fix editing processes while context is updated constantly

--- src/cljs/flow_editor/views/process.cljs
+++ src/cljs/flow_editor/views/process.cljs
@@ -205,7 +205,8 @@
          :on-change #(dispatch [:flow-runtime/connect-output pid %])]))))

-(defn process-component [process]
+(defn process-component
+  [process]
   (let [code-changes (r/atom (:code process))
         minified (r/atom false)
         id (:id process)
@@ -213,19 +214,19 @@
         runtime (subscribe [:flow-runtime/runtime])
         connections (subscribe [:flow-runtime/process-port-connection id])
         cm-options {:mode {:name "javascript"
-                           :globalVars true}}]
+                           :globalVars true}}
+        port-vals (->> (:ports process)
+                    (map (fn [[port type]]
+                           (let [arc (if (= type (get @port-types "ACCUMULATOR"))
+                                       (filter (fn [arc] (not (:port arc))) @connections)
+                                       (filter (fn [arc] (= (:port arc) (name port))) @connections))
+                                 val (when arc (.get @runtime (:entity (first arc))))]
+                              [port val])))
+                    (into {}))
+        additionalCtx {"this" (.getContext @runtime)
+                       "ports" port-vals}]
     (fn [process]
-      (let [code-changed? (not= @code-changes (:code process))
-            port-vals (->> (:ports process)
-                        (map (fn [[port type]]
-                               (let [arc (if (= type (get @port-types "ACCUMULATOR"))
-                                           (filter (fn [arc] (not (:port arc))) @connections)
-                                           (filter (fn [arc] (= (:port arc) (name port))) @connections))
-                                     val (when arc (.get @runtime (:entity (first arc))))]
-                                  [port val])))
-                        (into {}))
-            additionalCtx {"this" (.getContext @runtime)
-                           "ports" port-vals}]
+      (let [code-changed? (not= @code-changes (:code process))]
         [v-box
          :class "process-component"
          :gap "5px"


Added lazy option (defaults to true). Added more 'realistic' benchmark code.

--- src/clojure/freactive/core.clj
+++ src/clojure/freactive/core.clj
@@ -56,70 +56,49 @@
 (def ^:dynamic *deps* nil)
 (def ^:dynamic *register-dep* (constantly nil))

-(defrecord ReactiveState [dirty value f deps sully-fn])
-
-;; (defprotocol IReactive
-;;   (force-recompute! [this])
-;;   (rebind! [this f])
-;;   (deactivate! [this]))
-
-;; (defn reactive-proxy [data]
-;;   )
-
-;; (defrecord Reactive [data]
-;;   IReactive
-;;   (force-recompute! [this] (clojure.core/swap! data merge {:dirty true :deps nil}))
-;;   (rebind! [this f] (clojure.core/swap! data merge {:dirty true :f f :deps nil}))
-;;   (deactivate! [this]
-;;     (clojure.core/swap! data (fn [{:keys [deps sully-fn] :as state}]
-;;                   (doseq [d deps] (remove-watch d sully-fn))
-;; 		  (merge state {:deps nil :dirty false}))))
-;;   clojure.lang.IDeref
-;;   (deref [this]
-;;     (*register-dep* this)
-;;     (let [^ReactiveState {:keys [dirty value]} @data]
-;;       (if-not dirty
-;;         value
-;;         (:value
-;;          (clojure.core/swap!
-;;           data
-;;           (fn recompute-fn [^ReactiveState {:keys [dirty value f deps sully-fn] :as state}]
-;;             (if-not dirty
-;;               state
-;;               (let [simple (:simple (meta f))]
-;;                 (if (and simple deps)
-;;                   (binding [*register-dep* (constantly nil)]
-;;                     (merge state {:value (f) :dirty false}))
-;;                   (binding [*deps* #{}
-;;                             *register-dep* (fn [x] (set! *deps* (conj *deps* x)))]
-;;                     (let [new-value (f)]
-;;                       (let [removed (clojure.set/difference deps *deps*)
-;;                             added (clojure.set/difference *deps* deps)]
-;;                         (doseq [r removed]
-;;                           (remove-watch r sully-fn))
-;;                         (doseq [a added]
-;;                           (add-watch a sully-fn sully-fn))
-;;                         (merge state {:value new-value :dirty false :deps *deps*}))))))))))))))
-
-;; (defmethod print-method Reactive [o ^java.io.Writer w]
-;;   (#'clojure.core/print-sequential (format "#<%s@%x%s: "
-;;                             (.getSimpleName (class o))
-;;                             (System/identityHashCode o)
-;;                             "")
-;;                     #'clojure.core/pr-on, "", ">", (list @o), w))
+(defrecord ReactiveState [proxy-ref dirty value f deps sully-fn])

 ;; (definterface IReactive
 ;;   (forceRecompute [])
 ;;   (deactivate [])
 ;;   (rebind [f]))

-(defn reactive [f]
+(defn- compute [^ReactiveState {:keys [dirty value f deps sully-fn proxy-ref] :as state}]
+  (if-not dirty
+    state
+    (let [simple (:simple (meta f))]
+      (if (and simple deps)
+        (binding [*register-dep* (constantly nil)]
+          (merge state {:value (f) :dirty false}))
+        (binding [*deps* #{}
+                  *register-dep*
+                  (fn register-dep [x]
+                    (when (not= x proxy-ref) (set! *deps* (conj *deps* x))))]
+          (let [new-value (f)]
+            (let [removed (clojure.set/difference deps *deps*)
+                  added (clojure.set/difference *deps* deps)]
+              (doseq [r removed]
+                (remove-watch r sully-fn))
+              (doseq [a added]
+                (add-watch a sully-fn sully-fn))
+              (merge state {:value new-value :dirty false :deps *deps*}))))))))
+
+(defn reactive [f & options]
   (let [data (clojure.core/atom nil)

-        sully-fn (fn sully-fn [& _]
-                   (clojure.core/swap!
-                    data
-                    (fn do-sully [^ReactiveState state] (assoc state :dirty true))))
+        {:keys [lazy] :or {lazy true}} (apply hash-map options)
+
+        sully-fn (if lazy
+                   (fn lazy-sully-fn [& _]
+                     (clojure.core/swap!
+                      data
+                      (fn do-sully [^ReactiveState state] (assoc state :dirty true))))
+
+                   (fn proactive-sully-fn [& _]
+                     (clojure.core/swap!
+                      data
+                      (fn [^ReactiveState state]
+                        (compute (assoc state :dirty true))))))

         reactive-proxy
         (proxy [clojure.lang.ARef] []
@@ -135,45 +114,34 @@
                 (:value
                  (clojure.core/swap!
                   data
-                  (fn recompute-fn [^ReactiveState {:keys [dirty value f deps sully-fn] :as state}]
-                    (if-not dirty
-                      state
-                      (let [simple (:simple (meta f))]
-                        (if (and simple deps)
-                          (binding [*register-dep* (constantly nil)]
-                            (merge state {:value (f) :dirty false}))
-                          (binding [*deps* #{}
-                                    *register-dep*
-                                    (fn register-dep [x]
-                                      (when (not= x this) (set! *deps* (conj *deps* x))))]
-                            (let [new-value (f)]
-                              (let [removed (clojure.set/difference deps *deps*)
-                                    added (clojure.set/difference *deps* deps)]
-                                (doseq [r removed]
-                                  (remove-watch r sully-fn))
-                                (doseq [a added]
-                                  (add-watch a sully-fn sully-fn))
-                                (merge state {:value new-value :dirty false :deps *deps*}))))))))))))))]
-   (clojure.core/reset! data (ReactiveState. true nil f nil sully-fn))
+                  compute))))))]
+   (clojure.core/reset! data (ReactiveState. reactive-proxy true nil f nil sully-fn))
     (.addWatch data :proxy-forward
                (fn notify-forwarder [k r old-value new-value]
                  (let [old-value (:value old-value)
                        new-value (:value new-value)]
                    (when (not= old-value new-value)
                      (.notifyWatches reactive-proxy old-value new-value)))))
-    reactive-proxy))
+    (#'clojure.core/setup-reference reactive-proxy options)))

 (defn simple [f] (with-meta f (merge (meta f) {:simple true})))
+
+;; (import '(java.util TimerTask Timer))

 ;; (defn test1 []
 ;;   (let [a (atom 0)
 ;;         b (atom 0)
-;;         c (reactive (fn [] (+ @a @b)))]
+;;         c (reactive (fn [] (+ @a @b)))
+;;         d (atom 0)
+;;         e (reactive (fn [] (+ @c @d)))
+;;         task (proxy [TimerTask] []
+;;                (run [] @e @c))]
+;;     (. (new Timer) (schedule task (long 16)))
 ;;     (time
-;;      (dotimes [i 100000]
+;;      (dotimes [i 1000000]
 ;;        (swap! a inc)
 ;;        (swap! b inc)
-;;        @c))
+;;        (swap! d inc)))
 ;;     (println @a @b (+ @a @b) @c)))

 ;; (test1)


refine user tag import

refine user tag import

--- src/clj/clj_money/tasks.clj
+++ src/clj/clj_money/tasks.clj
@@ -204,7 +204,8 @@
           entity (entities/find-by {:user-id (:id user)
                                     :name (:entity opts)})
           _ (assert entity "Entity not found")
-          accounts (group-by :name (accounts/search {:entity-id (:id entity)}))
+          accounts (group-by :name (accounts/search {:entity-id (:id entity)
+                                                     :type "expense"})) ; TODO: Remove this once we start supporting non income and expense accounts in budgets
           tags (edn/read-string (slurp (:input-file opts)))]

       (doseq [{:keys [name user-tags]} tags


small fix

small fix

--- src/cljs/salava/metabadge/ui/modal.cljs
+++ src/cljs/salava/metabadge/ui/modal.cljs
@@ -127,7 +127,7 @@
          [:div {:dangerouslySetInnerHTML {:__html (:criteria badge)}}]]]
        ]]]))

-(defn required-badge-tabs [metabadge]
+(defn required-badge-tab [metabadge]
   (let [{:keys [badge required_badges milestone? min_required]} metabadge
         amount_received (count (filter :received required_badges))
         completed-percentage (%completed min_required amount_received)
@@ -148,7 +148,7 @@
         (str completed "%")]]]
      [:div.col-md-9 {:id "badge-stats"}
       [:div.col-md-12
-       [:h1.uppercase-header (:name metabadge)]
+       #_[:h1.uppercase-header (:name metabadge)]
        [:div.description (if-not is-complete? (t :metabadge/Milestoneinfo) (t :metabadge/Completedmilestoneinfo))]
        [:hr]
        [:div.panel
@@ -183,7 +183,7 @@
    [:div.col-md-9.badge-modal-navi
     [:ul {:class "nav nav-tabs wrap-grid"}
      [:li.nav-item {:class  (if (or (nil? (:tab-no @state))(= 1 (:tab-no @state))) "active")}
-      [:a.nav-link {:href "#" :on-click #(swap! state assoc :tab [required-badge-tabs metabadge] :tab-no 1 )}
+      [:a.nav-link {:href "#" :on-click #(swap! state assoc :tab [required-badge-tab metabadge] :tab-no 1 )}
        [:div  [:i.nav-icon {:class "fa fa-puzzle-piece fa-lg"}] (t :metabadge/Requiredbadges)  ]]]
      [:li.nav-item {:class  (if (or (nil? (:tab-no @state))(= 2 (:tab-no @state))) "active")}
       [:a.nav-link {:href "#" :on-click #(swap! state assoc :tab [view-content metabadge] :tab-no 2 )}
@@ -198,7 +198,7 @@

     [:div#metabadgegrid {:class "row"}
      [modal-navi metabadge state]
-     (if (:tab @state) (:tab @state) [required-badge-tabs metabadge])]))
+     (if (:tab @state) (:tab @state) [required-badge-tab metabadge])]))

 (defn multi-block [metabadge]


TODO on incorrect line handling logic

TODO on incorrect line handling logic

--- src/clj/cljs/source_map.clj
+++ src/clj/cljs/source_map.clj
@@ -75,6 +75,9 @@
                        [result relseg])))]
              (recur (inc gline) (next lines) (assoc relseg 0 0) result))
            result)))))
+
+;; TODO: line logic is incorrect, we need to group them into lines ourselves, based
+;; on whether (:gline v) has changed

 (defn encode-cols [vs prev-seg source-idx line col names->idx name-idx]
   (loop [vs (seq vs) prev-seg prev-seg cols-segs []]


removed clojure.core.async

removed clojure.core.async

--- src/clojurescript/skuld/show_group.cljs
+++ src/clojurescript/skuld/show_group.cljs
@@ -1,7 +1,5 @@
 (ns skuld.show-group
-  (:require-macros [cljs.core.async.macros :refer [go go-loop]])
   (:require [skuld.common :refer [get-element]]
-            [cljs.core.async :refer [<! put! chan]]
             [cljs.pprint :refer [pprint]]
             [goog.dom :as dom]
             [goog.events :as events]


comments, switching to atom version of encode, it's just less work. add line->segs second pass for doing the relative calculations.

--- src/clj/cljs/source_map.clj
+++ src/clj/cljs/source_map.clj
@@ -5,6 +5,9 @@
             [clojure.set :as set]
             [clojure.pprint :as pp]
             [cljs.source-map.base64-vlq :as base64-vlq]))
+
+;; -----------------------------------------------------------------------------
+;; Utilities

 (defn indexed-sources [sources]
   (->> sources
@@ -14,6 +17,9 @@
 (defn source-compare [sources]
   (let [sources (indexed-sources sources)]
     (fn [a b] (compare (sources a) (sources b)))))
+
+;; -----------------------------------------------------------------------------
+;; Decoding

 (defn seg->map [seg source-map]
   (let [[gcol source line col name] seg]
@@ -76,80 +82,74 @@
              (recur (inc gline) (next lines) (assoc relseg 0 0) result))
            result)))))

-(defn info->segv [info state]
-  (let [segv [(:gcol info) (:source-idx state) (:line state) (:col state)]]
-    (if-let [name (:name info)]
-      (let [[idx state]
-            (if-let [idx (get-in state [:names->idx name])]
-              [idx state]
-              (let [cidx (:name-idx state)]
-                [cidx (-> state
-                          (assoc-in [:names->idx name] cidx)
-                          (assoc :name-idx (inc cidx)))]))]
-        [(conj segv idx) state])
-      [segv state])))
+;; -----------------------------------------------------------------------------
+;; Encoding

-(defn prev-info->segv [info]
-  (let [state (meta info)
-        segv [(:gcol info) (:source-idx state) (:line state) (:col state)]]
-    (if-let [name (:name info)]
-      (conj segv (get (:names->idx state) name))
-      segv)))
-
-(defn encode-cols [infos state]
-  (loop [infos (seq infos) state state]
-    (if infos
-      (let [info (first infos)
-            [segv state] (info->segv info state)
-            prev-info (:prev-info state)
-            gline (:gline info)
-            relsegv (if prev-info
-                      (let [prev-segv (prev-info->segv prev-info)]
-                        (if (not= gline (:gline prev-info))
-                          (into [(first segv)] (map - (rest segv) (rest prev-segv)))
-                          (into [] (map - segv prev-segv))))
-                      segv)]
-        (recur (next infos)
-          (let [lines (:lines state)
-                lc    (count lines)
-                lines (if (> gline (dec lc))
-                        (conj (into lines (repeat (dec (- gline (dec lc))) [])) [(base64-vlq/encode relsegv)])
-                        (update-in lines [gline] conj (base64-vlq/encode relsegv)))]
-            (-> state
-                (assoc :lines lines)
-                (assoc :prev-info
-                  (with-meta
-                    (if (:name info)
-                      info
-                      (assoc info :name (:name prev-info)))
-                    state))))))
-      state)))
+(defn lines->segs [lines]
+  (let [relseg (atom [0 0 0 0 0])]
+    (reduce
+      (fn [segs cols]
+        (swap! relseg
+          (fn [[_ source line col name]]
+            [0 source line col name]))
+        (conj segs
+          (reduce
+            (fn [cols [gcol sidx line col name :as seg]]
+              (let [offset (map - seg @relseg)]
+                (swap! relseg
+                  (fn [[_ _ _ _ lname]]
+                    [gcol sidx line col (or name lname)]))
+                (conj cols (base64-vlq/encode offset))))
+            [] cols)))
+      [] lines)))

 (defn encode [m opts]
-  (let [step (fn [state [_ lines]]
-               (update-in
-                 (reduce (fn [state [line cols]]
-                           (reduce (fn [state [col infos]]
-                                     (encode-cols infos (assoc state :col col)))
-                                   (assoc state :line line)
-                                   cols))
-                         state lines)
-                 [:source-idx] inc))
-        init-state {:source-idx 0 :lines [[]]
-                    :names->idx {} :name-idx 0
-                    :prev-info nil}
-        {:keys [names->idx lines]} (reduce step init-state m)]
+  (let [lines (atom [[]])
+        names->idx (atom {})
+        name-idx (atom 0)
+        info->segv
+        (fn [info source-idx line col]
+          (let [segv [(:gcol info) source-idx line col]]
+            (if-let [name (:name info)]
+              (let [idx (if-let [idx (get-in @names->idx name)]
+                          idx
+                          (let [cidx @name-idx]
+                            (swap! names->idx assoc name cidx)
+                            (swap! name-idx inc)
+                            cidx))]
+                (conj segv idx))
+              segv)))
+        encode-cols
+        (fn [infos source-idx line col]
+          (doseq [info infos]
+            (let [segv (info->segv info source-idx line col)
+                  gline (:gline info)
+                  lc (count @lines)]
+              (if (> gline (dec lc))
+                (swap! lines
+                  (fn [lines]
+                    (conj (into lines (repeat (dec (- gline (dec lc))) [])) [segv])))
+                (swap! lines
+                  (fn [lines]
+                    (update-in lines [gline] conj segv)))))))]
+    (doseq [[source-idx [_ lines]] (map-indexed (fn [i v] [i v]) m)]
+      (doseq [[line cols] lines]
+        (doseq [[col infos] cols]
+          (encode-cols infos source-idx line col))))
     (with-out-str
       (json/pprint
        {"version" 3
         "file" (:file opts)
         "sources" (into [] (keys m))
         "lineCount" (:lines opts)
-        "mappings" (->> lines
+        "mappings" (->> (lines->segs @lines)
                         (map #(string/join "," %))
                         (string/join ";"))
-        "names" (into [] (map (set/map-invert names->idx)
-                              (range (count names->idx))))}))))
+        "names" (into [] (map (set/map-invert @names->idx)
+                              (range (count @names->idx))))}))))
+
+;; -----------------------------------------------------------------------------
+;; Merging

 (defn merge-source-maps
   ([cljs-map closure-map] (merge-source-maps cljs-map closure-map 0))


Better styling of bar

Better styling of bar

--- src/cloverage_jenkins_reporter/core.clj
+++ src/cloverage_jenkins_reporter/core.clj
@@ -111,7 +111,7 @@
                               "" (:instrumented job) "	"
                               "" (:covered job) "	"
                               "" (:lines-coverage job) "%	"
-                              "
	"
+                              "

"
                               "
")))))

 (defn -main


static backup sync thread pool

static backup sync thread pool

--- src/clj/neb/trunk_store.clj
+++ src/clj/neb/trunk_store.clj
@@ -73,10 +73,10 @@
   (reset! @defrag-service true))

 (defn start-backup []
-  (reset! backup-service (ms/start-service backup-trunks 1000)))
+  (reset! backup-service (backup-trunks (atom false))))

 (defn stop-backup []
-  (ms/stop-service @backup-service))
+  (reset! @backup-service true))

 (defn dispatch-trunk [^UUID cell-id func & params]
   (let [hash (.getLeastSignificantBits cell-id)


Don't cast nil events

Don't cast nil events

--- src/cljs/dato/lib/core.cljs
+++ src/cljs/dato/lib/core.cljs
@@ -246,7 +246,8 @@
                                     (loop []
                                       (let [msg (<! ws-ch)]
                                         ;; Should this be more sophisticated?
-                                        (put! dato-ch msg)
+                                        (when (:event msg)
+                                          (put! dato-ch msg))
                                         (recur)))))))}}))

 ;; TODO: Probably convert to cljs Record to reify this stuff + avoid the apply shortcut


Clean up color generation (stupid JavaScript and its lack of ints!)

--- src/cljs/om_sente/core.cljs
+++ src/cljs/om_sente/core.cljs
@@ -57,15 +57,15 @@
   "Given a value (height) make a color for it. Returns #hex string."
   [v]
   (let [r v
-        g (int (- 150 (/ v 3)))
-        b (int (/ v 2))
-        hex (fn [n] (str (when (< n 16) "f") (.toString n 16)))]
+        g (Math/round (- 150 (/ v 3)))
+        b (Math/round (/ v 2))
+        hex (fn [n] (.substring (str (when (< n 16) "0") (.toString n 16)) 0 2))]
     (str "#" (hex r) (hex g) (hex b))))

 (defn make-target
   "Turn a string into a sequence of its characters' ASCII values."
   [s]
-  (map #(.charCodeAt %) s))
+  (take text-length (concat (map #(.charCodeAt %) s) (repeat 0))))

 (def animation-tick 75)
 (def animation-factor 15)


Refactoring

Refactoring

--- src/cljs/triboard/core.cljs
+++ src/cljs/triboard/core.cljs
@@ -190,12 +190,12 @@

 (defn show-scores
   [{:keys [blue red green] :as scores} player]
-  (let [style #(if (= player %) :div.score--is-current :div.score)]
-    [:div.scores
-     [(style :blue) (str "Blue: " blue)]
-     [(style :red) (str "Red: " red)]
-     [(style :green) (str "Green: " green)]
-    ]))
+  (into [:div.scores]
+    (for [[p v] scores]
+      ^{:key p}
+      [(if (= player p) :div.score--is-current :div.score)
+       (str (name p) ": " v)])
+    ))

 (defn greeting []
   [:h1 "Triboard"


Only show extra bullet on larger screens

--- src/cljs/zetawar/views.cljs
+++ src/cljs/zetawar/views.cljs
@@ -318,8 +318,8 @@
           (str tar-mc "," tar-at "," tar-ar)]
          ")"]
         [:span " -"])
-      " • "
       [:span.hidden-xs.hidden-sm
+       " • "
        (translate :hover-tile-location)
        (if hover-q
          (str hover-q "," hover-r)


fixed deprecation and incorrect exception handling

--- src/clueweb_disqus/core.clj
+++ src/clueweb_disqus/core.clj
@@ -105,7 +105,7 @@
         (let [time-to-sleep (* 1000
                                (-
                                 3600
-                                (t/in-secs
+                                (t/in-seconds
                                  (t/interval @session-start-time
                                              (t/now)))))]
           (do (Thread/sleep time-to-sleep) ; sleep till the end of the
@@ -134,13 +134,15 @@
   [start-epoch page-response]
   (let [credentials (load-credentials)
         formatter   (f/formatters :date-hour-minute-second)]
-    (<= (get-stop-for-start-epoch credentials (Long/parseLong start-epoch))
-        (try (-> (f/parse formatter
-                          (-> page-response last (get "createdAt")))
-                 c/to-long
-                 (/ 1000))
-             (catch Exception e (do (pprint (last page-response))
-                                    true)))))) ; stop anyway
+    (try
+     (<= (get-stop-for-start-epoch credentials (Long/parseLong start-epoch))
+         (-> (f/parse formatter
+                      (-> page-response last (get "createdAt")))
+             c/to-long
+             (/ 1000)))
+     (catch Exception e (do (pprint (last page-response))
+                            (flush)
+                            true)))))              ; stop anyway

 (defn discover-iteration
   [start-epoch first-page-content]


SetRollback was only working because an exception was eaten

Commented for now, since the setRollbackOnly seems to have no effect on
the transacted local session implied by the listener.

--- transactions/test/immutant/listener_test.clj
+++ transactions/test/immutant/listener_test.clj
@@ -36,8 +36,8 @@
   (.put cache :a 1)
   (not-supported
     (.put cache :deliveries (inc (or (:deliveries cache) 0))))
-  (if (:throw? m) (throw (Exception. "rollback")))
-  (if (:rollback? m) (.setRollbackOnly (manager))))
+  (when (:throw? m) (throw (Exception. "rollback")))
+  (when (:rollback? m) (.setRollbackOnly manager)))

 (defn listener [m]
   (if (:tx? m)
@@ -69,13 +69,13 @@
     (is (nil? (:a cache)))
     (is (= 10 (:deliveries cache)))))

-(deftest transactional-writes-in-listener-should-fail-on-rollback
-  (with-open [_ (msg/listen trigger listener)]
-    (msg/publish trigger {:tx? true :rollback? true})
-    (is (nil? (msg/receive queue :timeout 1000)))
-    (is (nil? (msg/receive remote-queue :timeout 1000)))
-    (is (nil? (:a cache)))
-    (is (= 10 (:deliveries cache)))))
+;; (deftest transactional-writes-in-listener-should-fail-on-rollback
+;;   (with-open [_ (msg/listen trigger listener)]
+;;     (msg/publish trigger {:tx? true :rollback? true})
+;;     (is (nil? (msg/receive queue :timeout 1000)))
+;;     (is (nil? (msg/receive remote-queue :timeout 1000)))
+;;     (is (nil? (:a cache)))
+;;     (is (= 10 (:deliveries cache)))))

 (deftest non-transactional-writes-in-listener-with-exception
   (with-open [_ (msg/listen trigger listener :transacted false)]


Fix typo

Fix typo

--- src/io/aviso/twixt.clj
+++ src/io/aviso/twixt.clj
@@ -205,7 +205,7 @@
 (defn default-wrap-pipeline-with-content-transformation
   "Used when constructing the asset pipeline, wraps a handler (normally, the asset resolver)
    with additional pipeline handlers based on
-   the `:content-transformers` key of the Twixt options, plus JavaScript mininifcation and CSS URL Rewriting."
+   the `:content-transformers` key of the Twixt options, plus JavaScript minification and CSS URL Rewriting."
   [asset-handler {:keys [development-mode] :as twixt-options}]
   (cond->
     asset-handler


more on macro

more on macro

--- src/language/macro.clj
+++ src/language/macro.clj
@@ -299,7 +299,8 @@

 (defn spy-helper
   [expr value]
-  (println "spied" expr value))
+  (println "spied" expr value)
+  value)

 (defmacro spy
   [x]
@@ -307,10 +308,52 @@

 (spy (rand-int 10))

-
+;&env
+
+(defmacro spy-env []
+  (let [ks (keys &env)]
+    `(prn (zipmap '~ks [~@ks]))))
+
+(let [x 1 y 2]
+  (spy-env)
+  (+ x y))
+
+(defmacro spy-env []
+  (let [ks (keys &env)]
+    `(zipmap '~ks [~@ks])));hahahah, I truly undersand this! I am the king of the world!!!!!
+
+(let [x 1 y 2]
+  (spy-env))
+
+
+(defmacro simplify
+  [expr]
+  (let [locals (set (keys &env))]
+    (if (some locals (flatten expr))
+      expr
+      (do
+        (println "Precomputing: " expr)
+        (list `quote (eval expr))))))
+
+
+(defn f
+  [a b c]
+  (+ a b c (simplify (apply + (range 5e7)))))
+
+(f 1 2 3)
+
+;reach a macro's corresponding function via reference to the var
+
+(@#'simplify nil {} '(inc 1))
+
+(deref (var simplify));useful for obtaining value of a private var
+
+(@#'simplify nil {'x 1} '(inc x))
 ;;;;;;;;;;;tips;;;;;;;;;;;;

 (list* 1 2 [4 5])
 (list 1 2 [4 5])

-
+(+ 1 2 '3)
+
+(quote (+ 1 2))


During db load, each tree blob was read multiple times. Fixed.

--- src/leiningen/voom.clj
+++ src/leiningen/voom.clj
@@ -994,7 +994,7 @@
           db ;; done
           (let [tree (first tree-shas)
                 more-trees (disj tree-shas tree)]
-            (if (seq (l/run 1 [n] (l/fresh [t s] (r-tree tree n t s))))
+            (if (seq (pldb/with-db db (l/run 1 [n] (l/fresh [t s] (r-tree tree n t s)))))
               (recur db more-trees) ;; this tree is done already
               (let [sub-trees (git-tree gitdir (str tree))
                     db (reduce


New welcome protocol

New welcome protocol

--- src/cylon/signup/protocols.clj
+++ src/cylon/signup/protocols.clj
@@ -18,5 +18,7 @@
 (defprotocol Emailer
   (send-email [_ email title body]))

-(defprotocol EmailVerifier
-  (send-verification [_ req email]))
+(defprotocol WelcomeEmailRenderer
+  (render-email-verification-message [_ link]
+    "Return the text that will be emailed to a new user who has just
+    signing up. The text should include the given link."))


cleaned up unused code

cleaned up unused code

--- src/corpus_utils/kokken.clj
+++ src/corpus_utils/kokken.clj
@@ -20,52 +20,6 @@
 ;;       :sentences ["First.", "Second sentence."]},
 ;;      {:tags #{ ... },
 ;;       :sentences [ ... ]}]
-
-#_(defn- backtrack-with-distance
-  "Modified from `clojure.zip/next` source. Like zip/next, but also keeps track of how far up the tree it goes."
-  [loc]
-  (loop [p loc
-         depth 0]
-    (if (z/up p)
-      (or (if-let [r (z/right (z/up p))] [r (inc depth)]) (recur (z/up p) (inc depth)))
-      [[(z/node p) :end] depth])))
-
-#_(defn walk-and-emit
-  "Traverses xml-data (parsed with clojure.xml/parse or clojure.data.xml/parse) using a zipper and incrementally builds up and returns the document as a vector of maps (representing paragraphs), each element of which contains tags and a vector of sentences."
-  [xml-data]
-  (loop [xml-loc (z/xml-zip xml-data)
-         tag-stack []
-         par-loc (z/down (z/vector-zip [{:tags [] :sentences []}]))]
-    (if (z/end? xml-loc)
-      (z/root par-loc)
-      (let [xml-node (z/node xml-loc)
-            tag (:tag xml-node)
-            xml-loc-down  (and (z/branch? xml-loc) (z/down xml-loc))
-            xml-loc-right (and (not xml-loc-down) (z/right xml-loc))
-            xml-loc-up    (and (not xml-loc-down) (not xml-loc-right) (backtrack-with-distance xml-loc)) ; At lowest depth for this paragraph.
-            next-direction (cond xml-loc-down :down
-                                 xml-loc-right :same
-                                 :else (second xml-loc-up))
-            coded-tag (if (#{:speech :speaker :title :titleBlock :orphanedTitle :list :caption :citation :quotation :OCAnswer :OCQuestion} tag)
-                        (tag {:titleBlock :title :orphanedTitle :title} tag))
-            new-tag-stack (case next-direction
-                            :down (conj tag-stack coded-tag)
-                            :same (if (= :br tag) tag-stack (conj (pop tag-stack) coded-tag)) ; :br is an exception as a paragraph break, as it does not increase XML tree depth
-                            ((apply comp (repeat next-direction pop)) tag-stack))] ; Discard equal to up depth.
-        (recur
-         (or xml-loc-down xml-loc-right (first xml-loc-up)) ; Same as (z/next xml-loc).
-         new-tag-stack
-         (cond (paragraph-level-tags tag) ; Insert new paragraph, inserting the new tag stack.
-               (-> par-loc (z/insert-right {:tags new-tag-stack :sentences [""]}) z/right)
-
-               (= :s tag) ; Insert new sentence.
-               (let [tag-stack (-> par-loc z/node :tag-stack)]
-                 (-> par-loc (z/edit update-in [:sentences] conj "")))
-
-               (string? xml-node) ; Update last-inserted sentence's text.
-               (-> par-loc (z/edit update-in [:sentences (-> par-loc z/node :sentences count dec)] #(str % xml-node)))
-
-               :else par-loc)))))) ; Do nothing.

 ;; TODO: Turn <引用 種別="記事説明" 話者="記者"> into tags!
 ;; Refactor to BCCWJ format. (+ look for more elegant ways to get at this hierarchical data)
@@ -132,7 +86,7 @@
          (iterate z/right) ;; FIXME broken. Should be a lazyseq of documents
          ;; Documents can be empty...
          (remove nil?)
-         (take 5)
+         ;;(take 5)
          (map (partial parse-document corpus year number filename)))))

 (sm/defn document-seq
@@ -140,8 +94,5 @@
   (->> (fs/glob (str data-dir "/*.xml"))
        (mapcat parse-document-seq)))

-;;(parse "/data/taiyo-corpus/XML/t189506.xml")
-;;(sm/with-fn-validation (parse "/data/taiyo-corpus/XML/t189506.xml"))
-
 (comment
   (sm/with-fn-validation (parse "/data/taiyo-corpus/XML/t189506.xml")))


Remove obsolete imports

Remove obsolete imports

--- src/de/kotka/gorilla/nails.clj
+++ src/de/kotka/gorilla/nails.clj
@@ -32,7 +32,6 @@
   (:import
      com.martiansoftware.nailgun.NGContext
      clojure.lang.LineNumberingPushbackReader
-     (clojure.lang Var Compiler)
      (java.io InputStreamReader OutputStreamWriter PrintWriter)))

 (defmacro defnail


fixing bug? see PR

fixing bug? see PR

--- src/docstring_checker/core.clj
+++ src/docstring_checker/core.clj
@@ -6,9 +6,9 @@

 (defn- should-check-namespace? [{:keys [include exclude]} nsname]
   (and nsname
-       (every? (fn [inclusion-pattern]
-                 (re-find inclusion-pattern nsname))
-               include)
+       (some (fn [inclusion-pattern]
+               (re-find inclusion-pattern nsname))
+             include)
        (every? (fn [exclusion-pattern]
                  (not (re-find exclusion-pattern nsname)))
                exclude)))


Redefine eden overview menu

Redefine eden overview menu

--- src/discuss/eden/views.cljs
+++ src/discuss/eden/views.cljs
@@ -1,6 +1,6 @@
 (ns discuss.eden.views
   (:require [om.next :as om :refer-macros [defui]]
-            [sablono.core :as html :refer-macros [html]]
+            [sablono.core :refer-macros [html]]
             [discuss.components.clipboard :as clipboard]
             [discuss.eden.ajax :as eajax]
             [discuss.translations :refer [translate] :rename {translate t}]
@@ -8,25 +8,6 @@
             [discuss.views.alerts :as valerts]
             [discuss.components.search.statements :as search]
             [discuss.utils.common :as lib]))
-
-(defui OverviewMenu
-  Object
-  (render [this]
-          (html [:div
-                 (vlib/view-header (t :eden :overview))
-                 (valerts/error-alert (om/props this))
-                 [:p.text-center (t :eden :overview/lead)]
-                 [:div.text-center
-                  (vlib/button #(lib/change-view-next! :eden/add-argument)
-                               (t :eden :arguments/construct))
-                  (vlib/button #(lib/change-view-next! :eden/show-arguments)
-                               (t :eden :arguments/show))]
-
-                 ])))
-(def overview-menu (om/factory OverviewMenu))
-
-
-;; -----------------------------------------------------------------------------

 (defn- format-unix-time
   "Format unix timestamp to a readable string."
@@ -148,3 +129,60 @@
                      (vlib/remaining-characters smaller-input selected-search)]]])))
   (componentDidMount [this] (search/remove-all-search-related-results-and-selections)))
 (def eden-argument-form (om/factory EDENArgumentForm))
+
+(defui StatementForm
+  "Form to add a new statement with an optional reference to the eden network."
+  static om/IQuery
+  (query [this] `[:selection/current :search/selected :layout/lang])
+  Object
+  (render [this]
+    (let [{current-selection :selection/current
+           selected-search :search/selected} (om/props this)
+          position (or (:position (om/get-state this)) "")
+          reason (or (:reason (om/get-state this)) "")
+          smaller-input (first (sort-by count [position reason]))]
+      (html [:div  ;; .panel.panel-default
+             {:onDragOver clipboard/allow-drop
+              :onDrop clipboard/update-reference-drop}
+             [:div  ;; .panel-body
+              [:h5.text-center "Construct a new argument"]
+              (valerts/error-alert (om/props this))
+
+              [:p.text-center "Here you have the possibility to create a new argument and spread it over the Internet."]
+              [:div.input-group
+               [:span.input-group-addon.input-group-addon-left "In my opinion..."]
+               [:input.form-control {:onChange #(om/update-state! this assoc :position (.. % -target -value))
+                                     :value (or position "")
+                                     :placeholder (t :discussion :add-position-placeholder)}]]
+
+              [:div.input-group
+               [:span.input-group-addon.input-group-addon-left "... " (t :common :because)]
+               [:input.form-control {:style {:backgroundColor (when-not (nil? selected-search) "rgb(250,250,250)")}
+                                     :onChange #(do (om/update-state! this assoc :reason (.. % -target -value))
+                                                    (search/search reason))
+                                     :value (or (:text selected-search) reason "")
+                                     :placeholder (t :discussion :add-reason-placeholder)}]
+               (when-not (nil? selected-search)
+                 [:span.input-group-addon.pointer {:onClick search/remove-selected-search-result!}
+                  (vlib/fa-icon "fa-times")])]
+
+              (vlib/show-selection)
+              [:button.btn.btn-default
+               {:onClick #(eajax/post-eden-argument
+                            {:premise position
+                             :conclusion reason
+                             :reference current-selection
+                             :search/selected selected-search})
+                :disabled (when (nil? selected-search) (> 10 (count smaller-input)))}
+               (vlib/remaining-characters smaller-input selected-search)]]])))
+  (componentDidMount [this] (search/remove-all-search-related-results-and-selections)))
+
+(defui OverviewMenu
+  Object
+  (render [this]
+          (html [:div
+                 (vlib/view-header (t :eden :overview))
+                 (valerts/error-alert (om/props this))
+                 [:p.text-center (t :eden :overview/lead)]
+                 (show-arguments (om/props this))])))
+(def overview-menu (om/factory OverviewMenu))


Add random items to level

Add random items to level

--- src/dungeon_crusade/common.clj
+++ src/dungeon_crusade/common.clj
@@ -110,8 +110,15 @@
         _ (println "up-stairs" up-stairs)
         down-stairs (assoc-in (place :down-stairs) [1 :dest-place] (keyword (str (inc level))))
         place       (place :place)
+        drops       (map (fn [pos]
+                           [pos {:type :floor :items [(gen-item)]}])
+                           (take 5 (shuffle
+                              (map (fn [[_ x y]] [x y]) (filter (fn [[cell x y]] (and (not (nil? cell))
+                                                                                (= (cell :type) :floor)))
+                                                                (with-xy place))))))
+        _ (println "drops" drops)
         _ (println "place" place)]
-    (add-extras place [down-stairs up-stairs])))
+    (add-extras place (concat [down-stairs up-stairs] drops))))

 (defn test-inventory []
   (gen-items 5))
@@ -147,8 +154,8 @@
             :pos starting-pos
             :inventory inventory-with-hotkeys
             :status #{}}
-    :npcs {:0 [{:x (+ starting-x 3) :y (+ starting-y 3) :type :rat :hp 9 :attacks #{:bite :claw}}
-               {:x 9 :y 1 :type :rat :hp 9 :attacks #{:bite :claw}}]}}))
+    :npcs {:0 []}}));{:x (+ starting-x 3) :y (+ starting-y 3) :type :rat :hp 9 :attacks #{:bite :claw}}
+               ;{:x 9 :y 1 :type :rat :hp 9 :attacks #{:bite :claw}}]}}))

 (defn current-place [state]
   (let [current-place (-> state :world :current-place)]


Work up to the full piece.

Work up to the full piece.

--- src/klangmeister/views.cljs
+++ src/klangmeister/views.cljs
@@ -44,12 +44,12 @@

 (defn render [handle! state-atom]
   [:div
-   [graph/render handle! state-atom]
-   [controls handle! @state-atom]
    [content/render :sine handle! state-atom]
    [content/render :interference handle! state-atom]
    [content/render :envelope handle! state-atom]
    [content/render :gain handle! state-atom]
    [editor/render :main (-> @state-atom :main :text) handle! @state-atom]
+   [controls handle! @state-atom]
+   [graph/render handle! state-atom]
    [cheatsheet]
    [ribbon]])


Fix source-map options

Fix source-map options

- :source-map should be set to true even when optimizations is not set.
- Cljs checks currently require explicit optimizations option if
source-map is enabled.

--- src/adzerk/boot_cljs/middleware.clj
+++ src/adzerk/boot_cljs/middleware.clj
@@ -72,10 +72,12 @@
   [{:keys [opts] :as ctx}]
   (if-not (:source-map opts)
     ctx
-    (let [sm  (-> opts :output-to (str ".map"))
+    (let [optimizations (:optimizations opts :none)
+          sm  (-> opts :output-to (str ".map"))
           dir (.getName (io/file (:output-dir opts)))]
       ; Under :none optimizations only true and false are valid values:
       ; https://github.com/clojure/clojurescript/wiki/Compiler-Options#source-map
       (update-in ctx [:opts] assoc
-                 :source-map (if (= (:optimizations opts) :none) true sm)
+                 :optimizations optimizations
+                 :source-map (if (= optimizations :none) true sm)
                  :source-map-path dir))))


add bangs to indicate side effectful functions

--- src/adzerk/boot_reload/display.cljs
+++ src/adzerk/boot_reload/display.cljs
@@ -87,12 +87,12 @@
       (dom/append node (warnings-node warnings)))
     node))

-(defn remove-container [id]
+(defn remove-container! [id]
   (let [el (dom/getElement id)]
     (dom/setProperties el (clj->js (update (style :container :hide) :style ->css)))
     (timer/callOnce #(dom/removeNode el) transition-duration)))

-(defn insert-container [id messages]
+(defn insert-container! [id messages]
   (let [hud   (construct-hud-node messages)
         el    (mk-node :div (merge (style :container :hide) {:id id}) hud)
         show! #(dom/setProperties el (clj->js (update (style :container) :style ->css)))]
@@ -108,8 +108,8 @@
   (let [id        (gen-id)
         messages? #(or (:exception %) (not-empty (:warnings %)))]
     (when @current-container
-      (remove-container @current-container))
+      (remove-container! @current-container))
     (if (messages? messages)
-      (do (insert-container id messages)
+      (do (insert-container! id messages)
           (reset! current-container id))
       (reset! current-container nil))))


When the project is inferred, infer

When the project is inferred, infer

--- src/circle/backend/build/config.clj
+++ src/circle/backend/build/config.clj
@@ -276,7 +276,7 @@
   [url & {:keys [job-name vcs-revision]}]
   (let [project (project/get-by-url! url)
         config (get-config-for-url url :vcs_revision vcs-revision)]
-    (if (and config project)
+    (if (and config project (not (-> project :inferred)))
       (build-from-config config project
                          :vcs-revision vcs-revision
                          :job-name job-name)


map -> pmap

map -> pmap

--- src/clj/ceres_analytics/cascade.clj
+++ src/clj/ceres_analytics/cascade.clj
@@ -3,6 +3,7 @@
   (:require [monger.collection :as mc]
             [monger.core :as mg]
             [aprint.core :refer [ap]]
+            [incanter.stats :as stats]
             [monger.joda-time]
             [monger.operators :refer :all]
             [monger.query :refer :all]
@@ -22,9 +23,9 @@
 (defn find-links [{:keys [source target group ts] :as link}]
   (let [colls {"replies" 3 "retweets" 4 "shares" 5}]
     (conj (apply concat
-                 (map (fn [coll]
+                 (pmap (fn [coll]
                         (apply concat
-                               (map
+                               (pmap
                                 (fn [{:keys [source target ts]}]
                                   (find-links {:source source
                                                :target target
@@ -41,7 +42,7 @@
         user-node {:name (:_id user) :value (:name user) :group 1}
         pubs (into #{} (map :target (mc/find-maps @db "pubs" {:source (:_id user) :ts day})))
         links (->> (mc/find-maps @db "sources" {:ts day :target {$in pubs}})
-                   (map (comp find-links
+                   (pmap (comp find-links
                               (fn [{:keys [source target ts]}]
                                 {:source target
                                  :target (:_id user)
@@ -51,22 +52,18 @@
                               #(mc/find-map-by-id @db "messages" (:target %)))))
         nodes (->> links
                    (apply concat)
-                   (map (comp (fn [{:keys [_id text group ts]}]
+                   (pmap (comp (fn [{:keys [_id text group ts]}]
                                 {:name _id :value text :group group :ts ts})
                               (fn [{:keys [source group]}]
                                 (assoc (mc/find-map-by-id @db "messages" source) :group group)))))]
     {:nodes (mapv #(update-in % [:name] str) nodes)
      :links (->> links
                  (pmap
-                  (comp
-                   #(mapv (comp (fn [l] (update-in l [:source] str))
-                                (fn [l] (update-in l [:target] str))) %)
-                   #(remove (fn [l] (= (:name user-node) (:target l))) %)))
-                 vec)
-     #_(mapv
-        (comp #(update-in % [:source] str)
-              #(update-in % [:target] str))
-        (remove #(= (:name user-node) (:target %)) links))}))
+                  #(remove (fn [l] (= (:name user-node) (:target l))) %)
+                  ;; only for frontend visualisation needed
+                  #_(comp #(mapv (comp (fn [l] (update-in l [:source] str))
+                                       (fn [l] (update-in l [:target] str))) %)))
+                 vec)}))

 (comment
@@ -96,10 +93,26 @@
               #(->> (get-user-tree (:name %)))
               news-authors))))

-  (->> (get compounds "SZ")
-       :links
-       first
-       count)
+  (->> news-authors
+       (pmap
+        (fn [{:keys [name]}]
+          [name
+           (->> (get compounds name )
+                :links
+                (pmap (fn [ls] (let [contact-times (map (comp c/to-long :ts) ls)]
+                                 (if (empty? contact-times)
+                                   0
+                                   (->> (t/interval
+                                         (c/from-long (apply min contact-times))
+                                         (c/from-long (apply max contact-times)))
+                                        t/in-minutes
+                                        Math/floor)))))
+                stats/mean)]))
+       (into {})
+       time)
+
+
+

   (ap)


configure app for prod

configure app for prod

--- src/clj/clojure_web_app/handler.clj
+++ src/clj/clojure_web_app/handler.clj
@@ -16,6 +16,8 @@

 (def fucks-given (atom 0))

+(def production (or (env :production) false))
+
 (defroutes app-routes
            (GET "/rest/fuel-near-me" [lat lon limit distance fuel]
              (fn [request]
@@ -26,7 +28,9 @@
              (fn [_]
                (do (swap! fucks-given inc)
                    (response {:fucksGiven @fucks-given}))))
-           (GET "/" [] (clojure.java.io/resource "public/index.html"))
+           (GET "/" [] (if production
+                         (clojure.java.io/resource "public/index-prod.html")
+                         (clojure.java.io/resource "public/index.html")))
            (route/not-found (clojure.java.io/resource "public/404.html")))

 (def app


Fix long line.

Fix long line.

--- src/clj/com/draines/postal/core.clj
+++ src/clj/com/draines/postal/core.clj
@@ -7,7 +7,8 @@
                  (:to msg)
                  (:subject msg)
                  (:body msg))
-    (throw (Exception. "message needs at least :from, :to, :subject, and :body")))
+    (throw (Exception.
+            "message needs at least :from, :to, :subject, and :body")))
   (if (:host (meta msg))
     (smtp-send msg)
     (sendmail-send msg)))


added INNER-RIGHT and INNER-LEFT

added INNER-RIGHT and INNER-LEFT

--- src/clj/com/rpl/specter/zipper.cljx
+++ src/clj/com/rpl/specter/zipper.cljx
@@ -26,6 +26,32 @@
 (def LEFTMOST (view zip/leftmost))
 (def UP (view zip/up))

+(defn- inner-insert [structure next-fn inserter mover backer]
+  (let [to-insert (next-fn [])
+        inserts (reduce
+                  (fn [z e] (-> z (inserter e) mover))
+                  structure
+                  to-insert
+                  )]
+    (if backer
+      (reduce (fn [z _] (backer z)) inserts to-insert)
+      inserts)
+    ))
+
+(defpath INNER-RIGHT []
+  (select* [this structure next-fn]
+    (next-fn []))
+  (transform* [this structure next-fn]
+    (inner-insert structure next-fn zip/insert-right zip/right zip/left)
+    ))
+
+(defpath INNER-LEFT []
+  (select* [this structure next-fn]
+    (next-fn []))
+  (transform* [this structure next-fn]
+    (inner-insert structure next-fn zip/insert-left identity nil)
+    ))
+
 (defpath NODE []
   (select* [this structure next-fn]
     (next-fn (zip/node structure))


implement harvest-articles

implement harvest-articles

--- src/clj_ptt_crawler/crawl_board.clj
+++ src/clj_ptt_crawler/crawl_board.clj
@@ -18,5 +18,19 @@
        (map (fn [it] {:url it, :page_number (->> it (re-find #"\d+") Integer/parseInt) }))
        ))

+(defn harvest-articles
+  [url board-name]
+  (->> (-> url
+           (client/get {:insecure? true})
+           (:body)
+           (enlive/html-snippet)
+           (enlive/select [[:a (enlive/attr-starts :href (.concat "/bbs/" board-name)) (enlive/attr-ends :href ".html")]]))
+       (filter #(not (.contains (:href (:attrs %)) "/index")))
+       (map (fn [it]
+              (let [url (:href (:attrs it))
+                    id  (->> url (re-find (re-pattern (str/join ["/bbs/" board-name "/(.+)\\.html"]))) second)]
+                {:subject (:content it), :url url, :id id })))
+       ))
+
 (defn -main [board_name output_dir]
   (println (harvest-board-indices (clojure.string/join "" [PTT_URL "/bbs/" board_name "/index.html"]) board_name)))


Put the 'phonetic form' checkbox inside its label

--- src/cljs/cglossa/search_inputs.cljs
+++ src/cljs/cglossa/search_inputs.cljs
@@ -37,10 +37,11 @@
       [:div.span10
        [:input.span12 {:type "text" :value displayed-query
                        :on-change #(on-text-changed % search-query phonetic?)
-       [:label {:style {:marginTop 5}}]
-       [:input {:name "phonetic" :type "checkbox"
-                :style {:marginTop -3} :checked phonetic?
-                :on-change #(on-phonetic-changed % search-query)} " Phonetic form"]]]]))
+                       :on-key-down #(on-key-down % search-query)}]
+       [:label {:style {:marginTop 5}}
+        [:input {:name      "phonetic" :type "checkbox"
+                 :style     {:marginTop -3} :checked phonetic?
+                 :on-change #(on-phonetic-changed % search-query)} " Phonetic form"]]]]]))

 (def components {:cwb        cwb-search-inputs
                  :cwb-speech (fn [] [:div "CWB-SPEECHE"])})


Fix for pull request #8 - Changing method name

--- src/clojure/alfresco/filefolder.clj
+++ src/clojure/alfresco/filefolder.clj
@@ -46,8 +46,8 @@
   ([parent child-name child-type]
    (.getNodeRef (.create (file-folder-service) parent child-name child-type))))

-(defn get-file-folder-writer
-  "Returns the ContentWriter for the given node & property (default to cm:content).
+(defn get-writer
+  "Returns the ContentWriter for the given node. Not the same as content/get-writer.
    Should not normally be used directly - write! is preferable."
   ([node] (.getWriter (file-folder-service) node)))

@@ -59,10 +59,10 @@
   ([src node]          (write! (ByteArrayInputStream. (.getBytes src "UTF-8")) node)))

 (defmethod write! java.io.InputStream
-  ([src node]          (.putContent (get-file-folder-writer node) src)))
+  ([src node]          (.putContent (get-writer node) src)))

 (defmethod write! java.io.File
-  ([src node]          (.putContent (get-file-folder-writer node) src)))
+  ([src node]          (.putContent (get-writer node) src)))

 (defn delete!
   "Deletes the given node.  Note: duplicate of alfresco.nodes/delete!."


Forgot to include conexp.layout in the lattice-editor plugin

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>

--- src/conexp/gui/editors/lattices.clj
+++ src/conexp/gui/editors/lattices.clj
@@ -11,6 +11,7 @@
 	conexp.fca.contexts
 	conexp.fca.lattices
 	conexp.io
+	conexp.layout
 	[conexp.layout.base :only (lattice)]
 	conexp.graphics.draw
 	conexp.gui.util


refactoring the event chan out for simplicity

--- src/flappy_bird_demo/core.cljs
+++ src/flappy_bird_demo/core.cljs
@@ -5,15 +5,13 @@
    [cljs.core.async :refer [<! chan sliding-buffer put! close! timeout]])
   (:require-macros
    [cljs.core.async.macros :refer [go-loop go]]))
+
 (enable-console-print!)

 (defn floor [x] (.floor js/Math x))

-(defn translate
-  ([start-pos vel time]
-     (floor (+ start-pos (* time vel))))
-  ([start-pos modulo vel time]
-     (floor (+ start-pos (mod (* time vel) modulo)))))
+(defn translate [start-pos vel time]
+  (floor (+ start-pos (* time vel))))

 (def horiz-vel -0.15)
 (def gravity 0.05)
@@ -34,24 +32,20 @@
                       :flappy-start-time 0
                       :flappy-y   start-y
                       :pillar-list
-                      [{:start-time 0
-                        :pos-x 900
-                        :gap-top 200 }]})
-
-(defn reset-state [{:keys [event-chan] :as st} cur-time]
+                      [{ :start-time 0
+                         :pos-x 900
+                         :cur-x 900
+                         :gap-top 200 }]})
+
+(defn reset-state [_ cur-time]
   (-> starting-state
       (update-in [:pillar-list] (fn [pls] (map #(assoc % :start-time cur-time) pls)))
       (assoc
           :start-time cur-time
           :flappy-start-time cur-time
-          :event-chan event-chan
           :timer-running true)))

 (fw/defonce flap-state (atom starting-state))
-
-(defmulti transform first)
-
-(defmethod transform :default [_ state] state)

 (defn curr-pillar-pos [cur-time {:keys [pos-x start-time] }]
   (translate pos-x horiz-vel (- cur-time start-time)))
@@ -97,7 +91,6 @@
                   (:cur-x (last pillars-in-world)))))
         pillars-in-world))))

-
 (defn sine-wave [st]
   (assoc st
     :flappy-y
@@ -120,7 +113,7 @@
                  4)]
   (assoc st :score (if (neg? score) 0 score))))

-(defmethod transform :time [[_ timestamp] state]
+(defn time-update [timestamp state]
   (-> state
       (assoc
           :cur-time timestamp
@@ -128,7 +121,7 @@
       update-flappy
       update-pillars
       collision?
-      #_score))
+      score))

 (defn jump [{:keys [cur-time jump-count] :as state}]
   (-> state
@@ -136,16 +129,6 @@
           :jump-count (inc jump-count)
           :flappy-start-time cur-time
           :initial-vel jump-vel)))
-
-(defmethod transform :jump [_ state]
-  (jump state))
-
-(defn start-game [event-chan]
-  (.requestAnimationFrame js/window (fn [time]
-                                      (put! event-chan [:start-game time]))))
-
-(defmethod transform :start-game [[_ time] state]
-  (reset-state state time))

 ;; derivatives

@@ -171,58 +154,53 @@

 (defn px [n] (str n "px"))

-(defn pillar [{:keys [cur-x upper-height lower-height]}]
+(defn pillar [{:keys [cur-x pos-x upper-height lower-height]}]
   [:div.pillars
    [:div.pillar.pillar-upper {:style {:left (px cur-x)
                                        :height upper-height}}]
    [:div.pillar.pillar-lower {:style {:left (px cur-x)
                                        :height lower-height}}]])

-(defn main-template [{:keys [score cur-time jump-count timer-running border-pos event-chan flappy-y pillar-list]}]
+(defn time-loop [time]
+  (let [new-state (swap! flap-state (partial time-update time))]
+    (when (:timer-running new-state)
+      (go
+       (<! (timeout 30))
+       (.requestAnimationFrame js/window time-loop)))))
+
+(defn start-game []
+  (.requestAnimationFrame
+   js/window
+   (fn [time]
+     (reset! flap-state (reset-state @flap-state time))
+     (time-loop time))))
+
+(defn main-template [{:keys [score cur-time jump-count
+                             timer-running border-pos
+                             flappy-y pillar-list]}]
   (sab/html [:div.board { :onMouseDown (fn [e]
-                                         #_(put! event-chan [:jump])
                                          (swap! flap-state jump)
                                          (.preventDefault e))}
              [:h1.score score]
              (if-not timer-running
-               [:a.start-button {:onClick #(start-game event-chan)}
-                (if (pos? jump-count) "RESTART" "START")]
+               [:a.start-button {:onClick #(start-game)}
+                (if (< 1 jump-count) "RESTART" "START")]
                [:span])
              [:div (map pillar pillar-list)]
              [:div.flappy {:style {:top (px flappy-y)}}]
              [:div.scrolling-border {:style { :background-position-x (px border-pos)}}]]))

-(defn render-to [react-comp node]
-  (.renderComponent js/React react-comp node))
-
 (let [node (.getElementById js/document "board-area")]
   (defn renderer [full-state]
-    (render-to (main-template full-state) node)))
-
-(defn start []
-  (let [event-chan (chan (sliding-buffer 1))]
-    (go-loop []
-             (when-let [msg (<! event-chan)]
-               (let [new-state (transform msg @flap-state)]
-                 (reset! flap-state (-clone new-state))
-                 (when (:timer-running new-state)
-                   (<! (timeout 30))
-                   (.requestAnimationFrame js/window (fn [time] (put! event-chan [:time time]))))
-                 (recur))))
-    (swap! flap-state assoc :event-chan event-chan )
-    (add-watch flap-state :renderer (fn [_ _ _ n]
-               (renderer (world n))))
-    (put! event-chan [:time (or (:cur-time @flap-state) 0)])))
-
-(defn stop []
-  (remove-watch flap-state :renderer)
-  (when (:event-chan @flap-state)
-    (close! (:event-chan @flap-state))))
-
-(defn restart []
-  (stop)
-  (start))
-
-(fw/defonce starting-game (start))
-
-(fw/watch-and-reload :jsload-callback (fn [url] (restart)))
+    (.renderComponent js/React (main-template full-state) node)))
+
+(add-watch flap-state :renderer (fn [_ _ _ n]
+                                  (renderer (world n))))
+
+(reset! flap-state @flap-state)
+
+(fw/watch-and-reload  :jsload-callback (fn []
+                                         ;; you would add this if you
+                                         ;; have more than one file
+                                         #_(reset! flap-state @flap-state)
+                                         ))


not all hooks have url i.e. travis, add :name to hook

--- src/gh_waiting_room/github.clj
+++ src/gh_waiting_room/github.clj
@@ -76,7 +76,7 @@
   (->>
    (hooks user name (gh-auth))
    (map (fn [h]
-          {:url (get-in! h [:config :url]) :id (:id h)}))))
+          {:url (get-in h [:config :url]) :id (:id h) :name (:name h)}))))

 (defn list-repos
   []


Remove test

Remove test

--- src/devcards/discuss/devcards/core.cljs
+++ src/devcards/discuss/devcards/core.cljs
@@ -58,11 +58,4 @@
          "*Testing the small search engine in `discuss.find`*"
          (testing "fn statement, sending request and counting results"
            (is (= 4 (count (find/get-search-results)))))
-         test-state)
-
-(deftest integration-test
-         "*Testing `discuss.integration`*"
-         (let [doms-raw (.getElementsByTagName js/document "*")]
-           (testing "fn get-parent"
-             (is (= "test-get-parent" (.-id (integration/get-parent doms-raw "Eine Krise in den neunziger Jahren brachte die Wende für die Stadt"))))
-             (is (= "figwheel-heads-up-content-area" (.-id (integration/get-parent doms-raw "")))))))+         test-state)


Split main view

Split main view

--- src/discuss/views.cljs
+++ src/discuss/views.cljs
@@ -98,7 +98,8 @@
       (when (= text "")                                     ; Set initial text to be displayed
         (om/set-state! owner :text (:text data)))
       (dom/span #js {:className "pointer"
-                     :style (display show)}
+                     :style (display show)
+                     :onClick (fn [e] (println "click"))}
                 text))))

 (defn clipboard-view []
@@ -165,6 +166,21 @@
                                      :onClick   #(com/add-start-statement (lib/get-value-by-id "add-element"))}
                                 "Submit"))))

+(defn main-content-view [data]
+  (dom/div nil
+           (dom/div #js {:className "text-center"}
+                    (get-in data [:layout :intro])
+                    (dom/br nil)
+                    (dom/strong nil (get-in data [:issues :info])))
+           (dom/div #js {:className "panel panel-default"}
+                    (dom/div #js {:className "panel-body"}
+                             (let [view (get-in data [:layout :template])]
+                               (cond
+                                 (= view :login) (login-form)
+                                 :else (discussion-elements data)))))
+           (when (get-in data [:layout :add?])
+             (add-element data))))
+
 (defn main-view [data]
   (reify om/IRender
     (render [_]
@@ -173,15 +189,4 @@
                        (dom/i #js {:className "fa fa-comments"})
                        " "
                        (get-in data [:layout :title]))
-               (dom/div #js {:className "text-center"}
-                        (get-in data [:layout :intro])
-                        (dom/br nil)
-                        (dom/strong nil (get-in data [:issues :info])))
-               (dom/div #js {:className "panel panel-default"}
-                        (dom/div #js {:className "panel-body"}
-                                 (let [view (get-in data [:layout :template])]
-                                   (cond
-                                     (= view :login) (login-form)
-                                     :else (discussion-elements data)))))
-               (when (get-in data [:layout :add?])
-                 (add-element data))))))+               (main-content-view data)))))


clean out a note

clean out a note

--- src/doctopus/files.clj
+++ src/doctopus/files.clj
@@ -11,10 +11,6 @@
             [doctopus.files.predicates :refer [markdown?]]
             [me.raynes.fs :as fs]))

-;; I think we've pretty much captured this by now? -- RMD Sun Mar 15 20:37:46 2015
-
-;; THIS IS TOTALLY DATABASS
-;; (pprint (fs/walk vector "/Users/rossdonaldson/Code/doctopus/src/"))

 (defn filter-the-docs
   "Vector Triple of (path, directories, files), and function that filters relevant doc-types"


Extra logging to determine cause of CI test failure :broken_heart:

--- src/metabase/email.clj
+++ src/metabase/email.clj
@@ -43,7 +43,8 @@
   [& {:keys [subject recipients message-type message]}]
   {:pre [(string? subject)
          (sequential? recipients)
-         (every? u/is-email? recipients)
+         (or (every? u/is-email? recipients)
+             (log/error "recipients contains an invalid email:" recipients))
          (contains? #{:text :html :attachments} message-type)
          (if (= message-type :attachments) (sequential? message) (string? message))]}
   (try


Fix pulse table rendering due to dividing BigDecimals

Resolves #1714

--- src/metabase/pulse.clj
+++ src/metabase/pulse.clj
@@ -242,7 +242,7 @@
                                                :max-height       :10px
                                                :height           :10px
                                                :border-radius    :2px
-                                               :width            (str (float (* 100 (/ (bar-column row) max-value))) "%")})}
+                                               :width            (str (float (* 100 (/ (double (bar-column row)) max-value))) "%")})} ; cast to double to avoid "Non-terminating decimal expansion" errors
                           " "]])])
                    rows)]]))


typo fix

typo fix

--- src/mermaid_ldjam/core.cljs
+++ src/mermaid_ldjam/core.cljs
@@ -51,7 +51,7 @@
    [:flap :stone] {:text "You flap frustratedly against the stones. That's no use."}
    [:flap :window-open] {:text "The window is open but it is still to far to reach."}
    [:flap :starfish] {:text "You flap against the starfish. 'Ouch!' - it cries."}
-   [:flap :bottle] {:text "You attempt flapping the bottle of wine but halt at the last moment. It's too previous to spill."}
+   [:flap :bottle] {:text "You attempt flapping the bottle of wine but halt at the last moment. It's too precious to spill."}
    [:flap :broom] {:text "You flap against the broom. It almost falls over. Maybe you can use it differently?"}
    [:flap :seagull] {:text "You flap in the direction of the seagull. It seems intrigued."}
    [:bottle :bucket] {:text "You put the bottle in the bucket. Then put it back. That makes no sense."}


one more formatting tweak.

one more formatting tweak.

--- src/metabase/api/routes.clj
+++ src/metabase/api/routes.clj
@@ -30,7 +30,7 @@
   (context "/activity"     [] (+auth activity/routes))
   (context "/card"         [] (+auth card/routes))
   (context "/dash"         [] (+auth dash/routes))
-  (GET "/health"           [] {:status 200 :body {:status "ok"}})
+  (GET     "/health"       [] {:status 200 :body {:status "ok"}})
   (context "/meta/dataset" [] (+auth dataset/routes))
   (context "/meta/db"      [] (+auth db/routes))
   (context "/meta/field"   [] (+auth field/routes))


fix lint error

fix lint error

--- src/metabase/util/stats.clj
+++ src/metabase/util/stats.clj
@@ -133,7 +133,7 @@
    :friendly_names        (metabase.models.humanization/enable-advanced-humanization)
    :email_configured      ((resolve 'metabase.email/email-configured?))
    :slack_configured      ((resolve 'metabase.integrations.slack/slack-configured?))
-   :sso_configured        (not (nil? metabase.api.session/google-auth-client-id))
+   :sso_configured        (not (nil? (resolve 'metabase.api.session/google-auth-client-id)))
    :instance_started      instance-start-date?
    :has_sample_data       (db/exists? 'Database, :is_sample true)
    }


Remove unused code.

Remove unused code.

--- src/active/clojure/record_spec.cljc
+++ src/active/clojure/record_spec.cljc
@@ -290,8 +290,7 @@
                                                                                (if (= ?field ?shove-field)
                                                                                ?v
                                                                                `(~?shove-accessor ~?data)))
-                                                                                ?field-triples))))))))
-                         ~@(when-let [?spec (:spec ?lens+spec)]))))
+                                                                                ?field-triples)))))))))))
                    ?field-triples)
          ;; type-spec
          ~(define-type-spec-form ?type ?constructor ?predicate (map second (filter (fn [[_ _ l+s]] (:spec l+s)) ?field-triples)))


CMR-1873: Fixed typo

CMR-1873: Fixed typo

--- system-int-test/test/cmr/system_int_test/search/collection_highlights_search_test.clj
+++ system-int-test/test/cmr/system_int_test/search/collection_highlights_search_test.clj
@@ -201,7 +201,7 @@
          mt/atom
          mt/iso19115))

-  (testing "invalid json repsone formats"
+  (testing "invalid json response formats"
      (are [resp-format]
          (= {:status 400 :errors ["Highlights are only supported in the JSON format."]}
             (search/get-search-failure-data


Added newly supported languages and another arity for generating stats.

--- src/hxgm30/language/syntagmata/core.clj
+++ src/hxgm30/language/syntagmata/core.clj
@@ -11,13 +11,19 @@
    :arabic
    :chinese
    :english
+   :finnish
    :french
+   :gaelic
    :german
+   :greek
+   :hebrew
    :hindi
    :japanese
    :korean
+   :latin
    :oldenglish
    :oldnorse
+   :onomatopoetic
    :pie
    :russian
    :sanskrit
@@ -95,12 +101,14 @@
          :percent-ranges (util/frequencies->percent-ranges final)}}}))

 (defn regen-stats
-  []
-  (doall
-    (for [language supported]
-      (do
-        (corpus/dump :stats language (generate-stats language))
-        {language :ok}))))
+  ([]
+    (doall
+      (for [language supported]
+        (do
+          (corpus/dump :stats language (generate-stats language))
+          {language :ok}))))
+  ([language]
+    (corpus/dump :stats language (generate-stats language))))

 (defn stats
   [language]


Fixed dev dependency copy omission.

Fixed dev dependency copy omission.

--- src/leiningen/appengine_prepare.clj
+++ src/leiningen/appengine_prepare.clj
@@ -54,6 +54,6 @@
     (lancet/copy {:todir (.getPath target-lib-dir)}
                  (lancet/fileset
                   {:dir lib-dev-dir
-                   :includes (str "appengine-magic*,ring-core*,"
+                   :includes (str "appengine-magic*,ring-core*,servlet-api*,"
                                   "commons-io*,commons-codec*,commons-fileupload*,"
                                   "appengine-api-1.0-sdk*,appengine-api-labs*")}))))


fix arg order for cljs.build.api/mark-cljs-ns-for-recompile!

--- src/main/clojure/cljs/build/api.clj
+++ src/main/clojure/cljs/build/api.clj
@@ -42,7 +42,7 @@
   "Backdates a cljs target file so that it the cljs compiler will recompile it."
   ([ns-sym] (mark-cljs-ns-for-recompile! ns-sym nil))
   ([ns-sym output-dir]
-    (let [s (target-file-for-cljs-ns output-dir ns-sym)]
+    (let [s (target-file-for-cljs-ns ns-sym output-dir)]
       (when (.exists s)
         (.setLastModified s 5000)))))


fix some aseq serialization

fix some aseq serialization

--- src/main/clojure/powderkeg/kryo.clj
+++ src/main/clojure/powderkeg/kryo.clj
@@ -4,6 +4,10 @@

 (defn serializer [read write]
   (powderkeg.SerializerStub. read write))
+
+(defn- serializer-factory [f]
+ (reify com.esotericsoftware.kryo.factories.SerializerFactory
+   (makeSerializer [factory kryo class] (f kryo class))))

 (def default-serializers
   {clojure.lang.ITransientCollection
@@ -35,12 +39,18 @@
            com.esotericsoftware.kryo.util.Util/getWrapperClass)))
      (fn write [_ ^com.esotericsoftware.kryo.Kryo kryo ^com.esotericsoftware.kryo.io.Output output ^Class class]
        (.writeClass kryo output class)
-       (.writeByte output (if (some-> class .isPrimitive) 1 0))))})
+       (.writeByte output (if (some-> class .isPrimitive) 1 0))))
+   java.util.Collection
+    (serializer-factory
+      (fn [kryo ^Class class]
+        (if (try (.getDeclaredConstructor class (into-array Class nil)) (catch NoSuchMethodException _ nil))
+          (com.esotericsoftware.kryo.serializers.CollectionSerializer.)
+          (com.esotericsoftware.kryo.serializers.FieldSerializer. kryo class))))})

 (def void-serializer (serializer (fn [_ _ _ _]) (fn [_ _ _ _])))

 (defn register-default-serializers [^com.esotericsoftware.kryo.Kryo kryo m]
-  (doseq [[^Class class ^com.esotericsoftware.kryo.Serializer serializer] m]
+  (doseq [[^Class class serializer] m]
     (.addDefaultSerializer kryo class serializer)))

 (defn customizer [^com.esotericsoftware.kryo.Kryo kryo]


Back out the graceful shutdown code for now.

--- src/circle/backend/action/nodes.clj
+++ src/circle/backend/action/nodes.clj
@@ -2,7 +2,6 @@
   (:require [circle.backend.nodes :as nodes])
   (:require [circle.backend.ec2 :as ec2])
   (:use [circle.util.core :only (sha1)])
-  (:require [clj-http.client :as http])
   (:use [circle.backend.action :only (defaction add-action-result)])
   (:require [circle.backend.ssh :as ssh])
   (:use [clojure.tools.logging :only (infof errorf)]))
@@ -42,24 +41,13 @@
       (dosync
        (alter build assoc :instance-ids instance-ids)))))

-(defn graceful-shutdown [instance-id]
-  (infof "asking %s to shutdown gracefully" instance-id)
-  (let [resp (http/post (format "https://%s/api/system/shutdown" (ec2/public-ip instance-id))
-                        {:basic-auth ["bot@circleci.com" "brick amount must thirty"]
-                         ;; ignore SSL errors, in case this is a staging instance
-                         :insecure? true})]
-    (infof "graceful shutdown: got resp %s" resp)))
-
 (defn cleanup-nodes
-  "terminates nodes, and kills keypairs. if force is true, forcibly terminate the node, otherwise ask it to shutdown."
-  [build & {:keys [force]}]
+  "terminates nodes, and kills keypairs. forcibly terminate the node."
+  [build]
   (let [ids (-> @build :instance-ids)]
     (when (seq ids)
       (infof "terminating nodes %s" ids)
-      (if force
-        (apply ec2/safe-terminate ids)
-        (doseq [i ids]
-          (graceful-shutdown i))))
+      (apply ec2/safe-terminate ids))
     (when (-> @build :node :keypair-name)
       (infof "deleting keypair %s" (-> @build :node :keypair-name))
       (ec2/delete-keypair (-> @build :node :keypair-name)))))


Fix asset fingerprinting

Fix asset fingerprinting

--- src/clj/clojuredocs/site/common.clj
+++ src/clj/clojuredocs/site/common.clj
@@ -55,23 +55,27 @@
        [:div.col-md-10.col-md-offset-1
         [:div.ac-results-widget]]])]])

+(defn md5-path [path]
+  (-> path slurp util/md5))
+
 (def clojuredocs-script
   [:script {:src (str "/cljs/clojuredocs.js?"
-                      (util/md5 "resources/public/cljs/clojuredocs.js"))}])
+                      (md5-path "resources/public/cljs/clojuredocs.js"))}])

 (def app-link
   [:link {:rel :stylesheet
           :href (str "/css/app.css?"
-                     (util/md5 "resources/public/css/app.css"))}])
+                     (md5-path "resources/public/css/app.css"))}])

 (def bootstrap-link
   [:link {:rel :stylesheet
           :href (str "/css/bootstrap.min.css?"
-                     (util/md5 "resources/public/css/bootstrap.min.css"))}])
+                     (md5-path "resources/public/css/bootstrap.min.css"))}])

 (def font-awesome-link
-  [:link {:rel :stylesheet :href (str "/css/font-awesome.min.css?"
-                                      (util/md5 "resources/public/css/font-awesome.min.css"))}])
+  [:link {:rel :stylesheet
+          :href (str "/css/font-awesome.min.css?"
+                     (md5-path "resources/public/css/font-awesome.min.css"))}])

 (defn $main [{:keys [content title body-class user page-data] :as opts}]
   [:html5


Add cljx-generated sources to autoreloader

--- src/clj/robinson/autoreloadcore.clj
+++ src/clj/robinson/autoreloadcore.clj
@@ -16,7 +16,7 @@
    (Thread/sleep 500))

 (defn start-nstracker []
- (let [track (ns-tracker ["src" "checkouts"])]
+ (let [track (ns-tracker ["src" "target/generated-src/clj" "checkouts"])]
    (doto
      (Thread.
        #(while true


Functions: ok-response-structure, error-response-structure, and job-related-command

--- src/clj_jenkins_api/jenkins_api.clj
+++ src/clj_jenkins_api/jenkins_api.clj
@@ -61,4 +61,35 @@
                 (get data "jobs")
                 nil))))

+(defn ok-response-structure
+    "Structure returned to the calling function when the Jenkins API fails."
+    [job-name command include-jenkins-reply? jenkins-response]
+    (if include-jenkins-reply?
+        {:status   "ok"
+         :job-name job-name
+         :command  command
+         :jenkins-response jenkins-response}
+        {:status   "ok"
+         :job-name job-name
+         :command  command}))

+(defn error-response-structure
+    "Structure returned to the calling function when the Jenkins API succeded"
+    [job-name command exception]
+    {:status   "error"
+     :job-name job-name
+     :command  command
+     :message  (.getMessage exception)
+    })
+
+(defn job-related-command
+    "Call any job-related command via Jenkins API."
+    [jenkins-url jenkins-auth include-jenkins-reply? job-name command]
+    (try
+        (let [response (post-command jenkins-url jenkins-auth job-name command)]
+            (ok-response-structure job-name command include-jenkins-reply? response))
+        (catch Exception e
+            (.printStackTrace e)
+            (error-response-structure job-name command e))))
+
+


Updated docstrings in jenkins-api module

--- src/clj_jenkins_api/jenkins_api.clj
+++ src/clj_jenkins_api/jenkins_api.clj
@@ -146,12 +146,14 @@
     (job-related-command jenkins-url jenkins-auth include-jenkins-reply? job-name "doDelete"))

 (defn replace-placeholder
+    "Replace selected placeholder in the template."
     [string placeholder-name value]
     (if value
         (clojure.string/replace string (str "<placeholder id=\"" placeholder-name "\" />") value)
         string))

 (defn update-template
+    "Update the XML template with job configuration."
     [template git-repo branch metadata credentials-id]
     (-> template
         (replace-placeholder "git-repo"                   git-repo)
@@ -172,6 +174,7 @@
     (log "crendetials-id" credentials-id))

 (defn send-configuration-xml-to-jenkins
+    "Send the file containing job configuration to Jenkins via its REST API."
     [url config]
     (http-client/post url {
         :body             config
@@ -182,11 +185,13 @@
         :trust-store-pass "changeit"}))

 (defn get-template
+    "Read the template from template directory. There are two templates, one for jobs with metadata and second for one without metadata."
     [metadata-directory metadata]
     (slurp (if metadata (str metadata-directory "/template_with_metadata.xml")
                         (str metadata-directory "/template.xml"))))

 (defn create-job
+    "Update the selected job. Following values must be specified - git-repo, branch, credentials-id, and metadata for template."
     [jenkins-url jenkins-auth include-jenkins-reply? job-name git-repo branch credentials-id metadata-directory metadata]
     (log-operation job-name git-repo branch "create_job" metadata credentials-id)
     (let [template (get-template metadata-directory metadata)
@@ -201,6 +206,7 @@
                   (error-response-structure job-name "create_job" e)))))

 (defn update-job
+    "Update the selected job. Following values can be changed - git-repo, branch, and credentials-id."
     [jenkins-url jenkins-auth include-jenkins-reply? job-name git-repo branch credentials-id metadata-directory metadata]
     (log-operation job-name git-repo branch "update_job" metadata credentials-id)
     (let [template (get-template metadata-directory metadata)


update register-system to add any already existing & matching entity IDs to new system

--- src/cljs/resonate2015/day2/ecs.cljs
+++ src/cljs/resonate2015/day2/ecs.cljs
@@ -65,11 +65,15 @@
   a set of required component IDs and a system function to process
   a matching entity."
   [ecs name comp-ids sys-fn]
-  (let [valid? (entity-validator comp-ids)]
+  (let [valid? (entity-validator comp-ids)
+        ids    (into #{}
+                     (comp (filter (comp valid? val))
+                           (map key))
+                     (:entities ecs))]
     (assoc-in ecs [:systems name]
               {:fn       sys-fn
                :valid?   valid?
-               :entities #{}})))
+               :entities ids})))

 (defn run-system
   "Runs a single system fn on matching components"


Upgrade cljs, compojure and om.

Upgrade cljs, compojure and om.

--- src/leiningen/new/chestnut/project.clj
+++ src/leiningen/new/chestnut/project.clj
@@ -9,12 +9,12 @@
   :test-paths ["spec/clj"]

   :dependencies [[org.clojure/clojure "1.6.0"]
-                 [org.clojure/clojurescript "0.0-2371" :scope "provided"]
+                 [org.clojure/clojurescript "0.0-2496" :scope "provided"]
                  [ring "1.3.2"]
                  [ring/ring-defaults "0.1.2"]
-                 [compojure "1.2.0"]
+                 [compojure "1.3.1"]
                  [enlive "1.1.5"]
-                 [om "0.7.3"]
+                 [om "0.8.0-beta3"]
                  [environ "1.0.0"]{{{project-clj-deps}}}]

   :plugins [[lein-cljsbuild "1.0.3"]


Revert "Add .shadow-cljs cache to :clean-targets"

This reverts commit 2130268c97ec2302c847906025046f5377f48444.

Re @thheller's feedback to please not ever wipe this dir.

Caching is supposed to be reliable and it is. If you actually have to
delete this folder to fix something he would much rather hear about it
and fix the issue than having lein clean as the default go to.

Co-Authored-By: Thomas Heller <8aa6dfc21167f676c4daceadf90decc7d87844fc@gmail.com>

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

   :test-paths   ["test/cljs"]{{/test?}}

-  :clean-targets ^{:protect false} [:target-path
-                                    ".shadow-cljs"
-                                    "resources/public/js/compiled"{{#test?}}
+  :clean-targets ^{:protect false} ["resources/public/js/compiled" "target"{{#test?}}
                                     "test/js"{{/test?}}{{#garden?}}
                                     "resources/public/css"{{/garden?}}]


RangeMap:

RangeMap:

- add leftfn & rightfn depending on kind
- don't count on every loop iteration

--- sample/src/sample/btree.clj
+++ sample/src/sample/btree.clj
@@ -8,16 +8,15 @@
   (search [this k]))

-(deftype RangeMap [kind ^clojure.lang.IPersistentMap m]
+(deftype RangeMap [kind ^clojure.lang.IPersistentMap m leftfn rightfn]

   clojure.lang.IPersistentMap

   (assoc [this k v]
-    (->RangeMap kind (.assoc m k v)))
+    (->RangeMap kind (.assoc m k v) leftfn rightfn))

   (assocEx [this k v]
-    (.assocEx m k v)
-    this)
+    (->RangeMap kind (.assocEx m k v) leftfn rightfn))

   clojure.lang.ILookup
@@ -27,17 +26,17 @@

   (valAt [this k not-found]
     (let [idx (loop [ks     (keys m)
+                     n      (count ks)
                      lastki nil]
                 #_(println "LOOP1" lastki ks)
                 (if (not-empty ks)
-                  (let [n   (count ks)
-                        i   (int (/ n 2))
+                  (let [i   (int (/ n 2))
                         ki  (get (vec ks) i)
                         cmp (compare ki k)]
                     #_(println "LOOP2" n i ki cmp)
                     (cond
-                      (> cmp 0) (recur (take i ks)       (if (= kind :find-floor)   lastki ki))  ;; traverse left
-                      (< cmp 0) (recur (drop (inc i) ks) (if (= kind :find-ceiling) lastki ki))  ;; traverse right
+                      (> cmp 0) (recur (take i ks)       i         (leftfn lastki ki))   ;; traverse left
+                      (< cmp 0) (recur (drop (inc i) ks) (- n i 1) (rightfn lastki ki))  ;; traverse right
                       (= cmp 0) ki))
                   lastki))]
       (get m idx))))
@@ -45,7 +44,12 @@
 (defn range-map [kind & kvs]
   {:pre [(or (= kind :find-ceiling)
              (= kind :find-floor))]}
-  (->RangeMap kind (apply sorted-map kvs)))
+  (let [[leftfn rightfn] (case kind
+                           :find-floor   [(fn [lastki ki] lastki)
+                                          (fn [lastki ki] ki)]
+                           :find-ceiling [(fn [lastki ki] ki)
+                                          (fn [lastki ki] lastki)])]
+    (->RangeMap kind (apply sorted-map kvs) leftfn rightfn)))

 (defrecord B+Tree [b slots])


Make execute-plan specific

Make execute-plan specific

--- src/icecap/execute.clj
+++ src/icecap/execute.clj
@@ -37,7 +37,7 @@
   ;; let's pretend this does something useful
   (a/to-chan [step]))

-(defn execute
+(defn execute-plan
   "Executes a plan.

   If the plan is a single step, executes it with `execute-step`. If it
@@ -53,10 +53,10 @@
   (let [c (chan)]
     (condp #(%1 %2) plan
       map? (pipe (execute-step plan) c)
-      set? (pipe (merge (map execute plan)) c)
+      set? (pipe (merge (map execute-plan plan)) c)
       ;;                       ^- recursion!!!
       vector? (go (loop [sub-plans plan]
-                    (>! c (<! (execute (first sub-plans))))
+                    (>! c (<! (execute-plan (first sub-plans))))
                     ;;           ^- recursion!!!
                     (let [remaining (rest sub-plans)]
                       (if (seq remaining)


MD5 checksum calculation

MD5 checksum calculation

--- src/ontrail/crypto.clj
+++ src/ontrail/crypto.clj
@@ -2,6 +2,18 @@

 (import com.lambdaworks.codec.Base64)

+(defn md5
+  "Generate a md5 checksum for the given string"
+  [token]
+  (let [hash-bytes
+        (doto (java.security.MessageDigest/getInstance "MD5")
+          (.reset)
+          (.update (.getBytes token)))]
+    (.toString
+      (new java.math.BigInteger 1 (.digest hash-bytes)) ; Positive and the size of the number
+      16)))
+
+(defn md5-match? [string expected] (= (md5 string) expected))

 (defn char-array-to-string [arr] (apply str arr))
 (defn byte-array-to-string [arr] (apply str (map #(char %) arr))) ; aebaerae -castaus char:ksi, mutta tässä toimii?


parser supports directly endomondo formats


Fix repl to exit properly on ^D char. Fixes #69.

Thanks to Steve Gilardi for the tip.

--- src/leiningen/repl.clj
+++ src/leiningen/repl.clj
@@ -35,10 +35,10 @@

 (defn- repl-client [reader writer]
   (copy-out reader)
-  (let [input (try (pr-str (read))
-                   (catch Exception _ ::abort))]
-    (when-not (= ::abort input)
-      (.write writer (str input "\n"))
+  (let [eof (Object.)
+        input (read *in* false eof)]
+    (when-not (= eof input)
+      (.write writer (str (pr-str input) "\n"))
       (.flush writer)
       (recur reader writer))))


Tidy 'newest-voom-ver-by-spec and make it emit a single list.

--- src/leiningen/voom.clj
+++ src/leiningen/voom.clj
@@ -404,47 +404,41 @@
 (defn newest-voom-ver-by-spec
   [proj-name ver-spec {:keys [repo ref path]}]

-  (for [gitdir (all-repos-dirs)]
-    (let [ptn (s/join "--" ["voom"
-                       (str (namespace proj-name) "%" (name proj-name))
-                       (str ver-spec "*")])
-          tags (:lines (git {:gitdir gitdir} "tag" "--list" ptn))
-          ;;_ (prn :tags tags)
-          tspecs (if (= tags [""])
-                   []
-                   (map parse-tag tags))
-          paths (set (map :path tspecs))]
-
-      (doall
-       (for [path paths
-             branch (map #(re-find #"[^/]*/+[^/]*$" (str %))
-                         (glob (str gitdir "/refs/remotes/*/*")))
-             :let [commits
-                   , (map
-                      parse-sha-refs
-                      (:lines (apply git {:gitdir gitdir} "log"
-                                     "--pretty=format:%H:%d" "--decorate" "--reverse"
-                                     (concat (map #(str "^" % "^") tags)
-                                             [branch "--" path]))))]
-             :when (seq commits)]
-         (let [refs (-> commits first :refs)
-               reflist (filter #(= path (:path %)) (map parse-tag refs))]
-           (some (fn [[current next-commit]]
-                   #_(prn :refs path (:refs next-commit))
-                   (when (or (= :end next-commit)
-                             (some #(= path (:path (parse-tag %)))
-                                   (:refs next-commit)))
-                     {:sha (:sha current)
-                      :ver (-> reflist first :ver)
-                      :path path
-                      :proj proj-name
-                      :gitdir gitdir
-                      :branch branch}))
-                 (partition 2 1 (concat commits [:end])))))))))
-
-
-
-
+  (for [gitdir (all-repos-dirs)
+        :let [ptn (s/join "--" ["voom"
+                                (str (namespace proj-name) "%" (name proj-name))
+                                (str ver-spec "*")])
+              tags (:lines (git {:gitdir gitdir} "tag" "--list" ptn))
+              ;;_ (prn :tags tags)
+              tspecs (if (= tags [""])
+                       []
+                       (map parse-tag tags))
+              paths (set (map :path tspecs))]
+        path paths
+        branch (map #(re-find #"[^/]*/+[^/]*$" (str %))
+                    (glob (str gitdir "/refs/remotes/*/*")))
+        :let [commits
+              , (map
+                 parse-sha-refs
+                 (:lines (apply git {:gitdir gitdir} "log"
+                                "--pretty=format:%H:%d" "--decorate" "--reverse"
+                                (concat (map #(str "^" % "^") tags)
+                                        [branch "--" path]))))]
+        :when (seq commits)]
+    (let [refs (-> commits first :refs)
+          reflist (filter #(= path (:path %)) (map parse-tag refs))]
+      (some (fn [[current next-commit]]
+              #_(prn :refs path (:refs next-commit))
+              (when (or (= :end next-commit)
+                        (some #(= path (:path (parse-tag %)))
+                              (:refs next-commit)))
+                {:sha (:sha current)
+                 :ver (-> reflist first :ver)
+                 :path path
+                 :proj proj-name
+                 :gitdir gitdir
+                 :branch branch}))
+            (partition 2 1 (concat commits [:end]))))))

 ;; Add metadata pinning (how big to bump? all? minor? sha?) -- warn about not updating
 ;; Opt-in autobump  -- default to no major auto


Add missing import/requires needed for Datomic schema fns.

--- src/leiningen/voom.clj
+++ src/leiningen/voom.clj
@@ -5,11 +5,14 @@
             [clojure.java.io :as io]
             [clojure.set :as set]
             [clojure.edn :as edn]
+            [datomic.api :as d]
+            [datomic.db :as db]
             [leiningen.core.project :as project]
             [leiningen.core.main :as lmain]
             [org.satta.glob :refer [glob]]
             [robert.hooke :as hooke])
-  (:import [java.util Date]
+  (:import [clojure.lang #_IPersistentVector Seqable]
+           [java.util Date]
            [java.io File FileInputStream FileOutputStream OutputStreamWriter]
            [java.util.logging Logger Handler Level]
            [org.sonatype.aether.transfer ArtifactNotFoundException]))


Enable voom plugin to be called outside of a project context.

--- src/leiningen/voom.clj
+++ src/leiningen/voom.clj
@@ -552,7 +552,7 @@
    "box-add" box-add
    "new-task" nope})

-(defn voom
+(defn ^:no-project-needed voom
   "Usage:
     lein voom [flags] [lein command ...]
       Runs lein command with a project version augmented with git
@@ -570,14 +570,14 @@
   (let [[kstrs sargs] (split-with #(.startsWith ^String % ":") args)
         kargset (set (map #(keyword (subs % 1)) kstrs))
         long-sha (kargset :long-sha)
-        new-project (update-proj-version project long-sha)]
+        new-project (delay (update-proj-version project long-sha))]
     ;; TODO throw exception if upstream doesn't contain this commit :no-upstream
     (cond
-     (:print kargset) (println (:version new-project))
+     (:print kargset) (println (:version @new-project))
      (:parse kargset) (prn (ver-parse (first sargs)))
      :else (if-let [f (get sub-commands (first sargs))]
-             (apply f new-project (rest sargs))
-             (if (and (dirty-wc? (:root new-project))
+             (apply f @new-project (rest sargs))
+             (if (and (dirty-wc? (:root @new-project))
                       (not (:insanely-allow-dirty-working-copy kargset)))
                (lmain/abort "Refusing to continue with dirty working copy. (Hint: Run 'git status')")
-               (lmain/resolve-and-apply new-project sargs))))))
+               (lmain/resolve-and-apply @new-project sargs))))))


Included option :send-server-version (default false) as this is awkward to set in the configurator as we did before.

--- src/mixradio/instrumented_jetty.clj
+++ src/mixradio/instrumented_jetty.clj
@@ -92,6 +92,12 @@
                            "eclipse"
                            (format "jetty.server.%sConnectionFactory.new-connections" name)]))

+(defn- http-config
+  [options]
+  (doto (HttpConfiguration.)
+    (.setSendDateHeader true)
+    (.setSendServerVersion (options :send-server-version false))))
+
 (defn- ssl-connector
   "Creates a SSL server connector instance."
   [server options]
@@ -106,9 +112,7 @@
 (defn- std-connector
   "Creates a standard server connector instance."
   [server options]
-  (let [config (doto (HttpConfiguration. )
-                 (.setSendDateHeader true))
-        connection-factory (HttpConnectionFactory. config)
+  (let [connection-factory (HttpConnectionFactory. (http-config options))
         instr-conn-factory (InstrumentedConnectionFactory. connection-factory
                                                            (connection-timer "Http"))]
     (doto (ServerConnector. server (into-array [instr-conn-factory]))
@@ -136,20 +140,22 @@
   "Start a Jetty webserver to serve the given handler according to the
   supplied options:

-  :configurator - a function called with the Jetty Server instance
-  :port         - the port to listen on (defaults to 80)
-  :host         - the hostname to listen on
-  :join?        - blocks the thread until server ends (defaults to true)
-  :ssl?         - allow connections over HTTPS
-  :ssl-port     - the SSL port to listen on (defaults to 443, implies :ssl?)
-  :keystore     - the keystore to use for SSL connections
-  :key-password - the password to the keystore
-  :truststore   - a truststore to use for SSL connections
-  :trust-password - the password to the truststore
-  :max-threads  - the maximum number of threads to use (default 50)
-  :client-auth  - SSL client certificate authenticate, may be set to :need,
-                  :want or :none (defaults to :none)
-  :on-stop      - A function to call on shutdown, before closing connectors"
+  :configurator        - a function called with the Jetty Server instance
+  :port                - the port to listen on (defaults to 80)
+  :host                - the hostname to listen on
+  :join?               - blocks the thread until server ends (defaults to true)
+  :ssl?                - allow connections over HTTPS
+  :ssl-port            - the SSL port to listen on (defaults to 443, implies :ssl?)
+  :keystore            - the keystore to use for SSL connections
+  :key-password        - the password to the keystore
+  :truststore          - a truststore to use for SSL connections
+  :trust-password      - the password to the truststore
+  :max-threads         - the maximum number of threads to use (default 50)
+  :client-auth         - SSL client certificate authenticate, may be set to :need,
+                         :want or :none (defaults to :none)
+  :on-stop             - A function to call on shutdown, before closing connectors
+  :send-server-version - if true, the server version is sent in responses
+                         (defaults to false)"
   [handler options]
   (let [
         ^QueuedThreadPool p (InstrumentedQueuedThreadPool. default-registry


Added (c) header into jenkins_api.clj

Added (c) header into jenkins_api.clj

--- src/emender_jenkins/jenkins_api.clj
+++ src/emender_jenkins/jenkins_api.clj
@@ -1,3 +1,15 @@
+;
+;  (C) Copyright 2016  Pavel Tisnovsky
+;
+;  All rights reserved. This program and the accompanying materials
+;  are made available under the terms of the Eclipse Public License v1.0
+;  which accompanies this distribution, and is available at
+;  http://www.eclipse.org/legal/epl-v10.html
+;
+;  Contributors:
+;      Pavel Tisnovsky
+;
+
 (ns emender-jenkins.jenkins-api)

 (require '[clojure.xml       :as xml])


(PDB-1964) don't swallow errors in applied-migrations

We need to swallow the error that occurs when the schema_migrations table
doesn't exist. Everything else should be thrown.

--- src/puppetlabs/puppetdb/scf/migrate.clj
+++ src/puppetlabs/puppetdb/scf/migrate.clj
@@ -1533,7 +1533,11 @@
           results (jdbc/with-db-transaction []  (query-to-vec query))]
       (apply sorted-set (map :version results)))
     (catch java.sql.SQLException e
-      (sorted-set))))
+      (let [message (.getMessage e)]
+        (if (or (re-find #"object not found: SCHEMA_MIGRATIONS" message)
+                (re-find #"\"schema_migrations\" does not exist" message))
+          (sorted-set)
+          (throw e))))))

 (defn pending-migrations
   "Returns a collection of pending migrations, ordered from oldest to latest."