minor changes to stress testing code

minor changes to stress testing code

--- test/acceptance/stress_tests.clj
+++ test/acceptance/stress_tests.clj
@@ -53,7 +53,7 @@

 (defn bunch-a-junk
   [interpreter how-much-junk]
-  (remove nil? (repeatedly how-much-junk #(condp = (rand-int 10)
+  (remove nil? (repeatedly how-much-junk #(condp = (rand-int 20)
                                      0 (random-integer)
                                      1 (random-float)
                                      2 (random-boolean)


Reindent test-enlive-selectors

Reindent test-enlive-selectors

--- test/comic_reader/sites_test.clj
+++ test/comic_reader/sites_test.clj
@@ -93,12 +93,12 @@
 (defn test-enlive-selectors []
   (tu/are-with-msg [sel-fn]
                    (is (valid-selector? (sel-fn))
-                                (str "All elements of a selector "
-                                     "must be keywords."))
-    comic-list-selector
-    chapter-list-selector
-    page-list-selector
-    image-selector))
+                       (str "All elements of a selector "
+                            "must be keywords."))
+                   comic-list-selector
+                   chapter-list-selector
+                   page-list-selector
+                   image-selector))

 (defn test-normalize-functions []
   (tu/are-with-msg [norm-fn]


Fix atomic params for channels

Fix atomic params for channels

--- src/webcv/chan.cljs
+++ src/webcv/chan.cljs
@@ -36,12 +36,11 @@

 (defmethod make-chan-node ::transducer
   [ctx {::keys [xform] ::synthdef/keys [static-params]}]
-  (let [out (async/chan 1 (comp (merge-xform static-params)
+  (let [out (async/chan 1 (comp (merge-xform {})
                                 (make-transducer ctx xform)))]
     (doseq [[k v] static-params]
-      (.log js/console k v)
       (if (satisfies? IWatchable v)
-        (add-watch v k #(async/put! out {k v}))
+        (add-watch v k #(async/put! out {k %4}))
         (async/put! out {k v})))
     {::mult-out (async/mult out)
      ::mix-out (async/mix out)}))


Windows buildcheck: minor change.

Windows buildcheck: minor change.

Use explicit parameter for whether or not to report missing files and wiki
pages.

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@11156 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- buildscripts/buildcheck/src/buildcheck/core.clj
+++ buildscripts/buildcheck/src/buildcheck/core.clj
@@ -205,7 +205,7 @@
          (str-lines (flatten (list data)))
          "None.")))

-(defn report-build-errors [bits mode test]
+(defn report-build-errors [bits mode report-missing? test]
   (let [f (result-file bits mode)
         svn-confs (svn-conflicts)
         result-txt (slurp f)
@@ -238,22 +238,21 @@
         (report-segment "Errors reported by java compiler" javac-errs)
         (report-segment "Errors reported by clojure compiler" clojure-errors)
         (report-segment "Outdated jar files" outdated-jars)
-        (when (= 32 bits)
+        (when report-missing?
           (report-segment "Missing .vcproj files" missing-vcproj-files))
         (report-segment "Uncompiled device adapters" (missing-device-adapters bits))
-        (when (= 32 bits)
+        (when report-missing?
           (report-segment "Missing device links" (missing-device-links)))
-        (when (= 32 bits)
+        (when report-missing?
           (report-segment "Missing device pages" (missing-device-pages)))
         "\n\nIs installer download available on website?\n"
-        (if installer-ok "Yes." "No. (build missing)\n")
-      ))))
+        (if installer-ok "Yes." "No. (build missing)\n")))))

 (defn make-full-report [mode send?]
   (let [report
         (str
-          (report-build-errors 32 mode false)
-          (report-build-errors 64 mode false))]
+          (report-build-errors 32 mode true false)
+          (report-build-errors 64 mode false false))]
     (if-not (empty? report)
       (do
         (when send?
@@ -270,7 +269,7 @@

 (defn test-report []
   (doseq [bits [32 64]]
-    (println (report-build-errors bits :full true))))
+    (println (report-build-errors bits :full true true))))

 (defn -main [mode]
   (make-full-report (get {"inc" :inc "full" :full} mode) true))


Take advice from kibit

Take advice from kibit

--- src/refactor_nrepl/ns/dependencies.clj
+++ src/refactor_nrepl/ns/dependencies.clj
@@ -28,8 +28,7 @@
     (update-in libspec [:refer] (constantly :all))
     libspec))

-(defmulti parse-libspec
-  (fn [libspec] (first libspec)))
+(defmulti parse-libspec first)

 (defn- extract-referred [libspec]
   (let [refer (some->> libspec (drop-while #(not= % ":refer")) second)]
@@ -72,7 +71,7 @@
      (for [libspec parse-tree]
        (parse-libspec libspec)))))

-(defmulti parse-import (fn [import] (first import)))
+(defmulti parse-import first)

 (defmethod parse-import :class
   [import]


Pull reference to env out to a require :refer

It broke when I tried to run it on Heroku, so I've put it back to how it
was before and everything was happy.

--- resources/leiningen/new/com.beardandcode.web/src/clj/health.clj
+++ resources/leiningen/new/com.beardandcode.web/src/clj/health.clj
@@ -6,6 +6,7 @@
             [cheshire.core :as json]
             [compojure.core :refer :all]
             [compojure.route :as route]
+            [environ.core :refer [env]]
             [metrics.ring.expose :refer [serve-metrics]]
             [ring.middleware.params :refer [wrap-params]]))

@@ -45,7 +46,7 @@

          (GET "/" [:as request] (json-response {:app true}))

-         (GET "/environment-variables" [] (json-response environ.core/env))
+         (GET "/environment-variables" [] (json-response env))

          (GET "/metrics" [] (serve-metrics nil))


Added testing functions to user ns

Added testing functions to user ns

--- dev/user.clj
+++ dev/user.clj
@@ -3,13 +3,31 @@
             [clojure.string :as str]
             [clojure.pprint :refer [pprint]]
             [clojure.repl :refer :all]
+            [clojure.test :as test]
+            [clojure.tools.namespace.find :refer [find-namespaces-in-dir]]
+            [clojure.java.io :refer [as-file]]
             [clojure.tools.namespace.repl :refer [refresh refresh-all set-refresh-dirs]]
             [environ.core :refer [env]]
             [cfpb.qu.main :as main]
             [cfpb.qu.data :as data :refer [ensure-mongo-connection]]
             [cfpb.qu.loader :as loader :refer [load-dataset]]))

-(set-refresh-dirs "src/" "dev/")
+(set-refresh-dirs "src/" "dev/" "test/")
+
+(defn load-tests
+  []
+  (doseq [namespace (find-namespaces-in-dir (as-file "test"))]
+    (require namespace)))
+
+(defn run-unit-tests
+  []
+  (refresh)
+  (apply test/run-tests (remove (fn [namespace] (:integration (meta namespace))) (all-ns))))
+
+(defn run-all-tests
+  []
+  (refresh)
+  (test/run-all-tests))

 (def server (atom nil))


changes test token names to c<timestanmp>-w8r-<suffix> pattern (#1426)

--- waiter/src/waiter/util/client_tools.clj
+++ waiter/src/waiter/util/client_tools.clj
@@ -849,10 +849,17 @@
    (let [test-prefix (System/getenv "WAITER_TEST_PREFIX")]
      (str/replace (str test-prefix (extract-acronym service-name) (System/nanoTime)) #"-" ""))))

+(def retrieve-cluster-name
+  (memoize
+    (fn [waiter-url]
+      (-> (waiter-settings waiter-url)
+        (get-in [:cluster-config :name])))))
+
 (defn create-token-name
   "Creates a random token name using the waiter url."
   ([waiter-url separator]
-   (let [prefix (str "test-" java-pid "-" (System/nanoTime))]
+   (let [cluster-name (retrieve-cluster-name waiter-url)
+         prefix (str "c" (System/nanoTime) "-w8r-" cluster-name)]
      (create-token-name waiter-url separator prefix)))
   ([waiter-url separator prefix]
    (str prefix "." (subs waiter-url 0 (str/index-of waiter-url separator)))))


Separated between with and without navigation.

--- web/src/sound_effector/views/layout.clj
+++ web/src/sound_effector/views/layout.clj
@@ -28,7 +28,7 @@
         [:a {:class "btn btn-fb" :href "/sound-effects"}
          [:i {:class "fa fa-facebook"} " Facebook"]]]))])

-(defn common [request title & content]
+(defn- private-common [request title with-navigation & content]
   (page/html5
     [:head
      [:meta {:charset "utf-8"}]
@@ -41,9 +41,16 @@
      (page/include-css "/css/sound_effector.css")]
     [:body
      [:div {:id "content" :class "container"}
-      (navigation request)
+      (if with-navigation (navigation request))
       content]]))

+(defn common [request title & content]
+  (private-common request title true content))
+
+(defn common-without-navigation [request title & content]
+  (private-common request title false content))
+
 (defn response-404 []
-  (common "Page Not Found"
+  (common nil
+          "Page Not Found"
           "Page Not Found"))


Provide full board to representation render in a couple more cases.

--- src/oc/storage/api/entries.clj
+++ src/oc/storage/api/entries.clj
@@ -214,13 +214,15 @@

   ;; Responses
   :handle-ok (by-method {
-    :get (fn [ctx] (entry-rep/render-entry org-slug board-slug
+    :get (fn [ctx] (entry-rep/render-entry org-slug
+                      (:existing-board ctx)
                       (:existing-entry ctx)
                       (:existing-comments ctx)
                       (:existing-reactions ctx)
                       (:access-level ctx)
                       (-> ctx :user :user-id)))
-    :patch (fn [ctx] (entry-rep/render-entry org-slug board-slug
+    :patch (fn [ctx] (entry-rep/render-entry org-slug
+                        (:existing-board ctx)
                         (:updated-entry ctx)
                         (:existing-comments ctx)
                         (:existing-reactions ctx)
@@ -453,7 +455,7 @@

   ;; Responses
   :handle-ok (fn [ctx] (entry-rep/render-entry (:existing-org ctx)
-                                               (:slug (:existing-board ctx))
+                                               (:existing-board ctx)
                                                (:existing-entry ctx)
                                                (:existing-comments ctx)
                                                (:existing-reactions ctx)


Log font name on start up

Log font name on start up

--- src/robinson/swingterminal.clj
+++ src/robinson/swingterminal.clj
@@ -1,5 +1,6 @@
 ;; Functions for rendering state to screen
 (ns robinson.swingterminal
+  (:require [taoensso.timbre :as timbre])
   (:import
             java.util.concurrent.LinkedBlockingQueue
             java.awt.Color
@@ -27,6 +28,7 @@
             javax.swing.Timer
             javax.swing.ImageIcon))

+(timbre/refer-timbre)
 (set! *warn-on-reflection* true)

 (defprotocol ATerminal
@@ -69,6 +71,7 @@
           bold-font        (if is-windows
                               (Font. windows-font Font/BOLD font-size)
                               (Font. else-font  Font/BOLD font-size))
+          _                (info "Using font" (.getFontName normal-font))
           default-fg-color (Color. (long default-fg-color-r) (long default-fg-color-g) (long default-fg-color-b))
           default-bg-color (Color. (long default-bg-color-g) (long default-bg-color-g) (long default-bg-color-b))
           character-map    (atom (vec (repeat rows (vec (repeat columns (TerminalCharacter. \space default-fg-color default-bg-color #{}))))))


hiccip attrs normalization for prum

hiccip attrs normalization for prum

--- src/sablono/cljss_compiler.clj
+++ src/sablono/cljss_compiler.clj
@@ -4,24 +4,46 @@
             [cljss.core :as cljss]))

 (defn- compile-class [class styles]
-  (let [cls (str "css-" (hash styles))
+  (let [cls       (str "css-" (hash styles))
         gen-class `(cljss.core/css ~cls ~@(cljss/build-styles cls styles))]
     (if (seq class)
       `(apply str ~gen-class " " ~@(interpose " " class))
       gen-class)))

+(defn- normalize-attr [tag name type]
+  (if (and (or (= name :on-change) (= name :onChange))
+           (or (= tag "textarea")
+               (and (= tag "input")
+                    (or (nil? type)
+                        (->> type (re-matches #"^(fil|che|rad).*") nil?)))))
+    :on-input
+    name))
+
+(defn- compile-prum-attrs [tag attrs]
+  (->> attrs
+       (map (fn [[name value]]
+              [(normalize-attr tag name (:type attrs)) value]))))
+
+(defn- compile-rum-attrs [class attrs]
+  (->> attrs
+       (reduce (fn [attrs [name value]]
+                 (if (= name :css)
+                   (assoc attrs :class (compile-class class value))
+                   (assoc attrs name (s/compile-attr name value))))
+               nil)))
+
+(defn- compile-attrs
+  ([attrs]
+   (compile-attrs nil attrs))
+  ([tag {:keys [class className class-name] :as attrs}]
+   (let [class (filter identity [class className class-name])]
+     (cond->> (seq attrs)
+              tag (compile-prum-attrs tag)
+              true (compile-rum-attrs class)
+              true (sutil/html-to-dom-attrs)
+              true (s/to-js)))))
+
 ;; WARNING: NEVER EVER DO THIS AT HOME!
 ;; swap `sablono.compiler/compile-attrs` fn with own, adjusted, implementation
-(alter-var-root
-  #'s/compile-attrs
-  (fn [_]
-    (fn [{:keys [class className class-name] :as attrs}]
-      (let [class (filter identity [class className class-name])]
-        (->> (seq attrs)
-             (reduce (fn [attrs [name value]]
-                       (if (= name :css)
-                         (assoc attrs :class (compile-class class value))
-                         (assoc attrs name (s/compile-attr name value))))
-                     nil)
-             (sutil/html-to-dom-attrs)
-             (s/to-js))))))
+(alter-var-root #'s/compile-attrs (fn [_] compile-attrs))
+


Split long lines.

Split long lines.

--- src/cbfg/kvs.cljs
+++ src/cbfg/kvs.cljs
@@ -82,8 +82,8 @@
              (fn [state]
                (act list-names actx
                     (doseq [name (keys (:kvss state))]
-                      (aput list-names (:res-ch m) (merge m {:more true :status :ok
-                                                             :name name})))
+                      (aput list-names (:res-ch m)
+                            (merge m {:more true :status :ok :name name})))
                     (aput-close list-names (:res-ch m) (merge m {:status :ok})))
                nil)))

@@ -92,14 +92,17 @@
      (kvs-do actx state-ch (:res-ch m)
              #(if-let [name (:name m)]
                 (if-let [kvs (get-in % [:kvss name])]
-                  [% (merge m {:status :ok :status-info :reopened
+                  [% (merge m {:status :ok
+                               :status-info :reopened
                                :kvs-ident [name (:uuid kvs)]})]
                   [(-> %
                        (assoc-in [:kvss name] (make-kvs name (:next-uuid %)))
                        (assoc :next-uuid (inc (:next-uuid %))))
-                   (merge m {:status :ok :status-info :created
+                   (merge m {:status :ok
+                             :status-info :created
                              :kvs-ident [name (:next-uuid %)]})])
-                [% (merge m {:status :invalid :status-info :missing-name-arg})])))
+                [% (merge m {:status :invalid
+                             :status-info :missing-name-arg})])))

    :kvs-remove
    (fn [actx state-ch m]
@@ -120,10 +123,12 @@
                          (let [entry (kc-entry-by-key kc key)]
                            (if (and entry (or include-deleted (not (:deleted entry))))
                              (aput multi-get res-ch
-                                   (merge res-m {:more true :status :ok
+                                   (merge res-m {:more true
+                                                 :status :ok
                                                  :key key :entry entry}))
                              (aput multi-get res-ch
-                                   (merge res-m {:more true :status :not-found
+                                   (merge res-m {:more true
+                                                 :status :not-found
                                                  :key key})))))
                        (aput-close multi-get res-ch (merge res-m {:status :ok}))))
                 nil)]
@@ -202,5 +207,6 @@
              (dissoc-in [:dirty :changes [old-sq key]])
              (assoc-in [:dirty :changes [new-sq key]] (assoc entry :sq new-sq)))
          {:more true :status :ok :key key :sq new-sq}]
-        [kvs {:more true :status :mismatch :key key
+        [kvs {:more true
+              :status :mismatch :key key
               :status-info [:wrong-sq (:sq entry)]}]))))


replace for loop with doseq side-effects

--- src/sierpinski_sieve/core.cljs
+++ src/sierpinski_sieve/core.cljs
@@ -25,10 +25,9 @@
         (set! (.-fillStyle ctx) "black")
         (.fillRect ctx 0 0 size size)
         (set! (.-fillStyle ctx) "white")
-        (doall
-         (for [x (range 100)
-               y (range 10)]
-           (put-pixel ctx x y)))))))
+        (doseq [x (range 100)
+                y (range 10)]
+          (put-pixel ctx x y))))))

 (reagent/render-component [render-canvas]
                           (. js/document (getElementById "app")))


Hide opened keyboard when user taps on chat (#1057)

--- src/status_im/chat/screen.cljs
+++ src/status_im/chat/screen.cljs
@@ -16,7 +16,7 @@
             [status-im.utils.listview :refer [to-datasource-inverted]]
             [status-im.utils.utils :refer [truncate-str]]
             [status-im.utils.datetime :as time]
-            [status-im.utils.platform :refer [platform-specific]]
+            [status-im.utils.platform :as platform :refer [platform-specific]]
             [status-im.components.invertible-scroll-view :refer [invertible-scroll-view]]
             [status-im.components.toolbar-new.view :refer [toolbar]]
             [status-im.chat.views.toolbar-content :refer [toolbar-content-view]]
@@ -167,7 +167,7 @@
                 :renderScrollComponent     #(invertible-scroll-view (js->clj %))
                 :onEndReached              (when-not loaded? #(dispatch [:load-more-messages]))
                 :enableEmptySections       true
-                :keyboardShouldPersistTaps :always
+                :keyboardShouldPersistTaps (if platform/android? :always :never)
                 :dataSource                (to-datasource-inverted messages)}]))

 (defview chat []


Add occur* tests.

Add occur* tests.


jotted a few ideas

jotted a few ideas

--- test/push/design_spikes/dsl_macros.clj
+++ test/push/design_spikes/dsl_macros.clj
@@ -12,7 +12,7 @@
 ;; The DSL for Push instructions could be a series of simple steps.
 ;; Everything would be assumed to happen inside one interpreter, and the interpreter
 ;; (and some store of scratch vars) would be passed step-to-step.
-;;
+
 ; + `count-of [stackname :as local]`
 ;    store the number of items in `stackname` under key `local`
 ;    raise an Exception if the stack doesn't exist
@@ -62,13 +62,25 @@
 ;    raise an exception if it's undefined

 ; - `instructions [:as kwd]`
-;    save a list of all active instructions in the named local
+;    save a list of all registered instructions in the named local

 ; - `inputs [:as kwd]`
-;    save a list of all known inputs in the named local
+;    save a list of all registered inputs in the named local

 ; - `counter [:as kwd]`
-;    save the current interpreter counter in the named local
+;    save the current interpreter counter value in the named local
+
+
+
+;; Possible simplifications (this is JUST A SKETCH remember)
+;;
+;; (consume-all-of %
+;;   :integer :foo :boolean :bar :integer :baz :float :qux)
+;;
+;; (place-all-of %
+;;   :integer :foo :boolean :bar :integer :baz :float :qux)
+
+

 (def six-ints (make-interpreter :stacks {:integer '(6 5 4 3 2 1)}))


remove unused prop

remove unused prop

--- src/cljs/wombats_web_client/components/simulator/configure.cljs
+++ src/cljs/wombats_web_client/components/simulator/configure.cljs
@@ -28,8 +28,7 @@
   (when-not (:template-id @form-state)
     (swap! form-state assoc :template-id (:simulator-template/id (first templates))))

-  [:select.select {:name "template"
-                   :on-change #(update-form-state % :template-id form-state)}
+  [:select.select {:on-change #(update-form-state % :template-id form-state)}
    (for [{id :simulator-template/id
           {arena-name :arena/name} :simulator-template/arena-template} templates]
      (render-option id arena-name (:template-id @form-state)))])
@@ -39,8 +38,7 @@
   (when-not (:wombat-id @form-state)
     (swap! form-state assoc :wombat-id (:wombat/id (first wombats))))

-  [:select.select {:name "wombat"
-                   :on-change #(update-form-state % :wombat-id form-state)}
+  [:select.select {:on-change #(update-form-state % :wombat-id form-state)}
    (for [{id :wombat/id
           wombat-name :wombat/name} wombats]
      (render-option id wombat-name (:wombat-id @form-state)))])


Add missing move Transform, used by Ditto

--- frontend/src/cruncher/moves/data.cljs
+++ frontend/src/cruncher/moves/data.cljs
@@ -2151,4 +2151,19 @@
                :animation-id           4
                :vfx-name               "\"Rock_smash_fast\""
                :name                   "Rock Smash"
-               :type                   "Fighting"}})+               :type                   "Fighting"}
+          242 {:damage-window-end-ms   -1
+               :accuracy-change        -1
+               :stamina-loss-scalar    -1
+               :energy-delta           0
+               :trainer-level-max      100
+               :trainer-level-min      1
+               :damage-window-start-ms -1
+               :id                     242
+               :power                  0
+               :unique-id              "V0242_MOVE_Normal_TRANSFORM"
+               :duration-ms            1730
+               :animation-id           4
+               :vfx-name               "\"Normal_transform\""
+               :name                   "Transform"
+               :type                   "Normal"}})


:bug: Fix display of user tooltip

:bug: Fix display of user tooltip

--- frontend/src/uxbox/main/ui/users.cljs
+++ frontend/src/uxbox/main/ui/users.cljs
@@ -49,8 +49,8 @@
         photo (if (str/empty? (:photo profile ""))
                 "/images/avatar.jpg"
                 (:photo profile))]
-    [:div.user-zone {:on-mouse-down #(swap! local assoc :open true)
-                     :on-mouse-up #(swap! local assoc :open false)}
+    [:div.user-zone {:on-mouse-enter #(swap! local assoc :open true)
+                     :on-mouse-leave #(swap! local assoc :open false)}
      [:span (:fullname profile)]
      [:img {:src photo}]
      (user-menu (:open @local))]))


make search field changes more robust; some renaming

--- cljs-cheatsheet/cljs_cheatsheet/core.cljs
+++ cljs-cheatsheet/cljs_cheatsheet/core.cljs
@@ -125,29 +125,24 @@
 ;; Events
 ;;------------------------------------------------------------------------------

-(defn- click-toggle-tooltips []
-  ;; TODO: write me
-  )
-
-(defn- on-resize []
+(defn- on-window-resize []
   (let [browser-width (.width ($ js/window))
         new-size (width->size browser-width)]
     (when-not (= @current-size new-size)
       (reset! current-size new-size))))

-(defn- keydown-search-input2 []
+(defn- change-search-input2 []
   (let [txt (-> ($ search-input-sel) .val .toLowerCase)]
     (when (not= txt @current-search-txt)
       (reset! current-search-txt txt))))

 ;; reset the stack so we can grab the value out of the text field
-(defn- keydown-search-input []
-  (js/setTimeout keydown-search-input2 1))
+(defn- change-search-input []
+  (js/setTimeout change-search-input2 1))

 (defn- add-events! []
-  ;; (.on ($ "#toggleTooltips") "click" click-toggle-tooltips)
-  (.on ($ search-input-sel) "keydown" keydown-search-input)
-  (aset js/window "onresize" on-resize))
+  (.on ($ search-input-sel) "blur change keydown" change-search-input)
+  (aset js/window "onresize" on-window-resize))

 ;;------------------------------------------------------------------------------
 ;; Global Cheatsheet Init
@@ -164,8 +159,8 @@
   (add-events!)

   ;; trigger resize and search
-  (on-resize)
-  (keydown-search-input2)
+  (on-window-resize)
+  (change-search-input2)

   ;; put the focus on the search field
   (when-let [search-input-el (by-id search-input-id)]


[#672] WIP Refactored CSV import using clojure data.csv

--- backend/src/akvo/lumen/import/csv.clj
+++ backend/src/akvo/lumen/import/csv.clj
@@ -4,49 +4,33 @@
             [clojure.data.csv :as csv]
             [clojure.java.io :as io]
             [clojure.java.jdbc :as jdbc]
-            [clojure.string :as s]
-            [hugsql.core :as hugsql])
+            [clojure.string :as s])
   (:import com.ibm.icu.text.CharsetDetector
            java.util.UUID
            org.postgresql.PGConnection
            org.postgresql.copy.CopyManager))

+
 (defn- get-cols
-  ([num-cols]
-   (get-cols num-cols nil))
-  ([num-cols c-type]
-   (s/join ", "
-           (for [i (range 1 (inc num-cols))]
-             (str "c" i
-                  (if-not (nil? c-type)
-                    (str " " c-type)
-                    ""))))))
+  "Returns a vector of column names and PostgreSQL data types"
+  [num-cols & [col-type]]
+  (let [col-type-str (if col-type (str " " col-type) "")]
+    (vec (map #(str "c" % col-type-str)
+              (range 1 (inc num-cols))))))

-
-(defn get-create-table-sql
-  "Returns a `CREATE TABLE` statement for
-  the given number table name and number of columns"
-  [t-name num-cols]
-  (format "CREATE TABLE %s (%s, %s)"
-          t-name
-          "rnum serial primary key"
-          (get-cols num-cols "text")))
-
-(defn get-copy-sql
-  "Returns a `COPY` statement for the given
-  table and number of columns"
-  [t-name num-cols headers? encoding]
-  (format "COPY %s (%s) FROM STDIN WITH (FORMAT CSV, ENCODING '%s'%s)"
-          t-name
-          (get-cols num-cols)
-          encoding
-          (if headers? ", HEADER true" "")))
+(defn- create-table! ;; TODO handle column types other than "text"
+  "Creates a table of the given name & number of columns"
+  [tenant-conn table-name num-cols]
+  (let [sql (format "CREATE TABLE %s (rnum serial primary key, %s)"
+                    table-name
+                    (s/join ", " (get-cols num-cols "text")))]
+    (jdbc/execute! tenant-conn [sql])))

 (defn get-headers
-  "Returns the first line CSV a file"
+  "Returns the first line of the given CSV file"
   [path separator encoding]
-  (with-open [r (io/reader path :encoding encoding)]
-    (first (csv/read-csv r :separator separator))))
+  (with-open [reader (io/reader path :encoding encoding)]
+    (first (csv/read-csv reader :separator separator))))

 (defn get-num-cols
   "Returns the number of columns based on the
@@ -56,25 +40,35 @@

 (defn get-encoding
   "Returns the character encoding reading some
-  bytes from the file. It uses ICU's CharsetDetector"
+  bytes from the given CSV file. Uses ICU's `CharsetDetector`"
   [path]
   (let [detector (CharsetDetector.)
         ;; 100kb
         ba (byte-array 100000)]
-    (with-open [is (io/input-stream path)]
-      (.read is ba))
+    (with-open [input-stream (io/input-stream path)]
+      (.read input-stream ba))
     (-> (.setText detector ba)
         (.detect)
         (.getName))))

-(defn get-column-tuples
+(defn get-column-tuples ;; TODO handle types other than "text"
   [col-titles]
   (vec
-   (map-indexed (fn [idx title]
-                  {:title title
-                   :column-name (str "c" (inc idx))
-                   :type "text"})
-                col-titles)))
+    (map-indexed (fn [idx title]
+                   {:title title
+                    :column-name (str "c" (inc idx))
+                    :type "text"})
+                 col-titles)))
+
+(defn insert-from-csv!
+  "Inserts data from the given CSV file into the given table name"
+  [tenant-conn table-name num-cols headers? path separator encoding]
+  (with-open [reader (io/reader path :encoding encoding)]
+    (let [headers (get-cols (get-num-cols path \, encoding))
+          data (csv/read-csv reader :separator separator)
+          rows (if headers? (rest data) data)]
+      (doseq [row rows]
+        (jdbc/insert! tenant-conn (keyword table-name) headers row)))))

 (defmethod import/valid? "CSV"
   [{:strs [url fileName hasColumnHeaders]}]
@@ -102,24 +96,19 @@
 (defmethod import/make-dataset-data-table "CSV"
   [tenant-conn {:keys [file-upload-path]} table-name spec]
   (try
-    (let [ ;; TODO a bit of "manual" integration work
-          path (get-path spec file-upload-path)
+    (let [path (get-path spec file-upload-path)
+          separator \,
           headers? (boolean (get spec "hasColumnHeaders"))
           encoding (get-encoding path)
-          n-cols (get-num-cols path \, encoding)
-          col-titles (if headers?
-                       (get-headers path \, encoding)
-                       (vec (for [i (range 1 (inc n-cols))]
-                              (str "Column " i))))
-          copy-sql (get-copy-sql table-name n-cols headers? encoding)]
-      (jdbc/execute! tenant-conn [(get-create-table-sql table-name n-cols)])
-      (with-open [conn (-> tenant-conn :datasource .getConnection)
-                  input-stream (-> (io/input-stream path)
-                                   import/unix-line-ending-input-stream)]
-        (let [copy-manager (.getCopyAPI (.unwrap conn PGConnection))]
-          (.copyIn copy-manager copy-sql input-stream)))
-      {:success? true
-       :columns (get-column-tuples col-titles)})
+          num-cols (get-num-cols path separator encoding)]
+      (create-table! tenant-conn table-name num-cols)
+      (insert-from-csv! tenant-conn table-name num-cols headers? path separator encoding)
+      (let [col-titles (if headers?
+                         (get-headers path separator encoding)
+                         (vec (map #(str "Column " %)
+                                   (range 1 (inc num-cols)))))]
+        {:success? true
+         :columns (get-column-tuples col-titles)}))
     (catch Exception e
       {:success? false
        :reason (str "Unexpected error: " (.getMessage e))})))


fix/update demo

fix/update demo

--- src/hatch.clj
+++ src/hatch.clj
@@ -97,18 +97,20 @@

   ;; Callers should def their own schema
   (def schematode-def
-    [[:person {:attrs [[:name :string :db.unique/identity]
-                       [:favorite-dessert :ref]]}]
-     [:dessert {:attrs [[:name :string :db.unique/identity]]
-                :part :desserts}]])
+    [{:namespace :person
+      :attrs [[:name :string :db.unique/identity]
+              [:favorite-dessert :ref]]}
+     {:namespace :dessert
+      :attrs [[:name :string :db.unique/identity]]
+      :part :desserts}])

   ;; Callers should def their own partition map
   (def partitions {:person :db.part/user
                    :dessert :db.part/desserts})

-  ;; Callers should def their own valid-attrs. Attributes not in this
+  ;; Callers should def their own attribute map. Attributes not in this
   ;; map will be pruned by tx-clean-entity!
-  (def valid-attrs {:person [:person/name :person/favorite-dessert]
+  (def attrs {:person [:person/name :person/favorite-dessert]
                     :dessert [:dessert/name]})

   ;; Alternatively, partition maps and valid-attrs can be generated
@@ -118,11 +120,11 @@

   (def partitions2 (hatch/schematode->partitions schematode-def))

-  (def valid-attrs2 (hatch/schematode->attrs schematode-def))
+  (def attrs2 (hatch/schematode->attrs schematode-def))

   ;; Callers should def their own tx-entity! fns kinda like this
-  (def tx-entity! (partial hatch/tx-clean-entity! partitions valid-attrs))
-  (def tx-entity2! (partial hatch/tx-clean-entity! partitions2 valid-attrs2))
+  (def tx-entity! (partial hatch/tx-clean-entity! partitions attrs))
+  (def tx-entity2! (partial hatch/tx-clean-entity! partitions2 attrs2))

   ;; Galleon will do this stuff
   (schematode/init-schematode-constraints! (:db-conn ht-config/system))


Remove try/catch Catching errors from async processes doesn't work; the code that throws runs outside of the context of the try/catch block.

--- cljs-lambda/src/cljs_lambda/util.cljs
+++ cljs-lambda/src/cljs_lambda/util.cljs
@@ -35,11 +35,7 @@
   (wrap-lambda-fn
    (fn [event context]
      (go
-       (let [result
-             (try
-               (<! (f event context))
-               (catch js/Error e
-                 e))]
+       (let [result (<! (f event context))]
          (if (instance? js/Error result)
            (fail!    context result)
            (succeed! context result)))))))


People cards should not be clickable when filtered out

--- frontend/src/faceboard/views/boards/people.cljs
+++ frontend/src/faceboard/views/boards/people.cljs
@@ -127,9 +127,10 @@
                             (anim-class shrinking-anim " shrinking")
                             (when extended? " extended")
                             (if filtered? " filtered" " expandable"))
-                :on-click (fn [e]
-                            (.stopPropagation e)
-                            (router/switch-person (if-not extended? id nil)))}
+                :on-click (when-not filtered?
+                            (fn [e]
+                              (.stopPropagation e)
+                              (router/switch-person (if-not extended? id nil))))}
         (dom/div {:class "person-extended-wrapper"}
           (om/build person-info-component {:hide?     (not extended?)
                                            :extended? extended?


throw exception when trying to transact empty entity

--- src/hatch.clj
+++ src/hatch.clj
@@ -73,10 +73,10 @@
 (defn tx-clean-entity!
   "Clean up an entity (ensure it has a db/id and prune it), then transact it."
   [partitions attr-map db-conn entity-type entity]
-  (->> entity
-       (clean-entity partitions attr-map entity-type)
-       (conj [])
-       (tx! db-conn)))
+  (let [cleaned-entity (clean-entity partitions attr-map entity-type entity)]
+    (if (empty? (dissoc cleaned-entity :db/id))
+      (throw (Exception. "cannot transact empty entity"))
+      (tx! db-conn [cleaned-entity]))))

 (comment


Shifting times even more to make the test less likely to fail.

--- int_test/cmr/metadata_db/int_test/concepts/search_test.clj
+++ int_test/cmr/metadata_db/int_test/concepts/search_test.clj
@@ -158,10 +158,10 @@
                                     prov uniq-num num-revisions
                                     {:delete-time (str expire-time)})))
         ;; Expired a long time ago.
-        coll1 (make-coll-expiring-in "PROV1" 1 1 -60000)
-        coll2 (make-coll-expiring-in "PROV1" 2 2 -60000)
+        coll1 (make-coll-expiring-in "PROV1" 1 1 -600000)
+        coll2 (make-coll-expiring-in "PROV1" 2 2 -600000)
         ;; Expires in the far future
-        coll3 (make-coll-expiring-in "PROV1" 3 1 5000)
+        coll3 (make-coll-expiring-in "PROV1" 3 1 500000)
         ;; Doesn't have an expiration date
         coll4 (util/create-and-save-collection "PROV1" 4 1)
         ;; Won't find because it's in another provider


Fix erroneous ns declaration.

Fix erroneous ns declaration.

--- test/kixi/hecuba/amon_test.clj
+++ test/kixi/hecuba/amon_test.clj
@@ -2,7 +2,7 @@
   (:use clojure.test)
   (:require
    [kixi.hecuba.dev :refer (create-ref-store ->CassandraDirectCommander ->CassandraQuerier sha1-keyfn)]
-   [kixi.hecuba.web.amon :as amon]
+   [kixi.hecuba.amon :as amon]
    [kixi.hecuba.hash :refer (sha1)]
    [kixi.hecuba.protocols :refer (item items)]
    [cheshire.core :refer (generate-string parse-string)]


Experiment having 2 form fields with same name

--- examples/phonebook/src/phonebook/html.clj
+++ examples/phonebook/src/phonebook/html.clj
@@ -42,6 +42,9 @@
       [:label "Phone"]
       [:input {:name "phone" :type :text}]]
      [:p
+      [:label "Phone2"]
+      [:input {:name "phone" :type :text}]]
+     [:p
       [:input {:type :submit :value "Add entry"}]]]]))

 (defn entry-html [{:keys [firstname surname phone]}


fix edb deploy project.clj

fix edb deploy project.clj

--- deploy/project.clj
+++ deploy/project.clj
@@ -5,27 +5,15 @@
   :dependencies [[org.clojure/clojure "1.2.0"]
                  [org.clojure/clojure-contrib "1.2.0"]

-                 [org.cloudhoist/pallet "0.5.0-SNAPSHOT"
-                  :exclusions [org.jclouds/jclouds-jsch
-                               org.jclouds/jclouds-log4j
-                               org.jclouds.driver/jclouds-jsch
-                               org.jclouds.driver/jclouds-log4j
-                               org.jclouds.driver/jclouds-enterprise
-                               org.jclouds/jclouds-blobstore
-                               org.jclouds/jclouds-bouncycastle
-                               org.jclouds.driver/jclouds-bouncycastle
-                               org.jclouds/jclouds-compute
-                               org.jclouds/jclouds-scriptbuilder
-                               ]]
-                 [org.cloudhoist/java "0.5.0-SNAPSHOT"]
-                 [org.cloudhoist/git "0.5.0-SNAPSHOT"]
-                 [org.cloudhoist/ssh-key "0.5.0-SNAPSHOT"]
-                 [org.cloudhoist/automated-admin-user "0.5.0-SNAPSHOT"]
+                 [org.cloudhoist/pallet "0.5.0"]
+                 [org.cloudhoist/java "0.5.0"]
+                 [org.cloudhoist/git "0.5.0"]
+                 [org.cloudhoist/ssh-key "0.5.0"]
+                 [org.cloudhoist/automated-admin-user "0.5.0"]

-                 [org.jclouds.provider/aws-ec2 "1.0-SNAPSHOT"]
-                 [org.jclouds.provider/aws-s3 "1.0-SNAPSHOT"]
+                 [org.jclouds.provider/aws-ec2 "1.0-beta-9c"]
+                 [org.jclouds.provider/aws-s3 "1.0-beta-9c"]

-                 [org.jclouds.driver/jclouds-jsch "1.0-SNAPSHOT"]
                  [com.jcraft/jsch "0.1.44-1"]

                  [org.antlr/stringtemplate "3.2"]]


remove core test file

remove core test file

--- test/scramblyzer/test/core.clj
+++ test/scramblyzer/test/core.clj
@@ -1,3 +0,0 @@
-(ns scramblyzer.test.core
-  (:use [scramblyzer.core])
-  (:use [clojure.test]))


fix: var should be of Unbound type

fix: var should be of Unbound type

--- db-serializers/src/com/sixsq/slipstream/db/serializers/utils.clj
+++ db-serializers/src/com/sixsq/slipstream/db/serializers/utils.clj
@@ -206,7 +206,7 @@
   "STRONGLY DEPRECATED. Used to set the database CRUD implementation from Java
    code if needed. This must never be called from native clojure code."
   []
-  (if (instance? clojure.lang.Var db/*impl*)
+  (if (instance? clojure.lang.Var$Unbound db/*impl*)
     (set-db-crud-impl-uncond)))

 ;; Connection to a remote ES.
@@ -243,7 +243,7 @@
   "STRONGLY DEPRECATED. Used to set up a test Elasticsearch client from Java
    code if needed. This must never be called from native clojure code."
   []
-  (if (instance? clojure.lang.Var esb/*client*)
+  (if (instance? clojure.lang.Var$Unbound esb/*client*)
     (create-test-es-db-uncond)))

 (defn ^{:deprecated "3.34"} test-db-client-and-crud-impl


move conversion of iOS timestamp into import, rather than doing it in app

--- iwaswhere-web/src/clj/iwaswhere_web/imports.clj
+++ iwaswhere-web/src/clj/iwaswhere_web/imports.clj
@@ -137,6 +137,8 @@
                  (put-fn (with-meta [:entry/import file-info] msg-meta))))
              (catch Exception ex (log/error (str "Error while importing " filename) ex)))))))

+(defn double-ts-to-long [ts] (long (* ts 1000)))
+
 (defn import-geo
   "Imports geo data from respective directory.
   For now, only pays attention to visits."
@@ -149,8 +151,8 @@
         (try (let [lines (line-seq (clojure.java.io/reader file))]
                (doseq [line lines]
                  (let [raw-visit (cc/parse-string line #(keyword (s/replace % "_" "-")))
-                       arrival-ts (:arrival-timestamp raw-visit)
-                       departure-ts (:departure-timestamp raw-visit)
+                       arrival-ts (double-ts-to-long (:arrival-timestamp raw-visit))
+                       departure-ts (double-ts-to-long (:departure-timestamp raw-visit))
                        dur (-> (- departure-ts arrival-ts)
                                (/ 6000)
                                (Math/floor)
@@ -173,8 +175,10 @@
         (log/info "Trying to import " filename)
         (try (let [lines (line-seq (clojure.java.io/reader file))]
                (doseq [line lines]
-                 (let [entry (m/add-tags-mentions (cc/parse-string line #(keyword (s/replace % "_" "-"))))
-                       entry (update-in entry [:tags] conj "#import")]
+                 (let [entry (-> (cc/parse-string line #(keyword (s/replace % "_" "-")))
+                                 (m/add-tags-mentions)
+                                 (update-in [:tags] conj "#import")
+                                 (update-in [:timestamp] double-ts-to-long))]
                    (put-fn (with-meta [:entry/import entry] msg-meta)))))
              (catch Exception ex (log/error (str "Error while importing " filename) ex)))))))


PLD: bump large photo size to 1k pix

PLD: bump large photo size to 1k pix

--- src/hatti/views/photos.cljs
+++ src/hatti/views/photos.cljs
@@ -14,7 +14,7 @@

 (def data-pswp-id "data-pswp-id")
 (def pswp-gallery-class "pswp")
-(def width-px 800)
+(def width-px 1024)
 (def thumb-width-px 180)
 (def thumb-width-px-str (str thumb-width-px "px"))
 (def num-columns 3)


Tiny color tweak for conflicted cues.

Tiny color tweak for conflicted cues.

--- src/afterglow/web/routes/show_control.clj
+++ src/afterglow/web/routes/show_control.clj
@@ -33,7 +33,7 @@
              (if ending
                (if (> (rhythm/metro-beat-phase (:metronome show)) 0.4) 20.0 40.0)
                65.0)
-             (if (active-keys (:key cue)) 20.0 40.0))
+             (if (active-keys (:key cue)) 25.0 40.0))
            l-boost))))

 (defn cue-view


Tweak styling of avatar-upload view

Tweak styling of avatar-upload view

--- src/braid/core/client/ui/styles/misc.cljs
+++ src/braid/core/client/ui/styles/misc.cljs
@@ -61,8 +61,8 @@
   [:&

    [:&.dragging
-    {:background-color "gray"
-     :border [[(px 5) "dashed" "black"]]}]
+    {:background-color "lightgray"
+     :border [[(px 5) "dashed" "darkgray"]]}]

    [:>.uploading-indicator
     (mixins/fontawesome \uf110)


refine transaction item queries

refine transaction item queries

reduce usage of select-transaction-items (go through search-items)
remove unused fns

--- src/clj/clj_money/models/transactions.clj
+++ src/clj/clj_money/models/transactions.clj
@@ -106,16 +106,15 @@
 (defn- after-item-read
   "Makes adjustments to a transaction item in prepartion for return
   from the data store"
-  ([item] (after-item-read item nil))
-  ([{:keys [quantity negative reconciliation-status] :as item} account]
-   (if (map? item)
-     (-> item
-         (update-in [:action] keyword)
-         (assoc :reconciled? (= "completed" reconciliation-status)
-                :polarized-quantity (if negative
-                                      (* -1 quantity)
-                                      quantity)))
-     item)))
+  [{:keys [quantity negative reconciliation-status] :as item}]
+  (if (map? item)
+    (-> item
+        (update-in [:action] keyword)
+        (assoc :reconciled? (= "completed" reconciliation-status)
+               :polarized-quantity (if negative
+                                     (* -1 quantity)
+                                     quantity)))
+    item))

 (defn- item-value-sum
   "Returns the sum of values of the items in the transaction having
@@ -221,17 +220,75 @@
   [storage transaction-id]
   (select-lots-transactions-by-transaction-id storage transaction-id))

+; TODO move this to a util namespace
+(defmulti ^:private parse-date-range
+  type)
+
+(defmethod ^:private parse-date-range :default
+  [value]
+  value)
+
+(defmethod ^:private parse-date-range String
+  [value]
+  (let [[year month day] (->> (re-matches #"(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?"
+                                          value)
+                              rest
+                              (map #(when % (Integer. %))))]
+    (cond
+
+      day
+      (t/local-date year month day)
+
+      month
+      [:between
+       (t/first-day-of-the-month year month)
+       (t/last-day-of-the-month year month)]
+
+      :else
+      [:between
+       (t/local-date year 1 1)
+       (t/local-date year 12 31)])))
+
+; TODO Replace these with coercion rules?
+(defn- ensure-id-type
+  [criteria]
+  (if-let [id (:id criteria)]
+    (if (string? id)
+      (assoc criteria :id (java.util.UUID/fromString id))
+      criteria)
+    criteria))
+
+(defn- ensure-transaction-date-type
+  [criteria]
+  (if-let [transaction-date (:transaction-date criteria)]
+    (assoc criteria :transaction-date (parse-date-range transaction-date))
+    criteria))
+
+(defn- prepare-criteria
+  [criteria]
+  (-> criteria
+      ensure-transaction-date-type
+      ensure-id-type))
+
+(defn search-items
+  "Returns transaction items matching the specified criteria"
+  ([storage-spec criteria]
+   (search-items storage-spec criteria {}))
+  ([storage-spec criteria options]
+   (with-storage [s storage-spec]
+     (map after-item-read
+          (select-transaction-items s
+                                    (prepare-criteria criteria)
+                                    options)))))
+
 (defn- append-items
   [{:keys [id transaction-date] :as transaction} storage]
   (when transaction
     (assoc transaction
            :items
-           (mapv after-item-read
-                 (select-transaction-items
-                   storage
-                   {:transaction-id id
-                    :transaction-date transaction-date}
-                   {:sort [[:action :desc] [:quantity :desc]]})))))
+           (vec (search-items storage {:transaction-id id
+                                       :transaction-date transaction-date}
+                              {:sort [[:action :desc] [:quantity :desc]]})))))

 (defn- append-lot-items
   [transaction storage]
@@ -263,28 +320,18 @@
        true
        (authorization/tag-resource :transaction)))))

-(defn- get-previous-item
-  "Finds the transaction item that immediately precedes the specified item,
-  or a fake 'before first' item if there are no preceding items"
-  [storage {:keys [account-id transaction-date transaction-id] :as item}]
-  (or (->> (select-transaction-items storage
-                                     {:account-id account-id
-                                      :transaction-id [:<> transaction-id]
-                                      :transaction-date [:<= transaction-date]}
-                                     {:sort [[:transaction-date :desc] [:index :desc]]
-                                      :limit 1})
-           first)
-      {:account-id account-id
-       :transaction-date transaction-date
-       :index -1
-       :balance 0M}))
+(defn find-item
+  "Returns the first item matching the specified criteria"
+  ([storage-spec criteria]
+   (find-item storage-spec criteria {}))
+  ([storage-spec criteria options]
+   (first (search-items storage-spec criteria (merge options {:limit 1})))))

 (defn find-item-by-id
   [storage-spec id transaction-date]
-  (first (select-transaction-items storage-spec
-                                   {:id id
-                                    :transaction-date transaction-date}
-                                   {:limit 1})))
+  (find-item storage-spec
+             {:id id
+              :transaction-date transaction-date}))

 ; This is public to support the unit test
 (defn upsert-item
@@ -348,54 +395,6 @@
 (s/def ::per-page validation/positive-integer?)
 (s/def ::select-options (s/keys :req-un [::page ::per-page]))

-(defmulti ^:private parse-date-range
-  type)
-
-(defmethod ^:private parse-date-range :default
-  [value]
-  value)
-
-(defmethod ^:private parse-date-range String
-  [value]
-  (let [[year month day] (->> (re-matches #"(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?"
-                                          value)
-                              rest
-                              (map #(when % (Integer. %))))]
-    (cond
-
-      day
-      (t/local-date year month day)
-
-      month
-      [:between
-       (t/first-day-of-the-month year month)
-       (t/last-day-of-the-month year month)]
-
-      :else
-      [:between
-       (t/local-date year 1 1)
-       (t/local-date year 12 31)])))
-
-(defn- ensure-transaction-date-type
-  [criteria]
-  (if-let [transaction-date (:transaction-date criteria)]
-    (assoc criteria :transaction-date (parse-date-range transaction-date))
-    criteria))
-
-(defn- ensure-id-type
-  [criteria]
-  (if-let [id (:id criteria)]
-    (if (string? id)
-      (assoc criteria :id (java.util.UUID/fromString id))
-      criteria)
-    criteria))
-
-(defn- prepare-criteria
-  [criteria]
-  (-> criteria
-      ensure-transaction-date-type
-      ensure-id-type))
-
 (defn search
   "Returns the transactions that belong to the specified entity"
   ([storage-spec criteria]
@@ -449,24 +448,6 @@
        before-save-item
        (create-transaction-item storage)
        after-item-read))
-
-(defn search-items
-  "Returns transaction items matching the specified criteria"
-  ([storage-spec criteria]
-   (search-items storage-spec criteria {}))
-  ([storage-spec criteria options]
-   (with-storage [s storage-spec]
-     (map after-item-read
-          (select-transaction-items s
-                                    (prepare-criteria criteria)
-                                    options)))))
-
-(defn find-item
-  "Returns the first item matching the specified criteria"
-  ([storage-spec criteria]
-   (find-item storage-spec criteria {}))
-  ([storage-spec criteria options]
-   (first (search-items storage-spec criteria options))))

 (defn- earlier
   [d1 d2]
@@ -620,37 +601,22 @@
   ([storage-spec account-id date-spec]
    (items-by-account storage-spec account-id date-spec {}))
   ([storage-spec account-id date-spec options]
-   (with-storage [s storage-spec]
-     (let [account (accounts/find-by-id storage-spec account-id)]
-       (map #(after-item-read % account)
-            (select-transaction-items s
-                                      {:account-id account-id
-                                       :transaction-date (if (coll? date-spec)
-                                                             [:between
-                                                              (first date-spec)
-                                                              (second date-spec)]
-                                                             date-spec)}
-                                      (merge options
-                                             {:sort [[:transaction-date :desc]
-                                                     [:index :desc]]})))))))
-
-(defn count-items-by-account
-  "Returns the number of transaction items in the account"
-  [storage-spec account-id]
-  (with-storage [s storage-spec]
-    (select-transaction-items
-      s
-      {:account-id account-id}
-      {:count true})))
+   (search-items storage-spec
+                 {:account-id account-id
+                  :transaction-date (if (coll? date-spec)
+                                      [:between
+                                       (first date-spec)
+                                       (second date-spec)]
+                                      date-spec)}
+                 (merge options
+                        {:sort [[:transaction-date :desc]
+                                [:index :desc]]}))))

 (defn unreconciled-items-by-account
   "Returns the unreconciled transaction items for the specified account"
   [storage-spec account-id]
-  (with-storage [s storage-spec]
-    (let [account (accounts/find-by-id storage-spec account-id)]
-      (map #(after-item-read % account)
-           (select-transaction-items s {:account-id account-id
-                                        :reconciliation-id nil})))))
+  (search storage-spec {:account-id account-id
+                        :reconciliation-id nil}))

 (defn reload
   "Returns an updated copy of the transaction"
@@ -763,23 +729,17 @@

 (defn- find-last-item-before
   [storage-spec account-id date]
-  (with-storage [s storage-spec]
-    (->> (select-transaction-items
-           s
-           {:account-id account-id
-            :transaction-date [:< date]}
-           {:sort [[:t.transaction-date :desc] [:i.index :desc]]
-            :limit 1})
-         first)))
+  (find-item storage-spec
+             {:account-id account-id
+              :transaction-date [:< date]}
+             {:sort [[:t.transaction-date :desc] [:i.index :desc]]}))

 (defn- find-last-item-on-or-before
   [storage-spec account-id date]
-  (with-storage [s storage-spec]
-    (first (select-transaction-items s
-                                     {:account-id account-id
-                                      :transaction-date [:<= date]}
-                                     {:sort [[:i.transaction-date :desc] [:i.index :desc]]
-                                      :limit 1}))))
+  (find-item storage-spec
+             {:account-id account-id
+              :transaction-date [:<= date]}
+             {:sort [[:i.transaction-date :desc] [:i.index :desc]]}))

 (defn balance-delta
   "Returns the change in balance during the specified period for the specified account"


Refactor palette.cljs

Refactor palette.cljs

--- src/cljs/koeeoadi/components/palette.cljs
+++ src/cljs/koeeoadi/components/palette.cljs
@@ -14,13 +14,28 @@
 (declare Palette)
 (declare PaletteWidget)

-(defn color-update [comp props]
+(defn color-update [comp active-color closure-comp]
   (om/transact! comp
-    `[(color/update ~props) :palette]))
+    `[(color/update {:color/id ~(:color/id active-color)
+                     :color/hex ~(.getColor closure-comp)}) :palette]))

 (defn color-remove [comp {:keys [color/id] :as color}]
   (om/transact! comp
     `[(color/remove) :palette]))
+
+(defn palette-widget-update [color-id faces-list]
+  (om/transact! (om/class->any reconciler Palette)
+    `[(palette-widget/update
+        {:palette-widget/active-color [:colors/by-id ~color-id]
+         :palette-widget/face-classes-by-color-type ~(util/faces-to-colorize faces-list color-id)})]))
+
+(defn face-class-prefix [color-type]
+  (if (= :face/color-fg color-type)
+    ".color-fg-"
+    ".color-bg-"))
+
+(defn face-to-selectors [face color-type]
+  (vector (str ".code-" %) (str (face-class-prefix color-type) %)))

 (defn colorize-faces [classes color-prop hex-temp]
   (when-not (empty? classes)
@@ -28,18 +43,21 @@
       (forEach elements #(setStyle % color-prop hex-temp)))))

 (defn selectors-for-colorize [faces color-type]
-  (let [face-color-type-class-prefix (if (= :face/color-fg color-type) ".color-fg-" ".color-bg-")
-        code-class-prefix            ".code-"
-        face-classes-groups          (->> faces
-                                       (map #(vector
-                                               (str code-class-prefix %)
-                                               (str face-color-type-class-prefix %))))]
-    (if (= 1 (count face-classes-groups))
-      (first face-classes-groups)
+  (let [selectors (map #(face-to-selectors % color-type) faces)]
+    (if (= 1 (count faces))
+      (first selectors)
       (reduce #(vector
                  (str (first %1) "," (first %2))
                  (str (last %1) "," (last %2)))
-        face-classes-groups ))))
+        selectors))))
+
+(defn color-class [props]
+  (let [{:keys [:color/id :color/hex :palette-widget/active-color]} props
+        active? (= id (:color/id active-color))]
+    (str "color color-editable"
+      (when active? " color-active")
+      (when-not hex " color-missing")
+      " color-" id)))

 (defui Color
   static om/Ident
@@ -55,17 +73,10 @@

   Object
   (render [this]
-    (let [{:keys [color/id
-                  color/hex
-                  faces/list
-                  palette-widget/active-color] :as color} (om/props this)
-          {:keys [hex-temp]} (om/get-state this)
-          active? (= id (:color/id active-color))]
-      (dom/div #js {:className (str "color color-editable" (when active? " color-active") (when-not hex " color-missing") " color-" id)
-                    :onClick   #(om/transact! (om/class->any reconciler Palette)
-                                  `[(palette-widget/update
-                                      {:palette-widget/active-color [:colors/by-id ~id]
-                                       :palette-widget/face-classes-by-color-type ~(util/faces-to-colorize list id)})])
+    (let [{:keys [color/id color/hex faces/list] :as color} (om/props this)
+          {:keys [hex-temp]} (om/get-state this)]
+      (dom/div #js {:className (color-class color)
+                    :onClick   #(palette-widget-update id list)
                     :style     (when (or hex-temp hex) #js {:backgroundColor (or hex-temp hex)})}
         (dom/button #js {:className "color-remove"
                          :onClick   #(color-remove this color)}
@@ -135,10 +146,10 @@
         (.setColor closure-comp (:color/hex active-color)))))

   (render [this]
-    (let [{:keys [palette-widget/closure-comp palette-widget/active-color] :as props} (om/props this)]
-      (dom/div #js {:onMouseUp #(color-update this {:color/id (:color/id active-color)
-                                                    :color/hex (.getColor closure-comp)})
-                    ;;:onTouchEnd #(color-update this (.getColor closure-comp))
+    (let [{:keys [palette-widget/closure-comp
+                  palette-widget/active-color] :as props} (om/props this)]
+      (dom/div #js {:onMouseUp #(color-update this active-color closure-comp)
+                    ;;:onTouchEnd #(color-update this active-color closure-comp)
                     :ref "paletteWidget"} nil))))

 (def palette-widget (om/factory PaletteWidget))


select-filter now working (with a little hackery)

--- src/main/clojure/org/dada/demo/whales.clj
+++ src/main/clojure/org/dada/demo/whales.clj
@@ -286,9 +286,6 @@
 ;; collect all aggregators together for length and weight
 ;; pivot them into a single Model

-(defn select-filter [model filter-fn view]
-  (connect model (make-filter filter-fn view)))
-
 (defn clone-model [model name key version]
  (let [metadata (.getMetadata model)
        names (. metadata getAttributeNames)
@@ -300,14 +297,18 @@
    (println key-getter version-getter)
    (VersionedModelView. name metadata key-getter version-getter)))

- (let [tgt-model (clone-model whales (str (.getName whales) ".Type=blue_whale") "time" "version")]
-   (insert
-    *metamodel*
-    (select-filter
-     whales
-     #(= "blue whale" (.getType %))
-     tgt-model)
-   ))
+(defn select-filter
+  "apply a filter view to a model"
+  ([model filter-fn view]
+   (connect model (make-filter filter-fn view))
+   view)
+  ([model filter-fn]
+   (let [view-name (str (.getName model) "." (.toString filter-fn))
+	 view (clone-model model view-name "time" "version")] ;; TODO - pull time/verion from metadata
+     (select-filter model filter-fn view))))
+
+
+(insert *metamodel* (select-filter whales #(= "blue whale" (.getType %))))

 ;; filter out blues...


Make the ~/.pallet directory, so installing the config works

--- src/circle/backend/nodes/circle.clj
+++ src/circle/backend/nodes/circle.clj
@@ -86,6 +86,11 @@
                                                  :owner "circle"
                                                  :group "circle"
                                                  :mode "644")
+                        (directory/directory "/home/circle/.pallet/"
+                                             :create :action
+                                             :path true
+                                             :owner "circle"
+                                             :group "circle")
                         (remote-file/remote-file "/home/circle/.pallet/config.clj" :local-file "src/circle/pallet_config.clj" :no-versioning true))}))

 (defn start


working on grid macros

working on grid macros

--- src/clj/manager_web/core_macros.clj
+++ src/clj/manager_web/core_macros.clj
@@ -1,14 +1,15 @@
-(ns manager-web.core-macros)
+(ns manager-web.core-macros
+  (:require [om-bootstrap.grid :as grid]))

 ;;
 ;; use it like this:
 ;;
-;; (make-col [12 6 4]
-;;           (println 11)
-;;           (println 22))
+;; (bscol {:xs 12 :md 6 :lg 4}
+;;        (println 11)
+;;        (println 22))
 ;;
-(defmacro make-col
-  [[xs md lg] & body]
+(defmacro bscol
+  [{:keys [xs md lg]} & body]
   `(grid/col {:xs ~xs :md ~md :lg ~lg}
              ~@body))

@@ -22,6 +23,11 @@
 ;;            (println 21)
 ;;            (println 22)))
 ;;
+(defmacro bsrow
+  [& body]
+  `(grid/row {}
+             ~@body))
+
 (defmacro make-row
   [& cols]
   `(grid/row {}
@@ -32,6 +38,15 @@
                                    ~@col-body)))
                     cols)))

+;;
+;; use it like this:
+;;
+;; (bsgrid
+;;   (bsrow
+;;     (bscol {:xs 12 :md 6 :lg 4}
+;;            (println 11)
+;;            (println 22))))
+;;
 (defmacro make-grid
   [& rows]
   (map (fn [& cols]


bring defreduceraggregator inline with defcombineraggregator and defaggregator

--- src/clj/marceline/storm/trident.clj
+++ src/clj/marceline/storm/trident.clj
@@ -177,11 +177,13 @@
     `(reify storm.trident.operation.ReducerAggregator
        ~@fns)))

-(defmacro defreduceraggregator [name & [opts impl :as all]]
+(defmacro defreduceraggregator [name & [opts & [init-impl reduce-impl] :as all]]
   (if-not (map? opts)
     `(defreduceraggregator ~name {} ~@all)
     (let [params (:params opts)
           fn-name (symbol (str name "__"))
+          [init-args & init-body] init-impl
+          [reduce-args & reduce-body] reduce-impl
           definer (if params
                     `(defn ~name [& args#]
                        (clojure-reducer-aggregator ~fn-name args#))
@@ -189,7 +191,9 @@
                        (clojure-reducer-aggregator ~fn-name [])))]
       `(do
          (defn ~fn-name ~(if params params [])
-           ~impl)
+           (reducer-aggregator
+             (~'init ~(vec init-args) ~@init-body)
+             (~'reduce ~(vec reduce-args) ~@reduce-body)))
          ~definer))))

 ;; ## queryfn


handlers for incomming message

handlers for incomming message

--- src/cljs/catsocket_client/core.cljs
+++ src/cljs/catsocket_client/core.cljs
@@ -53,6 +53,7 @@
                     :connected? false
                     :identified? false
                     :queue []
+                    :handlers {}
                     :sent-messages {}})]
      (set! (.-onopen socket) #(on-open cat %))
      (set! (.-onmessage socket) #(on-message cat (.parse js/JSON (.-data %))))
@@ -95,9 +96,16 @@

               (log "ACK received: " data)
               (swap! cat update-in [:sent-messages] dissoc id)))
+    "message" (do
+                (let [room (.-room (.-data data))
+                      f (get-in @cat [:handlers room])]
+                  (if (re-find #"^function" (str (type f)))
+                    (f (.-message (.-data data)))
+                    (log "Handler is not a function" f))))
     (log "unrecognized message" data)))

-(defn join [cat room]
+(defn join [cat room f]
+  (swap! cat update-in [:handlers] assoc room f)
   (send cat "join" {:room room}))

 (defn leave [cat room]
@@ -110,7 +118,9 @@

 (defn main []
   (let [cat (init "foo-key")]
-    (join cat "test")
+    (log cat)
+    (join cat "test" #(log %))
+    (log "handlers:" (get-in @cat [:handlers]))
     (broadcast cat "test" "hello!"))


Display new job-config parameter.

Display new job-config parameter.

--- src/cljs/onyx_cheat_sheet/core.cljs
+++ src/cljs/onyx_cheat_sheet/core.cljs
@@ -19,12 +19,13 @@
 (:import goog.History))

 (def model-order
-  [:job :catalog-entry :flow-conditions-entry :lifecycle-entry :lifecycle-calls :task-states
-   :window-entry :state-aggregation :trigger-entry :state-event :event-map
+  [:job :catalog-entry :flow-conditions-entry :lifecycle-entry :lifecycle-calls :task-states
+   :job-config :window-entry :state-aggregation :trigger-entry :state-event :event-map
    :peer-config :env-config])

 (def model-names {:job "Job"
+                  :job-config "Job Configuration"
                   :catalog-entry "Catalogs"
                   :flow-conditions-entry "Flow Conditions"
                   :lifecycle-entry "Lifecycles"


Fix view update

Fix view update

--- src/cljs/onyx_cheat_sheet/core.cljs
+++ src/cljs/onyx_cheat_sheet/core.cljs
@@ -260,7 +260,7 @@
   "Grab the input element via the `input` reference."
   [owner data]
   (let [node (om/get-node owner "input")]
-    (om/update! data :view (keys model) (.-value node))
+    (om/update! data :view (keys model))
     (om/update! data :search (.-value node))))

 (defcomponent example-input [data owner]


Use %derive-key for derive-key

Use %derive-key for derive-key

--- src/clojure_fabric/crypto_suite.clj
+++ src/clojure_fabric/crypto_suite.clj
@@ -30,10 +30,11 @@
 ;; (generate-key :ECDSA :secp256r1)

-(defprotocol IKey
+(defprotocol IBCECKey
   (algorithm [this])
   (curve-spec [this])
-  (curve-params [this]))
+  (curve-params [this])
+  (%derive-key [this]))

 (defn- %curve-params [params]
   ;; (.multiply g (biginteger 100000000000000000000))
@@ -42,18 +43,22 @@
           ((juxt #(.getCurve ^ECParameterSpec %) #(.getG ^ECParameterSpec %) #(.getH ^ECParameterSpec %)
                  #(.getN ^ECParameterSpec %))
            params)))
-
+;;;
+;;; To avoid reflection at run time, duplicate code :(
+;;;
 (extend-type BCECPrivateKey
-  IKey
+  IBCECKey
   (algorithm [this] (-> this .getAlgorithm keyword))
   (curve-spec [this] (keyword (.getName ^ECNamedCurveSpec (.getParams this))))
-  (curve-params [this] (-> this .getParameters %curve-params)))
+  (curve-params [this] (-> this .getParameters %curve-params))
+  (%derive-key [this opts]))

 (extend-type BCECPublicKey
-  IKey
+  IBCECKey
   (algorithm [this] (-> this .getAlgorithm keyword))
   (curve-spec [this] (keyword (.getName ^ECNamedCurveSpec (.getParams this))))
-  (curve-params [this] (-> this .getParameters %curve-params)))
+  (curve-params [this] (-> this .getParameters %curve-params))
+  (%derive-key [this opts]))

 ;;; http://www.bouncycastle.org/wiki/display/JA1/Elliptic+Curve+Key+Pair+Generation+and+Key+Factories
 ;;;deriveKey
@@ -64,20 +69,12 @@
         opts (Object)
   Returns
         (Key) derived key"
-  [k {:keys [ephemeral] :as opt}]
+  [k opts]
   ;; From JS SDK doc
   ;; Derives the new private key from the source public key using the parameters passed in the opts.
   ;; This operation is needed for deriving private keys corresponding to the Transaction
   ;; Certificates.
-
-  ;; From Go SDK
-  ;;
-  ;;1.
-  )
-
-
-
-
+  (%derive-key k opts))

 ;;; importKey
 (defn import-key


Fixed comm watchdog timeout.

Fixed comm watchdog timeout.

--- src/com/lemondronor/turboshrimp.clj
+++ src/com/lemondronor/turboshrimp.clj
@@ -97,10 +97,17 @@

 (defn raise-event [drone event-type & args]
+  (log/debug "Event" event-type args)
   (when-let [handler (:event-handler drone)]
     (apply handler event-type args)))

+(defn communication-check [drone navdata]
+  (when (= :problem (-> navdata :state :com-watchdog))
+    (log/info "Watchdog Reset")
+    (command drone :reset-watchdog)))
+
 (defn process-navdata [drone navdata]
+  (communication-check drone navdata)
   (raise-event drone :navdata navdata))

 (defn- navdata-thread-fn [drone]
@@ -109,16 +116,20 @@
         ^DatagramPacket packet (navdata/new-datagram-packet
                                 (byte-array 2048) (:host drone) navdata-port)]
     (loop []
-      (when @(:keep-streaming-navdata drone)
-        (try
-          (do
-            (navdata/receive-navdata socket packet)
-            (log/debug packet)
-            (process-navdata drone (navdata/parse-navdata (.getData packet))))
-          (catch IOException e
-            (reset! (:keep-streaming-navdata drone) false)
-            (raise-event drone :error e)))
-        (recur)))))
+      (if @(:keep-streaming-navdata drone)
+        (do
+          (try
+            (do
+              (navdata/receive-navdata socket packet)
+              (log/debug packet)
+              (process-navdata drone (navdata/parse-navdata (.getData packet))))
+            (catch IOException e
+              (log/error e "Whoa")
+              (reset! (:keep-streaming-navdata drone) false)
+              (raise-event drone :error e)))
+          (recur))
+        (do
+          (log/info "Disconnecting thread for" drone))))))

 (defn- start-navdata! [drone]
   (reset! (:keep-streaming-navdata drone) true)
@@ -146,7 +157,3 @@
 (defn get-nav-data [drone]
   (:nav-data drone))

-(defn communication-check [drone]
-  (when (= :problem (:com-watchdog @(get-nav-data drone)))
-    (log/info "Watchdog Reset")
-    (command drone :reset-watchdog)))


Ready for release

Ready for release

--- lein-template/project.clj
+++ lein-template/project.clj
@@ -1,7 +1,7 @@
 ;; Copyright © 2014 JUXT LTD.

 ;; We call this project modular to make the invocation: lein new modular appname
-(defproject modular/lein-template "0.6.3"
+(defproject modular/lein-template "0.6.4"
   :description "Leiningen template for a full-featured component based app using modular extensions."
   :license {:name "The MIT License"
             :url "http://opensource.org/licenses/MIT"}


(TK-9) Reword usage message

(TK-9) Reword usage message

Reword usage message to refer users to the documentation for a
list of file types supported by TK for configuration files.

--- src/puppetlabs/trapperkeeper/internal.clj
+++ src/puppetlabs/trapperkeeper/internal.clj
@@ -117,8 +117,8 @@
   (let [specs       [["-d" "--debug" "Turns on debug mode"]
                      ["-b" "--bootstrap-config BOOTSTRAP-CONFIG-FILE" "Path to bootstrap config file"]
                      ["-c" "--config CONFIG-PATH"
-                      (str "Path to .ini file or directory of .ini files to be read and consumed by services."
-                           ".conf, .json, .properties, and .edn files are also supported.")]
+                      (str "Path to a configuration file or directory of configuration files. "
+                           "See the documentation for a list of supported file types.")]
                      ["-p" "--plugins PLUGINS-DIRECTORY" "Path to directory plugin .jars"]]
         required    []]
     (first (cli! cli-args specs required))))


update team for haml

update team for haml

--- frontend/components/about.cljs
+++ frontend/components/about.cljs
@@ -98,15 +98,6 @@
     :github "esnyder"
     :twitter "emilesnyder"
     :email "emile@circleci.com"}
-   {:name "Dave Jarvis"
-    :img-path (stefon/asset-path "/img/outer/about/dave.png")
-    :visible true
-    :role "Developer"
-    :github "venantius"
-    :twitter "venantius"
-    :email "dave@circleci.com"
-    :bio ["Dave's worst nightmare is to be boring. His childhood was split between New York City, Tokyo, and Bristol (U.K.), and he's never really felt at home anywhere since. In his spare time he plays an unreasonable amount of pool at the diviest bars he can find, and gardens aggressively in the hours before they open. One of the lucky few to live somewhere in San Francisco with a decent back yard, he's also a (discreet) amateur archer. In his prior life as a theater nerd, he designed theater sets (a production of Richard III being his favorite) and acted in independent theater productions in Chicago. Along with a few friends, he founded, edited and wrote a blog consisting of critical essays on video games, right up until the day he forgot to renew the domain name. Womp-womp.",
-          "CircleCI is his first job as a software developer, though his prior job involved hacking together the tools and libraries needed to help analyze petabyte-scale datasets as a data scientist. Before that, he worked as an honest-to-god economist for a small consulting outfit in Chicago, where he conducted economic impact analysis work for such clients as Argonne National Laboratory and the U.S. Department of Energy. He's now in the midst of launching a small hedge fund...because there actually *are* enough hours in the day. He joins Circle with the daydream of getting the time between each push and the next commit just that tiny bit shorter."]}
    {:name "Tim Dixon"
     :img-path (stefon/asset-path "/img/outer/about/tim.png")
     :visible true
@@ -119,13 +110,11 @@
     :github "iand675"
     :twitter "iand675"
     :email "ian@circleci.com"}
-   {:name "Joshua Ballanco"
-    :img-path (stefon/asset-path "/img/outer/about/josh.png")
-    :visible true
-    :role "Developer"
-    :github "jballanc"
-    :twitter "manhattanmetric"
-    :email "jballanc@circleci.com"}])
+   {:name "Kevin Bell"
+    :visible true
+    :role "Developer Advocate"
+    :github "bellkev"
+    :email "kevin@circleci.com"}])

 (def placeholder-image [:svg.about-placeholder {:height "150px" :width "150px" :viewBox "0 0 150 150"}
                         [:path.bust {:d "M-1.673,151.75v-13.856c0,0,0.901-8.505,11.143-11.142c0,0,16.495-6.022,29.415-11.646 c6.681-2.907,8.119-4.652,14.859-7.631c0,0,0.703-3.461,0.45-5.521h5.271c0,0,1.204,0.702,0-7.43c0,0-6.425-1.705-6.725-14.655 c0,0-4.825,1.625-5.121-6.224c-0.202-5.321-4.318-9.939,1.607-13.753l-3.012-8.131c0,0-6.023-32.826,11.294-28.008 c-7.305-8.734,41.409-17.465,44.574,10.24c0,0,2.256,14.958,0,25.197c0,0,7.113-0.824,2.357,12.852c0,0-2.609,9.836-6.627,7.628 c0,0,0.656,12.447-5.668,14.559c0,0,0.449,6.625,0.449,7.075l6.025,0.903c0,0-0.906,5.424,0.152,6.022c0,0,7.142,4.894,15.657,7.081 c16.414,4.212,35.837,11.44,35.837,17.766c0,0,1.659,8.435,1.659,18.673H-1.673z",


j' => je

j' => je

--- src/babel/francais/morphology.cljc
+++ src/babel/francais/morphology.cljc
@@ -529,7 +529,7 @@
 (def replace-patterns
   [
    ;; pronouns: e.g.: "t'" => "te"
-   [#"^([lmst])" "$1e" :top]
+   [#"^([jlmst])" "$1e" :top]
    [#"^(l)" "$1a" :top]

    ;; <reflexive past>: e.g. "amusé" => "s'amuser"


fix lowercasing damage: e.g. "luisa e marco" =>"Luisa e Marco"

--- src/babel/italiano/morphology.cljc
+++ src/babel/italiano/morphology.cljc
@@ -708,7 +708,11 @@
             (string/capitalize surface-form)
             (string/capitalize (string/lower-case surface-form))
             (string/upper-case surface-form)
-            (string/lower-case surface-form)))))
+            (string/lower-case surface-form)
+            (string/join " " (map #(if (not (= "e" %))
+                                     (string/capitalize %)
+                                     %)
+                                  (string/split surface-form #"[ ]")))))))

 (defn analyze-capitalization-variant [surface-form lexicon]
   "return an array of the maps, each of which represents the lexical information about a surface form."


Added menu structure for lattice-editor

Added menu structure for lattice-editor

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

--- src/conexp/gui/editors/lattices.clj
+++ src/conexp/gui/editors/lattices.clj
@@ -8,6 +8,7 @@

 (ns conexp.gui.editors.lattices
   (:use conexp.base
+	conexp.gui.util
 	conexp.gui.plugins.base))

 (update-ns-meta! conexp.gui.editors.lattices
@@ -24,20 +25,36 @@

 ;;; The Hooks

-(defn- load-lattice-editor
-  "Loads the lattice-editor plugin in frame."
-  [frame])
+(defvar- *lattice-menu*
+  {:name "Lattice",
+   :content [{:name "Load Lattice"}
+	     {:name "Load Layout"}
+	     {:name "Load Context"}
+	     {}
+	     {:name "Save Lattice"}
+	     {:name "Save Layout"}
+	     {}
+	     {:name "Edit Standard Context"}]}
+  "Menu for lattice editor.")

-(defn- unload-lattice-editor
-  "Unloads the lattice-editor plugin from frame."
-  [frame])
+(let [menu-hash (ref {})]

-;;; What we want
+  (defn- load-lattice-editor
+    "Loads the lattice-editor plugin in frame."
+    [frame]
+    (dosync
+     (alter menu-hash
+	    assoc frame (add-menus frame [*lattice-menu*]))))

-;; A Menu with
-;; - loading a Lattice from file and editing it
-;; - loading a Layout from file and showing it
-;; - loading a Context from file and showing its concept lattice
+  (defn- unload-lattice-editor
+    "Unloads the lattice-editor plugin from frame."
+    [frame]
+    (dosync
+     (let [menu (get @menu-hash frame)]
+       (remove-menus frame [menu])
+       (alter menu-hash dissoc frame))))
+
+  nil)

 ;;; The End


Story ID: RPC-259 Summary: recursively printing throwable causes

--- src/untangled_spec/reporters/terminal.clj
+++ src/untangled_spec/reporters/terminal.clj
@@ -38,7 +38,8 @@
   (pad " " (* 2 level)))

 (defn print-throwable [e]
-  (println (format-exception e {:frame-limit 10})))
+  (println (format-exception e {:frame-limit 10}))
+  (some-> (.getCause e) print-throwable))

 (defmethod print-method Throwable [e w]
   (print-method (c/red e) w))


Allow apps to be saved in Blockly format

This is useful as it means that users can forget about coding
clojurescript altogether for simpler programs

--- src/webapp/framework/server/systemfns.clj
+++ src/webapp/framework/server/systemfns.clj
@@ -844,6 +844,8 @@
           (
           id                        serial NOT NULL,
           application_name          character varying,
+          code_format               character varying,
+          blockly_xml               character varying,
           application_code          character varying,
           application_glyph         character varying,
           fk_appshare_publisher_id  integer,
@@ -858,6 +860,8 @@
           id                        NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY,
           application_name          VARCHAR2(200 BYTE),
           application_glyph         VARCHAR2(200 BYTE),
+          code_format               VARCHAR2(40 BYTE),
+          blockly_xml               CLOB,
           application_code          CLOB,
           fk_appshare_publisher_id  NUMBER,
           CONSTRAINT  APPSHARE_APPLICATIONS_PK PRIMARY KEY (ID)


Add client ID to the query

Add client ID to the query

So that each query knows which web browsers are attached to it

--- src/webapp/framework/server/systemfns.clj
+++ src/webapp/framework/server/systemfns.clj
@@ -542,12 +542,13 @@
       (println (str "    " query))

       (if (not existing-query)
-        (swap! cached-queries assoc  query (atom {})))
+        (swap! cached-queries assoc  query (atom {:clients  (atom #{})})))
+

       (let [the-query        (get @cached-queries   query)
             ]
-        (swap! the-query assoc  :records      result-id-vector)
-        (swap! the-query assoc  :count        record-count)
+        (swap! the-query assoc  :records       result-id-vector)
+        (swap! the-query assoc  :count         record-count)
         (swap! the-query assoc  :timestamp    (java.util.Date.))
         ))))

@@ -560,10 +561,10 @@
 (defn add-client-to-query [query  client-id]
   (let [
         existing-query     (get @cached-queries   query)
-        existing-clients   (get @query           :clients)
+        existing-clients   (get @existing-query  :clients)
         ]
-        (swap! existing-clients assoc client-id
-        )))
+        (swap! existing-clients conj client-id)
+        ))

@@ -595,14 +596,19 @@
                      (println (str "    " "Query"))
                      (println (str "    " query))
                      (println (str "    "))
+
                      (println (str "    " "Before"))
                      (println (str "    " @(get @cached-queries query)))
+                     (println (str "    "))
+                     (println (str "    " @(:clients @(get @cached-queries query))))

                      (update-query-in-cache  query)

                      (println (str "    "))
                      (println (str "    " "After"))
                      (println (str "    " @(get @cached-queries query)))
+                     (println (str "    "))
+                     (println (str "    " @(:clients @(get @cached-queries query))))
                      (println (str "    "))
                      ))))))))

@@ -674,9 +680,10 @@

      (if (get @cached-queries  query-key)
        nil
-       (update-query-in-cache  query-key)
-
-       )
+       (do
+         (update-query-in-cache  query-key)
+         (add-client-to-query  query-key  data-session-id)
+         ))

      (do-real   :table-name db-table)


Fix type conversions for hash

Fix type conversions for hash

--- src/caesium/crypto/generichash.clj
+++ src/caesium/crypto/generichash.clj
@@ -1,7 +1,8 @@
 (ns caesium.crypto.generichash
   (:refer-clojure :exclude [bytes hash])
   (:require [caesium.binding :as b]
-            [caesium.byte-bufs :as bb]))
+            [caesium.byte-bufs :as bb]
+            [medley.core :as m]))

 (b/defconsts [bytes
               bytes-min
@@ -40,8 +41,12 @@
   ([msg]
    (hash msg {}))
   ([msg {:keys [size] :or {size bytes} :as opts}]
-   (let [buf (bb/alloc size)]
-     (hash-to-buf! buf msg opts)
+   (let [buf (bb/alloc size)
+         opts (dissoc opts :size)]
+     (hash-to-buf!
+      buf
+      (bb/->indirect-byte-buf msg)
+      (m/map-vals bb/->indirect-byte-buf opts))
      (bb/->bytes buf))))

 (defn blake2b-to-buf!


Change mk-tuple-values into a protocol

Change mk-tuple-values into a protocol

--- src/clj/backtype/storm/clojure.clj
+++ src/clj/backtype/storm/clojure.clj
@@ -156,28 +156,33 @@
          ~definer
          ))))

-(defn- mk-tuple-values
-  [^OutputCollector collector stream values]
-  (if (map? values)
+(defprotocol TupleValues
+  (tuple-values [values collector stream]))
+
+(extend-protocol TupleValues
+  java.util.Map
+  (tuple-values [this ^OutputCollector collector ^String stream]
     (let [ fields (.. collector getContext (getThisOutputFields stream) toList) ]
       (vec (map (into
-                  (empty values) (for [[k v] values]
+                  (empty this) (for [[k v] this]
                                    [(if (keyword? k) (name k) k) v]))
-                fields)))
-    values))
-
-(defnk emit-bolt! [^OutputCollector collector values
+                fields))))
+  java.util.List
+  (tuple-values [this collector stream]
+    this))
+
+(defnk emit-bolt! [^OutputCollector collector ^TupleValues values
                    :stream Utils/DEFAULT_STREAM_ID :anchor []]
   (let [^List anchor (collectify anchor)
-        tuple-values (mk-tuple-values collector stream values) ]
-    (.emit collector stream anchor tuple-values)
-    ))
-
-(defnk emit-direct-bolt! [^OutputCollector collector task values
+        values (tuple-values values collector stream) ]
+    (.emit collector stream anchor values)
+    ))
+
+(defnk emit-direct-bolt! [^OutputCollector collector task ^TupleValues values
                           :stream Utils/DEFAULT_STREAM_ID :anchor []]
   (let [^List anchor (collectify anchor)
-        tuple-values (mk-tuple-values collector stream values) ]
-    (.emitDirect collector task stream anchor tuple-values)
+        values (tuple-values values collector stream) ]
+    (.emitDirect collector task stream anchor values)
     ))

 (defn ack! [^OutputCollector collector ^Tuple tuple]


refine web transaction create

refine web transaction create

--- src/clj_money/web/transactions.clj
+++ src/clj_money/web/transactions.clj
@@ -84,10 +84,10 @@
 (defn create
   [params]
   (let [transaction (-> params
-                        (select-keys [:transaction-date :description :items])
+                        (select-keys [:entity-id :transaction-date :description :items])
                         (update-in [:items] (partial map ->transaction-item))
                         (update-in [:items] (partial map #(select-keys % [:account-id :action :amount]))))
         result (transactions/create (env :db) transaction)]
     (if (validation/has-error? result)
-      (new-transaction (:entity-id result) result {})
+      (new-transaction (:entity-id transaction) result {})
       (redirect (str "/entities/" (:entity-id result) "/transactions")))))


fix: menu (boostrap nav)

fix: menu (boostrap nav)

--- src/cljs/expense_tracker/menu.cljs
+++ src/cljs/expense_tracker/menu.cljs
@@ -3,23 +3,29 @@

 (defn c-menu []
   [:div.navbar.navbar-default
-   [:div.navbar-header
-    [:a.navbar-brand {:href "#"} "Gryffin -- Expense Tracker"]
-    [:div.btn-group
-     [:ul
+   [:div.container-fluid
+    [:div.navbar-header
+     [:a.navbar-brand {:href "#"} "Expense Tracker"]]
+    [:div.collapse.navbar-collapse
+     [:ul.nav.navbar-nav
       [:li [:a {:href "#" :onClick #(reset! g/app-page :home)} "Home"]]
-      [:li "Transactions"
-       [:ul
-        [:li "View"]
-        [:li [:a {:href "#" :onClick #(reset! g/app-page :trans-add)} "Add"]] ;
-        [:li "Edit"]
-        [:li "Delete"]]]
-      [:li "Accounts"
-       [:ul
-        [:li "Add"]
-        [:li "Edit"]
-        [:li "Delete"]]]
-      [:li "Reports"
-       [:ul
-        [:li "Net Worth"]
-        [:li "Time-Periods"]]]]]]])
+      [:li [:a {:href "#" :onClick #(reset! g/app-page :trans-add)} "Add Transaction"]]
+      [:li.dropdown [:a.dropdown-toggle {:href "#"
+                                         :data-toggle "dropdown"
+                                         :role "button"
+                                         :aria-haspopup "true"
+                                         :aria-expanded "false"}
+                     "Accounts" [:span.caret]]
+       [:ul.dropdown-menu
+        [:li [:a {:href "#" :onClick #(reset! g/app-page :acc-view)} "View"]]
+        [:li [:a {:href "#" :onClick #(reset! g/app-page :acc-add)} "Add New"]]]]
+      [:li.dropdown [:a.dropdown-toggle {:href "#"
+                                         :data-toggle "dropdown"
+                                         :role "button"
+                                         :aria-haspopup "true"
+                                         :aria-expanded "false"}
+                     "Reports by" [:span.caret]]
+       [:ul.dropdown-menu
+        [:li [:a {:href "#" :onClick #(reset! g/app-page :rep-pie)} "Time Period"]]
+        #_[:li.divider {:role "separator"}]
+        [:li [:a {:href "#" :onClick #(reset! g/app-page :rep-bar)} "Account"]]]]]]]])


Node removal!

Node removal!

--- src/cljs/nested_sortable/tree.cljs
+++ src/cljs/nested_sortable/tree.cljs
@@ -112,9 +112,6 @@
                                                       (:id node))
                                                 (add-as-child? event node))
                              :drag-path path)))})
-
-(defn remove-click [node path]
-  (fn [] (println "Remove" node path)))

 (defn mouse-down [node path]
   (fn [event]
@@ -158,7 +155,7 @@
    (if (and (:in-tree? @mouse) (:dragging? @mouse))
      [display (:drag-node @state) (:drag-path @state)])])

-(defn attach-node-attr [block node path]
+(defn attach-node-attr [block node path root-node]
   (if (and (vector? block)
            (map? (second block)))
     (assoc block 1
@@ -166,15 +163,18 @@
                (#(if (:drag-grip %)
                    (merge % {:on-mouse-down (mouse-down node path)}) %))
                (#(if (:remove-click %)
-                   (merge % {:on-click (remove-click node path)}) %))))
+                   (merge % {:on-click (fn []
+                                         (reset! root-node
+                                                 (remove-node @root-node path)))})
+                   %))))
     block))

-(defn set-attrs [block node path]
+(defn set-attrs [block node path root-node]
   (if (vector? block)
     (into []
           (map #(-> %
-                    (attach-node-attr node path)
-                    (set-attrs node path))
+                    (attach-node-attr node path root-node)
+                    (set-attrs node path root-node))
                block))
     block))

@@ -192,7 +192,7 @@
                                   (swap! mouse assoc :down? false))))

-(defn tree-node [node path display is-root?]
+(defn tree-node [node path display root-node is-root?]
   [:div
    ^{:key (:id node)}
    (node-attr node path)
@@ -201,8 +201,8 @@
       [:div
        {:class (visible-if (not= (:id node)
                                  (get-in @state [:drag-node :id])))}
-       (let [b (-> (display node path) (set-attrs node path))]
-         b)])
+       (-> (display node path)
+           (set-attrs node path root-node))])
     [:div.children
      {:class (visible-if (not= (:id node)
                                (get-in @state [:drag-node :id])))}
@@ -211,7 +211,7 @@
        [placeholder display path])
      (if-not (empty? (:children node))
        (for [[pos child] (map vector (range) (:children node))]
-         [tree-node child (conj path pos) display false]))]
+         [tree-node child (conj path pos) display root-node false]))]
     (if-not (or is-root? (:add-as-child @state))
       [placeholder display path])]])

@@ -244,6 +244,6 @@
                                                 :drag-path (:start-path s)
                                                 :add-as-child false))))))}
       [drag-ghost display]
-      [tree-node @root-node [] display true]]]))
+      [tree-node @root-node [] display root-node true]]]))

 (enable-console-print!)


remove comments

remove comments

--- src/cljs/tictactoe/logic/game.cljs
+++ src/cljs/tictactoe/logic/game.cljs
@@ -3,13 +3,10 @@
     [tictactoe.logic.turn :as turn]))

-(defn new-game
-  "Create a new fresh game, with empty board and no history"
-  []
+(defn new-game []
   [turn/start-turn])

 (defn current-turn
-  "Access the current turn"
   [game-state]
   (peek game-state))


Select best layout judging by score

Select best layout judging by score

--- src-cljs/main.cljs
+++ src-cljs/main.cljs
@@ -109,9 +109,30 @@
       (gdom/removeChildren card-list)
       (doseq [card cards] (gdom/appendChild card-list card)))))

+(defn group-score
+  [layout group]
+  "calculates maximum distance in rows between cards from one group"
+  (transduce
+   (comp
+    (mapcat
+     (fn [[column-id cards]]
+       (map vector (range 0 (count cards)) cards)))
+    (filter #(get group (second %)))
+    (map first))
+   (fn
+     ([[min-pos max-pos]] (- max-pos min-pos))
+     ([[min-pos max-pos] position]
+        [(min min-pos position) (max max-pos position)]))
+   [(reduce max (map #(count (second %)) layout)) 0]
+   layout))
+
 (defn get-layout-score
-  [layout]
-  0)
+  [layout card-deps]
+  (reduce
+   (fn [score group]
+     (+ score (group-score layout group)))
+   0
+   card-deps))

 (defn better-score
   [left right]
@@ -197,31 +218,29 @@
      (fn [[ungrouped grouped]]
        [column-id
         (reduce into []
-                (into
+                (concat
                  (interleave ungrouped grouped)
                  (drop (count grouped) ungrouped)))])
      (cartesian-product [ungrouped-slices grouped-permutations]))))

 (defn layout-permuations
-  [layout]
-  (let [groups (get-card-deps)
-        columns-permutations (map (partial column-permutations groups) layout)]
-    (map
-     (partial into {})
-     (cartesian-product columns-permutations))))
+  [layout card-deps]
+  (->> (map (partial column-permutations card-deps) layout)
+       cartesian-product
+       (map (partial into {}))))

 (defn optimize-layout
-  [layout]
-  (let [permutations (layout-permuations layout)]
+  [layout card-deps]
+  (let [permutations (layout-permuations layout card-deps)]
     (transduce
-     (map (fn [layout] [(get-layout-score layout) layout]))
+     (map (fn [layout] [(get-layout-score layout card-deps) layout]))
      (fn
        ([final]
           (second final))
        ([best current]
           (if best
             (let [[best-score _] best
-                  [current-score _] current]
+                  [current-score l] current]
               (if (better-score current-score best-score)
                 current
                 best))
@@ -231,7 +250,8 @@

 (defn handle-layout-change
   [layout]
-  (-> (optimize-layout layout)
+  (.log js/console "layout changed")
+  (-> (optimize-layout layout (get-card-deps))
       apply-layout))

 (defn listen-drag
@@ -248,7 +268,6 @@

 (defn load
   []
-  ;(.log js/console (.getOwnPropertyDescriptor js/Object js/document "location"))
   (let [groups (create-groups (get-column-list))
         drag-group (new gfx/DragListGroup)]
     (.setDraggerElClass drag-group "Card")
@@ -258,6 +277,4 @@
            (.addDragList drag-group list goog.fx.DragListDirection/DOWN))
     (doseq [card (get-cards)] (add-card card))
     (.init drag-group)
-    (.log js/console (print-str (cartesian-product [[:a :b] [1 2]])))
-    (.log js/console "done")
     (listen-drag drag-group (get-cards-layout))))


DSDEEPB-2373: Don't show 'Failed to Start' div if list is empty

--- src/cljs/org/broadinstitute/firecloud_ui/page/workspace/monitor/submission_details.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/workspace/monitor/submission_details.cljs
@@ -189,8 +189,10 @@
           [WorkflowsTable {:workflows (submission "workflows")
                            :workspace-id (:workspace-id props)
                            :submission-id (submission "submissionId")}]
-          [:h2 {:style {:padding "3em 0 0.5em 0"}} "Failed to Start:"]
-          [WorkflowFailuresTable {:workflows (submission "notstarted")}]])))
+          (when-not (empty? (submission "notstarted"))
+            [:div {}
+             [:h2 {:style {:padding "3em 0 0.5em 0"}} "Failed to Start:"]
+             [WorkflowFailuresTable {:workflows (submission "notstarted")}]])])))
    :load-details
    (fn [{:keys [props state]}]
      (endpoints/call-ajax-orch


fix set lookups

fix set lookups

Avoid override of falsy value encountered in set lookup (closes #75)

--- src/aero/core.cljc
+++ src/aero/core.cljc
@@ -85,28 +85,26 @@
         (contains? value :default) (get value :default)
         :otherwise nil))

+(defn expand-set-keys [m]
+  (reduce-kv (fn [m k v]
+               (if (set? k)
+                 (reduce #(assoc %1 %2 v) m k)
+                 (assoc m k v))) {} m))
+
 (defmethod reader 'hostname
   [{:keys [hostname]} tag value]
   (let [hostn (or hostname #?(:clj (env "HOSTNAME")
                               :cljs (os/hostname)))]
-    (or
-     (some (fn [[k v]]
-             (when (or (= k hostn)
-                       (and (set? k) (contains? k hostn)))
-               v))
-           value)
-     (get value :default))))
+    (let [value (expand-set-keys value)]
+      (get value hostn
+        (get value :default)))))

 (defmethod reader 'user
   [{:keys [user]} tag value]
   (let [user (or user (env "USER"))]
-    (or
-     (some (fn [[k v]]
-             (when (or (= k user)
-                       (and (set? k) (contains? k user)))
-               v))
-           value)
-     (get value :default))))
+    (let [value (expand-set-keys value)]
+      (get value user
+        (get value :default)))))

 (defmethod reader 'include
   [{:keys [resolver source] :as opts} tag value]


Changed dummy data to get more significant digits in forma-estimate test

--- test/clj/forma/hadoop/jobs/forma_test.clj
+++ test/clj/forma/hadoop/jobs/forma_test.clj
@@ -369,8 +369,8 @@
                 ["500" 1 (vec (repeat 21 0.75))]]
       static-src [["500" 28 8 0 0 25 0 1 0 0]]
       forma-val (thrift/FormaValue* (thrift/FireValue* 0 0 0 0) 1. 2. 3. 4.)
-      neighbor-val (thrift/NeighborValue* (thrift/FireValue* 1 0 0 1) 1 1. 2. 3. 4. 5. 6. 7. 8.)
+      neighbor-val (thrift/NeighborValue* (thrift/FireValue* 1 0 0 1) 1 -1. 2. -15. -2. -2. 6. -12. 8.)
       dyn-src [["500" 827 28 8 0 0 forma-val neighbor-val]
                ["500" 829 28 8 0 0 forma-val neighbor-val]]]
     (forma-estimate test-map beta-src dyn-src static-src))
-  => (produces [["500" 28 8 0 0 [1.0 -9999.0 1.0]]]))
+  => (produces [["500" 28 8 0 0 [0.0953494648991095 -9999.0 0.0953494648991095]]]))


Bump eviction

Bump eviction

--- test/onyx/coordinator/simulation_test.clj
+++ test/onyx/coordinator/simulation_test.clj
@@ -174,10 +174,8 @@
             (let [failure (<!! failure-ch-spy)]
               (is (= (:ch failure) :complete)))))

-        (testing "Evicting a peer that doesn't have a task fails")
-
         (testing "Offer task cases")))
-    {:eviction-delay 0}))
+    {:eviction-delay 50000}))

 (deftest plan-one-job-no-peers
   (with-system


add :global-goog-object&array to cache affecting options

--- src/main/shadow/build/compiler.clj
+++ src/main/shadow/build/compiler.clj
@@ -734,6 +734,7 @@
    [:compiler-options :load-tests]
    [:compiler-options :data-readers]
    [:compiler-options :shadow-tweaks]
+   [:compiler-options :global-goog-object&array]
    [:compiler-options :warnings]
    ;; some community macros seem to use this
    ;; hard to track side-effecting macros but even more annoying to run into caching bugs


2nd fix for maxpdiff

2nd fix for maxpdiff

--- satori-rules/rules/alarm.clj
+++ satori-rules/rules/alarm.clj
@@ -160,10 +160,13 @@
 (defn |<| [& args] (apply < (map #(Math/abs %) args)))

 (defn maxpdiff
-  "计算最大变化率，与 aggregate 搭配使用(MAX Percentage DIFFerence)"
+  "计算列表中最后一个点相对之前的点的最大变化率(MAX Percentage DIFFerence)，
+   与 aggregate 搭配使用。计算变化率时总是使用两个点中的最小值做分母，
+   所以由1变到2的变化率是 1.0, 由2变到1的变化率是 -1.0 （而不是 -0.5)
+   "
   [& m]
   (let [r (last m)]
-    (->> (map #(/ (- r %) %) m)
+    (->> (map #(/ (- r %) (min r %)) m)
          (reduce (fn [v v'] (if (> (Math/abs v') (Math/abs v)) v' v))))))

@@ -221,16 +224,16 @@
         group-keys (ref #{})]
     (fn stream [event]
       (let [evkey (group-fn event)]
-        (-> (dosync
-              (if (@group-keys evkey)
-                (let [rst @buffer]
-                  (ref-set buffer [event])
-                  (ref-set group-keys #{evkey})
-                  rst)
-                (do
-                  (alter buffer conj event)
-                  (alter group-keys conj evkey)
-                  nil)))
-            ((fn [rst]
-              (when rst
-                (call-rescue rst children)))))))))
+        (as-> nil rst
+          (dosync
+            (if (@group-keys evkey)
+              (let [events @buffer]
+                (ref-set buffer [event])
+                (ref-set group-keys #{evkey})
+                events)
+              (do
+                (alter buffer conj event)
+                (alter group-keys conj evkey)
+                nil)))
+          (when rst
+            (call-rescue rst children)))))))