Fix CLJS compiler warnings about undeclared vars

```
WARNING: No such namespace: ByteOrder, could not locate ByteOrder.cljs, ByteOrder.cljc, or Closure namespace "" at line 92 resources/public/js/compiled/out/octet/buffer.cljc
WARNING: Use of undeclared Var ByteOrder/BIG_ENDIAN at line 92 resources/public/js/compiled/out/octet/buffer.cljc
WARNING: No such namespace: ByteOrder, could not locate ByteOrder.cljs, ByteOrder.cljc, or Closure namespace "" at line 93 resources/public/js/compiled/out/octet/buffer.cljc
WARNING: Use of undeclared Var ByteOrder/LITTLE_ENDIAN at line 93 resources/public/js/compiled/out/octet/buffer.cljc
```

Fixed the above warnings.

--- src/octet/buffer.cljc
+++ src/octet/buffer.cljc
@@ -86,11 +86,12 @@

 ;; ---- NIO & Netty Buffer implementations

-(defn- set-current-bytebuffer-byte-order!
-  [buff]
-  (case *byte-order*
-    :big-endian (.order buff ByteOrder/BIG_ENDIAN)
-    :little-endian (.order buff ByteOrder/LITTLE_ENDIAN)))
+#?(:clj
+   (defn- set-current-bytebuffer-byte-order!
+     [buff]
+     (case *byte-order*
+       :big-endian (.order buff ByteOrder/BIG_ENDIAN)
+       :little-endian (.order buff ByteOrder/LITTLE_ENDIAN))))

 #?(:clj
    (extend-type ByteBuffer


[fix] pre-declaration.

[fix] pre-declaration.

--- src/ombs/db/admin.clj
+++ src/ombs/db/admin.clj
@@ -58,6 +58,7 @@
       (if (can-finish? ename date)
         (finish ename date)))))

+(declare process-it)
 (defn pay-part [{ename :event-name date :date parts :parts :as params}]
   "Add participation of current user and selected event(given as param from
   post). Parts in params is count of parts, that user want to pay"


Move functionality out of serve-blog.

Move functionality out of serve-blog.

--- src/org/scode/sob.clj
+++ src/org/scode/sob.clj
@@ -11,7 +11,7 @@
   (System/exit 1))

 (defn make-blog-app
-  [port base path]
+  [base path]
   (let [repos (repos/new path)]
     (fn [req]
       {:status 200
@@ -19,10 +19,8 @@
        :body (str req)})))

 (defn serve-blog
-  "Start serving a blog at http://*:port/base."
-  [port base path]
-  (logging/info (str "starting sob on *:" port base ", serving " path))
-  (ring.adapter.jetty/run-jetty (make-blog-app port base path) {:port port}))
+  [port app]
+  (ring.adapter.jetty/run-jetty app {:port port}))

 (defn -main [& args]
   (cmdline/with-command-line args
@@ -34,7 +32,8 @@
       (die "only one file system path currently supported"))
     (if (empty? paths)
       (die "must specify the path to a blog"))
-    (serve-blog port base (first paths))))
+    (logging/info (str "starting sob on *:" port base))
+    (serve-blog port (make-blog-app base (first paths)))))


Set the dirty flag to actually show the messages...

--- src/fm/simrunner/gui/rendering.clj
+++ src/fm/simrunner/gui/rendering.clj
@@ -135,7 +135,9 @@

 (defn add-messages [app-state messages]
   (if (seq messages)
-    (update-in app-state [:ui :model :messages] #(reduce conj % messages))
+    (-> app-state
+        (update-in [:ui :model :messages] #(reduce conj % messages))
+        (assoc-in [:ui :dirty?] true))
     app-state))

 (defn log-messages! [app & messages]


WIP: find updates to send to users for digest

--- src/chat/server/email_digest.clj
+++ src/chat/server/email_digest.clj
@@ -3,15 +3,40 @@
              [triggers :as t]
              [jobs :as j :refer [defjob]]]
             [clojurewerkz.quartzite.schedule.cron :as cron]
+            [clj-time
+             [core :as time]
+             [coerce :refer [to-date-time]]]
             [environ.core :refer [env]]
             [org.httpkit.client :as http]
             [taoensso.timbre :as timbre]
             [chat.server.db :as db]))

-(defn update-for-user
+; finding data
+
+(defn thread-unseen?
+  "A thread is unseen if it's last-open-at is prior to any of the messages' created-at"
+  [thread]
+  (let [last-open (to-date-time (thread :last-open-at))]
+    (some (fn [{:keys [created-at]}]
+            (time/before? last-open (to-date-time created-at)))
+          (thread :messages))))
+
+(defn updates-for-user
   [user-id]
   (db/with-conn
-    (db/get-open-threads-for-user user-id)))
+    (doall (filter thread-unseen? (db/get-open-threads-for-user user-id)))))
+
+; sending
+
+(defn send-message
+  [to {:keys [text html]}]
+  (http/post (str "https://api.mailgun.net/v3/" (env :mailgun-domain) "/messages")
+             {:basic-auth ["api" (env :mailgun-password)]
+              :form-params {:to to
+                            :from (str "noreply@" (env :mailgun-domain))
+                            :subject "While you were away"
+                            :text text
+                            :html html}}))

 ; Scheduling


Fix ugly and duplicated code.

Fix ugly and duplicated code.

--- src/circleci/web/views/index.clj
+++ src/circleci/web/views/index.clj
@@ -22,30 +22,17 @@

 (declare signupform youre-done)

-
-;  center-vertically [height-id content]
-;    [:div {:class "vcenter1" :id height-id}
-;      [:div.vcenter2
-;        [:div.vcenter3
-;          content]]])
-
 (defn
   ^{:doc "Take the provided div and center it vertically, by adding classes and
           wrapping it's contents in more divs. It relies on additional.css
           having .vcenter{1,2,3} defined."}
-  center-vertically [[tag & tags]]
-    (let [[m & ts] tags]
-      (if (map? m)
-        (let [combined (into m {:class "vcenter1"})
-              x [tag combined [:div.vcenter2 (apply vector :div.vcenter3 ts)]]]
-          (println x)
-          x)
-        (let [combined {:class "vcenter1"}
-              x [tag combined [:div.vcenter2 (apply vector :div.vcenter3 tags)]]]
-          (println x)
-          x))))
-
-
+  center-vertically [[tag & args]]
+    (let [[m & remaining] args
+          property-map (into {:class "vcenter1"} (if (map? m) m {}))
+          inner-tags (if (map? m) remaining args)
+          x [tag property-map [:div.vcenter2 (apply vector :div.vcenter3 inner-tags)]]]
+      (println x)
+      x))

 (defpage "/" []


[reduce overdraw] Remove stack card background on Android

--- src/status_im/ui/screens/routing/core.cljs
+++ src/status_im/ui/screens/routing/core.cljs
@@ -72,7 +72,11 @@
 (defn stack-navigator [routes config]
   (nav-reagent/stack-navigator
    routes
-   (merge {:headerMode "none"} (prepare-config config))))
+   (cond->
+    (merge {:headerMode "none"}
+           (prepare-config config))
+     platform/android?
+     (assoc :cardStyle {:backgroundColor nil}))))

 (defn switch-navigator [routes config]
   (nav-reagent/switch-navigator


place try-cause in event-manager around complete while loop

--- src/clj/backtype/storm/event.clj
+++ src/clj/backtype/storm/event.clj
@@ -18,17 +18,17 @@
         running (atom true)
         runner (Thread.
                   (fn []
-                    (while @running
-                      (try-cause
+                    (try-cause
+                      (while @running
                         (let [r (.take queue)]
                           (r)
-                          (swap! processed inc))
-                      (catch InterruptedException t
-                        (log-message "Event manager interrupted"))
-                      (catch Throwable t
-                        (log-error t "Error when processing event")
-                        (halt-process! 20 "Error when processing an event"))
-                        ))))]
+                          (swap! processed inc)))
+                    (catch InterruptedException t
+                      (log-message "Event manager interrupted"))
+                    (catch Throwable t
+                      (log-error t "Error when processing event")
+                      (halt-process! 20 "Error when processing an event"))
+                      )))]
     (.setDaemon runner daemon?)
     (.start runner)
     (reify


better error handling added to ws handler

--- src/clj/hellhound/http/route.clj
+++ src/clj/hellhound/http/route.clj
@@ -15,6 +15,11 @@
   {:status 200
    :headers []
    :body "Yeah"})
+
+(def non-websocket-request
+  {:status 400
+   :headers {"content-type" "application/text"}
+   :body "Expected a websocket request."})

 (def event-router
   {:hello #(stream/put! (:stream %) "hey!")})
@@ -36,14 +41,20 @@
 (defn ws
   [req]
   (log/info "Accpting WS connection")
-  (let [input-stream  (create-ws req)
-        router-stream (stream/stream 100)
-        output-stream (stream/stream 100)]
-
+  (->
+   (deferred/let-flow [socket (http/websocket-connection req)
+                       input-stream @socket
+                       router-stream (stream/stream 100)
+                       output-stream (stream/stream 100)]
     (stream/consume #(println %) output-stream)
     (setup-event-router router-stream)
     (stream/connect input-stream router-stream)
-    (stream/connect router-stream output-stream)))
+    (stream/connect router-stream output-stream))
+   (deferred/catch
+       (fn [_]
+         non-websocket-request))))
+
+

 (def routes


confirm finish session: using core.async to reset local state after a timeout

--- src/cljs/movement/generator.cljs
+++ src/cljs/movement/generator.cljs
@@ -5,6 +5,7 @@
   (:require
     [reagent.session :as session]
     [reagent.core :refer [atom]]
+    [cljs.core.async :as async :refer [timeout <!]]
     [goog.events :as events]
     [clojure.string :as str]
     [movement.util :refer [GET POST get-stored-sessions get-equipment]]
@@ -294,8 +295,12 @@
     (fn []
       [:div
        (if @session-stored-successfully?
-         [:h3.pure-g
-          [:div.pure-u {:style {:color "green"}} "Session stored successfully!"]]
+         (let []
+           (go (<! (timeout 3000))
+               (reset! finish-button-clicked? false)
+               (reset! session-stored-successfully? false))
+           [:h3.pure-g
+            [:div.pure-u {:style {:color "green"}} "Session stored successfully!"]])
          [:h3.pure-g
           (if @finish-button-clicked?
             [:a.pure-u.log-button
@@ -308,7 +313,7 @@
                                 :error-handler (fn [response] (print response))})}
              "Confirm Finish Session"]
             [:a.pure-u.log-button
-             {:on-click #(reset! finish-button-clicked? true)}
+             {:on-click #(handler-fn (reset! finish-button-clicked? true))}
              "Finish Movement Session"])])])))

 (defn generator-component []


Remove the stack trace print

Remove the stack trace print

--- src/clojure/nightmod/sandbox.clj
+++ src/clojure/nightmod/sandbox.clj
@@ -128,7 +128,6 @@
     (jvm/jvm-sandbox func context)
     (catch Exception e
       (when (nil? @u/error)
-        (.printStackTrace e)
         (reset! u/error e))
       nil)))


Only add timeout checker to recur forms

Only add timeout checker to recur forms

--- src/clojure/nightmod/sandbox.clj
+++ src/clojure/nightmod/sandbox.clj
@@ -133,7 +133,7 @@
                            (= 'quote (first form))))
                 form
                 (let [form (walk macroexpand-most identity (macroexpand form))]
-                  (if (list? form)
+                  (if (and (seq? form) (= 'recur (first form)))
                     (list 'do '(#'nightmod.game/check-for-timeout!) form)
                     form))))
             (comp #'clojail.core/dotify)))


Database connection doesn't use SSL anymore, doesn't need it for the local connection

--- src/hphelper/server/shared/sql.clj
+++ src/hphelper/server/shared/sql.clj
@@ -5,7 +5,7 @@
             ))

 (def db {:subprotocol "mysql"
-         :subname "//127.0.0.1:3306/hphelper"
+         :subname "//127.0.0.1:3306/hphelper?useSSL=false"
          :user "fc"})

 (defn query


Use Throwable->map as default error processing

--- src/com/wsscode/pathom/core.cljc
+++ src/com/wsscode/pathom/core.cljc
@@ -220,7 +220,8 @@
     (try
       (reader env)
       (catch Exception e
-        (if errors* (swap! errors* assoc path (if process-error (process-error env e) e)))
+        (swap! errors* assoc path (if process-error (process-error env e)
+                                                    (Throwable->map e)))
         {:value ::reader-error}))))

 (defn wrap-parser-exception [parser]


add Auto Complete tags in bookmarks

add Auto Complete tags in bookmarks

--- src_cljs/bookmarks/corecljs.cljs
+++ src_cljs/bookmarks/corecljs.cljs
@@ -76,15 +76,37 @@
     [:input {:field :radio :name name :value value}]
     label]])

+(defn aggre-str [v]
+  (reduce (fn [acc t] (conj acc (.-tagname t) ))
+                [] v))
+
+(defn on-change [event]
+  (let [ele (.getElementById js/document "tags")
+        eval (.-value ele)
+        onresp (fn [json]
+                 ;; (let [dt  (aggre-str (getdata json))]
+                 ;;   (set! (.-value ele) (if(empty? dt) eval dt))))]
+                 (let [dt (getdata json)]
+                 (r/render [tags-template dt] (.getElementById js/document "tagdiv"))))]
+    (when-not ( >  2 (.-length eval))
+      (http-get (str "http://localhost:8090/tag/search/" eval)
+                onresp))))
+
 (defn input [label type id]
-  (row label [:input.form-control {:type type :id id}]))
+  (row label [:input.form-control {:type type :id id :on-change on-change}]))

+(defn tags-template [data]
+ [:datalist {:id "browsers"}
+   (for [d data] [:option {:value (.-tagname d)}])]
+)

 (defn bookmark-template []
   [:div.form-group
    [:div (input "Title" "text" "title")]
    [:div  (input "URL" "text" "url")]
-   [:div (input "Tags" "text" "tags")]
+   [:div  [:div.col-md-2[:label "Tags"]]
+   [:input  {:id "tags" :list "browsers" :type "text" :on-change on-change}]
+   [:div#tagdiv tags-template]]
    [:div  (input "Description" "textarea" "desc")]])

 (defn getinputvalue[id]


Minify usage view

Minify usage view

--- src/discuss/references/main.cljs
+++ src/discuss/references/main.cljs
@@ -107,16 +107,16 @@
   [data _owner]
   (reify om/IRender
     (render [_]
-      (let [reference (:reference data)
-            issue (:issue data)
+      (let [issue (:issue data)
             statement (:statement data)
             author (:author data)]
         (dom/div nil
                  (dom/div #js {:className "bs-callout bs-callout-info"}
+                          (dom/div #js {:className "pull-right"}
+                                   (bs/button-default-sm #(save-statement-change-view data) (vlib/fa-icon "fa-check") " Auswählen"))
                           (dom/a #js {:href    "javascript:void(0)"
                                       :onClick #(save-statement-change-view data)}
                                  (dom/strong nil (:text statement)))
-                          (dom/div nil "Referenz: \"" (:title reference) "\"")
                           (dom/div nil "Issue: " (:title issue))
                           (dom/div nil "Autor: " (:nickname author))))))))

@@ -127,7 +127,7 @@
     (render [_]
       (let [usages (rlib/get-reference-usages)]
         (dom/div nil
-                 (dom/h5 nil "Usages of this reference")
+                 (dom/h5 nil "Wo wird diese Referenz verwendet?")
                  (rlib/current-reference-component)
                  (dom/div nil
                           (apply dom/div nil


Add a Q parameter to filters so we can rlpf.

--- src/klangmeister/sound/synthesis.cljs
+++ src/klangmeister/sound/synthesis.cljs
@@ -114,11 +114,16 @@

 ; Filters

-(defn biquad-filter [type freq]
-  (fn [context at duration]
-    (doto (.createBiquadFilter context)
-      (-> .-frequency (plug freq context at duration))
-      (-> .-type (set! type)))))
+(defn biquad-filter
+  ([type freq q]
+   (fn [context at duration]
+     (doto (-> (biquad-filter type freq) (run-with context at duration))
+       (-> .-Q (plug q context at duration)))))
+  ([type freq]
+   (fn [context at duration]
+     (doto (.createBiquadFilter context)
+       (-> .-frequency (plug freq context at duration))
+       (-> .-type (set! type))))))

 (def low-pass (partial biquad-filter "lowpass"))
 (def high-pass (partial biquad-filter "highpass"))


Logging of job starts, job finishes and job-results

--- src/emender_service/rest_api.clj
+++ src/emender_service/rest_api.clj
@@ -12,12 +12,13 @@

 (ns emender-service.rest-api)

-(require '[ring.util.response         :as http-response])
-(require '[clojure.pprint             :as pprint])
-(require '[clojure.data.json          :as json])
+(require '[ring.util.response           :as http-response])
+(require '[clojure.pprint               :as pprint])
+(require '[clojure.data.json            :as json])

-(require '[emender-service.file-utils :as file-utils])
-(require '[emender-service.results    :as results])
+(require '[emender-service.file-utils   :as file-utils])
+(require '[emender-service.results      :as results])
+(require '[emender-service.db-interface :as db-interface])

 (defn read-request-body
     [request]
@@ -59,12 +60,14 @@
 (defn job-started-handler
     [request]
     (let [job-name (read-job-name-from-request request)]
+        (db-interface/log-job-started job-name)
         (println "job started" job-name)
         (send-response {:status :ok})))

 (defn job-finished-handler
     [request]
     (let [job-name (read-job-name-from-request request)]
+        (db-interface/log-job-finished job-name)
         (println "job finished" job-name)
         (send-response {:status :ok})))

@@ -72,6 +75,7 @@
     [request]
     (let [job-name (read-job-name-from-request request)
           results  (-> (read-request-body request) body->results)]
+        (db-interface/log-job-results job-name results)
         (println "job name" job-name)
         (println "results:" results)
         (results/add-new-results job-name results)


Convert old-style ^ to meta

Convert old-style ^ to meta

--- src/main/clojure/cascade/path_map.clj
+++ src/main/clojure/cascade/path_map.clj
@@ -78,7 +78,7 @@
   :path meta-data key. The namespace containing the mapped function is tracked for changes."
   [type function]
   (let [path (or ((meta function) :path) (str type "/" (qualified-function-name function)))]
-    (add-tracked-namespace (^function :ns))
+    (add-tracked-namespace ((meta function) :ns))
     (add-function-to-config :mapped-functions path function)))

 (defn path-for-function*


now pass parameters

now pass parameters

--- test6/src/test6/core.clj
+++ test6/src/test6/core.clj
@@ -3,8 +3,7 @@
 (defn finder [dbname key] (str "value from db " dbname))
 (defn pretty-printer [finder key] (str "This is a " (finder key)))

-(defn -main [& args]
-  (let [dbname "DBProd"
-	printer (partial pretty-printer (partial finder dbname))]
+(defn -main [dbname]
+  (let [printer (partial pretty-printer (partial finder dbname))]
    (printer "Alice") ))


add ratio shortcut function

add ratio shortcut function

--- src/semitone/core.clj
+++ src/semitone/core.clj
@@ -31,6 +31,9 @@
             SysexMessage ShortMessage Sequencer Sequence MidiEvent Track]
            [java.nio ByteBuffer]
            [com.sun.media.sound SF2Soundbank]))
+
+(defn ratio [value]
+  (toRatio value))

 (defn env [num-points values & args]
   (let [args (if (empty? args) '(:cubic) args)


Improved set func.

Improved set func.

--- src/suricatta/dsl.clj
+++ src/suricatta/dsl.clj
@@ -637,16 +637,24 @@
 (defn set
   "Attach values to the UPDATE statement."
   ([t kv]
+   {:pre [(map? kv)]}
    (defer
      (let [t (-unwrap t)]
-       (reduce (fn [acc [k v]]
-                 (.set t (-field k) v))
-               t kv))))
+       (run! (fn [[k v]]
+               (let [k (-unwrap k)
+                     v (-unwrap v)]
+                 (.set t (-field k) v))) kv)
+       t)))
   ([t k v]
    (defer
      (let [v (-unwrap v)
+           k (-unwrap k)
            t (-unwrap t)]
-       (if (instance? org.jooq.Row k)
+       (if (clojure.core/and
+            (instance? org.jooq.Row k)
+            (clojure.core/or
+             (instance? org.jooq.Row v)
+             (instance? org.jooq.Select v)))
          (.set t k v)
          (.set t (-field k) v))))))


more examples

more examples

--- src/tango/export2.clj
+++ src/tango/export2.clj
@@ -108,20 +108,34 @@

 (def raw-xml-2
-  (xml/parse (java.io.FileInputStream. "test/tango/examples/real-example-kungsor.xml")))
+  (xml/parse (java.io.FileInputStream. "test/tango/examples/real-example.xml")))

-(def new-stuff-2
+(defn fix-class [class]
+  (clojure.walk/postwalk
+    (fn [form]
+      (cond
+        (= (:tag form) :Results) (merge form {:attrs   {:Qty 997}
+                                              :content (conj (vec (:content form))
+                                                             (xml/element :Result {:Round "Awsome"}))
+                                              })
+        :else form))
+    class))
+
+(defn new-stuff-2 []
   (clojure.walk/postwalk
     (fn [form]
       (cond
         (= (:tag form) :Class) (if (= (:Name (:attrs form))
-                                      "Hiphop Singel Brons B1")
-                                 (xml/element :Class {:Name "Changed Class"})
+                                      "Disco Freestyle A-klass J Fl")
+                                 (fix-class form)
+                                 ;(xml/element :Class {:Name "Changed Class"})
                                  form)
         :else form))
     raw-xml-2))

-(spit "export4.xml" (xml/emit-str new-stuff-2))
+(xml/parse (java.io.FileInputStream. "test/tango/examples/real-example-kungsor.xml"))
+
+(spit "export4.xml" (xml/emit-str (new-stuff-2)))

 ;(defn sanitize [cmp]


Remove old impl of compile-dispatch-table

--- src/io/aviso/rook/dispatcher.clj
+++ src/io/aviso/rook/dispatcher.clj
@@ -378,68 +378,6 @@
        (emit-fn
          (build-handler routes handlers middleware apply-middleware)))))

-#_
-(defn compile-dispatch-table
-  "Compiles the dispatch table into a Ring handler.
-
-  See the docstring of unnest-dispatch-table for a description of
-  dispatch table format."
-  ([dispatch-table]
-     (compile-dispatch-table {} dispatch-table))
-  ([options dispatch-table]
-     (let [dt  (unnest-dispatch-table dispatch-table)
-           req (gensym "request__")
-           emit-fn (:emit-fn options eval)
-           apply-middleware (:apply-middleware-fn options
-                                                  `apply-middleware-sync)]
-       (emit-fn
-         `(fn rook-dispatcher# [~req]
-            (match (request-route-spec ~req)
-              ~@(mapcat
-                  (fn [[method pathvec verb-fn-sym middleware]]
-                    (let [method           (if (identical? method :all)
-                                             '_
-                                             method)
-                          ns-metadata      (-> verb-fn-sym
-                                             namespace symbol the-ns meta)
-                          metadata         (merge (dissoc ns-metadata :doc)
-                                             (meta (resolve verb-fn-sym)))
-                          sync?            (:sync metadata)
-                          pathvec          (keywords->symbols pathvec)
-                          route-params     (set (filter symbol? pathvec))
-                          arglist          (first (:arglists metadata))
-                          non-route-params (remove route-params arglist)
-                          arg-resolvers    (:arg-resolvers metadata)
-                          add-resolvers    (if arg-resolvers
-                                             `(rook/wrap-with-arg-resolvers
-                                                ~@arg-resolvers))
-                          middleware       (if arg-resolvers
-                                             `(fn [handler#]
-                                                (-> handler#
-                                                  ~add-resolvers
-                                                  ~middleware))
-                                             middleware)
-                          schema           (:schema metadata)]
-                      [[method pathvec]
-                       `(let [route-params# ~(zipmap
-                                               (map keyword route-params)
-                                               route-params)
-                              handler# (fn [~req]
-                                         (let [~@(prepare-handler-bindings
-                                                   req
-                                                   arglist
-                                                   route-params
-                                                   non-route-params)]
-                                           (~verb-fn-sym ~@arglist)))]
-                          ((~apply-middleware ~middleware ~sync? handler#)
-                           (-> ~req
-                             (assoc :route-params route-params#)
-                             ~@(if schema
-                                 [`(assoc-in [:rook :metadata :schema]
-                                     ~schema)]))))]))
-                  dt)
-              :else nil))))))
-
 (defn default-middleware [handler]
   (-> handler
     rook/wrap-with-function-arg-resolvers


CMR-4621: Print out in progress messages when not all messages complete

--- message-queue-lib/src/cmr/message_queue/test/queue_broker_wrapper.clj
+++ message-queue-lib/src/cmr/message_queue/test/queue_broker_wrapper.clj
@@ -102,9 +102,10 @@
          (Thread/sleep 10)
          (if (< (- (System/currentTimeMillis) start-time) ms-to-wait)
            (recur (set (current-message-states broker-wrapper)))
-           (warn (format "Waited %d ms for messages to complete, but they did not complete: %s"
+           (warn (format "Waited %d ms for messages to complete, but they did not complete. In progress: %s"
                          ms-to-wait
-                         (current-messages broker-wrapper)))))))))
+                         (pr-str (remove #(contains? terminal-states (:state %))
+                                         (current-messages broker-wrapper)))))))))))

 (defn- publish-to-queue
   "Publishes a message to the queue and captures the actions with the queue history."


Formatting

Formatting

--- lein-template/src/leiningen/new/modular.clj
+++ lein-template/src/leiningen/new/modular.clj
@@ -149,12 +149,7 @@
                                     (str (clojure.core/name (:module a)) "-components"))

                            :docstring (if (:docstring a)
-                                        (str \newline "  \""
-                                             (word-wrap (:docstring a))
-
-
-                                             "\"")
-                                        "")
+                                        (str \newline "  \"" (word-wrap (:docstring a)) "\"") "")

                            :components
                            (when (:components a)
@@ -298,13 +293,10 @@
                  ;; there aren't multiple entries, if there are it means
                  ;; we have a conflict - more than one dependency is trying to bind
                  (gbf #(into {} (gbf first %)))
-                 (into {})
-                 )
+                 (into {}))

                :files (concat (get-in manifest [:application-templates app-template :files] [])
-                              (mapcat :files modules))
-
-               }]
+                              (mapcat :files modules))}]

      (main/info (format "Generating a new modular project named %s with modules :-\n%s"
                         name


remove debug logging.

remove debug logging.

--- src/kixi/hecuba/api/entities.clj
+++ src/kixi/hecuba/api/entities.clj
@@ -127,7 +127,6 @@
            page-size      (or (:size params) 20)
            shoulds        (should-terms allowed-programmes allowed-projects)
            filter-terms   (search-filter nil shoulds nil)
-           _              (log/debugf "Filter Terms: %s" filter-terms)
            results        (search/search-entities query-string filter-terms page-number page-size (:search-session store))
            total_hits     (esr/total-hits results)
            file-bucket    (-> store :s3 :file-bucket)
@@ -142,7 +141,6 @@
            shoulds        (should-terms allowed-programmes allowed-projects)
            must           (must-term :project_id project_id)
            filter-terms   (search-filter must shoulds nil)
-           _              (log/debugf "Filter Terms: %s" filter-terms)
            results        (search/search-entities query-string filter-terms page-number page-size (:search-session store))
            total_hits     (esr/total-hits results)
            file-bucket    (-> store :s3 :file-bucket)


if -> when

if -> when

--- src/cyanite_remover/path_store.clj
+++ src/cyanite_remover/path_store.clj
@@ -141,7 +141,7 @@
           (let [query (build-query (build-filter tenant leafs-only
                                                  limit-depth path))]
             (log/trace (str "ES delete query: " query))
-            (if run
+            (when run
               (let [response (delete-fn query)]
                 (process-response-delete response index path stats-errors))))
           (catch Exception e


add ventilation-systems to profiles

add ventilation-systems to profiles

--- src/kixi/hecuba/api/profiles.clj
+++ src/kixi/hecuba/api/profiles.clj
@@ -58,7 +58,8 @@
                                         :low-energy-lights :photovoltaics
                                         :roof-rooms :roofs :small-hydros
                                         :solar-thermals :storeys :thermal-images
-                                        :walls :wind-turbines :window-sets])
+                                        :ventilation-systems :walls
+                                        :wind-turbines :window-sets])
                                      (update-in [:profile-data] json/encode)
                                      ))}))))


Add a sick hack to get the entrypoint from a tentacle

--- src/doctopus/doctopus/tentacle.clj
+++ src/doctopus/doctopus/tentacle.clj
@@ -1,5 +1,6 @@
 (ns doctopus.doctopus.tentacle
-  (:require [doctopus.shell :refer [make-html git-clone]]
+  (:require [clojure.string :as str]
+            [doctopus.shell :refer [make-html git-clone]]
             [doctopus.storage :refer [save-to-storage load-from-storage backend]]
             [me.raynes.fs :as fs]
             [taoensso.timbre :as log]))
@@ -13,10 +14,11 @@
   (load-html [this])
   (generate-html [this])
   (save-build-output [this dir])
+  (get-html-entrypoint [this])
   (routes [this]))

 (defrecord Tentacle
-    [name html-command html-args output-root source-location]
+    [name html-command html-args output-root source-location entry-point]
   TentacleMethods
   (load-html [this]
     (if (nil? (load-from-storage backend (:name this)))
@@ -37,6 +39,8 @@
   (save-build-output [this dir]
     (let [{:keys [name]} this])
     (save-to-storage backend name dir))
+  (get-html-entrypoint [this]
+    (str/join "/" ["" "docs" (:name this) (:entry-point this)]))
   (routes [this]
     (load-from-storage backend (:name this))))


Extract dimension calculation to function

--- src/gigrig/components/diagram.cljs
+++ src/gigrig/components/diagram.cljs
@@ -1,23 +1,32 @@
 (ns gigrig.components.diagram)

-(defn boxed-text [{:keys [text size background x y]}]
+(defn boxed-text-data
+  "Returns the dimensions and data required to render a boxed text element"
+  [{:keys [text size background x y]}]
   (let [padding 2
-        height (* 1.35 size)
-        width (* 0.6 (count text) size)
-        box-width (+ (* 2 padding) width)
-        box-height (+ (* 2 padding) height)
-        text-x (+ x padding)
-        text-y (+ y size padding)]
-    [:g
-     [:rect {:x x :y y :width box-width :height box-height :fill background}]
-     [:text {:x text-x :y text-y :font-family "monospace" :font-size size}
-      text]]))
+        inner-width (* 0.6 (count text) size)
+        inner-height (* 1.35 size)]
+    {:x x
+     :y y
+     :width (+ (* 2 padding) inner-width)
+     :height (+ (* 2 padding) inner-height)
+     :text {:value text
+            :size size
+            :background background
+            :x (+ x padding)
+            :y (+ y padding size)}}))

-(defn generator [{:keys [x y]}]
-  [boxed-text {:x x :y y :text "Generator" :size 13 :background "orange"}])
+(defn boxed-text [{:keys [text x y width height]}]
+  [:g
+   [:rect {:x x :y y :width width :height height :fill (:background text)}]
+   [:text {:x (:x text) :y (:y text) :font-family "monospace" :font-size (:size text)}
+    (:value text)]])

-(defn distributor [{:keys [x y]}]
-  [boxed-text {:x x :y y :text "Distributor" :size 9 :background "green"}])
+(defn generator [props]
+  (boxed-text-data (merge props {:text "Generator" :background "Orange" :size 13})))
+
+(defn distributor [props]
+  (boxed-text-data (merge props {:text "Distributor" :background "Green" :size 9})))

 (defn component [props]
   [:div
@@ -26,8 +35,8 @@
           :width "800"
           :height "400"
           :style {:border "1px solid black"}}
-    [generator {:x 0 :y 0}]
+    [boxed-text (generator {:x 0 :y 0})]
     [:g {:stroke "black"
          :stroke-width 1}
      [:line {:x1 23 :y1 18 :x2 23 :y2 38}]]
-    [distributor {:x 10 :y 38}]]])
+    [boxed-text (distributor {:x 10 :y 38})]]])


added deps

added deps

--- cljx/plongeur-clj/project.clj
+++ cljx/plongeur-clj/project.clj
@@ -19,9 +19,11 @@
                  [com.rpl/specter "0.10.0"]

                  [ring "1.4.0"]
+                 [ring/ring-defaults "0.2.0"]
                  [compojure "1.5.0"]
                  [clojurewerkz/route-one "1.2.0"]
                  [http-kit "2.1.18"]
+                 [hiccup "1.0.5"]
                  [com.taoensso/sente "1.8.1"]
                  [com.taoensso/timbre "4.3.1"]


[WM] create empty resources/schemas dir

[WM] create empty resources/schemas dir

...so datomic-toolbox won't error out

--- src/leiningen/new/kraken_works.clj
+++ src/leiningen/new/kraken_works.clj
@@ -34,6 +34,7 @@
              ["script/build" (render "script/build" data)]

              ["resources/config.edn" (render "config.edn" data)]
+             ["resources/schemas/.gitkeep" ""]

              ["src/{{sanitized}}/core.clj" (render "core.clj" data)]
              ["src/{{sanitized}}/queue.clj" (render "queue.clj" data)]


Insert the gate into the mix

Insert the gate into the mix

--- src/main/audio_utils/recorder.cljs
+++ src/main/audio_utils/recorder.cljs
@@ -20,7 +20,8 @@
     (let [{:keys [audio-ctx gate]} (om/get-state this)
           source                   (.createMediaStreamSource audio-ctx
                                                              stream)]
-      (.connect source (.-destination audio-ctx))))
+      (.connect source gate)
+      (.connect gate (.-destination audio-ctx))))

   (stop [this]
     (let [audio-ctx (:audio-ctx (om/get-state this))]


moved functions to resolve warnings

moved functions to resolve warnings

--- src/main/untangled/ui/forms.cljc
+++ src/main/untangled/ui/forms.cljc
@@ -915,6 +915,36 @@
             (completing (partial field-diff form))
             diff fields))))))

+(defn entity-xform
+  "Modify the form's (under `form-id`) using `update-forms` and a passed in transform `xf`"
+  [state form-id xf]
+  (update-forms state
+    (get-in state form-id)
+    (comp xf :form)))
+
+#?(:cljs (defmutation commit-to-entity
+           "Om Mutation: Commit the changes on the form. This will cause the state of the pristine cache to match what you see on the
+           form. Note, until tempids are rewritten a form will appear modified (unsaved changes).
+
+           `form` is the COMPLETE PROPS of a form. NOT AN IDENT.
+           `remote` is true if you wish the form to submit changes to the server. If you do not use this option it will
+           be up to you to define how you will persist any data to the server.
+           "
+           [{:keys [form remote]}]
+           (action [{:keys [state]}] (swap! state entity-xform (form-ident form) commit-state))
+           (remote [{:keys [state ast target]}]
+             (let [delta (when target (diff-form form))]
+               (and remote (update ast :params #(-> % (dissoc :remote) (assoc :delta delta))))))))
+
+#?(:cljs (defmutation reset-from-entity
+           "Om Mutation: Reset the entity back to its original state before editing. This will be the last state that
+           the entity had just following initialization or the last commit.
+
+           `form-id` is the ident of the entity acting as a form.
+           "
+           [{:keys [form-id]}]
+           (action [{:keys [state]}] (swap! state entity-xform form-id reset-entity))))
+
 (defn reset-from-entity!
   "Reset the form from a given entity in your application database using an Om transaction and update the validation state.
    You may compose your own Om transactions and use `(f/reset-from-entity {:form-id [:entity id]})` directly."
@@ -943,32 +973,3 @@
          form-root-key]
         rerender))))

-(defn entity-xform
-  "Modify the form's (under `form-id`) using `update-forms` and a passed in transform `xf`"
-  [state form-id xf]
-  (update-forms state
-    (get-in state form-id)
-    (comp xf :form)))
-
-#?(:cljs (defmutation commit-to-entity
-           "Om Mutation: Commit the changes on the form. This will cause the state of the pristine cache to match what you see on the
-           form. Note, until tempids are rewritten a form will appear modified (unsaved changes).
-
-           `form` is the COMPLETE PROPS of a form. NOT AN IDENT.
-           `remote` is true if you wish the form to submit changes to the server. If you do not use this option it will
-           be up to you to define how you will persist any data to the server.
-           "
-           [{:keys [form remote]}]
-           (action [{:keys [state]}] (swap! state entity-xform (form-ident form) commit-state))
-           (remote [{:keys [state ast target]}]
-             (let [delta (when target (diff-form form))]
-               (and remote (update ast :params #(-> % (dissoc :remote) (assoc :delta delta))))))))
-
-#?(:cljs (defmutation reset-from-entity
-           "Om Mutation: Reset the entity back to its original state before editing. This will be the last state that
-           the entity had just following initialization or the last commit.
-
-           `form-id` is the ident of the entity acting as a form.
-           "
-           [{:keys [form-id]}]
-           (action [{:keys [state]}] (swap! state entity-xform form-id reset-entity))))


Message failures should probably only log as trace.

--- src/onyx/messaging/netty_tcp.clj
+++ src/onyx/messaging/netty_tcp.clj
@@ -336,7 +336,7 @@
   (.addListener f (reify GenericFutureListener
                     (operationComplete [_ _]
                       (when-not (.isSuccess f)
-                        (timbre/error (ex-info "Message failed to send" {:cause (.cause f)}))
+                        (timbre/trace (ex-info "Message failed to send" {:cause (.cause f)}))
                         (reset-connection connection))))))

 (defn make-pending-chan [messenger]


successfully git show hash:file

successfully git show hash:file

--- src/atom_finder/atom_patch.clj
+++ src/atom_finder/atom_patch.clj
@@ -3,29 +3,67 @@
    [atom-finder.util :refer :all]
    [clojure.pprint :refer [pprint]]
    [clj-jgit.porcelain :as gitp]
+   [clj-jgit.querying :as gitq]
    [clj-jgit.internal :as giti]
    )
   (:import
    [org.eclipse.jgit.lib ObjectReader]
+   [org.eclipse.jgit.treewalk TreeWalk filter.PathFilter]
    )
   )

 (def commit-hash "3bb246b3c2d11eb3f45fab3b4893d46a47d5f931")
 (def repo (gitp/load-repo (expand-home "~/opt/src/gcc")))

-(defn commit-files
+(defn commit-finder
   "Return full source for each file changed in a commit"
   [repo commit-hash]
   (let [object-reader (.. repo getRepository newObjectReader)
         object-loader (.open object-reader (giti/resolve-object commit-hash repo))
         object-stream (.openStream object-loader)]

-    (.copyTo object-loader java.lang.System/out)
-    (.release object-reader)
+    ;(.copyTo object-loader java.lang.System/out)
+    (let [bytes (.getBytes object-loader)]
+      (.release object-reader)
+      (String. bytes)
+    )
     ; (don't forget to release the ObjectReader when done) See also this article for more details
   ))

-(commit-files repo commit-hash)
+(defn rev-walk-commit
+  "make a new revwalk to find given commit"
+  [repo commit-hash]
+  (gitq/find-rev-commit repo (giti/new-rev-walk repo) commit-hash)
+  )
+
+(defn object-loader-string
+  "dump the contents of an ObjectLoader to a String"
+  [loader]
+  (->> loader .getBytes String.))
+
+(defn commit-file
+  "Return full source for each file changed in a commit"
+  [repo commit-hash file-name]
+  (let [repository (.getRepository repo)
+        commit (giti/resolve-object commit-hash repo)
+        rev-commit (rev-walk-commit repo commit-hash)
+        tree      (.getTree rev-commit)
+        tree-walk (doto (TreeWalk. repository) (.setRecursive true) (.addTree tree))
+        ]
+
+    (.setFilter tree-walk (PathFilter/create file-name)) ; Use PathFilterGroup???? http://download.eclipse.org/jgit/docs/jgit-2.0.0.201206130900-r/apidocs/org/eclipse/jgit/treewalk/filter/PathFilter.html
+    (.next tree-walk)
+
+    (let [object-id (.getObjectId tree-walk 0)
+          loader (.open repository object-id)]
+      (object-loader-string loader)
+      )
+  ))
+
+
+(print (commit-file repo commit-hash "gcc/testsuite/g++.dg/debug/dwarf2/integer-typedef.C"))
+(print (commit-file repo commit-hash "integer-typedef.C"))
+(print (commit-file repo commit-hash "gcc/c-family/ChangeLog"))

 (defn atom-removed-in-commit?
   [repo commit-hash atom-classifier]


lein-release plugin: bumped version from 0.4.2 to 0.4.3-SNAPSHOT for next development cycle

--- re_view/project.clj
+++ re_view/project.clj
@@ -1,4 +1,4 @@
-(defproject re-view "0.4.2"
+(defproject re-view "0.4.3-SNAPSHOT"
   :description "ClojureScript React Library"
   :url "https://www.github.com/braintripping/re-view/tree/master/re_view"
   :license {:name "Eclipse Public License"


s/'(...)/[]/

s/'(...)/[]/

--- src/babel/english/grammar.cljc
+++ src/babel/english/grammar.cljc
@@ -157,16 +157,16 @@
    {:comment "c00"
     :schema-symbol 'c00 ;; used by over-each-parent to know where to put children.
     :first :comp
-    :comp {:synsem {:subcat '()}}
-    :head {:synsem {:subcat '()}}}))
+    :comp {:synsem {:subcat []}}
+    :head {:synsem {:subcat []}}}))

 (def h00
   (unify-check
    head-first
    {:comment "h00"
     :schema-symbol 'h00 ;; used by over-each-parent to know where to put children.
-    :comp {:synsem {:subcat '()}}
-    :head {:synsem {:subcat '()}}}))
+    :comp {:synsem {:subcat []}}
+    :head {:synsem {:subcat []}}}))

 (def c11
   (unify-check
@@ -268,7 +268,7 @@
                 :cat cat
                 :mod mod
                 :subcat {:1 argument
-                         :2 '()}
+                         :2 []}
                 :sem semantics}
        :comp {:phrasal true
               :synsem {:cat :verb
@@ -276,7 +276,7 @@
                        :sem semantics
                        :slash true
                        :subcat {:1 argument
-                                :2 '()}}}
+                                :2 []}}}
        :head {:phrasal false
               :synsem {:cat cat
                        :sem semantics}}
@@ -290,7 +290,7 @@
                 (let [propernoun (atom :top)
                       head-sem (atom :top)
                       mod-sem (atom {:subj head-sem})
-                      rest-mod '()]
+                      rest-mod []]
                   {:rule "nbar1"
                    :synsem {:reflexive false
                             :propernoun propernoun
@@ -349,7 +349,7 @@
                    :synsem {:agr {:number number-agreement}
                             :reflexive false
                             :cat :noun
-                            :mod '()
+                            :mod []
                             :propernoun propernoun
                             :sem {:number number-agreement}}
                    :head {:phrasal false
@@ -431,7 +431,7 @@
           comp-sem (atom :top)
           head-mod (atom :top)
           head-synsem (atom {:cat cat
-                             :subcat '()
+                             :subcat []
                              :mod head-mod
                              :sem head-sem})]
       {:phrasal true
@@ -440,14 +440,14 @@
                       :rest head-mod}
                 :sem head-sem
                 :slash false
-                :subcat '()}
+                :subcat []}
        :head {:rule "noun-phrase2"
               :phrasal true
               :synsem head-synsem}
        :comp {:phrasal true
               :synsem {:slash true
                        :subcat {:1 head-synsem
-                                :2 '()}
+                                :2 []}
                        :sem comp-sem}}}))
    (unify-check
     {:rule "slash-obj"}
@@ -459,14 +459,14 @@
        :synsem {:cat cat
                 :slash true
                 :subcat {:1 second-arg
-                         :2 '()}}
+                         :2 []}}
        :comp {:synsem first-arg}
        :head {:synsem {:cat cat
                        :subcat {:1 first-arg
                                 :2 second-arg}}}})
     {:synsem {:aux false}
      :head {:synsem {:aux false}}
-     :comp {:synsem {:subcat '()
+     :comp {:synsem {:subcat []
                      :case :nom
                      :cat :noun}}}

@@ -479,7 +479,7 @@
     )])

 (defn aux-is-head-feature [phrase]
-  (cond (= :verb (get-in phrase '(:synsem :cat)))
+  (cond (= :verb (get-in phrase [:synsem :cat]))
         (unify-check phrase
                 (let [ref (atom :top)]
                   {:synsem {:aux ref}
@@ -487,7 +487,7 @@
         true phrase))

 (defn modal-is-head-feature [phrase]
-  (cond (= :verb (get-in phrase '(:synsem :cat)))
+  (cond (= :verb (get-in phrase [:synsem :cat]))
         (unify-check phrase
                 (let [ref (atom :top)]
                   {:synsem {:modal ref}


+"stay": +PP[at]

+"stay": +PP[at]

--- src/babel/english/lexicon.cljc
+++ src/babel/english/lexicon.cljc
@@ -1683,7 +1683,9 @@
                      :sem {:pred :start}}}

    "stay" {:synsem {:cat :verb
-                    :sem {:pred :stay}}}
+                    :sem {:pred :stay}
+                    :subcat {:2 {:cat :prep
+                                 :sem {:pred :at}}}}}

    "stain" {:synsem {:cat :verb
                      :sem {:pred :stain}}}


use e(ncyclopedia)/animal

use e(ncyclopedia)/animal

--- src/babel/english/lexicon.cljc
+++ src/babel/english/lexicon.cljc
@@ -1,12 +1,12 @@
 (ns babel.english.lexicon
   (:refer-clojure :exclude [get-in merge])
   (:require
+   [babel.encyclopedia :as e]
    [babel.lexiconfn :refer (compile-lex if-then
                                         map-function-on-map-vals unify)]
    [babel.english.morphology :as morph]
    [babel.english.pos :refer [adjective
                               agreement-noun
-                              animal
                               common-noun
                               countable-noun
                               feminine-noun
@@ -352,8 +352,8 @@
    (unify agreement-noun
           common-noun
           countable-noun
-          {:synsem {:sem (unify animal {:pred :gatto
-                                        :pet true})}})
+          {:synsem {:sem (unify e/animal {:pred :gatto
+                                          :pet true})}})

    "change" {:synsem {:cat :verb
                       :sem {:pred :change}}} ;; TODO: add reflexive sense
@@ -479,8 +479,9 @@
    (unify agreement-noun
           common-noun
           countable-noun
-          {:synsem {:sem (unify animal {:pred :cane
-                                        :pet true})}})
+          {:synsem {:sem (unify e/animal {:pred :cane
+                                          :pet true})}})
+
    "earn"  {:synsem {:cat :verb
                      :sem {:pred :earn
                            :subj {:human true}}}}


fix condition for removing :note from subject

--- src/babel/english/morphology.cljc
+++ src/babel/english/morphology.cljc
@@ -12,8 +12,8 @@
 (defn fo [input & {:keys [from-language show-notes]
                    :or {from-language nil
                         show-notes true}}]
-  (let [input (if (or (not (= "it" from-language))
-                      (not (= "fr" from-language))
+  (let [input (if (or (and (not (= "it" from-language))
+                           (not (= "fr" from-language)))
                       (not (= :past (get-in input [:synsem :sem :tense])))
                       (not (= :perfect (get-in input [:synsem :sem :aspect]))))
                 (dissoc-paths input [[:comp :english :note]


add post-condition to parse-config-file

add post-condition to parse-config-file

--- src/puppetlabs/trapperkeeper/core.clj
+++ src/puppetlabs/trapperkeeper/core.clj
@@ -153,7 +153,8 @@

 (defn- parse-config-file
   [config-file-path]
-  {:pre [(not (nil? config-file-path))]}
+  {:pre [(not (nil? config-file-path))]
+   :post [(map? %)]}
   (when-not (.canRead (file config-file-path))
     (throw (FileNotFoundException.
              (format


Rename alter-table to add-column.

Rename alter-table to add-column.

--- src/circleci/db/migrations.clj
+++ src/circleci/db/migrations.clj
@@ -26,7 +26,7 @@
                      [:environment :text]
                      [:features :text]))

-(defn alter-table [name & specs]
+(defn add-column [name & specs]
    (jdbc/do-commands
     (format "ALTER TABLE %s ADD %s"
      (as-str name)
@@ -39,5 +39,5 @@

 (defmigration "add beta checkbox"
   (println "alter-table: beta checkbox")
-  (alter-table :beta_notify [:contact :boolean]))
+  (add-column :beta_notify [:contact :boolean]))


fix cron

fix cron

--- src/clj/salava/metabadge/cron.clj
+++ src/clj/salava/metabadge/cron.clj
@@ -29,34 +29,39 @@
                          ["INSERT IGNORE INTO user_badge_metabadge (user_badge_id, meta_badge, meta_badge_req, last_modified) VALUES (?,?,?,?)"
                           (:id user_badge) m (:required_badge data) (:last_modified data)]))))))

+;;TODO why does it skip some badges
 (defn- get-metabadge! [ctx db-conn factory-url user_badge]
   (let [url (str factory-url "/v1/assertion/metabadge/?url=" (u/url-encode (:assertion_url user_badge)))
         metabadges (:metabadge (fetch-json-data url))]
     (when-not (empty? metabadges)
       (doseq [metabadge metabadges
               :let [metabadge-badge-content (when-not (-> metabadge :badge :received) (fetch-json-data (-> metabadge :badge :url)))
-                    user_metabadge_id (when (-> metabadge :badge :received) (db/user-badge-by-assertion ctx (-> metabadge :badge :url)))
+                    user_metabadge (when (-> metabadge :badge :received) (db/user-badge-by-assertion ctx (-> metabadge :badge :url)))
                     {:keys [description criteria image]} metabadge-badge-content]]

         (if-not (-> metabadge :badge :received)
           (jdbc/execute! db-conn
                          ["INSERT IGNORE INTO factory_metabadge (id, name, description, criteria, image_file, min_required, ctime, mtime ) VALUES (?,?,?,?,?,?,?,?)"
                           (:id metabadge) (:name metabadge) description (u/md->html criteria) (u/file-from-url ctx image) (:min_required metabadge) (u/now) (u/now)])
-          (jdbc/execute! db-conn
-                         ["INSERT IGNORE INTO user_metabadge_received (metabadge_id, user_badge_id, user_id, name, min_required, last_modified) VALUES (?,?,?,?,?,?)"
-                          (:id metabadge) (:id user_metabadge_id) (:user_id user_badge) (:name metabadge) (:min_required metabadge) (:last_modified user_badge) ])
-          )
+
+          (doseq [um user_metabadge]
+            (jdbc/execute! db-conn
+                           ["INSERT IGNORE INTO user_metabadge_received (metabadge_id, user_badge_id, user_id, name, min_required, last_modified) VALUES (?,?,?,?,?,?)"
+                            (:id metabadge) (:id um) (:user_id user_badge) (:name metabadge) (:min_required metabadge) (:last_modified user_badge) ])
+            ))
         (doseq [badge (:required_badges metabadge)
                 :let [required-badge-content (when-not (:received badge) (fetch-json-data (:url badge)))
-                      user-badge-id (when (:received badge) (db/user-badge-by-assertion ctx (:url badge)))
+                      user-badge (when (:received badge) (db/user-badge-by-assertion ctx (:url badge)))
                       {:keys [name description image criteria]} required-badge-content]]
           (if-not (:received badge)
             (jdbc/execute! db-conn
                            ["INSERT IGNORE INTO factory_metabadge_required (metabadge_id, required_badge_id, name, description, criteria, image_file, ctime, mtime) VALUES (?,?,?,?,?,?,?,?)"
                             (:id metabadge) (:id badge) name description (u/md->html criteria) (u/file-from-url ctx image) (u/now) (u/now)])
-            (jdbc/execute! db-conn
-                           ["INSERT IGNORE INTO user_metabadge_required_received (metabadge_id, user_metabadge_id, user_required_badge_id, user_id, last_modified) VALUES (?,?,?,?,?)"
-                            (:id metabadge) (:id user_metabadge_id) (:id user-badge-id) (:user_id user_badge) (:last_modified user_badge)])
+            (doseq [um user_metabadge]
+              (doseq [ub user-badge]
+                (jdbc/execute! db-conn
+                               ["INSERT IGNORE INTO user_metabadge_required_received (metabadge_id, user_metabadge_id, user_required_badge_id, user_id, last_modified) VALUES (?,?,?,?,?)"
+                                (:id metabadge) (:id um) (:id ub) (:user_id user_badge) (:last_modified user_badge)])))
             ))))))

 (defn- badge->metabadge! [ctx factory-url]


test for 24/7 News Cycle

test for 24/7 News Cycle

--- src/clj/test/cards-operations.clj
+++ src/clj/test/cards-operations.clj
@@ -5,4 +5,28 @@
     (new-game (default-corp) (default-runner))
     (is (= 5 (:credit (get-corp))))
     (core/play state :corp {:card (first (:hand (get-corp)))})
-    (is (= 9 (:credit (get-corp))))))+    (is (= 9 (:credit (get-corp))))))
+
+(deftest news-cycle
+  (do-game
+    (new-game (default-corp [(qty "Breaking News" 2) (qty "24/7 News Cycle" 3)])
+              (default-runner))
+    (play-from-hand state :corp "Breaking News" "New remote")
+    (play-from-hand state :corp "Breaking News" "New remote")
+    (let [ag1 (get-in @state [:corp :servers :remote1 :content 0])
+          ag2 (get-in @state [:corp :servers :remote2 :content 0])]
+      (core/gain state :corp :click 3)
+      (core/advance state :corp {:card (refresh ag1)})
+      (core/advance state :corp {:card (refresh ag1)})
+      (core/score state :corp {:card (refresh ag1)})
+      (core/advance state :corp {:card (refresh ag2)})
+      (core/advance state :corp {:card (refresh ag2)})
+      (core/score state :corp {:card (refresh ag2)})
+      (take-credits state :corp)
+      (is (= 0 (:tag (get-runner)))) ; tags cleared
+      (take-credits state :runner)
+      (play-from-hand state :corp "24/7 News Cycle")
+      (prompt-card :corp (find-card "Breaking News" (:scored (get-corp))))
+      (is (= 1 (:agenda-point (get-corp))) "Forfeited Breaking News")
+      (prompt-card :corp (find-card "Breaking News" (:scored (get-corp))))
+      (is (= 2 (:tag (get-runner))) "Runner given 2 tags"))))


Add dummy ajax request

Add dummy ajax request

--- src/cljs/battle_console/game.cljs
+++ src/cljs/battle_console/game.cljs
@@ -107,7 +107,8 @@

 (defn- add-action
   "Processes a new action"
-  [])
+  []
+  (GET "http://rules.api.orionsbelt.eu/game/turn/p1?context={}"))

 (defn- render-action-console
   "Renders the action management console"


Activity add page

Activity add page

--- src/cljs/elevent_client/core.cljs
+++ src/cljs/elevent_client/core.cljs
@@ -13,8 +13,8 @@
       [alandipert.storage-atom :refer [local-storage]]
       [ajax.core :refer [DELETE GET POST PUT]]
       [cljs-time.coerce :refer [from-string]]
-      [cljs-time.core :refer [after? at-midnight now]]
-      [cljs-time.format :refer [formatter formatters unparse]]
+      [cljs-time.core :refer [after? at-midnight now plus hours]]
+      [cljs-time.format :refer [formatter formatters unparse parse]]
       [datascript :as d]
       [garden.core :refer [css]]
       [secretary.core :as secretary :refer-macros [defroute]]
@@ -722,6 +722,117 @@
                                         :on-click #(create-event @form)}
              "Add"]]]]]))))

+(defn event-activity-edit-page [event-id]
+  (let [form (atom {:EventId event-id})
+        validator (validation-set (presence-of :Name)
+                                  (presence-of :StartTime)
+                                  (presence-of :EndTime)
+                                  (format-of   :EnrollmentCap :format #"[0-9_]"
+                                                              :allow-nil true
+                                                              :allow-blank true
+                                                              :message "Please enter a number"))
+        reset-form!
+        (fn []
+          (reset! form (atom {:EventId event-id})))]
+    (fn [event-id]
+      (let [{:keys [Name Location EnrollmentCap StartTime EndTime Description]}
+            @form
+
+            errors
+            (validator @form)
+
+            event
+            (into {} (seq (d/entity @events-db event-id)))
+
+            activities
+            (map #(d/entity @activities-db %)
+                 (d/q '[:find [?e ...]
+                        :in $ ?event-id
+                        :where
+                        [?e :EventId ?event-id]]
+                      @activities-db
+                      event-id))
+
+            create-activity
+            (fn [form]
+              (when (empty? errors)
+                (activities-endpoint :create
+                                     (let [start-time (:StartTime form)
+                                           end-time   (:EndTime form)]
+                                       (assoc form
+                                         :StartTime (unparse (:date-hour-minute-second formatters)
+                                                             (from-string start-time))
+                                         :EndTime (unparse (:date-hour-minute-second formatters)
+                                                           (from-string end-time))))
+                                     #(reset-form!))))]
+        (when (seq event)
+          [:div.ui.page.grid
+           [:div.sixteen.wide.column
+            [:div.ui.segment
+             [:div.ui.vertical.segment
+              [:h2.ui.header
+               (:Name event)]]
+             [:div.ui.vertical.segment
+              [:h2.ui.header
+               "Add activity"]
+              [:form.ui.form
+               [:div.one.field
+                [:div.required.field {:class (when (and Name (:Name errors))
+                                               "error")}
+                 [:label "Name"]
+                 [input-atom :text (r/wrap Name swap! form assoc :Name)]]]
+               [:div.two.fields
+                [:div.field
+                 [:label "Location"]
+                 [input-atom :text (r/wrap Location swap! form assoc :Location)]]
+                [:div.field {:class (when (and EnrollmentCap (:EnrollmentCap errors))
+                                      "error")}
+                 [:label "Enrollment Cap"]
+                 [input-atom :text (r/wrap EnrollmentCap swap! form assoc :EnrollmentCap)]]]
+               [:div.two.fields =
+                [:div.required.field {:class (when (and StartTime (:StartTime errors))
+                                               "error")}
+                 [:label "Start Time"]
+                 [input-atom :datetime-local
+                  (r/wrap StartTime swap! form assoc :StartTime)
+                  #(or % (unparse (:date-hour-minute formatters) (now))) ; todo: date inputs clear on input
+                  #(unparse (:date-hour-minute formatters) (from-string %))]]
+                [:div.required.field {:class (when (and EndTime (:EndTime errors))
+                                               "error")}
+                 [:label "End Time"]
+                 [input-atom :datetime-local
+                  (r/wrap EndTime swap! form assoc :EndTime)
+                  #(or % (unparse (:date-hour-minute formatters) (now)))
+                  #(unparse (:date-hour-minute formatters) (from-string %))]]]
+               [:div.field
+                [:label "Description"]
+                [input-atom :textarea
+                 (r/wrap Description swap! form assoc :Description)]]
+               [:button.ui.primary.button {:class (when (seq errors) "disabled")
+                                           :type :submit
+                                           :on-click #(create-activity @form)}
+                "Add"]]]
+             [:div.ui.vertical.segment
+              [:h2.ui.header
+               "Activities"]
+              [:table.ui.table
+               [:thead
+                [:tr
+                 [:th "Start Time"]
+                 [:th "End Time"]
+                 [:th "Activity"]
+                 [:th "Location"]]]
+               [:tbody
+                (for [activity activities]
+                  ^{:key (:ActivityId activity)}
+                  [:tr
+                   [:td (let [start (from-string (:StartTime activity))]
+                          (unparse datetime-formatter start))]
+                   [:td (let [end   (from-string (:EndTime   activity))]
+                          (unparse datetime-formatter end))]
+                   [:td (:Name activity)]
+                   [:td (:Location activity)]])]]]]]])))))
+
 (defn event-page [event-id]
   (let [event (into {} (seq (d/entity @events-db event-id)))

@@ -777,10 +888,7 @@
           [:p (:Description event)]]
          [:div.ui.vertical.segment
           [:h2.ui.header
-           "Activities"
-           [:a.ui.right.floated.small.button
-            {:href (event-activity-add-route event)}
-            "View/Edit"]]
+           "Activities"]
           [:table.ui.table
            [:thead
             [:tr
@@ -1042,10 +1150,11 @@

             register
             (fn [form]
-              (attendees-endpoint :create
-                                  {:UserId (get-in @session [:user :UserId])
-                                   :EventId event-id}
-                                  #(js/location.replace (events-route))))]
+              (when (empty? errors)
+                (attendees-endpoint :create
+                                    {:UserId (get-in @session [:user :UserId])
+                                     :EventId event-id}
+                                    #(js/location.replace (events-route)))))]
         (when (seq event)
           [:div.ui.stackable.page.grid
            [:div.sixteen.wide.column


add message to Oaktown Renovation

add message to Oaktown Renovation

--- src/clj/game/cards-agendas.clj
+++ src/clj/game/cards-agendas.clj
@@ -280,6 +280,7 @@
    "Oaktown Renovation"
    {:install-state :face-up
     :events {:advance {:req (req (= (:cid card) (:cid target)))
+                       :msg (msg "gain " (if (>= (:advance-counter (get-card state card)) 5) "3" "2") " [Credits]")
                        :effect (req (gain state side :credit
                                           (if (>= (:advance-counter (get-card state card)) 5) 3 2)))}}}


Use threading macro

Use threading macro

--- src/clj/rumahsewa141/views.clj
+++ src/clj/rumahsewa141/views.clj
@@ -29,7 +29,11 @@
          transactions     (future (get-transactions-fn
                                    {:max_items max-items
                                     :offset (* (dec page) max-items)}))
-         first-page       (inc (* (quot (dec page) prange) prange))
+         first-page       (-> page
+                              dec
+                              (quot prange)
+                              (* prange)
+                              inc)
          pages            (take prange (iterate inc first-page))
          {tcount :tcount} @get-count-result
          total-pages      (if (zero? (mod tcount max-items))


Added temporary debug output.

Added temporary debug output.

--- src/clj/traveler/templates.clj
+++ src/clj/traveler/templates.clj
@@ -41,6 +41,7 @@
     :user-name      user-name
     :main-menu      main-menu
     :user-menu      user-menu
+    :page-content   (prn-str (:helmsman request))
     :page-content   page-content
     :extra-styles   extra-styles
     :extra-scripts  extra-scripts


commented out old line for debugging, will switch back.

--- src/clj/traveler/templates.clj
+++ src/clj/traveler/templates.clj
@@ -41,8 +41,8 @@
     :user-name      user-name
     :main-menu      main-menu
     :user-menu      user-menu
+    ;;; :page-content   page-content
     :page-content   (prn-str (:helmsman request))
-    :page-content   page-content
     :extra-styles   extra-styles
     :extra-scripts  extra-scripts
     :ng-app         ng-app


Add command processing for economic model.

--- src/cljs/beatha/automaton.cljs
+++ src/cljs/beatha/automaton.cljs
@@ -192,6 +192,14 @@
   (let [w (reductions #(+ % %2) (vals m))
         r (rand (last w))]
     (nth (keys m) (count (take-while #(<= % r) w)))))
+
+;;; from https://groups.google.com/d/msg/clojure/UdFLYjLvNRs/NqlA7wnLCE0J
+(defn- deep-merge
+  "Recursively merges maps. If vals are not maps, the last value wins."
+  [& vals]
+  (if (every? map? vals)
+    (apply merge-with deep-merge vals)
+    (last vals)))

 (def market-model
   (let [env (atom {:tax-rate 0.05
@@ -308,7 +316,8 @@
           next))

       InformationChannelsSpecification
-      (process-info-channel [this ic])
+      (process-info-channel [this ic]
+        (go (while true (let [cmd (<! ic)] (swap! env deep-merge cmd)))))
       (fill-output-info-channel [this grid oc]
         (put! oc (-> @env
                      (dissoc :utility)


Move focus code into helper

Move focus code into helper

--- src/cljs/retrobard/client.cljs
+++ src/cljs/retrobard/client.cljs
@@ -187,6 +187,12 @@
   (om/set-state! owner :editing false)
   (cb text))

+(defn focus-and-set-cursor [textarea]
+  (let [val (.-value textarea)]
+    (.focus textarea)
+    (set! (.-value textarea) "")
+    (set! (.-value textarea) val)))
+
 (defn editable [data owner {:keys [edit-key on-edit] :as opts}]
   (reify
     om/IInitState
@@ -194,13 +200,9 @@
       {:editing false})
     om/IDidUpdate
     (did-update [this prev-props prev-state]
-      (let [input (om/get-node owner "input")
-            val (.-value input)]
-        (when (and (om/get-state owner :editing)
-                   (not (:editing prev-state)))
-          (.focus input)
-          (set! (.-value input) "")
-          (set! (.-value input) val))))
+      (when (and (om/get-state owner :editing)
+                 (not (:editing prev-state)))
+        (focus-and-set-cursor (om/get-node owner "input"))))
     om/IRenderState
     (render-state [_ {:keys [editing]}]
       (let [text (get data edit-key)]


refactored rectangle and rounded rectangle

--- src/cljs/zee3/draw/shapes.cljs
+++ src/cljs/zee3/draw/shapes.cljs
@@ -10,28 +10,15 @@

 (defn rectangle [stage config]
   (let [mc (assoc (merge config/base config) :type "rectangle")
-        {:keys [x y width height]} mc
-	ctx (get @contexts stage)]
-    (base ctx mc
-      (fn [] (.fillRect ctx x y width height)))
+       ctx (get @contexts stage)]
+    (draw-rectangle ctx mc)
     (base-config stage mc)))

 (defn rounded-rectangle [stage config]
   (let [mc (assoc (merge config/rounded-rectangle config) :type "rounded-rectangle")
-        {:keys [cornerRadius x y width height lineWidth fillStyle strokeStyle]} mc
         ctx (get @contexts stage)]
-    (base ctx mc (fn []
-      (.moveTo ctx (+ x cornerRadius) y)
-      (.lineTo ctx (- (+ x width) cornerRadius) y)
-      (.quadraticCurveTo ctx (+ x width) y (+ x width) y)
-      (.lineTo ctx (+ x width) (- (+ y height) cornerRadius))
-      (.quadraticCurveTo ctx (+ x width) (+ y height) (- (+ x width) cornerRadius) (+ y height))
-      (.lineTo ctx (+ x cornerRadius) (+ y height))
-      (.quadraticCurveTo ctx x (+ y height) x (- (+ y height) cornerRadius))
-      (.lineTo ctx x (+ y cornerRadius))
-      (.quadraticCurveTo ctx x y (+ x cornerRadius) y)))
+    (draw-rounded-rectangle ctx mc)
     (base-config stage mc)))
-

 (defn circle [stage config]
   (let [mc (assoc (merge config/circle config) :type "circle") ctx (get @contexts stage) ]
@@ -56,6 +43,24 @@
 (defn base-config [stage config]
   (swap! entities conj config))

+(defn draw-rectangle [ctx config]
+  (let [{:keys [x y width height]} config]
+    (base ctx mc
+      (fn [] (.fillRect ctx x y width height)))))
+
+(defn draw-rounded-rectangle [ctx config]
+  (let [{:keys [cornerRadius x y width height lineWidth fillStyle strokeStyle]} config]
+    (base ctx mc (fn []
+      (.moveTo ctx (+ x cornerRadius) y)
+      (.lineTo ctx (- (+ x width) cornerRadius) y)
+      (.quadraticCurveTo ctx (+ x width) y (+ x width) y)
+      (.lineTo ctx (+ x width) (- (+ y height) cornerRadius))
+      (.quadraticCurveTo ctx (+ x width) (+ y height) (- (+ x width) cornerRadius) (+ y height))
+      (.lineTo ctx (+ x cornerRadius) (+ y height))
+      (.quadraticCurveTo ctx x (+ y height) x (- (+ y height) cornerRadius))
+      (.lineTo ctx x (+ y cornerRadius))
+      (.quadraticCurveTo ctx x y (+ x cornerRadius) y)))))
+
 (defn draw-circle [ctx config]
   (let [{:keys [centerX centerY radius]} config]
     (base ctx config (fn []


Basic PGN game import.

Basic PGN game import.

Doesn't yet handle comments or variations, those are ignored.

--- src/clojure/clj_chess/game.clj
+++ src/clojure/clj_chess/game.clj
@@ -3,7 +3,8 @@
   Work in progress, use at your own risk."
   (:require [clojure.zip :as zip]
             [clojure.pprint :refer [cl-format]]
-            [clj-chess.board :as board])
+            [clj-chess.board :as board]
+            [clj-chess.pgn :as pgn])
   (:import org.apache.commons.lang3.text.WordUtils))

 (defonce ^:private counter (atom 0))
@@ -424,3 +425,16 @@
        " "
        (tag-value game "Result")
        "\n"))
+
+
+(defn from-pgn
+  "Creates a game from a PGN string. Doesn't yet handle comments or
+  variations."
+  [pgn-string]
+  (let [parsed-pgn (pgn/parse-pgn pgn-string)
+        game (reduce #(apply set-tag %1 %2)
+                     (new-game)
+                     (rest (second parsed-pgn)))]
+    (-> game (add-san-move-sequence
+               (filter string? (-> parsed-pgn (nth 2) rest))))))
+


exceptions caught and handled during query execution

--- src/com/billpiel/sayid/query2.clj
+++ src/com/billpiel/sayid/query2.clj
@@ -232,9 +232,12 @@
   (let [path (drop-last query-coll)
         pred (last query-coll)]
     (fn [v]
-      (->> v
-           (get-some path)
-           (eq* pred)))))
+      (try
+        (->> v
+             (get-some path)
+             (eq* pred))
+        (catch Exception ex
+          nil)))))

 (defn some-mk-query-fn
   [queries]


link to self in each post title

link to self in each post title

--- src/yablog/hiccup.clj
+++ src/yablog/hiccup.clj
@@ -19,6 +19,9 @@

 (defn hiccup-entry [page]
   (into [:div {:class "entry"}
-         [:h1 {:class "title"} (or (:subject page) (:title page))]
+         [:h1 {:class "title"}
+          (page/title page)
+          [:span {:class "permalink"}
+           [:a {:href (page/url page)} "#"]]]
          [:h2 {:class "date"} (format-time (:date page))]]
         (hiccup-entry-body page)))


Use defconfig for the defentity macro configuration

--- src/main/workflo/macros/entity.clj
+++ src/main/workflo/macros/entity.clj
@@ -1,34 +1,25 @@
 (ns workflo.macros.entity
   (:require [clojure.spec :as s]
             [clojure.string :as string]
+            [workflo.macros.config :refer [defconfig]]
             [workflo.macros.query :as q]
             [workflo.macros.registry :refer [defregistry]]
             [workflo.macros.specs.entity]
             [workflo.macros.util.form :as f]
             [workflo.macros.util.symbol :refer [unqualify]]))

-;;;; Configuration
+;;;; Configuration options for the defentity macro

-(defonce ^:private +configuration+
-  (atom {:auth-query nil}))
-
-(defn configure!
-  "Configures how entities are created with defentity and how aspects
-   like authorization are performed against them. Supports the
-   following options:
-
-   :auth-query - a function that takes a parsed query and entity data;
-                 this query result from this function is then passed to
-                 the entity's auth function to perform authorization."
-  [{:keys [auth-query] :as options}]
-  (swap! +configuration+ assoc
-         :auth-query auth-query))
-
-(defn get-config
-  "Returns the configuration for a given configuration key, e.g.
-   :auth-query."
-  [key]
-  (@+configuration+ key))
+(defconfig entity
+  ;; Configures how entities are created with defentity and how aspects
+  ;; like authorization are performed against them. Supports the
+  ;; following options:
+  ;;
+  ;; :auth-query - a function that takes a parsed query and entity data;
+  ;;               this query result from this function is then passed
+  ;;               to the entity's auth function to perform
+  ;;               authorization.
+  {:auth-query nil})

 ;;;; Entity registry

@@ -45,7 +36,7 @@
     (if auth-fn
       (let [auth-query   (some-> entity :auth-query
                                  (q/bind-query-parameters data))
-            query-result (some-> (get-config :auth-query)
+            query-result (some-> (get-entity-config :auth-query)
                                  (apply [auth-query data]))]
         (auth-fn query-result))
       true)))


Fixing a test to consider the new column separator

--- test/app/test/operationsTest.clj
+++ test/app/test/operationsTest.clj
@@ -20,7 +20,7 @@
   (is (= "aFantastic | 10 | " (fieldValuesToStr [{:len 10} {:len 2}] ["aFantasticValue", 10]))))

 (deftest testRowStr
-  (is (= "ciao   1  " (rowStr [7 3] ["ciao" "1"]))))
+  (is (= "ciao    | 1  " (rowStr [7 3] ["ciao" "1"]))))

 (deftest testColumnLengthRowIsLongerThanHeader
   (is (= 5 (columnLength "ciao" [["a" "zzzzz" "bc"]] 1 ))))


also provide default 'step' value

also provide default 'step' value

--- test/bifurcan/benchmark_test.clj
+++ test/bifurcan/benchmark_test.clj
@@ -623,7 +623,7 @@
                        (map (fn [idx]
                               (let [coll (-> all-colls (nth idx) :label)]
                                 (println "benchmarking" coll)
-                                [coll (benchmark-collection (or n "1e6") step idx)])))
+                                [coll (benchmark-collection (or n "1e6") (or step "1") idx)])))
                        (into {}))]
       (spit "benchmarks/benchmarks.edn" (pr-str descriptor))
       (write-out-csvs descriptor)))


Only trap EOF read errors in site map expectation

--- test/comic_reader/sites_test.clj
+++ test/comic_reader/sites_test.clj
@@ -15,7 +15,9 @@
      (let [opts (read-site-options site)]
        (map? opts))
      (catch java.lang.RuntimeException re
-       nil))
+       (when (not= (.getMessage re)
+                   "EOF while reading")
+         (throw re))))

    (str "Contents of `resources/sites/" site ".clj' "
         "cannot be empty. It must contain exactly "


Generalize topology test driver to EDN data.

This makes it possible to reliably put all sorts of data throught a
topology during testing.

--- clstreams/test/clstreams/testutil/topology_driver.clj
+++ clstreams/test/clstreams/testutil/topology_driver.clj
@@ -1,8 +1,8 @@
 (ns clstreams.testutil.topology-driver
-  (:require [clstreams.landscape :as ldsc]
+  (:require [clstreams.kstreams.serdes :as serdes]
+            [clstreams.landscape :as ldsc]
             [clstreams.testutil.kstreams :refer [default-props]])
-  (:import org.apache.kafka.common.serialization.Serdes
-           org.apache.kafka.streams.kstream.KStreamBuilder
+  (:import org.apache.kafka.streams.kstream.KStreamBuilder
            [org.apache.kafka.streams.processor Processor TopologyBuilder]
            org.apache.kafka.streams.StreamsConfig
            org.apache.kafka.test.ProcessorTopologyTestDriver))
@@ -48,18 +48,24 @@
   {::ldsc/streams
    {:input {::ldsc/topic-name "input"
             ::ldsc/type :stream
-            ::ldsc/keys {::ldsc/serde (Serdes/String)}
-            ::ldsc/values {::ldsc/serde (Serdes/String)}}
+            ::ldsc/keys {::ldsc/serde (serdes/edn-serde)}
+            ::ldsc/values {::ldsc/serde (serdes/edn-serde)}}
     :output {::ldsc/topic-name "output"
              ::ldsc/type :stream
-             ::ldsc/keys {::ldsc/serde (Serdes/String)}
-             ::ldsc/values {::ldsc/serde (Serdes/String)}}}})
+             ::ldsc/keys {::ldsc/serde (serdes/edn-serde)}
+             ::ldsc/values {::ldsc/serde (serdes/edn-serde)}}}})

 (defn single-processor-topology [^Processor processor]
   (let [builder (TopologyBuilder.)]
-    (.addSource builder "src1" (into-array String '("input")))
+    (.addSource builder "src1"
+                (ldsc/key-deserializer single-processor-landscape :input)
+                (ldsc/value-deserializer single-processor-landscape :input)
+                (into-array String '("input")))
     (.addProcessor builder "prc1" processor (into-array String '("src1")))
-    (.addSink builder "snk1" "output" (into-array String '("prc1")))
+    (.addSink builder "snk1" "output"
+              (ldsc/key-serializer single-processor-landscape :output)
+              (ldsc/value-serializer single-processor-landscape :output)
+              (into-array String '("prc1")))
     builder))

 (defn through-kstreams-processor [^Processor processor msgs]


Mongo functions coded AOP functions -- grokking partial/comp

--- src/heroku_releases_copy/core.clj
+++ src/heroku_releases_copy/core.clj
@@ -12,13 +12,16 @@
 (assert (not-empty (System/getenv "HEROKU_RELEASE_TARGET_ORG")))
 (assert (not-empty (System/getenv "HEROKU_RELEASE_TARGET_APPS")))
 (assert (not-empty (System/getenv "MONGO_URL")))
+(assert (not-empty (System/getenv "MONGO_COLLECTION")))

 ;-- Global constants
-(def parameters {:app     (System/getenv "HEROKU_RELEASE_SOURCE_APP")
-                 :org     (System/getenv "HEROKU_RELEASE_TARGET_ORG")
-                 :targets (System/getenv "HEROKU_RELEASE_TARGET_APPS")
-                 :version (System/getenv "HEROKU_RELEASE_SOURCE_APP_VERSION")})
+(def parameters {:app        (System/getenv "HEROKU_RELEASE_SOURCE_APP")
+                 :org        (System/getenv "HEROKU_RELEASE_TARGET_ORG")
+                 :targets    (System/getenv "HEROKU_RELEASE_TARGET_APPS")
+                 :version    (System/getenv "HEROKU_RELEASE_SOURCE_APP_VERSION")
+                 :mongo      (System/getenv "MONGO_URL")
+                 :collection (System/getenv "MONGO_COLLECTION")})

 (def heroku-api-endpoint "https://api.heroku.com")

@@ -46,64 +49,57 @@

 ;-- MongoDB helper functions
-(defn save-to-mongo [configuration-data deployment-data]
-  (let [uri (System/getenv "MONGO_URL")
+(defn save-to-mongo [configuration-data]
+  (let [uri (:mongo parameters)
         {:keys [conn db]} (mg/connect-via-uri uri)]
-; TODO -- update the data
-    (mc/insert-and-return db "orgAppEnv" configuration-data)
+    (mc/update db (:collection parameters) configuration-data)
     (mg/disconnect conn)))

 (defn get-configuration-from-mongo [app-name]
-  (let [uri (System/getenv "MONGO_URL")
+  (let [uri (:mongo parameters)
         {:keys [conn db]} (mg/connect-via-uri uri)
-        configuration-data (mc/find-one db "orgAppEnv" {"app.name" app-name})]
+        configuration-data (mc/find-one-as-map db (:collection parameters) {"app.name" app-name})]
     (mg/disconnect conn)
-    configuration-data))
-
+    (if (nil? configuration-data)
+      (throw (Exception. (str "Failed, cannot find configuration for : " app-name)))
+      configuration-data)))

 ;-- Do the work functions
-
 (defn check-regexes [string regexes-as-strings]
   "Check whether one of a list of regexes matches the string"
   (remove nil? (map #(re-matches (re-pattern %) string) regexes-as-strings)))

 (defn find-target-apps [organization regexes]
-  "Find a filtered list of apps in the organisation whose name matches the regex for example
-    (target-apps 'tme-web-preview' 'bamboo-app1')
-    (target-apps 'tme-web-preview' 'bamboo-.*')
-    (target-apps 'tme-web-preview' '.*-[a-z]{2}')"
-  (let [apps (get-heroku-data (str "/organizations/" organization "/apps"))
-        filtered-apps (mapcat #(check-regexes (:name %) regexes) apps)]
-    filtered-apps))
+  "Find a filtered list of apps in the organisation whose name matches at least one of the regexes"
+  (let [apps (get-heroku-data (str "/organizations/" organization "/apps"))]
+    (mapcat #(check-regexes (:name %) regexes) apps)))

 (defn app-releases [app]
-  "Find releases for app"
   (get-heroku-data (str "/apps/" app "/releases") heroku-options))

-(defn get-release
-  "Get the release data for the most recent (or specific) version of app"
-  ([app] (let [releases (app-releases app)
-               sorted-list (sort-by :version < releases)]
-           (last sorted-list)))
-  ([app version] (let [releases (app-releases app)]
-                   (filter #(= version (:version %)) releases))))
+(defn get-latest-release [app]
+  (let [releases (app-releases app)]
+    (last (sort-by :version < releases))))

-(defn copy-release [slug target]
-  (post-heroku-data (str "/apps/" target "/releases") {"slug" slug}))
+(defn get-specific-release [app version]
+  (let [releases (app-releases app)]
+    (filter #(= version (:version %)) releases)))

-(defn copy-releases [slug targets]
-  (doall (map #(copy-release slug %) targets)))
+(defn copy-release [slug target configuration-data]
+  (let [deployment-data (post-heroku-data (str "/apps/" target "/releases") {"slug" slug})]
+    (merge configuration-data deployment-data)))

 (defn run-copy []
   (let [configuration-data (get-configuration-from-mongo (:app parameters))
         targets (find-target-apps (:org parameters) (str/split (:targets parameters) #"\s+"))
         release (if (nil? (:version parameters))
-                  (get-release (:app parameters))
-                  (get-release (:app parameters) (:version parameters)))
-        deployment-data (copy-releases (get-in release [:slug :id]) targets)]
-    (save-to-mongo configuration-data deployment-data)))
+                  (get-latest-release (:app parameters))
+                  (get-specific-release (:app parameters) (:version parameters)))
+        merge-data (partial merge configuration-data)
+        heroku-copier (comp save-to-mongo merge-data copy-release)] ; AOP on the cheap!
+    (dorun (map #(heroku-copier (get-in release [:slug :id]) %) targets))))

 ;-- Enable lein run
 (defn -main [] (run-copy))


add test for compiler

add test for compiler

--- test/kondolisp/compiler_test.clj
+++ test/kondolisp/compiler_test.clj
@@ -4,10 +4,6 @@

 (deftest test-make-num
   (is (= 0x8001 (make-num 0))))
-
-(deftest test-compile-pass1
-  (is (= [[:VM_IVAL (make-num 1)]]
-         (compile-pass1 1))))

 (deftest test-ubyte-to-sbyte
   (is (= 0 (ubyte-to-sbyte 0)))
@@ -31,4 +27,32 @@

   (is (= [0 -128]
          (short-to-byte 0x8000)))
-  )+  )
+
+(deftest test-make-t
+  (is (= 0x2001
+         (make-t))))
+
+(deftest test-make-nil
+  (is (= 0
+         (make-nil))))
+
+(deftest test-make-sym
+  (is (= 0x4001
+         (make-sym "!!")))
+
+  (is (thrown? RuntimeException
+               (make-sym "hoge"))))
+
+(deftest test-compile-pass1-immediate-values
+  (is (= [[:VM_IVAL (make-num 1)]]
+         (compile-pass1 1)))
+
+  (is (= [[:VM_IVAL (make-sym "aa")]]
+         (compile-pass1 ''aa)))
+
+  (is (= [[:VM_IVAL (make-t)]]
+         (compile-pass1 't)))
+
+  (is (= [[:VM_IVAL (make-nil)]]
+         (compile-pass1 'nil))))


Declare tv100 imports to whittle them down

--- src/irresponsible/oolong/util.clj
+++ src/irresponsible/oolong/util.clj
@@ -1,5 +1,5 @@
 (ns irresponsible.oolong.util
-  (:use [tv100])
+  (:use [tv100 :refer [tv-update tvsym? v->tv fail tvmap? tv-or tv=? tvlist?]])
   (:require [com.stuartsierra.component :as cpt]))

 ;; ## Utility functions


Tone down logging of stacktraces for parsing errors.

--- src/kixi/hecuba/data/entities.clj
+++ src/kixi/hecuba/data/entities.clj
@@ -91,7 +91,7 @@
         (try
           (json/parse-string (:property_data entity) keyword)
           (catch Throwable t
-            (log/errorf t "Could not parse property_data %s for entity %s" (:property_data entity) entity)
+            (log/errorf "Could not parse property_data %s for entity with id %s" (:property_data entity) (:entity_id entity))
             {})))
       (decode-tech-icons)))


Ctrl/Cmd +/- changes font size in worksheet SQL area and in log.

--- src/sqls/ui/seesaw/worksheet.clj
+++ src/sqls/ui/seesaw/worksheet.clj
@@ -8,8 +8,8 @@
   (:require [sqls.ui.dev-util :as ui-dev]
             [sqls.ui.proto :refer [UI WorksheetWindow]]
             [sqls.ui.seesaw.commander :refer [show-commander!]]
-            [sqls.util :refer [str-or-nil?]])
-  (:import [java.awt Container Dimension Point Rectangle Toolkit]
+            [sqls.util :refer [debugf str-or-nil?]])
+  (:import [java.awt Component Container Dimension Font Point Rectangle Toolkit]
            [java.awt.event InputEvent KeyEvent]
            [java.io File]
            [javax.swing JFrame JPanel JScrollPane JTable JViewport JTextArea KeyStroke JComponent]
@@ -367,6 +367,32 @@
   (when-let [p (.getContentPane frame)]
     (.removeAll p))
   (.removeAll frame))
+
+(defn change-font-size!
+  [^Component component change]
+  (let [^Font f (.getFont component)
+        current-size (.getSize f)
+        new-size (float (+ current-size change))
+        new-font (.deriveFont f new-size)]
+    (debugf "current size: %s, new size: %s" current-size new-size)
+    (when (pos? new-size)
+      (.setFont component new-font))))
+
+(defn setup-font-size-keys!
+  [frame]
+  (let [sql-text-area (seesaw.core/select frame [:#sql])
+        log-text (seesaw.core/select frame [:#log])
+        plus-key-stroke (seesaw.keystroke/keystroke "menu EQUALS")
+        minus-key-stroke (seesaw.keystroke/keystroke "menu MINUS")
+        handler-plus (fn []
+                       (change-font-size! sql-text-area 1)
+                       (change-font-size! log-text 1))
+        handler-minus (fn []
+                        (change-font-size! sql-text-area -1)
+                        (change-font-size! log-text -1))]
+    (assert (not (nil? sql-text-area)))
+    (seesaw.core/listen sql-text-area :key-pressed (partial on-key-press! handler-plus plus-key-stroke))
+    (seesaw.core/listen sql-text-area :key-pressed (partial on-key-press! handler-minus minus-key-stroke))))

 (defn create-worksheet-window!
   "Create implementation of sqls.ui.proto.WorksheetWindow interface.
@@ -464,6 +490,7 @@
     ;     (seesaw.core/listen
     ;       btn-print-ui-tree :action
     ;       (fn [_] (ui-dev/print-ui-tree worksheet-frame)))))
+    (setup-font-size-keys! worksheet-frame)
     (reify WorksheetWindow
       (show-worksheet-window! [_] (do
                                     (seesaw.core/show! worksheet-frame)
@@ -487,19 +514,6 @@
   [frame]
   (seesaw.core/dispose! frame))

-(defn set-on-windows-closed-handler
-  [^JFrame frame
-   handler]
-  (assert (ifn? handler))
-  (seesaw.core/listen frame :window-closed (fn [_] (handler))))
-
-; (defn set-on-explain-handler
-;   [frame handler]
-;   (assert (not= frame nil))
-;   (let [btn-explain (seesaw.core/select frame [:#explain])]
-;     (assert (not= btn-explain nil))
-;     (seesaw.core/listen btn-explain :action (fn [e] (handler)))))
-
 (defn set-on-execute-handler
   "Set Execute button handler."
   [frame handler]
@@ -546,14 +560,12 @@
         to-remove (seesaw.core/select frame [:#results-panel :> :*])]
     (doall (map (partial seesaw.core/remove! results-panel) to-remove))))

-
 (defn choose-save-file
   "Show save dialog, return absolute path as string."
   [frame]
   (-> (^File seesaw.chooser/choose-file frame :type :save)
       (.getAbsolutePath)))

-
 (defn show-explain-plan!
   "Show explain plan."
   [^JFrame frame


Helper functions in config module

Helper functions in config module

--- src/emender_jenkins/config.clj
+++ src/emender_jenkins/config.clj
@@ -136,3 +136,11 @@
     [request]
     (-> request :configuration :jobs :prod-test-jobs-suffix))

+(defn get-started-on-str
+    [request]
+    (-> request :configuration :started-on))
+
+(defn get-started-on-ms
+    [request]
+    (-> request :configuration :started-ms))
+