start with chapter 4 of clojure brave and true

--- src/clojure_noon/core.clj
+++ src/clojure_noon/core.clj
@@ -1,4 +1,4 @@
-(ns clojure-noon.core
+(ns clojure-noob.core
   (:gen-class))

 (require '[clojure.string :as str])
@@ -152,8 +152,6 @@

 ;; contains? vs keyword vs get
 (contains? #{:a :b} :a) ;returns true
-(contains? #{:a :b} :3) ;returns false
-(contains? #{nil}) nil ;returns true

 ;using a keyword
 (:a #{:a :b}) ; returns :a
@@ -505,4 +503,20 @@
 (dec3 8)

-
+;;chapter 4
+;;programming to abstractions - key concept in clojure
+
+;;a sequence is a collection of elements organized in linear order
+
+(defn titleize
+  [topic]
+  (str topic "for the Brave and True"))
+
+(map titleize ["Hamsters" "Puppies"]) ;map works with a vector
+(map titleize '("Empathy" "Hatred")) ;map works with a list
+(map titleize #{"Elbows" "Decorating"}) ;map works with unsorted sets
+
+;;first, rest, and cons is all you need to create the maps
+
+
+


Fixes some FIXMEs.

Fixes some FIXMEs.

--- test/active/clojure/match_test.clj
+++ test/active/clojure/match_test.clj
@@ -23,13 +23,12 @@
              (p/parse-clause (:k :as Binding)))))

   (t/testing "path exists without binding clause"
-    ;; FIXME: the test for flat and list are the same
     (t/testing "flat"
       (t/is (= (p/make-path-exists-without-binding-clause [:k "V"] p/the-existence-matcher)
                (p/parse-clause [:k V]))))
     (t/testing "list"
       (t/is (= (p/make-path-exists-without-binding-clause [:k "V"] p/the-existence-matcher)
-               (p/parse-clause [:k V])))))
+               (p/parse-clause ([:k V]))))))

   (t/testing "path exists with binding clause"
     (t/is (= (p/make-path-exists-with-binding-clause [:k "V"] p/the-existence-matcher "Binding")
@@ -132,23 +131,17 @@
     (t/is (= {:x "b"} (p/clause->lhs {} (p/key-matches-without-binding-clause :x (p/match-const "b"))))))

   (t/testing "path matches with binding"
-    ;; FIXME: is there a difference between these two tests? except for syntactic sugar?
     (t/is (= {:x {:y {:z "b"}}}
              (p/clause->lhs {} (p/path-matches-with-binding-clause [:x :y :z] (p/match-const "b") "z"))))
     (t/is (= {:x {:y {:z "b"}}}
-             (p/clause->lhs {} (-> (p/path-matches-with-binding-clause [:x :y :z] (p/match-const "b") "z")))))
-    (t/is (= {:x {:y {:z "b"}}}
-             (p/clause->lhs {} (-> (p/path-matches-with-binding-clause [:x :y :z] (p/match-const "b") "rebind")))))
+             (p/clause->lhs {} (p/path-matches-with-binding-clause [:x :y :z] (p/match-const "b") "rebind"))))
     ;; FIXME: what is wrong with that test?
     #_(t/is (= `({:x {:y {"Z" ~(quote _)}}} :guard [(constantly (~even? (get-in {} [:x :y "Z"])))])
              (p/clause->lhs {} (p/path-matches-with-binding-clause [:x :y "Z"] (p/match-predicate even?))))))

   (t/testing "path matches without binding"
-    ;; FIXME: is there a difference between these two tests? except for syntactic sugar?
     (t/is (= {:x {:y {:z "b"}}}
-             (p/clause->lhs {} (p/path-matches-without-binding-clause [:x :y :z] (p/match-const "b")))))
-    (t/is (= {:x {:y {:z "b"}}}
-             (p/clause->lhs {} (-> (p/path-matches-without-binding-clause [:x :y :z] (p/match-const "b"))))))))
+             (p/clause->lhs {} (p/path-matches-without-binding-clause [:x :y :z] (p/match-const "b")))))))

 (t/deftest path-matches-with-binding-clause->rhs-match-test
   (t/is (= `[~(symbol "z") (get-in {:x {:y {:z "b"}}} [:x :y :z] "b")]
@@ -219,7 +212,10 @@
            (example-matcher one-data)))
   (t/is (= ["a" "c" {"Z" 42 "Y" 23 "X" 65 "W" {"foo" "bar"}} 42 23]
            (example-matcher two-data)))
-  (t/is (= false (example-matcher {:kind "none"}))))
+  (t/is (= false (example-matcher {:kind "none"})))
+  ;; FIXME: What is the difference between this and the test before?
+  (t/testing "map-matcher-regex-key-not-found"
+    (t/is (= false (example-matcher three-data)))))

 ;; FIXME: Clean up
 (t/deftest map-matcher-without-binding-test
@@ -266,11 +262,6 @@
                            [a c C Z])
             two-data))))

- ;; FIXME: map-matcher-or-test - #3 --- same test?
-(t/deftest map-matcher-regex-key-not-found-test
-  (t/is (= false
-           (example-matcher three-data))))
-
 (p/defpattern one-or
   [(:kind #"one")
    (:x (:or "a" "b" "c" "x") :as x)
@@ -289,9 +280,7 @@
            (example-or-matcher one-data)))
   (t/is (= ["a" "c" 42 23]
            (example-or-matcher two-data)))
-  ;; FIXME: this is not an example-or-matcher
-  (t/is (= false (example-matcher {:kind "none"}))))
-
+  (t/is (= false (example-or-matcher {:kind "none"}))))

 (p/defpattern one-guard
   [(:kind #"one")
@@ -347,7 +336,6 @@
   (t/testing "with compare-fn"
     (let [evt {"X" "x"}]
       (t/is (= "x"
-               ;; FIXME: please explain: #(= % )
                ((p/map-matcher [(X (:compare-fn #(= % (get evt "X"))))] x)
                 evt)))))
   (t/testing "as local constant"


Add test for deep-merge   #psh

Add test for deep-merge
  #psh

--- test/cider_ci/utils/tests/core.clj
+++ test/cider_ci/utils/tests/core.clj
@@ -2,6 +2,7 @@
   (:require
     [clojure.test :refer :all]
     [cider-ci.utils.core :refer :all]
+    [clj-yaml.core :as yaml]
     ))

 (deftest test-to-cistr
@@ -58,3 +59,20 @@
              ]]
     (is (= (-> v to-ciset)
            (-> v to-ciset to-cisetmap to-ciset)))))
+
+(deftest test-deep-merge-
+  (is (= (deep-merge
+           (yaml/parse-string
+             "x y z:
+                x: 42")
+           (yaml/parse-string
+             "x y z:
+                y: 49")
+           (yaml/parse-string
+             "x y z:
+                z/z: 3.14")
+           (yaml/parse-string
+             "a b c: 7"))
+         {(keyword "x y z") {:x 42 :y 49 :z/z 3.14}
+          (keyword "a b c") 7 })))
+


fix a wonky test

fix a wonky test

--- test/metabase/api/session_test.clj
+++ test/metabase/api/session_test.clj
@@ -48,14 +48,13 @@
 ;; Test that we can initiate password reset
 (expect true
   (do
-    (let [{:keys [reset_token reset_triggered]} (sel :one :fields [User :reset_token :reset_triggered] :id (user->id :rasta))]
-      ;; make sure user is starting with no values
-      (assert (and (= nil reset_token) (= nil reset_triggered)))
-      ;; issue reset request (token & timestamp should be saved)
-      ((user->client :rasta) :post 200 "session/forgot_password" {:email (:email (user->credentials :rasta))}))
+    ;; make sure user is starting with no values
+    (upd User (user->id :rasta) :reset_token nil :reset_triggered nil)
+    ;; issue reset request (token & timestamp should be saved)
+    ((user->client :rasta) :post 200 "session/forgot_password" {:email (:email (user->credentials :rasta))})
     ;; TODO - how can we test email sent here?
     (let [{:keys [reset_token reset_triggered]} (sel :one :fields [User :reset_token :reset_triggered] :id (user->id :rasta))]
-      (and (not (nil? reset_token)) (not (nil? reset_triggered))))))
+      (and reset_token reset_triggered))))

 ;; Test that email is required
 (expect "'email' is a required param."


Cover them with tests

Cover them with tests

--- test/clojure/clojurewerkz/cassaforte/new_query_api_test.clj
+++ test/clojure/clojurewerkz/cassaforte/new_query_api_test.clj
@@ -348,4 +348,20 @@
          (delete :foo
                  (using {:timestamp 1240003134})
                  (where {:k "value"}))))
+
+  (is (= "DELETE FROM foo WHERE k1='foo' IF EXISTS;"
+         (delete :foo
+                 (where {:k1 "foo"})
+                 (if-exists))))
+
+  (is (= "DELETE FROM foo WHERE k1='foo' IF a=1 AND b=2;"
+         (delete :foo
+                 (where {:k1 "foo"})
+                 (only-if (array-map :a 1
+                                     :b 2)))))
+
+  (is (= "DELETE FROM foo WHERE k1=:key;"
+         (delete :foo
+                 (where {:k1 (? "key")}))))
+
   )


required data-structure for explorations obtained

--- src/crawler/extractor.clj
+++ src/crawler/extractor.clj
@@ -354,6 +354,7 @@
     enum-candidates-info))

 (defn xpath-uniqueness-rank
+  "FIX: Get rid of this routine"
   [{url                  :src-link
     explorations         :explorations
     xpaths-hrefs         :xpaths-hrefs
@@ -395,3 +396,31 @@
             (enum-exploration-hrefs xpath)
             (xpaths-hrefs xpath))))
         xpaths))))))
+
+(defn cluster-explorations
+  "Explorations are grouped into
+clusters based on their similarities."
+  [{url                  :src-link
+    explorations         :explorations
+    xpaths-hrefs         :xpaths-hrefs
+    signature            :signature
+    dfs                  :dfs
+    hrefs                :hrefs
+    novelties            :novelties
+    updates              :updates
+    in-host-xpaths-hrefs :in-host-xpaths-hrefs}]
+
+  (let [explorations-ds
+        (map
+         (fn [{xpath :xpath xpath-expls :explorations}]
+           (flatten
+            (map
+             (fn [x]
+               (let [hrefs-table (-> x :hrefs-table)
+                     xpaths      (map first hrefs-table)]
+                {:r1             (into {} (page/page-signature xpaths hrefs-table))
+                 :incoming-xpath xpath
+                 :url            (-> x :url)}))
+             xpath-expls)))
+         explorations)]
+    explorations-ds))


New tests test-read-components-for-chapter-existence, test-add-new-component-existence, test-delete-component-existence, and test-update-component-existence

--- test/hurvinek/db_interface_test.clj
+++ test/hurvinek/db_interface_test.clj
@@ -141,3 +141,26 @@
         (is (callable? 'hurvinek.db-interface/read-components))))

+(deftest test-read-components-for-chapter-existence
+    "Check that the hurvinek.db-interface/read-components-for-chapter definition exists."
+    (testing "if the hurvinek.db-interface/read-components-for-chapter definition exists."
+        (is (callable? 'hurvinek.db-interface/read-components-for-chapter))))
+
+
+(deftest test-add-new-component-existence
+    "Check that the hurvinek.db-interface/add-new-component definition exists."
+    (testing "if the hurvinek.db-interface/add-new-component definition exists."
+        (is (callable? 'hurvinek.db-interface/add-new-component))))
+
+
+(deftest test-delete-component-existence
+    "Check that the hurvinek.db-interface/delete-component definition exists."
+    (testing "if the hurvinek.db-interface/delete-component definition exists."
+        (is (callable? 'hurvinek.db-interface/delete-component))))
+
+
+(deftest test-update-component-existence
+    "Check that the hurvinek.db-interface/update-component definition exists."
+    (testing "if the hurvinek.db-interface/update-component definition exists."
+        (is (callable? 'hurvinek.db-interface/update-component))))
+


dummy connector should have community edition

--- dummy-connector/config/build.boot
+++ dummy-connector/config/build.boot
@@ -5,7 +5,7 @@

   :version +version+
   :license {"Apache 2.0" "http://www.apache.org/licenses/LICENSE-2.0.txt"}
-  :edition "enterprise"
+  :edition "community"

   :dependencies '[[org.clojure/clojure "1.9.0-beta2"]
                   [sixsq/build-utils "0.1.4" :scope "test"]])


fix typo

fix typo

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

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -261,7 +261,7 @@
       (swap! state assoc-in [:last-stage-positions (@state :default-z-drive)] z))
     (catch Exception e
            (ReportingUtils/logError e)
-           (set-stage-position :default-z-drive z-drive (+ 1.0e-6 z0)))))
+           (set-stage-position z-drive (+ 1.0e-6 z0)))))
     (log "running autofocus " (.. gui getAutofocusManager getDevice getDeviceName)))

 (defn snap-image [open-before close-after]


fix bug when absolute z positions are checked, but z slices are not

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

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -261,10 +261,10 @@
   (if-let [z-drive (:z-drive event)]
     (+ (or (get-in event [:channel :z-offset]) 0)
        (or (:slice event) 0)
-       (if (:relative-z event)
+       (if (and (:slice event) (not :relative-z event))
+	 0
          (or (get-z-position (:position event) z-drive)
-             (@state :reference-z-position))
-         0))))
+             (@state :reference-z-position))))))

 (defn make-event-fns [event out-queue]
   (let [task (:task event)]


Add colour scheme to clojure repl

Add colour scheme to clojure repl

--- lein_profiles.clj
+++ lein_profiles.clj
@@ -1 +1,2 @@
-{:user {:plugins [[venantius/ultra "0.4.0"]]}}
+{:user {:plugins [[venantius/ultra "0.4.0"]]
+       :ultra  {:color-scheme :solarized_dark}}}


drawing ropes implemented

drawing ropes implemented

--- src/engine/devel/rope.clj
+++ src/engine/devel/rope.clj
@@ -40,24 +40,6 @@
   ([coll rebalance?]
      (-> (if rebalance? (rope-rebalance coll) coll) rope->graph view svgdoc->string)))

-(defdispatcher "/devel/test.svg"
-  (fn [request]
-    {:status 200
-     :content-type "image/svg+xml"
-     :body
-     (-> (create-graph)
-         (add-node :athena "Athena" 10 30)
-         (add-node :zeus "Zeus" 200 150)
-         (add-node :hera "Hera" 500 150)
-         (add-node :ares "Ares" 350 250)
-         (add-node :matrimony "♥" 400 170 :shape :circle :style {:fill "salmon"})
-         (add-edge :father1 :athena :zeus)
-         (add-edge :zeus-matrimony :zeus :matrimony)
-         (add-edge :hera-matrimony :hera :matrimony)
-         (add-edge :son-zeus-hera :ares :matrimony)
-         (layout :hierarchical)
-         build view svgdoc->string)}))
-
 (defn svgdispatcher [path svg]
   (defdispatcher path
     (fn [request]
@@ -71,3 +53,27 @@
 (svgdispatcher "/devel/wiki.svg"
                (rope->svg (rope (rope (rope (rope "Hello " "my "))
                                       (rope (rope (rope "na" "me i") (rope "s")) (rope (rope " Simon")))))))
+
+(defn rope-graph [graph root]
+  (loop [graph graph,
+         zipper (rope-zip root), parent nil]
+    (if (zip/end? zipper)
+      graph
+      (let [id (-> zipper zip/node System/identityHashCode str keyword),
+            parent (zip/up zipper), name (if parent (-> zipper zip/node pr-str) "root")]
+        (recur
+         (if parent
+           (let [parent-id (-> parent zip/node System/identityHashCode str keyword),
+                 parent-name (if (zip/up parent) (-> parent zip/node pr-str) "root")]
+             (-> graph
+                 (add-node id name)
+                 (add-edge (str parent-id "->" id) id parent-id)))
+           (-> graph (add-node id name)))
+         (zip/next zipper) zipper)))))
+
+(svgdispatcher "/devel/test.svg"
+               (-> (create-graph)
+                   (add-default-node-attrs :r 45 :shape :circle)
+                   (rope-graph (rope (rope (rope (rope "Hello " "my "))
+                                           (rope (rope (rope "na" "me i") (rope "s")) (rope (rope " Simon"))))))
+                   (layout :hierarchical) build view svgdoc->string))


:tada: Add duration helpers under uxbox.util.time ns.

--- backend/src/uxbox/util/time.clj
+++ backend/src/uxbox/util/time.clj
@@ -11,7 +11,7 @@
    [cognitect.transit :as t])
   (:import java.time.Instant
            java.time.OffsetDateTime
-           java.sql.Timestamp))
+           java.time.Duration))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Serialization Layer conversions
@@ -41,24 +41,6 @@
   {Instant instant-write-handler
    OffsetDateTime offset-datetime-write-handler})

-;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; ;; Persistence Layer Conversions
-;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;; (extend-protocol sp/IParam
-;;   Instant
-;;   (-param [self ctx]
-;;     (si/sql->param "{0}::timestamptz" (.toString self))))
-
-;; (extend-protocol sp/ISQLType
-;;   Timestamp
-;;   (-convert [self]
-;;     (.toInstant self))
-
-;;   java.time.OffsetDateTime
-;;   (-convert [self]
-;;     (.toInstant self)))
-
 (defmethod print-method Instant
   [mv ^java.io.Writer writer]
   (.write writer (str "#instant \"" (.toString mv) "\"")))
@@ -78,3 +60,34 @@
 (defn now
   []
   (Instant/now))
+
+(defn- obj->duration
+  [{:keys [days minutes seconds hours nanos millis]}]
+  (cond-> (Duration/ofMillis (if (int? millis) ^long millis 0))
+    (int? days) (.plusDays ^long days)
+    (int? hours) (.plusHours ^long hours)
+    (int? minutes) (.plusMinutes ^long minutes)
+    (int? seconds) (.plusSeconds ^long seconds)
+    (int? nanos) (.plusNanos ^long nanos)))
+
+(defn duration?
+  [v]
+  (instance? Duration v))
+
+(defn duration
+  [ms-or-obj]
+  (cond
+    (duration? ms-or-obj)
+    ms-or-obj
+
+    (integer? ms-or-obj)
+    (Duration/ofMillis ms-or-obj)
+
+    :else
+    (obj->duration ms-or-obj)))
+
+(extend-protocol clojure.core/Inst
+  java.time.Duration
+  (inst-ms* [v] (.toMillis ^java.time.Duration v)))
+
+


fixed logic

fixed logic

--- src/frontend/uploads.cljs
+++ src/frontend/uploads.cljs
@@ -1,6 +1,9 @@
 (ns moomoo-frontend.uploads
   (:require [clojure.set :as set :refer [difference]]))

+; paused? refers to when user manually pauses an upload
+; stopped? refers to the upload being stopped because
+; of the upload limit
 (def blank-upload {:stopped? true
                    :paused?  false
                    :id       nil
@@ -24,9 +27,11 @@
        (not (:paused? upload))))

 (defn active-uploads [uploads-order uploads]
+  "Returns a list of active upload IDs"
   (remove #(not (active? (uploads %1))) uploads-order))

 (defn inactive-uploads [uploads-order uploads]
+  "Returns al list of inactive upload IDs"
   (remove #(active? (uploads %1)) uploads-order))

 (defn get-action [old-state new-state upload-id]
@@ -36,6 +41,7 @@
         new-uploads (:uploads new-state)
         old-upload (old-uploads upload-id)
         new-upload (new-uploads upload-id)]
+    ; confirm it is an upload, not a file hashing
     (when-not (= :hash (:type old-upload))
       (cond
         (and (not (:stopped? new-upload))
@@ -68,21 +74,26 @@
                                        (set old-uploads-order))
         removed-upload-ids (set/difference (set old-uploads-order)
                                            (set uploads-order))
-        update-vals (fn [f m vals] (reduce #(update % %2 f)
+        update-vals (fn [m keys f] (reduce #(update % %2 f)
                                            m
-                                           vals))]
+                                           keys))]
     (cond
       (< (count active-uploads) upload-slots)
       (assoc new-state
              :uploads
-              (update-vals start
-                           uploads
-                           (take (- upload-slots
-                                    (count active-uploads))
-                                 uploads-order)))
+             (update-vals uploads
+                          (take (- upload-slots
+                                   (count active-uploads))
+                                unpaused-inactive-uploads)
+                          start))

-      ;(> (count active-uploads) upload-slots)
-      ;new-state
+      (> (count active-uploads) upload-slots)
+      (assoc new-state
+             :uploads
+             (update-vals uploads
+                          (drop upload-slots
+                                active-uploads)
+                          stop))

       :else new-state)))


Fix some indentation and typos.

Fix some indentation and typos.

--- src/main/clojure/com/howardlewisship/cascade/view_manager.clj
+++ src/main/clojure/com/howardlewisship/cascade/view_manager.clj
@@ -41,9 +41,9 @@
 (def expansion-re #"\$((\(.*?\)))")

 (defn extract-matched-expression
-	"Extracts the expression string from a matched expansion."
-	[#^MatchResult match-result]
-	(.group match-result 2))
+  "Extracts the expression string from a matched expansion."
+  [#^MatchResult match-result]
+  (.group match-result 2))

 ; TODO: Eventually, when we have (defview) and (deffragment), we may need two levels of cache:
@@ -70,7 +70,7 @@
     (sequential? any) any

     ; A map is assumed to be a DOM node, wrap it in a vector
-    (map? any) [any]
+    (map? any) [any

     (string? any) [(struct-map dom-node :type :text :value any)]

@@ -308,24 +308,14 @@
   [name namespaces]
   (first-non-nil (map (partial find-name-in-namespace name) namespaces)))

-
 (defn create-from-template
   "Searches for a template file (with a .cml extension) as a classpath resource in one of the namespaces,
-creating a function (using the factory) if found. If not found, throws RuntimeException."
+creating a function (using the factory) if found, or nil."
   [name namespaces factory-fn]
-  (let [file (str name ".cml")
-        template-fn (first-non-nil
-      (for [namespace namespaces]
-        (if-let [src (find-namespace-resource namespace file)]
-          (factory-fn namespace src))))]
-
-    (or
-      template-fn
-      (throw (RuntimeException.
-        (format "Could not locate function %s or template '%s' in %s %s."
-          name file
-          (if (= 1 (count namespaces)) "namespace" "namespaces")
-          (to-str-list (map ns-name namespaces))))))))
+  (let [file (str name ".cml")]
+    (first-non-nil (for [namespace namespaces]
+                     (if-let [src (find-namespace-resource namespace file)]
+                       (factory-fn namespace src))))))

 (defn find-or-create-fn
   "Searches for an existing function in any of the namespaces, or creates a function from a bare template."
@@ -336,21 +326,39 @@

 (defn get-or-create-cached-fn
   "Gets a view or fragment function from a cache, or finds it as a real function,
-or uses the factory function to create it dynamically (from a template)."
-  [name cache config-key factory-fn]
+or uses the factory function to create it dynamically (from a template). Returns nil
+if not found in cace and the factory-fn returns nil."
+  [name cache namespaces factory-fn]
   (if-let [existing (get @cache name)]
     existing
-    (let [namespaces (get configuration config-key)
-          created (find-or-create-fn name namespaces factory-fn)]
-      (swap! cache assoc name created)
-      created)))
+    (if-let [created (find-or-create-fn name namespaces factory-fn)]
+      (do (swap! cache assoc name created)
+          created))))
+
+(defn namespaces-list
+  "Converts a list of namespaces into a string describing the list (used for exception reporting)."
+  [namespaces]
+  (str (if (= 1 (count namespaces)) "namespace" "namespaces")
+       " "
+       (to-str-list (map name namespaces))))

 (defn get-fragment
   "Gets a fragment function with a given string name. Fragment functions expect an env and a params and return a seq of rendered DOM nodes."
   [name]
-  (get-or-create-cached-fn name fragment-cache :fragment-namespaces parse-and-create-fragment))
-
+  (let [namespaces (get configuration :fragment-namespaces)]
+    (or
+      (get-or-create-cached-fn name fragment-cache namespaces parse-and-create-fragment)
+      (throw (RuntimeException.
+        (format "Could not locate fragment function %s or template '%<s.cml' in %s."
+          name (namespaces-list namespaces)))))))
+
 (defn get-view
   "Gets a fragment function with a given string name. View functions expect an env and return a seq of rendered DOM nodes."
   [name]
-  (get-or-create-cached-fn name view-cache :view-namespaces parse-and-create-view))+  (let [namespaces (get configuration :view-namespaces)]
+  (or
+    (get-or-create-cached-fn name view-cache namespaces parse-and-create-view)
+      (throw (RuntimeException.
+        (format "Could not locate view function %s or template '%<s.cml' in %s."
+          name (namespaces-list namespaces)))))))
+


CMR-721: Addes additional test cases for orbit spatial search.

--- test/cmr/system_int_test/search/granule_orbit_search_test.clj
+++ test/cmr/system_int_test/search/granule_orbit_search_test.clj
@@ -8,6 +8,7 @@
             [cmr.system-int-test.data2.collection :as dc]
             [cmr.system-int-test.data2.granule :as dg]
             [cmr.system-int-test.data2.core :as d]
+            [cmr.system-int-test.search.granule-spatial-search-test :as st]
             [cmr.spatial.polygon :as poly]
             [cmr.spatial.point :as p]
             [cmr.spatial.line-string :as l]
@@ -90,7 +91,60 @@
            ;; Search for orbits crossing a rectangle in the southern hemisphere crossing the anti-meridian
            [g2 g3 g4 g7] [145 -45 -145 -85] nil
            ;; Search while specifying parent collection
-           [g2] [145 45 -145 -45] {:concept-id (:concept-id coll1)}))))
+           [g2] [145 45 -145 -45] {:concept-id (:concept-id coll1)}))
+
+    (testing "point searches"
+      (are [items lon_lat params]
+           (let [found (search/find-refs :granule {:point (codec/url-encode (apply p/point lon_lat))
+                                                     :page-size 50})
+                   matches? (d/refs-match? items found)]
+             (when-not matches?
+                (println "Expected:" (->> items (map :granule-ur) sort pr-str))
+               (println "Actual:" (->> found :refs (map :name) sort pr-str)))
+             matches?)
+
+           [g3] [-45,45] nil
+           [g1] [0,-20] nil
+           [g2] [-180,0] nil
+           ))
+
+    (testing "line searches"
+      (are [items coords params]
+           (let [found (search/find-refs
+                         :granule
+                         {:line (codec/url-encode (apply l/ords->line-string :geodetic coords))
+                          :page-size 50})
+                 matches? (d/refs-match? items found)]
+             (when-not matches?
+                (println "Expected:" (->> items (map :granule-ur) sort pr-str))
+               (println "Actual:" (->> found :refs (map :name) sort pr-str)))
+             matches?)
+
+           ;; Line crossing prime meridian and equator
+           [g1 g8] [-45,-45 45,45] nil
+           ;; Line crossing the antimeridian
+           [g2] [179,-45 -170, 30] nil
+           ))
+
+    (testing "polygon searches"
+      (are [items coords params]
+           (let [found (search/find-refs
+                         :granule
+                         (merge {:polygon
+                                 (apply st/search-poly coords)
+                                 :page-size 50} params))
+                 matches? (d/refs-match? items found)]
+             (when-not matches?
+                (println "Expected:" (->> items (map :granule-ur) sort pr-str))
+               (println "Actual:" (->> found :refs (map :name) sort pr-str)))
+             matches?)
+
+           ;; Trangle crossing prime meridian
+           [g1 g8] [-45,-45 45,-45 45,0, -45,-45] nil
+           ;; Pentagon over the north pole
+           [g1 g2 g3 g4 g5] [0,80 72,80 144,80 -144,80 -72,80 0,80] nil
+           ;; Concave polygon crossing antimeridian and equator
+           [g2 g4 g7] [170,-70 -170,-80 -175,20 -179,-10 175,25 170,-70] nil))))

 (deftest multi-orbit-search
   (let [;; orbit parameters


Fix drain.

Fix drain.

--- src/onyx/plugin/kafka.clj
+++ src/onyx/plugin/kafka.clj
@@ -84,14 +84,14 @@
           (try
             (loop [ms (kc/messages consumer "onyx" topic kpartition offset fetch-size)
                    head-offset offset]
-              (if (first ms)
+              (if-not (seq ms)
+                (let [fetched (kc/messages consumer "onyx" topic kpartition head-offset fetch-size)]
+                  (Thread/sleep empty-read-back-off)
+                  (recur fetched head-offset))
                 (let [next-offset (.offset ^int (first ms))]
                   (>!! ch {:message (deserializer-fn (.value ^KafkaMessage (first ms)))
                            :offset next-offset})
-                  (recur (rest ms) next-offset))
-                (let [fetched (kc/messages consumer "onyx" topic kpartition head-offset fetch-size)]
-                  (Thread/sleep empty-read-back-off)
-                  (recur fetched head-offset))))
+                  (recur (rest ms) (inc next-offset)))))
             (finally
              (future-cancel commit-fut))))
         (catch InterruptedException e
@@ -117,10 +117,11 @@
     {:kafka/read-ch ch
      :kafka/reader-future reader-fut
      :kafka/pending-messages pending-messages
-     :kafka/pending-commits pending-commits}))
+     :kafka/pending-commits pending-commits
+     :kafka/drained? (atom false)}))

 (defmethod p-ext/read-batch :kafka/read-messages
-  [{:keys [kafka/read-ch kafka/pending-messages onyx.core/task-map] :as event}]
+  [{:keys [kafka/read-ch kafka/pending-messages kafka/drained? onyx.core/task-map] :as event}]
   (let [pending (count (keys @pending-messages))
         max-pending (or (:onyx/max-pending task-map) 10000)
         batch-size (:onyx/batch-size task-map)
@@ -130,13 +131,21 @@
         batch (->> (range max-segments)
                    (map (fn [_]
                           (let [result (first (alts!! [read-ch timeout-ch] :priority true))]
-                            {:id (java.util.UUID/randomUUID)
-                             :input :kafka
-                             :message (:message result)
-                             :offset (:offset result)})))
+                            (if (= (:message result) :done)
+                              {:id (java.util.UUID/randomUUID)
+                               :input :kafka
+                               :message :done}
+                              {:id (java.util.UUID/randomUUID)
+                               :input :kafka
+                               :message (:message result)
+                               :offset (:offset result)}))))
                    (remove (comp nil? :message)))]
     (doseq [m batch]
       (swap! pending-messages assoc (:id m) (select-keys m [:message :offset])))
+    (when (and (= 1 (count @pending-messages))
+               (= (count batch) 1)
+               (= (:message (first batch)) :done))
+      (reset! drained? true))
     {:onyx.core/batch batch}))

 (defmethod p-ext/ack-message :kafka/read-messages
@@ -147,18 +156,17 @@

 (defmethod p-ext/retry-message :kafka/read-messages
   [{:keys [kafka/pending-messages kafka/read-ch onyx.core/log]} message-id]
-  (>!! read-ch (get @pending-messages message-id))
-  (swap! pending-messages dissoc message-id))
+  (when-let [msg (get @pending-messages message-id)]
+    (swap! pending-messages dissoc message-id)
+    (>!! read-ch msg)))

 (defmethod p-ext/pending? :kafka/read-messages
   [{:keys [kafka/pending-messages]} message-id]
   (get @pending-messages message-id))

 (defmethod p-ext/drained? :kafka/read-messages
-  [{:keys [kafka/pending-messages]}]
-  (let [x @pending-messages]
-    (and (= (count (keys x)) 1)
-         (= (first (map :message (vals x))) :done))))
+  [{:keys [kafka/drained?]}]
+  @drained?)

 (defn close-read-messages
   [{:keys [kafka/read-ch] :as pipeline} lifecycle]


use correct namespaces

use correct namespaces

--- src/overtone/sc/synth.clj
+++ src/overtone/sc/synth.clj
@@ -296,8 +296,8 @@
           [tgt-fn args] (if (= :ctl (first args))
                           [controller (rest args)]
                           [player args])
-          args (map #(if (or (isa? (type %) :overtone.sc.core/buffer)
-                             (isa? (type %) :overtone.sc.core/sample))
+          args (map #(if (or (isa? (type %) :overtone.sc.buffer/buffer)
+                             (isa? (type %) :overtone.sc.sample/sample))
                        (:id %) %) args)

           named-args (if (keyword? (first args))


add more testcase

add more testcase

Signed-off-by: Yen-Chin Lee <082d453d72dce940e12089a4ad48b97cfe1f3ec4@gmail.com>

--- spec/leetcode/remove_element_spec.clj
+++ spec/leetcode/remove_element_spec.clj
@@ -12,15 +12,12 @@
   The order of elements can be changed. It doesn't matter what you leave beyond
   the new length."

- (verify {:nums [1 2 3 4 5]
-          :val 5
-          :expect [1 2 3 4]})
+ ;; testcase I wrote
+ (verify {:nums [1 2 3 4 5] :val 5 :expect [1 2 3 4]})
+ (verify {:nums [1 2 3 4]   :val 3 :expect [1 2 4]})
+ (verify {:nums [1 2 3 4]   :val 5 :expect [1 2 3 4]})

- (verify {:nums [1 2 3 4]
-          :val 3
-          :expect [1 2 4]})
-
- (verify {:nums [1 2 3 4]
-          :val 5
-          :expect [1 2 3 4]})
+ ;; https://github.com/samfang/leetcode/blob/master/26.%20Remove%20Element
+ (verify {:nums [2]         :val 3 :expect [2]})
+ (verify {:nums [4 5]       :val 4 :expect [5]})
  )


CMR-2130: Adding dependency on common app lib to message queue.

--- message-queue-lib/project.clj
+++ message-queue-lib/project.clj
@@ -3,6 +3,7 @@
   :url "***REMOVED***projects/CMR/repos/cmr/browse/message-queue-lib"
   :dependencies [[org.clojure/clojure "1.7.0"]
                  [nasa-cmr/cmr-common-lib "0.1.1-SNAPSHOT"]
+                 [nasa-cmr/cmr-common-app-lib "0.1.1-SNAPSHOT"]
                  [nasa-cmr/cmr-transmit-lib "0.1.0-SNAPSHOT"]
                  [nasa-cmr/cmr-acl-lib "0.1.0-SNAPSHOT"]
                  [com.novemberain/langohr "3.4.0"]]


Fix stupid issue where git hashes and email address couldn't be parsed by read-str in submit_topology.clj

--- jvm/src/streamparse/commands/submit_topology.clj
+++ jvm/src/streamparse/commands/submit_topology.clj
@@ -3,7 +3,8 @@
   (:require [clojure.string :as string]
             [streamparse.cli :refer [cli]]
             [clojure.stacktrace :refer [print-stack-trace]]
-            [clojure.core :refer [fn?]])
+            [clojure.core :refer [fn?]]
+            [clojure.data.json :as json])
   (:use [backtype.storm clojure config])
   (:import  [backtype.storm StormSubmitter])
   (:gen-class))
@@ -34,10 +35,19 @@
         ""]
         (string/join \newline)))

+(defn smart-read-str [val]
+  "Read JSON string and don't convert git hashes to numbers"
+  ;; issue with literals that start with digits, but contain letters
+  (if (not= (re-find #"\d+[A-Za-z]" val) nil)
+    val
+    (try
+      (json/read-str val)
+      (catch Exception e val))))
+
 (defn -parse-topo-option [val-str]
   "Parse topology --option in option.key=val form."
   (let [[key val] (string/split val-str #"=")
-       parsed-val (read-string val)]
+       parsed-val (smart-read-str val)]
        {key parsed-val}))

 (defn -assoc-topo-option [previous key val]


in the process of adding string mappings for piece selection

--- src/quick_chess/core.cljs
+++ src/quick_chess/core.cljs
@@ -5,7 +5,7 @@

 (println (str "Reloaded: " (.toLocaleTimeString (js/Date.))))

-(def init-pieces
+(defonce init-pieces
   [[\u265C \u265E \u265D \u265B \u265A \u265D \u265E \u265C]
    [\u265F \u265F \u265F \u265F \u265F \u265F \u265F \u265F]
    ["" "" "" "" "" "" "" ""]
@@ -15,12 +15,23 @@
    [\u2659 \u2659 \u2659 \u2659 \u2659 \u2659 \u2659 \u2659]
    [\u2656 \u2658 \u2657 \u2655 \u2654 \u2657 \u2658 \u2656]])

-(def init-colors
+(defonce init-colors
   (vec
    (take 8 (cycle [(vec (take 8 (cycle '("#a3854b" "#d3d2cf"))))
                    (vec (take 8 (cycle '("#d3d2cf" "#a3854b"))))]))))

-(defonce init-state
+(defn string-mapping
+  "given a list of rows and cols and a string list
+  creates the string mapping"
+  [rows cols strings]
+  (zipmap
+   (map char
+        strings)
+   (for [y rows
+         x cols]
+     [y x])))
+
+(def init-state
   {:width 500
    :height 500
    :board
@@ -30,7 +41,20 @@
        (fn [piece color]
          {:piece piece :color color})
        row-pieces row-colors))
-    init-pieces init-colors)})
+    init-pieces init-colors)
+   :white-string-map (string-mapping
+                      (range 6 8)
+                      (range 8)
+                      (map char (range 97 113)))
+   :black-string-map (string-mapping
+                      (range 2)
+                      (range 8)
+                      (map char (range 97 113)))
+   :turn :white})
+
+(defonce black #{\u265F \u265C \u265E \u265D \u265B \u265A})
+
+(defonce white #{\u2659 \u2656 \u2658 \u2657 \u2655 \u2654})

 (defonce app-state (r/atom init-state))
 #_(swap! app-state assoc :height 500)
@@ -60,7 +84,7 @@
   {:text-align "center"
    :font-size (*
                (min (:height data) (:width data))
-               0.07)})
+               0.06)})

 (defn slider-view
   "adjusts the size of the board"
@@ -73,12 +97,14 @@

 (defn input-view
   "input of commands through strings"
-  [state value]
-  [:input {:type "text"
-           :value @value
-           :on-change (fn [e]
-                        (let [c (-> e .-target .-value)]
-                          (reset! value c)))}])
+  []
+  (let [value (r/atom "")]
+    (fn [state]
+      [:input {:type "text"
+               :value @value
+               :on-change (fn [e]
+                            (let [c (-> e .-target .-value)]
+                              (reset! value c)))}])))

 (defn board-view
   "the board"
@@ -90,20 +116,20 @@
                    (map-indexed
                     (fn [col-idx elem]
                       ^{:key col-idx} [:td {:style (td-style state (:color elem))}
-                                       [:div {:style (piece-style state)} (:piece elem)]])
+                                       [:div {:style (piece-style state)} (:piece elem)]
+                                       [:div {:style {:text-align "center"}} "_"]])
                     row)])
     (:board state))])

 (defn app-view
   "main component of our app"
   []
-  (let [value (r/atom "")]
-       (fn []
-         [:div
-          [:div "Size:"]
-          [slider-view @app-state]
-          [board-view @app-state]
-          [input-view @app-state value]])))
+  (fn []
+    [:div
+     [:div "Size:"]
+     [slider-view @app-state]
+     [board-view @app-state]
+     [input-view @app-state]]))

 ;; -------------------------
 ;; Initialize app


shed old code

shed old code

--- dada-core/src/main/clojure/org/dada/core/jms/POJOInvoker.clj
+++ dada-core/src/main/clojure/org/dada/core/jms/POJOInvoker.clj
@@ -1,48 +0,0 @@
-(ns org.dada.core.jms.POJOInvoker
-    (:import
-     [java.lang.reflect Method]
-     [javax.jms MessageProducer Message Session]
-     [org.dada.core Translator SerializeTranslator]
-     [org.dada.jms AbstractClient MessageStrategy BytesMessageStrategy Invocation MethodMapper Results]
-     )
-    (:gen-class
-     :implements [org.dada.core.jms.Invoker]
-     :init init
-     :constructors {[org.dada.jms.MethodMapper][]}
-     :methods []
-     :state state
-     )
-    )
-
-(defn -init [#^MethodMapper mapper]
-  [ ;; super ctor args
-   []
-   ;; instance state
-   [mapper]
-   ])
-
-;; TODO: these should be injected, so that we can support e.g. ML over TextMessages
-(def ^MessageStrategy message-strategy (BytesMessageStrategy.))
-(def ^Translator translator (SerializeTranslator.))
-
-(defn -invoke [#^org.dada.core.jms.POJOInvoker this target #^Session session #^Message request #^MessageProducer producer]
-  (AbstractClient/setCurrentSession session) ;; allows object being deserialised to find current session
-  ;; TODO: handle URI ClassLoading stuff here...
-  (let [[#^MethodMapper mapper] (.state this)
-	#^Invocation invocation (.foreign-to-native translator (.readMessage message-strategy request))
-	;; TODO - handle Exceptions later
-	#^Method method (.getMethod mapper (Integer. (.getMethodIndex invocation)))
-	args (.getArgs invocation)
-	;;dummy (println "POJO INCOMING:" (str "sessionManager." (.getName method) "(" (apply str (interpose ", " args)) ")"))
-	results (.invoke method target args) ;TODO: introspection - slow
-	reply-to (.getJMSReplyTo request)
-	correlation-id (.getJMSCorrelationID request)]
-    (if (and reply-to correlation-id)
-      (let [#^Message response (.createMessage message-strategy session)]
-	(.setJMSCorrelationID response correlation-id)
-	(.writeMessage message-strategy response (.foreign-to-native translator (Results. false results)))
-	;;(println "POJO OUTGOING:" results)
-	(.send producer reply-to response)
-	))
-    ))
-


for PR note

for PR note

--- src/cljs/org/broadinstitute/firecloud_ui/page/method_config_importer.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/method_config_importer.cljs
@@ -230,16 +230,16 @@
    (fn [{:keys [props state]}]
      [table/Table
       {:columns [{:header "Type" :starting-width 100}
-                 {:header "Namespace" :starting-width 150}
-                 {:header "Name" :starting-width 200 :as-text #(% "name")
-                  :sort-by (fn [m] (str (m "namespace") (m "name"))) :sort-initial :asc
+                 {:header "Name" :starting-width 450 :as-text #(% "name")
+                  :sort-by (fn [m]
+                             [(str (m "namespace") (m "name")) (int (m "snapshotId"))])
+                  :sort-initial :asc
                   :content-renderer
                   (fn [item]
                     (style/create-link
                       (let [func (if (= :method (:type item)) :on-method-selected :on-config-selected)]
                         #((func props) (dissoc item :type)))
-                      (item "name")))}
-                 {:header "Snapshot ID" :starting-width 100}
+                      (str  (item "namespace") "/" (item "name") "/" (item "snapshotId")   )))}
                  {:header "Synopsis" :starting-width 160}
                  (table/date-column {:header "Created"})
                  {:header "Referenced Method" :starting-width 250
@@ -253,9 +253,7 @@
        :data (concat (:methods props) (:configs props))
        :->row (fn [item]
                 [(item "entityType")
-                 (item "namespace")
                  item
-                 (item "snapshotId")
                  (item "synopsis")
                  (item "createDate")
                  (when (= :config (:type item))


remove unused require

remove unused require

--- main/src/dda/pallet/dda_user_crate/infra/ssh.clj
+++ main/src/dda/pallet/dda_user_crate/infra/ssh.clj
@@ -16,7 +16,6 @@
 (ns dda.pallet.dda-user-crate.infra.ssh
   (:require
    [clojure.string :as string]
-   [clojure.java.io :as io]
    [schema.core :as s]
    [pallet.actions :as actions]
    [dda.provision :as p]


Print out and result

Print out and result

--- src-cljs/lein_ui/app.cljs
+++ src-cljs/lein_ui/app.cljs
@@ -80,8 +80,17 @@
                                       (set! (.-value eval-input) ""))}
                            "Eval!"]
                           [:ul
-                           (for [[index item] (vec (-> repl :history :entries))]
-                             [:li {:key index} (:code item)])
+                           (for [[index eval-request] (vec (-> repl :history :entries))]
+                             [:li {:key index}
+                              [:div {:class "eval-code"}
+                               (:code eval-request)]
+                              (when-let [value (:value eval-request)]
+                                [:div {:class "eval-value"}
+                                 value])
+                              (when-let [out (:out eval-request)]
+                                [:div {:class "eval-out"}
+                                 out])
+                              ])
                            ]]))))))

 (defn app-view [project owner]


Use direct-child for pill styles

Use direct-child for pill styles

--- src/braid/client/ui/styles/pills.cljs
+++ src/braid/client/ui/styles/pills.cljs
@@ -17,10 +17,10 @@
     [:.card
      {:display "block"}]]

-   [:.pill
+   [:>.pill
     mixins/pill-box]

-   [:.card
+   [:>.card
     (mixins/box-shadow)
     {:display "none"
      :position "absolute"
@@ -33,22 +33,25 @@
      :border-radius (px 3)
      :overflow "hidden"}

-    [:.header
+    [:>.header
      {:padding offset
       :margin [[(m/* -1 offset) (m/* -1 offset) 0 (m/* -1 offset)]]
       :white-space "nowrap"
-      :color "white"}]
+      :color "white"}

-    [:.info
+     [:>.pill
+      mixins/pill-box]]
+
+    [:>.info
      {:font-size (em 0.9)
       :color vars/grey-text
       :margin [[offset 0]]}

-     [:.description
+     [:>.description
       {:margin [[offset 0]]}]]

-    [:.actions
-     [:a
+    [:>.actions
+     [:>a
       {:margin-bottom (px 2)
        :margin-right (em 1)}
       mixins/pill-button]]]])
@@ -57,51 +60,54 @@
   [:.tag
    (hover-card)

-   [:.card
+   [:>.card

-    [:.count
-     {:margin-left (em 1)
-      :display "inline-block"}
-     (mixins/mini-text)
+    [:>.header

-     [:&::after
+     [:>.count
+      {:margin-left (em 1)
+       :display "inline-block"}
+      (mixins/mini-text)
+
+      [:&::after
        {:margin-left (em 0.25)
         :-webkit-font-smoothing "antialiased"}]

-     [:&.threads
+      [:&.threads

-      [:&::after
-       (mixins/fontawesome \uf181)]]
+       [:&::after
+        (mixins/fontawesome \uf181)]]

-     [:&.subscribers
+      [:&.subscribers

-      [:&::after
-       (mixins/fontawesome \uf0c0)]]]]])
+       [:&::after
+        (mixins/fontawesome \uf0c0)]]]]]])

 (defn user []
   [:.user
    (hover-card)

-   [:.card
+   [:>.card

-    [:.header
+    [:>.header
      ; reserve room for avatar, which is absolutely positioned
      {:padding-right avatar-size}

-     [:.status
+     [:>.status
       {:display "inline-block"
        :margin-left (em 0.5)}
       (mixins/mini-text)]

-     [:.badges
+     [:>.badges
       {:display "inline-block"
        :margin [[0 (em 0.5)]]}
-      [:.admin::before
+
+      [:>.admin::before
        {:display "inline-block"
         :-webkit-font-smoothing "antialiased"}
        (mixins/fontawesome \uf0e3)]]

-     [:img.avatar
+     [:>img.avatar
       {:margin-top (px 2)
        :border-radius (px 3)
        :width avatar-size
@@ -111,7 +117,7 @@
        :top offset
        :right offset}]]

-    [:.local-time
+    [:>.local-time

      [:&::after
       (mixins/fontawesome \uf017)


Fix styling for single thread view

Fix styling for single thread view

--- src/braid/client/ui/views/styles.cljs
+++ src/braid/client/ui/views/styles.cljs
@@ -68,6 +68,22 @@
                  [:>.page
                   (braid.client.ui.styles.misc/threads vars/pad)

+                  [:&.single-thread
+                   [:.content
+                    (braid.client.ui.styles.thread/thread vars/pad)
+                    (braid.client.ui.styles.thread/notice vars/pad)
+                    [:>.thread
+
+                     [:>.card
+
+                      [:>.messages
+                       braid.client.ui.styles.message/message
+
+                       [:>.message
+                        (braid.client.ui.styles.embed/embed vars/pad)]]
+
+                      (braid.client.ui.styles.thread/new-message vars/pad)]]]]
+

                   [:>.threads
                    (braid.client.ui.styles.thread/thread vars/pad)


Use HEAD instead of GET for link extracting

--- src/braid/server/api/link_extract.clj
+++ src/braid/server/api/link_extract.clj
@@ -52,11 +52,11 @@

 (defn extract'
   [url]
-  (let [response @(http/get url)
+  (let [response @(http/head url)
         headers (-> response :headers)
         content (when (some-> headers :content-type
                               (string/starts-with? "text/html"))
-                  (-> response :body h/parse h/as-hickory))
+                  (-> @(http/get url) :body h/parse h/as-hickory))
         u (URL. url)
         [proto host port] ((juxt (memfn getProtocol)
                                  (memfn getHost)


Build deps before deps-macros

Build deps before deps-macros

This avoids the issue where tools.reader is producing
code that can't read "0", thus fixing #8

--- ClojureScript/replete/script/build.clj
+++ ClojureScript/replete/script/build.clj
@@ -32,10 +32,10 @@
                 :source-map true
                 :static-fns true)]
     (env/with-compiler-env (env/default-compiler-env opts)
-      (let [;; Generate core$macros
-            deps-macros (compile1 copts "cljs/core.cljc")
-            ;; Compile main file
-            deps (compile1 copts file)]
+      (let [;; Compile main file
+            deps (compile1 copts file)
+            ;; Generate core$macros
+            deps-macros (compile1 copts "cljs/core.cljc")]
         ;; output unoptimized code and the deps file
         ;; for all compiled namespaces
         (apply closure/output-unoptimized


Add select page history event.

Add select page history event.

--- src/uxbox/data/pages.cljs
+++ src/uxbox/data/pages.cljs
@@ -210,3 +210,26 @@
 (defn clean-page-history
   []
   (CleanPageHistory.))
+
+;; --- Select Page History
+
+(defrecord SelectPageHistory [page history]
+  rs/UpdateEvent
+  (-apply-update [_ state]
+    (let [page (get-in state [:pages-by-id page])
+          page' (assoc page
+                       :history true
+                       :data (:data history)
+                       :version (:version history))]
+      (-> state
+          (stpr/unpack-page page')
+          (assoc-in [:workspace :history :selected] (:id history))
+          (update-in [:workspace :history]
+                     (fn [v]
+                       (if (:current-version v)
+                         v
+                         (assoc v :current-version (:version page)))))))))
+
+(defn select-page-history
+  [id history]
+  (SelectPageHistory. id history))


Add proper TODO on quartz abstraction layer ns.

--- src/uxbox/util/quartz.clj
+++ src/uxbox/util/quartz.clj
@@ -128,6 +128,9 @@
   [scheduler]
   (.shutdown ^Scheduler scheduler true))

+;; TODO: add proper jandling of `:delay` option that should allow
+;; execute a task firstly delayed until some milliseconds or at certain time.
+
 (defn schedule!
   ([schd f] (schedule! schd f nil))
   ([schd f opts]


Remove another rvm/trust missed in the merge

--- src/circle/backend/build/template.clj
+++ src/circle/backend/build/template.clj
@@ -17,8 +17,7 @@

    :deploy {:prefix [start-nodes
                      tag/tag-revision
-                     checkout
-                     rvm/trust]
+                     checkout]
             :suffix [lb/add-instances
                      lb/wait-for-healthy
                      lb/shutdown-remove-old-revisions]}


Send receiver confirmation to the right person

--- src/webapp/server/fns.clj
+++ src/webapp/server/fns.clj
@@ -89,8 +89,8 @@

        :from-email   "contact@connecttous.co"
        :from-name    "ConnectToUs.co"
-       :to-email     (:from_email send-endorsement-neo4j-node)
-       :to-name      (:from_full_name  send-endorsement-neo4j-node)
+       :to-email     (:to_email send-endorsement-neo4j-node)
+       :to-name      (:to_full_name  send-endorsement-neo4j-node)
        )

       (neo4j "match n where id(n)={id}


Finish Cue object.

Finish Cue object.

Clean up semantics of bang and variable setters, flesh out API documentation.

--- src/afterglow/max/Cue.clj
+++ src/afterglow/max/Cue.clj
@@ -20,13 +20,38 @@

   The first outlet sends messages that provide status updates about
   the cue, `started`, `ending`, or `ended`, each followed by the
-  numeric ID of the effect associated with that run of the cue. These
-  messages will be sent regardless of whether the cue was started by
-  this object.
+  numeric ID of the effect associated with that run of the cue, and
+  the cue name. These messages will be sent regardless of whether the
+  cue was started by this object.

   The remaining inlets and outlets allow the variables bound to the
-  cue to be adjusted and monitored. They will be documented once
-  implemented."
+  cue to be adjusted and monitored. There will be as many created as
+  there are cue variables, in the same order as found within the
+  https://github.com/brunchboy/afterglow/blob/master/doc/cues.adoc#creating-cues[:variables
+  list], and their popup help will name the variable each one affects.
+
+  The variable inlets respond to `float` messages by setting the
+  corresponding cue variable, as well as remembering that value to
+  establish as the initial value for the cue variable when the cue is
+  next started. (If the cue is not active when the message is
+  received, it will only establish the initial value for the next time
+  the cue starts; even if the cue variable is bound to an actual show
+  variable, it will not be affected while the cue is inactive.)
+
+  The variable inlets respond to `bang` messages by sending the
+  current stored value (within the Cue object, for use the next time
+  the cue is started, not the associated actual show variable, even if
+  the cue is currently active) to the corresponding outlet.
+
+  The variable outlets report new values of show variables they are
+  associated with whenever they change, regardless of whether the
+  changes were caused by Max or outside of it. Cue variables which are
+  bound to regular show variables can change even when the cue is not
+  active, and these changes will be reported. Cue variables which are
+  local to the cue exist only while the cue is active, so cannot
+  change otherwise. As noted above, these outlets also report the
+  locally stored initial value for the cue variable when the outlet
+  above them receives a `bang`."
   {:doc/format :markdown}
   (:gen-class :extends com.cycling74.max.MaxObject
               :constructors {[int int] []}
@@ -46,6 +71,7 @@
                         [kill [int] void]])
   (:require [afterglow.max.core :as core]
             [afterglow.controllers :as controllers]
+            [afterglow.effects.cues :as cues]
             [afterglow.show :as show]
             [afterglow.show-context :refer [*show*]]
             [taoensso.timbre :as timbre])
@@ -99,8 +125,7 @@
 (defn watch-cue-local-variables
   "After we start a cue, this function looks for any variable bindings
   which are cue-local, and registers callback functions to send
-  updates if their values change. Also immediately sends out the
-  values of the variables that the cue started up with."
+  updates if their values change."
   [this]
   (unwatch-cue-local-variables this)  ; Should be unnecessary, but clean up just in case
   (let [{:keys [x y]} @(.state this)
@@ -115,7 +140,10 @@
           (f cue-local-var (show/get-variable cue-local-var))
           (show/add-variable-set-fn! cue-local-var f)))))))

-(defn- -init
+(defn -init
+  "Called during the first phase of object construction with the two
+  arguments identifying the grid coordinates of the cue to be tracked.
+  Validates that there is a cue there, and allocates object state."
   [x y]
   (core/init)
   (when (nil? *show*)
@@ -125,7 +153,7 @@
       (throw (IllegalStateException. (str "Cannot create Cue object: No cue at " x ", " y " in *show*"))))
     [[] (atom {:x x :y y :cue cue})]))

-(defn- -post-init
+(defn -post-init
   "The post-init phase of the constructors tells Max about the inlets
   and outlets supported by this object, and registers our interest in
   cue state with Afterglow."
@@ -157,32 +185,18 @@
           (swap! (.state this) assoc-in [:perm-var-fn (:key v)] f)
           (show/add-variable-set-fn! (:key v) f))))))

-(defn apply-cue-local-variables
-  "After we start a cue, this function looks for any local values we
-  have saved for variables are creted for the duration of the cue,
-  and if any are found, copies them into the actual cue variables."
+(defn -start
+  "Start the cue if it is not already running (if it is in the process
+  of ending, start a new instance in its place). Send as overrides any
+  initial values for its variables which we have received on our
+  inlets."
   [this]
   (let [{:keys [x y]} @(.state this)
         [_ active] (show/find-cue-grid-active-effect *show* x y)]
-    (when active
-      (doseq [v (cue-variables this)]
-        (when (string? (:key v))
-          (let [cue-local-key (keyword (:key v))
-                cue-local-value (get-in @(.state this) [:variables cue-local-key])]
-            (when cue-local-value
-              (show/set-variable! (get-in active [:variables cue-local-key]) cue-local-value))))))))
-
-(defn- -start
-  "Start the cue if it is not already running (if it is in the process
-  of ending, start a new instance in its place)."
-  [this]
-  (let [{:keys [x y]} @(.state this)
-        [_ active] (show/find-cue-grid-active-effect *show* x y)]
     (when-not (and active (not (:ending active)))
-      (show/add-effect-from-cue-grid! x y)
-      (apply-cue-local-variables this))))
-
-(defn- -end
+      (show/add-effect-from-cue-grid! x y :var-overrides (:variables @(.state this))))))
+
+(defn -end
   "Ask the cue to end; if it has already been asked once, kill it
   immediately. If an id parameter is given, the cue will be affected
   only if it is still running the effect with the specified id."
@@ -191,7 +205,7 @@
   ([this id]
    (show/end-effect! (get-in @(.state this) [:cue :key]) :when-id id)))

-(defn- -kill
+(defn -kill
   "Terminate the cue immediately. If an id parameter is given, the cue
   will be killed only if it is still running the effect with the
   specified id."
@@ -200,28 +214,23 @@
   ([this id]
   (show/end-effect! (get-in @(.state this) [:cue :key]) :force true :when-id id)))

-(defn get-cue-local-variable
-  "Look up the current value for a cue variable which gets created for
-  the lifespan of a running cue. If the cue is currently active,
-  report the value of the corresponding temporary show variable. If
-  not, report the local value we are tracking to be used the next time
-  we start the cue."
+(defn get-cue-variable
+  "Look up the local value we are tracking for a cue variable, to be
+  used when we start the cue."
   [this v]
-  (let [cue-local-key (keyword (:key v))
-        {:keys [x y]} @(.state this)
-        [_ active] (show/find-cue-grid-active-effect *show* x y)]
-    (if active
-      (show/get-variable (get-in active [:variables cue-local-key]))
-      (get-in @(.state this) [:variables cue-local-key]))))
-
-(defn- -bang
+  (let [cue-local-key (keyword (:key v))]
+    (get-in @(.state this) [:variables cue-local-key])))
+
+(defn -bang
   "Respond to a bang message. For the cue control inlet, this acts
   like a press on a grid controller pad: If the cue is not active,
   start it. If it is running, ask it to end; if it is still running
-  after being asked to end, this will kill it. For variable inlets,
-  causes the current value of the variable, if it is defined, to be
-  output to the corresponding outlet. If the variable has no value, or
-  is not a number, the corresponding outlet is simply banged."
+  after being asked to end, this will kill it.
+
+  For variable inlets, sends the most recent value (if any) that has
+  been received by inlet above to establish for the cue when it next
+  starts. If no value has ever been received by the inlet, the
+  corresponding outlet is simply banged."
   [this]
   (let [inlet (.parentGetInlet this)
         {:keys [x y cue]} @(.state this)
@@ -231,26 +240,23 @@
         (-end this)
         (-start this))
       (let [v (nth (cue-variables this) (dec inlet)) ; One of the variable inlets; output its current value.
-            current-val (if (keyword? (:key v))
-                          (show/get-variable (:key v))
-                          (get-cue-local-variable this v))]
+            current-val (get-cue-variable this v active)]
         (if (number? current-val)
           (.outlet this inlet (float current-val))
           (.outletBang this inlet))))))

-(defn update-cue-local-variable
-  "Max wants to set a value for a cue variable which gets created for
-  the lifespan of a running cue. Save a local copy to use when
-  starting up future cues, and if there is currently one active, also
-  update the corresponding temporary show variable."
+(defn update-cue-variable
+  "Max wants to set a value for a cue variable. Save a local copy to
+  use when starting up future cues, and set the corresponding show
+  variable if the cue is currently active."
   [this new-value v]
   (let [cue-local-key (keyword (:key v))
-        {:keys [x y]} @(.state this)
+        {:keys [cue x y]} @(.state this)
         [_ active] (show/find-cue-grid-active-effect *show* x y)]
     (swap! (.state this) assoc-in [:variables cue-local-key] new-value)
-    (when active (show/set-variable! (get-in active [:variables cue-local-key]) new-value))))
-
-(defn- -inlet-float
+    (when active (cues/set-cue-variable! cue v new-value :when-id (:id active)))))
+
+(defn -inlet-float
   "Respond to a float message, meaning the value of one of the
   variable inlets has been set."
   [this new-value]
@@ -260,12 +266,9 @@
       (let [v (nth (cue-variables this) (dec inlet))
             new-value (max new-value (:min v))  ; Restrict range of variable values as per cue specs.
             new-value (min new-value (:max v))]
-        (if (keyword? (:key v))
-          (show/set-variable! (:key v) new-value)
-          (update-cue-local-variable this new-value v))
-        (.outlet this inlet new-value)))))
-
-(defn- -notifyDeleted
+        (update-cue-variable this new-value v)))))
+
+(defn -notifyDeleted
   "The Max peer object has been deleted, so this instance is no longer
   going to be used. Unregister our cue state notification function,
   and any variable change notification functions, and allow this


Cleaned error messages even better

Cleaned error messages even better

--- src/ardoq/swagger/api.clj
+++ src/ardoq/swagger/api.clj
@@ -126,21 +126,21 @@
              (catch IllegalArgumentException e
                (.printStackTrace e)
                (when notifier
-                 (send-failure-email! session client "Swagger file does not conform to Swagger specification"))
+                 (send-failure-email! session client (str "Failed reading request " (.getMessage e))))
                {:status 422
                 :headers {"Content-Type" "application/json"}
                 :body (json/write-str {:error (.getMessage e)})})
              (catch clojure.lang.ExceptionInfo e
                (.printStackTrace e)
                (when notifier
-                 (send-failure-email! session client "An unexpected error occured!"))
+                 (send-failure-email! session client (str "An unexpected error occured!")))
                (if (= 404 (-> e ex-data :status))
                  {:status 404
                   :headers {"Content-Type" "application/json"}
                   :body (json/write-str {:error (str (-> e ex-data :trace-redirects first) " returned 404")})}
                  {:status 500
                   :headers {"Content-Type" "application/json"}
-                  :body (json/write-str {:error (-> e ex-data :causes)})}))
+                  :body (json/write-str {:error (str "Internal error" (-> e ex-data :causes))})}))
              (catch Exception e
                (.printStackTrace e)
                (when notifier


Use more fine grained timeout wheel

Use more fine grained timeout wheel

--- src/beehive_http/core.clj
+++ src/beehive_http/core.clj
@@ -14,15 +14,28 @@

 (ns beehive-http.core
   (:require [beehive.future :as f])
-  (:import (com.ning.http.client AsyncHttpClient RequestBuilder)
+  (:import (com.ning.http.client AsyncHttpClient
+                                 RequestBuilder
+                                 AsyncHttpProvider
+                                 AsyncHttpClientConfig$Builder)
+           (com.ning.http.client.providers.netty NettyAsyncHttpProviderConfig NettyAsyncHttpProvider)
            (com.ning.http.client.providers.netty.response NettyResponse)
            (net.uncontended.precipice ServiceProperties RejectedActionException)
-           (net.uncontended.precipice_implementations.asynchttp HttpAsyncService)))
+           (net.uncontended.precipice_implementations.asynchttp HttpAsyncService)
+           (java.util.concurrent TimeUnit)
+           (org.jboss.netty.util HashedWheelTimer)))

 (set! *warn-on-reflection* true)

 (defn async-http-client []
-  (AsyncHttpClient.))
+  (let [timer (HashedWheelTimer. 20 TimeUnit/MILLISECONDS)
+        netty-config (doto (NettyAsyncHttpProviderConfig.)
+                       (.setNettyTimer timer))
+        client-config (.build
+                        (doto (AsyncHttpClientConfig$Builder.)
+                          (.setAsyncHttpClientProviderConfig netty-config)))
+        provider (NettyAsyncHttpProvider. client-config)]
+    (AsyncHttpClient. ^AsyncHttpProvider provider)))

 (defn request [url]
   (.build (doto (RequestBuilder.)


CLJS-602: Better error message: Too many arguments to def

--- src/clj/cljs/analyzer.clj
+++ src/clj/cljs/analyzer.clj
@@ -339,6 +339,9 @@
         ns-name (-> env :ns :name)]
     (when (namespace sym)
       (throw (error env "Can't def ns-qualified name")))
+    (when-let [doc (:doc args)]
+      (when-not (string? doc)
+        (throw (error env "Too many arguments to def"))))
     (let [env (if (or (and (not= ns-name 'cljs.core)
                            (core-name? env sym))
                       (get-in @namespaces [ns-name :uses sym]))


comment out cache-file bit for now, need to juggle a few different types for this to work.

--- src/clj/cljs/analyzer.clj
+++ src/clj/cljs/analyzer.clj
@@ -1670,8 +1670,9 @@
          (let [path (if (instance? File res)
                       (.getPath ^File res)
                       (.getPath ^java.net.URL res))
-               cache (if output-dir
-                       (cache-file f output-dir))]
+               ;; cache (if output-dir
+               ;;         (cache-file res output-dir))
+               ]
            (when-not (get-in @env/*compiler* [::analyzed-cljs path])
              (binding [*cljs-ns* 'cljs.user
                        *cljs-file* path


CLJS-986: Add :target to the list of build options that should trigger recompilation

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -908,9 +908,8 @@
 (defn url-path [^File f]
   (.getPath (.toURL (.toURI f))))

-(defn- build-affecting-options
-  [opts]
-  (select-keys opts [:static-fns :optimize-constants :elide-asserts]))
+(defn- build-affecting-options [opts]
+  (select-keys opts [:static-fns :optimize-constants :elide-asserts :target]))

 (defn compiled-by-string
   ([] (compiled-by-string nil))


Add plain media type to gtfs resources

Add plain media type to gtfs resources

--- src/clj/gtfve/handler.clj
+++ src/clj/gtfve/handler.clj
@@ -15,7 +15,8 @@
       (* 60000)))

 (defresource gtfs-routes
-  :available-media-types ["text/html"
+  :available-media-types ["text/plain"
+                          "text/html"
                           "application/edn"
                           "application/json"]
   :allowed-methods [:get]
@@ -23,7 +24,8 @@
   :handle-ok (fn [_] (q/routes)))

 (defresource gtfs-route [id]
-  :available-media-types ["text/html"
+  :available-media-types ["text/plain"
+                          "text/html"
                           "application/edn"
                           "application/json"]
   :allowed-methods [:get]


make payment from widget work

make payment from widget work

--- src/clj/yambox/widget.clj
+++ src/clj/yambox/widget.clj
@@ -90,7 +90,8 @@
       [:style (get-css)]]
      [:body
       [:form {:method "POST"
-              :action "https://money.yandex.ru/quickpay/confirm.xml"}
+              :action "https://money.yandex.ru/quickpay/confirm.xml"
+              :target "_blank"}
        [:div.banner
         [:div.row
          [:div.cell.content


extract process-lot-sale function

extract process-lot-sale function

--- src/clj_money/trading.clj
+++ src/clj_money/trading.clj
@@ -150,6 +150,23 @@
        (sort-by :created-at) ; this is FIFO, need to handle FILO
        first))

+(defn- process-lot-sale
+  [context lot shares-to-sell]
+  (let [shares-owned (:shares-owned lot)
+        [shares-sold
+         remaining-shares-to-sell
+         new-lot-balance] (if (>= shares-owned shares-to-sell)
+                            [shares-to-sell
+                             0
+                             (- shares-owned shares-to-sell)]
+                            [shares-owned
+                             (- shares-to-sell shares-owned)
+                             0])
+        adj-lot (lots/update (:storage context)
+                             (assoc lot :shares-owned new-lot-balance))
+        adj-context (update-in context [:lots] #(conj % adj-lot))]
+    [adj-context remaining-shares-to-sell]))
+
 (defn- process-lot-sales
   "Given a sell context, processes the lot changes and appends
   the new lot transactions and the affected lots"
@@ -157,19 +174,10 @@
   (loop [context (assoc context :lots [])
          shares-remaining (:shares context)]
     (if-let [lot (find-lot context)]
-      (let [shares-owned (:shares-owned lot)
-            [shares-sold
-             shares-to-be-sold
-             new-lot-balance] (if (>= shares-owned shares-remaining)
-                                  [shares-remaining
-                                   0
-                                   (- shares-owned shares-remaining)]
-                                  [shares-owned
-                                   (- shares-remaining shares-owned)
-                                   0])
-            adj-lot (assoc lot :shares-owned new-lot-balance)
-            adj-context (update-in context [:lots] #(conj % adj-lot))]
-        (lots/update (:storage context) adj-lot)
+      (let [[adj-context
+             shares-to-be-sold] (process-lot-sale context
+                                                  lot
+                                                  shares-remaining)]
         (if (= 0 shares-to-be-sold)
           adj-context
           (recur adj-context shares-to-be-sold)))


Employee-info om component now created with prismatic om-tools

--- src/cljs/metime/core.cljs
+++ src/cljs/metime/core.cljs
@@ -46,8 +46,11 @@
             ])))

-(defn employee-info [{:keys [lastname firstname email id]}]
-  (om/component
+(defcomponent employee-info [{:keys [lastname firstname email id]}]
+  (display-name [_]
+    "employee-info")
+
+  (render [_]
    (html
     [:li {:class "thumbnail pull-left well" :style {:width "200px" :margin-left "10px"}}
        [:div {:class "row"}


Add more examples

Add more examples

--- src/clojure/cfbt/ch10.clj
+++ src/clojure/cfbt/ch10.clj
@@ -192,4 +192,51 @@
 (future (dosync
          (commute counter (sleep-print-update 105 "Thread B" inc))))

-;; Vars :: 221
+;; Vars ::
+(def ^:dynamic *notification-address* "dobby@elf.org")
+
+(binding
+ [*notification-address* "test@elf.org"]
+  (str "address: " *notification-address*)) ;; "address: test@elf.org"
+
+(binding [*notification-address* "tester-1@elf.org"]
+  (str "address: " *notification-address*)) ;; "address: tester-1@elf.org"
+
+(str "address: " *notification-address*) ;; "address: dobby@elf.org"
+
+(defn notify
+  [message]
+  (str "TO: " *notification-address* "\n"
+       "MESSAGE: " message))
+
+(notify "I fell.")
+;;=> "TO: dobby@elf.org\nMESSAGE: I fell."
+
+;; Use binding
+(binding [*notification-address* "test@elf.org"]
+  (notify "test!"))
+;; => "TO: test@elf.org\nMESSAGE: test!"
+
+(binding [*out* (clojure.java.io/writer "print-output")]
+  (println "A man who carries a cat by the tail learns something he can learn in no other way. -- Mark Twain"))
+
+(slurp "print-output")
+;; => "A man who carries a cat by the tail learns something he can learn in no other way. -- Mark Twain\n"
+
+(def ^:dynamic *troll-thought* nil)
+(defn troll-riddle
+  [your-answer]
+  (let [number "man meat"]
+    (when (thread-bound? #'*troll-thought*)
+      (set! *troll-thought* number))
+    (if (= number your-answer)
+      "TROLL: You can cross the bridge!"
+      "TROLL: Time to eat you, succulent human!")))
+
+(binding [*troll-thought* nil]
+  (println (troll-riddle 2))
+  (println "SUCCULENT HUMAN: Ooooh! The answer was" *troll-thought*))
+;; => TROLL: Time to eat you, succulent human!
+;; => SUCCULENT HUMAN: Ooooh! The answer was man meat
+
+


memoize in clojure

memoize in clojure

--- src/clojure_noon/core.clj
+++ src/clojure_noon/core.clj
@@ -919,9 +919,24 @@
   (fn [& args]
     (f (apply g args))))

-
-
-
-
-
-
+;;memoize - kind of like cacheing to get better performance out of calls to referentially transparent functions like the one below
+(defn sleepy-identity
+  "Returns the given value after 1 second"
+  [x]
+  (Thread/sleep 1000)
+  x)
+
+(sleepy-identity "Mr. Fantastic") ;returns Mr.Fantastic after one second - first call
+(sleepy-identity "Mr. Fantastic") ;returns Mr.Fantastic after one second - second call - even though its the same input and same output
+
+(def memo-sleepy-identity (memoize sleepy-identity))
+(memo-sleepy-identity "Mr. Fantastic") ;returns Mr. Fantastic after one second - first call
+(memo-sleepy-identity "Mr. Fantastic") ; returns Mr. Fantastic immediately - second call
+
+;;memoize is useful for functions that are computationally intensive or that make network requests - any subsequent calls will not bear the cost
+
+
+
+
+
+


Return whole raw byte array in native/read

--- src/clojure_pf/native.clj
+++ src/clojure_pf/native.clj
@@ -35,7 +35,7 @@
                           data
                          (count data))]
     (if-not (= nr -1)
-      (byte-array (take nr data)))))
+      data)))

 (defn write [fd data]
   "Writes data to a socket/device.


Updating to use cmr-transmit-libs new config.

--- src/cmr/search/system.clj
+++ src/cmr/search/system.clj
@@ -5,7 +5,8 @@
             [cmr.common.cache :as cache]
             [cmr.search.api.routes :as routes]
             [cmr.search.data.elastic-search-index :as idx]
-            [cmr.system-trace.context :as context]))
+            [cmr.system-trace.context :as context]
+            [cmr.transmit.config :as transmit-config]))

 ;; Design based on http://stuartsierra.com/2013/09/15/lifecycle-composition and related posts

@@ -17,11 +18,12 @@
 (defn create-system
   "Returns a new instance of the whole application."
   []
-  {:log (log/create-logger)
-   :search-index (idx/create-elastic-search-index "localhost" 9210)
-   :web (web/create-web-server 3003 routes/make-api)
-   :cache (cache/create-cache)
-   :zipkin (context/zipkin-config "Search" false)})
+  (let [sys {:log (log/create-logger)
+             :search-index (idx/create-elastic-search-index "localhost" 9210)
+             :web (web/create-web-server (transmit-config/search-port) routes/make-api)
+             :cache (cache/create-cache)
+             :zipkin (context/zipkin-config "Search" false)}]
+    (transmit-config/system-with-connections sys [:metadata-db :index-set])))

 (defn start
   "Performs side effects to initialize the system, acquire resources,


added stubs for classify and estimating similarity

--- src/crawler/extractor.clj
+++ src/crawler/extractor.clj
@@ -293,7 +293,7 @@
       :in-host-xpaths-hrefs in-host-xpath-hrefs})))

 (defn enum-candidates
-  "Enumeration info"
+  "Returns enumeration info"
   [{url                  :src-link
     explorations         :explorations
     xpaths-hrefs         :xpaths-hrefs
@@ -318,3 +318,11 @@
                                enum-candidates-xs)]

     enum-candidates-info))
+
+(defn estimate-similarity
+  "After 1 round of sampling, fetch some values and make
+an estimation of the situation"
+  [] '*)
+
+(defn classify-nn
+  [] '*)


Handling - in clojure namespaces correctly now

--- jvm-runner/src/clojure/codewars/util.clj
+++ jvm-runner/src/clojure/codewars/util.clj
@@ -25,6 +25,7 @@
   (let [{:keys [:extension]} (get language-data language)]
     (-> class-name
         name
+        (clojure.string/replace "-" "_")
         ;; TODO: not platform independent...
         (clojure.string/replace "." "/")
         (str "." extension)


fix generated migration namespace

fix generated migration namespace

--- src/er_cassandra/drift/migrations.clj
+++ src/er_cassandra/drift/migrations.clj
@@ -138,4 +138,4 @@
 (def ns-content
   (str "\n  (:require [qbits.alia :as alia]"
        "\n            [qbits.hayt :as h]"
-       "\n            [er-cassandra.drift-migration-helpers :refer :all])"))
+       "\n            [er-cassandra.drift.migration-helpers :refer :all])"))


fix messages and disable validation test since validation is currently disabled

--- test/gangway/web_test.clj
+++ test/gangway/web_test.clj
@@ -13,24 +13,24 @@

 (def invalid-message
   (json/json-str
-   [{:header {:operation :assert
-              :entity-id {:task-id 137}
-              :entity-type :task}
-     :payload {:entity {:id-sk-origin "vlacs"
-                        :name "Master the art of addition"
-                        :description "This is some sort of description"}}}]))
+   {:header {:operation :assert
+             :entity-id {:task-id 137}
+             :entity-type :task}
+    :payload {:entity {:id-sk-origin "vlacs"
+                       :name "Master the art of addition"
+                       :description "This is some sort of description"}}}))

 (def valid-message
   (json/json-str
-   [{:header {:operation :assert
-              :entity-id {:task-id 17}
-              :entity-type :task}
-     :payload {:entity {:id-sk-origin "vlacs"
-                        :name "Master the art of addition"
-                        :version "v3"
-                        :description "This is some sort of description"}}}]))
+   {:header {:operation :assert
+             :entity-id {:task-id 17}
+             :entity-type :task}
+    :payload {:entity {:id-sk-origin "vlacs"
+                       :name "Master the art of addition"
+                       :version "v3"
+                       :description "This is some sort of description"}}}))

-(deftest remote-http-test-malformed
+#_(deftest remote-http-test-malformed
   (let [result (http/post
                 (format "%s/gangway/in/showevidence" (immutant.util/app-uri))
                 {:headers {"Authorization" (format "Token %s" token)}


Avoid laziness in collect

Avoid laziness in collect

--- src/datascript/query.cljc
+++ src/datascript/query.cljc
@@ -788,9 +788,7 @@
        symbols))))

 (defn collect [context symbols]
-  (->> (-collect context symbols)
-       (map vec)
-       set))
+  (into #{} (map vec) (-collect context symbols)))

 (defprotocol IContextResolve
   (-context-resolve [var context]))


fix get-post-files test

fix get-post-files test

--- test/misaki/test/core.clj
+++ test/misaki/test/core.clj
@@ -125,15 +125,15 @@
           (is (= 1 (count files)))
           (is (= "2000.01.01-foo.html.clj" (.getName (first files))))))
       (binding [*page-index* 1]
-        (let [files (get-post-files)]
+        (let [files (get-post-files :sort? true)]
           (is (= 1 (count files)))
           (is (= "2011.01.01-foo.html.clj" (.getName (first files))))))
       (binding [*page-index* 2]
-        (let [files (get-post-files)]
+        (let [files (get-post-files :sort? true)]
           (is (= 1 (count files)))
           (is (= "2022.02.02-bar.html.clj" (.getName (first files))))))
       (binding [*page-index* 3]
-        (is (zero? (count (get-post-files)))))))
+        (is (zero? (count (get-post-files :sort? true)))))))

   (testing "with all? option"
     (is (= 3 (count (get-post-files))))


bump deps

bump deps

--- src/leiningen/new/aemette/project.clj
+++ src/leiningen/new/aemette/project.clj
@@ -2,13 +2,13 @@
   :description "FIXME: write this!"
   :url "http://example.com/FIXME"
   :dependencies [[org.clojure/clojure "1.8.0"]
-                 [org.clojure/clojurescript "1.8.34"]
-                 [org.omcljs/om {{#om-legacy}}"0.9.0"{{/om-legacy}}{{^om-legacy}}"1.0.0-alpha31"{{/om-legacy}}]
+                 [org.clojure/clojurescript "1.8.51"]
+                 [org.omcljs/om {{#om-legacy}}"0.9.0"{{/om-legacy}}{{^om-legacy}}"1.0.0-alpha34"{{/om-legacy}}]
                  [org.clojure/core.async "0.2.374"]
                  [secretary "1.2.3"]]

   :plugins [[lein-cljsbuild "1.1.3"]
-            [lein-figwheel "0.5.0-6"]]
+            [lein-figwheel "0.5.2"]]

   :source-paths ["src"]
   :clean-targets ^{:protect false} [[:cljsbuild :builds 0 :compiler :output-dir]


Minor tidy up.

Minor tidy up.

--- SICP/ex_1_19.clj
+++ SICP/ex_1_19.clj
@@ -1,11 +1,12 @@
 ; :mode=clojure:
+
+; Fibonacci sequence in O(log(n)) iterations

 (defn T [p q]
     (fn [a b] [
         (+ (* b q) (* a q) (* a p))
         (+ (* b p) (* a q))]))

-(defn id [a b] [a b])
 (defn comb-fn [A B]
     (fn [a b] (apply A (B a b))))

@@ -25,3 +26,4 @@

 (fib 20)
+


really make it configurable

really make it configurable

--- src/gorilla_repl/core.clj
+++ src/gorilla_repl/core.clj
@@ -97,7 +97,7 @@
     ;; check for updates
     (version/check-for-update version)  ;; runs asynchronously
     ;; first startup nREPL
-    (nrepl/start-and-connect nrepl-requested-port)
+    (nrepl/start-and-connect nrepl-requested-port requested-port-file)
     ;; and then the webserver
     (let [s (server/run-server #'app-routes {:port webapp-requested-port :join? false :ip ip :max-body 500000000})
           webapp-port (:local-port (meta s))]


more on protocols and types

more on protocols and types

--- src/language/protocol.clj
+++ src/language/protocol.clj
@@ -48,7 +48,7 @@

 (defn vov [h v]
-  "create a vector of h v-item vectors"
+  "create a vector of h v-item vectors";factory function
   (vec (repeat h (vec (repeat v nil)))))

 ;(update [[1 2 3] [4 5 9] [6 7 8]] 2 1 100)
@@ -60,7 +60,7 @@
 ;(cols (update vov-a 2 4 3))

-;define types
+;define records

 (defrecord NamedPoint [^String name ^long x ^long y])

@@ -71,6 +71,46 @@
 (->NamedPoint "haha" 3 4)

 (map->NamedPoint {:name "haha" :x 2 :y 4})
+
+;define types
+
+(deftype Point [x y])
+
+(def bb (Point. 3 4))
+
+(.x bb)
+
+(.y bb)
+
+;
+
+(deftype MyType [^:volatile-mutable fld])
+
+;schrödinger's cat
+
+(deftype SchrödingerCat [^:unsynchronized-mutable state]
+  clojure.lang.IDeref
+  (deref [sc]
+         (locking sc
+           (or state
+               (set! state (if (zero? (rand-int 2))
+                             :dead
+                             :alive))))))
+
+(defn schrödinger-cat
+  []
+  (SchrödingerCat. nil))
+
+(def daguguguji (schrödinger-cat))
+
+@daguguguji
+
+
+
+
+
+
+

@@ -88,8 +128,19 @@
   {:pre [(pos? x)]}
   (+ x 2))

-;(try-pre -2)
+#_(try-pre -2)
 (try-pre 2)
+
+;the following shows how a lock works
+
+(def o (Object.))
+
+(future (locking o
+          (Thread/sleep 10000)
+          (println "done!")))
+
+(future (locking o
+          (println "done!")))


CMR-8674 - CMR already supports putting a payload under the 'data' field as defined for tag association, but this function was needed to prove the contents of the metadata column in the database (#1724)

--- metadata-db-app/src/cmr/metadata_db/data/oracle/concepts.clj
+++ metadata-db-app/src/cmr/metadata_db/data/oracle/concepts.clj
@@ -656,3 +656,15 @@
 (extend OracleStore
         concepts/ConceptsStore
         behaviour)
+
+(comment
+
+  (def db (get-in user/system [:apps :metadata-db :db]))
+  ;; Backdoor tool to read the encoded and zipped metadata column since this can
+  ;; not be done in a SQL query tool. All other columns are visible there.
+  (let [c (get-concept db :service-association "PROV1" "SA1200000040-CMR")
+        raw_meta_edn (:metadata c)
+        meta (read-string raw_meta_edn)]
+    meta)
+
+  )


Changed buttons from xl to lg; buttons now grey out while optimization is in progress

--- src/lolitemsets/core.cljs
+++ src/lolitemsets/core.cljs
@@ -16,6 +16,8 @@
                     :recommended []
                     :champ-level 18
                     :num-items 6
+                    :generating false
+                    :trolling false
                     :itemset {:title "Untitled"
                               :type "custom"
                               :map "any"
@@ -188,6 +190,7 @@

    {:name "Movement speed"
     :calc algo/move-speed
+    :optimizable true
     :troll true}])

 (defn build-stats []
@@ -247,20 +250,39 @@
   (recommend))

 (defn dorans-button []
-  [:a.btn.btn-danger.btn-xl {:on-click troll}
-   [:span.glyphicon.glyphicon-fire] " Troll"])
+  [:a.btn.btn-danger.btn-lg
+   {:on-click (fn [] (go (swap! app assoc :trolling true)
+                         (<! (troll))
+                         (swap! app assoc :trolling false)))
+    :class (if (:trolling @app)
+             "disabled"
+             nil)}
+   [:span.glyphicon.glyphicon-fire]
+   (if (:trolling @app)
+     " YOLO..."
+     " Troll")])

 (defn needlessly-large-button []
-  [:a.btn.btn-default.btn-xl {:href (set-url) :download "build.json"}
+  [:a.btn.btn-default.btn-lg {:href (set-url)
+                              :download (str (:title (:itemset @app)) ".json")}
    [:span.glyphicon.glyphicon-save] " Download"])

 (defn mirage-button []
-  [:a.btn.btn-default.btn-xl {:on-click add-block}
+  [:a.btn.btn-default.btn-lg {:on-click add-block}
    [:span.glyphicon.glyphicon-plus-sign] " Add to set"])

 (defn button-of-command []
-  [:a.btn.btn-primary.btn-xl {:on-click recommend}
-   [:span.glyphicon.glyphicon-equalizer] " Generate"])
+  [:a.btn.btn-primary.btn-lg
+   {:on-click (fn [] (go (swap! app assoc :generating true)
+                         (<! (recommend))
+                         (swap! app assoc :generating false)))
+    :class (if (:generating @app)
+             "disabled"
+             nil)}
+   [:span.glyphicon.glyphicon-equalizer]
+   (if (:generating @app)
+     " Generating..."
+     " Generate")])

 (defn app-component []
   [:div.container
@@ -286,7 +308,7 @@
         [dorans-button] ; troll
         [mirage-button] ; add
         [needlessly-large-button]] ; download
-      [:p
+      [:p [:br]
        "Save inside your League of Legends folder in "
        [:code
         "Config/Champions/"


A bit of refactoring.

A bit of refactoring.

--- modules/core/src/main/clojure/immutant/runtime/bootstrap.clj
+++ modules/core/src/main/clojure/immutant/runtime/bootstrap.clj
@@ -80,18 +80,13 @@
 lein1/lein2 differences for project keys that changed from strings to vectors."
   [project]
   (remove nil?
-          (reduce (fn [acc key]
-                    (let [path (project key)]
-                      (concat acc (if (coll? path)
-                                    path
-                                    (vector path)))))
-                  []
-                  [:resources-path ;; lein1
-                   :resource-paths ;; lein2
-                   :source-path    ;; lein1
-                   :source-paths   ;; lein2
-                   :native-path    ;; lein2
-                   ])))
+          (flatten
+           (map project [:resources-path ;; lein1
+                         :resource-paths ;; lein2
+                         :source-path    ;; lein1
+                         :source-paths   ;; lein2
+                         :native-path    ;; lein2
+                         ]))))

 (defn ^{:private true} resource-paths-for-projectless-app
   "Resolves the resource paths (in the AS7 usage of the term) for a non-leiningen application."


Add quadratic-vertex function.

Add quadratic-vertex function.

--- src/quil/core.clj
+++ src/quil/core.clj
@@ -1004,8 +1004,8 @@
   to use create-graphics with the :opengl renderer, because it doesn't
   allow offscreen use. The :pdf renderer requires the filename parameter.

-  It's important to call any drawing commands between begin-draw and
-  end-draw statements. This is also true for any commands that affect
+  It's important to call any drawing commands between (.beginDraw graphics) and
+  (.endDraw graphics) statements. This is also true for any commands that affect
   drawing, such as smooth or color-mode.

   Unlike the main drawing surface which is completely opaque, surfaces
@@ -1471,7 +1471,6 @@
   renderers."
   []
   (.endContour (current-surface)))
-

 (defn
   ^{:requires-bindings true
@@ -2843,6 +2842,25 @@
          (float x2) (float y2)
          (float x3) (float y3)
          (float x4) (float y4)))
+
+(defn
+  ^{:requires-bindings true
+    :processing-name "quadraticVertex()"
+    :category "Shape"
+    :subcategory "Vertex"
+    :added "1.0"}
+  quadratic-vertex
+  "Specifies vertex coordinates for quadratic Bezier curves. Each call to
+  quadratic-vertex defines the position of one control points and one anchor
+  point of a Bezier curve, adding a new segment to a line or shape. The first
+  time quadratic-vertex is used within a begin-shape call, it must be prefaced
+  with a call to vertex to set the first anchor point. This function must be
+  used between begin-shape and end-shape and only when there is no MODE parameter
+  specified to begin-shape. Using the 3D version requires rendering with :p3d."
+  ([cx cy x3 y3]
+    (.quadraticVertex (current-surface) (float cx) (float cy) (float x3) (float y3)))
+  ([cx cy cz x3 y3 z3]
+   (.quadraticVertex (current-surface) (float cx) (float cy) (float cz) (float x3) (float y3) (float z3))))

 (defn
   ^{:requires-bindings false


use ajax if ws isn't defined

use ajax if ws isn't defined

--- src-cljs/frontend/talaria.cljs
+++ src-cljs/frontend/talaria.cljs
@@ -286,8 +286,10 @@
                          :send-queue send-queue
                          :recv-queue recv-queue
                          :callbacks {}})]
-    (setup-ws url-parts tal-state :on-open on-open :on-error on-error :on-reconnect on-reconnect)
-    ;;(setup-ajax url-parts tal-state :on-open on-open :on-error on-error :on-reconnect on-reconnect)
+    (if js/Websocket
+      (setup-ws url-parts tal-state :on-open on-open :on-error on-error :on-reconnect on-reconnect)
+      (setup-ajax url-parts tal-state :on-open on-open :on-error on-error :on-reconnect on-reconnect))
+
     tal-state))

 (defn shutdown [tal-state]


Korjaa organizer-menu

Korjaa organizer-menu

--- mtg-pairings-server/src/cljs/mtg_pairings_server/events.cljs
+++ mtg-pairings-server/src/cljs/mtg_pairings_server/events.cljs
@@ -260,7 +260,9 @@
   (case action
     :start-clock {:db (assoc-in db [:organizer :clock :running] true)}
     :stop-clock {:db (assoc-in db [:organizer :clock :running] false)}
-    {}))
+    :select-pairings (resolve-organizer-action db id action value)
+    :select-standings (resolve-organizer-action db id action value)
+    :select-pods (resolve-organizer-action db id action value)))

 (reg-event-fx ::organizer-mode
   (fn [{:keys [db]} [_ action value]]


Enter key and component local state

Enter key and component local state

--- src-cljs/lein_ui/app.cljs
+++ src-cljs/lein_ui/app.cljs
@@ -12,6 +12,8 @@

 (defonce app-state (atom {:project nil
                           :user {:status :loading}}))
+
+(def ENTER-KEY 13)

 (defn edn-body [response]
   (-> response :body str edn/read-string))
@@ -87,37 +89,43 @@
   (swap! app-state assoc :user {:status :logged-out})
   (go (api-call :delete "http://localhost:8000/api/user")))

+(defn when-enter-key [f & args]
+  (fn [e]
+    (when (= ENTER-KEY
+             (.-keyCode e))
+      (apply f e args))))
+
 (defn user-widget [user owner]
   (reify
     om/IRenderState
-    (render-state [_ state]
+    (render-state [_ {:keys [username-input]}]
       (html
        [:div
         (cond
          (logged-in? user) [:div [:h3 "Welcome, " [:span (:username user)]]
-                            [:button {:onClick (fn [_] (logout!))} "Logout"]
-                            ]
+                            [:button {:onClick (fn [_] (logout!))} "Logout"]]
          (loading? user) [:span "Loading user.."]
          :else           [:span "Username"
                           [:input
                            {:type "text"
+                            :value username-input
+                            :onKeyPress (when-enter-key
+                                         (fn [e]
+                                           (login! (.-target e) username-input)
+                                           (om/set-state! owner :username-input "")))
                             :onChange (fn [e]
                                         (om/set-state! owner
                                                        :username-input
                                                        (.-value (.-target e))))}]
                           [:button
                            {:onClick (fn [e]
-                                       (login! (.-target e) (state :username-input)))}
+                                       (when-not (empty? username-input)
+                                         (login! (.-target e) username-input)
+                                         (om/set-state! owner :username-input "")))}
                            "Login"]])]))))

 (defn repl-widget [repl owner]
   (reify
-    om/IDidMount
-    (did-mount [this]
-      (om/set-state! owner :eval-input
-                     (-> (om/get-node owner)
-                         (.querySelector ".repl-code"))))
-
     om/IRenderState
     (render-state [_ {:keys [project-controller eval-input]}]
       (let [{:keys [state url]} repl]
@@ -126,13 +134,22 @@
                           "repl not started.. this is unexpected"])
           :started (html [:div
                           [:input {:type "text"
+                                   :value eval-input
+                                   :onKeyPress (when-enter-key (fn [_]
+                                                                 (put! project-controller
+                                                                       {:msg :eval
+                                                                        :args [eval-input]})
+                                                                 (om/set-state! :eval-input "")))
+                                   :onChange (fn [e]
+                                               (om/set-state! owner
+                                                              :eval-input (.-value (.-target e))))
                                    :class "repl-code"}]
                           [:button {:onClick
                                     (fn [_]
                                       (put! project-controller
                                             {:msg :eval
-                                             :args [(.-value eval-input)]})
-                                      (set! (.-value eval-input) ""))}
+                                             :args [eval-input]})
+                                      (om/set-state! :eval-input ""))}
                            "Eval!"]
                           [:ul {:class "eval-results"}
                            (for [id (rseq (-> (om/value repl) :history :order))]


Delete trailing whitespace.

Delete trailing whitespace.

--- src-cljs/pepa/search.cljs
+++ src-cljs/pepa/search.cljs
@@ -60,7 +60,7 @@
                   (cond
                     (list? query)
                     query
-
+
                     (string? query)
                     (parse-query-string query)))
           ch (if (= query ::all)


CIRCLE-2228 show the commit SHA on the builds table

--- src-cljs/frontend/components/builds_table.cljs
+++ src-cljs/frontend/components/builds_table.cljs
@@ -164,17 +164,17 @@
                                                                     :properties {:repo (:reponame build)
                                                                                :org (:username build)}})}
                 "#"
-                (gh-utils/pull-request-number url)])))]
+                (gh-utils/pull-request-number url)])))])

-        [:div.metadata-item.revision
-         [:i.octicon.octicon-git-commit]
-         (when (:vcs_revision build)
-           [:a {:title (build-model/github-revision build)
-                :href (build-model/commit-url build)
-                :on-click #((om/get-shared owner :track-event) {:event-type :revision-link-clicked
-                                                                :properties {:repo (:reponame build)
-                                                                             :org (:username build)}})}
-            (build-model/github-revision build)])])]]]))
+       (when (:vcs_revision build)
+         [:div.metadata-item.revision
+          [:i.octicon.octicon-git-commit]
+          [:a {:title (build-model/github-revision build)
+               :href (build-model/commit-url build)
+               :on-click #((om/get-shared owner :track-event) {:event-type :revision-link-clicked
+                                                               :properties {:repo (:reponame build)
+                                                                            :org (:username build)}})}
+           (build-model/github-revision build)]])]]]))

 (defn builds-table [data owner {:keys [show-actions? show-branch? show-project?]
                                 :or {show-branch? true


submit social group test

submit social group test

--- test/cljs/ohds/socialgroup_test.cljs
+++ test/cljs/ohds/socialgroup_test.cljs
@@ -1,5 +1,5 @@
 (ns ohds.socialgroup-test
-  (:require
+  (:require
    [ohds.socialgroup.view :as view]
    [ohds.socialgroup.messages :as m]
    [ohds.socialgroup.processing :as p]
@@ -20,4 +20,21 @@
   (testing "changing group type updates app state"
     (let [msg (m/->ChangeGroupType "COHORT")]
       (is (= {:socialgroup {:type "COHORT"}}
-             (process-message msg {}))))))
+             (process-message msg {})))))
+  (testing "submitting socialgroup calls backend correctly"
+    (let [msg (m/->SubmitSocialGroup)
+          app {:fieldworker-id "fw-id"
+               :socialgroup {:name "gname"
+                             :extId "extId"
+                             :type "COHORT"}}]
+      (with-redefs [http/post (fn [url body]
+                                (is (= {:form-params {:fieldworker-id "fw-id"
+                                                      :ext-id "extId"
+                                                      :group-name "gname"
+                                                      :group-type "COHORT"}}
+                                     body))
+                                {:status 200
+                                 :body "a-uuid"})
+                    wrap (fn [m c] (m c))]
+        (is (= #{(m/map->CreateSocialGroupResults {:status 200 :body "a-uuid"})}
+               (watch-channels msg app)))))))