macro initiation

macro initiation

--- src/clj/algorithms_clj/macro_initiation.clj
+++ src/clj/algorithms_clj/macro_initiation.clj
@@ -493,8 +493,7 @@
 (defn logger-enabled?
   "Read whether the log should be enabled by reading config file"
   []
-  (let [log-config (read-string (slurp log-config-file))]
-    (-> log-config :log :enabled?)))
+  (-> (slurp log-config-file) (read-string) :log :enabled?))

 (defmacro defn-log-3
   [& args]


implemented dynamic number of arity

implemented dynamic number of arity

--- src/clj/modern_cljs/dsl/dsltaskexecutor.clj
+++ src/clj/modern_cljs/dsl/dsltaskexecutor.clj
@@ -7,13 +7,10 @@
     (do (str "\""param"\""))
     param) )

-(defn execute-task [dsl-task entity email details]
+(defn execute-task [dsl-task & params]
   (binding [*ns* (:ns (meta #'t/send-string-details-by-email-task))]
-    (eval (read-string (str "("
-                            dsl-task " '"
-                            (extract-param entity) " '"
-                            (extract-param email) " '"
-                            (extract-param details)
-                            ")"  )))
-    ))
+    (let [code (for [param params]
+                 (str " '" (extract-param param)))]
+      (let [resulted-code (str "(" dsl-task (clojure.string/join code) ")" )]
+        (eval (load-string resulted-code))))))


Replace slurp with try-slurp as first try at error handling/recovery.

--- project/scrape-summitpost-data/src/scrape_summitpost_data/get_item_texts.clj
+++ project/scrape-summitpost-data/src/scrape_summitpost_data/get_item_texts.clj
@@ -10,15 +10,23 @@

 (def base-url "http://www.summitpost.org")

+; TODO: come up with more sophisticated error handling strategy
+(defn- try-slurp
+  [f]
+  (try
+    (slurp f)
+    (catch Exception e
+      "ERROR")))
+
 (defn- get-result-urls
   "Given a link to a paginated search results page from summitpost, GET the
   page and return a sequence of fully qualified urls to all of the search
   results."
   [link]
-  (let [page (slurp (str base-url link))
+  (let [page (try-slurp (str base-url link))
         pager-links (or (extract-all-pager-links page) [link])
         pager-urls (map (partial str base-url) pager-links)
-        search-pages (map slurp pager-urls)
+        search-pages (map try-slurp pager-urls)
         result-links (extract-all-result-links search-pages)]
     (map (partial str base-url) result-links)))

@@ -37,7 +45,7 @@
   [search-link]
   (let [result-urls (get-result-urls search-link)
         result-texts (->> result-urls
-                          (map slurp)
+                          (map try-slurp)
                           (map extract-item-text))]
     (map make-result-entry result-urls result-texts)))

@@ -51,7 +59,7 @@
   "Concatenate result page content with contents of pages at child-urls."
   [result-page child-urls]
   (let [result-text (extract-item-text result-page)
-        child-pages (map slurp child-urls)
+        child-pages (map try-slurp child-urls)
         child-texts (map extract-item-text child-pages)]
     (string/join "\n" (cons result-text child-texts))))

@@ -63,7 +71,7 @@
   sequence."
   [search-link]
   (let [result-urls (get-result-urls search-link)
-        result-pages (map slurp result-urls)
+        result-pages (map try-slurp result-urls)
         child-urls (map get-child-urls result-pages)
         all-child-urls (set (apply concat child-urls))
         result-texts (map get-result-text-and-child-texts


rename symbol for readability

rename symbol for readability

--- src-cljs/sory/sound.cljs
+++ src-cljs/sory/sound.cljs
@@ -24,23 +24,23 @@
     c))

-(defn- peak-freq [arr nyquist start-freq min-db]
-  (let [buffer-length (.-length arr)
+(defn- peak-freq [freqs nyquist start-freq min-db]
+  (let [buffer-length (.-length freqs)
         freq-to-index #(-> %
                            (/ nyquist)
                            (* buffer-length)
                            js/Math.round)
         index-to-freq #(* % (/ nyquist buffer-length))]
     (loop [i (freq-to-index start-freq)
-           index -1
-           max (- (.-Infinity js/window))]
+           max-index -1
+           max-db (- (.-Infinity js/window))]
       (if (< i buffer-length)
-        (let [val (aget arr i)]
-          (if (< max val)
-            (recur (inc i) i val)
-            (recur (inc i) index max)))
-        (when (< min-db max)
-          (index-to-freq index))))))
+        (let [db (aget freqs i)]
+          (if (< max-db db)
+            (recur (inc i) i db)
+            (recur (inc i) max-index max-db)))
+        (when (< min-db max-db)
+          (index-to-freq max-index))))))

 (defn- fetch-freqs [analyser]


Scanning no longer drops the first message

--- src/mafia_votecount/scraper/team_liquid.clj
+++ src/mafia_votecount/scraper/team_liquid.clj
@@ -253,7 +253,7 @@
 (defn- scan-votes [player-message-maps hosts first-index cycle-number cycle-type]
   (let [first-page-index (inc (* (quot (dec first-index) POSTS-PER-PAGE) POSTS-PER-PAGE))
         indexed (->> (enumerate player-message-maps first-page-index)
-                     (drop-while #(<= (first %) first-index))
+                     (drop-while #(< (first %) first-index))
                      (into (sorted-map)))
         day-ranges (-> (cycle-changes indexed hosts)
                        (keys)


Commiting file that was left out of previous commit

--- src/mafia_votecount/scraper/team_liquid.clj
+++ src/mafia_votecount/scraper/team_liquid.clj
@@ -14,6 +14,8 @@
 (def ^:private request-header
   {"User-Agent" user-agent})

+(def ^:private ^:const POSTS-PER-PAGE 20)
+
 (defn- fetch-page [path]
   (if-not (.contains path "teamliquid.net/forum/") nil
     (try
@@ -67,7 +69,7 @@
          (.contains id "spoiler")
          nil)))

-(defn death-to-quotes [loc]
+(defn- death-to-quotes [loc]
   (if (zip/end? loc)
     loc
     (if (or (has-quote? (zip/node loc)) (has-spoiler? (zip/node loc)))
@@ -109,23 +111,25 @@
    (get-forum-posts)
    (#(pair-users-messages (extract-users %) (extract-messages %)))))

-(defn- parse-and-wait [content]
+(defn- parse-and-wait [content first-index]
   (do (Thread/sleep 1000)
       (get-user-message-pairs content)))

-(defn- get-player-message-maps [path]
-  (some->>
-   (fetch-certain-page path 1)
-   (only-main-content)
-   (get-page-numbers)
-   ((fn [page-numbers]
-      (map #(-> (fetch-certain-page path %)
-                (parse-and-wait))
+(defn- get-player-message-maps [path first-index]
+  (let [first-page (inc (quot first-index POSTS-PER-PAGE))]
+   (some->>
+    (fetch-certain-page path 1)
+    (only-main-content)
+    (get-page-numbers)
+    (#(nthrest % (dec first-page)))
+    ((fn [page-numbers]
+       (map #(-> (fetch-certain-page path %)
+                 (parse-and-wait first-index))
             page-numbers)))
-   (flatten)))
-
-(defn- enumerate [posts]
-  (->> (map-indexed #(vector (inc %1) %2) posts)
+    (flatten))))
+
+(defn- enumerate [posts first-page-index]
+  (->> (map-indexed #(vector (+ first-page-index %1) %2) posts)
        (into (sorted-map))))

 (defn- is-host? [index-post hosts]
@@ -227,14 +231,28 @@
 ;;               (map #(assoc  % :day day) votes)))
 ;;           votes-by-days))

-(defn- scan-votes [player-message-maps hosts]
-  (let [indexed (enumerate player-message-maps)
+(defn- last-cycle [day-ranges]
+  (case (count (last day-ranges))
+    0 :none
+    1 :day
+    2 :night
+    :last-cycle-error)) ;; This should never happen
+
+(defn- scan-votes [player-message-maps hosts first-index cycle-number cycle-type]
+  (let [first-page-index (* (quot first-index POSTS-PER-PAGE) POSTS-PER-PAGE)
+        indexed (->> (enumerate player-message-maps first-page-index)
+                     (drop-while #(<= (first %) first-index))
+                     (into (sorted-map)))
         day-ranges (-> (cycle-changes indexed hosts)
                        (keys)
-                       (to-day-ranges))]
+                       (#(if (= cycle-type :day)
+                           (cons first-index %)
+                           %))
+                       (to-day-ranges))
+        last-cycle (last-cycle day-ranges)]
     (days-into-votes (range 1 (inc (count day-ranges)))
                      (map #(get-votes-in-range indexed %) day-ranges))))

-(defn scan-all-votes [url hosts]
-  (let [player-message-maps (get-player-message-maps url)]
-    (scan-votes player-message-maps hosts)))
+(defn scan-all-votes-after [url hosts first-index cycle-number cycle-type]
+  (let [player-message-maps (get-player-message-maps url first-index)]
+    (scan-votes player-message-maps hosts first-index cycle-number cycle-type)))


extracts refactored

extracts refactored

--- src/main/clojure/pdok/featured/extracts.clj
+++ src/main/clojure/pdok/featured/extracts.clj
@@ -65,7 +65,8 @@
 (defn add-extract-records [db dataset feature-type extract-type version rendered-features]
   "Inserts the xml-features and tile-set in an extract schema based on dataset, extract-type, version and feature-type,
    if schema or table doesn't exists it will be created."
-  (let [collection (str dataset "_" extract-type)
+  (let [_ (println rendered-features)
+        collection (str dataset "_" extract-type)
         table (str collection "_v" version)
         extractset-id (get-or-add-extractset db collection version) ]
     (do


Removes print statement.

Removes print statement.

--- src/loudmoauth/authflow.clj
+++ src/loudmoauth/authflow.clj
@@ -31,8 +31,6 @@
 (defn add-tokens-to-provider-data
   "Takes state-map a state and parsed response from http request. Adds access-token and refresh-token to state map."
   [provider-data parsed-body]
-  (prn provider-data)
-  (prn parsed-body)
   (dosync
     (ref-set (:access_token provider-data) (:access_token parsed-body))
     (when (:refresh_token parsed-body)


updated lein profile

updated lein profile

--- .lein/profiles.clj
+++ .lein/profiles.clj
@@ -17,6 +17,6 @@
    [org.clojure/tools.nrepl "0.2.12"]
    ]}
  :repl {:plugins
-        [[refactor-nrepl "2.2.0-SNAPSHOT"]
-         [cider/cider-nrepl "0.11.0"]
+        [
+         [refactor-nrepl "2.2.0-SNAPSHOT"]
          ]}}


Ref continue

Ref continue

--- src/mark-volkmann-tutorial/reference-types.clj
+++ src/mark-volkmann-tutorial/reference-types.clj
@@ -48,4 +48,90 @@
 ;; Refs
 ; coordinated chabges between multiple threads using STM (Software Transactional Memory)
 ; ref modified only in transaction
-; STM ~ database transactions: commit; atomic & isolation; validator function+; STM ~ database transactions: commit; atomic & isolation; validator function
+; dosync - transaction: in it ref have private value dont visible for other threads
+; if there is no exception before end of transaction - its committed, and it visible
+; if exception -> rollback changes
+; transaction should be side-effect free -> its could be called multiple times (retry on conflict)
+
+;; (def name (ref value)
+
+(dosync
+  ; ...
+  (ref-set name new-value)
+  ; ...
+  )
+
+;; If the new value must be computed from the old value then three steps are required.
+;; 1 deference the Ref to get the old value
+;; 2 compute the new value
+;; 3 set the new value
+;; alter - changes in specific oreder
+;; commute - order of changes are not imporant - could be done parallel
+
+(dosync
+;;   ...
+  (alter counter inc)
+  ; or as
+  (commute counter inc)   ; faster (parallel) but not deterministic, optimization of alter
+;;   ...
+)
+
+
+(ns com.ociweb.bank)
+
+; Assume the only account data that can change is its balance.
+(defstruct account-struct :id :owner :balance-ref)
+
+; We need to be able to add and delete accounts to and from a map.
+; We want it to be sorted so we can easily
+; find the highest account number
+; for the purpose of assigning the next one.
+(def account-map-ref (ref (sorted-map)))
+
+(defn open-account
+  "creates a new account, stores it in the account map and returns it"
+  [owner]
+  (dosync ; required because a Ref is being changed
+    (let [account-map @account-map-ref
+          last-entry (last account-map)
+          ; The id for the new account is one higher than the last one.
+          id (if last-entry (inc (key last-entry)) 1)
+          ; Create the new account with a zero starting balance.
+          account (struct account-struct id owner (ref 0))]
+      ; Add the new account to the map of accounts.
+      (alter account-map-ref assoc id account)
+      ; Return the account that was just created.
+      account)))
+
+(defn deposit [account amount]
+  "adds money to an account; can be negative amount"
+  (dosync ; required because a Ref is being changed
+    (Thread/sleep 50) ; simulate a long-running operation
+    (let [owner (account :owner)
+          balance-ref (account :balance-ref)
+          type (if (pos? amount) "deposit" "withdraw")
+          direction (if (pos? amount) "to" "from")
+          abs-amount (Math/abs amount)]
+      (if (>= (@balance-ref amount) 0) ; sufficient balance?
+        (do
+          (alter balance-ref + amount)
+          (println (str type "ing") abs-amount direction owner))
+        (throw (IllegalArgumentException.
+                 (str "insufficient balance for " owner " to withdraw " abs-amount)))))))
+
+(defn withdraw
+  "removes money from an account"
+  [account amount]
+  ; A withdrawal is lika a negative deposit.
+  (deposit account (- amount)))
+
+(defn transfer [from-account to-account amount]
+  (dosync
+    (println "transferring" amount
+             "from" (from-account :owner)
+             "to" (to-account :owner))
+    (withdraw from-account amount)
+    (deposit to-account amount)))
+
+


fix(frontend): add missing import

fix(frontend): add missing import

--- frontend/src/uxbox/main/ui/shapes/text.cljs
+++ frontend/src/uxbox/main/ui/shapes/text.cljs
@@ -16,7 +16,7 @@
             [uxbox.main.ui.shapes.common :as common]
             [uxbox.main.ui.shapes.attrs :as attrs]
             [uxbox.util.color :as color]
-            [uxbox.util.data :refer [classnames]]
+            [uxbox.util.data :refer [classnames normalize-props]]
             [uxbox.util.dom :as dom]
             [uxbox.util.geom.matrix :as gmt]
             [rumext.core :as mx :include-macros true])


Trying to avoid a race condition on EAP 6.4

--- transactions/test/immutant/transactions_test.clj
+++ transactions/test/immutant/transactions_test.clj
@@ -26,12 +26,12 @@
 (def cache (csh/cache "tx-test" :transactional? true))
 (def queue (msg/queue "/queue/test" :durable? false))
 (def local-remote-queue (msg/queue "remote" :durable? false))
-(def conn (msg/context (cond-> {:host "localhost" :xa? true}
-                         (in-container?) (assoc :port (messaging-remoting-port)
-                                           :username "testuser" :password "testuser1!"
-                                           :remote-type :hornetq-wildfly)
-                         (in-eap?) (dissoc :remote-type))))
-(def remote-queue (msg/queue "remote" :context conn))
+(def conn (delay (msg/context (cond-> {:host "localhost" :xa? true}
+                                (in-container?) (assoc :port (messaging-remoting-port)
+                                                  :username "testuser" :password "testuser1!"
+                                                  :remote-type :hornetq-wildfly)
+                                (in-eap?) (dissoc :remote-type)))))
+(def remote-queue (delay (msg/queue "remote" :context @conn)))
 (def trigger (msg/queue "/queue/trigger" :durable? false))
 (def spec {:connection-uri "jdbc:h2:mem:ooc;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE"})

@@ -48,7 +48,7 @@
 (use-fixtures :once
   (fn [f]
     (f)
-    (.close conn)))
+    (.close @conn)))

 ;;; Helper methods to verify database activity
 (defn write-thing-to-db [spec name]
@@ -65,7 +65,7 @@
 (defn work [m]
   (csh/swap-in! cache :a (constantly 1))
   (msg/publish queue "kiwi")
-  (msg/publish remote-queue "starfruit")
+  (msg/publish @remote-queue "starfruit")
   (not-supported
     (csh/swap-in! cache :deliveries (fnil inc 0)))
   (sql/with-db-transaction [t spec]


naive labelling function

naive labelling function

--- src/spcr/core.clj
+++ src/spcr/core.clj
@@ -23,9 +23,16 @@
        (map #(dissoc % :_id))))

+(defn categorize []
+  (->> (get-data)
+       (filter #(< (read-string (:Close %)) 40))
+      (group-by (fn [{close :Close low :Low high :High}]
+                  (mod (apply + (map read-string [close low high])) 10)))))
+
 (defroutes endpoints
   (GET "/" [] (response {:key "Hello world"}))
-  (GET "/data" [] (response (get-data))))
+  (GET "/data" [] (response (get-data)))
+  (GET "/label" [] (response (categorize))))


Use transients for array decoding, and a persistent range

Significantly reduces overall memory consumption when
connected to a statustext heavy system

--- src/mavlink/mavlink_xml.clj
+++ src/mavlink/mavlink_xml.clj
@@ -166,15 +166,17 @@
                        :type-key type-key
                        :name-key name-key}))
       (if length
-        (fn decode-it-array [buffer message]
-          (let [new-array (reduce
-                            (fn [vr i] (conj vr (let [v (read-fn buffer)]
-                                                    (get enum-group v v))))
-                            []
-                            (range length))]
-            (assoc! message  name-key (if (= type-key :char)
-                                        (.trim (new String ^"[B" (into-array Byte/TYPE new-array)))
-                                        new-array))))
+        (let [range-length (range length)]
+          (fn decode-it-array [buffer message]
+            (let [new-array (persistent!
+                              (reduce
+                                (fn [vr i] (conj! vr (let [v (read-fn buffer)]
+                                                       (get enum-group v v))))
+                                (transient [])
+                                range-length))]
+              (assoc! message  name-key (if (= type-key :char)
+                                          (.trim (new String ^"[B" (into-array Byte/TYPE new-array)))
+                                          new-array)))))
           (fn decode-it [buffer message]
             (assoc! message name-key (let [v (if (and bitmask
                                                       (= type-key :uint64_t))


implement hide

implement hide

--- src/mermaid_ldjam/core.cljs
+++ src/mermaid_ldjam/core.cljs
@@ -29,6 +29,12 @@
         new-entity (dissoc entity :hidden)]
     (assoc-in state [:entities hidden-entity] new-entity)))

+(defn hide [state hidden-entity]
+  (let [entities (:entities state)
+        entity (hidden-entity entities)
+        new-entity (conj entity {:hidden true})]
+    (assoc-in state [:entities hidden-entity] new-entity)))
+
 (defn win-game [state]
   (q/background 90 200 21)
   state)
@@ -39,7 +45,7 @@

 (def actions-map
   {[:look :window] {:text "You look outside the window and see your home, the mighty ocean." :action []}
-   [:look :bucket] {:text "You see a bucket. Maybe there is something inside." :action []}
+   [:look :bucket] {:text "You see a bucket. Maybe there is something inside."}
    [:look :stone] {:text "There are stones on the floor. You can easily reach them" :action []}
    [:look :bottle] {:text "There is a bottle of wine on the floor. You can't get drunk by yourself." :action []}
    [:look :seagull] {:text "It's a seagull looking for company!"}
@@ -57,10 +63,10 @@
    [:bottle :bucket] {:text "You put the bottle in the bucket. Then put it back. That makes no sense."}
    [:stone :starfish] {:text "You throw stones at the starfish. You will probably never be friends."}
    [:stone :bucket] {:text "You put a stone back in the bucket. Back to the beggining."}
-   [:stone :window] {:text "You throw a stone against the window. Crash! The window shatters in tiny pieces." :action [unhide :window-open]}
+   [:stone :window] {:text "You throw a stone against the window. Crash! The window shatters in tiny pieces." :action [unhide :window-open hide :window]}
    [:starfish :window] {:text "You throw the starfish against the window. It bounces back and gives you an angry look."}
-   [:starfish :window-open] {:text "You throw the starfish out the window." :action [unhide :seagull]}
-   [:bottle :seagull] {:text "You start drinking with the seagull. The seagull drunkenly points in the corner." :action [unhide :broom]}
+   [:starfish :window-open] {:text "You throw the starfish out the window. Looks like it attracted a seagull." :action [unhide :seagull hide :starfish]}
+   [:bottle :seagull] {:text "You start drinking with the seagull. The seagull drunkenly points in the corner and leaves." :action [unhide :broom hide :seagull]}
    [:bottle :starfish] {:text "You hand the bottle to the starfish. It takes a sip of wine, but it's more of a whiskey person."}
    [:broom :window-open] {:text "You catapult yourself out of the room with the broom. FREEDOM! You won." :action [win-game]}
    [:broom :bucket] {:text "You try to put the broom in the bucket. That's where the broom belongs, but you're not here to clean up."}
@@ -110,6 +116,8 @@
         (cond
           (= actions-count 1) ((first (:action todo)) new-state)
           (= actions-count 2) ((first (:action todo)) new-state (last (:action todo)))
+          (= actions-count 4) (let [newer-state ((first (:action todo)) new-state (nth (:action todo) 1))]
+                               ((nth (:action todo) 2) newer-state (last (:action todo))))
           :else new-state))
       state)))


even more cleanup

even more cleanup

--- src/tabby/net.clj
+++ src/tabby/net.clj
@@ -91,14 +91,18 @@
     (s/put! (get-in @state [:peer-sockets peer]) pkt))
   true)

-(defn transmit [s]
-  (loop []
-    (if (empty? (:tx-queue @s))
-      s
-      (do
-        (send-pkt s (first (:tx-queue @s)))
-        (swap! s update-in [:tx-queue] rest)
-        (recur)))))
+(defn transmit [state]
+  (swap! state (fn [s]
+                 (doseq [pkt (:tx-queue s)]
+                   (send-pkt state pkt))
+                 (assoc s :tx-queue '()))))
+  ;; (loop []
+  ;;   (if (empty? (:tx-queue @s))
+  ;;     s
+  ;;     (do
+  ;;       (send-pkt s (first (:tx-queue @s)))
+  ;;       (swap! s update-in [:tx-queue] rest)
+  ;;       (recur)))))

 (defn handle-rx-pkt [state dt pkt]
   (swap! state (fn [s]
@@ -112,17 +116,16 @@
       (if (a/alt!
             (:rx-chan @state) ([v] (handle-rx-pkt state (- (now) t) v))
             stop false
-            (a/timeout 10) (handle-timeout state (- (now) t))
-            (:tx-chan @state) ([v] (send-pkt state v)))
+            (a/timeout 10) (handle-timeout state (- (now) t)))
         (recur (now))
         :stopped))
     stop))

 (defn create-server [server]
-  (let [s (atom (assoc server :time (System/currentTimeMillis)))
+  (let [s (atom server)
         socket (start-server (connection-handler s) (+ (:id server) 8080))]
     (swap! s merge {:server-socket socket
-                    :rx-chan (a/chan) :tx-chan (a/chan)})
+                    :rx-chan (a/chan)})
     s))

 (def servers {})


indentation

indentation

--- src/metabase/util/stats.clj
+++ src/metabase/util/stats.clj
@@ -280,19 +280,18 @@
   []
   (merge (instance-settings)
            {:uuid anonymous-id :timestamp (new java.util.Date)}
-            {:stats {
-               :user (user-metrics)
-               :question (question-metrics)
-               :dashboard (dashboard-metrics)
-               :database (database-metrics)
-               :table (table-metrics)
-               :field (field-metrics)
-               :pulse (pulse-metrics)
-               :segment (segment-metrics)
-               :metric (metric-metrics)
-               :group (group-metrics)
-               :label (label-metrics)
-               :execution (execution-metrics)}}))
+            {:stats {:user (user-metrics)
+                     :question (question-metrics)
+                     :dashboard (dashboard-metrics)
+                     :database (database-metrics)
+                     :table (table-metrics)
+                     :field (field-metrics)
+                     :pulse (pulse-metrics)
+                     :segment (segment-metrics)
+                     :metric (metric-metrics)
+                     :group (group-metrics)
+                     :label (label-metrics)
+                     :execution (execution-metrics)}}))

 (defn- send-stats!


cleanup in progress

cleanup in progress

--- src/midje/util/checkers.clj
+++ src/midje/util/checkers.clj
@@ -349,32 +349,30 @@
  ;;

-(defn compatibility-check [actual expected kind]
+(defn compatibility-failure [actual expected kind]
   (cond (regex? expected)
-	(cond (and (not (sequential? actual))
-		   (not (empty? kind)))
-	      (throw (Error. (str "I don't know how to make sense of a "
-				  "regular expression applied "
-				  kind "."))))
+	(and (not (sequential? actual))
+	     (not (empty? kind))
+	     (noted-falsehood (str "I don't know how to make sense of a "
+				   "regular expression applied "
+				   kind ".")))

 	(not (collection-like? actual))
-	(throw (Error. (str "You can't compare " (pr-str actual) " (" (type actual)
-			    ") to " (pr-str expected) " (" (type expected) ").")))
+	(noted-falsehood (format "You can't compare %s (%s) to %s (%s)."
+				 (pr-str actual) (type actual)
+				 (pr-str expected) (type expected)))

 	(and (map? actual)
 	     (not (map? expected)))
-	(try (into {} expected)
+	(try (into {} expected) nil
 	     (catch Throwable ex
-	       (throw (Error. (str "If " (pr-str actual) " is a map, "
-				   (pr-str expected)
-				   " should look like map entries.")))))))
-
+	       (format "If %s is a map, %s should look like map entries."
+		       (pr-str actual) (pr-str expected))))))

 (defn- standardized-arguments [actual expected kind]
   "Reduce arguments to standard forms so there are fewer combinations to
-   consider. Also blow up for some incompatible forms."
-
-  (compatibility-check actual expected kind)
+   consider."
+
   (cond (sequential? actual)
 	(cond (set? expected)
 	      [actual (vec expected) (union kind #{:in-any-order})]
@@ -521,13 +519,16 @@
                 (fn [actual#]
                   ;; (prn "checking" actual# expected# kind#)
                   (add-actual actual#
-                              (try (~checker-fn actual# expected# kind#)
-                                   (catch Error ex#
-                                     (tag-as-chatty-falsehood {
-                                                               :notes [(.getMessage ex#)]}))))))
-         merge
-         {:midje/chatty-checker true, :midje/checker true}))
-       {:midje/checker true}))
+			      (if (chatty-checker-falsehood?
+				   (compatibility-failure actual# expected# kind#))
+				(compatibility-failure actual# expected# kind#)
+				(try (~checker-fn actual# expected# kind#)
+				     (catch Error ex#
+				       (tag-as-chatty-falsehood {
+								 :notes [(.getMessage ex#)]}))))))
+		merge
+		{:midje/chatty-checker true, :midje/checker true}))
+       {:midje/checker true})))

 (def contains (container-checker contains
     (fn [actual expected kind]


Add convenience

Add convenience

--- src/tick/core.clj
+++ src/tick/core.clj
@@ -529,7 +529,7 @@
   OffsetTime
   (on [t date] (.atTime date t))
   LocalDate
-  (at [date time] (.atTime date time)))
+  (at [date t] (.atTime date (time t))))

 (defn midnight [^LocalDate date]
   (at date (LocalTime/MIDNIGHT)))
@@ -546,25 +546,25 @@

 (extend-protocol IAtZone
   LocalDateTime
-  (at-zone [t zone] (.atZone t zone))
+  (at-zone [t z] (.atZone t (zone z)))
   (as-local
     ([t] t)
-    ([t zone] (as-local (at-zone t zone))))
+    ([t z] (as-local (at-zone t (zone z)))))
   Instant
-  (at-zone [t zone] (.atZone t zone))
+  (at-zone [t z] (.atZone t (zone z)))
   (as-local
     ([t] (throw (ex-info "Error, zone required" {})))
-    ([t zone] (as-local (at-zone t zone))))
+    ([t z] (as-local (at-zone t (zone z)))))
   ZonedDateTime
-  (at-zone [t zone] (.withZoneSameInstant t zone))
+  (at-zone [t z] (.withZoneSameInstant t (zone z)))
   (as-local
     ([t] (.toLocalDateTime t))
-    ([t zone] (as-local (at-zone t zone))))
+    ([t z] (as-local (at-zone t (zone z)))))
   Date
-  (at-zone [t zone] (at-zone (instant t) zone))
+  (at-zone [t z] (at-zone (instant t) (zone z)))
   (as-local
     ([t] (throw (ex-info "Error, zone required" {})))
-    ([t zone] (as-local (at-zone t zone)))))
+    ([t z] (as-local (at-zone t (zone z))))))

 (defprotocol ILocalTime
   (local? [t] "Is the time a java.time.LocalTime or java.time.LocalDateTime?"))


Revert "Change output file type from resource to asset"

Cljs output files have to be on classpath so it's possible to serve them
using resource-handler.

This reverts commit 0c7fac5358a645e8ea471990e343d414f98cb3e9.

--- src/adzerk/boot_cljs.clj
+++ src/adzerk/boot_cljs.clj
@@ -204,10 +204,7 @@
               ;; builds. Each :output-to js file will depend only on compiled
               ;; namespaces in its own :output-dir, including goog/base.js etc.
               dep-order (reduce into [] (map :dep-order results))]
-          ;; Added as asset (output-only) files so that other cljs tasks
-          ;; don't see these as input files.
-          ;; TODO: Does this cause other problems?
           (-> fileset
-              (core/add-asset tmp-result)
+              (core/add-resource tmp-result)
               (core/add-meta (deps/compiled fileset dep-order))
               core/commit!))))))


fix Genetics Pavilion + Fisk Investment Seminar

--- src/clj/game/cards-assets.clj
+++ src/clj/game/cards-assets.clj
@@ -336,9 +336,9 @@
    "Genetics Pavilion"
    {:msg "prevent the Runner from drawing more than 2 cards during their turn"
     :effect (req (max-draw state :runner 2)
-                 (when (= 0 (remaining-draws state side))
-                   (prevent-draw state side)))
-    :events {:runner-turn-begins {:effect (effect (max-draw 2))}}
+                 (when (= 0 (remaining-draws state :runner))
+                   (prevent-draw state :runner)))
+    :events {:runner-turn-begins {:effect (effect (max-draw :runner 2))}}
     :leave-play (req (swap! state update-in [:runner :register] dissoc :max-draw))}

    "Ghost Branch"


query

query

--- src/clj/hdfs_cleaner/core.clj
+++ src/clj/hdfs_cleaner/core.clj
@@ -32,7 +32,7 @@
   (routes
     (GET ["/scan:path", :path #"\/.+"]
          {{hdfs-path :path} :route-params
-          {:keys [depth] :as query} :query-params}
+          {:keys [depth] :as query} :query}
       (spy [depth query])
       (http-res/response (hdfs/scan [hdfs-path depth])))
     (GET "/ping" {}


badge-settings, save evidence, delete evidence

--- src/clj/salava/badge/main.clj
+++ src/clj/salava/badge/main.clj
@@ -4,7 +4,7 @@
             [clojure.tools.logging :as log]
             [clojure.java.jdbc :as jdbc]
             [clojure.set :refer [rename-keys]]
-            [clojure.string :refer [blank? split upper-case lower-case capitalize includes?]]
+            [clojure.string :refer [blank? split upper-case lower-case capitalize includes? join]]
             [slingshot.slingshot :refer :all]
             [clojure.data.json :as json]
             [salava.core.time :refer [unix-time date-from-unix-time]]
@@ -145,6 +145,9 @@
                                            :expires (if expires (date-from-unix-time (* 1000 expires)) "-")))
     (catch Object _
       (log/error "parse-assertion-json: " _))))
+
+(defn badge-evidences "get user-badge evidences" [ctx badge-id]
+  (select-user-badge-evidence {:user_badge_id badge-id} (u/get-db ctx)))

 (defn fetch-badge [ctx badge-id]
@@ -173,6 +176,7 @@
         badge (badge-issued-and-verified-by-obf ctx badge)
         recipient-count (select-badge-recipient-count {:badge_id (:badge_id badge) :visibility (if user-id "internal" "public")}
                                                       (into {:result-set-fn first :row-fn :recipient_count} (u/get-db ctx)))
+        evidences (badge-evidences ctx badge-id)

     ]
     (assoc badge :congratulated? user-congratulation?
@@ -184,7 +188,10 @@
                  :revoked (check-badge-revoked ctx badge-id (:revoked badge) (:assertion_url badge) (:last_checked badge))
                  :assertion (parse-assertion-json (:assertion_json badge))

-                 :qr_code (u/str->qr-base64 (badge-url ctx badge-id)))))
+                 :qr_code (u/str->qr-base64 (badge-url ctx badge-id))
+              ;;
+                 :evidences evidences
+      )))

 (defn get-endorsements [ctx badge-id]
@@ -307,13 +314,25 @@
     (catch Object _
       {:status "error" :message _})))

-(defn badge-settings
+#_(defn badge-settings
   "Get badge settings"
   [ctx user-badge-id user-id]
   (if (badge-owner? ctx user-badge-id user-id)
     (let [badge (update (select-badge-settings {:id user-badge-id} (into {:result-set-fn first} (u/get-db ctx))) :criteria_content u/md->html)
           tags (select-taglist {:user_badge_ids [user-badge-id]} (u/get-db ctx))]
       (assoc-badge-tags badge tags))))
+
+(defn badge-settings "Get badge settings" [ctx user-badge-id user-id]
+  (if (badge-owner? ctx user-badge-id user-id)
+    (let [badge (update (select-badge-settings {:id user-badge-id} (into {:result-set-fn first} (u/get-db ctx))) :criteria_content u/md->html)
+          tags (select-taglist {:user_badge_ids [user-badge-id]} (u/get-db ctx))
+          evidences (badge-evidences ctx user-badge-id)]
+      (-> (assoc-badge-tags badge tags)
+          (assoc :evidences evidences)
+          )
+      )
+    )
+  )

 (defn send-badge-info-to-obf [ctx user-badge-id user-id]
   (let [obf-url (get-in ctx [:config :core :obf :url])
@@ -333,6 +352,38 @@
     (if id
       (update-user-badge-evidence! {:url url :id id} (u/get-db ctx))
       (insert-user-badge-evidence-url<! {:user_badge_id user-badge-id :url url} (u/get-db ctx)))))
+
+
+(defn save-badge-evidence [ctx user-id user-badge-id evidence-id name description audience genre url narrative]
+    (try+
+      (if (badge-owner? ctx user-badge-id user-id)
+        (let [data {:user_badge_id user-badge-id :url url :narrative narrative :name name :description description :genre genre :audience audience}]
+          (if evidence-id
+            (update-user-badge-evidence2! (assoc data :id evidence-id) #_{:id evidence-id :user_badge_id user-badge-id :url url :narrative narrative :name name :description description :genre genre :audience audience} (u/get-db ctx))
+            (insert-evidence<! data #_{:user_badge_id user-badge-id :url url :narrative narrative :name name :description description :genre genre :audience audience} (u/get-db ctx))
+            )
+          {:status "success"})
+        (throw+ {:status "error"})
+        )
+      (catch Object _
+        (log/error _)
+        {:status "error"})
+      ))
+
+(defn delete-evidence! [ctx evidence-id user-badge-id user-id]
+  (try+
+    (if (badge-owner? ctx user-badge-id user-id)
+      (do
+        (delete-user-badge-evidence! {:id evidence-id :user_badge_id user-badge-id} (u/get-db ctx))
+        {:status "success"})
+
+      {:status "error"})
+
+    (catch Object _
+    (log/error _)
+    {:status "error"}))
+  )
+

 ;TODO rework evidence
 (defn save-badge-settings!


tests for Amped Up, Dirty Laundry, Lawyer Up, Modded, Vamp

--- src/clj/test/cards-events.clj
+++ src/clj/test/cards-events.clj
@@ -25,6 +25,20 @@
     (is (= 0 (:tag (get-runner)))) ; no new tags
     (is (= 5 (:credit (get-runner)))) ; no change in credits
     (is (= 8 (:credit (get-corp))))))
+
+(deftest amped-up
+  "Amped Up - Gain 3 clicks and take 1 unpreventable brain damage"
+  (do-game
+    (new-game (default-corp)
+              (default-runner [(qty "Amped Up" 1) (qty "Feedback Filter" 1) (qty "Sure Gamble" 3)]))
+    (take-credits state :corp)
+    (play-from-hand state :runner "Feedback Filter")
+    (play-from-hand state :runner "Amped Up")
+    (is (empty? (:prompt (get-runner))) "Feedback Filter brain damage prevention opportunity not given")
+    (is (= 5 (:click (get-runner))))
+    (is (= 2 (count (:discard (get-runner)))))
+    (is (= 4 (:max-hand-size (get-runner))))
+    (is (= 1 (:brain-damage (get-runner))) "Took 1 brain damage")))

 (deftest apocalypse-turn-facedown
   "Apocalypse - Turn Runner cards facedown without firing their leave play effects"
@@ -123,6 +137,23 @@
       (is (= 0 (:agenda-point (get-runner))) "Didn't steal False Lead")
       (is (= 2 (count (:discard (get-corp)))) "2 cards in Archives")
       (is (empty? (:prompt (get-runner))) "Run concluded"))))
+
+(deftest dirty-laundry
+  "Dirty Laundry - Gain 5 credits at the end of the run if it was successful"
+  (do-game
+    (new-game (default-corp)
+              (default-runner [(qty "Dirty Laundry" 2)]))
+    (take-credits state :corp)
+    (play-from-hand state :runner "Dirty Laundry")
+    (prompt-choice :runner "Archives")
+    (core/no-action state :corp nil)
+    (core/successful-run state :runner nil)
+    (is (= 8 (:credit (get-runner))) "Gained 5 credits")
+    (play-from-hand state :runner "Dirty Laundry")
+    (prompt-choice :runner "Archives")
+    (core/no-action state :corp nil)
+    (core/jack-out state :runner nil)
+    (is (= 6 (:credit (get-runner))) "Run unsuccessful; gained no credits")))

 (deftest drive-by
   "Drive By - Expose card in remote server and trash if asset or upgrade"
@@ -184,6 +215,38 @@
     (is (= 2 (count (filter #(= (:type %) "Program") (:discard (get-runner))))) "2 programs in Heap")
     (is (= 6 (:credit (get-runner))) "Paid 1 credit to play Inject, gained 2 credits from trashed programs")))

+(deftest lawyer-up
+  "Lawyer Up - Lose 2 tags and draw 3 cards"
+  (do-game
+    (new-game (default-corp)
+              (default-runner [(qty "Lawyer Up" 1) (qty "Sure Gamble" 3)]))
+    (take-credits state :corp)
+    (core/move state :runner (find-card "Sure Gamble" (:hand (get-runner))) :deck)
+    (core/move state :runner (find-card "Sure Gamble" (:hand (get-runner))) :deck)
+    (core/move state :runner (find-card "Sure Gamble" (:hand (get-runner))) :deck)
+    (core/gain state :runner :tag 3)
+    (play-from-hand state :runner "Lawyer Up")
+    (is (= 3 (count (:hand (get-runner)))) "Drew 3 cards")
+    (is (= 2 (:click (get-runner))) "Spent 2 clicks")
+    (is (= 1 (:tag (get-runner))) "Lost 2 tags")))
+
+(deftest modded
+  "Modded - Install a program or piece of hardware at a 3 credit discount"
+  (do-game
+    (new-game (default-corp)
+              (default-runner [(qty "Modded" 2) (qty "HQ Interface" 1) (qty "Nerve Agent" 1) (qty "Earthrise Hotel" 1)]))
+    (take-credits state :corp)
+    (play-from-hand state :runner "Modded")
+    (prompt-select :runner (find-card "Earthrise Hotel" (:hand (get-runner))))
+    (is (empty? (get-in @state [:runner :rig :resource])) "Can't install resources with Modded")
+    (prompt-select :runner (find-card "HQ Interface" (:hand (get-runner))))
+    (is (= 1 (count (get-in @state [:runner :rig :hardware]))) "Installed HQ Interface")
+    (is (= 4 (:credit (get-runner))) "Paid 1 credit instead of 4")
+    (play-from-hand state :runner "Modded")
+    (prompt-select :runner (find-card "Nerve Agent" (:hand (get-runner))))
+    (is (= 1 (count (get-in @state [:runner :rig :program]))) "Installed Nerve Agent")
+    (is (= 4 (:credit (get-runner))) "Paid 0 credits")))
+
 (deftest notoriety
   "Notoriety - Run all 3 central servers successfully and play to gain 1 agenda point"
   (do-game
@@ -328,6 +391,22 @@
       (prompt-select :runner gd)
       (is (= 3 (get-in (refresh gd) [:counter]))))))

+(deftest vamp
+  "Vamp - Run HQ and use replace access to pay credits to drain equal amount from Corp"
+  (do-game
+    (new-game (default-corp) (default-runner [(qty "Vamp" 1) (qty "Sure Gamble" 3)]))
+    (take-credits state :corp)
+    (is (= 8 (:credit (get-corp))))
+    (play-from-hand state :runner "Sure Gamble")
+    (play-from-hand state :runner "Sure Gamble")
+    (is (= 13 (:credit (get-runner))))
+    (play-run-event state (find-card "Vamp" (:hand (get-runner))) :hq)
+    (prompt-choice :runner "Run ability")
+    (prompt-choice :runner 8)
+    (is (= 1 (:tag (get-runner))) "Took 1 tag")
+    (is (= 5 (:credit (get-runner))) "Paid 8 credits")
+    (is (= 0 (:credit (get-corp))) "Corp lost all 8 credits")))
+
 (deftest virus-counter-flag-on-enter
   "Set counter flag when virus card enters play with counters"
   (do-game


remove unnecessary white space

remove unnecessary white space

--- src/clj_money/web/reports.clj
+++ src/clj_money/web/reports.clj
@@ -61,7 +61,7 @@
                                             entity-id
                                             as-of))]))

-(defn-  budget-report-row-class
+(defn- budget-report-row-class
   [record]
   (string/join " " (cond-> []
                      true (conj (format "report-%s" (-> record :style name)))


Updated, CCS-1791

Updated, CCS-1791

--- src/clj_mrazik/dictionary.clj
+++ src/clj_mrazik/dictionary.clj
@@ -2,6 +2,8 @@

 (require '[clj-mrazik.db-interface :as db-interface])

+; best colors: 10 4 6
+;
 (defn highlight
     [string color-code]
     (str (char 3) color-code string (char 3) "99"))
@@ -26,41 +28,56 @@
     [string]
     (highlight string "06"))

-(defn yes-no
+(defn yellow
+    [string]
+    (highlight string "08"))
+
+(defn bold
+    [string]
+    (str (char 2) string (char 15)))
+
+(defn reset
+    []
+    (str (char 15)))
+
+(defn yes-no-with-caution
     [w key]
     (condp = (get w key)
-          0 (red "no")
-          1 (green "yes")
-          2 (purple "with caution")))
+          0 (red    "no")
+          1 (green  "yes")
+          2 (yellow "with caution")))

 (defn incorrect-forms
     [w]
-    (str (black "class:")           (blue (:class w)) " "
-         (black "use it:")          (yes-no w :use) " "
-         (black "description:")     (blue (:description w)) " "
-         (black "source:")          (blue (:source w)) " "
-         (black "incorrect forms:") (blue (:incorrect_forms w)) " "
-         (black "see also:")        (blue (:see_also w))
+    (str (reset)
+         (bold "class: ")           (:class w) " "
+         (bold "use it: ")          (yes-no-with-caution w :use) " "
+         (bold "description: ")     (:description w) " "
+         (bold "source: ")          (:source w) " "
+         (bold "incorrect forms: ") (:incorrect_forms w) " "
+         (bold "see also: ")        (:see_also w)
 ))

 (defn correct-forms
     [w]
-    (str (black "class:")           (blue (:class w)) " "
-         (black "use it:")          (yes-no w :use) " "
-         (black "description:")     (blue (:description w)) " "
-         (black "source:")          (blue (:source w)) " "
-         (black "correct forms:")   (blue (:correct_forms w)) " "
-         (black "see also:")        (blue (:see_also w))
+    (str (reset)
+         (bold "class: ")           (:class w) " "
+         (bold "use it: ")          (yes-no-with-caution w :use) " "
+         (bold "description: ")     (:description w) " "
+         (bold "source: ")          (:source w) " "
+         (bold "correct forms: ")   (:correct_forms w) " "
+         (bold "see also: ")        (:see_also w)
 ))

 (defn preferred-forms
     [w]
-    (str "class: " (:class w) "  "
-         "use it: " (yes-no w :use) "  "
-         "description: " (:description w) "  "
-         "source: " (:source w) "  "
-         "preferred forms: " (:correct_forms w) "  "
-         "see also: " (:see_also w)
+    (str (reset)
+         (bold "class: ")           (:class w) " "
+         (bold "use it: ")          (yes-no-with-caution w :use) " "
+         (bold "description: ")     (:description w) " "
+         (bold "source: ")          (:source w) " "
+         (bold "preferred forms: ") (:correct_forms w) " "
+         (bold "see also: ")        (:see_also w)
 ))

 (defn find-word


Fix auto resize closes issue #13

Fix auto resize closes issue #13

--- src/clj_simple_chart/core.clj
+++ src/clj_simple_chart/core.clj
@@ -81,8 +81,16 @@
                       :padding "0 !important"
                       :overflow-x "hidden"
                       :overflow-y "hidden")]
+        attrs (second t)
+        width (:width attrs)
+        height (:height attrs)
         s (hiccup.core/html (conj body t))]
+    (Platform/runLater (fn [] (.setPrefHeight @webview height)))
+    (Platform/runLater (fn [] (.setPrefWidth @webview width)))
     (render-string s)
+    (wait-for-worker)
+    (Platform/runLater (fn [] (.sizeToScene @stage)))
+    (Platform/runLater (fn [] (.show @stage)))
     s))

 (defn export-to-file [filename t]
@@ -95,11 +103,6 @@
         width (:width attrs)
         height (:height attrs)]
     (render t)
-    (Platform/runLater (fn [] (.setPrefHeight @webview height)))
-    (Platform/runLater (fn [] (.setPrefWidth @webview width)))
-    (Platform/runLater (fn [] (.sizeToScene @stage)))
-    (Platform/runLater (fn [] (.show @stage)))
-    (wait-for-worker)
     (Platform/runLater
       (fn []
         (let [snap (SnapshotParameters.)]
@@ -128,13 +131,6 @@
         range-output))
     (with-meta all)))

-(def width 500)
-(def height 500)
-(def margin {:top 50 :bottom 50 :left 60 :right 40})
-
-(def y (scale-linear {:domain [0 100] :range [height 0]}))
-(def x (scale-linear {:domain [0 100] :range [0 width]}))
-
 (defn left-y-axis [scale]
   (let [tiks (apply ticks/ticks (:domain (meta scale)))]
     (map (fn [d] [:text {:x 0 :text-anchor "end" :dx "-.2em" :dy ".32em" :y (scale d)} (str d)]) tiks)))
@@ -143,6 +139,12 @@
   (let [tiks (apply ticks/ticks (:domain (meta scale)))]
     (map (fn [d] [:text {:x 0 :text-anchor "start" :dx ".2em" :dy ".32em" :y (scale d)} (str d)]) tiks)))

+(def width 500)
+(def height 500)
+(def margin {:top 50 :bottom 50 :left 60 :right 60})
+
+(def y (scale-linear {:domain [0 100] :range [height 0]}))
+(def x (scale-linear {:domain [0 100] :range [0 width]}))

 (def diagram
   [:svg {:width  (+ (:left margin) (:right margin) width)


Modify scoring formula

Modify scoring formula

--- src/cljc/robinson/render.cljc
+++ src/cljc/robinson/render.cljc
@@ -1024,15 +1024,15 @@
         thirst         (get-in state [:world :player :thirst])
         max-thirst     (get-in state [:world :player :max-thirst])
         will-to-live   (get-in state [:world :player :will-to-live])
-        cause-of-death (format "From %s"
-                               (or
-                                 (get-in state [:world :cause-of-death])
-                                 (cond
-                                   (<= hp 0)             "massive injuries"
-                                   (> hunger max-hunger) "literall starving to death"
-                                   (> thirst max-thirst) "not drinking enough water"
-                                   (<= will-to-live 0)   "just giving up on life"
-                                   :else                 "mysterious causes")))
+        cause-of-death (or
+                         (get-in state [:world :cause-of-death])
+                         (format "From %s"
+                           (cond
+                             (<= hp 0)             "massive injuries"
+                             (> hunger max-hunger) "literall starving to death"
+                             (> thirst max-thirst) "not drinking enough water"
+                             (<= will-to-live 0)   "just giving up on life"
+                             :else                 "mysterious causes")))
         width          (max 25 (markup->length cause-of-death))]
     (render-list screen 27 4 width 6
       (concat
@@ -1517,7 +1517,10 @@
   (let [cur-state      (current-state state)
         points         (int
                          (* (+ (get-in state [:world :player :will-to-live])
-                               (/ 50000 (get-time state)))
+                               (rp/player-xp state)
+                               (get-time state)
+                               (reduce-kv #(+ %1 %3) 0 (get-in state [:world :player :stats :num-items-harvested]))
+                               (reduce-kv #(+ %1 %3) 0 (get-in state [:world :player :stats :num-items-crafted])))
                             (case cur-state
                               :game-over-dead 1
                               :game-over-rescued 2)))


removed the useless nil in get-all

removed the useless nil in get-all

--- src/cljs/tictactoe/utils.cljs
+++ src/cljs/tictactoe/utils.cljs
@@ -10,5 +10,5 @@
   "Get all the values associated to the key"
   [col keys]
   (eduction
-    (map #(get col % nil))
+    (map #(get col %))
     keys))


Force evaluation of for. Fixes phase 1.

Force evaluation of for. Fixes phase 1.

--- src/onyx/peer/transform.clj
+++ src/onyx/peer/transform.clj
@@ -31,8 +31,9 @@
   (pr-str segment))

 (defn write-batch [queue session producers msgs]
-  (for [p producers msg msgs]
-    (extensions/produce-message queue p session msg)))
+  (dorun
+   (for [p producers msg msgs]
+     (extensions/produce-message queue p session msg))))

 (defn read-batch-shim
   [{:keys [queue session ingress-queues batch-size timeout]}]


Log read entries in case we hit an infinitely playing log and never timeout

--- src/onyx_jepsen/checker.clj
+++ src/onyx_jepsen/checker.clj
@@ -11,11 +11,12 @@

 (defn read-peer-log [log]
   (let [ch (chan 1000)
-        timeout-ms 1000]
+        timeout-ms 20000]
     (onyx.extensions/subscribe-to-log log ch)
     (loop [entries []]
       (if-let [entry (first (alts!! [ch (casync/timeout timeout-ms)]))]
-        (recur (conj entries entry))
+        (do (info "Read " entry)
+            (recur (conj entries entry)))
         entries))))

 (defn base-replica [peer-config]


Minor docstring fix

Minor docstring fix

--- src/com/palletops/cli/api.clj
+++ src/com/palletops/cli/api.clj
@@ -29,7 +29,7 @@

 ;;; ## Exception Handling
 (defn handle-exceptions*
-  "Executes a function with handling of exceptions contain :exit-code."
+  "Executes a function with handling of exceptions containing :exit-code."
   [f]
   (try
     (f)


Initial stab at page processing + avoid dotfiles in directory scan.

--- src/org/scode/sob/repos.clj
+++ src/org/scode/sob/repos.clj
@@ -36,22 +36,43 @@
   [s]
   (read (java.io.PushbackReader. (java.io.StringReader. s))))

+(defn- process-page
+  [s]
+  (let [r (java.io.PushbackReader. (java.io.StringReader. s))
+        meta (read r)]
+    (loop [next-char (.read r)]
+      (if (Character/isSpaceChar next-char)
+        (recur (.read r))
+        (do
+          (.unread r next-char))))
+    (let [html (markdown/to-html (duck-streams/slurp* r))]
+      [(:title meta) (:published? meta) (:pub-date meta) html])))
+
 (defn- make-page
   [f]
   (logging/info (str "processing new or possibly changed post " f))
-  (let [source (duck-streams/slurp* f)]
+  (let [source (duck-streams/slurp* f)
+        [title published? pub-date html] (process-page source)]
     {:fname (.getName f)
      :scan-checkpoint (dec (System/currentTimeMillis))
      :source source
-     }));; todo, process/render
+     :title title
+     :published? published?
+     :pub-date pub-date
+     :html html}))

 (defn- scan-pages
   "Inspect path for new, removed or updated pages relative to old-pages,
    and return a new pages map."
   [dir old-pages]
+  ; note 1: Avoiding dot files makes sense in general, and
+  ; specifically avoids the .#FNAME symlinks dropped by emacs while
+  ; editing.
   (let [now (System/currentTimeMillis)
         file-map (into {} (for [file (.listFiles dir)
-                                :when (.endsWith (.getName file) ".post")]
+                                :when (and (.endsWith (.getName file) ".post")
+                                           ; see note 1:
+                                           (not (.startsWith (.getName file) ".")))]
                             [(.getName file) file]))
         old-map (zipmap (map :fname old-pages) old-pages)
         make-page-cached (fn [[fname f]]


+(defn generate-all)

+(defn generate-all)

--- src/babel/english.cljc
+++ src/babel/english.cljc
@@ -37,6 +37,16 @@
     (if result
       (conj {:surface (fo result)}
             result))))
+
+(defn generate-all
+  [spec & {:keys [max-total-depth model truncate-children]
+           :or {max-total-depth generate/max-total-depth
+                truncate-children true
+                model (medium)}}]
+  (log/debug (str "generating with spec: " (strip-refs spec) " with max-total-depth: " max-total-depth))
+  (generate/generate-all spec model 0
+                         :max-total-depth max-total-depth
+                         :truncate-children truncate-children))

 ;; can't decide between 'morph' or 'fo' or something other better name.
 (defn morph [expr & {:keys [from-language show-notes]


Fixed assoc-route-params for routes using regular expressions.

Signed-off-by: James Reeves <9dadf8ecafa226c8f7c16002bdcb090267879343@weavejester.com>

--- src/compojure/http/routes.clj
+++ src/compojure/http/routes.clj
@@ -192,7 +192,8 @@
   [request params]
   (-> request
     (assoc :route-params params)
-    (assoc :params (merge (:params request) params))))
+    (assoc :params (merge (:params request)
+                          (when (map? params) params)))))

 (defn compile-route
   "Compile a route in the form (method path & body) into a function."


Expanded doc for definst.

Expanded doc for definst.

--- src/overtone/studio/rig.clj
+++ src/overtone/studio/rig.clj
@@ -205,18 +205,41 @@
        (= ::instrument (:type o))))

 (defmacro definst
-  "Define an instrument and return a player function. The instrument definition
-  will be loaded immediately. Instruments differ from basic synths in that they
-  will automatically add pan2 and out ugens when necessary to create a stereo
-  synth. Also, each instrument is assigned its own group which all instances
-  will automatically be placed in. This allows you to control all of an
-  instrument's running synths with one command:
-
-  (ctrl inst-name :param val)
-
-  You may also kill an all of an instrument's running synths:
-
-  (kill inst-name)"
+  "Define an instrument and return a player function. Arguments are a vector
+  of name/value parameter pairs, for example:
+
+  (definst inst-name [param0 value0 param1 value1 param2 value2] ...)
+
+  The returned player function takes any number of positional arguments,
+  followed by any number of keyword arguments. For example, all of the following
+  are equivalent:
+
+  (inst-name 0 1 2)
+  (inst-name 0 1 :param2 2)
+  (inst-name :param1 1 :param0 0 :param2 2)
+
+  Omitted parameters are given their default value from the instrument's
+  parameter list.
+
+  The instrument definition will be loaded immediately. Instruments differ
+  from basic synths in that they will automatically add pan2 and out ugens
+  when necessary to create a stereo synth. Also, each instrument is assigned
+  its own group which all instances will automatically be placed in. This
+  allows you to control all of an instrument's running synths with one command:
+
+  (ctl inst-name :param0 val0 :param1 val1)
+
+  You may also kill all of an instrument's running synths:
+
+  (kill inst-name)
+
+  A doc string may also be included between the instrument's name ant
+  parameter list:
+
+  (definst lucille
+    \"What's that Lucille?\"
+    [] ...)
+  "
   [i-name & inst-form]
   (let [[i-name params ugen-form] (synth-form i-name inst-form)
         i-name (with-meta i-name (merge (meta i-name) {:type ::instrument}))]


write node

write node

--- src/atom_finder/core.clj
+++ src/atom_finder/core.clj
@@ -1,7 +1,8 @@
 (ns atom-finder.core
   (:import [org.eclipse.cdt.core.dom.ast gnu.cpp.GPPLanguage ASTVisitor]
            [org.eclipse.cdt.core.parser DefaultLogService FileContent IncludeFileContentProvider ScannerInfo]
-           [org.eclipse.cdt.internal.core.dom.parser.cpp CPPASTTranslationUnit]))
+           [org.eclipse.cdt.internal.core.dom.parser.cpp CPPASTTranslationUnit]
+           [org.eclipse.cdt.internal.core.dom.rewrite.astwriter ASTWriter]))

 (defn file-content
   "read in source file to be analyzed"
@@ -98,13 +99,28 @@
     node
     (flatten (map leaves (.getChildren node)))))

-(defn node-str [node]
-  (let [stx (.getSyntax node)]
-        (if (nil? stx)
-          "nil"
-          (.getImage stx))))
+(defn node-str
+  "Convert single node to string"
+  [node]
+  (if (nil? node)
+    "nil1"
+    (let [stx (.getSyntax node)]
+      (if (nil? stx)
+        "nil2"
+        (.getImage stx)))))

 (map node-str (leaves root))
+
+(defn write [node]
+  (let [writer (ASTWriter.)]
+    (.write writer node)))
+
+(print (write (ancestor 2 (nth (leaves root) 11))))
+(println "\n\n")
+
+(defn stringify
+  "Convert multiple tree to string"
+  [node])

 ;; http://stackoverflow.com/questions/23178750/iteratively-apply-function-to-its-result-without-generating-a-seq
 (defn fn-pow
@@ -119,10 +135,11 @@
 (defn filter-size
   "Return every sub-tree of size n"
   [n node]
-
   (distinct (map #(ancestor n %) (leaves node))))

-(filter-size 3 root)
+(node-str (nth (filter-size 2 root) 3))
+(map node-str (.getChildren (nth (filter-size 2 root) 3)))
+

 (def filename "/Users/dgopstein/nyu/confusion/atoms/simplifications/2000-natori/nonconfusing.c")


Revert "Check defroutes behavior"

Revert "Check defroutes behavior"

This reverts commit 8de01cb8bd444db822d91c07e74ed9653e63de42.

--- src/bookshelf/core.clj
+++ src/bookshelf/core.clj
@@ -7,17 +7,11 @@
   (:use [compojure.core :refer :all])
   (:use [compojure.route :as route]))

-(defn write-to-file []
-  (with-open [w (clojure.java.io/writer "/tmp/out" :append true)]
-    (.write w "hello\n"))
-  "wrote to file")
-
 (defn library-files []
   (file-seq (clojure.java.io/file "/Users/dan/GoogleDrive/Literature/iPad")))

 (defroutes handler
   (GET "/" [] (str/join "<br>" (library-files)))
-  (GET "/write" [] (write-to-file))
   (route/not-found "Invalid request"))

 (def app


Ditto

Ditto

--- test/clojurewerkz/cassaforte/utils_test.clj
+++ test/clojurewerkz/cassaforte/utils_test.clj
@@ -1,9 +1,9 @@
 (ns clojurewerkz.cassaforte.iterate-world-test
-  (:require [clojurewerkz.cassaforte.test-helper :as th])
-  (:use clojurewerkz.cassaforte.cql
-        clojurewerkz.cassaforte.utils
-        clojure.test
-        clojurewerkz.cassaforte.query))
+  (:require [clojurewerkz.cassaforte.test-helper :as th]
+            [clojurewerkz.cassaforte.cql :refer :all]
+            [clojure.test :refer :all]
+            [clojurewerkz.cassaforte.query :refer :all]
+            [clojurewerkz.cassaforte.utils :refer :all]))

 (use-fixtures :each th/initialize!)


Changes workflow from interactive-form to http-basic.

--- src/cadence/security.clj
+++ src/cadence/security.clj
@@ -8,7 +8,7 @@

 (def friend-settings
       {:credential-fn (partial creds/bcrypt-credential-fn model/get-user)
-       :workflows [(workflows/interactive-form)]
+       :workflows [(workflows/http-basic)]
        :login-uri "/login"
        :unauthorized-redirect-uri "/login"
        :default-landing-uri "/"})


cleanup

cleanup

--- src/ci3/server/watch.clj
+++ src/ci3/server/watch.clj
@@ -58,7 +58,7 @@
     (let [[json-str rest-msg] (str/split s #"\n" 2)]
       (try (*parse-json-stream (conj acc (json/parse-string json-str keyword)) rest-msg)
            (catch com.fasterxml.jackson.core.JsonParseException e
-             (println "JSON ERROR WHILE PARSE" s)
+             #_(println "JSON ERROR WHILE PARSE" s)
              [s acc])))
     [s acc]))

@@ -77,11 +77,11 @@
       (update-version (:resource opts) (get-in res [:object :metadata :resourceVersion]))
       ;; sometimes version is compacted :(
       (if (and (= "ERROR" (:type res)) (= "Expired" (get-in res [:object :reason])))
-        (do (println "OUTDATE version:" res)
+        (do #_(println "OUTDATE version:" res)
             (reset-version (:resource opts))
             (retry))
-        (do (println opts " for v:" (get-in res [:object :metadata :resourceVersion]))
-            (println "->" (:handler opts))
+        (do #_(println opts " for v:" (get-in res [:object :metadata :resourceVersion]))
+            #_(println "->" (:handler opts))
             (u/*apply (:handler opts) {:env env :resource (k8s/resolve-secrets res)}))))
     [body :continue]))

@@ -96,7 +96,8 @@
         q (build-watch-query env opts)
         q (if v (assoc-in q [:query :resourceVersion] v) q)
         on-change (mk-on-change env opts #(do-watch env client opts))]
-    (println "Watch " opts " from " v)
+    #_(println "Start Watch " opts " from " v)
+    (println "Start Watch ")
     (->> (http/request-stream client :get (:url q) on-change
                               :headers {"Authorization" (str "Bearer " (:kube-token env))}
                               :insecure? true
@@ -129,7 +130,7 @@
                   (do #_(println "ERRORED:" opts)
                       (#'do-watch env client (dissoc opts :request)))
                   (realized? (:done req))
-                  (do (println "DONE:" opts)
+                  (do #_(println "DONE:" opts)
                       (#'do-watch env client (dissoc opts :request))))))
         (Thread/sleep 10000)))
     (println "Stopping supervisor")


Ref shapes and transformations

Ref shapes and transformations

--- src/clj/brutha/shape.clj
+++ src/clj/brutha/shape.clj
@@ -1,8 +1,10 @@
-(ns brutha.shape)
+(ns brutha.shape
+  (:require [brutha.geo :as geo]))

 (defprotocol IShape
-  (-position [_])
-  (-hash [_]))
+  (-position [s])
+  (-id [s])
+  (-scale [s]))

 (defn shape? [s]
   (satisfies? IShape s))
@@ -10,5 +12,41 @@
 (defn position [s]
   (-position s))

-(defn shash [s]
-  (-hash s))
+(defn id [s]
+  (-id s))
+
+(defn scale [s]
+  (-scale s))
+
+(defrecord RefShape [id p s]
+  IShape
+  (-id [_]
+    id)
+  (-position [_]
+    p)
+  (-scale [_]
+    s))
+
+(defn ref-shape
+  ([id]
+     (ref-shape id [0 0] [1 1]))
+  ([id p s]
+     (->RefShape id p s)))
+
+(defrecord TransformedShape [shape p s]
+  IShape
+  (-id [_]
+    (-id shape))
+  (-position [_]
+    (geo/p+ p (-position shape)))
+  (-scale [_]
+    (geo/dot s (-scale shape))))
+
+(defn x-shape [shape p s]
+  (->TransformedShape shape p s))
+
+(defn s+ [shape v]
+  (x-shape shape v [1 1]))
+
+(defn s* [shape s]
+  (x-shape shape [0 0] s))


Fixed compilation errors in schema.

Fixed compilation errors in schema.

--- src/clj/forma/schema.clj
+++ src/clj/forma/schema.clj
@@ -1,5 +1,8 @@
 (ns forma.schema
-  (:require [forma.utils :as u]))
+  (:require [clojure.string :as s]
+            [forma.utils :as u]
+            [forma.reproject :as r]
+            [forma.date-time :as date]))

 (defn boundaries
   "Accepts a sequence of pairs of <initial time period, collection>
@@ -34,7 +37,7 @@
   ([start-idx series]
      (let [elems (count series)]
        (timeseries-value start-idx
-                         (dec (+ start elems))
+                         (dec (+ start-idx elems))
                          series)))
   ([start-idx end-idx series]
      (when series
@@ -125,12 +128,15 @@
 (defn neighbor-value
   "Accepts either a forma value or a sequence of sub-values."
   ([{:keys [fire-value short-drop long-drop t-stat]}]
-     (neighbor-value fire 1 short short long long t t))
+     (neighbor-value fire-value 1
+                     short-drop short-drop
+                     long-drop long-drop
+                     t-stat t-stat))
   ([fire neighbors avg-short min-short avg-long min-long avg-stat min-stat]
      {:fire-value     fire
       :neighbor-count neighbors
       :avg-short-drop avg-short
-      :min-short-drop mon-short
+      :min-short-drop min-short
       :avg-long-drop  avg-long
       :min-long-drop  min-long
       :avg-t-stat     avg-stat
@@ -163,7 +169,7 @@
         (update-in [:avg-t-stat]     u/weighted-mean t-stat 1)
         (update-in [:min-short-drop] min short)
         (update-in [:min-long-drop]  min long)
-        (update-in [:min-t-stat]     min t))))
+        (update-in [:min-t-stat]     min t-stat))))

 (defn combine-neighbors
   "Returns a new forma neighbor value generated by merging together
@@ -182,10 +188,10 @@
          long-mean long-min t-mean t-min] (unpack-neighbor-val neighbor-val)
         [k330 c50 ck fire] (extract-fields fire-val)
         [k330-n c50-n ck-n fire-n] (extract-fields fire-sum)]
-    (join \tab
-          [k330 c50 ck fire s-drop l-drop t-drop
-           k330-n c50-n ck-n fire-n
-           ct short-mean short-min long-mean long-min t-mean t-min])))
+    (s/join \tab
+            [k330 c50 ck fire s-drop l-drop t-drop
+             k330-n c50-n ck-n fire-n
+             ct short-mean short-min long-mean long-min t-mean t-min])))

 ;; ## Location

@@ -213,7 +219,7 @@
   returns a pixel location."
   [{:keys [spatial-res size index mod-h mod-v]} pix-idx]
   (apply pixel-location spatial-res mod-h mod-v
-         (r/tile-position m-res chunk-size chunk-idx pix-idx)))
+         (r/tile-position spatial-res size index pix-idx)))

 ;; ## Data Chunks


create service from custom registry api fix -> passing registry name instead of registry object (not known at the moment)

--- src/clj/swarmpit/api.clj
+++ src/clj/swarmpit/api.clj
@@ -324,7 +324,7 @@
     (rename-keys
       (if (= "dockerhub" registry-name)
         (create-dockerhub-service service secrets)
-        (create-registry-service service registry secrets)) {:ID :id})))
+        (create-registry-service service registry-name secrets)) {:ID :id})))

 (defn update-service
   [service-id service force?]


Remove deprecated org.apache.http APIs from cookie

--- src/clj_http/cookies.clj
+++ src/clj_http/cookies.clj
@@ -1,20 +1,19 @@
 (ns clj-http.cookies
   (:require [clj-http.util :refer [opt]]
             [clojure.string :refer [blank? join lower-case]])
-  (:import (org.apache.http.client.params ClientPNames CookiePolicy)
-           (org.apache.http.cookie ClientCookie CookieOrigin)
-           (org.apache.http.params BasicHttpParams)
+  (:import (org.apache.http.cookie ClientCookie CookieOrigin CookieSpec)
            (org.apache.http.impl.cookie BasicClientCookie2)
            (org.apache.http.impl.cookie BrowserCompatSpecFactory)
            (org.apache.http.message BasicHeader)
-           org.apache.http.client.CookieStore))
+           org.apache.http.client.CookieStore
+           (org.apache.http.impl.client BasicCookieStore)
+           (org.apache.http Header)
+           (org.apache.http.protocol BasicHttpContext)))

-(defn cookie-spec ^org.apache.http.cookie.CookieSpec []
-  (.newInstance
+(defn cookie-spec ^CookieSpec []
+  (.create
    (BrowserCompatSpecFactory.)
-   (doto (BasicHttpParams.)
-     (.setParameter ClientPNames/COOKIE_POLICY
-                    CookiePolicy/BROWSER_COMPATIBILITY))))
+   (BasicHttpContext.)))

 (defn compact-map
   "Removes all map entries where value is nil."
@@ -43,7 +42,7 @@
      :value (.getValue cookie)
      :version (.getVersion cookie)})])

-(defn ^org.apache.http.impl.cookie.BasicClientCookie2
+(defn ^BasicClientCookie2
   to-basic-client-cookie
   "Converts a cookie seq into a BasicClientCookie2."
   [[cookie-name cookie-content]]
@@ -98,7 +97,7 @@
   (when-let [header (-> (cookie-spec)
                         (.formatCookies [(to-basic-client-cookie cookie)])
                         first)]
-    (.getValue ^org.apache.http.Header header)))
+    (.getValue ^Header header)))

 (defn encode-cookies
   "Encode the cookie map into a string."
@@ -128,7 +127,7 @@
   "Returns a new, empty instance of the default implementation of the
   org.apache.http.client.CookieStore interface."
   []
-  (org.apache.http.impl.client.BasicCookieStore.))
+  (BasicCookieStore.))

 (defn get-cookies
   "Given a cookie-store, return a map of cookie name to a map of cookie values."


add friendly message for schema enum validations

--- src/clj_money/schema.clj
+++ src/clj_money/schema.clj
@@ -1,5 +1,6 @@
 (ns clj-money.schema
-  (:require [clojure.pprint :refer [pprint]])
+  (:require [clojure.pprint :refer [pprint]]
+            [clojure.string :as string])
   (:use clj-money.inflection))

 (def rules
@@ -11,6 +12,13 @@
     :message "must be a number"}
    {:fn #(re-find #"invalid format" (print-str %))
     :message "is not valid"}
+   {:fn (fn [violation]
+          (when-let [match (re-find #"#\{((\S+\s?)*)\}" (print-str violation))]
+            (-> match
+                second
+                (string/replace #"(?<=^| ):" "")
+                (string/replace " " ", "))))
+    :message "must be one of: %s"}
    {:fn #(re-find #"instance\? java\.lang\.String nil" (print-str %))
     :message "is required"}])

@@ -19,8 +27,10 @@
   a user-friendly message"
   [violation]
   (or (some (fn [{f :fn m :message}]
-              (when (f violation)
-                m))
+              (when-let [result (f violation)]
+                (if (seq? result)
+                  (apply format m result)
+                  (format m result))))
             rules)
       violation))


Return response in case of error while response json parsing.

--- src/clj_spotify/core.clj
+++ src/clj_spotify/core.clj
@@ -20,10 +20,12 @@
       (json-string-to-map (:body response))
       (catch java.lang.NullPointerException e
         {:error {:status "NullPointerException"
-                 :message (.getMessage e)}})
+                 :message (.getMessage e)
+                 :response response}})
       (catch Exception e
         {:error {:status "Exception"
-                 :message (.getMessage e)}}))
+                 :message (.getMessage e)
+                 :reponse response}}))
     {:status (:status response)}))

 (defn- build-new-url


comment figwheel

comment figwheel

--- src/cljs/ceres/core.cljs
+++ src/cljs/ceres/core.cljs
@@ -37,7 +37,7 @@
     :news-frequencies nil
     :tweet-count 0}))

-(fw/watch-and-reload
+#_(fw/watch-and-reload
   ;; :websocket-url "ws://localhost:3449/figwheel-ws" default
  :jsload-callback (fn [] (print "reloaded"))) ;; optional callback


Add :case-appropriate-family-uniformity meta-error

--- src/clojush/evaluate.clj
+++ src/clojush/evaluate.clj
@@ -370,6 +370,43 @@
                                      siblings)
                                1
                                2)))))))
+                            ;
+              (= cat :case-appropriate-family-uniformity)
+              (if (not (:print-history argmap))
+                (throw
+                  (Exception.
+                    ":print-history must be true for :case-family-uniformity"))
+                (if (or (empty? (:parent-uuids ind))
+                        (empty? (rest (:history ind))))
+                  (vec (repeat (count (:errors ind)) 1))
+                  (let [siblings (filter #(and (= (first (:parent-uuids ind))
+                                                  (first (:parent-uuids %)))
+                                               (not (empty? (rest (:history %))))) ; new random sibs don't count
+                                         evaluated-population)]
+                    (vec (for [case-index (range (count (:errors ind)))]
+                           (if (zero? (nth (second (:history ind)) case-index))
+                             (if ;; mom solved, error for any child to be different
+                               (some (fn [sib]
+                                       (not= (-> (:history sib) ;; sib error different than mom's
+                                                 (first)
+                                                 (nth case-index))
+                                             (-> (:history sib)
+                                                 (second)
+                                                 (nth case-index))))
+                                     siblings)
+                               1
+                               0)
+                             (if ;; mom unsolved, error if there's not a different child
+                               (some (fn [sib]
+                                       (not= (-> (:history sib) ;; sib error different than mom's
+                                                 (first)
+                                                 (nth case-index))
+                                             (-> (:history sib)
+                                                 (second)
+                                                 (nth case-index))))
+                                     siblings)
+                               0
+                               1)))))))
               ;
               (= cat :case-scaled-error-plus-change)
               #_(if (and (:parent1-errors ind)
@@ -1392,3 +1429,4 @@
                            :history (if print-history (cons e (:history i)) (:history i)))]
         new-ind))))

+


Add another experimental option for :discounted-case-improvements

--- src/clojush/evaluate.clj
+++ src/clojush/evaluate.clj
@@ -253,7 +253,7 @@
                             (if (empty? (rest (:history ind)))
                               (vec (repeat (count (:errors ind)) 1000000))
                               (vec (for [case-history (apply map list (:history ind))]
-                                     (if (<= (first case-history) error-threshold)
+                                     (if (<= (first case-history) error-threshold) ;; wrong, thresh is on total
                                        0 ;; solved, improvement doesn't matter
                                        (let [improvements (mapv (fn [[newer-error older-error]]
                                                                   (let [imp (- older-error newer-error)]
@@ -266,7 +266,10 @@
                                          (if (<= sum 0)
                                            1.0E100
                                            ;(* (first case-history) (/ 1.0 sum))
+                                           ; arbitrating error ties with improvement
                                            (+ (first case-history) (- 1.0 sum))
+                                           ; (mostly) arbitrating improvement ties with error
+                                           ;(+ (first case-history) (* 1000 (/ 1.0 sum)))
                                            )))))))
                           (= cat :reproductive-fidelity)
                           (let [g (:genome ind)]
@@ -366,3 +369,4 @@

+


renamed "card" to "board-piece"

renamed "card" to "board-piece"

--- src/cartagena/core.clj
+++ src/cartagena/core.clj
@@ -1,25 +1,25 @@
 (ns cartagena.core
   (:gen-class))

-(def card1 [:bottle :gun :hat :skull :knife :key])
-(def card2 [:knife :bottle :key :gun :hat :skull])
-(def card3 [:hat :key :gun :bottle :skull :knife])
-(def card4 [:key :bottle :skull :knife :hat :gun])
-(def card5 [:gun :key :knife :hat :skull :bottle])
-(def card6 [:hat :knife :key :bottle :gun :skull])
-(def card1r (vec (reverse card1)))
-(def card2r (vec (reverse card2)))
-(def card3r (vec (reverse card3)))
-(def card4r (vec (reverse card4)))
-(def card5r (vec (reverse card5)))
-(def card6r (vec (reverse card6)))
-(def all-cards [card1 card2 card3 card4 card5 card6
-                card1r card2r card3r card4r card5r card6r])
+(def board-piece1 [:bottle :gun :hat :skull :knife :key])
+(def board-piece2 [:knife :bottle :key :gun :hat :skull])
+(def board-piece3 [:hat :key :gun :bottle :skull :knife])
+(def board-piece4 [:key :bottle :skull :knife :hat :gun])
+(def board-piece5 [:gun :key :knife :hat :skull :bottle])
+(def board-piece6 [:hat :knife :key :bottle :gun :skull])
+(def board-piece1r (vec (reverse board-piece1)))
+(def board-piece2r (vec (reverse board-piece2)))
+(def board-piece3r (vec (reverse board-piece3)))
+(def board-piece4r (vec (reverse board-piece4)))
+(def board-piece5r (vec (reverse board-piece5)))
+(def board-piece6r (vec (reverse board-piece6)))
+(def all-board-pieces [board-piece1 board-piece2 board-piece3 board-piece4 board-piece5 board-piece6
+                board-piece1r board-piece2r board-piece3r board-piece4r board-piece5r board-piece6r])

 (defn initialize-board
   "Returns a vector populated with icons from the 6 of the board pieces concatenated."
   []
-  (->> all-cards
+  (->> all-board-pieces
        shuffle
        (take 6)
        flatten


Cleanup prog-history and prog-ss better on rollback.

--- src/cbfg/world/t1.cljs
+++ src/cbfg/world/t1.cljs
@@ -57,7 +57,8 @@
   ; Time-travel to the past if snapshot is available.
   (when-let [ago-ss (get @prog-ss ss-ts)]
     (ago-restore (actx-agw (:world @prog-base)) ago-ss)
-    (swap! prog-history #(vec (take (+ ss-ts 1) %)))
+    (swap! prog-history #(vec (filter (fn [[s & _]] (<= s ss-ts)) %)))
+    (swap! prog-ss #(apply hash-map (flatten (filter (fn [[s _]] (<= s ss-ts)) %))))
     ; TODO: This prog-frame deref is strange, as it turned into a
     ; om.core/MapCursor somehow during the event handler rather than
     ; an expected prog-frame dict.


Use new CSS.

Use new CSS.

--- src/clj/aspire/web.clj
+++ src/clj/aspire/web.clj
@@ -19,7 +19,8 @@
   :handle-ok (fn [_]
                (hiccup.page/html5
                 [:head
-                 [:link {:rel "stylesheet" :href "css/page.css"}]]
+                 ;; alt: page.css
+                 [:link {:rel "stylesheet" :href "css/global.css"}]]
                 [:body
                  [:div#main
                   [:div [:p#loading "Loading..."]]


Wyrm. Parasite messsage on trash.

Wyrm. Parasite messsage on trash.

--- src/clj/game/cards.clj
+++ src/clj/game/cards.clj
@@ -1545,7 +1545,8 @@
               :effect (effect (ice-strength-bonus (- (get-virus-counters state side card))))}
              :ice-strength-changed
              {:req (req (and (= (:cid target) (:cid (:host card))) (<= (:current-strength target) 0)))
-              :effect (effect (trash target))}}}
+              :effect (effect (trash target))
+              :msg (msg "trash " (:title target))}}}

    "Paricia"
    {:recurring 2}
@@ -2696,8 +2697,17 @@

    "Wyrm"
    {:abilities [{:cost [:credit 3] :msg "break 1 subroutine on ICE with 0 or less strength"}
-                {:cost [:credit 1] :msg "reduce ICE strength by 1"}
-                {:cost [:credit 1] :msg "add 1 strength" :effect (effect (pump card 1))}]}
+                {:cost [:credit 1]
+                 :label "give -1 strength to current ice" :msg (msg "give -1 strength to " (:title current-ice))
+                 :req (req current-ice)
+                 :effect (req (update! state side (update-in card [:wyrm-count] (fnil #(+ % 1) 0)))
+                              (update-ice-strength state side current-ice))}
+                {:cost [:credit 1] :msg "add 1 strength" :effect (effect (pump card 1))}]
+    :events (let [wy {:effect (req (update! state side (dissoc card :wyrm-count)))}]
+                 {:pre-ice-strength {:req (req (and (= (:cid target) (:cid current-ice)) (:wyrm-count card)))
+                                     :effect (req (let [c (:wyrm-count (get-card state card))]
+                                                       (ice-strength-bonus state side (- c))))}
+                  :pass-ice wy :run-ends wy})}

    "Yog.0"
    {:abilities [{:msg "break 1 code gate subroutine"}]}


Add type hint for server-connector

Add type hint for server-connector

When building a Graal native image, Graal isn't able to resolve which
method to call. Adding the varargs type hint fixes this.

--- ring-jetty-adapter/src/ring/adapter/jetty.clj
+++ ring-jetty-adapter/src/ring/adapter/jetty.clj
@@ -43,7 +43,7 @@
         (.setHandled base-request true)))))

 (defn- ^ServerConnector server-connector [^Server server & factories]
-  (ServerConnector. server (into-array ConnectionFactory factories)))
+  (ServerConnector. server #^"[Lorg.eclipse.jetty.server.ConnectionFactory;" (into-array ConnectionFactory factories)))

 (defn- ^HttpConfiguration http-config [options]
   (doto (HttpConfiguration.)


[CS] Fix tests for add-csv-specs

[CS] Fix tests for add-csv-specs

--- test/vip/data_processor/validation/db_test.clj
+++ test/vip/data_processor/validation/db_test.clj
@@ -37,7 +37,8 @@
   (testing "validates that only one row exists in certain files"
     (let [ctx (merge {:input [(io/as-file
                                 (io/resource "bad-number-of-rows/election.txt"))]
-                      :pipeline [(csv/load-csvs csv/csv-specs)
+                      :pipeline [(csv/add-csv-specs csv/csv-specs)
+                                 csv/load-csvs
                                  validate-one-record-limit]}
                      (sqlite/temp-db "too-many-records"))
           out-ctx (pipeline/run-pipeline ctx)]


Added style to container tags

Added style to container tags

--- src/compojure/html.clj
+++ src/compojure/html.clj
@@ -105,7 +105,7 @@

 (def container-tags
   #{:body :b :dd :div :dl :dt :em :fieldset :form :h1 :h2 :h3 :h4 :h5 :h6 :head
-    :html :i :label :li :ol :pre :script :span :strong :textarea :ul})
+    :html :i :label :li :ol :pre :script :span :strong :style :textarea :ul})

 (defn container-tag?
   "Returns true if tag isn't a container tag like div or script."


Refactor SGR parsing test

Refactor SGR parsing test

--- test/asciinema_player/vt_test.cljs
+++ test/asciinema_player/vt_test.cljs
@@ -1694,49 +1694,30 @@

   (testing "CSI m (SGR)"
     (let [vt (make-vt 21 1)
-          vt (reduce feed-csi vt ["0mA"
-                                  "1mA" ; turn on bold
-                                  "3mA" ; turn on italic
-                                  "4mA" ; turn on underline
-                                  "5mA" ; turn on blink
-                                  "7mA" ; turn on inverse
-                                  "21mA" ; turn off bold
-                                  "23mA" ; turn off italic
-                                  "24mA" ; turn off underline
-                                  "25mA" ; turn off blink
-                                  "27mA" ; turn off inverse
-                                  "32;43mA" ; fg 2, bg 3
-                                  "93;104mA" ; fg 11, bg 12
-                                  "39mA" ; default fg
-                                  "49mA" ; default bg
-                                  "32;43;1mA" ; fg 2, bg 3, bold
-                                  "0mA" ; reset all attrs (explicit "0" param)
-                                  "32;43;1mA" ; fg 2, bg 3, bold
-                                  "mA" ; reset all attrs (implicit "0" param)
-                                  "1;38;5;88;48;5;99;5mA"]) ; bold, fg 88, bg 99, blink
-          {:keys [lines]} vt
-          [line0 & _] lines]
-      (is (= line0 [[0x41 {}]
-                    [0x41 {:bold true}]
-                    [0x41 {:bold true :italic true}]
-                    [0x41 {:bold true :italic true :underline true}]
-                    [0x41 {:bold true :italic true :underline true :blink true}]
-                    [0x41 {:bold true :italic true :underline true :blink true :inverse true}]
-                    [0x41 {:italic true :underline true :blink true :inverse true}]
-                    [0x41 {:underline true :blink true :inverse true}]
-                    [0x41 {:blink true :inverse true}]
-                    [0x41 {:inverse true}]
-                    [0x41 {}]
-                    [0x41 {:fg 2 :bg 3}]
-                    [0x41 {:fg 11 :bg 12}]
-                    [0x41 {:bg 12}]
-                    [0x41 {}]
-                    [0x41 {:fg 2 :bg 3 :bold true}]
-                    [0x41 {}]
-                    [0x41 {:fg 2 :bg 3 :bold true}]
-                    [0x41 {}]
-                    [0x41 {:fg 88 :bg 99 :bold true :blink true}]
-                    [0x20 {}]]))))
+          all-on-params "1;3;4;5;7;31;42m"
+          all-on-attrs {:bold true :italic true :underline true :blink true
+                        :inverse true :fg 1 :bg 2}
+          expect-attrs #(is (= (-> %1 (feed-str "A") :lines ffirst last) %2))]
+      (expect-attrs (feed-csi vt "1m") {:bold true})
+      (expect-attrs (feed-csi vt "3m") {:italic true})
+      (expect-attrs (feed-csi vt "4m") {:underline true})
+      (expect-attrs (feed-csi vt "5m") {:blink true})
+      (expect-attrs (feed-csi vt "7m") {:inverse true})
+      (expect-attrs (feed-csi vt "32m") {:fg 2})
+      (expect-attrs (feed-csi vt "43m") {:bg 3})
+      (expect-attrs (feed-csi vt "93m") {:fg 11})
+      (expect-attrs (feed-csi vt "104m") {:bg 12})
+      (expect-attrs (feed-csi vt "1;38;5;88;48;5;99;5m") {:fg 88 :bg 99 :bold true :blink true})
+      (expect-attrs (feed-csi vt all-on-params) all-on-attrs)
+      (expect-attrs (reduce feed-csi vt [all-on-params   "m"]) {}) ; implicit 0 param
+      (expect-attrs (reduce feed-csi vt [all-on-params  "0m"]) {}) ; explicit 0 param
+      (expect-attrs (reduce feed-csi vt [all-on-params "21m"]) (dissoc all-on-attrs :bold))
+      (expect-attrs (reduce feed-csi vt [all-on-params "23m"]) (dissoc all-on-attrs :italic))
+      (expect-attrs (reduce feed-csi vt [all-on-params "24m"]) (dissoc all-on-attrs :underline))
+      (expect-attrs (reduce feed-csi vt [all-on-params "25m"]) (dissoc all-on-attrs :blink))
+      (expect-attrs (reduce feed-csi vt [all-on-params "27m"]) (dissoc all-on-attrs :inverse))
+      (expect-attrs (reduce feed-csi vt [all-on-params "39m"]) (dissoc all-on-attrs :fg))
+      (expect-attrs (reduce feed-csi vt [all-on-params "49m"]) (dissoc all-on-attrs :bg))))

   (testing "CSI !p (DECSTR)"
     (let [vt (-> (make-vt 4 4)


adding integration meta

adding integration meta

--- test/celestial/features/stacks.clj
+++ test/celestial/features/stacks.clj
@@ -13,7 +13,7 @@

 (with-conf
   (with-state-changes [(before :facts (re-initlize))]
-    (fact "stack persistency" :redis :stacks :persistency
+    (fact "stack persistency" :redis :stacks :persistency :integration
       (s/add-stack simple-stack) => 1
       (s/update-stack "1" (assoc-in simple-stack [:shared :env] :qa))
       (get-in (s/get-stack 1) [:shared :env])  => :qa


Generate friend's attrs based on index

Generate friend's attrs based on index

--- test/graphql_clj/executor_test.clj
+++ test/graphql_clj/executor_test.clj
@@ -44,8 +44,8 @@
                        {:name "Test son name"
                         :nickname "Son's nickname"})
       ["User" "friends"] (fn [context parent & args]
-                           (map (fn [no] {:name "Friend 1 name"
-                                          :nickname "Friend 1 nickname"})
+                           (map (fn [no] {:name (format "Friend %s name" no)
+                                          :nickname (format "Friend %s nickname" no)})
                                 (range 5)))
       ["User" "phones"] (fn [context parent & args]
                           (->> (range 3) (map str) vec))


CMR-6219 broke method into multi-method, safeguards for only handling variable and service associations

--- search-app/src/cmr/search/api/association.clj
+++ search-app/src/cmr/search/api/association.clj
@@ -34,16 +34,45 @@
     (acl/verify-ingest-management-permission
      context :update :provider-object provider-id)))

-(defn- association-results->status-code
+(defn- results-contain-errors?
+  "Returns true if the results contain a :error key"
+  [results]
+  (some? (filter #(some? (:errors %)) results)))
+
+(defmulti association-results->status-code
+  [concept-type results]
+  concept-type)
+
+(defmethod association-results->status-code :default
   "If the concept-type is :variable the function will check for any errors in the results, and will return 400 if
   any are present. Otherwise it will return 200"
   ([results]
    (let [errors-during-association (filter #(some? (:errors %)) results)]
      (if (seq errors-during-association) 400 200)))
   ([results concept-type]
-   (if (= :variable concept-type)
+   (if (some #{concept-type} '(:variable :service))
      (association-results->status-code results)
      200)))
+
+(defmulti association-results->status-code
+  [concept-type results]
+  concept-type)
+
+(defmethod association-results->status-code :default
+  [_ _]
+  200)
+
+(defmethod association-results->status-code :service
+  "If the concept-type is :service the function will check for any errors in the results, and will return 400 if
+  any are present. Otherwise it will return 200"
+  [_ results]
+  (if (results-contain-errors? results) 400 200))
+
+(defmethod association-results->status-code :variable
+  "If the concept-type is :variable the function will check for any errors in the reuslts, and will return 400 if
+  any are present. Otherwise it will return 200"
+  [_ results]
+  (if (results-contain-error? results) 400 200))

 (defn associate-concept-to-collections
   "Associate the given concept by concept type and concept id to a list of
@@ -60,7 +89,7 @@
       400
       {:error "Only one collection allowed in the list because a variable can only be associated with one collection."})
     (let [results (assoc-service/associate-to-collections context concept-type concept-id body)
-          status-code (association-results->status-code results concept-type)]
+          status-code (association-results->status-code concept-type results)]
         (api-response status-code results))))

 (defn dissociate-concept-from-collections


another test function; use the shared object, not the .la file

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

--- plugins/DLLAutoReloader/src/DLLAutoReloader/core.clj
+++ plugins/DLLAutoReloader/src/DLLAutoReloader/core.clj
@@ -143,6 +143,7 @@
    stop-following function."
   [date-atom path]
   (reset! date-atom (file-dates path))
+  (println @date-atom)
   (let [keep-following (atom true)]
     (future
       (while @keep-following
@@ -210,15 +211,6 @@
     (when live-mode#
       (.enableLiveMode gui true))))

-(defn new-dll-name
-  "Get the name of the new dll file that will be created in the
-   MM application directory."
-  [dll]
-  (let [name (.getName dll)]
-    (if (JavaUtils/isWindows)
-      name
-      (.replace name ".la" ""))))
-
 (defn reload-updated-module
   "Unload a module, copy the new version to the Micro-Manager
    directory (overwriting the old version), and then load the module again."
@@ -231,7 +223,7 @@
       (pausing-live-mode
         (reload-module module
                        (copy dll
-                             (file "." (new-dll-name dll)))))
+                             (file "." (.getName dll)))))
       (notify-user true "Finished reloading " module "!"))))

 (defn reload-modules-on-device-adapter-change
@@ -328,6 +320,11 @@

 ;; testing

+(defn plugin-test
+  "Test the plugin."
+  []
+  (show-plugin (org.micromanager.MMStudioMainFrame/getInstance)))
+
 (defn test-lib
   "Get the first module with loaded devices."
   []


allow merging false values (but not nil values) in push-char

--- lib/src/parinfer/reader.cljc
+++ lib/src/parinfer/reader.cljc
@@ -126,4 +126,4 @@
 (defn push-char
   [state]
   (let [new-data (push-char* state)]
-    (merge-with #(or %2 %1) state new-data)))
+    (merge-with #(if (nil? %2) %1 %2) state new-data)))


add methods to make flatten instructions

--- src/sandbox/multithread.clj
+++ src/sandbox/multithread.clj
@@ -4,6 +4,12 @@
   (:require [clojure.pprint :refer :all]))

 (def p pprint)
+
+(defn p->i [{:keys [instructions] :as process}]
+  (map #(merge (dissoc process :instructions) %) instructions))
+
+(defn ps->is [processes]
+  (mapcat p->i processes))

 (def r3-language
 "S = INSTRS


Add trivial deterministic algorithm for debugging.

--- src/snergly/algorithms.cljc
+++ src/snergly/algorithms.cljc
@@ -187,6 +187,24 @@

 (defn recursive-backtracker-seq [grid]
   (recursive-backtracker-seq* (g/begin-step (assoc grid :algorithm-name "recursive-backtracker")) (list (g/random-coord grid))))
+
+;; There are a couple of weird, sporadic rendering bugs that are hard to track
+;; down because they only appear on some mazes.  This is a deterministic
+;; algorithm that triggers them every time, which should be helpful for
+;; debugging.
+(defn pessimal-seq* [grid [[row :as coord] & coords]]
+  (when coord
+    (let [cell (g/grid-cell grid coord)
+          next-grid (cond
+                      (:east cell) (g/link-cells grid cell (:east cell))
+                      (and (odd? row) (:south cell)) (let [first-on-row (g/grid-cell grid [row 0])]
+                                                       (g/link-cells grid first-on-row (:south first-on-row)))
+                      (and (even? row) (:south cell)) (g/link-cells grid cell (:south cell))
+                      :else grid)]
+      (lazy-seq (cons next-grid (pessimal-seq* (g/begin-step next-grid) coords))))))
+
+(defn pessimal-seq [grid]
+  (pessimal-seq* (g/begin-step (assoc grid :algorithm-name "pessimal")) (g/grid-coords grid)))

 ;; distances-seq advances on each iteration of Dijkstra's algorithm --- in
 ;; other words, for each cell that's on the current wavefront of the flood.


Ignore errors

Ignore errors

--- src/sormilla/drone_comm.clj
+++ src/sormilla/drone_comm.clj
@@ -30,7 +30,7 @@
   (cons (swap! command-id inc) command))

 (def ^InetAddress drone-ip (InetAddress/getByName "192.168.1.1"))
-(defonce at-socket (agent (doto (DatagramSocket.) (.setSoTimeout 1000))))
+(defonce at-socket (agent (doto (DatagramSocket.) (.setSoTimeout 1000)) :error-mode :continue))

 (defn send-packet [^DatagramSocket s ^DatagramPacket packet]
   (.send s packet)


followed @fnd's suggestion and moved original poster for replies into view code

--- src/statuses/views/main.clj
+++ src/statuses/views/main.clj
@@ -45,13 +45,19 @@
    (if in-reply-to
      [:span.reply (link-to (str "/statuses/updates/" in-reply-to) in-reply-to)])])

-(defn entry-form [& [reply]]
+
+(defn entry-form []
   (form-to [:post "/statuses/updates"]
            (text-field {:class "input-xxlarge" :autofocus "autofocus" } "text")
-           (if reply
-             (list (hidden-field "reply-to" reply)
-                   (submit-button "Reply"))
-             (submit-button "Send update"))))
+           (submit-button "Send update")))
+
+(defn reply-form [id author]
+  (form-to [:post "/statuses/updates"]
+           (text-field {:class "input-xxlarge"
+                        :autofocus "autofocus"
+                        :value (str "@" author) } "text")
+           (hidden-field "reply-to" id)
+           (submit-button "Reply")))

 (defpartial list-page [items next]
   (common/layout
@@ -63,7 +69,7 @@
 (defpartial update-page [item]
   (common/layout
    (list [:div.update (update item)]
-         (entry-form (:id item)))
+         (reply-form (:id item) (:author item)))
    (nav-links)))


Remove skip on page persistence stream.

Remove skip on page persistence stream.

--- src/uxbox/ui/workspace.cljs
+++ src/uxbox/ui/workspace.cljs
@@ -41,7 +41,6 @@
   [pageid]
   (as-> (focus-page pageid) $
     (rx/from-atom $)
-    (rx/skip 1 $)
     (rx/dedupe #(dissoc % :version) $)
     (rx/debounce 1000 $)
     (rx/subscribe $ on-page-change #(throw %))))


Only calculate hash for get requests.

Only calculate hash for get requests.

--- src/uxbox/util/response.clj
+++ src/uxbox/util/response.clj
@@ -37,15 +37,22 @@
   (-send [_ ctx]
     (let [^Response response (ctx/get-response* ctx)
           ^Request  request (ctx/get-request* ctx)
-          data (t/encode data)
-          etag (digest data)]
-      (if (etag-match? request etag)
+          ^MutableHeaders headers (.getHeaders response)
+          ^String method (.. request getMethod getName toLowerCase)
+          data (t/encode data)]
+      (if (= method "get")
+        (let [etag (digest data)]
+          (if (etag-match? request etag)
+            (do
+              (.set headers "etag" etag)
+              (.status response 304)
+              (.send response))
+            (do
+              (.set headers "content-type" "application/transit+json")
+              (.set headers "etag" etag)
+              (ch/-send data ctx))))
         (do
-          (.status response 304)
-          (.send response))
-        (let [^MutableHeaders headers (.getHeaders response)]
           (.set headers "content-type" "application/transit+json")
-          (.set headers "etag" etag)
           (ch/-send data ctx))))))

 (defn rsp


sudoku solver

sudoku solver

--- stuf/src/sandbox/sudoku.clj
+++ stuf/src/sandbox/sudoku.clj
@@ -1,4 +1,5 @@
-(ns sandbox.sudoku)
+(ns sandbox.sudoku
+  (:require [clojure.set :as set]))

 (def b1 '[3 - - - - 5 - 1 -
           - 7 - - - 6 - 3 -
@@ -9,3 +10,66 @@
           - - - - 4 - - - 6
           - 4 - 7 - - - 2 -
           - 2 - 6 - - - - 3])
+(defn prep [board]
+  (map #(partition 3 %)
+       (partition 9 board)))
+
+(defn print-board [board]
+  (let [row-sep (apply str (repeat 37 "-"))]
+    (println row-sep)
+    (dotimes [row (count board)]
+      (print "| ")
+      (doseq [subrow (nth board row)]
+        (doseq [cell (butlast subrow)]
+          (print (str cell "   ")))
+        (print (str (last subrow) " | ")))
+      (println)
+      (when (zero? (mod (inc row) 3))
+        (println row-sep)))))
+
+
+(defn rows [board sz]
+  (partition sz board))
+
+(defn row-for [board index sz]
+  (nth (rows board sz) (/ index 9)))
+
+(defn column-for [board index sz]
+  (let [col (mod index sz)]
+    (map #(nth % col)
+         (rows board sz))))
+
+(defn subgrid-for [board i]
+  (let [rows (rows board 9)
+        sgcol (/ (mod i 9) 3)
+        sgrow (/ (/ i 9) 3)
+        grp-col (column-for (mapcat #(partition 3 %) rows) sgcol 3)
+        grp (take 3 (drop (* 3 (int sgrow)) grp-col))]
+    (flatten grp)))
+
+(defn numbers-present-for [board i]
+  (set
+   (concat (row-for board i 9)
+           (column-for board i 9)
+           (subgrid-for board i))))
+
+(defn possible-placements [board index]
+  (set/difference #{1 2 3 4 5 6 7 8 9}
+                  (numbers-present-for board index)))
+
+(defn index [coll]
+  (cond
+    (map? coll) (seq coll)
+    (set? coll) (map vector coll coll)
+    :else (map vector (iterate inc 0) coll)))
+
+(defn pos [pred coll]
+  (for [[i v] (index coll) :when (pred v)] i))
+
+(defn solve [board]
+  (if-let [[i & _]
+           (and (some '#{-} board)
+                (pos  '#{-} board))]
+    (flatten (map #(solve (assoc board i %))
+                  (possible-placements board i)))
+    board))


Fix get paths, again.

Fix get paths, again.

--- src/constraint/core.cljs
+++ src/constraint/core.cljs
@@ -143,8 +143,8 @@
       world-state)))

 (go
-  (let [vertices (<! (GET "/vertices.edn"))
-        bare-edges (<! (GET "/edges.edn"))]
+  (let [vertices (<! (GET "./vertices.edn"))
+        bare-edges (<! (GET "./edges.edn"))]

     (big-bang!
       :initial-state {:vertices (reader/read-string vertices)