[ocr] Really kill subprocesses on timeout.

--- src/pepa/util.clj
+++ src/pepa/util.clj
@@ -35,18 +35,21 @@
   (let [process (-> (into-array (map str (cons command args)))
                     (ProcessBuilder.)
                     (.redirectError java.lang.ProcessBuilder$Redirect/INHERIT)
-                    (.start))
-        ;; TODO: We can use the new (.setTimeout process timeout unit)
-        ;; soon
-        fut (future (.waitFor process))
-        exit-code (if (and timeout (number? timeout))
-                    (deref fut timeout ::timeout)
-                    @fut)]
-    (if (and (not= ::timeout exit-code)
-             (zero? exit-code))
-      process
-      (throw (ex-info (str (pr-str command) " didn't terminate correctly")
-                      (assoc ex-data
-                             :exit-code exit-code
-                             :args args
-                             ::timeout timeout))))))
+                    (.start))]
+    (try
+      (let [fut (future (.waitFor process))
+            exit-code (if (and timeout (number? timeout))
+                        ;; TODO: We can use the new (.setTimeout
+                        ;; process timeout unit) soon
+                        (deref fut timeout ::timeout)
+                        @fut)]
+        (if (and (not= ::timeout exit-code)xg
+                 (zero? exit-code))
+          process
+          (throw (ex-info (str (pr-str command) " didn't terminate correctly")
+                          (assoc ex-data
+                                 :exit-code exit-code
+                                 :args args
+                                 ::timeout timeout)))))
+      (finally
+        (.destroy process)))))


Tweak EquilibriumLayer

Tweak EquilibriumLayer

--- src/overtone_workspace/layers/equilibrium.clj
+++ src/overtone_workspace/layers/equilibrium.clj
@@ -12,7 +12,7 @@
 ;;; Constants
 ;;;

-(def speed 3)
+(def speed 5)
 (def eps 1)

 ;;;
@@ -61,9 +61,12 @@
   [size]
   (let [angle (rand q/TWO-PI)
         cur-speed (rand speed)]
-      {:x (rand-int size)
-       :y (rand-int size)
-       :velocity ((juxt q/cos q/sin) cur-speed)}))
+    {:x (rand-int size)
+     :y (rand-int size)
+     :velocity ((juxt q/cos q/sin) cur-speed)
+     :r (+ 55 (rand-int 200))
+     :g (+ 55 (rand-int 200))
+     :b (+ 55 (rand-int 200))}))

 (defn generate-points
   "Generates n points with leaders assigned. size is size of the sketch."
@@ -75,29 +78,29 @@

 (defn- setup []
-  ; ; Set frame rate to 30 frames per second.
-  ; (q/frame-rate 30)
-  ; ; Set color mode to HSB (HSV) instead of default RGB.
-  ; (q/color-mode :hsb)
-  ; setup function returns initial state. It contains
-  ; circle color and position.
+  ;; ; Set frame rate to 30 frames per second.
+  ;; (q/frame-rate 30)
+  ;; ;; Set color mode to HSB (HSV) instead of default RGB.
+  ;; (q/color-mode :hsb)
+  ;; setup function returns initial state. It contains
+  ;; circle color and position.
   {
-    :running? false
+   :running? false
    })

-; (defn- setup
-;   "Standard quil function which sets up a sketch and returns initial state."
-;   []
-;   (q/frame-rate 30)
-;   (let [size (q/width)
-;         n (int (q/map-range size
-;                             200 500
-;                             15 25))]
-;    {:points (generate-points n size)
-;     :running? true
-;     :dragging nil
-;     :n n
-;     :size size}))
+;; (defn- setup
+;;   "Standard quil function which sets up a sketch and returns initial state."
+;;   []
+;;   (q/frame-rate 30)
+;;   (let [size (q/width)
+;;         n (int (q/map-range size
+;;                             200 500
+;;                             15 25))]
+;;    {:points (generate-points n size)
+;;     :running? true
+;;     :dragging nil
+;;     :n n
+;;     :size size}))

 ;;;
 ;;; Update logic
@@ -161,18 +164,20 @@
           n (int (q/map-range size
                               200 500
                               15 25))]
-     {:points (generate-points n size)
-      :running? true
-      :dragging nil
-      :n n
-      :size size})))
+      {:points (generate-points n size)
+       :running? true
+       :dragging nil
+       :n n
+       :size size})))

 ;;;
 ;;; Draw
 ;;;

 (defn draw-point [p]
-  (q/point (:x p) (:y p)))
+  (do
+    (q/stroke (:r p) (:g p) (:b p))
+    (q/point (:x p) (:y p))))

 (defn find-points
   "Finds all points in 10-pixel approximity of point (x,y)."
@@ -197,47 +202,26 @@
     (q/stroke 255 0 0)
     (draw-point p1)
     (draw-point p2)
-    (q/stroke-weight 1)
+    (q/stroke-weight 5) ;; CHANGE THIS to tweak line width!
     (q/line (+ mx a) (+ my b) (- mx a) (- my b))))

 (defn- draw-state
   "Draws sketch state."
   [{:keys [points] :as state}]
   ;;(q/background 250)
-  ; Use different point size depending on
-  ; screen size.
+  ;; Use different point size depending on
+  ;; screen size.
   (let [weight (q/map-range (:size state)
                             200 500
-                            7 10)]
+                            20 40)] ;; CHANGE THIS to tweak circle size!
     (q/stroke-weight weight))
-  (q/stroke 0)
   (doseq [p points]
     (draw-point p))
-  ; (doseq [ind (find-points points (q/mouse-x) (q/mouse-y))]
-  ;   (draw-equidistance points (points ind))))
-   (if (< (rand-int 30) 15)
+  ;; (doseq [ind (find-points points (q/mouse-x) (q/mouse-y))]
+  ;;   (draw-equidistance points (points ind))))
+  (if (< (rand-int 30) 15)
     (doseq [ind (find-points points (rand-int (q/width)) (rand-int (q/width)))]
       (draw-equidistance points (points ind)))))
-
-;;;
-;;; User interaction
-;;;
-
-(defn mouse-dragged
-  "Drags the selected point (if any). Sets coordinates of the selected
-  point to be equals to the current mouse position."
-  [state event]
-  (if-let [ind (:dragging state)]
-    (update-in state [:points ind] merge (select-keys event [:x :y]))
-    state))
-
-(defn mouse-pressed
-  "Selects a point for dragging. Adds the point index to the state."
-  [state event]
-  (let [ind (-> (:points state)
-                (find-points (:x event) (:y event))
-                first)]
-    (assoc state :dragging ind)))

 (defn regenerate-points
   "Regenerates points in the state map."
@@ -245,44 +229,22 @@
   (assoc state :points
          (generate-points (:n state) (:size state))))

-(defn change-n
-  "Updates n - number of points. fn is a function using which n is updated,
-  either inc or dec. Regenerates points after that."
-  [state fn]
-  (-> state
-      (update-in [:n] #(max 3 (fn %)))
-      regenerate-points))
-
-(defn key-pressed
-  "Process key event.
-  r - regenerate points
-  m,l - increase/decrease number of points and regenerate them
-  space - pause sketch"
-  [state event]
-  (condp = (:key event)
-    :r (regenerate-points state)
-    :up (change-n state inc)
-    :down (change-n state dec)
-    (keyword " ") (update-in state [:running?] not)
-    state))
-
-
 (defrecord EquilibriumLayer [state]
   Layer
   (setup-layer-state [this]
-                     (setup))
+    (setup))
   (update-layer-state [this state]
-                      (update-state state))
+    (update-state state))
   (draw-layer-state [this state]
-                    (draw-state state)))
-
-; (q/defsketch equilibrium
-;     :host "host"
-;     :size [500 500]
-;     :setup setup
-;     :update update-state
-;     :draw draw-state
-;     :mouse-pressed mouse-pressed
-;     :mouse-dragged mouse-dragged
-;     :key-pressed key-pressed
-;     :middleware [m/fun-mode])
+    (draw-state state)))
+
+;; (q/defsketch equilibrium
+;;     :host "host"
+;;     :size [500 500]
+;;     :setup setup
+;;     :update update-state
+;;     :draw draw-state
+;;     :mouse-pressed mouse-pressed
+;;     :mouse-dragged mouse-dragged
+;;     :key-pressed key-pressed
+;;     :middleware [m/fun-mode])


GR - fix title on objective details

GR - fix title on objective details

--- src/objective8/handlers/front_end.clj
+++ src/objective8/handlers/front_end.clj
@@ -103,7 +103,7 @@
                                           request
                                           :objective formatted-objective
                                           :comments comments
-                                          :doc (let [details (str (:title objective) " | Objective8")]
+                                          :doc (let [details (str (:title objective) " | Objective[8]")]
                                                  {:title details
                                                   :description details})))
            (= objective-status ::http-api/not-found) (error-404-response request)


Remove bad comment

Remove bad comment

--- src/onyx/messaging/protocol_aeron.clj
+++ src/onyx/messaging/protocol_aeron.clj
@@ -5,7 +5,6 @@
            [uk.co.real_logic.agrona.concurrent UnsafeBuffer]
            [uk.co.real_logic.agrona DirectBuffer MutableDirectBuffer]))

-;comment
 ;;;;;;
 ;; Constants


Update graphics example.

Update graphics example.

--- src/quil_cljs_examples/graphics/graphics.cljs
+++ src/quil_cljs_examples/graphics/graphics.cljs
@@ -2,16 +2,21 @@
 	(:require [quil.core :as q])
 	(:use-macros [quil.core :only [defsketch with-graphics]]))

+(def g (atom nil))
+
+(defn setup []
+	(reset! g (q/create-graphics 100 100 :p3d)))
+

 (defn draw []
 	(q/background 255)
-	(let [g (q/create-graphics 100 100 :p2d)]
-		(with-graphics g
-			(q/background 102))
-		(q/image g 10 10)))
+	(with-graphics @g
+		(q/background 102))
+	(q/image @g 10 10))

 (defsketch graphics
 	:host "graphics"
 	:draw draw
+	:setup setup
 	:size [300 300])


remove some outdated comments

remove some outdated comments

--- frontend/components/landing.cljs
+++ frontend/components/landing.cljs
@@ -520,7 +520,7 @@

 (defn home [app owner]
   (reify
-    om/IDisplayName (display-name [_] "Homepage B")
+    om/IDisplayName (display-name [_] "Homepage")
     om/IInitState
     (init-state [_]
       {:header-logo-visible false
@@ -532,7 +532,6 @@
     (render [_]
       (html
        [:div.home.page
-        ;; xxx less stuff in here
         (om/build nav (om/get-state owner))
         (om/build prolog {} {:opts {:logo-visibility-callback
                                     (fn [visible?]
@@ -549,7 +548,6 @@
         (om/build purpose {})
         (om/build practice (select-in app [state/customer-logo-customer-path
                                            state/selected-toolset-path]))
-        ;; xxx: use state and determine animate elsewhere
         (om/build potential {})
         (om/build epilog {} {:opts {:cta-visibility-callback
                                     (fn [visible?]


Remove use debug. Was causing warnings in swank

--- src/useful/fn.clj
+++ src/useful/fn.clj
@@ -1,5 +1,4 @@
-(ns useful.fn
-  (:use useful.debug))
+(ns useful.fn)

 (def ! complement)


fix bug in set-dashboard-crumbs

fix bug in set-dashboard-crumbs

--- frontend/utils/state.cljs
+++ frontend/utils/state.cljs
@@ -4,12 +4,12 @@

 (defn set-dashboard-crumbs [state {:keys [org repo branch]}]
   (if-let [path-crumbs (seq (concat
-                              (when org {:type :org
-                                         :username org})
-                              (when repo {:type :project
-                                          :username org :project repo})
-                              (when branch {:type :project-branch
-                                            :username org :project repo :branch branch})))]
+                             (when org [{:type :org
+                                         :username org}])
+                             (when repo [{:type :project
+                                          :username org :project repo}])
+                             (when branch [{:type :project-branch
+                                            :username org :project repo :branch branch}])))]
     (let [path-crumbs (assoc-in (vec path-crumbs)
                                 [(-> path-crumbs count dec) :active]
                                 true)
@@ -20,7 +20,7 @@
                                    :username org})
           all-crumbs (conj path-crumbs setting-crumb)]
       (assoc-in state state/crumbs-path all-crumbs))
-      state))
+    state))

 (defn reset-current-build [state]
   (assoc state :current-build-data {:build nil


Improve race condition in test

Improve race condition in test

--- test/clj/com/palletops/leaven/readme_test.clj
+++ test/clj/com/palletops/leaven/readme_test.clj
@@ -39,6 +39,7 @@
   (is (= 1 (async/<!! c)))
   (is (= 2 (async/<!! c)))
   (is (= 3 (async/<!! c)))
+  (Thread/sleep 100)
   (alter-var-root #'counter leaven/stop)
   (is (= 4 (async/<!! c)))
   (is (nil? (async/<!! c))))


simplify the ->> pipeline in (defn generate)

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -62,39 +62,35 @@

      ;; For each such map:complement-position -> complements, find all possible combinations of complements, taking one complement per position.
      ;; The result is a trellis for each bolt, and a path through this trellis is a generated expression, with one complement for each complement position.
-     (map (fn [each-bolt-and-comps]
-             (let [paths-to-comps (keys each-bolt-and-comps)
-                   vals (vals each-bolt-and-comps)]
-               (map (fn [each-path-through-trellis]
-                      (zipmap paths-to-comps each-path-through-trellis))
-                    (apply combo/cartesian-product vals)))))
-
-     ;; for each such path through each such trellis, unify the bolt with all of its complements to create a final expression tree.
-     (mapcat (fn [bolt-groups] ;; TODO: explain what a 'bolt group' is: (a map from complement positions to a complement for each such position)
-               (map (fn [bolt-and-comps]
-                      (let [bolt (get bolt-and-comps [])
-                            paths-and-comps (dissoc bolt-and-comps [])
-                            paths-to-comps (keys paths-and-comps)
-                            result (reduce (fn [a b]
-                                             (let [result
-                                                   (cond (or (= :fail a)
-                                                             (= :fail b)) :fail
-                                                         true (unify a b))]
-                                               (when (and (not (= :fail a)) (not (= :fail b)))
-                                                 (if (= :fail result)
-                                                   (log-unification-failure a b model)
-                                                   (log/debug (str "unify(" ((:morph-ps model) a)
-                                                                   " , " ((:morph-ps model) b) ") => "
-                                                                   ((:morph-ps model) result)))))
-                                               result))
-                                           (cons bolt
-                                                 (map (fn [path-to-comp]
-                                                        (let [complement (get paths-and-comps path-to-comp)]
-                                                          (assoc-in bolt path-to-comp complement)))
-                                                      paths-to-comps)))]
-                        (log/debug (str "generate-all: result: " ((:morph model) result)))
-                        result))
-                    bolt-groups)))
+     (mapcat (fn [each-bolt-and-comps]
+               (let [paths-to-comps (keys each-bolt-and-comps)
+                     vals (vals each-bolt-and-comps)]
+                 (map (fn [each-path-through-trellis]
+                        (zipmap paths-to-comps each-path-through-trellis))
+                      (apply combo/cartesian-product vals)))))
+
+     ;; for each such path through a trellis, unify the bolt with all of its complements to create a final expression tree.
+     (map (fn [bolt-and-comps]
+            (let [bolt (get bolt-and-comps [])
+                  paths-and-comps (dissoc bolt-and-comps [])
+                  paths-to-comps (keys paths-and-comps)]
+              (reduce (fn [a b]
+                        (let [result
+                              (cond (or (= :fail a)
+                                        (= :fail b)) :fail
+                                    true (unify a b))]
+                          (when (and (not (= :fail a)) (not (= :fail b)))
+                            (if (= :fail result)
+                              (log-unification-failure a b model)
+                              (log/debug (str "unify(" ((:morph-ps model) a)
+                                              " , " ((:morph-ps model) b) ") => "
+                                              ((:morph-ps model) result)))))
+                          result))
+                      (cons bolt
+                            (map (fn [path-to-comp]
+                                   (let [complement (get paths-and-comps path-to-comp)]
+                                     (assoc-in bolt path-to-comp complement)))
+                                 paths-to-comps))))))

      (map #(do-defaults % model)) ;; for each tree, run model defaults.


s/trace/debug/

s/trace/debug/

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -91,7 +91,7 @@
                            (lightning-bolt grammar lexicon each-spec depth index morph total-depth))
                          spec))
     (do
-      (log/trace (str "lightning-bolt(depth=" depth ", total-depth=" total-depth "): sem:" (strip-refs (get-in spec [:synsem :sem]))))
+      (log/debug (str "lightning-bolt(depth=" depth ", total-depth=" total-depth "): sem:" (strip-refs (get-in spec [:synsem :sem]))))
       (let [morph (if morph morph (fn [input] (get-in input [:rule] :default-morph-no-rule)))
             depth (if depth depth 0)
             parents (filter #(not (fail? %)) (map (fn [rule] (unifyc spec rule)) grammar))]


s/map/pmap/

s/map/pmap/

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -94,7 +94,7 @@
       (log/debug (str "lightning-bolt(depth=" depth ", total-depth=" total-depth "): sem:" (strip-refs (get-in spec [:synsem :sem]))))
       (let [morph (if morph morph (fn [input] (get-in input [:rule] :default-morph-no-rule)))
             depth (if depth depth 0)
-            parents (filter #(not (fail? %)) (map (fn [rule] (unifyc spec rule)) grammar))]
+            parents (filter #(not (fail? %)) (pmap (fn [rule] (unifyc spec rule)) grammar))]
         (let [lexical ;; 1. generate list of all phrases where the head child of each parent is a lexeme.
               (reduce concat
                       (pmap (fn [parent]


Convert cljx to reader conditionals

Convert cljx to reader conditionals

--- src/bootstrap_cljs.cljc
+++ src/bootstrap_cljs.cljc
@@ -52,26 +52,27 @@
     Tooltip
     Well])

-#+clj
-(defn ^:private gen-bootstrap-inline-fn [tag]
-  `(defmacro ~(symbol (kebab-case (str tag)))
-     [opts# & children#]
-     (let [ctor# '(.createFactory js/React (~(symbol (str ".-" (name tag))) js/ReactBootstrap))]
-       (if (om-tools.dom/literal? opts#)
-         (let [[opts# children#] (om-tools.dom/element-args opts# children#)]
-           (cond
-            (every? (complement om-tools.dom/possible-coll?) children#)
-            `(~ctor# ~opts# ~@children#)
+#?(:clj
+    (defn ^:private gen-bootstrap-inline-fn [tag]
+      `(defmacro ~(symbol (kebab-case (str tag)))
+         [opts# & children#]
+         (let [ctor# '(.createFactory js/React (~(symbol (str ".-" (name tag))) js/ReactBootstrap))]
+           (if (om-tools.dom/literal? opts#)
+             (let [[opts# children#] (om-tools.dom/element-args opts# children#)]
+               (cond
+                (every? (complement om-tools.dom/possible-coll?) children#)
+                `(~ctor# ~opts# ~@children#)

-            (and (= (count children#) 1) (vector? (first children#)))
-            `(~ctor# ~opts# ~@(-> children# first flatten))
+                (and (= (count children#) 1) (vector? (first children#)))
+                `(~ctor# ~opts# ~@(-> children# first flatten))

-            :else
-            `(apply ~ctor# ~opts# (flatten (vector ~@children#)))))
-         `(om-tools.dom/element ~ctor# ~opts# (vector ~@children#))))))
+                :else
+                `(apply ~ctor# ~opts# (flatten (vector ~@children#)))))
+             `(om-tools.dom/element ~ctor# ~opts# (vector ~@children#)))))))

-(defmacro ^:private gen-bootstrap-inline-fns []
-  `(do ~@(clojure.core/map gen-bootstrap-inline-fn bootstrap-tags)))
+#?(:clj
+    (defmacro ^:private gen-bootstrap-inline-fns []
+      `(do ~@(clojure.core/map gen-bootstrap-inline-fn bootstrap-tags))))

-#+clj
-(gen-bootstrap-inline-fns)
+#?(:clj
+    (gen-bootstrap-inline-fns))


Remove an unnecessary binding

Remove an unnecessary binding

--- src/cljam/tools/cli.clj
+++ src/cljam/tools/cli.clj
@@ -236,7 +236,7 @@
         (flush)))))

 (defn pileup [args]
-  (let [{:keys [options arguments errors summary]
+  (let [{:keys [arguments errors summary]
          {:keys [help region simple ref thread]} :options} (parse-opts args pileup-cli-options)]
     (cond
       help (exit 0 (pileup-usage summary))


* src/cljs/cljs/core.cljs: remove js* use

--- src/cljs/cljs/core.cljs
+++ src/cljs/cljs/core.cljs
@@ -1257,10 +1257,10 @@
 (extend-type js/String
   IFn
   (-invoke
-    ([_ coll]
-       (get coll (js* "this.toString()")))
-    ([_ coll not-found]
-       (get coll (js* "this.toString()") not-found))))
+    ([this coll]
+       (get coll (.toString this)))
+    ([this coll not-found]
+       (get coll (.toString this) not-found))))

 (set! js/String.prototype.apply
       (fn


More documentation

More documentation

--- src/cljs/cljs/core.cljs
+++ src/cljs/cljs/core.cljs
@@ -32,19 +32,25 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; arrays ;;;;;;;;;;;;;;;;

 (defn- array-clone [array-like]
+  "Returns a javascript array, cloned from the passed in array"
   #_(goog.array.clone array-like)
   (js* "Array.prototype.slice.call(~{array-like})"))

 (defn array [var-args];; [& items]
+  "Creates a new javascript array."
   (js* "Array.prototype.slice.call(arguments)"))

 (defn aget [array i]
+  "Returns the value at the index/indices."
   (js* "~{array}[~{i}]"))

 (defn aset [array i val]
+  "Sets the value at the index/indices."
   (js* "(~{array}[~{i}] = ~{val})"))

 (defn alength [array]
+  "Returns the length of the Java array. Works on arrays of all
+  types."
   (js* "~{array}.length"))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;; core protocols ;;;;;;;;;;;;;
@@ -122,12 +128,14 @@

 ;;;;;;;;;;;;;;;;;;; fundamentals ;;;;;;;;;;;;;;;
 (defn identical? [x y]
+  "Tests if 2 arguments are the same object"
   (js* "(~{x} === ~{y})"))

 (defn = [x y]
   (-equiv x y))

 (defn nil? [x]
+  "Returns true if x is nil, false otherwise."
   (identical? x nil))

 ;;;;;;;;;;;;;;;;;;; protocols on primitives ;;;;;;;;


print the filename when loading a path

print the filename when loading a path

--- src/cljs/lumo/repl.cljs
+++ src/cljs/lumo/repl.cljs
@@ -355,7 +355,7 @@
   (load {:file filename}
     (fn [{:keys [lang source cache]}]
       (if source
-        (execute-source source (assoc opts :type "text"))
+        (execute-source source (assoc opts :type "text" :filename filename))
         (handle-repl-error (ex-info (str "Could not load file " filename) {}))))))

 (def ^:private repl-special-fns
@@ -411,7 +411,7 @@
     (r/read {:read-cond :allow :features #{:cljs}} reader)))

 (defn- execute-text
-  [source {:keys [expression?] :as opts}]
+  [source {:keys [expression? filename] :as opts}]
   (binding [cljs/*eval-fn*   caching-node-eval
             cljs/*load-fn*   load
             ana/*cljs-ns*    @current-ns
@@ -425,7 +425,10 @@
         (cljs/eval-str
           st
           source
-          (if expression? source "source")
+          (cond
+            expression? source
+            filename filename
+            :else "source")
           (merge (make-eval-opts)
             (when expression?
               {:context :expr