Add action to the new tab button

Add action to the new tab button

--- nightweb-android/src/clojure/net/nightweb/tabs.clj
+++ nightweb-android/src/clojure/net/nightweb/tabs.clj
@@ -14,30 +14,26 @@
 (do
   (gen-class
     :name "net.nightweb.tabs.TabLayout"
-    :extends android.widget.LinearLayout
+    :extends net.nightweb.LinearLayout
     :state "state"
     :init "init"
     :post-init "post-init"
     :prefix "tab-layout-"
-    :constructors {[android.content.Context] [android.content.Context]
-                   [android.content.Context android.util.AttributeSet] [android.content.Context android.util.AttributeSet]
-                   [android.content.Context android.util.AttributeSet int] [android.content.Context android.util.AttributeSet int]}
+    :constructors {[android.content.Context net.nightweb.tabs.TabScrollView] [android.content.Context]}
     :methods []
     :exposes-methods {onMeasure superOnMeasure
-                      onLayout superOnLayout
-                      setMeasuredDimension superSetMeasuredDimension})
+                      onLayout superOnLayout})
   (defn tab-layout-create-state
-    [context]
+    [context tabs]
     (let [res (.getResources context)
           tab-overlap (.getDimension res (get-resource :dimen :tab_overlap))]
-      (atom {:tab-overlap tab-overlap})))
+      (atom {:tab-overlap tab-overlap
+             :tabs tabs})))
   (defn tab-layout-init
-    ([context] [[context] (tab-layout-create-state context)])
-    ([context attrs] [[context attrs] (tab-layout-create-state context)])
-    ([context attrs def-style] [[context attrs def-style] (tab-layout-create-state context)]))
+    ([context tabs] [[context] (tab-layout-create-state context tabs)]))
   (defn tab-layout-post-init
     ([this context]
-;      (.setChildrenDrawingOrderEnabled this true)
+      (.superSetChildrenDrawingOrderEnabled this true)
       )
     ([this context attrs] (tab-layout-post-init this context))
     ([this context attrs def-style] (tab-layout-post-init this context)))
@@ -47,9 +43,9 @@
     (let [child-count (- (.getChildCount this) 1)
           max (java.lang.Math/max 0 child-count)
           tab-overlap (get-state this :tab-overlap)]
-;      (.superSetMeasuredDimension this
-;                                  (- (.getMeasuredWidth this) (* max tab-overlap))
-;                                  (.getMeasuredHeight this))
+      (.superSetMeasuredDimension this
+                                  (- (.getMeasuredWidth this) (* max tab-overlap))
+                                  (.getMeasuredHeight this))
       ))
   (defn tab-layout-onLayout
     [this changed l t r b]
@@ -64,8 +60,14 @@
                   w (- (.getRight tab) (.getLeft tab))]]
         (.layout tab total-left (.getTop tab) (+ total-left w) (.getBottom tab)))))
   (defn tab-layout-getChildDrawingOrder
-    [this count i]
-    ())
+    [this cnt i]
+    (let [selected (.getSelectedTab (get-state this :tabs))
+          next (- cnt i 1)]
+      (if (and (= i (- cnt 1)) (>= selected 0) (< selected cnt))
+        selected
+        (if (and (<= next selected) (> next 0))
+          (- next 1)
+          next))))
     )

 (do
@@ -79,11 +81,14 @@
     :constructors {[android.content.Context] [android.content.Context]
                    [android.content.Context android.util.AttributeSet] [android.content.Context android.util.AttributeSet]
                    [android.content.Context android.util.AttributeSet int] [android.content.Context android.util.AttributeSet int]}
-    :methods []
+    :methods [["addTab" [] void]
+              ["setSelectedTab" [android.view.View] void]
+              ["getSelectedTab" [] int]]
     :exposes-methods {onLayout superOnLayout})
   (defn tab-scroll-view-create-state
     [context]
-    (atom {:selected -1 :content-view (net.nightweb.tabs.TabLayout. context)}))
+    (atom {:context context
+           :selected -1}))
   (defn tab-scroll-view-init
     ([context] [[context] (tab-scroll-view-create-state context)])
     ([context attrs] [[context attrs] (tab-scroll-view-create-state context)])
@@ -92,7 +97,7 @@
     ([this context]
       (let [res (.getResources context)
             tab-first-padding-left (.getDimension res (get-resource :dimen :tab_first_padding_left))
-            content-view (get-state this :content-view)]
+            content-view (net.nightweb.tabs.TabLayout. context this)]
         (.setHorizontalScrollBarEnabled this false)
         (.setOverScrollMode this android.view.View/OVER_SCROLL_NEVER)
         (.setOrientation content-view android.widget.LinearLayout/HORIZONTAL)
@@ -102,7 +107,8 @@
                             android.view.ViewGroup$LayoutParams/MATCH_PARENT))
         (.setPadding content-view tab-first-padding-left 0 0 0)
         (.addView this content-view)
-        (.scrollTo this (.getScrollX this) (.getScrollY this))))
+        (.scrollTo this (.getScrollX this) (.getScrollY this))
+        (set-state! this :content-view content-view)))
     ([this context attrs] (tab-scroll-view-post-init this context))
     ([this context attrs def-style] (tab-scroll-view-post-init this context)))
   (defn tab-scroll-view-onLayout
@@ -110,12 +116,36 @@
     (.superOnLayout this changed l t r b)
     (let []
       ))
+  (defn tab-scroll-view-addTab
+    [this]
+    (let [content-view (get-state this :content-view)
+          tab-view (net.nightweb.tabs.TabView. (get-state this :context))]
+      (.setTitle tab-view "New Tab")
+      (.setOnClickListener tab-view (on-click (.setSelectedTab this view)))
+      (.setActivated tab-view true)
+      (.addView content-view tab-view)))
+  (defn tab-scroll-view-setSelectedTab
+    [this view]
+    (let [content-view (get-state this :content-view)
+          num (.indexOfChild content-view view)
+          old-view (.getChildAt content-view (get-state this :selected))]
+      (if (> num -1)
+        (set-state! this :selected num)
+        (set-state! this :selected -1))
+      (if old-view
+        (.setActivated old-view false))
+      (if view
+        (.setActivated view true))
+      (.requestLayout this)))
+  (defn tab-scroll-view-getSelectedTab
+    [this]
+    (get-state this :selected))
   )

 (do
   (gen-class
     :name "net.nightweb.tabs.TabView"
-    :extends android.widget.LinearLayout
+    :extends net.nightweb.LinearLayout
     :state "state"
     :init "init"
     :post-init "post-init"
@@ -124,14 +154,16 @@
                    [android.content.Context android.util.AttributeSet] [android.content.Context android.util.AttributeSet]
                    [android.content.Context android.util.AttributeSet int] [android.content.Context android.util.AttributeSet int]}
     :methods [["setTitle" [String] void]]
-    :exposes-methods {onLayout superOnLayout})
+    :exposes-methods {onLayout superOnLayout
+                      setActivated superSetActivated})
   (defn tab-view-create-state
     [context]
-    (atom {:selected false
+    (atom {:context context
+           :selected false
            :path (android.graphics.Path.)
            :focus-path (android.graphics.Path.)
            :tab-slice-width (get-resource :dimen :tab_slice)
-           :tab-overlap (get-resource :dimen :tab_slice)}))
+           :tab-overlap (get-resource :dimen :tab_overlap)}))
   (defn tab-view-init
     ([context] [[context] (tab-view-create-state context)])
     ([context attrs] [[context attrs] (tab-view-create-state context)])
@@ -141,7 +173,8 @@
       (.setWillNotDraw this false)
       (.setGravity this android.view.Gravity/CENTER_VERTICAL)
       (.setOrientation this android.widget.LinearLayout/HORIZONTAL)
-      (.setPadding this (get-state this :tab-overlap) 0
+      (.setPadding this
+                   (get-state this :tab-overlap) 0
                    (get-state this :tab-slice-width) 0)
       (let [inflater (android.view.LayoutInflater/from context)
             tab-content (.inflate inflater (get-resource :layout :tab_title) this true)
@@ -149,12 +182,14 @@
             icon-view (find-view tab-content (get-resource :id :favicon))
             lock (find-view tab-content (get-resource :id :lock))
             close (find-view tab-content (get-resource :id :close))]
-        (set-state! this :title title)))
+        (.setOnClickListener close (on-click (println "close")))
+        (set-state! this :tab-content tab-content)
+        (set-state! this :title title)
+        (set-state! this :icon-view icon-view)
+        (set-state! this :lock lock)
+        (set-state! this :close close)))
     ([this context attrs] (tab-view-post-init this context))
     ([this context attrs def-style] (tab-view-post-init this context)))
-  (defn tab-view-setActivated
-    [this selected]
-    (set-state! this :selected selected))
   (defn tab-view-onLayout
     [this changed l t r b]
     (.superOnLayout this changed l t r b)
@@ -176,6 +211,23 @@
       (.lineTo focus-path local-l local-t)
       (.lineTo focus-path (- local-r (get-state this :tab-slice-width)) local-t)
       (.lineTo focus-path local-r local-b)))
+  (defn tab-view-setActivated
+    [this selected]
+    (set-state! this :selected selected)
+    (let [context (get-state this :context)
+          title (get-state this :title)
+          icon-view (get-state this :icon-view)
+          close (get-state this :close)]
+      (.setTextAppearance title context (if selected (get-resource :style :TabTitleSelected) (get-resource :style :TabTitleUnselected)))
+      (.setVisibility icon-view (if selected android.view.View/GONE android.view.View/VISIBLE))
+      (.setVisibility close (if selected android.view.View/VISIBLE android.view.View/GONE))
+      (.setHorizontalFadingEdgeEnabled this (not selected))
+      (.superSetActivated this selected)
+;      (.setLayoutParams this (android.view.ViewGroup$LayoutParams.
+;                               (get-state this :tab-width)
+;                               android.view.ViewGroup$LayoutParams/MATCH_PARENT))
+      (.setFocusable this (not selected))
+      (.postInvalidate this)))
   (defn tab-view-setTitle
     [this text]
     (let [title (get-state this :title)]
@@ -185,7 +237,7 @@
 (do
   (gen-class
     :name "net.nightweb.tabs.TabBar"
-    :extends android.widget.LinearLayout
+    :extends net.nightweb.LinearLayout
     :state "state"
     :init "init"
     :post-init "post-init"
@@ -195,8 +247,7 @@
                    [android.content.Context android.util.AttributeSet int] [android.content.Context android.util.AttributeSet int]}
     :methods []
     :exposes-methods {onMeasure superOnMeasure
-                      onConfigurationChanged superOnConfigurationChanged
-                      setMeasuredDimension superSetMeasuredDimension})
+                      onConfigurationChanged superOnConfigurationChanged})
   (defn tab-bar-create-state
     [context]
     (let [res (.getResources context)]
@@ -217,11 +268,9 @@
             tabs (find-view this (get-resource :id :tabs))
             new-tab (find-view this (get-resource :id :newtab))]
         (.setPadding this 0 tab-padding-top 0 0)
-        (.setOnClickListener new-tab
-                             (on-click (println "on-click")))
+        (.setOnClickListener new-tab (on-click (.addTab tabs)))
         (set-state! this :tabs tabs)
-        (set-state! this :new-tab new-tab)
-        ))
+        (set-state! this :new-tab new-tab)))
     ([this context attrs] (tab-bar-post-init this context))
     ([this context attrs def-style] (tab-bar-post-init this context)))
   (defn tab-bar-onConfigurationChanged
@@ -232,26 +281,26 @@
           tab-width (get-resource :dimen :tab_width)]
       (set-state! this :tab-width (.getDimension res tab-width))
       (.updateLayout (get-state this :tabs))))
-;  (defn tab-bar-onMeasure
-;    [this hspec vspec]
-;    (.superOnMeasure this hspec vspec)
-;    (.superSetMeasuredDimension this
-;                           (- (.getMeasuredWidth this)
-;                              (get-state this :tab-add-overlap))
-;                           (.getMeasuredHeight this)))
-;  (defn tab-bar-onLayout
-;    [this changed left top right bottom]
-;    (let [new-tab (get-state this :new-tab)
-;          tabs (get-state this :tabs)
-;          pl (.getPaddingLeft this)
-;          pt (.getPaddingTop this)
-;          w (- right left pl)
-;          tab-add-overlap (get-state this :tab-add-overlap)
-;          button-width (- (.getMeasuredWidth new-tab) tab-add-overlap)
-;          sw (- w button-width)]
-;      (.layout tabs pl pt (+ pl sw) (- bottom top))
-;      (.layout new-tab (- (+ pl sw) tab-add-overlap) pt
-;               (- (+ pl sw button-width) tab-add-overlap) (- bottom top))))
+  (defn tab-bar-onMeasure
+    [this hspec vspec]
+    (.superOnMeasure this hspec vspec)
+    (.superSetMeasuredDimension this
+                           (- (.getMeasuredWidth this)
+                              (get-state this :tab-add-overlap))
+                           (.getMeasuredHeight this)))
+  (defn tab-bar-onLayout
+    [this changed left top right bottom]
+    (let [new-tab (get-state this :new-tab)
+          tabs (get-state this :tabs)
+          pl (.getPaddingLeft this)
+          pt (.getPaddingTop this)
+          w (- right left pl)
+          tab-add-overlap (get-state this :tab-add-overlap)
+          button-width (- (.getMeasuredWidth new-tab) tab-add-overlap)
+          sw (- w button-width)]
+      (.layout tabs pl pt (+ pl sw) (- bottom top))
+      (.layout new-tab (- (+ pl sw) tab-add-overlap) pt
+               (- (+ pl sw button-width) tab-add-overlap) (- bottom top))))
   )

 (defn show-tab-bar


generator config back into default

generator config back into default

--- src/name_bazaar/server/dev.cljs
+++ src/name_bazaar/server/dev.cljs
@@ -70,9 +70,7 @@
   (-> (mount/with-args
         (merge
           (mount/args)
-          {:deployer {:write? true}
-           :generator {:total-accounts 1
-                       :offerings-per-account 2}}))
+          {:deployer {:write? true}}))
     (mount/start)
     pprint/pprint))

@@ -88,7 +86,9 @@
                             :ui {:public-key "2564e15aaf9593acfdc633bd08f1fc5c089aa43972dd7e8a36d67825cd0154602da47d02f30e1f74e7e72c81ba5f0b3dd20d4d4f0cc6652a2e719a0e9d4c7f10943"
                                  :use-instant-registrar? true
                                  :reveal-period {:hours 48}
-                                 :etherscan-url "https://rinkeby.etherscan.io"}}}
+                                 :etherscan-url "https://rinkeby.etherscan.io"}
+                            :generator {:total-accounts 10
+                                        :offerings-per-account 3}}}
          :smart-contracts {:contracts-var #'name-bazaar.shared.smart-contracts/smart-contracts
                            :print-gas-usage? true
                            :auto-mining? true}


Remove hierarchical event matching

Remove hierarchical event matching

In practice, hierarchical events does not make sense since all
subscribers are usually per entity per component. Gives a performance
boost due to reduced nested iterations.

--- src/cljs/chocolatier/engine/systems/events.cljs
+++ src/cljs/chocolatier/engine/systems/events.cljs
@@ -49,28 +49,20 @@
     state))

 (defn get-events
-  "Returns a lazy sequence of events matching the selectors.
-   Selectors are scoped from general to more specific.
-
-   For example:
-   - [:s1 :s2 :s3] matches all events with all 3 selectors
-   - [:s1] matches all results in the :s2 and :s3 key"
+  "Returns a collecition of events or nil"
   [state selectors]
-  (let [result (get-in state (into queue-path selectors))]
-    (if (map? result)
-      (mapcat #(get-events state (conj selectors %)) (keys result))
-      result)))
+  (get-in state (into queue-path selectors)))

 (defn get-subscribed-events
   "Returns a lazy seq of events for entity-id based on their subscriptions"
   [state entity-id]
-  (loop [s (get-in state [:state :events :subscriptions entity-id])
+  (loop [subscriptions (get-in state [:state :events :subscriptions entity-id])
          accum (transient [])]
-    (if-let [[selectors & more] s]
+    (if-let [selectors (first subscriptions)]
       (do
         (doseq [e (get-events state selectors)]
           (conj! accum e))
-        (recur more accum))
+        (recur (rest subscriptions) accum))
       (persistent! accum))))

 (defn valid-event?


Move Delete button (in Edit email form) to form title.

--- src/cljs/hatnik/web/client/form_components.cljs
+++ src/cljs/hatnik/web/client/form_components.cljs
@@ -13,17 +13,34 @@

 ;; For selecting action form header

-(def action-forms-headers
-  {:email-action "Add email notification"
-   :email-edit-action "Edit email notification"})
-
-(defn action-form-header [data owner]
+(defn email-action-form-header [data]
   (reify
     om/IRender
     (render [this]
       (dom/h4 #js {:className "modal-title"}
-              (get action-forms-headers
-                   (:form-type data))))))
+              "Add email notification"))))
+
+(defn email-update-header [data]
+  (reify
+    om/IRender
+    (render [this]
+      (dom/div
+       nil
+       (dom/h4 #js {:className "modal-title"}
+               "Edit email notification"
+       (dom/button #js {:className "btn btn-danger pull-right"
+                        :onClick #(action/delete-action
+                                   (get (deref (:current-action @data)) "id"))}
+                   "Delete"))))))
+
+(def action-forms-headers
+  {:email-action email-action-form-header
+   :email-edit-action email-update-header})
+
+(defn action-form-header [data owner]
+  (apply
+   (get action-forms-headers (:form-type data))
+   [data]))

 ;; For selecting action form body
@@ -86,9 +103,6 @@
                     :onClick #(action/update-email-action
                                (:current-project @data)
                                (get (deref (:current-action @data)) "id"))} "Update")
-   (dom/button #js {:className "btn btn-danger pull-center"
-                    :onClick #(action/delete-action
-                               (get (deref (:current-action @data)) "id"))} "Delete")
    (dom/button #js {:className "btn btn-default"
                     :onClick #(action/test-new-email-action (:current-project @data))} "Test")))


Fix keyword ':import' in 'ns' for c.t.n.find

--- src/main/clojure/clojure/tools/namespace/find.clj
+++ src/main/clojure/clojure/tools/namespace/find.clj
@@ -14,9 +14,9 @@
             [clojure.set :as set]
             [clojure.tools.namespace.file :as file]
             [clojure.tools.namespace.parse :as parse])
-  (import (java.io File FileReader BufferedReader PushbackReader
-                   InputStreamReader)
-          (java.util.jar JarFile JarEntry)))
+  (:import (java.io File FileReader BufferedReader PushbackReader
+                    InputStreamReader)
+           (java.util.jar JarFile JarEntry)))

 ;;; JAR-file utilities, adapted from clojure.java.classpath


Made master point to qa.

Made master point to qa.

--- src/cljs/wombats_web_client/constants/urls.cljs
+++ src/cljs/wombats_web_client/constants/urls.cljs
@@ -1,7 +1,7 @@
 (ns wombats-web-client.constants.urls)

 ;; Remote Dev
-(def base-api-url "//dev.api.wombats.io")
+(def base-api-url "//qa.api.wombats.io")

 ;; Local Dev
 #_(def base-api-url "//localhost:8888")


markup for superjob dot ru site has changed

--- src/cljs_workcalendar/datasource/superjobru.clj
+++ src/cljs_workcalendar/datasource/superjobru.clj
@@ -6,12 +6,12 @@
   (:require [clj-http.client :as http]))

 (defn- prev-month-day? [html-element]
-  (.contains (:class (:attrs html-element)) "_other"))
+  (.contains (:class (:attrs html-element)) "h_color_gray_lt"))

 (defn- weekend? [html-element]
   (let [c (:class (:attrs html-element))]
     (and (not (nil? c))
-         (.contains c "_holiday"))))
+         (.contains c "MonthsList_holiday"))))

 (defn- day [html-element]
   (Integer/parseInt (first (:content html-element))))
@@ -35,7 +35,7 @@

                    true
                    nil))
-               (html/select calendar-element [:.ProductionCalendar_cells :div])
+               (html/select calendar-element [:.MonthsList_date])
                (apply concat (repeatedly #(range 1 8))))))

 (defn- get-work-calendar-for-year [year url]
@@ -43,7 +43,7 @@
                   (:body (http/get url))
                   (catch Exception e ""))
         page (html/html-resource (java.io.StringReader. rawPage))
-        month-calendars (html/select page [:.ProductionCalendar_grid])]
+        month-calendars (html/select page [:.MonthsList_grid])]
     (apply concat (map (fn [calendar month-index]
                          (extract-non-working-days calendar year month-index))
                        month-calendars


extract build-output-values-mult

extract build-output-values-mult

--- src/cljx/jamesmacaulay/zelkova/impl/signal.cljx
+++ src/cljx/jamesmacaulay/zelkova/impl/signal.cljx
@@ -353,6 +353,12 @@
                           event)))
              ensure-sequential)))

+(defn- build-output-values-mult
+  [mult-map output-sig]
+  (-> (get mult-map output-sig)
+      (async/tap (async/chan 1 fresh-values))
+      (async/mult)))
+
 (extend-protocol SignalLike
   LiveChannelGraph
   (spawn* [g opts] (spawn* (:signal g) opts))
@@ -367,9 +373,7 @@
     (let [events-channel (async/chan 1 events-xform)
           events-mult (async/mult events-channel)
           mult-map (build-message-mult-map (topsort s) events-mult s opts)
-          output-values-mult (-> (get mult-map s)
-                                 (async/tap (async/chan 1 fresh-values))
-                                 (async/mult))]
+          output-values-mult (build-output-values-mult mult-map s)]
       (-> s
           (->LiveChannelGraph events-channel mult-map output-values-mult opts)
           (connect-to-world))))


RS+DM #5 Fix: Redirect to friend-protected urls after signing in

--- src/objective8/handlers/front_end.clj
+++ src/objective8/handlers/front_end.clj
@@ -39,6 +39,7 @@
                                        :doc-title (t' :sign-in/doc-title)
                                        :doc-description (t' :sign-in/doc-description)
                                        :signed-in (signed-in?)})
+      (assoc :session (:session request))
       (assoc-in [:session :sign-in-referrer] refer)))

 (defn sign-out [request]


Set up socket server.

Set up socket server.

--- src/onyx/messaging/http_kit.clj
+++ src/onyx/messaging/http_kit.clj
@@ -16,22 +16,24 @@
 (def completion-route "/completion")

 (defn app [daemon inbound-ch release-ch request]
-  (let [thawed (nippy/thaw (.bytes (:body request)))
-        uri (:uri request)]
-    (cond (= uri send-route)
-          (doseq [message thawed]
-            (>!! inbound-ch message))
+  (server/with-channel request channel
+    (server/on-receive
+     channel
+     (fn [data]
+       (let [thawed (nippy/thaw data)
+             uri (:uri request)]
+         (cond (= uri send-route)
+               (doseq [message thawed]
+                 (>!! inbound-ch message))

-          (= uri acker-route)
-          (acker/ack-message daemon
-                             (:id thawed)
-                             (:completion-id thawed)
-                             (:ack-val thawed))
+               (= uri acker-route)
+               (acker/ack-message daemon
+                                  (:id thawed)
+                                  (:completion-id thawed)
+                                  (:ack-val thawed))

-          (= uri completion-route)
-          (>!! release-ch (:id thawed)))
-    {:status 200
-     :headers {"Content-Type" "text/plain"}}))
+               (= uri completion-route)
+               (>!! release-ch (:id thawed))))))))

 (defrecord HttpKitWebSockets [opts]
   component/Lifecycle
@@ -58,7 +60,10 @@

 (defmethod extensions/peer-site HttpKitWebSockets
   [messenger]
-  {:url (format "http://%s:%s" (:ip messenger) (:port messenger))})
+  {:url (format "ws://%s:%s" (:ip messenger) (:port messenger))})
+
+(defmethod extensions/connect-to-peer HttpKitWebSockets
+  [messenger event peer-site])

 (defmethod extensions/receive-messages HttpKitWebSockets
   [messenger {:keys [onyx.core/task-map] :as event}]


Fix up klank and klang ugen init fns to munge the specifications correctly. Also some slight doc tweaking.

--- src/overtone/sc/ugen/ff_osc.clj
+++ src/overtone/sc/ugen/ff_osc.clj
@@ -31,19 +31,20 @@
       ;; }

       {:name "Klang",
-       :args [{:name "specs", :mode :not-expanded :doc "An array of three arrays frequencies, amplitudes and phases:  1) an array of filter frequencies, 2) an Array of filter amplitudes, or nil. If nil, then amplitudes default to 1.0, 3) an Array of initial phases, or nil. If nil, then phases default to 0.0."}
+       :args [{:name "specs", :mode :append-sequence :doc "An array of three arrays frequencies, amplitudes and phases:  1) an array of filter frequencies, 2) an Array of filter amplitudes, or nil. If nil, then amplitudes default to 1.0, 3) an Array of initial phases, or nil. If nil, then phases default to 0.0."}
               {:name "freqscale", :default 1.0 :doc "a scale factor multiplied by all frequencies at initialization time."}
               {:name "freqoffset", :default 0.0 :doc "an offset added to all frequencies at initialization time."}],
        :rates #{:ar}
-       :init (fn [rate [specs & args]]
-               (let [[freqs amps phases] specs
-                     amps (or amps (repeat 1.0))
-                     phases (or phases (repeat 0.0))
-                     faps (map vector freqs amps phases)]
-                 (apply concat args faps)))
+       :init (fn [rate args spec]
+               (let [[[ freqs amps times]] args
+                     amps                  (or amps (repeat (count freqs) 1.0))
+                     times                 (or times (repeat (count freqs) 1.0))
+                     fats                  (map vector freqs amps times)
+                     new-args              (concat [fats] (rest args))]
+                 new-args))
        :doc "Klang is a bank of fixed frequency sine oscillators. Klang is more efficient than creating individual oscillators but offers less flexibility.

-  The parameters in specificationsArrayRef can't be changed after it has been started.
+  The specs can't be changed after it has been started.
   For a modulatable but less efficient version, see dyn-klang."}

       ;; Klank : UGen {
@@ -68,28 +69,29 @@
       ;; }

       {:name "Klank",
-       :args [{:name "specs", :mode :not-expanded :doc "An array of three arrays: frequencies, amplitudes and ring times: *all arrays should have the same length*  1) an Array of filter frequencies. 2)  an Array of filter amplitudes, or nil. If nil, then amplitudes default to 1.0 3) an Array of 60 dB decay times for the filters."}
+       :args [{:name "specs", :mode :append-sequence :doc "An array of three arrays: frequencies, amplitudes and ring times: *all arrays should have the same length*  1) an Array of filter frequencies. 2)  an Array of filter amplitudes, or nil. If nil, then amplitudes default to 1.0 3) an Array of 60 dB decay times for the filters."}
               {:name "input" :doc "the excitation input to the resonant filter bank."}
               {:name "freqscale", :default 1.0 :doc "a scale factor multiplied by all frequencies at initialization time."}
               {:name "freqoffset", :default 0.0 :doc "an offset added to all frequencies at initialization time."}
               {:name "decayscale", :default 1.0 :doc "a scale factor multiplied by all ring times at initialization time."}],
        :rates #{:ar}
-       :init (fn [rate [specs & args]]
-               (let [[freqs amps times] specs
-                     amps               (or amps (repeat 1.0))
-                     times              (or times (repeat 1.0))
-                     fats               (map vector freqs amps times)]
-                 (apply concat args fats)))
+       :init (fn [rate args spec]
+               (let [[[ freqs amps times]] args
+                     amps                  (or amps (repeat (count freqs) 1.0))
+                     times                 (or times (repeat (count freqs) 1.0))
+                     fats                  (map vector freqs amps times)
+                     new-args              (concat [fats] (rest args))]
+                 new-args))
        :doc "Klank is a bank of fixed frequency resonators which can be used to simulate the resonant modes of an object. Each mode is given a ring time, which is the time for the mode to decay by 60 dB.

-  The parameters in specificationsArrayRef can't be changed after it has been started.
+  The specs can't be changed after it has been started.
   For a modulatable but less efficient version, see dyn-klank."}

       {:name "Blip",
        :args [{:name "freq", :default 440.0 :doc "Frequency in Hertz (control rate)"}
               {:name "numharm", :default 200.0 :doc "Number of harmonics. This may be lowered internally if it would cause aliasing."}],
        :rates #{:ar}
-       :doc "Band Limited ImPulse generator. All harmonics have equal amplitude. This is the equivalent of buzz in MusicN languages.
+       :doc "Band Limited Impulse generator. All harmonics have equal amplitude. This is the equivalent of buzz in MusicN languages.
   WARNING: This waveform in its raw form could be damaging to your ears at high amplitudes or for long periods.

   It is improved from other implementations in that it will crossfade in a control period when the number of harmonics changes, so that there are no audible pops. It also eliminates the divide in the formula by using a 1/sin table (with special precautions taken for 1/0).  The lookup tables are linearly interpolated for better quality.


fixed map update on sample data change

fixed map update on sample data change

--- src/prais2/open_layers_map.cljs
+++ src/prais2/open_layers_map.cljs
@@ -57,18 +57,21 @@
     (.setStyle marker iconStyle)
     marker))

-(def hospital-markers
+(defn hospital-markers
+  []
   (let [rows (rest ((content/table-data (:datasource @core/app))))]
     (clj->js
      (map hospital-marker rows))))

-(def vectorSource
+(defn vectorSource
+  []
   (new js/ol.source.Vector
-       (clj->js {:features hospital-markers})))
-
-(def vectorLayer
+       (clj->js {:features (hospital-markers)})))
+
+(defn vectorLayer
+  []
   (new js/ol.layer.Vector
-       (clj->js {:source vectorSource})))
+       (clj->js {:source (vectorSource)})))

 (def tileLayer
   (new js/ol.layer.Tile
@@ -80,7 +83,7 @@
                             :zoom 5.7})))
 (defn hospital-map []
   (new js/ol.Map (clj->js {:target "open-map"
-                           :layers [tileLayer vectorLayer]
+                           :layers [tileLayer (vectorLayer)]
                            :view mapView
                            :loadTilesWhileAnimating true})))


Add doc strings for debian file methods

Add doc strings for debian file methods

--- src/puppetlabs/ezbake/stage.clj
+++ src/puppetlabs/ezbake/stage.clj
@@ -131,14 +131,20 @@
              (fs/file staging-dir "ext" "redhat" (format "%s.spec.erb"
                                                          (:name lein-project)))))
 (defn rename-debian-init-file
-  "things."
+  "In order for debian to automatically populate the correct pre and post
+  scripts for service startup, it expects to find a file named
+  `<project-name>.init` to install as the init script. This function renames
+  ezbake.init.erb to match that convention."
   [lein-project]
   (fs/rename (fs/file staging-dir "ext" "debian" "ezbake.init.erb")
              (fs/file staging-dir "ext" "debian" (format "%s.init.erb"
                                                          (:name lein-project)))))

 (defn rename-debian-default-file
-  "things."
+  "In order for debian to automatically populate the correct pre and post
+  scripts for service startup, it expects to find a file named
+  `<project-name>.default` to install as the defaults file. This function
+  renames ezbake.default.erb to match that convention."
   [lein-project]
   (fs/rename (fs/file staging-dir "ext" "debian" "ezbake.default.erb")
              (fs/file staging-dir "ext" "debian" (format "%s.default.erb"


All async.http.client/{GET,PUT,..} are generated by template now.

--- src/async/http/client.clj
+++ src/async/http/client.clj
@@ -17,7 +17,8 @@
   {:author "Hubert Iwaniuk"}
   (:require [clojure.contrib.io :as duck])
   (:use async.http.client.request
-        async.http.client.headers)
+        async.http.client.headers
+        clojure.template)
   (:import (java.io ByteArrayOutputStream)
            (com.ning.http.client AsyncHttpClient AsyncHttpClientConfig$Builder)))

@@ -39,47 +40,19 @@
      (binding [*ahc* c#]
        ~@body)))

-(defn GET
-  "GET resource from url. Returns promise, that is delivered once response is completed."
-  [#^String url & {:as options}]
-  (apply execute-request
-         (apply prepare-request :get url (apply concat options))
-         (apply concat *default-callbacks*)))
-
-(defn POST
-  "POST to resource. Returns promise, that is delivered once response is completed."
-  [#^String url & {:as options}]
-  (apply execute-request
-         (apply prepare-request :post url (apply concat options))
-         (apply concat *default-callbacks*)))
-
-(defn PUT
-  "PUT to resource. Returns promise, that is delivered once response is completed."
-  [#^String url & {:as options}]
-  (apply execute-request
-         (apply prepare-request :put url (apply concat options))
-         (apply concat *default-callbacks*)))
-
-(defn DELETE
-  "DELETE resource from url. Returns promise, that is delivered once response is completed."
-  [#^String url & {:as options}]
-  (apply execute-request
-         (apply prepare-request :delete url (apply concat options))
-         (apply concat *default-callbacks*)))
-
-(defn HEAD
-  "Request HEAD from url. Returns promise, that is delivered once response is completed."
-  [#^String url & {:as options}]
-  (apply execute-request
-         (apply prepare-request :head url (apply concat options))
-         (apply concat *default-callbacks*)))
-
-(defn OPTIONS
-  "Request OPTIONS from url. Returns promise, that is delivered once response is completed."
-  [#^String url & {:as options}]
-  (apply execute-request
-         (apply prepare-request :options url (apply concat options))
-         (apply concat *default-callbacks*)))
+(do-template
+ [fn-name method]
+ (defn fn-name
+   [#^String url & {:as options}]
+   (apply execute-request
+          (apply prepare-request method url (apply concat options))
+          (apply concat *default-callbacks*)))
+ GET :get
+ POST :post
+ PUT :put
+ DELETE :delete
+ HEAD :head
+ OPTIONS :options)

 (defn request-stream
   "Consumes stream from given url.
@@ -114,10 +87,8 @@
 (defn string
   "Converts response to string."
   [resp]
-  ;; TODO remove instance? check once refactoring is complete and
-  ;; response is unified
   (let [enc (or (get-encoding (headers resp)) duck/*default-encoding*)
-        body  (body resp)
+        body (body resp)
         convert (fn [#^ByteArrayOutputStream baos] (.toString baos enc))]
     (if (seq? body)
       (map convert body)


Updated setPrepStrand and setObligTopic

Updated setPrepStrand and setObligTopic

--- src/research_clojure/eChild/Child.clj
+++ src/research_clojure/eChild/Child.clj
@@ -56,15 +56,15 @@

 (defn outOblique
   [sentence]
-  (def i (.indexOf sentence "01"))
-  (def j (.indexOf sentence "02"))
-  (def k (.indexOf sentence "P"))
-  (def l (.indexOf sentence "03"))
-
-  (if (and (not= i -1) (not= j -1) (not= k -1) (< i j k) (or (and (< i j k) (= l (+ k 1))) (and (< l j i) (= k (+ l 1)))))
-    false
-    (if (and (not= i -1) (not= j -1) (not= k -1) (not= l -1))
-      true)))
+  (let [i (.indexOf sentence "01")
+        j (.indexOf sentence "02")
+        k (.indexOf sentence "P")
+        l (.indexOf sentence "03")]
+
+      (if (and (not= i -1) (not= j -1) (not= k -1) (< i j k) (or (and (< i j k) (= l (+ k 1))) (and (< l j i) (= k (+ l 1)))))
+        false
+        (if (and (not= i -1) (not= j -1) (not= k -1) (not= l -1))
+          true))))

 (defn isQuestion
@@ -140,13 +140,15 @@
   [sentence grammar]
   (if (and (inSentence? sentence "P") (inSentence? sentence "03"))
     (do
-      (def i (.indexOf sentence "P")) ;Get index of P
-      (def j (.indexOf sentence "03")) ;Ge index of 03
+      (let [i (.indexOf sentence "P")   ;Get index of P
+            j (.indexOf sentence "03")] ;Get index of 03
+
       ;If they exist, make sure they aren't adjacent
       (if (not= (Math/abs (- i j)) 1)
         (assoc grammar 7 1)
-        grammar))
-    grammar))
+        grammar)))
+    grammar))
+

 (defn setTopicMark


Sort steam imports the same way backloggery does

--- src/bltool/data/steam.clj
+++ src/bltool/data/steam.clj
@@ -4,7 +4,7 @@
   (:require [clj-http.client :as http])
   (:require [clojure.data.xml :as xml])
   (:require [slingshot.slingshot :refer [throw+]])
-  (:require [clojure.string :refer [trim]]))
+  (:require [clojure.string :refer [trim, lower-case]]))

 (register-flags ["--steam-name" "Steam Community name"]
                 ["--steam-platform" "Default platform to use for Steam games (recommended: PC, PCDL, or Steam)" :default "PC"])
@@ -25,6 +25,10 @@
   [map]
   (hash-map :name (trim (:name map)) :played (if (:hoursOnRecord map) "unfinished" "unplayed")))

+(defn- remove-the
+  [name]
+  (if (.startsWith name "the ") (subs name 4) name))
+
 (defmethod read-games "steam" [_ source]
   (if (not (:steam-name *opts*))
     (throw+ "No Steam Community name specified - use the --steam-name option."))
@@ -32,6 +36,6 @@
         url (str "http://steamcommunity.com/id/" name "/games?tab=all&xml=1")]
     (->> url http/get :body xml/parse-str xml-seq (filter #(= :game (:tag %)))
       (map (comp extract-game-data xml-to-map))
-      (sort-by :name)
+      (sort-by (comp remove-the lower-case :name))
       (map (fn [xdata] { :id "0" :name (xdata :name) :platform (:steam-platform *opts*) :progress (xdata :played) }))
       check-games)))


Adds leftmost

Adds leftmost

--- src/the_little_clojurian/chapter5.clj
+++ src/the_little_clojurian/chapter5.clj
@@ -101,3 +101,15 @@
   (is (= (member* 'foo '(bar)) false))
   (is (= (member* 'foo '((foo))) true))
   (is (= (member* 'foo '((the quick) ((((brown (springy foo)) jumps over)) the dog))))))
+
+(with-test
+  (def leftmost
+    (fn [l]
+      (cond (null? l) nil
+            (atom? (car l)) (car l)
+            :else (leftmost (car l)))))
+
+  (is (= (leftmost '()) nil))
+  (is (= (leftmost '(apple)) 'apple))
+  (is (= (leftmost '((apple))) 'apple))
+  (is (= (leftmost '(((hot cider) with (green) tea))) 'hot)))


fixed a bug that was causing slow loads, the issue was increasing the size of the bootstrap tx 10x

--- src/catalysis/datomic.clj
+++ src/catalysis/datomic.clj
@@ -52,7 +52,7 @@
 (defn bootstrap
   [db]
   (let [eids (map (fn [[e a v t]] e) (d/datoms db :eavt))]
-    (d/pull-many db '[*] eids)))
+    (d/pull-many db '[*] (distinct eids))))


Added cmd-inject-ch to world-store.

Added cmd-inject-ch to world-store.

--- src/cbfg/world-store.cljs
+++ src/cbfg/world-store.cljs
@@ -1,6 +1,6 @@
 (ns cbfg.world-store
   (:require-macros [cbfg.ago :refer [ago ago-loop achan-buf aalts aput]])
-  (:require [cljs.core.async :refer [chan <! map< sliding-buffer]]
+  (:require [cljs.core.async :refer [chan <! merge map< sliding-buffer]]
             [goog.dom :as gdom]
             [cbfg.fence :refer [make-fenced-pump]]
             [cbfg.store :as store]
@@ -53,38 +53,41 @@
 (def store-max-inflight (atom 10))

 (defn world-vis-init [el-prefix]
-  (vis-init (fn [world]
-              (let [store (store/make-store world)
-                    store-cmd-handlers (make-store-cmd-handlers store)
-                    cmd-ch (map< (fn [ev] {:op (.-id (.-target ev))})
-                                 (cljs.core.async/merge (map #(listen-el (gdom/getElement %) "click")
-                                                             (keys store-cmd-handlers))))
-                    client-hist (atom {}) ; Keyed by opaque -> [request, replies]
-                    in-ch (achan-buf world 100)
-                    out-ch (achan-buf world 0)]
-                (ago-loop client world [num-ins 0 num-outs 0]
-                          (let [[v ch] (aalts client [cmd-ch out-ch])
-                                ts (+ num-ins num-outs)]
-                            (cond
-                             (= ch cmd-ch) (let [op (:op v)
-                                                 op-fence (= (get-el-value (str op "-fence")) "1")
-                                                 [params handler] (get store-cmd-handlers op)
-                                                 cmd2 (-> v
-                                                          (assoc :opaque ts)
-                                                          (assoc :fence op-fence))
-                                                 cmd3 (reduce #(assoc %1 (keyword %2)
-                                                                      (get-el-value (str op "-" %2)))
-                                                              cmd2 params)]
-                                             (render-client-hist (swap! client-hist
-                                                                        #(assoc % ts [cmd3 nil])))
-                                             (aput client in-ch (merge cmd3 (handler cmd3)))
-                                             (recur (inc num-ins) num-outs))
-                             (= ch out-ch) (do (render-client-hist (swap! client-hist
-                                                                          #(update-in % [(:opaque v) 1]
-                                                                                conj [ts v])))
-                                               (recur num-ins (inc num-outs))))))
-                (make-fenced-pump world in-ch out-ch @store-max-inflight)))
-            el-prefix nil))
+  (let [cmd-inject-ch (chan)]
+    (vis-init (fn [world]
+                (let [store (store/make-store world)
+                      store-cmd-handlers (make-store-cmd-handlers store)
+                      cmd-ch (merge [cmd-inject-ch
+                                     (map< (fn [ev] {:op (.-id (.-target ev))})
+                                           (merge (map #(listen-el (gdom/getElement %) "click")
+                                                       (keys store-cmd-handlers))))])
+                      client-hist (atom {}) ; Keyed by opaque -> [request, replies]
+                      in-ch (achan-buf world 100)
+                      out-ch (achan-buf world 0)]
+                  (ago-loop client world [num-ins 0 num-outs 0]
+                            (let [[v ch] (aalts client [cmd-ch out-ch])
+                                  ts (+ num-ins num-outs)]
+                              (cond
+                               (= ch cmd-ch) (let [op (:op v)
+                                                   op-fence (= (get-el-value (str op "-fence")) "1")
+                                                   [params handler] (get store-cmd-handlers op)
+                                                   cmd2 (-> v
+                                                            (assoc :opaque ts)
+                                                            (assoc :fence op-fence))
+                                                   cmd3 (reduce #(assoc %1 (keyword %2)
+                                                                        (get-el-value (str op "-" %2)))
+                                                                cmd2 params)]
+                                               (render-client-hist (swap! client-hist
+                                                                          #(assoc % ts [cmd3 nil])))
+                                               (aput client in-ch (cljs.core/merge cmd3 (handler cmd3)))
+                                               (recur (inc num-ins) num-outs))
+                               (= ch out-ch) (do (render-client-hist (swap! client-hist
+                                                                            #(update-in % [(:opaque v) 1]
+                                                                                conj [ts v])))
+                                                 (recur num-ins (inc num-outs))))))
+                  (make-fenced-pump world in-ch out-ch @store-max-inflight)))
+              el-prefix nil)
+    cmd-inject-ch))

 (let [last-id (atom 0)
       gen-id #(swap! last-id inc)]


Added a 'safe-read' for safely getting state from AIN; frequently hits file temp unavailable...

--- src/chicken_coop/core.clj
+++ src/chicken_coop/core.clj
@@ -31,8 +31,8 @@

 (defn time-sm [state day-fn! night-fn!]
-  (let [dusk 0.3
-        dawn 0.4]
+  (let [dusk 0.12
+        dawn 0.20]
     {:state state
      :trans
         {:day
@@ -58,12 +58,33 @@
     (((:trans sm) (:state sm)) m)))

+(defmacro try-times
+  [i message & body]
+  `(loop [i# ~i]
+     (let [result#
+             (when (> i# 0)
+               (try
+                 ~@body
+                 (catch Exception e#
+                   (println ~message ":" e#)
+                   ::failed)))]
+       (if (= result# ::failed)
+         (recur (dec i#))
+         result#))))
+
+
+(defn safe-read!
+  [a]
+  (try-times 50 "Failed to read pin"
+    (read! a)))
+
+
 (defn init-state!
   [floor-btn roof-btn light-ain]
   (cond
     (closed? floor-btn) :night
     (closed? roof-btn) :day
-    (> (read! light-ain) 0.35) :day
+    (> (safe-read! light-ain) 0.35) :day
     :else :night))

@@ -88,7 +109,7 @@
                                (mtr-ctrl x)))]
                (close! p))))
     (loop [time-sm time-sm]
-      (recur (trans-sm! timer (read! light-ain))))))
+      (recur (trans-sm! timer (safe-read! light-ain))))))

 (defn play []
@@ -102,8 +123,8 @@
     (println "initialized successfully")
     (doseq [_ (range)]
       (try
-        (println "Reading light" (read! a1))
-        (println "Reading temp" (read! a2))
+        (println "Reading light" (safe-read! a1))
+        (println "Reading temp" (safe-read! a2))
         (println "Reading btn" (read! g))
         (println "")
         (catch Exception e


util/context.clj: simplified to use properties directly

Don't do dynamic binding.  Exception on missing property.

--- src/org/altlaw/util/context.clj
+++ src/org/altlaw/util/context.clj
@@ -1,77 +1,34 @@
 (ns org.altlaw.util.context)

-(def #^{:private true} *altlaw-context*)
-
-(def #^{:private true}
-     *default-context*
-     {:home (System/getProperty "user.dir")
-      :env "development"})
-
-;; f is fn encapsulating a method call to some context object, that
-;; should return values for string keys.
-(defn- extract-context-with [f]
-  {:home (f "org.altlaw.home")
-   :env (f "org.altlaw.env")
-   :internal-uri (f "org.altlaw.internal.uri")})
-
-;; Extract context information from the given object.  May be a
-;; java.util.Properties, org.restlet.Context, or
-;; org.apache.hadoop.conf.Configuration.
-(defmulti #^{:private true} extract-context class)
-
-(defmethod extract-context java.util.Properties [props]
-  (extract-context-with #(.getProperty props %)))
-
-(defmethod extract-context org.restlet.Context [context]
-  (let [attrs (.getAttributes context)]
-    (extract-context-with #(.get attrs %))))
-
-(defmethod extract-context org.apache.hadoop.conf.Configuration [config]
-  (extract-context-with #(.get config %)))
+(defn get-property [name]
+  (or (System/getProperty name)
+      (throw (Exception. (str "Missing property " name)))))

 ;;; PUBLIC

-(defn setup-context
-  "Set up AltLaw's context object from the given context/configuration
-  object."
-  [obj]
-  (alter-var-root #'*altlaw-context*
-                  (fn [old] (merge *default-context* (extract-context obj)))))
-
 (defn altlaw-home
   "AltLaw's home directory, as String."
   []
-  (:home *altlaw-context*))
+  (get-property "org.altlaw.home"))

 (defn altlaw-env
   "AltLaw's running environment, a String.
   One of production/development/testing."
   []
-  (:env *altlaw-context*))
+  (get-property "org.altlaw.env"))

 (defn internal-uri
   "The base URI of the internal.altlaw.org server.  String, includes
   the scheme and host name, but not the initial slash."
   []
-  (:internal-uri *altlaw-context*))
+  (get-property "org.altlaw.internal.uri"))

 (defn internal-db
   "The DB description for clojure.contrib.sql/with-connection"
   []
   {:classname "org.apache.derby.jdbc.EmbeddedDriver"
    :subprotocol "derby"
-   :subname (str (altlaw-home) "/var/db/" (altlaw-env))
+   :subname (java.io.File. (str (altlaw-home) "/var/db/" (altlaw-env)))
    :create true})

-(defmacro with-altlaw-env
-  "Run body with a modified altlaw-env string."
-  [name & body]
-  `(binding [*altlaw-context* (assoc *altlaw-context* :env name)]
-     ~@body))
-
-(defn testing-env-fixture
-  "Fixture function for use in tests.  Sets the altlaw-env to
-  'testing'."
-  [f]
-  (with-altlaw-env "testing" (f)))


Don't call the same event multiple times

--- src/play_clj/core_listeners.clj
+++ src/play_clj/core_listeners.clj
@@ -91,7 +91,7 @@

 (defn ^:private actor-gesture-listener
   [{:keys [on-ui-fling on-ui-long-press on-ui-pan on-ui-pinch
-           on-ui-tap on-ui-touch-down on-ui-touch-up on-ui-zoom]}
+           on-ui-tap on-ui-zoom]}
    execute-fn!]
   (proxy [ActorGestureListener] []
     (fling [e vx vy b]
@@ -110,12 +110,8 @@
     (tap [e x y p b]
       (execute-fn! on-ui-tap
                    :event e :input-x x :input-y y :pointer p :button b))
-    (touchDown [e x y p b]
-      (execute-fn! on-ui-touch-down
-                   :event e :input-x x :input-y y :pointer p :button b))
-    (touchUp [e x y p b]
-      (execute-fn! on-ui-touch-up
-                   :event e :input-x x :input-y y :pointer p :button b))
+    ;(touchDown [e x y p b])
+    ;(touchUp [e x y p b])
     (zoom [e id d]
       (execute-fn! on-ui-zoom :event e :initial-distance id :distance d))))

@@ -150,20 +146,12 @@
                    :event e :input-x x :input-y y :pointer p :button b))))

 (defn ^:private drag-listener
-  [{:keys [on-ui-drag on-ui-drag-start on-ui-drag-stop
-           on-ui-touch-down on-ui-touch-dragged on-ui-touch-up]}
+  [{:keys [on-ui-drag on-ui-drag-start on-ui-drag-stop]}
    execute-fn!]
   (proxy [DragListener] []
-    (touchDown [e x y p b]
-      (execute-fn! on-ui-touch-down
-                   :event e :input-x x :input-y y :pointer p :button b)
-      (some? on-ui-touch-down))
-    (touchDragged [e x y p]
-      (execute-fn! on-ui-touch-dragged
-                   :event e :input-x x :input-y y :pointer p))
-    (touchUp [e x y p b]
-      (execute-fn! on-ui-touch-up
-                   :event e :input-x x :input-y y :pointer p :button b))
+    ;(touchDown [e x y p b])
+    ;(touchDragged [e x y p])
+    ;(touchUp [e x y p b])
     (drag [e x y p]
       (execute-fn! on-ui-drag :event e :input-x x :input-y y :pointer p))
     (dragStart [e x y p]


Load goog/deps.js and use it to resolve JavaScript dependencies; refs #8

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -655,7 +655,7 @@
   (when-not (contains? @loaded-libs rule)
     (let [path (string/replace (munge rule) \. java.io.File/separatorChar)
           cljs-path (str path ".cljs")
-          js-path (str path ".js")]
+          js-path (str "goog/" (.eval jse (str "goog.dependencies_.nameToPath['" rule "']")))]
       (if-let [res (io/resource cljs-path)]
         (binding [*cljs-ns* 'cljs.user]
           (load-stream jse res))
@@ -669,13 +669,18 @@
   Hang on to return for use across repl calls."
   []
   (let [jse (-> (javax.script.ScriptEngineManager.) (.getEngineByName "JavaScript"))
-        base (io/resource "goog/base.js")]
+        base (io/resource "goog/base.js")
+        deps (io/resource "goog/deps.js")]
     (assert base "Can't find goog/base.js in classpath")
+    (assert deps "Can't find goog/deps.js in classpath")
     (.put jse javax.script.ScriptEngine/FILENAME "goog/base.js")
     (.put jse "cljs_javascript_engine" jse)
     (with-open [r (io/reader base)]
       (.eval jse r))
     (.eval jse bootjs)
+    ;; Load deps.js line-by-line to avoid 64K method limit
+    (doseq [line (line-seq (io/reader deps))]
+      (.eval jse line))
     {:jse jse}))

 (defn repl


* src/clj/cljs/compiler.clj: put deftype and defprotocol :protocols meta into namespaces

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -1264,12 +1264,12 @@
              (let [m (assoc (or m {})
                        :name t
                        :num-fields (count fields))]
-               (if-let [line (:line env)]
-                 (-> m
-                     (assoc :file *cljs-file*)
-                     (assoc :line line))
-                 m))))
-    {:env env :op :deftype* :as form :t t :fields fields :pmasks pmasks}))
+               (merge m
+                 {:protocols (-> tsym meta :protocols)}
+                 (when-let [line (:line env)]
+                   {:file *cljs-file*
+                    :line line})))))
+    {:env env :op :deftype* :form form :t t :fields fields :pmasks pmasks}))

 (defmethod parse 'defrecord*
   [_ env [_ tsym fields pmasks :as form] _]
@@ -1277,11 +1277,11 @@
     (swap! namespaces update-in [(-> env :ns :name) :defs tsym]
            (fn [m]
              (let [m (assoc (or m {}) :name t)]
-               (if-let [line (:line env)]
-                 (-> m
-                     (assoc :file *cljs-file*)
-                     (assoc :line line))
-                 m))))
+               (merge m
+                 {:protocols (-> tsym meta :protocols)}
+                 (when-let [line (:line env)]
+                   {:file *cljs-file*
+                    :line line})))))
     {:env env :op :defrecord* :form form :t t :fields fields :pmasks pmasks}))

 ;; dot accessor code


add BQ clustering option in write-bq-table options as well as optimized-writes option (#126)

--- src/clj/datasplash/bq.clj
+++ src/clj/datasplash/bq.clj
@@ -10,7 +10,8 @@
    [datasplash.core :as ds])
   (:import
    (com.google.api.services.bigquery.model
-    TableRow TableFieldSchema TableSchema TimePartitioning)
+    TableRow TableFieldSchema TableSchema TimePartitioning
+    Clustering)
    (org.apache.beam.sdk Pipeline)
    (org.apache.beam.sdk.io.gcp.bigquery
     BigQueryIO
@@ -148,8 +149,14 @@
   (let [tp (doto (TimePartitioning.) (.setType (-> type name .toUpperCase)))]
     (cond-> tp
       (int? expiration-ms)                   (.setExpirationMs expiration-ms)
-      (string? field)                        (.setField field)
+      (string? field)                        (.setField (clean-name field))
       (boolean? require-partition-filter)    (.setRequirePartitionFilter require-partition-filter))))
+
+
+(defn ^Clustering ->clustering
+  [fields]
+  (let [obj (Clustering.)]
+    (.setFields ^Clustering obj (mapv clean-name fields))))

 (defn get-bq-table-schema
   "Beware, uses bq util to get the schema!"
@@ -219,6 +226,10 @@
                                    (if without-validation
                                      (.withoutValidation transform)
                                      transform))}
+    :with-optimized-writes {:docstr "Allows optimized writes feature, deactivated by default to maintain backward compatibility"
+                            :action (fn [transform bool]
+                                      (when (true? bool)
+                                        (.optimizedWrites transform)))}
     :ignore-unknown-values {:docstr "Ignores fields which does not match the schema."
                             :action (fn [transform ignore-unknown-values]
                                       (if ignore-unknown-values
@@ -242,7 +253,10 @@
                             (fn [transform retrypolicy] (.withFailedInsertRetryPolicy transform retrypolicy)))}
     :time-partitioning {:docstr "Toggles write partitioning for the destination table"
                         :action (fn [transform opts]
-                                  (.withTimePartitioning transform (->time-partitioning opts)))}}))
+                                  (.withTimePartitioning transform (->time-partitioning opts)))}
+    :clustering {:docstr "Toggles clustering for the destination table"
+                 :action (fn [transform opts]
+                           (.withClustering transform (->clustering opts)))}}))

 (defn custom-output-fn [cust-fn]
   (ds/sfn (fn [elt]


more reformat for better readability

more reformat for better readability

--- src/clj/libsearch/web.clj
+++ src/clj/libsearch/web.clj
@@ -14,16 +14,17 @@
    :body (json/write-str data)})

 (defn process-libs [libs]
-  (map #(apply assoc % (interleave [:lang :name] (clojure.string/split (:lib %) #"\/" 2))) libs))
+  (map #(apply assoc % (interleave [:lang :name] (clojure.string/split (:lib %) #"\/" 2)))
+       libs))

 (defn process-repos [repos]
   (map #(assoc %
           :created (str (:created %))
           :updated (str (:updated %))
           :libs (map (fn [name] (apply assoc
-                                      {}
-                                      (interleave [:lang :name]
-                                                  (clojure.string/split name #"\/" 2))))
+                                       {}
+                                       (interleave [:lang :name]
+                                                   (clojure.string/split name #"\/" 2))))
                      (:libs %)))
        repos))

@@ -43,4 +44,5 @@
       (resources/wrap-resource "public")
       (wrap-reload '(libsearch.web))))

-(defn run [port] (run-jetty handler {:port port, :join? false}))
+(defn run [port]
+  (run-jetty handler {:port port, :join? false}))


minified bootstrap

minified bootstrap

--- src/clj/tictag/server.clj
+++ src/clj/tictag/server.clj
@@ -52,7 +52,7 @@
      [:link {:href "https://fonts.googleapis.com/css?family=Roboto+Condensed:300,400"
              :rel "stylesheet"
              :type "text/css"}]
-     [:link {:rel "stylesheet" :href "//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.css"}]
+     [:link {:rel "stylesheet" :href "//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css"}]
      [:link {:rel "stylesheet" :href "/css/re-com.css"}]
      [:link {:rel "stylesheet" :href "/css/material-design-iconic-font.min.css"}]
      [:link {:rel "stylesheet" :href "/css/main.css"}]]


Remove dead code (game/setup-game!)

Remove dead code (game/setup-game!)

--- src/clj/zetawar/game.cljs
+++ src/clj/zetawar/game.cljs
@@ -786,31 +786,6 @@
 (defn load-specs! [conn]
   (d/transact! conn data/specs-tx))

-(def UNIT (filterer #(:unit/type %)))
-(def TERRAIN (filterer #(:terrain/type %)))
-
-;; TODO: add credits to factions based on map initial-credits
-;; TODO: automatically set unit counts to 10 (?)
-;; TODO: automatically set round-built, move-count, attack-count, repaired, and capturing on units
-(defn setup-game! [conn map-id]
-  (let [game-id (random-uuid)
-        game-temp -1
-        tx-ret (d/transact! conn [{:db/id game-temp
-                                   :game/id game-id
-                                   :game/round 1
-                                   :game/max-unit-count 10}])
-        game (d/resolve-tempid (d/db conn) (:tempids tx-ret) game-temp)
-        add-game-pos-idx (fn add-game-pos-idx [attr q r x]
-                           (assoc x attr (game-pos-idx game q r)))
-        map-tx (->> (data/maps map-id)
-                    (setval [ALL ALL LAST #(= :game %)] (e game))
-                    (transform [UNIT ALL (collect-one :unit/q) (collect-one :unit/r)]
-                               (partial add-game-pos-idx :unit/game-pos-idx))
-                    (transform [TERRAIN ALL (collect-one :terrain/q) (collect-one :terrain/r)]
-                               (partial add-game-pos-idx :terrain/game-pos-idx)))]
-    (d/transact! conn map-tx)
-    game-id))
-
 (defn game-map-tx [game map-def]
   (let [map-eid -101]
     (into [{:db/id map-eid


defining namespace pegthing and declaring some functions in order to refer to these functions before they are defined

--- src/clojure_noon/core.clj
+++ src/clojure_noon/core.clj
@@ -936,8 +936,14 @@
 ;;memoize is useful for functions that are computationally intensive or that make network requests - any subsequent calls will not bear the cost

 ;;Peg Thing
-
-
-
-
-
+(ns pegthing.core
+  (require [clojure.set :as set])
+  (:gen-class))
+
+(declare succesfull-move prompt-move game-over query-rows)  ;;this allows you to use refer to these functions before they're defined
+
+
+
+
+
+


scrollspy jsfiddle in everything-else

scrollspy jsfiddle in everything-else

--- src/prais2/everything_else.cljs
+++ src/prais2/everything_else.cljs
@@ -7,6 +7,7 @@
               [prais2.chrome :as chrome]
               [prais2.content :as content :refer [faq-sections]]))

+;; See http://jsfiddle.net/mtjhax/q4p5r/1/ for simple scrollspy

 (rum/defc render-everything-else [id]
   [:.container


remove dependency of politic on itself

remove dependency of politic on itself

--- src/civs/model/politic.clj
+++ src/civs/model/politic.clj
@@ -1,4 +1,3 @@
 (ns
   ^{:author ftomassetti}
-  civs.model.politic
-  (:require [civs.model.politic :refer :all]))
+  civs.model.politic)


Make adjoin into a protocol.

Make adjoin into a protocol.

This paves the way for other types (eg protobufs) providing
optimized implementations of adjoin.

--- src/useful/utils.clj
+++ src/useful/utils.clj
@@ -2,7 +2,7 @@
   (:use [clojure.walk :only [walk]]
         [useful.fn :only [decorate ignoring-nils fix]]
         [clojure.tools.macro :only [symbol-macrolet]])
-  (:import clojure.lang.IDeref))
+  (:import (clojure.lang IDeref ISeq IPersistentMap IPersistentSet IPersistentCollection)))

 (defn invoke
   "Like clojure.core/apply, but doesn't expand/splice the last argument."
@@ -63,30 +63,44 @@
 (defn into-set
   "Update the given set using an existence map."
   [set map]
-  (reduce (fn [set [k v]] ((if v conj disj) set k))
-          set map))
-
-(defn adjoin
-  "Merge two data structures by combining the contents. For maps, merge recursively by
+  (if (map? map)
+    (reduce (fn [set [k v]] ((if v conj disj) set k))
+            set map)
+    (into set map)))
+
+(defprotocol Adjoin
+  (adjoin [left right]
+    "Merge two data structures by combining the contents. For maps, merge recursively by
   adjoining values with the same key. For collections, combine the right and left using
   into or conj. If the left value is a set and the right value is a map, the right value
   is assumed to be an existence map where the value determines whether the key is in the
   merged set. This makes sets unique from other collections because items can be deleted
-  from them."
-  [left right]
-  (cond (map? left)
-        (merge-with adjoin left right)
-
-        (and (set? left) (map? right))
-        (into-set left right)
-
-        (seq? left)
-        (concat left right)
-
-        (coll? left)
-        ((if (coll? right) into conj) left right)
-
-        :else right))
+  from them."))
+
+(extend-protocol Adjoin
+  IPersistentMap
+  (adjoin [this other]
+    (merge-with adjoin this other))
+
+  IPersistentSet
+  (adjoin [this other]
+    (into-set this other))
+
+  ISeq
+  (adjoin [this other]
+    (concat this other))
+
+  IPersistentCollection
+  (adjoin [this other]
+    (into this other))
+
+  Object
+  (adjoin [this other]
+    other)
+
+  nil
+  (adjoin [this other]
+    other))

 (defn pop-if
   "Pop item off the given stack if (pred? item) returns true, returning both the item and the


Deduct simulation start timestamp from first scenario start

--- src/clj_gatling/report.clj
+++ src/clj_gatling/report.clj
@@ -20,8 +20,11 @@
         requests (apply concat (map #(vector (map-request (:name scenario) %)) (:requests scenario)))]
     (conj requests ["SCENARIO" (:name scenario) (.toString (:id scenario)) start end])))

+(defn first-scenario-start [result]
+  (LocalDateTime. (:start (first (sort-by :id result)))))
+
 (defn create-result-lines [result]
-  (let [timestamp (unparse-local (formatter "yyyyMMddhhmmss") (LocalDateTime.))
+  (let [timestamp (unparse-local (formatter "yyyyMMddhhmmss") (first-scenario-start result))
         header ["RUN" timestamp "simulation" "\u0020"]
         scenarios (apply concat (map #(vector (map-scenario %)) result))
        result-lines (conj (flatten-one-level scenarios) header)]


Commands should start with exclamation mark

--- src/clj_mrazik/irc_bot.clj
+++ src/clj_mrazik/irc_bot.clj
@@ -43,6 +43,8 @@
     [my-name message]
     (or (.startsWith (:target message) my-name)        ; private message
         (.startsWith (:text message) (str my-name ":")); direct message
+        (.startsWith (:text message) (str my-name ",")); direct message
+        (.startsWith (:text message) "!")              ; special prefix
     ))

 (defn create-reply
@@ -144,7 +146,9 @@
           dictionary?      (:dictionary modules)
           random-messages? (:random-messages modules)
           input       (if in-channel?
-                          (subs input-text (+ 2 (count @dyncfg/bot-nick)))
+                          (if (.startsWith input-text "!")
+                              (subs input-text 1)
+                              (subs input-text (+ 2 (count @dyncfg/bot-nick))))
                           input-text)
           prefix      (if in-channel? (str nick ": "))
           response    (condp = input


Work on add bookmark

Work on add bookmark

--- src/cljs/bookmarx/add.cljs
+++ src/cljs/bookmarx/add.cljs
@@ -9,6 +9,8 @@
             [bookmarx.header :as header])
   (:require-macros
     [cljs.core.async.macros :refer [go go-loop]]))
+
+(enable-console-print!)

 (defn row
   [label input]
@@ -28,28 +30,37 @@

 (defn upsert "Upsert a bookmark by updating the appropriate state."
   [doc]
-  ; Replace the folder to the session.
-  (when (:folder? @doc)
-    (session/put! (:db/id @doc)
-                  (assoc @doc :bookmark/_parent (:bookmark/_parent (session/get (:db/id @doc))))))
-
-  (let [parent-id (get-in @doc [:bookmark/parent :db/id])
-        parent (session/get parent-id)
-        children (:bookmark/_parent parent)]
-    (if (:add? @doc)
-        ; Add the child to the parent's children.
-        (session/put! parent-id (update-in parent [:bookmark/_parent] #(conj % @doc)))
-        ; Update the parent's children with the updated child.
-        (session/put! parent-id
-                      (update-in parent [:bookmark/_parent]
-                                 #(map (fn [b] (if (= (:db/id b) (:db/id @doc)) @doc b))
-                                       children)))))
+  (println "upsert")
+  (if (:add? @doc)
+    (let [parent-id (session/get :active)
+          parent (session/get parent-id)]
+      ; Add the parent.
+      (swap! doc (assoc @doc :bookmark/parent {:db/id parent-id}))
+      ; Add the bookmark to the parent's children.
+      (session/put! parent-id (update-in parent [:bookmark/_parent] #(conj % @doc)))
+      (session/put! (:db/id @doc) @doc))
+    (let [parent-id (get-in @doc [:bookmark/parent :db/id])
+          parent (session/get parent-id)
+          children (:bookmark/_parent parent)]
+      ; Replace the children of the folder with the children from folder in the session.
+      (when (:folder? @doc)
+        (session/put! (:db/id @doc)
+                      (assoc @doc :bookmark/_parent
+                                  (:bookmark/_parent (session/get (:db/id @doc))))))
+      ; Update the parent's children with the updated child.
+      (session/put! parent-id
+                    (update-in parent [:bookmark/_parent]
+                               #(map (fn [b] (if (= (:db/id b) (:db/id @doc)) @doc b))
+                                     children)))))

   ; Update the state in the remote repository.
-  (go (let [body (:body (<! (http/post (str (:host-url env) (:prefix env) "/api/bookmarks")
-                                       {:edn-params (pr-str @doc) :with-credentials? false
-                                        :headers {"x-csrf-token" (session/get :csrf-token)}})))]
-        (println "body" (str body))))
+  (println "bookmark" (dissoc @doc :bookmark/_parent :folder? :add?))
+  (go (let [bookmark (dissoc @doc :bookmark/_parent :folder? :add?)
+            body (<! (http/post (str (:host-url env) (:prefix env) "/api/bookmarks")
+                                {:edn-params bookmark
+                                 :with-credentials? false
+                                 :headers {"x-csrf-token" (session/get :csrf-token)}}))]
+        (println "body----" )))

   ; Return to the home page.
   (accountant/navigate! (str (:prefix env) "/")))


Add process dir. Closes #78.

Add process dir. Closes #78.

--- src/cljs/replumb/repl.cljs
+++ src/cljs/replumb/repl.cljs
@@ -1,5 +1,5 @@
 (ns replumb.repl
-  (:refer-clojure :exclude [load-file])
+  (:refer-clojure :exclude [load-file ns-publics])
   (:require-macros [cljs.env.macros :refer [with-compiler-env]])
   (:require [cljs.js :as cljs]
             [cljs.tagged-literals :as tags]
@@ -9,6 +9,7 @@
             [cljs.env :as env]
             [cljs.repl :as repl]
             [cljs.pprint :refer [pprint]]
+            [clojure.string :as s]
             [replumb.common :as common]
             [replumb.doc-maps :as docs]
             [replumb.load :as load]
@@ -41,6 +42,19 @@
 (defn known-namespaces
   []
   (keys (:cljs.analyzer/namespaces @st)))
+
+(defn ns-publics
+  "Given a namespace return all the public var analysis maps. Analagous to
+  clojure.core/ns-publics but returns var analysis maps not vars."
+  ([ns]
+   (ns-publics env/*compiler* ns))
+  ([state ns]
+   {:pre [(symbol? ns)]}
+   (->> (merge
+          (get-in @state [::ana/namespaces ns :macros])
+          (get-in @state [::ana/namespaces ns :defs]))
+        (remove (fn [[k v]] (:private v)))
+        (into {}))))

 (defn get-namespace
   [sym]
@@ -106,7 +120,7 @@
       var)))

 (def replumb-repl-special-set
-  '#{in-ns require require-macros import load-file doc source pst})
+  '#{in-ns require require-macros import load-file doc source pst dir})

 (defn repl-special?
   [form]
@@ -533,6 +547,14 @@
         (fetch-source opts var paths-to-try call-back))
       (call-back (common/wrap-success "nil")))))

+(defn process-dir
+  [opts cb data env sym]
+  (let [vars (-> (ns-publics st sym) keys sort)
+        call-back (partial call-back! (merge opts {:no-pr-str-on-value true}) cb data)]
+    (if (seq vars)
+      (call-back (common/wrap-success (s/join \newline vars)))
+      (call-back (common/wrap-success "nil")))))
+
 (defn process-repl-special
   [opts cb data expression-form]
   (let [env (assoc (ana/empty-env) :context :expr
@@ -546,6 +568,7 @@
       doc (process-doc opts cb data env argument)
       source (process-source opts cb data env argument)
       pst (process-pst opts cb data argument)
+      dir (process-dir opts cb data env argument)
       load-file (call-back! opts cb data (common/error-keyword-not-supported "load-file" ex-info-data))))) ;; (process-load-file argument opts)

 (defn process-1-2-3


Restore pprint in initialization function, closes #142

--- src/cljs/replumb/repl.cljs
+++ src/cljs/replumb/repl.cljs
@@ -850,7 +850,7 @@
   Data is passed from outside and will be forwarded to :init-fn!."
   [opts data]
   (when (:verbose opts)
-    (common/debug-prn "Initializing REPL environment with data" (println data)))
+    (common/debug-prn "Initializing REPL environment with data" (with-out-str (pprint data))))

   ;; Target/user init, we need at least one init-fn, the default init function
   (let [init-fns (:init-fns opts)]


Mark selection list API as stable based on previous 7ca70c01f55221008072f390fffd53338cfde30a

--- src/re_demo/selection_list.cljs
+++ src/re_demo/selection_list.cljs
@@ -86,7 +86,7 @@
                            :gap      "10px"
                            :width    "450px"
                            :children [[title2 "Notes"]
-                                      [status-text "Alpha (API will change)" {:color "#EA6B00"}]
+                                      [status-text "Stable"]
                                       [p "Allows the user to select items from a list (single or multi)."]
                                       [p "Uses radio buttons when single selecting, and checkboxes when multi-selecting."]
                                       [p "Via strike-through, it supports the notion of selections representing exclusions, rather than inclusions."]


Try to get get-docstring-spec out of cljdoc for zprint.

--- src/zprint/core.cljc
+++ src/zprint/core.cljc
@@ -202,7 +202,7 @@
                  (zprint.sutil/sredef-call fzprint-fn))
                options]))))

-(declare get-docstring-spec)
+#?(:clj (declare get-docstring-spec))

 (defn ^:no-doc process-rest-options
   "Take some internal-options and the & rest of a zprint/czprint


Add mongosoup config

Add mongosoup config

--- src/obb_api/gateways/mongodb/battle_gateway.clj
+++ src/obb_api/gateways/mongodb/battle_gateway.clj
@@ -1,11 +1,12 @@
 (ns obb-api.gateways.mongodb.battle-gateway
   "Persists battles on mongodb"
   (:require [monger.core :as mg]
+            [environ.core :refer [env]]
             [monger.collection :as mc])
   (:import [org.bson.types ObjectId]
-                      [com.mongodb DB WriteConcern]))
+           [com.mongodb DB WriteConcern]))

-(def mongodb-uri "mongodb://127.0.0.1/obb")
+(def mongodb-uri (or (env :mongosoup-url) "mongodb://127.0.0.1/obb"))

 (defn- db
   "Gets the current DB to handle"


configure js environment

configure js environment

--- worker/src/worker/worker.cljs
+++ worker/src/worker/worker.cljs
@@ -22,17 +22,23 @@
     (str *closure-base-path* "../cljs_deps.js")
     (first (scripts-src))))

-(def *cljs-output-file* (cljs-output-file))
-
-(defn serialize [obj]
+(defn generate-obj-body [obj]
   (->> obj
     (map (fn [[key val]] (str (name key) ":" val)))
     (interpose ",")
     (#(str "{" (apply str %) "}"))))

-(defn ^:export pr-str-js [code] (pr-str code))
+(defn genetate-env [objs]
+  (reduce
+    (fn [res [obj body]] (str res "var " (name obj) "=" (generate-obj-body body) ";"))
+    "" objs))

-(defn worker-body [[ns* fn*]]
+(def *cljs-output-file* (cljs-output-file))
+(def *env-str* (genetate-env *env-objs*))
+
+(defn ^:export pr-str-js [code] (*serialize* code))
+
+(defn create-worker-body []
   (let [
     multi-loader (str
      "var CLOSURE_BASE_PATH = '" *closure-base-path* "';"


Library page touchup (#638)

Library page touchup (#638)

* minor tweaks from PO

* Suggestions from Isaac

* nix negative margin, remove space below search, add border, move background gray to common parent

--- src/cljs/org/broadinstitute/firecloud_ui/page/library/library_page.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/library/library_page.cljs
@@ -34,14 +34,17 @@
          :resizable-columns? true
          :sortable-columns? false
          :filterable? false
+         :resize-tab-color (:border-light style/colors)
          :reorder-anchor :right
          :reorder-style {:width "300px" :whiteSpace "nowrap" :overflow "hidden" :textOverflow "ellipsis"}
          :reorder-prefix "Columns"
          :toolbar
          (fn [{:keys [reorderer]}]
            [:div {:style {:display "flex" :alignItems "top"}}
-            [:div {:style {:fontWeight 700 :fontSize "125%" :marginBottom "1em"}} "Search Results: "
-             [:span {:style {:fontWeight 100}}
+            [:div {:style {:fontSize "112%" :marginBottom "1em"}}
+             [:span {:style {:fontWeight 700 :color (:text-light style/colors) :marginRight "0.5rem"}}
+              "Matching Cohorts"]
+             [:span {:style {:fontSize "80%"}}
               (let [total (or (:total @state) 0)]
                 (str total
                      " Dataset"
@@ -137,36 +140,34 @@
      (utils/map-keys name (:facet-filters props)))
    :render
    (fn [{:keys [props this]}]
-     [:div {}
-      [:div {:style {:fontWeight 700 :fontSize "125%" :marginBottom "1em"}} "Search Filters:"]
-      [:div {:style {:background (:background-light style/colors) :padding "16px 12px"}}
-       [comps/AutocompleteFilter
-        {:on-filter (:on-filter props)
-         :width "100%"
-         :initial-text (:search-text props)
-         :ref "text-filter"
-         :placeholder "Search"
-         :facet-filters (:facet-filters props)
-         :bloodhoundInfo {:url (str (config/api-url-root) "/api/library/suggest")
-                          :transform (fn [response]
-                                       (clj->js
-                                         (mapv (partial hash-map :value) (aget response "results"))))
-                          :cache false
-                          :prepare (fn [query settings]
+     [:div {:style {:padding "16px 12px 0 12px"}}
+      [comps/AutocompleteFilter
+       {:on-filter (:on-filter props)
+        :width "100%"
+        :initial-text (:search-text props)
+        :ref "text-filter"
+        :placeholder "Search"
+        :facet-filters (:facet-filters props)
+        :bloodhoundInfo {:url (str (config/api-url-root) "/api/library/suggest")
+                         :transform (fn [response]
                                       (clj->js
-                                        (assoc (js->clj settings)
-                                          :headers {:Authorization (str "Bearer " (utils/get-access-token))}
-                                          :type "POST"
-                                          :contentType "application/json; charset=UTF-8"
-                                          :data (utils/->json-string
-                                                  {:searchString query
-                                                   :filters (react/call :get-filters this)
-                                                   :from 0
-                                                   :size 10}))))}
-         :typeaheadDisplay (fn [result]
-                             (.text (js/$ (str "
" (aget result "value") "
"))))
-         :typeaheadSuggestionTemplate (fn [result]
-                                        (str "
" (aget result "value") "
"))}]]])})
+                                       (mapv (partial hash-map :value) (aget response "results"))))
+                         :cache false
+                         :prepare (fn [query settings]
+                                    (clj->js
+                                     (assoc (js->clj settings)
+                                       :headers {:Authorization (str "Bearer " (utils/get-access-token))}
+                                       :type "POST"
+                                       :contentType "application/json; charset=UTF-8"
+                                       :data (utils/->json-string
+                                              {:searchString query
+                                               :filters (react/call :get-filters this)
+                                               :from 0
+                                               :size 10}))))}
+        :typeaheadDisplay (fn [result]
+                            (.text (js/$ (str "
" (aget result "value") "
"))))
+        :typeaheadSuggestionTemplate (fn [result]
+                                       (str "
" (aget result "value") "
"))}]])})

 (react/defc FacetCheckboxes
   {:render
@@ -191,7 +192,7 @@
                [:input {:type "checkbox"
                         :checked (contains? (:selected-items props) key)
                         :onChange #(react/call :update-selected this key (.. % -target -checked))}]
-               key]
+               [:span {:style {:marginLeft "0.3em"}} key]]
               (some-> doc_count style/render-count)])
            (concat (:buckets props) hidden-items-formatted))
          [:div {:style {:paddingTop "5"}}
@@ -243,7 +244,7 @@
      (if (empty? (:aggregates @state))
        [:div {:style {:fontSize "80%"}} "loading..."]
        (let [aggregate-fields (:aggregate-fields props)]
-         [:div {:style {:fontSize "80%" :background (:background-light style/colors) :padding "16px 12px"}}
+         [:div {:style {:fontSize "85%" :padding "16px 12px"}}
           (map
             (fn [prop-name] [Facet {:aggregate-field prop-name
                                     :aggregate-properties (prop-name (:aggregate-properties props))
@@ -287,7 +288,9 @@
    :render
    (fn [{:keys [this refs state]}]
      [:div {:style {:display "flex" :marginTop "2em"}}
-      [:div {:style {:width "20%" :minWidth 250 :marginRight "2em"}}
+      [:div {:style {:width "20%" :minWidth 250 :marginRight "2em"
+                     :background (:background-light style/colors)
+                     :border style/standard-line}}
        [SearchSection {:search-text (:search-text @state)
                        :facet-filters (:facet-filters @state)
                        :on-filter #(swap! state assoc :search-text %)}]


Fixed bug in multipart form parameters

Fixed bug in multipart form parameters

--- ring-core/src/ring/middleware/multipart_params.clj
+++ ring-core/src/ring/middleware/multipart_params.clj
@@ -43,7 +43,7 @@
   supplied store function is used to save it."
   [^FileItemStream item store]
   (if (.isFormField item)
-    (Streams/asString item)
+    (Streams/asString (.openStream item))
     (store {:filename     (.getName item)
             :content-type (.getContentType item)
             :stream       (.openStream item)})))


Run migrations at the beginning of every test run

I am not sure if this is a good idea. But I am also not sure if it
isn't an awesome idea I should get my production system and my
development system to use.

--- test/clj/coffee_table/test/system.clj
+++ test/clj/coffee_table/test/system.clj
@@ -1,5 +1,6 @@
 (ns coffee-table.test.system
-  (:require [com.stuartsierra.component :as component]
+  (:require [coffee-table.component.database :as dbc]
+            [com.stuartsierra.component :as component]
             [clojure.java.jdbc :as sql]))

 (def ^:dynamic *system* nil)
@@ -20,9 +21,9 @@

 (defn with-transaction-fixture
   [f]
-  (let [dbc (:db *system*)
-        spec (:spec dbc)
-        conn (:connection dbc)]
+  (let [db (:db *system*)
+        spec (:spec db)]
+    (dbc/migrate db)
     (sql/with-db-transaction [spec spec]
       (sql/db-set-rollback-only! spec)
       (binding [*system* (assoc-in *system* [:db :spec] spec)]


Local environment fixes for projects using :appengine-app-versions.

--- src/appengine_magic/local_env_helpers.clj
+++ src/appengine_magic/local_env_helpers.clj
@@ -13,7 +13,9 @@

 (defn appengine-init [#^File dir, port]
   (let [appengine-web-file (File. dir "WEB-INF/appengine-web.xml")
-        application-id (first (xpath-value appengine-web-file "//application"))
+        application-id (if (.exists appengine-web-file)
+                           (first (xpath-value appengine-web-file "//application"))
+                           "appengine-magic-app")
         proxy-factory (ApiProxyLocalFactory.)
         environment (proxy [LocalServerEnvironment] []
                       (getAppDir [] dir)


Added set-path! to show-wishlist!

Added set-path! to show-wishlist!

--- src/wishlistd/cljs/main.cljs
+++ src/wishlistd/cljs/main.cljs
@@ -41,13 +41,15 @@
   (.pop
     (.split js/window.location.pathname "/")))

-(defn show-wishlist! [{:keys [wishes title] :as wishlist}]
 (defn set-path! [code]
   (.pushState js/window.history nil "lol" code))
+
+(defn show-wishlist! [{:keys [wishes title code] :as wishlist}]
   (empty $content)
   (empty $header)
   (append $content (wish-ul wishes))
-  (append $header  (wishlist-title title)))
+  (append $header  (wishlist-title title))
+  (set-path! code))

 (defn title-from-html []
   (val wishlist-title))


quote between statement

quote between statement

--- src/zoo_live/model/event.clj
+++ src/zoo_live/model/event.clj
@@ -21,9 +21,8 @@
     (-> (create-entity (keyword (str "events_" type "_" project)))
         (database postgres))))

-(defn- date-between
-  [w from to]
-  (assoc w :created_at [between from to]))
+(defn- date-between [w from to]
+  (assoc w :created_at ['between from to]))

 (defn- params-to-where
   [w [k v]]
@@ -36,6 +35,6 @@

 (defn query-from-params
   [ent params]
-  (let [where-clause (reduce params-to-where {} params)] )
-  (select ent
-          (where where-clause)))
+  (let [where-clause (reduce params-to-where {} params)]
+    (select ent
+            (where where-clause))))


New algorithm for searching unicode database. Also fix for codepoints above BMP.

--- src/demogorgon/unicode.clj
+++ src/demogorgon/unicode.clj
@@ -1,28 +1,43 @@
 (ns demogorgon.unicode
-  (:use	[clojure.contrib.duck-streams :only (reader)]))
+  (:use	[clojure.contrib.duck-streams :only (reader read-lines)]))

 (defn get-resource [name]
   (.getResourceAsStream (.getContextClassLoader (Thread/currentThread)) name))

+(defn unicode-matches? [needle name codepoint]
+  (or (> (.indexOf (.toLowerCase name) needle) -1)
+      (= needle (.toLowerCase codepoint))))
+
 (defn unicode-lookup [_symbol]
   (let [symbol (.toLowerCase _symbol)]
-    (with-open [rdr (reader (get-resource "unicode.txt"))]
-      (let [lines (line-seq rdr)]
-        (some (fn [^String line]
-                (let [tokens (.split line "\t")
-                      ^String name (.trim (aget tokens 0))
-                      ^String codepoint (.trim (aget tokens 1))]
-                  (if (or (= symbol (.toLowerCase name))
-                          (= symbol (.toLowerCase codepoint)))
-                    {:name name :codepoint codepoint}
-                    nil))) lines)))))
+    (let [matches
+          (filter (fn [^String line]
+                    (let [tokens (.split line "\t")
+                          ^String name (.trim (aget tokens 0))
+                          ^String codepoint (.trim (aget tokens 1))]
+                      (unicode-matches? symbol name codepoint)))
+                  (read-lines (get-resource "unicode.txt")))]
+      (sort-by (fn [item]
+                 (- (count (:name item)) (count symbol)))
+               (map (fn [^String line]
+                      (let [tokens (.split line "\t")
+                            ^String name (.trim (aget tokens 0))
+                            ^String codepoint (.trim (aget tokens 1))]
+                        {:name name :codepoint codepoint})) matches)))))

 (defn unicode-hook [irc object match]
   (if (= (second match) "")
     (str "usage: " (first match) " <symbol>")
-    (let [result (unicode-lookup (second match))]
-      (if result
-        (str "U+" (:codepoint result) " " (:name result)
-             " (" (char (Integer/valueOf (:codepoint result) 16)) ")")
-        "No match"))))
+    (if (< (count (second match)) 3)
+      (str "minimum search length is 3")
+      (let [result (take 5 (unicode-lookup (second match)))]
+        (if (first result)
+
+          (map (fn [foo]
+                 (str "U+" (:codepoint foo) " " (:name foo)
+                      " (" (String. (Character/toChars (Integer/valueOf (:codepoint foo) 16))) ")"))
+               result)
+          "No match")))))

+
+


(DXML-28) Add test for emitting event-tree directly

--- src/test/clojure/clojure/data/xml/test_emit.clj
+++ src/test/clojure/clojure/data/xml/test_emit.clj
@@ -146,3 +146,7 @@
          (emit-str (element :foo {} (int 0)))))
   (is (= "<?xml version=\"1.0\" encoding=\"UTF-8\"?><foo>1.2</foo>"
          (emit-str (element :foo {} (float 1.2))))))
+
+(deftest test-event-seq-emit
+  (is (= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>123"
+         (emit-str (event-seq (java.io.StringReader. "123") {})))))


test update

test update

--- test/funimage/test/imp/statistics.clj
+++ test/funimage/test/imp/statistics.clj
@@ -4,5 +4,5 @@
         [clojure.test]))

 (deftest test-empty-image
-  (let [imp1 (create-image :width 10 :height 10)]
+  (let [imp1 (create-imp :width 10 :height 10)]
     (is (zero? (:mean (get-image-statistics imp1))))))


placeholder: iterating and destructuring in Clojure

--- clojure/lazy_seq_again.clj
+++ clojure/lazy_seq_again.clj
@@ -53,3 +53,9 @@
 (defn get-square-value [{memory :memory square :square}] (get memory square))

 (println (take 50 (map get-square-value (write-squares))))
+
+(def after-747 (first (for [{memory :memory square :square} (write-squares)
+                            :when (> (get memory square) 747)]
+                        (get memory square))))
+
+(assert (= after-747 806) (str "Actual: " after-747))


Improve help

Improve help


use :db/id for elasticsearch doc id

use :db/id for elasticsearch doc id

--- src/wb_es/datomic/data/util.clj
+++ src/wb_es/datomic/data/util.clj
@@ -22,12 +22,9 @@
 (defn default-metadata
   "default implementation of the data method of Document protocol"
   [entity]
-  (let [ident (get-ident-attr entity)]
-    (if ident
-      {:_index release-id
-       :_type "generic"
-       :_id (format "%s:%s" type (ident entity))}
-      (throw (Exception. "cannot identify ident attribute of the entity")))))
+  {:_index release-id
+   :_type "generic"
+   :_id (:db/id entity)})

 (defn format-enum
   "format the datomic enum into a elasticsearch term"


Still haven't got past 6.11, haven't had time to study it...

--- src/fpinscala/purely_functional_state.clj
+++ src/fpinscala/purely_functional_state.clj
@@ -301,16 +301,29 @@
 ;there is no instance you could invoke method on

 (defn flat-map-s
-  "flatMap for exercise 6.8 from FPINS but generalized to state"
+  "flatMap for exercise 6.8 from FPINS but generalized to state for exercise 6.10"
   [f g]
   #(from-state (f %) :let [v s]
              ((g v) s)))

 (defn map-via-flat-map-s
-  "map in terms of flatMap for exercise 6.9 of FPINS"
+  "Generalized version of map-via-flat-map from exercise 6.9, for exercise 6.10"
   [s f]
   (flat-map-s s (fn [x] (unit (f x)))))

 (defn map2-via-flat-map-s
   [s1 s2 f]
-  (flat-map-s s1 (fn [a] (map-via-flat-map-s s2 #(f a %)))))+  (flat-map-s s1 (fn [a] (map-via-flat-map-s s2 #(f a %)))))
+
+(defn unit-state
+  "Generalized Unit function from section 6.5 of fpins"
+  [a]
+  (fn [rng] (make-result-state a rng)))
+
+(defn state-sequence-fpins
+  "sequence function for exercise 6.7 FPINS variant"
+  [fs]
+  (fpinscala.strictness-and-laziness/fold-right             ;Notice that this variant is using fold-right
+    (unit '())                                              ;Check out that "unit-produced" function is used as z value (now - it wouldn't be really
+    #(map2-via-flat-map-s % %2 (fn [a b] (cons a b)))                 ;correct to say it is "initial" but rather neutral (or terminating?) element
+    fs))


Change month to startdate. Change the parameter names to signify they are incoming strings.

--- src/kixi/hecuba/weather/metoffice_api.clj
+++ src/kixi/hecuba/weather/metoffice_api.clj
@@ -23,12 +23,12 @@
 (defn save-file [file-name file-content]
   (spit file-name file-content))

-(defn run-data-pull [startdate enddate]
+(defn run-data-pull [startdate-str enddate-str]
   (let [fmt (f/formatter "dd/MM/YYYY")
         timefmt (f/formatter "HH00")
-        month (f/parse fmt startdate)
-        stopdate (f/parse fmt enddate)]
-    (->> (tp/periodic-seq month (t/hours 1))
+        startdate (f/parse fmt startdate-str)
+        stopdate (f/parse fmt enddate-str)]
+    (->> (tp/periodic-seq startdate (t/hours 1))
          (take-while #(t/before? % (t/minus stopdate (t/days 1))))
          (map #(pull-data (f/unparse fmt %) (f/unparse timefmt %)))
          doall)))


try adding new dimension to queries

try adding new dimension to queries

--- src/main/clojure/org/dada/demo/whales.clj
+++ src/main/clojure/org/dada/demo/whales.clj
@@ -524,6 +524,17 @@

 (?2 [(ccount)] all-whales)

+;; these queries seem to just be too big to run with a resonably sized dataset on my home box ...
+
+;; (?2 [(split :reporter nil [(split :ocean nil [(union)(split :type nil subquery)])])] all-whales)
+
+;; (?2 [(split :reporter nil [(union)(split :ocean nil subquery)])] all-whales)
+
+;; (?2 [(split :reporter nil [
+;;      (pivot :time years (keyword (count-value-key nil)))
+;;      (split :time by-year [(ccount)])])] all-whales)
+
+
 ;;--------------------------------------------------------------------------------

 ;; create some whales...


add alternative compress implementation

add alternative compress implementation

--- clojure/ninety-nine-lisp-problems/src/ninety_nine_lisp_problems/core.clj
+++ clojure/ninety-nine-lisp-problems/src/ninety_nine_lisp_problems/core.clj
@@ -75,18 +75,26 @@
     (mapcat my-flatten-2 coll)
     (list coll)))

+;; (defn compress
+;;   "If a list contains repeated elements they should be replaced with a single copy of the element. The order of the elements should not be changed."
+;;   [coll]
+;;   (if (empty? coll)
+;;     coll
+;;     (loop [coll coll
+;;            current (first coll)
+;;            acc [(first coll)]]
+;;       (cond
+;;         (empty? coll) acc
+;;         (= (first coll) current) (recur (rest coll) current acc)
+;;         :else (recur (rest coll) (first coll) (conj acc (first coll)))))))
+
 (defn compress
   "If a list contains repeated elements they should be replaced with a single copy of the element. The order of the elements should not be changed."
   [coll]
-  (if (empty? coll)
-    coll
-    (loop [coll coll
-           current (first coll)
-           acc [(first coll)]]
-      (cond
-        (empty? coll) acc
-        (= (first coll) current) (recur (rest coll) current acc)
-        :else (recur (rest coll) (first coll) (conj acc (first coll)))))))
+  (->> coll
+       (partition-by identity)
+       (map first)))
+

 ;; (defn pack
 ;;   "Pack consecutive duplicates of list elements into sublists."


more comments to remind me in implementing statistical tests

--- statspop/src/statspop/core.cljs
+++ statspop/src/statspop/core.cljs
@@ -32,7 +32,7 @@

 ;; these above are all correct.  for p-values, I'm working with percentiles so need to subtract these percentiles from 1.  For two-tailed t-test, I should just double the p value.  Don't really need to provide p-value -> test statistic functions, should just provide test-stat to p-value functions. For z-scores, this is all standardized.  parameters for chi square and t are test statistic and degrees of freedom; parameters for normal are test statistic, mean, and sd.

-;; should also add f-distro for anova. it's all in jStat.centralF and parameters are test stat, df1, and df2.
+;; should also add f-distro for anova. it's all in jStat.centralF and parameters are test stat, df1, and df2.  Df1 is numerator. see https://github.com/jstat/jstat/blob/master/doc/md/distributions.md

 (defcard-rg test-card
   "testing devcards"


fix test (#36)

fix test (#36)

--- test/clj/lambdacd/presentation/unified_test.clj
+++ test/clj/lambdacd/presentation/unified_test.clj
@@ -24,25 +24,30 @@
   [{:name "in-parallel"
    :type :parallel
    :step-id '(1)
+   :has-dependencies false
    :result {:status :running }
    :children
    [{:name "in-cwd"
      :type :container
      :step-id '(1 1)
+     :has-dependencies false
      :result {}
      :children [{:name "do-stuff"
                  :type :step
                  :step-id '(1 1 1)
+                 :has-dependencies false
                  :children []
                  :result {:status :failure
                           :out "do stuff failed"}}]}
     {:name "in-cwd"
      :type :container
      :step-id '(2 1)
+     :has-dependencies false
      :result {}
      :children [{:name "do-other-stuff"
                  :type :step
                  :step-id '(1 2 1)
+                 :has-dependencies false
                  :children []
                  :result {:status :running :some-key :some-value}}]}]}])


reorder defn of unqualify-symbol

reorder defn of unqualify-symbol

--- src/kondolisp/compiler.clj
+++ src/kondolisp/compiler.clj
@@ -85,6 +85,12 @@
 	idx
 	(recur (+ idx 1) pred (rest coll)))))
   (inner-index 0 pred coll))
+
+(defn unqualify-symbol [sym]
+  (let [sym-ns (namespace sym)]
+    (if sym-ns
+      (symbol (subs (str sym) (+ 1 (count sym-ns))))
+      sym)))

 (defn #^{:doc "Encode a VM instruction to bytes"}
   encode-inst [inst]
@@ -180,12 +186,6 @@
    (= val (make-t)) "T"
    (= (bit-and 0x8001 val) 0x8001) (format "%d" (decode-num val))
    (= (bit-and 0xc001 val) 0x4001) (format "'%s" (decode-sym val))))
-
-(defn unqualify-symbol [sym]
-  (let [sym-ns (namespace sym)]
-    (if sym-ns
-      (symbol (subs (str sym) (+ 1 (count sym-ns))))
-      sym)))

 (defn pp-program [insts]
   (dotimes [i (count insts)]


Remove dot

Remove dot

--- src-cljs/frontend/components/project_settings.cljs
+++ src-cljs/frontend/components/project_settings.cljs
@@ -335,7 +335,7 @@

                (button/link {:kind :primary
                              :href (common/contact-support-a-info owner)}
-                            "Contact us for more.")]
+                            "Contact us for more")]

               (> parallelism (project-model/buildable-parallelism plan project))
               [:div.insufficient-containers


Proper capitaliation

Proper capitaliation

--- src-cljs/frontend/components/project_settings.cljs
+++ src-cljs/frontend/components/project_settings.cljs
@@ -292,7 +292,7 @@
                               :result-path
                               (conj state/project-data-path :source-cache-clear))))
            [:p "CircleCI saves a copy of your source code on our system and pulls only changes since the last build on each branch."]
-           [:p [:b "NOTE: "] "Clearing your source cache will cause the next build to download a fresh copy of your source. In some cases this can add considerable time to that build.  Doing this too frequently or when you have a large number of high parallelism builds also carries some risk of becoming rate-limited by github, which will prevent your builds from being able to download source until the rate-limit expires.  Also, you may need to ensure that you have no running builds when using this to prevent the old cache from being resaved."]
+           [:p [:b "NOTE: "] "Clearing your source cache will cause the next build to download a fresh copy of your source. In some cases this can add considerable time to that build.  Doing this too frequently or when you have a large number of high parallelism builds also carries some risk of becoming rate-limited by GitHub, which will prevent your builds from being able to download source until the rate-limit expires.  Also, you may need to ensure that you have no running builds when using this to prevent the old cache from being resaved."]
            [:hr]
            (clear-cache-button "source" project-data owner)]]]))))