Define notes not in C major.

Define notes not in C major.

--- src/overtunes/pitch.clj
+++ src/overtunes/pitch.clj
@@ -56,10 +56,13 @@
                    (scale unison tone tone semitone tone tone tone semitone)))

 ; Name notes
-(defall [C D E F G A B]
+(defall [C C# D D# E F F# G G# A A# B B#]
         (map
           grounding
-          (sort (vals major-scale))))
+          (range (+ 1 octave))))
+
+(defall [Cb Db Eb E# Fb Gb Ab Bb]
+        [D  C# D# F  E  F# G# A#])

 ; Operations on intervals
 (def sharp #(+ % semitone))


Push message to build queue

Push message to build queue

--- src/harland/build.clj
+++ src/harland/build.clj
@@ -1,5 +1,17 @@
 (ns harland.build
-  (require [me.raynes.conch :as sh]))
+  (require [me.raynes.conch :as sh]
+           [taoensso.carmine :as car :refer (wcar)]))
+
+; TODO move this to conf file or something
+(def master-redis "redis://localhost:6379")
+(def server-conn {:pool {} :spec {:uri master-redis}})
+(defmacro wcar* [& body] `(car/wcar server-conn ~@body))
+
+(defn schedule-build
+  "Schedule a build"
+  [project-name]
+  (wcar*
+    (car/lpush "build-queue" project-name)))

 (defn build
   "Runs a build using conch"


Add :name-or-label to hatti.shared/app-state

Signed-off-by: Njagi Mwaniki <b6a4ba60ad861b9c9afb6daea7294be4be68f44c@urbanslug.com>

--- src/hatti/shared.cljs
+++ src/hatti/shared.cljs
@@ -66,6 +66,7 @@
                  :chart-data {}}
     :dataset-info {}
     :data []
+    :name-or-label :label
     :status {:total-records 0 :loading? true}
     :languages {:current nil :all []}
     :api-url "//api.ona.io/api/v1/"}))


Improve docstrings

Improve docstrings

--- src/icecap/schema.clj
+++ src/icecap/schema.clj
@@ -1,4 +1,5 @@
 (ns icecap.schema
+  "The schemata in icecap: request specifications and their components."
   (:require [schema.core :as s])
   (:import [java.net URI]))

@@ -7,7 +8,7 @@
   #{"http" "https"})

 (defn get-scheme
-  "Gets the scheme of a (String) URL."
+  "Gets the scheme of a URL."
   [url]
   (.getScheme (URI. url)))

@@ -16,12 +17,12 @@
   (comp supported-schemes get-scheme))

 (def SimpleRequest
-  "A simple request."
+  "The schema for a simple request."
   {:target (s/both s/Str
                    (s/pred supported-scheme? "supported-scheme?"))})

 (defn with-one-or-more
-  "Build a schema for a collection schema with 1+ items.
+  "Constrain a seq schema to require one or more items.

   Specifically, this checks that both the given schema is matched
   *and* there is at least one item in it."
@@ -30,23 +31,17 @@
           (s/pred seq "collection of one or more request specs")))

 (def RequestSpec
-  "A request specification.
+  "The schema for a request specification.

-  Please note that this uses prismatic/schema's `conditional` with
-  type dispatch, rather than the (perhaps more obvious) `either`. The
-  problem with `either` is that it didn't know which of the schemas
-  *probably* should have validated: if you give it a bogus
-  `SimpleRequest`, it can only tell you that it:
+  Consists either of a `SimpleRequest`, a `RequestSpec` set, or a
+  `RequestSpec` vector.

-  - wasn't a valid `SimpleRequest`
-  - wasn't an unordered collection of valid `SimpleRequests`
-  - wasn't an ordered collection of valid `SimpleRequests`
-
-  ... but it fails to tell you that it *was* something that looked
-  like a SimpleRequest but didn't validate because, for example, its
-  target was `ftp`, which is an unsupported URL scheme. That would've
-  been far more useful. Using `conditional` allows us to return
-  this (useful) error message.
+  This uses prismatic/schema's `conditional` with type dispatch,
+  rather than the (perhaps more obvious) `either`. If you give it a
+  bogus `SimpleRequest`, it will only tell you that it didn't satisfy
+  any of the three schemas. It won't tell you that it looked a little
+  like a `SimpleRequest`, but had unsupported URL scheme. Using
+  `conditional` allows us to return this improved error message.
   "
   (let [RequestSpec (s/recursive #'RequestSpec)]
     (s/conditional


[lein] Use eastwood

[lein] Use eastwood

--- .lein/profiles.clj
+++ .lein/profiles.clj
@@ -8,6 +8,7 @@
                   [lein-kibit                        "0.1.3"]
                   [lein-bikeshed                     "0.4.1"]
                   [slamhound                         "1.5.5"]
+                  [jonase/eastwood                   "0.2.3"]

                   [lein-pprint                       "1.1.2"]
                   [lein-figwheel                     "0.5.9"]


Autoreloading lein repl

Autoreloading lein repl

--- lein/profiles.clj
+++ lein/profiles.clj
@@ -1 +1,2 @@
-{:user {:plugins [[com.jakemccrary/lein-test-refresh "0.9.0"]]}}
+{:user {:plugins [[com.jakemccrary/lein-test-refresh "0.9.0"]
+                 [lein-autoreload "0.1.0"]]}}


Style fixes

Style fixes


[#2763] Refactor

[#2763] Refactor

--- backend/src/akvo/lumen/lib/update.clj
+++ backend/src/akvo/lumen/lib/update.clj
@@ -63,9 +63,9 @@
                                                   :columns             columns
                                                   :transformations     transformations})
     (db.transformation/touch-dataset conn {:id dataset-id})
-    (db.transformation/drop-table conn {:table-name (:imported-table-name old-dataset-version)})
-    (db.transformation/drop-table conn {:table-name (:table-name old-dataset-version)})
-    (db.job-execution/update-successful-job-execution conn {:id job-execution-id})))
+    (db.job-execution/update-successful-job-execution conn {:id job-execution-id})
+    (db.transformation/drop-table tenant-conn {:table-name (:imported-table-name old-dataset-version)})
+    (db.transformation/drop-table tenant-conn {:table-name (:table-name old-dataset-version)})))

 (defn- failed-update [conn job-execution-id reason]
   (db.job-execution/update-failed-job-execution conn {:id job-execution-id
@@ -124,67 +124,66 @@
                                    columns))
       nil)))

-(defn- import-data-to-table [tenant-conn caddisfly import-config dataset-id job-execution-id data-source-spec]
+(defn- import-data-to-table [tenant-conn import-config dataset-id job-execution-id data-source-spec]
   (jdbc/with-db-transaction [conn tenant-conn]
     (with-open [importer (import/dataset-importer (get data-source-spec "source") import-config)]
-      (let [initial-dataset-version  (db.transformation/initial-dataset-version-to-update-by-dataset-id conn {:dataset-id dataset-id})
-            latest-dataset-version (db.transformation/latest-dataset-version-by-dataset-id conn {:dataset-id dataset-id})
-            imported-dataset-columns (vec (:columns initial-dataset-version))
-            importer-columns         (p/columns importer)
-
-            columns-used (columns-used-in-txs
-                          (import/importer-type (get data-source-spec "source"))
-                          initial-dataset-version
-                          latest-dataset-version)
-            imported-dataset-columns-checked (reduce (fn [c co]
-                                                       (if (contains? columns-used (get co "columnName"))
-                                                         (conj c co)
-                                                         c)) [] imported-dataset-columns)]
-        (if-let [compatible-errors (compatible-columns-error? imported-dataset-columns-checked importer-columns)]
-          (failed-update conn job-execution-id
-                         (cond-> "Column mismatch"
-                           (seq (:missed-columns compatible-errors))
-                           (str ".\n Following columns are missed in new data version: " (:missed-columns compatible-errors))
-                           (seq (:wrong-types compatible-errors))
-                           (str ".\n Following columns have changed the column type in new data version: " (:wrong-types compatible-errors))))
-          (let [table-name          (util/gen-table-name "ds")
-                imported-table-name (util/gen-table-name "imported")]
-            (postgres/create-dataset-table conn table-name importer-columns)
-            (doseq [record (map (comp postgres/coerce-to-sql import/extract-first-and-merge) (p/records importer))]
-              (jdbc/insert! conn table-name record))
-            (db.job-execution/clone-data-table conn {:from-table table-name
-                                                     :to-table   imported-table-name}
-                                               {}
-                                               {:transaction? false})
-            (let [coerce-column-fn (fn [{:keys [title id type key multipleId multipleType groupName groupId] :as column}]
-                                     (cond-> {"type" type
-                                              "title" title
-                                              "columnName" id
-                                              "groupName" groupName
-                                              "groupId" groupId
-                                              "sort" nil
-                                              "direction" nil
-                                              "hidden" false}
-                                       key           (assoc "key" (boolean key))
-                                       multipleType (assoc "multipleType" multipleType)
-                                       multipleId   (assoc "multipleId" multipleId)))]
-              {:table-name table-name :imported-table-name imported-table-name
-               :importer-columns (mapv coerce-column-fn importer-columns) :imported-dataset-columns imported-dataset-columns
-               :latest-dataset-version latest-dataset-version})))))))
+     (let [initial-dataset-version  (db.transformation/initial-dataset-version-to-update-by-dataset-id conn {:dataset-id dataset-id})
+           latest-dataset-version (db.transformation/latest-dataset-version-by-dataset-id conn {:dataset-id dataset-id})
+           imported-dataset-columns (vec (:columns initial-dataset-version))
+           importer-columns         (p/columns importer)
+
+           columns-used (columns-used-in-txs
+                         (import/importer-type (get data-source-spec "source"))
+                         initial-dataset-version
+                         latest-dataset-version)
+           imported-dataset-columns-checked (reduce (fn [c co]
+                                                      (if (contains? columns-used (get co "columnName"))
+                                                        (conj c co)
+                                                        c)) [] imported-dataset-columns)]
+       (if-let [compatible-errors (compatible-columns-error? imported-dataset-columns-checked importer-columns)]
+         (failed-update conn job-execution-id
+                        (cond-> "Column mismatch"
+                          (seq (:missed-columns compatible-errors))
+                          (str ".\n Following columns are missed in new data version: " (:missed-columns compatible-errors))
+                          (seq (:wrong-types compatible-errors))
+                          (str ".\n Following columns have changed the column type in new data version: " (:wrong-types compatible-errors))))
+         (let [table-name          (util/gen-table-name "ds")
+               imported-table-name (util/gen-table-name "imported")]
+           (postgres/create-dataset-table conn table-name importer-columns)
+           (doseq [record (map (comp postgres/coerce-to-sql import/extract-first-and-merge) (p/records importer))]
+             (jdbc/insert! conn table-name record))
+           (db.job-execution/clone-data-table conn {:from-table table-name
+                                                    :to-table   imported-table-name}
+                                              {}
+                                              {:transaction? false})
+           (let [coerce-column-fn (fn [{:keys [title id type key multipleId multipleType groupName groupId] :as column}]
+                                    (cond-> {"type" type
+                                             "title" title
+                                             "columnName" id
+                                             "groupName" groupName
+                                             "groupId" groupId
+                                             "sort" nil
+                                             "direction" nil
+                                             "hidden" false}
+                                      key           (assoc "key" (boolean key))
+                                      multipleType (assoc "multipleType" multipleType)
+                                      multipleId   (assoc "multipleId" multipleId)))]
+             {:table-name table-name :imported-table-name imported-table-name
+              :importer-columns (mapv coerce-column-fn importer-columns) :imported-dataset-columns imported-dataset-columns
+              :latest-dataset-version latest-dataset-version})))))))

 (defn update-dataset [tenant-conn caddisfly import-config error-tracker dataset-id data-source-id data-source-spec]
   (if-let [current-tx-job (db.transformation/pending-transformation-job-execution tenant-conn {:dataset-id dataset-id})]
     (lib/bad-request {:message "A running transformation still exists, please wait to update this dataset ..."})
     (let [job-execution-id (str (util/squuid))]
      (db.job-execution/insert-dataset-update-job-execution tenant-conn {:id job-execution-id
-                                                       :data-source-id data-source-id
-                                                       :dataset-id dataset-id})
+                                                                        :data-source-id data-source-id
+                                                                        :dataset-id dataset-id})
      (future
        (try
          (let [{:keys [table-name imported-table-name
                        importer-columns imported-dataset-columns
                        latest-dataset-version]}  (import-data-to-table tenant-conn
-                                                                       caddisfly
                                                                        import-config
                                                                        dataset-id
                                                                        job-execution-id


released 0.2.5.3

released 0.2.5.3

--- bigquery/project.clj
+++ bigquery/project.clj
@@ -1,4 +1,4 @@
-(defproject gclouj/bigquery "0.2.5.2"
+(defproject gclouj/bigquery "0.2.5.3"
   :description "Google Cloud BigQuery"
   :url "https://github.com/pingles/gclouj"
   :license {:name "Eclipse Public License"


Limits history to 20 items until a better solution is created

--- src/hphelper/server/live/control.clj
+++ src/hphelper/server/live/control.clj
@@ -216,7 +216,7 @@
                       )]
     (log/trace "modify-index-inner. newAccess:" newAccess)
     (-> scenMap
-        (update-in [:access] (partial cons newAccess))
+        (update-in [:access] (comp (partial take 20) (partial cons newAccess)))
         (assoc-in [:updated :access] (current-time))
         )
     )
@@ -295,7 +295,7 @@
                       )]
     (log/trace "send-access-inner. newAccess:" newAccess)
     (-> g
-        (update-in [:access] (partial cons newAccess))
+        (update-in [:access] (conj (partial take 20) (partial cons newAccess)))
         (assoc-in [:updated :access] (current-time))
         )
     )
@@ -335,13 +335,16 @@
                            update-in [zone]
                            ;; Functions takes a list of indicies, conjoins a modified index to the beginning
                            (fn [l]
-                             (conj l
-                                   (-> l
-                                       first
-                                       (update-in [index] + amount)
-                                       indicies/fuzzify-indicies
-                                       indicies/normalise-all-indicies
-                                       )
+                             ;; Limit history to 20 items for now
+                             (take 20
+                                   (conj l
+                                         (-> l
+                                             first
+                                             (update-in [index] + amount)
+                                             indicies/fuzzify-indicies
+                                             indicies/normalise-all-indicies
+                                             )
+                                         )
                                    )
                              )
                            )


dependency sort module inputs

dependency sort module inputs

--- src/clj/cljs/closure.clj
+++ src/clj/cljs/closure.clj
@@ -800,6 +800,8 @@
                   sources)
         modules (build-modules sources opts)
         ^List inputs (map (comp :closure-module second) modules)
+        _ (doseq [^JSModule input inputs]
+            (.sortInputsByDeps input closure-compiler))
         ^Result result (.compileModules closure-compiler externs inputs compiler-options)]
     (if (.success result)
       (vec
@@ -1314,7 +1316,7 @@
      :modules
      {:hello
       {:output-to "samples/hello/out/hello.js"
-       :entries '#{hello.core}}}})
+       :entries '#{cljs.reader hello.core}}}})
   )

 (defn watch


Note in code as well

Note in code as well

--- src/cljs/go/compiler.clj
+++ src/cljs/go/compiler.clj
@@ -5,6 +5,9 @@
 ;   By using this software in any fashion, you are agreeing to be bound by
 ;   the terms of this license.
 ;   You must not remove this notice, or any other, from this software.
+
+;; Go emitter. Forked from f0dcc75573a42758f8c39b57d1747a2b4967327e
+;; References to js in the public API are retained.

 (ns cljs.compiler
   (:refer-clojure :exclude [munge macroexpand-1])


Experiment with discounted case improvements, (* (first case-history) (- 1.0 sum))

--- src/clojush/evaluate.clj
+++ src/clojush/evaluate.clj
@@ -173,7 +173,8 @@
                                            ;(+ (first case-history) (- 1.0 sum))
                                            ; (mostly) arbitrating improvement ties with error
                                            ;(+ (first case-history) (* 1000 (/ 1.0 sum)))
-                                           (- 1.0 sum)
+                                           ;(- 1.0 sum)
+                                           (* (first case-history) (- 1.0 sum))
                                            )))))))
                           (= cat :reproductive-infidelity)
                           (let [g (:genome ind)]


Cap errors to CURRENTLY HARDCODED limit for computing discounted improvement

--- src/clojush/evaluate.clj
+++ src/clojush/evaluate.clj
@@ -147,7 +147,7 @@
                                         (reduce + weights))))))
                           ;
                           (= cat :discounted-case-improvements)
-                          (if (not (:print-history argmap))
+                          #_(if (not (:print-history argmap))
                             (throw
                               (Exception.
                                 ":print-history must be true for :discounted-case-improvements"))
@@ -162,6 +162,69 @@
                                              weights (iterate (partial * (- 1 improvement-discount)) 1)
                                              sum (reduce + (mapv * improvements weights))]
                                          (if (<= sum 0)
+                                           1.0E100
+                                           (/ 1.0 sum))))))))
+                          #_(if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :discounted-case-improvements"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (count (:errors ind)) 1000000))
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     (let [improvements (mapv (fn [[older-error newer-error]]
+                                                                (- older-error newer-error))
+                                                              (partition 2 1 case-history))
+                                           weights (iterate (partial * (- 1 improvement-discount)) 1)
+                                           sum (reduce + (mapv * improvements weights))]
+                                       (- 0 sum))))))
+                          #_(if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :discounted-case-improvements"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (count (:errors ind)) 1000000))
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     (if (<= (first case-history) error-threshold)
+                                       -1.0E100 ;; solved, improvement doesn't matter
+                                       (let [improvements (mapv (fn [[older-error newer-error]]
+                                                                  (- older-error newer-error))
+                                                                (partition 2 1 case-history))
+                                             weights (iterate (partial * (- 1 improvement-discount)) 1)
+                                             sum (reduce + (mapv * improvements weights))]
+                                         (- 0 sum)))))))
+                          #_(if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :discounted-case-improvements"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (count (:errors ind)) 1000000))
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     (let [improvements (mapv (fn [[older-error newer-error]]
+                                                                (- older-error newer-error))
+                                                              (partition 2 1 case-history))
+                                           weights (iterate (partial * (- 1 improvement-discount)) 1)
+                                           sum (reduce + (mapv * improvements weights))]
+                                       (if (<= sum 0)
+                                         1.0E100
+                                         (/ 1.0 sum)))))))
+                          (if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :discounted-case-improvements"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (count (:errors ind)) 1000000))
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     (if (<= (first case-history) error-threshold)
+                                       0 ;; solved, improvement doesn't matter
+                                       (let [max-error 200
+                                             cap #(if (> % max-error) max-error %)
+                                             improvements (mapv (fn [[older-error newer-error]]
+                                                                  (- older-error newer-error))
+                                                                (partition
+                                                                  2 1 (mapv cap case-history)))
+                                             weights (iterate (partial * (- 1 improvement-discount)) 1)
+                                             sum (reduce + (mapv * improvements weights))]
+                                         (if (<= sum 0)
                                            1.0E100
                                            (/ 1.0 sum))))))))
                           ;
@@ -261,4 +324,3 @@
             me (calculate-meta-errors new-ind argmap)]
         (assoc new-ind :meta-errors me)))))

-


report number of connections and build-id in the REPL prompt

fixes #420

--- sidecar/src/figwheel_sidecar/repl.clj
+++ sidecar/src/figwheel_sidecar/repl.clj
@@ -226,12 +226,26 @@
        #_(when (in-nrepl-env?)
            (throw (ex-info "Hey" {})))))))

+(defn connection-count [figwheel-server build-id]
+  (when-let [res (get (server/connection-data figwheel-server)
+                      build-id)]
+    res))
+
 (defn cljs-repl-env
   ([build figwheel-server]
    (cljs-repl-env build figwheel-server {}))
   ([build figwheel-server opts]
    (let [opts (merge (assoc (or (:compiler build) (:build-options build))
                             :warn-on-undeclared true
+                            :prompt (fn []
+                                      (let [c (connection-count figwheel-server
+                                                                (:id build))]
+                                        (print (str
+                                                (when (:id build) (str (:id build) ":"))
+                                                ana/*cljs-ns*
+                                                (when (and c (< 1 c))
+                                                  (str "!{:conn " c "}"))
+                                                "=> "))))
                             :eval #'catch-warnings-and-exceptions-eval-cljs)
                      opts)
          figwheel-server (assoc figwheel-server


Added some nice macros

Added some nice macros

from euler. Don't know by now whether they're useful.

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

--- conexp/util.clj
+++ conexp/util.clj
@@ -61,6 +61,46 @@
   [& strings]
   (throw (IllegalArgumentException. (apply str strings))))

+(defmacro with-profiled-fns [fns & body]
+  `(binding ~(vec (apply concat
+			 (for [fn (distinct fns)]
+			   `[~fn (let [orig-fn# ~fn]
+				   (fn [& args#]
+				     (prof ~(keyword fn)
+				       (apply orig-fn# args#))))])))
+     (let [data# (with-profile-data ~@body)]
+       (if (not (empty? data#))
+	 (print-summary (summarize data#))))))
+
+(defmacro memo-fn [name args & body]
+  `(let [cache# (ref {})]
+     (fn ~name ~args
+       (if (contains? @cache# ~args)
+	 (@cache# ~args)
+	 (let [rslt# (do ~@body)]
+	   (dosync
+	    (alter cache# assoc ~args rslt#))
+	   rslt#)))))
+
+(defmacro recur-sequence [& things]
+  (let [initials (vec (butlast things))
+	recur-fn (last things)]
+    `(let [initials# (lazy-seq ~initials)]
+       (concat initials#
+	       ((fn step# [n# old-vals#]
+		  (lazy-seq
+		    (let [new-val# (apply ~recur-fn n# old-vals#)]
+		      (cons new-val# (step# (inc n#) (concat (rest old-vals#) (list new-val#)))))))
+		~(count initials) initials#)))))
+
+(defmacro with-recur-seqs [seq-definitions & body]
+  (let [seq-names (take-nth 2 seq-definitions)
+	seq-defs  (take-nth 2 (rest seq-definitions))]
+    `(let [~@(reduce concat (map (fn [seq-name] `(~seq-name (ref []))) seq-names))]
+       (dosync
+	~@(map (fn [name def] `(ref-set ~name (recur-sequence ~@def))) seq-names seq-defs))
+       ~@body)))
+
 ;;; Math

 (defmacro =>
@@ -110,3 +150,4 @@
 			  (cons f (step (rest s) (conj seen key-f)))))))
 		  xs seen)))]
     (step sequence #{})))
+


Fix slight alignment issue in landing page smooth scroll effect

--- src-cljs/frontend/controllers/controls.cljs
+++ src-cljs/frontend/controllers/controls.cljs
@@ -1068,50 +1068,37 @@
   [target message {:keys [tab]} state]
   (assoc-in state state/build-header-tab-path tab))

+
+(defn scroll-home-by-offset!
+  "Scrolls down to the next section of copy on the landing page."
+  [target index]
+  (let [body (.-body js/document)
+        vh (.-height (goog.dom/getViewportSize))
+        header-size 50]
+    (.play (goog.fx.dom.Scroll. body
+                                #js [(.-scrollLeft body) (.-scrollTop body)]
+                                #js [(.-scrollLeft body) (+ (* index vh) header-size)]
+                                250))))
+
 (defmethod post-control-event! :home-scroll-1st-clicked
-  [target message _ previous-state current-state]
-  (let [body (.-body js/document)
-        vh (.-height (goog.dom/getViewportSize))]
-    (.play (goog.fx.dom.Scroll. body
-                         #js [(.-scrollLeft body) (.-scrollTop body)]
-                         #js [(.-scrollLeft body) vh]
-                         250))))
+  [target _ _ _ _]
+  (scroll-home-by-offset! target 1))

 (defmethod post-control-event! :home-scroll-2nd-clicked
-  [target message _ previous-state current-state]
-  (let [body (.-body js/document)
-        vh (.-height (goog.dom/getViewportSize))]
-    (.play (goog.fx.dom.Scroll. body
-                         #js [(.-scrollLeft body) (.-scrollTop body)]
-                         #js [(.-scrollLeft body) (* 2 vh)]
-                         250))))
+  [target _ _ _ _]
+  (scroll-home-by-offset! target 2))

 (defmethod post-control-event! :home-scroll-3rd-clicked
-  [target message _ previous-state current-state]
-  (let [body (.-body js/document)
-        vh (.-height (goog.dom/getViewportSize))]
-    (.play (goog.fx.dom.Scroll. body
-                         #js [(.-scrollLeft body) (.-scrollTop body)]
-                         #js [(.-scrollLeft body) (* 3 vh)]
-                         250))))
+  [target _ _ _ _]
+  (scroll-home-by-offset! target 3))

 (defmethod post-control-event! :home-scroll-4th-clicked
-  [target message _ previous-state current-state]
-  (let [body (.-body js/document)
-        vh (.-height (goog.dom/getViewportSize))]
-    (.play (goog.fx.dom.Scroll. body
-                         #js [(.-scrollLeft body) (.-scrollTop body)]
-                         #js [(.-scrollLeft body) (* 4 vh)]
-                         250))))
+  [target _ _ _ _]
+  (scroll-home-by-offset! target 4))

 (defmethod post-control-event! :home-scroll-5th-clicked
-  [target message _ previous-state current-state]
-  (let [body (.-body js/document)
-        vh (.-height (goog.dom/getViewportSize))]
-    (.play (goog.fx.dom.Scroll. body
-                         #js [(.-scrollLeft body) (.-scrollTop body)]
-                         #js [(.-scrollLeft body) (* 5 vh)]
-                         250))))
+  [target _ _ _ _]
+  (scroll-home-by-offset! target 5))

 (defmethod post-control-event! :home-scroll-logo-clicked
   [target message _ previous-state current-state]


fix typo

fix typo

--- src-cljs/frontend/controllers/controls.cljs
+++ src-cljs/frontend/controllers/controls.cljs
@@ -320,7 +320,7 @@
         layers (get-in state [:drawing :layers])
         snap-paths? (first (filter #(not= :layer.type/path (:layer/type %)) layers))
         layers (map (fn [layer original]
-                      (move-layer layer original {:snap-x snap-move-x :snap-y snap-move-y :x move-x :y move-y :snap-paths snap-paths?}))
+                      (move-layer layer original {:snap-x snap-move-x :snap-y snap-move-y :x move-x :y move-y :snap-paths? snap-paths?}))
                     layers
                     (get-in state [:drawing :original-layers]))]
     (assoc-in state [:drawing :layers] layers)))


Map a NodeAffinity failure reason to a preemption. (#2090)

Some preemptions can show up with this error which we want to be
mapped to :reason-slave-removed so that they can be handled with the
mea culpa machinery.

Co-authored-by: Scott Crosby <23e8f75489aff47cf2cd5a529e9a769a24e9501c@twosigma.com>

--- scheduler/src/cook/kubernetes/controller.clj
+++ scheduler/src/cook/kubernetes/controller.clj
@@ -246,6 +246,13 @@
       (= "OutOfMemory" pod-status-reason) :reason-container-limitation-memory
       (= "Error" container-terminated-reason) :reason-command-executor-failed
       (= "OOMKilled" container-terminated-reason) :reason-container-limitation-memory
+
+      ; Check the node pod for NodeAffinity.
+      (= "NodeAffinity" pod-status-reason)
+      (do
+        (log/info "In compute cluster" name ", encountered NodeAffinity pod status reason for " instance-id)
+        :reason-slave-removed)
+
       (and pod-status-message (or
                                 ; this message is given when pod exceeds pod ephemeral-storage limit
                                 (str/includes? pod-status-message "ephemeral local storage usage exceeds")


allow incremental configurations for default job constraints (#2011)

--- scheduler/src/cook/scheduler/constraints.clj
+++ scheduler/src/cook/scheduler/constraints.clj
@@ -22,6 +22,7 @@
             [cook.cached-queries :as cached-queries]
             [cook.compute-cluster :as cc]
             [cook.config :as config]
+            [cook.config-incremental :as config-incremental]
             [cook.group :as group]
             [cook.regexp-tools :as regexp-tools]
             [cook.tools :as util]
@@ -250,13 +251,26 @@
     [this _ vm-attributes _]
     (job-constraint-evaluate this _ vm-attributes)))

+(defn- resolve-incremental-default-job-constraints
+  "Resolve any incremental configurations used for default job constraint patterns"
+  [default-job-constraints {:keys [job/uuid]}]
+  (->> default-job-constraints
+       (map (fn [{:keys [constraint/pattern constraint/pattern-fallback] :as constraint}]
+              (if (string? pattern)
+                constraint
+                (let [[resolved-pattern _] (config-incremental/resolve-incremental-config uuid pattern pattern-fallback)]
+                  (-> constraint
+                    (dissoc :constraint/pattern-fallback)
+                    (assoc :constraint/pattern resolved-pattern))))))))
+
 (defn job->default-constraints
   "Returns the list of default constraints configured for the job's pool"
   [job]
-  (regexp-tools/match-based-on-pool-name
-    (config/default-job-constraints)
-    (cached-queries/job->pool-name job)
-    :default-constraints))
+  (resolve-incremental-default-job-constraints
+    (regexp-tools/match-based-on-pool-name
+      (config/default-job-constraints)
+      (cached-queries/job->pool-name job)
+      :default-constraints) job))

 (def machine-type-constraint-attributes
   #{"cpu-architecture" "node-family" "node-type"})


Fix slow query for codes.

Fix slow query for codes.

--- src/cavm/h2.clj
+++ src/cavm/h2.clj
@@ -722,12 +722,11 @@
     "SELECT `ordering`, `value`
     FROM `field`
     JOIN `code` ON `field_id` = `field`.`id`
-    WHERE `value` IN (SELECT `value2` FROM TABLE(`value2` VARCHAR = ?)) AND
-          `name` = ? AND `dataset_id` = ?"
+    WHERE  `name` = ? AND `dataset_id` = ?"
     true))

-(defn- codes-for-values [dataset-id field values]
-  (->> (codes-for-values-query (to-array values) field dataset-id)
+(defn- codes-for-values [dataset-id field]
+  (->> (codes-for-values-query field dataset-id)
        (map #(mapv % [:value :ordering]))
        (into {})))

@@ -883,7 +882,7 @@
 (defn- genomic-read-req [req]
   (let [{:keys [samples table columns]} req
         dataset-id (dataset-by-name table)
-        samp->code (codes-for-values dataset-id "sampleID" samples)
+        samp->code (codes-for-values dataset-id "sampleID")
         order (mapv (comp float-nil samp->code) samples)     ; codes in request order
         rows (rows-matching dataset-id "sampleID" order)
         rows-to-copy (->> rows


Accept the node param on session creation.

--- src/shale/resources.clj
+++ src/shale/resources.clj
@@ -107,6 +107,9 @@
                  :include-boolean-params true
                  :schema {(s/optional-key "browser_name") s/Str
                           (s/optional-key "tags") [s/Str]
+                          (s/optional-key "node") {(s/optional-key "id")    s/Str
+                                                   (s/optional-key "url")   s/Str
+                                                   (s/optional-key "tags") [s/Str]}
                           (s/optional-key "reserve_after_create") s/Bool
                           (s/optional-key "reserve") s/Bool
                           (s/optional-key "reserved") s/Bool


Group functions

Group functions


Implicit refactored.

Implicit refactored.

--- src/angelic/search/incremental/implicit.clj
+++ src/angelic/search/incremental/implicit.clj
@@ -80,6 +80,9 @@
               (:max-reward s2))
            (min-key status-val (:status s1) (:status s2))))

+(defn viable-status? [status]
+  (> (:max-reward status) is/neg-inf))
+
 (defn refinable-status? [stat min-reward]
   (and (= (:status stat) :live)
        (>= (:max-reward stat) min-reward)))
@@ -284,54 +287,64 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-(defrecord PlanNode [input-set input-status sub-output-set-pointer excluded-child-set output-constraint status-bound])
-
-(defn make-plan-node [input-set input-status sub-output-set-pointer excluded-child-set ouptut-constraint status-bound]
-  (PlanNode. input-set input-status sub-output-set-pointer excluded-child-set ouptut-constraint status-bound))
+(defrecord PlanNode [sub-output-set-pointer excluded-child-set output-constraint status-bound output-set output-status])
+
+(defn compute-plan-node-output-set [input-set sub-output-set-pointer output-constraint]
+  (state-set/constrain (state/transfer-effects input-set (:output-set sub-output-set-pointer)) output-constraint))
+
+(defn compute-plan-node-output-status [input-status sub-output-set-pointer status-bound]
+  (add-statuses input-status (min-status status-bound (osp-status sub-output-set-pointer))))
+
+(defn make-plan-node [input-set input-status sub-output-set-pointer excluded-child-set output-constraint status-bound]
+  (PlanNode. sub-output-set-pointer excluded-child-set output-constraint status-bound
+             (compute-plan-node-output-set input-set sub-output-set-pointer output-constraint)
+             (compute-plan-node-output-status input-status sub-output-set-pointer status-bound)))

 (defn make-initial-plan-node [action [input-set input-status]]
   (let [sub (get-subproblem-root-pointer input-status action (constantly is/pos-inf))]
-    (make-plan-node input-set input-status #{} {} +best-status+)))
-
+    (make-plan-node input-set input-status sub #{} {} +best-status+)))

 (defn plan-node-output-set-and-status [pn]
-  [(state-set/constrain
-    (state/transfer-effects (:input-set pn) (:output-set (:sub-output-set-pointer pn)))
-    (:output-constraint pn))
-   (add-statuses
-    (:input-status pn)
-    (min-status (:status-bound pn) (osp-status (:sub-output-set-pointer pn))))])
+  [(:output-set pn) (:output-status pn)])

 (defn viable-output-set-and-status? [[set status]]
   (and (not (state-set/empty? set))
-       (> (:max-reward status) is/neg-inf)))
+       (viable-status? status)))

 (defn refine-pn! [pn min-reward]
   (refine-osp! (:sub-output-set-pointer pn) min-reward (:excluded-child-set pn)))

-(defn split-pn-output [pn min-reward-prefix]
-  (let [{:keys [input-status sub-output-set-pointer excluded-child-set]} pn]
-    (let [split-children (split-osp sub-output-set-pointer (- min-reward-prefix (:max-reward input-status)) excluded-child-set)
+(defn split-pn-output [pn min-step-reward]
+  (let [{:keys [sub-output-set-pointer excluded-child-set]} pn]
+    (let [split-children (split-osp sub-output-set-pointer min-step-reward excluded-child-set)
           new-ecs        (into excluded-child-set split-children)
           new-status     (osp-status sub-output-set-pointer new-ecs)]
       (concat
-       (when (> (:max-reward new-status) is/neg-inf) [(assoc pn :excluded-child-set new-ecs)])
+       (when (viable-status? new-status) [(assoc pn :excluded-child-set new-ecs)])
        (for [child split-children] (assoc pn :sub-output-set-pointer child :excluded-child-set nil))))))

+(defn patch-pn-status-tuple- [pn new-input-status]
+  (let [{:keys [sub-output-set-pointer status-bound output-set]} pn
+        new-output-status (compute-plan-node-output-status new-input-status sub-output-set-pointer status-bound)]
+    (when (viable-status? new-output-status)
+      [[false output-set new-output-status] (assoc pn :output-status new-output-status)])))
+
+
 (defn update-pn-input [[set-changed? new-input-set new-input-status] pn]
-  (let [{:keys [input-set input-status sub-output-set-pointer]} pn]
-    (if (or (not set-changed?) (= new-input-set input-set))
-      (if (= new-input-status input-status)
-        pn
-        (assoc pn :input-status new-input-status))
+  (let [{:keys [sub-output-set-pointer output-constraint status-bound output-set]} pn]
+    (if set-changed?
       (let [new-osp (refine-osp-input sub-output-set-pointer new-input-set)]
         (if (identical? new-osp sub-output-set-pointer)
-          (assoc pn :input-set new-input-set :input-status new-input-status)
-          (make-plan-node new-input-set new-input-status new-osp nil
-                          (:output-set sub-output-set-pointer)
-                          (Status. (:max-reward (osp-status sub-output-set-pointer)) :blocked)))))))
+          (patch-pn-status-tuple- pn new-input-status)
+          (let [new-pn (make-plan-node new-input-set new-input-status new-osp nil
+                                (:output-set sub-output-set-pointer)
+                                (Status. (:max-reward (osp-status sub-output-set-pointer)) :blocked))
+                new-output-pair (plan-node-output-set-and-status new-pn)]
+            (when (viable-output-set-and-status? new-output-pair)
+              [(cons (not (= (:output-set new-pn) output-set)) new-output-pair) new-pn]))))
+      (patch-pn-status-tuple- pn new-input-status))))

@@ -368,16 +381,11 @@
   "Returns a plan by propagating changes starting at the last node in prefix through remaining-nodes.
    Returns nil if the plan becomes infeasible, otherwise a plan."
   [input-constraint prefix-nodes remaining-nodes set-changed?]
-  (when-let [chain
-             (map-chain
+  (when-let [[[_ out-set out-status] out-nodes]
+             (map-state
               update-pn-input
-              (cons set-changed? (plan-node-ouptut-set-and-status  (last prefix-nodes)))
-              (comp viable-output-set-and-status? next)
-              (fn [old-pn new-pn]
-                (cons ()))
-              remaining-nodes)]
-    (let [[_ out-set out-status] (last chain)]
-      (Plan. input-constraint (concat prefix-nodes (butlast chain)) out-set out-status))))
+              (cons set-changed? (plan-node-output-set-and-status (last prefix-nodes))))]
+    (Plan. input-constraint (concat prefix-nodes out-nodes) out-set out-status)))


Update deps

Update deps

--- build.boot
+++ build.boot
@@ -4,9 +4,9 @@

 (set-env!
   :dependencies  '[[tailrecursion/boot.task   "2.1.3"]
-                   [tailrecursion/hoplon      "5.7.2"]
+                   [tailrecursion/hoplon      "5.8.3"]
                    [markdown-clj              "0.9.41"]
-                   [tailrecursion/boot.ring   "0.1.0-SNAPSHOT"]
+                   [tailrecursion/boot.ring   "0.1.0"]
                    [tailrecursion/boot.notify "2.0.0-SNAPSHOT"]
                    [org.clojure/clojurescript "0.0-2202"]]
   :src-paths     #{"src"}


PLD: set class in test

PLD: set class in test


Fix clipping of autocomplete results

Fix clipping of autocomplete results

Fixes #128

--- src/braid/core/client/ui/styles/thread.cljs
+++ src/braid/core/client/ui/styles/thread.cljs
@@ -157,8 +157,7 @@
      :background "white"
      :border-radius [[vars/border-radius
                       vars/border-radius 0 0]]
-     :position "relative"
-     :overflow "hidden"}
+     :position "relative"}

     (drag-and-drop pad)
     (head pad)


optimized frequency map

optimized frequency map

--- src/clj/algorithms_clj/macro_initiation.clj
+++ src/clj/algorithms_clj/macro_initiation.clj
@@ -134,6 +134,16 @@
 ;; - And there you are in troube with C++ constexpr
 ;; - And that's the thing: 1 language to learn, not 2
 ;; --------------------------------------------------------
+
+#_(set! *warn-on-reflection* true)
+
+(defn freq-map-opt
+  "Optimized version of the frequency map"
+  [coll]
+  (let [freqs (java.util.HashMap.)]
+    (doseq [val coll]
+      (.put freqs val (inc (get freqs val 0))))
+    freqs))

 (defn freq-map
   [coll]


4clojure:: impl the partially-flatten to one level of nesting a given nested-sequence

--- src/clojure_learning/4clojure-exercises.clj
+++ src/clojure_learning/4clojure-exercises.clj
@@ -2952,7 +2952,7 @@
         (recur (butlast (rest xs)) true)
         false))))
 (palindromic-num? 1234554321) ;; true
-(palindromic-num? 1234559321) ;;
+(palindromic-num? 1234559321) ;; false

 (defn gen-palindrom-nums
   [x]
@@ -3076,23 +3076,44 @@
 ;; (= (__ '( (1 2), ((3 4), ((((5 6)))))))
 ;;    '( (1 2), (3 4), (5 6)) )

-;; first draft using mutually recursive algorithm(through trampoline)
+(every? sequential? [[1 2] [3 4]]) ;; true
+(every? sequential? [[1 2] 3])     ;; false
+
+;; and stop playing around :) -> here's the real implementation
 (defn partial-flatten
-  ([nested-xs]
-   (letfn [(linear-traverse
-              [[head & tail] acc]
-              #(if (nil? head)
-                 acc
-                 (if (sequential? head)
-                   (conj acc (depth-traverse head acc))
-                   (linear-traverse tail (conj acc head)))))
-           (depth-traverse
-            [xs acc]
-            #(if-let [some-seq (seq xs)]
-               (if (= 1 (count some-seq))
-                   (depth-traverse (last some-seq) acc)
-                   (linear-traverse some-seq acc))))]
-     (trampoline linear-traverse nested-xs []))))
-
-(seq '(1 2 3))
+  [nested-xs]
+  (letfn [(nest-level-more-than-one?
+            [xs]
+            (letfn [(nested? [xs counter]
+                       (if (sequential? xs)
+                         (nested? (first xs) (inc counter))
+                         (> counter 1)))]
+              (nested? xs 0)))
+          (flatten-to-one-level
+            [nested-xs]
+            (reduce
+               (fn [acc xs]
+                  (if (nest-level-more-than-one? xs)
+                    (lazy-cat (flatten-to-one-level xs) acc) ;; don't loose the current state
+                    (cons xs acc))) ;; will maintain one level of nesting
+               (list) nested-xs))]
+    (reverse (flatten-to-one-level nested-xs))))
+
+(partial-flatten [ [ [[:a :b]] [:foo :bar] ], [[:c :d]], [:e :f] ])
 (partial-flatten [[[[:a :b]]] [[:c :d]] [:e :f]])
+(partial-flatten '( (1 2), ((3 4), ((((5 6)))))))
+(partial-flatten  [["Do"] ["Nothing"]])
+
+
+((comp not every?) (complement sequential?) [1 2 [3 4]]) ;; true
+
+(defn nested-more-than-one? [xs]
+  (letfn [(nested?
+           [xs counter]
+           (if (sequential? xs)
+             (nested? (first xs) (inc counter))
+             (> counter 1)))]
+    (nested? xs 0)))
+
+;; demo:
+(nested-more-than-one? [[[:a :b]]]) ;; true


WIP: find mirror branches for a binary tree -> depth first search

--- src/clojure_learning/4clojure-exercises.clj
+++ src/clojure_learning/4clojure-exercises.clj
@@ -2182,25 +2182,19 @@
 ;; hence, abuse of the clojure's values and denormalize the trees into sequences, inversing
 ;; the left->to->right branches and compare the yield sequence-values.
 ;; assume first it's a valid binary tree! then create a function which validates-first the binary-tree?
+;; DEPTH-FIRST-SEARCH -> in depth
 (defn reverse-tree-rec
-  ([tree] (reverse-tree-rec tree []))
-  ([[node l-branch r-branch] rev-tree]
+  ([[node l-branch r-branch]]
      (if (nil? node)
-       rev-tree
-       (if l-branch
-         (recur l-branch (conj rev-tree [node r-branch l-branch]))
-         (recur r-branch (conj rev-tree [node r-branch l-branch]))))))
+       nil
+      [node (reverse-tree-rec r-branch) (reverse-tree-rec l-branch)])))
+

 ;;       [2 nil [3 [4 [5 nil nil] [6 nil nil]] nil]]
-;;       [2 [3 nil [4 [6 nil nil] [5 nil nil]]] nil]]
-
+;;       [2 [3 nil [4 [6 nil nil] [5 nil nil]]] nil]

 (reverse-tree-rec [2 nil [3 [4 [5 nil nil] [6 nil nil]] nil]])
-
-[[2 [3 [4 [5 nil nil] [6 nil nil]] nil] nil]
-   [3 nil [4 [5 nil nil] [6 nil nil]]]
-     [4 [6 nil nil] [5 nil nil]] [5 nil nil]]
-
+;;       [2 [3 nil [4 [6 nil nil] [5 nil nil]]] nil]

 ;; work:
 (= [1 [1 2] nil] [1 [1 2] nil]) ;; true


Hotfix.

Hotfix.

--- src/onyx_starter/core.clj
+++ src/onyx_starter/core.clj
@@ -133,13 +133,13 @@
     {:core.async/chan question-output-chan})

   (def input-calls
-    {:lifecycle/before-task inject-input-ch})
+    {:lifecycle/before-task-start inject-input-ch})

   (def loud-output-calls
-    {:lifecycle/before-task inject-loud-output-ch})
+    {:lifecycle/before-task-start inject-loud-output-ch})

   (def question-output-calls
-    {:lifecycle/before-task inject-question-output-ch})
+    {:lifecycle/before-task-start inject-question-output-ch})

   (def lifecycles
     [{:lifecycle/task :in
@@ -205,4 +205,4 @@
   (onyx.api/shutdown-peer-group peer-group)

   (onyx.api/shutdown-env env)
-)+  )


Fix condition where slightly incomplete stats could be displayed prior to completion

--- src/parbench/displays.clj
+++ src/parbench/displays.clj
@@ -130,9 +130,10 @@
   "Dumps a summary of stats to the console"
   (let [task (proxy [TimerTask] []
          (run []
-           (display-live-console-stats reqs-state)
-           (cond (rstate/complete? reqs-state)
+           (if (rstate/complete? reqs-state)
              (do
+               (display-live-console-stats reqs-state)
                (display-final-stats reqs-state)
-               (.cancel this)))))]
+               (.cancel this))
+             (display-live-console-stats reqs-state))))]
     (.scheduleAtFixedRate (Timer.) task (long 0) (long 1000))))


Adds :gen-class for uberjar

Adds :gen-class for uberjar

--- clojure/src/me/perdomo/cofre/http.clj
+++ clojure/src/me/perdomo/cofre/http.clj
@@ -5,7 +5,8 @@
             [ring.adapter.jetty :refer (run-jetty)]
             [ring.util.response :refer (response content-type not-found file-response)]
             [compojure.core :refer (defroutes GET POST)])
-  (:import java.util.UUID))
+  (:import java.util.UUID)
+  (:gen-class))

 (defn- get-file-name []
   (let [name (str (UUID/randomUUID))]


passing missing opts

passing missing opts

--- src/remote/capistrano.clj
+++ src/remote/capistrano.clj
@@ -30,7 +30,7 @@
          (when (exists? (dest-path src dst))
            (throw+ {:type ::old-code :message "Old code found in place, cleanup first"}))
          (mkdirs dst)
-         (copy src dst)
+         (copy src dst {})
          (try
            (sh- "cap" "-T" {:dir (dest-path src dst)})
            (catch Throwable e


Componentize invite teammates modal

Componentize invite teammates modal

--- src-cljs/frontend/components/pages/team.cljs
+++ src-cljs/frontend/components/pages/team.cljs
@@ -5,6 +5,7 @@
             [frontend.components.forms :as forms]
             [frontend.components.pieces.card :as card]
             [frontend.components.pieces.empty-state :as empty-state]
+            [frontend.components.pieces.form :as form]
             [frontend.components.pieces.modal :as modal]
             [frontend.components.pieces.org-picker :as org-picker]
             [frontend.components.pieces.table :as table]
@@ -77,6 +78,86 @@
        (map (fn [u] (select-keys u [:email :login :id])))
        vec))

+(defn invite-teammates-modal [{:keys [selected-org-ident app]} owner]
+  (reify
+    om/IInitState
+    (init-state [_]
+      {:invite-teammates? true})
+    om/IDidMount
+    (did-mount [_]
+      (api/get-org-members (om/get-shared owner [:comms :api]) (:name (get-in app selected-org-ident))))
+
+    om/IRenderState
+    (render-state [_ {:keys []}]
+      (when (om/get-state owner :invite-teammates?)
+        (let [invite-data (:invite-data app)
+            users (remove :circle_member (:github-users invite-data))
+            opts {:vcs_type (:vcs_type invite-data)
+                  :org-name (:org invite-data)}
+            count-users (count users)
+            count-with-email (count (filter #(utils/valid-email? (:email %)) users))
+            count-selected (count (filter #(:checked %) users))]
+        (html
+          (component
+            (modal/modal-dialog {:title "Invite Teammates"
+                                 :body
+                                 [:div
+                                  [:div
+                                   "These are the people who are not using CircleCI yet:"
+                                   [:br]
+                                   [:span [:b count-with-email] " of " [:b count-users] " users have emails, " [:b count-selected] " are selected"]]
+                                  [:div.constraining-modal
+                                   (om/build table/table {:rows users
+                                                          :key-fn :login
+                                                          :columns [{:header "Username"
+                                                                     :cell-fn (fn [user-map]
+                                                                                [:span
+                                                                                [:img.invite-gravatar {:src (gh-utils/make-avatar-url user-map :size 50)}]
+                                                                                (str "  " (:login user-map))])}
+                                                                    {:header "Email"
+                                                                     :cell-fn (fn [user-map]
+                                                                                (let [{:keys [avatar_url email login index checked]} user-map
+                                                                                id-name (str login "-email")
+                                                                                error? (and (or checked (not (empty? email)))
+                                                                                (not (utils/valid-email? email)))]
+                                                                                (om/build form/text-field {:on-change (fn [event]
+                                                                                (utils/edit-input owner (conj (state/invite-github-user-path index) :email) event)
+                                                                                (when (and (not= checked true)
+                                                                                (not (empty? email)))
+                                                                                (utils/toggle-input owner (conj (state/invite-github-user-path index) :checked) nil)))
+                                                                                :value email
+                                                                                :size :medium
+                                                                                :validation-error (when (and (or checked (not (empty? email)))
+                                                                                (not (utils/valid-email? email)))
+                                                                                (str email "is not a valid email"))})))}
+                                                                    {:type :shrink
+                                                                     :cell-fn (fn [user-map]
+                                                                                (let [{:keys [email login index checked]} user-map
+                                                                                id-name (str login "-checkbox")
+                                                                                email-valid? (utils/valid-email? email)]
+                                                                                [:input {:type "checkbox"
+                                                                                :id id-name
+                                                                                :disabled (and (not (utils/valid-email? email))
+                                                                                (not (empty? email)))
+                                                                                :checked checked
+                                                                                :on-click #(utils/toggle-input owner (conj (state/invite-github-user-path index) :checked) %)}]))}]
+                                                          :striped? true
+                                                          :fixed-header? true})]]
+                                 :actions [(button/button {:on-click #(om/set-state! owner :invite-teammates? false)} "Cancel")
+                                           (forms/managed-button
+                                             [:button.btn.btn-success {:data-success-text "Sent"
+                                                                       :on-click #(.log js/console "Invitees: " (seq (invitees users)))
+                                                                       ;; :on-click #(raise! owner [:invited-github-users (merge {:invitees (invitees users)
+                                                                       ;;                                                         :vcs_type (:vcs_type opts)}
+                                                                       ;;                                                        (if (:project-name opts)
+                                                                       ;;                                                          {:project-name (:project-name opts)}
+                                                                       ;;                                                          {:org-name (:org-name opts)}))])
+                                                                       :disabled (or (empty? (invitees users))
+                                                                                (not (every? #(utils/valid-email? (:email %)) (invitees users))))}
+                                              "Send Invites "
+                                              [:i.fa.fa-envelope-o]])]
+                                 :close-fn #(om/set-state! owner :invite-teammates? false)}))))))))
+
 (defn- main-content [app owner]
   (reify
     om/IInitState
@@ -99,9 +180,11 @@
         (when (not= (:selected-org-ident (om/get-render-state owner))
                     selected-org-ident)
           (api/get-org-settings-normalized name vcs-type api-chan))
+        ;; TODO -ac This is doing the thing, need to make it into a component
+        ;; Fire on WillMount
         (when (and selected-org
                    invite-teammates?)
-          (api/get-org-members api-chan (:name selected-org)))))
+          #_(api/get-org-members api-chan (:name selected-org)))))

     om/IRenderState
     (render-state [_ {:keys [selected-org-ident invite-teammates?]}]
@@ -133,86 +216,19 @@
                                    "bitbucket" [:i.fa.fa-bitbucket]
                                    nil)])
                    :action  (html
-                                (let [invite-data (:invite-data app)
-                                      users (remove :circle_member (:github-users invite-data))
-                                      opts {:vcs_type (:vcs_type invite-data)
-                                            :org-name (:org invite-data)}
-                                      count-users (count users)
-                                      count-with-email (count (filter #(utils/valid-email? (:email %)) users))
-                                      count-selected (count (filter #(:checked %) users))]
-                                    [:div (when (:invite-teammates? (om/get-render-state owner))
-                                              (component
-                                                  (modal/modal-dialog {:title "Invite Teammates"
-                                                                       :body
-                                                                       [:div
-                                                                        [:div
-                                                                         "These are the people who are not using CircleCI yet:"
-                                                                         [:br]
-                                                                         [:span [:b count-with-email] " of " [:b count-users] " users have emails, " [:b count-selected] " are selected"]]
-                                                                        [:div.constraining-modal
-                                                                         (om/build table/table {:rows users
-                                                                                :key-fn :login
-                                                                                :columns [{:header "Username"
-                                                                                :cell-fn (fn [user-map]
-                                                                                [:span
-                                                                                [:img.invite-gravatar {:src (gh-utils/make-avatar-url user-map :size 50)}]
-                                                                                (str "  " (:login user-map))])}
-                                                                                {:header "Email"
-                                                                                :cell-fn (fn [user-map]
-                                                                                (let [{:keys [avatar_url email login index checked]} user-map
-                                                                                id-name (str login "-email")
-                                                                                error? (and (or checked (not (empty? email)))
-                                                                                (not (utils/valid-email? email)))]
-                                                                                [:span
-                                                                                [:input {:type "email"
-                                                                                :on-change (fn [event]
-                                                                                (utils/edit-input owner (conj (state/invite-github-user-path index) :email) event)
-                                                                                (when (and (not= checked true)
-                                                                                (not (empty? email)))
-                                                                                (utils/toggle-input owner (conj (state/invite-github-user-path index) :checked) nil)))
-                                                                                :required? true
-                                                                                :id id-name
-                                                                                :value email
-                                                                                ;; :size "small"
-                                                                                ;; :long? true
-                                                                                ;; :error? error?
-                                                                                :defaultValue email}]]))}
-                                                                                {:type :shrink
-                                                                                :cell-fn (fn [user-map]
-                                                                                (let [{:keys [email login index checked]} user-map
-                                                                                id-name (str login "-checkbox")
-                                                                                email-valid? (utils/valid-email? email)]
-                                                                                [:input {:type "checkbox"
-                                                                                :id id-name
-                                                                                :disabled? (and (not (utils/valid-email? email))
-                                                                                (not (empty? email)))
-                                                                                :checked? checked
-                                                                                :on-click #(utils/toggle-input owner (conj (state/invite-github-user-path index) :checked) %)}]))}]
-                                                                                :striped? true
-                                                                                :fixed-header? true})]]
-                                                                       :actions [(button/button {:on-click #(om/set-state! owner :invite-teammates? false)} "Cancel")
-                                                                                (forms/managed-button
-                                                                                [:button.btn.btn-success {:data-success-text "Sent"
-                                                                                :on-click #(raise! owner [:invited-github-users (merge {:invitees (invitees users)
-                                                                                :vcs_type (:vcs_type opts)}
-                                                                                (if (:project-name opts)
-                                                                                {:project-name (:project-name opts)}
-                                                                                {:org-name (:org-name opts)}))])
-                                                                                :disabled (or (empty? (invitees users))
-                                                                                (not (every? #(utils/valid-email? (:email %)) (invitees users))))}
-                                                                                "Send Invites "
-                                                                                [:i.fa.fa-envelope-o]])]
-                                                                       :close-fn #(om/set-state! owner :invite-teammates? false)})))
-                                     (button/button
-                                         {:disabled? (nil? (:users selected-org))
-                                          :primary? true
-                                          :on-click (fn []
-                                                        ;; TODO -ac Add tracking back in before merging
-                                                        #_((om/get-shared owner :track-event)
-                                                           {:event-type :invite-teammates-clicked
-                                                            :properties {:view :team}})
-                                                        (om/set-state! owner :invite-teammates? (not (:invite-teammates? (om/get-render-state owner)))))}
-                                         "Invite Teammates")]))}
+                              [:div (when (:invite-teammates? (om/get-render-state owner))
+                                      (om/build invite-teammates-modal {:selected-org-ident selected-org-ident
+                                                                        :app app}))
+                               (button/button
+                                 {:disabled? (nil? (:users selected-org))
+                                  :primary? true
+                                  :on-click (fn []
+                                              ;; TODO -ac Add tracking back in before merging
+                                              #_((om/get-shared owner :track-event)
+                                                 {:event-type :invite-teammates-clicked
+                                                  :properties {:view :team}})
+                                              (om/set-state! owner :invite-teammates? (not (:invite-teammates? (om/get-render-state owner)))))}
+                                 "Invite Teammates")])}
                 (if-let [users (:users selected-org)]
                   (table (add-follow-counts users (:projects selected-org)))
                   (html [:div.loading-spinner common/spinner])))


[#200] Removes the possibility of passing nil as parameter

--- api/src/clojure/org/akvo/flow_api/datastore/survey.clj
+++ api/src/clojure/org/akvo/flow_api/datastore/survey.clj
@@ -18,9 +18,7 @@
 (defn list-by-ids
   [user-id survey-ids]
   (let [survey-dao (SurveyDAO.)
-        all-surveys (if survey-ids
-                      (.listByKeys survey-dao (ArrayUtils/toObject (long-array survey-ids)))
-                      (.listAll survey-dao))]
+        all-surveys (.listByKeys survey-dao (ArrayUtils/toObject (long-array survey-ids)))]
     (.filterByUserAuthorizationObjectId survey-dao all-surveys user-id)))

 (defn list-ids [user-id]


Use loading run row when run is missing

Use loading run row when run is missing

--- src-cljs/frontend/components/pages/workflow.cljs
+++ src-cljs/frontend/components/pages/workflow.cljs
@@ -36,7 +36,7 @@
            [:div
             [:.page-info "Showing " [:span.run-numbers (inc offset) "–" (+ offset (count edges))]]
             (card/collection
-             (map #(when % (run-row/run-row (:edge/node %))) edges))
+             (map #(if % (run-row/run-row (:edge/node %)) (run-row/loading-run-row)) edges))
             [:.list-pager
              (a-or-span (pos? offset)
                         prev-page-href


make browser-settings use the default

make browser-settings use the default

--- frontend/browser_settings.cljs
+++ frontend/browser_settings.cljs
@@ -6,7 +6,7 @@
 (def browser-settings-key "circle-browser-settings")

 (defn restore-browser-settings! [localstorage-imp state-atom]
-  (swap! state-atom assoc-in state/browser-settings-path (localstorage/read localstorage-imp browser-settings-key)))
+  (swap! state-atom update-in state/browser-settings-path merge (localstorage/read localstorage-imp browser-settings-key)))

 (defn browser-settings-watcher [localstorage-imp key ref old-data new-data]
   (when (not (identical? (get-in old-data state/browser-settings-path)


dedup build messages

dedup build messages

--- frontend/components/build.cljs
+++ frontend/components/build.cljs
@@ -107,7 +107,7 @@
              controls-ch (om/get-shared owner [:comms :controls])]
          [:div.row-fluid
           [:div.offset1.span10
-           [:div (common/messages (:messages build))]
+           [:div (common/messages (set (:messages build)))]
            (when (empty? (:messages build))
              [:div (report-error build controls-ch)])


Add convenient reset-and-test dev function

--- dev/src/dev.clj
+++ dev/src/dev.clj
@@ -74,6 +74,10 @@
 (defn test-all []
   (clojure.test/run-all-tests #"(yada|phonebook).*test$"))

+(defn reset-and-test []
+  (reset)
+  (time (test-all)))
+
 (defn routes []
   (-> system :docsite-router :routes))


Exercise 1.21

Exercise 1.21

--- src/sicp/chapter1/2_6.clj
+++ src/sicp/chapter1/2_6.clj
@@ -40,7 +40,12 @@
     :else false))

 ;; Exercise 1.21
-;; TODO
+(smallest-divisor 199)
+;; => 199
+(smallest-divisor 1999)
+;; => 1999
+(smallest-divisor 19999)
+;; => 7

 ;; Exercise 1.22
 ;; TODO


code cleanup

code cleanup

--- src/single_track/core.clj
+++ src/single_track/core.clj
@@ -1,19 +1,22 @@
 (ns single-track.core
-  (:require [clojure.java.io :as io]))
+  (:require [clojure.java.io :as io])
+  (:import [java.io File]))

-(defn file-filter [file]
+(set! *warn-on-reflection* true)
+
+(defn visible-files [^File file]
   (not= \. (-> file .getName first)))

-(defn my-file-seq
-  "A tree seq on java.io.Files"
+(defn filtered-file-seq
+  "A filtered tree seq on java.io.Files"
+  [dir pred]
+  (tree-seq
+    (fn [^File f] (. f (isDirectory)))
+    (fn [^File d] (filter pred (. d (listFiles))))
+    dir))
+
+(defn -main
+  ([] (-main "."))
   ([dir]
-    (my-file-seq dir (fn [_] true)))
-  ([dir pred]
-    (tree-seq
-     (fn [^java.io.File f] (. f (isDirectory)))
-     (fn [^java.io.File d] (filter pred (seq (. d (listFiles)))))
-     dir)))
-
-(defn -main [dir]
-  (doseq [f (my-file-seq (io/file dir) file-filter)]
-    (println f)))
+   (doseq [f (filtered-file-seq (io/file dir) visible-files)]
+     (println (.getName f)))))


Convert TTLs to seconds before passing them to garbage collect functions

There's no need to do this every time. May as well simplify those
functions a bit.

--- src/com/puppetlabs/puppetdb/cli/services.clj
+++ src/com/puppetlabs/puppetdb/cli/services.clj
@@ -101,9 +101,9 @@
   (try
     (pl-utils/demarcate
       (format "sweep of stale nodes (threshold: %s)"
-              (format-period (secs node-ttl-seconds)))
+              (format-period node-ttl-seconds))
       (with-transacted-connection db
-        (doseq [node (scf-store/stale-nodes (ago (secs node-ttl-seconds)))]
+        (doseq [node (scf-store/stale-nodes (ago node-ttl-seconds))]
           (send-command! "deactivate node" 1 (json/generate-string node)))))
     (catch Exception e
       (log/error e "Error while deactivating stale nodes"))))
@@ -115,9 +115,9 @@
   (try
     (pl-utils/demarcate
       (format "purge deactivated nodes (threshold: %s)"
-              (format-period (secs node-purge-ttl-seconds)))
+              (format-period node-purge-ttl-seconds))
       (with-transacted-connection db
-        (scf-store/purge-deactivated-nodes! (ago (secs node-purge-ttl-seconds)))))
+        (scf-store/purge-deactivated-nodes! (ago node-purge-ttl-seconds))))
     (catch Exception e
       (log/error e "Error while purging deactivated nodes"))))

@@ -127,9 +127,9 @@
   (try
     (pl-utils/demarcate
       (format "sweep of stale reports (threshold: %s)"
-              (format-period (secs report-ttl-seconds)))
+              (format-period report-ttl-seconds))
       (with-transacted-connection db
-        (scf-store/delete-reports-older-than! (ago (secs report-ttl-seconds)))))
+        (scf-store/delete-reports-older-than! (ago report-ttl-seconds))))
     (catch Exception e
       (log/error e "Error while sweeping reports"))))

@@ -431,13 +431,13 @@
       (interspaced db-gc-millis #(garbage-collect! db) job-pool)

       (when (pos? node-ttl-seconds)
-        (interspaced db-gc-millis #(auto-deactivate-nodes! db node-ttl-seconds) job-pool :initial-delay (* db-gc-millis 1/4)))
+        (interspaced db-gc-millis #(auto-deactivate-nodes! db (secs node-ttl-seconds)) job-pool :initial-delay (* db-gc-millis 1/4)))

       (when (pos? node-purge-ttl-seconds)
-        (interspaced db-gc-millis #(purge-nodes! db node-purge-ttl-seconds) job-pool :initial-delay (* db-gc-millis 2/4)))
+        (interspaced db-gc-millis #(purge-nodes! db (secs node-purge-ttl-seconds)) job-pool :initial-delay (* db-gc-millis 2/4)))

       (when (pos? report-ttl-seconds)
-            (interspaced db-gc-millis #(sweep-reports! db report-ttl-seconds) job-pool :initial-delay (* db-gc-millis 3/4)))
+            (interspaced db-gc-millis #(sweep-reports! db (secs report-ttl-seconds)) job-pool :initial-delay (* db-gc-millis 3/4)))

       ;; Start debug REPL if necessary
       (let [{:keys [enabled type host port] :or {type "nrepl" host "localhost"}} (:repl config)]


Add more examples (continue)

Add more examples (continue)

--- src/clojure/clojure_walkthrough/cjia/ch08_xx.clj
+++ src/clojure/clojure_walkthrough/cjia/ch08_xx.clj
@@ -393,3 +393,51 @@
     (case command
       :name (name class-name)
       :new (new-object klass))))
+
+(defmacro defclass [class-name & specs]
+  (let [fns (or (method-specs specs) {})]
+    `(def ~class-name (new-class '~class-name ~fns))))
+
+(defclass Person
+  (method age [] (* 2 10))
+  (method greet [visitor] (str "Hello there, " visitor)))
+
+;; Invoking methods
+(defn find-method [method-name instance-methods]
+  (instance-methods method-name))
+
+(defn new-class [class-name methods]
+  (fn klass [command & args]
+    (case command
+      :name (name class-name)
+      :new (new-object klass)
+      :method (let [[method-name] args]
+                (find-method method-name methods)))))
+
+(Person :method :age) ; #function[clojure-walkthrough.cjia.ch08-xx/age--20738]
+
+((Person :method :age)) ; 20
+
+(defn new-object [klass]
+  (let [state (ref {})]
+    (fn [command & args]
+      (case command
+        :class klass
+        :class-name (klass :name)
+        :set! (let [[k v] args]
+                (dosync (alter state assoc k v))
+                nil)
+        :get (let [[k v] args]
+               (@state key))
+        (if-let [method (klass :method command)]
+          (apply method args)
+          (throw (RuntimeException.
+                  (str "Unable to respond to " command))))))))
+
+(def shelly (Person :new))
+
+(shelly :age) ; 20
+
+(shelly :greet "Nancy") ;; "Hello there, Nancy"
+
+;; Referring to this (TBC)


asserting machine existence in provided values

--- src/celestial/persistency/systems.clj
+++ src/celestial/persistency/systems.clj
@@ -190,7 +190,8 @@

 (defn templatize
   "Create a system from a template"
-   [name {:keys [env] :as provided}]
+   [name {:keys [env machine] :as provided}]
+   {:pre [machine (machine :hostname) (machine :domain)]}
    (let [{:keys [defaults] :as t} (get-template! name)]
      (add-system (merge-with merge t (defaults env) provided))))


Remove unused refs

Remove unused refs

--- src/clj/cglossa/search/cwb/shared.clj
+++ src/clj/cglossa/search/cwb/shared.clj
@@ -2,8 +2,7 @@
   "Shared code for all types of corpora encoded with the IMS Open Corpus Workbench."
   (:require [clojure.string :as str]
             [me.raynes.fs :as fs]
-            [me.raynes.conch.low-level :as sh]
-            [cglossa.search.core :refer [run-queries transform-results]]))
+            [me.raynes.conch.low-level :as sh]))

 (defn cwb-corpus-name [corpus queries]
   (let [uc-code (str/upper-case (:code corpus))]


Run the cleanup job once every hour.

Run the cleanup job once every hour.

--- src/cmr/metadata_db/services/jobs.clj
+++ src/cmr/metadata_db/services/jobs.clj
@@ -40,6 +40,6 @@
                   (t/with-identity (t/key "triggers.1"))
                   (t/start-now)
                   (t/with-schedule (schedule
-                                     (with-interval-in-seconds 10))))]
+                                     (with-interval-in-seconds 3600))))]
     (qs/schedule job trigger))
   (info "Expired concepts cleanup job started."))


Small refactoring of example.clj for anagram

`frequencies` is a core function that will make the word into a
map of letter frequencies, e.g.:

(canonicalize "hello")
;=> {\h 1, \e 1, \l 2, \o 1}

`frequencies` seems a bit clearer than the `split #""` then `sort`.

(Interestingly, the `split` is not necessary even if `sort`ing, since
Clojure will represent `word` as an Object array of Characters,
then return it sorted. `frequencies` probably ends up slower than `sort`
over large strings due to the incremental object allocation, but also
is likely _faster_ than `split` ... `sort`.)

--- assignments/clojure/anagram/example.clj
+++ assignments/clojure/anagram/example.clj
@@ -5,8 +5,7 @@
   [word]
   (-> word
       lower-case
-      (split #"")
-      sort))
+      frequencies))

 (defn anagrams-for
   [word candidates]


Rewrite generator so it can bail out if it gets stuck

--- src/staplo/generator.cljs
+++ src/staplo/generator.cljs
@@ -39,45 +39,52 @@
 (defn generate-start [type length]
   ((generators type) length))

-(defn generate-op [operations operation-names text op-history text-history]
-  (letfn [(rand-op []
-            (let [op-name (rand-nth operation-names)]
-              {:op-name op-name
-               :op (operations op-name)}))]
-    (loop [candidate-op (rand-op)]
-      (let [{op :op} candidate-op]
-        (if (and
-              ((:precondition op) text op-history)
-              ((:generator-precondition op) text op-history)
-              (not (contains? text-history ((:operation op) text))))
-          candidate-op
-          (recur (rand-op)))))))
+(defn generate-op-try [op-seq state op-history state-history]
+  (loop [op (rand-nth op-seq)
+         tries-remaining 20]
+    (cond
+      (zero? tries-remaining) nil
+      (and
+        ((:precondition op) state op-history)
+        ((:generator-precondition op) state op-history)
+        (not (contains? state-history ((:operation op) state))))
+      op
+      :else (recur (rand-nth op-seq) (dec tries-remaining)))))

-(defn generate-ops [start-text steps operations-config]
-  (letfn [
-    (step [{text :text op-history :op-history text-history :text-history}]
-      (let [op-sort (:type operations-config)
-            {op-name :op-name op :op} (generate-op
-                                        (operations/operations op-sort)
-                                        (:list operations-config)
-                                        text
-                                        op-history
-                                        text-history)
-            result ((:operation op) text)]
-        {:text result
-         :op-history (conj op-history op-name)
-         :text-history (conj text-history result)}))]
-    (accumulate
-      step
-      {:text start-text :op-history '() :text-history #{start-text}}
-      steps)))
+(defn generate-ops-try [start-state step-count op-seq]
+  (loop [state start-state
+         remaining step-count
+         op-history '()
+         state-history (list start-state)]
+    (let [op (generate-op-try op-seq state op-history state-history)]
+      (cond
+        (nil? op) nil
+        (zero? remaining) {:state state
+                           :op-history op-history
+                           :state-history state-history}
+        :else (let [new-state ((:operation op) state)]
+                (recur
+                  new-state
+                  (dec remaining)
+                  (conj op-history (:name op))
+                  (conj state-history new-state)))))))

-(defn generate-candidate [config]
-  (let [start (generate-start (:type (:operations config)) (:start-length config))
-        steps (rand-interval (:steps config))
-        target ((generate-ops start steps (:operations config)) :text)]
+(defn generate-ops [start-state step-count level-op-config op-config]
+  (let [op-map (op-config (:type level-op-config))
+        op-names (:list level-op-config)
+        op-seq (for [name op-names]
+                 (assoc (op-map name) :name name))]
+    (loop [ops nil]
+      (if (nil? ops)
+        (recur (generate-ops-try start-state step-count op-seq))
+        ops))))
+
+(defn generate-candidate [level-config]
+  (let [start (generate-start (:type (:operations level-config)) (:start-length level-config))
+        steps (rand-interval (:steps level-config))
+        generated (generate-ops start steps (:operations level-config) operations/operations)]
     {:start start
-     :target target
+     :target (:state generated)
      :steps steps}))

 (defn generate-challenge [config]


RP + CW | 44 | pretty logging for admin registration at startup

--- src/stonecutter/admin.clj
+++ src/stonecutter/admin.clj
@@ -1,6 +1,7 @@
 (ns stonecutter.admin
   (:require [stonecutter.config :as config]
             [stonecutter.validation :as v]
+            [clojure.tools.logging :as log]
             [stonecutter.db.user :as u]))

 (defn create-admin-user [config-m user-store]
@@ -10,8 +11,8 @@
         errors (v/validate-registration-email admin-login duplication-checker)]
     (when (and admin-login admin-password)
       (case errors
-        :duplicate nil
-        :invalid (throw Exception "exceptional")
+        :duplicate (log/info "Admin account already exists.")
+        :invalid (throw (Exception. "INVALID ADMIN DETAILS - please check that admin login is in the correct format"))
         nil (u/store-admin!
               user-store
               admin-login


port back to 57110 with fallback at 57120

--- src/temperaments/core.clj
+++ src/temperaments/core.clj
@@ -62,7 +62,10 @@

 (if (not (o/server-connected?))
   ;(o/boot-external-server 57110)
-  (o/connect-external-server 57120)
+  (o/connect-external-server 57110)
+)
+(if (not (o/server-connected?))
+  (o/connect-external-server 57121)
 )

 (require '[overtone.inst.synth :as syn])
@@ -655,6 +658,7 @@
                                            (transform-necklace
                                                    (transpose-names (get-e-val e))
                                                    id :pitches))])]
+    (value! reflect-button 0)
     (horizontal-panel :items [reflect-button translabel transbox])))

 ;;;;;;;;;;;;;; transforms end
@@ -855,6 +859,8 @@
                                      :listen [:action melody-chooser])
                            ])))

+(config! control-frame :on-close :exit)
+
 (defn -main [& args]
   (-> control-frame pack! show!)
   ;;(make-melody-canvas "test-canvas")


fix hunt-down-source for comments case

fix hunt-down-source for comments case

--- src/com/billpiel/sayid/util/other.clj
+++ src/com/billpiel/sayid/util/other.clj
@@ -234,8 +234,8 @@
                       (->> file
                            slurp
                            clojure.string/split-lines
-                           (drop (- line 1))
-                           clojure.string/join)
+                           (drop (dec line))
+                           (clojure.string/join "\n"))
                       "nil")))))

 (defmacro src-in-meta


Narrow 0mq port spec

Narrow 0mq port spec

--- src/com/frereth/common/zmq_socket.clj
+++ src/com/frereth/common/zmq_socket.clj
@@ -22,7 +22,7 @@
                                           ::thread-count]))

 (s/def ::client-keys :cljeromq.curve/key-pair)
-(s/def ::port int?)
+(s/def ::port (s/and nat-int? #(< % 65536)))
 (s/def ::server-key :cljeromq.common/byte-array-type)
 (s/def ::sock-type :cljeromq.common/socket-type)
 (s/def ::socket-description (s/keys :opt-un [::client-keys


+test

+test

--- test/babel/test/fr.cljc
+++ test/babel/test/fr.cljc
@@ -396,11 +396,16 @@
                             (unifyc unify-with entry))
                           (lookup lex)))
                   replace-patterns)))
-(deftest foo
-  (let [the-foo (try-hard-to
-                 #(generate
-                   {:synsem {:sem {:subj {:pred :lui}
-                                   :pred :have-fun
-                                   :tense :present}}}))]
-    (is (not (empty? the-foo)))))
-
+(deftest have-fun
+  (let [have-fun-expression
+        (generate
+         {:synsem {:sem {:subj {:pred :lui}
+                         :pred :have-fun
+                         :tense :present}}})]
+    (is (not (empty? have-fun-expression)))
+    (is (= (fo have-fun-expression)
+           "il l'amuse"))))
+
+
+
+


fix(launch): Remove interferences with Leiningen prep-tasks

Leininge prep-tasks (AOT compilation, javac) start new processes, including
code/configuration added by CCW, causing problems:

- would start ccw.server while AOT compiling (and preventing the shutdown
  of the compilation JVM because futures where created)
- etc.

--- ccw.core/lein/ccw/leiningen/main.clj
+++ ccw.core/lein/ccw/leiningen/main.clj
@@ -5,7 +5,22 @@
    'hooks (not necessarily via robert.hook) even before leiningen.core.main/-main
    has been called."
   (:require [leiningen.core.main]
-            [leiningen.core.eval]))
+            [leiningen.core.eval]
+            [leiningen.compile]))
+
+(def ^:dynamic *in-prep* false)
+
+(alter-var-root
+  #'leiningen.core.eval/run-prep-tasks
+  (fn [old-fn]
+    (fn [project & rest]
+      (binding [*in-prep* true]
+        ;; removing :injections during prep-tasks because
+        ;; it can only cause harm (e.g. start user code launching
+        ;; futures - thus preventing the compilation task to finish, etc.)
+        (let [project (dissoc project :injections)]
+          (apply old-fn project rest))))))
+

 (def original-eval-in-subprocess
   (get-method leiningen.core.eval/eval-in :subprocess))
@@ -35,21 +50,17 @@
            in# (.getInputStream socket#)]
        (try
          (.read in#)
-         (finally (System/exit ~lost-parent-socket-conn-errno))))))
-
+         (finally
+           (println "Lost parent connection" ~port)
+           (System/exit ~lost-parent-socket-conn-errno))))))
+
 (defmethod leiningen.core.eval/eval-in :subprocess
   [project form]
-  ;(println "Leiningen (not project) JVM java.io.tmpdir:" (System/getProperty "java.io.tmpdir"))
-  ;(println "form:")
-  ;(pr form)
-  ;(println "Project Shell Command:" (leiningen.core.eval/shell-command project form))
-  ;(println "all Leiningen (not project) JVM envs:" (System/getenv))
-  ;(println " all Leiningen (not project) JVM properties:" (System/getProperties))
-  (let [port (start-socket-server)
-        enhanced-form (list 'do (socket-client-form port) form)]
-    (original-eval-in-subprocess project enhanced-form)))
-
-
+  (if *in-prep* ;; prep tasks (compilation, etc. are finished)
+    (original-eval-in-subprocess project form)
+    (let [port (start-socket-server)
+          enhanced-form (list 'do (socket-client-form port) form)]
+      (original-eval-in-subprocess project enhanced-form))))

 (defn -main [& raw-args]
   (apply leiningen.core.main/-main raw-args))


Added teams creation and form validation. Redirects to stats on success.

--- src/fist/routes/home.clj
+++ src/fist/routes/home.clj
@@ -8,7 +8,9 @@
             [clj-time.coerce :as time-coerce]
             [formative.core :as f]
             [formative.parse :as fp]
-            [hiccup.page :as page]))
+            [hiccup.page :as page]
+            [korma.db :as korma-db]
+            [noir.response :as response]))

 (def match-form
   {:fields [{:name :home_player_id :label "Player" :type :select :datatype :int :class "form-control" :id "homePlayer"
@@ -20,7 +22,8 @@
              :options (fn [] (map #(vector (:id %) (:name %)) (db/get-players))) :placeholder ""}
             {:name :away_team_name :label "Team" :type :text :datatype :str :class "form-control" :id "awayTeam"}
             {:name :away_score :label "Score" :type :select :datatype :int :class "form-control" :id "awayScore"
-             :options (range 10) :placeholder ""}]})
+             :options (range 10) :placeholder ""}]
+   :validations [[:required [:home_player_id :home_team_name :home_score :away_player_id :away_team_name :away_score]]]})

 (defn home-page []
   (layout/render
@@ -31,16 +34,22 @@
                  :away-team-input (util/render-form-field :away_team_name match-form)
                  :away-score-select (util/render-form-field :away_score match-form)}))

-(defn create-match [match]
-  (let [home-team (db/get-team-by-name (:home_team_name match))
-        away-team (db/get-team-by-name (:away_team_name match))]
-    (db/create-match {:home_player_id (Integer/parseInt (:home_player_id match))
-                      :home_team_id (:id home-team)
-                      :home_score (Integer/parseInt (:home_score match))
-                      :away_player_id (Integer/parseInt (:away_player_id match))
-                      :away_team_id (:id away-team)
-                      :away_score (Integer/parseInt (:away_score match))
-                      :occured_at (time-coerce/to-sql-time (time/now))})))
+(defn create-match [params]
+  (korma-db/transaction
+    (let [match (fp/parse-params match-form params)
+          team1 (db/get-team-by-name (:home_team_name match))
+          home-team-id (if-not team1 (:id (db/create-team {:name (:home_team_name match)})) (:id team1))
+          team2 (db/get-team-by-name (:away_team_name match))
+          away-team-id (if-not team2 (:id (db/create-team {:name (:away_team_name match)})) (:id team2))
+          ]
+      (db/create-match {:home_player_id (:home_player_id match)
+                        :home_team_id home-team-id
+                        :home_score (:home_score match)
+                        :away_player_id (:away_player_id match)
+                        :away_team_id away-team-id
+                        :away_score (:away_score match)
+                        :occured_at (time-coerce/to-sql-time (time/now))})))
+  (response/redirect "/stats"))

 (defn stats-page []
@@ -48,6 +57,6 @@

 (defroutes home-routes
   (GET "/" [] (home-page))
-  (POST "/" {match :params} (create-match match))
+  (POST "/" {params :params} (create-match params))
   (GET "/stats" [] (stats-page)))


Fixed import decl.

Fixed import decl.

--- src/fx_clj/core/pset.clj
+++ src/fx_clj/core/pset.clj
@@ -12,7 +12,8 @@
            (javafx.application Platform)
            [clojure.lang IRef]
            [fx_clj.binding ReactiveRefObservable RefObservable]
-           (java.beans PropertyDescriptor)))
+           (java.beans PropertyDescriptor)
+           [freactive IReactiveRef]))

 (defn- get-generic-interfaces [cls]
   (loop [ifaces #{}


output float numbers by default

output float numbers by default

--- src/gamma/emit/emit.cljs
+++ src/gamma/emit/emit.cljs
@@ -35,7 +35,13 @@

 (defmulti emit emit-dispatch)

-(defmethod emit :primitive [db x] (str x))
+(defmethod emit :primitive [db x]
+  (if (number? x)
+    (let [tmp (str x)]
+      (if (pos? (.indexOf tmp "."))
+        tmp
+        (str tmp ".0")))
+    (str x)))

 (defmethod emit :primitive-type [db x] (name x))


Use defmapvisitor macro for spec visitor

--- src/graphql_clj/spec.clj
+++ src/graphql_clj/spec.clj
@@ -1,7 +1,7 @@
 (ns graphql-clj.spec
   (:require [clojure.spec :as s]
             [clojure.string :as str]
-            [zip.visit :as zv]))
+            [graphql-clj.visitor :as v]))

 (defn- named-spec
   "Given an unqualified string, return a registered spec identifier (namespaced keyword)"
@@ -104,6 +104,6 @@

 (defmethod spec-for :default [_])

-(zv/defvisitor add-spec :post [n s]
-  (when-let [spec (and (map? n) (spec-for n))]
+(v/defmapvisitor add-spec :post [n s]
+  (when-let [spec (spec-for n)]
     {:node (assoc n :spec spec)}))


update logging

update logging

--- src/group_redis/core.clj
+++ src/group_redis/core.clj
@@ -1,6 +1,7 @@
 (ns group-redis.core
   (:require [fun-utils.core :refer [fixdelay stop-fixdelay]]
             [clojure.core.async :refer [chan >! <! >!! go mult tap untap sliding-buffer close!]]
+            [clojure.tools.logging :refer [info]]
             [taoensso.carmine :as car :refer [wcar]])
   (:import [java.net InetAddress]))

@@ -90,6 +91,7 @@
   (let [lock-path (lock-path connector path)
         lock-val (car/wcar conn (car/get lock-path))]

+    ;(info "Release path " path " lock-path " lock-path " lock-val " lock-val)
     (if (= (:member lock-val) member)
       (do
         ;remove from state


getLocalHost doesn't seem to always work.

--- run-test.clj
+++ run-test.clj
@@ -20,6 +20,6 @@

 (println "starting nailgun")

-(.run (NGServer. (InetAddress/getLocalHost) 8701))
+(.run (NGServer. (InetAddress/getByName "127.0.0.1") 8701))

 (println "done")


nächster Fehltritt auf der Bühne

nächster Fehltritt auf der Bühne

--- src/hello_world/core.clj
+++ src/hello_world/core.clj
@@ -40,8 +40,8 @@
 )

-(defn handler [{{name "name"} :params}]
-  (-> (r/response (page name))
+(defn handler [{{name "name"} {empfaenger "empfaenger"} :params}]
+  (-> (r/response (page name empfaenger))
       (r/content-type "text/html")))

 (def app


deleted useless test

deleted useless test

--- test/puns/core_test.clj
+++ test/puns/core_test.clj
@@ -1,7 +0,0 @@
-(ns puns.core-test
-  (:require [clojure.test :refer :all]
-            [puns.core :refer :all]))
-
-(deftest a-test
-  (testing "FIXME, I fail."
-    (is (= 0 1))))


Убрал вывод пустых ошибок в js/alert

Убрал вывод пустых ошибок в js/alert


a simpler let

a simpler let

--- src/logic/truthtable.clj
+++ src/logic/truthtable.clj
@@ -28,11 +28,11 @@
 (defn truth-table
   "Takes a human-readable formula, parses it and prints a truth table."
   [formula]
-  (let [ast (parse formula)]
-    (let [clj-code (convert-ast ast)]
-      (let [symbols (find-symbols ast (sorted-set))]
-        (let [allcomb (selections [true false] (count symbols))]
-          (let [assign-map (for [comb allcomb]
+  (let [ast (parse formula),
+        clj-code (convert-ast ast),
+        symbols (find-symbols ast (sorted-set)),
+        allcomb (selections [true false] (count symbols)),
+        assign-map (for [comb allcomb]
                              (zipmap symbols comb))]
             (print-tt symbols assign-map clj-code formula)
-          ))))))
+          ))


tweak `setup-io!`

tweak `setup-io!`

- `:append false` is the default behavior, so pass empty map
  to`make-writer`
- don't need to delete the file when we set up, since we're overwriting
  it anyway

--- src/main/om_css/core.clj
+++ src/main/om_css/core.clj
@@ -123,10 +123,9 @@
                     (butlast)
                     vec
                     (conj default-fname))))]
-    (io/delete-file fname true)
     (add-watch css :watcher
       (fn [k atom old-state new-state]
-        (with-open [out ^java.io.Writer (io/make-writer fname {:append false})]
+        (with-open [out ^java.io.Writer (io/make-writer fname {})]
           (binding [*out* out]
             (println (string/join "\n" (vals new-state)))
             (println)))))))