added repack-post

added repack-post

this function reconsolidates the entire data map given by reddit to
retain only fields that are needed. to reduce the amount of space used
in the client browser

--- src/saved_for_reddit/core.cljs
+++ src/saved_for_reddit/core.cljs
@@ -28,6 +28,8 @@
                               :saved-for-reddit-app-state))

 (def saved-posts (r/atom []))
+(def subreddits (r/atom {}))
+
 (def error-msg (r/atom ""))

 (defn set-app-state-field [field value]
@@ -45,6 +47,18 @@
   (swap! error-msg #(str error))
   (r/render-component [error-html] (dommy/sel1 :#error)))

+(defn repack-post [p]
+  (let [link? (nil? (:title p))
+        key (str (:name p) (:subreddit_id p) (:link_id p))
+        title (unescapeEntities (if link? (:link_title p) (:title p)))
+        url (if link? (str (:link_url p) key) (:url p))
+        body (if (not (nil? (:body_html p))) (unescapeEntities (:body_html p)))
+        subreddit (:subreddit p)
+        author (:author p)
+        permalink (if link? (:link_url p) (str "https://www.reddit.com" (:permalink p)))
+        created-on-epoch-local (+ (:created_utc p) (* 3600 (.getTimezoneOffset (js/Date.))))
+        created-on-str (timef/unparse time-formatter (timec/from-long (* 1000 created-on-epoch-local)))]
+    {:link link? :key key :title title :url url :body body :subreddit subreddit :author author :permalink permalink :created-on created-on-str}))

 (defn get-saved-posts [& after]
   (let [saved-post-get-chan (if (nil? after)
@@ -69,23 +83,22 @@
                 (set! (.-disabled (dommy/sel1 :#btn-get-posts)) true))
               (doseq [p posts]
                 #_(println (process-json-post p))
-                (swap! saved-posts #(conj % %2) (assoc (:data p) :key (str (-> p :data :name) (-> p :data :subreddit_id) (-> p :data :link_id))))))
+                (swap! saved-posts #(conj % %2) (repack-post (:data p)))))
             (handle-error (str error " " (:error-text response) "\nYour API token might've expired")))))))

 (defn loggedin-html []
   [:p {:class "navbar-text navbar-right"} "Logged in as " (:username @app-state)])

 (defn post-html [p]
-  (let [link? (nil? (:title p))
+  (let [link? (:link p)
         key (:key p)
-        title (unescapeEntities (if link? (:link_title p) (:title p)))
-        url (if link? (str (:link_url p) key) (:url p))
-        body (if (not (nil? (:body_html p))) (unescapeEntities (:body_html p)))
+        title (:title p)
+        url (:url p)
+        body (:body p)
         subreddit (:subreddit p)
         author (:author p)
-        permalink (if link? (:link_url p) (str "https://www.reddit.com" (:permalink p)))
-        created-on-epoch-local (+ (:created_utc p) (* 3600 (.getTimezoneOffset (js/Date.))))
-        created-on-str (timef/unparse time-formatter (timec/from-long (* 1000 created-on-epoch-local)))]
+        permalink (:permalink p)
+        created-on-str (:created-on p)]
     [:div {:class "panel panel-default"}
      [:div {:class "panel-heading"}
       [:h4 {:class "panel-title"}
@@ -101,7 +114,7 @@
        [:button {:type "button" :class "btn btn-default"} "Unsave"]]]]))

 (defn main-html [posts]
-  [:div {:class "col-md-12"}
+  [:div {:class "col-md-10"}
    [:h4 "Saved Posts"]
    [:div {:class "list-group"}
     (for [p @posts]


Add details to doc about explicitly changing the logging implementation.

--- src/main/clojure/clojure/tools/logging.clj
+++ src/main/clojure/clojure/tools/logging.clj
@@ -13,7 +13,11 @@
 (ns ^{:author "Alex Taggart"
       :doc "Logging macros which delegate to a specific logging implementation. At
             runtime a specific implementation is selected from, in order, slf4j,
-            Apache commons-logging, log4j, and finally java.util.logging."}
+            Apache commons-logging, log4j, and finally java.util.logging.
+
+           The logging implementation can be expliticly determined by using
+           binding or alter-var-root to change the value of *logger-factory* to
+           another implementation of clojure.tools.logging.impl/LoggerFactory."}
   clojure.tools.logging
   [:use
    [clojure.string :only [trim-newline]]


pretty print output code

pretty print output code

--- src/cljs/wombats_web_client/components/simulator/output.cljs
+++ src/cljs/wombats_web_client/components/simulator/output.cljs
@@ -1,6 +1,10 @@
 (ns wombats-web-client.components.simulator.output
   (:require [reagent.core :as reagent]
             [re-frame.core :as re-frame]))
+
+(defn- format-code
+  [clj-object]
+  [:pre (.stringify js/JSON (clj->js clj-object) nil 2)])

 (defn render []
   (let [command (re-frame/subscribe [:simulator/player-command])
@@ -8,8 +12,8 @@
     [:div.output
      [:div.output-section
       [:h3.output-section-title "Command"]
-      (prn-str @command)]
+      (format-code @command)]

      [:div.output-section
       [:h3.output-section-title "State"]
-      (prn-str @player-state)]]))
+      (format-code @player-state)]]))


Integration with data store

Integration with data store

--- src/shurly/web.clj
+++ src/shurly/web.clj
@@ -5,17 +5,29 @@
             [clojure.java.io :as io]
             [ring.middleware.stacktrace :as trace]
             [ring.middleware.session :as session]
+            [ring.middleware.params :as params]
             [ring.middleware.session.cookie :as cookie]
             [ring.adapter.jetty :as jetty]
+            [shurly.data :as data]
             [environ.core :refer [env]]))

-(defroutes app
+(defroutes routes
   (GET "/" []
        {:status 200
         :headers {"Content-Type" "text/plain"}
         :body (slurp (io/resource "index.html"))})
+  (GET "/:slug" [slug]
+       {:status 301
+        :headers {"Location" (data/request-redirect! slug)}})
+  (POST "/shorten" [slug target]
+        (if (data/store-slug! slug target)
+          {:status 200}
+          {:status 404}))
   (ANY "*" []
        (route/not-found (slurp (io/resource "404.html")))))
+
+(def app (-> routes
+             params/wrap-params))

 (defn wrap-error-page [handler]
   (fn [req]


fsync queue before stop

fsync queue before stop

--- src/spq/server.clj
+++ src/spq/server.clj
@@ -209,7 +209,8 @@
     (time/in (conf :server :period-millis) #(periodic-task stop-periodic-task))
     (fn stop-fn []
       (reset! stop-periodic-task true)
-      (.close server))))
+      (.close server)
+      (dq/fsync queue))))

 (defn -main
   [port & confs]


elevio Refer to support module by name instead of ID

--- src-cljs/frontend/elevio.cljs
+++ src-cljs/frontend/elevio.cljs
@@ -40,7 +40,7 @@
         user-info (-> js/window
                       (aget "elevSettings")
                       (aget "user"))
-        support-module-id 2968
+        support-module-id "support"
         discuss-link-module-id 3003
         discuss-support-link-module-id 3762]
     (if user/support-eligible?


Don't clear other `:current-*-data` on nav either

We shouldn't need to. There's a risk we have stale project or org data
temporarily and show something odd until the right one loads, but
there's no good way around that for now and it'll go away when this data
fetching moves to Om Next. (Stale build data would be more obvious, but
we're able to filter that out of the state by matching the build data
against the build we expect to find there.)

--- src-cljs/frontend/parser.cljs
+++ src-cljs/frontend/parser.cljs
@@ -152,9 +152,7 @@
                                ;; replaced completely on each route change.
                                (update :legacy/state dissoc
                                        :navigation-point
-                                       :navigation-data
-                                       :current-org-data
-                                       :current-project-data)))
+                                       :navigation-data)))
              (analytics/track {:event-type :pageview
                                :navigation-point route
                                :subpage :default


Changed weird input type values in profile.cljs to 'text'

--- src-cljs/rmfu_ui/profile.cljs
+++ src-cljs/rmfu_ui/profile.cljs
@@ -9,10 +9,10 @@
     "Tell Us About Yourself"]
    [:div.col-lg-6
     [:input.form-control.pull-left
-     {:type "firstname", :placeholder "First Name", :value ""}]]
+     {:type "text", :placeholder "First Name", :value ""}]]
    [:div.col-lg-6
     [:input.form-control.pull-right
-     {:type "lastname", :placeholder "Last Name", :value ""}]]
+     {:type "text", :placeholder "Last Name", :value ""}]]
    [:br]
    [:br]
    [:div.dropdown.col-lg-3
@@ -95,7 +95,7 @@
     [:div.col-lg-10
      {:style {:padding-right 0}}
      [:input.form-control
-      {:type "zip", :placeholder "Enter Zip Code", :value ""}]]
+      {:type "text", :placeholder "Enter Zip Code", :value ""}]]
     [:select.c-select.col-lg-2
      [:option
       "Item 1"]
@@ -118,7 +118,7 @@
     "Topics of Interest"]
    [:div.input-group
     [:input.form-control
-     {:type "topics", :placeholder "Enter Keywords or select from suggestions below", :value ""}]
+     {:type "text", :placeholder "Enter Keywords or select from suggestions below", :value ""}]
     [:span.input-group-btn
      [:button.btn.btn-default
       {:type "button", :value "add"}


fix show-error fx

fix show-error fx

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

--- src/status_im/ui/screens/wallet/choose_recipient/events.cljs
+++ src/status_im/ui/screens/wallet/choose_recipient/events.cljs
@@ -78,7 +78,7 @@
        (if (ethereum/address? recipient)
          {:db       (assoc-in db [:wallet :send-transaction :to] recipient)
           :dispatch [:navigate-back]}
-         {:show-error (i18n/label :t/wallet-invalid-address {:data recipient})})))))
+         {:ui/show-error (i18n/label :t/wallet-invalid-address {:data recipient})})))))

 (handlers/register-handler-fx
  :wallet/fill-request-from-url


s /:synsem :pred/ /:synsem :sem :pred/

s /:synsem :pred/ /:synsem :sem :pred/

--- src/babel/espanol/lexicon.clj
+++ src/babel/espanol/lexicon.clj
@@ -225,9 +225,9 @@
                                      :3plur "dicen"}
                            :preterito-stem "dij"}}]
             [(unify common
-                    {:synsem {:pred :say}})
+                    {:synsem {:sem {:pred :say}}})
              (unify common
-                    {:synsem {:pred :tell}})])
+                    {:synsem {:sem {:pred :tell}}})])

    "dejar" {:synsem {:cat :verb
                      :sem {:pred :leave-behind}}}
@@ -439,9 +439,9 @@
                                        :2plur "hicisteis"
                                        :3plur "hicieron"}}}]
      [(unify common
-             {:synsem {:pred :do}})
+             {:synsem {:sem {:pred :do}}})
       (unify common
-             {:synsem {:pred :make}})])
+             {:synsem {:sem {:pred :make}}})])

    "hervir" {:espanol {:boot-stem "hierv"}
              :synsem {:cat :verb
@@ -558,9 +558,9 @@
    "llevar" (let [shared-part-of-llevar
                   {:synsem {:cat :verb}}]
               [(unify shared-part-of-llevar
-                      {:synsem {:pred :carry}})
+                      {:synsem {:sem {:pred :carry}}})
                (unify shared-part-of-llevar
-                      {:synsem {:pred :bring}})])
+                      {:synsem {:sem {:pred :bring}}})])

    "me" {:synsem {:cat :noun
                   :pronoun true
@@ -658,11 +658,11 @@
                     :pret-stem "pud"}
           :synsem {:cat :verb}}]
      [(unify shared-part-of-poder
-             {:synsem {:pred :can}})
+             {:synsem {:sem {:pred :can}}})
       (unify shared-part-of-poder
-             {:synsem {:pred :may}})
+             {:synsem {:sem {:pred :may}}})
       (unify shared-part-of-poder
-             {:synsem {:pred :be-able-to}})])
+             {:synsem {:sem {:pred :be-able-to}}})])

    "poner" {:espanol {:future-stem "pondr"
                    :present {:1sing "tengo"
@@ -695,9 +695,9 @@
                              :preterito-stem "quis"
                              :futuro-stem "querr"}}]
               [(unify shared-part-of-querer
-                      {:synsem {:pred :want}})
+                      {:synsem {:sem {:pred :want}}})
                (unify shared-part-of-querer
-                      {:synsem {:pred :love}})])
+                      {:synsem {:sem {:pred :love}}})])

    "se"
    [;; 3rd singular or plural: 'él,ellas,..etc'


french-specific enrich function

french-specific enrich function

--- src/babel/francais/writer.clj
+++ src/babel/francais/writer.clj
@@ -3,7 +3,6 @@

 (require '[babel.cache :refer [create-index]])
 (require '[babel.english.writer :as en])
-(require '[babel.enrich :refer [enrich]])
 (require '[babel.forest :as forest])
 (require '[babel.francais.grammar :refer [grammar]])
 (require '[babel.francais.lexicon :refer [lexicon-source]])
@@ -17,6 +16,8 @@
 (require '[clojure.string :as string])
 (require '[clojure.tools.logging :as log])
 (require '[dag-unify.core :refer (fail? get-in strip-refs)])
+
+(declare enrich)

 ;; see TODOs in lexiconfn/compile-lex (should be more of a pipeline
 ;; as opposed to a argument-position-sensitive function.
@@ -125,4 +126,32 @@
                                  (get root-verbs key))
                                (sort (keys root-verbs)))))))))

+(declare against-pred)
+(declare matching-head-lexemes)
+(defn enrich [spec lexicon]
+  (against-pred spec lexicon))

+(defn against-pred [spec lexicon]
+  (let [pred (get-in spec [:synsem :sem :pred] :top)]
+    (if (= :top pred)
+      spec
+      (mapcat (fn [lexeme]
+                (let [result (unify spec
+                                    {:synsem {:sem (strip-refs (get-in lexeme [:synsem :sem] :top))}})]
+                  (if (not (fail? result))
+                    (do
+                      (log/debug (str "matched head lexeme: " (strip-refs lexeme)))
+                      (list result)))))
+              (matching-head-lexemes spec lexicon)))))
+
+(defn matching-head-lexemes [spec lexicon]
+  (let [pred-of-head (get-in spec [:synsem :sem :pred] :top)]
+    (if (= pred-of-head :top)
+      spec
+      (mapcat (fn [lexemes]
+                (mapcat (fn [lexeme]
+                          (if (= pred-of-head
+                                 (get-in lexeme [:synsem :sem :pred] :top))
+                            (list lexeme)))
+                        lexemes))
+              (vals lexicon)))))


making it non lazy in order to make friend current user info to be in perm call context

--- src/celestial/api/systems.clj
+++ src/celestial/api/systems.clj
@@ -62,10 +62,9 @@
   {:pre [(> from -1) (if type (p/type-exists! type) true)]}
   (let [systems (if type (p/get-system-index :type type) (into [] (p/all-systems)))
         to* (min to (count systems))]
-    (println to* (contains? systems to*))
     (when-not (empty? systems)
       (if (and (contains? systems from) (contains? systems (- to* 1)))
-        {:meta {:total (count systems)} :systems (map (juxt identity p/get-system) (subvec systems from to*))}
+        {:meta {:total (count systems)} :systems (doall (map (juxt identity p/get-system) (subvec systems from to*)))}
         (throw+ {:type ::non-legal-range :message (<<  "No legal systems in range ~{from}:~{to*} try between ~{0}:~(count systems)")})))))

 (defroutes- systems {:path "/systems" :description "Operations on Systems"}


don't include storage in ex-info

don't include storage in ex-info

--- src/clj/clj_money/trading.clj
+++ src/clj/clj_money/trading.clj
@@ -379,7 +379,7 @@
           adj-context
           (recur adj-context shares-to-be-sold)))
       (throw (ex-info "Unable to find a lot to sell the shares"
-                      {:context context})))))
+                      {:context (dissoc context :storage)})))))

 (def ^:private sale-coercion-rules
   (concat purchase-coercion-rules


As of Firefox 43, we are using longer revision identifiers.

Update the regex to match the new identifiers properly.

--- src/clj/medusa/changesets.clj
+++ src/clj/medusa/changesets.clj
@@ -46,7 +46,7 @@
     (assert (= (count text-file-links) 1) "Could not find revision ID text file")
     (let [revision-file-url (str build-dir-url (:href (second (first text-file-links))))
           revision-file (:body (client/get revision-file-url))
-          revision (re-find #"https:\/\/hg\.mozilla.*([0-9a-f]{12})$" revision-file)]
+          revision (re-find #"https:\/\/hg\.mozilla.*rev/([0-9a-f]+)$" revision-file)]
       (second revision))))

 (defn- find-build-revision


minor mistake

minor mistake

--- src/clj/shadow/cljs/build.clj
+++ src/clj/shadow/cljs/build.clj
@@ -377,7 +377,7 @@
           ;; merge resource data & return it
           ;; FIXME: lost source-map data at this point, assuming it exist when out-js exists
           (-> (merge rc cache-data)
-              (dissoc cache-data :analysis :version)
+              (dissoc :analysis :version)
               (assoc :js-source (slurp target-js))))))))

 (defn write-cached-cljs-resource


Corrected type hinting.

Corrected type hinting.

--- src/clj/think/image/pixel.clj
+++ src/clj/think/image/pixel.clj
@@ -14,7 +14,7 @@
 (defonce g-shift (int 8))
 (defonce b-shift (int 0))

-(defn color-int-to-unpacked ^Integer [^Integer px ^Integer shift-amount]
+(defn color-int-to-unpacked ^long [^Integer px ^Integer shift-amount]
   (int (bit-and 0xFF (bit-shift-right px shift-amount))))

 (defn color-unpacked-to-int ^Integer [^Integer bt ^Integer shift-amount]


routing to login if no token

routing to login if no token

--- src/cljs/swarmpit/router.cljs
+++ src/cljs/swarmpit/router.cljs
@@ -1,13 +1,16 @@
 (ns swarmpit.router
   (:require [bidi.router :as br]
             [swarmpit.routes :as routes]
+            [swarmpit.storage :as storage]
             [swarmpit.controller :as controller]))

 (defonce location (atom nil))

 (defn- on-navigate
   [location]
-  (controller/dispatch location))
+  (if (nil? (storage/get "token"))
+    (controller/dispatch {:handler :login})
+    (controller/dispatch location)))

 (defn start
   []


Forgot to commit the client apparently

Forgot to commit the client apparently

--- src/clojure/picard/client.clj
+++ src/clojure/picard/client.clj
@@ -34,43 +34,9 @@
   [[hdrs]]
   (not= "close" (hdrs "connection")))

-;; (defn- handling-initial-request
-;;   [_ _ _ _]
-;;   (throw (Exception. "Bro, I thought I told you to chill out")))
-
-;; (defn- incoming-request
-;;   [state evt [hdrs body :as val] args]
-;;   (when-not (= :request evt)
-;;     (throw (Exception. "Picard is confused... requests start with the head.")))
-
-;;   ;; First, raise an exception if any further events are received
-;;   (swap! state (fn [[_ args]] [handling-initial-request args]))
-
-;;   (let [resp (args :resp) pool (args :pool) host (hdrs "host")]
-;;     ;; Acquire a channel from the pool
-;;     (pool/checkout-conn
-;;      pool host
-;;      (netty-bridge state resp)
-;;      (fn [ch]
-;;        ;; TODO - handle the error case
-;;        (netty/on-complete
-;;         (.write ch (req->netty-req val))
-;;         (fn [_]
-;;           (let [[_ {placeholder :ch}] @state]
-;;             (swap! state (fn [[f args]] [f (assoc args :ch ch)]))
-;;             ;; When the request is chunked and we sent a pause
-;;             ;; event downstream
-;;             (when (and (= :pending placeholder) (chunked? val))
-;;               (resp :resume nil)))))))
-
-;;     ;; If the body is chunked, then mark the request as paused
-;;     ;; until a channel has been acquired.
-;;     (when (chunked? val)
-;;       (locking val
-;;         (let [[_ {ch :ch}] @state]
-;;           (when-not ch
-;;             (swap! state (fn [f args] [f (assoc args :ch :pending)]))
-;;             (resp :pause nil)))))))
+(defn- addr-from-req
+  [[{host "host"}]]
+  [host 80])

 (defn- request-complete
   [_ evt _ _]
@@ -267,12 +233,203 @@
            ;; written, move the state of the exchange forward
            (fn [future] 1)))))))

+
+
+(defn- request-complete
+  [_ evt _ _]
+  (when-not (= :abort evt)
+   (throw (Exception. "The request is complete"))))
+
+(defn- finalize-request
+  [current-state]
+  (if (= request-complete (.next-up-fn current-state))
+    (if (.keepalive? current-state)
+      (pool/checkin-conn (.pool current-state) (.ch current-state))
+      (.close (.ch current-state)))))
+
+(defn- connection-pending
+  [_ _ _]
+  ;; Need to be able to handle abortiong
+  (throw (Exception. "The connection has not yet been established")))
+
+(defn- write-pending
+  [_ _ _]
+  ;; Need to be able to handle aborting
+  (throw (Exception. "The first write has not yet succeded")))
+
+(defn- response-pending
+  [_ _ _ _]
+  (throw (Exception. "Not implemented yet")))
+
+(defn- stream-or-finalize-request
+  [state evt val current-state]
+  (let [ch (.ch current-state)]
+    (if (= :done evt)
+      (do (.write ch HttpChunk/LAST_CHUNK)
+          (swap-then!
+           state
+           (fn [current-state]
+             (cond
+              (nil? (.next-dn-fn current-state))
+              (assoc current-state :next-up-fn request-complete)
+
+              :else
+              (assoc current-state :next-up-fn response-pending)))
+           finalize-request))
+      (.write ch (mk-netty-chunk val)))))
+
+(defn- stream-or-finalize-response
+  [state ^HttpChunk msg args]
+  (let [downstream-fn (.downstream args)
+        upstream-fn   (.upstream args)]
+    (if (.isLast msg)
+      (do (swap-then!
+           state
+           (fn [current-state]
+             (if (= response-pending (.next-up-fn current-state))
+               (assoc current-state
+                 :next-up-fn request-complete
+                 :next-dn-fn nil)
+               (assoc current-state
+                 :next-dn-fn nil)))
+           finalize-request)
+          (downstream-fn upstream-fn :done nil))
+      (downstream-fn upstream-fn :body (.getContent msg)))))
+
+(defn- initial-response
+  [state ^HttpResponse msg args]
+  (let [downstream-fn (.downstream args)
+        upstream-fn   (.upstream args)]
+    (swap-then!
+     state
+     (fn [current-state]
+       (let [keepalive? (and (.keepalive? current-state)
+                             (HttpHeaders/isKeepAlive msg))]
+         (cond
+          ;; If the response is chunked, then we need to
+          ;; stream the body through
+          (.isChunked msg)
+          (assoc current-state
+            :keepalive? keepalive?
+            :next-dn-fn stream-or-finalize-response)
+
+          ;; If the exchange is waiting for the response to complete then
+          ;; finish everything up
+          (= response-pending (.next-up-fn current-state))
+          (assoc current-state
+            :keepalive? keepalive?
+            :next-up-fn request-complete
+            :next-dn-fn nil)
+
+          ;; Otherwise, just mark the request as done
+          :else
+          (assoc current-state
+            :keepalive? keepalive?
+            :next-dn-fn nil))))
+     finalize-request)
+    (downstream-fn upstream-fn :respond (netty-resp->resp msg))))
+
+(defn- initial-write-succeeded
+  [state current-state]
+  (swap-then!
+   state
+   (fn [current-state]
+     (cond
+      ;; If the body is chunked, the next events will
+      ;; be the HTTP chunks
+      (.chunked? current-state)
+      (assoc current-state :next-up-fn stream-or-finalize-request)
+
+      ;; If the body is not chunked, then the request is
+      ;; finished. If the response has already been completed
+      ;; then we must finish up the request
+      (nil? (.next-dn-fn current-state))
+      (assoc current-state :next-up-fn request-complete)
+
+      ;; Otherwise, the exchange state is to be awaiting
+      ;; the response to complete.
+      :else
+      (assoc current-state :next-up-fn response-pending)))
+   finalize-request)
+  ;; The connected event is only sent downstream when the
+  ;; request body is marked as chunked because that's the
+  ;; only time that we really care. Also, there is somewhat
+  ;; of a race condition where the response could be sent
+  ;; upstream before this is called.
+  ;; TODO: This should be moved into the netty bridge so that
+  ;;       all downstream function calls happen on the same
+  ;;       thread.
+  (when (.chunked? current-state)
+    ((.downstream current-state) (.upstream current-state) :connected nil)))
+
+(defn- netty-bridge
+  [state]
+  (netty/upstream-stage
+   (fn [ch evt]
+     (let [current-state @state]
+       (cond-let
+        [msg (netty/message-event evt)]
+        ((.next-dn-fn current-state) state msg current-state)
+
+        [_ (netty/write-completion-event evt)]
+        (when (and (= write-pending (.next-up-fn current-state))
+                   (.. evt getFuture isSuccess))
+          (initial-write-succeeded state current-state))
+
+        [err (netty/exception-event evt)]
+        (do (.printStackTrace err)))))))
+
+(defn- mk-initial-state
+  [pool [_ body :as  req] downstream-fn]
+  (let [state       (atom nil)
+        upstream-fn (mk-upstream-fn state)]
+    (swap!
+     state
+     (fn [_] (State. pool               ;; The connection pool
+                    nil                ;; Netty channel
+                    (keepalive? req)   ;; Is the exchange keepalive?
+                    (= :chunked body)  ;; Is the request chunked?
+                    connection-pending ;; Next upstream event handler
+                    initial-response   ;; Next downstream event handler
+                    upstream-fn        ;; Upstream handler (external interface)
+                    downstream-fn)))   ;; Downstream handler (passed in)
+    [state upstream-fn]))
+
+;; Alias so that the pool namespace doesn't have to be required as
+;; well as the client namespace
+(def mk-pool pool/mk-pool)
+
+(defn- initial-request
+  [state evt val]
+  )
+
+;; TODO: Possibly have a mk-client function.
+(defn request
+  ([addr req downstream-fn]
+     (request (pool/mk-pool) addr req downstream-fn))
+  ([pool addr [_ body :as request] downstream-fn]
+     ;; Create an atom that contains the state of the request
+     (let [[state upstream-fn] (mk-initial-state pool request downstream-fn)]
+       ;; TODO: Handle cases where the channel returned is open but
+       ;;       writes to it will fail.
+       (pool/checkout-conn
+        pool addr (netty-bridge state)
+        ;; When a connection to the remote host has been established.
+        (fn [ch]
+          ;; Stash the channel in the state structure
+          (swap!
+           state
+           (fn [current-state]
+             (assoc current-state :ch ch :next-up-fn write-pending)))
+
+          ;; Write the request to the connection
+          (netty/on-complete
+           (.write ch (req->netty-req request))
+           ;; When the request has successfully been
+           ;; written, move the state of the exchange forward
+           (fn [future] 1)))))))
+
 (defn mk-proxy
   ([] (mk-proxy (pool/mk-pool)))
   ([pool]
-     ;; (fn [resp]
-     ;;   (let [state (atom [incoming-request {:pool pool :resp resp}])]
-     ;;     (fn [evt val]
-     ;;       (let [[next-fn args] @state]
-     ;;         (next-fn state evt val args)))))
      1))


Woops, forgot a variable rename

Woops, forgot a variable rename

--- src/clojure/picard/client.clj
+++ src/clojure/picard/client.clj
@@ -106,7 +106,7 @@
       (do (swap-then!
            state
            (fn [current-state]
-             (if (= response-pending (.next-up-fn current-state))
+             (if (= response-pending (.next-dn-fn current-state))
                (assoc current-state
                  :next-dn-fn request-complete
                  :next-up-fn nil)


Unify disconnecting channels and handling errors in the server

--- src/clojure/picard/server.clj
+++ src/clojure/picard/server.clj
@@ -300,17 +300,6 @@
           (catch Exception err
             (handle-err state err current-state)))))))

-(defn- handle-ch-disconnected
-  [state current-state]
-  (when-let [upstream (.upstream current-state)]
-    ;; Sometimes we call this function when we received errors
-    ;; from netty that we don't care to pass to the application.
-    ;; So, here we ensure that the channel actually gets closed.
-    (.close (.ch current-state))
-    (try (upstream :abort (Exception. "Connection reset by peer."))
-         (catch Exception _ nil))
-    (swap! state #(assoc % :next-dn-fn aborted-req))))
-
 (defn- netty-bridge
   [app opts]
   "Bridges the netty pipeline API to the picard API. This is done with
@@ -344,7 +333,8 @@
              (swap! state (fn [current-state] (assoc current-state :ch ch))))

            (= ch-state ChannelState/CONNECTED)
-           (handle-ch-disconnected state current-state))
+           (handle-err state (Exception. "Connection reset by peer")
+                       current-state))

           [err (netty/exception-event evt)]
           (when-not (instance? IOException err)


Updated function docstring

Updated function docstring

--- src/emender_jenkins/utils.clj
+++ src/emender_jenkins/utils.clj
@@ -14,7 +14,7 @@
     "Various utility function used by other modules.")

 (defn third
-    "Simple utility function - returns third item from a given sequence."
+    "Simple utility function - returns third item from a given sequence, nil if third item does not exist."
     [coll]
     (nth coll 2 nil))


Add missing license header on stream.channel ns.

--- src/futura/stream/channel.clj
+++ src/futura/stream/channel.clj
@@ -1,3 +1,27 @@
+;; Copyright (c) 2015 Andrey Antukh <niwi@niwi.nz>
+;; All rights reserved.
+;;
+;; Redistribution and use in source and binary forms, with or without
+;; modification, are permitted provided that the following conditions
+;; are met:
+;;
+;; 1. Redistributions of source code must retain the above copyright
+;;    notice, this list of conditions and the following disclaimer.
+;; 2. Redistributions in binary form must reproduce the above copyright
+;;    notice, this list of conditions and the following disclaimer in the
+;;    documentation and/or other materials provided with the distribution.
+;;
+;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+;; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+;; IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+;; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+;; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
 (ns futura.stream.channel
   (:require [futura.atomic :as atomic]
             [futura.stream.common :as common]


Restore basic movement

Restore basic movement

--- src/try_lwjgl/model/player.clj
+++ src/try_lwjgl/model/player.clj
@@ -24,6 +24,24 @@
     (.addRigidBody world phys-player)
     specs))

+(defn unit-movement [right? left? backward? forward? down? up?]
+  "Movement vector from origin position, origin rotation"
+  (let [x (+ (if right? -1 0) (if left? 1 0))
+        y (+ (if down? -1 0) (if up? 1 0))
+        z (+ (if backward? -1 0) (if forward? 1 0))
+        _ (println "x:" x ", y:" y ", z:" z)
+        v (let [v (math/jvec3f x y z)]
+            (when (not (= v (math/jvec3f 0 0 0))) (.normalize v))
+            [(.x v) (.y v) (.z v)])]
+    v))
+
+(defn rotate-vector [v angle]
+  (let [[x0 y0 z0] v
+        x (- (* x0 (Math/cos angle)) (* z0 (Math/sin angle)))
+        y y0
+        z (+ (* x0 (Math/sin angle)) (* z0 (Math/cos angle)))]
+    [x y z]))
+
 (defn movement [delta player]
   (let [forward?    (input/key-down? :w)
         backward?  (input/key-down? :s)
@@ -31,14 +49,11 @@
         right? (input/key-down? :d)
         up? (input/key-down? :space)
         down? (input/key-down? :lshift)
-        strife-normal (+ (if left? -1 0) (if right? 1 0))
-        forward-normal (+ (if backward? -1 0) (if forward? 1 0))
-        up-normal (+ (if up? 1 0) (if down? -1 0))
-        [pitch yaw roll] (map (fn [d] (Math/toRadians d)) (deref (:orientation player)))
-        fx (* strife-normal)
-        fy (* up-normal)
-        fz (* forward-normal)
-        [fx fy fz] (map (fn [v] (* v delta movement-force-factor)) [fx fy fz])
+        m-unit-vector (unit-movement right? left? backward? forward? down? up?)
+        orientation (map (fn [d] (Math/toRadians d)) (deref (:orientation player)))
+        [pitch yaw roll] orientation
+        [mx my mz] (rotate-vector m-unit-vector yaw)
+        [fx fy fz] (map (fn [v] (* v delta movement-force-factor)) [mx my mz])
         force (math/jvec3f fx fy fz)]
     ;; Move player phys
     (.applyDamping (:phys player) 0.5)


JC | #27 | Added logging for case when forgotten password email is not sent because user doesn't exist

--- src/stonecutter/controller/forgotten_password.clj
+++ src/stonecutter/controller/forgotten_password.clj
@@ -9,7 +9,8 @@
             [stonecutter.email :as email]
             [stonecutter.routes :as routes]
             [stonecutter.util.uuid :as uuid]
-            [stonecutter.db.user :as user]))
+            [stonecutter.db.user :as user]
+            [clojure.tools.logging :as log]))

 (defn request->forgotten-password-id [request]
   (get-in request [:params :forgotten-password-id]))
@@ -26,10 +27,11 @@
         request-with-validation-errors (assoc-in request [:context :errors] err)]
     (if (empty? err)
       (do
-        (when (user/retrieve-user user-store email-address)
+        (if (user/retrieve-user user-store email-address)
           (let [forgotten-password-id (uuid/uuid)]
             (cl-store/store! forgotten-password-store :forgotten-password-id {:forgotten-password-id forgotten-password-id :login email-address})
-            (email/send! email-sender :forgotten-password email-address {:app-name app-name :base-url base-url :forgotten-password-id forgotten-password-id})))
+            (email/send! email-sender :forgotten-password email-address {:app-name app-name :base-url base-url :forgotten-password-id forgotten-password-id}))
+          (log/warn (format "User %s does not exist so reset password e-mail not sent." email-address)))
         (response/redirect (routes/path :show-forgotten-password-confirmation)))
       (show-forgotten-password-form request-with-validation-errors))))

@@ -39,5 +41,8 @@
 (defn show-reset-password-form [forgotten-password-store user-store request]
   (let [forgotten-password-id (request->forgotten-password-id request)]
     (when-let [forgotten-password-record (cl-store/fetch forgotten-password-store forgotten-password-id)]
+      (prn "Forgotten-password-record" forgotten-password-record)
       (when-let [user (user/retrieve-user user-store (:login forgotten-password-record))]
-        (response/response "password reset form")))))
+        (prn "Forgotten-password-user" user)
+        (-> (response/response "password reset form")
+            (response/content-type "text/html"))))))


A little Blurred Lines.

A little Blurred Lines.

--- src/kolmogorov_music/song.clj
+++ src/kolmogorov_music/song.clj
@@ -26,9 +26,12 @@
       (* vol master-volume)))

 ; Arrangement
-(defmethod live/play-note :dux [{hertz :pitch seconds :duration}] (buzz hertz seconds))
-(defmethod live/play-note :comes [{hertz :pitch seconds :duration}] (sing hertz seconds))
-(defmethod live/play-note :bass [{hertz :pitch seconds :duration}] (sing (* 1/2 hertz) seconds))
+(defmethod live/play-note :dux [{hertz :pitch seconds :duration}]
+  (when hertz (buzz hertz seconds)))
+(defmethod live/play-note :comes [{hertz :pitch seconds :duration}]
+  (when hertz (sing hertz seconds)))
+(defmethod live/play-note :bass [{hertz :pitch seconds :duration}]
+  (when hertz (sing (* 1/2 hertz) seconds)))

 (defn construct [time duration pitch part]
   {:time time
@@ -56,16 +59,21 @@

 (def track
   (->>
-    (champernowne/word 10 4100410033073307230713083309)
-    (encode {:dux 0 :comes 0 :bass 0})
+    (champernowne/word 10
+                       7207120772071207720712077207120772031203720312037203120312551255125412541253125312521232
+                       )
+    ; (encode {:dux 0 :comes 0 :bass 0})
+    (encode {:dux 0})
     (wherever :pitch, :pitch (comp temperament/equal scale/A scale/minor scale/lower))
     (where :time (bpm 120))
     (where :duration (bpm 120))))

 (comment

-  ; Loop the track, allowing live editing.
+   ; Loop the track, allowing live editing.
   (live/jam (var track))
   (fx-reverb)
   (fx-chorus)
-  (fx-distortion))
+  (fx-distortion)
+
+  )


revert change in prefix-dependency-imports

--- src/leiningen/source_deps.clj
+++ src/leiningen/source_deps.clj
@@ -175,7 +175,8 @@
   (info "    prefixing imports in clojure files...")
   (let [cleaned-name-version (clean-name-version pname pversion)
         rel-src-path (relative-src-path src-path)
-        clj-files (clojure-source-files-relative ["target/srcdeps"])
+        clj-files (concat (clojure-source-files-relative ["target/srcdeps"])
+                          (clojure-source-files-relative rel-src-path))
         imports (->> clj-files
                      (reduce #(conj %1 (retrieve-import srcdeps (remove-2parents %2))) [])
                      (remove nil?)


oops cleaning up a bit

oops cleaning up a bit

--- test/restaurant_inspections_api/handlers/businesses_test.clj
+++ test/restaurant_inspections_api/handlers/businesses_test.clj
@@ -9,11 +9,10 @@

 (deftest validate-businesses-params-test
   (testing "Given query params input, returns valid and invalid format/values."
-    (is (=
-         (validate-businesses-params
-          "33137,22345" "11" "1" "2")
-         {:invalid {}
+    (is (= {:invalid {}
           :valid {:zipCodes "33137,22345"
                   :countyNumber "11"
                   :perPage 1
-                  :page 2}}))))
+                  :page 2}}
+         (validate-businesses-params
+          "33137,22345" "11" "1" "2")))))


Added tests for existing operators on larger stacks

Turns out that we had no tests for any of our math operators or `swap` that acted on a stack with more than two items. This fixes that, and exposes a bug in the implementation of `swap`.

--- test/simple_symbolic_regression_clojure/interpreter_test.clj
+++ test/simple_symbolic_regression_clojure/interpreter_test.clj
@@ -30,6 +30,8 @@
              (process-token [2/3 5/6] :+) => [3/2]
              (process-token [0 0] :+) => [0]
              )
+       (fact "process-token with :+ and many numbers"
+             (process-token [5 8 9 6 3 2] :+) => [5 8 9 6 5])
        )

 (facts "about process-token with :-"
@@ -43,6 +45,8 @@
              (process-token [2/3 5/6] :-) => [-1/6]
              (process-token [0 0] :-) => [0]
              )
+       (fact "process-token with :- and many numbers"
+             (process-token [5 8 9 6 3 2] :-) => [5 8 9 6 1])
        )

 (facts "about process-token with :÷"
@@ -61,6 +65,8 @@
              (process-token [1/2 0/5] :÷) => [1/2 0]
              (process-token [0.0 0.0] :÷) => [0.0 0.0]
              )
+       (fact "process-token with :÷ and many numbers"
+             (process-token [5 8 9 6 3 2] :÷) => [5 8 9 6 3/2])
        )

 (facts "about process-token with :*"
@@ -80,6 +86,8 @@
              (process-token [111111 22222222222222222] :*)
                => [2469133333333333308642N]
              )
+       (fact "process-token with :* and many numbers"
+             (process-token [5 8 9 6 3 2] :*) => [5 8 9 6 6])
        )

@@ -92,8 +100,9 @@
        (fact "process-token with :swap and only one number"
              (process-token [7] :swap) => [7])
        (fact "process-token with :swap and two numbers"
-             (process-token [3 5] :swap) => [5 3]))
-
+             (process-token [3 5] :swap) => [5 3])
+       (fact "process-token with :swap and several numbers"
+             (process-token [5 8 9 6 3 2 0] :swap) => [5 8 9 6 3 0 2]))

 (facts "about process-token with a variable"
        (fact "process-token with an undefined variable"


CMR-2652: Fixed naming issue for the PR.

--- system-int-test/test/cmr/system_int_test/search/collection_keyword_search_test.clj
+++ system-int-test/test/cmr/system_int_test/search/collection_keyword_search_test.clj
@@ -524,20 +524,20 @@
 ;; ingest this UMM-SPEC collection but it contains some keyword values other tests are using.
 ;; This would break other tests when doing the keyword searches.
 (deftest search-by-ancillary-keywords
-  (let [c10-umm-json-1 (d/ingest "PROV1"
-                                 (-> exp-conv/example-collection-record
-                                     (assoc :AncillaryKeywords ["CMR2652AKW1" "CMR2652AKW2"])
-                                     (assoc :ShortName "CMR2652SN1")
-                                     (assoc :EntryTitle "CMR2652ET1"))
-                                 {:format :umm-json
-                                  :accept-format :json})
-        c10-umm-json-2 (d/ingest "PROV1"
-                                 (-> exp-conv/example-collection-record
-                                     (assoc :AncillaryKeywords ["CMR2652AKW3" "CMR2652AKW4"])
-                                     (assoc :ShortName "CMR2652SN2")
-                                     (assoc :EntryTitle "CMR2652ET2"))
-                                 {:format :umm-json
-                                  :accept-format :json})]
+  (let [coll1 (d/ingest "PROV1"
+                        (-> exp-conv/example-collection-record
+                            (assoc :AncillaryKeywords ["CMR2652AKW1" "CMR2652AKW2"])
+                            (assoc :ShortName "CMR2652SN1")
+                            (assoc :EntryTitle "CMR2652ET1"))
+                        {:format :umm-json
+                         :accept-format :json})
+        coll2 (d/ingest "PROV1"
+                        (-> exp-conv/example-collection-record
+                            (assoc :AncillaryKeywords ["CMR2652AKW3" "CMR2652AKW4"])
+                            (assoc :ShortName "CMR2652SN2")
+                            (assoc :EntryTitle "CMR2652ET2"))
+                        {:format :umm-json
+                         :accept-format :json})]
     (index/wait-until-indexed)
     (testing "parameter searches"
       (are3 [keyword-str items]
@@ -546,11 +546,11 @@

         "testing parameter search by existing ancillary keywords"
         "CMR2652AKW1"
-        [c10-umm-json-1]
+        [coll1]

         "testing parameter search by existing ancillary keywords"
         "CMR2652AKW4"
-        [c10-umm-json-2]
+        [coll2]

         "testing parmaeter search by non-existing ancillary keywords"
         "CMR2652NOAKW"
@@ -563,11 +563,11 @@

         "testing json query search by existing ancillary keywords"
         "CMR2652AKW2"
-        [c10-umm-json-1]
+        [coll1]

         "testing json query search by existing ancillary keywords"
         "CMR2652AKW3"
-        [c10-umm-json-2]
+        [coll2]

         "testing json query search by non-existing ancillary keywords"
         "CMR2652NOAKW"


Set :realtime to true

Set :realtime to true

Set the :realtime flag of the select query to the server to true if
realtime is added before the select query

--- src/webapp/framework/client/coreclient.clj
+++ src/webapp/framework/client/coreclient.clj
@@ -674,16 +674,17 @@
   (insta/parser
     "SQL                = SELECT_QUERY | INSERT_STATEMENT

-     <SELECT_QUERY>     = <REALTIME_OPTIONS> <SELECT> FIELDS <FROM> TABLE WHERE_CLAUSE?
-
-     <REALTIME_OPTIONS> = 'realtime ' | ''
+     <SELECT_QUERY>     = REALTIME_CLAUSE? <SELECT> FIELDS <FROM> TABLE WHERE_CLAUSE?
+
+     REALTIME_OPTIONS   = 'realtime '
+     REALTIME_CLAUSE    = <REALTIME_OPTIONS>

      <INSERT_STATEMENT> = <INSERT>  TABLE  INSERT_FIELD_SPEC  VALUES

-     <INSERT> = 'insert into '
-     INSERT_FIELD_SPEC = '(' (FIELD)+ ')'
-     <VALUES> = 'values  '
-     INSERT_VALUES = '('   #'[a-z|A-Z|_| |=|0-9|?|\\'|%]+'   ')'
+     <INSERT>           = 'insert into '
+     INSERT_FIELD_SPEC  = '(' (FIELD)+ ')'
+     <VALUES>           = 'values  '
+     INSERT_VALUES      = '('   #'[a-z|A-Z|_| |=|0-9|?|\\'|%]+'   ')'

      SELECT             = 'select '
@@ -722,6 +723,7 @@
              :FIELDS          (fn[& x] {:fields (into [] (map keyword x) )})
              :TABLE           (fn[x]   {:db-table x})
              :WHERE_CLAUSE    (fn[x]   {:where (trim x)})
+             :REALTIME_CLAUSE (fn[]    {:realtime true})
              }
             ))
    ]
@@ -824,9 +826,9 @@
            ;(~'div {}  (~'str "SQL LIST: "                         ~list-of-sql))
            (~'div {}  (~'str "SQL STRING: "
                         ~sql-as-a-string))
-           ;(~'div {}  (~'str "Main Instaparse Query: "       ~parsed-sql))
-           ;(~'div {}  (~'str "Main Transformed query: "
-           ;             ~transformed-sql))
+           (~'div {}  (~'str "Main Instaparse Query: "       ~parsed-sql))
+           (~'div {}  (~'str "Main Transformed query: "
+                        ~transformed-sql))
            (~'div {}  (~'str "Main Dataview map: "           ~dataview-map))
            (~'div {}  (~'str "Main Params: "                 ~main-params))
            (~'div {}  (~'str "Type: "  ~typeof2))


CMR-2920 respond to PR comments

CMR-2920 respond to PR comments

--- transmit-lib/src/cmr/transmit/echo/soap/group.clj
+++ transmit-lib/src/cmr/transmit/echo/soap/group.clj
@@ -86,8 +86,7 @@
   "Convenience function to allow retrieving a group by the group name and user id of one of its members, without needing to know any guids.
     returns a map containing the group information for the matched group, if any."
   [token group-name member-name]
-  (let [member (or (user/get-user-by-user-name {:token token :user-name (str/lower-case member-name)})
-                   (user/get-user-by-user-name {:token token :user-name member-name}))
+  (let [member ((user/get-user-by-user-name {:token token :user-name member-name}))
         member-guid (:guid member)
         group (->> (get-group-names-by-member {:token token :member-guid member-guid})
                    (filter #(= (:name %) group-name))


Add teaser image

Add teaser image


allow a default value to be supplied to config-get

--- src/overtone/config/store.clj
+++ src/overtone/config/store.clj
@@ -19,9 +19,13 @@
 (def live-config (partial live-file-store config*))

 (defn config-get
-  "Get config value"
-  [key]
-  (get @config* key))
+  "Get config value. Returns default if specified and the config does
+  not contain key."
+  ([key]
+     (get @config* key))
+  ([key not-found]
+     (let [c @config*]
+       (get @config* key not-found))))

 (defn config-set!
   "Set config key to val"


fix #'mk-tmp-dir for linux users. Thanks to Saturnation in #clojure for helping debug this.

--- src/overtone/helpers/file.clj
+++ src/overtone/helpers/file.clj
@@ -331,13 +331,14 @@
   *NIX systems. Returns a File object pointing to the new directory. Raises an
   exception if the directory couldn't be created after 10000 tries."
   []
-  (let [base-dir (file (System/getProperty "java.io.tmpdir"))
-        base-name (str (System/currentTimeMillis) "-" (long (rand 1000000000)) "-")
+  (let [base-dir     (file (System/getProperty "java.io.tmpdir"))
+        base-name    (str (System/currentTimeMillis) "-" (long (rand 1000000000)) "-")
+        tmp-base     (mk-path base-dir base-name)
         max-attempts 10000]
     (loop [num-attempts 1]
       (if (= num-attempts max-attempts)
         (throw (Exception. (str "Failed to create temporary directory after " max-attempts " attempts.")))
-        (let [tmp-dir-name (str base-dir base-name num-attempts)
+        (let [tmp-dir-name (str tmp-base num-attempts)
               tmp-dir (file tmp-dir-name)]
           (if (.mkdir tmp-dir)
             tmp-dir


Fix bug where columns did not line up when scrollbar was visible

--- src/reabledit/components.cljs
+++ src/reabledit/components.cljs
@@ -55,6 +55,7 @@
   (let [column-widths (:column-widths @state)
         scrollbar-size (util/vertical-scrollbar-size (:main-el @state))]
     [:div.reabledit-row.reabledit-row--header
+     {:style {:padding-right (str scrollbar-size "px")}}
      (if (:resize @state)
        [:div.reabledit-resize-area
         {:on-drag-over (fn [e]


added title and qoe to numbers screen

added title and qoe to numbers screen

--- src/unspun/screens/stats.cljs
+++ src/unspun/screens/stats.cljs
@@ -7,6 +7,7 @@
             [unspun.db :refer [app-state palette-index stories story-index compare-text-vector nn-text-vector to-pc clamp parse-sources]]
             [unspun.navigation.bottom-nav :refer [story-links]]
             [unspun.screens.mixins :refer [monitor]]
+            [unspun.screens.scenario-title-view :refer [scenario-title]]
             ))

 (defn edit-icon [palette]
@@ -47,7 +48,7 @@

 (defc page < rum/reactive []
   (let [scenar ((rum/react stories) (rum/react story-index))
-        db (rum/react app-state) ; unused?
+        db (rum/react app-state)                            ; unused?
         br (:baseline-risk scenar)
         rr (:relative-risk scenar)
         brpc (to-pc br)
@@ -56,46 +57,56 @@
         erpc (to-pc (clamp [0 1] er))
         palette (get-palette (rum/react palette-index))
         page-style {:flex            1
-                    :backgroundColor (:primary palette)}]
+                    :backgroundColor (:primary palette)}

-    (let [text-style {:color (:text-icons palette)
-                      :fontSize tffsz}
-          small-text-style (merge text-style {:fontSize (* 0.8 tffsz)})
-          outcome-type (:outcome-type scenar)
-          br-sources (parse-sources (:sources-baseline-risk scenar))
-          rr-sources (parse-sources (:sources-relative-risk scenar))]
-      (container
-        {:key   "stats-container"
-         :style {:flex            1
-                 :backgroundColor (:primary palette)
-                }}
-        (content
-          {:key   "stats-content"
-           :theme (aget my-theme "default")
+        text-field (fn [palette-key weight content]
+                     (text {:key   (gensym "text-field")
+                            :style {:color      (palette-key palette)
+                                    :fontWeight weight
+                                    }} content))
+
+        text-style {:color    (:text-icons palette)
+                    :fontSize tffsz}
+        small-text-style (merge text-style {:fontSize (* 0.8 tffsz)})
+        outcome-type (:outcome-type scenar)
+        br-sources (parse-sources (:sources-baseline-risk scenar))
+        rr-sources (parse-sources (:sources-relative-risk scenar))]
+
+    (container
+      {:key   "stats-container"
+       :style {:flex            1
+               :backgroundColor (:primary palette)
+               }}
+      (content
+        {:key   "stats-content"
+         :theme (aget my-theme "default")
+         :style {:flex 1}}
+
+        (scenario-title (:title scenar) text-field (:qoe scenar))
+
+        (n-list
+          {:key   "stats-list"
            :style {:flex 1}}

-          (n-list
-            {:key   "stats-list"
-             :style {:flex 1}}
-            (n-list-item
-              {:key (gensym "item")}
-              (txt {:key   1
-                    :style text-style}
-                   (str "Background " outcome-type ": " (percentage br) " (baseline " outcome-type ": " (sigfigs 2 br) ")\n\n")
-                   (show-sources small-text-style br-sources))
-              )
-            (n-list-item
-              {:key (gensym "item")}
-              (txt {:key   1
-                    :style text-style}
-                   (str (if (> rr 1) (str "Increased " outcome-type ": " (percentage (- rr 1)))
-                                     (str "Decreased " outcome-type ": " (percentage (- 1 rr)))) " (relative " outcome-type ": " (sigfigs 2 rr) ")\n\n")
-                   (show-sources small-text-style rr-sources)))
+          (n-list-item
+            {:key (gensym "item")}
+            (txt {:key   1
+                  :style text-style}
+                 (str "Background " outcome-type ": " (percentage br) " (baseline " outcome-type ": " (sigfigs 2 br) ")\n\n")
+                 (show-sources small-text-style br-sources))
+            )
+          (n-list-item
+            {:key (gensym "item")}
+            (txt {:key   1
+                  :style text-style}
+                 (str (if (> rr 1) (str "Increased " outcome-type ": " (percentage (- rr 1)))
+                                   (str "Decreased " outcome-type ": " (percentage (- 1 rr)))) " (relative " outcome-type ": " (sigfigs 2 rr) ")\n\n")
+                 (show-sources small-text-style rr-sources)))

-            (n-list-item
-              {:key (gensym "item")}
-              (txt {:style text-style} (compare-text-vector scenar)))
+          (n-list-item
+            {:key (gensym "item")}
+            (txt {:style text-style} (compare-text-vector scenar)))

-            (n-list-item
-              {:key (gensym "item")}
-              (txt {:style text-style} (nn-text-vector scenar)))))))))+          (n-list-item
+            {:key (gensym "item")}
+            (txt {:style text-style} (nn-text-vector scenar))))))))


don't let multiple go-loops run at the same time, kill old ones when the user clicks the generate button

--- src/voke/world/visualize.cljs
+++ src/voke/world/visualize.cljs
@@ -6,39 +6,49 @@
             [voke.world.generation :as generate])
   (:require-macros [cljs.core.async.macros :refer [go-loop]]))

-(s/def ::active-cell ::generate/cell)
-(s/def ::dungeon (s/keys :req [::generate/grid ::active-cell]))
+;; Constants

 (def cell-size 15)
 (def ms-per-tick 50)
+(def grid-width 30)
+(def grid-height 30)

-; TODO construct some sort of system that takes a ::generation/world and draws its progress over time
+(defonce visualization-state (r/atom {::generate/grid (generate/full-grid grid-width grid-height)
+                                      ::active-cell   nil
+                                      ::id            0}))

-(defn make-dungeon []
-  {::generate/grid (generate/full-grid 30 30)
-   ::active-cell   nil})
+(defn reset-visualization-state [old-state]
+  {::generate/grid (generate/full-grid grid-width grid-height)
+   ::active-cell   nil
+   ::id            (inc (old-state ::id))})

-(defonce dungeon (r/atom (make-dungeon)))
+;; Async code

 (defn animate-dungeon-history [historical-active-cells w h]
-  (reset! dungeon {::generate/grid (generate/full-grid w h)
-                   ::active-cell   nil})
+  (let [visualization-id (-> visualization-state
+                             (swap! reset-visualization-state)
+                             ::id)]

-  (go-loop [history historical-active-cells]
-    (when (seq history)
-      (<! (timeout ms-per-tick))
+    (go-loop [history historical-active-cells]
+      (when (and (seq history)
+                 (= (@visualization-state ::id) visualization-id))
+        (<! (timeout ms-per-tick))

-      (let [[x y] (first history)]
-        (swap! dungeon (fn [a-dungeon]
-                         (-> a-dungeon
-                             (assoc-in [::generate/grid y x] :empty)
-                             (assoc ::active-cell [x y])))))
-      (recur (rest history)))))
+        (let [[x y] (first history)]
+          (swap! visualization-state (fn [state]
+                                       (if (= (state ::id) visualization-id)
+                                         (-> state
+                                             (assoc-in [::generate/grid y x] :empty)
+                                             (assoc ::active-cell [x y]))
+                                         state))))
+        (recur (rest history))))))

 (s/fdef animate-dungeon-history
   :args (s/cat :historical-active-cells ::generate/historical-active-cells
                :w nat-int?
                :h nat-int?))
+
+;; Reagent components

 (defn row [a-row y]
   [:div.row
@@ -46,18 +56,18 @@
      ^{:key ["cell" x y]} [:div.cell {:class (name cell)}])])

 ; TODO rewrite when grid is 1d
-(defn grid [dungeon]
+(defn grid [visualization-state]
   [:div.world
-   (conj (for [[y a-row] (map-indexed vector (@dungeon ::generate/grid))]
+   (conj (for [[y a-row] (map-indexed vector (@visualization-state ::generate/grid))]
            ^{:key ["row" y]} [row a-row y])

-         (when-let [[x y] (@dungeon ::active-cell)]
+         (when-let [[x y] (@visualization-state ::active-cell)]
            ^{:key "active-cell"} [:div.cell.active {:style {:left (* cell-size x)
                                                             :top  (* cell-size y)}}]))])

-(defn ui [dungeon]
+(defn ui [visualization-state]
   [:div.content
-   ^{:key "dungeon"} [grid dungeon]
+   ^{:key "dungeon"} [grid visualization-state]
    ^{:key "button"} [:button {:on-click (fn [e]
                                           (.preventDefault e)
                                           (let [new-dungeon (-> (generate/full-grid 30 30)
@@ -67,8 +77,10 @@
                                                                      30)))}
                      "generate"]])

+;; Main
+
 (defn ^:export main []
-  (r/render-component [ui dungeon]
+  (r/render-component [ui visualization-state]
                       (js/document.getElementById "content")))


[victoryw] #N/A add test

[victoryw] #N/A add test

--- go-visual/test/go_visual/static_pipeline_instance_test.clj
+++ go-visual/test/go_visual/static_pipeline_instance_test.clj
@@ -14,6 +14,14 @@
               {:name "test-pipeline"
                :counter 13
                :stages [{:name "stage-1" :counter 13}
-                        {:name "stage-2" :counter 14}]})))))
+                        {:name "stage-2" :counter 14}]}))))
+  (testing "should extract pipeline successful and value is nil when not with key"
+    (let [origin-instance {:name "test-pipeline"
+             :status 15
+             :time 100}]
+             (is (= (extract-pipeline-instance-history origin-instance)
+                {:name "test-pipeline"
+                 :counter nil
+                 :stages '()})))))

 (run-tests 'go-visual.static_pipeline_instance_test)


Cleaned up a fixture

Cleaned up a fixture

--- test/cia/test_helpers/core.clj
+++ test/cia/test_helpers/core.clj
@@ -45,12 +45,11 @@

 (defn fixture-store [store-map]
   (fn [f]
-    (let [store-impls store-map]
-      (doseq [[store impl-fn] store-impls]
-        (reset! store (impl-fn)))
-      (f)
-      (doseq  [store (keys store-impls)]
-        (reset! store nil)))))
+    (doseq [[store impl-fn] store-map]
+      (reset! store (impl-fn)))
+    (f)
+    (doseq  [store (keys store-map)]
+      (reset! store nil))))

 (def fixture-in-memory-store (fixture-store memory-stores))


def'd base address.

def'd base address.

--- test/kixi/hecuba/amon_test.clj
+++ test/kixi/hecuba/amon_test.clj
@@ -37,6 +37,8 @@
                        (gen/choose 0 59)
                        (gen/choose 0 59))))

+(def base-addr "http://127.0.0.1:8010")
+
 (defn- get-date []
   (str (subs (str (last (gen/sample gen-date-time))) 0 19) "Z"))

@@ -53,7 +55,7 @@
           (get-in (:headers
                    (let [sample (last (sg/generate-examples amon/BaseProgramme))]
                      (reset! poster-map (assoc-in @poster-map [:programme-name] (:name sample)))
-                     (client/post "http://127.0.0.1:8010/4/programmes/" {:accept :json :content-type :json :basic-auth ["support@mastodonc.com" "password"] :body (json/write-str sample)})))
+                     (client/post (apply str base-addr "/4/programmes/") {:accept :json :content-type :json :basic-auth ["support@mastodonc.com" "password"] :body (json/write-str sample)})))
                   ["Location"]))
   (log/info "Programmes: " @programme-loc))

@@ -62,7 +64,7 @@
           (get-in (:headers
                    (let [sample (last (sg/generate-examples amon/BaseProject))]
                      (reset! poster-map (assoc-in @poster-map [:project-name] (:name sample)))
-                     (client/post (apply str "http://127.0.0.1:8010" @programme-loc "/projects/") {:accept :json :content-type :json :basic-auth ["support@mastodonc.com" "password"] :body (json/write-str (assoc-in sample [:programme_id]  (clojure.string/replace @programme-loc  #"/4/programmes/(.*?)" "$1")))})))
+                     (client/post (apply str base-addr @programme-loc "/projects/") {:accept :json :content-type :json :basic-auth ["support@mastodonc.com" "password"] :body (json/write-str (assoc-in sample [:programme_id]  (clojure.string/replace @programme-loc  #"/4/programmes/(.*?)" "$1")))})))
                   ["Location"]))
   (log/info "Project: " @project-loc))

@@ -71,7 +73,7 @@
           (get-in (:headers
                    (let [sample (last (sg/generate-examples amon/BaseEntity))]
                       (reset! poster-map (assoc-in @poster-map [:entity-property-code] (:property_code sample)))
-                     (client/post "http://127.0.0.1:8010/4/entities/" {:accept :json :content-type :json :basic-auth ["support@mastodonc.com" "password"] :body (json/write-str (assoc-in sample [:project_id]  (clojure.string/replace @project-loc  #"/4/projects/(.*?)" "$1")))})))
+                      (client/post (apply str base-addr "/4/entities/") {:accept :json :content-type :json :basic-auth ["support@mastodonc.com" "password"] :body (json/write-str (assoc-in sample [:project_id]  (clojure.string/replace @project-loc  #"/4/projects/(.*?)" "$1")))})))
                   ["Location"]))
   (log/info "Entity: " @entity-loc))

@@ -81,17 +83,17 @@
                    (let [sample (last (sg/generate-examples amon/BaseDevice))]
                      (reset! reading-type (:type (first (:readings sample))))
                      (reset! poster-map (assoc-in @poster-map [:device-description] (:description sample)))
-                     (client/post (apply str "http://127.0.0.1:8010" @entity-loc "/devices/") {:accept :json :content-type :json :basic-auth ["support@mastodonc.com" "password"] :body (json/write-str (assoc-in sample [:entity_id]  (clojure.string/replace @entity-loc  #"/4/entities/(.*?)" "$1")))})))
+                     (client/post (apply str base-addr @entity-loc "/devices/") {:accept :json :content-type :json :basic-auth ["support@mastodonc.com" "password"] :body (json/write-str (assoc-in sample [:entity_id]  (clojure.string/replace @entity-loc  #"/4/entities/(.*?)" "$1")))})))
                   ["Location"]))
   (log/info "Devices: " @device-loc))

 (defn- post-measurement []
-  (client/post (apply str "http://127.0.0.1:8010" @device-loc "/measurements/") {:accept :json :content-type :json :basic-auth ["support@mastodonc.com" "password"] :body (json/write-str (assoc-in (sample-Measurement) [:measurements 0 :type] @reading-type))})
+  (client/post (apply str base-addr @device-loc "/measurements/") {:accept :json :content-type :json :basic-auth ["support@mastodonc.com" "password"] :body (json/write-str (assoc-in (sample-Measurement) [:measurements 0 :type] @reading-type))})
   (log/info "Posting Measurements"))

                                         ;using a specific example -- schema for this may be too hard
 (defn- post-dataset []
-  (client/post (apply str "http://127.0.0.1:8010" @entity-loc "/datasets/") { :basic-auth ["support@mastodonc.com" "password"] :body  (json/write-str {:entity_id "9ac7f5635832d843dda594f58525239263ffdd37" :operation "divide" :name "systemEfficiencyOverall" :members ["interpolatedHeatConsumption-b4f0c7e2b15ba9636f3fb08379cc4b3798a226bb" "interpolatedElectricityConsumption-268e93a5249c24482ac1519b77f6a45f36a6231d"]})})
+  (client/post (apply str base-addr @entity-loc "/datasets/") { :basic-auth ["support@mastodonc.com" "password"] :body  (json/write-str {:entity_id "9ac7f5635832d843dda594f58525239263ffdd37" :operation "divide" :name "systemEfficiencyOverall" :members ["interpolatedHeatConsumption-b4f0c7e2b15ba9636f3fb08379cc4b3798a226bb" "interpolatedElectricityConsumption-268e93a5249c24482ac1519b77f6a45f36a6231d"]})})
   (log/info "Posting dataset"))

 ;post one of everything
@@ -117,28 +119,28 @@

 (defn- get-programme []
   (log/info "\nProgramme data:\n")
-  (let [output (json/read-json (:body (client/get (apply str "http://127.0.0.1:8010/4" @programme-loc) {:accept :json :content-type :json :basic-auth ["support@mastodonc.com" "password"]})))
+  (let [output (json/read-json (:body (client/get (apply str base-addr "/4" @programme-loc) {:accept :json :content-type :json :basic-auth ["support@mastodonc.com" "password"]})))
         prog-name (:name output)]
     (reset! getter-map (assoc-in @getter-map [:programme-name] prog-name))
      (log/info output)))

 (defn- get-project []
   (log/info "\nProject data:\n")
-  (let [output (json/read-json (:body (client/get (apply str "http://127.0.0.1:8010/4" @programme-loc @project-loc) {:accept :json :content-type :json :basic-auth ["support@mastodonc.com" "password"]})))
+  (let [output (json/read-json (:body (client/get (apply str base-addr "/4" @programme-loc @project-loc) {:accept :json :content-type :json :basic-auth ["support@mastodonc.com" "password"]})))
         proj-name (:name output)]
     (reset! getter-map (assoc-in @getter-map [:project-name] proj-name))
      (log/info output)))

 (defn- get-entity []
   (log/info "\nEntity data:\n")
-  (let [output (json/read-json (:body (client/get (apply str "http://127.0.0.1:8010/4" @entity-loc) {:accept :json :content-type :json :basic-auth ["support@mastodonc.com" "password"]})))
+  (let [output (json/read-json (:body (client/get (apply str base-addr "/4" @entity-loc) {:accept :json :content-type :json :basic-auth ["support@mastodonc.com" "password"]})))
         prop-code (:property_code output)]
     (reset! getter-map (assoc-in @getter-map [:entity-property-code] prop-code))
      (log/info output)))

 (defn- get-device []
   (log/info "\nDevice data:\n")
-  (let [output (json/read-json (:body (client/get (apply str "http://127.0.0.1:8010/4" @device-loc) {:accept :json :content-type :json :basic-auth ["support@mastodonc.com" "password"]})))
+  (let [output (json/read-json (:body (client/get (apply str base-addr "/4" @device-loc) {:accept :json :content-type :json :basic-auth ["support@mastodonc.com" "password"]})))
         device-desc (:description output)]
      (reset! getter-map (assoc-in @getter-map [:device-description] device-desc))
     (log/info output)))


Comments and cleaning up

Comments and cleaning up

--- src/subpar/core.cljs
+++ src/subpar/core.cljs
@@ -1,5 +1,5 @@
 (ns subpar.core
-   (:use [subpar.paredit :only [parse
+  (:use [subpar.paredit :only [parse
                                in-string  ; takes string
                                in-string? ; takes parse output
                                forward-delete-action
@@ -30,8 +30,6 @@
 ;; operations -- those belong in subpar.paredit.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-(enable-console-print!)
-
 (defn get-index [cm]
   (.indexFromPos cm (.getCursor cm)))

@@ -55,10 +53,10 @@
           (.setCursor cm (.-line cur) (inc (.-ch cur))))
       (.operation cm
                        (fn []
-                           (.replaceRange cm pair cur)
-                           ; CHANGED: use aget instead of -line
-                           (.setCursor cm (aget cur "line") (inc (aget cur "ch")))
-                           (.indentLine cm (aget cur "line")))))))
+                         (.replaceRange cm pair cur)
+                         ; Using aget instead of -line because (.-line cur) was returning nil
+                         (.setCursor cm (aget cur "line") (inc (aget cur "ch")))
+                         (.indentLine cm (aget cur "line")))))))

 (defn ^:export forward-delete [cm]
   (if (nothing-selected? cm)
@@ -87,11 +85,12 @@
           e2  (.posFromIndex cm (inc i))
           s3  (.posFromIndex cm (- i 2))
           e3  e1]
-
       (condp = act
         1 (.replaceRange cm "" s1 e1)
         2 (.replaceRange cm "" s2 e2)
         3 (.replaceRange cm "" s3 e3)
+             ; removed '4' and made .setCursor the fallback action because
+             ; this was throwing a 'no matching clause' error
         (.setCursor cm s1)))
     (.replaceSelection cm "")))


Get after atomix.close

Get after atomix.close

--- src/trinity/core.clj
+++ src/trinity/core.clj
@@ -54,7 +54,8 @@
 (defn close!
   "Closes the `atomix` client or server."
   [^Atomix atomix]
-  (.close atomix))
+  (-> (.close atomix)
+      (.get)))

 (defn dist-atom
   "Creates a distributed atom for the `client` on the `path`."


State.

State.

--- test/com/nomistech/clojure_the_language/c_400_state_and_concurrency/s_020_atoms.clj
+++ test/com/nomistech/clojure_the_language/c_400_state_and_concurrency/s_020_atoms.clj
@@ -65,26 +65,22 @@
 ;; Whoops; that's Paws, not Jaws.

 ;; Fix the title (using `assoc`):
-
+;; - Do this: (assoc <current-value> :title "Jaws"):
 (do (swap! jaws-atom assoc :title "Jaws")
-    ;; does this: (assoc <current-value> :title "Jaws")
     (fact @jaws-atom => {:title "Jaws"
                          :director {:name "Karl Zwicky"
                                     :n-movies-as-director 40}
                          :n-likes 0}))

 ;; Fix the director (using `assoc-in`):
-
+;; - Do this: (assoc-in <current-value> [:director :name] "Steven Spielberg"):
 (do (swap! jaws-atom assoc-in [:director :name] "Steven Spielberg")
-    ;; does this:
-    ;;   (assoc-in <current-value> [:director :name] "Steven Spielberg")
     (fact @jaws-atom => {:title "Jaws"
                          :director {:name "Steven Spielberg"
                                     :n-movies-as-director 40}
                          :n-likes 0}))

 ;; Add more detail to the director (using `assoc-in`):
-
 (do (swap! jaws-atom assoc-in [:director :date-of-birth] 1946)
     (fact @jaws-atom => {:title "Jaws"
                          :director {:name "Steven Spielberg"
@@ -93,7 +89,6 @@
                          :n-likes 0}))

 ;; We can apply a function to part of a map in an atom (using `update`):
-
 (do (swap! jaws-atom update :n-likes + 2)
     (fact @jaws-atom => {:title "Jaws"
                          :director {:name "Steven Spielberg"
@@ -103,7 +98,6 @@

 ;; We can apply a function to part of a nested map in an atom (using
 ;; `update-in`):
-
 (do (swap! jaws-atom update-in [:director :n-movies-as-director] + 15)
     (fact @jaws-atom => {:title "Jaws"
                          :director {:name "Steven Spielberg"


(TK-343) Overlong UTF-8 character decoding tests

This commit adds a couple of tests which confirm that when an overlong
encoding of a UTF-8 character is used that the string is decoded with
replacement characters instead of being decoded to the same value as the
minimal form of the character.

--- test/clj/puppetlabs/trapperkeeper/services/webserver/normalized_uri_helpers_test.clj
+++ test/clj/puppetlabs/trapperkeeper/services/webserver/normalized_uri_helpers_test.clj
@@ -100,6 +100,26 @@
     (is (= "/foo/bar/.../baz" (normalize-uri-path-for-string
                                "/foo/bar/%2E%2E%2E/baz")))))

+(deftest normalize-uri-with-overlong-utf8-chars-tests
+  (testing (str "utf-8 characters with overlong encodings are substituted "
+                "with replacement characters")
+    ;; %C0%AE is an overlong (leading zero-padded, two byte) encoding of the
+    ;; full stop (period) character.  The full stop character's minimal
+    ;; encoding in UTF-8 is %2E.  These tests validate that the normalization
+    ;; process substitutes replacement characters for the original characters
+    ;; in the string - as opposed to decoding the character back to the
+    ;; same character that the minimal form would decode to.
+    ;;
+    ;; From section 3 of RFC 3629 (https://tools.ietf.org/html/rfc3629):
+    ;;> Implementations of the decoding algorithm above MUST protect against
+    ;;> decoding invalid sequences.  For instance, a naive implementation may
+    ;;> decode the overlong UTF-8 sequence C0 80 into the character U+0000,
+    ;;> or the surrogate pair ED A1 8C ED BE B4 into U+233B4.  Decoding
+    ;;> invalid sequences may have security consequences or cause other
+    ;;> problems.
+    (is (= "��" (normalize-uri-path-for-string "%C0%AE")))
+    (is (= "/foo/��/��" (normalize-uri-path-for-string "/foo/%C0%AE/%C0%AE")))))
+
 (deftest normalize-uris-with-redundant-slashes-tests
   (testing "uris with redundant slashes are removed"
     (is (= "/" (normalize-uri-path-for-string "//")))


Hopefully improve performance of quiescence-search

--- src/edu/berkeley/ai/util/graphs.clj
+++ src/edu/berkeley/ai/util/graphs.clj
@@ -319,16 +319,21 @@
         outgoing-map (edge-list->outgoing-map edge-list)
         node-vals    (HashMap. #^Map (into {} (for [[g [_ v]] named-srcs] [g v])))
         node-val     #(lazy-get node-vals % (init-fn %))
-        queue        (LinkedList. (map first src-vals))]
+        queue        (LinkedList. (map first src-vals))
+        queue-count  (HashMap. (into {} (for [x (map first src-vals)] [x 1])))]

     (while (not (.isEmpty queue))
       (let [node (.removeFirst queue)
-            old-val (node-val node)
-            new-val (apply update-fn node old-val (map node-val (incoming-map node)))]
-;        (println node old-val new-val)
-        (when-not (= new-val old-val)
-          (.put node-vals node new-val)
-          (doseq [succ (outgoing-map node)] (.addFirst queue succ)))))
+            rem-count (dec (.get queue-count node))]
+        (.put queue-count node rem-count)
+        (when (zero? rem-count)
+          (let [old-val (node-val node)
+                new-val (apply update-fn node old-val (map node-val (incoming-map node)))]
+            (when-not (= new-val old-val)
+              (.put node-vals node new-val)
+              (doseq [succ (outgoing-map node)]
+                (.addFirst queue succ)
+                (.put queue-count succ (inc (get queue-count node 0)))))))))

     (apply dissoc (into {} node-vals) (map first named-srcs))))


Exception message from jenkins call are returned to the client

--- src/emender_jenkins/jenkins_api.clj
+++ src/emender_jenkins/jenkins_api.clj
@@ -61,15 +61,31 @@
                  (.printStackTrace e)
                  nil))))

+(defn job-related-command
+    [jenkins-url jenkins-auth job-name command]
+    (try
+        (let [response (post-command jenkins-url jenkins-auth job-name command)]
+            {:status   "ok"
+             :job-name job-name
+             :command  command
+             :jenkins-response response})
+        (catch Exception e
+            (.printStackTrace e)
+            {:status "error"
+             :job-name job-name
+             :command  command
+             :message (.getMessage e)
+            })))
+
 (defn start-job
     [jenkins-url jenkins-auth job-name]
-    (post-command jenkins-url jenkins-auth job-name "build"))
+    (job-related-command jenkins-url jenkins-auth job-name "build"))

 (defn enable-job
     [jenkins-url jenkins-auth job-name]
-    (post-command jenkins-url jenkins-auth job-name "enable"))
+    (job-related-command jenkins-url jenkins-auth job-name "enable"))

 (defn disable-job
     [jenkins-url jenkins-auth job-name]
-    (post-command jenkins-url jenkins-auth job-name "disable"))
+    (job-related-command jenkins-url jenkins-auth job-name "disable"))


fix locals

fix locals

--- src/gamma_driver/drivers/basic.cljs
+++ src/gamma_driver/drivers/basic.cljs
@@ -111,34 +111,34 @@
                          (swap! resource-state dissoc k)))

   gdp/IBindVariable
-  (bind-attribute [this program attribute input]
+  (bind-attribute [this program attribute spec]
     (input
       this
       program
       gd/bind-attribute
       attribute
-      input))
-  (bind-element-array [this program element-array input]
+      spec))
+  (bind-element-array [this program element-array spec]
     (input
       this
       program
       gd/bind-element-array
       element-array
-      input))
-  (bind-texture-uniform [this program uniform input]
+      spec))
+  (bind-texture-uniform [this program uniform spec]
     (input
       this
       program
       gd/bind-texture-uniform
       uniform
-      input))
-  (bind-uniform [this program uniform input]
+      spec))
+  (bind-uniform [this program uniform spec]
     (input
       this
       program
       gd/bind-uniform
       uniform
-      input))
+      spec))

   gdp/IDraw
   (draw-arrays [this program spec] (draw-arrays* this program spec))


First prototype of server side system finished

--- src/hellhound/connection/server.clj
+++ src/hellhound/connection/server.clj
@@ -2,16 +2,19 @@
   (:require [hellhound.system :refer [get-system]]
             [compojure.core :as compojure :refer [GET POST]]))

+(defn- websocket
+  []
+  (:websocket (get-system)))

 (defn routes
   "Routes macro allows developer to setup sente connection and urls easy
   and painlessly."
   []
   (compojure/routes
-   (compojure/context "/hellhound" []
-                      (compojure/GET  "/" req ((:ring-ajax-get-or-ws-handshake (:websocket (get-system))) req))
-                      (compojure/POST "/" req ((:ring-ajax-post (:websocket (get-system)))) req))))
-
+   (compojure/context
+    "/hellhound" []
+    (compojure/GET  "/" req ((:ring-ajax-get-or-ws-handshake (websocket)) req))
+    (compojure/POST "/" req ((:ring-ajax-post (websocket))) req))))

 (defmulti router
@@ -24,13 +27,13 @@
   [{:as ev-msg :keys [event id ?data ring-req ?reply-fn send-fn]}]
   (let [session (:session ring-req)
         uid     (:uid     session)]
-    (println "Unhandled event: %s" event)
+    (println "Unhandled event: " event)
     (when ?reply-fn
       (?reply-fn {:umatched-event-as-echoed-from-from-server event}))))

-(defmethod router :sam/sam
-  [{:as ev-msg :keys [?data ?reply-fn event]}]
-  (spit "/home/lxsameer/tmpdata" event :append true))
+(defmethod router :chsk/ws-ping
+  [{:as ev-msg :keys [?data ?reply-fn event]}])
+

 (defn event-router [{:as ev-msg :keys [id ?data event]}]
   (router ev-msg))


Changes is-authentic? to cadence-matches? and implements it.

--- src/cadence/pattern_recognition.clj
+++ src/cadence/pattern_recognition.clj
@@ -41,8 +41,9 @@
   ; TODO Implement
   nil)

-(defn is-authentic?
+  ; TODO Implement
+
+(defn cadence-matches?
   "Returns whether the given cadence is authentic or not."
-  [classifer cadence]
-  ; TODO Implement
-  true)
+  [classifier cadence]
+  (= :authentic (classifier-classify classifier (cadence-to-instance cadence))))


(hopefully) Fix SSH permissions on nodes

--- src/circle/backend/nodes/circle.clj
+++ src/circle/backend/nodes/circle.clj
@@ -59,19 +59,23 @@
                              (service/service "nginx" :action :enable)
                              ;;users
                              (thread-expr/let->
-                              [home (str "/home/" (-> session :user :username))]
+                              [username (-> session :user :username)
+                               home (str "/home/" (-> session :user :username))]
                               (directory/directory  (str home "/.ssh/")
-                                                   :create :action
-                                                   :path true)
-                              (ssh-key/install-key "ubuntu"
+                                                    :create :action
+                                                    :owner username
+                                                    :group  username
+                                                    :mode "600"
+                                                    :path true)
+                              (ssh-key/install-key username
                                                    "id_rsa"
                                                    (slurp "www.id_rsa")
                                                    (slurp "www.id_rsa.pub"))
                               (lein/lein)
                               (remote-file/remote-file (str home "/.ssh/config") :content "Host github.com\n\tStrictHostKeyChecking no\n"
-                                                       ;; :owner "circle"
-                                                       ;; :group "circle"
-                                                       :mode "644")
+                                                       :owner username
+                                                       :group username
+                                                       :mode "600")
                               (directory/directory (str home "/.pallet/")
                                                    :create :action
                                                    :path true)


Add a macro that defines a devcard test runner.

Credit to Eric Smith for posting an initial implementation. It produces
something vaguely similar to a Jasmine test run so you can see in one
place in the browser whether all your tests passing.

--- src/clj/comic_reader/macro_util.clj
+++ src/clj/comic_reader/macro_util.clj
@@ -1,5 +1,7 @@
 (ns comic-reader.macro-util
-  (:require [schema.core :as s]))
+  (:require [schema.core :as s]
+            [cljs.analyzer.api :as ana-api]
+            [devcards.core :as dc]))

 (s/defschema SubscriptionVector
   [(s/one s/Keyword :subscription-key) s/Any])
@@ -51,3 +53,25 @@
 (defmacro reactively [hiccup]
   `[(fn []
       ~hiccup)])
+
+(defn list-of-tests [test-namespace]
+  (->> (ana-api/ns-publics (symbol test-namespace))
+       (remove (comp :test second))
+       (remove (comp :anonymous second))
+       (map (fn [[short-name details]]
+              [(str "**" short-name "**")
+               (list (:name details))]))))
+
+(defn tests-matching-regex [test-regex]
+  (let [sorted-test-nses (->> (ana-api/all-ns)
+                              (map str)
+                              (filter #(re-matches test-regex %))
+                              (sort))
+        test-ns-headers (map #(vector (str "### " %)) sorted-test-nses)
+        test-ns-bodies (map list-of-tests sorted-test-nses)]
+    (mapcat #(apply concat %1 %2) test-ns-headers test-ns-bodies)))
+
+(defmacro dev-cards-runner [test-regex]
+  `(dc/defcard ~'all-test
+     (dc/tests
+      ~@(tests-matching-regex test-regex))))


add atom state to metrics consumers

add atom state to metrics consumers

--- src/clj/marceline/storm/metrics.clj
+++ src/clj/marceline/storm/metrics.clj
@@ -9,11 +9,18 @@
 (defmacro defmetricsconsumer
   [name prepare-impl handle-data-points-impl cleanup-impl]
   (let [prefix (gensym)
-        classname (str *ns* ".consumer." name)]
+        classname (str *ns* ".consumer." name)
+        state "state"
+        init "init"]
     `(do
        (gen-class :name ~classname
                   :implements [backtype.storm.metric.api.IMetricsConsumer]
-                  :prefix ~prefix)
+                  :prefix ~prefix
+                  :state ~state
+                  :init ~init)
+       (defn ~(symbol (str prefix "init"))
+         []
+         [[] (atom {})])
        (defn ~(symbol (str prefix "prepare"))
          ~@prepare-impl)
        (defn ~(symbol (str prefix "handleDataPoints"))


Probably no need for type=button?

Probably no need for type=button?

--- src/cljs/cglossa/search_inputs.cljs
+++ src/cljs/cglossa/search_inputs.cljs
@@ -38,9 +38,8 @@
     (search!)))

 (defn- search-button [multilingual?]
-  [:button.btn.btn-success {:type "button"
-                            :style {:marginLeft (if multilingual? 80 40)}
-                            :on-click #()}
+  [:button.btn.btn-success {:style {:marginLeft (if multilingual? 80 40)}
+                            :on-click search!}
    "Search"])

 (defn- language-add-button []


use partial where it makes sense

use partial where it makes sense

--- src/cljs/love_letter_cljs/game.cljs
+++ src/cljs/love_letter_cljs/game.cljs
@@ -167,7 +167,7 @@
         :players
         vals
         (->>
-         (filter #(valid-target? current-player %))
+         (filter (partial valid-target? current-player))
          (map :id)))))

 (defn remove-protection [game]


Add docstrings to primes, closes #2.

Add docstrings to primes, closes #2.

--- src/clojure/com/hypirion/primes.clj
+++ src/clojure/com/hypirion/primes.clj
@@ -2,17 +2,28 @@
   (:import [com.hypirion.primes Primes])
   (:refer-clojure :exclude [take get]))

-(defn primes []
+(defn primes
+  "Returns a lazy sequence of all primes in sorted order."
+  []
   (seq Primes/PRIME))

-(defn prime? [^long n]
+(defn prime?
+  "Checks whether an integer (long or lower) is a prime. Returns true if yes,
+  false otherwise."
+  [^long n]
   (Primes/isPrime n))

-(defn take [n]
+(defn take
+  "Returns the n first primes as an unmodifiable list."
+  [n]
   (Primes/take n))

-(defn get [n]
+(defn get
+  "Returns the nth prime number."
+  [n]
   (Primes/get n))

-(defn take-below [n]
+(defn take-below
+  "Returns all primes below n as an unmodifiable list."
+  [n]
   (Primes/takeUnder n))


Don't allow white space to break up disallowed numeric sequence.

--- src/oc/storage/resources/common.clj
+++ src/oc/storage/resources/common.clj
@@ -21,7 +21,7 @@

 (defn- allowed-org-name? [name]
   (and (string? name)
-       (not (re-matches #".*\d\d\d\d.*" name)) ; don't allow any more than 3 numerals in a row
+       (not (re-matches #".*\d(\s*)\d(\s*)\d(\s*)\d.*" name)) ; don't allow any more than 3 numerals in a row
        (= (count name) (.codePointCount name 0 (count name))))) ; same # of characters as Unicode points

 (defn- allowed-board-name? [name]


swapped arguments

swapped arguments

--- src/org/spootnik/cyanite/carbon.clj
+++ src/org/spootnik/cyanite/carbon.clj
@@ -28,7 +28,7 @@
   "Send each metric over to the cassandra store"
   [index rollups insertch]
   (fn [ch info]
-    (siphon (map* (partial index formatter rollups) ch) insertch)))
+    (siphon (map* (partial formatter index rollups) ch) insertch)))

 (defn start
   "Start a tcp carbon listener"


:art: Allow remote development with figwheel

--- frontend/scripts/figwheel.clj
+++ frontend/scripts/figwheel.clj
@@ -15,7 +15,8 @@
    :build-ids ["main", "view"]
    :all-builds
    [{:id "main"
-     :figwheel {:on-jsload "uxbox.main.ui/init"}
+     :figwheel {:websocket-host :js-client-host
+                :on-jsload "uxbox.main.ui/init"}
      :source-paths ["src" "vendor"]
      :compiler
      {:main 'uxbox.main
@@ -31,7 +32,8 @@
       :verbose true}}

     {:id "view"
-     :figwheel {:on-jsload "uxbox.view.ui/init"}
+     :figwheel {:websocket-host :js-client-host
+                :on-jsload "uxbox.view.ui/init"}
      :source-paths ["src" "vendor"]
      :compiler
      {:main 'uxbox.view


Test if correct form(s) are stored into the database

--- test/zg/db_interface_test.clj
+++ test/zg/db_interface_test.clj
@@ -181,5 +181,19 @@
                 "b" (insert-word-into-dictionary "different word" "correct form" "description" "user-name"           :blacklist "2016-01-01")
                 "b" (insert-word-into-dictionary "different word" "correct form" "description" "user-name"           :blacklist "2016-01-01")
                 "b" (insert-word-into-dictionary "different word" "correct form" "description" "different user-name" :blacklist "2016-01-01")
-                "b" (insert-word-into-dictionary "different word" "correct form" "description" "different user-name" :blacklist "2016-01-01")))))
+                "b" (insert-word-into-dictionary "different word" "correct form" "description" "different user-name" :blacklist "2016-01-01")))
+        (with-redefs [jdbc/insert! (fn [db-spec table-name data-entry] (get data-entry :correct))]
+            (are [x y] (= x y)
+                nil (insert-word-into-dictionary "word"           nil "description" "user-name"           :whitelist "2016-01-01")
+                nil (insert-word-into-dictionary "word"           nil "description" "user-name"           :blacklist "2016-01-01")
+                nil (insert-word-into-dictionary "different word" nil "description" "user-name"           :blacklist "2016-01-01")
+                nil (insert-word-into-dictionary "different word" nil "description" "user-name"           :blacklist "2016-01-01")
+                nil (insert-word-into-dictionary "different word" nil "description" "different user-name" :blacklist "2016-01-01")
+                nil (insert-word-into-dictionary "different word" nil "description" "different user-name" :blacklist "2016-01-01")
+                "correct form" (insert-word-into-dictionary "word"           "correct form" "description" "user-name"           :whitelist "2016-01-01")
+                "correct form" (insert-word-into-dictionary "word"           "correct form" "description" "user-name"           :blacklist "2016-01-01")
+                "correct form" (insert-word-into-dictionary "different word" "correct form" "description" "user-name"           :blacklist "2016-01-01")
+                "correct form" (insert-word-into-dictionary "different word" "correct form" "description" "user-name"           :blacklist "2016-01-01")
+                "correct form" (insert-word-into-dictionary "different word" "correct form" "description" "different user-name" :blacklist "2016-01-01")
+                "correct form" (insert-word-into-dictionary "different word" "correct form" "description" "different user-name" :blacklist "2016-01-01")))))


play with tests in clojure -- still not hooked up or actual tests

--- language-adaptors/rxjava-clojure/src/test/clojure/rx/lang/clojure/observable_tests.clj
+++ language-adaptors/rxjava-clojure/src/test/clojure/rx/lang/clojure/observable_tests.clj
@@ -2,4 +2,6 @@
   (import rx.Observable))

 ;; still need to get this wired up in build.gradle to run as tests
-; (-> (rx.Observable/toObservable [\"one\" \"two\" \"three\"]) (.take 2) (.subscribe (fn [arg] (println arg))))+; (-> (rx.Observable/toObservable ["one" "two" "three"]) (.take 2) (.subscribe (fn [arg] (println arg))))
+
+; (-> (rx.Observable/toObservable [1 2 3]) (.takeWhile (fn [x i] (< x 2))) (.subscribe (fn [arg] (println arg))))


add :env to :case-node

add :env to :case-node

--- src/main/clojure/clojure/tools/analyzer/js.clj
+++ src/main/clojure/clojure/tools/analyzer/js.clj
@@ -292,6 +292,8 @@
         test-expr (-analyze test expr-env)
         nodes (mapv (fn [tests then]
                       {:op       :case-node
+                       ;; no :form, this is a synthetic grouping node
+                       :env      env
                        :tests    (mapv (fn [test]
                                          {:op       :case-test
                                           :form     test
@@ -299,10 +301,10 @@
                                           :test     (-analyze test expr-env)
                                           :children [:test]})
                                        tests)
-                       :then     {:op   :case-then
+                       :then     {:op       :case-then
                                   :form     test
                                   :env      env
-                                  :then (-analyze then env)
+                                  :then     (-analyze then env)
                                   :children [:then]}
                        :children [:tests :then]})
                     tests thens)


Fix load-spec to handle collections of symbols

Has to recursively call require on each symbol

--- src/main/clojure/com/stuartsierra/lazytest.clj
+++ src/main/clojure/com/stuartsierra/lazytest.clj
@@ -448,6 +448,14 @@
           (throw (IllegalArgumentException.
                   "File argument to load-spec must be a directory")))

+        (coll? x)
+        (let [xs (distinct (filter identity (map #(apply load-spec % options) x)))]
+          (if (seq xs)
+            (SimpleContainer (vec xs)
+                             {:generator `load-spec
+                              :comment "Generated from collection by load-spec."}
+                             nil)))
+
         :else (find-spec x)))

 (defn run-spec


Applied PR suggestions.

Applied PR suggestions.

--- src/cljs/wombats_web_client/components/countdown_timer.cljs
+++ src/cljs/wombats_web_client/components/countdown_timer.cljs
@@ -4,13 +4,13 @@

 (defn- seconds-until
   [time]
-  (if (t/after? (t/now) time)
+  (if (or (nil? time) (t/after? (t/now) time))
     0
     (t/in-seconds (t/interval (t/now) time))))

 (defn- millis-until
   [time]
-  (if (t/after? (t/now) time)
+  (if (or (nil? time) (t/after? (t/now) time))
     0
     (mod (t/in-millis (t/interval (t/now) time))
          1000)))
@@ -21,8 +21,8 @@
     (if (< seconds-left 0)
       "0:00"
       (let [seconds (mod seconds-left 60)
-            seconds-formatted (if (< seconds 10)
-                                (str "0" seconds)
+            seconds-formatted (if (< seconds 10)
+                                (str "0" seconds)
                                 seconds)
             minutes (/ (- seconds-left seconds) 60)]
         (str minutes ":" seconds-formatted)))))
@@ -31,24 +31,26 @@
   [start-time]

   (let [cmpnt-state (reagent/atom {:interval-fn nil
-                                   :timeout-fn nil})]
+                                   :timeout-fn nil})
+        swap-interval-fn! (fn []
+                      (swap! cmpnt-state
+                             assoc
+                             :interval-fn
+                             (.setInterval js/window
+                                           #(reagent/force-update-all)
+                                           1000)))
+        swap-timeout-fn! (fn []
+                      (swap! cmpnt-state
+                             assoc
+                             :timeout-fn
+                             (.setTimeout js/window
+                                          swap-interval-fn!
+                                          ;; Give the browser some extra time to render the next second
+                                          (- (millis-until start-time) 100))))]
     (reagent/create-class
      {:component-will-mount
-      (fn []
-        ;; Force timer to redraw every second, start interval when the countdown timer should switch
-        (swap! cmpnt-state
-               assoc
-               :timeout-fn
-               (.setTimeout js/window
-                            (fn []
-                              (swap! cmpnt-state
-                                     assoc
-                                     :interval-fn
-                                     (.setInterval js/window
-                                                   #(reagent/force-update-all)
-                                                   1000)))
-                            ;; Give the browser some extra time to render the next second
-                            (- (millis-until start-time) 100))))
+      ;; Force timer to redraw every second, start interval when the countdown timer should switch
+      (swap-timeout-fn!)

       :component-will-unmount
       (fn []


(PDB-1984) Remove vestigial sort-by on resource-events cleanup

This commit removes an old sort-by on our resource-events in a reports
sanitization function that didn't serve any utility for the tools using
it.

--- src/puppetlabs/puppetdb/reports.clj
+++ src/puppetlabs/puppetdb/reports.clj
@@ -139,18 +139,13 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Reports Query -> Wire format conversions

-(defn remove-reports-metadata [resource-events]
-  (map #(dissoc %
-                :report :certname :containing_class :configuration_version
-                :run_start_time :run_end_time :report_receive_time :environment)
-       resource-events))
-
 (pls/defn-validated resource-events-query->wire-v5 :- [resource-event-v5-wireformat-schema]
   [resource-events :- resource-events-expanded-query-schema]
   (->> resource-events
        :data
-       remove-reports-metadata
-       (sort-by #(mapv % [:timestamp :resource_type :resource_title :property]))))
+       (map #(dissoc %
+                     :report :certname :containing_class :configuration_version
+                     :run_start_time :run_end_time :report_receive_time :environment))))

 (pls/defn-validated report-query->wire-v5 :- report-v5-wireformat-schema
   [report :- report-query-schema]


into instead of reduce

into instead of reduce

--- src/hivewing_core/worker_config.clj
+++ src/hivewing_core/worker_config.clj
@@ -21,10 +21,8 @@
   (let [result (query aws-credentials ddb-worker-table {"uuid" worker-uuid})
         items (:items result)
         kv-pairs (map #(hash-map (get % "key") (select-keys % ["data" "_uat" "type"])) items)
-        result   (reduce #(merge %1 %2) kv-pairs)
+        result (into {} kv-pairs)
         ]
-    (println items)
-    (println kv-pairs)
     result
     ))


fixed temp-file

fixed temp-file

--- src/main/clojure/czlab/basal/io.clj
+++ src/main/clojure/czlab/basal/io.clj
@@ -387,11 +387,14 @@
 (defn temp-file
   "Create a temporary file."
   {:tag File}
+  ([]
+   (temp-file nil nil))
+  ([pfx sux]
+   (temp-file pfx sux *tempfile-repo*))
   ([pfx sux dir]
-   (File/createTempFile (c/stror pfx "czlab")
-                        (c/stror sux ".tmp") (io/file dir)))
-  ([] (temp-file nil nil))
-  ([pfx sux] (temp-file pfx sux *tempfile-repo*)))
+   (c/do-with
+     [f (File/createTempFile (c/stror pfx "czlab")
+                             (c/stror sux ".tmp") (io/file dir))] (fdelete f))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (defn open-temp-file


Add a note

Add a note

--- test/com/nomistech/clojure_the_language/old_to_organise/protocols_and_records_test.clj
+++ test/com/nomistech/clojure_the_language/old_to_organise/protocols_and_records_test.clj
@@ -82,6 +82,8 @@
   (str (->MyRecord3 "plop" "plop plop"))
   => "==== MyRecord3 [4, 9] ====" )

+;; See alse com.nomistech.clojure-the-language.old-to-organise.type-hints-test
+

 ;;;; ___________________________________________________________________________
 ;;;; ---- Confusing stuff about protocols and inheritance ----


improved function

improved function

--- main/src/dda/pallet/dda_serverspec_crate/infra/fact/command.clj
+++ main/src/dda/pallet/dda_serverspec_crate/infra/fact/command.clj
@@ -44,12 +44,8 @@
         result-key (first result-lines)
         result-out (second result-lines)
         status (int (read-string (nth result-lines 2)))]
-    (if (zero? status)
-      {(keyword result-key) {:exit-code 1
-                             :stout result-out}}
-      {(keyword result-key) {:exit-code 0
-                             :stout result-out}})))
-
+      {(keyword result-key) {:exit-code (if (zero? status) 1 0)
+                             :stout result-out}}))

 (s/defn parse-command-outputs :- CommandFactResult
   [script-result]