Fix output in order property

Fix output in order property

--- test/onyx/peer/deterministic_peer_test.clj
+++ test/onyx/peer/deterministic_peer_test.clj
@@ -40,7 +40,6 @@
 ;; Job code

 (defn add-path [job-id task-id {:keys [n] :as segment}]
-  ;(when-not (:state-output? segment) (println "New segment " (update segment :path conj [job-id task-id])))
   (update segment :path conj [job-id task-id]))

 (def add-paths-calls
@@ -74,7 +73,6 @@
                          :path []
                          :extent-state extent-state}]
                        destinations)))
-  (println "state out: " (:event-type state-event))

   ;; Triggering on job completed is buggy
   ;; as peer may die while writing :job-completed
@@ -88,7 +86,7 @@
       ;          (m/replica-version (:messenger (:state event)))
       ;          (m/epoch (:messenger (:state event)))
       ;          (:job-id event) extent-state)
-      (swap! state-atom assoc (:job-id event) extent-state))))
+      (swap! state-atom assoc [(:job-id event) (:slot-id event)] extent-state))))

 (defn simple-job-def [job-id]
   (let [n-messages 200
@@ -183,15 +181,16 @@
                  inputs))
           (build-paths job)))

-(defn prop-is [ok? & [message]]
-  (when-not ok?
-    (throw (Exception. message))))
+(defn prop-is [pass? & messages]
+  (when-not pass?
+    (throw (Exception. (pr-str messages)))))

 (defn check-outputs-in-order!
   "Check that all messages arrive in order, absent rewinds
    This is only true if there is only one peer per task
    at any given time"
   [peer-outputs]
+  (def pppp peer-outputs)
   (doseq [peer-output peer-outputs]
     (doseq [run (->> peer-output
                      (partition-by #(= [:reset-messenger] %))
@@ -206,7 +205,7 @@
           ;; FIXME: why less than or equal
           (prop-is (apply < (map :n segments))
                    (str (mapv :n segments))
-                   "outputs not in order"))))))
+                   (str "outputs not in order " input-task " " segments)))))))

 (defn job-completion-cmds
   "Generates a series of commands that should allow any submitted jobs to finish.
@@ -308,16 +307,12 @@
     (prop-is (= (count jobs) (count (:completed-jobs replica))) "jobs not completed")
     (prop-is (= (count (:groups model)) (count (:groups replica))) "groups check")
     (prop-is (= (count (:peers model)) (count (:peers replica))) "peers")
-
+    ;(println "STATE ATOM" @state-atom)
     (let [state-values (reduce into [] (vals @state-atom))]
       (prop-is (= (count (set state-values)) (count state-values)) "not enough state values")
       (prop-is (= (set expected-state) (set state-values))
                (str "incorrect state "
-                    (vec (take 2 (clojure.data/diff (set expected-state) (set state-values))))
-
-                    "state values"
-                    (pr-str state-values)
-                    )))
+                    (vec (take 2 (clojure.data/diff (set expected-state) (set state-values)))))))
     (prop-is (= expected-state
                 ;; Potentially should check for state ordering here
                 (set (:extent-state
@@ -327,7 +322,7 @@
     (prop-is (= (set expected-outputs) (set flow-outputs)) "messenger flow values incorrect")
     ;(println "Expected: " expected-outputs)
     ;(println "Outputs:" actual-outputs)
-    #_(check-outputs-in-order! peer-outputs)))
+    (check-outputs-in-order! peer-outputs)))

 (defspec deterministic-abs-test {;:seed X
                                  :num-tests (times 200)}
@@ -352,7 +347,7 @@
                                                     [500 g/play-group-commands-gen]
                                                     [500 g/write-outbox-entries-gen]
                                                     [500 g/apply-log-entries-gen]])
-                                    50000))))]
+                                    5000))))]
            (let [generated {:phases phases
                             :uuid-seed uuid-seed}]
              (spit "/tmp/testcase.edn" (pr-str generated))


test-fix ?

test-fix ?

--- test/metabase/api/common/throttle_test.clj
+++ test/metabase/api/common/throttle_test.clj
@@ -102,7 +102,7 @@
 (expect [0 3]
   [(do (reset! (:attempts test-throttler) '()) ; reset it to 0
        (count @(:attempts test-throttler)))
-   (do (attempt 10)
+   (do (attempt 5)
        (count @(:attempts test-throttler)))])

 ;; Check that attempts clear after the TTL


set random card faces

set random card faces

--- Assets/game/core.clj
+++ Assets/game/core.clj
@@ -47,8 +47,27 @@
     (card-update-type card res-name)))

 (def card-faces ["robot" "roboty-drogowe"])
-(defn rand-card-face []
-  (rand-nth card-faces))
+(defn rand-card-face
+  ([] (rand-nth card-faces))
+  ([_] (rand-card-face))
+  ([coll face] ))
+
+;; (shuffle (flatten (map #(repeat 2 (keyword %)) card-faces)))
+
+(doseq [[card face]
+        (->> card-faces
+             (map #(repeat 2 %))
+             flatten
+             shuffle
+             (zipmap (cards)))]
+  (card-set-face-texture! card face))
+
+;; (map rand-card-face
+;;      (range (* 2 (count card-faces))))
+
+;; (reduce conj
+;;         []
+;;         (range (* 2 (count card-faces))))

 ;; (card-set-face-texture! (card) (rand-card-face))


CMR-3973: remove println.

CMR-3973: remove println.

--- metadata-db-app/src/cmr/metadata_db/services/jobs.clj
+++ metadata-db-app/src/cmr/metadata_db/services/jobs.clj
@@ -49,7 +49,6 @@
   "clean up the rows in the bulk-update-task-status table that are older than the
    configured age"
   [context]
-  (println "=====================IN BULKUPDATE STATUS TABLE CLEANUP==================")
   (concept-service/cleanup-old-bulkupdate-status context))

 (def-stateful-job BulkUpdateStatusTableCleanupJob


Start filling out some fixture configuration.

Based on actual experiments, flesh out pan/tilt response. Also
discovered some inverted dimmers, so needed to add support for that to
Afterglow.

--- src/afterglow/fixtures/chauvet.clj
+++ src/afterglow/fixtures/chauvet.clj
@@ -90,6 +90,10 @@
   If you do not specify a mode when patching it, `:11-channel` is
   assumed; you can pass a value of `:8-channel` for `mode` if you are
   using it that way.
+
+  The standard orientation to hang this fixture is with the Chauvet
+  logo and LED upright and facing the audience, but tilted up and away
+  from them at a 45 degree angle.

   This was created by Afterglow from the QLC+ Fixture Definintion
   (.qxf) file, and heavily revised by James Elliott.
@@ -165,8 +169,8 @@
                                     :range :variable}
                                240 :gobo-bounce))]
        (merge {:name "Chauvet Intimidator Scan LED 300"
-               :pan-center 128 :pan-half-circle 128 ; TODO: Fix these values
-               :tilt-center 128 :tilt-half-circle 128 ; TODO: Fix these values
+               :pan-center 128 :pan-half-circle -256
+               :tilt-center 0 :tilt-half-circle -1024
                :mode mode}
               (case mode
                 :11-channel
@@ -223,6 +227,9 @@
   If you do not specify a mode when patching it, `:11-channel` is
   assumed; you can pass a value of `:6-channel` for `mode` if you are
   using it that way.
+
+  The standard orientation for this fixture is hung with the Chauvet
+  label and LED indicator upside-down and facing towards the audience.

   This was created by Afterglow from the QLC+ Fixture Definintion
   (.qxf) file, and heavily revised by James Elliott.
@@ -285,12 +292,12 @@
                                     :var-label "CCW Speed"
                                     :range :variable}))]
        (merge {:name "Chauvet Intimidator Spot LED 150"
+               :pan-center 170 :pan-half-circle -85
+               :tilt-center 42 :tilt-half-circle 192
                :mode mode}
               (case mode
                 :11-channel
-                {:pan-center 128 :pan-half-circle 128 ; TODO: Fix these values
-                 :tilt-center 128 :tilt-half-circle 128 ; TODO: Fix these values
-                 :channels [(chan/pan 1 3)
+                {:channels [(chan/pan 1 3)
                             (chan/tilt 2 4)
                             (chan/fine-channel :pan-tilt-speed 5
                                                :function-name "Pan / Tilt Speed"
@@ -319,9 +326,7 @@
                                             (range 8 135 16) "Program"
                                             (range 136 255 16) "Sound Active")]}
                 :6-channel
-                {:pan-center 128 :pan-half-circle 128 ; TODO: Fix these values
-                 :tilt-center 128 :tilt-half-circle 128 ; TODO: Fix these values
-                 :channels [(chan/pan 1)
+                {:channels [(chan/pan 1)
                             (chan/tilt 2)
                             (build-color-wheel 3)
                             (build-shutter 4)
@@ -356,7 +361,7 @@
                               210 :sound-active)
               (chan/functions :strobe 2 0 nil
                               1 :strobe)  ; TODO: Measure speed, add scale-fn
-              (chan/dimmer 3)]  ; TODO: Manual implies this might be reversed? If so, what a pain.
+              (chan/dimmer 3 :inverted-from 1)]
    :name "Chauvet LED Techno Strobe"})

 (defn led-techno-strobe-rgb
@@ -381,7 +386,7 @@
               (chan/color 4 :blue)
               (chan/functions :strobe 5 0 nil
                               1 :strobe)  ; TODO: Measure speed, add scale-fn
-              (chan/dimmer 6)]
+              (chan/dimmer 6 :inverted-from 0)]
    :name "Chauvet LED Techno Strobe RGB"})

 (defn scorpion-storm-fx-rgb
@@ -528,7 +533,11 @@
   This fixture can be configured to use either 9 or 12 DMX channels.
   If you do not specify a mode when patching it, `:12-channel` is
   assumed; you can pass a value of `:9-channel` for `mode` if you are
-  using it that way."
+  using it that way.
+
+  The standard hanging orientation is with the Chauvet label and LED
+  panel upside-down and facing the house-right wall (the positive X
+  axis direction)."
   {:doc/format :markdown}
   ([]
    (q-spot-160 :12-channel))
@@ -591,8 +600,8 @@
                                200 "Reset"
                                220 nil))]
        (merge {:name "Chauvet Q Spot 160"
-               :pan-center 128 :pan-half-circle 128 ; TODO: Fix these values
-               :tilt-center 128 :tilt-half-circle 128 ; TODO: Fix these values
+               :pan-center 85 :pan-half-circle 85
+               :tilt-center 218 :tilt-half-circle -180
                :mode mode}
               (case mode
                 :12-channel


Maintain correct order on group duplication

--- frontend/src/uxbox/main/data/shapes_impl.cljs
+++ frontend/src/uxbox/main/data/shapes_impl.cljs
@@ -47,6 +47,7 @@
                                (update-in $ [:shapes group :items] #(into [] (cons id %)))
                                (assoc-in $ [:shapes id] shape)))]
                  (->> (map #(get-in state [:shapes %]) items)
+                      (reverse)
                       (reduce #(duplicate-shape %1 %2 used-names page id) state)))
                (let [id (uuid/random)
                      shape (-> (dissoc shape :group)


Delete config1.clj

Delete config1.clj

--- seria/config1.clj
+++ seria/config1.clj
@@ -1 +0,0 @@
-(defconfig my-config1 :schemas {:x [:tuple [:int]]})


commented in failing line in install-system

--- main/src/dda/pallet/dda_managed_ide/infra.clj
+++ main/src/dda/pallet/dda_managed_ide/infra.clj
@@ -95,7 +95,7 @@
     (db/install-system facility ide-settings contains-db? db)
     (clojure/install-system facility contains-clojure? clojure)
     (java/install-system facility contains-java? java)
-    ;(js/install-system facility contains-java-script? java-script ide-settings)
+    (js/install-system facility contains-java-script? java-script ide-settings)
     (py/install-system facility ide-settings)
     (devops/install-system facility ide-settings contains-devops? devops)
     (atom/install-system facility ide-settings contains-atom? atom)


Rename fix for pool variable. (#1030)

Rename fix for pool variable. (#1030)

--- scheduler/src/cook/mesos/scheduler.clj
+++ scheduler/src/cook/mesos/scheduler.clj
@@ -855,7 +855,7 @@
 (counters/defcounter [cook-mesos scheduler offer-chan-depth])

 (defn make-offer-handler
-  [conn driver-atom fenzo framework-id pending-jobs-atom agent-attributes-cache max-considerable scaleback
+  [conn driver-atom fenzo framework-id pool-name->pending-jobs-atom agent-attributes-cache max-considerable scaleback
    floor-iterations-before-warn floor-iterations-before-reset trigger-chan rebalancer-reservation-atom
    mesos-run-as-user pool-name]
   (let [chan-length 100
@@ -904,7 +904,7 @@
                       _ (log/debug "In" pool-name "pool, passing following offers to handle-resource-offers!" offers)
                       using-pools? (not (nil? (config/default-pool)))
                       user->quota (quota/create-user->quota-fn (d/db conn) (if using-pools? pool-name nil))
-                      matched-head? (handle-resource-offers! conn @driver-atom fenzo framework-id pending-jobs-atom
+                      matched-head? (handle-resource-offers! conn @driver-atom fenzo framework-id pool-name->pending-jobs-atom
                                                              mesos-run-as-user @user->usage-future user->quota
                                                              num-considerable offers-chan offers
                                                              rebalancer-reservation-atom pool-name)]


Note bound-fn usage in schedule docstring [IMMUTANT-478]

--- scheduling/src/immutant/scheduling.clj
+++ scheduling/src/immutant/scheduling.clj
@@ -90,7 +90,10 @@
   scheduler configured with the default options. If you pass scheduler
   options on a subsequent call, you will get a different scheduler
   configured with those options. The same scheduler will be used for any
-  future `schedule` calls with those same scheduler options."
+  future `schedule` calls with those same scheduler options.
+
+  If you need to capture any bindings in effect when the job is
+  scheduled, wrap `f` in a call to `bound-fn`."
   [f & spec]
   (let [opts (->> spec
                iu/kwargs-or-map->map


Use map-indexed instead of raw for

Use map-indexed instead of raw for

--- dev/pot/core/ui.cljs
+++ dev/pot/core/ui.cljs
@@ -61,25 +61,26 @@
             #(root-key-handler @cursor actions %))))
       om/IRender
       (render [_]
-        (let [board (:board cursor)
-              yc (count board)
-              xc (count (first board))]
+        (let [board (:board cursor)]
           (html
             [:table
              (if (game-over? board)
                [:tbody [:tr [:td "GAME OVER"]]]
-               (into
-                 [:tbody]
-                 (for [y (range yc)]
-                   (into
-                     [:tr {:key (str "tr" y)}]
-                     (for [x (range xc)]
-                       [:td {:style {:width      50
-                                     :height     50
-                                     :border     [["1px solid black"]]
-                                     :text-align :center}
-                             :key   (str "td" (+ (* yc y) x))}
-                        (get-in board [y x])])))))])))))
+               [:tbody
+                (map-indexed
+                  (fn [y row]
+                    [:tr {:key (str "tr" y)}
+                     (let [rc (count row)]
+                       (map-indexed
+                         (fn [x cell]
+                           [:td {:style {:width      50
+                                         :height     50
+                                         :border     [["1px solid black"]]
+                                         :text-align :center}
+                                 :key   (str "td" (+ (* rc y) x))}
+                            cell])
+                         row))])
+                  board)])])))))
   app-state
   {:target     (.getElementById js/document "app")
    :init-state {:channels channels}})


Add section on new React

Add section on new React

--- demo/reagentdemo/news/news060.cljs
+++ demo/reagentdemo/news/news060.cljs
@@ -244,6 +244,43 @@
         itself dispatches a new event (that would result in lost
         events, and much confusion)."]]

+       [:section.demo-text
+        [:h2 "New React version and new namespaces"]
+
+        [:p "Reagent now depends on React version 0.14.3. React itself
+        is now split into three parts, with separate packages for
+        browser specific code, and HTML generation respectively."]
+
+        [:p "To reflect that, two new namespaces have been introduced
+        in Reagent as well: "[:code "reagent.dom"]"
+        and "[:code "reagent.dom.server"]". They contain functions
+        that used to be in "[:code "reagent.core"]". "]
+
+        [:p [:code "reagent.dom"]" contains: "]
+
+        [:ul
+         [:li [:code "render"]]
+         [:li [:code "unmount-component-at-node"]]
+         [:li [:code "dom-node"]]
+         [:li [:code "force-update-all"]]]
+
+        [:p [:code "reagent.dom.server"]" contains: "]
+
+        [:ul
+         [:li [:code "render-to-string"]]
+         [:li [:code "render-to-static-markup"]]]
+
+        [:p "These functions are still available
+        in "[:code "reagent.core"]" in this release (for backward
+        compatibility reasons), but they may be deprecated in the
+        future."]
+
+        [:p "The changes in React also mean that if you specify the
+        React version to use in your project.clj,
+        with "[:code "cljsjs/react"]" in the "[:code ":dependencies"]"
+        section, you now have to specify "[:code "cljsjs/react-dom"]"
+        and "[:code "cljsjs/react-dom-server"]" instead."]]
+
        ])]])

 (tools/register-page url [#'main] title)


Refactor kvs-work to more reusable kvs-check.

--- src/cbfg/kvs.cljs
+++ src/cbfg/kvs.cljs
@@ -37,6 +37,16 @@

 ; TODO: Add snapshot ability.

+(defn kvs-check [m work-fn]
+  (fn [state] ; Meant to be used as work-fn for state-work function.
+    (if-let [[name uuid] (:kvs-ident m)]
+      (if-let [kvs (get-in state [:kvss name])]
+        (if (= uuid (:uuid kvs))
+          (work-fn state kvs)
+          [state {:status :mismatch :sub-status :wrong-uuid}])
+        [state {:status :not-found :sub-status :no-kvs}])
+      [state {:status :invalid :sub-status :no-kvs-ident}])))
+
 (defn state-work [actx state-ch m work-fn]
   (act state-work actx
        (let [res-ch (:res-ch m)
@@ -45,41 +55,36 @@
          (aput state-work res-ch
                (merge m (or (atake state-work help-ch) {:status :error}))))))

-(defn kvs-work [actx state-ch m work-fn]
-  (state-work actx state-ch m
-              #(if-let [[name uuid] (:kvs-ident m)]
-                 (if-let [kvs (get-in % [:kvss name])]
-                   (if (= uuid (:uuid kvs))
-                     (work-fn % kvs)
-                     [% {:status :mismatch :sub-status :wrong-uuid}])
-                   [% {:status :not-found :sub-status :no-kvs}])
-                 [% {:status :invalid :sub-status :no-kvs-ident}])))
-
 (def op-handlers
   {:kvs-open
    (fn [actx state-ch m]
      (state-work actx state-ch m
-                 #(if-let [name (:name m)]
-                    (if-let [kvs (get-in % [:kvss name])]
-                      [% {:status :ok :kvs-ident [name (:uuid kvs)]}]
-                      [(-> %
-                           (update-in [:kvss name] (make-kvs name (:next-uuid %)))
-                           (assoc :next-uuid (inc (:next-uuid %))))
-                       {:status :ok :kvs-ident [name (:next-uuid %)]}])
-                    [% {:status :invalid :sub-status :no-name}])))
+                 (kvs-check m #(if-let [name (:name m)]
+                                 (if-let [kvs (get-in % [:kvss name])]
+                                   [% {:status :ok :kvs-ident [name (:uuid kvs)]}]
+                                   [(-> %
+                                        (update-in [:kvss name]
+                                                   (make-kvs name (:next-uuid %)))
+                                        (assoc :next-uuid (inc (:next-uuid %))))
+                                    {:status :ok :kvs-ident [name (:next-uuid %)]}])
+                                 [% {:status :invalid :sub-status :no-name}]))))

    :kvs-remove
    (fn [actx state-ch m]
-     (kvs-work actx state-ch m
-               (fn [state kvs]
-                 [(dissoc-in state [:kvss (:name kvs)]) {:status :ok}])))
+     (state-work actx state-ch m
+                 (kvs-check m
+                            (fn [state kvs]
+                              [(dissoc-in state [:kvss (:name kvs)])
+                               {:status :ok}]))))

    :multi-get
    (fn [actx state-ch m]
-     (kvs-work actx state-ch m
-               (fn [state kvs]
-                 [state {:status :ok
-                         :results (map #(kvs-entry-by-key kvs %) (:keys m))}])))
+     (state-work actx state-ch m
+                 (kvs-check m
+                            (fn [state kvs]
+                              [state
+                               {:status :ok
+                                :results (map #(kvs-entry-by-key kvs %) (:keys m))}]))))

    :multi-change
    (fn [actx state-ch [res-ch name changes]])


[#3031] Use data-groups=true in new tenant instance

--- backend/src/akvo/lumen/admin/add_tenant.clj
+++ backend/src/akvo/lumen/admin/add_tenant.clj
@@ -153,6 +153,7 @@
           {:keys [email label title url]} (conform-input url title email)
           {:keys [tenant-db] :as db-uris} (admin.db/db-uris label (new-tenant-db-pass) (-> dbs :lumen :password) (-> dbs :lumen :user))
           _ (admin.db/setup-tenant-database label title (-> administer :db-settings :encryption-key) db-uris drop-if-exists?)
+          _ (util/exec! tenant-db {} "insert into environment(id, value) values ('data-groups', 'true'::jsonb);")
           {:keys [user-id email tmp-password] :as user-creds} (admin.keycloak/setup-tenant authorizer label email url  drop-if-exists?)]
       (exec-mail (merge administer {:user-creds user-creds
                                     :tenant-db tenant-db


Incomplete cli support sketched

Incomplete cli support sketched

--- src/civs/core.clj
+++ src/civs/core.clj
@@ -10,12 +10,43 @@
     [civs.logic.stats :refer :all]
     [civs.society :refer :all]
     [civs.graphics :refer :all]
-    [clojure.tools.cli :refer [parse-opts]]))
+    [clojure.tools.cli :refer [parse-opts]]
+    [clojure.string :as string]))

 ;(require '[civs.model :refer :all])
 ;(require '[civs.logic :refer :all])

 (def w (load-world "examples-worlds/seed_77.world"))

+(defn failure [msg]
+  (binding [*out* *err*]
+    (println "Error:" msg)
+    (println "")
+    (println "Use -h for help")
+    (println "Exit."))
+  (System/exit 1))
+
+(defn usage [options-summary]
+  (println (->> ["This program run simulations of civilizations evolution and struggling"
+        ""
+        "Usage: [lein run] civs [options]"
+        ""
+        "Options:"
+        options-summary
+        ""
+        "Feel free to ask all possible questions on https://github.com/ftomassetti/civs (just open an issue!)"]
+    (string/join \newline)))
+    (System/exit 0))
+
 (defn -main [& args]
-  (parse-opts args cli-options))
+  (println " Civs : a civilizations simulator ")
+  (println "----------------------------------")
+  (println "")
+  (let [{:keys [options arguments errors summary]} (parse-opts args cli-options)]
+    (cond
+      (nil? (:world options))
+        (failure "World to be used not specified (option -w missing)")
+      (:help options)
+        (usage summary)
+      errors (failure errors))
+      (println "Not yet implemented...")))


Comments on the clojure-pp public function format-clj!.

--- pp-server/src/pp_server/format/clojure_pp.clj
+++ pp-server/src/pp_server/format/clojure_pp.clj
@@ -26,6 +26,8 @@
   (str literal))

 (defn format-clj!
+  "Clojure formatting function that takes a unformatted-input and format type
+  and transforms it into a formatted output using clojure.pprint/write."
   [input tipe]
   (let [in-lit    (str-to-literal! input)
         formatted (format-literal! in-lit tipe)


condp

condp

--- src/mark-volkmann-tutorial/conditional-processing.clj
+++ src/mark-volkmann-tutorial/conditional-processing.clj
@@ -45,4 +45,6 @@
     (println)))

 (summarize ["Moe" "Larry" "Curly"])
-(summarize [])+(summarize [])
+
+; condp ~ switch/case statement: 2 param predicate (=, instance?)


Align top recipient multiline input

Align top recipient multiline input

Signed-off-by: Gheorghe Pinzaru <742a0a3885ab52ea1795e48e261ec4223e194612@gmail.com>

--- src/status_im/ui/screens/wallet/components/views.cljs
+++ src/status_im/ui/screens/wallet/components/views.cljs
@@ -42,6 +42,7 @@
         :container           {:height           98
                               :padding-vertical 8}
         :placeholder         (i18n/label :t/recipient-code-placeholder)
+        :text-align-vertical :top
         :on-change-text      #(reset! content %)
         :accessibility-label :recipient-address-input}]
       [react/text {:style {:color           colors/gray


[STORM-1453] nimbus.clj/wait-for-desired-code-replication print wrong log message

--- storm-core/src/clj/org/apache/storm/daemon/nimbus.clj
+++ storm-core/src/clj/org/apache/storm/daemon/nimbus.clj
@@ -516,13 +516,13 @@
     (if (and (< min-replication-count @current-replication-count-conf)
              (< min-replication-count @current-replication-count-code)
              (< min-replication-count @current-replication-count-jar))
-      (log-message "desired replication count of "  min-replication-count " not achieved but we have hit the max wait time "
-        max-replication-wait-time " so moving on with replication count for conf key = " @current-replication-count-conf
-        " for code key = " @current-replication-count-code "for jar key = " @current-replication-count-jar)
       (log-message "desired replication count "  min-replication-count " achieved, "
         "current-replication-count for conf key = " @current-replication-count-conf ", "
         "current-replication-count for code key = " @current-replication-count-code ", "
-        "current-replication-count for jar key = " @current-replication-count-jar))))
+        "current-replication-count for jar key = " @current-replication-count-jar)
+      (log-message "desired replication count of "  min-replication-count " not achieved but we have hit the max wait time "
+        max-replication-wait-time " so moving on with replication count for conf key = " @current-replication-count-conf
+        " for code key = " @current-replication-count-code "for jar key = " @current-replication-count-jar))))

 (defn- read-storm-topology-as-nimbus [storm-id blob-store]
   (Utils/deserialize


Refactor multilang tests

Refactor multilang tests

--- storm-core/test/clj/backtype/storm/multilang_test.clj
+++ storm-core/test/clj/backtype/storm/multilang_test.clj
@@ -37,33 +37,28 @@
 ;;       (Thread/sleep 10000)
 ;;       )))

-(deftest test-multilang-rb
-  (with-local-cluster [cluster :supervisors 4]
-    (let [nimbus (:nimbus cluster)
-          topology (thrift/mk-topology
-                    {"1" (thrift/mk-shell-spout-spec ["ruby" "tester_spout.rb"] ["word"])}
-                    {"2" (thrift/mk-shell-bolt-spec {"1" :shuffle} "ruby" "tester_bolt.rb" ["word"] :parallelism-hint 1)})]
-      (submit-local-topology nimbus
-                             "test"
-                             {TOPOLOGY-WORKERS 20 TOPOLOGY-MESSAGE-TIMEOUT-SECS 3 TOPOLOGY-DEBUG true}
-                             topology)
-      (Thread/sleep 10000)
-      (.killTopology nimbus "test")
-      (Thread/sleep 10000))))
+
+ (defn test-multilang
+       [executor file-extension]
+       (with-local-cluster [cluster :supervisors 4]
+         (let [nimbus (:nimbus cluster)
+               topology (thrift/mk-topology
+                  {"1" (thrift/mk-shell-spout-spec [executor (str "tester_spout." file-extension)] ["word"])}
+                  {"2" (thrift/mk-shell-bolt-spec {"1" :shuffle} [executor (str "tester_bolt." file-extension)] ["word"] :parallelism-hint 1)})]
+         (submit-local-topology nimbus
+               "test"
+               {TOPOLOGY-WORKERS 20 TOPOLOGY-MESSAGE-TIMEOUT-SECS 3 TOPOLOGY-DEBUG true}
+               topology)
+       (Thread/sleep 10000)
+       (.killTopology nimbus "test")
+       (Thread/sleep 10000)
+       )))

-(deftest test-multilang-py
-  (with-local-cluster [cluster :supervisors 4]
-    (let [nimbus (:nimbus cluster)
-          topology (thrift/mk-topology
-                      {"1" (thrift/mk-shell-spout-spec ["python" "tester_spout.py"] ["word"])}
-                      {"2" (thrift/mk-shell-bolt-spec {"1" :shuffle} ["python" "tester_bolt.py"] ["word"] :parallelism-hint 1)}
-                      )]
-      (submit-local-topology nimbus
-                          "test"
-                          {TOPOLOGY-WORKERS 20 TOPOLOGY-MESSAGE-TIMEOUT-SECS 3 TOPOLOGY-DEBUG true}
-                          topology)
-      (Thread/sleep 10000)
-      (.killTopology nimbus "test")
-      (Thread/sleep 10000)
-      )))
+(deftest test-python
+(test-multilang "python" "py")
+)
+
+(deftest test-ruby
+(test-multilang "ruby" "rb")
+)


Fix missing context argument in async Jetty

--- ring-jetty-adapter/src/ring/adapter/jetty.clj
+++ ring-jetty-adapter/src/ring/adapter/jetty.clj
@@ -33,7 +33,7 @@
         (handler
          (servlet/build-request-map request)
          (fn [response-map]
-           (servlet/update-servlet-response response response-map)
+           (servlet/update-servlet-response response context response-map)
            (.setHandled base-request true))
          (fn [^Throwable exception]
            (.sendError response 500 (.getMessage exception))


Restore the default for header.

Restore the default for header.

Something funky funk is going on here that I don't have time to debug at
the moment.

--- src/frmr/dstt.clj
+++ src/frmr/dstt.clj
@@ -135,6 +135,7 @@

    [nil "--header HEADER" "HTTP header to set, multiple possible."
     :id :headers
+    :default {}
     :parse-fn parse-header
     :assoc-fn (fn [map key value]
                 (update-in map


List connected rooms in room intro.

List connected rooms in room intro.

--- src/isla/talk.clj
+++ src/isla/talk.clj
@@ -3,10 +3,12 @@
   (:require [clojure.string :as str])
   (:require [mrc.utils :as utils]))

-(defn room-intro [room]
 (declare list-rooms)
+
+(defn room-intro [room connected-rooms]
   (str "You are in the " (:name room) ". "
-       (:summary room)))
+       (:summary room) " "
+       "You can see doors leading to " (list-rooms connected-rooms)))

 (defn room-already [name] (str "You are already in the " name "."))
 (defn room-not-allowed [name] (str "You cannot go into the " name "."))


composition of injections

composition of injections

--- src/latte/rel.clj
+++ src/latte/rel.clj
@@ -14,7 +14,7 @@
   (:refer-clojure :exclude [and or not])

   (:require [latte.core :as latte :refer [definition defaxiom defthm
-                                          forall ==>
+                                          forall lambda ==>
                                           proof assume have]]
             [latte.prop :as p :refer [and or not]]
             [latte.equal :as eq :refer [equal]]
@@ -92,3 +92,36 @@
     (have a (injective T U F) :by (p/%and-elim-left H))
     (qed a)))

+
+(definition compose
+  "The composition of two functions."
+  [[T :type] [U :type] [V :type]
+   [f (==> U V)] [g [==> T U]]]
+  (lambda [x T] (f (g x))))
+
+(defthm compose-injective
+  "The composition of two injective functions is injective."
+  [[T :type] [U :type] [V :type]
+   [f (==> U V)] [g [==> T U]]]
+  (==> (injective U V f)
+       (injective T U g)
+       (injective T V (compose T U V f g))))
+
+(proof compose-injective
+    :script
+  (assume [Hf (injective U V f)
+           Hg (injective T U g)]
+    (assume [x T
+             y T
+             Hinj (equal V
+                         ((compose T U V f g) x)
+                         ((compose T U V f g) y))]
+      (have <a> (equal V (f (g x)) (f (g y))) :by Hinj)
+      (have <b> (equal U (g x) (g y))
+            :by (Hf (g x) (g y) <a>))
+      (have <c> (equal T x y)
+            :by (Hg x y <b>))
+      (have <d> (injective T V (compose T U V f g))
+            :discharge [x y Hinj <c>]))
+    (qed <d>)))
+


Inbox: Remove `accepts-drop?' (and indicate failure by returning false).

--- src-cljs/pepa/workflows/inbox2.cljs
+++ src-cljs/pepa/workflows/inbox2.cljs
@@ -27,7 +27,6 @@
   (remove-pages! [_ state page-ids]))

 (defprotocol ColumnDropTarget
-  (accepts-drop? [_ state])     ;can't get data in drag-over
   (accept-drop!  [_ state pages]))

 (defrecord InboxColumnSource [id]
@@ -49,13 +48,13 @@
                               (remove #(contains? page-ids (:id %)))
                               pages))))))
   ColumnDropTarget
-  (accepts-drop? [_ state]
-    true)
   ;; TODO: Make immutable?
   (accept-drop! [_ state new-pages]
     (go
       (println "dropping" (pr-str new-pages) "on inbox")
-      (<! (api/add-to-inbox! (map :id new-pages)))))
+      (<! (api/add-to-inbox! (map :id new-pages)))
+      ;; Return true, indicating successful drop
+      true))
   om/IWillMount
   (will-mount [_]
     (api/fetch-inbox!)))
@@ -76,15 +75,15 @@
         (js/console.error (str "[DocumentColumnSource] Failed to get document " document-id)
                           {:document-id document-id}))))
   ColumnDropTarget
-  (accepts-drop? [_ state]
-    true)
   (accept-drop! [_ state new-pages]
     (go
       (println "dropping" (pr-str new-pages) "on document" document-id)
       (let [document (om/value (get-in state [:documents document-id]))]
         (<! (api/update-document! (update document :pages
                                           #(into % new-pages))))
-        (println "Saved!"))))
+        (println "Saved!")
+        ;; indicate successful drop
+        true)))
   om/IWillMount
   (will-mount [_]
     (assert (number? document-id))
@@ -165,14 +164,14 @@
                        (selection/make-selection new-pages)))))
   (render-state [_ {:keys [selection handle-drop!]}]
     ;; NOTE: `column' needs to be a value OR we need to extend cursors
-    [:.column {:on-drag-over (when (satisfies? ColumnDropTarget (om/value column))
-                               (fn [e]
-                                 (when (accepts-drop? column state)
-                                   (.preventDefault e))))
+    [:.column {:on-drag-over (fn [e]
+                               (when (satisfies? ColumnDropTarget (om/value column))
+                                 (.preventDefault e)))
                :on-drag-start (partial column-drag-start state column owner)
                :on-drag-end (fn [_]
                               (println "on-drag-end"))
                :on-drop (fn [e]
+                          (println "on-drop")
                           (let [page-cache (::page-cache column)
                                 source-column (get-transfer-data e "application/x-pepa-column")
                                 page-ids (get-transfer-data e "application/x-pepa-pages")]
@@ -189,7 +188,6 @@
                      :fn (partial mark-page-selected (:selected selection))})]]))

 (defn ^:private inbox-handle-drop! [state owner page-cache target source page-ids]
-  ;; Call `accepts-drop!' in `target'
   (let [columns (om/get-state owner :columns)
         target (get columns target)
         source (get columns source)
@@ -201,13 +199,16 @@
                           (map om/value))
                     page-ids)]
     (if-not (seq pages)
+      ;; TODO: Should we do that in the columns itself?
       (js/console.warn "Ignoring drop consisting only of duplicate pages:"
                        (pr-str page-ids))
       (go
-        (<! (accept-drop! target state pages))
-        (println "Target saved. Removing from source...")
-        (<! (remove-pages! source state page-ids))
-        (println "Drop saved!")))))
+        (if (<! (accept-drop! target state pages))
+          (do
+            (println "Target saved. Removing from source...")
+            (<! (remove-pages! source state page-ids))
+            (println "Drop saved!"))
+          (js/console.warn "`accept-drop!' returned non-truthy value. Aborting drop."))))))

 (defn ^:private make-page-cache [state columns]
   (into {}


Simple infinite scrolling for the dashboard.

--- src-cljs/pepa/workflows/dashboard.cljs
+++ src-cljs/pepa/workflows/dashboard.cljs
@@ -65,28 +65,11 @@
      (catch js/Error e nil))
    1))

+(def +per-page+ 20)
+
 (defn ^:private page-ids [state]
   (let [page (parse-page state)]
-    (pagination/page-items (document-ids state)
-                           page)))
-
-(defn ^:private change-page-buttons [state owner _]
-  (om/component
-   (let [page (parse-page state)
-         page-count (pagination/pages (document-ids state))
-         navigation (:navigation state)
-         route-fn (fn [page]
-                    (-> navigation
-                        (assoc-in [:query-params :page] page)
-                        (nav/nav->route)))]
-     (html
-      [:nav.page
-       [:a.button.prev {:class [(when (<= page 1)
-                                  "disabled")]
-                        :href (route-fn (dec page))}]
-       [:a.button.next {:class [(when (>= page page-count)
-                                  "disabled")]
-                        :href (route-fn (inc page))}]]))))
+    (take (* +per-page+ page) (document-ids state))))

 (defn ^:private fetch-missing-documents!
   "Fetches all missing documents which will be visible in the
@@ -108,25 +91,30 @@
     (go (search/clear-results! state))))

 (defn ^:private dashboard-title [state]
-  (let [documents (document-ids state)
-        page (parse-page state)
-        [start end] (pagination/page-range documents page)]
+  (let [documents (document-ids state)]
     (cond
      (search/search-query state)
      "Search Results"

      true
-     "Dashboard ")))
+     "Dashboard")))

-(defn ^:private document-page-count-label [state _ _]
-  (om/component
-   (html
-    (let [documents (document-ids state)
-          page (parse-page state)
-          [start end] (pagination/page-range documents page)]
-      [:span.document-count
-       (when (and start end)
-         (str "(" start "-" end " of " (count documents) ")"))]))))
+;;; Should be twice the document-height or so.
+(def +scroll-margin+ 400)
+
+(defn on-documents-scroll [state owner e]
+  (let [container e.currentTarget
+        scroll-top (.-scrollTop container)
+        scroll-height (.-scrollHeight container)
+        outer-height (.-clientHeight container)
+        bottom-distance (Math/abs (- scroll-height
+                                     (+ scroll-top outer-height)))]
+    (when (< bottom-distance +scroll-margin+)
+      (let [page (parse-page state)]
+        (nav/navigate! (-> (:navigation state)
+                           (assoc-in [:query-params :page] (inc page))
+                           (nav/nav->route)
+                           (nav/navigate!)))))))

 (defn dashboard [state owner]
   (reify
@@ -142,8 +130,7 @@
         (<! (fetch-missing-documents! state owner))))
     om/IInitState
     (init-state [_]
-      {:sort/key :id
-       :filter-width css/default-right-sidebar-width})
+      {:filter-width css/default-right-sidebar-width})
     om/IRenderState
     (render-state [_ local-state]
       ;; Show all documents with ids found in :dashboard/document-ids
@@ -152,14 +139,12 @@
          [:.workflow.dashboard
           [:.pane {:style {:width (str "calc(100% - " (:filter-width local-state) "px - 2px)")}}
            [:header
-            (dashboard-title state)
-            (om/build document-page-count-label state)
-            (om/build change-page-buttons state)]
-           [:.documents {:class ["col-3"]}
+            (dashboard-title state)]
+           [:.documents {:class ["col-3"]
+                         :on-scroll (partial on-documents-scroll state owner)}
             (let [documents (->> document-ids
                                  (map (partial get (:documents state)))
-                                 (remove nil?)
-                                 (sort-by (:sort/key local-state)))]
+                                 (remove nil?))]
               (om/build-all document-preview documents
                             {:key :id}))]]
           [:.pane {:style {:width (:filter-width local-state)}}


Always disable template caching in development

Do we really want our templates to be cached when we are developing? I
think not.


make search not care about case

make search not care about case

--- cljs-client/cljsinfo_client/cheatsheet.cljs
+++ cljs-client/cljsinfo_client/cheatsheet.cljs
@@ -76,7 +76,7 @@

 (defn- toggle-fn-link [el search-txt]
   (let [$link ($ el)
-        link-txt (.text $link)
+        link-txt (-> $link .text .toLowerCase)
         match? (not= -1 (.indexOf link-txt search-txt))]
     (if match?
       (.addClass $link matched-search-class)
@@ -126,7 +126,7 @@
       (reset! current-size new-size))))

 (defn- keydown-search-input2 []
-  (let [txt (.val ($ search-input-sel))]
+  (let [txt (-> ($ search-input-sel) .val .toLowerCase)]
     (when (not= txt @current-search-txt)
       (reset! current-search-txt txt))))


Different permutation implementation via tree-seq

--- clojure/org/gavrog/clojure/permutations.clj
+++ clojure/org/gavrog/clojure/permutations.clj
@@ -1,14 +1,17 @@
 (ns org.gavrog.clojure.permutations)

-(defn positions [coll x]
-  (keep-indexed #(when (= %2 x) %1) coll))
-
 (defn permutations [degree]
-  (let [complete? #(empty? (positions %1 false))
+  (let [keys (range 1 (inc degree))
+        complete? (comp empty? :unused)
         branch? (comp not complete?)
-        children (fn [perm]
-                   (when-let [i (first (positions perm false))]
-                     (for [n (range degree) :when (empty? (positions perm n))]
-                       (assoc perm i n))))
-        root (into [] (repeat degree false))]
-    (filter complete? (tree-seq branch? children root))))
+        children (fn [node]
+                   (let [{:keys [perm unused unseen]} node]
+                     (when-let [i (first unused)]
+                       (for [n unseen]
+                         {:perm (assoc perm i n)
+                          :unused (disj unused i)
+                          :unseen (disj unseen n)}))))
+        root {:perm {}
+              :unused (into #{} keys)
+              :unseen (into #{} keys)}]
+    (map :perm (filter complete? (tree-seq branch? children root)))))


Une solution à l'exercice 'Luhn' de Exercism dans la track Clojure

--- exercism/clojure/luhn/src/luhn.clj
+++ exercism/clojure/luhn/src/luhn.clj
@@ -1,5 +1,30 @@
-(ns luhn)
+(ns luhn
+  (:require [clojure.string :as str]))

-(defn valid? [] ;; <- arglist goes here
-  ;; your code goes here
-)
+(defn clean
+  "Remove all spaces from the string arguments 'id'"
+  [id]
+  (str/replace id #"\s+" ""))
+
+(defn calculate-luhn-sum
+  "Caculate the sum of all the digit of the given argument 'id' following the Luhn formula"
+  [id]
+  (->> id
+       (map #(Character/getNumericValue %1))
+       (reverse)
+       (map-indexed vector)
+       (map #(if (not= 0 (rem (first %1) 2)) (let [product (* 2 (second %1))] (if (> product 9) (- product 9) product)) (second %1)))
+       (reduce + )))
+
+(defn check
+  "Check whether the well-formed argument 'id' (composed only of numbers) respect the Luhn Formula"
+  [id]
+  (= 0 (rem (calculate-luhn-sum id) 10)))
+
+(defn valid?
+  "Check whether the given argument 'id' is valid per the Luhn formula"
+  [id]
+  (let [id (clean id)]
+    (cond
+      (or (= 1 (count id)) (nil? (re-matches #"^\d+$" id))) false
+      :else (check id))))


Very basic and PoC websocket client implemented using chord

--- src/cljs/hellhound/websocket/core.cljs
+++ src/cljs/hellhound/websocket/core.cljs
@@ -11,6 +11,7 @@

 (defn connect-to
   [address {:keys [read-buffer write-buffer data-format]}]
+  (js/console.log "XXX" data-format)
   (ws-ch address
          {:read-ch (async/chan read-buffer)
           :write-ch (async/chan write-buffer)
@@ -22,4 +23,8 @@
   ([address options]
    (let [config (merge default-ws-config options)]
      (go
-       (let [{:keys [ws-channel connection-error]} (<! (connect-to address))])))))
+       (let [{:keys [ws-channel connection-error]} (<! (connect-to address config))]
+         (if connection-error
+           (js/console.log "Can't connect to the server.")
+           (>! ws-channel {:a 1})
+           (js/console.log "Got message from server" (pr-str (<! ws-channel)))))))))


typing is hard

typing is hard

--- src/cljs/main/broadfcui/endpoints.cljs
+++ src/cljs/main/broadfcui/endpoints.cljs
@@ -378,7 +378,7 @@
    (str "/link/v1/" provider)
    {:on-done on-done}))

-(defn profile-link-fence-account [provider oauth-code oath-state redirect-uri on-done ]
+(defn profile-link-fence-account [provider oauth-code oauth-state redirect-uri on-done ]
   (ajax/call-bond
    (str "/link/v1/" provider "/oauthcode?oauthcode=" oauth-code "&redirect_uri=" redirect-uri "&state=" oauth-state)
    {:method :post


Provide a default play-note.

Provide a default play-note.

--- src/african_polyphony_and_polyrhythm/talk.clj
+++ src/african_polyphony_and_polyrhythm/talk.clj
@@ -301,7 +301,7 @@
 (defmethod live/play-note :father [_]
   (drum 75 :pan 0 :vol 1.0))

-(definst whistle [freq 660 vol 0.5 pan 0 dur 0.5]
+(definst whistle [freq 880 vol 0.5 pan 0 dur 0.2]
   (-> (sin-osc freq)
       (+ (* 1/2 (sin-osc 3) (sin-osc (* 3.01 freq))))
       (+ (* 1/5 (sin-osc (* 2 freq))))
@@ -315,3 +315,6 @@

 (defmethod live/play-note :horn [{:keys [pitch pan duration]}]
   (whistle :freq pitch :pan (or pan 0) :dur (min duration 0.2)))
+
+(defmethod live/play-note :default [note]
+  (-> note (assoc :part :horn) live/play-note))


bug fix

bug fix

--- src/io/perun/contrib/images_resize.clj
+++ src/io/perun/contrib/images_resize.clj
@@ -18,7 +18,7 @@
       (perun/extension file-path)))

 (defn ^String new-image-filepath [file-path filename new-filename]
-  (str (perun/parent-path file-path new-filename)
+  (str (perun/parent-path file-path filename)
        "/"
        new-filename))


#1 to path

#1 to path

--- src/kalar_plugins/templates/hiccup.clj
+++ src/kalar_plugins/templates/hiccup.clj
@@ -3,15 +3,22 @@
             [kalar-core.config :as config]))

 (defprotocol HiccupPlugin
-  (hiccup-compile [this] [this x]))
+  (hiccup-compile [this]))

 (plugin/defkalar-plugin
   hiccup
   plugin/KalarPlugin
-  (load-plugin [this] (println (config/read-config))))
+  (load-plugin
+    [this]
+    (let [hpnamespace (:template-hiccup-ns (config/read-config))]
+      (require hpnamespace)
+      (dorun
+        (for [f (filter #(satisfies? HiccupPlugin (-> % var-get))
+                        (-> hpnamespace ns-publics vals))]
+          (hiccup-compile (var-get f)) )))))

-(defmacro hiccup [args & body]
-  `(defn hiccup# []
-      (reify HiccupPlugin (hiccup-compile ~(into ['this] args) ~@body)
-        )))
+
+(defmacro def-template [& body]
+  `(def hiccup#
+      (reify HiccupPlugin (hiccup-compile [this] ~@body))))


Better document things in project.clj

Better document things in project.clj

--- src/leiningen/new/chestnut/project.clj
+++ src/leiningen/new/chestnut/project.clj
@@ -26,15 +26,20 @@

   :uberjar-name "{{{name}}}.jar"

+  ;; Use `lein run` if you just want to start a HTTP server, without figwheel
   :main {{{project-ns}}}.server

-  :repl-options {:init-ns {{{project-ns}}}.server}
+  ;; nREPL by default starts in the :main namespace, we want to start in `user`
+  ;; because that's where our development helper functions like (run) and
+  ;; (browser-repl) live.
+  :repl-options {:init-ns user}

   :cljsbuild {:builds
               [{:id "app"
                 :source-paths ["src/cljs"]

-                :figwheel {:on-jsload "{{{project-ns}}}.core/main"}
+                ;; You can configure a function to run every time figwheel reloads.
+                ;; :figwheel {:on-jsload "{{{project-ns}}}.core/on-figwheel-reload"}

                 :compiler {:main {{{project-ns}}}.core
                            :asset-path "js/compiled/out"
@@ -42,12 +47,41 @@
                            :output-dir "resources/public/js/compiled/out"
                            :source-map-timestamp true}}]}

-  :figwheel {:css-dirs ["resources/public/css"]
-             :ring-handler {{{project-ns}}}.server/http-handler}
+  ;; When running figwheel from nREPL, figwheel will read this configuration
+  ;; stanza, but it will read it without passing through leiningen's profile
+  ;; merging. So don't put a :figwheel section under the :dev profile, it will
+  ;; not be picked up, instead configure figwheel here on the top level.

-  :env {:is-dev true
-        :browser-caching {"text/javascript" 0
-                          "text/html" 0}}{{#less?}}
+  :figwheel {;; :http-server-root "public"       ;; serve static assets from resources/public/
+             ;; :server-port 3449                ;; default
+             ;; :server-ip "127.0.0.1"           ;; default
+             :css-dirs ["resources/public/css"]  ;; watch and update CSS
+
+             ;; Instead of booting a separate server on its own port, we embed
+             ;; the server ring handler inside figwheel's http-kit server, so
+             ;; assets and API endpoints can all be accessed on the same host
+             ;; and port. If you prefer a separate server process then take this
+             ;; out and start the server with `lein run`.
+             :ring-handler user/http-handler
+
+             ;; Start an nREPL server into the running figwheel process. We
+             ;; don't do this, instead we do the opposite, running figwheel from
+             ;; an nREPL process, see
+             ;; https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-within-NRepl
+             ;; :nrepl-port 7888
+
+             ;; To be able to open files in your editor from the heads up display
+             ;; you will need to put a script on your path.
+             ;; that script will have to take a file path and a line number
+             ;; ie. in  ~/bin/myfile-opener
+             ;; #! /bin/sh
+             ;; emacsclient -n +$2 $1
+             ;;
+             ;; :open-file-command "myfile-opener"
+
+             ;; to configure a different figwheel logfile path
+             ;; :server-logfile "tmp/logs/figwheel-logfile.log"
+             }{{#less?}}

   :less {:source-paths ["src/less"]
          :target-path "resources/public/css"}{{/less?}}{{#sass?}}


simplified ag state

simplified ag state

--- src/frontend/cljs/alibi/activity_graphic.cljs
+++ src/frontend/cljs/alibi/activity_graphic.cljs
@@ -743,15 +743,14 @@
     (render [_]
       (let [entries (om/observe owner (state/entries))
             entry-screen-form (om/observe owner (state/entry-screen-form))
-            selected-entry (get-selected-entry entry-screen-form)]
-        (render-graphic (-> (select-keys state [:dispatch!])
-                            (assoc :selected-entry (when selected-entry
-                                                     (:entry-id selected-entry))
-                                   :additional-entries (when selected-entry
-                                                         [selected-entry]))
-                            (assoc-in [:project-data :data] entries)
-                            (assoc-in [:project-data :selected-date]
-                                      (get-in entry-screen-form [:selected-date :date]))))))))
+            selected-entry (get-selected-entry entry-screen-form)
+            selected-date (get-in entry-screen-form [:selected-date :date])]
+        (render-graphic
+          {:dispatch! (:dispatch! state)
+           :selected-entry (when selected-entry (:entry-id selected-entry))
+           :additional-entries (when selected-entry [selected-entry])
+           :project-data {:data entries
+                          :selected-date selected-date}})))))

 (defn render-tooltip
   [state owner]
@@ -764,8 +763,7 @@

             selected-entry (get-selected-entry entry-screen-form)
             project-data (merge-entries entries
-                                        (when selected-entry
-                                          [selected-entry]))
+                                        (when selected-entry [selected-entry]))
             entry-id (:entry-id mouse-over-entry)
             {:keys [left top width]} (:pos mouse-over-entry)
             comment (->> project-data


Change defschema to return the schema name

--- src/main/cljc/mikron/runtime/core.cljc
+++ src/main/cljc/mikron/runtime/core.cljc
@@ -14,11 +14,11 @@

 (defonce ^:private registry-ref (atom {}))

-(defn registered-schema!
+(defn register-schema!
   "Registers a reified schema with the given name."
   [schema-name ^Schema schema]
   (swap! registry-ref assoc schema-name schema)
-  schema)
+  schema-name)

 (defonce ^:private local-registry-ref (atom {}))

@@ -72,7 +72,7 @@
     "Globally registers a reified schema for the given schema definition, with the given name."
     [& args]
     (let [{:keys [schema-name schema global-options]} (util/enforce-spec ::runtime.core-spec/defschema-args args)]
-      `(registered-schema! ~schema-name ~(schema* schema global-options)))))
+      `(register-schema! ~schema-name ~(schema* schema global-options)))))

 (def ^:dynamic ^:private *buffer*
   "The default buffer with a 10Kb size."


Add before/after macros to describe

Add before/after macros to describe

--- src/main/clojure/lazytest/describe.clj
+++ src/main/clojure/lazytest/describe.clj
@@ -106,6 +106,14 @@
 		    ~metadata)
 		  ~@binding-symbols)))))))

+(defmacro before
+  [& body]
+  `(fn-context (fn [] ~@body) (constantly nil)))
+
+(defmacro after
+  [& body]
+  `(fn-context (constantly nil) (fn [] ~@body)))
+
 (defmacro it
   "Defines a single test case.


verwwerken zip-stream

verwwerken zip-stream

--- src/main/clojure/pdok/featured/api.clj
+++ src/main/clojure/pdok/featured/api.clj
@@ -18,7 +18,10 @@
             [ring.middleware.defaults :refer :all]
             [ring.middleware.json :refer :all]
             [ring.util.response :as r]
-            [schema.core :as s]))
+            [schema.core :as s])
+  (:import  [java.util.zip ZipInputStream]
+            [java.io FileInputStream])
+   )

 (extend-protocol cheshire.generate/JSONable
   org.joda.time.DateTime
@@ -57,15 +60,38 @@
   (when (:callback request)
           (go (>! callback-chan [(:callback request) stats]))))

+(defn feature-stream-zip [request])
+
+(defmulti feature-stream (fn [request] "json"))
+(defmethod feature-stream "json" [request]
+   (io/input-stream (:file request)))
+(defmethod feature-stream :default [request] nil)
+
+
+(defn- input-zip [input]
+  (let [in (ZipInputStream. input)
+       ze (.getNextEntry in)]
+  in))
+
+(defn- close-zip [zip]
+    (do (.closeEntry zip)
+        (.close zip)))
+
+
 (defn- process* [stats callback-chan request]
   (log/info "Processsing: " request)
   (swap! stats assoc-in [:processing] request)
   (let [persistence (config/persistence)
         projectors (config/projectors persistence)
-        processor (processor/create persistence projectors)]
-    (try (with-open [in (io/input-stream (:file request))]
-           (let [features (reader/features-from-stream in :dataset (:dataset request))
-                 _ (dorun (consume processor features))
+        processor (processor/create persistence projectors)
+        request-file (:file request)
+        zip-file? (.endsWith request-file ".zip")]
+    (try
+          (with-open [input (io/input-stream (:file request))]
+            (let [in (if zip-file? (input-zip input) input)
+                  features (reader/features-from-stream in :dataset (:dataset request))
+                  _ (dorun (consume processor features))
+                  _ (if zip-file? (close-zip in))
                  processor (shutdown processor)
                  run-stats (assoc (:statistics processor) :request request)]
              (swap! stats update-in [:processed] #(conj % run-stats))


Update PMD ontology to include attachments

--- src/ontologies/grafter/rdf/ontologies/pmd.clj
+++ src/ontologies/grafter/rdf/ontologies/pmd.clj
@@ -6,9 +6,18 @@
 (def pmd                 (prefixer "http://publishmydata.com/def/dataset#"))

 (def pmd:Dataset         (pmd "Dataset"))
+(def pmd:LinkedDataset   (pmd "LinkedDataset"))
+(def pmd:FileDataset     (pmd "FileDataset"))
+(def pmd:DeprecatedDataset (pmd "DeprecatedDataset"))

 (def pmd:contactEmail    (pmd "contactEmail"))
 (def pmd:graph           (pmd "graph"))
+
+(def pmd:fileName (pmd "fileName"))
+(def pmd:fileExtension (pmd "fileExtension"))
+(def pmd:mediaType (pmd "mediaType"))
+(def pmd:sizeInBytes (pmd "sizeInBytes"))
+(def pmd:downloadURL (pmd "downloadURL"))

 (def folder              (prefixer "http://publishmydata.com/def/ontology/folder/"))


Fixed scoping issue

Fixed scoping issue

--- src/aws_overlord/logic/accounts.clj
+++ src/aws_overlord/logic/accounts.clj
@@ -77,9 +77,9 @@
     (login-to account
               (log/info "Performing account-wide actions")
               (security/run account)
-              (dns/run account))
-    (doseq [{:keys [region] :as network} networks]
-      (switch-to region
-                 (log/info "Performing region-wide actions in" region)
-                 (networking/run account network)
-                 (peering/run account network existing-accounts)))))+              (dns/run account)
+              (doseq [{:keys [region] :as network} networks]
+                (switch-to region
+                           (log/info "Performing region-wide actions in" region)
+                           (networking/run account network)
+                           (peering/run account network existing-accounts))))))


Add some explicit type checks for synthdef manipulation fns.

--- src/overtone/sc/machinery/synthdef.clj
+++ src/overtone/sc/machinery/synthdef.clj
@@ -127,6 +127,11 @@

 (defn synthdef? [obj] (= ::synthdef (type obj)))

+(defn ensure-synthdef!
+  [obj]
+  (when-not (synthdef? obj)
+    (throw (IllegalArgumentException. (str "Error, was expecting a synthdef, found: " (type obj))))))
+
 (defn- supercollider-synthdef-path
   "Returns a constructed path to a named synthdef on the current platform"
   [synth-name]
@@ -153,6 +158,7 @@
   "Write a synth definition to a new file at the given path, which includes
   the name of the file itself.  (e.g. /home/rosejn/synths/bass.scsyndef)"
   [sdef path]
+  (ensure-synthdef! sdef)
   (let [path (resolve-tilde-path path)]
     (spec-write-file synthdef-file-spec (synthdef-file sdef) path)))

@@ -160,6 +166,7 @@
   "Produces a serialized representation of the synth definition understood
   by SuperCollider, and returns it in a byte array."
   [sdef]
+  (ensure-synthdef! sdef)
   (spec-write-bytes synthdef-file-spec
     (cond
       (synthdef? sdef) (synthdef-file sdef)
@@ -187,6 +194,7 @@
     (synthdef-print synth)))

 (defn synthdef-print [s]
+  (ensure-synthdef! s)
   (println
     "  name: "          (:name s)
     "\n  n-constants: " (:n-constants s)
@@ -203,6 +211,7 @@
   "Returns the set of control parameter name/default-value pairs for a synth
   definition."
   [sdef]
+  (ensure-synthdef! sdef)
   (let [names (map #(keyword (:name %1)) (:pnames sdef))
         vals (:params sdef)]
   (apply hash-map (interleave names vals))))
@@ -221,7 +230,7 @@
   synthdef loading is delayed until the server has succesfully
   connected."
   [sdef]
-  (assert (synthdef? sdef))
+  (ensure-synthdef! sdef)
   (dosync (alter loaded-synthdefs* assoc (:name sdef) sdef))

   (when (server-connected?)


Add agent string to resolver.

Add agent string to resolver.

--- src/chronograph/import/resolver.clj
+++ src/chronograph/import/resolver.clj
@@ -35,7 +35,8 @@
                                                           :throw-exceptions true
                                                           :socket-timeout 5000
                                                           :conn-timeout 5000
-                                                          :headers {"Referer" "chronograph.crossref.org"}}))
+                                                          :headers {"Referer" "chronograph.crossref.org"
+                                                                    "User-Agent" "CrossRefDOICheckerBot (labs@crossref.org)"}}))
           ; Drop the initial dx.doi.org
           redirects (rest (:trace-redirects result))
           first-redirect (first redirects)


display of local state

display of local state

--- src/cljs/netrunner/cardbrowser.cljs
+++ src/cljs/netrunner/cardbrowser.cljs
@@ -23,18 +23,11 @@
 (defn set-view [{:keys [name]} owner]
   (reify
     om/IRenderState
-    (render-state [this {:keys [set-filter]}]
-      (sab/html
-       [:div {:class (if (= set-filter name) "active" "")
-              :on-click #(om/set-state! owner :set-filter name)} name]))))
-
-(defn set-list-view [cursor owner]
-  (reify
-    om/IRenderState
     (render-state [this state]
       (sab/html
-       [:div.blue-shade.panel.set-list {}
-        (om/build-all set-view (:sets cursor) {:init-state state})]))))
+       [:div {:class (if (= (:set-filter state) name) "active" "")
+              :on-click #(om/set-state! owner [:set-filter] name)}
+        name]))))

 (defn card-view [card owner]
   (om/component
@@ -49,6 +42,9 @@
     [:div.card-list
      (om/build-all card-view cards)])))

+(defn handle-change [e owner {:keys [set-filter]}]
+  (om/set-state! owner :set-filter (.. e -target -value)))
+
 (defn card-browser-app [cursor owner]
   (reify
     om/IInitState
@@ -56,14 +52,18 @@
       {:set-filter "Core Set"})

     om/IRenderState
-    (render-state [this {:keys [set-filter]}]
+    (render-state [this state]
       (sab/html
        [:div.cardbrowser
-        (om/build set-list-view cursor {:init-state {:set-filter set-filter}})
+        [:input {:type "text" :value (:set-filter state)
+                 :on-change #(handle-change % owner state)}]
+        [:div.blue-shade.panel.set-list {}
+         (om/build-all set-view (:sets cursor) {:init-state state})]
         [:div.main
          ;;  (om/build filter-view cursor)
          (om/build card-list-view
-                   (let [cards (:cards cursor)]
+                   (let [set-filter (:set-filter state)
+                         cards (:cards cursor)]
                      (if (zero? (alength set-filter))
                        cards
                        (filter #(= (:setname %) set-filter) cards))))]]))))


Add tag for ID

Add tag for ID

--- src/cljs/onyx_cheat_sheet/core.cljs
+++ src/cljs/onyx_cheat_sheet/core.cljs
@@ -195,7 +195,7 @@
            (g/grid
             {}
             (g/row
-             {}
+             {:id "cheat-sheet-block"}
              (g/col
               {:xs 18 :md 3}
               (r/well


Faster search

Faster search

--- src/cljs/onyx_cheat_sheet/core.cljs
+++ src/cljs/onyx_cheat_sheet/core.cljs
@@ -223,8 +223,8 @@
                                 {:id "summary" :bs-style "primary" :class "summary-doc" :header (dom/h3 nil (str (model-names section) " Summary"))}
                                 (get-in model [section :summary])))]
                            (for [k (model-display-order section)]
-                             (if (get-in model [section :model k])
-                               (om/build display-feature {:section section :key k}))))))))
+                             (dom/div (if (get-in model [section :model k]) #js {} #js {:style #js {:display "none"}})
+                                      (om/build display-feature {:section section :key k}))))))))

 (defcomponent feature-options [{:keys [model section]} owner]
   (render [_]


Test match with symbols that mean strings.

--- test/active/clojure/match_test.clj
+++ test/active/clojure/match_test.clj
@@ -292,48 +292,48 @@
               {:x 42})))))

 (def x "x")
-(p/defpattern constant-pattern [(:x x)])
-(def p (p/parse-pattern '[(:x x)]))
+(p/defpattern constant-pattern [(X x)])
+(def p (p/parse-pattern '[(X x)]))

 (t/deftest closes-over-outer-variables-test
   (t/testing "with compare-fn"
-    (let [evt {:x "x"}]
+    (let [evt {"X" "x"}]
       (t/is (= "x"
-               ((p/map-matcher [(:x (:compare-fn #(= % (:x evt))))] x)
+               ((p/map-matcher [(X (:compare-fn #(= % (get evt "X"))))] x)
                 evt)))))
   (t/testing "as local constant"
     (let [x   "x"
-          evt {:x x}]
-      (t/is (= x
-               ((p/map-matcher [(:x x)] x)
+          evt {"X" x}]
+      (t/is (= x
+               ((p/map-matcher [(X x)] x)
                 evt)))))
   (t/testing "as global constant"
-    (let [evt {:x x}]
-      (t/is (= x
-               ((p/map-matcher [(:x x)] x)
+    (let [evt {"X" x}]
+      (t/is (= x
+               ((p/map-matcher [(X x)] x)
                 evt)))))
   (t/testing "as constant with global defpattern"
     (let [x   "x"
-          evt {:x x}]
+          evt {"X" x}]
       (t/is (= x
                ((p/map-matcher constant-pattern x)
                 evt)))))
   (t/testing "as constant with global parse-pattern"
-    (let [evt {:x x}]
+    (let [evt {"X" x}]
       (t/is (= x
                ((p/map-matcher p x)
                 evt)))))
   (t/testing "as constant with global defpattern"
     (let [x   "x"
-          evt {:x x}]
-      (p/defpattern p [(:x x)])
+          evt {"X" x}]
+      (p/defpattern p [("X" x)])
       (t/is (= x
                ((p/map-matcher p x)
                 evt)))))
   #_(t/testing "as constant with local parse-pattern"
     (let [x   "x"
-          evt {:x x}
-          p   (p/parse-pattern [(:x x)])]
+          evt {"X" x}
+          p   (p/parse-pattern [(X x)])]
       (t/is (= x
                ((p/map-matcher p x)
                 evt))))))


strip punctuation in one step

strip punctuation in one step

--- src/vip/data_processor/db/postgres.clj
+++ src/vip/data_processor/db/postgres.clj
@@ -138,8 +138,7 @@
                         (map #(str/trim %))
                         (map #(Normalizer/normalize % java.text.Normalizer$Form/NFKD))
                         (map #(str/replace % #"\p{Space}" "-"))
-                        (map #(str/replace % #"[\p{Punct}&&[^-]]" "%"))
-                        (map #(str/replace % #"[\P{ASCII}%]" "")))]
+                        (map #(str/replace % #"[\p{Punct}\P{ASCII}&&[^-]]" "")))]
     (if (empty? good-parts)
       (str "invalid-" import-id)
       (str/join "-" (concat good-parts [import-id])))))


Better variable name

Better variable name

--- test/icecap/handlers/http_test.clj
+++ test/icecap/handlers/http_test.clj
@@ -12,8 +12,8 @@

 (deftest schema-tests
   (testing "valid steps"
-    (are [x] (nil? (check-plan x))
          step)))
+    (are [s] (nil? (check-plan s))

 (def fake-response
   {})


correct income statement test expectations

--- test/clj_money/models/reports_test.clj
+++ test/clj_money/models/reports_test.clj
@@ -204,7 +204,7 @@
                    :style :data
                    :depth 0}
                   {:caption "Expense"
-                   :value (bigdec 1200)
+                   :value (bigdec 1754)
                    :style :header}
                   {:caption "Groceries"
                    :value (bigdec 500)
@@ -214,7 +214,23 @@
                    :value (bigdec 700)
                    :style :data
                    :depth 0}
+                  {:caption "Taxes"
+                   :value (bigdec 554)
+                   :style :data
+                   :depth 0}
+                  {:caption "FIT"
+                   :value (bigdec 400)
+                   :style :data
+                   :depth 1}
+                  {:caption "Medicare"
+                   :value (bigdec 30)
+                   :style :data
+                   :depth 1}
+                  {:caption "Social Security"
+                   :value (bigdec 124)
+                   :style :data
+                   :depth 1}
                   {:caption "Net"
-                   :value (bigdec 803)
+                   :value (bigdec 249)
                    :style :summary}]]
     (is (= expected actual) "The report renders the corect data")))


cleanup scrape bulbs

cleanup scrape bulbs

--- src/bonews_rest/scraper/bulbs.clj
+++ src/bonews_rest/scraper/bulbs.clj
@@ -5,15 +5,15 @@

 (def link-href [[:a (html/attr? :href)]])

-(defn bulbs-clickable?
+(defn can-scrape-bulbs?
   []
-  (web/click (web/find-element {:css "input.bo_knows_bulbs_view_votes"}))
+  (web/click "input.bo_knows_bulbs_view_votes")
   (web/visible? "div.bo_knows_bulbs_voters"))

 (defn get-page-source
   [reply-url]
   (web/to reply-url)
-  (web/wait-until #(bulbs-clickable?))
+  (web/wait-until #(can-scrape-bulbs?))
   (utils/parse-page-source (web/page-source)))

 (defn get-username


Fixed call to cleaning functions

Fixed call to cleaning functions

--- src/clj/forma/trends/analysis.clj
+++ src/clj/forma/trends/analysis.clj
@@ -181,7 +181,7 @@
   and `end-idx` (inclusive)."
   [freq start-idx end-idx spectral-ts reli-ts cofactor-ts]
   (let [params [freq start-idx end-idx spectral-ts reli-ts]
-        clean-ts (apply clean-tele-trends params)
+        clean-ts (apply clean-timeseries params)
         cofactor-tele (lengthening-ts start-idx end-idx cofactor-ts)]
     (map flatten
          (transpose [(map hansen-stat (map i/matrix clean-ts))


Make Kate's ability apply only if the install succeeded.

--- src/clj/game/cards-identities.clj
+++ src/clj/game/cards-identities.clj
@@ -123,10 +123,13 @@

    "Kate \"Mac\" McCaffrey: Digital Tinker"
    {:effect (effect (gain :link 1))
-    :events {:pre-install {:once :per-turn
-                           :req (req (some #(= % (:type target)) '("Hardware" "Program")))
-                           :msg (msg "reduce the install cost of " (:title target) " by 1 [Credits]")
-                           :effect (effect (install-cost-bonus -1))}}}
+    :events {:pre-install {:req (req (and (#{"Hardware" "Program"} (:type target))
+                                          (not (get-in @state [:per-turn (:cid card)]))))
+                           :effect (effect (install-cost-bonus -1))}
+             :runner-install {:req (req (and (#{"Hardware" "Program"} (:type target))
+                                             (not (get-in @state [:per-turn (:cid card)]))))
+                              :msg (msg "reduce the install cost of " (:title target) " by 1 [Credits]")
+                              :effect (req (swap! state assoc-in [:per-turn (:cid card)] true))}}}

    "Ken \"Express\" Tenma: Disappeared Clone"
    {:events {:play-event {:req (req (has? target :subtype "Run")) :once :per-turn


implement Subcontract

implement Subcontract

--- src/clj/game/cards-operations.clj
+++ src/clj/game/cards-operations.clj
@@ -642,6 +642,20 @@
                           (update-ice-strength target)
                           (host (get-card state target) (assoc card :zone [:discard] :seen true)))}

+   "Subcontract"
+   (letfn [(sc [i sccard]
+             {:prompt "Select an operation in HQ to play"
+              :choices {:req #(and (= (:side %) "Corp")
+                                   (is-type? % "Operation")
+                                   (in-hand? %))}
+              :msg (msg "play " (:title target))
+              :effect (req (when-completed target
+                                           (play-instant state side target)
+                                           (when (< i 2)
+                                               (resolve-ability state side (sc (inc i) sccard) sccard nil))))})]
+     {:req (req tagged)
+      :effect (effect (resolve-ability (sc 1 card) card nil))})
+
    "Subliminal Messaging"
    {:msg "gain 1 [Credits]"
     :effect (effect (gain :credit 1)


dont tell which card are discarded with reuse

fixes mtgred/netrunner#434

--- src/clj/game/cards-operations.clj
+++ src/clj/game/cards-operations.clj
@@ -217,7 +217,7 @@

    "Reuse"
    {:choices {:max 100 :req #(and (:side % "Corp") (= (:zone %) [:hand]))}
-    :msg (msg "trash " (join ", " (map :title targets)) " and gain " (* 2 (count targets)) " [Credits]")
+    :msg (msg "trash " (count targets) " card" (if (not= 1 (count targets)) "s") " and gain " (* 2 (count targets)) " [Credits]")
     :effect (effect (trash-cards targets) (gain :credit (* 2 (count targets))))}

    "Rework"


add Restructure :msg, fix Housekeeping

add Restructure :msg, fix Housekeeping

--- src/clj/game/cards-operations.clj
+++ src/clj/game/cards-operations.clj
@@ -204,7 +204,7 @@
                          true)))))}

    "Defective Brainchips"
-   {:events {:pre-damage {:req (req (= target :brain)) :msg "to do 1 additional brain damage"
+   {:events {:pre-damage {:req (req (= target :brain)) :msg "do 1 additional brain damage"
                           :once :per-turn :effect (effect (damage-bonus :brain 1))}}}

    "Diversified Portfolio"
@@ -268,9 +268,9 @@
    {:events {:runner-install {:req (req (= side :runner))
                               :choices {:req #(and (in-hand? %)
                                                    (= (:side %) "Runner"))}
-                              :prompt "Choose a card from your grip to trash for Housekeeping" :once :per-turn
-                              :msg (msg "to force the Runner to trash " (:title target) " from Grip")
-                              :effect (effect (trash target))}}}
+                              :prompt "Choose a card from your Grip to trash for Housekeeping" :once :per-turn
+                              :msg (msg "force the Runner to trash " (:title target) " from their Grip")
+                              :effect (effect (trash target {:unpreventable true}))}}}

    "Interns"
    {:prompt "Choose a card to install from Archives or HQ"
@@ -498,13 +498,19 @@
     :effect (effect (lose :bad-publicity 2) (trash target))}

    "Restructure"
-   {:effect (effect (gain :credit 15))}
+   {:msg "gain 15 [Credits]"
+    :effect (effect (gain :credit 15))}

    "Reuse"
-   {:choices {:max 100 :req #(and (:side % "Corp")
-                                  (in-hand? %))}
-    :msg (msg "trash " (count targets) " card" (if (not= 1 (count targets)) "s") " and gain " (* 2 (count targets)) " [Credits]")
-    :effect (effect (trash-cards targets) (gain :credit (* 2 (count targets))))}
+   {:effect (req (let [n (count (:hand corp))]
+                   (resolve-ability state side
+                     {:prompt (msg "Choose up to " n " cards in HQ to trash with Reuse")
+                      :choices {:max n :req #(and (:side % "Corp")
+                                                  (in-hand? %))}
+                      :msg (msg "trash " (count targets) " card" (if (not= 1 (count targets)) "s")
+                                " and gain " (* 2 (count targets)) " [Credits]")
+                      :effect (effect (trash-cards targets)
+                                      (gain :credit (* 2 (count targets))))} card nil)))}

    "Rework"
    {:prompt "Choose a card from HQ to shuffle into R&D"


Remove unused variables

Remove unused variables

--- src/cljs/asciinema_player/vt.cljs
+++ src/cljs/asciinema_player/vt.cljs
@@ -67,7 +67,7 @@
                                (let [next-tab (first (filter (partial < x) (:tabs vt)))]
                                  (or next-tab x)))))

-(defn execute-lf [{width :width height :height {x :x y :y} :cursor :as vt}]
+(defn execute-lf [{height :height {y :y} :cursor :as vt}]
   (if (= height (inc y))
     (-> vt
         scroll-up
@@ -76,7 +76,7 @@
         (assoc-in [:cursor :x] 0)
         (update-in [:cursor :y] inc))))

-(defn move-cursor-down [{width :width height :height {x :x y :y} :cursor :as vt}]
+(defn move-cursor-down [{height :height {y :y} :cursor :as vt}]
   (if (= height (inc y))
     (scroll-up vt)
     (update-in vt [:cursor :y] inc)))
@@ -90,7 +90,7 @@
 (def execute-ind move-cursor-down)
 (def execute-nel execute-lf)

-(defn execute-hts [{{x :x} :cursor width :width :as vt}]
+(defn execute-hts [{{x :x} :cursor :as vt}]
   (if (pos? x)
     (update-in vt [:tabs] conj x)
     vt))


Think I finally fixed colors. Miss tests

--- src/cljs/battle_console/game.cljs
+++ src/cljs/battle_console/game.cljs
@@ -85,10 +85,21 @@
                   (dom/td nil unit)
                   (dom/td nil quantity))))))))))

+(defn- get-player-position
+  "Gets the position of a player for a given game"
+  [game player]
+  (if (empty? player)
+    nil
+    (let [player-code (get-in game ["viewed-by" "player-code"])]
+      (cond
+        (= "p1" player-code player) "p1"
+        (= "p2" player-code player) "p1"
+        :else "p2"))))
+
 (defn- get-element-css
   "Gets a CSS class for the given element"
-  [element]
-  (condp = (get element "player")
+  [game element]
+  (condp = (get-player-position game (get element "player"))
     "p1" "success"
     "p2" "warning"
     nil ""))
@@ -98,7 +109,7 @@
   [game x y]
   (let [coordCode (str "[" x " " y "]")
         element (get-in game ["battle" "elements" coordCode])
-        css (get-element-css element)]
+        css (get-element-css game element)]
     (dom/td #js {:className css}
       (dom/p #js {:className "boardCoords"} coordCode)
       (dom/p #js {:className "boardUnit"} (or (get element "unit") "-"))
@@ -115,12 +126,24 @@
             (for [x (range 1 9)]
               (render-board-cell game x y))))))))

+(defn- player-switch
+  "Switches players"
+  [player]
+  (if (= player "p1")
+    "p2"
+    "p1"))
+
 (defn- get-name-for
   "Gets the name to be on the given position"
   [game position]
-  (if (= "p1" (name position) (get-in game [:game-data "viewed-by" "player-code"]))
-    (get-in game [:game-data "p1" "name"])
-    (get-in game [:game-data "p2" "name"])))
+  (let [player-code (get-in game [:game-data "viewed-by" "player-code"])
+        pos (name position)]
+    (println "get-name-for " pos " code: " player-code)
+    (cond
+      (= "p1" pos player-code) (get-in game [:game-data "p1" "name"])
+      (= ["p2" pos player-code] ["p2" "p1" "p2"]) (get-in game [:game-data "p2" "name"])
+      (= ["p2" pos player-code] ["p2" "p2" "p1"]) (get-in game [:game-data "p2" "name"])
+      :else (get-in game [:game-data (player-switch pos) "name"]))))

 (defn- render-player-roaster
   "Renders the player's roaster"


fixed texts and little change in previous step

--- src/cljs/cljs_repl_web/views.cljs
+++ src/cljs/cljs_repl_web/views.cljs
@@ -39,7 +39,7 @@
                     [:p "It contains many features, so let’s start!"]]}
    :step1 {:title "Tour 1 of 9"
            :body [:div [:h1.tour-title "Clicking the Bin icon"]
-                  [:p "will reset the REPL, that is:"]
+                  [:p "It will reset the REPL, that is:"]
                   [:ul.tour
                    [:li "it will clear the current prompt"]
                    [:li "it will clear the REPL “screen”"]
@@ -51,23 +51,23 @@
                   [:span "or just by clicking on the item you are interested in."]]}
    :step2 {:title "Tour 2 of 8"
            :body [:div [:h1.tour-title "Clicking the Clear icon"]
-                  [:p "will trigger the same action as before with the difference that the history will not be deleted"]]}
+                  [:p "It will trigger the same action as before with the difference that the history will not be deleted."]]}
    :step3 {:title "Tour 3 of 9"
            :body [:div [:h1.tour-title "Creating a Gist"]
-                  [:p "is really one of the nicest features of our app."]
+                  [:p "It is really one of the nicest features of our app."]
                   [:p "You will need to fill your username and password and a new window with the newly created Gist will be opened."]
                   [:p "The username will be saved (but not the password) so you won’t need to fill it every time."]
-                  [:h4 "note:"]
-                  [:p "only what is shown in the REPL will be sent to Gist. So even if you have some items in your history but the current “screen” is empty you won’t be able to create a Gist."]]}
+                  [:h5 "Note:"]
+                  [:p "Only what is shown in the REPL will be sent to Gist. So even if you have some items in your history but the current “screen” is empty you won’t be able to create a Gist."]]}
    :step4 {:title "Tour 4 of 9"
            :body [:div [:h1.tour-title "Clear examples"]
                   [:p "Just under the REPL you will find many buttons, logically grouped by topic. Clicking on them will open a popup (this feature will be explained in another step of this tutorial)."]
                   [:p "One of the actions you can take is send the examples directly to the REPL:"]
-                  [:span "for example the"]
+                  [:span "For example the"]
                   [:span.symbol " + "]
                   [:span "symbol contains 5 examples you can evaluate. If for any reason you want to interrupt the examples’ evaluation just click on this button."]
-                  [:h4 "note:"]
-                  [:p "the number of current examples to evaluate is shown in the mode-line:"]
+                  [:h5 "Note:"]
+                  [:p "The number of current examples to evaluate is shown in the mode-line:"]
                   [:span.mode "X form(s) in the evaluation queue"]]}
    :step5 {:title "Tour 5 of 9"
            :body [:div [:h1.tour-title "Switch input mode"]
@@ -75,6 +75,7 @@
                   [:a.tour {:href "https://github.com/shaunlebron/parinfer"} " parinfer"]
                   [:span " to our REPL with the default input mode as "]
                   [:span.mode "indent-mode"]
+                  [:span "."]
                   [:p " You can shuffle between three modes:"]
                   [:ul.tour
                    [:li "Indent Mode"]
@@ -82,8 +83,8 @@
                    [:li "none"]]
                   [:span "The "]
                   [:span.mode "non"]
-                  [:span " mode will just disable parinfer and switch to normal editing"]
-                  [:h4 "note:"]
+                  [:span " mode will just disable parinfer and switch to normal editing."]
+                  [:h5 "Note:"]
                   [:span "Our REPL is clever enough to determine whether a form should be evaluated or whether issue a new-line. For example if you are in "]
                   [:span.mode "none"]
                   [:span " mode, write "]
@@ -91,6 +92,7 @@
                   [:span " and press ENTER the cursor will be placed on a newline."]
                   [:span "This is not always the case with Indent Mode, which will try to balance parenthesis causing the previous expression to be transformed to "]
                   [:span.mode "(def a)"]
+                  [:span "."]
                   [:p "If you now press ENTER you’ll receive an error: to overcome this problem just press SHIFT+ENTER to issue a new line."]]}
    :step6 {:title "Tour 6 of 9"
            :body [:div [:h1.tour-title "Console"]
@@ -118,7 +120,7 @@
                    [:li "related symbols list"]]]}
    :step9 {:title  "Tour 9 of 9"
            :body [:div [:h1.tour-title "Send to repl"]
-                  [:p "click on this button to send the examples to the REPL"]]}
+                  [:p "Click on this button to send the examples to the REPL."]]}
    :step10 {:title  "Excellent!"
             :body [:div [:p "This is the end of the tutorial. If you want to report an issue or fork the repository click on the ribbon in the top-left corner."]
                    [:span "Check also our blog at "]
@@ -214,8 +216,10 @@
       (reset! ((nth steps new-step) tour) true))))

 (defn tour-buttons
-  [tour another-step close-fn]
-  (let [on-first-button (= @(:current-step tour) 0)
+  [tour another-steps close-fn]
+  (let [next-step (:next another-steps)
+        previous-step (:prev another-steps)
+        on-first-button (= @(:current-step tour) 0)
         on-last-button  (= @(:current-step tour) (dec (count (:steps tour))))
         showing? (reagent/atom true)]
     [:div
@@ -224,14 +228,18 @@
      (when-not on-first-button
        [button
         :label    "Previous"
-        :on-click (handler-fn (prev-tour-step tour))
+        :on-click (handler-fn
+                   (if previous-step
+                     ((previous-step)
+                      (prev-tour-step tour))
+                     (prev-tour-step tour)))
         :style    {:margin-right "15px"}
         :class     "btn-default"])
      [button
       :label    "Next"
       :on-click (handler-fn
-                 (if another-step
-                   ((another-step)
+                 (if next-step
+                   ((next-step)
                     (next-tour-step tour))
                    (next-tour-step tour)))
       :style    {:z-index 5000}
@@ -582,7 +590,7 @@
                #(do (finish-tour tour)
                     (reset! showing-atom false)
                     (utils/scroll-to-top))
-               #(reset! showing-atom false)]
+               {:next #(reset! showing-atom false)}]
               [api-example example-map]]])

 (defn api-examples
@@ -648,7 +656,9 @@
                                :on-click #(utils/open-new-window (utils/symbol->clojuredocs-url full-name))]
                               #(do (finish-tour tour)
                                    (reset! showing-atom false)
-                                   (utils/scroll-to-top))]]]
+                                   (utils/scroll-to-top))
+                              {:prev #(reset! showing-atom false)}
+                               ]]]
           :body [reagent/create-class
                  {:component-did-mount (fn [this]
                                          (let [node (reagent/dom-node this)]
@@ -704,15 +714,15 @@
                    #(do (finish-tour tour)
                         (utils/scroll-to-top)
                         (reset! tour? false))
-                   #(do (reset! popover-position :above-center)
-                        (reset! tour? true)
-                        (reset! showing? true)
-                        [popover-anchor-wrapper
-                         :showing? showing?
-                         :position @popover-position
-                         :anchor [button
-                                  :class "btn btn-default api-panel-symbol-button"
-                                  :label (:name symbol)]])]
+                   {:next #(do (reset! popover-position :above-center)
+                               (reset! tour? true)
+                               (reset! showing? true)
+                               [popover-anchor-wrapper
+                                :showing? showing?
+                                :position @popover-position
+                                :anchor [button
+                                         :class "btn btn-default api-panel-symbol-button"
+                                         :label (:name symbol)]])}]
                   (do [popover-anchor-wrapper
                        :showing? showing?
                        :position @popover-position


Add incrementing button

Add incrementing button

--- src/cljs/five_three_one/core.cljs
+++ src/cljs/five_three_one/core.cljs
@@ -9,9 +9,18 @@
 ;; -------------------------
 ;; Views

-(defn home-page []
-  [:div [:h2 "Welcome to five-three-one"]
-   [:div [:a {:href "#/about"} "go to about page"]]])
+(defn heading
+  []
+  "this is a heading.")
+
+(def home-page
+  (let [state (atom 0)]
+    (fn [] [:div [:h2 (heading)]
+            [:div [:a {:href "#/about"} "go to about page"]]
+            [:button {:on-click #(do (swap! state inc)
+                                     (println state))}
+             "Click here to increment the number!"]
+            [:div (str @state)]])))

 (defn about-page []
   [:div [:h2 "About five-three-one"]


Current-strength for rezzed ice.

Current-strength for rezzed ice.

--- src/cljs/netrunner/gameboard.cljs
+++ src/cljs/netrunner/gameboard.cljs
@@ -176,7 +176,8 @@
         [:div.counters
          (when (> counter 0) [:div.darkbg.counter counter])
          (when (> advance-counter 0) [:div.darkbg.advance.counter advance-counter])]
-        (when current-strength [:div.darkbg.strength current-strength])
+        (when (and current-strength (not= strength current-strength))
+              current-strength [:div.darkbg.strength current-strength])
         (when (and (= zone ["hand"]) (#{"Agenda" "Asset" "ICE" "Upgrade"} type))
           (let [centrals ["HQ" "R&D" "Archives"]
                 remotes (conj (remote-list remotes) "New remote")


送信の周期を短くできるように

送信の周期を短くできるように

osc-clientを毎回作るように。内部的にPriorityBlockingQueueを使っているの
が関係するっぽい

--- src/clojure/com/illiichi/main.clj
+++ src/clojure/com/illiichi/main.clj
@@ -9,20 +9,13 @@

 (def state (atom {:start? false}))

-(def client (atom nil))
 (def listeners (atom nil))

 (def my-pool (mk-pool))
 (def acc-stack (agent []))
 (def rotate-stack (agent []))

-(defn send-every [id interval]
-  (letfn [(task []
-            (apply osc-send @client (str "/" id) (concat @acc-stack @rotate-stack))
-            (for [stack [acc-stack rotate-stack]]
-              (send stack (fn [_] []))))]
-    (every interval task my-pool)))
-
+(defn now [] (.format (java.text.SimpleDateFormat. "HH:mm:ss.S") (java.util.Date.)))

 (defn replace-mean [stack vals]
@@ -30,7 +23,15 @@
             (if (empty? xs) vals
                 (map #(/ (+ %1 %2) 2.0) vals xs)))]
     (send-off stack mean)))
-
+(defn send-every [id interval host port]
+  (letfn [(task []
+            (let [client (osc-client host port)] (apply osc-send client (str "/" id) (concat [(now)] @acc-stack @rotate-stack)))
+            ;; (apply osc-send client (str "/" id) (concat [(now)] [-0.74782043082746, 5.3259560276466, 8.299258563232] [0.21574099701674, -0.18960481184636, -0.74130249528735] ))
+            ;; (apply osc-send client (str "/" id) [(now) -0.74782043082746, 5.3259560276466, 8.299258563232 0.21574099701674, -0.18960481184636, -0.74130249528735])
+            ;; (let [client (osc-client host port)] (osc-send client (str "/" id) (now) -0.74782043082746, 5.3259560276466, 8.299258563232 0.21574099701674, -0.18960481184636, -0.74130249528735))
+            (for [stack [acc-stack rotate-stack]] (send stack (fn [_] [])))
+            )]
+    (every interval task my-pool)))

 (defn push-vector [stack vals]
   (let [push (fn [xs xss]
@@ -44,13 +45,13 @@
 (set-error-handler! acc-stack err-handler-fn)
 (set-error-handler! rotate-stack err-handler-fn)

-(defn create-listeners [interval sensorManager]
+(defn create-listeners [interval sensorManager host port]
   (let [create (fn [id sensor-type stack]
                  (let [listener (reify SensorEventListener
                                   (onAccuracyChanged [this sensor value] ())
                                   (onSensorChanged [this event]
                                     (apply #'replace-mean stack (seq (list (. event values))))))]
-                   (send-every "Data" interval)
+                   (send-every "Data" interval host port)
                    (.. sensorManager
                        (registerListener listener
                                          (.getDefaultSensor sensorManager sensor-type)
@@ -58,8 +59,8 @@
                                          ;; SensorManager/SENSOR_DELAY_UI
                                          SensorManager/SENSOR_DELAY_GAME))
                    listener))]
-    [(create "rotate" Sensor/TYPE_ROTATION_VECTOR rotate-stack)
-     (create "acc" Sensor/TYPE_LINEAR_ACCELERATION acc-stack)
+    [(create "acc" Sensor/TYPE_ACCELEROMETER acc-stack)
+     (create "rotate" Sensor/TYPE_ROTATION_VECTOR rotate-stack)
      ]))

 (def sensorManager (atom nil))
@@ -67,8 +68,7 @@
 (defn start-send [address port interval]
   (for [stack [acc-stack rotate-stack]]
     (send stack (fn [_] [])))
-  (reset! client (osc-client address port))
-  (reset! listeners (create-listeners interval @sensorManager))
+  (reset! listeners (create-listeners interval @sensorManager address port))
   (prn "start"))

 (defn stop-send []
@@ -79,7 +79,6 @@
     (.unregisterListener manager (first xs))
     (.unregisterListener manager (second xs))
    (stop-and-reset-pool! my-pool)
-   (reset! client nil)
    (reset! listeners nil)
    (prn "stop")))

@@ -109,17 +108,16 @@
           [:edit-text {:text "192.168.0.2" :id ::address}]]
          [:linear-layout {}
           [:text-view {:text "port"}]
-          [:edit-text {:text "1235" :id ::port}]]
+          [:edit-text {:text "5000" :id ::port}]]
          [:linear-layout {}
           [:text-view {:text "interval(ms)"}]
-          [:edit-text {:text "200" :id ::interval}]]
+          [:edit-text {:text "80" :id ::interval}]]
          [:button {:id "button"
                    :text "ready?" :on-click (fn [_] (toggle-state (*a)))}]]))))

 (comment
-  (def GRT-RECEIVE-PORT 5000)
-  (def GRT-RECEIVE-PORT 1235)
+  (def GRT-RECEIVE-PORT 5000)
   (def client (osc-client "192.168.0.2" GRT-RECEIVE-PORT))

@@ -164,3 +162,5 @@
 ;;
 ;; {PMOsc.ar(440 * In.ar(rotateBus).poll.abs, 10 * In.ar(accBus).abs, 3)}.play(soundGroup)
 ;;)
+
+


Prevent sentences of unbounded length by using a very big word limit which we don't expect to hit.

--- Spraff/src/spraff/core.clj
+++ Spraff/src/spraff/core.clj
@@ -48,9 +48,9 @@
 (defn generate-sentence [{:keys [table starters]}]
     (drop-last (map first
         (apply max-key #(count (filter true? (map second %)))
-            (take retries (repeatedly #(stream-of-shite
+            (take retries (repeatedly #(take 1000 (stream-of-shite
                     (nth starters (rand-int (count starters)))
-                    table)))))))
+                    table))))))))

 (defn value-or-default [value default]
     (if (nil? value) default value))


other stuff from repl

other stuff from repl

--- src/yalp/core.clj
+++ src/yalp/core.clj
@@ -19,4 +19,9 @@
              {}
              categories))

-
+(defn city-comp
+  [city1 pop1 city2 pop2]
+  (reduce-kv (fn [a label value]
+               (let [other-val (or (get city2 label) 0)]
+                 (conj a [label (- (/ (or value 0) pop1) (/ other-val pop2))])))
+             [] city1))