some trial n error

some trial n error

--- src/clj/signet/core.clj
+++ src/clj/signet/core.clj
@@ -106,7 +106,7 @@
                                  (get-in @stage ["kordano@topiq.es" r-id])
                                  "Some bookmarks")))

-  (get-in @stage ["kordano@topiq.es" r-id :state :causal-order])
+  (get-in @stage ["kordano@topiq.es" r-id :state])

   (d/q '[:find ?e ?u ?t
          :where
@@ -115,29 +115,31 @@
        (d/db conn))

-  (let [{:keys [commits branches head]}
+  ;; commit graph to layout
+
+  (let [{:keys [commits branches head] :as g}
         {:commits {10 #{}
                    20 #{10}
                    30 #{20}
                    40 #{20}
                    50 #{40}
                    60 #{50 30}
-                   70 #{60}}
+                   70 #{60}
+                   80 {}
+                   90 #{80}}
          :branches {"master" 10
-                    "slave" 40}
-         :head 70}
+                    "fix" 40
+                    "dev" 30}
+         :heads #{70 90}}
         inverted (->> commits
                       (map (fn [[k v]]
                              (if (empty? v)
                                {:root k}
                                (zipmap v (repeat (count v) k)))))
                       (apply merge-with list))]
-    (loop [h heads
-           real-order {}]
-      (if (empty? (get commits h))
-        real-order

-        )))
+
+    )

   )


small fixes in dependencies

small fixes in dependencies

--- src/clj/yambox/core.clj
+++ src/clj/yambox/core.clj
@@ -33,12 +33,12 @@
   (let [session-store (redis-store {:pool {} :spec {}})
         middleware-conf (deep-merge rmd/site-defaults
                                     {:security {:anti-forgery false}}
-                                    {:session {:store session-store}})
+                                    #_{:session {:store session-store}})
         naked-handler (c/routes
                        routes/main
                        (c/context "/management" req
                          (friend/wrap-authorize routes/secure #{::user}))
-                       (route/resources "/")
+                       (cr/resources "/")
                        (cr/not-found "Page not found"))]
     (-> naked-handler
         (friend/authenticate (oauth/friend-config config))


Removed useless functions 'get-connection' and 'release-connection'. Renamed 'bind-connection' 'bind?' to reflect the boolean response. Corrected documentation.

--- src/clj_ldap/client.clj
+++ src/clj_ldap/client.clj
@@ -22,7 +22,8 @@
             EntrySourceException
             SearchScope])
   (:import [com.unboundid.ldap.sdk.extensions
-            PasswordModifyExtendedRequest])
+            PasswordModifyExtendedRequest
+            PasswordModifyExtendedResult])
   (:import [com.unboundid.ldap.sdk.controls
             PreReadRequestControl
             PostReadRequestControl
@@ -323,26 +324,23 @@
       (connect-to-hosts options)
       (connect-to-host options))))

-(defn get-connection
-  "Retrieves an LDAP connection from the pool."
-  [connection-pool]
-  (.getConnection connection-pool))
-
-(defn release-connection
-  "Releases the provided connection back to the pool."
-  [connection-pool connection]
-  (.releaseConnection connection-pool connection))
-
-(defn bind-connection
-  "Performs a bind operation using the provided connection and optional
-   credentials. If called with a connection pool, the connection used
-   for the bind request is returned to the pool after the server response.
-   If called with an LDAP connection, and the bind request is successful,
-   it will change the identity of that connection."
-    [connection bind-dn password]
-    (try
-      ((.bind connection bind-dn password) true)
-      (catch Exception _ false)))
+(defn bind?
+  "Performs a bind operation using the provided connection, bindDN and
+password. Returns true if successful.
+
+When an LDAP connection object is used as the connection argument the
+bind? function will attempt to change the identity of that connection
+to that of the provided DN. Subsequent operations on that connection
+will be done using the bound identity.
+
+If an LDAP connection pool object is passed as the connection argument
+the bind attempt will have no side-effects, leaving the state of the
+underlying connections unchanged."
+  [connection bind-dn password]
+  (try
+    (let [bind-result (.bind connection bind-dn password)]
+      (if (= ResultCode/SUCCESS (.getResultCode bind-result)) true false))
+    (catch Exception _ false)))

 (defn get
   "If successful, returns a map containing the entry for the given DN.
@@ -409,8 +407,8 @@
     (let [request (PasswordModifyExtendedRequest. old new)]
       (.processExtendedOperation connection request)))

-  ([connection dn old new]
-    (let [request  (PasswordModifyExtendedRequest. dn old new)]
+  ([connection old new dn]
+    (let [request (PasswordModifyExtendedRequest. dn old new)]
       (.processExtendedOperation connection request))))

 (defn delete


Add 'empty' for all collections.  Refs #10, #1

--- src/cljs/cljs/core.cljs
+++ src/cljs/cljs/core.cljs
@@ -699,7 +699,7 @@
   (-conj [coll o] (cons o coll))

   IEmptyableCollection
-  (-iempty [coll] coll)
+  (-empty [coll] (with-meta cljs.core.List/EMPTY meta))

   ISequential
   IEquiv
@@ -901,7 +901,7 @@
   (-conj [coll o] (List. meta o coll (inc count)))

   IEmptyableCollection
-  (-iempty [coll] coll)
+  (-empty [coll] (with-meta cljs.core.List/EMPTY meta))

   ISequential
   IEquiv
@@ -938,7 +938,7 @@
   (-conj [coll o] (List. meta o nil 1))

   IEmptyableCollection
-  (-iempty [coll] coll)
+  (-empty [coll] coll)

   ISequential
   IEquiv
@@ -976,7 +976,7 @@
   (-conj [coll o] (Cons. nil o coll))

   IEmptyableCollection
-  (-iempty [coll] (EmptyList. nil))
+  (-empty [coll] (with-meta cljs.core.List/EMPTY meta))

   ISequential
   IEquiv
@@ -1121,7 +1121,7 @@
       (Vector. meta new-array)))

   IEmptyableCollection
-  (-iempty [coll] coll)
+  (-empty [coll] (with-meta cljs.core.Vector/EMPTY meta))

   ISequential
   IEquiv
@@ -1216,7 +1216,7 @@
   (-conj [coll entry] (-assoc coll (-nth entry 0) (-nth entry 1)))

   IEmptyableCollection
-  (-iempty [coll] coll)
+  (-empty [coll] (with-meta cljs.core.ObjMap/EMPTY meta))

   IEquiv
   (-equiv [coll other] (equiv-map coll other))
@@ -1268,6 +1268,8 @@
     (let [pr-pair (fn [keyval] (pr-sequential pr-seq "" " " "" opts keyval))]
       (pr-sequential pr-pair "{" ", " "}" opts coll))))

+(set! cljs.core.ObjMap/EMPTY (ObjMap. nil (array) (js-obj)))
+
 (set! cljs.core.ObjMap/fromObject (fn [ks obj] (ObjMap. nil ks obj)))

 ; The keys field is an array of all keys of this map, in no particular
@@ -1286,7 +1288,7 @@
   (-conj [coll entry] (-assoc coll (-nth entry 0) (-nth entry 1)))

   IEmptyableCollection
-  (-iempty [coll] coll)
+  (-empty [coll] (with-meta cljs.core.HashMap/EMPTY meta))

   IEquiv
   (-equiv [coll other] (equiv-map coll other))
@@ -1382,6 +1384,11 @@
        (recur (conj coll x) (first xs) (next xs))
        (conj coll x))))

+(defn empty
+  "Returns an empty collection of the same category as coll, or nil"
+  [coll]
+  (when (coll? coll)
+    (-empty coll)))

 ;;; Math - variadic forms will not work until the following implemented:
 ;;; first, next, reduce
@@ -2082,5 +2089,34 @@
     (assert (= {:a 1} (meta a)))
     (alter-meta! a assoc :b 2)
     (assert (= {:a 1 :b 2} (meta a))))
+  (assert (nil? (empty nil)))
+  (let [e-lazy-seq (empty (with-meta (lazy-seq (cons :a nil)) {:b :c}))]
+    (assert (seq? e-lazy-seq))
+    (assert (empty? e-lazy-seq))
+    (assert (= {:b :c} (meta e-lazy-seq))))
+  (let [e-list (empty '^{:b :c} (1 2 3))]
+    (assert (seq? e-list))
+    (assert (empty? e-list))
+    (assert (= :c (get (meta e-list) :b))))
+  (let [e-elist (empty '^{:b :c} ())]
+    (assert (seq? e-elist))
+    (assert (empty? e-elist))
+    (assert (= :c (get (meta e-elist) :b))))
+  (let [e-cons (empty (with-meta (cons :a nil) {:b :c}))]
+    (assert (seq? e-cons))
+    (assert (empty? e-cons))
+    (assert (= {:b :c} (meta e-cons))))
+  (let [e-vec (empty ^{:b :c} [:a :d :g])]
+    (assert (vector? e-vec))
+    (assert (empty? e-vec))
+    (assert (= {:b :c} (meta e-vec))))
+  (let [e-omap (empty ^{:b :c} {:a :d :g :h})]
+    (assert (map? e-omap))
+    (assert (empty? e-omap))
+    (assert (= {:b :c} (meta e-omap))))
+  (let [e-hmap (empty ^{:b :c} {[1 2] :d :g :h})]
+    (assert (map? e-hmap))
+    (assert (empty? e-hmap))
+    (assert (= {:b :c} (meta e-hmap))))
   :ok
 )


reorganize code

reorganize code

--- src/cljs/jiyi/core.cljs
+++ src/cljs/jiyi/core.cljs
@@ -13,19 +13,55 @@

 (enable-console-print!)

+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Stores
+
 (defonce user (atom {}))
-;; (defonce search-term (atom ""))
-;; (defonce search-results (atom []))

-;; -------------------------
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Actions
+
+
+(defn- extract-content [] (map #(-> % :body :Entries)))
+
+(defn <get-user
+  [userid]
+  (http/jsonp "https://genome.klick.com:443/api/User.json"
+              {:query-params {"UserID" userid}
+               :channel (chan 1 (extract-content))}))
+
+(defn <search-user
+  [keyword]
+  (http/jsonp "https://genome.klick.com:443/api/User.json"
+              {:query-params {:ForAutocompleter true
+                              :Enabled true
+                              :IsNotAPerson false
+                              :Keyword keyword}
+               :channel (chan 1 (extract-content))}))
+
+
+(defn json->userdetails [json]
+  {:id (:UserID json)
+   :photo (str "https://genome.klick.com" (:PhotoPath json))
+   :name (:Name json)
+   :title (:Title json)
+   :dept (:BusinessUnitName json)})
+
+(defn save-to-atom [atm id]
+  (go
+    (as-> (<! (<get-user id)) $
+      (first $)
+      (json->userdetails $)
+      (reset! user $))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Views

-(defn home-page []
-  [:div [:h2 "Yo, Welcome to jiyi"]])
-
-(defn Card []
+(defn Card [user]
   (let [{:keys [id photo name title dept]} @user]
     [:div.card {:style {:width "400px" :height "600px"}}
      [:div.card-image.waves-effect.waves-block.waves-light
@@ -52,35 +88,11 @@
        [:p dept]]]]))

-(defn about-page []
-  [:div [:h2 "About jiyi"]])
-
-(defn- extract-content [] (map #(-> % :body :Entries)))
-
-(defn <get-user
-  [userid]
-  (http/jsonp "https://genome.klick.com:443/api/User.json"
-              {:query-params {"UserID" userid}
-               :channel (chan 1 (extract-content))}))
-
-(defn <search-user
-  [keyword]
-  (http/jsonp "https://genome.klick.com:443/api/User.json"
-              {:query-params {:ForAutocompleter true
-                              :Enabled true
-                              :IsNotAPerson false
-                              :Keyword keyword}
-               :channel (chan 1 (extract-content))}))
-
-;; (go
-;;   (prn (<! (<search-user "ash"))))
-
-
 (defn SearchResults [results]
   [:div.row
    [:ul.collection
     (map (fn [result]
-           [:li.collection-item {:key (:UserID result)} (:Name result)])
+           [:li.collection-item ^{:key (:UserID result)} (:Name result)])
          results)]])

 (defn Search []
@@ -99,35 +111,20 @@
                                  (when-not (empty? newval)
                                    (go
                                      (reset! search-results (<! (<search-user newval)))))))}]]]
-       ;;Results
        [SearchResults @search-results ]])))

-(defn json->userdetails [json]
-  {:id (:UserID json)
-   :photo (str "https://genome.klick.com" (:PhotoPath json))
-   :name (:Name json)
-   :title (:Title json)
-   :dept (:BusinessUnitName json)})
-
-(defn save-to-atom [atm id]
-  (go
-    (as-> (<! (<get-user id)) $
-      (first $)
-      (json->userdetails $)
-      (reset! user $))))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Routes

 (save-to-atom user 5702)

-(defn card [] (Card))
+(defn card [] (Card user))
+
 (defn search [] (Search))
-

 (defn current-page []
   [:div [(session/get :current-page)]])
-
-;; -------------------------
-;; Routes
 (secretary/set-config! :prefix "#")

 (secretary/defroute "/" []
@@ -139,8 +136,6 @@
 (secretary/defroute "/search" []
   (session/put! :current-page #'search))

-(secretary/defroute "/about" []
-  (session/put! :current-page #'about-page))

 ;; -------------------------
 ;; History


Fix channel-type selection

Fix channel-type selection

--- src/cljs/virt/home.cljs
+++ src/cljs/virt/home.cljs
@@ -50,37 +50,39 @@
           (om/build-all list-item (:channels data) {:init-state {:comm comm}
                                                     :opts {:channel-types channel-types}}))))))

-(defn radio-selector [values owner]
+(defn radio-selector [{:keys [channel-types selected-type update-type-fn]} owner]
+  (reify
+    om/IRender
+    (render [_]
+      (apply dom/div #js {:ref "channel-type" :id "radio-selector"}
+        (map (fn [[id ch-type]]
+               (dom/div #js {:className (str "radio-option" (if (= selected-type (name id)) " radio-option-selected"))
+                             :value (name id)
+                             :onClick #(update-type-fn (name id))}
+                 (dom/img #js {:src "img/check.png" :width 16 :height 16 :className "check"})
+                 (dom/span nil
+                   (:name ch-type))))
+             channel-types)))))
+
+(defn new-channel [_ owner {:keys [channel-types]}]
   (reify
     om/IInitState
     (init-state [_]
-      {:selected nil})
+      {:selected-type nil})
     om/IRenderState
-    (render-state [_ {:keys [selected]}]
-      (apply dom/div #js {:ref "channel-type" :id "radio-selector"}
-        (map (fn [[id ch-type]]
-               (dom/div #js {:className (str "radio-option" (if (= selected (name id)) " radio-option-selected"))
-                             :value (name id)
-                             :onClick #(om/set-state! owner :selected (name id))}
-                 (dom/img #js {:src "img/check.png" :width 16 :height 16 :className "check"})
-                 (dom/span nil
-                   (:name ch-type))))
-             values)))))
-
-(defn new-channel [_ owner {:keys [channel-types]}]
-  (reify
-    om/IRenderState
-    (render-state [_ {:keys [comm]}]
+    (render-state [_ {:keys [comm selected-type]}]
       (dom/form #js {:className "full-width-form"}
         (dom/input #js {:ref "channel-name" :type "text" :placeholder "Title" :autoFocus true})
-        (om/build radio-selector channel-types)
+        (om/build radio-selector {:channel-types channel-types
+                                  :selected-type selected-type
+                                  :update-type-fn #(om/set-state! owner :selected-type %)})
         (dom/button
           #js {:className "transparent-button"
                :onClick (fn [e]
                           (.preventDefault e)
                           (put! comm [:new-channel
                                       [(.-value (om/get-node owner "channel-name"))
-                                       (.-value (om/get-node owner "channel-type"))]]))}
+                                       selected-type]]))}
           "Create")))))

 (defn main [{:keys [page params data]} owner opts]


fix: catch exception in callbacker

fix: catch exception in callbacker

--- src/main/clojure/pdok/featured/api.clj
+++ src/main/clojure/pdok/featured/api.clj
@@ -72,7 +72,10 @@
   {:dataset s/Str})

 (defn- callbacker [uri run-stats]
-  (http/post uri {:body (json/generate-string run-stats) :headers {"Content-Type" "application/json"}}))
+  (try
+    (http/post uri {:body (json/generate-string run-stats)
+                    :headers {"Content-Type" "application/json"}})
+    (catch Exception e (log/error "Callback error" e))))

 (defn- stats-on-callback [callback-chan request stats]
   (when (:callback request)


Raise errors if invalid

Raise errors if invalid

--- src/clojure/core.clj
+++ src/clojure/core.clj
@@ -138,10 +138,21 @@
     (xtract/xtract_wavelet_f0 wave-data block-size (xtract-args sample-rate) r)
     (first r)))

+(defn raise-errors [result]
+    (cond
+      (= result xtract-success)        true
+      (= result xtract-bad-argv)       (throw (Exception. "Bad argv error"))
+      (= result xtract-argument-error) (throw (Exception. "Bad arguments error"))
+      true (throw (Exception. "Unknown result type"))))
+
 (defn frequency->cents [f0]
-  (let [cents (double-array 1)]
-    (xtract/xtract_midicent nil 0 (xtract-args f0) cents)
-    (first cents)))
+  (if (= 0.0 f0)
+    0.0
+    (let [cents (double-array 1)]
+      (let [r (xtract/xtract_midicent nil 0 (xtract-args f0) cents)]
+        (raise-errors r)
+        (first cents)))))
+

 (defn peek-inside
   ([sample-path] (peek-inside sample-path DEFAULT_BLOCK_SIZE))


Remove merge-all from rstore.

Remove merge-all from rstore.

--- frontend/uxbox/rstore.cljs
+++ frontend/uxbox/rstore.cljs
@@ -101,7 +101,6 @@
     ;; pushed to the event-stream bus
     (as-> (rx/with-latest-from vector state-s watch-s) $
       (rx/flat-map (fn [[event model]] (-apply-watch event model)) $)
-      (rx/merge-all $)
       (rx/on-value $ emit!))

     ;; Initialize the stream machinary with initial state.


Revert b1673ecac60adf9a404080dbeb08f6ae1124b9ee 0f4c192fca7a640cde4c84b110d12bf24accabc9

--- backend/src/akvo/lumen/endpoint/user.clj
+++ backend/src/akvo/lumen/endpoint/user.clj
@@ -31,7 +31,6 @@
     ["/profile" {:get {:handler (fn [{tenant :tenant
                                     query-params :query-params}]
                                   (let [u (user/user authorizer tenant (get query-params "email"))]
-                                    (log/error :email (get query-params "email") :profile u)
                                     (lib/ok (select-keys u [:admin :email :firstName :id :lastName]))))}}]
    ["/admin/users"
     ["" {:get {:handler (fn [{tenant :tenant}]


Debug

Debug

--- backend/src/akvo/lumen/lib/dashboard.clj
+++ backend/src/akvo/lumen/lib/dashboard.clj
@@ -94,7 +94,7 @@
   (when-let [d (db.dashboard/dashboard-by-id tenant-conn {:id id})]
     (let [dashboard (handle-dashboard-by-id tenant-conn id)
           aggregated-dashboard (aggregation/aggregate-dashboard-viss dashboard tenant-conn windshaft-url)
-          aggregated-entities (reduce (fn [c [k v]] (assoc c k (assoc v :type "visualisation")))
+          aggregated-entities (reduce (fn [c [k v]] (assoc c (keyword k) (assoc v :type "visualisation")))
                                       {} (:visualisations aggregated-dashboard))
           res (update dashboard :entities #(merge % aggregated-entities))]
       (log/info :fetch-aggregated :aggregated-dashboard aggregated-dashboard)


SC Book pp17-20

SC Book pp17-20

--- src/overtone_workspace/sc-one.clj
+++ src/overtone_workspace/sc-one.clj
@@ -78,6 +78,7 @@
            (comb-n src 5 0 5)
            ))
 (odoc demo)
+(println *demo-time*)
 (odoc comb-n)
 (odoc midicps)
 (odoc mul-add)
@@ -121,6 +122,18 @@

 (demo 2 (pm-osc 440 550 7))
 (demo 5 (pm-osc 440 (mouse-y:kr 250 300) (mouse-x:kr 6 7)))
+
+
+(demo 2 (pm-osc 100 500 10 0))
+
+;;Page 55
+;; note 3
+;; {PMOsc.ar(Line.kr(10, 1000, 60), Line.kr(1000, 10, 60) Line.kr(1, 30, 60))}.play
+(demo 60 (pm-osc (line:kr 10 1000 60) (line:kr 1000 10 60) (line:kr 1 30 60)))
+(odoc line)
+
+(demo 10 (pm-osc 1000 10 30))
+
 (println mouse-x)

 (odoc demo)
@@ -151,13 +164,23 @@
 ;;
 ;;/////////////

-(demo 10
+(demo 90
       (let [trigger       (line:kr :start 1, :end 20, :dur 60)
             freq          (t-rand:kr :lo 100, :hi 1000, :trig (impulse:kr trigger))
             num-harmonics (t-rand:kr :lo 1,   :hi 10,   :trig (impulse:kr trigger))
             amp           (linen:kr :gate (impulse:kr trigger) :attack-time 0, :sus-level 0.5, :release-time (/ 1 trigger))]
         (* amp (blip freq num-harmonics))))

+(odoc blip)
+
+(demo 60 (* (linen:kr :gate (impulse:kr (line:kr :start 1 :end 20 :dur 60)) :attack-time 0 :sus-level 0.5 :release-time (/ 1.0 (line:kr :start 1 :end 20 :dur 60))) (blip 1000 10)))
+
+(demo 10 (* (linen:kr :gate (impulse:kr 20) :attack-time 0 :sus-level 0.5 :release-time (/ 1.0 20)) (blip [1000, 1001] 5)))
+
+(demo (blip 1000 10))
+(odoc linen)
+(odoc line)
+(stop)

 ;;;;;;;;;
@@ -197,7 +220,7 @@
 ;;
 ;;///////////// Figure 1.6 Phase modulation with modulator as ratio

-(demo 10 (let [r (line:kr :start 1, :end 20, :dur 60)
+(demo 30 (let [r (line:kr :start 1, :end 20, :dur 60)
                ;;r (+ 7 (* 3 (lf-tri:kr 0.1)))
                t (impulse:kr r)
                ;;t (dust:kr r)


Better erroring when format is not infered or specified.

--- src/rdf-common/grafter/rdf/io.clj
+++ src/rdf-common/grafter/rdf/io.clj
@@ -2,6 +2,7 @@
   (:require [clojure.java.io :as io]
             [grafter.rdf.protocols :as pr]
             [clojure.tools.logging :as log]
+            [me.raynes.fs :as fs]
             [pantomime.media :as mime])
   (:import (grafter.rdf.protocols IStatement Quad Triple)
            (java.io File)
@@ -308,6 +309,21 @@
          (when-let [graph (.getContext st)]
            (sesame-rdf-type->type graph))))

+(defn filename->rdf-format
+  "Given a filename we attempt to return an appropriate RDFFormat
+  object based on the files extension."
+  [fname]
+  (Rio/getParserFormatForFileName fname))
+
+(defn mimetype->rdf-format
+  "Given a mimetype string we attempt to return an appropriate
+  RDFFormat object based on the files extension."
+  [mime-type]
+  (let [base-type (str (mime/base-type mime-type))]
+    (condp = base-type
+      "application/n-triples" RDFFormat/NTRIPLES ;; Sesame doesn't yet support application/n-triples
+      (Rio/getParserFormatForMIMEType mime-type))))
+
 (defn rdf-serializer
   "Coerces destination into an java.io.Writer using
   clojure.java.io/writer and returns an RDFSerializer.
@@ -326,15 +342,15 @@

   ([destination & {:keys [append format encoding] :or {append false
                                                        encoding "UTF-8"}}]
-     (let [^RDFFormat format (or format
-                      (condp = (class destination)
-                        String (Rio/getWriterFormatForFileName destination)
-                        File   (Rio/getWriterFormatForFileName (str destination))
-                        (throw (ex-info "Could not infer file format, please supply a :format parameter" {:error :could-not-infer-file-format :object destination}))))]
-       (Rio/createWriter format
-                         (io/writer destination
-                                    :append append
-                                    :encoding encoding)))))
+   (let [^RDFFormat format (or format
+                               (condp = (class destination)
+                                 String (filename->rdf-format destination)
+                                 File   (filename->rdf-format destination))
+                               (throw (ex-info "Could not infer file format, please supply a :format parameter" {:error :could-not-infer-file-format :object destination})))]
+     (Rio/createWriter format
+                       (io/writer destination
+                                  :append append
+                                  :encoding encoding)))))

 (extend-protocol pr/ITripleWriteable
   RDFWriter
@@ -374,21 +390,6 @@
       (throw (ex-info (str "Unsupported format: " (pr-str format)) {:type :unsupported-format})))
     (let [^RDFParserFactory factory (.newInstance parser-class)]
       (.getParser factory))))
-
-(defn filename->rdf-format
-  "Given a filename we attempt to return an appropriate RDFFormat
-  object based on the files extension."
-  [fname]
-  (Rio/getParserFormatForFileName fname))
-
-(defn mimetype->rdf-format
-  "Given a mimetype string we attempt to return an appropriate
-  RDFFormat object based on the files extension."
-  [mime-type]
-  (let [base-type (str (mime/base-type mime-type))]
-    (condp = base-type
-      "application/n-triples" RDFFormat/NTRIPLES ;; Sesame doesn't yet support application/n-triples
-      (Rio/getParserFormatForMIMEType mime-type))))

 ;; http://clj-me.cgrand.net/2010/04/02/pipe-dreams-are-not-necessarily-made-of-promises/
 (defn- pipe


points cleanup

points cleanup


Make feature flag cookies persist past session end

With an unspecified max age they disappear when the browser restarts
and, I think, at other times. Add a ridic high max age to fix that.

--- src-cljs/frontend/models/feature.cljs
+++ src-cljs/frontend/models/feature.cljs
@@ -32,13 +32,16 @@
   (-> (get-in-cookie feature)
       feature-flag-value-true?))

+;; feature cookies should be basically permanent, so make them last for 10 years
+(def feature-cookie-max-age (* 60 60 24 365 10))
+
 ;; export so we can set this using javascript in production
 (defn ^:export enable-in-cookie [feature]
-  (cookies/set (feature-flag-key-name feature) "true"))
+  (cookies/set (feature-flag-key-name feature) "true" feature-cookie-max-age))

 ;; export so we can set this using javascript in production
 (defn ^:export disable-in-cookie [feature]
-  (cookies/set (feature-flag-key-name feature) "false"))
+  (cookies/set (feature-flag-key-name feature) "false" feature-cookie-max-age))

 ;; export so we can set this using javascript in production
 (defn ^:export enabled?


Simplify 'document' workflow sidebar width handling.

--- src-cljs/pepa/workflows/document.cljs
+++ src-cljs/pepa/workflows/document.cljs
@@ -205,26 +205,26 @@
           page-events (:pages state)
           tag-changes (:tag-changes state)
           sidebars (om/observe owner (data/ui-sidebars))
-          meta-width (get sidebars ::meta
-                          css/default-sidebar-width)
-          thumbnail-width (get sidebars ::thumbnails
-                               css/default-sidebar-width)
           current-page (nth (:pages (om/value document))
                             (dec (or page-number 1)))]
       [:.workflow.document
-       [:.pane {:style {:min-width thumbnail-width
-                        :max-width thumbnail-width}}
-        (om/build thumbnails document
-                  {:init-state {:events page-events}
-                   :state {:current-page current-page}})]
+       ;; Left (thunbmail) pane
+       (let [width (get sidebars ::thumbnails
+                        css/default-sidebar-width)]
+         [:.pane {:style {:min-width width :max-width width}}
+          (om/build thumbnails document
+                    {:init-state {:events page-events}
+                     :state {:current-page current-page}})])
        [:.pane
         (om/build pages document
                   {:init-state {:events page-events}
                    :state {:current-page current-page}})]
-       [:.pane {:style {:min-width meta-width
-                        :max-width meta-width}}
-        (om/build meta-pane document
-                  {:init-state {:tags tag-changes}})]])))
+       ;; Right (meta) pane
+       (let [width (get sidebars ::meta
+                        css/default-sidebar-width)]
+         [:.pane {:style {:min-width width :max-width width}}
+          (om/build meta-pane document
+                    {:init-state {:tags tag-changes}})])])))

 (defmethod draggable/pos->width ::thumbnails [sidebars sidebar [x _]]
   (draggable/limit


[#2620] Adapt category option in scatter aggregation

--- backend/src/akvo/lumen/lib/aggregation/scatter.clj
+++ backend/src/akvo/lumen/lib/aggregation/scatter.clj
@@ -1,6 +1,6 @@
 (ns akvo.lumen.lib.aggregation.scatter
   (:require [akvo.lumen.lib :as lib]
-            [akvo.lumen.lib.aggregation.commons :refer (run-query sql-aggregation-subquery) :as commons]
+            [akvo.lumen.lib.aggregation.commons :refer (run-query sql-aggregation-subquery sql-option-bucket-column) :as commons]
             [akvo.lumen.lib.dataset.utils :refer (find-column)]
             [akvo.lumen.postgres.filter :refer (sql-str)]
             [clojure.java.jdbc :as jdbc]
@@ -56,7 +56,7 @@
                          (:columnName column-x)
                          (:columnName column-y)
                          (:columnName column-size)
-                         (:columnName column-category)
+                         (sql-option-bucket-column column-category)
                          (:columnName column-label)
                          table-name
                          filter-sql
@@ -105,7 +105,7 @@
                          (:columnName column-x)
                          (:columnName column-y)
                          (:columnName column-size)
-                         (:columnName column-category)
+                         (sql-option-bucket-column column-category)
                          (:columnName column-label)
                          table-name
                          filter-sql)


Tidy up SQLKorma syntax.

Tidy up SQLKorma syntax.

--- src/chronograph/import/resolver.clj
+++ src/chronograph/import/resolver.clj
@@ -60,9 +60,9 @@
   ; Insert recently published.
   (let [yesterday (t/minus (t/now) (t/days 1))
         today (t/plus (t/now) (t/days 1))
-        recently-published (k/select d/events-isam (k/where {:type issued-type-id
-                                                             :event [>= (coerce/to-sql-date yesterday)]
-                                                             :event [<= (coerce/to-sql-date today)]}))]
+        recently-published (k/select d/events-isam (k/where (and (= :type issued-type-id)
+                                                             (>= :event (coerce/to-sql-date yesterday))
+                                                             (<= :event (coerce/to-sql-date today)))))]

     (doseq [event recently-published]
       (prn "Add to resolutions table" (:doi event))


Fix bootstrapping

Fix bootstrapping

Make everything functions! Or at least, more things

--- src/doctopus/web.clj
+++ src/doctopus/web.clj
@@ -74,8 +74,8 @@

 (defn add-head
   [request]
-   (let [head-name (get (:form-params request) "name")]
-     (serve-html (str "ADD A HEAD: " head-name))))
+  (let [head-name (get (:form-params request) "name")]
+    (serve-html (str "ADD A HEAD: " head-name))))

 (defn serve-head
   [request]
@@ -88,28 +88,30 @@

 (defn add-tentacle
   [request]
-   (let [params (keywordize-keys (:form-params request))]
-     (serve-html
-      (str "ADD A TENTACLE: " (:name params) " BELONGING TO: " (:head params)))))
+  (let [params (keywordize-keys (:form-params request))]
+    (serve-html
+     (str "ADD A TENTACLE: " (:name params) " BELONGING TO: " (:head params)))))

 ;; Bidi routes are defined as nested sets of ""
-(def routes ["/" {""             {:get serve-index}
-                  "index.html"   {:get serve-index}
-                  "assets"       (->Resources {:prefix "public/assets"})
-                  "frame.html"   {:get serve-iframe}
-                  "heads"        {"/"           {:get serve-all-heads}
-                                  ""            {:get serve-all-heads}
-                                  [:head-name]  {:get serve-head}}
-                  "add-head"     {:get serve-add-head-form :post add-head}
-                  "add-tentacle" {:get serve-add-tentacle-form :post add-tentacle}
-                  "docs"         (load-routes doctopus)}])
+(defn generate-routes []
+  ["/" {""             {:get serve-index}
+        "index.html"   {:get serve-index}
+        "assets"       (->Resources {:prefix "public/assets"})
+        "frame.html"   {:get serve-iframe}
+        "heads"        {"/"           {:get serve-all-heads}
+                        ""            {:get serve-all-heads}
+                        [:head-name]  {:get serve-head}}
+        "add-head"     {:get serve-add-head-form :post add-head}
+        "add-tentacle" {:get serve-add-tentacle-form :post add-tentacle}
+        "docs"         (load-routes doctopus)}])

 (defn- get-tentacle-from-uri
   [request-uri]
   (let [pieces (re-find #"/docs/([^/]+)/.+" request-uri)]
     (if pieces (second pieces) nil)))

-(def application-handlers
+(defn generate-application-handlers
+  [routes]
   (bidi/make-handler routes))

 (defn wrap-iframe-transform
@@ -122,8 +124,9 @@
         (assoc response :body (templates/add-frame (slurp file)))
         response))))

-(def application
-  (-> (wrap-defaults application-handlers site-defaults)
+(defn create-application
+  [app-handlers]
+  (-> (wrap-defaults app-handlers site-defaults)
       (wrap-iframe-transform)
       (wrap-route-not-found)
       (reload/wrap-reload)
@@ -143,7 +146,10 @@
 (defn -main
   []
   (let [{:keys [port]} (server-config)
-        env (parse-env)]
+        env (parse-env)
+        routes (generate-routes)
+        handlers (generate-application-handlers routes)
+        application (create-application handlers)]
     (log/info "Checking DB is set up...")
     (schema/bootstrap env)
     (log/info "Bootstrapping heads")


Destructure part's argument

Destructure part's argument

--- src/cljs/asciinema_player/view.cljs
+++ src/cljs/asciinema_player/view.cljs
@@ -22,8 +22,8 @@
         classes (remove nil? [fg-class bg-class bold-class underline-class cursor-class])]
     (string/join " " classes)))

-(defn part [p]
-  [:span {:class-name (part-class-name (last p))} (first p)])
+(defn part [[text attrs]]
+  [:span {:class-name (part-class-name attrs)} text])

 (defn line [parts]
   [:span.line (map-indexed (fn [idx p] ^{:key idx} [part p]) parts)])


Add comment

Add comment

--- src/cljs/cglossa/search_inputs.cljs
+++ src/cljs/cglossa/search_inputs.cljs
@@ -4,6 +4,8 @@
 (defn- convert-to-cqp [value phonetic?]
   (let [attr (if phonetic? "phon" "word")
         chinese-chars-range "[\u4E00-\u9FFF\u3400-\u4DFF\uF900-\uFAFF]"
+        ; Surround every Chinese character by space when constructing a cqp query,
+        ; to treat it as if it was an individual word:
         value (str/replace value (re-pattern (str "(" chinese-chars-range ")")) " $1 ")]
     (->> (str/split value #"\s")
          (map #(if (= % "")


Rename user -> author for see alsos

Rename user -> author for see alsos

--- src/cljs/clojuredocs/see_alsos.cljs
+++ src/cljs/clojuredocs/see_alsos.cljs
@@ -17,7 +17,7 @@
                             (assoc state key (not (get state key)))))
   false)

-(defn $see-also [{:keys [ns name created-at doc user] :as sa}]
+(defn $see-also [{:keys [ns name created-at doc author] :as sa}]
   [:div.col-sm-6.see-also
    [:div
     (util/$var-link ns name
@@ -30,7 +30,7 @@
     (when (> (count doc) 100)
       "...")]
    [:div.meta
-    "Added by " [:a {:href (str "/u/" (:login user))} (:login user)]]])
+    "Added by " [:a {:href (str "/u/" (:login author))} (:login author)]]])

 (defn $add [{:keys [user]} owner]
   (reify


Remove return symbol

Remove return symbol

--- src/clojure/nightcode/shortcuts.clj
+++ src/clojure/nightcode/shortcuts.clj
@@ -36,7 +36,7 @@
    :find-field "F"
    :replace-field "shift R"
    :repl-console "shift E"
-   :project-pane "↑ ↓ ↩"
+   :project-pane "↑ ↓"
    :toggle-logcat-button "S"})

 (defn create-mappings


Fixed typo in comment.

Fixed typo in comment.

--- src/com/lemondronor/turboshrimp.clj
+++ src/com/lemondronor/turboshrimp.clj
@@ -85,7 +85,7 @@
     (raise-event drone :error exception)))

-;; Queue's an already built AT command for the drone.
+;; Queues an already built AT command for the drone.
 (defn- queue-command [drone command]
   (dosync
    (alter (:command-queue drone) concat (list command))))


using run macro and implementing all workflow actions

--- src/gce/provider.clj
+++ src/gce/provider.clj
@@ -31,70 +31,68 @@
          (.setHttpRequestInitializer (.createScoped auth scopes))
          (.build))))

-(defn instances [compute]
-  (-> compute (.instances)))
+(defn instances [compute] (-> compute (.instances)))

 (defn list-instances [compute project zone]
   (let [items (get (-> (instances compute) (.list project zone) (.execute)) "items")]
-    (map clojure.walk/keywordize-keys items)))
+    (map keywordize-keys items)))

 (defn create-instance [compute gce {:keys [project-id zone] :as spec}]
   (let [instance (.fromString (JacksonFactory/getDefaultInstance) (write-str gce) Instance)]
     (-> (instances compute)
-      (.insert project-id zone instance) (.execute) from-java keywordize-keys)
-    ))
+      (.insert project-id zone instance) (.execute) from-java keywordize-keys)))

-(defn delete-instance [compute {:keys [name]} {:keys [project-id zone]}]
-   (-> (instances compute) (.delete project-id zone name) (.execute)))
-
-(defn get-instance [compute {:keys [name]} {:keys [project-id zone]}]
-   (-> (instances compute) (.get project-id zone name) (.execute) from-java keywordize-keys))
-
+(defmacro run [action]
+  `(-> (instances ~'compute)
+     (~action (~'spec :project-id) (~'spec :zone) (~'gce :name))
+        (.execute) from-java keywordize-keys))
+
 (defn get-operation [compute {:keys [project-id zone]} operation]
   (-> (.zoneOperations compute)
     (.get project-id zone (:name operation)) (.execute) from-java keywordize-keys))

 (defmacro with-id [& body])

+(defn wait-for-operation [compute gce spec operation]
+   (wait-for {:timeout [5 :minute]}
+     #(= (:status (get-operation compute spec operation)) "DONE")
+       {:type ::gce:operation-fail} (<< "Timed out on waiting for operation ~{operation}")))
+
 (defrecord GCEInstance [compute gce spec]
   Vm
   (create [this]
     (let [operation (create-instance compute gce spec)]
-     (wait-for {:timeout [5 :minute]}
-        #(= (:status (get-operation compute spec operation)) "DONE")
-         {:type ::gce:creation-fail} "Timed out on waiting for creation to be done")
-     (let [{:keys [natIp]} (get-instance compute gce spec)]
+     (wait-for-operation compute gce spec operation)
+     (let [{:keys [natIp]} (run .get)]
        (s/partial-system (spec :system-id) {:machine {:ip natIp}}))
       this))

   (start [this]
     (with-id
       (let [{:keys [machine]} (s/get-system (spec :system-id))]
-        (when-not (= "running" (.status this))
-          )
+        (when-not (= "running" (.status this)))
+        (let [operation (run .start)]
+          (wait-for-operation compute gce spec operation))
         (wait-for-ssh (machine :ip) "root" [5 :minute]))
       ))

   (delete [this]
-     (let [{:keys [id] :as operation} (create-instance compute gce spec) ]
-      (wait-for {:timeout [5 :minute]} #(= ("status" operation) "DONE")
-       {:type ::gce:fail} "Timed out on waiting for operation to be done"))
-    )
+     (let [operation (run .delete)]
+       (wait-for-operation compute gce spec operation)))

-  (stop [this])
+  (stop [this]
+    (let [operation (run .stop)]
+       (wait-for-operation compute gce spec operation)))

   (status [this]
-    (try
-      (let [{:keys [status]} (get-instance compute gce spec)]
-        (.toLowerCase status))
-      (catch Exception e false)
-      )))
+    (try (.toLowerCase (:status (run .get)))
+      (catch Exception e false))))

 (defn into-gce [{:keys [name machine-type tags zone image]}]
   {
     :name name
     :machineType (<< "zones/~{zone}/machineTypes/~{machine-type}")
-    :tags {:items (clojure.tools.trace/trace tags)}
+    :tags {:items tags}
     :disks [{
       :initializeParams {:sourceImage image} :autoDelete true
       :type "PERSISTENT" :boot true


Don't make API requests for a single commit

--- src/gitique/api.cljs
+++ src/gitique/api.cljs
@@ -57,4 +57,5 @@
                        (callback body))))]
      (xhr/send url handler "GET" nil headers)))
   ([repo from to callback]
-   (get-new-commits! (str "https://api.github.com/repos/" repo "/compare/" from "..." to) callback)))
+   (when-not (= from to)
+     (get-new-commits! (str "https://api.github.com/repos/" repo "/compare/" from "..." to) callback))))


Modifying schema

Modifying schema

--- src/helda/schema.clj
+++ src/helda/schema.clj
@@ -13,7 +13,8 @@

 (s/defschema Action{
   :source-model s/Str
-  (s/optional-key :action-ctx) {s/Keyword s/Str} ;model per key
+  (s/optional-key :request-ctx) {s/Keyword s/Str} ;model per key
+  (s/optional-key :response-ctx) {s/Keyword s/Str} ;model per key
   })

 (s/defschema Model {


fix ref name

fix ref name

--- src/holston/core.clj
+++ src/holston/core.clj
@@ -10,7 +10,7 @@
               "postgresql://localhost:5432/holston"))

 (defn show-landing-page [req]
-  (println ("DB url:" db))
+  (println (str "DB url:" db-url))
   (str "Holston is ready for e-business " (:?column? (first (sql/query db-url
            ["select 'with a DB!'"])))))


Use om.next in tooltip

Use om.next in tooltip

--- src/discuss/components/tooltip.cljs
+++ src/discuss/components/tooltip.cljs
@@ -3,7 +3,7 @@
   (:require [cljs.core.async :refer [put! chan <!]]
             [goog.dom :as gdom]
             [goog.events :as events]
-            [om.next :as nom :refer-macros [defui]]
+            [om.next :as om :refer-macros [defui]]
             [sablono.core :as html :refer-macros [html]]
             [discuss.components.clipboard :as clipboard]
             [discuss.translations :refer [translate]]
@@ -102,3 +102,4 @@
                  [:span.pointer {:onClick (fn [] (sidebar/show) (hide))}
                   (vlib/fa-icon "fa-comment")
                   (translate :common :show-discuss :space)]])))
+(def tooltip (om/factory Tooltip))


optimized calculation of form

optimized calculation of form

--- src/foosball/statistics/ratings.clj
+++ src/foosball/statistics/ratings.clj
@@ -128,14 +128,14 @@
                                                :inactivity inactivities})))
                               logs)]))))))

-(defn calculate-current-form-for-player [logs number-of-matches player]
-  (->> logs
-       (filter (comp (partial = :played-match) :log-type))
-       (filter (comp (partial = player)        :player))
-       reverse
-       (take number-of-matches)
-       reverse
-       (map :win?)))
+(defn calculate-current-forms-for-players [logs number-of-matches]
+  (let [played-matches (filter (comp (partial = :played-match) :log-type) logs)
+        by-player      (group-by :player played-matches)]
+    (->> by-player
+         (map (fn [[player logs]] {player (->> logs
+                                            (take-last number-of-matches)
+                                            (map :win?))}))
+         (apply merge))))

 (defn teams-from-players [players]
   (let [ps (set players)]


remove unused require

remove unused require

--- src/fscrawler_tika_convert/core.clj
+++ src/fscrawler_tika_convert/core.clj
@@ -4,7 +4,7 @@
   (:require [langohr.queue :as lq])
   (:require [langohr.channel :as lch])
   (:require [langohr.consumers :as lcons])
-  (:require [me.raynes.fs :as fs])
+  ;; (:require [me.raynes.fs :as fs])
   (:require [clojure.tools.cli :as cli])
   (:require [clojure.data.json :as json])
   (:require [clojure.string :as string])


dep bump.

dep bump.

--- resources/leiningen/new/bukkure/project.clj
+++ resources/leiningen/new/bukkure/project.clj
@@ -1,5 +1,5 @@
 (defproject {{name}} "0.1.0-SNAPSHOT"
   :description "A bukkure plugin to..."
   :dependencies [[org.clojure/clojure "1.7.0"]
-                 [bukkure "0.3.1-SNAPSHOT"]]
+                 [bukkure "0.3.2-SNAPSHOT"]]
   :java-source-paths ["javasrc"])


moving functions around for clarity

moving functions around for clarity

--- src/lambdaci/dsl.clj
+++ src/lambdaci/dsl.clj
@@ -25,19 +25,19 @@
     {:outputs { step-id step-result}} ))

+(defn execute-step-foo [args [step-id step]]
+  (execute-step step args step-id))
+
+
+(defn merge-step-results [r1 r2]
+  (merge-with merge r1 r2))
+
 (defn steps-with-ids [steps prev-id]
   (let [significant-part (first prev-id)
         rest-part (rest prev-id)
         significant-ids (range-from significant-part (count steps))
         ids (map #(cons %1 rest-part) significant-ids)]
     (map vector ids steps)))
-
-(defn merge-step-results [r1 r2]
-  (merge-with merge r1 r2))
-
-(defn execute-step-foo [args [step-id step]]
-  (execute-step step args step-id))
-

 (defn execute-steps-internal [step-result-producer steps args step-id]
   (let [step-results (step-result-producer args (steps-with-ids steps step-id))]


[#1656] Load dashboard.spec.filter on public dashboard [backend]

--- backend/src/akvo/lumen/lib/public.clj
+++ backend/src/akvo/lumen/lib/public.clj
@@ -18,7 +18,7 @@

 (defn dashboard-response-data [tenant-conn id windshaft-url]
   (when-let [dashboard (dashboard/fetch tenant-conn id)]
-    (assoc (aggregation/aggregate-dashboard-viss dashboard tenant-conn windshaft-url {})
+    (assoc (aggregation/aggregate-dashboard-viss dashboard tenant-conn windshaft-url (or (:filter dashboard) {}))
            :dashboards {id dashboard})))

 (defn response-data [tenant-conn share windshaft-url]


multilingual fix

multilingual fix

--- src-clj/acha/achievement.clj
+++ src-clj/acha/achievement.clj
@@ -378,8 +378,8 @@
 (def multilingual
   [:multilingual
    (fn [commit-info]
-     (when (>= (+ (map #(if (% commit-info) 1 0)
-      (vals (map make-language-scanner language-table)))) 5)
+     (when (>= (reduce + (map #(if (% commit-info) 1 0)
+      (map second (map make-language-scanner language-table)))) 5)
        {:username (:author commit-info)
         :time (:time commit-info)}))])


Added auto-clean behavior to new cursor implementation.

--- src-cljs/freactive/core.cljs
+++ src-cljs/freactive/core.cljs
@@ -6,13 +6,13 @@

 ;; Core API for reactive binding

-(deftype BindingInfo [raw-deref add-watch remove-watch clean dispose])
+(deftype BindingInfo [raw-deref add-watch remove-watch clean])

 (defprotocol IReactive
   (-get-binding-fns [this]))

 (def ^:private iwatchable-binding-fns
-  (BindingInfo. cljs.core/-deref cljs.core/-add-watch cljs.core/-remove-watch nil nil))
+  (BindingInfo. cljs.core/-deref cljs.core/-add-watch cljs.core/-remove-watch nil))

 (defn get-binding-fns [iref]
   (if (satisfies? IReactive iref)
@@ -45,14 +45,6 @@
   (-update! [this key f args])
   (-update-in! [this ks f args])
   (-assoc-in! [this ks v]))
-
-(defprotocol IDisposable
-  (-dispose! [this])
-  (-disposed? [this]))
-
-(defn dispose! [this] (-dispose! this))
-
-(defn disposed? [this] (-disposed? this))

 (defn update! [cursor key f & args]
   (-update! cursor key f args))
@@ -142,7 +134,7 @@

 (def fwatch-binding-info
   (BindingInfo.
-   #(.rawDeref %) #(.addFWatch % %2 %3) #(.removeFWatch % %2) #(.clean %) #(.dispose %)))
+   #(.rawDeref %) #(.addFWatch % %2 %3) #(.removeFWatch % %2) #(.clean %)))

 (defn- make-register-dep [rx]
   (fn do-register-dep [dep id binding-info]
@@ -196,8 +188,7 @@
    #(.rawDeref %)
    #(.addInvalidationWatch % %2 %3)
    #(.removeInvalidationWatch % %2)
-   #(.clean %)
-   #(.dispose %)))
+   #(.clean %)))

 (def rx-mixin
   #js
@@ -233,7 +224,7 @@
         (.notifyFWatches this old-val new-val)
         new-val)))
   (clean [this]
-    (when  (and (identical? 0 watchers) (identical? 0 iwatchers))
+    (when (and (identical? 0 watchers) (identical? 0 iwatchers))
       (goog.object/forEach deps
                            (fn [val key obj]
                              ;; (println "cleaning:" key val)
@@ -251,10 +242,6 @@
   (-get-binding-fns [this]
     (if lazy invalidates-binding-info fwatch-binding-info))

-  IDisposable
-  (-dispose! [this] (.dispose this))
-  (-disposed? [this] false)
-
   IEquiv
   (-equiv [o other] (identical? o other))

@@ -315,15 +302,20 @@

 ;; WIP on new cursor implementation

-(deftype Cursor [id parent tkey ^:mutable child-cursors swap-fn ^:mutable state meta watches fwatches watchers keyset-watches]
+(deftype Cursor [id parent tkey ^:mutable child-cursors get-fn swap-fn ^:mutable state meta ^:mutable watches ^:mutable fwatches ^:mutable watchers ^:mutable keyset-watches]
     Object
     (equiv [this other]
       (-equiv this other))
-    (clean [this])
-    (dispose [this]
-      (when-let [disposed-fn (.-disposed-fn this)]
-        (disposed-fn)
-        (set! (.-disposed this) true)))
+    (activate [this]
+      (when (.-dirty this)
+        (when-let [activate-fn (.-activate-fn this)]
+          (activate-fn)
+          (.rawDeref this)
+          (set! (.-dirty this) false))))
+    (clean [this]
+      (when-let [clean-fn (.-clean-fn this)]
+        (set! (.-dirty this) true)
+        (clean-fn)))
     (updateChild [this key f args]
       (set! (.-change-ks this) [key])
       (apply swap-fn update key f args)
@@ -336,9 +328,9 @@
       (doseq [child (get child-cursors child-key)]
         (.updateCursor child new-val)))
     (updateCursor [this new-state]
-      (let [old-state state]
-        (set! state new-state)
-        (when-not (identical? old-state state)
+      (when-not (identical? state new-state)
+        (let [old-state state]
+          (set! state new-state)
           (if-let [change-ks (.-change-ks this)]
             (let [change-ks (if (keyword? change-ks)
                               [(case change-ks
@@ -359,37 +351,56 @@
                       ))))
               (set! (.-change-key this) nil))
             (cond keyset-watches
-              (let [old-keys (keyset old-state)
-                    new-keys (keyset state)
-                    [removed added both] (diff-set (set old-keys) (set new-keys))]
-                (when (or (not (empty? removed)) (not (empty? added)))
-                  ;; notify key set change
-                  )
-                (doseq [rx removed]
-                  (.notifyChild rx nil))
-                (doseq [ra added]
-                  (.notifyChild ra (get state ra)))
-                (doseq [rc both]
-                  (when-let [cursors (get child-cursors rc)]
-                    (when-let [cur (first cursors)]
-                      (let [old-val (.-state cur)
-                            new-val (get state rc)]
-                        (when-not (identical? old-val new-val)
-                          (doseq [cur cursors]
-                            (.updateCursor cur new-val))))))))
-              child-cursors
-              (doseq [[ckey cursors] child-cursors]
-                (let [old-val (get old-state ckey)
-                      new-val (get state ckey)]
-                  (when-not (identical? old-val new-val)
-                    (doseq [cur cursors]
-                      (.updateCursor cur new-val)))))))
+                  (let [old-keys (keyset old-state)
+                        new-keys (keyset state)
+                        [removed added both] (diff-set (set old-keys) (set new-keys))]
+                    (when (or (not (empty? removed)) (not (empty? added)))
+                      ;; notify key set change
+                      )
+                    (doseq [rx removed]
+                      (.notifyChild rx nil))
+                    (doseq [ra added]
+                      (.notifyChild ra (get state ra)))
+                    (doseq [rc both]
+                      (when-let [cursors (get child-cursors rc)]
+                        (when-let [cur (first cursors)]
+                          (let [old-val (.-state cur)
+                                new-val (get state rc)]
+                            (when-not (identical? old-val new-val)
+                              (doseq [cur cursors]
+                                (.updateCursor cur new-val))))))))
+                  child-cursors
+                  (doseq [[ckey cursors] child-cursors]
+                    (let [old-val (get old-state ckey)
+                          new-val (get state ckey)]
+                      (when-not (identical? old-val new-val)
+                        (doseq [cur cursors]
+                          (.updateCursor cur new-val)))))))
           (.notifyFWatches this old-state state))))
     (rawDeref [this]
+      (when (.-dirty this)
+        (.updateCursor this (get-fn)))
       state)
     (reactiveDeref [this]
       (register-dep this id fwatch-binding-info)
-      state)
+      (.rawDeref this))
+    (addFWatch [this key f]
+      (when-not (aget (.-fwatches this) key)
+        (.activate this)
+        (set! (.-watchers this) (inc (.-watchers this)))
+        (aset (.-fwatches this) key f)))
+    (removeFWatch [this key]
+      (when (aget (.-fwatches this) key)
+        (set! (.-watchers this) (dec (.-watchers this)))
+        (js-delete (.-fwatches this) key)
+        (when (identical? watchers 0) (.clean this))))
+    (notifyFWatches [this oldVal newVal]
+      (goog.object/forEach
+       (.-fwatches this)
+       (fn [f key _]
+         (f key this oldVal newVal)))
+      (doseq [[key f] (.-watches this)]
+        (f key this oldVal newVal)))

     cljs.core/IAtom

@@ -414,13 +425,16 @@
     IWatchable
     (-add-watch [this key f]
       (when-not (contains? watches key)
+        (.activate this)
         (set! (.-watchers this) (inc watchers))
         (set! (.-watches this) (assoc watches key f)))
       this)
     (-remove-watch [this key]
       (when (contains? watches key)
         (set! (.-watchers this) (dec watchers))
-        (set! (.-watches this) (dissoc watches key)))
+        (set! (.-watches this) (dissoc watches key))
+        (when (identical? watchers 0)
+          (.clean this)))
       this)

     IKeysetCursor
@@ -446,17 +460,15 @@
       (if-let [child-cursor (first (get child-cursors ckey))]
         (first child-cursors)
         (let [id (new-reactive-id)
-              cur (Cursor.
-                            id this ckey nil
-                            (fn [f & args] (.updateChild this ckey f args))
-                            (get state ckey)
-                            nil
-                            nil
-                            #js {}
-                            0
-                            nil)]
-          (set! child-cursors (update child-cursors ckey conj cur))
-          (set! (.-dispose-fn cur)
+              cur (Cursor. id this ckey nil
+                           (fn [] (get (.rawDeref this) ckey))
+                           (fn [f & args] (.updateChild this ckey f args))
+                           (get state ckey)
+                           nil nil #js {} 0 nil)
+              activate-fn (fn [] (set! child-cursors (update child-cursors ckey conj cur)))]
+          (activate-fn)
+          (set! (.-active-fn cur) activate-fn)
+          (set! (.-clean-fn cur)
                 (fn []
                   (set! child-cursors
                         (update child-cursors ckey
@@ -469,11 +481,6 @@
       (when tkey
         parent))

-    IDisposable
-    (-dispose! [this]
-      (.dispose this))
-    (-disposed? [this] (or (.-disposed this) false))
-
     ITransientCollection
     (-conj! [this val]
       (set! (.-change-ks this) :conj)
@@ -504,8 +511,6 @@
     (-assoc-in! [this ks v]
       (set! (.-change-ks this) ks)
       (swap-fn assoc-in ks v)))
-
-(apply-js-mixin Cursor fwatch-mixin)

 (defn atom
   "Creates and returns a ReactiveAtom with an initial value of x and zero or
@@ -519,8 +524,9 @@
   return false or throw an Error. If either of these error conditions
   occur, then the value of the atom will not change."
   [init & {:keys [meta validator]}]
-  (let [cur (Cursor. (new-reactive-id) nil nil nil nil init
+  (let [cur (Cursor. (new-reactive-id) nil nil nil nil nil init
                      meta nil #js {} 0 nil)]
+    (set! (.-get-fn cur) (fn [] (.-state cur)))
     (set!
      (.-swap-fn cur)
      (fn [f & args]
@@ -533,16 +539,21 @@

 (defn lens-cursor [parent getter setter]
   (let [id (new-reactive-id)
+        binding-info (get-binding-fns parent)
         cur (Cursor.
              id parent nil nil
+             (fn [] (getter ((.-raw-deref parent))))
              (fn [f & args]
                (swap! parent
                       (fn [x] (setter x (apply f (getter x) args)))))
              (getter @parent) nil nil #js {} 0 nil)
-        binding-info (get-binding-fns parent)]
-    ((.-add-watch binding-info) parent id
-     (fn [k r o n] (.updateCursor cur (getter n))))
-    (set! (.-dispose-fn cur)
+        activate-fn
+        (fn []
+          ((.-add-watch binding-info) parent id
+           (fn [k r o n] (.updateCursor cur (getter n)))))]
+    (activate-fn)
+    (set! (.-activate-fn cur) activate-fn)
+    (set! (.-clean-fn cur)
           (fn [] ((.-remove-watch binding-info) parent id)))
     cur))


Доработка стиля media

Доработка стиля media

--- radiolamp-6P3S/src/ixinfestor/omut.cljs
+++ radiolamp-6P3S/src/ixinfestor/omut.cljs
@@ -2223,8 +2223,10 @@
 ;;*
 ;;**************************************************************************************************

-(defn ui-media-object [{:keys [src style]}]
-  (dom/img #js {:className "media-object" :style style :src src
+(defn ui-media-object [{:keys [src class+ style]}]
+  (dom/img #js {:className (str "media-object " (or class+ ""))
+                :style style
+                :src src
                 }))

 (defn ui-media [{:keys [media-object


friend-list: revert temp code

friend-list: revert temp code

--- examples/friend-list/src-spec/friend_list/core.cljs
+++ examples/friend-list/src-spec/friend_list/core.cljs
@@ -38,8 +38,6 @@

              [:on-input q]
              (do
-               (dispatch-action [:set-query q])
-               (dispatch-action [:set-query q])
                (dispatch-action [:set-query q])
                (search-on-input q dispatch-signal))


Add version command for unnethack. Closes #1

--- src/demogorgon/core.clj
+++ src/demogorgon/core.clj
@@ -53,8 +53,14 @@
     else
     obj))

-(defn get-version [& args]
+(defn get-bot-version [& args]
   (str "version " (or-if-empty v/version "unknown") " (" v/gitref ")"))
+
+(defn get-nh-version [& args]
+  (let [v (slurp "/tmp/version.txt")]
+    (if (> (count v) 100)
+      "unknown"
+      v)))

 (def msg-handlers [[[#"^\.last ?(.*)?" #"^\.lastdump ?(.*)?"] #'last-dump-hook]
                    [[#"^\.whereis ?(.*)?"] #'whereis-hook]
@@ -62,7 +68,8 @@
                [[#"^\.cur" #"^\.online"] #'online-players-hook]
                [[#"^\.last ?(.*)?" #"^\.lastdump ?(.*)?" #"^\.lasturl ?(.*)?"] #'last-dump-hook]
                [[#"^\.debug"] #'get-memory-info]
-               [[#"^\.version"] #'get-version]])
+               [[#"^\.bot"] #'get-bot-version]
+               [[#"^\.version"] #'get-nh-version]])

 (defn handle-privmsg [con data]
   (let [target (get-reply-target data)
@@ -120,5 +127,3 @@
   (stop-web (:web bot))
   (nh-stop (:nh bot))
   (irc/shutdown (:connection bot)))
-
-


fix exit condition

fix exit condition

--- src/neuseg/train.clj
+++ src/neuseg/train.clj
@@ -6,7 +6,7 @@
         train-data (fann/load-train-data "data/trains/train")
         test-data  (fann/load-train-data "data/trains/tests")]
     (println "training...")
-    (fann/train nn train-data 10000 1 0.04)
+    (fann/train nn train-data 10000 1 0.004)
     (println "testing...")
     (println "error = " (fann/testnn nn test-data))
     (fann/save nn "data/models/tagging.nn")))


Use generic dbas hostname

Use generic dbas hostname

--- src/discuss/config.cljs
+++ src/discuss/config.cljs
@@ -4,7 +4,7 @@

 (def user "Q2hyaXN0aWFu")

-(def api {:host "http://172.18.0.3/"
+(def api {:host "http://dbas/"
           :init "api/elektroautos"
           :base "api/"
           :add  {:add-start-statement "add/start_statement"


Additional validation for trigger context type.

--- src/onyx/windowing/window_compile.cljc
+++ src/onyx/windowing/window_compile.cljc
@@ -43,13 +43,19 @@
           sync-fn (if sync (u/kw->fn sync))
           emit-fn (if emit (u/kw->fn emit))
           locals (if-let [f-init-locals (:trigger/init-locals trigger-calls)]
-                   (f-init-locals trigger))]
+                   (f-init-locals trigger))
+          state-context-trigger? (or (empty? state-context) (boolean (some #{:trigger-state} state-context)))
+          state-context-window? (boolean (some #{:window-state} state-context))]
+      (when (and (not f-init-state)
+                 (not state-context-window?))
+        (throw (ex-info "Trigger calls for this trigger does not include a :trigger/init-state fn, and thus must use `:trigger/state-context [:window-state]`"
+                        trigger)))
       (-> trigger
           (filter-ns-key-map "trigger")
           (into locals)
           (assoc :trigger trigger)
-          (assoc :state-context-window? (boolean (some #{:window-state} state-context)))
-          (assoc :state-context-trigger? (or (empty? state-context) (boolean (some #{:trigger-state} state-context))))
+          (assoc :state-context-window? state-context-window?)
+          (assoc :state-context-trigger? state-context-trigger?)
           (assoc :pre-evictor pre-evictor)
           (assoc :post-evictor post-evictor)
           (assoc :idx (or (get indices [id window-id]) (throw (ex-info "Could not find state index for window id." {}))))


eastwood

eastwood

--- src/open_company/resources/company.clj
+++ src/open_company/resources/company.clj
@@ -187,8 +187,7 @@
 (s/defn add-updated-at
   [{:keys [section-name] :as section} :- common/Section ts]
   (let [notes-section? (contains? common/notes-sections section-name)]
-    (cond-> section
-      true                                  (assoc :updated-at ts)
+    (cond-> (assoc section :updated-at ts)
       (and notes-section? (:notes section)) (assoc-in [:notes :updated-at] ts))))

 (s/defn create-company!


you should be able to select backwards

you should be able to select backwards

--- src-cljs/frontend/controllers/controls.cljs
+++ src-cljs/frontend/controllers/controls.cljs
@@ -144,14 +144,18 @@
       r)))

 (defn eids-in-bounding-box [db {:keys [start-x end-x start-y end-y] :as box}]
-  (let [has-start-x (set (map :e (d/index-range db :layer/start-x start-x end-x)))
-        has-end-x (set (map :e (d/index-range db :layer/end-x start-x end-x)))
-        has-start-y (set (map :e (d/index-range db :layer/start-y start-y end-y)))
-        has-end-y (set (map :e (d/index-range db :layer/end-y start-y end-y)))]
-    (set/union (set/intersection has-start-x has-start-y)
-               (set/intersection has-start-x has-end-y)
-               (set/intersection has-end-x has-start-y)
-               (set/intersection has-end-x has-end-y))))
+  (let [x0 (min start-x end-x)
+        x1 (max start-x end-x)
+        y0 (min start-y end-y)
+        y1 (max start-y end-y)
+        has-x0 (set (map :e (d/index-range db :layer/start-x x0 x1)))
+        has-x1 (set (map :e (d/index-range db :layer/end-x x0 x1)))
+        has-y0 (set (map :e (d/index-range db :layer/start-y y0 y1)))
+        has-y1 (set (map :e (d/index-range db :layer/end-y y0 y1)))]
+    (set/union (set/intersection has-x0 has-y0)
+               (set/intersection has-x0 has-y1)
+               (set/intersection has-x1 has-y0)
+               (set/intersection has-x1 has-y1))))

 (defmethod control-event :mouse-released
   [target message [x y] state]


don't cast from within the controls ch

don't cast from within the controls ch

--- src-cljs/frontend/controllers/controls.cljs
+++ src-cljs/frontend/controllers/controls.cljs
@@ -187,8 +187,7 @@
   (let [points (map js/parseInt (str/split (subs path 1) #" "))]
     (map (fn [[rx ry]] {:rx rx :ry ry}) (partition 2 points))))

-(defmethod control-event :drawing-started
-  [browser-state message [x y] state]
+(defn handle-drawing-started [state x y]
   (let [[rx ry] (cameras/screen->point (:camera state) x y)
         [snap-x snap-y] (cameras/snap-to-grid (:camera state) rx ry)
         {:keys [entity-id state]} (frontend.db/get-entity-id state)
@@ -210,6 +209,10 @@
               (assoc-in [:editing-eids :editing-eids] #{entity-id})
               (assoc-in [:selected-eids :selected-eids] #{entity-id}))]
       r)))
+
+(defmethod control-event :drawing-started
+  [browser-state message [x y] state]
+  (handle-drawing-started state x y))

 (defmethod control-event :drawing-edited
   [browser-state message {:keys [layer x y]} state]
@@ -572,40 +575,56 @@
       (assoc-in [:mouse-down] false)
       (assoc-in [:editing-eids :editing-eids] #{}))))

+(defn mouse-depressed-intents [state button ctrl?]
+  (let [tool (get-in state state/current-tool-path)
+        drawing-text? (and (keyword-identical? :text tool)
+                           (get-in state [:drawing :in-progress?]))]
+    (concat
+     ;; If you click while writing text, you probably wanted to place it there
+     ;; You also want the right-click menu to open
+     (when drawing-text? [:finish-text-layer])
+     (cond
+       (= button 2) [:open-menu]
+       (and (= button 0) ctrl?) [:open-menu]
+       (get-in state [:layer-properties-menu :opened?]) [:submit-layer-properties]
+       (contains? #{:pen :rect :circle :line :select} tool) [:start-drawing]
+       (and (keyword-identical? tool :text) (not drawing-text?)) [:start-drawing]
+       :else nil))))
+
+(declare handle-menu-opened)
+(declare handle-menu-opened-after)
+(declare handle-layer-properties-submitted)
+(declare handle-layer-properties-submitted-after)
+(declare handle-text-layer-finished)
+(declare handle-text-layer-finished-after)
+
 (defmethod control-event :mouse-depressed
-  [browser-state message [x y {:keys [button type]}] state]
-  (-> state
-      (update-mouse x y)
-      (assoc-in [:mouse-down] true)
-      (assoc-in [:mouse-type] (if (= type "mousedown") :mouse :touch))))
+  [browser-state message [x y {:keys [button type ctrl?]}] state]
+  (let [intents (mouse-depressed-intents state button ctrl?)
+        new-state (-> state
+                    (update-mouse x y)
+                    (assoc-in [:mouse-down] true)
+                    (assoc-in [:mouse-type] (if (= type "mousedown") :mouse :touch)))]
+    (reduce (fn [s intent]
+              (case intent
+                :finish-text-layer (handle-text-layer-finished s)
+                :open-menu (handle-menu-opened s)
+                :start-drawing (handle-drawing-started s x y)
+                :submit-layer-properties (handle-layer-properties-submitted s)
+                s))
+            new-state intents)))

 (defmethod post-control-event! :mouse-depressed
   [browser-state message [x y {:keys [button ctrl?]}] previous-state current-state]
-  (let [cast! (fn [msg & [payload]]
-                (put! (get-in current-state [:comms :controls]) [msg payload]))
-        drawing-text? (and (= (get-in current-state state/current-tool-path) :text)
-                           (get-in current-state [:drawing :in-progress?]))]
-    ;; If you click while writing text, you probably wanted to place it there
-    ;; You also want the right-click menu to open
-    (when drawing-text?
-      (cast! :text-layer-finished))
-    (cond
-      (= button 2) (cast! :menu-opened)
-      (and (= button 0) ctrl?) (cast! :menu-opened)
-      ;; turning off Cmd+click for opening the menu
-      ;; (get-in current-state [:keyboard :meta?]) (cast! :menu-opened)
-      (get-in current-state [:layer-properties-menu :opened?]) (cast! :layer-properties-submitted)
-      (= (get-in current-state state/current-tool-path) :pen) (cast! :drawing-started [x y])
-
-      (= (get-in current-state state/current-tool-path) :text)
-      (when-not drawing-text?
-        (cast! :drawing-started [x y]))
-
-      (= (get-in current-state state/current-tool-path) :rect) (cast! :drawing-started [x y])
-      (= (get-in current-state state/current-tool-path) :circle) (cast! :drawing-started [x y])
-      (= (get-in current-state state/current-tool-path) :line)  (cast! :drawing-started [x y])
-      (= (get-in current-state state/current-tool-path) :select)  (cast! :drawing-started [x y])
-      :else                                             nil)))
+  ;; use previous state so that we're consistent with the control-event
+  (let [intents (mouse-depressed-intents previous-state button ctrl?)]
+    (doseq [intent intents]
+      (case intent
+        :finish-text-layer (handle-text-layer-finished-after current-state)
+        :open-menu (handle-menu-opened-after current-state previous-state)
+        :start-drawing nil
+        :submit-layer-properties (handle-layer-properties-submitted-after current-state)
+        nil))))

 (defn detectable-movement?
   "Checks to make sure we moved the layer from its starting position"
@@ -662,20 +681,25 @@

      :else nil)))

+(defn handle-text-layer-finished [state bbox]
+  (-> state
+    (update-in [:drawing :layers 0 :bbox] #(or bbox %))
+    (finalize-layer)))
+
 (defmethod control-event :text-layer-finished
   [browser-state message {:keys [bbox]} state]
-  (-> state
-    (update-in [:drawing :layers 0 :bbox] #(or bbox %))
-    (finalize-layer)))
-
-(defmethod post-control-event! :text-layer-finished
-  [browser-state message _ previous-state current-state]
-  (let [cast! #(put! (get-in current-state [:comms :controls]) %)
-        db           (:db current-state)
-        layer        (utils/remove-map-nils (get-in current-state [:drawing :finished-layers 0]))]
+  (handle-text-layer-finished state bbox))
+
+(defn handle-text-layer-finished-after [current-state]
+  (let [db (:db current-state)
+        layer (utils/remove-map-nils (get-in current-state [:drawing :finished-layers 0]))]
     (when (layer-model/detectable? layer)
       (d/transact! db [layer] {:can-undo? true}))
     (maybe-notify-subscribers! current-state nil nil)))
+
+(defmethod post-control-event! :text-layer-finished
+  [browser-state message _ previous-state current-state]
+  (handle-text-layer-finished-after current-state))

 (defmethod control-event :deleted-selected
   [browser-state message _ state]
@@ -761,22 +785,27 @@
       (assoc-in [:drawing :moving?] true)
       (assoc-in [:drawing :starting-mouse-position] [rx ry]))))

+(defn handle-menu-opened [state]
+  (-> state
+    (update-in [:menu] assoc
+               :open? true
+               :x (get-in state [:mouse :x])
+               :y (get-in state [:mouse :y]))
+    (assoc-in [:drawing :in-progress?] false)
+    (assoc-in state/right-click-learned-path true)))
+
 (defmethod control-event :menu-opened
   [browser-state message _ state]
-  (print "menu opened")
-  (-> state
-      (update-in [:menu] assoc
-                 :open? true
-                 :x (get-in state [:mouse :x])
-                 :y (get-in state [:mouse :y]))
-      (assoc-in [:drawing :in-progress?] false)
-      (assoc-in state/right-click-learned-path true)))
-
-(defmethod post-control-event! :menu-opened
-  [browser-state message _ previous-state current-state]
+  (handle-menu-opened state))
+
+(defn handle-menu-opened-after [previous-state current-state]
   (when (and (not (get-in previous-state state/right-click-learned-path))
              (get-in current-state state/right-click-learned-path))
     (analytics/track "Radial menu learned")))
+
+(defmethod post-control-event! :menu-opened
+  [browser-state message _ previous-state current-state]
+  (handle-menu-opened-after previous-state current-state))

 (defmethod control-event :menu-closed
   [browser-state message _ state]
@@ -1058,17 +1087,23 @@
         (assoc-in [:layer-properties-menu :x] rx)
         (assoc-in [:layer-properties-menu :y] ry))))

+(defn handle-layer-properties-submitted [state]
+  (-> state
+    (assoc-in [:layer-properties-menu :opened?] false)))
+
 (defmethod control-event :layer-properties-submitted
   [browser-state message _ state]
-  (-> state
-      (assoc-in [:layer-properties-menu :opened?] false)))
-
-(defmethod post-control-event! :layer-properties-submitted
-  [browser-state message _ previous-state current-state]
+  (handle-layer-properties-submitted state))
+
+(defn handle-layer-properties-submitted-after [current-state]
   (let [db (:db current-state)]
     (d/transact! db [(utils/remove-map-nils
                       (select-keys (get-in current-state [:layer-properties-menu :layer])
                                    [:db/id :layer/ui-id :layer/ui-target]))])))
+
+(defmethod post-control-event! :layer-properties-submitted
+  [browser-state message _ previous-state current-state]
+  (handle-layer-properties-submitted-after current-state))

 (defn empty-str->nil [s]
   (if (str/blank? s)


Add missing executor public api.

Add missing executor public api.

--- src/futura/executor.clj
+++ src/futura/executor.clj
@@ -29,7 +29,6 @@
            java.util.concurrent.Executor
            java.util.concurrent.Executors
            java.util.concurrent.ThreadFactory))
-

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; The main abstraction definition.
@@ -96,3 +95,24 @@
   ([factory]
    (Executors/newCachedThreadPool (thread-factory-adapter factory))))

+(defn execute
+  "Execute a task in a provided executor.
+
+  A task is a plain clojure function or
+  jvm Runnable instance."
+  ([task]
+   (execute* *default* task))
+  ([executor task]
+   (execute* executor task)))
+
+(defn submit
+  "Submit a task to be executed in a provided executor
+  and return a promise that will be completed with
+  the return value of a task.
+
+  A task is a plain clojure function."
+  ([task]
+   (submit* *default* task))
+  ([executor task]
+   (submit* executor task)))
+


Scroll to bottom when sending a message

Scroll to bottom when sending a message

--- src/braid/client/ui/views/thread.cljs
+++ src/braid/client/ui/views/thread.cljs
@@ -74,8 +74,7 @@

         last-open-at (subscribe [:thread-last-open-at thread-id])

-        unseen? (fn [message] (> (:created-at message)
-                                        @last-open-at))
+        unseen? (fn [message] (> (:created-at message) @last-open-at))

         kill-chan (chan)
         embed-update-chan (chan)
@@ -85,6 +84,8 @@

         at-bottom? (atom true)
         first-scroll? (atom true)
+
+        old-last-msg (atom nil)

         check-at-bottom
         (fn []
@@ -108,6 +109,7 @@
        (fn [c]
          (reset! at-bottom? true)
          (scroll-to-bottom! c)
+         (reset! old-last-msg (:id (last @messages)))
          (go (loop []
                (let [[_ ch] (alts! [embed-update-chan kill-chan])]
                  (when (not= ch kill-chan)
@@ -117,7 +119,14 @@
        :component-will-unmount
        (fn [] (put! kill-chan (js/Date.)))

-       :component-did-update scroll-to-bottom!
+       :component-did-update
+       (fn [c _]
+         (let [last-msg (last @messages)]
+           (when (and (not= @old-last-msg (:id last-msg))
+                      (= (:user-id last-msg) @(subscribe [:user-id])))
+             (reset! at-bottom? true))
+           (reset! old-last-msg (:id last-msg)))
+         (scroll-to-bottom! c))

        :reagent-render
        (fn [thread-id]


The parameter even says seconds

The parameter even says seconds

--- src/pedantic/aws.clj
+++ src/pedantic/aws.clj
@@ -26,9 +26,13 @@
 (def ^:private credentials-ttl-enabled?
   (Boolean/valueOf (env :credentials-ttl-enabled)))

+(defn- to-seconds
+  [minutes]
+  (* minutes 60))
+
 (defn- to-millis
   [minutes]
-  (* minutes 60 1000))
+  (* (to-seconds minutes) 1000))

 (defn- role-arn
   [account-id]
@@ -37,7 +41,7 @@
 (defn- assume-role*
   [account-id]
   (info "Assuming role")
-  (:credentials (guarded (sts/assume-role :duration-seconds (to-millis (+ credentials-ttl 5)) :role-arn (role-arn account-id) :role-session-name "pedantic"))))
+  (:credentials (guarded (sts/assume-role :duration-seconds (to-seconds (+ credentials-ttl 5)) :role-arn (role-arn account-id) :role-session-name "pedantic"))))

 (def assume-role
   (if credentials-ttl-enabled?


only go to "usage-queue" when running

only go to "usage-queue" when running

--- src-cljs/frontend/components/build_head.cljs
+++ src-cljs/frontend/components/build_head.cljs
@@ -736,13 +736,14 @@
    ;; default to the queue tab if the build is currently usage queued, and
    ;; the user is has the right permissions (and is logged in).
    (and (:read-settings scopes)
-        (or (build-model/in-usage-queue? build)
-            ;; "config" takes up too much room for paid customers.
-            (feature/enabled? :ui-v2)))
+        (build-model/in-usage-queue? build))
    :usage-queue
    ;; If there's no SSH info, build isn't finished, show the config or commits.
    (build-model/running? build) (if (feature/enabled? :ui-v2)
-                                  :config
+                                  ;; "config" takes up too much room for paid customers.
+                                  (if (:read-settings scopes)
+                                    :usage-queue
+                                    :config)
                                   :commits)
    ;; Otherwise, just use the first one.
    :else :tests))


fix request not being passed to view function

--- src/greybear/server.clj
+++ src/greybear/server.clj
@@ -14,7 +14,7 @@
         [greybear.pages game login]))

 (defroutes main-routes
-  (GET ["/games/:id", :id #"[0-9]+"] [id]
+  (GET ["/games/:id", :id #"[0-9]+"] [id :as request]
        (game request (Integer. id)))
   (GET "/login" request (login-get))
   (GET "/logout" request


Now I know about .. macro

Now I know about .. macro

--- src/harnocode/core.cljs
+++ src/harnocode/core.cljs
@@ -245,11 +245,10 @@
 (defn on-reader-load [event]
   (let [pixels-div (dom/getElement "pixels")
         image      (js/Image.)
-        src        (.-result (.-target event))]
+        src        (.. event -target -result)]
     (events/listen image (.-LOAD events/EventType) on-image-load)
     (set! (.-src image) src)
-    (set! (.-innerHTML pixels-div) ""))
-  (print "onreaderload"))
+    (set! (.-innerHTML pixels-div) "")))

 (defn handle-files [event]
   {:pre [(> (alength (.-files (.-target event))) 0)]}


remove json file usage

remove json file usage

--- src/http_users/core.clj
+++ src/http_users/core.clj
@@ -11,7 +11,8 @@
 ;(def user-data "/var/www/json/user-data.json")
 ;(def user-data (.getFile (clojure.java.io/resource "user-data.json")))

-(def user-data (io/file (io/resource "user-data.json")))
+;(def user-data (io/file (io/resource "user-data.json")))
+(def user-data 0)
 (def port 8080)

 (defn user-to-html [user]


test(minify): add test for minify function

--- test/asset_minifier/core_test.clj
+++ test/asset_minifier/core_test.clj
@@ -123,4 +123,26 @@
   (testing "html minification"
     (run-test
      (minify-html (str input-path "/html/") (str output-path "html/") {})
-     {:sources '("testCompress.html") :targets '("testCompress.html") :original-size 581 :compressed-size 459 :gzipped-size 256})))
+     {:sources '("testCompress.html") :targets '("testCompress.html") :original-size 581 :compressed-size 459 :gzipped-size 256}))
+
+  (testing "minify function"
+    (is (= (minify [[:html {:source (str input-path "/html/") :target (str output-path "html/")}]
+                    [:js {:source (str input-path "/js/input1.js") :target (str output-path "output.min.js")}]
+                    [:css {:source (str input-path "/css/input1.css") :target (str output-path "output.min.css")}]])
+            [{:sources '("testCompress.html")
+              :targets '("testCompress.html")
+              :original-size 581
+              :compressed-size 459
+              :gzipped-size 256}
+             {:warnings ()
+              :errors ()
+              :sources ["input1.js"]
+              :target "output.min.js"
+              :original-size 117
+              :compressed-size 84
+              :gzipped-size 93}
+             {:sources '("input1.css"),
+              :target "output.min.css",
+              :original-size 989,
+              :compressed-size 784,
+              :gzipped-size 424}]))))


Fixed output variables - don't know what I was thinking before.

--- src/clj/forma/hadoop/jobs/scatter.clj
+++ src/clj/forma/hadoop/jobs/scatter.clj
@@ -306,11 +306,10 @@

 (defn sink-40103-for-betas
-  "query to return the beta vector associated with each ecoregion"
   [{:keys [t-res est-start ridge-const convergence-thresh max-iterations]}
    dynamic-src static-src]
   (let [first-idx (date/datetime->period t-res est-start)]
-    (<- [?s-res ?eco]
+    (<- [?hansen ?val ?neighbor-val]
         (dynamic-src ?s-res ?pd ?mod-h ?mod-v ?s ?l ?val ?neighbor-val)
         (static-src ?s-res ?mod-h ?mod-v ?s ?l _ _ ?eco ?hansen)
         (= ?pd first-idx)


rename filters to criteria

rename filters to criteria

--- src/clj/morpheus/models/edge/base.clj
+++ src/clj/morpheus/models/edge/base.clj
@@ -181,7 +181,7 @@
         list-ids (map :list-cid lists)]
     (dorun (map remove-list-chain list-ids))))

-(defn extract-cid-lists [direction sid vertex-id filters]
+(defn extract-cid-lists [direction sid vertex-id criteria]
   (with-cid-list
     (let [{:keys [cid-array] :as list-cell} (neb-cell/read-cell trunk hash)]
       (concat [{:cid-array cid-array
@@ -191,7 +191,7 @@
                 (neb/read-lock-exec*
                   next-cid
                   'morpheus.models.edge.base/extract-cid-lists
-                  direction sid vertex-id filters))))))
+                  direction sid vertex-id criteria))))))

 (defn get-oppisite [edge vertex-id]
   (let [{:keys [*start* *end*]} edge]
@@ -220,25 +220,25 @@
                                            types [types])))))
         params (if-not (seq params)
                  (map (fn [d] {:directions [d]}) all-dir-fields)
-                 (map (fn [{:keys [type types direction directions filters]}]
+                 (map (fn [{:keys [type types direction directions criteria]}]
                         {:types (regular-types (or type types))
                          :directions (regular-directions (or direction directions))
-                         :filters filters})
+                         :criteria criteria})
                       params))
-        expand-params (flatten (map (fn [{:keys [directions types filters]}]
+        expand-params (flatten (map (fn [{:keys [directions types criteria]}]
                                       (map
                                         (fn [d]
                                           (if (seq types)
-                                            (map (fn [t] {:d d :t (or t :Nil) :f filters}) types)
-                                            {:d d :t nil :f filters}))
+                                            (map (fn [t] {:d d :t (or t :Nil) :c criteria}) types)
+                                            {:d d :t nil :c criteria}))
                                         directions))
                                     params))
         params-grouped (group-by :d expand-params)
         direction-fields (->> params-grouped (keys) (set))
         direction-items (map-on-vals
                           (fn [ps]
-                            (let [item (set (map (fn [{:keys [t f]}]
-                                                   (if t [t f] :Nil))
+                            (let [item (set (map (fn [{:keys [t c]}]
+                                                   (if t [t c] :Nil))
                                                  ps))]
                               (when-not (item :Nil) item)))
                           params-grouped)
@@ -261,7 +261,7 @@
                        list-cid read-list-sym
                        direction sid vertex-id
                        (map second
-                            (filter (fn [[t f]] (and (= t sid) (identity t) (identity f)))
+                            (filter (fn [[t c]] (and (= t sid) (identity t) (identity c)))
                                     items)))))
                  dir-cid-list)))
            cid-lists)


removing old browse-page function, renaming new one to old one

--- src/cljs/cljspazzer/client/pages.cljs
+++ src/cljs/cljspazzer/client/pages.cljs
@@ -60,34 +60,6 @@
      ])
   )

-(defn browse-page [data]
-  (let [active-artist (:active-artist data)
-        artists (:artists data)
-        artist-count (count artists)
-        albums (:albums data)
-        album-count (count albums)
-        active-album (:active-album data)]
-    (html
-     [:div.browse
-      [:div.pure-g
-       [:div.collection-nav
-        [:h3 "Artists"]
-        [:ul (map nav-item nav-seq)]]]
-      [:div.content.pure-g
-       [:div.artist-list.pure-u-1
-        [:h3 (utils/format "%s Artists" artist-count)]
-        [:ul (map artist-item artists)]]
-       [:div.artist-detail
-        [:div.pure-u-4-5
-         [:h3 (utils/format "%s Albums" album-count)]
-         [:ul (map (partial album-item active-artist) albums)]]
-        [:div.pure-u-1-5
-         [:h3 active-artist]
-         [:img {:src (utils/format "/api/artists/%s/image" (utils/encode active-artist))}]]]
-       [:div.pure-u-1
-        [:div.album-detail
-         (album-detail active-artist active-album)]]]])))
-
 (defn nav-partial []
   [:div.collection-nav
    [:h3 "Artists"]
@@ -112,7 +84,7 @@
      [:h3 active-artist]
      [:img {:src artist-image}]]))

-(defn browse-page-new [data]
+(defn browse-page [data]
   (let [active-artist (:active-artist data)
         artists (:artists data)
         artist-count (count artists)
@@ -183,7 +155,7 @@
                   "create"]]]])))))

 (defn view-browse [data]
-  (om/component (browse-page-new data)))
+  (om/component (browse-page data)))

 (defn view-debug [data owner]
   (reify


add another bower pkg to jetty example

add another bower pkg to jetty example

--- jetty/config/bower.clj
+++ jetty/config/bower.clj
@@ -1,7 +1,8 @@
 (ns bower)

 (def config-map
-  {"materialize" [{:ns 'hello.styles :name 'materialize
+  {"moment" 'hello.scripts/moment
+   "materialize" [{:ns 'hello.styles :name 'materialize
                    :uri "bower_components/Materialize/bin/materialize.css"}
                   {:ns 'hello.scripts :name 'materialize
                    :uri "bower_components/Materialize/bin/materialize.js"}]})


Tweaks and thoughts on a new idea

Tweaks and thoughts on a new idea

--- src/main/clojure/clj_print/core.clj
+++ src/main/clojure/clj_print/core.clj
@@ -162,36 +162,52 @@
 (defprotocol ISpoolable
   "This protocol defines a contract that states the
    responsibilities of any implementation that wishes
-   to be considered 'spoolable.' For an implementation
+   to be considered 'spoolable,' which implies that it
+   can be queued for later processing such that it is
+   another process' resonsibility to handle the ISpoolable
+   and block until it has been processed. For an implementation
    to be spoolable, it must be able to do the following:"
   (submit [this]) ;; Submit the job
-  (add-listener [this listener])) ;; Attach an event listener
-
-;; (defprotocol IBlock
-;;   "This protcol specifies methods that a PrintsService may
-;;    implement to allow clients to block/unblock the service."
-;;   (block [this])
-;;   (unblock [this]))
+  (add-listener [this listener])) ;; Attach an event listener that
+                                  ;; returns a value when the process is complete

 (defrecord JobSpec [doc printer job attrs]
   ISpoolable
   (submit [this]
-    (let [{{obj :obj} :doc} this
-          {:keys [^DocPrintJob job attrs]} this]
-      (.. job (print @obj (make-set attrs :request)))))
+    (cond
+     (:doc this) (let [{{obj :obj} :doc} this
+                       {:keys [^DocPrintJob job attrs]} this]
+                   (.. job (print @obj (make-set attrs :request))))
+     (:docs this) (let [{docs :docs ^PrintService printer :printer} this]
+                    (for [d docs]
+                      [(make-doc d) (.. printer createPrintJob)]))
+     :else nil))
   (add-listener [this listener]
-    (if-let [{job :job} this]
+    (if-let [{^DocPrintJob job :job} this]
       (do (doto job (.addPrintJobListener listener))
           (assoc this :listener listener))
       (throw IllegalStateException "No DocPrintJob keyed at :job."))))

-(defn linked-listener [job]
-  )
-
-;; (defrecord SimpleMultiDoc [this]
-;;   javax.print.MultiDoc
-;;   (getDoc [this] this)
-;;   (next [this]))
+(defn job-seq [job-map]
+  (let [{docs :docs ^PrintService printer :printer} job-map]
+    (for [d docs]
+      [(make-doc d) (.. printer createPrintJob)])))
+
+;; TODO: SEE http://oobaloo.co.uk/clojure-from-callbacks-to-sequences!!!
+;;
+;; (defprotocol IOperator
+;;   "This protocol is to be used by implementations
+;;    that wish to handle a print process by coordinating
+;;    the processing of multiple documents within an ISpoolable."
+;;   (process [this spec]))
+
+;; (defrecord PrintOperator [spec]
+;;   IOperator
+;;   (process [this spec]
+;;     (when-let [docs (seq (:docs spec))]
+;;       (let [{^PrintService printer :printer} spec
+;;             job (.. printer createPrintJob)]
+;;         (submit spec)))))

 ;; TODO: Need to be able to ensure that the PrintService does not
 ;; process incoming jobs until it has finished processing the MultiDoc


exclude ensure

exclude ensure

--- src/main/clojure/cljs/analyzer.cljc
+++ src/main/clojure/cljs/analyzer.cljc
@@ -7,8 +7,8 @@
 ;   You must not remove this notice, or any other, from this software.

 (ns cljs.analyzer
-  #?(:clj  (:refer-clojure :exclude [macroexpand-1])
-     :cljs (:refer-clojure :exclude [macroexpand-1 ns-interns]))
+  #?(:clj  (:refer-clojure :exclude [macroexpand-1 ensure])
+     :cljs (:refer-clojure :exclude [macroexpand-1 ns-interns ensure]))
   #?(:cljs (:require-macros
              [cljs.analyzer.macros
               :refer [no-warn wrapping-errors


Remove stray new line

Remove stray new line

--- src/karmanaut/utils.clj
+++ src/karmanaut/utils.clj
@@ -27,7 +27,6 @@
       (.set Calendar/MILLISECOND 0))
     (.getTime c)))

-
 (defn long-to-date
   "Reddit timestamps are the number of seconds since the
   Unix epoch, in UTC."


- make api explicit and verified using pre-coditions

--- src/re_com/date.cljs
+++ src/re_com/date.cljs
@@ -2,9 +2,8 @@
 ;; depends: datepicker-bs3.css

 (ns re-com.date
-  (:require-macros [clairvoyant.core :refer [trace-forms]])
   (:require
-    [clairvoyant.core     :refer [default-tracer]]
+    [clojure.set          :refer [superset?]]
     [cljs-time.core       :refer [now minus plus months days year month day day-of-week first-day-of-the-month
                                   before? after?]]
     [cljs-time.predicates :refer [sunday?]]
@@ -188,21 +187,22 @@
     (merge attributes {:enabled-days enabled-days
                        :today (now)})))

+(def api
+  #{:model        ; goog.date.UtcDateTime can be reagent/atom.
+                  ; The calendar will be focused on corresponding date and the date represents selection.
+   :on-change     ; function callback will be passed new selected goog.date.UtcDateTime
+   :disabled      ; optional boolean can be reagent/atom. When true, navigation is allowed but selection is disabled.
+   :enabled-days  ; set of any #{:Su :Mo :Tu :We :Th :Fr :Sa} if nil or an empty set, all days are enabled.
+   :show-weeks    ; boolean. When true, first column shows week numbers.
+   :show-today    ; boolean. When true, today's date is highlighted. Selected day highlight takes precedence.
+   :minimum       ; optional goog.date.UtcDateTime inclusive beyond which navigation & selection is blocked.
+   :maximum       ; optional goog.date.UtcDateTime inclusive beyond which navigation & selection is blocked.
+   :hide-border   ; boolean. Default false.
+   })

 (defn inline-picker
-  ;; API
-  ;;  :model         - goog.date.UtcDateTime can be reagent/atom.
-  ;;                   The calendar will be focused on corresponding date and the date represents selection.
-  ;;  :on-change     - function callback will be passed new selected goog.date.UtcDateTime
-  ;;  :disabled      - optional boolean can be reagent/atom. When true, navigation is allowed but selection is disabled.
-  ;;  :enabled-days  - set of any #{:Su :Mo :Tu :We :Th :Fr :Sa} if nil or an empty set, all days are enabled.
-  ;;  :show-weeks    - boolean. When true, first column shows week numbers.
-  ;;  :show-today    - boolean. When true, today's date is highlighted. Selected day highlight takes precedence.
-  ;;  :minimum       - optional goog.date.UtcDateTime inclusive beyond which navigation & selection is blocked.
-  ;;  :maximum       - optional goog.date.UtcDateTime inclusive beyond which navigation & selection is blocked.
-  ;;  :hide-border   - boolean. Default false.
-
-  [& {:keys [model]}]
+  [& {:keys [model] :as allprops}]
+  {:pre [(superset? api (keys allprops))]}
   (let [current (-> (real-value model) first-day-of-the-month reagent/atom)]
     (fn
       [& {:keys [model disabled hide-border on-change] :as properties}]


Interim commit.

Interim commit.

--- src/accounter/forms/date.clj
+++ src/accounter/forms/date.clj
@@ -3,13 +3,36 @@
   (require [clojure.math.combinatorics :as combo])
   (require [clj-time.core :as t]))

+(declare as-dates)
+(declare as-date)
 (declare coerce-date)

+;; takes a list of strings containing exactly 3 numeric components and returns the most likely conversion
+;; to date. this is computed by using as-date to generate permutations and selecting the permutation number
+;; which maximizes valid dates...amongs equals, use the following sequence preferences
+;; mm dd yyyy -- [2 3 1] -- index 3
+;; yyyy mm dd -- [1 2 3] -- index 0
+;; dd mm yyyy -- [3 2 1] -- index 5
+;;
+;; selection order 3 0 5 1 2 4
+
+(defn as-dates [xs]
+  (let [ps (apply mapv vector (vec (map #(vec (as-date %)) xs)))
+        sel [3 0 5 1 2 4]]
+    (let [counts (map #(count (remove false? %)) ps)]
+
+
+;; takes a string containing exactly 3 numeric components and produces a 6-vector of all possible permutations
+;; coerced to date (or false if date components were invalid)
+
 (defn as-date [s]
-  (let [ds (vec (map clojure.edn/read-string (re-seq #"\d+" s)))]
+  (let [ds (vec (map-indexed (fn [idx itm] [idx (clojure.edn/read-string itm)]) (re-seq #"\d+" s)))]
     (match ds
-      [a b c] (remove #(= % false) (map coerce-date (combo/permutations ds)))
+      [a b c] (map coerce-date (map second (combo/permutations ds)))
       :else false)))
+
+;; ds - array of yyyy mm dd
+;;               1    2  3

 (defn- coerce-date [ds]
   (try


Add doc string

Add doc string

--- src/clj/collect_earth_online/db/projects.clj
+++ src/clj/collect_earth_online/db/projects.clj
@@ -203,7 +203,15 @@
                                                                     :plot_id))))))
       nil)))

-(defn- assign-qaqc [assigned-plots design-settings]
+(defn- assign-qaqc
+  "Assigns additional plots to users based on QA/QC method.  The two options are:
+   {:qaqc-method \"overlap\"
+    :percent     50}
+   and
+   {:qaqc-method \"sme\"
+    :percent     100
+    :smes        [2 5]}"
+  [assigned-plots design-settings]
   (when (seq assigned-plots)
     (let [{:keys [qaqc-method percent smes]} (:qaqc-assignment design-settings)
           {:keys [users]}                    (:user-assignment design-settings)]


some premature optimization of constant

some premature optimization of constant

--- src/cljx/jamesmacaulay/async_tools/core.cljx
+++ src/cljx/jamesmacaulay/async_tools/core.cljx
@@ -15,11 +15,13 @@
   [x]
   (satisfies? impl/ReadPort x))

+(defrecord ConstantReadPort [boxed-value]
+  impl/ReadPort
+  (take! [_ _] boxed-value))
+
 (defn constant
   [x]
-  (reify
-    impl/ReadPort
-    (take! [_ _] (channels/box x))))
+  (ConstantReadPort. (channels/box x)))

 (defn cast-as-readport
   [x]


Fix pasting html into request

Fix pasting html into request

--- src/cljs/gc_api_browser/tabbed_request.cljs
+++ src/cljs/gc_api_browser/tabbed_request.cljs
@@ -9,9 +9,14 @@

 (def ENTER 13)

+(defn handle-paste [e]
+  (let [text (.getData (.-clipboardData e) "text/plain")]
+    (.execCommand js/document "insertText", false text))
+  (.preventDefault e))
+
 (defn handle-key-down [e]
   (when (= (.-keyCode e) ENTER)
-    (.execCommand js/document "insertHTML" false "\n")
+    (.execCommand js/document "insertText" false "\n")
     (.preventDefault e)))

 (defn content-editable [cursor owner]
@@ -21,6 +26,7 @@
       (dom/code #js {:contentEditable         true
                      :dangerouslySetInnerHTML #js {:__html (:body cursor)}
                      :onKeyDown               handle-key-down
+                     :onPaste                 handle-paste
                      :onInput                 (fn [_]
                                                 (let [html (.-innerHTML (om/get-node owner))]
                                                   (om/transact! cursor :body (fn [_] html))))}))))


cleanup

cleanup

--- src/clojure/zensols/cisql/process_query.clj
+++ src/clojure/zensols/cisql/process_query.clj
@@ -179,7 +179,8 @@
           (print (format (conf/config :prompt) (swap! line-no inc)))
           (flush))))))

-(defn process-queries [dir-fns]
+(defn process-queries
+  [dir-fns]
   (let [prompt-fn (or (get dir-fns :prompt-for-input)
                       (gen-prompt-fn))]
     (letfn [(set-var [[key newval]]
@@ -190,9 +191,7 @@
               (if (= key 'show)
                 (conf/print-key-values)
                 (let [val (conf/config key)]
-                  (println (format "%s: %s" (name key) val))
-                  ;(println (format "Error: no such variable: %s" (name key)))
-                  )))
+                  (println (format "%s: %s" (name key) val)))))
             (toggle [key]
               (let [oldval (conf/config key)
                     nextval (not oldval)]
@@ -218,10 +217,6 @@
         (when (= :end-query (:directive query-data))
           (recur (read-query prompt-fn set-var show toggle)))))))

-(defn process-query-string [query-string dir-fns]
-  (binding [*std-in* (BufferedReader. (StringReader. query-string))]
-    (process-queries dir-fns)))
-
 (defn start-event-loop [dbspec]
   (log/debug "staring loop")
   (db/set-db-spec dbspec)


ready for prom

ready for prom

--- src/tailrecursion/boot/tmpregistry.clj
+++ src/tailrecursion/boot/tmpregistry.clj
@@ -5,9 +5,9 @@
   (:refer-clojure :exclude [get])
   (:import java.io.File))

+(def ^:dynamic *basedir* (File. "."))
+
 ;;; file stuff
-
-(def ^:dynamic *basedir* (File. "."))

 (defn delete! [f]
   (let [delete (io/file f)]
@@ -55,25 +55,14 @@
     (delete! (io/file reg (munge k)))))

 (defn mk [k & [name]]
-  (when (exists? k) (unmk k))
+  (when (exists? k) (unmk k))
   (doto (make-file k (or name (str (gensym "file") ".tmp")))
     io/make-parents
     (.createNewFile)
     (.setLastModified (System/currentTimeMillis))))

 (defn mkdir [k & [name]]
-  (when (exists? k) (unmk k))
+  (when (exists? k) (unmk k))
   (doto (make-file k (or name (str (gensym "dir"))))
     delete!
     (.mkdirs)))
-
-(comment
-  ;; by default, the registry goes in (File. "."). can be set with *basedir*.
-  (create-registry!);=> recursively deletes and creates: #<File /home/alan/./.boot/tmp>
-  (mk ::foo)        ;=> #<File /home/alan/./.boot/tmp/_COLON_tmpregistry_SLASH_foo/file745.tmp>
-  (mk ::file "a.b") ;=> #<File /home/alan/./.boot/tmp/_COLON_tmpregistry_SLASH_file/a.b>
-  (mkdir ::out)     ;=> #<File /home/alan/./.boot/tmp/_COLON_tmpregistry_SLASH_out/dir750>
-  (get ::out)       ;=> #<File /home/alan/./.boot/tmp/_COLON_tmpregistry_SLASH_out/dir750>
-  (unmk ::out)
-  (destroy-registry!)   ;=> true (~/.boot/tmp was recursively deleted, optional)
-)