AW | 395 | @id no longer recognised as an activity key

--- test/mooncake/test/view/feed.clj
+++ test/mooncake/test/view/feed.clj
@@ -58,27 +58,27 @@
                               (keyword "@context") "http://www.w3.org/ns/activitystreams"
                               :type                "Create"
                               :published           ten-minutes-ago-iso
-                              :actor               {:type        "Person"
+                              :actor               {:type "Person"
                                                     :name "JDog"}
-                              :object              {:type        "Objective"
-                                                    :name "OBJECTIVE 7 TITLE"
-                                                    :content     "We want to establish Activity Types for Objective8"
-                                                    :url         "http://objective8.dcentproject.eu/objectives/7"}
+                              :object              {:type    "Objective"
+                                                    :name    "OBJECTIVE 7 TITLE"
+                                                    :content "We want to establish Activity Types for Objective8"
+                                                    :url     "http://objective8.dcentproject.eu/objectives/7"}
                               :relInsertTime       "6"}
                              {:activity-src        "a-helsinki-activity-src"
                               (keyword "@context") "http://www.w3.org/ns/activitystreams"
                               :type                "Add"
                               :published           "2015-09-06T11:05:53.002Z"
-                              :actor               {:type           "Group"
-                                                    :name    "Kaupunginjohtaja/J"
-                                                    (keyword "@id") "http://dev.hel.fi/paatokset/v1/policymaker/50/"}
-                              :object              {(keyword "@id") "http://dev.hel.fi/paatokset/v1/agenda_item/52359/"
+                              :actor               {:type "Group"
+                                                    :name "Kaupunginjohtaja/J"
+                                                    :id   "http://dev.hel.fi/paatokset/v1/policymaker/50/"}
+                              :object              {:id      "http://dev.hel.fi/paatokset/v1/agenda_item/52359/"
                                                     :name    "Ymp\u00e4rist\u00f6raportoinnin asiantuntijaty\u00f6ryhm\u00e4n asettaminen toimikaudeksi 2015\u20132020"
-                                                    :type           "Content"
-                                                    :url            "http://dev.hel.fi/paatokset/asia/hel-2015-005343/11010vh1j-2015-25/"
-                                                    :content        "some Finnish HTML"}
-                              :target              {:name "Ymp\u00e4rist\u00f6raportoinnin asiantuntijaty\u00f6ryhm\u00e4n asettaminen toimikaudeksi 2015\u20132020"
-                                                    :content     "some Finnish HTML"}
+                                                    :type    "Content"
+                                                    :url     "http://dev.hel.fi/paatokset/asia/hel-2015-005343/11010vh1j-2015-25/"
+                                                    :content "some Finnish HTML"}
+                              :target              {:name    "Ymp\u00e4rist\u00f6raportoinnin asiantuntijaty\u00f6ryhm\u00e4n asettaminen toimikaudeksi 2015\u20132020"
+                                                    :content "some Finnish HTML"}
                               :relInsertTime       "9"}
                              {:activity-src        "another-objective8-activity-src"
                               (keyword "@context") "http://www.w3.org/ns/activitystreams"
@@ -129,16 +129,16 @@
 (fact "activity action text varies depending on existence of target"
       (let [page (fv/feed {:context {:activities
                                      [{:type   "Question"
-                                       :object {:type        "Objective Question"
+                                       :object {:type "Objective Question"
                                                 :name "QUESTION 6 TITLE"
-                                                :url         "http://objective8.dcentproject.eu/objectives/6/questions/23"}}
+                                                :url  "http://objective8.dcentproject.eu/objectives/6/questions/23"}}
                                       {:type   "Question"
-                                       :object {:type        "Objective Question"
+                                       :object {:type "Objective Question"
                                                 :name "QUESTION 7 TITLE"
-                                                :url         "http://objective8.dcentproject.eu/objectives/7/questions/23"}
-                                       :target {:type        "Objective"
+                                                :url  "http://objective8.dcentproject.eu/objectives/7/questions/23"}
+                                       :target {:type "Objective"
                                                 :name "OBJECTIVE 7 TITLE OBJECTIVE 7 TITLE OBJECTIVE 7 TITLE OBJECTIVE 7 TITLE OBJECTIVE 7 TITLE"
-                                                :url         "http://objective8.dcentproject.eu/objectives/7"}}]}})
+                                                :url  "http://objective8.dcentproject.eu/objectives/7"}}]}})
             [activity-without-target activity-with-target] (html/select page [:.clj--activity-item])]
         activity-with-target => (eh/text-is? [:.clj--activity-item__target] "OBJECTIVE 7 TITLE OBJECTIVE 7 TITLE…")
         activity-with-target => (eh/has-attr? [:.activity-item__action__target html/last-child] :href "http://objective8.dcentproject.eu/objectives/7")
@@ -151,13 +151,13 @@
 (fact "activity item avatars are given the initial of the actor (the name of the person)"
       (let [page (fv/feed {:context {:activities
                                      [{:activity-src "an-activity-src"
-                                       :actor        {:type        "Person"
+                                       :actor        {:type "Person"
                                                       :name "abby"}}
                                       {:activity-src "an-activity-src"
-                                       :actor        {:type        "Person"
+                                       :actor        {:type "Person"
                                                       :name "Bobby"}}
                                       {:activity-src "an-activity-src"
-                                       :actor        {:type        "Person"
+                                       :actor        {:type "Person"
                                                       :name "2k12carlos"}}]}})
             initials-elements (-> (html/select page [:.clj--avatar__initials]))]
         (html/text (first initials-elements)) => "A"


use file-defined mask-populate-errors to control generation exception handling

--- src/babel/writer.clj
+++ src/babel/writer.clj
@@ -496,10 +496,11 @@
                                                           ;; subject), but we're trying to generate with
                                                           ;; {:agr {:person :1st or :2nd}}, for which the only lexemes
                                                           ;; are human.
+
+                                                          (= true mask-populate-errors)
+                                                          (log/warn (str "ignoring exception: " e))
+
                                                           true
-
-                                                          (log/warn (str "ignoring exception: " e))
-                                                          false
                                                           (throw e))))
                                                     ))
                                                 numbers


Fix tests

Fix tests

--- src/clojure/clojurewerkz/cassaforte/embedded.clj
+++ src/clojure/clojurewerkz/cassaforte/embedded.clj
@@ -15,7 +15,7 @@
 Raise an exception if any deletion fails unless silently is true."
   [f & [silently]]
   (let [f (io/file f)]
-    (if (and (.isDirectory f) (.exists f))
+    (if (.isDirectory f)
       (doseq [child (.listFiles f)]
         (delete-file-recursively child silently)))
     (delete-file f silently)))
@@ -31,7 +31,8 @@
   (System/setProperty "log4j.appender.R.File" "/var/log/cassandra/system.log")

   (when-not (bound? (var daemon))
-    (delete-file-recursively "tmp")
+    (if (.exists (io/file "tmp"))
+      (delete-file-recursively "tmp"))
     (def daemon (let [d (CassandraDaemon.)]
                   (.init d nil)
                   (.start d)


Handle provenance on ingestion.

Handle provenance on ingestion.

--- src/com/lemondronor/orbital_detector/reports.clj
+++ src/com/lemondronor/orbital_detector/reports.clj
@@ -15,7 +15,8 @@

 (gflags/define-integer "time-window-secs"
   1
-  "Only 1 ping will be recorded for each aircraft during each interval of this long.")
+  (str "Only 1 ping will be recorded for each aircraft during each interval of"
+       " the specified length."))

 (gflags/define-boolean "with-position-only"
   false
@@ -40,7 +41,7 @@
             (zero? (:lon r)))))

-(defn log-record-to-db-record [r]
+(defn log-record-to-db-record [r provenance]
   (let [db-rec
         {:timestamp (sql-str (timefmt/unparse db-timestamp-formatter (:timestamp r)))
          :icao (sql-str (:icao r))
@@ -48,7 +49,8 @@
          :altitude (:altitude r)
          :speed (:speed r)
          :heading (:heading r)
-         :squawk (sql-str (:squawk r))}]
+         :squawk (sql-str (:squawk r))
+         :provenance (if (= :provenance :mlat) 2 1)}]
     (if (has-position? r)
       (assoc db-rec
              :lat (:lat r)
@@ -119,7 +121,7 @@
                      (update-in num-skipped [:rate-too-high] inc))
               :else
               (do
-                (insert! t-con :reports (log-record-to-db-record r))
+                (insert! t-con :reports (log-record-to-db-record r :basestation))
                 (recur rstrecords
                        (assoc previous-ping-time icao ping-ts)
                        (inc num-inserted)


Add static type declarations.

Add static type declarations.


fix accidental text formatting on try-gravity

--- src/client/core.cljs
+++ src/client/core.cljs
@@ -200,7 +200,11 @@
     (if-let [collapse-anim (go-go-collapse!)]
       (go (<! collapse-anim) (try-spawn-piece!))
       (try-spawn-piece!))))
-(defn try-gravity!  "Move current piece down 1 if possible, else lock the piece." [] (let [piece (:piece @state)
+
+(defn try-gravity!
+  "Move current piece down 1 if possible, else lock the piece."
+  []
+  (let [piece (:piece @state)
         [x y] (:position @state)
         board (:board @state)
         ny (inc y)]


Styling for when tag list needs to scroll

--- src/braid/core/client/ui/styles/thread.cljs
+++ src/braid/core/client/ui/styles/thread.cljs
@@ -317,11 +317,14 @@

    [:>.search-results
     {:display "flex"
-     :flex-direction "row"}
+     :flex-direction "row"
+     :flex-grow "2"
+     :min-height "0px"}

     [:>.tag-list
      :>.user-list
-     {:flex-grow "1"}
+     {:flex-grow "1"
+      :overflow-y "scroll"}

      [:>.tag-option
       :>.user-option


Darken card shadow

Darken card shadow

--- src/braid/core/client/ui/styles/thread.cljs
+++ src/braid/core/client/ui/styles/thread.cljs
@@ -149,7 +149,7 @@
    [:>.card
     mixins/flex
     {:flex-direction "column"
-     :box-shadow [[0 (px 1) (px 2) 0 "#ccc"]]
+     :box-shadow [[0 (px 1) (px 3) 0 "#bbb"]]
      :transition [["box-shadow" "0.2s"]]
      :max-height "100%"
      :background "white"


Use a lazy sequence of flat maps

Use a lazy sequence of flat maps

--- src/cljam/io/wig.clj
+++ src/cljam/io/wig.clj
@@ -42,6 +42,8 @@
   [f]
   (WIGWriter. (cio/writer (util/compressor-output-stream f)) (util/as-url f)))

+(def ^:const wig-fields [:format :chrom :start :end :value])
+
 (defn- header-or-comment?
   "Checks if given string is neither a header nor a comment line."
   [^String s]
@@ -73,84 +75,90 @@
     (as-double s)))

 (defn- deserialize-wigs
-  "Parse WIG lines and returns a vector of maps."
+  "Parse WIG lines and return a lazy sequence of flat map."
   [lines]
-  (loop [lines lines
-         wigs []
-         current-track nil]
-    (if (nil? (first lines))
-      (conj wigs current-track)
-      (let [fields (-> lines first cstr/trim (cstr/split #"\s+"))]
-        (case (first fields)
-          ; declaration line of variableStep
-          "variableStep"
-          (let [{:keys [chrom span] :or {span 1}} (->> fields rest fields->map)]
-            (recur (rest lines)
-                   (cond-> wigs
-                     (some? current-track) (conj current-track))
-                   {:format :variable-step
-                    :chrom chrom
-                    :span (as-long span)
-                    :values []}))
+  (letfn [(deserialize [lines current-track]
+            (lazy-seq
+             (when (some? (first lines))
+               (let [fields (-> lines first cstr/trim (cstr/split #"\s+"))]
+                 (case (first fields)
+                   ; declaration line of variableStep
+                   "variableStep"
+                   (let [{:keys [chrom span] :or {span 1}} (->> fields rest fields->map)
+                         span (as-long span)]
+                     (deserialize (rest lines) {:format :variable-step, :chrom chrom, :pre-start nil, :span span, :step nil}))

-          ; declaration line of fixedStep
-          "fixedStep"
-          (let [{:keys [chrom start step span] :or {span 1}} (->> fields rest fields->map)]
-            (recur (rest lines)
-                   (cond-> wigs
-                     (some? current-track) (conj current-track))
-                   {:format :fixed-step
-                    :chrom chrom
-                    :start (as-long start)
-                    :step (as-long step)
-                    :span (as-long span)
-                    :values []}))
+                   ; declaration line of fixedStep
+                   "fixedStep"
+                   (let [{:keys [chrom start span step] :or {span 1, step 1}} (->> fields rest fields->map)
+                         step (as-long step)
+                         pre-start (- (as-long start) step)
+                         span (as-long span)]
+                     (deserialize (rest lines) {:format :fixed-step, :chrom chrom, :pre-start pre-start, :span span, :step step}))

-          ; data line
-          (let [v (case (:format current-track)
-                    :variable-step
-                    (let [[start value] fields]
-                      {:start (as-long start)
-                       :value (str->wiggle-track-data value)})
+                   ; data line
+                   (let [m (case (:format current-track)
+                             :variable-step
+                             (let [{:keys [chrom span]} current-track
+                                   [start value] fields
+                                   start (as-long start)
+                                   end (dec (+ start span))
+                                   value (str->wiggle-track-data value)]
+                               {:format :variable-step, :chrom chrom, :start start, :end end, :value value})

-                    :fixed-step
-                    (-> fields first str->wiggle-track-data)
+                             :fixed-step
+                             (let [{:keys [chrom pre-start span step]} current-track
+                                   start (+ pre-start step)
+                                   end (dec (+ start span))
+                                   value (-> fields first str->wiggle-track-data)]
+                               {:format :fixed-step, :chrom chrom, :start start, :end end, :value value})

-                    (throw (IllegalArgumentException. "Invalid wiggle format")))]
-            (recur (rest lines)
-                   wigs
-                   (update current-track :values conj v))))))))
+                             (throw (IllegalArgumentException. "Invalid wiggle format")))]
+                     (cons m (deserialize (rest lines)
+                                          (update current-track :pre-start (fn [_] (:start m)))))))))))]
+    (deserialize lines {:format nil, :chrom nil, :pre-start nil, :span nil :step nil})))

-(defn- serialize-wig
-  "Serialize WIG fields into string."
-  [wig]
-  {:pre [;; There are two options for formatting wiggle data.
-         (or (= (:format wig) :fixed-step) (= (:format wig) :variable-step))
-         ;; These fields are required if the format is fixedStep.
-         (if (= (:format wig) :fixed-step) (and (:chrom wig) (:span wig) (:start wig) (:step wig) (:values wig)) true)
-         ;; These fields are required if the format is variableStep.
-         (if (= (:format wig) :variable-step) (and (:chrom wig) (:span wig) (:values wig)) true)]}
-  (case (:format wig)
-    :variable-step
-    (let [{:keys [chrom span values]} wig
-          declaration-line (->> (cond-> ["variableStep" (str "chrom=" chrom)]
-                                  (not= span 1) (conj (str "span=" span)))
-                                (cstr/join \space))
-          data-lines (->> values
-                          (map (fn [{:keys [start value]}]
-                                 (cstr/join \space [start value])))
-                          (cstr/join \newline))]
-      (cstr/join \newline [declaration-line data-lines]))
+(defn- serialize-wigs
+  "Serialize a sequence of WIG fields into a lazy sequence of string."
+  [wigs]
+  {:pre [;; These fields are required.
+         (map (fn [wig] (every? some? ((apply juxt wig-fields) wig))) wigs)
+         ;; There are two options for formatting wiggle data.
+         (map (fn [{:keys [format]} wig] (or (= format :fixed-step) (= format :variable-step))) wigs)]}
+  (letfn [(same-track? [first-wig wig]
+            (and (= (:format first-wig) (:format wig))
+                 (= (- (:end first-wig) (:start first-wig))
+                    (- (:end wig) (:start wig)))))
+          (serialize [wigs]
+            (lazy-seq
+             (when (some? (first wigs))
+               (let [[track rest-wigs] (split-with (partial same-track? (first wigs)) wigs)
+                     track (case (-> track first :format)
+                             :variable-step
+                             (let [{:keys [chrom start end]} (first track)
+                                   span (inc (- end start))
+                                   declaration-line (->> (cond-> ["variableStep" (str "chrom=" chrom)]
+                                                           (not= span 1) (conj (str "span=" span)))
+                                                         (cstr/join \space))
+                                   data-lines (->> track
+                                                   (map (fn [{:keys [start value]}] (cstr/join \space [start value])))
+                                                   (cstr/join \newline))]
+                               (cstr/join \newline [declaration-line data-lines]))

-    :fixed-step
-    (let [{:keys [chrom start step span values]} wig
-          declaration-line (->> (cond-> ["fixedStep" (str "chrom=" chrom) (str "start=" start) (str "step=" step)]
-                                  (not= span 1) (conj (str "span=" span)))
-                                (cstr/join \space))
-          data-lines (cstr/join \newline values)]
-      (cstr/join \newline [declaration-line data-lines]))
-
-    (throw (IllegalArgumentException. "Invalid wiggle format"))))
+                             :fixed-step
+                             (let [{:keys [chrom start end]} (first track)
+                                   step (- (-> track rest first :start) start)
+                                   span (inc (- end start))
+                                   declaration-line (->> (cond-> ["fixedStep" (str "chrom=" chrom) (str "start=" start)]
+                                                           (not= step 1) (conj (str "step=" step))
+                                                           (not= span 1) (conj (str "span=" span)))
+                                                         (cstr/join \space))
+                                   data-lines (->> track
+                                                   (map (fn [{:keys [value]}] value))
+                                                   (cstr/join \newline))]
+                               (cstr/join \newline [declaration-line data-lines])))]
+                 (cons track (serialize rest-wigs))))))]
+    (serialize wigs)))

 (defn read-fields
   "Read sequence of WIG fields from reader"
@@ -167,6 +175,6 @@
   [^WIGWriter wtr xs]
   (let [w ^BufferedWriter (.writer wtr)]
     (->> xs
-         (map serialize-wig)
+         serialize-wigs
          (cstr/join \newline)
          (.write w))))


fix critical bugs of sorter

fix critical bugs of sorter

fix a bug that doesn't work merge sort correctly
refactor sorter codes a bit

--- src/cljam/sorter.clj
+++ src/cljam/sorter.clj
@@ -15,11 +15,19 @@
 (def order-coordinate :coordinate)
 (def order-queryname :queryname)

+(defn- make-ref-map
+  [hdr]
+  (->> hdr
+       sam-util/make-refs
+       (map :name)
+       (map-indexed (fn [i val] {val i}))
+       (into {})))
+
 ;; Coordinate sorter
 ;; -----------------

 (defn- replace-header [hdr vn so]
-  (conj hdr {:HD {:VN vn, :SO so}}))
+  (assoc hdr :HD {:VN vn, :SO so}))

 (defn- compare-key-pos [ref-map b1 b2]
   (if (= (:rname b1) (:rname b2))
@@ -33,9 +41,7 @@
                     (get ref-map (:rname b2))))))

 (defn- sort-alignments-by-pos [rdr]
-  (let [ref-map (apply merge
-                       (map-indexed (fn [i val] {val i})
-                                    (map :name (sam-util/make-refs (io/read-header rdr)))))]
+  (let [ref-map (make-ref-map (io/read-header rdr))]
     (sort (partial compare-key-pos ref-map) (io/read-blocks rdr {:mode :coordinate}))))

 ;; Queryname sorter
@@ -64,43 +70,42 @@
   (format "%s/%s_%05d.sorted.cache" util/temp-dir prefix i))

 (defn- find-head
-  ([keyfn l]
-     (reduce (fn [e1 e2]
-               (condp = (compare e1 e2)
-                 0 e1
-                 1 e2
-                 -1 e1))
-             l)))
+  [keyfn l]
+  (reduce (fn [e1 e2]
+            (let [v (keyfn e1 e2)]
+              (cond
+                (or (zero? v)
+                    (neg? v)) e1
+                (pos? v) e2)))
+          l))

 (defn- head
   [blocks ref-map]
-  (find-head
-         (fn [[idx1 b1] [idx2 b2]]
-           (compare-key-pos ref-map b1 b2))
-         (filter
-          (fn [[_ b]] (not (nil? b)))
-          (map-indexed vector blocks))))
+  (->> blocks
+       (map-indexed vector)
+       (filter (fn [[_ b]] (not (nil? b))))
+       (find-head (fn [[idx1 b1] [idx2 b2]]
+                    (compare-key-pos ref-map b1 b2)))))

 (defn split-sam
   [rdr name-fn]
-  (doall
-   (map
-    (fn [[i blks]]
-      (let [f (name-fn i)
-            hdr (io/read-header rdr)]
-        (with-open [wtr (bam/writer f)]
-          (io/write-header wtr hdr)
-          (io/write-refs wtr hdr)
-          (io/write-blocks wtr blks))
-        f))
-    (map-indexed vector (partition-all chunk-size (io/read-blocks rdr))))))
+  (let [hdr (io/read-header rdr)]
+    (doall
+     (->> (io/read-blocks rdr)
+          (partition-all chunk-size)
+          (map-indexed vector)
+          (map (fn [[i blks]]
+                 (let [f (name-fn i)]
+                   (with-open [wtr (bam/writer f)]
+                     (io/write-header wtr hdr)
+                     (io/write-refs wtr hdr)
+                     (io/write-blocks wtr blks))
+                   f)))))))

 (defn merge-sam
   [wtr header name-fn n]
   (let [rdrs (map #(bam/reader (name-fn %) :ignore-index true) (range n))
-        ref-map (apply merge
-                       (map-indexed (fn [i val] {val i})
-                                    (map :name (sam-util/make-refs header))))]
+        ref-map (make-ref-map header)]
     (io/write-header wtr header)
     (io/write-refs wtr header)
     (loop [blocks-list (map #(io/read-blocks % {:mode :coordinate}) rdrs)]
@@ -117,10 +122,10 @@

 (defn clean-split-merge-cache
   [name-fn sorted-name-fn count]
-  (let [clean (fn [path]
-                (let [f (file path)]
-                  (when (.exists f)
-                    (.delete f))))]
+  (letfn [(clean [path]
+            (let [f (file path)]
+              (when (.exists f)
+                (.delete f))))]
     (doseq [i (range count)]
       (clean (name-fn i))
       (clean (sorted-name-fn i)))))
@@ -134,7 +139,7 @@
         sorted-cache-name-fn (partial gen-sorted-cache-filename basename)
         splited-files (split-sam rdr cache-name-fn)
         num-splited (count splited-files)
-        hdr (replace-header (io/read-header rdr)
+        hdr (replace-header (into (sorted-map) (io/read-header rdr))
                             version
                             (name order-coordinate))]
     (doseq [idxs (partition-all util/num-cores (range num-splited))]
@@ -153,7 +158,7 @@

 (defn sort-by-qname [rdr wtr]
   (let [alns (sort-alignments-by-qname rdr)
-        hdr (replace-header (io/read-header rdr)
+        hdr (replace-header (into (sorted-map) (io/read-header rdr))
                             version
                             (name order-queryname))]
     (io/write-header wtr hdr)


better standard deviation function

better standard deviation function

--- uni-linear-regression.clj
+++ uni-linear-regression.clj
@@ -33,10 +33,11 @@
 ; computes sample standard deviation
 (defn st-dev [a-vector]
   (let [themean (mean a-vector)]
-    (Math/pow (/ (reduce + (map #(Math/pow % 2)
-                                (map #(- % themean)
-                                     a-vector)))
-                 (- (count a-vector) 1)) 0.5)))
+    (->> (map #(- % themean) a-vector)
+         (map #(Math/pow % 2))
+         (reduce +)
+         (#(/ % (- (count a-vector) 1)))
+         (#(Math/pow % 0.5)))))

 ; returns a transformed vector where each


Show different invite button text depending on num invites

--- src-cljs/frontend/components/pages/team.cljs
+++ src-cljs/frontend/components/pages/team.cljs
@@ -94,6 +94,12 @@

 (defn- get-entered-email [owner {:keys [handle] :as user}]
   (om/get-state owner [:org-members-by-handle handle :entered-email]))
+
+(defn- invite-button-text [number-of-invites]
+  (cond
+    (= 0 number-of-invites) "Send Invites"
+    (= 1 number-of-invites) "Send 1 Invite"
+    :else (gstr/format "Send %s Invites" number-of-invites)))

 (defn invite-teammates-modal [{:keys [selected-org close-fn show-modal?]} owner]
   (reify
@@ -206,9 +212,7 @@
                                                                                :org-name (:name selected-org)}])
                                                                                (close-fn))
                                                                        :disabled (= 0 count-selected)}
-                                              "Send "
-                                              count-selected
-                                              " Invites"
+                                              (invite-button-text count-selected)
                                               [:i.fa.fa-envelope-o]])]
                                   :close-fn close-fn})))])))))


Defer creating the app handler until launching Jetty

--- test/user.clj
+++ test/user.clj
@@ -16,9 +16,10 @@
            (doall
              (get-asset-uris (:twixt request) "invalid-coffeescript.coffee")))))

-(def app
+(defn app
+  []
   (wrap-with-twixt handler default-options true))

 (defn launch []
-  (let [server (run-jetty app {:port 8888 :join? false})]
+  (let [server (run-jetty (app) {:port 8888 :join? false})]
     #(.stop server)))


Added joining with weather data

Added joining with weather data

--- taxi-rides-clj/src/taxi_rides_clj/core.clj
+++ taxi-rides-clj/src/taxi_rides_clj/core.clj
@@ -26,7 +26,7 @@
      :double    double-parser
      :latlon   #(if-not (= % "0") (double-parser %))
      :keyword  #(let [s (string/trim %)] (if-not (empty? s) s))
-     :date     #(let[d (.parse date-format %)](str (.format ymd-format d) "T" (.format hms-format d) "Z"))}))
+     :date     #(let [d (.parse date-format %)] (str (.format ymd-format d) "T" (.format hms-format d) "Z"))}))

 (def col-mapping
   {"VendorID"                [:int     :vendor-id]
@@ -50,25 +50,43 @@
    "Trip_type"               [:keyword :trip-type]
    "Extra"                   nil})

+(let [[header & rows] (-> (str data-folder "/central_park_weather.csv") slurp csv/read-csv)
+      cols-to-keep #{"DATE" "PRCP" "SNWD" "SNOW" "TMAX" "TMIN" "AWND"}
+      n-cols (count header)
+      rows (for [row rows :when (>= (count row) n-cols)]
+             (into {} (map (fn [k v] (if (cols-to-keep k) [k v])) header row)))]
+  (def weather
+    (->> rows
+         (map (fn [row] (let [[y1 y2 m d] (partition 2 (row "DATE"))
+                              date (apply str (concat y1 y2 "-" m "-" d))]
+                          [date
+                           (->>
+                             (-> row (dissoc "DATE") seq)
+                             (map (fn [[k v]] [(keyword (str "weather-" k)) ((:double parsers) v)]))
+                             (into {}))])))
+         (into {}))))
+;(->> weather seq (take 10))
+
 (defn parse-trips [file]
   (with-open [in (-> file clojure.java.io/input-stream java.util.zip.GZIPInputStream.)]
-    (let [[header & rows] (-> in slurp csv/read-csv)
+    (let [doc-id-fields [:pickup-dt :dropff-dt :pickup-lat :pickup-lon :dropoff-lat :dropoff-lon :distance  :paid-total]
+          dataset (->> file str (re-find #"([a-z]+)[^/]+$") second)
+          [header & rows] (-> in slurp csv/read-csv)
           header   (map string/trim header)
           missing  (clojure.set/difference (-> header set) (-> col-mapping keys set))
           check    (assert (empty? missing) (str "Missing cols for " missing))
           header   (map col-mapping header)
-          n_cols   (count header)
-          doc-id-fields [:pickup-dt :dropff-dt :distance :pickup-lat :pickup-lon :dropoff-lat :dropoff-lon :paid-total]
-          docs     (for [row rows :when (>= (count row) n_cols)]
+          n-cols   (count header)
+          docs     (for [row rows :when (>= (count row) n-cols)]
                      (let [doc (into {} (map (fn [h v] (if h [(second h) ((-> h first parsers) v)])) header row))]
-                       (assoc doc :id (->> (interleave (map doc doc-id-fields) (repeat "/")) (apply str) sha1-hash))))]
+                       (-> doc
+                         (assoc :id      (->> doc-id-fields (map doc) (interleave (repeat "/")) (apply str) sha1-hash))
+                         (assoc :index   (apply str "nyc-taxi-" dataset "-" (take 7 (:pickup-dt doc))))
+                         (into           (weather (-> doc :pickup-dt (subs 0 10)))))))]
         (filter #(pos? (:distance %)) docs))))

-
-(def rows (->> files first parse-trips))
-(pprint (take 3 rows))
-(def freqs (into {} (for [key (keys (first rows))] [key (frequencies (map key rows))])))
-(pprint (into {} (for [[k v] freqs] [k (count v)])))
+(def rows (->> files first parse-trips (group-by :index)))
+(pprint (take 3 (rows (-> rows keys first))))

 (defn -main []
   (println "Hello, World!"))


Use defvar- insteadof declare private

Use defvar- insteadof declare private

--- src/control/core.clj
+++ src/control/core.clj
@@ -4,10 +4,10 @@
         [clojure.walk :only [walk]]
 		[clojure.contrib.def :only [defvar- defvar]]))

-(def {^private: true} bash-reset "\033[0m")
-(def {^private: true} bash-bold "\033[1m")
-(def {^private: true} bash-redbold "\033[1;31m")
-(def {^private: true} bash-greenbold "\033[1;32m")
+(defvar- bash-reset "\033[0m")
+(defvar- bash-bold "\033[1m")
+(defvar- bash-redbold "\033[1;31m")
+(defvar- bash-greenbold "\033[1;32m")

 (defmacro cli-bash-bold [& content]
   `(str bash-bold ~@content bash-reset))


Wire up get-comic-list and get-chapter-list for manga reader

--- src/clj/comic_reader/sites/manga_reader.clj
+++ src/clj/comic_reader/sites/manga_reader.clj
@@ -72,13 +72,21 @@
                        comic-list-selector
                        comic-link-normalize))

+(defn comic->url [comic-id]
+  (format "%s%s/" manga-url comic-id))
+
 (deftype MangaReader []
   MangaSite
   (get-comic-list [this]
-    [])
+    (-> manga-url
+        scrape/fetch-url
+        extract-comics-list))

   (get-chapter-list [this comic-id]
-    [])
+    (let [comic-url (comic->url comic-id)]
+      (-> comic-url
+          scrape/fetch-url
+          (extract-chapters-list comic-url))))

   (get-page-list [this comic-id chapter]
     [])


express all dc routes

express all dc routes

--- src/cljs/daveconservatoire/site/routes.cljs
+++ src/cljs/daveconservatoire/site/routes.cljs
@@ -2,6 +2,10 @@
   (:require [bidi.bidi :as b]))

 (def routes
-  ["/" {""             :home
-        "about"        :about
-        ["topic/" :id] :topic}])
+  ["/" {""                :home
+        "about"           :about
+        "donate"          :donate
+        "tuition"         :tuition
+        "contact"         :contact
+        ["topic/" :slug]  :topic
+        ["lesson/" :slug] :lesson}])


switchbox styling

switchbox styling

--- src/cljs/re_form/inputs/switchbox_impl.cljs
+++ src/cljs/re_form/inputs/switchbox_impl.cljs
@@ -5,30 +5,30 @@
    [re-frame.core :as rf]))

 (defn re-switch-box-style
-  [{:keys [h h2 h3 selection-bg-color hover-bg-color border]}]
+  [{:keys [h h2 h3 selection-bg-color hover-bg-color border gray-color]}]
   [:.re-switch
-   {:font-decoration "none"}
+   {:font-decoration :none}
    [:.re-label {:line-height (u/px h3)
-                :display "inline-block"}]
-   [:.re-switch-line {:width (u/px h3)
+                :display :inline-block}]
+   [:.re-switch-line {:width (u/px* h3 2)
                       :top (u/px 5)
                       :height (u/px h2)
-                      :display "inline-block"
-                      :background-color "gray"
-                      :border-radius (u/px 12)
-                      :margin-right (u/px-div h 2)
-                      :position "relative"}
-    [:.re-box {:width (u/px h2)
-               :height (u/px h2)
+                      :display :inline-block
+                      :background-color gray-color
+                      :border-radius (u/px h2)
+                      :margin-right (u/px 12)
+                      :position :relative}
+    [:.re-box {:width (u/px h3)
+               :height (u/px h3)
                :transition "left 300ms ease-out"
-               :background-color "white"
+               :background-color :white
                :border border
-               :border-radius (u/px 12)
-               :position "absolute"
-               :top 0
+               :border-radius (u/percent 50)
+               :position :absolute
+               :top (u/px- (/ h2 2) (/ h3 2))
                :left 0}]]
    [:&.re-checked
-    [:.re-box {:left (u/px 14)}]
+    [:.re-box {:left (u/px h3)}]
     [:.re-switch-line {:background-color "#007bff"}]]])

 (defn switch-box [_]
@@ -36,7 +36,7 @@
     (let [local-onchange (partial on-change (not value))]
       [:a.re-switch
        {:href "javascript:void(0)"
-        :class (when value "re-checked")
+        :class (when value :re-checked)
         :on-key-press (fn [event] (when (= 32 (.-which event)) (local-onchange)))
         :on-click local-onchange}
        [:span.re-switch-line [:span.re-box]]


stacktrace close instead of cancel dialog

--- src/cljs/swarmpit/component/page_error.cljs
+++ src/cljs/swarmpit/component/page_error.cljs
@@ -30,7 +30,7 @@
           {:title                 "Stacktrace"
            :actions               (comp/flat-button
                                     {:onClick close!
-                                     :label   "Cancel"
+                                     :label   "Close"
                                      :primary false})
            :open                  (rum/react open)
            :autoScrollBodyContent true


A typo in comments.

A typo in comments.

--- src/clojure/uncomplicate/clojurecl/core.clj
+++ src/clojure/uncomplicate/clojurecl/core.clj
@@ -19,7 +19,7 @@
   and gives primitive results. These functions are useful when you
   already have primitive data and want to avoid unnecessary conversions

-  The documentation given here is only a quick reminder; it is necessarry
+  The documentation given here is only a quick reminder; it is necessary
   to grasp OpenCL and parallel computing concepts to be able to use the
   library. Also, each function's doc entry have a link to much more detailed
   documentation available in OpenCL and JOCL reference - be sure to


:art: Store page id in let

:art: Store page id in let

--- frontend/src/uxbox/view/ui/viewer/sitemap.cljs
+++ frontend/src/uxbox/view/ui/viewer/sitemap.cljs
@@ -33,10 +33,11 @@
      [:span.sitemap-title project-name]
      [:ul.sitemap-list
       (for [[i page] (map-indexed vector pages)
-            :let [selected? (= i selected)]]
+            :let [selected? (= i selected)
+                  id (:id page)]]
         [:li {:class (when selected? "selected")
               :on-click (partial on-click i)
-              :id (str "page-" (:id page))
+              :id (str "page-" id)
               :key (str i)}
          [:div.page-icon i/page]
          [:span (:name page)]])]]))


Make sure we're always creating little-endian ByteBuffers. Added options-bytes-seq.

--- src/com/lemondronor/turboshrimp/navdata.clj
+++ src/com/lemondronor/turboshrimp/navdata.clj
@@ -629,8 +629,10 @@
   (let [ba ^"[B" (Arrays/copyOfRange
                   ^"[B" (.array bb)
                   offset
-                  (+ offset len))]
-    (ByteBuffer/wrap ba)))
+                  (+ offset len))
+        bb (ByteBuffer/wrap ba)]
+    (.order bb ByteOrder/LITTLE_ENDIAN)
+    bb))

 (defn get-ushort [^ByteBuffer bb]
   (bit-and 0xFFFF (Integer. (int (.getShort bb)))))
@@ -673,6 +675,7 @@
     :seqnum :uint32-le
     :vision-flag :uint32-le)))

+
 (defn parse-navdata [navdata-bytes]
   (log/debug "-- parse-navdata")
   (let [^ByteBuffer bb (doto ^ByteBuffer (gloss.io/to-byte-buffer navdata-bytes)
@@ -689,7 +692,34 @@
       :vision-flag vision-flag
       :state pstate)))

-;;    (swap! navdata merge new-data)))
+
+
+(defn options-bytes-seq [^ByteBuffer bb]
+  (if (zero? (.remaining bb))
+    '()
+    (let [option-header (get-ushort bb)
+          option-size (get-ushort bb)]
+      (log/info "Processing option" option-header "of" option-size "bytes")
+      (if (pos? option-size)
+        (cons [(or (which-option-type option-header) option-header)
+               (slice-byte-buffer bb 0 option-size)]
+              (lazy-seq
+               (options-bytes-seq
+                (slice-byte-buffer
+                 bb option-size (+ 4 (- (.remaining bb) option-size))))))
+        (do
+          (log/info "Aborting 0-length option.")
+          '())))))
+
+
+(defn navdata-bytes-seq [navdata-bytes]
+  (let [^ByteBuffer bb (doto ^ByteBuffer (gloss.io/to-byte-buffer navdata-bytes)
+                             (.order ByteOrder/LITTLE_ENDIAN))]
+    [(slice-byte-buffer bb 0 16)
+     (options-bytes-seq
+      (slice-byte-buffer bb 16 (- (count navdata-bytes) 16)))]))
+
+

 (defn new-datagram-packet [^bytes data ^InetAddress host ^long port]
   (DatagramPacket. data (count data) host port))


paginaton removal fix added

paginaton removal fix added

--- src/crawler/main.clj
+++ src/crawler/main.clj
@@ -179,8 +179,22 @@
                                     leaf-clusters
                                     (str "example-scheduler-estimate-stopper-" prefix))))

+(defn fix-model
+  [model-file]
+  (let [corpus-file (crawler-model/associated-corpus-file model-file)
+        leaves-file (crawler-model/associated-leaves-file model-file)
+
+        the-model (crawler-model/read-model model-file)]
+    (when-not (:fixed the-model)
+      (let [no-paging-model (corpus/remove-pagination-from-actions the-model)
+
+            fixed-model (merge {:fixed true} no-paging-model)]
+        (with-open [wrtr (io/writer model-file)]
+          (pprint fixed-model wrtr))))))
+
 (defn execute-model-crawler
   [start-url model-file]
+  (fix-model model-file) ; this is a preliminary first step - needed
   (let [model  (crawler-model/read-model model-file)
         corpus-file (crawler-model/associated-corpus-file model-file)
         crawled-corpus (corpus/read-corpus-file corpus-file)
@@ -226,7 +240,7 @@
   (let [model  (crawler-model/read-model model-file)
         corpus-file (crawler-model/associated-corpus-file model-file)
         crawled-corpus (corpus/read-corpus-file corpus-file)
-
+
         actions    (:actions model)
         pagination (:pagination model)


clean up debugging calls

clean up debugging calls

--- src/app/cljs/one/sample/view/editor.cljs
+++ src/app/cljs/one/sample/view/editor.cljs
@@ -36,7 +36,6 @@
                   CHANGE
                   (fn [e] (let [content (. field (getCleanContents))
                                 previous (first (doc-session :get-history))]
-                            (.log js/console content)
                             (doc-session :set! :content content)
                             (if (not= content previous)
                               (do
@@ -66,6 +65,7 @@

 (defn strip-html [s]
   (-> s
+      (.replace "
" "
 ")
       (.replace "
" "\n")
       (.replace " " " ")
       (.replace (js/RegExp. "(<([^>]+)>)" "ig") "")))


core: ratio?

core: ratio?

--- data/core.clj
+++ data/core.clj
@@ -1717,3 +1717,8 @@
     (if (or (zero? m) (= (pos? num) (pos? div)))
       m
       (+ m div))))
+
+(defn ratio?
+  "Returns true if n is a Ratio"
+  {:added "1.0"}
+  [n] (instance? Ratio n))


Remove unnecessary logs

Remove unnecessary logs

--- jar-async/src/slipstream/async/collector.clj
+++ jar-async/src/slipstream/async/collector.clj
@@ -89,8 +89,7 @@
     (go
       (while true
         (let [[[user connector] ch] (alts! [chan (timeout timeout-processing-loop)])]
-          (if (nil? user)
-            (log/log-info "Collect reader " i " loop idle. Looping...")
+          (when (not-nil? user)
             (try
               (log/log-info (str "executing collect request for " (.getName user) " and " (.getConnectorInstanceName connector)))
               (collect! user connector)
@@ -123,13 +122,11 @@
 	  (while true
 	    (<! (timeout timeout-online-loop))
 	    (let [users (online-users)]
-	      (log/log-info "inserting online users requests")
 	      (insert-collection-requests users online-collector-chan))))
   (go
 	  (while true
 	    (<! (timeout timeout-all-users-loop))
 	    (let [users (users)]
-	      (log/log-info "inserting all users requests")
 	      (insert-collection-requests users all-collector-chan)))))

 (defn -start


Updated test to match default fakes.

Updated test to match default fakes.

--- test/behaviors/t_line_number_reporting.clj
+++ test/behaviors/t_line_number_reporting.clj
@@ -111,10 +111,10 @@
      (provided
        (name (favorite-animal)) => "betsy"))
    (fact
-     @reported =future=> (just [ (contains {:type :mock-argument-match-failure
-				     :lhs #'clojure.core/name
-				     :position ["t_line_number_reporting.clj" (+ line-number 5)]
-				     :actual '("fred")})
+     @reported => (just [
+              ;; This used to produce a :mock-argument-match-failure because of
+              ;; (name "fred"). Since the name function actually exists, it's
+              ;; used.
 			  (contains {:type :mock-incorrect-call-count
 				     :position ["t_line_number_reporting.clj" (+ line-number 5)]
 				     :expected-call "(name ...favorite-animal-value-1...)"})


more TODO

more TODO

--- test/com/billpiel/mem_tracer/core_test.clj
+++ test/com/billpiel/mem_tracer/core_test.clj
@@ -562,6 +562,9 @@
 x use 'returns' and 'returned' in output
 x trace aliases
 - ns wildcards
+   x for `add-trace`
+   - for `remove-trace`
+   - other places?
 - bisect recording trees to find bugs
 - split ns and fn name in trace rec and output
 - trace individual fns


Fix bug in paging test utility code

Fix bug in paging test utility code

At some point when we changed the API for paging to use
`include-total` instead of `count?` for indicating that
we'd like for the response to include a count header,
we missed a spot in the test utility code that was still
expecting it to be `count?`, and thus we lost test
coverage for the count-related functionality.

This commit fixes that oversight and adds more strict
validation to the arguments to the test utility function,
to ensure that it is being used properly by all callers.

--- test/com/puppetlabs/puppetdb/testutils.clj
+++ test/com/puppetlabs/puppetdb/testutils.clj
@@ -10,8 +10,9 @@
             [fs.core :as fs])
   (:use     [com.puppetlabs.puppetdb.scf.storage :only [sql-current-connection-table-names]]
             [com.puppetlabs.testutils.logging :only [with-log-output]]
-            [com.puppetlabs.utils :only [parse-int excludes?]]
+            [com.puppetlabs.utils :only [parse-int excludes? keyset]]
             [clojure.test]
+            [clojure.set :only [difference]]
             [ring.mock.request]))

 (def c-t "application/json")
@@ -227,20 +228,22 @@
       (assoc request :headers (assoc headers "Accept" c-t)))))

 (defn paged-results
-  [{:keys [app-fn path query params limit total count?]}]
+  [{:keys [app-fn path query params limit total include-total] :as paged-test-params}]
+  {:pre [(= (keyset paged-test-params)
+          #{:app-fn :path :query :params :limit :total :include-total})]}
   (reduce
     (fn [coll n]
       (let [params  (merge params
                       {:limit limit :offset (* limit n)})
             request (get-request path query
-                      (if count?
-                        (assoc params :count? true)
+                      (if include-total
+                        (assoc params :include-total true)
                         params))
             {:keys [status body headers] :as resp} (app-fn request)
             _       (assert-success! resp)
             result  (json/parse-string body true)]
         (is (>= limit (count result)))
-        (if count?
+        (if include-total
           (do
             (is (contains? headers paging/count-header))
             (is (= total (parse-int (headers paging/count-header)))))


Fix get-reviewer function

Fix get-reviewer function

--- src/antlion_clojure/bot.clj
+++ src/antlion_clojure/bot.clj
@@ -294,7 +294,7 @@
   (let [usergroups-users (some->> usergroups-str
                                   slack/parse-usergroups
                                   (slack/usergroups-users slack))
-        reviewers (-> (dynamodb/get-all-reviewers dynamodb) remove-me)]
+        reviewers (-> (dynamodb/get-all-reviewers dynamodb) (remove-me slack))]
     (if (seq usergroups-users)
       (some->> reviewers
                (filter #((set usergroups-users) (:id %)))


Parse port integer.

Parse port integer.

--- src/clj/clj_templates/config/main_config.clj
+++ src/clj/clj_templates/config/main_config.clj
@@ -5,7 +5,9 @@
 (def main-config
   {:handler/main        {:es-client (ig/ref :search/elastic)}
    :server/jetty        {:handler (ig/ref :handler/main)
-                         :opts    {:port (or (env :port) 3000) :join? false}}
+                         :opts    {:port  (or (Integer/parseInt (env :port))
+                                              3000)
+                                   :join? false}}
    :db/postgres         {:jdbc-url          (env :db-url)
                          :driver-class-name "org.postgresql.Driver"}
    :logger/timbre       {:appenders {:println {:stream :auto}}}


Timeouts

Timeouts

--- src/aurora/interpreter.cljs
+++ src/aurora/interpreter.cljs
@@ -4,6 +4,7 @@

 ;; efficient implementation of stack queries (maybe only compile the watched fn?)
 ;; efficient implementation of cursors (maybe via side-vars)
+;; passing a copy of vars into run-match is a messy hack

 ;; interpreter

@@ -12,23 +13,23 @@
 (defn run-pipe [id->node node inputs output stack]
   (let [vars #js {}
         calls #js []
-        frame #js {:id (:id node) :vars vars :calls calls}]
+        frame #js {:id (:id node) :vars vars :calls calls :inputs inputs :output @output}]
     (.push stack frame) ; call
     (assert (= :pipe (:type node)))
     (doseq [[id value] (map vector (:inputs node) inputs)]
       (aset vars id value))
     (doseq [{:keys [id inputs node]} (:nodes node)]
       (assert (not= :pipe (:type node)) "No inline pipes")
-      (aset vars id (run-node id->node node (map #(aget vars %) inputs) output calls))) ; note calls, not stack
+      (aset vars id (run-node id->node node (map #(aget vars %) inputs) output calls vars))) ; note calls, not stack ; not passing vars is a hack
     (let [result (aget vars (-> node :nodes last :id))]
       (aset frame "result" result) ; return
       result)))

-(defn run-node [id->node node inputs output stack]
+(defn run-node [id->node node inputs output stack vars]
   (case (:type node)
     :data (run-data id->node node inputs output stack)
     :ref (run-ref id->node node inputs output stack)
-    :match (run-match id->node node inputs output stack)
+    :match (run-match id->node node inputs output stack vars)
     :replace (run-replace id->node node inputs output stack)
     :output (run-output id->node node inputs output stack)))

@@ -56,18 +57,17 @@
 (defn check [bool]
   (when-not bool (throw (MatchFailure.))))

-(defn run-match [id->node node inputs output stack]
+(defn run-match [id->node node inputs output stack vars]
   (assert (= 1 (count inputs)))
   (let [input (first inputs)]
     (loop [branches (:branches node)]
       (if-let [[{:keys [pattern inputs node]} & branches] (seq branches)]
         (try
-          (let [vars #js {}]
-            (run-match-pattern id->node pattern (:path input) (:value input) output stack vars)
-            (case (:type node)
-              :match/return (do (assert (= 1 (count inputs)))
-                              (aget vars (first inputs)))
-              (run-node id->node node (map #(aget vars %) inputs) output stack)))
+          (run-match-pattern id->node pattern (:path input) (:value input) output stack vars)
+          (case (:type node)
+            :match/return (do (assert (= 1 (count inputs)))
+                            (aget vars (first inputs)))
+            (run-node id->node node (map #(aget vars %) inputs) output stack vars))
           (catch MatchFailure _
             (recur branches)))
         (throw (MatchFailure.))))))
@@ -90,15 +90,13 @@
                      (let [key (:value key-pattern)]
                        (check (contains? input-value key))
                        (run-match-pattern id->node (get value key-pattern) (conj input-path key) (get input-value key) output stack vars)))))
-    (check (:value (run-node id->node pattern [(Cursor. input-path input-value)] output stack)))))
+    (check (:value (run-node id->node pattern [(Cursor. input-path input-value)] output stack #js {})))))

 (defn run-replace [id->node node inputs output stack]
   (swap! output assoc-in (:path (first inputs)) (:value (second inputs))))

 (defn run-output [id->node node inputs output stack]
-  (swap! output update-in (:path node) cons (:value (first inputs))))
-
-(assoc-in {} [] :foo)
+  (swap! output update-in (:path node) conj (:value (first inputs))))

 ;; ast

@@ -194,32 +192,56 @@
           "c+1" ["c" "one"] (cljs-ref +)
           "nil" ["c" "c+1"] replace)})

+(def example-e
+  #{(pipe "root" ["root"]
+          "result" ["root"] (match (data-map (data-value "started?") (bind "started?" (data-value "false"))) ["started?"] (pipe-ref "start")
+                                   any ["root"] (pipe-ref "wait")))
+    (pipe "start" ["started?"]
+          "timer" [] (data-map (data-value "cursor") (data-vector (data-value "ready")) (data-value "timeout") (data-value 1000))
+          "result" ["timer"] (output ["output" "timeout"])
+          "true" [] (data-value "true")
+          "foo" ["started?" "true"] replace)
+    (pipe "wait" ["root"]
+          "result" ["root"] (match (data-map (data-value "ready") (bind "ready" (data-value "timeout"))) ["root" "ready"] (pipe-ref "go")
+                                   any [] (data-value "ok")))
+    (pipe "go" ["root" "ready"]
+          "false" [] (data-value "false")
+          "foo" ["ready" "false"] replace
+          "c" ["root"] (match (data-map (data-value "counter") (bind "c" any)) ["c"] return)
+          "one" [] (data-value 1)
+          "c+1" ["c" "one"] (cljs-ref +)
+          "nil" ["c" "c+1"] replace)})
+
 (defn run-example [example this-state]
   (let [stack #js []
         id->node (into {} (for [pipe example] [(:id pipe) pipe]))
-        next-state (atom state)]
+        next-state (atom this-state)]
     (try
       (let [result (run-pipe id->node (get id->node "root") [(Cursor. [] this-state)] next-state stack)]
         [result @next-state (aget stack 0)])
-      (catch :default exception
+      (catch MatchFailure exception
         [exception @next-state (aget stack 0)]))))

 (defn step-example [example watchers this-state]
-  (let [[_ next-state _] (run-example example this-state)]
+  (let [stack #js []
+        id->node (into {} (for [pipe example] [(:id pipe) pipe]))
+        next-state (atom this-state)
+        result (run-pipe id->node (get id->node "root") [(Cursor. [] this-state)] next-state stack)]
     (dissoc
      (reduce
       (fn [state watcher] (watcher state))
-      next-state
-      watchers))
-    :output))
+      @next-state
+      watchers)
+     "output")))

 (defn watch-timeout* [buffer state]
-  (doseq [{:keys [cursor timeout]} (get-in state :output :timeout)]
+  (doseq [{:strs [cursor timeout]} (get-in state ["output" "timeout"])]
     (js/setTimeout (fn [] (swap! buffer conj cursor)) timeout))
   (let [cursors @buffer] ;; this is only valid because js is single-threaded
+    (reset! buffer nil)
     (reduce #(assoc-in %1 %2 "timeout") state cursors)))

-(def watch-timeout
+(defn watch-timeout []
   (let [buffer (atom [])]
     #(watch-timeout* buffer %)))

@@ -238,13 +260,28 @@

 (step-example example-d [] {"counter" 0})

-(take 10 (iterate #(step-example example-d [] %) {"counter" 0}))
+(let [wt (watch-timeout)]
+  (take 10 (iterate #(step-example example-d [wt] %) {"counter" 0})))
+
+(run-example example-e {"counter" 0})
+
+(run-example example-e {"counter" 0 "started?" "false"})
+
+(let [wt (watch-timeout)]
+  (nth (iterate #(step-example example-e [wt] %) {"counter" 0 "started?" "false"}) 2000))
+
+(def buffer (atom []))
+(def wt #(watch-timeout* buffer %))
+(def s0 {"counter" 0 "started?" "false"})
+(def s1 (step-example example-e [wt] s0))
+(def s2 (step-example example-e [wt] s1))
+(def s3 (step-example example-e [wt] s2))

 (defn print-stack
   ([frame]
    (print-stack 0 frame))
   ([indent frame]
-   (println (.join (make-array indent) " ") "=>" (.-id frame) (.-vars frame))
+   (println (.join (make-array indent) " ") "=>" (.-id frame) (.-vars frame) (.-inputs frame) (.-output frame))
    (doseq [call (.-calls frame)]
      (print-stack (+ indent 2) call))
    (when (js* "('result' in ~{frame})") ; seriously?
@@ -259,3 +296,6 @@
 (print-example example-b [1 "foo"])
 (print-example example-b 1)
 (print-example example-c 10)
+(print-example example-d {"counter" 0})
+(print-example example-e {"counter" 0})
+(print-example example-e s2)


place => !speakable

place => !speakable

--- src/babel/encyclopedia.cljc
+++ src/babel/encyclopedia.cljc
@@ -117,7 +117,8 @@
    {:place true}     {:activity false
                       :consumable false
                       :living false
-                      :physical-object true}
+                      :physical-object true
+                      :speakable false}

    ;; <preds>
    {:pred :bag}      {:artifact true


cleanup

cleanup

--- src/babel/francais/morphology/verbs.cljc
+++ src/babel/francais/morphology/verbs.cljc
@@ -7,7 +7,6 @@
    #?(:clj [clojure.tools.logging :as log])
    #?(:cljs [babel.logjs :as log])
    [dag_unify.core :refer (copy dissoc-paths fail? get-in merge ref? strip-refs unifyc)]))
-

 (def present-nonreflexive-er-verb
   [


[#11842] Fix login after restoring existing account

--- src/status_im/multiaccounts/login/core.cljs
+++ src/status_im/multiaccounts/login/core.cljs
@@ -504,7 +504,7 @@
     (fx/merge
      cofx
      {:db (-> db
-              (dissoc :intro-wizard)
+              (dissoc :intro-wizard :recovered-account?)
               (update :keycard dissoc :application-info))}
      (open-login (select-keys multiaccount [:key-uid :name :public-key :identicon :images])))))


fix typo

fix typo

--- src/blind/reader.clj
+++ src/blind/reader.clj
@@ -797,9 +797,9 @@
         (throw e)
         (throw (ex-info (.getCause e)
                         (merge {:type :reader-exception}
-                               (if (satisfies? IndexingReader rdr)
-                                 {:line (get-line-number rdr)
-                                  :column (get-column-number rdr)}))
+                               (if (satisfies? IndexingReader reader)
+                                 {:line (get-line-number reader)
+                                  :column (get-column-number reader)}))
                         e))))))

 (defn read-tagged* [rdr tag]


Minor fix on spec constructor docstring.

--- src/bytebuf/spec.clj
+++ src/bytebuf/spec.clj
@@ -18,7 +18,7 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (defmulti spec
-  "Spec instance polymorphic constructor.
+  "Polymorphic constructor for Spec instances.

   Spec is a some kind of composition of arbitrary
   number of types in associative or indexed data


moved to 1.7 class

moved to 1.7 class

moved to 1.7 class

--- src/webapp/framework/client/coreclient.cljs
+++ src/webapp/framework/client/coreclient.cljs
@@ -591,7 +591,10 @@
       (reset! debugger-ui
               (assoc-in @debugger-ui [:mode]
                         "show-event"))
-      (display-debug-code)
+      )
+    (display-debug-code)
+
+    ))


update cats.labs.promise for changes in promesa

as much as we’re going all the way from 1.9.0 to 5.1.0 there’s only two real
changes needed:

1. Promesa now allows for a configurable promise type.

   I’ve used the same “define a fn to extend the implementation class, call it
   on the default class” pattern as used in `promesa.impl` to add
   implementations of the `Contextual` and `Extract` protocols.
2. The protocol fn `-catch` has been removed, replaced by `-mapErr` and
   `-thenErr`.

   I’ve replaced it’s use with `-thenErr` (as promise flattening in an error
   handler seems more appropriate than not.)

--- src/cats/labs/promise.cljc
+++ src/cats/labs/promise.cljc
@@ -4,19 +4,34 @@
             [cats.context :as mc]
             [cats.protocols :as mp]
             [promesa.core :as p]
+            [promesa.impl :as pi]
             [promesa.protocols :as pp])
   #?(:clj
      (:import java.util.concurrent.CompletableFuture)))

 (declare context)

-(extend-type #?(:cljs p/Promise :clj CompletableFuture)
-  mp/Contextual
-  (-get-context [_] context)
+#?(:cljs
+   (defn extend-promise!
+     [t]
+     (extend-type t
+       mp/Contextual
+       (-get-context [_] context)

-  mp/Extract
-  (-extract [it]
-    (pp/-extract it)))
+       mp/Extract
+       (-extract [it]
+         (pp/-extract it)))))
+
+#?(:cljs (extend-promise! pi/*default-promise*))
+
+#?(:clj
+   (extend-type CompletableFuture
+     mp/Contextual
+     (-get-context [_] context)
+
+     mp/Extract
+     (-extract [it]
+       (pp/-extract it))))

 (def ^:no-doc context
   (reify
@@ -29,7 +44,7 @@
     (-bimap [_ err succ mv]
       (-> mv
           (pp/-map succ)
-          (pp/-catch err)))
+          (pp/-thenErr err)))

     mp/Monad
     (-mreturn [_ v]


Language: language is developed when evolving to tribes

--- src/civs/model/society.clj
+++ src/civs/model/society.clj
@@ -2,6 +2,7 @@
   ^{:author ftomassetti}
   civs.model.society
   (:require [civs.model.core :refer :all]
+            [civs.model.language :refer :all]
             [civs.logic.basic :refer :all]))

 ; See http://en.wikipedia.org/wiki/Tribe
@@ -47,8 +48,17 @@
 (defn chiefdom-society? [tribe]
   (= :chiefdom (.society tribe)))

-(defn evolve-in-tribe [tribe]
-  (assoc tribe :society :tribe))
+; TODO assign names to all the settlements
+; TODO when creating settlements for a group with a language they get a name
+(defn develop-a-language [group]
+  (let [group (assoc-language group (generate-language))
+        language (get-language group)
+        group (assoc group :name (.name language))]
+    group))
+
+(defn evolve-in-tribe
+  "The group evolve into a tribe and develop a language"
+  [tribe] (develop-a-language (assoc tribe :society :tribe)))

 (defn evolve-in-chiefdom [tribe]
   (assoc tribe :society :chiefdom))


Removed unused binding: dictionary?

Removed unused binding: dictionary?

--- src/clj_mrazik/irc_bot.clj
+++ src/clj_mrazik/irc_bot.clj
@@ -262,7 +262,6 @@
           modules     (-> @dyncfg/configuration :modules)
           number-cruncher? (:number-cruncher modules)
           s-expressions?   (:s-expressions modules)
-          dictionary?      (:dictionary modules)
           random-messages? (:random-messages modules)
           input       (if in-channel?
                           (if (.startsWith input-text (-> @dyncfg/configuration :bot :prefix))


Docstring format.

Docstring format.

--- src/clj_ravendb/client.clj
+++ src/clj_ravendb/client.clj
@@ -28,7 +28,7 @@

   `:api-key` the api key to use for oauth autentication

-  `:ssl-insecure? use insecure underlying http requests"
+  `:ssl-insecure?` use insecure underlying http requests"
   ([url database]
    (client url database {}))
   ([url database {:keys [caching] :as options


Improve event formatting slightly

Improve event formatting slightly

--- src/cljs/herder/event.cljs
+++ src/cljs/herder/event.cljs
@@ -31,7 +31,9 @@
     (fn []
       [:div {:class "container-fluid"}
        [convention-header :events]
-       [:h2 (:name (get-event))]
+       [:h2 "Event: " (:name (get-event))]
+       [:hr]
+       [:h4 "People"]
        (into [:ul]
              (for [{:keys [id name]} (map get-person (:persons (get-event)))]
                ^{:key id} [:li name " "


add test for changing the account on a transaction item

--- test/clj_money/models/transactions_test.clj
+++ test/clj_money/models/transactions_test.clj
@@ -597,6 +597,87 @@
         (testing "account balances are correct"
           (is (= (bigdec 590) (:balance (accounts/reload storage-spec checking))) "Checking has the correct balance"))))))

+(def change-account-context
+  {:users [(factory :user, {:email "john@doe.com"})]
+   :entities [{:name "Personal"}]
+   :accounts [{:name "Checking"
+               :type :asset}
+              {:name "Salary"
+               :type :income}
+              {:name "Rent"
+               :type :expense}
+              {:name "Groceries"
+               :type :expense}]
+   :transactions [{:transaction-date (t/local-date 2016 3 2)
+                   :entity-id "Personal"
+                   :items [{:action :debit
+                            :account-id "Checking"
+                            :amount 1000}
+                           {:action :credit
+                            :account-id "Salary"
+                            :amount 1000}]}
+                  {:transaction-date (t/local-date 2016 3 9)
+                   :entity-id "Personal"
+                   :items [{:action :debit
+                            :account-id "Groceries"
+                            :amount 101}
+                           {:action :credit
+                            :account-id "Checking"
+                            :amount 101}]}
+                  {:transaction-date (t/local-date 2016 3 16)
+                   :entity-id "Personal"
+                   :items [{:action :debit
+                            :account-id "Groceries"
+                            :amount 102}
+                           {:action :credit
+                            :account-id "Checking"
+                            :amount 102}]}
+                  {:transaction-date (t/local-date 2016 3 23)
+                   :entity-id "Personal"
+                   :items [{:action :debit
+                            :account-id "Groceries"
+                            :amount 103}
+                           {:action :credit
+                            :account-id "Checking"
+                            :amount 103}]}]})
+
+(deftest update-a-transaction-change-account
+  (let [context (serialization/realize storage-spec change-account-context)
+        [checking
+         salary
+         rent
+         groceries] (:accounts context)
+        [t1 t2 t3 t4] (:transactions context)
+        _ (transactions/update storage-spec (assoc t3 :account-id (:id rent)))
+        groceries-items (transactions/items-by-account storage-spec (:id groceries))
+        rent-items (transactions/items-by-account storage-spec (:id rent))
+        expected-groceries [{:index 1
+                             :amount (bigdec 103)
+                             :balance (bigdec 204)}
+                            {:index 0
+                             :amount (bigdec 101)
+                             :balance (bigdec 101)}]
+        expected-rent [{:index 0
+                        :amount (bigdec 102)
+                        :balance (bigdec 102)}]
+        actual-groceries (map #(select-keys % [:index :amount :balance])
+                              groceries-items)]
+
+    (pprint {:expected expected-groceries
+             :actual actual-groceries
+             :diff (diff expected-groceries actual-groceries)})
+
+    (testing "accounts have the correct items"
+      (is (= expected-groceries actual-groceries)
+          "Groceries should have the correct items after update")
+      #_(is (= expected-rent
+             (map #(select-keys % [:index :amount :balance]) rent-items))))
+    #_(testing "accounts have the correct balances"
+      (is (= (bigdec 204)
+             (:balance (accounts/reload storage-spec groceries))))
+      (is (= (bigdec 102)
+             (:balance (accounts/reload storage-spec rent)))))))
+
 ; update a transaction

 ; change account


refactor: readability - convert to thread

--- src/fat_jar/core.clj
+++ src/fat_jar/core.clj
@@ -30,8 +30,10 @@
     (.newLine w))))

 (def config
-  (p/properties->map
-    (p/load-from (io/file "./mapper.properties")) true))
+  (->> "./mapper.properties"
+    io/file
+    p/load-from
+    #(p/properties->map % true)))

 (defn -main [& args]
   (let [options (parse-opts args cli-options :strict true :missing true)


finish format part

finish format part

1. Need more test (in test folder)
2. Clean marks

--- src/codeitlater/format.clj
+++ src/codeitlater/format.clj
@@ -10,6 +10,7 @@
     (doall (map #(printf "  |-- %s\n" %) tuples))
     (println)))

+
 (defn print-with-keyword [filepath tuples keyword]
   (let [filter-content (filter #(-> (str "(?<=" keyword ":" ").*$")
                                     (re-pattern)
@@ -19,9 +20,10 @@
       (printline filepath filter-content)
       )))

-(defn format-keyword-content [tuples keyword]
+
+(defn check-keyword-content [tuples keyword]
   "cut content those including keyword:
-return ((linenum [keyword content])..)
+return ((linenum \"keyword content\")..)
 "
   (let [filter-content (filter #(-> (str "(?<=" keyword ":" ").*$")
                                     (re-pattern)
@@ -29,8 +31,9 @@
                                tuples)]
     ;;(print filter-content)
     (if (not (empty? filter-content))
-      (doall (map #(list (first %) (str/split (second %) #": ")) filter-content))
+      (map #(list (first %) (str/split (second %) #": ")) filter-content)
       )))
+

 (defn list2tree [ls keyword]
   "make list to tree"
@@ -48,6 +51,7 @@
         (recur (rest listset))
         ))))

+
 (defn write-keyword-sentence [ls keyword path]
   "write keyword content in level"
  (with-open [wrtr (io/writer path)]
@@ -55,13 +59,14 @@
     (if (not (empty? listset))
       (let [thisls (first listset)
             [filepath & tuples] thisls]
-        ;(.write wrtr tuples)
-        (.write wrtr (str "*" filepath "\n"
-                          (format-keyword-content tuples keyword)))
+        (.write wrtr (str "* " filepath "\n"))
+        (doseq [line (check-keyword-content tuples keyword)]
+          (.write wrtr (str "** " keyword " " (format-content line))))
         (recur (rest listset)))))))

-(defn write-to-file [path]
-  (with-open [wrtr (io/writer path)]
-    (.write wrtr "test")
-    (.write wrtr "test1")))
+(defn format-content [line]
+  "line struct is '(1 [keyword content])"
+  (format "%s (in line %d)" (second (second line)) (first line))
+  )
+


factor out heartbeat updating code

factor out heartbeat updating code

--- src/clj/backtype/storm/daemon/nimbus.clj
+++ src/clj/backtype/storm/daemon/nimbus.clj
@@ -334,33 +334,35 @@
 ;;(alive-task-groups nimbus topology-details all-task-groups existing-assignment)

-(defn update-heartbeats! [nimbus topology-details ...]
-  )
+(defn update-heartbeats! [nimbus storm-id existing-assignment]
+  (let [storm-cluster-state (:storm-cluster-state nimbus)
+        task-heartbeats-cache (:task-heartbeats-cache nimbus)
+        taskbeats (.taskbeats storm-cluster-state storm-id (:task-group->node+port existing-assignment))]
+    (doseq [[task-id {reported-time :time-secs}] taskbeats
+            :let [{last-nimbus-time :nimbus-time
+                   last-reported-time :task-reported-time} (get-in @task-heartbeats-cache [storm-id task-id])
+                  start-time (-> existing-assignment :task->start-time-secs task-id)
+                  nimbus-time (if (or (not last-nimbus-time)
+                                  (not= last-reported-time reported-time))
+                                (current-time-secs)
+                                last-nimbus-time
+                                )]]
+      (swap! task-heartbeats-cache
+                 assoc-in [storm-id task-id]
+                 {:nimbus-time nimbus-time
+                  :task-reported-time reported-time}))))

 ;;TODO: rewrite
 ;; separate updating of heartbeats into another function
 (defn- alive-task-groups
   [nimbus topology-details all-task-groups existing-assignment]
+  (let [task-heartbeats-cache (:task-heartbeats-cache nimbus)]
+    )
   ;;[conf storm-id taskbeats task-ids task-start-times task-heartbeats-cache]
   (doall
     (filter
       (fn [task-id]
-        (let [heartbeat (get taskbeats task-id)
-              reported-time (:time-secs heartbeat)
-              {last-nimbus-time :nimbus-time
-               last-reported-time :task-reported-time} (get-in @task-heartbeats-cache
-                                                               [storm-id task-id])
-              task-start-time (get task-start-times task-id)
-              nimbus-time (if (or (not last-nimbus-time)
-                                  (not= last-reported-time reported-time))
-                            (current-time-secs)
-                            last-nimbus-time
-                            )
-              ]
-          (swap! task-heartbeats-cache
-                 assoc-in [storm-id task-id]
-                 {:nimbus-time nimbus-time
-                  :task-reported-time reported-time})
+        ;; TODO;...
           (if (and task-start-time
                    (or
                     (< (time-delta task-start-time)
@@ -438,6 +440,7 @@

         existing-assigned (reverse-map (:task-group->node+port existing-assignment))

+        _ (update-heartbeats! nimbus storm-id existing-assignment)
         ;; TODO: finish
         alive-groups (if scratch?
                         all-task-ids


Include :db/id in stop search pull

Include :db/id in stop search pull

--- src/cljs/gtfve/controllers/controls.cljs
+++ src/cljs/gtfve/controllers/controls.cljs
@@ -23,7 +23,8 @@
                               :get "/stops-search"
                               :response-format :edn
                               :params {:query query
-                                       :pull (pr-str [:stop/id
+                                       :pull (pr-str [:db/id
+                                                      :stop/id
                                                       :stop/name
                                                       :stop/latitude
                                                       :stop/longitude])}))]


compile bug

compile bug

--- src/clojure/zensols/actioncli/log4j2.clj
+++ src/clojure/zensols/actioncli/log4j2.clj
@@ -58,7 +58,7 @@
   a resource."
   [res]
   (let [stream (cond (string? res) (io/input-stream (io/resource res))
-                     (instance? java.io.InputStream res)
+                     (instance? java.io.InputStream res) res
                      true (io/input-stream res))]
     (with-open [in stream]
       (LogUtil/config in))


cleanup

cleanup

--- src/clojure/zensols/nlparse/stanford.clj
+++ src/clojure/zensols/nlparse/stanford.clj
@@ -270,24 +270,6 @@
           awmap (zipmap keys (map attr-fn-map keys))]
       (into {} (filter second awmap)))))

-(defn- parse-tree-to-map [node senti-node]
-  (when node
-    (let [label (.label node)
-          [pchild schild] (if-not (.isLeaf node)
-                            (let [pchild (.getChildrenAsList node)]
-                             [pchild
-                              (if senti-node
-                                (.getChildrenAsList senti-node)
-                                (repeat (count pchild) nil))]))]
-      (merge {:label (->> label .value)}
-             (select-keys (->> label anon-word-map)
-                          [:token-index :index-range])
-             (let [score (.score node)]
-               (if-not (Double/isNaN score)
-                 {:score score}))
-             (if pchild
-               {:child (map parse-tree-to-map pchild schild)})))))
-
 (defn- parse-tree-to-map [node]
   (when node
     (let [label (.label node)]
@@ -343,13 +325,11 @@
 (defn- anon-sent-map [anon]
   (->> [[:text (text- anon)]
         [:sent-index (sent-index- anon)]
-        [:parse-tree (parse-tree-to-map (parse-tree- anon)
-                                        ;(sentiment-tree- anon)
-                                        )]
+        [:parse-tree (parse-tree-to-map (parse-tree- anon))]
         [:dependency-parse-tree
          (dep-parse-tree-to-map (dependency-parse-tree- anon))]
         [:sentiment-class (sentiment-class- anon)]
-        [:sentiment-tree (parse-tree-to-map (sentiment-tree- anon))]
+        ;[:sentiment-tree (parse-tree-to-map (sentiment-tree- anon))]
         [:tokens (map anon-word-map (tokens- anon))]]
        util/map-if-data))


Added :use-mate-differently diversification test.

--- src/clojush/pushgp/genetic_operators.clj
+++ src/clojush/pushgp/genetic_operators.clj
@@ -961,6 +961,19 @@
          (not (zero? c2-diff))
          (not= c1-diff c2-diff))))

+(defn use-mate-differently-diversifying?
+  "Returns true iff genome g passes the diversification test."
+  [g argmap]
+  (let [mate (vec (repeat (count g) {:instruction :from-mate}))
+        c1 (produce-child-genome-by-autoconstruction g mate false argmap)
+        c1-from-mate (count (filter #(= (:instruction %) :from-mate) c1))]
+    (if (> c1-from-mate 0)
+      (let [c2 (produce-child-genome-by-autoconstruction g mate false argmap)
+            c2-from-mate (count (filter #(= (:instruction %) :from-mate) c2))]
+        (and (> c2-from-mate 0)
+             (not= c1-from-mate c2-from-mate)))
+      false)))
+

 (defn diversifying?
   "Returns true iff genome g passes the diversification test."
@@ -974,6 +987,7 @@
      :three-gens-size-and-instruction three-gens-size-and-instruction-diversifying?
      :diffmeans diffmeans-diversifying?
      :minimal-reproductive-difference minimal-reproductive-difference-diversifying?
+     :use-mate-differently use-mate-differently-diversifying?
      :no-clones no-clones-diversifying?
      :none (fn [genome argmap] true))
     g
@@ -1101,3 +1115,4 @@

+


Reformatting; lein release :minor

Reformatting; lein release :minor

--- src/clojush/pushgp/genetic_operators.clj
+++ src/clojush/pushgp/genetic_operators.clj
@@ -1,6 +1,4 @@
-;; gorilla-repl.fileformat = 1
-
-;; @@
+
 (ns clojush.pushgp.genetic-operators
   (:use [clojush util random individual globals interpreter translate pushstate]
         clojush.instructions.tag
@@ -280,13 +278,13 @@
     (let [close-mutator (fn [instr-map]
                           (let [closes (get instr-map :close 0)]
                             (assoc instr-map :close
-                                   (if (< (lrand) uniform-close-mutation-rate)
-                                     (if (< (lrand) close-increment-rate) ;Rate at which to increase closes instead of decrease
-                                       (inc closes)
-                                       (if (<= closes 0)
-                                         0
-                                         (dec closes)))
-                                     closes))))
+                              (if (< (lrand) uniform-close-mutation-rate)
+                                (if (< (lrand) close-increment-rate) ;Rate at which to increase closes instead of decrease
+                                  (inc closes)
+                                  (if (<= closes 0)
+                                    0
+                                    (dec closes)))
+                                closes))))
           new-genome (map close-mutator (:genome ind))]
       (make-individual :genome new-genome
                        :history (:history ind)
@@ -599,4 +597,3 @@
       )))

-;; @@


Mention swap! duh

Mention swap! duh

--- src/demo/caching.clj
+++ src/demo/caching.clj
@@ -4,15 +4,25 @@
   (:import java.util.concurrent.TimeUnit))

 ;;; Caches implement org.infinispan.Cache and
-;;; java.util.concurrent.ConcurrentMap. They are mutable maps, so
-;;; changing them requires Java interop, as would any mutable Java
-;;; data structure. Of course, reading entries can be done with core
-;;; Clojure functions.
+;;; java.util.concurrent.ConcurrentMap

 ;;; Writing

 (def foo (c/cache "foo", :ttl [5 :minutes], :idle [1 :minute]))
+
+;;; The swap! function atomically updates cache entries by applying a
+;;; function to the current value or nil, if the key is missing. The
+;;; function should be side-effect free.
+
+(c/swap! foo :a (fnil inc 0))           ;=> 1
+(c/swap! foo :b (constantly "foo"))     ;=> "foo"
+(c/swap! foo :a inc)                    ;=> 2
+
+;;; Internally, swap! uses the ConcurrentMap methods, replace (CAS)
+;;; and putIfAbsent, to provide a consistent view of the cache to
+;;; callers. Of course, you can invoke these and other methods
+;;; directly using plain ol' Java interop...

 ;;; Put an entry in the cache
 (.put foo :a 1)
@@ -86,9 +96,9 @@

 ;;; Encoding

-;;; Cache entries not encoded by default, but may be "wrapped" in a
-;;; codec. Provided codecs include :edn, :json, and :fressian. The
-;;; latter two require additional dependencies: 'cheshire' and
+;;; Cache entries are not encoded by default, but may be decorated
+;;; with a codec. Provided codecs include :edn, :json, and :fressian.
+;;; The latter two require additional dependencies: 'cheshire' and
 ;;; 'org.clojure/data.fressian', respectively.
 (def encoded (c/with-codec baz :edn))


fix reference to dynamic var

fix reference to dynamic var

--- src/com/billpiel/sayid/string_output.clj
+++ src/com/billpiel/sayid/string_output.clj
@@ -252,9 +252,9 @@
 (defn print-tree
   [tree]
   (let [s (with-out-str (print-tree-unlimited tree))
-        s' (if (<  max-len
+        s' (if (<  *max-chars*
                    (count s))
-             (str (subs s 0 max-len)
+             (str (subs s 0 *max-chars*)
                   truncate-msg)
              s)]
     (print s')))


parameterize callback url

parameterize callback url

--- src/holston/core.clj
+++ src/holston/core.clj
@@ -25,10 +25,15 @@
       (slurp (str (System/getenv "ENV_DIR") "/" name)) ;; This happens in macroexpansion and heroku only reveals config vars this way in compile
       (throw (Exception. (str "Mandatory environment variable missing: " name)))))

+(defn get-oauth-callback-domain []
+  (if (System/getenv "ENV_DIR") ;; We're in Heroku, not local env
+    (get-mandatory-env-var "HOLSTON_OATH2_CALLBACK_DOMAIN")
+    "http://localhost:8080"))
+
 (defn create-client-config []
   {:client-id (get-mandatory-env-var "HOLSTON_GOOGLE_CLIENT_ID")
    :client-secret (get-mandatory-env-var "HOLSTON_GOOGLE_CLIENT_SECRET")
-   :callback {:domain "http://localhost:8080" :path "/oauth2callback"}})
+   :callback {:domain (get-oauth-callback-domain) :path "/oauth2callback"}})

 (defn uri-config []
   (let [client-config (create-client-config)]


we start only providers that dont start during create

--- src/celestial/workflows.clj
+++ src/celestial/workflows.clj
@@ -131,7 +131,8 @@
   "create and provision"
   [type {:keys [system-id] :as spec}]
   (create spec)
-  (start spec)
+  (when-not (= (.status (vconstruct spec)) "running"); some providers already start the vm (AWS, vCenter)
+    (start spec))
   (puppetize type (assoc (s/get-system system-id) :system-id system-id)))

 (deflow ^{:hook-args :run-info} run-action


add helper function to make migrating to groups easier

--- src/chat/server/migrate.clj
+++ src/chat/server/migrate.clj
@@ -30,4 +30,16 @@
         :db/valueType :db.type/ref
         :db/cardinality :db.cardinality/many
         :db/id #db/id [:db.part/db]
-        :db.install/_attribute :db.part/db}])))
+        :db.install/_attribute :db.part/db}]))
+  (println "You'll now need to create a group and add existing users & tags to that group"))
+
+(defn create-group-for-users-and-tags
+  "Helper function for migrate-2015-07-29 - give a group name to create that
+  group and add all existing users and tags to that group"
+  [group-name]
+  (db/with-conn
+    (let [group (db/create-group! {:group/id (db/uuid) :group/name group-name})
+          all-users (->> (d/q '[:find ?u :where [?u :user/id]] (d/db db/*conn*)) (map first))
+          all-tags (->> (d/q '[:find ?t :where [?t :tag/id]] (d/db db/*conn*)) (map first))]
+      (d/transact db/*conn* (mapv (fn [u] [:db/add [:group/id (group :id)] :group/user u]) all-users))
+      (d/transact db/*conn* (mapv (fn [t] [:db/add t :tag/group [:group/id (group :id)]]) all-tags)))))


Refactor. Exptract row, and use ->> macro. Remove unnecessary parameters

--- src/fp_contest_data_transformations/core.clj
+++ src/fp_contest_data_transformations/core.clj
@@ -9,7 +9,7 @@
     {hexapod-name
      (into {}
            (for [stats hexapod-info
-                 :let [stats-words (->> (split stats #"[:,]") (remove blank?) (map trim))
+                 :let [stats-words (->> (split stats #"[:,]") (map trim) (remove blank?))
                        [quantity & countries] stats-words]
                  :when (not (blank? stats))]
              [quantity (into #{} countries)]))}))
@@ -40,21 +40,22 @@
           [country diversity])))

 (defn hexapod-stats->csv [data hexapods]
-  (letfn [(header [hexapods]
-                   (join ";" (conj (seq hexapods) "Country/Hexapod")))
-           (body [data hexapods]
-             (apply str
-                    (interpose "\n"
-                               (for [[country stats] data]
-                                 (apply str
-                                        (interpose ";"
-                                                   (into [country]
-                                                         (for [hexapod hexapods]
-                                                           (get stats hexapod "-")))))))))]
+  (letfn [(header []
+            (join ";" (conj (seq hexapods) "Country/Hexapod")))
+          (row [country stats]
+            (->> (into [country]
+                       (for [hexapod hexapods]
+                         (get stats hexapod "-")))
+                 (interpose ";")
+                 (apply str)))
+          (body []
+            (interpose "\n"
+                       (for [[country stats] data]
+                         (row country stats))))]
           (apply str
-                 (header hexapods)
+                 (header)
                  "\n"
-                 (body data hexapods))))
+                 (body))))

 (defn risc-of-dissapearance [data countries quantities]
   (into {}


Remove mistaken multiple publications.

Remove mistaken multiple publications.

Test multihop stage-api demo.

--- src/clj/geschichte/sync.clj
+++ src/clj/geschichte/sync.clj
@@ -12,6 +12,10 @@
               [clojure.core.async :as async
                :refer [<! >! timeout chan alt! go put! filter< map< go-loop]]))

+;; TODO
+;; adjust wire
+;; ack connected
+;; sente

 (declare wire)
 (defn client-peer
@@ -44,7 +48,7 @@
                     :ip ip
                     :port port})]
     (go-loop [[in out] (<! new-conns)]
-             (wire peer [out in])
+             (wire peer [out (async/pub in :type)])
              (recur (<! new-conns)))
     peer))

@@ -61,7 +65,7 @@
   ([peer author repo schema]
      (load-stage! peer author repo schema (chan) (chan)))
   ([peer author repo schema [in out]]
-     (go (<! (wire peer [in out]))
+     (go (<! (wire peer [in (async/pub out :type)]))
          {:author author
           :schema schema
           :meta (<! (-get-in (:store (:volatile peer)) [author repo]))
@@ -99,17 +103,13 @@
   (go-loop [{:keys [user meta] :as p} (<! pub-ch)]
            (when p
              (let [repo (:id meta)
-                   nc (<! (new-commits! store meta (<! (-get-in store [user repo]))))
-                   filt-ch #_(filter< #(do (println "FILTER" (:ip @peer) % nc)
-                                           (= (set (keys (:values %))) nc)))
-                   fetched-ch]
-               (>! out {:type :fetch
-                        :user user :repo repo
-                        :ids nc})
-               (println "WAIT FOR FETCH" (:ip @peer) nc)
-               (doseq [[repo-id val] (:values (<! filt-ch))]
-                 (<! (-assoc-in store [repo-id] val)))
-               (println "GOT FETCH" (:ip @peer) nc)
+                   nc (<! (new-commits! store meta (<! (-get-in store [user repo]))))]
+               (when-not (empty? nc)
+                 (>! out {:type :fetch
+                          :user user :repo repo
+                          :ids nc})
+                 (doseq [[repo-id val] (:values (<! fetched-ch))]
+                   (<! (-assoc-in store [repo-id] val))))

                (>! out {:type :meta-pubed :user user :repo repo})
                ;; TODO find cleaner way to atomically update
@@ -129,18 +129,15 @@
                    [c-in c-out] [(debug/chan log [(str ip4 ":" port) :in])
                                  (debug/chan log [(str ip4 ":" port) :out])]
                    subs (:meta-sub @peer)
-;                  p (async/pub c-in :type)
                    subed-ch (chan)]
                (client-connect! ip4 port c-in c-out)

                                         ; handshake
-               #_(async/sub p :meta-subed subed-ch)
                (>! c-out {:type :meta-sub :metas subs})
                (put! subed-ch (<! c-in))
                (subscribe peer subed-ch bus-out c-out)

-               (<! (wire peer [c-out c-in]))
-               ; (async/unsub p :meta-subed subed-ch)
+               (wire peer [c-out (async/pub c-in :type)])
                (recur (<! conn-ch))))))

@@ -154,18 +151,16 @@
                                 (async/into [])
                                 <!
                                 (zipmap ids))]
-               #_(println "TO-FETCH" (:ip @peer) fetched)
                (>! out {:type :fetched
                         :user user :repo repo
                         :values fetched})
                (recur (<! fetch-ch))))))

-(defn wire [peer [out in]]
+(defn wire [peer [out p]]
   (go (let [{:keys [store chans log]} (:volatile @peer)
             ip (:ip @peer)
             [bus-in bus-out] chans
-            p (async/pub in :type)
             pub-ch (debug/chan log [ip :pub])
             conn-ch (debug/chan log [ip :conn])
             sub-ch (debug/chan log [ip :sub])
@@ -206,7 +201,7 @@
 #_(clojure.pprint/pprint @stage-log)
 #_(let [in (debug/chan stage-log [:stage :in])
       out (debug/chan stage-log [:stage :out])]
-  (go (<! (wire peer [in out]))
+  (go (<! (wire peer [in (async/pub out :type)]))
       (>! out {:type :meta-sub :metas {"john" #{1}}})
 ;      (<! in)
       (<! (timeout 1000))
@@ -250,30 +245,39 @@

+; publish all out channels before wiring
 (defn wire-stage [peer {:keys [chans] :as stage}]
   (go (if chans stage
-          (let [[in out] [(chan) (chan)]]
-            (<! (wire peer [in out]))
-            (assoc stage :chans [in out])))))
-
-
+          (let [log (atom {})
+                in (debug/chan log ["STAGE" :in])
+                out (debug/chan log ["STAGE" :out])]
+            (<! (wire peer [in (async/pub out :type)]))
+            (assoc stage :chans [(async/pub in :type) out])))))
+
+;; push perspective
 (defn sync! [{:keys [type author chans new-values meta] :as stage}]
-  (go (let [[in out] chans
-            p (async/pub in :type)
+  (go (let [[p out] chans
             fch (chan)
+            pch (chan)
             repo (:id meta)]

         (async/sub p :fetch fch)
+        (async/sub p :meta-pubed pch)
         (case type
           :meta-pub  (>! out {:type :meta-pub :user author :meta meta})
           :meta-sub (do
                       (>! out {:type :meta-sub :metas {author #{repo}}})
                       (>! out {:type :meta-pub :user author :meta meta})))

-        (let [to-fetch (select-keys new-values (:ids (<! fch)))]
-          (>! out {:type :fetched
-                   :user author :repo repo
-                   :values to-fetch}))
+        (go (let [to-fetch (select-keys new-values (:ids (<! fch)))]
+              (>! out {:type :fetched
+                       :user author :repo repo
+                       :values to-fetch})))
+
+        (let [m (alt! pch (timeout 10000))]
+          (when-not m
+            (throw (IllegalStateException. (str "No meta-pubed ack received for" meta)))))
+        (async/unsub p :fetch fch)
         (async/unsub p :fetch fch)

         (dissoc stage :type :new-values))))
@@ -283,21 +287,22 @@
   (def peer (client-peer "CLIENT" (new-store)))
   (require '[clojure.core.incubator :refer [dissoc-in]])
   (dissoc-in @peer [:volatile :log])
-
-  (go (let [stage (repo/new-repository "me@mail.com"
+  (clojure.pprint/pprint (get-in @peer [:volatile :log]))
+
+  (go (let [printfn (partial println "STAGE:")
+            stage (repo/new-repository "me@mail.com"
                                        {:type "s" :version 1}
                                        "Testing."
                                        false
                                        {:some 42})
             stage (<! (wire-stage peer stage))
-            printfn (partial println "STAGE:")
-            in  (first (:chans stage))
-            _ (go-loop [m (<! in)]
-                       (println "STAGE-IN:" m)
-                       (recur (<! in)))
-            _ (>! (second (:chans stage)) {:type :connect
-                                           :ip4 "127.0.0.1"
-                                           :port 9090})
+            out (second (:chans stage))
+            _ (>! out {:type :meta-sub
+                       :metas {"me@mail.com" #{(:id (:meta stage))}}})
+            _ (<! (timeout 1000))
+            _ (>! out {:type :connect
+                       :ip4 "127.0.0.1"
+                       :port 9090})
             _ (<! (timeout 1000))
             new-stage (<! (sync! stage))]
         (-> new-stage
@@ -305,8 +310,7 @@
             repo/commit
             sync!
             <!
-            printfn)
-        (<! (timeout 1000)))))
+            printfn))))


fix page links

fix page links

--- src/clj/salava/page/pdf.clj
+++ src/clj/salava/page/pdf.clj
@@ -134,8 +134,9 @@
                                                                    (:description %)"\n"
                                                                    [:spacer 0]
                                                                    [:paragraph {:keep-together true}
-                                                                    [:phrase.bold (str (t :badge/Criteria ul)": ")] [:spacer 0]
-                                                                    [:anchor {:target (:criteria_url %) :style{:family :times-roman :color [66 100 162]}} (:criteria_url %)]
+                                                                    [:phrase.bold (str (t :badge/Criteria ul)": ")]
+                                                                    [:anchor {:target (:criteria_url %)} [:chunk.link (t :badge/Opencriteriapage ul)]] "\n"
+                                                                    [:paragraph {:style :italic} (:criteria_url %) ]
                                                                     [:spacer 0]
                                                                     (let [content (some->> (pdf-generator-helper ctx user-id (list (:badge_id %))) first :content first) ]
                                                                       (when-not (empty? content)
@@ -181,8 +182,9 @@
                                                                                (:description badge)"\n"
                                                                                [:spacer 0]
                                                                                [:paragraph {:keep-together true}
-                                                                                [:phrase.bold (str (t :badge/Criteria ul)": ")] "\n"
-                                                                                [:anchor {:target (:criteria_url badge) :style{:family :times-roman :color [66 100 162]}} (:criteria_url badge)] "\n"
+                                                                                [:phrase.bold (str (t :badge/Criteria ul)": ")]
+                                                                                [:anchor {:target (:criteria_url badge)} [:chunk.link (t :badge/Opencriteriapage ul)]] "\n"
+                                                                                [:paragraph {:style :italic} (:criteria_url badge) ]
                                                                                (process-markdown (:criteria_content content) (:id badge) "Criteria")
                                                                                ]
                                                                                ][:spacer 0]]))))


Expand wrapper for secured-application piece.

--- src/cljs/om_sente/core.cljs
+++ src/cljs/om_sente/core.cljs
@@ -152,7 +152,8 @@
   (reify
     om/IRender
     (render [this]
-            (dom/div nil
+            (dom/div #js {:style #js {:margin "auto" :width "1000"
+                                      :border "solid blue 1px" :padding 20}}
                      (dom/h1 nil "Test Sente")
                      (om/build text-sender app {})
                      (om/build data-view app {})))))


Comments

Comments

--- src/cljs/triboard/core.cljs
+++ src/cljs/triboard/core.cljs
@@ -216,7 +216,7 @@
   (get-in game [:moves player point]))

 (defn play-move
-  "On player playing the move [x y]"
+  "On player playing the move [x y] - update all the game state accordingly"
   [{:keys [player board] :as game} point]
   (if-let [moves (get-move-at game player point)]
     (->


Be less lazy!

Be less lazy!

--- src/clojurecraft/events.clj
+++ src/clojurecraft/events.clj
@@ -14,7 +14,7 @@
   (let [action-groups (map #(apply (deref %) (into [bot] args))
                            (event-type @(:event-handlers bot)))
         queue-action #(.put (:actionqueue bot) %)
-        queue-action-group #(map queue-action %)]
+        queue-action-group #(dorun (map queue-action %))]
     (dorun (map queue-action-group action-groups))))

 (defn fire-chat [bot message]


Tweak resilience

Tweak resilience

--- src/clojush/meta_errors.clj
+++ src/clojush/meta_errors.clj
@@ -168,7 +168,7 @@
         0
         (if (> (/ (count (distinct hist))
                   (count hist))
-               2/5)
+               3/5)
           0
           1)))))

@@ -193,7 +193,7 @@
   (if (not (:print-history argmap))
     (throw
      (Exception.
-      ":print-history must be true for :stasis"))
+      ":print-history must be true for :non-improvement"))
     (let [hist (:history ind)]
       (if (< (count hist) 2)
         0


Add test cases for content-negotiation

Add test cases for content-negotiation

Signed-off-by: Deepak Giridharagopal <d11186354d1ef01ca06ae37d7e23e827da13e85f@puppetlabs.com>

--- test/com/puppetlabs/test/utils.clj
+++ test/com/puppetlabs/test/utils.clj
@@ -25,3 +25,23 @@
     (testing "should return default when divisor is zero"
       (is (= 0 (quotient 1 0)))
       (is (= 10 (quotient 1 0 10))))))
+
+(deftest conneg
+  (testing "should match an exact accept header"
+    (is (= "text/html" (acceptable-content-type "text/html" "text/html"))))
+
+  (testing "should match an exact accept header that includes other types"
+    (is (= "text/html" (acceptable-content-type "text/html" "text/html, text/plain"))))
+
+  (testing "should match a wildcard accept header"
+    (is (= "text/*" (acceptable-content-type "text/html" "text/*"))))
+
+  (testing "should match a wildcard accept header that includes other types"
+    (is (= "text/*" (acceptable-content-type "text/html" "text/plain, text/*"))))
+
+  (testing "should return nil if a single header doesn't match"
+    (is (= nil (acceptable-content-type "text/html" "application/json"))))
+
+  (testing "should return nil if no headers match"
+    (is (= nil (acceptable-content-type "text/html" "text/plain, application/json")))
+    (is (= nil (acceptable-content-type "text/html" "text/plain, application/*")))))