remove spec-parser, not needed

remove spec-parser, not needed

--- src/karras/spec_parser.clj
+++ src/karras/spec_parser.clj
@@ -1,101 +0,0 @@
-(ns karras.spec-parser)
-
-(defn attr-name [[name option-map]] name)
-(defn attr-options [[name option-map]] option-map)
-
-(defn filter-spec [f spec]
-  (filter f (partition 2 spec)))
-
-(defn contains-options? [attr & keywords]
-  (let [options (attr-options attr)]
-    (reduce #(and %1 (contains? options %2))
-            keywords)))
-
-(defn required-attrs [spec]
-  (filter-spec #(= :required (:type (attr-options %)))
-               spec))
-
-(defn enum-attrs [spec]
-  (filter-spec #(contains? (attr-options %) :enums)
-               spec))
-
-(defn pair-attrs [spec]
-  (filter-spec #(not (contains-options? % :enums :type))
-               spec))
-
-(defn attrs-with-defaults [spec]
-  (filter-spec #(contains-options? % :default)
-              spec))
-
-(defn pair-field [spec token]
-  (some #(if (= token (attr-name %)) %) (pair-attrs spec)))
-
-(defn enum-field [spec token]
-  (some #(if (contains? (:enums (attr-options %)) token) %)
-        (enum-attrs spec)))
-
-(defn enum-name [spec val]
-  (attr-name (enum-field spec val)))
-
-(defn parse-pair [spec parsed key [value & tail]]
-  [(assoc parsed key value) tail])
-
-(defn parse-enum [spec parsed token tail]
-  (let [key (enum-name spec token)]
-    [(assoc parsed key token) tail]))
-
-(defn parse-ignore [spec parsed token tail]
-  [parsed tail])
-
-(defn choose-parser [spec token]
-  (cond (pair-field spec token) parse-pair
-        (enum-field spec token) parse-enum
-        :default parse-ignore))
-
-(defn parse-options [spec item init-results init-unparsed]
-  (loop [results init-results
-         [token & tail] init-unparsed]
-    (if token
-      (let [parser (choose-parser spec token)
-            [parsed unparsed] (parser spec results token tail)]
-        (recur parsed unparsed))
-      results)))
-
-(defn apply-default [parsed-item attr]
-  (let [default-fn (:default (attr-options attr))]
-    {(attr-name attr)
-     (default-fn parsed-item)}))
-
-(defn set-defaults [spec parsed-item]
-  (let [attrs (attrs-with-defaults spec)
-        need-defaults (filter #(nil? ((attr-name %) parsed-item)) attrs)
-        defaulted (map #(apply-default parsed-item %) need-defaults)]
-    (apply merge parsed-item defaulted)))
-
-(defn parse-item [spec item]
-  (let [required-keys (map first (required-attrs spec))
-        required-values (take (count required-keys) item)
-        init-results (zipmap required-keys required-values)
-        init-unparsed (drop (count required-keys) item)
-        parsed-item (parse-options spec item init-results init-unparsed)]
-    (set-defaults spec parsed-item)))
-
-(defn parse-items [spec items]
-  (map #(parse-item spec %) items))
-
-(def demographic-spec
-     [:name {:type :required}
-      :age  {:type :required}
-      :gender {:enums #{:male :female}}])
-
-(def dick ["dick" 1 :male  ])
-(def jane ["jane" 1 :female])
-
-(assert (= (parse-item demographic-spec dick)
-           {:gender :male, :age 1, :name "dick"}))
-
-(assert (= (parse-items demographic-spec [dick jane])
-           [{:gender :male, :age 1, :name "dick"}
-            {:gender :female, :age 1, :name "jane"}]))
-
-


Make Swagger take routes from compojure

Make Swagger take routes from compojure

--- src/photon/handler.clj
+++ src/photon/handler.clj
@@ -134,8 +134,9 @@
                             (default-db))]
     (dosync (alter own-stream (fn [_] ms)))))

-(defroutes app-routes
-  (GET "/startup" []
+(capi/defroutes* app-routes
+  (capi/GET* "/startup" []
+       :no-doc true
        (if (nil? @own-stream)
          (do
            (figwheel-main)
@@ -159,9 +160,9 @@
   (POST "/projections" request (api/post-projection!
                                 (:stm @own-stream)
                                 (:body request)))
-  (POST "/event" request (api/post-event!
-                          (:stm @own-stream)
-                          (json/parse-string (:body request) true)))
+  (capi/POST* "/event" request (api/post-event!
+                                (:stm @own-stream)
+                                (json/parse-string (:body request) true)))
   (POST "/event/:stream-name" request
         (api/post-event! (:stm @own-stream) (:body request)))
   (route/not-found "Not Found"))
@@ -176,7 +177,9 @@
 (capi/defapi app
   (capi/swagger-ui)
   (capi/swagger-docs)
-  (GET "/ui" [] (response/resource-response "index.html" {:root "public/ui"}))
+  (capi/GET* "/ui" []
+       :no-doc true
+       (response/resource-response "index.html" {:root "public/ui"}))
   (route/resources "/")
   (context "/ws" []
            (routes (rjson/wrap-json-body (pms/wrap-params (site ws-routes))


change file

change file

--- src/leiningen/new/kick.clj
+++ src/leiningen/new/kick.clj
@@ -10,7 +10,7 @@
     (->files data
              ["project.clj" (render "project.clj" data)]
              [".gitignore" (render "gitignore" data)]
-             [".karma.conf.js" (render "karma.conf.js" data)]
+             ["karma.conf.js" (render "karma.conf.js" data)]
              ["externs/angular.js" (render "angular.js" data)]
              ["src/{{sanitized}}/core.clj" (render "core.clj" data)]
              ["src-cljs/{{sanitized}}/app.clj" (render "app.clj" data)]


add idempotent checks to each test case

add idempotent checks to each test case

--- test/parinfer/formatter_test.cljc
+++ test/parinfer/formatter_test.cljc
@@ -92,19 +92,31 @@

     (:test-cases state)))

+(defn idempotent-check
+  [type- message result state format-text]
+  (let [post-result (format-text state result)
+        message (str type- " idempotence over " message)]
+    (is (= result post-result) message)))
+
 (defn run-test-cases
-  [type- format-text]
-  (let [filename (str "doc/" type- "-tests.md")
-        text #?(:clj (slurp filename)
-                :cljs (.readFileSync fs filename))
-        test-cases (parse-test-cases text)]
-    (doseq [{:keys [in out]} test-cases]
-      (let [cursor-line (:cursor-line in)
-            cursor-x (:cursor-x in)]
-        (is (= (:text out) (format-text {:cursor-line cursor-line
-                                         :cursor-x cursor-x} (:text in)))
-            (cond-> (str "test case @ line #" (:line-no in))
-              (and cursor-line cursor-x) (str " with cursor at line=" cursor-line " x=" cursor-x)))))))
+  ([type- format-text] (run-test-cases type- format-text nil))
+  ([type- format-text post-test]
+   (let [filename (str "doc/" type- "-tests.md")
+         text #?(:clj (slurp filename)
+                      :cljs (.readFileSync fs filename))
+         test-cases (parse-test-cases text)]
+     (doseq [{:keys [in out]} test-cases]
+       (let [cursor-line (:cursor-line in)
+             cursor-x (:cursor-x in)
+             cursor? (and cursor-line cursor-x)
+             state (select-keys in [:cursor-line :cursor-x])
+             message (cond-> (str type- " test case @ line #" (:line-no in))
+                       cursor? (str " with cursor at line=" cursor-line " x=" cursor-x))
+             result (format-text state (:text in))]
+         (is (= (:text out) result))
+         (idempotent-check "infer" message result state infer/format-text)
+         (when-not cursor?
+           (idempotent-check "prep" message result state prep/format-text)))))))

 (deftest run-infer-cases
   (run-test-cases "infer" infer/format-text))


great

great

--- src/nettle/fibers/core.clj
+++ src/nettle/fibers/core.clj
@@ -199,6 +199,10 @@
     (make-node-recursive node-map x)
     x))

+(defn expand-symbols [node-map expr]
+  (clojure.walk/postwalk
+   #(expand-symbol node-map %)
+   expr))

 (defn make-code [expr0]
   (let [[node-map expr] (make-map {} expr0)
@@ -206,7 +210,5 @@
         deps (get-dependency-map node-map)
         dep-sort (reverse (toposort/toposort deps))
         bindings (make-bindings dep-sort node-map)]
-    (clojure.walk/postwalk
-     #(expand-symbol node-map %)
-     expr)))
-
+    (expand-symbols node-map expr)))
+


Chris - use new includes? function

Chris - use new includes? function

--- src/nevergreen/servers.clj
+++ src/nevergreen/servers.clj
@@ -1,21 +1,22 @@
 (ns nevergreen.servers
-  (:require [clj-cctray.util :refer [in?]]))
+  (:require [clojure.string :refer [includes?]]
+            [clj-cctray.util :refer [in?]]))

 (defn detect-server [url]
   (cond
     (nil? url) nil
-    (.contains url "//jenkins") :jenkins
-    (.contains url ".ci.cloudbees.com") :jenkins
-    (.contains url "//hudson") :hudson
-    (.contains url "//travis-ci.org") :travis
-    (.contains url "/go/") :go
-    (.contains url "//snap-ci.com") :snap
-    (.contains url "//circleci.com") :circle
-    (.contains url "//teamcity") :team-city
-    (.contains url "//cc.rb.") :cruise-control-rb
-    (.contains url "//cc.java.") :cruise-control
-    (.contains url "//cc.net.") :cruise-control-net
-    (.contains url "//api.tddium.com") :solano
+    (includes? url "//jenkins") :jenkins
+    (includes? url ".ci.cloudbees.com") :jenkins
+    (includes? url "//hudson") :hudson
+    (includes? url "//travis-ci.org") :travis
+    (includes? url "/go/") :go
+    (includes? url "//snap-ci.com") :snap
+    (includes? url "//circleci.com") :circle
+    (includes? url "//teamcity") :team-city
+    (includes? url "//cc.rb.") :cruise-control-rb
+    (includes? url "//cc.java.") :cruise-control
+    (includes? url "//cc.net.") :cruise-control-net
+    (includes? url "//api.tddium.com") :solano
     :else :unknown))

 (defn unknown-server? [server-type]


Fixes ECHO10 generate-and-parse tests.

Fixes ECHO10 generate-and-parse tests.

--- umm-spec-lib/src/cmr/umm_spec/json_schema.clj
+++ umm-spec-lib/src/cmr/umm_spec/json_schema.clj
@@ -174,6 +174,13 @@
         find-var
         var-get)))

+(defn- resolve-$refs
+  "Recursively resolves $refs, as some are multi-level $refs to other types."
+  [[schema definition :as pair]]
+  (if (:$ref definition)
+    (recur (apply lookup-ref pair))
+    pair))
+
 (defn coerce
   ([x]
    (coerce umm-c-schema x))
@@ -182,24 +189,26 @@
   ([schema definition x]
    (let [type-name (or (-> definition :$ref :type-name)
                        (:root schema))
-         ;; Some definitions are several $ref's deep so we need to those down.
-         [schema definition] (if (:$ref definition)
-                               (lookup-ref schema definition)
-                               [schema definition])]
+         [schema definition] (resolve-$refs [schema definition])]
      (condp = (:type definition)
        "string"  (condp = (:format definition)
                    "date-time" (dtp/parse-datetime x)
                    (str x))
        "number"  (Double. x)
-       "integer" (Double. x)
+       "integer" (Long. x)
        "boolean" (= "true" x)
-       "array"   (mapv #(coerce schema (:items definition) %) x)
-       "object"  (let [ctor (record-ctor schema type-name)]
-                   (ctor
-                    (into {}
-                          (for [[k v] x]
-                            (let [prop-definition (get-in definition [:properties k])]
-                              [k (coerce schema prop-definition v)])))))
+       ;; Return nil instead of empty vectors.
+       "array"   (when (seq x)
+                   (mapv #(coerce schema (:items definition) %) x))
+       "object"  (let [ctor (record-ctor schema type-name)
+                       kvs (for [[k v] x]
+                             (when v
+                               (let [prop-definition (get-in definition [:properties k])]
+                                 [k (coerce schema prop-definition v)])))
+                       m (into {} kvs)]
+                   ;; Return nil instead of empty maps/records here.
+                   (when-not (empty? m)
+                     (ctor m)))
        (throw (IllegalArgumentException. (str "Don't know how to coerce " definition " (" x ")")))))))

 (comment


transform results for uploading WIP

transform results for uploading WIP

--- src/polismath/play.clj
+++ src/polismath/play.clj
@@ -38,7 +38,21 @@
                                      ]}))

 (pprint results)
-(pprint results2)
+
+; apply each function to the result of the previous
+(defn snowball [obj fns] (reduce #(%2 %1) obj fns))
+
+(defn prep-for-uploading [results]
+  (let [proj (get results :proj)]
+    (snowball
+      results
+      [
+        #(dissoc %1 :mat :rating-mat :opts') ;remove things we don't want to publish
+        #(dissoc %1 :proj)
+        #(assoc-in %1 [:proj :x] (map first proj))
+        #(assoc-in %1 [:proj :y] (map second proj))
+      ])))
+

 (add-encoder mikera.vectorz.Vector
              (fn [v jsonGenerator]
@@ -50,7 +64,10 @@
                (encode-seq (into-array v) jsonGenerator)))

-(pprint (generate-string results))
+
+(pprint (prep-for-uploading results2))
+
+(pprint (generate-string (prep-for-uploading results2)))

 (defn -main []


mineral style

mineral style

--- src/cljs/meins/electron/renderer/ui/locations_map.cljs
+++ src/cljs/meins/electron/renderer/ui/locations_map.cljs
@@ -90,6 +90,7 @@
   {:street            "mapbox://styles/mapbox/streets-v11"
    :dark              "mapbox://styles/mapbox/dark-v10"
    :light             "mapbox://styles/mapbox/light-v10"
+   :mineral           "mapbox://styles/matthiasn/ck0o3ac0d0ab51cp6o565lvx0"
    :satellite         "mapbox://styles/mapbox/satellite-v9"
    :satellite-streets "mapbox://styles/mapbox/satellite-streets-v11"})


Small cleanup

Small cleanup

--- src/snergly/algorithms.clj
+++ src/snergly/algorithms.clj
@@ -117,7 +117,7 @@
           visited-neighbors (remove #(empty? (:links (grid-cell grid %))) (cell-neighbors current-cell))]
       (cond
         (and (empty? (:links current-cell))
-             (not (empty? visited-neighbors))) [(link-cells grid current-cell (rand-nth visited-neighbors)) current-coord]
+             (not-empty visited-neighbors)) [(link-cells grid current-cell (rand-nth visited-neighbors)) current-coord]
         (empty? other-coords) [grid nil]
         :else (recur other-coords)))))


Add outer-html analogous to inner-html

Add outer-html analogous to inner-html

--- src/sparkledriver/core.clj
+++ src/sparkledriver/core.clj
@@ -169,6 +169,11 @@
   [element]
   (.getAttribute element "innerHTML"))

+(defn outer-html
+  "Return the outerHTML of `element`"
+  [element]
+  (.getAttribute element "outerHTML"))
+
 (defn screenshot
   "Takes a screenshot of `browser-or-element`'s current state and stores the image in a temporary file, then returns the file's absolute path."
   [browser-or-element]


And again

And again

--- src/re_frame/core.cljc
+++ src/re_frame/core.cljc
@@ -30,9 +30,10 @@
    'very soon', bit not now. And if the queue already contains events,
    they will be processed first.

-  Usage:
-
-      (dispatch [:order-pizza \"me\" {:supreme 2 :meatlovers 1 :veg 1}])
+   Usage:
+   ```clj
+   (dispatch [:order-pizza \"me\" {:supreme 2 :meatlovers 1 :veg 1}])
+   ```
    "
   [event]
   (router/dispatch event))
@@ -52,8 +53,9 @@
      3. in a unit test where immediate, synchronous processing is useful.

    Usage:
-
-     (dispatch-sync [:sing :falsetto 634])
+   ```clj
+   (dispatch-sync [:sing :falsetto 634])
+   ```
   "
   [event-v]
   (router/dispatch-sync event-v))
@@ -209,29 +211,30 @@
   signals (atoms, reactions, etc), NOT values. This argument exists for
   historical reasons and is borderline deprecated these days.

-  Example Usage:
-  --------------
-
-    (subscribe [:items])
-    (subscribe [:items \"blue\" :small])
-    (subscribe [:items {:colour \"blue\"  :size :small}])
-
+### Example Usage:
+
+   ```clj
+   (subscribe [:items])
+   (subscribe [:items \"blue\" :small])
+   (subscribe [:items {:colour \"blue\"  :size :small}])
+   ```
+
   Note: for any given call to `subscribe` there must have been a previous call
   to `reg-sub`, registering the query handler (function) for the `query-id` given.

-  Hint
-  ----
+  ### Hint

   When used in a view function BE SURE to `deref` the returned value.
   In fact, to avoid any mistakes, some prefer to define:
-
-     (def <sub  (comp deref re-frame.core/subscribe))
+
+  ```clj
+  (def <sub  (comp deref re-frame.core/subscribe))
+  ```

   And then, within their views, they call  `(<sub [:items :small])` rather
   than using `subscribe` directly.

-  De-duplication
-  --------------
+  ### De-duplication

   Two, or more, concurrent subscriptions for the same query will source reactive
   updates from the one executing handler.
@@ -286,15 +289,15 @@
   value is ignored.

   Example Use
-  -----------
-
   First, registration ... associate `:effect2` with a handler.
-
+
+  ```clj
   (reg-fx
      :effect2
      (fn [value]
         ... do something side-effect-y))
-
+  ```
+
   Then, later, if an event handler were to return this effects map ...

   {...
@@ -413,13 +416,15 @@
 (defn reg-event-fx
   "Register the given event `handler` (function) for the given `id`. Optionally, provide
   an `interceptors` chain.
-  `id` is typically a namespaced keyword  (but can be anything)
-  `handler` is a function: (coeffects-map event-vector) -> effects-map
-  `interceptors` is a collection of interceptors. Will be flattened and nils removed.
-  `handler` is wrapped in its own interceptor and added to the end of the interceptor
+
+    - `id` is typically a namespaced keyword  (but can be anything)
+    - `handler` is a function: (coeffects-map event-vector) -> effects-map
+    - `interceptors` is a collection of interceptors. Will be flattened and nils removed.
+    - `handler` is wrapped in its own interceptor and added to the end of the interceptor
    chain, so that, in the end, only a chain is registered.
-   Special effects and coeffects interceptors are added to the front of the
-   interceptor chain.  These interceptors inject the value of app-db into coeffects,
+
+   This function will add special effects and coeffects interceptors to the front of
+   `interceptors`. These additional interceptors inject the value of app-db into coeffects,
    and, later, action effects."
   ([id handler]
    (reg-event-fx id nil handler))
@@ -566,7 +571,6 @@
         [... trim-v ...]    ;; <-- added to the interceptors
         (fn [db [x y z]]    ;; <-- instead of [_ x y z]
           ...)
-
     "
   std-interceptors/trim-v)


Reformat todomvc.events ns

Reformat todomvc.events ns

--- examples/todomvc/src/todomvc/events.cljs
+++ examples/todomvc/src/todomvc/events.cljs
@@ -1,6 +1,6 @@
 (ns todomvc.events
   (:require
-    [todomvc.db    :refer [default-db todos->local-store]]
+    [todomvc.db :refer [default-db todos->local-store]]
     [re-frame.core :refer [reg-event-db reg-event-fx inject-cofx path after]]
     [cljs.spec.alpha :as s]
     [day8.re-frame.tracing :refer-macros [fn-traced]]))
@@ -76,9 +76,9 @@
 ;; which manipulate todos.
 ;; A chain of interceptors is a vector of interceptors.
 ;; Explanation of the `path` Interceptor is given further below.
-(def todo-interceptors [check-spec-interceptor    ;; ensure the spec is still valid  (after)
-                        (path :todos)             ;; the 1st param given to handler will be the value from this path within db
-                        ->local-store])            ;; write todos to localstore  (after)
+(def todo-interceptors [check-spec-interceptor              ;; ensure the spec is still valid  (after)
+                        (path :todos)                       ;; the 1st param given to handler will be the value from this path within db
+                        ->local-store])                     ;; write todos to localstore  (after)

 ;; -- Helpers -----------------------------------------------------------------
@@ -108,29 +108,29 @@
 ;; To fully understand this advanced topic, you'll have to read the tutorials
 ;; and look at the bottom of `db.cljs` for the `:local-store-todos` cofx
 ;; registration.
-(reg-event-fx                 ;; part of the re-frame API
-  :initialise-db              ;; event id being handled
+(reg-event-fx                                               ;; part of the re-frame API
+  :initialise-db                                            ;; event id being handled

   ;; the interceptor chain (a vector of 2 interceptors in this case)
-  [(inject-cofx :local-store-todos) ;; gets todos from localstore, and puts value into coeffects arg
-   check-spec-interceptor]          ;; after event handler runs, check app-db for correctness. Does it still match Spec?
+  [(inject-cofx :local-store-todos)                         ;; gets todos from localstore, and puts value into coeffects arg
+   check-spec-interceptor]                                  ;; after event handler runs, check app-db for correctness. Does it still match Spec?

   ;; the event handler (function) being registered
-  (fn [{:keys [db local-store-todos]} _]                  ;; take 2 values from coeffects. Ignore event vector itself.
-    {:db (assoc default-db :todos local-store-todos)}))   ;; all hail the new state to be put in app-db
+  (fn [{:keys [db local-store-todos]} _]                    ;; take 2 values from coeffects. Ignore event vector itself.
+    {:db (assoc default-db :todos local-store-todos)}))     ;; all hail the new state to be put in app-db

 ;; usage:  (dispatch [:set-showing  :active])
 ;; This event is dispatched when the user clicks on one of the 3
 ;; filter buttons at the bottom of the display.
-(reg-event-db      ;; part of the re-frame API
-  :set-showing     ;; event-id
+(reg-event-db                                               ;; part of the re-frame API
+  :set-showing                                              ;; event-id

   ;; only one interceptor
-  [check-spec-interceptor]       ;; after event handler runs, check app-db for correctness. Does it still match Spec?
+  [check-spec-interceptor]                                  ;; after event handler runs, check app-db for correctness. Does it still match Spec?

   ;; handler
-  (fn [db [_ new-filter-kw]]     ;; new-filter-kw is one of :all, :active or :done
+  (fn [db [_ new-filter-kw]]                                ;; new-filter-kw is one of :all, :active or :done
     (assoc db :showing new-filter-kw)))

 ;; NOTE: below is a rewrite of the event handler (above) using a `path` Interceptor
@@ -148,23 +148,23 @@
 ;; So, `path` operates a little like `update-in`
 ;;
 #_(reg-event-db
-  :set-showing
-
-  ;; this now a chain of 2 interceptors. Note use of `path`
-  [check-spec-interceptor (path :showing)]
-
-  ;; The event handler
-  ;; Because of the `path` interceptor above, the 1st parameter to
-  ;; the handler below won't be the entire 'db', and instead will
-  ;; be the value at the path `[:showing]` within db.
-  ;; Equally the value returned will be the new value for that path
-  ;; within app-db.
-  (fn [old-showing-value [_ new-showing-value]]
-    new-showing-value))                  ;; return new state for the path
+    :set-showing
+
+    ;; this now a chain of 2 interceptors. Note use of `path`
+    [check-spec-interceptor (path :showing)]
+
+    ;; The event handler
+    ;; Because of the `path` interceptor above, the 1st parameter to
+    ;; the handler below won't be the entire 'db', and instead will
+    ;; be the value at the path `[:showing]` within db.
+    ;; Equally the value returned will be the new value for that path
+    ;; within app-db.
+    (fn [old-showing-value [_ new-showing-value]]
+      new-showing-value))                                   ;; return new state for the path

 ;; usage:  (dispatch [:add-todo  "a description string"])
-(reg-event-db                     ;; given the text, create a new todo
+(reg-event-db                                               ;; given the text, create a new todo
   :add-todo

   ;; Use the standard interceptors, defined above, which we
@@ -187,38 +187,38 @@
   :toggle-done
   todo-interceptors
   (fn-traced [todos [_ id]]
-    (update-in todos [id :done] not)))
+             (update-in todos [id :done] not)))

 (reg-event-db
   :save
   todo-interceptors
   (fn-traced [todos [_ id title]]
-    (assoc-in todos [id :title] title)))
+             (assoc-in todos [id :title] title)))

 (reg-event-db
   :delete-todo
   todo-interceptors
   (fn-traced [todos [_ id]]
-    (dissoc todos id)))
+             (dissoc todos id)))

 (reg-event-db
   :clear-completed
   todo-interceptors
   (fn-traced [todos _]
-    (let [done-ids (->> (vals todos)         ;; which todos have a :done of true
-                        (filter :done)
-                        (map :id))]
-      (reduce dissoc todos done-ids))))      ;; delete todos which are done
+             (let [done-ids (->> (vals todos)               ;; which todos have a :done of true
+                                 (filter :done)
+                                 (map :id))]
+               (reduce dissoc todos done-ids))))            ;; delete todos which are done

 (reg-event-db
   :complete-all-toggle
   todo-interceptors
   (fn-traced [todos _]
-    (let [new-done (not-every? :done (vals todos))]   ;; work out: toggle true or false?
-      (reduce #(assoc-in %1 [%2 :done] new-done)
-              todos
-              (keys todos)))))
+             (let [new-done (not-every? :done (vals todos))] ;; work out: toggle true or false?
+               (reduce #(assoc-in %1 [%2 :done] new-done)
+                       todos
+                       (keys todos)))))


Fix /file/:state/<path> URL to allow arbitrary paths

--- src/server/handler.clj
+++ src/server/handler.clj
@@ -76,10 +76,10 @@
   ((:ring-ajax-post (:sente system)) req))

 (defroutes backend-routes
-  (GET  "/query"             req          (ajax-get-or-ws-handshake req))
-  (POST "/query"             req          (ajax-post req))
-  (GET  "/uml/:data"         [data]       (handle-uml data))
-  (GET  "/file/:state/:path" [state path] (handle-file state path))
+  (GET  "/query" req (ajax-get-or-ws-handshake req))
+  (POST "/query" req (ajax-post req))
+  (GET  "/uml/:data" [data] (handle-uml data))
+  (GET  "/file/:state/:path{.*}" [state path] (handle-file state path))

   (route/not-found "Not found"))


Accept node IDs in the old session requirements.

--- src/shale/sessions.clj
+++ src/shale/sessions.clj
@@ -73,7 +73,9 @@
   {(s/optional-key :browser-name)  s/Str
    (s/optional-key :reserved)      s/Bool
    (s/optional-key :tags)          [s/Str]
-   (s/optional-key :node)          {:url s/Str}})
+   (s/optional-key :node)          {(s/optional-key :id)   s/Str
+                                    (s/optional-key :url)  s/Str
+                                    (s/optional-key :tags) [s/Str]}})

 (defn first-checked-schema
   "Return the first schema which validates a value. Useful as a dispatch


Refactored for clarity

Refactored for clarity

--- src/sormilla/video.clj
+++ src/sormilla/video.clj
@@ -14,22 +14,7 @@

 (set! *warn-on-reflection* true)

-;;
-;; I/O
-;;
-
-(defn read-input ^bytes [^InputStream in ^bytes buffer ^Long size]
-  (.read in buffer 0 size)
-  ;(IOUtils/readFully in buffer 0 size)
-  buffer)
-
-(defn skip-input [^InputStream in ^long size]
-  (.skip in size)
-  in)
-
-;;
-;; Video decoding
-;;
+(def image (atom nil))

 (defn ba->ia [^bytes source ^ints target ^Long size]
   (loop [i 0]
@@ -37,29 +22,29 @@
     (when (< (inc i) size) (recur (inc i))))
   target)

-(defn signature [header]    (bin/get-int header 0))
-(defn header-size [header]  (bin/get-short header 6))
-(defn payload-size [header] (bin/get-int header 8))
-
 (defn buffer->image ^BufferedImage [^Long w ^Long h ^ints buffer]
   (let [image (BufferedImage. w h BufferedImage/TYPE_INT_RGB)]
     (.setRGB image 0 0 w h buffer 0 w)
     image))

+(defn read-buffer [^InputStream in buffer offset size]
+  (when (neg? (.read in buffer offset size)) (throw (java.io.EOFException.))))
+
 (defn make-reader [^InputStream in]
-  (let [header1  (byte-array 12)
-        header2  (byte-array 256)
+  (let [header   (byte-array 256)
         payload  (byte-array (+ 65535 MpegEncContext/FF_INPUT_BUFFER_PADDING_SIZE))]
     (fn []
-      (read-input in header1 12)
-      (when-not (= (bin/get-int header1 0) 0x45566150) (throw (java.io.IOException. "out of sync")))
-      (let [header-size  (bin/get-short header1 6)
-            payload-size (bin/get-int header1 8)]
-        (read-input in header2 (- header-size 12))
-        (read-input in payload payload-size)
-        [[header1 12]
-         [header2 header-size]
-         [payload payload-size]]))))
+      (try
+        (read-buffer in header 0 12)
+        (let [signature    (bin/get-int header 0)
+              header-size  (bin/get-short header 6)
+              payload-size (bin/get-int header 8)]
+          (when-not (= signature 0x45566150) (throw (java.io.IOException. "out of sync")))
+          (read-buffer in header 12 (- header-size 12))
+          (read-buffer in payload 0 payload-size)
+          [[header header-size] [payload payload-size]])
+        (catch java.io.EOFException _
+          nil)))))

 (defn make-decoder []
   (let [codec           (H264Decoder.)
@@ -68,12 +53,12 @@
         frame           (AVFrame/avcodec_alloc_frame)
         ibuffer         (int-array (+ 65535 MpegEncContext/FF_INPUT_BUFFER_PADDING_SIZE))
         got-picture?    (int-array [0])]
-
+
     (if-not (zero? (bit-and (.capabilities codec) H264Decoder/CODEC_CAP_TRUNCATED)) (throw (Exception. "need to configure CODEC_FLAG_TRUNCATED")))
     (if (neg? (.avcodec_open context codec)) (throw (Exception. "Could not open codec")))
     (.av_init_packet packet)
-
-    (fn ^BufferedImage [buffer size]
+
+    (fn ^BufferedImage [[^bytes buffer size]]
       (set! (.size packet) size)
       (set! (.data_base packet) (ba->ia buffer ibuffer size))
       (set! (.data_offset packet) 0)
@@ -88,76 +73,49 @@
         (FrameUtils/YUV2RGB picture picture-buffer)
         (buffer->image width height picture-buffer)))))

-;;
-;; Streaming:
-;;
-
-(def image (atom nil))
-
 (defn open-socket ^Socket []
   (doto (Socket.)
     (.setSoTimeout 2000)
     (.connect (InetSocketAddress.  "localhost" #_ comm/drone-ip 5555))))

-(defn get-date-time []
-  (.format (java.text.SimpleDateFormat. "yyyyMMdd-HHmmss") (java.util.Date.)))
-
 (defn save [^OutputStream out data]
   (doseq [[buffer size] data]
-    (.write out buffer 0 size)))
+    (.write out buffer 0 size))
+  out)
+
+(defmacro while-let [[l r] & body]
+  `(loop []
+     (when-let [v# ~r]
+       (let [~l v#]
+         ~@body)
+       (when v# (recur)))))

 (defn init-video-streaming! []
   (future
     (try
       (while (run?)
-        (let [socket   (open-socket)
-              out      (io/output-stream (io/file (str "sormilla-" (get-date-time) ".h264")))
-              reader   (make-reader (.getInputStream socket))
-              saver    (partial save out)
-              decoder  (make-decoder)]
+        (let [socket      (open-socket)
+              out         (agent (io/output-stream (io/file (str "sormilla-" (.format (java.text.SimpleDateFormat. "yyyyMMdd-HHmmss") (java.util.Date.)) ".h264"))))
+              reader      (make-reader (.getInputStream socket))
+              decoder     (make-decoder)]
           (try
             (doto (.getOutputStream socket)
               (.write (byte-array (map bin/ubyte [1 0 0 0])))
               (.flush))
-            (loop [data (reader)]
-              (saver data)
-              (reset! image (apply decoder (nth data 2)))
-              (when (run?) (recur (reader))))
+            (while-let [data (reader)]
+              (send-off out save data)
+              (reset! image (decoder (second data))))
             (catch java.io.IOException e
-              (println "I/O error:" e ": reconnecting..."))
+              (println "I/O error:" e ": reconnecting...")
+              (Thread/sleep 1000))
             (finally
-              (try (.close socket) (catch Exception _))))))
+              (try (.close socket) (catch Exception _))
+              (try (.close ^OutputStream @out) (catch Exception _))))))
       (catch Throwable e
         (println "exception while processing video stream" e)
-        (.printStackTrace e)
-        (Thread/sleep 1000))
+        (.printStackTrace e))
       (finally
         (reset! image nil)))))
-
-(defn init-video-saving! []
-  (future
-    (try
-      (while (run?)
-        (let [socket   (open-socket)
-              in       (io/input-stream socket)
-              out      (io/output-stream (io/file (str "sormilla-" (get-date-time) ".h264")))
-              buffer   (byte-array 4096)]
-          (try
-            (doto (.getOutputStream socket)
-              (.write (byte-array (map bin/ubyte [1 0 0 0])))
-              (.flush))
-            (while (run?)
-              (let [c (.read in buffer 0 4096)]
-                (.write out buffer 0 c)))
-            (catch java.io.IOException e
-              (println "I/O error:" e ": reconnecting..."))
-            (finally
-              (try (.close socket) (catch Exception e))
-              (try (.close out) (catch Exception e))))))
-      (catch Throwable e
-        (println "exception while processing video stream" e)
-        (.printStackTrace e)))))
-

 ;;
 ;; here be dragons...


whitespace

whitespace

--- server/src/gratefulplace/utils.clj
+++ server/src/gratefulplace/utils.clj
@@ -49,8 +49,6 @@
   []
   (java.util.Date.))

-
-
 (defmacro defnpd
   ;; defn with default positional arguments
   [name args & body]


CMR-2112 Fix business rule validation fail

--- ingest-app/src/cmr/ingest/services/ingest_service.clj
+++ ingest-app/src/cmr/ingest/services/ingest_service.clj
@@ -47,6 +47,7 @@
   (v/validate-concept-metadata collection-concept)
   (let [{:keys [format metadata]} collection-concept
         collection (spec/parse-metadata context :collection format metadata {:sanitize? false})
+        sanitized-collection (spec/parse-metadata context :collection format metadata {:sanitize? true})

     ;; Validate against the UMM Spec validation rules
         warnings (v/validate-collection-umm-spec context collection validation-options)]
@@ -55,7 +56,7 @@
                                (umm-legacy/parse-concept context collection-concept)
                                (:validate-keywords? validation-options))
     ;; The UMM Spec collection is returned
-    {:collection collection
+    {:collection sanitized-collection
      :warnings warnings}))

 (defn-timed validate-and-prepare-collection


remove unused views, make private views public

Just put a warning in the docstring instead of making it private

--- src/braid/client/ui/views/embed.cljs
+++ src/braid/client/ui/views/embed.cljs
@@ -10,7 +10,10 @@
     (str "rgb(" (arr 0) "," (arr 1) "," (arr 2) ")")
     "rgb(150, 150, 150)"))

-(defn- website-embed-view [content]
+(defn website-embed-view
+  "View for embedly generic website info. Prefer to use embed-view with a url
+  instead of this directly"
+  [content]
   [:div.content.loaded.website
    {:style {:background-color (url->color (content :original_url))}}
    (if-let [img (get-in content [:images 0])]
@@ -26,21 +29,20 @@
     [:div.title (:title content)]
     [:div.url (:url content)]]])

-(defn- video-overlay-view [content]
-  [:div.content
-   [:div.frame
-    {:dangerouslySetInnerHTML {:__html (:html (:media content))}}]])
-
-(defn- content-overlay-view [content])
-
-(defn- video-embed-view [content]
+(defn video-embed-view
+  "View for embedly video info. Prefer to use embed-view with a url instead of
+  this directly"
+  [content]
   [:div.video
    (when-let [img (get-in content [:images 0])]
      [:img {:src (img :url)
             :style {:background-color
                     (arr->rgb (get-in img [:colors 0 :color]))}}])])

-(defn- image-embed-view [content]
+(defn image-embed-view
+  "View for embedly image info. Prefer to use embed-view with a url instead of
+  this directly"
+  [content]
   [:div.image
    (when-let [img (get-in content [:images 0])]
      [:img {:src (img :url)


fix influx task tags mapper

fix influx task tags mapper

--- src/clj/swarmpit/influxdb/mapper.clj
+++ src/clj/swarmpit/influxdb/mapper.clj
@@ -4,8 +4,10 @@

 (defn ->task-tags [task-name host-name]
   (let [segments (drop 1 (str/split task-name #"/|\."))]
-    (if (= 1 segments)
-      nil
+    (if (= 1 (count segments))
+      {:task    (first segments)
+       :service "-" ;; can't be nil (influx throws exception)
+       :host    host-name}
       {:task    (str (first segments) "." (second segments))
        :service (first segments)
        :host    host-name})))


Make the target optional for throttle

Make the target optional for throttle

--- src/cljs/comic_reader/scrolling.cljs
+++ src/cljs/comic_reader/scrolling.cljs
@@ -1,7 +1,7 @@
 (ns comic-reader.scrolling
   (:require [re-frame.core :as rf]))

-(defn throttle [type key target]
+(defn throttle [type key & [target]]
   (let [target (or target js/window)
         running (atom false)
         toggle! #(swap! running not)


Extract let

Extract let

--- src/cljs/gc_api_browser/url_bar.cljs
+++ src/cljs/gc_api_browser/url_bar.cljs
@@ -7,20 +7,20 @@
             [gc-api-browser.schema-select :as schema-select]))

 (defn resource-selection [{:keys [selected-resource schema] :as request}]
-  (dom/div #js {:className "url-bar__item url-bar__item--resource select-container"}
-           (apply dom/select #js {:className "select-container__select input"
-                                  :value     selected-resource
-                                  :onChange  (partial schema-select/handle-resource-change request)}
-                  (map #(dom/option #js {:value %} %)
-                       (schema-select/schema->resources schema)))))
+  (let [resources (sort (schema-select/schema->resources schema))]
+    (dom/div #js {:className "url-bar__item url-bar__item--resource select-container"}
+             (apply dom/select #js {:className "select-container__select input"
+                                    :value     selected-resource
+                                    :onChange  (partial schema-select/handle-resource-change request)}
+                    (map #(dom/option #js {:value %} %) resources)))))

 (defn action-selection [{:keys [selected-resource selected-action schema] :as request}]
-  (dom/div #js {:className "url-bar__item url-bar__item--action select-container"}
-           (apply dom/select #js {:className "select-container__select input"
-                                  :value     (when selected-action (name selected-action))
-                                  :onChange  (partial schema-select/handle-action-change request)}
-                  (map #(dom/option #js {:value %} %)
-                       (schema-select/resource->actions schema selected-resource)))))
+  (let [actions (sort (schema-select/resource->actions schema selected-resource))]
+    (dom/div #js {:className "url-bar__item url-bar__item--action select-container"}
+             (apply dom/select #js {:className "select-container__select input"
+                                    :value     (when selected-action (name selected-action))
+                                    :onChange  (partial schema-select/handle-action-change request)}
+                    (map #(dom/option #js {:value %} %) actions)))))

 (defn edit-method [{:keys [method] :as cursor}]
   (dom/div #js {:className "url-bar__item url-bar__item--method select-container"}


remove duplicate subscriptions

remove duplicate subscriptions

--- src/cljs/phonecat_re_frame/subs.cljs
+++ src/cljs/phonecat_re_frame/subs.cljs
@@ -1,19 +1,13 @@
 (ns phonecat-re-frame.subs
   (:require [re-frame.core :refer [register-sub, subscribe]])
   (:require-macros [reagent.ratom :refer [reaction]]))
-
-(register-sub                                      ;; a new subscription handler
-  :phones                                                   ;; usage (subscribe [:phones])
-  (fn [db]
-    ;; extracts the phones property from the db
-    (reaction (:phones @db))))                              ;; pulls out :phones

 (register-sub
   :search-input
   (fn [db]
     (reaction (:search-input @db))))

-(register-sub                                      ;; a new subscription handler
+(register-sub                                               ;; a new subscription handler
   :phones                                                   ;; usage (subscribe [:phones])
   (fn [db]
     (reaction (:phones @db))))                              ;; pulls out :phones
@@ -36,11 +30,6 @@
               (first @images))))))))

 (register-sub
-  :phone-details
-  (fn [db]
-    (reaction (:phone-details @db))))
-
-(register-sub
   :order-prop
   (fn [db]
     (reaction (:order-prop @db))))


Create Contact info accounts work as links

--- src/cljs/salava/user/ui/profile.cljs
+++ src/cljs/salava/user/ui/profile.cljs
@@ -109,9 +109,15 @@
                                         :key)]]
                      [:tr
                       [:td.profile-field (t key) ":"]
-                      [:td (if (re-find #"^https?://" (str value))
-                             [:a {:href value :target "_blank"} (t value)]
-                             (t value))]]))]]]
+                      [:td (cond
+                             (or (re-find #"www." (str value)) (re-find #"^https?://" (str value))) [:a {:href value :target "_blank"} (t value)]
+                             (and (re-find #"@" (str value)) (= "twitter" field)) [:a {:href (str "https://twitter.com/" value) :target "_blank" } (t value)]
+                             (and (re-find #"@" (str value)) (= "email" field)) [:a {:href (str "mailto:" value)} (t value)]
+                             (and  (empty? (re-find #" " (str value))) (= "facebook" field)) [:a {:href (str "https://www.facebook.com/" value) :target "_blank" } (t value)]
+                             (and (re-find #"@" (str value)) (= "twitter" field)) [:a {:href (str "https://twitter.com/" value) :target "_blank" } (t value)]
+                             (and  (empty? (re-find #" " (str value))) (= "pinterest" field)) [:a {:href (str "https://www.pinterest.com/" value) :target "_blank" } (t value)]
+                             (and  (empty? (re-find #" " (str value))) (= "instagram" field)) [:a {:href (str "https://www.instagram.com/" value) :target "_blank" } (t value)]
+                             :else (t value))]]))]]]
           )]]
       (if (not-empty badges)
         [:div {:id "user-badges"}


Mild refactor and remove filter on "slow" tags


Make room in ZooKeeper.

Make room in ZooKeeper.

--- src/onyx/log/zookeeper.clj
+++ src/onyx/log/zookeeper.clj
@@ -26,6 +26,9 @@

 (defn flow-path [prefix]
   (str (prefix-path prefix) "/flow"))
+
+(defn lifecycles-path [prefix]
+  (str (prefix-path prefix) "/lifecycles"))

 (defn task-path [prefix]
   (str (prefix-path prefix) "/task"))
@@ -78,6 +81,7 @@
       (zk/create conn (catalog-path onyx-id) :persistent? true)
       (zk/create conn (workflow-path onyx-id) :persistent? true)
       (zk/create conn (flow-path onyx-id) :persistent? true)
+      (zk/create conn (lifecycles-path onyx-id) :persistent? true)
       (zk/create conn (task-path onyx-id) :persistent? true)
       (zk/create conn (sentinel-path onyx-id) :persistent? true)
       (zk/create conn (chunk-path onyx-id) :persistent? true)
@@ -237,6 +241,14 @@
            bytes (compress chunk)]
        (zk/create conn node :persistent? true :data bytes)))))

+(defmethod extensions/write-chunk [ZooKeeper :lifecycles]
+  [{:keys [conn opts prefix] :as log} kw chunk id]
+  (clean-up-broken-connections
+   (fn []
+     (let [node (str (lifecycles-path prefix) "/" id)
+           bytes (compress chunk)]
+       (zk/create conn node :persistent? true :data bytes)))))
+
 (defmethod extensions/write-chunk [ZooKeeper :task]
   [{:keys [conn opts prefix] :as log} kw chunk id]
   (clean-up-broken-connections
@@ -315,6 +327,13 @@
   (clean-up-broken-connections
    (fn []
      (let [node (str (flow-path prefix) "/" id)]
+       (decompress (:data (zk/data conn node)))))))
+
+(defmethod extensions/read-chunk [ZooKeeper :lifecycles]
+  [{:keys [conn opts prefix] :as log} kw id & _]
+  (clean-up-broken-connections
+   (fn []
+     (let [node (str (lifecycles-path prefix) "/" id)]
        (decompress (:data (zk/data conn node)))))))

 (defmethod extensions/read-chunk [ZooKeeper :task]


Made a square render!

Made a square render!

--- src/petulant_life/main.clj
+++ src/petulant_life/main.clj
@@ -1,24 +1,43 @@
 (ns petulant-life.main
   (:import (org.lwjgl.opengl DisplayMode
-                             Display)))
+                             Display
+                             GL11)))

+; Defining some width and height constraints to the program.
 (def width 640)
 (def height 480)

 ; Initializing the OpenGL window.
 (defn create []
   (Display/setDisplayMode (DisplayMode. width height))
-  (Display/create))
+  (Display/create)
+
+  (GL11/glMatrixMode GL11/GL_PROJECTION)
+  (GL11/glLoadIdentity)
+  (GL11/glOrtho 0 width height 0 -1 1)
+  (GL11/glMatrixMode GL11/GL_MODELVIEW))

 ; Cleaning up the LWJGL context.
 (defn destroy []
   (Display/destroy))

+; Rendering a square.
+(defn renderSquare [x y w h]
+  (GL11/glColor3f 1 1 1)
+  (GL11/glBegin GL11/GL_QUADS)
+    (GL11/glVertex2f x y)
+    (GL11/glVertex2f (+ x w) y)
+    (GL11/glVertex2f (+ x w) (+ y h))
+    (GL11/glVertex2f x (+ y h))
+  (GL11/glEnd))
+
 ; Running the simulation / graphics.
 (defn run []
   (loop [running true]
     (if (and running (not (Display/isCloseRequested)))
-      (do (Display/update)
+      (do (GL11/glClear GL11/GL_COLOR_BUFFER_BIT)
+          (renderSquare 10 10 50 50)
+          (Display/update)
           (recur true))
       nil)))


Fix debug string construction

Fix debug string construction

--- storm-core/src/clj/backtype/storm/daemon/logviewer.clj
+++ storm-core/src/clj/backtype/storm/daemon/logviewer.clj
@@ -124,11 +124,18 @@
 (defn cleanup-fn! [log-root-dir]
   (let [now-secs (current-time-secs)
         old-log-files (select-files-for-cleanup *STORM-CONF* (* now-secs 1000) log-root-dir)
-        dead-worker-files (get-dead-worker-files-and-owners *STORM-CONF* now-secs old-log-files log-root-dir)]
+        owner->files (get-dead-worker-files-and-owners *STORM-CONF*
+                                                       now-secs
+                                                       old-log-files
+                                                       log-root-dir)]
     (log-debug "log cleanup: now(" now-secs
-               ") old log files (" (seq (map #(.getName %) old-log-files))
-               ") dead worker files (" (seq (map #(.getName %) dead-worker-files)) ")")
-    (dofor [{:keys [owner files]} dead-worker-files
+               ") old log files (" (mapcat #(.getName %) old-log-files)
+               ") dead worker files (" (mapcat #(for [{f :files} %
+                                                      :when f]
+                                                  (.getName f))
+                                               owner->files)
+               ")")
+    (dofor [{:keys [owner files]} owner->files
             file files]
       (let [path (.getCanonicalPath file)]
         (log-message "Cleaning up: Removing " path)


This time really fixed atom deref bug on handle-profile-data function

--- src/polismath/conv_man.clj
+++ src/polismath/conv_man.clj
@@ -131,8 +131,9 @@
 (defn handle-profile-data
   "For now, just log profile data. Eventually want to send to influxDB and graphite."
   [conv]
-  (if-let [prof @(:profile-data conv)]
-    (let [tot (apply + (map second prof))
+  (if-let [prof-atom (:profile-data conv)]
+    (let [prof @prof-atom
+          tot (apply + (map second prof))
           prof (assoc prof :total tot)]
       (log/debug "Profile data for zid" (:zid conv) ": " prof))))


Use fn to get all selected pokemon

Use fn to get all selected pokemon

--- frontend/src/cruncher/shredder/main.cljs
+++ frontend/src/cruncher/shredder/main.cljs
@@ -6,7 +6,8 @@
             [cruncher.communication.utils :as clib]
             [cruncher.communication.main :as com]
             [cruncher.communication.progress :as progress]
-            [cruncher.selections :as selections]))
+            [cruncher.selections :as selections]
+            [cruncher.utils.views :as vlib]))

 (defn success-handler
   "React on response after sending a new statement. Reset atom and call newly received url."
@@ -19,7 +20,7 @@
   [this]
   (selections/unselect-favorites)
   (let [url (:crunch-selected-pokemon config/api)
-        selected-pokemon (vec (map #(.. % -value) (filter #(.. % -checked) (gdom/getElementsByClass "poketable-checkbox"))))]
+        selected-pokemon (vlib/get-selected-pokemon)]
     (when (pos? (count selected-pokemon))
       (when (js/confirm "Do you really want to send away the selected Pokemon?\nYou won't get them back!\n\nConsider your decision.")
         (lib/loading!)


Fix userface update logic

Fix userface update logic


PoC of continuation monad has been added

--- core/src/cljc/playground.cljc
+++ core/src/cljc/playground.cljc
@@ -75,3 +75,22 @@
           (println "hasdsadasndsakndakdnkjsandkasndakjndksajdnakndakjdnakdjnakjdnakjdnakdjnakdjand")
           (println (.toString t)))
         (println "Successsssss")))))
+
+
+
+(defn return
+  [v]
+  (fn [continuation]
+    (continuation v)))
+
+(defn value
+  [mv]
+  (mv identity))
+
+(value (return 5))
+
+(defn bind
+  [mv f]
+  (fn [continuation]
+    (mv (fn [v]
+          ((f v) continuation)))))


Chad suggested red/green in the hipchat message for success/failure.

--- src/circle/backend/build/email.clj
+++ src/circle/backend/build/email.clj
@@ -26,7 +26,8 @@
 (defn build-url [build]
   (ruby/send (ruby/->instance :Build build) :absolute_url))

-(defn send-hipchat-message [project message & args]
+(defn send-hipchat-message [project message & {:keys [color]
+                                               :or {color :yellow}}]
   (let [token (-> :hipchat_api_token project)
         room (-> :hipchat_room project)]
     (when (and token room)
@@ -35,23 +36,27 @@
        {:room_id room
         :from "Circle"
         :notify 1
-        :message (apply format message args)}))))
+        :color (name color)
+        :message message}))))

 (defn send-hipchat-build-notification [build]
   (let [project (build/get-project build)
         message (build-message @build)
-        url (build-url @build)]
-    (send-hipchat-message project "%s" url message)))
+        url (build-url @build)
+        message (format "%s" url message)
+        success? (-> @build :failed not)
+        color (if success? :green :red)]
+    (send-hipchat-message project message :color color)))

 (defn send-hipchat-setup-notification [project-id]
   (ruby/ruby-require :project)
   (let [project (project/get-by-id (ObjectId. project-id))
         url (project-url project)
-        project-name (github-project-name project)]
-    (send-hipchat-message project
-                          "Hi, welcome to Circle! Hipchat notifications are now enabled for %s"
-                          url
-                          project-name)))
+        project-name (github-project-name project)
+        message (format  "Hi, welcome to Circle! Hipchat notifications are now enabled for %s"
+                         url
+                         project-name)]
+    (send-hipchat-message project message)))


Added missing link on about us page

Added missing link on about us page

Allowed the games button to actually take you to the games page

--- src/clj/clj_mini_apps/about_us.clj
+++ src/clj/clj_mini_apps/about_us.clj
@@ -15,7 +15,7 @@
 		    [:li {:role "presentation"}
 		      [:a {:href "/"} "Home"]]
 		    [:li {:role "presentation"}
-		      [:a {:href ""} "Games"]]
+		      [:a {:href "/games"} "Games"]]
 		    [:li {:role "presentation"}
 		      [:a {:href "/blog"} "Blog"]]
 		    [:li {:role "presentation"}


Correct history hooking?

Correct history hooking?

--- src/cljs/comic_reader/history.cljs
+++ src/cljs/comic_reader/history.cljs
@@ -14,9 +14,9 @@
                          (.getElementById js/document
                                           "history_state"))]
       (reset! goog-history hist)
+      (events/listen hist
+          EventType/NAVIGATE
+        (fn [event]
+          (dispatch! (.-token event))))
       (doto hist
-        (events/listen
-            EventType/NAVIGATE
-            (fn [event]
-              (dispatch! (.-token event))))
         (.setEnabled true)))))


all timers use the same formatting

all timers use the same formatting

--- src/clojure/com/gt/metime/main.clj
+++ src/clojure/com/gt/metime/main.clj
@@ -11,8 +11,7 @@
             [com.gt.metime.time :refer [millis-to-format-time format-time-to-millis]]
             [com.gt.metime.listing :refer [listing add-to-listing remove-from-listing sorted-map-array-to-array-task]])
   (:import [android.os SystemClock CountDownTimer]
-           [android.widget CursorAdapter TextView LinearLayout Chronometer]
-           android.graphics.Color
+           [android.widget CursorAdapter TextView LinearLayout Chronometer Chronometer$OnChronometerTickListener]
            [java.util Calendar]
            [android.app Activity DialogFragment]
            android.view.View
@@ -50,6 +49,11 @@
             :classname android.widget.Chronometer
             :inherits  :text-view)

+(defn get-chronometer-listener []
+   (proxy [Chronometer$OnChronometerTickListener] []
+     (onChronometerTick [chronometer]
+       (config chronometer :text (str (millis-to-format-time (- (SystemClock/elapsedRealtime) (.getBase chronometer))))))))
+
 (defn make-date-adapter []
   (adapters/ref-adapter
     (fn [_]
@@ -65,7 +69,7 @@
         [:button {:id ::event-btn}]
         [:button {:id   ::delete-btn
                   :text "del"}]]])
-    (fn [indx view _ task]
+    (fn [_ view _ task]
       (let [date-text-view (find-view view ::date-tv)
             event-linear-layout-view (find-view view ::event-ll)
             event-text-view (find-view event-linear-layout-view ::event-tv)
@@ -74,14 +78,13 @@
             event-delete-button-view (find-view event-linear-layout-view ::delete-btn)
             timer-context (:timer-context task)]

+        (.setOnChronometerTickListener event-chonometer (get-chronometer-listener))
+
         ;mutates the viz
         (config date-text-view :visibility (if (= (:date-index task) 0) View/VISIBLE View/GONE))
         (config date-text-view :text (str (:date task)))

         (.stop event-chonometer)
-
-
-

         (if
           (:running @timer-context)


Fix startup script

Fix startup script

to use new calling convention of conexp.contrib.gui/gui

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

--- src/scripts/conexp-clj.clj
+++ src/scripts/conexp-clj.clj
@@ -17,15 +17,18 @@
                                   ["--gui"  "Start the graphical user interface"]
                                   ["--load" "Load a given script"]
                                   ["--help" "This help"])]
+  ;;
   (when (contains? options :help)
     (println doc)
     (System/exit 0))
+  ;;
   (when (contains? options :gui)
     (clojure.main/repl :init #(do
                                 (use 'conexp.main)
                                 (use 'conexp.contrib.gui)
                                 (@(ns-resolve 'conexp.contrib.gui 'gui)
-                                 :default-close-operation javax.swing.JFrame/EXIT_ON_CLOSE))))
+                                 :default-close-operation :exit))))
+  ;;
   (when (contains? options :load)
     (use 'conexp.main)
     (when (not (options :load))
@@ -33,6 +36,7 @@
       (println doc)
       (System/exit 1))
     (load-file (options :load)))
+  ;;
   (when-not (or (options :gui)
                 (options :load))
     (clojure.main/repl :init #(do (use 'conexp.main) (use 'clojure.repl)))))


Require blacklisted gems before using them

--- src/circle/backend/build/inference/rails.clj
+++ src/circle/backend/build/inference/rails.clj
@@ -13,6 +13,7 @@
   (:require [circle.util.map :as map])
   (:require circle.backend.nodes.rails)
   (:require [circle.backend.build.inference.mysql :as mysql])
+  (:use [circle.backend.build.inference.gems-map :only (blacklisted-gems)])
   (:require [circle.backend.build.inference.postgres :as postgres]))

 (defn bundler?
@@ -189,7 +190,7 @@
     (sh/q (sed -i ~(format "\"%s\"" sed-str) Gemfile))))

 (defn blacklist []
-  (bash (sh/q (doseq [g ~circle.backend.build.inference.gems-map/blacklisted-gems]
+  (bash (sh/q (doseq [g ~blacklisted-gems]
                 ~(sed-gem "$g")))
         :name "blacklist problematic gems"))


Tiny cleanup

Tiny cleanup

--- src/snergly/animation.cljs
+++ src/snergly/animation.cljs
@@ -49,13 +49,13 @@
 (defn analysis-steps [{:keys [analysis] :as maze-params} ui]
   (println (str "analysis: " analysis))
   (condp = analysis
-    "none" []
-    "distances" [#(produce-distances % maze-params ui :dist-1 nil)]
-    "path" [#(produce-distances % maze-params ui :dist-1 nil)
-            #(produce-path % maze-params ui :dist-1 false)]
-    "longest path" [#(produce-distances % maze-params ui :dist-1 nil)
+    "none"         []
+    "distances"    [#(produce-distances % maze-params ui :dist-1 nil    )]
+    "path"         [#(produce-distances % maze-params ui :dist-1 nil    )
+                    #(produce-path      % maze-params ui :dist-1 false  )]
+    "longest path" [#(produce-distances % maze-params ui :dist-1 nil    )
                     #(produce-distances % maze-params ui :dist-2 :dist-1)
-                    #(produce-path % maze-params ui :dist-2 true)]))
+                    #(produce-path      % maze-params ui :dist-2 true   )]))

 (defn produce-maze [{:keys [rows columns algorithm] :as maze-params} ui]
   (println (str "algorithm: " algorithm))


Improve fitting (include last point)

Improve fitting (include last point)

--- src/clj/clojurewerkz/statistiker/fitting.clj
+++ src/clj/clojurewerkz/statistiker/fitting.clj
@@ -45,4 +45,4 @@
     (mapv
      (fn [x-val]
        {x x-val y (.value f (double x-val))})
-     (take steps (iterate #(+ % step) min-x)))))
+     (take (inc steps) (iterate #(+ % step) min-x)))))


Added a warning if any of the namespaces given to web-function-resources is nil - this is to avoid lengthy debug sessions in future.

--- src/main/clojure/plugboard/webfunction/plugboards.clj
+++ src/main/clojure/plugboard/webfunction/plugboards.clj
@@ -145,20 +145,22 @@
      :otherwise false)))

 (defn web-function-resources [namespaces]
-  {:init (fn [state]
-           (-> state
-               (assoc ::web-namespaces namespaces)
-               (assoc plugboard/path (get-in state [:request :route-params :*]))))
-   plugboard/malformed? (fn [state dlg]
-                          [false (assoc state
-                                   ::uri-matching-web-functions
-                                   (get-matching-webfunctions-for-path
-                                    (get state plugboard/path)
-                                    (get state ::web-namespaces)))])
-   plugboard/resource-exists? (fn [state dlg]
-                                (let [result
-                                      (not (empty? (filter is-resource (get state ::uri-matching-web-functions))))]
-                                  [result state]))})
+  (if (not (every? #(not (nil? %)) namespaces))
+    (throw (Exception. "If any of the namespaces given to this function are nil, this will cause errors and confusion during requests. Please fix this error before proceeding."))
+    {:init (fn [state]
+             (-> state
+                 (assoc ::web-namespaces namespaces)
+                 (assoc plugboard/path (get-in state [:request :route-params :*]))))
+     plugboard/malformed? (fn [state dlg]
+                            [false (assoc state
+                                     ::uri-matching-web-functions
+                                     (get-matching-webfunctions-for-path
+                                      (get state plugboard/path)
+                                      (get state ::web-namespaces)))])
+     plugboard/resource-exists? (fn [state dlg]
+                                  (let [result
+                                        (not (empty? (filter is-resource (get state ::uri-matching-web-functions))))]
+                                    [result state]))}))

 (defn set-header [state name value]
   (update-in state [:response :headers] (fn [old] (assoc old name value))))


tags (simple) widget keyboard control

tags (simple) widget keyboard control

--- src/cljs/re_form/inputs/tags_input_impl.cljs
+++ src/cljs/re_form/inputs/tags_input_impl.cljs
@@ -8,19 +8,20 @@
   [{:keys [radius w h h2 h3 selection-bg-color hover-bg-color border error-border]}]
   [:div.re-tags-container
    {:display "inline-block"
-     :min-width "30em"
-     :background-color :white
-     :padding [[(u/px 3) (u/px 12)]]
-     :border-radius (u/px 2)
-     :line-height (u/px h2)
+    :min-width "30em"
+    :background-color :white
+    :padding [[(u/px 3) (u/px 12)]]
+    :border-radius (u/px 2)
+    :line-height (u/px h2)
     :border border}
    [:&.empty-tags
     {:padding [[(u/px 4) (u/px 12)]]}]
    [:input {:border :none
-            :width (u/px 100)
-            :outline :none}]
+            :width (u/px 100)}]
    [:.tag
     {:border border
+     :color :inherit
+     :text-decoration :inherit
      :position :relative
      :display :inline-flex
      :align-items :center
@@ -31,10 +32,38 @@
      {:cursor :pointer
       :font-size (u/px h)}]]])

-(defn tag [label on-delete]
-  [:span.tag label
-   [:i.cross.material-icons
-    {:on-click on-delete} "close"]])
+(defn tag [label nodes on-delete]
+  (let [state (r/atom {})
+        keydown-listener
+        (fn [ev]
+          (cond
+
+            (#{46 8} (.-keyCode ev))
+            (let [ntag (.. ev -target -nextSibling)]
+              (on-delete)
+              (.focus ntag))
+
+            (#{32 13} (.-keyCode ev))
+            (do
+              (.focus (:input @nodes))
+              (.preventDefault ev))))]
+    (r/create-class
+     {:component-did-mount
+      (fn [this]
+        (.addEventListener (:root @state) "keydown" keydown-listener))
+
+      :component-will-unmount
+      (fn [this]
+        (.removeEventListener (:root @state) "keydown" keydown-listener))
+
+      :reagent-render
+      (fn [label nodes on-delete]
+        [:a.tag
+         {:href "javascript:void(0)"
+          :ref (fn [this] (swap! state assoc :root this))}
+         label
+         [:i.cross.material-icons
+          {:on-click on-delete} "close"]])})))

 (defn tags [{:keys [value on-change space-delimiter]}]
   (let [setgen #(-> % vector set)
@@ -81,8 +110,9 @@
          {:class (when (empty? value) :empty-tags)
           :ref (fn [this] (swap! nodes assoc :root-node this))}
          (for [v value] ^{:key v}
-           [tag v #(on-change (s/difference (set value) (setgen v)))])
+           [tag v nodes #(on-change (s/difference @inner-value (setgen v)))])
          [:input.new-tag {:type :text
                           :ref (fn [this] (swap! nodes assoc :input this))
+                          :on-blur add-tag
                           :value @newtag
                           :on-change #(reset! newtag (.. % -target -value))}]])})))


Add switch for resampling; experimentation.

--- src/clojush/problems/classification/penn.clj
+++ src/clojush/problems/classification/penn.clj
@@ -30,7 +30,9 @@
     (println "Total number of data lines:" (count lines))
     (mapv #(mapv read-string %) lines)))

-(def training-proportion 0.5) ;; proportion of training cases to use each generation
+(def training-proportion 0.2) ;; proportion of training cases to use each generation
+
+(def resampling false)

 (defn define-fitness-cases
   "Returns a map with two keys: train and test. Train maps to a
@@ -92,7 +94,7 @@
                       (count best-test-errors))))(flush)
     (printf "\nTest RMSE: %.4f" (float (rmse best-test-errors)))(flush)
     (printf "\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n")(flush)
-    (when (< training-proportion 1)
+    (when (and resampling (< training-proportion 1))
       (println "Resampling training cases...")
       (swap! penn-fitness-cases
              #(assoc % :train (vec (take (count (:train %))
@@ -107,16 +109,21 @@
   (println @penn-fitness-cases)
   (println ";;******************************"))

+(defn cycle-to-longest
+  [& sequences]
+  (let [max-count (apply max (map count sequences))]
+    (vec (apply concat (map #(take max-count (cycle %)) sequences)))))
+
 (def penn-atom-generators
-  (vec (concat (distinct (mapv :target (:all-train @penn-fitness-cases))) ;; classes, for output
-               (list (tag-instruction-erc [:exec :integer :float :boolean :string] 1000)
-                     (tagged-instruction-erc 1000)
-                     (fn [] (lrand-int 1000))
-                     (fn [] (lrand 1)))
-               (for [n (map inc
-                            (range (count (:inputs (first (:train @penn-fitness-cases))))))]
-                 (symbol (str "in" n)))
-               (registered-for-stacks [:exec :integer :float :boolean :string]))))
+  (cycle-to-longest (concat (distinct (mapv :target (:all-train @penn-fitness-cases))) ;; classes, for output
+                            (list (tag-instruction-erc [:exec :integer :float :boolean :string] 1000)
+                                  (tagged-instruction-erc 1000)
+                                  (fn [] (lrand-int 1000))
+                                  (fn [] (lrand 1))))
+                    (for [n (map inc
+                                 (range (count (:inputs (first (:train @penn-fitness-cases))))))]
+                      (symbol (str "in" n)))
+                    (registered-for-stacks [:exec :integer :float :boolean :string])))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Main call
@@ -136,10 +143,13 @@
    ;                                 ;*** [:alternation :uniform-mutation] 0.4
    ;                                 :genesis 0.1 ;***
    ;                                 }
-   :genetic-operator-probabilities {:uniform-addition-and-deletion 0.5
-                                    :uniform-combination-and-deletion 0.5}
-   :uniform-addition-and-deletion-rate [1 1/2 1/4 1/8 1/16 1/32 1/64 1/128]
-   :uniform-combination-and-deletion-rate [1 1/2 1/4 1/8 1/16 1/32 1/64 1/128]
+   ;:genetic-operator-probabilities {:uniform-addition-and-deletion 0.45
+   ;                                 :uniform-combination-and-deletion 0.45
+   ;                                 :genesis 0.1}
+   :genetic-operator-probabilities {:uniform-addition-and-deletion 0.9
+                                    :uniform-combination-and-deletion 0.1}
+   :uniform-addition-and-deletion-rate [0.1 0.01] ;[1/16 1/32 1/64 1/128]
+   :uniform-combination-and-deletion-rate 1 ;[1 1/2 1/4 1/8]
    :alternation-rate 0.01
    :alignment-deviation 10
    :uniform-mutation-rate 0.01
@@ -148,8 +158,8 @@
    ;:print-behavioral-diversity true ;; requires maintaining @population-behaviors
    :report-simplifications 0
    :final-report-simplifications 5000
-   :age-mediated-parent-selection [0.05 0.5]
-   :age-combining-function :proportionate
+   ;:age-mediated-parent-selection [0.05 0.5]
+   ;:age-combining-function :proportionate
    ;:age-combining-function :first-reuse
    ;:autoconstructive true
    ;:autoconstructive-genome-instructions :uniform


Improve log message for stale report/node sweep

Prior to this commit, we were converting the TTL values to days
before logging them during the node/report cleanup.  Now that
we are accepting finer-grained intervals for configuring these
fields, we may as well log them in a more readable format.

--- src/com/puppetlabs/puppetdb/cli/services.clj
+++ src/com/puppetlabs/puppetdb/cli/services.clj
@@ -58,7 +58,7 @@
   (:use [clojure.java.io :only [file]]
         [clj-time.core :only [ago secs days]]
         [clojure.core.incubator :only (-?>)]
-        [com.puppetlabs.time :only [to-secs to-days parse-period]]
+        [com.puppetlabs.time :only [to-secs parse-period format-period]]
         [com.puppetlabs.jdbc :only (with-transacted-connection)]
         [com.puppetlabs.utils :only (cli! configure-logging! inis-to-map with-error-delivery)]
         [com.puppetlabs.repl :only (start-repl)]
@@ -103,7 +103,9 @@
   that haven't been active in the last `node-ttl-seconds`, and clearing out
   reports that are older than `report-ttl-seconds`"
   [db interval node-ttl-seconds report-ttl-seconds]
-  {:pre [(integer? report-ttl-seconds)]}
+  {:pre [(pos? interval)
+         (>= node-ttl-seconds 0)
+         (>= report-ttl-seconds 0)]}
   (let [sleep #(Thread/sleep (* 60 1000 interval))]
     (pl-utils/keep-going
      (fn [exception]
@@ -117,16 +119,16 @@

      (when (pos? node-ttl-seconds)
        (pl-utils/demarcate
-        (format "sweep of stale nodes (%s day threshold)"
-              (to-days (secs node-ttl-seconds)))
+        (format "sweep of stale nodes (threshold: %s)"
+          (format-period (secs node-ttl-seconds)))
         (with-transacted-connection db
           (doseq [node (scf-store/stale-nodes (ago (secs node-ttl-seconds)))]
             (send-command! "deactivate node" 1 (json/generate-string node))))))

      (when (pos? report-ttl-seconds)
        (pl-utils/demarcate
-        (format "sweep of stale reports (%s day threshold)"
-          (to-days (secs report-ttl-seconds)))
+        (format "sweep of stale reports (threshold: %s)"
+          (format-period (secs report-ttl-seconds)))
         (with-transacted-connection db
           (scf-store/delete-reports-older-than! report-ttl-seconds))))


Extract garbage collection tasks to their own functions

This simplifies the GC loop, and lets us refactor those functions
independently, or break them out.

--- src/com/puppetlabs/puppetdb/cli/services.clj
+++ src/com/puppetlabs/puppetdb/cli/services.clj
@@ -93,6 +93,47 @@
    (with-open [conn (mq/connect! mq)]
      (command/process-commands! conn mq-endpoint discard-dir {:db db}))))

+(defn auto-deactivate-nodes!
+  "Deactivate nodes which haven't had any activity (catalog/fact submission) in
+  more than `node-ttl-seconds` seconds."
+  [db node-ttl-seconds]
+  (pl-utils/demarcate
+    (format "sweep of stale nodes (threshold: %s)"
+            (format-period (secs node-ttl-seconds)))
+    (with-transacted-connection db
+      (doseq [node (scf-store/stale-nodes (ago (secs node-ttl-seconds)))]
+        (send-command! "deactivate node" 1 (json/generate-string node))))))
+
+(defn purge-nodes!
+  "Delete nodes which have been *deactivated* for more than
+  `node-purge-ttl-seconds` seconds."
+  [db node-purge-ttl-seconds]
+  (pl-utils/demarcate
+    (format "purge deactivated nodes (threshold: %s)"
+            (format-period (secs node-purge-ttl-seconds)))
+    (with-transacted-connection db
+      (scf-store/purge-deactivated-nodes! (ago (secs node-purge-ttl-seconds))))))
+
+(defn sweep-reports!
+  "Delete reports which are older than than `report-ttl-seconds` seconds."
+  [db report-ttl-seconds]
+  (pl-utils/demarcate
+    (format "sweep of stale reports (threshold: %s)"
+            (format-period (secs report-ttl-seconds)))
+    (with-transacted-connection db
+      (scf-store/delete-reports-older-than! (ago (secs report-ttl-seconds))))))
+
+(defn garbage-collect!
+  "Perform garbage collection on `db`, which means deleting any orphaned data.
+  This basically just wraps the corresponding scf.storage function with some
+  logging and other ceremony. Exceptions are logged but otherwise ignored."
+  [db]
+  {:pre [(map? db)]}
+  (pl-utils/demarcate
+    "database garbage collection"
+    (with-transacted-connection db
+      (scf-store/garbage-collect!))))
+
 (defn sweep-database!
   "Sweep the indicated database every `interval` minutes.

@@ -115,31 +156,15 @@
         (sleep))

       (when (pos? node-ttl-seconds)
-        (pl-utils/demarcate
-          (format "sweep of stale nodes (threshold: %s)"
-                  (format-period (secs node-ttl-seconds)))
-          (with-transacted-connection db
-            (doseq [node (scf-store/stale-nodes (ago (secs node-ttl-seconds)))]
-              (send-command! "deactivate node" 1 (json/generate-string node))))))
+        (auto-deactivate-nodes! db node-ttl-seconds))

       (when (pos? node-purge-ttl-seconds)
-        (pl-utils/demarcate
-          (format "purge deactivated nodes (threshold: %s)"
-                  (format-period (secs node-purge-ttl-seconds)))
-          (with-transacted-connection db
-            (scf-store/purge-deactivated-nodes! (ago (secs node-purge-ttl-seconds))))))
+        (purge-nodes! db node-purge-ttl-seconds))

       (when (pos? report-ttl-seconds)
-        (pl-utils/demarcate
-          (format "sweep of stale reports (threshold: %s)"
-                  (format-period (secs report-ttl-seconds)))
-          (with-transacted-connection db
-            (scf-store/delete-reports-older-than! (ago (secs report-ttl-seconds))))))
-
-      (pl-utils/demarcate
-        "database garbage collection"
-        (with-transacted-connection db
-          (scf-store/garbage-collect!)))
+        (sweep-reports! db report-ttl-seconds))
+
+      (garbage-collect! db)

       (sleep))))


Implemented average-robustness

Implemented average-robustness

--- src/main/clojure/conexp/fca/more.clj
+++ src/main/clojure/conexp/fca/more.clj
@@ -302,5 +302,25 @@
   ([concept concepts alpha]
    (concept-robustness concept concepts alpha false)))

+;;; Average robustness of all concepts of a context.
+
+(defn average-concept-robustness
+  "Takes the seq `concepts' which should contain the concepts of a context
+   and computes the average concept robustness with parmater `alpha'."
+  [concepts alpha]
+  (assert (<= 0 alpha 1) "Second argument must be between 0 and 1!")
+  (let [sortedconcepts (sort-by
+                         #(count (second %))
+                         concepts)
+        n (count sortedconcepts)
+        robustness-values (map
+                            #(concept-robustness
+                               (nth sortedconcepts %)
+                               (drop % sortedconcepts)
+                               alpha
+                               true)
+                            (range 0 n))]
+    (/ (reduce + robustness-values) n)))
+
 ;;;
 nil


Work around clojurescript compiler bug

Work around clojurescript compiler bug

--- src-cljs/frontend/api.cljs
+++ src-cljs/frontend/api.cljs
@@ -69,20 +69,22 @@

 ;; Note that dashboard-builds-url can take a :page (within :query-params)
 ;; and :builds-per-page, or :limit and :offset directly.
-(defn dashboard-builds-url [{:keys [branch repo org admin deployments query-params builds-per-page vcs_type offset limit]
+(defn dashboard-builds-url [{:keys [branch repo org admin deployments query-params builds-per-page offset limit]
                              :or {offset (* (get query-params :page 0) builds-per-page)
-                                  limit builds-per-page}}]
-  (let [url (cond admin "/api/v1/admin/recent-builds"
+                                  limit builds-per-page}
+                             :as args}]
+  (let [vcs-type (:vcs_type args)
+        url (cond admin "/api/v1/admin/recent-builds"
                   deployments "/api/v1/admin/deployments"
-                  branch (case vcs_type
+                  branch (case vcs-type
                            "github" (gstring/format "/api/v1/project/%s/%s/tree/%s" org repo branch)
-                           "bitbucket" (gstring/format "/api/dangerzone/project/%s/%s/%s/tree/%s" vcs_type org repo branch))
-                  repo (case vcs_type
+                           "bitbucket" (gstring/format "/api/dangerzone/project/%s/%s/%s/tree/%s" vcs-type org repo branch))
+                  repo (case vcs-type
                          "github" (gstring/format "/api/v1/project/%s/%s" org repo)
-                         "bitbucket" (gstring/format "/api/dangerzone/project/%s/%s/%s" vcs_type org repo))
-                  org (case vcs_type
+                         "bitbucket" (gstring/format "/api/dangerzone/project/%s/%s/%s" vcs-type org repo))
+                  org (case vcs-type
                         "github" (gstring/format "/api/v1/organization/%s" org)
-                        "bitbucket" (gstring/format "/api/dangerzone/organization/%s/%s" vcs_type org))
+                        "bitbucket" (gstring/format "/api/dangerzone/organization/%s/%s" vcs-type org))
                   :else "/api/v1/recent-builds")]
     (str url "?" (sec/encode-query-params (merge {:shallow true
                                                   :offset offset


STORM-1735: Nimbus should log that replication succeeded when min replicas was reached exactly

--- storm-core/src/clj/org/apache/storm/daemon/nimbus.clj
+++ storm-core/src/clj/org/apache/storm/daemon/nimbus.clj
@@ -518,9 +518,9 @@
           (reset! current-replication-count-jar  (get-blob-replication-count (ConfigUtils/masterStormJarKey storm-id) nimbus)))
         (reset! current-replication-count-code  (get-blob-replication-count (ConfigUtils/masterStormCodeKey storm-id) nimbus))
         (reset! current-replication-count-conf  (get-blob-replication-count (ConfigUtils/masterStormConfKey storm-id) nimbus))))
-    (if (and (< min-replication-count @current-replication-count-conf)
-             (< min-replication-count @current-replication-count-code)
-             (< min-replication-count @current-replication-count-jar))
+    (if (and (<= min-replication-count @current-replication-count-conf)
+             (<= min-replication-count @current-replication-count-code)
+             (<= min-replication-count @current-replication-count-jar))
       (log-message "desired replication count "  min-replication-count " achieved, "
         "current-replication-count for conf key = " @current-replication-count-conf ", "
         "current-replication-count for code key = " @current-replication-count-code ", "


with-image macro

with-image macro

--- src/tax_extractor/core.clj
+++ src/tax_extractor/core.clj
@@ -8,6 +8,19 @@
            [java.awt Rectangle]
            [java.io File PrintStream OutputStreamWriter FileOutputStream BufferedWriter]
            [org.apache.commons.io FilenameUtils]))
+
+(defmacro with-image
+  "Same as with-open except it deletes the file"
+  [bindings & body]
+  (cond
+    (= (count bindings) 0) `(do ~@body)
+    (symbol? (bindings 0)) `(let ~(subvec bindings 0 2)
+                              (try
+                                (with-image ~(subvec bindings 2) ~@body)
+                                (finally
+                                  (. ~(bindings 0) delete))))
+    :else (throw (IllegalArgumentException.
+                   "with-image only allows Symbols in bindings"))))

 (def row-height 112)
 (def page-two-row-height 116)
@@ -73,8 +86,14 @@
         :reportable-external-comp (parse-comp (doocr (reportable-external-comp y-off)))
         :other-comp (parse-comp (doocr (other-comp y-off)))))))

-(defn threshold [filename]
-  (sh "convert" filename "-threshold" "75%" filename))
+(defn threshold [file]
+  (sh "convert" (.getName file) "-threshold" "75%" (.getName file)))
+
+(defn save-image [image]
+  (let [file (File. (str (java.util.UUID/randomUUID) ".png"))]
+    (ImageIO/write image "png" file)
+    (threshold file)
+    file))

 (defn efiled-990? [page-one]
   (let [name-rect (Rectangle. 115 30 75 40)
@@ -88,36 +107,23 @@
     (when (> (.getPageCount doc) 8)
       (let [renderer (doto (SimpleRenderer.)
                        (.setResolution 300))
-            [page-one page-two] (.render renderer doc 7 8)
-            filename-one (str (java.util.UUID/randomUUID) ".png")
-            filename-two (str (java.util.UUID/randomUUID) ".png")
-            file-one (File. filename-one)
-            file-two (File. filename-two)]
-        (ImageIO/write page-one "png" file-one)
-        (threshold filename-one)
-        (if (efiled-990? file-one)
-          (do
-            (ImageIO/write page-two "png" file-two)
-            (threshold filename-two)
-            (loop [idx 0
-                   records []]
-              (if-let [record (try
-                                (read-record file-one file-two idx)
-                                (catch Exception e
-                                  (println "Failed to read record" idx "from" (.getName pdf))
-                                  (println "Exception:" (.getMessage e))
-                                  nil))]
-                (do (print ".")
-                    (flush)
-                    (recur (inc idx)
-                           (conj records record)))
-                (do
-                  (.delete file-one)
-                  (.delete file-two)
-                  records))))
-          (do
-            (.delete file-one)
-            nil))))))
+            [page-one page-two] (.render renderer doc 7 8)]
+        (with-image [file-one (save-image page-one)]
+          (when (efiled-990? file-one)
+            (with-image [file-two (save-image page-two)]
+              (loop [idx 0
+                     records []]
+                (if-let [record (try
+                                  (read-record file-one file-two idx)
+                                  (catch Exception e
+                                    (println "Failed to read record" idx)
+                                    (println "Exception:" (.getMessage e))
+                                    nil))]
+                  (do (print ".")
+                      (flush)
+                      (recur (inc idx)
+                             (conj records record)))
+                  records)))))))))

 (defn process-pdf [pdf out-path]
   (print "Processing" (.getName pdf))


Remove unused functions.

Remove unused functions.

--- src/uxbox/repo/images.cljs
+++ src/uxbox/repo/images.cljs
@@ -11,25 +11,12 @@
             [uxbox.state :as ust]
             [uxbox.util.transit :as t]))

-(defn- decode-image-collection
-  [{:keys [data] :as coll}]
-  coll)
-  ;; (merge coll
-  ;;        (when data {:data (t/decode data)})))
-
-(defn- decode-payload
-  [{:keys [payload] :as rsp}]
-  rsp)
-  ;; (if (sequential? payload)
-  ;;   (assoc rsp :payload (mapv decode-image-collection payload))
-  ;;   (assoc rsp :payload (decode-image-collection payload))))

 (defmethod request :fetch/image-collections
   [_]
   (let [params {:url (str url "/library/image-collections")
                 :method :get}]
-    (->> (send! params)
-         (rx/map decode-payload))))
+    (send! params)))

 (defmethod request :delete/image-collection
   [_ id]
@@ -42,8 +29,7 @@
         params {:url (str url "/library/image-collections")
                 :method :post
                 :body body}]
-    (->> (send! params)
-         (rx/map decode-payload))))
+    (send! params)))

 (defmethod request :update/image-collection
   [_ {:keys [id data] :as body}]
@@ -51,15 +37,13 @@
         params {:url (str url "/library/image-collections/" id)
                 :method :put
                 :body body}]
-    (->> (send! params)
-         (rx/map decode-payload))))
+    (send! params)))

 (defmethod request :fetch/images
   [_ {:keys [coll]}]
   (let [params {:url (str url "/library/images/" coll)
                 :method :get}]
-    (->> (send! params)
-         (rx/map decode-payload))))
+    (send! params)))

 (defmethod request :create/image
   [_ {:keys [coll id files] :as body}]
@@ -71,8 +55,7 @@
         params {:url (str url "/library/images/" coll)
                 :method :post
                 :body (build-body)}]
-    (->> (send! params)
-         (rx/map decode-payload))))
+    (send! params)))

 (defmethod request :delete/image
   [_ id]


Update pedestal style

Update pedestal style

--- frameworks/Clojure/pedestal/src/pedestal/service.clj
+++ frameworks/Clojure/pedestal/src/pedestal/service.clj
@@ -41,11 +41,12 @@
   (database mysql-db))

-(defn random-world []
+(defn random-world
   "Query a random World record from the database"
+  []
   (let [id (inc (rand-int 9999))] ; Num between 1 and 10,000
     (select world
-      (where {:id id }))))
+            (where {:id id }))))

 (defn run-queries
@@ -62,26 +63,27 @@

 (defn sanitizeQueriesParam
   "Sanitizes the `queries` parameter. Caps the value between 1 and 500.
-Invalid (stringy) values become 1"
+  Invalid (stringy) values become 1"
   [request]
-  (let [queries (-> request :params :queries)]
-    (let [n
-      (if (= (re-find #"\A-?\d+" queries) nil)
-        1
-        (Integer/parseInt queries))]
-    (cond
-      (< n 1) 1
-      (> n 500) 500
-      :else n))))
+  (let [queries (-> request
+                    :params
+                    :queries)]
+    (if-let [n (if (= (re-find #"\A-?\d+" queries) nil)
+                   1
+                   (Integer/parseInt queries))]
+      (cond
+        (< n 1) 1
+        (> n 500) 500
+        :else n))))

 (defn multiple-query-test
   "Test 3: Multiple database queries"
   [request]
   (-> request
-    (sanitizeQueriesParam)
-    (run-queries)
-    (bootstrap/json-response)))
+      (sanitizeQueriesParam)
+      (run-queries)
+      (bootstrap/json-response)))

 ; Set up entity Fortune and the database representation
@@ -92,23 +94,26 @@
   (database mysql-db))

-(defn get-all-fortunes []
+(defn get-all-fortunes
   "Query all Fortune records from the database."
+  []
   (select fortune
-    (fields :id :message)))
+          (fields :id :message)))

-(defn get-fortunes []
+(defn get-fortunes
   "Fetch the full list of Fortunes from the database, sort them by the fortune
-message text, and then return the results."
+  message text, and then return the results."
+  []
   (sort-by #(:message %)
     (conj
       (get-all-fortunes)
       { :id 0 :message "Additional fortune added at request time." })))

-(defn fortunes-hiccup [fortunes]
+(defn fortunes-hiccup
   "Render the given fortunes to simple HTML using Hiccup."
+  [fortunes]
   (html5
    [:head
     [:title "Fortunes"]]
@@ -124,8 +129,9 @@
      ]]))

-(defn fortune-test [request]
+(defn fortune-test
   "Test 4: Fortunes"
+  [request]
   (->
     (get-fortunes)
     (fortunes-hiccup)
@@ -136,23 +142,25 @@

 (defn update-and-persist
   "Changes the :randomNumber of a number of world entities.
-Persists the changes to sql then returns the updated entities"
+  Persists the changes to sql then returns the updated entities"
   [request]
-  (let [results (-> request (sanitizeQueriesParam) (run-queries))]
+  (let [results (-> request
+                    (sanitizeQueriesParam)
+                    (run-queries))]
     (for [w results]
       (update-in w [:randomNumber (inc (rand-int 9999))]
         (update world
-          (set-fields {:randomNumber (:randomNumber w)})
-          (where {:id [:id w]}))))
-  results))
+                (set-fields {:randomNumber (:randomNumber w)})
+                (where {:id [:id w]}))))
+    results))

 (defn db-updates
   "Test 5: Database updates"
   [request]
   (-> request
-    (update-and-persist)
-    (bootstrap/json-response)))
+      (update-and-persist)
+      (bootstrap/json-response)))

 (defn plaintext


Address more PR comments

Address more PR comments

--- ingest-app/src/cmr/ingest/api/ingest.clj
+++ ingest-app/src/cmr/ingest/api/ingest.clj
@@ -89,9 +89,7 @@
   (let [warning-context "After translating item to UMM-C the metadata had the following issue: "]
    (update result
           :warnings
-          (fn [warnings]
-            (when (seq warnings)
-              (map #(str warning-context %) warnings))))))
+          (fn [warnings] (seq (map #(str warning-context %) warnings))))))

 (defmulti generate-ingest-response
   "Convert a result to a proper response format"
@@ -252,10 +250,10 @@
       (info (format "Ingesting collection %s from client %s"
                     (concept->loggable-string concept) (:client-id request-context)))
       (generate-ingest-response headers (contextualize-warnings
-                                         (ingest/save-collection
-                                          request-context
-                                          (set-user-id concept request-context headers)
-                                          validation-options))))))
+                                          (ingest/save-collection
+                                           request-context
+                                           (set-user-id concept request-context headers)
+                                           validation-options))))))

 (defn delete-collection
   [provider-id native-id request]


Update project version emitted by template

--- resources/leiningen/new/re_frame/project.clj
+++ resources/leiningen/new/re_frame/project.clj
@@ -1,4 +1,4 @@
-(defproject {{name}} "0.5.0-alpha3"
+(defproject {{name}} "0.1.0-SNAPSHOT"
   :dependencies [[org.clojure/clojure "1.6.0"]
                  [org.clojure/clojurescript "0.0-2816"]
                  [reagent "0.5.0-alpha3"]


More paginate tests

More paginate tests

--- test/io/perun_test.clj
+++ test/io/perun_test.clj
@@ -477,7 +477,13 @@
           (content-check :path "baz/decomplect-2.html"
                          :content "paginate 2")
           (content-check :path "baz/decomplect-3.html"
-                         :content "paginate 1"))
+                         :content "paginate 1")
+          (value-check :path "baz/decomplect-1.html"
+                       :value-fn #(meta= %1 %2 :paginated "mmhmm"))
+          (value-check :path "baz/decomplect-2.html"
+                       :value-fn #(meta= %1 %2 :paginated "mmhmm"))
+          (value-check :path "baz/decomplect-3.html"
+                       :value-fn #(meta= %1 %2 :paginated "mmhmm")))

         (p/render :renderer 'io.perun-test/render
                   :filterer :markdown-set


(PDB-5161) engine: remove vestigial non-predicate-clause

--- src/puppetlabs/puppetdb/query_eng/engine.clj
+++ src/puppetlabs/puppetdb/query_eng/engine.clj
@@ -1797,9 +1797,6 @@
        (map first)
        (some numeric-functions)))

-(def non-predicate-clause
-  #{"group_by" "limit" "offset"})
-
 (defn expand-query-node
   "Expands/normalizes the user provided query to a minimal subset of the
   query language"


build is no longer a cursor, and no longer IDeref

But then, derefing it was never necessary to begin with.

--- src-cljs/frontend/components/build_head.cljs
+++ src-cljs/frontend/components/build_head.cljs
@@ -82,9 +82,9 @@
             build-id (build-model/id build)]
         (raise! owner [:usage-queue-why-showed
                        {:build-id build-id
-                        :username (:username @build)
-                        :reponame (:reponame @build)
-                        :build_num (:build_num @build)}])))
+                        :username (:username build)
+                        :reponame (:reponame build)
+                        :build_num (:build_num build)}])))

     om/IRender
     (render [_]


[#2080] Relates 3206783cfbfc6a50804e903cffaefbf509e6bbe8

--- backend/src/akvo/lumen/endpoint/collection.clj
+++ backend/src/akvo/lumen/endpoint/collection.clj
@@ -52,11 +52,11 @@
                               body :body
                               auth-service :auth-service
                               {:keys [id]} :path-params}]
-                        (let [vis-payload (w/keywordize-keys body)
-                              ids (l.auth/ids ::collection.s/collection-payload vis-payload)]
-                          (if (p/allow? auth-service ids)
-                            (collection/update* (p/connection tenant-manager tenant) id vis-payload)
-                            (lib/not-authorized {:ids ids}))))}
+                          (let [vis-payload (w/keywordize-keys body)
+                                ids (l.auth/ids ::collection.s/collection-payload vis-payload)]
+                            (if (p/allow? auth-service ids)
+                              (lib/ok (collection/update* (p/connection tenant-manager tenant) id vis-payload))
+                              (lib/not-authorized {:ids ids}))))}
          :delete {:parameters {:path-params {:id string?}}
                   :handler (fn [{tenant :tenant
                                  {:keys [id]} :path-params}]


adding missing specter

adding missing specter

--- resources/leiningen/new/closp/project.clj
+++ resources/leiningen/new/closp/project.clj
@@ -61,7 +61,9 @@

                  [org.clojure/core.typed "0.3.11"]
                  [prismatic/plumbing "0.5.0"]
-                 [prismatic/schema "1.0.3"]]
+                 [prismatic/schema "1.0.3"]
+
+                 [com.rpl/specter "0.8.0"]]

   :plugins [[de.sveri/closp-crud "0.1.4"]
             [lein-cljsbuild "1.0.5"]]


improved delete conference message | sg

improved delete conference message | sg

--- src/cljs/conference_rating/conference_detail_page/conference_detail_page.cljs
+++ src/cljs/conference_rating/conference_detail_page/conference_detail_page.cljs
@@ -15,7 +15,7 @@
    [:a {:class "btn btn-md btn-orange" :href (str "#/conferences/" conference-id "/add-rating") :data-e2e "button-add-new-rating"} "give it your voice"]])

 (defn delete-conference [conference]
-  (let [delete (js/confirm "If you delete this conference, it will be gone forever!")]
+  (let [delete (js/confirm "If you delete this conference, it will be gone forever including all of its ratings!")]
     (if delete
       (ajax/DELETE (str "/api/conferences/" (:_id conference)) {:keywords?       true
                                                                 :handler         #(history/redirect-to "/")


Deal with 0 or 1 prefused vals.

Deal with 0 or 1 prefused vals.

--- src/onyx/messaging/acking_daemon.clj
+++ src/onyx/messaging/acking_daemon.clj
@@ -39,5 +39,8 @@
   "Prefuse values on a peer before sending them to the acking
    daemon to decrease packet size."
   [& vals]
-  (apply bit-xor vals))
+  (let [vals (filter identity vals)]
+    (cond (zero? (count vals)) nil
+          (= 1 (count vals)) (first vals)
+          :else (apply bit-xor vals))))


docs - clarify :secure and :http-only in wrap-cookies

--- ring-core/src/ring/middleware/cookies.clj
+++ ring-core/src/ring/middleware/cookies.clj
@@ -164,8 +164,9 @@
   :domain    - the domain the cookie is valid for
   :max-age   - the maximum age in seconds of the cookie
   :expires   - a date string at which the cookie will expire
-  :secure    - set to true if the cookie is valid for HTTPS only
-  :http-only - set to true if the cookie is valid for HTTP only"
+  :secure    - set to true if the cookie requires HTTPS, prevent HTTP access
+  :http-only - set to true if the cookie is valid for HTTP and HTTPS only
+               (ie. prevent JavaScript access)"
   [handler]
   (fn [request]
     (-> request


More experiments with the way data is enqueued.

--- src/dsbdp/local_data_processing_pipeline.clj
+++ src/dsbdp/local_data_processing_pipeline.clj
@@ -28,7 +28,8 @@
                 (do
                   (println file-name "not found. Using default.")
 ;                  "ArrayBlockingQueue_put"))]
-                  "ArrayBlockingQueue_put-counted-yield"))]
+;                  "ArrayBlockingQueue_put-counted-yield"))]
+                  "ArrayBlockingQueue_add-counted-yield"))]
 ;                  "ArrayBlockingQueue_offer"))]
 ;                  "ArrayBlockingQueue_offer-counted-yield"))]
 ;                  "LinkedTransferQueue_transfer"))]
@@ -51,6 +52,13 @@
   [queue data enqueued-counter dropped-counter]
   (println "Enqueueing data via:")
   (let [expr (condp (fn [^String v ^String s] (.endsWith s v)) queue-setup
+               "add-counted-yield" `(if (< (.size ~queue) queue-size)
+                                      (do
+                                        (.add ~queue ~data)
+                                        (.inc ~enqueued-counter))
+                                      (do
+                                        (.inc ~dropped-counter)
+                                        (Thread/yield)))
                "put" `(.put ~queue ~data)
                "put-counted-yield" `(if (< (.size ~queue) queue-size)
                                       (do
@@ -105,7 +113,13 @@

 (defmacro take-from-queue
   [queue]
-  `(.take ~queue))
+  `(loop []
+     (if (not (.isEmpty ~queue))
+       (.remove ~queue)
+       (do
+         (Thread/yield)
+         (recur)))))
+;  `(.take ~queue))


Handle recursive objects

Handle recursive objects

--- src/javascript_externs_generator/extern.cljs
+++ src/javascript_externs_generator/extern.cljs
@@ -6,12 +6,16 @@
     :function
     :object))

+(defn parent-type? [obj]
+  (or (object? obj)
+      (fn? obj)))
+
 (defn build-tree [obj name]
   {:name name
    :type (get-type obj)
    :props (mapv #(let [child (aget obj %)]
-                   (if (or (object? child)
-                           (fn? child))
+                   (if (and (parent-type? child)
+                            (not (identical? obj child)))
                      (build-tree child %)
                      {:name % :type (get-type child)}))
                 (js-keys obj))


Whitespace fix

Whitespace fix

Signed-off-by: Daniel Borchmann <3d0f3b9ddcacec30c4008c5e030e6c13a478cb4f@algebra20.de>

--- src/main/clojure/conexp/contrib/gui/util.clj
+++ src/main/clojure/conexp/contrib/gui/util.clj
@@ -9,7 +9,7 @@
 ;; this file contains contributions by Immanuel Albrecht

 (ns conexp.contrib.gui.util
-  (:import [javax.swing JFrame JPanel JButton ImageIcon JTabbedPane
+  (:import [javax.swing JFrame JPanel JButton ImageIcon JTabbedPane
                         JLabel BorderFactory AbstractButton JFileChooser
                         JOptionPane JComponent JMenuBar]
            [javax.swing.filechooser FileNameExtensionFilter]


matching meta tags

matching meta tags

--- src/name_bazaar/ui/components/meta_tags.cljs
+++ src/name_bazaar/ui/components/meta_tags.cljs
@@ -7,5 +7,5 @@
                                    description "A peer-to-peer marketplace for the exchange of names registered via the Ethereum Name Service."}}]
   (let [{:keys [:handler :query-params :path] :as active-page} @(subscribe [:district0x/active-page])]
     [d0x-meta-tags/meta-tags
-     [:title {:id "title" :title title}]
-     [:meta {:id "description" :content description}]]))
+     [:title {:id "title"} title]
+     [:meta {:id "description" :name "description" :content description}]]))