Refactoring (extract function)

Refactoring (extract function)

--- src/cylon/oauth/impl/authorization_server.clj
+++ src/cylon/oauth/impl/authorization_server.clj
@@ -32,12 +32,103 @@
     (s/with-fn-validation
       (h req))))

-;;
+(defn authorize-client [component req store]
+  (let [session (get-session-from-cookie req SESSION-ID (:session-store component))]
+
+    (if-let [auth-interaction-session-result (get-result (:authenticator component) req)]
+      ;; the session can be authenticated or maybe we are
+      ;; coming from the authenticator workflow
+      (do
+        (debugf "auth session result is %s" auth-interaction-session-result)
+        (if (:cylon/authenticated? auth-interaction-session-result)
+          ;; "you are authenticated now!"
+
+          (let [_ (clean-resources! (:authenticator component) req)
+                code (str (java.util.UUID/randomUUID))
+                {:keys [client-id requested-scopes]}
+                session
+                {:keys [redirection-uri
+                        application-name
+                        description
+                        requires-user-acceptance
+                        required-scopes] :as client}
+                (lookup-client+ (:client-registry component) client-id)]
+
+            (assoc-session! (:session-store component) (get-session-id req SESSION-ID) :cylon/authenticated? true)
+            (assoc-session! (:session-store component) (get-session-id req SESSION-ID) :code code)
+
+            ;; Remember the code for the possible exchange - TODO expire these
+            (swap! store assoc
+                   {:client-id client-id
+                    :code code}
+                   {:created (java.util.Date.)
+                    :cylon/identity (:cylon/identity auth-interaction-session-result)})
+
+            ;; When a user permits a client, the client's scopes that they have accepted, are stored in the user preferences database
+            ;; why?
+            ;; because next time, we don't have to ask the user for their permission everytime they login
+            ;; ok, i understand
+            ;; however
+
+            (debugf (if requires-user-acceptance
+                      "App requires user acceptance"
+                      "App does not require user acceptance"))
+            ;; Lookup the application - do we have at-least the client id?
+            (if requires-user-acceptance
+              {:status 200
+               :body (html [:body
+                            [:form {:method :post :action (path-for (:modular.bidi/routes req) ::permit)}
+                             [:h1 "Authorize application?"]
+                             [:p (format "An application (%s) is requesting to use your credentials" application-name)]
+                             [:h2 "Application description"]
+                             [:p description]
+                             [:h2 "Scope"]
+                             (for [s requested-scopes]
+                               (let [s (apply str (interpose "/" (remove nil? ((juxt namespace name) s))))]
+                                 [:p [:label {:for s} s] [:input {:type "checkbox" :id s :name s :value s :checked true}]]))
+                             [:input {:type "submit"}]]
+                            ])}
+
+              (do
+                (debugf (format "App doesn't require user acceptance, granting scopes as required: [%s]" required-scopes))
+                (swap! store update-in
+                       [{:client-id client-id
+                         :code code}]
+                       assoc :granted-scopes required-scopes)
+                ;; 4.1.2: "If the resource owner grants the
+                ;; access request, the authorization server
+                ;; issues an authorization code and delivers it
+                ;; to the client by adding the following
+                ;; parameters to the query component of the
+                ;; redirection URI"
+                (redirect
+                 (str redirection-uri
+                      (as-query-string
+                       {"code" code
+                        "state"  (:state session)}))))))
+
+          ;; you have auth-session although you are NOT authenticated but ,,, we carry on with this session"
+          (do
+            (debugf "Session exists, but no evidence in it of authentication. Initiating authentication interaction using %s" (:authenticator component))
+            (initiate-authentication-interaction (:authenticator component) req {}))))
+
+      ;; You are not authenticated, so let's authenticate first.
+      (do
+        (debugf "Not authenticated, must authenticate first with %s" (:authenticator component))
+        (let [auth-session
+              (create-session!
+               (:session-store component)
+               {:client-id (-> req :query-params (get "client_id"))
+                :requested-scopes (decode-scope (-> req :query-params (get "scope")))
+                :state (-> req :query-params (get "state"))})]
+          (cookies-response-with-session
+           (initiate-authentication-interaction (:authenticator component) req {})
+           SESSION-ID auth-session))))))
+

 (defrecord AuthorizationServer [store scopes iss]
-
   WebService
-  (request-handlers [this]
+  (request-handlers [component]
     {::authorization-endpoint
      (-> (fn [req]
            ;; Establish whether the user-agent is already authenticated.
@@ -54,97 +145,7 @@

            (let [{response-type "response_type" client-id "client_id"} (:query-params req)]
              (case response-type
-               "code" (let [session (get-session-from-cookie req SESSION-ID (:session-store this))]
-
-                        (if-let [auth-interaction-session-result (get-result (:authenticator this) req)]
-                          ;; the session can be authenticated or maybe we are
-                          ;; coming from the authenticator workflow
-                          (do
-                            (debugf "auth session result is %s" auth-interaction-session-result)
-                            (if (:cylon/authenticated? auth-interaction-session-result)
-                              ;; "you are authenticated now!"
-
-                              (let [_ (clean-resources! (:authenticator this) req)
-                                    code (str (java.util.UUID/randomUUID))
-                                    {:keys [client-id requested-scopes]}
-                                    session
-                                    {:keys [redirection-uri
-                                            application-name
-                                            description
-                                            requires-user-acceptance
-                                            required-scopes] :as client}
-                                    (lookup-client+ (:client-registry this) client-id)]
-
-                                (assoc-session! (:session-store this) (get-session-id req SESSION-ID) :cylon/authenticated? true)
-                                (assoc-session! (:session-store this) (get-session-id req SESSION-ID) :code code)
-
-                                ;; Remember the code for the possible exchange - TODO expire these
-                                (swap! store assoc
-                                       {:client-id client-id
-                                        :code code}
-                                       {:created (java.util.Date.)
-                                        :cylon/identity (:cylon/identity auth-interaction-session-result)})
-
-                                ;; When a user permits a client, the client's scopes that they have accepted, are stored in the user preferences database
-                                ;; why?
-                                ;; because next time, we don't have to ask the user for their permission everytime they login
-                                ;; ok, i understand
-                                ;; however
-
-                                (debugf (if requires-user-acceptance
-                                          "App requires user acceptance"
-                                          "App does not require user acceptance"))
-                                ;; Lookup the application - do we have at-least the client id?
-                                (if requires-user-acceptance
-                                  {:status 200
-                                   :body (html [:body
-                                                [:form {:method :post :action (path-for (:modular.bidi/routes req) ::permit)}
-                                                 [:h1 "Authorize application?"]
-                                                 [:p (format "An application (%s) is requesting to use your credentials" application-name)]
-                                                 [:h2 "Application description"]
-                                                 [:p description]
-                                                 [:h2 "Scope"]
-                                                 (for [s requested-scopes]
-                                                   (let [s (apply str (interpose "/" (remove nil? ((juxt namespace name) s))))]
-                                                     [:p [:label {:for s} s] [:input {:type "checkbox" :id s :name s :value s :checked true}]]))
-                                                 [:input {:type "submit"}]]
-                                                ])}
-
-                                  (do
-                                    (debugf (format "App doesn't require user acceptance, granting scopes as required: [%s]" required-scopes))
-                                    (swap! store update-in
-                                           [{:client-id client-id
-                                             :code code}]
-                                           assoc :granted-scopes required-scopes)
-                                    ;; 4.1.2: "If the resource owner grants the
-                                    ;; access request, the authorization server
-                                    ;; issues an authorization code and delivers it
-                                    ;; to the client by adding the following
-                                    ;; parameters to the query component of the
-                                    ;; redirection URI"
-                                    (redirect
-                                     (str redirection-uri
-                                          (as-query-string
-                                           {"code" code
-                                            "state"  (:state session)}))))))
-
-                              ;; you have auth-session although you are NOT authenticated but ,,, we carry on with this session"
-                              (do
-                                (debugf "Session exists, but no evidence in it of authentication. Initiating authentication interaction using %s" (:authenticator this))
-                                (initiate-authentication-interaction (:authenticator this) req {}))))
-
-                          ;; You are not authenticated, so let's authenticate first.
-                          (do
-                            (debugf "Not authenticated, must authenticate first with %s" (:authenticator this))
-                            (let [auth-session
-                                  (create-session!
-                                   (:session-store this)
-                                   {:client-id (-> req :query-params (get "client_id"))
-                                    :requested-scopes (decode-scope (-> req :query-params (get "scope")))
-                                    :state (-> req :query-params (get "state"))})]
-                              (cookies-response-with-session
-                               (initiate-authentication-interaction (:authenticator this) req {})
-                               SESSION-ID auth-session)))))
+               "code" (authorize-client component req store)

                ;; Unknown response_type
                {:status 400
@@ -161,7 +162,7 @@
       ;; TODO I'm worred about the fact we must ensure that the session
       ;; represents a true authenticated user
       (fn [req]
-        (let [session (get-session-from-cookie req SESSION-ID (:session-store this))]
+        (let [session (get-session-from-cookie req SESSION-ID (:session-store component))]
           (if (:cylon/authenticated? session)
             (let [permitted-scopes (set (map
                                          (fn [x] (apply keyword (str/split x #"/")))
@@ -173,7 +174,7 @@
                   granted-scopes (set/intersection permitted-scopes requested-scopes)
                   code (:code session)
                   client-id (:client-id session)
-                  {:keys [redirection-uri] :as client} (lookup-client+ (:client-registry this) client-id)
+                  {:keys [redirection-uri] :as client} (lookup-client+ (:client-registry component) client-id)
                   ]

               (debugf "Granting scopes: %s" granted-scopes)
@@ -196,7 +197,7 @@
            (let [params (:form-params req)
                  code (get params "code")
                  client-id (get params "client_id")
-                 client (lookup-client+ (:client-registry this) client-id)]
+                 client (lookup-client+ (:client-registry component) client-id)]

              ;; "When making the request, the client authenticates with
              ;; the authorization server."
@@ -211,9 +212,10 @@
                              {:client-id client-id :code code})]

                  (let [{access-token :cylon.session/key}
-                       (create-session! (:access-token-store this) {:client-id client-id
-                                                                    :identity identity
-                                                                    :scopes granted-scopes})
+                       (create-session! (:access-token-store component)
+                                        {:client-id client-id
+                                         :identity identity
+                                         :scopes granted-scopes})
                        claim {:iss iss
                               :sub identity
                               :aud client-id
@@ -255,13 +257,13 @@
                   :body "Invalid request - unknown code"}))))
          wrap-params )})

-  (routes [this]
+  (routes [_]
     ["/" {"authorize" {:get ::authorization-endpoint}
           "permit-client" {:post ::permit}
           ;; TODO: Can we use a hyphen instead here?
           "access_token" {:post ::token-endpoint}}])

-  (uri-context [this] "/login/oauth")
+  (uri-context [_] "/login/oauth")

   AccessTokenAuthorizer
   (authorized? [component access-token scope]
@@ -274,10 +276,10 @@
                  scope)))

   RequestAuthorizer
-  (request-authorized? [this request scope]
+  (request-authorized? [component request scope]
     (when-let [auth-header (get (:headers request) "authorization")]
       (let [access-token (second (re-matches #"\Qtoken\E\s+(.*)" auth-header))]
-        (authorized? this access-token scope)))))
+        (authorized? component access-token scope)))))

 (defn new-authorization-server [& {:as opts}]
   (->> opts


removed logging

removed logging

--- src/frontend/cljs/alibi/activity_graphic.cljs
+++ src/frontend/cljs/alibi/activity_graphic.cljs
@@ -66,7 +66,7 @@
       (recur (. for-date plusDays -1)))))

 (defn c [el attrs & children]
-  (log "attrs %o" attrs)
+  ;(log "attrs %o" attrs)
   (apply js/React.createElement el attrs children))

 (defn svg-glow [id color & {:keys [radius std-dev] :or {:radius 1 :std-dev 1}}]


CMR-2454 fix indentation

CMR-2454 fix indentation

--- transmit-lib/src/cmr/transmit/echo/soap/authentication.clj
+++ transmit-lib/src/cmr/transmit/echo/soap/authentication.clj
@@ -23,7 +23,6 @@
 (defn login
   "Perform a login request against the SOAP API and return the generated token."
   [user pass]
-  (let [[status body-xml]
-        (soap/post-soap :authentication
-          (login-request user pass))]
+  (let [[status body-xml] (soap/post-soap :authentication
+                            (login-request user pass))]
       (xp/value-of body-xml "/Envelope/Body/LoginResponse/result")))


cleanup

cleanup


IMMUTANT-515

--- web/src/immutant/web.clj
+++ web/src/immutant/web.clj
@@ -35,6 +35,10 @@
      * :path          Maps the handler to a prefix of the url path [\"/\"]
      * :virtual-host  Virtual host name[s] (a String or a List of Strings) [nil]
      * :dispatch?     Invoke handlers in worker thread pool [true]
+
+   for servlets only:
+
+     * :servlet-name  The name to register the servlet under (gets passed to ServletInfo) [simple class name]

    Note the web server only binds to the loopback interface, by
    default. To expose your handler to the network, set :host to an


Add functions for querying stories

Add functions for querying stories

--- src/storemi/models/story.clj
+++ src/storemi/models/story.clj
@@ -197,6 +197,52 @@
        limit ?"
        limit])))

+(defn select-sql [& addendums]
+  (str "select * from stories "
+       (apply str addendums)))
+
+(defn filter-sql [exact & criterias]
+  (let [s (if exact
+            "%s = ?"
+            "%s ~* ?")]
+    (str
+      "where "
+      (apply str
+             (interpose " or " (map #(format s %) criterias))))))
+
+(defn valid-column [name]
+  (some #(= name %) ["username" "title" "synopsis"]))
+
+(defn what-sql [val criteria & [exact]]
+  (if (valid-column criteria)
+    [(select-sql (filter-sql exact criteria)) val]
+    [(select-sql
+       (filter-sql exact "username" "title" "synopsis"))
+     val val val]))
+
+(defn what-page [page-data]
+  (when page-data
+    ; safe if only page-data isn't direct user input
+    (format "limit %d offset %d"
+            (:limit page-data)
+            (:offset page-data))))
+
+(defn query-stories [val & {:keys [criteria exact page-data]}]
+  (let [sql (if-not val
+              (select-sql)
+              (what-sql val criteria exact))
+        result (vec (db/query sql))]
+
+    {:page-data page-data
+     :total (count result)
+     :stories
+     (if (empty? (select-keys page-data [:start :end]))
+       result
+       (com/safe-subvec
+         result
+         (:start page-data)
+         (:end page-data)))}))
+
 (defn user-stories [username]
   (db/query
     ["select id, title, username from stories where username = ?


improve separate function

improve separate function

--- src/testdouble/cljs/csv.cljs
+++ src/testdouble/cljs/csv.cljs
@@ -5,9 +5,9 @@
   (str "\"" s "\""))

 (defn- seperate [data separator quote]
-  (if quote
-    (str/join separator (map wrap-in-quotes data))
-    (str/join separator data)))
+  (str/join separator
+            (cond->> data
+              quote (map wrap-in-quotes))))

 (defn- write-data [data separator newline quote]
   (str/join newline (map #(seperate % separator quote) data)))


Improved go-to event impl.

Improved go-to event impl.

--- src/uxbox/data/projects.cljs
+++ src/uxbox/data/projects.cljs
@@ -161,16 +161,20 @@
   "A shortcut event that redirects the user to the
   first page of the project."
   ([projectid]
-   (go-to projectid nil))
+   (reify
+     rs/WatchEvent
+     (-apply-watch [_ state]
+       (println "go-to" projectid)
+       (let [pages (stpr/project-pages state projectid)
+             pageid (:id (first pages))
+             params {:project-uuid projectid
+                     :page-uuid pageid}]
+         (rx/of (r/navigate :workspace/page params))))))
+
   ([projectid pageid]
    (reify
-     rs/EffectEvent
-     (-apply-effect [_ state]
-       (if pageid
-         (rs/emit! (r/navigate :workspace/page {:project-uuid projectid
-                                                :page-uuid pageid}))
-         (let [pages (stpr/project-pages state projectid)
-               pageid (:id (first pages))]
-           (println "selected" pageid "projectid" projectid)
-           (rs/emit! (r/navigate :workspace/page {:project-uuid projectid
-                                                  :page-uuid pageid}))))))))
+     rs/WatchEvent
+     (-apply-watch [_ state]
+       (let [params {:project-uuid projectid
+                     :page-uuid pageid}]
+         (rx/of (r/navigate :workspace/page params)))))))


Added action for signing out

Added action for signing out

--- src/word_keeper/frontend.clj
+++ src/word_keeper/frontend.clj
@@ -34,3 +34,12 @@
       {:status 200
        :headers {"Content-Type" "text/plain"}
        :body ("Something went wrong")})))
+
+(defn action-signout [req]
+  (let [session (assoc
+                  (:session req)
+                  :request-token nil
+                  :uid nil)]
+    {:status 301
+     :session session
+     :headers {"location" "/"}}))


Allow rolling logs to be disabled

Allow rolling logs to be disabled

--- src/yetibot/core/logging.clj
+++ src/yetibot/core/logging.clj
@@ -19,15 +19,22 @@
       :warn
       (keyword (:value v)))))

+(defn rolling-appender-enabled?
+  "Rolling appender is enabled by default. Disable it by setting enabled=false"
+  []
+  (let [v (get-config String [:yetibot :log :rolling :enabled])]
+    (if-let [enabled (:value v)]
+      (not= enabled "false")
+      true)))
+
 (defn start []
-
-  (timbre/set-config!
-    {:level (log-level)
-     :appenders
-     ;; stdout
-     {:println (println-appender {:stream :auto})
-      ;; rolling log files
-      :rolling-appender (rolling-appender {:path "/var/log/yetibot/yetibot.log"
-                                           :pattern :daily})}})
-
-  )
+  (if (rolling-appender-enabled?)
+    (timbre/set-config!
+      {:level (log-level)
+       :appenders
+       ;; stdout
+       {:println (println-appender {:stream :auto})
+        ;; rolling log files
+        :rolling-appender (rolling-appender
+                            {:path "/var/log/yetibot/yetibot.log"
+                             :pattern :daily})}})))


#22 - Made positioning code independent of automatic browser hash behavior. Hash refs now center in window if possible.

--- src/biblecli/commands/staticpages.cljs
+++ src/biblecli/commands/staticpages.cljs
@@ -180,7 +180,9 @@

 (defn js []
 "// NOTE: Experimental
-document.lastElem = null;
+(function (document, window) {
+
+var lastElem = null;

 function RemoveHilite(el) {
     if(el) {
@@ -199,28 +201,50 @@
     }
 }

+function FindElem(id)
+{
+    return id === null ? null : document.getElementById(id);
+}
+
 function SetHilight()
 {
     var el;
-    if(document.lastElem) {
-        el = document.getElementById(document.lastElem);
-        RemoveHilite(el);
+    el = FindElem(lastElem);
+    RemoveHilite(el);
+
+    var id = '_' + window.location.hash.substr(1);
+    el = FindElem(id);
+    if(el) {
+        lastElem = id;
+        AddHilite(el);
+    } else {
+        lastElem = null;
     }
-
-    var id = window.location.hash.substr(1);
-    el = document.getElementById(id);
+}
+
+function CenterElem(el)
+{
     if(el) {
-        document.lastElem = id;
-        AddHilite(el);
+        var elRect = el.getBoundingClientRect(),
+            elHeight = elRect.bottom - elRect.top,
+            docEl = document.documentElement,
+            newY = window.scrollY +
+                   elRect.top -
+                   (docEl.clientHeight - elHeight) / 2;
+        window.scrollTo(window.scrollX, newY);
     }
 }

-document.addEventListener('DOMContentLoaded', function(e) {
-    SetHilight();
-    window.addEventListener('hashchange', function(e) {
-        SetHilight();
-    });
+window.addEventListener('hashchange', function(e) {
+  SetHilight();
 });
+
+window.addEventListener('load', function() {
+  SetHilight();
+  window.setTimeout(function() { CenterElem(FindElem(lastElem)); }, 1);
+});
+
+})(document, window);

 // Google Analytics
 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
@@ -330,7 +354,7 @@
     (rel-url book-id chap-num chap-cnt)))

 (defn toc-book [b]
-  [:p.tocp {:id (book-elem-id (:id b))}
+  [:p.tocp {:id (str "_" (book-elem-id (:id b)))}
     [:span.chapter (book-name (:id b))]
     " "
     (->> (:chapters b)
@@ -447,7 +471,7 @@

 (defn verse-id [i ch]
   (if-let [num (verse-num i ch)]
-    {:id num}
+    {:id (str "_" num)}
     {}))

 (defn verse [i ch v]


Adjust default pill-button border to be slightly lighter than the text

--- src/braid/client/ui/styles/mixins.cljs
+++ src/braid/client/ui/styles/mixins.cljs
@@ -35,17 +35,18 @@
   [:&
    pill-box
    [:&
-    {:color vars/grey-text
-     :border [[(px 1) "solid" vars/grey-text]]
+    {:color "#888"
+     :border [[(px 1) "solid" "#BBB"]]
      :background "none"}]

    [:&:hover
-    {:color "#eee"
-     :background vars/grey-text
+    {:color "#EEE"
+     :background "#888"
+     :border-color "#888"
      :cursor "pointer"}]

    [:&:active
-    {:color "#eee"
+    {:color "#EEE"
      :background "#666"
      :border-color "#666"
      :cursor "pointer"}]])


update objects

update objects

--- src/clj/morpheus/query/lang/update.clj
+++ src/clj/morpheus/query/lang/update.clj
@@ -4,7 +4,7 @@
             [morpheus.models.edge.core :as edge]
             [neb.utils :refer [map-on-keys]]))

-(defn update-vertex* [vertex field-exp-map]
+(defn update-object* [vertex field-exp-map]
   (loop [exp-pairs field-exp-map
          vertex-to-update vertex]
     (if (empty? exp-pairs)
@@ -14,8 +14,13 @@
                (assoc-in vertex-to-update k
                          (AST/eval-with-data vertex exp)))))))

+(defn update-object [update-func obj field-exp-map]
+  (update-func
+    obj 'morpheus.query.lang.update/update-object*
+    (map-on-keys AST/parse-map-path field-exp-map)))
+
 (defn update-vertex [vertex field-exp-map]
-  (vertex/update-vertex!
-    vertex
-    'morpheus.query.lang.update/update-vertex*
-    (map-on-keys AST/parse-map-path field-exp-map)))+  (update-object vertex/update-vertex! vertex field-exp-map))
+
+(defn update-edge [edge field-exp-map]
+  (update-object edge/update-edge! edge field-exp-map))


Select all/Clear selections -button added to badge export view

--- src/cljs/salava/badge/ui/exporter.cljs
+++ src/cljs/salava/badge/ui/exporter.cljs
@@ -14,7 +14,7 @@
 (defn visibility-options []
   [{:value "all" :title (t :badge/All)}
    {:value "public"  :title (t :badge/Public)}
-   {:value "shared"  :title (t :badge/Shared)}
+   {:value "internal"  :title (t :badge/Shared)}
    {:value "private" :title (t :badge/Private)}])

 (defn order-radio-values []
@@ -99,6 +99,11 @@
     (if-not (empty? badges-to-export)
       (.issue js/OpenBadges (clj->js assertion-urls)))))

+(defn select-all [state]
+  (if (:badges-all @state)
+    (swap! state assoc :badges-selected [] :badges-all false)
+    (swap! state assoc :badges-selected (map :id (:badges @state)) :badges-all true)))
+
 (defn content [state]
   [:div {:id "export-badges"}
    [:h1.uppercase-header (t :badge/Exportordownload)]
@@ -114,11 +119,13 @@
            (empty? (:emails @state)) [:span (t :badge/Nomozillaaccount) " " [:a {:href "/user/edit/email-addresses"} (t :badge/here) "."]])]
         [:div
          [badge-grid-form state]
-         [:div.export-button
-          [:button {:class    "btn btn-primary"
-                    :on-click #(export-badges state)
-                    :disabled (= 0 (count (:badges-selected @state)))}
-           (t :badge/Exportselected)]]
+         [:button {:class "btn btn-primary"
+                   :on-click #(select-all state)}
+          (if (:badges-all @state) (t :badge/Clearall) (t :badge/Selectall))]
+         [:button {:class    "btn btn-primary"
+                   :on-click #(export-badges state)
+                   :disabled (= 0 (count (:badges-selected @state)))}
+          (t :badge/Exportselected)]
          [badge-grid state]])])])

 (defn init-data [state]


small fix

small fix

--- src/cljs/salava/core/ui/page_grid.cljs
+++ src/cljs/salava/core/ui/page_grid.cljs
@@ -9,41 +9,43 @@
 (defn page-grid-element [element-data opts]
   (let [{:keys [state init-data type]} opts
         {:keys [id name user_id first_name last_name profile_picture visibility mtime badges theme]} element-data]
-    [:div.col-xs-12.col-sm-6.col-md-4 {:key id}
+    ;[:div.col-xs-12.col-sm-6.col-md-4 {:key id}
      (case type
-       "basic"      [:div.media.grid-container
-                     [:a {:href (path-for (str "/profile/page/view/" id )) :style {:text-decoration "none"}}
-                      [:div.media-content
+       "basic" [:div.col-xs-12.col-sm-6.col-md-4 {:key id}
+                  [:div.media.grid-container
+                                             [:a {:href (path-for (str "/profile/page/view/" id )) :style {:text-decoration "none"}}
+                                              [:div.media-content

-                       [:div.media-body
-                        [:div;.flip-modal
-                         [:div.media-heading
-                          [:p.heading-link name]]
-                         [:div.visibility-icon
-                          (case visibility
-                            "private" [:i {:class "fa fa-lock" :title (t :page/Private)}]
-                            "password" [:i {:class "fa fa-lock" :title (t :page/Passwordprotected)}]
-                            "internal" [:i {:class "fa fa-group" :title (t :page/Forregistered)}]
-                            "public" [:i {:class "fa fa-globe" :title (t :page/Public)}]
-                            nil)]
-                         [:div.media-description
-                          [:div.page-create-date.no-flip
-                           (date-from-unix-time (* 1000 mtime) "minutes")]
-                          (reduce (fn [r badge] (conj r [:img {:title (:name badge)
-                                                               :alt (:name badge)
-                                                               :src (str "/" (:image_file badge))}] ) )[:div.page-badges] badges)]]]]]
+                                               [:div.media-body
+                                                [:div;.flip-modal
+                                                 [:div.media-heading
+                                                  [:p.heading-link name]]
+                                                 [:div.visibility-icon
+                                                  (case visibility
+                                                    "private" [:i {:class "fa fa-lock" :title (t :page/Private)}]
+                                                    "password" [:i {:class "fa fa-lock" :title (t :page/Passwordprotected)}]
+                                                    "internal" [:i {:class "fa fa-group" :title (t :page/Forregistered)}]
+                                                    "public" [:i {:class "fa fa-globe" :title (t :page/Public)}]
+                                                    nil)]
+                                                 [:div.media-description
+                                                  [:div.page-create-date.no-flip
+                                                   (date-from-unix-time (* 1000 mtime) "minutes")]
+                                                  (reduce (fn [r badge] (conj r [:img {:title (:name badge)
+                                                                                :alt (:name badge)
+                                                                                :src (str "/" (:image_file badge))}] ) )[:div.page-badges] badges)]]]]]

-                     [:div.media-bottom.flip-modal
-                      [:a {:class "bottom-link"
-                           :title (t :page/Edit)
-                           :href  (path-for (str "/profile/page/edit/" id))}
-                       [:i {:class "fa fa-pencil"}]]
-                      [:a {:class "bottom-link pull-right"
-                           :title (t :page/Settings)
-                           :href  (path-for (str "/profile/page/settings/" id))}
-                       [:i {:class "fa fa-cog"}]]]]
+                                             [:div.media-bottom.flip-modal
+                                              [:a {:class "bottom-link"
+                                                   :title (t :page/Edit)
+                                                   :href  (path-for (str "/profile/page/edit/" id))}
+                                               [:i {:class "fa fa-pencil"}]]
+                                              [:a {:class "bottom-link pull-right"
+                                                   :title (t :page/Settings)
+                                                   :href  (path-for (str "/profile/page/settings/" id))}
+                                               [:i {:class "fa fa-cog"}]]]]]

-       "profile" [:div.media.grid-container
+      "profile" [:div.col-xs-12.col-md-4  {:key id :style {:padding-left "0"}}
+                 [:div.media.grid-container
                   [:a {:href "#" :on-click #(mo/open-modal [:page :view] {:page-id id}) :style {:text-decoration "none"}}
                    [:div.media-content
                     [:div.media-body
@@ -60,56 +62,59 @@

                     [:div {:class "media-right"}
                      [:img {:src (profile-picture profile_picture)
-                            :alt (str first_name " " last_name)}]]]]]
-       "gallery" [:div.media.grid-container
-                  [:a {:href "#" :on-click #(mo/open-modal [:page :view] {:page-id id}) :style {:text-decoration "none"}}
-                   [:div.media-content
-                    [:div.media-body
-                     [:div.media-heading
-                      [:p.heading-link name]]
-                     [:div.media-content
-                      [:div.page-owner
-                       [:p (str first_name " " last_name)]]
-                      [:div.page-create-date.no-flip
-                       (date-from-unix-time (* 1000 mtime) "minutes")]
-                      (reduce (fn [r badge] (conj r [:img {:title (:name badge)
-                                                           :alt (:name badge)
-                                                           :src (str "/" (:image_file badge))}] ) )[:div.page-badges] (take 4 badges))]]
+                            :alt (str first_name " " last_name)}]]]]]]
+       "gallery" [:div.col-xs-12.col-sm-6.col-md-4 {:key id}
+                  [:div.media.grid-container
+                   [:a {:href "#" :on-click #(mo/open-modal [:page :view] {:page-id id}) :style {:text-decoration "none"}}
+                    [:div.media-content
+                     [:div.media-body
+                      [:div.media-heading
+                       [:p.heading-link name]]
+                      [:div.media-content
+                       [:div.page-owner
+                        [:p (str first_name " " last_name)]]
+                       [:div.page-create-date.no-flip
+                        (date-from-unix-time (* 1000 mtime) "minutes")]
+                       (reduce (fn [r badge] (conj r [:img {:title (:name badge)
+                                                            :alt (:name badge)
+                                                            :src (str "/" (:image_file badge))}] ) )[:div.page-badges] (take 4 badges))]]

-                    [:div {:class "media-right"}
-                     [:img {:src (profile-picture profile_picture)
-                            :alt (str first_name " " last_name)}]]]]
-                  (admintool-gallery-page id "page" state init-data user_id)]
-      "pickable" [:div.media.grid-container
-                  [:a {:href "#" :on-click #(do
-                                              (.preventDefault %)
-                                              (when-not (some (fn [page] (= id (:id page))) @(:atom element-data))
-                                               (reset! (:atom element-data) (conj @(:atom element-data) {:name name :id id :visibility visibility})))) :style {:text-decoration "none"}
-                       :data-dismiss "modal"}
-                   [:div.media-content
-                    [:div.media-body
-                     [:div.media-heading
-                      [:p.heading-link name]]
-                     [:div.visibility-icon {:style {:font-size "20px"}}
-                      (case visibility
-                        "private" [:i {:class "fa fa-lock" :title (t :page/Private)}]
-                        "password" [:i {:class "fa fa-lock" :title (t :page/Passwordprotected)}]
-                        "internal" [:i {:class "fa fa-group" :title (t :page/Forregistered)}]
-                        "public" [:i {:class "fa fa-globe" :title (t :page/Public)}]
-                        nil)]
-                     [:div.media-content
-                      [:div.page-owner
-                       [:p (str first_name " " last_name)]]
-                      [:div.page-create-date.no-flip
-                       (date-from-unix-time (* 1000 mtime) "minutes")]
-                      (reduce (fn [r badge] (conj r [:img {:title (:name badge)
-                                                           :alt (:name badge)
-                                                           :src (str "/" (:image_file badge))}] ) )[:div.page-badges] (take 4 badges))]]
+                     [:div {:class "media-right"}
+                      [:img {:src (profile-picture profile_picture)
+                             :alt (str first_name " " last_name)}]]]]
+                   (admintool-gallery-page id "page" state init-data user_id)]]
+      "pickable" [:div.col-xs-12.col-sm-6.col-md-4 {:key id}
+                  [:div.media.grid-container
+                   [:a {:href "#" :on-click #(do
+                                               (.preventDefault %)
+                                               (when-not (some (fn [page] (= id (:id page))) @(:atom element-data))
+                                                (reset! (:atom element-data) (conj @(:atom element-data) {:name name :id id :visibility visibility})))) :style {:text-decoration "none"}
+                        :data-dismiss "modal"}
+                    [:div.media-content
+                     [:div.media-body
+                      [:div.media-heading
+                       [:p.heading-link name]]
+                      [:div.visibility-icon {:style {:font-size "20px"}}
+                       (case visibility
+                         "private" [:i {:class "fa fa-lock" :title (t :page/Private)}]
+                         "password" [:i {:class "fa fa-lock" :title (t :page/Passwordprotected)}]
+                         "internal" [:i {:class "fa fa-group" :title (t :page/Forregistered)}]
+                         "public" [:i {:class "fa fa-globe" :title (t :page/Public)}]
+                         nil)]
+                      [:div.media-content
+                       [:div.page-owner
+                        [:p (str first_name " " last_name)]]
+                       [:div.page-create-date.no-flip
+                        (date-from-unix-time (* 1000 mtime) "minutes")]
+                       (reduce (fn [r badge] (conj r [:img {:title (:name badge)
+                                                            :alt (:name badge)
+                                                            :src (str "/" (:image_file badge))}] ) )[:div.page-badges] (take 4 badges))]]

-                    [:div {:class "media-right"}]]]]
-      "embed" [:div.media.grid-container
+                     [:div {:class "media-right"}]]]]]
+      "embed" [:div.col-xs-12.col-sm-6.col-md-4 {:key id}
+                [:div.media.grid-container
                  [:a {:target "_blank" :href (path-for (str "/page/view/" id)) :style {:text-decoration "none"}}
                   [:div.media-content
                    [:div.media-body
@@ -127,4 +132,4 @@

                    [:div {:class "media-right"}
                     [:img {:src (profile-picture profile_picture)
-                           :alt (str first_name " " last_name)}]]]]])]))
+                           :alt (str first_name " " last_name)}]]]]]])))


Removing stale old version.

Removing stale old version.

--- Clojure/asteroids.clj
+++ Clojure/asteroids.clj
@@ -1,102 +0,0 @@
-; :mode=clojure:
-
-(import
-    '(java.awt Color Dimension Polygon RenderingHints)
-    '(javax.swing JComponent JFrame JLabel Timer)
-    '(java.awt.event ActionListener KeyAdapter)
-)
-
-(defn do-mod [coll func v]
-    (dosync (alter coll (fn [x] (apply func [x v])))))
-
-(defn player-shape []
-    (doto
-        (new Polygon)
-        (.addPoint 10 0)
-        (.addPoint -3 5)
-        (.addPoint -3 -5)))
-
-(defn draw-player [player g]
-    (do
-        (.setColor g (Color/WHITE))
-        (let [old-transform (.getTransform g)]
-            (.translate g (:x player) (:y player))
-            (.fill g (player-shape))
-            (.setTransform g old-transform))))
-
-(defn game-render [state g]
-    (do
-        (.setRenderingHint g
-            RenderingHints/KEY_ANTIALIASING
-            RenderingHints/VALUE_ANTIALIAS_ON)
-        (.setRenderingHint g
-            RenderingHints/KEY_RENDERING
-            RenderingHints/VALUE_RENDER_QUALITY)
-        (.setColor g (Color/BLACK))
-        (let [rect (.getClipBounds g)]
-            (.fillRect g (.x rect) (.y rect) (.width rect) (.height rect)))
-        (draw-player (:player state) g)))
-
-(defn create-component [game-state]
-    (doto
-        (proxy [JComponent] []
-            (paint [g] (dosync (game-render (deref game-state) g))))
-        (.setPreferredSize (new Dimension 640 480))
-        (.setDoubleBuffered true)
-        (.setFocusable true)))
-
-(defn now [] (* 0.001 (System/currentTimeMillis)))
-
-(defn default-state [] {
-    :time (now)
-    :player { :x 100.0 :y 100.0 :xv 10.0 :yv 5.0 } } )
-
-(defn player-step [player time-step]
-    (assoc player
-        :x (+ (:x player) (* (:xv player) time-step))
-        :y (+ (:y player) (* (:yv player) time-step))))
-
-(defn game-step [state keys-pressed]
-    (let [new-time (now) time-step (- new-time (:time state))]
-        (assoc state
-            :time new-time
-            :player (player-step (:player state) time-step))))
-
-(defn create-game []
-    (let [
-        keys-pressed (ref (hash-set))
-        game-state (ref (default-state))
-        result (create-component game-state)
-        ]
-        (do
-            (doto
-                result
-                (.addKeyListener (proxy [KeyAdapter] []
-                    (keyPressed [event] (if (not (.isConsumed event)) (do
-                        (do-mod keys-pressed conj (.getKeyCode event))
-                        (.consume event))))
-                    (keyReleased [event] (if (not (.isConsumed event)) (do
-                        (do-mod keys-pressed disj (.getKeyCode event))
-                        (.consume event)))))))
-
-            (doto
-                (new Timer (/ 1000 60)
-                    (reify ActionListener
-                        (actionPerformed [this event] (.repaint result))))
-                (.start))
-
-            (future (loop []
-                (do
-                    (Thread/sleep 1)
-                    (dosync (alter game-state (fn [state] (game-step state (deref keys-pressed)))))
-                    (recur))))
-
-            result)))
-
-(let [frame (new JFrame)]
-    (do
-        (.add (.getContentPane frame) (create-game))
-        (.pack frame)
-        (.setResizable frame false)
-        (.show frame)))
-


Add special route for single-query test with response not in a vector

--- http-kit/hello/src/hello/handler.clj
+++ http-kit/hello/src/hello/handler.clj
@@ -23,16 +23,17 @@

 ;; Run the specified number of queries, return the results
 (defn run-queries [queries]
-  (vec ; Return as a vector
    (flatten ; Make it a list of maps
     (take
      queries ; Number of queries to run
-     (repeatedly get-world)))))
+     (repeatedly get-world))))

 ;; Define route handlers
 (defroutes app-routes
   (GET "/http-kit/" [] "Hello, World!")
   (GET "/http-kit/json" [] (response {:message "Hello, World!"}))
+  (GET "/http-kit/db" []
+       (response (first (run-queries 1))))
   (GET "/http-kit/db/:queries" [queries]
        (response (run-queries (Integer/parseInt queries))))
   (route/not-found "Not Found"))


primitive-acting-as-class issue fix

primitive-acting-as-class issue fix

--- src/latte_compiler/static_analysis.clj
+++ src/latte_compiler/static_analysis.clj
@@ -13,6 +13,17 @@
     [:ident name] (str name)
     :else (str var)
     ))
+
+(defn- print-type
+  [type]
+  (match type
+    [:void] "void"
+    [:int] "int"
+    [:string] "string"
+    [:bool] "bool"
+    [:atype ident] (str (print-type ident) "[]")
+    [:tident [:ident a]] a
+    [:ident a] a))

 (defn map-fun
   [fun]
@@ -186,7 +197,10 @@
         (err (str "class " (print-var clss) " not found in: " location))
         (lookup-field clss (.-fields (second class)) fident location)
         )
-      ))
+      )
+    type
+    (err (str "expected class type, found " (print-type type) " in: " location))
+    )
   )

 (defn- new-scope
@@ -412,17 +426,6 @@
                [narg vmap3] (add-arg vmap2 arg)] [(conj tmprgs narg) vmap3]))
     [:succ [[:args] vmap]] (rest args))
   )
-
-(defn- print-type
-  [type]
-  (match type
-    [:void] "void"
-    [:int] "int"
-    [:string] "string"
-    [:bool] "bool"
-    [:atype ident] (str (print-type ident) "[]")
-    [:tident [:ident a]] a
-    [:ident a] a))

 (defn- print-args
   [args]
@@ -578,7 +581,7 @@
       :etypednull (domonad phase-m
                     [type (m-result (second expr))
                      tmp (if (contains? ["void" "int" "boolean" "string"] (second type))
-                           (err (str "expected class type, found " (print-var type) " in: " location))
+                           (err (str "expected class type, found " (print-type type) " in: " location))
                            (succ "ok")
                            )
                      tmp2 (if (contains? (.-classes glob-state) type)


Update ring-defaults: 0.1.2 => 0.1.3

Update ring-defaults: 0.1.2 => 0.1.3

--- src/leiningen/new/chestnut/project.clj
+++ src/leiningen/new/chestnut/project.clj
@@ -11,7 +11,7 @@
   :dependencies [[org.clojure/clojure "1.6.0"]
                  [org.clojure/clojurescript "0.0-2511" :scope "provided"]
                  [ring "1.3.2"]
-                 [ring/ring-defaults "0.1.2"]
+                 [ring/ring-defaults "0.1.3"]
                  [compojure "1.3.1"]
                  [enlive "1.1.5"]
                  [om "0.8.0-rc1"]


Remove redundant 'let' bindings

Remove redundant 'let' bindings

--- src/main/clojure/clojure/data/json.clj
+++ src/main/clojure/clojure/data/json.clj
@@ -31,43 +31,41 @@
 (defn- read-json-array [^PushbackReader stream keywordize?]
   ;; Expects to be called with the head of the stream AFTER the
   ;; opening bracket.
-  (loop [i (.read stream), result (transient [])]
-    (when (neg? i) (throw (EOFException. "JSON error (end-of-file inside array)")))
-    (let [c i]
-      (cond
-       (Character/isWhitespace c) (recur (.read stream) result)
-       (= c (codepoint \,)) (recur (.read stream) result)
-       (= c (codepoint \])) (persistent! result)
-       :else (do (.unread stream i)
-                 (let [element (read-json-reader stream keywordize? true nil)]
-                   (recur (.read stream) (conj! result element))))))))
+  (loop [c (.read stream), result (transient [])]
+    (when (neg? c) (throw (EOFException. "JSON error (end-of-file inside array)")))
+    (cond
+     (Character/isWhitespace c) (recur (.read stream) result)
+     (= c (codepoint \,)) (recur (.read stream) result)
+     (= c (codepoint \])) (persistent! result)
+     :else (do (.unread stream c)
+               (let [element (read-json-reader stream keywordize? true nil)]
+                 (recur (.read stream) (conj! result element)))))))

 (defn- read-json-object [^PushbackReader stream keywordize?]
   ;; Expects to be called with the head of the stream AFTER the
   ;; opening bracket.
-  (loop [i (.read stream), key nil, result (transient {})]
-    (when (neg? i) (throw (EOFException. "JSON error (end-of-file inside array)")))
-    (let [c i]
-      (cond
-       (Character/isWhitespace c) (recur (.read stream) key result)
-
-       (= c (codepoint \,)) (recur (.read stream) nil result)
-
-       (= c (codepoint \:)) (recur (.read stream) key result)
-
-       (= c (codepoint \})) (if (nil? key)
-                  (persistent! result)
-                  (throw (Exception. "JSON error (key missing value in object)")))
-
-       :else (do (.unread stream i)
-                 (let [element (read-json-reader stream keywordize? true nil)]
-                   (if (nil? key)
-                     (if (string? element)
-                       (recur (.read stream) element result)
-                       (throw (Exception. "JSON error (non-string key in object)")))
-                     (recur (.read stream) nil
-                            (assoc! result (if keywordize? (keyword key) key)
-                                    element)))))))))
+  (loop [c (.read stream), key nil, result (transient {})]
+    (when (neg? c) (throw (EOFException. "JSON error (end-of-file inside array)")))
+    (cond
+     (Character/isWhitespace c) (recur (.read stream) key result)
+
+     (= c (codepoint \,)) (recur (.read stream) nil result)
+
+     (= c (codepoint \:)) (recur (.read stream) key result)
+
+     (= c (codepoint \})) (if (nil? key)
+                            (persistent! result)
+                            (throw (Exception. "JSON error (key missing value in object)")))
+
+     :else (do (.unread stream c)
+               (let [element (read-json-reader stream keywordize? true nil)]
+                 (if (nil? key)
+                   (if (string? element)
+                     (recur (.read stream) element result)
+                     (throw (Exception. "JSON error (non-string key in object)")))
+                   (recur (.read stream) nil
+                          (assoc! result (if keywordize? (keyword key) key)
+                                  element))))))))

 (defn- read-json-hex-character [^PushbackReader stream]
   ;; Expects to be called with the head of the stream AFTER the
@@ -101,68 +99,66 @@
   ;; Expects to be called with the head of the stream AFTER the
   ;; opening quotation mark.
   (let [buffer (StringBuilder.)]
-    (loop [i (.read stream)]
-      (when (neg? i) (throw (EOFException. "JSON error (end-of-file inside array)")))
-      (let [c i]
-        (cond
-         (= c (codepoint \")) (str buffer)
-         (= c (codepoint \\)) (do (.append buffer (read-json-escaped-character stream))
-                      (recur (.read stream)))
-         :else (do (.append buffer (char c))
-                   (recur (.read stream))))))))
+    (loop [c (.read stream)]
+      (when (neg? c) (throw (EOFException. "JSON error (end-of-file inside array)")))
+      (cond
+       (= c (codepoint \")) (str buffer)
+       (= c (codepoint \\)) (do (.append buffer (read-json-escaped-character stream))
+                                (recur (.read stream)))
+       :else (do (.append buffer (char c))
+                 (recur (.read stream)))))))

 (defn- read-json-reader
   ([^PushbackReader stream keywordize? eof-error? eof-value]
-     (loop [i (.read stream)]
-       (if (neg? i) ;; Handle end-of-stream
+     (loop [c (.read stream)]
+       (if (neg? c) ;; Handle end-of-stream
 	 (if eof-error?
 	   (throw (EOFException. "JSON error (end-of-file)"))
 	   eof-value)
-	 (let [c i]
-	   (cond
-	    ;; Ignore whitespace
-	    (Character/isWhitespace c) (recur (.read stream))
-
-	    ;; Read numbers, true, and false with Clojure reader
-	    (#{(codepoint \-) (codepoint \0) (codepoint \1) (codepoint \2) (codepoint \3) (codepoint \4) (codepoint \5) (codepoint \6) (codepoint \7) (codepoint \8) (codepoint \9)} c)
-	    (do (.unread stream i)
-		(read stream true nil))
-
-	    ;; Read strings
-	    (= c (codepoint \")) (read-json-quoted-string stream)
-
-	    ;; Read null as nil
-	    (= c (codepoint \n)) (let [ull [(char (.read stream))
-                                  (char (.read stream))
-                                  (char (.read stream))]]
-		       (if (= ull [\u \l \l])
-			 nil
-			 (throw (Exception. (str "JSON error (expected null): " c ull)))))
-
-	    ;; Read true
-	    (= c (codepoint \t)) (let [rue [(.read stream)
-                                            (.read stream)
-                                            (.read stream)]]
-		       (if (= rue [(codepoint \r) (codepoint \u) (codepoint \e)])
-			 true
-			 (throw (Exception. (str "JSON error (expected true): " c rue)))))
-
-	    ;; Read false
-	    (= c (codepoint \f)) (let [alse [(.read stream)
-                                             (.read stream)
-                                             (.read stream)
-                                             (.read stream)]]
-		       (if (= alse [(codepoint \a) (codepoint \l) (codepoint \s) (codepoint \e)])
-			 false
-			 (throw (Exception. (str "JSON error (expected false): " c alse)))))
-
-	    ;; Read JSON objects
-	    (= c (codepoint \{)) (read-json-object stream keywordize?)
-
-	    ;; Read JSON arrays
-	    (= c (codepoint \[)) (read-json-array stream keywordize?)
-
-	    :else (throw (Exception. (str "JSON error (unexpected character): " (char c))))))))))
+	 (cond
+          ;; Ignore whitespace
+          (Character/isWhitespace c) (recur (.read stream))
+
+          ;; Read numbers, true, and false with Clojure reader
+          (#{(codepoint \-) (codepoint \0) (codepoint \1) (codepoint \2) (codepoint \3) (codepoint \4) (codepoint \5) (codepoint \6) (codepoint \7) (codepoint \8) (codepoint \9)} c)
+          (do (.unread stream c)
+              (read stream true nil))
+
+          ;; Read strings
+          (= c (codepoint \")) (read-json-quoted-string stream)
+
+          ;; Read null as nil
+          (= c (codepoint \n)) (let [ull [(char (.read stream))
+                                          (char (.read stream))
+                                          (char (.read stream))]]
+                                 (if (= ull [\u \l \l])
+                                   nil
+                                   (throw (Exception. (str "JSON error (expected null): " c ull)))))
+
+          ;; Read true
+          (= c (codepoint \t)) (let [rue [(.read stream)
+                                          (.read stream)
+                                          (.read stream)]]
+                                 (if (= rue [(codepoint \r) (codepoint \u) (codepoint \e)])
+                                   true
+                                   (throw (Exception. (str "JSON error (expected true): " c rue)))))
+
+          ;; Read false
+          (= c (codepoint \f)) (let [alse [(.read stream)
+                                           (.read stream)
+                                           (.read stream)
+                                           (.read stream)]]
+                                 (if (= alse [(codepoint \a) (codepoint \l) (codepoint \s) (codepoint \e)])
+                                   false
+                                   (throw (Exception. (str "JSON error (expected false): " c alse)))))
+
+          ;; Read JSON objects
+          (= c (codepoint \{)) (read-json-object stream keywordize?)
+
+          ;; Read JSON arrays
+          (= c (codepoint \[)) (read-json-array stream keywordize?)
+
+          :else (throw (Exception. (str "JSON error (unexpected character): " (char c)))))))))

 (defprotocol Read-JSON-From
   (read-json-from [input keywordize? eof-error? eof-value]


add 'maybe-create-loader' to facade.

add 'maybe-create-loader' to facade.

--- src/ancient_clj/core.clj
+++ src/ancient_clj/core.clj
@@ -27,6 +27,12 @@
   (->> (for [[id v] m]
          [id (wrap (io/loader-for v))])
        (into {})))
+
+(defn ^{:added "0.3.12"} maybe-create-loader
+  "Create loader function for the given spec. Will return `nil` for
+   unknown loader types."
+  [spec]
+  (io/maybe-loader-for spec))

 (defn ^{:added "0.3.12"} maybe-create-loaders
   "Create loader map for a seq of ID/settings pairs representing


Refactor RocksDB test to improve DB directory handling

--- clstreams/test/clstreams/rocksdb_test.clj
+++ clstreams/test/clstreams/rocksdb_test.clj
@@ -1,16 +1,25 @@
 (ns clstreams.rocksdb-test
   (:require [clstreams.rocksdb :as sut]
-            [clojure.test :refer :all]))
+            [clojure.test :refer :all]
+            [clojure.java.io :as io]))

-(defn delete-recursively [fname]
-  (let [file (clojure.java.io/file fname)]
-    (if (.exists (clojure.java.io/as-file file))
-      (doseq [f (reverse (file-seq file))]
-        (clojure.java.io/delete-file f)))))
+(def db-dir "/tmp/ddeDB/somedb")
+(def db-dir-file (io/file db-dir))
+
+(defn delete-recursively [file]
+  (if (.exists file)
+    (doseq [f (reverse (file-seq file))]
+      (io/delete-file f))))
+
+(defn clean-db-fixture [run-test]
+  (let [base-dir-file (.getParentFile db-dir-file)]
+    (delete-recursively base-dir-file)
+    (run-test)
+    (delete-recursively base-dir-file)))
+
+(use-fixtures :each clean-db-fixture)

 (deftest rocksdb-open-test
   (testing "can open a rocksdb DB"
-    (delete-recursively "/tmp/ddeDB")
-    (with-open [db (sut/create-db "/tmp/ddeDB/somedb")]
-      (is (instance? Object db)))
-    (delete-recursively "/tmp/ddeDB")))
+    (with-open [db (sut/create-db db-dir)]
+      (is (instance? Object db)))))


Include proxy tags in session tests.

Include proxy tags in session tests.

--- test/shale/test/sessions.clj
+++ test/shale/test/sessions.clj
@@ -23,7 +23,8 @@
                  :host "localhost"
                  :port 101010
                  :type :socks5
-                 :public-ip nil})
+                 :public-ip nil
+                 :tags #{}})

 (deftest test-matches-requirement
   (testing "matches-requirement"


lein-release plugin: bumped version from 0.3.0 to 0.3.1-SNAPSHOT for next development cycle

--- backend/project.clj
+++ backend/project.clj
@@ -1,4 +1,4 @@
-(defproject lambdaui "0.3.0"
+(defproject lambdaui "0.3.1-SNAPSHOT"
   :description "LambdaCD-Plugin that provides a modern UI for your pipeline."
   :url "https://github.com/sroidl/lambda-ui"
   :license {:name "Apache License 2.0"


create-message! should be outside of loop

--- src/chat/server/sync.clj
+++ src/chat/server/sync.clj
@@ -36,9 +36,9 @@

 (defmethod event-msg-handler :chat/new-message
   [{:as ev-msg :keys [event id ?data ring-req ?reply-fn send-fn]}]
+  (db/with-conn (db/create-message! ?data))
   (doseq [uid (->> (:any @connected-uids)
                    (remove (partial = id)))]
-    (db/with-conn (db/create-message! ?data))
     (chsk-send! uid [:chat/new-message ?data])))

 (defmethod event-msg-handler :chat/hide-thread


upstream deps support is no longer experimental

--- src/clj/cljs/closure.clj
+++ src/clj/cljs/closure.clj
@@ -1210,9 +1210,8 @@
   ([]
    (get-upstream-deps* (. (Thread/currentThread) (getContextClassLoader))))
   ([classloader]
-   (let [upstream-deps (map #(read-string (slurp %)) (enumeration-seq (. classloader (getResources "deps.cljs"))))]
-     #_(doseq [dep upstream-deps]
-         (println (str "Upstream deps.cljs found on classpath. " dep " This is an EXPERIMENTAL FEATURE and is not guarenteed to remain stable in future versions.")))
+   (let [upstream-deps (map #(read-string (slurp %))
+                         (enumeration-seq (. classloader (getResources "deps.cljs"))))]
      (apply merge-with concat upstream-deps))))

 (def get-upstream-deps (memoize get-upstream-deps*))


Fix broken single file compilation.

Fix broken single file compilation.

--- src/clj/cljs/closure.clj
+++ src/clj/cljs/closure.clj
@@ -276,8 +276,10 @@
   returns a JavaScriptFile. In either case the return value satisfies
   IJavaScript."
   [^File file {:keys [output-file] :as opts}]
-  (let [out-file (io/file (output-directory opts) output-file)]
-    (compiled-file (comp/compile-file file out-file))))
+  (if output-file
+    (let [out-file (io/file (output-directory opts) output-file)]
+      (compiled-file (comp/compile-file file out-file)))
+    (compile-form-seq (comp/forms-seq file))))

 (defn compile-dir
   "Recursively compile all cljs files under the given source


Ensure distinct dependencies.

Ensure distinct dependencies.

--- src/clj/cljs/closure.clj
+++ src/clj/cljs/closure.clj
@@ -536,13 +536,13 @@
   (let [requires (mapcat -requires inputs)
         required-cljs (cljs-dependencies opts requires)
         required-js (js-dependencies opts (set (concat (mapcat -requires required-cljs) requires)))]
-    (concat (map #(-> (javascript-file (:foreign %)
-                                       (or (:url %) (io/resource (:file %)))
-                                       (:provides %)
-                                       (:requires %))
-                      (assoc :group (:group %))) required-js)
-            required-cljs
-            inputs)))
+    (distinct (concat (map #(-> (javascript-file (:foreign %)
+                                                 (or (:url %) (io/resource (:file %)))
+                                                 (:provides %)
+                                                 (:requires %))
+                                (assoc :group (:group %))) required-js)
+                      required-cljs
+                      inputs))))

 (comment
   ;; add dependencies to literal js


Added gadm2 to static-datasets map

Added gadm2 to static-datasets map


Send e-mail to rightful subscribers.

Send e-mail to rightful subscribers.

--- src/clj/medusa/alert.clj
+++ src/clj/medusa/alert.clj
@@ -7,12 +7,11 @@
             [clj.medusa.config :as config]))

 (defn send-email [subject body destinations]
-  (let [destinations ["rvitillo@mozilla.com"]] ;; TODO: remove once everything works
-    (when-not (:dry-run @config/state)
-      (ses/send-email :destination {:to-addresses destinations}
-                      :source "telemetry-alerts@mozilla.com"
-                      :message {:subject subject
-                                :body {:html (str "" body "")}}))))
+  (when-not (:dry-run @config/state)
+    (ses/send-email :destination {:to-addresses destinations}
+                    :source "telemetry-alerts@mozilla.com"
+                    :message {:subject subject
+                              :body {:html (str "" body "")}})))

 (defn notify-subscribers [{:keys [metric_id date emails]}]
   (let [{:keys [hostname]} @config/state


implemented gc alloc and commit. test seem to be working just fine

--- src/clojure_metal/gc.clj
+++ src/clojure_metal/gc.clj
@@ -34,6 +34,12 @@
    [casted (<-b (llvm/BuildBitCast x (llvm/PointerType size-t 0) "casted"))
     val (<-b (llvm/BuildLoad casted "loaded"))]
    val))
+
+(defn TYPEID= [x val]
+  (gen-plan
+   [casted (<-b (llvm/BuildBitCast x (llvm/PointerType size-t 0) "casted"))
+    _ (<-b (llvm/BuildStore val casted))]
+   casted))

 (defllvmstruct mps_ss_t [size-t _zs
@@ -168,8 +174,27 @@
             [_# (update-in-plan [:next-type-id]  (fnil inc -1))
              tid# (get-in-plan [:next-type-id])
              _# (assoc-in-plan [:known-types (name ns-name#) ~(name nm) :fns] ~fns)
-             _# (assoc-in-plan [:known-types (name ns-name#) ~(name nm) :type-id] tid#)]
+             _# (assoc-in-plan [:known-types (name ns-name#) ~(name nm) :type-id] tid#)
+             _# (assoc-in-plan [:known-types (name ns-name#) ~(name nm) :llvm-type] ~nm)]
             nil)))))
+
+(defn type-id-by-sym [sym]
+  (gen-plan
+   [tid (get-in-plan [:known-types (namespace sym) (name sym) :type-id])
+    _ (<- (assert tid))]
+   tid))
+
+(defn llvm-type-by-sym [sym]
+  (gen-plan
+   [llvm-type (get-in-plan [:known-types (namespace sym) (name sym) :llvm-type])
+    _ (<- (assert llvm-type))]
+   llvm-type))
+
+(defn fn-by-sym [sym]
+  (gen-plan
+   [module (get-in-plan [:module])
+    f (<- (llvm/GetNamedFunction module (name sym)))]
+   f))

 (defapptype fwd_t [size-t tid
@@ -483,7 +508,46 @@
     _ (<-b (llvm/BuildCondBr small? small not-small))]
    nil))

-
+(defn alloc-amc [type-sym]
+  (gen-plan
+   [klass (llvm-type-by-sym type-sym)
+    type-id (type-id-by-sym type-sym)
+    size (<- (llvm/SizeOf klass))
+    size (ALIGN-VAL size)
+    data (<-b (llvm/BuildAlloca i8* "alloced"))
+
+    f (fn-by-sym :cm_pool_amc_reserve)
+
+    continue-blk (add-block "continue")
+
+
+
+    [val retry-blk] (add-block "retry"
+                               (gen-plan
+                      [this-blk (get-block)
+                       _ (<-b (llvm/BuildCall f
+                                              (into-array Pointer [data size])
+                                              2
+                                              "reserve"))
+
+                       *data (<-b (llvm/BuildLoad data "*data"))
+                       _ (TYPEID= *data (const-size-t type-id))
+
+                       f (fn-by-sym :cm_pool_amc_commit)
+
+                       result (<-b (llvm/BuildCall f
+                                                  (into-array Pointer [data size])
+                                                  2
+                                                  "commit"))
+                       retry? (<-b (llvm/BuildICmp llvm/LLVMIntEQ result (const-size-t 0) "retry?"))
+                       _ (<-b (llvm/BuildCondBr retry? this-blk continue-blk))]
+                      nil #_*data))
+
+   _ (<-b (llvm/BuildBr retry-blk))
+
+    _ (set-block continue-blk)
+    ]
+   val))

 (defn add-externals []
   (gen-plan
@@ -497,7 +561,13 @@
                                (&tp obj_pad_t)
                                (&tp obj_skip_t)
                                (&tp obj_isfwd_t)]
-                              i8*))]
+                              i8*))
+    cm_pool_amc_reserve (add-function "cm_pool_amc_reserve"
+                                      (function-type
+                                       [i8** size-t] size-t))
+    cm_pool_amc_commit (add-function "cm_pool_amc_commit"
+                                     (function-type
+                                      [i8** size-t] size-t))]
    nil))

@@ -538,7 +608,17 @@
     _ (init-gc)
     _ (mark-stack)

-    _ (<-b (llvm/BuildRetVoid))]
+    [val blk] (add-block "loop"
+                         (gen-plan
+                          [val (alloc-amc ::cons_t)
+                           this-blk (get-block)
+                           _ (<-b (llvm/BuildBr this-blk))]
+                          nil))
+
+    _ (<-b (llvm/BuildBr blk))
+
+
+    #_ _ #_(<-b (llvm/BuildRetVoid))]
    nil))

 (defn do-it2 []


Add another experimental option for :discounted-case-improvements

--- src/clojush/evaluate.clj
+++ src/clojush/evaluate.clj
@@ -207,7 +207,7 @@
                                        (if (<= sum 0)
                                          1.0E100
                                          (/ 1.0 sum)))))))
-                          (if (not (:print-history argmap))
+                          #_(if (not (:print-history argmap))
                             (throw
                               (Exception.
                                 ":print-history must be true for :discounted-case-improvements"))
@@ -218,7 +218,7 @@
                                        0 ;; solved, improvement doesn't matter
                                        (let [max-error 200
                                              cap #(if (> % max-error) max-error %)
-                                             improvements (mapv (fn [[older-error newer-error]]
+                                             improvements (mapv (fn [[newer-error older-error]]
                                                                   (- older-error newer-error))
                                                                 (partition
                                                                   2 1 (mapv cap case-history)))
@@ -227,7 +227,25 @@
                                          (if (<= sum 0)
                                            1.0E100
                                            (/ 1.0 sum))))))))
-                          ;
+                          (if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":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 (:history ind))]
+                                     (if (<= (first case-history) error-threshold)
+                                       0 ;; solved, improvement doesn't matter
+                                       (let [improvements (mapv (fn [[newer-error older-error]]
+                                                                  (if (> (- older-error newer-error) 0)
+                                                                    1.0
+                                                                    0.0))
+                                                                (partition 2 1 case-history))
+                                             weights (iterate (partial * (- 1 improvement-discount)) 0.5)
+                                             sum (reduce + (mapv * improvements weights))]
+                                         (if (<= sum 0)
+                                           1.0E100
+                                           (/ 1.0 sum))))))))
                           (= cat :reproductive-fidelity)
                           (let [g (:genome ind)]
                             (- 1.0


CMR-183: Changed to use BasicCache by default.

--- src/cmr/common/cache.clj
+++ src/cmr/common/cache.clj
@@ -9,6 +9,7 @@
   "Looks up the value of the cached item using the key. If there is a cache miss it will invoke
   the function given with no arguments, save the value in the cache and return the value."
   [cmr-cache key f]
+  (debug "CMR-CACHE" cmr-cache)
   (-> (swap! (:atom cmr-cache)
              (fn [cache]
                (if (cc/has? cache key)
@@ -19,7 +20,7 @@
 (defn create-cache
   "Create system level cache."
   ([]
-   (create-cache (cc/lru-cache-factory {})))
+   (create-cache (cc/basic-cache-factory {})))
   ([initial-cache]
    {:initial initial-cache
     :atom (atom initial-cache)}))
@@ -28,6 +29,11 @@
   [cmr-cache]
   (reset! (:atom cmr-cache) (:initial cmr-cache)))

+(defn set-cache!
+  [cmr-cache value]
+  (swap! (:atom cmr-cache)
+         (fn [_] value)))

+


Select project after creating it

Select project after creating it

--- src/net/sekao/nightcode/controller.clj
+++ src/net/sekao/nightcode/controller.clj
@@ -75,7 +75,7 @@
             (fn []
               (.hide dialog)
               (swap! pref-state update :project-set conj (.getCanonicalPath file))
-              (p/update-project-tree! pref-state project-tree))))))))
+              (p/update-project-tree! pref-state project-tree (.getCanonicalPath file)))))))))

 (defn -onNewConsoleApp [this ^ActionEvent event]
   (-> event .getSource .getParentPopup .getOwnerWindow .getScene (new-project! :console)))


s/unifyc/unify/ for visibility into fails

--- src/babel/espanol/pos.clj
+++ src/babel/espanol/pos.clj
@@ -1,8 +1,7 @@
 (ns babel.espanol.pos)

-(require '[babel.lexiconfn :as lexiconfn :refer (map-function-on-map-vals)])
+(require '[babel.lexiconfn :as lexiconfn :refer (map-function-on-map-vals unify)])
 (require '[babel.pos :as pos])
-(require '[dag-unify.core :refer (unifyc)])

 (def agreement-noun pos/agreement-noun)
 (def cat-of-pronoun pos/cat-of-pronoun)
@@ -14,47 +13,47 @@
     {:espanol {:agr agr}
      :synsem {:agr agr}}))

-(def feminine-noun (unifyc
+(def feminine-noun (unify
                     noun-agreement (:feminine pos/noun)))

-(def masculine-noun (unifyc
+(def masculine-noun (unify
                      noun-agreement (:masculine pos/noun)))
 (def adjective
-  (unifyc pos/adjective
-          (let [agr (ref :top)
-                cat (ref :top)]
-            {:espanol {:agr agr
-                        :cat cat}
-             :synsem {:agr agr
-                      :cat cat}})))
+  (unify pos/adjective
+         (let [agr (ref :top)
+               cat (ref :top)]
+           {:espanol {:agr agr
+                      :cat cat}
+            :synsem {:agr agr
+                     :cat cat}})))

 ;; A generalization of intransitive and transitive:
 ;; they both have a subject, thus "subjective".
 (def verb-subjective
-  (unifyc pos/verb-subjective
-          (let [infl (ref :top)
-                agr (ref :top)
-                essere-type (ref :top)]
-            {:espanol {:agr agr
-                        :essere essere-type
-                        :infl infl}
-             :synsem {:infl infl
+  (unify pos/verb-subjective
+         (let [infl (ref :top)
+               agr (ref :top)
+               essere-type (ref :top)]
+           {:espanol {:agr agr
                       :essere essere-type
-                      :subcat {:1 {:agr agr}}}})))
+                      :infl infl}
+            :synsem {:infl infl
+                     :essere essere-type
+                     :subcat {:1 {:agr agr}}}})))

 (def transitive
-  (unifyc verb-subjective
-          pos/transitive
-          {:synsem {:essere false}}))
+  (unify verb-subjective
+         pos/transitive
+         {:synsem {:essere false}}))

 (def intransitive-unspecified-obj
-  (unifyc verb-subjective
-          {:synsem {:sem {:reflexive false}}}
-          pos/intransitive-unspecified-obj))
+  (unify verb-subjective
+         {:synsem {:sem {:reflexive false}}}
+         pos/intransitive-unspecified-obj))

 (def intransitive
-  (unifyc verb-subjective
-          pos/intransitive))
+  (unify verb-subjective
+         pos/intransitive))

 (defn intransitivize [lexicon]
   (lexiconfn/intransitivize lexicon intransitive transitive intransitive-unspecified-obj))


gen-delegate, generate-generic-delegate, sys-func,

and sys-action taken from core-clr.clj and reworked from macros to be functions.

--- core.clj
+++ core.clj
@@ -36,6 +36,39 @@

 ;; This is just me trying to debug do-with-minibuffer
 (defonce defer-count 0)
+;; gen-delegate, generate-generic-delegate, sys-func, and sys-action taken from
+;; core-clr.clj and reworked from macros to be functions.
+
+(defn- my-gen-delegate
+  [type f]
+	(clojure.lang.GenDelegate/Create type f))
+
+
+;; (clojure.string/join "," coll) will substitute for str-join, I think.
+(defn- str-join    ;; clojure.string not yet loaded
+  [coll]
+  (loop [sb (StringBuilder. (str (first coll)))
+        more (next coll)]
+        (if more
+            (recur (-> sb (.Append ",") (.Append (str (first more))))
+                   (next more))
+                   (str sb))))
+
+(defn- my-generate-generic-delegate
+  [typename typesyms f]
+  (let [types (map (fn [tsym] (clojure.lang.CljCompiler.Ast.HostExpr/MaybeType tsym false)) typesyms)
+        ftype (symbol (str typename "`" (count types) "[" (str-join types) "]"))]
+       (my-gen-delegate ftype f)))
+
+(defn- my-sys-func
+  "Translates to a gen-delegate for a System.Func<,...> call"
+  [typesyms f]
+  (my-generate-generic-delegate "System.Func" typesyms f))
+
+(defn- my-sys-action
+  "Translates to a gen-delegate for a System.Action<,...> call"
+  [typesyms f]
+  (my-generate-generic-delegate "System.Action" typesyms f))

 (defn do-with-minibuffer
   "Run (f Minibuffer/instance) when Minibuffer/instance is available.
@@ -65,31 +98,20 @@
                    (str "Typeargs and args must be equal length or typeargs may have "
                         "one more element at the end to represent its return type.")))))

-(defmacro defcmd
-    "Define a Minibuffer command and function. The docstring is required.
-  The typeargs define what C# types the function accepts and optionally what it
-  returns. Minibuffer makes extensive use of the type information. Consider the
-  following example.
-
-  e.g. (defcmd say-hello \"Says hello. Return int.\" [String Int32]
-          [x]
-          (message \"Hello, \" x)
-          1)
-
-  The function `say-hello` be defined as if it were a normal `defn` but it may
-  additionally be run interactively by typing `M-x say-hello` which will then
-  prompt for a string. Functions with a String output will be `message`'d
-  automatically. Functions with a IEnumerator output will be run as coroutines."
-  [fn-name docstring typeargs args & body]
-  `(do (defn ~fn-name
-         ~docstring
-         ~args ;; add type annotation?
-         ~@body)
-       (with-minibuffer ~'m
-                        (.RegisterCommand ~'m (doto (Command. ~(name fn-name))
-                                                    (.set_description ~docstring))
-                                          (make-delegate ~typeargs ~args ~fn-name)))
-     #'~fn-name))
+(defn- my-make-delegate
+    "Creates a delegate that may be a Func<...>, Action<...>, or Action based on
+  typeargs and args. A Func<...> is created if there is one more typearg than
+  arg. An Action is created if there are no typeargs or args."
+  [typeargs args f]
+  (cond
+   (some #{'&} args)                       (throw
+                                            (ArgumentException. "Cannot have variable length arguments '&' in command."))
+   (= (count typeargs) (+ 1 (count args))) (my-sys-func typeargs f))
+   (empty? args)                           (my-gen-delegate Action f)
+   (= (count typeargs) (count args))       (my-sys-action typeargs f))
+   :else (throw (ArgumentException.
+                 (str "Typeargs and args must be equal length or typeargs may have "
+                      "one more element at the end to represent its return type.")))))

 (defmacro separate-types [f args]
           `{:typeargs (->> '~args
@@ -108,7 +130,9 @@
                 (if (:typeresult h#)
                     (conj (:typeargs h#) (:typeresult h#))
                   (:typeargs h#))))
+
 (defn register-command
+  "Register a Minibuffer command."
   [cmd-name-or-attrs typeargs args f]
   (let [attrs (if (string? cmd-name-or-attrs)
                   {:name cmd-name-or-attrs}
@@ -128,6 +152,27 @@
                                                           (:parameter-names attrs nil)))
                                nil)))
                       (eval `(make-delegate ~typeargs ~args ~f))))))
+(defn my-register-command
+  "Register a Minibuffer command."
+  [cmd-name-or-attrs typeargs args f]
+  (let [attrs (if (string? cmd-name-or-attrs)
+                  {:name cmd-name-or-attrs}
+                  cmd-name-or-attrs)]
+   (with-minibuffer
+    m
+    (.RegisterCommand m
+                      (doto (Command. (:name attrs nil))
+                            (.set_description (:description attrs nil))
+                            (.set_keySequence (:keysequence attrs nil))
+                            (.set_signature   (:signature attrs nil))
+                            (.set_parameterNames
+                             (if (:parameter-names attrs nil)
+                                 ;; There's an extra "closure "parameter in the
+                                 ;; generated method.
+                                 (into-array String (into ["closure"]
+                                                          (:parameter-names attrs nil)))
+                               nil)))
+                      (eval `(make-delegate ~typeargs ~args ~f))))))

 (defmacro defcmd2
     "Define a Minibuffer command and function. The docstring is required.


add docstring to slug-available? + taken-slugs

--- src/open_company/resources/company.clj
+++ src/open_company/resources/company.clj
@@ -61,10 +61,14 @@
 ;; ----- Slug -----

 (declare list-companies)
-(defn taken-slugs []
+(defn taken-slugs
+  "Return all slugs which are in use as a set."
+  []
   (set (map :slug (list-companies))))

-(defn slug-available? [slug]
+(defn slug-available?
+  "Return true if the slug is not used by any company in the database."
+  [slug]
   (not (contains? (taken-slugs) slug)))

 ;; ----- Company CRUD -----


Change file-store layout to be compatible with IPFS.

--- src/blocks/store/file.clj
+++ src/blocks/store/file.clj
@@ -3,24 +3,26 @@

   In many filesystems, directories are limited to 4,096 entries. In order to
   avoid this limit (and make navigating the filesystem a bit more efficient),
-  block content is stored in a nested hierarchy three levels deep.
+  block content is stored in nested directories three levels deep. All path
+  elements are lower-case hex-encoded bytes from the multihash.

-  The first level is the algorithm used in the block's multihash. The second
-  and third levels are formed by the first three characters and next three
-  characters from the id's digest. Finally, the block is stored in a file named
-  by the multihashes' hex string.
+  The first level is the two-byte multihash prefix, which designates the
+  algorithm and digest length. There will usually only be one or two of these
+  directories. The second and third levels are formed by the first two bytes of
+  the hash digest. Finally, the block is stored in a file containing the rest of
+  the digest.

-  Thus, a file path for the content \"foobar\" might be:
+  Thus, a file path for the content \"foobar\" stored under `root` might be:

-  `root/sha1/97d/f35/011497df3588b5a3...`
+  `root/1114/97/df/35011497df3588b5a3...`

   Using this scheme, leaf directories should start approaching the limit once the
-  user has 2^(3*12) entries, or about 68.7 billion blocks."
+  user has 2^28 entries, or about 268 million blocks."
   (:require
     [blocks.core :as block]
     [blocks.data :as data]
     [clojure.java.io :as io]
-    [clojure.string :as string]
+    [clojure.string :as str]
     [multihash.core :as multihash])
   (:import
     java.io.File
@@ -71,16 +73,15 @@
 (defn- id->file
   "Determines the filesystem path for a block of content with the given hash
   identifier."
-  ^File
+  ^java.io.File
   [root id]
-  (let [algorithm (:algorithm id)
-        digest (:hex-digest id)]
+  (let [hex (multihash/hex id)]
     (io/file
       root
-      (name algorithm)
-      (subs digest 0 3)
-      (subs digest 3 6)
-      (multihash/hex id))))
+      (subs hex 0 4)
+      (subs hex 4 6)
+      (subs hex 6 8)
+      (subs hex 8))))

 (defn- file->id
@@ -93,8 +94,7 @@
                (str "File " path " is not a child of root directory " root))))
     (-> path
         (subs (inc (count root)))
-        (string/split #"/")
-        (last)
+        (str/replace "/" "")
         (multihash/decode))))


Fix wrong usage of unqualified bytes? predicate.

--- src/buddy/core/crypto.clj
+++ src/buddy/core/crypto.clj
@@ -75,7 +75,7 @@

 (defn- initialize-cipher!
   [engine {:keys [iv key op]}]
-  {:pre [(bytes? key)
+  {:pre [(bytes/bytes? key)
          (valid-op? op)]}
   (let [params (if (nil? iv)
                  (KeyParameter. key)


Fix typo in docstring

Fix typo in docstring

--- cortex/src/cortex/optimise/optimisers.clj
+++ cortex/src/cortex/optimise/optimisers.clj
@@ -207,7 +207,7 @@
   Adam appears to perform better than ADADELTA, with both faster convergence and more
   resistance to oscillations, in general.

-  [1]: http://arxiv.org/pdf/1412.6980v8.pdf."
+  [2]: http://arxiv.org/pdf/1412.6980v8.pdf."
   [& {:keys [step-size first-moment-decay
              second-moment-decay conditioning]
       :or {step-size 0.001


lein-release plugin: bumped version from 1.0.0 to 1.0.1-SNAPSHOT for next development cycle

--- backend/project.clj
+++ backend/project.clj
@@ -1,4 +1,4 @@
-(defproject lambdaui "1.0.0"
+(defproject lambdaui "1.0.1-SNAPSHOT"
   :description "LambdaCD-Plugin that provides a modern UI for your pipeline."
   :url "https://github.com/sroidl/lambda-ui"
   :license {:name "Apache License 2.0"


safeguard with-ack-status

safeguard with-ack-status

--- src/riemann/plugin/acknowledgement.clj
+++ src/riemann/plugin/acknowledgement.clj
@@ -38,8 +38,12 @@
 (defn with-ack-status
   "Associate acknowledgement status to events"
   [{:keys [host service acked] :as event}]
-  (let [acked? (or acked (@acks [host service]))]
-    (assoc event :acked acked?)))
+  (try
+    (let [acked? (or acked (@acks [host service]))]
+      (assoc event :acked acked?))
+    (catch Exception e
+      (info "could not process acked status for: " event)
+      event)))

 (defn alert-stream
   "Given a function that sends out alerts to interested parties,


[#441] Renamed backend artefact

[#441] Renamed backend artefact

--- backend/project.clj
+++ backend/project.clj
@@ -1,4 +1,4 @@
-(defproject org.akvo.lumen "0.2-SNAPSHOT"
+(defproject org.akvo/lumen "0.3-SNAPSHOT"
   :description "Akvo Lumen backend"
   :url "https://github.com/akvo/akvo-lumen"
   :license {:name "GNU Affero General Public License 3.0"


lein-release plugin: preparing 0.3.4 release

--- backend/project.clj
+++ backend/project.clj
@@ -1,4 +1,4 @@
-(defproject lambdaui "0.3.4-SNAPSHOT"
+(defproject lambdaui "0.3.4"
   :description "LambdaCD-Plugin that provides a modern UI for your pipeline."
   :url "https://github.com/sroidl/lambda-ui"
   :license {:name "Apache License 2.0"


Simplify creation of new motion trace.

Simplify creation of new motion trace.

--- src/videotest/falling/motion_trace.clj
+++ src/videotest/falling/motion_trace.clj
@@ -23,9 +23,8 @@
 (defn build-motion-trace
   [{:keys [motion-trace triangle-points color-record previous-color-record] :as state}]
   (let [inc-life (fn [trace]
-                   (let [trace (if (empty? trace)
-                                 (init-trace)
-                                 trace)]
+                   (if (empty? trace)
+                     (init-trace)
                      (update-in trace [:life] #(min MAX-TRACE-LIFE
                                                     (+ 10 %)))))]
     (assoc-in state [:motion-trace]


add a couple more spark-sql functions

add a couple more spark-sql functions

--- src/clojure/flambo/sql.clj
+++ src/clojure/flambo/sql.clj
@@ -16,6 +16,9 @@
 (defn parquet-file [sql-context path]
   (.parquetFile sql-context path))

+(defn json-file [sql-context path]
+  (.jsonFile sql-context path))
+
 (defn register-rdd-as-table [sql-context rdd table-name]
   (.registerRDDAsTable sql-context rdd table-name))

@@ -23,3 +26,5 @@
 ;;
 (defn register-as-table [rdd table-name]
   (.registerAsTable rdd table-name))
+
+(def print-schema (memfn printSchema))


fix coupons description

fix coupons description

--- src/clojure/nossal/web.clj
+++ src/clojure/nossal/web.clj
@@ -125,7 +125,7 @@
             [:meta {:http-equiv "X-UA-Compatible" :content "IE=edge,chrome=1"}]
             [:meta {:name "viewport" :content "width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=0"}]
             [:meta {:name "keywords" :content "desconto, grátis, promoção, uber, cabify, 99, viagem, corrida, cupom, coupom, código de desconto"}]
-            [:meta {:name "description" :content (format "🎁 Cupom de desconto %s da %s e %s" (s/upper-case (cdata :code)) (s/capitalize service) (cdata :description))}]
+            [:meta {:name "description" :content (format "🎁 Cupom de desconto %s da %s %s" (s/upper-case (cdata :code)) (s/capitalize service) (cdata :description))}]
             [:title (s/upper-case (cdata :code)) " 🤑 Cupom de Desconto " (s/capitalize service)]
             (map (fn [s]
                   [:link {:rel "icon" :type "image/png" :href (s/join ["/" "gift-icon-" s ".png"]) :sizes (s/join [s "x" s])}])


Updated file_info date-checking

Updated file_info date-checking

--- ring-core/src/ring/middleware/file_info.clj
+++ ring-core/src/ring/middleware/file_info.clj
@@ -84,7 +84,8 @@
   "Has the file been modified since the last request from the client?"
   [{headers :headers :as req} last-modified]
   (if-let [modified-since (headers "if-modified-since")]
-    (= last-modified (.parse (make-http-format) modified-since))))
+    (not (.before (.parse (make-http-format) modified-since)
+                  last-modified))))

 (defn wrap-file-info
   "Wrap an app such that responses with a file a body will have corresponding


Fix typo in run.clj

Fix typo in run.clj

--- jvm/src/streamparse/commands/run.clj
+++ jvm/src/streamparse/commands/run.clj
@@ -25,7 +25,7 @@
                        options
                        topology)
       ;; sleep for a few seconds to let the topology run locally
-      (Thread/sleep (if (= 0 run-for-secs)) -1 run-for-secs)
+      (Thread/sleep (if (= 0 run-for-secs) -1 run-for-secs))
       ;; shutdown the cluster
       (.shutdown cluster))
     (catch Exception e


Genericize bullets

Genericize bullets

--- frontend/components/integrations.cljs
+++ frontend/components/integrations.cljs
@@ -155,9 +155,19 @@
 (def integration-data
   {:heroku {:hero {:header [:span "Deploy to " [:img {:src (utils/cdn-path "img/outer/integrations/heroku-icon.svg") :alt "Heroku" :style {:vertical-align "-35%"}}] " from CircleCI"]
                    :text "Experience a simple, modern continuous delivery workflow now."}
-            :bullets [{:title nil
-                       :content nil
-                       :graphic nil}]}})
+            :bullets [{:title "Test before you deploy. Always."
+                       :text [:span "Heroku revolutionized the way developers think about deployment. Being able to deploy with a simple "
+                              [:code "git push heroku master"] " is an amazing thing. But setting up a proper continuous delivery workflow means automating every step of the process. With CircleCI whenever you push a commit to master, it will go through a complete continuous delivery pipeline. All of your tests will run with our blazing fast parallelism, and" [:em " only if they pass, "] "your code will be pushed to Heroku automatically."]
+                       :graphic [:img {:src (stefon/data-uri "/img/status-logos/success.svg")}]}
+                      {:title "Dead Simple Configuration"
+                       :text "The deployment of your application is configured through just a few lines of YAML that are kept safe in your source code. All you need to do to deploy to Heroku from CircleCI is configure your Heroku credentials in our UI, add a simple config file like this one into your project, and make a push. You can also easily deploy different branches to different Heroku apps (e.g. one for staging and one for production)."
+                       :graphic [:div.console
+                                 [:pre
+                                  "deployment:\n  staging:\n    branch: " [:span.value "master"] "\n    heroku:\n      appname: " [:span.value "my-app"]]]}
+                      {:title "Watch how to get started in minutes"
+                       :text [:span "This video shows step-by-step how to configure CircleCI to test your application and deploy to Heroku, and how CircleCI keeps defects from getting into production. "
+                    "See our docs for a " [:a {:href "/docs/continuous-deployment-with-heroku#part-2-multiple-environments"} "followup video"] " showing how to setup a more robust continuous delivery pipeline with staging and prod environments."]
+                       :graphic [:div {:dangerouslySetInnerHTML {:__html ""}}]}]}})

 (defrender integration [app owner]
   (let [integration (get-in app [:navigation-data :integration])]
@@ -176,28 +186,13 @@
                    [:p (get-in data [:hero :text])]]
                   [:a {:role "button"} "Sign up for CircleCI"]]]]
                [:div.middle-section
-                [:div.bullet
-                 [:div.content
-                  [:h2 "Test before you deploy. Always."]
-                  [:p "Heroku revolutionized the way developers think about deployment. Being able to deploy with a simple "
-                   [:code "git push heroku master"] " is an amazing thing. But setting up a proper continuous delivery workflow means automating every step of the process. With CircleCI whenever you push a commit to master, it will go through a complete continuous delivery pipeline. All of your tests will run with our blazing fast parallelism, and" [:em " only if they pass, "] "your code will be pushed to Heroku automatically."]]
-                 [:div.graphic
-                  [:img {:src (stefon/data-uri "/img/status-logos/success.svg")}]]]
-                [:div.bullet
-                 [:div.graphic
-                  [:div.console
-                   [:pre
-                    "deployment:\n  staging:\n    branch: " [:span.value "master"] "\n    heroku:\n      appname: " [:span.value "my-app"]]]]
-                 [:div.content
-                  [:h2 "Dead Simple Configuration"]
-                  [:p "The deployment of your application is configured through just a few lines of YAML that are kept safe in your source code. All you need to do to deploy to Heroku from CircleCI is configure your Heroku credentials in our UI, add a simple config file like this one into your project, and make a push. You can also easily deploy different branches to different Heroku apps (e.g. one for staging and one for production)."]]]
-                [:div.bullet
-                 [:div.content
-                  [:h2 "Watch how to get started in minutes"]
-                  [:p "This video shows step-by-step how to configure CircleCI to test your application and deploy to Heroku, and how CircleCI keeps defects from getting into production. "
-                   "See our docs for a " [:a {:href "/docs/continuous-deployment-with-heroku#part-2-multiple-environments"} "followup video"] " showing how to setup a more robust continuous delivery pipeline with staging and prod environments."]]
-                 [:div.graphic
-                  [:div {:dangerouslySetInnerHTML {:__html ""}}]]]]
+                (for [bullet (:bullets data)]
+                 [:div.bullet
+                  [:div.graphic
+                   (:graphic bullet)]
+                  [:div.content
+                   [:h2 (:title bullet)]
+                   [:p (:text bullet)]]])]
                [:div.bottom-section
                 [:h2 "Ready for world-class continuous delivery?"]
                 [:a {:role "button"} "Sign up for Free"]


Job is a better name

Job is a better name

--- scheduling/src/immutant/scheduling/joda.clj
+++ scheduling/src/immutant/scheduling/joda.clj
@@ -26,13 +26,13 @@
   (as-time [x] (.toDate x)))

 (defn schedule-seq
-  "Lazily schedule a task for each `DateTime` in a sequence, typically
+  "Lazily schedule a job for each `DateTime` in a sequence, typically
   returned from `clj-time.periodic/periodic-seq`. For any two
   successive elements, the second is scheduled upon completion of the
   first, and they will all have the same id."
-  [task seq]
+  [job seq]
   (let [id (u/uuid)]
     (letfn [(f [t & ts]
-              (i/schedule #(do (task) (if ts (apply f ts)))
+              (i/schedule #(do (job) (if ts (apply f ts)))
                 {:id id, :at t}))]
       (apply f seq))))


Fix unstubbed dependency in auth handler test.

--- test/lunchlotto/auth/handlers_test.clj
+++ test/lunchlotto/auth/handlers_test.clj
@@ -37,10 +37,11 @@
         (is (contains (:body resp) "Re-send Confirmation Email")))))

   (testing "invalid email format"
-    (let [resp (handlers/register-user {:email "foo@example.com"})]
-      (is (= 400 (:status resp)))
-      (is (contains (:body resp) "Register New User"))
-      (is (contains (:body resp) "email must be from the cyrusinnovation.com domain")))))
+    (with-redefs [models/find-user-by-email (fn [_ _] nil)]
+      (let [resp (handlers/register-user {:email "foo@example.com"})]
+        (is (= 400 (:status resp)))
+        (is (contains (:body resp) "Register New User"))
+        (is (contains (:body resp) "email must be from the cyrusinnovation.com domain"))))))

 (deftest show-confirmation-page
   (testing "with valid confirmation token"


Fix missing require for clojure.java.io

Fix missing require for clojure.java.io

--- server/src/main/clojure/vimclojure/core.clj
+++ server/src/main/clojure/vimclojure/core.clj
@@ -20,7 +20,9 @@
 ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 ; THE SOFTWARE.

-(ns vimclojure.core)
+(ns vimclojure.core
+  (:require
+    [clojure.java.io :as io]))

 (defn init-server
   []


Add strategic ^dynamic annotations for 1.3

--- server/src/main/clojure/vimclojure/repl.clj
+++ server/src/main/clojure/vimclojure/repl.clj
@@ -29,7 +29,7 @@
      (clojure.lang Var Compiler LineNumberingPushbackReader)))

 (def
-  #^{:doc
+  ^{:dynamic true :doc
   "A map holding the references to all running repls indexed by their repl id."}
   *repls*
   (atom {}))
@@ -41,7 +41,7 @@
     (swap! id inc)))

 (def
-  #^{:doc
+  ^{:dynamic true :doc
   "Set to true in the Repl if you want pretty printed results. Has no effect
   if clojure.contrib.pprint is not available."}
   *print-pretty*


Revert "De-feature-flag Build Diagnostics."

--- src-cljs/frontend/components/dashboard.cljs
+++ src-cljs/frontend/components/dashboard.cljs
@@ -7,6 +7,7 @@
             [frontend.components.project.common :as project-common]
             [frontend.models.plan :as plan-model]
             [frontend.models.project :as project-model]
+            [frontend.models.feature :as feature]
             [frontend.routes :as routes]
             [frontend.state :as state]
             [frontend.utils :as utils :include-macros true]
@@ -85,7 +86,8 @@

                :else
                [:div.dashboard
-                (when project
+                (when (and (feature/enabled? :build-diagnostics)
+                           project)
                   (om/build build-diagnostics {:data data :project project}))
                 (when (and plan (project-common/show-trial-notice? project plan))
                   [:div.container-fluid