Munge layer.

Munge layer.

--- src/onyx/peer/task_pipeline.clj
+++ src/onyx/peer/task_pipeline.clj
@@ -25,47 +25,65 @@
   (doseq [msg msgs]
     (extensions/produce-message queue producer msg)))

+(defn munge-open-session [session]
+  {:session session})
+
+(defn munge-read-batch [{:keys [session] :as event} queue queue-name batch-size]
+  (let [consumer (extensions/create-consumer queue session queue-name)
+        batch (read-batch queue consumer batch-size)]
+    (assoc event :batch batch :consumer consumer)))
+
+(defn munge-decompress-tx [{:keys [batch] :as event}]
+  (let [decompressed-msgs (map decompress-message batch)]
+    (assoc event :decompressed decompressed-msgs)))
+
+(defn munge-apply-fn [{:keys [decompressed] :as event} task]
+  (let [results (map (partial apply-fn task) decompressed)]
+    (assoc event :results results)))
+
+(defn munge-compress-tx [{:keys [results] :as event}]
+  (let [compressed-msgs (map compress-msg results)]
+    (assoc event :compressed compressed-msgs)))
+
+(defn munge-write-batch [{:keys [session compressed] :as event} queue queue-name]
+  (let [producer (extensions/create-producer queue session queue-name)
+        batch (write-batch queue session producer compressed)]
+    (assoc event :producer producer)))
+
 (defn open-session-loop [queue read-ch]
   (loop []
     (when-let [session (create-tx-session queue)]
-      (>!! read-ch {:session session})
+      (>!! read-ch (munge-open-session session))
       (recur))))

 (defn read-batch-loop [queue queue-name read-ch decompress-ch batch-size]
   (loop []
-    (when-let [{:keys [session] :as event} (<!! read-ch)]
-      (let [consumer (extensions/create-consumer queue session queue-name)
-            batch (read-batch queue consumer batch-size)]
-        (>!! decompress-ch (assoc event :batch batch :consumer consumer)))
+    (when-let [event (<!! read-ch)]
+      (>!! decompress-ch (munge-read-batch event queue queue-name batch-size))
       (recur))))

 (defn decompress-tx-loop [decompress-ch apply-fn-ch]
   (loop []
-    (when-let [{:keys [batch] :as event} (<!! decompress-ch)]
-      (let [decompressed-msgs (map decompress-message batch)]
-        (>!! apply-fn-ch (assoc event :decompressed decompressed-msgs)))
+    (when-let [event (<!! decompress-ch)]
+      (>!! apply-fn-ch (munge-decompress-tx event))
       (recur))))

 (defn apply-fn-loop [apply-fn-ch compress-ch task]
   (loop []
-    (when-let [{:keys [decompressed] :as event} (<!! apply-fn-ch)]
-      (let [results (map (partial apply-fn task) decompressed)]
-        (>!! compress-ch (assoc event :results results)))
+    (when-let [event (<!! apply-fn-ch)]
+      (>!! compress-ch (munge-apply-fn event task))
       (recur))))

 (defn compress-tx-loop [compress-ch write-batch-ch]
   (loop []
-    (when-let [{:keys [results] :as event} (<!! compress-ch)]
-      (let [compressed-msgs (map compress-msg results)]
-        (>!! compress-ch (assoc event :compressed compressed-msgs)))
+    (when-let [event (<!! compress-ch)]
+      (>!! write-batch-ch (munge-compress-tx event))
       (recur))))

 (defn write-batch-loop [queue queue-name write-ch status-check-ch]
   (loop []
-    (when-let [{:keys [session compressed] :as event} (<!! write-ch)]
-      (let [producer (extensions/create-producer queue session queue-name)
-            batch (write-batch queue session producer compressed)]
-        (>!! status-check-ch (assoc event :producer producer)))
+    (when-let [event (<!! write-ch)]
+      (>!! status-check-ch (munge-write-batch event queue queue-name))
       (recur))))

 (defn status-check-loop [status-ch commit-tx-ch]


housekeeping

housekeeping

--- src/chessground/chess.cljs
+++ src/chessground/chess.cljs
@@ -6,7 +6,7 @@

 (comment
   ; Representation of a chess game:
-  {"a1" {}
+  {"a1" nil
    "a2" {:color "white" ; piece color
          :role "king" ; piece role
          }})
@@ -24,10 +24,6 @@
   (merge
     clear
     (forsyth/parse (if (= fen "start") forsyth/default fen))))
-
-(defn transform
-  "f takes a key and a square, and returns a square"
-  [chess f] (into {} (for [[k v] chess] [k (f k v)])))

 (defn get-piece [chess key] (get chess key))


Commenting the NodeMatcher protocol in favor of TreeLocMatch protocol

--- src/clj/dalap/selector.clj
+++ src/clj/dalap/selector.clj
@@ -24,30 +24,28 @@

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-(defprotocol NodeMatcher
-  "This protocol provides a function that returns another
-  function that accepts a node from the dalap Tree and tests
-  it matches."
-  (to-node-matcher [selectable]))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(extend-protocol NodeMatcher
-  ;; Something that behaves like function will always match
-  ;; and return itself.
-  ^{:cljs 'function }
-  clojure.lang.IFn
-  (to-node-matcher [sfn]
-    ^:clj (println "fakjsdfjdskalfjasldkf")
-    sfn)
-
-  ;; Anything else, it will check the dalap node type is
-  ;; equal to the object.
-  ^{:cljs 'default}
-  Object
-  (to-node-matcher [type_]
-    (fn type-matcher [node]
-      (= (type node) type_))))
+;; (defprotocol NodeMatcher
+;;   "This protocol provides a function that returns another
+;;   function that accepts a node from the dalap Tree and tests
+;;   it matches."
+;;   (to-node-matcher [selectable]))
+
+;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;; (extend-protocol NodeMatcher
+;;   ;; Something that behaves like function will always match
+;;   ;; and return itself.
+;;   ^{:cljs 'function }
+;;   clojure.lang.IFn
+;;   (to-node-matcher [sfn] sfn)
+
+;;   ;; Anything else, it will check the dalap node type is
+;;   ;; equal to the object.
+;;   ^{:cljs 'default}
+;;   Object
+;;   (to-node-matcher [type_]
+;;     (fn type-matcher [node]
+;;       (= (type node) type_))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Fixing compile errors in canon.

Fixing compile errors in canon.

--- src/clj/minijava/canon.clj
+++ src/clj/minijava/canon.clj
@@ -1,32 +1,37 @@
 (ns minijava.cannon
   (:use (minijava ir)))

+(defn commute? [x y]
+	true ;;standin
+)
+
 (defmulti cannon (fn [x] (type x)))

+ (defmulti cannonExp (fn [x] (type x)))
 (defn isit? [x t]
 (= (type x) t)
 )

-(defn nopNull (list (Exp (Const 0))))
+(def nopNull (cons (Exp (Const 0)) '()))

 (defn reorder [exps]
 	(cond
 			(empty? exps)
 						(nopNull)
 			 (true)
-			 		   (let ((a (first exps)))
+			 		   (let [ a (first exps)]
 			 		   (cond (isit? a :minijava.ir/Call)
-			 		   			 (let ((t (minijava.ir.temp.Temp))
-			 		   			 				(e (ExpSeq (Move (Temp t) a) (Temp t))))
+			 		   			 (let [t (minijava.ir.temp.Temp )
+			 		   			 				e (ExpSeq (Move (Temp t) a) (Temp t))]
 			 		   			 		(reorder (cons e (rest exps)))
 			 		   			 )
 			 		   			 (true)
-			 		   			 (let ((aa (cannonExp a))
-			 		   			 				(bb (reorder (rest exps))))
+			 		   			 (let [aa ( cannonExp a)
+			 		   			 				bb (reorder (rest exps))]
 			 		   			       (cond (commute? (:stm bb) (:exp aa))
 			 		   			       							(list (make-seq (:stm aa) (:stm bb)) (cons (:exp aa) (:exps bb)))
 			 		   			       				(true)
-			 		   			       			  (let ((t (minijava.ir.temp.Temp)))
+			 		   			       			  (let [ t (minijava.ir.temp.Temp)]
 			 		   			       			  (list (make-seq (:stm aa) (make-seq (Move (Temp t) (:exp aa)) (:stm bb)) (cons (Temp t) (:exps bb)) ))
 			 		   			       )
 			 		   			 ))
@@ -52,13 +57,13 @@

 (defn reorderExp [x]
-	(let ((r (reorder (kids e))))
+	(let [ r (reorder (kids e)) ]
 	(ExpSeq (:stm x) (build e (:exps x)))
 	)
 )

 (defn reorderStm [x]
-	(let ((r (reorder (kids e))))
+	(let [ r (reorder (kids e) ])
 	(ExpSeq (:stm x) (build e (:exps x)))
 	)
 )
@@ -126,18 +131,17 @@
  )

- (defmulti cannonExp (fn [x] (type x)))

  (defmethod cannonExp :minijava.ir/ExpSeq
   [x]
- 	(let ( (stms  cannon (:seqs x))
- 				(b (cannon (:exp x))))
+ 	(let [ stms  cannon (:seqs x)
+ 				b (cannon (:exp x)])
  			(ExpSeq (make-seq stms (:stm b)) (:exp b)))
  	)

  (defmethod cannonExp :default
    [x]
- 	 (let ((lst  (reorderExp (kids x))))
+ 	 (let [ lst  (reorderExp (kids x)])
  			(ExpSeq (:stm lst) (build x (:exps lst)))
  			)
  )


Added Gridlex CSS dp

Added Gridlex CSS dp

--- src/clj/myproject/html.clj
+++ src/clj/myproject/html.clj
@@ -11,7 +11,9 @@
      ;; Normalize
      [:link {:rel "stylesheet" :href "https://necolas.github.io/normalize.css/7.0.0/normalize.css"}]
      ;; Awesome Font
-     [:link {:rel "stylesheet" :href "https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"}]]
+     [:link {:rel "stylesheet" :href "https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"}]
+     ;; Gridlex
+     [:link {:rel "stylesheet" :href "https://cdnjs.cloudflare.com/ajax/libs/gridlex/2.4.0/gridlex.min.css"}]]
     [:body
      [:div#app]
      [:script {:src "js/compiled/myproject.js" :type "text/javascript"}]]]))


Attempt to avoid adding empty strings for the times

If commit is nil, this would have returned a map with author and
commit times set to an empty string.  Later ES would throw an error.

I'm still unsure why commit would be nil.

--- src/clj/runbld/vcs/git.clj
+++ src/clj/runbld/vcs/git.clj
@@ -55,25 +55,27 @@
 (defn commit-map [commit]
   (let [message (let [b (-> commit :message :body)]
                   (str (-> commit :message :title)
-                       (when (and b (not-empty b)) (str "\n\n" b))))]
-    {:commit-id (:commit commit)
-     :commit-short (:commit-short commit)
-     :message (-> commit :message :title)
-     :message-full message
-     :commit-time (-> commit :committer :time str)
-     :commit-name (-> commit :committer :name)
-     :commit-email (-> commit :committer :email)
-     :author-time (-> commit :author :time str)
-     :author-name (-> commit :author :name)
-     :author-email (-> commit :author :email)
-     :provider provider
-     :log-pretty (format
-                  "commit %s\nAuthor: %s <%s>\nDate:   %s\n\n%s"
-                  (:commit commit)
-                  (or (-> commit :author :name) "")
-                  (or (-> commit :author :email) "")
-                  (-> commit :committer :time str)
-                  message)}))
+                       (when (and b (not-empty b)) (str "\n\n" b))))
+        commit-time (-> commit :committer :time)
+        author-time (-> commit :author :time)]
+    (cond-> {:commit-id (:commit commit)
+             :commit-short (:commit-short commit)
+             :message (-> commit :message :title)
+             :message-full message
+             :commit-name (-> commit :committer :name)
+             :commit-email (-> commit :committer :email)
+             :author-name (-> commit :author :name)
+             :author-email (-> commit :author :email)
+             :provider provider
+             :log-pretty (format
+                          "commit %s\nAuthor: %s <%s>\nDate:   %s\n\n%s"
+                          (:commit commit)
+                          (or (-> commit :author :name) "")
+                          (or (-> commit :author :email) "")
+                          commit-time
+                          message)}
+      commit-time (assoc :commit-time (str commit-time))
+      author-time (assoc :author-time (str author-time)))))

 (defn resolve-remote [^String loc]
   (condp #(.startsWith %2 %1) loc


Going more functionally themed

Going more functionally themed

--- src/cljc/state/slides.cljc
+++ src/cljc/state/slides.cljc
@@ -1,18 +1,8 @@
 (ns state.slides
  (:require [reveal.clj.core :as reveal]
-           [state.state :as st]
-           [state.concurrency :as sc]
-           [state.practice :as sp]))
-
-
-
-(def overview
- [:section
-  [:h2 "Overview"]
-  [:ul
-   [:li "What is stateless code?"]
-   [:li "How do I get there?"]
-   [:li "Considerations"]]])
+           [state.state :as state]
+           [state.concurrency :as concurrency]
+           [state.practice :as practice]))

 ;;FP in the small is easy
 ;; - persistent collections
@@ -99,7 +89,8 @@

 (def intro
  [:section
-  [:h3 "Functional Programming: Writing Stateless Code in a Stateful World with Clojure"]
+  [:h2 "Functional Programming"]
+  [:h3 "Writing Stateless Code in a Stateful World with Clojure"]
   [:p "Mark Bastian"]
   [:p
    [:a
@@ -107,6 +98,15 @@
     "markbastian@gmail.com"]]
   [:p [:a {:href "https://twitter.com/mark_bastian" } "@mark_bastian"]]
   [:p "3/24/2015"]])
+
+(def overview
+ [:section
+  [:h2 "Overview"]
+  [:ul
+   [:li "Functional Programming"]
+   [:li "State and Statelessness"]
+   [:li "Getting There"]
+   [:li "Examples"]]])

 ;Overview -
 ;The Problem - The transition to FP is very difficult in part due to understanding programming with no state.
@@ -124,9 +124,9 @@
  [intro
   overview
   ;(into [:section foo])                                    ;why? - Why FP? Maybe grab some from the FP talk.
-  (into [:section] st/slides)                               ;what
-  (into [:section] sp/slides)                               ;how
-  (into [:section] sc/slides)                               ;examples?
+  (into [:section] state/slides)                               ;what
+  (into [:section] practice/slides)                               ;how
+  (into [:section] concurrency/slides)                               ;examples?
   the-challenge                                             ;move
   clojure-vs                                                ;move
   conclusion])


Add :base-type to terrains in second map

--- src/cljs/zetawar/data.cljs
+++ src/cljs/zetawar/data.cljs
@@ -985,32 +985,32 @@
     :max-count-per-unit 10
     :credits-per-base 50
     :bases
-    [{:q 4  :r 2}
-     {:q 12 :r 2}
-     {:q 3  :r 3}
-     {:q 5  :r 3}
-     {:q 10 :r 3}
-     {:q 2  :r 4}
-     {:q 4  :r 4}
-     {:q 12 :r 4}
-     {:q 7  :r 5}
-     {:q 11 :r 5}
-     {:q 13 :r 5}
-     {:q 5  :r 7}
-     {:q 7  :r 7}
-     {:q 9  :r 7}
-     {:q 7  :r 8}
-     {:q 12 :r 9}
-     {:q 2  :r 10}
-     {:q 7  :r 10}
-     {:q 11 :r 10}
-     {:q 2  :r 11}
-     {:q 3  :r 11}
-     {:q 4  :r 11}
-     {:q 9  :r 11}
-     {:q 11 :r 11}
-     {:q 3  :r 13}
-     {:q 10 :r 13}]
+    [{:q 4  :r 2 :base-type :base}
+     {:q 12 :r 2 :base-type :base}
+     {:q 3  :r 3 :base-type :base}
+     {:q 5  :r 3 :base-type :base}
+     {:q 10 :r 3 :base-type :base}
+     {:q 2  :r 4 :base-type :base}
+     {:q 4  :r 4 :base-type :base}
+     {:q 12 :r 4 :base-type :base}
+     {:q 7  :r 5 :base-type :base}
+     {:q 11 :r 5 :base-type :base}
+     {:q 13 :r 5 :base-type :base}
+     {:q 5  :r 7 :base-type :base}
+     {:q 7  :r 7 :base-type :base}
+     {:q 9  :r 7 :base-type :base}
+     {:q 7  :r 8 :base-type :base}
+     {:q 12 :r 9 :base-type :base}
+     {:q 2  :r 10 :base-type :base}
+     {:q 7  :r 10 :base-type :base}
+     {:q 11 :r 10 :base-type :base}
+     {:q 2  :r 11 :base-type :base}
+     {:q 3  :r 11 :base-type :base}
+     {:q 4  :r 11 :base-type :base}
+     {:q 9  :r 11 :base-type :base}
+     {:q 11 :r 11 :base-type :base}
+     {:q 3  :r 13 :base-type :base}
+     {:q 10 :r 13 :base-type :base}]
     ;; TODO: determine best faction order
     :factions
     [{:color :red


update parser to check for :doc and :dynamic in defn meta

--- src/cljs_api_gen/parse.clj
+++ src/cljs_api_gen/parse.clj
@@ -131,11 +131,12 @@
         meta- (meta name-)
         args (drop 2 form)
         docstring (let [ds (first args)]
-                    (when (string? ds)
-                      ds))
+                     (when (string? ds)
+                       ds))
         args (if docstring (rest args) args)
         attr-map (let [m (first args)]
                    (when (map? m) m))
+        docstring (or docstring (:doc meta-) (:doc attr-map))
         args (if attr-map (rest args) args)
         macro? (:macro attr-map)
         private? (or (#{'core/defn- 'defn-} (first form))
@@ -143,6 +144,7 @@
                      (:private attr-map)
                      (:skip-wiki meta-)
                      (:skip-wiki attr-map))
+        dynamic? (:dynamic meta-)
         doc-forms (cond-> []
                     docstring (conj docstring)
                     attr-map (conj attr-map))
@@ -164,6 +166,7 @@
        :docstring (fix-docstring docstring)
        :signature (or arglists signatures)
        :type (cond
+               dynamic? "dynamic var" ;; e.g. *exec-tap-fn*
                constructor? "type"
                macro? "macro"
                :else type-)})))


add alt text to shields

add alt text to shields

--- src/cljs_api_gen/write.clj
+++ src/cljs_api_gen/write.clj
@@ -56,8 +56,8 @@
         change ({"+" "+", "-" "×"} change)]
     (str
       ""
-      ""
+      ""
       "")))

 (defn sig-args


Remove om, use om.next

Remove om, use om.next

--- src/discuss/references/main.cljs
+++ src/discuss/references/main.cljs
@@ -2,9 +2,7 @@
   "Handle interaction with already existing references, for example showing
   usages in other statements / arguments or providing a form to use it in the
   own statement."
-  (:require [om.core :as om]
-            [om.dom :as dom]
-            [om.next :as nom :refer-macros [defui]]
+  (:require [om.next :as om :refer-macros [defui]]
             [clojure.spec.alpha :as s]
             [goog.string :refer [format]]
             [goog.string.format]
@@ -63,12 +61,12 @@

 (defui ReferenceUsageForSingleArgumentView
   "Build single usage of a reference in an argument."
-  static nom/IQuery
+  static om/IQuery
   (query [this]
          `[:argument])
   Object
   (render [this]
-          (let [{:keys [argument]} (nom/props this)
+          (let [{:keys [argument]} (om/props this)
                 {:keys [author issue]} argument]
             (html [:div.bs-callout.bs-callout-info
                    [:div.pull-right
@@ -80,15 +78,15 @@
                     [:strong (vlib/safe-html (:text argument))]]
                    [:div (t :common :author) ": " (:nickname author)]
                    [:div (t :common :issue) ": " (:title issue)]]))))
-(def reference-usage-for-single-argument (nom/factory ReferenceUsageForSingleArgumentView {:keyfn identity}))
+(def reference-usage-for-single-argument (om/factory ReferenceUsageForSingleArgumentView {:keyfn identity}))

 (defui ReferenceUsagesForArgumentsView
-  static nom/IQuery
+  static om/IQuery
   (query [this]
          `[:arguments])
   Object
   (render [this]
-          (let [{:keys [issue arguments author]} (nom/props this)]
+          (let [{:keys [issue arguments author]} (om/props this)]
             (html [:div
                    (map
                     #(reference-usage-for-single-argument
@@ -96,18 +94,16 @@
                        :issue issue
                        :argument %})
                     arguments)]))))
-(def reference-usages-for-arguments (nom/factory ReferenceUsagesForArgumentsView {:keyfn identity}))
-
-(lib/store-to-app-state! 'references/selected {:text "foo"})
+(def reference-usages-for-arguments (om/factory ReferenceUsagesForArgumentsView {:keyfn identity}))

 (defui UsagesView
   "Complete list of all references and all their usages in their arguments."
-  static nom/IQuery
+  static om/IQuery
   (query [this]
          `[:references/usages :references/selected])
   Object
   (render [this]
-          (let [{:keys [references/usages references/selected]} (nom/props this)]
+          (let [{:keys [references/usages references/selected]} (om/props this)]
             (html [:div
                    (if-not (empty? selected)
                      [:div
@@ -127,16 +123,16 @@
                      [:div.text-center
                       (vlib/view-header (t :references :usages/not-found-lead))
                       [:p (t :references :usages/not-found-body) "."]])]))))
-(def usages-view-next (nom/factory UsagesView))
+(def usages-view-next (om/factory UsagesView))

 (defui ReferenceView
   "Nested reference link in text."
   Object
   (render [this]
-          (let [{:keys [text url id dom-pre dom-post]} (nom/props this)]
+          (let [{:keys [text url id dom-pre dom-post]} (om/props this)]
             (html [:span
                    [:span dom-pre]
                    [:span.arguments.pointer {:onClick #(click-reference (Reference. id text url))}
                     text " " (vlib/logo)]
                    [:span dom-post]]))))
-(def reference (nom/factory ReferenceView))
+(def reference (om/factory ReferenceView))


Cleanup.

Cleanup.

--- examples/src/test/clojure/stone/example/incanter.clj
+++ examples/src/test/clojure/stone/example/incanter.clj
@@ -31,6 +31,4 @@
 ;;(view (with-data st-dataset
 ;;  (time-series-plot timestamp (value-nth 1))))

-;;(st-in/histogram storage 1)
-
 (st/close wts)


Use HTTP codes everywhere

Use HTTP codes everywhere

--- src/emender_jenkins/rest_api.clj
+++ src/emender_jenkins/rest_api.clj
@@ -173,7 +173,7 @@
                 (reload-job-list request)
                 (send-response request))
             (-> (job-does-not-exist-response job-name "enable")
-                (send-error-response request)))))
+                (send-error-response request :not-found)))))

 (defn disable-job
     [request]
@@ -186,7 +186,7 @@
                 (reload-job-list request)
                 (send-response request))
             (-> (job-does-not-exist-response job-name "enable")
-                (send-error-response request)))))
+                (send-error-response request :not-found)))))

 (defn delete-job
     [request]
@@ -199,7 +199,7 @@
                 (reload-job-list request)
                 (send-response request))
             (-> (job-does-not-exist-response job-name "delete")
-                (send-error-response request)))))
+                (send-error-response request :not-found)))))

 (defn job-invalid-input
     [job-name git-repo branch]
@@ -220,7 +220,7 @@
               metadata   (get input-data :metadata)]
             (if (results/job-exists? job-name)
                 (-> (job-already-exist-response job-name create-job-command)
-                    (send-error-response request))
+                    (send-error-response request :bad-request))
                 (if (and job-name git-repo branch)
                     (-> (jenkins-api/create-job (config/get-jenkins-url request)
                                                 (config/get-jenkins-auth request)
@@ -230,10 +230,10 @@
                         (send-response request))
                     (-> (create-error-response (or job-name "not set!") create-job-command
                                                (job-invalid-input job-name git-repo branch))
-                        (send-error-response request)))))
+                        (send-error-response request :bad-request)))))
         (catch Exception e
                 (-> (create-error-response "not set!" create-job-command "invalid input")
-                    (send-error-response request)))))
+                    (send-error-response request :bad-request)))))

 (defn uri->job-name
     [uri prefix]
@@ -255,9 +255,9 @@
                  (if job-metadata
                      (send-response job-metadata request))
                      (-> (job-does-not-exist-response job-name "get-job")
-                         (send-error-response request)))
+                         (send-error-response request :not-found)))
             (-> (job-does-not-exist-response job-name "get-job")
-                (send-error-response request)))))
+                (send-error-response request :bad-request)))))

 (defn update-job
     [request]
@@ -278,12 +278,12 @@
                         (send-response request))
                     (-> (create-error-response (or job-name "not set!") update-job-command
                                                (job-invalid-input job-name git-repo branch))
-                        (send-error-response request)))
+                        (send-error-response request :bad-request)))
                 (-> (job-does-not-exist-response job-name update-job-command)
-                    (send-error-response request))))
+                    (send-error-response request :not-found))))
         (catch Exception e
                 (-> (create-error-response "not set!" update-job-command "invalid input")
-                    (send-error-response request)))))
+                    (send-error-response request :bad-request)))))

 (defn get-jobs
     [request]
@@ -303,7 +303,7 @@
                      (-> (create-error-response job-name "get_job_results" "can not read test results")
                          (send-response request))))
             (-> (job-does-not-exist-response job-name "get_job_results")
-                (send-error-response request)))))
+                (send-error-response request :not-found)))))

 (defn job-started-handler
     [request]
@@ -326,5 +326,5 @@
                     :error "Unknown API call"
                     :uri uri
                     :method method}]
-        (send-response response request)))
-
+        (send-error-response response request)))
+


Make polkadots brighter

Make polkadots brighter

--- spectacles/src/spectacles/polkadots.clj
+++ spectacles/src/spectacles/polkadots.clj
@@ -60,11 +60,11 @@
   (q/background 0)
   (q/no-stroke)

-  (q/fill 255 0 0 128)
+  (q/fill 255 0 0 255)
   (doseq [dot (:vdots state)]
     (q/ellipse (:x dot) (:y dot) (:diameter dot) (:diameter dot)))

-  (q/fill 255 255 0 128)
+  (q/fill 255 255 0 255)
   (doseq [dot (:hdots state)]
     (q/ellipse (:x dot) (:y dot) (:diameter dot) (:diameter dot))))


Update installation assignments for seasonal display

--- spectacles/src/spectacles/scheduler.clj
+++ spectacles/src/spectacles/scheduler.clj
@@ -102,10 +102,10 @@
                                :author "Aaron Arnett"}})

 (def installations {:lifeinlights01 :logo-countdown       ;; Leeds north door
-                    :lifeinlights02 :mirror-camera        ;; Commercial Kitchen (window)
+                    :lifeinlights02 :social-light         ;; Commercial Kitchen (window)
                     :lifeinlights03 :bet-you-miss         ;; Easy Pickins
                     :lifeinlights04 :cyberspeed           ;; Bridges and Lane
-                    :lifeinlights05 :kaleidoscope            ;; Kerr (C)
+                    :lifeinlights05 :social-light         ;; Kerr (C)
                     :lifeinlights06 :fireflies            ;; Leeds lobby (or entrance?)
                     :lifeinlights07 :kaleidoscope-lamp    ;; Commercial Kitchen (facade) (800x600)
                     :lifeinlights08 :polkadots            ;; Kerr (A)


Use updated name for v2 build steps

Use updated name for v2 build steps

--- src-cljs/frontend/components/build.cljs
+++ src-cljs/frontend/components/build.cljs
@@ -502,7 +502,7 @@
                                  :enter true
                                  :leave true
                                  :class "build-steps-animator"}
-                                [(om/build build-steps/container-build-steps-v2
+                                [(om/build build-steps/container-build-steps
                                            container-data
                                            {:key :current-container-id})])]])])))))


comments from cr to inline fn and rename variable

--- src-cljs/frontend/components/build.cljs
+++ src-cljs/frontend/components/build.cljs
@@ -27,7 +27,7 @@
             [om.core :as om :include-macros true])
   (:require-macros [frontend.utils :refer [html defrender]]))

-(defn report-error [{:keys [messages failed infrastructure_fail fail_reason]} owner]
+(defn report-infrastructure-error [{:keys [messages failed infrastructure_fail fail_reason]} owner]
   (when (and (empty? messages)
              failed
              infrastructure_fail)
@@ -114,8 +114,7 @@
           (common/messages (set (:messages build)))
           [:div.row
            [:div.col-xs-12
-            (when-let [error-div (report-error build
-                                               owner)]
+            (when-let [error-div (report-infrastructure-error build owner)]
               error-div)

             (when (project-common/show-trial-notice? project plan (:dismissed-trial-update-banner browser-settings))


Remove logging that breaks IE 8.

Remove logging that breaks IE 8.

--- src-cljs/kixi/hecuba/tabs/profiles.cljs
+++ src-cljs/kixi/hecuba/tabs/profiles.cljs
@@ -4,8 +4,6 @@
             [cljs-time.coerce :as tc]
             [cljs-time.format :as tf]
             [kixi.hecuba.bootstrap :as bs]))
-
-(enable-console-print!)

 (defn get-profiles [selected-property-id data]
   (->>  data
@@ -89,7 +87,6 @@
   (reify
     om/IRenderState
     (render-state [_ state]
-      (println "Profiles: " profiles)
       (html
        [:div.col-md-12
         (for [profile profiles]


[#2212] Delay allowed-paths

[#2212] Delay allowed-paths

--- backend/src/akvo/lumen/auth.clj
+++ backend/src/akvo/lumen/auth.clj
@@ -129,22 +129,22 @@
       (if (api-authz? jwt-claims)
         (try
           (let [email (get jwt-claims "email")
-                allowed-paths (keycloak/allowed-paths keycloak email)]
+                allowed-paths (delay (keycloak/allowed-paths keycloak email))]
             (cond
               (nil? jwt-claims) not-authenticated
-              (admin-path? request) (if (api-tenant-admin? tenant allowed-paths)
+              (admin-path? request) (if (api-tenant-admin? tenant @allowed-paths)
                                       (handler request)
                                       not-authorized)
-              (api-path? request) (if (api-tenant-member? tenant allowed-paths)
+              (api-path? request) (if (api-tenant-member? tenant @allowed-paths)
                                     (handler request)
                                     not-authorized)
               :else not-authorized))
           (catch Exception e
-            (log/info (.getMessage e))
-            (case (-> e ex-data :response-code)
-              503 service-unavailable
-              401 not-authorized
-              internal-server-error)))
+            (let [wrap-info (fn [e v] (log/info (.getMessage e)) v)]
+              (case (-> e ex-data :response-code)
+                503 (wrap-info e service-unavailable)
+                401 not-authorized
+                (wrap-info e internal-server-error)))))
         (handler request)))))

 (defmethod ig/pre-init-spec :akvo.lumen.auth/wrap-authorization [_]


Unfuck deps.cljs

Unfuck deps.cljs

--- backend/deps.cljs
+++ backend/deps.cljs
@@ -1 +1 @@
-{:externs :["chemtrack/externs/express-ws.js"]}
+{:externs ["chemtrack/externs/express-ws.js"]}


Add descriptions to the MP3 encoder devcards

--- src/devcards/audio_utils/devcards/mp3_encoder.cljs
+++ src/devcards/audio_utils/devcards/mp3_encoder.cljs
@@ -185,14 +185,24 @@
                          "Run test"]))))

 (defcard
-  ""
+  "An OGG played back, chunked and encoded into 5s long MP3s with
+   a 160kb/s bit rate and a sample rate of 44100. The concatenated
+   result shows notable audio glitches where the MP3s are stitched
+   together, likely resulting from encoding and decoding slightly
+   altering the waveforms."
   (fn [state owner]
     (encoder-test state))
   {:worker "mp3-encoder-1.js"
    :source "public/viper.ogg"})

 (defcard
-  ""
+  "A 1000Hz sine wave, played back at -30dB for 2 seconds, -3dB for
+   2 seconds, -30dB for 2 seconds, -6dB for 2 seconds and -30dB for
+   2 seconds. It is processed using a gate (threshold -16dB, look-ahead
+   500ms, hold time 1000ms, RMS window 100ms) and is chunked using a
+   triggered chunker controlled by the gate. The result are two MP3s
+   for the -3dB and -6dB periods, with a 500ms and 1000ms of the quieter
+   audio signal at the beginning and end, respectively."
   (fn [state owner]
     (encoder-test state))
   {:worker "mp3-encoder-2.js"


temporary save

temporary save

--- src/synthesis_crawlers/core.clj
+++ src/synthesis_crawlers/core.clj
@@ -75,7 +75,6 @@
      (empty? container-expr) attr-expr
      :else (str container-expr " > " attr-expr))})

-
 ;; If container is empty, it is interpreted as a node descriptor that extracts the root of the page.
 ;; If container is empty and f is undefined for every attribute, we say that the data extractor is empty.
 (s/fdef drop-undef-attr-extractors
@@ -121,7 +120,6 @@
                         text (vals (:pages (sites site)))]
                     (extract text extractor))]
     (apply (partial merge-with into) extracted)))
-

 (s/fdef empty-extractor?
         :args (s/cat :extractor (s/map-of ::container-extractor
@@ -358,8 +356,9 @@
 (s/fdef unify-exprs
         :args (s/cat :exprs-with-supports (s/coll-of
                                             (fn [{:keys [expr support]}]
-                                              (and (int? support)
-                                                   (s/coll-of ::expr))))
+                                              (and (int? support) ;; FIXME
+                                                   (s/valid?
+                                                     (s/coll-of ::expr) expr))))
                      :threshold double?))
 (defn unify-exprs
   [exprs-with-supports threshold]
@@ -374,11 +373,22 @@
       (if (>= iter longest)
         agreed-path
         (let [agreed (filter #(agree? (:expr %) agreed-path) still-agreed)
-              instructions (map #(nth (:expr %) iter) agreed)
-              ]
+              instructions (map (fn [{:keys [expr support]}]
+                                  (hash-map :inst (nth expr iter)
+                                            :support support))
+                                agreed)]
           (if-not (seq? instructions)
             agreed-path
-            (str "to be implemented" ":" (println instructions))
+            (reduce (fn [acc expr]
+                      (let [score (apply + (map :support
+                                                (filter (fn [{:keys [inst support]}]
+                                                          (agree? [inst] [expr]))
+                                                        instructions)))]
+                        (if (> score (* threshold * total-support))
+                          :recur
+                          )))
+                    nil
+                    (sort compare-instruction (map :inst instructions)))
             ))
         ))))


refactor extracotrs spec

refactor extracotrs spec

--- src/synthesis_crawlers/core.clj
+++ src/synthesis_crawlers/core.clj
@@ -30,7 +30,7 @@
 (s/def ::container-extractor string?)
 (s/def ::complete-attr-extractor (s/map-of keyword? string?))
 (s/def ::text string?)
-(s/def ::extractors (s/map-of ::container-extractor ::attr-extractor))
+(s/def ::extractor (s/map-of ::container-extractor ::attr-extractor))
 (s/def ::complete-extractor (s/map-of ::container-extractor
                                       ::complete-attr-extractor))
 (defn build-selector [attribute container-expr attr-expr]
@@ -49,7 +49,7 @@
   (select-keys attr-extractors (filter #(get attr-extractors %)  (keys attr-extractors))))

 (s/fdef build-selectors
-        :ars (s/cat :extractors ::extractors))
+        :ars (s/cat :extractors ::extractor))
 (defn build-selectors
   [extractors]
   (let [built (for [[container attr-extractors] extractors
@@ -60,7 +60,7 @@
             (map first (map seq built)))))

 (s/fdef extract
-        :args (s/cat :text ::text :extractors ::extractors)
+        :args (s/cat :text ::text :extractors ::extractor)
         :ret (s/map-of keyword? set?))
 (defn extract
   [text extractors]


Point kibana ELB at the logstash instance

--- src/terraboot/elasticsearch.clj
+++ src/terraboot/elasticsearch.clj
@@ -198,7 +198,7 @@
                                       :listeners [(elb-listener (if cert-name
                                                                   {:lb-port 443 :lb-protocol "https" :port 80 :protocol "http" :cert-name "StartMastodoncNet"}
                                                                   {:port 80 :protocol "http"}))]
-                                      :instances [(id-of "aws_instance" (vpc-unique "kibana"))]
+                                      :instances [(id-of "aws_instance" (vpc-unique "logstash"))]
                                       :security-groups (map #(id-of "aws_security_group" %)
                                                             ["allow_outbound"
                                                              "allow_external_http_https"


Add elb-kibana SG to the logstash instance

It's a bad name, but does what we want

--- src/terraboot/elasticsearch.clj
+++ src/terraboot/elasticsearch.clj
@@ -178,6 +178,7 @@
                                                                               (id-of "aws_security_group" "allow_ssh")
                                                                               (vpc-id-of "aws_security_group" "sends_influx")
                                                                               (vpc-id-of "aws_security_group" "all-servers")
+                                                                              (vpc-id-of "aws_security_group" "elb-kibana")
                                                                               ]
                                                      :user_data (logstash-user-data-coreos "es.sandpit-vpc.kixi")
                                                      :associate_public_ip_address true


add udp to security group

add udp to security group

--- src/terraboot/elasticsearch.clj
+++ src/terraboot/elasticsearch.clj
@@ -83,6 +83,9 @@
                                                 ]}
                                  {:port 9200
                                   :protocol "tcp"
+                                  :cidr_blocks [all-external]}
+                                 {:port 9200
+                                  :protocol "udp"
                                   :cidr_blocks [all-external]})

              (vpc-resource "aws_eip" "logstash"


Add plaintext test

Add plaintext test

--- frameworks/Clojure/pedestal/src/pedestal/service.clj
+++ frameworks/Clojure/pedestal/src/pedestal/service.clj
@@ -12,12 +12,21 @@
                               (clojure-version)
                               (route/url-for ::about-page))))

-(defn json-test
+(defn json-serialization
   [request]
   (bootstrap/json-response {:message "Hello, World!"}))

+(defn plaintext
+  [request]
+  (ring-resp/response "Hello, World!"))
+
+
+
+
 (defroutes routes
-  [[["/json" {:get json-test}]]])
+  [[
+  [  "/json" {:get json-serialization}]
+  [  "/plaintext" {:get plaintext}]]])

 ;; How the server will look, not the code to start it up
 (def service {:env :prod


Fix bug in monitoring where it attempted to start even when not configured

--- src/yetibot/core/monitoring.clj
+++ src/yetibot/core/monitoring.clj
@@ -22,15 +22,16 @@

 (defn start
   []
-  (if-let [{:keys [host port interval]} (config/get-config ::config [:monitoring])]
-    (let [reporter (-> (riemann/make-riemann host (or port 5555))
-                       (riemann/reporter {:rate-unit TimeUnit/SECONDS
-                                          :duration-unit TimeUnit/MILLISECONDS
-                                          :filter MetricFilter/ALL}))]
-      (log/info "starting monitoring")
-      (reset! riemann-reporter reporter)
-      (riemann/start reporter (or interval 1)))
-    (log/debug "monitoring is not configured")))
+  (let [{:keys [host port interval]} (config/get-config ::config [:monitoring])]
+    (if (and host port interval)
+      (let [reporter (-> (riemann/make-riemann host (or port 5555))
+                         (riemann/reporter {:rate-unit TimeUnit/SECONDS
+                                            :duration-unit TimeUnit/MILLISECONDS
+                                            :filter MetricFilter/ALL}))]
+        (log/info "starting monitoring")
+        (reset! riemann-reporter reporter)
+        (riemann/start reporter (or interval 1)))
+      (log/debug "monitoring is not configured"))))

 (defn stop
   []


Only test whether a module it is undeployed on shutdown.

--- src/containium/modules.clj
+++ src/containium/modules.clj
@@ -295,7 +295,7 @@
                      false)
                  ;; Action channel message
                  (if (instance? containium.modules.Response val)
-                   (if (and (:success? val) (= (:status val) :undeployed))
+                   (if (= (:status val) :undeployed)
                      ;; Succesfully undeployed, remove this channel.
                      (recur (dissoc channel+names channel))
                      ;; Failed to undeploy, schedule another deactivate.


Better write-batch logging

Better write-batch logging

--- src/onyx/plugin/onyx_output.clj
+++ src/onyx/plugin/onyx_output.clj
@@ -25,7 +25,7 @@
 (extend-type Object
   OnyxOutput
   (write-batch [this {:keys [task-type results messenger task-id id egress-ids grouping-fn] :as event}]
-    (info "Writing batch " (vec (:segments results)))
+    (info "Writing batch " (m/replica-version messenger) (m/epoch messenger) task-type (vec (:segments results)))
     (let [leaves (:segments results)]
       (if-not (= task-type :output)
         ;; TODO: implement hash grouping


fix mis-merged type hint

fix mis-merged type hint

--- src/clj/clj_json/core.clj
+++ src/clj/clj_json/core.clj
@@ -45,5 +45,5 @@
 (defn parsed-seq
   "Returns a lazy seq of Clojure objects corresponding to the JSON read from
   the given reader. The seq continues until the end of the reader is reached."
-  [#^BufferedReader reader & [keywords]]
+  [^BufferedReader reader & [keywords]]
   (parsed-seq* (.createJsonParser factory reader) (or keywords false)))


ensure the emittance of properly escaped non ascii characters (including the full unicode range) for maximum host compatibility (Internet Explorer), fixing CLJS-139, 133 and 56

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -11,7 +11,8 @@
 (ns cljs.compiler
   (:refer-clojure :exclude [munge macroexpand-1])
   (:require [clojure.java.io :as io]
-            [clojure.string :as string]))
+            [clojure.string :as string])
+  (:import java.lang.StringBuilder))

 (declare resolve-var)
 (require 'cljs.core)
@@ -154,30 +155,60 @@
 (defn- comma-sep [xs]
   (apply str (interpose "," xs)))

+(defn- escape-char [^Character c]
+  (let [cp (.hashCode c)]
+    (case cp
+      ; Handle printable escapes before ASCII
+      34 "\\\""
+      92 "\\\\"
+      47 "\\/"
+      ; Handle non-printable escapes
+      8 "\\b"
+      12 "\\f"
+      10 "\\n"
+      13 "\\r"
+      9 "\\t"
+      (if (< 31 cp 127)
+        c ; Print simple ASCII characters
+        (format "\\u%04X" cp))))) ; Any other character is Unicode
+
+(defn- escape-string [^CharSequence s]
+  (let [sb (StringBuilder. (count s))]
+    (doseq [c s]
+      (.append sb (escape-char c)))
+    (.toString sb)))
+
+(defn- wrap-in-double-quotes [x]
+  (str \" x \"))
+
 (defmulti emit-constant class)
 (defmethod emit-constant nil [x] (print "null"))
 (defmethod emit-constant Long [x] (print x))
 (defmethod emit-constant Integer [x] (print x)) ; reader puts Integers in metadata
 (defmethod emit-constant Double [x] (print x))
-(defmethod emit-constant String [x] (pr x))
+(defmethod emit-constant String [x]
+  (print (wrap-in-double-quotes (escape-string x))))
 (defmethod emit-constant Boolean [x] (print (if x "true" "false")))
-(defmethod emit-constant Character [x] (pr (str x)))
+(defmethod emit-constant Character [x]
+  (print (wrap-in-double-quotes (escape-char x))))

 (defmethod emit-constant java.util.regex.Pattern [x]
   (let [[_ flags pattern] (re-find #"^(?:\(\?([idmsux]*)\))?(.*)" (str x))]
     (print (str \/ (.replaceAll (re-matcher #"/" pattern) "\\\\/") \/ flags))))

 (defmethod emit-constant clojure.lang.Keyword [x]
-           (pr (str \uFDD0 \'
+           (print (str \" "\\uFDD0" \'
+                       (if (namespace x)
+                         (str (namespace x) "/") "")
+                       (name x)
+                       \")))
+
+(defmethod emit-constant clojure.lang.Symbol [x]
+           (print (str \" "\\uFDD1" \'
                     (if (namespace x)
                       (str (namespace x) "/") "")
-                    (name x))))
-
-(defmethod emit-constant clojure.lang.Symbol [x]
-           (pr (str \uFDD1 \'
-                    (if (namespace x)
-                      (str (namespace x) "/") "")
-                    (name x))))
+                    (name x)
+                    \")))

 (defn- emit-meta-constant [x string]
   (if (meta x)


Update economic model UI to show info for any number of corporations.

--- src/cljs/beatha/core.cljs
+++ src/cljs/beatha/core.cljs
@@ -538,113 +538,100 @@

        (dom/hr nil)))))

-(defn market-output-view
-  [data owner]
-  (let [get-market-info (fn [path] (get-in data (cons :market-state path)))]
+(defn gen-market-info-box
+  [f path]
+  (fn [data owner]
     (reify
       om/IRender
       (render [_]
-        (let [taxation-type (get-market-info [:taxation-type])]
+        (let [corp (:corp data)
+              corp-str (keyword->str corp)]
           (dom/div
-           #js {:className "row"
-                :hidden (not (contains? data :market-state))}
-           (dom/b nil "Taxation type: ")
-           (dom/span nil (keyword->str taxation-type))
-           (dom/div nil)
-
-           (dom/span
-            #js {:hidden (not= :rate taxation-type)}
-            (dom/b nil "Tax rate: ")
-            (dom/span
-             nil
-             (num->percent (get-market-info [:tax-rate])))
-            (dom/div nil))
-
-           (dom/span
-            #js {:hidden (not= :fixed taxation-type)}
-            (dom/b nil "Fixed tax: ")
-            (dom/span nil (get-market-info [:fixed-tax]))
-            (dom/div nil))
-
-           (dom/b nil "Depreciation rate: ")
-           (dom/span
-            nil
-            (num->percent (get-market-info [:depreciation])))
-           (dom/div nil)
-
-           (dom/b nil "Utility function params: ")
-           (dom/div
-            nil
-            (dom/span nil "a: " (get-market-info [:utility-params :a]))
-            (dom/span nil " p: " (get-market-info [:utility-params :p]))
-            (dom/span nil " q: " (get-market-info [:utility-params :q])))
-
-           (dom/b nil "Capital")
-           (dom/div
-            nil
-            "Government: " (get-market-info [:capital :government]))
-           (dom/div
-            #js {:className "corp-1"} "Corporation 1: "
-            (get-market-info [:capital :corp-1]))
-           (dom/div
-            #js {:className "corp-2"} "Corporation 2: "
-            (get-market-info [:capital :corp-2]))
-           (dom/div
-            #js {:className "corp-3"} "Corporation 3: "
-            (get-market-info [:capital :corp-3]))
-           (dom/div
-            #js {:className "corp-4"} "Corporation 4: "
-            (get-market-info [:capital :corp-4]))
-
-           (dom/b nil "Market share")
-           (dom/div
-            #js {:className "without-good"}
-            "Without good: "
-            (num->percent
-             (get-market-info [:global-user-share :without-good])))
-           (dom/div
-            #js {:className "corp-1"} "Corporation 1: "
-            (num->percent (get-market-info [:global-user-share :corp-1])))
-           (dom/div
-            #js {:className "corp-2"} "Corporation 2: "
-            (num->percent (get-market-info [:global-user-share :corp-2])))
-           (dom/div
-            #js {:className "corp-3"} "Corporation 3: "
-            (num->percent (get-market-info [:global-user-share :corp-3])))
-           (dom/div
-            #js {:className "corp-4"} "Corporation 4: "
-            (num->percent (get-market-info [:global-user-share :corp-4])))
-
-           (dom/b nil "Good prices")
-           (dom/div
-            #js {:className "corp-1"} "Corporation 1: "
-            (get-market-info [:prices :corp-1]))
-           (dom/div
-            #js {:className "corp-2"} "Corporation 2: "
-            (get-market-info [:prices :corp-2]))
-           (dom/div
-            #js {:className "corp-3"} "Corporation 3: "
-            (get-market-info [:prices :corp-3]))
-           (dom/div
-            #js {:className "corp-4"} "Corporation 4: "
-            (get-market-info [:prices :corp-4]))
-
-           (dom/b nil "Good quality")
-           (dom/div
-            #js {:className "corp-1"} "Corporation 1: "
-            (get-market-info [:quality :corp-1]))
-           (dom/div
-            #js {:className "corp-2"} "Corporation 2: "
-            (get-market-info [:quality :corp-2]))
-           (dom/div
-            #js {:className "corp-3"} "Corporation 3: "
-            (get-market-info [:quality :corp-3]))
-           (dom/div
-            #js {:className "corp-4"} "Corporation 4: "
-            (get-market-info [:quality :corp-4]))))))))
+           #js {:className corp-str}
+           (apply str "Corporation " (get (.split corp-str "-") 1) ": ")
+           (f (conj path corp))))))))
+
+(defn gen-market-output-view
+  [corps]
+  (fn [data owner]
+    (let [get-market-info (fn [path] (get-in data (cons :market-state path)))]
+      (reify
+        om/IRender
+        (render [_]
+          (let [taxation-type (get-market-info [:taxation-type])]
+            (dom/div
+             #js {:className "row"
+                  :hidden (not (contains? data :market-state))}
+             (dom/b nil "Taxation type: ")
+             (dom/span nil (keyword->str taxation-type))
+             (dom/div nil)
+
+             (dom/span
+              #js {:hidden (not= :rate taxation-type)}
+              (dom/b nil "Tax rate: ")
+              (dom/span
+               nil
+               (num->percent (get-market-info [:tax-rate])))
+              (dom/div nil))
+
+             (dom/span
+              #js {:hidden (not= :fixed taxation-type)}
+              (dom/b nil "Fixed tax: ")
+              (dom/span nil (get-market-info [:fixed-tax]))
+              (dom/div nil))
+
+             (dom/b nil "Depreciation rate: ")
+             (dom/span
+              nil
+              (num->percent (get-market-info [:depreciation])))
+             (dom/div nil)
+
+             (dom/b nil "Utility function params: ")
+             (dom/div
+              nil
+              (dom/span nil "a: " (get-market-info [:utility-params :a]))
+              (dom/span nil " p: " (get-market-info [:utility-params :p]))
+              (dom/span nil " q: " (get-market-info [:utility-params :q])))
+
+             (dom/b nil "Capital")
+             (dom/div
+              nil
+              "Government: " (get-market-info [:capital :government]))
+             (apply
+              dom/span nil
+              (om/build-all
+               (gen-market-info-box get-market-info [:capital]) corps))
+
+             (dom/b nil "Market share")
+             (dom/div
+              #js {:className "without-good"}
+              "Without good: "
+              (num->percent
+               (get-market-info [:global-user-share :without-good])))
+             (apply
+              dom/span nil
+              (om/build-all
+               (gen-market-info-box
+                (comp num->percent get-market-info)
+                [:global-user-share])
+               corps))
+
+             (dom/b nil "Good prices")
+             (apply
+              dom/span nil
+              (om/build-all
+               (gen-market-info-box get-market-info [:prices]) corps))
+
+             (dom/b nil "Good quality")
+             (apply
+              dom/span nil
+              (om/build-all
+               (gen-market-info-box get-market-info [:quality]) corps)))))))))

 (def market-model-customization
-  (let [corps (keys (:prices a/market-model-default-state))]
+  (let [corps (keys (:prices a/market-model-default-state))
+        market-output-view
+        (gen-market-output-view (map (fn [x] {:corp x}) corps))]
     (reify
       CellularAutomatonAppCustomization
       (automaton-specific-css [_]


Remove notes

Remove notes

--- src/cljs/fatlip/core.cljs
+++ src/cljs/fatlip/core.cljs
@@ -1,9 +1,3 @@
-;; Change name to urthr?  sudicka?
-;; Count crossings for subnodes
-;; Account for danglers
-;; cycle detection to short circuit the layer sweeps
-;; do cross counting based on the smaller of the two layers
-
 (ns fatlip.core
   (:require [clojure.core.rrb-vector :as rrb]
             [clojure.set :as set]


Moar.

Moar.

--- src/clojurecraft/core.clj
+++ src/clojurecraft/core.clj
@@ -14,6 +14,7 @@
      0x05 :equipment
      0x06 :spawnposition
      0x07 :useentity
+     0x08 :updatehealth
 })
 (def packet-ids (apply assoc {} (mapcat reverse packet-types)))

@@ -169,6 +170,10 @@
           (assoc :user (-read-int conn))
           (assoc :target (-read-int conn))
           (assoc :leftclick (-read-bool conn))))
+
+(defn read-packet-updatehealth [conn]
+      (-> {}
+          (assoc :health (-read-short conn))))

 ; Reading Wrappers -----------------------------------------------------------------
@@ -186,6 +191,7 @@
             (= packet-type :equipment) (read-packet-equipment conn)
             (= packet-type :spawnposition) (read-packet-spawnposition conn)
             (= packet-type :useentity) (read-packet-useentity conn)
+            (= packet-type :updatehealth) (read-packet-updatehealth conn)
             :else (str "UNKNOWN PACKET TYPE: " packet-id)
             ))
         (println "\n\n\n")))


Quick fix to correct port

Quick fix to correct port

--- src/cmr/search/system.clj
+++ src/cmr/search/system.clj
@@ -17,7 +17,7 @@
   "Returns a new instance of the whole application."
   []
   {:log (log/create-logger)
-   :search-index (idx/create-elastic-search-index "localhost" 9220)
+   :search-index (idx/create-elastic-search-index "localhost" 9210)
    :web (web/create-web-server 3003 routes/make-api)
    :zipkin (context/zipkin-config "Search" false)})


TikZ output format started

TikZ output format started

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

--- src/conexp/io/layouts.clj
+++ src/conexp/io/layouts.clj
@@ -143,6 +143,68 @@
                    (set-of [(nodes x) (nodes y)]
                            [[x y] conn])))))

+;;; TikZ
+
+(define-layout-output-format :tikz
+  [layout file]
+  (let [infs         (set (inf-irreducibles layout)),
+        sups         (set (sup-irreducibles layout)),
+        insu         (intersection infs sups),
+        vertex-pos   (positions layout),
+        sorted       (sort #(let [[x_1 y_1] (vertex-pos %1),
+                                  [x_2 y_2] (vertex-pos %2)]
+                              (or (< y_1 y_2)
+                                  (and (= y_1 y_2)
+                                       (< x_1 x_2))))
+                           (nodes layout)),
+        vertex-idx   (into {}
+                           (map-indexed (fn [i v] [v i])
+                                        sorted)),
+        vertex-lines (map (fn [v]
+                            (let [i     (vertex-idx v),
+                                  [x y] (vertex-pos v)]
+                              (str "        " i "/"
+                                   (cond
+                                    (contains? insu v)  "divertex"
+                                    (contains? sups v)  "jivertex"
+                                    (contains? infs v)  "mivertex"
+                                    :else               "vertex")
+                                   "/" x "/" y)))
+                          sorted)]
+    (with-out-writer file
+      (println "\\colorlet{mivertexcolor}{blue}")
+      (println "\\colorlet{jivertexcolor}{red}")
+      (println "\\colorlet{vertexcolor}{mivertexcolor!50}")
+      (println "\\colorlet{bordercolor}{black!80}")
+      (println "\\colorlet{linecolor}{gray}")
+      (println "\\tikzset{vertexbase/.style={semithick, shape=circle, inner sep=2pt, outer sep=0pt, draw=bordercolor},%")
+      (println "  vertex/.style={vertexbase, fill=vertexcolor!45},%")
+      (println "  mivertex/.style={vertexbase, fill=mivertexcolor!45},%")
+      (println "  jivertex/.style={vertexbase, fill=jivertexcolor!45},%")
+      (println "  divertex/.style={vertexbase, top color=mivertexcolor!45, bottom color=jivertexcolor!45},%")
+      (println "  conn/.style={-, thick, color=linecolor}%")
+      (println "}")
+      (println "\\begin{tikzpicture}")
+      (println "  \\begin{scope} %for scaling and the like")
+      (println "    \\begin{scope} %draw vertices")
+      (println "      \\foreach \\nodename/\\nodetype/\\xpos/\\ypos in {%")
+      (doseq [x (interpose ",\n" vertex-lines)]
+        (print x))
+      (println)
+      (println "      } \\nodex[\\nodetype] (\\nodename) at (\\xpos, \\ypos) {};")
+      (println "    \\end{scope}")
+      (println "    \\begin{scope} %draw connections")
+      (doseq [[v w] (connections layout)]
+        (println (str "      \\path (" (vertex-idx v) ") edge[conn] (" (vertex-idx w) ");")))
+      (println "    \\end{scope}")
+      (println "    \\begin{scope} %add labels")
+      (println "      \\foreach \\nodename/\\labelpos/\\labelopts/\\labelcontent in {%")
+      'todo
+      (println "      } \\coordinate[label={[\\labelopts]\\labelpos:{\\labelcontent}}](c) at (\\nodename);")
+      (println "    \\end{scope}")
+      (println "  \\end{scope}")
+      (println "\\end{tikzpicture}"))))
+
 ;;; FCA-style

 (define-layout-output-format :fca-style


added definitions for single, maximum and average linkage clustering

--- src/crawler/extractor.clj
+++ src/crawler/extractor.clj
@@ -376,7 +376,8 @@
         xpath-expls)))
     explorations)))

-(defn cluster-member?
+(defn cluster-member-single?
+  "Single linkage clustering of explorations"
   [a-cluster x]
   (some
    (fn [a-member]
@@ -387,6 +388,37 @@
           0.75)
          *page-sim-thresh*))
    a-cluster))
+
+(defn cluster-member-maximum?
+  "Cluster explorations using maximum linkage"
+  [a-cluster x]
+  (every?
+   (fn [a-member]
+     (>= (page/signature-edit-distance-similarity
+          (-> a-member :r1)
+          (-> x :r1)
+          0.25
+          0.75)
+         *page-sim-thresh*))
+   a-cluster))
+
+(defn cluster-member-average?
+  "CLuster explorations using average linkage"
+  [a-cluster x]
+  (let [sim-scores (map
+                    (fn [a-member]
+                      (page/signature-edit-distance-similarity
+                       (-> a-member :r1)
+                       (-> x :r1)
+                       0.25
+                       0.75)
+                      *page-sim-thresh*)
+                    a-cluster)]
+
+    (/ (apply + sim-scores)
+       (count sim-scores))))
+
+(def cluster-member? cluster-member-single?)

 (defn cluster-explorations
   "Explorations are converted to an exploration-ds and
@@ -473,7 +505,6 @@
   [explorations clusters]

   (let [total-expl   (-> clusters flatten count)
-
         enums-ranked (fetch-enum-xpaths explorations clusters)]

     {:enum-candidates-ranked enums-ranked}))


Fixed up assoc for BitmapIndexedNode

Fixed up assoc for BitmapIndexedNode

--- src/main/cljs/fast_map/core.cljs
+++ src/main/cljs/fast_map/core.cljs
@@ -7,7 +7,7 @@
                             create-inode-seq create-array-node-seq create-node
                             mask bitmap-indexed-node-index bitpos]))

-(declare NodeSeq TransientHashMap PersistentHashMap)
+(declare NodeSeq HashCollisionNode TransientHashMap PersistentHashMap)

 (deftype Box [^:mutable added ^:mutable modified])

@@ -58,7 +58,21 @@
       (array-copy arr (+ 2 idx-old) dst idx-old (- idx-new idx-old))
       (aset dst idx-new node)
       (array-copy arr (+ idx-new 2) dst (inc idx-new) (- (alength arr) idx-new 2))
-      (BitmapIndexedNode. e (bit-or datamap bit) (bit-xor nodemap bit) dst)))
+      (BitmapIndexedNode. e (bit-xor datamap bit) (bit-or nodemap bit) dst)))
+
+  (merge-two-kv-pairs [inode medit shift key1 val1 key2hash key2 val2]
+    (let [key1hash (hash key1)]
+      (if (and (< shift 32) (== key1hash key2hash))
+        (HashCollisionNode. medit key1hash 2 (array key1 val1 key2 val2))
+        (let [mask1 (mask key1hash shift)
+              mask2 (mask key2hash shift)]
+          (if (== mask1 mask2)
+            (let [new-node (.merge-two-kv-pairs inode medit (+ shift 5) key1 val1 key2hash key2 val2)]
+              (BitmapIndexedNode. medit 0 (bitpos key1hash shift) (array new-node)))
+            (let [new-datamap (bit-or (bitpos key1hash shift) (bitpos key2hash shift))]
+              (if (< mask1 mask2)
+                (BitmapIndexedNode. medit new-datamap 0 (array key1 val1 key2 val2))
+                (BitmapIndexedNode. medit new-datamap 0 (array key2 val2 key1 val1)))))))))

   (inode-seq [inode]
     (NodeSeq. nil arr (* 2 (bit-count datamap)) (bit-count nodemap) 0 nil nil))
@@ -71,11 +85,10 @@
               k (aget arr (* 2 idx))]
           (set! (.-modified changed?) true)
           (if (= k key)
-            (do
+            (.copy-and-set-value inode aedit bit val)
+            (let [v (aget arr (inc (* 2 idx)))
+                  new-node (.merge-two-kv-pairs inode aedit (+ shift 5) k v hash key val)]
               (set! (.-added changed?) true)
-              (.copy-and-set-value inode aedit bit val))
-            (let [v (aget arr (inc (* 2 idx)))
-                  new-node (create-node aedit (+ shift 5) k v hash key val)]
               (.copy-and-migrate-to-node inode aedit bit new-node))))
         (not (zero? (bit-and nodemap bit)))
         (let [sub-node (node-at arr nodemap bit)
@@ -84,13 +97,13 @@
             (.copy-and-set-node inode aedit bit sub-node-new)
             inode))
         :else
-        (let [n (bit-count datamap)
-              idx (bitmap-indexed-node-index datamap bit)
-              new-arr (make-array (* 2 (inc n)))]
-          (array-copy arr 0 new-arr 0 (* 2 idx))
-          (aset new-arr (* 2 idx) key)
-          (aset new-arr (inc (* 2 idx)) val)
-          (array-copy arr (* 2 idx) new-arr (* 2 (inc idx)) (* 2 (- n idx)))
+        (let [n (alength arr)
+              idx (* 2 (bitmap-indexed-node-index datamap bit))
+              new-arr (make-array (+ 2 n))]
+          (array-copy arr 0 new-arr 0 idx )
+          (aset new-arr idx key)
+          (aset new-arr (inc idx) val)
+          (array-copy arr idx new-arr (+ 2 idx) (- n idx))
           (set! (.-added changed?) true)
           (BitmapIndexedNode. aedit (bit-or datamap bit) nodemap new-arr)))))

@@ -107,6 +120,7 @@
         (.inode-lookup (node-at arr nodemap bit) (+ shift 5) hash key not-found)
         :else
         not-found)))
+
   (inode-find [inode shift hash key not-found]
     (let [bit (bitpos hash shift)]
       (cond
@@ -324,16 +338,25 @@
   (-reduce [coll f start] (seq-reduce f start coll)))

 (extend-protocol IPrintWithWriter
+  NodeSeq
+  (-pr-writer [coll writer opts] (pr-sequential-writer writer pr-writer "(" " " ")" opts coll))
   PersistentHashMap
   (-pr-writer [coll writer opts]
     (print-map coll pr-writer writer opts)))

 (comment
   (let [em (.-EMPTY PersistentHashMap)
+        times 12
         hm1 (loop [m em i 0]
-              (if (< i 50)
+              (if (< i times)
                 (recur (assoc m (str "key" i) i) (inc i))
-                m))]
-    (println hm1)
-    [(= (into #{} (vals hm1)) (into #{} (map #(get hm1 (str "key" %)) (range 50))))
-     (= (keys hm1) (map (fn [[k v]] k) hm1))]))+                m))
+        root (.-root hm1)]
+
+    [ (count hm1)  (seq hm1)]
+    #_[(count hm1)
+       (= (into #{} (vals hm1)) (into #{} (range times)))
+       (= (into #{} (vals hm1)) (into #{} (map #(get hm1 (str "key" %)) (range times))))
+       (= (keys hm1) (map (fn [[k v]] k) hm1))
+       (= (into #{} (keys hm1)) (into #{} (map #(str "key" %) (range times))))])
+  )


Move insertion tracking outside of loop to avoid redundant execution.

--- src/main/clojure/clara/rules.clj
+++ src/main/clojure/clara/rules.clj
@@ -56,12 +56,12 @@
     ;; Update the insertion count.
     (swap! insertions + (count facts))

+    ;; Track this insertion in our transient memory so logical retractions will remove it.
+    (when (not unconditional)
+      (mem/add-insertions! transient-memory node token facts))
+
     (doseq [[alpha-roots fact-group] (get-alphas-fn facts)
             root alpha-roots]
-
-      ;; Track this insertion in our transient memory so logical retractions will remove it.
-      (when (not unconditional)
-        (mem/add-insertions! transient-memory node token facts))

       (eng/alpha-activate root fact-group transient-memory transport))))


Use properly specific function

Use properly specific function

--- src/braid/server/routes/api/private.clj
+++ src/braid/server/routes/api/private.clj
@@ -19,14 +19,14 @@
                        markdown->hiccup)}))

   (GET "/extract" [url :as {session :session}]
-    (if (some? (db/user-by-id (:user-id session)))
+    (if (db/user-id-exists? (:user-id session))
       (edn-response (embedly/extract url))
       {:status 403
        :headers {"Content-Type" "application/edn"}
        :body (pr-str {:error "Unauthorized"})}))

   (GET "/s3-policy" req
-    (if (some? (db/user-by-id (get-in req [:session :user-id])))
+    (if (db/user-id-exists? (get-in req [:session :user-id]))
       (if-let [policy (s3/generate-policy)]
         {:status 200
          :headers {"Content-Type" "application/edn"}


small fix

small fix

--- src/cljs/salava/metabadge/ui/modal.cljs
+++ src/cljs/salava/metabadge/ui/modal.cljs
@@ -148,36 +148,34 @@
         (str completed "%")]]]
      [:div.col-md-9 {:id "badge-stats"}
       [:div.col-md-12
-              [:h1.uppercase-header (:name metabadge)]
+       [:h1.uppercase-header (:name metabadge)]
        [:div.description (if-not is-complete? (t :metabadge/Milestoneinfo) (t :metabadge/Completedmilestoneinfo))]
-       #_[:div {:style {:margin-top "10px"}}[:label (str (t :metabadge/Minimumrequired) ": ")] min_required]
-       #_[:div [:label (str (t :metabadge/Amountearned)": ")] amount_received]
-      [:hr]
-      [:div.panel
-       [:div.panel-body
-        [:div.row.header {:style {:margin-bottom "10px" :margin-top "10px"}}
-         [:div.row.flip-table
-          [:div.col-md-6]
-          [:div.col-md-2 (t :metabadge/Earnedon)]
-          [:div.col-md-4]]]
-        (reduce (fn [r badge]
-                  (let [{:keys [badge-info received current user_badge]} badge
-                        {:keys [name image criteria]} badge-info
-                        {:keys [id issued_on status]} user_badge
-                        image-class (if-not received " opaque")]
-                    (conj r [:div
-                             [:div.row.flip-table {:style {:margin-bottom "10px"}}
-                              [:div.col-md-1 [:img.badge-icon {:src image :class image-class}]]
-                              [:div.col-md-5 (if received
-                                               (if (= status "declined")
-                                                 [:a {:href "#" :on-click #(mo/open-modal [:metabadge :declined] badge)} name]
-                                                 [:a {:href "#" :on-click #(mo/open-modal [:badge :info] {:badge-id id})} name])
-                                               [:a {:href "#" :on-click #(mo/open-modal [:metabadge :dummy] badge)} name]
-                                               )]
-                              [:div.col-md-2 [:label (t :metabadge/Dateissued)] (if issued_on (date-from-unix-time (* 1000 issued_on)) "-")]
-                              [:div.col-md-4 ]]]))) [:div.row.body] (->> required_badges
-                                                                         (sort-by #(-> % :user_badge :issued_on) >)
-                                                                         (sort-by :received >)))]]]]]))
+       [:hr]
+       [:div.panel
+        [:div.panel-body
+         [:div.row.header {:style {:margin-bottom "10px" :margin-top "10px"}}
+          [:div.row.flip-table
+           [:div.col-md-6]
+           [:div.col-md-2 (t :metabadge/Earnedon)]
+           [:div.col-md-4]]]
+         (reduce (fn [r badge]
+                   (let [{:keys [badge-info received current user_badge]} badge
+                         {:keys [name image criteria]} badge-info
+                         {:keys [id issued_on status]} user_badge
+                         image-class (if-not received " opaque")]
+                     (conj r [:div
+                              [:div.row.flip-table {:style {:margin-bottom "10px"}}
+                               [:div.col-md-1 [:img.badge-icon {:src image :class image-class}]]
+                               [:div.col-md-5 (if received
+                                                (if (= status "declined")
+                                                  [:a {:href "#" :on-click #(mo/open-modal [:metabadge :declined] badge)} name]
+                                                  [:a {:href "#" :on-click #(mo/open-modal [:badge :info] {:badge-id id})} name])
+                                                [:a {:href "#" :on-click #(mo/open-modal [:metabadge :dummy] badge)} name]
+                                                )]
+                               [:div.col-md-2 [:label (t :metabadge/Earnedon)] (if issued_on (date-from-unix-time (* 1000 issued_on)) "-")]
+                               [:div.col-md-4 ]]]))) [:div.row.body] (->> required_badges
+                                                                          (sort-by #(-> % :user_badge :issued_on) >)
+                                                                          (sort-by :received >)))]]]]]))

 (defn modal-navi [metabadge state]
   [:div.row.flip-table


Make these behave better outside of the container

--- namespaces/common/src/main/clojure/immutant/util.clj
+++ namespaces/common/src/main/clojure/immutant/util.clj
@@ -46,7 +46,8 @@
 (defn app-relative
   "Returns a file relative to app-root"
   [& path]
-  (apply io/file (app-root) path))
+  (if-let [root (app-root)]
+    (apply io/file root path)))

 (defn at-exit
   "Registers a function to be called when the application is undeployed.
@@ -80,12 +81,14 @@
 (defn http-port
   "Returns the HTTP port for the embedded web server"
   []
-  (.getPort (registry/get "jboss.web.connector.http")))
+  (if-let [server (registry/get "jboss.web.connector.http")]
+    (.getPort server)))

 (defn context-path
   "Returns the HTTP context path for the deployed app"
   []
-  (.getName (immutant.registry/get "web-context")))
+  (if-let [context (immutant.registry/get "web-context")]
+    (.getName context)))

 (defn app-uri
   "Returns the base URI for the app, given a host [localhost]"


Tidy up

Tidy up

--- src/devcards/discuss/devcards/core.cljs
+++ src/devcards/discuss/devcards/core.cljs
@@ -19,17 +19,6 @@
          lib/app-state
          #_{:history true})

-#_(defcard user-information
-           ""
-           (dom/div nil
-                    (dom/h6 nil "User")
-                    (dom/pre nil (lib/get-nickname))
-                    (dom/h6 nil "Auth Token")
-                    (dom/pre nil (lib/get-token))
-                    (dom/h6 nil "CSRF Token")
-                    (dom/pre nil (lib/get-csrf))
-                    ))
-
 (defcard control-buttons
          ""
          (dom/div nil
@@ -38,22 +27,14 @@
                               (dom/i #js {:className "fa fa-fort-awesome"}))
                   (debug/control-buttons lib/app-state)))

-#_(defcard debug
-           (dc/om-root debug/debug-view)
-           lib/app-state)
-
-#_(defcard global-state
-           @lib/app-state)
-
 (defcard find-form
          ""
          (dc/om-root find/form-view))

 (defcard-om find-statement
-            "Query database to find stataments."
+            "Query database to find statements."
             find/results-view
-            lib/app-state
-            )
+            lib/app-state)

 (deftest find-tests
          "Testing the small search engine in `discuss.find`"
@@ -71,7 +52,4 @@
 (deftest lib-test
          (testing "cljs to json conversion stuff"
            (let [json "{\"distance_name\": \"Levensthein\", \"values\": {\"00020_020\": \"Foobaraaaaaaaaaaaaaa.\", \"00033_013\": \"This is the only park in our city.\"}}"]
-             (is (= {:distance_name "Levensthein", :values {:00020_020 "Foobaraaaaaaaaaaaaaa.", :00033_013 "This is the only park in our city."}} (lib/json->clj json))))))
-
-#_(deftest communication-test
-           "Testing `discuss.communication`")+             (is (= {:distance_name "Levensthein", :values {:00020_020 "Foobaraaaaaaaaaaaaaa.", :00033_013 "This is the only park in our city."}} (lib/json->clj json))))))


be more forceful

be more forceful

--- src/matross/connections/core.clj
+++ src/matross/connections/core.clj
@@ -28,7 +28,7 @@
 (defn verify-sudo-state [conn]
   ;; here we can do things like kill the cache
   ;; verify a password is needed, the pass is correct, etc
-  (let [proc (run conn {:cmd ["sudo" "-k"]})]
+  (let [proc (run conn {:cmd ["sudo" "-K"]})]
     (= @(:exit proc) 0)))

 (defn sudo-command [command user]


Fix bad merge :unamused:

Fix bad merge :unamused:

--- src/metabase/query_processor.clj
+++ src/metabase/query_processor.clj
@@ -512,24 +512,23 @@
   ;; TODO: it probably makes sense to throw an error or return a failure response here if we can't get a driver
   (let [driver (driver/database-id->driver (:database query))]
     (binding [*driver* driver]
-      (let [driver-process-in-context (partial driver/process-query-in-context driver)]
-        ((<<- wrap-catch-exceptions
-              pre-add-settings
-              pre-expand-macros
-              pre-substitute-parameters
-              pre-expand-resolve
-              driver-process-in-context
-              post-add-row-count-and-status
-              post-format-rows
-              pre-add-implicit-fields
-              pre-add-implicit-breakout-order-by
-              cumulative-sum
-              cumulative-count
-              limit
-              post-check-results-format
-              pre-log-query
-              guard-multiple-calls
-              run-query) (assoc query :driver driver))))))
+      ((<<- wrap-catch-exceptions
+            pre-add-settings
+            pre-expand-macros
+            pre-substitute-parameters
+            pre-expand-resolve
+            (driver/process-query-in-context driver)
+            post-add-row-count-and-status
+            post-format-rows
+            pre-add-implicit-fields
+            pre-add-implicit-breakout-order-by
+            cumulative-sum
+            cumulative-count
+            limit
+            post-check-results-format
+            pre-log-query
+            guard-multiple-calls
+            run-query) (assoc query :driver driver)))))

 ;;; +----------------------------------------------------------------------------------------------------+


Fix race condition between throw exception and restart channel.

--- src/onyx/peer/task_lifecycle.clj
+++ src/onyx/peer/task_lifecycle.clj
@@ -52,7 +52,9 @@

               (= action :restart)
               (do (>!! (:onyx.core/restart-ch event) true)
-                  (throw t))
+                  (throw (ex-info "Jumping out of task lifecycle for a clean restart."
+                                  {:onyx.core/lifecycle-restart? true
+                                   :original-exception t})))

               :else
               (throw (ex-info
@@ -462,12 +464,15 @@
           (:onyx.core/triggers event)))

 (defn handle-exception [log restart-pred-fn e restart-ch outbox-ch job-id]
-  (warn e "Uncaught exception throw inside task lifecycle.")
-  (if (restart-pred-fn e)
-    (>!! restart-ch true)
-    (let [entry (entry/create-log-entry :kill-job {:job job-id})]
-      (extensions/write-chunk log :exception e job-id)
-      (>!! outbox-ch entry))))
+  (let [data (ex-data e)]
+    (if (:onyx.core/lifecycle-restart? data)
+      (warn (:original-exception data) "Caught exception inside task lifecycle. Rebooting the task.")
+      (do (warn e "Uncaught exception throw inside task lifecycle.")
+          (if (restart-pred-fn e)
+            (>!! restart-ch true)
+            (let [entry (entry/create-log-entry :kill-job {:job job-id})]
+              (extensions/write-chunk log :exception e job-id)
+              (>!! outbox-ch entry)))))))

 (defn run-task-lifecycle
   "The main task run loop, read batch, ack messages, etc."


Switch name to assign-windows.

Switch name to assign-windows.

[ci skip]

--- src/onyx/peer/task_lifecycle.clj
+++ src/onyx/peer/task_lifecycle.clj
@@ -312,7 +312,7 @@
                                    (count (:onyx.core/results rets))))
     rets))

-(defn populate-windows
+(defn assign-windows
   [{:keys [onyx.core/windows onyx.core/window-state onyx.core/results] :as event}]
   (if (seq windows)
     (do
@@ -452,7 +452,7 @@
              (add-messages-to-timeout-pool task-type state)
              (process-sentinel task-type pipeline monitoring)
              (apply-fn fn bulk?)
-             (populate-windows)
+             (assign-windows)
              (build-new-segments egress-ids task->group-by-fn flow-conditions)
              (write-batch pipeline)
              (flow-retry-segments replica state messenger monitoring)


rename state -> session

rename state -> session

--- src/org/timmc/heim_logger/v2.clj
+++ src/org/timmc/heim_logger/v2.clj
@@ -5,17 +5,17 @@
             [org.timmc.heim-logger.common :as cm]))

 (defn send-msg
-  [state msg]
-  (ws/send-msg @(:socket @state)
+  [session msg]
+  (ws/send-msg @(:socket @session)
                (json/generate-string msg)))

 (defn on-connect
-  [state session]
-  (send-msg state {:type "nick"
-                   :data {:name "hillbot v2"}}))
+  [session _jetty-ws-session]
+  (send-msg session {:type "nick"
+                     :data {:name "hillbot v2"}}))

 (defn on-receive
-  [state raw]
+  [session raw]
   (let [msg (try
               (json/parse-string raw true)
               (catch Throwable t
@@ -23,9 +23,11 @@
                 (throw t)))
         mtype (:type msg)
         data (:data msg)]
+    (when-let [error (:error msg)]
+      (println msg))
     (case mtype
       "ping-event"
-      (send-msg state
+      (send-msg session
                 {:type "ping-reply",
                  :data {:time (:time data)}})

@@ -43,25 +45,25 @@

       "nick-event"
       (println "NICK" (:from data) "->" (:to data))
-
+
       ;; :else
       (println "received" mtype))))

-(defn test-gniazdo
-  []
-  (let [state (atom {:session nil
-                     :socket (promise)})
+(defn connect
+  "Connect to a room and yield a session."
+  [room]
+  (let [session (atom {:socket (promise)})
         socket (ws/connect
-                (cm/address "euphoria.io" "space")
-                :on-connect (partial on-connect state)
-                :on-receive (partial on-receive state))]
+                (cm/address "euphoria.io" room)
+                :on-connect (partial on-connect session)
+                :on-receive (partial on-receive session))]
     ;; This is how we tie the asynchronous knot: Block any use of the
     ;; socket until we have time to set it! (Otherwise there's a race
     ;; condition where we might want to send a reply before reaching
     ;; this line -- would require a fast connection and a long context
     ;; switch or GC pause, of course.)
-    (deliver (:socket @state) socket)
-    state))
+    (deliver (:socket @session) socket)
+    session))

 ;; --


[Fix #121] Include cognitect artifacts

[Fix #121] Include cognitect artifacts

--- src/refactor_nrepl/artifacts.clj
+++ src/refactor_nrepl/artifacts.clj
@@ -36,19 +36,23 @@
         (neg? (- millis-per-day (- last-modified (.getTime (java.util.Date.)))))
         true)))

-(defn- get-all-clj-artifacts!
+(defn- get-mvn-artifacts!
   "All the artifacts under org.clojure in mvn central"
-  []
-  (let [search-url "http://search.maven.org/solrsearch/select?q=g:%22org.clojure%22+AND+p:%22jar%22&rows=2000&wt=json"
+  [group-id]
+  (let [search-prefix "http://search.maven.org/solrsearch/select?q=g:%22"
+        search-suffix "%22+AND+p:%22jar%22&rows=2000&wt=json"
+        search-url (str search-prefix group-id search-suffix)
         {:keys [_ _ body _]} @(http/get search-url {:as :text})
         search-result (json/parse-string body true)]
     (map :a (-> search-result :response :docs))))

 (defn- get-versions!
   "Gets all the versions from an artifact belonging to the org.clojure."
-  [artifact]
-  (let [{:keys [_ _ body _]} @(http/get (str "http://search.maven.org/solrsearch/select?"
-                                             "q=g:%22org.clojure%22+AND+a:%22"
+  [group-id artifact]
+  (let [search-prefix "http://search.maven.org/solrsearch/select?q=g:%22"
+        {:keys [_ _ body _]} @(http/get (str search-prefix
+                                             group-id
+                                             "%22+AND+a:%22"
                                              artifact
                                              "%22&core=gav&rows=200&wt=json")
                                         {:as :text})]
@@ -58,24 +62,26 @@
          (map :v)
          doall)))

-(defn- collate-artifact-and-versions [artifact]
+(defn- collate-artifact-and-versions [group-id artifact]
   (->> artifact
-       get-versions!
-       (vector (str "org.clojure/" artifact))))
+       (get-versions! group-id)
+       (vector (str group-id "/" artifact))))

 (defn- add-artifact [[artifact versions]]
   (swap! artifacts update-in [artifact] (constantly versions)))

-(defn- add-artifacts [artifacts]
+(defn- add-artifacts [group-id artifacts]
   (->> artifacts
        (partition-all 2)
        (map #(future (->> %
-                          (map collate-artifact-and-versions)
+                          (map (partial collate-artifact-and-versions group-id))
                           (map add-artifact)
                           dorun)))))

 (defn- get-artifacts-from-mvn-central! []
-  (add-artifacts (get-all-clj-artifacts!)))
+  (let [group-ids #{"com.cognitect" "org.clojure"}]
+    (mapcat (fn [group-id] (add-artifacts group-id (get-mvn-artifacts! group-id)))
+            group-ids)))

 (defn- update-artifact-cache! []
   (let [mvn-central-futures (get-artifacts-from-mvn-central!)


check uploader-id on hash progress

check uploader-id on hash progress

--- src/server/client-interface.cljs
+++ src/server/client-interface.cljs
@@ -329,7 +329,15 @@
           (.emit socket "start-hashing" client-id upload-id)))))

   (s/defevent "hash-progress" [id filename current-chunk chunks] [user-id room-id]
-    (.emit (.to io room-id) "hash-progress" id filename current-chunk chunks))
+    (rooms/get-uploader-id id
+      (fn [uploader-id]
+        (if (= uploader-id user-id)
+          (.emit (.to io room-id)
+                 "hash-progress"
+                 id
+                 filename
+                 current-chunk
+                 chunks)))))

   (s/defevent "check-hash" [id file-hash] [user-id room-id]
     (println (.-id socket) "sent hash:" file-hash)


CMR-4058: Fix a bug unrelated to this ticket but related to one of the tests in           collection_keyword_search_test.clj

--- system-int-test/src/cmr/system_int_test/data2/umm_spec_collection.clj
+++ system-int-test/src/cmr/system_int_test/data2/umm_spec_collection.clj
@@ -181,14 +181,14 @@
   ([first-name last-name email]
    (contact-person first-name last-name email "dummy"))
   ([first-name last-name email role]
-   (let [contacts (when email
-                    [(umm-cmn/map->ContactInformationType
-                       {:ContactMechanisms [(umm-cmn/map->ContactMechanismType
-                                              {:Type :email
-                                               :Value email})]})])]
+   (let [contact-info (when email
+                        (umm-cmn/map->ContactInformationType
+                          {:ContactMechanisms [(umm-cmn/map->ContactMechanismType
+                                                 {:Type "Email"
+                                                  :Value email})]}))]
      (umm-cmn/map->ContactPersonType {:FirstName first-name
                                       :LastName last-name
-                                      :ContactInformation contacts
+                                      :ContactInformation contact-info
                                       :Roles [role]}))))

 ;; Used for testing warnings when reqired properties are missing.


Formatting

Formatting

--- src/cylon/oauth/client.clj
+++ src/cylon/oauth/client.clj
@@ -1,6 +1,6 @@
 (ns cylon.oauth.client
-  (:require [clojure.tools.logging :refer :all])
-)
+  (:require
+   [clojure.tools.logging :refer :all]))

 ;; I don't think this is a wonderful name but until we can think of
 ;; something better :)


put license templates under correct key

put license templates under correct key

--- ssclj/jar/src/main/clojure/com/sixsq/slipstream/ssclj/resources/license_template.clj
+++ ssclj/jar/src/main/clojure/com/sixsq/slipstream/ssclj/resources/license_template.clj
@@ -8,7 +8,7 @@
     [com.sixsq.slipstream.ssclj.resources.common.utils :as u]
     [com.sixsq.slipstream.ssclj.resources.common.authz :as a]))

-(def ^:const resource-tag :licenses)
+(def ^:const resource-tag :licenseTemplate)

 (def ^:const resource-name "LicenseTemplate")


CMR-5848 require cleanup.

CMR-5848 require cleanup.

--- system-int-test/test/cmr/system_int_test/ingest/provider_cmr_only_client_id_test.clj
+++ system-int-test/test/cmr/system_int_test/ingest/provider_cmr_only_client_id_test.clj
@@ -5,7 +5,6 @@
     [cmr.system-int-test.data2.core :as d]
     [cmr.system-int-test.data2.granule :as dg]
     [cmr.system-int-test.data2.umm-spec-collection :as data-umm-c]
-    [cmr.system-int-test.data2.umm-spec-common :as data-umm-cmn]
     [cmr.system-int-test.utils.index-util :as index]
     [cmr.system-int-test.utils.ingest-util :as ingest]
     [cmr.system-int-test.utils.search-util :as search]


Fix source/resource paths.

Fix source/resource paths.

--- project/analyze-data/build.boot
+++ project/analyze-data/build.boot
@@ -1,7 +1,8 @@
 ; vi: ft=clojure

 (set-env!
-  :resource-paths #{"src", "test"}
+  :source-paths #{"src", "test"}
+  :resource-paths #{"resources"}
   :dependencies '[[org.clojure/clojure "1.8.0"]
                   [org.clojure/data.csv "0.1.3"]
                   [incanter "1.9.0"]


no need to wrap in anon fn.

no need to wrap in anon fn.

--- test/async/http/client/test.clj
+++ test/async/http/client/test.clj
@@ -113,7 +113,7 @@
   (let [resp (GET "http://localhost:8080/")
         headers (@resp :headers)
         body (@resp :body)]
-    (is (= "
Hello WWW!
\n" (apply str (map #(char %) body))))
+    (is (= "
Hello WWW!
\n" (apply str (map char body))))
     (is (not (empty? body)))
     (if (contains? headers :content-length)
       (is (= (count body) (:content-length headers))))))


remove tests against removed functions

remove tests against removed functions

--- test/doctopus/template_test.clj
+++ test/doctopus/template_test.clj
@@ -6,18 +6,6 @@
             [net.cgrand.enlive-html :as enlive]))

 (deftest template
-  (testing "make-anchor makes an anchor element"
-    (is (= (#'doctopus.template/make-anchor "/" "test") [:a {:href "/"} "test"])))
   (testing "add-frame injects an iframe in the body element"
     (is (not (nil? (re-find #"\\\"
-                            (add-frame ""))))))
-  (testing "head-li creates a list item with a head link"
-    (is (= (#'doctopus.template/head-li (map->Tentacle {:name "cat"}))
-           (enlive/html [:li [:a {:href "/heads/cat"} "cat"]]))))
-  (testing "head-li creates a list item with a head link"
-    (is (= (#'doctopus.template/head-option (map->Tentacle {:name "cat"}))
-           (enlive/html [:option {:value "cat"} "cat"]))))
-  (testing "tentacle-li creates a list item with a tentacle link"
-    (is (= (#'doctopus.template/tentacle-li
-            (map->Tentacle {:name "cat" :entry-point "index.html"}))
-             (enlive/html [:li [:a {:href "/docs/cat/index.html"} "cat"]])))))
+                            (add-frame "")))))))


Fix JSON API tests

Fix JSON API tests

--- test/metabase/api/card_test.clj
+++ test/metabase/api/card_test.clj
@@ -349,7 +349,7 @@
   (do-with-temp-native-card
     (fn [database-id card]
       (perms/grant-native-read-permissions! (perms-group/all-users) database-id)
-      ((user->client :rasta) :get 200 (format "card/%d/json" (u/get-id card))))))
+      ((user->client :rasta) :post 200 (format "card/%d/query/json" (u/get-id card))))))

 ;;; Test GET /api/card/:id/query/csv & GET /api/card/:id/json **WITH PARAMETERS**
@@ -385,4 +385,4 @@
   [{(keyword "COUNT(*)") 8}]
   (do-with-temp-native-card-with-params
     (fn [database-id card]
-      ((user->client :rasta) :get 200 (format "card/%d/json?parameters=%s" (u/get-id card) encoded-params)))))
+      ((user->client :rasta) :post 200 (format "card/%d/query/json?parameters=%s" (u/get-id card) encoded-params)))))


Task IDs are no longer returned through submit-job.

--- test/onyx/plugin/input_test.clj
+++ test/onyx/plugin/input_test.clj
@@ -185,10 +185,10 @@

   (let [job-info-offset (submit-and-wait catalog-http-q&map&idx)]
     (def res-multi (take-segments! out-chan 5000))
-    (def task-chunk-offset (extensions/read-chunk (:log env) :chunk (get-in job-info-offset [:task-ids :read-messages :id]))))
+    (def task-chunk-offset (extensions/read-chunk (:log env) :chunk :read-messages)))

   (let [job-info-restart (submit-and-wait (update-in catalog-http-q&map&idx [0] assoc :elasticsearch/restart-on-fail true))]
-    (def task-chunk-restart (extensions/read-chunk (:log env) :chunk (get-in job-info-restart [:task-ids :read-messages :id]))))
+    (def task-chunk-restart (extensions/read-chunk (:log env) :chunk :read-messages)))

   (def res-multi-fail (run-job catalog-http-q&map&idx lifecycles-fail))


[#13068] No error "Profile not found" if entering invalid public key in New chat field

Signed-off-by: andrey <b713972e59b8e606e23253c4a13e948139fea4d1@gmail.com>

--- src/status_im/add_new/core.cljs
+++ src/status_im/add_new/core.cljs
@@ -27,10 +27,8 @@
 (fx/defn new-chat-set-new-identity
   {:events [:new-chat/set-new-identity]}
   [{db :db} new-identity-raw new-ens-name id]
-  (let [new-identity (utils/safe-trim new-identity-raw)
-        ens-error (and (= new-identity-raw "0x") (not (string/blank? new-ens-name)))]
-    (when (and (or (not id) (= id @resolve-last-id))
-               (or ens-error (> (count new-identity) 4)))
+  (let [ens-error (and (= new-identity-raw "0x") (not (string/blank? new-ens-name)))]
+    (when (or (not id) (= id @resolve-last-id))
       (if ens-error
         {:db (assoc-in db [:contacts/new-identity :state] :error)}
         (let [new-identity (utils/safe-trim new-identity-raw)


added naive 'connect' feature

added naive 'connect' feature

--- src/etcd_clojure/core.clj
+++ src/etcd_clojure/core.clj
@@ -1,14 +1,25 @@
 (ns etcd-clojure.core)
 (:require '[clj-http.client :as client])

+(def endpoint (atom "http://127.0.0.1:4001"))
+
+(def api-version "v1")
+
+(defn connect!
+  [etcd-server-uri]
+  (reset! endpoint etcd-server-uri))
+
+(def base-url
+  (str @endpoint "/" api-version))
+
 (defn set
   [key value]
-  (client/put (str "http://127.0.0.1:4001/v1/keys/" key "?value=" value)))
+  (client/put (str base-url "/keys/" key "?value=" value)))

 (defn get
   [key]
-  (client/get (str "http://127.0.0.1:4001/v1/keys/" key)))
+  (client/get (str base-url "/keys/" key)))

 (defn delete
   [key]
-  (client/delete (str "http://127.0.0.1:4001/v1/keys/" key)))
+  (client/delete (str base-url "/keys/" key)))


Sort RuuviTag observations in observation data fetch

--- src/env_logger/handler.clj
+++ src/env_logger/handler.clj
@@ -144,13 +144,15 @@
     response-unauthorized
     (let [data (first (filter #(not (nil? (:fmi_temperature %)))
                               (reverse (db/get-obs-days db/postgres 1))))
-          rt-data (take (count (get-conf-value :ruuvitag-locations))
-                        (reverse (db/get-ruuvitag-obs
-                                  db/postgres
-                                  (t/minus (t/local-date-time)
-                                           (t/minutes 45))
-                                  (t/local-date-time)
-                                  (get-conf-value :ruuvitag-locations))))]
+          rt-data (sort-by :location
+                           (take (count (get-conf-value :ruuvitag-locations))
+                                 (reverse (db/get-ruuvitag-obs
+                                           db/postgres
+                                           (t/minus (t/local-date-time)
+                                                    (t/minutes 45))
+                                           (t/local-date-time)
+                                           (get-conf-value
+                                            :ruuvitag-locations)))))]
       {:status 200
        :body {:data (assoc data :recorded
                            (convert-epoch-ms-to-string (:recorded data)))


update resolve-fn to support arguments

update resolve-fn to support arguments

--- src/graphql_clj/parser.clj
+++ src/graphql_clj/parser.clj
@@ -106,6 +106,13 @@
     (log/debug "get-selection-object-name: name: " name)
     name))

+(defn get-selection-arguments
+  [selection]
+  (log/debug "get-selection-arguments: " selection)
+  (let [arguments (get-in (second selection) [:field :arguments])]
+    (log/debug "get-selection-arguments: arguments: " arguments)
+    arguments))
+
 (defn get-selection-name
   [selection]
   (log/debug "get-selection-name: " selection)
@@ -151,6 +158,12 @@
   :LIST
   :NOT_NULL)

+(defn default-resolve-fn
+  [field-name]
+  (fn [& args]
+    (let [parent (first args)]
+      (get parent (keyword field-name)))))
+
 (def type-map
   {:GraphQLString {:name "String"
                    :kind :SCALAR}
@@ -158,21 +171,37 @@
               :kind :OBJECT
               :fields {:id {:type :GraphQLString}
                        :name {:type :GraphQLString}
-                       :profilePic {:type :GraphQLString}}
+                       :profilePic {:type :ProfilePicType}}
               :args {}
-              :resolve-fn (fn [object]
-                            (log/debug "user resolve-fn: ")
-                            {:id "test"
-                             :name "good"
-                             :additional "extra"})}})
+              :resolve-fn (fn [& args]
+                            (let [parent (first args)]
+                              (log/debug "user resolve-fn: ")
+                              (log/debug "user resolve-fn: parent: " parent)
+                              {:id "test"
+                               :name "good"
+                               :additional "extra"}))}
+   :ProfilePicType {:name "ProfilePic"
+                    :kind :OBJECT
+                    :fields {:resolution {:type :GraphQLString}
+                             :url {:type :GraphQLString}}
+                    :args {}
+                    :resolve-fn (fn [& args]
+                                  (let [parent (first args)
+                                        arguments (second args)]
+                                    (log/debug "profile pic resolve-fn.")
+                                    (log/debug "profile pic parent: " parent)
+                                    (log/debug "profile pic arguments: " arguments)
+                                    {:resolution "480"
+                                     :url "http://test.url.com"}))}})

 (def schema
   {:query {:name "Query"
            :kind :OBJECT
            :fields {:user {:type :UserType}}
-           :resolve-fn (fn [obj]
-                         (log/debug "query resolve-fn:" obj)
-                         (identity obj))}})
+           :resolve-fn (fn [& args]
+                         (let [parent (first args)]
+                           (log/debug "query resolve-fn:" parent)
+                           (identity parent)))}})

 (defn get-type-meta
   [type-key]
@@ -210,14 +239,18 @@
 (defn resolve-field-on-object
   "FIXME"
   [parent-object field-type field-entry]
-  (let [object-name (get-selection-object-name field-entry)
+  (let [field-name (get-selection-object-name field-entry)
+        arguments (get-selection-arguments field-entry)
         resolve-fn (or (:resolve-fn field-type)
-                       (fn default-resolve-fn [parent-object]
-                         (get parent-object (keyword object-name))))]
+                       (default-resolve-fn field-name))]
     (log/spy field-type)
+    (log/spy field-entry)
     (log/spy resolve-fn)
     (log/spy parent-object)
-    (log/spy (resolve-fn parent-object))))
+    (log/spy arguments)
+    (if arguments
+      (log/spy (resolve-fn parent-object arguments))
+      (log/spy (resolve-fn parent-object)))))

 (defn merge-selection-sets
   [selections]
@@ -270,7 +303,7 @@
       (is-scalar-field-type? field-type) result
       (is-enum-field-type? field-type) result
       (is-object-field-type? field-type) (log/spy (execute-fields field-type result sub-selection-set))
-      :else (throw (ex-info (format "Not a valid field type %s." field-type) {:field-type field-type})))))
+      :else (throw (ex-info (format "Unhandled field type %s." field-type) {:field-type field-type})))))

 (defn get-field-entry [parent-type parent-object field]
   (log/debug "*** get-field-entry: " field)


Added some notes to the repl experience

Added some notes to the repl experience

--- src/honeysql_talk/repl.clj
+++ src/honeysql_talk/repl.clj
@@ -4,10 +4,12 @@
             [com.stuartsierra.component :as component]
             [clj-time.core :as t]
             clj-time.jdbc
+            [clojure.java.jdbc :refer [query execute!]]
             [honeysql.core :refer [call format raw]]
             [honeysql.helpers :refer :all]
             [honeysql-talk.extra :refer :all]))

+;; this is setup for the docker instructions in this project's README.md
 (def db (-> (new-postgres-database {:classname "org.postgresql.Driver"
                                     :subprotocol "postgresql"
                                     :subname "//127.0.0.1:5432/exercises"
@@ -17,9 +19,13 @@

 (comment

+  ;; using HoneySQL
   (query-runner db (-> (select :*)
                        (from :cd.members)
                        (limit 1)))

+  ;; using SQL
+  (query db ["SELECT * FROM cd.members LIMIT 1"])
+
   )