fixing throwable assertions admin has access to all

--- test/celestial/integration/persistency/persmissions.clj
+++ test/celestial/integration/persistency/persmissions.clj
@@ -41,17 +41,17 @@
       (fact "persmissionless access" :integration :redis :systems
             (let [id (s/add-system (assoc redis-prox-spec :env :prod))]
              (s/get-system id) =>
-               (throws ExceptionInfo (is-type? :celestial.persistency.systems/persmission-violation))
+               (throws ExceptionInfo (is-type? :celestial.persistency.systems/persmission-env-violation))
               ; note that the assert-access precondition adds a current-user call
               (provided (current-user) => {:username "ronen"} :times 2)
               (s/update-system id redis-prox-spec) =>
-                 (throws ExceptionInfo (is-type? :celestial.persistency.systems/persmission-violation))
+                 (throws ExceptionInfo (is-type? :celestial.persistency.systems/persmission-env-violation))
               (provided (current-user) => {:username "ronen"} :times 4)
               (s/delete-system id) =>
-                  (throws ExceptionInfo (is-type? :celestial.persistency.systems/persmission-violation))
+                  (throws ExceptionInfo (is-type? :celestial.persistency.systems/persmission-env-violation))
               (provided (current-user) => {:username "ronen"} :times 2)
-              (s/add-system {:env :prod}) =>
-                (throws ExceptionInfo (is-type? :celestial.persistency.systems/persmission-violation))
+              (s/add-system {:env :prod :owner "ronen"}) =>
+                (throws ExceptionInfo (is-type? :celestial.persistency.systems/persmission-env-violation))
               (provided (current-user) => {:username "ronen"} :times 2)
               ))

@@ -61,14 +61,14 @@
           (provided (current-user) => {:username "ronen"} :times 2)
           (s/update-system id (assoc redis-prox-spec :cpus 20)) => (contains ["OK"])
           (provided (current-user) => {:username "ronen"} :times 12)
-          (s/delete-system id) => [1 1 1]
+          (s/delete-system id) => [1 1 1 1]
           (provided (current-user) => {:username "ronen"} :times 6)
           (s/add-system redis-prox-spec) => truthy
           (provided (current-user) => {:username "ronen"} :times 6)))

       (fact "user trying to create on another username" :integration :redis :systems
          (s/add-system (assoc redis-prox-spec :owner "foo")) =>
-           (throws ExceptionInfo (is-type? :celestial.persistency.systems/persmission-violation))
+           (throws ExceptionInfo (is-type? :celestial.persistency.systems/persmission-owner-violation))
          (provided
            (current-user) => {:username "ronen"} :times 2)
          (s/add-system (assoc redis-prox-spec :user "ronen")) => 1


JC | Show standard 500 page for anti-forgery token error, and log something

--- src/stonecutter/handler.clj
+++ src/stonecutter/handler.clj
@@ -17,10 +17,11 @@
             [stonecutter.translation :as t]
             [stonecutter.middleware :as m]))

+(def default-context {:translator (t/translations-fn t/translation-map)})
+
 (defn not-found [request]
-  (let [context {:translator (t/translations-fn t/translation-map)}]
-    (-> (html-response (error/not-found-error context))
-        (r/status 404))))
+  (-> (html-response (error/not-found-error default-context))
+      (r/status 404)))

 (def site-handlers
   {:home                   user/home
@@ -43,9 +44,14 @@
         (api request)
         (site request)))))

+(defn handle-anti-forgery-error [req]
+  (log/warn "ANTI_FORGERY_ERROR - headers: " (:headers req))
+  (html-response (error/internal-server-error default-context)))
+
 (def wrap-defaults-config
   (-> site-defaults
-      (assoc-in [:session :cookie-attrs :max-age] 3600)))
+      (assoc-in [:session :cookie-attrs :max-age] 3600)
+      (assoc-in [:security :anti-forgery] {:error-handler handle-anti-forgery-error})))

 (defn create-site-app [dev-mode?]
   (-> (scenic-handler routes site-handlers not-found)
@@ -58,10 +64,10 @@
       (wrap-defaults api-defaults)
       (m/wrap-error-handling dev-mode?)))                   ;; TODO create json error handler

-(defn create-app [dev-mode?]
+(defn create-app [& {dev-mode? :dev-mode? }]
   (splitter (create-site-app dev-mode?) (create-api-app dev-mode?)))

-(def app (create-app false))
+(def app (create-app :dev-mode? false))

 (def port (Integer. (get env :port "3000")))

@@ -84,4 +90,4 @@
     (log/info (str "TEST USER DETAILS:" user))
     (log/info (str "TEST CLIENT DETAILS:" client-details))))

-(def lein-app (create-app true))
+(def lein-app (create-app :dev-mode? true))


validation are added

validation are added

--- src_cljs/rrms/corecljs.cljs
+++ src_cljs/rrms/corecljs.cljs
@@ -281,82 +281,58 @@

 (defn form-validator [data-set]
   (first (b/validate data-set
-                     :mutationnumber [[v/required :message "Filed is required"]
-                                      [v/string :message "Enter valid Document Name"]]
-                     :nameofthefirstparty [[v/required :message "Filed is required"]
-                                           [v/string :message "Enter valid Title"]]
-                     :nameofthesecondparty [[v/required :message "Filed is required"]
-                                            [v/string  :message "Enter valid Employee name"]]
-                     :dateofinstitution [[v/required :message "Filed is required"]
-                                         [v/datetime  :message "Enter valid Date"]]
-                     :nameofpo [[v/required :message "Filed is required"]
-                                [v/string  :message "Enter valid Location"]]
-                     :dateofdecision [[v/required :message "Filed is required"]
-                                      [v/datetime  :message "Enter valid Date"]]
-                     :title [[v/required :message "Filed is required"]
-                             [v/string  :message "Enter valid Location"]]
-                     :khasranumber [[v/required :message "Filed is required"]
-                                    [v/string  :message "Enter valid Location"]]
-                     :subdivisionname [[v/required :message "Filed is required"]
-                                       [v/string  :message "Enter valid Location"]]
-                     :villageid [[v/required :message "Filed is required"]
-                                 [v/string  :message "Enter valid Location"]]
-                     :o2number [[v/required :message "Filed is required"]
-                                [v/string  :message "Enter valid Location"]]
-                     :o4number [[v/required :message "Filed is required"]
-                                [v/string  :message "Enter valid Location"]]
-                     :o6number [[v/required :message "Filed is required"]
-                                [v/string  :message "Enter valid Location"]]
-                     :racknumber [[v/required :message "Filed is required"]
-                                  [v/string  :message "Enter valid Location"]]
-                     :receiveddate [[v/required :message "Filed is required"]
-                                    [v/datetime  :message "Enter valid Date"]]
-                     :remarks [[v/required :message "Filed is required"]
-                               [v/string  :message "Enter valid Location"]]
-                     )))
+                     :mutationnumber [[v/required :message "Field is required"]]
+                     :nameofthefirstparty [[v/required :message "Field is required"]]
+                     :nameofthesecondparty [[v/required :message "Field is required"]]
+                     :dateofinstitution [[v/required :message "Field is required"]]
+                     :nameofpo [[v/required :message "Field is required"]]
+                     :dateofdecision [[v/required :message "Field is required"]]
+                     :title [[v/required :message "Field is required"]]
+                     :khasranumber [[v/required :message "Field is required"]]
+                     :area [[v/required :message "Field is required"]]
+                     :khatakhatuninumber [[v/required :message "Field is required"]]
+                     :subdivisionname  [[v/required :message "Field is required"]]
+                     :o2number [[v/required :message "Field is required"]]
+                     :o4number [[v/required :message "Field is required"]]
+                     :o6number [[v/required :message "Field is required"]]
+                     :racknumber [[v/required :message "Field is required"]]
+                     :receiveddate [[v/required :message "Field is required"]]
+                     :remarks [[v/required :message "Field is required"]])))

 (defn form-input-element [id label ttype data-set focus]
   (let [input-focus (r/atom nil)]
     (fn []
       [:div.form-group
-       [:div.col-md-12
-        [:div.row
-         [:div.col-md-2 [:label label]]
-         [:div.col-md-6 [input-element id ttype data-set label input-focus]]
-         [:div.col-md-4 (if (or @input-focus @focus)
-                          (if (= nil (form-validator @data-set))
-                            [:div]
-                            [:div {:style  {:color "red"}}
-                             [:b (str (first ((form-validator @data-set) id)))]])
-                          [:div])]]]] )))
-
-
-(defn button [value fun]
-  [:button.btn.btn-primary {:on-click fun} value])
+       [:label.col-sm-3.control-label label]
+       [:div.col-sm-6 [input-element id ttype data-set label input-focus]]
+       [:div.col-sm-3 (if (or @input-focus @focus)
+                        (if (= nil (form-validator @data-set))
+                          [:div]
+                          [:div {:style  {:color "red"}}
+                           [:b (str (first ((form-validator @data-set) id)))]])
+                        [:div])]])))
+

 (defn add-form-onclick [data-set focus]
-  (reset! data-set (assoc @data-set :villageid
-                          (int (.-value (.getElementById js/document "districts")))))
-  (let [onres (fn[json]
-                (secretary/dispatch! "/"))]
-    (http-post "http://localhost:9000/mutations"
-               onres  (.serialize (Serializer.) (clj->js @data-set))))
-  (reset! focus "on"))
+  (if (= nil (form-validator @data-set))
+    (do (reset! data-set (assoc @data-set :villageid
+                                (int (.-value (.getElementById js/document "districts")))))
+        (let [onres (fn[json]
+                      (secretary/dispatch! "/"))]
+          (http-post "http://localhost:9000/mutations"
+                     onres  (.serialize (Serializer.) (clj->js @data-set)))))
+    (reset! focus "on")))
+

 (defn update-form-onclick [data-set focus]
-  (reset! data-set (assoc @data-set :villageid
-                          (int (.-value (.getElementById js/document "districts")))))
-  (let [onres (fn[data]
-                (secretary/dispatch! "/"))]
-    (http-put (str "http://localhost:9000/mutations/" (:id @data-set))
-              onres (.serialize (Serializer.) (clj->js @data-set)))))
-
-;; (if (= nil (form-validator @data-set))
-;;   (let [onres (fn[data]
-;;                 (secretary/dispatch! "/mutations"))]
-;;     (http-put (str "http://localhost:9000/mutations/" (:id @data-set))
-;;               onres (.serialize (Serializer.) (clj->js @data-set))))
-;;   (reset! focus "on"))
+  (if (= nil (form-validator @data-set))
+    (do (reset! data-set (assoc @data-set :villageid
+                                (int (.-value (.getElementById js/document "districts")))))
+        (let [onres (fn[data]
+                      (secretary/dispatch! "/"))]
+          (http-put (str "http://localhost:9000/mutations/" (:id @data-set))
+                    onres (.serialize (Serializer.) (clj->js @data-set)))))
+    (reset! focus "on")))

 (defn form-cancel [event]
   (secretary/dispatch! "/"))
@@ -383,50 +359,85 @@
     (http-get "http://localhost:9000/villages" onres)))

 (defn tags-template [data-set]
-  (cond (nil? (:villageid @data-set)) [:select {:id "districts"}
+  (cond (nil? (:villageid @data-set)) [:select.form-control {:id "districts"}
                                        (for [d (get-value! :villages)]
                                          ^{:key (.-id d)} [:option {:value (.-id d)} (.-villagename d)])]
-        :else [:select {:id "districts" :defaultValue (:villageid @data-set)}
+        :else [:select.form-control {:id "districts" :defaultValue (:villageid @data-set)}
                (doall (for [d (get-value! :villages)]
                         ^{:key (.-id d)} [:option {:value (.-id d)} (.-villagename d)]))]))

+
+(defn form-input-select [label data-set focus]
+  (let [input-focus (r/atom nil)]
+    (fn []
+      [:div.form-group
+       [:label.col-sm-3.control-label label]
+       [:div#tagdiv.col-sm-6 [tags-template data-set]]
+       [:div.col-sm-3 [:div]]])))
+
+(defn datalist []
+  [:datalist {:id "combo"}
+   (let [name-po ["Kumar" "Sai" "Bhaskar" "Rajesh"]]
+     (for [i name-po]
+       ^{:key i}
+       [:option {:value i}]))])
+
+(defn input-combo [id data-set placeholder in-focus]
+  [:input.form-control {:id id
+                        :list "combo"
+                        :value (@data-set id)
+                        :placeholder placeholder
+                        :on-change #(swap! data-set assoc id (-> % .-target .-value))
+                        :on-blur  #(reset! in-focus "on")
+                        } [datalist ]])
+
+(defn form-input-combo [id label data-set focus]
+  (let [input-focus (r/atom nil)]
+    (fn []
+      [:div.form-group
+       [:label.col-sm-3.control-label label]
+       [:div.col-sm-6 [input-combo id data-set label input-focus]]
+       [:div.col-sm-3 (if (or @input-focus @focus)
+                        (if (= nil (form-validator @data-set))
+                          [:div]
+                          [:div {:style  {:color "red"}}
+                           [:b (str (first ((form-validator @data-set) id)))]])
+                        [:div])]])))
+
 (defn mutation-template [doc-name data-set focus save-function]
-  [:div.container
-   [:div.panel.panel-primary.model-dialog
-    [:div.panel-heading
-     [:h2 doc-name]]
-    [:div.panel-boby
-     [:div.container
-      [:div.form-group
-
+ [:div.container
+  [:div.col-md-12
+   [:div.box.box-info
+    [:div.box-header.with-border
+     [:h2.box-title doc-name]]
+    [:div.form-horizontal
+     [:div.box-body
        [form-input-element :mutationnumber "Mutation Number" "text" data-set focus]
        [form-input-element :nameofthefirstparty "Name of the First Party" "text" data-set focus ]
-       [form-input-element :nameofthesecondparty "Name of the SecondParty" "text" data-set focus]
-       [form-input-element :dateofinstitution "Dateof Institution" "date" data-set focus]
-       [form-input-element :nameofpo "Name of PO" "text" data-set focus]
-       [form-input-element :dateofdecision "Dateof Decision" "date" data-set focus]
+       [form-input-element :nameofthesecondparty "Name of the Second Party" "text" data-set focus]
+       [form-input-element :dateofinstitution "Date of Institution" "date" data-set focus]
+       [form-input-combo   :nameofpo "Name of PO" data-set focus]
+       [form-input-element :dateofdecision "Date of Decision" "date" data-set focus]
        [form-input-element :title "Title" "text" data-set focus]
        [form-input-element :khasranumber "Khasra Number" "text" data-set focus]
        [form-input-element :area "Area" "text" data-set focus]
        [form-input-element :khatakhatuninumber "Khata Khatuni Number" "text" data-set focus]
-       [:div  [:div.col-md-2[:label "Village Name"]]
-        [:div#tagdiv [tags-template data-set]]]
-       [form-input-element :subdivisionname "Subdivision Name" "text" data-set focus]
-       [form-input-element :o2number "O2Number" "text" data-set focus]
-       [form-input-element :o4number "O4Number" "text" data-set focus]
-       [form-input-element :o6number "O6Number" "text" data-set focus]
+       [form-input-select "Village Name" data-set focus]
+       [form-input-element :subdivisionname "Sub division Name" "text" data-set focus]
+       [form-input-element :o2number "O2 Number" "text" data-set focus]
+       [form-input-element :o4number "O4 Number" "text" data-set focus]
+       [form-input-element :o6number "O6 Number" "text" data-set focus]
        [form-input-element :racknumber "Rack Number" "text" data-set focus]
        [form-input-element :receiveddate "Received Date" "date" data-set focus]
-       [form-input-element :remarks "Remarks" "text" data-set focus]
-                                        ; [form-input-element :isactive "isactive" "text" data-set focus]
-       [button "Save" save-function]
-       [button "cancel" form-cancel]]]]]])
+       [form-input-element :remarks "Remarks" "text" data-set focus]]
+     [:div.box-footer
+      [:button.btn.btn-default {:on-click form-cancel} "Cancel"]
+      [:button.btn.btn-info.pull-right {:on-click save-function} "Save"]]]]]])

 (defn mutation-add-template []
   (let [add-data (r/atom {:isactive true})
         focus (r/atom nil)]
-    (fn [] [mutation-template "Mutation" add-data focus #(add-form-onclick add-data focus)])))
-
+    (fn [] [mutation-template "Mutation Add Form" add-data focus #(add-form-onclick add-data focus)])))

 (defn mutation-update-template [id dmt]
   (let [update-data (r/atom {:id (int id)
@@ -447,12 +458,14 @@
                              :o6number (.-o6number dmt)
                              :racknumber (.-racknumber dmt)
                              :receiveddate (.-receiveddate dmt)
-                             ;; :receiveddate (f/unparse (f/formatter "yyyy-mm-dd")(f/parse (.-receiveddate dmt)))
                              :remarks (.-remarks dmt)
                              :villagename (.-villagename dmt)
                              :districtname (.-districtname dmt)})
         focus (r/atom nil)]
-    (fn [] [mutation-template "Update Mutations" update-data focus  #(update-form-onclick update-data focus)])))
+    (fn [] [mutation-template
+            "Mutation Update Form"
+            update-data focus
+            #(update-form-onclick update-data focus)])))

 ;; ===============================================================================================
 ;; end of add-update-form coding


Improve moving along walls

Improve moving along walls

--- dungeon-crawler/desktop/src-common/dungeon_crawler/entities.clj
+++ dungeon-crawler/desktop/src-common/dungeon_crawler/entities.clj
@@ -54,15 +54,13 @@
     entity))

 (defn prevent-move
-  [screen entities {:keys [x y x-change y-change health] :as entity}]
-  (if (or (and (or (not= 0 x-change) (not= 0 y-change))
-               (u/is-near-entities? entities entity 1))
-          (u/is-on-layer? screen entity "walls"))
-    (assoc entity
-           :x-velocity 0
-           :y-velocity 0
-           :x-change 0
-           :y-change 0
-           :x (- x x-change)
-           :y (- y y-change))
-    entity))
+  [screen entities {:keys [x y x-change y-change] :as entity}]
+  (let [old-x (- x x-change)
+        old-y (- y y-change)
+        x-entity (assoc entity :y old-y)
+        y-entity (assoc entity :x old-x)]
+    (merge entity
+           (when (u/is-invalid-location? screen entities x-entity)
+             {:x-velocity 0 :x-change 0 :x old-x})
+           (when (u/is-invalid-location? screen entities y-entity)
+             {:y-velocity 0 :y-change 0 :y old-y}))))


Generation of children points

Generation of children points

--- src/connect5_ai/core.clj
+++ src/connect5_ai/core.clj
@@ -1,7 +1,98 @@
 (ns connect5-ai.core
+  (:require [clojure.core.async :as casync]
+            clojure.set)
   (:gen-class))

-(defn -main
-  "I don't do a whole lot ... yet."
-  [& args]
-  (println "Hello, World!"))
+;(defn -main [& args])
+
+(def adjacent-transform
+  (for [c1 (range -2 3)
+        c2 (range -2 3)]
+    [c1 c2]))
+
+(defn in-bounds?
+  [grid-w grid-h [x y :as point]]
+  (not (or
+         (< x 0)
+         (< y 0)
+         (>= x grid-w)
+         (>= y grid-h))))
+
+(defn gen-map-from-charmat
+  "Generates map representation of blabla"
+  [charmat ret-map line-idx]
+  (if (empty? charmat)
+    ret-map
+    (recur
+      (rest charmat)
+      (reduce
+        (fn [col [col-idx charac]]
+          (case charac
+            1 (assoc col :1 (cons [line-idx col-idx] (:1 col)))
+            2 (assoc col :2 (cons [line-idx col-idx] (:2 col)))
+            col))
+        ret-map
+        (map-indexed vector (first charmat)))
+      (inc line-idx))))
+
+
+(defn heuristic
+  "Processes the heuristic for a state"
+  [grid-w grid-h is-first-player state])
+
+(defn gen-surrounding-points
+  [grid-w grid-h [x y :as point]]
+  (filter
+    (partial in-bounds? grid-w grid-h)
+    (map
+      #(map + point %)
+      adjacent-transform)))
+
+(defn gen-children-points
+  [parent-state grid-w grid-h]
+
+  (let [all-parent-points-union (clojure.set/union (parent-state :1) (parent-state :2))]
+
+    ;Possible points
+    (clojure.set/difference
+      (reduce
+        (fn [col1 el1] (clojure.set/union col1 (set (gen-surrounding-points grid-w grid-h el1))))
+        #{}
+        all-parent-points-union)
+      all-parent-points-union)))
+
+(defn gen-children-states
+  "Swiggity Swag"
+  [grid-w grid-h is-first-player state]
+
+  (let [player-to-gen (if (> (count (state :1)) (count (state :2))) :2 :1)
+        children-positions (gen-children-points state grid-w grid-h)
+        ]
+    ; Todo: Started from the bottom now we here
+    ))
+
+(defn minimax-decision
+  [grid-w grid-h is-first-player state]
+
+  (println grid-w grid-h is-first-player state)
+  (if (and
+        is-first-player
+        (empty? (state :1)))
+    [(long (/ grid-w 2)) (long (/ grid-h 2))]
+
+    [2 3]
+    ;(gen-successors grid-w grid-h is-first-player state)
+    ))
+
+(defn -getNextMove
+  "Gets the next best move"
+  [charmat timeout]
+  (let [charmat-seq (lazy-seq charmat)
+        state (gen-map-from-charmat charmat-seq {:1 #{} :2 #{}} 0)
+        is-first-player (even? (+ (count (state :1)) (count (state :2))))]
+
+    (minimax-decision (count (first charmat-seq))
+                      (count charmat-seq)
+                      is-first-player
+                      state)))
+


Remove debugging statement

Remove debugging statement

--- test/desdemona/cli_test.clj
+++ test/desdemona/cli_test.clj
@@ -136,7 +136,7 @@
                                  'onyx.api/shutdown-peers
                                  'onyx.api/shutdown-peer-group
                                  'clojure.core/shutdown-agents]]
-                        [(spy (resolve sym))
+                        [(resolve sym)
                          (fn [& args]
                            (let [event (into [sym] args)]
                              (swap! events conj event)))])


Adapt to upstream renaming (editor-view => editor)

--- src/flense_demo/app.cljs
+++ src/flense_demo/app.cljs
@@ -1,7 +1,7 @@
 (ns flense-demo.app
   (:require [cljs.core.async :as async]
             [flense.actions.text :as text]
-            [flense.editor :refer [editor-view]]
+            [flense.editor :as flense]
             [flense.model :as model]
             [flense-demo.keymap :refer [keymap]]
             [flense-demo.sidebar :refer [sidebar]]
@@ -35,7 +35,7 @@
       (async/put! edit-chan (partial text/insert-char c)))))

 (defn init []
-  (om/root editor-view app-state
+  (om/root flense/editor app-state
     {:target (.getElementById js/document "editor")
      :opts {:edit-chan edit-chan}})
   (om/root sidebar app-state


Buttons: docstring typo and component macro

--- src-cljs/frontend/components/pieces/button.cljs
+++ src-cljs/frontend/components/pieces/button.cljs
@@ -1,6 +1,6 @@
 (ns frontend.components.pieces.button
   (:require [devcards.core :as dc :refer-macros [defcard]])
-  (:require-macros [frontend.utils :refer [html]]))
+  (:require-macros [frontend.utils :refer [component html]]))

 (defn button
   "A standard button.
@@ -8,17 +8,17 @@
   :on-click  - A function called when the button is clicked.
   :primary?  - If true, the button appears as a primary button. (default: false)
   :disabled? - If true, the button is disabled. (default: false)
-  :size      - The size of the button. One of #{:full medium}. (default: :full)"
+  :size      - The size of the button. One of #{:full :medium}. (default: :full)"
   [{:keys [on-click primary? disabled? size] :or {size :full}} content]
-  (html
-   [:button {:data-component `button
-             :class (remove nil? [(when primary? "primary")
-                                  (case size
-                                    :full nil
-                                    :medium "medium")])
-             :disabled disabled?
-             :on-click on-click}
-    content]))
+  (component
+    (html
+     [:button {:class (remove nil? [(when primary? "primary")
+                                    (case size
+                                      :full nil
+                                      :medium "medium")])
+               :disabled disabled?
+               :on-click on-click}
+      content])))

 (dc/do


Switch back to node repl for now.

Switch back to node repl for now.

--- cljs_repl.clj
+++ cljs_repl.clj
@@ -1,7 +1,7 @@
 (require 'cljs.repl)
-(require 'cljs.repl.rhino)
+(require 'cljs.repl.node)

 (cljs.repl/repl
-  (cljs.repl.rhino/repl-env)
+  (cljs.repl.node/repl-env)
   :watch "src"
   :output-dir "target")


<who_name> isn't the outermost tag

<who_name> isn't the outermost tag

--- lib/assets/cljs/cglossa/result_views/cwb/speech.cljs
+++ lib/assets/cljs/cglossa/result_views/cwb/speech.cljs
@@ -17,7 +17,7 @@
     (reset! current-media-type media-type)))

 (defn- extract-fields [res]
-  (let [m (re-find #"<who_name\s+(.*?)>(.*)\{\{(.+?)\}\}(.*?)</who_name>$" (:text res))]
+  (let [m (re-find #"<who_name\s+(.*?)>(.*)\{\{(.+?)\}\}(.*?)</who_name>" (:text res))]
     (let [[_ s-id pre match post] m]
       [(str/trim s-id) [pre match post]])))


CMR-2896 pr comments

CMR-2896 pr comments

--- access-control-app/src/cmr/access_control/api/routes.clj
+++ access-control-app/src/cmr/access_control/api/routes.clj
@@ -160,7 +160,7 @@

 (defn- get-permissions
   "Returns a Ring response with the requested permission check results."
-  [request-context headers params]
+  [request-context params]
   (let [result (acl-service/get-permissions request-context params)]
     {:status 200
      :body (json/generate-string result)}))
@@ -306,7 +306,7 @@
         (OPTIONS "/" [] common-routes/options-response)

         (GET "/" {:keys [request-context headers params]}
-          (get-permissions request-context headers params))))
+          (get-permissions request-context params))))

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


Added test for disabled

Added test for disabled

--- test/om_semantic/tests.cljs
+++ test/om_semantic/tests.cljs
@@ -6,6 +6,11 @@
             [om-semantic.dropdown :as d]))

 (enable-console-print!)
+
+(defn make-wrapper [init-state]
+  (fn [data owner]
+    (om/component
+      (om/build d/dropdown data {:init-state init-state}))))

 (deftest dropdown
   (testing "Dropdown displays initial state"
@@ -19,9 +24,7 @@
                       :lkey :val
                       :disabled false
                       :selected [:selected]}
-          wrapper (fn [data owner]
-                    (om/component
-                     (om/build d/dropdown data {:init-state init-state})))
+          wrapper (make-wrapper init-state)
           rt (om/root wrapper app-state {:target c})
           react-nodes (tu/find-by-tag rt "div")
           [main-react display-react] react-nodes
@@ -37,6 +40,25 @@
             (sim/click (second ns) nil)
             (om/render-all)
             (is (= (:selected @app-state) (:id (second xs))))
-            (is (= (:val (second xs)) (.-innerHTML display-node)))))))))
+            (is (= (:val (second xs)) (.-innerHTML display-node))))))
+      (testing "but does nothing else if disabled"
+        (tu/unmount! c)
+        (let [c (tu/new-container!)
+              init-state {:menu [:xs]
+                          :idkey :id
+                          :lkey :val
+                          :disabled true
+                          :selected [:selected]}
+              app-state (atom {:xs xs :selected 1})
+              wrapper (make-wrapper init-state)
+              rt (om/root wrapper app-state {:target c})
+              react-nodes (tu/find-by-tag rt "div")
+              [main-react display-react] react-nodes
+              [main-node display-node] (mapv om/get-node react-nodes)]
+          (is (= "Joffrey" (.-innerHTML display-node)))
+          (sim/click main-node nil)
+          (om/render-all)
+          (is (empty? (tu/find-by-class rt "transition")))
+          (is (empty? (tu/find-by-class rt "menu")))
+          (is (empty? (tu/find-by-class rt "visible"))))))))

-


.write -> write, .read -> read

.write -> write, .read -> read


A silly bug has been fixed in system_test

--- core/test/clj/hellhound/system_test.clj
+++ core/test/clj/hellhound/system_test.clj
@@ -103,4 +103,3 @@

     (system/stop!)))
-ٓج


store: adapt to new signature for ->id

store: adapt to new signature for ->id

--- src/io/cyanite/store.clj
+++ src/io/cyanite/store.clj
@@ -46,7 +46,7 @@
   MetricStore
   (fetch! [this from to paths]
     (c/runq! session fetchq
-             [(mapv (partial c/->id id-type) paths)
+             [(mapv (partial c/->id id-type res-type) paths)
               (long from)
               (long to)]
              {:consistency rdcty


last => peek

last => peek

--- src/java_time/graph.cljc
+++ src/java_time/graph.cljc
@@ -207,7 +207,7 @@
             dsts (equivalent-targets g dst)]
         (loop []
           (when-some [^ConversionPath p (poll)]
-            (let [curr (or (-> p .path last second) src)]
+            (let [curr (or (-> p .path peek second) src)]
               (if (some #(assignable? curr %) dsts)
                 p
                 (do (run! (fn [[[src dst] c]]
@@ -220,7 +220,7 @@
 (defn- replace-range [v replacement idxs]
   (concat (subvec v 0 (first idxs))
           replacement
-          (subvec v (inc (last idxs)) (count v))))
+          (subvec v (inc (peek idxs)) (count v))))

 (defn- index-conversions [^Types src idxs [[_ ^Types replacement] ^Conversion conv]]
   [src
@@ -228,7 +228,7 @@
    (fn [vs]
      (let [vs (vec vs)]
        (replace-range vs
-                      ((.f conv) (subvec vs (first idxs) (inc (last idxs))))
+                      ((.f conv) (subvec vs (first idxs) (inc (peek idxs))))
                       idxs)))
    (.cost conv)])

@@ -251,7 +251,7 @@
     (->> (continuous-combinations (.arity src))
          (mapcat
            (fn [idxs]
-             (let [^Types input (types (subvec (.types src) (first idxs) (inc (last idxs))))]
+             (let [^Types input (types (subvec (.types src) (first idxs) (inc (peek idxs))))]
                (->> (possible-conversions g input)
                     (filter (fn [[[_ ^Types replacement] _]]
                               (>= max-arity (+ (.arity replacement)


Sort mbeans returned by /v2/metrics/mbeans

--- src/com/puppetlabs/puppetdb/http/v1/metrics.clj
+++ src/com/puppetlabs/puppetdb/http/v1/metrics.clj
@@ -66,9 +66,10 @@
 (defn list-mbeans
   "Returns a JSON array of all MBean names"
   [_]
-  (-> (all-mbean-names)
-      (linkify-names)
-      (pl-http/json-response)))
+  (->> (all-mbean-names)
+       (linkify-names)
+       (into (sorted-map))
+       (pl-http/json-response)))

 (defn get-mbean
   "Returns the attributes of a given MBean"


Require valid deviceId and type for measurements POST.

--- src/kixi/hecuba/amon.clj
+++ src/kixi/hecuba/amon.clj
@@ -531,21 +531,26 @@
   :authorized? (authorized? querier :measurement)

   :post! (fn [{{body :body {:keys [device-id]} :route-params} :request}]
-           (let [topic (get-in queue ["measurements"])]
-             (doseq [measurement (-> body read-json-body ->shallow-kebab-map :measurements)]
-               (let [t        (db-timestamp (get measurement "timestamp"))
-                     m2       {:device-id device-id
-                               :type (get measurement "type")
-                               :timestamp t
-                               :value (get measurement "value")
-                               :error (get measurement "error")
-                               :month (get-month-partition-key t)
-                               :metadata "{}"}]
-                 (->> m2
-                      (v/validate commander querier)
-                      (upsert! commander :measurement))
-                 (q/put-on-queue topic m2)
-                 ))))
+           (let [topic         (get-in queue ["measurements"])
+                 measurements  (-> body read-json-body ->shallow-kebab-map :measurements)
+                 type          (get (first  measurements) "type")]
+             (if (and device-id type (not (empty? (first (items querier :sensor {:device-id device-id :type type})))))
+               (do
+                 (doseq [measurement measurements]
+                   (let [t        (db-timestamp (get measurement "timestamp"))
+                         m2       {:device-id device-id
+                                   :type type
+                                   :timestamp t
+                                   :value (get measurement "value")
+                                   :error (get measurement "error")
+                                   :month (get-month-partition-key t)
+                                   :metadata "{}"}]
+                     (->> m2
+                          (v/validate commander querier)
+                          (upsert! commander :measurement))
+                     (q/put-on-queue topic m2)))
+                 {:response {:status 202 :body "Accepted"}})
+               {:response {:status 400 :body "Provide valid deviceId and type."}})))

   :handle-ok (fn [{{{:keys [device-id]} :route-params} :request {mime :media-type} :representation}]
                (let [measurements (items querier :measurement {:device-id device-id})]
@@ -559,7 +564,9 @@
                                       [:pre (with-out-str (pprint m))]]])]])
                    "application/json" (->> measurements downcast-to-json camelify encode))))

-  :handle-created (fn [_] (ring-response {:status 202 :body "Accepted"})))
+  :handle-created
+  (fn [{response :response {routes :modular.bidi/routes} :request}]
+    (ring-response response)))

 (defresource sensors-by-property [{:keys [commander querier]} handlers]
   :allowed-methods #{:get}


show error details during execution, cleanup some code

--- src/leiningen/jshint.clj
+++ src/leiningen/jshint.clj
@@ -68,6 +68,11 @@
         content (joine excludes)]
     (create-tmp-file (ignore-file project) content)))

+(defn- sources-list [project args]
+  (let [includes (include-files project)
+        excludes (exclude-files project)]
+    (remove empty? (concat (apply vec args) includes))))
+
 (defn- invoke [project & args]
   (process/exec
    (project :root)
@@ -78,13 +83,12 @@
     (npm/environmental-consistency project)
     (let [file (config-file project)
           content (generate-config-file project)
-          includes (include-files project)
-          sources (remove empty? (concat (apply vec args) includes))]
+          sources (sources-list project args)]
       (npm/with-json-file file content project
                           (generate-exclude-files project)
                           (apply invoke project sources)))
     (catch Throwable t
-      (println (joine "Can't execute jshint application."
+      (println (joine (str "Can't execute jshint application: " (.getMessage t))
                       "Check that JSHint is:"
                       " - installed correctly: npm install jshint -g"
                       " - configured correctly: https://github.com/vbauer/lein-jshint.git"))


event_extension_types.description is nullable

--- src/lobos/migrations.clj
+++ src/lobos/migrations.clj
@@ -14,7 +14,7 @@
               (table-entity :trackers
                             (varchar :tracker_identifier 256 :not-null :unique)
                             (varchar :name 256)
-                            (timestamp :latest_activity :index)
+                            (timestamp :latest_activity)
                             (varchar :shared_secret 64)
                             ))
       (create (index :trackers :ix_trackers_name [:name]))
@@ -52,10 +52,13 @@
   (down [] (drop (table :event_annotations))))

 (defmigration add-event-extension-types-table
-  (up [] (create
-          (table-entity :event_extension_types
-                        (varchar :name 256 :not-null)
-                        (varchar :description 256 :not-null))))
+  (up []
+      (create
+       (table-entity :event_extension_types
+                     (varchar :name 256 :not-null)
+                     (varchar :description 256)))
+      (create (index :event_extension_types [:name]))
+      )
   (down [] (drop (table :event_extension_types))))

 (defmigration add-event-extension-values-table


logging bug fix

logging bug fix


Add int32 type

Add int32 type


Keep displaying upload status until transcoding starts

--- src/airhead_frontend/components.cljs
+++ src/airhead_frontend/components.cljs
@@ -154,9 +154,6 @@
         done? (fn [] (some #(= track-id %)
                            (map :uuid library)))]
     (cond
-      (< loaded total)
-      [info-uploading file-name loaded total]
-
       (= status 200)
       (if (done?)
         [info-done (->> library
@@ -164,8 +161,11 @@
                         first)]
         [info-transcoding file-name])

+      (and status (not= status 200))
+      [info-error status error-msg]
+
       :else
-      [info-error status error-msg])))
+      [info-uploading file-name loaded total])))

 (defn file-select-button [file-input-ref]
   [:div.pure-button.pure-u-1-2


load test comps (incomplete) and comp-tags

--- test/navigator/test_data.clj
+++ test/navigator/test_data.clj
@@ -5,91 +5,88 @@

 (defn load-multiple!
   [db-conn entity-type entities]
-  (doseq ))
+  (doseq [ent entities] (navigator/tx-entity! db-conn entity-type ent)))

 (defn load-test-data!
   ([db-conn] (load-test-data! db-conn test-data))
   ([db-conn data]
-     (doseq [[entity-type entities] data]
-
-       (navigator/tx-entity! ))))
+     (doseq [[entity-type entities] (partition 2 data)]
+       (load-multiple! db-conn entity-type entities))))

 (def test-data
-  [:comp-tags [{:comp-tag/name "VLACS HS Diploma"
-                :comp-tag/version "v1"
-                :comp-tag/type "program-of-study"
-                :comp-tag/status "active"}
-               {:comp-tag/name "Mathematics"
-                :comp-tag/version "v1"
-                :comp-tag/type "area-of-study"
-                :comp-tag/status :comp-tag.status/active}
-               {:comp-tag/name "English":comp-tag.status/active
-                :comp-tag/version "v1"
-                :comp-tag/type "area-of-study"
-                :comp-tag/status :comp-tag.status/active}
-               {:comp-tag/name "Foreign Language"
-                :comp-tag/version "v1"
-                :comp-tag/type "area-of-study"
-                :comp-tag/status :comp-tag.status/active}
-               {:comp-tag/name "Geometry"
-                :comp-tag/version "v1"
-                :comp-tag/type "course"
-                :comp-tag/status :comp-tag.status/active}
-               {:comp-tag/name "English 1"
-                :comp-tag/version "v1"
-                :comp-tag/type "course"
-                :comp-tag/status :comp-tag.status/active}
-               {:comp-tag/name "Spanish 1"
-                :comp-tag/version "v1"
-                :comp-tag/type "course"
-                :comp-tag/status :comp-tag.status/active}
-               {:comp-tag/name "Music Theory"
-                :comp-tag/version "v1"
-                :comp-tag/type "course"
-                :comp-tag/status :comp-tag.status/active}
-               {:comp-tag/name "Quantitative Skills"
-                :comp-tag/version "v1"
-                :comp-tag/type "cluster"
-                :comp-tag/status :comp-tag.status/active}
-               {:comp-tag/name "Critical and Creative Thinking"
-                :comp-tag/version "v1"
-                :comp-tag/type "cluster"
-                :comp-tag/status :comp-tag.status/active}
-               {:comp-tag/name "Musical Intelligence"
-                :comp-tag/version "v1"
-                :comp-tag/type "cluster"
-                :comp-tag/status :comp-tag.status/active}]])
-
-(def comps
-  [{:comp/id-sk "1"
-    :comp/name "Can add vectors"
-    :comp/version "v1"
-    :comp/status :comp.status/active}
-   {:comp/id-sk "2"
-    :comp/name "Can draw circles"
-    :comp/verion "v1"
-    :comp/status :comp.status/active}
-   {:comp/id-sk "3"
-    :comp/name "Can say \"hegemon\" in Spanish"
-    :comp/version "v1"
-    :comp/status :comp.status/active}
-   {:comp/id-sk "4"
-    :comp/name "Can say \"disjunctivist\" in English"
-    :comp/version "v1"
-    :comp/status :comp.status/archived}
-   {:comp/id-sk "5"
-    :comp/name "Can write resaurant criticism"
-    :comp/version "v1"
-    :comp/status :comp.status/active}
-   {:comp/id-sk "6"
-    :comp/name "Can create balloon animals"
-    :comp/version "v1"
-    :comp/status :comp.status/active}
-   {:comp/id-sk "7"
-    :comp/name "Can say \"disjunctivist\" in English"
-    :comp/version "v2"
-    :comp/status :comp.status/active}
-   {:comp/id-sk "8"
-    :comp/name "Can compose trios for washboard"
-    :comp/version "v1"
-    :comp/status :comp.status/preactive}])
+  [:comp-tag [{:comp-tag/name "VLACS HS Diploma"
+               :comp-tag/version "v1"
+               :comp-tag/type "program-of-study"
+               :comp-tag/status "active"}
+              {:comp-tag/name "Mathematics"
+               :comp-tag/version "v1"
+               :comp-tag/type "area-of-study"
+               :comp-tag/status :comp-tag.status/active}
+              {:comp-tag/name "English"
+               :comp-tag/version "v1"
+               :comp-tag/type "area-of-study"
+               :comp-tag/status :comp-tag.status/active}
+              {:comp-tag/name "Foreign Language"
+               :comp-tag/version "v1"
+               :comp-tag/type "area-of-study"
+               :comp-tag/status :comp-tag.status/active}
+              {:comp-tag/name "Geometry"
+               :comp-tag/version "v1"
+               :comp-tag/type "course"
+               :comp-tag/status :comp-tag.status/active}
+              {:comp-tag/name "English 1"
+               :comp-tag/version "v1"
+               :comp-tag/type "course"
+               :comp-tag/status :comp-tag.status/active}
+              {:comp-tag/name "Spanish 1"
+               :comp-tag/version "v1"
+               :comp-tag/type "course"
+               :comp-tag/status :comp-tag.status/active}
+              {:comp-tag/name "Music Theory"
+               :comp-tag/version "v1"
+               :comp-tag/type "course"
+               :comp-tag/status :comp-tag.status/active}
+              {:comp-tag/name "Quantitative Skills"
+               :comp-tag/version "v1"
+               :comp-tag/type "cluster"
+               :comp-tag/status :comp-tag.status/active}
+              {:comp-tag/name "Critical and Creative Thinking"
+               :comp-tag/version "v1"
+               :comp-tag/type "cluster"
+               :comp-tag/status :comp-tag.status/active}
+              {:comp-tag/name "Musical Intelligence"
+               :comp-tag/version "v1"
+               :comp-tag/type "cluster"
+               :comp-tag/status :comp-tag.status/active}]
+   :comp [{:comp/id-sk "1"
+           :comp/name "Can add vectors"
+           :comp/version "v1"
+           :comp/status :comp.status/active}
+          {:comp/id-sk "2"
+           :comp/name "Can draw circles"
+           :comp/verion "v1"
+           :comp/status :comp.status/active}
+          {:comp/id-sk "3"
+           :comp/name "Can say \"hegemon\" in Spanish"
+           :comp/version "v1"
+           :comp/status :comp.status/active}
+          {:comp/id-sk "4"
+           :comp/name "Can say \"disjunctivist\" in English"
+           :comp/version "v1"
+           :comp/status :comp.status/archived}
+          {:comp/id-sk "5"
+           :comp/name "Can write resaurant criticism"
+           :comp/version "v1"
+           :comp/status :comp.status/active}
+          {:comp/id-sk "6"
+           :comp/name "Can create balloon animals"
+           :comp/version "v1"
+           :comp/status :comp.status/active}
+          {:comp/id-sk "7"
+           :comp/name "Can say \"disjunctivist\" in English"
+           :comp/version "v2"
+           :comp/status :comp.status/active}
+          {:comp/id-sk "8"
+           :comp/name "Can compose trios for washboard"
+           :comp/version "v1"
+           :comp/status :comp.status/preactive}]])


use html input type='email' (#611)

use html input type='email' (#611)

--- src/cljs/org/broadinstitute/firecloud_ui/page/workspace/summary/catalog.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/workspace/summary/catalog.cljs
@@ -147,6 +147,7 @@
                      :else
                      (style/create-text-field {:style (colorize {:width "100%"})
                                                :type (cond (= renderHint "date") "date"
+                                                           (= renderHint "email") "email"
                                                            (= type "integer") "number"
                                                            :else "text")
                                                :min minimum


Expand test coverage of web site.

Expand test coverage of web site.

--- test/circle/web/test_web.clj
+++ test/circle/web/test_web.clj
@@ -1,11 +1,26 @@
 (ns circle.web.test-web
   (:require circle.init)
   (:require [clj-http.client :as http])
+  (:require [clj-http.core :as core])
   (:use midje.sweet))

 (circle.init/init)

 (def site "http://localhost:8080")

+
+
 (fact "/ returns 200"
-  (http/get site) => (contains {:status 200}))+  (let [response (http/get site)]
+    response => (contains {:status 200 :body #"Sign up"})))
+
+(fact "posting works"
+      (let [post-request {:form-params {:email "mytest@test.com" :contact true}}
+            post-response (http/post site post-request)
+            get-request {:cookies (post-response :cookies)
+                         :url (get-in post-response [:headers "location"])}
+            get-response (http/get site get-request)]
+
+        post-response => (contains {:status 302})
+        (:headers post-response) => (contains {"location" "/"})
+        get-response => (contains {:status 200 :body #"Thanks"})))


Fix unexpected exception on workspace load...

... when the user access it from dashboard.

--- src/uxbox/ui/workspace/header.cljs
+++ src/uxbox/ui/workspace/header.cljs
@@ -18,13 +18,13 @@

 (defn- coordenates-render
   [own]
-  (let [{:keys [x y]} (rum/react wb/mouse-canvas-a)
-        x (mth/precision x 1)
-        y (mth/precision y 1)]
-    (html
-     [:ul.options-btn
-      [:li.tooltip.tooltip-bottom {:alt "x"} x]
-      [:li.tooltip.tooltip-bottom {:alt "y"} y]])))
+  (when-let [{:keys [x y]} (rum/react wb/mouse-canvas-a)]
+    (let [x (mth/precision x 1)
+          y (mth/precision y 1)]
+      (html
+       [:ul.options-btn
+        [:li.tooltip.tooltip-bottom {:alt "x"} x]
+        [:li.tooltip.tooltip-bottom {:alt "y"} y]]))))

 (def coordinates
   (mx/component


Size setup for SPF space and projector.

Size setup for SPF space and projector.

--- src/videotest/coral/coral_core.clj
+++ src/videotest/coral/coral_core.clj
@@ -17,7 +17,7 @@
    [org.opencv.imgproc Imgproc]
    [java.nio ByteBuffer ByteOrder]))

-(def CAM-DEV-NUM 0)
+(def CAM-DEV-NUM 1)
 (def CAM-SIZE (cv/camera-frame-size CAM-DEV-NUM))
 (def CAM-WIDTH  (int (:width  CAM-SIZE)))
 (def CAM-HEIGHT (int (:height CAM-SIZE)))
@@ -25,10 +25,13 @@
 ;; Optoma Projector
 ;; (def DISPLAY-WIDTH 1280.0)
 ;; (def DISPLAY-HEIGHT 800.0)
+(def DISPLAY-WIDTH 1280.0)
+(def DISPLAY-HEIGHT 720.0)
+

 ;; Lenovo
-(def DISPLAY-WIDTH 1366.0)
-(def DISPLAY-HEIGHT 768.0)
+;; (def DISPLAY-WIDTH 1366.0)
+;; (def DISPLAY-HEIGHT 768.0)

 ;; pixCnt1 is the number of bytes in the pixel buffer
 ;; pixCnt2 is the number of integers in the PImage pixels buffer
@@ -169,7 +172,7 @@
        (.release camera))))

 (q/defsketch videotest
-  :title "x"
+  :title ""
   :size [DISPLAY-WIDTH DISPLAY-HEIGHT]
   :setup setup
   :update update


read body properly under httpkit

read body properly under httpkit

--- src/chat/server/extensions/asana.clj
+++ src/chat/server/extensions/asana.clj
@@ -105,14 +105,15 @@
           (db/set-extension-config! (extension :id) :webhook-secret secret))
       {:status 200 :headers {"X-Hook-Secret" secret}})
     (if-let [signature (get-in event-req [:headers "x-hook-signature"])]
-      (let [body (str (:body event-req))]
+      (let [body (:body event-req)
+            body (if (string? body) body (slurp body))]
         (timbre/debugf "webhook %s" event-req)
           (if (hmac-verify {:secret (get-in extension [:config :webhook-secret])
                             :data body
                             :mac signature})
             (do
               (timbre/debugf "webhook signature okay")
-              (let [data (json/read-str (:body event-req))
+              (let [data (json/read-str body)
                     new-issues (->> (data "events")
                                     (filter (fn [e] (and (= "task" (e "type"))
                                                          (= "added" (e "action"))))))]


WIP clean up certain parts of forward tests, add backwards tests


Playing with relations with core.unify

Playing with relations with core.unify

--- src/clj/algorithms_clj/ancestors.clj
+++ src/clj/algorithms_clj/ancestors.clj
@@ -3,6 +3,8 @@
     [clojure.core.logic :rename {== ===} :refer :all]
     [clojure.core.logic.fd :as fd]
     [clojure.core.logic.pldb :as pldb]
+    [clojure.core.unify :as uni]
+    [clojure.set :as set]
     ))

@@ -39,13 +41,13 @@
       [link 'b 'd]
       ))

-  (defn has-parent?
+  (defn childo
     [x]
     (fresh [z] (link z x)))

   (pldb/with-db dbg-facts
     (run* [childs]
-      (has-parent? childs))
+      (childo childs))
     ))

@@ -58,9 +60,11 @@
     (pldb/db
       [link 'a ['b 'c]] ;; Sets would be nicer, but seems not supported in core.logic
       [link 'b ['c 'd]]
-      ))
-
-  (defn has-parent?
+      ;;[link 'a #{'b 'c}] ;; Stack overflow with anything like (project and contains?)
+      ;;[link 'b #{'c 'd}]
+      ))
+
+  (defn childo
     [x]
     (fresh [parent childs]
       (link parent childs)
@@ -68,8 +72,8 @@
       ))

   (pldb/with-db dbg-facts
-    (run* [childs]
-      (has-parent? childs))
+    (run* [child]
+      (childo child))
     ))

@@ -83,12 +87,43 @@

   (def parent-view (into {} (:parent-rels db)))
   (def childs-view (into {} (map (comp vec reverse)) (:parent-rels db)))
-
-  (defn has-parent? [c]
-    (contains? childs-view c))
-
+  (defn has-parent? [c] (contains? childs-view c))
   (keys childs-view))

+
+
+(defn test-dbg-4
+  "Different modelization: using unify and clojure.set/join"
+  []
+
+  ;;Based on the amazing API:
+  ;;(uni/unify '((?a * ?x ** 2) + (?b * ?x) + ?c) '(?z + (4 * 5) + 3))
+
+  (def parent-rel '[::parent ?parent ?child])
+  (def parent-db
+    [[::parent 'a 'b]
+     [::parent 'a 'c]
+     [::parent 'b 'c]
+     [::parent 'b 'd]])
+
+  (def sex-rel '[?sex ?person])
+  (def sex-db
+    [[::male 'a]
+     [::female 'b]
+     [::male 'c]
+     [::female 'd]])
+
+  (defn bind-relation [rel values]
+    (map #(uni/unify rel %) values))
+
+  (defn get-children-sex
+    []
+    (let [children (bind-relation parent-rel parent-db)
+          sexes (bind-relation '[?sex ?child] sex-db)]
+      (map (juxt '?child '?sex) (set/join children sexes))
+      ))
+
+  (get-children-sex))

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


Convert type in cljs.

Convert type in cljs.

--- src/cljc/cmr/client/common/http.cljc
+++ src/cljc/cmr/client/common/http.cljc
@@ -2,5 +2,7 @@

 (defn query+options
   [query-params http-options]
-  (merge {:query-params query-params}
-         http-options))
+  (merge {:query-params #?(:clj query-params
+                           :cljs (js->clj query-params))}
+         #?(:clj http-options
+            :cljs (js->clj http-options))))


Fixed route annotation check.

Fixed route annotation check.

--- src/cmr/opendap/auth/permissions.clj
+++ src/cmr/opendap/auth/permissions.clj
@@ -62,14 +62,20 @@
   [request]
   (get-in request [:path-params :concept-id]))

+(defn- -route-annotation
+  [request]
+  (get-in (ring/get-match request) [:data :get :permissions]))
+
 (defn route-annotation
   "Extract any permissions annotated in the route associated with the given
   request."
   [request]
-  (reitit-acl-data
-   (route-concept-id request)
-   (cmr-acl->reitit-acl
-    (get-in (ring/get-match request) [:data :get :permissions]))))
+  (let [annotation (-route-annotation request)]
+    (log/debug "Permissions annotation:" annotation)
+    (when annotation
+      (reitit-acl-data
+       (route-concept-id request)
+       (cmr-acl->reitit-acl annotation)))))

 (defn concept
   "Query the CMR Access Control API to get the permissions the given token+user


allow setting a null value for Org :report_timezone, which is valid.

--- src/metabase/api/org.clj
+++ src/metabase/api/org.clj
@@ -67,11 +67,11 @@
   {name NonEmptyString
    report_timezone TimezoneOption}
   (write-check Org id)
-  (check-500 (upd-non-nil-keys Org id
-                               :description description
-                               :logo_url logo_url
-                               :report_timezone report_timezone
-                               :name name))
+  (check-500 (upd Org id
+                  :description description
+                  :logo_url logo_url
+                  :report_timezone report_timezone
+                  :name name))
   (sel :one Org :id id))

 (defendpoint DELETE "/:id"


Revert to defrecord for State, to keep equality

--- src/micro_logic/core.clj
+++ src/micro_logic/core.clj
@@ -220,7 +220,7 @@

 ;; A *state* is a record containing a substitution map *s* and the id
 ;; of the next unbound logic variable *c*.
-(deftype State [s c])
+(defrecord State [s c])
 (defn state [s c] (State. s c))
 (def empty-state (state {} 0))


画像表示に仮対応

画像表示に仮対応

--- src/mj-game/mj-game.cljc
+++ src/mj-game/mj-game.cljc
@@ -112,7 +112,7 @@
        (let [curr (nth @current-problems @i)
              choices (calc/choices-generator curr)]
          (reset! current-answer ((comp str :点 first) (calc/nan-ten? curr)))
-         (set! (.-innerHTML buffer1) curr)
+         (set! (.-innerHTML buffer1) (str curr "<br>" (calc/hand-to-html (calc/to-list curr))))
          (mapc
           (fn [btn choice]
             (set! (.-innerHTML btn) choice)


Removing unused reference in core

Removing unused reference in core

--- src/buzz_me_when/core.clj
+++ src/buzz_me_when/core.clj
@@ -2,8 +2,7 @@
                                 [ring.middleware.params :refer [wrap-params]]
                                 [ring.adapter.jetty :refer [run-jetty]]
                                 [compojure.core :refer [defroutes ANY]]
-                                [buzz-me-when.accessor :as accessor]
-                                [buzz-me-when.monitor :as monitor]))
+                                [buzz-me-when.accessor :as accessor]))

 (defresource alert-retriever-marker [symbol]
   :allowed-methods [:get :put]
@@ -29,4 +28,4 @@
   (-> alerts
     (wrap-params)))

-(run-jetty #'handler {:port 3000})
+;(run-jetty #'handler {:port 3000})


Improve handlers communication functions.

--- src/catacumba/ratpack.clj
+++ src/catacumba/ratpack.clj
@@ -70,25 +70,39 @@
     (fn [chain] (reduce attach-route chain routes))
     {:type :ratpack-router}))

+(defn route-params
+  "Return a hash-map with parameters extracted from
+  routing patterns."
+  [^Context context]
+  (into {} utils/keywordice-keys-t (.getPathTokens context)))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Handlers Communication
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (defrecord ContextData [payload])
-
 (alter-meta! #'->ContextData assoc :private true)
 (alter-meta! #'map->ContextData assoc :private true)

 (defn delegate
-  "Delegate handling to the next handler in line."
+  "Delegate handling to the next handler in line.
+
+  This function accept an additiona parameter for
+  pass context parameters to the next handlers, and
+  that can be obtained with `context-params`
+  function."
   ([^Context context]
    (.next context))
   ([^Context context data]
    (let [reg (Registries/just (ContextData. data))]
      (.next context reg))))

-(defn context-data
-  "Get current context data."
+(defn context-params
+  "Get the current context params.
+
+  The current params can be passed to the next
+  handler using the `delegate` function. Is a simple
+  way to communicate the handlers chain."
   [^Context context]
   (try
     (let [cdata (.get context ContextData)]


Add a FIXME

Add a FIXME

to a place in the code that isn't quite finished

--- src/catalog/web/views.clj
+++ src/catalog/web/views.clj
@@ -232,7 +232,7 @@
           (form/hidden-field "items" (prn-str items))
           (form/submit-button "Upload Anyway"))))
       (do
-        ;; add the file
+        ;; FIXME: add the file
         ;; and redirect to the index
         (response/redirect-after-post (format "/%s/%s" year issue))))))


Update email verification and password reset copy.

--- src/oc/email/content.clj
+++ src/oc/email/content.clj
@@ -30,12 +30,12 @@
 (def anonymous-board-invite-message "You've been invited to a private section on Carrot")
 (def board-invite-explainer "Private sections of the digest are only available to invited team members.")

-(def reset-message "Someone (hopefully you) requested a new password for your Carrot account")
+(def reset-message "Please reset the password for your Carrot account")
 (def reset-instructions "Click the link below to reset your password.")
 (def reset-button-text "Reset Password")
 (def reset-ignore "If you didn't request a password reset, you can safely ignore this email.")

-(def verify-message "Someone (hopefully you) created a Carrot account")
+(def verify-message "Please verify your email for Carrot")
 (def verify-instructions "Click the link below to verify your email address.")
 (def verify-button-text "Verify Email")
 (def verify-ignore "If you didn't create a Carrot account, you can safely ignore this email.")


format docstrings

format docstrings

--- src/overtone/sc/core.clj
+++ src/overtone/sc/core.clj
@@ -85,14 +85,15 @@

 (defn notify
   "Turn on notification messages from the audio server.  This lets us free
-  synth IDs when they are automatically freed with envelope triggers.  It also lets
-  us receive custom messages from various trigger ugens."
+  synth IDs when they are automatically freed with envelope triggers.  It also
+  lets us receive custom messages from various trigger ugens."
   [notify?]
   (snd "/notify" (if (false? notify?) 0 1)))

 (defn connect-jack-ports
-  "Connect the jack input and output ports as best we can.  If jack ports are always different
-  names with different drivers or hardware then we need to find a better strategy to auto-connect."
+  "Connect the jack input and output ports as best we can.  If jack ports are
+  always different names with different drivers or hardware then we need to find
+  a better strategy to auto-connect."
   ([] (connect-jack-ports 2))
   ([n-channels]
      (let [port-list (sh "jack_lsp")
@@ -163,8 +164,8 @@

 ;; TODO: setup an error-handler in the case that we can't connect to the server
 (defn connect
-  "Connect to an running SC audio server. Either an external server if host and port are passed or an internal server
-   in the case of no args."
+  "Connect to an running SC audio server. Either an external server if host and
+  port are passed or an internal server in the case of no args."
   ([] (connect-internal))
   ([host port] (.run (Thread. #(connect-external host port)))))

@@ -175,14 +176,18 @@
     (print msg)))

 (defn recv
-  "Register your intent to wait for a message associated with given path to be received from the server. Returns a promise that will contain the message once it has been received. Does not block current thread (this only happens once you try and look inside the promise and the reply has not yet been received)."
+  "Register your intent to wait for a message associated with given path to be
+  received from the server. Returns a promise that will contain the message once
+  it has been received. Does not block current thread (this only happens once
+  you try and look inside the promise and the reply has not yet been received)."
   [path]
   (let [p (promise)]
     (on-sync-event path (uuid) #(do (deliver p %) :done))
     p))

 (defn await-promise
-  "Read the reply received from the server, waiting for timeout ms if the message hasn't yet been received. Returns :timeout if a timeout occurs."
+  "Read the reply received from the server, waiting for timeout ms if the
+  message hasn't yet been received. Returns :timeout if a timeout occurs."
   ([prom] (await-promise prom REPLY-TIMEOUT))
   ([prom timeout]
      (try
@@ -191,7 +196,9 @@
          :timeout))))

 (defn await-promise!
-  "Read the reply received from the server, waiting for timeout ms if the message hasn't yet been received. Raises an exception if the message hasn't been received within timeout ms"
+  "Read the reply received from the server, waiting for timeout ms if the
+  message hasn't yet been received. Raises an exception if the message hasn't
+  been received within timeout ms"
   ([prom] (await-promise prom REPLY-TIMEOUT))
   ([prom timeout]
      (.get (future @prom) timeout TimeUnit/MILLISECONDS)))
@@ -240,7 +247,8 @@
     @status*))

 (defn wait-sync
-  "Wait until the audio server has completed all asynchronous commands currently in execution."
+  "Wait until the audio server has completed all asynchronous commands
+  currently in execution."
   [& [timeout]]
   (let [sync-id (rand-int 999999)
         reply-p (recv "/synced")


rename pass-on to route

rename pass-on to route

--- src/ow/starbuck/core.clj
+++ src/ow/starbuck/core.clj
@@ -20,7 +20,7 @@
             [taoensso.timbre :refer [trace debug info warn error fatal]]))

 (defprotocol MessageRouting
-  (pass-on [this req]))
+  (route [this req]))

 (defn safe-process [this f req & args]
   (try
@@ -43,7 +43,7 @@

        MessageRouting

-       (pass-on [this# req#]
+       (route [this# req#]
          (debug "routing message...")
          (put! ~'ch-out req#))

@@ -62,8 +62,8 @@
                          (debug "sending response(s)")
                          (cond
                            (nil? res#)        nil
-                           (sequential? res#) (dorun (map #(pass-on ~this1 %) res#))
-                           true               (pass-on ~this1 res#)))))
+                           (sequential? res#) (dorun (map #(route ~this1 %) res#))
+                           true               (route ~this1 res#)))))
                  (recur (<! ~'ch-in)))
              (info "stopped.")))
          (let [~this1 ~(if startfn


more interface stuff for RangeMap

more interface stuff for RangeMap

--- sample/src/sample/rangemap.clj
+++ sample/src/sample/rangemap.clj
@@ -2,6 +2,8 @@

 (deftype RangeMap [kind ^clojure.lang.IPersistentMap m leftfn rightfn]
+
+  clojure.lang.MapEquivalence

   clojure.lang.IPersistentMap

@@ -10,6 +12,9 @@

   (assocEx [this k v]
     (RangeMap. kind (.assocEx m k v) leftfn rightfn))
+
+  (without [this k]
+    (RangeMap. kind (.without m k) leftfn rightfn))

   clojure.lang.ILookup
@@ -49,9 +54,30 @@
     (.seq m))

-  java.lang.Iterable
+  clojure.lang.Associative

-  (iterator [this]
+  (containsKey [this k]
+    (.containsKey m k))
+
+
+  clojure.lang.IPersistentCollection
+
+  (equiv [this o]
+    (.equiv m o))
+
+  (empty [this]
+    (RangeMap. kind (.empty m) leftfn rightfn))
+
+  (cons [this o]
+    (RangeMap. kind (.cons m o) leftfn rightfn))
+
+  (count [this]
+    (.count m))
+
+
+  #_java.lang.Iterable
+
+  #_(iterator [this]
     (.iterator m))

@@ -60,8 +86,14 @@
   (toString [this]
     (.toString m))

-  (equiv [this o]
-    (.equiv m o))
+
+  java.util.Map
+
+  (size [this]
+    (.size m))
+
+  (get [this k]
+    (.valAt this k))

   clojure.lang.IHashEq


Search all loaded macro namespaces for doc

Previously, had a hard-coded search through a few macro namespaces. Revises this to look through all loaded macro namespaces.

Fixes #181

--- planck-cljs/src/planck/repl.cljs
+++ planck-cljs/src/planck/repl.cljs
@@ -765,18 +765,26 @@
      (when-let [cause (.-cause error)]
        (recur cause include-stacktrace? message)))))

+(defn- get-macro-var
+  [env sym macros-ns]
+  {:pre [(symbol? macros-ns)]}
+  (let [macros-ns-str (str macros-ns)
+        base-ns-str   (subs macros-ns-str 0 (- (count macros-ns-str) 7))
+        base-ns       (symbol base-ns-str)]
+    (if-let [macro-var (with-compiler-env st
+                         (resolve-var env (symbol macros-ns-str (name sym))))]
+      (update (assoc macro-var :ns base-ns)
+        :name #(symbol base-ns-str (name %))))))
+
+(defn- all-macros-ns
+  []
+  (->> (all-ns)
+    (filter #(s/ends-with? (str %) "$macros"))))
+
 (defn- get-var
   [env sym]
-  (let [var (with-compiler-env st (resolve-var env sym))
-        var (or var
-                (if-let [macro-var (with-compiler-env st
-                                     (resolve-var env (symbol "cljs.core$macros" (name sym))))]
-                  (update (assoc macro-var :ns 'cljs.core)
-                    :name #(symbol "cljs.core" (name %))))
-                (if-let [macro-var (with-compiler-env st
-                                     (resolve-var env (symbol "planck.repl$macros" (name sym))))]
-                  (update (assoc macro-var :ns 'planck.repl)
-                    :name #(symbol "planck.repl" (name %)))))]
+  (let [var (or (with-compiler-env st (resolve-var env sym))
+                (some #(get-macro-var env sym %) (all-macros-ns)))]
     (when var
       (if (= (namespace (:name var)) (str (:ns var)))
         (update var :name #(symbol (name %)))


Use code closer to cljs.analyzer/resolve-symbol

--- planck-cljs/src/planck/repl.cljs
+++ planck-cljs/src/planck/repl.cljs
@@ -1901,7 +1901,7 @@
   found."
   [s]
   (try
-    (when-let [var (some->> s repl-read-string first (resolve-var (assoc-in @env/*compiler* [:ns :name] (.-name *ns*))))]
+    (when-let [var (some->> s repl-read-string first (resolve-var (assoc @env/*compiler* :ns (ana/get-namespace ana/*cljs-ns*))))]
       (let [arglists (if-not (or (:macro var))
                        (:arglists var)
                        (-> var :meta :arglists second))]


Remove extraneous code

Remove extraneous code

The event handler for :complete-all-toggle doesn't appear to require any info from the event vector.

--- examples/todomvc/src/todomvc/views.cljs
+++ examples/todomvc/src/todomvc/views.cljs
@@ -55,7 +55,7 @@
         [:input#toggle-all
           {:type "checkbox"
            :checked all-complete?
-           :on-change #(dispatch [:complete-all-toggle (not all-complete?)])}]
+           :on-change #(dispatch [:complete-all-toggle])}]
         [:label
           {:for "toggle-all"}
           "Mark all as complete"]


use hipo, not crate

use hipo, not crate

--- src/demos/async_page.cljs
+++ src/demos/async_page.cljs
@@ -1,7 +1,7 @@
 (ns demos.async-page
   (:require [cljs.core.async :as async
              :refer [<! >! chan close! sliding-buffer put!]]
-            [crate.core :as crate]
+            [hipo.core :as hipo]
             [jayq.core :as jq :refer [$ css inner html on]]
             [clojure.string :as string])
   (:require-macros [cljs.core.async.macros :as m :refer [go alt!]]))
@@ -66,7 +66,7 @@
   (let [elem ($ ".container")]
     (log elem)
     (inner elem
-          (crate/html (view-func state)))))
+          (hipo/create (view-func state)))))

 (defn app-loop [start-state]
   (let [edit-click       (click-chan ".app a.edit" :edit)


pass around a doctopus

pass around a doctopus


Change twitter message

Change twitter message

--- src/pict_source/site.clj
+++ src/pict_source/site.clj
@@ -18,7 +18,7 @@
 (def twitter-share-button
   "<a href=\"https://twitter.com/share\" class=\"twitter-share-button\"
     data-url=\"http://pict.divshot.io\"
-    data-text=\"Check this out: #pict the open, multi language programmers dictionary\">
+    data-text=\"Check this out: @pict_dictionary the open, multi language programmers dictionary\">
       Tweet
   </a>
   <script>
@@ -53,5 +53,5 @@
        [:p {:class "copyright"}
         "© 2015 "
         [:a {:href "http://shvetsovdm.github.io"}
-         "Dmitry Shvetsov (@shvetsovdm)"]]]]
+         "Dmitry Shvetsov"]]]]
      google-analytics-code]))


Make functions pure

Make functions pure

--- src/play_clj/core_2d.clj
+++ src/play_clj/core_2d.clj
@@ -41,14 +41,14 @@
 (defn image-width
   ([^TextureRegion img]
     (.getRegionWidth img))
-  ([^TextureRegion img val]
-    (.setRegionWidth img val)))
+  ([img val]
+    (doto ^TextureRegion (image img) (.setRegionWidth val))))

 (defn image-height
   ([^TextureRegion img]
     (.getRegionHeight img))
-  ([^TextureRegion img val]
-    (.setRegionHeight img val)))
+  ([img val]
+    (doto ^TextureRegion (image img) (.setRegionHeight val))))

 (defn split-image
   ([val size]


Add decide-corr and decide-bias games

Add decide-corr and decide-bias games

--- src/randometer/core.cljs
+++ src/randometer/core.cljs
@@ -67,6 +67,26 @@
      [:button {:on-click #(on-reset) :style {:margin-top "0.5em"}}
       "play again"])])

+(defn board-decider [{:keys [on-guess on-reset flavortext answertext]} boards choice guess]
+  [:fieldset {:on-click #(when (some? guess) (on-reset))}
+   [:legend flavortext]
+   [:div {:style {:background-color (when (some? guess)
+                                      (if (= guess (= 0 choice))
+                                        "#efe"
+                                        "#fee"))}}
+    [board-element (nth boards choice)]
+    [:span {:style {:display (when (nil? guess) "none")}}
+     (nth answertext choice)]]
+   [:div
+    (for [[value text] {true "yes" false "no"}]
+      [:button {:disabled (some? guess)
+                :on-click #(on-guess value)
+                :style {:margin-top "0.5em"}}
+       text])]
+   (when (some? guess)
+     [:button {:on-click #(on-reset)}
+      "play again"])])
+
 (defn choose-corr [x xs]
   (let [game-state (atom {})
         init-game! (fn []
@@ -106,6 +126,46 @@
                         :flavortext "Which is unbiased?"
                         :answertext (map #(str % " ●") (cons x xs))}
          boards keymap guess]))))
+
+(defn decide-corr [x xs]
+  (let [game-state (atom {})
+        init-game! (fn []
+                     (let [boards (map #(puzzle muted-generator %) (cons x xs))
+                           choice (rand-int (count boards))]
+                      (swap! game-state assoc
+                             :boards boards
+                             :choice choice
+                             :guess nil)))
+        guess! (fn [guess]
+                 (swap! game-state assoc :guess guess))]
+    (init-game!)
+    (fn []
+      (let [{:keys [boards choice guess]} @game-state]
+        [board-decider {:on-guess #(guess! %)
+                        :on-reset #(init-game!)
+                        :flavortext "Was this generated by a fair random generator?"
+                        :answertext (map #(str "The dots flip with " % " chance.") (cons x xs))}
+         boards choice guess]))))
+
+(defn decide-bias [x xs]
+  (let [game-state (atom {})
+        init-game! (fn []
+                     (let [boards (map #(puzzle biased-generator %) (cons x xs))
+                           choice (rand-int (count boards))]
+                      (swap! game-state assoc
+                             :boards boards
+                             :choice choice
+                             :guess nil)))
+        guess! (fn [guess]
+                 (swap! game-state assoc :guess guess))]
+    (init-game!)
+    (fn []
+      (let [{:keys [boards choice guess]} @game-state]
+        [board-decider {:on-guess #(guess! %)
+                        :on-reset #(init-game!)
+                        :flavortext "Was this generated by an unbiased random generator?"
+                        :answertext (map #(str "The dots flip with " % " chance.") (cons x xs))}
+         boards choice guess]))))

 (defn main-page []
   (let [app-state (atom {:game nil})]
@@ -124,6 +184,8 @@
        (case (:game @app-state)
          "choose-corr" [choose-corr 0.5 [0.25 0.33 0.67 0.75]]
          "choose-bias" [choose-bias 0.5 [0.25 0.33 0.67 0.75]]
+         "decide-corr" [decide-corr 0.5 [0.25 0.33 0.67 0.75]]
+         "decide-bias" [decide-bias 0.5 [0.25 0.33 0.67 0.75]]
          nil)])))

 (reagent/render-component [main-page]


Keep JVM thread bindings on next-tick

Keep JVM thread bindings on next-tick

... to enable clojure.test reporting to identify the current test.

--- src/re_frame/interop.clj
+++ src/re_frame/interop.clj
@@ -24,7 +24,8 @@
 (defonce ^:private executor (Executors/newSingleThreadExecutor))

 (defn next-tick [f]
-  (.execute executor f)
+  (let [bound-f (bound-fn [& args] (apply f args))]
+    (.execute executor bound-f))
   nil)

 (def empty-queue clojure.lang.PersistentQueue/EMPTY)


Changed to give the influxdb series name as the first word of the service field

--- src/riemann/influxdb.clj
+++ src/riemann/influxdb.clj
@@ -10,21 +10,41 @@
         split-service (if service (split service #" ") [])]
      (join "." split-service)))

+(defn influxdb-series-name
+  "Constructs a series-name for an event by picking the first word of the
+   service field of an event."
+  [event]
+  (let [service (:service event)]
+    (first (if service (split service #" ")))))
+
 (defn influxdb
+  "Returns a function which accepts an event and sends it to InfluxDB.
+  Use:
+
+  (influxdb {:host \"play.influxdb.org\" :port 8086})
+
+  Options:
+
+  :name           Name of the metric which is same as the series name.
+
+  :db             Name of the DB of InfluxDB to push riemann-events.
+
+  :username       Name of the user who is allowed to push metrics to this DB.
+
+  :password       Password of the corresponding user."
   [opts]
   (let [opts (merge {:host "127.0.0.1"
                      :port 8086
                      :scheme "http"
                      :username "root"
                      :password "root"
-                     :db "riemann"
-                     :series "riemann-events" } opts)
+                     :db "riemann" } opts)
         client (influx/make-client opts)]
     (fn [event]
     (when (:metric event)
       (when (:service event)
         (when (:host event)
-          (influx/post-points client (:series opts) [{:name (influxdb-metric-name event)
-                                                      :host (:host event)
-                                                      :state (:state event)
-                                                      :value (:metric event)}])))))))+          (influx/post-points client (influxdb-series-name event) [{ :name (influxdb-metric-name event)
+                                                                     :host (:host event)
+                                                                     :state (:state event)
+                                                                     :value (:metric event) }])))))))


code changes suggested by the maintainer

--- src/riemann/logstash.clj
+++ src/riemann/logstash.clj
@@ -6,7 +6,7 @@
              DatagramSocket
              DatagramPacket
              InetAddress)
-   (java.io Writer OutputStreamWriter))
+   (java.io Writer OutputStreamWriter BufferedWriter))
   (:use [clojure.string :only [split join replace]]
         clojure.tools.logging
         riemann.pool
@@ -21,58 +21,38 @@
   (close [client]
          "Cleans up (closes sockets etc.)"))

-(defn get-socket
-  [host  port  opts]
-  (cond
-     (= ^Boolean (:tls opts) true)
-         (socket  (ssl-context (:key opts) (:cert opts) (:ca-cert opts))
-                              host
-                              port)
-     :else
-          (Socket. host port)))
-
-(defrecord LogStashTCPClient [^String host ^int port opts]
+(defrecord LogStashTLSClient [^String host ^int port opts]
   LogStashClient
-
   (open [this]
-
-    (let [sock (get-socket host port opts)]
-
-        (cond
-           (= ^Boolean (:tls opts) true)
-              (do
-                (.getSession sock)
-                (assoc this
-                       :socket sock
-                       :out (.getOutputStream sock))
-              )
-          :else
-              (assoc this
-                     :socket sock
-                     :out (OutputStreamWriter. (.getOutputStream sock))))))
-
+    (let [sock  (socket  (ssl-context (:key opts) (:cert opts) (:ca-cert opts))
+                host
+                port)]
+          (.startHandshake sock)
+          (assoc this
+                 :socket sock
+                 :out (BufferedWriter. (OutputStreamWriter. (.getOutputStream sock))))))
   (send-line [this line]
     (let [out (:out this)]
-          (cond
-            (= ^Boolean (:tls opts) true)
-               (do
-                (.write  out  (.getBytes (str line ) ))
-                (.flush out))
-            :else
-              (do
-                (.write ^OutputStreamWriter out ^String line)
-                (.flush ^OutputStreamWriter out)))))
+          (.write ^BufferedWriter out  ^String line)
+          (.flush ^BufferedWriter out)))
+  (close [this]
+    (.close ^BufferedWriter (:out this))
+    (.close ^Socket (:socket this))))

+(defrecord LogStashTCPClient [^String host ^int port]
+  LogStashClient
+  (open [this]
+    (let [sock (Socket. host port)]
+      (assoc this
+             :socket sock
+             :out (OutputStreamWriter. (.getOutputStream sock)))))
+  (send-line [this line]
+    (let [out (:out this)]
+      (.write ^OutputStreamWriter out ^String line)
+      (.flush ^OutputStreamWriter out)))
   (close [this]
-    (cond
-      (= ^Boolean (:tls opts) true)
-         (do
-            (.close (:out this))
-            (.close ^Socket (:socket this)))
-        :else
-        (do
-           (.close ^OutputStreamWriter (:out this))
-           (.close ^Socket (:socket this))))))
+    (.close ^OutputStreamWriter (:out this))
+    (.close ^Socket (:socket this))))

 (defrecord LogStashUDPClient [^String host ^int port]
   LogStashClient
@@ -110,10 +90,9 @@
   :block-start          Wait for the pool's initial connections to open
                         before returning.

-  :protocol             Protocol to use. Either :tcp (default) or :udp.
+  :protocol             Protocol to use. Either :tcp (default), :tls or :udp.

   TLS options:
-  :tls?             Whether to enable TLS
   :key              A PKCS8-encoded private key file
   :cert             The corresponding public certificate
   :ca-cert          The certificate of the CA which signed this key"
@@ -123,19 +102,20 @@
   (let [opts (merge {:host "127.0.0.1"
                      :port 9999
                      :protocol :tcp
-                     :tls false
                      :claim-timeout 0.1
                      :pool-size 4} opts)

         pool (fixed-pool
                (fn []
-                 (info "Connecting to " (select-keys opts [:host :port :security.protocol :tls]))
+                 (info "Connecting to " (select-keys opts [:host :port :protocol]))
                  (let [
                        host (:host opts)
                        port (:port opts)
                        client (open (condp = (:protocol opts)
-                                      :tcp (LogStashTCPClient. host port opts)
-                                      :udp (LogStashUDPClient. host port)))]
+                                      :tcp (LogStashTCPClient. host port)
+                                      :udp (LogStashUDPClient. host port)
+                                      :tls (LogStashTLSClient. host port opts)
+                                      ))]
                    (info "Connected")
                    client))
                (fn [client]


add necessary IAM roles for AWS Minion

add necessary IAM roles for AWS Minion

--- src/aws_overlord/tasks/security.clj
+++ src/aws_overlord/tasks/security.clj
@@ -30,15 +30,21 @@
   {
    "Version" "2012-10-17"
    "Statement" [{"Effect" "Allow"
-                 "Action" ["iam:CreateRole"
+                 "Action" [
+                           "iam:AddRoleToInstanceProfile"
                            "iam:CreateInstanceProfile"
-                           "iam:AddRoleToInstanceProfile"
+                           "iam:CreateRole"
+                           "iam:DeleteInstanceProfile"
+                           "iam:DeleteRole"
+                           "iam:GetInstanceProfile"
+                           "iam:ListRolePolicies"
+                           "iam:ListRoles"
+                           "iam:ListServerCertificates"
                            "iam:PassRole"
-                           "iam:ListServerCertificates"
-                           "iam:ListRoles"
-                           "iam:ListRolePolicies"
                            ; FIXME: PutRolePolicy allows privilege escalation!
-                           "iam:PutRolePolicy"]
+                           "iam:PutRolePolicy"
+                           "iam:RemoveRoleFromInstanceProfile"
+                           ]
                  "Resource" "*"}
                 {"Effect" "Allow"
                  "Action" "ec2:*"


Fix not passing state

Fix not passing state

--- src/braid/client/state/helpers.cljs
+++ src/braid/client/state/helpers.cljs
@@ -163,12 +163,13 @@
 (defn maybe-create-thread [state thread-id group-id]
   (let [state (update-in state [:user :open-thread-ids] #(conj % thread-id))]
     (when-not (get-in state [:threads thread-id])
-      (assoc-in state [:threads thread-id] {:id thread-id
-                                            :group-id group-id
-                                            :messages []
-                                            :tag-ids #{}
-                                            :mentioned-ids #{}})
-      (update-in state [:group-threads group-id] #(conj (set %) thread-id)))))
+      (-> state
+          (assoc-in [:threads thread-id] {:id thread-id
+                                          :group-id group-id
+                                          :messages []
+                                          :tag-ids #{}
+                                          :mentioned-ids #{}})
+          (update-in [:group-threads group-id] #(conj (set %) thread-id))))))

 (defn add-message [state message]
   (-> state


Add boolean transformations for clj->vim

--- src/main/clojure/vimclojure/util.clj
+++ src/main/clojure/vimclojure/util.clj
@@ -196,6 +196,10 @@
   [thing]
   (str-wrap thing \"))

+(defmethod clj->vim Boolean
+  [thing]
+  (if thing "1" "0"))
+
 (derive clojure.lang.ISeq              ::ToVimList)
 (derive clojure.lang.IPersistentSet    ::ToVimList)
 (derive clojure.lang.IPersistentVector ::ToVimList)


Add TODO

Add TODO

--- src/taoensso/faraday.clj
+++ src/taoensso/faraday.clj
@@ -69,6 +69,10 @@
             com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient
             java.nio.ByteBuffer))

+;; TODO Add support for splitting data > 64KB over > 1 keys? This may be tough
+;; to do well relative to the payoff. And I'm guessing there may be an official
+;; (Java) lib to offer this capability at some point?
+
 ;;;; Connections

 (def ^:private db-client*


Use HEAD rather than GET in resolver, narrow down 'yesterday' to 1 day.

--- src/chronograph/import/resolver.clj
+++ src/chronograph/import/resolver.clj
@@ -30,7 +30,7 @@
   (try
     (locking *out* (prn "Start resolve" doi))
     (let [url (crdoi/normalise-doi doi)
-          result (try-try-again {:sleep 5000 :tries 2} #(client/get url
+          result (try-try-again {:sleep 5000 :tries 2} #(client/head url
                                                          {:follow-redirects true
                                                           :throw-exceptions false
                                                           :socket-timeout 5000
@@ -54,11 +54,11 @@

 ; Create a load of return channels for resolved DOIs.
-(def num-return-chans 20)
+(def num-return-chans 50)

 (defn run-doi-resolution []
   ; Insert recently published.
-  (let [yesterday (t/minus (t/now) (t/weeks 1))
+  (let [yesterday (t/minus (t/now) (t/days 1))
         recently-published (k/select d/events-isam (k/where {:type issued-type-id :event [>= (coerce/to-sql-date yesterday)]}))]

     (doseq [event recently-published]


Make sure timers are kicked off at the same time for everyone.

--- src/cljs/wombats_web_client/components/countdown_timer.cljs
+++ src/cljs/wombats_web_client/components/countdown_timer.cljs
@@ -30,24 +30,31 @@
 (defn countdown-timer
   [start-time]

-  (let [cmpnt-state (reagent/atom {:interval-fn nil})]
+  (let [cmpnt-state (reagent/atom {:interval-fn nil
+                                   :timeout-fn nil})]
     (reagent/create-class
      {:component-will-mount
       (fn []
         ;; Force timer to redraw every second, start interval when the countdown timer should switch
-        (swap! cmpnt-state
-               assoc
-               :interval-fn
-               (.setInterval js/window
-                             #(reagent/force-update-all)
-                             1000))
-
-        #_(millis-until start-time))
+        (swap! cmpnt-state
+               assoc
+               :timeout-fn
+               (.setTimeout js/window
+                            (fn []
+                              (swap! cmpnt-state
+                                     assoc
+                                     :interval-fn
+                                     (.setInterval js/window
+                                                   #(reagent/force-update-all)
+                                                   1000)))
+                            ;; Give the browser some extra time to render the next second
+                            (- (millis-until start-time) 100))))

       :component-will-unmount
       (fn []
-        (.clearInterval js/window
-                        (:interval-fn @cmpnt-state)))
+        (let [{:keys [interval-fn timeout-fn]} @cmpnt-state]
+          (.clearTimeout js/window timeout-fn)
+          (.clearInterval js/window interval-fn)))

       :reagent-render
       (fn []


Revert "Change to moving average for bpm sync."

This reverts commit 7386dd246da7d1601569e43a4f3d6781399e009d.

--- src/afterglow/midi.clj
+++ src/afterglow/midi.clj
@@ -11,35 +11,26 @@
   (sync-start [this])
   (sync-stop [this]))

-;; The maximum number of clock pulse intervals to keep for averaging.
-(def ^:private max-clock-intervals 12)
-
 (defn- sync-handler
   "Called whenever a MIDI message is received from the clock source. If it is a clock pulse, update
   the ring buffer in which we are collecting timestamps, and if we have enough, calculate a BPM value
   and update the associated metronome."
-  [metronome msg intervals last-timestamp]
-  (case (:status msg)
-    :timing-clock (let [timestamp (now)]
-                    (when @last-timestamp
-                      (let [delta (- timestamp @last-timestamp)]
-                        (if (< delta 1000)
-                          (do ; Not a completely ridiculous interval, so process this clock pulse
-                            (swap! intervals conj delta)
-                            (when (> (count @intervals) 2)
-                              (let [mean (/ (reduce + @intervals) (count @intervals))]
-                                (metro-bpm metronome (double (/ 60000 (* mean 24)))))))
-                          (reset! intervals (ring-buffer max-clock-intervals))))) ; Too long a gap, discard data and start over.
-                    (reset! last-timestamp timestamp))
-    (:start :stop) (reset! intervals (ring-buffer max-clock-intervals)) ; Clock is being reset!
-    nil))
+  [msg buffer metronome]
+  (when (= (:status msg) :timing-clock)
+    (let [timestamp (now)]
+      (swap! buffer conj timestamp)
+      (when (> (count @buffer) 2)
+        (let [passed (- timestamp (peek @buffer))
+              intervals (dec (count @buffer))
+              mean (/ passed intervals)]
+          (metro-bpm metronome (double (/ 60000 (* mean 24)))))))))

 ;; A simple object which holds the values necessary to establish a link between an external
 ;; source of MIDI clock messages and the metronome driving the timing of a light show.
-(defrecord ClockSync [metronome midi-clock-source intervals last-timestamp]
+(defrecord ClockSync [metronome midi-clock-source buffer]
     IClockSync
     (sync-start [this]
-      (midi/midi-handle-events midi-clock-source (fn [msg] (sync-handler metronome msg intervals last-timestamp))))
+      (midi/midi-handle-events midi-clock-source (fn [msg] (sync-handler msg buffer metronome))))
     (sync-stop [this]
       (midi/midi-handle-events midi-clock-source (fn [msg] nil))))

@@ -48,6 +39,6 @@
   received from the named MIDI source. This synchronization can be stopped by calling the sync-stop
   function on the object returned."
   [^afterglow.rhythm.Metronome metronome ^String midi-clock-source]
-  (let [sync-handler (ClockSync. metronome (midi/midi-in midi-clock-source) (atom (ring-buffer max-clock-intervals)) (atom nil))]
+  (let [sync-handler (ClockSync. metronome (midi/midi-in midi-clock-source) (atom (ring-buffer 12)))]
     (sync-start sync-handler)
     sync-handler))


bumped up clojurescript/reagent/figwheel

--- resources/leiningen/new/reagent_frontend/project.clj
+++ resources/leiningen/new/reagent_frontend/project.clj
@@ -5,8 +5,8 @@
             :url "http://www.eclipse.org/legal/epl-v10.html"}

   :dependencies [[org.clojure/clojure "1.8.0" :scope "provided"]
-                 [org.clojure/clojurescript "1.8.51" :scope "provided"]
-                 [reagent "0.5.1"]
+                 [org.clojure/clojurescript "1.9.36" :scope "provided"]
+                 [reagent "0.6.0-alpha2"]
                  [reagent-forms "0.5.22"]
                  [reagent-utils "0.1.7"]
                  [secretary "1.2.3"]]
@@ -30,11 +30,11 @@
                                         :pretty-print  true}}}}

   :profiles {:dev {:dependencies [[prone "1.1.0"]
-                                  [lein-figwheel "0.5.2"]
+                                  [lein-figwheel "0.5.4-SNAPSHOT"]
                                   [org.clojure/tools.nrepl "0.2.12"]
-                                  [com.cemerick/piggieback "0.2.1"]]
+                                  [com.cemerick/piggieback "0.2.2-SNAPSHOT"]]

-                   :plugins [[lein-figwheel "0.5.2"]]
+                   :plugins [[lein-figwheel "0.5.4-SNAPSHOT"]]

                    :figwheel {:http-server-root "public"
                               :nrepl-port 7002


Implementation of: start-job, enable-job, disable-job, and delete-job

--- src/clj_jenkins_api/jenkins_api.clj
+++ src/clj_jenkins_api/jenkins_api.clj
@@ -92,4 +92,24 @@
             (.printStackTrace e)
             (error-response-structure job-name command e))))

+(defn start-job
+    "Start the given job via Jenkins API."
+    [jenkins-url jenkins-auth include-jenkins-reply? job-name]
+    (job-related-command jenkins-url jenkins-auth include-jenkins-reply? job-name "build"))

+(defn enable-job
+    "Enable the given job via Jenkins API."
+    [jenkins-url jenkins-auth include-jenkins-reply? job-name]
+    (job-related-command jenkins-url jenkins-auth include-jenkins-reply? job-name "enable"))
+
+(defn disable-job
+    "Disable the given job via Jenkins API."
+    [jenkins-url jenkins-auth include-jenkins-reply? job-name]
+    (job-related-command jenkins-url jenkins-auth include-jenkins-reply? job-name "disable"))
+
+(defn delete-job
+    "Delete the given job via Jenkins API."
+    [jenkins-url jenkins-auth include-jenkins-reply? job-name]
+    (job-related-command jenkins-url jenkins-auth include-jenkins-reply? job-name "doDelete"))
+
+


Use ClojureScript's min and max

Use ClojureScript's min and max

--- src/cljs/asciinema_player/util.cljs
+++ src/cljs/asciinema_player/util.cljs
@@ -1,7 +1,7 @@
 (ns asciinema-player.util)

 (defn adjust-to-range [value min-value max-value]
-  (.min js/Math max-value (.max js/Math value min-value)))
+  (min max-value (max value min-value)))

 ; Optimized js->clj implementation by Darrick Wiebe (http://dev.clojure.org/jira/browse/CLJS-844)
 (defn faster-js->clj


code prettifying fixes as suggested by saintis

--- src/cljs/netrunner/deckbuilder.cljs
+++ src/cljs/netrunner/deckbuilder.cljs
@@ -268,12 +268,12 @@
 (defn influence-dots
   "Returns a string with UTF-8 full circles representing influence."
   [num]
-  (apply str (conj (for [_ (range num)] "●") ""))) ;  is a zero-width space to allow wrapping
+  (join (conj (repeat num "●") ""))) ;  is a zero-width space to allow wrapping

 (defn restricted-dots
   "Returns a string with UTF-8 empty circles representing MWL restricted cards."
   [num]
-  (apply str (conj (for [_ (range num)] "○") "")))
+  (join (conj (repeat num "○") "")))

 (defn influence-html
   "Returns hiccup-ready vector with dots colored appropriately to deck's influence."
@@ -295,9 +295,10 @@

 (defn deck-status-label
   [deck]
-  (if (mwl-legal? deck)
-    "legal"
-    (if (valid? deck) "casual" "invalid")))
+  (cond
+    (mwl-legal? deck) "legal"
+    (valid? deck) "casual"
+    :else "invalid"))

 (defn deck-status-span
   "Returns a [:span] with standardized message and colors depending on the deck validity."
@@ -317,9 +318,9 @@
              "<deck game=\"0f38e453-26df-4c04-9d67-6d43de939c77\">
<card qty=\"1\" id=\""
              id (:code identity) "\">" (:title identity) "</card>
"
              "
"
-             (apply str (for [c (:cards deck) :when (get-in c [:card :title])]
-                          (str "<card qty=\"" (:qty c) "\" id=\"" id (get-in c [:card :code]) "\">"
-                               (html-escape (get-in c [:card :title])) "</card>")))
+             (join (for [c (:cards deck) :when (get-in c [:card :title])]
+                     (str "<card qty=\"" (:qty c) "\" id=\"" id (get-in c [:card :code]) "\">"
+                          (html-escape (get-in c [:card :title])) "</card>")))
              "
</deck>")
         blob (js/Blob. (clj->js [xml]) #js {:type "application/download"})]
     (.createObjectURL js/URL blob)))


Floor divergence and deviation

Floor divergence and deviation

--- src/cljs/pack_builder/handlers.cljs
+++ src/cljs/pack_builder/handlers.cljs
@@ -32,8 +32,8 @@
   (let [capacity (total-capacity cells)]
     {:id (str (random-uuid))
      :total-capacity capacity
-     :divergence (- capacity average-capacity)
-     :deviation (standard-deviation cells)
+     :divergence (Math/floor (- capacity average-capacity))
+     :deviation (Math/floor (standard-deviation cells))
      :cells (sort-by :capacity > cells)}))

 (defn guess-next [solution]


Fixed badge embed iframe link url (REDMINE-126)

--- src/cljs/salava/badge/ui/embed.cljs
+++ src/cljs/salava/badge/ui/embed.cljs
@@ -4,8 +4,8 @@
             [salava.core.ui.layout :as layout]
             [salava.core.i18n :refer [t]]
             [reagent.session :as session]
+            [salava.core.helper :refer [dump]]
             [salava.core.ui.helper :refer [path-for]]))
-

 (defn error-view [state]
@@ -19,8 +19,8 @@
             [:div "The owner of the badge has set it private and therefore it can’t be shown."]]]]]])

 (defn success-view [state]
-  (let [{:keys [content permission]} @state
-        {:keys [id image_file name description issuer_content_name issuer_content_url recipients]} (first (filter  #(= (:language_code %) (:default_language_code %)) content))
+  (let [{:keys [id content permission]} @state
+        {:keys [image_file name description issuer_content_name issuer_content_url recipients]} (first (filter  #(= (:language_code %) (:default_language_code %)) content))
         url (str (session/get :site-url) (path-for (str "/badge/info/" id)))]
     [:div {:id "badge-gallery"}
      [:div {:id "grid"}
@@ -38,8 +38,6 @@
             name]]
           [:div.media-issuer
            issuer_content_name]
-
-
           [:div.media-description description]]]]
        [:div.media-bottom
         [:div {:class "pull-left"}
@@ -50,7 +48,6 @@
 (defn content [state]
   (let [{:keys [id permission]} @state
         url                     (str (session/get :site-url) (path-for (str "/badge/info/" id)))]
-
     (cond
       (= "success" permission) (success-view state)
       (= "error" permission)   (error-view state)
@@ -70,7 +67,7 @@

 (defn handler [site-navi params]
-  (let [id (:badge-id params)
+  (let [id (:badge-id params)
         state (atom {:permission "initial"}) ]
     (init-data state id)
     (fn []


Add comments for normalize-edges

Add comments for normalize-edges

--- src/com/puppetlabs/cmdb/catalog.clj
+++ src/com/puppetlabs/cmdb/catalog.clj
@@ -18,6 +18,10 @@
     (into #{} (apply concat parsed-edges))))

 (defn normalize-edges
+  "Turn vanilla edges in a catalog into properly split type/title resources.
+
+Turns {'source' 'Class[foo]' 'target' 'User[bar]'}
+into {'source' {'type' 'Class' 'title' 'foo'} 'target' {'type' 'User' 'title' 'bar'}}"
   [{:strs [edges] :as catalog}]
   (let [parse-edge   (fn [s]
                        (let [[[_ type title]] (re-seq #"(^.*)\[(.*)\]$" s)]