correct implementation errors

correct implementation errors

--- src/clj_money/models/commodities.clj
+++ src/clj_money/models/commodities.clj
@@ -26,21 +26,35 @@
   [(coercion/rule :integer [:entity-id])])

 (defn- name-is-in-use?
-  [storage {:keys [id entity-id exchange] commodity-name :name}]
+  [storage {:keys [id entity-id exchange] commodity-name :name :as commodity}]
   (when (and commodity-name entity-id exchange)
-                 (->> (select-commodities-by-entity-id
-                        storage
-                        entity-id
-                        {:where {:name commodity-name
-                                 :exchange (name exchange)}})
-                      (remove #(= id (:id %)))
-                      seq)))
+    (->> (select-commodities-by-entity-id
+           storage
+           entity-id
+           {:where {:name commodity-name
+                    :exchange (name exchange)}})
+         (remove #(= id (:id %)))
+         seq)))
+
+(defn- symbol-is-in-use?
+  [storage {:keys [id entity-id exchange] commodity-symbol :symbol}]
+  (when (and commodity-symbol entity-id exchange)
+    (->> (select-commodities-by-entity-id
+           storage
+           entity-id
+           {:where {:symbol commodity-symbol
+                    :exchange (name exchange)}})
+         (remove #(= id (:id %)))
+         seq)))

 (defn- validation-rules
   [storage]
-  [(validation/create-rule #(complement (name-is-in-use? storage %))
+  [(validation/create-rule (complement (partial name-is-in-use? storage))
                            [:name]
-                           "Name must be unique for a given exchange")])
+                           "Name must be unique for a given exchange")
+   (validation/create-rule (complement (partial symbol-is-in-use? storage))
+                           [:symbol]
+                           "Symbol must be unique for a given exchange")])

 (defn- before-validation
   [commodity]


[TEMP COMMIT] Remove all 'fake' lessons on drag stop

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

--- src/cljs/cljs_nusmods/timetable.cljs
+++ src/cljs/cljs_nusmods/timetable.cljs
@@ -472,6 +472,8 @@

 ; Forward declaration
 (declare add-module-lesson-group)
+(declare timetable-prune-empty-rows)
+(declare add-missing-td-elements-replacing-lesson)

 (defn- lesson-draggable-start-evt-handler-maker
   "Returns a function that can be used as the `start` event handler for a
@@ -492,10 +494,11 @@
           ; Add all the <div> elements
           augmentedTTLessonInfoSeq
           (doall
-            (map (fn [[lessonGroup _]]
-                   (add-module-lesson-group moduleCode lessonType lessonGroup
-                                            bgColorCssClass false))
-                 unselectedLessonGroupsMap))]
+            (flatten
+              (map (fn [[lessonGroup _]]
+                     (add-module-lesson-group moduleCode lessonType lessonGroup
+                                              bgColorCssClass false))
+                   unselectedLessonGroupsMap)))]
       (set! Lessons-Created-By-Draggable augmentedTTLessonInfoSeq))))

 ; TODO: Account for a user dropping the draggable lesson onto a different lesson
@@ -504,40 +507,29 @@
   "Returns a function used as the `stop` event handler for a draggable lesson."
   []
   (fn [evt ui]
-    (let [$divElemSeq (map #(:divElem %1) Lessons-Created-By-Draggable)
-
-          daysAndRowsAffected
-          (reduce (fn [dayVec ttLessonInfo]
-                    (update-in dayVec [(:day ttLessonInfo)]
-                               (fn [rowSet]
-                                 (conj rowSet (:rowNum ttLessonInfo)))))
-                  [#{} #{} #{} #{} #{}]
-                  Lessons-Created-By-Draggable)
-
-          ; This should not be placed here.
-          ; We should only remove such rows after we update the `Timetable`
-          ; global
-          emptyRowsToRemove
-          (map (fn [[day rowSet]]
-                 (let [ttDay (get-timetable-day day)]
-                   [day,
-                    (sort > (filter (fn [rowNum]
-                                      (and (> rowNum 1)
-                                           (zero? (count (nth ttDay rowNum)))))
-                                    rowSet))]))
-               (map vector (range (count daysAndRowsAffected))
-                    daysAndRowsAffected))]
+    (let [affectedDaysSet
+          (reduce (fn [daySet ttLessonInfo]
+                    (conj daySet (:day ttLessonInfo)))
+                  #{}
+                  Lessons-Created-By-Draggable)]
+
       (doseq [augTTLessonInfo Lessons-Created-By-Draggable]
         (timetable-remove-lesson (:day augTTLessonInfo)
                                  (:rowNum augTTLessonInfo)
                                  (dissoc augTTLessonInfo :divElem :day
                                          :rowNum)))
-      (doseq [$divElem $divElemSeq]
-        (.remove $divElem))
-      (doseq [[day rowsToRemove]]
-        (s)
-        )
-      )))
+
+      (doseq [augTTLessonInfo Lessons-Created-By-Draggable]
+        (let [$divElem  (:divElem augTTLessonInfo)
+              $parentTd (parent $divElem)]
+          ; TODO: This part of the code is the same as in the
+          ;       `remove-lesson-group-html` function. Refactor it.
+          (remove-attr $parentTd "colspan")
+          (.remove $divElem)
+          (add-missing-td-elements-replacing-lesson $parentTd augTTLessonInfo)))
+
+      (timetable-prune-empty-rows affectedDaysSet)
+      (set! Lessons-Created-By-Draggable nil))))

 ; TODO: Make lesson type with only a single lessongroup non-draggable
 (defn- make-added-lessons-draggable
@@ -609,8 +601,8 @@
                         (get-selected-module-codes-as-js-array))))

                 (make-added-lessons-draggable $divElemSeq moduleCode lessonType
-                                              lessonLabel bgColorCssClass)
-                augLessonInfoSeq))))))
+                                              lessonLabel bgColorCssClass)))
+          augLessonInfoSeq))))

 (defn add-module
   "Adds a module to the timetable.


improved award widget

improved award widget

--- src/cljs/iwaswhere_web/ui/award.cljs
+++ src/cljs/iwaswhere_web/ui/award.cljs
@@ -8,9 +8,10 @@
   "Renders bars."
   [stats]
   (let [chart-h 22
-        indexed (map-indexed (fn [idx [day v]] [idx [day v]]) stats)
-        daily-totals (map (fn [[_ [d v]]] (h/add (:task v) (:habit v))) indexed)
-        max-val (apply max daily-totals)]
+        daily-totals (map (fn [[d v]] (h/add (:task v) (:habit v))) stats)
+        max-val (apply max daily-totals)
+        indexed (map-indexed (fn [idx [day v]] [idx [day v]])
+                             (take-last 14 stats))]
     [:svg
      [:g
       (for [[idx [day v]] indexed]


Auto-require namespaces necessary for EDN deserialization.

--- src/clojure/parkour/remote/basic.clj
+++ src/clojure/parkour/remote/basic.clj
@@ -2,8 +2,12 @@
   {:private true}
   (:require [clojure.string :as str]
             [clojure.edn :as edn]
-            [parkour (conf :as conf) (fs :as fs)]
+            [parkour (conf :as conf)]
             [parkour.util :refer [doto-let]]))
+
+(defn ^:private require-readers
+  "Require the namespaces of all `*data-readers*` vars."
+  [] (doseq [[_ v] *data-readers*] (-> v .-ns ns-name require)))

 (defn ^:private step-f-args
   ([conf key]
@@ -11,8 +15,9 @@
            [ns sym] (str/split fqname #"/" 2)
            ns (symbol (if-not (.startsWith ^String ns "#'") ns (subs ns 2)))
            f (do (require ns) (ns-resolve ns (symbol sym)))
-           args (some->> (conf/get conf (str "parkour." key ".args"))
-                         (edn/read-string {:readers *data-readers*}))]
+           args (do (require-readers)
+                    (some->> (conf/get conf (str "parkour." key ".args"))
+                             (edn/read-string {:readers *data-readers*})))]
        [f args]))
   ([conf kind id]
      (step-f-args conf (str kind "." id))))


Finished adding vector instructions

Finished adding vector instructions

--- src/clojush/instructions/vectors.clj
+++ src/clojush/instructions/vectors.clj
@@ -393,18 +393,21 @@
 (define-registered vector_boolean_replacefirst (replacefirster :vector_boolean :boolean))
 (define-registered vector_string_replacefirst (replacefirster :vector_string :string))

-
-
-
-;
-;(define-registered
-;  string_removechar ; In top string on stack, remove all occurences of char
-;  (fn [state]
-;    (if (and (not (empty? (:string state)))
-;             (not (empty? (:char state))))
-;      (let [result (apply str (remove #{(stack-ref :char 0 state)}
-;                                      (stack-ref :string 0 state)))]
-;        (push-item result
-;                   :string
-;                   (pop-item :char (pop-item :string state))))
-;      state)))
+(defn removeer
+  "Returns a function that takes a state and removes all occurrences of the first lit-type item
+   in the top type vector."
+  [type lit-type]
+  (fn [state]
+    (if (or (empty? (type state))
+            (empty? (lit-type state)))
+      state
+      (let [result (vec (remove #(= % (top-item lit-type state))
+                                (top-item type state)))]
+        (push-item result
+                   type
+                   (pop-item lit-type (pop-item type state)))))))
+
+(define-registered vector_integer_remove (removeer :vector_integer :integer))
+(define-registered vector_float_remove (removeer :vector_float :float))
+(define-registered vector_boolean_remove (removeer :vector_boolean :boolean))
+(define-registered vector_string_remove (removeer :vector_string :string))


Build the ResponseObject properly, with the missing :schema key

--- src/io/aviso/rook/swagger.clj
+++ src/io/aviso/rook/swagger.clj
@@ -204,8 +204,8 @@
                                           ;; description is required in the Response Object, so we need some default here.
                                           "Documentation not provided.")
                           [so' schema-reference] (to-schema-reference swagger-options so schema)
-                          response (assoc schema-reference
-                                     :description description)]
+                          response (remove-nil-vals {:description description
+                                                     :schema      schema-reference})]
                       (assoc-in so' (concat paths-key [:responses status-code]) response))))]
     (reduce reducer swagger-object responses)))


Made get-input more robust

Made get-input more robust

Signed-off-by: Stefan Marr <46f1a0bd5592a2f9244ca321b129902a06b53e03@stefan-marr.de>

--- Clojure/src/snake/terminal_reader.clj
+++ Clojure/src/snake/terminal_reader.clj
@@ -8,7 +8,9 @@
   (if (.ready input-reader)
     (do
       (def num-chars-read (.read input-reader buffer))
-      (String/valueOf buffer 0 num-chars-read))
+      (if (= num-chars-read -1)
+          ""
+          (String/valueOf buffer 0 num-chars-read)))
     ""))


misc(frontend): remove builtins icons from initial state

--- frontend/src/uxbox/main/state.cljs
+++ frontend/src/uxbox/main/state.cljs
@@ -23,7 +23,7 @@
    :workspace nil
    :images-collections nil
    :images nil
-   :icons-collections icons/collections
+   :icons-collections nil
    :icons nil
    :colors-collections colors/collections
    :shapes nil


add a function, read-page #26

add a function, read-page #26

--- src/kalar_plugins/templates/page.clj
+++ src/kalar_plugins/templates/page.clj
@@ -40,8 +40,15 @@
           output (new StringWriter)
           metadata (md/md-to-html input outpu :parse-meta? true :heading-anchors true)
           body (.toString output)]
-      (merge metadata {:body body}))
-    ))
+      (merge metadata {:body body}))))
+
+(defn- read-page
+  ([page] (load-md page)) ; add link
+  ([page lang-cd]
+    (let [loaded-md (load-md page)]
+      (assoc loaded-md :link (str "/" lang-cd (:link loaded-md))))))
+
+

 (defn load-md-excerpt [^String md]
   (let [compiled (load-markdown md)


Fix merge.

Fix merge.

--- src/kixi/hecuba/api/measurements.clj
+++ src/kixi/hecuba/api/measurements.clj
@@ -32,17 +32,20 @@
         {:keys [device-id
                 reading-type]} route-params
         decoded-params         (util/decode-query-params query-string)
-        formatter              (java.text.SimpleDateFormat. "dd-MM-yyyy HH:mm")
-        start-date             (.parse formatter (string/replace (get decoded-params "startDate") "%20" " "))
-        end-date               (.parse formatter (string/replace (get decoded-params "endDate") "%20" " "))
+        start-date             (to-db-format (string/replace (get decoded-params "startDate") "%20" " "))
+        end-date               (to-db-format (string/replace (get decoded-params "endDate") "%20" " "))
         measurements           (hecuba/items querier :measurement [[= :device-id device-id]
                                                                    [= :type reading-type]
                                                                    [= :month (util/get-month-partition-key start-date)]
                                                                    [>= :timestamp start-date]
                                                                    [<= :timestamp end-date]])]
-    (->> measurements
-         (map #(update-in % [:timestamp] str))
-         (util/render-item request))))
+    (util/downcast-to-json {:measurements (->> measurements
+                                               (map (fn [m]
+                                                      (-> m
+                                                          (update-in [:value] (when-not (empty? (:value m)) read-string))
+                                                          (update-in [:timestamp] db-to-iso)
+                                                          (dissoc :month :metadata :device-id (when-not (empty? (:value m)) :error))
+                                                          util/camelify))))})))

 (defn index-post! [commander querier queue ctx]
   (let [request      (:request ctx)


reordered posts display

reordered posts display

* put "New Post" + bookmarklet at the top of the page
* disaply the post directly rather than in a ul

--- instapapure.clj
+++ instapapure.clj
@@ -74,11 +74,12 @@
 (defn show-posts []
   (layout "All Posts"
     (html
-      [:ul
-        (map display-post (select-posts))]
-      [:a {:href "/post"} "New Post"]
-      [:p "Drag the bookmarklet: "
-        [:a {:href bookmarklet} "Read later"]])))
+      [:p
+        [:a {:href "/post"} "New Post"]]
+      [:p
+        "Drag the bookmarklet: "
+        [:a {:href bookmarklet} "Read later"]]
+      (map display-post (select-posts)))))

 (defn new-post [location title summary]
   (insert-post location title summary)


refactor(class-keys): fix view/state, add view/props & view/children explicitly

--- re_view/src/re_view/core.cljs
+++ re_view/src/re_view/core.cljs
@@ -59,8 +59,14 @@
   [k]
   (case k
     :constructor "constructor"
-    :view/initial-state "$initialState"
-    :view/state "$state"
+
+    ;; re-view class keys
+    :view/props "re$props"
+    :view/state "re$state"
+    :view/children "re$children"
+    :view/initial-state "re$initialState"
+
+    ;; react class keys
     :view/did-catch "componentDidCatch"
     :view/will-mount "componentWillMount"
     :view/did-mount "componentDidMount"
@@ -71,6 +77,9 @@
     :view/did-update "componentDidUpdate"
     :view/will-unmount "componentWillUnmount"
     :view/render "render"
+
+    ;; fallback to "re$<name>"
+    ;; (you can specify class keys in a view's method map by using the :view/.. namespace)
     (str "re$" (v-util/camelCase (name k)))))

 (defn compseq
@@ -255,7 +264,7 @@
                         ;;    a function, which will be called w/ the component to return initial state.
                         ;;    the initial value is wrapped in an atom.

-                        (when-let [initial-state (gobj/get component "$initialState")]
+                        (when-let [initial-state (.-re$initialState component)]
                           (atom (cond-> initial-state (fn? initial-state) (apply component children))))

                         ;; 3. in the component's methods map, can specify :view/state directly. Must be


Shows alert before deleting documents

Shows alert before deleting documents

--- src/wordsmith/core.cljs
+++ src/wordsmith/core.cljs
@@ -56,7 +56,9 @@
     (put! (:channel @app) [:change title])))

 (defn delete-click [title app]
-  (put! (:channel @app) [:remove title]))
+  (let [response (js/confirm "Are you sure?")]
+    (when response
+      (put! (:channel @app) [:remove title]))))

 (defn left-menu [app owner]
   (reify


Comments

Comments

--- src/acyclic/awstools/core.clj
+++ src/acyclic/awstools/core.clj
@@ -16,16 +16,17 @@

 (def cred (read-string (slurp "AWS.clj")))
-
 (apply defcredential (map cred [:access-key :secret-key :endpoint]))

 (defn s->b64 [s] (String. (b64/encode (.getBytes s))))
-
 (defn b64->s [s] (String. (b64/decode (.getBytes s))))
-
 (defn- m->pair [[_ k v]] [(keyword k) v])
-
-(defn b64->ec2-data [s]
+(defn b64->ec2-data
+  "Given a base-64 encoded message of the form
+     field1: some data
+     field2: some other data
+return a map of the form {:field1 \"some data\" :field2: \"some other data}."
+  [s]
   (let [xs  (-> s b64->s clojure.string/split-lines)
         es  (map #(->> %
                        (re-matches #"^([\w\-]+):\s*(.*)")
@@ -33,7 +34,9 @@
     (into {} es)))

 (defn chan->seq
-  "Drains a channel onto a lazy sequence.  Blocks internally."
+  "Drains a channel onto a lazy sequence.  If the optional terminate?
+argument is true, it will return immediately with whatever is currently
+available on the channel; otherwise it will block until data is available."
   [c & [terminate?]]
   (lazy-seq
    (when-let [v (if terminate?
@@ -42,14 +45,6 @@
      (cons v (chan->seq c terminate?)))))

-(def ^{:private true} paths {:zone  [:launch-specification :placement :availability-zone]
-                             :itype [:launch-specification :instance-type]
-                             :subnet [:launch-specification :instance-network-interface-specification 0 :subnet-id]
-                             :group [:launch-specification :network-interfaces 0 :groups 0]
-                             :public? [:launch-specification :network-interfaces 0 :associate-public-ip-address]
-                             :price [:spot-price]
-                             :n     [:instance-count]
-                             :udata [s->b64 :launch-specification :user-data]})

 (def my-ec2-info nil)
@@ -67,6 +62,48 @@
   nil
   )

+(comment  ;; typical contents of the ec2 data file
+{
+ :sqs-url "https://sqs.us-east-1.amazonaws.com/633840533036/instance-status"
+ :sns-topic "arn:aws:sns:us-east-1:633840533036:instance-up"
+ :region "us-east-1"
+ :vpc "vpc-e2299f87"
+ :subnet-public "subnet-7482935c"
+ :subnet-private "subnet-7382935b"
+ :route-table-public "rtb-68c0770d"
+ :route-table-private "rtb-6ec0770b"
+ :nat-id "i-8a0e1565"
+ :template-id "i-7c949193"
+ :req {:spot-price 0.01,
+                :instance-count 1,
+                :type "one-time",
+                :launch-specification  {:image-id "ami-ec70d384",
+                                        :instance-type "t1.micro",
+                                        :placement  {:availability-zone "us-east-1a"},
+                                        :key-name "telekhine",
+                                        :network-interfaces
+                                        [{:device-index 0
+                                          :subnet-id "subnet-7482935c"
+                                          ;;:associate-public-ip-address true
+                                          :groups ["sg-f8fea59d"]}]
+                                        :iam-instance-profile {:arn "arn:aws:iam::633840533036:instance-profile/girder-peer"}}}
+ :subnets {"us-east-1a"  "subnet-7482935c"}
+}
+
+)
+
+
+;; Pinhole paths into ec2 request map:
+(def ^{:private true} paths
+  {:zone    [:launch-specification :placement :availability-zone]
+   :itype   [:launch-specification :instance-type]
+   :subnet  [:launch-specification :instance-network-interface-specification 0 :subnet-id]
+   :group   [:launch-specification :network-interfaces 0 :groups 0]
+   :public? [:launch-specification :network-interfaces 0 :associate-public-ip-address]
+   :price   [:spot-price]
+   :n       [:instance-count]
+   :udata   [s->b64 :launch-specification :user-data]})
+

 (defn cmd-timeout [sec cmd & args]
   (let [cc (go (apply cmd args))
@@ -76,10 +113,10 @@
       (do (debug "cmd" args "timed out after" sec) nil))))

 (defn sqs-listen
-  "Listen on an SQS queue, sending messages to a channel, which is returned."
+  "Listen on an SQS queue, forwarding  messages to a channel, which is returned."
  [& [url]]
   (let [url (or url my-sqs-url)
-        c   (chan)]
+        c   (chan 100)]
     (async/go-loop []
       (if (pimpl/closed? c)
         (debug "Shutting down sqs-listen" url)
@@ -95,16 +132,6 @@
           (recur))))
     c))

-(defmacro go-try [& forms]
-  `(go (try (do ~@forms)
-            (catch Exception e#
-              (do (debug "Caught exception" e#) nil)))))
-
-(defn request-status [rs]
-  (let [d    (cmd-timeout 5 describe-spot-instance-requests :spot-instance-request-ids rs)
-        sirs (:spot-instance-requests d)
-        _    (debug "Request statuses" rs d sirs)]
-    (map :state sirs)))

 (defn instance-info-map
   "Returns map of instance-id to map of information about instance."
@@ -118,7 +145,11 @@
                        [:host [:public-dns-name #(when (seq %) %)]]])) ims)]
     (mseq->m xms :instance-id)))

-(defn request-info-map [ids]
+(defn request-info-map
+  "Returns a map of request-id to map of request-id to a map of information
+about the request.  If an instance-id is available, the instance-info-map data
+will be merged in."
+  [ids]
   (let [descs  (describe-spot-instance-requests :spot-instance-request-ids ids)
         sirs   (:spot-instance-requests descs)
         sirs   (map (fn [rm] (m-section rm [[:request-id :spot-instance-request-id] :state :instance-id])) sirs)
@@ -155,7 +186,9 @@
     t))

-(defn cancel-requests [rs]
+(defn cancel-requests
+  "Cancel the specified requests; if instance-id information is available, also stops the instances."
+  [rs]
   (let [ds (:spot-instance-requests (describe-spot-instance-requests :spot-instance-request-ids rs))
         is (filter (complement nil?) (map :instance-id ds))
         cr (:cancelled-spot-instance-requests (cancel-spot-instance-requests :spot-instance-request-ids rs))
@@ -165,7 +198,10 @@

 (def ids->chs (atom {}))

-(defn notify-chan [id]
+(defn- notify-chan
+  "Return a channel that will receive status information extracted from send-up messages
+with the specified id.  See b64->ec2-data."
+  [id]
   (let [c (chan)]
     (swap! ids->chs assoc id c)
     c))
@@ -196,24 +232,21 @@
     ctl))

-;;aws --region us-east-1 sns publish --topic-arn  arn:aws:sns:us-east-1:633840533036:instance-up --message yowsassl
-
-(defn send-up [id & {topic :topic region :region}]
+(defn send-up
+  "Creates an aws command to send a coded SNS message indicating that the instance is up.
+The message incorporates the id argument as well as some fields from the ec2-metadata utility
+and resembles the base 64 encoding of:
+    id: 50b190c0-67d5-407d-aa48-b031c11a4521
+    instance-id: i-a0d5204e
+    public-hostname: ec2-54-85-255-39.compute-1.amazonaws.com
+    cal-ipv4: 10.0.49.210
+See b64->ec2-data."
+  [id & {topic :topic region :region}]
   (str
    "aws --region " (or region my-region)
    " sns publish --topic-arn " (or topic my-sns-topic)
    " --message `(echo \"id: " id "\";bin/ec2-metadata -i -p -o) | base64 -w 0`"
    "\n"))
-
-;(stop-instances :instance-ids ["i-7c949193"])
-;(modify-instance-attribute :instance-id "i-7c949193" :user-data (s->b64 "echo hello"))
-
-(defn good-strings [vs]
-  (and (sequential?  vs)
-       (every? string? vs)
-       (every? pos? (map count vs))))
-
-

 (defn- really-up? [rs->info rs]
   (let [info (get rs->info rs)]
@@ -222,7 +255,11 @@
      (string? (:ip info))
      (pos? (count (:ip info))))))

-(defn bring-up-spots  [reqmap nmin cmds & opts]
+(defn bring-up-spots
+  "Bring up at least nmin instances as specified by reqmap.  The sequence
+of cmds will be excecuted at startup.  Any other request-spot-instance arguments
+can be specified optionally."
+  [reqmap nmin cmds & opts]
   (let [id  (.toString (UUID/randomUUID))
         cmd (str (send-up id) (clojure.string/join "\n" cmds) "\n")
         req (apply ph-assoc reqmap paths opts)


Fix defn in preparation for Clojure 1.9

Fix defn in preparation for Clojure 1.9

--- src/afterglow/effects/fun.clj
+++ src/afterglow/effects/fun.clj
@@ -726,9 +726,9 @@
   at the origin. For efficiency, the measure cannot be frame dynamic,
   and is evaluated when the effect is created."
   [fixtures & {:keys [color fraction measure]
-               :or {:color (colors/create-color :white)
-                    :fraction 0
-                    :measure (transform/build-distance-measure 0 0 0)}}]
+               :or {color (colors/create-color :white)
+                    fraction 0
+                    measure (transform/build-distance-measure 0 0 0)}}]
     (let [color (params/bind-keyword-param color :com.evocomputing.colors/color (colors/create-color :white))
           fraction (params/bind-keyword-param fraction Number 0)
           measure (params/resolve-param (params/bind-keyword-param measure :afterglow.transform/distance-measure
@@ -993,5 +993,3 @@
                           (fx/chase "Pinstripe" effects pin-step :beyond :loop)))
                       (range) stripes)]
       (apply fx/scene "Pinstripes" chases))))
-
-


comment out sub-beta placeholder

comment out sub-beta placeholder

--- src-cljs/frontend/components/account.cljs
+++ src-cljs/frontend/components/account.cljs
@@ -156,9 +156,10 @@

 (def available-betas
-  [{:id "insights"
-    :name "Insights"
-    :description "Also this text. Insights is super fun for the whole family! "}])
+  [;; {:id "insights"
+   ;;  :name "Insights"
+   ;;  :description "Also this text. Insights is super fun for the whole family! "}
+   ])

 (defn set-beta-preference! [owner betas id value]
   (raise! owner [:preferences-updated {state/user-betas-key


procfiles/altcrawl.clj: simple logging & counting

--- src/org/altlaw/jobs/pre/altcrawl.clj
+++ src/org/altlaw/jobs/pre/altcrawl.clj
@@ -1,73 +1,92 @@
 (ns org.altlaw.jobs.pre.altcrawl
   (:require [org.altlaw.util.hadoop :as hadoop]
+            [org.altlaw.util.files :as files]
+            [org.altlaw.util.tsv :as tsv]
             [clojure.contrib.walk :as walk])
   (:use clojure.contrib.json.read
         org.altlaw.util.log)
-  (:import (org.apache.commons.codec.binary Base64)
-           (java.util Arrays)))
+  (:import (org.apache.commons.codec.binary Base64)))

 (hadoop/setup-mapreduce)

 (declare *reporter*)

-(defn- get-bytes [download]
-  (Base64/decodeBase64
-   (.getBytes (:response_body_base64 download)
-              "UTF-8")))
+(defn counter [group name]
+  (.incrCounter *reporter* group name 1))

-(defn- guess-mime-type
-  "Attempts to guess the MIME type of the data in a byte array.
-  Recognizes PDF and HTML.  Returns nil if it can't recognize the
-  type."
-  [bytes]
-  (let [magic (String. (Arrays/copyOf bytes 4) "UTF-8")]
-    (cond (= "%PDF" magic) "application/pdf"
-          (.contains magic "<") "text/html"
-          :else nil)))
+(def *docid-map* (ref {}))

-(defmulti handle-download
-  (fn [download] (guess-mime-type (get-bytes download))))
+(defn get-docid [uri]
+  (get @*docid-map* uri))

-(defmethod handle-download :default [download]
-  (.warn *log* (str "No handler for MIME type of "
-                    (:request_uri download))))
+(defn- decode-response-body [download]
+  (assoc download :response_body_bytes
+         (Base64/decodeBase64
+          (.getBytes (:response_body_base64 download) "UTF-8"))))

-(defmethod handle-download "application/pdf" [download]
-  (.debug *log* (str "handle-download got PDF from "
-                    (:request_uri download))))
+;;; Step 2: dispatch on MIME type of the download

-(defmethod handle-download "text/html" [download]
-  (.debug *log* (str "handle-download got HTML from "
-                    (:request_uri download))))
+(defmulti mime-type-dispatch
+  (fn [download]
+    (files/guess-mime-type-by-content (:response_body_bytes download))))

-(defmulti my-map
-  (fn [data]
-    (cond (contains? data :request_uri) :download
-          (contains? data :doctype) :metadata)))
+(defmethod mime-type-dispatch "application/pdf" [download]
+  (counter "MIME types" "PDF")
+  (debug "mime-type-dispatch got PDF from " (:request_uri download)))

-(defmethod my-map :download [data]
-  (let [uri (:request_uri data)
-        status (:response_status_code data)]
-    (.debug *log* (str "my-map got download from " uri))
-    (if (= 200 status)
-      (handle-download data)
-      (.warn *log* (str "my-map saw HTTP error " status
-                        " from " uri)))))
+(defmethod mime-type-dispatch "text/html" [download]
+  (counter "MIME types" "HTML")
+  (debug "mime-type-dispatch got HTML from " (:request_uri download)))

-(defmethod my-map :metadata [data]
-  (.debug *log* (str "my-map got metadata for "
-                     (:name data))))
+(defmethod mime-type-dispatch :default [download]
+  (counter "MIME types" "unknown")
+  (warn "mime-type-dispatch found no handler for " (:request_uri download)))
+
+
+;;; Step 1: dispatch on Status code of the download
+
+(defn status-code-dispatch [download]
+  (counter "Status codes" (str (:response_status_code download)))
+  (if (= 200 (:response_status_code download))
+    (mime-type-dispatch download)
+    (warn "status-code-dispatch saw "
+          (:response_status_code download)
+          " from " (:request_uri download))))
+
+
+(defn my-map [download]
+  (status-code-dispatch (decode-response-body download)))
+
+
+
+;;; MAPPER METHODS
+
+(defn mapper-configure [this job]
+  (let [cached (DistributedCache/getLocalCacheFiles job)
+        path (first (filter #(= (.getName %) "docids.tsv.gz") cached))]
+    (when (nil? path) (throw (RuntimeException. "No docid.tsv.gz in DistributedCache.")))
+    (info "Loading docid map from " path)
+    (dosync (ref-set *docid-map* (tsv/load-tsv-map (str path))))))

 (defn mapper-map [this wkey wvalue output reporter]
     (let [input (walk/keywordize-keys (read-json-string (str wvalue)))]
-      (.debug *log* (str "Called map with file position " wkey
-                         " and value " (logstr input)))
+      (debug "Called map with file position " wkey
+             " and value " (logstr input))
       (binding [*reporter* reporter]
         (doseq [[key value] (my-map input)]
           (.collect output (Text. key) (Text. value))))))

-(defn reducer-reduce [this wkey wvalues output reporter]
-  (.debug *log* (str "Called reduce with key " wkey)))
+
+
+;;; REDUCER METHODS
+
+(defn reducer-reduce [this wkey values-iter output reporter]
+  (debug "Called reduce with key " wkey " and "
+         (count (iterator-seq values-iter)) " values."))
+
+
+
+;;; TOOL METHODS

 (defn tool-run [this args]
   (let [job (hadoop/default-jobconf this)
@@ -81,5 +100,6 @@
     (.setMapperClass job (Class/forName "org.altlaw.jobs.pre.altcrawl_mapper"))
     (.setReducerClass job (Class/forName "org.altlaw.jobs.pre.altcrawl_reducer"))
     (.setMapOutputKeyClass job Text)
+    (DistributedCache/addCacheFile (URI. (hadoop/docid-path :seqfiles :ohm1)) job)
     (JobClient/runJob job))
   0)


websockets: Minor bug fixes

websockets: Minor bug fixes

* Removed accidental duplicate of routes.
* Close channel in exception handler.
* :error-handler has to be non-first argument to `run-pipeline`.

--- src/riemann/transport/websockets.clj
+++ src/riemann/transport/websockets.clj
@@ -71,14 +71,14 @@
                                    ; latency
                                    (let [t1 (System/nanoTime)]
                                      (run-pipeline
-                                       {:error-handler (fn [_] (close ch))}
                                        (enqueue ch (event-to-json event))
                                        ; When the write completes, measure
                                        ; latency
                                        (fn measure [_]
                                          (metrics/update!
                                            (:out stats)
-                                           (- (System/nanoTime) t1)))))))
+                                           (- (System/nanoTime) t1)))
+                                       {:error-handler (fn [_] (close ch))}))))

                                true)]
       (info "New websocket subscription to" topic ":" query)
@@ -188,16 +188,10 @@
           (info "Unknown URI " (:uri req) ", closing")
           (close ch)))

-    ; Route request
-    (condp re-matches (:uri req)
-      #"/events/?"       (put-events-handler @core stats ch req)
-      #"/index/?"        (ws-index-handler @core stats ch req)
-      #"/pubsub/[^/]+/?" (ws-pubsub-handler @core stats ch req)
-      (do
-        (info "Unknown URI " (:uri req) ", closing")
-        (close ch)))
       (catch Throwable t
-        (warn t "ws-handler caught; closing websocket connection.")))))
+        (do
+          (warn t "ws-handler caught; closing websocket connection.")
+          (close ch))))))

 (defrecord WebsocketServer [host port core server stats]
   ServiceEquiv


Use the correct group chat id

Use the correct group chat id

--- src/status_im/protocol/handlers.cljs
+++ src/status_im/protocol/handlers.cljs
@@ -121,13 +121,12 @@
   (fn [processed-message]
     (processed-messages/save processed-message)))

-(defn system-message
-  ([message-id timestamp content]
-   {:from         "system"
-    :message-id   message-id
-    :timestamp    timestamp
-    :content      content
-    :content-type constants/text-content-type}))
+(defn system-message [message-id timestamp content]
+  {:from         "system"
+   :message-id   message-id
+   :timestamp    timestamp
+   :content      content
+   :content-type constants/text-content-type})

 (re-frame/reg-fx
   ::participant-removed-from-group-message
@@ -499,8 +498,10 @@
          {:keys [group-id timestamp message-id]} :payload}]]
     (when (and (not= current-public-key from)
                chats-is-active-and-timestamp)
-      {::participant-left-group-message {:group-id group-id :from from :message-id message-id
-                                         :timestamp timestamp}
+      {::participant-left-group-message {:chat-id    group-id
+                                         :from       from
+                                         :message-id message-id
+                                         :timestamp  timestamp}
        ::chats-remove-contact [group-id from]
        :db (update-in db [:chats group-id :contacts]
                       #(remove (fn [{:keys [identity]}]


+(deftest conjugate-irregular)

+(deftest conjugate-irregular)

--- test/babel/test/fr.cljc
+++ test/babel/test/fr.cljc
@@ -375,6 +375,14 @@
                                                  :number :sing}}}}})
          "blesses")))

+(deftest conjugate-irregular
+  (is (= (conjugate "boire"
+                    {:synsem {:infl :present
+                              :subcat {:1 {:agr {:person :1st
+                                                 :number :plur}}}}}
+                    @lexicon)
+         "buvons")))
+
 (deftest have-fun
   (let [have-fun-expression
         (generate


whitespace

whitespace

--- test/babel/test/it.cljc
+++ test/babel/test/it.cljc
@@ -140,8 +140,8 @@
                    println))))
     (-> "loro vedono casa"
         parse
-        first
-        (get :parses)
+        ((fn [tokenizations]
+           (mapcat :parses tokenizations)))
         first
         (get-in [:synsem :sem])
         clojure.pprint/pprint)))


[CS DC] Break out `make-tables` for REPL sanity

--- src/vip/data_processor/db/sqlite.clj
+++ src/vip/data_processor/db/sqlite.clj
@@ -13,6 +13,38 @@
   `(-> (korma/create-entity ~(name ent))
        ~@body))

+(defn make-tables [db]
+  {:elections (entity :elections (korma/database db))
+   :sources (entity :sources (korma/database db))
+   :states (entity :states (korma/database db))
+   :election-administrations (entity :election_administrations (korma/database db))
+   :election-officials (entity :election_officials (korma/database db))
+   :localities (entity :localities (korma/database db))
+   :precincts (entity :precincts (korma/database db))
+   :precinct-splits (entity :precinct_splits (korma/database db))
+   :precinct-split-electoral-districts (entity :precinct_split_electoral_districts (korma/database db))
+   :early-vote-sites (entity :early_vote_sites (korma/database db))
+   :precinct-polling-locations (entity :precinct_polling_locations (korma/database db))
+   :polling-locations (entity :polling_locations (korma/database db))
+   :street-segments (entity :street_segments (korma/database db))
+   :electoral-districts (entity :electoral_districts (korma/database db))
+   :contests (entity :contests (korma/database db))
+   :ballots (entity :ballots (korma/database db))
+   :ballot-responses (entity :ballot_responses (korma/database db))
+   :referendums (entity :referendums (korma/database db))
+   :referendum-ballot-responses (entity :referendum_ballot_responses (korma/database db))
+   :candidates (entity :candidates (korma/database db))
+   :ballot-candidates (entity :ballot_candidates (korma/database db))
+   :state-early-vote-sites (entity :state_early_vote_sites (korma/database db))
+   :precinct-split-polling-locations (entity :precinct_split_polling_locations (korma/database db))
+   :precinct-electoral-districts (entity :precinct_electoral_districts (korma/database db))
+   :precinct-early-vote-sites (entity :precinct_early_vote_sites (korma/database db))
+   :locality-early-vote-sites (entity :locality_early_vote_sites (korma/database db))
+   :custom-ballot-ballot-responses (entity :custom_ballot_ballot_responses (korma/database db))
+   :custom-ballots (entity :custom_ballots (korma/database db ))
+   :contest-results (entity :contest_results (korma/database db))
+   :ballot-line-results (entity :ballot_line_results (korma/database db))})
+
 (defn temp-db [upload-filename]
   (let [temp-file (create-temp-db-file upload-filename)
         url (str "jdbc:sqlite:" temp-file)
@@ -21,36 +53,7 @@
                         :url url}
                    :migrator "resources/processing-migrations"})
     {:db db
-     :tables {:elections (entity :elections (korma/database db))
-              :sources (entity :sources (korma/database db))
-              :states (entity :states (korma/database db))
-              :election-administrations (entity :election_administrations (korma/database db))
-              :election-officials (entity :election_officials (korma/database db))
-              :localities (entity :localities (korma/database db))
-              :precincts (entity :precincts (korma/database db))
-              :precinct-splits (entity :precinct_splits (korma/database db))
-              :precinct-split-electoral-districts (entity :precinct_split_electoral_districts (korma/database db))
-              :early-vote-sites (entity :early_vote_sites (korma/database db))
-              :precinct-polling-locations (entity :precinct_polling_locations (korma/database db))
-              :polling-locations (entity :polling_locations (korma/database db))
-              :street-segments (entity :street_segments (korma/database db))
-              :electoral-districts (entity :electoral_districts (korma/database db))
-              :contests (entity :contests (korma/database db))
-              :ballots (entity :ballots (korma/database db))
-              :ballot-responses (entity :ballot_responses (korma/database db))
-              :referendums (entity :referendums (korma/database db))
-              :referendum-ballot-responses (entity :referendum_ballot_responses (korma/database db))
-              :candidates (entity :candidates (korma/database db))
-              :ballot-candidates (entity :ballot_candidates (korma/database db))
-              :state-early-vote-sites (entity :state_early_vote_sites (korma/database db))
-              :precinct-split-polling-locations (entity :precinct_split_polling_locations (korma/database db))
-              :precinct-electoral-districts (entity :precinct_electoral_districts (korma/database db))
-              :precinct-early-vote-sites (entity :precinct_early_vote_sites (korma/database db))
-              :locality-early-vote-sites (entity :locality_early_vote_sites (korma/database db))
-              :custom-ballot-ballot-responses (entity :custom_ballot_ballot_responses (korma/database db))
-              :custom-ballots (entity :custom_ballots (korma/database db ))
-              :contest-results (entity :contest_results (korma/database db))
-              :ballot-line-results (entity :ballot_line_results (korma/database db))}}))
+     :tables (make-tables db)}))

 (defn column-names
   "Find the names of all columns for a table. Uses a JDBC connection


Don't cache planck.core macros

Don't cache planck.core macros

--- planck-cljs/src/planck/repl.cljs
+++ planck-cljs/src/planck/repl.cljs
@@ -449,9 +449,9 @@
   [cache]
   (s/ends-with? (str (:name cache)) "$macros"))

-(defn cache-eligible?
+(defn ^boolean cache-eligible?
   [name]
-  (not= name 'planck.repl))
+  (not ({'planck.core 'planck.repl} name)))

 (defn form-build-affecting-options
   []


제목 처리 추가

제목 처리 추가


remove big-root

remove big-root

--- src/atom_finder/classifier/macro-operator-precedence.clj
+++ src/atom_finder/classifier/macro-operator-precedence.clj
@@ -2,15 +2,6 @@
 (import '(org.eclipse.cdt.core.dom.ast IASTNode IASTBinaryExpression IASTUnaryExpression IASTExpressionStatement IASTPreprocessorFunctionStyleMacroDefinition))

 (def macro-expansions (comp (memfn getMacroExpansions) root-ancestor))
-(def ap (all-preprocessor atom-finder.constants/big-root))
-
-(->> ap
-    ;(filter (partial instance? IASTPreprocessorFunctionStyleMacroDefinition))
-    (take 100)
-    ;(map #(vector (.getExpansion %1) (.toString (.getName %1))))
-    (map typename)
-    ;pprint
-    )

 (->> "#define f(x) x?x:x
 int main() {


add null pronoun counterpart to "yo"

add null pronoun counterpart to "yo"

--- src/babel/espanol/lexicon.clj
+++ src/babel/espanol/lexicon.clj
@@ -10,7 +10,17 @@
    [dag-unify.core :refer [fail? get-in]]))

 (def lexicon-source
-  {"abandonar" {:synsem {:cat :verb
+  {""
+   [{:synsem {:cat :noun
+              :pronoun true
+              :case :nom
+              :agr {:person :1st
+                    :number :sing}
+              :sem {:human true
+                    :pred :I}
+              :subcat '()}}]
+
+   "abandonar" {:synsem {:cat :verb
                          :sem {:pred :abandon}}}

    "acabar" {:synsem {:cat :verb
@@ -418,7 +428,6 @@
                     :def :def
                     :gender :fem
                     :number :sing}})
-
    "lastimarse"
    (let [subject-semantics (ref {:human true})
          subject-agr (ref :top)]


Remove test I added accidentally

Remove test I added accidentally

--- test/expound/alpha_test.cljc
+++ test/expound/alpha_test.cljc
@@ -28,13 +28,6 @@
             [spec-tools.data-spec :as ds]
             #?(:clj [orchestra.spec.test :as orch.st]
                :cljs [orchestra-cljs.spec.test :as orch.st])))
-
-(deftest int-in-test
-  (binding [s/*explain-out* s/explain-printer]
-    (s/def ::int-in (s/int-in 0 10))
-    (is (s/valid? ::int-in 9))
-    (is (= "11 - failed: (int-in-range? 0 10 %) spec: :expound.alpha-test/int-in\n" (s/explain-str ::int-in 11)))))
-

 ;;;; override specs and add generators
 ;;;; this allows us to load expound with babaska and spartan.spec


make clear-database a function, not a test

--- test/greybear/model_test.clj
+++ test/greybear/model_test.clj
@@ -3,11 +3,9 @@
         [korma.core]
         greybear.model))

-
-(deftest clear-database
+(defn clear-database []
   (teardown)
   (setup))
-

 (deftest user-create
   (clear-database)


Minor change on async support tests.

Minor change on async support tests.

--- test/suricatta/core_test.clj
+++ test/suricatta/core_test.clj
@@ -106,7 +106,8 @@
     (execute ctx "create table foo (n int)")
     (testing "Execute query asynchronously"
       (let [result (<!! (sca/execute ctx "insert into foo (n) values (1), (2)"))]
-        (is (= result (exc/success 2)))))
+        (is (= result (exc/success 2)))
+        (is (= 1 (deref (.-act ctx))))))

     (testing "Fetching query asynchronously"
       (let [ch      (sca/fetch ctx "select * from foo order by n")


Use existing edn-xhr function in validations

--- src/braid/client/gateway/validations.cljs
+++ src/braid/client/gateway/validations.cljs
@@ -1,8 +1,7 @@
 (ns braid.client.gateway.validations
   (:require
     [clojure.string :as string]
-    [ajax.core :refer [ajax-request]]
-    [ajax.edn :refer [edn-request-format edn-response-format]])
+    [braid.client.xhr :as xhr])
   (:import
     [goog.format EmailAddress]))

@@ -51,16 +50,16 @@
         (cb "Your URL can't end with a dash.")
         (cb nil)))
     (fn [url cb]
-      (ajax-request
-        {:uri (str "//" js/window.api_domain "/registration/check-slug-unique")
+      (xhr/edn-xhr
+        {:uri "/registration/check-slug-unique"
          :method :get
-         :format (edn-request-format)
-         :response-format (edn-response-format)
          :params {:slug url}
-         :handler (fn [[_ valid?]]
-                    (if valid?
-                      (cb nil)
-                      (cb "Your group URL is already taken; try another.")))}))]
+         :on-complete (fn [valid?]
+                        (if valid?
+                          (cb nil)
+                          (cb "Your group URL is already taken; try another.")))
+         :on-error (fn [_]
+                     (cb "There was an error checking your URL."))}))]

    :gateway.action.create-group/group-type
    [(fn [type cb]


sources state is a map of id => command-channel

--- src/buyme_aggregation_backend/sources.clj
+++ src/buyme_aggregation_backend/sources.clj
@@ -34,7 +34,7 @@
                                                  :stop :shutdown
                                                  :running))
                          fetch-timer-ch (do
-                                          (println "got a chime")
+                                          (info "got a chime")
                                           :running)))]
         (recur new-state)))
     command-ch))
@@ -43,6 +43,7 @@
   (println "stopping"))

 (defstate sources
-          :start (->> (get-source-settings) (map start-source))
+          :start (->> (get-source-settings)
+                         (map #(vector (:source_id %) (start-source %)))
+                         (into {}))
           :stop (stop-all-sources))
-


CEO-206 Fix verification for emails with '+'

--- src/clj/collect_earth_online/db/users.clj
+++ src/clj/collect_earth_online/db/users.clj
@@ -1,5 +1,6 @@
 (ns collect-earth-online.db.users
-  (:import java.time.format.DateTimeFormatter
+  (:import java.net.URLEncoder
+           java.time.format.DateTimeFormatter
            java.time.LocalDateTime
            java.util.UUID)
   (:require [clojure.string :as str]
@@ -58,7 +59,7 @@
                                    "  %sverify-email?email=%s&passwordResetKey=%s\n\n"
                                    "Kind Regards,\n"
                                    "  The CEO Team")
-                              email email timestamp (get-base-url) email reset-key)]
+                              email email timestamp (get-base-url) (URLEncoder/encode email) reset-key)]
         (call-sql "add_user" email password reset-key)
         (try
           (send-mail email nil nil "Welcome to CEO!" email-msg "text/plain")


Convert lesson 09 to function-first-api

Convert lesson 09 to function-first-api

--- src/cljs/gampg/learn_gamma/lesson_09.cljs
+++ src/cljs/gampg/learn_gamma/lesson_09.cljs
@@ -1,14 +1,10 @@
 (ns gampg.learn-gamma.lesson-09
-  (:require [clojure.string :as s]
-            [gamma.api :as g]
+  (:require [gamma.api :as g]
             [gamma.program :as p]
-            [gamma.tools :as gt]
+            [gamma-driver.api :as gd]
             [gamma-driver.drivers.basic :as driver]
-            [gamma-driver.protocols :as dp]
-            [goog.webgl :as ggl]
             [thi.ng.geom.core :as geom]
-            [thi.ng.geom.core.matrix :as mat :refer [M44]]
-            [thi.ng.geom.webgl.arrays :as arrays]))
+            [thi.ng.geom.core.matrix :as mat :refer [M44]]))

 (def title
   "9. Lots of moving objects")
@@ -123,11 +119,11 @@
                      (geom/rotate-around-axis [0 0 1] (:angle star))
                      (geom/translate [(:distance star) 0 -7])
                      (geom/rotate-around-axis [0 0 -1] (- (:angle star))))]
-          (driver/draw-arrays driver program
-                               (get-data p mv star-vertices texture star-texture-coords (if twinkle?
-                                                                                (:twinkle star)
-                                                                                (:color star)))
-                               {:draw-mode :triangle-strip}))))))
+          (gd/draw-arrays driver (gd/bind driver program
+                                          (get-data p mv star-vertices texture star-texture-coords (if twinkle?
+                                                                                (:twinkle star)
+                                                                                (:color star))))
+                          {:draw-mode :triangle-strip}))))))

 (defn animate [draw-fn step-fn current-value]
   (js/requestAnimationFrame
@@ -165,7 +161,7 @@
   (let [width   (.-clientWidth node)
         height  (.-clientHeight node)
         driver  (driver/basic-driver gl)
-        program (dp/program driver program-source)
+        program program-source
         state   (app-state width height)]
     (reset-gl-canvas! node)
     ;; Set the blending function
@@ -176,10 +172,10 @@
     (.clear gl (bit-or (.-COLOR_BUFFER_BIT gl) (.-DEPTH_BUFFER_BIT gl)))
     (let [image (js/Image.)]
       (aset image "onload"
-            (fn [] (let [texture {:data {:data       image
-                                        :filter     {:min :linear
-                                                     :mag :nearest}
-                                        :flip-y     true
-                                        :texture-id 0}}]
+            (fn [] (let [texture {:data       image
+                                 :filter     {:min :linear
+                                              :mag :nearest}
+                                 :flip-y     true
+                                 :texture-id 0}]
                     (animate (draw-fn gl driver program) tick (assoc-in state [:scene :texture] texture)))))
       (aset image "src" "/images/star.gif"))))


Add validation of user input on client.

Add validation of user input on client.

--- src/cljs/hatnik/web/client/z_actions.cljs
+++ src/cljs/hatnik/web/client/z_actions.cljs
@@ -1,7 +1,9 @@
 (ns hatnik.web.client.z-actions
   (:require [jayq.core :as jq]
             [hatnik.web.client.app-state :as state]
-            [hatnik.web.client.message :as msg])
+            [hatnik.web.client.message :as msg]
+            [hatnik.schema :as schm]
+            [schema.core :as s])
   (:use [jayq.core :only [$]]))

 (defn get-data-from-input [id]
@@ -43,7 +45,7 @@

 (defn ^:export send-new-project-request []
   (let [name (.-value (.getElementById js/document "project-name-input"))]
-    (if (= "" name)
+    (if (s/check schm/Project {:name name})
       (msg/danger "Project name must be not empty!")
       (do
         (.modal ($ :#iModalProject) "hide")
@@ -54,183 +56,122 @@
     (when (= "ok" (get resp "result"))
       (state/update-all-view))))

-(defn send-new-email-action [project-id artifact email email-body]
-  (let [data {:project-id project-id
+
+(defmulti send-new-action #(:type %))
+
+(defmethod send-new-action :email [data-pack]
+  (let [data {:project-id (:project-id data-pack)
               :type "email"
-              :address email
-              :template email-body
-              :library artifact}]
-    (if (or
-         (= "" artifact)
-         (= "" email)
-         (= "" email-body))
-      (msg/danger "Wrong data! Check out fields!")
-
+              :address (:user-email data-pack)
+              :template (:email-template data-pack)
+              :library (:artifact-value data-pack)}]
+    (if (s/check schm/EmailAction data)
+      (msg/danger "Data is wrong! Check out it please.")
       (do
         (.modal ($ :#iModalAddAction) "hide")
         (ajax "/api/actions" "POST" data
               (wrap-error-alert #(create-new-action-callback data %)))))))

-(defn send-new-noop-action [project-id artifact]
-  (let [data {:project-id project-id
-              :type "noop"
-              :library artifact}]
-    (if (= "" artifact)
-      (msg/danger "Wrong data! Check out fields!")
-
+(defmethod send-new-action :noop [data-pack]
+  (let [data {:type "noop"
+              :project-id (:project-id data-pack)
+              :library (:artifact-value data-pack)}]
+    (if (s/check schm/NoopAction data)
+      (msg/danger "Data is wrong! Check out it please.")
       (do
         (.modal ($ :#iModalAddAction) "hide")
         (ajax "/api/actions" "POST" data
               (wrap-error-alert #(create-new-action-callback data %)))))))

-(defn send-new-github-issue-action [project-id repo title body library]
-  (let [data {:project-id project-id
+(defmethod send-new-action :github-issue [data-pack]
+  (let [data {:project-id (:project-id data-pack)
               :type "github-issue"
-              :repo repo
-              :title title
-              :body body
-              :library library}]
-    (if (or (= "" library)
-            (= "" repo)
-            (= "" title))
-      (msg/danger "Wrong data! Check out fields!")
-
+              :repo (:gh-repo data-pack)
+              :title (:gh-issue-title data-pack)
+              :body (:gh-issue-body data-pack)
+              :library (:artifact-value data-pack)}]
+    (if (s/check schm/GithubIssueAction data)
+      (msg/danger "Data is wrong! Check out it please.")
       (do
         (.modal ($ :#iModalAddAction) "hide")
         (ajax "/api/actions" "POST" data
               (wrap-error-alert #(create-new-action-callback data %)))))))

-(defmulti send-new-action #(:type %))
-(defmethod send-new-action :email [data-pack]
-  (send-new-email-action (:project-id data-pack)
-                         (:artifact-value data-pack)
-                         (:user-email data-pack)
-                         (:email-template data-pack)))
-(defmethod send-new-action :noop [data-pack]
-  (send-new-noop-action (:project-id data-pack)
-                        (:artifact-value data-pack)))
-(defmethod send-new-action :github-issue [data-pack]
-  (send-new-github-issue-action (:project-id data-pack)
-                                (:gh-repo data-pack)
-                                (:gh-issue-title data-pack)
-                                (:gh-issue-body data-pack)
-                                (:artifact-value data-pack)))
-
-
-(defn test-new-email-action [project-id artifact email email-body]
-  (let [data {:project-id project-id
-              :type "email"
-              :address email
-              :template email-body
-              :library artifact}]
-    (if (or
-         (= "" artifact)
-         (= "" email)
-         (= "" email-body))
-      (msg/danger "Wrong data! Check out fields!")
-
-      (ajax "/api/actions/test" "POST" data
-            (wrap-error-alert (fn [e] (msg/success "Email sent. Check your inbox.")))))))
-
-(defn test-github-issue-action [project-id repo title body library]
-  (let [data {:project-id project-id
-              :type "github-issue"
-              :repo repo
-              :title title
-              :body body
-              :library library}]
-    (if (or (= "" library)
-            (= "" repo)
-            (= "" title))
-      (msg/danger "Wrong data! Check out fields!")
-
-      (ajax "/api/actions/test" "POST" data
-            (wrap-error-alert (fn [e] (msg/success "GitHub issue created. Check out your project.")))))))

 (defmulti test-action #(:type %))
 (defmethod test-action :email [data-pack]
-  (test-new-email-action (:project-id data-pack)
-                         (:artifact-value data-pack)
-                         (:user-email data-pack)
-                         (:email-template data-pack)))
+  (let [data {:project-id (:project-id data-pack)
+              :type "email"
+              :address (:user-email data-pack)
+              :template (:email-template data-pack)
+              :library (:artifact-value data-pack)}]
+    (if (s/check schm/EmailAction data)
+      (msg/danger "Data is wrong! Check out it please.")
+      (do
+        (msg/info "We are trying to send email to you...")
+       (ajax "/api/actions/test" "POST" data
+            (wrap-error-alert (fn [e] (msg/success "Email sent. Check your inbox."))))))))
+
 (defmethod test-action :github-issue [data-pack]
-  (test-github-issue-action (:project-id data-pack)
-                            (:gh-repo data-pack)
-                            (:gh-issue-title data-pack)
-                            (:gh-issue-body data-pack)
-                            (:artifact-value data-pack)))
-
-(defn update-email-action [project-id action-id artifact email email-body]
-    (let [data {:project-id project-id
-                :type "email"
-                :address email
-                :template email-body
-                :library artifact}]
-    (if (or
-         (= "" artifact)
-         (= "" email)
-         (= "" email-body))
-      (msg/danger "Wrong data! Check out fields!")
-
+  (let [data {:project-id (:project-id data-pack)
+              :type "github-issue"
+              :repo (:gh-repo data-pack)
+              :title (:gh-issue-title data-pack)
+              :body (:gh-issue-body data-pack)
+              :library (:artifact-value data-pack)}]
+    (if (s/check schm/GithubIssueAction data)
+      (msg/danger "Data is wrong! Check out it please.")
+      (do
+        (msg/info "We are trying to create issue on Github...")
+        (ajax "/api/actions/test" "POST" data
+              (wrap-error-alert (fn [e] (msg/success "GitHub issue created. Check out your project."))))))))
+
+
+(defmulti update-action #(:type %))
+(defmethod update-action :email [data-pack]
+  (let [data {:project-id (:project-id data-pack)
+              :type "email"
+              :address (:user-email data-pack)
+              :template (:email-template data-pack)
+              :library (:artifact-value data-pack)}]
+    (if (s/check schm/EmailAction data)
+      (msg/danger "Data is wrong! Check out it please.")
       (do
         (.modal ($ :#iModalAddAction) "hide")
         (ajax
-         (str "/api/actions/" action-id) "PUT"
+         (str "/api/actions/" (:action-id data-pack)) "PUT"
          data (wrap-error-alert
                #(common-update-callback "Action don't updated!" data %)))))))

-(defn update-noop-action [project-id action-id artifact]
-  (let [data {:project-id project-id
+(defmethod update-action :noop [data-pack]
+  (let [data {:project-id (:project-id data-pack)
               :type "noop"
-              :library artifact}]
-    (if (= "" artifact)
-      (msg/danger "Wrong data! Check out fields!")
-
+              :library (:artifact-value data-pack)}]
+    (if (s/check schm/NoopAction data)
+      (msg/danger "Data is wrong! Check out it please.")
       (do
         (.modal ($ :#iModalAddAction) "hide")
         (ajax
-         (str "/api/actions/" action-id) "PUT"
+         (str "/api/actions/" (:action-id data-pack)) "PUT"
          data (wrap-error-alert
                #(common-update-callback "Action don't updated!" data %)))))))

-(defn update-github-issue-action [project-id action-id repo title body library]
-  (let [data {:project-id project-id
+(defmethod update-action :github-issue [data-pack]
+  (let [data {:project-id (:project-id data-pack)
               :type "github-issue"
-              :repo repo
-              :title title
-              :body body
-              :library library}]
-    (if (or (= "" library)
-            (= "" repo)
-            (= "" title))
-      (msg/danger "Wrong data! Check out fields!")
-
+              :repo (:gh-repo data-pack)
+              :title (:gh-issue-title data-pack)
+              :body (:gh-issue-body data-pack)
+              :library (:artifact-value data-pack)}]
+    (if (s/check schm/GithubIssueAction data)
+      (msg/danger "Data is wrong! Check out it please.")
       (do
         (.modal ($ :#iModalAddAction) "hide")
         (ajax
-         (str "/api/actions/" action-id) "PUT"
+         (str "/api/actions/" (:action-id data-pack)) "PUT"
          data (wrap-error-alert
                #(common-update-callback "Action don't updated!" data %)))))))
-
-(defmulti update-action #(:type %))
-(defmethod update-action :email [data-pack]
-  (update-email-action (:project-id data-pack)
-                       (:action-id data-pack)
-                       (:artifact-value data-pack)
-                       (:user-email data-pack)
-                       (:email-template data-pack)))
-(defmethod update-action :noop [data-pack]
-  (update-noop-action (:project-id data-pack)
-                      (:action-id data-pack)
-                      (:artifact-value data-pack)))
-(defmethod update-action :github-issue [data-pack]
-  (update-github-issue-action (:project-id data-pack)
-                              (:action-id data-pack)
-                              (:gh-repo data-pack)
-                              (:gh-issue-title data-pack)
-                              (:gh-issue-body data-pack)
-                              (:artifact-value data-pack)))
-
+
 (defn delete-action [action-id]
   (.modal ($ :#iModalAddAction) "hide")
   (ajax
@@ -246,11 +187,14 @@
        #(common-update-callback "Project don't deleted!" {} %))))

 (defn ^:export update-project [project-id new-name]
-  (.modal ($ :#iModalProjectMenu) "hide")
-  (ajax
-   (str "/api/projects/" project-id) "PUT"
-   {:name new-name}
-   (wrap-error-alert #(common-update-callback "Project don't renamed!" {} %))))
+  (let [data {:name new-name}]
+    (if (s/check schm/Project data)
+      (msg/danger "Data is wrong! Check out it please.")
+      (do
+        (.modal ($ :#iModalProjectMenu) "hide")
+        (ajax
+         (str "/api/projects/" project-id) "PUT"  data
+         (wrap-error-alert #(common-update-callback "Project don't renamed!" {} %)))))))

 (defn get-library [library callback]


Fixed regression

Fixed regression

--- src/clojure/staircase/resources/steps.clj
+++ src/clojure/staircase/resources/steps.clj
@@ -22,7 +22,8 @@
     (json/generate-string maybe-string)))

 (defn parse-data [step]
-  (update-in step [:data] json/parse-string))
+  (when step
+    (update-in step [:data] json/parse-string)))

 (def parse-steps (comp vec (partial map parse-data)))


Prevent unnecessary exceptions and warnings in session

... when authenticating cookies
  #ec #psh

--- src/cider_ci/auth/session.clj
+++ src/cider_ci/auth/session.clj
@@ -53,16 +53,16 @@
   "Returns the authenticated user or nil."
   (catcher/snatch
     {}
-    (let [services-cookie (-> request keywordize-keys :cookies :cider-ci_services-session :value)
-          session-object (decrypt (get-session-secret) services-cookie)
-          user (-> session-object :user_id get-user!)]
-      (validate! (-> session-object :signature)
-                 (get-session-secret)
-                 (-> user :password_digest))
-      (validate-expiration! user session-object)
-      (when-not (:account_enabled user)
-        (throw (IllegalStateException. "Account disabled!")))
-      user)))
+    (when-let [services-cookie (-> request keywordize-keys :cookies :cider-ci_services-session :value)]
+      (let [session-object (decrypt (get-session-secret) services-cookie)
+            user (-> session-object :user_id get-user!)]
+        (validate! (-> session-object :signature)
+                   (get-session-secret)
+                   (-> user :password_digest))
+        (validate-expiration! user session-object)
+        (when-not (:account_enabled user)
+          (throw (IllegalStateException. "Account disabled!")))
+        user))))

 (defn authenticate-session-cookie [request handler]
   (if-let [user (authenticated-user request)]


fix default report params

fix default report params

--- src/clj_money/web/reports.clj
+++ src/clj_money/web/reports.clj
@@ -35,6 +35,13 @@
    [:td.text-right
     [:span {:class (str "balance-depth-" (:depth record))}
      (format-number (:value record))]]])
+
+(defn- default-start-date
+  []
+  (let [today (t/today)]
+    (t/local-date (t/year today)
+                  (t/month today)
+                  1)))

 (defn- default-end-date
   []
@@ -155,7 +162,7 @@
                         (select-keys [:entity-id :type :start-date :end-date :as-of])
                         (update-in [:type] (fnil keyword :balance-sheet))
                         (assoc :start-date (or (parse-local-date (:start-date params))
-                                               (budgets/default-start-date))
+                                               (default-start-date))
                                :end-date (or (parse-local-date (:end-date params))
                                              (default-end-date))
                                :as-of (or (parse-local-date (:as-of params))


sort boards by created-at time

sort boards by created-at time

--- src/cljs/retroboard/user.cljs
+++ src/cljs/retroboard/user.cljs
@@ -184,7 +184,8 @@
                        "Your most recently viewed boards will show up here.")
              (apply dom/div nil
                     (map #(dom/p #js {:className "text-center"}
-                                 (board-link %)) (reverse (take 3 boards)))))))
+                                 (board-link %)) (take 3 (reverse
+                                                          (sort-by :created-at boards))))))))

 (defn create-environment
   ([& [initial-actions]]


CMR-694: Removing unnecessary url decode.

--- src/cmr/ingest/api/routes.clj
+++ src/cmr/ingest/api/routes.clj
@@ -31,8 +31,7 @@
     (context "/providers/:provider-id" [provider-id]
       (context ["/collections/:native-id" :native-id #".*$"] [native-id]
         (PUT "/" {:keys [body content-type headers request-context]}
-          (let [native-id (codec/url-decode native-id)
-                metadata (string/trim (slurp body))
+          (let [metadata (string/trim (slurp body))
                 base-concept {:metadata metadata
                               :format content-type
                               :provider-id provider-id
@@ -47,8 +46,7 @@
             (r/response (ingest/delete-concept request-context concept-attribs)))))
       (context ["/granules/:native-id" :native-id #".*$"] [native-id]
         (PUT "/" {:keys [body content-type headers request-context]}
-          (let [native-id (codec/url-decode native-id)
-                metadata (string/trim (slurp body))
+          (let [metadata (string/trim (slurp body))
                 base-concept {:metadata metadata
                               :format content-type
                               :provider-id provider-id


detect old config dir and move it to a backup location before creating a clean new one

--- src/overtone/config/store.clj
+++ src/overtone/config/store.clj
@@ -4,7 +4,7 @@
   overtone.config.store
   (:use [overtone.config file-store]
         [overtone.util.lib :only [get-os system-user-name]]
-        [overtone.helpers.file :only [mkdir! file-exists?]]
+        [overtone.helpers.file :only [mkdir! file-exists? mv!]]
         [clojure.java.io :only [delete-file]]))

 (def CONFIG-DEFAULTS
@@ -58,6 +58,12 @@
              (alter config* assoc k v)))
          CONFIG-DEFAULTS))))

+(defonce __MOVE-OLD-ROOT-DIR__
+  (let [root (:root OVERTONE-DIRS)]
+      (when (file-exists? (str root "/config"))
+        (println "Warning - old config directory detected. Moved to ~/.overtone-old and replaced with new, empty config.")
+        (mv! root (str root "-old")))))
+
 (defonce __ENSIRE-DIRS___
   (ensure-dir-structure))


Dev mode shouldn't be default.

Dev mode shouldn't be default.

--- src/containium/standalone.clj
+++ src/containium/standalone.clj
@@ -27,7 +27,6 @@
                 {:file (io/as-file ".")
                  :profiles []
                  :active-profiles []
-                 :dev? true
                  :containium containium-map})
       (read-line)
       (stop-fn systems)))


improve syntax-quote on self-evaluating vals

--- src/main/clojure/clojure/tools/reader.clj
+++ src/main/clojure/clojure/tools/reader.clj
@@ -18,7 +18,8 @@
   (:import (clojure.lang PersistentHashSet IMeta
                          RT Symbol Reflector Var IObj
                          PersistentVector IRecord Namespace)
-           java.lang.reflect.Constructor))
+           java.lang.reflect.Constructor
+           java.util.regex.Pattern))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; helpers
@@ -602,7 +603,10 @@
     (or (keyword? form)
         (number? form)
         (char? form)
-        (string? form))
+        (string? form)
+        (nil? form)
+        (instance? Boolean form)
+        (instance? Pattern form))
     form

     :else (list 'quote form))


reader: bring back *alias-map*

reader: bring back *alias-map*

--- src/main/clojure/clojure/tools/reader.clj
+++ src/main/clojure/clojure/tools/reader.clj
@@ -266,8 +266,11 @@
                   {:line line :column column})))
             (reader-error rdr "Invalid token: " token))))))

+(def ^:dynamic *alias-map* nil)
+
 (defn- resolve-ns [sym]
-  (or ((ns-aliases *ns*) sym)
+  (or ((or *alias-map*
+           (ns-aliases *ns*)) sym)
       (find-ns sym)))

 (defn- read-keyword


Call Driver/run instead of main.

Call Driver/run instead of main.

--- src/lein_xjc/internal/xjc.clj
+++ src/lein_xjc/internal/xjc.clj
@@ -9,8 +9,7 @@

 (defn xjc-main
   [argv]
-  ;; TODO: fork process to avoid driver killing currently executing jvm
-  (Driver/main (into-array String argv)))
+  (Driver/run (into-array String argv) (System/out) (System/err)))

 (defn call-xjc
   [project-root target-dir xjc-calls]


Improve conformer to avoid flaky test

Improve conformer to avoid flaky test

--- test/expound/alpha_test.cljc
+++ test/expound/alpha_test.cljc
@@ -2389,7 +2389,7 @@
 (s/def :conformers-test/string-AB
   (s/and
    ;; conform as sequence (seq function)
-   (s/conformer seq)
+   (s/conformer #(if (seqable? %) (seq %) %))
    ;; re-use previous sequence spec
    :conformers-test/string-AB-seq))


Remove disabled test

Remove disabled test

--- test/io/aviso/twixt_test.clj
+++ test/io/aviso/twixt_test.clj
@@ -80,13 +80,6 @@
     (is (= asset-uri (str "/assets/" compiled-coffeescript-checksum "/coffeescript-source.coffee"))))

   (is (nil? (find-asset-uri context "does/not/exist.png"))))
-
-
-
-#_ (deftest uri-generation
-
-  (is (= (get-asset-uri twixt "sample.js") "/assets/sample.js"))
-  (is (nil? (get-asset-uri twixt "does-not-exist.js"))))

 (deftest coffeescript-compilation


basic mirth-8 test fixture in place

basic mirth-8 test fixture in place

--- test/mirthsync/core_test.clj
+++ test/mirthsync/core_test.clj
@@ -19,6 +19,9 @@
              {:version "3.8.0.b2464"
               :sha256 "e4606d0a9ea9d35263fb7937d61c98f26a7295d79b8bf83d0dab920cf875206d"
               :what-happened? []}])
+
+(def mirth-9 (first mirths))
+(def mirth-8 (second mirths))

 (defn mirth-name [mirth]
   (str "mirthconnect-" (:version mirth) "-unix"))
@@ -82,14 +85,27 @@
                           unpack-mirth
                           select-jvm-9-options)))

-(defn make-all-mirths-available []
+(defn make-all-mirths-ready []
   (ensure-target-dir)
   (doall
    (map ensure-valid-mirth mirths)))

-;; (defn mirth-8-fixture [f]
-;;         (create-db)
-;;         (f)
-;;         (destroy-db))
+(defn start-mirth [mirth]
+  (let [mirth-base (mirth-base-dir mirth)
+        mcserver (sh/proc "./mcserver" :dir mirth-base)]
+    (future (sh/stream-to-out mcserver))
+    mcserver))

-;; (use-fixtures :once mirth-8-fixture)
+(defn stop-mirth [mirth-proc]
+  (let [exit-code (future (sh/exit-code mirth-proc))]
+    (sh/destroy mirth-proc)
+    @exit-code))
+
+(defn mirth-8-fixture [f]
+  (make-all-mirths-ready)
+  (let [mirth-proc (start-mirth mirth-8)]
+    (f)
+    (stop-mirth mirth-proc)))
+
+(use-fixtures :once mirth-8-fixture)
+


add independent registration tests

add independent registration tests

--- test/otaservice/api_test.clj
+++ test/otaservice/api_test.clj
@@ -11,8 +11,35 @@
 (with-state-changes [(before :facts (migrate))
                      (after :facts (rollback-all))]
   (facts "about authentication"
-         (let [register-req #(-> (mock/request :post "/api/v1/register")
-                                 (mock/content-type "application/json")
-                                 (mock/body (cheshire/generate-string %)))]
+         (let [register-req #(rest-api (-> (mock/request :post "/api/v1/register")
+                                           (mock/content-type "application/json")
+                                           (mock/body (cheshire/generate-string %))))]
+
            (fact "if register with short login/pass proper error returned"
-                 (:status (rest-api (register-req {:username "tes" :password "pass"}))) => 400))))
+                 (let [response (register-req {:username "tes" :password "passwor"})
+                       body (parse-body (:body response))]
+                   (:status response) => 400
+                   (:error body) => {:username ["Username length must be greater than 3"]
+                                     :password ["Password length must be greater than 7"]}))
+
+           (fact "correctly filled field do not show up in error message"
+                 (let [response (register-req {:username "user" :password "wrong"})
+                       body (parse-body (:body response))]
+                   (:status response) => 400
+                   (:error body) =not=> (contains {:username anything})
+                   (:error body) => (contains {:password anything})))
+
+           (fact "successful registration returns username"
+                 (let [sameuser "user"
+                       response (register-req {:username sameuser :password "password"})
+                       body (parse-body (:body response))]
+                   (:status response) => 200
+                   (:identity body) => sameuser))
+
+           (fact "registering with existing username returns proper code and error"
+                 (let [sameuser "user"
+                       _ (register-req {:username sameuser :password "password"})
+                       response (register-req {:username sameuser :password "anything"})
+                       body (parse-body (:body response))]
+                   (:status response) => 409
+                   (:error body) => "User already exists")))))


Change charset just to make sure.

Change charset just to make sure.

--- test/postal/test/message.clj
+++ test/postal/test/message.clj
@@ -121,4 +121,14 @@
            :body "Charsets!"}]
     (is (.contains (message->str m) "=?utf-8?B?w63EjQ==?="))
     (is (.contains (message->str m) "=?utf-8?Q?B=C3=B6b?="))
+    (is (.contains (message->str m) "Plain Addr")))
+  (let [m {:from "íč <p@p.com>"
+           :to "Böb <bob@bar.dom>"
+           :cc ["Plain Addr <plain@bar.dom>"]
+           :subject "Test"
+           :charset "iso-8859-1"
+           :body "Charsets!"}]
+    (is (.contains (message->str m)
+                   "Content-Type: text/plain; charset=iso-8859-1"))
+    (is (.contains (message->str m) "=?iso-8859-1?B?7T8=?="))
     (is (.contains (message->str m) "Plain Addr"))))


Correct test

Correct test

--- test/riemann/twilio_test.clj
+++ test/riemann/twilio_test.clj
@@ -31,7 +31,7 @@
       (are [key result] (= result (key @result-atom))
            :url (str "https://api.twilio.com/2010-04-01/Accounts/" account "/Messages.json")
            :basic-auth [account service-key]
-           :from (str "+10000000000")
+           :from (str "+15005550006")
            :to (list recipient)
            :body default-body-result))


Remove duplicated function valid-ens-name?

--- src/name_bazaar/ui/utils.cljs
+++ src/name_bazaar/ui/utils.cljs
@@ -8,7 +8,7 @@
     [district0x.ui.utils :refer [truncate path-with-query solidity-sha3]]
     [goog.string :as gstring]
     [goog.string.format]
-    [name-bazaar.shared.utils :refer [name-label]]
+    [name-bazaar.shared.utils :refer [name-label valid-ens-name?]]
     [name-bazaar.ui.constants :as constants]
     [name-bazaar.ui.db :refer [default-db]]))

@@ -31,13 +31,6 @@
                  bid-hash))

 (def name->label-hash (comp sha3 name-label))
-
-(defn valid-ens-name? [name]
-  (try
-    (normalize name)
-    true
-    (catch js/Error e
-      false)))

 (defn valid-ens-subname? [subname]
   (and subname (valid-ens-name? subname) (not (string/includes? subname "."))))


Tweak log output.

Tweak log output.

--- src/oc/storage/api/boards.clj
+++ src/oc/storage/api/boards.clj
@@ -182,17 +182,24 @@
                             (entry-res/->entry conn board-uuid fixed-entry user))]
             (timbre/info "Upserting entry for new board:" board-uuid)
             (let [entry-result (entry-res/upsert-entry! conn new-entry user)]
+
               ;; Now publish all the entries that are not published already
-              (when (and (= entry-action :update)
-                         (= (keyword (:status new-entry)) :published)
-                         (not (:published-at new-entry)))
-                (entry-res/publish-entry! conn (:uuid new-entry) user))
-              (timbre/info "Upserted entry for new board:" board-uuid "as" (:uuid entry-result))
+              (if (and (= entry-action :update)
+                       (= (keyword (:status new-entry)) :published)
+                       (not (:published-at new-entry)))
+
+                (do
+                  (entry-res/publish-entry! conn (:uuid new-entry) user)
+                  (timbre/info "Upserted and published entry for new board:" board-uuid "as" (:uuid entry-result)))
+
+                (timbre/info "Upserted entry for new board:" board-uuid "as" (:uuid entry-result)))
+
               ;; If we are updating an existing draft check if we need to remove the old board
               (when (not= (:board-uuid entry) entry-res/temp-uuid)
                 (let [old-board (board-res/get-board conn (:board-uuid entry))
                       remaining-entries (entry-res/list-all-entries-by-board conn (:uuid old-board))]
                   (board-res/maybe-delete-draft-board conn org old-board remaining-entries user)))
+
               (when (= (:status entry-result) "published")
                 (when (= :add entry-action)
                   (entries-api/auto-share-on-publish conn (assoc ctx :existing-board board-result) entry-result))


Add ChannelOption/RCVBUF_ALLOCATOR to UDP server

Without it, packets are truncated at 2048 bytes, regardless of SO_RCVBUF

--- src/riemann/transport/udp.clj
+++ src/riemann/transport/udp.clj
@@ -12,7 +12,8 @@
                              DefaultMessageSizeEstimator
                              ChannelOutboundHandler
                              ChannelInboundHandler
-                             ChannelInboundHandlerAdapter]
+                             ChannelInboundHandlerAdapter
+                             FixedRecvByteBufAllocator]
            [io.netty.channel.group ChannelGroup]
            [io.netty.channel.socket.nio NioDatagramChannel]
            [io.netty.channel.nio NioEventLoopGroup])
@@ -99,7 +100,10 @@
                   (.handler handler))

                 ; Setup Channel options
-                (if (> so-rcvbuf 0) (.option bootstrap ChannelOption/SO_RCVBUF so-rcvbuf))
+                (if (> so-rcvbuf 0)
+                  (doto bootstrap
+                    (.option ChannelOption/SO_RCVBUF so-rcvbuf)
+                    (.option ChannelOption/RCVBUF_ALLOCATOR (FixedRecvByteBufAllocator. so-rcvbuf))))

                 ; Start bootstrap
                 (->> (InetSocketAddress. host port)


[test] plot grids with heatmap

[test] plot grids with heatmap

--- test/clj_dstream/generative_test.clj
+++ test/clj_dstream/generative_test.clj
@@ -24,7 +24,7 @@
                        (max domain-start (min domain-end (+ domain-start

                                                             ;(rand (- domain-end domain-start))
-                                                            (+ (get the-centroid idx) (first (random/sample-normal 1)))
+                                                            (+ (get the-centroid idx) (/ (first (random/sample-normal 1)) 10.0))
                                                             ))))
                      (::core/phase-space properties))))
     (case method
@@ -44,16 +44,39 @@
   (->> (for [y (range 10) x (range 50)] (n/noise2 (* x 0.1) (* y 0.25)))
        (viz/matrix-2d 50 10)))

+(defn grids-2d->heatmap-vec [grid-cells props]
+  (let [phase-space (::core/phase-space props)
+        d1          (first phase-space)
+        d2          (second phase-space)
+        rows        (int (/ (- (::core/domain-end d1) (::core/domain-start d1)) (::core/domain-interval d1)))
+        cols        (int (/ (- (::core/domain-end d2) (::core/domain-start d2)) (::core/domain-interval d2)))]
+
+    (println "rows, cols: " rows cols)
+
+    (let [vecs
+          (for [c (range cols) r (range rows)]
+                 (let [num (or (::core/density-at-last-update (get grid-cells [r c]))
+                               0.0)]
+                   num
+                   ))]
+      (->>
+        vecs
+        (viz/matrix-2d rows cols)
+        ))
+
+    ))
+
 (defn heatmap-spec
-  [id]
-  {:matrix        test-matrix
-   :value-domain  (viz/value-domain-bounds test-matrix)
+  [id the-matrix]
+  {:matrix        the-matrix
+   :value-domain  (viz/value-domain-bounds the-matrix)
    :palette       (->> id (grad/cosine-schemes) (apply grad/cosine-gradient 100))
    :palette-scale viz/linear-scale
    :layout        viz/svg-heatmap})

 (defn cartesian-viz
-  [prefix id & [opts]]
+  [prefix id the-matrix & [opts]]
+  (clojure.pprint/pprint the-matrix)
   (->> {:x-axis (viz/linear-axis
                   {:domain [0 50]
                    :range  [50 550]
@@ -67,31 +90,31 @@
                    :pos         50
                    :label-dist  15
                    :label-style {:text-anchor "end"}})
-        :data   [(merge (heatmap-spec id) opts)]}
+        :data   [(merge (heatmap-spec id the-matrix) opts)]}
        (viz/svg-plot2d-cartesian)
        (svg/svg {:width 600 :height 300})
        (svg/serialize)
        (spit (str prefix "-" (name id) ".svg"))))

 (defn display-state [props grid-cells]
-  (let [cluster-positions (remove nil? (map (fn [[pos-idx char-vec]]
-                                              (let [cluster (::core/cluster char-vec)]
-                                                (if-not (or (= nil cluster)
-                                                            (= "NO_CLASS" cluster))
-                                                  pos-idx)))
-                                            grid-cells))]
-    (if (= 2 (::core/dimensions props))
-      {"none" cluster-positions}
-      (let [_            (println "cluster positions: " cluster-positions)
-            input-matrix (matrix/array :vectorz cluster-positions)
-            _            (println "input mat;" input-matrix)
-            algo-name    :parallel-bht
-            _            (println "tsne: " algo-name)
-            output-map   {algo-name (tsne/tsne input-matrix 2 :tsne-algorithm algo-name :perplexity 0.01)}]
-        output-map)))
+  #_(let [cluster-positions (remove nil? (map (fn [[pos-idx char-vec]]
+                                                (let [cluster (::core/cluster char-vec)]
+                                                  (if-not (or (= nil cluster)
+                                                              (= "NO_CLASS" cluster))
+                                                    pos-idx)))
+                                              grid-cells))]
+      (if (= 2 (::core/dimensions props))
+        {"none" cluster-positions}
+        (let [_            (println "cluster positions: " cluster-positions)
+              input-matrix (matrix/array :vectorz cluster-positions)
+              _            (println "input mat;" input-matrix)
+              algo-name    :parallel-bht
+              _            (println "tsne: " algo-name)
+              output-map   {algo-name (tsne/tsne input-matrix 2 :tsne-algorithm algo-name :perplexity 0.01)}]
+          output-map)))

-  ;(cartesian-viz "hm" :rainbow2)
-  ;(cartesian-viz "hm" :orange-blue)
+  (cartesian-viz "hm" :rainbow2 (grids-2d->heatmap-vec grid-cells props))
+  (cartesian-viz "hm" :orange-blue (grids-2d->heatmap-vec grid-cells props))
   )

@@ -106,22 +129,22 @@
                       ::core/beta        0.3
                       ::core/dimensions  2
                       ::core/phase-space [
-                                          {::core/domain-start    -2.0
-                                           ::core/domain-end      2.0
-                                           ::core/domain-interval 0.02}
-                                          {::core/domain-start    -2.0
-                                           ::core/domain-end      2.0
-                                           ::core/domain-interval 0.02}]
+                                          {::core/domain-start    -2.5
+                                           ::core/domain-end      2.5
+                                           ::core/domain-interval 0.1}
+                                          {::core/domain-start    -0.5
+                                           ::core/domain-end      0.5
+                                           ::core/domain-interval 0.1}]
                       ::core/gap-time    50}
-        centroids    (vec (repeatedly 30 (fn [] (get-random-sample :unifrom test-props))))
+        centroids    (vec (repeatedly 3 (fn [] (get-random-sample :unifrom test-props))))
         _            (println "centroids: " centroids)
-        samples      (repeatedly 1000 #(hash-map
-                                        ::core/raw-datum
-                                        {::core/position-value
-                                                      (get-random-sample :normal test-props
-                                                                         :centroids
-                                                                         centroids)
-                                         ::core/value 1.0}))
+        samples      (repeatedly 10000 #(hash-map
+                                         ::core/raw-datum
+                                         {::core/position-value
+                                                       (get-random-sample :normal test-props
+                                                                          :centroids
+                                                                          centroids)
+                                          ::core/value 1.0}))

         test-state   {::core/state {::core/grid-cells           {}
                                     ::core/properties           test-props
@@ -134,7 +157,7 @@

     ;;TODO abandon tsne for a simple dxd grid of 2d scatter plots

-    ;(clojure.pprint/pprint displayable)
+    (clojure.pprint/pprint displayable)
     ;(clojure.pprint/pprint sorted-stats)
     )
   )


actually mention which dependency didn't match. doh.

--- src/main/shadow/build/targets/browser.clj
+++ src/main/shadow/build/targets/browser.clj
@@ -694,9 +694,10 @@
   "Checking used npm package versions")

 (defmethod build-log/event->str ::npm-version-conflict
-  [{:keys [package-name wanted-version installed-version] :as event}]
-  (format "npm package \"%s\" expected version \"%s\" but \"%s\" is installed."
+  [{:keys [package-name wanted-dep wanted-version installed-version] :as event}]
+  (format "npm package \"%s\" expected version \"%s@%s\" but \"%s\" is installed."
     package-name
+    wanted-dep
     wanted-version
     installed-version))

@@ -729,6 +730,7 @@

               (util/warn state {:type ::npm-version-conflict
                                 :package-name package-name
+                                :wanted-dep dep
                                 :wanted-version wanted-version
                                 :installed-version installed-version}))


[#1077] Use fake table when no dataset

[#1077] Use fake table when no dataset

--- backend/src/akvo/lumen/lib/visualisation/maps.clj
+++ backend/src/akvo/lumen/lib/visualisation/maps.clj
@@ -42,23 +42,27 @@
                locations)))

 (defn sql-statement
-  [locations]
-  (format "SELECT * FROM (VALUES %s ) AS t (label, geom);"
-          (sql-values locations)))
+  "Dummy data"
+  ([]
+   "SELECT * FROM (VALUES ('label', ST_SetSRID(ST_MakePoint(4.908075,52.372189), 4326))) AS t (label, geom) LIMIT 0;")
+  ([locations]
+   (format "SELECT * FROM (VALUES %s ) AS t (label, geom);"
+           (sql-values locations))))
+

 ;;;  Dummy sql stop

 (def cartocss
   "#s { marker-width: 10; marker-fill: #e00050;}")

-(defn map-config [cartocss geom-column label sql-statement]
+(defn map-config [cartocss geom-column label sql]
   {"version" "1.6.0"
    "layers" [{"type" "mapnik"
               "options" {"cartocss" cartocss
                          "cartocss_version" "2.0.0"
                          "geom_column" geom-column
                          "interactivity" label
-                         "sql" sql-statement
+                         "sql" sql
                          "srid" 4326}}]})

@@ -69,17 +73,21 @@
   (let [{:keys [db-name headers]} (connection-details tenant-conn)
         akvo-maps-url "http://windshaft:4000"
         url (format "%s/%s/layergroup" akvo-maps-url db-name)
-        sql-statement (sql-statement locations)
+        sql (sql-statement) ;; No dataset
+        ;; sql-statement (sql-statement locations)
+        ;; sql-statement (sql-statement)
+        ;; sql-v (sql)
+        ;; _ (prn sql-v)
         resp (client/post url
                           {:body (json/encode (map-config cartocss
                                                           "geom"
                                                           "label"
-                                                          sql-statement))
+                                                          sql))
                            :headers headers
                            :content-type :json})]
     (case (:status resp)
       200 (lib/ok (assoc (json/decode (:body resp))
-                         "tenantDB" "lumen_tenant_1"))
+                         "tenantDB" db-name))
       (prn resp))))


Added five tests into config-test module

--- test/emender_jenkins/config_test.clj
+++ test/emender_jenkins/config_test.clj
@@ -23,3 +23,37 @@
     [function-name]
     (clojure.test/function? function-name))

+;
+; Tests for various function definitions
+;
+
+(deftest test-update-configuration-existence
+    "Check that the emender-jenkins.config/update-configuration definition exists."
+    (testing "if the emender-jenkins.config/update-configuration definition exists."
+        (is (callable? 'emender-jenkins.config/update-configuration))))
+
+
+(deftest test-load-configuration-from-ini-existence
+    "Check that the emender-jenkins.config/load-configuration-from-ini definition exists."
+    (testing "if the emender-jenkins.config/load-configuration-from-ini definition exists."
+        (is (callable? 'emender-jenkins.config/load-configuration-from-ini))))
+
+
+(deftest test-assoc-in-if-not-nil-existence
+    "Check that the emender-jenkins.config/assoc-in-if-not-nil definition exists."
+    (testing "if the emender-jenkins.config/assoc-in-if-not-nil definition exists."
+        (is (callable? 'emender-jenkins.config/assoc-in-if-not-nil))))
+
+
+(deftest test-override-options-by-cli-existence
+    "Check that the emender-jenkins.config/override-options-by-cli definition exists."
+    (testing "if the emender-jenkins.config/override-options-by-cli definition exists."
+        (is (callable? 'emender-jenkins.config/override-options-by-cli))))
+
+
+(deftest test-print-configuration-existence
+    "Check that the emender-jenkins.config/print-configuration definition exists."
+    (testing "if the emender-jenkins.config/print-configuration definition exists."
+        (is (callable? 'emender-jenkins.config/print-configuration))))
+
+


Nested map tests in the wrong place

Nested map tests in the wrong place

--- test/structural_typing/f_bouncer.clj
+++ test/structural_typing/f_bouncer.clj
@@ -32,36 +32,17 @@
                                       :in-any-order)

-  (fact "optional args"
-    (let [type-repo (-> accumulator/type-repo
-                        (type/named :hork [:string [:point :x] [:point :y]]
-                                    {:string #'string?
-                                     [:point :x] #'integer?
-                                     :distance #'pos?}))]
-      (type/checked type-repo :hork {:string "hi" :point {:x 1, :y 1} :distance 3})
-      (type/checked type-repo :hork {:string "hi" :point {:x 1, :y 1}})
-
-      (type/checked type-repo :hork {:string 3 :point {:x 1, :y 1}}) => :failure-handler-called
-      (accumulator/messages) => [":string should be `string?`; it is `3`"]
-
-      (type/checked type-repo :hork {:string "hi" :point {:x 1.0, :y 1.0}}) => :failure-handler-called
-      (accumulator/messages) => ["[:point :x] should be `integer?`; it is `1.0`"]
-
-      (type/checked type-repo :hork {:string "hi" :point {:x 1, :y 1} :distance -3}) => :failure-handler-called
-      (accumulator/messages) => [":distance should be `pos?`; it is `-3`"]
-
-      (type/checked type-repo :hork {:string "hi" :point {:x 1, :y 1} :distance "foo"}) => :failure-handler-called
-      (accumulator/messages) => [":distance should be `pos?`; it is `\"foo\"`"]))
-
-
-  (future-fact "validator sets would be nice"
+  (fact "nested maps"
     (let [type-repo (-> accumulator/type-repo
                         (type/named :hork [:string [:point :x] [:point :y]]
                                     {:string #'string?
                                      :point {:x #'integer?}
                                      :distance #'pos?}))]
-      (type/checked type-repo :hork {:string "hi" :point {:x 1, :y 1} :distance 3})
-      (type/checked type-repo :hork {:string "hi" :point {:x 1, :y 1}})
+      (type/checked type-repo :hork {:string "hi" :point {:x 1, :y 1} :distance 3}) => {:string "hi" :point {:x 1, :y 1} :distance 3}
+      (type/checked type-repo :hork {:string "hi" :point {:x 1, :y 1}}) => {:string "hi" :point {:x 1, :y 1}}
+
+      (type/checked type-repo :hork {:string "hi" :point {:x 1}}) => :failure-handler-called
+      (accumulator/messages) => ["[:point :y] must be present and non-nil"]

       (type/checked type-repo :hork {:string 3 :point {:x 1, :y 1}}) => :failure-handler-called
       (accumulator/messages) => [":string should be `string?`; it is `3`"]
@@ -75,8 +56,30 @@
       (type/checked type-repo :hork {:string "hi" :point {:x 1, :y 1} :distance "foo"}) => :failure-handler-called
       (accumulator/messages) => [":distance should be `pos?`; it is `\"foo\"`"]

-      )
-))
+      ))
+  (fact "optional args"
+    (let [type-repo (-> accumulator/type-repo
+                        (type/named :hork [:string [:point :x] [:point :y]]
+                                    {:string #'string?
+                                     [:point :x] #'integer?
+                                     :distance #'pos?}))]
+      (type/checked type-repo :hork {:string "hi" :point {:x 1, :y 1} :distance 3}) => {:string "hi" :point {:x 1, :y 1} :distance 3}
+      (type/checked type-repo :hork {:string "hi" :point {:x 1, :y 1}}) => {:string "hi" :point {:x 1, :y 1}}
+
+      (type/checked type-repo :hork {:string "hi" :point {:x 1}}) => :failure-handler-called
+      (accumulator/messages) => ["[:point :y] must be present and non-nil"]
+
+      (type/checked type-repo :hork {:string 3 :point {:x 1, :y 1}}) => :failure-handler-called
+      (accumulator/messages) => [":string should be `string?`; it is `3`"]
+
+      (type/checked type-repo :hork {:string "hi" :point {:x 1.0, :y 1.0}}) => :failure-handler-called
+      (accumulator/messages) => ["[:point :x] should be `integer?`; it is `1.0`"]
+
+      (type/checked type-repo :hork {:string "hi" :point {:x 1, :y 1} :distance -3}) => :failure-handler-called
+      (accumulator/messages) => [":distance should be `pos?`; it is `-3`"]
+
+      (type/checked type-repo :hork {:string "hi" :point {:x 1, :y 1} :distance "foo"}) => :failure-handler-called
+      (accumulator/messages) => [":distance should be `pos?`; it is `\"foo\"`"])))

 (future-fact "validating embedded collections"


remove unused use

remove unused use

--- tasks.clj
+++ tasks.clj
@@ -3,7 +3,6 @@
         [cake.utils :only [git]]
         [bake.core :only [log]]
         [cake.tasks.jar :only [build-uberjar jars uberjarfile]]
-        [cake.tasks.release :only [upload-to-clojars]]
         [cake.tasks.version :only [snapshot? snapshot-timestamp]])
   (:import [org.apache.tools.ant.taskdefs Jar Copy Move ExecTask]
            [java.io File]))


Adds explicit dependency on org.clojure/java.jdbc

--- backend/project.clj
+++ backend/project.clj
@@ -19,6 +19,7 @@
                  [meta-merge "0.1.1"]
                  [org.clojure/clojure "1.8.0"]
                  [org.clojure/data.csv "0.1.3"]
+                 [org.clojure/java.jdbc "0.4.2"]
                  [org.immutant/scheduling "2.1.2"]
                  [org.immutant/web "2.1.2"]
                  [org.postgresql/postgresql "9.4.1208"]