use writer/generate-from-spec rather than writer/process

--- src/babel/espanol/writer.clj
+++ src/babel/espanol/writer.clj
@@ -11,7 +11,7 @@
 (require '[babel.log :refer [log4j!]])
 (require '[babel.parse :as parse])
 (require '[babel.ug :refer :all])
-(require '[babel.writer :as writer :refer [process reload write-lexicon]])
+(require '[babel.writer :as writer :refer [write-lexicon]])
 (require '[clojure.string :as string])
 (require '[clojure.tools.logging :as log])
 (require '[dag_unify.core :refer (fail? get-in strip-refs)])
@@ -25,19 +25,20 @@
 (def use-map-fn pmap)

 (defn root-verbs [lexicon]
-  (let [lexemes (vals lexicon)]
-    (zipmap
-     (keys lexicon)
-     (use-map-fn (fn [lexeme-set]
-                   (filter (fn [lexeme]
-                             (and
-                              ;; how to only generate for a single infinitive (for testing/development):
-                              ;;                           (= (get-in lexeme [:espanol :espanol]) "abandonar")
-                                  (= (get-in lexeme [:synsem :cat]) :verb)
-                                  (= (get-in lexeme [:synsem :infl]) :top)
-                                  (not (= :top (get-in lexeme [:synsem :sem :pred] :top)))))
-                           lexeme-set))
-                 lexemes))))
+  (let [lexemes (vals lexicon)
+        verbs (filter #(not (empty? (last %)))
+                      (zipmap
+                       (keys lexicon)
+                       (use-map-fn (fn [lexeme-set]
+                                     (filter (fn [lexeme]
+                                               (and
+                                                (= (get-in lexeme [:synsem :cat]) :verb)
+                                                (= (get-in lexeme [:synsem :infl]) :top)
+                                                (not (= :top (get-in lexeme [:synsem :sem :pred] :top)))))
+                                             lexeme-set))
+                                   lexemes)))]
+    (zipmap (map first verbs)
+            (map second verbs))))

 (defn todos [ & [count lexeme]]
   (let [count (if count (Integer. count) 10)
@@ -63,179 +64,15 @@
     (.size
      (->> root-verb-array
           (use-map-fn
-          (fn [verb]
-            (log/debug (str "verb: " (strip-refs verb)))
-            (let [root-form (get-in verb [:espanol :espanol])]
-              (log/info (str "generating with verb: '" root-form "'"))
-              (doall (use-map-fn
-                      (fn [tense]
-                        (let [debug (log/debug (str "{:root {:espanol {:espanol " root-form))
-                              spec (unify {:root {:espanol {:espanol root-form}}}
-                                          tense)]
-                          (doall
-                           (use-map-fn
-                            (fn [gender]
-                              (let [spec (dissoc (unify spec
-                                                        {:comp {:synsem {:agr gender}}})
-                                                 :dag_unify.core/serialized)]
-                                (log/debug (str "generating from gender: " gender " with spec: " spec))
-                                (doall
-                                 (use-map-fn
-                                  (fn [person]
-                                    (let [debug (log/debug (str "generating from spec(pre-person):" spec))
-                                          unify-with {:comp {:synsem {:agr {:person person}}}}
-                                          unified (unify spec unify-with)
-                                          debug (if (fail? unified)
-                                                  (do
-                                                    (log/warn (str "spec=fail:tried to generate with spec(pre-person):" spec))
-                                                    (log/warn (str "spec=fail:tried to generate with unify-with      : " unify-with))))
-                                          spec
-                                          (if (fail? unified)
-                                            (let [message (str "could not unify " spec " with person specification:" unify-with ".")]
-                                              (cond
-                                                (and (= (get-in spec [:comp :synsem :agr :person])
-                                                        :3rd)
-                                                     (= (get-in spec [:comp :synsem :pronoun])
-                                                        false)
-                                                     false)
-                                                (do
-                                                  (log/debug message)
-                                                  (log/debug (str "Ignoring and continuing."))
-                                                  :fail)
-                                                true
-                                                (do (log/error message)
-                                                    (log/error "Stopping further processing now.")
-                                                    (throw (Exception. message)))))
-                                            unified)
-                                          ]
-                                      (log/debug (str "generating from person: " person))
-                                      (log/debug (str "generating from spec+person: " spec))
-                                      (if (fail? spec)
-                                        (throw (Exception. (str "spec+person is fail!"))))
-                                      (doall
-                                       (use-map-fn
-                                        (fn [number]
-                                          (let [debug (log/debug (str "generating from spec(1): " spec))
-                                                spec (unify spec
-                                                            {:comp {:synsem {:agr {:number number}}}})]
-                                            (log/debug (str "generating from spec(2): " spec))
-                                            (try
-                                              (if (fail? spec)
-                                                (do
-                                                  (if true
-                                                    (throw (Exception. (str "spec is fail!")))
-                                                    (log/debug (str "ignoring failed spec."))))
-                                                (process [{:fill-one-language
-                                                           {:count 1
-                                                            :spec spec
-                                                            :model model
-                                                            }}]
-                                                         "es"))
-
-                                              ;; TODO: move this to *before*
-                                              ;; attempting generation that fails.
-                                              (catch Exception e
-                                                (cond
-                                                  ;; Ignore the generation-failure exception, if
-                                                  ;; there is a legitimate reason for the exception, such as:
-                                        ;
-                                                  ;; The spec was :fail.
-                                                  (= spec :fail)
-                                                  (if false
-                                                    (log/warn (str "spec is fail!"))
-                                                    (let [message "spec is fail!"]
-                                                      (log/error message)
-                                                      (throw (Exception. message))))
-
-                                                  ;; The verb is "funcionar" (which takes a non-human
-                                                  ;; subject), but we're trying to generate with
-                                                  ;; {:agr {:person :1st or :2nd}}, for which the only lexemes
-                                                  ;; are human.
-                                                  (and
-                                                   (= (get-in spec [:root :espanol :espanol])
-                                                      "funcionar")
-                                                   (or (= (get-in spec [:comp :synsem :agr :person])
-                                                          :1st)
-                                                       (= (get-in spec [:comp :synsem :agr :person])
-                                                          :2nd)))
-                                                  (log/info (str "ignoring exception: allowed by rule 'funcionar-is-only-nonhuman'."))
-
-
-                                                  ;; The verb is "funcionar" (which takes a non-human
-                                                  ;; subject), but we're trying to generate a non-pronoun complement;
-                                                  ;; there are no such single words in the lexicon that are both
-                                                  ;; non-human and non-pronoun. There are *human* non-pronouns in the lexicon,
-                                                  ;; however: proper names like "Juan". If we added a place (e.g. "Madrid"), then
-                                                  ;; we would have a non-human non-pronoun in the lexicon.
-                                                  (and
-                                                   (= (get-in spec [:root :espanol :espanol])
-                                                      "funcionar")
-                                                   (= (get-in spec [:comp :synsem :pronoun])
-                                                      false))
-                                                  (log/info (str "ignoring exception: allowed by rule 'funcionar-is-only-pronoun'."))
-
-                                                  ;; "llamarse": there is currently only singular
-                                                  ;; proper singular names, so any attempt to use
-                                                  ;; plural number with this verb will fail.
-                                                  (and
-                                                   (= (get-in spec [:root :espanol :espanol])
-                                                      "llamarse")
-                                                   (or (= (get-in spec [:comp :synsem :agr :number])
-                                                          :plur)
-                                                       (and (not (= (get-in spec [:synsem :sem :tense])
-                                                                    :present))
-                                                            (not (= (get-in spec [:synsem :sem :aspect])
-                                                                    :simple)))
-                                                       (and (= (get-in spec [:synsem :sem :tense])
-                                                               :past)
-                                                            (= (get-in spec [:synsem :sem :aspect])
-                                                               :progressive))
-                                                       (and (= (get-in spec [:synsem :sem :tense])
-                                                               :present)
-                                                            (= (get-in spec [:synsem :sem :aspect])
-                                                               :perfect))))
+           (fn [verb]
+             (log/debug (str "verb: " (strip-refs verb)))
+             (let [root-form (get-in verb [:espanol :espanol])
+                   spec {:root {:espanol {:espanol root-form}}}]
+               (log/info (str "generating with verb: '" root-form "'"))
+               (writer/generate-from-spec
+                model (strip-refs spec)
+                (vals babel.espanol.grammar/tenses)
+                [{:gender :masc} {:gender :fem}]
+                [:1st :2nd :3rd]
+                [:sing :plur]))))))))

-                                                  (log/info (str "ignoring exception(llamarse-is-only-singular and present): " e))
-
-                                                  ;; "llamarse": subject must be a pronoun
-                                                  (and
-                                                   (= (get-in spec [:root :espanol :espanol])
-                                                      "llamarse")
-                                                   (= (get-in spec [:comp :synsem :pronoun])
-                                                      false))
-                                                  (log/info (str "ignoring exception(llamarse-requires-pronoun-as-subject): " e))
-
-                                                  true
-                                                  (do
-                                                    (log/error (str "Stopping further generation: unexpectedly "
-                                                                    "couldn't generate any expression for spec:"
-                                                                    spec "; exception:" e))
-                                                    (throw e)))))
-                                            ))
-                                        [:sing :plur]))))
-                                  [:1st :2nd :3rd]))))
-                            ;; TODO: why is this check disabled with (or true ..)?
-                            (cond (or true (= tense
-                                              {:synsem {:sem {:aspect :perfect
-                                                              :tense :past}}}))
-                                  [{:gender :masc}
-                                   {:gender :fem}]
-                                  true
-                                  [:top])))))
-                      (mapcat (fn [tense]
-                                (filter #(not (= :fail %))
-                                        (list
-                                         ;; don't generate with null-pronouns - too confusing and inconsistent.
-                                        ;                                           (unify tense
-                                        ;                                                        {:comp {:synsem {:pronoun true
-                                        ;                                                                         :null-pronoun true}}})
-                                         (unify tense
-                                                {:comp {:synsem {:pronoun true
-                                                                 :null-pronoun false}}})
-;                                         (unify tense
-;                                                {:comp {:synsem {:agr {:person :3rd
-;                                                                       :number :sing}
-;                                                                 :pronoun false}}})
-
-                                         )))
-                              (vals babel.espanol.grammar/tenses)))))))))))


Add verbose logging for metric store errors

--- src/whisper2cyanite/metric_store.clj
+++ src/whisper2cyanite/metric_store.clj
@@ -33,6 +33,16 @@
   [session]
   (alia/prepare session insert-cql))

+(defn- log-error
+  "Log a error."
+  [e tenant rollup period path time]
+  (wlog/error (str "Metric store error: " e ", "
+                   "tenant: " tenant ", "
+                   "rollup " rollup ", "
+                   "period: " period ", "
+                   "path: " path ", "
+                   "time: " time)))
+
 (defn- get-channel
   "Get store channel."
   [session statement chan-size data-stored?]
@@ -40,15 +50,18 @@
     (utils/go-while (not @data-stored?)
                     (let [values (async/<! ch)]
                       (if values
-                        (try
-                          (async/take!
-                           (alia/execute-chan session statement
-                                              {:values values :consistency :any})
-                           (fn [rows-or-e]
-                             (if (instance? Throwable rows-or-e)
-                               (wlog/error "Metric store error: " rows-or-e))))
-                          (catch Exception e
-                            (wlog/error "Metric store error: " e)))
+                        (let [[_ _ tenant rollup period path time] values]
+                          (try
+                            (async/take!
+                             (alia/execute-chan session statement
+                                                {:values values
+                                                 :consistency :any})
+                             (fn [rows-or-e]
+                               (if (instance? Throwable rows-or-e)
+                                 (log-error rows-or-e tenant rollup period path
+                                            time))))
+                            (catch Exception e
+                              (log-error e tenant rollup period path time))))
                         (when (not @data-stored?)
                           (swap! data-stored? (fn [_] true))))))
     ch))
@@ -79,7 +92,7 @@
                               (int rollup) (int period) (str path)
                               (long time)])
           (catch Exception e
-            (wlog/error "Metric store error: " e))))
+            (log-error e tenant rollup period path time))))
       (fetch-series [this tenant rollup period path from to]
         (try
           (let [series (atom {})]


code clean up and pass req in context

code clean up and pass req in context

--- src/clj/closerve/snippet.clj
+++ src/clj/closerve/snippet.clj
@@ -16,11 +16,11 @@
    "form.ajax"
  [node req page-id lift-instr]
  (let [sub-nodes-transed (process-snippets node req page-id)
-       {:keys [new-node uuid->name form-id]} (randomize-node-names sub-nodes-transed)
-       func-callback nil]
+       {:keys [new-node uuid->name form-id]} (randomize-node-names sub-nodes-transed)]
    (register-call-back-fn page-id form-id
                           (get-in lift-instr [:params "callback"])
                           {:session-id (-> req :session :session-id)
+                           :req     req
                            :page-id page-id
                            :form-id form-id
                            :name->uuid (set/map-invert uuid->name)}


refactoring logs query params (from -> since)

--- src/clj/swarmpit/handler.clj
+++ src/clj/swarmpit/handler.clj
@@ -184,7 +184,7 @@
 (defmethod dispatch :service-logs [_]
   (fn [{:keys [route-params query-params]}]
     (->> (keywordize-keys query-params)
-         :from
+         :since
          (api/service-logs (:id route-params))
          (resp-ok))))


Move timer setup inside (when msg ...) block in router

--- src/cljs/zetawar/router.cljs
+++ src/cljs/zetawar/router.cljs
@@ -46,17 +46,17 @@
         last-render-ts (atom 0)
         render-chan (chan (sliding-buffer 1))]
     (go-loop [msg (<! ev-chan)]
-      (when (< @start-ts @last-render-ts)
-        (let [current-ts (.getTime (js/Date.))]
-          (log/tracef "Setting start-ts to %d" current-ts)
-          (reset! start-ts current-ts)))
-      (r/next-tick #(let [current-ts (.getTime (js/Date.))]
-                      (log/trace "Rendering...")
-                      (put! render-chan :rendered)
-                      (when (> current-ts @last-render-ts)
-                        (log/tracef "Setting last-render-ts to %d" current-ts)
-                        (reset! last-render-ts current-ts))))
       (when msg
+        (when (< @start-ts @last-render-ts)
+          (let [current-ts (.getTime (js/Date.))]
+            (log/tracef "Setting start-ts to %d" current-ts)
+            (reset! start-ts current-ts)))
+        (r/next-tick #(let [current-ts (.getTime (js/Date.))]
+                        (log/trace "Rendering...")
+                        (put! render-chan :rendered)
+                        (when (> current-ts @last-render-ts)
+                          (log/tracef "Setting last-render-ts to %d" current-ts)
+                          (reset! last-render-ts current-ts))))
         (try
           (log/debugf "Handling event: %s" (pr-str msg))
           ;; TODO: validate event


이탤릭 이스케이프 테스트케이스 추가

이탤릭 이스케이프 테스트케이스 추가


Refactored configuration values.

Refactored configuration values.

--- src/cmr/bootstrap/system.clj
+++ src/cmr/bootstrap/system.clj
@@ -10,8 +10,7 @@
             [cmr.system-trace.context :as context]
             [clojure.core.async :as ca :refer [chan]]
             [cmr.bootstrap.data.bulk-migration :as bm]
-            [cmr.common.config :as config]
-            [cmr.oracle.config :as oracle-config]
+            [cmr.metadata-db.config :as mdb-config]
             [cmr.transmit.config :as transmit-config]))

 (def DEFAULT_PORT 3006)
@@ -23,9 +22,6 @@
     :private true}
   component-order [:log :db :web])

-(def catalog-rest-db-user
-  (config/config-value-fn :catalog-rest-db-user "DEV_52_CATALOG_REST"))
-
 (defn create-system
   "Returns a new instance of the whole application."
   []
@@ -36,8 +32,8 @@
              ;; Channel for requesting single collection/granules migration.
              ;; Takes maps, e.g., {:collection-id collection-id :provider-id provider-id}
              :collection-channel (chan CHANNEL_BUFFER_SIZE)
-             :catalog-rest-user (catalog-rest-db-user)
-             :db (oracle/create-db (apply oracle/db-spec (oracle-config/db-spec-args)))
+             :catalog-rest-user (mdb-config/catalog-rest-db-username)
+             :db (oracle/create-db (mdb-config/db-spec))
              :web (web/create-web-server DEFAULT_PORT routes/make-api)
              :zipkin (context/zipkin-config "bootstrap" false)}]
     (transmit-config/system-with-connections sys [:metadata-db])))


Added docstrings.

Added docstrings.

--- src/com/lemonodor/gflags.clj
+++ src/com/lemonodor/gflags.clj
@@ -139,7 +139,9 @@
     *ns*))

-(defn define-string [name default help & args]
+(defn define-string
+  "Registers a flag whose value can be any string."
+  [name default help & args]
   (apply define string-parser name default help
          :serializer string-serializer
          args))
@@ -173,6 +175,7 @@
   (str value))

 (defn define-integer [name default help & args]
+  "Registers a flag whose value must be an integer."
   (apply define integer-parser name default (or help "an integer value")
          :serializer integer-serializer
          args))
@@ -188,7 +191,9 @@
 (defn float-serializer [value]
   (str value))

-(defn define-float [name default help & args]
+(defn define-float
+  "Registers a flag whose value must be a float."
+  [name default help & args]
   (apply define float-parser name default (or help "a float value")
          :serializer float-serializer
          args))
@@ -203,7 +208,9 @@
 (defn enum-serializer [value]
   (str value))

-(defn define-enum [name default enum-values help & args]
+(defn define-enum
+  "Registers a flag whose value can be any string from enum_values."
+  [name default enum-values help & args]
   (apply define enum-parser name default  (or help "an enum value")
          :serializer enum-serializer
          :enum-values enum-values
@@ -220,21 +227,42 @@
       (conj values new-value))))

-(defn define-multi-string [name default help & args]
+(defn define-multi-string
+  "Registers a flag whose value can be a list of any strings.
+
+  Use the flag on the command line multiple times to place multiple
+  string values into the list.  The 'default' may be a single string
+  (which will be converted into a single-element vector) or a vector of
+  strings."
+  [name default help & args]
   (apply define (make-multi-parser string-parser)
          name default help
          :serializer string-serializer
          args))

-(defn define-multi-integer [name default help & args]
+(defn define-multi-integer
+  "Registers a flag whose value can be a list of arbitrary integers.
+
+  Use the flag on the command line multiple times to place multiple
+  integer values into the list.  The 'default' may be a single integer
+  (which will be converted into a single-element vector) or a vector of
+  integers."
+ [name default help & args]
   (apply define (make-multi-parser integer-parser)
          name default help
          :serializer integer-serializer
          args))

-(defn define-multi-float [name default help & args]
+(defn define-multi-float
+  "Registers a flag whose value can be a list of arbitrary floats.
+
+  Use the flag on the command line multiple times to place multiple
+  float values into the list.  The 'default' may be a single float
+  (which will be converted into a single-element vector) or a vector
+  of floats."
+  [name default help & args]
   (apply define
          (make-multi-parser float-parser)
          name default help


add when in doseq for nil value

add when in doseq for nil value

--- src/datasplash/datastore.clj
+++ src/datasplash/datastore.clj
@@ -84,7 +84,8 @@
         ^Entity$Builder entity-builder (Entity/newBuilder)]
     (when ds-namespace (.setNamespaceId (.getPartitionIdBuilder key-builder) ds-namespace))
     (.setKey entity-builder (.build key-builder))
-    (doseq [[v-key v-val] raw-values]
+    (doseq [[v-key v-val] raw-values
+            :when v-val]
       (.put (.getMutableProperties entity-builder)
             (if (keyword? v-key) (name v-key) v-key)
             (let [^Value$Builder val-builder (make-ds-value-builder v-val options)]


remove namespace deps

remove namespace deps

--- src/er_cassandra/session.clj
+++ src/er_cassandra/session.clj
@@ -1,12 +1,4 @@
-(ns er-cassandra.session
-  (:require
-   [plumbing.core :refer :all]
-   [qbits.alia :as alia]
-   [qbits.alia.manifold :as aliam]
-   [manifold.deferred :as d]
-   [qbits.hayt :as h]
-   [clj-uuid :as uuid]
-   [er-cassandra.key :refer [make-sequential extract-key-equality-clause]]))
+(ns er-cassandra.session)

 (defprotocol Session
   (execute [this statement])


Someone messed up indentation of my (assuming) form. If it was you, get the latest version of clojure-mode.el and start customizing your indentation with M-x customize-variable clojure-defun-indents

--- src/foreclojure/register.clj
+++ src/foreclojure/register.clj
@@ -34,14 +34,14 @@
                "Passwords don't match",
                (not (empty? email))
                "Please enter a valid email address"]
-              (do
-                (insert! :users
-                         {:user lower-user
-                          :pwd (.encryptPassword (StrongPasswordEncryptor.) pwd)
-                          :email email})
-                (session/session-put! :user user)
-                (response/redirect "/"))
-              (flash-error why "/register"))))
+      (do
+        (insert! :users
+                 {:user lower-user
+                  :pwd (.encryptPassword (StrongPasswordEncryptor.) pwd)
+                  :email email})
+        (session/session-put! :user user)
+        (response/redirect "/"))
+      (flash-error why "/register"))))

 (defroutes register-routes
   (GET  "/register" [] (register-page))


fix simple test error

fix simple test error

--- src/graphql_clj/executor.clj
+++ src/graphql_clj/executor.clj
@@ -98,14 +98,12 @@

 (defn- execute-statement [{:keys [selection-set variable-definitions] :as statement} {:keys [variables] :as state}]
   (let [errors (guard-missing-vars variable-definitions variables)]
-    (println "execute-statement errors: %s.%n" (doall errors))
-    (if (nil? errors)
-      [nil (execute-fields selection-set state 'QueryRoot :root)]
-      [errors nil])))
+    (if (seq errors)
+      [errors nil]
+      [nil (execute-fields selection-set state 'QueryRoot :root)])))

 (defn- execute-document
   [document state]
-  (printf "execute-document: document: %s%n" document)
   (let [results (map #(execute-statement % state) document)
         errors (->> results
                     (filter first)
@@ -117,6 +115,7 @@
                     (map second)
                     flatten
                     vec)]
+    (println "results: %s.%n" results)
     (printf "errors: %s.%n" errors)
     (printf "fields: %s.%n" fields)
     (if (seq errors)


clean up executor

clean up executor

--- src/graphql_clj/executor.clj
+++ src/graphql_clj/executor.clj
@@ -2,14 +2,6 @@
   (:require [graphql-clj.parser :as parser]
             [graphql-clj.type :as type]
             [taoensso.timbre :as log]))
-
-;; (defn get-selection-object-name
-;;   [selection]
-;;   {:post [(not (nil? %))]}
-;;   (log/debug "get-selection-object-name: " selection)
-;;   (let [name (get-in (second selection) [:field :name])]
-;;     (log/debug "get-selection-object-name: name: " name)
-;;     name))

 (defn get-selection-arguments
   [selection]
@@ -53,7 +45,7 @@
   (let [fragment (get fragments fragment-name)
         selection-set (:selection-set fragment)]
     (if fragment
-      (log/spy selection-set)
+      selection-set
       (throw (ex-info (format "expand-fragment: cannot find fragment(%s)." fragment-name)
                       {:fragment-name fragment-name
                        :fragments fragments})))))
@@ -80,7 +72,7 @@
   [selection-set fragments]
   (log/debug "collect-fields: selection-set" selection-set)
   (log/debug "collect-fields: fragments: " fragments)
-  (log/spy (reduce (collect-selection-fn fragments) [] selection-set)))
+  (reduce (collect-selection-fn fragments) [] selection-set))

 (comment ; Type kind
   :SCALAR
@@ -125,8 +117,8 @@
         resolve-fn (resolver-fn parent-type-name field-name)]
     (log/debug "resolve-field-on-object: arguments: " arguments)
     (if arguments
-      (log/spy (resolve-fn context parent-object arguments))
-      (log/spy (resolve-fn context parent-object)))))
+      (resolve-fn context parent-object arguments)
+      (resolve-fn context parent-object))))

 (defn merge-selection-sets
   [selections]
@@ -191,12 +183,12 @@
     (cond
       (is-scalar-field-type? field-type) result
       (is-enum-field-type? field-type) result
-      (is-object-field-type? field-type) (log/spy (execute-fields context schema resolver-fn field-type result sub-selection-set fragments))
-      (is-list-field-type? field-type) (log/spy (map #(execute-fields context schema resolver-fn (type/get-inner-type schema field-type) % sub-selection-set fragments) result))
-      (is-not-null-type? field-type) (log/spy (let [not-null-result (complete-value context schema resolver-fn (type/get-inner-type schema field-type) result sub-selection-set fragments)]
-                                                (if not-null-result
-                                                  not-null-result
-                                                  (throw (ex-info (format "NOT_NULL type %s returns null." field-type {:field-type field-type}))))))
+      (is-object-field-type? field-type) (execute-fields context schema resolver-fn field-type result sub-selection-set fragments)
+      (is-list-field-type? field-type) (map #(execute-fields context schema resolver-fn (type/get-inner-type schema field-type) % sub-selection-set fragments) result)
+      (is-not-null-type? field-type) (let [not-null-result (complete-value context schema resolver-fn (type/get-inner-type schema field-type) result sub-selection-set fragments)]
+                                       (if not-null-result
+                                         not-null-result
+                                         (throw (ex-info (format "NOT_NULL type %s returns null." field-type {:field-type field-type})))))
       :else (throw (ex-info (format "Unhandled field type %s." field-type) {:field-type field-type})))))

 (defn get-field-entry [context schema resolver-fn parent-type parent-object field-entry fragments]
@@ -238,7 +230,7 @@
                         ;; field-type (get-field-type-from-object-type parent-type field)
                         ;; resolved-object (resolve-field-on-object field-type root-value field)
                         field-entry (get-field-entry context schema resolver-fn parent-type root-value field fragments)]
-                    (log/spy field-entry)))
+                    field-entry))
                 fields)))

 (defn execute-query [context schema resolver-fn query fragments]
@@ -254,7 +246,7 @@
   (let [type (get-in definition [:operation-type :type])]
     (log/debug "*** execute-definition: fragments: " fragments)
     (case type
-      "query" (log/spy (execute-query context schema resolver-fn definition fragments))
+      "query" (execute-query context schema resolver-fn definition fragments)
       (throw (ex-info (format "Unhandled operation root type: %s." definition) {})))))

 (defn execute
@@ -263,9 +255,9 @@
         fragments (:fragments document)]
     (if (empty? operation-definitions)
       (throw (ex-info (format "Document is invalid (%s)." document) {}))
-      {:data (into {} (log/spy (map (fn [definition]
-                                      (execute-definition context schema resolver-fn definition fragments))
-                                    operation-definitions)))})))
+      {:data (into {} (map (fn [definition]
+                             (execute-definition context schema resolver-fn definition fragments))
+                           operation-definitions))})))

 (comment
   (execute nil (parser/transform (parser/parse "query {user {id}}")) (graphql-clj.type/create-type-meta-fn graphql-clj.type/demo-schema))


Remove deprecated user_variables field.

Remove deprecated user_variables field.

--- src/ipython_clojure/core.clj
+++ src/ipython_clojure/core.clj
@@ -207,7 +207,6 @@
             (send-router-message shell-socket "execute_reply"
                                  {:status "ok"
                                   :execution_count @execution-count
-                                  :user_variables {}
                                   :user_expressions {}}
                                  parent-header
                                  {:dependencies_met "True"
@@ -256,7 +255,6 @@
                                   :started (now)} session-id signer (:idents message)))
           )

-
         (send-message iopub-socket "status" (status-content "idle")
                       parent-header {} session-id signer)))))


relax restrictions so we can bootstrap under :simple optimizations

--- src/main/cljs/cljs/core.cljs
+++ src/main/cljs/cljs/core.cljs
@@ -9926,16 +9926,11 @@
     :else (recur (gobject/get ctxt (first xs)) (next xs))))

 (defn find-ns-obj [ns]
-  (if-not js/COMPILED
-    (let [segs (-> ns str (.split "."))]
-      (when-not (nil? (gobject/get (. goog/dependencies_ -nameToPath) (str ns)))
-        (case *target*
-          "nodejs"  (find-ns-obj* js/global segs)
-          "default" (find-ns-obj* js/window segs)
-          (throw (js/Error. (str "find-ns-obj not supported for target " *target*))))))
-    (throw
-      (js/Error.
-        "find-ns-obj not supported when Closure optimization applied"))))
+  (let [segs (-> ns str (.split "."))]
+    (case *target*
+      "nodejs"  (find-ns-obj* js/global segs)
+      "default" (find-ns-obj* js/window segs)
+      (throw (js/Error. (str "find-ns-obj not supported for target " *target*))))))

 (defn ns-interns* [sym]
   (let [ns-obj (find-ns-obj sym)


this works on my box :scream:

this works on my box :scream:

--- src/metabase/driver/sync.clj
+++ src/metabase/driver/sync.clj
@@ -68,7 +68,7 @@
              (map #(assoc % :db (delay database))) ; replace default delays with ones that reuse database (and don't require a DB call)
              (sync-database-active-tables! driver))

-        (log/info (color/blue (format "Finished syncing database %s." (:name database))))))))
+        (log/info (u/format-color 'blue "Finished syncing %s database %s." (name (:engine database)) (:name database)))))))

 (defn sync-table!
   "Sync a *single* TABLE by running all the sync steps for it.


Use rethinkdb.query/and instead of the clojure.core/and for the follow/unfollow filter.

--- src/oc/storage/db/common.clj
+++ src/oc/storage/db/common.clj
@@ -47,13 +47,13 @@
                      (r/or ;; no filter if it's nil
                            (not (map? follow-data))
                            ;; filter on followed authors and on not unfollowed boards
-                           (and (:following follow-data)
-                                (r/or (r/contains (vec (:follow-publisher-uuids follow-data)) (r/get-field post-row [:publisher :user-id]))
-                                      (r/not (r/contains (vec (:unfollow-board-uuids follow-data)) (r/get-field post-row :board-uuid)))))
+                           (r/and (:following follow-data)
+                                  (r/or (r/contains (vec (:follow-publisher-uuids follow-data)) (r/get-field post-row [:publisher :user-id]))
+                                        (r/not (r/contains (vec (:unfollow-board-uuids follow-data)) (r/get-field post-row :board-uuid)))))
                            ;; filter on not followed authors and on unfollowed boards
-                           (and (:unfollowing follow-data)
-                                (r/not (r/contains (vec (:follow-publisher-uuids follow-data)) (r/get-field post-row [:publisher :user-id])))
-                                (r/contains (vec (:unfollow-board-uuids follow-data)) (r/get-field post-row :board-uuid)))))))
+                           (r/and (:unfollowing follow-data)
+                                  (r/not (r/contains (vec (:follow-publisher-uuids follow-data)) (r/get-field post-row [:publisher :user-id])))
+                                  (r/contains (vec (:unfollow-board-uuids follow-data)) (r/get-field post-row :board-uuid)))))))
             ;; Merge in a last-activity-at date for each post, which is the
             ;; last comment created-at, with fallback to published-at or created-at for published entries
             ;; the entry created-at in all the other cases.


Adjust direction filter.

Adjust direction filter.

--- src/oc/storage/db/common.clj
+++ src/oc/storage/db/common.clj
@@ -54,15 +54,17 @@
          (sequential? relation-fields)
          (every? db-common/s-or-k? relation-fields)
          (boolean? count?)]}
-  (let [order-fn (if (= order :desc) r/desc r/asc)]
+  (let [order-fn (if (= order :desc) r/desc r/asc)
+        dir-filter (when-not (string/empty-or-nil? start)
+                     #(direction-filter direction start (r/get-field % :published-at)))]
     (db-common/with-timeout db-common/default-timeout
       (as-> (r/table table-name) query
         (r/get-all query index-value {:index index-name})
            ;; Filter out:
-        (if-not (string/blank? start)
+        (if dir-filter
           (r/filter query (r/fn [row]
             ;; All records after/before the start
-            (direction-filter direction start (r/get-field row :published-at))))
+            (dir-filter row)))
           query)
         (if-not count?
           (r/order-by query (order-fn :published-at))
@@ -105,11 +107,14 @@
          (every? db-common/s-or-k? relation-fields)
          (boolean? count?)]}
   (let [order-fn (if (= order :desc) r/desc r/asc)
-        dir-filter (when-not (string/blank? start)
+        dir-filter (when-not (string/empty-or-nil? start)
                      #(direction-filter direction start (r/get-field % :sort-value)))]
     (db-common/with-timeout db-common/default-timeout
       (as-> (r/table table-name) query
         (r/get-all query index-value {:index index-name})
+        (if-not count?
+          (r/order-by query (order-fn index-name))
+          query)
         (if (or dir-filter
                 (not count?))
           (r/merge query (r/fn [row]
@@ -120,9 +125,6 @@
           (r/filter query (r/fn [row]
             ;; All records after/before the start
             (dir-filter row)))
-          query)
-        (if-not count?
-          (r/order-by query (order-fn :sort-value))
           query)
            ;; Apply count if needed
         (if count? (r/count query) query)
@@ -168,7 +170,7 @@
                                (map :uuid
                                     (filter #(not= (:access %) "private") allowed-boards)))
                               (set (map :uuid allowed-boards)))
-        dir-filter (when-not (string/blank? start)
+        dir-filter (when-not (string/empty-or-nil? start)
                      #(direction-filter direction start (r/get-field % :sort-value)))
         uns-filter (when (and unseen container-last-seen-at)
                       #(unseen-filter container-last-seen-at (r/get-field % :sort-value)))
@@ -223,14 +225,16 @@
          (#{:after :before} direction)
          (integer? limit)
          (boolean? count?)]}
-  (let [order-fn (if (= order :desc) r/desc r/asc)]
+  (let [order-fn (if (= order :desc) r/desc r/asc)
+        dir-filter (when-not (string/empty-or-nil? start)
+                     #(direction-filter direction start (r/get-field % :published-at)))]
     (db-common/with-timeout db-common/default-timeout
       (as-> (r/table table-name) query
         (r/get-all query index-value {:index index-name})
         ;; Filter out:
-        (if-not (string/blank? start)
+        (if dir-filter
           (r/filter query (r/fn [row]
-            (direction-filter direction start (r/get-field row :published-at))))
+            (dir-filter row)))
           query)
         (if-not count?
           (r/order-by query (order-fn :published-at))
@@ -314,7 +318,7 @@
          (boolean? count?)
          (boolean? unseen)]}
   (let [order-fn (if (= order :desc) r/desc r/asc)
-        dir-filter (when-not (string/blank? start)
+        dir-filter (when-not (string/empty-or-nil? start)
                      #(direction-filter direction start (r/get-field % [:reduction :created-at])))
         uns-filter (when (and unseen container-last-seen-at)
                       #(unseen-filter container-last-seen-at (r/get-field % [:reduction :created-at])))


rejig tilemap api to support tile changing


WIP: Bring color into Sunburst, but need to decide how to mimic D3's parent-based color scheme.

--- vrepl/resources/samples/sunburst.clj
+++ vrepl/resources/samples/sunburst.clj
@@ -5,24 +5,30 @@
         [c2.svg :only [arc]]
         [c2.layout.partition :only [partition]]

-        [vomnibus.d3 :only [flare]]))
+        [vomnibus.d3 :only [flare]]
+        [vomnibus.d3-color :only [Categorical-20]]))

-(let [radius 170
+(let [radius 270
       ;;Partition will give us entries for every node;
       ;;we only want slices, so filter out the root node.
       slices (filter #(-> % :partition :depth (not= 0))
                      (partition flare :value :size
-                                :size [Tau (* radius radius)]))]
-
+                                :size [Tau (* radius radius)]))
+      ;;TODO: Rework partition to include reference to parent so we can match D3's coloring scheme?
+      color-scale (apply hash-map (interleave
+                                   (into #{} (map :name (filter :children slices)))
+                                   (flatten (repeat Categorical-20))))]
+
   [:svg {:width (* 2 radius) :height (* 2 radius)}
    [:g {:transform (str "translate(" radius "," radius ")")}
     (unify slices
      (fn [{name :name, bites :bites
           {:keys [x dx y dy]} :partition}]
        [:g.slice
-        [:path {:d (arc :inner-radius (sqrt y)
+        [:path {:title name
+                :d (arc :inner-radius (sqrt y)
                         :outer-radius (sqrt (+ y dy))
                         :start-angle x
-                        :end-angle  (+ x dx))}]]))]]
+                        :end-angle  (+ x dx))
+                :fill "white"}]]))]]
 )
-


REST API call /api/info

REST API call /api/info

--- src/hurvinek/server.clj
+++ src/hurvinek/server.clj
@@ -15,6 +15,7 @@

 (require '[ring.util.response     :as http-response])
 (require '[clojure.tools.logging  :as log])
+(require '[clojure.data.json      :as json])

 (require '[hurvinek.html-renderer :as html-renderer])
 (require '[hurvinek.exporter      :as exporter])
@@ -39,6 +40,11 @@
     (-> (:configuration request)
         :server
         :url-prefix))
+
+(defn send-rest-api-response
+    [response]
+    (-> (http-response/response (json/write-str response))
+        (http-response/content-type "application/json")))

 (defn finish-processing
     [render-function request title & rest-parameters]
@@ -322,6 +328,12 @@
           mime-type     (mime-type output-format)]
         (-> (http-response/response output-data)
             (http-response/content-type mime-type))))
+
+(defn process-api-info
+    [request]
+    (let [response {:toasterNotifications [(str "info|Api response|Hurvinek api v1")]
+                    :configuration (:configuration request)}]
+        (send-rest-api-response response)))

 (defn return-file
     "Creates HTTP response containing content of specified file.
@@ -367,5 +379,6 @@
             "/api/groups"                 (process-list-of-groups       request)
             "/api/components"             (process-list-of-components   request)
             "/api/components-to-chapter"  (process-list-of-components-to-chapter request)
+            "/api/info"                   (process-api-info             request)
             )))


Fix spelling of 'weird'

Fix spelling of 'weird'

https://en.wiktionary.org/wiki/wierd

--- src/re_frame/middleware.cljs
+++ src/re_frame/middleware.cljs
@@ -91,7 +91,7 @@

 ;; -- Middleware Factories ----------------------------------------------------
 ;;
-;; Note: wierd approach defn-ing middleware factories below. Why? Because
+;; Note: weird approach defn-ing middleware factories below. Why? Because
 ;; I wanted to put some metadata on them (useful for later checking).
 ;; Found I had to do it this way:
 ;;   (def fn-name
@@ -99,7 +99,7 @@
 ;;     ^{....}       ;; middleware put on the following fn
 ;;     (fn fn-name ....))
 ;;
-;; So, yeah, wierd.
+;; So, yeah, weird.

 (def path
   "A middleware factory which supplies a sub-tree of `db` to the handler.


cleanup for string join

cleanup for string join

--- src/selmer/tags.clj
+++ src/selmer/tags.clj
@@ -258,7 +258,7 @@
       [tag
        (update-in content [:content]
          (fn [^selmer.node.INode node]
-           (apply str (map #(.render-node ^selmer.node.INode % context-map) node))))])))
+           (clojure.string/join (map #(.render-node ^selmer.node.INode % context-map) node))))])))

 (defn tag-handler [handler & tags]
   (fn [args tag-content render rdr]


Wrap select as special form element

Wrap select as special form element

--- src/sablono/interpreter.cljc
+++ src/sablono/interpreter.cljc
@@ -46,6 +46,7 @@

 #?(:cljs (def input (wrap-form-element js/React.DOM.input "input")))
 #?(:cljs (def option (wrap-form-element js/React.DOM.option "option")))
+#?(:cljs (def select (wrap-form-element js/React.DOM.select "select")))
 #?(:cljs (def textarea (wrap-form-element js/React.DOM.textarea "textarea")))

 #?(:cljs
@@ -53,6 +54,7 @@
      ((if (util/wrapped-type? type)
         (get {:input sablono.interpreter/input
               :option sablono.interpreter/option
+              :select sablono.interpreter/select
               :textarea sablono.interpreter/textarea}
              (keyword type))
         (partial js/React.createElement (name type)))


ns doc

ns doc

--- src/useful/bean.clj
+++ src/useful/bean.clj
@@ -1,7 +1,5 @@
-(ns
-    #^{:author "Justin Balthrop"
-       :doc "Modify bean attributes in clojure."}
-  useful.bean
+(ns useful.bean
+  "Modify bean attributes in clojure."
   (:import [java.beans Introspector]))

 (defn- property-key [property]


Move write-header! in source.

Move write-header! in source.

--- src/multicodec/core.clj
+++ src/multicodec/core.clj
@@ -38,15 +38,6 @@
       encoded)))

-(defn write-header!
-  "Writes a multicodec header for `path` to the given stream. Returns the number
-  of bytes written."
-  [^OutputStream output path]
-  (let [header (encode-header path)]
-    (.write output header)
-    (count header)))
-
-
 (defn- take-bytes!
   "Attempts to read `length` bytes from the given stream. Returns a byte array with
   the read bytes."
@@ -78,3 +69,12 @@
                  (str "Last byte in header is not a newline: "
                       (pr-str (.charAt header (dec (count header))))))))
       (str/trim-newline header))))
+
+
+(defn write-header!
+  "Writes a multicodec header for `path` to the given stream. Returns the number
+  of bytes written."
+  [^OutputStream output path]
+  (let [header (encode-header path)]
+    (.write output header)
+    (count header)))


Properly use projects fetched event after fetch projects event.

--- src/uxbox/data/projects.cljs
+++ src/uxbox/data/projects.cljs
@@ -27,15 +27,18 @@
   [projects]
   (ProjectsFetched. projects))

+(defn projects-fetched?
+  [v]
+  (instance? ProjectsFetched v))
+
 ;; --- Fetch Projects

 (defrecord FetchProjects []
   rs/WatchEvent
   (-apply-watch [_ state s]
-    (letfn [(on-loaded [{projects :payload}]
-              #(reduce stpr/assoc-project % projects))]
-      (->> (rp/req :fetch/projects)
-           (rx/map on-loaded)))))
+    (->> (rp/req :fetch/projects)
+         (rx/map :payload)
+         (rx/map projects-fetched))))

 (defn fetch-projects
   []


Forgot to add the title in value

Forgot to add the title in value

--- src/wishlistd/cljs/main.cljs
+++ src/wishlistd/cljs/main.cljs
@@ -26,5 +26,6 @@
     (wish-li-last)])

 (defpartial wishlist-title [title]
-  [:input {:type "text" :class "title"}])
+  [:input {:type "text" :class "title" :value title}])

+


Substract tone profiles

Substract tone profiles

--- src/neuhon/profiles.clj
+++ src/neuhon/profiles.clj
@@ -1,3 +1,21 @@
-(def major-key-profile (to-array (seq [6.4 2.2 3.5 2.3 4.4 4.1 2.5 5.2 2.4 3.7 2.3 2.9])))
-(def minor-key-profile (to-array (seq [6.4 2.8 3.6 5.4 2.7 3.6 2.6 4.8 4.0 2.7 3.3 3.2])))
+(def major-coefs (to-array (seq [6.4 2.2 3.5 2.3 4.4 4.1 2.5 5.2 2.4 3.7 2.3 2.9])))
+(def minor-coefs (to-array (seq [6.4 2.8 3.6 5.4 2.7 3.6 2.6 4.8 4.0 2.7 3.3 3.2])))

+(deftype Profile [coefs fondamental])
+
+(def major-key-profile (Profile. major-coefs 0))
+(def minor-key-profile (Profile. minor-coefs 0))
+
+(def profile-data-type Double/TYPE)
+
+(defn substract-profiles [profile_A profile_B]
+	(let [arr_A (.coefs profile_A)
+		  arr_B (.coefs profile_B)
+		  fondamental (.fondamental profile_A)
+		  N (alength arr_A)
+		  new_arr (make-array profile-data-type N)]
+		(do (loop [i 0]
+			(when (< i N)
+				(aset new_arr i (- (aget arr_A i) (aget arr_B i)))
+				(recur (inc i)))) (Profile. new_arr fondamental))))
+


fixes

fixes

--- src/node/game/core.cljs
+++ src/node/game/core.cljs
@@ -67,7 +67,7 @@
 (defn update! [state side card]
   (if (= (:type card) "Identity")
     (swap! state assoc-in [side :identity] card)
-    (let [zone (cons (:side card) (:zone card))
+    (let [zone (cons (to-keyword (:side card)) (:zone card))
           [head tail] (split-with #(not= (:cid %) (:cid card)) (get-in @state zone))]
       (swap! state assoc-in zone (vec (concat head [card] (rest tail)))))))

@@ -92,9 +92,9 @@
 (defn optional-ability [state side card msg ability targets]
   (swap! state update-in [side :prompt]
          (fn [p]
-           (conj p {:msg msg :choices ["Yes" "No"]
-                    :effect #(when (= % "Yes")
-                               (resolve-ability state side ability card targets))}))))
+           (conj (vec p) {:msg msg :choices ["Yes" "No"]
+                          :effect #(when (= % "Yes")
+                                     (resolve-ability state side ability card targets))}))))

 (defn resolve-prompt [state side {:keys [choice] :as args}]
   (let [effect (:effect (first (get-in @state [side :prompt])))]


Add comments to dar.unpack

Add comments to dar.unpack

Signed-off-by: Gregory Haskins <640d9fe47775e6723f0355b7315e38f7d98d3539@gmail.com>

--- src/obcc/dar/unpack.clj
+++ src/obcc/dar/unpack.clj
@@ -19,14 +19,25 @@
   (:require [clojure.java.io :as io]
             [obcc.dar.read :as dar.read]))

+;;--------------------------------------------------------------------------------------
+;; unpack - given a (pre-read) index of entries and an outputdir, unpack each element
+;;--------------------------------------------------------------------------------------
 (defn unpack [index outputdir verbose]
   (dorun
    (for [[path item] index]
      (let [entry (:entry item)
            outputfile (io/file outputdir path)]
+
+       ;; ensure our output path exists
        (io/make-parents outputfile)
+
+       ;; walk each entry and stream it out to the filesystem
        (with-open [is (dar.read/entry-stream item)
                    os (io/output-stream outputfile)]
+
+         ;; we optionally may report out status to stdout
          (when (= verbose :true)
            (println (:sha1 entry) (:path entry) (str "(" (:size entry) " bytes)")))
+
+         ;; stream it out, pulling the input stream through any appropriate decompressor transparently
          (io/copy is os))))))


Avoid assertions (Error), as they're not intended to be caught.

Use an Exception, instead.

--- src/cavm/h2.clj
+++ src/cavm/h2.clj
@@ -601,10 +601,12 @@
                              (update-in values [:name] trunc max-probe-length))
                            values)
                   write (fn write [i] ; on field inserts we retry on certain failures, with sanitized probe ids.
-                          {:pre [(< i max-insert-retry)]} ; XXX change this to drop field & write remainer of dataset instead.
                           (let [values (if (= :insert-field insert-type)
                                          (update-in values [:name] str (numbered-suffix i))
                                          values)]
+                            ; On primary key violations, try to rename probes. If we can't find a usable
+                            ; name after max-insert-retry attempts, let the dataset error out. It's probably
+                            ; a severe error, like wrong column being used as probe id.
                             (try
                               ((writer insert-type) values)
                               (catch JdbcBatchUpdateException ex
@@ -613,7 +615,8 @@
                                        ; h2 concats the english message after
                                        ; the localized message, so using
                                        ; .contains.
-                                       (.contains (.getMessage ex) "Unique index"))
+                                       (.contains (.getMessage ex) "Unique index")
+                                       (< i max-insert-retry))
                                   (do
                                     (swap! warnings update-in ["duplicate-probes"] conj (:name values))
                                     (warn "Duplicate probe" (:name values))


removed modal crashes

removed modal crashes

--- src/re_demo/modals.cljs
+++ src/re_demo/modals.cljs
@@ -13,17 +13,17 @@
 (def demos [{:id 1 :label "Basic example"}
             {:id 2 :label "Other variations"}])

-
-(def show-modal-popover? (reagent/atom false))
-(def progress-percent    (reagent/atom 0))
-
+(def progress-percent (reagent/atom 0))                     ;; TODO: Remove this dirty global!

 (defn cpu-delay
   [num-times]
   (let [waste-time  #(Math.tan (Math.tan (+ %1 %2)))         ;; tan is a time consuming operation
         iterations  (if (nil? num-times) 10 num-times)]
+    (println "starting cpu-delay")
     (dotimes [n iterations]
-      (doall (reduce waste-time n (range 1000000))))))
+      ;(doall (reduce waste-time n (range 1000000)))
+      (reduce waste-time n (range 1000))
+      (println "finished cpu-delay"))))

@@ -33,8 +33,9 @@
   [button
    :label    label
    :on-click on-click
-   :style {:font-weight "bold" :color "red" :margin "1px" :height "39px"}
+   :style {:margin "1px" :height "39px"}
    :class "btn-info"])
+

 ;; ------------------------------------------------------------------------------------
 ;;  MODAL PROCESSING #1 - Long running with progress and cancel
@@ -163,7 +164,7 @@
             [:p (str "Saving '" path "'...")]
             [:div {:style {:display "flex"}}
              [:div {:style {:margin "auto"}}
-              [:img {:src "img/spinner.gif" :style {:margin-right "12px"}}]
+              [:img {:src "resources/img/spinner.gif" :style {:margin-right "12px"}}]
               [button
                :label    "STOP!"
                :on-click #(reset! writing? false)
@@ -388,7 +389,6 @@
 ;;  core.async tests
 ;; ------------------------------------------------------------------------------------

-
 (defn cancellable-step
   [continue? func]
   (fn [val]
@@ -400,6 +400,7 @@
 (defn fib-step
   [{:keys [step-num] :as params}]
   (cpu-delay step-num)
+  (+)
   [(< step-num 10)
    (assoc params :step-num (inc step-num))])

@@ -667,6 +668,7 @@
     :label    "Cancel"
     :on-click process-cancel]])

+
 (defn test-modal-dialog
   []
   "Create a button to test the modal component for modal dialogs"
@@ -702,9 +704,7 @@

 (defn demo1
   []
-  (let []
-    ;; Modal component
-
+  (let [show-modal-popover? (reagent/atom false)]
     [:div.container
      {:style {:width "100%" :margin-top "20px" :margin-left "0px" :margin-right "0px"}}
      [:div.row
@@ -713,21 +713,21 @@

         [popover-anchor-wrapper
          :showing? show-modal-popover?
-         :position :right-center
+         :position :left-center
          :anchor   [:input.btn.btn-info
-                    {:style         {:font-weight "bold" :color "red" :margin "1px" :height "39px"}
+                    {:style         {:margin "1px" :height "39px"}
                      :type          "button"
                      :value         "Long"
                      :on-mouse-over #(reset! show-modal-popover? true)
                      :on-mouse-out  #(reset! show-modal-popover? false)
-                     :on-click      #()
+                     :on-click      #(cpu-delay 10)
                     #_#(chunk-runner
                       serious-process-1-chunk
                       serious-process-1-status
                       250)}]
          :popover  [popover-content-wrapper
                     :showing?         show-modal-popover?
-                    :position         :right-center
+                    :position         :left-center
                     :width            "300px"
                     :body             [:div
                                        [:p "Click on this button to launch a modal demo. The demo will start an intensive operation and..."]
@@ -737,30 +737,6 @@
                                          {:role  "progressbar"
                                           :style {:width "60%"}}
                                          "60%"]]]]]
-        #_[popover
-         :position :right-center
-         :showing? show-modal-popover?
-         :anchor   [:input.btn.btn-info
-                    {:style         {:font-weight "bold" :color "red" :margin "1px" :height "39px"}
-                     :type          "button"
-                     :value         "Long"
-                     :on-mouse-over #(reset! show-modal-popover? true)
-                     :on-mouse-out  #(reset! show-modal-popover? false)
-                     :on-click      #()
-                    #_#(chunk-runner
-                      serious-process-1-chunk
-                      serious-process-1-status
-                      250)}]
-         :popover  {:body  [:div
-                            [:p "Click on this button to launch a modal demo. The demo will start an intensive operation and..."]
-                            [:p "It will have a progress bar which looks something like this:"]
-                            [:div.progress
-                             [:div.progress-bar
-                              {:role  "progressbar"
-                               :style {:width "60%"}}
-                              "60%"]]]
-                    :width 300}]
-
         [test-load-url]          ;; 1 - Loading URL
         [test-write-disk]        ;; 2 - Writing to disk
         ;[test-calc-pivot-totals] ;; 3 - Calculating pivot totals


No need to annotated defmacro.

No need to annotated defmacro.

--- src/react/who/core.cljx
+++ src/react/who/core.cljx
@@ -6,13 +6,11 @@
             #+clj [react.who.compiler :as compiler])
   #+cljs (:require-macros [react.who.core :refer [defelem]]))

-#+clj
 (defmacro html
   "Render Clojure data structures via Facebook's React."
   [options & content]
   (apply react.who.compiler/compile-html options content))

-#+clj
 (defmacro html-expand
   "Returns the expanded HTML generation forms."
   [& forms]


Always send data to zookeeper.

Always send data to zookeeper.

- continuous publishing of data acts as a health check for the daemon
  too.
- allows for monitoring at the application side, since custom monitoring
  can't really be a part of this generic and open sourced daemon.

--- src/repmgr_to_zk/zk.clj
+++ src/repmgr_to_zk/zk.clj
@@ -9,9 +9,6 @@

 (defn get-client []
   (zk/connect (config/lookup :zookeeper :connect)))
-
-(defn get-master [client path]
-  (some->> (zk/data client path) :data zk-data/to-string))

 (defn create [client path]
   (let [paths (->> (s/split path #"/")
@@ -25,9 +22,7 @@
         version (:version (zk/exists client path))]
     (when-not (some? version)
       (create client path))
-    (when-not (= (get-master client path)
-                 master-ip)
-      (zk/set-data client
-                   path
-                   (zk-data/to-bytes master-ip)
-                   version))))
+    (zk/set-data client
+                 path
+                 (zk-data/to-bytes master-ip)
+                 version)))


logging errors

logging errors

--- src/es/node.clj
+++ src/es/node.clj
@@ -38,7 +38,7 @@
        :on-error
        :max-retry 5
        :message "Error while trying to connect to Elasticsearch"
-       :log-errors false
+       :log-errors true
        :retry-delay [:random-range :min 2000 :max 5000])))

 (defn stop


Fix code style on suricatta.async ns.

Fix code style on suricatta.async ns.

--- src/suricatta/async.clj
+++ src/suricatta/async.clj
@@ -30,41 +30,41 @@
 (defn execute
   "Execute a query asynchronously returning a channel."
   ([ctx q]
-     (execute ctx q {}))
+   (execute ctx q {}))
   ([ctx q opts]
-     (let [c   (or (:chan opts) (chan))
-           act (.-act ctx)]
-       (send-off act (fn [counter]
-                       (let [result (exc/try-on (sc/execute ctx q))]
-                         (put! c result)
-                         (close! c))
-                       (inc counter)))
-       c)))
+   (let [c   (or (:chan opts) (chan))
+         act (.-act ctx)]
+     (send-off act (fn [counter]
+                     (let [result (exc/try-on (sc/execute ctx q))]
+                       (put! c result)
+                       (close! c))
+                     (inc counter)))
+     c)))

 (defn fetch
   "Execute a query asynchronously returning a channel with
   streaming results."
   ([ctx q]
-     (fetch ctx q {}))
+   (fetch ctx q {}))
   ([ctx q opts]
-     (let [c    (or (:chan opts) (chan))
-           act  (.-act ctx)
-           opts (dissoc opts :chan)]
-       (send-off act (fn [counter]
-                       (try
-                         (sc/atomic ctx
-                           (with-open [cursor (sc/fetch-lazy ctx q opts)]
-                             (reduce (fn [acc v]
-                                       (if-not (put! c (exc/success v))
-                                         (reduced nil)
-                                         nil))
-                                     nil
-                                     (sc/cursor->lazyseq cursor opts))
-                             (close! c)
-                             (inc counter)))
-                         (catch Exception e
-                           (put! c (exc/failure e))
-                           (close! c)))
-                       (inc counter)))
-       c)))
+   (let [c (or (:chan opts) (chan))
+         act (.-act ctx)
+         opts (dissoc opts :chan)]
+     (send-off act (fn [counter]
+                     (try
+                       (sc/atomic ctx
+                                  (with-open [cursor (sc/fetch-lazy ctx q opts)]
+                                    (reduce (fn [acc v]
+                                              (if-not (put! c (exc/success v))
+                                                (reduced nil)
+                                                nil))
+                                            nil
+                                            (sc/cursor->lazyseq cursor opts))
+                                    (close! c)
+                                    (inc counter)))
+                       (catch Exception e
+                         (put! c (exc/failure e))
+                         (close! c)))
+                     (inc counter)))
+     c)))


Add logs to debug issue

Add logs to debug issue

Debug https://flowhelp.reamaze.com/admin/conversations/akvolumen-support-request-number-207626-from-annabelle-at-akvo-dot-org

--- backend/src/akvo/lumen/lib/update.clj
+++ backend/src/akvo/lumen/lib/update.clj
@@ -36,13 +36,17 @@
                                 (cond-> {:id (get column "columnName")
                                          :type (get column "type")}
                                   (contains? column "key") (assoc :key (boolean (get column "key")))))
-                              imported-columns)]
-    (set/subset? (set (map #(select-keys % [:id :type]) imported-columns))
-                 (set (map #(select-keys % [:id :type])
-                           ;; https://github.com/akvo/akvo-lumen/issues/1923
-                           ;; https://github.com/akvo/akvo-lumen/issues/1926
-                           ;; remove this map conversion logic once #1926 is finished
-                           (map #(update % :id name) columns))))))
+                              imported-columns)
+        compatible? (set/subset? (set (map #(select-keys % [:id :type]) imported-columns))
+                         (set (map #(select-keys % [:id :type])
+                                   ;; https://github.com/akvo/akvo-lumen/issues/1923
+                                   ;; https://github.com/akvo/akvo-lumen/issues/1926
+                                   ;; remove this map conversion logic once #1926 is finished
+                                   (map #(update % :id name) columns))))]
+    (if compatible?
+      compatible?
+      (do (log/error :imported-columns imported-columns)
+          (log/error :columns columns)))))

 (defn- do-update [tenant-conn import-config dataset-id data-source-id job-execution-id data-source-spec]
   (jdbc/with-db-transaction [conn tenant-conn]


Move test functions

Move test functions

--- test/expound/alpha_test.cljc
+++ test/expound/alpha_test.cljc
@@ -21,7 +21,7 @@
             #?(:clj [orchestra.spec.test :as orch.st]
                :cljs [orchestra-cljs.spec.test :as orch.st])))

-(def num-tests 1) ;; TODO - restore
+(def num-tests 30)

 (use-fixtures :once
   test-utils/check-spec-assertions
@@ -2497,6 +2497,13 @@
   [f]
   (f 1))

+(s/fdef results-str-missing-fn
+        :args (s/cat :x int?))
+
+(s/fdef results-str-missing-args-spec
+        :ret int?)
+(defn results-str-missing-args-spec [] 1)
+
 (deftest explain-results
   (testing "explaining results with non-expound printer"
     ;; Ensure this doesn't throw exception
@@ -2691,9 +2698,6 @@
 ")
          (binding [s/*explain-out* expound/printer]
            (expound/explain-results-str (orch.st/with-instrument-disabled (st/check `results-str-fn6)))))))
-  ;; TODO - move above
-  (s/fdef results-str-missing-fn
-          :args (s/cat :x int?))
   (testing "no-fn failure"
     (is (= #?(:clj "== Checked expound.alpha-test/results-str-missing-fn

@@ -2713,10 +2717,6 @@
 ")
            (binding [s/*explain-out* expound/printer]
              (expound/explain-results-str (orch.st/with-instrument-disabled (st/check `results-str-missing-fn)))))))
-  ;; TODO - move to top
-  (s/fdef results-str-missing-args-spec
-          :ret int?)
-  (defn results-str-missing-args-spec [] 1)
   (testing "no args spec"
     (is (= (pf "== Checked expound.alpha-test/results-str-missing-args-spec

@@ -2728,25 +2728,6 @@
 ")
            (binding [s/*explain-out* expound/printer]
              (expound/explain-results-str (orch.st/with-instrument-disabled (st/check `results-str-missing-args-spec))))))))
-
-(comment
-  (ns user)
-
-  (s/fdef results-str-fn6
-          :ret any?)
-  (defn results-str-fn6
-    [f]
-    (f 1))
-  (require '[clojure.spec.alpha :as s])
-  (require '[clojure.spec.test.alpha :as st])
-  (explain-results (st/check `results-str-fn6))
-
-  (require '[expound.paths])
-  (require '[expound.alpha :as expound])
-  (require '[orchestra.spec.test :as orch.st])
-  (expound/explain-results
-   (orch.st/with-instrument-disabled (st/check `expound.paths/prefix-path?
-                                               {:clojure.spec.test.check/opts {:num-tests 10}}))))

 #?(:clj (deftest explain-results-gen
           (checking


Modified first test.

Modified first test.

--- test/guymover/util_test.cljc
+++ test/guymover/util_test.cljc
@@ -3,6 +3,6 @@
             [expectations :as e]))

 (e/expect "#FFFFFF"
-          (count (sut/clr-hex [255 255 255])))
+          (sut/clr-hex [255 255 255]))

 (e/expect empty? (list))


Test for add-access-token

Test for add-access-token

--- test/myshelf/test/worker.clj
+++ test/myshelf/test/worker.clj
@@ -15,6 +15,42 @@

 (use-fixtures :each
   db/clean-db-fixture)
+
+(deftest t-add-access-token
+  ;; no mocking; get-access-token and get-user-id should throw
+  ;; create new user
+  (let [handle "merlin"
+        handle-key (keyword handle)]
+    (user/create-user :handle handle :last-tweet 256)
+    ;; add-access-token should return false
+    (is (not (add-access-token handle {})))
+    ;; user in db should not have oauth
+    (let [db-user (user/find-by-handle handle)]
+      (is (nil? (:oauth_token db-user)))
+      (is (nil? (:oauth_token_secret db-user))))
+    ;; mock out get-access-token and get-user-id to pass
+    (let [access-token {:oauth_token "token"
+                        :oauth_token_secret "secret"}
+          user-id "1337"]
+      (with-redefs [get-access-token (fn [& args] access-token)
+                    get-user-id (fn [& args] user-id)]
+        ;; add-access-token should return updated creds
+        (let [ret (add-access-token handle {})]
+          (is ret)
+          (is (= access-token (:access-token (handle-key ret))))
+          (is (= user-id (:user-id (handle-key ret))))))
+      ;; user in db should have oauth
+      (let [db-user (user/find-by-handle handle)]
+        (is (= (:oauth_token access-token)
+               (:oauth_token db-user)))
+        (is (= (:oauth_token_secret access-token)
+               (:oauth_token_secret db-user))))
+      ;; no mocking out
+      ;; add-access-token should return db creds
+      (let [ret (add-access-token handle {})]
+        (is ret)
+        (is (= access-token (:access-token (handle-key ret))))
+        (is (= user-id (:user-id (handle-key ret))))))))

 (deftest t-goodreads-access-for-user
   ;; arbitrary handles should be false


`+into`

`+into`

--- test/such/f_wide_domains.clj
+++ test/such/f_wide_domains.clj
@@ -67,3 +67,8 @@
       (subject/+find-var 'clojure.core "derp/odd?") => #'clojure.core/odd?
       (subject/+find-var "clojure.core" ::odd?) => #'clojure.core/odd?
       (subject/+find-var *ns* 'clojure.set/intersection) => #'intersection)))
+
+(fact +into
+  (let [result (subject/+into [] [1] (list 3 4))]
+    result => [1 3 4]
+    result => vector?))


-(defn parse),(defn morph-ps),(defn fo-ps)

--- test/babel/test/it.cljc
+++ test/babel/test/it.cljc
@@ -3,7 +3,7 @@
   (:require
    [babel.directory :refer [models]]
    [babel.generate :as generate]
-   [babel.italiano :as italiano :refer [analyze generate morph preprocess]]
+   [babel.italiano :as italiano :refer [analyze generate morph morph-ps parse preprocess]]
    [babel.italiano.grammar :as grammar]
    [babel.italiano.lexicon :as lexicon]
    [babel.italiano.morphology :as morph :refer [analyze-regular]]
@@ -41,18 +41,6 @@

 ;; (repeatedly #(println (morph (time (generate reflexive-passato-is-slow)))))
-
-(defn parse
-  ([spec]
-   (italiano/parse spec model))
-  ([spec model]
-   (italiano/parse spec model)))
-
-(defn morph-ps [expr]
-  (italiano/morph-ps expr model))
-
-(defn fo-ps [expr]
-  (morph-ps expr))

 (deftest analyze-1
   (let [singular (analyze "compito")


clean up references to infinity for demand ugen examples

--- test/example/demand.clj
+++ test/example/demand.clj
@@ -6,13 +6,11 @@
 ; when it is "demanded" of them.  This is normally done using the
 ; demand ugen, which will pull from its arguments when triggered.

-(def inf Float/POSITIVE_INFINITY)
-
 ; Play a sequence of notes, where the demand ugen pulls them
 ; each time it gets a trigger.
 (demo 2
       (let [trig (impulse:kr 8)
-            freqs (dseq [440 880 220] Float/POSITIVE_INFINITY)
+            freqs (dseq [440 880 220] INF)
             note-gen (demand:kr trig 0 freqs)
             src (sin-osc note-gen)]
         (* [0.1 0.1] src)))
@@ -20,7 +18,7 @@
 ; Randomize the sequence of notes
 (demo 2
       (let [trig (impulse:kr 8)
-            freqs (drand [440 880 220] Float/POSITIVE_INFINITY)
+            freqs (drand [440 880 220] INF)
             note-gen (demand:kr trig 0 freqs)
             src (sin-osc note-gen)]
         (pan2 (* 0.1 src))))
@@ -28,7 +26,7 @@
 ; Shuffle the notes, but then repeat them in the same order
 (demo 4
       (let [trig (impulse:kr 3)
-            freqs (dseq (dshuf [440 880 220] 2) Float/POSITIVE_INFINITY)
+            freqs (dseq (dshuf [440 880 220] 2) INF)
             note-gen (demand:kr trig 0 freqs)
             src (sin-osc [(* 1.01 note-gen) note-gen])]
         (* 0.2 src)))
@@ -37,7 +35,7 @@
 ; the others have played.
 (demo 2
       (let [trig (impulse:kr 8)
-            freqs (dxrand [440 880 220] Float/POSITIVE_INFINITY)
+            freqs (dxrand [440 880 220] INF)
             note-gen (demand:kr trig 0 freqs)
             src (sin-osc note-gen)]
         (* [0.2 0.2] src)))
@@ -99,8 +97,7 @@
 ; Demanding noise...
 (demo 2
       (let [trig (impulse:kr 2)
-            freqs (dwhite 0 20 Float/POSITIVE_INFINITY)
+            freqs (dwhite 0 20 INF)
             note-gen (+ 340 (* 30 (demand:kr trig 0 freqs)))
             src (sin-osc note-gen)]
         (pan2 (* 0.1 src))))
-


[skip ci] ws

[skip ci] ws

--- test/java_time_test.clj
+++ test/java_time_test.clj
@@ -1,8 +1,7 @@
 (ns java-time-test
   (:require [clojure.test :refer :all]
             [java-time.util :as jt.u]
-            [java-time :as j]
-            )
+            [java-time :as j])
   (:import java.util.Locale))

 (def clock (j/fixed-clock "2015-11-26T10:20:30.000000040Z" "UTC"))


Cleanup insert-* tests: use vectors, add explanations

--- test/toucan/db_test.clj
+++ test/toucan/db_test.clj
@@ -170,38 +170,47 @@

 ;; TODO - Test simple-delete!

-;; Test simple-insert-many!
-(expect
- '(4 5)
+;;; Test simple-insert-many!
+
+;; It must return the inserted ids
+(expect
+ [5]
+ (test/with-clean-db
+   (db/simple-insert-many! Category [{:name "seafood" :parent-category-id 100}])))
+
+;; it must not fail when using SQL function calls.
+(expect
+ [4 5]
  (test/with-clean-db
    (db/simple-insert-many! User [{:first-name "Grass" :last-name #sql/call [:upper "Hopper"]}
                                  {:first-name "Ko" :last-name "Libri"}])))

-(expect
- '(5)
- (test/with-clean-db
-   (db/simple-insert-many! Category [{:name "seafood" :parent-category-id 100}])))
-
-;; Test insert-many!
-(expect
- '(4 5)
+;;; Test insert-many!
+
+;; It must return the inserted ids, it must not fail when using SQL function calls.
+(expect
+ [4 5]
  (test/with-clean-db
    (db/insert-many! User [{:first-name "Grass" :last-name #sql/call [:upper "Hopper"]}
                           {:first-name "Ko" :last-name "Libri"}])))

-(expect
- AssertionError ;; triggered by pre-insert hook
+;; It must call pre-insert hooks
+(expect
+ AssertionError ; triggered by pre-insert hook
  (test/with-clean-db
    (db/insert-many! Category [{:name "seafood" :parent-category-id 100}])))

 ;; TODO - Test simple-insert!

-;; Test insert!
+;;; Test insert!
+
+;; It must return the inserted model
 (expect
  #toucan.test_models.user.UserInstance{:id 4, :first-name "Trash", :last-name "Bird"}
  (test/with-clean-db
    (db/insert! User {:first-name "Trash", :last-name "Bird"})))

+;; The returned data must match what's been inserted in the table
 (expect
  #toucan.test_models.user.UserInstance{:id 4, :first-name "Grass", :last-name "HOPPER"}
  (test/with-clean-db


new default file

new default file

--- shared/default.clj
+++ shared/default.clj
@@ -1,3 +1,4 @@
+;Here we define a bunch of variables to make our config shorter and easier to understand
 (def elb-8080->8080  {:LoadBalancerPort 8080
                       :InstancePort 8080
                       :Protocol "http"
@@ -7,9 +8,11 @@
                            :UnhealthyThreshold 4
                            :Interval 12
                            :Timeout 5})
-(def elb-sg-name (str $app-name "-lb"))
-
-{:SecurityGroups [{:GroupName elb-sg-name
+(def elb-sg-name (str $app-name "-lb"));$app-name is made available by Shuppet
+;Here we define a configuration as a Clojure map, it must be at the end of the file to be used by Shuppet.
+;Security group doc http://docs.aws.amazon.com/AWSEC2/latest/APIReference/Welcome.html
+{:SecurityGroups [;Define a security group for our elb
+                  {:GroupName elb-sg-name
                    :GroupDescription (str "Security group for load balancer " $app-name)
                    :VpcId $vpc-id
                    :Ingress [{:IpRanges $private-ips
@@ -17,6 +20,7 @@
                               :FromPort 8080
                               :ToPort 8080}]
                    :Egress $sg-egress-all}
+                  ;Define a security group for our application so only our elb can talk to it
                   {:GroupName $app-name
                    :GroupDescription (str "Security group for application " $app-name)
                    :VpcId $vpc-id
@@ -25,16 +29,18 @@
                               :FromPort 8080
                               :ToPort 8080}]
                    :Egress $sg-egress-all}]
-
+;Elastic load balancer doc http://docs.aws.amazon.com/ElasticLoadBalancing/latest/APIReference/Welcome.html
  :LoadBalancer {:LoadBalancerName $app-name
                 :Listeners [elb-8080->8080]
                 :SecurityGroups [elb-sg-name $sg-ssh]
                 :Subnets $elb-subnets-be
                 :Scheme "internal"
                 :HealthCheck elb-healthcheck-ping}
-
+;IAM role doc http://docs.aws.amazon.com/IAM/latest/APIReference/Welcome.html
  :Role {:RoleName $app-name
-        :Policies  [{:PolicyName "full-access"
-                     :PolicyDocument [{:Action "*",
-                                       :Resource "*"}]}]}
- }
+        :Policies  [{:PolicyName "ec2-describe"
+                     :PolicyDocument [{:Effect "Allow"
+                                       :Action "EC2:Describe*"
+                                       :Resource "*"}]
+; This tool http://awspolicygen.s3.amazonaws.com/policygen.html helps to create policy documents
+                     }]}


1.8 -> 1.9

1.8 -> 1.9

--- exercises/armstrong-numbers/project.clj
+++ exercises/armstrong-numbers/project.clj
@@ -1,4 +1,4 @@
 (defproject armstrong-numbers "0.1.0-SNAPSHOT"
   :description "armstrong-numbers exercise"
   :url "https://github.com/exercism/clojure/tree/master/exercises/armstrong-numbers"
-  :dependencies [[org.clojure/clojure "1.8.0"]])
+  :dependencies [[org.clojure/clojure "1.9.0"]])