Refactoring

Refactoring

--- src/yada/core.clj
+++ src/yada/core.clj
@@ -116,17 +116,6 @@
 (defn as-sequential [s]
   (if (sequential? s) s [s]))

-(defn cors [allow-origin]
-  (fn [ctx]
-    (if-let [origin (p/allow-origin allow-origin ctx)]
-      (update-in ctx [:response :headers]
-                 merge {"access-control-allow-origin"
-                        origin
-                        "access-control-expose-headers"
-                        (apply str
-                               (interpose ", " ["Server" "Date" "Content-Length" "Access-Control-Allow-Origin"]))})
-      ctx)))
-
 (defn exists-flow [method state req status headers body post allow-origin]
   (fn [ctx]
     (case method
@@ -419,17 +408,17 @@
                ;; temporarily storing the whole (potentially huge) body
                ;; somewhere.
                #_(assoc req
-                      ;; We assoc in a 'delayed' body to the context's
-                      ;; version of the request. The first caller to
-                      ;; deref causes the slurp (which to do ahead of
-                      ;; time might be unnecessarily wasteful).
-                      :body (delay
-                             (if-let [body (:body req)]
-                               ;; TODO Don't slurp, read into a byte array
-                               ;; Does aleph provide access to the underlying javax.nio.ByteBuffer(s)?
-                               ;; (yes - provided option raw-stream? is true)
-                               (slurp body :encoding (or (character-encoding req) "utf8"))
-                               nil)))
+                        ;; We assoc in a 'delayed' body to the context's
+                        ;; version of the request. The first caller to
+                        ;; deref causes the slurp (which to do ahead of
+                        ;; time might be unnecessarily wasteful).
+                        :body (delay
+                               (if-let [body (:body req)]
+                                 ;; TODO Don't slurp, read into a byte array
+                                 ;; Does aleph provide access to the underlying javax.nio.ByteBuffer(s)?
+                                 ;; (yes - provided option raw-stream? is true)
+                                 (slurp body :encoding (or (character-encoding req) "utf8"))
+                                 nil)))
                :resource-map resource-map})

              (d/chain
@@ -600,31 +589,214 @@
               ;; Split the flow based on the existence of the resource
               (fn [ctx]

-                (cond
-                  ;; 'Exists' flow
-                  ;; TODO: Not sure that exists-flow is what we're doing here - exists-flow has all kinds of things complected in it. Break up into individual cases, perhaps based on method. We are only using this to avoid the 404 of the 'not exists' flow. Perhaps check for existence and throw the 404 now if necessary.
-                  (or state body (#{:post :put} method))
+                (case method
+                  (:get :head)
                   (d/chain
                    ctx
-                   ;; Not sure we should use exists-flow for CORS pre-flight requests, should handle further above
-                   (exists-flow method state req status headers body post allow-origin)
-                   (cors allow-origin)
-
+
+                   ;; OK, let's pick the resource's state
                    (fn [ctx]
-                     (merge
-                      {:status (or (get-in ctx [:response :status])
-                                   (p/status status ctx)
-                                   200)
-                       :headers (merge
-                                 (get-in ctx [:response :headers])
-                                 (p/headers headers ctx))
-                       ;; TODO :status and :headers should be implemented like this in all cases
-                       :body (get-in ctx [:response :body])}))
-                   )
-
-                  ;; 'Not exists' flow
-                  :otherwise
-                  (d/chain ctx (constantly {:status 404})))))
+                     (d/chain
+                      state             ; could be nil
+                      #(p/state % ctx)
+                      (fn [state] (if state (assoc-in ctx [:resource :state] state) ctx))))
+
+                   ;; Conditional request
+                   (link ctx
+                     (let [state (get-in ctx [:resource :state])]
+                       (if-let [last-modified (yst/last-modified state)]
+
+                         (if-let [if-modified-since (some-> req
+                                                            (get-in [:headers "if-modified-since"])
+                                                            parse-date)]
+                           (let [last-modified (if (d/deferrable? last-modified) @last-modified last-modified)]
+
+                             (if (<=
+                                  (.getTime last-modified)
+                                  (.getTime if-modified-since))
+
+                               ;; exit with 304
+                               (d/error-deferred
+                                (ex-info "" (merge {:status 304
+                                                    ::http-response true}
+                                                   ctx)))
+
+                               (assoc-in ctx [:response :headers "last-modified"] (format-date last-modified))))
+
+                           (do
+                             (infof "No if-modified-since header: %s" (:headers req))
+                             (or
+                              (some->> (if (d/deferrable? last-modified) @last-modified last-modified)
+                                       format-date
+                                       (assoc-in ctx [:response :headers "last-modified"]))
+                              ctx))))))
+
+                   ;; Create body
+                   (fn [ctx]
+                     (let [state (get-in ctx [:resource :state])
+                           content-type
+                           (or (get-in ctx [:response :content-type])
+                               ;; It's possible another callback has set the content-type header
+                               (get-in headers ["content-type"])
+                               (when-not body
+                                 ;; Hang on, we should have done content neg by now
+                                 (rep/content-type-default state)))
+                           content-length (rep/content-length state)]
+
+                       (case method
+                         :head (if content-type
+                                 ;; We don't need to add Content-Length,
+                                 ;; Content-Range, Trailer or Tranfer-Encoding, as
+                                 ;; per rfc7231.html#section-3.3
+                                 (update-in ctx [:response :headers] assoc "content-type" content-type)
+                                 ctx)
+
+                         :get
+                         (d/chain
+
+                          ;; Determine body
+                          (cond
+                            body (p/body body ctx)
+                            state state ; the state here can still be deferred
+                            )
+
+                          ;; serialize to representation (an existing string will be left intact)
+                          (fn [state]
+                            (rep/content state content-type))
+
+                          ;; on nil, compose default result (if in dev)
+                          #_(fn [x] (if x x (rep/content nil content-type)))
+
+                          (fn [body]
+                            (if (not= method :head)
+                              (assoc-in ctx [:response :body] body)
+                              ctx))
+
+                          (fn [ctx]
+                            (if content-type
+                              (update-in ctx [:response :headers] assoc "content-type" content-type)
+                              ctx
+                              ))
+
+                          (fn [ctx]
+                            (if content-length
+                              (update-in ctx [:response :headers] assoc "content-length" content-length)
+                              ctx)))))))
+
+                  :put
+                  (d/chain
+                   ctx
+                   (link ctx
+                     (when-let [etag (get-in req [:headers "if-match"])]
+                       (when (not= etag (get-in ctx [:resource :etag]))
+                         (throw
+                          (ex-info "Precondition failed"
+                                   {:status 412
+                                    ::http-response true})))))
+
+                   ;; Do the put!
+                   (fn [ctx]
+                     (let [exists? (yst/exists? state)]
+                       (if-let [put (some-> ctx :resource-map :put)]
+                         ;; Custom put function
+                         ;; TODO Rename put to put!
+                         (p/put put ctx)
+                         ;; Default behaviour
+                         (if state
+                           (yst/write! state ctx)
+                           (throw (ex-info "No implementation of put" {}))))
+                       (assoc-in ctx [:response :status]
+                                 (if exists? 204 201)))))
+
+                  :post
+                  (d/chain
+                   ctx
+
+                   (link ctx
+                     (when-let [etag (get-in req [:headers "if-match"])]
+                       (when (not= etag (get-in ctx [:resource :etag]))
+                         (throw
+                          (ex-info "Precondition failed"
+                                   {:status 412
+                                    ::http-response true})))))
+
+                   (fn [ctx]
+                     ;; TODO: what if error?
+
+                     ;; TODO: Should separate p/post from p/interpret-post-result
+                     ;; because p/post could return a deferred, so we need to chain
+                     ;; them together rather than complicate logic in resource.clj
+                     (p/interpret-post-result (p/post post ctx) ctx))
+
+                   (fn [ctx]
+                     (-> ctx
+                         (assoc-in [:response :status] 200))))
+
+                  :options
+                  (d/chain
+                   ctx
+                   (link ctx
+                     (if-let [origin (p/allow-origin allow-origin ctx)]
+                       (update-in ctx [:response :headers]
+                                  merge {"access-control-allow-origin"
+                                         origin
+                                         "access-control-allow-methods"
+                                         (apply str
+                                                (interpose ", " ["GET" "POST" "PUT" "DELETE"]))}))))
+
+                  (throw (ex-info "Unknown method"
+                                  {:status 501
+                                   :http-response true})))
+
+                #_(cond
+                    ;; 'Exists' flow
+                    ;; TODO: Not sure that exists-flow is what we're doing here - exists-flow has all kinds of things complected in it. Break up into individual cases, perhaps based on method. We are only using this to avoid the 404 of the 'not exists' flow. Perhaps check for existence and throw the 404 now if necessary.
+                    (or state body (#{:post :put} method))
+                    (d/chain
+                     ctx
+                     ;; Not sure we should use exists-flow for CORS pre-flight requests, should handle further above
+                     (exists-flow method state req status headers body post allow-origin)
+                     (cors allow-origin)
+
+                     (fn [ctx]
+                       (merge
+                        {:status (or (get-in ctx [:response :status])
+                                     (p/status status ctx)
+                                     200)
+                         :headers (merge
+                                   (get-in ctx [:response :headers])
+                                   (p/headers headers ctx))
+                         ;; TODO :status and :headers should be implemented like this in all cases
+                         :body (get-in ctx [:response :body])}))
+                     )
+
+                    ;; 'Not exists' flow
+                    :otherwise
+                    (d/chain ctx (constantly {:status 404}))))
+
+              (fn [ctx]
+                (merge
+                 {:status (or (get-in ctx [:response :status])
+                              (p/status status ctx)
+                              200)
+                  :headers (merge
+                            (get-in ctx [:response :headers])
+                            (p/headers headers ctx))
+                  ;; TODO :status and :headers should be implemented like this in all cases
+                  :body (get-in ctx [:response :body])}))
+
+              (fn [ctx]
+               (if-let [origin (p/allow-origin allow-origin ctx)]
+                 (update-in ctx [:response :headers]
+                            merge {"access-control-allow-origin"
+                                   origin
+                                   "access-control-expose-headers"
+                                   (apply str
+                                          (interpose ", " ["Server" "Date" "Content-Length" "Access-Control-Allow-Origin"]))})
+                 ctx))
+
+              ;; End of chain
+              )

              ;; Handle exits
              (d/catch clojure.lang.ExceptionInfo


Latest triggers

Latest triggers

--- src/yaqp/core.clj
+++ src/yaqp/core.clj
@@ -15,10 +15,11 @@

 (def eq-logs-dir "C:/binski/apps/eq/Logs/")

-(defonce app
+(def app
   (atom {:kill nil
          :tail nil
          :log-path "/home/mattk/wine/eq/drive_c/eq/Logs/eqlog_Hypermagic_P1999Green.txt"
+;;         :log-path "/home/mattk/wine/eq/drive_c/eq/Logs/eqlog_Haddgar_P1999Green.txt"
          ;;:log-path "C:/dev/yaqp/log/eqlog_Hadiar_project1999.txt"
          ;:log-path "C:/binski/apps/eq/Logs/eqlog_Subgenius_project1999.txt"
          ;;:log-path "C:/binski/apps/eq/Logs/eqlog_Hadiar_project1999.txt"
@@ -70,23 +71,76 @@
   `(
     "The cool breeze fades." (speak "Blue meth please?")
     "charm spell has worn off" (speak "Pet is loose, pet is loose.")
-    #"(.*) looks uncomfortable" (speak "%t is malo")
-
-    #"(.*) looks less aggressive" (timer "Calm" "3:00")
-
-    #"(.*) has been mesmerized by the Glamour" (timer "Mez" "00:54")
+    #"(.*) looks very uncomfortable" (speak "%t is malo")
+    "You feel yourself starting to appear" (speak "Invis fading")
+    #"(.*) yawns" (speak "slow %t")
+    #"(.*) slows down" (speak "slow %t")
+
+    "hits you" (speak "hit")
+
+    "You begin casting Dictate" (timer "Dictate" "00:52" {:remaining? true})
+
+;;    #"(.*) looks less aggressive" (timer "Calm" "3:00")
+    #"(.*) looks less aggressive" (timer "Paci" "7:00")
+
+    #"(.*) has been mesmerized by the Glamour" (timer "Mez" "00:30")
     #"(.*) has been mesmerized\." (timer "Mez" "00:24")
     #"(.*) has been enthralled." (timer "Mez" "00:48")
     #"(.*) has been entranced." (timer "Mez" "00:80")
     #"(.*) has been fascinated." (timer "Mez" "00:36")
-
+
+    #"Basher (.*) has been slain by" (timer "Pop" "24:00"
+                                            {:remaining? true
+                                             :on-end #(speak "%t pop" %)})
+
+    #"(.*) says, 'Curse you" (timer "" "24:00"
+                                    {:remaining? true
+                                     :on-end #(speak "%t pop" %)})
+
+
     #"You have slain Bouncer (.*)" (timer "Pop" "24:00"
-                                          {:remaining? true})
+                                          {:remaining? true
+                                           :on-end #(speak "%t pop" %)})
+
+    #"You have slain Basher (.*)" (timer "" "24:00"
+                                          {:remaining? true
+                                           :on-end #(speak "%t pop" %)})
+
+;;    "slain by" (timer "Pop" "6:40" {:remaining? true})
+;;    "You have slain" (timer "Pop" "6:40" {:remaining? true})
+
+    ;; "a spectre has been slain" (timer "spectre" "6:40"
+    ;;                                   {:remaining? true})
+    ;; "You have slain a spectre" (timer "spectre" "6:40"
+    ;;                                   {:remaining? true})
+
+    ;;"You gain experience" (timer "Pop" "5:50"
+    ;;                             {:remaining? true})
+
+    "You have slain Cynthia" (timer "Cynthia" "5:50"
+                                    {:remaining? true})
+
+    ;; "You have slain Cynthia" (timer "Cynthia Warn" "5:35"
+    ;;                                 {:remaining? true
+    ;;                                  :on-end #(speak (str "Cynthia pop, Cynthia pop" %))})
+
+
+;;     "You gain party experience" (timer "Pop" "27:00"
+;;                                        {:remaining? true})
+
+     ;; "has been slain by" (timer "Pop" "18:00"
+     ;;                            {:remaining? true})
+
+     ;; "You have slain" (timer "Pop" "18:00"
+     ;;                         {:remaining? true})

     ;; #"(.*) feels much faster." (timer "Swift" "14:30")

     #"(.*) experiences a quickening." (timer "Haste" "24:00"
-                                             {:on-end #(speak "%t needs AQ" %)})
+                                             {:on-end #(speak "%t needs A.Q." %)})
+
+    #"(.*) begins to move with wonderous rapidity." (timer "WR" "18:20"
+                                                           {:on-end #(speak "%t needs haste." %)})

     #"(.*) experiences visions of grandeur." (timer "VoG" "42:00")
     ;#"(.*) experiences a quickening." (timer "AQ" "0:05")
@@ -100,7 +154,10 @@
     "Subgenius drops dead." (timer "Feign" "0:10")

     "A cool breeze slips through your mind." (timer "Crack" "26:00" {:fg "cyan"})
-    "A soft breeze slips through your mind." (timer "Crack" "35:00" {:fg "blue" :color "white"})
+    "A soft breeze slips through your mind." (timer "Crack" "35:00" {:fg "blue"
+                                                                     :color "white"})
+
+    "You gather mana from your surroundings." (timer "Harvest" "10:00" {:remaining? true})
     ;;"Your spirit screams with berserker strength." (timer "Zerk" "5:00")
     ;;"the skin breaking and peeling." (timer "Boon" "4:30")


Printing message to *out* so I can know when to go grab coffee

--- jvm-runner/test/codewars/runner/clojure_test.clj
+++ jvm-runner/test/codewars/runner/clojure_test.clj
@@ -86,6 +86,7 @@
     (with-in-str
       (json/generate-string
        {:language "clojure"
-        :solution "(Thread/sleep 50000)"})
+        :solution "(println \"...Sleeping deeply...\")
+                   (Thread/sleep 50000)"})
       (with-redefs [core/fail #(throw %)]
         (is (thrown? TimeoutException (-main)))))))


Fix phonebook dependencies blow-up

Fix phonebook dependencies blow-up

--- examples/phonebook/project.clj
+++ examples/phonebook/project.clj
@@ -5,7 +5,7 @@
   :license {:name "The MIT License"
             :url "http://opensource.org/licenses/MIT"}

-  :dependencies [[aero "0.1.4"]
+  :dependencies [[aero "0.1.4" :exclusions [prismatic/schema]]
                  [aleph "0.4.1-beta2" :exclusions [org.clojure/clojure byte-streams]]
                  [com.stuartsierra/component "0.3.1"]
                  [hiccup "1.0.5" :exclusions [org.clojure/clojure]]


fix overzealous search and replace.

fix overzealous search and replace.

--- dev/etl.clj
+++ dev/etl.clj
@@ -30,7 +30,7 @@

 (def custom-formatter (tf/formatter "yyyy-MM-dd'T'HH:mm:ss.SSSZ"))

-(defn difference_series-batch
+(defn difference-series-batch
   "Retrieves all sensors that need to have difference series calculated and performs calculations."
   [commander querier item]
   (let [sensors (m/all-sensors querier)]
@@ -353,7 +353,7 @@
       (let [commander (-> system :store :commander)
             querier   (-> system :store :querier)]

-        (difference_series-batch commander querier {})
+        (difference-series-batch commander querier {})
         (rollups commander querier {})))
     (catch Exception e
       (log/error e "ETL failed:"))))


Creates parent directories as necessary

Creates parent directories as necessary

--- jvm-runner/src/clojure/codewars/util.clj
+++ jvm-runner/src/clojure/codewars/util.clj
@@ -42,6 +42,7 @@
         (format "Could not write to file %s, because that file already exists.  Perhaps it already contains the setup or test fixture code?\ncode:\n%s" (pr-str base-name) code)))
       ;; else
       (do
+        (-> file-name .getParentFile .mkdirs)
         (spit file-name code)
         {:file-name file-name
          :class-name class-name}))))


Trim unnecessary fully qualified namespace

--- test/cljam/t_cli.clj
+++ test/cljam/t_cli.clj
@@ -7,12 +7,12 @@

 (defmacro with-out-file
   [f & body]
-  `(let [os# (clojure.java.io/output-stream ~f)
+  `(let [os# (io/output-stream ~f)
          old-ps# System/out
          ps# (PrintStream. os#)]
      (try
        (System/setOut ps#)
-       (binding [*out* (clojure.java.io/writer os#)]
+       (binding [*out* (io/writer os#)]
          ~@body)
        (finally
          (.flush ps#)


more idiomatic selection of messages

more idiomatic selection of messages

--- barge-ui/src/barge/core.cljs
+++ barge-ui/src/barge/core.cljs
@@ -82,6 +82,9 @@
                 (dom/tr nil
                   (dom/th nil "Timestamp")
                   (dom/th nil "Message")))
+
+              ;; not sure why we have to use apply here? means that tbody is actually a function, but then
+              ;; why can't I call it directly?
               (apply dom/tbody nil
                  (map format-msg
                      (take count cursor)))
@@ -102,22 +105,22 @@
              #js {:onClick #(toggle-connect owner id (om/get-state owner :connected))
                   :className "pure-button pure-button-primary"}
             (if connected
-              (str "Disconnect " id)
-             (str "Connect " id)
+              (str "Disconnect " (name id))
+             (str "Connect " (name id))
               ))
           (om/build messages-view
-                    (:msgs ((keyword id) app))
+                    (-> app id :msgs)
                     {:init-state {:count 15}})
           )))))

 (defn set-root
-  [name] (om/root (node-view name)
+  [id] (om/root (node-view id)
              node-state
-          {:target (. js/document (getElementById name))}))
+          {:target (. js/document (getElementById (name id)))}))

-(set-root "node1")
-(set-root "node2")
-(set-root "node3")
+(set-root :node1)
+(set-root :node2)
+(set-root :node3)


Don't strip characters from page title.

Don't strip characters from page title.

--- src-cljs/frontend/utils.cljs
+++ src-cljs/frontend/utils.cljs
@@ -186,11 +186,6 @@
   [f]
   (.start (goog.async.AnimationDelay. f)))

-(defn strip-html
-  "Strips all html characters from the string"
-  [str]
-  (string/replace str #"[&<>\"']" ""))
-
 (defn valid-email? [str]
   (.isValidAddrSpec EmailAddress str))

@@ -240,10 +235,9 @@

 (defn set-page-title! [& [title]]
-  (set! (.-title js/document) (strip-html
-                               (if title
-                                 (str title  " - CircleCI")
-                                 "CircleCI"))))
+  (set! (.-title js/document) (if title
+                                (str title  " - CircleCI")
+                                "CircleCI")))

 (defn set-page-description!
   [description]


add re-seq-pos

add re-seq-pos

--- ohack/src/ohack/core.clj
+++ ohack/src/ohack/core.clj
@@ -208,6 +208,14 @@
   )

 ;; we want a function that takes a regex and returns the position of the match...
+;; turns out someone asked for the exact same thing on SO!
+;; http://stackoverflow.com/questions/21191045/get-string-indices-from-the-result-of-re-seq
+(defn re-seq-pos [pattern string]
+  (let [m (re-matcher pattern string)]
+    ((fn step []
+      (when (. m find)
+        (cons {:start (. m start) :end (. m end) :group (. m group)}
+              (lazy-seq (step))))))))

 ;; copy a line from the prn output and add in a hammer for good measure:
 (let [line "B|----1-----2----0----3----|--1---0---3------|--1---0---3---0h1-|--1---3------|"]


j.u.HashMap fails with nil

j.u.HashMap fails with nil

--- modules/reitit-core/src/reitit/impl.cljc
+++ modules/reitit-core/src/reitit/impl.cljc
@@ -161,7 +161,7 @@
       :cljs [[a k v] (assoc a k v)]))

 (defn fast-map [m]
-  #?@(:clj  [(java.util.HashMap. m)]
+  #?@(:clj  [(java.util.HashMap. (or m {}))]
       :cljs [m]))

 (defn fast-get


added get on

added get on

--- src/babel/english/lexicon.clj
+++ src/babel/english/lexicon.clj
@@ -414,6 +414,19 @@
       :english {:participle "getting dressed"
                 :present {:3sing "gets dressed"}
                 :past "got dressed"}})
+
+   "get on"
+   (let [subject-semantics (ref {:human true})]
+     {:synsem {:cat :verb
+               :sem {:pred :get-on
+                     :subj subject-semantics
+                     :obj subject-semantics}
+               :subcat {:1 {:sem subject-semantics}
+                        :2 '()}}
+      :english {:participle "getting on"
+                :present {:3sing "gets on"}
+                :past "got on"}})
+
    "get ready"
    (let [subject-semantics (ref {:human true})]
      {:synsem {:cat :verb


fix typos in Spanish

fix typos in Spanish

--- src/babel/espanol/lexicon.clj
+++ src/babel/espanol/lexicon.clj
@@ -52,7 +52,7 @@
    "cambiar" {:synsem {:cat :verb
                        :sem {:pred :cambiare}}}

-   "cerrar" {:spanish {:boot-stem1 "cierr"
+   "cerrar" {:espanol {:boot-stem1 "cierr"
                         :boot-stem2 "cerr"}
              :synsem {:cat :verb
                       :sem {:pred :close}}}
@@ -208,20 +208,20 @@
                    :pred :loro}
              :subcat '()}}

-    "empezar" {:boot-stem1 "empiez"
+   "empezar" {:espanol {:boot-stem1 "empiez"
                         :boot-stem2 "empez"}
-             :synsem {:cat :verb
-                      :sem {:pred :begin}}
+              :synsem {:cat :verb
+                       :sem {:pred :begin}}}

    "enseñar" [{:synsem {:cat :verb
                         :sem {:pred :show}}}
               {:synsem {:cat :verb
                         :sem {:pred :teach}}}]
-
-    "entender" {:spanish {:boot-stem1 "entiend"
-                        :boot-stem2 "entend"}
-             :synsem {:cat :verb
-                      :sem {:pred :understand-simply}}}
+
+   "entender" {:espanol {:boot-stem1 "entiend"
+                         :boot-stem2 "entend"}
+               :synsem {:cat :verb
+                        :sem {:pred :understand-simply}}}

    "entrar" {:synsem {:cat :verb
                       :sem {:pred :enter}}}
@@ -269,7 +269,7 @@
                             :subj {:human true}
                             :obj {:human false}}}}]

-   ;; TODO: handle syntax/semantics mismatch between Italian/Spanish and English.
+   ;; TODO: handle syntax/semantics mismatch between Italian/Espanol and English.
                                         ;                     "gustar" {:synsem {:cat :verb
                                         ;                                         :sem {:pred :??}}}

@@ -343,8 +343,8 @@
                                  :number :sing
                                  :def :def}}}})

-    "pensar" {:spanish {:boot-stem1 "piens"
-                        :boot-stem2 "pens"}
+   "pensar" {:espanol {:boot-stem1 "piens"
+                       :boot-stem2 "pens"}
              :synsem {:cat :verb
                       :sem {:pred :think}}}


format dates in income statment filter form

--- src/clj_money/web/reports.clj
+++ src/clj_money/web/reports.clj
@@ -7,6 +7,7 @@
             [hiccup.page :refer :all]
             [clj-time.core :as t]
             [clj-money.util :refer [format-number
+                                    format-date
                                     parse-date]]
             [clj-money.web.shared :refer :all]
             [clj-money.models.reports :as reports]))
@@ -64,12 +65,12 @@
     [:label.control-label {:for :start-date} "Start Date"]
     [:input.form-control.date-field {:type :text
                                      :name :start-date
-                                     :value (:start-date params)}]]
+                                     :value (format-date (:start-date params))}]]
    [:div.form-group
     [:label {:for :end-date} "End Date"]
     [:input.form-control.date-field {:type :text
                                      :name :end-date
-                                     :value (:end-date params)}]]
+                                     :value (format-date (:end-date params))}]]
    [:input.btn.btn-primary {:type :submit :value "Show"}]])

 (defmethod render-filter :balance-sheet


Enable rerendering when new code is loaded.

--- scripts/figwheel.clj
+++ scripts/figwheel.clj
@@ -10,7 +10,7 @@
    :build-ids ["dev"]
    :all-builds
    [{:id "dev"
-     :figwheel true
+     :figwheel {:on-jsload "uxbox.ui/init"}
      :source-paths ["src"]
      :compiler {:main 'uxbox.core
                 :asset-path "js"


Load `datomic.clj` from `.lein/profiles.clj`

- but only if it exists

I'm not sure this is what I'll do long-term, but I don't like the
alternative (GPG-encrypted credentials), because it still doesn't seem
to solve the "Don't add the Datomic repo to every project" problem.

--- .lein/profiles.clj
+++ .lein/profiles.clj
@@ -1,3 +1,7 @@
-{:user {:plugins [[lein-try "0.4.1"]
-                  [lein-pprint "1.1.1"]
-                  [cider/cider-nrepl "0.8.0"]]}}
+{:user #=(merge
+           {:plugins [[lein-try "0.4.1"]
+                      [lein-pprint "1.1.1"]
+                      [cider/cider-nrepl "0.8.0"]]}
+           #=(eval (try (read-string (slurp (str (System/getProperty "user.home")
+                                                 "/.config/datomic.clj")))
+                     (catch Exception e {}))))}


add TODO comment

add TODO comment

--- src/braid/server/routes/bots.clj
+++ src/braid/server/routes/bots.clj
@@ -101,6 +101,7 @@
          :headers {"Content-Type" "text/plain"}
          :body "Invalid user id"})))

+  ; TODO: allow unsubscribed by sending DELETE
   (PUT "/subscribe/:thread-id" [thread-id :as req]
     (let [bot-id (get req ::bot-id)
           bot (db/bot-by-id bot-id)]


Change comment indentifiers to match clojure idioms

In-method comments (those that shouldn't be hard-aligned against column 0)
should have a leading ';' as opposed to ';;'. This jives with how Emacs does
indentation and how marginalia determines what is sidebar material.

--- src/com/puppetlabs/cmdb/core.clj
+++ src/com/puppetlabs/cmdb/core.clj
@@ -49,32 +49,32 @@
 (defn persist-resource!
   "Given a host and a single resource, persist that resource and its parameters"
   [host {:keys [type title hash exported parameters] :as resource}]
-  ;; Have to do this to avoid deadlock on updating "resources" and
-  ;; "resource_params" tables in the same xaction
+  ; Have to do this to avoid deadlock on updating "resources" and
+  ; "resource_params" tables in the same xaction
   (sql/do-commands "LOCK TABLE resources IN EXCLUSIVE MODE")

   (let [persisted? (resource-already-persisted? hash)]

     (when-not persisted?
-      ;; Add to resources table
+      ; Add to resources table
       (sql/insert-record :resources {:hash hash :type type :title title :exported exported})

-      ;; Build up a list of records for insertion
+      ; Build up a list of records for insertion
       (let [records (for [[name value] parameters]
-                      ;; I'm not sure what to do about multi-value columns.
-                      ;; I suppose that we could put them in as an array of values,
-                      ;; but then I think we'll have to call out directly to the JDBC
-                      ;; driver as most ORM layers don't support arrays (clojure.core/sql
-                      ;; included)
+                      ; I'm not sure what to do about multi-value columns.
+                      ; I suppose that we could put them in as an array of values,
+                      ; but then I think we'll have to call out directly to the JDBC
+                      ; driver as most ORM layers don't support arrays (clojure.core/sql
+                      ; included)
                       (let [value (if (coll? value)
                                     (json/generate-string value)
                                     value)]
                         {:resource hash :name name :value value}))]

-        ;; ...and insert them
+        ; ...and insert them
         (apply sql/insert-records :resource_params records)))

-    ;; Insert pointer into host => resource map
+    ; Insert pointer into host => resource map
     (sql/insert-record :host_resources {:host host :resource hash})))

 (defn persist-edges!


run takes :interactive, bind-applets is private

--- src/rosado/processing/applet.clj
+++ src/rosado/processing/applet.clj
@@ -1,38 +1,44 @@
 (ns rosado.processing.applet
-  (:use [rosado.processing]
-        [clojure.contrib.java-utils :only [as-str]])
-  (:import (java.awt Frame)))
+  (:use [rosado.processing])
+  (:import (javax.swing JFrame)))

-(defn bind-applets
+(defn- bind-applets
   "Turn the method map into something one that update-proxy can use."
   [methods [method-name f]]
   (assoc methods (name method-name)
-         (fn [this & args]
-           (binding [*applet* this]
-             (apply f args)))))
+         `(fn [this# & args#]
+            (binding [*applet* this#]
+              (apply ~f args#)))))

 (defmacro defapplet
   "Define an applet. Takes an app-name and a map of options."
   [app-name & opts]
   (let [options (assoc (apply hash-map opts) :name (str app-name))
-        fns (dissoc options :name :title :height :width)]
+        fns (dissoc options :name :title :height :width)
+        methods (reduce bind-applets {} fns)]
     `(def ~app-name
           (let [frame# (atom nil)
-                methods# (reduce bind-applets {} ~fns)
                 prx# (proxy [processing.core.PApplet
                              clojure.lang.IMeta] []
                        (meta [] (assoc ~options :frame frame#)))]
-            (update-proxy prx# methods#)
+            (update-proxy prx# ~methods)
             prx#))))

-(defn run [applet]
+(defn run
+  "Launches the applet. If given the flag :interactive, it won't exit
+  on clicking the close button - it will only dispose the window."
+  [applet & interactive?]
   (.init applet)
   (let [m (.meta applet)
         width (or (:width m) 200)
-        height (or (:height m) 200)]
+        height (or (:height m) 200)
+        close-op (if (first interactive?)
+                   JFrame/DISPOSE_ON_CLOSE
+                   JFrame/EXIT_ON_CLOSE)]
     (.size applet width height)
     (reset! (:frame m)
-            (doto (Frame. (or (:title m) (:name m)))
+            (doto (JFrame. (or (:title m) (:name m)))
+              (.setDefaultCloseOperation close-op)
               (.setSize width height)
               (.add applet)
               (.pack)


guard all methods with allow read

guard all methods with allow read

--- src/quiescent.cljs
+++ src/quiescent.cljs
@@ -51,21 +51,21 @@
                                            (binding [*component* this]
                                              #js {:value (get-initial-state)})))))
                  (:getDefaultProps m)
-                 (q/set-prop! -getDefaultProps (fn [] (.apply (:getDefaultProps m) (js-this) (js-arguments))))
+                 (q/set-prop! -getDefaultProps (fn [] (om/allow-reads (.apply (:getDefaultProps m) (js-this) (js-arguments)))))
                  (:componentWillMount m)
-                 (q/set-prop! -componentWillMount (fn [] (.apply (:componentWillMount m) (js-this) (js-arguments))))
+                 (q/set-prop! -componentWillMount (fn [] (om/allow-reads (.apply (:componentWillMount m) (js-this) (js-arguments)))))
                  (:componentDidMount m)
-                 (q/set-prop! -componentDidMount (fn [] (.apply (:componentDidMount m) (js-this) (js-arguments))))
+                 (q/set-prop! -componentDidMount (fn [] (om/allow-reads (.apply (:componentDidMount m) (js-this) (js-arguments)))))
                  (:componentWillReceiveProps m)
-                 (q/set-prop! -componentWillReceiveProps (fn [] (.apply (:componentWillReceiveProps m) (js-this) (js-arguments))))
+                 (q/set-prop! -componentWillReceiveProps (fn [] (om/allow-reads (.apply (:componentWillReceiveProps m) (js-this) (js-arguments)))))
                  (:shouldComponentUpdate m)
-                 (q/set-prop! -shouldComponentUpdate (fn [] (.apply (:shouldComponentUpdate m) (js-this) (js-arguments))))
+                 (q/set-prop! -shouldComponentUpdate (fn [] (om/allow-reads (.apply (:shouldComponentUpdate m) (js-this) (js-arguments)))))
                  (:componentWillUpdate m)
-                 (q/set-prop! -componentWillUpdate (fn [] (.apply (:componentWillUpdate m) (js-this) (js-arguments))))
+                 (q/set-prop! -componentWillUpdate (fn [] (om/allow-reads (.apply (:componentWillUpdate m) (js-this) (js-arguments)))))
                  (:componentDidUpdate m)
-                 (q/set-prop! -componentDidUpdate (fn [] (.apply (:componentDidUpdate m) (js-this) (js-arguments))))
+                 (q/set-prop! -componentDidUpdate (fn [] (om/allow-reads (.apply (:componentDidUpdate m) (js-this) (js-arguments)))))
                  (:componentWillUnmount m)
-                 (q/set-prop! -componentWillUnmount (fn [] (.apply (:componentWillUnmount m) (js-this) (js-arguments)))))
+                 (q/set-prop! -componentWillUnmount (fn [] (om/allow-reads (.apply (:componentWillUnmount m) (js-this) (js-arguments))))))
         react-component (.createClass js/React react-map)
         q-wrapper (fn [value & static-args]
                     (let [props #js {:value value :statics static-args}]


reset changes to nil. next name invocation generates new name.

--- clojure/robot-name/robot.clj
+++ clojure/robot-name/robot.clj
@@ -19,7 +19,8 @@
   (atom (next-name)))

 (defn robot-name [robot]
-  @robot)
+  (or @robot
+      (reset! robot (next-name))))

 (defn reset-name [robot]
-  (reset! robot (next-name)))
+  (reset! robot nil))


few tweaks to scrape

few tweaks to scrape

--- clj-scrape/src/clj_scrape/core.clj
+++ clj-scrape/src/clj_scrape/core.clj
@@ -10,7 +10,7 @@
          '[clojure.contrib.zip-filter.xml :as zfxml]
          '[clojure.zip :as zip])

-
+; http://paste.lisp.org/display/70171
 (defn- startparse-tagsoup [s ch]
   "startparse fn required by xml/parse constructor for generating a tagsoup
   parse stream."
@@ -24,16 +24,16 @@
   (zip/xml-zip
     (xml/parse (org.xml.sax.InputSource. stream) startparse-tagsoup)))

-(def xml->      zfxml/xml->)
-(def xml1->     zfxml/xml1->)
-(def desc       zf/descendants)
-(def leftmost?  zf/leftmost?)
-(def rightmost? zf/rightmost?)
-(def ansc       zf/ancestors)
-(def children   zf/children)
-(def attr       zfxml/attr)
-(def attr=      zfxml/attr=)
-(def text       zfxml/text)
+(def xml->       zfxml/xml->)
+(def xml1->      zfxml/xml1->)
+(def rightmost?  zf/leftmost?)
+(def rightmost?  zf/rightmost?)
+(def desc        zf/descendants)
+(def ansc        zf/ancestors)
+(def children    zf/children)
+(def attr        zfxml/attr)
+(def attr=       zfxml/attr=)
+(def text        zfxml/text)

 (defn class= [target-name]
   "Returns a query predicate that matches a node when has a class named


fix issue in clj: ldt -> odt

fix issue in clj: ldt -> odt

--- src/tick/core.cljc
+++ src/tick/core.cljc
@@ -192,7 +192,7 @@
   LocalDateTime
   (inst [ldt] (inst (zoned-date-time ldt)))
   (instant [ldt] (instant (zoned-date-time ldt)))
-  (offset-date-time [ldt] #?(:clj (.atOffset ldt (. ZoneOffset systemDefault))
+  (offset-date-time [ldt] #?(:clj (.atOffset ldt (.. ZoneOffset systemDefault getRules (getOffset ldt)))
                              :cljs (zoned-date-time ldt)))
   (zoned-date-time [ldt] (.atZone ldt (. ZoneId systemDefault)))


navigation between todos over stack works

--- src/todos/core.clj
+++ src/todos/core.clj
@@ -27,7 +27,7 @@
 (def todolist
   (t-item/todo-load-from-plain
     (storage/load-data
-      (((t-item/todo-create "< t o d o s >") :plain)) ; if file cant be read this is the default.
+      (((t-item/todo-create "todos") :plain)) ; if file cant be read this is the default.
       )))

 (def current-stack (atom '() )) ; this have the subpath of opened todos. (subpath in todolist)
@@ -35,19 +35,42 @@
 (defn command-repl
   []
   (do
+    (println)
     (doseq [i @current-stack]
-      (println (format "> %s <" ((i :name)) )))
+      (print (format "%s <- " ((i :name)) )))
+    (println ((todolist :name)))
     (let [[cmd & args] (inp/user-cmd-input ">> ")
-          current-todo (or (first @current-stack) todolist)]
+          current-todo (or (first @current-stack) todolist)
+          joined-args  (stri/join " " args)]
       (cond
         (= cmd "ls")
         ((current-todo :print) "")
         ;
         (= cmd "create")
-        ((current-todo :todo-add) (t-item/todo-create (stri/join " " args)))
+        ((current-todo :todo-add) (t-item/todo-create joined-args))
         ;
         (= cmd "note")
-        ((current-todo :note-add) (stri/join " " args))
+        ((current-todo :note-add) joined-args)
+        ;
+        (= cmd "plain")
+        (println ((current-todo :plain)))
+        ;
+        (= cmd "first")
+        (let [ft (first ((current-todo :todos)))]
+          (if ft
+            (swap! current-stack conj ft)
+            (println "Es existieren keine Subtodos.")
+            ))
+        ;
+        (and (= cmd "cd") (= joined-args ".."))
+        (swap! current-stack rest)
+        ;
+        (= cmd "cd")
+        (loop [todos ((current-todo :todos))]
+          (if (= (((first todos) :name)) joined-args)
+            (swap! current-stack conj (first todos))
+            (recur (rest todos))
+            ))
         )
       ; exit clause
       (if (not= cmd "exit")


Remove used style

Remove used style

--- src/trek/style.clj
+++ src/trek/style.clj
@@ -20,12 +20,10 @@
    [[:body (attributes :.bg-gray-700)]
     [:.container (attributes :.mx-auto :.bg-green-400 :.mt-2)]
     [:input (attributes :.border :.border-blue-900 :.border-3 :.bg-gray-400 :.mx-2 :.p-1 :.rounded)]
-    #_ [:button (attributes :.border :.border-blue-300 :.rounded :.bg-gray-200 :.px-2 :.py-1)]
     [:.terminal
      (attributes :.p-2 :.border :.border-4 :.border-white :.mt-12 :.overflow-x-hidden)
      [(pre (garden.selectors/nth-child "2n")) (attributes :.bg-green-500)]]
-    [:.tab-button (attributes :.mr-2 :.mt-1 :.text-lg)]
-    ]))
+    [:.tab-button (attributes :.mr-2 :.mt-1 :.text-lg)]]))

 (comment


Limit subscription data to real IDs

Limit subscription data to real IDs

This ensures that the frontend receives real ids, and can update with them.

--- app/src/edge/graphql.clj
+++ app/src/edge/graphql.clj
@@ -38,7 +38,7 @@
     (->
       (md/future
         (while (not (realized? cancel))
-          (cb {:id (rand-int 100)
+          (cb {:id (rand-nth (range 100 120))
                :person {:firstname (str (rand-int 1000))
                         :surname "bar"
                         :phone (swap! phone inc)}})


Update re-console version

Update re-console version

--- build.boot
+++ build.boot
@@ -22,7 +22,7 @@
                  [re-frame                    "0.5.0"]
                  [replumb/replumb             "0.2.2-SNAPSHOT"]
                  [cljsjs/highlight            "8.4-0"]
-                 [re-console                  "0.1.0-SNAPSHOT"]
+                 [re-console                  "0.1.0"]
                  [re-com                      "0.7.0-alpha2"]
                  [cljs-ajax                   "0.5.1"]
                  [hickory                     "0.5.4"]


Add web native libraries

Add web native libraries

--- build.boot
+++ build.boot
@@ -23,9 +23,12 @@
     :dependencies (into '[[adzerk/boot-cljs "2.1.5" :scope "test"]
                           [javax.xml.bind/jaxb-api "2.3.0" :scope "test"]
                           [orchestra "2018.12.06-2" :scope "test"]
-			  [org.openjfx/javafx-graphics "11.0.2" :classifier "win"]
-			  [org.openjfx/javafx-graphics "11.0.2" :classifier "linux"]
-			  [org.openjfx/javafx-graphics "11.0.2" :classifier "mac"]]
+                          [org.openjfx/javafx-graphics "11.0.2" :classifier "win"]
+                          [org.openjfx/javafx-graphics "11.0.2" :classifier "linux"]
+                          [org.openjfx/javafx-graphics "11.0.2" :classifier "mac"]
+                          [org.openjfx/javafx-web "11.0.2" :classifier "win"]
+                          [org.openjfx/javafx-web "11.0.2" :classifier "linux"]
+                          [org.openjfx/javafx-web "11.0.2" :classifier "mac"]]
                         dependencies)
     :repositories (conj (get-env :repositories)
                     ["clojars" {:url "https://clojars.org/repo/"


fix simulation script

fix simulation script

--- build.boot
+++ build.boot
@@ -2,7 +2,9 @@
           :dependencies '[[http-kit "2.1.19"]
                           [base64-clj "0.1.1"]
                           [cheshire "5.1.1"]
-                          [com.novemberain/monger "3.0.2"]])
+                          [com.novemberain/monger "3.0.2"]
+                          [mount "0.1.10"]
+                          [cprop "0.1.8"]])

 (require '[wombats-api.config.game :as game]
          '[wombats-api.game.frame.processor :refer [process-frame]]


add confetti

add confetti

--- build.boot
+++ build.boot
@@ -6,6 +6,7 @@
                   [pygdown "0.1.5"]
                   [hashobject/boot-s3 "0.1.2-SNAPSHOT"]
                   [clj-time "0.11.0"]
+                  [confetti "0.1.0-SNAPSHOT"]
                   [pandeiro/boot-http "0.7.0"]
                   [org.martinklepsch/boot-gzip "0.1.2"]])

@@ -15,6 +16,7 @@
          '[pandeiro.boot-http :refer [serve]]
          '[hashobject.boot-s3 :refer :all]
          '[org.martinklepsch.boot-gzip :refer [gzip]]
+         '[confetti.boot-confetti :refer [create-site sync-bucket]]
          '[io.perun.core :as perun]
          '[boot.core :as boot]
          '[boot.util       :as u]
@@ -27,6 +29,12 @@
   pom {:project 'code.hashobject.com
        :version "0.2.0"
        :description "Hashobject team open source corner."}
+  sync-bucket {:creds {
+    :access-key (System/getenv "AWS_ACCESS_KEY")
+    :secret-key (System/getenv "AWS_SECRET_KEY")}}
+  create-site {:creds {
+    :access-key (System/getenv "AWS_ACCESS_KEY")
+    :secret-key (System/getenv "AWS_SECRET_KEY")}}
   s3-sync {
     :bucket "code.hashobject.com"
     :source "resources/public/"


Bump version for next release

Bump version for next release

No 0.3.1 was released

--- build.boot
+++ build.boot
@@ -15,7 +15,7 @@
 (require '[adzerk.bootlaces :refer :all])

-(def +version+ "0.3.1")
+(def +version+ "0.3.1-SNAPSHOT")
 (bootlaces! +version+)

 (task-options!


CMR-688: Added opendata-result-handler namespace to routes import.

--- search-app/src/cmr/search/api/routes.clj
+++ search-app/src/cmr/search/api/routes.clj
@@ -31,6 +31,7 @@
             [cmr.search.results-handlers.metadata-results-handler]
             [cmr.search.results-handlers.query-specified-results-handler]
             [cmr.search.results-handlers.timeline-results-handler]
+            [cmr.search.results-handlers.opendata-results-handler]

             ;; ACL support. Required here to avoid circular dependencies
             [cmr.search.services.acls.collection-acls]


Make open nil-safe.

Make open nil-safe.

--- src/blobble/core.clj
+++ src/blobble/core.clj
@@ -58,7 +58,6 @@
     (*hash-fn* content)))

-
 (defn validate!
   "Checks that the identifier of a blob matches the actual digest of the
   content. Throws an exception if the id does not match."
@@ -90,8 +89,9 @@
 (defn open
   "Opens an input stream to read the content of the blob."
   [blob]
-  (.rewind ^ByteBuffer (:content blob))
-  (bytes/to-input-stream (:content blob)))
+  (when-let [content (:content blob)]
+    (.rewind ^ByteBuffer content)
+    (bytes/to-input-stream content)))


Removed default argument from defconstrainedtype

--- src/trammel/core.clj
+++ src/trammel/core.clj
@@ -271,8 +271,7 @@

 (defmacro defconstrainedtype
   [name slots invariants & etc]
-  (let [fields       (->> slots (partition 2) (map first) vec)
-        defaults     (->> slots (partition 2) (map second))
+  (let [fields       (vec slots)
         ctor-name    (symbol (str name \.))
         factory-name (symbol (str "new-" name))]
     `(do
@@ -284,7 +283,6 @@
                             ~(str "Invariant contract for " name)
                             [{:keys ~fields :as m#}] ~invariants)]
          (defconstrainedfn ~factory-name
-           ([] [] (~ctor-name ~@defaults))
            (~fields ~invariants
               (~ctor-name ~@fields))))
        ~name)))


Improve code

Improve code

...but still failing

--- solutions/uri/1025/1025.clj
+++ solutions/uri/1025/1025.clj
@@ -2,35 +2,27 @@
   (:require
    [clojure.string :as str]))

-(defn binary-search [_ _]
-  1)
+(defn binary-search [value items]
+  (loop [begin 0
+         end (-> (count items)
+                 (dec))]
+    (let [middle (-> (+ begin end)
+                     (quot 2))]
+      (if  (> begin end)
+        -1
+        (cond
+          (< (items middle) value)
+          (recur (inc middle)
+                 end)

-;; (defn binary-search [value items]
-;;   (loop [begin 0
-;;          end (-> (count items)
-;;                  (dec))
-;;          middle (-> (+ begin end)
-;;                     (quot 2))]
-;;     (if  (> begin end)
-;;       -1
-;;       (cond
-;;         (< (items middle) value)
-;;         (recur (inc middle)
-;;                end
-;;                (-> (+ begin end)
-;;                    (quot 2)))
+          (or (> (items middle) value)
+              (and (> middle 0)
+                   (== (items (dec middle)) value)))
+          (recur begin
+                 (dec middle))

-;;         (or (> (items middle) value)
-;;             (and (> middle 0)
-;;                  (== (items (dec middle)) value)))
-;;         (recur
-;;          begin
-;;          (dec middle)
-;;          (-> (+ begin end)
-;;              (quot 2)))
-
-;;         :else
-;;         (inc middle)))))
+          :default
+          (inc middle))))))

 (defn read-values [total]
   (loop [reverse-index total
@@ -38,12 +30,12 @@
     (if (== reverse-index 0)
       vals
       (recur (dec reverse-index)
-             (cons (Integer/parseInt (read-line)) vals)))))
+             (concat vals [(Integer/parseInt (read-line))])))))

-(defn process-and-print [index marbles all-queries]
+(defn process-print [index marbles queries]
   (printf "CASE# %d:%n" index)
-  (loop [queries all-queries]
+  (loop [queries queries]
     (let [query (first queries)
           position (binary-search query marbles)]
       (if (>= position 0)
@@ -58,9 +50,9 @@
     (let [[n q] (->> (str/split line #" ")
                      (map #(Integer/parseInt %)))
           marbles (sort (read-values n))
-          all-queries (reverse (read-values q))]
+          queries (read-values q)]
       (when (and (not= n 0) (not= q 0))
-        (process-and-print index marbles all-queries)
+        (process-print index marbles queries)
         (recur (read-line) (inc index))))))

 (main)


remove unused destructuring.

remove unused destructuring.

--- src/leiningen/ancient/artifact/options.clj
+++ src/leiningen/ancient/artifact/options.clj
@@ -68,13 +68,9 @@
   [{:keys [dependencies?
            plugins?
            profiles?
-           snapshots?
-           qualified?
            check-clojure?]
     :or {dependencies? true
-         snapshots? false
          profiles? true
-         qualified? false
          check-clojure? false}}]
   (let [spec {:dependencies dependencies?
               :plugins      plugins?


0.0-2629-4

--- build.boot
+++ build.boot
@@ -6,7 +6,7 @@

 (require '[adzerk.bootlaces :refer :all])

-(def +version+ "0.0-2629-3")
+(def +version+ "0.0-2629-4")

 (bootlaces! +version+)


Update tools.namespace

Update tools.namespace

--- build.boot
+++ build.boot
@@ -34,7 +34,7 @@
    [bidi "2.0.9"]
    [com.stuartsierra/component "0.3.1"]
    [hiccup "1.0.5"]
-   [org.clojure/tools.namespace "0.2.10"]
+   [org.clojure/tools.namespace "0.2.11"]
    [prismatic/schema "1.0.4"]
    [selmer "1.0.4"]
    [yada "1.1.17"]


Update om to 1.0.0-beta2

Update om to 1.0.0-beta2

--- build.boot
+++ build.boot
@@ -14,7 +14,7 @@
                  [buddy/buddy-auth "1.2.0"]
                  [buddy/buddy-hashers "1.0.0"]
                  [org.postgresql/postgresql "9.4.1208"]
-                 [org.omcljs/om "1.0.0-beta1"]
+                 [org.omcljs/om "1.0.0-beta2"]
                  [org.clojure/clojure "1.9.0"]
                  [org.clojure/clojurescript "1.9.946"]
                  [org.clojure/core.async "0.3.443"]


Update deps

Update deps

--- build.boot
+++ build.boot
@@ -5,13 +5,13 @@
   :source-paths #{"test" "test-resources"}
   :dependencies   '[[org.clojure/clojure "1.8.0" :scope "provided"]
                     [boot/core "2.6.0" :scope "provided"]
-                    [adzerk/boot-test "1.0.7" :scope "test"]
+                    [adzerk/boot-test "1.1.2" :scope "test"]
                     ;; Webjars-locator uses logging
-                    [org.slf4j/slf4j-nop "1.7.12" :scope "test"]
+                    [org.slf4j/slf4j-nop "1.7.21" :scope "test"]

                     [com.github.sommeri/less4j "1.17.2"]
                     [com.github.sommeri/less4j-javascript "0.0.1" :exclusions [com.github.sommeri/less4j]]
-                    [org.webjars/webjars-locator "0.29"]
+                    [org.webjars/webjars-locator "0.32"]

                     ;; For testing the webjars asset locator implementation
                     [org.webjars/bootstrap "3.3.6" :scope "test"]])


Simplify lein artifact filter

Simplify lein artifact filter

--- build.boot
+++ build.boot
@@ -77,7 +77,7 @@
      (install)))

    (with-files
-    (fn [x] (re-find #"less4j" (tmp-path x)))
+    (fn [x] (re-find #"leiningen" (tmp-path x)))
     (comp
      (pom
       :project 'deraen/lein-less4j


New randoms/empties in autoconstruction get age 0; lein release :patch

--- src/clojush/pushgp/genetic_operators.clj
+++ src/clojush/pushgp/genetic_operators.clj
@@ -939,9 +939,11 @@
                                         new-genome
                                         [])
                               :history (:history parent1)
-                              :age ((age-combining-function argmap)
-                                    (inc (:age parent1))
-                                    (inc (:age parent2)))
+                              :age (if use-child
+                                     ((age-combining-function argmap)
+                                      (inc (:age parent1))
+                                      (inc (:age parent2)))
+                                     0)
                               :ancestors (if maintain-ancestors
                                            (cons (:genome parent1) (:ancestors parent1))
                                            (:ancestors parent1)))
@@ -960,3 +962,4 @@

+


Track closed ch's, fix acopy, and refresh state on fn-handler.

--- src/ago/core.cljs
+++ src/ago/core.cljs
@@ -12,7 +12,7 @@
             [cljs.core.async.impl.protocols :as protocols]))

 (defn acopy [asrc adst & start-idx]
-  (loop [idx (or start-idx 0)]
+  (loop [idx (or (first start-idx) 0)]
     (when (< idx (alength asrc))
       (aset adst idx (aget asrc idx))
       (recur (inc idx))))
@@ -40,6 +40,7 @@
            :bufs {}           ; Keyed by buf-id, value is FifoBuffer.
            :smas {}           ; Keyed by buf-id, value is state-machine array.
            :smas-new {}       ; Like :smas, but for new, not yet run goroutines.
+           :closed {}         ; Keyed by buf-id, value is bool on chan closure.
            :logical-speed 1.0 ; Logical-speed * physical-delta = logical-delta.
            :logical-ms 0      ; Logical time/msecs, which is always updated
            :physical-ms (now) ; at the same time as physical-ms time snapshot.
@@ -123,16 +124,19 @@
 (deftype WrapManyToManyChannel [ago-world seqv buf-id m2m-ch]
   protocols/WritePort
   (put! [this val ^not-native handler]
+    (set! (.-closed m2m-ch) (protocols/closed? this))
     (protocols/put! m2m-ch val handler))

   protocols/ReadPort
   (take! [this ^not-native handler]
+    (set! (.-closed m2m-ch) (protocols/closed? this))
     (protocols/take! m2m-ch handler))

   protocols/Channel
   (closed? [_]
-    (protocols/closed? m2m-ch))
+    (get-in @ago-world [:closed buf-id] false))
   (close! [this]
+    (swap! ago-world #(assoc-in % [:closed buf-id] true))
     (protocols/close! m2m-ch)))

 ; --------------------------------------------------------
@@ -163,18 +167,25 @@
                        buf-or-n)
                      ch-id))))

+(defn chan-ago-world [ch]
+  (when (instance? WrapManyToManyChannel ch)
+    (.-ago-world ch)))
+
 (defn chan-seqv [ch]
   (when (instance? WrapManyToManyChannel ch)
     (.-seqv ch)))

-(defn chan-ago-world [ch]
+(defn chan-buf-id [ch]
   (when (instance? WrapManyToManyChannel ch)
-    (.-ago-world ch)))
+    (.-buf-id ch)))

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

 (defn ago-reg-state-machine [ago-world state-machine-arr buf-id]
-  (swap! ago-world #(seqv+ (assoc-in % [:smas-new buf-id] state-machine-arr))))
+  (swap! ago-world #(-> %
+                        (assoc-in [:smas-new buf-id] state-machine-arr)
+                        (dissoc-in [:smas buf-id])
+                        (seqv+))))

 (defn ago-run-state-machine [ago-world state-machine-arr buf-id]
   (swap! ago-world #(-> %
@@ -192,13 +203,9 @@
   (let [buf (fifo-buffer ago-world (:seqv @ago-world) buf-id 1)
         ch (ago-chan-buf ago-world buf)
         new-sma (acopy old-sma ((aget old-sma ioc-helpers/FN-IDX))
-                       ioc-helpers/STATE-IDX) ; We depend on *-IDX ordering.
-        new-sma2 (ioc-macros/aset-all! new-sma ioc-helpers/USER-START-IDX ch)]
-    (ago-reg-state-machine ago-world new-sma2 buf-id)
-    (dispatch/run
-     (fn []
-       (ago-run-state-machine ago-world new-sma2 buf-id)
-       (ioc-helpers/run-state-machine-wrapped new-sma2)))
+                       ioc-helpers/STATE-IDX)] ; We depend on *-IDX ordering.
+    (ioc-macros/aset-all! new-sma ioc-helpers/USER-START-IDX ch)
+    (ago-run-state-machine ago-world new-sma buf-id)
     ch))

 (defn ago-judge-state-machines [bufs-ss smas-ss smas-cur]
@@ -248,30 +255,41 @@
     (commit [_] (when (active-cb) f))))

 (defn ssa-take [state blk ^not-native c]
-  (let [active? #(seqv-alive? (chan-ago-world c) (chan-seqv c))]
+  (let [ago-world (chan-ago-world c)
+        active? #(seqv-alive? ago-world (chan-seqv c))]
     (if-let [cb (protocols/take!
                  c (fn-handler
                     active?
                     (fn [x]
                       (when (active?)
-                        (ioc-macros/aset-all! state ioc-helpers/VALUE-IDX
-                                              x ioc-helpers/STATE-IDX blk)
-                        (ioc-helpers/run-state-machine-wrapped state)))))]
+                        (let [buf-id (chan-buf-id c)
+                              s (if ago-world
+                                  (get-in @ago-world [:smas buf-id] state)
+                                  state)]
+                          (ioc-macros/aset-all! s ioc-helpers/VALUE-IDX
+                                                x ioc-helpers/STATE-IDX blk)
+                          (ioc-helpers/run-state-machine-wrapped s))))))]
       (do (ioc-macros/aset-all! state ioc-helpers/VALUE-IDX
                                 @cb ioc-helpers/STATE-IDX blk)
           :recur)
       nil)))

 (defn ssa-put [state blk ^not-native c val]
-  (let [active? #(seqv-alive? (chan-ago-world c) (chan-seqv c))]
+  (let [ago-world (chan-ago-world c)
+        active? #(seqv-alive? ago-world (chan-seqv c))]
     (if-let [cb (protocols/put!
-                 c val (fn-handler
-                        active?
-                        (fn [ret-val]
-                          (when (active?)
-                            (ioc-macros/aset-all! state ioc-helpers/VALUE-IDX
-                                                  ret-val ioc-helpers/STATE-IDX blk)
-                            (ioc-helpers/run-state-machine-wrapped state)))))]
+                 c val
+                 (fn-handler
+                  active?
+                  (fn [ret-val]
+                    (when (active?)
+                      (let [buf-id (chan-buf-id c)
+                            s (if ago-world
+                                  (get-in @ago-world [:smas buf-id] state)
+                                  state)]
+                        (ioc-macros/aset-all! s ioc-helpers/VALUE-IDX
+                                              ret-val ioc-helpers/STATE-IDX blk)
+                        (ioc-helpers/run-state-machine-wrapped s))))))]
       (do (ioc-macros/aset-all! state ioc-helpers/VALUE-IDX
                                 @cb ioc-helpers/STATE-IDX blk)
           :recur)
@@ -298,7 +316,7 @@
       (when-not (nil? value)
         (protocols/put! c value (fn-handler active? (fn [] nil))))
       (protocols/close! c))
-    (ago-dereg-state-machine ago-world (.-buf-id c))
+    (ago-dereg-state-machine ago-world (chan-buf-id c))
     c))

 ; --------------------------------------------------------
@@ -328,6 +346,7 @@
                   (assoc :bufs (:bufs ss))
                   (assoc :smas recycled-smas)
                   (assoc :smas-new recycled-smasN)
+                  (assoc :closed (:closed ss))
                   (assoc :logical-ms (:logical-ms ss))
                   (assoc :physical-ms (now))))
       (doseq [[sma-old ss-buf-id] reborn-smas]


Changed granule spatial indexing so coordinate system types other than geodetic do not throw errors. We just log an error and ignore spatial. We need this so that we can index and test in workload.

--- src/cmr/indexer/services/concepts/granule.clj
+++ src/cmr/indexer/services/concepts/granule.clj
@@ -6,6 +6,7 @@
             [cmr.umm.echo10.granule :as granule]
             [cmr.umm.echo10.related-url :as ru]
             [cmr.transmit.metadata-db :as mdb]
+            [cmr.common.log :refer (debug info warn error)]
             [cmr.common.services.errors :as errors]
             [cmr.indexer.services.concepts.temporal :as temporal]
             [cmr.indexer.services.concepts.attribute :as attrib]
@@ -20,7 +21,8 @@
 (defn- fetch-parent-collection
   "Retrieve the parent collection umm from the db"
   [context parent-collection-id]
-  (let [concept (mdb/get-latest-concept context parent-collection-id)]
+  (let [parent-collection-cache (get-in context [:system :parent-collection-cache])
+        concept (mdb/get-latest-concept context parent-collection-id)]
     (assoc (idx/parse-concept concept) :concept-id parent-collection-id)))

 (defn- get-parent-collection
@@ -36,8 +38,8 @@
     (let [gsr (get-in parent-collection [:spatial-coverage :granule-spatial-representation])]
       (if (= gsr :geodetic)
         (spatial/spatial->elastic-docs gsr granule)
-        (errors/internal-error!
-          (format "Only geodetic is supported for granule spatial representation not [%s]"
+        (error
+          (format "Only geodetic is supported for granule spatial representation currently. GSR: [%s]"
                   gsr))))))

 (defmethod idx/concept->elastic-doc :granule


datamunging part2 (clojure)

datamunging part2 (clojure)

--- src/main/clojure/datamunging/datamunging1.clj
+++ src/main/clojure/datamunging/datamunging1.clj
@@ -1,21 +1,48 @@
 (ns datamunging.datamunging1
   (:use clojure.test))
+
+(defn read-lines-from [file-name] (.split (slurp file-name) "\n"))
+(defn split-lines [lines] (vec (map #(vec (.split (.trim %) "\\s+")) lines)))
+(defn remove-non-digits [s] (.replaceAll s "\\*" ""))
+(defn parse-row [row]
+  (let [key (first row)
+        value1 (remove-non-digits (nth row 1))
+        value2 (remove-non-digits (nth row 2))]
+    (vector key (Integer/parseInt value1) (Integer/parseInt value2))
+))
+
+
+(deftest should-find-team-with-min-goall-diff
+  (def football-file "/Users/dima/IdeaProjects/katas/src/main/scala/ru/katas/n4/football.dat")
+  (defn remove-non-data [lines] (filter #(not (.contains % "----")) (drop 5 (drop-last 1 lines))))
+  (defn take-columns-with-data [lines] (map #(vector (nth % 1) (nth % 6) (nth % 8)) lines))
+
+  (let [
+         columns-with-data (take-columns-with-data (split-lines (remove-non-data (read-lines-from football-file))))
+         parsed-lines (map parse-row columns-with-data)
+         row-with-min-values-diff (apply min-key #(Math/abs (- (nth % 1) (nth % 2))) parsed-lines)
+         team-with-min-goall-diff (first row-with-min-values-diff)
+         ]
+    (is (= "Aston_Villa" team-with-min-goall-diff))
+    (is (= (list "Aston_Villa", 46, 47) row-with-min-values-diff))
+
+    (is (= (list "Arsenal", 79, 36) (nth parsed-lines 0)))
+    (is (= (list "Leicester", 30, 64) (nth parsed-lines 19)))
+    (is (= 20 (count parsed-lines)))
+
+    (is (= (list "Arsenal", "79", "36") (nth columns-with-data 0)))
+    (is (= (list "Leicester", "30", "64") (nth columns-with-data 19)))
+    (is (= 20 (count columns-with-data)))
+
+    (is (= 20 (count (remove-non-data (read-lines-from football-file)))))
+    (is (= 27 (count (read-lines-from football-file))))
+))

 (deftest should-find-day-with-min-temperature-spread
   (def weather-file "/Users/dima/IdeaProjects/katas/src/main/scala/ru/katas/n4/weather.dat")

-  (defn read-lines-from [file-name] (.split (slurp weather-file) "\n"))
   (defn remove-non-data [lines] (drop 8 (drop-last 2 lines)))
-  (defn split-lines [lines] (vec (map #(vec (.split (.trim %) "\\s+")) lines)))
   (defn take-columns-with-data [lines] (map #(vector (nth % 0) (nth % 1) (nth % 2)) lines))
-
-  (defn remove-non-digits [s] (.replaceAll s "\\*" ""))
-  (defn parse-row [row]
-    (let [key (first row)
-          value1 (remove-non-digits (nth row 1))
-          value2 (remove-non-digits (nth row 2))]
-      (vector key (Integer/parseInt value1) (Integer/parseInt value2))
-  ))

   (let [
         columns-with-data (take-columns-with-data (split-lines (remove-non-data (read-lines-from weather-file))))
@@ -24,22 +51,20 @@
         find-day-with-min-temperature-spread (first row-with-min-values-diff)
     ]

+    (is (= "14" find-day-with-min-temperature-spread))
     (is (= (list "14", 61, 59) row-with-min-values-diff))
+
+    (is (= (list "1", 88, 59) (nth parsed-lines 0)))
+    (is (= (list "9", 86, 32) (nth parsed-lines 8)))
+    (is (= (list "30", 90, 45) (nth parsed-lines 29)))
+    (is (= 30 (count parsed-lines)))

     (is (= (list "1", "88", "59") (nth columns-with-data 0)))
     (is (= (list "9", "86", "32*") (nth columns-with-data 8)))
     (is (= (list "30", "90", "45") (nth columns-with-data 29)))
     (is (= 30 (count columns-with-data)))

-    (is (= (list "1", 88, 59) (nth parsed-lines 0)))
-    (is (= (list "9", 86, 32) (nth parsed-lines 8)))
-    (is (= (list "30", 90, 45) (nth parsed-lines 29)))
-    (is (= 30 (count parsed-lines)))
-
     (is (= 30 (count (remove-non-data (read-lines-from weather-file)))))
     (is (= 40 (count (read-lines-from weather-file))))
-
-    (is (= "14" find-day-with-min-temperature-spread))
-    )
-)
+))
 (run-tests)


Use resolve to fetch current user's orgs

--- src-cljs/frontend/send.cljs
+++ src-cljs/frontend/send.cljs
@@ -400,7 +400,20 @@
                                                   (mapv #(hash-map :edge/node %)))}]
               ;; Run the adapted structure through a parser to match it to the
               ;; rest of the query.
-              (parser {:state (atom adapted)} (mapv om-next/ast->query (:children ast))))))))})
+              (parser {:state (atom adapted)} (mapv om-next/ast->query (:children ast))))))))
+
+   :app/current-user
+   (fn [env ast]
+     (-> (api-promise api/get-orgs :include-user? true)
+         (p/then (fn [response]
+                   (let [adapted {:user/organizations
+                                  (mapv #(hash-map :organization/name (:login %)
+                                                   :organization/vcs-type (:vcs_type %)
+                                                   :organization/avatar-url (:avatar_url %))
+                                        response)}]
+                     ;; Run the adapted structure through a parser to match it to the
+                     ;; rest of the query.
+                     (parser {:state (atom adapted)} (mapv om-next/ast->query (:children ast))))))))})

 (defn- resolvers-can-handle?
   "Tool for migrating to resolvers. True if the expression can be handled by the
@@ -408,7 +421,9 @@
   [expr]
   (let [de-aliased-ast (om-parser/expr->ast (first (de-alias-expression expr #())))]
     (or (branch-crumb-ast? de-aliased-ast)
-        (branch-runs-ast? de-aliased-ast))))
+        (branch-runs-ast? de-aliased-ast)
+        (= {:app/current-user [{:user/organizations [:organization/name :organization/vcs-type :organization/avatar-url]}]}
+           expr))))

 (defmulti send* key)

@@ -437,16 +452,6 @@
         (let [[expr cb] (de-alias-expression expr cb)
               ast (om-parser/expr->ast expr)]
           (cond
-            (= {:app/current-user [{:user/organizations [:organization/name :organization/vcs-type :organization/avatar-url]}]}
-               expr)
-            (let [ch (callback-api-chan
-                      #(let [orgs (for [api-org %]
-                                    {:organization/name (:login api-org)
-                                     :organization/vcs-type (:vcs_type api-org)
-                                     :organization/avatar-url (:avatar_url api-org)})]
-                         (cb {:app/current-user {:user/organizations (vec orgs)}} query)))]
-              (api/get-orgs ch :include-user? true))
-
             (and (= :circleci/organization (:key ast))
                  (= '[:organization/vcs-type
                       :organization/name


Whitespace.

Whitespace.

--- src/cbfg/vis.cljs
+++ src/cbfg/vis.cljs
@@ -169,12 +169,14 @@
   (let [actx-id (last actx)
         actx-info (get-in vis [:actxs actx])
         children (:children actx-info)]
-    ["

"
-     "<button class='toggle' id='toggle-" actx-id "'>"
+    ["
"
+     "
"
+     " <button class='toggle' id='toggle-" actx-id "'>"
      (if (:closed actx-info) "▶" "▼")
-     "</button>"
-     "" actx-id " "
-     "
" (vis-html-loop-state vis (:loop-state actx-info)) "

"
+     " </button>"
+     " " actx-id " "
+     "
" (vis-html-loop-state vis (:loop-state actx-info)) "
"
+     "
"
      "

"
      (mapv (fn [ch-info]
              (let [ch-id (:id ch-info)]


Fix bug: upload messages not being sent

Fix bug: upload messages not being sent

--- src/braid/uploads/core.cljc
+++ src/braid/uploads/core.cljc
@@ -22,7 +22,7 @@
           ::create-upload!
           (fn [{db :db} [_ url]]
             (let [thread-id (get-in db [::upload-config :thread-id])
-                  group-id (get-in db [::upload-config :thread-id])]
+                  group-id (get-in db [::upload-config :group-id])]
               {:websocket-send (list [:braid.server/create-upload
                                       {:id (uuid/make-random-squuid)
                                        :url url
@@ -30,7 +30,9 @@
                                        :group-id group-id}])
                :dispatch [:new-message {:content url
                                         :thread-id thread-id
-                                        :group-id group-id}]}))})
+                                        :group-id group-id
+                                        :mentioned-user-ids []
+                                        :mentioned-tag-ids []}]}))})

        (core/register-root-view!
          (fn []


Support POST for expressions.

Support POST for expressions.

--- src/cavm/views/datasets.clj
+++ src/cavm/views/datasets.clj
@@ -7,6 +7,7 @@
   (:require [cavm.query.sources :as sources])
   (:require [ring.util.codec :as codec])
   (:require [ring.util.response :as response ])
+  (:require [ring.util.request :refer [body-string] ])
   (:require [clojure.edn :as edn])
   (:require [clojure.data.json :as json])
   (:require [cavm.h2 :as h2])
@@ -151,6 +152,7 @@
 ; (json/json-str (matrix (double-array [1 Double/NaN 3])))
 ; (json/json-str (matrix [(double-array [1 Double/NaN 3])]))

+;
 ; liberator handler for simple values
 ;

@@ -183,7 +185,11 @@
 ; set of vectors. Not sure how it was supposed to work.

 (defresource expression [exp]
+  :allowed-methods [:post :get]
   :available-media-types ["application/json" "application/edn"]
+  :new? (fn [req] false)
+  :respond-with-entity? (fn [req] true)
+  :multiple-representations? (fn [req] false)
   :handle-ok (fn [{{db :db} :request}]
                (expr/expression exp f/functions (functions db))))

@@ -201,7 +207,8 @@

 ; XXX add the custom pattern #".+" to avoid nil, as above?
 (defroutes routes
-  (ANY "/data/:exp" [exp] (expression exp))
+  (GET "/data/:exp" [exp] (expression exp))
+  (POST "/data/" r (expression (body-string r)))
   (POST "/update/" [file :as {ip :remote-addr
                               loader :loader}] (loader-request ip loader file))
   (not-found "not found"))


fix typo in migrate helper fn

fix typo in migrate helper fn

--- src/chat/server/migrate.clj
+++ src/chat/server/migrate.clj
@@ -38,7 +38,7 @@
   group and add all existing users and tags to that group"
   [group-name]
   (db/with-conn
-    (let [group (db/create-group! {:group/id (db/uuid) :group/name group-name})
+    (let [group (create-group! {:id (db/uuid) :name group-name})
           all-users (->> (d/q '[:find ?u :where [?u :user/id]] (d/db db/*conn*)) (map first))
           all-tags (->> (d/q '[:find ?t :where [?t :tag/id]] (d/db db/*conn*)) (map first))]
       (d/transact db/*conn* (mapv (fn [u] [:db/add [:group/id (group :id)] :group/user u]) all-users))


Adjust stroke color.

Adjust stroke color.

--- src/chronograph/render.cljs
+++ src/chronograph/render.cljs
@@ -9,7 +9,7 @@

 (defn draw [{:keys [margin weight length offset group row block section marks]}]
   (clear)
-  (q/stroke 0)
+  (q/stroke 57 7 13)
   (q/stroke-weight weight)
   (q/stroke-cap :square)
   (doseq [[s b r g i] marks]


Update bootjs. Don't show namespace eval stacktrace.

--- src/clj/cljs/repl/rhino.clj
+++ src/clj/cljs/repl/rhino.clj
@@ -16,16 +16,7 @@

 ;;todo - move to core.cljs, using js
 (def ^String bootjs "
-//goog.provide should do this for us
-//cljs = {}
-//cljs.lang = {}
-//cljs.user = {}
-//goog.provide('cljs.core');
-//goog.provide('cljs.user');
-//cljs.lang.truth_ = function(x){return x != null && x !== false;}
-//cljs.lang.fnOf_ = function(f){return (f instanceof Function?f:f.cljs$core$Fn$invoke);}
-//cljs.lang.original_goog_require = goog.require;
-goog.require = function(rule){Packages.clojure.lang.RT[\"var\"](\"cljs.compiler\",\"goog-require\").invoke(goog.global.cljs_javascript_engine, rule);}
+goog.require = function(rule){Packages.clojure.lang.RT[\"var\"](\"cljs.repl.rhino\",\"goog-require\").invoke(goog.global.cljs_javascript_engine, rule);}
 ")

 (defn rhino-eval
@@ -43,7 +34,7 @@
     (catch Throwable ex
       {:status :exception
        :value (.getMessage ex)
-       :stacktrace (with-out-str (.printStackTrace ex))})))
+       :stacktrace (apply str (interpose "\n" (map #(.toString %) (.getStackTrace ex))))})))

 (def loaded-libs (atom #{}))

@@ -60,26 +51,6 @@
           (.eval jse (io/reader res))
           (throw (Exception. (str "Cannot find " cljs-path " or " js-path " in classpath")))))
       (swap! loaded-libs conj rule))))
-
-(defn rhino-repl-env
-  "Returns a fresh JS environment, suitable for passing to repl.
-  Hang on to return for use across repl calls."
-  []
-  (let [jse (-> (javax.script.ScriptEngineManager.) (.getEngineByName "JavaScript"))
-        base (io/resource "goog/base.js")
-        deps (io/resource "goog/deps.js")
-        new-repl-env {:jse jse :global (.eval jse "this")}]
-    (assert base "Can't find goog/base.js in classpath")
-    (assert deps "Can't find goog/deps.js in classpath")
-    (.put jse javax.script.ScriptEngine/FILENAME "goog/base.js")
-    (.put jse "cljs_javascript_engine" new-repl-env)
-    (with-open [r (io/reader base)]
-      (.eval jse r))
-    (.eval jse bootjs)
-    ;; Load deps.js line-by-line to avoid 64K method limit
-    (doseq [^String line (line-seq (io/reader deps))]
-      (.eval jse line))
-    new-repl-env))

 (defn rhino-setup [repl-env]
   (let [env {:context :statement :locals {}}]
@@ -103,6 +74,26 @@
   (-tear-down [this]
     nil))

+(defn rhino-repl-env
+  "Returns a fresh JS environment, suitable for passing to repl.
+  Hang on to return for use across repl calls."
+  []
+  (let [jse (-> (javax.script.ScriptEngineManager.) (.getEngineByName "JavaScript"))
+        base (io/resource "goog/base.js")
+        deps (io/resource "goog/deps.js")
+        new-repl-env (merge (RhinoEvaluator.) {:jse jse :global (.eval jse "this")})]
+    (assert base "Can't find goog/base.js in classpath")
+    (assert deps "Can't find goog/deps.js in classpath")
+    (.put jse javax.script.ScriptEngine/FILENAME "goog/base.js")
+    (.put jse "cljs_javascript_engine" new-repl-env)
+    (with-open [r (io/reader base)]
+      (.eval jse r))
+    (.eval jse bootjs)
+    ;; Load deps.js line-by-line to avoid 64K method limit
+    (doseq [^String line (line-seq (io/reader deps))]
+      (.eval jse line))
+    new-repl-env))
+
 (defn repl-env []
   (merge (RhinoEvaluator.) (rhino-repl-env)))

@@ -122,7 +113,8 @@
   (load-file "clojure/string.cljs")
   (clojure.string/triml "   hello")
   (clojure.string/reverse "   hello")
-  :cljs/quit
-  (exit)
-
+
+  (ns test.crypt
+    (:require [goog.crypt :as c]))
+  (c/stringToByteArray "Hello")
   )


Make the permissions so that you can cd into it

--- src/clj/mdr2/production.clj
+++ src/clj/mdr2/production.clj
@@ -139,7 +139,7 @@
               ;; access to the structured dir
               (and (= (:production_type production) "periodical")
                    (= (path/structured-path production) dir)))
-      (let [permissions (fs/str->posix "rw-rw-r--")]
+      (let [permissions (fs/str->posix "rwxrwxr--")]
         (fs/set-posix-file-permissions dir permissions)))))

 (defn create!


transfer schemas

transfer schemas

--- src/clj/stripe/transfer.clj
+++ src/clj/stripe/transfer.clj
@@ -51,7 +51,7 @@
        (s/optional-key :type) (s/eq "bank_account")
        (s/optional-key :account) r/BankAccount
        (s/optional-key :bank_account) r/BankAccount
-       :balance_transaction b/BalanceTxID
+       :balance_transaction (s/either b/BalanceTxID b/BalanceTx)
        :description (s/maybe TransferDescription)
        :metadata ss/Metadata
        :recipient (-> (s/maybe r/RecipientID)
@@ -63,7 +63,7 @@

 ;; ## Transfers API

-(s/defn create-transfer :- (ss/Async)
+(s/defn create-transfer :- (ss/Async Transfer)
   "Returns a channel with a Transfer object. To send funds from your
    Stripe account to a third-party bank account, you create a new
    transfer object. Your Stripe balance must be able to cover the
@@ -77,7 +77,7 @@
      (h/post-req "transfers"
                  (update more :stripe-params merge options))))

-(s/defn get-transfer :- (ss/Async)
+(s/defn get-transfer :- (ss/Async Transfer)
   "Returns a channel with a Transfer object, or an error if the
   transfer does not exist.

@@ -93,7 +93,7 @@
   ([id :- TransferID more :- h/RequestOptions]
      (h/get-req (str "transfers/" id) more)))

-(s/defn update-transfer :- (ss/Async)
+(s/defn update-transfer :- (ss/Async Transfer)
   "Updates the specified transfer by setting the values of the
    parameters passed. Any parameters not provided will be left
    unchanged. Returns a channel with the updated transfer object.
@@ -104,7 +104,7 @@
   (h/post-req (str "transfers/" id)
               {:stripe-params options}))

-(s/defn cancel-transfer :- (ss/Async)
+(s/defn cancel-transfer :- (ss/Async Transfer)
   "Returns a channel with either a Transfer object (if the
    cancellation succeeded) or an error.


Fix grammatical error in the comment.

Fix grammatical error in the comment.

--- src/cljam/io/bcf/reader.clj
+++ src/cljam/io/bcf/reader.clj
@@ -294,8 +294,8 @@
      (make-lazy-variants f (rest s)))))

 (defn read-variants-randomly
-  "Reads variants of the bgzip compressed BCF file randomly using csi file.
-   Returning them as a lazy sequence."
+  "Reads variants of the BCF file randomly using csi file.
+   Returns them as a lazy sequence."
   [^BCFReader rdr
    {:keys [chr start end] :or {start 1 end 4294967296}}
    {:keys [depth] :or {depth :deep}}]


distr now takes arbitrary number of arguments

--- src/logic/cnf.clj
+++ src/logic/cnf.clj
@@ -63,10 +63,8 @@
 	       :else formula)
 	     )))

-; TODO make this function possible for arbitrary number of arguments
-
-(defn distr
-  "Takes two nnf formulas and applies the distribution for 'formula-1 or formula-2'"
+(defn- distr-bin
+  "Takes (exactly) two formulas and applies the distribution."
   [formula-1 formula-2]
   (cond
     ;f-1 has the form (and f-11 f-12)
@@ -88,7 +86,12 @@
     :else
     (list 'or formula-1 formula-2)
 ))
-
+
+(defn distr
+  "Takes nnf formulas and applies the distribution to it."
+  ([f] f)
+  ([f & more] (distr-bin f (apply distr more))))
+
 (defn cnf
   "Takes a nnf formula and produces the conjunctive normal form of it."
   [formula]


Fix bug in figwheel et al.

Fix bug in figwheel et al.

--- env/dev/clj/vinculum/dev.clj
+++ env/dev/clj/vinculum/dev.clj
@@ -20,7 +20,8 @@
 (defn browser-repl []
   (let [repl-env (weasel/repl-env :ip "0.0.0.0" :port 9001)]
     (piggieback/cljs-repl :repl-env repl-env)
-    (piggieback/cljs-eval repl-env '(in-ns 'vinculum.core) {})))
+    ;;(piggieback/cljs-eval repl-env '(in-ns 'vinculum.core) {})
+    ))

 (defn start-figwheel []
   (let [server (fig/start-server { :css-dirs ["resources/public/css"] })


Fixed the exclusions to remove the over zealous maven dependencies from being downloaded.

--- clj/project.clj
+++ clj/project.clj
@@ -3,14 +3,29 @@
 ;; loading other task definitions.

 (defproject fmath "0.0.1"
-  :description "Some sample math functions for FX options"
-  :url "http://blog.ericwhite.ca"
-  :license {:name "MIT"}
-  :dependencies [[org.clojure/clojure "1.2.1"]
-                 [org.clojure/clojure-contrib "1.2.0"]
-                 [ring/ring-core "0.3.7"]
-                 [ring/ring-jetty-adapter "0.3.7"]
-                 [compojure "0.6.2"]
-                 [com.github.spullara.mustache.java/compiler "0.4-SNAPSHOT"]]
-  :main fmath.core
-  :dev-dependencies [[org.clojars.brandonw/lein-nailgun "1.0.1"]])
+            :description "Some sample math functions for FX options"
+            :url "http://blog.ericwhite.ca"
+            :license {:name "MIT"}
+            :repositories {
+                           "sonatype"
+                           {:url "https://oss.sonatype.org/content/groups/public/"}
+                           "jetty-releases"
+                           {:url "https://oss.sonatype.org/content/repositories/jetty-releases/"}
+                           }
+            :dependencies [[org.clojure/clojure "1.2.1"]
+                           [org.clojure/clojure-contrib "1.2.0"]
+                           [ring/ring-core "0.3.7"]
+                           [ring/ring-jetty-adapter "0.3.7"]
+                           [javax/servlet/servlet-api "2.5"]
+                           [compojure "0.6.2"]
+
+                           [com.github.spullara.mustache.java/compiler "0.4-SNAPSHOT"
+                            :exclusions [org.eclipse.jetty/jetty-http
+                                         org.eclipse.jetty/jetty-util
+                                         org.eclipse.jetty/jetty-client]]
+                           ]
+            :exclusions [javax.servlet/servlet-api
+                         org.mortbay.jetty/servlet-api]
+            :main fmath.core
+            :dev-dependencies [[org.clojars.brandonw/lein-nailgun "1.0.1"]])
+


Fixed bug in bezier-vertex with arity 6

Fixed bug in bezier-vertex with arity 6

Signed-off-by: dan kefford <cf24ec9f6cbecf330fa0b87dfb9659f55cda7afb@hotmail.com>

--- src/quil/core.clj
+++ src/quil/core.clj
@@ -1,4 +1,4 @@
-(ns
+(ns
     ^{:doc "Wrappers and extensions around the core Processing.org API."
       :author "Roland Sadowski, Sam Aaron"}
     quil.core
@@ -555,7 +555,7 @@
   begin-shape."
   ([cx1 cy1 cx2 cy2 x y]
      (.bezierVertex (current-surface)
-                    (float cx1) (float cx1)
+                    (float cx1) (float cy1)
                     (float cx2) (float cy2)
                     (float x) (float y)))
   ([cx1 cy1 cz1 cx2 cy2 cz2 x y z]


delete-file update

delete-file update

--- src/runtime/q.clj
+++ src/runtime/q.clj
@@ -886,6 +886,14 @@
 "
 an implementation that returns the true/false status
 which clojure.java.io/delete-file doesn't do(tested in 1.5.0-RC14)
+thanks to Sean Corfield, I'm made aware that
+(clojure.java.io/delete-file \"file\" :not-deleted)
+can be used to return :not-deleted when failed, however I still don't agree with this
+optimization-based-implementation, so I still want to get true/false from this, even though
+I could make a new function on top of the original delete-file function, because the original
+does have it's use, ie. it allows me to return whatever value i want(except false/nil) when deletion fails,
+tho doesn't allow me to return whatever I want when it succeeds, let's just say that
+I wouldn't wanna implement it like that ever (not consciously anyway).
 "
   [f & [silently]]
   (let [ret (.delete (clojure.java.io/file f))]


Don't crash if connections.json is not found.

--- src/sqls/stor.clj
+++ src/sqls/stor.clj
@@ -45,7 +45,9 @@
                                  (j "jdbc-conn-str")))
                (catch Throwable e
                  (println (format "exception while parsing connections: %s" e))))))
-         (filter (complement nil?)))))
+         (filter (complement nil?)))
+    (catch Exception e
+      (println (format "exception while loading connections: %s" e)))))

 (defn save-connections!
   "Write connections to connections.json"


@donnitazen telling defproject in which namespace should it start -main

--- sscom/project.clj
+++ sscom/project.clj
@@ -11,4 +11,5 @@
                  [com.ashafa/clutch "0.4.0"]
                  [selmer "0.9.1"]
                  [couchbase-clj "0.2.0"]
-                 [com.stuartsierra/component "0.3.0"]])
+                 [com.stuartsierra/component "0.3.0"]]
+  :main sscom.core)


fixing merge error

fixing merge error

--- src/jobless_clj/example.clj
+++ src/jobless_clj/example.clj
@@ -68,7 +68,6 @@
      (bulletin "Created and gave presentations on coding and development.")
      (bulletin "Helped to maintain a \"Code Club\" to expand interest in learning new programming languages.")
      (start-date "July 2009")
-<<<<<<< Updated upstream
      (end-date "August 2010")))
    (education
     (entry
@@ -88,7 +87,6 @@
     (entry
      (title "StackOverflow")
      (homepage "http://stackoverflow.com/users/113332/jbristow")))))
-=======
      (end-date "August 2010"))
     (entry
      (title "Software Engineer")
@@ -143,4 +141,3 @@
    (entry
     (title "StackOverflow")
     (homepage "http://stackoverflow.com/users/113332/jbristow")))))
->>>>>>> Stashed changes


Jobs module require-able but hardly functional [IMMUTANT-103]

--- modules/jobs/src/main/clojure/immutant/jobs/internal.clj
+++ modules/jobs/src/main/clojure/immutant/jobs/internal.clj
@@ -16,14 +16,12 @@
 ;; 02110-1301 USA, or see the FSF site: http://www.fsf.org.

 (ns immutant.jobs.internal
-  (:use [immutant.utilities :only [app-name]])
+  (:use [immutant.utilities :only [app-name]]
+        [immutant.try :only [try-defn]])
   (:require [immutant.registry :as registry]
-            [clojure.tools.logging :as log])
-  (:import [org.immutant.jobs ClojureJob JobScheduler JobSchedulizer ScheduledJobMBean]
-           [org.immutant.jobs.as JobsServices]
-           [org.projectodd.polyglot.jobs BaseScheduledJob]))
+            [clojure.tools.logging :as log]))

-(defn ^{:private true} #^JobSchedulizer job-schedulizer  []
+(defn ^{:private true} job-schedulizer  []
   (registry/fetch "job-schedulizer"))

 (defn ^{:internal true} create-scheduler
@@ -45,7 +43,7 @@
   "Waits for the scheduler to start before invoking f"
   ([scheduler f]
      (wait-for-scheduler scheduler f 30))
-  ([^JobScheduler scheduler f attempts]
+  ([scheduler f attempts]
      (cond
       (.isStarted scheduler) (f)
       (< attempts 0)         (throw (IllegalStateException.
@@ -55,10 +53,12 @@
                                (Thread/sleep 1000)
                                (recur scheduler f (dec attempts))))))

-(defn ^{:internal true} create-job
+(try-defn (import [org.immutant.jobs ClojureJob ScheduledJobMBean]
+                  org.projectodd.polyglot.jobs.BaseScheduledJob)
+  ^{:internal true} create-job
   "Instantiates and starts a job"
   [f name spec singleton]
-  (let [^JobScheduler scheduler (scheduler singleton)]
+  (let [scheduler (scheduler singleton)]
     (doto
         (proxy [BaseScheduledJob ScheduledJobMBean]
             [ClojureJob (app-name) name "" spec singleton]
@@ -76,14 +76,14 @@

 (defn ^{:internal true} stop-job
   "Stops (unschedules) a job, removing it from the scheduler."
-  [^BaseScheduledJob job]
+  [job]
   (if-not (.isShutdown (.getScheduler job))
     (.stop job)))

 ;; we don't currently register an mbean for each job, since we can't
 ;; yet easily unregister the mbean
 ;; ignore reflection here for now, since we don't even use it yet
-(defn register-job-mbean [name job]
+(try-defn (import org.immutant.jobs.as.JobsServices) register-job-mbean [name job]
   (.installMBean
    (job-schedulizer)
    (.append JobsServices/JOBS


Validate Boot-cljs .cljs.edn options

Validate Boot-cljs .cljs.edn options

--- src/adzerk/boot_cljs.clj
+++ src/adzerk/boot_cljs.clj
@@ -110,6 +110,28 @@
                    :tmp-out (core/tmp-dir!)
                    :main-ns-name (name (gensym "main"))}}))

+(defn assert-cljs-edn!
+  "Validate boot-cljs specific .cljs.edn options.
+
+  Check https://github.com/boot-clj/boot-cljs/blob/master/docs/cljs.edn.md
+  for documentation about options."
+  [{:keys [main] :as ctx}]
+  (assert (and (every? (fn [v]
+                         (and (symbol? v) (not (namespace v))))
+                       (:require main)))
+          (str "Every .cljs.edn :require item should be a symbol referring to a namespace, "
+               "i.e. symbol should only have a name:\n"
+               (:require main)))
+
+  (assert (and (every? (fn [v]
+                         (and (symbol? v) (and (namespace v) (name v))))
+                       (:init-fns main)))
+          (str "Every .cljs.edn :init-fns item should a be symbol referring to a function, "
+               "i.e. symbol should have both a namespace and a name:\n"
+               (:init-fns main)))
+
+  ctx)
+
 (defn- compile-1
   [compilers task-opts macro-changes write-main? {:keys [path] :as cljs-edn} deps-changed?]
   (swap! compilers (fn [compilers]
@@ -121,6 +143,7 @@
         ctx (-> initial-ctx
                 (assoc :main (-> (read-cljs-edn cljs-edn)
                                  (assoc :ns-name (:main-ns-name initial-ctx))))
+                (assert-cljs-edn!)
                 (wrap/compiler-options task-opts)
                 (wrap/main write-main?)
                 (wrap/modules)


Modified internal server error handler

Modified internal server error handler

The buddy library currently throws a 500 error when it cannot
decrypt a JWE token. The internal error middleware will now check for a
checksum failed message and return a 498 status instead of 500.
Should really catch the explicit excepiton rather than match on excepiton
message

--- src/arcis/middleware.clj
+++ src/arcis/middleware.clj
@@ -1,6 +1,6 @@
 ;;      Filename: middleware.clj
 ;; Creation Date: Saturday, 04 July 2015 05:16 PM AEST
-;; Last Modified: Friday, 18 September 2015 03:46 PM AEST
+;; Last Modified: Saturday, 19 September 2015 10:17 AM AEST
 ;;        Author: Tim Cross <theophilusx AT gmail.com>
 ;;   Description:
 ;;
@@ -59,16 +59,20 @@
     (try
       (handler req)
       (catch Throwable t
-        (timbre/error t)
-        (assoc (http-resp/internal-server-error
-                (generate-string {:status-text "Internal server error"
-                                  :message (str "Error: " (.getMessage t))}))
-               :headers {"Content-Type" "application/json"}))
-      (catch Exception e
-        (assoc (http-resp/internal-server-error
-                (generate-string {:status-text "Internal server error"
-                                  :message (str "Error: "
-                                                (.getMessage e))})))))))
+        (let [msg (.getMessage t)]
+          (timbre/error t)
+          (if (= "checksum failed" msg)
+            {:status 498
+             :headers {"Content-Type" "application/json"}
+             :body (generate-string
+                    {:status-text "Token expired/invalid"
+                     :message (str "Supplied authorization token is invalid. "
+                                   "Logout and login again to obtain "
+                                   "a new token.")})}
+            (assoc (http-resp/internal-server-error
+                    (generate-string {:status-text "Internal Server Error"
+                                      :message (str "Error: " msg)}))
+                   :headers {"Content-Type" "application/json"})))))))

 (defn wrap-dev [handler]
   (if (env :dev)