moved HTTP GET and supporting logic into its own function;

--- src/mustached_hipster/core.clj
+++ src/mustached_hipster/core.clj
@@ -2,6 +2,17 @@
    (:require [clojure.string  :as s    :only [replace split-lines]])
    (:require [clj-http.client :as http :only [get]])
    (:gen-class))
+
+(defn get-playlist
+   [m3u8]
+
+   (let
+      [before (System/nanoTime)]
+
+      (let
+         [response (http/get m3u8)]
+         (println "the request took" (* (- (System/nanoTime) before) 1e-9) "seconds")
+         response)))

 (defn -main
    [url]
@@ -9,15 +20,10 @@
    ;; work around dangerous default behaviour in Clojure
    (alter-var-root #'*read-eval* (constantly false))

-   (let
-      [before (System/nanoTime)]
-
-      (spit "foo.txt"
-         (apply str (take 10
-            (map
-               #(s/replace % #"\?.*" "\n")
-               (filter
-                  #(not= \# (first %))
-                  (s/split-lines (:body (http/get url))))))))
-
-      (println "the whole thing took" (* (- (System/nanoTime) before) 1e-9) "seconds")))
+   (spit "foo.txt"
+      (apply str (take 10
+         (map
+            #(s/replace % #"\?.*" "\n")
+            (filter
+               #(not= \# (first %))
+               (s/split-lines (:body (get-playlist url)))))))))


change noise seed from int to long

change noise seed from int to long

as per processing docs noiseSeed takes a long https://processing.github.io/processing-javadocs/core/

--- src/cljc/quil/core.cljc
+++ src/cljc/quil/core.cljc
@@ -2587,7 +2587,7 @@
   constant to return the same pseudo-random numbers each time the
   software is run."
   [val]
-  (.noiseSeed (ap/current-applet) (int val)))
+  (.noiseSeed (ap/current-applet) (long val)))

 (defn
   ^{:requires-bindings true


CLJS-330: fix (hash js/undefined)

CLJS-330: fix (hash js/undefined)

--- src/cljs/cljs/core.cljs
+++ src/cljs/cljs/core.cljs
@@ -395,7 +395,8 @@

 (extend-type default
   IHash
-  (-hash [o] (goog.getUid o)))
+  (-hash [o]
+    (if (nil? o) 0 (goog.getUid o))))

 ;;this is primitive because & emits call to array-seq
 (defn inc


missing data needed for filtering out private entries.

--- src/oc/storage/util/search.clj
+++ src/oc/storage/util/search.clj
@@ -47,7 +47,7 @@
 (defn index-all-entries [conn]
   (let [now (db-common/current-timestamp)]
     (doseq [org (org-res/list-orgs conn [:team-id])]
-      (let [boards (board-res/list-boards-by-org conn (:uuid org) [:access])
+      (let [boards (board-res/list-boards-by-org conn (:uuid org) [:access :viewers :authors])
             allowed-boards (vec (map :uuid boards))]
         (doseq [board boards]
           (let [entries (entry-res/list-entries-by-board conn (:uuid board))]


join function

join function

--- src/cljx/cats/core.cljx
+++ src/cljx/cats/core.cljx
@@ -93,6 +93,11 @@
 ;; Monadic functions
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

+(defn join
+  "Remove one level of monadic structure."
+  [mv]
+  (bind mv identity))
+
 (defn =<<
   "Same as the two argument version of `>>=` but with the
   arguments interchanged."


Remove messenger from state event now that we can message downstream via triggers.

--- src/onyx/peer/window_state.clj
+++ src/onyx/peer/window_state.clj
@@ -301,8 +301,7 @@
 (defn assign-windows [state event-type]
   (let [messenger (get-messenger state)
         event (get-event state)
-        ;; FIXME: do we want messenger in the state event
-        state-event (assoc (new-state-event event-type event) :messenger messenger)]
+        state-event (new-state-event event-type event)]
     (if (= :new-segment event-type)
       (process-segment state state-event)
       (process-event state state-event))))


Switch to new default-vals.

Switch to new default-vals.

--- src/onyx/plugin/bookkeeper.clj
+++ src/onyx/plugin/bookkeeper.clj
@@ -6,7 +6,7 @@
             [onyx.peer.pipeline-extensions :as p-ext]
             [onyx.peer.function :as function]
             [onyx.types :as t]
-            [onyx.static.default-vals :refer [defaults]]
+            [onyx.static.default-vals :refer [default-vals]]
 	    [clojure.core.async.impl.protocols :refer [closed?]]
             [onyx.log.zookeeper :as log-zk]
             [onyx.log.curator :as zk]
@@ -177,8 +177,8 @@
                 bookkeeper/zookeeper-addr bookkeeper/deserializer-fn bookkeeper/no-recovery?] :as defaulted-task-map}
         (-> task-map
             (default-value :bookkeeper/read-max-chunk-size 1000)
-            (default-value :onyx/batch-timeout (:onyx/batch-timeout defaults))
-            (default-value :bookkeeper/zookeeper-ledgers-root-path (:onyx.bookkeeper/zk-ledgers-root-path defaults))
+            (default-value :onyx/batch-timeout (:onyx/batch-timeout default-vals))
+            (default-value :bookkeeper/zookeeper-ledgers-root-path (:onyx.bookkeeper/zk-ledgers-root-path default-vals))
             (default-value :bookkeeper/ledger-start-id 0)
             (default-value :bookkeeper/ledger-end-id Double/POSITIVE_INFINITY)
             (default-value :bookkeeper/no-recovery-empty-read-back-off 500)
@@ -291,9 +291,9 @@
     @drained?))

 (defn read-ledgers [{:keys [onyx.core/task-map onyx.core/log onyx.core/task-id] :as pipeline-data}]
-  (let [max-pending (or (:onyx/max-pending task-map) (:onyx/max-pending defaults))
+  (let [max-pending (or (:onyx/max-pending task-map) (:onyx/max-pending default-vals))
         batch-size (:onyx/batch-size task-map)
-        batch-timeout (or (:onyx/batch-timeout task-map) (:onyx/batch-timeout defaults))
+        batch-timeout (or (:onyx/batch-timeout task-map) (:onyx/batch-timeout default-vals))
         read-ch (chan (or (:bookkeeper/read-buffer task-map) 1000))
         retry-ch (chan (* 2 max-pending))
         error (atom nil)
@@ -430,7 +430,7 @@
   (validate-task-map! task-map BookKeeperOutput)
   (let [onyx-id (:onyx/tenancy-id peer-opts)
         ledgers-root-path (or (:bookkeeper/zookeeper-ledgers-root-path task-map)
-                              (:onyx.bookkeeper/zk-ledgers-root-path defaults))
+                              (:onyx.bookkeeper/zk-ledgers-root-path default-vals))
         zookeeper-addr (:bookkeeper/zookeeper-addr task-map)
         ;; FIXME, parameterize these in the task-map
         zookeeper-timeout 60000
@@ -456,7 +456,7 @@
   [{:keys [onyx.core/task-map onyx.core/log onyx.core/peer-opts onyx.core/task-id onyx.core/job-id] :as event} lifecycle]
   (let [onyx-id (:onyx/tenancy-id peer-opts)
         ledgers-root-path (or (:bookkeeper/zookeeper-ledgers-root-path lifecycle)
-                              (:onyx.bookkeeper/zk-ledgers-root-path defaults))
+                              (:onyx.bookkeeper/zk-ledgers-root-path default-vals))
         zookeeper-addr (:bookkeeper/zookeeper-addr lifecycle)
         ;; FIXME, parameterize these in the lifecycle
         zookeeper-timeout 60000


my ocd

my ocd

--- src/crawler/dom.clj
+++ src/crawler/dom.clj
@@ -723,6 +723,7 @@
                         (= mp p))
                       muscle-positions)))
              positions))
+
      :avoid (map
              (fn [p]
                [p (nth


(MAINT) Fix ezbake version in manifest

(MAINT) Fix ezbake version in manifest

--- src/puppetlabs/ezbake/core.clj
+++ src/puppetlabs/ezbake/core.clj
@@ -80,13 +80,13 @@
   (let [iter (fs/iterate-dir dir)]
     (mapcat files-from-dir-iter iter)))

-(defn get-ezbake-sha
-  "Get the commit SHA of the current ezbake working copy, plus an asterisk if the
-  working tree is dirty."
-  []
-  (let [sha     (str/trim (:out (exec/exec "git" "rev-parse" "HEAD")))
-        dirty?  (not= "" (str/trim (:out (exec/exec "git" "diff" "--shortstat"))))]
-    (str sha (if dirty? "*" ""))))
+(defn get-ezbake-version
+  "Get the version number of the ezbake plugin being used for this build."
+  [lein-project]
+  (->> (:plugins lein-project)
+       (filter #(= 'puppetlabs/lein-ezbake (first %)))
+       first
+       second))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; General Staging Helper functions
@@ -151,7 +151,7 @@

 %s
 "
-            (get-ezbake-sha)
+            (get-ezbake-version lein-project)
             (:group lein-project)
             (:name lein-project)
             (:version lein-project)


CMR-1199: Updated comment

CMR-1199: Updated comment

--- ingest-app/src/cmr/ingest/api/routes.clj
+++ ingest-app/src/cmr/ingest/api/routes.clj
@@ -289,7 +289,8 @@
     (route/not-found "Not Found")))

 (defn default-format-fn
-  "Determine the format that results should be returned in based on the request URI."
+  "Determine the format that results should be returned in based on the request URI and http
+  actions."
   [{:keys [uri request-method]}]
   (if (or (re-find #"validate" uri)
           (some #{request-method} #{:put :delete}))


Tabular syntactic sugar notes weren't actually being printed

--- src/midje/ideas/tabular.clj
+++ src/midje/ideas/tabular.clj
@@ -18,12 +18,12 @@
 (def #^:private deprecation-hack:file-position (atom ""))

 (defn- remove-pipes+where [table]
-  (when (and false (#{:where 'where} (first table)))
-    (println "The `where` syntactic sugar for tabular facts is deprecated and will be removed in Midje 1.4."
+  (when (#{:where 'where} (first table))
+    (println "The `where` syntactic sugar for tabular facts is deprecated and will be removed in Midje 1.6."
       @deprecation-hack:file-position))

-  (when (and false (some #(= % '|) table))
-    (println "The `|` syntactic sugar for tabular facts is deprecated and will be removed in Midje 1.4."
+  (when (some #(= % '|) table)
+    (println "The `|` syntactic sugar for tabular facts is deprecated and will be removed in Midje 1.6."
       @deprecation-hack:file-position))

   (letfn [(strip-off-where [x] (if (#{:where 'where} (first x)) (rest x) x))]


Missing (= ...)

Missing (= ...)

--- test/clj_http/test/core.clj
+++ test/clj_http/test/core.clj
@@ -421,7 +421,7 @@
                                      :http-conn conn})))})]
     (is (= 200 status))
     (is (= 2 (count @saved-ctx)))
-    (is (count trace-redirects) (count @saved-ctx))
+    (is (= (count trace-redirects) (count @saved-ctx)))
     (is (every? #(= 18080 (:remote-port %)) @saved-ctx))
     (is (every? #(instance? HttpConnection (:http-conn %)) @saved-ctx))))


New test: test-get-port-special-cases

New test: test-get-port-special-cases

--- test/clouseau/test_core.clj
+++ test/clouseau/test_core.clj
@@ -98,12 +98,21 @@
 (deftest test-get-port
     "Check the function clouseau.core/get-port."
     (testing "the function clouseau.core/get-port."
+        (is (= (get-port "1")     "1"))
+        (is (= (get-port "2")     "2"))
+        (is (= (get-port "3000")  "3000"))
+        (is (= (get-port "65534") "65534"))
+        (is (= (get-port "65535") "65535"))))
+
+(deftest test-get-port-special-cases
+    "Check the function clouseau.core/get-port."
+    (testing "the function clouseau.core/get-port."
         (is (= (get-port nil)     "3000"))
         (is (= (get-port "")      "3000"))
-        (is (= (get-port "1")     "1"))
+        (is (= (get-port 0)       "3000"))
         (is (= (get-port 1)       "3000"))
-        (is (= (get-port "3000")  "3000"))
-        (is (= (get-port "65535") "65535"))))
+        (is (= (get-port 65535)   "3000"))
+        (is (= (get-port 65536)   "3000"))))

 (deftest test-get-port-negative
     "Check the function clouseau.core/get-port."


Check that symbols refer to aliases.

Check that symbols refer to aliases.

--- src/smallex/grammar_checks.clj
+++ src/smallex/grammar_checks.clj
@@ -72,3 +72,29 @@
   (mapcat check-expr-arg-type
           (concat (vals (:aliases grammar))
                   (vals (:rules grammar)))))
+
+(defn- check-expr-symbol-refs
+  "Recursively checks for symbols not referencing aliases, and returns a lazy
+  seq of ExceptionInfos of culprits."
+  [g expr]
+  (cond (and (= :symbol (:type expr))
+             (not (contains? (:alises g) (:value expr))))
+        (if (contains? (:rules g) (:value expr))
+          (list (ex-info "Symbol cannot refer to a rule definition, must be an alias."
+                         {:type :symbol-ref, :expr expr}))
+          (list (ex-info "Couldn't find the definition for symbol."
+                         {:type :symbol-ref, :expr expr})))
+        ;; ^^ TODO: Damerau-Levensthein? =)
+        (and (= :op (:type expr))
+             (not (-> expr meta :alias-expansion)))
+        (mapcat #(check-expr-symbol-refs g %) (:args expr))
+        :else nil))
+
+(defn check-symbol-references
+  "Checks that all symbols refer to aliases, and creates understandable error
+  messages for those which doesn't. Returns a lazy seq of all non-alias
+  references as ExceptionInfos. Does not require the aliases to be expanded."
+  [grammar]
+  (mapcat #(check-expr-symbol-refs grammar %)
+          (concat (vals (:aliases grammar))
+                  (vals (:rules grammar)))))


remove duplicate test

remove duplicate test

--- test/crucible/core_test.clj
+++ test/crucible/core_test.clj
@@ -1,52 +0,0 @@
-(ns crucible.core-test
-  (:require [clojure.test :refer :all]
-            [crucible.core :refer :all]))
-
-(deftest value-conversions
-
-  (testing "string value"
-    (is (= "foo" (encode "foo"))))
-
-  (testing "ref value"
-    (is (= {"Ref" "x"} (encode [:ref "x"]))))
-
-  (testing "select fn get-att value"
-    (is (= {"Fn::GetAtt" ["resource" "foo"]}
-           (encode [:ref :resource :foo]))))
-
-  (testing "pseudo-account value"
-    (is (= {"Ref" "AWS::AccountId"} (encode [:pseudo :account-id]))))
-
-  (testing "pseudo-region value"
-    (is (= {"Ref" "AWS::Region"} (encode [:pseudo :region]))))
-
-  (testing "pseudo-notification-arns value"
-    (is (= {"Ref" "AWS::NotificationARNs"} (encode [:pseudo :notification-arns]))))
-
-  (testing "no-value value"
-    (is (= {"Ref" "AWS::NoValue"} (encode [:pseudo :no-value]))))
-
-  (testing "stack-id value"
-    (is (= {"Ref" "AWS::StackId"} (encode [:pseudo :stack-id]))))
-
-  (testing "stack-name value"
-    (is (= {"Ref" "AWS::StackName"} (encode [:pseudo :stack-name]))))
-
-  (testing "join fn strings value"
-    (is (= {"Fn::Join" ["." ["foo" "bar"]]}
-           (encode [:fn [:join {:delimiter "." :values ["foo" "bar"]}]]))))
-
-  (testing "select fn string value"
-    (is (= {"Fn::Select" ["1" ["foo" "bar"]]}
-           (encode [:fn [:select {:index "1" :values ["foo" "bar"]}]]))))
-
-  (testing "select fn select value"
-    (is (= {"Fn::Select" ["1" ["foo" {"Ref" "blah"}]]}
-           (encode [:fn [:select {:index "1" :values ["foo" [:ref :blah]]}]]))))
-
-  (testing "property value walk"
-    (is (= {"Fn::Join" ["-" [{"Ref" "foo"} "bar" {"Ref" "AWS::AccountId"}]]}
-           (encode [:fn [:join {:delimiter "-"
-                                :values [[:ref :foo]
-                                         "bar"
-                                         [:pseudo :account-id]]}]])))))


wrong binding name

wrong binding name

--- src/onyx/plugin/datomic.clj
+++ src/onyx/plugin/datomic.clj
@@ -210,7 +210,7 @@
   (let [start-tx (:datomic/log-start-tx task-map)
         max-tx (:datomic/log-end-tx task-map)
         read-size (or (:datomic/read-max-chunk-size task-map) 1000)
-        batch-timeout (or (:onyx/batch-timeout catalog-entry) (:onyx/batch-timeout defaults))
+        batch-timeout (or (:onyx/batch-timeout task-map) (:onyx/batch-timeout defaults))
         initial-backoff 1
         ch (:read-ch pipeline)
         conn (safe-connect task-map)


Add a test for the connection pool with invalid hosts

--- test/picard/test/client.clj
+++ test/picard/test/client.clj
@@ -788,3 +788,45 @@
          :done      nil)))

   (is (= 3 (count (netty-connect-evts)))))
+
+(defcoretest doesnt-decrecement-pool-count-for-failed-connections
+  [_ ch1 ch2 ch3]
+  :slow-hello-world
+
+  (let [pool (client/mk-pool {:max-connections-per-address 1})]
+    ;; bogus request
+    (client/request
+     ["localhost" 666]
+     [{:path-info "/"
+       :request-method "GET"}]
+     {:pool pool}
+     (fn [_]
+       (fn [evt val]
+         (enqueue ch1 [evt val]))))
+
+
+    (doseq [ch [ch2 ch3]]
+      (client/request
+       ["localhost" 4040]
+       [{:path-info      "/"
+         :request-method "GET"}]
+       {:pool pool}
+       (fn [_]
+         (fn [evt val]
+           (enqueue ch [evt val])))))
+
+    (is (next-msgs-for
+         ch1
+         :abort #(instance? Exception %)))
+
+    (is (next-msgs-for
+         ch2
+         :connected nil
+         :response  :dont-care
+         :done      nil))
+
+    (is (next-msgs-for
+         ch3
+         :abort #(instance? Exception %)))
+
+    (picard/shutdown-pool pool)))


allow ugen searches to also match the ugen name in addition to its full doc string

--- src/overtone/repl/ugens.clj
+++ src/overtone/repl/ugens.clj
@@ -15,15 +15,16 @@
        terms))

 (defn- find-matching-ugen-specs
-  "Find ugen specs by searching their :full-doc strings for occurances of all the
-  terms. Terms can either be strings or regexp patterns."
+  "Find ugen specs by searching their :full-doc and :name strings for occurances
+   of all the terms. Terms can either be strings or regexp patterns."
   [terms]
   (let [regexps (map-terms-to-regexps terms)]
     (sort-by
      #(:name %)
      (map #(second %)
           (filter (fn [[key spec]]
-                    (let [docstr  (get spec :full-doc)
+                    (let [docstr  (:full-doc spec)
+                          docstr  (str docstr " " (overtone-ugen-name (:name spec)))
                           matches (filter #(re-find % docstr) regexps)]
                       (= matches regexps)))
                   (combined-specs))))))


Make commutative featurec test pass

Make commutative featurec test pass

--- src/desdemona/query.clj
+++ src/desdemona/query.clj
@@ -65,7 +65,8 @@
       `(l/featurec ~lvar {~attr ~value}))

     [((= value ((attr lvar) :seq)) :seq)]
-    `(l/featurec ~lvar {~attr ~value})
+    (let [lvar (free-sym lvar)]
+      `(l/featurec ~lvar {~attr ~value}))

     [(('and & terms) :seq)]
     (let [logic-terms (map dsl->logic terms)]


Make the tests pass

Make the tests pass

--- src/desdemona/query.clj
+++ src/desdemona/query.clj
@@ -37,11 +37,14 @@
   it to correctly bound the number of answers. This helps us limit how
   long it takes to query."
   [n-answers logic-query events]
-  `(l/run ~n-answers [results#]
-     (l/fresh [~'x] ;; ~'x means "literally x, don't gensym", see #28
-       (l/== [~'x] results#)
-       (l/membero ~'x ~events)
-       ~logic-query)))
+  (let [free-vars (find-free-vars logic-query)
+        membero-clauses (for [v free-vars]
+                          `(l/membero ~v ~events))]
+    `(l/run ~n-answers [results#]
+       (l/fresh [~@free-vars]
+         (l/== [~@free-vars] results#)
+         ~@membero-clauses
+         ~logic-query))))

 (defn ^:private run-logic-query
   "Runs a query over some events and finds n answers (default 1)."


CMR-687: Added validation for OR option.

--- src/cmr/search/services/parameters/parameter_validation.clj
+++ src/cmr/search/services/parameters/parameter_validation.clj
@@ -33,6 +33,10 @@
 (def params-that-disallow-pattern-search-option
   "Parameters which do not allow pattern search option."
   (set #{:concept-id :echo-collection-id :echo-granule-id}))
+
+(def params-that-allow-or-option
+  "Parameter which allow search with the OR option."
+  #{:attribute :science-keywords})

 (def exclude-params
   "Lists parameters which can be used to exclude items from results."
@@ -181,7 +185,6 @@
              options))
     []))

-
 (defn option-case-sensitive-params-validation
   "Validates ignore case option setting is not set to true for identified params."
   [concept-type params]
@@ -210,6 +213,17 @@
              options))
     []))

+(defn options-or-params-validation
+  "Validates or option setting is not set to true for anything but attribute"
+  [concept-type params]
+  (when-let [options (:options params)]
+    (apply concat
+           (map
+             (fn [[param settings]]
+               (when (and (= "true" (:or settings))
+                        (not (contains? params-that-allow-or-option param)))
+                 [(c-msg/invalid-or-opt-setting-msg param)]))
+             options))))

 (defn- validate-date-time
   "Validates datetime string is in the given format"
@@ -477,6 +491,7 @@
    unrecognized-params-settings-in-options-validation
    option-case-sensitive-params-validation
    option-pattern-params-validation
+   options-or-params-validation
    temporal-format-validation
    updated-since-validation
    orbit-number-validation


bugfix aggregate-select & add-param-query to allow retracted results, optimize various other collection fns, refactor test setup

--- src/thi/ng/fabric/triples.cljc
+++ src/thi/ng/fabric/triples.cljc
@@ -22,16 +22,13 @@
   (query-result [_ id]))

 (defn signal-triple
-  [vertex op]
-  (let [sig [op (:id vertex) @vertex]]
-    (debug :signal-triple sig)
-    sig))
+  [vertex op] [op (:id vertex) @vertex])

 (defn collect-index
   [spo]
   (f/collect-pure
    (fn [val incoming]
-     (debug :update-index spo incoming)
+     ;;(debug :update-index spo incoming)
      (debug :old-index val)
      (let [val (transduce
                 (map (fn [[op id t]] [op id (nth t spo)]))
@@ -52,9 +49,7 @@

 (defn signal-index-select
   [vertex [idx sel]]
-  (let [sig [idx (if sel (@vertex sel [nil]) (->> @vertex vals (mapcat identity) (set)))]]
-    (debug :signal-index sig)
-    sig))
+  [idx (if sel (@vertex sel [nil]) (->> @vertex vals (mapcat identity) (set)))])

 (def collect-select
   (f/collect-pure
@@ -79,8 +74,7 @@
    (fn [_ incoming]
      (let [res (vals (peek incoming))]
        ;;(debug :agg-incoming res)
-       ;; FIXME delay
-       (when (every? #(not= [nil] %) res)
+       (if (every? #(not= [nil] %) res)
          (->> res
               (into #{} (map #(disj % nil)))
               (sort-by count)
@@ -88,7 +82,8 @@
               (into #{}
                     (comp (map #(f/vertex-for-id g %))
                           (filter identity)
-                          (map deref)))))))))
+                          (map deref))))
+         #{})))))

 (defn qvar?
   "Returns true, if x is a qvar (a symbol prefixed with '?')"
@@ -137,17 +132,15 @@
   (let [vs?        (qvar? s), vp? (qvar? p), vo? (qvar? o)
         vmap       (bind-translator vs? vp? vo? s p o)
         verify     (triple-verifier s p o vs? vp? vo?)
+        res-tx     (comp (map #(if (verify %) (vmap %))) (filter identity))
         collect-fn (f/collect-pure
                     (fn [_ incoming]
-                      ;; FIXME delay
-                      (when-let [res (peek incoming)]
-                        (into #{}
-                              (comp (map #(if (verify %) (vmap %)))
-                                    (filter identity))
-                              res)))) ;; FIXME delay @
+                      (if-let [res (seq (peek incoming))]
+                        (into #{} res-tx res)
+                        #{})))
         q-pattern  [(if vs? nil s) (if vp? nil p) (if vo? nil o)]
         q-spec     (add-query! g id q-pattern)
-        resv       (f/add-vertex! g nil {::f/collect-fn collect-fn})] ;; FIXME delay
+        resv       (f/add-vertex! g nil {::f/collect-fn collect-fn})]
     (f/add-edge! g (:result q-spec) resv f/signal-forward nil)
     (assoc q-spec :qvar-result resv)))

@@ -162,11 +155,11 @@
             g nil ;; FIXME delay
             {::f/collect-fn
              (fn [vertex]
-               (let [state (:state vertex)
-                     a (get-in @state [::f/signal-map (:id (:qvar-result qa))]) ;; FIXME delay @
-                     b (get-in @state [::f/signal-map (:id (:qvar-result qb))])] ;; FIXME delay @
-                 (debug :join-sets a b)
-                 (reset! (:value vertex) (set/join a b)))) ;; FIXME delay
+               (let [sig-map (::f/signal-map @(:state vertex))
+                     a (sig-map (:id (:qvar-result qa)))
+                     b (sig-map (:id (:qvar-result qb)))]
+                 (debug (:id vertex) :join-sets a b)
+                 (reset! (:value vertex) (set/join a b))))
              ::f/score-collect-fn
              score-collect-join})]
     (f/add-edge! g (:qvar-result qa) jv f/signal-forward nil)
@@ -177,8 +170,7 @@
   [g [a b & more]]
   (if b
     (reduce
-     (fn [acc p]
-       (add-join! g acc (add-param-query! g (keyword (gensym)) p)))
+     (fn [acc p] (add-join! g acc (add-param-query! g (keyword (gensym)) p)))
      (add-join! g
                 (add-param-query! g (keyword (gensym)) a)
                 (add-param-query! g (keyword (gensym)) b))
@@ -187,15 +179,12 @@

 (defn add-query-filter!
   [g q-vertex flt]
-  (let [fv (f/add-vertex!
-            g nil ;; FIXME delay
+  (let [tx (comp (mapcat identity) (filter flt))
+        fv (f/add-vertex!
+            g nil
             {::f/collect-fn
              (f/collect-pure
-              (fn [_ incoming]
-                ;; FIXME delay
-                ;;(delay (sequence (comp (mapcat deref) (filter flt)) incoming))
-                (sequence (comp (mapcat identity) (filter flt)) incoming)
-                ))})]
+              (fn [_ incoming] (sequence tx incoming)))})]
     (f/add-edge! g q-vertex fv f/signal-forward nil)
     fv))

@@ -203,32 +192,24 @@
   [g production]
   (fn [vertex]
     (let [prev @vertex
-          in   (transduce
-                (map identity) ;;(map deref) ;; FIXME delay
-                (completing into)
-                #{}
-                (::f/uncollected @(:state vertex)))
+          in   (reduce into #{} (::f/uncollected @(:state vertex)))
           adds (set/difference in prev)
           inferred (mapcat production adds)]
       (debug :additions adds)
       (doseq [t inferred]
         (debug :add-triple t)
-        (add-triple! g t)
-        )
+        (add-triple! g t))
       (swap! (:value vertex) set/union in (set inferred)))))

 (defn- index-vertex
   [g spo]
   (f/add-vertex!
    g {} {::f/collect-fn      (collect-index spo)
-         ::f/score-signal-fn (fn [v] (let [score (f/score-signal-with-new-edges v)]
-                                      (info (:id v) :index-score score)
-                                      score))
-         }))
+         ::f/score-signal-fn f/score-signal-with-new-edges}))

 (def triple-vertex-spec
   {::f/score-collect-fn (constantly 0)
-   ::f/score-signal-fn f/score-signal-with-new-edges})
+   ::f/score-signal-fn  f/score-signal-with-new-edges})

 (defrecord TripleGraph
     [g indices triples queries rules]
@@ -272,16 +253,15 @@
       (warn "attempting to remove unknown triple:" t)))
   (add-query!
     [_ id [s p o]]
-    ;; TODO figure out way how to at to a running context
     ;; TODO remove vertices if query ID already exists
     ;; TODO add default [nil nil nil] query & re-use
     (let [{:keys [subj pred obj]} indices
-          acc (f/add-vertex!
-               g {} {::f/collect-fn collect-select})
-          res (f/add-vertex!
-               g nil ;; FIXME delay
-               {::f/collect-fn (aggregate-select g)
-                ::f/score-collect-fn (score-collect-min-signal-vals 3)})
+          acc  (f/add-vertex!
+                g {} {::f/collect-fn collect-select})
+          res  (f/add-vertex!
+                g nil
+                {::f/collect-fn       (aggregate-select g)
+                 ::f/score-collect-fn (score-collect-min-signal-vals 3)})
           spec {:pattern [s p o] :acc acc :result res}]
       (f/add-edge! g subj acc signal-index-select [0 s])
       (f/add-edge! g pred acc signal-index-select [1 p])
@@ -290,7 +270,7 @@
       (swap! queries assoc id spec)
       spec))
   (query-result
-    [_ id] (when-let [q (@queries id)] @(:result q))) ;; FIXME delay @@
+    [_ id] (when-let [q (@queries id)] @(:result q)))
   (add-rule!
     [_ id query production]
     (let [q   (add-join-query! _ query)
@@ -315,27 +295,20 @@
   [g src]
   (let [v (f/add-vertex!
            g nil
-           {::f/collect-fn
-            (f/collect-pure
-             (fn [val in]
-               (debug :updated-result (pr-str (peek in))) ;; FIXME delay @
-               (count (peek in))))})]
+           {::f/collect-fn (f/collect-pure (fn [_ in] (count (peek in))))})]
     (f/add-edge! g src v f/signal-forward nil)
     v))

 (def triple-log-transducer
   (comp
-   (filter
-    (fn [[op v]]
-      (and (#{:add-vertex :remove-vertex} op) (vector? @v))))
-   (map
-    (fn [[op v]] [({:add-vertex :+ :remove-vertex :-} op) @v]))))
+   (filter (fn [[op v]] (and (#{:add-vertex :remove-vertex} op) (vector? @v))))
+   (map (fn [[op v]] [({:add-vertex :+ :remove-vertex :-} op) @v]))))

 (defn add-triple-graph-logger
   [g log-fn]
   (let [ch        (chan 1024 triple-log-transducer)
-        log->chan #(go (>! ch %))
-        watch-id  (keyword (gensym))]
+        watch-id  (keyword (gensym))
+        log->chan #(go (>! ch %))]
     (go-loop []
       (let [t (<! ch)]
         (when t
@@ -351,7 +324,7 @@
   (f/remove-watch! graph :remove-vertex watch-id)
   (close! chan))

-(defn ^:export start-async
+(defn make-test-graph
   []
   (let [g (triple-graph (f/compute-graph))
         log (add-triple-graph-logger
@@ -383,116 +356,74 @@
            (fn [{:syms [?a ?super ?b]}] [[?a ?super ?b]]))
         pq (:qvar-result (add-param-query! g :pq '[?s knows ?o]))
         jq (:qvar-result (add-join-query! g '[[?p author ?prj] [?prj type project] [?p type person]]))
-        tq (:qvar-result (add-join-query! g '[[?p author ?prj] [?prj tag ?t]]))
-        _ (run!
-           #(add-triple! g %)
-           '[[toxi author fabric]
-             [fabric type project]
-             [knows type symmetric-prop]
-             [knows domain person]
-             [author domain person]
-             [author range creative-work]
-             [parent sub-prop-of ancestor]
-             [ancestor type transitive-prop]
-             [ancestor domain person]
-             [ancestor range person]])
-        ;;_ (prn :next-id (-> g :g :state deref :next-id))
-        ctx (f/async-execution-context {:graph g})
+        tq (:qvar-result (add-join-query! g '[[?p author ?prj] [?prj tag ?t]]))]
+    (run!
+     #(add-triple! g %)
+     '[[toxi author fabric]
+       [fabric type project]
+       [knows type symmetric-prop]
+       [knows domain person]
+       [author domain person]
+       [author range creative-work]
+       [parent sub-prop-of ancestor]
+       [ancestor type transitive-prop]
+       [ancestor domain person]
+       [ancestor range person]])
+    {:g            g
+     :log          log
+     :all          all
+     :toxi         toxi
+     :types        types
+     :knows        knows
+     :projects     projects
+     :pq           pq
+     :jq           jq
+     :tq           tq
+     :num-projects num-projects
+     :num-types    num-types}))
+
+(defn ^:export start-async
+  []
+  (let [spec     (make-test-graph)
+        {:keys [g log all pq jq tq]} spec
+        ctx      (f/async-execution-context {:graph g})
         ctx-chan (f/execute! ctx)]
-    (go []
+    (go
+      (let [res (<! ctx-chan)]
+        (warn :result res)
+        (warn (sort @all))
+        (run!
+         #(add-triple! g %)
+         '[[toxi parent noah]
+           [ingo parent toxi]
+           [geom type project]
+           [toxi author geom]
+           [toxi knows noah]
+           [geom tag clojure]
+           [fabric tag clojure]])
         (let [res (<! ctx-chan)]
           (warn :result res)
-          (warn (sort @all))
-          (run!
-           #(add-triple! g %)
-           '[[toxi parent noah]
-             [ingo parent toxi]
-             [geom type project]
-             [toxi author geom]
-             [toxi knows noah]
-             [geom tag clojure]
-             [fabric tag clojure]])
+          (warn :all (sort @all))
+          (warn :pq @pq)
+          (warn :jq @jq)
+          (warn :tq @tq)
+          (remove-triple! g '[geom tag clojure])
+          (remove-triple! g '[fabric tag clojure])
           (let [res (<! ctx-chan)]
-            (warn :result res)
-            (warn :all (sort @all))
-            (warn :pq @pq)
             (warn :jq @jq)
             (warn :tq @tq)
-            (remove-triple! g '[geom tag clojure])
-            (remove-triple! g '[fabric type project])
-            (let [res (<! ctx-chan)]
-              (warn :jq @jq)
-              (warn :tq @tq)
-              (f/stop! ctx)
-              (do (remove-triple-graph-logger log)
-                  (warn :done))))))
-
-    {:g        g
-     :ctx      ctx
-     :all      all
-     :toxi     toxi
-     :types    types
-     :knows    knows
-     :projects projects
-     :pq       pq
-     :jq       jq
-     :tq       tq
-     :num-projects num-projects
-     :num-types num-types
-     }))
+            (f/stop! ctx)
+            (do (remove-triple-graph-logger log)
+                (warn :done))))))
+    (assoc spec :ctx ctx)))

 (defn ^:export start-sync
   []
-  (let [;;log (add-triple-graph-logger "triple-log.edn")
-        ;;g (triple-graph (f/logged-compute-graph (f/compute-graph) log))
-        g (triple-graph (f/compute-graph))
-        log (add-triple-graph-logger
-             g #?(:clj
-                  #(spit "triple-log.edn" (str (pr-str %) "\n") :append true)
-                  :cljs
-                  #(.log js/console (pr-str %))))
-        toxi (:result (add-query! g :toxi ['toxi nil nil]))
-        types (:result (add-query! g :types [nil 'type nil]))
-        projects (:result (add-query! g :projects [nil 'type 'project]))
-        knows (:result (add-query! g :projects [nil 'knows nil]))
-        all (:result (add-query! g :all [nil nil nil]))
-        num-projects (add-counter! g projects)
-        num-types (add-counter! g types)
-        _ (add-rule!
-           g :symmetric '[[?a ?prop ?b] [?prop type symmetric-prop]]
-           (fn [{:syms [?a ?prop ?b]}] [[?b ?prop ?a]]))
-        _ (add-rule!
-           g :domain '[[?a ?prop nil] [?prop domain ?d]]
-           (fn [{:syms [?a ?prop ?d]}] [[?a 'type ?d]]))
-        _ (add-rule!
-           g :range '[[nil ?prop ?a] [?prop range ?r]]
-           (fn [{:syms [?a ?prop ?r]}] [[?a 'type ?r]]))
-        _ (add-rule!
-           g :transitive '[[?a ?prop ?b] [?b ?prop ?c] [?prop type transitive-prop]]
-           (fn [{:syms [?a ?prop ?c]}] [[?a ?prop ?c]]))
-        _ (add-rule!
-           g :sub-prop '[[?a ?prop ?b] [?prop sub-prop-of ?super]]
-           (fn [{:syms [?a ?super ?b]}] [[?a ?super ?b]]))
-        pq (:qvar-result (add-param-query! g :pq '[?s knows ?o]))
-        jq (:qvar-result (add-join-query! g '[[?p author ?prj] [?prj type project] [?p type person]]))
-        tq (:qvar-result (add-join-query! g '[[?p author ?prj] [?prj tag ?t]]))
-        _ (run!
-           #(add-triple! g %)
-           '[[toxi author fabric]
-             [fabric type project]
-             [knows type symmetric-prop]
-             [knows domain person]
-             [author domain person]
-             [author range creative-work]
-             [parent sub-prop-of ancestor]
-             [ancestor type transitive-prop]
-             [ancestor domain person]
-             [ancestor range person]
-             ;;[noah knows toxi]
-             ])
-        ctx (f/sync-execution-context {:graph g})
-        res (f/execute! ctx)]
+  (let [spec (make-test-graph)
+        {:keys [g log all pq jq tq]} spec
+        ctx  (f/sync-execution-context {:graph g})
+        res  (f/execute! ctx)]
     (warn :result res)
     (warn (sort @all))
     (run!
@@ -505,25 +436,15 @@
        [geom tag clojure]
        [fabric tag clojure]])
     (warn :result2 (f/execute! ctx))
-    (warn (sort @all))
-    (warn @pq)
-    (warn @jq)
-    (warn @tq)
+    (warn :all (sort @all))
+    (warn :pq @pq)
+    (warn :jq @jq)
+    (warn :tq @tq)
+    (f/signal! (remove-triple! g '[geom tag clojure]) f/sync-vertex-signal)
     (f/signal! (remove-triple! g '[fabric tag clojure]) f/sync-vertex-signal)
     (warn :result3 (f/execute! ctx))
-    (warn @all)
-    (warn @tq)
+    (warn :all @all)
+    (warn :jq @jq)
+    (warn :tq @tq)
     (remove-triple-graph-logger log)
-    {:g        g
-     :ctx      ctx
-     :all      all
-     :toxi     toxi
-     :types    types
-     :knows    knows
-     :projects projects
-     :pq       pq
-     :jq       jq
-     :tq       tq
-     :num-projects num-projects
-     :num-types num-types
-     }))
+    (assoc spec :ctx ctx)))


불필요 파일 삭제.

불필요 파일 삭제.

--- src/tweetbook/views/layout.clj
+++ src/tweetbook/views/layout.clj
@@ -1,13 +0,0 @@
-(ns tweetbook.views.layout
-  (:require [hiccup.page :refer [html5 include-css include-js]]))
-
-(defn common [& body]
-  (html5
-    [:head
-     [:title "Welcome to tweetbook"]
-     (include-css "/css/screen.css")
-     (include-css "//maxcdn.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css")
-     (include-js "//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js")
-     (include-js "//maxcdn.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js")
-     (include-js "/js/count.js")]
-    [:body body]))


Increase initial scraping limit to 1000

Increase initial scraping limit to 1000

Change-Id: I70966049f503e9d1d67f7f1a50c62f3528a959ea

--- src/qcast/infoq/scraper.clj
+++ src/qcast/infoq/scraper.clj
@@ -120,11 +120,11 @@

 (defn- cache-updates
   "Scrape the overview sites and collect its oughly 12 items per site until
-  finding an seen item (since). Scrape a maximum of limit or 100 items. This
+  finding an seen item (since). Scrape a maximum of limit or 1000 items. This
   sequence requires one additional GET (page) + three HEAD (video, audio, pdf)
   requests per item, thus n%12 + 2*n."
   ([] (cache-updates (cache/latest)))
-  ([until] (cache-updates until 100))
+  ([until] (cache-updates until 1000))
   ([until limit]
      (let [until-id (or (:id until) :inf)]
        (info "Check for updates up until" until-id)


Updated stackdriver adapter

Updated stackdriver adapter

--- src/riemann/stackdriver.clj
+++ src/riemann/stackdriver.clj
@@ -13,9 +13,9 @@
   (let [service ((:name opts) event)]
      (replace service #"\s+" ".")))

-(defmulti generate-datapoint (fn [opts event] (class event)))
+(defmulti generate-datapoint (fn [opts event] (sequential? event)))

-(defmethod generate-datapoint riemann.codec.Event
+(defmethod generate-datapoint false
   [opts event]
   (let [value (:metric event)
         service (metric-name opts event)]
@@ -23,7 +23,7 @@
      :value (if (nil? value) 0 value)
      :collected_at (long (:time event))}))

-(defmethod generate-datapoint clojure.lang.PersistentVector
+(defmethod generate-datapoint true
   [opts event]
   (mapv
    #(let [value (:metric %)


deriving a column with a single source value no longer needs to boxed in a vector.

--- src/grafter/tabular.clj
+++ src/grafter/tabular.clj
@@ -202,6 +202,9 @@
   [dataset n]
   (tabc/pass-rows dataset (partial take n)))

+(defn lift->vector [x]
+  (if (sequential? x) x [x]))
+
 (defn derive-column
   "Adds a new column to the end of the row which is derived from
 column with position col-n.  f should just return the cells value.
@@ -213,7 +216,7 @@
    (derive-column dataset new-column-name from-cols identity))
   ;; todo support multiple columns/arguments to f.
   ([dataset new-column-name from-cols f]
-     (inc/add-derived-column new-column-name from-cols f dataset)))
+     (inc/add-derived-column new-column-name (lift->vector from-cols) f dataset)))

 (defn- resolve-keys [headers hash]
   (map-keys #(resolve-col-id % headers nil) hash))
@@ -239,9 +242,6 @@
         new-col-ids (keys first-result)]

     new-col-ids))
-
-(defn lift->vector [x]
-  (if (sequential? x) x [x]))

 (defn add-columns
   ([dataset hash]


Catch #'esd/search errors to enable easier debugging.

--- src/haystack/routes.clj
+++ src/haystack/routes.clj
@@ -73,7 +73,7 @@
 (defn process-search
   [query-map]
   (let [q (query/build-search-query query-map)
-        response (esd/search repo "searchecommerce" "productplus" q)
+        response (try (esd/search repo "searchecommerce" "productplus" q) (catch Throwable e {}))
         aggregations (query/extract-aggregations query-map response)
         named-aggregations (merge-aggregation-names aggregations)
         ]
@@ -82,6 +82,9 @@
        :elasticsearch-query q
        }
       {:paging (query/extract-paging query-map response)
+       ;; :response response
+       ;; :transform (query/transform-search-query query-map)
+       ;; :q q
        :search-request query-map
        :documents (query/extract-documents response)
        :aggregations named-aggregations


Add exception printing to process-search.

--- src/haystack/search.clj
+++ src/haystack/search.clj
@@ -13,7 +13,8 @@
             [haystack.query :as query]

             [haystack.ecommerce :refer [find-category-by-path find-manufacturer]]
-            ))
+            )
+  (:import [java.net ConnectException SocketException]))

 (defn merge-aggregation-names
   [aggregations]
@@ -57,7 +58,15 @@
 (defn process-search
   [query-map]
   (let [q (query/build-search-query query-map)
-        response (try (esd/search repo "searchecommerce" "productplus" q) (catch Throwable e {}))
+        response (try (esd/search repo "searchecommerce" "productplus" q)
+                      (catch Throwable e
+                        (println e) (println "err type:" (type e)) (prn (type e))
+                        (condp = (type e)
+                          java.net.ConnectException (println "connection error")
+                          java.net.SocketException (println "socket error. Elasticsearch may have just come back and next search request may work.")
+                          (println "error type:" (type e))
+                          )
+                        {}))
         aggregations (query/extract-aggregations query-map response)
         named-aggregations (merge-aggregation-names aggregations)
         ]


~p147

--- src/study_4clojure/p147.clj
+++ src/study_4clojure/p147.clj
@@ -1,6 +1,6 @@
 ;; 4Clojure Question 147
 ;;
-;;
Write a function that, for any given input vector of numbers, returns an infinite lazy sequence of vectors, where each next one is constructed from the previous following the rules used in Pascal's Triangle. For example, for [3 1 2], the next row is [3 4 3 2].

+;;
Write a function that, for any given input vector of numbers, returns an infinite lazy sequence of vectors, where each next one is constructed from the previous following the rules used in Pascal's Triangle. For example, for [3 1 2], the next row is [3 4 3 2].

 ;;
 ;;
Beware of arithmetic overflow! In clojure (since version 1.3 in 2011), if you use an arithmetic operator like + and the result is too large to fit into a 64-bit integer, an exception is thrown. You can use +' to indicate that you would rather overflow into Clojure's slower, arbitrary-precision bigint.

 ;;
@@ -12,4 +12,15 @@

 (= (take 2 (__ [3 1 2])) [[3 1 2] [3 4 3 2]])

-(= (take 100 (__ [2 4 2])) (rest (take 101 (__ [2 2]))))+(= (take 100 (__ [2 4 2])) (rest (take 101 (__ [2 2]))))
+
+;지금. p97에서 가져와서 +'만 바꿨.
+iterate #(vec (map +' (concat [0] %) (concat % [0])))
+
+;이전
+(fn [col]
+  ((fn _iterate [f x] (cons x (lazy-seq (_iterate f (f x)))))
+    #(map +' (concat [0] %) (concat % [0])) col))
+
+;max `[0 ~@%] 기억할만 하다.
+(fn [s] (iterate  #(map + `[0 ~@%] `[~@% 0]) s))


Delete this custom task as it is not surfaced

--- src/leiningen/clear.clj
+++ src/leiningen/clear.clj
@@ -1,7 +0,0 @@
-(ns leiningen.clear
-  "Clear the storage database of all tables"
-  (:require [layzee.adapters.amazon.dynamo-db :as db]
-            [layzee.adapters.settings :as settings]))
-
-(defn clear []
-  (db/delete-all-tables settings/amazon-credential))


[l.droid] Don't force-clean release builds

--- src/leiningen/droid.clj
+++ src/leiningen/droid.clj
@@ -43,9 +43,7 @@
 (defn doall
   "Metatask. Performs all Android tasks from compilation to deployment."
   [{{:keys [library]} :android :as project} & device-args]
-  (let [build-steps (if library ["build"] ["build" "apk" "deploy"])
-        build-steps (if (dev-build? project)
-                      build-steps (cons "clean" build-steps))]
+  (let [build-steps (if library ["build"] ["build" "apk" "deploy"])]
     (doseq [task build-steps]
       (execute-subtask project task device-args))))


need to have a default.

need to have a default.

--- src/metabase/driver.clj
+++ src/metabase/driver.clj
@@ -291,7 +291,8 @@
         org.postgresql.util.PGobject :UnknownField} klass)
       (condp isa? klass
         clojure.lang.IPersistentMap    :DictionaryField
-        clojure.lang.IPersistentVector :ArrayField)
+        clojure.lang.IPersistentVector :ArrayField
+        nil)
       (do (log/warn (format "Don't know how to map class '%s' to a Field base_type, falling back to :UnknownField." klass))
           :UnknownField)))


always use post data to get the title/headline.

--- src/oc/email/mailer.clj
+++ src/oc/email/mailer.clj
@@ -194,9 +194,7 @@
         mention? (:mention notification)
         comment? (:interaction-id notification)
         post-data (post-data-from-msg msg)
-        title (if comment?
-                (:headline post-data)
-                (:entry-title notification))
+        title (:headline post-data)
         parsed-title (.text (soup/parse title))
         updated-post-data (assoc post-data :parsed-headline parsed-title)
         msg-title (assoc-in msg [:notification :entry-data] updated-post-data)


Fix entity ids in schema/reserve

Fix entity ids in schema/reserve

Since this function was updated to take job ids, we need to update the
query appropriately as well. Doh!

--- src/overseer/schema.clj
+++ src/overseer/schema.clj
@@ -58,8 +58,8 @@
                              job-id)
                     status (ffirst result)]
                 (if (= :unstarted status)
-                  [[:db/add entity-id :job/status :started]
-                   [:db/add entity-id :job.status/updated-at (java.util.Date.)]]
+                  [[:db/add [:job/id job-id] :job/status :started]
+                   [:db/add [:job/id job-id] :job.status/updated-at (java.util.Date.)]]
                   (throw (Exception. "Job status not eligible for start."))))})})

  (defn install


cleanup

cleanup

--- test/clojento/magento/t_db.clj
+++ test/clojento/magento/t_db.clj
@@ -98,17 +98,17 @@
             (first (run-query (:db @system) :product-entities [ 1 ])) => (contains {:id 1 :sku "sku-1" :type "simple" :attribute-set 4 :date-created anything :date-updated anything})
             (first (run-query (:db @system) :product-entities [[1]])) => (contains {:id 1 :sku "sku-1" :type "simple" :attribute-set 4 :date-created anything :date-updated anything}))
       (fact "get multiple products"
-            (run-query (:db @system) :product-entities [[1 2]])   => (contains (contains {:id 1})(contains {:id 2}))
-            (run-query (:db @system) :product-entities [[3 2 1]]) => (contains (contains {:id 1})(contains {:id 2}))))
+            (run-query (:db @system) :product-entities [[1 2]])   => (contains (contains {:id 1}) (contains {:id 2}))
+            (run-query (:db @system) :product-entities [[3 2 1]]) => (contains (contains {:id 1}) (contains {:id 2}))))

     (facts "query :product-websites"
       (fact "get missing product(s)"
             (run-query (:db @system) :product-websites [-1]) => []
             (run-query (:db @system) :product-websites [[-1 -2]]) => [])
       (fact "get product with id 1"
-            (run-query (:db @system) :product-websites [ 1 ]) => (contains (contains {:id 1 :website-id 1})(contains {:id 1 :website-id 2})))
+            (run-query (:db @system) :product-websites [ 1 ]) => (contains {:id 1 :website-id 1} {:id 1 :website-id 2}))
       (fact "get multiple products"
-            (run-query (:db @system) :product-websites [[1 2]])   => (contains (contains {:id 1 :website-id 1})(contains {:id 1 :website-id 2})(contains {:id 2 :website-id 1}))
+            (run-query (:db @system) :product-websites [[1 2]])   => (contains {:id 1 :website-id 1} {:id 1 :website-id 2} {:id 2 :website-id 1})
             (count (run-query (:db @system) :product-websites [[3 2 1]])) => 4))

     (facts "query :product-stock"


Add test for create-or-conj.

Add test for create-or-conj.

--- test/frontrow/handler_test.clj
+++ test/frontrow/handler_test.clj
@@ -1,6 +1,6 @@
 (ns frontrow.handler-test
   (:require [clojure.test :refer [deftest is testing]]
-            [frontrow.handler :refer [average]]))
+            [frontrow.handler :refer [average create-or-conj]]))

 ;;;; Tests for pure functions in handler.clj
 ;;;; lein test :only frontrow.handler-test/test-pure-fns
@@ -9,4 +9,8 @@
   (testing "Test average"
     (is (= (average [0 1 2 3 4]) 2))
     (is (= (float (average [-4 2 0 0])) -0.5))
-    (is (thrown? AssertionError (average [])))))
+    (is (thrown? AssertionError (average []))))
+  (testing "Test create-or-conj"
+    (is (= (create-or-conj {} :a 4) {:a [4]}))
+    (is (= (create-or-conj {:a [4]} :a 5) {:a [4 5]}))
+    (is (= (create-or-conj {:a [4]} :b -4) {:a [4] :b [-4]}))))


Changing test wait outputs to println

Changing test wait outputs to println

--- test/kixi/integration/base.clj
+++ test/kixi/integration/base.clj
@@ -137,7 +137,7 @@
        (if (= 404 (:status md))
          (do
            (when (zero? (mod cnt every-count-tries-emit))
-             (prn (str "Waited " cnt " times for " url ". Getting: " (:status md))))
+             (println "Waited" cnt "times for" url ". Getting:" (:status md)))
            (Thread/sleep wait-per-try)
            (recur url tries (inc cnt) md))
          md))
@@ -190,7 +190,7 @@
        (if-not (get-in md [:body k])
          (do
            (when (zero? (mod cnt every-count-tries-emit))
-             (prn (str "Waited " cnt " times for " k " to be metadata for " id)))
+             (println "Waited" cnt "times for" k "to be metadata for" id))
            (Thread/sleep wait-per-try)
            (recur id k tries (inc cnt) md))
          md))


Comment out possible cause of 1.7 problem

--- test/midje/util/t_laziness.clj
+++ test/midje/util/t_laziness.clj
@@ -22,7 +22,7 @@
 ;; After justification, more facts.

 (unfinished exploder)
-(map exploder [1 2 3])
+; (map exploder [1 2 3])

 (defrecord Foo [x y])


Add Broker Port Config

Add Broker Port Config

--- src/lens/system.clj
+++ src/lens/system.clj
@@ -6,14 +6,15 @@
             [lens.util :as u]
             [lens.import-clinical-data]))

-(defnk new-system [lens-sds-batch-version port broker-host]
+(defnk new-system [lens-sds-batch-version port broker-host {broker-port "5672"}]
   (comp/system-map
     :version lens-sds-batch-version
     :port (u/parse-long port)
     :thread 1

     :broker
-    (new-broker {:host broker-host :num-batch-threads 1})
+    (new-broker {:host broker-host :port (u/parse-long broker-port)
+                 :num-batch-threads 1})

     :server
     (comp/using (new-server) [:port :thread :broker])))


Add comments back

Add comments back

--- android/project.clj
+++ android/project.clj
@@ -15,7 +15,13 @@
                  [org.clojure-android/clojure "1.5.1-jb" :use-resources true]]
   :profiles {:dev {:dependencies [[android/tools.nrepl "0.2.0-bigstack"]]
                    :android {:aot :all-with-unused}}
-             :release {:android {:aot :all}}}
+             :release {:android
+                       {;; Specify the path to your private
+                        ;; keystore and the the alias of the
+                        ;; key you want to sign APKs with.
+                        ;; :keystore-path "/home/user/.android/private.keystore"
+                        ;; :key-alias "mykeyalias"
+                        :aot :all}}}

   :android {:support-libraries ["v13"]
             :target-version "15"


#63: prn => log

#63: prn => log

--- src/mount/core.cljc
+++ src/mount/core.cljc
@@ -109,7 +109,7 @@
                                    (record! state stop done)
                                    :fail? false)
                          :f-failed)]
-        (prn error)                                         ;; this would mostly be useful in REPL
+        (log error)                                         ;; this would mostly be useful in REPL
         (alter-state! current (NotStartedState. state)))
         (alter-state! current (NotStartedState. state)))    ;; (!) if a state does not have :stop when _should_ this might leak
     (swap! running dissoc state)


schema: use one and enum so users are given info

--- src/onyx/schema.clj
+++ src/onyx/schema.clj
@@ -102,25 +102,30 @@
    :flow/predicate (s/either s/Keyword [s/Any])
    s/Keyword s/Any})

-(defn valid-units [[a b :as x]]
-  (and (= 2 (count x))
-       (s/validate s/Int a)
-       (s/validate s/Keyword b)))
+(def Unit
+  [(s/one s/Int "number")
+   (s/one s/Keyword "unit-type")])
+
+(def WindowType
+  (s/enum :fixed :sliding))

 (def Window
   {:window/id s/Keyword
    :window/task s/Keyword
-   :window/type (s/pred #(some #{%} #{:fixed :sliding}) 'window-type)
+   :window/type WindowType
    :window/window-key s/Any
    :window/aggregation s/Keyword
-   :window/range (s/pred valid-units 'valid-units)
-   (s/optional-key :window/slide) (s/pred valid-units 'valid-units)
+   :window/range Unit
+   (s/optional-key :window/slide) Unit
    (s/optional-key :window/doc) s/Str
    s/Keyword s/Any})
+
+(def TriggerRefinement
+  (s/enum :accumulating :discarding))

 (def Trigger
   {:trigger/window-id s/Keyword
-   :trigger/refinement (s/pred #(some #{%} #{:accumulating :discarding}) 'refinement-type)
+   :trigger/refinement TriggerRefinement
    :trigger/on s/Keyword
    :trigger/sync s/Keyword
    (s/optional-key :trigger/fire-all-extents?) s/Bool


Make cell! private

Make cell! private

--- src/play_clj/ui.clj
+++ src/play_clj/ui.clj
@@ -58,7 +58,7 @@
   [k]
   (u/gdx-field :scenes :scene2d :utils :Align (u/key->camel k)))

-(defn cell!
+(defn ^:private cell!
   "Calls methods on a [Cell](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Cell.html)."
   [^Cell cell & args]
   (let [method (first args)


formatting

formatting

--- src/qttt/ui/om.cljs
+++ src/qttt/ui/om.cljs
@@ -85,7 +85,9 @@
         (apply dom/table #js {:className "board"}
           (map (fn [row]
                  (apply dom/tr nil
-                   (map (fn [idx] (om/build cell (get cells idx))) row)))
+                   (map (fn [idx]
+                          (om/build cell
+                            (get cells idx))) row)))
             (partition 3 (range 9))))))))

 (defn screen [game owner]


Add tests for indexed specs.

Add tests for indexed specs.

--- test/bytebuf/core_tests.clj
+++ test/bytebuf/core_tests.clj
@@ -48,7 +48,7 @@
       (is (= (buf/size spec) 12))))
 )

-(deftest associative-static-specs
+(deftest associative-specs
   (testing "write data"
     (let [spec (buf/spec :field1 (buf/int32)
                          :field2 (buf/int64))
@@ -89,4 +89,59 @@
       (let [[readed data] (buf/read* buffer spec {:offset 8})]
         (is (= readed 4))
         (is (= data {:field1 1000})))))
+  )
+
+(deftest indexed-specs
+  (testing "write data"
+    (let [spec (buf/spec (buf/int32) (buf/int64))
+          buffer (buf/allocate 12)
+          data [1 4]]
+      (is (= (buf/write! buffer data spec) 12))
+      (is (= (.getInt buffer 0) 1))
+      (is (= (.getLong buffer 4) 4))))
+
+  (testing "write data with offset"
+    (let [spec (buf/spec (buf/int32))
+          buffer (buf/allocate 12)
+          data [500]]
+      (is (= (buf/write! buffer data spec {:offset 3}) 4))
+      (is (= (.getInt buffer 3) 500))))
+
+  (testing "write data to wrong buffer (less space)"
+    (let [spec (buf/spec (buf/int32))
+          buffer (buf/allocate 2)
+          data [1]]
+      (is (thrown? java.lang.IndexOutOfBoundsException
+                   (buf/write! buffer data spec) 12))))
+
+  (testing "read data"
+    (let [spec (buf/spec (buf/int32) (buf/int64))
+          buffer (buf/allocate 12)]
+      (.putInt buffer 0 10)
+      (.putLong buffer 4 100)
+      (let [[readed data] (buf/read* buffer spec)]
+        (is (= readed 12))
+        (is (= data [10 100])))))
+
+  (testing "read data with offset"
+    (let [spec (buf/spec (buf/int32))
+          buffer (buf/allocate 12)]
+      (.putInt buffer 8 1000)
+      (let [[readed data] (buf/read* buffer spec {:offset 8})]
+        (is (= readed 4))
+        (is (= data [1000])))))
+  )
+
+(deftest spec-data-types
+  (testing "Read/Write static string"
+    (let [spec (buf/spec (buf/string 5))
+          buffer (buf/allocate 20)]
+      (buf/write! buffer ["1234567890"] spec)
+      (let [[readed data] (buf/read* buffer spec)]
+        (is (= readed 5))
+        (is (= data ["12345"])))))
 )
+
+;; (deftest experiments
+
+;; )


#99 print only when tests fail

#99 print only when tests fail

--- test/cheshire/test/core.clj
+++ test/cheshire/test/core.clj
@@ -261,12 +261,13 @@
   (let [test-obj (sorted-map :foo 1 :bar {:baz [{:ulu "mulu"} {:moot "foo"} 3]} :quux :blub)
         pretty-str-default (json/encode test-obj {:pretty true})
         pretty-str-custom (json/encode test-obj {:pretty {}})]
-    ; print for easy comparison
-    (println "; default pretty print")
-    (println pretty-str-default)
-    (println "; custom pretty print with default options")
-    (println pretty-str-custom)
-    (is (= pretty-str-default pretty-str-custom))))
+    (is (= pretty-str-default pretty-str-custom))
+    (when-not (= pretty-str-default pretty-str-custom)
+      ; print for easy comparison
+      (println "; default pretty print")
+      (println pretty-str-default)
+      (println "; custom pretty print with default options")
+      (println pretty-str-custom))))

 (deftest t-custom-pretty-print-with-non-defaults
   (let [test-obj (sorted-map :foo 1 :bar {:baz [{:ulu "mulu"} {:moot "foo"} 3]} :quux :blub)
@@ -275,24 +276,26 @@
                             :before-array-values ""
                             :after-array-values ""
                             :object-field-value-separator ": "}}
+        expected (str "{\n"
+                      "    \"bar\": {\n"
+                      "        \"baz\": [{\n"
+                      "            \"ulu\": \"mulu\"\n"
+                      "        }, {\n"
+                      "            \"moot\": \"foo\"\n"
+                      "        }, 3]\n"
+                      "    },\n"
+                      "    \"foo\": 1,\n"
+                      "    \"quux\": \"blub\"\n"
+                      "}")
         pretty-str (json/encode test-obj test-opts)]
+
     ; just to be easy on the eyes in case of error
-    (println "; pretty print with options")
-    (println (json/encode test-obj
-                          test-opts))
-    ; actual test
-    (is (= (str "{\n"
-                "    \"bar\": {\n"
-                "        \"baz\": [{\n"
-                "            \"ulu\": \"mulu\"\n"
-                "        }, {\n"
-                "            \"moot\": \"foo\"\n"
-                "        }, 3]\n"
-                "    },\n"
-                "    \"foo\": 1,\n"
-                "    \"quux\": \"blub\"\n"
-                "}")
-            pretty-str))))
+    (when-not (= expected pretty-str)
+      (println "; pretty print with options - actual")
+      (println pretty-str)
+      (println "; pretty print with options - expected")
+      (println expected))
+    (is (= expected pretty-str))))

 (deftest t-unicode-escaping
   (is (= "{\"foo\":\"It costs \\u00A3100\"}"


SAVEPOINT

SAVEPOINT

--- test/cljsfmt/core_test.cljs
+++ test/cljsfmt/core_test.cljs
@@ -167,7 +167,7 @@
 ;   (is (= (f/reformat-string "(foo)\n;bar\n;baz\n;qux\n(bang)")
 ;          "(foo)\n;bar\n;baz\n;qux\n(bang)")))

-; (deftest test-options
+(deftest test-options
 ;   (is (= (f/reformat-string "(foo)\n\n\n(bar)" {:remove-consecutive-blank-lines? false})
 ;          "(foo)\n\n\n(bar)"))
 ;   (is (= (f/reformat-string "(  foo  )" {:remove-surrounding-whitespace? false})
@@ -176,10 +176,10 @@
 ;          "(foo(bar))"))
 ;   (is (= (f/reformat-string "(foo\nbar)" {:indents '{foo [[:block 0]]}})
 ;          "(foo\n  bar)"))
-;   (is (= (f/reformat-string "(do\nfoo\nbar)" {:indents {}})
-;          "(do\n foo\n bar)"))
-;   (is (= (f/reformat-string "(do\nfoo\nbar)" {:indentation? false})
-;          "(do\nfoo\nbar)")))
+  (is (= (f/reformat-string "(do\nfoo\nbar)" {:indents {}})
+        "(do\n foo\n bar)"))
+  (is (= (f/reformat-string "(do\nfoo\nbar)" {:indentation? false})
+        "(do\nfoo\nbar)")))

  (deftest test-parsing
    (is (= (f/reformat-string ";foo") ";foo"))


Improve RuuviTag insert unit test

Improve RuuviTag insert unit test

Test that pressure with NULL insert works.

--- test/env_logger/db_test.clj
+++ test/env_logger/db_test.clj
@@ -336,6 +336,11 @@
                  (assoc ruuvitag-obs
                         :recorded
                         (t/zoned-date-time "2019-01-25T20:45:18+02:00")))))
+      (is (pos? (insert-ruuvitag-observation
+                 test-ds
+                 (assoc ruuvitag-obs
+                        :pressure
+                        nil))))
       (= -1 (insert-ruuvitag-observation test-ds
                                          (dissoc ruuvitag-obs :temperature))))))


fix occasional test failures, again :sob:

--- test/metabase/task_test.clj
+++ test/metabase/task_test.clj
@@ -67,16 +67,16 @@
          :restarted]
   [(do
      (stop-task-runner!)
-     (with-redefs [metabase.task/hourly-task-delay (constantly 50)
+     (with-redefs [metabase.task/hourly-task-delay (constantly 100)
                    metabase.task/hourly-tasks-hook mock-hourly-tasks-hook]
        (add-hook! #'hourly-tasks-hook inc-task-test-atom-counter-by-system-hour)
        (reset! task-test-atom-counter 0)
        (start-task-runner!)

        [@task-test-atom-counter      ; should be 0, since not enough time has elaspsed for the hook to be executed
-        (do (Thread/sleep 75)
-            @task-test-atom-counter) ; should have been called once (~25ms ago)
-        (do (Thread/sleep 100)
+        (do (Thread/sleep 150)
+            @task-test-atom-counter) ; should have been called once (~50ms ago)
+        (do (Thread/sleep 200)
             @task-test-atom-counter) ; should have been called two more times
         (do (stop-task-runner!)
             :stopped)]))


Further test proxy tags.

Further test proxy tags.

Closes #74.

--- test/shale/test/proxies.clj
+++ test/shale/test/proxies.clj
@@ -55,10 +55,14 @@
 (deftest ^:integration test-creation-and-deletion
   (testing "proxy creation"
     (let [pool (:proxy-pool @system)
-          spec (select-keys base-proxy [:type :host :port])]
+          spec (-> (select-keys base-proxy [:type :host :port])
+                   (assoc :tags #{"example" "tag"}))]
       (is 0 (count (proxies/view-models pool)))
       (proxies/create-proxy! pool spec)
-      (is 1 (count (proxies/view-models pool)))))
+      (is 1 (count (proxies/view-models pool)))
+      (is (= spec (-> (proxies/view-models pool)
+                      first
+                      (select-keys [:type :host :port :tags]))))))

   (testing "proxy deletion"
     (let [pool (:proxy-pool @system)


Added a logging shell command.

Added a logging shell command.

--- src/dragon/util.clj
+++ src/dragon/util.clj
@@ -16,6 +16,14 @@
 (defn get-build
   []
   (:out (shell/sh "git" "rev-parse" "--short" "HEAD")))
+
+(defn shell!
+  [& args]
+  (log/trace "shell! args:" args)
+  (let [results (apply shell/sh args)
+        err (:err results)]
+    (when-not (empty? err)
+      (log/error err))))

 (defn post-now
   "Return the current time in two parts, ready to be used for creating


minor improvements on router

minor improvements on router

--- src/blackbox/src/leela/blackbox/czmq/router.clj
+++ src/blackbox/src/leela/blackbox/czmq/router.clj
@@ -20,17 +20,19 @@

 (def s java.util.concurrent.TimeUnit/SECONDS)

+(def nilarr (byte-array 0))
+
 (defn make-queue [size]
   (java.util.concurrent.LinkedBlockingQueue. size))

 (defn enqueue [fh queue worker]
   (let [[peer [blank & msg]] (split-with #(not (empty? %)) (z/recvmulti fh))
         time                 (System/currentTimeMillis)]
-    (when (empty? blank)
+    (when (and (empty? blank) (not (empty? msg)))
       (when-not (.offer queue [time peer msg])
         (do
           (warn "queue full, dropping request")
-          (z/sendmulti fh (concat peer (cons "" (:onerr worker)))))))))
+          (z/sendmulti fh (concat peer (cons nilarr (:onerr worker)))))))))

 (defn routing-loop [ifh ofh queue worker]
   (let [[ifh-info ofh-info] (z/poll -1 [ifh [ZMQ$Poller/POLLIN] ofh [ZMQ$Poller/POLLIN]])]
@@ -54,7 +56,7 @@
            reply           (evaluate worker msg)
            req-id          (pr-str (map f/bytes-to-str-unsafe (take 2 msg)))
            rep-id          (pr-str (take 1 reply))]
-       (z/sendmulti fh (concat peer (cons "" reply)))
+       (z/sendmulti fh (concat peer (cons nilarr reply)))
        (info (format "WORKER[%04d] %s ~ %s [%d ms]" myid req-id rep-id (- (System/currentTimeMillis) time)))))))

 (defn fork-worker [ctx myid endpoint queue worker]
@@ -65,8 +67,12 @@
   (with-open [ifh (.socket ctx ZMQ/ROUTER)
               ofh (.socket ctx ZMQ/PULL)]
     (let [queue       (make-queue (:queue-size cfg))
-          ipcendpoint "inproc://blackbox.router"]
+          ipcendpoint (format "inproc://blackbox-router-%s" (f/uuid-1))]
       (info (format "router-start1; config=%s" cfg))
+      (.setSndHWM ofh 0)
+      (.setSndHWM ifh 0)
+      (.setRcvHWM ofh 0)
+      (.setRcvHWM ifh 0)
       (.bind (z/setup-socket ofh) ipcendpoint)
       (.bind (z/setup-socket ifh) (:endpoint cfg))
       (dotimes [myid (:capabilities cfg)] (fork-worker ctx myid ipcendpoint queue worker))


restart listener

restart listener

--- src/mount/core.cljc
+++ src/mount/core.cljc
@@ -301,6 +301,25 @@
                   (var-to-str to) :state))
    states))

+;; restart on events
+
+(defprotocol ChangeListener
+  (add-watcher [this ks watcher])
+  (on-change [this k]))
+
+(deftype RestartListener [watchers]
+  ChangeListener
+
+  (add-watcher [_ ks state]
+    (doseq [k ks]
+      (swap! watchers update k #(conj % state))))
+
+  (on-change [_ k]
+    (let [states (@watchers k)]
+      (apply stop states)
+      (apply start states))))
+
+
 ;; explicit, not composable (subject to depreciate?)

 (defn stop-except [& states]


Better error handling for NNML files that get deleted before we get to indexing them

--- src/net/dishevelled/mailindex/backends/nnml.clj
+++ src/net/dishevelled/mailindex/backends/nnml.clj
@@ -1,6 +1,6 @@
 (ns net.dishevelled.mailindex.backends.nnml
   (:import (java.util Date)
-           (java.io FileInputStream))
+           (java.io FileInputStream IOException))
   (:require clojure.set)
   (:use clojure.java.io))

@@ -13,10 +13,13 @@
 (defn- message-bytes
   "Return the bytes of a message."
   [^String msg]
-  (let [out (byte-array (.length (file msg)))]
-    (with-open [fis (FileInputStream. msg)]
-      (.read fis out))
-    out))
+  (try
+    (let [out (byte-array (.length (file msg)))]
+      (with-open [fis (FileInputStream. msg)]
+        (.read fis out))
+      out)
+    (catch IOException _
+      (byte-array 0))))

 (defn- filename-to-id


(TK-202) Add HUP restart test for services

This commit adds a simple test to verify that HUP successfully stops and
starts services. The actual tests are identical to the restart test,
except the restart is replaced by raising a HUP signal.

--- test/puppetlabs/trapperkeeper/services_test.clj
+++ test/puppetlabs/trapperkeeper/services_test.clj
@@ -1,13 +1,15 @@
 (ns puppetlabs.trapperkeeper.services-test
   (:require [clojure.test :refer :all]
             [puppetlabs.trapperkeeper.services :refer
-                [defservice service] :as svcs]
+             [defservice service] :as svcs]
             [puppetlabs.trapperkeeper.app :as app]
             [puppetlabs.trapperkeeper.testutils.bootstrap :refer
-                [bootstrap-services-with-empty-config
-                 with-app-with-empty-config]]
+             [bootstrap-services-with-empty-config
+              with-app-with-empty-config]]
             [schema.test :as schema-test]
-            [puppetlabs.kitchensink.testutils.fixtures :refer [with-no-jvm-shutdown-hooks]]))
+            [puppetlabs.kitchensink.testutils.fixtures :refer [with-no-jvm-shutdown-hooks]]
+            [beckon]
+            [puppetlabs.trapperkeeper.internal :as internal]))

 (use-fixtures :once schema-test/validate-schemas with-no-jvm-shutdown-hooks)

@@ -135,7 +137,37 @@
               :stop-service3 :stop-service2 :stop-service1]
              @call-seq)))))

-
+(deftest test-lifecycle-function-ordering-signaling
+  (testing "app restart calls life cycle functions in the correct order"
+    (let [call-seq (atom [])
+          services (create-lifecycle-services call-seq)]
+      (with-app-with-empty-config app
+        services
+        (is (= [:init-service1 :init-service2 :init-service3
+                :start-service1 :start-service2 :start-service3]
+               @call-seq))
+        (internal/register-sighup-handler [app])
+        (beckon/raise! "HUP")
+        (let [start (System/currentTimeMillis)]
+          (while (or (not= (count @call-seq) 15)
+                     (> (- (System/currentTimeMillis) start) 1000))
+            (Thread/yield)))
+        (is (= (count @call-seq) 15))
+        (is (= [:init-service1 :init-service2 :init-service3
+                :start-service1 :start-service2 :start-service3
+                :stop-service3 :stop-service2 :stop-service1
+                :init-service1 :init-service2 :init-service3
+                :start-service1 :start-service2 :start-service3]
+               @call-seq)))
+      (is (= [:init-service1 :init-service2 :init-service3
+              :start-service1 :start-service2 :start-service3
+              :stop-service3 :stop-service2 :stop-service1
+              :init-service1 :init-service2 :init-service3
+              :start-service1 :start-service2 :start-service3
+              :stop-service3 :stop-service2 :stop-service1]
+             @call-seq)))))
+
+(deftest test-lifecycle-service-id-available
   (testing "service-id should be able to be called from any lifecycle phase"
     (let [test-context (atom {})
           service1 (service Service1


Use in memory datomic db by default

Use in memory datomic db by default

--- server/src/spira/core/system.clj
+++ server/src/spira/core/system.clj
@@ -16,14 +16,22 @@
 (ns spira.core.system
   (:require [spira.dm.garden :as garden]
             [spira.dm.plant-desc :as plant-desc]
-            [spira.dm.in-memory-repo :as mem-repo]))
+            [spira.dm.in-memory-repo :as mem-repo]
+            [spira.datomic-adapter.repo :as da]))

 ;; A representation of the applications total top level state.
 (defrecord SystemState [garden-repo plant-desc-repo])

-(defn dev-system []
+(defn mem-dev-system []
   "Create a light weight development state"
   (->SystemState
    (mem-repo/memory-garden-repo)
    (mem-repo/memory-plant-description-repo)))

+(defn dev-system []
+  "Create a light weight development state"
+  (let [uri da/test-uri]
+    (da/create-test-db uri)
+    (->SystemState
+     (da/datomic-garden-repo uri)
+     (da/datomic-plant-description-repo uri))))


add nbar -> adj noun (as well as near -> noun adj)

--- src/babel/italiano/grammar.cljc
+++ src/babel/italiano/grammar.cljc
@@ -93,6 +93,19 @@
     :first :head
     :comment "h11"}))

+(def c11-comp-subcat-1
+  (let [subcat (atom :top)]
+    (unifyc
+     {:head {:synsem {:subcat {:1 subcat}}}
+      :comp {:synsem {:subcat {:1 subcat}}}}
+     subcat-1-1-principle-comp-subcat-1
+     hc-agreement
+     head-principle
+     comp-modifies-head
+     head-last
+     {:schema-symbol 'c11-comp-subcat-1
+      :first :head
+      :comment "c11-comp-subcat-1"})))

 (def h11-comp-subcat-1
   (let [subcat (atom :top)]
@@ -105,7 +118,7 @@
      comp-modifies-head
      head-first
      {:schema-symbol 'h11-comp-subcat-1
-      :first :head
+      :first :comp
       :comment "h11-comp-subcat-1"})))

 (def h10
@@ -169,6 +182,7 @@
                              {:rule "intensifier-phrase"
                               :synsem head-synsem}))

+                   ;; nbar where noun is first ('h' in h11)
                    (unifyc h11-comp-subcat-1
                            (let [is-propernoun? (atom :top)
                                  head-synsem {:cat :noun
@@ -180,8 +194,24 @@
                               :head {:phrasal false
                                      :synsem {:modified false ;; TODO: document what purpose :modified serves (if any: if none, remove).
                                               :propernoun is-propernoun?}}
-                              :rule "nbar"
+                              :rule "nbar1"
                               :synsem head-synsem}))
+
+                   ;; nbar where adjective is first ('c' in c11)
+                   (unifyc c11-comp-subcat-1
+                           (let [is-propernoun? (atom :top)
+                                 head-synsem {:cat :noun
+                                              :modified true
+                                              :propernoun is-propernoun?}]
+                             {:comp {:phrasal false ;; rathole prevention ;; TODO: see if this can be removed.
+                                     :synsem {:cat :adjective
+                                              :mod head-synsem}}
+                              :head {:phrasal false
+                                     :synsem {:modified false ;; TODO: document what purpose :modified serves (if any: if none, remove).
+                                              :propernoun is-propernoun?}}
+                              :rule "nbar2"
+                              :synsem head-synsem}))
+
                    (unifyc c10
                            comp-specs-head
                            (let [number-agreement (atom :top)


comment

comment

--- src/babel/italiano/grammar.cljc
+++ src/babel/italiano/grammar.cljc
@@ -610,6 +610,7 @@
                                   (or (and
                                        (= (get-in % [:synsem :cat]) :verb)

+                                       ;; disabled with (or true) but shows how to filter by infinitive.
                                        (or true (= (get-in % [:italiano :italiano]) "sedersi")
                                            (= (get-in % [:synsem :aux]) true))


cleanup comments and whitespace

cleanup comments and whitespace

--- src/babel/italiano/lexicon.cljc
+++ src/babel/italiano/lexicon.cljc
@@ -270,42 +270,6 @@
               :essere true
               :sem {:subj {:animate true}
                     :pred :go}}}
-
-;   (map (fn [each]
-;          (unify
-;           each
-;           ;; common part of all andare lexemes:
-;           {:italiano {:italiano "andare"
-;                       :essere true
-;                       :drop-e true
-;                       :present {:1sing "vado"
-;                                 :2sing "vai"
-;                                 :3sing "va"
-;                                 :1plur "andiamo"
-;                                 :2plur "andate"
-;                                 :3plur "vanno"}}
-;            :synsem {:essere true
-;                     :sem {:subj {:animate true}
-;                           :activity false ;; because "I was going when (something happened) .." sounds weird.
-;                           :pred :andare
-;                           :discrete false
-;                           :motion false}}}))
-;        (list
-;          ;; "andare"-intransitive
-;
-
-;           {:synsem {:sem {:location '()}}})))
-
-;          (unify
-;           transitive
-;           ;; "andare" that takes a prepositional phrase
-;           (let [place-sem (atom {:place true
-;                                 :pred :a})]
-;             {:synsem {:sem {:location place-sem}
-;                       :subcat {:2 {:sem place-sem
-;                                    :subcat '()
-;                                    :cat :prep}}}
-;              :note "andare-pp"}))))

    "anno" {:synsem {:agr {:gender :masc}
                     :cat :noun
@@ -630,17 +594,6 @@
                               :pred :close}}
                :italiano {:passato "chiuso"}}

-;     "chiunque"
-;     {:synsem {:cat :fail ; :noun ;; disabling until more constraints are put on usage of it (TODO).
-;               :pronoun true
-;               :case :nom
-;               :agr {:person :3rd
-;                     :number :sing}
-;               :sem {:human true
-;                      :pred :chiunque
-;                     :elective-existential true}
-;               :subcat '()}}
-
    "ci"
    {:synsem {:cat :noun
              :pronoun true
@@ -775,14 +728,6 @@
             :italiano {:present {:2sing "dai"
                                  :3plur "danno"}
                        :future-stem "dar"}}
-
-;; TODO: something wrong here with respect to passato: probably the :essere=false is causing a problem.
-;        :synsem {:cat :verb
-;                 :essere false
-;                 :sem {:pred :dare
-;                       :subj {:human true}
-;                      :iobj {:animate true}
-;                       :obj {:buyable true}}}})

    "decidere"  {:synsem {:cat :verb
                          :essere false
@@ -1037,35 +982,7 @@
                 :sem {:pred :be
                       :activity false
                       :discrete false}}}
-
-      ;; essere: intensifier
-      ;; this is for e.g "essere più alto di quelle donne belle (to be taller than those beautiful women)"
-;           (let [gender (atom :top)
-;                 number (atom :top)
-;                 subject (atom {:agr {:gender gender
-;                                     :number number}
-;                               :cat :noun})
-;                 comp-pred (atom :top)
-;                 comp-sem (atom
-;                           {:activity false
-;                            :pred comp-pred
-;                            :discrete false})]
-;             (unify
-;              verb-subjective
-;              essere-common
-;              {:notes "essere-intensifer"
-;               :synsem {:cat :verb
-;                        :subcat {:1 subject
-;                                 :2 {:cat :intensifier
-;                                     :sem comp-sem
-;                                     :subcat {:1 subject
-;                                              :2 '()}}}
-;                        :sem {:pred comp-pred
-;                              :intensified true
-;                              :obj comp-sem}}}))
-
-      {:unify [essere-common verb-aux verb-subjective essere-aux-subject-agreement
-       ]
+      {:unify [essere-common verb-aux verb-subjective essere-aux-subject-agreement]
        :notes "essere-aux"
        :italiano {:notes "essere-aux"}}])

@@ -1114,10 +1031,6 @@

    "fornire"  {:synsem {:cat :verb
                         :sem {:pred :furnish}}}
-
-;; commenting out: no english equivalent
-;      "frequentare"  {:synsem {:cat :verb
-;                               :sem {:pred :frequentare}}}

    "funzionare" {:synsem {:cat :verb
                           :essere false
@@ -1204,17 +1117,6 @@
    "interrompere" {:italiano {:passato "interrotto"}
                    :synsem {:cat :verb
                             :sem {:pred :interrupt}}}
-
-;; commenting out until discussed with Franco
-;;      "" ;; empty pronominal subject e.g. "mangio" = "io mangio".
-;;      [{:synsem {:agr {:person :1st
-;;                       :number :sing}
-;;                 :cat :noun
-;;                 :case :nom
-;;                 :pronoun true
-;;                 :sem {:human true}
-;;                 :subcat '()}}]
-
    "io"
    [{:synsem {:cat :noun
               :pronoun true
@@ -1391,10 +1293,10 @@
                     :place false
                     :pred :lui}
               :subcat '()}
-       :italiano {:initial true  ;; TODO: verify that 'lo' above and this below are being unified correctly.
-                  :pronoun true
-                  :cat :noun
-                  :case pronoun-acc}}
+     :italiano {:initial true  ;; TODO: verify that 'lo' above and this below are being unified correctly.
+                :pronoun true
+                :cat :noun
+                :case pronoun-acc}}
     {:synsem {:cat :det
               :def :def
               :agr {:gender :masc


simply (over): reduce ways to call over/over to only 1

--- src/babel/italiano/workbook.clj
+++ src/babel/italiano/workbook.clj
@@ -36,19 +36,22 @@

 (defn over
   ([arg1]
-   (cond (string? arg1)
-         (over (lookup arg1))
+   (over (vals (:rule-map medium))
+         arg1 :top))
+  ([arg1 arg2]
+   (over (vals (:rule-map medium))
+         arg1 arg2))
+  ([rule child1 child2]
+   (cond (string? child1)
+         (over rule
+               (analyze child1)
+               child2)
+         (string? child2)
+         (over rule child1
+               (analyze child2))
          true
-         (over/over (vals (:grammar-map medium)) arg1)))
-  ([arg1 arg2]
-   (cond (string? arg1)
-         (over (lookup arg1)
-               arg2)
-         (string? arg2)
-         (over arg1 (lookup arg2))
-         true
-         (over/over (vals (:grammar-map medium))
-                    arg1 arg2))))
+         (over/over rule
+                    child1 child2))))

 (def workbook-sandbox-it
   (sandbox


Remove new line

Remove new line

--- src/braid/ui/styles/thread.cljs
+++ src/braid/ui/styles/thread.cljs
@@ -194,4 +194,4 @@
     (mixins/fontawesome \uf110)
     mixins/spin
     {:font-size (em 1.5)
-     :text-align "center"}]])
+     :text-align "center"}]])


Fix: honor absolute path directive for attachments

--- src/cider_ci/ex/attachments.clj
+++ src/cider_ci/ex/attachments.clj
@@ -15,10 +15,17 @@
     [me.raynes.fs :as fs]
     ))

+
+(defn path-post-fix [file abs-working-dir]
+  (if (.startsWith (str file) (str abs-working-dir))
+    (apply str (drop (inc (count (str abs-working-dir)))
+                     (seq (str file))))
+    (apply str (drop 1 (str (fs/normalized (str file)))))
+    ))
+
 (defn put-file [file abs-working-dir base-url content-type]
   (with/logging
-    (let [relative (apply str (drop (inc (count (str abs-working-dir)))
-                                    (seq (str file))))
+    (let [relative (path-post-fix file abs-working-dir)
           url (str base-url relative)]
       (logging/debug "putting attachment"
                      {:file file :nomalized (fs/normalized file)
@@ -40,4 +47,3 @@
 ;(logging-config/set-logger! :level :debug)
 ;(logging-config/set-logger! :level :info)

-


Fix indentation

Fix indentation

--- src/airhead_cljs/components.cljs
+++ src/airhead_cljs/components.cljs
@@ -14,7 +14,6 @@
 (defn now-playing []
   (let [track (@app-state :now-playing)]
     [:p#now-playing
-     [:span]
      (if track
        (str " " (:artist track) " - " (:title track))
        [:em "Nothing is playing"])]))
@@ -22,12 +21,12 @@
 (defn player-section []
   (let [cursor  (r/cursor app-state [:info])
         url     (@cursor :stream_url)]
-  [:section#player
-   [:div
-    [:audio {:controls "controls"}
-    [:source {:src url}]]
-    [:a {:href url}]]
-   [now-playing]]))
+    [:section#player
+     [:div
+      [:audio {:controls "controls"}
+       [:source {:src url}]]
+      [:a {:href url}]]
+     [now-playing]]))

 (defn upload-section []
   [:section#upload


Fix docstring

Fix docstring

--- src/asciinema/player/source.cljs
+++ src/asciinema/player/source.cljs
@@ -114,7 +114,7 @@
       (>! msg-ch (m/->SetLoading false)))))

 (defn emit-coll
-  "Starts sending frames as events with a given name, stopping when stop-ch
+  "Starts sending frames as events with a given name, stopping when out-ch
   closes."
   [coll]
   (let [out-ch (chan)]


Bring back profiling by rule-type

Bring back profiling by rule-type

--- src/aurora/compiler/datalog.cljs
+++ src/aurora/compiler/datalog.cljs
@@ -23,6 +23,8 @@
   (-s vars fn)
   )

+(def profile? false)
+
 ;; TODO
 ;; query optimisation (starting with clause sorting)
 ;; aggregates (conj? sorting?)
@@ -275,8 +277,10 @@
   [(dec (alength plan)) (:shape node)])

 (defn run-plan [plan cache kn]
-  (dotimes [i (count plan)]
-    (aset cache i (run-node (nth plan i) cache kn))))
+  (console-time (str "plan") profile?
+                (dotimes [i (count plan)]
+                  (console-time (pr-str (type (nth plan i))) profile?
+                                (aset cache i (run-node (nth plan i) cache kn))))))

 (comment
   (let [kn (->Knowledge nil nil nil #{{:a 1 :b 2} {:a 2 :b 3} {:c 1 :b 2} {:c 2 :d 4}})
@@ -418,12 +422,14 @@
   (let [cache (make-array (count plan))
         result (transient #{})]
     (run-plan plan cache kn)
-    (doseq [assert-ix assert-ixes
-            fact (aget cache assert-ix)]
-      (conj!! result fact))
-    (doseq [retract-ix retract-ixes
-            fact (aget cache retract-ix)]
-      (disj!! result fact))
+    (console-time "query asserts" profile?
+                  (doseq [assert-ix assert-ixes
+                          fact (aget cache assert-ix)]
+                    (conj!! result fact)))
+    (console-time "query retracts" profile?
+                  (doseq [retract-ix retract-ixes
+                          fact (aget cache retract-ix)]
+                    (disj!! result fact)))
     (persistent! result)))

 (comment
@@ -441,16 +447,18 @@
         asserted-now (transient (:asserted-now kn))
         retracted-now (transient (:retracted-now kn))]
     (run-plan plan cache kn)
-    (doseq [assert-ix assert-ixes
-            fact (aget cache assert-ix)]
-      (conj!! asserted-now fact)
-      (when (or (contains? prev fact) (not (contains? retracted-now fact)))
-        (conj!! now fact)))
-    (doseq [retract-ix retract-ixes
-            fact (aget cache retract-ix)]
-      (conj!! retracted-now fact)
-      (when (or (not (contains? prev fact)) (not (contains? asserted-now fact)))
-        (disj!! now fact)))
+    (console-time "rule asserts" profile?
+                  (doseq [assert-ix assert-ixes
+                          fact (aget cache assert-ix)]
+                    (conj!! asserted-now fact)
+                    (when (or (contains? prev fact) (not (contains? retracted-now fact)))
+                      (conj!! now fact))))
+    (console-time "rule retracts" profile?
+                  (doseq [retract-ix retract-ixes
+                          fact (aget cache retract-ix)]
+                    (conj!! retracted-now fact)
+                    (when (or (not (contains? prev fact)) (not (contains? asserted-now fact)))
+                      (disj!! now fact))))
     (->Knowledge prev (persistent! asserted-now) (persistent! retracted-now) (persistent! now))))

 (comment


Fix Clojure tests

Fix Clojure tests

--- clojure/test/funcatron/sample/clojure/funcs_test.clj
+++ clojure/test/funcatron/sample/clojure/funcs_test.clj
@@ -1,9 +1,8 @@
 (ns funcatron.sample.clojure.funcs-test
   (:require [clojure.test :refer :all]
-            )
+            [funcatron.sample.clojure.funcs :refer :all])
   (:import (funcatron.intf.impl ContextImpl)
            (java.util.logging Logger)
-           (funcatron.sample.clojure SimpleGet PostOrDelete)
            (com.fasterxml.jackson.databind ObjectMapper)
            (funcatron.intf MetaResponse)))

@@ -23,8 +22,7 @@

 (deftest simple-test
   (testing "Simple"
-    (let [s (SimpleGet.)
-          result (.apply s {} (ContextImpl. {} (Logger/getAnonymousLogger)))
+    (let [result (simple_get {} (ContextImpl. {} (Logger/getAnonymousLogger)))
           res-json (.writeValueAsString jackson result)]
       (is (instance? String res-json))
       (is (>= (.indexOf ^String res-json "bools") 0))
@@ -32,20 +30,18 @@
     ))

-(deftest Not_POST_DELETE_on_PostOrDelete
-  (let [pod (PostOrDelete.)
-        result (.apply pod nil (ContextImpl. {"parameters"     {"path" {"cnt" 42}}
-                                              "request-method" "get"}
-                                             (Logger/getAnonymousLogger)))]
+(deftest Not_POST_DELETE_on_post_or_delete
+  (let [result (post_or_delete nil (ContextImpl. {"parameters"     {"path" {"cnt" 42}}
+                                                  "request-method" "get"}
+                                                 (Logger/getAnonymousLogger)))]
     (is (instance? MetaResponse result))
     (is (= 400 (.getResponseCode ^MetaResponse result)))
     ))

-(deftest DELETE_on_PostOrDelete
-  (let [pod (PostOrDelete.)
-        result (.apply pod nil (ContextImpl. {"parameters"     {"path" {"cnt" 45}}
-                                              "request-method" "delete"}
-                                             (Logger/getAnonymousLogger)))
+(deftest DELETE_on_post_or_delete
+  (let [result (post_or_delete nil (ContextImpl. {"parameters"     {"path" {"cnt" 45}}
+                                                  "request-method" "delete"}
+                                                 (Logger/getAnonymousLogger)))
         res-json (.writeValueAsString jackson result)]
     (is (contains? result "name"))
     (is (contains? result "age"))
@@ -54,12 +50,11 @@
     )
   )

-(deftest POST_on_PostOrDelete
-  (let [pod (PostOrDelete.)
-        result (.apply pod {"name" "David" "age" 33}
-                       (ContextImpl. {"parameters"     {"path" {"cnt" 3}}
-                                      "request-method" "post"}
-                                     (Logger/getAnonymousLogger)))
+(deftest POST_on_post_or_delete
+  (let [result (post_or_delete {"name" "David" "age" 33}
+                               (ContextImpl. {"parameters"     {"path" {"cnt" 3}}
+                                              "request-method" "post"}
+                                             (Logger/getAnonymousLogger)))
         res-json (.writeValueAsString jackson result)]

     (is (sequential? result))


don't choke on null types

don't choke on null types

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

--- plugins/SlideExplorer2/src/slide_explorer/canvas.clj
+++ plugins/SlideExplorer2/src/slide_explorer/canvas.clj
@@ -259,9 +259,10 @@
 (defn draw-primitives [g2d items]
   (enable-anti-aliasing g2d)
   (doseq [[type params inner] items]
+    (when type
     (let [params+ (complete-coordinates params)]
       (with-g2d-state [g2d params+]
-                      (draw-primitive g2d (make-obj type params+) params+)))))
+                      (draw-primitive g2d (make-obj type params+) params+))))))

 (defn paint-canvas-graphics [^Graphics graphics data]
   (draw-primitives graphics data))


BACK-1 [*] remove pprint;

BACK-1 [*] remove pprint;

--- src/ws/clojure/sample/handler.clj
+++ src/ws/clojure/sample/handler.clj
@@ -4,7 +4,6 @@

 (defn ws-handler
   [request]
-  (clojure.pprint/pprint request)
   (async/as-channel request
     {:on-open    (fn [channel]
                    (swap! clients assoc channel true)


fixed break.

fixed break.

--- test/forma/source/static_test.clj
+++ test/forma/source/static_test.clj
@@ -6,8 +6,6 @@

 ;; Create a sample cascalog source comprised of MODIS resolution,
 ;; horizontal tile, vertical tile, row (line) and column (sample).
-
-(fact (+ 1 1) => 3)

 (def temp-mod-source
   (memory-source-tap [["1000" 28 7 208 2]


indentation fix

indentation fix

--- src/main/clojure/clojure/tools/reader/impl/utils.clj
+++ src/main/clojure/clojure/tools/reader/impl/utils.clj
@@ -41,8 +41,8 @@
     (defn ex-info? [ex]
       (instance? clojure.tools.reader.impl.ExceptionInfo ex)))

-    (defn ex-info? [ex]
-      (instance? clojure.lang.ExceptionInfo ex)))
+  (defn ex-info? [ex]
+    (instance? clojure.lang.ExceptionInfo ex)))

 (defn whitespace?
   "Checks whether a given character is whitespace"


fixed dom situation

fixed dom situation

--- src/crawler/dom.clj
+++ src/crawler/dom.clj
@@ -683,10 +683,12 @@

         muscle-paths-list (map first muscle-nodes)

-        muscle-histogram (map
-                          #(-> % distinct count)
-                          (apply map vector muscle-paths-list))
-
+        muscle-histogram (if (empty? muscle-paths-list)
+                           []
+                           (map
+                            #(-> % distinct count)
+                            (apply map vector muscle-paths-list)))
+
         muscle-positions (filter
                           (fn [x]
                             (not=


Added config for rabbit mq to amqp component.

--- components/amqp/src/gorillalabs/tesla/component/amqp.clj
+++ components/amqp/src/gorillalabs/tesla/component/amqp.clj
@@ -24,7 +24,8 @@
     (lch/close ch)))

 (defn- start []
-  (let [connection (rmq/connect)]
+  (let [cfg (config/config config/configuration [:amqp :rabbit-mq])
+        connection (if cfg (rmq/connect cfg) (rmq/connect))]
     (declare-queues! connection)
     (atom {:connection connection
            :channels []})))


Turns out case doesn't matter for the components of e.g. attributes.entry.0.key

--- src/eulalie/sns.clj
+++ src/eulalie/sns.clj
@@ -10,7 +10,7 @@
             [eulalie.util.query :as q]
             [cheshire.core :as json]))

-(let [kv-spec [:kv [:attributes "entry"] "key" "value"]]
+(let [kv-spec [:kv [:attributes :entry] :key :value]]
   (def target->seq-spec
     {:add-permission
      {:accounts [:list ["AWSAccountId" :member]]
@@ -27,7 +27,7 @@
 (def enum-keys-out
   #{:attribute-name
     :action-name
-    #(and (= (first %) :attributes) (= (last %) "key"))})
+    #(and (= (first %) :attributes) (= (last %) :key))})

 (defmulti  prepare-body (fn [target body] target))
 (defmethod prepare-body :default [_ body] body)


send pending requests to failure sink

send pending requests to failure sink

--- src/fowles/util.clj
+++ src/fowles/util.clj
@@ -5,7 +5,7 @@
             [zeromq.zmq :as zmq]
             [clojure.core.async :refer [chan close! timeout
                                         go-loop <! >! alt!
-                                        <!! alt!!]]
+                                        <!! >!! alt!!]]
             [clj-time
              [core :as t]
              [coerce :as c]
@@ -87,27 +87,26 @@
     {:request (:query-type req)
      id-name  (get-in req [:args id-name])}))

-(defn print-requests
-  [name ch]
-  (let [requests (map request-msg->input-msg
-                      (dequeue-all-timeout ch WAIT_MS))]
-    (json/pprint {name requests})))
-
 (defn print-pending-requests
   [chs-map]
   (println "*** :msg")
   (doseq [msg (dequeue-all-timeout (:msg chs-map) WAIT_MS)]
-    (println msg))
+    (do
+      (>!! (:failed chs-map) msg)
+      (println msg)))
   (doseq [ch-name [:requests :next-pages :retries]]
     (println "***" ch-name)
     (doseq [msg (map request-msg->input-msg
                      (dequeue-all-timeout (get chs-map ch-name) WAIT_MS))]
-      (json/pprint msg))))
+      (do
+        (>!! (:failed chs-map) (json/write-str msg))
+        (json/pprint msg)))))

 ;;-----------------------

 (def SLEEP_SECS 5)

+;; TODO: Make this an async.timeout?
 (defn- wait-around []
   (println "\nSleeping for" SLEEP_SECS
            "seconds, to allow work to finish.")
@@ -127,7 +126,7 @@
    (Runtime/getRuntime)
    (Thread.
     (fn []
-      ;; This stops any more input from coming in.
+      ;; Stop any more input from coming in.
       (close! (:msg chs-map))
       (wait-around)
       (doseq [name [:failed :bodies :responses]]


Remplacé implémentation de fibo-suite en liste par deux derniers termes uniquement

--- into-clojure/session-3/src/session_3/core.clj
+++ into-clojure/session-3/src/session_3/core.clj
@@ -16,10 +16,10 @@
 (defn fibo-suite
   "Retourne une séquence infinie de termes de la suite de Fibonnacci"
   []
-  (defn fibnext [s]
-    (cons (+' (first s) (second s)) s))
-  (map first
-    (iterate fibnext [0 1])))
+  (defn fibnext [[a b]]
+    [b (+' a b)])
+    (map first
+      (iterate fibnext [0 1])))

 (defn -main
   "I don't do a whole lot ... yet."


bind tag sheet to Sheet instance instead of doing DOM lookup

--- src/cljss/sheet.cljs
+++ src/cljss/sheet.cljs
@@ -13,32 +13,20 @@
     (dom/appendChild head tag)
     tag))

-(defn- find-sheet [tag]
-  (if-let [sheet (gobj/get tag "sheet")]
-    sheet
-    ;; workaround for Firefox
-    (let [sheets (gobj/get js/document "styleSheets")]
-      (loop [idx 0
-             sheet (aget sheets idx)]
-        (if (= tag (gobj/get sheet "ownerNode"))
-          sheet
-          (recur (inc idx) (aget sheets (inc idx))))))))
-

 (defprotocol ISheet
   (insert! [this css cls-name])
   (flush! [this])
   (filled? [this]))

-(deftype Sheet [tag cls-names]
+(deftype Sheet [tag sheet cls-names]
   ISheet
   (insert! [this rule cls-name]
     (when (filled? this)
       (throw (js/Error. (str "A stylesheet can only have " limit " rules"))))
     (when-not (@cls-names cls-name)
       (swap! cls-names conj cls-name)
-      (let [sheet (find-sheet tag)
-            rules-count (gobj/get (gobj/get sheet "cssRules") "length")]
+      (let [rules-count (gobj/get (gobj/get sheet "cssRules") "length")]
         (if dev?
          (if (not= (.indexOf rule "@import") -1)
            (.insertBefore tag (dom/createTextNode rule) (gobj/get tag "firstChild"))
@@ -58,4 +46,6 @@
     (= (count @cls-names) limit)))

 (defn create-sheet []
-  (Sheet. (make-style-tag) (atom #{})))
+  (let [tag (make-style-tag)
+        sheet (gobj/get tag "sheet")]
+    (Sheet. tag sheet (atom #{}))))