Interim commit - old move-base-unsafe

Interim commit - old move-base-unsafe

--- ros/angelic_planning/src/ros/robot.clj
+++ ros/angelic_planning/src/ros/robot.clj
@@ -45,7 +45,8 @@

 (defmsgs  [std_msgs Float64]
-	  [geometry_msgs PointStamped PoseStamped PoseWithRatesStamped]
+	  [geometry_msgs PointStamped PoseStamped PoseWithRatesStamped
+	    PoseWithCovariance]
 	  [robot_msgs PoseDot]
 	  [nav_robot_actions MoveBaseState]
 	  [motion_planning_msgs
@@ -107,6 +108,8 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Base ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

+(def *current-base-pose* (atom nil))
+(def *base-pose-sub* (atom nil))

 (defstruct robot-base-state    :class :x :y :theta)

@@ -119,6 +122,7 @@
 (defn pose-stamped->base-state [pose-stamped]
   (assert (#{"map" "/map"} (:frame_id (:header pose-stamped))))
   (let [pose (condp = (:class pose-stamped)
+	       PoseWithCovariance   (:pose pose-stamped)
 	       PoseStamped          (:pose pose-stamped)
 	       PoseWithRatesStamped (:pose (:pose_with_rates pose-stamped)))]
     (make-robot-base-state
@@ -133,8 +137,22 @@
 	    :orientation (angle->quaternion (:theta base-state))}})

-(defn get-current-base-pose [#^NodeHandle nh]
-  (get-single-message nh "/base_pose_ground_truth" (PoseWithRatesStamped.)))
+;(defn get-current-base-pose [#^NodeHandle nh]
+;  (get-single-message nh "/base_pose_ground_truth" (PoseWithRatesStamped.)))
+
+(let [mem (atom {})]
+  (def get-current-base-pose
+     (fn [#^NodeHandle nh]
+       (let [a
+	     (or (@mem nh)
+		 (let [a (atom nil)]
+		   (.subscribe nh "/amcl_pose" (PoseWithCovariance.)
+				      (sub-cb [m] (reset! a m)) 1)
+		   (swap! mem assoc nh a)
+		   a))]
+	 (.spinOnce nh)
+	 (while (not @a) (.spinOnce nh))
+	 @a))))

 (defn get-current-base-state [#^NodeHandle nh]
   (pose-stamped->base-state (get-current-base-pose nh)))
@@ -197,23 +215,27 @@
     (.shutdown pub)))

-(defn move-base-forward-unsafe
-  "Directly moves using base controllers, without invoking planning"
-  [#^NodeHandle nh distance]
+(defn move-base-rel
+  "Directly moves using base controllers (unsafe), without invoking planning"
+  [#^NodeHandle nh coord distance]
+  (assert (#{:vx :vy} coord))
+  (let [distance (double distance)
+	dir (Math/signum distance)
+	distance (Math/abs distance)]
    (move-base-unsafe nh
     (fn [init-pose current-pose]
       (let [dist (- distance (point-distance (:position init-pose) (:position current-pose)))]
-	{:vel {:vx (if (> dist 0.1) 0.5 (* dist 3))}}))
+	{:vel {coord (* dir (if (> dist 0.1) 0.5 (* dist 3)))}}))
     (fn [init-pose current-pose]
       (let [dist (- distance (point-distance (:position init-pose) (:position current-pose)))]
-	(< dist 0.005)))))
+	(< (Math/abs (double dist)) 0.005))))))

 (defn norm-angle [a]
   (cond (> a Math/PI) (- a (* 2 Math/PI))
 	(< a (- Math/PI)) (+ a (* 2 Math/PI))
 	:else a))

-(defn spin-base-unsafe
+(defn spin-base
   "Spins base at a specified vecocity (pos = ccw) for a specified time."
   [#^NodeHandle nh vel secs]
   (let [pub (.advertise nh "/cmd_vel" (PoseDot.) 1)
@@ -227,7 +249,7 @@
 	(recur)))
     (.shutdown pub)))

-(defn spin-base-to-angle-unsafe
+(defn spin-base-to
   "Spins base to a desired angle, with no collision checking."
   [#^NodeHandle nh angle]
   (move-base-unsafe nh
@@ -386,6 +408,7 @@
 (def *arm-joints*
   ["shoulder_pan_joint" "shoulder_lift_joint" "upper_arm_roll_joint"
    "elbow_flex_joint" "forearm_roll_joint" "wrist_flex_joint" "wrist_roll_joint"])
+(def *arm-joint-wraps* [false false false false true false true])

 (def *larm-joints* (map #(str "l_" %) *arm-joints*))
 (def *rarm-joints* (map #(str "r_" %) *arm-joints*))
@@ -417,6 +440,21 @@
 		    (if right? *rarm-joints* *larm-joints*)
 		    (safe-get* (if right? *rarm-joint-states* *larm-joint-states*) name))))))

+(defn arm-l2-distance [j1 j2]
+  (Math/sqrt (double (apply + (map #(* % %)
+    (for [[v1 v2 roll?] (map vector j1 j2 *arm-joint-wraps*)]
+      (let [diff (Math/abs (double (- v1 v2)))]
+	(if roll? (if (> diff Math/PI) (- (* 2 Math/PI) diff) diff) diff))))))))
+
+
+(defn interpolate-arm-joint [v1 v2 w wrap?]
+  (let [dist (double (- v2 v1))]
+    (if (or (not wrap?) (< (Math/abs dist) Math/PI))
+        (+ v1 (* dist w))
+      (norm-angle (- v1 (* (- (* 2 Math/PI) dist) w))))))
+
+(defn interpolate-arm-joints [j1 j2 w]
+  (map (fn [v1 v2 wrap?] (interpolate-arm-joint v1 v2 w wrap?)) j1 j2 *arm-joint-wraps*))

 ;;; Using known states ;;;

@@ -438,11 +476,7 @@
      :points (map (fn [m t] {:positions (map m ks) :time t}) [init-joints final-joints] [0 0.2])}))

-(defn arm-l2-distance [j1 j2]
-  (Math/sqrt (double (apply + (map #(* % %)
-    (for [[v1 v2 roll?] (map vector j1 j2 [false false false false true false true])]
-      (let [diff (Math/abs (double (- v1 v2)))]
-	(if roll? (if (> diff Math/PI) (- (* 2 Math/PI) diff) diff) diff))))))))
+

  ;; TODO: handle wraparound
 (defn make-smooth-joint-trajectory [init-joints final-joints step-l2 step-time]
@@ -458,7 +492,9 @@
     {:class JointTraj :names ks
      :points
        (for [t (range (inc steps))]
-	 {:positions (map + j1 (map #(* % (/ t steps)) jd)) :time (* step-time t)})}))
+	 {:positions (interpolate-arm-joints j1 j2 (/ t steps))
+	    ;(map + j1 (map #(* % (/ t steps)) jd))
+	  :time (* step-time t)})}))

 (defn start-trajectory [#^NodeHandle nh srv-prefix traj]
@@ -797,12 +833,29 @@
 	  :pose   {:position    {:x x :y y :z z}
 		   :orientation (axis-angle->quaternion-msg [ax ay az] angle)}}})))

+(def *upright-rgripper-constraint*
+  (let [tolv 0.5
+	tol {:x tolv :y tolv :z tolv}]
+   {:joint_constraint nil
+    :pose_constraint
+     [{:type (+ PoseConstraint/ORIENTATION_R PoseConstraint/ORIENTATION_P)
+       :link_name "r_gripper_palm_link"
+       :pose {:header *bl-header* :pose (make-pose [0 0 0] [0 0 0 1])}
+       :orientation_importance 1.0
+       :orientation_tolerance_above tol
+       :orientation_tolerance_below tol
+       :position_tolerance_above tol
+       :position_tolerance_below tol}]}))
+
+
 (defn plan-arm-motion
   "joint constraints are passed as map from name to either value,
    which will use this tolerance, or interval, or joint_constraint map.
    pose constraints are lists of PoseConstraints maps -- no shortcuts for now.
    Init-joints should include base and torso, in general."
-  [#^NodeHandle nh right? world robot-state joint-constraints pose-constraints]
+  ([#^NodeHandle nh right? world robot-state joint-constraints pose-constraints]
+     (plan-arm-motion nh right? world robot-state joint-constraints pose-constraints *no-constraints*))
+  ([#^NodeHandle nh right? world robot-state joint-constraints pose-constraints path-constraints]
   (println "Putting collision map")
   (put-single-message-cached nh "/collision_map_future" (map-msg (world->collision-map world)))
 ;  (println "\n\n\n\n\n\n\n\n" right?)
@@ -815,9 +868,9 @@
      {:class GetMotionPlan$Request :times 1 :allowed_time 0.5 :planner_id ""
       :params (if right? *rarm-params* *larm-params*)
       :start_state      (doall (map make-kinematic-joint (get-joint-map robot-state)))
-      :path_constraints *no-constraints*
+      :path_constraints path-constraints
       :goal_constraints {:pose_constraint (vec pose-constraints)
-			 :joint_constraint (vec (map parse-joint-constraint joint-constraints))}})))
+			 :joint_constraint (vec (map parse-joint-constraint joint-constraints))}}))))

 (defn describe-motion-plan [plan]


Support :test as a shortcut

Support :test as a shortcut

:test args is short for :run frege.tools.Quick args

--- src/leiningen/fregec.clj
+++ src/leiningen/fregec.clj
@@ -50,13 +50,14 @@
                            arg)) args))

 (defn- run-class-args
-  "Given command line arguments, extract :run ClassName.
-  Returns a pair of ClassName (or nil) and the args without :run."
+  "Given command line arguments, extract keyword arg and ClassName.
+  Returns a vector of the keyword arg (or nil), the ClassName (or nil), the args
+  before the keyword arg, and the args after the ClassName."
   [args]
-  (let [[before run-etc] (split-with (partial not= ":run") args)]
-    (if (seq run-etc)
-      [(second run-etc) before (rest (rest run-etc))]
-      [nil args nil])))
+  (let [[before & [kw arg & run-args]] (split-with (fn [arg] (not= \: (first arg))) args)]
+    (if (and kw arg (seq run-args))
+      [(keyword (subs kw 1)) arg before run-args]
+      [nil nil args nil])))

 (defn- run-main-form
   "Build a form that can run the main method of the given class."
@@ -78,7 +79,7 @@
 To display the Frege compiler's help, use: lein fregec :help"
   [project & args]
   (binding [*out* *err*]
-    (let [[class-name args run-args] (run-class-args args)
+    (let [[op class-name args run-args] (run-class-args args)
           project (merge {:frege-source-paths ["."]} project)
           srcs  (:frege-source-paths project)
           out   (:compile-path project)
@@ -104,4 +105,6 @@
                       (subprocess-compiler-form fregec-args)))
       (when class-name
         (eval/eval-in (project/merge-profiles project [subprocess-profile])
-                      (run-main-form class-name (vec run-args)))))))
+                      (case op
+                        :run (run-main-form class-name (vec run-args))
+                        :test (run-main-form "frege.tools.Quick" (into [class-name] run-args))))))))


Change source to website. Open source page when clicking plugin title.

--- src/lt/objs/plugins.cljs
+++ src/lt/objs/plugins.cljs
@@ -494,7 +494,7 @@
    (search-input this)])

 (defui source-button [plugin]
-  [:span.source [:a {:href (:url plugin (:source plugin))} "source"]]
+  [:span.source [:a {:href (:url plugin (:source plugin))} "website"]]
   :click (fn [e]
            (dom/prevent e)
            (dom/stop-propagation e)
@@ -525,6 +525,13 @@
                                                          (notifos/set-msg! (str "Installed " (:name plugin) " " (:version plugin))))))))
            (dom/prevent e)
            (dom/stop-propagation e)))
+
+(defui plugin-title [plugin]
+  [:h1 (:name plugin) [:span.version (:version plugin)]]
+  :click (fn [e]
+           (dom/prevent e)
+           (dom/stop-propagation e)
+           (platform/open-url (:url plugin (:source plugin)))))

 (defui server-plugin-ui [plugin]
   (let [info plugin
@@ -540,7 +547,7 @@
          (update-button plugin)
          [:span.installed]))
      (source-button plugin)
-     [:h1 (:name info) [:span.version ver]]
+     (plugin-title plugin)
      [:h3 (:author info)]
      [:p (:desc info)]]))

@@ -566,7 +573,7 @@
        (update-button (assoc plugin :version cached)))
      (uninstall-button plugin)
      (source-button plugin)
-     [:h1 (:name plugin) [:span.version (:version plugin)]]
+     (plugin-title plugin)
      [:h3 (:author plugin)]
      [:p (:desc plugin)]
      ]))


Added a shuffle button - ez

Added a shuffle button - ez

--- src/matchmaker/core.cljs
+++ src/matchmaker/core.cljs
@@ -4,6 +4,7 @@

 (defonce players-tsv (atom ""))
 (defonce attendance-tsv (atom ""))
+(defonce shuffle-count (atom 0))

 (def rank-scores
   {"NONE" 0
@@ -99,8 +100,10 @@
   [:ul.teams (map (fn [t] [:li {:key (hash t)} (team t)]) teams)])

 (defn results []
+  @shuffle-count
   (let [result (make-teams)]
     [:section.results
+     [:button {:on-click #(swap! shuffle-count inc)} "Shuffle!"]
      [:section.teams
       [:h3 "Teams"]
       (team-list (:teams result))]


Blacklist symbols related to asset manager

--- src/nightmod/sandbox.clj
+++ src/nightmod/sandbox.clj
@@ -32,7 +32,8 @@
        pmap pcalls
        System/out System/in System/err
        defgame set-screen! setScreen set-screen-wrapper! app! app on-gl
-       set-asset-manager!
+       loader loader! resolver
+       asset-manager* asset-manager set-asset-manager!
        reify proxy gen-class})
    (jail-test/blacklist-nses '[clojure.main])
    (jail-test/blanket "clojail")])


RS & MG | #9 | Add questions url to safe referal whitelist

--- src/objective8/utils.clj
+++ src/objective8/utils.clj
@@ -35,7 +35,9 @@
     (fn [fragment] (when fragment (re-matches fragment-regex fragment))))

 (defn safen-url [target]
-  (or ((regex-checker #"/objectives/\d+") target) ((regex-checker #"/objectives/\d+/questions/\d+") target)))
+  (or ((regex-checker #"/objectives/\d+") target)
+      ((regex-checker #"/objectives/\d+/questions") target)
+      ((regex-checker #"/objectives/\d+/questions/\d+") target)))

 ;;DISABLE CSRF for tests


Fix table spacer.

Fix table spacer.

--- src/oc/email/content.clj
+++ src/oc/email/content.clj
@@ -147,13 +147,7 @@
     [:tr
       [:th {:class "small-12 large-12 first last columns"}
         [:table
-          [:tr
-            [:th
-              [:table {:class "spacer"}
-                [:tr
-                  [:td {:height (str "font-size:" pixels "px")
-                        :style (str "font-size:" pixels "px;line-height:" pixels "px;")} " "]]]]
-                [:th {:class "expander"}]]]]]]))
+          (tr-spacer pixels)]]]]))

 (defn- paragraph [content]
   [:table {:class "row"}


Do not add nil states to a row if there is no state

--- src/mdr2/db.clj
+++ src/mdr2/db.clj
@@ -12,7 +12,9 @@
   (update-in row [:state] state/from-int))

 (defn map-state-to-int [row]
-  (update-in row [:state] state/to-int))
+  (if-let [state (:state row)]
+    (assoc row :state (states/to-int state))
+    row))

 (defn find
   "Return production for given `id`"


don't compile less until the server is ready!

--- src/pc/init.clj
+++ src/pc/init.clj
@@ -27,7 +27,6 @@
   [#'pc.logging/init
    #'pc.nrepl/init
    #'pc.statsd/init
-   #'pc.less/init
    #'pc.datomic/init
    #'pc.datomic.schema/init
    #'pc.datomic.migrations/init
@@ -39,6 +38,7 @@
    #'pc.cache/init
    #'pc.stripe/init
    #'pc.server/init
+   #'pc.less/init
    #'pc.http.webhooks/init
    #'pc.datomic.admin-db/init
    #'pc.http.admin/init


Add distance function to math ns.

Add distance function to math ns.

--- src/uxbox/util/math.cljs
+++ src/uxbox/util/math.cljs
@@ -67,3 +67,11 @@
   "Converts radians to degrees."
   [^number radiants]
   (math/toDegrees radiants))
+
+(defn distance
+  "Calculate the distance between two points."
+  [[x1 y1] [x2 y2]]
+  (let [dx (- x1 x2)
+        dy (- y1 y2)]
+    (-> (sqrt (+ (pow dx 2) (pow dy 2)))
+        (precision 2))))


Refactored

Refactored

--- src/varjocafe/format.clj
+++ src/varjocafe/format.clj
@@ -49,8 +49,8 @@
       nil
       [days times])))

-(defn opening-times [spec]
-  (->> spec
+(defn opening-times [schedule]
+  (->> schedule
        (map opening-time)
        (remove empty?)
        (flatten)))
@@ -67,8 +67,8 @@
 (defn opening-times-html
   ([restaurant category]
     (opening-times-html (get-in restaurant [:information category :regular])))
-  ([spec]
-    (->> spec
+  ([schedule]
+    (->> schedule
          (opening-times)
          (partition 2)
          (map opening-time-html)


Does this work?

Does this work?

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

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

 (ns sequence-generator)


Scheduling should keywordize keys as well.

--- scheduling/src/immutant/scheduling.clj
+++ scheduling/src/immutant/scheduling.clj
@@ -26,8 +26,8 @@
    Any options here are applied to the scheduler with the given name,
    but only if it has not yet been instantiated."
   [& {:as opts}]
-  (let [opts (->> opts
-               (merge {:name "default" :num-threads 5})
+  (let [opts (-> opts
+               keywordize-keys
                (validate-options scheduler))]
     (WunderBoss/findOrCreateComponent Scheduling
       (:name opts)
@@ -50,7 +50,8 @@
   is called with the same id, to reschedule jobs."
   ([id f spec] (schedule (scheduler) id f spec))
   ([scheduler id f spec]
-     (let [opts (->> spec
+     (let [opts (-> spec
+                  keywordize-keys
                   resolve-options
                   (validate-options schedule))]
        (.schedule scheduler (name id) f


Go to target

Go to target

--- src/bot/brain.clj
+++ src/bot/brain.clj
@@ -140,7 +140,7 @@
       (do
         (pprint state)
         (pprint my-coords)
-        (let [first-step (java-a* (get-in gameState [:map :tiles]) my-x my-y (:x exit) (:y exit))
+        (let [first-step (first (java-a* (get-in gameState [:map :tiles]) my-x my-y (first target) (second target)))
               x (first first-step)
               y (second first-step)
               tx (- x my-x)


Can't use ago during world init due to recursion.

--- src/cbfg/vis.cljs
+++ src/cbfg/vis.cljs
@@ -274,7 +274,7 @@

 (defn vis-init [world-init-cb el-prefix on-render-cb]
   (let [event-delay (atom 0)
-        event-ch (chan 10) ; TODO: hacks around RACE during early initialization!!
+        event-ch (chan)
         step-ch (chan (dropping-buffer 1))
         last-id (atom 0)
         gen-id #(swap! last-id inc)
@@ -304,37 +304,37 @@
     (let [el-event (str el-prefix "-event") ; Process U/I related events.
           el-html (str el-prefix "-html")
           el-svg (str el-prefix "-svg")]
-      (ago world w
-           (go-loop [vis-last nil ; Process render-ch, updating U/I.
-                     vis-last-positions nil
-                     vis-last-html nil
-                     vis-last-svg nil
-                     prev-deltas nil]
-             (let [[vis-next deltas after event-str] (<! render-ch)
-                   next-deltas (take 20 (conj prev-deltas [after deltas]))]
-               (set-el-innerHTML el-event event-str)
-               (if after
-                 (let [vis-next-positions (atom {})
-                       actx-ch-ch-infos (group-by #(:first-taker-actx (second %)) (:chs vis-next))]
-                   (assign-positions vis-next world vis-next-positions actx-ch-ch-infos
-                                     (when (get-in vis-next [:actxs world :closed]) 0))
-                   (let [vis-next-html (apply str (flatten (vis-html-actx vis-next world
-                                                                          actx-ch-ch-infos)))
-                         vis-next-svg (apply str (flatten (vis-svg-actxs vis-next @vis-next-positions
-                                                                         deltas true prev-deltas)))]
-                     (when (not= vis-next-html vis-last-html)
-                       (set-el-innerHTML el-html vis-next-html)
-                       (when on-render-cb
-                         (on-render-cb vis-next)))
-                     (when (not= vis-next-svg vis-last-svg)
-                       (set-el-innerHTML el-svg vis-next-svg))
-                     (recur vis-next @vis-next-positions vis-next-html vis-next-svg next-deltas)))
-                 (let [vis-next-svg (apply str (flatten (vis-svg-actxs vis-last vis-last-positions
-                                                                       deltas false prev-deltas)))]
-                   (when (not= vis-next-svg vis-last-svg)
-                     (set-el-innerHTML el-svg vis-next-svg))
-                   (recur vis-last vis-last-positions vis-last-html vis-next-svg next-deltas)))))
-           (world-init-cb world))
+      (go (let [world (conj w 'world-1)]    ; Can't use ago to initialize world.
+            (go-loop [vis-last nil          ; Process render-ch, updating U/I.
+                      vis-last-positions nil
+                      vis-last-html nil
+                      vis-last-svg nil
+                      prev-deltas nil]
+              (let [[vis-next deltas after event-str] (<! render-ch)
+                    next-deltas (take 20 (conj prev-deltas [after deltas]))]
+                (set-el-innerHTML el-event event-str)
+                (if after
+                  (let [vis-next-positions (atom {})
+                        actx-ch-ch-infos (group-by #(:first-taker-actx (second %)) (:chs vis-next))]
+                    (assign-positions vis-next world vis-next-positions actx-ch-ch-infos
+                                      (when (get-in vis-next [:actxs world :closed]) 0))
+                    (let [vis-next-html (apply str (flatten (vis-html-actx vis-next world
+                                                                           actx-ch-ch-infos)))
+                          vis-next-svg (apply str (flatten (vis-svg-actxs vis-next @vis-next-positions
+                                                                          deltas true prev-deltas)))]
+                      (when (not= vis-next-html vis-last-html)
+                        (set-el-innerHTML el-html vis-next-html)
+                        (when on-render-cb
+                          (on-render-cb vis-next)))
+                      (when (not= vis-next-svg vis-last-svg)
+                        (set-el-innerHTML el-svg vis-next-svg))
+                      (recur vis-next @vis-next-positions vis-next-html vis-next-svg next-deltas)))
+                  (let [vis-next-svg (apply str (flatten (vis-svg-actxs vis-last vis-last-positions
+                                                                        deltas false prev-deltas)))]
+                    (when (not= vis-next-svg vis-last-svg)
+                      (set-el-innerHTML el-svg vis-next-svg))
+                    (recur vis-last vis-last-positions vis-last-html vis-next-svg next-deltas)))))
+            (world-init-cb world)))
       (let [toggle-ch (listen-el (gdom/getElement el-html) "click")] ; Process toggle U/I events.
         (go-loop []
           (let [actx-id (no-prefix (.-id (.-target (<! toggle-ch))))]


Whitespace.

Whitespace.

--- src/cbfg/vis.cljs
+++ src/cbfg/vis.cljs
@@ -333,6 +333,3 @@
           (recur))))
     (vis-run-controls event-delay step-ch el-prefix)))

-
-
-


#26 - Tweaked hash active code. Started adding old ie compatibility.

--- src/biblecli/commands/staticpages.cljs
+++ src/biblecli/commands/staticpages.cljs
@@ -193,46 +193,57 @@
 ")

 (defn js []
-"(function (document, window) {
-
-var lastElem = null;
-
-function SetActiveElem(el, isActive) {
-    if(el) {
-        var t = el.className;
-        t = t.replace('active', '').trim();
-        if(isActive) {
-          t += ' active';
-        }
-        el.className = t;
-    }
-}
+"
+/*!
+ * domready (c) Dustin Diaz 2012 - License MIT
+ * https://github.com/ded/domready/blob/v0.3.0/ready.min.js
+ */
+!function(e,t){typeof module!=\"undefined\"?module.exports=t():typeof define==\"function\"&&typeof define.amd==\"object\"?define(t):this[e]=t()}(\"domready\",function(e){function p(e){h=1;while(e=t.shift())e()}var t=[],n,r=!1,i=document,s=i.documentElement,o=s.doScroll,u=\"DOMContentLoaded\",a=\"addEventListener\",f=\"onreadystatechange\",l=\"readyState\",c=o?/^loaded|^c/:/^loaded|c/,h=c.test(i[l]);return i[a]&&i[a](u,n=function(){i.removeEventListener(u,n,r),p()},r),o&&i.attachEvent(f,n=function(){/^c/.test(i[l])&&(i.detachEvent(f,n),p())}),e=o?function(n){self!=top?h?n():t.push(n):function(){try{s.doScroll(\"left\")}catch(t){return setTimeout(function(){e(n)},50)}n()}()}:function(e){h?e():t.push(e)}});
+
+(function (document, window) {
+
+var activeId = '_main';

 function FindElem(id)
 {
     return id === null ? null : document.getElementById(id);
 }

+function SetActiveElem(id) {
+  function Activate(id, active) {
+    var el = document.getElementById(id);
+    if(el) {
+      var t = el.className;
+      t = t.replace('active', '').trim();
+      if(active) {
+        t = (t + ' active').trim();
+      }
+      if(el.className !== t) {
+        el.className = t;
+      }
+    }
+    return !!el;
+  }
+
+  var ret;
+  if(id !== activeId) {
+    Activate(activeId, false);
+    ret = Activate(id, true);
+    activeId = id;
+  }
+  else {
+    ret = true;
+  }
+  return ret;
+}
+
+
 function SetActive()
 {
-    var el;
-    el = FindElem(lastElem);
-    SetActiveElem(el, false);
-    el = FindElem('_main');
-    SetActiveElem(el, false);
-
     var raw = window.location.hash.substr(1);
     var id = '_' + raw;
-    el = FindElem(id);
-    if(!el) {
-      id = '_main';
-      el = FindElem(id);
-    }
-    if(el) {
-        lastElem = id;
-        SetActiveElem(el, true);
-    } else {
-        lastElem = null;
+    if(!SetActiveElem(id)) {
+      SetActiveElem('_main');
     }
 }

@@ -253,9 +264,9 @@
   SetActive();
 });

-window.addEventListener('load', function() {
+domready(function() {
   SetActive();
-  window.setTimeout(function() { CenterElem(FindElem(lastElem)); }, 1);
+  window.setTimeout(function() { CenterElem(FindElem(activeId)); }, 0);
 });

 })(document, window);
@@ -265,7 +276,6 @@
 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
-
 ga('create', 'UA-75078401-1', 'auto');
 ga('send', 'pageview');")

@@ -385,7 +395,7 @@
         bookid (book-elem-id id)]
     [:div.book {:id (str "_" bookid)}
       [:h2.chapter (book-name-nbsp id)]
-      [:div.back [:a {:href "."} "Back to Book Lists"]]
+      [:div.back [:a {:href "#"} "Back to Book Lists"]]
       [:div.chapters
         (->> chapters
              (map (fn [ch]


limit emoji autocomplete to 10

limit emoji autocomplete to 10

--- src/chat/client/views/new_message.cljs
+++ src/chat/client/views/new_message.cljs
@@ -56,6 +56,7 @@
          (->> emoji/unicode
               (filter (fn [[k v]]
                         (simple-matches? k query)))
+              (take 10)
               (map (fn [[k v]]
                      {:action
                       (fn [thread-id])


small doc improvements

small doc improvements

--- src/insn/core.clj
+++ src/insn/core.clj
@@ -24,7 +24,7 @@
        :dynamic true}
   *method-flags* #{:public :final})

-(def ^{:doc "The default bytecode version to use if unspecified."
+(def ^{:doc "The bytecode version to use for types if unspecified."
        :dynamic true}
   *bytecode-version* 1.7)

@@ -33,17 +33,27 @@
 (declare visit-field visit-method)

 (defn visit
-  "Visit the provided type map and its members to generate the class
-  bytecode. Returns a map of the classes' :name and :bytes. Options:
+  "Generate the class bytecode from the provided type map. Returns a map
+  of the classes' :name and :bytes. Options:

     :name         of the class. Optional, but see below.
+
     :flags        seq of class/interface modifier flags (e.g., :final).
+                  See the `insn.util` namespace.
+
     :super        defaults to Object.
+
     :interfaces   sequence of interface types to extend/implement.
+
     :annotations  map or sequence of tuples, described below.
+
     :fields       sequence of field maps, described below.
+
     :methods      sequence of method maps, described below.
-    :version      bytecode version given as a double of major.minor.
+
+    :version      bytecode version given as a integer. For backwards
+                  compatibility, a float of major.minor may be given
+                  for versions 1.1 through 1.8.

   Each field and method can also be given :annotations as per above.

@@ -71,8 +81,11 @@
   Class instance/static fields are provided as maps. Options:

     :name   field name (required).
+
     :type   field type (required).
-    :flags  modifier flags.
+
+    :flags  seq of field modifier flags.
+
     :value  initial value. Only for primitive and String static fields,
             and if given, must be a corresponding Integer, Float, Long,
             Double, or String value.
@@ -88,11 +101,15 @@
     :name   method name (required). Can be either :init or :clinit,
             designating a constructor or the static initializer,
             respectively.
-    :flags  modifier flags. Ignored for the static initializer.
+
+    :flags  seq of method modifier flags. Ignored for the static
+            initializer.
+
     :desc   method parameter types and return type (specified last).
             Ignored for the static initializer, optional for
             constructors. For constructors, the method return type is
             forced to void if not explicitly specified as such.
+
     :emit   either a fn taking a MethodVisitor or a sequence of
             instructions to emit for the method (see `insn.op`).
             Optional if method is abstract.


allow empty flags to specify the defaults

--- src/insn/core.clj
+++ src/insn/core.clj
@@ -123,7 +123,7 @@
         cls (if (.contains cls ".")
               cls
               (str (munge (ns-name *ns*)) "." cls))
-        flags (set (or (seq (:flags t)) *class-flags*))
+        flags (set (seq (:flags t *class-flags*)))
         concrete? (not (or (:interface flags)
                            (:abstract flags)))
         flags (if (:interface flags) (conj flags :abstract) flags)
@@ -141,7 +141,7 @@
     (binding [util/*this* this, util/*super* super]

       (doseq [f (:fields t)]
-        (let [flags (or (seq (:flags f)) *field-flags*)
+        (let [flags (:flags f *field-flags*)
               fv (.visitField cv (util/flags flags) (:name f)
                               (util/type-desc (:type f)) nil (:value f))]
           (ann/visit fv (:annotations f))
@@ -160,12 +160,12 @@
                 [flags desc init?]
                 (case mname
                   "<clinit>" [[:static], [:void] false]
-                  "<init>" [(or (seq (:flags m)) *init-flags*)
+                  "<init>" [(:flags m *init-flags*)
                             (if (= :void (last (:desc m)))
                               (:desc m)
                               (concat (:desc m) [:void]))
                             true]
-                  #_:else [(or (seq (:flags m)) *method-flags*)
+                  #_:else [(:flags m *method-flags*)
                            (or (:desc m) [:void])
                            false])
                 mv (.visitMethod cv (util/flags flags) mname


Fix unused var warning, rename widget to app

--- src/iss/core.cljs
+++ src/iss/core.cljs
@@ -8,7 +8,13 @@

 (def app-state (atom {:foo "bar"}))

-(defn widget [data owner]
+(defstyles bump-app
+  {:container
+    {:backgroundColor white
+     :color black
+     :font system-font-large}})
+
+(defn app [data owner]
   (reify
     om/ICheckState
     om/IInitState
@@ -16,10 +22,10 @@
       {:count 0})
     om/IWillMount
     (will-mount [_]
-      (println "Hello widget mounting"))
+      (println "Hello app mounting"))
     om/IWillUnmount
     (will-unmount [_]
-      (println "Hello widget unmounting"))
+      (println "Hello app unmounting"))
     om/IRenderState
     (render-state [_ {:keys [count]}]
       (println "Render!")
@@ -39,11 +45,5 @@
                   (om/update-state! owner :count identity))}
           "Do Nothing")))))

-(defstyles bump-app
-  {:container
-    {:backgroundColor white
-     :color black
-     :font system-font-large}})
-
-(om/root widget app-state
+(om/root app app-state
   {:target (.-body js/document)})


formatting

formatting

--- test/unit/todos.cljs
+++ test/unit/todos.cljs
@@ -8,15 +8,16 @@
     [frontend.ui :as ui]))

 ;;;;;;;;;;;;;;;; Customize reporting of test.chuck
-(defmethod ct/report [::ct/default :my-shrunk] [m]
-  (newline)
+(defmethod ct/report [::ct/default :my-shrunk]
+  [m]
   (println "\nPROPERTY TEST FAILED"
            "\nCase:" (with-out-str (cljs.pprint/pprint (:fail m)))
            "\nShrunk:" (with-out-str (cljs.pprint/pprint (-> m :shrunk :smallest)))
            "\nNum tests:" (:num-tests m)
            "\nSeed:" (:seed m)))

-(defn my-shrunk-report [m]
+(defn my-shrunk-report
+  [m]
   (merge (dissoc m :result) {:type :my-shrunk}))

 ;;;;;;;;;;;;;;;;;;;;;;;; Helpers


Adding flat-map-to-pair test

Adding flat-map-to-pair test

--- test/flambo/api_test.clj
+++ test/flambo/api_test.clj
@@ -186,15 +186,14 @@
             f/collect
             vec) => [["key1" [1 2]] ["key2" [3 4]] ["key3" [5]]])

-      #_(fact
+      (fact
         "flat-map-to-pair"
-        (-> (f/parallelize c [["Four score and seven years ago our fathers"]
-                              ["brought forth on this continent a new nation"]])
+        (-> (f/parallelize c [["Four score and seven"]
+                              ["years ago"]])
             (f/flat-map-to-pair (f/fn [x] (map (fn [y] [y 1])
                                                (clojure.string/split (first x) #" "))))
-            #_f/untuple
-            #_f/collect
-            #_vec) => [["Four" 1] ["score" 1] ["and" 1] ["seven" 1] ["years" 1] ["ago" 1]])
+            (f/map f/untuple)
+            f/collect) => [["Four" 1] ["score" 1] ["and" 1] ["seven" 1] ["years" 1] ["ago" 1]])
       )))

 (facts


Format base api

Format base api

--- src/clj/clojure_template/apis/base.clj
+++ src/clj/clojure_template/apis/base.clj
@@ -4,11 +4,10 @@

 (def apis
   (api
-    {:swagger
-     {:ui   "/apis"
-      :spec "/swagger.json"
-      :data {:info {:title "APIS" :description "clojure_template apis"}
-             :tags [{:name "api", :description "apis"}]}}}
+    {:swagger {:ui   "/apis"
+               :spec "/swagger.json"
+               :data {:info {:title "APIS" :description "clojure_template apis"}
+                      :tags [{:name "api", :description "apis"}]}}}

     (context "/api/v1" []
       :tags ["api"]


Verify petro reserves and resources

Verify petro reserves and resources

--- src/clj_simple_chart/ncs/discovery.clj
+++ src/clj_simple_chart/ncs/discovery.clj
@@ -84,7 +84,7 @@
                      (map :year)
                      (apply min)))

-(def stop-year 2017) ;max-complete-year)
+(def stop-year max-complete-year)

 (def producing-field-names (->> parsed
                                 (filter #(= :producing (:status %)))
@@ -167,6 +167,28 @@
   (for [yr (range start-year (inc stop-year))]
     (produce-row-year yr :gas)))

+; http://www.npd.no/no/Tema/Ressursregnskap-og-analyser/Temaartikler/Ressursregnskap/2016/
+; Totalt olje 7308,3
+; Totalt NGL 337,3
+; Totalt Kondensat 264,4
+;
+(def oil-resources-but-not-undiscovered-gb (* 6.29e-3 (- (+ 7308.3 337.3 264.4)
+                                                         (+ 1285.0 120.0
+                                                            145
+                                                            367 14.3 3.4)))) ; 37.5
+
+(def data-factpages-oil (-> (last flat-data)
+                            (dissoc :year)
+                            (vals)
+                            ((fn [x] (* 6.29e-3 (reduce + 0 x)))))) ; 37.49
+
+(def data-factpages-gas (-> (last flat-data-gas)
+                            (dissoc :year)
+                            (vals)
+                            ((fn [x] (* 1 (reduce + 0 x)))))) ; 4279
+; (- 6070.2 1465 60 299.5) => 4245.7
+; Minus Ikkje oppdaga ressursar,	Utvinning ikkje evaluert (RK 7A) og Betinga ressursar i funn
+
 (defn explode-row [row]
   (reduce (fn [o k]
             (conj o {:year  (:year row)
@@ -177,13 +199,13 @@
 (def exploded-data-liquids-gboe
   (->> flat-data
        (mapcat explode-row)
-       (map #(update % :value (fn [v] (double (/ (* 6.29 v) 1000)))))
+       (map #(update % :value (fn [v] (double (* 6.29e-3 v)))))
        (sort-by :year)
        (vec)))

 (def exploded-data-gas-gboe
   (->> flat-data-gas
        (mapcat explode-row)
-       (map #(update % :value (fn [v] (double (/ (* 6.29 v) 1000)))))
+       (map #(update % :value (fn [v] (double (* 6.29e-3 v)))))
        (sort-by :year)
        (vec)))


Added optional generator.

Added optional generator.

--- src/cmr/common/test/test_check_ext.clj
+++ src/cmr/common/test/test_check_ext.clj
@@ -3,6 +3,11 @@
             [clojure.string :as s]
             [clj-time.coerce :as c])
   (:import java.util.Random))
+
+(defn optional
+  "Returns either nil or the given generator. This should be used for optional fields"
+  [generator]
+  (gen/one-of [(gen/return nil) generator]))

 (defn model-gen
   "Creates a generator for models. Takes the constructor function for the model and generators


Adding test docs

Adding test docs

--- test/yadic/core_test.clj
+++ test/yadic/core_test.clj
@@ -66,7 +66,7 @@
                                   [:a]))
   => (throws IllegalArgumentException))

-(fact "functions that aren't arity 1 will be rejected"
+(fact "functions that aren't arity 1 (with argument expected to be a container) will be rejected"
   (->activators :a (fn [a b])) => (throws IllegalArgumentException))

 (fact "There's a handy macro for creating functions activators"


Reformat day8.re-frame-10x.metamorphic ns

--- src/day8/re_frame_10x/metamorphic.cljc
+++ src/day8/re_frame_10x/metamorphic.cljc
@@ -249,10 +249,10 @@

               :else
-              state
-              ;; Add a timeout/warning if a match goes on for more than a second?
-
-              )
+              state)
+            ;; Add a timeout/warning if a match goes on for more than a second?
+
+
             (assoc :previous-event event))))
     parse-state
     traces))


Changed appd-db trash icon to an x and made the hit area for the checkbox the entire enclosing box

--- src/day8/re_frame_10x/view/app_db.cljs
+++ src/day8/re_frame_10x/view/app_db.cljs
@@ -6,10 +6,11 @@
             [day8.re-frame-10x.view.components :as components]
             [mranderson047.re-frame.v0v10v2.re-frame.core :as rf]
             [mranderson047.reagent.v0v7v0.reagent.core :as r]
-            [day8.re-frame-10x.utils.re-com :as rc :refer [css-join]]
+            [day8.re-frame-10x.utils.re-com :as rc :refer [close-button css-join]]
             [day8.re-frame-10x.common-styles :as common]
             [clojure.data])
-  (:require-macros [day8.re-frame-10x.utils.macros :as macros]))
+  (:require-macros [day8.re-frame-10x.utils.macros :as macros]
+                   [day8.re-frame-10x.utils.re-com :refer [handler-fn]]))

 (def delete (macros/slurp-macro "day8/re_frame_10x/images/delete.svg"))
 (def reload (macros/slurp-macro "day8/re_frame_10x/images/reload.svg"))
@@ -132,9 +133,12 @@
                              :on-click #(rf/dispatch [:snapshot/load-snapshot @app-db-after])]]]]]))

 (defn header-section
-  [& {:keys [style gap width min-width background-color children last?]}]
+  [& {:keys [size justify align gap width min-width background-color children style attr last?]
+      :or   {size "none" justify :center align :stretch}}]
   [rc/h-box
-   :align     :center
+   :size      size
+   :justify   justify
+   :align     align
    :gap       gap
    :width     width
    :min-width min-width
@@ -142,6 +146,7 @@
    :style     (merge {:border-right     (when-not last? pod-border-edge)
                       :background-color background-color}
                      style)
+   :attr      attr
    :children  children])

 (defn pod-header [{:keys [id path path-str open? diff?]}]
@@ -183,27 +188,27 @@
                            :placeholder "Showing all of app-db. Try entering a path like [:todos 1]"]]]
               [header-section
                :width "50px"
+               :attr     {:on-click (handler-fn (rf/dispatch [:app-db/set-diff-visibility id (not diff?)]))}
                :children [[rc/box
                            :style {:margin "auto"}
                            :child [rc/checkbox
                                    :model     diff?
                                    :label     ""
-                                   :style     {:margin-left "6px"}
-                                   :on-change #(when open? (rf/dispatch [:app-db/set-diff-visibility id (not diff?)]))]]]]
-
+                                   :style     {:margin-left "6px"
+                                               :margin-top  "1px"}
+                                   :on-change #(rf/dispatch [:app-db/set-diff-visibility id (not diff?)])]]]]
               [header-section
-               :width "50px"
-               :last? true
-               :children [[rc/box
-                           :class "bm-muted-button app-db-path--button noselect"
-                           :style {:margin "auto"}
-                           :attr  {:title    "Remove this pod"
-                                   :on-click #(do (reset! *finished-animation? false)
-                                                  (rf/dispatch [:app-db/remove-path id]))}
-                           :child [:img
-                                   {:src   (str "data:image/svg+xml;utf8," trash)
-                                    :style {:width  "13px"
-                                            :margin "0px 6px"}}]]]]]])
+               :width    "50px"
+               :justify  :center
+               :last?    true
+               :children [[close-button
+                           :div-size    31
+                           :font-size   31
+                           :left-offset 3
+                           :top-offset  -4
+                           :tooltip     "Remove this pod"
+                           :on-click    #(do (reset! *finished-animation? false)
+                                             (rf/dispatch [:app-db/remove-path id]))]]]]])

 (defn pod [{:keys [id path open? diff?] :as pod-info}]
   (let [render-diff?  (and open? diff?)


Upgrade Om to 0.8.0-beta3

Upgrade Om to 0.8.0-beta3

--- src/leiningen/new/chestnut/project.clj
+++ src/leiningen/new/chestnut/project.clj
@@ -14,7 +14,7 @@
                  [ring/ring-defaults "0.1.2"]
                  [compojure "1.3.1"]
                  [enlive "1.1.5"]
-                 [om "0.8.0-beta3"]
+                 [om "0.8.0-beta5"]
                  [environ "1.0.0"]{{{project-clj-deps}}}]

   :plugins [[lein-cljsbuild "1.0.3"]


Update to new enlive version

Update to new enlive version

Use latest version of enlive to fix windows issue
https://github.com/cgrand/enlive/issues/92
https://github.com/plexus/chestnut/issues/104

--- src/leiningen/new/chestnut/project.clj
+++ src/leiningen/new/chestnut/project.clj
@@ -13,7 +13,7 @@
                  [ring "1.3.2"]
                  [ring/ring-defaults "0.1.4"]
                  [compojure "1.3.2"]
-                 [enlive "1.1.5"]
+                 [enlive "1.1.6"]
                  [org.omcljs/om "0.8.8"]
                  [environ "1.0.0"]{{{project-clj-deps}}}]


Fix tests in web_unit and formatting

Fix tests in web_unit and formatting

--- src/leiningen/new/cljskel/web_unit.clj
+++ src/leiningen/new/cljskel/web_unit.clj
@@ -1,14 +1,14 @@
 (ns {{name}}.unit.web
-    (:require [{{name}}.web]
+    (:require [{{name}}.web :refer :all]
               [cheshire.core :as json]
-              [midje.sweet]))
+              [midje.sweet :refer :all]))

-(defn app [method resource]
-  (routes {:request-method method
-           :uri resource } ))
+(defn request [method resource]
+  (app {:request-method method
+        :uri resource}))

 (fact-group
  :unit

  (fact "Ping returns a pong"
-       (:body (request :get "/ping"))  => "pong" ))
+       (:body (request :get "/ping"))  => "pong"))


Clean up whitespace in project.clj

Clean up whitespace in project.clj

--- src/leiningen/new/devcards/project.clj
+++ src/leiningen/new/devcards/project.clj
@@ -10,10 +10,10 @@
   :profiles { :dev {:dependencies [[devcards "0.1.0-SNAPSHOT"]]
                     :plugins [[lein-cljsbuild "1.0.3"]
                               [lein-figwheel "0.1.3-SNAPSHOT"]] }}
-
+
   :source-paths ["src"]

-  :cljsbuild {
+  :cljsbuild {
               :builds [{:id "devcards"
                         :source-paths ["devcards_src" "src"]
                         :compiler {
@@ -21,7 +21,7 @@
                                    :output-dir "resources/public/devcards/js/compiled/out"
                                    :optimizations :none
                                    :source-map true}}
-
+
                        #_{:id "app"
                           :source-paths ["src"]
                           :compiler {
@@ -29,5 +29,5 @@
                                      :output-dir "resources/public/js/compiled/out"
                                      :optimizations :none
                                      :source-map true}}]}
-
+
   :figwheel { :css-dirs ["resources/public/css"] })


Tag throughput with peer-id

Tag throughput with peer-id

--- src/onyx/lifecycle/metrics/metrics.clj
+++ src/onyx/lifecycle/metrics/metrics.clj
@@ -30,10 +30,11 @@
         metrics (->Metrics rate batch-start rate+latency-10s retry-rate (atom {}) completion-rate+latencies-10s)
         name (str (:metrics/workflow-name lifecycle))
         task-name (str (:onyx.core/task event))
+        peer-id (:onyx.core/id event)
         core {:job-id (:onyx.core/job-id event)
               :task-id (:onyx.core/task-id event)
               :task-name (:onyx.core/task event)
-              :peer-id (:onyx.core/id event)}]
+              :peer-id peer-id}]

     {:onyx.metrics.metrics/metrics metrics
      :onyx.metrics.metrics/sender-thread ((kw->fn (:metrics/sender-fn lifecycle)) lifecycle ch)
@@ -48,7 +49,7 @@
                                                         (conj (take (dec historical-throughput-max-count)
                                                                     tps)
                                                               throughput)))]
-               (>!! ch (merge core {:service (format "[%s] 1s_throughput" task-name)
+               (>!! ch (merge core {:service (format "[%s] 1s_throughput [%s]" task-name peer-id)
                                     :window "1s"
                                     :metric :throughput
                                     :value (apply + (remove nil? (take 1 throughputs-val)))


Trivial cleanup

Trivial cleanup

--- src/refactor_nrepl/ns/dependencies.clj
+++ src/refactor_nrepl/ns/dependencies.clj
@@ -121,15 +121,12 @@

 (defn- get-class-name [{:keys [op class type val children] :as node}]
   (when-not children
-    (try (cond
-          (and (class-op? op)
-               (:type :class)) (.getName val)
-
-               (and class (not (= op :import)
-                               ))
-               (str (.getName class)))
-         (catch Exception e
-           (println e)))))
+    (try
+      (cond
+        (and (class-op? op) (:type :class)) (.getName val)
+        (and class (not= op :import)) (str (.getName class)))
+      (catch Exception e
+        (println e)))))

 (defn- get-var-name [node]
   (some-> node
@@ -142,6 +139,7 @@
       (get-var-name node)))

 (defn- used-vars
+  "Finds used functions and classes"
   [ast]
   (->> ast
        (map nodes)
@@ -156,7 +154,7 @@
 (defn- prune-refer
   [refer-clause prefix used-syms]
   (map #(-> (str/split % #"/") second symbol)
-       (filter (into #{} used-syms)
+       (filter (set used-syms)
                (map #(str prefix "/" %) refer-clause))))

 (defn- remove-unused
@@ -180,7 +178,7 @@

 (defn remove-unused-imports
   [symbols-in-use imports]
-  (filter (into #{} symbols-in-use) imports))
+  (filter (set symbols-in-use) imports))

 (defn- remove-unused-requires [symbols-in-use libspecs]
   (map (partial remove-unused-syms-and-specs symbols-in-use) libspecs))


decouple ack status assoc from sinking

decouple ack status assoc from sinking

--- src/riemann/plugin/acknowledgement.clj
+++ src/riemann/plugin/acknowledgement.clj
@@ -35,15 +35,13 @@
   (route/not-found      "
404
"))

-(defn assoc-ack-status
+(defn with-ack-status
   "Associate acknowledgement status to events"
   [{:keys [host service acked] :as event}]
-  (if (sequential? event)
-    (map assoc-ack-status event)
-    (let [acked? (or acked (@acks [host service]))]
-      (assoc event :acked acked?))))
+  (let [acked? (or acked (@acks [host service]))]
+    (assoc event :acked acked?)))

-(defn acked-alert-stream
+(defn alert-stream
   "Given a function that sends out alerts to interested parties,
    only call that function on events which are not acknowledged.

@@ -53,16 +51,9 @@
    The double arity version does the same and sends acked events to
    its second argument. This can be useful to index events."
   ([non-acked]
-     (smap assoc-ack-status
-           (let [handler-fn (where* (complement :acked) non-acked)]
-             #(if (sequential? %)
-                (doseq [event %] (handler-fn event))))))
+     (where* (complement :acked) non-acked))
   ([non-acked acked]
-     (smap assoc-ack-status
-           (let [handler-fn (where* (complement :acked) non-acked
-                                    (else acked))]
-             #(if (sequential? %)
-                (doseq [event %] (handler-fn event)))))))
+     (where* (complement :acked) non-acked (else acked))))

 (defrecord AcknowledgementServer [host port headers core server]
   ServiceEquiv


handle lists, as is often the case in rollups

--- src/riemann/plugin/acknowledgement.clj
+++ src/riemann/plugin/acknowledgement.clj
@@ -38,8 +38,10 @@
 (defn assoc-ack-status
   "Associate acknowledgement status to events"
   [{:keys [host service acked] :as event}]
-  (let [acked? (or acked (@acks [host service]))]
-    (assoc event :acked acked?)))
+  (if (sequential? event)
+    (map assoc-ack-status event)
+    (let [acked? (or acked (@acks [host service]))]
+      (assoc event :acked acked?))))

 (defn acked-alert-stream
   "Given a function that sends out alerts to interested parties,
@@ -51,10 +53,16 @@
    The double arity version does the same and sends acked events to
    its second argument. This can be useful to index events."
   ([non-acked]
-     (smap assoc-ack-status (where* (complement :acked) non-acked)))
+     (smap assoc-ack-status
+           (let [handler-fn (where* (complement :acked) non-acked)]
+             #(if (sequential? %)
+                (doseq [event %] (handler-fn event))))))
   ([non-acked acked]
      (smap assoc-ack-status
-           (where* (complement :acked) non-acked (else acked)))))
+           (let [handler-fn (where* (complement :acked) non-acked
+                                    (else acked))]
+             #(if (sequential? %)
+                (doseq [event %] (handler-fn event)))))))

 (defrecord AcknowledgementServer [host port headers core server]
   ServiceEquiv


Fixed an issue with uninstalling non-active extensions

Signed-off-by: Julien Eluard <c768e13f1ba4c3ebed2909a1fc1e4b50bb021a2f@gmail.com>

--- src/status_im/extensions/registry.cljs
+++ src/status_im/extensions/registry.cljs
@@ -29,10 +29,12 @@
               (update-hooks hooks/hook-in extension-key))))

 (fx/defn remove-from-registry
-  [{:keys [db] :as cofx} extension-key]
-  (fx/merge cofx
-            (update-hooks hooks/unhook extension-key)
-            {:db (update-in db [:account/account :extensions] dissoc extension-key)}))
+  [cofx extension-key]
+  (let [extensions (get-in cofx [:db :account/account :extensions])]
+    (fx/merge cofx
+              (when (get-in extensions [extension-key :active?])
+                (update-hooks hooks/unhook extension-key))
+              {:db (update-in cofx [:db :account/account :extensions] dissoc extension-key)})))

 (fx/defn change-state
   [cofx extension-key active?]


Message queue: add support for multi-threaded workers

--- src/taoensso/carmine/message_queue.clj
+++ src/taoensso/carmine/message_queue.clj
@@ -304,26 +304,29 @@
   (start [_]
     (when-not @running?
       (reset! running? true)
-      (future
-        (let [{:keys [handler monitor throttle-ms _]} opts
-              qk (partial qkey qname)]
-          (while @running?
-            (try
-              (let [[poll-reply ndruns mid-circle-size]
-                    (wcar conn (dequeue qname opts)
-                               (car/get  (qk :ndry-runs))
-                               (car/llen (qk :mid-circle)))]
-
-                (when monitor (monitor {:mid-circle-size mid-circle-size
-                                        :ndry-runs       (or ndruns 0)
-                                        :poll-reply      poll-reply}))
-
-                (if (= poll-reply "eoq-backoff")
-                  (Thread/sleep (max (wcar conn (car/pttl (qk :eoq-backoff?))) 10))
-                  (handle1 conn qname handler poll-reply)))
-
-              (catch Throwable t (timbre/fatalf t "Worker error!") (throw t)))
-            (when throttle-ms (Thread/sleep throttle-ms)))))
+      (let [{:keys [handler monitor nthreads throttle-ms _]} opts
+            qk (partial qkey qname)
+            start-polling-loop!
+            (fn []
+              (while @running?
+                (try
+                  (let [[poll-reply ndruns mid-circle-size]
+                        (wcar conn (dequeue qname opts)
+                                   (car/get  (qk :ndry-runs))
+                                   (car/llen (qk :mid-circle)))]
+
+                    (when monitor (monitor {:mid-circle-size mid-circle-size
+                                            :ndry-runs       (or ndruns 0)
+                                            :poll-reply      poll-reply}))
+
+                    (if (= poll-reply "eoq-backoff")
+                      (Thread/sleep (max (wcar conn (car/pttl (qk :eoq-backoff?)))
+                                         10))
+                      (handle1 conn qname handler poll-reply)))
+
+                  (catch Throwable t (timbre/fatalf t "Worker error!") (throw t)))
+                (when throttle-ms (Thread/sleep throttle-ms))))]
+        (dorun (repeatedly nthreads (fn [] (future (start-polling-loop!))))))
       true)))

 (defn monitor-fn
@@ -357,13 +360,15 @@
    :eoq-backoff-ms - Thread sleep period each time end of queue is reached.
                      Can be a (fn [ndry-runs]) -> ms (n<=5) will be used.
                      Sleep synchronized for all queue workers.
+   :nthreads       - Number of synchronized worker threads to use.
    :throttle-ms    - Thread sleep period between each poll."
-  [conn qname & [{:keys [handler monitor lock-ms eoq-backoff-ms throttle-ms
-                         auto-start?]
+  [conn qname & [{:keys [handler monitor lock-ms eoq-backoff-ms nthreads
+                         throttle-ms auto-start?]
                   :or   {handler (fn [args] (timbre/infof "%s" args)
                                            {:status :success})
                          monitor (monitor-fn qname 1000 (* 1000 60 60))
                          lock-ms        (* 1000 60 60)
+                         nthreads       1
                          throttle-ms    200
                          eoq-backoff-ms exp-backoff
                          auto-start?    true}}]]
@@ -372,6 +377,7 @@
                      :monitor        monitor
                      :lock-ms        lock-ms
                      :eoq-backoff-ms eoq-backoff-ms
+                     :nthreads       nthreads
                      :throttle-ms    throttle-ms})]
     (when auto-start? (start w)) w))


Message queue: fix backoff ttl

Message queue: fix backoff ttl

--- src/taoensso/carmine/message_queue.clj
+++ src/taoensso/carmine/message_queue.clj
@@ -197,7 +197,9 @@
               done  (fn [mid] (wcar conn (car/sadd (qk :recently-done) mid)))
               retry (fn [mid & [backoff-ms]]
                       (wcar conn
-                        (when backoff-ms (car/hset (qk :backoffs) mid backoff-ms))
+                       (when backoff-ms
+                         (car/hset (qk :backoffs) mid (+ (System/currentTimeMillis)
+                                                         backoff-ms)))
                         (car/hdel (qk :locks) mid)))
               error (fn [mid poll-reply & [throwable]]
                       (done mid)


Added Neo4j stuff to find records with certain properties

--- src/webapp/framework/client/neo4j.cljs
+++ src/webapp/framework/client/neo4j.cljs
@@ -96,23 +96,25 @@

 (defn count-all-neo4j-records-with-field [ field-name ]
   (go
-     (get (first (<!
-             (neo4j "START x = node(*) WHERE has(x.age) RETURN count(x)" {} )
-     )) "count(x)")
+     (get (first
+        (<!
+             (neo4j "START x = node(*) WHERE HAS(x.type) RETURN count(x)" {:type "age"} )
+        )
+     ) "count(x)")
   )
 )

-(go
-    (log (<! (count-all-neo4j-records-with-field 1)))
+(comment go
+    (log (<! (count-all-neo4j-records-with-field :age)))
 )

-(go
+(comment go
     (log (<! (count-all-neo4j-records)))
 )

-(log "hey" 2)
+(comment log "hey" 2)


Using https..

Using https..

--- src/mba/rest.cljs
+++ src/mba/rest.cljs
@@ -4,7 +4,7 @@
            [mba.config   :as config]))

 (def service-url
-  "http://milesbox.azurewebsites.net/api"
+  "https://milesbox.azurewebsites.net/api"
   #_(if config/dev?
      "http://milesbox.azurewebsites.net/api"
      "/api"))


indexing vertexes and edges

indexing vertexes and edges

--- src/ophion/db.clj
+++ src/ophion/db.clj
@@ -36,10 +36,10 @@
 (defn janus-make-index
   [graph index]
   (try
-    (let [index-name (string/join "-" (concat (keys index) ["-index"]))
+    (let [index-name (string/join "-" (concat (keys index) ["index"]))
           manage (.openManagement graph)]
-      (janus-apply-index manage (.buildIndex manage index-name Vertex) index)
-      (janus-apply-index manage (.buildIndex manage index-name Edge) index)
+      (janus-apply-index manage (.buildIndex manage (str index-name "-vertex") Vertex) index)
+      (janus-apply-index manage (.buildIndex manage index-name "-edge" Edge) index)
       (.commit manage))
     (catch Exception e
       (.printStackTrace e))))


giving credit where it's due

giving credit where it's due

--- src/runtime/q.clj
+++ src/runtime/q.clj
@@ -92,7 +92,7 @@
                        )
                      )
                 )
-        :else
+        :else ;thanks to gfredericks for this line:
         (cons 'do (for [oneForm allPassedForms] (list `assumedTrue1 oneForm)))
         )
       )


New line for method-implemented

New line for method-implemented

--- src/toucan/db.clj
+++ src/toucan/db.clj
@@ -392,7 +392,8 @@
                     (dissoc :id))
          updated? (update! model (-> (h/sset {} kvs)
                                      (where :id id)))]
-        (when (and updated? (method-implemented? :post-update model))
+        (when (and updated?
+                   (method-implemented? :post-update model))
           (models/post-update (model id)))
      updated?))


initial expression

initial expression

--- src/uawa/core.clj
+++ src/uawa/core.clj
@@ -1,12 +1,14 @@
 (ns uawa.core)

-(def істина true)
-(def фальш false)
-(defn дай-антонім "not" [x] (not x))
+(defmacro стала "defonce" [назва значення] `(let [v# (def ~назва)](when-not (.hasRoot v#) (def ~назва ~значення))))
 (defmacro вираз "same as defn" [назви & описи] (list* `defn (with-meta назви (assoc (meta назви) :private false)) описи))
-(defmacro стала "defonce" [назва значення] `(let [v# (def ~назва)](when-not (.hasRoot v#) (def ~назва ~значення))))
-(def дай-випадкове "rand" ([] (rand) ([n] (rand n))
-
-(defmacro вираз "same as defn" [назви & описи] (list* `defn (with-meta назви (assoc (meta назви) :private false)) описи))
-(defmacro стала "defonce" [назва значення] `(let [v# (def ~назва)](when-not (.hasRoot v#) (def ~назва ~значення))))
-(def дай-випадкове "rand" ([] (rand) ([n] (rand n))))+(defmacro якщо ([умова то] `(if ~умова ~то nil)) ([умова то інакше] `(if ~умова ~то ~інакше)))
+(стала істина true)
+(стала фальш false)
+(вираз ні? "not" [x] (not x))
+(вираз кожен? "and" ([x y] (and x y)) ([x y & more] (reduce кожен? (кожен? x y) more)))
+(вираз якийсь? "or" ([x y] (or x y)) ([x y & more] (reduce якийсь? (якийсь? x y) more)))
+(вираз дай-випадкове "rand-int" [n] (rand-int n))
+(вираз друкуй "println" [& більше]  (binding [*print-readably* nil] (apply prn більше)))
+(вираз менше?  ([x] true) ([x y] (. clojure.lang.Numbers (lt x y))) ([x y & more]   (if (< x y)     (if (next more)       (recur y (first more) (next more))       (< y (first more))) false)))
+;; (якщо (менше? (дай-випадкове 3) 4) (друкуй "українська") (друкуй "ураиский русский))


next'

next'

--- src/uawa/core.clj
+++ src/uawa/core.clj
@@ -56,6 +56,9 @@
 (функція вибери-ключі "див. select-keys" [колекція ключі] (select-keys колекція ключі))
 (функція сортуй-за "див. sort-by" ([функція-рядків колекція] (sort-by функція-рядків колекція))  ([функція-рядків компаратор колекція] (sort-by функція-рядків компаратор колекція)))
 (функція відфільтруй-повтори "див distinct" [колекція] (distinct колекція))
+(функція візьми "див. take" ([n] (take n)) ([n col] (take n col)))
+(функція вибери-значення "див. vals" ([m] (vals m))
+(функція геш-таблиця "див. hash-map" ([] {}) ([& keyvals] (hash-map keyvals)))

 ;; системні

@@ -70,8 +73,12 @@
 ;; (функція застосуй "див. apply" [f a b c d &args] (apply f a b c d &args))
 (функція потребуй "див. require" [& args] (застосуй require args))
 (defmacro спробуй ([вираз винятоковий-вираз] `(try ~вираз ~винятоковий-вираз )) ([вираз винятоковий-вираз остаточний-вираз] `(try ~вираз ~винятоковий-вираз ~остаточний-вираз )) )
+(defmacro злови [Trhrowable e вираз] `(catch Trhrowable e вираз))
 (функція встав "див. interpose" ([sep] (interpose sep)) ([sep col] (interpose sep col)))
 (функція інтернуй "див intern"  ([ns name] (intern ns name)) ([ns name val] (intern ns name val)))
+
+;; io
+(defmacro сьорбни "див. slurp" [джерело & решта] `(slurp ~джерело ~@решта))
 ;; різні

 (функція дай-випадкове "див. rand-int" [максимальне] (rand-int максимальне))
@@ -89,4 +96,5 @@
 (постійна грн ₴)
 (defmacro ціна "ціна у валюті" [назва кількість валюта] `(постійна ~назва (Ціна. ~кількість  ~валюта)))
 (метод print-method Ціна [x ^java.io.Writer w] (.write w (str (:кількість x) " " (:валюта x))))
-(функція домнож  [x ^clojure.lang.Numbers y] (Ціна. (* (:кількість x) y) (:валюта x)))
+(функція домнож  [x ^clojure.lang.Numbers y] (Ціна. (* (:кількість x) y) (:валюта x)))\
+


Escape error output

Escape error output

--- src/yada/body.clj
+++ src/yada/body.clj
@@ -8,7 +8,7 @@
    [clojure.walk :refer [keywordize-keys]]
    [byte-streams :as bs]
    [cheshire.core :as json]
-   [hiccup.core :refer [html]]
+   [hiccup.core :refer [html h]]
    [hiccup.page :refer [html5]]
    [json-html.core :as jh]
    [manifold.stream :refer [->source transform]]
@@ -224,7 +224,7 @@
        [:p (.getMessage error)]
        (when *output-stack-traces*
          [:pre
-          (with-out-str (pprint error))])])
+          (h (with-out-str (pprint error)))])])

     (when-let [path (:journal-browser-path options)]
       [:div


Make interceptor-chain part of resource model

--- src/yada/core.clj
+++ src/yada/core.clj
@@ -410,6 +410,7 @@
   "Handle Ring request"
   [http-resource request]
   (let [method (:request-method request)
+        interceptors (:interceptors http-resource)
         options (:options http-resource)
         ;; TODO: Document this debug feature
         debug (boolean (get-in request [:headers "x-yada-debug"]))
@@ -417,33 +418,12 @@
              (make-context)
              {:method method
               :method-instance (get (:known-methods http-resource) method)
+              :interceptors interceptors
               :http-resource http-resource
               :resource (:resource http-resource)
               :request request
               :allowed-methods (:allowed-methods http-resource)
-              :options options})
-        interceptors
-        [
-         available?
-         known-method?
-         uri-too-long?
-         TRACE
-         method-allowed?
-         malformed?
-         authentication
-         authorization
-         fetch
-         ;; TODO: Unknown or unsupported Content-* header
-         ;; TODO: Request entity too large - shouldn't we do this later,
-         ;; when we determine we actually need to read the request body?
-         select-representation
-         exists?
-         check-modification-time
-         if-match
-         invoke-method
-         compute-etag
-         create-response]
-        ]
+              :options options})]

     (->
      (apply d/chain ctx interceptors)
@@ -516,12 +496,35 @@
                             (when (satisfies? p/Representations resource)
                               (p/representations resource)))))

-         vary (rep/vary representations)]
+         vary (rep/vary representations)
+
+         interceptors
+         [
+          available?
+          known-method?
+          uri-too-long?
+          TRACE
+          method-allowed?
+          malformed?
+          authentication
+          authorization
+          fetch
+          ;; TODO: Unknown or unsupported Content-* header
+          ;; TODO: Request entity too large - shouldn't we do this later,
+          ;; when we determine we actually need to read the request body?
+          select-representation
+          exists?
+          check-modification-time
+          if-match
+          invoke-method
+          compute-etag
+          create-response]]

      (map->HttpResource
       {:id (or (:id options) (java.util.UUID/randomUUID))
        :resource resource
        :base base
+       :interceptors interceptors
        :options options
        :allowed-methods allowed-methods
        :known-methods known-methods


Change a description

Change a description

--- src/whisper2cyanite/cli.clj
+++ src/whisper2cyanite/cli.clj
@@ -84,7 +84,7 @@
 (defn- usage
   "Construct usage message."
   [options-summary]
-  (->> ["Whisper to Cyanite data migration tool"
+  (->> ["A Whisper to Cyanite data migration tool"
         ""
         "Usage: "
         "  whisper2cyanite [options] migrate <directory | whisper_file | filelist_file> <tenant> <cassandra_host,...> <elasticsearch_url>"


CMR-5311: Update json-schema-validator.

CMR-5311: Update json-schema-validator.

* Updated json-schema-validator. This however results in the same vulnerabilities being found.

--- common-lib/project.clj
+++ common-lib/project.clj
@@ -21,7 +21,7 @@
     [clojusc/ltest "0.3.0"]
     [com.dadrox/quiet-slf4j "0.1"]
     [com.gfredericks/test.chuck "0.2.9"]
-    [com.github.fge/json-schema-validator "2.2.6"]
+    [com.github.java-json-tools/json-schema-validator "2.2.10"]
     [com.taoensso/timbre "4.10.0"]
     [commons-codec/commons-codec "1.11"]
     [compojure "1.6.1"]


Finally write a bio

Finally write a bio

--- frontend/components/about.cljs
+++ frontend/components/about.cljs
@@ -115,7 +115,9 @@
     :role "Developer"
     :github "iand675"
     :twitter "iand675"
-    :email "ian@circleci.com"}
+    :email "ian@circleci.com"
+    :bio ["Ian joins the CircleCI team remotely from South Carolina. When he’s not busy coding away on CircleCI, he’s probably off hacking on his Haskell side projects or studying distributed systems with a quality microbrew in hand. He started learning Haskell in high school for some research projects, and has been hooked on functional programming ever since. Ian's always had more ideas for things to build than time on his hands, but managed to win runner up in a few entrepreneurship competitions in college for his work.",
+          "He’s particularly fond of travel, and has done two cross-country moves in 2 years. He loves getting to know foreign cultures, and has learned to speak some Japanese and French along the way. During the summer months, he spends his time bicycling, hiking, and running, and once the weather turns cold he hones his gaming skills on Dance Dance Revolution and Super Smash Bros, sits back and binge-watches television shows (currently: Castle and Brooklyn Nine-Nine), and chows down on pumpkin pie."]}
    {:name "Kevin Bell"
     :visible true
     :role "Developer Evangelist"


fix to doc string for to-dbo/clj

fix to doc string for to-dbo/clj

--- src/karras.clj
+++ src/karras.clj
@@ -35,7 +35,7 @@
   (boolean (some #{k} options)))

 (defn to-dbo
-  "Converts a com.mongodb.DBObject to a clojure map"
+  "Converts a clojure map to acom.mongodb.DBObject"
   [m]
   (let [to-v #(if (map? %) (to-dbo %) %)
         dbo  (BasicDBObject.)]
@@ -44,7 +44,7 @@
     dbo))

 (defn to-clj
-  "Converts a clojure map to acom.mongodb.DBObject"
+  "Converts a com.mongodb.DBObject to a clojure map"
   [dbo]
   (apply merge (map (fn [#^java.util.Map$Entry e]
                        (let [k (.getKey e)


Remove the "Repeated analysis" FIXME

Remove the "Repeated analysis" FIXME

I'm punting to t.e.jvm for its eval anyway, so I'll just ignore this
defect. If it turns out to be a real performance issue at some later
point I'll revisit it.

--- src/oxcart.clj
+++ src/oxcart.clj
@@ -90,15 +90,9 @@

            (eval ret options))

-         ;; bare expression handling
-         ;;-----------------------------
-         ;; FIXME: Repeated analysis
-         ;;   Is there some way that I can merge this so that only one
-         ;;   ana.jvm/analyze invocation is required? I think the
-         ;;   answer is no, but it'd be nice.
-
-         (do ;; Save the AST using (.name *ns*) to determine the module
-             (let [ast (-> mform
+         ;; Bare expression handling
+         ;; ----------------------------
+         (do (let [ast (-> mform
                            (util/ast)
                            (assoc :raw-form form
                                   :raw-op   (when (list? form) (first form))))]


implementing select-lazy

implementing select-lazy

--- src/clj/eventsourcing/db.clj
+++ src/clj/eventsourcing/db.clj
@@ -3,7 +3,8 @@
             [korma.core :refer :all]
             [heroku-database-url-to-jdbc.core :as h]
             [environ.core :as env]
-            [clojure.core.logic :refer :all]))
+            [clojure.core.logic :refer :all]
+            [clojure.core.logic.pldb :refer :all]))

 (defn open []
   (let [url (env/env :database-url)
@@ -11,3 +12,9 @@
         db (db/create-db (db/postgres kmap))]
     (db/default-connection db)
     db))
+
+(defn select-lazy
+  ([q l o] (when-let [res (seq (select (-> (q) (limit l) (offset o))))]
+             (println "did another select from" o "to" (+ o l))
+             (cons res (lazy-seq (select-lazy q l (+ o l))))))
+  ([q] (select-lazy q 1 0)))


Swap coordinates.

Swap coordinates.

--- src/clj/triangulate/core.clj
+++ src/clj/triangulate/core.clj
@@ -87,7 +87,7 @@

 (def front-coordinate (nth coordinates front-segment))

-(def vehicle-bearing (bearing back-coordinate front-coordinate))
+(def vehicle-bearing (bearing front-coordinate back-coordinate))

 (def distance-to-front-segment (- back-distance meters-away))


Add try-let macro.

Add try-let macro.

Refactor some of the execute-handler to be simpler.

--- src/ipython_clojure/core.clj
+++ src/ipython_clojure/core.clj
@@ -10,6 +10,37 @@
   (:gen-class :main true))

 (def protocol-version "5.0")
+
+(defmacro try-let
+  "A combination of try and let such that exceptions thrown in the binding or
+   body can be handled by catch clauses in the body, and all bindings are
+   available to the catch and finally clauses. If an exception is thrown while
+   evaluating a binding value, it and all subsequent binding values will be nil.
+   Example:
+   (try-let [x (f a)
+             y (f b)]
+     (g x y)
+     (catch Exception e (println a b x y e)))"
+  {:arglists '([[bindings*] exprs* catch-clauses* finally-clause?])}
+  [bindings & exprs]
+  (when-not (even? (count bindings))
+    (throw (IllegalArgumentException. "try-let requires an even number of forms in binding vector")))
+  (let [names  (take-nth 2 bindings)
+        values (take-nth 2 (next bindings))
+        ex     (gensym "ex__")]
+    `(let [~ex nil
+           ~@(interleave names (repeat nil))
+           ~@(interleave
+               (map vector names (repeat ex))
+               (for [v values]
+                 `(if ~ex
+                    [nil ~ex]
+                    (try [~v nil]
+                      (catch Throwable ~ex [nil ~ex])))))]
+      (try
+        (when ~ex (throw ~ex))
+        ~@exprs))))
+

 (defn prep-config [args]
   (-> args first slurp json/read-str walk/keywordize-keys))
@@ -188,22 +219,30 @@
    :parent-header (cheshire/parse-string (:parent-header message) keyword)
    :content (cheshire/parse-string (:content message) keyword)})

+(defn get-busy-handler [iopub-socket]
+  "handles setting the engine to busy when executing a request"
+  (fn [message signer execution-count]
+    (let [session-id (get-in message [:header :session])
+          parent-header (:header message)]
+      (send-message iopub-socket "status" (status-content "busy")
+                    parent-header {} session-id signer)
+      (send-message iopub-socket "execute-content"
+                    (pyin-content @execution-count message)
+                    parent-header {} session-id signer))))
+
 (defn execute-request-handler [shell-socket iopub-socket executer]
-  (let [execution-count (atom 0N)]
+  (let [execution-count (atom 0N)
+        busy-handler (get-busy-handler iopub-socket)]
     (fn [message signer]
       (let [session-id (get-in message [:header :session])
             parent-header (:header message)]
         (swap! execution-count inc)
-        (send-message iopub-socket "status" (status-content "busy")
-                      parent-header {} session-id signer)
-        (send-message iopub-socket "execute-content"
-                      (pyin-content @execution-count message)
-                      parent-header {} session-id signer)
+        (busy-handler message signer execution-count)
         (try
           (let [s# (new java.io.StringWriter) [output results]
-              (binding [*out* s#]
-                (let [result (pr-str (eval (read-string
-                                            (get-in message [:content :code]))))
+                (binding [*out* s#]
+                  (let [result (pr-str (eval (read-string
+                                              (get-in message [:content :code]))))
                       output (str s#)]
                   [output, result]))]
             (send-router-message shell-socket "execute_reply"


username and password are configurable

username and password are configurable

--- src/jepsen/voltdb/runner.clj
+++ src/jepsen/voltdb/runner.clj
@@ -62,6 +62,14 @@
    [nil "--skip-os" "Don't perform OS setup"]

    [nil "--force-download" "Always download HTTP/S tarballs"]
+
+   [nil "--username USER" "Username for logins"
+    :default "root"
+    :assoc-fn (fn [m k v] (assoc-in m [:ssh k] v))]
+
+   [nil "--password PASS" "Password for sudo access"
+    :default "root"
+    :assoc-fn (fn [m k v] (assoc-in m [:ssh k] v))]

    ["-p" "--procedure-call-timeout MILLISECONDS"
     "How long should we wait before timing out procedure calls?"


aoc2020 day17

aoc2020 day17

--- 2020/src/day17.clj
+++ 2020/src/day17.clj
@@ -2,34 +2,39 @@
   (:refer-clojure :exclude [cycle])
   (:require [clojure.pprint :refer [pprint]]))

-(def test-input-raw [".#."
-                     "..#"
-                     "###"])
-(def test-input
-  (->> test-input-raw
+(def test-input [".#."
+                 "..#"
+                 "###"])
+
+(def input ["..#....#"
+            "##.#..##"
+            ".###...."
+            "#....#.#"
+            "#.######"
+            "##.#...."
+            "#......."
+            ".#......"])
+
+(defn to-db [input]
+  (->> input
        (map-indexed (fn [y line]
                       (->> line
-                           (map-indexed (fn [x active] [[x y 0] (= active \#)]))
-                           #_(mapcat (fn [[[x y] active]]
-                                     [[[x y -1] active]
-                                      [[x y  0] active]
-                                      [[x y  1] active]]))
+                           (map-indexed (fn [x active] [[x y 0 0] (= active \#)]))
                            (into []))))
        (mapcat identity)
        (into {})))

-; (pprint test-input)
+(defn neigbours [db [x y z w] part2?]
+  (for [x' [(dec x) x (inc x)]
+        y' [(dec y) y (inc y)]
+        z' [(dec z) z (inc z)]
+        w' (if part2? [(dec w) w (inc w)] [w])
+        :when (not= [x y z w] [x' y' z' w'])
+        :let [active' (get db [x' y' z' w'])]]
+    [[x' y' z' w'] active']))

-(defn neigbours [db [x y z]]
-  (for [x' (range (dec x) (+ 2 x))
-        y' (range (dec y) (+ 2 y))
-        z' (range (dec z) (+ 2 z))
-        :when (not= [x y z] [x' y' z'])
-        :let [active' (get db [x' y' z'])]]
-    [[x' y' z'] active']))
-
-(defn next-cube [db [point active]]
-  (let [c (->> (neigbours db point)
+(defn next-cube [db [point active] part2?]
+  (let [c (->> (neigbours db point part2?)
                (filter second)
                count)
         active' (if active
@@ -38,21 +43,31 @@
     [point active']))

-(defn cycle [db]
+(defn cycle [db part2?]
   (let [[x1 x2] (apply (juxt min max) (map #(nth % 0) (keys db)))
         [y1 y2] (apply (juxt min max) (map #(nth % 1) (keys db)))
-        [z1 z2] (apply (juxt min max) (map #(nth % 2) (keys db))) ]
+        [z1 z2] (apply (juxt min max) (map #(nth % 2) (keys db)))
+        [w1 w2] (apply (juxt min max) (map #(nth % 3) (keys db))) ]
     (->> (for [x (range (dec x1) (+ 2 x2))
                y (range (dec y1) (+ 2 y2))
-               z (range (dec z1) (+ 2 z2))]
-           (next-cube db [[x y z] (get db [x y z])]))
+               z (range (dec z1) (+ 2 z2))
+               w (range (dec w1) (+ 2 w2)) ]
+           (next-cube db [[x y z w] (get db [x y z w])] part2?))
          (into {}))))

-(pprint (->> test-input
-            (iterate cycle)
-            (drop 6)
-            first
-            ;;  cycle
-             (filter second)
-             count
-             ))
+(defn boot-cycle [input part2?]
+  (->> input
+       to-db
+       (iterate #(cycle % part2?))
+       (drop 6)
+       first
+       (filter second)
+       count))
+
+;; part 1
+(pprint (boot-cycle test-input false))
+(pprint (boot-cycle input false))
+
+;; part 2
+(pprint (boot-cycle test-input true))
+(pprint (boot-cycle input true))


Reformat fleet-state as a table.

Reformat fleet-state as a table.

--- src-cljs/frontend/components/admin.cljs
+++ src-cljs/frontend/components/admin.cljs
@@ -36,12 +36,28 @@
       (let [fleet-state (get-in app state/fleet-state-path)]
         (html
          [:section {:style {:padding-left "10px"}}
-          [:a {:href "/api/v1/admin/build-state-summary" :target "_blank"} "View raw"]
-          " / "
-          [:a {:on-click #(raise! owner [:refresh-admin-fleet-state-clicked])} "Refresh"]
+          [:header
+           [:a {:href "/api/v1/admin/build-state-summary" :target "_blank"} "View raw"]
+           " / "
+           [:a {:on-click #(raise! owner [:refresh-admin-fleet-state-clicked])} "Refresh"]]
           (if-not fleet-state
             [:div.loading-spinner common/spinner]
-            [:code (om/build ankha/inspector fleet-state)])])))))
+            [:table
+             [:thead
+              [:tr
+               [:th "Instance ID"]
+               [:th "Instance Type"]
+               [:th "Boot Time"]
+               [:th "Busy Containers"]
+               [:th "State"]]]
+             [:tbody
+              (for [instance fleet-state]
+                [:tr
+                 [:td (:instance_id instance)]
+                 [:td (:ec2_instance_type instance)]
+                 [:td (:boot_time instance)]
+                 [:td (:busy instance) " / " (:total instance)]
+                 [:td (:state instance)]])]])])))))

 (defn admin [app owner]
   (reify


Lessons Learnt.

Lessons Learnt.

--- src-cljs/kixi/hecuba/tabs/profiles.cljs
+++ src-cljs/kixi/hecuba/tabs/profiles.cljs
@@ -255,6 +255,29 @@
                (text-control profile_data state owner :moisture_condensation_mould_strategy "Moisture Condensation Mould Strategy")
                (text-control profile_data state owner :appliances_strategy "Appliances Strategy")
                (text-control profile_data state owner :cellar_basement_issues "Cellar Basement Issues")])]))]))))
+
+(defn lessons-learnt-row [profiles owner]
+  (reify
+    om/IRenderState
+    (render-state [_ state]
+      (html
+       [:div.col-md-12
+        (for [profile profiles]
+          (let [profile_data (:profile_data profile)]
+            [:div {:class (profile-column-width)}
+             (bs/panel
+              "Lesson Learnt"
+              [:div
+               (text-control profile_data state owner :thermal_bridging_strategy "Thermal Bridging Strategy")
+               (text-control profile_data state owner :airtightness_and_ventilation_strategy "Airtightness And Ventilation Strategy")
+               ;; moisture/mould/condensation?
+               ;; passive solar?
+               (text-control profile_data state owner :overheating_cooling_strategy "Overheating Cooling Strategy")
+               (text-control profile_data state owner :controls_strategy "Controls Strategy")
+               ;; appliances
+               (text-control profile_data state owner :lighting_strategy "Lighting Strategy")
+               (text-control profile_data state owner :water_saving_strategy "Water Saving Strategy")
+               (text-control profile_data state owner :innovation_approaches "Innovation Approaches")])]))]))))

 (defn sap-results-row [profiles owner]
   (reify
@@ -295,6 +318,7 @@
          (om/build glazing-row profiles)
          (om/build issues-row profiles)
          (om/build sap-results-row profiles)
+         (om/build lessons-learnt-row profiles)
          ;; (om/build documents profiles)
          ;; (om/build co-heating profiles)
          ;; (om/build air-tightness profiles)
@@ -344,7 +368,7 @@
   (text-control profile_data state owner :air_tightness_equipment "Air Tightness Equipment")
   (text-control profile_data state owner :air_tightness_performed_on "Air Tightness Performed On")
   (text-control profile_data state owner :air_tightness_rate "Air Tightness Rate")
-  (text-control profile_data state owner :airtightness_and_ventilation_strategy "Airtightness And Ventilation Strategy")
+
   (text-control profile_data state owner :annual_heating_load "Annual Heating Load")
   (text-control profile_data state owner :best_u_value_for_doors "Best U Value For Doors")
   (text-control profile_data state owner :best_u_value_for_floors "Best U Value For Floors")
@@ -360,7 +384,7 @@
   (text-control profile_data state owner :completeness "Completeness")
   (text-control profile_data state owner :conservation_issues "Conservation Issues")
   (text-control profile_data state owner :construction_time_new_build "Construction Time New Build")
-  (text-control profile_data state owner :controls_strategy "Controls Strategy")
+
   (text-control profile_data state owner :design_guidance "Design Guidance")
   (text-control profile_data state owner :dwelling_u_value_other "Dwelling U Value Other")
   (text-control profile_data state owner :estimated_cost_new_build "Estimated Cost New Build")
@@ -368,18 +392,18 @@
   (text-control profile_data state owner :final_cost_new_build "Final Cost New Build")
   (text-control profile_data state owner :heat_loss_parameter_hlp "Heat Loss Parameter Hlp")
   (text-control profile_data state owner :id "ID")
-  (text-control profile_data state owner :innovation_approaches "Innovation Approaches")
+
   (text-control profile_data state owner :intention_ofpassvhaus "Intention Ofpassvhaus")
   (text-control profile_data state owner :intervention_completion_date "Intervention Completion Date")
   (text-control profile_data state owner :intervention_description "Intervention Description")
   (text-control profile_data state owner :intervention_start_date "Intervention Start Date")
-  (text-control profile_data state owner :lighting_strategy "Lighting Strategy")
+
   (text-control profile_data state owner :modelling_software_methods_used "Modelling Software Methods Used")
   (text-control profile_data state owner :onsite_days "Onsite Days")
   (text-control profile_data state owner :onsite_days_new_build "Onsite Days New Build")
   (text-control profile_data state owner :orientation "Orientation")
-  (text-control profile_data state owner :overheating_cooling_strategy "Overheating Cooling Strategy")
-  (text-control profile_data state owner :passive_solar_strategy "Passive Solar Strategy")
+
+
   (text-control profile_data state owner :planning_considerations "Planning Considerations")
   (text-control profile_data state owner :profile_air_in_summer "Profile Air In Summer")
   (text-control profile_data state owner :profile_air_in_winter "Profile Air In Winter")
@@ -398,13 +422,13 @@
   (text-control profile_data state owner :property_id "Property Id")
   (text-control profile_data state owner :roof_rooms_present "Roof Rooms Present")
   (text-control profile_data state owner :space_heating_requirement "Space Heating Requirement")
-  (text-control profile_data state owner :thermal_bridging_strategy "Thermal Bridging Strategy")
+
   (text-control profile_data state owner :total_area "Total Area")
   (text-control profile_data state owner :total_budget "Total Budget")
   (text-control profile_data state owner :total_budget_new_build "Total Budget New Build")
   (text-control profile_data state owner :total_envelope_area "Total Envelope Area")
-  (text-control profile_data state owner :used_passivehaus_principles "Used Passivehaus Principles")
+
   (text-control profile_data state owner :ventilation_approach "Ventilation Approach")
   (text-control profile_data state owner :ventilation_approach_other "Ventilation Approach Other")
-  (text-control profile_data state owner :water_saving_strategy "Water Saving Strategy")
+
   )


Ignore empty lines.

Ignore empty lines.

--- src/mash_commander/core.cljs
+++ src/mash_commander/core.cljs
@@ -37,9 +37,11 @@

 (defmethod dispatch-enter :default
   [cursor]
-  (as-> cursor c
-    (assoc c :history (cons (:active c) (:history c)))
-    (assoc c :active {:state [:empty] :letters []})))
+  (condp = (first (get-in cursor [:active :state]))
+    :empty cursor ; ignore empty lines
+    (as-> cursor c
+      (assoc c :history (cons (:active c) (:history c)))
+      (assoc c :active {:state [:empty] :letters []}))))

 (defmethod dispatch-enter "clear"
   [cursor]


Exclude user's own post from Home feed.

Exclude user's own post from Home feed.

--- src/oc/storage/db/common.clj
+++ src/oc/storage/db/common.clj
@@ -48,8 +48,8 @@
                            (not (map? follow-data))
                            ;; filter on followed authors and on not unfollowed boards
                            (r/and (:following follow-data)
+                                  (r/ne (:user-id follow-data) (r/get-field post-row [:publisher :user-id]))
                                   (r/or (r/contains (vec (:follow-publisher-uuids follow-data)) (r/get-field post-row [:publisher :user-id]))
-                                        (r/eq (:user-id follow-data) (r/get-field post-row [:publisher :user-id]))
                                         (r/not (r/contains (vec (:unfollow-board-uuids follow-data)) (r/get-field post-row :board-uuid)))))
                            ;; filter on not followed authors and on unfollowed boards
                            (r/and (:unfollowing follow-data)
@@ -149,8 +149,8 @@
                                   (r/ne (:user-id follow-data) (r/get-field post-row [:publisher :user-id]))
                                   (r/contains (vec (:unfollow-board-uuids follow-data)) (r/get-field post-row :board-uuid)))
                            (r/and (:following follow-data)
+                                  (r/ne (:user-id follow-data) (r/get-field post-row [:publisher :user-id]))
                                   (r/or (r/contains (vec (:follow-publisher-uuids follow-data)) (r/get-field post-row [:publisher :user-id]))
-                                        (r/eq (:user-id follow-data) (r/get-field post-row [:publisher :user-id]))
                                         (r/not (r/contains (vec (:unfollow-board-uuids follow-data)) (r/get-field post-row :board-uuid)))))))))
             ;; Merge in a last-activity-at date for each post (last comment created-at, fallback to published-at)
             (r/merge query (r/fn [post-row]


Make control panel with multiple widgets scrollable.

--- src/overtone/gui/control.clj
+++ src/overtone/gui/control.clj
@@ -105,9 +105,9 @@
     (let [panels  (map synth-controller-panel synths)
           cleanup (apply juxt (map :cleanup panels))
           frame (frame :title "Synth Controllers"
-                       :content (vertical-panel
+                       :content (scrollable (vertical-panel
                                   :border 5
-                                  :items (map :panel panels))
+                                  :items (map :panel panels)))
                        :on-close :dispose)]
       ; When the window is closed, unhook everything from the synth
       ; so the ui can be garbage collected, etc.


add further pitch helper methods for determining the frequencies of given diotonic modes (currently only with equal-tempered tuning)

--- src/overtone/music/pitch.clj
+++ src/overtone/music/pitch.clj
@@ -119,6 +119,14 @@
      :aeolian    (rotate-ionian 5)
      :minor      (rotate-ionian 5)
      :lochrian   (rotate-ionian 6)}))
+
+(defn nth-diotonic
+  "Return the count of semitones for the nth interval from the start of the diatonic scale in the specifiec mode (or ionian/major by default).
+     i.e. the ionian/major scale has an interval sequence of 2 2 1 2 2 2 1
+          therefore the 4th interval is (+ 2 2 1 2) semitones from the start of the scale."
+  ([n] (nth-diotonic n :ionian))
+  ([n mode]
+     (reduce + (take n (cycle (mode DIOTONIC-MODES))))))

 ;; Various scale intervals in terms of steps on a piano, or midi note numbers
 ;; All sequences should add up to 12 - the number of semitones in an octave
@@ -240,6 +248,19 @@
   [freq n]
   (* freq (math/expt 2 n)))

+(defn nth-equal-tempered-freq
+  "Returns the frequency of a given scale interval using an equal-tempered tuning i.e. dividing all 12 semi-tones equally across an octave. This is currently the standard tuning."
+  [base-freq interval]
+  (* base-freq (math/expt 2 (/ interval 12))))
+
+(defn diotonic-freq
+  "Returns the frequence of the given interval using the specified mode and tuning (defaulting to ionian and equal-tempered respectively)."
+  ([base-freq n] (diotonic-freq base-freq n :ionian :equal-tempered))
+  ([base-freq n mode tuning]
+     (case tuning
+           :equal-tempered (nth-equal-tempered-freq base-freq (nth-diotonic n mode)))))
+
+
 ;; TODO:
 ;; * weighted random
 ;; * arpeggiator(s)


[BUGFIX] localStorage/get-item - dont always return nil

Misplacement of the closing parentheses for the `if` expression causes
`nil` to be returned all the time

Signed-off-by: Pang Yan Han <22594c345857f664c61cd411f607c4d40a9d4af9@gmail.com>

--- src/cljs/cljs_nusmods/localStorage.cljs
+++ src/cljs/cljs_nusmods/localStorage.cljs
@@ -10,8 +10,8 @@
    not support localStorage"
   [k]
   (if LOCALSTORAGE
-      (.getItem LOCALSTORAGE k))
-      nil)
+      (.getItem LOCALSTORAGE k)
+      nil))

 (defn set-item
   "Sets a key value pair in the localStorage"


add sprite alpha option

add sprite alpha option

--- src/cljs/infinitelives/pixi/sprite.cljs
+++ src/cljs/infinitelives/pixi/sprite.cljs
@@ -10,12 +10,19 @@

 (defn make-sprite
   "construct a sprite by its texture. optionally pass in other things"
-  [texture & {:keys [x y xhandle yhandle]
-              :or {x 0 y 0 xhandle 0.5 yhandle 0.5}}]
+  [texture & {:keys [x y xhandle yhandle scale alpha]
+              :or {x 0 y 0
+                   xhandle 0.5 yhandle 0.5
+                   scale [1 1]
+                   alpha 1}}]
   (let [s (PIXI/Sprite. texture)]
     (set! (.-anchor s) (make-point xhandle yhandle))
     (set! (.-x s) x)
     (set! (.-y s) y)
+    (when-not (= scale [1 1])
+      (set! (.-scale s) (make-point (get scale 0) (get scale 1))))
+    (when-not (= 1 alpha)
+      (set! (.-alpha s) alpha))
     s))

 (defn set-pos!


redo let inner trace

redo let inner trace

--- src/com/billpiel/sayid/inner_trace3.clj
+++ src/com/billpiel/sayid/inner_trace3.clj
@@ -365,6 +365,63 @@
                 [a (take (inc a) lazy-recur)]))
      nil ~'$$return))

+(defn tr-let-ret
+  [template tree-atom v]
+  (-> (produce-recent-tree-atom! (:inner-path template)
+                                 (:path-parents template)
+                                 tree-atom)
+      deref
+      (merge template)
+      (assoc :return v
+             :inner-tags [:let])
+      (update-tree! tree-atom))
+  v)
+
+(defn tr-let-bind
+  [template tree-atom v bnd-frm val-frm]
+  (-> (produce-recent-tree-atom! (:inner-path template)
+                                 (:path-parents template)
+                                 tree-atom)
+      deref
+      (update-in [:let-binds] conj [v bnd-frm val-frm])
+      (update-tree! tree-atom))
+  v)
+
+(defn xpand-let-binds
+  [xbinds orig-binds path-sym]
+  (vec (mapcat (fn [[xb xv] [ob ov]]
+                 `(~ob (tr-let-bind ~path-sym
+                         ~'$$
+                         ~xv
+                         '~ob
+                         '~ov)))
+               (partition 2 xbinds)
+               (partition 2 orig-binds))))
+
+(defn xpand-let-form
+  [[_ binds & body] orig-binds path-sym]
+  `(tr-let-ret ~path-sym
+     ~'$$
+     (let ~(xpand-let-binds binds orig-binds path-sym)
+       ~@body)))
+
+(defn xpand-let
+  [[_ binds :as form] src-map fn-meta path path-parent]
+  (let [xmap (xpand-all form
+                        src-map
+                        fn-meta
+                        path
+                        path)]
+    (layer-xpansion-maps xmap
+                         {:path-parents {path path-parent}
+                          :templates {path (mk-tree-template src-map
+                                                             (get-form-meta-somehow form)
+                                                             fn-meta
+                                                             path)}
+                          :form (xpand-let-form (:form xmap)
+                                  binds
+                                  (path->sym path))})))
+
 (defn tr-macro
   [template tree-atom mcro v]
   (let [tree @(produce-recent-tree-atom! (:inner-path template)
@@ -611,6 +668,7 @@
       (let [head (first form)]
         (cond
           (= 'fn* head) {:form form}
+          (= 'let head) (apply xpand-let args)
           (util/macro? head) (apply xpand-macro head args)
           (= 'loop head) (apply xpand-loop args)
           (= 'recur head) (apply xpand-recur args)
@@ -728,7 +786,7 @@

 (defn f1
   [a]
-  (for [b [a (inc a)]]
+  (let [b (inc a)]
     b))

 #_ (inner-tracer {:qual-sym 'com.billpiel.sayid.inner-trace3/f1


try again

try again

--- src/edu/berkeley/ai/scripts/cluster.clj
+++ src/edu/berkeley/ai/scripts/cluster.clj
@@ -27,7 +27,7 @@
 		  "-o" (str (util/file-stem f) ".out")
 		  "-e" (str (util/file-stem f) ".err")]
 		*default-qsub-options*
-		[:in (str *default-clj* f) :dir (util/dirname f)])))))))
+		[:in (str *default-clj* " " f) :dir (util/dirname f)])))))))

 (defn run-experiment-set-subprocesses [es]
   (run-files-subprocesses


Try to get more informative info out of compile-stefon-with-sourcemaps take 2

--- src/frontend/stefon_with_sourcemaps.clj
+++ src/frontend/stefon_with_sourcemaps.clj
@@ -16,6 +16,7 @@
         current-sourcemap-sections (atom [])
         compiled-stefon (StringBuilder.)]
     (doseq [sf (original-stefon/stefon-files root adrf content)]
+      (println "compile-stefon-with-sourcemaps handling: " sf)
       (let [compiled-content (->> sf
                                   (asset/compile root)
                                   second
@@ -36,12 +37,13 @@
                                                   (fs/join root (fs/dirname sf))
                                                   source-map))]
                 (try
+                  (println sf " asset compiled to compiled-source-map of type " (type compiled-source-map))
                   (swap! current-sourcemap-sections conj {:offset {:line @current-offset-row
                                                                    :column 0}
                                                           :map (json/read-str compiled-source-map)})
                   (catch java.lang.ClassCastException e
-                    (infof "(asset/compile %s source-map) gives compiled-source-map of type %s"
-                           (fs/join root (fs/dirname sf)) (type compiled-source-map))
+                    (println "(asset/compile %s source-map) gives compiled-source-map of type %s"
+                             (fs/join root (fs/dirname sf)) (type compiled-source-map))
                     (throw e)))))
             (do
               ;; if the last line isn't a sourcemapping, append it


Refer to the http-handler by var

Refer to the http-handler by var

Introducing this extra level of indirections means that when the server
implementation (e.g. the routes) changes, and ring.reload reloads it,
figwheel actually uses the new definition.

--- src/leiningen/new/chestnut/dev/user.clj
+++ src/leiningen/new/chestnut/dev/user.clj
@@ -24,7 +24,7 @@
 {{/sass?}}

 (def http-handler
-  (wrap-reload {{project-ns}}.server/http-handler))
+  (wrap-reload #'{{project-ns}}.server/http-handler))

 (defn run []
   (figwheel/start-figwheel!){{less-sass-start}})