set fix start and end dates

set fix start and end dates

--- src/clj/ceres/curator.clj
+++ src/clj/ceres/curator.clj
@@ -31,6 +31,9 @@
 (def tokenize (make-tokenizer "data/de-token.bin"))
 (def stopwords (read-string "data/stopwords.txt"))

+(def start-date (t/date-time 2014 7 1))
+(def end-date (t/date-time 2014 10 1))
+
 ;; --- DATA MINING ---

 (defn get-news-frequencies
@@ -42,14 +45,14 @@
           (mc/count
            @db "tweets"
            {:user.screen_name %
-            :created_at {$gt (t/date-time 2014 7 1)}})])
+            :created_at {$gt start-date}})])
     news-accounts)))

 (defn get-tweet-count
   "Compute overall tweet count"
   []
-  (mc/count @db "tweets" {:created_at {$gt (t/date-time 2014 7 1)}}))
+  (mc/count @db "tweets" {:created_at {$gt start-date}}))

 (defn get-tweets-from-date
@@ -75,7 +78,7 @@
                               "tweets"
                               {$and [{$or [{"retweeted_status.id_str" tweet-id}
                                            {"in_reply_to_status_id_str" tweet-id}]}
-                                     {:created_at {$gt (t/date-time 2014 7 1)}}]}
+                                     {:created_at {$gt start-date}}]}
                               [:text :user.screen_name :id_str :in_reply_to_status_id_str :retweeted_status.id_str])
                              (pmap #(assoc % :parents (into parents [(:_id tweet)]))))
         neightbar-ids (pmap :id_str neighbor-tweets)]
@@ -97,7 +100,7 @@
                          "tweets"
                          {$and [{$or [{"retweeted_status.id_str" tweet-id}
                                       {"in_reply_to_status_id_str" tweet-id}]}
-                                {:created_at {$gt (t/date-time 2014 7 1)}}]})]
+                                {:created_at {$gt start-date}}]})]
     (Reaction. tweet (vec (pmap spread neighbor-tweets)))))

@@ -120,7 +123,8 @@
                           "tweets"
                           {$and [{$or [{"retweeted_status.id_str" (:id_str tweet)}
                                        {"in_reply_to_status_id_str" (:id_str tweet)}]}
-                                 {:created_at {$gt (t/date-time 2014 7 1)}}]})
+                                 {:created_at {$gt start-date
+                                               $lt end-date}}]})
           merged-articles (into related-origins related-tweets)]
       (zip/zipper
        (fn [node] true)
@@ -139,8 +143,12 @@
 (defn compute-impact-forest
   "Compute article impact forest of given news source"
   [source]
-  (let [source-origins (mc/find-maps @db "origins" {:source source :ts {$gt (t/date-time 2014 7 1)
-                                                                        $lt (t/date-time 2014 8 1)}})]
+  (let [source-origins (mc/find-maps
+                        @db
+                        "origins"
+                        {:source source
+                         :ts {$gt start-date
+                              $lt end-date}})]
     (vec (pmap compute-impact-tree source-origins))))

@@ -148,7 +156,7 @@
   (loop [counter 0
          max-path 0
          users []
-;;         tokens []
+         tokens []
          pub-times []
          hashtags []
          delays []
@@ -157,7 +165,7 @@
       {:size counter
        :height max-path
        :users users
-       ;;:tokens tokens
+       :tokens tokens
        :pub-times pub-times
        :hashtags (mapv #(-> % :text clojure.string/lower-case) hashtags)
        :delays delays}
@@ -172,7 +180,7 @@
          (let [user (-> node :tweet :user)]
              (conj users (:screen_name user)))
          users)
-       #_(if (zip/node loc)
+       (if (zip/node loc)
          (conj
           tokens
           (clojure.set/difference
@@ -204,7 +212,9 @@

 (defn random-tree []
-  (let [origin (rand-nth (mc/find-maps @db "origins" {:source {$in news-accounts}}))
+  (let [origin (rand-nth (mc/find-maps @db "origins" {:source {$in news-accounts}
+                                                      :ts {$gt start-date
+                                                           $lt end-date}}))
         tree (compute-impact-tree origin)]
     {:title (:title (mc/find-map-by-id @db "articles" (:article origin)))
      :tree tree
@@ -274,7 +284,6 @@
       (:_id x)
       (update-in x [:created_at] #(f/parse custom-formatter (:created_at %))) )))

-  (mc/indexes-on @db "tweets")

   (def some-tree (build-tree-from-source (ObjectId. "53fcc425e4b09b711bdec9a9" )))

@@ -282,18 +291,9 @@

   (def rand-tree (time (random-tree)))

-  (loop [counter 10]
-    (if (= counter 0)
-      :true
-      (do (time (random-tree))
-          (recur (dec counter)))))
-
-
   (-> rand-tree :analysis :height)

   (-> rand-tree :analysis :size)
-
-  (-> rand-tree :tree ffirst second :_id aprint)

   (-> rand-tree :analysis aprint)

@@ -313,149 +313,78 @@

   (lio/view g)

-  (let [user (-> rand-tree second :users last)
-        tweets (mc/find-maps @db "tweets" {:user.screen_name user})]
-    (->> tweets
-         (mapv spread)
-         ffirst
-         aprint
-         time))
-
-
-
-  (def sum-tagesschau (time (compute-summary "tagesschau")))
-
-  (def sum-faz (compute-summary "FAZ_NET"))
-
-  (def sum-sz (compute-summary "SZ"))
-
-  (def sum-spon (compute-summary "SPIEGELONLINE"))
-
-  (def sum-welt (compute-summary "welt"))
-
-
-
-  ;; publication time of day
-  (let [sz-hours (->> sum-sz
-                       :pub-times
-                       flatten
-                       (map t/hour)
-                       frequencies
-                       (sort-by key <))]
-    (view (line-chart (keys sz-hours) (vals sz-hours))))
-
-
-  ;; reaction delay
-  (let [delays (->>  sum-sz
-                     :delays
-                     (remove #(= % 0))
-                     (remove #(> % 3600))
-                     frequencies
-                     (sort-by key <))]
-    (view (line-chart (keys delays) (vals delays))))
-
-
-  ;; daily tweet counts
-  (let [days (t/in-days (t/interval (t/date-time 2014 8 1) (t/date-time 2014 9 15)))
-        dates (take days (p/periodic-seq (t/date-time 2014 8 1) (t/days 1)))
-        tweet-counts (map
-                      (fn [date]
-                        (->> sum-sz
-                             :pub-times
-                             flatten
-                             (filter #(and (t/after? % date) (t/before? % (t/plus date (t/days 1)))))
-                             count))
-                      dates)]
-    (view (line-chart (range 1 (inc days)) tweet-counts)))
-
-
-
   ;; tweet counts
-  (let [days-running (t/in-days (t/interval (t/date-time 2014 7 2) (t/date-time 2014 10 12)))
-        dates (take days-running (p/periodic-seq (t/date-time 2014 7 2) (t/days 1)))
+  (let [days-running (t/in-days (t/interval start-date end-date))
+        dates (take days-running (p/periodic-seq start-date (t/days 1)))
         sz-tweet-count (map #(mc/count @db "tweets" {:user.screen_name "SZ" :created_at {$gte % $lt (t/plus % (t/days 1))}}) dates)
         spon-tweet-count (map #(mc/count @db "tweets" {:user.screen_name "SPIEGELONLINE" :created_at {$gte % $lt (t/plus % (t/days 1))}}) dates)
         faz-tweet-count (map #(mc/count @db "tweets" {:user.screen_name "FAZ_NET" :created_at {$gte % $lt (t/plus % (t/days 1))}}) dates)
         bild-tweet-count (map #(mc/count @db "tweets" {:user.screen_name "BILD" :created_at {$gte % $lt (t/plus % (t/days 1))}}) dates)
         tagesschau-tweet-count (map #(mc/count @db "tweets" {:user.screen_name "tagesschau" :created_at {$gte % $lt (t/plus % (t/days 1))}}) dates)
         days-since-start (apply concat (repeat 5 (range days-running)))
-        ;; tweet-count-2 (loop [hours-list [] tweet-dist tweet-count] (if (empty? tweet-dist) hours-list (recur (conj hours-list (vec (take 24 tweet-dist))) (drop 24 tweet-dist))))
-        ;; avg-tweets-per-hour (map (fn [hour] (/ (reduce + (map (fn [count] (get count hour)) tweet-count-2)) (count tweet-count-2))) (range 24))
         tweet-counts (concat sz-tweet-count spon-tweet-count faz-tweet-count bild-tweet-count tagesschau-tweet-count)
         grouping (apply concat (map #(repeat (count sz-tweet-count) %) ["sz" "spon" "faz" "bild" "tagesschau"]))]
     (view (line-chart days-since-start tweet-counts :legend true :group-by grouping)))

-  (let [days-running (t/in-hours (t/interval (t/date-time 2014 7 2) (t/date-time 2014 10 12)))
-        dates (take days-running (p/periodic-seq (t/date-time 2014 7 2) (t/hours 1)))
+  (let [days-running (t/in-hours (t/interval start-date end-date))
+        dates (take days-running (p/periodic-seq start-date (t/hours 1)))
         tweet-count (map #(mc/count @db "tweets" {:created_at {$gte % $lt (t/plus % (t/hours 1))}}) dates)
-        time (range days-running)
+        times (range days-running)
         tweet-count-2 (loop [hours-list []
                              tweet-dist tweet-count]
                         (if (empty? tweet-dist)
                           hours-list
                           (recur (conj hours-list (vec (take 24 tweet-dist))) (drop 24 tweet-dist))))
         avg-tweets-per-hour (map (fn [hour] (/ (reduce + (map (fn [count] (get count hour)) tweet-count-2)) (count tweet-count-2))) (range 24))]
-    (view (line-chart time tweet-count))
+    (view (line-chart times tweet-count))
     (view (line-chart (range 24) avg-tweets-per-hour)))

-  (let [days-running (t/in-days (t/interval (t/date-time 2014 7 2) (t/date-time 2014 10 13)))
-        dates (take days-running (p/periodic-seq (t/date-time 2014 7 2) (t/days 1)))
+  (let [days-running (t/in-days (t/interval start-date end-date))
+        dates (take days-running (p/periodic-seq start-date (t/days 1)))
         tweet-count (map #(mc/count @db "tweets" {:created_at {$gte % $lt (t/plus % (t/days 1))}}) dates)
         days (range  2 (inc (inc days-running)))]
-    (view (scatter-plot days tweet-count :title "tweet counts" :y-label "Tweet Count" :x-label "Day")))
-
-
-  ;; user posts distribution
-  (let [users (->> (mc/find-maps
-                    @db "tweets"
-                    {$and
-                     [
-                      {:created_at {$gt (t/date-time 2014 7 1)
-                                    $lt (t/date-time 2014 10 1)}}
-                      {:user.screen_name {$ne news-accounts}}]
-                     ["user.screen_name"]})
-                   (pmap #(-> % :user :screen_name))
-                   frequencies)
-        unique-posters #(float (/ (count %) (count users)))
-        post-counter (frequencies (vals users))]
-    (->> users
-         (sort-by second >)
-         (take 10)
-         aprint))
+    (view (line-chart days tweet-count :title "tweet counts" :y-label "Tweet Count" :x-label "Day")))

   ;; news posts fraction
-  (let [overall-count (mc/count @db "tweets" {:created_at {$gt (t/date-time 2014 7 1)}})
+  (let [overall-count (mc/count @db "tweets" {:created_at {$gt start-date
+                                                           $lt end-date}})
         news-count (mc/count
-                    @db "tweets" {$and [{:created_at {$gt (t/date-time 2014 7 1)}}
+                    @db "tweets" {$and [{:created_at {$gt start-date
+                                                      $lt end-date}}
                                         {:user.screen_name {$in news-accounts} }]})]
     (aprint (float (/ news-count overall-count))))

-  (def origin (time (rand-nth (mc/find-maps @db "origins" {:source {$in news-accounts}}))))
-
-  (println "\n")
-
-  (def tree (time (compute-impact-tree origin)))
-
   (def dpa-sum (time (compute-summary "dpa")))

-  (aprint (keys dpa-sum))
-
-  (def tagesschau-sum (time (compute-summary "tagesschau")))
-
   (aprint (dissoc dpa-sum :heights :sizes :users :hashtags :pub-times :no-reactions :delays))

-
-  (->> (mc/find-maps @db "tweets" {:created_at {$gt (t/date-time 2014 7 1)
-                                                $lt (t/date-time 2014 10 1)}}
-                     [:user.id_str])
-       (pmap #(-> % :user :id_str))
-       (into #{})
-       count
-       aprint
-       time)
+  (let [heights (->> dpa-sum :heights frequencies (sort-by second >))]
+    (view (line-chart (keys heights) (vals heights))))
+
+  (let [sizes (->> dpa-sum :sizes frequencies (sort-by second >))]
+    (view (line-chart (keys sizes) (vals sizes))))
+
+  (->> dpa-sum
+       :hashtags
+       frequencies
+       (sort-by second >)
+       (take 50)
+       aprint)
+
+  ;; article percentage with no reactions
+  (->> dpa-sum
+       :no-reactions
+       aprint)
+
+  ;; avg delay time
+  (let [delay-sum (->> dpa-sum
+                        :delays
+                        (remove #(= % 0))
+                        (reduce +))]
+    (aprint (/ (float (/ delay-sum (count (remove #(= % 0) (:delays dpa-sum))))) 60)))

   )


implement user extendable coercions

implement user extendable coercions

--- src/clj/clj_json/core.clj
+++ src/clj/clj_json/core.clj
@@ -1,11 +1,27 @@
 (ns clj-json.core
   (:import (clj_json JsonExt)
            (org.codehaus.jackson JsonFactory JsonParser JsonParser$Feature)
+<<<<<<< HEAD
            (java.io StringWriter StringReader BufferedReader)))
+=======
+           (java.io StringWriter StringReader BufferedReader))
+  (:use (clojure.contrib [def :only (defvar-)])
+        (clojure [walk :only (postwalk)]
+                 [string :only (join)])))
+>>>>>>> implement user extendable coercions

 (def ^{:tag JsonFactory, :private true} factory
   (doto (JsonFactory.)
     (.configure JsonParser$Feature/ALLOW_UNQUOTED_CONTROL_CHARS true)))
+
+(def *coercions* {clojure.lang.IPersistentSet vec
+                  clojure.lang.Keyword (fn [x] (join "/" (remove nil? ((juxt namespace name) x))))})
+
+(defn- coerce [obj]
+  (postwalk (fn [x]
+              (if-let [coercion (seq (filter #(instance? (key %) x) *coercions*))]
+                ((-> coercion first val) x)
+                x)) obj))

 (defn generate-string
   "Returns a JSON-encoding String for the given Clojure object."
@@ -13,7 +29,7 @@
   [obj]
   (let [sw        (StringWriter.)
         generator (.createJsonGenerator factory sw)]
-    (JsonExt/generate generator obj)
+    (JsonExt/generate generator (coerce obj))
     (.flush generator)
     (.toString sw)))


CLJS-408: Include :form key on fn :methods

--- src/clj/cljs/analyzer.clj
+++ src/clj/cljs/analyzer.clj
@@ -360,11 +360,11 @@
              (when export-as {:export export-as})
              (when init-expr {:children [init-expr]})))))

-(defn- analyze-fn-method [env locals meth type]
-  (let [param-names (first meth)
+(defn- analyze-fn-method [env locals form type]
+  (let [param-names (first form)
         variadic (boolean (some '#{&} param-names))
         param-names (vec (remove '#{&} param-names))
-        body (next meth)
+        body (next form)
         [locals params] (reduce (fn [[locals params] name]
                                   (let [param {:name name
                                                :tag (-> name meta :tag)
@@ -376,7 +376,7 @@
         block (binding [*recur-frames* (cons recur-frame *recur-frames*)]
                 (analyze-block (assoc env :context :return :locals locals) body))]
     (merge {:env env :variadic variadic :params params :max-fixed-arity fixed-arity
-            :type type :recurs @(:flag recur-frame)}
+            :type type :form form :recurs @(:flag recur-frame)}
            block)))

 (defmethod parse 'fn*


Normalize crypto api.

Normalize crypto api.

--- src/buddy/core/crypto.clj
+++ src/buddy/core/crypto.clj
@@ -20,8 +20,9 @@
             [buddy.core.nonce :as nonce]
             [buddy.core.codecs :as codecs])
   (:import org.bouncycastle.crypto.engines.TwofishEngine
+           org.bouncycastle.crypto.engines.SerpentEngine
            org.bouncycastle.crypto.engines.BlowfishEngine
-           org.bouncycastle.crypto.engines.AESEngine
+           org.bouncycastle.crypto.engines.AESFastEngine
            org.bouncycastle.crypto.engines.ChaChaEngine
            org.bouncycastle.crypto.modes.CBCBlockCipher
            org.bouncycastle.crypto.modes.SICBlockCipher
@@ -38,24 +39,28 @@
            clojure.lang.IFn
            clojure.lang.Keyword))

-(def ^{:doc "Supported block cipher modes."
-       :dynamic true}
-  *supported-modes* {:ecb #(identity %)
-                     :cbc #(CBCBlockCipher. %)
-                     :gcm #(GCMBlockCipher. %)
-                     :ctr #(SICBlockCipher. %)
-                     :sic #(SICBlockCipher. %)
-                     :ofb #(OFBBlockCipher. %1 (* 8 (.getBlockSize %1)))})
-
-(def ^{:doc "Supported block ciphers."
-       :dynamic true}
-  *supported-block-ciphers* {:twofish #(TwofishEngine.)
-                             :blowfish #(BlowfishEngine.)
-                             :aes #(AESEngine.)})
-
-(def ^{:doc "Supported block ciphers."
-       :dynamic true}
-  *supported-stream-ciphers* {:chacha #(ChaChaEngine.)})
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Protocols
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(def ^:no-doc
+  +block-cipher-engines+
+  {:aes     #(AESFastEngine.)
+   :serpent #(SerpentEngine.)
+   :twofish #(TwofishEngine.)})
+
+(def ^:no-doc
+  +stream-cipher-engines+
+  {:chacha #(ChaChaEngine.)})
+
+(def ^{:doc false}
+  +cipher-modes+
+  {:ecb #(identity %)
+   :cbc #(CBCBlockCipher. %)
+   :gcm #(GCMBlockCipher. %)
+   :ctr #(SICBlockCipher. %)
+   :sic #(SICBlockCipher. %)
+   :ofb #(OFBBlockCipher. % (* 8 (.getBlockSize %)))})

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Cipher protocol declaration.
@@ -63,21 +68,21 @@

 (defprotocol IBlockCipher
   "Common protocol to block ciphers."
-  (^:private get-block-size* [_] "Get block size in bytes."))
+  (-block-size [_] "Get block size in bytes."))

 (defprotocol IStreamCipher
   "Common protocol to stream ciphers.")

 (defprotocol ICipher
   "Common protocol to both, stream and block ciphers."
-  (^:private initialize [_ params] "Initialize cipher")
-  (^:private process-bytes [_ input] [_ input inoffset output outoffset]
+  (-init [_ params] "Initialize cipher")
+  (-process-bytes [_ input] [_ input inoffset output outoffset]
     "Encrypt/Decrypt a block of bytes."))

 (defprotocol IAEADBlockCipher
   "Common protocol to Authenticated Cipher."
-  (^:private calculate-authtag [_ output outoffset] "Calculate the authentication tag.")
-  (^:private get-output-size* [_ data] "Get the output size."))
+  (-auth-tag [_ output outoffset] "Calculate the authentication tag.")
+  (-output-size [_ data] "Get the output size."))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Implementation details.
@@ -86,7 +91,7 @@
 (extend-type StreamCipher
   IStreamCipher
   ICipher
-  (initialize [engine params]
+  (-init [engine params]
     (let [iv (:iv params)
           key (:key params)
           params' (if (nil? iv)
@@ -98,7 +103,7 @@
       (.init engine encrypt params')
       engine))

-  (process-bytes
+  (-process-bytes
     ([engine input]
      (let [len    (count input)
            buffer (byte-array len)]
@@ -109,11 +114,11 @@

 (extend-type BlockCipher
   IBlockCipher
-  (get-block-size* [engine]
+  (-block-size [engine]
     (.getBlockSize engine))

   ICipher
-  (initialize [engine params]
+  (-init [engine params]
     (let [iv (:iv params)
           key (:key params)
           params' (if (nil? iv)
@@ -125,9 +130,9 @@
       (.init engine encrypt params')
       engine))

-  (process-bytes
+  (-process-bytes
     ([engine input]
-     (let [buffer (byte-array (get-block-size* engine))]
+     (let [buffer (byte-array (-block-size engine))]
        (.processBlock engine input 0 buffer 0)
        buffer))
     ([engine input inoffset output outoffset]
@@ -135,18 +140,18 @@

 (extend-type AEADBlockCipher
   IAEADBlockCipher
-  (get-output-size* [engine length]
+  (-output-size [engine length]
     (.getOutputSize engine length))

-  (calculate-authtag [engine output outoffset]
+  (-auth-tag [engine output outoffset]
     (.doFinal engine output outoffset))

   IBlockCipher
-  (get-block-size* [engine]
-    (get-block-size* (.getUnderlyingCipher engine)))
+  (-block-size [engine]
+    (-block-size (.getUnderlyingCipher engine)))

   ICipher
-  (initialize [engine params]
+  (-init [engine params]
     (let [iv (:iv params)
           key (:key params)
           aad (:aad params)
@@ -159,9 +164,9 @@
       (.init engine encrypt params')
       engine))

-  (process-bytes
+  (-process-bytes
     ([engine input]
-     (let [buffer (byte-array (get-block-size* engine))]
+     (let [buffer (byte-array (-block-size engine))]
        (.processBytes engine input 0 buffer 0)
        buffer))

@@ -176,46 +181,46 @@
 (defn- algorithm-supported?
   [^Keyword type ^Keyword cipher]
   (condp = type
-    :block (contains? *supported-block-ciphers* cipher)
-    :stream (contains? *supported-stream-ciphers* cipher)))
+    :block (contains? +block-cipher-engines+ cipher)
+    :stream (contains? +stream-cipher-engines+ cipher)))

 (defn- mode-supported?
-  [^Keyword mode]
-  (contains? *supported-modes* mode))
+  [mode]
+  (contains? +cipher-modes+ mode))

 (defn get-block-size
   "Given a block cipher, return the block size
   in bytes."
-  [^BlockCipher engine]
-  (get-block-size* engine))
+  [engine]
+  (-block-size engine))

 (defn get-output-size
   "Given a aead cipher, return the buffer size required for
   a `process-bytes!` plus a `calculate-authtag!` with an input of
   `len` bytes."
-  [^AEADBlockCipher engine ^long len]
-  (get-output-size* engine len))
+  [engine len]
+  (-output-size engine len))

 (defn block-cipher
   "Block cipher engine constructor."
-  [^Keyword alg ^Keyword mode]
+  [alg mode]
   {:pre [(algorithm-supported? :block alg)
          (mode-supported? mode)]}
-  (let [modefactory (get *supported-modes* mode)
-        enginefactory (get *supported-block-ciphers* alg)]
+  (let [modefactory (get +cipher-modes+ mode)
+        enginefactory (get +block-cipher-engines+ alg)]
     (modefactory (enginefactory))))

 (defn stream-cipher
   "Stream cipher engine constructor."
   [^Keyword alg]
   {:pre [(algorithm-supported? :stream alg)]}
-  (let [enginefactory (get *supported-stream-ciphers* alg)]
+  (let [enginefactory (get +stream-cipher-engines+ alg)]
     (enginefactory)))

 (defn initialize!
   "Initialize the cipher engine."
   [engine {:keys [iv key op] :as params}]
-  (initialize engine params))
+  (-init engine params))

 (defn process-bytes!
   "Encrypt or decrypt a block of bytes using the specified engine.
@@ -223,9 +228,9 @@
   crypto engine. A great example are stream cipher engine
   that allows blocks of 1 byte lenght."
   ([engine input]
-   (process-bytes engine input))
+   (-process-bytes engine input))
   ([engine input inoffset output outoffset]
-   (process-bytes engine input inoffset output outoffset)))
+   (-process-bytes engine input inoffset output outoffset)))

 (defn process-block!
   "Encrypt or decrypt a block of bytes using the specified engine.
@@ -234,13 +239,13 @@
   that allows blocks of 1 byte lenght.
   This is an alias to `process-bytes! function."
   ([engine input]
-   (process-bytes engine input))
+   (-process-bytes engine input))
   ([engine input inoffset output outoffset]
-   (process-bytes engine input inoffset output outoffset)))
+   (-process-bytes engine input inoffset output outoffset)))

 (defn calculate-authtag!
   [engine output offset]
-  (calculate-authtag engine output offset))
+  (-auth-tag engine output offset))

 (defn split-by-blocksize
   "Split a byte array in blocksize blocks.


emit source map info for every AST node not just vars

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -130,6 +130,24 @@

 (defn emit [ast]
   (env/ensure
+    (when *source-map-data*
+      (let [{:keys [env]} ast]
+        (when (:line env)
+          (let [{:keys [line column]} env]
+            (swap! *source-map-data*
+              (fn [m]
+                (let [minfo (cond-> {:gcol (:gen-col m)
+                                     :gline (:gen-line m)}
+                              (= (:op ast) :var)
+                              (assoc :name (-> ast :info :name)))]
+                  ; Dec the line number for 0-indexed line numbers.
+                  ; tools.reader has 0-indexed line number, chrome
+                  ; expects 1-indexed source maps.
+                  (update-in m [:source-map (dec line)]
+                    (fnil (fn [line]
+                            (update-in line [(or column 0)]
+                              (fnil (fn [column] (conj column minfo)) [])))
+                      (sorted-map))))))))))
     (emit* ast)))

 (defn emits [& xs]
@@ -240,22 +258,6 @@
         info (if (= (namespace var-name) "js")
                (name var-name)
                info)]
-    (when *source-map-data*
-      (when (and (:line env) (symbol? var-name))
-        (let [{:keys [line column]} env]
-          (swap! *source-map-data*
-            (fn [m]
-              (let [minfo {:gcol  (:gen-col m)
-                           :gline (:gen-line m)
-                           :name  var-name}]
-                ; Dec the line number for 0-indexed line numbers.
-                ; tools.reader has 0-indexed line number, chrome
-                ; expects 1-indexed source maps.
-                (update-in m [:source-map (dec line)]
-                  (fnil (fn [line]
-                          (update-in line [(or column 0)]
-                            (fnil (fn [column] (conj column minfo)) [])))
-                    (sorted-map)))))))))
     ; We need a way to write bindings out to source maps and javascript
     ; without getting wrapped in an emit-wrap calls, otherwise we get
     ; e.g. (function greet(return x, return y) {}).


the beginning of a mapping structure from the CLJS compiler output

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -32,16 +32,22 @@
     "transient" "try" "typeof" "var" "void"
     "volatile" "while" "with" "yield" "methods"})

-(def ^:dynamic *cljs-mappings* (atom [[]]))
+(def ^:dynamic *cljs-mappings* (atom {}))
 (def ^:dynamic *cljs-gen-col* (atom 0))
+(def ^:dynamic *cljs-gen-line* (atom 0))

 (defn reset-mappings! []
-  (reset! *cljs-mappings* [[]])
-  (reset! *cljs-gen-col* 0))
+  (reset! *cljs-mappings* {})
+  (reset! *cljs-gen-col* 0)
+  (reset! *cljs-gen-line* 0))

 (def ^:dynamic *position* nil)
 (def ^:dynamic *emitted-provides* nil)
 (def cljs-reserved-file-names #{"deps.cljs"})
+
+(defmacro ^:private debug-prn
+  [& args]
+  `(.println System/err (str ~@args)))

 (defn munge
   ([s] (munge s js-reserved))
@@ -91,18 +97,7 @@
      (map? x) (emit x)
      (seq? x) (apply emits x)
      (fn? x)  (x)
-     :else (let [m (when (symbol? x)
-                     (-> x meta))
-                 s (print-str x)]
-             (swap! *cljs-mappings*
-                    (fn [lines]
-                      (let [last (conj (peek lines)
-                                       (merge {:file ana/*cljs-file*
-                                               :gcol @*cljs-gen-col*}
-                                              (when m {:line (:line m)
-                                                       :col (or (:col m) 0)
-                                                       :name (:name m)})))]
-                        (conj (pop lines) last))))
+     :else (let [s (print-str x)]
              (swap! *cljs-gen-col* (fn [col] (+ col (count s))))
              (print s))))
   nil)
@@ -113,9 +108,7 @@
 (defn emitln [& xs]
   (apply emits xs)
   (println)
-  (swap! *cljs-mappings*
-         (fn [lines]
-           (conj lines [])))
+  (swap! *cljs-gen-line* inc)
   (reset! *cljs-gen-col* 0)
   nil)

@@ -207,15 +200,24 @@
 (defmethod emit :var
   [{:keys [info env] :as arg}]
   (let [n (:name info)
-        n (if (symbol? n)
-            (vary-meta n
-              (fn [m]
-                (merge m {:line (:line env)
-                          :name (:name info)})))
-            n)
         n (if (= (namespace n) "js")
             (name n)
             n)]
+    (when (and (:line env) (symbol? n))
+      (let [{:keys [line col]} env]
+        (swap! *cljs-mappings*
+          (fn [m]
+            (let [minfo {:gcol @*cljs-gen-col*
+                         :gline @*cljs-gen-line*
+                         :name n}]
+              (update-in m [ana/*cljs-file*]
+                (fnil (fn [m]
+                        (update-in m [line]
+                          (fnil (fn [m]
+                                  (update-in m [(or col 0)]
+                                    (fnil (fn [v] (conj v minfo)) [])))
+                            (sorted-map))))
+                  (sorted-map))))))))
     (emit-wrap env (emits (munge n)))))

 (defmethod emit :meta


* src/clj/cljs/compiler.clj: line -> gline, col -> gcol

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -238,8 +238,8 @@
       :else (let [s (print-str x)]
               (when *position*
                 (swap! *position*
-                  (fn [{:keys [line col]}]
-                    {:line line :col (+ col (count s))})))
+                  (fn [{:keys [gline gcol]}]
+                    {:gline gline :gcol (+ gcol (count s))})))
               (print s))))
   nil)

@@ -255,8 +255,8 @@
   (println)
   (when *position*
     (swap! *position*
-      (fn [{:keys [line col]}]
-        {:line (inc line) :col 0})))
+      (fn [{:keys [gline gcol]}]
+        {:gline (inc gline) :gcol 0})))
   nil)

 (defmulti emit-constant class)
@@ -1584,7 +1584,7 @@
       (binding [*out* out
                 *cljs-ns* 'cljs.user
                 *cljs-file* (.getPath ^java.io.File src)
-                *position* (atom {:line 0 :col 0})]
+                *position* (atom {:gline 0 :gcol 0})]
         (loop [forms (forms-seq src)
                ns-name nil
                deps nil]


Fix bug preventing Node REPL from using cached files

Node.js compiled cljs.core w/o setting :optimizations. Change
`cljs.compiler/compile-file` to merge `opts` with default
optimization setting. Now source map handling logic and
`cljs.compiler/require-compilation?` work correctly.

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -910,7 +910,7 @@
                                :source-file src}
                               (when sm-data
                                 {:source-map (:source-map sm-data)}))]
-                    (when (and sm-data (contains? #{:none nil} (:optimizations opts)))
+                    (when (and sm-data (= (:optimizations opts) :none))
                       (let [sm-file (io/file (str (.getPath ^File dest) ".map"))]
                         (emits "\n//# sourceMappingURL=" (.getName sm-file)
                           (if (true? (:source-map-timestamp opts))
@@ -964,8 +964,9 @@
   ([src dest]
     (compile-file src dest nil))
   ([src dest opts]
-    (let [src-file (io/file src)
-          dest-file (io/file dest)]
+    (let [src-file  (io/file src)
+          dest-file (io/file dest)
+          opts      (merge {:optimizations :none} opts)]
       (if (.exists src-file)
         (try
           (let [{ns :ns :as ns-info} (ana/parse-ns src-file dest-file opts)]


Add pair type annotations to state monad (#217)

--- src/cats/monad/state.cljc
+++ src/cats/monad/state.cljc
@@ -4,7 +4,8 @@
             [cats.core :as m]
             [cats.data :as d]
             [cats.protocols :as p]
-            [cats.util :as util]))
+            [cats.util :as util])
+  (:import (cats.data Pair)))

 (declare context)

@@ -73,7 +74,7 @@

     (-mbind [_ self f]
       (state (fn [s]
-               (let [p          ((p/-extract self) s)
+               (let [^Pair p  ((p/-extract self) s)
                      value    (.-fst p)
                      newstate (.-snd p)]
                  ((p/-extract (f value)) newstate)))))


world updates

world updates

--- src/clojure/yaw/world.clj
+++ src/clojure/yaw/world.clj
@@ -120,6 +120,7 @@
                       mesh     (create-mesh! world)}}]         ;;error here
   (.createItemObject world id (position 0) (position 1) (position 2) scale mesh))

+
 (defn remove-item!
   "Remove the specified `item` from the `world`"
   [world item]
@@ -139,7 +140,7 @@
                    scale    1
                    position [0 0 -2]
                    id (str (gensym "block-"))}}]
-  (create-item! world :id id
+  (create-item! world id
                 :position position
                 :scale scale
                 :mesh (create-simple-mesh! world :rgb color)))
@@ -152,8 +153,8 @@
                    color    [0 0 1]
                    scale    1
                    position [0 0 -2]
-                   id       ""}}]
-  (create-item! world :id id
+                   id (str (gensym "pyra-"))}}]
+  (create-item! world id
                 :position position
                 :scale scale
                 :mesh (create-simple-mesh! world :rgb color :geometry (yaw.mesh/pyramid-geometry))))
@@ -315,7 +316,8 @@
                        :or   {x 0
                               y 0
                               z 0}}]
-  (.rotate item x y z))
+  (.rotateXYZ item x y z))
+
 (defn translate! [item & {:keys [x y z]
                           :or   {x 0
                                  y 0


Add - to Number instances

Add - to Number instances

--- src/clojure_ruby/core.clj
+++ src/clojure_ruby/core.clj
@@ -62,6 +62,9 @@
              "+" (fn number-plus [this other]
                    (let [other (host-send other :number)]
                      (create-number (+ (:data this) other))))
+             "-" (fn number-minus [this other]
+                   (let [other (host-send other :number)]
+                     (create-number (- (:data this) other))))
              "==" (fn number-equal [this other]
                     (let [other (host-send other :number)]
                       (= (:data this) other)))}


throw entire error message

throw entire error message

--- src/clj_docker/client.clj
+++ src/clj_docker/client.clj
@@ -11,7 +11,8 @@
   (post   [this path opts]))

 (defn- make-opts [opts]
-  (merge {} opts))
+  (merge {:throw-entire-message? true}
+         opts))

 (def methods {:get    http/get
               :post   http/post


Fixes #4 : Gyptis doesn't recognize joda time datetime

--- src/cljc/gyptis/util.cljc
+++ src/cljc/gyptis/util.cljc
@@ -1,7 +1,6 @@
 (ns gyptis.util
   #?(:clj
-     (:require [clojure.data.json :as json]
-               [clj-time.format :as f])))
+     (:require [clojure.data.json :as json])))

 (defn merge-spec
   "Similar to how leiningen merges profiles:
@@ -39,18 +38,6 @@
   ([k m]
    (ensure-key k nil m)))

-#?(:clj
-   (defn date?
-     [x]
-     (or (instance? java.util.Date x)))
-
-   :cljs
-   (defn date?
-     [x]
-
-     (instance? js/Date x)
-     true))
-
 (defn ->epoch-millis
   "Takes a java.util.Date or joda DateTime or js/Date
   instance and returns milliseconds since UNIX epoch. Returns a nil if passed none of those."
@@ -63,6 +50,8 @@
      :cljs (when (isa? js/Date (type date))
              (.getTime date))))

+(def date? (comp not nil? ->epoch-millis))
+
 (defn dedup
   [xs]
   (second (reduce (fn [[seen?, deduped] x]


Top nav bar now appearing

Top nav bar now appearing

--- src/cljs/metime/core.cljs
+++ src/cljs/metime/core.cljs
@@ -14,6 +14,7 @@
   (:import goog.History
            goog.History.EventType))

+(enable-console-print!)

 (def app-state
   (atom {:top-nav-bar [
@@ -23,7 +24,7 @@
                        {:href "tables.html"   :text "Tables"}
                        {:href "login.html"    :text "Login"}
                        {:href "user.html"     :text "User"}
-                     ]}))
+                      ]}))

 (defn refresh-navigation []
 ;;   (
@@ -185,22 +186,13 @@
   (render [_]

           ;;(println "Count top-nav-bar: " (count top-nav-bar))
-          (println "Last: text " (:text (last top-nav-bar)))
-          ;;(map #(println "href " (:href %)) top-nav-bar)
-
-          ;;(for [item top-nav-bar]
-            ;;[:li [:a {href= (:href item)} (:text item)]]
-            ;;(println (:href item))
-            ;;(map? item)
-          ;;)
-
+          ;;(println "Last: text " (:text (last top-nav-bar)))
+          ;; (map #(println "text " %) top-nav-bar)

           (html
            [:ul.nav.navbar-nav
-;;              (for [item top-nav_bar]
-;;                 [:li [:a {href= (:href item)} (:text item)]]
-;;                )
-           ])))
+            (for [item top-nav-bar]
+              [:li [:a {:href (:href item)} (:text item)]])])))

 (defn main []
   (doto history


Clarify which direction events are going.

--- src/clojurecafe/core.cljs
+++ src/clojurecafe/core.cljs
@@ -30,7 +30,7 @@
 (defn error-handler [{:keys [status status-text]}]
   (log "Error: " status " " status-text))

-(defn load-events [result-chan]
+(defn get-events [result-chan]
   (ajax/GET
     "/data/events.edn"
     {:handler (fn [res] (go (>! result-chan {:success? true :data res})))
@@ -44,7 +44,7 @@
           {:keys [success? data]} result]
       (if success? (success-handler data) (error-handler data)))))

-(load-events result-chan)
+(get-events result-chan)

 (defn calendar-widget [events]
   (om/component


Reverted use of sql-utils/query in find_one due to failing tests.

--- src/cmr/metadata_db/data/oracle/sql_utils.clj
+++ src/cmr/metadata_db/data/oracle/sql_utils.clj
@@ -44,4 +44,4 @@
                    (select ['*]
                            (from :inner)
                            (where '(= :ROWNUM 1))))]
-    (first (query db (build stmt)))))+    (first (j/query db (build stmt)))))


throw-str

throw-str

--- src/com/billpiel/mem_tracer/string_output.clj
+++ src/com/billpiel/mem_tracer/string_output.clj
@@ -92,6 +92,30 @@
          (pprint-str return)
          "\n")))

+(defn throw-str
+  [entry]
+  (when-let [thrown (:throw entry)]
+    (str (indent (:depth entry))
+         (color-code :fg 7 :bg 1 :bold true)
+         "THROW"
+         reset-color-code
+         " => "
+         (pprint-str (:cause thrown))
+         "\n"
+         (indent-line-breaks
+          (->> thrown
+               :via
+               (mapv (fn [v]
+                       (let [at (:at v)
+                             [c f l] ((juxt :class-name
+                                            :file-name
+                                            :line-number)
+                                      at)]
+                         (format "%s %s:%s" c f l))))
+               pprint-str)
+          (:depth entry))
+         "\n")))
+
 (defn entry->string
   [entry]
   (->> [(header->string entry)
@@ -99,7 +123,8 @@
         (args-str entry)
         (when (some-> entry :children not-empty) (return-str entry))
         (clojure.string/join "" (mapcat entry->string (:children entry)))
-        (return-str entry)]
+        (return-str entry)
+        (throw-str entry)]
        (remove nil?)
        (clojure.string/join "")))


utilize flash-error-with-results

utilize flash-error-with-results

--- src/cljs/early_vote_site/early_vote_site_detail/events.cljs
+++ src/cljs/early_vote_site/early_vote_site_detail/events.cljs
@@ -72,11 +72,6 @@
 (defn end-time-selected
   [db [_ new-time-selected]]
   (assoc-in db [:schedules :form  :end-time] new-time-selected))
-
-(defn load-schedules-failure
-  [{:keys [db]} [_ result]]
-  {:db db
-   :dispatch [:flash/error (str "Error loading schedules" (pr-str result))]})

 (defn unassign-schedule
   [{:keys [db]} [_ assignment-id]]
@@ -161,7 +156,9 @@
         (utils/flash-error-with-results "Error assigning schedule")

         :navigate/early-vote-site-detail navigate
-        :schedules-list/failure load-schedules-failure
+        :schedules-list/failure
+        (utils/flash-error-with-results "Error loading schedules")
+
         :schedules-list/get list-schedules
         :early-vote-site/get get-early-vote-site
         :get-early-vote-site/failure


Radio buttons now work like they do in React Toolbox. Closes #23.

--- src/cljs/reagent_toolbox_docs/components/radio_buttons.cljs
+++ src/cljs/reagent_toolbox_docs/components/radio_buttons.cljs
@@ -16,29 +16,22 @@
      [:p "You can provide the theme for this component using the key ToolboxButton."]
      [ui/display-and-eval-code "
 (defn radio-buttons-test []
-  (let [radio-value (reagent.ratom/atom {:value \"vvendetta\"})
-        target-value (fn [t] (.. t -target -value))
-        select (fn [sel] (swap! radio-value assoc :value (target-value sel)))]
+  (let [value (reagent.ratom/atom \"vvendetta\")]
     (fn []
       [:div
-       [:p \"Value: \" @radio-value]
+       [:p \"Value: \" (pr-str @value)]
        [reagent-toolbox.core/radio-group {:name  \"comic\"
-                                          :value (:value @radio-value)}
+                                          :value @value
+                                          :on-change #(reset! value %)}
         [reagent-toolbox.core/radio-button {:label     \"The Walking Dead\"
-                                            :value     \"thewalkingdead\"
-                                            :checked   (when (= (:value @radio-value) \"thewalkingdead\") true)
-                                            :on-change #(select %)}]
+                                            :value     :thewalkingdead}]
         [reagent-toolbox.core/radio-button {:label    \"From Hell\"
                                             :value    \"fromhell\"
                                             :disabled true}]
         [reagent-toolbox.core/radio-button {:label     \"V for Vendetta\"
-                                            :value     \"vvendetta\"
-                                            :checked   (when (= (:value @radio-value) \"vvendetta\") true)
-                                            :on-change #(select %)}]
+                                            :value     \"vvendetta\"}]
         [reagent-toolbox.core/radio-button {:label     \"Watchmen\"
-                                            :value     \"watchmen\"
-                                            :checked   (when (= (:value @radio-value) \"watchmen\") true)
-                                            :on-change #(select %)}]]])))
+                                            :value     \"watchmen\"}]]])))

 [radio-buttons-test]"]
      [:section


Tidy up

Tidy up

--- src/cylon/oauth/impl/authorization_server.clj
+++ src/cylon/oauth/impl/authorization_server.clj
@@ -253,15 +253,13 @@
     (if-not (contains? (set (keys scopes)) scope)
       (throw (ex-info "Invalid scope" {:scope scope}))
       (contains? (:scopes (get-session (:access-token-store this) access-token))
-scope)))
+                 scope)))

   RequestAuthorizer
   (request-authorized? [this request scope]
     (when-let [auth-header (get (:headers request) "authorization")]
       (let [access-token (second (re-matches #"\Qtoken\E\s+(.*)" auth-header))]
-        (authorized? this access-token scope))))
-
-)
+        (authorized? this access-token scope)))))

 (defn new-authorization-server [& {:as opts}]
   (component/using


remove regex literal from EDN reader

remove regex literal from EDN reader

--- src/main/clojure/clojure/tools/reader/edn.clj
+++ src/main/clojure/clojure/tools/reader/edn.clj
@@ -296,7 +296,7 @@
     \= (throwing-reader "Not an EDN form")
     \{ read-set
     \< (throwing-reader "Unreadable form")
-    \" read-regex
+    \" (throwing-reader "Not an EDN form") ;;read-regex
     \! read-comment
     \_ read-discard
     nil))


Remove duplicated functions.

Remove duplicated functions.

--- src/oc/storage/db/common.clj
+++ src/oc/storage/db/common.clj
@@ -387,34 +387,6 @@
    (r/run query conn)))

 (defn list-latest-published-entries
-  [conn org-uuid allowed-boards days]
-  (let [start-date (t/minus (t/date-midnight (t/year (t/today)) (t/month (t/today)) (t/day (t/today))) (t/days days))
-        allowed-board-uuids (map :uuid allowed-boards)]
-    (db-common/with-timeout db-common/default-timeout
-      (as-> (r/table "entries") query
-       (r/get-all query [[:published org-uuid]] {:index :status-org-uuid})
-       ;; Make an initial filter to select only posts the user has access to
-       (r/filter query (r/fn [row]
-         (r/and (r/contains allowed-board-uuids (r/get-field row :board-uuid))
-                (r/ge (r/to-epoch-time (r/iso8601 (r/get-field row [:published-at])))
-                      (lib-time/epoch start-date)))))
-       (r/pluck query [:uuid :publisher :published-at :headline])
-       (r/order-by query (r/desc :published-at))
-       (r/run query conn)
-       ;; Drain cursor
-       (if (= (type query) rethinkdb.net.Cursor)
-         (seq query)
-         query)))))
-
-(defn last-entry-of-board
-  [conn board-uuid]
-  (as-> (r/table "entries") query
-   (r/get-all query [board-uuid] {:index :board-uuid})
-   (r/order-by query (r/desc :created-at))
-   (r/default (r/nth query 0) {})
-   (r/run query conn)))
-
-(defn list-latest-published-entries
   [conn index-name index-value days {count? :count :or {count? false}}]
   (let [start-date (lib-time/to-iso (t/minus (t/with-time-at-start-of-day (t/now)) (t/days days)))]
     (db-common/with-timeout db-common/default-timeout


don't insert in order; add time statements for lookups

--- sample/src/sample/btree.clj
+++ sample/src/sample/btree.clj
@@ -397,8 +397,8 @@
   #_(Thread/sleep 120000)
   [kv1 (count @ts) (time (t/lookup t k1))])

-#_(let [kvs (for [k1 [:a :b :c]
-                k2 ["x" "y" "z"]
+#_(let [kvs (for [k1 [:c :a :b]
+                k2 ["x" "z" "y"]
                 k3 (range 50)]
             [[k1 k2 k3] (str (name k1) k2 (format "%02d" k3))])
       t1 (-> (reduce (fn [t [k v]]
@@ -410,8 +410,8 @@
       t2 (-> (t/insert t1 [:b "y" 3] "____")
              time)]
   #_(clojure.pprint/pprint t)
-  [(t/lookup t1 [:b "y" 3])
-   (t/lookup t2 [:b "y" 3])])
+  [(time (t/lookup-range t1 [:b "y"]))
+   (time (t/lookup-range t2 [:b "y"]))])


[#2145] Load derive-category multimethod namespace

--- backend/src/akvo/lumen/lib/transformation.clj
+++ backend/src/akvo/lumen/lib/transformation.clj
@@ -12,6 +12,7 @@

 (def transformation-namespaces
   '[akvo.lumen.lib.transformation.change-datatype
+    akvo.lumen.lib.transformation.derive-category
     akvo.lumen.lib.transformation.text
     akvo.lumen.lib.transformation.sort-column
     akvo.lumen.lib.transformation.split-column


Upgrade bidi for release

Upgrade bidi for release

--- modules/bidi/project.clj
+++ modules/bidi/project.clj
@@ -1,6 +1,6 @@
 ;; Copyright © 2014 JUXT LTD.

-(defproject juxt.modular/bidi "0.8.0"
+(defproject juxt.modular/bidi "0.8.1"
   :description "A modular extension that provides support for bidi routing"
   :url "https://github.com/juxt/modular/tree/master/modules/bidi"
   :license {:name "The MIT License"


Remove unnecessary require

Remove unnecessary require

--- breakout/desktop/src-common/breakout/core.clj
+++ breakout/desktop/src-common/breakout/core.clj
@@ -4,8 +4,7 @@
   (:require [play-clj.core :refer :all]
             [play-clj.g2d :refer :all]
             [play-clj.g2d-physics :refer :all]
-            [play-clj.ui :refer :all]
-            [play-clj.math :as m]))
+            [play-clj.ui :refer :all]))

 (declare breakout main-screen text-screen)


step two

step two

--- Clojure/src/com/yourtion/TinyWeb/controller.clj
+++ Clojure/src/com/yourtion/TinyWeb/controller.clj
@@ -1,12 +1,20 @@
 (ns com.yourtion.TinyWeb.controller
-    (:import (com.yourtion.TinyWeb HttpRequest HttpRequest$Builder)))
+    (:import (com.yourtion.TinyWeb HttpRequest HttpRequest$Builder RenderingException)))

 (defn test-controller [http-request]
-      {:name (.getBody http-request)})
+      {:name (http-request :body)})

 (def test-builder (HttpRequest$Builder/newBuilder))

 (def test-http-request (.. test-builder (body "Mike") (path "/say-hello") build))

 (defn test-controller-with-map [http-request]
-      {:name (http-request :body)})+      {:name (http-request :body)})
+
+(defn test-view [model]
+      (str "
Hello, " (model :name) "
"))
+
+(defn- render [view model]
+       (try
+         (view model)
+         (catch Exception e (throw (RenderingException. e)))))


Fix #68 Must pass single argument to print fns

--- Clojure/src/ambly/repl/jsc.clj
+++ Clojure/src/ambly/repl/jsc.clj
@@ -17,15 +17,15 @@
   {:pre [(every? string? args)]}
   (.waitFor (.exec (Runtime/getRuntime) (string/join " " args))))

-(defn print-fn [opts]
+(defn repl-print [opts msg]
   {:pre [(map? opts)]}
-  (or (:print-no-newline opts) print))
-
-(defn println-fn [opts]
+  ((or (:print-no-newline opts) print) msg))
+
+(defn repl-println [opts msg]
   {:pre [(map? opts)]}
-  (or (:print opts) println))
-
-(defn flush-fn [opts]
+  ((or (:print opts) println) msg))
+
+(defn repl-flush [opts]
   {:pre [(map? opts)]}
   (or (:flush opts) flush))

@@ -52,9 +52,9 @@
 (defn print-discovered-devices [name-endpoint-map opts]
   {:pre [(map? name-endpoint-map) (map? opts)]}
   (if (empty? name-endpoint-map)
-    ((println-fn opts) "(No devices)")
+    (repl-println opts "(No devices)")
     (doseq [[choice-number [bonjour-name _]] (name-endpoint-map->choice-list name-endpoint-map)]
-      ((println-fn opts) (str "[" choice-number "] " (bonjour-name->display-name bonjour-name))))))
+      (repl-println opts (str "[" choice-number "] " (bonjour-name->display-name bonjour-name))))))

 (defn discover-and-choose-device
   "Looks for Ambly WebDAV devices advertised via Bonjour and presents
@@ -88,16 +88,16 @@
         (when (empty? @name-endpoint-map)
           (Thread/sleep 100)
           (when (= 20 count)
-            ((println-fn opts) "\nSearching for devices ..."))
+            (repl-println opts "\nSearching for devices ..."))
           (recur (inc count))))
       (Thread/sleep 500)                                    ;; Sleep a little more to catch stragglers
       (loop [current-name-endpoint-map @name-endpoint-map]
-        ((println-fn opts))
+        (repl-println opts "")
         (print-discovered-devices current-name-endpoint-map opts)
         (when-not choose-first-discovered?
-          ((println-fn opts) "\n[R] Refresh\n")
-          ((print-fn opts) "Choice: ")
-          ((flush-fn opts)))
+          (repl-println opts "\n[R] Refresh\n")
+          (repl-print opts "Choice: ")
+          (repl-flush opts))
         (let [choice (if choose-first-discovered? "1" (read-line))]
           (if (= "r" (.toLowerCase choice))
             (recur @name-endpoint-map)
@@ -143,8 +143,8 @@
                    (deliver resp-promise :eof))
                  :eof)
       (= c 1) (do
-                ((print-fn opts) (str sb))
-                ((flush-fn opts))
+                (repl-print opts (str sb))
+                (repl-flush opts)
                 (recur (StringBuilder.) (.read in)))
       (= c 0) (do
                 (deliver @response-promise (str sb))
@@ -282,7 +282,7 @@
           output-dir (io/file webdav-mount-point)
           env (ana/empty-env)
           core (io/resource "cljs/core.cljs")]
-      ((println-fn opts) "\nConnecting to" (bonjour-name->display-name bonjour-name) "...\n")
+      (repl-println opts (str "\nConnecting to" (bonjour-name->display-name bonjour-name) "...\n"))
       (set-up-socket repl-env opts endpoint-address (dec endpoint-port))
       (if (= "true" (:value (jsc-eval repl-env "typeof cljs === 'undefined'")))
         (do
@@ -341,7 +341,7 @@
         (let [expected-clojurescript-version (cljs.util/clojurescript-version)
               actual-clojurescript-version (:value (jsc-eval repl-env "cljs.core._STAR_clojurescript_version_STAR_"))]
           (when-not (= expected-clojurescript-version actual-clojurescript-version)
-            ((println-fn opts)
+            (repl-println opts
               (str "WARNING: " (bonjour-name->display-name bonjour-name)
                 "\n         is running ClojureScript " actual-clojurescript-version
                 ", while the Ambly REPL is\n         set up to use ClojureScript "
@@ -371,9 +371,9 @@
               (repl/mapped-stacktrace stacktrace build-options)]
         (let [url (when url (string/trim (.toString url)))
               file (when file (string/trim (.toString file)))]
-          ((println-fn repl/*repl-opts*)
-            "\t" (str (when function (str function " "))
-                      "(" (source url file) (when line (str ":" line)) (when column (str ":" column)) ")"))))))
+          (repl-println repl/*repl-opts*
+            (str "\t" (when function (str function " "))
+              "(" (source url file) (when line (str ":" line)) (when column (str ":" column)) ")"))))))
   repl/IJavaScriptEnv
   (-setup [repl-env opts]
     (setup repl-env opts))


Add test for using in batch

Add test for using in batch

--- test/clojure/clojurewerkz/cassaforte/new_query_api_test.clj
+++ test/clojure/clojurewerkz/cassaforte/new_query_api_test.clj
@@ -239,7 +239,6 @@
                  (value :k 0)
                  (value :x (tuple-of [:int] [(int 1)])))))

-
   (is (= "UPDATE foo USING TIMESTAMP 42 SET a=12,b=[3,2,1],c=c+3 WHERE k=2;"
          (update :foo
                  (array-map :a 12
@@ -371,7 +370,10 @@
   (is (= "TRUNCATE b.a;"
          (truncate :a :b)))

-  (is (= "BEGIN BATCH INSERT INTO foo(asd) VALUES ('bsd');INSERT INTO foo(asd) VALUES ('bsd');INSERT INTO foo(asd) VALUES ('bsd');APPLY BATCH;"
+  (is (= (str "BEGIN BATCH INSERT INTO foo(asd) VALUES ('bsd');"
+              "INSERT INTO foo(asd) VALUES ('bsd');"
+              "INSERT INTO foo(asd) VALUES ('bsd');"
+              "APPLY BATCH;")
          (batch
           (queries
            (insert :foo
@@ -379,7 +381,21 @@
            (insert :foo
                    (value "asd" "bsd"))
            (insert :foo
-                   (value "asd" "bsd"))))
-
-
-         )))
+                   (value "asd" "bsd"))))))
+
+  (is (= (str "BEGIN COUNTER BATCH USING TIMESTAMP 42 "
+              "UPDATE foo SET a=a+1;"
+              "UPDATE foo SET b=b+1;"
+              "UPDATE foo SET c=c+1;"
+              "APPLY BATCH;")
+         (batch
+          (using {:timestamp 42})
+          (queries
+           (update :foo
+                   (array-map :a (increment-by 1)))
+           (update :foo
+                   (array-map :b (increment-by 1)))
+           (update :foo
+                   (array-map :c (increment-by 1)))))))
+
+  )


external http get-location request now GET

--- src/complico/external.clj
+++ src/complico/external.clj
@@ -3,7 +3,7 @@

 (defn get-location [url]
   (-> url
-    (client/head)
+    (client/get)
     (:trace-redirects)
     (last)))


retrieve schema metadata

retrieve schema metadata

--- src/dbquery/databases.clj
+++ src/dbquery/databases.clj
@@ -133,17 +133,40 @@
   ([ds sql] (execute ds sql {}))
   )

-(defn table-meta
-  ([ds name]
-   (with-db-metadata [meta ds]
-     (let [cols  (with-open [rs (.getColumns meta nil nil name "%")]
-                   (read-as-map rs))
-           pks (with-open [rs (.getPrimaryKeys meta nil nil name)]
-                 (read-as-map rs))
-           fks (with-open [rs (.getImportedKeys meta nil nil name)]
-                 (read-as-map rs))]
-       {:columns cols :primaryKeys pks :foreignKeys fks})))
-  ([ds] (table-meta "%"))
+(defn table-meta [ds name]
+  (with-db-metadata [meta ds]
+    (let [cols  (with-open [rs (.getColumns meta nil nil name "%")]
+                  (read-as-map rs))
+          pks (with-open [rs (.getPrimaryKeys meta nil nil name)]
+                (read-as-map rs))
+          fks (with-open [rs (.getImportedKeys meta nil nil name)]
+                (read-as-map rs))]
+      {:columns cols :primaryKeys pks :foreignKeys fks}))
+  )
+
+(defn- find-and-replace [col pred f]
+  (loop ))
+
+(defn db-meta [ds]
+  (defn merge-col-keys [cols pks fks]
+    (reduce #(update cols ()))
+    )
+  (with-db-metadata [meta ds]
+    (let [tables (future (with-open [rs (.getTables meta nil (:schema ds) "%" (into-array ["TABLE" "VIEW"]))]
+                           (read-as-map rs {:fields ["TABLE_NAME" "TABLE_TYPE"]})))
+          cols (future (with-open [rs (.getColumns meta nil nil "%" "%")]
+                         (-> rs
+                             (read-as-map {:fields ["TABLE_NAME" "COLUMN_NAME" "DATA_TYPE" "TYPE_NAME" "COLUMN_SIZE" "NULLABLE"]})
+                             (#(hash-map (for [e %] [(:table_name e) e] ))))))
+          pkfn (fn [tbl] (with-open [rs (.getPrimaryKeys meta nil nil tbl)]
+                           (read-as-map rs {:fields ["COLUMN_NAME" "KEY_SEQ"]})))
+          fkfn (fn [tbl] (with-open [rs (.getImportedKeys meta nil nil tbl)]
+                           (read-as-map rs {:fields ["PKTABLE_NAME" "PKCOLUMN_NAME" "FKCOLUMN_NAME" "KEY_SEQ" "FK_NAME" "PK_NAME"]})))
+          pks (for [tbl @tables][tbl (future (pkfn tbl))])
+          fks (for [tbl @tables][tbl (future (fkfn tbl))])
+          ]
+      (for [tbl @tables] (assoc :columns (@cols (:table_name tbl))))
+      ))
   )

 (defn exec-query [ds {:keys [tables fields predicates offset limit] :or {offset 0 limit 20}}]


add missing hyphen

add missing hyphen

--- src/overtone/music/pitch.clj
+++ src/overtone/music/pitch.clj
@@ -289,7 +289,7 @@
      :harmonic-minor     [2 1 2 2 1 3 1]
      :diminished2        [2 1 2 1 2 1 2 1]
      :marva              [1 3 2 1 2 2 1]
-     :melodicmajor       [2 2 1 2 1 2 2]
+     :melodic-major      [2 2 1 2 1 2 2]
      :indian             [4 1 2 3 2]
      :hex-major6         [2 2 1 2 2 3]
      :spanish            [1 3 1 2 1 2 2]


Presumably got shader/program error logging working.

--- src/petulant_life/shader.clj
+++ src/petulant_life/shader.clj
@@ -19,13 +19,14 @@
         status (GL20/glGetShaderi shader GL20/GL_COMPILE_STATUS)]
     (if status
       shader
-      (.exit System 1))))
+      (do (print (GL20/glGetShaderInfoLog shader 2048))
+          (.exit System) 1))))

 ;; Loading a shader if it exists.
 (defn load-if-exists [path type]
   (if (.exists (as-file path))
     (load-shader path type)
-    (print (str path " does not exist."))))
+    (print (str "Loading shader: " path " does not exist.\n"))))

 ;; Loading a bunch of shaders and returning them in one map.
 (defn load-shaders [src-path]
@@ -61,4 +62,7 @@
 (defn load-shader-program [src-path]
   (let [shader-program (load-shader-program-raw src-path)
         status (GL20/glGetProgrami shader-program GL20/GL_LINK_STATUS)]
-    shader-program))
+    (if status
+      shader-program
+      (do (print (GL20/glGetProgramInfoLog shader-program 2048))
+          (.exit System 1)))))


add warning to deprecated subtasks.

add warning to deprecated subtasks.

--- src/leiningen/ancient.clj
+++ src/leiningen/ancient.clj
@@ -4,7 +4,18 @@
              [get :as g]
              [upgrade :as u]
              [verbose :refer :all]]
+            [leiningen.core.main :as main]
             [jansi-clj.auto]))
+
+
+(defn- as-deprecated
+  [given-task new-task f arg]
+  (main/warn "WARN: the subtask"
+             (str "'" given-task "'")
+             "is deprecated, use"
+             (str "'" new-task "'")
+             "instead.\n")
+  (f arg))

 (defn
   ^:higher-order ^:no-project-needed
@@ -17,11 +28,14 @@
   ancient
   "Check your projects and profiles for outdated dependencies/plugins."
   [project & args]
-  (let [run #(apply % project (rest args))]
+  (let [run #(apply % project (rest args))
+        run-deprecated #(as-deprecated (first args) %1 run %2)]
     (case (first args)
       "check"                       (run c/check)
-      ("check-profiles" "profiles") (run c/check-profiles)
-      ("show-versions" "get")       (run g/show-versions)
+      "check-profiles"              (run c/check-profiles)
+      "get"                         (run-deprecated "show-versions" g/show-versions)
+      "profiles"                    (run-deprecated "check-profiles" c/check-profiles)
+      "show-versions"               (run g/show-versions)
       ("show-latest" "latest")      (run g/show-latest)
       "upgrade"                     (run u/upgrade)
       "upgrade-profiles"            (run u/upgrade-profiles)


find-signal can parse "lx -> a" now, adds doc string to memoized version

--- src/advent/core.clj
+++ src/advent/core.clj
@@ -179,6 +179,14 @@
   [n]
   (- 65535 n))

+(defn parse-int-if-possible
+  "returns the integer of i if possible, otherwise returns i"
+  [i]
+  (try
+    (Integer. i)
+    (catch Exception e
+      i)))
+
 (defn parse-output-wire [s]
   (last (map str/trim (str/split s #"->"))))

@@ -191,7 +199,7 @@
   [value]
   (if (> (count value) 1)
     value
-    (Integer. (first value))))
+    (parse-int-if-possible (first value))))

 (defn map-values
   "returns a map of the map (m) with the values mapped over the function (f)"
@@ -219,73 +227,40 @@
   [circuit-input]
   (map-values (parse-circuit-data-into-map (str/split (slurp circuit-input) #"\n")) single-values-to-keywords))

-(defn parse-int-if-possible
-  "returns the integer of i if possible, otherwise returns i"
-  [i]
-  (try
-    (Integer. i)
-    (catch Exception e
-      i)))
-
-;"returns the value of signal (keyword) within a circuit (map)
-;Usage: (find-signal :i sample-built-circuit)"
-(def find-signal
+
+(def ^{:doc "returns the value of signal (keyword) within a circuit (map)\n  Usage: (find-signal :i sample-built-circuit)"}
+  find-signal
   (memoize (fn
              [signal circuit]
-
              (if (integer? (signal circuit))
                (signal circuit)
-               (case (count (signal circuit))
-                 2 (let [value (parse-int-if-possible (last (signal circuit)))]
-                     (if (number? value)
-                       (bit-not-unsigned value)
-                       (bit-not-unsigned (find-signal (keyword value) circuit))))
-
-                 3 (let [[left-val-raw opcode right-val-raw] (signal circuit)
-                         left-val-parsed (parse-int-if-possible left-val-raw)
-                         right-val-parsed (parse-int-if-possible right-val-raw)
-                         left-val (if (number? left-val-parsed)
-                                    left-val-parsed
-                                    (find-signal (keyword left-val-parsed) circuit))
-                         right-val (if (number? right-val-parsed)
-                                     right-val-parsed
-                                     (find-signal (keyword right-val-parsed) circuit))]
-                     (case opcode
-                       "LSHIFT" (bit-shift-left left-val right-val)
-                       "RSHIFT" (bit-shift-right left-val right-val)
-                       "AND" (bit-and left-val right-val)
-                       "OR" (bit-or left-val right-val))
-                     ))))))
-
-(defn find-signal-slowly
-  "returns the value of signal (keyword) within a circuit (map)
-  Usage: (find-signal :i sample-built-circuit)"
-  [signal circuit]
-  (if (integer? (signal circuit))
-    (signal circuit)
-    (case (count (signal circuit))
-      2 (let [value (parse-int-if-possible (last (signal circuit)))]
-          (if (number? value)
-            (bit-not-unsigned value)
-            (bit-not-unsigned (find-signal-slowly (keyword value) circuit))))
-
-      3 (let [[left-val-raw opcode right-val-raw] (signal circuit)
-              left-val-parsed (parse-int-if-possible left-val-raw)
-              right-val-parsed (parse-int-if-possible right-val-raw)
-              left-val (if (number? left-val-parsed)
-                         left-val-parsed
-                         (find-signal-slowly (keyword left-val-parsed) circuit))
-              right-val (if (number? right-val-parsed)
-                          right-val-parsed
-                          (find-signal-slowly (keyword right-val-parsed) circuit))]
-          (case opcode
-            "LSHIFT" (bit-shift-left left-val right-val)
-            "RSHIFT" (bit-shift-right left-val right-val)
-            "AND" (bit-and left-val right-val)
-            "OR" (bit-or left-val right-val))
-          ))))
-
-; Data prep: had to manually set lx in the data since it's the only one where lx isn't a number,
-; I was able to just update the line to: lw OR lv -> a
-
-; Timing: the memozied version copletes in 0.055178 msecs, the non-memoized version in ...+               (if (string? (signal circuit))  ; either a string, "lx", or array, ["x" "LSHIFT" "y"] or ["NOT" "x"]
+                 (find-signal (keyword (signal circuit)) circuit)
+                 (case (count (signal circuit))
+                   ; handle NOT
+                   2 (let [value (parse-int-if-possible (last (signal circuit)))]
+                       (if (number? value)
+                         (bit-not-unsigned value)
+                         (bit-not-unsigned (find-signal (keyword value) circuit))))
+                   ; handle LSHIFT RSHIFT AND OR
+                   3 (let [[left-val-raw opcode right-val-raw] (signal circuit)
+                           left-val-parsed (parse-int-if-possible left-val-raw)
+                           right-val-parsed (parse-int-if-possible right-val-raw)
+                           left-val (if (number? left-val-parsed)
+                                      left-val-parsed
+                                      (find-signal (keyword left-val-parsed) circuit))
+                           right-val (if (number? right-val-parsed)
+                                       right-val-parsed
+                                       (find-signal (keyword right-val-parsed) circuit))]
+                       (case opcode
+                         "LSHIFT" (bit-shift-left left-val right-val)
+                         "RSHIFT" (bit-shift-right left-val right-val)
+                         "AND" (bit-and left-val right-val)
+                         "OR" (bit-or left-val right-val))
+                       )))))))
+
+; Timing: the memozied version copletes in 0.055178 msecs, the non-memoized version never completed
+; as it probably went into swap
+
+; Data was loaded via: (def day-7-data (build-circuit day-7-input))
+; For the solution to part B, I just ran (find-signal :a (assoc day-7-data :b (find-signal :a day-7-data)))


CMR-1863 Extracts DIF 10 platform type generation to a named function.

--- umm-spec-lib/src/cmr/umm_spec/umm_to_xml_mappings/dif10.clj
+++ umm-spec-lib/src/cmr/umm_spec/umm_to_xml_mappings/dif10.clj
@@ -24,6 +24,12 @@
    :xmlns:xsi "http://www.w3.org/2001/XMLSchema-instance"
    :xsi:schemaLocation "http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/ http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/dif_v10.1.xsd"})

+(defn- generate-platform-type
+  "Returns content for the Platform Type field."
+  [xpath-context]
+  (let [platform (-> xpath-context :context first)]
+    [(or (get platform-types (:Type platform) "Not provided"))]))
+
 (def umm-c-to-dif10-xml
   [:DIF
    dif10-xml-namespaces
@@ -37,9 +43,7 @@

    (for-each "/Platforms"
      [:Platform
-      [:Type (fn [xpath-context]
-               (let [platform (-> xpath-context :context first)]
-                 [(or (get platform-types (:Type platform) "Not provided"))]))]
+      [:Type generate-platform-type]
       [:Short_Name (xpath "ShortName")]
       [:Long_Name (xpath "LongName")]
       [:Instrument [:Short_Name "Not implemented"]]])


CMR-1863 Extracts DIF 10 platform type parsing to a named function.

--- umm-spec-lib/src/cmr/umm_spec/xml_to_umm_mappings/dif10.clj
+++ umm-spec-lib/src/cmr/umm_spec/xml_to_umm_mappings/dif10.clj
@@ -5,6 +5,12 @@
             [cmr.umm-spec.xml-to-umm-mappings.add-parse-type :as apt]
             [cmr.umm-spec.json-schema :as js]
             [cmr.umm-spec.simple-xpath :as xp]))
+
+(defn parse-platform-type
+  [xpath-context]
+  (let [val (-> xpath-context :context first (cx/string-at-path [:Type]))]
+    (when (not= val "Not provided")
+      val)))

 (def dif10-xml-to-umm-c
   (apt/add-parsing-types
@@ -21,10 +27,7 @@
                     (object
                      {:ShortName (xpath "Short_Name")
                       :LongName (xpath "Long_Name")
-                      :Type (fn [xpath-context]
-                              (let [val (-> xpath-context :context first (cx/string-at-path [:Type]))]
-                                (when (not= val "Not provided")
-                                  val)))}))
+                      :Type parse-platform-type}))
        :TemporalExtents (for-each "/DIF/Temporal_Coverage"
                           (object
                             {:TemporalRangeType (xpath "Temporal_Range_Type")


Fix sign up process

Fix sign up process

--- src/ansel/views.clj
+++ src/ansel/views.clj
@@ -84,7 +84,7 @@
                  (= password confirm))
           (let [user (select-keys params [:username :password])]
             (db/add-user-to-db user)
-            (resp/redirect "/") user)
+            (resp/redirect "/"))
           (assoc (resp/redirect (str (:context req) "/")) :flash "passwords don't match!")))

   (with-admin-required


Link to github page

Link to github page

--- src/foreclojure/users.clj
+++ src/foreclojure/users.clj
@@ -11,7 +11,9 @@
     (reverse (sort-by sortfn users))))

 (def-page users-page []
-  [:div [:span.contributor "*"]" 4clojure contributor"]
+  [:div
+   [:span.contributor "*"] " "
+   (link-to "https://github.com/dbyrne/4clojure" "4clojure contributor")]
   [:br]
   [:table#user-table.my-table
    [:thead


start new upload when active upload paused

--- src/frontend/uploads.cljs
+++ src/frontend/uploads.cljs
@@ -5,6 +5,15 @@

 (defonce blank-upload {:paused?  false
                        :started? false})
+
+(defn active? [upload]
+  (and (:started? upload)
+       (not (:paused? upload))))
+
+(defn unpaused-and-not-started? [upload]
+  (and (not (:started? upload))
+       (not (:paused?  upload))))
+

 (defn pause-upload [upload]
   (assoc upload :paused? true))
@@ -22,10 +31,10 @@
   (conj uploads upload))

 (defn active-uploads [uploads-order uploads]
-  (vec (remove #(not (:started? (uploads %1))) uploads-order)))
+  (vec (remove #(not (active? (uploads %1))) uploads-order)))

 (defn inactive-uploads [uploads-order uploads]
-  (vec (remove #(:started? (uploads %1)) uploads-order)))
+  (vec (remove #(active? (uploads %1)) uploads-order)))

 (defn handle-upload-slots-change [old-state new-state]
   (let [old-upload-slots (:upload-slots old-state)
@@ -106,14 +115,27 @@
         blob-stream (.createBlobReadStream js/ss file)
         upload-watch-fn! (fn [_ _ old-state new-state]
                            (let [action (get-action old-state new-state upload-id)
-                                 upload (get (:uploads @app-state/app-state) upload-id)]
+                                 uploads (:uploads new-state)
+                                 uploads-order (:uploads-order new-state)
+                                 upload (get uploads upload-id)
+                                 upload-slots (:upload-slots new-state)]
                              (if-not (nil? action)
                                (do
                                  (println "ACTION:" action)
                                  (println "Upload-id:" upload-id)
                                  (cond
                                    (= action :paused)
+                                    (do
                                      (.unpipe blob-stream)
+                                     (let [first-inactive-upload-id (first (filter #(unpaused-and-not-started? (uploads %)) uploads-order))
+                                           first-inactive-upload    (uploads first-inactive-upload-id)]
+                                       (if-not (nil? first-inactive-upload)
+                                         (swap! app-state/app-state
+                                                assoc
+                                                :uploads
+                                                (merge uploads
+                                                       {first-inactive-upload-id
+                                                        (start-upload first-inactive-upload)})))))
                                    (and (= action :unpaused)
                                         (:started? upload))
                                      (.pipe blob-stream stream)


Removed unused pretty-conv

Removed unused pretty-conv

--- src/polismath/simulation.clj
+++ src/polismath/simulation.clj
@@ -74,10 +74,6 @@
    (string/join \newline)))

-(defn pretty-conv [conv]
-  (debug-repl)
-  conv)
-
 (defn conv-stat-row
   [zid votes conv]
   (str "XXX,"


record log message

record log message

--- src/babel/over.cljc
+++ src/babel/over.cljc
@@ -62,7 +62,7 @@
               true
               (not (= v1 v2)))]
     (if (= result true)
-      (log/debug (str "CAUGHT ONE: p1=" p1 "; p2=" p2)))
+      (log/debug (str "check-vals caught a fail: p1=" p1 "; p2=" p2 "; fail-path:" (fail-path m1 m2))))
     result))

 (defn head-pre-checks [parent child]


Make conversions import optional.

Make conversions import optional.

--- src/blocks/core.clj
+++ src/blocks/core.clj
@@ -14,7 +14,6 @@
   (:refer-clojure :exclude [get list])
   (:require
     [blocks.data :as data]
-    [blocks.data.conversions]
     [blocks.store :as store]
     [byte-streams :as bytes]
     [clojure.java.io :as io]


Trim csv fields.

Trim csv fields.

--- src/cgdata/core.clj
+++ src/cgdata/core.clj
@@ -281,7 +281,7 @@
 ;

 (defn- split-no-empty [in pat] ; XXX Does this need to handle quotes?
-  (filter #(not (= "" %)) (s/split in pat)))
+  (filter #(not (= "" %)) (map s/trim (s/split in pat))))

 (defn- probemap-row [row]
   (let [[probe genes chrom start end strand] (s/split row #"\t")]


Indentation for native-names.

Indentation for native-names.

--- src/leiningen/compile.clj
+++ src/leiningen/compile.clj
@@ -74,19 +74,10 @@
   (m (first (drop-while #(nil? (re-find (re-pattern %) k))
                         (keys m)))))

-(def native-names
-     {"Mac OS X" :macosx
-      "Windows" :windows
-      "Linux" :linux
-      "FreeBSD" :freebsd
-      "SunOS" :solaris
-      "OpenBSD" :openbsd
-      "amd64" :x86_64
-      "x86_64" :x86_64
-      "x86" :x86
-      "i386" :x86
-      "arm" :arm
-      "sparc" :sparc})
+(def native-names {"Mac OS X" :macosx "Windows" :windows "Linux" :linux
+                   "FreeBSD" :freebsd "OpenBSD" :openbsd
+                   "amd64" :x86_64 "x86_64" :x86_64 "x86" :x86 "i386" :x86
+                   "arm" :arm "SunOS" :solaris "sparc" :sparc})

 (defn get-os
   "Returns a keyword naming the host OS."


When creating a standalone jar don't unpack deps.

This means we don't have to unpack everything into classes/ which was
causing people to accidentally create an uberjar when they did
"lein jar".  We also merge plexus components.xml files, this means
that uberjaring projects that embed Maven (like Leiningen itself)
now works reliably.

--- src/leiningen/uberjar.clj
+++ src/leiningen/uberjar.clj
@@ -1,28 +1,64 @@
 (ns leiningen.uberjar
   "Create a jar containing the compiled code, source, and all dependencies."
-  (:use [clojure.contrib.java-utils :only [file]]
+  (:require [clojure.xml :as xml])
+  (:use [clojure.zip :only [xml-zip]]
+        [clojure.contrib.java-utils :only [file]]
         [clojure.contrib.duck-streams :only [copy]]
+        [clojure.contrib.zip-filter.xml :only [xml-> tag=]]
         [leiningen.deps :only [deps]]
         [leiningen.jar :only [jar]])
-  (:import [java.util.zip ZipFile]
-           [java.io File FileOutputStream]))
+  (:import [java.util.zip ZipFile ZipOutputStream ZipEntry]
+           [java.io File FileOutputStream PrintWriter]))

-(defn unzip
-  "Unzip zipfile into the target directory."
-  [zipfile target]
-  (with-open [zipfile (ZipFile. zipfile)]
-    (let [entries (enumeration-seq (.entries zipfile))]
-      (doseq [file (remove (memfn isDirectory) entries)]
-        (.mkdirs (.getParentFile (java.io.File. (str target (.getName file)))))
-        (with-open [out (FileOutputStream. (str target (.getName file)))]
-          (copy (.getInputStream zipfile file) out))))))
+(defn read-components [zipfile]
+  (when-let [entry (.getEntry zipfile "META-INF/plexus/components.xml")]
+    (-> (xml-> (xml-zip (xml/parse (.getInputStream zipfile entry)))
+               (tag= :components))
+        first first :content)))
+
+(defn copy-entries
+  "Copies the entries of ZipFile in to the ZipOutputStream out, skipping
+  the entries which satisfy skip-pred. Returns the names of the
+  entries copied."
+  [in out & [skip-pred]]
+  (for [file (enumeration-seq (.entries in))
+        :when (not (skip-pred file))]
+    (do
+      (.putNextEntry out file)
+      (copy (.getInputStream in file) out)
+      (.closeEntry out)
+      (.getName file))))
+
+;; we have to keep track of every entry we've copied so that we can
+;; skip duplicates.  We also collect together all the plexus components so
+;; that we can merge them.
+(defn include-dep [out [skip-set components] dep]
+  (println "Including" (.getName dep))
+  (with-open [zipfile (ZipFile. dep)]
+    [(into skip-set (copy-entries zipfile out #(skip-set (.getName %))))
+     (concat components (read-components zipfile))]))

 (defn uberjar
   "Create a jar like the jar task, but including the contents of each of
-the dependency jars. Suitable for standalone distribution."
+  the dependency jars. Suitable for standalone distribution."
   [project & args]
-  (doseq [dep (file-seq (file (:root project) "lib"))
-          :when (.endsWith (.getName dep) ".jar")]
-    (println "Unpacking" (.getName dep))
-    (unzip dep *compile-path*))
-  (jar project (str (:name project) "-standalone.jar")))
+  (jar project)
+  (with-open [out (-> (file (:root project)
+                            (str (:name project) "-standalone.jar"))
+                      (FileOutputStream.) (ZipOutputStream.))]
+    (let [deps (->> (file-seq (file (:root project) "lib"))
+                    (filter #(.endsWith (.getName %) ".jar"))
+                    (cons (file (:root project) (str (:name project) ".jar"))))
+          [_ components] (reduce (partial include-dep out)
+                                 [#{"META-INF/plexus/components.xml"} nil]
+                                 deps)]
+      (when-not (empty? components)
+        (.putNextEntry out (ZipEntry. "META-INF/plexus/components.xml"))
+        (binding [*out* (PrintWriter. out)]
+          (xml/emit {:tag :component-set
+                     :content
+                     [{:tag :components
+                       :content
+                       components}]})
+          (.flush *out*))
+        (.closeEntry out)))))


Remove debug output.

Remove debug output.

--- src/cli4clj/cli.clj
+++ src/cli4clj/cli.clj
@@ -120,7 +120,6 @@
       (let [line (if *mock-jline-readline-input*
                    (read-line)
                    (.readLine in-rdr))]
-        (println "line:" line)
         (if (and (not (nil? line))
                  (not (.isEmpty line))
                  (not (-> line (.trim) (.startsWith *comment-begin-string*))))


A simplified difference series.

A simplified difference series.

--- src/kixi/hecuba/data/calculate.clj
+++ src/kixi/hecuba/data/calculate.clj
@@ -119,22 +119,13 @@
   "Takes store, sensor and a range of dates and calculates difference series using resolution
   stored in the sensor data. If resolution is not specified, default 60 seconds is used."
   [store {:keys [sensor range]}]
-  (let [resolution (if-let [r (:resolution sensor)] (edn/read-string r) 60)]
-    (when (> resolution 0)
-      (let [{:keys [start-date end-date]} range
-            timestamps                  (expected-timestamps start-date end-date resolution)
-            measurements                (measurements-for-range store sensor range (t/hours 1))
-            template-reading            (-> (first measurements)
-                                            (assoc :value "n/a")
-                                            (dissoc :timestamp :reading_metadata))]
-        (when (> (count (take 2 measurements)) 1)
-          (let [{:keys [device_id type]} sensor
-                quantized            (quantized-measurements resolution measurements)
-                grouped-measurements (grouped-readings quantized)
-                new-type             (ext-type type)
-                padded-measurements  (filled-measurements template-reading grouped-measurements timestamps)
-                calculated           (diff-seq padded-measurements)]
-            (m/insert-measurements store {:device_id device_id :type new-type} calculated 100)))))))
+  (let [{:keys [start-date end-date]} range
+        measurements                  (measurements-for-range store sensor range (t/hours 1))]
+    (when (> (count (take 2 measurements)) 1)
+      (let [{:keys [device_id type]} sensor
+            new-type                 (ext-type type)
+            calculated               (diff-seq measurements)]
+        (m/insert-measurements store {:device_id device_id :type new-type} calculated 100)))))

 (defn kWh->co2
   "Converts measurements from kWh to co2."


missed a usage of prefix

missed a usage of prefix

--- src/riemann/jvm_profiler.clj
+++ src/riemann/jvm_profiler.clj
@@ -30,7 +30,7 @@
                  :ttl         (* 2 dt)
                  :tags        tags}))
          (concat [{:host    (or host (client/localhost))
-                   :service (str prefix "profiler rate")
+                   :service (str (string/trim prefix) " profiler rate")
                    :state   "ok"
                    :metric  rate
                    :ttl     (* 2 dt)


Fixed bug with Chained WriteHandler Lookup

Signed-off-by: Peter Schuck <4b8373d016f277527198385ba72fda0feb5da015@bendyworks.com>

--- src/longshi/fressian/handlers.cljs
+++ src/longshi/fressian/handlers.cljs
@@ -34,7 +34,7 @@
                  (loop [i 0]
                    (if-let [v (aget (aget handlers i) k)]
                      v
-                     (when (< cnt i)
+                     (when (< i cnt)
                        (recur (inc i)))))]
         (do
           (aset cache k chain-handler)


Require clojure.test in conexp.main

Require clojure.test in conexp.main

to make the reader happy.

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

--- src/conexp/main.clj
+++ src/conexp/main.clj
@@ -10,7 +10,8 @@
   (:require conexp.base
             conexp.fca
             conexp.io
-            conexp.layouts))
+            conexp.layouts)
+  (:require clojure.test))

 (conexp.base/ns-doc
  "Main namespace for conexp-clj. Immigrates all needed namespaces.")
@@ -70,7 +71,6 @@
   conexp.contrib.tests too."
   ([] (test-conexp false))
   ([with-contrib?]
-     (require 'clojure.test)
      (if with-contrib?
        (do (require 'conexp.tests
                     'conexp.contrib.tests)


fix compilation error - our on-the-fly class-generation cannot yet handle compilation

--- src/main/clojure/org/dada/core.clj
+++ src/main/clojure/org/dada/core.clj
@@ -316,14 +316,15 @@

 ;; sum specific stuff - should be in its own file

-(def #^Metadata sum-reducer-metadata (class-metadata "org.dada.core.reducer.Sum" Object :key :version [:key String :version Integer :sum Number]))
-
-(defn make-sum-reducer-strategy [#^Keyword attribute-key #^Metadata src-metadata]
+;; TODO - should just be a class, not a fn - but then we wouldn't be able to compile this file
+(defn #^Metadata sum-reducer-metadata [] (class-metadata "org.dada.core.reducer.Sum" Object :key :version [:key String :version Integer :sum Number]))
+
+(defn make-sum-reducer-strategy [#^Keyword attribute-key #^Metadata src-metadata #^Metadata tgt-metadata]
   (let [getter (.getAttributeGetter src-metadata (name attribute-key))
 	accessor (fn [value] (.get getter value))
 	new-value (fn [#^Update update] (accessor (.getNewValue update)))
 	old-value (fn [#^Update update] (accessor (.getOldValue update)))
-	creator (.getCreator sum-reducer-metadata)]
+	creator (.getCreator tgt-metadata)]
     (proxy
      [Reducer$Strategy]
      []
@@ -341,21 +342,23 @@
      )))

 (defn do-reduce-sum [#^Model model #^Keyword attribute-key]
-  (let [strategy (make-sum-reducer-strategy attribute-key (.getMetadata model))
+  (let [tgt-metadata (sum-reducer-metadata)
+	strategy (make-sum-reducer-strategy attribute-key (.getMetadata model) tgt-metadata)
 	view-name-fn #(str "sum(" % ")")
-	reducer (make-reducer model attribute-key strategy sum-reducer-metadata view-name-fn)]
+	reducer (make-reducer model attribute-key strategy tgt-metadata view-name-fn)]
     (connect model reducer)))

 ;; count specific stuff - should be in its own file

-(def #^Metadata count-reducer-metadata (class-metadata "org.dada.core.reducer.Count" Object :key :version [:key String :version Integer :count Number]))
-
-(defn make-count-reducer-strategy [#^Keyword attribute-key #^Metadata src-metadata]
+;; TODO - should just be a class, not a fn - but then we wouldn't be able to compile this file
+(defn #^Metadata count-reducer-metadata [] (class-metadata "org.dada.core.reducer.Count" Object :key :version [:key String :version Integer :count Number]))
+
+(defn make-count-reducer-strategy [#^Keyword attribute-key #^Metadata src-metadata #^Metadata tgt-metadata]
   (let [getter (.getAttributeGetter src-metadata (name attribute-key))
 	accessor (fn [value] (.get getter value))
 	new-value (fn [#^Update update] (accessor (.getNewValue update)))
 	old-value (fn [#^Update update] (accessor (.getOldValue update)))
-	creator (.getCreator count-reducer-metadata)]
+	creator (.getCreator tgt-metadata)]
     (proxy
      [Reducer$Strategy]
      []
@@ -368,9 +371,10 @@
     ))

 (defn do-reduce-count [#^Model model #^Keyword attribute-key]
-  (let [strategy (make-count-reducer-strategy attribute-key (.getMetadata model))
+  (let [tgt-metadata (count-reducer-metadata)
+	strategy (make-count-reducer-strategy attribute-key (.getMetadata model) tgt-metadata)
 	view-name-fn #(str "count(" % ")")
-	reducer (make-reducer model attribute-key strategy count-reducer-metadata view-name-fn)]
+	reducer (make-reducer model attribute-key strategy tgt-metadata view-name-fn)]
     (connect model reducer)))

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


Fetch request needs to be recur'ed

Fetch request needs to be recur'ed

--- src/onyx/plugin/kafka.clj
+++ src/onyx/plugin/kafka.clj
@@ -75,7 +75,6 @@
               consumer (kc/consumer (:host broker) (:port broker) client-id)
               offset (starting-offset m consumer topic kpartition group-id task-map)
               fetch-size (or (:kafka/fetch-size task-map) (:kafka/fetch-size defaults))
-              messages (kc/messages consumer "onyx" topic kpartition offset fetch-size)
               empty-read-back-off (or (:kafka/empty-read-back-off task-map) (:kafka/empty-read-back-off defaults))
               commit-interval (or (:kafka/commit-interval task-map) (:kafka/commit-interval defaults))
               commit-fut (future (commit-loop group-id m topic kpartition commit-interval pending-commits))
@@ -83,12 +82,16 @@
           (log/info "Opening Kafka consumer" task-map)
           (log/info (str "Kafka consumer is starting at offset " offset))
           (try
-            (loop [ms messages]
+            (loop [ms (kc/messages consumer "onyx" topic kpartition offset fetch-size)
+                   head-offset offset]
               (if (first ms)
-                (>!! ch {:message (deserializer-fn (.value ^KafkaMessage (first ms)))
-                         :offset (.offset ^int (first ms))})
-                (Thread/sleep empty-read-back-off))
-              (recur (rest ms)))
+                (let [next-offset (.offset ^int (first ms))]
+                  (>!! ch {:message (deserializer-fn (.value ^KafkaMessage (first ms)))
+                           :offset next-offset})
+                  (recur (rest ms) next-offset))
+                (let [fetched (kc/messages consumer "onyx" topic kpartition head-offset fetch-size)]
+                  (Thread/sleep empty-read-back-off)
+                  (recur fetched head-offset))))
             (finally
              (future-cancel commit-fut))))
         (catch InterruptedException e


Sort commits.

Sort commits.

--- src/onyx/plugin/kafka.clj
+++ src/onyx/plugin/kafka.clj
@@ -46,7 +46,8 @@
       (read-from-bound consumer topic kpartition task-map))))

 (defn highest-offset-to-commit [offsets]
-  (->> (partition-all 2 1 offsets)
+  (->> (sort offsets)
+       (partition-all 2 1)
        (partition-by #(- (or (second %) (first %)) (first %)))
        (first)
        (last)


Add support for local buffers.

Add support for local buffers.

--- src/overtone/sc/synth.clj
+++ src/overtone/sc/synth.clj
@@ -11,7 +11,9 @@
         [overtone.sc.machinery.ugen fn-gen defaults common specs sc-ugen]
         [overtone.sc.machinery synthdef]
         [overtone.sc bindings ugens server node]
-        [overtone.helpers seq])
+        [overtone.helpers seq]
+        [clojure.pprint])
+
   (:require [overtone.util.log :as log]
             [clojure.set :as set]))

@@ -106,7 +108,11 @@
       (throw (Exception.
                (format "Cannot connect ugen arguments for %s ugen with args: %s" (:name ugen) (str (seq (:args ugen)))))))

-    ugen))
+    ;;Add link back to MaxLocalBufs ugen (always at root of tree) if
+    ;;ugen is a local-buf.
+    (if (= "LocalBuf" (:name ugen))
+      (assoc ugen :inputs (concat (:inputs ugen) {:src 0 :index 0}))
+      ugen)))

 ; TODO: Currently the output rate is hard coded to be the same as the
 ; computation rate of the ugen.  We probably need to have some meta-data
@@ -433,8 +439,14 @@
 (defsynth bar [freq 220] (out 0 (rlpf (saw [freq (* 3.013 freq)]) (x-line:kr 20000 2 1 FREE))))
 (definst faz [] (rlpf (saw [220 663]) (x-line:kr 20000 2 1 FREE)))
 (definst baz [freq 220] (rlpf (saw [freq (* 3.013 freq)]) (x-line:kr 20000 2 1 FREE)))
-(run 1 (out 184 (saw (x-line:kr 10000 10 1 FREE))))
-)
+(run 1 (out 184 (saw (x-line:kr 10000 10 1 FREE)))))
+
+(defn count-ugens
+  [ug-tree ug-name]
+  (let [ugens      (flatten  ug-tree)
+        local-bufs (filter #(= ug-name (:name %)) ugens)
+        ids        (set (map :id local-bufs))]
+    (count ids)))

 (defmacro pre-synth
   "Resolve a synth def to a list of its name, params, ugens (nested if
@@ -448,12 +460,20 @@
             (let [[ugens# constants#] (gather-ugens-and-constants
                                         (with-overloaded-ugens ~@ugen-form))
                   ugens# (topological-sort-ugens ugens#)
-;;                  _# (println "main-tree[" (count ugens#) "]: " ugens#)
-;;                  _# (println (str "*ugens*: [" (count *ugens*) "] " *ugens*))
+;;                _# (print  (with-out-str (print "main-tree[") (print  (count ugens#)) (print  "]: ") (pprint ugens#)))
+;;                _# (println (str "*ugens*: [" (count *ugens*) "] " *ugens*))
                   main-tree# (set ugens#)
                   side-tree# (filter #(not (main-tree# %)) *ugens*)
-;;                  _# (println "side-tree[" (count side-tree#) "]: " side-tree#)
+;;                _# (println "side-tree[" (count side-tree#) "]: " side-tree#)
                   ugens# (concat ugens# side-tree#)
+                  n-local-bufs# (count-ugens ugens# "LocalBuf")
+;;                _# (println "num local bufs: " n-local-bufs#)
+                  ugens# (if (> n-local-bufs# 0)
+                           (cons (max-local-bufs n-local-bufs#) ugens#)
+                           ugens#)
+                  constants# (if (> n-local-bufs# 0)
+                               (cons n-local-bufs# constants#)
+                               constants#)
                   constants# (into [] (set (concat constants# *constants*)))]
 ;;              (println "all ugens[" (count ugens#) "]: " ugens#)
        [~sname ~params ugens# constants#])))))


DM #3 - Minor refactoring: add authorization wrapper to create-objective in handlers map

--- src/d_cent/core.clj
+++ src/d_cent/core.clj
@@ -48,19 +48,17 @@
                       :objective-link-text (t' :objective-new-link/objective-link-text)
                       :locale (subs (str locale) 1)}))

-(def objective-create
-  (-> (fn [{:keys [t' locale] :as request}]
-        (rendered-response "objective_create.mustache"
-                        {:doc-title (t' :objective-create/doc-title)
-                         :doc-description (t' :objective-create/doc-description)
-                         :page-title (t' :objective-create/page-title)
-                         :title-label (t' :objective-create/title-label)
-                         :description-label (t' :objective-create/description-label)
-                         :actions-label (t' :objective-create/actions-label)
-                         :end-date-label (t' :objective-create/end-date)
-                         :submit (t' :objective-create/submit)
-                         :locale (subs (str locale) 1)}))
-      (friend/wrap-authorize #{:signed-in})))
+(defn objective-create [{:keys [t' locale] :as request}]
+  (rendered-response "objective_create.mustache"
+                     {:doc-title (t' :objective-create/doc-title)
+                      :doc-description (t' :objective-create/doc-description)
+                      :page-title (t' :objective-create/page-title)
+                      :title-label (t' :objective-create/title-label)
+                      :description-label (t' :objective-create/description-label)
+                      :actions-label (t' :objective-create/actions-label)
+                      :end-date-label (t' :objective-create/end-date)
+                      :submit (t' :objective-create/submit)
+                      :locale (subs (str locale) 1)}))

 (defn objective-create-post [request]
   (let [objective (request->objective request)]
@@ -88,7 +86,7 @@
                :sign-in sign-in
                :sign-out sign-out
                :email-capture    (friend/wrap-authorize email-capture #{:signed-in})
-               :objective-create objective-create
+               :objective-create (friend/wrap-authorize objective-create #{:signed-in})
                :objective-create-post (-> objective-create-post wrap-keyword-params wrap-params)
                :objective-view objective-view })


pull out and name keyword functions

pull out and name keyword functions

--- src/doctopus/db.clj
+++ src/doctopus/db.clj
@@ -20,6 +20,14 @@
     (if (:created new-fields) new-fields
       (assoc new-fields :created now-string))))

+(defn- ->kebab-keys
+  [fields]
+  (transform-keys ->kebab-case-keyword fields))
+
+(defn- ->snake-keys
+  [fields]
+  (transform-keys ->snake_case_keyword fields))
+
 (defdb db (sqlite3
            (select-keys (:database (server-config)) [:db :user :password])))

@@ -30,8 +38,8 @@
             (if html-commands
               (assoc tentacle :html-commands (string/join "\n" html-commands))
               tentacle)))
-  (prepare #(transform-keys ->snake_case_keyword %))
-  (transform #(transform-keys ->kebab-case-keyword %))
+  (prepare ->snake-keys)
+  (transform ->kebab-keys)
   (transform (fn [{html-commands :html-commands :as tentacle}]
               (if html-commands
                 (assoc tentacle :html-commands (split-lines html-commands))
@@ -40,8 +48,8 @@
 (defentity heads
   (pk :name)
   (prepare add-date-fields)
-  (prepare #(transform-keys ->snake_case_keyword %))
-  (transform #(transform-keys ->kebab-case-keyword %))
+  (prepare ->snake-keys)
+  (transform ->kebab-keys)
   (has-many tentacles {:fk :head_name}))

 (defn get-tentacle


pretty print

pretty print

--- src/funcgo/core.clj
+++ src/funcgo/core.clj
@@ -143,4 +143,9 @@
 (defn -main
   "Convert funcgo to clojure."
   [& args]
-  (println (funcgo-parse (slurp (first args)))))+  (doseq
+      [expr (read-string (str "["
+                              (funcgo-parse (slurp (first args)))
+                              "]"  ))]
+    (clojure.pprint/pprint expr)
+    (println)))


fix and config

fix and config

todo put config in a session

--- src/fxc/handler.clj
+++ src/fxc/handler.clj
@@ -80,50 +80,53 @@

   (GET "/share" []
-      (web/render-page
-       {:section "Share a Secret to 5 pieces (quorum 3)"
-        :body
-        [:div {:class "secrets row center"}
-         [:div {:class "content input-form"}
-          (fc/render-form generate-form-spec)]]}))
+       (let [config (config-read settings)]
+         (web/render-page
+          {:section "Share a Secret to 5 pieces (quorum 3)"
+           :body
+           [:div {:class "secrets row center"}
+            [:div {:class "content input-form"}
+             (fc/render-form (generate-form-spec config))]]})))

   (POST "/share" {params :params}
-        (let [input (fh/validate-form generate-form-spec params)]
+        (let [config (config-read settings)
+              input (fh/validate-form (generate-form-spec config))]
           (if (= (:status input) :error)
             (web/render-static (web/render-error input))
             ;; take only a max of 32 chars, else truncate
-            (let [pass   (trunc 32 (get-in input [:data :secret]))
-                  conf (config-read settings)
-                  shares (encode conf pass)]
+            (let [pass   (trunc (:max config) (get-in input [:data :secret]))
+                  shares (encode config pass)]

             (web/render-page
              {:section "Secret shared succesfully"
               :body [:div {:class "secrets row center"}
                      [:div {:class "slices"}
-                      [:h3 (str "Split to " (:total conf)
+                      [:h3 (str "Split to " (:total config)
                                 " shared secrets, quorum "
-                                (:quorum conf) ":")]
+                                (:quorum config) ":")]
                       [:ul (map #(conj [:li {:class "content"}] %)
                                 shares)]]]})))))

   (GET "/combine" []
-    (web/render-page {:section "Combine a Shared Secret"
-                      :body [:div {:class "recovery row center"}
-                         [:div {:class "content input-form"}
-                          (fc/render-form recovery-form-spec)
-                          ]]}))
+       (let [config (config-read settings)]
+             (web/render-page {:section "Combine a Shared Secret"
+                               :body [:div {:class "recovery row center"}
+                                      [:div {:class "content input-form"}
+                                       (fc/render-form (recovery-form-spec config))
+                                       ]]})))

   (POST "/combine" {params :params}
-        (let [input (fh/validate-form recovery-form-spec params)
-              conf (config-read settings)]
+        (let [config (config-read settings)
+              input (fh/validate-form (recovery-form-spec config))]
+
           (if (= (:status input) :error)
             (web/render-static (web/render-error input))
             (web/render-page
              {:section "Secret recovered succesfully"
               :body (let [para (:data input)
                           converted
-                          (decode conf
+                          (decode config
                                   (map #(trunc 256 %) (vals para)))]
                       [:div {:class "password"}
                        "Your Secret: "