adjust outer nav for guest, fix minor space issues

--- frontend/components/header.cljs
+++ frontend/components/header.cljs
@@ -123,26 +123,25 @@
            [:div.container
             [:div.row
              [:div.span8
-              [:div.row
-               [:a#logo.span2
-                {:href "/"}
-                [:img
-                 {:width "130",
-                  :src (utils/cdn-path "/img/logo-new.svg")
-                  :height "40"}]]
-               [:nav.span6
-                {:role "navigation"}
-                [:ul.nav.nav-pills
-                 [:li [:a {:href "/about"} "About"]]
-                 [:li [:a {:href "/pricing"} "Pricing"]]
-                 [:li [:a {:href "/docs"} "Documentation"]]
-                 [:li [:a {:href "/jobs"} "Jobs"]]
-                 [:li [:a {:href "http://blog.circleci.com"} "Blog"]]]]]]
+              [:a#logo.span2
+               {:href "/"}
+               [:img
+                {:width "130",
+                 :src (utils/cdn-path "/img/logo-new.svg")
+                 :height "40"}]]
+              [:nav.span6
+               {:role "navigation"}
+               [:ul.nav.nav-pills
+                [:li [:a {:href "/about"} "About"]]
+                [:li [:a {:href "/pricing"} "Pricing"]]
+                [:li [:a {:href "/docs"} "Documentation"]]
+                [:li [:a {:href "/jobs"} "Jobs"]]
+                [:li [:a {:href "http://blog.circleci.com"} "Blog"]]]]]
              (if logged-in?
-               [:div.controls.span4
+               [:div.controls.span2.offset2
                 [:a#login.login-link {:href "/"} "Return to App"]]

-               [:div.controls.span4
+               [:div.controls.span2.offset2
                 [:a#login.login-link {:href (auth-url)
                                       :on-click #(put! controls-ch [:track-external-link-clicked {:path (auth-url) :event "Auth GitHub" :properties {:source "header sign-in" :url js/window.location.pathname}}])
                                       :title "Sign in with Github"}
@@ -162,7 +161,7 @@
       (let [admin? (get-in app [:current-user :admin])
             logged-out? (not (get-in app state/user-path))]
         (html
-         [:header.main-head
+         [:header.main-head (when logged-out? {:class "guest"})
           (when admin?
             (om/build head-admin app))
           (when logged-out?


Fix format in interactive mode tests

Fix format in interactive mode tests

--- test/app/test/interactive.clj
+++ test/app/test/interactive.clj
@@ -64,7 +64,7 @@
                (interactive javaparser-cus)
                (verify-call-times-for printOperation 1)
                (verify-first-call-args-for
-                 printOperation operation (:cus javaparser-cus) threshold)))))
+                printOperation operation (:cus javaparser-cus) threshold)))))

 (deftest can-execute-mc-operation
   (test-operation "mc" classesWithManyConstructorsOp 2))


Add test for eq between >2 fn calls

Add test for eq between >2 fn calls

--- test/desdemona/query_test.clj
+++ test/desdemona/query_test.clj
@@ -30,6 +30,13 @@
                  (fn-call "ip" "y")]]
          (#'q/infix-parser "ip(x) = ip(y)"))
       "equality between two fn calls")
+  (is (= [:expr [:eq
+                 (fn-call "ip" "p")
+                 (fn-call "ip" "q")
+                 (fn-call "ip" "r")
+                 (fn-call "ip" "s")]]
+         (#'q/infix-parser "ip(p) = ip(q) = ip(r) = ip(s)"))
+      "equality between >2 fn calls")
   (testing "equality between two fn calls & literal"
     (is (= [:expr [:eq
                    (fn-call "ip" "x")


Use fancy new hotness

Use fancy new hotness

--- test/icecap/e2e/http_test.clj
+++ test/icecap/e2e/http_test.clj
@@ -4,7 +4,6 @@
             [clojure.test :refer :all]
             [aleph.http :as http]
             [manifold.deferred :refer [let-flow]]
-            [byte-streams :as bs]
             [taoensso.timbre :refer [info spy]]))

 (def ^:dynamic http-server)
@@ -42,7 +41,7 @@
   (let [create-result @(create-cap {:type :http
                                     :url (str http-server-base-url
                                               "/test/example")})
-        cap-url (spy (bs/to-string (:body create-result)))
+        cap-url (spy (:cap (get-body create-result)))
         exercise-result @(execute-cap cap-url)]
     (is (= (select-keys create-result [:code])
            {:code 201}))
@@ -50,6 +49,6 @@

 (deftest invalid-http-step-tests
   (are [step expected] (let [create-result @(create-cap step)
-                             message (bs/to-string (:body create-result))]
-                         (= message expected))
+                             message (get-body create-result)]
+                         (= message {:error expected}))
        {:type :http} '{:url missing-required-key}))


CHanges unit tests from using with-routes to using redefs.W

--- test/loudmoauth/core_test.clj
+++ test/loudmoauth/core_test.clj
@@ -111,16 +111,11 @@
     (parse-code test-code-http-response)
     (is (= (:code final-state-map) (a/<!! code-chan)))))

-;This throws an exception that no one catches, but what can we do?
-;TODO - Don't use with-fake-routes here, hard code the http/get method and go with redefs instead.
 (deftest test-fetch-code
   (testing "Test issuing http get for auth-code from oauth provider."
-    (reset-channels)
+   (reset-channels)
    (a/go (a/>!! code-chan (:code final-state-map)))
-   (Thread/sleep 1000)
-    (with-fake-routes
-      {(:token-url final-state-map) (fn [request] (:token-response final-state-map))
-       (:auth-url final-state-map) (fn [request] nil)}
+   (with-redefs [clj-http.client/get (constantly (:token-response final-state-map))]
       (is (= final-state-map (fetch-code final-state-map))))))

 (deftest test-user-interaction
@@ -170,10 +165,7 @@

 (deftest test-get-tokens
   (testing "Test retrieving tokens through http requests."
-    (with-fake-routes
-      {(:token-url final-state-map) (fn [request] (:token-response final-state-map))
-       (:auth-url final-state-map) (fn [request] (parse-code test-code-http-response))}
-
+       (with-redefs [clj-http.client/post (constantly (:token-response final-state-map))]
       (is (= final-state-map (update-in (get-tokens (dissoc final-state-map [:access_token :refresh_token :expires_in])) [:token-response :request-time] (fn [x] 0)))))))

 (deftest test-token-url
@@ -194,30 +186,22 @@

 (deftest test-request-access-and-refresh-tokens
   (testing "Build url and retrieve tokens."
-    (with-fake-routes
-      {(:token-url final-state-map) (fn [request] (:token-response final-state-map))
-       (:auth-url final-state-map) (fn [request] (parse-code test-code-http-response))}
-      (is (= final-state-map (update-in (request-access-and-refresh-tokens (dissoc final-state-map [:access_token :refresh_token :expires_in])) [:token-response :request-time] (fn [x] 0)))))))
+       ( with-redefs [clj-http.client/post (constantly (:token-response final-state-map))]
+     (is (= final-state-map (update-in (request-access-and-refresh-tokens (dissoc final-state-map [:access_token :refresh_token :expires_in])) [:token-response :request-time] (fn [x] 0)))))))

   (deftest test-request-access-to-data
     (testing "Build auth url and fetch code."
     (reset-channels)
     (a/go (a/>!! code-chan (:code final-state-map)))
-    (Thread/sleep 1000)
-      (with-fake-routes
-        {(:token-url final-state-map) (fn [request] (:token-response final-state-map))
-         (:auth-url final-state-map) (fn [request] (parse-code test-code-http-response))}
-        (is (= final-state-map) (update-in  (request-access-to-data (dissoc final-state-map :code)) [:token-response :request-time] (fn [x] 0))))))
+        (with-redefs [clj-http.client/get (constantly (:token-response final-state-map))]
+       (is (= final-state-map) (update-in  (request-access-to-data (dissoc final-state-map :code)) [:token-response :request-time] (fn [x] 0))))))

 (deftest test-init
   (testing "Test init function setting parameters and retrieving code and tokens."
     (reset! app-state middle-state-map)
     (reset-channels)
     (a/go (a/>!! code-chan (:code final-state-map)))
-    (Thread/sleep 1000)
-     (with-fake-routes
-      {(:token-url final-state-map) (fn [request] (:token-response final-state-map))
-       (:auth-url final-state-map) (fn [request] (parse-code test-code-http-response))}
+    (with-redefs [clj-http.client/get (constantly (:token-response final-state-map)) clj-http.client/post  (constantly (:token-response final-state-map))]
       (is (= final-state-map (update-in (init) [:token-response :request-time] (fn [x] 0)))))))

 (deftest test-set-oauth-params


Obey Leiningen's *exit-after-tests*

Obey Leiningen's *exit-after-tests*

--- leiningen/midje.clj
+++ leiningen/midje.clj
@@ -3,6 +3,7 @@
 (ns leiningen.midje
   (:refer-clojure :exclude [test])
   (:use [leiningen.util.ns :only [namespaces-in-dir]]
+        [leiningen.test :only [*exit-after-tests*]]
         [leiningen.compile :only [eval-in-project]]))

 (defn require-namespaces-form [namespaces]
@@ -58,9 +59,10 @@
        (println midje-failure-message# midje-consolation#)

        ;; A non-nil return value is printed, so I'll just exit here.
-       (System/exit (+ midje-fails#
-                       (:error clojure-test-result#)
-                       (:fail clojure-test-result#))))))
+       (when ~*exit-after-tests*
+         (System/exit (+ midje-fails#
+                         (:error clojure-test-result#)
+                         (:fail clojure-test-result#)))))))

 (defn midje [project & namespaces]
   (let [desired-namespaces  (if (empty? namespaces)


More destructuring bind again.

More destructuring bind again.


Define markdown-to-html function in impl.markdown.

--- src/incise/parsers/impl/markdown.clj
+++ src/incise/parsers/impl/markdown.clj
@@ -12,6 +12,7 @@
                           :smarts
                           :smartypants])

-(def parser (html-parser #(md/to-html % *options*)))
+(defn markdown-to-html [markdown-str]
+  (md/to-html markdown-str *options*))

-(pc/register [:md :markdown] parser)
+(pc/register [:md :markdown] (html-parser markdown-to-html))


Fixed some bas CSS names

Fixed some bas CSS names

Not an important fix

--- idecode/myappshare/mainapp.cljs
+++ idecode/myappshare/mainapp.cljs
@@ -248,7 +248,7 @@
                                                    :height "800px"
                                                    :width "100px"
                                                    :display "inline-block"
-                                                   :vertical-align "text-top"}}
+                                                   :verticalAlign "text-top"}}
             (add-blocks "Samples"  ["appshare_samples_helloworld"])

@@ -268,14 +268,14 @@

-       (div {:id "blocklyDiv" :style {:vertical-align "text-top"
+       (div {:id "blocklyDiv" :style {:verticalAlign "text-top"
                                       :background     "white"
                                       :color          "white"
                                       :height         "800px"
                                       :width          "500px"
                                       :display        "inline-block"}} "")

-       (pre {:id "blocklyCode" :style {:vertical-align "text-top"
+       (pre {:id "blocklyCode" :style {:verticalAlign "text-top"
                                        :background     "white"
                                        :color          "black"
                                        :height         "800px"
@@ -620,7 +620,7 @@
             (div {:style {:display (if
                                      (or (= (read-ui app [:mode]) "view")
                                          (and (= (read-ui app [:mode]) "edit") (large-screen)))
-                                     "inline-block" "none") :width "600px" :verticalAlign "top" :padding-top "40px"} }
+                                     "inline-block" "none") :width "600px" :verticalAlign "top" :paddingTop "40px"} }
                  (component  view-app-component  app [])))


Add CPS support to servlets

Add CPS support to servlets

--- ring-servlet/src/ring/util/servlet.clj
+++ ring-servlet/src/ring/util/servlet.clj
@@ -99,27 +99,48 @@
     (set-headers headers)
     (set-body body)))

-(defn make-service-method
-  "Turns a handler into a function that takes the same arguments and has the
-  same return value as the service method in the HttpServlet class."
-  [handler]
-  (fn [^HttpServlet servlet
-      ^HttpServletRequest request
-      ^HttpServletResponse response]
+(defn- handler-nil-exception []
+  (NullPointerException. "Handler returned nil"))
+
+(defn- make-blocking-service-method [handler]
+  (fn [servlet request response]
     (let [request-map (-> request
                           (build-request-map)
                           (merge-servlet-keys servlet request response))]
       (if-let [response-map (handler request-map)]
         (update-servlet-response response response-map)
-        (throw (NullPointerException. "Handler returned nil"))))))
+        (throw (handler-nil-exception))))))
+
+(defn- make-async-service-method [handler]
+  (fn [servlet request response]
+    (handler
+     (-> request
+         (build-request-map)
+         (merge-servlet-keys servlet request response))
+     (fn [response-map]
+       (if response-map
+         (update-servlet-response response response-map)
+         (throw (handler-nil-exception)))))))
+
+(defn make-service-method
+  "Turns a handler into a function that takes the same arguments and has the
+  same return value as the service method in the HttpServlet class."
+  ([handler]
+   (make-service-method {}))
+  ([handler options]
+   (if (:async? options)
+     (make-async-service-method handler)
+     (make-blocking-service-method handler))))

 (defn servlet
   "Create a servlet from a Ring handler."
-  [handler]
-  (let [service-method (make-service-method handler)]
-    (proxy [HttpServlet] []
-      (service [request response]
-        (service-method this request response)))))
+  ([handler]
+   (servlet handler {}))
+  ([handler options]
+   (let [service-method (make-service-method handler options)]
+     (proxy [HttpServlet] []
+       (service [request response]
+         (service-method this request response))))))

 (defmacro defservice
   "Defines a service method with an optional prefix suitable for being used by
@@ -132,7 +153,11 @@
   ([handler]
      `(defservice "-" ~handler))
   ([prefix handler]
-     `(let [service-method# (make-service-method ~handler)]
+   (if (map? handler)
+     `(defservice ~prefix ~handler)
+     `(defservice ~prefix ~handler {})))
+  ([prefix handler options]
+     `(let [service-method# (make-service-method ~handler ~options)]
         (defn ~(symbol (str prefix "service"))
           [servlet# request# response#]
           (service-method# servlet# request# response#)))))


Remove contrib dependencies from r.u.servlet.

--- ring-servlet/src/ring/util/servlet.clj
+++ ring-servlet/src/ring/util/servlet.clj
@@ -1,7 +1,6 @@
 (ns ring.util.servlet
   "Compatibility functions for turning a ring handler into a Java servlet."
-  (:use [clojure.contrib.except :only (throwf)]
-        [clojure.contrib.duck-streams :only (copy)])
+  (:require [clojure.java.io :as io])
   (:import (java.io File InputStream FileInputStream)
            (javax.servlet.http HttpServlet
                                HttpServletRequest
@@ -80,7 +79,7 @@
     (instance? InputStream body)
     (let [^InputStream b body]
       (with-open [out (.getOutputStream response)]
-        (copy b out)
+        (io/copy b out)
         (.close b)
         (.flush out)))
     (instance? File body)
@@ -90,7 +89,7 @@
     (nil? body)
       nil
     :else
-      (throwf "Unrecognized body: %s" body)))
+      (throw (Exception. (format "Unrecognized body: %s" body)))))

 (defn update-servlet-response
   "Update the HttpServletResponse using a response map."


Start using resolve in send

Start using resolve in send

--- src-cljs/frontend/send.cljs
+++ src-cljs/frontend/send.cljs
@@ -1,9 +1,10 @@
 (ns frontend.send
   (:require [cljs-time.coerce :as time-coerce]
             [cljs-time.core :as time]
-            [cljs.core.async :refer [chan]]
+            [cljs.core.async :refer [chan <!]]
             [clojure.set :refer [rename-keys]]
             [frontend.api :as api]
+            [frontend.send.resolve :refer [resolve]]
             [frontend.utils.expr-ast :as expr-ast]
             [frontend.utils.vcs-url :as vcs-url]
             [om.next.impl.parser :as om-parser])
@@ -318,6 +319,31 @@
           (cb novelty query))))
      id)))

+(def resolvers
+  {:circleci/organization
+   (fn [env ast]
+     (resolve (assoc env
+                     :organization/vcs-type (:organization/vcs-type (:params ast))
+                     :organization/name (:organization/name (:params ast)))
+              ast
+              (chan)))
+
+   :organization/project
+   (fn [env ast]
+     (resolve (assoc env :project/name (:project/name (:params ast)))
+              ast
+              (chan)))
+
+   :project/branch
+   (fn [env ast]
+     (resolve (assoc env :branch/name (:branch/name (:params ast)))
+              ast
+              (chan)))
+
+   :branch/name
+   (fn [env ast]
+     (:branch/name env))})
+
 (defmulti send* key)

 ;; This implementation is merely a prototype, which does some rudimentary
@@ -335,197 +361,204 @@
       (js/setTimeout #(send* [:remote (rest query)] cb)
                      ms-until-retried-run-retrieved))
     (doseq [expr query]
-      (let [[expr cb] (de-alias-expression expr cb)
-            ast (om-parser/expr->ast expr)]
-        (cond
-          (branch-crumb-ast? ast) (get-branch-name cb ast query)
-          (branch-runs-ast? ast) (get-branch-runs cb ast query)
-          (= {:app/current-user [{:user/organizations [:organization/name :organization/vcs-type :organization/avatar-url]}]}
-             expr)
-          (let [ch (callback-api-chan
-                    #(let [orgs (for [api-org %]
-                                  {:organization/name (:login api-org)
-                                   :organization/vcs-type (:vcs_type api-org)
-                                   :organization/avatar-url (:avatar_url api-org)})]
-                       (cb {:app/current-user {:user/organizations (vec orgs)}} query)))]
-            (api/get-orgs ch :include-user? true))
-
-          (and (= :circleci/organization (:key ast))
-               (= '[:organization/vcs-type
-                    :organization/name
-                    :organization/avatar-url
-                    :organization/current-user-is-admin?]
-                  (:query ast)))
-          (let [{:keys [organization/vcs-type organization/name]} (:params ast)]
-            (api/get-orgs
-             (callback-api-chan
-              #(let [selected-org (first (filter (fn [{:keys [vcs_type login]}]
-                                                   (and (= vcs_type vcs-type)
-                                                        (= login name)))
-                                                 %))
-
-                     avatar-url (:avatar_url selected-org)
-                     admin (:admin selected-org)]
-                 (cb {:circleci/organization {:organization/name name
+      (if (branch-crumb-ast? (om-parser/expr->ast (first (de-alias-expression expr cb))))
+        (let [ch (resolve {:resolvers resolvers} [expr] (chan))]
+          (go-loop []
+            (when-let [novelty (<! ch)]
+              (cb novelty query)
+              (recur))))
+
+        (let [[expr cb] (de-alias-expression expr cb)
+              ast (om-parser/expr->ast expr)]
+          (cond
+            ;; (branch-crumb-ast? ast) (get-branch-name cb ast query)
+            (branch-runs-ast? ast) (get-branch-runs cb ast query)
+            (= {:app/current-user [{:user/organizations [:organization/name :organization/vcs-type :organization/avatar-url]}]}
+               expr)
+            (let [ch (callback-api-chan
+                      #(let [orgs (for [api-org %]
+                                    {:organization/name (:login api-org)
+                                     :organization/vcs-type (:vcs_type api-org)
+                                     :organization/avatar-url (:avatar_url api-org)})]
+                         (cb {:app/current-user {:user/organizations (vec orgs)}} query)))]
+              (api/get-orgs ch :include-user? true))
+
+            (and (= :circleci/organization (:key ast))
+                 (= '[:organization/vcs-type
+                      :organization/name
+                      :organization/avatar-url
+                      :organization/current-user-is-admin?]
+                    (:query ast)))
+            (let [{:keys [organization/vcs-type organization/name]} (:params ast)]
+              (api/get-orgs
+               (callback-api-chan
+                #(let [selected-org (first (filter (fn [{:keys [vcs_type login]}]
+                                                     (and (= vcs_type vcs-type)
+                                                          (= login name)))
+                                                   %))
+
+                       avatar-url (:avatar_url selected-org)
+                       admin (:admin selected-org)]
+                   (cb {:circleci/organization {:organization/name name
+                                                :organization/vcs-type vcs-type
+                                                :organization/avatar-url avatar-url
+                                                :organization/current-user-is-admin? admin}} query)))
+               :include-user? true))
+
+            ;; :route/projects
+            (and (= :circleci/organization (:key ast))
+                 (= '[:organization/vcs-type
+                      :organization/name
+                      {:organization/projects [:project/follower-count
+                                               :project/vcs-url
+                                               :project/name
+                                               :project/parallelism
+                                               :project/oss?]}
+                      {:organization/plan [*]}]
+                    (:query ast)))
+            (let [{:keys [organization/vcs-type organization/name]} (:params ast)]
+              (api/get-org-settings
+               name vcs-type
+               (callback-api-chan
+                #(let [projects (for [p (:projects %)]
+                                  {:project/vcs-url (:vcs_url p)
+                                   :project/name (vcs-url/repo-name (:vcs_url p))
+                                   :project/parallelism (:parallel p)
+                                   ;; Sometimes the backend returns a map of feature_flags,
+                                   ;; and sometimes it returns :oss directly on the project.
+                                   :project/oss? (or (:oss p)
+                                                     (get-in p [:feature_flags :oss]))
+                                   :project/follower-count (count (:followers p))})]
+                   (cb {:circleci/organization {:organization/name name
+                                                :organization/vcs-type vcs-type
+                                                :organization/projects (vec projects)}} query))))
+              (api/get-org-plan
+               name vcs-type
+               (callback-api-chan
+                #(cb {:circleci/organization {:organization/name name
                                               :organization/vcs-type vcs-type
-                                              :organization/avatar-url avatar-url
-                                              :organization/current-user-is-admin? admin}} query)))
-             :include-user? true))
-
-          ;; :route/projects
-          (and (= :circleci/organization (:key ast))
-               (= '[:organization/vcs-type
-                    :organization/name
-                    {:organization/projects [:project/follower-count
-                                             :project/vcs-url
-                                             :project/name
-                                             :project/parallelism
-                                             :project/oss?]}
-                    {:organization/plan [*]}]
-                  (:query ast)))
-          (let [{:keys [organization/vcs-type organization/name]} (:params ast)]
-            (api/get-org-settings
-             name vcs-type
-             (callback-api-chan
-              #(let [projects (for [p (:projects %)]
-                                {:project/vcs-url (:vcs_url p)
-                                 :project/name (vcs-url/repo-name (:vcs_url p))
-                                 :project/parallelism (:parallel p)
-                                 ;; Sometimes the backend returns a map of feature_flags,
-                                 ;; and sometimes it returns :oss directly on the project.
-                                 :project/oss? (or (:oss p)
-                                                   (get-in p [:feature_flags :oss]))
-                                 :project/follower-count (count (:followers p))})]
-                 (cb {:circleci/organization {:organization/name name
-                                              :organization/vcs-type vcs-type
-                                              :organization/projects (vec projects)}} query))))
-            (api/get-org-plan
-             name vcs-type
-             (callback-api-chan
-              #(cb {:circleci/organization {:organization/name name
-                                            :organization/vcs-type vcs-type
-                                            :organization/plan %}}
-                   query))))
-
-          ;; Also :route/projects (but a separate expression for analytics, which
-          ;; doesn't actually need to hit the server)
-          (and (= :circleci/organization (:key ast))
-               (= '[:organization/name] (:query ast)))
-          (let [{:keys [organization/vcs-type organization/name]} (:params ast)]
-            (cb {:circleci/organization {:organization/name name}} query))
-
-          ;; :route/workflow
-          (project-runs-ast? ast)
-          (let [{:keys [connection/offset connection/limit]}
-                (:params (expr-ast/get-in ast [:organization/project :routed-page]))]
-            (merge-workflow-runs {:organization/vcs-type (-> ast :params :organization/vcs-type)
-                                  :organization/name (-> ast :params :organization/name)
-                                  :project/name (-> ast
-                                                    (expr-ast/get :organization/project)
-                                                    :params
-                                                    :project/name)}
-                                 offset
-                                 limit
-                                 cb
-                                 query))
-
-          ;; :route/run
-          (let [{:keys [key children]} ast]
-            (and (= :circleci/run key)
-                 (= 1 (count children))
-                 (= :run/job (:key (first children)))
-                 (= [:job/build :job/name]
-                    (:query (first children)))))
-          (let [job-ast (first (:children ast))
-                job-name (:job/name (:params job-ast))]
+                                              :organization/plan %}}
+                     query))))
+
+            ;; Also :route/projects (but a separate expression for analytics, which
+            ;; doesn't actually need to hit the server)
+            (and (= :circleci/organization (:key ast))
+                 (= '[:organization/name] (:query ast)))
+            (let [{:keys [organization/vcs-type organization/name]} (:params ast)]
+              (cb {:circleci/organization {:organization/name name}} query))
+
+            ;; :route/workflow
+            (project-runs-ast? ast)
+            (let [{:keys [connection/offset connection/limit]}
+                  (:params (expr-ast/get-in ast [:organization/project :routed-page]))]
+              (merge-workflow-runs {:organization/vcs-type (-> ast :params :organization/vcs-type)
+                                    :organization/name (-> ast :params :organization/name)
+                                    :project/name (-> ast
+                                                      (expr-ast/get :organization/project)
+                                                      :params
+                                                      :project/name)}
+                                   offset
+                                   limit
+                                   cb
+                                   query))
+
+            ;; :route/run
+            (let [{:keys [key children]} ast]
+              (and (= :circleci/run key)
+                   (= 1 (count children))
+                   (= :run/job (:key (first children)))
+                   (= [:job/build :job/name]
+                      (:query (first children)))))
+            (let [job-ast (first (:children ast))
+                  job-name (:job/name (:params job-ast))]
+              (api/get-workflow-status
+               (callback-api-chan
+                (fn [response]
+                  (cb {:circleci/run {:run/job (->> response
+                                                    adapt-to-run
+                                                    :run/jobs
+                                                    (filter #(= job-name (:job/name %)))
+                                                    first)}}
+                      query)))
+               (:run/id (:params ast))))
+            ;; Also :route/workflow (but a separate expression for breadcrumbs, which
+            ;; doesn't actually need to hit the server)
+            (and (= :circleci/organization (:key ast))
+                 (= '[:organization/vcs-type :organization/name] (:query ast)))
+            (let [{:keys [organization/vcs-type organization/name]} (:params ast)]
+              (cb {:circleci/organization {:organization/vcs-type vcs-type
+                                           :organization/name name}}
+                  query))
+
+            ;; Also :route/workflow (but *another( expression for breadcrumbs, which
+            ;; doesn't actually need to hit the server)
+            (project-crumb-ast? ast) (get-project-name cb ast query)
+
+            ;; :route/run crumbs
+            (run-page-crumbs-ast? ast) (get-run-page-crumbs cb ast query)
+
+            ;; :route/run RunRow
+            (let [{:keys [key query]} ast]
+              (and (= :circleci/run key)
+                   (= [:run/id
+                       :run/name
+                       :run/status
+                       :run/started-at
+                       :run/stopped-at
+                       {:run/jobs [:job/id]}
+                       {:run/trigger-info [:trigger-info/vcs-revision
+                                           :trigger-info/subject
+                                           :trigger-info/body
+                                           :trigger-info/branch
+                                           {:trigger-info/pull-requests [:pull-request/url]}]}
+                       {:run/project [:project/name
+                                      {:project/organization [:organization/name
+                                                              :organization/vcs-type]}]}]
+                      query)))
             (api/get-workflow-status
              (callback-api-chan
               (fn [response]
-                (cb {:circleci/run {:run/job (->> response
-                                                  adapt-to-run
-                                                  :run/jobs
-                                                  (filter #(= job-name (:job/name %)))
-                                                  first)}}
+                (cb {:circleci/run (-> (adapt-to-run response)
+                                       (dissoc :run/jobs))}
                     query)))
-             (:run/id (:params ast))))
-          ;; Also :route/workflow (but a separate expression for breadcrumbs, which
-          ;; doesn't actually need to hit the server)
-          (and (= :circleci/organization (:key ast))
-               (= '[:organization/vcs-type :organization/name] (:query ast)))
-          (let [{:keys [organization/vcs-type organization/name]} (:params ast)]
-            (cb {:circleci/organization {:organization/vcs-type vcs-type
-                                         :organization/name name}}
-                query))
-
-          ;; Also :route/workflow (but *another( expression for breadcrumbs, which
-          ;; doesn't actually need to hit the server)
-          (project-crumb-ast? ast) (get-project-name cb ast query)
-
-          ;; :route/run crumbs
-          (run-page-crumbs-ast? ast) (get-run-page-crumbs cb ast query)
-
-          ;; :route/run RunRow
-          (let [{:keys [key query]} ast]
-            (and (= :circleci/run key)
-                 (= [:run/id
-                     :run/name
-                     :run/status
-                     :run/started-at
-                     :run/stopped-at
-                     {:run/jobs [:job/id]}
-                     {:run/trigger-info [:trigger-info/vcs-revision
-                                         :trigger-info/subject
-                                         :trigger-info/body
-                                         :trigger-info/branch
-                                         {:trigger-info/pull-requests [:pull-request/url]}]}
-                     {:run/project [:project/name
-                                    {:project/organization [:organization/name
-                                                            :organization/vcs-type]}]}]
-                    query)))
-          (api/get-workflow-status
-           (callback-api-chan
-            (fn [response]
-              (cb {:circleci/run (-> (adapt-to-run response)
-                                     (dissoc :run/jobs))}
-                  query)))
-           (:run/id (:params ast)))
-
-          (let [{:keys [key query]} ast]
-            (and (= :circleci/run key)
-                 (= '[({:jobs-for-jobs [:job/id
-                                        :job/status
-                                        :job/started-at
-                                        :job/stopped-at
-                                        :job/name
-                                        :job/build]}
-                       {:< :run/jobs})
-                      ({:jobs-for-first [:job/id
-                                         :job/build
-                                         :job/name]}
-                       {:< :run/jobs})]
-                    query)))
-          (api/get-workflow-status
-           (callback-api-chan
-            (fn [response]
-              (let [run (adapt-to-run response)
-                    run-with-aliases (-> run
-                                         (dissoc :run/jobs)
-                                         (assoc :jobs-for-jobs (mapv #(select-keys % [:job/id
-                                                                                :job/status
-                                                                                :job/started-at
-                                                                                :job/stopped-at
-                                                                                :job/name
-                                                                                :job/build])
-                                                                     (:run/jobs run))
-                                                :jobs-for-first (mapv #(select-keys % [:job/id
-                                                                                :job/build
-                                                                                :job/name])
-                                                                      (:run/jobs run))))]
-                (cb {:circleci/run run-with-aliases} query))))
-           (:run/id (:params ast)))
-
-          ;; :route/org-workflows
-          (org-runs-ast? ast) (get-org-runs ast cb query))))))
+             (:run/id (:params ast)))
+
+            (let [{:keys [key query]} ast]
+              (and (= :circleci/run key)
+                   (= '[({:jobs-for-jobs [:job/id
+                                          :job/status
+                                          :job/started-at
+                                          :job/stopped-at
+                                          :job/name
+                                          :job/build]}
+                         {:< :run/jobs})
+                        ({:jobs-for-first [:job/id
+                                           :job/build
+                                           :job/name]}
+                         {:< :run/jobs})]
+                      query)))
+            (api/get-workflow-status
+             (callback-api-chan
+              (fn [response]
+                (let [run (adapt-to-run response)
+                      run-with-aliases (-> run
+                                           (dissoc :run/jobs)
+                                           (assoc :jobs-for-jobs (mapv #(select-keys % [:job/id
+                                                                                :job/status
+                                                                                :job/started-at
+                                                                                :job/stopped-at
+                                                                                :job/name
+                                                                                :job/build])
+                                                                       (:run/jobs run))
+                                                  :jobs-for-first (mapv #(select-keys % [:job/id
+                                                                                :job/build
+                                                                                :job/name])
+                                                                        (:run/jobs run))))]
+                  (cb {:circleci/run run-with-aliases} query))))
+             (:run/id (:params ast)))
+
+            ;; :route/org-workflows
+            (org-runs-ast? ast) (get-org-runs ast cb query)))))))

 (defn send [remotes cb]
   (doseq [remote-entry remotes]


Added new localization key for situations when weather data is being fetched.

--- app/src/weather/localization.cljc
+++ app/src/weather/localization.cljc
@@ -2,6 +2,7 @@

 (def dictionary {:title "Weather with Clojure from Wunderground!"
                  :submit "Show me the weather!"
+                 :fetching-data "Fetching data. Please wait..."
                  :current-weather "Here is the current weather:"
                  :data-arrived "Here is the weather data you wanted:"
                  :fog "There was some fog to be seen!"


pre/altcrawl.clj: store scraper handler in a binding var

Because using the binding arg to jruby.eval
overrides ALL currently defined globals.

--- src/org/altlaw/jobs/pre/altcrawl.clj
+++ src/org/altlaw/jobs/pre/altcrawl.clj
@@ -1,29 +1,26 @@
 (ns org.altlaw.jobs.pre.altcrawl
-  (:require [org.altlaw.util.hadoop :as hadoop]
+  (:require [org.altlaw.util.hadoop :as h]
             [org.altlaw.util.files :as files]
             [org.altlaw.util.tsv :as tsv]
-            [clojure.contrib.walk :as walk])
+            [org.altlaw.util.jruby :as ruby]
+            [org.altlaw.util.context :as context]
+            [org.altlaw.util.log :as log]
+            [org.altlaw.db.docids :as ids]
+            [clojure.contrib.walk :as walk]
+            [clojure.contrib.singleton :as sing])
   (:use clojure.contrib.json.read
         org.altlaw.util.log)
   (:import (org.apache.commons.codec.binary Base64)
            (javax.script ScriptContext ScriptEngine ScriptEngineManager)
            (java.io StringReader)))

-(hadoop/setup-mapreduce)
+(h/setup-mapreduce)

-(declare *reporter* *raw-input*)
-
-(defn counter [group name]
-  (.incrCounter *reporter* group name 1))
-
-(def *ruby* nil)
-
-(def *ruby-context* nil)
-
-(def *docid-map* nil)
-
-(defn get-docid [uri]
-  (get *docid-map* uri))
+(def scraper-handler
+     (sing/per-thread-singleton
+      (fn []
+        (ruby/eval-jruby "require 'org/altlaw/extract/scrape/scraper_handler'")
+        (ruby/eval-jruby "ScraperHandler.new"))))

 (defn- decode-response-body [download]
   (assoc download :response_body_bytes
@@ -57,22 +54,14 @@

 ;; Step 3 (for HTML): Run scrapers

-(defn handle-scraped [record]
-  [101 (pr-str record)])
-
-(defn handle-scraper-output [output]
-  (filter identity
-          (map (fn [line]
-                 (when (seq (.trim line))
-                   (handle-scraped (read-json-string line))))
-               (.split output "\n"))))
+(defn handle-scraper-record [record]
+  [101 (pr-str (into {} record))])

 (defn run-scrapers [download]
-  (handle-scraper-output
-   (with-out-str
-     (.setWriter *ruby-context* *out*)
-     (.setReader *ruby-context* (StringReader. *raw-input*))
-     (.eval *ruby* "$runner.parse_all_from_stream($stdin)"))))
+  (map handle-scraper-record
+       (ruby/eval-jruby "$handler.parse(Download.from_map($dmap))"
+                        {:dmap (walk/stringify-keys download)
+                         :handler (scraper-handler)})))

 ;;; Step 4 (for PDFs): convert to HTML
@@ -83,12 +72,12 @@
 ;;; Step 3 (for PDFs): dispatch on presence of Docid

 (defn handle-pdf [download]
-  (if-let [docid (get-docid (:request_uri download))]
+  (if-let [docid (ids/get-docid "altcrawl" (:request_uri download))]
     (do (debug "handle-pdf got docid " docid " for " (:request_uri download))
-        (counter "PDF files" "with docid")
+        (h/counter "PDF files" "with docid")
         (convert-pdf docid download))
     (do (warn "handle-pdf found no docid for " (:request_uri download))
-        (counter "PDF files" "no docid"))))
+        (h/counter "PDF files" "no docid"))))

 ;;; Step 2: dispatch on MIME type of the download
@@ -98,24 +87,24 @@
     (files/guess-mime-type-by-content (:response_body_bytes download))))

 (defmethod mime-type-dispatch "application/pdf" [download]
-  (counter "MIME types" "PDF")
+  (h/counter "MIME types" "PDF")
   (debug "mime-type-dispatch got PDF from " (:request_uri download))
   (handle-pdf download))

 (defmethod mime-type-dispatch "text/html" [download]
-  (counter "MIME types" "HTML")
+  (h/counter "MIME types" "HTML")
   (debug "mime-type-dispatch got HTML from " (:request_uri download))
   (run-scrapers download))

 (defmethod mime-type-dispatch :default [download]
-  (counter "MIME types" "unknown")
+  (h/counter "MIME types" "unknown")
   (warn "mime-type-dispatch found no handler for " (:request_uri download)))

 ;;; Step 1: dispatch on Status code of the download

 (defn status-code-dispatch [download]
-  (counter "Status codes" (str (:response_status_code download)))
+  (h/counter "Status codes" (str (:response_status_code download)))
   (if (= 200 (:response_status_code download))
     (mime-type-dispatch download)
     (warn "status-code-dispatch saw "
@@ -123,38 +112,17 @@
           " from " (:request_uri download))))

-(defn my-map [download]
+(defn my-map [key download]
   (status-code-dispatch (decode-response-body download)))

 ;;; MAPPER METHODS

-(defn load-jruby []
-  (alter-var-root #'*ruby*
-                  (fn [_] (.getEngineByName (ScriptEngineManager.) "jruby")))
-  (alter-var-root #'*ruby-context*
-                  (fn [_] (.getContext *ruby*)))
-  (.eval *ruby* (str "require 'org/altlaw/extract/scrape/run_scraper'"))
-  (.eval *ruby* (str "$runner = RunScraper.new")))
+(defn mapper-configure [this job]
+  (context/use-hadoop-jobconf job))

-(defn mapper-configure [this job]
-  (let [cached (DistributedCache/getLocalCacheFiles job)
-        path (first (filter #(= (.getName %) "docids.tsv.gz") cached))]
-    (when (nil? path) (throw (RuntimeException. "No docid.tsv.gz in DistributedCache.")))
-    (info "Loading docid map from " path)
-    (alter-var-root #'*docid-map*
-                    (fn [_] (tsv/load-tsv-map (str path))))
-    (load-jruby)))
-
-(defn mapper-map [this wkey wvalue output reporter]
-    (let [input (walk/keywordize-keys (read-json-string (str wvalue)))]
-      (debug "Called map with file position " wkey
-             " and value " (logstr input))
-      (binding [*reporter* reporter
-                *raw-input* (str wvalue)]
-        (doseq [[key value] (my-map input)]
-          (.collect output (Text. (str key)) (Text. value))))))
+(def mapper-map (partial h/json-map my-map))

@@ -169,17 +137,17 @@
 ;;; TOOL METHODS

 (defn tool-run [this args]
-  (let [job (hadoop/default-jobconf this)
-        outpath (Path. (hadoop/job-path :pre :altcrawl))
+  (let [job (h/default-jobconf this)
+        outpath (Path. (h/job-path :pre :altcrawl))
         hdfs (FileSystem/get job)]
     (.setJobName job "pre.altcrawl")
-    (FileInputFormat/setInputPaths job (str (hadoop/job-path :seqfiles :altcrawl) "/*.jsr"))
+    (FileInputFormat/setInputPaths job (str (h/job-path :seqfiles :altcrawl) "/*.jsr"))
     (FileOutputFormat/setOutputPath job outpath)
     (.setInputFormat job TextInputFormat)
     (.delete hdfs outpath true)
     (.setMapperClass job (Class/forName "org.altlaw.jobs.pre.altcrawl_mapper"))
     (.setReducerClass job (Class/forName "org.altlaw.jobs.pre.altcrawl_reducer"))
     (.setMapOutputKeyClass job Text)
-    (DistributedCache/addCacheFile (URI. (hadoop/docid-path :seqfiles :ohm1)) job)
+    (DistributedCache/addCacheFile (URI. (h/docid-path :seqfiles :ohm1)) job)
     (JobClient/runJob job))
   0)


Hook up radial layout to showgraph. A bit broken. #48

--- samples/twitterbuzz/src/twitterbuzz/showgraph.cljs
+++ samples/twitterbuzz/src/twitterbuzz/showgraph.cljs
@@ -40,6 +40,9 @@
 (defn unit-to-pixel [unit-arg canvas-size]
   (+ (* unit-arg (- canvas-size avatar-size)) (/ avatar-size 2)))

+(defn log [& args]
+  (js* "console.log(~{})" (apply pr-str args)))
+
 (defn draw-graph [{:keys [locs mentions]} text]
   (let [canvas-size (. g (getPixelSize))]
     (. g (clear))
@@ -57,7 +60,8 @@
                     (get edge-strokes mention-count max-stroke) nil))))

     ; Draw avatar nodes
-    (doseq [[username {:keys [x y]}] locs]
+    (doseq [[username {:keys [x y] :as foo}] locs]
+      ;(log (pr-str foo))
       (.drawImage g
                   (- (unit-to-pixel x (.width canvas-size))  (/ avatar-size 2))
                   (- (unit-to-pixel y (.height canvas-size)) (/ avatar-size 2))
@@ -71,31 +75,10 @@
         (.drawTextOnLine g text 5 20 (.width canvas-size) 20
                         "left" font nil fill)))))

-(def users (atom nil))
-(buzz/register :graph-update #(reset! users %))
+(buzz/register :graph-update #(draw-graph (layout/radial %) nil))

 (def animation (atom nil))

-(set! (.cycle animation)
-  (fn [t]
-    (let [a (first @animation)]
-      (draw-graph (:best a) (debug a))
-      (swap! animation #(drop anneal-skipping %))
-      (when (= (:best a) (:best (first @animation)))
-        ; no better graph in the last 'anneal-skipping' steps, so quit trying.
-        (anim/unregisterAnimation animation)))))
-
-(defn start-anneal []
-  (reset! animation
-    (ann/anneal
-      layout/score
-      (ann/linear-cooling cooling)
-      layout/permute-move
-      ann/standard-prob
-      (layout/init-state @users)))
-  (anim/registerAnimation animation))
-
-(events/listen
-  (dom/getElement "network") (array events/EventType.CLICK) start-anneal)
-(buzz/register :track-clicked start-anneal)
-(buzz/register :refresh-clicked start-anneal)
+;(events/listen (dom/getElement "network") events/EventType.CLICK start-anneal)
+;(buzz/register :track-clicked start-anneal)
+;(buzz/register :refresh-clicked start-anneal)


Added the ability to edit pages.

Added the ability to edit pages.

--- src/ackbar/core.clj
+++ src/ackbar/core.clj
@@ -24,10 +24,10 @@
 (defn response-wrapper
   ([title body] (response-wrapper title body 200))
   ([title body status]
-   {:status status
-    :headers {"Content-Type" "text/html"}
-    :body (xhtml [:head [:title title]]
-                 [:body body])}))
+     {:status status
+      :headers {"Content-Type" "text/html"}
+      :body (xhtml [:head [:title title]]
+                   [:body body])}))

 (defn render-page
   "Retrieve a page from the datastore and render it for display to the user"
@@ -35,23 +35,23 @@
   (try
     (response-wrapper name (:body (ds/retrieve Page name)))
     (catch EntityNotFoundException _
-        (response-wrapper "404" (str "Unable to find page: " name) 404))))
+      (response-wrapper "404" (str "Unable to find page: " name) 404))))

 (defn admin-add-page
   "Displays the Ackbar Admin 'Add Page' Page"
   []
   (response-wrapper "Add Page"
-   (form-to [:post "/admin/add_page"]
-            (label "title" "Title:")
-            [:br]
-            (text-field "title")
-            [:br]
-            (label "body" "Body:")
-            [:br]
-            (text-area {:cols 80 :rows 40} "body")
-            [:br]
-            (submit-button "Submit")
-            )))
+                    (form-to [:post "/admin/add"]
+                             (label "title" "Title:")
+                             [:br]
+                             (text-field "title")
+                             [:br]
+                             (label "body" "Body:")
+                             [:br]
+                             (text-area {:cols 80 :rows 40} "body")
+                             [:br]
+                             (submit-button "Submit")
+                             )))

 (defn add-page
   "Adds a page to the database with the specified title and content"
@@ -60,37 +60,58 @@
   (result "Page saved!")
   )

+(defn page-link
+  "Builds a link to the specified page object"
+  [page]
+  (link-to (str "/" (:name page)) (:name page)))
+
+(defn edit-link
+  "Builds a link to edit the specified page"
+  [page]
+  (link-to (str "/admin/edit/" (:name page)) "edit"))
+
+(defn delete-link
+  "Builds a link to delete the specified page"
+  [page]
+  (form-to [:post (str "/admin/delete/" (:name page))]
+           (submit-button "Delete")))
+
+(defn admin-page-list
+  "The admin page listing all pages along with edit and delete links"
+  []
+  (def page-list (ds/query :kind Page))
+  (if (empty? page-list)
+    (response-wrapper "No Pages Yet!" "No pages.")
+    (response-wrapper "Page List"
+                      [:ul (for [page page-list]
+                             [:li (page-link page) [:br]
+                              (edit-link page) (delete-link page)])])))
+
+(defn delete-page
+  "Deletes the specified page by name."
+  [name]
+    (try
+      (do (ds/delete! (ds/retrieve Page name))
+          (response-wrapper "Deleted"
+                            (str "Page deleted: " name)))
+
+    (catch EntityNotFoundException _
+      (response-wrapper "404" (str "Unable to find page: " name) 404))))
+
 (defn admin-edit-page
   "Displays the Ackbar Admin 'Edit Page' Page"
   []
   (result "Admin Edit Page"))

-(defn admin-delete-page
-  "Displays the Ackbar Admin 'Delete Page' Page"
-  []
-  (result "Admin Delete Page"))
-
-(defn combined-js
-  "A link to the minified and combined javascript for the project"
-  []
-  (result "Combined Javascript"))
-
-(defn combined-css
-  "A link to the combined CSS for the project."
-  []
-  (result "Combined CSS"))
-
 (defroutes ackbar-app-handler
   (GET "/" [] (render-page "home"))
-  (GET "/admin/add_page" [] (admin-add-page))
-  (POST "/admin/add_page" {params :params}
+  (GET "/admin/add" [] (admin-add-page))
+  (GET "/admin/pages" [] (admin-page-list))
+  (POST "/admin/add" {params :params}
         (add-page (params "title") (params "body")))
-  (GET "/admin/edit_page" [] (admin-edit-page))
-  (POST "/admin/edit_page" {params :params} (render-page "edit page post"))
-  (GET "/admin/delete_page" [] (admin-delete-page))
-  (POST "/admin/delete_page" {params :params} (render-page "delete page post"))
-  (GET "/static/combined.js" [] (combined-js))
-  (GET "/static/combined.css" []  (combined-css))
+  (GET "/admin/edit/:name" [name] (admin-edit-page name))
+  (POST "/admin/edit/:name" [name params] (render-page "edit page post"))
+  (POST "/admin/delete/:name" [name] (delete-page name))
   (GET "/:name" [name] (render-page (canonical-name name)))
   (ANY "*" [] (response-wrapper "404" "NOT FOUND!" 404)))


only send new tag to users that can see it

--- src/chat/server/sync.clj
+++ src/chat/server/sync.clj
@@ -93,10 +93,11 @@
   [{:as ev-msg :keys [event id ?data ring-req ?reply-fn send-fn]}]
   (when-let [user-id (get-in ring-req [:session :user-id])]
     (if (db/with-conn (db/user-in-group? user-id (?data :group-id)))
-      (do (db/with-conn (db/create-tag! (select-keys ?data [:id :name :group-id])))
-          (doseq [uid (->> (:any @connected-uids)
-                           (remove (partial = user-id)))]
-            (chsk-send! uid [:chat/create-tag ?data])))
+      (let [new-tag (db/with-conn (db/create-tag! (select-keys ?data [:id :name :group-id])))]
+        (doseq [uid (->> (:any @connected-uids)
+                         (filter #(db/with-conn (db/user-in-tag-group? % (:id new-tag))))
+                         (remove (partial = user-id)))]
+          (chsk-send! uid [:chat/create-tag ?data])))
       ; TODO: indicate permissions error to user?
       (timbre/warnf "User %s attempted to create a tag %s in a disallowed group"
                     user-id (?data :name) (?data :group-id)))))


update doc strings

update doc strings

--- src/clj/aspire/model.clj
+++ src/clj/aspire/model.clj
@@ -4,15 +4,15 @@
 (def browser-model (atom {}))

 (defn update-in!
-  "Pass a fn to update a path within 'model.
-   Use this whenever you need to update the value of a path within 'model.
+  "Pass a fn to update a path within 'browser-model.
+   Use this whenever you need to update the value of a path within 'browser-model.
    Example: (update-in! [:ui :user2comp 1234 :current_score] (fn [old-val] (inc old-val)))
    Example: (update-in! [:ui :user2comp 1234] update-iscomplete requirements-spec)"
   [path fn & args]
   (apply swap! browser-model update-in path fn args))

 (defn get-in!
-  "Retrieve the value of a path within 'model.
+  "Retrieve the value of a path within 'browser-model.
    DO NOT retrieve the value, do some processing, and then assoc-in! a new value.
    Instead, see update-in! to avoid overwriting changes made between your calls to get-in! a subsequent assoc-in!.
    Example: (get-in! [:ui :comps 73 :name])"
@@ -20,8 +20,9 @@
   (get-in @browser-model path))

 (defn assoc-in!
-  "Set the value for a path within 'model.
-   DO NOT use assoc-in! to overwrite an existing value within 'model, unless overwriting is explicitly what you intend.
+  "Set the value for a path within 'browser-model.
+   DO NOT use assoc-in! to overwrite an existing value within
+   'browser-model, unless overwriting is explicitly what you intend.
    Instead, see update-in!.
    Example: (assoc-in! [:ui :comps 73] {:id 73 :name \"Some Competency\" :version \"v3\"})"
   [path val]
@@ -45,7 +46,7 @@
     (dissoc m k)))

 (defn dissoc-in!
-  "Remove the value of a path within 'model.
+  "Remove the value of a path within 'browser-model.
    Example: (dissoc-in! [:ui :comps 73])"
   [path]
   (swap! browser-model dissoc-in path))


CLJS-1110: cljs.closure/watch needs to print errors to *err*

--- src/clj/cljs/closure.clj
+++ src/clj/cljs/closure.clj
@@ -57,7 +57,8 @@
            [javax.xml.bind DatatypeConverter]
            [java.nio.file Path Paths Files StandardWatchEventKinds WatchKey
                           WatchEvent FileVisitor FileVisitResult]
-           [com.sun.nio.file SensitivityWatchEventModifier]))
+           [com.sun.nio.file SensitivityWatchEventModifier]
+           [com.google.common.base Throwables]))

 (def name-chars (map char (concat (range 48 57) (range 65 90) (range 97 122))))

@@ -1486,7 +1487,8 @@
                   (when-let [f (:watch-fn opts)]
                     (f))
                   (catch Throwable e
-                    (.printStackTrace e))))
+                    (binding [*out* *err*]
+                      (println (Throwables/getStackTraceAsString e))))))
               (watch-all [^Path root]
                 (Files/walkFileTree root
                   (reify


CLJS-1093: Better compiler defaults

CLJS-1093: Better compiler defaults

:optimizations :none is the default if nothing supplied. if :optimizations
:none, :cache-analysis is true and :source-map is true by default unless
different setting supplied

:verbose is the default for cljs.closure/watch unless different setting
supplied

--- src/clj/cljs/closure.clj
+++ src/clj/cljs/closure.clj
@@ -1310,7 +1310,11 @@
   (and (satisfies? deps/IJavaScript js)
        (deps/-foreign? js)))

-(defn add-implicit-options [opts]
+(defn add-implicit-options
+  [{:keys [optimizations output-dir]
+    :or {optimizations :none
+         output-dir "out"}
+    :as opts}]
   (let [opts (cond-> opts
                (:closure-defines opts)
                (assoc :closure-defines
@@ -1322,15 +1326,21 @@
     (cond->
       (-> opts
         (assoc
+          :optimizations optimizations
+          :output-dir output-dir
           :ups-libs libs
           :ups-foreign-libs foreign-libs
           :ups-externs externs)
         (update-in [:preamble] #(into (or % []) ["cljs/imul.js"])))
+
       (:target opts)
       (assoc-in [:closure-defines (str (comp/munge 'cljs.core/*target*))]
         (name (:target opts)))
-      (nil? (:optimizations opts))
-      (assoc :optimizations :none))))
+
+      (= optimizations :none)
+      (assoc
+        :cache-analysis (:cache-analysis opts true)
+        :source-map (:source-map opts true)))))

 (defn build
   "Given a source which can be compiled, produce runnable JavaScript."
@@ -1458,7 +1468,10 @@
         env/*compiler*
         (env/default-compiler-env opts))))
   ([source opts compiler-env]
-    (let [path (Paths/get (.toURI (io/file source)))
+    (let [opts (cond-> opts
+                 (= (:verbose opts :not-found) :not-found)
+                 (assoc :verbose true))
+          path (Paths/get (.toURI (io/file source)))
           fs (.getFileSystem path)
           service (.newWatchService fs)]
       (letfn [(buildf []


when adding inputs to base module need to convert to Closure SourceFile

--- src/clj/cljs/closure.clj
+++ src/clj/cljs/closure.clj
@@ -693,8 +693,9 @@
           [sources []] (sort-modules (add-cljs-base-module (:modules opts))))
         cljs-base-closure-module (get-in modules [:cljs-base :closure-module])]
     ;; add anything left to :cljs-base module
-    (doseq [^SourceFile source sources']
-      (.add ^JSModule cljs-base-closure-module source))
+    (doseq [source sources']
+      (.add ^JSModule cljs-base-closure-module
+        (js-source-file (javascript-name source))))
     modules))

 (comment


added exercise-fn per dchelimsky

added exercise-fn per dchelimsky

--- src/clj/clojure/spec.clj
+++ src/clj/clojure/spec.clj
@@ -1679,6 +1679,18 @@
   ([spec n overrides]
      (map #(vector % (conform spec %)) (gen/sample (gen spec overrides) n))))

+(defn exercise-fn
+  "exercises the fn named by sym (a symbol) by applying it to
+  n (default 10) generated samples of its args spec. When fspec is
+  supplied its arg spec is used, and sym-or-f can be a fn.  Returns a
+  sequence of tuples of [args ret]. "
+  ([sym] (exercise-fn sym 10))
+  ([sym n] (exercise-fn sym n (get-spec sym)))
+  ([sym-or-f n fspec]
+     (let [f (if (symbol? sym-or-f) (resolve sym-or-f) sym-or-f)]
+       (for [args (gen/sample (gen (:args fspec)) n)]
+         [args (apply f args)]))))
+
 (defn coll-checker
   "returns a predicate function that checks *coll-check-limit* items in a collection with pred"
   [pred]


added documentation for the static data sets.

--- src/clj/forma/static.clj
+++ src/clj/forma/static.clj
@@ -17,29 +17,51 @@

 (def chunk-size 24000)

-;; TODO: Comments.
 (def static-datasets
-  {:gadm {:ncols 36001
-          :nrows 13962
-          :xulcorner -180.000001
-          :yulcorner 83.635972
-          :cellsize 0.01
-          :nodata -9999}
-   :ecoid {:ncols 36000
-           :nrows 17352
-           :xulcorner -179.99996728576
-           :yulcorner 83.628027
-           :cellsize 0.01
-           :nodata -9999}
+  ^{:doc "These are the static datasets, described briefly below.  The inner
+   keys (e.g., :ncols) are a quick transformation on the ASCII header, where
+   the coordinates for the upper left corner are presented, rather than the
+   lower left corner.  The only value that changes, then, is the y-coord.
+
+   gadm   :: administrative boundaries, found [here](http://goo.gl/2N5CT),
+   and converted to a raster with the cell value given by ID_2, an integer
+   value corresponding to the most detailed administrative unit.
+
+   ecoid  :: ecoregions according to the World Wildlife Fund. The technical
+   paper can be found [here](http://goo.gl/yvssq). The polygons are converted
+   to a raster for sampling - much like the admin boundaries - where each cell
+   is assigned the value of the ecoregion id, the most detailed eco unit.
+
+   hansen :: forest cover loss hotspots data for training at 500m resolution,
+   found [here](http://goo.gl/HqvCW). Note that this has been projected into
+   WGS84 from Sinusoidal (463.3127m res).  The time period is 2000-2005.
+
+   vcf    :: vegetation continuous field index, derived from MODIS products for
+   the year 2000, found [here](http://goo.gl/KW8y1), and used to define the
+   extent of the sample area, given by the Forest Cover Loss Hotspots training
+   data set."}
+
+  {:gadm   {:ncols 36001
+            :nrows 13962
+            :xulcorner -180.000001
+            :yulcorner 83.635972
+            :cellsize 0.01
+            :nodata -9999}
+   :ecoid  {:ncols 36000
+            :nrows 17352
+            :xulcorner -179.99996728576
+            :yulcorner 83.628027
+            :cellsize 0.01
+            :nodata -9999}
    :hansen {:ncols 86223
             :nrows 19240
             :xulcorner -179.99998844516
             :yulcorner 40.164567
             :cellsize 0.0041752289295106
             :nodata -9999}
-   :vcf {:ncols 86223
-         :nrows 19240
-         :xulcorner -179.99998844516
-         :yulcorner 40.164567
-         :cellsize 0.0041752289295106
-         :nodata -9999}})
+   :vcf    {:ncols 86223
+            :nrows 19240
+            :xulcorner -179.99998844516
+            :yulcorner 40.164567
+            :cellsize 0.0041752289295106
+            :nodata -9999}})


added domain mapping to service api

added domain mapping to service api

--- src/clj/swarmpit/api.clj
+++ src/clj/swarmpit/api.clj
@@ -4,8 +4,15 @@
             [swarmpit.domain :as dom]))

 (defn services
-  ([] (dc/get "/services"))
-  ([service-id] (dc/get (str "/services/" service-id))))
+  []
+  (->> (dc/get "/services")
+       (dom/<-services)))
+
+(defn service
+  [service-id]
+  (->> (str "/services/" service-id)
+       (dc/get)
+       (dom/<-service)))

 (defn delete-service
   [service-id]


bullet starting position

bullet starting position

--- src/cljs/mpd/player.cljs
+++ src/cljs/mpd/player.cljs
@@ -53,8 +53,8 @@
 ; FIRE

 (defn make-bullet [player]
-  {:x (:x player)
-   :y (:y player)
+  {:x (+ (:x player) (* (Math/cos (:rotation player)) 80))
+   :y (+ (:y player) (* (Math/sin (:rotation player)) 80))
    :angle (:rotation player)
    :speed 10
    :distance 100


Relative urls

Relative urls

--- src/cljs/threed/api.cljs
+++ src/cljs/threed/api.cljs
@@ -18,7 +18,7 @@
 (defn send-position! [pos]
   (edn-xhr
    {:method :post
-    :url "/events"
+    :url "events" ;; TODO url builder
     :data {:event/name "add" :event/position pos
            }
     :on-complete
@@ -29,7 +29,7 @@
   (let [result (chan)]
     (edn-xhr
      {:method :get
-      :url "/events"
+      :url "events"
       :on-complete
       (fn [res]
         (put! result (events->positions (:events res))))


Removed history horizon for discounted-case-improvements

--- src/clojush/evaluate.clj
+++ src/clojush/evaluate.clj
@@ -252,7 +252,7 @@
                                 ":print-history must be true for :discounted-case-improvements"))
                             (if (empty? (rest (:history ind)))
                               (vec (repeat (count (:errors ind)) 1000000))
-                              (vec (for [case-history (apply map list (take 10 (:history ind)))]
+                              (vec (for [case-history (apply map list (:history ind))]
                                      (if (zero? (first case-history))
                                        ;; note only zero is solved
                                        ;; error-threshold applies to total so can't be used here


Fix/improve discounted total error meta-errors.

--- src/clojush/evaluate.clj
+++ src/clojush/evaluate.clj
@@ -112,16 +112,35 @@
                                 1000000
                                 (loop [remaining hist
                                        new-best-count 0
-                                       scale 1]
+                                       scale 1
+                                       max-total 0]
                                   (if (empty? (rest remaining))
-                                    (- 1.0 (/ new-best-count (dec (count hist))))
+                                    (- 1.0 (/ new-best-count max-total))
                                     (recur (rest remaining)
                                            (+ new-best-count
                                               (if (every? #(> % (first remaining))
                                                           (rest remaining))
                                                 (/ 1 scale)
                                                 0))
-                                           (inc scale)))))))
+                                           (* 2.0 scale)
+                                           (+ max-total (/ 1 scale))))))))
+                          ;
+                          (= cat :discounted-total-error-improvement-ratio)
+                          (if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :discounted-total-error-improvement-ratio"))
+                            (if (empty? (rest (:history ind)))
+                              1000000
+                              (let [diffs (mapv (fn [[a b]] (- a b))
+                                                (partition 2 1 (:history ind)))
+                                    improvements (mapv #(if (neg? %) 1.0 0.0)
+                                                       diffs)
+                                    persistence 0.9
+                                    weights (take (count diffs)
+                                                  (iterate (partial * persistence) 1))]
+                                (- 1 (/ (reduce + (mapv * improvements weights))
+                                        (reduce + weights))))))
                           ;
                           (= cat :reproductive-fidelity)
                           (let [g (:genome ind)]


Hack more

Hack more

--- src/clojush/evaluate.clj
+++ src/clojush/evaluate.clj
@@ -287,7 +287,7 @@
                                          (/ 1.0 (inc (/ sum
                                                         (reduce + weights)))))))))) ;;;;;;;;;;;;;; HACK
                           ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HACKED STABILITY
-                          (if (not (:print-history argmap))
+                          #_(if (not (:print-history argmap))
                             (throw
                               (Exception.
                                 ":print-history must be true for :case-stagnation"))
@@ -303,13 +303,304 @@
                                                                1.0
                                                                (if (= older-error newer-error)
                                                                  0.0
-                                                                 0.5)))
+                                                                 0.0)))
                                                            (partition 2 1 case-history))
                                              weights (take (count changes)
                                                            (iterate (partial * (- 1 improvement-discount)) 1.0))
                                              sum (reduce + (mapv * changes weights))]
-                                         (/ 1.0 (inc (/ sum
-                                                        (reduce + weights)))))))))) ;;;;;;;;;;;;;; HACK
+                                         (* (first case-history)
+                                            (/ 1.0 (inc (/ sum
+                                                           (reduce + weights))))))))))) ;;;;;;;;;;;;;; HACK
+                          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HACKED STABILITY
+                          #_(if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :case-stagnation"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (* 2 (count (:errors ind))) 1000000)) ;******************** HACK
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     (if false ;(zero? (first case-history)) ;;;;;;;;;; HACK
+                                       ;; note only zero is solved
+                                       ;; error-threshold applies to total so can't be used here
+                                       0 ;; solved, improvement doesn't matter
+                                       (let [changes (mapv (fn [[newer-error older-error]]
+                                                             (if (> older-error newer-error)
+                                                               1.0
+                                                               (if (= older-error newer-error)
+                                                                 0.0
+                                                                 0.0)))
+                                                           (partition 2 1 case-history))
+                                             weights (take (count changes)
+                                                           (iterate (partial * (- 1 improvement-discount)) 1.0))
+                                             sum (reduce + (mapv * changes weights))]
+                                         [(first case-history)
+                                          (/ 1.0 (inc (/ sum
+                                                         (reduce + weights))))])))))) ;;;;;;;;;;;;;; HACK
+                          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HACKED STABILITY
+                          #_(if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :case-stagnation"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (* 2 (count (:errors ind))) 1000000)) ;******************** HACK
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     (if false ;(zero? (first case-history)) ;;;;;;;;;; HACK
+                                       ;; note only zero is solved
+                                       ;; error-threshold applies to total so can't be used here
+                                       0 ;; solved, improvement doesn't matter
+                                       (let [changes (mapv (fn [[newer-error older-error]]
+                                                             (if (> older-error newer-error)
+                                                               1.0
+                                                               (if (= older-error newer-error)
+                                                                 0.0
+                                                                 0.0)))
+                                                           (partition 2 1 case-history))
+                                             weights (take (count changes)
+                                                           (iterate (partial * (- 1 improvement-discount)) 1.0))
+                                             sum (reduce + (mapv * changes weights))]
+                                         (vec (repeat 2 (/ 1.0 (inc (/ sum
+                                                                       (reduce + weights)))))))))))) ;;;;;;;;;;;;;; HACK
+                          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HACKED STABILITY
+                          #_(if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :case-stagnation"))
+                            (if (empty? (rest (:history ind)))
+                              1000000 ;******************** HACK
+                              (let [case-meta-errors
+                                    (for [case-history (apply map list (:history ind))]
+                                      (if false ;(zero? (first case-history)) ;;;;;;;;;; HACK
+                                        ;; note only zero is solved
+                                        ;; error-threshold applies to total so can't be used here
+                                        0 ;; solved, improvement doesn't matter
+                                        (let [changes (mapv (fn [[newer-error older-error]]
+                                                              (if (> older-error newer-error)
+                                                                1.0
+                                                                (if (= older-error newer-error)
+                                                                  0.0
+                                                                  0.0)))
+                                                            (partition 2 1 case-history))
+                                              weights (take (count changes)
+                                                            (iterate (partial * (- 1 improvement-discount)) 1.0))
+                                              sum (reduce + (mapv * changes weights))]
+                                          (/ 1.0 (inc (/ sum
+                                                         (reduce + weights)))))))]
+                                (mean case-meta-errors))))
+                          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HACKED STABILITY
+                          #_(if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :case-stagnation"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (count (:errors ind)) 1000000))
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     (if (zero? (first case-history))
+                                       ;; note only zero is solved
+                                       ;; error-threshold applies to total so can't be used here
+                                       0 ;; solved, improvement doesn't matter
+                                       (if (< (first case-history)
+                                              (second case-history))
+                                         0
+                                         1))))))
+                          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HACKED STABILITY
+                          #_(if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :case-stagnation"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (count (:errors ind)) 1000000))
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     (if (< (first case-history)
+                                            (second case-history))
+                                       0
+                                       1)))))
+                          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HACKED STABILITY
+                          #_(if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :case-stagnation"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (count (:errors ind)) 1000000))
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     (if (< (first case-history)
+                                            (second case-history))
+                                       0
+                                       (if (= (first case-history)
+                                              (second case-history))
+                                         1
+                                         0.5))))))
+                          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HACKED STABILITY
+                          #_(if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :case-stagnation"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (count (:errors ind)) 1000000))
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     (if (zero? (first case-history))
+                                       0 ;; solved, improvement doesn't matter
+                                       (if (< (first case-history)
+                                              (second case-history))
+                                         0
+                                         (if (= (first case-history)
+                                                (second case-history))
+                                           1
+                                           1)))))))
+                          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HACKED STABILITY
+                          #_(if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :case-stagnation"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (count (:errors ind)) 1000000))
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     (if (zero? (first case-history))
+                                       0 ;; solved, improvement doesn't matter
+                                       (let [improvements (mapv (fn [[newer-error older-error]]
+                                                                  (if (< newer-error older-error)
+                                                                    1.0
+                                                                    (if (= newer-error older-error)
+                                                                      0.0
+                                                                      0.5)))
+                                                                (partition 2 1 case-history))
+                                             weights (take (count improvements)
+                                                           (iterate (partial * (- 1 improvement-discount)) 1.0))
+                                             sum (reduce + (mapv * improvements weights))]
+                                         (inc (/ 1.0 (inc (/ sum (reduce + weights)))))))))))
+                          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HACKED STABILITY
+                          #_(if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :case-stagnation"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (count (:errors ind)) 1000000))
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     (let [improvements (mapv (fn [[newer-error older-error]]
+                                                                (if (or (zero? newer-error)
+                                                                        (< newer-error older-error))
+                                                                  1.0
+                                                                  (if (= newer-error older-error)
+                                                                    0.0
+                                                                    0.5)))
+                                                              (partition 2 1 case-history))
+                                           weights (take (count improvements)
+                                                         (iterate (partial * (- 1 improvement-discount)) 1.0))
+                                           sum (reduce + (mapv * improvements weights))]
+                                       (/ 1.0 (inc (/ sum (reduce + weights)))))))))
+                          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HACKED STABILITY
+                          #_(if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :case-stagnation"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (count (:errors ind)) 1000000))
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     (let [improvements (mapv (fn [[newer-error older-error]]
+                                                                (cond
+                                                                  (zero? newer-error) 1
+                                                                  (< newer-error older-error) 1/2
+                                                                  (= newer-error older-error) 0
+                                                                  :else 1/4))
+                                                              (partition 2 1 case-history))
+                                           weights (take (count improvements)
+                                                         (iterate (partial * (- 1 improvement-discount)) 1.0))
+                                           sum (reduce + (mapv * improvements weights))]
+                                       (/ 1.0 (inc (/ sum (reduce + weights)))))))))
+                          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HACKED STABILITY
+                          #_(if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :case-stagnation"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (count (:errors ind)) [1000000 1000000]))
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     [(let [improvements (mapv (fn [[newer-error older-error]]
+                                                                 (cond
+                                                                   (zero? newer-error) 1
+                                                                   (< newer-error older-error) 0.5
+                                                                   (= newer-error older-error) 0
+                                                                   :else 0))
+                                                               (partition 2 1 case-history))
+                                            weights (take (count improvements)
+                                                          (iterate (partial * (- 1 improvement-discount)) 1.0))
+                                            sum (reduce + (mapv * improvements weights))]
+                                        (/ 1.0 (inc (/ sum (reduce + weights)))))
+                                      (let [improvements (mapv (fn [[newer-error older-error]]
+                                                                 (cond
+                                                                   (zero? newer-error) 1
+                                                                   (< newer-error older-error) 0.5
+                                                                   (= newer-error older-error) 0
+                                                                   :else 0.5))
+                                                               (partition 2 1 case-history))
+                                            weights (take (count improvements)
+                                                          (iterate (partial * (- 1 improvement-discount)) 1.0))
+                                            sum (reduce + (mapv * improvements weights))]
+                                        (/ 1.0 (inc (/ sum (reduce + weights)))))]))))
+                          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HACKED STABILITY
+                          #_(if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :case-stagnation"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (count (:errors ind)) 1000000))
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     (if (zero? (first case-history))
+                                       0  ;; solved, improvement doesn't matter
+                                       (let [improvements (mapv (fn [[newer-error older-error]]
+                                                                  (if (< newer-error older-error)
+                                                                    1.0
+                                                                    (if (= newer-error older-error)
+                                                                      0.0
+                                                                      0.0)))
+                                                                (partition 2 1 case-history))
+                                             weights (take (count improvements)
+                                                           (iterate (partial * (- 1 improvement-discount)) 1.0))
+                                             sum (reduce + (mapv * improvements weights))]
+                                         (/ 1.0 (inc (/ sum
+                                                        1 ;(reduce + weights)
+                                                        ))))))))) ;;;;;;;;;;;;;; HACK
+                          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HACKED STABILITY
+                          #_(if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :case-stagnation"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (count (:errors ind)) 1000000))
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     (if (zero? (first case-history))
+                                       0  ;; solved, improvement doesn't matter
+                                       (let [improvements (mapv (fn [[newer-error older-error]]
+                                                                  (if (< newer-error older-error)
+                                                                    1.0
+                                                                    (if (= newer-error older-error)
+                                                                      0.0
+                                                                      -1.0)))
+                                                                (partition 2 1 case-history))
+                                             weights (take (count improvements)
+                                                           (iterate (partial * 0.5) 0.5))
+                                             sum (reduce + (mapv * improvements weights))]
+                                         (- sum)))))))
+                          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HACKED STABILITY
+                          (if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :case-stagnation"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (count (:errors ind)) 1000000))
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     (if (zero? (first case-history))
+                                       -100000  ;; solved, improvement doesn't matter
+                                       (let [improvements (mapv (fn [[newer-error older-error]]
+                                                                  (if (< newer-error older-error)
+                                                                    1.0
+                                                                    (if (= newer-error older-error)
+                                                                      0.0
+                                                                      -1.0)))
+                                                                (partition 2 1 case-history))
+                                             weights (take (count improvements)
+                                                           (iterate (partial * (- 1 improvement-discount)) 0.5))
+                                             sum (reduce + (mapv * improvements weights))]
+                                         (- sum)))))))
                           (= cat :reproductive-infidelity)
                           (let [g (:genome ind)]
                             (- 1.0


Add reset action for directory watcher

Add reset action for directory watcher

--- src/main/clojure/com/stuartsierra/lazytest/watch.clj
+++ src/main/clojure/com/stuartsierra/lazytest/watch.clj
@@ -22,6 +22,11 @@
   [state]
   (remove-watch *agent* ::watch)
   nil)
+
+(defn reset
+  "Send as an agent action, restarts a directory-watching agent."
+  [state]
+  {})

 (defn ns-mod-time-agent
   "Creates an agent that monitors namespaces for changes to their


logging and comments

logging and comments

--- src/babel/over.cljc
+++ src/babel/over.cljc
@@ -150,7 +150,10 @@
                      result)]
           result))
       (do
+        (log/debug (str "moreover-comp: fail: " result))
         (log/debug (str "moreover-comp: fail at: " (fail-path result)))
+        (log/debug (str "moreover-comp: fail: parent: " (strip-refs (get-in parent [:rule]))))
+        (log/debug (str "moreover-comp: fail: child: " (strip-refs child)))
         (if (and
              *throw-exception-if-failed-to-add-complement*
              (get-in child '(:head)))
@@ -160,8 +163,8 @@
                                   (get-in parent (fail-path result))
                                   "; Synsem of child is: "
                                   (get-in child '(:synsem) :top)))))
-        (log/debug (str "moreover-comp: complement synsem: " (get-in child '(:synsem) :top)))
-        (log/debug (str "moreover-comp:  parent value: " (get-in parent (fail-path result))))
+        (log/debug (str "moreover-comp: complement synsem: " (strip-refs (get-in child '(:synsem) :top))))
+        (log/debug (str "moreover-comp:  parent value: " (strip-refs (get-in parent (fail-path result)))))
         :fail))))

 (defn overh [parent head morph]


create failsafe 'morph' function if given value is null

--- src/babel/over.cljc
+++ src/babel/over.cljc
@@ -91,7 +91,7 @@
       nil)))

 (defn moreover-head [parent child lexfn-sem-impl morph]
-  (do
+  (let [morph (if morph morph (fn [x] x))]
     (log/trace (str "moreover-head (candidate) parent: [" (get-in parent [:rule]) "] '" (morph parent) "' sem:    " (strip-refs (get-in parent '(:synsem :sem) :no-semantics))))
     (log/trace (str "moreover-head (candidate) head child: [" (get-in parent [:child]) "] '" (morph child) "' sem:" (strip-refs (get-in child '(:synsem :sem) :top))))
     (let [result


better transfer-logging

better transfer-logging

--- boot/aether/src/boot/aether.clj
+++ boot/aether/src/boot/aether.clj
@@ -28,10 +28,21 @@
 (defn set-local-repo! [x] (reset! local-repo x))

 (defn transfer-listener
-  [{type :type meth :method {name :name repo :repository} :resource err :error :as info}]
+  [{type :type meth :method {name :name repo :repository size :size} :resource err :error :as info}]
   (util/dbug "Aether: %s\n" (with-out-str (pprint/pprint info)))
-  (when (and (.endsWith name ".jar") (= type :started))
-    (util/info "Retrieving %s from %s\n" (.getName (io/file name)) repo)))
+  (letfn [(->k [size] (if (neg? size) "" (str (Math/round (double (max 1 (/ size 1024)))))))]
+    (case type
+      :started
+      (util/info "%s %s from %s (%sk)\n"
+        (case meth :get "Retrieving" :put "Sending")
+        (.getName (io/file name))
+        repo
+        (->k size))
+
+      (:corrupted :failed)
+      (when err (util/fail (.getMessage err)))
+
+      nil)))

 (defn ^{:boot/from :technomancy/leiningen} build-url
   "Creates java.net.URL from string"
@@ -276,7 +287,7 @@
        :coordinates  [project version]
        :jar-file     (io/file jarpath)
        :pom-file     (io/file pomfile)
-       :transfer-listener :stdout
+       :transfer-listener transfer-listener
        :artifact-map artifact-map
        :repository   {repo-id repo-settings}
        :local-repo   (or (:local-repo env) @local-repo nil)))))


added a ! to cluster-eval in cluster.clj (Sam on Dan's machine)

--- leiningen/cluster.clj
+++ leiningen/cluster.clj
@@ -17,7 +17,7 @@
      project
      `(do (println (format "Creating cluster of %s instances and %d nodes."
                            ~node-type ~node-count))
-          (forma.hadoop.cluster/create-cluster ~node-type ~node-count)
+          (forma.hadoop.cluster/create-cluster! ~node-type ~node-count)
           (println "Cluster created!")
           (println "Hit Control-C to exit.")))))

@@ -26,7 +26,7 @@
   (cluster-eval
    project
    `(do (println "Running destroy-cluster.")
-        (forma.hadoop.cluster/destroy-cluster ~node-type)
+        (forma.hadoop.cluster/destroy-cluster! ~node-type)
         (println "Cluster destroyed!")
         (println "Hit Control-C to exit."))))


Whitespace.

Whitespace.

--- src/cbfg/store.cljs
+++ src/cbfg/store.cljs
@@ -60,7 +60,6 @@
                    (update-in [:next-sq] inc))
                {:opaque opaque :status :ok
                 :key key :sq new-sq :cas new-cas}])))))))
-

 (defn store-set [actx store opaque key old-cas val op]
   (ago store-set actx


Only print aliases when there are aliases set for a command.

--- src/cli4clj/cli.clj
+++ src/cli4clj/cli.clj
@@ -104,7 +104,10 @@
     (fn []
       (doseq [c command-names]
         (when (map? (cmds c))
-          (println (str (name c) " " (vec (map #(symbol (name %)) (c cmd-aliases)))))
+          (print (str (name c)))
+          (if (not (nil? (c cmd-aliases)))
+            (println "" (vec (map #(symbol (name %)) (c cmd-aliases))))
+            (println ""))
           (when-let [si (get-in cmds [c :short-info])]
             (println (str "\t" si)))
           (when-let [li (get-in cmds [c :long-info])]


Reimplemented set-of without lazy sequences

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

--- src/conexp/util.clj
+++ src/conexp/util.clj
@@ -233,7 +233,10 @@
 (defmacro set-of
   "Macro for writing sets as mathematicians do (at least similar to it.)"
   [thing condition]
-  `(set (for ~condition ~thing)))
+  `(with-local-vars [set# (transient #{})]
+     (doseq ~condition
+       (var-set set# (conj! (var-get set#) ~thing)))
+     (persistent! (var-get set#))))

 (defn div
   "Integer division."


right, still can't do this

right, still can't do this

--- src/datest1/ret.clj
+++ src/datest1/ret.clj
@@ -47,7 +47,7 @@
   )

-(def
+(defonce
   ^{:private true
     :doc "keeps a 1-to-1 map between symbol name and keyword
 ie. KEY_lines_count --> :lines_count
@@ -62,7 +62,7 @@
         )
   )

-(def
+(defonce
   ^{:doc "one to one mapping from keyword to symbol"}
 -allKeysToSymbols
   (ref (sorted-map-by comparator_AZ_order)
@@ -328,7 +328,7 @@
   )

 (defn afterTests []
-  ;(-cleanMaps)
+  (-cleanMaps);XXX: kinda depends when u're running the tests for this ns, if prior any other tests that use thing ns then should be ok, else it would lose those ns-es' bindings and likely cause them to fail
   )

 (defn testsFixture [testsHere]