add missing shuffle to Mumbad City Hall

add missing shuffle to Mumbad City Hall

--- src/clj/game/cards-assets.clj
+++ src/clj/game/cards-assets.clj
@@ -529,7 +529,8 @@
                            (if (= (:type target) "Operation") "play " "install ") " it")
                  :effect (req (if (= (:type target) "Operation")
                                 (play-instant state side target)
-                                (corp-install state side target nil)))}]}
+                                (corp-install state side target nil))
+                              (shuffle! state side :deck))}]}

    "Mumbad Construction Co."
    {:derezzed-events {:runner-turn-ends corp-rez-toast}


have Tinkering update ICE strength

have Tinkering update ICE strength

--- src/clj/game/cards-events.clj
+++ src/clj/game/cards-events.clj
@@ -640,13 +640,13 @@
                        stypes (:subtype ice)]
               (resolve-ability
                  state :runner
-                 {:msg (msg "give sentry, code gate, and barrier to " (if (:rezzed ice) (:title ice) "the ICE at position ")
-                              (ice-index state ice) " of " serv " until the end of the turn")
+                 {:msg (msg "make " (card-str state ice) " gain sentry, code gate, and barrier until the end of the turn")
                   :effect (effect (update! (assoc ice :subtype
                                                       (->> (vec (.split (:subtype ice) " - "))
                                                            (concat ["Sentry" "Code Gate" "Barrier"])
                                                            distinct
                                                            (join " - "))))
+                                  (update-ice-strength (get-card state ice))
                                   (register-events {:runner-turn-ends
                                                     {:effect (effect (update! (assoc (get-card state ice) :subtype stypes)))}}
                                   (assoc card :zone '(:discard))))}


Simpler implementation of algebra.angle

Simpler implementation of algebra.angle

--- src/clj/genartlib/algebra.clj
+++ src/clj/genartlib/algebra.clj
@@ -1,6 +1,6 @@
 (ns genartlib.algebra
   (:require [genartlib.util :refer [between?]]
-            [quil.core :refer [HALF-PI PI TWO-PI atan cos sin dist]]))
+            [quil.core :refer [HALF-PI PI TWO-PI atan2 cos sin dist]]))

   (defn avg
     "Returns the average of the arguments"
@@ -98,22 +98,13 @@
     [slope x1 y1]
     (- y1 (* slope x1)))

-  (defn angle
-    "Returns the angle between two points in radians"
-    [x1 y1 x2 y2]
-    (let [x-delta (- x2 x1)
-          y-delta (- y2 y1)]
-      (if (zero? x-delta)
-        (if (> y2 y1)
-          HALF-PI
-          (+ HALF-PI PI))
-        (if (zero? y-delta)
-          (if (> x2 x1)
-            0
-            PI)
-          (let [angle (atan (/ y-delta x-delta))
-                angle (+ angle (if (neg? x-delta) PI 0))]
-            (mod angle TWO-PI))))))
+  (defn angle [x1 y1 x2 y2]
+    "Returns the angle between two points in radians. Values are between
+     0 and 2 * PI."
+    (let [a (atan2 (- y2 y1) (- x2 x1))]
+      (if (neg? a)
+        (+ a (* PI 2.0))
+        a)))

   (defn point-angle
     "Returns the angle between two points in radians"


Fix a problem in the walk-file-tree visitor function

It receives 2 arguments

--- src/clj/mdr2/archive/core.clj
+++ src/clj/mdr2/archive/core.clj
@@ -109,7 +109,7 @@
 (defn set-file-permissions
   "Set file permissions on `file-tree` to g+w recursively"
   [file-tree]
-  (let [visitor-fn (fn [f] (fs/set-posix-file-permissions f "rw-rw-r--") nil)]
+  (let [visitor-fn (fn [f _] (fs/set-posix-file-permissions f "rw-rw-r--") :continue)]
     (fs/walk-file-tree file-tree {:pre-visit-dir visitor-fn :visit-file visitor-fn})))

 (defn- copy-files


Add key for every generated row in bank-event-table so React is satisfied

--- src/cljs/my_money/events.cljs
+++ src/cljs/my_money/events.cljs
@@ -30,6 +30,7 @@
       [:th "Amount"]
       [:th "Recipient"]]]
     [:tbody (for [event (rest events)]
+              ^{:key (:id event)}
               [:tr
                [:td (str (:transaction_date event))]
                [:td (str (/ (:amount event) 100) "€")]


Updated about page

Updated about page

--- src/cljs/netrunner/about.cljs
+++ src/cljs/netrunner/about.cljs
@@ -21,15 +21,15 @@

      [:h3 "Development"]

-     [:p "The gameplay functionalities are currently under development. Check "
-      [:a {:href "https://docs.google.com/spreadsheets/d/1ICv19cNjSaW9C-DoEEGH3iFt09PBTob4CAutGex0gnE/pubhtml"
-           :target "_blank"} "card automation status"] "."]
-
      [:p "The code is open source and available on "
       [:a {:href "https://github.com/mtgred/netrunner" :target "_blank"} "Github"] "."]

      [:p "Bug reports and feature suggestions can be submitted "
       [:a {:href "https://github.com/mtgred/netrunner/issues" :target "_blank"} "here"] "."]
+
+     [:p "Card automation "
+      [:a {:href "https://docs.google.com/spreadsheets/d/1ICv19cNjSaW9C-DoEEGH3iFt09PBTob4CAutGex0gnE/pubhtml"
+           :target "_blank"} "status"] "."]

      [:p "Donations can be submitted to PayPal account mtgred@gmail.com or to Bitcoin address "
       [:span.bitcoin "1ByjuLNZRvG17YaRKgKUjNi3c4qQ3daX3g" [:img.qr {:src "/img/bitcoin.png"}]]
@@ -38,7 +38,7 @@
      [:p "Contributions are appreciated and help finance fast servers."]

      [:h3 "Contributors"]
-     [:p "A big props to Neal Terrell (nealpro), Joel Koepp (JoelCFC25) and Dominic Kexel (queueseven) who actively contribute to the success of the project with regular code submissions, the management of the issue tracker and answers to questions in the chat. It would not be the same without your help."]
+     [:p "A big props to Neal Terrell (nealpro), Joel Koepp (JoelCFC25), Lukasz Dobrogowski (zaroth) and Filip Gokstorp (Saintis) who actively contribute to the success of the project with regular code submissions, the management of the issue tracker and answers to questions in the chat. It would not be the same without your help."]
      [:p "Many thanks to all the donators. Your contributions and kind words are greatly appreciated. You help finance fast servers and keep the developer motivated."]
      [:ul.list.compact
       (for [d (:donators cursor)]


fix build error

fix build error

--- src/clojure/cljam/indexer.clj
+++ src/clojure/cljam/indexer.clj
@@ -4,7 +4,8 @@
                    [util :refer [reg->bin]]))
   (:import java.io.DataOutputStream
            ;(net.sf.picard.sam BuildBamIndex BamIndexStats)
-           cljam.lib.stream.BlockCompressedOutputStream))
+           ;cljam.lib.stream.BlockCompressedOutputStream
+           [chrovis.bgzf4j BGZFInputStream BGZFOutputStream]))

 (def bai-magic "BAI\1")

@@ -21,7 +22,7 @@
   "Opposite of slurp. Opens sam/bam-file with writer, writes sam headers and
   alignments, then closes the sam/bam-file."
   [bai-file sam]
-  (with-open [w (DataOutputStream. (BlockCompressedOutputStream. bai-file))]
+  (with-open [w (DataOutputStream. (BGZFOutputStream. bai-file))]
     (lsb/write-bytes w (.getBytes bai-magic)) ; magic
     ;; TODO
     nil))


Let's try to limit any race conditions until we can refactor the guts of picard.

--- src/clojure/picard/client.clj
+++ src/clojure/picard/client.clj
@@ -106,22 +106,22 @@
     (netty/on-complete
      (.last-write current-state)
      (fn [future]
-       (debug (let [current-state @state]
-                {:msg   "Last write finished, cleaning up exchange"
+       (let [current-state ^State @state]
+         (debug {:msg   "Last write finished, cleaning up exchange"
                  :event future
-                 :state current-state}))
-
-       ;; Clear the timeout since there will be no other user code called
-       (clear-timeout state)
-
-       ;; The connection will either be closed or it will be moved
-       ;; into the connection pool which has it's own keepalive
-       ;; timeout, so clear any existing timeout for this connection.
-       (if (and (.keepalive? current-state)
-                (not (.aborted? current-state)))
-         (pool/checkin-conn (.pool current-state) (.ch current-state))
-         (when-let [ch (.ch current-state)]
-           (pool/close-conn (.pool current-state) ch)))))))
+                 :state current-state})
+
+         ;; Clear the timeout since there will be no other user code called
+         (clear-timeout state)
+
+         ;; The connection will either be closed or it will be moved
+         ;; into the connection pool which has it's own keepalive
+         ;; timeout, so clear any existing timeout for this connection.
+         (if (and (.keepalive? current-state)
+                  (not (.aborted? current-state)))
+           (pool/checkin-conn (.pool current-state) (.ch current-state))
+           (when-let [ch (.ch current-state)]
+             (pool/close-conn (.pool current-state) ch))))))))

 (defn- connection-pending
   [_ evt val _]


Fixing merge conflicts

Fixing merge conflicts

--- src/clojush/pushgp/pushgp.clj
+++ src/clojush/pushgp/pushgp.clj
@@ -3,7 +3,7 @@
             [clj-random.core :as random]
             [clojure.repl :as repl])
   (:use [clojush args globals util pushstate random individual evaluate simplification translate]
-        [clojush.instructions boolean code common numbers random-instructions string char vectors
+        [clojush.instructions boolean code common numbers random-instructions string char vectors
          tag zip return input-output genome]
         [clojush.pushgp breed parent-selection report]
         [clojush.experimental.decimation]))
@@ -11,180 +11,6 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; pushgp

-<<<<<<< HEAD
-(def push-argmap
-  (atom (sorted-map
-          ;;----------------------------------------
-          ;; Clojush system arguments
-          ;;----------------------------------------
-          :use-single-thread false ;; When true, Clojush will only use a single thread
-          :random-seed (random/generate-mersennetwister-seed) ;; The seed for the random number generator
-          :run-uuid nil ;; This will be set to a new type 4 pseudorandom UUID on every run
-          ;;
-          ;;----------------------------------------
-          ;; Standard GP arguments
-          ;;----------------------------------------
-          :error-function (fn [p] '(0)) ;; Function that takes a program and returns a list of errors
-          :error-threshold 0 ;; Pushgp will stop and return the best program if its total error is <= the error-threshold
-          :atom-generators (concat @registered-instructions ;; The instructions that pushgp will use in random code
-                                   (list
-                                     (fn [] (lrand-int 100))
-                                     (fn [] (lrand))))
-          :population-size 1000 ;; Number of individuals in the population
-          :max-generations 1001 ;; The maximum number of generations to run GP
-          :max-point-evaluations 10e100 ;; The limit for the number of point (instruction) evaluations to execute during the run
-          :max-points 200 ;; Maximum size of push programs and push code, as counted by points in the program. 1/4 this limit is used as the limit for sizes of Plush genomes.
-          :max-genome-size-in-initial-program 50 ;; Maximum size of initial Plush genomes in generation 0. Keep in mind that genome lengths will otherwise be limited by 1/4 of :max-points
-          :evalpush-limit 150 ;; The number of Push instructions that can be evaluated before stopping evaluation
-          :evalpush-time-limit 0 ;; The time in nanoseconds that a program can evaluate before stopping, 0 means no time limit
-          :reuse-errors true ;; When true, children produced through direct reproduction will not be re-evaluated but will have the error vector of their parent
-          :pass-individual-to-error-function false ;; When true, entire individuals (rather than just programs) are passed to error functions
-          ;;
-          ;;----------------------------------------
-          ;; Genetic operator probabilities
-          ;;----------------------------------------
-          ;; The map supplied to :genetic-operator-probabilities should contain genetic operators
-          ;; that sum to 1.0. All available genetic operators are defined in clojush.pushgp.breed.
-          ;; Along with single operators, pipelines (vectors) containing multiple operators are
-          ;; also allowed, where each operator is applied to the child of the previous operator, along
-          ;; with newly selecting individuals where necessary. If an operator is preceeded by
-          ;; :make-next-operator-revertable, it will only keep the child if it is at least as good as
-          ;; its (first) parent on every test case.
-          :genetic-operator-probabilities {:reproduction 0.0
-                                           :alternation 0.7
-                                           :uniform-mutation 0.1
-                                           [:alternation :uniform-mutation] 0.2 ;Somewhat equivalent to normal Push's ULTRA operator
-                                           :uniform-close-mutation 0.0
-                                           :uniform-silence-mutation 0.0
-                                           [:make-next-operator-revertable :uniform-silence-mutation] 0.0 ;Equivalent to a hill-climbing version of uniform-silence-mutation
-                                           :autoconstruction 0.0
-                                           :uniform-deletion 0.0
-                                           }
-          ;;
-          ;;----------------------------------------
-          ;; Arguments related to genetic operators
-          ;;----------------------------------------
-          :alternation-rate 0.01 ;; When using alternation, how often alternates between the parents
-          :alignment-deviation 10 ;; When using alternation, the standard deviation of how far alternation may jump between indices when switching between parents
-          :uniform-mutation-rate 0.01 ;; The probability of each token being mutated during uniform mutation
-          :uniform-mutation-constant-tweak-rate 0.5 ;; The probability of using a constant mutation instead of simply replacing the token with a random instruction during uniform mutation
-          :uniform-mutation-float-gaussian-standard-deviation 1.0 ;; The standard deviation used when tweaking float constants with Gaussian noise
-          :uniform-mutation-int-gaussian-standard-deviation 1 ;; The standard deviation used when tweaking integer constants with Gaussian noise
-          :uniform-mutation-string-char-change-rate 0.1 ;; The probability of each character being changed when doing string constant tweaking
-          :uniform-mutation-tag-gaussian-standard-deviation 100 ;; The standard deviation used when tweaking tag locations with Gaussian noise
-          :uniform-close-mutation-rate 0.1 ;; The probability of each :close being incremented or decremented during uniform close mutation
-          :close-increment-rate 0.2 ;; The probability of making an increment change to :close during uniform close mutation, as opposed to a decrement change
-          :uniform-deletion-rate 0.01 ;; The probability that any instruction will be deleted during uniform deletion
-          :uniform-silence-mutation-rate 0.1 ;; The probability of each :silent being switched during uniform silent mutation
-          :replace-child-that-exceeds-size-limit-with :random ;; When a child is produced that exceeds the size limit of (max-points / 4), this is used to determine what program to return. Options include :parent, :empty, :random, :truncate
-          :parent-reversion-probability 1.0 ;; The probability of a child being reverted to its parent by a genetic operator that has been made revertable, if the child is not as good as the parent on at least one test case
-          :autoconstructive false ;; if true then :genetic-operator-probabilities will be {:autoconstruction 1.0}, :epigenetic-markers will be [:close :silent], and :atom-generators will include everything in (registered-for-stacks [:integer :boolean :exec :genome]). Also sets :replace-child-that-exceeds-size-limit-with to :empty. You will probably also want to provide a high value for :max-generations.
-          :autoconstructive-integer-rand-enrichment 1 ;; the number of extra instances of autoconstructive_integer_rand to include in :atom-generators for autoconstruction. If negative then autoconstructive_integer_rand will not be in :atom-generators at all
-          :autoconstructive-boolean-rand-enrichment -1 ;; the number of extra instances of autoconstructive_boolean_rand to include in :atom-generators for autoconstruction. If negative then autoconstructive_boolean_rand will not be in :atom-generators at all
-          ;;
-          ;;----------------------------------------
-          ;; Epignenetics
-          ;;----------------------------------------
-          :epigenetic-markers [:close] ;; A vector of the epigenetic markers that should be used in the individuals. Implemented options include: :close, :silent
-          :close-parens-probabilities [0.772 0.206 0.021 0.001] ;; A vector of the probabilities for the number of parens ending at that position. See random-closes in clojush.random
-          :silent-instruction-probability 0.2 ;; If :silent is used as an epigenetic-marker, this is the probability of random instructions having :silent be true
-          ;;
-          ;;----------------------------------------
-          ;; Arguments related to parent selection
-          ;;----------------------------------------
-          :parent-selection :lexicase ;; The parent selection method. Options include :tournament, :lexicase, :epsilon-lexicase, :elitegroup-lexicase, :uniform :leaky-lexicase
-          :epsilon-lexicase-epsilon nil ;; When parent-selection is :epsilon-lexicase, the value for epsilon. If nil, automatic epsilon lexicase selection will be used.
-          :lexicase-leakage 0.1 ;; If using leaky lexicase selection, the percentage of selection events that will return random (tourny 1) individuals
-          :tournament-size 7 ;; If using tournament selection, the size of the tournaments
-          :total-error-method :sum ;; The method used to compute total error. Options include :sum (standard), :hah (historically-assessed hardness), :rmse (root mean squared error), and :ifs (implicit fitness sharing)
-          :normalization :none ;; The method used to normalize the errors to the range [0,1], with 0 being best. Options include :none (no normalization), :divide-by-max-error (divides by value of argument :max-error), :e-over-e-plus-1 (e/(e+1) = 1 - 1/(e+1))
-          :max-error 1000 ;; If :normalization is set to :max-error, will use this number for normalization
-          :meta-error-categories [] ;; A vector containing meta-error categories that can be used for parent selection, but do not affect total error. See clojush.evaluate for options.
-          :trivial-geography-radius 0 ;; If non-zero, this is used as the radius from which to select individuals for tournament or lexicase selection
-          :decimation-ratio 1 ;; If >= 1, does nothing. Otherwise, is the percent of the population size that is retained before breeding. If 0 < decimation-ratio < 1, decimation tournaments will be used to reduce the population to size (* population-size decimation-ratio) before breeding.
-          :decimation-tournament-size 2 ;; Size of the decimation tournaments
-          :print-selection-counts false ;; If true, keeps track of and prints the number of times each individual was selected to be a parent
-          ;;
-          ;;----------------------------------------
-          ;; Arguments related to the Push interpreter
-          ;;----------------------------------------
-          :pop-when-tagging true ;; When true, tagging instructions will pop the exec stack when tagging; otherwise, the exec stack is not popped
-          :tag-limit 10000 ;; The size of the tag space
-          :top-level-push-code false ;; When true, run-push will push the program's code onto the code stack prior to running
-          :top-level-pop-code false ;; When true, run-push will pop the code stack after running the program
-          ;;
-          ;;----------------------------------------
-          ;; Arguments related to generational and final reports
-          ;;----------------------------------------
-          :report-simplifications 100 ;; The number of simplification steps that will happen during report simplifications
-          :final-report-simplifications 1000 ;; The number of simplification steps that will happen during final report simplifications
-          :problem-specific-initial-report default-problem-specific-initial-report ;; A function can be called to provide a problem-specific initial report, which happens before the normal initial report is printed
-          :problem-specific-report default-problem-specific-report ;; A function can be called to provide a problem-specific report, which happens before the normal generational report is printed
-          :return-simplified-on-failure false ;; When true, will simplify the best indivual and return it, even if the error threshold has not been reached. This will make failures return the same as successes
-          :print-errors true ;; When true, prints the error vector of the best individual
-          :print-history false ;; When true, prints the history of the best individual's ancestors' total errors
-          :print-timings false ; If true, report prints how long different parts of evolution have taken during the current run.
-          :print-error-frequencies-by-case false ; If true, print reports of error frequencies by case each generation
-          :print-cosmos-data false ; If true, report prints COSMOS data each generation.
-          :maintain-ancestors false  ; If true, save all ancestors in each individual (costly)
-          :print-ancestors-of-solution false ; If true, final report prints the ancestors of the solution. Requires :maintain-ancestors to be true.
-          :print-behavioral-diversity false ; If true, prints the behavioral diversity of the population each generation. Note: The error function for the problem must support behavioral diversity. For an example, see wc.clj
-          :print-homology-data false ; If true, prints the homology statistics
-          ;;
-          ;;----------------------------------------
-          ;; Arguments related to printing JSON, EDN, or CSV logs
-          ;;----------------------------------------
-          :print-csv-logs false ;; Prints a CSV log of the population each generation
-          :print-edn-logs false ;; Prints an EDN log of the run
-          :print-json-logs false ;; Prints a JSON log of the population each generation
-          :csv-log-filename "log.csv" ;; The file to print CSV log to
-          :edn-log-filename "log.edn" ;; The file to print EDN log to
-          :json-log-filename "log.json" ;; The file to print JSON log to
-          :csv-columns [:generation :location :total-error :push-program-size] ;; The columns to include in a printed CSV beyond the generation and individual. Options include: [:generation :location :parent-uuids :genetic-operators :push-program-size :plush-genome-size :push-program :plush-genome :total-error :test-case-errors]
-          :edn-keys [:uuid :parent-uuids :genetic-operators :program :genome :total-error :errors] ;; Keys from clojush.individual.individual that should be included.
-          :edn-additional-keys [:generation :location] ;; additional information to include in the edn-printout. Available options are [:generation :location :push-program-size :plush-genome-size].
-          :log-fitnesses-for-all-cases false ;; If true, the CSV and JSON logs will include the fitnesses of each individual on every test case
-          :json-log-program-strings false ;; If true, JSON logs will include program strings for each individual
-          )))
-
-(defn load-push-argmap
-  [argmap]
-  (doseq [[argkey argval] argmap]
-    (assert (contains? @push-argmap argkey) (str "Argument key " argkey " is not a recognized argument to pushgp."))
-    (swap! push-argmap assoc argkey argval))
-  (swap! push-argmap assoc :run-uuid (java.util.UUID/randomUUID))
-  (when (:autoconstructive @push-argmap)
-    (swap! push-argmap assoc :genetic-operator-probabilities {:autoconstruction 1.0})
-    (swap! push-argmap assoc :epigenetic-markers [:close :silent])
-    (doseq [instr (registered-for-stacks [:integer :boolean :exec :genome])]
-      (when (not (some #{instr} (:atom-generators @push-argmap)))
-        (swap! push-argmap assoc :atom-generators (conj (:atom-generators @push-argmap) instr))))
-    (dotimes [n (:autoconstructive-integer-rand-enrichment @push-argmap)]
-      (swap! push-argmap assoc :atom-generators (conj (:atom-generators @push-argmap) 'autoconstructive_integer_rand)))
-    (if (neg? (:autoconstructive-integer-rand-enrichment @push-argmap))
-      (swap! push-argmap assoc :atom-generators (remove #(= % 'autoconstructive_integer_rand)
-                                                        (:atom-generators @push-argmap))))
-    (dotimes [n (:autoconstructive-boolean-rand-enrichment @push-argmap)]
-      (swap! push-argmap assoc :atom-generators (conj (:atom-generators @push-argmap) 'autoconstructive_boolean_rand)))
-    (if (neg? (:autoconstructive-boolean-rand-enrichment @push-argmap))
-      (swap! push-argmap assoc :atom-generators (remove #(= % 'autoconstructive_boolean_rand)
-                                                        (:atom-generators @push-argmap))))
-    (swap! push-argmap assoc :replace-child-that-exceeds-size-limit-with :empty)))
-
-(defn reset-globals
-  "Resets all Clojush globals according to values in @push-argmap. If an argmap argument is provided then it is loaded
-into @push-argmap first."
-  ([]
-    (doseq [[gname gatom] (filter (fn [[a _]] (.startsWith (name a) "global-")) (ns-publics 'clojush.globals))]
-      (if (contains? @push-argmap (keyword (.substring (name gname) (count "global-"))))
-        (reset! @gatom (get @push-argmap (keyword (.substring (str gname) (count "global-")))))
-        (throw (Exception. (str "globals.clj definition " gname " has no matching argument in push-argmap. Only such definitions should use the prefix 'global-'."))))))
-  ([argmap]
-    (load-push-argmap argmap)
-    (reset-globals)))
-
-=======
->>>>>>> master
 (defn agent-error-handler
   "Given to individual agents for handling errors."
   [agnt except]
@@ -226,13 +52,13 @@
   (let [random-seeds (loop [seeds '()]
                        (let [num-remaining (- population-size (count seeds))]
                          (if (pos? num-remaining)
-                           (let [new-seeds (repeatedly num-remaining #(random/lrand-bytes (:mersennetwister random/*seed-length*)))]
+                           (let [new-seeds (repeatedly num-remaining #(random/lrand-bytes (:mersennetwister random/*seed-length*)))]
                              (recur (concat seeds (filter (fn [candidate]
                                                             (not (some #(random/=byte-array % candidate)
                                                                        seeds))) new-seeds)))); only add seeds that we do not already have
                            seeds)))]
     {:random-seeds random-seeds
-     :rand-gens (vec (doall (for [k (range population-size)]
+     :rand-gens (vec (doall (for [k (range population-size)]
                               (random/make-mersennetwister-rng (nth random-seeds k)))))
      }))

@@ -256,8 +82,8 @@
                         trivial-geography-radius))]
     (dotimes [i population-size]
       ((if use-single-thread swap! send)
-           (nth child-agents i)
-           breed
+           (nth child-agents i)
+           breed
            i (nth rand-gens i) pop @push-argmap)))
   (when-not use-single-thread (apply await child-agents))) ;; SYNCHRONIZE


add test for autocomplete by lower case input

--- test/wb_es/core_test.clj
+++ test/wb_es/core_test.clj
@@ -95,5 +95,11 @@
             (is (= "syIs1" (-> (first hits)
                                (get-in [:_source :label])))))))
       (testing "autocompletion by transgene name in lowercase"
-        )))
+        (let [hits (-> (autocomplete "syis1")
+                       (get-in [:hits :hits]))]
+          (is (some (fn [hit]
+                      (= "syIs101"
+                         (get-in hit [:_source :label])))
+                    hits))))
+      ))
   )


add tests for anatomy

add tests for anatomy

--- test/wb_es/core_test.clj
+++ test/wb_es/core_test.clj
@@ -50,6 +50,36 @@

 (def search (with-default-options web/search))
 (def autocomplete (with-default-options web/autocomplete))
+
+
+(deftest anatomy-type-test
+  (testing "anatomy type using \"tl\" prefixed terms"
+    (let [db (d/db datomic-conn)
+          anatomy-tl-prefixed (->> (d/q '[:find [?e ...]
+                                          :in $ [?th ...]
+                                          :where
+                                          [?e :anatomy-term/term ?th]]
+                                        db
+                                        (->> (d/datoms db :aevt :anatomy-term.term/text)
+                                             (keep (fn [[e _ v]]
+                                                     (if (re-matches #"tl.*" (clojure.string/lower-case v))
+                                                       e)))))
+                                   (map (partial d/entity db))
+                                   (shuffle))]
+      (do
+        (apply index-datomic-entity anatomy-tl-prefixed)
+        (testing "autocomplete by term"
+          (let [hits (-> (autocomplete "tl")
+                         (get-in [:hits :hits]))]
+            (is (= "TL"
+                   (->> (get-in (first hits) [:_source :label]))))
+
+            (is (some (fn [hit]
+                        (= "TL.a"
+                           (get-in hit [:_source :label])))
+                      hits))
+            )))
+      )))

 (deftest clone-type-test


Attempt to make gateway forms not choke on very fast input

--- src/braid/core/client/gateway/helper_views.cljs
+++ src/braid/core/client/gateway/helper_views.cljs
@@ -1,7 +1,7 @@
 (ns braid.core.client.gateway.helper-views
   (:require
    [reagent.core :as r]
-   [re-frame.core :refer [subscribe dispatch]]
+   [re-frame.core :refer [subscribe dispatch dispatch-sync]]
    [reagent.ratom :refer-macros [run!]]))

 (defn with-ns [ns n]
@@ -39,7 +39,7 @@
                   :on-change (fn [e]
                                (let [value (on-change-transform (.. e -target -value))]
                                  (reset! value-atom value)
-                                 (dispatch [(with-ns (opts :disp-ns) :update-value) field-id value])))}]]
+                                 (dispatch-sync [(with-ns (opts :disp-ns) :update-value) field-id value])))}]]
         (when (= :invalid status)
           [:div.error-message (first errors)])
         (when (opts :help-text)


Bring back drop! and init! functions in seed

--- src/chat/server/seed.clj
+++ src/chat/server/seed.clj
@@ -1,6 +1,12 @@
 (ns chat.server.seed
   (:require [chat.server.db :as db]
-            [environ.core :refer [env]]))
+            [braid.server.conf :refer [config]]))
+
+(defn drop! []
+  (datomic.api/delete-database (config :db-url)))
+
+(defn init! []
+  (db/init! (config :db-url)))

 (defn seed! []
   (let [group-1 (db/create-group! {:id (db/uuid) :name "Braid"})


:tada: Add support for store plain js objects in transit.

--- frontend/src/uxbox/util/transit.cljs
+++ frontend/src/uxbox/util/transit.cljs
@@ -11,15 +11,35 @@
             [uxbox.util.geom.matrix :as gmt]
             [uxbox.util.time :as dt]))

+(deftype Blob [content]
+  IDeref
+  (-deref [_] content))
+
+(defn blob?
+  [v]
+  (instance? Blob v))
+
+(def blob-write-handler
+  (t/write-handler
+   (constantly "jsonblob")
+   (fn [v] (js/JSON.stringify @v))))
+
+(def blob-read-handler
+  (t/read-handler
+   (fn [value]
+     (->Blob (js/JSON.parse value)))))
+
 ;; --- Transit Handlers

 (def ^:privare +read-handlers+
   {"u" uuid
+   "jsonblob" blob-read-handler
    "matrix" gmt/matrix-read-handler
    "point" gpt/point-read-handler})

 (def ^:privare +write-handlers+
   {gmt/Matrix gmt/matrix-write-handler
+   Blob       blob-write-handler
    gpt/Point gpt/point-write-handler})

 ;; --- Public Api


[#2252] Increment socket-timeout in import flow http calls

--- backend/src/akvo/lumen/lib/import/flow_common.clj
+++ backend/src/akvo/lumen/lib/import/flow_common.clj
@@ -6,7 +6,7 @@
             [clojure.string :as str])
   (:import [java.time Instant]))

-(def http-client-req-defaults (http.client/req-opts 5000))
+(def http-client-req-defaults (http.client/req-opts 10000))

 (defn survey-definition
   [api-root headers-fn instance survey-id]


test fix

test fix

--- test/metabase/api/meta/table_test.clj
+++ test/metabase/api/meta/table_test.clj
@@ -10,6 +10,7 @@
                              [table :refer [Table]])
             [metabase.test.data.datasets :as datasets, :refer [*dataset* with-dataset-when-testing]]
             [metabase.test-data :refer :all]
+            [metabase.test-data.data :as data]
             [metabase.test.util :refer [match-$ expect-eval-actual-first]]))

@@ -90,7 +91,6 @@
   ((user->client :rasta) :get 200 (format "meta/table/%d/fields" (table->id :categories))))

 ;; ## GET /api/meta/table/:id/query_metadata
-; TODO - create test which includes :field_values
 (expect
     (match-$ (sel :one Table :id (table->id :categories))
       {:description nil
@@ -133,7 +133,7 @@
                    :preview_display true
                    :created_at $
                    :base_type "TextField"})]
-       :field_values nil
+       :field_values {}
        :rows 75
        :updated_at $
        :entity_name nil
@@ -143,6 +143,23 @@
        :created_at $})
   ((user->client :rasta) :get 200 (format "meta/table/%d/query_metadata" (table->id :categories))))

+
+(def ^:private user-last-login-date-strs
+  "In an effort to be really annoying, the date strings returned by the API are different on Circle than they are locally.
+   Generate strings like '2014-01-01' at runtime so we get matching values."
+  (let [format-inst (fn [^java.util.Date inst]
+                      (format "%d-%02d-%02d"
+                              (+ (.getYear inst) 1900)
+                              (+ (.getMonth inst) 1)
+                              (.getDate inst)))]
+    (->> data/test-data
+         :users
+         :rows
+         (map second)
+         (map format-inst)
+         set
+         sort
+         vec)))

 ;;; GET api/meta/table/:id/query_metadata?include_sensitive_fields
 ;;; Make sure that getting the User table *does* include info about the password field, but not actual values themselves


support both :agr (older convention) and :u (newer convention) in pattern tuples

--- src/babel/morphology.clj
+++ src/babel/morphology.clj
@@ -84,7 +84,8 @@
   (mapcat (fn [pattern]
             (map (fn [pair]
                    {:u (unify unify-with
-                              (:agr pattern))
+                              (get-in pattern [:agr] :top) ;; older convention: :agr
+                              (get-in pattern [:u] :top)) ;; newer convention: :u
                     :p pair})
                  (group-by-two (:p pattern))))
           patterns))


Fix conversions.

Fix conversions.

--- src/kixi/hecuba/data/calculate.clj
+++ src/kixi/hecuba/data/calculate.clj
@@ -205,11 +205,11 @@
                 (hayt/insert :measurements
                              (hayt/values m)))))

-(def conversions {:vol2kwh {"gasConsumption" {"m^3" 10.97222
+(def conversions {"vol2kwh" {"gasConsumption" {"m^3" 10.97222
                                               "ft^3" (* 2.83 10.9722)}
                             "oilConsumption" {"m^3" 10308.34
                                               "ft^3" (* 2.83 10308.34)}}
-                  :kwh2co2 {"electricityConsumption" {"kWh" 0.517}
+                  "kwh2co2" {"electricityConsumption" {"kWh" 0.517}
                             "gasConsimption" {"kWh" 0.185}
                             "oilConsumption" {"kWh" 0.246}}})

@@ -299,7 +299,7 @@
 ;;;; kWh to co2

 (defmethod calculate-data-set :kwh2co2 [ds store]
-  (let [get-fn-and-measurements  (fn [s] [(conversion-fn s (:operation ds)) (measurements/all-measurements store s)])
+  (let [get-fn-and-measurements  (fn [s] (prn "s: " s) [(conversion-fn s (:operation ds)) (measurements/all-measurements store s)])
         convert                  (fn [[f xs]] (map f xs))
         topic (get-in (:queue store) [:queue "measurements"])
         {:keys [operation device_id]} ds]


updated file generation

updated file generation

--- src/leiningen/new/threejs_game.clj
+++ src/leiningen/new/threejs_game.clj
@@ -27,7 +27,8 @@
              ["src/cljs/{{sanitized}}/menu.cljs" (render "src/cljs/menu.cljs" data)]
              ["src/cljs/{{sanitized}}/time_loop.cljs" (render "src/cljs/time_loop.cljs" data)]
              ["src/cljs/{{sanitized}}/utilities.cljs" (render "src/cljs/utilities.cljs" data)]
-
+             ["src/cljs/{{sanitized}}/xhr.cljs" (render "src/cljs/xhr.cljs" data)]
+             ["src/cljs/{{sanitized}}/cookies.cljs" (render "src/cljs/cookies.cljs" data)]
              ["src/js/{{sanitized}}.externs.js" (render "src/js/externs.js" data)]
              ["resources/public/index.html" (render "resources/public/index.html" data)]
              ["resources/public/index_release.html" (render "resources/public/index_release.html" data)]


Prevent style from leaking

Prevent style from leaking

--- src/braid/client/ui/styles/thread.cljs
+++ src/braid/client/ui/styles/thread.cljs
@@ -50,10 +50,10 @@
         {:background vars/limbo-thread-accent-color}]]]

    [:&.focused
-    [:.card
+    ["> .card"
      {:box-shadow [[0 (px 10) (px 10) (px 10) "#ccc"]]}]]

-   [:.card
+   ["> .card"
     mixins/flex
     {:flex-direction "column"
      :box-shadow [[0 (px 1) (px 2) 0 "#ccc"]]
@@ -77,7 +77,7 @@
       :content "\"\""}]]

    [:&.private :&.limbo
-    [:.card
+    ["> .card"
      {; needs to be a better way
       ; which is based on the height of the notice
       :max-height "85%"}]]


Remove unnecessary debug logging call

Remove unnecessary debug logging call

--- src/main/clojure/cascade/asset.clj
+++ src/main/clojure/cascade/asset.clj
@@ -84,7 +84,6 @@
         [_ _ application-version & asset-path-terms] (-> env :cascade :split-path)
         asset-path (s2/join "/" asset-path-terms)
     		_ (fail-if (nil? application-version) "Invalid classpath asset URL.")
-    		_ (debug "Application version: %s, expect %s" application-version (read-config :application-version))
     		_ (fail-unless (= application-version (read-config :application-version)) "Incorrect application version.")
     		; TODO Check whitelist/blacklist
     		; TODO Gzip, etc.


Add a :description field to entity definition map

--- src/main/workflo/macros/entity.clj
+++ src/main/workflo/macros/entity.clj
@@ -113,15 +113,20 @@
          query-keys      (some-> auth-query q/map-destructuring-keys)
          validation      (:validation (:forms args))
          schema          (:schema (:forms args))
+         name-sym        (unqualify name)
          forms           (-> (:forms args)
                              (select-keys [:auth :validation :schema])
-                             (vals))
-         name-sym        (unqualify name)
-         all-forms       (cond-> forms
-                           auth-query (conj {:form-name 'auth-query}))
+                             (vals)
+                             (cond->
+                               description (conj {:form-name
+                                                  'description})
+                               auth-query  (conj {:form-name
+                                                  'auth-query})))
          def-sym         (f/qualified-form-name 'definition name-sym)]
      (register-entity! name def-sym env)
      `(do
+        ~@(when description
+            `(~(f/make-def name-sym 'description description)))
         ~@(when auth
             `(~(f/make-defn name-sym 'auth [{:keys query-keys}]
                 (:form-body auth))))
@@ -134,7 +139,7 @@
         ~@(when schema
             `(~(f/make-def name-sym 'schema (:form-body schema))))
         ~(f/make-def name-sym 'definition
-          (f/forms-map all-forms name-sym))))))
+          (f/forms-map forms name-sym))))))

 (defmacro defentity
   [name & forms]


Fixing unit test

Fixing unit test

--- test/vignette/util/thumbnail_test.clj
+++ test/vignette/util/thumbnail_test.clj
@@ -25,12 +25,12 @@
        ; successful run
        (original->thumbnail beach-file beach-map) => truthy
        (provided
-         (run-thumbnailer anything any-params) => {:exit 0})
+         (run-thumbnailer anything anything) => {:exit 0})

        ; failed run
        (original->thumbnail beach-file beach-map) => (throws Exception)
        (provided
-         (run-thumbnailer anything any-params) => {:exit 1 :err 256 :out "testing failure"})
+         (run-thumbnailer anything anything) => {:exit 1 :err 256 :out "testing failure"})

        ;special mime type
        (generate-thumbnail ..store.. beach-map nil) => ..file..


Negative test for the function proper-word-for-whitelist?

--- test/zg/dictionary_interface_test.clj
+++ test/zg/dictionary_interface_test.clj
@@ -62,7 +62,10 @@
             "0"
             "I'm"
             "This is test"
-            "This is test.")))
+            "This is test."
+            "/"
+            "a/b"
+            "foo/bar")))

 (deftest test-proper-word-for-blacklist?-negative
     "Check the function zg.dictionary-interface/proper-word-for-blacklist?"
@@ -88,3 +91,17 @@
             "This is test"
             "This is test.")))

+(deftest test-proper-word-for-whitelist?-negative
+    "Check the function zg.dictionary-interface/proper-word-for-whitelist?"
+    (testing "the function zg.dictionary-interface/proper-word-for-whitelist?"
+        (are [x] (not (seq (proper-word-for-whitelist? x)))
+            ""
+            "!"
+            "!!"
+            "! !"
+            "Test!"
+            "This is test!"
+            "/"
+            "a/b"
+            "foo/bar")))
+


Add login via github.

Add login via github.

--- src/clj/hatnik/web/server/renderer.clj
+++ src/clj/hatnik/web/server/renderer.clj
@@ -1,5 +1,6 @@
 (ns hatnik.web.server.renderer
-  (:require [hiccup.core :as hc]))
+  (:require [hiccup.core :as hc])
+  (:use [hatnik.config :only [config]]))

 (defn page-html-head []
   (hc/html
@@ -8,12 +9,18 @@
     [:link {:rel "stylesheet" :href "/css/bootstrap.min.css"}]]))

+(def github-link
+  (str "https://github.com/login/oauth/authorize?"
+       "client_id=" (:github-id config)
+       "&scope=user:email"))
+
 (defn page-header []
   [:nav.navbar.navbar-default {:role "navigation"}
    [:div#navbarCollapse.collapse.navbar-collapse
     [:ul.nav.navbar-nav.navbar-right
      [:li
-      [:a.btn "Login via GitHub"]]]]])
+      [:a.btn
+       {:href github-link} "Login via GitHub"]]]]])

 (defn core-page [req]
   (hc/html


RS | #64 | Destructure 'doc' key from context in draft.clj

--- src/objective8/templates/draft.clj
+++ src/objective8/templates/draft.clj
@@ -132,7 +132,7 @@

       [:.clj-draft-comments] nil)))

-(defn draft-page [{:keys [translations data] :as context}]
+(defn draft-page [{:keys [translations data doc] :as context}]
   (let [objective (:objective data)]
     (apply str
            (html/emit*


move all REST validation into processable?

--- src/open_company/api/companies.clj
+++ src/open_company/api/companies.clj
@@ -62,24 +62,14 @@

 ;; ----- Validations -----

-(defn malformed-post-req?
-  "If the request contains valid JSON POST data to create
-   companies, return the parsed JSON, otherwise return nil."
-  [ctx]
-  (let [[invalid-json? parsed] (common/malformed-json? ctx)]
-    (if invalid-json?
-      [true (assoc parsed :reason :malformed-json)]
-      (let [company (company/->company (:data parsed) (:user ctx))
-            valid?  (s/check common-res/Company company)]
-        (if (seq (dissoc valid? :slug)) ; remove slug check because that's handled by processable?
-          [true {:reason valid?}]
-          [false parsed])))))
-
-(defn slug-processable [slug]
-  (cond
-    (nil? slug) true
-    (s/check common-res/Slug slug) [false {:reason :invalid-slug-format}]
-    (not (company/slug-available? slug)) [false {:reason :slug-taken}]))
+(defn processable-post-req? [{:keys [user data]}]
+  (let [company (company/->company data user)
+        invalid? (s/check common-res/Company company)
+        slug-taken? (not (company/slug-available? (:slug company)))]
+    (cond
+      invalid? [false {:reason invalid?}]
+      slug-taken? [false {:reason :slug-taken}]
+      :else [true {}])))

 ;; ----- Resources - see: http://clojure-liberator.github.io/liberator/assets/img/decision-graph.svg

@@ -141,18 +131,13 @@

   :handle-not-acceptable (common/only-accept 406 company-rep/collection-media-type)

-  :malformed? (by-method {
-    :options false
-    :get false
-    :post (fn [ctx] (malformed-post-req? ctx))})
-
   ;; Get a list of companies
   :exists? (fn [_] {:companies (company/list-companies)})

   :processable? (by-method {
     :get true
     :options true
-    :post (fn [ctx] (slug-processable (-> ctx :data :slug)))})
+    :post (fn [ctx] (processable-post-req? ctx))})

   :post! (fn [ctx] {:company (-> (company/->company (:data ctx) (:user ctx))
                                  (company/add-placeholder-sections)


Invoked function returns back ctx AND return value.


editor! and fromSelector now accept completions as an argument

--- src/org/knotation/editor/core.cljs
+++ src/org/knotation/editor/core.cljs
@@ -16,6 +16,7 @@
             [org.knotation.editor.update :as update]

             [org.knotation.api :as api]
+            [org.knotation.rdf :as rdf]
             [org.knotation.state :as st]

             [clojure.string :as string]))
@@ -52,8 +53,11 @@
 (def onLeave on-leave!)

 (defn editor!
-  [editor-selector & {:keys [mode theme focus?]
-                      :or {mode "sparql" theme "default" focus? true}}]
+  [editor-selector & {:keys [mode theme focus? completions]
+                      :or {mode "sparql"
+                           theme "default"
+                           focus? true
+                           completions []}}]
   (styles/apply-style!)
   (let [elem (.querySelector js/document editor-selector)
         opts (clj->js {:lineNumbers true :gutters ["CodeMirror-linenumbers" "line-errors"]
@@ -63,12 +67,15 @@
                        :hintOptions
                        {:completeSingle false
                         :hint (fn [ed opt]
-                                (let [completions ["one" "two" "three" "four"]
-                                      line (util/current-line ed)
+                                (let [completions (.-completions (.-knotation ed))
                                       token (js->clj (.getTokenAt ed (.getCursor ed)))]
-                                  (clj->js {:list (filter #(string/starts-with? % (get token "string")) completions)
-                                            :from {:line line :ch (get token "start")}
-                                            :to {:line line :ch (get token "end")}})))}})
+                                  ;; (.log js/console "TOKEN" (.getTokenAt ed (.getCursor ed)) (clj->js completions))
+                                  (when (> (count (get token "string")) 1)
+                                    (let [line (util/current-line ed)]
+                                      (when (not (empty? completions))
+                                        (clj->js {:list (filter #(string/starts-with? % (get token "string")) completions)
+                                                  :from {:line line :ch (get token "start")}
+                                                  :to {:line line :ch (get token "end")}}))))))}})
         ed (if (= "TEXTAREA" (.-nodeName elem))
              (.fromTextArea js/CodeMirror elem opts)
              (js/CodeMirror elem opts))]
@@ -80,7 +87,9 @@
                     :getCompiledLine
                     (fn [ln-num]
                       (when-let [g (.-graph (.-knotation ed))]
-                        (first (filter #(= (inc ln-num) (->> % ::st/input ::st/line-number)) g))))}))
+                        (first (filter #(= (inc ln-num) (->> % ::st/input ::st/line-number)) g))))
+
+                    :completions completions}))

     (ln/assign-ix! ed)

@@ -91,9 +100,10 @@
     (.on
      ed "change"
      (fn [ed change]
-       (let [chg (js->clj change)]
-         (when (contains? #{"+input" "+delete"} (get chg "origin"))
-           (.execCommand ed "autocomplete")))))
+       (when (not (empty? (.-completions (.-knotation ed))))
+         (let [chg (js->clj change)]
+           (when (contains? #{"+input" "+delete"} (get chg "origin"))
+             (.execCommand ed "autocomplete"))))))

     (on-hover!
      ed (fn [token]
@@ -107,10 +117,13 @@

 (defn fromSelector
   [editor-selector options]
-  (let [opts (merge {:mode "sparql" :theme "default"
-                     :on-hover (.-onHover options)
-                     :focus? (not (not (.-focus options)))}
-                    (dissoc (js->clj options :keywordize-keys true) :focus))]
+  (let [opts (update
+              (merge {:mode "sparql" :theme "default"
+                      :on-hover (.-onHover options)
+                      :completions []
+                      :focus? (not (not (.-focus options)))}
+                     (dissoc (js->clj options :keywordize-keys true) :focus))
+              :completions #(js->clj %))]
     (apply editor! editor-selector (mapcat identity opts))))

 (defn linked-editors


Refactor

Refactor

--- backend/src/akvo/lumen/component/keycloak.clj
+++ backend/src/akvo/lumen/component/keycloak.clj
@@ -28,13 +28,11 @@
 (defn request-headers
   "Create a set of request headers to use for interaction with the Keycloak
    REST API. This allows us to reuse the same token for multiple requests."
-  ([{:keys [openid-config credentials connection-manager] :as k}]
-   (request-headers k {}))
-  ([{:keys [openid-config credentials connection-manager]}
-    {:keys [timeout] :as req-opts}]
+  ([{:keys [openid-config credentials connection-manager] :as keycloak}]
+   (request-headers keycloak {}))
+  ([{:keys [openid-config credentials connection-manager]} req-opts]
    (let [params (merge {:grant_type "client_credentials"} credentials)
-         req-opts (-> (select-keys req-opts [:timeout])
-                      (assoc :form-params params :connection-manager connection-manager))]
+         req-opts (merge {:form-params params :connection-manager connection-manager} req-opts)]
      (when-let [access-token (-> (client/post (get openid-config "token_endpoint") req-opts)
                                  :body
                                  json/decode
@@ -189,7 +187,6 @@
           (println (format "Tried to promote user: %s" user-id))
           (lib/internal-server-error))))))

-
 (defn do-demote-user-from-admin
   [{:keys [api-root] :as keycloak} tenant author-claims user-id]
   (if (= (get author-claims "sub") user-id)
@@ -228,7 +225,6 @@
           (println (format "Tried to remove user: %s" user-id))
           (lib/internal-server-error))))))

-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; API Authorization
 ;;;
@@ -264,20 +260,16 @@

   The Keycloak groups are on the form /akvo/lumen/demo/admin, to simplify  we
   remove the leading /akvo/lumen and return paths as demo/admin."
-  ([keycloak email]
-   (allowed-paths keycloak email {}))
-  ([{:keys [api-root http-timeout user-id-cache connection-manager] :as keycloak} email
-    {:keys [timeout] :or {timeout http-timeout}}]
-   (let [bare-req-opts {:timeout timeout}]
-     (when-let [headers (request-headers keycloak bare-req-opts)]
-       (let [req-opts (assoc bare-req-opts :headers headers :connection-manager connection-manager)]
-         (when-let [user-id (lookup-user-id req-opts api-root user-id-cache email)]
-           (->> (client/get (format "%s/users/%s/groups" api-root user-id) req-opts)
-                :body
-                json/decode
-                (reduce (fn [paths {:strs [path]}]
-                          (conj paths (subs path 12)))
-                        #{}))))))))
+  [{:keys [api-root user-id-cache connection-manager] :as keycloak} email]
+  (when-let [headers (request-headers keycloak)]
+    (let [req-opts {:headers headers :connection-manager connection-manager}]
+      (when-let [user-id (lookup-user-id req-opts api-root user-id-cache email)]
+        (->> (client/get (format "%s/users/%s/groups" api-root user-id) req-opts)
+             :body
+             json/decode
+             (reduce (fn [paths {:strs [path]}]
+                       (conj paths (subs path 12)))
+                     #{}))))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -337,12 +329,11 @@
   (allowed-paths [this email]
     (allowed-paths this email)))

-(defn- init-keycloak [{:keys [credentials http-timeout url realm max-user-ids-cache]}]
+(defn- init-keycloak [{:keys [credentials url realm max-user-ids-cache]}]
   (map->KeycloakAgent {:api-root (format "%s/admin/realms/%s" url realm)
                        :credentials credentials
                        :issuer (format "%s/realms/%s" url realm)
-                       :user-id-cache (atom (cache/lru-cache-factory {} :threshold max-user-ids-cache))
-                       :http-timeout http-timeout}))
+                       :user-id-cache (atom (cache/lru-cache-factory {} :threshold max-user-ids-cache))}))

 (defmethod ig/init-key :akvo.lumen.component.keycloak/data  [_ {:keys [url realm] :as opts}]
   (try
@@ -369,26 +360,31 @@
 (defmethod ig/pre-init-spec :akvo.lumen.component.keycloak/data [_]
   ::data)

+(defn default-req-opts
+  "all timeouts are in milliseconds!!
+  :timeout - Time that connections are left open before automatically closing
+  :connection-timeout - the default connect timeout value for connection
+
+  https://github.com/dakrone/clj-http/issues/477
+  "
+  [opts]
+  (merge {:timeout 5 :threads 2 :insecure? false :default-per-route 2}
+         (select-keys opts [:timeout :threads :insecure? :default-per-route])))
+
 (defn new-connection-manager
   ([] (new-connection-manager {}))
   ([opts]
-   (let [default-values {:timeout 1000 :threads 2 :insecure? false :default-per-route 2}]
-     (http.conn-mgr/make-reusable-conn-manager (merge default-values (select-keys opts [:timeout :threads :insecure? :default-per-route]))))))
-
-
-;;   all timeouts are in milliseconds!!
-;;  :timeout - Time that connections are left open before automatically closing
-;;  :connection-timeout - int the default connect timeout value for connection
+   (http.conn-mgr/make-reusable-conn-manager (default-req-opts opts))))

 (defmethod ig/init-key :akvo.lumen.component.keycloak/keycloak  [_ {:keys [credentials data max-user-ids-cache] :as opts}]
   (log/info "Starting keycloak")
   (let [{:keys [issuer openid-config api-root] :as this} (init-keycloak (assoc data :credentials credentials :max-user-ids-cache max-user-ids-cache))
-        connection-manager (new-connection-manager {:timeout (* 30 1000) :threads 10 :default-per-route 10})
+        connection-manager (new-connection-manager {:timeout (* 10 1000) :threads 10 :default-per-route 10
+                                                    :connection-timeout (* 30 1000)})
         openid-config (fetch-openid-configuration issuer {})]
     (log/info "Successfully got openid-config from provider.")
     (assoc this
            :connection-manager connection-manager
-           :http-timeout http-timeout
            :openid-config openid-config)))

 (defmethod ig/halt-key! :akvo.lumen.component.keycloak/keycloak  [_ opts]


indenting

indenting

--- src/celestial/launch.clj
+++ src/celestial/launch.clj
@@ -71,8 +71,7 @@
     (ssh-config {:key (get! :ssh :private-key-path) :user "root"} )
     (start-nrepl)
     (setup-all components)
-     components)
-  )
+     components))

 (defn start
   "Main components startup (jetty, job workers etc..)"


+(defn json-value-converter)

+(defn json-value-converter)

--- src/babel/reader.clj
+++ src/babel/reader.clj
@@ -398,22 +398,29 @@
 ;; TODO: document why we need this
 ;; TODO: verbcoach should use this, not config/json-read-str
 ;; TODO: move this to babel/globals.cljc or something similar
+(declare json-value-converter)
+
 (defn json-read-str [json]
   (json/read-str json
                  :key-fn keyword
-                 :value-fn (fn [k v]
-                             (cond
-                              (and (or (= k :english)
-                                       (= k :espanol)
-                                       (= k :français)
-                                       (= k :italiano))
-                                   (not (map? v)))
-                              (str v)
-
-                              (and (string? v)
-                                   (= (nth v 0) \:))
-                              (keyword (string/replace-first v ":" ""))
-
-                              (string? v)
-                              (keyword v)
-                              :else v))))
+                 :value-fn json-value-converter))
+
+(defn json-value-converter [k v]
+  (cond
+    (and (or (= k :english)
+             (= k :espanol)
+             (= k :français)
+             (= k :italiano)
+             (= k :latin))
+         (not (map? v)))
+    (str v)
+
+    (and (string? v)
+         (= (nth v 0) \:))
+    (keyword (string/replace-first v ":" ""))
+
+    (string? v)
+    (keyword v)
+    :else v))
+
+


Wait for yellow after creating index

Wait for yellow after creating index

Race.  We've been getting indices that aren't used, in favor of the
auto-created from index ops.

--- src/clj/runbld/store.clj
+++ src/clj/runbld/store.clj
@@ -61,6 +61,7 @@
      (when-not (= (get-in e [:body :error :type])
                   "index_already_exists_exception")
        (throw+ e))))
+  (indices/wait-for-health conn :yellow idx)
   idx)

 (s/defn create-timestamped-index :- s/Str


[refactor] refactor initial clustering

[refactor] refactor initial clustering

--- src/clj_dstream/core.clj
+++ src/clj_dstream/core.clj
@@ -290,11 +290,10 @@
                                 (map (fn [[pos-idx char-vec]] [pos-idx (assoc char-vec ::cluster new-cluster-label)]) grids))]
     grids-w-new-label))

-(defn initial-clustering [state t]
-
+(defn update-grid-cells [state t]
+  ;;TODO spec this
   (let [lambda (get-in state [::properties ::lambda])
         state* (atom state)]
-
     (doseq [[pos-idx char-vec] (::grid-cells @state*)]
       (reset! state* (assoc-in
                        @state*
@@ -302,6 +301,10 @@
                        (update-char-vec-label
                          {::char-vec   (update-char-vec-density char-vec t lambda false)
                           ::properties (::properties state)}))))
+    @state*))
+
+(defn dense-grids->unique-clusters [state]
+  (let [state* (atom state)]
     (doseq [[pos-idx char-vec] (::grid-cells @state*)]
       (if (= ::dense (::label char-vec))
         (do
@@ -315,81 +318,78 @@
                              @state*
                              [::grid-cells pos-idx ::cluster]
                              "NO_CLASS")))))
-    (let [grid-cells       (::grid-cells @state*)
-          initial-clusters (->> @state*
-                                ::grid-cells
-                                vals
-                                (map ::cluster)
-                                (remove nil?)
-                                (remove #(= "NO_CLASS" %)))]
-
-      (println "initial clusters:" initial-clusters)
-      (let [one-pass-fn (fn [the-state]
-                          (let [the-state* (atom the-state)]
-                            (doseq [initial-cluster initial-clusters]
-                              (println " initial cluster: " initial-cluster)
-                              (let [grids-in-cluster (cluster->grid-cells initial-cluster @the-state*)]
-                                (println " grids in cluster: " grids-in-cluster)
-                                (doseq [grid-in-cluster grids-in-cluster]
-                                  (println "   grid in cluster: " grid-in-cluster)
-                                  (let [its-grid-group (grid-cell->grid-group (apply hash-map grid-in-cluster) grid-cells)
-                                        outside-grids  (filter
-                                                         (fn [[pos-idx char-vec]]
-                                                           (= ::outside
-                                                              (grid-is-inside-or-outside-group pos-idx (keys its-grid-group)))) its-grid-group)]
-                                    (doseq [outside-grid outside-grids]
-                                      (println "     outisde grid: " outside-grid)
-                                      (let [neighbors (grid-cell->neighbors (apply hash-map outside-grid) grid-cells)]
-
-                                        (doseq [neighbor neighbors]
-                                          (println "          neighbor: " neighbor)
-                                          (let [neighbor-cluster      (::cluster (second neighbor))
-                                                neighbor-cluster-size (cluster->size neighbor-cluster @the-state*)
-                                                initial-cluster-size  (cluster->size initial-cluster @the-state*)
-                                                ]
-                                            (println "          this size vs initial: " neighbor-cluster-size " ; " initial-cluster-size)
-                                            ;;if neighbor belongs to a cluster
-                                            (if (< 0 neighbor-cluster-size)
-                                              (if (> initial-cluster-size neighbor-cluster-size)
-                                                (do
-                                                  (println "swapping 1")
-                                                  (swap! the-state* assoc-in [::grid-cells] (merge (::grid-cells @the-state*)
-                                                                                (relabel-cluster neighbor-cluster initial-cluster @the-state*))))
-                                                (do
-                                                  (println "swapping 2")
-                                                  (swap! the-state* assoc-in [::grid-cells] (merge (::grid-cells @the-state*)
-                                                                                (relabel-cluster initial-cluster neighbor-cluster @the-state*)))))
-                                              ;;elif neighbor does not have a cluster
-                                              (if (= ::transitional (::label (second neighbor)))
-                                                (do
-                                                  (println "swapping 3")
-                                                  (swap! the-state* assoc-in [::grid-cells] (merge (::grid-cells @the-state*)
-                                                                                {(first neighbor) (assoc (second neighbor) ::cluster initial-cluster)})))
-                                                )
-                                              )
-                                            )
-                                          ))
-                                      )
-                                    )
-                                  ))
-                              )
-                            @the-state*))
-            recur-fn    (fn [s c]
-                          (println "doing one pass" c)
-                          (let [s2 (one-pass-fn s)]
-                            (if (= s s2)
-                              (do
-                                (println "no state change, returning after iters: " c)
-                                s2)
-                              (do
-                                (println "state changed, recurring")
-                                (recur s2 (inc c))))))
-
-            ]
-        (reset! state* (recur-fn @state* 1))
-        ))
-    @state*)
+    @state*))
+
+(defn initial-clustering-single-pass [the-state]
+  (let [the-clusters (->> the-state
+                          ::grid-cells
+                          vals
+                          (map ::cluster)
+                          (remove nil?)
+                          (remove #(= "NO_CLASS" %)))
+        grid-cells   (::grid-cells the-state)
+        the-state*   (atom the-state)]
+    (doseq [initial-cluster the-clusters]
+      (println " initial cluster: " initial-cluster)
+      (let [grids-in-cluster (cluster->grid-cells initial-cluster @the-state*)]
+        (println " grids in cluster: " grids-in-cluster)
+        (doseq [grid-in-cluster grids-in-cluster]
+          (println "   grid in cluster: " grid-in-cluster)
+          (let [its-grid-group (grid-cell->grid-group (apply hash-map grid-in-cluster) grid-cells)
+                outside-grids  (filter
+                                 (fn [[pos-idx char-vec]]
+                                   (= ::outside
+                                      (grid-is-inside-or-outside-group pos-idx (keys its-grid-group)))) its-grid-group)]
+            (doseq [outside-grid outside-grids]
+              (println "     outisde grid: " outside-grid)
+              (let [neighbors (grid-cell->neighbors (apply hash-map outside-grid) grid-cells)]
+
+                (doseq [neighbor neighbors]
+                  (println "          neighbor: " neighbor)
+                  (let [neighbor-cluster      (::cluster (second neighbor))
+                        neighbor-cluster-size (cluster->size neighbor-cluster @the-state*)
+                        initial-cluster-size  (cluster->size initial-cluster @the-state*)
+                        ]
+                    (println "          this size vs initial: " neighbor-cluster-size " ; " initial-cluster-size)
+                    ;;if neighbor belongs to a cluster
+                    (if (< 0 neighbor-cluster-size)
+                      (if (> initial-cluster-size neighbor-cluster-size)
+                        (do
+                          (println "swapping 1")
+                          (swap! the-state* assoc-in [::grid-cells] (merge (::grid-cells @the-state*)
+                                                                           (relabel-cluster neighbor-cluster initial-cluster @the-state*))))
+                        (do
+                          (println "swapping 2")
+                          (swap! the-state* assoc-in [::grid-cells] (merge (::grid-cells @the-state*)
+                                                                           (relabel-cluster initial-cluster neighbor-cluster @the-state*)))))
+                      ;;elif neighbor does not have a cluster
+                      (if (= ::transitional (::label (second neighbor)))
+                        (do
+                          (println "swapping 3")
+                          (swap! the-state* assoc-in [::grid-cells] (merge (::grid-cells @the-state*)
+                                                                           {(first neighbor) (assoc (second neighbor) ::cluster initial-cluster)})))))))))))))
+    @the-state*)
+
   )
+
+(defn initial-clustering [state t]
+  (let [init-state (->
+                     state
+                     (update-grid-cells t)
+                     dense-grids->unique-clusters)]
+
+    (let [recur-fn (fn [s c]
+                     (println "doing one pass" c)
+                     (let [
+                           s2 (initial-clustering-single-pass init-state)]
+                       (if (= s s2)
+                         (do
+                           (println "no state change, returning after iters: " c)
+                           s2)
+                         (do
+                           (println "state changed, recurring")
+                           (recur s2 (inc c))))))]
+      (recur-fn init-state 1))))

 (s/fdef initial-clustering


Add :favoritism meta-error

Add :favoritism meta-error

--- src/clojush/evaluate.clj
+++ src/clojush/evaluate.clj
@@ -401,6 +401,11 @@
                   (max (sequence-similarity g child1-genome)
                        (sequence-similarity g child2-genome)
                        (sequence-similarity child1-genome child2-genome)))
+                1.0)
+              (= cat :favoritism)
+              (if (and (:parent1-genome ind) (:parent2-genome ind))
+                (Math/abs (- (sequence-similarity (:genome ind) (:parent1-genome ind))
+                             (sequence-similarity (:genome ind) (:parent2-genome ind))))
                 1.0)
               ;
               (= cat :autoconstruction-blindness)


show the host in the exception

show the host in the exception

--- src/bzzz/core.clj
+++ src/bzzz/core.clj
@@ -82,7 +82,7 @@
         (http-client/put resolved args callback)
         (http-client/get resolved args callback))
       (catch Throwable e
-        (async/>!! c {:exception (ex-str e)})))))
+        (async/>!! c {:exception (str "host:" resolved "exception:" (ex-str e))})))))

 (defn search-many [hosts input]
   (let [c (async/chan)


make the all-hosts-are-doing-gc message a debug message

--- src/bzzz/core.clj
+++ src/bzzz/core.clj
@@ -38,7 +38,7 @@
   (let [p (filter #(and (rescent? %1) (not-doing-gc? %1)) list)]
     (if (= 0 (count p))
       (let [more (filter rescent? list)]
-        (log/info "found host after ignoring the gcing ones, dump:" list @timer* @discover-hosts* @peers*)
+        (log/debug "found host after ignoring the gcing ones, dump:" list @timer* @discover-hosts* @peers*)
         (first (rand-nth more)))
       (first (rand-nth p)))))


Improve throttle function docstring.

Improve throttle function docstring.

--- src/beicon/core.cljs
+++ src/beicon/core.cljs
@@ -365,9 +365,9 @@
   (.tap ob f))

 (defn throttle
-  "Returns an Observable that emits only the first item
-  emitted by the source Observable during sequential
-  time windows of a specified duration."
+  "Returns an observable sequence that emits only the
+  first item emitted by the source Observable during
+  sequential time windows of a specified duration."
   [ms ob]
   {:pre [(observable? ob) (number? ms)]}
   (.throttle ob ms))


fix newline parsing for java.io.PushbackReader

--- src/blind/reader.clj
+++ src/blind/reader.clj
@@ -91,18 +91,22 @@

 (declare newline?)

+(defn- normalize-newline [rdr ch]
+  (let [ch (char ch)]
+    (if (identical? \return ch)
+      (let [c (char (peek-char rdr))]
+        (when (identical? \formfeed c)
+          (read-char rdr))
+        \newline)
+      ch)))
+
 (deftype IndexingPushbackReader
     [rdr ^:unsynchronized-mutable line ^:unsynchronized-mutable column
      ^:unsynchronized-mutable line-start? ^:unsynchronized-mutable prev]
   Reader
   (read-char [reader]
     (when-let [ch (char (read-char rdr))]
-      (let [ch (if (identical? \return ch)
-                 (let [c (char (peek-char rdr))]
-                   (when (identical? \formfeed c)
-                     (read-char rdr))
-                   \newline)
-                 ch)]
+      (let [ch (normalize-newline rdr ch)]
         (set! prev line-start?)
         (set! line-start? (newline? ch))
         (when line-start?
@@ -130,7 +134,7 @@
   (read-char [rdr]
     (let [c (.read ^java.io.PushbackReader rdr)]
       (when-not (== -1 c)
-        (char c))))
+        (normalize-newline rdr (char c)))))

   (peek-char [rdr]
     (when-let [c (read-char rdr)]


Finish renaming.

Finish renaming.

--- src/oc/storage/representations/activity.clj
+++ src/oc/storage/representations/activity.clj
@@ -40,8 +40,8 @@
 (defn- is-inbox? [collection-type]
   (= collection-type "inbox"))

-(defn- is-contributor? [collection-type]
-  (= collection-type "contributors"))
+(defn- is-contributions? [collection-type]
+  (= collection-type "contributions"))

 (defn- pagination-link
   "Add `next` and/or `prior` links for pagination as needed."
@@ -55,7 +55,7 @@
                    (cond
                      (is-inbox? collection-type)
                      (inbox-url collection-type org {:start last-activity-date :direction direction})
-                     (is-contributor? collection-type)
+                     (is-contributions? collection-type)
                      (contributions-url org author-uuid sort-type {:start last-activity-date :direction direction})
                      :else
                      (url collection-type org sort-type {:start last-activity-date :direction direction})))
@@ -78,11 +78,11 @@
   [params org collection-type activity boards user]
   (let [sort-type (:sort-type params)
         inbox? (is-inbox? collection-type)
-        contributor? (is-contributor? collection-type)
+        contributions? (is-contributions? collection-type)
         collection-url (cond
                         inbox?
                         (inbox-url collection-type org)
-                        contributor?
+                        contributions?
                         (contributions-url org (:author-uuid params) (:sort-type params))
                         :else
                         (url collection-type org sort-type))
@@ -90,7 +90,7 @@
         other-sort-url (cond
                         inbox?
                         nil
-                        contributor?
+                        contributions?
                         (contributions-url org (:author-uuid params) (if recent-activity-sort? :recently-posted :recent-activity))
                         :else
                         (url collection-type org (if recent-activity-sort? :recently-posted :recent-activity)))


Use a more unique index name to stop concurrent build/test errors.

--- test/clj_ravendb/client_putting_indexes_test.clj
+++ test/clj_ravendb/client_putting_indexes_test.clj
@@ -6,7 +6,8 @@
             [clj-ravendb.config :refer :all]))

 (let [client (client ravendb-url ravendb-database {:ssl-insecure? true :oauth-url oauth-url :api-key api-key})
-      idx {:index "ExpensiveSweetAndSavouryProductsWithLowStockAndRunningOut"
+      idx-name (str "ExpensiveSweetAndSavouryProductsWithLowStockAndRunningOut" (System/currentTimeMillis))
+      idx {:index idx-name
            :from :Products
            :where [[:> :PricePerUser 20] [:< :UnitsInStock 10] [:== :UnitsOnOrder 0] [:== :Category "categories/2"]]
            :select [:Name]}]
@@ -32,7 +33,7 @@
   (deftest test-query-put-index-returns-correct-results
     (testing "querying an index returns the correct results"
       (let [_ (put-index! client idx)
-            actual (query-index client {:index "ExpensiveSweetAndSavouryProductsWithLowStockAndRunningOut"})
+            actual (query-index client {:index idx-name})
             results (sort-by :UnitsInStock (actual :results))
             doc-one (first (filter
                              (fn [i]
@@ -60,4 +61,4 @@

   (use-fixtures :each (fn [f]
                         (f)
-                        (delete-index! client "ExpensiveSweetAndSavouryProductsWithLowStockAndRunningOut"))))+                        (delete-index! client idx-name))))


remove unnecessary var

remove unnecessary var

--- src/chat/client/views/new_message.cljs
+++ src/chat/client/views/new_message.cljs
@@ -55,9 +55,6 @@
                           (> x z) z
                           (< x a) a
                           :else x))
-            thread-tag-ids (-> (store/id->thread (config :thread-id))
-                               :tag-ids
-                               set)
             partial-tag (second (re-matches #"(?:.|\n)*#(\S*)" text))
             results ((get-in engines [0 :results]) partial-tag (config :thread-id))
             highlight-next!


Coffee stays "fresh" for 10 min.

Coffee stays "fresh" for 10 min.

--- src/cljs/mokkameister/brew_status.cljs
+++ src/cljs/mokkameister/brew_status.cljs
@@ -1,7 +1,7 @@
 (ns mokkameister.brew-status
   (:require [mokkameister.loading :refer [loading-gif]]))

-(def ^:private fresh-coffee-minutes 5)
+(def ^:private fresh-coffee-minutes 10)

 (defn- fresh-brew? [brew]
   (let [duration (:brew-time brew)


CMR-657: Added comment to explain dissoc of score field.

--- src/cmr/system_int_test/data2/core.clj
+++ src/cmr/system_int_test/data2/core.clj
@@ -101,6 +101,8 @@
   "Returns true if the references match the expected items"
   [items search-result]
   (let [result (= (set (map item->ref items))
+                  ;; need to remove score because it won't be available in collections
+                  ;; to which we are comparing
                   (set (map #(dissoc % :score) (:refs search-result))))]
     (when (:status search-result)
       (println (pr-str search-result)))
@@ -110,6 +112,8 @@
   "Returns true if the references match the expected items in the order specified"
   [items search-result]
   (= (map item->ref items)
+     ;; need to remove score because it won't be available in collections
+     ;; to which we are comparing
      (map #(dissoc % :score) (:refs search-result))))

 (defmacro record-fields


Fix scrape logging format

Fix scrape logging format

--- src/servisne_info/tasks/scrape.clj
+++ src/servisne_info/tasks/scrape.clj
@@ -33,4 +33,4 @@
        (save-news)))

 (deftask "scrape"
-  (println "Scraping new links, count='" (save-links) "'"))
+  (println (str "Scraping new links, count='" (save-links) "'")))


Allow recovering to see referral flow

Allow recovering to see referral flow

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

--- src/status_im/multiaccounts/login/core.cljs
+++ src/status_im/multiaccounts/login/core.cljs
@@ -250,9 +250,7 @@
   [{:keys [db] :as cofx}]
   (let [{:keys [multiaccount multiaccounts :multiaccount/accounts]} db
         {:keys [creating?]}                                         (:multiaccounts/login db)
-        recovering?                                                 (get-in db [:intro-wizard :recovering?])
         first-account?                                              (and creating?
-                                                                         (not recovering?)
                                                                          (empty? multiaccounts))]
     (fx/merge cofx
               {:db                   (-> db


🏗 Update congregation projection with events from database

--- src/territory_bro/congregation.clj
+++ src/territory_bro/congregation.clj
@@ -144,3 +144,21 @@
   (query! conn :revoke-access {:congregation cong-id
                                :user user-id})
   nil)
+
+
+(def cache (atom {:last-event nil
+                  :state nil}))
+
+(defn update-cache! [conn]
+  (let [cached @cache
+        new-events (event-store/read-all-events conn {:since (:event/global-revision (:last-event cached))})]
+    (when-let [last-event (last new-events)]
+      (log/info "Updating with" (count new-events) "new events")
+      (let [updated {:last-event last-event
+                     :state (reduce congregations-view (:state cached) new-events)}]
+        ;; with concurrent requests, only one of them will update the cache
+        (compare-and-set! cache cached updated)))))
+
+(comment
+  (count (:state @cache))
+  (update-cache! db/database))


DOM parentNode is a property, not a function.

--- src/cljs/c2/dom.cljs
+++ src/cljs/c2/dom.cljs
@@ -44,7 +44,7 @@
           (.-childNodes (select node))))

 (defn parent [node]
-  (.parentNode (select node)))
+  (.-parentNode (select node)))


Updated test-and-train-data-from-domains to ensure that the test and training sets are a disjoint union of the input set

--- src/clojush/util.clj
+++ src/clojush/util.clj
@@ -245,12 +245,15 @@
                             (if (fn? input-set)
                               (vector (repeatedly n-train input-set)
                                       (repeatedly n-test input-set))
-                              (vector (if (>= n-train (count input-set))
-                                        input-set
-                                        (take n-train (shuffle input-set)))
-                                      (if (>= n-test (count input-set))
-                                        input-set
-                                        (take n-test (shuffle input-set))))))
+                              (let [shuffled-inputs (shuffle input-set)
+                                    train-inputs (if (= n-train (count input-set))
+                                                   input-set
+                                                   (take n-train shuffled-inputs))
+                                    test-inputs (if (= n-test (count input-set))
+                                                   input-set
+                                                   (drop n-train shuffled-inputs))]
+                                (assert (= (+ n-train n-test) (count input-set)) "Sizes of train and test sets don't add up to the size of the input set.")
+                                (vector train-inputs test-inputs))))
                           domains)))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Take static url for organization logo

Take static url for organization logo

--- src/time_tracker/invoices/core.clj
+++ src/time_tracker/invoices/core.clj
@@ -134,8 +134,7 @@
                                                          #"\n")]
     (clj-pdf/pdf
      [{:font {:encoding :unicode}}
-      [:image {:xscale 0.5 :yscale 0.5}
-       (.getFile (clojure.java.io/resource (util/from-config :logo)))]
+      [:image {:xscale 0.2 :yscale 0.2} (util/from-config :logo)]

       ;; Nilenso + Client information
       [:table {:width 100 :border false :cell-border false :spacing -5 :num-cols 2}


namespace collision

namespace collision

--- src/euler/helper.clj
+++ src/euler/helper.clj
@@ -31,10 +31,10 @@
   Multiplies all natural numbers from 1 to n+1."
   (reduce * (range 1N (inc n))))

-(def facts
+(def factorials
 "**facts :: [Int]**
 Lazy, infinite sequence of all factorial numbers."
-  (lazy-cat [1] (map * facts (iterate inc 2))))
+  (lazy-cat [1] (map * factorials (iterate inc 2))))

 (defn lattice-paths [n]
   ;; divide the factorial of 2n


Use symbol instead of keyword to avoid warning

--- src/leiningen/new/chestnut/project.clj
+++ src/leiningen/new/chestnut/project.clj
@@ -52,7 +52,7 @@
                            :output-dir "target"
                            :source-map-timestamp true
                            :optimizations :advanced
-                           :closure-defines {:goog.DEBUG false}
+                           :closure-defines {goog.DEBUG false}
                            :pretty-print false}}]}

   ;; When running figwheel from nREPL, figwheel will read this configuration


Bugfix: else case was indented wrong

Bugfix: else case was indented wrong

--- src/grimoire/doc.clj
+++ src/grimoire/doc.clj
@@ -267,6 +267,7 @@
                         (map io/file)
                         (tns.f/find-namespaces))]
           (require ns)
-          (write-docs-for-ns config ns))
-
-        (:doc (meta #'-main)))))
+          (write-docs-for-ns config ns)))
+
+    ;; Implicit else
+    (:doc (meta #'-main))))


Add another missing newline

Add another missing newline

--- src/hu/ssh/github_changelog/github.clj
+++ src/hu/ssh/github_changelog/github.clj
@@ -14,4 +14,4 @@
   (let [{:keys [user repo token github-api]} config
         options {:token token, :all-pages true, :state "closed"}]
     (with-url github-api
-              (map parse-pull (pulls/pulls user repo options)))))+              (map parse-pull (pulls/pulls user repo options)))))


#35 fix joda datetime serialization

#35 fix joda datetime serialization

--- src/io/sarnowski/swagger1st/parser.clj
+++ src/io/sarnowski/swagger1st/parser.clj
@@ -12,13 +12,11 @@
            (clojure.lang ExceptionInfo)))

 ; add json capability to org.joda.time.DateTime
-(add-encoder
-  org.joda.time.DateTime
-  (fn [dt jsonGenerator]
-    (.writeString jsonGenerator
-                  (-> dt
-                      (f/formatters :date-time)
-                      (f/unparse)))))
+(add-encoder org.joda.time.DateTime
+   (fn [d jsonGenerator]
+     (->> d
+          (f/unparse (:date-time f/formatters))
+          (.writeString jsonGenerator))))

 (def json-content-type?
   ; TODO could be more precise but also complex


Update builtins.clj

Update builtins.clj

--- src/iyye/subcon/knowledge/builtins.clj
+++ src/iyye/subcon/knowledge/builtins.clj
@@ -1,5 +1,5 @@
 ; Iyye - AI agent
-; Copyright (C) 2016-2018  Sasha Yumzya
+; Copyright (C) 2016-2019  Sasha Yumzya

 ; This program is free software: you can redistribute it and/or modify
 ; it under the terms of the GNU Affero General Public License as
@@ -18,7 +18,8 @@
                                      [clojure.tools.logging :as log]
                                      [iyye.bios.persistence :as persistence]
                                      ;[iyye.subcon.knowledge.relation :as relation]
-                                     [iyye.subcon.knowledge.words :as words]))
+                                     [iyye.subcon.knowledge.words :as words]
+                                     [iyye.subcon.knowledge.inference :as inference]))

 ; Builtin types
 (def iyye_actor (ref 0))
@@ -71,21 +72,21 @@
       new-p2-type)))

 (defn iyye_is_type_function [params]
-  (let [[rel & remaining] params
-        pars (words/check-select-params rel remaining)
+  (let [[pred rel & remaining] params
+        ;       pars (words/check-select-params rel remaining)
         ;rel (first (filter #(= "relation" (:Type (:name %))) relations))
         ]
-      (if (and (:Predicate rel) pars) ; is Relation
-        ((:Function rel) pars)
+      (if (:Predicate rel) ; is Relation
+        ((:Function rel) (cons pred remaining))
         (words/->Iyye_Error (pr-str "Not a relation: " rel) pr-str))))

 (defn iyye_is_type_function_relation [params]
-  (let [[type1 type2 pred & rest] params]
+  (let [[pred type1 type2 & rest] params]
   (if rest
     (words/->Iyye_Error (pr-str "Too many types to relation: " params) pr-str)
     (if type2
-      (if (:UNKNOWN (first type2))
-        (iyye_add_relation type1 (words/create-iyye-type (:UNKNOWN type2)) (words/builtin-words @iyye_is_type_rel) pred)
+      (if (:UNKNOWN type2)
+        (iyye_add_relation (words/create-iyye-type (:UNKNOWN type2)) type1 (words/builtin-words @iyye_is_type_rel) pred)
         (iyye_add_relation type1 type2 (words/builtin-words @iyye_is_type_rel) pred))
       (words/->Iyye_Error (pr-str "No type in : " params) pr-str)))))

@@ -144,7 +145,7 @@
                    (create-entry yumzya)))))

 (defn- init-builtin-relations []
-  (let [t_is (create-iyye-builtin-relation "type" ["type" "?" "predicate"] iyye_is_type_function_relation iyye_is_type_predicate_function)
+  (let [t_is (create-iyye-builtin-relation "type" ["type" "?"] iyye_is_type_function_relation iyye_is_type_predicate_function)
         ;t_is2 (create-iyye-builtin-relation "is" [:UNKNOWN "type"] iyye_is_type_create_function iyye_is_type_predicate_function)
         ;  consistsof (create-iyye-builtin-relation "has" [] iyye_consists_function iyye_is_type_predicate_function)
         ;instof (create-iyye-builtin-relation "instance" ["type"] iyye_instance_function iyye_is_type_predicate_function)
@@ -156,8 +157,8 @@
     (dosync (alter words/builtin-words conj (create-entry t_is)))))

 (defn- init-builtin-verbs []
-  (let [t_is (create-iyye-builtin-verb "is" ["relation" "*"] "relation" iyye_is_type_function)
-        t_is? (create-iyye-builtin-query "is?" ["relation" "type" "?"] iyye_is_predicate_function)
+  (let [t_is (create-iyye-builtin-verb "is" ["predicate" "relation" "*"] "relation" iyye_is_type_function)
+        t_is? (create-iyye-builtin-query "is?" ["relation" "*"] iyye_is_predicate_function)
         ;t_is2 (create-iyye-builtin-relation "is" [:UNKNOWN "type"] iyye_is_type_create_function iyye_is_type_predicate_function)
         consistsof (create-iyye-builtin-verb "has" ["type" "*"] "relation" iyye_consists_function)
         ;instof (create-iyye-builtin-relation "instance" ["type"] iyye_instance_function iyye_is_type_predicate_function)
@@ -175,21 +176,20 @@
         f (get-function @iyye_is_type)]
         (when f
           (do
-            (f [(get-type @iyye_is_type_rel) [(get-type @iyye_ai)] [(get-type @iyye_actor)]
-                [(words/->Iyye_ModalPredicate :IYE :AXIOM (persistence/local-time-to-string) :ALWAYS)]])
-            (f [(get-type @iyye_is_type_rel) [(get-type @iyye_human)] [(get-type @iyye_actor)]
-                [(words/->Iyye_ModalPredicate :IYE :AXIOM (persistence/local-time-to-string) :ALWAYS)]])
-            (f [(get-type @iyye_is_type_rel) [(get-type @iyye_iyye)] [(get-type @iyye_ai)]
-                [(words/->Iyye_ModalPredicate :IYE :AXIOM (persistence/local-time-to-string) :ALWAYS)]])
-            (f [(get-type @iyye_is_type_rel) [(get-type @iyye_yumzya)] [(get-type @iyye_human)]
-                [(words/->Iyye_ModalPredicate :IYE :AXIOM (persistence/local-time-to-string) :ALWAYS)]])))))
+            (f [(words/->Iyye_ModalPredicate :IYE :AXIOM (persistence/local-time-to-string) :ALWAYS)
+                (get-type @iyye_is_type_rel) (get-type @iyye_ai) (get-type @iyye_actor)])
+            (f [(words/->Iyye_ModalPredicate :IYE :AXIOM (persistence/local-time-to-string) :ALWAYS)
+                (get-type @iyye_is_type_rel) (get-type @iyye_human) (get-type @iyye_actor)])
+            (f [(words/->Iyye_ModalPredicate :IYE :AXIOM (persistence/local-time-to-string) :ALWAYS)
+                (get-type @iyye_is_type_rel) (get-type @iyye_iyye) (get-type @iyye_ai)])
+            (f [(words/->Iyye_ModalPredicate :IYE :AXIOM (persistence/local-time-to-string) :ALWAYS)
+                (get-type @iyye_is_type_rel) (get-type @iyye_yumzya) (get-type @iyye_human)])))))

 (defn- init-builtins-kb []
   (init-builtin-words)
   (init-builtin-verbs)
   (init-builtin-relations)
-  (apply-builtin-relations)
-  )
+  (apply-builtin-relations))

 ;(dorun (map #(do ( persistence/write-fact-to-db (into {} %))) @action-words))
 ; (apply str (rest (str (:When {:When :ALWAYS}))))


Improve autocomplete to handle module prefix better

--- src/lt/plugins/elm_light.cljs
+++ src/lt/plugins/elm_light.cljs
@@ -136,8 +136,16 @@
                                           command (assoc info :token token) :only ed))))))

-(defn create-hints [completions]
-  (map #(do #js {:completion (:completion %)
+
+(js/CodeMirror.extendMode "elm" (clj->js {:hint-pattern #"[\w_\.]"}))
+
+(defn- maybe-trim-prefix [token completion]
+  (if (> (.indexOf "." token) -1)
+    (last (s/split comletion "."))
+    completion))
+
+(defn create-hints [token completions]
+  (map #(do #js {:completion (maybe-trim-prefix token (:completion %))
                  :text (:text %)})
        completions))

@@ -145,20 +153,20 @@
           :triggers #{:editor.elm.hints.result}
           :reaction (fn [ed res]
                       (when [res]
-                        (object/merge! ed {::hints (create-hints res)})
+                        (object/merge! ed {::hints (create-hints (::token ed) res)})
                         (object/raise auto-complete/hinter :refresh!))
                       (notifos/done-working)))

 (behavior ::use-local-hints
           :triggers #{:hints+}
-          :reaction (fn [ed hints token]
-                      (when (not= token (::token @ed))
-                          (object/merge! ed {::token token})
-                          (object/raise ed :editor.elm.hints.update!))
-                        (if-let [elm-hints (::hints @ed)]
-                          (concat elm-hints hints)
-                          hints)))
-
+          :reaction (fn [ed hints _]
+                      (let [token (find-symbol ed (editor/->cursor ed))]
+                        (when (not= token (::token @ed))
+                         (object/merge! ed {::token token})
+                         (object/raise ed :editor.elm.hints.update!)))
+                      (if-let [elm-hints (::hints @ed)]
+                        (concat elm-hints hints)
+                        hints)))

 (behavior ::connect


Add instance stores for c4 instances

Add instance stores for c4 instances

--- src/maestro/messages/data.clj
+++ src/maestro/messages/data.clj
@@ -31,6 +31,11 @@
    "c3.2xlarge" {:instance-stores 2}
    "c3.4xlarge" {:instance-stores 2}
    "c3.8xlarge" {:instance-stores 2}
+   "c4.large" {:instance-stores 0}
+   "c4.xlarge" {:instance-stores 0}
+   "c4.2xlarge" {:instance-stores 0}
+   "c4.4xlarge" {:instance-stores 0}
+   "c4.8xlarge" {:instance-stores 0}
    "cc2.8xlarge" {:instance-stores 4}
    "cg1.4xlarge" {:instance-stores 2}
    "cr1.8xlarge" {:instance-stores 2}


Check for clojure.lang.BigInt to support Clojure 1.2.x

--- src/main/clojure/clojure/data/json.clj
+++ src/main/clojure/clojure/data/json.clj
@@ -363,9 +363,14 @@
 ;; Numbers
 (extend java.lang.Number       JSONWriter {:-write write-plain})
 (extend clojure.lang.Ratio     JSONWriter {:-write write-ratio})
-(extend clojure.lang.BigInt    JSONWriter {:-write write-bignum})
 (extend java.math.BigInteger   JSONWriter {:-write write-bignum})
 (extend java.math.BigDecimal   JSONWriter {:-write write-bignum})
+;; Attempt to support Clojure 1.2.x:
+(when (try (.. Thread currentThread getContextClassLoader
+               (loadClass "clojure.lang.BigInt"))
+           (catch ClassNotFoundException _ false))
+  (extend clojure.lang.BigInt    JSONWriter {:-write write-bignum}))
+

 ;; Symbols, Keywords, and Strings
 (extend clojure.lang.Named     JSONWriter {:-write write-named})


cleaning up client so that it doesn't trigger compile warning

--- support/src/figwheel/client.cljs
+++ support/src/figwheel/client.cljs
@@ -123,10 +123,9 @@
 (defn ensure-cljs-user
   "The REPL can disconnect and reconnect lets ensure cljs.user exists at least."
   []
-  (when-not js/cljs
-    (set! js/cljs #js {}))
-  (when-not (.-user js/cljs)
-    (set! (.-user js/cljs) #js {})))
+  ;; this should be included in the REPL
+  (when-not js/cljs.user
+    (set! js/cljs.user #js {})))

 (defn repl-plugin [{:keys [build-id] :as opts}]
   (fn [[{:keys [msg-name] :as msg} & _]]


Respond with appropriate content-type

Respond with appropriate content-type

--- src/qcast/server.clj
+++ src/qcast/server.clj
@@ -69,8 +69,13 @@

 ;;; Main

+(defn- rss-response [body & [status]]
+  {:status (or status 200)
+   :headers {"Content-Type" "application/rss+xml"}
+   :body body})
+
 (defroutes app-routes
-  (GET "/feed" [] serve-feed)
+  (GET "/feed" [] (comp rss-response serve-feed))
   (route/files "/")
   (route/not-found "Not found"))


add class for bar-class

add class for bar-class

this allow us use classes like ```progress-bar-success, progress-bar-info, progress-bar-warning, progress-bar-danger```

--- src/re_com/misc.cljs
+++ src/re_com/misc.cljs
@@ -338,16 +338,17 @@
 ;; ------------------------------------------------------------------------------------

 (def progress-bar-args-desc
-  [{:name :model    :required true  :type "double | string | atom"                 :validate-fn number-or-string? :description "current value of the slider. A number between 0 and 100"}
-   {:name :width    :required false :type "string"                 :default "100%" :validate-fn string?           :description "a CSS width"}
-   {:name :striped? :required false :type "boolean"                :default false                                 :description "when true, the progress section is a set of animated stripes"}
-   {:name :class    :required false :type "string"                                 :validate-fn string?           :description "CSS class names, space separated"}
-   {:name :style    :required false :type "CSS style map"                          :validate-fn css-style?        :description "CSS styles to add or override"}
-   {:name :attr     :required false :type "HTML attr map"                          :validate-fn html-attr?        :description [:span "HTML attributes, like " [:code ":on-mouse-move"] [:br] "No " [:code ":class"] " or " [:code ":style"] "allowed"]}])
+  [{:name :model     :required true  :type "double | string | atom"                 :validate-fn number-or-string? :description "current value of the slider. A number between 0 and 100"}
+   {:name :width     :required false :type "string"                 :default "100%" :validate-fn string?           :description "a CSS width"}
+   {:name :striped?  :required false :type "boolean"                :default false                                 :description "when true, the progress section is a set of animated stripes"}
+   {:name :class     :required false :type "string"                                 :validate-fn string?           :description "CSS class names, space separated"}
+   {:name :bar-class :required false :type "string"                                 :validate-fn string?           :description "CSS class names, space separated"}
+   {:name :style     :required false :type "CSS style map"                          :validate-fn css-style?        :description "CSS styles to add or override"}
+   {:name :attr      :required false :type "HTML attr map"                          :validate-fn html-attr?        :description [:span "HTML attributes, like " [:code ":on-mouse-move"] [:br] "No " [:code ":class"] " or " [:code ":style"] "allowed"]}])

 (defn progress-bar
   "Render a bootstrap styled progress bar"
-  [& {:keys [model width striped? class style attr]
+  [& {:keys [model width striped? class bar-class style attr]
       :or   {width "100%"}
       :as   args}]
   {:pre [(validate-args-macro progress-bar-args-desc args "progress-bar")]}
@@ -362,7 +363,7 @@
                               style)}
                attr)
              [:div
-              {:class (str "progress-bar " (when striped? "progress-bar-striped active"))
+              {:class (str "progress-bar " bar-class (when striped? "progress-bar-striped active"))
                :role  "progressbar"
                :style {:width      (str model "%")
                        :transition "none"}}                 ;; Default BS transitions cause the progress bar to lag behind