make endorser-transaction default to call send-chaincode-request

--- src/clojure_fabric/user.clj
+++ src/clojure_fabric/user.clj
@@ -131,7 +131,7 @@
                                                                system-channel-name
                                                                target-peers
                                                                user
-                                                               {:channel-header-type :endorser-transaction})))))
+                                                               {})))))

 ;; (defonce ^:private client-state-store (atom {}))
 ;; ;;; set_state_store
@@ -261,7 +261,7 @@
                                               system-channel-name
                                               peer
                                               user
-                                              {:channel-header-type :endorser-transaction}))
+                                              {}))
      (throw (Exception. "The target Peer does not know anything about the channel")))))

 ;;; get_name
@@ -447,8 +447,7 @@
                                          system-channel-name
                                          target-peers
                                          user
-                                         {:args [deployment-spec]
-                                          :channel-header-type :endorser-transaction})))))
+                                         {:args [deployment-spec]})))))

 ;; (def e1 (Common$Envelope/parseFrom buf))


Almost-working find-by-class

Almost-working find-by-class

--- src/clojurefx/clojurefx.clj
+++ src/clojurefx/clojurefx.clj
@@ -147,8 +147,8 @@
   (not (empty? (clojure.lang.Reflector/getMethods (class node) 0 method false))))

 (defn- graph-node-has-children? [node]
-  {:pre [(s/valid? ::node node)]
-   :post [boolean?]}
+  ;{:pre [(s/valid? ::node node)]
+  ; :post [boolean?]}
   (or (has-method? node "getChildren")
       (has-method? node "getGraphic")
       (has-method? node "getMenus")


Restore potemkin

Restore potemkin

--- src/rdf-common/grafter/rdf.clj
+++ src/rdf-common/grafter/rdf.clj
@@ -9,11 +9,9 @@
 ;; definition to prevent ns refactoring tools cleaning it away.
 (require '[grafter.rdf.io])

-(comment (import-vars
-          [grafter.rdf.io
-           s]))
-
-(def s grafter.rdf.io/s)
+(import-vars
+ [grafter.rdf.io
+  s])

 (defn prefixer
   "Takes the base prefix of a URI string and returns a function that


Improve error message for invalid Hiccup forms

--- src/reagent/impl/template.cljs
+++ src/reagent/impl/template.cljs
@@ -190,7 +190,6 @@
   (if (keyword? tag)
     (cached-wrapper tag)
     (do
-      (assert (fn? tag))
       (let [cached-class (.-cljsReactClass tag)]
         (if-not (nil? cached-class)
           cached-class
@@ -199,7 +198,11 @@
             (fn-to-class tag)))))))

 (defn vec-to-comp [v level]
-  (assert (pos? (count v)))
+  (assert (pos? (count v)) "Hiccup form should not be empty")
+  (assert (let [tag (v 0)]
+            (or (keyword? tag)
+                (fn? tag)))
+          (str "Invalid Hiccup form: " (pr-str v)))
   (let [props (get v 1)
         c (as-class (v 0))
         jsprops (js-obj cljs-argv v


Fix index template reference

Fix index template reference

--- src/stonecutter/view/index.clj
+++ src/stonecutter/view/index.clj
@@ -93,7 +93,7 @@

 (defn index [request]
   (let [error-m (get-in request [:context :errors])]
-    (->> (vh/load-template "public/home.html")
+    (->> (vh/load-template "public/index.html")
          (vh/set-form-action [:.clj--register__form] (r/path :register-user))
          (vh/set-form-action [:.clj--sign-in__form] (r/path :sign-in))
          (vh/set-attribute [:.clj--forgot-password] :href (r/path :show-forgotten-password-form))


Move home function def after depended function.

--- src/todo_repl_webapp/views.clj
+++ src/todo_repl_webapp/views.clj
@@ -31,28 +31,6 @@
         [:code "(complete-task "
                [:em "index"]
                ")"]]]))
-
-(defn home [tasks]
-  (core/html [:head
-          [:title "todo-repl"]
-          (page/include-css "css/bootstrap.min.css")
-          (page/include-js "http://code.jquery.com/jquery-1.10.1.min.js"
-                           "js/bootstrap.min.js")]
-        [:body
-          [:div.col-md-7.col-md-offset-2
-            [:h1 "todo-repl"]
-            (form/form-to {:id "todoForm"}
-                          [:post "/eval"]
-                          (form/text-area {:class "form-control"}
-                                          "evalInput"
-                                          "(tasks)")
-                          [:br]
-                          (form/submit-button {:id "todoSubmitButton"}
-                                              "Eval"))]
-          instructions
-          [:div#display.col-md-7.col-md-offset-2
-            (display tasks)]
-          (page/include-js "js/eval.js")]))

 (defn task-item
   "Given a task (map), return a div representing the task"
@@ -88,3 +66,25 @@
     (core/html [:h2 "list"]
           #_[:h3 x]
             (task-table (vec x)))))
+
+(defn home [tasks]
+  (core/html [:head
+          [:title "todo-repl"]
+          (page/include-css "css/bootstrap.min.css")
+          (page/include-js "http://code.jquery.com/jquery-1.10.1.min.js"
+                           "js/bootstrap.min.js")]
+        [:body
+          [:div.col-md-7.col-md-offset-2
+            [:h1 "todo-repl"]
+            (form/form-to {:id "todoForm"}
+                          [:post "/eval"]
+                          (form/text-area {:class "form-control"}
+                                          "evalInput"
+                                          "(tasks)")
+                          [:br]
+                          (form/submit-button {:id "todoSubmitButton"}
+                                              "Eval"))]
+          instructions
+          [:div#display.col-md-7.col-md-offset-2
+            (display tasks)]
+          (page/include-js "js/eval.js")]))


Remove unused variable from transform-point function.

--- src/uxbox/util/geom/point.cljs
+++ src/uxbox/util/geom/point.cljs
@@ -147,10 +147,9 @@

 (defn transform-point
   [pt mx]
-  (let [other (-point other)]
-    (Point. (+ (* (:x pt) (:a mx))
-               (* (:y pt) (:c mx))
-               (:tx mx))
-            (+ (* (:x pt) (:b mx))
-               (* (:y pt) (:d mx))
-               (:ty mx)))))
+  (Point. (+ (* (:x pt) (:a mx))
+             (* (:y pt) (:c mx))
+             (:tx mx))
+          (+ (* (:x pt) (:b mx))
+             (* (:y pt) (:d mx))
+             (:ty mx))))


Enable root cursor traversal

Enable root cursor traversal

--- src/derive/nativestore.cljs
+++ src/derive/nativestore.cljs
@@ -288,40 +288,6 @@
   ([o1 o2 & more]
      (apply upsert-merge (upsert-merge o1 o2) more)))

-
-;; Hash KV Index, meant to be for a root store index (unique keys)
-;; - Merging upsert against existing if keyfn output matches
-;; - Nil values in provided object deletes keys
-;; - Original object maintains identity
-(deftype HashIndex [keyfn hashmap]
-  ILookup
-  (-lookup [idx val]
-    (-lookup idx val nil))
-  (-lookup [idx val not-found]
-    (js-lookup hashmap val not-found))
-
-  IFn
-  (-invoke [idx k]
-    (-lookup idx k))
-  (-invoke [idx k not-found]
-    (-lookup idx k not-found))
-
-  ICounted
-  (-count [idx] (alength (js-keys hashmap)))
-
-  IIndex
-  (key-fn [idx] keyfn)
-  (index! [idx obj]
-    (let [key (keyfn obj)
-          old (js-lookup hashmap key)]
-      (js-assoc hashmap key (if old (upsert-merge old obj) obj))))
-  (unindex! [idx obj]
-    (let [key (keyfn obj)]
-      (js-dissoc hashmap key obj))))
-
-(defn root-index []
-  (HashIndex. #(aget % "id") #js {}))
-
 ;; Return a cursor for walking a range of the index
 (deftype Cursor [idx start end ^:mutable valid?]
   IReduce
@@ -333,6 +299,48 @@
         (if (< i end)
           (recur (inc i) (f ret (aget a i)))
           ret)))))
+
+;; Hash KV Index, meant to be for a root store index (unique keys)
+;; - Merging upsert against existing if keyfn output matches
+;; - Nil values in provided object deletes keys
+;; - Original object maintains identity
+(deftype HashIndex [keyfn hashmap]
+  ILookup
+  (-lookup [idx val]
+    (-lookup idx val nil))
+  (-lookup [idx val not-found]
+    (js-lookup hashmap val not-found))
+
+  IFn
+  (-invoke [idx k]
+    (-lookup idx k))
+  (-invoke [idx k not-found]
+    (-lookup idx k not-found))
+
+  ICounted
+  (-count [idx] (alength (js-keys hashmap)))
+
+  IIndex
+  (key-fn [idx] keyfn)
+  (index! [idx obj]
+    (let [key (keyfn obj)
+          old (js-lookup hashmap key)]
+      (js-assoc hashmap key (if old (upsert-merge old obj) obj))))
+  (unindex! [idx obj]
+    (let [key (keyfn obj)]
+      (js-dissoc hashmap key obj)))
+
+  IScannable
+  (-get-cursor [idx]
+    (let [vals #js {:arry (goog.object.getValues (.-hashmap idx))}]
+      (Cursor. vals 0 (alength (.-arry vals)) true)))
+  (-get-cursor [idx start]
+    (assert false))
+  (-get-cursor [idx start end]
+    (assert false)))
+
+(defn root-index []
+  (HashIndex. #(aget % "id") #js {}))

 ;; KV index using binary search/insert/remove on array
 ;; - Always inserts new objects in sorted order
@@ -547,7 +555,7 @@
   "Walk the entire store, or an index"
   ([store]
      ;; TODO - this is broken, add inform tracker, etc.
-     (apply -get-cursor store))
+     (-get-cursor (.-root store)))
   ([store index start]
      (deps/inform-tracker store (js-obj (name index) (array start (last-val index)))) ;; shorthand
      (-get-cursor (get-index store index) start))


Update leiningen to 2.9.7

Update leiningen to 2.9.7

--- src/docker_clojure/core.clj
+++ src/docker_clojure/core.clj
@@ -46,7 +46,7 @@
   {:default :debian-slim/slim-bullseye})

 (def build-tools
-  {"lein"       "2.9.6"
+  {"lein"       "2.9.7"
    "boot"       "2.8.3"
    "tools-deps" "1.10.3.967"})


Update tools.deps to 1.10.3.1069

Update tools.deps to 1.10.3.1069


removed unused test

removed unused test

--- ingestion-api/test/ingestion_api/core_test.clj
+++ ingestion-api/test/ingestion_api/core_test.clj
@@ -1,7 +0,0 @@
-(ns ingestion-api.core-test
-  (:require [clojure.test :refer :all]
-            [ingestion-api.core :refer :all]))
-
-(deftest a-test
-  (testing "FIXME, I fail."
-    (is (= 1 1))))


more idiomatic version of update-stringified-list

--- src/kixi/hecuba/webutil.clj
+++ src/kixi/hecuba/webutil.clj
@@ -39,10 +39,7 @@
   (map encode items))

 (defn update-stringified-list [body selector]
-  (if
-    (contains? body selector)
-    (update-in body [selector] json-list)
-    (assoc body selector nil)))
+  (update-in body [selector] #(when % (map encode %))))

 (defn update-stringified-lists [body selectors]
   (reduce update-stringified-list body selectors))


Values passed back as `{:ref x :val y}`.

* :ref only there if value if not a literal.

--- src/isla/interpreter.clj
+++ src/isla/interpreter.clj
@@ -41,9 +41,11 @@
       (nreturn (:ctx env) return-val))))

 (defmethod interpret :value [node env]
-  (if (= :identifier (:tag (extract node [:c 0])))
-    (lookup (extract node [:c 0 :c 0]) env) ;; sub is identifier - lookup+return
-    (interpret (extract node [:c 0]) env)))
+  (let [sub-node (extract node [:c 0])]
+    (if (= :identifier (:tag sub-node))
+      (let [ref (interpret sub-node env)]
+        {:ref ref :val (lookup-ref ref env)})
+      {:val (interpret sub-node env)})))

 (defmethod interpret :identifier [node _]
   (extract node [:c 0]))


Работа с тегами

Работа с тегами

--- src/ixinfestor/core.cljs
+++ src/ixinfestor/core.cljs
@@ -427,13 +427,15 @@

 (defn modal-show [id]
   (println "Show modal on id = " id)
-  (-> id name js/jQuery .modal))
+  (-> id name js/jQuery (.modal "show")))

 ;; ----------------------------------------------------------------

+(def modal-dialog-id-suffix :modal-dialog)
+
 (defn modal-cr-and-show-on-id [id {:keys [label header title body footer]}]
-  (let [modal-id (xml-id :modal-dialog id)]
+  (let [modal-id (xml-id modal-dialog-id-suffix id)]
     (clear-and-set-on-tag-by-id id
                                 [:div {:id (name modal-id) :aria-hidden "true", :aria-labelledby (or label "Modal Label..."),
                                        :class "modal"
@@ -449,6 +451,12 @@
                                     ]]]])
     (modal-show (str \# (name modal-id)))))

+(defn modal-hide-on-id [id]
+  (-> (xml-id modal-dialog-id-suffix id)
+      name
+      ((partial str \#))
+      js/jQuery (.modal "hide")))
+
 ;; END Modal dialogs
 ;;..................................................................................................


Revert "Replace usages of `get-static-fields-of-type` in format.clj with a static value."

This reverts commit c55adb3b

--- src/java_time/format.clj
+++ src/java_time/format.clj
@@ -6,23 +6,8 @@
   (:import [java.time.temporal TemporalAccessor]
            [java.time.format DateTimeFormatter DateTimeFormatterBuilder ResolverStyle]))

-(defonce predefined-formatters
-  (->>
-    {"BASIC_ISO_DATE"       DateTimeFormatter/BASIC_ISO_DATE
-     "ISO_LOCAL_TIME"       DateTimeFormatter/ISO_LOCAL_TIME
-     "RFC_1123_DATE_TIME"   DateTimeFormatter/RFC_1123_DATE_TIME
-     "ISO_OFFSET_DATE"      DateTimeFormatter/ISO_OFFSET_DATE
-     "ISO_OFFSET_DATE_TIME" DateTimeFormatter/ISO_OFFSET_DATE_TIME
-     "ISO_ZONED_DATE_TIME"  DateTimeFormatter/ISO_ZONED_DATE_TIME
-     "ISO_LOCAL_DATE_TIME"  DateTimeFormatter/ISO_LOCAL_DATE_TIME
-     "ISO_TIME"             DateTimeFormatter/ISO_TIME
-     "ISO_WEEK_DATE"        DateTimeFormatter/ISO_WEEK_DATE
-     "ISO_LOCAL_DATE"       DateTimeFormatter/ISO_LOCAL_DATE
-     "ISO_OFFSET_TIME"      DateTimeFormatter/ISO_OFFSET_TIME
-     "ISO_ORDINAL_DATE"     DateTimeFormatter/ISO_ORDINAL_DATE
-     "ISO_DATE"             DateTimeFormatter/ISO_DATE
-     "ISO_DATE_TIME"        DateTimeFormatter/ISO_DATE_TIME
-     "ISO_INSTANT"          DateTimeFormatter/ISO_INSTANT}
+(def predefined-formatters
+  (->> (jt.u/get-static-fields-of-type DateTimeFormatter DateTimeFormatter)
        (jt.u/map-kv
          (fn [^String n fmt]
            [(string/lower-case (.replace n \_ \-)) fmt]))))


(PE-27515) Add unit test for cert_ttl values

--- test/unit/puppetlabs/services/ca/certificate_authority_core_test.clj
+++ test/unit/puppetlabs/services/ca/certificate_authority_core_test.clj
@@ -499,7 +499,7 @@
           test-app (-> (build-ring-handler settings "42.42.42")
                        (wrap-with-ssl-client-cert))]
       (testing "PUT"
-        (testing "signing a cert"
+        (testing "signing a cert with an hour ttl"
           (let [csr-path (ca/path-to-cert-request (:csrdir settings) "test-agent")
                 signed-cert-path (ca/path-to-cert (:signeddir settings) "test-agent")
                 static-csr (ca/path-to-cert-request csrdir "test-agent")]
@@ -508,8 +508,15 @@
               (let [response (test-app
                               {:uri "/v1/certificate_status/test-agent"
                                :request-method :put
-                               :body (body-stream "{\"desired_state\":\"signed\"}")})]
+                               :body (body-stream "{\"desired_state\":\"signed\",\"cert_ttl\":3600}")})]
                 (is (true? (fs/exists? signed-cert-path)))
+                (let [cert (utils/pem->cert signed-cert-path)
+                      date (java.util.Calendar/getInstance)]
+                  (is (nil? (.checkValidity cert (.getTime date))))
+                  (.add date (java.util.Calendar/YEAR) 2)
+                  (is (thrown?
+                       java.security.cert.CertificateExpiredException
+                       (.checkValidity cert (.getTime date)))))
                 (is (= 204 (:status response))
                     (ks/pprint-to-string response)))
               (finally


Simplify and make behavior toggling generic with flat format

--- src/lt/plugins/user.cljs
+++ src/lt/plugins/user.cljs
@@ -24,24 +24,24 @@
 ;; ================

 ;; toggle behaviors by changing workspace behavior: is there a more localized way of doing this?
-(defn toggle-line-numbers
+(defn toggle-behavior
   "Sets line number first time this is called and toggles on subsequent calls"
-  []
-  (let [ws-behavior (settings/safe-read (:ws-behaviors @workspace/current-ws) "workspace.behaviors")
-        show-line-numbers (some #(= :lt.objs.editor/hide-line-numbers %) (get-in ws-behavior [:+ :editor]))
-        line-behavior (if show-line-numbers :lt.objs.editor/line-numbers :lt.objs.editor/hide-line-numbers)
-        behavior-string  (->> (get-in ws-behavior [:+ :editor])
-                              (remove #{:lt.objs.editor/line-numbers :lt.objs.editor/hide-line-numbers})
-                              (cons line-behavior)
-                              vec
-                              (assoc-in ws-behavior [:+ :editor])
+  [[behavior-tag behavior]]
+  (let [negated-behavior (keyword (str "-" (namespace behavior)) (name behavior))
+        ws-behaviors (settings/safe-read (:ws-behaviors @workspace/current-ws) "workspace.behaviors")
+        behavior-string  (->> ws-behaviors
+                              (mapv (fn [[_ beh :as v]]
+                                      (condp = beh
+                                        behavior [behavior-tag negated-behavior]
+                                        negated-behavior [behavior-tag behavior]
+                                        v)))
                               pr-str)]
     (swap! workspace/current-ws assoc :ws-behaviors behavior-string)
     (cmd/exec! :behaviors.reload)))

 (cmd/command {:command :user.toggle-line-numbers
               :desc "User: toggles line numbers"
-              :exec toggle-line-numbers})
+              :exec (partial toggle-behavior [:editor :lt.objs.editor/line-numbers])})

 (defn toggle-strip-whitespace
   "Disables stripping whitespace on first call and toggles on subsequent calls"


Casing is ignored between TSVs now

Casing is ignored between TSVs now

--- src/matchmaker/core.cljs
+++ src/matchmaker/core.cljs
@@ -46,11 +46,13 @@
        (columns tsv)))

 (defn parse-attendance [tsv]
-  (let [pairs (map (fn [c] [(nth c 0) (= (nth c 1 nil) "attended")]) (columns tsv))]
+  (let [pairs (map (fn [c] [(string/lower-case (nth c 0))
+                            (= (nth c 1 nil) "attended")])
+                   (columns tsv))]
     (into (sorted-map) pairs)))

 (defn can-play [players attendance]
-  (filter (fn [p] (attendance (:name p))) players))
+  (filter (fn [p] (attendance (string/lower-case (:name p)))) players))

 (defn teams-by-skill [players]
   (loop [ps (cond->> players


Parsing of players, attendance and filtering

--- src/matchmaker/core.cljs
+++ src/matchmaker/core.cljs
@@ -1,14 +1,27 @@
 (ns matchmaker.core
-    (:require [reagent.core :as reagent :refer [atom]]))
+    (:require [reagent.core :as reagent :refer [atom]]
+              [clojure.string :refer [split]]))

-(defn parse-players [txt]
-  [])
+(def players-tsv (atom ""))
+(def attendance-tsv (atom ""))

-(defn parse-attendance [txt]
-  [])
+(defn columns [tsv]
+  (let [rows (split tsv #"\n")
+        cols (map #(split % #"\t") rows)]
+    cols))
+
+(defn parse-players [tsv]
+  (map (fn [c]
+           {:name (nth c 0)
+            :rank (nth c 3 nil)})
+       (columns tsv)))
+
+(defn parse-attendance [tsv]
+  (let [pairs (map (fn [c] [(nth c 0) (= (nth c 1 nil) "attended")]) (columns tsv))]
+    (into (sorted-map) pairs)))

 (defn can-play [players attendance]
-  [])
+  (filter (fn [p] (attendance (:name p))) players))

 (defn group-teams [players]
   [])
@@ -16,21 +29,19 @@
 ;; -------------------------
 ;; Views

-(defn editor [value]
-  [:textarea {:value @value
+(defn editor [placeholder value]
+  [:textarea {:placeholder placeholder
+              :value @value
               :on-change #(reset! value (-> % .-target .-value))}])
-
-(def players-txt (atom ""))
-(def attendance-txt (atom ""))

 (defn root []
   [:div
-   [editor players-txt]
-   [editor attendance-txt]
-   (let [players (parse-players players-txt)
-         attendance (parse-attendance attendance-txt)
+   [editor "Players" players-tsv]
+   [editor "Attendance" attendance-tsv]
+   (let [players (parse-players players-tsv)
+         attendance (parse-attendance attendance-tsv)
          teams (group-teams (can-play players attendance))]
-     [:p "TODO: Everything. " (count @players-txt) " - " (count @attendance-txt)])])
+     [:p "TODO: Everything. " (count @players-tsv) " - " (count @attendance-tsv)])])

 ;; -------------------------
 ;; Initialize app


Updated tests for metrics-to-measure

Updated tests for metrics-to-measure

--- test/aeolian/composer_test.clj
+++ test/aeolian/composer_test.clj
@@ -7,7 +7,6 @@
             [aeolian.abc.key :as k]))

 (facts "when processing metrics"
-
        (facts "line length is mapped to note"
               (fact "empty lines are mapped to rests"
                            (c/metric-to-note "Foo.java#1 LL=0" k/major) => (contains n/rest-note))
@@ -27,17 +26,20 @@
                n/minor-octave-4    99            k/minor
                n/minor-octave-5    2000          k/minor))

+       (future-fact "changes to git author produces a change in instrument")
+       (future-fact "changes to source file name produces a change in lyrics")
+
        (fact "complexity > 1 is mapped to tempo"
              (c/metric-to-note "Foo.java#1 LL=30 CC=1" k/major) =not=> (contains t/prefix)
              (c/metric-to-note "Foo.java#1 LL=30 CC=10" k/major) => (contains t/prefix)
              (c/metric-to-note "Foo.java#1 LL=30 CC=5" k/major) => (contains t/prefix)
              (c/metric-to-note "Foo.java#1 LL=30 CC=3" k/major) => (contains t/prefix))

-       (future-fact "method-length is mapped to accompanying chord"
-                    (str/index-of (c/metrics-to-measure "Foo.java#1 LL=30 ML=1") t/prefix) => falsey
-                    (str/index-of (c/metrics-to-measure "Foo.java#1 LL=30 ML=10") t/prefix) => truthy
-                    (str/index-of (c/metrics-to-measure "Foo.java#1 LL=30 ML=5") t/prefix) => truthy
-                    (str/index-of (c/metrics-to-measure "Foo.java#1 LL=30 ML=3") t/prefix) => truthy))
+       (fact "method-length is mapped to accompanying chord"
+             (str/index-of (c/metrics-to-measure ["Foo.java#1 LL=30 ML=1"] k/major) "\"C\"") => truthy
+             (str/index-of (c/metrics-to-measure ["Foo.java#1 LL=30 ML=10"] k/major) "\"Dm\"") => truthy
+             (str/index-of (c/metrics-to-measure ["Foo.java#1 LL=30 ML=5"] k/minor) "\"Cm\"") => truthy
+             (str/index-of (c/metrics-to-measure ["Foo.java#1 LL=30 ML=11"] k/minor) "\"_E\"") => truthy))

 (facts "when opening metrics files"
        (fact "all lines are used in composition"


clean up cgen macros

clean up cgen macros

--- src/overtone/sc/cgen.clj
+++ src/overtone/sc/cgen.clj
@@ -135,10 +135,9 @@
   A cgen behaves similarly to a ugen - it has a default rate, named params, full
   docstring and may be mixed with both ugens and cgens in the construction of
   synths."
-  ([c-name summary doc params body rate] (cgen c-name doc params body rate [["Composite Ugen"]]))
-  ([c-name summary doc params body rate categories]
-     (let [c-name (symbol (name c-name))]
-       (mk-cgen c-name summary doc params body categories rate))))
+  [c-name summary doc params body rate categories]
+  (let [c-name (symbol (name c-name))]
+    (mk-cgen c-name summary doc params body categories rate)))

 (defmacro defcgen
   "Define one or more related cgens (composite generators) with different rates.
@@ -174,15 +173,20 @@
         default-body                             (get bodies default-rate)
         default-cgen                             (mk-cgen c-name summary doc params default-body categories default-rate)
         default-c-name                           (with-meta c-name metadata)
-        cgen-defs                                [`(def ~default-c-name ~default-cgen)]]
+        default-def                              `(def ~default-c-name ~default-cgen)
+        cgen-defs (list* default-def
+                         (for [rate rates]
+                           (let [body   (get bodies rate)
+                                 cgen   (mk-cgen c-name summary doc params body categories rate)
+                                 c-name (symbol (str (name c-name) rate))
+                                 c-name (with-meta c-name metadata)
+                                 ]
+                             `(def ~c-name ~cgen))))]

-    (conj cgen-defs
-     (for [rate rates]
-       (let [body   (get bodies rate)
-             cgen   (mk-cgen c-name summary doc params body categories rate)
-             c-name (symbol (str (name default-c-name) rate))
-             c-name (with-meta c-name metadata)]
-         `(def ~c-name ~cgen))))))
+    `(do ~@cgen-defs)
+
+
+))

 (defmethod print-method ::cgen [cgen w]
   (let [info (meta cgen)]


no longer call .openUdp on port which is a String. What was this trying to do? Perhaps we should look into the ability to specify that the internal server listen for TCP/UDP packets on a given port from external processes - thus allowing the ability to bypass Overtone where necessary.

--- src/overtone/sc/core.clj
+++ src/overtone/sc/core.clj
@@ -266,6 +266,10 @@

 (defonce scsynth-server* (ref nil))

+
+;;TODO: make use of the port or remove it as a param.
+;;      should we be able to get the internal server to listen
+;;      for external processes on a given port?
 (defn- internal-booter [port]
   (log/info "booting internal audio server listening on port: " port)
   (let [server (ScSynth.)
@@ -276,8 +280,7 @@
                      (reset! running?* true)))]
     (.addScSynthStartedListener server listener)
     (dosync (ref-set sc-world* server))
-    (.run server)
-    (.openUdp port)))
+    (.run server)))

 (defn- boot-internal
   ([] (boot-internal (+ (rand-int 50000) 2000)))


Print node info on inactive modification error.

--- src/overtone/sc/node.clj
+++ src/overtone/sc/node.clj
@@ -16,11 +16,11 @@
 (defn- inactive-node-modification-error
   "The default error behaviour triggered when a user attempts to either
   control or kill an inactive node."
-  [err-msg]
+  [node err-msg]
   (condp = *inactive-node-modification-error*
     :silent    nil ;;do nothing
-    :warning   (println "Warning - " err-msg)
-    :exception (throw (Exception. err-msg))
+    :warning   (println "Warning - " err-msg node " " (with-out-str (print node)))
+    :exception (throw (Exception. (str "Error - " err-msg " " (with-out-str (print node)))))
     (throw
      (IllegalArgumentException.
       (str "Unexpected value for *inactive-node-modification-error*: "
@@ -197,7 +197,7 @@
   ([node err-msg]
      (when (and (node? node)
                 (not (node-active? node)))
-      (inactive-node-modification-error err-msg))))
+      (inactive-node-modification-error node err-msg))))

 (defn node-free*


refer to correct namespaced keyword for instrument. Thanks to Dave Ray for pointing this out.

--- src/overtone/sc/node.clj
+++ src/overtone/sc/node.clj
@@ -32,7 +32,7 @@
   integer"
   [node]
   (let [id (if   (and (associative? node)
-                      (= ::instrument (:type node))) (:group node) node)]
+                      (= :overtone.studio.rig/instrument (:type node))) (:group node) node)]
     (if-not (integer? id)
       (throw (Exception. (str "The following node id is not an integer:" id)))
       id)))


removed unneeded imports

removed unneeded imports

--- src/maqueta/hello/input.clj
+++ src/maqueta/hello/input.clj
@@ -3,9 +3,7 @@

 (ns maqueta.hello.input
   (:use (maqueta application geometry))
-  (:import (com.jme3.math ColorRGBA Vector3f)
-           com.jme3.scene.Geometry
-           com.jme3.scene.shape.Box))
+  (:import com.jme3.math.ColorRGBA))

 (defn get-speed
   [app]


put favicon link back in head

put favicon link back in head

--- src/pc/views/content.clj
+++ src/pc/views/content.clj
@@ -48,6 +48,7 @@
     [:meta {:name       "twitter:image"       :content ""}] ; TODO
     [:meta {:name       "twitter:url"         :content "https://prcrsr.com/"}]

+    [:link {:rel "icon" :href "/favicon.ico" :type "image/ico"}]
     [:link {:rel        "apple-touch-icon"    :href    "/apple-touch-icon.png"}]
     [:link {:rel        "stylesheet"          :href    (pc.assets/asset-path "/css/app.css")}]
     [:link {:rel        "stylesheet"          :href    "https://fonts.googleapis.com/css?family=Roboto:500,900,100,300,700,400"}]


Code cleanup now that checkers.clj is *finally* stabilizing.

--- src/midje/util/checkers.clj
+++ src/midje/util/checkers.clj
@@ -142,55 +142,6 @@
  ;;Checkers that work with collections.

-; non-loops
-(defn- like-a-map-entry? [elt]
-  (or (and (sequential? elt) (= (count elt) 2))
-      (= (class elt) clojure.lang.MapEntry)))
-
-;; (defn singleton-to-be-wrapped? [actual expected]     ;;; To be destroyed.
-;;   (cond (map? actual)
-;;         (like-a-map-entry? expected)
-
-;;         (string? actual)
-;;         false
-
-;;         (regex? actual)
-;;         false
-
-;;         (set? expected)
-;;         false
-
-;;         (coll? actual)
-;;         (not (sequential? expected))
-
-;;         :else
-;;         true))
-
-
-
-; Loops that look for something according to extended-equals
-
-(defn- index-in [expected-elt actual-vector]
-  (loop [index 0]
-;    (println expected-elt actual-vector index)
-    (cond (= index (count actual-vector))
-          false
-
-          (extended-= (actual-vector index) expected-elt)
-          index
-
-          :else
-          (recur (inc index)))))
-
-(defn- retval [actual-found actual-missed expected-found expected-missed]
-  {:actual-found actual-found, :actual-missed actual-missed
-   :expected-found expected-found, :expected-missed expected-missed})
-
-(defmacro transfer-firsts-to [hashmap & kvs]
-  (let [first-kvs (map (fn [ [key val] ] `[~key (first ~val)])
-		       (partition 2 kvs))
-	argmap `(hash-map ~@first-kvs)]
-    `(merge-with conj ~hashmap ~argmap)))

 (defn- all-expected-permutations [expected]
   (cond (and (not-any? extended-fn? expected)
@@ -203,29 +154,44 @@
 	:else
 	(rotations expected)))

-(defn closer-match? [candidate best-so-far]
+(defn- closer-match? [candidate best-so-far]
   (> (count (:actual-found candidate))
      (count (:actual-found best-so-far))))

-(defn better-of [candidate best-so-far]
+(defn- better-of [candidate best-so-far]
   (if (closer-match? candidate best-so-far) candidate best-so-far))

-
-(defn tack-on-to [hashmap & kvs]
+(defn- tack-on-to [hashmap & kvs]
   (merge-with conj hashmap (apply (partial assoc {}) kvs)))

-
-(defmulti seq-comparison (fn [actual expected kind]
-			   (or (some #{:in-any-order} kind) :strict-order)))
-
-
-(defn sequence-success? [comparison]
+(defn- sequence-success? [comparison]
   (= (count (:expected-found comparison))
      (count (:expected comparison))))

-(defn full-sequence-match? [actual expected kind]
-  (let [comparison (seq-comparison actual expected kind)]
-    (sequence-success? comparison)))
+(defn- collection-like? [thing]
+  (or (coll? thing)
+      (string? thing)))
+
+(defn- right-hand-singleton? [thing]
+  (or (not (coll? thing)) (map? thing)))
+
+(defn- same-lengths? [actual expected]
+  (= (count actual) (count expected)))
+
+(defn- expected-fits? [actual expected]
+  (>= (count actual) (count expected)))
+
+(defn- midje-re-find [re string]
+  (try
+    (re-find re string)
+    (catch Exception ex false)))
+
+(defn- midje-re-matches [re string]
+  (try
+    (re-matches re string)
+    (catch Exception ex false)))
+
+
 (defn in-any-order--one-permutation [actual expected kind]
   (let [starting-candidate  {:actual-found [], :expected-found [],
@@ -277,7 +243,10 @@

 	    :else
 	    (better-of candidate best-so-far)))))
-
+
+(defmulti seq-comparison (fn [actual expected kind]
+			   (or (some #{:in-any-order} kind) :strict-order)))
+
 (defmethod seq-comparison :in-any-order
   [actual expected kind]

@@ -336,122 +305,6 @@

 ; Searches through particular types of actual results

-
-;; (defn- actual-sequential-has-prefix? [expected actual kind]
-;;   (cond (some #{:in-any-order} kind)
-;;         (let [possible-prefix (take (count expected) actual)]
-;;           (empty? (:expected-missed (seq-comparison possible-prefix expected kind))))
-
-;;         (empty? expected)
-;;         true
-
-;;         (< (count actual) (count expected))
-;;         false
-
-;;         (extended-= (first actual) (first expected))
-;;         (recur (rest expected) (rest actual) kind)
-
-;;         :else
-;;         false))
-
-
-;; (defn- actual-sequential-contains? [actual expected kind]
-;;   (cond (set? expected)
-;; 	(recur actual (vec expected) (conj kind :in-any-order))
-
-;; 	:else
-;; 	(full-sequence-match? actual expected kind)))
-
-;; (defn- actual-map-contains? [actual expected]
-;;   (cond (map? expected)
-;;         (every? (fn [key]
-;;                   (and (find actual key)
-;;                        (extended-= (get actual key) (get expected key))))
-;;                 (keys expected))
-
-;;         (and (sequential? expected)
-;;              (every? like-a-map-entry? expected))
-;;         (actual-map-contains? actual (apply hash-map (apply concat expected)))
-
-;;         :else
-;;         (throw (Error. (str "If " (pr-str actual) " is a map, " (pr-str expected) " should look like map entries.")))))
-
-;; (defn- actual-x-contains? [actual expected kind]
-;;   (cond (singleton-to-be-wrapped? actual expected)
-;;         (recur actual [expected] kind)
-
-;;         (sequential? actual)
-;;         (actual-sequential-contains? actual expected kind)
-
-;;         (set? actual)
-;;         (recur (vec actual) expected [:in-any-order])
-
-;;         (map? actual)
-;;         (actual-map-contains? actual expected)
-
-;;         (string? expected)
-;;         (if (empty? kind)
-;;           (.contains actual expected)
-;;           (recur (vec actual) (vec expected) kind))
-
-;;         (regex? expected)
-;;         (if (empty? kind)
-;;           (re-find expected actual)
-;;           (throw (Error. (str "I don't know how to make sense of a "
-;;                               "regular expression applied "
-;; 			      kind "."))))
-
-;;         :else
-;;         false))
-
-;; (defn- actual-x-has-prefix? [actual expected kind]
-;;   (cond (singleton-to-be-wrapped? actual expected)
-;;         (recur actual [expected] kind)
-
-;;         (sequential? actual)
-;;         (actual-sequential-has-prefix? actual expected kind)
-
-;;         (string? expected)
-;;         (if (empty? kind)
-;;           (.startsWith actual expected)
-;;           (recur (vec actual) (vec expected) kind))
-
-;;         (regex? expected)
-;;         (if (empty? kind)
-;;           (re-find (re-pattern (str "^" (.toString expected))) actual)
-;;           (throw (Error. (str "I don't know how to make sense of a regular expression "
-;; 			      "applied " kind "."))))
-;;         :else
-;;         false))
-
-
-;; (defn- actual-x-has-suffix? [actual expected kind]
-;;   (cond (singleton-to-be-wrapped? actual expected)
-;;         (recur actual [expected] kind)
-
-;;         (sequential? actual)
-;;         (actual-sequential-has-prefix? actual expected kind)
-
-;;         (string? expected)
-;;         (if (empty? kind)
-;;           (.startsWith actual expected)
-;;           (recur (vec actual) (vec expected) kind))
-
-;;         (regex? expected)
-;;         (if (empty? kind)
-;;           (re-find (re-pattern (str "^" (.toString expected))) actual)
-;;           (throw (Error. (str "I don't know how to make sense of a regular expression "
-;; 			      "applied " kind "."))))
-;;         :else
-;;         false))
-
-(defn collection-like? [thing]
-  (or (coll? thing)
-      (string? thing)))
-
-(defn right-hand-singleton? [thing]
-  (or (not (coll? thing)) (map? thing)))
-
 (defn standardized-arguments [actual expected kind]
   ;; The choice to make these (throw Error) rather than be falsey is purely
   ;; one of implementation convenience.
@@ -503,6 +356,10 @@
 	:else
 	[actual expected kind]))

+(defn full-sequence-match? [actual expected kind]
+  (let [comparison (seq-comparison actual expected kind)]
+    (sequence-success? comparison)))
+
 (defn actual-map-contains? [actual expected kind]
   ;;  (prn "actual-map-contains" actual expected)
   (every? (fn [key]
@@ -518,28 +375,6 @@
 	:else
 	(full-sequence-match? actual expected kind))
   )
-
-(defn same-lengths? [actual expected]
-  (= (count actual) (count expected)))
-
-(defn expected-fits? [actual expected]
-  (>= (count actual) (count expected)))
-
-(defn midje-take [n thing]
-  (take n thing))
-
-(defn midje-take-last [n thing]
-  (take-last n thing))
-
-(defn midje-re-find [re string]
-  (try
-    (re-find re string)
-    (catch Exception ex false)))
-
-(defn midje-re-matches [re string]
-  (try
-    (re-matches re string)
-    (catch Exception ex false)))

 ;; The interface

@@ -605,47 +440,20 @@

 (def has-prefix
      (container-checker
-      (has-xfix "prefix" #(re-pattern (str "^" (.toString %))) midje-take)))
+      (has-xfix "prefix" #(re-pattern (str "^" (.toString %))) take)))
 (def has-suffix
      (container-checker
-      (has-xfix "suffix" #(re-pattern (str (.toString %) "$" )) midje-take-last)))
+      (has-xfix "suffix" #(re-pattern (str (.toString %) "$" )) take-last)))

-;; (def has-prefix (container-checker
-;;    (fn [actual expected kind]
-;;      (cond (set? actual)
-;; 	   (tag-as-chatty-falsehood {:actual actual
-;; 				     :notes ["Sets don't have prefixes."]})
-
-;; 	   :else
-;; 	   (let [ [actual expected kind] (standardized-arguments actual expected kind)]
-;; 	     (cond (regex? expected)
-;; 		   (midje-re-find ) actual)
-
-;; 		   (expected-fits? actual expected)
-;; 		   (apply actual-x-contains?
-;; 			  [(midje-take (count expected) actual) expected kind])
-
-;; 		   :else
-;; 		   false))))))
-
-;; (def has-suffix (container-checker
-;;     (fn [[actual expected kind]]
-;;       (cond (regex? expected)
-;; 	    (midje-re-find ) actual)
-
-;; 	    (expected-fits? actual expected)
-;; 	    (apply actual-x-contains?
-;; 		   [(midje-take-last (count expected) actual) expected kind])
-
-;; 	    :else
-;; 	    false))))
-
 (defn has [quantifier predicate]
   (fn [actual]
     (quantifier predicate
 		(if (map? actual)
 		  (vals actual)
 		  actual))))
+
++;; These are used in some internal tests. Worth publicizing?

 (defn n-of [expected expected-count]
   {:midje/checker true}
@@ -665,7 +473,7 @@
 (of-functions)

 -;; Deprecated checkers
+;; deprecated checkers

 (defn map-containing [expected]
   "Accepts a map that contains all the keys and values in expected,


WIP upload results to postgres

WIP upload results to postgres

--- src/polismath/poller.clj
+++ src/polismath/poller.clj
@@ -1,5 +1,7 @@
 (ns polismath.poller
-  (:use polismath.named-matrix
+  (:use
+        clojure.pprint
+        polismath.named-matrix
         polismath.utils
         polismath.pca)
   (:require [korma.db :as kdb]
@@ -36,11 +38,43 @@
                (conj (get conv-map conv-id []) vote))))
     {} votes))

+(defn post-results [db-spec zid last-timestamp results-json]
+  (kdb/with-db db-spec
+    (ko/update "math_results_dev01"
+      (ko/set-fields {
+        :data results-json
+        :last_timestamp last-timestamp })
+      (ko/where {
+        :zid [= zid]
+        :last_timestamp [< last-timestamp] }))))

-(defn poll [db-spec last-timestanp]
+(defn post-results-raw [db-spec zid last-timestamp results-json]
+  (kdb/with-db db-spec
+    (ko/exec-raw [
+      "UPDATE math_results_dev01 SET data = ?, last_timestamp = ? WHERE zid = ? RETURNING zid"
+      [results-json last-timestamp zid]
+      :results])))
+
+
+(defn post-results-insert [db-spec zid last-timestamp results-json]
+  (kdb/with-db db-spec
+    (ko/insert "math_results_dev01"
+      (ko/values {
+        :data results-json
+        :last_timestamp last-timestamp
+        :zid zid}))))
+
+(defn upsert-results [db-spec zid last-timestamp results-json]
+  (try
+    (post-results-insert db-spec 1001 0 results-json)
+    (catch Exception e
+      (post-results db-spec 1001 1 results-json))))
+
+
+(defn poll [db-spec last-timestamp]
   (kdb/with-db db-spec
     (ko/select "votes"
-      (ko/where {:created [> last-timestanp]})
+      (ko/where {:created [> last-timestamp]})
       (ko/order :created :asc))))

@@ -48,11 +82,19 @@
   (let [poll-interval 1000
         pg-spec         (heroku-db-spec (env/env :database-url))
         mg-db           (mongo-db env/env)
-        last-timestanp  (atom 1388285552490)]
+        last-timestamp  (atom 1388285552490)]
     (endlessly poll-interval
-      (let [new-votes (poll pg-spec @last-timestanp)
-            split-votes (split-by-conv new-votes)]
+      (let [new-votes (poll pg-spec @last-timestamp)
+            split-votes (split-by-conv new-votes)
+            ; results (small-conv-update {
+                      ; :conv conv
+                      ; :opts {}
+                             ; :votes (get split-votes 451)})
+            ]
         (println "polling:" split-votes)
-        (swap! last-timestanp (fn [_] (:created (last new-votes))))))))
+        (swap! last-timestamp (fn [_] (:created (last new-votes))))
+        ; want to upsert, using try-catch instead. try
+        (upsert-results pg-spec 1001 1 "foo")
+        ))))


Corrected public api url in darwin

Corrected public api url in darwin

--- src/polismath/server.clj
+++ src/polismath/server.clj
@@ -31,7 +31,7 @@
 (defn full-path [filename] (str tmp-dir filename))

 (def private-app-url-base (or (:export-server-url-base env/env) "http://localhost:3000"))
-(def public-app-url-base "https://pol.is")
+(def public-app-url-base "https://pol.is/api/v3")
 (defn private-url
   [& path]
   (apply str private-app-url-base "/" path))
@@ -163,7 +163,7 @@

 (defn public-datadump-url
   [filename zinvite]
-  (public-url (str "datadump/results?filename=" filename "&zinvite=" zinvite)))
+  (public-url (str "dataExport/results?filename=" filename "&zinvite=" zinvite)))

 ;; Email notification of completion

@@ -247,7 +247,7 @@

 (defn generate-aws-url!
   "Generate a presigned url from amazon for the given filename. Optionally set an expiration in hours (defaulting to the number
-  sourced from env variable :download-link-expiration-hours."
+  sourced from env variable :download-link-expiration-hours)."
   ([aws-cred filename expiration]
    ;; XXX more env/env stuff
    (let [expiration (-> expiration time/hours time/from-now)]
@@ -366,7 +366,7 @@
 ;; completed down the road.

 (defn run-datadump
-   "Based on params this actually runs the export-conversation computation."
+  "Based on params this actually runs the export-conversation computation."
   [filename params]
   (log/info "Params for run-datadump are:" (with-out-str (prn params)))
   (try


tiny change to make travis-ci go

tiny change to make travis-ci go

--- src/navigator/templates.clj
+++ src/navigator/templates.clj
@@ -116,7 +116,8 @@
    :header (common-header (rand-int 100) "http://google.com" "Bo Jackson")
    :menu (common-menu [{:name "Admin" :href "/admin"}
                        {:name "Home" :href "/"}
-                       {:name "Add to your playlist" :href "/welcome"}])})
+                       {:name "Add to your playlist" :href "/welcome"}
+                       {:name "Google" :href "http://google.com"}])})

 (defn onboarding [common-snippets & args]
   (let [main (apply onboarding-main args)]


Change response content type to application/json

--- src/obb_rules_api/reply.clj
+++ src/obb_rules_api/reply.clj
@@ -9,7 +9,7 @@
   "Builds a response"
   [status-code obj]
   {:status status-code
-   :headers {"Content-Type" "text/json; charset=utf-8"}
+   :headers {"Content-Type" "application/json; charset=utf-8"}
    :body (parser/dump obj)})

 (defn ok


documentation

documentation

--- examples/pedestal/src/example/server.clj
+++ examples/pedestal/src/example/server.clj
@@ -35,8 +35,13 @@
         {:interceptors [[interceptor :async]]
          :get {:interceptors [[interceptor :get] async-handler]}}]]

+      ;; optional interceptors for all matched routes
       {:data {:interceptors [[interceptor :router]]}})
+
+    ;; optional default ring handler (if no routes have matched)
     (ring/create-default-handler)
+
+    ;; optional top-level routes for both routes & default route
     {:interceptors [[interceptor :top]]}))

 (defonce server (atom nil))


Make sure users without a name are sorted after all the other.

--- src/oc/storage/api/orgs.clj
+++ src/oc/storage/api/orgs.clj
@@ -179,7 +179,7 @@
         updated-other-users (mapv #(assoc %
                                           :sort-name (if (and (string/blank? (:first-name %))
                                                               (string/blank? (:last-name %)))
-                                                       "zzz"
+                                                       (str Character/MAX_VALUE)
                                                        (str (:first-name %) " " (:last-name %)))
                                           :name (lib-user/name-for-csv %))
                                   other-users)


Remove an unused namespace.

Remove an unused namespace.

--- src/oc/storage/api/orgs.clj
+++ src/oc/storage/api/orgs.clj
@@ -16,8 +16,7 @@
             [oc.storage.representations.board :as board-rep]
             [oc.storage.resources.common :as common-res]
             [oc.storage.resources.org :as org-res]
-            [oc.storage.resources.board :as board-res]
-            [oc.storage.resources.story :as story-res]))
+            [oc.storage.resources.board :as board-res]))

 ;; ----- Utility functions -----


Finish NUX min/max sample entries.

Finish NUX min/max sample entries.

--- src/oc/storage/api/orgs.clj
+++ src/oc/storage/api/orgs.clj
@@ -93,26 +93,25 @@
 (defn- create-entry
   "Create any default entries (from config) for a new default board."
   [conn org entry user]
-  (timbre/info "Creating sample entry:" (:headline entry) "for board:" (:board-slug entry))
-)
-  ; (let [ts (f/unparse lib-time/timestamp-format (t/minus (t/now) (t/minutes (or (:time-offset entry) 0))))
-  ;       board (board-res/get-board conn (:uuid org) (:board-slug entry))
-  ;       entry-res (db-common/create-resource conn common-res/entry-table-name
-  ;                   (-> (entry-res/->entry conn (:uuid board)
-  ;                                               (dissoc entry :board-slug :author :time-offset :comments :reactions)
-  ;                                               (:author entry))
-  ;                     (assoc :sample true)
-  ;                     (assoc :status :published)
-  ;                     (assoc :created-at ts)
-  ;                     (assoc :updated-at ts)
-  ;                     (assoc :published-at ts)
-  ;                     (assoc :publisher (:author entry))) ts)
-  ;       interaction-resource (merge entry entry-res)]
-  ;   ;; notify of new entry
-  ;   (notification/send-trigger! (notification/->trigger :add org board {:new entry-res} user nil))
-  ;   ;; create any entry interactions (comments and/or reactions) in parallel
-  ;   (doall (pmap #(create-interaction conn (:org-uuid board) % interaction-resource)
-  ;             (concat (:comments interaction-resource) (:reactions interaction-resource))))))
+  (timbre/info "Creating sample entry:" (:headline entry) "for board:" (:board-slug entry) "of org:" (:uuid org))
+  (let [ts (f/unparse lib-time/timestamp-format (t/minus (t/now) (t/minutes (or (:time-offset entry) 0))))
+        board (board-res/get-board conn (:uuid org) (:board-slug entry))
+        entry-res (db-common/create-resource conn common-res/entry-table-name
+                    (-> (entry-res/->entry conn (:uuid board)
+                                                (dissoc entry :board-slug :author :time-offset :comments :reactions)
+                                                (:author entry))
+                      (assoc :sample true)
+                      (assoc :status :published)
+                      (assoc :created-at ts)
+                      (assoc :updated-at ts)
+                      (assoc :published-at ts)
+                      (assoc :publisher (:author entry))) ts)
+        interaction-resource (merge entry entry-res)]
+    ;; notify of new entry
+    (notification/send-trigger! (notification/->trigger :add org board {:new entry-res} user nil))
+    ;; create any entry interactions (comments and/or reactions) in parallel
+    (doall (pmap #(create-interaction conn (:org-uuid board) % interaction-resource)
+              (concat (:comments interaction-resource) (:reactions interaction-resource))))))

 (defn- create-board
   "Create a boards for a new org."
@@ -157,7 +156,8 @@
               desired-board-names (set (conj selected-board-names config/forced-board-name))
               delete-board-names (clojure.set/difference existing-board-names desired-board-names)
               create-board-names (clojure.set/difference desired-board-names existing-board-names)
-              ;; including these next 2 in the let to prevent Eastwood from having a tizzy about the doall
+              ;; including these doall/pmap in the let to prevent Eastwood from having a tizzy about the doall
+              ;; Sync the orgs boards w/ the NUX selected boards by deleting and adding as needed
               _deleted-boards (doall (pmap (fn [delete-board-name]
                 (timbre/info "NUX sync - Deleting board:" delete-board-name "for org:" org-uuid)
                 (let [board (board-res/get-board conn (:uuid (get existing-boards-by-name delete-board-name)))
@@ -169,12 +169,13 @@
                 (timbre/info "NUX sync - Creating board:" create-board-name "for org:" org-uuid)
                 (create-board conn updated-org {:name create-board-name} author))
                 create-board-names))
-              ;; min 3 / max 4 sample entries
+              ;; create a min of 3 / max of 4 sample entries, including at least 1 from the forced board
               selected-entries (take 3 (flatten (map #(default-entries-for %) selected-board-names)))
               forced-entries (default-entries-for config/forced-board-name)
+              total-entries (take 4 (concat selected-entries forced-entries))
               create-entries (map #(assoc % :author (lib-schema/author-for-user author))
-                              (take 4 (into selected-entries forced-entries)))
-              _created-entries (doall (pmap #(create-entry conn org % author) create-entries))]
+                              (take 4 (concat selected-entries forced-entries)))
+              _created-entries (doall (pmap #(create-entry conn updated-org % author) create-entries))]
             (notification/send-trigger!
               (notification/->trigger :nux updated-org {:nux-boards (vec desired-board-names)} author))
             (timbre/info "Syncing samples for:" org-uuid "complete.")))


Wrong param name in protocol (again)

Wrong param name in protocol (again)

Wrong param name in protocol (again)

--- src/re_frame/router.cljc
+++ src/re_frame/router.cljc
@@ -72,7 +72,7 @@

   ;; -- API
   (push [this event])
-  (add-post-event-callback [this id callack])
+  (add-post-event-callback [this id callback-fn])
   (remove-post-event-callback [this id])
   (purge [this])


Add tests for sql rendering with arrays as parameter.

--- test/suricatta/extend_test.clj
+++ test/suricatta/extend_test.clj
@@ -24,12 +24,6 @@
         (sc/set-rollback! ctx)))))

 (use-fixtures :each my-fixture)
-
-;; (deftest inserting-json
-;;   (sc/execute *ctx* "create table t1 (data json, k int)")
-;;   (sc/execute *ctx* ["insert into t1 (data, k) values (?, ?)" (DSL/val #{:foo "bar"} datatype) 3])
-;;   (-> (sc/fetch *ctx* ["select * from t1"])
-;;       (println)))

 (deftype MyJson [data])

@@ -80,7 +74,7 @@
   (render [self]
     (let [items (->> (map str (.-data self))
                      (interpose ","))]
-      (str "{" (apply str items) "}")))
+      (str "'{" (apply str items) "}'::bigint[]")))

   (bind [self stmt index]
     (let [con (.getConnection stmt)
@@ -99,3 +93,10 @@
     (sc/execute *ctx* ["insert into t1 (data) values (?)" data]))
   (let [result (sc/fetch *ctx* "select * from t1")]
     (is (= result [{:data [1 2 3]}]))))
+
+(deftest render-array
+  (let [q (-> (dsl/insert-into :t1)
+              (dsl/insert-values {:data (myintarray [1 2 3])}))]
+    (is (= (fmt/get-sql q {:dialect :pgsql :type :inlined})
+           "insert into t1 (data) values ('{1,2,3}'::bigint[])"))))
+


Don't retry cached exhausted chs.

Don't retry cached exhausted chs.

--- src/onyx/peer/aggregate.clj
+++ src/onyx/peer/aggregate.clj
@@ -25,10 +25,11 @@
 (defn inject-pipeline-resource-shim
   [{:keys [onyx.core/queue onyx.core/ingress-queues onyx.core/task-map] :as event}]
   (let [session (extensions/bind-active-session queue (first (vals ingress-queues)))
+        uncached (into {} (remove (fn [[t _]] (some #{t} learned)) ingress-queues))
         consumers (map (fn [[task queue-name]]
                          {:input task
                           :consumer (extensions/create-consumer queue session queue-name)})
-                       ingress-queues)
+                       uncached)
         halting-ch (chan 0)
         read-ch (chan 1)
         rets


Declare

Declare


Added FIXME for using the `:skip-wiki fns from clojure.spec

* data-specs should be into own ns if can't be fixed

--- src/spec_tools/impl.cljc
+++ src/spec_tools/impl.cljc
@@ -63,6 +63,10 @@
   (let [{:keys [req opt req-un opt-un]} (some->> form (rest) (apply hash-map))]
     (flatten (map polish (concat req opt req-un opt-un)))))

+;;
+;; FIXME: using ^:skip-wiki functions from clojure.spec. might break.
+;;
+
 (defn register-spec! [k s]
   (s/def-impl k (s/form s) s))


added sleep

added sleep

--- src/riak_mesos/executor.clj
+++ src/riak_mesos/executor.clj
@@ -27,5 +27,6 @@
 (defn -main
   [master]
   (let [exec (riak-executor)
-        driver (exec/driver exec)])
-  (executor/start driver))
+        driver (exec/driver exec)]
+     (exec/start driver)
+  (Thread/sleep 100000)))


find instructions to start

find instructions to start

--- src/sandbox/multithread.clj
+++ src/sandbox/multithread.clj
@@ -138,3 +138,29 @@
                    processes-w-count)))
 ;=> processes-w-count is just another name for the "scheduled"
 ;; state map.
+
+(defn find-inst-to-be-fired-in-process
+         [locks
+          process-id
+          the-process-instructions
+          the-process-scheduled-parts]
+         (let [p-not-locked-instrs (set (->> the-process-instructions
+                                             (filter #(not (is-locked? process-id
+                                                                       the-process-instructions
+                                                                       locks
+                                                                       %)))))
+;;=> A set of not locked instructions
+               p-incomplete-instrs (set (->> (:instructions  the-process-
+                                                             scheduled-parts)
+                                             (filter incomplete-instruction?)
+                                             (map #(dissoc % :count))))
+;;=> A set of incomplete instructions
+               fireable-instrs (clojure.set/intersection p-not-locked-instrs
+                                                         p-incomplete-instrs)
+;;=> Their intersection
+               instr-id-to-fire (->> fireable-instrs
+                                     (sort-by #(.indexOf the-process-instructions %) < )
+                                     (first)
+                                     (:inst-id))]
+;;=> The first on of them
+           instr-id-to-fire))


Neil can't stand bad formatting

Neil can't stand bad formatting

--- src/shuppet/config_util.clj
+++ src/shuppet/config_util.clj
@@ -4,20 +4,19 @@
 (defn elb-listener
   "http://docs.aws.amazon.com/ElasticLoadBalancing/latest/APIReference/API_Listener.html"
   [elb-port instance-port protocol]
-  (without-nils
-   {:LoadBalancerPort elb-port
-    :InstancePort instance-port
-    :Protocol protocol
-    :InstanceProtocol protocol}))
+  (without-nils {:LoadBalancerPort elb-port
+                 :InstancePort instance-port
+                 :Protocol protocol
+                 :InstanceProtocol protocol}))

 (defn elb-healthcheck
   "http://docs.aws.amazon.com/ElasticLoadBalancing/latest/APIReference/API_HealthCheck.html"
   [target healthy-threshold unhealthy-threshold interval timeout]
   (without-nils {:Target target
-                      :HealthyThreshold healthy-threshold
-                      :UnhealthyThreshold unhealthy-threshold
-                      :Interval interval
-                      :Timeout timeout}))
+                 :HealthyThreshold healthy-threshold
+                 :UnhealthyThreshold unhealthy-threshold
+                 :Interval interval
+                 :Timeout timeout}))

 (defn sg-rule
   "Creates a Ingress/Egress config for a security group"


Remove original, explicitly synchronous algorithms.

--- src/snergly/algorithms.cljc
+++ src/snergly/algorithms.cljc
@@ -45,10 +45,6 @@
       grid
       (g/link-cells grid cell (rand-nth neighbors)))))

-(s/defn maze-binary-tree-sync :- g/Grid [grid :- g/Grid]
-  (assoc (reduce binary-tree-step grid (g/grid-coords grid))
-    :algorithm-name "binary-tree"))
-
 (s/defn maze-binary-tree [grid :- g/Grid result-chan report-partial-steps?]
   (go
     (let [step-and-report (fn [g c]
@@ -79,17 +75,6 @@
                    (sidewinder-end-run grid run)
                    (g/link-cells grid cell (:east cell)))]
     [new-grid (if end-run? [] run)]))
-
-(s/defn maze-sidewinder-sync :- g/Grid [grid :- g/Grid]
-  (loop [grid grid
-         [coord & coords] (g/grid-coords grid)
-         current-run [coord]]
-    (let [[new-grid processed-run] (sidewinder-step grid coord current-run)]
-      (if (empty? coords)
-        (assoc new-grid :algorithm-name "sidewinder")
-        (recur new-grid
-               coords
-               (conj processed-run (first coords)))))))

 (s/defn maze-sidewinder [grid :- g/Grid result-chan report-partial-steps?]
   (go-loop [grid (assoc grid :algorithm-name "sidewinder")
@@ -103,21 +88,6 @@
         (recur new-grid
                coords
                (conj processed-run (first coords)))))))
-
-(s/defn maze-aldous-broder-sync :- g/Grid [grid :- g/Grid]
-  (loop [grid grid
-         current (g/random-coord grid)
-         unvisited (dec (g/grid-size grid))]
-    (let [cell (g/grid-cell grid current)
-          neighbor (rand-nth (g/cell-neighbors cell))
-          neighbor-new? (empty? (:links (g/grid-cell grid neighbor)))]
-      (if (= unvisited 0)
-        (assoc grid :algorithm-name "aldous-broder")
-        (recur (if neighbor-new?
-                 (g/link-cells (g/begin-step grid) cell neighbor)
-                 grid)
-               neighbor
-               (if neighbor-new? (dec unvisited) unvisited))))))

 (s/defn maze-aldous-broder [grid :- g/Grid result-chan report-partial-steps?]
   (go-loop [grid (assoc grid :algorithm-name "aldous-broder")
@@ -175,18 +145,6 @@
                new-unvisited
                pairs)))))

-(s/defn maze-wilsons-sync :- g/Grid [grid :- g/Grid]
-  (loop [grid grid
-         unvisited (rest (shuffle (g/grid-coords grid)))
-         coord (rand-nth unvisited)]
-    (let [path (wilsons-loop-erased-walk grid coord unvisited)
-          [new-grid new-unvisited] (wilsons-carve-passage grid path unvisited nil false)]
-      (if (empty? new-unvisited)
-        (assoc new-grid :algorithm-name "wilsons")
-        (recur new-grid
-               new-unvisited
-               (rand-nth new-unvisited))))))
-
 (s/defn maze-wilsons [grid :- g/Grid result-chan report-partial-steps?]
   (go-loop [grid (assoc grid :algorithm-name "wilsons")
             unvisited (rest (shuffle (g/grid-coords grid)))
@@ -222,14 +180,6 @@
       (let [neighbor (rand-nth unvisited-neighbors)]
         [(g/link-cells grid current-cell neighbor)
          neighbor]))))
-
-(s/defn maze-hunt-and-kill-sync :- g/Grid [grid :- g/Grid]
-  (loop [grid grid
-         current-coord (g/random-coord grid)]
-    (let [[new-grid next-coord] (hunt-and-kill-step grid current-coord)]
-      (if-not next-coord
-        (assoc new-grid :algorithm-name "hunt-and-kill")
-        (recur new-grid next-coord)))))

 (s/defn maze-hunt-and-kill [grid :- g/Grid result-chan report-partial-steps?]
   (go-loop [grid (assoc grid :algorithm-name "hunt-and-kill")


Icon component

Icon component

--- src/trak/ui/components.cljs
+++ src/trak/ui/components.cljs
@@ -89,3 +89,25 @@
 (rum/defc link [props children]
   (let [proper-props (merge props {:on-click (create-onclick-handler props)})]
     [:a proper-props children]))
+
+
+;;;;;;;;;;;;;;;;;;;;
+;; Icon
+
+
+(rum/defc icon [type]
+  [:img {:src (str "/img/" type ".svg") :width "16"}])
+
+
+
+
+
+
+
+
+
+
+
+
+
+


Log errors except 404

Log errors except 404

--- src/asciinema/yada.clj
+++ src/asciinema/yada.clj
@@ -16,7 +16,7 @@

 (defn logger [ctx]
   (when-let [error (:error ctx)]
-    (when (= (-> ctx :response :status) 500)
+    (when (not= (-> ctx :response :status) 404)
       (log/error error))))

 (defn resource [model]


save IDE state

save IDE state

--- src/brevis/ui/core.clj
+++ src/brevis/ui/core.clj
@@ -176,7 +176,10 @@
       (spit selected
             (get-text-from-tab tab-idx)))))

-(defn a-exit  [e] (System/exit 0))
+(declare save-IDE-state)
+(defn a-exit  [e]
+  (save-IDE-state)
+  (System/exit 0))
 (defn a-copy  [e] (.copy (:text-area (get-editor))))
 (defn a-cut   [e] (.cut (:text-area (get-editor))))
 (defn a-paste [e] (.paste (:text-area (get-editor))))
@@ -515,31 +518,31 @@
 (defn make-ui
   "Make a multi-widget UI."
   []
-  (let [a-new (action :handler a-new :name "New" :tip "Create a new file.")
-        a-open (action :handler a-open :name "Open" :tip "Open a file")
-        a-save (action :handler a-save :name "Save" :tip "Save the current file.")
-        a-exit (action :handler a-exit :name "Exit" :tip "Exit the editor.")
-        a-copy (action :handler a-copy :name "Copy" :tip "Copy selected text to the clipboard.")
-        a-paste (action :handler a-paste :name "Paste" :tip "Paste text from the clipboard.")
-        a-cut (action :handler a-cut :name "Cut" :tip "Cut text to the clipboard.")
-        a-save-as (action :handler a-save-as :name "Save As" :tip "Save the current file.")
-        a-eval-file (action :handler a-eval-file :name "Evaluate" :tip "Evaluate the current file.")
-        a-restart-brevis
+  (let [action-new (action :handler a-new :name "New" :tip "Create a new file.")
+        action-open (action :handler a-open :name "Open" :tip "Open a file")
+        action-save (action :handler a-save :name "Save" :tip "Save the current file.")
+        action-exit (action :handler a-exit :name "Exit" :tip "Exit the editor.")
+        action-copy (action :handler a-copy :name "Copy" :tip "Copy selected text to the clipboard.")
+        action-paste (action :handler a-paste :name "Paste" :tip "Paste text from the clipboard.")
+        action-cut (action :handler a-cut :name "Cut" :tip "Cut text to the clipboard.")
+        action-save-as (action :handler a-save-as :name "Save As" :tip "Save the current file.")
+        action-eval-file (action :handler a-eval-file :name "Evaluate" :tip "Evaluate the current file.")
+        action-restart-brevis
         (action :handler (fn [e]
                            (System/exit 1))
                 :name "Restart Brevis"
                 :tip "Completely restarts the application")
-        a-projects (map #(action :handler (make-a-active-project %)
-                                 :name (str (:group %) "/" (:name %))
-                                 :tip (str (:group %) "/" (:name %)))
-                        (:projects @current-profile))
+        action-projects (map #(action :handler (make-a-active-project %)
+                                      :name (str (:group %) "/" (:name %))
+                                      :tip (str (:group %) "/" (:name %)))
+                             (:projects @current-profile))
         menus (menubar
-                :items [(menu :text "File" :items [a-new a-open a-save a-save-as a-exit])
-                        (menu :text "Edit" :items [a-copy a-cut a-paste])
-                        (menu :text "Run" :items [a-eval-file])
-                        (menu :text "Projects" :items (into [] a-projects))
+                :items [(menu :text "File" :items [action-new action-open action-save action-save-as action-exit])
+                        (menu :text "Edit" :items [action-copy action-cut action-paste])
+                        (menu :text "Run" :items [action-eval-file])
+                        (menu :text "Projects" :items (into [] action-projects))
                         (menu :text "Git" :items [])
-                        (menu :text "Brevis" :items [a-restart-brevis])
+                        (menu :text "Brevis" :items [action-restart-brevis])
                         #_(menu :text "My Project" :items [(action :handler (fn [e] nil) :name "Open a project")
                                                           (action :handler (fn [e] nil) :name "in")
                                                           (action :handler (fn [e] nil) :name "projects menu")])])
@@ -554,7 +557,11 @@
                          #_[[(:scroll-pane (get-editor)) "wrap, span 2, w 100%, h 75%"]
                            [(:scroll-pane @repl-input-window) "w 50%, h 25%"]
                            [(:scrollable @repl-output-window) "w 50%, h 25%"]])
-        f (frame :title "Brevis - UI" :width 1024 :height 768 #_:minimum-size #_[800 :by 600] :menubar menus)]
+        f (frame :title "Brevis" :width 1024 :height 768 #_:minimum-size #_[800 :by 600]
+                 :menubar menus :on-close :nothing #_:exit)]
+    (listen f
+            #{:window-closed :window-closing}
+            a-exit)
     (listen (:project-tree @project-browser) #_(select f [:#project-tree]) :selection
             (fn [e]
               (if-let [dir (last (selection e))]
@@ -574,6 +581,26 @@
     (.setLocation f 0 0)
     {:frame f
      :panel panel}))
+
+(defn save-IDE-state
+  "Save the state of the IDE."
+  []
+  (println "saving IDE state.")
+  (let [num-tabs (.getTabCount (:tabbed-panel @editor-window))
+        tab-names (map #(.getToolTipTextAt (:tabbed-panel @editor-window) %) (range num-tabs))
+        state-filename (str brevis-directory File/separator "IDE_state.clj")]
+    (spit state-filename {:open-files tab-names})))
+
+(defn load-IDE-state
+  "Load the IDE state, if it was saved."
+  []
+  (println "loading IDE state.")
+  (let [state-filename (str brevis-directory File/separator "IDE_state.clj")]
+    (if (.exists (file state-filename))
+      (let [saved-state (read-string (slurp state-filename))]
+        (doseq [filename (:open-files saved-state)]
+          (add-content-tab-from-filename filename @content-pane-params))))))
+

 (defn -main
   "Start from command line."
@@ -623,6 +650,7 @@
     (reset! repl-output-window ro)
     (make-ui)
     (load-file (str "src" File/separator "brevis" File/separator "ui" File/separator "keybinds.clj"))
+    (load-IDE-state)
     "Launched BrIDE"
     #_(add-content-tab-from-filename @current-filename params)
     #_(when-not (empty? (:current-filename @current-profile))


use room-for-name in place of clojure.core/some on (all-rooms)

--- src/subrosa/commands.clj
+++ src/subrosa/commands.clj
@@ -218,7 +218,7 @@
         nick (nick-for-channel channel)]
     (doseq [room rooms]
       (if (not (empty? room))
-        (if (some #{room} (all-rooms))
+        (if (room-for-name room)
           (if (nick-in-room? nick room)
             (dosync
              (send-to-room room (format ":%s PART %s :%s"


Use filter-keys-by-namespace to build query for MainView

--- src/discuss/views.cljs
+++ src/discuss/views.cljs
@@ -237,11 +237,13 @@
 (defui MainView
   static om/IQuery
   (query [this]
-         [:layout/title
-          {:layout/view (om/get-query MainContentView)}
-          {:discussion/items (om/get-query MainContentView)}
-          {:discussion/bubbles (om/get-query MainContentView)}
-          {:clipboard/items (om/get-query MainContentView)}])
+         (vec
+          (merge
+           (lib/filter-keys-by-namespace (keys parser/init-data) "layout")
+           {:layout/view (om/get-query MainContentView)}
+           {:discussion/items (om/get-query MainContentView)}
+           {:discussion/bubbles (om/get-query MainContentView)}
+           {:clipboard/items (om/get-query MainContentView)})))
   Object
   (render [this]
           (let [{:keys [layout/title]} (om/props this)]


Add pointer

Add pointer

--- src/discuss/views.cljs
+++ src/discuss/views.cljs
@@ -97,8 +97,9 @@
     (render-state [_ {:keys [show text]}]
       (when (= text "")                                     ; Set initial text to be displayed
         (om/set-state! owner :text (:text data)))
-      (dom/span #js {:style (display show)}
-        text))))
+      (dom/span #js {:className "pointer"
+                     :style (display show)}
+                text))))

 (defn clipboard-view []
   (reify om/IRender


Renamed create-fcn-by-props to factory-fcn-by-props.

--- src/yourproject/app.cljs
+++ src/yourproject/app.cljs
@@ -90,7 +90,7 @@
       ;; Forces post-assert fail.
       nil)))

-(defn create-fcn-by-props
+(defn factory-fcn-by-props
   "Gets create function for query via props."
   [props]
   {:pre [(not (nil? props))]
@@ -125,7 +125,7 @@
                      (dom/h4 nil (str "*** "(if logged-in? "LOGGED IN" "LOGGED OUT") "***"))

                      (navbar navbar-props)
-                     ((create-fcn-by-props props) page-props)))))
+                     ((factory-fcn-by-props props) page-props)))))

 ;;-----------------
 ;; Sets page.


Fixes bug

Fixes bug

--- src/expound/alpha.cljc
+++ src/expound/alpha.cljc
@@ -766,10 +766,8 @@
         (check-result? explain-data)
         (print-check-result explain-data)

-        :elsep
-        (do
-          (str "Unknonw data:::" (keys explain-data))
-          #_(str "Unknown data:\n\n" explain-data))))))
+        :else
+        (str "Unknown data:\n\n" explain-data)))))

 ;;(s/def ::foo string?)


validate config file existance

validate config file existance

--- ingestion-api/src/ingestion_api/core.clj
+++ ingestion-api/src/ingestion_api/core.clj
@@ -30,7 +30,9 @@
 (def cli-options
   "Command line options"
   [
-   ["-c" "--config FILE" "Config file (.edn)"]
+   ["-c" "--config FILE" "Config file (.edn)"
+    :validate [#(.exists (io/file %)) "The given file must exist"]]
+
    ["-h" "--help"]
    ])


attempt to fix multiple files palying at once

--- src/frontend/core.cljs
+++ src/frontend/core.cljs
@@ -21,7 +21,8 @@
                           :download-slots default-download-slots
                           :num-of-uploads 0
                           :num-of-downloads 0
-                          :download-progress {}}))
+                          :download-progress {}
+                          :tracks-to-delete []}))

 (enable-console-print!)

@@ -160,6 +161,23 @@
   (println "Song has finished!")
   (.emit socket "track-complete"))

+(defn while-loading []
+  (letfn [(remove-once [pred coll]
+            ((fn inner [coll]
+              (lazy-seq
+                (when-let [[x & xs] (seq coll)]
+                  (if (pred x)
+                    xs
+                    (cons x (inner xs))))))
+              coll))]
+    (this-as sound
+      (if (some #(= (.-id sound) %) (:tracks-to-delete @app-state))
+        (do
+          (println "DESTROYING SOUND FROM whileloading()")
+          (.destruct sound)
+          (swap! app-state assoc :tracks-to-delete
+            (vec (remove #(= (.-id sound) %) (:tracks-to-delete @app-state)))))))))
+
 (defn play-track [track-id position]
   (let [reader (new js/FileReader)
         song-blob (get (:music-files @app-state) track-id)]
@@ -170,12 +188,23 @@
           (.createSound js/soundManager #js {:id track-id
                                              :type "audio/mpeg"
                                              :url (.-result reader)
-                                             :autoLoad true}))
+                                             :autoLoad true
+                                             :whileloading while-loading
+                                             :onload while-loading}))
         (.play (:current-sound @app-state)
                #js {:whileplaying while-playing
                     :onfinish on-finish
                     :onplay #(.setPosition (:current-sound @app-state)
                                            position)})))))
+
+(defn destroy-track [track-id]
+  (if (or
+        (= 0 (.-readyState (:current-sound @app-state)))
+        (= 1 (.-readyState (:current-sound @app-state))))
+    (do
+      (println "HAPPENING!!!")
+      (swap! app-state assoc :tracks-to-delete (conj (:tracks-to-delete @app-state) track-id)))
+    (.destruct (:current-sound @app-state))))

 (.on socket "sign-in-success"
   (fn []
@@ -249,10 +278,13 @@
 (.on socket "track-change"
   (fn [track-id]
     (println "CHANGING TO TRACK " track-id)
-    (swap! app-state assoc :current-track-id track-id)
-
-    (if-not (nil? (:current-sound @app-state))
-      (.destruct (:current-sound @app-state)))
+    (let [last-current-track-id (:current-track-id @app-state)]
+      (swap! app-state assoc :current-track-id track-id)
+
+      (if-not (or
+                (= last-current-track-id track-id)
+                (nil? last-current-track-id))
+        (destroy-track last-current-track-id)))

     (if (nil? (get (:music-files @app-state) track-id))
       (.emit socket "file-download-request" track-id)


add describe for upstream compatibility

add describe for upstream compatibility

--- src/jasminejs/core.clj
+++ src/jasminejs/core.clj
@@ -45,7 +45,7 @@
                                    (aset this# "message" #(~msg expected# actual#))
                                    (~pred expected# actual#)))})))))

-(defmacro check [s & body]
+(defmacro describe [s & body]
   `((aget js/window "describe")
       ~s
       (fn []
@@ -53,6 +53,9 @@
                                  ". Actual: " (pr-str %2)))
         ~@body)))

+(defmacro check [s & body]
+  `(describe ~s ~@body))
+
 (defmacro it [s & body]
   `((aget js/window "it") ~s
       (fn [] (do ~@body))))


fix cut-n-paste error

fix cut-n-paste error

--- dada-core/src/main/clojure/org/dada/core.clj
+++ dada-core/src/main/clojure/org/dada/core.clj
@@ -65,7 +65,7 @@
 ;; TODO: Spring should look after this - see application-context.xml...
 (if (not (System/getProperty "dada.broker.name")) (System/setProperty "dada.broker.name" "DADA"))
 (if (not (System/getProperty "dada.broker.uri")) (System/setProperty "dada.broker.uri" "tcp://0.0.0.0:61616"))
-(if (not (System/getProperty "dada.broker.uri")) (System/setProperty "dada.client.uri" "tcp://localhost:61616"))
+(if (not (System/getProperty "dada.client.uri")) (System/setProperty "dada.client.uri" "tcp://localhost:61616"))

 (defn insert [#^View view item]
   (.update view (list (Update. nil item)) '() '())


more on macro

more on macro

--- src/language/macro.clj
+++ src/language/macro.clj
@@ -1,4 +1,6 @@
-(ns language.macro)
+(ns language.macro
+  (:require (clojure [string :as string]
+                     [walk :as walk])))

 (when (= (nth "abc" 1) \b)
   (println "b")
@@ -67,6 +69,59 @@
 (macroexpand-1 '(trymap [1 2 3]))

+;realize a foreach macro,this basically equals to the function of doseq (but not clojure's for)
+
+(defmacro foreach
+  [[sym coll] & body]
+  `(loop [coll# ~coll]
+     (when-let [[~sym & xs#] (seq coll#)]
+       ~@body
+       (recur xs#))))
+
+
+;a macro reverses all the symbols in the form
+
+(defmacro reverse-it
+  [form]
+  (walk/postwalk #(if (symbol? %)
+                    (symbol (string/reverse (name %)))
+                    %)
+                 form))
+
+(macroexpand-1 '(reverse-it (pam cni (egnar 5))))
+
+
+;we'd like macro returns list to represent futher calls of functions, forms or macros.
+
+(defmacro hello
+  [name]
+  (list 'println name))
+
+(macroexpand-1 '(hello "Brian"))
+
+;whereas using list is a natural way, It would be out of control when codes become complicated
+
+;as the following one
+(defmacro while
+  [test & body]
+  (list 'loop []
+        (concat (list 'when test) body '((recur)))))
+
+(def a (atom 10))
+
+(while (> @a 3) (do (println @a) (swap! a dec)))
+
+;we use this syntax sugar
+
+(defmacro while
+  [test & body]
+  `(loop []
+     (when ~test
+       ~@body
+       (recur))))
+
+
+(quote (a b))

@@ -84,13 +139,3 @@

-
-
-
-
-
-
-
-
-
-


make-queries-from-dirs need to return queries

--- src/larva/db/utils.clj
+++ src/larva/db/utils.clj
@@ -1,4 +1,5 @@
 (ns larva.db.utils
+  "Provides common utilities which larva needs for producing database related things."
   (:require [clojure.java.io :as io]
             [yesql.core :refer [defqueries]]
             [conman.core :as conman]))
@@ -24,29 +25,29 @@

 (defn make-queries-from-dirs
   "Takes a variable number of directory paths (which are presumably in the classpath),
-  options to forward to yesql.core/defqueries or connection to forward to conman.core/bind-connection  as arguments.
+  options to forward to `yesql.core/defqueries` or connection to forward to `conman.core/bind-connection`  as arguments.
   If options are provided:
-  for each path, finds the .sql files and calls `defqueries` on each.
+  for each directory path, finds .sql files in it and calls `defqueries` on each.
   If connection is provided:
-  Make vector of sql paths contained in provided directories and bind connection for each directory.
-  Does not walk subdirectories for more .sql files."
+  Make vector of .sql file paths contained in provided directories and bind connection for each directory.
+  Does not walk subdirectories for more .sql files.
+  Returns vector of queries partitioned by directories they originated from."
   [{:keys [paths options connection]}]
   (loop [dir-paths paths queries []]
-    (if (> (count dir-paths) 0)
-      (do
-        (let [dir (first dir-paths)
-              sqls (for [file (file-seq (-> dir io/resource io/file))
-                         :let [name (.getName file)]
-                         :when
-                         (#(and (.isFile %) (re-matches #".*\.sql$" name)) file)]
-                     (str dir (System/getProperty "file.separator") name))]
-          (if (nil? connection)
-            (loop [files sqls queries []]
-              (if (> (count files) 0)
-                (recur (rest files)
-                       (conj queries (defqueries (first files) options)))
-                queries))
-            (recur (rest dir-paths)
-                   (apply (functionalize conman/bind-connection)
-                          connection sqls)))))
+    (if (-> dir-paths count (> 0))
+      (let [dir (first dir-paths)
+            sqls (for [file (file-seq (-> dir io/resource io/file))
+                       :let [name (.getName file)]
+                       :when
+                       (#(and (.isFile %) (re-matches #".*\.sql$" name)) file)]
+                   (str dir (System/getProperty "file.separator") name))]
+        (recur (rest dir-paths)
+               (if (nil? connection)
+                 (loop [files sqls q []]
+                   (if (-> files count (> 0))
+                     (recur (rest files)
+                            (conj q (defqueries (first files) options)))
+                     (conj queries (flatten q))))
+                 (conj queries (apply (functionalize conman/bind-connection)
+                                      connection sqls)))))
       queries)))


Fixed whitespace in munge-project-args.

Fixed whitespace in munge-project-args.

--- src/leiningen/core.clj
+++ src/leiningen/core.clj
@@ -9,10 +9,9 @@

 (defn- munge-project-args [args]
   (walk (fn inner-munge [item]
-          (cond (and (seq? item)
-                     (= `unquote (first item))) (second item)
-                     (symbol? item) (list 'quote item)
-                     :else (munge-project-args item)))
+          (cond (and (seq? item) (= `unquote (first item))) (second item)
+                (symbol? item) (list 'quote item)
+                :else (munge-project-args item)))
         identity
         args))


Fix over-slurped function. Ooops.

Fix over-slurped function. Ooops.

--- src/leiningen/voom.clj
+++ src/leiningen/voom.clj
@@ -1002,38 +1002,38 @@
                   :lines
                   (filter-shas "tree"))
         all-shas (concat pack-shas obj-shas)]
-    all-shas)
-
-  (defn import-db
-    [gitdir]
-    (let [uri "datomic:mem://voom"
-          _ (d/delete-database uri)
-          _ (d/create-database uri)
-          conn (d/connect uri)
-          commits (git-commits gitdir "origin/master")
-          stxn (map gen-schema datomic-schema)
-          txn (apply concat
-                     (for [c commits
-                           :let [{:keys [sha ctime tree parents]} c
-                                 id (d/tempid :db.part/user)
-                                 cid (d/tempid :db.part/user)
-                                 tid (d/tempid :db.part/user)]]
-                       (concat
-                        [[:db/add id :git/type :commit]
-                         [:db/add id :git/sha sha]
-                         [:db/add id :commit/tree cid]
-                         [:db/add cid :node/object tid]
-                         [:db/add tid :git/type :tree]
-                         [:db/add tid :git/sha tree]]
-                        (apply concat
-                               (for [p parents
-                                     :let [pid (d/tempid :db.part/user)]]
-                                 [[:db/add pid :git/type :commit]
-                                  [:db/add pid :git/sha p]
-                                  [:db/add id :commit/parents pid]])))))]
-      @(d/transact conn stxn)
-      @(d/transact conn txn)
-      :done)))
+    all-shas))
+
+(defn import-db
+  [gitdir]
+  (let [uri "datomic:mem://voom"
+        _ (d/delete-database uri)
+        _ (d/create-database uri)
+        conn (d/connect uri)
+        commits (git-commits gitdir "origin/master")
+        stxn (map gen-schema datomic-schema)
+        txn (apply concat
+                   (for [c commits
+                         :let [{:keys [sha ctime tree parents]} c
+                               id (d/tempid :db.part/user)
+                               cid (d/tempid :db.part/user)
+                               tid (d/tempid :db.part/user)]]
+                     (concat
+                      [[:db/add id :git/type :commit]
+                       [:db/add id :git/sha sha]
+                       [:db/add id :commit/tree cid]
+                       [:db/add cid :node/object tid]
+                       [:db/add tid :git/type :tree]
+                       [:db/add tid :git/sha tree]]
+                      (apply concat
+                             (for [p parents
+                                   :let [pid (d/tempid :db.part/user)]]
+                               [[:db/add pid :git/type :commit]
+                                [:db/add pid :git/sha p]
+                                [:db/add id :commit/parents pid]])))))]
+    @(d/transact conn stxn)
+    @(d/transact conn txn)
+    :done))

 (def subtasks [#'build-deps #'deploy #'find-box #'freshen #'install
                #'retag-all-repos #'ver-parse #'wrap])


Fixing zlib build

Fixing zlib build

--- config/software/zlib.clj
+++ config/software/zlib.clj
@@ -16,6 +16,7 @@
 ; limitations under the License.
 ;

-(software "zlib"  :source "zlib-1.2.5" :steps [["env LDFLAGS='-R/opt/opscode/embedded/lib -L/opt/opscode/embedded/lib -I/opt/opscode/embedded/include' CFLAGS='-I/opt/opscode/embedded/include -L/opt/opscode/embedded/lib'" "./configure" "--prefix=/opt/opscode/embedded"]
+(software "zlib"  :source "zlib-1.2.5" :steps
+          [["env" "LDFLAGS=-R/opt/opscode/embedded/lib" "CFLAGS=-I/opt/opscode/embedded/include -L/opt/opscode/embedded/lib" "./configure" "--prefix=/opt/opscode/embedded"]
                                                ["make"]
                                                [ "make" "install"]])


Update schema.clj

Update schema.clj

--- src/oarlock/schema.clj
+++ src/oarlock/schema.clj
@@ -29,17 +29,17 @@
             [:instructor :ref]
             [:perf-asmts :ref :many]
             [:status :enum [:active :archived :preactive]]]}
-   {:namespace :user2perf-asmt
+   {:namespace :user2perf-asmt ;; TODO: rename to student2perf-asmt
     :attrs [[:user :ref]
             [:perf-asmt :ref]
             [:grade :boolean]]}
-   {:namespace :user2task
+   {:namespace :student2task
     :attrs [[:user :ref]
             [:task :ref]
             [:progress :boolean]]}
-   {:namespace :user2section
+   {:namespace :student2section
     :attrs [[:user :ref]
             [:section :ref]
-            ;; TODO: do we want to use our current model of status, or do something different?
+            [:events :ref :many] ;; examples: welcome-email-sent, welcome-call-done, follow-up-call-done, etc.
             [:status :enum [:active :completed :withdrawn-failing :withdrawn-no-grade]]
-            [:activation-status :enum [:assigned :assigned-emailed :enabled :contact-instructor]]]}])
+            [:access :enum [:assigned :enabled :contact-instructor]]]}])


parsing distance

parsing distance

--- src/ontrail/mutate.clj
+++ src/ontrail/mutate.clj
@@ -68,8 +68,16 @@
        (sport-ok? (:sport uex))
        (date-ok? (:date uex))))

-(defn parse-distance [d]
-  (Integer. d))
+(defn meters [m] (Integer. m))
+(defn kilometers [m] (* (Integer. m) 1000))
+
+(def distance-regexps
+  [{:re #"^([0-9]+)$" :conv meters}
+   {:re #"^([0-9]+) *m$" :conv meters},
+   {:re #"^([0-9]+) *km$" :conv kilometers}])
+
+(defn parse-distance [dist]
+  (some identity (map #(try-parse % dist) distance-regexps)))

 (defn parse-tags
   ([] '())
@@ -94,7 +102,7 @@
         (assoc :body body)
         (assoc :tags tags)
         (assoc :distance distance)
-        (assoc :avghr 0) ;; How to not insert if avghr nil?
+        (assoc :avghr 0)
         (assoc :comments '()))))

 (defn create-ex [params]


Small reformatting

Small reformatting

--- web-app/src/cljs/potato/core.cljs
+++ web-app/src/cljs/potato/core.cljs
@@ -756,8 +756,8 @@
                   (cond
                     ;; Hidden
                     isHidden
-                    (om.dom/span nil "Hidden"
-                     )
+                    (om.dom/span nil
+                      "Hidden")
                     ;; Unconfirmed
                     (and (:unconfirmed message) (:raw_field message))
                     (om.dom/span #js {:dangerouslySetInnerHTML #js {:__html (:raw_field message)}} nil)


Whitespace.

Whitespace.

--- src/postal/message.clj
+++ src/postal/message.clj
@@ -71,7 +71,7 @@
     (let [attachment-part (doto (javax.mail.internet.MimeBodyPart.)
                             (.attachFile (fileize (:content part)))
                             (.setDisposition (name (:type part))))]
-
+
       (when (:content-type part)
         (.setHeader attachment-part "Content-Type" (:content-type part)))
       attachment-part)
@@ -88,11 +88,11 @@
                                  ["mixed" parts])
         mp (javax.mail.internet.MimeMultipart. multiPartType)]
     (doseq [part parts]
-      (.addBodyPart mp (eval-part part)))
+      (.addBodyPart mp (eval-part part)))
     mp))

 (defn add-multipart! [jmsg parts]
-    (.setContent jmsg (eval-multipart parts)))
+  (.setContent jmsg (eval-multipart parts)))

 (defn add-extra! [jmsg msgrest]
   (doseq [[n v] msgrest]


Fixing java.classpath deps version

Fixing java.classpath deps version

--- joplin.core/project.clj
+++ joplin.core/project.clj
@@ -6,6 +6,6 @@
   :license {:name "Eclipse Public License"
             :url "http://www.eclipse.org/legal/epl-v10.html"}
   :dependencies [[org.clojure/clojure "1.6.0"]
-                 [org.clojure/java.classpath "0.2.3-SNAPSHOT"]
+                 [org.clojure/java.classpath "0.2.2"]
                  [clj-time "0.8.0"]
                  [ragtime/ragtime.core "0.3.8"]])


Implement repeating catcher and cache task

--- src/infoq_podcast/core.clj
+++ src/infoq_podcast/core.clj
@@ -8,26 +8,44 @@
             [taoensso.timbre        :as timbre :refer [trace debug info]]))

-;;; Main
+;;; Utilities

-(defn- prepare [p]
-  (let [guid (:link p)
-        date (:date p)]
-    (cache/put guid date p)
+(defn- interspaced
+  "Repeatedly execute task-fn following a t ms sleep. If arg is given, pass arg
+  to the initial execution and its result to subsequent executions."
+  ([t task-fn]
+     (future
+       (loop []
+         (task-fn)
+         (Thread/sleep t)
+         (recur))))
+  ([t task-fn arg]
+     (future
+       (loop [arg' arg]
+         (let [res (task-fn arg')]
+           (Thread/sleep t)
+           (recur res))))))
+
+(defn- secs [n]
+  (* n 1000))
+
+
+;;; Internals
+
+(defn- prepare-item [p]
+  (let [link (:link p)]
     [(rss/title (:title p))
-     (rss/link guid)
+     (rss/link link)
      (rss/description (:summary p))
      (rss/author "info@infoq.com") ;; (string/join ", " (:authors p))
-     (rss/pub-date date)
-     (rss/guid guid)
+     (rss/pub-date (:date p))
+     (rss/guid link)
      (apply rss/enclosure (:video p))
      (apply rss/category (:keywords p))]))

-(defn -main
-  "Requires n/12 + 2*n requests (/12 -> overview page, 2* -> page + video)."
-  []
-  (debug "Starting")
-  (cache/init)
+(defn- serve-feed
+  "Create and serve the presentation feed."
+  [coll]
   (let [channel [(rss/title "InfoQ Presentations Feed")
                  (rss/link "http://www.infoq.com")
                  (rss/description (str "Facilitating the spread of knowledge and "
@@ -35,7 +53,32 @@
                  (rss/language "en-US")
                  (rss/generator "InfoQ-Feed-Generator/1.0")]
         extensions [:atom :itunes :feedburner :simple-chapters :content :history]
-        items (->> (catcher/latest) (take 4) (map catcher/metadata) (map prepare))
+        items (map prepare-item coll)
         feed (rss/feed channel items extensions)]
-    (prn (cache/latest))
     (clojure.pprint/pprint feed)))
+
+(defn- cache-updates
+  "Scrape the overview sites and collect its oughly 12 items per site until
+  finding an seen item (since). Scrape a maximum of limit or 100 items. This
+  sequence requires additional two requests (page+video) per item, thus n%12 +
+  2*n."
+  ([since] (cache-updates since 100))
+  ([since limit]
+     (info "Check for updates since:" (or since :inf))
+     (->> (catcher/latest)
+          (take-while #(not= % since))
+          (pmap catcher/metadata)
+          (map cache/put)
+          (dorun (dec limit)))
+     (prn "Done.")))
+
+
+;;; Main
+
+(defn -main []
+  (let [task #(cache-updates (cache/latest) 13)]
+    (info "Starting")
+    (info "Initializing cache")
+    (cache/init)
+    (info "Spawing update task")
+    (interspaced (secs 30) task)))


plug sigma-driver into the MAIN function

--- cljx/plongeur-cljs/src/plongeur/core.cljs
+++ cljx/plongeur-cljs/src/plongeur/core.cljs
@@ -4,6 +4,7 @@
             [plongeur.intent :as i]
             [plongeur.model  :as m]
             [plongeur.view   :as v]
+            [plongeur.sigma-driver :as sig]
             [kierros.quiescent-dom-driver   :as dom]
             [kierros.sente-websocket-driver :as ws]
             [kierros.local-storage-driver   :as st]))
@@ -15,21 +16,33 @@
 (defn plongeur-main
   "Cycle main."
   [{dom-event-chan       :DOM
-    ;websocket-event-chan :WEB
-    saved-state-chan     :STORAGE}]
-  (let [intent-chans (i/intents)
-        states-chan  (m/model saved-state-chan intent-chans)
-        states-mult  (mult states-chan)
-        view-states-chan   (->> (chan) (tap states-mult))
+    sigma-event-chan     :SIGMA
+    saved-state-chan     :STORAGE
+    websocket-event-chan :WEB
+    }]
+  (let [sigma-chan         (chan 10)
+        intent-chans       (-> (i/intents)
+                               (assoc :sigma-ctrl sigma-chan))
+
+        states-chan        (m/model saved-state-chan intent-chans)
+        states-mult        (mult states-chan)
+
         pickle-states-chan (->> (sliding-buffer 1) (chan) (tap states-mult))
-        views-chan   (v/view view-states-chan intent-chans)
-        request-chan (chan)]
+
+        view-states-chan   (->> (chan 10) (tap states-mult))
+
+        request-chan       (chan 10)
+
+        views-chan         (v/view view-states-chan intent-chans)]
     {:DOM     views-chan
-     ;:WEB     request-chan
-     :STORAGE pickle-states-chan}))
+     :SIGMA   sigma-chan
+     :STORAGE pickle-states-chan
+     :WEB     request-chan}))

 (cycle/run
   plongeur-main
   {:DOM     (dom/make-dom-driver "plongeur-app")
-   ;:WEB     (ws/make-websocket-driver "/chsk")
-   :STORAGE (st/make-storage-driver "plongeur" m/default-state)})+   :SIGMA   (sig/make-sigma-driver)
+   :STORAGE (st/make-storage-driver "plongeur" m/default-state)
+   ;:WEB    (ws/make-websocket-driver "/chsk")
+   })