Align options vertically

Align options vertically

--- src/re_com/popover.cljs
+++ src/re_com/popover.cljs
@@ -223,21 +223,21 @@
     (or (some? clip-left) (some? clip-right) (some? clip-top) (some? clip-bottom))))        ;; Return boolean

 (def popover-border-args-desc
-  [{:name :children        :required true                        :type "vector"           :validate-fn sequential?       :description "a vector of component markups"}
-   {:name :position        :required true                        :type "keyword atom"     :validate-fn position?         :description [:span "relative to this anchor. One of " position-options-list]}
-   {:name :position-offset :required false                       :type "integer"          :validate-fn number?           :description [:span "px offset of the arrow from its default " [:code ":position"] " along the popover border. Is ignored when " [:code ":position"] " is one of the " [:code ":xxx-center"] " variants. Positive numbers slide the popover toward its center"]}
-   {:name :width           :required false                       :type "string"           :validate-fn string?           :description "a CSS style describing the popover width"}
-   {:name :height          :required false :default "auto"       :type "string"           :validate-fn string?           :description "a CSS style describing the popover height"}
-   {:name :popover-color   :required false :default "white"      :type "string"           :validate-fn string?           :description "fill color of the popover"}
-   {:name :arrow-length    :required false :default 11           :type "integer | string" :validate-fn number-or-string? :description "the length in pixels of the arrow (from pointy part to middle of arrow base)"}
-   {:name :arrow-width     :required false :default 22           :type "integer | string" :validate-fn number-or-string? :description "the width in pixels of arrow base"}
-   {:name :arrow-gap       :required false :default -1           :type "integer"          :validate-fn number?           :description "px gap between the anchor and the arrow tip. Positive numbers push the popover away from the anchor"}
-   {:name :padding         :required false                       :type "string"           :validate-fn string?           :description "a CSS style which overrides the inner padding of the popover"}
-   {:name :margin-left     :required false                       :type "string"           :validate-fn string?           :description "a CSS style describing the horiztonal offset from anchor after position"}
-   {:name :margin-top      :required false                       :type "string"           :validate-fn string?           :description "a CSS style describing the vertical offset from anchor after position"}
-   {:name :tooltip-style?  :required false :default false        :type "boolean"                                         :description "setup popover styles for a tooltip"}
-   {:name :title           :required false                       :type "string | markup"                                 :description "describes a title"}
-   {:name :popover-border-color :required false                  :type "string"           :validate-fn string?           :description "color of the popover arrow stroke"}])
+  [{:name :children             :required true                        :type "vector"           :validate-fn sequential?       :description "a vector of component markups"}
+   {:name :position             :required true                        :type "keyword atom"     :validate-fn position?         :description [:span "relative to this anchor. One of " position-options-list]}
+   {:name :position-offset      :required false                       :type "integer"          :validate-fn number?           :description [:span "px offset of the arrow from its default " [:code ":position"] " along the popover border. Is ignored when " [:code ":position"] " is one of the " [:code ":xxx-center"] " variants. Positive numbers slide the popover toward its center"]}
+   {:name :width                :required false                       :type "string"           :validate-fn string?           :description "a CSS style describing the popover width"}
+   {:name :height               :required false :default "auto"       :type "string"           :validate-fn string?           :description "a CSS style describing the popover height"}
+   {:name :popover-color        :required false :default "white"      :type "string"           :validate-fn string?           :description "fill color of the popover"}
+   {:name :arrow-length         :required false :default 11           :type "integer | string" :validate-fn number-or-string? :description "the length in pixels of the arrow (from pointy part to middle of arrow base)"}
+   {:name :arrow-width          :required false :default 22           :type "integer | string" :validate-fn number-or-string? :description "the width in pixels of arrow base"}
+   {:name :arrow-gap            :required false :default -1           :type "integer"          :validate-fn number?           :description "px gap between the anchor and the arrow tip. Positive numbers push the popover away from the anchor"}
+   {:name :padding              :required false                       :type "string"           :validate-fn string?           :description "a CSS style which overrides the inner padding of the popover"}
+   {:name :margin-left          :required false                       :type "string"           :validate-fn string?           :description "a CSS style describing the horiztonal offset from anchor after position"}
+   {:name :margin-top           :required false                       :type "string"           :validate-fn string?           :description "a CSS style describing the vertical offset from anchor after position"}
+   {:name :tooltip-style?       :required false :default false        :type "boolean"                                         :description "setup popover styles for a tooltip"}
+   {:name :title                :required false                       :type "string | markup"                                 :description "describes a title"}
+   {:name :popover-border-color :required false                       :type "string"           :validate-fn string?           :description "color of the popover arrow stroke"}])

 (defn popover-border
   "Renders an element or control along with a Bootstrap popover"
@@ -324,27 +324,27 @@
 ;;--------------------------------------------------------------------------------------------------

 (def popover-content-wrapper-args-desc
-  [{:name :showing-injected? :required true                         :type "boolean atom"                                    :description [:span "an atom. When the value is true, the popover shows." [:br] [:strong "NOTE: "] "When used as direct " [:code ":popover"] " arg in popover-anchor-wrapper, this arg will be injected automatically by popover-anchor-wrapper. If using your own popover function, you must add this yourself"]}
-   {:name :position-injected :required true                         :type "keyword atom"     :validate-fn position?         :description [:span "relative to this anchor. One of " position-options-list [:br] [:strong "NOTE: "] "See above NOTE for " [:code ":showing-injected?"] ". Same applies" ]}
-   {:name :position-offset   :required false                        :type "integer"          :validate-fn number?           :description [:span "px offset of the arrow from its default " [:code ":position"] " along the popover border. Is ignored when " [:code ":position"] " is one of the " [:code ":xxx-center"] " variants. Positive numbers slide the popover toward its center"]}
-   {:name :no-clip?          :required false  :default false        :type "boolean"                                         :description "when an anchor is in a scrolling region (e.g. scroller component), the popover can sometimes be clipped. By passing true for this parameter, re-com will use a different CSS method to show the popover. This method is slightly inferior because the popover can't track the anchor if it is repositioned"}
-   {:name :width             :required false                        :type "string"           :validate-fn string?           :description "a CSS style representing the popover width"}
-   {:name :height            :required false                        :type "string"           :validate-fn string?           :description "a CSS style representing the popover height"}
-   {:name :backdrop-opacity  :required false  :default 0.0          :type "double | string"  :validate-fn number-or-string? :description "indicates the opacity of the backdrop where 0.0=transparent, 1.0=opaque"}
-   {:name :on-cancel         :required false                        :type "-> nil"           :validate-fn fn?               :description "a function which takes no params and returns nothing. Called when the popover is cancelled (e.g. user clicks away)"}
-   {:name :title             :required false                        :type "string | hiccup"  :validate-fn string-or-hiccup? :description "describes the title of the popover. The default font size is 18px to make it stand out"}
-   {:name :close-button?     :required false  :default true         :type "boolean"                                         :description "when true, displays the close button"}
-   {:name :body              :required false                        :type "string | hiccup"  :validate-fn string-or-hiccup? :description "describes the popover body. Must be a single component"}
-   {:name :tooltip-style?    :required false  :default false        :type "boolean"                                         :description "setup popover styles for a tooltip"}
-   {:name :popover-color     :required false  :default "white"      :type "string"           :validate-fn string?           :description "fill color of the popover"}
-   {:name :popover-border-color :required false                     :type "string"           :validate-fn string?           :description "color of the popover arrow stroke"}
-   {:name :arrow-length      :required false  :default 11           :type "integer | string" :validate-fn number-or-string? :description "the length in pixels of the arrow (from pointy part to middle of arrow base)"}
-   {:name :arrow-width       :required false  :default 22           :type "integer | string" :validate-fn number-or-string? :description "the width in pixels of arrow base"}
-   {:name :arrow-gap         :required false  :default -1           :type "integer"          :validate-fn number?           :description "px gap between the anchor and the arrow tip. Positive numbers push the popover away from the anchor"}
-   {:name :padding           :required false                        :type "string"           :validate-fn string?           :description "a CSS style which overrides the inner padding of the popover"}
-   {:name :class             :required false                        :type "string"           :validate-fn string?           :description "CSS class names, space separated (applies to the outer container)"}
-   {:name :style             :required false                        :type "CSS style map"    :validate-fn css-style?        :description "override component style(s) with a style map, only use in case of emergency (applies to the outer container)"}
-   {:name :attr              :required false                        :type "HTML attr map"    :validate-fn html-attr?        :description [:span "HTML attributes, like " [:code ":on-mouse-move"] [:br] "No " [:code ":class"] " or " [:code ":style"] "allowed (applies to the outer container)"]}])
+  [{:name :showing-injected?    :required true                         :type "boolean atom"                                    :description [:span "an atom. When the value is true, the popover shows." [:br] [:strong "NOTE: "] "When used as direct " [:code ":popover"] " arg in popover-anchor-wrapper, this arg will be injected automatically by popover-anchor-wrapper. If using your own popover function, you must add this yourself"]}
+   {:name :position-injected    :required true                         :type "keyword atom"     :validate-fn position?         :description [:span "relative to this anchor. One of " position-options-list [:br] [:strong "NOTE: "] "See above NOTE for " [:code ":showing-injected?"] ". Same applies" ]}
+   {:name :position-offset      :required false                        :type "integer"          :validate-fn number?           :description [:span "px offset of the arrow from its default " [:code ":position"] " along the popover border. Is ignored when " [:code ":position"] " is one of the " [:code ":xxx-center"] " variants. Positive numbers slide the popover toward its center"]}
+   {:name :no-clip?             :required false  :default false        :type "boolean"                                         :description "when an anchor is in a scrolling region (e.g. scroller component), the popover can sometimes be clipped. By passing true for this parameter, re-com will use a different CSS method to show the popover. This method is slightly inferior because the popover can't track the anchor if it is repositioned"}
+   {:name :width                :required false                        :type "string"           :validate-fn string?           :description "a CSS style representing the popover width"}
+   {:name :height               :required false                        :type "string"           :validate-fn string?           :description "a CSS style representing the popover height"}
+   {:name :backdrop-opacity     :required false  :default 0.0          :type "double | string"  :validate-fn number-or-string? :description "indicates the opacity of the backdrop where 0.0=transparent, 1.0=opaque"}
+   {:name :on-cancel            :required false                        :type "-> nil"           :validate-fn fn?               :description "a function which takes no params and returns nothing. Called when the popover is cancelled (e.g. user clicks away)"}
+   {:name :title                :required false                        :type "string | hiccup"  :validate-fn string-or-hiccup? :description "describes the title of the popover. The default font size is 18px to make it stand out"}
+   {:name :close-button?        :required false  :default true         :type "boolean"                                         :description "when true, displays the close button"}
+   {:name :body                 :required false                        :type "string | hiccup"  :validate-fn string-or-hiccup? :description "describes the popover body. Must be a single component"}
+   {:name :tooltip-style?       :required false  :default false        :type "boolean"                                         :description "setup popover styles for a tooltip"}
+   {:name :popover-color        :required false  :default "white"      :type "string"           :validate-fn string?           :description "fill color of the popover"}
+   {:name :popover-border-color :required false                        :type "string"           :validate-fn string?           :description "color of the popover arrow stroke"}
+   {:name :arrow-length         :required false  :default 11           :type "integer | string" :validate-fn number-or-string? :description "the length in pixels of the arrow (from pointy part to middle of arrow base)"}
+   {:name :arrow-width          :required false  :default 22           :type "integer | string" :validate-fn number-or-string? :description "the width in pixels of arrow base"}
+   {:name :arrow-gap            :required false  :default -1           :type "integer"          :validate-fn number?           :description "px gap between the anchor and the arrow tip. Positive numbers push the popover away from the anchor"}
+   {:name :padding              :required false                        :type "string"           :validate-fn string?           :description "a CSS style which overrides the inner padding of the popover"}
+   {:name :class                :required false                        :type "string"           :validate-fn string?           :description "CSS class names, space separated (applies to the outer container)"}
+   {:name :style                :required false                        :type "CSS style map"    :validate-fn css-style?        :description "override component style(s) with a style map, only use in case of emergency (applies to the outer container)"}
+   {:name :attr                 :required false                        :type "HTML attr map"    :validate-fn html-attr?        :description [:span "HTML attributes, like " [:code ":on-mouse-move"] [:br] "No " [:code ":class"] " or " [:code ":style"] "allowed (applies to the outer container)"]}])

 (defn popover-content-wrapper
   "Abstracts several components to handle the 90% of cases for general popovers and dialog boxes"
@@ -393,23 +393,23 @@
              :opacity  backdrop-opacity
              :on-click on-cancel])
           [popover-border
-           :position        position-injected
-           :position-offset position-offset
-           :width           width
-           :height          height
-           :tooltip-style?  tooltip-style?
-           :popover-color   popover-color
+           :position             position-injected
+           :position-offset      position-offset
+           :width                width
+           :height               height
+           :tooltip-style?       tooltip-style?
+           :popover-color        popover-color
            :popover-border-color popover-border-color
-           :arrow-length    arrow-length
-           :arrow-width     arrow-width
-           :arrow-gap       arrow-gap
-           :padding         padding
-           :title           (when title [popover-title
-                                         :title          title
-                                         :showing?       showing-injected?
-                                         :close-button?  close-button?
-                                         :close-callback on-cancel])
-           :children        [body]]])})))
+           :arrow-length         arrow-length
+           :arrow-width          arrow-width
+           :arrow-gap            arrow-gap
+           :padding              padding
+           :title                (when title [popover-title
+                                             :title          title
+                                             :showing?       showing-injected?
+                                             :close-button?  close-button?
+                                             :close-callback on-cancel])
+           :children             [body]]])})))

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


Log cleanup

Log cleanup

--- libs/datreactor/src/dat/reactor.cljc
+++ libs/datreactor/src/dat/reactor.cljc
@@ -47,7 +47,6 @@
   presently, errors do not bubble up. The last successful state of the db will be returned. Errors will be passed
   through to the :datview/error."
   ([app db events {:as options :keys [datview.resolver/catch?]}]
-   (log/info "Calling resolve-to with messages:" events)
    (reduce
      (fn [db' event]
        ;; Handles all the expanded events and at the very end ends up transacting the final state
@@ -178,7 +177,6 @@
                                      pre-middleware))
          middleware-fn (apply comp middleware-fns)
          effect-fn (middleware-fn effect-fn)]
-     (log/info "Registering effect" effect-id)
      (defmethod execute-effect! effect-id
        [app db effect]
        (try
@@ -252,7 +250,7 @@
       (try
         (let [event (async/<! event-chan)
               final-meta (atom nil)]
-          (log/debug "Reactor recieved event:" event)
+          ;(log/debug "Reactor recieved event:" event)
           (swap!
             conn
             (fn [current-db]


Cleanup

Cleanup

--- src/clj/mokkameister/resources/button.clj
+++ src/clj/mokkameister/resources/button.clj
@@ -8,12 +8,11 @@
     (= token (system :button-token))))

 (defn- handle-button-post [ctx]
-  ;; Just produce a faux slack /coffee event map for now..
-  (let [event {:channel "#penthouse"
-               :slack-user "nokon"
-               :brew-time 5
-               :coffee-type :regular}]
-    (start-brewing! event))
+  (let [brew {:channel "#penthouse"
+              :slack-user "nokon"
+              :brew-time 5
+              :coffee-type :regular}]
+    (start-brewing! brew))
   "OK")

 (defresource coffee-button


more cards implementation

more cards implementation

--- src/node/game/cards.cljs
+++ src/node/game/cards.cljs
@@ -31,6 +31,10 @@
    "Borrowed Satellite"
    {:effect (effect (gain :link 1 :max-hand-size 1))
     :leave-play (effect (lose :link 1 :max-hand-size 1))}
+
+   "BOX-E"
+   {:effect (effect (gain :memory 2 :max-hand-size 2))
+    :leave-play (effect (lose :memory 2 :max-hand-size 2))}

    "Calling in Favors"
    {:effect (effect (gain :credit (count (filter (fn [c] (has? c :subtype "Connection"))
@@ -65,6 +69,9 @@

    "Diesel"
    {:effect (effect (draw 3))}
+
+   "Duggar’s"
+   {:abilities [{:cost [:click 4] :effect (effect (draw 10)) :msg "draw 10 cards"}]}

    "Dyson Mem Chip"
    {:effect (effect (gain :link 1 :memory 1)) :leave-play (effect (lose :link 1 :memory 1))}


Open a new window for sign-in flow (#454)

https://broadinstitute.atlassian.net/browse/GAWB-764

--- src/cljs/org/broadinstitute/firecloud_ui/main.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/main.cljs
@@ -252,14 +252,40 @@
       [:div {}
        [comps/Button
         {:text "Sign In"
-         :href (str (config/api-url-root) "/login?callback="
-                    (js/encodeURIComponent
-                     (str js/window.location.protocol "//" js/window.location.hostname))
-                    (let [hash (nav/get-hash-value)]
-                      (if (clojure.string/blank? hash) "" (str "&path=" hash))))}]]
+         :onClick (fn [e]
+                    (.. js/window
+                        (open
+                         (str (config/api-url-root) "/login?callback="
+                              (js/encodeURIComponent (.. js/window -location -origin)))
+                         "Authentication"
+                         "menubar=no,toolbar=no,width=500,height=500")))}]]
       [:div {:style {:marginTop "1em"}} [RegisterLink]]
       [:div {:style {:maxWidth 600 :paddingTop "2em" :fontSize "small"}}
-        [Policy]]])})
+        [Policy]]])
+   :component-did-mount
+   (fn [{:keys [props]}]
+     (aset js/window (name ::handle-auth-message)
+           (fn [message] ((:on-login props) (get message "access_token")))))
+   :component-will-unmount
+   (fn [{:keys [locals]}]
+     (js-delete js/window (name ::handle-auth-message)))})
+
+
+(defn- parse-hash-into-map []
+  ;; Transforms the browser navigation hash into a map to make it easier to pass around. Technique
+  ;; stolen from Swagger's authentication flow.
+  (let [hash (nav/get-hash-value)
+        hash (clojure.string/replace hash #"^[?]" "")
+        parts (clojure.string/split hash #"[&=]")
+        parts (map js/decodeURIComponent parts)]
+    (apply assoc {} parts)))
+
+
+(defn- attempt-auth [token on-done]
+  ;; Use basic ajax call here to bypass default ajax-orch failure behavior.
+  (utils/ajax {:url (str (config/api-url-root) "/me")
+               :headers {"Authorization" (str "Bearer " token)}
+               :on-done on-done}))

 (defn- server-unavailable-dialog [dismiss]
@@ -285,7 +311,7 @@
    (fn []
      {:root-nav-context (nav/create-nav-context)})
    :render
-   (fn [{:keys [state]}]
+   (fn [{:keys [this state]}]
      [:div {}
       (when (:show-server-down-message? @state)
         (server-unavailable-dialog #(swap! state dissoc :show-server-down-message?)))
@@ -330,7 +356,7 @@
           (= :logged-in (:user-status @state))
           [LoggedIn {:nav-context (:root-nav-context @state)}]
           (= :not-logged-in (:user-status @state))
-          [LoggedOut])]]
+          [LoggedOut {:on-login #(react/call :authenticate-with-fresh-token this %)}])]]
       (footer)])
    :component-did-mount
    (fn [{:keys [this state]}]
@@ -358,31 +384,14 @@
                                (swap! state assoc :config-status :error)))}))
    :authenticate-user
    (fn [{:keys [this state]}]
-     (let [hash (nav/get-hash-value)
-           at-index (utils/str-index-of hash "?access_token=")
-           [_ token] (when-not (neg? at-index) (clojure.string/split (subs hash at-index) #"="))
-           attempt-auth (fn [token on-done]
-                          ;; Use basic ajax call here to bypass default ajax-orch failure behavior.
-                          (utils/ajax {:url (str (config/api-url-root) "/me")
-                                       :headers {"Authorization" (str "Bearer " token)}
-                                       :on-done on-done}))]
-       (if-not (neg? at-index)
-         (do
-           ;; New access token. Attempt to authenticate with it.
-           (.replace (.-location js/window) (str "#" (subs hash 0 at-index)))
-           (attempt-auth token (fn [{:keys [success? status-code]}]
-                                 (cond
-                                   (= 401 status-code)
-                                   (swap! state assoc :user-status :auth-failure)
-                                   (= 403 status-code)
-                                   (do (utils/set-access-token-cookie token)
-                                       (swap! state assoc :user-status :not-activated))
-                                   ;; 404 just means not registered
-                                   (or success? (= status-code 404))
-                                   (do (utils/set-access-token-cookie token)
-                                       (react/call :handle-successful-auth this token))
-                                   :else
-                                   (swap! state assoc :user-status :error)))))
+     (if-let [parent (.-opener js/window)]
+       ;; This window was used for login. Send the token to the parent. No need to render the UI.
+       (do
+         ((aget parent (name ::handle-auth-message)) (parse-hash-into-map))
+         (.close js/window))
+       (if-let [token (get (parse-hash-into-map) "access_token")]
+         ;; New access token. Attempt to authenticate with it.
+         (react/call :authenticate-with-fresh-token this token)
          (let [token (utils/get-access-token-cookie)]
            (if token
              (attempt-auth token (fn [{:keys [success? status-code]}]
@@ -398,6 +407,21 @@
                                      :else
                                      (swap! state assoc :user-status :error))))
              (swap! state assoc :user-status :not-logged-in))))))
+   :authenticate-with-fresh-token
+   (fn [{:keys [this state]} token]
+     (attempt-auth token (fn [{:keys [success? status-code]}]
+                           (cond
+                             (= 401 status-code)
+                             (swap! state assoc :user-status :auth-failure)
+                             (= 403 status-code)
+                             (do (utils/set-access-token-cookie token)
+                               (swap! state assoc :user-status :not-activated))
+                             ;; 404 just means not registered
+                             (or success? (= status-code 404))
+                             (do (utils/set-access-token-cookie token)
+                               (react/call :handle-successful-auth this token))
+                             :else
+                             (swap! state assoc :user-status :error)))))
    :handle-successful-auth
    (fn [{:keys [this state locals]} token]
      (reset! utils/access-token token)


retaining order in results

retaining order in results

--- src/ophion/aggregate.clj
+++ src/ophion/aggregate.clj
@@ -169,7 +169,7 @@
 (defn group-count
   [path]
   [{:$group {:_id (dollar path) :count {:$sum 1}}}
-   {:$project {:key "$_id" :count "$count"}}])
+   {:$project {(name path) "$_id" :count "$count"}}])

 (defn unwind
   [label]
@@ -256,9 +256,9 @@
        {:input dollar
         :as "index"
         :in
-        {:k "$$index._id"
-         :v "$$index.count"}}}
-      {:$arrayToObject dollar}]]))
+        {(keyword outer) "$$index._id"
+         :count "$$index.count"}}}
+      dollar]]))

 (defn render-percentile
   [outer percentiles]
@@ -293,8 +293,13 @@
             {:$divide
              [dollar interval]}}]}
          :count {:$sum 1}}}
-       {:$sort {"_id" -1}}]
-      dollar
+       {:$sort {"_id" 1}}]
+      {:$map
+       {:input dollar
+        :as "index"
+        :in
+        {(keyword outer) "$$index._id"
+         :count "$$index.count"}}}
       dollar]]))

 (defn render-aggregate


Fix bug in node-map-controls* - correctly idify names-busses.

--- src/overtone/sc/node.clj
+++ src/overtone/sc/node.clj
@@ -429,8 +429,9 @@
   [node names-busses]
   (ensure-connected!)
   (ensure-node-active! node "Attempting to map the controls of a node that has been destroyed.")
+
   (let [node-id      (to-sc-id node)
-        names-busses (map idify (stringify names-busses))]
+        names-busses (-> names-busses stringify idify)]
     (apply snd "/n_map" node-id names-busses))
   node)


Implemented kernel thread safety. Now every vector has its own kernel instances.

--- src/clojure/uncomplicate/neanderthal/opencl.clj
+++ src/clojure/uncomplicate/neanderthal/opencl.clj
@@ -21,7 +21,9 @@
 (deftype FloatCLVector [cl-buf linear-work-size queue swp-kernel]
   Releaseable
   (release [_]
-    (release cl-buf))
+    (and
+      (release cl-buf)
+      (release swp-kernel)))
   Mappable
   (read! [_ host]
     (enq-read! queue cl-buf (.buf ^FloatBlockVector host)))
@@ -36,21 +38,20 @@
         (enq-nd! queue swp-kernel linear-work-size)
         x)))

-(defrecord CLSettings [^long max-local-size queue prog swp-kernel]
+(defrecord CLSettings [^long max-local-size queue prog]
   Releaseable
   (release [_]
-    (do
-      (release prog)
-      (release swp-kernel))))
+    (release prog)))

 (defn cl-settings [queue]
   (let [prog (build-program! (program-with-source [(slurp "resources/opencl/blas.cl")]))
         max-local-size (max-work-group-size (queue-device queue))]
-    (->CLSettings max-local-size queue prog (kernel prog "swp_kernel"))))
+    (->CLSettings max-local-size queue prog)))

 (defn cl-fv [^CLSettings settings ^long size]
-  (let [cl-buf (cl-buffer (* size Float/BYTES))]
+  (let [cl-buf (cl-buffer (* size Float/BYTES))
+        prog (.prog settings)]
     (->FloatCLVector cl-buf
                      (work-size [size] [(min size (.max-local-size settings))])
                      (.queue settings)
-                     (.swp-kernel settings))))
+                     (kernel prog "swp_kernel"))))


Concatenate buffers using the channel count from the input buffers

--- src/devcards/audio_utils/devcards/mp3_encoder.cljs
+++ src/devcards/audio_utils/devcards/mp3_encoder.cljs
@@ -4,6 +4,8 @@
   (:require [cljs.core.async :refer [<! timeout]]
             [devcards.core :refer-macros [defcard defcard-doc]]
             [sablono.core :refer-macros [html]]
+            [audio-utils.util :refer [amplify]]
+            [audio-utils.viz :refer [sine-wave]]
             [audio-utils.web-audio :as a]
             [audio-utils.worker :as w]))

@@ -67,8 +69,9 @@
 (defn concat-buffers
   [ctx buffers]
   (let [total-length (transduce (map #(.-length %)) + 0 buffers)
-        buffer (a/create-buffer ctx 2 total-length
-                                (.-sampleRate ctx))]
+        n-channels   (.-numberOfChannels (first buffers))
+        buffer       (a/create-buffer ctx n-channels total-length
+                                      (.-sampleRate ctx))]
     (reduce (fn [length-so-far buf]
               (doseq [channel (range 0 (.-numberOfChannels buffer))]
                 (let [in-chan  (.getChannelData buf channel)


Fix onkeydown event handler so it can always update

--- src/tile_game/grid.cljs
+++ src/tile_game/grid.cljs
@@ -67,10 +67,8 @@
     (slide! direction)))

 (defn init []
-  ;; Warning: changes here require a page refresh to take effect
-  ;; Is it possible to attach page keydown event so that reagent can rebind?
-  (.addEventListener js/document "keydown" handle-keydown)
+  ;; Rebind onkeydown with set! so figwheel can always update
+  (set! (.-onkeydown js/window) handle-keydown)
   (r/render-component [tile-grid] (. js/document (getElementById "grid"))))

-(defonce start
-  (init))
+(init)


Translate each grid tile and then position text with styles

--- src/tile_game/grid.cljs
+++ src/tile_game/grid.cljs
@@ -48,10 +48,13 @@
 (defn render-tile [[x y] tile command]
   (when (pos? tile)
     (let [fill-color (nth colors tile)]
-      [:g {:key (str "tile-" tile) :on-click #(async/put! command tile)}
-       [:rect {:x (+ x 0.05) :y (+ y 0.05) :width 0.9 :height 0.9 :fill fill-color}]
-       [:text {:x (+ 0.5 x) :y (+ 0.65 y)
-               :font-family "Verdana" :font-size 0.4 :text-anchor "middle"}
+      [:g {:transform (str "translate(" x "," y ")")
+           :key (str "tile-" tile)
+           :on-click #(async/put! command tile)}
+       [:rect {:x 0.05 :y 0.05 :width 0.9 :height 0.9 :fill fill-color}]
+       [:text {:x 0.5 :y 0.5
+               :style {:dominant-baseline "central" :text-anchor "middle"
+                       :font-family "Verdana" :font-size 0.4}}
         (str tile)]])))

 (defn render-board [board dim command]


Fix tests

Fix tests

--- src/atom_finder/classifier_util.clj
+++ src/atom_finder/classifier_util.clj
@@ -210,13 +210,12 @@
     (not (contained-by-line-range? node start-line end-line))
     (every? #(contained-by-line-range? % start-line end-line) (children node))))

+; TODO this is untested, also it should probably use binary search for efficiency
 (s/defn line-range-parent [node :- IASTNode start-line :- s/Int end-line :- s/Int]
-  ;(pprn [start-line end-line])
   (if (= start-line end-line)
     nil
-    (let [kids      (children root)
-          container (find-first #(contains-offset? % offset) kids)]
+    (let [kids      (children node)
+          container (find-first #(line-range-parent? % start-line end-line) kids)]
       (if (nil? container)
-        root
-        (recur container offset))))
-    ))
+        node
+        (recur container start-line end-line)))))


Solved 6.4, translated fpins variants, my solution is incomplete in sense fpins variant give last rng as outcome as well whereas mine returns just numbers as I've used unfold

--- src/fpinscala/purely_functional_state.clj
+++ src/fpinscala/purely_functional_state.clj
@@ -1,4 +1,5 @@
-(ns fpinscala.purely-functional-state)
+(ns fpinscala.purely-functional-state
+  (:use [fpinscala.strictness-and-laziness :only [unfold-fpins take-via-unfold]]))

 (declare simple-rng)

@@ -90,3 +91,37 @@
 ;fpins
 ;well conceptually all the same stuff with difference I've introduced
 ;macro (for fun and exercise :) )
+;-----------------------------------------------------------------------
+
+;6.4
+;mine
+(defn random-ints
+  "Generates list of random integers"
+  [n rng]
+  (take-via-unfold n (unfold-fpins
+                       (rng)
+                       (fn [nstate]
+                         (from-rng nstate :let [n nxt-rng]
+                                   [n (nxt-rng)])))))
+;fpins
+;I've used unfold, whereas fpins is using plain recursion
+;and my solution does not return last rng so my solution is only partial :|
+(defn random-ints-fpins-1
+  "Generates list of random integers - fpins variant 1"
+  [n rng]
+  (if (zero? n)
+    ['() rng]
+    (from-rng (rng) :let [x r1]
+              (let [[xs, r2] (random-ints-fpins-1 (dec n) r1)]
+                [(cons x xs) r2]))))
+
+(defn random-ints-fpins-2
+  "Generates list of random integers - fpins variant 2 - TAIL RECURSIVE - outcome is reversed though but apparently it does not matter"
+  [n rng]
+  (letfn [(go [cnt r xs]
+              (if (zero? cnt)
+                [xs r]
+                (from-rng (r) :let [x r2]
+                          (go (dec cnt) r2 (cons x xs)))))]
+    (go n rng '())))
+;-----------------------------------------------------------------------


Solved 5.15 and translated hasSubsequence

--- src/fpinscala/strictness_and_laziness.clj
+++ src/fpinscala/strictness_and_laziness.clj
@@ -52,7 +52,7 @@
 ;fpins
 ;take - conceptually similar
 ;drop - better than mine, preserves lazyness
-(defn my-drop-fpins [x s]
+(defn drop-fpins [x s]
   (if (seq s)
     (if (> x 0)
       (recur (dec x) (rest s))
@@ -356,3 +356,26 @@
 ;FPINS variant is also more correct(?, mathematically?)
 ;given subsequence is empty it returns true, while mine not

+;5.15
+(defn tails
+  "Tails function"
+  [s]
+  (unfold-fpins s #(let [[h & t] %]
+                    (when h
+                      [% t]))))
+;my solution does not contain "empty stream" at the end as required in FPINS
+(defn tails-fpins
+  "Tails function - fpins translation"
+  [s]
+  (unfold-fpins s #(if (empty? %)
+                    nil
+                    [% (drop-fpins 1 %)])))
+;well given that Clojure does not have "option" and treats nil as falsey then
+;neither fpins translation yielded "empty" stream at the end
+;nevertheless this works properly - Clojure way :)
+
+;has-subsequence
+(defn has-subsequence
+  "Translation of hasSubsequence after exercise 5.15"
+  [s sub]
+  (exists #(do (println %) (starts-with-fpins % sub)) (tails s)))


Added total number text to pagination bar, changed background color

--- src/cljs/org/broadinstitute/firecloud_ui/common/table.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/common/table.cljs
@@ -32,19 +32,20 @@
    (fn [{:keys [props state refs]}]
      (let [rows-per-page (:rows-per-page @state)
            current-page (:current-page @state)
-           num-total (:num-rows props)
-           num-pages (js/Math.ceil (/ num-total rows-per-page))
-           num-onClick (fn [n] #(swap! state assoc :current-page n))
-           page-range (create-page-range current-page num-pages)
+           num-rows-visible (:num-rows-visible props)
+           num-pages (js/Math.ceil (/ num-rows-visible rows-per-page))
            allow-prev (> current-page 1)
            allow-next (< current-page num-pages)
-           right-num (min num-total (* current-page rows-per-page))
+           right-num (min num-rows-visible (* current-page rows-per-page))
            left-num (if (zero? right-num) 0 (inc (* (dec current-page) rows-per-page)))]
        [:div {:style {:border "1px solid #ebebeb" :boxShadow "-3px -6px 23px -7px #ebebeb inset"}}
         [:div {:style {:fontSize 13 :lineHeight 1.5 :padding "0px 48px" :verticalAlign "middle"}}

-         [:div {:style {:float "left" :display "inline-block" :width "33.33%" :padding "2.15em 0em" :verticalAlign "middle"}}
-          [:b {} (str left-num " - " right-num)] (str " of " (pluralize num-total " result"))]
+         [:div {:style {:float "left" :display "inline-block" :width "33.33%" :padding "2.15em 0em"
+                        :verticalAlign "middle"}}
+          [:b {} (str left-num " - " right-num)] (str " of " (pluralize num-rows-visible " result")
+                                                   (when-not (= num-rows-visible (:num-total-rows props))
+                                                     (str " (filtered from " (:num-total-rows props) " total)")))]

          (style/create-unselectable :div {:style {:float "left" :display "inline-block" :width "33.33%"
                                                   :padding "1.6em 0em" :verticalAlign "middle" :textAlign "center"}}
@@ -63,9 +64,9 @@
                                     :color (if selected? "white" (:button-blue style/colors))
                                     :borderRadius (when selected? "100%")
                                     :cursor (when-not selected? "pointer")}
-                            :onClick (when-not selected? (num-onClick n))}
+                            :onClick (when-not selected? #(swap! state assoc :current-page n))}
                       n]))
-              page-range)]
+              (create-page-range current-page num-pages))]

            [:div {:style {:display "inline-block" :padding "0.55em 0.9em"
                           :color (if allow-next (:button-blue style/colors) (:border-gray style/colors))
@@ -189,7 +190,7 @@
    (fn [{:keys [state this]}]
      [:span {}
       (style/create-text-field {:ref "filter-field" :placeholder "Filter"
-                                :style {:backgroundColor (if (:synced @state) "#fff" (:background-gray style/colors))}
+                                :style {:backgroundColor (if (:synced @state) "#fff" (:tag-background style/colors))}
                                 :onKeyDown (common/create-key-handler
                                              [:enter] #(react/call :apply-filter this))
                                 :onChange #(swap! state assoc :initial false :synced false)})
@@ -225,7 +226,8 @@
      (let [paginator-above (= :above (:paginator props))
            paginator-below (= :below (:paginator props))
            paginator [Paginator {:ref "paginator"
-                                 :num-rows (count (:filtered-data @state))
+                                 :num-rows-visible (count (:filtered-data @state))
+                                 :num-total-rows (count (:data props))
                                  :onChange #(react/call :handle-pagination-change this)}]]
        [:div {}
         (when (:filterable? props)
@@ -238,14 +240,13 @@
                         :cursor (when (:dragging? @state) "col-resize")}
                 :onMouseMove (fn [e]
                                (when (:dragging? @state)
-                                 (let [widths (:column-widths @state)
-                                       current-width (nth widths (:drag-column @state))
+                                 (let [current-width (nth (:column-widths @state) (:drag-column @state))
                                        new-mouse-x (.-clientX e)
                                        drag-amount (- new-mouse-x (:mouse-x @state))
                                        new-width (+ current-width drag-amount)]
-                                   (when (>= new-width 10)
+                                   (when (and (>= new-width 10) (not (zero? drag-amount)))
                                      (swap! state update-in [:column-widths]
-                                       assoc (:drag-column @state) (+ current-width drag-amount))
+                                       assoc (:drag-column @state) new-width)
                                      (swap! state assoc :mouse-x new-mouse-x)))))
                 :onMouseUp #(swap! state assoc :dragging? false)}
           (render-header state props)


Created the zmqserver test related to link deletion.

--- src/clojure/test/leela/blackbox/network/zmqserver_test.clj
+++ src/clojure/test/leela/blackbox/network/zmqserver_test.clj
@@ -70,12 +70,20 @@
       (server/handle-message cluster ["put" "label" "0x03" "foobar"])
       (is (= (server/msg-label ["foobar"]) (server/handle-message cluster ["get" "label" "ext" "0x03" "foobar"]))))

+    (testing "dellink with no data"
+      (is (= (server/msg-done) (server/handle-message cluster ["del" "link" "0x00" "0x"]))))
+
+    (testing "dellink after putlink"
+      (server/handle-message cluster ["put" "link" "0x00" "0x01" "0x02" "0x03"])
+      (is (= (server/msg-done) (server/handle-message cluster ["del" "link" "0x00" "0x01" "0x02" "0x03"])))
+      (is (= (server/msg-link []) (server/handle-message cluster ["get" "link" "0x00"]))))
+
     (testing "getlink with no data"
-      (is (= (server/msg-fail 404)) (server/handle-message cluster ["get" "link" "0x00" "0x"])))
+      (is (= (server/msg-link []) (server/handle-message cluster ["get" "link" "0x00" "0x"]))))

     (testing "getlink after putlink"
       (server/handle-message cluster ["put" "link" "0x00" "0x01" "0x02" "0x03"])
-      (is (= (server/msg-link ["0x01" "0x02" "0x03"])) (server/handle-message cluster ["get" "link" "0x00" "0x"])))
+      (is (= (server/msg-link ["0x01" "0x02" "0x03"]) (server/handle-message cluster ["get" "link" "0x00" "0x"]))))

     (testing "getlink pagination"
       (server/handle-message cluster ["put" "link" "0x00" "0x01" "0x02" "0x03"])


Fix issue with Ubuntu EC2 mirror down by adding another mirror.

--- src/circle/backend/nodes/circle.clj
+++ src/circle/backend/nodes/circle.clj
@@ -18,7 +18,7 @@

 (def circle-group
   (pallet.core/group-spec
-   "CircleCI box"
+   "circle"
    :node-spec (pallet.core/node-spec
                :hardware {:hardware-id "m1.small"} ;; require m1.small or larger right now, because of https://bugs.launchpad.net/ubuntu/+source/linux-ec2/+bug/634487
                :image {:os-family :ubuntu
@@ -28,7 +28,18 @@
    :phases {:bootstrap (pallet.phase/phase-fn
                         (automated-admin-user/automated-admin-user))
             :configure (pallet.phase/phase-fn
-                        (java/java :openjdk)
+                        (package/package-source "ubuntu-archive"
+                                                ;; by default, EC2
+                                                ;; ubuntu images only
+                                                ;; use ubuntu mirrors
+                                                ;; hosted on EC2,
+                                                ;; which sometimes go
+                                                ;; down. Add this as
+                                                ;; another mirror for
+                                                ;; reliability
+                                                :aptitude {:url "http://us.archive.ubuntu.com/ubuntu/"
+                                                           :scopes ["main" "natty-updates" "universe" "multiverse"]}) ;; TODO the natty is specific to 11.04, change later.
+                        (java/java :sun :jdk)
                         (git/git)
                         (postgres/settings (postgres/settings-map {:version "8.4"
                                                                    :permissions [{:connection-type "local" :database "all" :user "all" :auth-method "trust"}


Remove unnecessary packages to the circle image, add emacs

--- src/circle/backend/nodes/circle.clj
+++ src/circle/backend/nodes/circle.clj
@@ -54,7 +54,7 @@
                                                      ;; reliability
                                                      :aptitude {:url "http://us.archive.ubuntu.com/ubuntu/"
                                                                 :scopes ["main" "updates" "universe" "multiverse"]})
-                             (package/packages :aptitude ["nginx" "htop" "mongodb" "rubygems" "libsqlite3-dev" "nodejs" "firefox" "xvfb" ])
+                             (package/packages :aptitude ["nginx" "htop" "mongodb" "rubygems" "firefox" "xvfb" "emacs"])

                              (remote-file/remote-file "/etc/rc.local" :local-file "pallet/rc.local" :mode "755" :no-versioning true)
                              (remote-file/remote-file "/home/ubuntu/.bashrc" :local-file "pallet/bashrc" :mode "644" :no-versioning true)


Create a gen-select->map utility fn

Create a gen-select->map utility fn

--- src/clj/comic_reader/sites/util.clj
+++ src/clj/comic_reader/sites/util.clj
@@ -21,7 +21,12 @@
   (html-fn {name :content
             {url :href} :attrs}
     {:name (process-name name)
-     :url (process-url url)}))
+     :url  (process-url  url)}))
+
+(defn gen-select->map [process-name process-url]
+  (html-fn {[name] :content}
+    {:name (process-name name)
+     :url  (process-url  name)}))

 (defn gen-add-key-from-url [key extract-pattern & [process]]
   (let [process (or process identity)]


Remove unusable ability to fetch all from addicted

--- src/clj/subman/sources/addicted.clj
+++ src/clj/subman/sources/addicted.clj
@@ -9,128 +9,6 @@
                   (if (nil? (re-find #"^/" end-part))
                     (str "/" end-part)
                     end-part)))
-
-(defn- create-shows
-  "Create show from html items"
-  [items] (for [item items]
-            {:name (-> item
-                       :content
-                       first)
-             :url (-> item
-                      :attrs
-                      :href
-                      make-url)}))
-
-(defn get-shows
-  "Get all available shows from addicted"
-  [] (-> "/shows.php"
-         make-url
-         helpers/fetch
-         (html/select [:td.version :h3 :a])
-         create-shows))
-
-(defn- get-episode-list-elements
-  "Get episode list elements"
-  [data] (html/select data [:div#header
-                            [:a (html/has [(html/re-pred
-                                            #"Episode list and air dates")])]]))
-
-(defn- is-title?
-  "Is line a title?"
-  [line] (some-> line
-                 :content
-                 vec
-                 (get 1)
-                 :tag
-                 (= :th)))
-
-(defn- is-episode?
-  "Is line a episode"
-  [line] (let [content (:content line)]
-           (and (some-> content
-                        first
-                        :attrs
-                        :align
-                        (= "left"))
-                (some-> content
-                        vec
-                        (get 10)
-                        :content
-                        first
-                        :tag
-                        (= :a)))))
-
-(defn- get-season-number
-  "Get season number from line"
-  [line] (-> line
-             :content
-             (nth 1)
-             :content
-             first
-             :content
-             first
-             (clojure.string/split  #" ")
-             last
-             helpers/remove-first-0))
-
-(defn- get-episode-name-element
-  "Get episode name holder element"
-  [line] (-> line
-             :content
-             last
-             :content
-             first))
-
-(defn- get-episode
-  "Get episode from line"
-  [line] {:number (-> line
-                      :content
-                      (nth 4)
-                      :content
-                      first
-                      :content
-                      first
-                      helpers/remove-first-0)
-          :name (-> line
-                    get-episode-name-element
-                    :content
-                    first)
-          :url (-> line
-                   get-episode-name-element
-                   :attrs
-                   :href
-                   make-url)})
-
-(defn- get-seasons
-  "Get season with episodes"
-  [lines] (reduce (fn [buffer line]
-                    (cond
-                     (is-title? line) (list* {:number (get-season-number line)
-                                              :episodes []}
-                                             buffer)
-                     (is-episode? line) (list*
-                                         (let [season (first buffer)
-                                               episodes (:episodes season)]
-                                           (assoc season
-                                             :episodes (list* (get-episode line)
-                                                              episodes)))
-                                         (rest buffer))
-                     :else buffer))
-                  [] lines))
-
-(defn get-episodes
-  "Get episodes for show"
-  [show] (-> show
-             :url
-             helpers/fetch
-             get-episode-list-elements
-             first
-             :attrs
-             :href
-             make-url
-             helpers/fetch
-             (html/select [:table.tableEplist :tr])
-             get-seasons))

 (defn- is-version-line?
   "Is it line with version?"


disclaimer

disclaimer

--- src/cljs/ikea_clojure_cup/core.cljs
+++ src/cljs/ikea_clojure_cup/core.cljs
@@ -46,6 +46,8 @@
      [:div#main
       [(session/get :current-page)]]]]
    [:div#footer.container
+    "IFLOGS is not endorsed or affiliated with IKEA."
+    [:br]
     [:sup "© "]
     [:a {:href "http://www.icm-consulting.com.au/"} "ICM Consulting Pty Ltd B.V 2010"]
     [:div.serial-text.pull-right "AA-498638-1"]


Fix and improve sign

Fix and improve sign

--- src/clojure_fabric/crypto_suite.clj
+++ src/clojure_fabric/crypto_suite.clj
@@ -32,14 +32,14 @@
            [org.bouncycastle.util.encoders Hex]
            [org.bouncycastle.asn1.pkcs PrivateKeyInfo]
            [org.bouncycastle.asn1.x509 SubjectPublicKeyInfo]
-           [org.bouncycastle.asn1 ASN1Integer DERSequenceGenerator]
+           [org.bouncycastle.asn1 ASN1Integer DERSequence ASN1InputStream ASN1Sequence]
            [org.bouncycastle.cert X509CertificateHolder]
            [org.bouncycastle.openssl.jcajce JcaPEMKeyConverter]
            [org.bouncycastle.openssl PEMParser]
            [org.bouncycastle.cert.jcajce JcaX509CertificateConverter]
            [org.bouncycastle.crypto.signers ECDSASigner]
            [org.bouncycastle.crypto.params ECDomainParameters ECPrivateKeyParameters]
-           [java.io FileInputStream StringReader FileReader File ByteArrayOutputStream]
+           [java.io FileInputStream StringReader FileReader File ByteArrayOutputStream ByteArrayInputStream]
            [java.util Arrays]
            [javax.crypto Cipher SecretKeyFactory]
            [javax.crypto.spec SecretKeySpec]
@@ -273,16 +273,48 @@
   [k cipher-text {:keys [algorithm] :as opts}]
   (%encrypt-or-decrypt k cipher-text (assoc opts :cipher-mode :decrypt)))

-(defn- prevent-malleability
-  [signature ^BigInteger curve-n]
+(defn- malleability-free-s
+  [^BigInteger s ^BigInteger curve-n]
   ;; Copy from Fabric SDK Java
-  (let [cmp-val ^BigInteger (.divide curve-n (biginteger 2))
-        s-val (aget signature 1)]
-    (when (= (.compareTo ^BigInteger s-val cmp-val) 1)
-      (aset signature 1 s-val))
-    signature))
+  (if (= (->> (biginteger 2) (.divide curve-n) (.compareTo s))
+         1)
+    (.subtract curve-n s)
+    s))

 ;;;sign
+
+#_
+(defn sign
+  "Sign the data.
+  Params
+        digest (byte[]) fixed-length digest of the target message to be signed
+        Key (Key) private signing key
+        opts (function) hashing function to use
+  Returns
+        Result(Object):Signature object"
+  ;; https://crypto.stackexchange.com/questions/1795/how-can-i-convert-a-der-ecdsa-signature-to-asn-1
+  [^bytes digest priv-key {:keys [algorithm curve hash-algorithm]
+                           :or {algorithm :ecdsa curve :secp256r1 hash-algorithm :sha256}}]
+  (let [signer (doto (Signature/getInstance (name algorithm))
+                 (.initSign priv-key)
+                 ;; FIXME: not sure need of hash call
+                 ;;(.update (hash digest :algorithm hash-algorithm))
+                 (.update digest))
+        asn-encodables (.toArray (.readObject (ASN1InputStream. (.sign signer))))]
+    (aset asn-encodables 1 (-> (aget asn-encodables 1)
+                               (.getValue)
+                               (malleability-free-s (-> (name curve)
+                                                        (ECNamedCurveTable/getParameterSpec)
+                                                        (.getN)))
+                               (ASN1Integer.)))
+    (let [result (.getEncoded (DERSequence. asn-encodables))]
+      (println "***1" (aget asn-encodables 1) (aget asn-encodables 1) )
+      (println "***2" (javax.xml.bind.DatatypeConverter/printHexBinary result))
+
+      result)))
+
+;;;; WORKS
+#_
 (defn sign
   "Sign the data.
   Params
@@ -299,19 +331,43 @@
     (->> (ECDomainParameters. (.getCurve priv-params) (.getG priv-params) curve-n)
          (ECPrivateKeyParameters. (.getS ^BCECPrivateKey priv-key))
          (.init signer true))
-    (let [out-stream (ByteArrayOutputStream.)
-          der-seq (DERSequenceGenerator. out-stream)
-          signature (prevent-malleability (.generateSignature signer
-                                                              (hash digest :algorithm hash-algorithm))
-                                          curve-n)]
-      (try
-        (.addObject der-seq (ASN1Integer. ^BigInteger (aget signature 0)))
-        (.addObject der-seq (ASN1Integer. ^BigInteger (aget signature 1)))
-        (catch Exception e
-          (println "FIXME: log error?" e))
-        (finally (.close der-seq)))
+    (let [signature (.generateSignature signer
+                                        (hash digest :algorithm hash-algorithm))
+          der-array (doto (make-array ASN1Integer 2)
+                      (aset 0 (ASN1Integer. (aget signature 0)))
+                      (aset 1 (-> (aget signature 1) (malleability-free-s curve-n) (ASN1Integer.))))
+          result (.getEncoded (DERSequence. der-array))]
+      (println "***1" (aget signature 0) (aget signature 1))
+      (println "***12" (aget der-array 0) (aget der-array 1))
+      (println "***2" (javax.xml.bind.DatatypeConverter/printHexBinary result))
+      result)))
+
+(defn sign
+  "Sign the data.
+  Params
+        digest (byte[]) fixed-length digest of the target message to be signed
+        Key (Key) private signing key
+        opts (function) hashing function to use
+  Returns
+        Result(Object):Signature object"
+  ;; https://crypto.stackexchange.com/questions/1795/how-can-i-convert-a-der-ecdsa-signature-to-asn-1
+  [^bytes digest priv-key {:keys [algorithm curve hash-algorithm]
+                           :or {algorithm :ecdsa curve :secp256r1 hash-algorithm :sha256}}]
+  (let [signer (doto (Signature/getInstance "SHA256withECDSA")
+                 (.initSign priv-key)
+                 (.update digest))
+        asn-encodables (.toArray (.readObject (ASN1InputStream. (.sign signer))))]
+    (aset asn-encodables 1 (-> (aget asn-encodables 1)
+                               (.getValue)
+                               (malleability-free-s (-> (name curve)
+                                                        (ECNamedCurveTable/getParameterSpec)
+                                                        (.getN)))
+                               (ASN1Integer.)))
+    (let [result ]
+      (println "***1" (aget asn-encodables 0) (aget asn-encodables 1) )
+      (println ">***2" (javax.xml.bind.DatatypeConverter/printHexBinary result))

-      (.toByteArray out-stream))))
+      result)))

 ;;; verify
 (defn verify


Changed rates in genome_uniform... instructions to be floats.

--- src/clojush/instructions/genome.clj
+++ src/clojush/instructions/genome.clj
@@ -1,3 +1,6 @@
+;; gorilla-repl.fileformat = 1
+
+;; @@
 (ns clojush.instructions.genome
   (:use [clojush pushstate globals args random]
         clojush.instructions.common
@@ -278,31 +281,15 @@
   ;; nondetermistic autoconstruction
   ^{:stack-types [:genome :boolean]} (fn [state] (push-item false :boolean state)))

-;(define-registered
-;  genome_uniform_instruction_mutation
-;  ^{:stack-types [:genome :float]}
-;  (fn [state]
-;    (if (and (not (empty? (:float state)))
-;             (not (empty? (:genome state))))
-;      (let [rate (mod (Math/abs (first (:float state))) 1.0)
-;            genome (first (:genome state))]
-;        (->> (pop-item :float state)
-;             (pop-item :genome)
-;             (push-item (vec (:genome (uniform-instruction-mutation
-;                                        {:genome genome}
-;                                        (merge @push-argmap {:uniform-mutation-rate rate}))))
-;                        :genome)))
-;      state)))
-
 (define-registered
   genome_uniform_instruction_mutation
-  ^{:stack-types [:genome :integer]}
-  (fn [state]
-    (if (and (not (empty? (:integer state)))
+  ^{:stack-types [:genome :float]}
+  (fn [state]
+    (if (and (not (empty? (:float state)))
              (not (empty? (:genome state))))
-      (let [rate (+ 0.001 (* 0.001 (mod (first (:integer state)) 100)))
+      (let [rate (mod (first (:float state)) 1.0)
             genome (first (:genome state))]
-        (->> (pop-item :integer state)
+        (->> (pop-item :float state)
              (pop-item :genome)
              (push-item (vec (:genome (uniform-instruction-mutation
                                         {:genome genome}
@@ -312,15 +299,15 @@

 (define-registered
   genome_uniform_integer_mutation
-  ^{:stack-types [:genome :integer]}
-  (fn [state]
-    (if (and (not (empty? (rest (:integer state))))
+  ^{:stack-types [:genome :integer :float]}
+  (fn [state]
+    (if (and (not (empty? (rest (:float state))))
              (not (empty? (:genome state))))
-      (let [rate (+ 0.001 (* 0.001 (mod (first (:integer state)) 100)))
-            stdev (+ 1 (#(if (pos? %) % (- %)) (second (:integer state))))
+      (let [rate (mod (first (:float state)) 1.0)
+            stdev (+ 1 (#(if (pos? %) % (- %)) (second (:float state))))
             genome (first (:genome state))]
-        (->> (pop-item :integer state)
-             (pop-item :integer)
+        (->> (pop-item :float state)
+             (pop-item :float)
              (pop-item :genome)
              (push-item (vec (:genome (uniform-integer-mutation
                                         {:genome genome}
@@ -328,4 +315,5 @@
                                                {:uniform-mutation-constant-tweak-rate rate
                                                 :uniform-mutation-int-gaussian-standard-deviation stdev}))))
                         :genome)))
-      state)))+      state)))
+;; @@


Resolver and Mutation will enable override of sym and lambda from config map

--- src/com/wsscode/pathom/connect.cljc
+++ src/com/wsscode/pathom/connect.cljc
@@ -1011,7 +1011,7 @@
   "Helper to return a resolver map"
   [sym options resolve]
   (assert (symbol? sym) "Resolver name must be a symbol")
-  (assoc options ::sym sym ::resolve resolve))
+  (merge {::sym sym ::resolve resolve} options))

 (defmacro defresolver [sym arglist config & body]
   (let [fqsym (if (namespace sym)
@@ -1031,9 +1031,9 @@

 (defn mutation
   "Helper to return a mutation map"
-  [sym options resolve]
+  [sym options mutate]
   (assert (symbol? sym) "Mutation name must be a symbol")
-  (assoc options ::sym sym ::mutate resolve))
+  (merge {::sym sym ::mutate mutate} options))

 (defmacro defmutation [sym arglist config & body]
   (let [fqsym (if (namespace sym)


lein: new plugins

lein: new plugins

--- lein_profiles.clj
+++ lein_profiles.clj
@@ -1,5 +1,7 @@
 {:user {:plugins [
                   [lein-cljfmt "0.3.0" :exclusions [org.clojure/clojure]]
                   [lein-ancient "0.6.8" :exclusions [org.clojure/clojure]]
-                  [cider/cider-nrepl "0.10.1"]
+                  [lein-cloverage "1.0.6"]
+                  [org.clojure/tools.nrepl "0.2.12"]
+                  [cider/cider-nrepl "0.11.0-SNAPSHOT"]
                   ]}}


check for identical transaction before forwarding

--- src/block_chain/message_handlers.clj
+++ src/block_chain/message_handlers.clj
@@ -79,8 +79,10 @@

 (defn submit-transaction [msg sock-info]
   (let [txn (:payload msg)]
-    (swap! db/transaction-pool conj txn)
-    (peers/transaction-received! txn)
+    (if-not (contains? @db/transaction-pool txn)
+      (do
+        (swap! db/transaction-pool conj txn)
+        (peers/transaction-received! txn)))
     {:message-type "transaction-accepted"
      :payload txn}))

@@ -106,5 +108,4 @@
                         (:message-type msg)
                         echo)
         resp (handler-fn msg sock-info)]
-    ;; (println "Responding with: " resp)
     resp))


add comments to code

add comments to code

--- src/cljs/phonecat_re_frame/core.cljs
+++ src/cljs/phonecat_re_frame/core.cljs
@@ -11,11 +11,12 @@
     (:import goog.History))

 ;; -------------------------
-;; Re-frame data
+;; Re-frame subscriptions

 (re-frame/register-sub        ;; a new subscription handler
  :phones             ;; usage (subscribe [:phones])
  (fn [db]
+   ;; extracts the phones property from the db
    (reaction (:phones @db))))  ;; pulls out :phones

 (re-frame/register-sub
@@ -30,10 +31,13 @@

 (re-frame/register-sub
  :selected-image-url
- (fn [db [_ phone-id]]
+ (fn
+   ;; extract the selected-image-url from the db. If it's not set return the first image of the current phone under query
+   [db [_ phone-id]]
    (let [phone (re-frame/subscribe [:phone-query phone-id])
          phone-details (re-frame/subscribe [:phone-details])
          images (reaction (:images @phone))]
+     ;; Note how we are sequencing reactions above. Whenever the phone ratom changes the images ratom will change as well
      (reaction
       (if @phone-details
         (if-let [image-url (:selected-image-url @phone-details)]
@@ -57,31 +61,40 @@

 (re-frame/register-sub
  :phone-query
- (fn [db [_ phone-id]]
+ (fn
+   ;; get info on the given phone id from the phone-details map
+   [db [_ phone-id]]
    (let [phone-details-reaction (reaction (:phone-details @db))]
      (reaction ((keyword phone-id) @phone-details-reaction)))))

+;; -------------------------
+;; Re-frame handlers
+
 (re-frame/register-handler
  :set-image
  (fn
+   ;; take an image url and set it in the db
    [app-state [_ selected-image-url]]
    (assoc-in app-state [:phone-details :selected-image-url] selected-image-url)))

 (re-frame/register-handler
  :process-phones-response
  (fn
+   ;; store the response of fetching the phones list in the phones attribute of the db
    [app-state [_ response]]
    (assoc-in app-state [:phones] response)))

 (re-frame/register-handler
  :process-phones-bad-response
  (fn
+   ;; log a bad response fetching the phones list
    [app-state [_ response]]
    app-state))

 (re-frame/register-handler
  :load-phones
  (fn
+   ;; Fetch the list of phones and process the response
    [app-state _]
    (ajax/GET "phones/phones.json"
                   {:handler #(re-frame/dispatch [:process-phones-response %1])
@@ -102,32 +115,6 @@
  (fn
    [app-state [_ phone-id response]]
    (println "Error getting phone detail for id: " phone-id)
-   app-state))
-
-(re-frame/register-handler
- :load-phone-detail
- (fn
-   [app-state [_ phone-id]]
-   (ajax/GET (str "phones/" phone-id ".json")
-             {:handler #(re-frame/dispatch [:process-phone-detail-response phone-id %1])
-              :error-handler #(re-frame/dispatch [:process-phone-detail-bad-response phone-id %1])
-              :response-format :json
-              :keywords? true})
-   app-state))
-
-(re-frame/register-handler
- :process-phone-detail-response
- (fn
-   ;; store info for the specific phone-id in the db
-   [app-state [_ phone-id response]]
-   (assoc-in app-state [:phone-details (keyword phone-id)] response)))
-
-(re-frame/register-handler
- :process-phone-detail-bad-response
- (fn
-   [app-state [_ [phone-id response]]]
-   (println "Error getting phone detail for id: " phone-id)
-   (println response)
    app-state))

 (re-frame/register-handler
@@ -143,6 +130,33 @@
    app-state))

 (re-frame/register-handler
+ :process-phone-detail-response
+ (fn
+   ;; store info for the specific phone-id in the db
+   [app-state [_ phone-id response]]
+   (assoc-in app-state [:phone-details (keyword phone-id)] response)))
+
+(re-frame/register-handler
+ :process-phone-detail-bad-response
+ (fn
+   [app-state [_ [phone-id response]]]
+   (println "Error getting phone detail for id: " phone-id)
+   (println response)
+   app-state))
+
+(re-frame/register-handler
+ :load-phone-detail
+ (fn
+   ;; fetch information for the phone with the given phone-id
+   [app-state [_ phone-id]]
+   (ajax/GET (str "phones/" phone-id ".json")
+             {:handler #(re-frame/dispatch [:process-phone-detail-response phone-id %1])
+              :error-handler #(re-frame/dispatch [:process-phone-detail-bad-response phone-id %1])
+              :response-format :json
+              :keywords? true})
+   app-state))
+
+(re-frame/register-handler
  :initialise-db             ;; usage: (dispatch [:initialise-db])
  (fn
    [_ _]                   ;; Ignore both params (db and v).
@@ -170,10 +184,12 @@
 (re-frame/register-handler
  :order-prop-changed
  handle-order-prop-changed)
-;; -------------------------
-;; Views
+
+;; -------------------------
+;; Phone List View

 (defn phone-component
+  "individual phone component in the phoens list view"
   [phone]
   [:li {:class "thumbnail phone-listing"}
    [:a {:href (str "#/phones/" (:id phone))
@@ -183,14 +199,16 @@
    [:p (:snippet phone)]])

 (defn matches-query?
- [search-input phone]
- (if (= "" search-input)
-   true
-   (boolean (or
-             (re-find (re-pattern search-input) (:name phone))
-             (re-find (re-pattern search-input) (:snippet phone))))))
+  "checks if the search input matches a name or snippet of the given phone"
+  [search-input phone]
+  (if (= "" search-input)
+    true
+    (boolean (or
+              (re-find (re-pattern search-input) (:name phone))
+              (re-find (re-pattern search-input) (:snippet phone))))))

 (defn phones-component
+  "component for the list of phones"
   []
   (let [phones (re-frame/subscribe [:phones])
         search-input (re-frame/subscribe [:search-input])
@@ -203,6 +221,7 @@
          ^{:key (:name phone)} [phone-component phone])])))

 (defn search-component
+  "component for the search input"
   []
   (let [search-input (re-frame/subscribe [:search-input])])
   (fn []
@@ -210,12 +229,14 @@
      [:input {:on-change #(re-frame/dispatch [:search-input-entered (-> % .-target .-value)])}]]))

 (defn mark-selected
-  [props order-prop current-prop-value]
+  "mark the given select element as selected if the order-prop matches the value of the element passed in"
+  [props order-prop]
   (if (= order-prop current-prop-value)
     (reagent/merge-props props {:selected "selected"})
     props))

 (defn order-by-component
+  "component to define how you want to order the phones list"
   []
   (let [order-prop (re-frame/subscribe [:order-prop])]
     (fn []
@@ -224,7 +245,9 @@
         [:option (mark-selected {:value "name"} @order-prop "name") "Alphabetical"]
         [:option (mark-selected {:value "age"} @order-prop "age") "Newest"]]])))

-(defn home-page []
+(defn home-page
+  "defines the ome page which will be the phone list component"
+  []
   [:div {:class "container-fluid"}
    [:div {:class "row"}
     [:div {:class "col-md-2"}
@@ -240,6 +263,7 @@
 ;; Phone details views

 (defn phone-info-template
+  "template for listing a set of phone attributes"
   [section-title attributes-map]
   [:li
    [:span section-title]
@@ -254,6 +278,7 @@
          attributes-map)]])

 (defn thumbnails
+  "component for displaying thumbnails of the phone"
   [phone]
   [:ul {:class "phone-thumbs"}
    (for [image (:images @phone)]
@@ -345,6 +370,7 @@
    [:dd @additional-features]])

 (defn specs
+  "component for displaying the specs of the phone"
   [phone]
   [:ul {:class "specs"}
    [availability (reaction (:availiability @phone))]
@@ -357,7 +383,9 @@
    [camera (reaction (:camera @phone))]
    [additional-features (reaction (:additionalFeatures @phone))]])

-(defn phone-page [{phone-id :phone-id}]
+(defn phone-page
+  "top level component for the phone page"
+  [{phone-id :phone-id}]
   (let [phone (re-frame/subscribe [:phone-query phone-id])
         image-url (re-frame/subscribe [:selected-image-url phone-id])]
     (fn []


remove unused stuff

remove unused stuff

--- server/src/gratefulplace/controllers/shared.clj
+++ server/src/gratefulplace/controllers/shared.clj
@@ -13,15 +13,6 @@
   [errors]
   {:body {:errors errors}
    :status 412})
-
-(def OK
-  {:status 200})>
-
-(def NOT-AUTHORIZED
-  {:status 401})
-
-(def NOT-FOUND
-  {:status 404})

 (defmacro id
   []


Fix status display by providing public key in message data

--- src/status_im/ui/components/connectivity/view.cljs
+++ src/status_im/ui/components/connectivity/view.cljs
@@ -3,7 +3,6 @@
   (:require [re-frame.core :as re-frame]
             [reagent.core :as reagent]
             [status-im.ui.components.react :as react]
-            [taoensso.timbre :as log]
             [status-im.ui.components.connectivity.styles :as styles]
             [status-im.i18n :as i18n]))


Removing print-expr that I don't have the library for anymore

--- src/com/okl/tokenmgr/filter_file.clj
+++ src/com/okl/tokenmgr/filter_file.clj
@@ -93,4 +93,4 @@
             dir (second (rest args)) ;; aka third
             tokens (get-token-values app envt cli-tokens)
             tokens (process-token-values tokens)]
-        (process-dir (print-expr dir) tokens)))))
+        (process-dir dir tokens)))))


Sort of working solver. Constraints need much cleaning up.

--- src/aurora/btree.cljs
+++ src/aurora/btree.cljs
@@ -4,7 +4,7 @@
             [cemerick.double-check.properties :as prop :include-macros true]
             [cemerick.pprng :as pprng]
             clojure.set)
-  (:require-macros [aurora.macros :refer [debug apush apush* amake aclear typeof set!! dofrom]]))
+  (:require-macros [aurora.macros :refer [debug check apush apush* amake aclear typeof set!! dofrom]]))

 ;; COMPARISONS

@@ -401,7 +401,6 @@
          (set ix 0)
          (set end? (> (alength (.-keys node)) 0)))
   (seek-gt [this key]
-           tree
            (loop []
              (if (and (instance? Node (.-parent node))
                       (or (key-lte (.-upper node) key)
@@ -467,48 +466,71 @@
 (def failed 2)

 ;; lower and upper are inclusive
-;; lower is aliased to iterator, must not be mutated
-(deftype Contains [iterator seek-key ^:mutable lower ^:mutable upper ixes pushed|split pushed-nodes pushed-ixes split-lowers split-uppers]
+(deftype Contains [iterator ^:mutable lower ^:mutable upper ixes pushed|split pushed-nodes pushed-ixes split-lowers split-uppers]
   Object
   (reset [this]
          (.reset iterator)
-         (dotimes [i (alength seek-key)]
-           (aset seek-key i least))
-         (set! lower (.seek-gte iterator seek-key))
-         (dotimes [i (alength upper)]
+         (dotimes [i (alength lower)]
+           (aset lower i least)
            (aset upper i greatest))
+         (let [key (.seek-gte iterator lower)]
+           (aset lower 0 (aget key 0)))
          (aclear pushed-nodes)
          (aclear pushed-ixes)
          (aclear split-lowers)
          (aclear split-uppers))
   (propagate [this los his]
-             (if (nil? lower)
-               failed
-               (do
-                 (dotimes [i (alength ixes)]
-                   (aset seek-key i (aget los (aget ixes i))))
-                 (when (key-lt lower seek-key)
-                   (set! lower (.seek-gte iterator seek-key)))
-                 (if (or (nil? lower)
-                         (key-lt upper lower))
+             (check (key-lte los his) (pr-str los his))
+             (check (key-lte lower upper) (pr-str lower upper))
+             (debug :before-propagate lower upper los his)
+             (let [this-changed? false]
+               (loop [i 0]
+                 (when (< i (alength ixes))
+                   (let [ix (aget ixes i)
+                         old-lo (aget lower i)
+                         old-hi (aget upper i)
+                         new-lo (aget los ix)
+                         new-hi (aget his ix)]
+                     (when (val-lt old-lo new-lo)
+                       (aset lower i new-lo)
+                       (set!! this-changed? true))
+                     (when (val-lt new-hi old-hi)
+                       (aset upper i new-hi)
+                       (set!! this-changed? true))
+                     (when (identical? new-lo new-hi)
+                       (recur (+ i 1))))))
+               ;; TODO only seek on change, including split as change
+               (let [key (.seek-gte iterator lower)
+                     that-changed? false]
+                 (debug :propagate-with key)
+                 (if (or (nil? key)
+                         (key-lt upper key))
                    failed
-                   (let [changed? false]
-                     (dotimes [i (alength ixes)]
-                       (let [ix (aget ixes i)
-                             new-lo (aget lower i)
-                             old-hi (aget his ix)
-                             new-hi (aget upper i)]
-                         (when (val-lt (aget los ix) new-lo)
-                           (aset los ix new-lo)
-                           (set!! changed? true))
-                         (if (val-lt new-hi old-hi)
-                           (do
+                   (loop [i 0]
+                     (let [ix (aget ixes i)
+                           old-lo (aget los ix)
+                           old-hi (aget his ix)
+                           new-lo (aget key i)
+                           new-hi (aget upper i)]
+                       (if (val-lt old-hi new-lo)
+                         failed
+                         (do
+                           (aset lower i new-lo)
+                           (when (val-lt old-lo new-lo)
+                             (aset los ix new-lo)
+                             (set!! that-changed? true))
+                           (when (val-lt new-hi old-hi)
                              (aset his ix new-hi)
-                             (set!! changed? true))
-                           (aset upper i old-hi))))
-                     (if (true? changed?)
-                       changed
-                       unchanged))))))
+                             (set!! that-changed? true))
+                           (if (and (< (+ i 1) (alength ixes)) (identical? new-lo new-hi))
+                             (recur (+ i 1))
+                             (do
+                               (debug :after-propagate lower upper los his)
+                               (check (key-lte los his) (pr-str los his))
+                               (check (key-lte lower upper) (pr-str lower upper))
+                               (if (true? that-changed?)
+                                 changed
+                                 unchanged)))))))))))
   (push [this]
         (apush pushed|split true)
         (apush pushed-nodes (.-node iterator))
@@ -516,13 +538,17 @@
   (split [this]
          ;; split by value of next unset var
          (loop [i 0]
-           (if (< i (alength upper))
+           (if (< i (alength ixes))
              (if (identical? (aget lower i) (aget upper i))
                (recur (+ i 1))
                (do
                  (apush pushed|split false)
                  (apush split-uppers (aclone upper))
-                 (aset upper i (aget lower i))
+                 (let [old-lo (aget lower i)
+                       new-lo (aget (.seek-gte iterator lower) i)]
+                   (if (val-lt new-lo old-lo)
+                     (aset upper i old-lo)
+                     (aset upper i new-lo)))
                  (apush split-lowers (aclone upper)) ;; the lower for right-hand branch is the next key after the upper for the left-hand branch
                  true))
              false)))
@@ -536,10 +562,77 @@
            (set! upper (.pop split-uppers))))))

 (defn contains [iterator ixes]
-  (let [seek-key (least-key (alength ixes))
-        lower (.seek-gte iterator seek-key)
-        upper (greatest-key (alength ixes))]
-    (Contains. iterator seek-key lower upper ixes #js [] #js [] #js [] #js [] #js [])))
+  (let [lower (least-key (alength ixes))
+        upper (greatest-key (alength ixes))
+        key (.seek-gte iterator lower)]
+    (aset lower 0 (aget key 0))
+    (Contains. iterator lower upper ixes #js [] #js [] #js [] #js [] #js [])))
+
+;; SOLVER
+
+(deftype Solver [constraints ^:mutable los ^:mutable his ^:mutable depth pushed-los pushed-his ^:mutable end?]
+  Object
+  (reset [this]
+         (dotimes [i (alength constraints)]
+           (.reset (aget constraints i)))
+         (dotimes [i (alength los)]
+           (aset los i least)
+           (aset his i greatest))
+         (set! depth 0)
+         (aclear pushed-los)
+         (aclear pushed-his)
+         (set! end? false))
+  (split [this current]
+         (debug :splitting los his)
+         (loop [splitter current]
+           (if (true? (.split (aget constraints splitter)))
+             (do
+               (apush pushed-los (aclone los))
+               (apush pushed-his (aclone his))
+               (set! depth (+ depth 1))
+               (dotimes [i (alength constraints)
+                         :when (not (identical? i splitter))]
+                 (.push (aget constraints i)))
+               splitter)
+             (let [new-splitter (mod (+ splitter 1) (alength constraints))]
+               (if (identical? new-splitter current)
+                 (assert false "Can't split anything!")
+                 (recur new-splitter))))))
+  (pop [this]
+       (set! los (.pop pushed-los))
+       (set! his (.pop pushed-his))
+       (set! depth (- depth 1))
+       (dotimes [i (alength constraints)]
+         (.pop (aget constraints i))))
+  (next [this]
+        (debug :next los his pushed-los pushed-his)
+        (when (false? end?)
+          (loop [current 0
+                 last-changed (- (alength constraints) 1)]
+            (let [result (.propagate (aget constraints current) los his)]
+              (debug :next-loop current result los his pushed-los pushed-his)
+              (condp identical? result
+                changed (recur (mod (+ current 1) (alength constraints)) current)
+                unchanged (if (not (identical? current last-changed))
+                            (recur (mod (+ current 1) (alength constraints)) last-changed)
+                            (if (key= los his)
+                              (let [result (aclone los)]
+                                (if (> depth 0)
+                                  (.pop this)
+                                  (set! end? true))
+                                result)
+                              (let [splitter (.split this current)]
+                                (recur splitter (mod (+ splitter 1) (alength constraints))))))
+                failed (if (> depth 0)
+                         (do
+                           (.pop this)
+                           (recur current (mod (- current 1) (alength constraints))))
+                         (do
+                           (set! end? true)
+                           nil))))))))
+
+(defn solver [constraints num-vars]
+  (Solver. constraints (least-key num-vars) (greatest-key num-vars) 0 #js [] #js [] false))

 ;; TESTS

@@ -884,20 +977,28 @@
     (alength (time (iterator->keys j)))
   )

-  (let [tree1 (tree 10)
-        _ (.assoc! tree1 #js ["a" "b"] 0)
-        _ (.assoc! tree1 #js ["b" "c"] 0)
-        _ (.assoc! tree1 #js ["c" "d"] 0)
-        _ (.assoc! tree1 #js ["d" "b"] 0)
-        tree2 (tree 10)
-        _ (.assoc! tree2 #js ["b" "a"] 0)
-        _ (.assoc! tree2 #js ["c" "b"] 0)
-        _ (.assoc! tree2 #js ["d" "c"] 0)
-        _ (.assoc! tree2 #js ["b" "d"] 0)
-        join-itr (join #js [(iterator tree1) (iterator tree2)] 3 #js [#js [true false true]
-                                                                      #js [false true true]])
-        ]
-     (map vec (iterator->keys join-itr))
-    )
+
+
+

  )
+
+(enable-console-print!)
+
+(let [tree1 (tree 10)
+      _ (.assoc! tree1 #js ["a" "b"] 0)
+      _ (.assoc! tree1 #js ["b" "c"] 0)
+      _ (.assoc! tree1 #js ["c" "d"] 0)
+      _ (.assoc! tree1 #js ["d" "b"] 0)
+      tree2 (tree 10)
+      _ (.assoc! tree2 #js ["b" "a"] 0)
+      _ (.assoc! tree2 #js ["c" "b"] 0)
+      _ (.assoc! tree2 #js ["d" "c"] 0)
+      _ (.assoc! tree2 #js ["b" "d"] 0)
+      s (solver #js [(contains (iterator tree1) #js [0 2])
+                     (contains (iterator tree2) #js [1 2])]
+                3)
+      ]
+  [(.next s) (.next s) (.next s)]
+  )
+


draw player and zombies a bit bigger

draw player and zombies a bit bigger

--- src/zombie_run/quil.clj
+++ src/zombie_run/quil.clj
@@ -42,13 +42,13 @@

   ; display player
   (when-let [[x y] (z/player-position game)]
-    (->> (q/rect (width* x) (width* y) width width 2)
+    (->> (q/rect (width* x) (width* y) 20 20 5)
          (q/with-fill [204 255 255])
          (q/with-stroke [0 51 102])))

   ; display zombies
   (doseq [[x y] (z/zombie-positions game)]
-    (->> (q/rect (width* x) (width* y) width width 2)
+    (->> (q/rect (width* x) (width* y) 20 20 5)
          (q/with-fill [204 102 0])
          (q/with-stroke [255 0 0]))))


disable photowall for the moment (not a priority)

--- src/blogiseq/core.clj
+++ src/blogiseq/core.clj
@@ -136,9 +136,9 @@

 (compojure/defroutes
   routes
-  (compojure-route/resources "/resources/photowalls/" {:root "photowalls/"}) ; all photowalls resources (photos)
-  (compojure/GET "/photowalls/index" [] (hiccup/html (site (photowalls-index "resources/photowalls"))))
-  (compojure/GET "/photowalls/:name" [name] (hiccup/html (site (dir-to-photowall (str "resources/photowalls/" name)))))
+  ;(compojure-route/resources "/resources/photowalls/" {:root "photowalls/"}) ; all photowalls resources (photos)
+  ;(compojure/GET "/photowalls/index" [] (hiccup/html (site (photowalls-index "resources/photowalls"))))
+  ;(compojure/GET "/photowalls/:name" [name] (hiccup/html (site (dir-to-photowall (str "resources/photowalls/" name)))))

   (compojure/GET "/" [] (hiccup/html (site (md/md-to-html-string (slurp "resources/index.md")))))
   (compojure/GET "/resources/articles/:file" [file] (hiccup/html (site (detail (str "resources/articles/" file)))))


`reduce-scan`: support `reduced`

`reduce-scan`: support `reduced`

--- src/taoensso/carmine.clj
+++ src/taoensso/carmine.clj
@@ -688,7 +688,7 @@
 ;;;;

 (defn reduce-scan
-  "For use with `scan`, `zscan`, etc. Takes:
+  "For use with `scan`, `hscan`, `zscan`, etc. Takes:
     - (fn rf      [acc scan-result]) -> next accumulator
     - (fn scan-fn [cursor]) -> next scan result"
   ([rf          scan-fn] (reduce-scan rf nil scan-fn))
@@ -697,7 +697,10 @@
      (let [[next-cursor in] (scan-fn cursor)]
        (if (= next-cursor "0")
          (rf acc in)
-         (recur next-cursor (rf acc in)))))))
+         (let [result (rf acc in)]
+           (if (reduced? result)
+             @result
+             (recur next-cursor result))))))))

 (comment
   (reduce-scan (fn rf [acc in] (into acc in))


Housekeeping for 854cf17

Housekeeping for 854cf17

--- src/taoensso/faraday.clj
+++ src/taoensso/faraday.clj
@@ -220,7 +220,6 @@
       :bs   (into #{} (mapv nt-thaw          x))
       :b    (nt-thaw  x)

-      ;;; TODO Completely untested
       :l (mapv db-val->clj-val x)
       :m (zipmap (mapv keyword         (.keySet ^java.util.HashMap x))
                  (mapv db-val->clj-val (.values ^java.util.HashMap x))))))
@@ -239,7 +238,6 @@
    (ddb-num? x)          (doto (AttributeValue.) (.setN (str x)))
    (freeze?  x)          (doto (AttributeValue.) (.setB (nt-freeze x)))

-   ;;; TODO Completely untested
    (vector?  x) (doto (AttributeValue.) (.setL (mapv clj-val->db-val x)))
    (map?     x) (doto (AttributeValue.) (.setM (encore/map-kvs
                                                  (fn [k _] (name k))


Housekeeping: high-level code organization

--- src/taoensso/faraday.clj
+++ src/taoensso/faraday.clj
@@ -60,6 +60,62 @@
 ;; * Async API.
 ;; * Auto throughput adjusting.

+;;;; Coercion - values
+
+;; TODO see http://goo.gl/hOzhR and http://goo.gl/NSY3Z for types supported by
+;; the Java SDK! (incl. Date, Long, BigDecimal, BigInteger, ...).
+
+;; TODO Nippy support (will require special marker bin-wrapping), incl.
+;; Serialized (boxed) type (should allow empty strings & ANY type of set)
+;; Maybe require special wrapper types for writing bins/serialized
+
+(defn- str->num [^String s] (if (.contains s ".") (Double. s) (Long. s)))
+(defn- bb->ba   [^ByteBuffer bb] (.array bb))
+
+(defn- db-val->clj-val "Returns the Clojure value of given AttributeValue object."
+  [^AttributeValue x]
+  (or (.getS x)
+      (some->> (.getN  x) str->num)
+      (some->> (.getB  x) bb->ba)
+      (some->> (.getSS x) (into #{}))
+      (some->> (.getNS x) (map str->num) (into #{}))
+      (some->> (.getBS x) (map bb->ba)   (into #{}))))
+
+(def ^:private ^:const ba-class (Class/forName "[B"))
+(defn- ba? [x] (instance? ba-class x))
+(defn- ba-buffer [^bytes ba] (ByteBuffer/wrap ba))
+(defn- simple-num? [x] (or (instance? Long    x)
+                           (instance? Double  x)
+                           (instance? Integer x)
+                           (instance? Float   x)))
+
+(defn- clj-val->db-val "Returns an AttributeValue object for given Clojure value."
+  ^AttributeValue [x]
+  (cond
+   (string? x)
+   (if (.isEmpty ^String x)
+     (throw (Exception. "Invalid DynamoDB value: \"\""))
+     (doto (AttributeValue.) (.setS x)))
+
+   (simple-num? x) (doto (AttributeValue.) (.setN (str x)))
+   (ba? x)         (doto (AttributeValue.) (.setB (ba-buffer x)))
+
+   (set? x)
+   (if (empty? x)
+     (throw (Exception. "Invalid DynamoDB value: empty set"))
+     (cond
+      (every? string?     x) (doto (AttributeValue.) (.setSS x))
+      (every? simple-num? x) (doto (AttributeValue.) (.setNS (map str x)))
+      (every? ba?         x) (doto (AttributeValue.) (.setBS (map ba-buffer x)))
+      :else (throw (Exception. (str "Invalid DynamoDB value: set of invalid type"
+                                    " or more than one type")))))
+
+   :else (throw (Exception. (str "Unknown value type: " (type x) "."
+                                 " Wrap with `serialize`?")))))
+
+(comment (map clj-val->db-val ["foo" 10 3.14 (.getBytes "foo")
+                               #{"a" "b" "c"} #{1 2 3.14} #{(.getBytes "foo")}]))
+
 ;;;; API - object wrappers

 (def ^:private db-client*
@@ -123,61 +179,18 @@
        (.setProjection (projection projection included-attrs))))
    indexes))

-;;;; Coercion - values
-
-;; TODO see http://goo.gl/hOzhR and http://goo.gl/NSY3Z for types supported by
-;; the Java SDK! (incl. Date, Long, BigDecimal, BigInteger, ...).
-
-;; TODO Nippy support (will require special marker bin-wrapping), incl.
-;; Serialized (boxed) type (should allow empty strings & ANY type of set)
-;; Maybe require special wrapper types for writing bins/serialized
-
-(defn- str->num [^String s] (if (.contains s ".") (Double. s) (Long. s)))
-(defn- bb->ba   [^ByteBuffer bb] (.array bb))
-
-(defn- db-val->clj-val "Returns the Clojure value of given AttributeValue object."
-  [^AttributeValue x]
-  (or (.getS x)
-      (some->> (.getN  x) str->num)
-      (some->> (.getB  x) bb->ba)
-      (some->> (.getSS x) (into #{}))
-      (some->> (.getNS x) (map str->num) (into #{}))
-      (some->> (.getBS x) (map bb->ba)   (into #{}))))
-
-(def ^:private ^:const ba-class (Class/forName "[B"))
-(defn- ba? [x] (instance? ba-class x))
-(defn- ba-buffer [^bytes ba] (ByteBuffer/wrap ba))
-(defn- simple-num? [x] (or (instance? Long    x)
-                           (instance? Double  x)
-                           (instance? Integer x)
-                           (instance? Float   x)))
-
-(defn- clj-val->db-val "Returns an AttributeValue object for given Clojure value."
-  ^AttributeValue [x]
-  (cond
-   (string? x)
-   (if (.isEmpty ^String x)
-     (throw (Exception. "Invalid DynamoDB value: \"\""))
-     (doto (AttributeValue.) (.setS x)))
-
-   (simple-num? x) (doto (AttributeValue.) (.setN (str x)))
-   (ba? x)         (doto (AttributeValue.) (.setB (ba-buffer x)))
-
-   (set? x)
-   (if (empty? x)
-     (throw (Exception. "Invalid DynamoDB value: empty set"))
-     (cond
-      (every? string?     x) (doto (AttributeValue.) (.setSS x))
-      (every? simple-num? x) (doto (AttributeValue.) (.setNS (map str x)))
-      (every? ba?         x) (doto (AttributeValue.) (.setBS (map ba-buffer x)))
-      :else (throw (Exception. (str "Invalid DynamoDB value: set of invalid type"
-                                    " or more than one type")))))
-
-   :else (throw (Exception. (str "Unknown value type: " (type x) "."
-                                 " Wrap with `serialize`?")))))
-
-(comment (map clj-val->db-val ["foo" 10 3.14 (.getBytes "foo")
-                               #{"a" "b" "c"} #{1 2 3.14} #{(.getBytes "foo")}]))
+(defn- expected-values
+  "Returns a map of attribute/ExpectedAttributeValue pairs from a map of
+  attribute/condition pairs: {\"my-attr\" \"expected-value\"}, etc.
+
+  All conditions must be met for operation to succeed."
+  [expected]
+  (utils/fmap
+   #(case %
+      (true  ::exists)     (ExpectedAttributeValue. true) ;; TODO Valid?
+      (false ::not-exists) (ExpectedAttributeValue. false)
+      (ExpectedAttributeValue. (clj-val->db-val %)))
+   expected))

 ;;;; Coercion - objects


Fixup checkbox styling

Fixup checkbox styling

--- src/day8/re_frame/trace/styles.cljs
+++ src/day8/re_frame/trace/styles.cljs
@@ -68,11 +68,9 @@
     (s/attr= "type" "reset")
     (s/attr= "type" "submit")
     {:-webkit-appearance "button"}]
-"input[type=\"checkbox\" i] {\n    -webkit-appearance: checkbox;\n    box-sizing: border-box;\n}"
-   [:input
-    (s/attr= "type" "checkbox")
+   [(s/input (s/attr= "type" "checkbox"))
     {:-webkit-appearance "checkbox"
-     :box-sizing "border-box"}]
+     :box-sizing         "border-box"}]

    [:button:-moz-focusring
     (s/attr= "type" "button")


Add origin to posted statements

Add origin to posted statements

--- src/discuss/communication/main.cljs
+++ src/discuss/communication/main.cljs
@@ -5,7 +5,8 @@
             [discuss.config :as config]
             [discuss.utils.common :as lib]
             [discuss.references.integration :as rint]
-            [discuss.communication.lib :as comlib]))
+            [discuss.communication.lib :as comlib]
+            [cljs.spec.alpha :as s]))

 ;;;; Calls
 (defn process-url-handler
@@ -45,12 +46,13 @@
   ([url body]
    (post-json url body process-url-handler {"Content-Type" "application/json"})))

-(defn post-statement [statement reference add-type]
+(defn- post-statement [statement reference origin add-type]
   (let [app @lib/app-state
         url (get-in config/api [:add add-type])
         headers (merge {"Content-Type" "application/json"} (comlib/token-header))
         body {:statement     (htmlEscape statement)
               :reference     (htmlEscape reference)
+              :origin        origin
               :conclusion_id (get-conclusion-id)            ; Relevant for add-start-premise
               :supportive    (get-in app [:discussion :is_supportive])
               :arg_uid       (get-in app [:discussion :arg_uid]) ; For premisses for arguments
@@ -65,13 +67,18 @@
 ;;;; For preparation
 (defn dispatch-add-action
   "Check which action needs to be performed based on the type previously stored in the app-state."
-  [statement reference]
-  (let [action (get-in @lib/app-state [:layout :add-type])]
-    (case action
-      :add-start-statement (post-statement statement reference :add-start-statement)
-      :add-start-premise (post-statement [statement] reference :add-start-premise)
-      :add-justify-premise (post-statement [statement] reference :add-justify-premise)
-      (println "Action not found:" action))))
+  ([statement reference origin]
+   (let [action (get-in @lib/app-state [:layout :add-type])]
+     (case action
+       :add-start-statement (post-statement statement reference origin :add-start-statement)
+       :add-start-premise (post-statement [statement] reference origin :add-start-premise)
+       :add-justify-premise (post-statement [statement] reference origin :add-justify-premise)
+       (println "Action not found:" action))))
+  ([statement reference] (dispatch-add-action statement reference nil)))
+
+#_(s/fdef dispatch-add-action
+        :args (s/cat :statement string? :reference string?))
+

 (defn prepare-add
   "Save current add-method and show add form."


CMR-2253 Fixes example record for round trip tests.

--- umm-spec-lib/src/cmr/umm_spec/test/expected_conversion.clj
+++ umm-spec-lib/src/cmr/umm_spec/test/expected_conversion.clj
@@ -72,10 +72,10 @@
                                        :NumberOfOrbits 2.0
                                        :StartCircularLatitude 50.0}}
      :TilingIdentificationSystem {:TilingIdentificationSystemName "Tiling System Name"
-                                  :Coordinate1 {:MinimumValue 1
-                                                :MaximumValue 10}
-                                  :Coordinate2 {:MinimumValue 1
-                                                :MaximumValue 10}}
+                                  :Coordinate1 {:MinimumValue 1.0
+                                                :MaximumValue 10.0}
+                                  :Coordinate2 {:MinimumValue 1.0
+                                                :MaximumValue 10.0}}
      :AccessConstraints {:Description "Restriction Comment: Access constraints"
                          :Value "0"}
      :UseConstraints "Restriction Flag: Use constraints"


Whoops, fix initial bot state

Whoops, fix initial bot state

--- src/braid/core/client/bots/views/bots_page.cljs
+++ src/braid/core/client/bots/views/bots_page.cljs
@@ -118,7 +118,7 @@
         admin? (subscribe [:current-user-is-group-admin?] [group-id])
         dragging? (r/atom false)
         error (r/atom nil)
-        new-bot (r/atom nil)
+        new-bot (r/atom {})
         state (r/atom :initial)
         bot-valid? (reaction (and
                                (and (string? (@new-bot :name))


Refactoring jenkins-api module: filter for preview, stage, and prod jobs

--- src/emender_jenkins/jenkins_api.clj
+++ src/emender_jenkins/jenkins_api.clj
@@ -59,11 +59,17 @@
                 (get data "jobs")
                 nil))))

+(defn filter-test-jobs
+    [all-jobs preview-jobs-suffix stage-jobs-suffix prod-jobs-suffix]
+    (filter #(or (.endsWith (get %1 "name") preview-jobs-suffix)
+                 (.endsWith (get %1 "name") stage-jobs-suffix)
+                 (.endsWith (get %1 "name") prod-jobs-suffix))
+            all-jobs))
+
 (defn read-list-of-test-jobs
-    [jenkins-url job-list-part suffix]
-     (let [all-jobs (read-list-of-all-jobs jenkins-url job-list-part)
-           test-jobs (filter #(.endsWith (get %1 "name") suffix) all-jobs)]
-           test-jobs))
+    [jenkins-url job-list-part preview-jobs-suffix stage-jobs-suffix prod-jobs-suffix]
+    (-> (read-list-of-all-jobs jenkins-url job-list-part)
+        (filter-test-jobs preview-jobs-suffix stage-jobs-suffix prod-jobs-suffix)))

 (defn read-job-results
     [jenkins-url job-name]