Generalised to a group of animals

Generalised to a group of animals

--- src/cat_facts_v2/views/index.clj
+++ src/cat_facts_v2/views/index.clj
@@ -4,8 +4,27 @@
    [hiccup.core                :as hiccup]
    [hiccup.page                :as page]))

+(defn animal-specific
+  [part animal]
+  (let [animal (or animal :cat)]
+    {:name   {:sloth "sloth"
+              :cat "cat"
+              :mole-rate "naked mole-rat"}
+     :header {:sloth "Sloth Facts!"
+              :cat   "Cat Facts!"
+              :mole-rat "Naked Mole-Rat Facts!"}
+     :title  {:sloth "Stationary Strange Stats Starring Slow Stationary Strangers!"
+              :cat "Fascinating Facts Featuring Furry Feline Friends"
+              :mole-rat "Natty Noteworthy News Notarising Naughty Nude Nitwits"}
+     :more-header {:sloth "Not had enough of your furry funnies? Here are our top sloths"
+                   :cat "Not had enough of your purring pals to leave you catisfied? Here are our top cats for your purr-usal!"}
+     :goodbye     {:sloth "That's all for sloth facts today but stay tuned for more exciting facts about your favourite tree lovers!"
+                   :cat "That's all for cat facts today but stay tuned for more exciting facts about your favourite tuna lovers!"
+                   :mole-rat "That's all for naked mole-rat facts today, but stay tuned for more exciting facts about your favourite birthday-suited buddies!"}
+     }))
+
 (defn render
-  [{:keys [title recipient-name image-folder facts cats-of-the-day]}]
+  [{:keys [title recipient-name image-folder header facts animals-of-the-day animal]}]
   (hiccup/html (page/doctype :html5)
                [:html
                 [:head
@@ -15,12 +34,14 @@
                  [:div.whole {:style "width:100%; margin:auto;"}
                   [:div.container {:style "font-family: Tahoma, Arial, Geneva; sans-serif; font-size: 12px; color: #333;"}
                    [:div.content {:style "margin: auto;"}
-                    [:h1 {:style "color: #B74C11;"} "Sloth Facts!"]
-                    [:h2 (or title "Stationary Strange Stats Starring Slow Stationary Strangers!")]
-                    [:h3 {:style "color: #B74C11;"} (format "Aloha %s! Here are your daily sloth facts!" recipient-name)]
-                    [:p "We are your daily source of all things sloth. We have an exciting programme for you today, so stick around, it's time to learn us some sloths!"]
+                    [:h1 {:style "color: #B74C11;"} (animal-specific :header animal)]
+                    [:h2 (or title (animal-specific title animal))]
+                    [:h3 {:style "color: #B74C11;"} (format "Aloha %s! Here are your daily %s facts!" (animal-specific :name animal) recipient-name)]
+                    [:p (format "We are your daily source of all things %s. We have an exciting programme for you today, so stick around, it's time to learn us some %ss!" (animal-specific :name animal) (animal-specific :name animal))]
                     [:div.image {:style "width: auto;"}
-                     [:img {:style "max-width: 400px" :src (format "%s/images/header.jpg" config/app-base-url )}]]
+                     [:img {:style "max-width: 400px" :src (if header
+                                                             (format "%s/%s" config/app-base-url header)
+                                                             (format "%s/images/header.jpg" config/app-base-url))}]]
                     [:br]
                     [:ul {:style "color: #B74C11;"}
                      [:p {:style "font-size: 2em;"}]
@@ -30,12 +51,12 @@
                         [:p
                          [:img {:style "max-width: 335px;" :src (format "%s/images/%s/%s" config/app-base-url image-folder image-name)}]]])]
                     [:h3 {:style "color: #B74C11;"} "Sloths of the day"]
-                    [:p "Not had enough of your furry funnies? Here are our top sloths"]
+                    [:p (animal-specific :more-header animal)]
                     [:br]
-                    (for [[cat-caption image-name] cats-of-the-day]
+                    (for [[animal-caption image-name] cats-of-the-day]
                       [:span
                        [:p
                         [:img {:style "max-width: 335px;" :src (format "%s/images/%s/%s" config/app-base-url image-folder image-name)}]]
-                       [:p cat-caption]])
-                    [:h3 "Thats all for sloth facts today but stay tuned for more exciting facts about your favourite tree lovers!"]
+                       [:p animal-caption]])
+                    [:h3 (animal-specific :goodbye animal)]
                     [:img {:src (format "%s/images/dance.gif" config/app-base-url)}]]]]]]))


resolve #99 by making the timer lock completely independent from the submit lock. the timer releases the lock before calling the task function.

--- src/clj/backtype/storm/timer.clj
+++ src/clj/backtype/storm/timer.clj
@@ -28,8 +28,12 @@
                             (let [[time-secs _ _ :as elem] (.peek queue)]
                               (if elem
                                 (if (>= (current-time-secs) time-secs)
-                                  (locking lock
-                                    ((second (.poll queue))))
+                                  ;; can't hold the lock while executing the task function, or else
+                                  ;; deadlocks are possible (if the task function locks another lock
+                                  ;; and another thread locks that other lock before trying to schedule
+                                  ;; something on the timer)
+                                  (let [exec-fn (locking lock (second (.poll queue)))]
+                                    (exec-fn))
                                   (Time/sleepUntil (to-millis time-secs))
                                   )
                                 (Time/sleep 10000)


Added message key to game-update command

--- src/clj/funstructor/commands.clj
+++ src/clj/funstructor/commands.clj
@@ -48,7 +48,7 @@
         (gs/update-global-state #(apply gs/remove-from-pending % pending-pair))))
     (recur)))

-(defn make-update-data [game-state player-uuid]
+(defn make-player-update-data [game-state player-uuid]
   (let [player-state (f/get-player-state game-state player-uuid)
         opponent-uuid (f/get-opponent game-state player-uuid)]
     (-> (update-in player-state
@@ -59,17 +59,24 @@
         (assoc :enemy-cards-num (count (:cards (f/get-player-state game-state opponent-uuid))))
         (assoc :enemy-funstruct (:funstruct (f/get-player-state game-state opponent-uuid))))))

+(defn make-game-update-data [game]
+  (select-keys game [:messages]))
+
+(defn make-update-data [game player]
+  (merge (make-game-update-data game)
+         (make-player-update-data game player)))
+
 (defn send-game-updates [game-id]
-  (let [initialized-game (gs/get-game (gs/current-global-state) game-id)
-        [p1 p2 :as players] (f/get-game-players initialized-game)
+  (let [game (gs/get-game (gs/current-global-state) game-id)
+        [p1 p2 :as players] (f/get-game-players game)
         [c1 c2] (map #(gs/channel-for-player (gs/current-global-state) %) players)]
     (u/log "Sending game-update's for game " game-id)
     (send-command {:type :game-update
-                    :data (make-update-data initialized-game p1)
+                   :data (make-update-data game p1)
                     }
                    c1)
     (send-command {:type :game-update
-                    :data (make-update-data initialized-game p2)}
+                    :data (make-update-data game p2)}
                    c2)))


partial implementation of Jak Sinclair

partial implementation of Jak Sinclair

--- src/clj/game/cards-resources.clj
+++ src/clj/game/cards-resources.clj
@@ -257,6 +257,15 @@
    {:req (req (> (:bad-publicity corp) 0))
     :abilities [{:cost [:click 4] :msg "give the Corp 1 bad publicity"
                  :effect (effect (gain :corp :bad-publicity 1) (trash card {:cause :ability-cost}))}]}
+
+   "Jak Sinclair"
+   {:install-cost-bonus (req [:credit (* -1 (:link runner))])
+    :events {:runner-turn-begins
+              {:optional {:prompt "Use Jak Sinclair to make a run?"
+                          :yes-ability {:prompt "Choose a server"
+                                        :choices (req servers)
+                                        :msg (msg "make a run on " target " during which no programs can be used")
+                                        :effect (effect (run target))}}}}}

    "John Masanori"
    {:events {:successful-run {:req (req (first-event state side :successful-run))


clean up for readability

clean up for readability

--- src/clj_money/import/gnucash.clj
+++ src/clj_money/import/gnucash.clj
@@ -77,23 +77,19 @@

 (def ^:private ignored-accounts #{"Root Account" "Assets" "Liabilities" "Equity" "Income" "Expenses"})

-(defn- include-account?
-  [account]
-  (not (ignored-accounts (:name account))))
-
 (defmethod process-node :gnc:account
   [callback node]
-  (let [account (node->model node account-attributes)
-        account (-> account
-                    (with-meta {:record-type :account
-                                :ignore? (not (include-account? account))})
-                    (assoc :commodity {:exchange (when-let [exchange (:commodity-exchange account)]
-                                                   (-> exchange
-                                                       s/lower-case
-                                                       keyword))
-                                       :symbol (:commodity-symbol account)})
-                    (dissoc :commodity-exchange :commodity-symbol))]
-    (callback account)))
+  (let [account (node->model node account-attributes)]
+    (-> account
+        (assoc :commodity {:exchange (when-let [exchange (:commodity-exchange account)]
+                                       (-> exchange
+                                           s/lower-case
+                                           keyword))
+                           :symbol (:commodity-symbol account)})
+        (dissoc :commodity-exchange :commodity-symbol)
+        (with-meta {:record-type :account
+                    :ignore? (ignored-accounts (:name account))})
+        callback)))

 (def ^:private budget-attributes
   [{:attribute :id


robustify model helpers

robustify model helpers

--- src/clj_money/models/helpers.clj
+++ src/clj_money/models/helpers.clj
@@ -3,13 +3,17 @@
             [schema.core :as schema]
             [schema.coerce :as coerce]
             [schema.utils :as sutils]
+            [clj-money.models.storage]
             [clj-money.models.storage.sql-storage])
-  (:import clj_money.models.storage.sql_storage.SqlStorage))
+  (:import clj_money.models.storage.sql_storage.SqlStorage
+           clj_money.models.storage.Storage))

 ;; Storage
 ; TODO should this be dynamic to support extension?
 (def handlers
-  [{:can-handle-fn #(re-find #"\Apostgresql" %)
+  [{:can-handle-fn #(and
+                      (string? %)
+                      (re-find #"\Apostgresql" %))
     :create-fn #(SqlStorage. %)}])

 (defn- process-handler
@@ -27,8 +31,13 @@
   [config]
   (when (not config)
     (throw (RuntimeException.
-            "No configuration was specified. Unable to select a storage provider.")))
-  (some #(process-handler % config) handlers))
+             "No configuration was specified. Unable to select a storage provider.")))
+  (if (instance? Storage config)
+    config
+
+    (or (some #(process-handler % config) handlers)
+        (throw (RuntimeException.
+                 (format "Unable to find a storage provider for config %s" config))))))

 ;; Validation
 (defn- nil-matcher


Only show a warning on the hyphenation field if suggested is non-blank

--- src/cljs/hyphen_keeper/core.cljs
+++ src/cljs/hyphen_keeper/core.cljs
@@ -189,7 +189,7 @@

 (defn hyphenation-ui []
   (let [label "Corrected Hyphenation"
-        blank? (string/blank? @word)
+        blank? (or (string/blank? @word) (string/blank? @suggested-hyphenation))
         valid? (or blank? (hyphenation-valid? @hyphenation @word))
         same-as-suggested? (and (not blank?) (= @hyphenation @suggested-hyphenation))
         klass (cond


Don't set blank screen when restarting

Don't set blank screen when restarting

--- src/clojure/nightmod/screens.clj
+++ src/clojure/nightmod/screens.clj
@@ -70,7 +70,6 @@
 (defn restart!
   []
   (when @ui/tree-selection
-    (on-gl (set-screen! nightmod blank-screen overlay-screen))
     (reset! u/project-dir @u/project-dir)))

 (defn scrollify


minor content changes in `/about`

minor content changes in `/about`

--- src/whatsoup/web.clj
+++ src/whatsoup/web.clj
@@ -19,7 +19,8 @@
      [:body
       [:div#header
        [:div#app-icon
-        [:a {:href (or home-href "/about")} [:img {:src "/img/whatsoup.png" :alt "Whatsoup?"}]]]
+        [:a {:title "Hey you! Whatsoup?" :href (or home-href "/about")}
+         [:img {:src "/img/whatsoup.png" :alt "Whatsoup?"}]]]
        (into [] (concat [:h1] title))]
       [:hr]
       [:div#content content]]]))
@@ -124,12 +125,14 @@
        [:cite "Molière"]]
       [:p "Soup is delicious, quickly prepared, healthy and economic. Why don't we eat it more often then?
            There's only so many instant soup flavors, and " [:strong "we lack imagination."]]
-      [:p "This software aims to help with the latter. It randomly derives new soups from a set of base
+      [:p "This software aims to provide a solution for the latter: it randomly derives new soups from a set of base
            recipes and a food catalog, while considering how well certain foods fit together."]
       [:p "Try out some of the more exotic combinations that are generated – after all,
            the culinary arts are full of surprises. Maybe we can even convince you that computers are able
            to produce art ;-)"]
-      [:p "Whatsoup, made with love and " (loc-count) " lines of Clojure."]]]
+      [:p "Bon appétit!"]
+      [:p {:style "text-align: right; font-style: italic;"}
+       "Whatsoup, made with love (and " (loc-count) " lines of Clojure)."]]]
     "/"))

 (defn handle-404 []


CMR-755: Adding test from failed catalog rest integration test.

--- test/cmr/system_int_test/search/collection_spatial_search_test.clj
+++ test/cmr/system_int_test/search/collection_spatial_search_test.clj
@@ -24,6 +24,13 @@

 (use-fixtures :each (ingest/reset-fixture {"provguid1" "PROV1"}))

+(comment
+
+  (ingest/reset)
+  (ingest/create-provider "provguid1" "PROV1")
+
+  )
+
 (defn polygon
   "Creates a single ring polygon with the given ordinates. Points must be in counter clockwise order.
   The polygon will be closed automatically."
@@ -105,6 +112,8 @@
   (let [;; Lines
         normal-line (make-coll :geodetic "normal-line"
                                (l/ords->line-string :geodetic 22.681 -8.839, 18.309 -11.426, 22.705 -6.557))
+        along-am-line (make-coll :geodetic "along-am-line"
+                                 (l/ords->line-string :geodetic -180 0 -180 85))
         normal-line-cart (make-coll :cartesian "normal-line-cart"
                                     (l/ords->line-string :cartesian 16.439 -13.463,  31.904 -13.607, 31.958 -10.401))

@@ -170,10 +179,11 @@
                                                   polygon-with-holes-cart normal-line-cart
                                                   normal-line normal-poly-cart]
            ;; across antimeridian
-           [-167.85,-9.08,171.69,43.24] [whole-world across-am-br across-am-poly very-wide-cart]
+           [-167.85,-9.08,171.69,43.24] [whole-world across-am-br across-am-poly very-wide-cart
+                                         along-am-line]

            ;; across north pole
-           [0 85, 180 85] [whole-world north-pole on-np touches-np]
+           [0 85, 180 85] [whole-world north-pole on-np touches-np along-am-line]

            ;; across north pole where cartesian polygon touches it
            [-155 85, 25 85] [whole-world north-pole on-np very-tall-cart]
@@ -267,7 +277,8 @@
                             polygon-with-holes-cart]

            ;; crosses am
-           [166.11,53.04,-166.52,-19.14] [whole-world across-am-poly across-am-br am-point very-wide-cart]
+           [166.11,53.04,-166.52,-19.14] [whole-world across-am-poly across-am-br am-point
+                                          very-wide-cart along-am-line]

            ;; Matches geodetic line
            [17.67,-4,25.56,-6.94] [whole-world normal-line]
@@ -280,7 +291,8 @@
                               wide-north wide-south across-am-poly on-sp on-np normal-poly
                               polygon-with-holes north-pole south-pole normal-point am-point
                               very-wide-cart very-tall-cart wide-north-cart wide-south-cart
-                              normal-poly-cart polygon-with-holes-cart normal-line normal-line-cart]))
+                              normal-poly-cart polygon-with-holes-cart normal-line normal-line-cart
+                              along-am-line]))

     (testing "polygon searches"
       (are [ords items]
@@ -303,7 +315,7 @@

            ;; around north pole
            [58.41,76.95,163.98,80.56,-122.99,81.94,-26.18,82.82,58.41,76.95]
-           [whole-world on-np touches-np north-pole very-tall-cart]
+           [whole-world on-np touches-np north-pole very-tall-cart along-am-line]

            ;; around south pole
            [-161.53,-69.93,25.43,-51.08,13.89,-39.94,-2.02,-40.67,-161.53,-69.93]
@@ -311,7 +323,7 @@

            ;; Across antimeridian
            [-163.9,49.6,171.51,53.82,166.96,-11.32,-168.36,-14.86,-163.9,49.6]
-           [whole-world across-am-poly across-am-br am-point very-wide-cart]
+           [whole-world across-am-poly across-am-br am-point very-wide-cart along-am-line]

            [-2.212 -12.44, 0.103 -15.911, 2.185 -11.161 -2.212 -12.44]
            [whole-world normal-poly-cart polygon-with-holes-cart]
@@ -371,9 +383,18 @@
            [whole-world normal-poly normal-brs polygon-with-holes normal-line normal-line-cart]

            :box [23.59,-4,25.56,-15.47] [whole-world normal-line-cart]
+
+           ;; Across antimeridian
+           :box [170 20 -170 10]
+           [whole-world across-am-br along-am-line]
+
+           :box [166.11,53.04,-166.52,-19.14]
+           [whole-world across-am-poly across-am-br am-point very-wide-cart along-am-line]
+
            :point [17.73 2.21] [whole-world normal-brs]
            :line [-0.37,-14.07,4.75,1.27,25.13,-15.51]
            [whole-world polygon-with-holes polygon-with-holes-cart normal-line-cart normal-line
             normal-poly-cart]))))

+


(SERVER-1096) Re-enable HUP test now that we have TK HUP

--- test/integration/puppetlabs/services/jruby/jruby_pool_int_test.clj
+++ test/integration/puppetlabs/services/jruby/jruby_pool_int_test.clj
@@ -26,7 +26,8 @@
             [puppetlabs.kitchensink.testutils :as ks-testutils]
             [puppetlabs.puppetserver.testutils :as testutils :refer
              [ca-cert localhost-cert localhost-key ssl-request-options]]
-            [puppetlabs.trapperkeeper.testutils.logging :as logging]))
+            [puppetlabs.trapperkeeper.testutils.logging :as logging]
+            [puppetlabs.trapperkeeper.bootstrap :as tk-bootstrap]))

 (def test-resources-dir
   "./dev-resources/puppetlabs/services/jruby/jruby_pool_int_test")
@@ -285,7 +286,7 @@
 (defprotocol BonusService
   (bonus-service-fn [this]))

-#_(deftest ^:integration test-restart-comes-back
+(deftest ^:integration test-restart-comes-back
   (testing "After a TK restart puppetserver can still handle requests"
     (let [call-seq (atom [])
           lc-fn (fn [context action] (swap! call-seq conj action) context)
@@ -306,7 +307,7 @@
            (Thread/yield)))
        (is (= @call-seq [:init-bonus-service :start-bonus-service :stop-bonus-service :init-bonus-service :start-bonus-service]))
        (let [get-results (http-client/get "https://localhost:8140/puppet/v3/environments"
-                                          bootstrap/catalog-request-options)]
+                                          testutils/catalog-request-options)]
          (is (= 200 (:status get-results))))))))

 (deftest ^:integration test-503-when-app-shuts-down


(SERVER-1096) Update disabled HUP test to use restart-tk-apps

Because jenkins clients swallow HUP signals, this commit updates the HUP
test in puppet-server to call the restart-tk-apps function directly, as
the HUP would have triggered.

--- test/integration/puppetlabs/services/jruby/jruby_pool_int_test.clj
+++ test/integration/puppetlabs/services/jruby/jruby_pool_int_test.clj
@@ -296,8 +296,8 @@
 (defprotocol BonusService
   (bonus-service-fn [this]))

-#_(deftest ^:integration test-hup-comes-back
-  (testing "After a HUP signal puppetserver can still handle requests"
+#_(deftest ^:integration test-restart-comes-back
+  (testing "After a TK restart puppetserver can still handle requests"
     (let [call-seq (atom [])
           lc-fn (fn [context action] (swap! call-seq conj action) context)
           bonus-service (tk-services/service BonusService
@@ -310,8 +310,7 @@
        app
        (conj (tk-bootstrap/parse-bootstrap-config! bootstrap/dev-bootstrap-file) bonus-service)
        {:jruby-puppet {:max-active-instances 1}}
-       (tk-internal/register-sighup-handler [app])
-       (beckon/raise! "HUP")
+       (tk-internal/restart-tk-apps [app])
        (let [start (System/currentTimeMillis)]
          (while (and (not= (count @call-seq) 5)
                      (< (- (System/currentTimeMillis) start) 90000))


Extending NodeStreaming to String won't work, because it's unclear about whether or when the string must be encoded

--- src/main/clojure/cascade/dom.clj
+++ src/main/clojure/cascade/dom.clj
@@ -117,8 +117,6 @@
           (write out ">")
           (stream-nodes content strategy out)
           (write out "</" element-name ">"))))))
-
-; TODO: possibly don't need Text, instead extend NodeStreaming to String

 (defrecord Text [text]


Fix inbox-inbox-height with visible footer.

--- src-cljs/pepa/style.cljs
+++ src-cljs/pepa/style.cljs
@@ -243,23 +243,23 @@

 (def page-css
   [:.thumbnail {:position :relative}
-   (let [rotate-height 25]
+   (let [rotate-height 24]
      [:.rotate {:position :absolute
                 :top 0, :right 0
                 :height (px rotate-height)
                 :z-index 500
                 :background-color "rgba(255, 255, 255, 0.8)"
-                :margin (px 5)}
-      [:.left :.flip :.right (list
-                              {:float :right
-                               :width (px rotate-height)
-                               :height (px rotate-height)
-                               :line-height (px rotate-height)
-                               :text-align :center
-                               :background-size "100%"
-                               :cursor :pointer
-                               :opacity 0.3}
-                              ^:prefix {:user-select :none})
+                :margin (px 5)
+                :border-radius (px 4)}
+      [:.left :.right (list
+                       {:float :right
+                        :width (px rotate-height)
+                        :height (px rotate-height)
+                        :line-height (px rotate-height)
+                        :text-align :center
+                        :cursor :pointer
+                        :opacity 0.3}
+                       ^:prefix {:user-select :none})
        ;; Give buttons full opacity when hovered
        [:&:hover {:opacity 1}]
        [:&.right {:background-image (image-url "material/page-rotate-right.svg")}]
@@ -364,6 +364,9 @@
                                         ["100%"
                                          - margin-top
                                          - footer-height])
+       [:&.inbox (calc-property :height ["100%"
+                                         - header-height
+                                         - footer-height])]
        [:footer {:position :absolute
                  :height (px footer-height)
                  :width "100%"
@@ -372,8 +375,7 @@
                  :display :initial}
         [:button (list
                   {:position :relative
-                   :left "50%", :top "50%"
-                   }
+                   :left "50%", :top "50%"}
                   ^:prefix {:transform "translate(-50%,-50%)"})]]]])
    ;; The drop-area to create new documents
    [:td.create-document {:min-width (px document-width)


Add monad transformer with channel tests for clojurescript.

--- test/cats/monad/channel_spec.cljx
+++ test/cats/monad/channel_spec.cljx
@@ -121,7 +121,6 @@
         (t/is (= (<! rs1) (<! rs2)))
         (done)))))

-#+clj
 (def chaneither-m (either/either-transformer c/channel-monad))

 #+clj
@@ -144,4 +143,25 @@
       (t/is (= (either/left :foo) (<!! r2)))))
   )

+#+cljs
+(t/deftest channel-transformer-tests
+  (t/async done
+    (let [funcright #(c/with-value (either/right %))
+          funcleft #(c/with-value (either/left %))
+          r1 (m/with-monad chaneither-m
+               (m/mlet [x (funcright 1)
+                        y (funcright 2)]
+                 (m/return (+ x y))))

+          r2 (m/with-monad chaneither-m
+               (m/mlet [x (funcright 1)
+                        y (funcleft :foo)
+                        z (funcright 2)]
+                 (m/return (+ x y))))]
+      (go
+        (t/is (= (either/right 3) (<! r1)))
+        (t/is (= (either/left :foo) (<! r2)))
+        (done))))
+  )
+
+


Pass all tests

Pass all tests

--- test/clojure_fabric/core_test.clj
+++ test/clojure_fabric/core_test.clj
@@ -178,33 +178,35 @@
           (core/get-peers mychannel)))

 ;; This must be available with Admin user
-(expect [io.grpc.StatusRuntimeException]
+(expect io.grpc.StatusRuntimeException
         (let [user (get-user "Org1MSP" "user1") ;; user == error!
               mychannel (get-channel user "mychannel")]
           (mapv type (query-installed-chaincodes user (get-random-peer mychannel)))))

-(expect [[]]
+(expect true
         (let [user (get-user "Org1MSP" "admin")
-              mychannel (get-channel user "mychannel")]
-          (query-installed-chaincodes user (get-random-peer mychannel))))
-
-(expect [[]]
-        (let [user (get-user "Org1MSP" "admin")
-              mychannel (get-channel user "mychannel")]
-          (install-chaincode user "test1" "github.com/example_cc" "v1"
+              mychannel (get-channel user "mychannel")
+              chaincodes1 (query-installed-chaincodes user (get-random-peer mychannel))]
+          (install-chaincode user (str "test" (System/currentTimeMillis)) "github.com/example_cc" "v1"
                              "/home/jc/Work/clojure-fabric/resources/gocc/src/github.com"
-                             :golang (core/get-peers mychannel))))
-
-
-(expect [io.grpc.StatusRuntimeException]
+                             :golang (core/get-peers mychannel))
+          (= (inc (count chaincodes1))
+             (count (query-installed-chaincodes user (get-random-peer mychannel))))))
+
+(expect io.grpc.StatusRuntimeException
         (let [user (get-user "Org2MSP" "user1") ;; user == error!
               mychannel (get-channel user "mychannel")]
           (mapv type (query-installed-chaincodes user (get-random-peer mychannel)))))

-(expect [[]]
+(expect true
         (let [user (get-user "Org2MSP" "admin")
-              mychannel (get-channel user "mychannel")]
-          (query-installed-chaincodes user (get-random-peer mychannel))))
+              mychannel (get-channel user "mychannel")
+              chaincodes1 (query-installed-chaincodes user (get-random-peer mychannel))]
+          (install-chaincode user (str "test" (System/currentTimeMillis)) "github.com/example_cc" "v1"
+                             "/home/jc/Work/clojure-fabric/resources/gocc/src/github.com"
+                             :golang (core/get-peers mychannel))
+          (= (inc (count chaincodes1))
+             (count (query-installed-chaincodes user (get-random-peer mychannel))))))

 ;; (expect (let [user (get-user "Org2MSP" "admin")
 ;;               mychannel (get-channel user "mychannel")]


we now use the discussion forum idea for stopping

--- src/crawler/discussion_forum.clj
+++ src/crawler/discussion_forum.clj
@@ -49,7 +49,21 @@
   [x num-leaves]
   (let [estimated-model (estimate-model x)]
     (pprint estimated-model)
-    (>= (:visited x) num-leaves)))
+    (pprint
+     [:estimate
+      (map
+       (fn [l]
+         (corpus/estimate-yield l
+                                (:pagination estimated-model)
+                                (:corpus x)))
+       (:actions estimated-model))
+
+      :expected
+      (map
+       (fn [l]
+         (* (Math/pow 5 (count l)) 10))
+       (:actions estimated-model))])
+    (>= (:observed x) num-leaves)))

 (defn leaf?
   [model url-ds]


docstring have to be placed before arglist in defn

Signed-off-by: yenda <96f164ad4d9b2b0dacf8ebee2bb1eeb3aa69adf1@status.im>

--- src/status_im/utils/ethereum/stickers.cljs
+++ src/status_im/utils/ethereum/stickers.cljs
@@ -7,28 +7,32 @@
    :testnet "0x39d16CdB56b5a6a89e1A397A13Fe48034694316E"
    :rinkeby nil})

-(defn pack-count [web3 contract cb]
+(defn pack-count
   "Returns number of packs rigestered in the contract"
+  [web3 contract cb]
   (ethereum/call web3
                  (ethereum/call-params contract "packCount()")
                  (fn [_ count] (cb (ethereum/hex->int count)))))

-(defn pack-data [web3 contract pack-id cb]
+(defn pack-data
   "Returns vector of pack data parameters by pack id: [category owner mintable timestamp price contenthash]"
+  [web3 contract pack-id cb]
   (ethereum/call web3
                  (ethereum/call-params contract "getPackData(uint256)" (ethereum/int->hex pack-id))
                  (fn [_ data]
                    (cb (when data (abi-spec/decode (subs data 2) ["bytes4[]" "address" "bool" "uint256" "uint256" "bytes"]))))))

-(defn owned-tokens [web3 contract address cb]
+(defn owned-tokens
   "Returns vector of owned tokens ids in the contract by address"
+  [web3 contract address cb]
   (ethereum/call web3
                  (ethereum/call-params contract "tokensOwnedBy(address)" (ethereum/normalized-address address))
                  (fn [_ data]
                    (cb (when data (first (abi-spec/decode (subs data 2) ["uint256[]"])))))))

-(defn token-pack-id [web3 contract token cb]
+(defn token-pack-id
   "Returns pack id in the contract by token id"
+  [web3 contract token cb]
   (ethereum/call web3
                  (ethereum/call-params contract "tokenPackId(uint256)" (ethereum/int->hex token))
-                 (fn [_ data] (cb (ethereum/hex->int data)))))+                 (fn [_ data] (cb (ethereum/hex->int data)))))


fundamental.clj: factored out a piece of common code.

--- clojure/org/gavrog/clojure/fundamental.clj
+++ clojure/org/gavrog/clojure/fundamental.clj
@@ -4,25 +4,10 @@
 (defn- other [a b c]
   (if (= c a) b a))

-(defn- initial-todo [ds]
-  (first
-    (reduce (fn [[result seen] [D i E]]
-              [(if (or (= :root i) (seen E)) result (conj result [D i nil]))
-               (conj seen E)])
-            [[] #{}]
-            (traversal ds (indices ds) (elements ds)))))
-
 (defn- update-todo [ds todo opposite D i]
   (into todo (for [j (indices ds) :when (not= i j)]
                (let [[E k _] (opposite [D i j])]
                  [E k (other i j k)]))))
-
-(defn- initial-boundary [ds]
-  [(set (for [D (elements ds), i (indices ds)] [D i]))
-   (into {} (for [D (elements ds)
-                  i (indices ds)
-                  j (indices ds) :when (not= i j)]
-              [[D i j] [D j 1]]))])

 (defn- glue-boundary [ds [on-bnd opposite] D i]
   (let [E (s ds i D)]
@@ -35,13 +20,12 @@
                              [[[D* r (other i j r)] [E* s n]]
                               [[E* s (other i j s)] [D* r n]]]))))]))

-(defn inner-edges [ds]
-  "Returns the list of inner edges for a fundamental domain."
-  (loop [todo (initial-todo ds)
-         [on-bnd opposite :as boundary] (initial-boundary ds)
-         result []]
+(defn- glue-recursively [ds boundary edges]
+  (loop [todo edges
+         [on-bnd opposite :as boundary] boundary
+         glued []]
     (if (empty? todo)
-      result
+      [boundary glued]
       (let [[D i j] (first todo)
             [_ _ n] (opposite [D i j])
             todo (rest todo)]
@@ -50,31 +34,40 @@
                      (= n (* 2 (m ds i j D)))))
           (recur (update-todo ds todo opposite D i)
                  (glue-boundary ds boundary D i)
-                 (conj result [D i]))
-          (recur todo boundary result))))))
+                 (conj glued [D i]))
+          (recur todo boundary glued))))))
+
+(defn- initial-todo [ds]
+  (first
+    (reduce (fn [[result seen] [D i E]]
+              [(if (or (= :root i) (seen E)) result (conj result [D i nil]))
+               (conj seen E)])
+            [[] #{}]
+            (traversal ds (indices ds) (elements ds)))))
+
+(defn- initial-boundary [ds]
+  [(set (for [D (elements ds), i (indices ds)] [D i]))
+   (into {} (for [D (elements ds)
+                  i (indices ds)
+                  j (indices ds) :when (not= i j)]
+              [[D i j] [D j 1]]))])
+
+(defn inner-edges [ds]
+  "Returns the list of inner edges for a fundamental domain."
+  (second (glue-recursively ds (initial-boundary ds) (initial-todo ds))))

 (defn- trace-word [ds edge2word D i]
   )

 (defn- glue-generator [ds [_ opposite :as boundary] edge2word gen2edge D i]
   (let [gen (count gen2edge)
-        gen2edge (conj gen2edge [gen [D i]])]
-    (loop [todo (update-todo ds '() opposite D i)
-           [on-bnd opposite :as boundary] (glue-boundary ds boundary D i)
-           edge2word (conj edge2word [[D i] [gen]])]
-      (if (empty? todo)
-        [boundary edge2word gen2edge]
-        (let [[D i j] (first todo)
-              [_ _ n] (opposite [D i j])
-              todo (rest todo)]
-          (if (and (on-bnd [D i])
-                   (or (nil? j)
-                       (= n (* 2 (m ds i j D)))))
-            (recur (update-todo ds todo opposite D i)
-                   (glue-boundary ds boundary D i)
-                   (conj edge2word
-                         [[D i] (inverse (trace-word ds edge2word D i))]))
-            (recur todo boundary edge2word)))))))
+        gen2edge (conj gen2edge [gen [D i]])
+        [boundary glued] (glue-recursively ds boundary [[D i nil]])
+        edge2word (reduce (fn [e2w [D i]]
+                            (conj e2w (inverse (trace-word ds e2w D i))))
+                          (conj edge2word [[D i] [gen]])
+                          (rest glued))]
+    [boundary edge2word gen2edge]))

 (defn- find-generators [ds]
   (let [boundary (reduce (fn [bnd [D i]] (glue-boundary ds bnd D i))


Use :import.

Use :import.

--- src-cljs/frontend/utils/ajax.cljs
+++ src-cljs/frontend/utils/ajax.cljs
@@ -4,7 +4,8 @@
             [cljs-time.core :as time]
             [clojure.string :as str]
             [frontend.async :refer [put!]]
-            [frontend.utils :as utils :include-macros true]))
+            [frontend.utils :as utils :include-macros true])
+  (:import [goog.net Jsonp] [goog Uri]))

 ;; https://github.com/JulianBirch/cljs-ajax/blob/master/src/ajax/core.cljs
 ;; copy of the default json formatter, but returns a map with json body
@@ -123,8 +124,8 @@
   a relative URL (which will be resolved relative to the document's URL, and
   should therefore have the same origin)."
   [url]
-  (let [document-uri (js/goog.Uri.parse (.-href js/document.location))
-        other-uri (js/goog.Uri.parse url)
+  (let [document-uri (Uri. (.-href js/document.location))
+        other-uri (Uri. url)
         resolved-other-uri (.resolve document-uri other-uri)]
     (.hasSameDomainAs resolved-other-uri document-uri)))


Temporary fix for lack of timer trigger fires.

--- src/onyx/peer/task_lifecycle.clj
+++ src/onyx/peer/task_lifecycle.clj
@@ -324,14 +324,18 @@
 ;   (Thread/sleep (arg-or-default :onyx.peer/drained-back-off (:peer-opts event))))

 (defn assign-windows [state]
-  (advance (ws/assign-windows state :new-segment)))
+  (advance (ws/assign-windows state
+                              (if (empty? (mapcat :leaves
+                                                  (:tree
+                                                   (:onyx.core/results
+                                                    (get-event state)))))
+                                :task-iteration
+                                :new-segment))))

 (defn build-lifecycle-invoke-fn [event lifecycle-kw]
   (if-let [f (lc/compile-lifecycle-functions event lifecycle-kw)]
     (fn [state]
       (advance (update-event! state f)))))
-
-

 (defn recover-input [state]
   (let [{:keys [recover-coordinates recovered?] :as context} (get-context state)


Remove unused :description from company copy.

--- src/open_company/resources/stakeholder_update.clj
+++ src/open_company/resources/stakeholder_update.clj
@@ -51,7 +51,7 @@
   (-> su-props
     (assoc :slug (slug-for title))
     (assoc :company-slug (:slug company))
-    (merge (select-keys company [:name :description :logo :logo-width :logo-height])) ; freeze some props of company
+    (merge (select-keys company [:name :logo :logo-width :logo-height])) ; freeze some props of company
     (update :title #(or % ""))
     (assoc :author (common/author-for-user user))
     (assoc :created-at timestamp)


some adj to example

some adj to example

--- examples/ex05_particles.clj
+++ examples/ex05_particles.clj
@@ -27,7 +27,7 @@

 (defn move-particle
   ""
-  [^Vec2 vrand fun noise canvas ^Vec2 in ]
+  [^Vec2 vrand line? fun noise canvas ^Vec2 in]
   (let [xx (m/norm (.x in) 0 width -2 2)
         yy (m/norm (.y in) 0 height -2 2)
         ^Vec2 vr (v/add vrand (Vec2. xx yy))
@@ -40,8 +40,10 @@
     (if (and (<= 80 ny (- height 81)) (<= 80 nx (- width 81)))
       (do
         (set-color canvas col col col alpha)
-        ;; (line (.x in) (.y in) nx ny)
-        (point canvas nx ny)
+
+        (if line?
+          (line canvas (.x in) (.y in) nx ny)
+          (point canvas nx ny))

         (Vec2. nx ny))
       (make-particle))))
@@ -54,7 +56,7 @@
         variation1 (rand-nth variation-list-not-random)
         variation2 (rand-nth variation-list-not-random)
         vrand (Vec2. (r/drand -1 1) (r/drand -1 1))
-        mv-fun (partial move-particle vrand (comp (make-variation variation2 1.0 {}) (make-variation variation1 1.0 {})) noise)
+        mv-fun (partial move-particle vrand (r/brand) (comp (make-variation variation2 1.0 {}) (make-variation variation1 1.0 {})) noise)
         particles (vec (repeatedly 25000 make-particle))
         looper (fn [canvas] (loop [xs particles]
                               (if @running


fixed source code urls

fixed source code urls

--- src/ganelon/test/pages/index.clj
+++ src/ganelon/test/pages/index.clj
@@ -59,8 +59,8 @@
       "Microframework bringing instant development of AJAX-enabled web applications to Clojure/Ring."
       [:div {:style "text-align: center"}
         [:div
-         [:a.btn.btn-large.btn-primary {:style "margin-right: 10px"} [:i.icon-github] " Browse the source codes"]
-         [:a.btn.btn-large.btn-primary {:style "margin-left: 10px"} [:i.icon-star] " Star on GitHub"]
+         [:a.btn.btn-large.btn-primary {:href "https://github.com/tlipski/ganelon" :style "margin-right: 10px"} [:i.icon-github] " Browse the source codes"]
+         [:a.btn.btn-large.btn-primary {:href "https://github.com/tlipski/ganelon/star":style "margin-left: 10px"} [:i.icon-star] " Star on GitHub"]
          ]]
       )
     [:div {:class "container" :style "padding-top: 30px;"}
@@ -112,7 +112,7 @@
         [:a {:href "https://mydailysocial.info" :target "_blank"} "Daily Social"] "."]
        [:p "If you are using Ganelon, " "tell me about it!"]
        [:p "This demo site is of course powered by Ganelon as well. " [:br]
-        [:a {:href "http://github.com/tlipski/ganelon/demo" :target "_blank"} "View source"]]
+        [:a {:href "http://github.com/tlipski/ganelon-demo" :target "_blank"} "View source"]]
        ]]
      [:div {:class "row"}
       [:div {:class "span6"}


Handle restriction & projection of genes.

--- src/cavm/h2.clj
+++ src/cavm/h2.clj
@@ -1005,7 +1005,10 @@

 ;
 ;
-;
+; Methods for providing a sql abstraction over the column store.
+;
+;
+

 (def ^:private field-ids-query
   (cached-statement
@@ -1093,10 +1096,17 @@
         (update-in new-cache [:codes] update-codes-cache field-id missing new-cache))
        cache)))

+(defmulti fetch-rows
+  (fn [cache rows field-id]
+    (cond
+      (has-genes? field-id) :gene
+      (has-position? field-id) :position
+      :else :binned)))
+
 ; return fn of rows->vals
-(defn fetch-rows [fields cache rows field]
-  (swap! cache update-in [field] update-cache (fields field) rows)
-  (let [f (@cache field)
+(defmethod fetch-rows :binned [cache rows field-id]
+  (swap! cache update-in [field-id] update-cache field-id rows)
+  (let [f (@cache field-id)
         getter (match [(:codes f)]
                       ; XXX cast to int here is pretty horrible.
                       ; Really calls for an int array bin in h2.
@@ -1106,6 +1116,34 @@
     (fn [row]
       (apply getter (bin-offset row)))))

+(def ^:private field-genes-by-row-query
+  (cached-statement
+    "SELECT `row`, `gene` FROM `field_gene`
+    INNER JOIN TABLE(x VARCHAR = (?)) X ON X.x = `row`
+    WHERE `field_id` = ?"
+    true))
+
+(defn field-genes-by-row [field-id rows]
+  (->> (field-genes-by-row-query rows field-id)
+      (map (juxt :row :gene))))
+
+(defmethod fetch-rows :gene [cache rows field-id]
+  (into {} (field-genes-by-row field-id rows)))
+
+(def ^:private field-position-by-row-query
+  (cached-statement
+    "SELECT `row`, `chrom`, `chromStart`, `chromEnd` FROM `field_position`
+    INNER JOIN TABLE(x VARCHAR = (?)) X ON X.x = `row`
+    WHERE `field_id` = ?"
+    true))
+
+(defn field-position-by-row [field-id rows]
+  (->> (field-position-by-row-query rows field-id)
+      (map (fn [{:keys [row] :as values}] [row (dissoc values :row)]))))
+
+(defmethod fetch-rows :position [cache rows field-id]
+  (into {} (field-position-by-row field-id rows)))
+
 ; might want to use a reader literal for field names, so we
 ; find them w/o knowing syntax.
 (defn collect-fields [exp]
@@ -1132,24 +1170,45 @@
       (map :row)))

 (defn fetch-genes [field-id values]
-  (into #{} (field-genes field-id values)))
+  (into (sorted-set) (field-genes field-id values)))
+
+; fetch-indexed doesn't cache, and it's unclear
+; if we should cache the indexed fields during 'restrict'.
+; h2 also has caches, so it might be better to rely on them,
+; simply doing the query again if we need it.
+
+; Otherwise, we might want to inform the cache of what columns are
+; required later during 'restrict', or in 'project', so
+; we know if they should be cached.

 (defn fetch-indexed [fields field values]
   (let [field-id (fields field)]
     (cond
-      (has-position? field-id) #{})
+      (has-position? field-id) #{}) ; XXX fix this!
       (has-genes? field-id) (fetch-genes field-id values)))

+; XXX Look at memory use of pulling :gene field. If it's not
+; interned, it could be expensive.
+
+; XXX Add some param guards, esp. unknown field.
 (defn eval-sql [{[from] :from where :where select :select :as exp}]
   (let [{dataset-id :id N :rows} (dataset-by-name from :id :rows)
         fields (into {} (fetch-field-ids dataset-id
                                          (into (collect-fields where) select)))
-        fetch (partial fetch-rows fields (atom {}))]
+        cache (atom {})
+        fetch (fn [rows field] (fetch-rows cache rows (fields field)))]
     ; XXX project, perhaps in sqleval
-  (evaluate (range N) {:fetch fetch
+  (evaluate (apply sorted-set (range N)) {:fetch fetch
                        :fetch-indexed (partial fetch-indexed fields)
                        :indexed? (partial has-index? fields)} exp)))

+
+;
+;
+;
+;
+;
+;

 ; Each req is a map of
 ;  :table "tablename"


remove commented out code

remove commented out code

--- src/ccm_clj.clj
+++ src/ccm_clj.clj
@@ -134,12 +134,4 @@
     (start! name)
     (switch! name)))

-;(defn launch!
-;  "Launch the default terminal with cqlsh running against the specified node or 'node1'"
-;  ([]
-;   (launch! "node1"))
-;  ([node]
-;   (shell/sh "open" "--args" "zsh" "-c" "ccm" node "cqlsh")))

-
-


Remove unused require.

Remove unused require.

--- src/app/clj/one/sample/config.clj
+++ src/app/clj/one/sample/config.clj
@@ -2,8 +2,7 @@
   "This namespace contains the configuration for a ClojureScript One
   application."
   (:use [one.reload :only [dependency clojure-reloads clojurescript-reloads watched-directory shared]])
-  (:require [net.cgrand.enlive-html :as html]
-            [one.reload :as reload]))
+  (:require [net.cgrand.enlive-html :as html]))

 ;; Set the location where all generated JavaScript will be stored.


Remove unused CLJ code from a CLJS source file

--- src/main/audio_recorder/rms.cljs
+++ src/main/audio_recorder/rms.cljs
@@ -43,8 +43,7 @@
     (if (empty? samples)
       0
       (let [sum-by-n (/ squared-sum (count samples))]
-        #?(:clj  (Math/sqrt    sum-by-n)
-           :cljs (js/Math.sqrt sum-by-n))))))
+        (js/Math.sqrt sum-by-n)))))

 (defn rms-buffer


Fix seq case for BitmapIndexedNode of all nodes

--- src/main/cljs/lean_map/core.cljs
+++ src/main/cljs/lean_map/core.cljs
@@ -75,7 +75,9 @@
                 (BitmapIndexedNode. medit new-datamap 0 (array key2 val2 key1 val1)))))))))

   (inode-seq [inode]
-    (NodeSeq. nil arr (dec (* 2 (bit-count datamap))) (dec (alength arr)) 0 nil nil))
+    (if (zero? datamap)
+      (NodeSeq. nil arr -1 (dec (alength arr)) 0 (.inode-seq (aget arr (dec (alength arr)))) nil)
+      (NodeSeq. nil arr (dec (* 2 (bit-count datamap))) (dec (alength arr)) 0 nil nil)))

   (inode-assoc [inode aedit shift hash key val changed?]
     (let [bit (bitpos hash shift)]


Add filter to compiler

Add filter to compiler

--- src/aurora/language.cljs
+++ src/aurora/language.cljs
@@ -171,7 +171,7 @@
     ;; rewrite clauses
     (doseq [[rule-id clauses] @rule-id->clauses]
       (doseq [[_ clause-type clause-id name] clauses
-              :when (not (#{"=constant" "=variable" "=function"} name))]
+              :when (not (#{"=constant" "=variable" "=function" "filter"} name))]
         (let [fields (get @clause-id->fields clause-id)
               var->key (atom {})]
           (doseq [[_ field-type key val] fields]
@@ -243,6 +243,15 @@
                                                        arg-ixes (map var->ix args)
                                                        fun (apply js/Function (conj (vec args) (str "return (" js ");")))]
                                                    (btree/function fun result-ix (into-array arg-ixes)))
+                                     "filter" (let [js (first (for [[_ field-type key val] fields
+                                                                    :when (= key "js")]
+                                                                val))
+                                                    args (for [var @vars
+                                                               :when (>= (.indexOf js var) 0)]
+                                                           var)
+                                                    arg-ixes (map var->ix args)
+                                                    fun (apply js/Function (conj (vec args) (str "return (" js ");")))]
+                                                (btree/filter fun (into-array arg-ixes)))
                                      (let [clause-vars&keys (sort-by (fn [[val key]] (var->ix val))
                                                                      (for [[_ field-type key val] fields]
                                                                        [val key]))
@@ -332,11 +341,13 @@
                                                                                #js ["output-transitive-connected" "variable" "y" "zz"]])

 (.add-facts kn "know" "clauses" #js ["rule-id" "when|know|remember|forget" "clause-id" "name"] #js [#js ["function-edge" "when" "get-function-edge" "connected"]
+                                                                                #js ["function-edge" "when" "filter-edge" "filter"]
                                                                                #js ["function-edge" "when" "make-str" "=function"]
                                                                                #js ["function-edge" "remember" "know-str" "str-edge"]])

 (.add-facts kn "know" "clause-fields" #js ["clause-id" "constant|variable" "key" "val"] #js [#js ["get-function-edge" "variable" "x" "xx"]
                                                                                #js ["get-function-edge" "variable" "y" "yy"]
+                                                                                #js ["filter-edge" "constant" "js" "xx == \"a\""]
                                                                                #js ["make-str" "variable" "variable" "zz"]
                                                                                #js ["make-str" "constant" "js" "\"edge \" + xx + \" \" + yy"]
                                                                                #js ["know-str" "variable" "name" "zz"]])


Overlap adjustment.

Overlap adjustment.

--- src/clojush.clj
+++ src/clojush.clj
@@ -268,11 +268,11 @@
 (defn overlap
  [thing1 thing2]
  "Returns a measure of the similarity of the arguments, which may be
-nested sequences. The overlap is defined in terms of the collections of
-the items contained in each of the arguments, including nested items at
-all levels. The overlap is then the maximal number of pairings by identity
-across the two collections, divided by the size of the larger collection.
-The returned value will range from 0 (for entirely distinct arguments)
+nested sequences. The overlap is defined in terms of the collections of
+the items contained in each of the arguments, including nested items at
+all levels. The overlap is then the maximal number of pairings by identity
+across the two collections, divided by the size of the larger collection.
+The returned value will range from 0 (for entirely distinct arguments)
 to 1 (for identical arguments). Run (overlap-demo) to see some examples."
  (let [items1 (all-items thing1)
        items2 (all-items thing2)


modify (defn analyze): 2nd argument should be a lexicon, not a lookup function

--- src/babel/english/morphology.cljc
+++ src/babel/english/morphology.cljc
@@ -707,9 +707,7 @@
    {:unify-with {:synsem {:cat :noun
                           :agr {:number :sing}}}}})

-
-
-(defn analyze [surface-form lookup-fn]
+(defn analyze [surface-form lexicon]
   "return the map incorporating the lexical information about a surface form."
   (let [replace-pairs
         (merge
@@ -737,7 +735,7 @@
                    (if (and (not (keyword? key)) (re-find key surface-form))
                      (let [lexical-form (string/replace surface-form key
                                                         (:replace-with (get replace-pairs key)))
-                           looked-up (lookup-fn lexical-form)]
+                           looked-up (get lexicon lexical-form)]
                        (map #(unifyc % (:unify-with (get replace-pairs key)))
                             looked-up))))
                  (keys replace-pairs)))
@@ -748,7 +746,7 @@
                  (fn [key]
                    (if (keyword? key)
                      (let [lexical-form surface-form
-                           looked-up (lookup-fn lexical-form)]
+                           looked-up (get lexicon lexical-form)]
                        (map #(unifyc % (:unify-with (get replace-pairs key)))
                             looked-up))))
                  (keys replace-pairs)))]
@@ -760,7 +758,7 @@
      ;; might be either the canonical form of a word, or an irregular conjugation of a word.
      (if (not (empty? analyzed-via-identity))
        analyzed-via-identity
-       (lookup-fn surface-form)))))
+       (get lexicon surface-form)))))

 (def pronoun-semantic-gender-agreement
   (let [gender (atom :top)]


spacing

spacing

--- src/babel/english/morphology.cljc
+++ src/babel/english/morphology.cljc
@@ -10,7 +10,7 @@
 (declare plural-en)

 (defn fo [input & {:keys [show-notes]
-                          :or {show-notes true}}]
+                   :or {show-notes true}}]
   (cond

    (= input :fail)
@@ -28,7 +28,8 @@
        (vector? input))
    (str "(" (string/join " , "
                          (remove #(= % "")
-                                 (map #(let [f (fo %)] (if (= f "") "" (str "" f ""))) input)))
+                                 (map #(let [f (fo %)] (if (= f "") "" (str "" f "")))
+                                      input)))
         ")")

    true


s/info/debug/

s/info/debug/

--- src/babel/morphology.clj
+++ src/babel/morphology.clj
@@ -10,7 +10,7 @@
   (let [{infinitive :infinitive
          common :common
          forms :forms} specification]
-    (log/info (str "conjugation for: " infinitive " with common:" common))
+    (log/debug (str "conjugation for: " infinitive " with common:" common))

     (map (fn [form]
            (let [suffix (first form)


Fixed text importer breaking on platforms with spaces

--- src/bltool/data/text.clj
+++ src/bltool/data/text.clj
@@ -7,7 +7,7 @@
   (format "%8s  %-10s  %-10s  %s" (:id game) (:platform game) (:progress game) (:name game)))

 (defn- from-text [game]
-  (let [[id platform progress name] (-> game trim (split #"\s+" 4))]
+  (let [[id platform progress name] (-> game trim (split #"\s\s+" 4))]
     {:id id :name name :platform platform :progress progress}))

 (defmethod read-games "text" [_ source]


More formatting.

More formatting.

--- src/blutwurst/tuple_generator.clj
+++ src/blutwurst/tuple_generator.clj
@@ -32,13 +32,18 @@
         (find-generator-by-name override-name generators)))))

 (defn- build-dependency-selector-fn [generated-data dependency]
-  (let [targeted-table (first (filter #(and (= (-> % :entity :schema) (:target-schema dependency))
-                                            (= (-> % :entity :name) (:target-name dependency)))
+  (let [targeted-table (first (filter #(and (= (-> % :entity :schema)
+                                               (:target-schema dependency))
+                                            (= (-> % :entity :name)
+                                               (:target-name dependency)))
                                       generated-data))
         tuple-count (count (:tuples targeted-table))]
     (fn []
-      (let [chosen-row (nth (:tuples targeted-table) (random-integer-under-value tuple-count))
-            column-values (map #(hash-map (keyword (first %)) (get chosen-row (keyword (second %)))) (:links dependency))]
+      (let [chosen-row (nth (:tuples targeted-table)
+                            (random-integer-under-value tuple-count))
+            column-values (map #(hash-map (keyword (first %))
+                                          (get chosen-row (keyword (second %))))
+                               (:links dependency))]
         (if (= :embedded (-> dependency :links first second))
           (hash-map (keyword (-> dependency :links first first)) chosen-row)
           (apply merge column-values))))))


deleted header om file

deleted header om file

--- src/chat/client/views/header.cljs
+++ src/chat/client/views/header.cljs
@@ -1,17 +0,0 @@
-(ns chat.client.views.header
-  (:require [om.core :as om]
-            [om.dom :as dom]
-            [chat.client.store :as store]
-            [chat.client.views.search-bar :refer [search-bar-view]]
-            [chat.client.views.pills :refer [tag-view user-view]]
-            [chat.client.views.helpers :refer [id->color]]
-            [chat.client.routes :as routes]
-            [chat.client.dispatcher :refer [dispatch!]]))
-
-(defn header-view [data owner]
-  (reify
-    om/IRender
-    (render [_]
-      (dom/div #js {:className "header"}
-
-        (om/build search-bar-view (data :page))))))


optimization for using comp-paths on already compiled path

--- src/clj/com/rpl/specter/impl.cljx
+++ src/clj/com/rpl/specter/impl.cljx
@@ -22,9 +22,6 @@
   (println (pr-str e))
   e)

-(defprotocol PathComposer
-  (comp-paths* [paths]))
-
 (defn- smart-str* [o]
   (if (coll? o)
     (pr-str o)
@@ -134,6 +131,13 @@
     params
     idx))

+(defprotocol PathComposer
+  (do-comp-paths [paths]))
+
+(defn comp-paths* [p]
+  (if (compiled-path? p) p (do-comp-paths p))
+  )
+
 (defn- seq-contains? [aseq val]
   (->> aseq
        (filter (partial = val))
@@ -238,7 +242,7 @@

   #+clj java.util.List #+cljs cljs.core/PersistentVector
   (coerce-path [this]
-    (comp-paths* this))
+    (do-comp-paths this))

   #+cljs cljs.core/IndexedSeq
   #+cljs (coerce-path [this]
@@ -331,13 +335,13 @@

 (extend-protocol PathComposer
   nil
-  (comp-paths* [sp]
+  (do-comp-paths [sp]
     (coerce-path sp))
   #+clj Object #+cljs default
-  (comp-paths* [sp]
+  (do-comp-paths [sp]
     (coerce-path sp))
   #+clj java.util.List #+cljs cljs.core/PersistentVector
-  (comp-paths* [structure-paths]
+  (do-comp-paths [structure-paths]
     (if (empty? structure-paths)
       (coerce-path nil)
       (let [coerced (->> structure-paths


give Chronos Protocol prompt only to the Corp player

--- src/clj/game/cards-identities.clj
+++ src/clj/game/cards-identities.clj
@@ -56,14 +56,14 @@
    "Chaos Theory: Wünderkind"
    {:effect (effect (gain :memory 1))}

-"Chronos Protocol: Selective Mind-mapping"
+   "Chronos Protocol: Selective Mind-mapping"
    {:events
     {:pre-resolve-damage
      {:once :per-turn
       :effect (effect (damage-defer :net (last targets))
                       (resolve-ability
                         {:optional {:prompt (str "Use Chronos Protocol: Selective Mind-mapping to reveal the Runner's "
-                                                 "grip to select the first card trashed?")
+                                                 "grip to select the first card trashed?") :player :corp
                                     :yes-ability {:prompt (msg "Choose a card to trash")
                                                   :choices (req (:hand runner)) :not-distinct true
                                                   :msg (msg "trash " (:title target) " and deal "


Start/stop function of new system are done

--- src/clj/hellhound/system/core.clj
+++ src/clj/hellhound/system/core.clj
@@ -24,49 +24,51 @@
   (get (:components (get-system)) component-name))

-(defn for-each-component
-  [components f]
-  (doseq [component components]
-    (f component)))
-
-
-(defn start-dependencies
-  [system component]
-  ())
-

 (defn starting-context
+  "Generates the `context` map to be passed to `start!` of the component"
   [component]
   {})

 (defn call-start
+  "Calls `start!` function of the component and generates the context for it."
   [component]
   (when-not (started? component)
     (start! component (starting-context component))))

 (defn component-dependencies
+  "Returns a vector of all the components of the `system` which the given
+  `component` depends on them."
   [system component]
   (map #(get-component system %
                        (dependencies component))))

-(defn start-component!
-  [system component]
-  (let [components-map   (conj (component-dependencies system component)
-                               component)]
-
+(defn with-component-dependencies
+  "Runs the given function for all the dependencies of the given `component`
+  and the `component` itself and update the given `system` with the result
+  of the execution."
+  [system component f]
+  (let [components-map  (conj (component-dependencies system component)
+                              component)]
     (update-system system
                    :components
-                   (map call-start components-map))))
+                   (map f components-map))))
+
+(defn start-component!
+  "Starts the given `component` of the given `system`."
+  [system component]
+  (with-component-dependencies system component call-start))

 (defn stop-component!
-  [system component])
+  "Stops the given `component` of the given `system`."
+  [system component]
+  (with-component-dependencies system component call-stop))

 (defn start-system!
+  "Starts the given `system` map."
   [system]
-  (for-each-component (components system)
-                      #(start-component! system %)))
-
+  (map #(start-component! system %) (components system)))

 (s/fdef get-components


line graph switches when clicking different stats

--- src/cljs/ta_crash/line_graph.cljs
+++ src/cljs/ta_crash/line_graph.cljs
@@ -9,16 +9,6 @@
 (def tick-padding 5)
 (def width (- (- 960 (:left margin)) (:right margin)))
 (def height (- (- 640 (:top margin)) (:bottom margin)))
-
-;(defmulti get-data-type (fn [type _] type))
-
-;(defmethod get-data-type :crashes
-;  [type totals]
-;  (let [type-total (first (filter #(= :crashes (keyword (:type %))) totals))]
-;    ; (println "type-total: " (:total-crashes type-total))
-;    (:total-crashes type-total)))
-
-;(defmulti get-data-type (fn [parent & _] parent))

 (defn get-data-type
   [parent type totals]
@@ -55,28 +45,16 @@
              :identifier (:identifier x)
              :val (get-data-type parent type (:totals x))}) data)}))

-;(defn get-line-graph-data
-;  [type data]
-;  ;(println "get-line-graph-data: " (count data))
-;  {:title (get-graph-title type)
-;   :data (map (fn [x]
-;          {:month (:month x)
-;            :year (:year x)
-;            :type (:type x)
-;            :identifier (:identifier x)
-;            :val (get-data-type type (:totals x))}) data)})

 (defn get-svg
   [selector]
-  (if-let [svg (.select (.select js/d3 selector) "svg")]
-    svg
-    (.append (.select js/d3 selector) "svg")))
+  (let [svg (.select (.select js/d3 selector) "svg")]
+    (if (nil? (first (first (js->clj svg)))) (.append (.select js/d3 selector) "svg") svg)))

 (defn get-g
   [selector from-elem]
-  (if-let [g (.select from-elem selector)]
-    g
-    (.append from-elem "g")))
+  (let [g (.select from-elem selector)]
+    (if (nil? (first (first (js->clj g)))) (.append from-elem "g") g)))

 (defn set-graph
   [graph-data]
@@ -85,7 +63,8 @@
         svg (-> (get-svg ".line-graph-modal")
                 (.attr "width" (+ width (:right margin) (:left margin)))
                 (.attr "height" (+ height (:top margin) (:bottom margin))))
-        line-group (-> (.append svg "g")
+        line-group (-> (get-g ".line-group" svg)
+                       (.attr "class" "line-group")
                        (.attr "transform" (str "translate(" (:left margin) "," 0 ")")))
         domain-max (.max js/d3 (clj->js (map #(:val %) graph-data)))
         domain-min (.min js/d3 (clj->js (map #(:val %) graph-data)))
@@ -104,7 +83,7 @@
                          (.interpolate "linear"))
         y-axis (graph/create-axis total-scale :right width tick-padding graph/number-formatter y-tick-count)
         x-axis (graph/create-axis time-scale :top height tick-padding graph/month-formatter x-tick-count)
-        x-axis-group (-> (.append line-group "g")
+        x-axis-group (-> (get-g ".axis.x" line-group)
                          (.attr "transform" (str "translate(0 ," (- height 25) ")"))
                          (.attr "class" "x axis")
                          (.call x-axis)
@@ -113,7 +92,7 @@
                          (.attr "y" 12)
                          (.attr "dx" "-1.5em")
                          (.style "text-anchor" "start"))
-        y-axis-group (-> (.append line-group "g")
+        y-axis-group (-> (get-g ".axis.y" line-group)
                          (.attr "transform" (str "translate(0, -25)"))
                          (.attr "class" "y axis")
                          (.call y-axis)
@@ -126,6 +105,8 @@
                   (.data (clj->js graph-data)))
         enter (.enter lines)]
     (println "set-graph:" graph-data)
+    (-> (.selectAll line-group "path")
+        (.remove))
     (-> (.append line-group "path")
         (.attr "d" (line-segment (clj->js graph-data)))
         (.attr "class" "year-line"))


WIP prefer native js log10 implementation

--- src/clojure/contrib/humanize.cljc
+++ src/clojure/contrib/humanize.cljc
@@ -26,9 +26,15 @@
 #?(:clj (def log #(java.lang.Math/log %))
    :cljs (def log (.-log js/Math)))

+#?(:cljs (def ^:private rounding-const 1000000))
+
 #?(:clj (def log10 #(java.lang.Math/log10 %))
-   :cljs (def log10 #(/ (.round js/Math (* 100000 (/ (.log js/Math %) js/Math.LN10)))
-                        100000)))                           ;; FIXME implement proper rounding
+   :cljs (def log10 (or (.-log10 js/Math)                   ;; prefer native implementation
+                        #(/ (.round js/Math
+                                    (* rounding-const
+                                       (/ (.log js/Math %)
+                                          js/Math.LN10)))
+                            rounding-const))))              ;; FIXME rounding

 #?(:clj (def char->int #(Character/getNumericValue %))
    :cljs (def char->int #(int %)))


revert unnecessary changes to tree_xml

revert unnecessary changes to tree_xml

--- src/vip/data_processor/output/tree_xml.clj
+++ src/vip/data_processor/output/tree_xml.clj
@@ -3,7 +3,6 @@
             [clojure.java.io :as io]
             [clojure.java.jdbc :as jdbc]
             [vip.data-processor.output.xml-helpers :refer [create-xml-file]]
-            [vip.data-processor.output.street-segments :refer [insert-street-segment-nodes]]
             [vip.data-processor.db.postgres :as postgres]
             [vip.data-processor.db.util :as db.util]
             [clojure.tools.logging :as log]
@@ -159,4 +158,5 @@
   ctx)

 (def pipeline
-  [create-xml-file generate-xml-file])
+  [create-xml-file
+   generate-xml-file])


removing - from uuid making it more ES search friendly

--- src/celestial/common.clj
+++ src/celestial/common.clj
@@ -67,7 +67,7 @@
 (def conflict (partial resp :conflict))
 (def success (partial resp :success))

-(defn gen-uuid [] (str (java.util.UUID/randomUUID)))
+(defn gen-uuid [] (.replace (str (java.util.UUID/randomUUID)) "-" ""))

 (defn interpulate
   "basic string interpulation"


shortened moving average using comp per Dan's suggestion

--- src/clj/forma/postprocess/csv.clj
+++ src/clj/forma/postprocess/csv.clj
@@ -74,7 +74,6 @@

 Ex. (backward-looking-mavg 3 [1 2 3 4]) expands to [nil nil 1 2 3 4]. Nils are filtered out, so the output is effectively [(average [1]) (average [1 2]) (average [1 2 3]) (average 2 3 4)]"
   [window series]
-  (let [expanded-ts (concat (take (dec window) (repeat nil)) series)]
-    (map average
-         (map #(filter not-nil? %)
-              (partition window 1 expanded-ts)))))+  (let [expanded-ts (concat (repeat (dec window) nil) series)]
+    (map (comp float average #(filter not-nil? %))
+         (partition window 1 expanded-ts))))


Fixed indentation.

Fixed indentation.

--- src/cmr/plugin/jar/types/core.clj
+++ src/cmr/plugin/jar/types/core.clj
@@ -1 +0,0 @@
-(ns cmr.plugin.jar.types.core)


Removed unneeded calls to :once :per-turn

--- src/clj/game/cards-identities.clj
+++ src/clj/game/cards-identities.clj
@@ -85,7 +85,7 @@

    "Hayley Kaplan: Universal Scholar"
    {:events {:runner-install
-             {:optional {:prompt (msg "Install another " (:type target) " from Grip?") :once :per-turn
+             {:optional {:prompt (msg "Install another " (:type target) " from Grip?")
                          :req (req (and (first-event state side :runner-install) ;; If this is the first installation of the turn
                                         (some #(= (:type  %) (:type target)) (:hand runner)))) ;; and there are additional cards of that type in hand
                          :effect (req (let [type (:type target)]


Fix errors on browse console and also close #70

--- src/cljs/cljs_repl_web/views.cljs
+++ src/cljs/cljs_repl_web/views.cljs
@@ -231,10 +231,9 @@
      [button
       :label    "Next"
       :on-click (handler-fn
-                 (if next-step
-                   ((next-step)
-                    (next-tour-step tour))
-                   (next-tour-step tour)))
+                 (when next-step
+                   (next-step))
+                 (next-tour-step tour))
       :style    {:z-index 5000}
       :class     "btn-default"]]))


Add docstring section (when the description is missing). Fixes #92.

--- src/cljs/cljs_repl_web/views.cljs
+++ src/cljs/cljs_repl_web/views.cljs
@@ -187,11 +187,7 @@
   [v-box
    :size "0 0 auto"
    :gap "2px"
-   :children [[title
-               :label "Signatures"
-               :level :level4
-               :class "api-panel-popup-section-title"]
-              (for [s signatures]
+   :children [(for [s signatures]
                 [label
                  :label s
                  :class "api-panel-signature"])]])
@@ -206,7 +202,7 @@
    :children [[h-box
                :gap      "4px"
                :children [[title
-                           :label "Docs"
+                           :label "Description"
                            :level :level4
                            :class "api-panel-popup-section-title"]
                           [md-icon-button
@@ -319,14 +315,20 @@
   (let [{name :name
          full-name :full-name
          desc :description
+         docstring :docstring
          examples-htmls :examples-htmls
          examples-strings :examples-strings
          sign :signature
          related :related} sym-doc-map
-        examples (map (fn [html string] {:html html :strings string}) examples-htmls examples-strings)
-        popover-width  400
-        popover-height 400
-        popover-content-width (- popover-width (* 2 14) 15)] ; bootstrap padding + scrollbar width
+         desc (or desc docstring)       ; some symbols don't have a description so we use
+                                        ; the docstring instead; docstring is a regular string,
+                                        ; without markdown. Nonetheless, it will be passed to
+                                        ; md->react->component function to gain some basic html
+                                        ; formatting (like paragraphs)
+         examples (map (fn [html string] {:html html :strings string}) examples-htmls examples-strings)
+         popover-width  400
+         popover-height 400
+         popover-content-width (- popover-width (* 2 14) 15)] ; bootstrap padding + scrollbar width
     [popover-content-wrapper
      :showing? showing?
      :position @popover-position


Tidying

Tidying

--- src/cljs/cloj/resources/html.cljs
+++ src/cljs/cloj/resources/html.cljs
@@ -11,13 +11,27 @@
             [dommy.core             :as dommy :include-macros true]
             [hipo.core              :as hipo  :include-macros true]))

+;; =============================================================================
+;; {{{ Misc TODO move into utils file
 (defn put-close! [ch v]
   (do
     (async/put! ch v)
     (async/close! ch)))

+(defn cb->chan
+  "Convert a callback function "
+  [ cb-fn ]
+  (let [ret-chan (chan )]
+    (do
+      (->>
+        (fn [ret-val] (put-close! ret-chan ret-val))
+        (cb-fn))
+      ret-chan)))
+
+;; }}}
+
 ;; =============================================================================
-;; Multi method to turn a blob into an element
+;; {{{ Multi method to turn a blob into an element
 (defn img->iimage [img]
   (reify
     rp/IImage
@@ -39,9 +53,10 @@
     ret-chan))

 (defmethod blob->element :default [e] (println (str "unknown type " (.-type e))))
+;; }}}

 ;; =============================================================================
-;; Extend req to make it a little easier to deal with
+;; {{{ Extend req to make it a little easier to deal with
 (defprotocol IXHRReq
   (get-status [_])
   (u-okay-hun? [_])
@@ -63,19 +78,10 @@
                 (cb (.-response xhr)))))
       (.send))))

-(defn cb->chan
-  "Convert a callback function "
-  [ cb-fn ]
-  (let [ret-chan (chan )]
-    (do
-      (->>
-        (fn [ret-val] (put-close! ret-chan ret-val))
-        (cb-fn))
-      ret-chan))
-  )
+;; }}}

 ;; =============================================================================
-;; Crappy stab at seperating out loading into a channel
+;; {{{ Crappy stab at seperating out loading into a channel
 (defprotocol ILoader
   (load-blob! [_ file-name]))

@@ -93,6 +99,8 @@
           )
           ret-chan
         ))))
+
+;; }}}

 ;; =============================================================================
 ;; todo
@@ -117,13 +125,8 @@
       [0 0 (rp/width this) (rp/height this)])
     (img [_] el)))

-(defn msg [v s]
-  (println (str s "(" (type v) ")"))
-  v)
-
 (defn mk-resource-manager []
   (let [store (atom empty-store)]
-    (println "TRYIN THIS!")
     (do
       (reify
         IResourceManagerInfo
@@ -153,5 +156,3 @@
       )
     ))

-
-


fix board

fix board

--- src/cljs/triboard/view/board.cljs
+++ src/cljs/triboard/view/board.cljs
@@ -1,15 +1,13 @@
 (ns triboard.view.board
   (:require
     [triboard.logic.board :as board]
-    [triboard.view.interactions :as cb]
+    [triboard.view.interactions :as i]
     [triboard.view.utils :as vutils]))

 ;; ----------------------------------------------------------------------------
 ;; Private
 ;; ----------------------------------------------------------------------------
-
-;; TODO - Square SVG Board utils

 (def relative-size 0.9)
 (def border-size (/ (- 1 relative-size) 2))
@@ -24,9 +22,9 @@
      options)])

 (defn- empty-cell
-  [[x y :as position] cb player]
+  [[x y :as position] interactions player]
   (rect-cell position player
-    {:on-click #(cb/on-player-move cb x y)}))
+    {:on-click #(i/on-player-move interactions x y)}))

 (defn- empty-svg-board []
   [:svg.board
@@ -39,14 +37,13 @@
 ;; ----------------------------------------------------------------------------

 (defn render-board
-  [board suggestions cb]
+  [board suggestions interactions]
   (into
     (empty-svg-board)
     (for [[position cell] (board/to-seq board)]
       ^{:key position}
       (if (= :none cell)
-        [empty-cell position cb
-         (if (and suggestions (suggestions position))       ;; Avoids crash !
-           :help :none)]
+        [empty-cell position interactions
+         (if (suggestions position) :help :none)]
         [rect-cell position cell])
       )))


stop warning about deps.cljs

stop warning about deps.cljs

--- src/clj/cljs/closure.clj
+++ src/clj/cljs/closure.clj
@@ -844,7 +844,7 @@
   []
   (let [classloader (. (Thread/currentThread) (getContextClassLoader))
         upstream-deps (map #(read-string (slurp %)) (enumeration-seq (. classloader (findResources "deps.cljs"))))]
-    (doseq [dep upstream-deps]
+    #_(doseq [dep upstream-deps]
       (println (str "Upstream deps.cljs found on classpath. " dep " This is an EXPERIMENTAL FEATURE and is not guarenteed to remain stable in future versions.")))
     (apply merge-with concat upstream-deps)))


:modules has use once semantics, present a meaningful error if the user violates

--- src/clj/cljs/closure.clj
+++ src/clj/cljs/closure.clj
@@ -672,6 +672,7 @@
                            (when (some matcher (:provides source))
                              source)))
                        sources))
+        used (atom {})
         [sources' modules]
         (reduce
           (fn [[sources ret] [name {:keys [entries output-to depends-on] :as module-desc}]]
@@ -684,10 +685,17 @@
                   (reduce
                     (fn [[sources ret] entry-sym]
                       (if-let [entry (find-entry sources entry-sym)]
-                        [(remove #{entry} sources) (conj ret entry)]
-                        (throw
-                          (IllegalArgumentException.
-                            (str "Could not find namespace " entry-sym)))))
+                        (do
+                          (swap! used assoc entry-sym name)
+                          [(remove #{entry} sources) (conj ret entry)])
+                        (if (contains? @used entry-sym)
+                          (throw
+                            (IllegalArgumentException.
+                              (str "Already used namespace " entry-sym " "
+                                   "in module " (get @used entry-sym))))
+                          (throw
+                            (IllegalArgumentException.
+                             (str "Could not find namespace " entry-sym))))))
                     [sources []] entries)
                   foreign-deps (atom [])]
               ;; add inputs to module


Rename threads to users

Rename threads to users

--- src/clj_gatling/core.clj
+++ src/clj_gatling/core.clj
@@ -29,12 +29,12 @@
       {:result :requests})
     :id id))

-(defn run-simulation [threads]
-  (println (str "Run simulation with " threads " threads"))
-  (let [cs (repeatedly threads async/chan)
+(defn run-simulation [users]
+  (println (str "Run simulation with " users " users"))
+  (let [cs (repeatedly users async/chan)
         ps (map vector (iterate inc 0) cs)]
     (doseq [[i c] ps] (go (>! c (run-scenario test-scenario i))))
-    (let [result (for [i (range threads)]
+    (let [result (for [i (range users)]
       (let [[v c] (async/alts!! cs)]
         v))]
       (println result)
@@ -72,8 +72,8 @@
     (println result-lines)
     result-lines))

-(defn -main [threads]
-  (let [result (run-simulation (read-string threads))
+(defn -main [users]
+  (let [result (run-simulation (read-string users))
         csv (csv/write-csv (create-result-lines result) :delimiter "\t" :end-of-line "\n")]
     (println csv)
     (spit "results/23/simulation.log" csv)


A note

A note

--- src/cljs/klang/core.cljs
+++ src/cljs/klang/core.cljs
@@ -48,7 +48,7 @@

 (defonce
   ^{:doc "Holds a global instance of a db in case we want to use this
- library in single user mode. Ie only one loggins system. Will be true for 99%
+ library in single user mode. Ie only one logging system. Will be true for 99%
  of all users."}
   *db* (atom {}))

@@ -284,6 +284,8 @@
 ;; Given: n, VH, scroll position and thus the ratio of T/B
 ;; Not known: OH, p, q, k, T, B
 ;; :((, so much estimation
+;; Actually: We render a fixed with font, so we should know very well what the
+;; size is

 ;; Log message size:
 ;; Q: What if we pre-render a log message when it arrives do we then


Focus search field when showing overlay

Focus search field when showing overlay

Doing this by forcing a remount of the search component when the overlay is shown.

TODO: Select the text in the search field when shown.

--- src/cljs/klang/core.cljs
+++ src/cljs/klang/core.cljs
@@ -312,7 +312,6 @@
              (.push aout (render-log-event lg-ev)))))
        aout)))

-
 (defn- render-overlay
   "Renders the entire log message overlay in a div when :showing? is true."
   []
@@ -329,16 +328,18 @@
                              :width "calc(100% - 12px)"
                              :justifyContent "center"
                              :display "flex"}}
-        (h "input" #js{:style #js{:background "#000"
-                                  :color "white"
-                                  :width "350px"}
-                       :id "search"
-                       :tabIndex 1
-                       :onChange (fn [e] (!! assoc :search (.. e -target -value)))
-                       :autoFocus true
-                       :type "text"
-                       :defaultValue (:search @db "")
-                       :placeholder "Search"})
+        (if (:showing? @db)
+          (h "input" #js{:style #js{:background "#000"
+                                    :color "white"
+                                    :width "350px"}
+                         :id "klang-search"
+                         :tabIndex 1
+                         :onChange (fn [e] (!! assoc :search (.. e -target -value)))
+                         :autoFocus true
+                         :type "text"
+                         :defaultValue (:search @db "")
+                         :placeholder "Search"})
+          (h "span"))
         (h "button" #js{:style #js{:cursor "pointer"
                                    :color (if (:frozen-at @db) "orange" "green")}
                         :onClick #(toggle-freeze)}


Tidied up compojure.http.middleware

Tidied up compojure.http.middleware

--- src/compojure/http/middleware.clj
+++ src/compojure/http/middleware.clj
@@ -9,30 +9,27 @@
 (ns compojure.http.middleware
   "Various middleware functions."
   (:use compojure.http.routes)
+  (:use compojure.str-utils)
   (:use clojure.contrib.str-utils))

 (defn header-option
   "Converts a header option KeyValue into a string."
-  [[k v]]
+  [[key val]]
   (cond
-    (true? v)
-      (name k)
-    (false? v)
-      ""
-    :else
-      (str (name k) "=" v)))
+    (true? val)  (str* key)
+    (false? val) nil
+    :otherwise   (str* key "=" val)))

 (defn header-options
   "Converts a map into an HTTP header options string."
-  [m delim]
-  (str-join delim
-    (filter
-      #(not (= "" %))
-      (map header-option m))))
+  [map delimiter]
+  (str-join delimiter
+    (filter (complement nil?)
+            (map header-option map))))

 (defn with-headers
-  "Merges a map of header name and values into the response.
-   Will not overwrite existing headers."
+  "Merges a map of header name and values into the response.  Will not
+  overwrite existing headers."
   [handler headers]
   (fn [request]
     (let [response (handler request)
@@ -40,12 +37,11 @@
       (assoc response :headers merged-headers))))

 (defn with-cache-control
-   "Middleware to set the Cache-Control http header.
-    Map entries with boolean values either write their
-    key's (name) if true, or nothing if false.
-    Example:
-    (... {:max-age 3600 :public false :must-revalidate true})
-    Cache-Control: max-age=3600, must-revalidate"
-   [handler m]
+   "Middleware to set the Cache-Control http header. Map entries with boolean
+   values either write their key if true, or nothing if false.
+   Example:
+   {:max-age 3600 :public false :must-revalidate true}
+   => Cache-Control: max-age=3600, must-revalidate"
+   [handler header-map]
    (with-headers handler
-     {"Cache-Control" (header-options m ", ")}))
+     {"Cache-Control" (header-options header-map ", ")}))


STORM-186 convert 1000 to long to avoid int overflow

--- storm-core/src/clj/backtype/storm/util.clj
+++ storm-core/src/clj/backtype/storm/util.clj
@@ -221,7 +221,7 @@
   (Time/currentTimeMillis))

 (defn secs-to-millis-long [secs]
-  (long (* 1000 secs)))
+  (long (* (long 1000) secs)))

 (defn clojurify-structure [s]
   (prewalk (fn [x]


force trampoline for tasks that start a repl

--- plugin/src/leiningen/figwheel.clj
+++ plugin/src/leiningen/figwheel.clj
@@ -5,6 +5,7 @@
    [leiningen.core.eval :as leval]
    [leiningen.clean :as clean]
    [leiningen.core.main :as main]
+   [leiningen.trampoline :as tramp]
    [clojure.java.io :as io]
    [clojure.set :refer [intersection]]
    [leiningen.figwheel.fuzzy :as fuz]
@@ -445,6 +446,12 @@
 (defmethod fig-dispatch ":help" [_ project build-ids]
   (println (:doc (meta #'figwheel))))

+(defn launch-figwheel [command project build-ids]
+  (clean-on-dependency-change project)
+  (ensure-build-dirs project)
+  (println "Figwheel: Cutting some fruit, just a sec ...")
+  (fig-dispatch command project build-ids))
+
 (defn figwheel
 "Figwheel - a tool that helps you compile and reload ClojureScript.

@@ -519,19 +526,18 @@
   ignored.

   To learn more about configuring Figwheel please see the README at
-  https://github.com/bhauman/lein-figwheel
-"
+  https://github.com/bhauman/lein-figwheel"
   [project & command-and-or-build-ids]
   (let [[command & build-ids] command-and-or-build-ids]
     (when-not ((every-pred command-like? report-if-bad-command) command)
       (let [[command build-ids] (if (command-like? command)
-                                  [command build-ids]
-                                  [nil (and command (cons command build-ids))])]
-        (clean-on-dependency-change project)
-        (ensure-build-dirs project)
-        (println "Figwheel: Cutting some fruit, just a sec ...")
-        (fig-dispatch command project build-ids)))))
-
-#_(figwheel {:cljsbuilds {:builds [{:id :five}
-                                 {:id :six}]}}
-          )
+                                    [command build-ids]
+                                    [nil (and command (cons command build-ids))])]
+        (if (and
+             (or (= nil command)
+                 (= ":reactor" command))
+             (get-in project [:figwheel :repl] true))
+          (if tramp/*trampoline?*
+            (launch-figwheel command project build-ids)
+            (apply tramp/trampoline project "figwheel" command-and-or-build-ids))
+          (launch-figwheel command project build-ids))))))


Less noise when testing.

Less noise when testing.

--- web/dev-resources/testing/app.clj
+++ web/dev-resources/testing/app.clj
@@ -92,10 +92,7 @@
   (@client-defined-handler request))

 (defn get-client-state [_]
-  (println "get-client-state called")
-  (let [res (-> @client-state (maybe-deref 30000 :failure!) pr-str response)]
-    (println "get-client-state deref" (if (= res :failure!) "FAILED" "succeeded"))
-    res))
+  (-> @client-state (maybe-deref 30000 :failure!) pr-str response))

 (defroutes routes
   (GET "/" [] counter)


WIP, statefully check BookKeeper log impl

--- test/onyx/state/log/bookkeeper_stateful_check.clj
+++ test/onyx/state/log/bookkeeper_stateful_check.clj
@@ -1,6 +1,7 @@
 (ns onyx.state.log.bookkeeper-stateful-check
-  (:require [stateful-check.core :refer [reality-matches-model print-test-results]]
+  (:require [stateful-check.core :refer [reality-matches-model print-test-results specification-correct?]]
             [onyx.log.generators :as loggen]
+            [taoensso.timbre :refer [info error warn trace fatal] :as timbre]
             [onyx.extensions :as ext]
             [onyx.state.state-extensions :as state-ext]
             [onyx.messaging.dummy-messenger :refer [dummy-messenger]]
@@ -11,72 +12,98 @@
             [clojure.test.check.clojure-test :refer [defspec]]
             [onyx.test-helper :refer [load-config]]
             [clojure.test :refer :all]
+            [onyx.state.log.bookkeeper :as log-bk]
             [com.gfredericks.test.chuck :refer [times]]
             [com.gfredericks.test.chuck.clojure-test :refer [checking]]))

-(comment
 (defn new-replica []
-  (atom {:replica {:job-scheduler :onyx.job-scheduler/balanced
-                   :messaging {:onyx.messaging/impl :dummy-messenger}}
-         :message-id 0}))
+    (atom {:replica {:job-scheduler :onyx.job-scheduler/balanced
+                     :messaging {:onyx.messaging/impl :dummy-messenger}}
+           :message-id 0}))
+

 (def messenger (dummy-messenger {:onyx.peer/try-join-once? false}))

-(def env
-  (let [id (java.util.UUID/randomUUID)
-        config (load-config)
-        env-config (assoc (:env-config config) :onyx/id id)
-        peer-config (assoc (:peer-config config)
-                           :onyx/id id
-                           :onyx.bookkeeper/write-batch-size 1
-                           :onyx.bookkeeper/write-batch-timeout 10000000)
-        env (onyx.api/start-env env-config)]
+(def id (java.util.UUID/randomUUID))

-    (try
-
-
-(def new-peer-spec
-  {:next-state (fn [state args result]
-                 (let [pipeline {}]
-                   {:event (assoc pipeline
-                                  :onyx.core/window-state
-                                  (->WindowState (state-ext/initialize-filter :set pipeline)
-                                                 {}))}))
-   :real/command #'new-replica})
+(def config (load-config))
+
+(def env-config (assoc (:env-config config) :onyx/id id))
+
+(def peer-config (assoc (:peer-config config)
+                        :onyx/id id
+                        :onyx.bookkeeper/write-batch-size 1
+                        :onyx.bookkeeper/write-batch-timeout 10000000))
+
+(def initial-bookkeeper-state {:logs [[]] :ledger-ids [0]})
+
+(def bookkeeper-state (atom initial-bookkeeper-state))
+(def bookkeeper-peer-state (atom nil))
+
+(defn add-to-bookkeeper [arg]
+  (swap! bookkeeper-state (fn [bs-state]
+                            (update-in bs-state [:logs (last (:ledger-ids bs-state))] conj arg))))
+
+(def add-to-log-espec
+  {:model/args (fn [state]
+                 [gen/int])
+   :next-state (fn [state [arg] result]
+                 (conj state arg))
+   :real/postcondition (fn [prev-state next-state [arg] result]
+                         (= (reduce into [] (:logs @bookkeeper-state)) next-state))
+   :real/command #'add-to-bookkeeper})
+
+(defn switch-to-next-ledger []
+  (swap! bookkeeper-state (fn [bs-state]
+                            (-> bs-state
+                                (update :logs conj [])
+                                (update :ledger-ids conj (inc (apply max (:ledger-ids bs-state))))))))
+
+(def peer-crash-new-log-spec
+  {:model/args (fn [state]
+                 [])
+   :next-state (fn [state [arg] result]
+                 state)
+   ;:real/postcondition (fn [prev-state next-state [arg] result]
+   ;                      (= (reduce into [] (:logs @bookkeeper-state)) next-state))
+   :real/command #'switch-to-next-ledger})
+
+(defn new-peer-log []
+  (let [bk-peer-val {:ledger-ids []
+                     :event-log []
+                     :event (let [pipeline {:onyx.core/peer-opts peer-config}]
+                              (-> pipeline
+                                  ;(assoc :onyx.core/window-state (->WindowState (state-ext/initialize-filter :set pipeline) {}))
+                                  (assoc :onyx.core/state-log (state-ext/initialize-log :bookkeeper pipeline))))}]
+    (reset! bookkeeper-state initial-bookkeeper-state)
+    (reset! bookkeeper-peer-state bk-peer-val)))
+
+(defn close-peer-log [state]
+  (let [real-state-event (:event @bookkeeper-peer-state)]
+    (info " Closing log")
+    (state-ext/close-log (:onyx.core/state-log real-state-event) real-state-event)))
+
+(def log-spec
+  {:commands {:add-to-log add-to-log-espec
+              :peer-crash-new-log peer-crash-new-log-spec}
+   :real/setup #'new-peer-log
+   :real/cleanup #'close-peer-log
+   :real/postcondition (fn [final-state]
+                         (= (reduce into [] (:logs @bookkeeper-state)) final-state))
+   :initial-state (fn [setup] [])
+   ;:model/generate-command (fn [state]
+   ;                          (gen/elements [(gen/return :add-to-log)
+   ;                                         (gen/return :peer-crash-new-log)]))
+   })

-(def new-log-entry
-  {:model/args (fn [state]
-                 (gen/tuple
-                   (gen/return (:replica-real state))
-                   (gen/elements (:peers state))))
-   :model/precondition (fn [state _]
-                         (not-empty (:peers state)))
-   :real/postcondition (fn [state next-state args updated-real]
-                         (= (count (:peers (:replica updated-real)))
-                            (count (:peers next-state))))
-   :real/command #'apply-leave-entry
-   :next-state (fn [state [_ peer-id] _]
-                 (update-in state [:peers] disj peer-id))})
-
-(def replica-spec
-  {:commands {:new-peer new-peer-spec
-              :new-log-entry new-log-entry
-              :add-peer add-peer-spec
-              :remove-peer remove-peer-spec}
-   :model/generate-command (fn [state]
-                             (cond (nil? state)
-                                   (gen/return :new-replica)
-                                   (not-empty (:peers state))
-                                   (gen/elements [:add-peer :remove-peer])
-                                   :else
-                                   (gen/elements [:add-peer])))})
-
-
-#_(defspec run-replica-spec 5 (reality-matches-model? replica-spec))
-#_(print-test-results replica-spec (quick-check 50 (reality-matches-model? replica-spec) :seed 1417059242645))
-
-
-
-(finally
-  (onyx.api/shutdown-env env))))))
+(deftest log-test-correct
+  (with-redefs [log-bk/assign-bookkeeper-log-id-spin (fn [event new-ledger-id]
+                                                       (swap! bookkeeper-peer-state
+                                                              (fn [ps]
+                                                                (update ps :ledger-ids conj new-ledger-id))))]
+    (let [env (onyx.api/start-env env-config)]
+      (try
+        (is (specification-correct? log-spec))
+        (finally
+          (onyx.api/shutdown-env env))))))


getInitialState -> initLocalState in next.common

--- src/om-next/deathrow/common.cljs
+++ src/om-next/deathrow/common.cljs
@@ -49,7 +49,7 @@

 (defui GenericPanel
   Object
-  (getInitialState [this]
+  (initLocalState [this]
     {:loading true
      :eror false})
   (componentWillReceiveProps [this next-props]


Fix rename.

Fix rename.

--- src/onyx/peer/task_lifecycle.clj
+++ src/onyx/peer/task_lifecycle.clj
@@ -137,7 +137,7 @@
       (doseq [m (:onyx.core/batch rets)]
         (go (try (<! (timeout 60000))
                  (when (p-ext/pending? rets (:id m))
-                   (p-ext/replay-message event (:id m)))
+                   (p-ext/retry-message event (:id m)))
                  (catch Exception e
                    (taoensso.timbre/warn e))))))
     rets))
@@ -147,7 +147,7 @@
     (if (sentinel-found? rets)
       (do (if (p-ext/drained? rets)
             (complete-job rets)
-            (p-ext/replay-message rets (sentinel-id rets)))
+            (p-ext/retry-message rets (sentinel-id rets)))
           (strip-sentinel rets))
       rets)))


Bugfix in the docstring of hbase-clj.core/scan

--- src/hbase_clj/core.clj
+++ src/hbase_clj/core.clj
@@ -143,7 +143,7 @@
    (scan & options)
    (scan :with-versions & options)
    options could contain these keys:
-     - :eager?       If set to true, return a hash-map similar to the result of `get`, if false, returns a lazy scanner to fetch results later.
+     - :eager?       If set to true, return a vector similar to the result of `get`, if false, returns a lazy seq to fetch results later.
      - :start-id     The ID the htable-scan starts from (including)
      - :stop-id      The ID the htable-scan stops at (non-including)
      - :cache-size   The number of rows fetched when getting a \"next\" item, only takes effect when `eager?` is set to false