Improve docs on repos structure.

Improve docs on repos structure.

--- src/org/scode/sob/repos.clj
+++ src/org/scode/sob/repos.clj
@@ -13,7 +13,11 @@
  "Make a new repository at the given path. The path need not exist,
   can be empty, or can contain one or more posts.

-  The returned repository is intended to be opaque."
+  A repos has at least these keys:
+
+    :path - the path given to this function
+    :pages - arbitrarily ordered list of pages
+ "
  [path]
  ; Perform an immediate scan because it tends to be helpful to see
  ; failures immediately in case there are any; both during development


parking mongo date cache

parking mongo date cache

--- src/org/gensym/viddy/queries/mongo_date_cache.clj
+++ src/org/gensym/viddy/queries/mongo_date_cache.clj
@@ -1,11 +1,25 @@
 (ns org.gensym.viddy.queries.mongo-date-cache
-  (:require [monger.core :as mg])
+  (:require [monger.core :as mg]
+            [monger.multi.collection :as coll])
   (:import [com.mongodb MongoOptions ServerAddress]))

 (def host "localhost")

-(def port 7878)
+(def dbname "local")
+
+(def port 27017)

 (defn connect []
   (mg/connect {:host host :port port}))

+
+
+(defn insertion [db]
+  (coll/insert-and-return db "documents" {:name "John" :age 23 :hobbies ["fishing" "fission"]}))
+
+
+(defn doit [conn]
+  (insertion (mg/get-db conn dbname)))
+
+(defn findit [conn]
+  (coll/find (mg/get-db conn dbname) "documents" {:name "John"}))


fixing bad pre-condition

fixing bad pre-condition

--- src/overtone/core/synth.clj
+++ src/overtone/core/synth.clj
@@ -14,6 +14,12 @@
 (def *ugens* nil)
 (def *constants* nil)
 (def *params* nil)
+
+(defn control-proxy [name]
+  (with-meta {:name (str name)}
+             {:type ::control-proxy}))
+
+(defn control-proxy? [obj] (= ::control-proxy (type obj)))

 (defn- index-of [col item]
   (first (first (filter (fn [[i v]]
@@ -56,7 +62,7 @@
   ugens according to the arguments in the initial definition."
   [ugen ugens constants grouped-params]
   {:pre [(contains? ugen :args)
-         (every? #(or (ugen? %) (number? %)) (:args ugen))]
+         (every? #(or (ugen? %) (number? %) (control-proxy? %)) (:args ugen))]
    :post [(contains? % :inputs)
           (every? (fn [in] (not (nil? in))) (:inputs %))]}
   (let [inputs (flatten
@@ -234,10 +240,6 @@
                 :pnames pnames
                 :ugens detailed}
                {:type :overtone.core.synthdef/synthdef})))
-
-(defn control-proxy [name]
-  (with-meta {:name (str name)}
-             {:type ::control-proxy}))

 ; TODO: This should eventually handle optional rate specifiers, and possibly
 ; be extended with support for defining ranges of values, etc...


Improve docstring

Improve docstring

--- src/overtone/libs/event.clj
+++ src/overtone/libs/event.clj
@@ -187,8 +187,9 @@
   "Fire an event of type event-type with any number of additional
   properties.

-  NOTE: an event requires key/value pairs, and everything gets wrapped
-  into an event map.  It will not work if you just pass values.
+  NOTE: an event requires either a map as a single argument, or
+  key/value pairs which will be poured into an event map.  It will not
+  work if you just pass values.

   (event ::my-event)
   (event ::filter-sweep-done :instrument :phat-bass)"


Normalize spherical coordinates in layout.

--- src/org/playasophy/wonderdome/geometry/layout.clj
+++ src/org/playasophy/wonderdome/geometry/layout.clj
@@ -142,7 +142,7 @@
               {:strip i
                :pixel j
                :coord coord
-               :sphere (cartesian/->sphere coord)})
+               :sphere (sphere/normalize (cartesian/->sphere coord))})
             strip
             (range)))
         (map struts->pixels strip-struts)


Do not resize animated GIFs

Do not resize animated GIFs

--- src/multiplex/gfx.clj
+++ src/multiplex/gfx.clj
@@ -25,9 +25,21 @@
         src (java.nio.file.Paths/get uri)]
     (java.nio.file.Files/probeContentType src)))

+(defn num-frames
+  [gif-path]
+  (let [file (java.io.File. gif-path)
+        irs (com.sun.imageio.plugins.gif.GIFImageReaderSpi.)
+        ir (com.sun.imageio.plugins.gif.GIFImageReader. irs)
+        foo (javax.imageio.ImageIO/createImageInputStream file)
+        ir2 (doto ir (.setInput foo))]
+     (.getNumImages ir2 true)))
+
 (defn needs-resize?
-  [orig-sizes new-sizes]
-  (not= orig-sizes new-sizes))
+  [orig-sizes new-sizes filename]
+  (let [ext (util/file-extension filename)]
+    (if (= "gif" ext)
+      (if (= 1 (num-frames filename)) true false)
+      (not= orig-sizes new-sizes))))

 (defn calc-resized
   [image]


wip(incidents): edit incident screen uses react component with form validation

--- src/re_navigate/shared/screens/edit_incident.cljs
+++ src/re_navigate/shared/screens/edit_incident.cljs
@@ -46,20 +46,14 @@
             [view {:style card-action-style}
               [text { } @greeting]]]]])))

-(defn valid-form? [props] true)
-
-; TODO: Need to get to local/global props to get the 'validation result'
-
-; (defn valid-form? [props]
-;   (js/console.log "valid form?")
-;   (let [validation-result
-;     (.validate (-> props
-;                                          (aget "refs")
-;                                          (aget "form")))]
-;   (empty? (js->clj (aget validation-result "errors")))))
-
-(defn sanitise-form [incident]
-  (if (valid-form? incident)
+(defn valid-form? [props]
+  (let [validation-result (.validate (-> props
+                                         (aget "refs")
+                                         (aget "form")))]
+  (empty? (js->clj (aget validation-result "errors")))))
+
+(defn on-submit [props incident]
+  (when (valid-form? props)
     (js/console.log (clj->js incident))
     (let [value (keywordize-keys (:value incident))
           start_time (:start_time value)
@@ -70,8 +64,8 @@
             (assoc :start_time (.toISOString (new js/Date start_time)))
             (assoc :end_time (.toISOString (new js/Date end_time))))]
             (js/console.log "converted incident object to: " (clj->js updated))
-          updated))
-          incident)
+      (rf/dispatch [:save-incident updated])
+      (rf/dispatch [:nav/push :incidents]))))

 (defn save [incident]
   (let [updated (sanitise-form incident)]
@@ -155,7 +149,6 @@
       (t.struct (clj->js (assoc obj :id t.Number)))
       (t.struct (clj->js obj)))))

-; ; TODO: Move state into GLOBAL app state, not confined to component
 ;
 (def style
   {
@@ -172,31 +165,45 @@
                  :font-weight "bold"}
    })

+; ; TODO: Move state into GLOBAL app state, not confined to component
 (defn edit-incident-form []
-  (let [current-incident (subscribe [:current-incident])
-        start_time (:start_time @current-incident)
-        end_time   (:end_time @current-incident)
-        students   (:students @current-incident)
-        id         (:id @current-incident)
-        local_id   (:local_id @current-incident)
-    ; Convert string to Date objects, and extract student id's
-    updated (-> @current-incident
-        (assoc :students (into [] (map #(:id %1) students)))
-        (assoc :local_id (if (and (nil? id) (nil? local_id))
-                             (.now js/Date)
-                             (if-not (nil? local_id) local_id id)))
-        (assoc :start_time (js->clj (if (nil? start_time) (new js/Date) (new js/Date start_time))))
-        (assoc :end_time (js->clj (if (nil? end_time) (new js/Date) (new js/Date end_time)))))]
-    (fn []
-      [scroll {:style {:flex 1}}
-        [view {:style { :flex 1 :alignItems "stretch" :backgroundColor "#F5FCFF" :padding 20 :marginTop 0 }}
-          [Form {:ref "form"
-             :type (incident @current-incident)
-             :value @current-incident
-             :options options
-             :on-change #(save %1)
-           }]
-           [touchable-highlight
-             {:style    (style :button)
-             :on-press    #(dispatch [:nav/set-tab "Index"])}
-             [text {:style (style :button-text)} "Save Incident"]]]])))
+ (fn []
+  (r/create-class
+    {:component-will-mount
+     (fn [this]
+       (let [incident (subscribe [:current-incident])
+             start_time (:start_time @incident)
+             end_time   (:end_time @incident)
+             students   (:students @incident)
+             id         (:id @incident)
+             local_id   (:local_id @incident)
+         ; Convert string to Date objects, and extract student id's
+         updated (-> @incident
+             (assoc :students (into [] (map #(:id %1) students)))
+             (assoc :local_id (if (and (nil? id) (nil? local_id))
+                                  (.now js/Date)
+                                  (if-not (nil? local_id) local_id id)))
+             (assoc :start_time (js->clj (if (nil? start_time) (new js/Date) (new js/Date start_time))))
+             (assoc :end_time (js->clj (if (nil? end_time) (new js/Date) (new js/Date end_time)))))]
+         (r/set-state this {:value updated})))
+
+     :reagent-render
+     (fn [props]
+       (this-as this
+                (let [{:keys [value]} (r/state this)]
+                (js/console.log "Updated model: " (clj->js value))
+                   [view {:style (:form-container styles)}
+                    [scroll
+                     {:style (:scroll-container styles)}
+                     [Form {:ref "form"
+                            :type (incident value)
+                            :value value
+                            :options options
+                            :on-change #(r/set-state this {:value (js->clj %1)})}]
+                      [touchable-highlight
+                        {:style      (style :button)
+                        :disabled?    #(not (valid-form? props))
+                        :on-press    #(js/console.log "touchable-highlight")}
+                        [text {:style (style :button-text)} "Save Incident"]]
+
+                            ]])))})))


asx-prices link

asx-prices link

--- src/notifier/core.clj
+++ src/notifier/core.clj
@@ -8,6 +8,8 @@
             [clj-time.periodic :refer [periodic-seq]]
             [org.httpkit.client :as http])
   (:gen-class))
+
+;; ASX-ordinaries http://www.marketindex.com.au/all-ordinaries

 (def ifttt-key (delay (System/getProperty "ifttt-key")))


Add biquad filter node

Add biquad filter node

--- src/alder/node-type.cljs
+++ src/alder/node-type.cljs
@@ -147,6 +147,53 @@
              (fn [ctx] #js {})
              {:type :input}))

+(def biquad-filter-node-type
+  (NodeType. {:signal-in {:type :node
+                          :index 0
+                          :title "Signal in"}
+              :frequency {:type :param
+                          :name "frequency"
+                          :title "Frequency"
+                          :default 350
+                          :data-type :number
+                          :range [0 22050]}
+              :detune {:type :param
+                       :name "detune"
+                       :title "Detune"
+                       :default 0
+                       :data-type :number
+                       :range [-100 100]}
+              :Q {:type :param
+                  :name "Q"
+                  :title "Quality"
+                  :default 1
+                  :data-type :number
+                  :range [0.0001 1000]}
+              :gain {:type :param
+                     :name "gain"
+                     :title "Gain"
+                     :default 0
+                     :data-type :number
+                     :range [-40 40]}
+              :type {:type :constant
+                     :name "type"
+                     :title "Type"
+                     :default "lowpass"
+                     :data-type :string
+                     :choices ["lowpass" "highpass" "bandpass"
+                               "lowshelf" "highshelf" "peaking"
+                               "notch"
+                               "allpass"]}}
+             {:signal-out {:type :node
+                           :index 0
+                           :title "Signal out"}}
+             nil
+             false
+             "LO Filter"
+             [90 100]
+             (fn [ctx] (.call (aget ctx "createBiquadFilter") ctx))
+             {:constructor "context.createBiquadFilter()"}))
+
 (def midi-note-node-type
   (NodeType. {:device {:type :accessor
                        :name "device"
@@ -177,6 +224,7 @@
                      :input input-node-type
                      :oscillator oscillator-node-type
                      :gain gain-node-type
+                     :biquad-filter biquad-filter-node-type
                      :adsr adsr-node-type
                      :fft fft-analyser-node-type
                      :scope scope-analyser-node-type}


Use reduce instead of apply.

Use reduce instead of apply.

--- project/analyze-data/src/analyze_data/naive_bayes/train.clj
+++ project/analyze-data/src/analyze_data/naive_bayes/train.clj
@@ -43,7 +43,7 @@
   the number of terms. Each entry phi[i][j] represents prob(j|y=i)."
   [X label-indices]
   (let [sum-of-samples-by-label (sum-samples-by-label X label-indices)
-        sum-of-all-samples (apply m/add X)
+        sum-of-all-samples (reduce m/add X)
         num-terms (second (m/shape X))]
     (m/div (m/add sum-of-samples-by-label 1)
            (m/add sum-of-all-samples num-terms))))


use 'next' label when sending transaction requires a sign

Signed-off-by: Volodymyr Kozieiev <f2778d839d9f3ad586693b057b494a6ec3a7ca24@gmail.com>

--- src/status_im/ui/screens/wallet/send/views.cljs
+++ src/status_im/ui/screens/wallet/send/views.cljs
@@ -18,7 +18,8 @@
             [status-im.ui.screens.wallet.send.sheets :as sheets]
             [status-im.ui.screens.wallet.components.views :as components]
             [status-im.utils.utils :as utils]
-            [status-im.ui.components.button :as button]))
+            [status-im.ui.components.button :as button]
+            [status-im.ethereum.core :as ethereum]))

 (defn header [{:keys [label small-screen? on-cancel]}]
   [react/view (styles/header small-screen?)
@@ -89,7 +90,8 @@
                   [:wallet.send/prepare-transaction-with-balance]
                   window-height [:dimensions/window-height]
                   keyboard-height [:keyboard-height]]
-    (let [small-screen? (< (- window-height keyboard-height) 450)]
+    (let [small-screen? (< (- window-height keyboard-height) 450)
+          to-norm (ethereum/normalized-hex (if (string? to) to (:address to)))]
       [react/view {:style (styles/sheet small-screen?)}
        [header {:small-screen? small-screen?
                 :on-cancel #(re-frame/dispatch [:wallet/cancel-transaction-command])}]
@@ -130,7 +132,7 @@
          [render-contact to from-chat?]]]
        [toolbar/toolbar
         {:center
-         {:label               :t/wallet-send
+         {:label               (if (and (not request?) from-chat? (not to-norm)) :t/wallet-send :t/next)
           :accessibility-label :send-transaction-bottom-sheet
           :disabled?           (not sign-enabled?)
           :on-press            #(re-frame/dispatch


RDC - Include the rotate-cell function in unit.

--- src/icfp2015/unit.clj
+++ src/icfp2015/unit.clj
@@ -1,6 +1,6 @@
 (ns icfp2015.unit
   (:require [clojure.set :refer [intersection union]]
-            [icfp2015.cell :refer [translate-dir]]))
+            [icfp2015.cell :refer [translate-dir rotate-cell]]))

 (defn translate [direction]
   (fn [unit]


Better doc string

Better doc string

--- src/structural_typing/guts/paths/substituting.clj
+++ src/structural_typing/guts/paths/substituting.clj
@@ -16,10 +16,7 @@

 (defn includes
   "During creation of a type by [[named]] or [[type!]], a call to
-   `includes` is replaced with the type the `type-signifier` refers
-   to.  The exact meaning of that replacement depends on whether it's used in a path, as
-   the value of a path, or as an entire argument itself. See the wiki
-   documentation."
+   `includes` is replaced with the type the `type-signifier` refers to."
   [type-signifier]
   (when-not (keyword? type-signifier) (frob/boom! "%s is supposed to be a keyword." type-signifier))
   (-> (fn [type-map]


Better cmd + middle click handling

Better cmd + middle click handling

Fixes #2754

--- frontend/history.cljs
+++ frontend/history.cljs
@@ -5,10 +5,11 @@
             [frontend.utils :as utils :include-macros true]
             [goog.events :as events]
             [goog.history.Html5History :as html5-history]
+            [goog.window :as window]
             [secretary.core :as sec])
   (:require-macros [dommy.macros :refer [sel sel1]])
   (:import [goog.history Html5History]
-           [goog.events EventType Event]
+           [goog.events EventType Event BrowserEvent]
            [goog History]))

@@ -77,31 +78,39 @@
   (= (first (string/split token-a #"#"))
      (first (string/split token-b #"#"))))

+(defn new-window-click? [event]
+  (or (.isButton event goog.events.BrowserEvent.MouseButton.MIDDLE)
+      (and (.-platformModifierKey event)
+           (.isButton event goog.events.BrowserEvent.MouseButton.LEFT))))
+
 (defn setup-link-dispatcher! [history-imp top-level-node]
   (let [dom-helper (goog.dom.DomHelper.)]
     (events/listen top-level-node "click"
-                   #(when (and (.isMouseActionButton %) ; ignore middle clicks
-                               (not (.-metaKey %))) ; ignore cmd+click
-                      (let [-target (.. % -target)
-                            _ (set! js/window.teste %)
-                            target (if (= (.-tagName -target) "A")
-                                     -target
-                                     (.getAncestorByTagNameAndClass dom-helper -target "A"))
-                            location (when target (str (.-pathname target) (.-search target) (.-hash target)))
-                            new-token (when (seq location) (subs location 1 ))]
-                        (when (and (seq location)
-                                   (not= "_blank" (.-target target))
-                                   (= (.. js/window -location -hostname)
-                                      (.-hostname target)))
-                          (.stopPropagation %)
-                          (.preventDefault %)
-                          (if (and (route-fragment location)
-                                   (path-matches? (.getToken history-imp) new-token))
+                   #(let [-target (.. % -target)
+                          _ (set! js/window.teste %)
+                          target (if (= (.-tagName -target) "A")
+                                   -target
+                                   (.getAncestorByTagNameAndClass dom-helper -target "A"))
+                          new-window? (or (new-window-click? %) (= (.-target target) "_blank"))
+                          location (when target (str (.-pathname target) (.-search target) (.-hash target)))
+                          new-token (when (seq location) (subs location 1))]
+                      (when (and (seq location)
+                                 (= (.. js/window -location -hostname)
+                                    (.-hostname target)))
+                        (.stopPropagation %)
+                        (.preventDefault %)
+                        (cond
+                          new-window?
+                            (do (utils/mlog "new window at" location)
+                                (window/open location))
+                          (and (route-fragment location)
+                               (path-matches? (.getToken history-imp) new-token))
                             (do (utils/mlog "scrolling to hash for" location)
                                 ;; don't break the back button
                                 (.replaceToken history-imp new-token))
+                          :else
                             (do (utils/mlog "navigating to" location)
-                                (.setToken history-imp new-token)))))))))
+                                (.setToken history-imp new-token))))))))

 (defn new-history-imp [top-level-node]
   ;; need a history element, or goog will overwrite the entire dom


Factor out button bit-testing logic to enable button maps.

--- src/org/playasophy/wonderdome/input/gamepad.clj
+++ src/org/playasophy/wonderdome/input/gamepad.clj
@@ -17,6 +17,17 @@
       :else (inc value))
     (/ 128.0)
     (- 1.0)))
+
+
+(defn- read-buttons
+  "Takes in a definition map from button keys to a vector of [byte bit-pos] and
+  a buffer, and returns a map of button keys to booleans."
+  [buttons ^bytes buffer]
+  (->>
+    buttons
+    (map (fn [[k [b n]]]
+           [k (bit-test (aget buffer b) n)]))
+    (into {})))

 (defn- button-events
@@ -68,6 +79,17 @@
 (def ^:const snes-product-id 0xd015)

+(def ^:private snes-buttons
+  {:X      [3 0]
+   :A      [3 1]
+   :B      [3 2]
+   :Y      [3 3]
+   :L      [3 4]
+   :R      [3 5]
+   :select [4 0]
+   :start  [4 1]})
+
+
 (defn- snes-read-state
   "SNES controller state is read 8 bytes at a time:
     byte 0: x-axis [00 7F FF] (FF is right)
@@ -80,16 +102,10 @@
   (if (< len 8)
     (println "Incomplete data read from SNES controller:"
              (apply str (map (partial format "%02X") (take len buffer))))
-    {:x-axis (byte-axis (aget buffer 0))
-     :y-axis (- (byte-axis (aget buffer 1)))
-     :X (bit-test (aget buffer 3) 0)
-     :A (bit-test (aget buffer 3) 1)
-     :B (bit-test (aget buffer 3) 2)
-     :Y (bit-test (aget buffer 3) 3)
-     :L (bit-test (aget buffer 3) 4)
-     :R (bit-test (aget buffer 3) 5)
-     :select (bit-test (aget buffer 4) 0)
-     :start  (bit-test (aget buffer 4) 1)}))
+    (assoc
+      (read-buttons snes-buttons buffer)
+      :x-axis (byte-axis (aget buffer 0))
+      :y-axis (- (byte-axis (aget buffer 1))))))

 (defn- snes-state-events


make use of #'file-exists? file helper fn

--- src/overtone/sc/machinery/server/connection.clj
+++ src/overtone/sc/machinery/server/connection.clj
@@ -9,7 +9,8 @@
         [overtone.sc.machinery defaults]
         [overtone.sc.machinery.server comms]
         [overtone.osc]
-        [overtone.osc.decode :only [osc-decode-packet]])
+        [overtone.osc.decode :only [osc-decode-packet]]
+        [overtone.helpers.file :only [file-exists?]])
   (:require [overtone.util.log :as log]))

 (defonce server-thread*       (ref nil))
@@ -195,7 +196,7 @@
         paths (SC-PATHS os)
         path  (if (= :linux os)
                 (first paths)
-                (first (filter #(.exists (java.io.File. %)) paths)))]
+                (first (filter #(file-exists? %) paths)))]
     (when-not path
       (throw (Exception. (str "Unable to locate a valid scsynth executable on your system. I looked in the following places: " paths))))


Add test for st op in interactive mode

Add test for st op in interactive mode

--- test/app/test/interactive.clj
+++ test/app/test/interactive.clj
@@ -76,3 +76,18 @@
                  constructorsWithManyParametersOp
                  (:cus javaparser-cus)
                  mcp-op-threshold)))))
+
+(deftest can-execute-st-operation
+  (let [javaparser-cus {:cus (take 2 (cus javaparser-cus-path))}
+        command-sequence ["st" "quit"]
+        input-string (command-sequence->input-str command-sequence)]
+    (with-in-str
+      input-string
+      (mocking [println print flush printOperation]
+               (interactive javaparser-cus)
+               (verify-call-times-for printOperation 1)
+               (verify-first-call-args-for
+                 printOperation
+                 classesAndSingletonTypeOp
+                 (:cus javaparser-cus)
+                 nil)))))


apply clean-text translation to 3.0 spec

--- src/vip/data_processor/validation/data_spec/v3_0.clj
+++ src/vip/data_processor/validation/data_spec/v3_0.clj
@@ -1,6 +1,7 @@
 (ns vip.data-processor.validation.data-spec.v3-0
   (:require [vip.data-processor.validation.data-spec.value-format :as format]
-            [vip.data-processor.validation.data-spec.coerce :as coerce]))
+            [vip.data-processor.validation.data-spec.coerce :as coerce]
+            [vip.data-processor.validation.data-spec.translate :as translate]))

 (def data-specs
   [{:filename "ballot.txt"
@@ -39,7 +40,7 @@
     :tag-name :ballot_response
     :stats true
     :columns [{:name "id" :required :critical :format format/all-digits :coerce coerce/coerce-integer}
-              {:name "text" :required :critical}
+              {:name "text" :required :critical :translate translate/clean-text}
               {:name "sort_order" :format format/all-digits :coerce coerce/coerce-integer}]}
    {:filename "candidate.txt"
     :table :candidates
@@ -291,7 +292,7 @@
               {:name "title" :required :critical}
               {:name "subtitle"}
               {:name "brief"}
-              {:name "text" :required :critical}
+              {:name "text" :required :critical :translate translate/clean-text}
               {:name "pro_statement"}
               {:name "con_statement"}
               {:name "passage_threshold"}


Fix scheduled-pool constructor

Fix scheduled-pool constructor

--- src/promesa/exec.cljc
+++ src/promesa/exec.cljc
@@ -139,7 +139,7 @@

 #?(:clj
    (defn scheduled-pool
-     "A scheduled thread pool constructo."
+     "A scheduled thread pool constructor."
      ([] (Executors/newScheduledThreadPool (int 0)))
      ([n] (Executors/newScheduledThreadPool (int n)))
      ([n opts]


remove println

remove println

--- test/clj_kafka/test/utils.clj
+++ test/clj_kafka/test/utils.clj
@@ -38,7 +38,6 @@

 (defn create-zookeeper
   [{:keys [port host snapshot-dir log-dir]}]
-  (println "Creating zookeeper: " host port snapshot-dir log-dir)
   (let [tick-time 500
         zk (ZooKeeperServer. (file snapshot-dir) (file log-dir) tick-time)]
     (doto (NIOServerCnxn$Factory. (InetSocketAddress. host port))


fix specify "this" test

fix specify "this" test

--- test/cljs/cljs/core_test.cljs
+++ test/cljs/cljs/core_test.cljs
@@ -2060,8 +2060,8 @@
   ;; CLJS-414

   (assert (= (specify noz IWoz (-woz [_] :boz)) noz))
-  (assert (= (specify noz IWoz (-woz [this] this)) noz))
   (assert (not (identical? (specify noz IWoz (-woz [_] :boz)) noz)))
+  (assert (= (-woz (specify noz IWoz (-woz [this] this))) noz))
   (assert (= (-woz (specify noz IWoz (-woz [_] :boz))) :boz))

   :ok


load css files directly from where they came from

--- support/src/figwheel/client/file_reloading.cljs
+++ support/src/figwheel/client/file_reloading.cljs
@@ -146,7 +146,8 @@
 ;; CSS reloading

 (defn current-links []
-  (.call (.. js/Array -prototype -slice) (.getElementsByTagName js/document "link")))
+  (.call (.. js/Array -prototype -slice)
+         (.getElementsByTagName js/document "link")))

 (defn truncate-url [url]
   (-> (first (string/split url #"\?"))
@@ -160,13 +161,28 @@
     (or (= file trunc-href)
         (= (truncate-url request-url) trunc-href))))

-#_(defn matches-file-new? [{:keys [file] } link-href]
-    (.endsWith goog.string file (truncate-url link-href)))
+(defn matches-file-new?
+  [{:keys [file]} link]
+  (when-let [link-href (.-href link)]
+    (let [match-length (count (take-while identity
+                                          (map #(= %1 %2)
+                                               (reverse file)
+                                               (reverse (truncate-url link-href)))))
+          file-name-length (count (last (string/split file "/")))]
+      (when (>= match-length file-name-length) ;; has to match more than the file name length
+        {:link link
+         :link-href link-href
+         :match-length match-length
+         :current-url-length (count (truncate-url link-href))}))))

 (defn get-correct-link [f-data]
-  (some (fn [l]
-          (when (matches-file? f-data (.-href l)) l))
-        (current-links)))
+  (when-let [res (first
+                  (sort-by
+                   (fn [{:keys [match-length current-url-length]}]
+                     (- current-url-length match-length))
+                   (keep #(matches-file-new? f-data %)
+                         (current-links))))]
+    (:link res)))

 (defn clone-link [link url]
   (let [clone (.createElement js/document "link")]
@@ -191,13 +207,11 @@
        (if (= orig-link (.-lastChild parent))
          (.appendChild parent klone)
          (.insertBefore parent klone (.-nextSibling orig-link)))
-       (go
-        (<! (timeout 200))
-        (.removeChild parent orig-link)))))
+       (js/setTimeout #(.removeChild parent orig-link) 300))))

 (defn reload-css-file [{:keys [file request-url] :as f-data}]
   (if-let [link (get-correct-link f-data)]
-    (add-link-to-doc link (clone-link link request-url))
+    (add-link-to-doc link (clone-link link (.-href link)))
     (add-link-to-doc (create-link request-url))))

 (defn reload-css-files [{:keys [on-cssload] :as opts} files-msg]
@@ -206,4 +220,3 @@
   (go
    (<! (timeout 100))
    (on-cssload (:files files-msg))))
-


Add write support

Add write support

--- src/lacinia_tut/core.clj
+++ src/lacinia_tut/core.clj
@@ -44,8 +44,14 @@
                         (columns :artistname)
                         (values [[artistname]])
                         (sql/format))
-        result (jdbc/execute! db insert-stmt)]
-    result))
+        result (jdbc/execute! db insert-stmt)
+        res-query (-> (select :*)
+                      (from :artist)
+                      (order-by [:artistid :desc])
+                      (limit 1)
+                      sql/format)
+        artist (jdbc/query db res-query)]
+    artist))

 (def artist-schema
   (-> "schema.edn"


Upgrade todomvc example karma to 4.4.1

Upgrade todomvc example karma to 4.4.1

--- examples/todomvc/src/deps.cljs
+++ examples/todomvc/src/deps.cljs
@@ -1,5 +1,5 @@
 {:npm-dev-deps {"shadow-cljs"           "2.8.69"
-                "karma"                 "4.3.0"
+                "karma"                 "4.4.1"
                 "karma-chrome-launcher" "3.1.0"
                 "karma-cljs-test"       "0.1.0"
                 "karma-junit-reporter"  "1.2.0"}}


cleaned up calls from entity to collection

--- src/karras/entity.clj
+++ src/karras/entity.clj
@@ -205,14 +205,7 @@
   ([type obj]
      (update-all type {} obj))
   ([type criteria obj]
-     (c/update-all (collection-for type) criteria obj)))
-
-(defn delete
-  "Deletes one or more entities."
-  ([entity]
-     (c/delete (collection-for entity) (where (eq :_id (:_id entity)))))
-  ([entity & entities]
-     (doall (map delete (cons entity entities)))))
+     (update type criteria obj :multi)))

 (defn delete-all
   "Deletes all entitys given an optional where clause."
@@ -221,6 +214,13 @@
   ([type where]
      (c/delete (collection-for type) where)))

+(defn delete
+  "Deletes one or more entities."
+  ([entity]
+     (delete-all entity (where (eq :_id (:_id entity)))))
+  ([entity & entities]
+     (doall (map delete (cons entity entities)))))
+
 (defn fetch
   "Fetch a seq of entities for the given type matching the supplied parameters."
   [type criteria & options]
@@ -229,12 +229,12 @@
 (defn fetch-all
   "Fetch all of the entities for the given type."
   [type & options]
-  (map #(make type %) (apply c/fetch-all (collection-for type) options)))
+  (apply fetch type nil options))

 (defn fetch-one
   "Fetch the first entity for the given type matching the supplied criteria and options."
   [type criteria & options]
-  (make type (apply c/fetch-one (collection-for type) criteria options)))
+  (first (apply fetch type criteria options)))

 (defn fetch-by-id
   "Fetch an enity by :_id"
@@ -248,7 +248,7 @@
   ([type]
      (count-instances type nil))
   ([type criteria]
-     (c/fetch (collection-for type) criteria :count true)))
+     (c/count-docs (collection-for type) criteria)))

 (defn distinct-values
   "Return the distinct values of a given type for a given key."


OCD line shifting

OCD line shifting

--- src/main/shadow/cljs/devtools/server/util.clj
+++ src/main/shadow/cljs/devtools/server/util.clj
@@ -78,9 +78,8 @@
   (println " File:" (if file
                       (str file ":" line ":" column)
                       source-name))
-  (println)
   (if-not source-excerpt
-    (do
+    (do (println)
         (println (str " " (coded-str [:yellow :bold] msg)))
         (println separator))


Tests: test-process-front-page-existence, test-process-help-page-existence, test-process-database-statistic-existence, and test-process-export-database-existence

--- test/hurvinek/server_test.clj
+++ test/hurvinek/server_test.clj
@@ -51,3 +51,27 @@
         (is (callable? 'hurvinek.server/finish-processing))))

+(deftest test-process-front-page-existence
+    "Check that the hurvinek.server/process-front-page definition exists."
+    (testing "if the hurvinek.server/process-front-page definition exists."
+        (is (callable? 'hurvinek.server/process-front-page))))
+
+
+(deftest test-process-help-page-existence
+    "Check that the hurvinek.server/process-help-page definition exists."
+    (testing "if the hurvinek.server/process-help-page definition exists."
+        (is (callable? 'hurvinek.server/process-help-page))))
+
+
+(deftest test-process-database-statistic-existence
+    "Check that the hurvinek.server/process-database-statistic definition exists."
+    (testing "if the hurvinek.server/process-database-statistic definition exists."
+        (is (callable? 'hurvinek.server/process-database-statistic))))
+
+
+(deftest test-process-export-database-existence
+    "Check that the hurvinek.server/process-export-database definition exists."
+    (testing "if the hurvinek.server/process-export-database definition exists."
+        (is (callable? 'hurvinek.server/process-export-database))))
+
+


Less verbose store test.

Less verbose store test.

--- src/cbfg/store-test.cljs
+++ src/cbfg/store-test.cljs
@@ -6,11 +6,10 @@
   (let [result2 (if (:cas expect)
                   result
                   (dissoc result :cas))
-        pass (= result2 expect)]
-    (println (str (swap! n inc) ":")
-             (if pass
-               (str "pass: " (:key expect))
-               (str "FAIL:" result2 expect)))
+        pass (= result2 expect)
+        my-n (swap! n inc)]
+    (when (not pass)
+      (println (str my-n ":") "FAIL:" result2 expect))
     (and pass (nil? result-nil))))

 (defn test-basic [actx]


nicknames can't contain punctuation

nicknames can't contain punctuation

--- src/chat/server/util.clj
+++ src/chat/server/util.clj
@@ -4,4 +4,7 @@
 (defn valid-nickname?
   "Checks if a nickname is well-formed. Does NOT check if already taken"
   [nick]
-  (not (or (string/blank? nick) (< 30 (count nick)) (re-find #"\s" nick))))
+  (not (or (string/blank? nick)
+           (< 30 (count nick))
+           (re-find #"\s" nick)
+           (re-find #"\p{Punct}" nick))))


Use atomic move for persistence

Use atomic move for persistence

--- src/robinson/main.clj
+++ src/robinson/main.clj
@@ -52,14 +52,24 @@
 ;(def world-storage (atom nil))

 (go-loop []
-  (let [state (async/<! save-chan)]
+  (let [state (async/<! save-chan)
+        tmp-file (rfs/cwd-file "save/world.edn.tmp")
+        target-file(rfs/cwd-file "save/world.edn")]
     (if-not (contains? #{:quit} (rw/current-state state))
       (do
-        (log/info "World saved at time" (get-in state [:world :time]))
-           (try
-             (with-open [o (io/output-stream (rfs/cwd-path "save/world.edn"))]
-               (nippy/freeze-to-out! (DataOutputStream. o) (get state :world)))
-             (catch Throwable e (log/error "Error saving" e)))
+        (log/info "World saved at time" (get-in state [:world :time]) tmp-file target-file)
+        (try
+          (with-open [o (io/output-stream tmp-file)]
+            (nippy/freeze-to-out! (DataOutputStream. o) (get state :world)))
+          (catch Throwable e (log/error "Error saving" e)))
+
+        ;; copy tmp file to permenent store atomically
+        (java.nio.file.Files/move (.toPath tmp-file)
+                                  (.toPath target-file)
+                                  (into-array java.nio.file.CopyOption
+                                            [(java.nio.file.StandardCopyOption/ATOMIC_MOVE)
+                                             (java.nio.file.StandardCopyOption/REPLACE_EXISTING)]))
+
         ;(as-> state state
         ;  (get state :world)
         ;  (pp/write state :stream nil)


Got rid of the confusing # suffixes and lambda functions.

--- src/overtone/examples/compositions/at_all.clj
+++ src/overtone/examples/compositions/at_all.clj
@@ -3,28 +3,25 @@
     overtone.live
     [overtone.inst.sampled-piano :only [sampled-piano]]))

-(defn at-bpm [beats-per-minute]
-  (let [start (now)
-        ms-per-minute (* 60 1000)
-        ms-per-beat (/ ms-per-minute beats-per-minute)]
-    #(+ start (* ms-per-beat %))))
-
-(defn from [timing offset]
-  #(timing (+ offset %)))
+(defn from [metro offset]
+  (fn [beat] (metro (+ beat offset))))

 (defn speed-up [metro factor]
   (fn [beat] (metro (/ beat factor))))

 (def base 60)
-(defn ground [note] (+ base note))

-(def note# (comp sampled-piano ground))
-(defn chord# [chord] (doseq [note (vals chord)] (note# note)))
+(defn play-note [relative-midi]
+  (-> relative-midi (+ base) sampled-piano))

-(def ionian #(let [interval (mod % 7)
-                  note ([0 2 4 5 7 9 11] interval)
-                  octave (quot (- % interval) 7)]
-               (+ (* 12 octave) note)))
+(defn play-chord [chord]
+  (doseq [note (vals chord)] (play-note note)))
+
+(defn ionian [degree]
+  (let [interval (mod degree 7)
+        note ([0 2 4 5 7 9 11] interval)
+        octave (quot (- degree interval) 7)]
+    (+ (* 12 octave) note)))

 (defn triad [scale root]
   (zipmap [:i :iii :v]
@@ -45,65 +42,65 @@

 (def progression [I I II II II V I (update-in V [:base] lower)])

-(defn rhythm-n-bass# [timing [chord1 chord2 & chords]]
+(defn rhythm-n-bass [timing [chord1 chord2 & chords]]
   (do
-    (at (timing 0) (note# (:base chord1)))
-    (at (timing 2) (chord# (dissoc chord1 :base)))
-    (at (timing 3) (note# (:base chord1)))
-    (at (timing 4) (note# (:base chord2)))
-    (at (timing 6) (chord# (dissoc chord2 :base)))
+    (at (timing 0) (play-note (:base chord1)))
+    (at (timing 2) (play-chord (dissoc chord1 :base)))
+    (at (timing 3) (play-note (:base chord1)))
+    (at (timing 4) (play-note (:base chord2)))
+    (at (timing 6) (play-chord (dissoc chord2 :base)))
     (let [next (from timing 8)]
       (if chords
-        (rhythm-n-bass# next chords)
+        (rhythm-n-bass next chords)
         next))))

-(defn even-melody# [timing [note & notes]]
+(defn even-melody [timing [note & notes]]
   (do
-    (at (timing 0) (note# note))
+    (at (timing 0) (play-note note))
     (let [next (from timing 1)]
       (if notes
-        (even-melody# next notes)
+        (even-melody next notes)
         next))))

-(defn intro# [timing]
-    (even-melody# timing (take 32 (cycle (map ionian [5 4]))))
-    (rhythm-n-bass# timing (take 8 (cycle progression))))
+(defn intro [timing]
+    (even-melody timing (take 32 (cycle (map ionian [5 4]))))
+    (rhythm-n-bass timing (take 8 (cycle progression))))

-(defn first-bit# [timing]
+(defn first-bit [timing]
   (-> timing
     (from -1)
     (speed-up 2)
-    (even-melody# (map ionian [2 4 5 4 4 2 4]))
+    (even-melody (map ionian [2 4 5 4 4 2 4]))
     (from 9)
-    (even-melody# (map ionian [-2 1 2 1 1 -2 1]))
+    (even-melody (map ionian [-2 1 2 1 1 -2 1]))
     (from 9)
-    (even-melody# (map ionian [-2 1 2 1 1 -2 1 2 3 4]))
+    (even-melody (map ionian [-2 1 2 1 1 -2 1 2 3 4]))
     (from 6)
-    (even-melody# (map ionian [-1 -2 -3 0 0 -3 0 1 0 -3])))
-  (rhythm-n-bass# timing (take 8 (cycle progression))))
+    (even-melody (map ionian [-1 -2 -3 0 0 -3 0 1 0 -3])))
+  (rhythm-n-bass timing (take 8 (cycle progression))))

-(defn variation# [timing]
+(defn variation [timing]
   (-> timing
     (speed-up 2)
     (from 9)
-    (even-melody# (map ionian [11 11 12 9 7]))
+    (even-melody (map ionian [11 11 12 9 7]))
     (from 11)
-    (even-melody# (map ionian [8 8 9 8 3]))
+    (even-melody (map ionian [8 8 9 8 3]))
     (from 11)
-    (even-melody# (map ionian [8 8 9 6 4]))
+    (even-melody (map ionian [8 8 9 6 4]))
     (from 11)
-    (even-melody# (map ionian [11 11 12 11 8])))
-  (first-bit# timing))
+    (even-melody (map ionian [11 11 12 11 8])))
+  (first-bit timing))

-(defn final-chord# [timing]
+(defn final-chord [timing]
   (-> timing
     (from -1)
     (speed-up 2)
-    (even-melody# (map ionian [11 13 14])))
+    (even-melody (map ionian [11 13 14])))
   (at (timing 0)
-      (chord# (update-in I [:i] raise))))
+      (play-chord (update-in I [:i] raise))))

-(defn play# [] (-> (metronome 160) (from 2) intro# first-bit#
-                 (speed-up 3/2) variation# final-chord#))
+(defn play [] (-> (metronome 160) (from 2) intro first-bit
+                 (speed-up 3/2) variation final-chord))

-(play#)
+(play)


typos

typos

--- src/clj/cljs/closure.clj
+++ src/clj/cljs/closure.clj
@@ -1079,11 +1079,11 @@
                                    [(-compile (io/resource "cljs/nodejscli.cljs") all-opts)]))))
                  optim (:optimizations all-opts)
                  ret (if (and optim (not= optim :none))
-                       (let [fdeps-str (foreign-deps-str opts
+                       (let [fdeps-str (foreign-deps-str all-opts
                                          (filter foreign-source? js-sources))
-                             all-opts (assoc all-opts
-                                        :foreign-deps-line-count
-                                        (- (count (.split #"\r?\n" fdeps-str -1)) 1))]
+                             all-opts  (assoc all-opts
+                                         :foreign-deps-line-count
+                                         (- (count (.split #"\r?\n" fdeps-str -1)) 1))]
                          (when-let [fname (:source-map all-opts)]
                            (assert (string? fname)
                              (str ":source-map must name a file when using :whitespace, "


spec-ify predicates entering fspec

spec-ify predicates entering fspec

--- src/clj/clojure/spec.clj
+++ src/clj/clojure/spec.clj
@@ -297,7 +297,8 @@

   Returns a spec."
   [form & {:keys [gen]}]
-  `(spec-impl '~(res form) ~form ~gen nil))
+  (when form
+    `(spec-impl '~(res form) ~form ~gen nil)))

 (defmacro multi-spec
   "Takes the name of a spec/predicate-returning multimethod and a
@@ -490,7 +491,9 @@
   Optionally takes :gen generator-fn, which must be a fn of no args
   that returns a test.check generator."
   [& {:keys [args ret fn gen]}]
-  `(fspec-impl ~args '~(res args) ~ret '~(res ret) ~fn '~(res fn) ~gen))
+  `(fspec-impl (spec ~args) '~(res args)
+               (spec ~ret) '~(res ret)
+               (spec ~fn) '~(res fn) ~gen))

 (defmacro tuple
   "takes one or more preds and returns a spec for a tuple, a vector
@@ -1423,20 +1426,14 @@
 (defn ^:skip-wiki fspec-impl
   "Do not call this directly, use 'fspec'"
   [argspec aform retspec rform fnspec fform gfn]
-  (assert (c/and argspec retspec))
   (let [specs {:args argspec :ret retspec :fn fnspec}]
     (reify
      clojure.lang.IFn
      (invoke [this x] (valid? this x))

      clojure.lang.ILookup
-     (valAt [this k] (.valAt this k nil))
-     (valAt [_ k not-found]
-            (case k
-                  :args argspec
-                  :ret retspec
-                  :fn fnspec
-                  not-found))
+     (valAt [this k] (get specs k))
+     (valAt [_ k not-found] (get specs k not-found))

      Spec
      (conform* [_ f] (if (fn? f)


Parse special case of INFO::Number in VCF

--- src/cljam/vcf/reader.clj
+++ src/cljam/vcf/reader.clj
@@ -43,7 +43,10 @@

 (defn- parse-meta-info-info
   [m]
-  (update m :number str->long))
+  (update m :number (fn [s]
+                      (if (#{"A" "R" "G"} s)
+                        s
+                        (str->long s)))))

 (defn- parse-meta-info-line
   [line]


Fix record gensym

Fix record gensym

--- src/cljc/seria/util.cljc
+++ src/cljc/seria/util.cljc
@@ -73,7 +73,7 @@
            {:index        index
             :symbol       (if tuple?
                             (postfix-gensym value (str index))
-                            (gensym (name index)))
+                            (gensym (str (name index) "_")))
             :inner-schema (inner-schemas index)
             :inner-value  (if tuple?
                             `(~value ~index)


Need to deal with uboxing twice for :js as well.

--- src/cljs/go/compiler.clj
+++ src/cljs/go/compiler.clj
@@ -1026,7 +1026,7 @@
                      ")"))))))))

 (defmethod emit* :js
-  [{:keys [env code js-op segs args numeric]}]
+  [{:keys [env code js-op segs args numeric tag]}]
   (let [aset-return? (and (= 'cljs.core/aset js-op) (= :return (:context env)))
         args (case js-op
                cljs.core/make-array [(go-unbox 'number (first args))]
@@ -1037,16 +1037,18 @@
                                       (map (partial go-unbox 'number) (butlast (rest args)))
                                       [(last args)])
                args)]
-    (emit-wrap env
-      (when aset-return?
-        (emits "func() " (go-type (:tag (last args))) "{ "))
-      (cond
-       code (emits code)
-       :else (emits (interleave (concat segs (repeat nil))
-                                (map (if numeric (partial go-unbox 'number) identity)
-                                     (concat args [nil])))))
-      (when aset-return?
-        (emits "; return " (first args) (map #(str "[int(" % ")]") (butlast (rest args))) " }()")))))
+    (binding [*go-return-tag* (when (go-needs-coercion? tag *go-return-tag*)
+                                *go-return-tag*)]
+      (emit-wrap env
+        (when aset-return?
+          (emits "func() " (go-type (:tag (last args))) "{ "))
+        (cond
+         code (emits code)
+         :else (emits (interleave (concat segs (repeat nil))
+                                  (map (if numeric (partial go-unbox 'number) identity)
+                                       (concat args [nil])))))
+        (when aset-return?
+          (emits "; return " (first args) (map #(str "[int(" % ")]") (butlast (rest args))) " }()"))))))

 (defn rename-to-js
   "Change the file extension from .cljs to .js. Takes a File or a


Generate good markup for issues.

Generate good markup for issues.

--- src/cljs/sally/core.cljs
+++ src/cljs/sally/core.cljs
@@ -26,12 +26,24 @@
                        :on-change (ig change-code data owner)}
            (:code data)]])))

-(defn display-issue [issue]
+(defn code->hiccup [class-name code]
+  [:pre {:class class-name}
+   [:code (pr-str code)]])
+
+(defn display-issue [{:keys [alt expr line column]}]
   (reify
     om/IDisplayName
     (display-name [_] "Issue")
     om/IRender
-    (render [_] (html [:li.issue (pr-str issue)]))))
+    (render [_]
+      (html [:li.issue
+             [:div.line line]
+             [:div.column column]
+             [:div.suggestion
+              "Use "
+              (code->hiccup :alt alt)
+              " instead of "
+              (code->hiccup :expr expr)]]))))

 (defn display-checker [{:keys [name issues]}]
   (om/component
@@ -46,7 +58,7 @@
             (om/build-all display-checker (get data :issues))]])))

 (defmulti listen (fn [tx-data _] (:tag tx-data)))
-; (defmethod listen :default (constantly nil))
+(defmethod listen :default [_ _] nil)

 (defn- edn-post [url [content-type data] success-fn]
   (jq/ajax url
@@ -63,7 +75,6 @@
             (fn code-change-post-success [resp]
               (om/transact! root-cursor
                             :issues (constantly resp)))))
-(defmethod listen :default [_ _] nil)

 (om/root
   live-checking


Experiment with meta-errors

Experiment with meta-errors

--- src/clojush/evaluate.clj
+++ src/clojush/evaluate.clj
@@ -208,7 +208,7 @@
                                                (iterate (partial * (- 1 improvement-discount)) 1))
                                  sum (reduce + (mapv * improvements weights))]
                              (- sum)))))))
-              #_(if (not (:print-history argmap))
+              (if (not (:print-history argmap))
                 (throw
                   (Exception.
                     ":print-history must be true for :case-stagnation"))
@@ -228,7 +228,7 @@
                                                (iterate (partial * (- 1 improvement-discount)) 1))
                                  sum (reduce + (mapv * improvements weights))]
                              (- sum)))))))
-              (if (not (:print-history argmap))
+              #_(if (not (:print-history argmap))
                 (throw
                   (Exception.
                     ":print-history must be true for :case-stagnation"))
@@ -237,6 +237,25 @@
                   (vec (for [case-history (apply map list (:history ind))]
                          (let [improvements (mapv (fn [[newer-error older-error]]
                                                     (if (< newer-error older-error)
+                                                      1.0
+                                                      (if (= newer-error older-error)
+                                                        -1.0
+                                                        0.0)))
+                                                  (partition 2 1 case-history))
+                               weights (take (count improvements)
+                                             (iterate (partial * (- 1 improvement-discount)) 1))
+                               sum (reduce + (mapv * improvements weights))]
+                           (- sum))))))
+              #_(if (not (:print-history argmap))
+                (throw
+                  (Exception.
+                    ":print-history must be true for :case-stagnation"))
+                (if (empty? (rest (:history ind)))
+                  (vec (repeat (count (:errors ind)) 1000000))
+                  (vec (for [case-history (apply map list (:history ind))]
+                         (let [improvements (mapv (fn [[newer-error older-error]]
+                                                    (if (or (zero? newer-error)
+                                                            (< newer-error older-error))
                                                       1.0
                                                       (if (= newer-error older-error)
                                                         -1.0


Hack more

Hack more

--- src/clojush/evaluate.clj
+++ src/clojush/evaluate.clj
@@ -265,7 +265,7 @@
                                          (- 1.0 (/ (max 0 (reduce + improvements))
                                                    (count improvements))))))))) ;;;;;;;;;;;;;; HACK
                           ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HACKED STABILITY
-                          (if (not (:print-history argmap))
+                          #_(if (not (:print-history argmap))
                             (throw
                               (Exception.
                                 ":print-history must be true for :case-stagnation"))
@@ -280,6 +280,30 @@
                                                              (if (= older-error newer-error)
                                                                0.0
                                                                1.0))
+                                                           (partition 2 1 case-history))
+                                             weights (take (count changes)
+                                                           (iterate (partial * (- 1 improvement-discount)) 1.0))
+                                             sum (reduce + (mapv * changes weights))]
+                                         (/ 1.0 (inc (/ sum
+                                                        (reduce + weights)))))))))) ;;;;;;;;;;;;;; HACK
+                          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HACKED STABILITY
+                          (if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :case-stagnation"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (count (:errors ind)) 1000000))
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     (if false ;(zero? (first case-history)) ;;;;;;;;;; HACK
+                                       ;; note only zero is solved
+                                       ;; error-threshold applies to total so can't be used here
+                                       0 ;; solved, improvement doesn't matter
+                                       (let [changes (mapv (fn [[newer-error older-error]]
+                                                             (if (> older-error newer-error)
+                                                               1.0
+                                                               (if (= older-error newer-error)
+                                                                 0.0
+                                                                 0.5)))
                                                            (partition 2 1 case-history))
                                              weights (take (count changes)
                                                            (iterate (partial * (- 1 improvement-discount)) 1.0))


Directory name.

Directory name.

--- from-repl.clj
+++ from-repl.clj
@@ -61,4 +61,4 @@
 (render-wt "HTML/02_forms_controls_inputs")
 (render-wt "React/01_introduction_to_React")
 (render-wt "WebServices/02_AJAX")
-(render-wt "WebServices/99_AJAX_forms")
+(render-wt "WebServices/99_AJAX_React")


Fix mailgun output unit test

Fix mailgun output unit test

Can't use a static string for the body stub as the timestamp generated
by the body function is based on the timezone of the machine it is run
on. Use the default body function instead.

--- test/riemann/mailgun_test.clj
+++ test/riemann/mailgun_test.clj
@@ -1,5 +1,6 @@
 (ns riemann.mailgun-test
   (:require [riemann.mailgun :as mailgun]
+            [riemann.common :refer [body]]
             [clj-http.client :as client]
             [clojure.test :refer [deftest testing is are]]))

@@ -16,12 +17,12 @@
         sandbox "mail.relay"
         service-key "testkey"
         recipient "somedude@somewhere.com"
-        default-body-result "At Wed Dec 31 16:02:03 PST 1969\ntest host testservice  (17)\nTags: []\nCustom Attributes: {}\n\n"
-        default-subject-result "test host testservice"
         event {:service "testservice"
                :host "test host"
                :time 123
                :metric 17}
+        default-body-result (body [event])
+        default-subject-result "test host testservice"
         mailer (mailgun/mailgun {:sandbox sandbox
                                  :service-key service-key})
         email (mailer recipient)]


fix missing page when cycling via keyboard

--- src/cljs/meins/electron/renderer/ui/config/core.cljs
+++ src/cljs/meins/electron/renderer/ui/config/core.cljs
@@ -34,7 +34,7 @@
                                   (when (= (:highlighted @local) k) "highlight"))}
                      t])
         sections [:sagas :stories :custom-fields :habits :dashboards
-                  :metrics :sync :photos :localization :exit]
+                  :metrics :sync :photos :localization :usage :exit]
         sections (concat sections sections)
         next-item (fn [coll] (first (rest (drop-while #(not= (:highlighted @local) %) coll))))
         next-page #(swap! local assoc :highlighted (next-item sections))


Stable version.

Stable version.

--- src/clojure/test/matlab_physicloud/matlab_server.clj
+++ src/clojure/test/matlab_physicloud/matlab_server.clj
@@ -12,7 +12,9 @@
   (:gen-class))

 (defn -main
-  [ip neighbors]
+  [ip ns]
+
+  (def neighbors (load-string ns))

   (util/initialize-printer 2) ;(2) - print output to physicloud console
   (def connecting? (atom true))


Make split directory group writable

Make split directory group writable

--- src/mdr2/production.clj
+++ src/mdr2/production.clj
@@ -112,7 +112,7 @@
                (remove #{(path/recording-path production)}))]
     (fs/mkdirs dir)
     ;; make sure recording and recorded are group writable
-    (when (#{path/recorded-path path/recording-path} dir)
+    (when (#{path/recorded-path path/recording-path path/split-path} dir)
       (let [permissions (conj (nio/posix-file-permissions dir)
                               (nio/posix-file-permission :group-write))]
         (nio/set-posix-file-permissions! dir permissions)))))


allow to stop metronome via shift click

allow to stop metronome via shift click

--- src/metronome/core.cljs
+++ src/metronome/core.cljs
@@ -15,7 +15,10 @@
 (defn clock [bpm owner]
   (letfn [(start-interval [millis]
             (om/update! bpm :interval millis)
-            (om/update! bpm :next-beat nil))]
+            (om/update! bpm :next-beat nil))
+          (stop-interval []
+            (.log js/console "lol")
+            (om/update! bpm :interval nil))]
     (reify
       om/IInitState
       (init-state [_] {:mounted false})
@@ -36,7 +39,9 @@
                  (let [click-channel (om/get-state owner :click-channel)]
                    (go (loop []
                          (let [new-interval-millis (<! click-channel)]
-                           (start-interval new-interval-millis)
+                           (if (false? new-interval-millis)
+                             (stop-interval)
+                             (start-interval new-interval-millis))
                            (recur))))))
       om/IWillUnmount
       (will-unmount [_] (om/set-state! owner :mounted false))
@@ -91,7 +96,7 @@
                                               (let [m (millis)]
                                                 (om/set-state! owner :previous-click m)
                                                 (when-not (nil? previous-click)
-                                                  (put! click-channel (- m previous-click)))))}
+                                                  (put! click-channel (if (:should-stop app) false (- m previous-click))))))}
                               (if (:should-stop app) "stop" "tap tempo")))))

 (defn dots [meter owner]


make `setup-io!` work even if there's no CLJS compiler

this is useful for running the tests without having to comment the call
to `setup-io!`

--- src/main/om_css/core.clj
+++ src/main/om_css/core.clj
@@ -1,6 +1,7 @@
 (ns om-css.core
   (:require [om-css.dom :as dom]
             [cljs.analyzer.api :as ana-api]
+            [cljs.env :as env]
             [clojure.java.io :as io]
             [clojure.string :as string]
             [garden.core :as garden]))
@@ -201,7 +202,9 @@

 ;; TODO: can we make this not open the file for each atom state change?
 (defn setup-io! []
-  (let [opts (ana-api/get-options)
+  (let [opts (some-> env/*compiler*
+               deref
+               :options)
         default-fname "out.css"
         fname (or (:css-output-to opts)
                 (str (:output-dir opts) default-fname)


fixing integration test setup

fixing integration test setup

--- resources/leiningen/new/closp/integtest/clj/web/setup.clj
+++ resources/leiningen/new/closp/integtest/clj/web/setup.clj
@@ -26,7 +26,7 @@
 Your Team"
    :activation-placeholder  "{{activationlink}}"
    :smtp-data               {}                                ; passed directly to postmap like {:host "postfix"}
-   :jdbc-url                "jdbc:sqlite:./db/{{name}}.sqlite"
+   :jdbc-url                db-uri
    :env                     :dev
    :registration-allowed?   true
    :captcha-enabled?        false
@@ -47,35 +47,25 @@
 (def test-base-url (str "http://localhost:3001/"))

 (defn start-browser [browser]
-  (w/set-driver! {:browser browser}))
-
-(defn stop-browser []
-  (w/quit))
-
-(defn start-server []
   (j/migrate-db
     {:db       {:type :sql,
                 :url  db-uri}
      :migrator migrators})
+  (w/set-driver! {:browser browser}))
+
+(defn stop-browser []
+  (j/rollback-db
+    {:db       {:type :sql,
+                :url  db-uri}
+     :migrator migrators})
+  (w/quit))
+
+(defn start-server []
   (reloaded.repl/set-init! test-system)
   (go))

 (defn stop-server []
-  (stop)
-  (j/rollback-db
-    {:db       {:type :sql,
-                :url  db-uri}
-     :migrator migrators}))
-
-(defn server-setup [f]
-  (start-server)
-  (f)
-  (stop-server))
-
-(defn browser-setup [f]
-  (start-browser :htmlunit)
-  (f)
-  (stop-browser))
+  (stop))

 ;; locale stuff


change tag parser

change tag parser

--- src/misaki/template.clj
+++ src/misaki/template.clj
@@ -5,13 +5,12 @@
     [clojure.core.incubator :only [-?>]])
   (:require [clojure.string :as str]))

-; =parse-tag-option
-(defn- parse-tag-option [option]
-  (if-let [tags (-?> option :tag (str/split #"[\s,]+"))]
-    (assoc option :tag (for [tag (distinct tags)]
-                         {:name tag
-                          :url  (str "/" (make-tag-output-filename tag))}))
-    option))
+; =parse-tag
+(defn- parse-tag [tag-data]
+  (if-let [tags (and tag-data (str/split tag-data #"[\s,]+"))]
+    (for [tag (distinct tags)]
+      {:name tag
+       :url  (str "/" (make-tag-output-filename tag))})))

 ; =parse-template-options
 (defn parse-template-options
@@ -27,10 +26,9 @@
   (let [lines    (map str/trim (str/split-lines data))
         comments (filter #(= 0 (.indexOf % ";")) lines)
         params   (remove nil? (map #(re-seq #"^;+\s*@(\w+)\s+(.+)$" %) comments))
-        option   (into {} (for [[[_ k v]] params] [(keyword k) v]))]
-
-    (-> option
-        parse-tag-option)))
+        option   (into {} (for [[[_ k v]] params] [(keyword k) v]))
+        tags     (-?> option :tag parse-tag)]
+    (assoc option :tag tags)))

 ; =apply-template
 (defn apply-template


Fixed wrong indentation

Fixed wrong indentation

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

--- src/conexp/contrib/dl/languages/EL_gfp_rewriting.clj
+++ src/conexp/contrib/dl/languages/EL_gfp_rewriting.clj
@@ -104,18 +104,18 @@
     (set [dl-expression])
     (set (arguments dl-expression))))

- (defn- abbreviate-expression
-   "Abbreviates expression with given knowledge."
-   [expression knowledge]
-   (let [language            (expression-language expression),
-         implication-closure (memoize (clop-by-implications knowledge)),
-         more-specific?      more-specific?] ;hehe...
-     (binding [more-specific? #(more-specific?
-                                 %1 %2
-                                 (fn [term-1 term-2]
-                                   (contains? (implication-closure #{(make-dl-expression-nc language term-1)})
-                                              (make-dl-expression-nc language term-2))))]
-       (make-dl-expression-nc language (normalize-EL-gfp-term (expression-term expression))))))
+(defn- abbreviate-expression
+  "Abbreviates expression with given knowledge."
+  [expression knowledge]
+  (let [language            (expression-language expression),
+        implication-closure (memoize (clop-by-implications knowledge)),
+        more-specific?      more-specific?] ;hehe...
+    (binding [more-specific? #(more-specific?
+                               %1 %2
+                               (fn [term-1 term-2]
+                                 (contains? (implication-closure #{(make-dl-expression-nc language term-1)})
+                                            (make-dl-expression-nc language term-2))))]
+      (make-dl-expression-nc language (normalize-EL-gfp-term (expression-term expression))))))

 (defn abbreviate-subsumption
   "Takes a subsumption whose subsumee and subsumer are in normal form


:tada: Add missing memoization to frame wrapper on viewer.

--- frontend/src/uxbox/main/ui/viewer/thumbnails.cljs
+++ frontend/src/uxbox/main/ui/viewer/thumbnails.cljs
@@ -88,7 +88,8 @@
         width (* (:width frame) zoom)
         height (* (:height frame) zoom)
         vbox (str "0 0 " (:width frame 0) " " (:height frame 0))
-        frame-wrapper (exports/frame-wrapper objects)]
+        frame-wrapper (mf/use-memo (mf/deps objects)
+                                   #(exports/frame-wrapper objects))]

     [:svg {:view-box vbox
            :width width


Move the guts of maybe-dispatch to a fn so type-hinting works.

--- web/src/immutant/web/async.clj
+++ web/src/immutant/web/async.clj
@@ -66,14 +66,17 @@

 (def ^:dynamic ^:private *dispatched?* nil)

+(defn ^:private maybe-dispatch* [ch f]
+  (if (or *dispatched?*
+        ;; we can't do async sends under WF 8.x due to WFLY-3715
+        (and (instance? HttpChannel ch)
+          (not (.asyncSendSupported ^HttpChannel ch))))
+    (f)
+    (binding [*dispatched?* true]
+      (future (f)))))
+
 (defmacro ^:private maybe-dispatch [ch & body]
-  `(if (or *dispatched?*
-         ;; we can't do async sends under WF 8.x due to WFLY-3715
-         (and (instance? HttpChannel ~ch)
-           (not (.asyncSendSupported ^HttpChannel ~ch))))
-     (do ~@body)
-     (binding [*dispatched?* true]
-       (future ~@body))))
+  `(maybe-dispatch* ~ch (fn [] ~@body)))

 (defn ^:private finalize-channel-response
   [^Channel ch status headers]


CSS for register renders OK

CSS for register renders OK

--- src/swanson/routes/auth.clj
+++ src/swanson/routes/auth.clj
@@ -27,8 +27,7 @@

 (defn control [id label field]
   (list (vali/on-error id error-item)
-  label field
-  [:br]))
+  [:div.form-group label field]))

 (defn registration-page [& [id]]
   (layout/common


flatten only top level to avoid breaking values that are collections

--- boot/pod/src/boot/util.clj
+++ boot/pod/src/boot/util.clj
@@ -340,7 +340,7 @@
   [{:keys [project version] :as dep-map}]
   (let [kvs (remove #(or (some #{:project :version} %)
                          (= [:scope "compile"] %)) dep-map)]
-    (vec (remove nil? (into [project version] (flatten kvs))))))
+    (vec (remove nil? (into [project version] (mapcat identity kvs))))))

 (defn jarname
   "Generates a friendly name for the jar file associated with the given project


Component: modifying test for nil-returning components to fit yadic's exceptions

--- test/yadic/component_test.clj
+++ test/yadic/component_test.clj
@@ -289,9 +289,11 @@
     nil))

 (deftest component-returning-nil
+  "This test has been modified from the original to match yadic's exception behaviour"
   (let [a (->ComponentReturningNil nil)
-        s (component/system-map :a a :b (component-b))
-        e (try (component/start s)
-               false
-               (catch Exception e e))]
-    (is (= ::component/nil-component (:reason (ex-data e))))))
+        s (component/system-map :a a)]
+    (try (component/start s)
+         (is false "Expected exception")
+         (catch UnsupportedOperationException e
+           (is (= "Activator returned nil for :a" (.getMessage e)))))))
+


Use same function to get the subject.

Use same function to get the subject.

--- src/oc/email/mailer.clj
+++ src/oc/email/mailer.clj
@@ -130,13 +130,7 @@
         org-name (:org-name msg)
         daily? (= (keyword (:digest-frequency msg)) :daily)
         frequency (if daily? "Daily" "Weekly")
-        digest-email-subject (if daily?
-                              (if org-name
-                                (str "Yesterday at " org-name)
-                                (str "Yesterday in Carrot"))
-                              (if org-name
-                                (str "Last week at " org-name)
-                                (str "Last week in Carrot")))]
+        digest-email-subject (content/digest-title org-name (not daily?))]
     (try
       (spit html-file (content/digest-html msg)) ; create the email in a tmp file
       (inline-css html-file inline-file) ; inline the CSS


move config into atom

move config into atom

--- src/om_pear/core.cljs
+++ src/om_pear/core.cljs
@@ -10,6 +10,7 @@
                    :data
                    (clj->js [{:name "Bob Fleming" :address "230 Oak St., NJ USA"}
                           {:name "Rick Rearden" :address "91 Windings Way, Clement OK 28174"}])
+                   :config (clj->js {:AllowColumnResize true :ShowCellBorder true :AllowAlternateRowHighlight true})
                    }))

 (defn ^:export om-pear [app-state owner]
@@ -17,7 +18,7 @@
                       dom-ele (dom/div #js {:id "grid2"})]
                   (.setColumns g (:columns @mygrid))
                   (.setDataRows g (:data @mygrid))
-                  (.setConfiguration g #js {:AllowColumnResize true :ShowCellBorder true :AllowAlternateRowHighlight true})
+                  (.setConfiguration g (:config @mygrid) )
                   (.setWidth g 500)
                   (.setHeight g 200)
                   (.render g (. js/document (getElementById "grid2")))


Fixed adj-qty

Fixed adj-qty

--- src/tango/export2.clj
+++ src/tango/export2.clj
@@ -115,7 +115,7 @@
   (xml/parse (java.io.FileInputStream. "test/tango/examples/real-example.xml")))

 (def class-results [{:class-name "Disco Freestyle B-klass J Po"
-                     :result {:ajudicators [{:number 2}
+                     :result {:adjudicators [{:number 2}
                                             {:number 4}
                                             {:number 5}]
                               :dances [{:name "X-Quick Forward"}
@@ -179,7 +179,7 @@
                                                               (get-in class-result [:result :result-array] )
                                                               (count (:content form))
                                                               (get-dance-count-from-class-node class)
-                                                              3)
+                                                              (count  (get-in class-result [:result :adjudicators] )))
                                                              )
                                               })
         :else form))


add upvote to the fallback

add upvote to the fallback

--- src/pc/product_hunt.clj
+++ src/pc/product_hunt.clj
@@ -35,12 +35,15 @@
           "votes" [{"user"
                     {"image_url" {"30px" "http://avatars-cdn.producthunt.com/7824/30?1430236722"}}}]}
    19567 {"name" "Precursor",
-          "votes_count" 2,
+          "votes_count" 3,
           "comments_count" 1,
           "tagline" "We make prototyping and team collaboration quick and simple"
           "discussion_url" "http://www.producthunt.com/posts/precursor-for-teams"
           "makers" [{"image_url" {"30px" "http://avatars-cdn.producthunt.com/106624/30?1430244521"}}
-                    {"image_url" {"30px" "http://avatars-cdn.producthunt.com/106635/30?1430312595"}}]}})
+                    {"image_url" {"30px" "http://avatars-cdn.producthunt.com/106635/30?1430312595"}}]
+          "votes" [{"user"
+                    {"image_url" {"30px" "http://avatars-cdn.producthunt.com/2081/30?1430313498"}}}]}})
+

 (defn post-info [post-id]
   (try


Move server onto new IP

Move server onto new IP

--- src/clojure/uk/org/potentialdifference/darknet/config.clj
+++ src/clojure/uk/org/potentialdifference/darknet/config.clj
@@ -1,8 +1,8 @@
 (ns uk.org.potentialdifference.darknet.config)

-(def ip "192.168.1.24")
+(def ip "192.168.1.25")

 (def config
   {:ws-url  (str "wss://" ip ":8081")
-   :api-url (str "http://") ip ":8080"
+   :api-url (str "http://" ip ":8080")
    :api-key "x9RHJ2I6nWi376Wa"})


No need to pass inst back if no change

No need to pass inst back if no change

* Caller will do the passing back of orig instrument in this case.

--- src/playmary/one.cljs
+++ src/playmary/one.cljs
@@ -145,8 +145,7 @@
                         (-> instrument
                             (assoc :notes (conj (get instrument :notes)
                                                 {:freq freq :on time :off nil :touch-id touch-id}))
-                            (assoc-in [:piano-keys freq :on?] true)))
-                      instrument)))
+                            (assoc-in [:piano-keys freq :on?] true))))))
    "touchend" (fn
                 [{piano-keys :piano-keys :as instrument}
                  {touch-id :touch-id time :time :as event}]


small change for next release #test2

small change for next release #test2

--- src/testapp/other.clj
+++ src/testapp/other.clj
@@ -45,7 +45,7 @@
 ; take-while on processed and sorted data- makes sense. performance wise...
 ; some - when we just need to check if at least one element for the collection satisfies one condition
 ; sort and sort-by
-; small change, another change
+; small change, another change, change #3

 (reduce (fn [new-map [key val]]


Fix coloring of cash.

Fix coloring of cash.

--- src/oc/email/content.clj
+++ src/oc/email/content.clj
@@ -136,8 +136,7 @@
                                    (utils/with-currency currency (utils/with-size-label revenue))
                                    :pos))
             (when (and cash? (not revenue?)) (metric (str "Cash - " date)
-                                            (utils/with-currency currency (utils/with-size-label cash))
-                                            :pos))
+                                            (utils/with-currency currency (utils/with-size-label cash))))
             (when costs? (metric (str cost-label " - " date)
                          (utils/with-currency currency (utils/with-size-label costs))
                          :neg))


Quickie invitee instructions.

Quickie invitee instructions.

--- src/oc/email/content.clj
+++ src/oc/email/content.clj
@@ -447,6 +447,7 @@
       (when note? (paragraph note "note-paragraph"))
       (when note? (spacer 24 "note-paragraph bottom-note-paragraph" "note-paragraph"))
       (when note? (spacer 16))
+      [:p "Click here to join your team:"]
       [:a
         {:class "token-link"
          :href (:token-link invite)}


Tighten a bit the spacing above and below post attribution. Fix invite to company subject.

--- src/oc/email/content.clj
+++ src/oc/email/content.clj
@@ -47,7 +47,7 @@
 (def verify-button-text "verify_email")

 (def digest-weekly-title "Your weekly brief")
-(def digest-daily-title "Your morning brief")
+(def digest-daily-title "Your daily brief")
 (def digest-message "Here are the new posts to the %s digest.")
 (def digest-go-to-digest-button "go_to_digest")
 (def digest-read-post-button "read_post")
@@ -229,9 +229,9 @@
   [horizontal-line
    (spacer 24)
    (h2 (:headline entry))
-   (spacer 16)
+   (spacer 12)
    (post-attribution entry)
-   (spacer 16)
+   (spacer 12)
    (left-button digest-read-post-button (:url entry))
    (spacer 24)])

@@ -388,9 +388,9 @@
       horizontal-line
       (spacer 24)
       (h2 headline)
-      (spacer 16)
+      (spacer 12)
       (post-attribution entry)
-      (spacer 16)
+      (spacer 12)
       (left-button share-cta entry-url)
       (spacer 56)]))

@@ -466,7 +466,7 @@
   (let [msg (keywordize-keys invite)
         org-name (if bold? (str "<b>" (:org-name msg) "</b>") (:org-name msg))
         from (:from msg)
-        prefix (if (s/blank? from) "You've been invited" (str from " invited you"))
+        prefix (if (s/blank? from) "You've been invited" (str from " has invited you"))
         org (if (s/blank? org-name) "" (str org-name " on "))]
     (str prefix " to join " org "Carrot")))


More readable interval code

More readable interval code

--- src/tick/interval.clj
+++ src/tick/interval.clj
@@ -408,43 +408,49 @@
           ys s2
           result []]
      (if (and (not-empty xs) (not-empty ys))
-       (let [x (first xs) y (first ys)
+       (let [x (first xs)
+             y (first ys)
              code (code (relation x y))]
          (case code
            (\p \m) (recur (next xs) ys result)
            (\P \M) (recur xs (next ys) result)
-           \S (recur (cons (narrow x (t/end y) (t/end x))
-                           (next xs))
-                     (next ys)
-                     (clojure.core/conj result (narrow x (t/beginning y) (t/end y))))
-           \F (recur (next xs) (next ys) (clojure.core/conj result y))
-           \o (recur (cons (narrow x (t/beginning y) (t/end x))
-                           (next xs))
-                     (cons (narrow x (t/end x) (t/end y)) (next ys))
-                     (clojure.core/conj
-                       result
-                       (narrow x (t/beginning y) (t/end x))))
-           \O (recur (cons
-                       (narrow x (t/end y) (t/end x))
-                       (next xs))
-                     (next ys)
-                     (clojure.core/conj
-                       result
-                       (narrow x (t/beginning x) (t/end y))))
-           \D (recur (cons
-                       (narrow x (t/end y) (t/end x))
-                       (next xs))
-                     (next ys)
-                     (clojure.core/conj result (narrow x (t/beginning y) (t/end y))))
-           \d (recur (next xs) (cons (narrow x (t/end x) (t/end y))
-                                     (next ys))
-                     (clojure.core/conj result x))
-           \e (recur (next xs) (next ys) (clojure.core/conj result x))
-           \f (recur (next xs) (next ys) (clojure.core/conj result x))
-           \s (recur (next xs)
-                     (cons (narrow x (t/end x) (t/end y))
-                           (next ys))
-                     (clojure.core/conj result x))))
+           \S (recur
+                (cons (narrow x (t/end y) (t/end x)) (next xs))
+                (next ys)
+                (clojure.core/conj result (narrow x (t/beginning y) (t/end y))))
+           \F (recur
+                (next xs)
+                (next ys)
+                (clojure.core/conj result y))
+           \o (recur
+                (cons (narrow x (t/beginning y) (t/end x)) (next xs))
+                (cons (narrow y (t/end x) (t/end y)) (next ys))
+                (clojure.core/conj result (narrow x (t/beginning y) (t/end x))))
+           \O (recur
+                (cons (narrow x (t/end y) (t/end x)) (next xs))
+                (next ys)
+                (clojure.core/conj result (narrow x (t/beginning x) (t/end y))))
+           \D (recur
+                (cons (narrow x (t/end y) (t/end x)) (next xs))
+                (next ys)
+                (clojure.core/conj result (narrow x (t/beginning y) (t/end y))))
+           \d (recur
+                (next xs)
+                (cons (narrow y (t/end x) (t/end y)) (next ys))
+                (clojure.core/conj result x))
+           \e (recur
+                (next xs)
+                (next ys)
+                (clojure.core/conj result x))
+           \f (recur
+                (next xs)
+                (next ys)
+                (clojure.core/conj result x))
+           \s (recur
+                (next xs)
+                (cons (narrow y (t/end x) (t/end y))
+                      (next ys))
+                (clojure.core/conj result x))))
        result)))
   ([s1 s2 & sets]
    (reduce intersection s1 (clojure.core/conj sets s2))))


Restored interlace detection

Restored interlace detection

--- src/video_server/ffmpeg.clj
+++ src/video_server/ffmpeg.clj
@@ -30,7 +30,7 @@
                            "-t" 120 "-an" "-sn" "-vf" "idet" "/dev/null"))]
     (when-let [frames (re-find #"Multi frame detection:.*" output)]
       (let [[top bottom prog und] (parse-ints frames)]
-        #_(> (+ top bottom) (/ (+ top bottom prog und) 10))))))
+        (> (+ top bottom) (/ (+ top bottom prog und) 10))))))

 (defn detect-crop
   "Performs crop detection, returning the filter argument or nil."


action creator accepts get-store fn not current state

--- src/rex/dispatch.cljs
+++ src/rex/dispatch.cljs
@@ -81,7 +81,7 @@
                                    get-subscribers
                                    deref-state-by-cursor)]
     (let [event (action-creator (partial dispatch-event-fn cursor)
-                                (get-store)
+                                get-store
                                 cursor)]
       (if (nil? event)
         (get-store)


Use non-blocking put! for game save

Use non-blocking put! for game save

--- src/robinson/main.clj
+++ src/robinson/main.clj
@@ -65,7 +65,7 @@
     (recur)))

 (defn save-state [state]
-  (async/>!! save-chan state))
+  (async/put! save-chan state))

 (defn render-state [state]
   (async/>!! render-chan state))


use hiccup-like syntax

use hiccup-like syntax

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

--- plugins/SlideExplorer2/src/slide_explorer/canvas.clj
+++ plugins/SlideExplorer2/src/slide_explorer/canvas.clj
@@ -176,11 +176,11 @@

 (defn draw-primitives [g2d items]
   (enable-anti-aliasing g2d)
-  (dorun
-    (for [item (flatten items)]
-      (let [params (:params item)]
-      (set-style g2d params)
-      (draw-primitive g2d (:type item) (complete-coordinates params))))))
+  (doseq [[type params inner] items]
+    (println type params inner)
+    (set-style g2d params)
+    (draw-primitive g2d type (complete-coordinates params))
+    ))

 (defn paint-canvas-graphics [^Graphics graphics data]
   (draw-primitives graphics data))
@@ -196,23 +196,45 @@

 ;; test

-(def temp-data
+(def grafix (atom nil))
+
+(defn canvas-frame [reference]
+  (let [panel (canvas reference)]
+    (doto (JFrame. "canvas")
+      (.. getContentPane (add panel))
+      (.setBounds 10 10 500 500)
+      .show)
+    panel))
+
+(defn demo-atom []
+  (canvas-frame grafix))
+
+(defn demo-animation [reference]
+  (dotimes [i 200]
+  (Thread/sleep 30)
+  (swap! reference (fn [data]
+                     (-> data
+                         (assoc-in [0 :params :w] (+ i 100))
+                         (assoc-in [0 :params :h] (+ i 100)))
+                     ))))
+
+(reset! grafix
   [
-   {:type :primitive-round-rect
-    :params {:l 20 :t 10 :w 140 :h 140
-             :arc-radius 20
-             :filled true :color Color/RED}}
-   {:type :primitive-ellipse
-    :params {:l 25 :t 15 :w 110 :h 90
-             :filled true :color Color/YELLOW}}
-   {:type :primitive-round-rect
-    :params {:x 90 :y 80 :r 160 :b 150
-             :arc-width 20 :arc-height 20
+   [:primitive-round-rect
+    {:l 20 :t 10 :w 300 :h 300
+             :arc-radius 50
+             :filled true :color Color/PINK}]
+   [:primitive-ellipse
+    {:l 25 :t 15 :w 110 :h 90
+             :filled true :color Color/YELLOW}]
+   [:primitive-round-rect
+    {:l 20 :t 10 :w 300 :h 300
+             :arc-width 50 :arc-height 50
              :filled false :color Color/DARK_GRAY
              :stroke {:width 5
-                      :dashes [10 10]}}}
-   {:type :primitive-polygon
-    :params {:vertices [{:x 100 :y 100}
+                      :dashes [10 10] :dash-phase 0}}]
+   [:primitive-polygon
+    {:vertices [{:x 100 :y 100}
                         {:x 50 :y 150}
                         {:x 50 :y 220}
                         {:x 160 :y 250}]
@@ -224,9 +246,9 @@
                       :dashes [20 3 10 3 5 3]
                       :cap :butt
                       :join :bevel
-                      :miter-limit 10.0}}}
-   {:type :primitive-text
-    :params {:x 180 :y 120 :text "TEST"
+                      :miter-limit 10.0}}]
+   [:primitive-text
+    {:x 180 :y 120 :text "TEST"
              :color Color/BLUE
              :alpha 0.5
              :font {:name "Arial"
@@ -234,43 +256,20 @@
                     :italic false
                     :underline true
                     :strikethrough false
-                    :size 100}}}
-   {:type :primitive-line
-    :params {:x 180 :y 120 :w 0 :h 150 :color Color/RED
+                    :size 100}}]
+   [:primitive-line
+    {:x 180 :y 120 :w 0 :h 150 :color Color/RED
              :stroke {:width 10 :cap :round}
-             :alpha 0.7}}
-   {:type :primitive-line
-    :params {:x 180 :y 120 :w 30 :h 0 :color Color/GREEN
+             :alpha 0.7}]
+   [:primitive-line
+    {:x 180 :y 120 :w 30 :h 0 :color Color/GREEN
              :alpha 0.6
-             :stroke {:width 4}}}
-   {:type :primitive-arc
-    :params {:l 40 :t 30 :w 100 :h 100
-             :start-angle 10 :arc-angle 100 :color Color/GREEN
-             :filled true}}
+             :stroke {:width 4}}]
+   [:primitive-arc
+    {:l 60 :t 30 :w 100 :h 100
+             :start-angle 30 :arc-angle 100 :color Color/GREEN
+             :filled true
+             :alpha 0.7}]
    ])

-(def grafix (atom temp-data))
-
-(defn canvas-frame [reference]
-  (let [panel (canvas reference)]
-    (doto (JFrame. "canvas")
-      (.. getContentPane (add panel))
-      (.setBounds 10 10 500 500)
-      .show)
-    panel))
-
-(defn demo-var []
-  (canvas-frame (var temp-data)))
-
-(defn demo-atom []
-  (canvas-frame grafix))
-
-(defn demo-animation [reference]
-  (dotimes [i 200]
-  (Thread/sleep 30)
-  (swap! reference (fn [data]
-                     (-> data
-                         (assoc-in [0 :params :w] (+ i 100))
-                         (assoc-in [0 :params :h] (+ i 100)))
-                     ))))
-
+


(TK-202) Add test cases for the context clear test

This commit updates the test-context-cleared-on-restart test to include
some additional state and assertions as suggested by cprice. This
includes validating that the context is cleared after a restart and that
init is called twice during the test lifetime.

--- test/puppetlabs/trapperkeeper/services_test.clj
+++ test/puppetlabs/trapperkeeper/services_test.clj
@@ -173,15 +173,28 @@

 (deftest test-context-cleared-on-restart
   (testing "service contexts should be cleared out during a restart"
-    (let [test-context (atom {})
+    (let [test-init-context (atom nil)
+          test-init-count (atom 0)
+          test-start-context (atom nil)
+          context-elem  {:foo "bar"}
           service1 (service EmptyService
                      []
                      (init [this context]
-                           (swap! test-context merge context)
-                           {:foo "bar"}))]
+                           (reset! test-init-context (merge context context-elem))
+                           (swap! test-init-count inc)
+                           {:context @test-init-context :count @test-init-count})
+                     (start [this context]
+                            (reset! test-start-context context)))]
       (with-app-with-empty-config app [service1]
+        (is (= context-elem @test-init-context))
+        (is (= {:foo "bar"} (:context @test-start-context)))
+        (is (= 1 (:count @test-start-context)))
+        (swap! test-init-context dissoc :context)
+        (swap! test-start-context dissoc :context)
         (app/restart app))
-      (is (= {} @test-context)))))
+      (is (= {:foo "bar"} @test-init-context))
+      (is (= {:foo "bar"} (:context @test-start-context)))
+      (is (= 2 (:count @test-start-context))))))

 (deftest test-exception-during-restart
   (testing "restart should halt if an exception is raised"


fix occurence of nil being placed on channel

--- src/server/rabbit.clj
+++ src/server/rabbit.clj
@@ -30,9 +30,10 @@
       (lq/bind ch qname "touchvision" {:routing-key "glove"})
       (lc/subscribe ch qname (partial message-cb capture-in) {:auto-ack true})
       (go-loop [[m ch] (alts! [capture-in stdin])]
-               (cond
-                 (= ch capture-in) (put! out m)
-                 (= ch stdin) (log/fatal m))
+               (when m
+                 (cond
+                   (= ch capture-in) (put! out m)
+                   (= ch stdin) (log/fatal m)))
                (recur (alts! [capture-in stdin])))
       (-> this
           (assoc :out out)


Add save uploading

Add save uploading

--- src/robinson/update.clj
+++ src/robinson/update.clj
@@ -2596,10 +2596,15 @@
               ((fn [state]
                  ;; if UPLOADVERSION file is present, upload save/world.edn as json to aaron-santos.com:8888/upload
                  (when (.exists (io/file "config/.feedbackparticipant"))
+                   (when (not (.exists (io/file "config/.userid")))
+                     (spit "config/.userid" (doto (java.util.UUID/randomUUID)
+                                                  (.toString))))
                    (let [version (slurp "VERSION")
+                         userid  (slurp "config/.userid")
+                         url     (format "https://aaron-santos.com:3000/saves/%s" userid)
                          body    (json/write-str (-> (get state :world)
-                                                   (assoc :version version)))]
-                     (http/post "http://aaron-santos.com:3000/robinson/worlds"
+                                                     (assoc :version version)))]
+                     (http/post url
                        {:body body
                         :content-type :json})))
                  (doseq [file (filter (fn [file] (re-matches #".*edn" (.getName file))) (file-seq (io/file "save")))]


fix(release)

fix(release)

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


Add future-fact for error message

Add future-fact for error message

--- test/structural_typing/use/f_error_messages.clj
+++ test/structural_typing/use/f_error_messages.clj
@@ -8,6 +8,9 @@

 (future-fact "There should be an error if there's an instance of `includes` in a path")

+(future-fact "error out if you use `requires` on the right-hand side"
+  (type! :Line {(each-of :head :tail) (requires :x :y)})
+  )

 (future-fact "reject impossible condensed type descriptions"


[CS] Remove errant parens

[CS] Remove errant parens

--- test/vip/data_processor/validation/csv_test.clj
+++ test/vip/data_processor/validation/csv_test.clj
@@ -78,7 +78,6 @@
 (deftest missing-files-test
   (testing "reports errors or warnings when certain files are missing"
     (let [ctx {:input [(io/as-file (io/resource "source.txt"))]}
-          ()
           out-ctx (-> ctx
                       ((error-on-missing-file "election.txt"))
                       ((error-on-missing-file "source.txt"))


Some work on secretbox nmr

Some work on secretbox nmr

--- src/caesium/magicnonce/secretbox.clj
+++ src/caesium/magicnonce/secretbox.clj
@@ -15,10 +15,23 @@
   (:require [caesium.crypto.generichash :as g]
             [caesium.crypto.secretbox :as s]
             [caesium.randombytes :as r]
-            [caesium.byte-bufs :as bb])
+            [caesium.byte-bufs :as bb]
+            [caesium.util :as u]
+            [taoensso.timbre :refer [spy info]])
   (:import (java.nio ByteBuffer)))

 (def keybytes s/keybytes)
+
+(defn secretbox-pfx-to-buf!
+  "Like [[secretbox-pfx]], but you manage the output buffer. See that fn for
+  details.
+
+  All buffers must be `java.nio.ByteBuffer`.
+
+  Buffer `c` must be of length of `m` + [[s/noncebytes]] + [[s/macbytes]]."
+  [^ByteBuffer c ^ByteBuffer m ^ByteBuffer n ^ByteBuffer k]
+  (.put c n)
+  (s/secretbox-easy-to-buf! c m n k))

 (defn secretbox-pfx
   "secretbox, with the given nonce embedded in the ciphertext as a prefix.
@@ -37,13 +50,13 @@
   To decrypt, use [[decrypt]] or [[open]], depending on which argument order
   you prefer."
   [m n k]
-  (let [mlen (bb/buflen m)
-        clen (+ s/macbytes mlen)
-        outlen (+ s/noncebytes clen)
-        out (byte-array outlen)
-        cbuf (ByteBuffer/wrap out s/noncebytes clen)]
-    (System/arraycopy n 0 out 0 s/noncebytes)
-    (s/secretbox-easy-to-buf! cbuf m n k)
+  (let [outlen (+ s/noncebytes (bb/buflen m) s/macbytes)
+        out (byte-array outlen)]
+    (secretbox-pfx-to-buf!
+     (ByteBuffer/wrap out)
+     (bb/->indirect-byte-buf m)
+     (bb/->indirect-byte-buf n)
+     (bb/->indirect-byte-buf k))
     out))

 (defn ^:private random-nonce!
@@ -146,20 +159,29 @@
 (defn open-to-buf!
   "Decrypts any secretbox message with a prefix nonce into the given buffer.

+  This splits the given ciphertext buffer into the nonce and the
+  resulting ciphertext and then defers to [[s/secretbox-open-easy-to-buf!]].
+
+  All arguments must be `java.nio.ByteBuffer`.
+
   Analogous to [[caesium.crypto.secretbox/secretbox-open-easy-to-buf!]]."
-  [^bytes out ^bytes nonced-ctext ^bytes key]
-  (let [noncebuf (ByteBuffer/wrap nonced-ctext 0 s/noncebytes)
-        ctextlen (- (buflen nonced-ctext) s/noncebytes)
-        ctextbuf (ByteBuffer/wrap nonced-ctext s/noncebytes ctextlen)]
-    (s/secretbox-open-easy-from-byte-bufs! out ctextbuf ctextlen noncebuf key)))
+  [m ^ByteBuffer c k]
+  (info "c before dup" c)
+  (info "c contents" (u/hexify (bb/->bytes c)))
+  (let [n (-> c (.duplicate) (.limit s/noncebytes))
+        c (-> c (.duplicate) (.position s/noncebytes))]
+    (spy (u/hexify (bb/->bytes n)))
+    (spy (u/hexify (bb/->bytes c)))
+    (s/secretbox-open-easy-to-buf! m (spy c) (spy n) k)))

 (defn open
   "Decrypts any secretbox message with a prefix nonce.

   Analogous to [[caesium.crypto.secretbox/secretbox-open-easy]]."
-  [^bytes nonced-ctext ^bytes key]
-  (let [out (byte-array (- (buflen nonced-ctext) s/noncebytes s/macbytes))]
-    (open-to-buf! out nonced-ctext key)))
+  [c k]
+  (let [m (bb/alloc (- (bb/buflen c) s/noncebytes s/macbytes))]
+    (open-to-buf! m (bb/->indirect-byte-buf c) (bb/->indirect-byte-buf k))
+    (bb/->bytes m)))

 (defn decrypt-to-buf!
   "Like [[open-to-buf!]], but with different argument order."


Comment code on src/user.clj.

Comment code on src/user.clj.

Because it raises class not found exception on first run, when
java clases are not compiled.

--- src/user.clj
+++ src/user.clj
@@ -1,23 +1,23 @@
 (ns user
   (:require [clojure.tools.namespace.repl :refer (refresh)]
-            [clojure.test :as test]
-            [catacumba.core :as ct]))
+            [clojure.test :as test]))
+;; [catacumba.core :as ct]))

-(defn test-ns
-  ([]
-   (refresh)
-   (test/run-tests
-    'catacumba.core-tests
-    'catacumba.sse-tests
-    'catacumba.ring-tests
-    'catacumba.handlers-tests
-    'catacumba.websocket-tests
-    ))
-  ([& namespaces]
-   (refresh)
-   (apply test/run-tests namespaces)))
+;; (defn test-ns
+;;   ([]
+;;    (refresh)
+;;    (test/run-tests
+;;     'catacumba.core-tests
+;;     'catacumba.sse-tests
+;;     'catacumba.ring-tests
+;;     'catacumba.handlers-tests
+;;     'catacumba.websocket-tests
+;;     ))
+;;   ([& namespaces]
+;;    (refresh)
+;;    (apply test/run-tests namespaces)))

-(defn test-vars
-  [& vars]
-  (refresh)
-  (test/test-vars vars))
+;; (defn test-vars
+;;   [& vars]
+;;   (refresh)
+;;   (test/test-vars vars))


rev comments

rev comments


somehow missed this

somehow missed this

--- src/rwn4clojure/core.clj
+++ src/rwn4clojure/core.clj
@@ -2,7 +2,7 @@
   (:require [clojure.test :refer :all]))

 (defn test-all []
-  (t/run-tests *ns*))
+  (run-tests *ns*))

 (def all? (partial every? true?))


Put res on admin page

Put res on admin page

--- src/cljs-admin/sbsk_admin/views.cljs
+++ src/cljs-admin/sbsk_admin/views.cljs
@@ -175,7 +175,8 @@
 (defn thumb-control
   [video]
   (let [meta-thumb (get-in video [:meta :thumb])
-        uploading? (and meta-thumb (clojure.string/starts-with? meta-thumb "data:"))]
+        uploading? (and meta-thumb (clojure.string/starts-with? meta-thumb "data:"))
+        xfactor 3.334]
     [re-com/v-box
      :children
      [[re-com/title
@@ -191,7 +192,7 @@
           [:div
            {:style {:position :relative}}
            [:img {:src (or meta-thumb
-                           (str "http://placehold.it/" video-large-width "x" video-large-height))
+                           (str "http://placehold.it/" (* video-large-width xfactor) "x" (* video-large-height xfactor)))
                   :width video-large-width
                   :height video-large-height}]
            (when uploading?


[REFACTOR] Use `TIMETABLE` row vector as function

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

--- src/cljs/cljs_nusmods/timetable.cljs
+++ src/cljs/cljs_nusmods/timetable.cljs
@@ -499,13 +499,13 @@
 ; First argument is a 0-indexed integer of the day
 (defmethod timetable-get-day-row true
   [day rowNum]
-  (nth (timetable-get-day day) rowNum))
+  ((timetable-get-day day) rowNum))

 ; First argument is a day in `TIMETABLE` - the return value of
 ; `timetable-get-day` function
 (defmethod timetable-get-day-row false
   [ttDay rowNum]
-  (nth ttDay rowNum))
+  (ttDay rowNum))

 ; Returns the total number of rows for a given day in the Timetable.
 (defmulti timetable-day-get-nr-rows number? :default true)


draggable stop - Remove unnecessary setting of cursor on helper

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

--- src/cljs/cljs_nusmods/timetable.cljs
+++ src/cljs/cljs_nusmods/timetable.cljs
@@ -659,7 +659,6 @@

       (timetable-prune-empty-rows affectedDaysSet)
       (set! Lessons-Created-By-Draggable nil)
-      (.css $helper "cursor" "grab")

       ; User has dropped the draggable helper <div> onto a droppable
       (if (not (nil? destLessonGroup))


more concise stats string

more concise stats string

--- src/cljs/iwaswhere_web/ui/stats.cljs
+++ src/cljs/iwaswhere_web/ui/stats.cljs
@@ -29,15 +29,15 @@
           (count (:hashtags @options)) " hashtags, "
           (count (:mentions @options)) " people, "
           (:open-tasks-cnt @stats) " open tasks, "
-          (:started-tasks-cnt @stats) " started tasks, "
-          (:due-tasks-cnt @stats) " due tasks, "
-          (:backlog-cnt @stats) " in backlog, "
+          (:started-tasks-cnt @stats) " started, "
+          (:due-tasks-cnt @stats) " due, "
+          (:backlog-cnt @stats) " backlog, "
           (:completed-cnt @stats) " completed, "
           (:closed-cnt @stats) " closed, "
-          (:open-habits-cnt @stats) " habits - "
+          (:open-habits-cnt @stats) " habits, "
           (:waiting-habits-cnt @stats) " waiting, "
           (:import-cnt @stats) " tagged #import, "
-          (:new-cnt @stats) " tagged #new."])
+          (:new-cnt @stats) " #new."])
        (when-let [ms (:query @timing)]
          [:div
           (str "Query with " (:count @timing)