Use hash map as data structure instead of vector

--- src/kostlee/handler.clj
+++ src/kostlee/handler.clj
@@ -17,11 +17,11 @@

 ;;; TODO Read in from somewhere™ at startup
-(def daymoney-state (atom [
-  {:id "1" :date "2014-01-27" :people 16 :amount 2609.13M}
-  {:id "2" :date "2014-01-28" :people 16 :amount 2609.13M}
-  {:id "3" :date "2014-01-29" :people 16 :amount 2709.13M}
-  {:id "4" :date "2014-01-30" :people 17 :amount 2739.13M}]))
+(def daymoney-state (atom {
+  "1" { :date "2014-01-27T21:19:37+0100" :people 16 :amount 2209.13M }
+  "2" { :date "2014-01-28T21:19:37+0100" :people 16 :amount 2459.13M }
+  "3" { :date "2014-01-29T21:19:37+0100" :people 16 :amount 2709.13M }
+  "4" { :date "2014-01-30T21:19:37+0100" :people 17 :amount 2989M }}))

 ;;; API index provides links to resources
 (defn index []
@@ -29,27 +29,28 @@

 ;;; Daymoney handlers
 (defn get-all-daymoneys []
-  (response @daymoney-state))
+  (response (map (fn [d] (assoc (second d) :id (first d)))
+                 @daymoney-state)))

 (defn get-daymoney [id]
-  (let [daymoney (get (group-by :id @daymoney-state) id)]
+  (let [daymoney (get @daymoney-state id)]
     (cond
-      (empty? daymoney) {:status 404}
-      :else (response (first daymoney)))))
+      (empty? daymoney) { :status 404 }
+      :else (response (assoc daymoney :id id)))))

 ;TODO validate input
 (defn create-new-daymoney [daymoney]
   (let [id (uuid)]
-    (swap! daymoney-state conj (assoc daymoney :id id))
+    (reset! daymoney-state (merge @daymoney-state { id daymoney }))
     (get-daymoney id)))

 ;FIXME not implemented
 (defn update-daymoney [id daymoney]
-  (get-daymoney id))
+  {:status 501})

 ;FIXME not implemented
 (defn delete-daymoney [id]
-  {:status 204})
+  {:status 501})

 (defroutes api-routes


Refactor (extract play from generate)

Refactor (extract play from generate)

--- src/speech_melody/generator.clj
+++ src/speech_melody/generator.clj
@@ -67,6 +67,13 @@
 (defmethod live/play-note :piano [{midi :pitch}]
   (sampled-piano midi))

+(defn- play [mfccs]
+  (->>
+    (sort-by :time (concat (piano mfccs) (melody mfccs)))
+    (tempo (bpm 40))
+    (where :pitch (comp scale/D scale/blues))
+    live/play))
+
 (defn- drop-seconds! [input-ais seconds]
   (let [format (.getFormat input-ais)
         frame-size (.getFrameSize format)
@@ -88,11 +95,7 @@
         _ (download (make-url text lang) temp-mp3)
         mfccs (preprocess-mfccs (audio->mfccs temp-mp3 NUMBER-OF-COEFFICIENTS))]
     (recording-start temp-wav)
-    @(->>
-       (sort-by :time (concat (piano mfccs) (melody mfccs)))
-       (tempo (bpm 40))
-       (where :pitch (comp scale/D scale/blues))
-       live/play)
+    @(play mfccs)
     (Thread/sleep (* 5 1000))
     (recording-stop)
     (postprocess-audio temp-wav temp-ogg (str text " (" lang ")"))


presyntax ok

presyntax ok

--- src/latte/presyntax.clj
+++ src/latte/presyntax.clj
@@ -1,17 +1,15 @@

-(ns typetheory.presyntax
+(ns latte.presyntax
   (:require [clj-by.example :refer [example do-for-example]])
-  (:require [typetheory.syntax :as stx])
   )

 (def ^:private +examples-enabled+)

-
 (def +reserved-symbols+
-  '#{kind type □ * ∗ ✳ lambda prod forall})
+  '#{kind type □ * ∗ ✳ lambda λ prod forall ∀})

 (defn reserved-symbol? [s]
-  (or (contains +reserved-symbols+ s)
+  (or (contains? +reserved-symbols+ s)
       (= (first (name s)) \_)))

 (defn kind? [t]
@@ -47,7 +45,7 @@
     (let [sdef (get def-env sym)]
       (if (not= (:arity sdef) 0)
         [:ko {:msg "Definition is not a constant (arity>0)" :term sym :def sdef}]
-        [:ok (list ::stx/ref sym)]))
+        [:ok (list sym)]))
     :else [:ko {:msg "Variable out of scope" :term sym}]))

 (example
@@ -59,7 +57,7 @@

 (example
  (parse-term {'x {:arity 0}} 'x)
- => '[:ok (:typetheory.syntax/ref x)])
+ => '[:ok (x)])

 (example
  (parse-term {'x {:arity 1}} 'x)
@@ -103,7 +101,7 @@
               (not (symbol? (first s)))
               [:ko {:msg "Binding variable is not a symbol" :term v :var (first s)}]
               (reserved-symbol? (first s))
-              [:ko {:msg "Wrong binding variable : symbol is reserved" :term v :symbol (first s)}]
+              [:ko {:msg "Wrong binding variable: symbol is reserved" :term v :symbol (first s)}]
               (contains? vars (first s))
               [:ko {:msg "Duplicate binding variable" :term v :var (first s)}]
               :else (recur (rest s) (conj vars (first s)) (conj res [(first s) ty'])))
@@ -116,6 +114,12 @@
 (example
  (parse-binding {} '[x y z :type] #{})
  => '[:ok [[x :type] [y :type] [z :type]]])
+
+(example
+ (parse-binding {} '[x y forall :type] #{})
+ => '[:ko {:msg "Wrong binding variable: symbol is reserved",
+           :term [x y forall :type],
+           :symbol forall}])

 (example
  (parse-binding {} '[x y x :type] #{})
@@ -139,20 +143,23 @@
  (concat [1 2 3] [4 5 6]) => [1 2 3 4 5 6])

 (defn parse-binder-term [def-env binder t bound]
-  (if (not= (count t) 3)
-    [:ko {:msg (str "Wrong " binder " form (expecting 3 arguments)") :term t :nb-args (count t)}]
+  (if (< (count t) 3)
+    [:ko {:msg (str "Wrong " binder " form (expecting at least 3 arguments)") :term t :nb-args (count t)}]
     (let [[status bindings] (parse-binding def-env (second t) bound)]
       (if (= status :ko)
         [:ko {:msg (str "Wrong bindings in " binder " form") :term t :from bindings}]
         (let [bound' (reduce (fn [res [x _]]
                                (conj res x)) #{} bindings)]
-          (let [[status body] (parse-term def-env (nth t 2) bound')]
-            (if (= status :ko)
-              [:ko {:msg (str "Wrong body in " binder " form") :term t :from body}]
-              (loop [i (dec (count bindings)), res body]
-                (if (>= i 0)
-                  (recur (dec i) (list binder (bindings i) res))
-                  [:ok res])))))))))
+          (let [body (if (= (count t) 3)
+                       (nth t 2)
+                       (rest (rest t)))]
+            (let [[status body] (parse-term def-env body bound')]
+              (if (= status :ko)
+                [:ko {:msg (str "Wrong body in " binder " form") :term t :from body}]
+                (loop [i (dec (count bindings)), res body]
+                  (if (>= i 0)
+                    (recur (dec i) (list binder (bindings i) res))
+                    [:ok res]))))))))))

 (defn parse-lambda-term [def-env t bound]
   (parse-binder-term def-env 'lambda t bound))
@@ -176,12 +183,6 @@
  => '[:ko {:msg "Wrong bindings in lambda form",
            :term (lambda [x] x),
            :from {:msg "Binding must have at least 2 elements", :term [x]}}])
-
- (example
- (parse-term {} '(lambda [x :type] x y))
- => '[:ko {:msg "Wrong lambda form (expecting 3 arguments)",
-           :term (lambda [x :type] x y),
-           :nb-args 4}])

 (example
  (parse-term {} '(lambda [x :type] z))
@@ -226,30 +227,29 @@
       (let [[status ts] (parse-terms def-env (rest t) bound)]
         (if (= status :ko)
           [:ko {:msg "Wrong argument" :term t :from ts}]
-          [:ok (conj (conj (into '() ts) def-name) ::stx/ref)])))))
+          [:ok (list* def-name ts)])))))

 (example
  (parse-term {'ex {:arity 2}}
              '(ex x :kind) #{'x})
- => '[:ok (:typetheory.syntax/ref ex :kind x)])
-
+ => '[:ok (ex x :kind)])

 (defn left-binarize [t]
   (if (< (count t) 2)
     t
-    (loop [s (rest (rest t)), res (list (first t) (second t))]
+    (loop [s (rest (rest t)), res [(first t) (second t)]]
       (if (seq s)
-        (recur (rest s) (list res (first s)))
+        (recur (rest s) [res (first s)])
         res))))

 (example
- (left-binarize '(a b)) => '(a b))
-
-(example
- (left-binarize '(a b c)) => '((a b) c))
-
-(example
- (left-binarize '(a b c d e)) => '((((a b) c) d) e))
+ (left-binarize '(a b)) => '[a b])
+
+(example
+ (left-binarize '(a b c)) => '[[a b] c])
+
+(example
+ (left-binarize '(a b c d e)) => '[[[[a b] c] d] e])

 (defn parse-application-term [def-env t bound]
   (if (< (count t) 2)
@@ -260,7 +260,13 @@
         [:ok (left-binarize ts)]))))

 (example
- (parse-term {} '(x y) '#{x y}) => '[:ok (x y)])
-
-(example
- (parse-term {} '(x y z) '#{x y z}) => '[:ok ((x y) z)])
+ (parse-term {} '(x y) '#{x y}) => '[:ok [x y]])
+
+(example
+ (parse-term {} '(x y z) '#{x y z}) => '[:ok [[x y] z]])
+
+(example
+ (parse-term {} '(lambda [x :type] x :type :kind))
+ => '[:ok (lambda [x :type] [[x :type] :kind])])
+
+


[#8762] Dapp can't derive a wallet balance, "Not enough ETH for gas" at attempt to send transaction in any DApp

Signed-off-by: yenda <96f164ad4d9b2b0dacf8ebee2bb1eeb3aa69adf1@status.im>

--- src/status_im/signing/core.cljs
+++ src/status_im/signing/core.cljs
@@ -13,7 +13,8 @@
             [re-frame.core :as re-frame]
             [status-im.constants :as constants]
             [status-im.utils.utils :as utils]
-            status-im.utils.handlers))
+            status-im.utils.handlers
+            [status-im.ethereum.eip55 :as eip55]))

 (re-frame/reg-fx
  :signing/send-transaction-fx
@@ -254,9 +255,7 @@
                  {:dispatch (conj on-error "transaction was cancelled by user")}))))

 (defn normalize-tx-obj [db tx]
-  (if (get-in tx [:tx-obj :from])
-    tx
-    (assoc-in tx [:tx-obj :from] (ethereum/default-address db))))
+  (update-in tx [:tx-obj :from] #(eip55/address->checksum (or % (ethereum/default-address db)))))

 (fx/defn sign [{:keys [db] :as cofx} tx]
   "Signing transaction or message, shows signing sheet


Fix github pull request status on main page.

--- src/clj/hatnik/web/server/renderer.clj
+++ src/clj/hatnik/web/server/renderer.clj
@@ -110,7 +110,7 @@
      "have a place that lists the latest versions for selected libraries."]
     [:li.available {:title "Work in progress"} [:strong "GitHub Issue"]
      " - create an issue in the selected repo. The text can be customized just like in email."]
-    [:li.unavailable {:title "Work in progress"} [:strong "GitHub Pull Request"]
+    [:li.available {:title "Work in progress"} [:strong "GitHub Pull Request"]
      " - create a pull request in selected repo using simple find-and-replace-in-file operations."]
     [:li.unavailable {:title "Work in progress"} [:strong "GitHub Wiki"]
      " - update a wiki page using the same find-and-replace operations."]]


Simplfiy and rename predicates

Simplfiy and rename predicates

--- src/cljs/react_cljs_blogpost/core.cljs
+++ src/cljs/react_cljs_blogpost/core.cljs
@@ -18,11 +18,11 @@
 (defn generate-cards [] (mapv generate-card (generate-symbols)))

 ;couple of helpful predicate functions
-(defn is-matched [card] (= (:matched @card) true))
-(defn is-visible [card] (= (:visible @card) true))
+(defn matched? [card] (:matched @card))
+(defn visible? [card] (:visible @card))

-(defn revealed-cards-count [] (count (filter is-visible (:cards @state))))
-(defn matched-cards-count [] (count (filter is-matched (:cards @state))))
+(defn revealed-cards-count [] (count (filter visible? (:cards @state))))
+(defn matched-cards-count [] (count (filter matched? (:cards @state))))

 ; side effecting functions used for hiding/marking revealed cards
 (defn hide-nonmatch! [] (mapv #(swap! % assoc :visible false) (:cards @state)) (swap! state assoc :last-symbol ""))


add comment

add comment

--- src/babel/espanol/morphology/verbs.clj
+++ src/babel/espanol/morphology/verbs.clj
@@ -9,6 +9,10 @@
 (require '[clojure.tools.logging :as log])
 (require '[dag-unify.core :refer (copy dissoc-paths fail? get-in merge ref? strip-refs unifyc)])

+;; TODO: replace with a runtime flag.
+;; issue is that logging requires partial morphological evaluation,
+;; whereas generation and batch jobs should immediately raise an exception.
+;; Correct solution should catch in logging code.
 (def suppress-morph-exceptions false)

 (defn reflexive-to-infinitive [reflexive-infinitive]


reimplement save dialog

reimplement save dialog

--- src/lt/objs/opener.cljs
+++ src/lt/objs/opener.cljs
@@ -14,6 +14,7 @@
             [lt.objs.notifos :as notifos]
             [lt.objs.files :as files]
             [lt.util.dom :as dom]
+            [lt.util.ipc :as ipc]
             [lt.util.cljs :refer [->dottedkw]])
   (:use [crate.binding :only [bound map-bound]])
   (:use-macros [crate.def-macros :only [defpartial]]
@@ -22,8 +23,6 @@
 ;;**********************************************************
 ;; transient docs
 ;;**********************************************************
-
-(def active-dialog nil)

 (defui open-input [this]
   [:input {:type "file"}]
@@ -32,12 +31,9 @@
                      (when-not (empty? (dom/val me))
                        (object/raise this :open! (dom/val me))))))

-(defui save-input [this path]
-  [:input {:type "file" :nwsaveas (or path true)}]
-  :change (fn []
-            (this-as me
-                     (when-not (empty? (dom/val me))
-                       (object/raise this :save-as! (dom/val me))))))
+(defn save-input [this path]
+  (ipc/call this :save-as!
+            :dialog.showSaveDialog ipc/win {:defaultPath path}))

 (defn path->info [path]
   (when path
@@ -65,37 +61,36 @@
                                     info (:info @this)
                                     fname (:name info)
                                     ext (when-let [e (:exts info)]
-                                          (str "." (name (first e))))
-                                    s (save-input this (files/join path (str fname ext)))]
-                                (set! active-dialog s)
-                                (dom/trigger s :click))))
+                                          (str "." (name (first e))))]
+                                (save-input this (files/join path (str fname ext))))))

 (behavior ::save-as-rename!
                   :triggers #{:save-as-rename!}
                   :reaction (fn [this]
-                              (dom/trigger (save-input this (-> @this :info :path)) :click)))
+                              (save-input this (-> @this :info :path))))

 (behavior ::save-as
                   :triggers #{:save-as!}
                   :reaction (fn [this path]
-                              (let [type (files/path->type path)
-                                    prev-tags (-> @this :info :tags)
-                                    mode (files/path->mode path)
-                                    neue-doc (doc/create {:doc (editor/get-doc this)
-                                                          :line-ending files/line-ending
-                                                          :mtime (files/stats path)
-                                                          :mime mode})]
-                                (when (:doc @this)
-                                  (object/raise (:doc @this) :close.force))
-                                (doc/register-doc neue-doc path)
-                                (object/update! this [:info] merge (path->info path))
-                                (object/merge! this {:dirty true
-                                                     :doc neue-doc})
-                                (editor/set-mode this mode)
-                                (object/remove-tags this (conj prev-tags :editor.transient))
-                                (object/add-tags this (conj (:tags type) :editor.file-backed))
-                                (object/raise this :save-as)
-                                (object/raise this :save))))
+                              (when (not (empty? path))
+                                (let [type (files/path->type path)
+                                      prev-tags (-> @this :info :tags)
+                                      mode (files/path->mode path)
+                                      neue-doc (doc/create {:doc (editor/get-doc this)
+                                                            :line-ending files/line-ending
+                                                            :mtime (files/stats path)
+                                                            :mime mode})]
+                                  (when (:doc @this)
+                                    (object/raise (:doc @this) :close.force))
+                                  (doc/register-doc neue-doc path)
+                                  (object/update! this [:info] merge (path->info path))
+                                  (object/merge! this {:dirty true
+                                                       :doc neue-doc})
+                                  (editor/set-mode this mode)
+                                  (object/remove-tags this (conj prev-tags :editor.transient))
+                                  (object/add-tags this (conj (:tags type) :editor.file-backed))
+                                  (object/raise this :save-as)
+                                  (object/raise this :save)))))

 (behavior ::check-read-only
                   :desc "Opener: check if file is read only"


Fixed search.cljs warnings

Fixed search.cljs warnings

--- src/lt/objs/search.cljs
+++ src/lt/objs/search.cljs
@@ -240,6 +240,8 @@
                          ]
                         ))

+(def searcher (object/create ::workspace-search))
+
 (cmd/command {:command :searcher.search
               :desc "Searcher: Execute search"
               :hidden true
@@ -272,5 +274,3 @@
               :hidden true
               :exec (fn []
                       (object/raise searcher :replace!))})
-
-(def searcher (object/create ::workspace-search))


pivot enabled on all cols. of multipdgmmod

--- src/clj/webapp/routes/multipdgmmod.clj
+++ src/clj/webapp/routes/multipdgmmod.clj
@@ -1,5 +1,5 @@
 (ns webapp.routes.multipdgmmod
- (:refer-clojure :exclude [filter concat group-by max min count])
+ (:refer-clojure :exclude [filter concat group-by max min])
   (:require
             ;;[clojure.core/count :as count]
             [compojure.core :refer :all]
@@ -107,14 +107,29 @@
                   [:td [:input#submit
                         {:value "Display pdgms", :name "submit", :type "submit"}]]]])))

+(defn addpnum
+  [valclusters]
+  (let [pnum (atom 0)]
+    (for [valcluster valclusters]
+      (let [pnum (swap! pnum inc)]
+        (clojure.string/replace valcluster #"\r\n(\S)" (str "\r\nP-"  pnum  ",$1"))))))
+
 (defn vc2req
  [valclusters pos]
   (let [vcvec (split valclusters #" ")
-        lprefmap (read-string (slurp "pvlists/lprefs.clj"))]
+        lprefmap (read-string (slurp "pvlists/lprefs.clj"))
+        pmnum (atom 0)
+        pdgmnums (into [] (take (count vcvec) (iterate inc 1)))
+        ]
     (for [valcluster vcvec]
-      (let [vals (split valcluster #"," 2)
+      (let [;;valcluster (nth vcvec (dec pdgmnum))
+            vals (split valcluster #"," 2)
             language (first vals)
             vcluster (last vals)
+            ;; all three of following fail to recalculate after 1st iteration
+            pnum (.indexOf valclusters valcluster)
+            pmnum (swap! pmnum inc)
+            pdnum (nth pdgmnums pnum)
             lang (read-string (str ":" language))
             lpref (lang lprefmap)
             valstrng (clojure.string/replace vcluster #",*person|,*gender|,*number" "")
@@ -133,16 +148,11 @@
                        {"query" query-sparql ;;generated sparql
                         ;;"format" "application/sparql-results+json"}})]
                         "format" "csv"}})
-            ;;pvec (split (:body req) #"\r\n" 2)
-            ;;pbody (str (last pvec))
             ;; get rid of header
             pbody (clojure.string/replace (:body req) #"^.*?\r\n" "\r\n")
             ]
-        ;;(str (:body req))))
-        ;;(clojure.string/replace (:body req) #" " "_")
-        ;;(clojure.string/replace (:body req) #"\r\n$" "")
         ;; add pdgm name to each row of pbody as first value
-        (clojure.string/replace pbody #"\r\n(\S)" (str "\r\n" vcstring ",$1"))))))
+        (clojure.string/replace pbody #"\r\n(\S)" (str "\r\n" vcstring  ",$1"))))))

 (defn csv2pdgm
 "Takes sorted 4-col csv list with vectors of pnames and headers, and outputs 5-col html table with first col for pname ref; cols are draggable and sortable."
@@ -171,9 +181,6 @@
      (for [pname pnames]
        [:li pname])]]
    [:hr]
-   ;;[:pre pdgmstr2]
-   ;;[:hr]
-   ;; For visible borders set {:border "1"}.
    [:table {:id "handlerTable" :class "tablesorter sar-table"}
     [:thead
      [:tr
@@ -199,13 +206,13 @@
            ;;)
        ))]]]))

-
 (defn handle-multimoddisplay
   [valclusters pos]
   ;; send SPARQL over HTTP request
   (let [headerset1 (str "Paradigm " "Number " "Person " "Gender " "Token ")
         headerset2 (str "pdgm " "num " "pers " "gen ")
         headers (split headerset2 #" ")
+        ;;valclusters2 (addpnum valclusters)
         pdgmvec (map #(vc2req  % pos) valclusters)
         header (first pdgmvec)
         pdgmstr1 (apply pr-str pdgmvec)


correct entity permission errors

correct entity permission errors

--- src/clj_money/permissions/entities.clj
+++ src/clj_money/permissions/entities.clj
@@ -5,10 +5,11 @@
             [clj-money.models.grants :as grants]))

 (authorization/allow :entity
-       (fn [user resource _ _]
-         (= (:id user) (:user-id resource))))
+                     (fn [user resource _ _]
+                       (= (:id user) (:user-id resource))))
 (authorization/allow :entity
                      (fn [user resource action {storage-spec :storage-spec}]
                        ; :show permission is implicit on entity with the grant
-                       (grants/search storage-spec {:user-id (:id user)
-                                                    :entity-id (:id resource)})))
+                       (and (:id resource)
+                            (seq (grants/search storage-spec {:user-id (:id user)
+                                                              :entity-id (:id resource)})))))


Fix pack_it merge issue

Fix pack_it merge issue

--- src/cljs/ikea_clojure_cup/pack_it.cljs
+++ src/cljs/ikea_clojure_cup/pack_it.cljs
@@ -15,23 +15,12 @@
 (defn pack-it-view
   [result-state progress-fn]
   (fn [_ _]
-<<<<<<< HEAD
     [:section.center
-=======
-    [:section
-     [:p (str @result-state)]
->>>>>>> 34e04bae4cd0f3036e8b7f29dbdb1269f5476a10
      (case (:result @result-state)
        :yes [:div
             [:img {:src "img/itFits.png"}]]
        :no [:div
             [:img {:src "img/itDoesNotFit.png"}]]
        :partial [:div
-<<<<<<< HEAD
-                 [:div
-            [:img {:src "img/itFitMayBe.png"}]]
-                 [:p "It'll should fit better if you remove: " (cs/join "," (map #(-> % :id str) (:missing @result-state)))]])]))
-=======
-                 (heading "...kinda fits")
+                 [:img {:src "img/itFitsMayBe.png"}]
                  [:p "It'll should fit better if you remove: " (cs/join "," (map #(-> % :name str) (:missing @result-state)))]])]))
->>>>>>> 34e04bae4cd0f3036e8b7f29dbdb1269f5476a10


more vec2 functions

more vec2 functions

--- src/cljs/infinitelives/utils/vec2.cljs
+++ src/cljs/infinitelives/utils/vec2.cljs
@@ -83,3 +83,90 @@
    (Vec2/negate v (make)))
   ([v0 v1]
    (Vec2/subtract v0 v1 (make))))
+
+(defn dot
+  "Returns the dot product of v0 and v1"
+  [v0 v1]
+  (Vec2/dot v0 v1))
+
+(defn scale
+  "Returns a vector that is v, multiplied by the scalar."
+  [v scalar]
+  (Vec2/scale v scalar (make)))
+
+(defn unit
+  "Returns a unit vector that points in the same direction as v"
+  [v]
+  (Vec2/normalize v (make)))
+
+(defn abs
+  "Returns a vector that is a flipped and mirrored
+  version of v, such that it appears in the positive quadrant"
+  [v]
+  (Vec2/abs v (make)))
+
+(defn direction
+  "returns a unit vector indicating the direction
+  from the tip of v0, to the tip of v1"
+  [v0 v1]
+  (Vec2/direction v0 v1 (make)))
+
+(defn rotate
+  "return a vector identical to v but rotated
+  ang radians"
+ [v ang]
+  (let [cos (Math/cos ang)
+        sin (Math/sin ang)]
+    (vec2 (- (* cos (aget v 0)) (* sin (aget v 1)))
+          (+ (* cos (aget v 1)) (* sin (aget v 0))))))
+
+(defn random-unit
+  "Return a vector pointing in a random direction, but of exactly unit
+  length"
+  []
+  (let [ang (* (rand) Math/PI 2)]
+    (vec2 (Math/cos ang)
+          (Math/sin ang))))
+
+(defn random
+  "return a random vector that fits entirely in the unit circle, that
+  is, whose length is always less than or equal to one."
+  []
+  (let [mag (Math/sqrt (rand))
+        ang (* (rand) Math/PI 2)]
+    (vec2 (* mag (Math/cos ang))
+          (* mag (Math/sin ang)))))
+
+(defn lerp
+  "linearly interperet a vector between v0 and v1. f is the factor
+  along the interpolation. f=0 is v0. f=1 is v1. f can extend outside
+  0 and 1"
+  [v0 v1 f]
+  (Vec2/lerp v0 v1 f (make)))
+
+(defn heading
+  "horrible function you shouldn't really use. Just keep working with
+  vectors directly. Returns the angle of the vector. Answers always
+  between 0 and 2*PI"
+  [v]
+  (let [pi-on-2 (/ Math/PI 2)
+        x (aget v 0)
+        y (aget v 1)]
+    (if (= 0 x)
+      ;; vertical
+      (if (neg? y)
+        (* 3 pi-on-2)
+        pi-on-2)
+
+      (if (= 0 y)
+        ;; horizontal
+        (if (neg? x)
+          Math/PI
+          0)
+
+        ;; calculable angle
+        (if (pos? x)
+          (if (pos? y)
+            (Math/atan (/ y x))
+            (+ Math/PI Math/PI (Math/atan (/ y x))))
+          (+ Math/PI (Math/atan (/ y x))))))))


Minor changes on data loading on colors page.

--- src/uxbox/main/data/colors.cljs
+++ src/uxbox/main/data/colors.cljs
@@ -55,9 +55,10 @@
        (rx/of (fetch-collections))
          (->> (rx/filter collections-fetched? s)
               (rx/take 1)
-              (rx/do #(reset! st/loader false))
+              ;; (rx/do #(reset! st/loader false))
               (rx/ignore)))
-      (rx/empty))))
+      (rx/empty)))
+  )

 (defn initialize
   [type id]


Fixup

Fixup

--- src/uxbox/services/projects.clj
+++ src/uxbox/services/projects.clj
@@ -16,6 +16,7 @@
             [uxbox.services.pages :as pages]
             [uxbox.util.data :as data]
             [uxbox.util.transit :as t]
+            [uxbox.util.blob :as blob]
             [uxbox.util.uuid :as uuid]))

@@ -82,18 +83,26 @@

 ;; --- List Projects

-(defn get-projects-for-user
+(declare decode-page-metadata)
+(declare decode-page-data)
+
+(defn get-projects
   [conn user]
   (let [sqlv (sql/get-projects {:user user})]
     (->> (sc/fetch conn sqlv)
-         (map data/normalize-attrs)
-         (map data/strip-delete-attrs))))
+         (map data/normalize)
+
+         ;; This is because the project comes with
+         ;; the first page preloaded and it need
+         ;; to be decoded.
+         (map decode-page-metadata)
+         (map decode-page-data))))

 (defmethod core/query :list-projects
   [{:keys [user] :as params}]
   (s/assert ::user user)
   (with-open [conn (db/connection)]
-    (get-projects-for-user conn user)))
+    (get-projects conn user)))

 ;; --- Retrieve Project by share token

@@ -121,5 +130,20 @@
   (s/assert ::project project)
   (let [sqlv (sql/get-share-tokens-for-project {:project project})]
     (->> (sc/fetch conn sqlv)
-         (map data/normalize-attrs)
-         (map data/strip-delete-attrs))))
+         (map data/normalize))))
+
+;; Helpers
+
+(defn- decode-page-metadata
+  [{:keys [page-metadata] :as result}]
+  (s/assert ::us/bytes page-metadata)
+  (merge result (when page-metadata
+                  {:page-metadata (blob/decode->str page-metadata)})))
+
+(defn- decode-page-data
+  [{:keys [page-data] :as result}]
+  (s/assert ::us/bytes page-data)
+  (merge result (when page-data
+                  {:page-data (blob/decode->str page-data)})))
+
+


tests on by default

tests on by default

--- src/me/panzoo/story.clj
+++ src/me/panzoo/story.clj
@@ -442,10 +442,15 @@
   []
   (re-pattern (str (comment) "%require +")))

-(defn testcode
-  "A regular expression matching the beginning of a test comment."
+(defn test-begin
+  "A regular expression matching a test-begin line."
   []
-  (re-pattern (str (comment) "\\? ")))
+  (re-pattern (str (comment) "<\\?")))
+
+(defn test-end
+  "A regular expression matching a test-end line."
+  []
+  (re-pattern (str (comment) "\\?>")))

 ; ## Parsing
@@ -554,7 +559,8 @@
       [text]
       (m include) [[:include (include-info text)]]
       (m required) []
-      (m testcode) [[:testcode text]]
+      (m test-begin) [[:test-begin text]]
+      (m test-end) [[:test-end text]]
       (m anchor) [[:anchor text]]
       (m heading) [[:anchor text]
                    [:comment (m markdown)]]
@@ -579,7 +585,7 @@
   [lines]
   (lazy-seq
     (when-let [classfn (first (first lines))]
-      (if (#{:comment :code :testcode} classfn)
+      (if (#{:comment :code} classfn)
         (let [[same tail] (split-with #(= classfn (first %)) lines)
               text (string/join "\n" (map second same))]
           (cons [classfn text] (gather-lines- tail)))
@@ -658,17 +664,16 @@
                   "
"))))

 (defmethod html<- :comment [[_ text]]
-  (message text)
   (println (.markdownToHtml processor text link-renderer)))

 (defmethod html<- :anchor [[_ text]]
   (println (str "")))

 (defmethod html<- :include [[_ [path comment lang] :as args]]
-    (render-file "
" path comment lang))
-
-(defmethod html<- :testcode [[_ text]]
-  (html<- [:code text]))
+  (render-file "
" path comment lang))
+
+(defmethod html<- :test-begin [_])
+(defmethod html<- :test-end [_])

 ; ## Look and feel
@@ -783,10 +788,11 @@

 ; ## Testing

-(defn write-test-file
+(defn write-production-file
   ""
   [in-file outdir]
-  (let [out-file (io/file outdir in-file)]
+  (let [out-file (io/file outdir in-file)
+        in-test? (atom false)]
     (.. out-file (getParentFile) (mkdirs))
     (map-lines
       in-file out-file
@@ -794,28 +800,41 @@
         (let [m (partial ?match line)]
           (cond-let
             [text]
-            (m testcode) text
-
-            (m include)
-            (let [[path comment lang] (include-info text)]
-              (binding [*path* path]
-                (binding [*single-comment* comment]
-                  (binding [*language* lang]
-                    (write-test-file path outdir)))))
-
-            (m required)
-            (io/copy text (io/file outdir text))
-
-            :else line))))))
-
-(defn write-test-tree
+            (m test-begin)
+            (do (reset! in-test? true)
+              line)
+
+            (m test-end)
+            (do (reset! in-test? false)
+              line)
+
+            :else
+            (if @in-test?
+              (str *single-comment* line)
+              (cond-let
+                [text]
+                (m include)
+                (let [[path comment lang] (include-info text)]
+                  (binding [*path* path]
+                    (binding [*single-comment* comment]
+                      (binding [*language* lang]
+                        (write-production-file path outdir))))
+                  line)
+
+                (m required)
+                (do (io/copy text (io/file outdir text))
+                  line)
+
+                :else line))))))))
+
+(defn write-production-tree
   ""
   [in-paths outdir]
   (when (fs/exists? outdir)
     (fs/deltree outdir))
   (fs/mkdir outdir)
   (doseq [p in-paths]
-    (write-test-file p outdir)))
+    (write-production-file p outdir)))

 ; ## Commandline
@@ -834,7 +853,7 @@
                  ["-t" "--theme" "SyntaxHighlighter theme file"]
                  ["-l" "--language" "SyntaxHighlighter language"]
                  ["-s" "--stylesheet" "A stylesheet file to include"]
-                 ["-t" "--testtree" "Test tree directory (no documentation)."]
+                 ["-p" "--production" "Production directory."]
                  ["-v" "--verbose" "Turn on verbose output"
                   :default false :flag true]
                  ["-h" "--help" "Show this help" :default false :flag true])]
@@ -860,8 +879,8 @@
                 *language* (canonical-lang (or (:language amap) *language*))]

 ; When no output file is given, the program renders to standard-out.
-        (if-let [tt (:testtree amap)]
-          (write-test-tree tail tt)
+        (if-let [dir (:production amap)]
+          (write-production-tree tail dir)
           (if (= 1 (count tail))
             (process-files tail *out*)
             (process-files (butlast tail) (last tail))))))))


Update reply to address to be no reply rather than hello for outbound emails.

--- src/oc/email/mailer.clj
+++ src/oc/email/mailer.clj
@@ -18,11 +18,11 @@
    :secret-key c/aws-secret-access-key
    :endpoint   c/aws-endpoint})

-(def default-reply-to (str "hello@" c/email-from-domain))
+(def default-reply-to (str "Carrot.No.Reply@" c/email-from-domain))
 (def default-from "Carrot")
 (def default-source (str default-from " <" default-reply-to ">"))

-(def digest-reply-to (str "digest@" c/email-from-domain))
+(def digest-reply-to (str "Carrot.No.Reply@" c/email-from-domain))
 (def digest-source (str default-from " <" digest-reply-to ">"))

 (defn- email


Update builtins.clj

Update builtins.clj

--- src/iyye/subcon/knowledge/builtins.clj
+++ src/iyye/subcon/knowledge/builtins.clj
@@ -46,26 +46,30 @@
            (= p2-name (:sub p1-data))))))

 (defn iyye_is_type_function [p1-type p2-type]
-    (when (and p1-type p2-type)
-      (let [p1-supertype (assoc @iyye_is_type :Data {:super (:Name (:atom p2-type))})
-            p2-subtype (assoc @iyye_is_type :Data {:sub (:Name (:atom p1-type))})
+  (when (and p1-type p2-type)
+    (let [is_type #(words/action-words @iyye_is_type)]
+      (let [p1-supertype (assoc (is_type) :Data {:super (:Name (:atom p2-type))})
+            p2-subtype (assoc (is_type) :Data {:sub (:Name (:atom p1-type))})
             new-p1-type (assoc p1-type :Relations
                                        (conj (:Relations p1-type) p1-supertype))
             new-p2-type (assoc p2-type :Relations
                                        (conj (:Relations p1-type) p2-subtype))]
       (do
         (words/set-iyye-type! new-p1-type)
-        (words/set-iyye-type! new-p2-type)))))
+        (words/set-iyye-type! new-p2-type))))))

 (defn iyye_is_type_create_function [p1-name p2-type]
   (let [p1-type (words/create-iyye-type p1-name)]
     (when (and p1-type p2-type)
-      (let [new-p1-type (assoc p1-type :Relations (conj (:Relations p1-type)))
-            p2-subtypes (assoc @iyye_is_type :Data {:sub (:Name (:atom p1-type))})
+      (let [is_type #(words/action-words @iyye_is_type)]
+        (let [new-p1-type (assoc p1-type :Relations
+                                       (conj (:Relations p1-type)))
+            p2-subtypes (assoc (is_type) :Data
+                                             {:sub (:Name (:atom p1-type))})
             new-p2-type (assoc p2-type :Relations p2-subtypes)]
       (do
         (words/set-iyye-type! new-p1-type)
-        (words/set-iyye-type! new-p2-type))))))
+        (words/set-iyye-type! new-p2-type)))))))

 (defn iyye_consists_function [p1 p2]
   (let [])
@@ -84,7 +88,7 @@
 ;(defn ^{:source "(+ 1 a)"} aaa [a] (+ 1 a))
 ;(defmacro getsrc [func] `(:source (meta (var ~func))))

-(defn create-iyye-builtin-relation [name types func pred-func]
+(defn- create-iyye-builtin-relation [name types func pred-func]
   (words/create-iyye-relation name
                               (words/->Iyye_ModalPredicate :IYE :AXIOM (persistence/current-time-to-string) :ALWAYS)
                               types func pred-func true))
@@ -96,32 +100,36 @@
         ai (words/create-iyye-type "ai" true)
         iyye (words/create-iyye-type "iyye" true)
         human (words/create-iyye-type "human" true)
-        yumzya (words/create-iyye-type "yumzya" true)]
-    (dosync (ref-set iyye_actor actor))
-    (dosync (ref-set iyye_ai ai))
-    (dosync (ref-set iyye_iyye iyye))
-    (dosync (ref-set iyye_human human))
-    (dosync (ref-set iyye_yumzya yumzya))
+        yumzya (words/create-iyye-type "yumzya" true)
+        uname #(:Uname (:atom %))]
+    (dosync (ref-set iyye_actor (uname actor)))
+    (dosync (ref-set iyye_ai (uname ai)))
+    (dosync (ref-set iyye_iyye (uname iyye)))
+    (dosync (ref-set iyye_human (uname human)))
+    (dosync (ref-set iyye_yumzya (uname yumzya)))
     (dosync (alter words/noun-words conj (create-entry actor)
                    (create-entry ai) (create-entry iyye) (create-entry human)
                    (create-entry yumzya)))))

-(defn init-builtin-relations []
+(defn- init-builtin-relations []
   (let [t_is (create-iyye-builtin-relation "is" ["type" "type"] iyye_is_type_function iyye_is_type_predicate_function)
         t_is2 (create-iyye-builtin-relation "is" [:UNKNOWN "type"] iyye_is_type_create_function iyye_is_type_predicate_function)
         consistsof (create-iyye-builtin-relation "consists" [] iyye_consists_function iyye_is_type_predicate_function)
-        instof (create-iyye-builtin-relation "instance" ["type"] iyye_instance_function iyye_is_type_predicate_function)]
-    (dosync (ref-set iyye_is_type t_is))
-    (dosync (ref-set iyye_consists_type consistsof))
-    (dosync (ref-set iyye_create_instance instof))
+        instof (create-iyye-builtin-relation "instance" ["type"] iyye_instance_function iyye_is_type_predicate_function)
+        uname #(:Uname (:atom %))]
+    (dosync (ref-set iyye_is_type (uname t_is)))
+    (dosync (ref-set iyye_consists_type (uname consistsof)))
+    (dosync (ref-set iyye_create_instance (uname instof)))
     (dosync (alter words/action-words conj (create-entry t_is) (create-entry t_is2) (create-entry consistsof) (create-entry instof)))))

-(defn apply-builtin-relations []
-  (do
-    ((:Function @iyye_is_type) @iyye_ai @iyye_actor)
-    ((:Function @iyye_is_type) @iyye_human @iyye_actor)
-    ((:Function @iyye_is_type) @iyye_iyye @iyye_ai)
-    ((:Function @iyye_is_type) @iyye_yumzya @iyye_human)))
+(defn- apply-builtin-relations []
+  (let [get-type #(words/noun-words %)
+        get-function #(:Function (words/action-words %))]
+    (do
+      ((get-function @iyye_is_type) (get-type @iyye_ai) (get-type @iyye_actor))
+      ((get-function @iyye_is_type) (get-type @iyye_human) (get-type @iyye_actor))
+      ((get-function @iyye_is_type) (get-type @iyye_iyye) (get-type @iyye_ai))
+      ((get-function @iyye_is_type) (get-type @iyye_yumzya) (get-type @iyye_human)))))

 (defn- init-builtins-kb []
   (init-builtin-words)


Fix media driver query.

Fix media driver query.

--- src/onyx/http_query.clj
+++ src/onyx/http_query.clj
@@ -63,7 +63,7 @@
   {{:uri "/network/media-driver"
     :request-method :get}
    {:doc "Returns a map describing the media driver status."
-    :f (fn [request _ _ _] (onyx.peer-query.aeron/media-driver-health))}
+    :f (fn [request _ _ _] {:result (onyx.peer-query.aeron/media-driver-health)})}

    {:uri "/network/media-driver/active"
     :request-method :get}


Add spaces back or the leiningen template thingy gets confused :(

--- src/leiningen/new/chestnut/project.clj
+++ src/leiningen/new/chestnut/project.clj
@@ -67,7 +67,7 @@

                    :env {:is-dev true}

-                   :cljsbuild {:test-commands {{{{test-command-name}}} {{{test-command}}}}
+                   :cljsbuild {:test-commands { {{{test-command-name}}} {{{test-command}}} }
                                :builds {:app {:source-paths ["env/dev/cljs"]}
                                         :test {:source-paths ["src/cljs" {{{test-src-path}}}]
                                                :compiler {:output-to     "resources/public/js/app_test.js"


collect trailing args only

collect trailing args only

--- src/main/clojure/clojure/tools/cli.clj
+++ src/main/clojure/clojure/tools/cli.clj
@@ -70,7 +70,7 @@
                 (drop 2 args))

          :default
-         (recur (update-in result [:args] conj (first args)) (rest args)))))))
+         (recur (assoc result :args args) nil))))))

 (defn switches-for
   [switches flag]


endpoint/request for templates added

endpoint/request for templates added

--- src/main/clojure/pdok/featured/api.clj
+++ src/main/clojure/pdok/featured/api.clj
@@ -116,6 +116,13 @@
       (r/status (r/response invalid) 400)
       (do (go (>! request-chan request)) (r/response {:result :ok})))))

+(defn- template-request [http-req]
+  (let [request (:body http-req)
+        invalid (s/check TemplateRequest request)]
+    (if invalid
+      (r/status (r/response invalid) 400)
+      (r/response {:result :ok}))))
+
 (defn api-routes [process-chan extract-chan callback-chan stats]
   (defroutes api-routes
     (context "/api" []
@@ -123,7 +130,8 @@
              (POST "/ping" [] (fn [r] (log/info "!ping pong!" (:body r)) (r/response {:pong (tl/local-now)})))
              (GET "/stats" [] (r/response @stats))
              (POST "/process" [] (partial process-request ProcessRequest process-chan))
-             (POST "/extract" [] (partial process-request ExtractRequest extract-chan )))
+             (POST "/extract" [] (partial process-request ExtractRequest extract-chan ))
+             (POST "/template" [] (fn [r] (log/info "Template request: " (:body r)) (r/response (template-request r)))))
     (route/not-found "NOT FOUND")))

 (defn rest-handler [& more]


Refactor akvo.lumen.lib.public namespace

--- backend/src/akvo/lumen/lib/public.clj
+++ backend/src/akvo/lumen/lib/public.clj
@@ -17,127 +17,30 @@
 (defn get-share [tenant-conn id]
   (public-by-id tenant-conn {:id id}))

-(defmulti visualisation (fn [_ visualisation config]
-                          (:visualisationType visualisation)))
-
-(defmethod visualisation "pivot table"
-  [tenant-conn visualisation config]
-  (let [dataset-id (:datasetId visualisation)
-        [dataset-tag dataset] (dataset/fetch-metadata tenant-conn dataset-id)
+(defn run-visualisation
+  [tenant-conn visualisation]
+  (let [visualisation (keywordize-keys visualisation)
+        [dataset-tag dataset] (dataset/fetch-metadata tenant-conn (:datasetId visualisation))
+        vis-aggregation-mapper {"pivot table" "pivot"
+                                "line"      "line"
+                                "bubble"    "bubble"
+                                "area"      "line"
+                                "pie"       "pie"
+                                "donut"     "donut"
+                                "polararea" "pie"
+                                "bar"       "bar"
+                                "scatter"   "scatter"}
+        aggregation-type (get vis-aggregation-mapper (:visualisationType visualisation))
         [tag query-result] (aggregation/query tenant-conn
-                                              dataset-id
-                                              "pivot"
+                                              (:datasetId visualisation)
+                                              aggregation-type
                                               (:spec visualisation))]
     (when (and (= tag ::lib/ok)
                (= dataset-tag ::lib/ok))
       {"visualisations" {(:id visualisation) (assoc visualisation :data query-result)}
-        "datasets" { dataset-id dataset}})))
+       "datasets" { (:id dataset) dataset}})))

-(defmethod visualisation "line"
-  [tenant-conn visualisation config]
-  (let [dataset-id (:datasetId visualisation)
-        [dataset-tag dataset] (dataset/fetch-metadata tenant-conn dataset-id)
-        [tag query-result] (aggregation/query tenant-conn
-                                              dataset-id
-                                              "line"
-                                              (:spec visualisation))]
-    (when (and (= tag ::lib/ok)
-               (= dataset-tag ::lib/ok))
-      {"visualisations" {(:id visualisation) (assoc visualisation :data query-result)}
-        "datasets" { dataset-id dataset}})))
-
-(defmethod visualisation "bubble"
-  [tenant-conn visualisation config]
-  (let [dataset-id (:datasetId visualisation)
-        [dataset-tag dataset] (dataset/fetch-metadata tenant-conn dataset-id)
-        [tag query-result] (aggregation/query tenant-conn
-                                              dataset-id
-                                              "bubble"
-                                              (:spec visualisation))]
-    (when (and (= tag ::lib/ok)
-                (= dataset-tag ::lib/ok))
-      {"visualisations" {(:id visualisation) (assoc visualisation :data query-result)}
-        "datasets" { dataset-id dataset}})))
-
-(defmethod visualisation "area"
-  [tenant-conn visualisation config]
-  (let [dataset-id (:datasetId visualisation)
-        [dataset-tag dataset] (dataset/fetch-metadata tenant-conn dataset-id)
-        [tag query-result] (aggregation/query tenant-conn
-                                              dataset-id
-                                              "line"
-                                              (:spec visualisation))]
-    (when (and (= tag ::lib/ok)
-               (= dataset-tag ::lib/ok))
-      {"visualisations" {(:id visualisation) (assoc visualisation :data query-result)}
-        "datasets" { dataset-id dataset}})))
-
-(defmethod visualisation "pie"
-  [tenant-conn visualisation config]
-  (let [dataset-id (:datasetId visualisation)
-        [dataset-tag dataset] (dataset/fetch-metadata tenant-conn dataset-id)
-        [tag query-result] (aggregation/query tenant-conn
-                                              dataset-id
-                                              "pie"
-                                              (:spec visualisation))]
-    (when (and (= tag ::lib/ok)
-               (= dataset-tag ::lib/ok))
-      {"visualisations" {(:id visualisation) (assoc visualisation :data query-result)}
-        "datasets" { dataset-id dataset}})))
-
-(defmethod visualisation "donut"
-  [tenant-conn visualisation config]
-  (let [dataset-id (:datasetId visualisation)
-        [dataset-tag dataset] (dataset/fetch-metadata tenant-conn dataset-id)
-        [tag query-result] (aggregation/query tenant-conn
-                                              dataset-id
-                                              "pie"
-                                              (:spec visualisation))]
-    (when (and (= tag ::lib/ok)
-               (= dataset-tag ::lib/ok))
-      {"visualisations" {(:id visualisation) (assoc visualisation :data query-result)}
-        "datasets" { dataset-id dataset}})))
-
-(defmethod visualisation "polararea"
-  [tenant-conn visualisation config]
-  (let [dataset-id (:datasetId visualisation)
-        [dataset-tag dataset] (dataset/fetch-metadata tenant-conn dataset-id)
-        [tag query-result] (aggregation/query tenant-conn
-                                              dataset-id
-                                              "pie"
-                                              (:spec visualisation))]
-    (when (and (= tag ::lib/ok)
-                (= dataset-tag ::lib/ok))
-      {"visualisations" {(:id visualisation) (assoc visualisation :data query-result)}
-        "datasets" { dataset-id dataset}})))
-
-(defmethod visualisation "bar"
-  [tenant-conn visualisation config]
-  (let [dataset-id (:datasetId visualisation)
-        [dataset-tag dataset] (dataset/fetch-metadata tenant-conn dataset-id)
-        [tag query-result] (aggregation/query tenant-conn
-                                              dataset-id
-                                              "bar"
-                                              (:spec visualisation))]
-    (when (and (= tag ::lib/ok)
-               (= dataset-tag ::lib/ok))
-      {"visualisations" {(:id visualisation) (assoc visualisation :data query-result)}
-        "datasets" { dataset-id dataset }})))
-
-(defmethod visualisation "scatter"
-  [tenant-conn visualisation config]
-  (let [dataset-id (:datasetId visualisation)
-        [dataset-tag dataset] (dataset/fetch-metadata tenant-conn dataset-id)
-        [tag query-result] (aggregation/query tenant-conn
-                                              dataset-id
-                                              "scatter"
-                                              (:spec visualisation))]
-    (when (and (= tag ::lib/ok)
-               (= dataset-tag ::lib/ok))
-      {"visualisations" {(:id visualisation) (assoc visualisation :data query-result)}
-        "datasets" { dataset-id dataset}})))
-
-(defmethod visualisation "map"
+(defn run-map-visualisation
   [tenant-conn visualisation {:keys [windshaft-url]}]
   (let [layers (get-in visualisation [:spec "layers"])]
     (if (some #(get % "datasetId") layers)
@@ -154,8 +57,8 @@
             {"visualisations" {(:id visualisation) (merge visualisation map-data)}
              "metadata" {(:id visualisation) map-data}})))))

-(defmethod visualisation :default
-  [tenant-conn visualisation config]
+(defn run-unknown-type-visualisation
+  [tenant-conn visualisation]
   (let [dataset-id (:datasetId visualisation)
         [tag dataset] (dataset/fetch-metadata tenant-conn dataset-id)]
     (when (= tag ::lib/ok)
@@ -164,16 +67,15 @@

 (defn visualisation-response-data [tenant-conn id config]
   (try
-    (let [[tag vis] (visualisation/fetch tenant-conn id)
-          ;; provisional condition until akvo.lumen.lib.visualisation.maps is keywordized, tested and speced too
-          vis (if (= "map" (:visualisationType vis))
-                vis
-                (update vis :spec keywordize-keys))]
-     (when (= tag ::lib/ok)
-       (visualisation tenant-conn vis config)))
-    (catch Exception e (do
-                         (log/warn e ::visualisation-response-data (str "problems fetching this vis-id: " id))
-                         nil))))
+    (let [vis-types #{"pivot table" "line" "bubble" "area" "pie" "donut" "polararea" "bar" "scatter" "map"}
+          [tag vis] (visualisation/fetch tenant-conn id)]
+      (when (= tag ::lib/ok)
+        (condp contains? (:visualisationType vis)
+          #{"map"} (run-map-visualisation tenant-conn vis config)
+          vis-types (run-visualisation tenant-conn vis)
+          (run-unknown-type-visualisation tenant-conn vis))))
+    (catch Exception e
+      (log/warn e ::visualisation-response-data (str "problems fetching this vis-id: " id)))))

 (defn dashboard-response-data [tenant-conn id config]
   (let [[tag dashboard] (dashboard/fetch tenant-conn id)]


Load symbols in the values as well

Load symbols in the values as well

--- src/search/core.clj
+++ src/search/core.clj
@@ -69,6 +69,7 @@
    :graph (fnk [graphs :- [utils/Graph]] (apply g/graph graphs))
    :values-graph (fnk [values :- {s/Keyword s/Any}]
                   (->> values
+                    utils/eval-load-ns
                     (plumbing.core/map-vals utils/v->fnk)
                     g/graph))
    :wrappers (fnk [wrapper-forms :- [Wrapper]] (map utils/eval-load-ns wrapper-forms))


Fixing issues with migrating indices

Fixing issues with migrating indices

--- joplin.elasticsearch/src/joplin/elasticsearch/database.clj
+++ joplin.elasticsearch/src/joplin/elasticsearch/database.clj
@@ -87,14 +87,15 @@
   ([old-index mapping-type new-index trans-f]
      (let [es-client (ensure-connected)]
        (dorun
-        (->> (esd/search old-index
+        (->> (esd/search es-client
+                         old-index
                          mapping-type
                          :query {:match_all {}})
-             (esd/scroll-seq)
+             (esd/scroll-seq es-client)
              (map :_source)
              (map trans-f)
              (pmap (fn [doc]
-                     (esd/create new-index mapping-type doc :id (:_id doc)))))))))
+                     (esd/create es-client new-index mapping-type doc :id (:_id doc)))))))))

 ;; ============================================================================
 ;; Functions for use within migrations
@@ -152,8 +153,8 @@
   (let [es-client (ensure-connected)
         current-index (first (find-index-names alias-name))
         mappings (:mappings ((esi/get-mapping es-client current-index) (keyword current-index)))
-        settings (-> ((get-settings es-client) (name current-index))
-                     (update-in ["index"] dissoc "uuid" "version"))
+        settings (-> (into {} ((get-settings es-client) (name current-index)))
+                     (update-in ["index"] #(dissoc (into {} %) "uuid" "version")))
         update-map (apply hash-map updates)
         mappings-u (or (:mappings update-map) {})
         settings-u (or (:settings update-map) {})]


Cat command.

Cat command.

--- src/mash_commander/nix/filesystem.cljs
+++ src/mash_commander/nix/filesystem.cljs
@@ -91,6 +91,14 @@
                                   :type :file
                                   :contents ""}))))

+(defn cat-cmd [param]
+  (let [f (get (:files (cwd)) param)]
+    (cond
+      (not (contains? (:mod f) :r))
+      "409 error: permission denied"
+      :default
+      (:contents f))))
+
 (defn init []
   (om/update!
    (fs-cursor)
@@ -124,10 +132,15 @@
                                          :args [["color red" "color blue" "color green" "color white"]]
                                          :help "`set` appearance. E.g `set color red`."}
                                   "touch" {:mod #{:x}
-                                          :type :file
-                                          :fn touch-cmd
-                                          :args [:alpha]
-                                          :help "`touch` creates an empty file."}}}
+                                           :type :file
+                                           :fn touch-cmd
+                                           :args [:alpha]
+                                           :help "`touch` creates an empty file."}
+                                  "cat" {:mod #{:x}
+                                         :type :file
+                                         :fn cat-cmd
+                                         :args [:file]
+                                         :help "`cat` shows the contents of a file"}}}
                    "usr" {:mod #{:r :w}
                           :type :dir
                           :files {}}}}
@@ -142,6 +155,12 @@

 (defn args-trie [args-spec]
   (cond
+    ;; Looking for a valid file in the current working directory
+    (= :file args-spec)
+    (let [everything (seq (:files (cwd)))
+          files (filter #(= :file (:type (second %))) everything)
+          names (map first files)]
+      (trie/build names))
     ;; Looking for a valid directory in the current working directory
     (= :dir args-spec)
     (let [everything (seq (:files (cwd)))
@@ -154,7 +173,7 @@
     (= :cmd args-spec)
     (trie/build (keys (command-map)))
     ;; Any characters a-z
-    :alpha
+    (= :alpha args-spec)
     (alpha-trie 0)
     ;; Pre-specified parameters
     :default


get-current-movies now returns json objects, e.g. [ {'name' : 'Movie Name'}, {'name' : 'Another Movie'}]

--- src/cine/server.clj
+++ src/cine/server.clj
@@ -18,7 +18,7 @@
 (defn current-movie-list-handler [req]
   {:status 200
    :headers {"Content-type" "text"}
-   :body (cheshire/generate-string (cine/get-current-movies))})
+   :body (cheshire/generate-string (cine/mapify-current-movies))})

 (defn upcoming-movie-list-handler [req]
   {:status 200


use hyphen delimiter

use hyphen delimiter

--- src/collar/page.clj
+++ src/collar/page.clj
@@ -92,7 +92,7 @@
   "Construct native representation of file."
   [file]
   (let [name (clojure.string/replace (.getName file) #"\.md$" "")
-        short (clojure.string/replace name "_" " ")
+        short (clojure.string/replace name "-" " ")
         data (get-file file)
         meta (:metadata data)]
     {:name name


Add missing copyright header on media ns.

--- src/uxbox/media.clj
+++ src/uxbox/media.clj
@@ -1,3 +1,9 @@
+;; This Source Code Form is subject to the terms of the Mozilla Public
+;; License, v. 2.0. If a copy of the MPL was not distributed with this
+;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
+;;
+;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>
+
 (ns uxbox.media
   "A media storage persistence layer.")


stop function of Websocket component fixed

--- src/hellhound/components/websocket.clj
+++ src/hellhound/components/websocket.clj
@@ -7,7 +7,9 @@
   (:require [hellhound.connection.server             :refer [event-router]]
             [hellhound.system                        :refer [get-system]]
             [com.stuartsierra.component              :as component]
-            [taoensso.sente :as sente]
+            [taoensso.sente                          :as sente]
+            [taoensso.encore :as enc :refer (swap-in! reset-in! swapped have have! have?)]
+            [taoensso.sente.interfaces :as interfaces]
             ;[taoensso.sente.server-adapters.http-kit :refer (sente-web-server-adapter)]
             [taoensso.sente.server-adapters.immutant :refer [get-sch-adapter]]))

@@ -18,29 +20,30 @@
   (let [func (:chsk-send! (:websocket (get-system)))]
     (func :sente/all-users-without-uid event)))

-(defrecord WebSocketServer [ring-ajax-post ring-ajax-get-or-ws-handshake
-                            ch-chsk chsk-send! connected-uids router
-                            web-server-adapter handler options]
+(defrecord WebSocketServer [web-server-adapter handler options adapter]
   component/Lifecycle
   (start [component]
-    (let [handler (get-in component [:sente-handler :handler] handler)
-          {:keys [ch-recv send-fn ajax-post-fn ajax-get-or-ws-handshake-fn connected-uids]}
-          (sente/make-channel-socket-server! web-server-adapter options)
+    (let [{:keys [ch-recv send-fn ajax-post-fn ajax-get-or-ws-handshake-fn connected-uids]}
+          (sente/make-channel-socket-server! adapter  options) ;;web-server-adapter
           component (assoc component
-                           :ring-ajax-post ajax-post-fn
+                           :ring-ajax-post                ajax-post-fn
                            :ring-ajax-get-or-ws-handshake ajax-get-or-ws-handshake-fn
-                           :ch-chsk ch-recv
-                           :chsk-send! send-fn
-                           :connected-uids connected-uids)]
+                           :ch-chsk                       ch-recv
+                           :chsk-send!                    send-fn
+                           :adapter                       adapter
+                           :connected-uids                connected-uids)]
+
       (assoc component
              :router (sente/start-chsk-router!
                       ch-recv (if (:wrap-component? options)
                                 (handler component)
                                 handler)))))
   (stop [component]
-    (if-let [stop-f router]
-      (assoc component :router (stop-f))
-      component)))
+    (let [router (:router component)]
+      (if (not (nil? router))
+        (do
+          (router)
+          (assoc component :router nil))))))

@@ -51,8 +54,9 @@
    (new-channel-socket-server event-msg-handler web-server-adapter {}))
   ([event-msg-handler web-server-adapter options]
    (map->WebSocketServer {:web-server-adapter web-server-adapter
-                              :handler event-msg-handler
-                              :options options})))
+                          :handler event-msg-handler
+                          :options options
+                          :adapter (get-sch-adapter)})))

 (defn make-websocket


Makes db code generation dirs configurable

- larva.frameworks.luminus.stuff/migrations-dir &
  larva.frameworks.luminus.stuff/queries-dir are now dynamic variables

--- src/larva/frameworks/luminus/stuff.clj
+++ src/larva/frameworks/luminus/stuff.clj
@@ -3,9 +3,9 @@
   (:require [clojure.java.io :refer [resource]]))

 (def ^:private queries-templates-dir "db/sql/")
-(def queries-dir "resources/sql/")
+(def ^:dynamic queries-dir "resources/sql/")
 (def ^:private migrations-templates-dir "db/migrations/")
-(def migrations-dir "resources/migrations/")
+(def ^:dynamic migrations-dir "resources/migrations/")

 (def core-assets
   [[".gitignore" "core/gitignore"]


change versions of clojurescript and om to the latest

--- src/leiningen/new/chestnut/project.clj
+++ src/leiningen/new/chestnut/project.clj
@@ -9,14 +9,14 @@
   :test-paths [{{{clj-test-src-path}}}]

   :dependencies [[org.clojure/clojure "1.7.0"]
-                 [org.clojure/clojurescript "1.7.122" :scope "provided"]
+                 [org.clojure/clojurescript "1.7.145" :scope "provided"]
                  [ring "1.4.0"]
                  [ring/ring-defaults "0.1.5"]
                  [slester/ring-browser-caching "0.1.1"]
                  [bk/ring-gzip "0.1.1"]
                  [compojure "1.4.0"]
                  [enlive "1.1.6"]
-                 [org.omcljs/om "0.9.0"]
+                 [org.omcljs/om "1.0.0-alpha14"]
                  [environ "1.0.0"]{{{project-clj-deps}}}]

   :plugins [[lein-cljsbuild "1.0.5"]


Upgrade ns-tracker dependency to 0.4.0

Upgrade ns-tracker dependency to 0.4.0

--- src/leiningen/new/re_frame/project.clj
+++ src/leiningen/new/re_frame/project.clj
@@ -6,7 +6,7 @@
                  [re-com "2.5.0"]{{/re-com?}}{{#routes?}}
                  [secretary "1.2.3"]{{/routes?}}{{#garden?}}
                  [garden "1.3.9"]
-                 [ns-tracker "0.3.1"]{{/garden?}}{{#handler?}}
+                 [ns-tracker "0.4.0"]{{/garden?}}{{#handler?}}
                  [compojure "1.6.1"]
                  [yogthos/config "0.8"]
                  [ring "1.4.0"]{{/handler?}}{{#re-pressed?}}


removed id attribute in xpath

removed id attribute in xpath

--- src/crawler/dom.clj
+++ src/crawler/dom.clj
@@ -113,9 +113,7 @@
   (let [silent-fail-split (fn [s regex] (try (str/split s regex)
                                             (catch Exception e nil)))]
    (list (.getName a-tagnode)
-         (-> a-tagnode
-            (.getAttributeByName "id")
-            format-attr)
+         nil
          (map
           format-attr
           (-> a-tagnode
@@ -164,22 +162,11 @@
         formatted-classes (map
                            #(format "contains(@class,'%s')" %)
                            class-list)]
-    (cond (and id (not (empty? class-list)))
-          (map
-           #(format "%s[%s and %s]"
-                    tag
-                    formatted-id
-                    %)
-           formatted-classes)
-
-          (and id (empty? class-list))
-          (list
-           (format "%s[%s]" tag formatted-id))
-
-          (and (not (empty? class-list)) (not id))
-          (map #(format "%s[%s]" tag %) formatted-classes)
-
-          :else (list tag))))
+
+
+    (if (not (empty? class-list))
+      (map #(format "%s[%s]" tag %) formatted-classes)
+      (list tag))))

 (defn tag-node->xpath
   [a-tagnode]


Include `only`

Include `only`

--- src/structural_typing/clojure/core.clj
+++ src/structural_typing/clojure/core.clj
@@ -23,7 +23,7 @@
              [such.wrongness
               boom!]
              [such.sequences
-               bifurcate]
+               bifurcate only]
              [such.control-flow
                branch-on]
              [such.immigration


Add saving of initial state when moving into edit mode

--- src/reabledit/core.cljs
+++ src/reabledit/core.cljs
@@ -9,9 +9,11 @@
   [state row col]
   (swap! state assoc :selected [row col]))

-(defn enable-edit-mode!
-  [state row col]
-  (swap! state assoc :edit-mode true))
+(defn enable-edit!
+  [data state]
+  (let [row-data (nth data (first (:selected @state)))]
+    (swap! state assoc :edit {:initial row-data
+                              :updated row-data})))

 ;;
 ;; Keyboard event handlers
@@ -22,7 +24,7 @@
   (if (= 13 (.-keyCode e))
     (do
       (.preventDefault e)
-      (swap! state dissoc :edit-mode)
+      (swap! state dissoc :edit)
       ;; Dirty as fudge, but what can you do with Reagent?
       (.focus (.getElementById js/document id)))
     nil))
@@ -42,12 +44,12 @@
       39 (f current-row (min cols (inc current-col)))
       40 (f (min rows (inc current-row)) current-col)
       9 (f current-row (min cols (inc current-col)))
-      13 (enable-edit-mode! state current-row current-col)
+      13 (enable-edit! data state)
       nil)))

 (defn handle-key-down
   [e headers data state id]
-  (if (:edit-mode @state)
+  (if (:edit @state)
     (handle-editing-mode-key-down e state id)
     (handle-selection-mode-key-down e headers data state)))

@@ -58,10 +60,10 @@
 (defn data-table-cell
   [v nth-row nth-col state]
   (let [selected? (= (:selected @state) [nth-row nth-col])
-        edit-mode? (:edit-mode @state)]
+        edit? (:edit @state)]
     [:td {:class (if selected? "selected")
           :on-click #(set-selected! state nth-row nth-col)}
-     (if (and selected? edit-mode?)
+     (if (and selected? edit?)
        [:input {:type "text"
                 :auto-focus true
                 :value v}]


Update test logger output

Update test logger output

--- test/build_mon/test/vso_api.clj
+++ test/build_mon/test/vso_api.clj
@@ -6,7 +6,7 @@
 (def account "VSO_ACCOUNT_NAME")
 (def project "VSO_PROJECT_NAME")

-(def logger {:log-exception (fn [message exception] (println "Exception:" message))})
+(def logger {:log-exception (fn [message _] (println "Test logger:" message))})

 (fact "vso-api-get-fn wraps an api token and returns a function which makes a HTTP GET request on a url"
       (let [result (api/vso-api-get-fn "VSO_API_TOKEN")]


requiring system-id

requiring system-id

--- src/hooks/hubot.clj
+++ src/hooks/hubot.clj
@@ -16,7 +16,7 @@
 (defn notify-hubot
   "notify a hubot instance that a machine is up"
   [{:keys [event workflow system-id hubot-host]}]
-  {:pre [hubot-host]}
+  {:pre [hubot-host system-id]}
   (client/post (<< "~{hubot-host}/hubot/creation-notify")
                {:body (<< "{\"id\": \"~{system-id}\", \"msg\": \"~(reply workflow event)\"}")
                 :content-type :json


Reuse parts.

Reuse parts.

--- test/onyx/coordinator/cluster_test.clj
+++ test/onyx/coordinator/cluster_test.clj
@@ -6,58 +6,10 @@
             [datomic.api :as d]
             [onyx.system :as s]
             [onyx.coordinator.extensions :as extensions]
-            [onyx.coordinator.log.datomic :as datomic]))
+            [onyx.coordinator.log.datomic :as datomic]
+            [onyx.coordinator.sim-test-utils :refer [with-system]]))

-(def system (s/onyx-system {:sync :zookeeper :queue :hornetq :eviction-delay 500000}))
-
-(def components (alter-var-root #'system component/start))
-
-(def coordinator (:coordinator components))
-
-(def sync-storage (:sync components))
-
-(def log (:log components))
-
-(def tx-queue (d/tx-report-queue (:conn log)))
-
-(def offer-spy (chan 1000))
-
-(tap (:offer-mult coordinator) offer-spy)
-
-(def catalog
-  [{:onyx/name :in
-    :onyx/direction :input
-    :onyx/consumption :sequential
-    :onyx/type :queue
-    :onyx/medium :hornetq
-    :hornetq/queue-name "in-queue"}
-   {:onyx/name :inc
-    :onyx/type :transformer
-    :onyx/consumption :sequential}
-   {:onyx/name :out
-    :onyx/direction :output
-    :onyx/consumption :sequential
-    :onyx/type :queue
-    :onyx/medium :hornetq
-    :hornetq/queue-name "out-queue"}])
-
-(def workflow {:in {:inc :out}})
-
-(def n-jobs 15)
-
-(def n-peers 10)
-
-(def tasks-per-job 3)
-
-(doseq [_ (range n-jobs)]
-  (>!! (:planning-ch-head coordinator) {:catalog catalog :workflow workflow}))
-
-(doseq [_ (range n-jobs)]
-  (<!! offer-spy))
-
-(def peers (take n-peers (repeatedly (fn [] (extensions/create sync-storage :peer)))))
-
-(defn start-peers! [peers]
+(defn start-peers! [peers coordinator sync-storage]
   (doseq [peer peers]
     (go (try
           (let [payload (extensions/create sync-storage :payload)
@@ -84,62 +36,107 @@
                   (recur next-payload)))))
           (catch Exception e (prn e))))))

-(start-peers! peers)
+(defn run-cluster [n-jobs n-peers]
+  (with-system
+    (fn [coordinator sync-storage log]
+      (let [tx-queue (d/tx-report-queue (:conn log))
+            offer-spy (chan 1000)

-(testing "All tasks complete"
-  (loop []
-    (let [db (:db-after (.take tx-queue))
-          query '[:find (count ?task) :where [?task :task/complete? true]]
-          result (ffirst (d/q query db))]
-      (prn result)
-      (when-not (= result (* n-jobs tasks-per-job))
-        (recur)))))
+            catalog [{:onyx/name :in
+                      :onyx/direction :input
+                      :onyx/consumption :sequential
+                      :onyx/type :queue
+                      :onyx/medium :hornetq
+                      :hornetq/queue-name "in-queue"}
+                     {:onyx/name :inc
+                      :onyx/type :transformer
+                      :onyx/consumption :sequential}
+                     {:onyx/name :out
+                      :onyx/direction :output
+                      :onyx/consumption :sequential
+                      :onyx/type :queue
+                      :onyx/medium :hornetq
+                      :hornetq/queue-name "out-queue"}]
+            workflow {:in {:inc :out}}
+            tasks-per-job 3]

-(def result-db (d/db (:conn log)))
+        (tap (:offer-mult coordinator) offer-spy)

-(deftest task-completeness
-  (testing "No tasks are left incomplete"
-    (let [query '[:find (count ?task) :where [?task :task/complete? false]]
-          result (ffirst (d/q query result-db))]
-      (is (nil? result)))))
+        (doseq [_ (range n-jobs)]
+          (>!! (:planning-ch-head coordinator) {:catalog catalog :workflow workflow}))

-(deftest task-safety
-  (testing "No sequential task ever had more than 1 peer"
-    (let [query '[:find ?task (count ?peer) :where
-                  [?task :task/consumption :sequential]
-                  [?peer :peer/task ?task]]
-          result (map second (d/q query (d/history result-db)))]
-      (is (every? (partial = 1) result)))))
+        (doseq [_ (range n-jobs)]
+          (<!! offer-spy))

-(deftest peer-liveness
-  (testing "No peers got 0 tasks"
-    (let [query '[:find ?peer :where
-                  [?peer :peer/task]]
-          result (map first (d/q query (d/history result-db)))]
-      (is (= (count result) n-peers)))))
+        (let [peers (take n-peers (repeatedly (fn [] (extensions/create sync-storage :peer))))]
+          (start-peers! peers coordinator sync-storage)
+          (testing "All tasks complete"
+
+            (loop []
+              (let [db (:db-after (.take tx-queue))
+                    query '[:find (count ?task) :where [?task :task/complete? true]]
+                    result (ffirst (d/q query db))]
+                (prn result)
+                (when-not (= result (* n-jobs tasks-per-job))
+                  (recur)))))

-(deftest peer-fairness
-  (testing "All peers got a roughly even number of tasks assigned"
-    (let [query '[:find ?peer (count ?task) :where
-                  [?peer :peer/task ?task]]
-          result (map second (d/q query (d/history result-db)))
-          mean (/ (* n-jobs tasks-per-job) n-peers)
-          confidence 0.5]
-      (is (every?
-           #(and (<= (- mean (* mean confidence)) %)
-                 (>= (+ mean (* mean confidence)) %))
-           result)))))
+          (d/db (:conn log)))))
+    {:eviction-delay 500000}))

-#_(deftest concurrency-liveness
-  (testing ">= 25% of all concurrency tasks got > 1 peer at some point"
-    (let [query '[:find ?task (count ?peer) :where
-                  [?task :task/consumption :concurrent]
-                  [?peer :peer/task ?task]]
-          result (map second (d/q query (d/history result-db)))]
-      (is (>= (count (filter (partial < 1) result))
-              (/ (* n-jobs tasks-per-job) 0.25))))))
+(defn task-completeness [result-db]
+  (let [query '[:find (count ?task) :where [?task :task/complete? false]]
+        result (ffirst (d/q query result-db))]
+    (is (nil? result))))
+
+(defn task-safety [result-db]
+  (let [query '[:find ?task (count ?peer) :where
+                [?task :task/consumption :sequential]
+                [?peer :peer/task ?task]]
+        result (map second (d/q query (d/history result-db)))]
+    (is (every? (partial = 1) result))))
+
+(defn peer-liveness [result-db n-peers]
+  (let [query '[:find ?peer :where
+                [?peer :peer/task]]
+        result (map first (d/q query (d/history result-db)))]
+    (is (= (count result) n-peers))))
+
+(defn peer-fairness [result-db n-peers n-jobs tasks-per-job]
+  (let [query '[:find ?peer (count ?task) :where
+                [?peer :peer/task ?task]]
+        result (map second (d/q query (d/history result-db)))
+        mean (/ (* n-jobs tasks-per-job) n-peers)
+        confidence 0.5]
+    (is (every?
+         #(and (<= (- mean (* mean confidence)) %)
+               (>= (+ mean (* mean confidence)) %))
+         result))))
+
+(defn concurrency-liveness [result-db n-jobs tasks-per-job]
+  (let [query '[:find ?task (count ?peer) :where
+                [?task :task/consumption :concurrent]
+                [?peer :peer/task ?task]]
+        result (map second (d/q query (d/history result-db)))]
+    (is (>= (count (filter (partial < 1) result))
+            (/ (* n-jobs tasks-per-job) 0.25)))))
+
+(deftest small-even-cluster
+  (let [n-jobs 15
+        n-peers 10
+        tasks-per-job 3
+        result-db (run-cluster n-jobs n-peers)]
+
+    (testing "No tasks are left incomplete"
+      (task-completeness result-db))
+
+    (testing "No sequential task ever had more than 1 peer"
+      (task-safety result-db))
+
+    (testing "No peers got 0 tasks"
+      (peer-liveness result-db n-peers))
+
+    (testing "All peers got a roughly even number of tasks assigned"
+      (peer-fairness result-db n-peers n-jobs tasks-per-job))))

 (run-tests 'onyx.coordinator.cluster-test)

-(alter-var-root #'system component/stop)
-


(PDB-2565) Change =-after? to is-equal-after

This wraps the entire macro in an `is` assertion. Since all cases where this was
used did this anyway, it provides more convenience. However, the main reason was
to ensure that the differential between the old and new values actually gets
printed during testing instead of simply returning the expectation of being true.

Signed-off-by: Ken Barber <470bc578162732ac7f9d387d34c4af4ca6e1b6f7@bob.sh>

--- test/puppetlabs/puppetdb/testutils.clj
+++ test/puppetlabs/puppetdb/testutils.clj
@@ -128,11 +128,11 @@
 (defn json-content-type? [response]
   (= http/json-response-content-type (get-in response [:headers "Content-Type"])))

-(defmacro =-after?
+(defmacro is-equal-after
   "Checks equality of `args` after
    the `func` has been applied to them"
   [func & args]
-  `(= ~@(map #(list func %) args)))
+  `(is (= ~@(map #(list func %) args))))

 (defn assert-success!
   "Given a Ring response, verify that the status


Update view for sub-heading degree description

--- src/kevin/views.clj
+++ src/kevin/views.clj
@@ -76,17 +76,17 @@
   [path]
   [:ul] (content (map result-node path)))

-(defn paths-count [paths bacon-number]
-  (let [total (str paths " path" (when-not (= 1 paths) "s"))
-        degrees (str bacon-number " degree" (when-not (= 1 bacon-number) "s"))]
-    (str total " with " degrees " of separation")))
+(defn degrees-description [bacon-number]
+  (let [degrees (str bacon-number " degree" (when-not (= 1 bacon-number) "s"))]
+    (str "(with " degrees " of separation)")))

 (defsnippet results "templates/results.html" [:#results]
   [{:keys [paths total start end bacon-number]}]
   [:.result_list :> [:ul (html/but first-of-type)]] nil
   [:.result_list :> [:ul first-of-type]] (clone-for [path paths]
                                                     (content (result path)))
-  [:.result_list :> :h3] (content (paths-count total bacon-number))
+  [:.result_list :> :h3] (content (str (count paths) " path" (when-not (= 1 (count paths)) "s")))
+  [:.result_list :> :h4] (content (degrees-description bacon-number))
   [:.bacon_number :mark] (content (str bacon-number))
   [:.bacon_number [:p first-of-type]] (content (format-name start))
   [:.bacon_number [:p last-of-type]] (content (format-name end)))


Oopsie: test didn't run right in full suite.

--- test/user/fus_check_after_creation.clj
+++ test/user/fus_check_after_creation.clj
@@ -11,10 +11,10 @@
   (future-fact (throw (new Error ":check-after-creation fail")))
 )

-(silent-check-facts #"^fact$")
+(silent-check-facts *ns* #"^fact$")
 (note-that fact-failed (fact-expected "fact"))

-(silent-check-facts #"^facts$")
+(silent-check-facts *ns* #"^facts$")
 (note-that fact-failed (fact-expected "facts"))

 ;; `with-state-changes` also obeys :check-after-creation
@@ -29,7 +29,7 @@

 (fact @state => 0)

-(silent-check-facts #"^state changes$")
+(silent-check-facts *ns* #"^state changes$")
 (note-that fact-failed (fact-expected "state changes"))

 ;;; Check-after-creation makes no sense with contents.


Remove UI metadata from placeholder sections on new companies (prior was just new sections of existing companies).

--- src/open_company/resources/company.clj
+++ src/open_company/resources/company.clj
@@ -96,10 +96,12 @@
   (reduce (fn [s sec]
             (assoc s
                    (:section-name sec)
-                   (-> sec
-                       (assoc :company-slug company-slug)
-                       (assoc :placeholder true)
-                       (dissoc :name))))
+                   (apply dissoc
+                      (-> sec
+                        (assoc :company-slug company-slug)
+                        (assoc :placeholder true)
+                        (dissoc :name))
+                      metadata-properties)))
           {}
           (filter :core common/sections)))


[CS] Remove unused fn

[CS] Remove unused fn

--- src/vip/data_processor/validation/db/duplicate_records.clj
+++ src/vip/data_processor/validation/db/duplicate_records.clj
@@ -5,9 +5,6 @@

 (defn columns-without-id [table]
   (remove (partial = "id") (sqlite/column-names table)))
-
-(defn dupe-column-name [column]
-  (str "dupes." column))

 (defn if-null
   "SQL does not believe that NULL = NULL, so in order to match NULL


Changed ClojureScript optimization level to :simple.

--- scripts/build.clj
+++ scripts/build.clj
@@ -8,7 +8,7 @@
    {:main 'cats.runner
     :output-to "out/tests.js"
     :output-dir "out"
-    :optimizations :advanced
+    :optimizations :simple
     :target :nodejs
     :verbose true})
   (println "... done. Elapsed" (/ (- (System/nanoTime) start) 1e9) "seconds"))


Avoid math with nil

Avoid math with nil

--- src/mdr2/abacus.clj
+++ src/mdr2/abacus.clj
@@ -219,7 +219,7 @@
   [{:keys [product_number total_time state audio_format multimedia_type
            date id produced_date volumes] :as production}]
   (->> [(create-row 2 product_number)
-        (create-row 239 (quot total_time (* 1000 60))) ; in minutes
+        (create-row 239 (quot (or total_time 0) (* 1000 60))) ; in minutes
         (create-row 106 state)
         (create-row 280 audio_format)
         (create-row 271 volumes) ; Number of CDs


Resolved merge conflict again.

Resolved merge conflict again.

--- umm-spec-lib/src/cmr/umm_spec/test/expected_conversion.clj
+++ umm-spec-lib/src/cmr/umm_spec/test/expected_conversion.clj
@@ -44,8 +44,11 @@
                                                   :EndingDateTime (t/date-time 2003)}])})]
      :ProcessingLevel (umm-c/map->ProcessingLevelType {})
      :RelatedUrls [(cmn/map->RelatedUrlType {:URLs ["http://google.com"]})]
-     :Organizations [(cmn/map->ResponsibilityType {:Role "CUSTODIAN"
-                                                   :Party (cmn/map->PartyType {})})]
+     :Organizations [(cmn/map->ResponsibilityType
+                       {:Role "CUSTODIAN"
+                        :Party (cmn/map->PartyType
+                                 {:OrganizationName (cmn/map->OrganizationNameType
+                                                      {:ShortName "custodian"})})})]
      :ScienceKeywords [(cmn/map->ScienceKeywordType {:Category "cat" :Topic "top" :Term "ter"})]
      :SpatialExtent (cmn/map->SpatialExtentType {:GranuleSpatialRepresentation "NO_SPATIAL"})
      :AccessConstraints (cmn/map->AccessConstraintsType


Fixes indentation.

Fixes indentation.

--- umm-spec-lib/src/cmr/umm_spec/test/expected_conversion.clj
+++ umm-spec-lib/src/cmr/umm_spec/test/expected_conversion.clj
@@ -4,7 +4,7 @@
   can be lossy if some fields are not supported by that format"
   (:require [cmr.common.util :refer [update-in-each]]
             [cmr.umm-spec.models.collection :as umm-c]
-                        [cmr.umm-spec.json-schema :as js]
+            [cmr.umm-spec.json-schema :as js]
             [cmr.umm-spec.models.common :as cmn]
             [clj-time.core :as t]
             [cmr.common.util :as util]


refactoring

refactoring

--- src/snap_spot/controllers/position.clj
+++ src/snap_spot/controllers/position.clj
@@ -7,12 +7,17 @@
     [snap-spot.redis :as redis]
     [taoensso.carmine :as car :refer (wcar)]
     [taoensso.timbre :as timbre]
+    [bouncer.core :as b]
+    [bouncer.validators :as v]
     [clojure.data.json :as json]
-    [me.shenfeng.mustache :as mustache]))
+    [me.shenfeng.mustache :as mustache]
+    [snap-spot.helper :as helper]
+    [snap-spot.models
+     (position :as position)
+     (trip :as trip)]))

 (timbre/refer-timbre)

-(defn get-position-key [params] (str (:id params) "-positions"))

 (defn send-position [channel position]
   "send postion to websocket channel"
@@ -20,7 +25,7 @@

 (defn send-past-positions [channel params]
   "send all past positions to websocket channel"
-  (def positions (redis/wcar* (car/lrange (get-position-key params) 0 -1)))
+  (def positions (position/fetch-positions params))
   (doseq [p (reverse positions)] (send-position channel p)))

 (defn subscribe-to-redis [channel trip-id]
@@ -41,13 +46,32 @@
     (subscribe-to-redis channel (:id params))
     (send-past-positions channel params)))

+(defn position-from-params [params]
+  (select-keys [:lat :lon :instant] params))
+
+(defn handle-new-position [trip position]
+  "push new position to subscribed channels and persist to redis"
+  (redis/wcar* (car/publish (:id trip) position))
+  (position/add trip position))
+
+(def update-validations
+  {:id [v/required v/number]
+   :secret [v/required v/number]
+   :lat [v/required v/number]
+   :lon [v/required v/number]
+   :instant [v/required v/number]})
+
 (defn update [req]
   "update position for trip"
-  (def params (:params req))
-  (redis/wcar*
-    (if (car/get (:id params))
-      (do
-        (car/publish (:id params) (map params [:lat :lon :instant]))
-        (car/lpush (get-position-key params) (select-keys params [:lat :lon :instant])))
-      "BORK!(trip not found)"))
-  "Position updated.")
+  (let [p (:params req)
+        trip (trip/fetch (:id p))
+        position (position-from-params p)
+        errors (helper/validate-all [[p update-validations]
+                                     [trip trip/validations]
+                                     [position position/validations]])]
+    (if errors
+      (helper/error-response errors)
+      (if (= (:secret p) (:secret trip ""))
+        (do (handle-new-position trip position)
+            "Position updated")
+        (helper/error-response "invalid secret")))))


Fix sidecar confusing dependencies

Fix sidecar confusing dependencies

lein deps :tree complained about a few confusing dependencies.
this sorts them out so that it's explicit what version of
everything this is using.

--- sidecar/project.clj
+++ sidecar/project.clj
@@ -10,13 +10,16 @@
   [[org.clojure/clojure "1.7.0"]
    [org.clojure/clojurescript "1.7.170"
     :exclusions [org.apache.ant/ant]]
-   [org.clojure/core.async "0.2.374"]
+   [org.clojure/core.async "0.2.374"
+    :exclusions [org.clojure/tools.reader]]
    [com.stuartsierra/component "0.3.0"]
    [http-kit "2.1.19"]
-   [ring-cors "0.1.7"]
+   [ring-cors "0.1.7"
+    :exclusions [ring/ring-core]]
    [compojure "1.4.0"]
    [clj-stacktrace "0.2.8"]
    [digest "1.4.4"]
-   [figwheel "0.5.0-2"]
+   [figwheel "0.5.0-2"
+    :exclusions [org.clojure/tools.reader]]
    [hawk "0.2.5"]])


Explicit wrapping of case-sensitive tests in `testing` macro

--- test/java_time_test.clj
+++ test/java_time_test.clj
@@ -865,26 +865,27 @@
              (j/local-time fmt "00:34am")
              (j/local-time fmt "00:34AM")))))

-  ;; Java version detection:
-  ;; java.lang.Runtime.Version class exists from Java 9 onwards, hence
-  ;; the need to detect the Java version from the java.version string returned
-  ;; by System/getProperty. In versions before 9, java.version has the format
-  ;; 1.x.y, e.g., 1.8.0_255, but from version 9 onwards, the initial 1 element
-  ;; is dropped.
-  ;; Refer to JEP 223 for information on the change.
-  ;; https://openjdk.java.net/jeps/223
-  (let [java-version (->> (System/getProperty "java.version")
-                          (re-find #"^\d+")
-                          Integer/parseInt)]
-    (if (> java-version 11)
-      (testing "Java 13 and above treats AM as invalid"
+  (testing "case-sensitive formatter"
+    ;; Java version detection:
+    ;; java.lang.Runtime.Version class exists from Java 9 onwards, hence
+    ;; the need to detect the Java version from the java.version string returned
+    ;; by System/getProperty. In versions before 9, java.version has the format
+    ;; 1.x.y, e.g., 1.8.0_255, but from version 9 onwards, the initial 1 element
+    ;; is dropped.
+    ;; Refer to JEP 223 for information on the change.
+    ;; https://openjdk.java.net/jeps/223
+    (let [java-version (->> (System/getProperty "java.version")
+                            (re-find #"^\d+")
+                            Integer/parseInt)]
+      (if (> java-version 11)
+        (testing "Java 13 and above treats AM as invalid"
           (let [fmt (java-time/formatter "hh:mma" {:case :sensitive})]
             (is (= (j/local-time 0 34 0 0)
                    (j/local-time fmt "12:34am")))
             (is (thrown? Exception (j/local-time fmt "12:34AM")))))

-      (testing "Java 8 and 11 treats am as invalid"
-        (let [fmt (java-time/formatter "hh:mma" {:case :sensitive})]
-          (is (= (j/local-time 0 34 0 0)
-                 (j/local-time fmt "12:34AM")))
-          (is (thrown? Exception (j/local-time fmt "12:34am"))))))))
+        (testing "Java 8 and 11 treats am as invalid"
+          (let [fmt (java-time/formatter "hh:mma" {:case :sensitive})]
+            (is (= (j/local-time 0 34 0 0)
+                   (j/local-time fmt "12:34AM")))
+            (is (thrown? Exception (j/local-time fmt "12:34am")))))))))


Revert db_test

Revert db_test

--- test/toucan/db_test.clj
+++ test/toucan/db_test.clj
@@ -6,8 +6,7 @@
                                 [venue :refer [Venue]]
                                 [category :refer [Category]])
             [toucan.test-setup :as test]
-            [toucan.util.test :as tu])
-  (:import (java.util UUID)))
+            [toucan.util.test :as tu]))

 ;; TODO - Test quoting-style

@@ -133,13 +132,6 @@
    (db/update! User 1 :last-name "Era")
    (db/select-one User :id 1)))

-(let [id (UUID/randomUUID)]
-  (expect
-    #toucan.test_models.user.UserInstance{:id id, :first-name "Cam", :last-name "Era"}
-    (test/with-clean-db
-      (db/update! User id :last-name "Era")
-      (db/select-one User :id id))))
-
 ;; Test update-where!
 (expect
  [#toucan.test_models.user.UserInstance{:id 1, :first-name "Cam", :last-name "Saul"}


Test for checking the boolean parser

Test for checking the boolean parser

--- test/zg/config_test.clj
+++ test/zg/config_test.clj
@@ -56,6 +56,17 @@
 ;
 ; Test for function behaviours
 ;
+
+(deftest test-parse-boolean
+    "Check the behaviour of function emender-jenkins.config/parse-boolean."
+    (are [x y] (= x y)
+        true (parse-boolean "true")
+        true (parse-boolean "True")
+        false (parse-boolean "false")
+        false (parse-boolean "False")
+        false (parse-boolean "")
+        false (parse-boolean "unknown")
+        false (parse-boolean nil)))

 (deftest test-parse-int-zero
     "Check the behaviour of function zg.config/parse-int."


Optional ch's for make-kvs-mgr.

Optional ch's for make-kvs-mgr.

--- src/cbfg/kvs.cljs
+++ src/cbfg/kvs.cljs
@@ -18,6 +18,7 @@
 ; TODO: Cannot use atoms because they prevent time travel.
 ; TODO: Add snapshot ability.
 ; TODO: Readers not blocked by writers.
+; TODO: Mutations shadow old values.

 (defn make-kc [] ; A kc is a keys / changes map.
   {:keys (sorted-map)      ; key -> sq
@@ -60,10 +61,8 @@

 (defn make-scan-fn [scan-kind result-key get-entry]
   (fn [actx state-ch m]
-     (let [from (:from m)
-           to (:to m)
+     (let [{:keys [from to res-ch]} m
            res-m (dissoc m :status :status-info :partial)
-           res-ch (:res-ch m)
            work-fn (fn [state kvs]
                      (act scan-work actx
                           (let [kc-clean (:clean kvs)]
@@ -164,9 +163,9 @@
                                                    (assoc :dirty (make-kc))))
                                      {:status :ok :status-info :synced}]))))})

-(defn make-kvs-mgr [actx & op-handlers-in]
-  (let [cmd-ch (achan actx)
-        state-ch (achan actx)]
+(defn make-kvs-mgr [actx & op-handlers-in & {:keys [cmd-ch state-ch]}]
+  (let [cmd-ch (or cmd-ch (achan actx))
+        state-ch (or state-ch (achan actx))]
     (act-loop kvs-mgr-in actx [tot-ops 0]
               (if-let [m (atake kvs-mgr-in cmd-ch)]
                 (if-let [op-handler (get (or op-handlers-in op-handlers) (:op m))]


Start the world off at id 0.

Start the world off at id 0.

--- src/cbfg/vis.cljs
+++ src/cbfg/vis.cljs
@@ -301,7 +301,7 @@
         gen-id #(swap! last-id inc)
         w [{:gen-id gen-id
             :event-ch event-ch}]
-        world (conj w "world-1")  ; No ago for world actx init to avoid recursion.
+        world (conj w "world-0")  ; No ago for world actx init to avoid recursion.
         vis (atom {:actxs {world {:children {} ; child-actx -> true,
                                   :wait-chs {} ; ch -> [:ghost|:take|:put optional-ch-name],
                                   ; :loop-state last-loop-bindings,


more robust handling of nils

more robust handling of nils

--- src/pc/admin/db.clj
+++ src/pc/admin/db.clj
@@ -11,14 +11,15 @@
                                  limit 100}}]
   (let [db (pcd/default-db)
         index-range (d/index-range db :db/txInstant (to-date start-time) (to-date end-time))
-        earliest-tx (.tx (first index-range))
-        latest-tx (.tx (last index-range))
-        doc-ids (map first (d/q '{:find [?d] :in [$ ?earliest-tx ?latest-tx]
-                                  :where [[?t :document/id ?d ?tx]
-                                          [?t :layer/name]
-                                          [(< ?earliest-tx ?tx)]
-                                          [(> ?latest-tx ?tx)]]}
-                                db (dec earliest-tx) (inc latest-tx)))]
+        earliest-tx (some-> index-range first .tx)
+        latest-tx (some-> index-range last .tx)
+        doc-ids (when (and earliest-tx latest-tx)
+                  (map first (d/q '{:find [?d] :in [$ ?earliest-tx ?latest-tx]
+                                    :where [[?t :document/id ?d ?tx]
+                                            [?t :layer/name]
+                                            [(<= ?earliest-tx ?tx)]
+                                            [(>= ?latest-tx ?tx)]]}
+                                  db earliest-tx latest-tx)))]
     (take limit (filter (fn [doc-id]
                           (< layer-threshold (or (ffirst (d/q '{:find [(count ?t)] :in [$ ?d]
                                                                 :where [[?t :document/id ?d]


Fix minor typo. Good night

Fix minor typo. Good night

--- frontend/src/crunsher/views.cljs
+++ frontend/src/crunsher/views.cljs
@@ -72,7 +72,7 @@
   Object
   (render [this]
     (dom/div nil
-             (dom/h1 nil "Poké-Crunsher"))))
+             (dom/h1 nil "Poké-Cruncher"))))
 (def header (om/factory Header))

 (defn commit-component-state


fixing test

fixing test

--- test/celestial/integration/proxmox.clj
+++ test/celestial/integration/proxmox.clj
@@ -22,7 +22,8 @@
     (.delete ct)))

 (deftest ^:proxmox full-cycle
-  (let [{:keys [machine]} spec ct (Container. (machine :hypervisor) machine)]
+  (let [{:keys [machine]} spec
+        ct (Container. (machine :hypervisor) (dissoc machine :features))]
     (.stop ct)
     (.delete ct)
     (.create ct)


removed graphing toy functions

removed graphing toy functions

--- test/forma/postprocess/select_test.clj
+++ test/forma/postprocess/select_test.clj
@@ -114,27 +114,6 @@
                          ["MYS" 831 0.9]
                          ["nil" 0 0]])))

-(defbufferop docat
-  [tuples]
-  [[(vec (flatten tuples))]])

-(defn graph-ts
-  [cntry ts]
-  (let [path (str "/Users/danhammer/Desktop/" cntry ".png")]
-    (if (> (count ts) 1)
-      (i/save (chart/line-chart
-               (range (count ts))
-               ts
-               :x-label "index"
-               :y-label "aggregate clearing"
-               :title (str "Clearing activity in " cntry))
-              path)
-      (println (str "no data for " cntry)))))

-(defn vectorize-output
-  []
-  (?<- (stdout)
-       [?cntry]
-       (agg-tap ?cntry ?pd ?tot-prob)
-       (docat ?tot-prob :> ?ts)
-       (graph-ts ?cntry ?ts)))
+


Fix binary name

Fix binary name

--- src/runbld/opts.clj
+++ src/runbld/opts.clj
@@ -121,7 +121,7 @@

     (when (not (= 1 (count arguments)))
       (throw+ {:help ::usage
-               :msg (format "runbld %s\nusage: rundmc /path/to/script.bash"
+               :msg (format "runbld %s\nusage: runbld /path/to/script.bash"
                             (version/string))}))

     (merge options


s/unify/unifyc/: might be a source of bugs

--- src/babel/over.cljc
+++ src/babel/over.cljc
@@ -157,7 +157,7 @@
               debug
               (let [p-sc (get-in parent [:head :synsem :subcat :1 :cat] :top)
                     c-sc (get-in child [:synsem :subcat :1 :cat] :top)]
-                (if (fail? (unify p-sc c-sc))
+                (if (fail? (unifyc p-sc c-sc))
                   (do
                     (log/debug (str "moreover-head: pass: parent sc:" (get-in parent [:head :synsem :subcat :1 :cat] :none)))
                     (log/debug (str "moreover-head: pass: head sc:  " (get-in child [:synsem :subcat :1 :cat] :none))))))


rename

rename

--- src/bardo/ease.cljx
+++ src/bardo/ease.cljx
@@ -1,8 +1,8 @@
 (ns bardo.ease
   (:require [clojure.string :as str]))

-(defn easer
-  "canonical definition of a higher order easing function"
+(defn interpolator
+  "canonical definition of a higher order interpolator function"
   [f]
   (fn [t]
     (f t)))
@@ -10,7 +10,7 @@
 (defn wrap
   "useful for wrapping easers in other easers, especially in theading macros"
   [f ease]
-  (easer (comp f ease)))
+  (interpolator (comp f ease)))

 (defn clamp
   "clamp input to function so that (<= 0 t 1)"


no moving through walls

no moving through walls

--- src/cas/client.cljs
+++ src/cas/client.cljs
@@ -112,7 +112,8 @@
     (cond (:passable (world-at world (x-op (:x pos)) (y-op (:y pos))))
           (update-in (update-in robot [:pos :y] y-op) [:pos :x] x-op)
           (and (or (= dir :left) (= dir :right))
-               (:passable (world-at world (x-op (:x pos)) (dec (:y pos)))))
+               (:passable (world-at world (x-op (:x pos)) (dec (:y pos))))
+               (:passable (world-at world (:x pos) (dec (:y pos)))))
           (update-in (update-in robot [:pos :y] dec) [:pos :x] x-op)
           :else robot)))


fix indentation in core.clj

fix indentation in core.clj

--- src/clj/pw/core.clj
+++ src/clj/pw/core.clj
@@ -36,21 +36,21 @@
    (resources "/")
    (GET "/" [] (index))
    (POST "/pass/*" [* password]
-          (let [{:keys [out err]} (sh "gpg"
-                        "--batch"
-                        "-d"
-                        "--passphrase-fd" "0"
-                        (format "%s/%s.gpg" path *)
-                        :in password)]
-            (cond
-             (re-find #"No such file or directory" err)
-             (edn-response {:error "Bad service or password"})
+         (let [{:keys [out err]} (sh "gpg"
+                                     "--batch"
+                                     "-d"
+                                     "--passphrase-fd" "0"
+                                     (format "%s/%s.gpg" path *)
+                                     :in password)]
+           (cond
+            (re-find #"No such file or directory" err)
+            (edn-response {:error "Bad service or password"})

-             (= "" out)
-             (edn-response {:error "Bad service or password"})
+            (= "" out)
+            (edn-response {:error "Bad service or password"})

-             :else
-             (edn-response {:pass (clojure.string/trim-newline out)}))))
+            :else
+            (edn-response {:pass (clojure.string/trim-newline out)}))))

    (not-found "404")))


Drop dud print.

Drop dud print.

--- src/clojars/scp.clj
+++ src/clojars/scp.clj
@@ -83,7 +83,6 @@
 (defmethod read-metadata "xml" [f]
   (let [model (maven/read-pom (:file f))
         jarmap (maven/model-to-map model)]
-    (printerr "reading" f)
     [[model jarmap]]))

 ;; TODO: probably want to show an error if the file contains no defjars
@@ -136,3 +135,4 @@
 (defn -nailMain [context]
   (nail context))

+;(sorted-set-by compare 1 "a")


Some type tags

Some type tags

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

--- src/conexp/base.clj
+++ src/conexp/base.clj
@@ -202,9 +202,9 @@

 (defn ensure-length
   "Fills given string with padding to have at least the given length."
-  ([string length]
+  ([string ^long length]
      (ensure-length string length " "))
-  ([string length padding]
+  ([string ^long length padding]
      (apply str string (repeat (- length (count string)) padding))))

 (defn with-str-out
@@ -257,7 +257,7 @@
     (fn [a b]
       (and (contains? pos a)
            (contains? pos b)
-           (>= (pos a) (pos b))))))
+           (>= ^long (pos a) ^long (pos b))))))
 (defn zip
   "Returns sequence of pairs [x,y] where x runs through seq-1 and
   y runs through seq-2 simultaneously. This is the same as
@@ -700,7 +700,7 @@
   (exists [set cover]
     (forall [x set]
       (=> (contains? base-set x)
-          (<= 2 (get count x))))))
+          (<= 2 ^long (get count x))))))

 (defn minimum-set-covers
   "For a given set base-set and a collection of sets returns all subcollections of sets such that


Make worker execute jobs on separate threads

--- src/worker/core.clj
+++ src/worker/core.clj
@@ -66,7 +66,7 @@
   [ch {:keys [delivery-tag]} payload]
   (let [data (to-json payload)]
     (print-job-info data)
-    (handle-job data ch delivery-tag)))
+    (future (handle-job data ch delivery-tag))))

 (defn -main
   [& args]