Added small warning for filters when the accessor returns nil

--- src/selmer/filter_parser.clj
+++ src/selmer/filter_parser.clj
@@ -108,5 +108,7 @@
                       (reverse))]
     (fn [context-map]
       (let [x (get-in context-map accessor)]
+        (when-not x
+          (println "Warning:" val "returns nil"))
         ;; Escape by default unless the last filter is 'safe'
         (escape-html ((apply comp filters) x))))))


remove info

remove info

--- clj-tcp/src/clj_tcp/client.clj
+++ clj-tcp/src/clj_tcp/client.clj
@@ -254,7 +254,7 @@
     ;async read off internal-error-ch
     (go
       (loop [local-client client]
-        (info "wait -internal error: " internal-error-ch)
+        ;(info "wait -internal error: " internal-error-ch)
         (let [[v o] (<! internal-error-ch)
               reconnect-count (.get ^AtomicInteger (:reconnect-count local-client))
               ]


Don't print port

Don't print port

--- src/servisne_info/webapp.clj
+++ src/servisne_info/webapp.clj
@@ -15,7 +15,6 @@

 (defn -main [& [port]]
   (let [port (Integer. (or port (env :port) 5000))]
-    (println "PORT: " port)
     (reset! server (run-server handler/app {:port port}))
     (.addShutdownHook (Runtime/getRuntime) (Thread. stop-server))
     (handler/init)))


Corret required package name for reactify-component

--- src/re_natal_esp32control_app/android/core.cljs
+++ src/re_natal_esp32control_app/android/core.cljs
@@ -144,4 +144,4 @@

 (defn init []
   (dispatch-sync [:initialize-db])
-  (.registerComponent app-registry "reNatalEsp32ControlApp" #(r/reactify-component app-root)))
+  (.registerComponent app-registry "reNatalEsp32ControlApp" #(reagent/reactify-component app-root)))


add test for specific owner

add test for specific owner

--- storm-core/test/clj/org/apache/storm/nimbus_test.clj
+++ storm-core/test/clj/org/apache/storm/nimbus_test.clj
@@ -965,13 +965,13 @@
                                        TOPOLOGY-EVENTLOGGER-EXECUTORS 0
                                        })))]
     (letlocals
-      ;test for 0-topology case
+      ;;test for 0-topology case
       (.advanceClusterTime cluster 11)
       (bind owner-resource-summaries (.getOwnerResourceSummaries (.getNimbus cluster) nil))
       (bind summary (first owner-resource-summaries))
       (is (nil? summary))

-      ;test for 1-topology case
+      ;;test for 1-topology case
       (bind topology (Thrift/buildTopology
                        {"1" (Thrift/prepareSpoutDetails
                               (TestPlannerSpout. true) (Integer. 3))}
@@ -988,7 +988,7 @@
       (is (= (.get_total_executors summary)) 3)
       (is (= (.get_total_topologies summary)) 1)

-      ;test for many-topology case
+      ;;test for many-topology case
       (bind topology2 (Thrift/buildTopology
                         {"2" (Thrift/prepareSpoutDetails
                                (TestPlannerSpout. true) (Integer. 4))}
@@ -1014,6 +1014,21 @@
       (is (= (.get_total_workers summary) 10))
       (is (= (.get_total_executors summary)) 12)
       (is (= (.get_total_topologies summary)) 3)
+
+      ;;test for specific owner
+      (bind owner-resource-summaries (.getOwnerResourceSummaries (.getNimbus cluster) (System/getProperty "user.name")))
+      (bind summary (first owner-resource-summaries))
+      (is (= (.get_total_workers summary) 10))
+      (is (= (.get_total_executors summary)) 12)
+      (is (= (.get_total_topologies summary)) 3)
+
+      ;;test for other user
+      (bind other-user (str "not-" (System/getProperty "user.name")))
+      (bind owner-resource-summaries (.getOwnerResourceSummaries (.getNimbus cluster) other-user))
+      (bind summary (first owner-resource-summaries))
+      (is (= (.get_total_workers summary) 0))
+      (is (= (.get_total_executors summary)) 0)
+      (is (= (.get_total_topologies summary)) 0)
       )))

 (deftest test-rebalance


Add/update tests for required and optional entity keys functions

--- src/test/workflo/macros/entity/schema_test.cljc
+++ src/test/workflo/macros/entity/schema_test.cljc
@@ -1,6 +1,6 @@
 (ns workflo.macros.entity.schema-test
   (:require [clojure.spec :as s]
-            [clojure.test :refer [deftest is]]
+            [clojure.test :refer [are deftest is]]
             [workflo.macros.entity :refer [resolve-entity defentity]]
             [workflo.macros.entity.schema :as schema]
             [workflo.macros.specs.types]))
@@ -84,12 +84,34 @@
           :ui/search-text-with-extended-spec [:string]}
          (schema/matching-entity-schemas #"^(url|ui)/.*"))))

+(deftest all-keys
+  (are [x y] (= x (-> y resolve-entity schema/keys))
+    {:required [] :optional []} 'url/selected-user
+    {:required [] :optional []} 'ui/search-text
+    {:required [] :optional []} 'ui/search-text-with-extended-spec
+    {:required [:db/id
+                :user/name
+                :user/email
+                :user/role]
+     :optional [:user/bio]} 'user
+    {:required [:db/id
+                :user/name
+                :user/email
+                :user/role]
+     :optional [:user/bio]} 'user-with-extended-spec))
+
 (deftest required-keys
-  (and (is (= [] (-> 'url/selected-user resolve-entity
-                     schema/required-keys)))
-       (is (= [] (-> 'ui/search-text resolve-entity
-                     schema/required-keys)))
-       (is (= [] (-> 'ui/search-text-with-extended-spec
-                     resolve-entity schema/required-keys)))
-       (is (= [:db/id :user/name :user/email :user/role]
-              (-> 'user resolve-entity schema/required-keys)))))
+  (are [x y] (= x (-> y resolve-entity schema/required-keys))
+    [] 'url/selected-user
+    [] 'ui/search-text
+    [] 'ui/search-text-with-extended-spec
+    [:db/id :user/name :user/email :user/role] 'user
+    [:db/id :user/name :user/email :user/role] 'user-with-extended-spec))
+
+(deftest optional-keys
+  (are [x y] (= x (-> y resolve-entity schema/optional-keys))
+    [] 'url/selected-user
+    [] 'ui/search-text
+    [] 'ui/search-text-with-extended-spec
+    [:user/bio] 'user
+    [:user/bio] 'user-with-extended-spec))


Restoring ns requires that got lost during merge

--- src/cia/init.clj
+++ src/cia/init.clj
@@ -4,6 +4,8 @@
             [cia.auth.threatgrid :as threatgrid]
             [cia.properties :as properties]
             [cia.store :as store]
+            [cia.stores.es.store :as es]
+            [cia.stores.es.index :as es-index]
             [cia.stores.memory :as mem]))

 (defn init-auth-service! []


removed nightlight

removed nightlight

--- main/src/dda/pallet/dda_managed_ide/infra/clojure.clj
+++ main/src/dda/pallet/dda_managed_ide/infra/clojure.clj
@@ -30,8 +30,8 @@
 (def LeiningenUserProfileConfig
   {:os-user-name s/Str
    (s/optional-key :signing-gpg-key) s/Str
-   (s/optional-key :lein-auth) [RepoAuth]
-   (s/optional-key :settings) (hash-set (s/enum :install-nightlight))})
+   (s/optional-key :lein-auth) [RepoAuth]})
+   ;(s/optional-key :settings) (hash-set (s/enum))})

 (defn install-leiningen
   []


Minor fixes on group-selected event.

Minor fixes on group-selected event.

--- src/uxbox/data/workspace.cljs
+++ src/uxbox/data/workspace.cljs
@@ -305,14 +305,13 @@
               (into [group] $)
               (assoc-in state [:pages-by-id pid :shapes] $)))

-          (update-shapes-on-index [state shapes dimensions group]
-            (let [{:keys [x y]} dimensions]
-              (reduce (fn [state {:keys [id] :as shape}]
-                        (as-> shape $
-                          (assoc $ :group group)
-                          (assoc-in state [:shapes-by-id id] $)))
-                      state
-                      shapes)))]
+          (update-shapes-on-index [state shapes group]
+            (reduce (fn [state {:keys [id] :as shape}]
+                      (as-> shape $
+                        (assoc $ :group group)
+                        (assoc-in state [:shapes-by-id id] $)))
+                    state
+                    shapes))]
     (reify rs/UpdateEvent
       (-apply-update [_ state]
         (let [shapes-by-id (get state :shapes-by-id)
@@ -326,7 +325,7 @@
                     :id sid
                     :page pid}]
           (as-> state $
-            (update-shapes-on-index $ selected' dimensions sid)
+            (update-shapes-on-index $ selected' sid)
             (update-shapes-on-page $ pid selected sid)
             (update $ :shapes-by-id assoc sid group)
             (update $ :workspace assoc :selected #{})))))))


Remove query count clamping when hard-coded to 1 query

--- compojure/hello/src/hello/handler.clj
+++ compojure/hello/src/hello/handler.clj
@@ -95,7 +95,6 @@
         1 ; clamp to 1 min
         q)))) ; otherwise use provided value

-
 ; Set up entity World and the database representation
 (defentity fortune
   (pk :id)
@@ -142,9 +141,9 @@
         :headers {"Content-Type" "text/plain; charset=utf-8"}
         :body "Hello, World!"})
   (GET "/json" [] (response {:message "Hello, World!"}))
-  (GET "/db" [] (response (first (run-queries (get-query-count 1)))))
+  (GET "/db" [] (response (first (run-queries 1))))
   (GET "/db/:queries" [queries] (response (run-queries (get-query-count queries))))
-  (GET "/dbraw" [] (response (first (run-queries-raw (get-query-count 1)))))
+  (GET "/dbraw" [] (response (first (run-queries-raw 1))))
   (GET "/dbraw/:queries" [queries] (response (run-queries-raw (get-query-count queries))))
   (GET "/fortune" [] (response (get-fortunes)))
   (GET "/fortune-hiccup" [] (fortunes-hiccup (get-fortunes)))


Removed duplicate values

Removed duplicate values

--- src/video_server/freebase.clj
+++ src/video_server/freebase.clj
@@ -103,11 +103,14 @@
   (when-let [desc (value md :/type/object/name :en)]
     (:value desc)))

+(defn- clean [s]
+  (seq (distinct s)))
+
 (defn get-notable-for [md]
-  (seq (map :text (values md :/common/topic/notable_for :en))))
+  (clean (map :text (values md :/common/topic/notable_for :en))))

 (defn get-notable-types [md]
-  (seq (map :text (values md :/common/topic/notable_types :en))))
+  (clean (map :text (values md :/common/topic/notable_types :en))))

 (defn get-imdb [md]
   (let [urls (map :value (values md :/common/topic/topic_equivalent_webpage))]
@@ -137,7 +140,7 @@
 (defn get-genres [md]
   (when-let [genres (or (values md :/film/film/genre :en)
                         (values md :/tv/tv_program/genre :en))]
-    (seq (map :text genres))))
+    (clean (map :text genres))))

 (defn get-rating [md]
   (when-let [ratings (values md :/film/film/rating)]
@@ -146,15 +149,15 @@
 (defn get-subjects [md]
   (when-let [subjects (or (values md :/film/film/subjects :en)
                           (values md :/tv/tv_program/subjects :en))]
-    (seq (map :text subjects))))
+    (clean (map :text subjects))))

 (defn get-taglines [md]
   (when-let [lines (values md :/film/film/tagline :en)]
-    (seq (map :text lines))))
+    (clean (map :text lines))))

 (defn get-creators [md]
   (when-let [creators (values md :/tv/tv_program/program_creator)]
-    (seq (map :text creators))))
+    (clean (map :text creators))))

 (defn- get-tv-producers [md]
   (when-let [producers (values md :/tv/tv_program/tv_producer)]
@@ -163,41 +166,41 @@

 (defn get-executive-producers [md]
   (if-let [producers (values md :/film/film/executive_produced_by)]
-    (seq (map :text producers))
+    (clean (map :text producers))
     (when-let [producers (get-tv-producers md)]
-      (seq (map first (filter #(= (second %) "Executive Producer") producers))))))
+      (clean (map first (filter #(= (second %) "Executive Producer") producers))))))

 (defn get-producers [md]
   (if-let [producers (values md :/film/film/produced_by)]
-    (seq (map :text producers))
+    (clean (map :text producers))
     (when-let [producers (get-tv-producers md)]
-      (seq (map first (filter #(or (nil? (second %)) (= (second %) "Producer")) producers))))))
+      (clean (map first (filter #(or (nil? (second %)) (= (second %) "Producer")) producers))))))

 (defn get-directors [md]
   (when-let [directors (values md :/film/film/directed_by)]
-    (seq (map :text directors))))
+    (clean (map :text directors))))

 (defn get-actors [md]
   (when-let [actors (values md :/film/film/starring)]
-    (seq (map (comp :text first :values :/film/performance/actor :property) actors))))
+    (clean (map (comp :text first :values :/film/performance/actor :property) actors))))

 (defn get-cast [md]
   (when-let [stars (values md :/tv/tv_program/regular_cast)]
-    (seq (map (comp :text first :values :/tv/regular_tv_appearance/actor :property) stars))))
+    (clean (map (comp :text first :values :/tv/regular_tv_appearance/actor :property) stars))))

 (defn get-networks [md]
   (when-let [networks (values md :/tv/tv_program/original_network)]
-    (seq (map (comp :text first :values :/tv/tv_network_duration/network :property) networks))))
+    (clean (map (comp :text first :values :/tv/tv_network_duration/network :property) networks))))

 (defn get-country [md]
   (:text (or (value md :/film/film/country :en)
              (value md :/tv/tv_program/country_of_origin :en))))

 (defn get-film-locations [md]
-  (seq (map :text (values md :/film/film/featured_film_locations :en))))
+  (clean (map :text (values md :/film/film/featured_film_locations :en))))

 (defn get-trailers [md]
-  (seq (map :value (values md :/film/film/trailers))))
+  (clean (map :value (values md :/film/film/trailers))))

 (defn get-wikipedia [md]
   (let [urls (map :value (values md :/common/topic/topic_equivalent_webpage))
@@ -210,7 +213,7 @@
     (:value id)))

 (defn get-netflix-genres [md]
-  (seq (map :text (values md :/media_common/netflix_title/netflix_genres :en))))
+  (clean (map :text (values md :/media_common/netflix_title/netflix_genres :en))))

 (defn freebase-info
   "Extracts normalized information from the metadata."


Test for language scanner.

Test for language scanner.

--- test/acha/achievement_test.clj
+++ test/acha/achievement_test.clj
@@ -6,7 +6,17 @@
   (let [time #inst "2014-04-20T17:29:59.000-00:00"]
     (is (= {:time time
             :username "Bender"}
-          ((last (achievement/make-date-scanner :foo 3 20))
+          ((last (achievement/make-date-scanner [:foo 3 20]))
            {:time time
             :author "Bender"
             })))))
+
+(deftest language-scanner
+  (let [time #inst "2014-04-20T17:29:59.000-00:00"
+        diffs [[:added]]]
+    (is (= {:time time
+            :username "Bender"}
+          ((last (achievement/make-language-scanner [:clojure ["clj"]]))
+           {:time time
+            :author "Bender"
+            :changed-files [[:add {:id 123} {:id 345 :path "project.clj"}]]})))))


improve docstrings for render and collection tasks

--- src/io/perun.clj
+++ src/io/perun.clj
@@ -254,7 +254,7 @@

    Make files permalinked. E.x. about.html will become about/index.html"
   [p permalink-fn PERMALINKFN code "function to build permalink from TmpFile metadata"
-   _ filterer     FILTER      code "filter function"]
+   _ filterer     FILTER      code "predicate to use for selecting entries (default: `identity`)"]
   (boot/with-pre-wrap fileset
     (let [options       (merge +permalink-defaults+ *opts*)
           files         (filter (:filterer options) (perun/get-meta fileset))
@@ -290,7 +290,7 @@
 (deftask sitemap
   "Generate sitemap"
   [f filename FILENAME str  "generated sitemap filename"
-   _ filterer FILTER   code "filter function"
+   _ filterer FILTER   code "predicate to use for selecting entries (default: `:content`)"
    o target   OUTDIR   str  "the output directory"
    u url      URL      str  "base URL"]
   (let [pod     (create-pod sitemap-deps)
@@ -314,7 +314,7 @@
 (deftask rss
   "Generate RSS feed"
   [f filename    FILENAME    str  "generated RSS feed filename"
-   _ filterer    FILTER      code "filter function"
+   _ filterer    FILTER      code "predicate to use for selecting entries (default: `:content`)"
    o target      OUTDIR      str  "the output directory"
    t title       TITLE       str  "feed title"
    p description DESCRIPTION str  "feed description"
@@ -341,7 +341,7 @@
 (deftask atom-feed
   "Generate Atom feed"
   [f filename    FILENAME    str  "generated Atom feed filename"
-   _ filterer    FILTER      code "filter function"
+   _ filterer    FILTER      code "predicate to use for selecting entries (default: `:content`)"
    o target      OUTDIR      str  "the output directory"
    t title       TITLE       str  "feed title"
    s subtitle    SUBTITLE    str  "feed subtitle"
@@ -382,13 +382,23 @@
    :filterer :content})

 (deftask render
-  "Render pages.
-
-   If permalink is set for the file, it is used as the filepath.
-   If permalink ends in slash, index.html is used as filename.
-   If permalink is not set, the original filename is used with file extension set to html."
-  [o out-dir  OUTDIR   str  "the output directory"
-   _ filterer FILTER   code "filter function"
+  "Render individual pages for entries in perun data.
+
+  The symbol supplied as `renderer` should resolve to a function
+  which will be called with a map containing the following keys:
+   - `:meta`, global perun metadata
+   - `:entries`, all entries
+   - `:entry`, the entry to be rendered
+
+  Entries can optionally be filtered by supplying a function
+  to the `filterer` option.
+
+  Filename is determined as follows:
+  If permalink is set for the file, it is used as the filepath.
+  If permalink ends in slash, index.html is used as filename.
+  If permalink is not set, the original filename is used with file extension set to html."
+  [o out-dir  OUTDIR   str  "the output directory (default: \"public\")"
+   _ filterer FILTER   code "predicate to use for selecting entries (default: `:content`)"
    r renderer RENDERER sym  "page renderer (fully qualified symbol which resolves to a function)"]
   (let [pods    (wrap-pool (pod/pod-pool (boot/get-env)))
         tmp     (boot/tmp-dir!)
@@ -421,12 +431,22 @@
    :comparator (fn [i1 i2] (compare i2 i1))})

 (deftask collection
-  "Render collection files"
+  "Render single file for a collection of entries
+  The symbol supplied as `renderer` should resolve to a function
+  which will be called with a map containing the following keys:
+   - `:meta`, global perun metadata
+   - `:entries`, all entries
+
+  Entries can optionally be filtered by supplying a function
+  to the `filterer` option.
+
+  The `sortby` and `groupby` functions can be used for ordering entries
+  before rendering as well as rendering groups of entries to different pages."
   [o out-dir    OUTDIR     str  "the output directory"
    r renderer   RENDERER   sym  "page renderer (fully qualified symbol resolving to a function)"
-   _ filterer   FILTER     code "filter function"
-   s sortby     SORTBY     code "sort by function"
-   g groupby    GROUPBY    code "group posts by function, keys will be used as filenames where posts (values) will be rendered"
+   _ filterer   FILTER     code "predicate to use for selecting entries (default: `:content`)"
+   s sortby     SORTBY     code "sort entries by function"
+   g groupby    GROUPBY    code "group posts by function, keys are filenames, values are to-be-rendered entries"
    c comparator COMPARATOR code "sort by comparator function"
    p page       PAGE       str  "collection result page path"]
   (let [pods      (wrap-pool (pod/pod-pool (boot/get-env)))


store.pure: adapt to new shape of metrics

--- src/io/cyanite/store/pure.clj
+++ src/io/cyanite/store/pure.clj
@@ -41,7 +41,8 @@
     (let [min-point  (-> points first :time)
           max-point  (-> to (quot precision) (* precision))
           nil-points (empty-series min-point max-point precision)
-          by-path    (->> (group-by :path points)
+          get-path   (fn [{:keys [id]}] (get id "path"))
+          by-path    (->> (group-by get-path points)
                           (map (fn [[k v]] [k (fill-in nil-points v)]))
                           (reduce merge {}))]
       {:from   min-point


Make build scripts executable

Make build scripts executable

--- src/leiningen/new/cljskel.clj
+++ src/leiningen/new/cljskel.clj
@@ -15,10 +15,10 @@
               :year (year)}]
     (->files data
              ["project.clj" (render "project.clj" data)]
-             ["all" (render "all" data)]
+             ["all" (render "all" data) :executable true]
              ["test_helper.sh" (render "test_helper.sh" data)]
-             ["acceptance" (render "acceptance" data)]
-             ["integration" (render "integration" data)]
+             ["acceptance" (render "acceptance" data) :executable true]
+             ["integration" (render "integration" data) :executable true]
              [".gitignore" (render ".gitignore" data)]
              ["src/{{sanitized}}/setup.clj" (render "setup.clj" data)]
              ["src/{{sanitized}}/web.clj" (render "web.clj" data)]


bug #5269 - fix sending from wallet

bug #5269 - fix sending from wallet

Signed-off-by: Andrey Shovkoplyas <b713972e59b8e606e23253c4a13e948139fea4d1@gmail.com>

--- src/status_im/ui/screens/wallet/send/events.cljs
+++ src/status_im/ui/screens/wallet/send/events.cljs
@@ -306,9 +306,13 @@
  (concat models.message/send-interceptors
          navigation/navigation-interceptors)
  (fn [{:keys [db] :as cofx} [chat-id params]]
-   (when-let [send-command (get-in db [:id->command ["send" #{:personal-chats}]])]
+   ;;NOTE(goranjovic): we want to send the payment message only when we have a whisper id
+   ;; for the recipient, we always redirect to `:wallet-transaction-sent` even when we don't
+   (if-let [send-command (and chat-id (get-in db [:id->command ["send" #{:personal-chats}]]))]
      (handlers-macro/merge-fx cofx
                               (commands-sending/send chat-id send-command params)
+                              (navigation/replace-view :wallet-transaction-sent))
+     (handlers-macro/merge-fx cofx
                               (navigation/replace-view :wallet-transaction-sent)))))

 (handlers/register-handler-fx


Now that we have streamparse on clojars, drop the clj and main from bootstrap project.clj files. #7

--- streamparse/bootstrap/project/project.jinja2.clj
+++ streamparse/bootstrap/project/project.jinja2.clj
@@ -1,11 +1,11 @@
 (defproject {{ project_name }} "0.0.1-SNAPSHOT"
-  :source-paths ["clj" "topologies"]
+  :source-paths ["topologies"]
   :resource-paths ["_resources"]
   :aot :all
   :target-path "_build"
   :min-lein-version "2.0.0"
-  :main stormlocal
   :dependencies [[org.apache.storm/storm-core "0.9.1-incubating"]
+                 [com.parsely/streamparse "0.0.1-SNAPSHOT"]
                  [org.clojure/clojure "1.5.1"]
                  [org.clojure/data.json "0.2.4"]
                  [org.clojure/tools.cli "0.3.1"]


REPL should make no assumptions about the namespaces loaded by the runtime

otherwise reloading the browser doesn't allow requiring a namespace
since it thinks its already loaded

--- src/main/shadow/cljs/repl.clj
+++ src/main/shadow/cljs/repl.clj
@@ -177,20 +177,8 @@
         {:keys [reload-deps] :as new-ns-info}
         (ns-form/merge-repl-require ns-info require-form)

-        known-deps
-        (-> #{}
-            (into (:deps ns-info))
-            ;; :deps already had the string aliased
-            ;; need to remember which strings we aliased
-            ;; so we don't reimport the whole thing again
-            (into (keys (:js-deps ns-info)))
-            ;; (require 'the.thing :reload)
-            (util/reduce-> disj reload-deps))
-
         new-deps
-        (->> (:deps new-ns-info)
-             (remove known-deps)
-             (into []))
+        (:deps new-ns-info)

         [new-sources state]
         (res/resolve-repl state (:name new-ns-info) new-deps)


Stopping a stopped service is OK

Stopping a stopped service is OK

--- src/midje/util/scheduling.clj
+++ src/midje/util/scheduling.clj
@@ -6,8 +6,9 @@
 (def scheduled-futures (atom {}))

 (defn stop [service-tag]
-  (.cancel (service-tag @scheduled-futures) true)
-  (swap! scheduled-futures dissoc service-tag))
+  (if-let [future (service-tag @scheduled-futures)]
+    (.cancel future true)
+    (swap! scheduled-futures dissoc service-tag)))

 (defn schedule [service-tag function interval]
   (when (@scheduled-futures service-tag)


Added small comment in read-wiki.clj

Added small comment in read-wiki.clj

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

--- doc/examples/read-wiki.clj
+++ doc/examples/read-wiki.clj
@@ -5,6 +5,8 @@
 ;; By using this software in any fashion, you are agreeing to be bound by
 ;; the terms of this license.
 ;; You must not remove this notice, or any other, from this software.
+
+;; A program to convert data from the dbpedia project to DL models

 (in-ns 'user)

@@ -222,4 +224,4 @@

 ;;;

-nil+nil


Fixed a bug where environments were not converted to javascript objects before sending them to objc.

Signed-off-by: Mike Fikes <mike@fikesfarm.com>

Former-commit-id: cca7aab72ff37c64320302b6e3b947b2b8012c7f

--- planck-cljs/src/planck/sh.cljs
+++ planck-cljs/src/planck/sh.cljs
@@ -35,4 +35,4 @@
   [& args]
   (let [[cmd opts] (parse-args args)
          {:keys [in in-enc out-enc env dir]} opts]
-    (js->clj (js/PLANCK_SHELL_SH (clj->js cmd) in in-enc out-enc env dir) :keywordize-keys true)))
+    (js->clj (js/PLANCK_SHELL_SH (clj->js cmd) in in-enc out-enc (clj->js env) dir) :keywordize-keys true)))


Quick fixes

Quick fixes

--- src/clojure/test/matlab_physicloud/matlab_client.clj
+++ src/clojure/test/matlab_physicloud/matlab_client.clj
@@ -32,7 +32,7 @@
 	(def properties (load-file "config.clj"))

 	(def spatial (new SpatialPhidget))
-	(print "waiting on imu attachment...")
+	(println "waiting on imu attachment...")
 	(.openAny spatial)
 	(.waitForAttachment spatial)
 	(println "ok")
@@ -280,7 +280,8 @@
 	      :neighbors (:neighbors properties)
 	      :requires [:matlab-cmd]
 	                 ;provides either state1, state2, or state3
-	      :provides [(keyword (str "state" (last (str (:id properties)))))]}
+	      :provides [(keyword (str "state" (last (str (:id properties)))))]
+        :output-preference 3}

 	(w/vertex :control
 	           [:matlab-cmd]


attempt to fix pfs problem

attempt to fix pfs problem

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

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -35,8 +35,7 @@
            [org.json JSONObject JSONArray]
            [java.util Date UUID]
            [java.text SimpleDateFormat]
-           [ij ImagePlus]
-           )
+           [ij ImagePlus])
    (:gen-class
      :name org.micromanager.AcqEngine
      :implements [org.micromanager.api.Pipeline]
@@ -182,6 +181,9 @@
   (while (and (:pause @state) (not (:stop @state))) (Thread/sleep 5)))

 (defn interruptible-sleep [time-ms]
+  (when (and (@state :init-continuous-focus)
+             (not (core isContinuousFocusEnabled)))
+    (core enableContinuousFocus true))
   (let [sleepy (CountDownLatch. 1)]
     (state-assoc! :sleepy sleepy :next-wake-time (+ (clock-ms) time-ms))
     (.await sleepy time-ms TimeUnit/MILLISECONDS)))
@@ -207,11 +209,13 @@
   (if (pos? (count stage)) (core getPosition stage) 0))

 (defn set-z-stage-position [stage pos]
-  (if (pos? (count stage)) (core setPosition stage pos)))
+  (when (core isContinuousFocusEnabled)
+    (core enableContinuousFocus false))
+  (when (pos? (count stage)) (core setPosition stage pos)))

 (defn set-stage-position
   ([stage-dev z] (log "setting z position to " z)
-     (core setPosition stage-dev z)
+     (set-z-stage-position stage-dev z)
      (state-assoc! :last-z-position z))
   ([stage-dev x y] (log "setting x,y position to " x "," y)
                    (when (and x y) (core setXYPosition stage-dev x y))))
@@ -324,10 +328,6 @@
       (set (@state :init-system-state))
       (set (get-system-config-cached))))))

-(defn prepare []
-  (when (@state :init-continuous-focus)
-    (core enableContinuousFocus false)))
-
 (defn cleanup []
   (log "cleanup")
   (do-when #(.update %) (:display @state))
@@ -367,7 +367,6 @@
     (def last-state state)
     (let [acq-seq (generate-acq-sequence settings)]
        (def acq-sequence acq-seq)
-       (prepare)
        (execute (mapcat #(make-event-fns % out-queue) acq-seq))
        (.put out-queue TaggedImageQueue/POISON)
        (cleanup))))


Handle email addresses too

Handle email addresses too

--- src/net/dishevelled/mailindex/MailindexURLFilter.clj
+++ src/net/dishevelled/mailindex/MailindexURLFilter.clj
@@ -45,13 +45,25 @@
 (defn pending-tokens ^LinkedList [^MailindexURLFilter this]
   (:pending-tokens @(.state this)))

-(defn prepare-additional-tokens [^MailindexURLFilter this]
+(defn hostname-permutations [^String s]
+  (let [parts (.split s "\\.")]
+   (reductions (fn [state n] (clojure.string/join "." (drop n parts)))
+               s
+               (range 0 (dec (count parts))))))
+
+(defn add-url-tokens [^MailindexURLFilter this]
   (let [hostname (str (char-term-attribute this))]
     (let [parts (.split hostname "\\.")]
-      (doseq [domain (concat (reductions (fn [state n] (clojure.string/join "." (drop n parts)))
-                                         hostname
-                                         (range 0 (dec (count parts))))
+      (doseq [domain (concat (hostname-permutations hostname)
                              parts)]
+        (.push (pending-tokens this)
+               domain)))))
+
+(defn add-email-tokens [^MailindexURLFilter this]
+  (let [email (str (char-term-attribute this))]
+    (let [[username domain] (.split email "@")]
+      (doseq [domain (concat (hostname-permutations domain)
+                             [username domain])]
         (.push (pending-tokens this)
                domain)))))

@@ -68,8 +80,11 @@
 (defn -incrementToken [^MailindexURLFilter this]
   (cond (not (empty? (pending-tokens this))) (emit-pending-token this 0)
         (-> this .input .incrementToken)
-        (if (= (.type (type-attribute this)) "<HOST>")
-          (do (prepare-additional-tokens this)
-              (emit-pending-token this 1))
-          true)
+        (cond (= (.type (type-attribute this)) "<HOST>")
+              (do (add-url-tokens this)
+                  (emit-pending-token this 1))
+              (= (.type (type-attribute this)) "<EMAIL>")
+              (do (add-email-tokens this)
+                  (emit-pending-token this 1))
+              :else true)
         :else false))


Fix test name

Fix test name

--- test/desdemona/query_test.clj
+++ test/desdemona/query_test.clj
@@ -156,7 +156,7 @@
        [{:ip "10.0.0.2"    ;; ip clause succeeded
          :type "ingress"}]])))

-(deftest logic-query-tests
+(deftest run-logic-query-tests
   (are [query results] (= results (#'q/run-logic-query query events))
     'l/fail
     []


bug #5057 - automatically converts recovery phrase to lowecase during recovery

Signed-off-by: Goran Jovic <fc686822162e6f379ea05b6f92d78d206147085c@gmail.com>

--- src/status_im/ui/screens/accounts/recover/views.cljs
+++ src/status_im/ui/screens/accounts/recover/views.cljs
@@ -32,7 +32,7 @@
       :multiline           true
       :default-value       passphrase
       :auto-correct        false
-      :on-change-text      #(re-frame/dispatch [:set-in [:accounts/recover :passphrase] %])
+      :on-change-text      #(re-frame/dispatch [:set-in [:accounts/recover :passphrase] (string/lower-case %)])
       :error               error}]))

 (defview password-input [password]


update parse-intger function

update parse-intger function

--- src-cljs/irc_logger/core.cljs
+++ src-cljs/irc_logger/core.cljs
@@ -17,19 +17,14 @@
     (mod s 18)
     (str "c" s)))

-; TODO
 (defn parse-integer [text]
   (loop [t text, r ""]
-    (if-not (empty? t)
-      (let [c (first t)]
-        (if (js/isNaN (js/parseInt c))
-          (if (not= r "")
-            [(js/parseInt r) t]
-            [nil t])
-          (recur (next t) (str r c))))
-      (if (not= r "")
-        [(js/parseInt r) t]
-        [nil t]))))
+    (let [int (js/parseInt (first t))]
+      (if-not (js/isNaN int)
+        (recur (next t) (str r int))
+        (if (not= r "")
+          [(js/parseInt r) t]
+          [nil t])))))

 (def colors ["white" "black" "blue" "green" "red" "brown"
              "purple" "orange" "yellow" "lime" "teal" "cyan"


Improve future test with more scenarios

Improve future test with more scenarios

--- test/beehive/future_test.clj
+++ test/beehive/future_test.clj
@@ -17,8 +17,12 @@
             [beehive.future :as f])
   (:import (net.uncontended.precipice.concurrent Eventual)))

+(set! *warn-on-reflection* true)
+
 (def pending [:success? :error? :timeout? :rejected? :cancelled? :result :error])
 (def success [:pending? :error? :timeout? :rejected? :cancelled? :error])
+(def error [:pending? :success? :timeout? :rejected? :cancelled? :result])
+(def timeout [:pending? :success? :error? :rejected? :cancelled? :result :error])

 (defn- remove-false [f ks]
   (filter (fn [func] (func f)) ks))
@@ -37,5 +41,24 @@
           future (f/->BeehiveFuture eventual)]
       (.complete eventual 4)
       (is (= :success (:status future)))
+      (is (= 4 (:result future)))
       (is (:success? future))
-      (is (= [] (remove-false future success))))))
+      (is (= [] (remove-false future success)))))
+
+  (testing "Test that error futures work correctly."
+    (let [eventual (Eventual.)
+          ex (RuntimeException.)
+          future (f/->BeehiveFuture eventual)]
+      (.completeExceptionally eventual ex)
+      (is (= :error (:status future)))
+      (is (= ex (:error future)))
+      (is (:error? future))
+      (is (= [] (remove-false future error)))))
+
+  (testing "Test that timeout futures work correctly."
+    (let [eventual (Eventual.)
+          future (f/->BeehiveFuture eventual)]
+      (.completeWithTimeout eventual)
+      (is (= :timeout (:status future)))
+      (is (:timeout? future))
+      (is (= [] (remove-false future timeout))))))


Test for NPE in 'contains'

Test for NPE in 'contains'

--- test/hurvinek/utils_test.clj
+++ test/hurvinek/utils_test.clj
@@ -214,6 +214,13 @@
             true  (contains "Hello world!" "o w")
             true  (contains "Hello world!" "world!"))))

+(deftest test-contains-NPE
+    "Check the function hurvinek.utils/contains."
+    (testing "the function hurvinek.utils/contains."
+        (is (thrown? NullPointerException (contains nil "")))
+        (is (thrown? NullPointerException (contains "" nil)))
+        (is (thrown? NullPointerException (contains nil nil)))))
+
 (deftest test-starts-with-1
     "Check the function hurvinek.utils/starts-with."
     (testing "the function hurvinek.utils/starts-with."


Complete runtime polymorphism koans test

--- clojure/koans/src/koans/09_runtime_polymorphism.clj
+++ clojure/koans/src/koans/09_runtime_polymorphism.clj
@@ -7,19 +7,19 @@
                    "!")))

 (defmulti diet (fn [x] (:eater x)))
-(defmethod diet :herbivore [a] __)
-(defmethod diet :carnivore [a] __)
-(defmethod diet :default [a] __)
+(defmethod diet :herbivore [a] (str (:name a) " eats veggies."))
+(defmethod diet :carnivore [a] (str (:name a) " eats animals."))
+(defmethod diet :default [a] (str "I don't know what " (:name a) " eats."))

 (meditations
   "Some functions can be used in different ways - with no arguments"
-  (= __ (hello))
+  (= "Hello World!" (hello))

   "With one argument"
-  (= __ (hello "world"))
+  (= "Hello, you silly world." (hello "world"))

   "Or with many arguments"
-  (= __
+  (= "Hello to this group: Peter, Paul, Mary!"
      (hello "Peter" "Paul" "Mary"))

   "Multimethods allow more complex dispatching"


(TK-202) Add test to verify context is cleared on restart

This commit adds a simple test to validate that the context is
re-initialized after a restart.

--- test/puppetlabs/trapperkeeper/services_test.clj
+++ test/puppetlabs/trapperkeeper/services_test.clj
@@ -166,6 +166,18 @@
               :start-service1 :start-service2 :start-service3
               :stop-service3 :stop-service2 :stop-service1]
              @call-seq)))))
+
+(deftest test-context-cleared-on-restart
+  (testing "service contexts should be cleared out during a restart"
+    (let [test-context (atom {})
+          service1 (service EmptyService
+                     []
+                     (init [this context]
+                           (swap! test-context merge context)
+                           {:foo "bar"}))]
+      (with-app-with-empty-config app [service1]
+        (app/restart app))
+      (is (= {} @test-context)))))

 (deftest test-lifecycle-service-id-available
   (testing "service-id should be able to be called from any lifecycle phase"


minor(fps): rename, measure-frame-rate

minor(fps): rename, measure-frame-rate

--- re_view/src/re_view/render_loop.cljs
+++ re_view/src/re_view/render_loop.cljs
@@ -24,10 +24,9 @@
   (react-dom/render (react/createElement "div" #js {} (str (Math.floor frame-rate)))
                     (fps-element)))

-(defn toggle-fps!
+(defn measure-frame-rate!
   [value]
-  (set! count-fps? (if (some? value)
-                     value (not count-fps?))))
+  (set! count-fps? value))

 (defonce _raf-polyfill
          (when (js* "typeof window !== 'undefined'")


Refactoro: extract js-array fn

Refactoro: extract js-array fn

--- src/archi/core.clj
+++ src/archi/core.clj
@@ -88,6 +88,11 @@
 (defn wrap-in-quotes [x]
   (str "'" x "'"))

+(defn js-array [coll]
+  (str "["
+       (apply str (interpose ", " (map wrap-in-quotes coll)))
+       "]"))
+
 (defn make-scripts [edges]
   (let [edges-by-feature (group-by (comp :feature #(nth % 2)) edges)]
     (println edges)
@@ -102,12 +107,8 @@
           (apply str (map (fn [edges]
                             (let [nodes (distinct (sort (mapcat #(take 2 %) edges)))
                                   edges (distinct (sort (map (fn [[n1 n2 m]] (:id m)) edges)))]
-                              (str "var nodes = ["
-                                   (apply str (interpose ", " (map wrap-in-quotes nodes)))
-                                   "];\n"
-                                   "var edges = ["
-                                   (apply str (interpose ", " (map wrap-in-quotes edges)))
-                                   "];\n"
+                              (str "var nodes = " (js-array nodes) ";\n"
+                                   "var edges = " (js-array edges) ";\n"
                                    "var d = {nodes: nodes, edges: edges};\n"
                                    (apply str (for [e edges]
                                                 (str "data['" e "'] = d;\n"))))))


remove wip module

remove wip module

--- src/bzzz/query.clj
+++ src/bzzz/query.clj
@@ -4,7 +4,6 @@
   (use bzzz.expr)
   (use bzzz.analyzer)
   (use bzzz.random-score-query)
-  (use bzzz.expr-score-query)
   (:import (org.apache.lucene.queryparser.classic QueryParser)
            (org.apache.lucene.index Term)
            (org.apache.lucene.expressions Expression SimpleBindings)


Added suffix-based renderings to vis-html-loop-state.

--- src/cbfg/core.cljs
+++ src/cbfg/core.cljs
@@ -66,7 +66,7 @@
              [{:delta :actx-end :actx actx :child-actx child-actx :phase :prev}]))}
    :ago-loop
    {:loop-state (fn [vis actx args]
-                  (swap! vis #(assoc-in % [:actxs actx :loop-state] args))
+                  (swap! vis #(assoc-in % [:actxs actx :loop-state] (first args)))
                   nil)}
    :aclose
    {:before (fn [vis actx args]
@@ -144,9 +144,21 @@

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

-(defn vis-html-loop-state [loop-state]
-  (mapv (fn [name val])
-        loop-state))
+(defn vis-html-ch [vis ch]
+  (if ch
+    ["(ch " (:id (get-in vis [:chs ch])) ")"]
+    "nil"))
+
+(defn vis-html-loop-state
+  ([vis loop-state] (mapv (fn [nv] [(vis-html-loop-state vis
+                                                         (first nv) (second nv)) ", "])
+                          loop-state))
+  ([vis name val] (let [name-parts (string/split (str name) #"-")]
+                    (cond (= "ch" (last name-parts)) [name " " (vis-html-ch vis val)]
+                          (= "chs" (last name-parts)) [name " ["
+                                                       (map #(vis-html-ch vis %) val)
+                                                       "]"]
+                          :default [name " " (if val val "nil")]))))

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

@@ -158,7 +170,7 @@
         chs (:chs vis)]
     (assign-position positions actx-id)
     ["
" actx-id
-     "
" (:loop-state actx-info) "
"
+     "
" (vis-html-loop-state vis (:loop-state actx-info)) "
"
      "
"
      "
"
      (mapv (fn [ch-ch-info]


downgrade warning

downgrade warning

--- dada-swt/src/main/clojure/org/dada/swt/nattable.clj
+++ dada-swt/src/main/clojure/org/dada/swt/nattable.clj
@@ -64,7 +64,7 @@
 			    (.propertyChange event-layer (java.beans.PropertyChangeEvent. old-mutable property-name old new)))))
 		      getters
 		      property-names)))
-		  (warn ["rejecting out-of-order version: " old-value new-value])))
+		  (debug ["rejecting out-of-order version: " old-value new-value])))
 	      ;; insertion
 	      ;; TODO - we should check that old-value-version is not > new-value version - if it is, we should remember it as extinct
 	      (let [new-mutable (Mutable. new-value)]


Progress and some docs

Progress and some docs

--- src/h5gal/core.clj
+++ src/h5gal/core.clj
@@ -1,5 +1,41 @@
 (ns h5gal.core
   (:gen-class))
+
+;;;; Gallery Generator built to learn Clojure
+
+;;; Directory strucutre example:
+;;;
+;;;     <datadir>/2011/04/28/Tokyo Trip/Picture3425.jpg
+;;;
+;;; The location of photo's, the first three levels of directory outside of the
+;;; <datadir> are teh date in reverse order. The next "Tokyo Trip" is the name
+;;; of the specific event. These combined should give enough information to
+;;; supply a title and a date of a set of pictures, which might be enough for
+;;; lots of people.
+;;;
+;;;     <datadir>/2011/04/28/Tokyo Trip/README.md
+;;;
+;;; Should you wish to describe the event in detail you can include a README
+;;; within the event directory. It should be formatted using Markdown.
+;;;
+;;;     <datadir>/2011/04/28/Tokyo Trip/Picture3425/README.md
+;;;
+;;; If you want to add a description of what is in the individual picture
+;;; create a directory of the same name, but without the extension and add a
+;;; README file there.
+;;;
+;;;     <datadir>/2011/04/28/Tokyo Trip/Picture3425/_default.jpg
+;;;     <datadir>/2011/04/28/Tokyo Trip/Picture3425/_thumb_small.jpg
+;;;     <datadir>/2011/04/28/Tokyo Trip/Picture3425/_thumb_medium.jpg
+;;;     <datadir>/2011/04/28/Tokyo Trip/Picture3425/_thumb_large.jpg
+;;;
+;;; NOTE: These files will be created automatically for displaying within the
+;;; browser.
+;;;
+;;;     <datadir>/2011/04/28/Tokyo Trip/Picture3425/override.jpg
+;;;
+;;; But if it seems a file called override it will show this within the browser
+;;; instead as well as use it for thumbnails.

 (use '[clojure.java.io])
 (use 'clj-time.core)


Make lexer get rid of empty lines.

Make lexer get rid of empty lines.

--- src/isla/lexer.clj
+++ src/isla/lexer.clj
@@ -6,12 +6,20 @@
   (vec (re-seq #"[^\s\"']+|\"[^\"]*\"|'[^']*'"
                        (str/trim line))))

+(defn chuck-empties [prev lines]
+  (if (> (count lines) 0)
+    (let [cur (first lines)]
+      (concat (if (and (= :nl cur) (= :nl prev)) [] [cur])
+              (chuck-empties cur (rest lines))))
+    []))
+
 (defn lex [string]
-  (let [tokens (flatten (map
-                         (fn [x] (conj x :nl))
-                         (map
-                          (fn [x] (split-a-line x))
-                          (str/split-lines string))))]
+  (let [tokens (chuck-empties nil
+                              (flatten (map
+                                        (fn [x] (conj x :nl))
+                                        (map
+                                         (fn [x] (split-a-line x))
+                                         (str/split-lines string)))))]

     ;; add final newline if required
     (if (not= :nl (last tokens))


Add test for print function in example.

Add test for print function in example.

--- test/cli4clj/test/example.clj
+++ test/cli4clj/test/example.clj
@@ -44,3 +44,13 @@
                              "Divide by zero"])
            out-string))))

+(deftest print-function-test
+  (let [test-cmd-input ["print 1701"]
+        out-string (test-cli-stdout #(-main "") test-cmd-input)]
+    (is
+      (=
+        (expected-string
+          ["Arg-type: java.lang.Long Arg: 1701"
+           "Opt-args: nil"])
+        out-string))))
+


use subject-verb-agreement

use subject-verb-agreement

--- src/babel/english/lexicon.clj
+++ src/babel/english/lexicon.clj
@@ -94,18 +94,26 @@
                                        :3plur "were"}}}]
           [(merge common
                   {:synsem {:sem {:pred :be}}})
-           (let [agr (ref :top)]
-             (merge common
+           (let [subj-agr (ref :top)
+                 infl (ref :top)
+                 the-real-subj (ref :top)
+                 the-obj (ref :top)]
+             (unify common
+                    subject-verb-agreement
                     {:intransitivize false
-                     :synsem {:sem {:pred :be-called
+                     :transitivize false
+                     :synsem {:agr subj-agr
+                              :sem {:pred :be-called
                                     :tense :present
-                                    :subj {:pred :name}
-                                    :obj :top}
+                                    :subj the-real-subj
+                                    :obj the-obj}
                               :subcat {:1 {:cat :noun
-                                           :agr agr
-                                           :sem {:pred :name}}
+                                           :agr subj-agr
+                                           :sem {:pred :name
+                                                 :subj the-real-subj}}
                                        :2 {:cat :noun
-                                           :agr agr
+                                           :agr subj-agr
+                                           :sem the-obj
                                            :propernoun true}}}}))])

    "be able to" {:english {:imperfect {:1sing "was able to"


Clojure 1.3 compatibility

Clojure 1.3 compatibility

--- src/midje/repl.clj
+++ src/midje/repl.clj
@@ -10,9 +10,25 @@
             [midje.ideas.metadata :as metadata]
             [midje.doc :as doc]
             [midje.config :as config]
-            [leiningen.core.project :as project]
             [midje.util.form-utils :as form]
+            [midje.util.ecosystem :as ecosystem]
             [midje.util.namespace :as namespace]))
+
+;; Supply function to leiningen.core.project.
+;; Note that it does not work to put the following code into
+;; midje.util.backwards-compatible-utils.
+
+(in-ns 'clojure.core)
+(if-not (resolve 'ex-info)
+  (defn ex-info
+    ([msg map]
+       (RuntimeException. msg))
+    ([msg map cause]
+       (RuntimeException. msg cause))))
+(in-ns 'midje.repl)
+
+(require '[leiningen.core.project :as project])
+

 (namespace/immigrate-from 'midje.ideas.metadata
                           (map metadata/metadata-function-name


[misc] whitespace.

[misc] whitespace.

--- test/cortex/network_test.cljc
+++ test/cortex/network_test.cljc
@@ -34,7 +34,6 @@
               [(layers/linear-layer 2 3)
                (layers/logistic [3])
                (layers/linear-layer 3 1)])
-
         training-data XOR-DATA
         training-labels XOR-LABELS
         n-epochs 1000
@@ -46,7 +45,6 @@
         network (net/train net optimizer loss-fn training-data training-labels batch-size n-epochs)
         score-percent (net/evaluate net training-data training-labels)]
     (is (< (abs-diff score-percent 1.0) 0.001))))
-

 (deftest linear-model-test
   "Define a random dataset and create the labels from some fixed parameters so we know exactly
@@ -60,8 +58,6 @@
         model (net/train model optimizer loss x-data y-data 10 1)
         mse (net/evaluate-mse model x-data y-data)]
     (is (< mse 1))))
-
-

 ; Data from: Dominick Salvator and Derrick Reagle


Adapt bench/dev code to use new initialization functions.

--- dev/bench/core.cljs
+++ dev/bench/core.cljs
@@ -20,19 +20,17 @@

 (defn- bench-init-10000
   []
-  (js/console.time "init:10000")
-  (let [points (generate-points 1000 10)]
-    (println (count points))
-    (k/create2d points)
-    (js/console.timeEnd "init:10000")))
+  (println "1000x1000,10 -> 10000 points")
+  (let [tree (k/create)]
+    (time
+     (k/initialize tree 1000 1000 10 10))))

 (defn- bench-init-250000
   []
-  (js/console.time "init:250000")
-  (let [points (generate-points 5000 10)]
-    (println (count points))
-    (k/create2d points)
-    (js/console.timeEnd "init:250000")))
+  (println "5000x5000,10 -> 250000 points")
+  (let [tree (k/create)]
+    (time
+     (k/initialize tree 5000 5000 10 10))))

 (defn bench-init
   []
@@ -43,23 +41,26 @@

 (defn- bench-knn-160000
   []
-  (let [tree (k/create2d (generate-points 4000 10))]
-    (dotimes [i 100]
-      (js/console.time "knn:160000")
-      (let [pt #js [(rand-int 400)
-                    (rand-int 400)]]
-        (.nearest tree pt 2))
-      (js/console.timeEnd "knn:160000"))))
+  (let [tree (k/create)]
+    (k/initialize tree 4000 4000 10 10)
+    (println "KNN Search (160000 points) 1000 times")
+    (time
+     (dotimes [i 1000]
+       (let [pt #js [(rand-int 400)
+                     (rand-int 400)]]
+         (.nearest tree pt 2))))))
+

 (defn- bench-knn-360000
   []
-  (let [tree (k/create2d (generate-points 6000 10))]
-    (dotimes [i 100]
-      (js/console.time "knn:360000")
-      (let [pt #js [(rand-int 600)
-                    (rand-int 600)]]
-        (.nearest tree pt 2))
-      (js/console.timeEnd "knn:360000"))))
+  (let [tree (k/create)]
+    (k/initialize tree 6000 6000 10 10)
+    (println "KNN Search (360000 points) 1000 times")
+    (time
+     (dotimes [i 1000]
+       (let [pt #js [(rand-int 600)
+                     (rand-int 600)]]
+         (.nearest tree pt 2))))))

 (defn bench-knn
   []
@@ -70,7 +71,7 @@

 (defn test-accuracity
   []
-  (let [tree (k/create2d (generate-points 4000 20))]
+  (let [tree (k/create (generate-points 4000 20))]
     (print "[1742 1419]")
     (pprint (js->clj (.nearest tree #js [1742 1419] 6)))
     (print "[1742 1420]")


Add help, exit/quit commands, closes #8

Add help, exit/quit commands, closes #8

--- src/reply/main.clj
+++ src/reply/main.clj
@@ -36,16 +36,31 @@
   (println "Welcome back!")
   (reader.jline/resume-reader))

+(defn help []
+  (println "Exit:    Control+D")
+  (println "Docs:    (doc function-name-here)")
+  (println "         (find-doc \"part-of-name-here\")")
+  (println "Javadoc: (javadoc java-object-or-class-here)")
+  (println "Source:  (source function-name-here)"))
+
+(defn exit []
+  (shutdown-agents)
+  (reader.jline/shutdown-reader)
+  (println "Bye for now!")
+  (System/exit 0))
+
+(defn setup-conveniences []
+  (intern 'user 'exit exit)
+  (intern 'user 'quit exit)
+  (intern 'user 'help help))
+
 (defn -main [& args]
   (set-signal-handler! "INT" handle-ctrl-c)
   (set-signal-handler! "CONT" handle-resume)

   (println "Clojure" (clojure-version))
-  (println "Exit:    Control+D")
-  (println "Docs:    (doc function-name-here)")
-  (println "         (find-doc \"part-of-name-here\")")
-  (println "Javadoc: (javadoc java-object-or-class-here)")
-  (println "Source:  (source function-name-here)")
+  (help)
+  (setup-conveniences)

   (with-redefs [clojure.core/print-sequential hacks.printing/print-sequential
                 complete/resolve-class hacks.complete/resolve-class]
@@ -55,6 +70,5 @@
           :prompt (constantly false)
           :need-prompt (constantly false)))

-  (shutdown-agents)
-  (reader.jline/shutdown-reader))
+  (exit))


update consumer

update consumer

--- src/clj_kafka/consumer/zk.clj
+++ src/clj_kafka/consumer/zk.clj
@@ -11,14 +11,13 @@
    (with-resource [c (consumer m)]
      shutdown
      (take 5 (messages c \"test\")))
-
+
    Keys:
-   zk.connect             : host:port for Zookeeper. e.g: 127.0.0.1:2181
-   groupid                : consumer group. e.g. group1
-   zk.sessiontimeout.ms   : session timeout. e.g. 400
-   zk.synctime.ms         : Max time for how far a ZK follower can be behind a ZK leader. 200 ms
-   autocommit.interval.ms : the frequency that the consumed offsets are committed to zookeeper.
-   autocommit.enable      : if set to true, the consumer periodically commits to zookeeper the latest consumed offset of each partition"
+   zookeeper.connect             : host:port for Zookeeper. e.g: 127.0.0.1:2181
+   group.id                      : consumer group. e.g. group1
+   auto.offset.reset             : what to do if an offset is out of range, e.g. smallest, largest
+   auto.commit.interval.ms       : the frequency that the consumed offsets are committed to zookeeper.
+   auto.commit.enable            : if set to true, the consumer periodically commits to zookeeper the latest consumed offset of each partition"
   [m]
   (let [config (ConsumerConfig. (as-properties m))]
     (Consumer/createJavaConsumerConnector config)))


correct error creating budget display structure

--- src/clj_money/web/budgets.clj
+++ src/clj_money/web/budgets.clj
@@ -141,8 +141,8 @@
                  nil)}
    (html
      [:td (:caption item)]
-     (map #(vector :td.text-right (format-number %)) (:data item))
-     [:td.text-right (format-number (reduce + 0 (:data item)))])])
+     (map #(vector :td.text-right (format-number (:value %))) (:data item))
+     [:td.text-right (format-number (reduce + 0 (map :value (:data item))))])])

 (defn- summarize-periods
   [items]
@@ -153,8 +153,7 @@
       (reduce (fn [totals periods]
                 (->> (interleave totals periods)
                      (partition 2)
-                     (map #(apply + %))
-                     (map #(hash-map :value %))))
+                     (map #(apply + %))))
               period-matrix))
     items))

@@ -178,7 +177,7 @@
                              ; header
                              [{:caption (humanize account-type)
                                :style :header
-                               :data totals}]
+                               :data (map #(hash-map :value %) totals)}]
                              ; data
                              (map #(hash-map :caption (-> % :account :name)
                                              :style :data
@@ -207,7 +206,6 @@
                     :style :summary
                     :data (->> (interleave (-> result :totals :income)
                                            (-> result :totals :expense))
-                               (map :value)
                                (partition 2)
                                (map #(apply - %))
                                (map #(hash-map :value %)))}])))
@@ -222,8 +220,7 @@
 (defn show
   "Renders the budet details"
   [id]
-  (let [budget (-> (budgets/find-by-id (env :db) id)
-                   (update-in [:items] group-budget-items))]
+  (let [budget (for-display id)]
   (layout
     (str "Budget: " (:name budget)) {}
     [:div.row


Compare props map using identical? only

Compare props map using identical? only

That makes shouldComponentUpdate even faster, especially with big
maps/vectors as args

--- src/cloact/impl/template.cljs
+++ src/cloact/impl/template.cljs
@@ -69,6 +69,7 @@
              objprops))))

 (defn identical-parts [v1 v2 from]
+  ;; Compare two vectors, from item with index "from", using identical?
   (let [end (count v1)]
     (loop [n from]
       (if (>= n end)
@@ -77,17 +78,35 @@
           (recur (inc n))
           false)))))

+(def -not-found (js-obj))
+
+(defn shallow-equal-maps [x y]
+  ;; Compare two maps, using identical? on all values
+  (or (identical? x y)
+      (when (== (count x) (count y))
+        (reduce-kv (fn [res k v]
+                     (let [yv (get y k -not-found)]
+                       (if (or (identical? v yv)
+                               ;; hack to allow cloact.core/partial
+                               (and (ifn? v) (= v yv)))
+                         res
+                         (reduced false))))
+                   true x))))
+
 (defn equal-args [v1 v2]
-  (let [c1 (count v1)]
-    (and (= (nth v1 0) (nth v2 0))
-         (identical? c1 (count v2))
-         (if (< c1 2)
-           true
-           (let [props1 (nth v1 1)]
-             (if (or (nil? props1) (map? props1))
-               (and (identical-parts v1 v2 2)
-                    (= props1 (nth v2 1)))
-               (identical-parts v1 v2 1)))))))
+  ;; Compare two "args" vectors, i.e things like [:div {:foo "bar} "baz"],
+  ;; using identical? on all individual parts.
+  (or (identical? v1 v2)
+      (let [c1 (count v1)]
+        (and (= (nth v1 0) (nth v2 0)) ; may be symbol or fn
+             (identical? c1 (count v2))
+             (if (< c1 2)
+               true
+               (let [props1 (nth v1 1)]
+                 (if (or (nil? props1) (map? props1))
+                   (and (identical-parts v1 v2 2)
+                        (shallow-equal-maps props1 (nth v2 1)))
+                   (identical-parts v1 v2 1))))))))

 (declare wrapper)


Allow game-pref! to update multiple key-value pairs

--- src/clojure/nightmod/game.clj
+++ src/clojure/nightmod/game.clj
@@ -59,9 +59,11 @@
 (defn game-pref!
   "Stores preferences.

-    (game-pref! {:level 10 :health 5})
-    (game-pref! :level 10)"
-  ([m]
-    (spit (io/file @u/project-dir u/prefs-file) (pr-str m)))
-  ([k v]
-    (game-pref! (assoc (game-pref) k v))))
+    (game-pref! {:level 10 :health 5}) ; replace all preferences
+    (game-pref! :level 10 :health 5) ; add to existing preferences"
+  [& keyvals]
+  (->> (if (map? (first keyvals))
+         (first keyvals)
+         (apply assoc (game-pref) keyvals))
+       pr-str
+       (spit (io/file @u/project-dir u/prefs-file))))


CMR-615: Added check for content type to find-concepts.

--- src/cmr/search/api/routes.clj
+++ src/cmr/search/api/routes.clj
@@ -2,6 +2,7 @@
   (:require [compojure.handler :as handler]
             [compojure.route :as route]
             [compojure.core :refer :all]
+            [clojure.string :as str]
             [ring.util.response :as r]
             [ring.util.codec :as codec]
             [ring.middleware.json :as ring-json]
@@ -147,16 +148,21 @@
 (defn- find-concepts
   "Invokes query service to find results and returns the response"
   [context path-w-extension params headers query-string]
-  (let [concept-type (concept-type-path-w-extension->concept-type path-w-extension)
-        context (-> context
-                    (process-context-info params headers)
-                    (assoc :query-string query-string))
-        params (process-params params path-w-extension headers "application/xml")
-        _ (info (format "Searching for %ss from client %s in format %s with params %s."
-                        (name concept-type) (:client-id context) (:result-format params) (pr-str params)))
-        search-params (lp/process-legacy-psa params query-string)
-        results (query-svc/find-concepts-by-parameters context concept-type search-params)]
-    (search-response params results)))
+  (println headers)
+  (if (= "application/x-www-form-urlencoded" (get headers (str/lower-case CONTENT_TYPE_HEADER)))
+    (let [concept-type (concept-type-path-w-extension->concept-type path-w-extension)
+          context (-> context
+                      (process-context-info params headers)
+                      (assoc :query-string query-string))
+          params (process-params params path-w-extension headers "application/xml")
+          _ (info (format "Searching for %ss from client %s in format %s with params %s."
+                          (name concept-type) (:client-id context) (:result-format params)
+                          (pr-str params)))
+          search-params (lp/process-legacy-psa params query-string)
+          results (query-svc/find-concepts-by-parameters context concept-type search-params)]
+      (search-response params results))
+    {:status 415
+     :body (str "Unsupported content type [" (get headers (str/lower-case CONTENT_TYPE_HEADER)) "]")}))

 (defn- find-concepts-by-aql
   "Invokes query service to parse the AQL query, find results and returns the response"
@@ -220,14 +226,14 @@
         (GET "/" {params :params headers :headers context :request-context}
           (find-concept-by-cmr-concept-id context path-w-extension params headers)))

-      ;; Find concepts
+      ;; Find concepts - form encoded
       (context ["/:path-w-extension" :path-w-extension concept-type-w-extension-regex] [path-w-extension]
         (GET "/" {params :params headers :headers context :request-context query-string :query-string}
           (find-concepts context path-w-extension params headers query-string))
         (POST "/" {params :params headers :headers context :request-context body :body-copy}
           (find-concepts context path-w-extension params headers body)))

-      ;; AQL search
+      ;; AQL search - xml
       (context ["/concepts/:path-w-extension" :path-w-extension search-w-extension-regex] [path-w-extension]
         (POST "/" {params :params headers :headers context :request-context body :body-copy}
           (find-concepts-by-aql context path-w-extension params headers body)))


test for CLJS-853

test for CLJS-853


Even simpler test case

Even simpler test case

--- test/desdemona/query_test.clj
+++ test/desdemona/query_test.clj
@@ -4,6 +4,8 @@
    [clojure.test :refer [deftest is are testing]]))

 (deftest infix->dsl-tests
+  (is (= '(= 1 1)
+         (q/infix->dsl "1 = 1")))
   (is (= '(= (:ip x) "10.0.0.1")
          (q/infix->dsl "ip(x) = 10.0.0.1"))))


Basic host-key tests

Basic host-key tests

I can expect other tests will break as well if host-key breaks, but
this will let me know what happened faster.

--- test/relevance/test/data.cljs
+++ test/relevance/test/data.cljs
@@ -51,6 +51,15 @@
                                :time       4432
                                :host       "www.kitco.com"}}})

+
+(deftest test-host-key
+  ;;Test the host-key function against known values
+  (are [host key] (= (utils/host-key host) key)
+                  "numergent.com" 971841386
+                  "google.com" -1536293812
+                  "startpage.com" 920793092
+                  "" 0
+                  nil 0))

 (deftest test-track-url-time
@@ -113,6 +122,7 @@
       (is (= 9001 (:time item)) "Time should have increased")
       ))
   )
+

 (deftest test-track-site-time
   (testing "Add time to an empty database"
@@ -180,4 +190,6 @@
         (is (= (val other) (get (:site-times test-db) (key other))) "Other items should have remained untouched")
         ))
     )
-  )+  )
+
+


Parametrized tests with chan-size.

Parametrized tests with chan-size.

--- test/ago/test.cljs
+++ test/ago/test.cljs
@@ -144,11 +144,11 @@
                (assert (seqv-alive? agw nil))
                (assert (seqv-alive? agw2 nil)))))))

-(defn test-put-take []
-  (println "test-put-take")
+(defn test-put-take [chan-size]
+  (println "test-put-take" chan-size)
   (let [agw (make-ago-world nil)
-        ch0 (ago-chan agw)
-        ch1 (ago-chan agw)
+        ch0 (ago-chan agw chan-size)
+        ch1 (ago-chan agw chan-size)
         echoer (ago agw
                     (loop [acc []]
                       (if-let [msg (<! ch0)]
@@ -176,12 +176,12 @@
         (recur)))
     @all-done))

-(defn test-alts []
-  (println "test-alts")
+(defn test-alts [chan-size]
+  (println "test-alts" chan-size)
   (let [agw (make-ago-world nil)
-        chx (ago-chan agw)
-        chy (ago-chan agw)
-        chz (ago-chan agw)
+        chx (ago-chan agw chan-size)
+        chy (ago-chan agw chan-size)
+        chz (ago-chan agw chan-size)
         collector (ago agw
                        (loop [chs #{chx chy chz}
                               acc #{}]
@@ -223,7 +223,11 @@
   (println "ago test run started.")
   (test-constructors)
   (test-seqvs)
-  (test-put-take)
-  (test-alts)
+  (test-put-take 0)
+  (test-put-take 1)
+  (test-put-take 10)
+  (test-alts 0)
+  (test-alts 1)
+  (test-alts 10)
   (println "ago test run PASS.")
   success)


doseq was the way to go (mapM_)

doseq was the way to go (mapM_)

--- src/didactic_waddle/core.cljs
+++ src/didactic_waddle/core.cljs
@@ -49,8 +49,7 @@
 (defn draw-state [state]
   ; Clear the sketch by filling it with light-grey color.
   (q/background 240)
-  ; Set circle color.
-  (map draw-box (:boxes state)))
+  (doseq [box (:boxes state)] (draw-box box)))

 (q/defsketch didactic-waddle
   :host "didactic-waddle"


Add fn to construct current version

Add fn to construct current version

--- src/discuss/utils/common.cljs
+++ src/discuss/utils/common.cljs
@@ -3,17 +3,26 @@
             [clojure.walk :refer [keywordize-keys]]
             [clojure.string :refer [trim trim-newline]]
             [cljs.spec.alpha :as s]
-            [goog.string :as gstring]
+            [goog.string :as gstring :refer [format]]
+            [goog.string.format]
             [cognitect.transit :as transit]
             [inflections.core :refer [plural]]
             [discuss.config :as config]
             [discuss.parser :as parser]
-            [discuss.utils.logging :as log]))
+            [discuss.utils.logging :as log]
+            [clojure.string :as string]))

 (defn prefix-name
   "Create unique id for DOM elements."
   [name]
   (str config/project "-" name))
+
+(defn project-version
+  "Return the project's current version."
+  []
+  (format "%s-%s" (string/replace config/version "\"" "") config/build-commit))
+(s/fdef project-version
+  :ret string?)

 (s/def ::fn-and-val (s/tuple symbol? any?))
 (s/def ::col-of-fn-and-vals (s/coll-of ::fn-and-val))


Uploading challenge 2

Uploading challenge 2

--- day3/challenge1/challenge1.clj
+++ day3/challenge1/challenge1.clj
@@ -7,14 +7,13 @@
                             (remove #(= % "" ))
                             (map read-string)
                             (sort)
-                            (seq)
                             )
 )

 (defn make-triangles [strings] (map make-triangle strings))

-(defn is-valid-triangle [[a b c]] (> (+ a b) c))
-(defn get-valid-triangles [triangles] (filter is-valid-triangle triangles))
+(defn is-valid-triangle? [[a b c]] (> (+ a b) c))
+(defn get-valid-triangles [triangles] (filter is-valid-triangle? triangles))

 (defn main [] (->
                (read-file)


Refactor out common request operation

Refactor out common request operation

--- src/grimoire/api/web/read.clj
+++ src/grimoire/api/web/read.clj
@@ -26,50 +26,31 @@
 (defn make-request [thing op]
   (str baseurl (:uri thing) "?op=" op "&type=edn"))

-(defmethod api/list-groups :web [config]
-  ;; FIXME: Needs to return a Succeed[Seq[Thing]]
-  (let [?res (->  nil
-                 (make-request "groups")
+(defn do-thing-req [op ctor parent]
+  (let [?res (->  op
+                 (make-request op)
                  slurp
                  edn/read-string)]
     (if (grim-succeed? ?res)
       (->> ?res grim-result
-         (map (comp ->Group :name))
+         (map (comp (partial ctor parent) :name))
          succeed)
       (fail (grim-result ?res)))))

+(defmethod api/list-groups :web [config]
+  (do-thing-req "groups" ->Group nil))
+
 (defmethod api/list-artifacts :web [config group-thing]
-  ;; FIXME: Needs to return a Succeed[Seq[Thing]]
-  (let [?res (-> group-thing
-                (make-request "artifacts")
-                slurp
-                edn/read-string)]
-    (if (grim-succeed? ?res)
-      (->> ?res grim-result
-         (map (comp (partial ->Artifact group-thing) :name))
-         succeed)
-      (fail (grim-result ?res)))))
+  (do-thing-req "artifacts" ->Artifact group-thing)

 (defmethod api/list-versions :web [config artifact-thing]
-  ;; FIXME: Needs to return a Succeed[Seq[Thing]]
-  (let [?res (-> artifact-thing
-                (make-request "versions")
-                edn/read-string)]
-    ((if (grim-succeed? ?res)
-       succeed fail)
-     (grim-result ?res))))
+  (do-thing-req "versions" ->Version artifact-thing))

 (defmethod api/list-namespaces :web [config version-thing]
-  ;; FIXME: Needs to return a Succeed[Seq[Thing]]
-  (-> version-thing
-     (make-request "namespaces")
-     edn/read-string))
+  (do-thing-req "namespaces" ->Ns version-thing)))

 (defmethod api/list-defs :web [config namespace-thing]
-  ;; FIXME: Needs to return a Succeed[Seq[Thing]]
-  (-> namespace-thing
-     (make-request "all")
-     edn/read-string))
+  (do-thing-req "all" ->Def namespace-thing))

 (defmethod api/thing->prior-versions :web [config thing]
   {:pre [(#{:version :namespace :def} (:type thing))]}


cleanup

cleanup

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

--- plugins/SlideExplorer2/src/slide_explorer/display.clj
+++ plugins/SlideExplorer2/src/slide_explorer/display.clj
@@ -27,11 +27,6 @@
                          (remove-watch reference key))))
       .show))
   reference)
-
-(defn- default-screen-device []
-  (->
-    (java.awt.GraphicsEnvironment/getLocalGraphicsEnvironment)
-    .getDefaultScreenDevice))

 (defn bind-key
   "Maps an input-key on a swing component to an action,
@@ -53,6 +48,11 @@
 (defn bind-window-key
   [window input-key action-fn]
   (bind-key (.getContentPane window) input-key action-fn true))
+
+(defn- default-screen-device []
+  (->
+    (java.awt.GraphicsEnvironment/getLocalGraphicsEnvironment)
+    .getDefaultScreenDevice))

 (defn full-screen! ; adapted from seesaw
   "Make the given window/frame full-screen. Pass nil to return all windows


Update persistence.clj

Update persistence.clj

--- src/iyye/bios/persistence.clj
+++ src/iyye/bios/persistence.clj
@@ -64,12 +64,10 @@
         entry {:time current-time-to-string dir input}]
     (mongo/add-entry dbname doc entry)))

-
  (defn write-knowledge-to-db [doc-name fact]
-   (let [dbname (str @iyye-name "_knowledge")
-         doc doc-name]
-     (println "writing to DB:" fact)
-     (mongo/add-entry dbname doc fact)))
+   (let [dbname (str @iyye-name "_knowledge")]
+     (log/info "add list: " (str fact))
+     (mongo/add-entry dbname doc-name fact)))

 ; (apply str (rest (str (:When {:When :ALWAYS}))))


Add Twitter lexicon.

Add Twitter lexicon.

--- src/kolmogorov_music/talk.clj
+++ src/kolmogorov_music/talk.clj
@@ -129,9 +129,9 @@
 (fact "Lexicons aren't very random."
   (randomness (take 10000 (library-of-babel))) => #(< % 1/100))

-
-
-
+(comment
+  (take 100000
+     (letfn[(t[](cons[](for[x(lazy-seq(t))e(map char(range 32 65536))](conj x e))))](map #(apply str %)(take-while #(<(count %)141)(t))))))

 ;;;;;;;;;;;;;;;;
 ;;; Contact ;;;;


updated Compojure to latest

updated Compojure to latest

--- src/leiningen/new/reagent.clj
+++ src/leiningen/new/reagent.clj
@@ -36,7 +36,7 @@
     [ring "1.3.1"]
     [ring/ring-defaults "0.1.2"]
     [prone "0.6.0"]
-    [compojure "1.2.0"]
+    [compojure "1.3.1"]
     [selmer "0.7.2"]
     [environ "1.0.0"]
     [leiningen "2.5.0"]


structure tenzing.clj a bit more

structure tenzing.clj a bit more

--- src/leiningen/new/tenzing.clj
+++ src/leiningen/new/tenzing.clj
@@ -44,6 +44,9 @@
 (defn indent [n list]
   (wrap-indent identity n list))

+; ---------------------------------------------------------------
+; Options - currently: divshot, reagent, om, sass, garden
+; ---------------------------------------------------------------

 (defn divshot? [opts]
   (some #{"+divshot"} opts))
@@ -60,8 +63,9 @@
 (defn garden? [opts]
   (some #{"+garden"} opts))

-(defn cljs-lib? [opts]
-  (or (om? opts) (reagent? opts)))
+;; ---------------------------------------------------------------
+;; Template data helpers
+;; ---------------------------------------------------------------

 (defn source-paths [opts]
   (cond-> #{"src/cljs"}
@@ -127,14 +131,16 @@
    :index-html-script-tags (indent 4 (index-html-script-tags opts))
    :index-html-head-tags (indent 4 (index-html-head-tags opts))})

-(defn warn-on-exclusive-opts! [opts]
+(defn warn-on-exclusive-opts!
+  "Some options can't be used together w/o added complexity."
+  [opts]
   (when (and (om? opts)
              (reagent? opts))
     (main/warn "Please specify only +om or +reagent, not both.")
     (main/exit)))

 (defn tenzing
-  "FIXME: write documentation"
+  "Main function to generate new tenzing project."
   [name & opts]
   (let [data     (template-data name opts)
         app-cljs "src/cljs/{{sanitized}}/app.cljs"]
@@ -145,9 +151,9 @@
                    (vector (if (divshot? opts) ["divshot.json" (render "divshot.json" data)])
                            (if (garden? opts)  ["src/clj/{{sanitized}}/styles.clj" (render "styles.clj" data)])
                            (if (sass? opts)    ["sass/styles.sass" (render "styles.sass" data)])
-                           (if (reagent? opts) [app-cljs (render "reagent-app.cljs" data)])
-                           (if (om? opts)      [app-cljs (render "om-app.cljs" data)])
-                           (if (not (cljs-lib? opts)) [app-cljs (render "app.cljs" data)])
+                           (cond (reagent? opts) [app-cljs (render "reagent-app.cljs" data)]
+                                 (om? opts)      [app-cljs (render "om-app.cljs" data)]
+                                 :none           [app-cljs (render "app.cljs" data)])

                            ["resources/index.html" (render "index.html" data)]
                            ["build.boot" (render "build.boot" data)])))))


fix type hints

fix type hints

--- src/main/clojure/clojure/test/generative/generators.clj
+++ src/main/clojure/clojure/test/generative/generators.clj
@@ -47,25 +47,25 @@

 (defn geometric
   "Geometric distribution with mean 1/p."
-  [p]
+  ^long [p]
   (core/long (Math/ceil (/ (Math/log (.nextDouble *rnd*))
                            (Math/log (- 1.0 p))))))

 (defn uniform
   "Uniform distribution from lo (inclusive) to high (exclusive).
    Defaults to range of Java long."
-  ([] (.nextLong *rnd*))
-  ([lo hi] {:pre [(< lo hi)]}
-     (clojure.core/long (Math/floor (+ lo (* (.nextDouble *rnd*) (- hi lo)))))))
-
-(defn ^float float
+  (^long [] (.nextLong *rnd*))
+  (^long[lo hi] {:pre [(< lo hi)]}
+         (clojure.core/long (Math/floor (+ lo (* (.nextDouble *rnd*) (- hi lo)))))))
+
+(defn float
   "Generate a float."
-  []
+  ^double []
   (Float/intBitsToFloat (.nextInt *rnd*)))

-(defn ^double double
+(defn double
   "Generate a double."
-  []
+  ^double []
   (.nextDouble *rnd*))

 (defn rand-nth
@@ -102,7 +102,7 @@
    of the framework (and subject to change!)
    If you want to explicitly control the distribution, use one of the
    distribution fns, e.g. uniform, geometric, etc."
-  []
+  ^long []
   (one-of
    (uniform -2 3)
    uniform))
@@ -112,18 +112,18 @@
    convenience of the framework (and subject to change!)
    If you want to explicitly control the distribution, use one of the
    distribution fns, e.g. uniform, geometric, etc."
-  ([] (unsigned-long Long/MAX_VALUE))
-  ([upper] {:pre [(pos? upper)]}
-     (one-of
-       (uniform 0 (min 3 upper))
-       (uniform 0 upper))))
-
-(defn ^byte byte
+  (^long [] (unsigned-long Long/MAX_VALUE))
+  (^long [upper] {:pre [(pos? upper)]}
+         (one-of
+          (uniform 0 (min 3 upper))
+          (uniform 0 upper))))
+
+(defn byte
   "Returns a random long in the byte range."
-  []
+  ^long []
   (uniform Byte/MIN_VALUE (inc (core/int Byte/MAX_VALUE))))

-(defn ^bool bool
+(defn bool
   "Returns a random bool."
   []
   (< (.nextDouble *rnd*) 0.5))
@@ -206,10 +206,8 @@
 (defn string
   "Create a string with chars from v and sized from sizer."
   ([] (string printable-ascii-char))
-  ([f]
-     (string f default-sizer))
-  ([f sizer]
-     (apply str (reps sizer f))))
+  ([f] (string f default-sizer))
+  ([f sizer] (apply str (reps sizer f))))

 (def ^:private ascii-alpha
   (concat (range 65 (+ 65 26))


Don't assume group-examples inside group

--- src/main/clojure/com/stuartsierra/lazytest/examples.clj
+++ src/main/clojure/com/stuartsierra/lazytest/examples.clj
@@ -66,8 +66,7 @@
   bindings is a vector of symbol-context pairs, symbols will become
   locals in the examples.

-  examples is a vector of expressions to be compiled into example
-  functions.
+  examples is a vector of compiled examples functions.

   subgroups is a vector of child example groups."
   [bindings examples subgroups]
@@ -77,7 +76,7 @@
     `(with-context ~(first bindings) ~(second bindings)
        (group ~(vec (nnext bindings)) ~examples ~subgroups))
     `(new-group ~(find-locals &env)
-                (group-examples ~@examples)
+                ~examples
                 ~subgroups
                 ~(standard-metadata &form nil))))

@@ -110,7 +109,7 @@
     (assert (= '[x] (:locals m)))))

 (let [c1 (com.stuartsierra.lazytest.contexts/context [] 1)
-      g (group [x c1] [(= 1 x) "foo" (= x 2)] [])]
+      g (group [x c1] (group-examples (= 1 x) "foo" (= x 2)) [])]
   (assert (group? g))
   (assert (= [c1] (:contexts g)))
   (let [exs (:examples g)]
@@ -137,7 +136,7 @@

 (let [c1 (com.stuartsierra.lazytest.contexts/context [] 1)
       c2 (com.stuartsierra.lazytest.contexts/context [] 2)
-      g (group [x c1 y c2] [(= 1 x) "foo" (= y 2)] [])]
+      g (group [x c1 y c2] (group-examples (= 1 x) "foo" (= y 2)) [])]
   (assert (group? g))
   (assert (= [c1 c2] (:contexts g)))
   (let [exs (:examples g)]


Reenable the pricing page

Reenable the pricing page

--- src-cljs/frontend/components/app.cljs
+++ src-cljs/frontend/components/app.cljs
@@ -71,6 +71,7 @@
     :landing (if (config/enterprise?) enterprise-landing/home landing/home)
     :changelog changelog/changelog
     :documentation docs/documentation
+    :pricing pricing/pricing

     :signup signup/signup


Break out current plan notice component, fix various copy, try to simplify.

--- frontend/components/org_settings.cljs
+++ frontend/components/org_settings.cljs
@@ -5,7 +5,7 @@
             [frontend.routes :as routes]
             [frontend.datetime :as datetime]
             [frontend.models.organization :as org-model]
-            [frontend.models.plan :as plan-model]
+            [frontend.models.plan :as pm]
             [frontend.models.repo :as repo-model]
             [frontend.models.user :as user-model]
             [frontend.components.common :as common]
@@ -48,10 +48,10 @@
                             {:page :users :text "Users"}])
                 [:li.nav-header "Plan"]
                 (when plan
-                  (if (plan-model/can-edit-plan? plan org-name)
+                  (if (pm/can-edit-plan? plan org-name)
                     (let [links [{:page :containers :text "Adjust containers"}
                                  {:page :organizations :text "Organizations"}]
-                          links (if (plan-model/paid? plan)
+                          links (if (pm/paid? plan)
                                   (into links [{:page :billing :text "Billing info"}
                                                {:page :cancel :text "Cancel"}])
                                   links)]
@@ -213,17 +213,17 @@

 (defn plans-trial-notification [plan org-name owner]
   [:div.row-fluid
-   [:div.alert.alert-success {:class (when (plan-model/trial-over? plan) "alert-error")}
+   [:div.alert.alert-success {:class (when (pm/trial-over? plan) "alert-error")}
     [:p
-     (if (plan-model/trial-over? plan)
+     (if (pm/trial-over? plan)
        "Your 2-week trial is over!"

        [:span "The " [:strong org-name] " organization has "
-        (plan-model/pretty-trial-time plan) " left in its trial."])]
+        (pm/pretty-trial-time plan) " left in its trial."])]
     [:p
      "The trial plan is equivalent to the Solo plan with 6 containers."]
     (when (and (not (:too_many_extensions plan))
-               (> 3 (plan-model/days-left-in-trial plan)))
+               (> 3 (pm/days-left-in-trial plan)))
       [:p
        "Need more time to decide? "
        (forms/managed-button
@@ -247,8 +247,13 @@
                                                   :subpage "plan"})}
        (:org_name plan) " plan page"] "."]
      [:p
-      "You can create a separate plan for " current-org-name " by selecting from the plans below."]]]])
-
+      "You can create a separate plan for " current-org-name " below."]]]])
+
+;;
+;; TODO: Kill this component when we're sure we're happy w/ the new
+;; pricing page (ie, the 'Adjust containers' used for all plans.)
+;; Leaving it for now out of cowardice.
+;;
 (defn plan [app owner]
   (reify

@@ -286,19 +291,67 @@
            [:div.loading-spinner common/spinner]

            [:div#billing.plans.pricing.row-fluid
-            (when (plan-model/trial? plan)
+            (when (pm/trial? plan)
               (plans-trial-notification plan org-name owner))
-            (when (plan-model/piggieback? plan org-name)
+            (when (pm/piggieback? plan org-name)
               (plans-piggieback-plan-notification plan org-name))
             (om/build plans-component/plans app)
             (shared/customers-trust)
             (om/build plans-component/pricing-features app)
             plans-component/pricing-faq]))))))

+(defn current-plan-desc
+  "A div that explains your current plan."
+  [app owner]
+  (om/component
+   (html
+    (let [org-name (get-in app state/org-name-path)
+          plan (get-in app state/org-plan-path)
+          plan-total (pm/stripe-cost plan)
+          container-cost (pm/per-container-cost plan)]
+      [:div.plan
+       ;; TODO: make the org-name a drop-down selector of the orgs you
+       ;; are a member of.
+       [:h2 org-name "'" (when-not (re-matches #".*s" org-name) "s")
+        " Current Plan"]
+       (cond
+        (pm/paid? plan)
+        (list
+         [:p [:strong "PAID"]]
+         [:ul
+          [:li [:strong (pm/usable-containers plan) " for $" plan-total] "/ month"]
+          (when (pm/freemium? plan)
+            [:li "Includes " (pluralize (pm/freemium-containers plan) "container") " FREE!"])
+          (if (> (pm/paid-plan-min-containers plan) 0)
+            [:li (if (pm/freemium? plan) "Next " "First ")
+             (pluralize (pm/paid-plan-min-containers plan) "container") " at $"
+             (-> plan :paid :template :price)])
+          [:li "Additional containers for $" (pm/per-container-cost plan) "/month"]
+          [:li [:strong "No other limits"]]])
+
+        (and (pm/freemium? plan)
+             (not (pm/in-trial? plan)))
+        (list
+         [:p [:strong "FREE"]]
+         [:ul [:li "Includes " (pluralize (:containers plan) "container") " free!"]
+          [:li "Additional containers for $" container-cost "/month"]
+          [:li [:strong "No other limits"]]])
+
+        (pm/trial? plan)
+        (list
+         [:p [:strong "TRIAL" (when-not (pm/in-trial? plan) " ENDED")]]
+         [:ul
+          (if (pm/in-trial? plan)
+            [:li "You are currently trialing a plan with " (pluralize (pm/usable-containers plan) "container") "."]
+            [:li "Your trial of a plan with " (pluralize (pm/trial-containers plan) "container") " has ended. Please add containers to continue building private repositories."])
+          [:li "Additional containers for $" (pm/per-container-cost plan) "/month"]
+          [:li [:strong "No other limits"]]]))]))))
+
 (defn containers [app owner]
   (reify
     ;; I stole the stateful "did we load stripe checkout code" stuff
-    ;; from the billing-info component; is there some nice way to
+    ;; from the plan component above, but the billing-card component
+    ;; also has it. What's the nice way to
     ;; abstract it out?
     om/IInitState
     (init-state [_]
@@ -325,16 +378,18 @@
       (let [org-name (get-in app state/org-name-path)
             plan (get-in app state/org-plan-path)
             selected-containers (or (get-in app state/selected-containers-path)
-                                    (plan-model/usable-containers plan))
-            selected-paid-containers (max 0 (- selected-containers (plan-model/freemium-containers plan)))
-            old-total (plan-model/stripe-cost plan)
-            new-total (plan-model/cost plan selected-containers)
-            container-cost (plan-model/per-container-cost plan)]
+                                    (pm/usable-containers plan))
+            selected-paid-containers (max 0 (- selected-containers (pm/freemium-containers plan)))
+            old-total (pm/stripe-cost plan)
+            new-total (pm/cost plan selected-containers)
+            container-cost (pm/per-container-cost plan)]
         (html
          (if-not plan
-           [:div.loading-spinner common/spinner]
+           [:div.loading-spinner common/spinner] ;; TODO: fix; add plan

            [:div#edit-plan
+            (when (pm/piggieback? plan org-name)
+              (plans-piggieback-plan-notification plan org-name))
             [:fieldset
              [:legend
               "Our pricing is flexible and scales with you. Add as many containers as you want for $"
@@ -346,7 +401,7 @@
                 [:div.container-picker
                  [:p "More containers means faster builds and lower queue times."]
                  [:div.container-slider
-                  (let [min (+ (plan-model/freemium-containers plan) (plan-model/paid-plan-min-containers plan))
+                  (let [min (+ (pm/freemium-containers plan) (pm/paid-plan-min-containers plan))
                         max (if (< selected-containers 80)
                               80
                               (let [num (+ 80 selected-containers)]
@@ -362,10 +417,13 @@
                                                      :value (int (.. % -target -value)))}]
                      [:span max]))]
                  [:div
-                  [:span (if (= 0 new-total) "Free!" (str selected-containers " for $" new-total "/month"))]
+                  [:input {:type "text" :value selected-containers
+                           :on-change #(utils/edit-input owner state/selected-containers-path %
+                                                         :value (int (.. % -target -value)))}]
+                  [:span "containers for " (if (= 0 new-total) "Free!" (str "$" new-total "/month"))]
                   (when (not (= new-total old-total))
                     [:span.strikeout (str "$" old-total "/month")])
-                  (when (plan-model/grandfathered? plan)
+                  (when (pm/grandfathered? plan)
                     [:span.grandfather
                      "(grandfathered"
                      [:i.fa.fa-question-circle#grandfathered-tooltip-hack
@@ -373,7 +431,7 @@
                      ")"])]
                  ]
                 [:fieldset
-                 (if (plan-model/paid? plan)
+                 (if (pm/paid? plan)
                    (forms/managed-button
                     [:button.btn.btn-large.btn-primary.center
                      {:data-success-text "Saved",
@@ -391,55 +449,30 @@
                         :data-loading-text "Paying...",
                         :data-failed-text "Failed!",
                         :on-click #(raise! owner [:new-plan-clicked {:containers selected-containers
-                                                                     :paid {:template (:id plan-model/default-template-properties)}
+                                                                     :paid {:template (:id pm/default-template-properties)}
                                                                      :price new-total
                                                                      :description (str "$" new-total "/month, includes " (pluralize selected-containers "container"))}])}
-                       "Update plan"])))
-                 (when (< old-total new-total)
-                   [:span.help-block
-                    "We'll charge your card today, for the prorated difference between your new and old plans."])
-                 (when (> old-total new-total)
-                   [:span.help-block
-                    "We'll credit your account, for the prorated difference between your new and old plans."])]]]
+                       "Pay Now"])))
+                 (if (or (pm/paid? plan) (and (pm/freemium? plan) (not (pm/in-trial? plan))))
+                   (list
+                    (when (< old-total new-total)
+                      [:span.help-block
+                       "We'll charge your card today, for the prorated difference between your new and old plans."])
+                    (when (> old-total new-total)
+                      [:span.help-block
+                       "We'll credit your account, for the prorated difference between your new and old plans."]))
+                   (if (pm/in-trial? plan)
+                     [:span "Your trial will end in " (pluralize (Math/abs (pm/days-left-in-trial plan)) "day")
+                      ". Please pay for a plan by then or "
+                      (if (pm/freemium? plan)
+                        (str "you will revert to a free " (pluralize (pm/freemium-containers plan) "container") " plan.")
+                        "we will stop building your private repository pushes.")]
+                     [:span "Your trial of " (pluralize (pm/trial-containers plan) "container")
+                      " ended " (pluralize (Math/abs (pm/days-left-in-trial plan)) "day")
+                      " ago. Pay now to enable builds of private repositories."]))]]]
+
               [:div.right-section
-               [:div.plan
-                [:h2 "Your Current Plan" [:br] org-name]
-                (cond
-                 (plan-model/paid? plan)
-                 (list
-                   [:p [:strong "PAID"]]
-                   [:p [:strong (plan-model/usable-containers plan) " for $" old-total] "/ month"]
-                   [:ul
-                    (when (plan-model/freemium? plan)
-                      [:li "Includes " (pluralize (plan-model/freemium-containers plan) "container") " FREE!"])
-                    (if (> (plan-model/paid-plan-min-containers plan) 0)
-                      [:li (if (plan-model/freemium? plan) "Next " "First ")
-                       (pluralize (plan-model/paid-plan-min-containers plan) "container") " at $"
-                       (-> plan :paid :template :price)])
-                    [:li "Additional containers for $" (plan-model/per-container-cost plan) "/month"]
-                    [:li [:strong "No other limits"]]])
-
-                 (plan-model/freemium? plan)
-                 (if (plan-model/in-trial? plan)
-                   (list
-                    [:p [:strong "TRIAL"]]
-                    [:ul
-                     [:li "You are currently trialing a plan with " (pluralize (plan-model/usable-containers plan) "container") ". (freemium)"]])
-                   (list
-                     [:p [:strong "FREE"]]
-                     [:ul [:li "Includes " (pluralize (:containers plan) "container") " free!"]
-                      [:li "Additional containers for $" container-cost "/month"]
-                      [:li [:strong "No other limits"]]]))
-
-                 (plan-model/trial? plan)
-                 (if (plan-model/in-trial? plan)
-                   (list
-                     [:p [:strong "TRIAL"]]
-                     [:p "You are currently trialing a plan with " (pluralize (plan-model/usable-containers plan) "container") "."])
-                   (list
-                     [:p [:strong "TRIAL ENDED"]]
-                     [:p "Your trial of a plan with " (pluralize (plan-model/trial-containers plan) "container") " has ended. Please add containers to continue building private repositories."])))
-                ]]]]]))))))
+               (om/build current-plan-desc app)]]]]))))))

 (defn piggyback-organizations [app owner]
@@ -664,7 +697,7 @@
       (html
         (let [plan (get-in app state/org-plan-path)]
           [:div.row-fluid
-            (when (plan-model/has-active-discount? plan)
+            (when (pm/has-active-discount? plan)
               [:fieldset
                 [:legend.span8 "Discounts"]
                 [:div.span8 (format-discount plan)]])])))))
@@ -914,12 +947,12 @@
         subpage

         (and plan
-             (plan-model/can-edit-plan? plan org-name)
+             (pm/can-edit-plan? plan org-name)
              (= subpage :plan))
         :containers

         (and plan
-             (not (plan-model/can-edit-plan? plan org-name))
+             (not (pm/can-edit-plan? plan org-name))
              (#{:containers :organizations :billing :cancel} subpage))
         :plan


changed oss? to oss since thats what is returned from the api

--- src-cljs/frontend/models/project.cljs
+++ src-cljs/frontend/models/project.cljs
@@ -155,7 +155,7 @@

 (defn show-build-timing? [project plan]
   (or (config/enterprise?)
-      (:oss? project)
+      (:oss project)
       (> (:containers plan) 1)))

 (defn add-show-insights? [project plans]


fix type

fix type

--- src-cljs/cljs_workspace/om_test.cljs
+++ src-cljs/cljs_workspace/om_test.cljs
@@ -11,7 +11,7 @@
             [om-sync.util :refer [tx-tag edn-xhr]]
             [cljs-workspace.morph :as morphic :refer [set-fill toggle-halo find-morph-path]]
             [cljs-workspace.history :as history :refer [app-state init-history]]
-            [cljs-workspace.repl :as repl])
+            [cljs-workspace.repl :as repl]
             [cljs-workspace.branch-merge :as branch-merge])
   (:import [goog.events EventType]))


Using new CA library DNS alt. names function

--- src/clj/puppetlabs/master/certificate_authority.clj
+++ src/clj/puppetlabs/master/certificate_authority.clj
@@ -256,11 +256,8 @@
    master-certname :- schema/Str]
   (let [dns-alt-names (split-hostnames (:dns-alt-names settings))
         alt-names-ext (when-not (empty? dns-alt-names)
-                        ;; TODO: Create a list of OID def'ns in CA lib
-                        ;;       This is happening in PE-4373
-                        {:oid      "2.5.29.17"
-                         :critical false
-                         :value    {:dns-name (conj dns-alt-names master-certname)}})]
+                        (utils/subject-dns-alt-names
+                          (conj dns-alt-names master-certname) false))]
     (if alt-names-ext [alt-names-ext] [])))

 (schema/defn initialize-master!