refactoring remote connection capabilities (#303)

--- src/etaoin/api.clj
+++ src/etaoin/api.clj
@@ -3146,29 +3146,11 @@
   `run-driver` and `connect-driver` may accept."
   ([type]
    (boot-driver type {}))
-  ([type opt]
-   (-> type
-       (create-driver opt)
-       (run-driver opt)
-       (connect-driver opt))))
-
-(defn boot-driver-remote
-  "Two-in-one: creates a driver, and creates a new
-  session. Returns the driver instance.
-
-  Arguments:
-
-  - `type` a keyword determines a driver type.
-
-  - `opt` a map of all possible parameters that `create-driver`,
-  `connect-driver` may accept."
-  ([type]
-   (boot-driver-remote type {}))
-  ([type opt]
-   (-> type
-       (create-driver opt)
-       (connect-driver opt))))
-
+  ([type {host :host :as opt}]
+   (cond-> type
+     true       (create-driver opt)
+     (not host) (run-driver opt)
+     true       (connect-driver opt))))

 (defn quit
   "Closes the current session and stops the driver."
@@ -3305,131 +3287,3 @@
   `(with-driver :edge (assoc ~opt :headless true) ~bind
      ~@body))

-;; remote section
-
-(def firefox-remote
-  "Connects to a remote Firefox driver. A shortcut for `boot-driver-remote`."
-  (partial boot-driver-remote :firefox))
-
-(def edge-remote
-  "Connects to a remote Edge driver. A shortcut for `boot-driver-remote`."
-  (partial boot-driver-remote :edge))
-
-(def chrome-remote
-  "Connects to a remote Chrome driver. A shortcut for `boot-driver-remote`."
-  (partial boot-driver-remote :chrome))
-
-(def phantom-remote
-  "Connects to a remote Phantom.js driver. A shortcut for `boot-driver-remote`."
-  (partial boot-driver-remote :phantom))
-
-(def safari-remote
-  "Connects to a remote Safari driver. A shortcut for `boot-driver-remote`."
-  (partial boot-driver-remote :safari))
-
-(defn chrome-headless-remote
-  "Connects to a remote headless Chrome driver. A shortcut for `boot-driver-remote`."
-  ([]
-   (chrome-headless-remote {}))
-  ([opt]
-   (boot-driver-remote :chrome (assoc opt :headless true))))
-
-(defn firefox-headless-remote
-  "Connects to a remote headless Firefox driver. A shortcut for `boot-driver-remote`."
-  ([]
-   (firefox-headless-remote {}))
-  ([opt]
-   (boot-driver-remote :firefox (assoc opt :headless true))))
-
-(defn edge-headless-remote
-  "Connects to a remote headless Edge driver. A shortcut for `boot-driver-remote`."
-  ([]
-   (edge-headless-remote {}))
-  ([opt]
-   (boot-driver-remote :edge (assoc opt :headless true))))
-
-(defmacro with-driver-remote
-  "Performs the body within a driver session.
-
-  Connects to remote a driver of a given type. Binds the driver instance to a
-  passed `bind` symbol. Executes the body once the driver has
-  connected. Disconnect the driver finally (even if an exception
-  occurred).
-
-  Arguments:
-
-  - `type` is a keyword what driver type to start.
-
-  - `opt` is a map with driver's options. See `boot-driver-remote` for more
-  details.
-
-  - `bind` is a symbol to bind a driver reference.
-
-  Example:
-
-  (with-driver-remote :firefox {} driver
-    (go driver \"http://example.com\"))
-  "
-  [type opt bind & body]
-  `(client/with-pool {}
-     (let [~bind (boot-driver-remote ~type ~opt)]
-       (try
-         ~@body
-         (finally
-           (disconnect-driver ~bind))))))
-
-(defmacro with-firefox-remote
-  "Performs the body with Firefox session. A shortcut for
-  `with-driver-remote`."
-  [opt bind & body]
-  `(with-driver-remote :firefox ~opt ~bind
-     ~@body))
-
-(defmacro with-chrome-remote
-  "Performs the body with Chrome session. A shortcut for
-  `with-driver-remote`."
-  [opt bind & body]
-  `(with-driver-remote :chrome ~opt ~bind
-     ~@body))
-
-(defmacro with-edge-remote
-  "Performs the body with Edge session. A shortcut for
-  `with-driver-remote`."
-  [opt bind & body]
-  `(with-driver-remote :edge ~opt ~bind
-     ~@body))
-
-(defmacro with-phantom-remote
-  "Performs the body with Phantom.js session. A shortcut for
-  `with-driver-remote`."
-  [opt bind & body]
-  `(with-driver-remote :phantom ~opt ~bind
-     ~@body))
-
-(defmacro with-safari-remote
-  "Performs the body with Safari session. A shortcut for
-  `with-driver-remote`."
-  [opt bind & body]
-  `(with-driver-remote :safari ~opt ~bind
-     ~@body))
-
-(defmacro with-chrome-headless-remote
-  "Performs the body with headless Chrome session. A shortcut for
-  `with-driver-remote`."
-  [opt bind & body]
-  `(with-driver-remote :chrome (assoc ~opt :headless true) ~bind
-     ~@body))
-
-(defmacro with-firefox-headless-remote
-  "Performs the body with headless Firefox session. A shortcut for
-  `with-driver-remote`."
-  [opt bind & body]
-  `(with-driver-remote :firefox (assoc ~opt :headless true) ~bind
-     ~@body))
-
-(defmacro with-edge-headless-remote
-  "Performs the body with headless Edge session. A shortcut for
-  `with-driver-remote`."
-  [opt bind & body]
-  `(with-driver-remote :edge (assoc ~opt :headless true) ~bind
-     ~@body))


Make sure spec is compiled

Make sure spec is compiled

--- src/time_tracker/timers/pubsub/middleware.clj
+++ src/time_tracker/timers/pubsub/middleware.clj
@@ -4,7 +4,8 @@
             [time-tracker.timers.pubsub.io :as io]
             [clojure.spec :as s]
             [time-tracker.db :as db]
-            [time-tracker.timers.db :as timers-db]))
+            [time-tracker.timers.db :as timers-db]
+            [time-tracker.timers.spec]))

 (defn wrap-exception
   [func]


Print stack trace on console when an exception is raised.

--- frontend/src/uxbox/main/ui.cljs
+++ frontend/src/uxbox/main/ui.cljs
@@ -52,6 +52,7 @@
   "A default error handler."
   [{:keys [status] :as error}]
   (js/console.error "on-error:" (pr-str error))
+  (js/console.error (.-stack error))
   (reset! st/loader false)
   (cond
     ;; Unauthorized or Auth timeout


new specials in prop

new specials in prop

--- src/latte/prop.clj
+++ src/latte/prop.clj
@@ -335,6 +335,19 @@
     (have a C :by (H1 x))
     (qed a)))

+(defspecial or-intro-left%
+  "Left introduction for disjunction, a special version of [[or-intro-left]]."
+  [def-env ctx left-type right-term]
+  (when-not (ty/proper-type? def-env ctx left-type)
+    (throw (ex-info "Not a type." {:special 'latte.prop/or-intro-left%
+                                   :term left-type})))
+  (let [[status right-type] (ty/type-of-term def-env ctx right-term)]
+    (when (= status :ko)
+      (throw (ex-info "Cannot type term." {:special 'latte.prop/or-intro-left%
+                                           :term right-term
+                                           :from right-type})))
+    [(list #'or-intro-left left-type right-type) right-term]))
+
 (defthm or-intro-right
   "Introduction rule for logical disjunction.
 This is the introduction by the right operand."
@@ -350,6 +363,19 @@
            H2 (==> B C)]
     (have a C :by (H2 y))
     (qed a)))
+
+(defspecial or-intro-right%
+  "Right introduction for disjunction, a special version of [[or-intro-right]]."
+  [def-env ctx left-term right-type]
+  (when-not (ty/proper-type? def-env ctx right-type)
+    (throw (ex-info "Not a type." {:special 'latte.prop/or-intro-right%
+                                   :term right-type})))
+  (let [[status left-type] (ty/type-of-term def-env ctx left-term)]
+    (when (= status :ko)
+      (throw (ex-info "Cannot type term." {:special 'latte.prop/or-intro-right%
+                                           :term left-term
+                                           :from left-type})))
+    [(list #'or-intro-right left-type right-type) left-term]))

 (defthm or-elim
   "Elimination rule for logical disjunction.


[subcat 2] = ()

[subcat 2] = ()

--- src/babel/italiano/lexicon.cljc
+++ src/babel/italiano/lexicon.cljc
@@ -54,7 +54,8 @@
     {:synsem {:cat :prep
               :sem {:pred :in}
               :subcat {:1 {:cat :noun
-                           :sem {:city true}}}}}
+                           :sem {:city true}}
+                       :2 '()}}}

     ;; "a mezzogiorno"
     {:synsem {:cat :prep


[up] Add parse-int func.

[up] Add parse-int func.

--- src/ombs/funcs.clj
+++ src/ombs/funcs.clj
@@ -11,3 +11,6 @@
   [x] (if-not (vector? x)
         (conj [] x)
         x))
+
+(defn parse-int [s]
+   (when-let [r (re-find  #"\d+" s )] (Integer. r)))


Revert "Delete WrapperComponent functionality"

This reverts commit bda7716ba29e1ae8b8fc2ae066d1d1cc0c76e0cf.

--- src/quiescent.cljs
+++ src/quiescent.cljs
@@ -49,6 +49,51 @@
     (fn [value & static-args]
       (react-component #js {:value value :statics static-args}))))

+(def WrapperComponent
+  "Wrapper component used to mix-in lifecycle access"
+  (.createClass js/React
+     #js {:render
+          (fn [] (this-as this (aget (.-props this) "wrappee")))
+          :componentDidUpdate
+          (fn [prev-props prev-state node]
+            (this-as this
+              (when-let [f (aget (.-props this) "onUpdate")]
+                (binding [*component* this]
+                  (f node)))))
+          :componentDidMount
+          (fn [node]
+            (this-as this
+              (when-let [f (aget (.-props this) "onMount")]
+                       (f node))))}))
+
+(defn on-update
+  "Wrap a component, specifying a function to be called on the
+  componentDidUpdate lifecycle event.
+
+  The function will be passed the rendered DOM node."
+  [child f]
+  (WrapperComponent #js {:wrappee child
+                         :onUpdate f}))
+
+(defn on-initial-render
+  "Wrap a component, specifying a function to be called on the
+  componentDidMount lifecycle event.
+
+  The function will be passed the rendered DOM node."
+  [child f]
+  (WrapperComponent #js {:wrappee child
+                         :onMount f}))
+
+(defn on-render
+  "Wrap a component, specifying a function to be called on the
+  componentDidMount AND the componentDidUpdate lifecycle events.
+
+  The function will be passed the rendered DOM node."
+  [child f]
+  (WrapperComponent #js {:wrappee child
+                         :onUpdate f
+                         :onMount f}))
+
 (defn render
   "Given a ReactJS component, immediately render it, rooted to the
   specified DOM node."


Working class parsing.

Working class parsing.

--- src/refac/core.clj
+++ src/refac/core.clj
@@ -1,13 +1,21 @@
 (ns refac.core
   (:gen-class)
   (use clojure.java.io)
-  (use refac.io))
+  (use refac.io)
+  (:require [clojure.string :as str]))

-(def visibility-keywords
-  #{"private"
-    "public"
-    "protected"
-    "internal"})
+(defn goto-state
+  ([context state] (assoc-in context [:state :current] state)))
+
+(defn goto-state-with
+  ([context state arg]
+    (-> context
+        (assoc-in [:state :current] state)
+        (assoc-in [:state :arg] arg))))
+
+(defn state-arg [context]
+  (let [arg (context :state :arg)]
+    [arg (assoc context [:state :arg] nil)]))

 (defn handle-namespace [namespace symbol]
   (case symbol
@@ -16,40 +24,81 @@
         [false (if (nil? symbol)
                  (list symbol)
                  (cons symbol namespace))]
-        ))
+    ))

 (defn handle-package [context symbol]
-  (let [[complete namespace] (handle-namespace (context :namespace) symbol)]
+  (let [[complete namespace] (handle-namespace (get-in context [:class :namespace]) symbol)]
     (if complete
-      (assoc context :mode "init"
-                     :namespace namespace)
-      (assoc context :namespace namespace))))
+      (-> context
+          (goto-state "base")
+          (assoc-in [:class :namespace] namespace))
+    (assoc-in context [:class :namespace] namespace))))

 (defn handle-import [context symbol]
   (if (= ";" symbol)
-    (assoc context :mode "init"))
-  context)
+    (goto-state context "base")
+    context))

-(defn next-handler [context symbol]
+(defn handle-class [context symbol]
   (case symbol
-    "package" (assoc context :mode "package")
-    "import"  (assoc context :mode "import")))
+    "{" (-> context
+            (assoc-in [:class :body] {})
+            (goto-state "class-body"))
+    (-> context
+        (assoc-in [:class :name] symbol)
+        (assoc-in [:class :visability] (get-in context [:state :arg]))
+        (assoc-in [:state :arg] nil))))
+
+(defn handle-declaration [context symbol]
+    (case symbol
+      "class" (-> context (goto-state "class"))
+      (-> context (goto-state "type"))))
+
+(defn handle-class-body [context symbol]
+  (case symbol
+    "}" (-> context (goto-state "base"))
+    (-> context (goto-state-with "declaration" symbol))))
+
+(defn handle-type [context symbol] context)
+
+(defn handle-base [context symbol]
+  (case symbol
+    ("class" "import" "package")                (goto-state context symbol)
+    ("private" "public" "protected" "internal") (goto-state-with context "declaration" symbol)
+    (throw IllegalStateException)))
+
+(def states
+  {"declaration"  handle-declaration
+   "base"         handle-base
+   "package"      handle-package
+   "import"       handle-import
+   "class"        handle-class
+   "type"         handle-type
+   "class-body"   handle-class-body})
+
+(defn state-for [arg]
+  (if (contains? states arg)
+    (states arg)
+    (throw (Exception. arg))))

 (defn handle-symbol [context symbol]
-  (let [mode (context :mode)]
-    (case mode
-      "init"    (next-handler   context symbol)
-      "package" (handle-package context symbol)
-      "import"  (handle-import  context symbol)
-      context)))
+  (let [state   (context :state)
+        current (state :current)
+        handler (state-for current)
+        next    (handler context symbol)]
+    (println next)
+    next))
+
+(defn initial-context [] {:state {:current "base" :arg nil}
+                          :class {:fields {}}})

 (defn process-symbols [symbols]
-  (reduce handle-symbol (hash-map :mode "init") symbols))
+  (reduce handle-symbol (initial-context) symbols))

 (defn -main
   [& args]
-  (println (process-symbols
-    (get-symbol-stream))))
+  (process-symbols
+    (get-symbol-stream)))


fixing broken test

fixing broken test

--- test/clj/tdd_trainer/routes/snapshot_test.clj
+++ test/clj/tdd_trainer/routes/snapshot_test.clj
@@ -11,10 +11,10 @@
 (deftest create-file-diffs
   (facts "about `process-changed-files`"
     (fact "should return the whole new file when the file is not in the cache"
-      (process-changed-files cache files) => [{:filename "thisFile.txt" :diff {:old nil :new ["this" "is" "the" "file"]}}]
+      (process-changed-files cache new-file) => [{:filename "thisFile.txt" :diff {:old nil :new ["this" "is" "the" "file"]}}]
       (provided
        (file-to-vector-of-lines "thisFile.txt") => ["this" "is" "the" "file"]))
     (fact "should return the diff when the file is already in the cache"
-      (process-changed-files cache existing-file) => [{:filename "thatFile.txt" :diff {:old [nil "the" "file"] :new [nil "is" "the" "file"]}}]
+      (process-changed-files cache existing-file) => [{:filename "thatFile.txt" :diff '(["the" "is"] ["file" "the"])}]
       (provided
        (file-to-vector-of-lines "thatFile.txt") => ["this" "is" "the" "file"]))))


implement Archives Interface

implement Archives Interface

--- src/clj/game/cards-hardware.clj
+++ src/clj/game/cards-hardware.clj
@@ -3,6 +3,22 @@
 (def cards-hardware
   {"Akamatsu Mem Chip"
    {:effect (effect (gain :memory 1)) :leave-play (effect (lose :memory 1))}
+
+   "Archives Interface"
+   {:events {:no-action {:effect (req (system-msg state :runner (str "may remove 1 card in Archives from the game instead of"
+                                                                     " accessing it by clicking on Archives Interface"))
+                                      (update! state side (assoc card :ai-active true)))
+                         :req (req (and run (= [:archives] (:server run)) (not current-ice)))}}
+    :abilities [{:req (req (and run (= [:archives] (:server run)) (not current-ice) (:ai-active card)))
+                 :effect (req (swap! state update-in [:corp :discard] #(map (fn [c] (assoc c :seen true)) %))
+                              (resolve-ability
+                                state side
+                                {:prompt "Choose a card in Archives to remove from the game instead of accessing"
+                                 :choices (req (:discard corp))
+                                 :msg (msg "remove " (:title target) " from the game")
+                                 :effect (req (move state :corp target :rfg)
+                                              (update! state side (dissoc (get-card state card) :ai-active)))}
+                               card nil))}]}

    "Astrolabe"
    {:effect (effect (gain :memory 1)) :leave-play (effect (lose :memory 1))


fix Medium and Nerve Agent to look for Hivemind when they have 0 counters

also tighten up the :req on the click ability so you can't use it after a full access run ends

--- src/clj/game/cards-programs.clj
+++ src/clj/game/cards-programs.clj
@@ -305,7 +305,7 @@
    {:events {:no-action {:req (req (and run
                                         (= (first (get-in @state [:run :server])) :rd)
                                         (not current-ice)
-                                        (and (:counter card) (> (:counter card) 0))))
+                                        (> (get-virus-counters state side card) 0)))
                          :effect (req (system-msg state :runner (str "may choose fewer than all additional R&D accesses"
                                                                      " by clicking on Medium"))
                                       (update! state side (assoc card :medium-active true)))}
@@ -314,7 +314,10 @@
                               :effect (effect (add-prop card :counter 1))}
              :pre-access {:req (req (and (= target :rd) (:medium-active card)))
                           :effect (effect (access-bonus (max 0 (dec (get-virus-counters state side (get-card state card))))))}}
-    :abilities [{:req (req (:medium-active card))
+    :abilities [{:req (req (and run
+                                (= (first (get-in @state [:run :server])) :rd)
+                                (not current-ice)
+                                (:medium-active card)))
                  :effect (effect (add-prop card :counter 1)
                                  (resolve-ability
                                    {:prompt "Choose how many additional R&D accesses to make"
@@ -330,7 +333,7 @@
    {:events {:no-action {:req (req (and run
                                         (= (first (get-in @state [:run :server])) :hq)
                                         (not current-ice)
-                                        (and (:counter card) (> (:counter card) 0))))
+                                        (> (get-virus-counters state side card) 0)))
                          :effect (req (system-msg state :runner (str "may choose fewer than all additional HQ accesses"
                                                                      " by clicking on Nerve Agent"))
                                       (update! state side (assoc card :nerve-active true)))}
@@ -339,7 +342,10 @@
                               :effect (effect (add-prop card :counter 1))}
              :pre-access {:req (req (and (= target :hq) (:nerve-active card)))
                           :effect (effect (access-bonus (max 0 (dec (get-virus-counters state side (get-card state card))))))}}
-    :abilities [{:req (req (:nerve-active card))
+    :abilities [{:req (req (and run
+                                (= (first (get-in @state [:run :server])) :hq)
+                                (not current-ice)
+                                (:nerve-active card)))
                  :effect (effect (add-prop card :counter 1)
                                  (resolve-ability
                                    {:prompt "Choose how many additional HQ accesses to make"


:lipstick: Cosmetic changes on app component.

--- frontend/src/uxbox/main/ui.cljs
+++ frontend/src/uxbox/main/ui.cljs
@@ -89,9 +89,8 @@

 (mf/defc app
   [props]
-  (let [route (mf/deref route-iref)
-        route-id (get-in route [:data :name])]
-    (case route-id
+  (let [route (mf/deref route-iref)]
+    (case (get-in route [:data :name])
       :auth/login (mf/element auth/login-page)
       :auth/register (auth/register-page)
       :auth/recovery-request (auth/recovery-request-page)


Add documentation markup for `quil.snippets.macro` namespace.

--- src/clj/quil/snippets/macro.clj
+++ src/clj/quil/snippets/macro.clj
@@ -2,43 +2,44 @@
   (:require [quil.util :as u]))

 (defmacro defsnippet
-  "Defines a snippet. Snippet is a smalll example of how to use specific
-  Quil function. Snippets used in Quil docs as well as they used for release
-  testing.
+  "Defines a snippet. A snippet is a small example showing how to use a specific
+  Quil function. Snippets are used in Quil docs and for release testing.

-  If snippet is intended for clj-only or cljs-only function - use reader conditionals
-  (https://clojure.org/reference/reader#_reader_conditionals) to define snippet only in
-  clj or cljs. Also you can use reader conditionals inside snippet itself if needed.
+  If a snippet is intended for a clj-only or cljs-only function, use reader conditionals
+  (https://clojure.org/reference/reader#_reader_conditionals) to define the snippet only in
+  clj or cljs. You can also use reader conditionals inside the snippet itself if needed.

-  If the snippet is not trivial and has multiple parts - it should have comments. These
-  comments will help Quil users to understand better what snippet does when they read
-  Quil API. Because standard clojure comments (the one that start with ;) are stripped in
-  macros instead comments should be added using (comment) macro. Like the following:
+  If the snippet is not trivial and has multiple parts it should have comments. These
+  comments will help Quil users to understand better what the snippet does when they read
+  the Quil API. Since standard clojure comments (the one that start with ;) are stripped in
+  macros, comments should be added using (comment) macro like this:

+  ```
   (comment \"Do foo bar\")
   (foo-bar 123)
+  ```

-  All (comment) forms will be converted into ';' comments when generating documentation.
+  All `(comment)` forms will be converted into `;` comments when generating the
+  documentation.

   Snippets are stored in https://github.com/quil/quil/tree/master/src/cljc/quil/snippets

   More info about snippets: https://github.com/quil/quil/wiki/Snippets

-  This macro works by storing its parts in a list quil.snippets.all-snippets/all-snippets
-  that later used to generate tests for release testing or generate documentation.
+  This macro works by storing its parts in a list [[quil.snippets.all-snippets/all-snippets]]
+  that is later used to generate tests for release testing or generate documentation.

-  Params:
-    name Name of snippet. Doesn't really matter, needs to be unique
-        in the current file. Good default name is the same as function
-        this snippets tests.
-    fns Name of the Quil function name that the snippet tests. Used to
-        to find all snippets for each function when generating documentation.
-        Supports a collection of names if snippet tests few related Quil
-        functions at the same time.
-    opts Map of extra options. Supported options:
-      :renderer Renderer to use for snippet, if not default.
-      :setup Setup function to use. Default is empty.
-    body Body of draw function of the snippet."
+  Parameters:
+    * `name` - Name of snippet. Usually the same as the function
+               the snippet tests. Needs to be unique in the current file.
+    * `fns`  - Name of the Quil function that the snippet tests. Used to
+               to find all snippets for each function when generating documentation.
+               Supports a collection of names if snippet tests few related Quil
+               functions at the same time.
+    * `opts` - Map of extra options. Supported options:
+      - `:renderer` - Renderer to use for the snippet, if not default.
+      - `:setup`    - Setup function to use. Default is empty.
+    * `body` - The body of the `draw` function of the snippet."
   [snip-name fns opts & body]
   (let [setup (:setup opts '())
         mouse-clicked (:mouse-clicked opts '())]


Add guards for FOUC

Add guards for FOUC

--- src/cljs/hacker_agent/core.cljs
+++ src/cljs/hacker_agent/core.cljs
@@ -22,7 +22,7 @@
   (let [local (atom {:collapse-comments? false})]
     (fn [data]
       (let [{:keys [id by kids parent text type time score deleted]} data]
-        (when-not deleted
+        (when (and id (not deleted))
           [:ul
            [:li "ID: " [:a {:href (str "/#/items/" id)} id]]
            [:li "Parent: " [:a {:href (str "/#/items/" parent)} parent]]
@@ -41,21 +41,22 @@
                      :collapse-comments? false})]
     (fn [data]
       (let [{:keys [id by title kids type time url score]} data]
-        (if (:collapse? @local)
-          [:p {:on-click #(swap! local update-in [:collapse?] not)} title]
-          [:ul
-           [:li "ID: " id]
-           [:li {:on-click #(swap! local update-in [:collapse?] not)} title]
-           [:li "URL: " url]
-           [:li "Score: " score]
-           [:li "By: " by]
-           [:li "Time: " time]
-           (when kids
-             [:li [:span {:on-click #(swap! local update-in [:collapse-comments?] not)}
-                   "Comments: "]
-              (when-not (:collapse-comments? @local)
-                (for [[id sub-data] (vec kids)]
-                  ^{:key id} [comment sub-data]))])])))))
+        (when id
+          (if (:collapse? @local)
+            [:p {:on-click #(swap! local update-in [:collapse?] not)} title]
+            [:ul
+             [:li "ID: " id]
+             [:li {:on-click #(swap! local update-in [:collapse?] not)} title]
+             [:li "URL: " url]
+             [:li "Score: " score]
+             [:li "By: " by]
+             [:li "Time: " time]
+             (when kids
+               [:li [:span {:on-click #(swap! local update-in [:collapse-comments?] not)}
+                     "Comments: "]
+                (when-not (:collapse-comments? @local)
+                  (for [[id sub-data] (vec kids)]
+                    ^{:key id} [comment sub-data]))])]))))))

 (defn story-list-item [id]
   (let [data (base/id->atom id)]


no border for form-list-view form

no border for form-list-view form

--- src/cljs/swarmpit/material.cljs
+++ src/cljs/swarmpit/material.cljs
@@ -167,9 +167,10 @@
           (map-indexed
             (fn [index item]
               (table-row
-                #js {:key       (str "row" index)
-                     :rowNumber index
-                     :style     table-el-height}
+                #js {:key           (str "row" index)
+                     :rowNumber     index
+                     :displayBorder false
+                     :style         table-el-height}
                 (->> (keys item)
                      (map #(table-row-column
                              #js {:key   (str (name %) index)


GET needs some CORS love, too...

GET needs some CORS love, too...

--- src/cmr/graph/rest/response.clj
+++ src/cmr/graph/rest/response.clj
@@ -23,17 +23,13 @@

 (defn cors
   [request response]
-  (log/debug "Got request:" request)
-  (log/debug "Got response:" response)
-  (log/debug "Got request-method:" (:request-method request))
-  (if (= :options (:request-method request))
-    (do
-      (log/debug "Setting CORS response headers ...")
-      (-> response
-          (response/content-type "text/plain; charset=utf-8")
-          (response/header "Access-Control-Allow-Origin" "*")
-          (response/header "Access-Control-Allow-Methods" "POST, PUT, GET, DELETE, OPTIONS")
-          (response/header "Access-Control-Allow-Headers" "Content-Type")
-          (response/header "Access-Control-Max-Age" "2592000")
-          ((fn [x] (log/debug "New response:" x) x))))
+  (case (:request-method request)
+    :options (-> response
+                 (response/content-type "text/plain; charset=utf-8")
+                 (response/header "Access-Control-Allow-Origin" "*")
+                 (response/header "Access-Control-Allow-Methods" "POST, PUT, GET, DELETE, OPTIONS")
+                 (response/header "Access-Control-Allow-Headers" "Content-Type")
+                 (response/header "Access-Control-Max-Age" "2592000")
+                 ((fn [x] (log/debug "New response:" x) x)))
+    :get (response/header response "Access-Control-Allow-Origin" "*")
     response))


Fix gen lint issues

Fix gen lint issues

--- src/com/wsscode/pathom/gen.cljc
+++ src/com/wsscode/pathom/gen.cljc
@@ -6,7 +6,6 @@
     [clojure.walk :as walk]
     [com.fulcrologic.guardrails.core :refer [>def >defn >fdef => | <- ?]]
     [com.wsscode.pathom.core :as p]
-    [com.wsscode.pathom.misc :as p.misc]
     [com.wsscode.spec-inspec :as si]
     [fulcro.client.primitives :as fp]))

@@ -134,9 +133,7 @@
       {:appear #{} :res []}
       s)))

-(defn normalize-placeholders [{::p/keys [placeholder-prefixes]
-                               :or      {placeholder-prefixes #{">"}}
-                               :as      env}
+(defn normalize-placeholders [env
                               outer
                               inner]
   (if (map? inner)
@@ -277,7 +274,7 @@
   "Generates from a given component using spec generators for the attributes."
   ([comp]
    (comp->props {} comp))
-  ([{::keys [initialize] :as env :or {initialize true}} comp]
+  ([env comp]
    (->> (query->props env (fp/get-query comp))
         (comp-initialize env comp))))


cleanup cljs source map file

cleanup cljs source map file

--- src/main/cljs/cljs/source_map.cljs
+++ src/main/cljs/cljs/source_map.cljs
@@ -7,7 +7,8 @@
 ;   You must not remove this notice, or any other, from this software.

 (ns cljs.source-map
-  (:require [clojure.string :as string]
+  (:require [goog.object :as gobj]
+            [clojure.string :as string]
             [clojure.set :as set]
             [cljs.source-map.base64-vlq :as base64-vlq]))

@@ -55,11 +56,11 @@
   [seg source-map]
   (let [[gcol source line col name] seg]
    {:gcol   gcol
-    :source (aget (.split (aget source-map "sources" source) "?") 0)
+    :source (aget (.split (gobj/get source-map "sources" source) "?") 0)
     :line   line
     :col    col
     :name   (when-let [name (-> seg meta :name)]
-              (aget source-map "names" name))}))
+              (gobj/get source-map "names" name))}))

 (defn seg-combine
   "Combine a source map segment vector and a relative
@@ -100,38 +101,39 @@
   mapping original ClojureScript source locations to the generated
   JavaScript."
   ([source-map]
-     (decode-reverse (aget source-map "mappings") source-map))
+   (decode-reverse
+     (gobj/get source-map "mappings") source-map))
   ([mappings source-map]
-     (let [sources (aget source-map "sources")
-           relseg-init [0 0 0 0 0]
-           lines (seq (string/split mappings #";"))]
-       (loop [gline 0
-              lines lines
-              relseg relseg-init
-              result (sorted-map-by (source-compare sources))]
-         (if lines
-           (let [line (first lines)
+   (let [sources     (gobj/get source-map "sources")
+         relseg-init [0 0 0 0 0]
+         lines       (seq (string/split mappings #";"))]
+     (loop [gline  0
+            lines  lines
+            relseg relseg-init
+            result (sorted-map-by (source-compare sources))]
+       (if lines
+         (let [line (first lines)
+               [result relseg]
+               (if (string/blank? line)
                  [result relseg]
-                 (if (string/blank? line)
-                   [result relseg]
-                   (let [segs (seq (string/split line #","))]
-                     (loop [segs segs relseg relseg result result]
-                       (if segs
-                         (let [seg (first segs)
-                               nrelseg (seg-combine (base64-vlq/decode seg) relseg)]
-                           (recur (next segs) nrelseg
-                             (update-reverse-result result (seg->map nrelseg source-map) gline)))
-                         [result relseg]))))]
-             (recur (inc gline) (next lines) (assoc relseg 0 0) result))
-           result)))))
+                 (let [segs (seq (string/split line #","))]
+                   (loop [segs segs relseg relseg result result]
+                     (if segs
+                       (let [seg (first segs)
+                             nrelseg (seg-combine (base64-vlq/decode seg) relseg)]
+                         (recur (next segs) nrelseg
+                           (update-reverse-result result (seg->map nrelseg source-map) gline)))
+                       [result relseg]))))]
+           (recur (inc gline) (next lines) (assoc relseg 0 0) result))
+         result)))))

 (defn update-result
   "Helper for decode. Take a source map and update it based on a
   segment map."
   [result segmap gline]
   (let [{:keys [gcol source line col name]} segmap
-        d {:line line
-           :col col
+        d {:line   line
+           :col    col
            :source source}
         d (if name (assoc d :name name) d)]
     (update-in result [gline]
@@ -145,11 +147,11 @@
   generated JavaScript source locations to the original
   ClojureScript."
   ([source-map]
-     (decode (aget source-map "mappings") source-map))
+     (decode (gobj/get source-map "mappings") source-map))
   ([mappings source-map]
-     (let [sources (aget source-map "sources")
+     (let [sources     (gobj/get source-map "sources")
            relseg-init [0 0 0 0 0]
-           lines (seq (string/split mappings #";"))]
+           lines       (seq (string/split mappings #";"))]
        (loop [gline 0 lines lines relseg relseg-init result {}]
          (if lines
            (let [line (first lines)
@@ -159,7 +161,7 @@
                    (let [segs (seq (string/split line #","))]
                      (loop [segs segs relseg relseg result result]
                        (if segs
-                         (let [seg (first segs)
+                         (let [seg     (first segs)
                                nrelseg (seg-combine (base64-vlq/decode seg) relseg)]
                            (recur (next segs) nrelseg
                              (update-result result (seg->map nrelseg source-map) gline)))


add urls to top nav links

add urls to top nav links

--- frontend/components/common.cljs
+++ frontend/components/common.cljs
@@ -171,11 +171,10 @@
    [:nav.outer-nav
     [:a.logo-circleci {:on-click #(raise! owner [:home-scroll-logo-clicked])}
      [:figure circle-logo]]
-    [:a "Pricing"]
-    [:a "Docs"]
-    [:a "About"]
-    [:a "Blog"]
-    [:a "Contact"]
+    [:a {:href "/about"} "About"]
+    [:a {:href "/pricing"} "Pricing"]
+    [:a {:href "/docs"} "Docs"]
+    [:a {:href "http://blog.circleci.com"} "Blog"]
     [:a.login {:href (auth-url)
                :on-click #(raise! owner [:track-external-link-clicked
                                          {:event "Auth GitHub"
@@ -188,8 +187,7 @@
                                           {:event "Auth GitHub"
                                            :properties {:source "header-cta"}
                                            :path (auth-url)}])}
-     "Sign Up Free"]
-    ]))
+     "Sign Up Free"]]))

 (defn footer []
   (html [:div.home-footer


Fix version again

Fix version again

--- example/project.clj
+++ example/project.clj
@@ -8,7 +8,7 @@
                  [org.clojure/clojurescript "0.0-3308"]]

   :plugins [[lein-cljsbuild "1.0.5"]
-            [lein-doo "0.1.0-SNAPSHOT"]]
+            [lein-doo "0.1.1-SNAPSHOT"]]

   :clean-targets ^{:protect false} [:target-path "resources/public/js/"]


2_1_4

--- src/sicp_tasks_on_clojure/chapter2_1_4.clj
+++ src/sicp_tasks_on_clojure/chapter2_1_4.clj
@@ -1,4 +1,4 @@
-(ns sicp-tasks-on-clojure.chapter2-1-1)
+(ns sicp-tasks-on-clojure.chapter2-1-4)

 (defrecord interval [min max])


More work for retracts

More work for retracts

and I'm quite sure I did something wrong...

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

--- src/conexp/contrib/retracts.clj
+++ src/conexp/contrib/retracts.clj
@@ -1,6 +1,12 @@
 (ns #^{:doc "Package for computing retracts from formal contexts."}
   conexp.contrib.retracts
-  (:use [conexp.fca.contexts]))
+  (:use [conexp :only (concepts,
+		       objects, object-derivation,
+		       attributes, attribute-derivation,
+		       compatible-subcontexts,
+		       restrict-concept,
+		       make-context,
+		       set-of)]))

 (defn homomorphism-by-csc
   "Returns the homomorphisms obtained by resticting every concept to the
@@ -10,46 +16,72 @@
     (restrict-concept concept subcontext)))

 (defn homomorphisms-by-cscs
-  "Returns all homomorphisms originating from compatible subcontexts."
+  "Returns all homomorphisms originating from compatible
+  subcontexts. context has to be reduced."
   [context]
   (map homomorphism-by-csc (compatible-subcontexts context)))

-(defn endofunctions-as-hash
+(defn endofunctions-as-hash ; name is misleading
   "Given a homomorphisms which has been obtained by a compatible
   subcontext this function computes a hash representing all
   endofunctions of context originating from this homomorphism. The
   result may be thought of as a \"multifunction\"."
   [context hom]
   (reduce (fn [hash concept]
-	    (assoc hash (hom concept) concept))
+	    (assoc hash (hom concept)
+		   (conj (hash (hom concept)) concept)))
 	  {}
 	  (concepts context)))

-(defn endofunctions-from-hash
+(defn endofunctions-from-hash ; name is misleading
   "Computes all endofunctions (as a hash) in endo-hash."
   [endo-hash]
-; alle einzelnen Endofunktionen aus endo-hash nacheinander extrahieren
-  nil)
+  (let [runner (fn runner [func rem]
+		 (if (empty? rem)
+		   [func]
+		   (let [[preimg imgs] (first rem)]
+		     (for [img imgs,
+			   fun (runner (assoc func preimg img)
+				       (rest rem))]
+		       fun))))]
+    (runner {} (seq endo-hash))))

-(defn endofunctions-by-homomorphism
+(defn endofunctions-by-homomorphism ; name is misleading
   "Returns all endofunctions obtained by homomorphism."
   [context hom]
   (endofunctions-from-hash (endofunctions-as-hash context hom)))

 (defn retract?
   "Tests whether given concept endofunction, given as hash-map, is a
-  retract of context."
+  retract of context or not."
   [context endo]
-; Begriffe zählen, um Retraktionen zu erhalten
-  nil)
+  (let [zero-concept [(objects context),
+		      (object-derivation context (objects context))]
+	one-concept  [(attribute-derivation context (attributes context)),
+		      (attributes context)]]
+    (and (= zero-concept (endo zero-concept))
+	 (= one-concept (endo one-concept))
+	 (let [imgs (vals endo)
+	       img-ctx (make-context (objects context)
+				     (attributes context)
+				     (set-of [g m] [[objs atts] imgs,
+						    g objs,
+						    m atts]))]
+	   (= (count (concepts context))
+	      (count (concepts img-ctx)))))))

 (defn retracts
   "Returns all retracts of context as computed by the algorithm of
   Felix Kästner."
   [context]
-  (for [hom (homomorphisms-by-cscs context)
-	endo (endofunctions-by-homomorphism context hom)
-	:when (retract? endo)]
-    endo))
+  (binding [concepts (memoize concepts)]
+    (let [concepts (concepts context)]
+      (for [hom (homomorphisms-by-cscs context)
+	    endo (endofunctions-by-homomorphism context hom)
+	    :let [ret (apply hash-map
+			     (interleave concepts
+					 (map (comp endo hom) concepts)))]
+	    :when (retract? context ret)]
+	ret))))

-nil
+nil


Removed obsolete reference to «extended-iceberg-intent-seq»

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

--- src/conexp/fca/implications.clj
+++ src/conexp/fca/implications.clj
@@ -402,7 +402,7 @@
   for minimal support minsupp and minimal confidence minconf."
   ;; UNTESTED!
   [context minsupp minconf]
-  (let [closures (set (extended-iceberg-intent-seq context minsupp))]
+  (let [closures (frequent-pseudoclosed-itemsets context minsupp)]
     (set-of impl
             [B_1 closures,
              B_2 closures,


make sure animation works

make sure animation works

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

--- plugins/SlideExplorer2/src/slide_explorer/canvas.clj
+++ plugins/SlideExplorer2/src/slide_explorer/canvas.clj
@@ -299,7 +299,7 @@
 (defn canvas [reference]
   (let [panel (proxy [JPanel] []
                 (paintComponent [^Graphics graphics]
-                                ;(proxy-super paintComponent graphics)
+                                (proxy-super paintComponent graphics)
                                 (draw graphics @reference)))]
     (add-watch reference panel (fn [_ _ _ _]
                                  (.repaint panel)))
@@ -325,7 +325,7 @@
     (Thread/sleep 30)
     (swap! reference (fn [data]
                        (-> data
-                           (assoc-in [0 1 :rotate] (* i 15))
+                           (assoc-in [1 1 :rotate] (* i 15))
                            ))
            )))


displaying the screenshots from the local images directory

--- src-cljs/bitfondue/core.cljs
+++ src-cljs/bitfondue/core.cljs
@@ -17,7 +17,10 @@
 (defn chunk-card
   [chunk]
   [:div.col-sm-4
-   [:div.card.card-block
+   [:img.card-img-top {:src (str "/images/"
+                                 (:uid chunk)
+                                 ".png")}]
+   [:div.card.card-block.chunk-content
     [:h4.card-title (let [character-max-length 20]
                       (if (> character-max-length (count (:title chunk)))
                         (:title chunk)


add submit chat learning to state

add submit chat learning to state

--- src-cljs/frontend/state.cljs
+++ src-cljs/frontend/state.cljs
@@ -13,6 +13,7 @@
    :newdoc-button-learned false
    :main-menu-learned false
    :chat-button-learned false
+   :chat-submit-learned false
    :login-button-learned false})

 (def subscriber-bot
@@ -118,6 +119,8 @@

 (def chat-button-learned-path (conj browser-settings-path :chat-button-learned))

+(def chat-submit-learned-path (conj browser-settings-path :chat-submit-learned))
+
 (defn doc-settings-path [doc-id]
   (conj browser-settings-path :document-settings doc-id))


(maint) restructure to use a tail-threading macro

This code reads better if we use the tail-threading macro rather than a
redundant binding.

--- src/puppetlabs/pcp/broker/core.clj
+++ src/puppetlabs/pcp/broker/core.clj
@@ -447,8 +447,8 @@
                                               (capsule/summarize capsule)
                                               {:type :connection-message})
                                 "Message {messageid} for {destination} from {commonname} {remoteaddress}")
-                     (let [next (determine-next-state broker capsule connection)]
-                       (swap! (:connections broker) assoc ws next))))
+                     (->> (determine-next-state broker capsule connection)
+                          (swap! (:connections broker) assoc ws))))
                  (catch map? m
                    ;; This is a processing error, say an uncaught exception in any of the stuff we meant to do
                    (send-error-message message (str "Error " (:type m) " handling message: " (:message &throw-context)) connection))))


Add a bunch of features - sending, etc.

Add a bunch of features - sending, etc.

--- src/sns_beanstalk_chat/handler.clj
+++ src/sns_beanstalk_chat/handler.clj
@@ -7,65 +7,73 @@
             [eulalie.creds]
             [eulalie.instance-data :as instance-data]
             [fink-nottle.sns :as sns]
+            [fink-nottle.sns.consume :as sns.consume]
             [org.httpkit.client :as http.client]
             [org.httpkit.server :as http])
   (:gen-class))

-(defmulti handle-sns-request
-  (fn [{{:strs [x-amz-sns-message-type]} :headers}]
-    x-amz-sns-message-type))
-(defmethod handle-sns-request "SubscriptionConfirmation" [{:keys [body] :as req}]
-  (clojure.pprint/pprint req)
-  (-> body :SubscribeURL http.client/get))
-(defmethod handle-sns-request "Message" [{:keys [body topic-chan] :as req}]
-  (clojure.pprint/pprint req)
-  (async/put! topic-chan (:Message body)))
+(defn make-post-handler [{region :region} {chan :sns-incoming}]
+  (fn [{:keys [body] :as req}]
+    (go
+      (let [{:keys [type] :as m} (sns.consume/stream->message body)]
+        (when (<! (sns.consume/verify-message! m region))
+          (http/close req)
+          (case type
+            :subscription-confirmation (http.client/get (:subscribe-url m))
+            :message (async/put! chan (:message m))))))))

-(defn handle-topic-post [{:keys [body] :as req}]
-  (-> req
-      (assoc :body (-> body
-                       (io/reader :encoding "UTF-8")
-                       (json/parse-stream true)))
-      handle-sns-request))
+(defn make-get-handler [_ {mult :sns-incoming-mult out-chan :sns-outgoing}]
+  (fn [req]
+    (let [to-client (async/chan)]
+      (async/tap mult to-client)
+      (http/with-channel req handle
+        (http/on-receive handle #(async/put! out-chan %))
+        (async/go-loop []
+          (when-let [value (<! to-client)]
+            (if (http/send! handle value)
+              (recur)
+              (async/close! to-client))))))))

-(defn handle-topic-get [{:keys [topic-mult] :as req}]
-  (let [out-chan (async/chan)]
-    (async/tap topic-mult out-chan)
-    (http/with-channel req handle
-      (async/go-loop []
-        (when-let [value (<! out-chan)]
-          (if (http/send! handle value)
-            (recur)
-            (async/close! out-chan)))))))
+(defn make-app [config state]
+  (cj/routes
+   (cj/POST "/topic/events" [] (make-post-handler config state))
+   (cj/GET  "/topic/events" [] (make-get-handler  config state))))

-(defn topic-middleware [handler topic mult]
-  (fn [req] (handler (assoc req
-                            :topic-chan topic
-                            :topic-mult mult))))
-
-(defn make-app [channel]
-  (->
-   (cj/routes
-    (cj/POST "/topic/events" [] handle-topic-post)
-    (cj/GET  "/topic/events" [] handle-topic-get))
-   (topic-middleware channel (async/mult channel))))
+(defn sns-publish! [creds topic-arn msg-chan]
+  (async/go-loop []
+    (when-let [message (<! msg-chan)]
+      (<! (sns/publish-topic! creds topic-arn message))
+      (recur))))

 (defn subscribe-sns!! [creds this-address topic-name]
   (let [topic-arn  (sns/create-topic!! creds topic-name)
-        endpoint   (str "http://" this-address "/topic/events")
-        subs-arn   (sns/subscribe!! creds topic-arn :http endpoint)]
-    (log/info (pr-str {:event :subscribe-sns
-                       :data [topic-arn endpoint subs-arn]}))
-    subs-arn))
+        endpoint   (str "http://" this-address "/topic/events")]
+    {:topic-arn topic-arn
+     :subscription-arn (sns/subscribe!! creds topic-arn :http endpoint)}))
+
+(defn get-creds!! []
+  (let [iam-role (instance-data/default-iam-role!!)
+        current  (atom (instance-data/iam-credentials!! iam-role))
+        creds    {:eulalie/type :refresh :current current}]
+    (eulalie.creds/periodically-refresh! current iam-role)
+    creds))

 (defn -main [& [topic]]
   (let [topic    (or topic :sns-demo-events)
-        iam-role (instance-data/default-iam-role!!)
-        current  (atom (instance-data/iam-credentials!! iam-role))
-        creds    {:eulalie/type :refresh :current current}]
-    (log/info (pr-str {:event :start :data {:role iam-role :creds creds :topic topic}}))
-    (eulalie.creds/periodically-refresh! current iam-role)
-    (let [hostname (instance-data/retrieve!! :public-hostname)
-          events      (async/chan)]
-      (http/run-server (make-app events) {:port 80})
-      (subscribe-sns!! creds hostname topic))))
+        creds    (get-creds!!)
+        sns-incoming (async/chan)
+        sns-outgoing (async/chan)]
+
+    (http/run-server
+     (make-app
+      {:topic topic :region (instance-data/identity-key!! :region)}
+      {:creds creds
+       :sns-incoming-mult (async/mult sns-incoming)
+       :sns-incoming sns-incoming
+       :sns-outgoing sns-outgoing}
+      {:port 80}))
+
+    (let [{:keys [topic-arn]}
+          (subscribe-sns!!
+           creds (instance-data/meta-data!! :public-hostname) topic)]
+      (sns-publish! creds topic-arn sns-outgoing))))


[lein] Add lein-kibit

[lein] Add lein-kibit

--- .lein/profiles.clj
+++ .lein/profiles.clj
@@ -4,6 +4,7 @@
                   [jonase/eastwood                   "0.2.3"]
                   [com.jakemccrary/lein-test-refresh "0.3.4"]
                   [lein-pprint                       "1.1.1"]
+                  [lein-kibit                        "0.1.2"]
                   [cider/cider-nrepl                 "0.12.0"]
                   [venantius/ultra                   "0.4.1"]]
         :signing {:gpg-key "E5B26621"}}}


CFY-6482- Execute workflow script

CFY-6482- Execute workflow script

--- resources/rest-service/cloudify/triggers/execute_workflow.clj
+++ resources/rest-service/cloudify/triggers/execute_workflow.clj
@@ -2,12 +2,13 @@
   [ctx]
     (let [deployment-id         (:deployment_id ctx)
           parameters            (:trigger-parameters ctx)
+          rest-token            "{{rest_api_token}}"
           rest-host             (or (System/getenv "REST_HOST") "127.0.0.1")
           rest-protocol         "https"
-          raw-rest-port         (or (System/getenv "REST_PORT") "80")
+          raw-rest-port         (or (System/getenv "REST_PORT") "53333")
           rest-port             (Integer/parseInt raw-rest-port)
-          verify-ssl-cert       false
-          base-uri              (str rest-protocol "://" rest-host ":" rest-port "/api/v2")
+          tenant-id             "{{tenant_id}}"
+          base-uri              (str rest-protocol "://" rest-host ":" rest-port "/api/v3")
           endpoint              (str "/executions")
           resource-uri          (str base-uri endpoint)
           body                  (cheshire.core/generate-string {
@@ -15,11 +16,23 @@
                                   :workflow_id             (:workflow parameters)
                                   :force                   (:force parameters)
                                   :allow_custom_parameters (:allow_custom_parameters parameters)
-                                  :parameters              (:workflow_parameters parameters)})]
-      (clj-http.client/post resource-uri
-        {:content-type   :json
-         :accept         :json
-         :socket-timeout (:socket_timeout parameters)
-         :conn-timeout   (:conn_timeout parameters)
-         :insecure?      (not verify-ssl-cert)
-         :body           body})))
+                                  :parameters              (:workflow_parameters parameters)})
+          execute-api-call      (fn [] (clj-http.client/post resource-uri
+                        {:content-type   :json
+                         :accept         :json
+                         :socket-timeout (:socket_timeout parameters)
+                         :conn-timeout   (:conn_timeout parameters)
+                         :headers {"API-Authentication-Token" rest-token
+                                   "Tenant" tenant-id}
+                         :trust-store "/etc/cloudify/ssl/cloudify_internal.p12"
+                         :trust-store-type "pkcs12"
+                         :trust-store-pass "cloudify"
+                         :body           body}))]
+    (try
+        (execute-api-call)
+        (catch Exception e
+             (error "Exception calling Cloudify API: " e)
+             (throw e)
+        )
+    )
+))


add main interactions to workspace-bar

add main interactions to workspace-bar

--- src/uxbox/ui/workspace/header.cljs
+++ src/uxbox/ui/workspace/header.cljs
@@ -35,6 +35,15 @@
        i/project-tree
        [:span (:name page)]]
       [:div.workspace-options
+       [:ul.options-btn
+        [:li.tooltip.tooltip-bottom {:alt "Undo (Ctrl + Z)"}
+         i/shapes]
+        [:li.tooltip.tooltip-bottom {:alt "Undo (Ctrl + Z)"}
+         i/puzzle]
+        [:li.tooltip.tooltip-bottom {:alt "Undo (Ctrl + Z)"}
+         i/icon-set]
+        [:li.tooltip.tooltip-bottom {:alt "Redo (Ctrl + Shift + Z)"}
+         i/layers]]
        [:ul.options-btn
         [:li.tooltip.tooltip-bottom {:alt "Undo (Ctrl + Z)"}
          i/undo]


Gen test for function parameterization.

Gen test for function parameterization.

--- test/onyx/generative/apply_fn_gen_test.clj
+++ test/onyx/generative/apply_fn_gen_test.clj
@@ -51,15 +51,14 @@
      (is (= input (map :root tree)))
      (is (= output (map :message (mapcat :leaves tree)))))))

-(deftest message-key-doesnt-get-overwritten
-  (let [input {:xxxxmessage 42}
-        f (fn [segment] {:output 30})
-        event {:onyx.core/batch [input]}
-        rets (t/apply-fn f false event)
-        tree (:tree (t/persistent-results! (:onyx.core/results rets)))]
-    (prn tree)))
-
-(clojure.pprint/pprint
- (t/persistent-results! (:onyx.core/results (t/apply-fn (fn [x] []) false {:onyx.core/batch [{:x 1} {:x 2}]}))))
-
-;;; BUG: key :message
+(deftest parameterized-functions
+  (checking
+   "Functions can be parameterized via the event map"
+   (times 30)
+   [input (gen/vector (gen/hash-map :message (gen/map gen/any gen/any)))
+    params (gen/vector gen/any)]
+   (let [f (fn [& args] {:result (or (butlast args) [])})
+         event {:onyx.core/batch input :onyx.core/params params}
+         rets (t/apply-fn f false event)
+         tree (:tree (t/persistent-results! (:onyx.core/results rets)))]
+     (is (every? (partial = params) (map :result (map :message (mapcat :leaves tree))))))))


Correção de texto

Correção de texto

--- test/metabase/api/session_test.clj
+++ test/metabase/api/session_test.clj
@@ -30,7 +30,7 @@
   (client :post 400 "session" (user->credentials :trashbird)))

 ;; Test for password checking
-(expect {:errors {:password "não coincide com a senha armazenada"}}
+(expect {:errors {:password "não coincide com a senha armazenada."}}
   (client :post 400 "session" (-> (user->credentials :rasta)
                                   (assoc :password "something else"))))


Fix handling of server crashes.

Fix handling of server crashes.

- Mistakenly thought could check for closed channel on writes.
- Did not get rid of stale channel in all shutdown scenarios.

--- src/afterglow/ola_client.clj
+++ src/afterglow/ola_client.clj
@@ -178,6 +178,8 @@
       (swap! connection disconnect-server))
 ))

+(declare shutdown)
+
 (defn- process-requests
   "Set up loops to read requests on our local channel and send them to the OLA server, and read its responses
   and  dispatch them to the proper handlers. Needs to be called in a future since it uses blocking reads from
@@ -215,8 +217,9 @@
             (swap! connection connect-server)
             (when-not @connection
               (error "Unable to reconnect to OLA server, shutting down ola_client")
-              (close! channel))))))
-    (info "OLA request processor terminating.")))
+              (shutdown))))))
+    (info "OLA request processor terminating.")
+    (shutdown)))

 (defn- create-channel
   [old-channel]
@@ -245,11 +248,6 @@
 (defn send-request
   "Send a request to the OLA server."
   [name message response-type response-handler]
-  (loop [retrying false]
-    (start)
-    (when-not (>!! @channel [name message response-type response-handler])
-      (shutdown)
-      (if retrying
-        (error "ola_client unable to connect to server, discarding" name message)
-        (recur true)))))
-
+  (start)
+  (>!! @channel [name message response-type response-handler]))
+


Ring middleware: Replace `my-request` with `make-my-request`

--- test/com/nomistech/clojure_the_language/c_800_libraries/s_800_web/ss_020_ring.clj
+++ test/com/nomistech/clojure_the_language/c_800_libraries/s_800_web/ss_020_ring.clj
@@ -27,7 +27,9 @@
 (defn identity-handler [request]
   request)

-(def my-request
+(defn make-my-request []
+  ;; This is a function rather than a var, so for each call the return value's
+  ;; `:body` stream can be consumed separately.
   {:headers {"content-type" "application/json; charset=utf-8"}
    :query-string "q1=a&q2=b"
    :body (string->stream "{\"user\":\"Fred\"}")})
@@ -35,27 +37,29 @@
 ;;;; ___________________________________________________________________________
 ;;;; ---- rmp/wrap-params ----

-(fact ((-> identity-handler
-           rmp/wrap-params)
-       my-request)
-  => (just (merge my-request
-                  {:body         anything
-                   :form-params  {}
-                   :params       {"q1" "a"
-                                  "q2" "b"}
-                   :query-params {"q1" "a"
-                                  "q2" "b"}})))
+(let [req (make-my-request)]
+  (fact ((-> identity-handler
+             rmp/wrap-params)
+         req)
+    => (just (merge req
+                    {:body         anything
+                     :form-params  {}
+                     :params       {"q1" "a"
+                                    "q2" "b"}
+                     :query-params {"q1" "a"
+                                    "q2" "b"}}))))

 ;;;; ___________________________________________________________________________
 ;;;; ---- rmj/wrap-json-params ----

-(fact ((-> identity-handler
-           rmj/wrap-json-params)
-       my-request)
-  => (just (merge my-request
-                  {:body        anything
-                   :json-params {"user" "Fred"}
-                   :params      {"user" "Fred"}})))
+(let [req (make-my-request)]
+  (fact ((-> identity-handler
+             rmj/wrap-json-params)
+         req)
+    => (just (merge req
+                    {:body        anything
+                     :json-params {"user" "Fred"}
+                     :params      {"user" "Fred"}}))))

 ;;;; ___________________________________________________________________________

@@ -102,8 +106,7 @@

 (fact "Wrapped handler with request whose body is JSON"
   (wrapped-handler-of-interesting-request
-   {:headers {"content-type" "application/json; charset=utf-8"}
-    :body (string->stream "{\"user\":\"Fred\"}")})
+   (make-my-request))
   => {:status 200
       :headers {}
       :body "Uploaded 'Fred'."})


Remove unnecessary fixpoints

Remove unnecessary fixpoints

--- src/aurora/runtime/core.cljs
+++ src/aurora/runtime/core.cljs
@@ -230,87 +230,87 @@
                                          (- done)
                                          (- editing))]

-                      :rules [[(rule {:name "todo" :id id}
-                                     {:name :todo/filter :value "all"}
-                                     (+ {:name :todo/displayed :id id}))
-                               (rule {:name "todo" :id id}
-                                     {:name :todo/filter :value v}
-                                     {:name "todo-done" :id id :done? v}
-                                     (+ {:name :todo/displayed :id id}))]
-
-                              [(rule {:name :todo/displayed :id id}
-                                     {:name "todo" :id id :text text :order order}
-                                     {:name "todo-done" :id id :done? done}
-                                     (= parent-id [id] (str "todo" id))
-                                     (= child-id [id] (str "todo-checkbox" id))
-                                     (+s [child-id id done]
-                                         (hiccup
-                                          [:input {:id child-id
-                                                   :event-key "todo-checkbox"
-                                                   :entity id
-                                                   :checked done
+                      :rules [(rule {:name "todo" :id id}
+                                    {:name :todo/filter :value "all"}
+                                    (+ {:name :todo/displayed :id id}))
+                              (rule {:name "todo" :id id}
+                                    {:name :todo/filter :value v}
+                                    {:name "todo-done" :id id :done? v}
+                                    (+ {:name :todo/displayed :id id}))
+
+                              (rule {:name :todo/displayed :id id}
+                                    {:name "todo" :id id :text text :order order}
+                                    {:name "todo-done" :id id :done? done}
+                                    (= parent-id [id] (str "todo" id))
+                                    (= child-id [id] (str "todo-checkbox" id))
+                                    (+s [child-id id done]
+                                        (hiccup
+                                         [:input {:id child-id
+                                                  :event-key "todo-checkbox"
+                                                  :entity id
+                                                  :checked done
+                                                  :events ["onChange"]
+                                                  :type "checkbox"}]))
+                                    (+ {:name :ui/child :id parent-id :child child-id :pos -1}))
+                              (rule {:name :todo/displayed :id id}
+                                    {:name "todo" :id id :text text :order order}
+                                    {:name "todo-editing" :id id :editing? "false"}
+                                    (+s [id text]
+                                        (hiccup
+                                         [:li {:id (str "todo" id) :entity id :event-key "todo" :events ["onDoubleClick"]}
+                                          text
+                                          [:button {:id (str "todo-remove" id) :style {:margin-left "10px"} :entity id :event-key "todo-remove" :events ["onClick"]} "x"]]))
+                                    (= child-id [id] (str "todo" id))
+                                    (+ {:name :ui/child :id "todo-list" :child child-id :pos order}))
+                              (rule {:name :todo/displayed :id id}
+                                    {:name "todo" :id id :text text :order order}
+                                    {:name "todo-editing" :id id :editing? "true"}
+                                    (+s [id text]
+                                        (hiccup
+                                         [:input {:id (str "todo-editor") :entity id :event-key "todo-editor" :defaultValue text :events ["onChange" "onKeyDown" "onBlur"]}]))
+                                    (+ {:name :ui/child :id "todo-list" :child "todo-editor" :pos order}))
+
+                              (rule {:name :todo/current-text :value v}
+                                    (+s []
+                                        (hiccup
+                                         [:input {:id "todo-input" :value v :event-key "todo-input" :events ["onChange" "onKeyDown"] :placeholder "What do you need to do?"}]))
+                                    (+ {:name :ui/child :id "app" :child "todo-input" :pos 1}))
+
+                              (rule (set remaining [id]
+                                         {:name "todo-done" :id id :done? "false"})
+                                    (= left [remaining] (count remaining))
+                                    (= text [left] (if (= left 1)
+                                                     " todo "
+                                                     " todos "))
+                                    (+s [left text]
+                                        (hiccup [:span {:id "remaining-count"} left text "left"]))
+                                    (+ {:name :ui/child :id "app" :child "remaining-count" :pos 3.5}))
+
+                              (rule (set completed [id]
+                                         {:name "todo-done" :id id :done? "true"})
+                                    (= left [completed] (count completed))
+                                    (? [left] (> left 0))
+                                    (+s [left]
+                                        (hiccup [:span {:id "completed-count" :event-key "clear completed" :events ["onClick"]} "clear completed (" left ")"]))
+                                    (+ {:name :ui/child :id "app" :child "completed-count" :pos 7}))
+
+                              (rule {:name :todo/toggle-all :value toggle}
+                                    (+s [toggle]
+                                        (hiccup
+                                         [:div {:id "app"}
+                                          [:h1 {:id "todo-header"} "Todos"]
+                                          [:input {:id "toggle-all"
+                                                   :event-key "toggle-all"
+                                                   :checked toggle
                                                    :events ["onChange"]
-                                                   :type "checkbox"}]))
-                                     (+ {:name :ui/child :id parent-id :child child-id :pos -1}))]
-                              [(rule {:name :todo/displayed :id id}
-                                     {:name "todo" :id id :text text :order order}
-                                     {:name "todo-editing" :id id :editing? "false"}
-                                     (+s [id text]
-                                         (hiccup
-                                          [:li {:id (str "todo" id) :entity id :event-key "todo" :events ["onDoubleClick"]}
-                                           text
-                                           [:button {:id (str "todo-remove" id) :style {:margin-left "10px"} :entity id :event-key "todo-remove" :events ["onClick"]} "x"]]))
-                                     (= child-id [id] (str "todo" id))
-                                     (+ {:name :ui/child :id "todo-list" :child child-id :pos order}))
-                               (rule {:name :todo/displayed :id id}
-                                     {:name "todo" :id id :text text :order order}
-                                     {:name "todo-editing" :id id :editing? "true"}
-                                     (+s [id text]
-                                         (hiccup
-                                          [:input {:id (str "todo-editor") :entity id :event-key "todo-editor" :defaultValue text :events ["onChange" "onKeyDown" "onBlur"]}]))
-                                     (+ {:name :ui/child :id "todo-list" :child "todo-editor" :pos order}))]
-
-                              [(rule {:name :todo/current-text :value v}
-                                     (+s []
-                                         (hiccup
-                                          [:input {:id "todo-input" :value v :event-key "todo-input" :events ["onChange" "onKeyDown"] :placeholder "What do you need to do?"}]))
-                                     (+ {:name :ui/child :id "app" :child "todo-input" :pos 1}))]
-
-                              [(rule (set remaining [id]
-                                          {:name "todo-done" :id id :done? "false"})
-                                     (= left [remaining] (count remaining))
-                                     (= text [left] (if (= left 1)
-                                                      " todo "
-                                                      " todos "))
-                                     (+s [left text]
-                                         (hiccup [:span {:id "remaining-count"} left text "left"]))
-                                     (+ {:name :ui/child :id "app" :child "remaining-count" :pos 3.5}))
-
-                               (rule (set completed [id]
-                                          {:name "todo-done" :id id :done? "true"})
-                                     (= left [completed] (count completed))
-                                     (? [left] (> left 0))
-                                     (+s [left]
-                                         (hiccup [:span {:id "completed-count" :event-key "clear completed" :events ["onClick"]} "clear completed (" left ")"]))
-                                     (+ {:name :ui/child :id "app" :child "completed-count" :pos 7}))]
-
-                              [(rule {:name :todo/toggle-all :value toggle}
-                                     (+s [toggle]
-                                         (hiccup
-                                          [:div {:id "app"}
-                                           [:h1 {:id "todo-header"} "Todos"]
-                                           [:input {:id "toggle-all"
-                                                    :event-key "toggle-all"
-                                                    :checked toggle
-                                                    :events ["onChange"]
-                                                    :type "checkbox"}]
-                                           [:button {:id "add-todo" :event-key "add-todo" :events ["onClick"]} "add"]
-                                           [:ul {:id "todo-list"}]
-                                           [:button {:id "filter-all" :event-key "filter-all" :events ["onClick"]} "all"]
-                                           [:button {:id "filter-active" :event-key "filter-active" :events ["onClick"]} "active"]
-                                           [:button {:id "filter-completed" :event-key "filter-completed" :events ["onClick"]} "completed"]
-                                           ]))
-                                     )]
+                                                   :type "checkbox"}]
+                                          [:button {:id "add-todo" :event-key "add-todo" :events ["onClick"]} "add"]
+                                          [:ul {:id "todo-list"}]
+                                          [:button {:id "filter-all" :event-key "filter-all" :events ["onClick"]} "all"]
+                                          [:button {:id "filter-active" :event-key "filter-active" :events ["onClick"]} "active"]
+                                          [:button {:id "filter-completed" :event-key "filter-completed" :events ["onClick"]} "completed"]
+                                          ]))
+                                    )
                               ]})))

 ;; (go-to-do)


comments & logging

comments & logging

--- src/babel/espanol/writer.clj
+++ src/babel/espanol/writer.clj
@@ -81,11 +81,13 @@
                                                                                :model small
                                                                                }}]
                                                                               "es")
+
+                                                                     ;; TODO: move this to *before*
+                                                                     ;; attempting generation that fails.
                                                                      (catch Exception e
                                                                        (cond
-
-                                                                         ;;conditional on
-                                                                         ;; there being a legitimate reason for the exception -
+                                                                         ;; Ignore the generation-failure exception, if
+                                                                         ;; there is a legitimate reason for the exception, such as:

                                                                          ;; The verb is "funzionare" (which takes a non-human
                                                                          ;; subject), but we're trying to generate with
@@ -98,14 +100,17 @@
                                                                                :1st)
                                                                               (= (get-in spec [:comp :synsem :agr :person])
                                                                                :2nd)))
-                                                                         (log/warn (str "ignoring exception(1): " e))
+                                                                         (log/info (str "ignoring exception(funcionar): " e))

+                                                                         ;; "llamarse": there is currently only singular
+                                                                         ;; proper names, so any attempt to use
+                                                                         ;; plural number with this verb will fail.
                                                                          (and
                                                                           (= (get-in spec [:root :espanol :espanol])
                                                                              "llamarse")
                                                                           (get-in spec [:comp :synsem :arg :number]
                                                                                :plur))
-                                                                         (log/warn (str "ignoring exception(2): " e))
+                                                                         (log/info (str "ignoring exception(llamarse): " e))

                                                                          true
                                                                          (do


make inline cache vars private

make inline cache vars private

--- src/clj/com/rpl/specter.cljc
+++ src/clj/com/rpl/specter.cljc
@@ -238,7 +238,7 @@

              cache-sym (vary-meta
                         (gensym "pathcache")
-                        merge {:cljs.analyzer/no-resolve true :no-doc true})
+                        merge {:cljs.analyzer/no-resolve true :no-doc true :private true})

              info-sym (gensym "info")


Running inside wildfly is totally hosed

Running inside wildfly is totally hosed

Add a comment about another problem I just ran across

--- src/clj/frereth_web/core.clj
+++ src/clj/frereth_web/core.clj
@@ -1,6 +1,7 @@
 (ns frereth-web.core
   (:require [com.stuartsierra.component :as component]
-            [frereth-web.system :as sys])
+            [frereth-web.system :as sys]
+            [ribol.core :refer (raise)])
   ;; Q: Do I want to do this?
   ;; It just seems to cause trouble
   (:gen-class))
@@ -13,6 +14,11 @@
   (let [initial (sys/ctor)
         active (component/start initial)]
     (try
+      ;; It looks like just starting the web server should be enough
+      ;; for this part
+      (raise {:not-implemented "Must return"
+              :problem "Otherwise container never finishes initializing"
+              :question "So how's this supposed to work?"})
       ;; Just wait for the promise to be delivered
       @(:done active)
       (finally


Use application cache to store checkins

Use application cache to store checkins

Now since we have to make several requests to retrieve all checkins for
the day it is better to cache all the checkins. That way we can compare
the first barcode in the cache with the first barcode from the first
page of results. if they match then we don't need to make any further
requests.

--- src/clj/kids_checkin/api.clj
+++ src/clj/kids_checkin/api.clj
@@ -8,6 +8,8 @@
    (clj-time [core :as time] [coerce :as tc]))
   (:import (javax.crypto Mac)
            (javax.crypto.spec SecretKeySpec)))
+
+(def checkins-store (atom []))

 (defn load-config []
   (edn/read-string (slurp "src/clj/config.edn")))
@@ -51,16 +53,23 @@
 (defn get-starting-date [checkin]
   (apply str (take 10 (get-in checkin [:event :starting_at]))))

+(defn retrieve-new-checkins [checkins]
+  (take-while #(not= (:barcode %) (:barcode (first @checkins-store))) checkins))
+
 (defn retrieve-checkins
   ([] (retrieve-checkins 1 []))
   ([page-number checkins]
    (let [today (.toString (time/today) "MM/dd/yyyy")
          body (:body (retrieve-checkins-page page-number))
          page-checkins (:checkins (json/read-str body :key-fn keyword))
-         last-checkin-date (get-starting-date (last page-checkins))]
-     (if (= today last-checkin-date)
-       (retrieve-checkins (inc page-number) (into checkins page-checkins))
-       (into checkins (filter #(= today (get-starting-date %)) page-checkins))))))
+         last-checkin-date (get-starting-date (last page-checkins))
+         new-checkins (retrieve-new-checkins page-checkins)]
+     (println new-checkins)
+     (if (and (= 20 (count new-checkins)) (= today last-checkin-date))
+       (retrieve-checkins (inc page-number) (into checkins new-checkins))
+       (let [complete-checkin-list (into checkins (filter #(= today (get-starting-date %)) new-checkins))]
+         (swap! checkins-store into complete-checkin-list)
+         @checkins-store)))))

 (defn count-checkins [id checkins]
   (count (filter #(= id (get-in % [:group :id])) checkins)))
@@ -74,7 +83,7 @@
    {:id 108123 :color "blue" :count 1 :max 12 :name "Primary"}])

 (defn create-checkin-map [env]
-  (if (false? (:dev env))
+  (if (true? (:dev env))
     (test-checkins)
     (let [checkins (retrieve-checkins)]
       [{:id 108117 :max 12 :color "red" :count (count-checkins 108117 checkins) :name "Nursery"}


Google verification

Google verification

--- src/clj/skidskytte/views.clj
+++ src/clj/skidskytte/views.clj
@@ -30,22 +30,23 @@

 (defn main [name]
   (hp/html5
-    [:head
-     [:meta {:charset "utf-8"}]
-     [:title "Skidskytteroulette"]
-     [:meta {:name "viewport" :content "width=device-width" :initial-scale "1"}]
-     (hp/include-css "/css/pure-base-min.css")
-     (hp/include-css "/css/custom.css")]
-    [:body
-     [:div.container
-       [:div.inner
-        [:h1 "Skidskytteroulette"]
-        [:p "Om du gillar skidskytte och nordisk kombination så kanske du också gillar"]
-        [:p#sport.sport [:span name]]
-        [:p.something-else "Nja, det låter trist, jag vill pröva "
-         [:a {:onclick "skidskytte.get_new_sport(); return false" :href "/"} "något annat"]]
-        [:div.fb-like.social fb-like-button]
-        [:div.tweet-button.social tweet-button]]]
-     [:script {:src "js/skidskytte.js"}]
-     [:script "skidskytte.render()"]
-     [:div google-analytics fb-api]]))
+   [:head
+    [:meta {:charset "utf-8"}]
+    [:title "Skidskytteroulette"]
+    [:meta {:name "viewport" :content "width=device-width" :initial-scale "1"}]
+    [:meta { :name "google-site-verification" :content "r7VtbOM8b_7mep2VcJfOfm1FhQl5R9w-I9C_yoJm90k"}]
+    (hp/include-css "/css/pure-base-min.css")
+    (hp/include-css "/css/custom.css")]
+   [:body
+    [:div.container
+     [:div.inner
+      [:h1 "Skidskytteroulette"]
+      [:p "Om du gillar skidskytte och nordisk kombination så kanske du också gillar"]
+      [:p#sport.sport [:span name]]
+      [:p.something-else "Nja, det låter trist, jag vill pröva "
+       [:a {:onclick "skidskytte.get_new_sport(); return false" :href "/"} "något annat"]]
+      [:div.fb-like.social fb-like-button]
+      [:div.tweet-button.social tweet-button]]]
+    [:script {:src "js/skidskytte.js"}]
+    [:script "skidskytte.render()"]
+    [:div google-analytics fb-api]]))


Reuse nested-fns for running around-alls

--- src/cljx/speclj/running.cljx
+++ src/cljx/speclj/running.cljx
@@ -108,15 +108,8 @@
     (do-child-contexts description results reporters)))

 (defn- with-around-alls [description run-characteristics-fn]
-  (let [around-alls (reduce (fn [composed around-all]
-                              (fn [f] ((.-body around-all)
-                                         (partial composed f))))
-
-                            (fn [f] (f))
-
-                            (reverse @(.-around-alls description)))]
-
-    (around-alls run-characteristics-fn)))
+  ((nested-fns run-characteristics-fn
+               (map #(.-body %) @(.-around-alls description)))))

 (defn do-description [description reporters]
   (let [tag-sets (tag-sets-for description)]


Add tasks to tools.clj script for start node and jvm repls.

--- tools.clj
+++ tools.clj
@@ -1,11 +1,15 @@
 (require '[clojure.java.shell :as shell])
-(require '[figwheel.main.api :as figwheel])
-(require '[cljs.build.api :as api])
+
+(require '[cljs.build.api :as api]
+         '[cljs.repl :as repl]
+         '[cljs.repl.node :as node])

 (require '[rebel-readline.core]
          '[rebel-readline.clojure.main]
          '[rebel-readline.clojure.line-reader]
-         '[rebel-readline.clojure.service.local])
+         '[rebel-readline.clojure.service.local]
+         '[rebel-readline.cljs.service.local]
+         '[rebel-readline.cljs.repl])

 (defmulti task first)

@@ -16,7 +20,7 @@
     (println "Unknown or missing task. Choose one of:" interposed)
     (System/exit 1)))

-(defmethod task "repl"
+(defmethod task "repl:jvm"
   [args]
   (rebel-readline.core/with-line-reader
     (rebel-readline.clojure.line-reader/create
@@ -25,52 +29,51 @@
      :prompt (fn []) ;; prompt is handled by line-reader
      :read (rebel-readline.clojure.main/create-repl-read))))

+(defmethod task "repl:node"
+  [args]
+  (rebel-readline.core/with-line-reader
+    (rebel-readline.clojure.line-reader/create
+     (rebel-readline.cljs.service.local/create))
+    (cljs.repl/repl
+     (node/repl-env)
+     :prompt (fn []) ;; prompt is handled by line-reader
+     :read (rebel-readline.cljs.repl/create-repl-read)
+     :output-dir "out"
+     :cache-analysis false)))
+
 (def build-options
   {:main 'lentes.tests
    :output-to "target/tests.js"
    :source-map "target/tests.js.map"
    :output-dir "target/tests"
+   :optimizations :advanced
    :target :nodejs
    :pretty-print false
    :pseudo-names false
    :verbose true})

-(defn build
-  [optimizations]
-  (api/build (api/inputs "src" "test")
-             (cond->  (assoc build-options :optimizations optimizations)
-               (= optimizations :none) (assoc :source-map true))))
+(defmethod task "build:tests"
+  [args]
+  (api/build (api/inputs "src" "test") build-options))

-(defmethod task "build"
-  [[_ type]]
-  (case type
-    (nil "none") (build :none)
-    "simple"     (build :simple)
-    "advanced"   (build :advanced)
-    (do (println "Unknown argument to test task:" type)
-        (System/exit 1))))
-
-(require '[badigeon.jar])
-(require '[badigeon.deploy])
-
-(defmethod task "jar"
+(defmethod task "watch:tests"
   [args]
-  (badigeon.jar/jar 'funcool/lentes
-                    {:mvn/version "1.3.0-SNAPSHOT"}
-                    {:out-path "target/lentes.jar"
-                     :mvn/repos '{"clojars" {:url "https://repo.clojars.org/"}}
-                     :allow-all-dependencies? false}))
-
-(defmethod task "deploy"
-  [args]
-  (let [;; Artifacts are maps with a required :file-path key and an optional :extension key
-        artifacts [{:file-path "target/lentes.jar" :extension "jar"}
-                   {:file-path "pom.xml" :extension "pom"}]]
-    (badigeon.deploy/deploy
-     'funcool/lentes "1.3.0-SNAPSHOT"
-     artifacts
-     {:id "clojars" :url "https://repo.clojars.org/"}
-     {:allow-unsigned? true})))
+  (println "Start watch loop...")
+  (letfn [(run-tests []
+            (let [{:keys [out err]} (shell/sh "node" "out/tests.js")]
+              (println out err)))
+          (start-watch []
+            (try
+              (api/watch (api/inputs "src" "test")
+                         (assoc build-options
+                                :watch-fn run-tests
+                                :source-map true
+                                :optimizations :none))
+              (catch Exception e
+                (println "ERROR:" e)
+                (Thread/sleep 2000)
+                start-watch)))]
+    (trampoline start-watch)))

 ;;; Build script entrypoint. This should be the last expression.


more stable log det

more stable log det

--- src/distributions/linalg.clj
+++ src/distributions/linalg.clj
@@ -1,6 +1,5 @@
 (in-ns 'distributions.core)

-(defn log-det [M]
-  (let [L (:L (la/cholesky M))]
-    (* 2 (reduce + (map log (diagonal L))))))

+(defn log-det [M] (reduce + (map log (:S (la/svd M)))))
+


Changed formatting of log messages.

Changed formatting of log messages.

--- src/fm/simrunner/actions.clj
+++ src/fm/simrunner/actions.clj
@@ -107,8 +107,8 @@
       (rdg/log-messages! app
                          "Starting simulation run."
                          (format "Executable file: '%s'" executable-file)
-                         (format "Config file    : '%s'" config-file)
-                         (format "Ouput file     : '%s'" output-file))
+                         (format "Config file: '%s'" config-file)
+                         (format "Ouput file: '%s'" output-file))
       (try
         (exc/wait-for (exc/drain-outputs (apply exc/exec args)
                                          :out> (console-logger app)


+(rewrite-lexicon) at beginning of (translate)

--- src/babel/english/writer.clj
+++ src/babel/english/writer.clj
@@ -30,6 +30,7 @@

 (defn translate [source-language-short-name]
   "generate English translations of all available expressions in source language."
+  (rewrite-lexicon)
   (let [source-expressions (read-all :top source-language-short-name)]
     (.size (pmap (fn [source-expression]
                    (do (log/debug (str source-language-short-name ": " (:surface source-expression)))


Start storing (-> build :node) in the DB, so we have access to the instance's private key. Adds a fn for ssh'ing into instances

--- src/circle/backend/build.clj
+++ src/circle/backend/build.clj
@@ -11,6 +11,7 @@
   (:use [circle.util.predicates :only (ref?)])
   (:require [somnium.congomongo :as mongo])
   (:require [circle.util.mongo :as c-mongo])
+  (:require [circle.sh :as sh])
   (:use [clojure.tools.logging :only (log)]))

 (def build-coll :builds) ;; mongo collection for builds
@@ -52,7 +53,7 @@

 (def build-dissoc-keys
   ;; Keys on build that shouldn't go into mongo, for whatever reason
-  [:node :actions :action-results])
+  [:actions :action-results])

 (defn insert! [b]
   (let [return (mongo/insert! build-coll (apply dissoc @b build-dissoc-keys))]
@@ -145,4 +146,31 @@

 (defn build-log-error [message & args]
   (when *log-ns*
-    (log *log-ns* :error nil (apply format message args))))+    (log *log-ns* :error nil (apply format message args))))
+
+(defn build-with-instance-id
+  "Returns the build from the DB with the given instance-id"
+  [id]
+  (mongo/fetch-one build-coll :where {:instance-ids id}))
+
+(defn ssh
+  "Opens a terminal window that SSHs into intance with the provided id.
+
+Assumes:
+  1) the instance was started by a build
+  2) the build is in the DB
+  3) the instance is still running
+  4) this clojure process is on OSX"
+
+  [instance-id]
+  (let [build (build-with-instance-id instance-id)
+        ssh-private-key (-> build :node :private-key)
+        username (-> build :node :username)
+        ip-addr (-> build :node :ip-addr)
+        key-temp-file (fs/tempfile "ssh")
+        _ (spit key-temp-file ssh-private-key)
+        _ (fs/chmod "-r" key-temp-file)
+        _ (fs/chmod "u+r" key-temp-file)
+        ssh-cmd (format "ssh -i %s %s@%s" key-temp-file username ip-addr)
+        tell-cmd (format "'tell app \"Terminal\" \ndo script \"%s\"\n end tell'" ssh-cmd)]
+    (sh/shq (osascript -e ~tell-cmd))))


Rewrote the with-gdal-open macro as a function; the wrapping macro now calls a thunk.

--- src/clj/forma/source/hdf.clj
+++ src/clj/forma/source/hdf.clj
@@ -66,15 +66,18 @@
 ;; provides us with everything we need for proper classification of
 ;; the data we need.

+(defn with-gdal-open* [f path]
+  (let [gdal (do (gdal/AllRegister)
+                 (gdal/Open path))]
+    (try (f gdal)
+         (finally (.delete gdal)))))
+
 (defmacro with-gdal-open
   "Accepts a vector containing a symbol and a path to a file capable
   of being opened with `gdal/Open`, and binds the opened dataset to
   the supplied symbol."
   [[sym path] & body]
-  `(let [~sym (do (gdal/AllRegister)
-                  (gdal/Open ~path))]
-     (try ~@body
-          (finally (.delete ~sym)))))
+  (with-gdal-open* (fn [~sym] ~@body) path))

 (defn metadata
   "Returns the metadata map for the supplied MODIS Dataset."


convert backpack id to string, fix congratulation

--- src/clj/salava/user/data.clj
+++ src/clj/salava/user/data.clj
@@ -122,7 +122,7 @@
                                                [:chunk.chunk (str (t :user/Emailnotifications ul) ": ")][:chunk (str (:email_notifications $user) "  ")]
                                                [:chunk.chunk (str (t :user/Profilevisibility ul) ": ")][:chunk (:profile_visibility $user)]"\n"
                                                [:chunk.chunk (str (t :user/Aboutme ul) ":")]"\n"
-                                               [:paragraph (:about $user)]]
+                                               [:paragraph (or (:about $user) "-")]]
                                               [:spacer 2]
                                               [:paragraph.generic
                                                (if (> (count $emails) 1)
@@ -141,7 +141,9 @@
                                                            [:chunk.chunk (str (t :user/Loginaddress ul)": ")] [:chunk (str (:primary_address e))] "\n"]
                                                           )
                                                         (when-not (blank? (:backpack_id e))
-                                                          [:chunk.chunk (str (t :user/BackpackID ul) ": ") (:backpack_id e)])
+                                                          [:phrase
+                                                           [:chunk.chunk (str (t :user/BackpackID ul) ": ")][:chunk (str (:backpack_id e))]]
+                                                          )

                                                         ]))]

@@ -221,17 +223,24 @@
                                                                                [:paragraph
                                                                                [:chunk.chunk (str (t :badge/Name ul) ": ")] [:chunk (:name a)]"\n"
                                                                                [:chunk.chunk (str (t :page/Description ul) ": ")] [:chunk (:description a)]"\n"
-                                                                                [:chunk.chunk (str (t :badge/Url ul) ": ")] [:chunk.link (:url a)]]))
+                                                                                [:chunk.chunk (str (t :badge/URL ul) ": ")] [:chunk.link (:url a)]]))
                                                                                ])

                                                                                [:chunk.chunk (str (t :badge/Viewed ul) ": ")] [:chunk (str (:view_count more-badge-info) " " (t :badge/times ul)" ")]", "
                                                                                [:chunk.chunk (str (t :badge/Recipientcount ul) ": ")][:chunk (str (:recipient_count more-badge-info) " ")]", "
                                                                                [:chunk.chunk (str (t :badge/Congratulated ul) "?: ")][:chunk (str congratulated?  #_(:congratulated? more-badge-info ) " ")]"\n"
                                                                                ;;TEST congratulated!
-                                                                                (when (= true  congratulated?
-                                                                                [:paragraph
-                                                                                (into [:paragraph] (for [c (:congratulations more-badge-info)]
-                                                                                [:chunk (str c)]))]))
+                                                                                (when-not (empty? (:congratulations more-badge-info))
+                                                                                [:paragraph
+                                                                                [:chunk.chunk (str (t :badge/Congratulations ul) ": ")]"\n"
+                                                                                [:paragraph
+                                                                                (into [:paragraph] (for [c (:congratulations more-badge-info)]
+                                                                                [:phrase
+                                                                                [:chunk (str c)] "\n"]))]
+                                                                                #_(when (= true  congratulated?
+                                                                                [:paragraph
+                                                                                (into [:paragraph] (for [c (:congratulations more-badge-info)]
+                                                                                [:chunk (str c)]))]))])
                                                                                [:chunk.chunk (str (capitalize (t :badge/endorsements ul)) ": ")][:chunk (str (:endorsement_count %))]"\n"
                                                                                (when (not-empty endorsements)
                                                                                (into [:paragraph {:indent 0}]


add link to ssllabs

add link to ssllabs

--- src/clj/yambox/templates.clj
+++ src/clj/yambox/templates.clj
@@ -112,7 +112,10 @@
                  в браузере отправителя, прочитать его не сможет никто, кроме адресата — даже мы."]
                 [:p [:b
                      "И последнее: никто не любит, когда его подслушивают. Именно поэтому ваше соединение
-                     с YamBox имеет рейтинг безопасности A+."]]]
+                     с YamBox "
+                     [:a {:href "https://www.ssllabs.com/ssltest/analyze.html?d=yambox.org"}
+                      "имеет рейтинг безопасности A+"]
+                     "."]]]
                [:div.col-sm-2]]]
              [:div.choose
               [:div.container


Some colour and polish to focusing on district

--- src/cljs/geoforms/forms.cljs
+++ src/cljs/geoforms/forms.cljs
@@ -13,7 +13,9 @@

 (defn toggle-district! [d]
   (swap! app-state update :selected-districts
-         #(if (% d) (disj % d) (conj % d))))
+         #(do (when (and (= d @db/selected-district) (% d))
+                (reset! db/selected-district nil))
+              (if (% d) (disj % d) (conj % d)))))

 (defn selected-districts []
   (:selected-districts @app-state))
@@ -172,27 +174,27 @@

 (defn list-idea-blocks-component []
   (let [districts @db/districts]
-    [:div
-     (doall
-      (interpose
-       [:br]
-       (for [d     districts
-             :when (selected-district? d)
-             :let  [ideas (district-ideas d)]]
-         [:div {:key d}
-          [:p [:strong (str d " - " (count ideas) " " (snippet :idea) "(s)")]]
-          (for [{:keys [id title]} ideas]
-            [:div.checkbox {:key id
-                            :on-change #(let [supported? (-> % .-target .-checked)]
-                                          (db/set-idea-support! id supported?))}
-             [:label [:input {:type :checkbox :id id}] title]])
-          [:a.btn.btn-xs.btn-default
-           {:disabled (= d @db/selected-district)
-            :on-click #(reset! db/selected-district d)}
-           (str (snippet :add-idea-to) " " d)]
-          [:br]])))]))
-
-(def idea-template
+    (into
+     [:div]
+     (interpose
+      [:br]
+      (for [d     districts
+            :when (selected-district? d)
+            :let  [ideas (district-ideas d)]]
+        [:div {:key d}
+         [:p [:strong (str d " - " (count ideas) " " (snippet :idea) "(s)")]]
+         (for [{:keys [id title]} ideas]
+           [:div.checkbox {:key id
+                           :on-change #(let [supported? (-> % .-target .-checked)]
+                                         (db/set-idea-support! id supported?))}
+            [:label [:input {:type :checkbox :id id}] title]])
+         [:a.btn.btn-xs.btn-success
+          {:disabled (= d @db/selected-district)
+           :on-click #(reset! db/selected-district d)}
+          (str (snippet :add-idea-to) " " d)]
+         [:br]])))))
+
+(defn idea-template []
   [:div
    (input-placeholder (snippet :idea-title) :text :title)
    (error-field :title)
@@ -214,8 +216,10 @@

 (defn add-idea-component []
   [:div
+   [:div.form-group
+    [:input.form-control {:disabled true, :value @db/selected-district}]]
    [bind-fields
-    idea-template
+    (idea-template)
     idea-doc
     #_ (fn [k v _] (prn k v _))]
    [:button.btn.btn-default
@@ -310,6 +314,6 @@
                      errors (validate-user after)]
                  (assoc after :errors errors)))]

-         [:button.btn.btn-default
+         [:button.btn.btn-primary
           {:on-click #(when (validate-user! user-doc) (submit! @user-doc))}
           (snippet :submit)]])])])


Make little refactoring on history

Make little refactoring on history

--- src/cljs/subman/history.cljs
+++ src/cljs/subman/history.cljs
@@ -13,20 +13,30 @@
     (.setPathPrefix "/search/")
     (.setEnabled true)))

+(defn watch-to-value
+  "Watch to search result value"
+  [history value]
+  (add-watch value :history
+             (fn [_ _ _ new-value]
+               (wait 500 #(when (= new-value @value)
+                            (.setToken history new-value))))))
+
+(defn watch-to-navigation
+  "Watch to navigation events"
+  [history value]
+  (gevents/listen history history-event/NAVIGATE
+                  #(let [token (-> % .-token js/decodeURIComponent)]
+                     (when (and (= (.-isNavigatopn %))
+                                (not= token @value))
+                       (reset! value token)))))
+
 (defn init-history
   "Init history and spy to atom"
   [value]
   (when (history5/isSupported)
     (let [history (get-history)]
-      (add-watch value :history
-                 (fn [_ _ _ new-value]
-                   (wait 500 #(when (= new-value @value)
-                                (.setToken history new-value)))))
-      (gevents/listen history history-event/NAVIGATE
-                      #(let [token (-> % .-token js/decodeURIComponent)]
-                         (when (and (= (.-isNavigatopn %))
-                                    (not= token @value))
-                           (reset! value token))))
+      (watch-to-value history value)
+      (watch-to-navigation history value)
       (->> (.getToken history)
            js/decodeURIComponent
            (reset! value)))))