~babel.use babel.espanol.lexicon/edn2lexicon, not babel.lexiconfn/edn2lexicon

--- src/babel/espanol/grammar.cljc
+++ src/babel/espanol/grammar.cljc
@@ -1,11 +1,11 @@
 (ns babel.espanol.grammar
   (:refer-clojure :exclude [get-in resolve])
   (:require
-   [babel.espanol.lexicon :refer [deliver-lexicon]]
+   [babel.espanol.lexicon :refer [deliver-lexicon edn2lexicon]]
    [babel.espanol.morphology :as morph
     :refer [analyze fo morph-walk-tree]]
    [babel.index :refer [create-indices lookup-spec]]
-   [babel.lexiconfn :refer [edn2lexicon lexicon-for-generation read-lexicon]]
+   [babel.lexiconfn :refer [lexicon-for-generation read-lexicon]]
    [babel.parse :as parse]
    [babel.stringutils :refer [show-as-tree]]
    [babel.ug :refer [comp-modifies-head comp-specs-head head-principle


fix typo

fix typo

--- src/babel/francais/lexicon.clj
+++ src/babel/francais/lexicon.clj
@@ -28,11 +28,11 @@
    ;;  CONJUGATES LIKE TENIR
    "apprendre" {:synsem {:cat :verb
                          :sem {:pred :imparare}}}
-
    "avoir"
    {:synsem {:essere false
+             :sem {:pred :avere}
              :cat :verb}
-    :italiano {:français "avoir"
+    :français {:infinitive "avoir"
                :futuro-stem "aur"
                :drop-e true
                :present {:1sing "ai"


got rid of distributed state, starting simple with one topology at a time

--- src/backtype/storm/cluster.clj
+++ src/backtype/storm/cluster.clj
@@ -18,61 +18,17 @@
   (:import [backtype.storm.utils Utils])
   (:use [backtype.storm util log config]))

-(defprotocol ClusterState
-  (close [this])
-  (register [this callback])
-  (unregister [this id]))
-
-
-(defn mk-distributed-cluster-state
-  "Make state for all 'storms'."
-  [conf]
-  (let [callbacks (atom {})
-        active (atom true)]
-    (reify
-      ClusterState
-
-      (register
-        [this callback]
-        ; Generate random uuid and associate it with a callback in callbacks map.
-        (let [id (uuid)]
-          (swap! callbacks assoc id callback)
-          id))
-
-      (unregister
-        [this id]
-        ; Remove callback with a respective id from callbacks map.
-        (swap! callbacks dissoc id))
-
-      (close
-        [this]
-        (reset! active false)))))

 (defprotocol StormClusterState
   (assignments [this callback])
   (assignment-info [this storm-id callback])
   (active-storms [this])
   (storm-base [this storm-id callback])
-;  (get-worker-heartbeat [this storm-id node port])
-;  (executor-beats [this storm-id executor->node+port])
-  (supervisors [this callback])
-  (supervisor-info [this supervisor-id]) ;; returns nil if doesn't exist
-;  (setup-heartbeats! [this storm-id])
-;  (teardown-heartbeats! [this storm-id])
-  (teardown-topology-errors! [this storm-id])
-;  (heartbeat-storms [this])
-  (error-topologies [this])
-;  (worker-heartbeat! [this storm-id node port info])
-;  (remove-worker-heartbeat! [this storm-id node port])
-;  (supervisor-heartbeat! [this supervisor-id info])
   (activate-storm! [this storm-id storm-base])
   (update-storm! [this storm-id new-elems])
   (remove-storm-base! [this storm-id])
-  (set-assignment! [this storm-id info])
   (remove-storm! [this storm-id])
-  (report-error [this storm-id task-id error])
-  (errors [this storm-id task-id])
-  (disconnect [this]))
+  (set-assignment! [this storm-id info]))

 (defn- issue-callback!
@@ -95,103 +51,34 @@

 (defn mk-storm-cluster-state
   "Make state for one instance of a 'storm'."
-  [cluster-state-spec]
-  (let [[solo? cluster-state] (if (satisfies? ClusterState cluster-state-spec)
-                                [false cluster-state-spec]
-                                [true (mk-distributed-cluster-state cluster-state-spec)])
+  []
+  (let [
         assignment-info-callback (atom {})
         supervisors-callback (atom nil)
         assignments-callback (atom nil)
         storm-base-callback (atom {})
         ;; store active storms in a set
         active-storms-map (atom {})
-        state-id (register
-                   cluster-state
-                   (fn [type path]
-                     ))]
-;                     (let [[subtree & args] (tokenize-path path)]
-;                       (condp = subtree
-;                         ASSIGNMENTS-ROOT (if (empty? args)
-;                                            (issue-callback! assignments-callback)
-;                                            (issue-map-callback! assignment-info-callback (first args)))
-;                         SUPERVISORS-ROOT (issue-callback! supervisors-callback)
-;                         STORMS-ROOT (issue-map-callback! storm-base-callback (first args))
-;                         ;; this should never happen
-;                         (halt-process! 30 "Unknown callback for subtree " subtree args)))))]
+        state-id (uuid)]
     (reify
       StormClusterState

       (assignments
         [this callback]
         (when callback
-          (reset! assignments-callback callback))
-        (get-children cluster-state ASSIGNMENTS-SUBTREE (not-nil? callback)))
+          (reset! assignments-callback callback)))
+;        (get-children cluster-state ASSIGNMENTS-SUBTREE (not-nil? callback)))

       (assignment-info
         [this storm-id callback]
         (when callback
-          (swap! assignment-info-callback assoc storm-id callback))
-        (maybe-deserialize (get-data cluster-state (assignment-path storm-id) (not-nil? callback))))
+          (swap! assignment-info-callback assoc storm-id callback)))
+;        (maybe-deserialize (get-data cluster-state (assignment-path storm-id) (not-nil? callback))))

       (active-storms
         [this]
         ; Return storm ids that are running
         (keys @active-storms-map))
-
-;      (heartbeat-storms [this]
-      ;        (get-children cluster-state WORKERBEATS-SUBTREE false))
-
-      (error-topologies [this]
-        )
-      ;        (get-children cluster-state ERRORS-SUBTREE false))
-
-;      (get-worker-heartbeat [this storm-id node port]
-      ;        (-> cluster-state
-      ;            (get-data (workerbeat-path storm-id node port) false)
-      ;            maybe-deserialize))
-
-;      (executor-beats [this storm-id executor->node+port]
-      ;; need to take executor->node+port in explicitly so that we don't run into a situation where a
-      ;; long dead worker with a skewed clock overrides all the timestamps. By only checking heartbeats
-      ;; with an assigned node+port, and only reading executors from that heartbeat that are actually assigned,
-      ;; we avoid situations like that
-      ;        (let [node+port->executors (reverse-map executor->node+port)
-      ;              all-heartbeats (for [[[node port] executors] node+port->executors]
-      ;                               (->> (get-worker-heartbeat this storm-id node port)
-      ;                                    (convert-executor-beats executors)
-      ;                                    ))]
-      ;          (apply merge all-heartbeats)))
-
-      (supervisors [this callback]
-        )
-      ;        (when callback
-      ;          (reset! supervisors-callback callback))
-      ;        (get-children cluster-state SUPERVISORS-SUBTREE (not-nil? callback)))
-
-      (supervisor-info [this supervisor-id]
-        )
-      ;        (maybe-deserialize (get-data cluster-state (supervisor-path supervisor-id) false)))
-
-;      (worker-heartbeat! [this storm-id node port info]
-      ;        (set-data cluster-state (workerbeat-path storm-id node port) (Utils/serialize info)))
-
-;      (remove-worker-heartbeat! [this storm-id node port]
-      ;        (delete-node cluster-state (workerbeat-path storm-id node port)))
-
-;      (setup-heartbeats! [this storm-id]
-      ;        (mkdirs cluster-state (workerbeat-storm-root storm-id)))
-
-;      (teardown-heartbeats! [this storm-id]
-      ;        (try-cause
-      ;          (delete-node cluster-state (workerbeat-storm-root storm-id))
-      ;          (catch KeeperException e
-      ;            (log-warn-error e "Could not teardown heartbeats for " storm-id))))
-
-;      (teardown-topology-errors! [this storm-id]
-      ;        (try-cause
-      ;          (delete-node cluster-state (error-storm-root storm-id))
-      ;          (catch KeeperException e
-      ;            (log-warn-error e "Could not teardown errors for " storm-id))))

       (activate-storm!
         [this storm-id storm-base]
@@ -217,50 +104,19 @@

       (remove-storm-base!
         [this storm-id]
-        (delete-node cluster-state (storm-path storm-id)))
+        )
+;        (delete-node cluster-state (storm-path storm-id)))

       (set-assignment!
         [this storm-id info]
-        (set-data cluster-state (assignment-path storm-id) (Utils/serialize info)))
+        )
+;        (set-data cluster-state (assignment-path storm-id) (Utils/serialize info)))

       (remove-storm!
         [this storm-id]
-        (delete-node cluster-state (assignment-path storm-id))
-        (remove-storm-base! this storm-id))
+;        (delete-node cluster-state (assignment-path storm-id))
+        (remove-storm-base! this storm-id)))))

-      (report-error
-        [this storm-id component-id error]
-        (let [path (error-path storm-id component-id)
-              data {:time-secs (current-time-secs) :error (stringify-error error)}
-              _ (mkdirs cluster-state path)
-              _ (create-sequential cluster-state (str path "/e") (Utils/serialize data))
-              to-kill (->> (get-children cluster-state path false)
-                        (sort-by parse-error-path)
-                        reverse
-                        (drop 10))]
-          (doseq [k to-kill]
-            (delete-node cluster-state (str path "/" k)))))
-
-      (errors
-        [this storm-id component-id]
-        (let [path (error-path storm-id component-id)
-              _ (mkdirs cluster-state path)
-              children (get-children cluster-state path false)
-              errors (dofor [c children]
-                       (let [data (-> (get-data cluster-state (str path "/" c) false)
-                                    maybe-deserialize)]
-                         (when data
-                           (struct TaskError (:error data) (:time-secs data))
-                           )))
-              ]
-          (->> (filter not-nil? errors)
-            (sort-by (comp - :time-secs)))))
-
-      (disconnect
-        [this]
-        (unregister cluster-state state-id)
-        (when solo?
-          (close cluster-state))))))

 ;; daemons have a single thread that will respond to events
 ;; start with initialize event


save audio file in proper directory

save audio file in proper directory

--- iwaswhere-web/src/clj/iwaswhere_web/upload.clj
+++ iwaswhere-web/src/clj/iwaswhere_web/upload.clj
@@ -1,9 +1,10 @@
 (ns iwaswhere-web.upload
   "Provides upload via REST call."
   (:require [ring.adapter.jetty :as j]
-            [compojure.core :refer [routes POST]]
+            [compojure.core :refer [routes POST PUT]]
             [clojure.java.io :as io]
             [iwaswhere-web.imports :as i]
+            [iwaswhere-web.files :as f]
             [clojure.string :as s]))

 (defn state-fn
@@ -16,10 +17,18 @@
                     (case filename
                       "text-entries.json" (i/import-text-entries-fn rdr put-fn {} filename)
                       "visits.json" (i/import-visits-fn rdr put-fn {} filename)
-                      :default)
+                      (prn req))
                     "OK"))
-        app (routes (POST "/upload/:filename" [filename :as r] (post-fn filename r put-fn)))]
-    (j/run-jetty app {:port 3001 :join? false}))
+        audio-post-fn (fn [filename req put-fn]
+                        (let [filename (str f/data-path "/audio/" filename)]
+                          (prn req)
+                          (io/copy (:body req) (java.io.File. filename)))
+                        "OK")
+        app (routes
+              (PUT "/upload/audio/:filename" [filename :as r] (audio-post-fn filename r put-fn))
+              (POST "/upload/:filename" [filename :as r] (post-fn filename r put-fn)))]
+    (future
+      (j/run-jetty app {:port 3001 :join? false})))
   {:state (atom {})})

 (defn cmp-map


split token handler for delete, get, and post requests (#133)

--- waiter/src/waiter/token.clj
+++ waiter/src/waiter/token.clj
@@ -157,6 +157,153 @@
                   token-set (->> tokens (map :token) set)]
               (kv/store kv-store owner-key token-set))))))))

+(defn- handle-token-delete-request
+  "Deletes the token configuration if found."
+  [clock synchronize-fn kv-store waiter-hostname entitlement-manager make-peer-requests-fn {:keys [headers] :as req}]
+  (try
+    (let [{:keys [token]} (sd/retrieve-token-from-service-description-or-hostname headers headers waiter-hostname)
+          authenticated-user (get req :authorization/user)
+          request-params (:query-params (ring-params/params-request req))
+          hard-delete (utils/request-flag request-params "hard-delete")]
+      (if token
+        (let [{:keys [service-description-template token-metadata]} (sd/token->token-description kv-store token :include-deleted hard-delete)]
+          (if (and service-description-template (not-empty service-description-template))
+            (let [token-owner (get token-metadata "owner")]
+              (if hard-delete
+                (when-not (authz/administer-token? entitlement-manager authenticated-user token token-metadata)
+                  (throw (ex-info "Cannot hard-delete token"
+                                  {:metadata token-metadata
+                                   :status 403
+                                   :user authenticated-user})))
+                (when-not (authz/manage-token? entitlement-manager authenticated-user token token-metadata)
+                  (throw (ex-info "User not allowed to delete token"
+                                  {:owner token-owner
+                                   :status 403
+                                   :user authenticated-user}))))
+              (delete-service-description-for-token clock synchronize-fn kv-store token token-owner :hard-delete hard-delete)
+              ; notify peers of token delete and ask them to refresh their caches
+              (make-peer-requests-fn "tokens/refresh"
+                                     :body (json/write-str {:owner token-owner, :token token})
+                                     :method :post)
+              (utils/map->json-response {:delete token, :hard-delete hard-delete, :success true}))
+            (throw (ex-info (str "Token " token " does not exist")
+                            {:status 404 :token token}))))
+        (throw (ex-info "Couldn't find token in request"
+                        {:status 400 :token token}))))
+    (catch Exception ex
+      (utils/exception->response ex req))))
+
+(defn- handle-get-token-request
+  "Returns the configuration if found.
+   Anyone can see the configuration, b/c it shouldn't contain any sensitive data."
+  [kv-store waiter-hostname {:keys [headers] :as req}]
+  (try
+    (let [request-params (:query-params (ring-params/params-request req))
+          include-deleted (utils/request-flag request-params "include-deleted")
+          {:keys [token]} (sd/retrieve-token-from-service-description-or-hostname headers headers waiter-hostname)]
+      (let [{:keys [service-description-template token-metadata]} (sd/token->token-description kv-store token :include-deleted include-deleted)]
+        (if (and service-description-template (not-empty service-description-template))
+          ;;NB do not ever return the password to the user
+          (do
+            (log/info "successfully retrieved token " token)
+            (utils/map->json-response (merge service-description-template token-metadata)))
+          (do
+            (throw (ex-info (str "Couldn't find token " token)
+                            {:status 404 :token token}))))))
+    (catch Exception ex
+      (utils/exception->response ex req))))
+
+(defn- handle-post-token-request
+  "Validates that the user is the creator of the token if it already exists.
+   Then, updates the configuration for the token in the database using the newest password."
+  [clock synchronize-fn kv-store waiter-hostname entitlement-manager make-peer-requests-fn validate-service-description-fn req]
+  (try
+    (let [request-params (:query-params (ring-params/params-request req))
+          authenticated-user (get req :authorization/user)
+          {:strs [token] :as new-token-description} (json/read-str (slurp (:body req)))
+          new-token-metadata (select-keys new-token-description sd/token-metadata-keys)
+          {:strs [authentication permitted-user run-as-user] :as new-service-description-template}
+          (select-keys new-token-description sd/service-description-keys)
+          {existing-token-metadata :token-metadata} (sd/token->token-description kv-store token)
+          owner (or (get new-token-metadata "owner")
+                    (get existing-token-metadata "owner")
+                    authenticated-user)]
+      (when (str/blank? token)
+        (throw (ex-info "Must provide the token" {:status 400})))
+      (when (= waiter-hostname token)
+        (throw (ex-info "Token name is reserved" {:status 403 :token token})))
+      (when-not (re-matches valid-token-re token)
+        (throw (ex-info "Token must match pattern"
+                        {:status 400 :token token :pattern (str valid-token-re)})))
+      (validate-service-description-fn new-service-description-template)
+      (let [unknown-keys (set/difference (-> new-token-description keys set)
+                                         (set sd/token-description-keys)
+                                         #{"token"})]
+        (when (not-empty unknown-keys)
+          (throw (ex-info (str "Unsupported key(s) in token: " (str (vec unknown-keys)))
+                          {:status 400 :token token}))))
+      (when (= authentication "disabled")
+        (when (not= permitted-user "*")
+          (throw (ex-info (str "Tokens with authentication disabled must specify"
+                               " permitted-user as *, instead provided " permitted-user)
+                          {:status 400 :token token})))
+        ;; partial tokens not supported when authentication is disabled
+        (when-not (sd/required-keys-present? new-service-description-template)
+          (throw (ex-info "Tokens with authentication disabled must specify all required parameters"
+                          {:missing-parameters (->> sd/service-required-keys
+                                                    (remove #(contains? new-service-description-template %1)) seq)
+                           :service-description new-service-description-template
+                           :status 400}))))
+      (case (get request-params "update-mode")
+        "admin"
+        (when-not (authz/administer-token? entitlement-manager authenticated-user token new-token-metadata)
+          (throw (ex-info "Cannot administer token"
+                          {:status 403
+                           :token-metadata new-token-metadata
+                           :user authenticated-user})))
+
+        nil
+        (do
+          (when (and run-as-user (not= "*" run-as-user))
+            (when-not (authz/run-as? entitlement-manager authenticated-user run-as-user)
+              (throw (ex-info "Cannot run as user"
+                              {:authenticated-user authenticated-user
+                               :run-as-user run-as-user
+                               :status 403}))))
+          (let [existing-service-description-owner (get existing-token-metadata "owner")]
+            (if-not (str/blank? existing-service-description-owner)
+              (when-not (authz/manage-token? entitlement-manager authenticated-user token existing-token-metadata)
+                (throw (ex-info "Cannot change owner of token"
+                                {:existing-owner existing-service-description-owner
+                                 :new-user owner
+                                 :status 403})))
+              (when-not (authz/run-as? entitlement-manager authenticated-user owner)
+                (throw (ex-info "Cannot create token as user"
+                                {:authenticated-user authenticated-user
+                                 :owner owner
+                                 :status 403})))))
+          (when (contains? new-token-metadata "last-update-time")
+            (throw (ex-info "Cannot modify last-update-time token metadata"
+                            {:status 400
+                             :token-metadata new-token-metadata}))))
+        (throw (ex-info "Invalid update-mode"
+                        {:mode (get request-params "update-mode")
+                         :status 400})))
+
+      ; Store the token
+      (let [new-token-metadata (merge {"last-update-time" (.getMillis ^DateTime (clock))
+                                       "owner" owner}
+                                      new-token-metadata)]
+        (store-service-description-for-token synchronize-fn kv-store token new-service-description-template new-token-metadata))
+      ; notify peers of token update
+      (make-peer-requests-fn "tokens/refresh"
+                             :method :post
+                             :body (json/write-str {:token token, :owner owner}))
+      (utils/map->json-response {:message (str "Successfully created " token)
+                                 :service-description new-service-description-template}))
+    (catch Exception ex
+      (utils/exception->response ex req))))
+
 (defn handle-token-request
   "Ring handler for dealing with tokens.

@@ -168,144 +315,13 @@
    If handling POST, validates that the user is the creator of the token if it already exists.
    Then, updates the configuration for the token in the database using the newest password."
   [clock synchronize-fn kv-store waiter-hostname entitlement-manager make-peer-requests-fn validate-service-description-fn
-   {:keys [headers request-method] :as req}]
-  ;;if post, validate that this is a valid job schema & that the user == the kerberos user, then sign & store in riak
-  ;;  remember that we need an extra field in this schema, which is who is allowed to use this. Could be "*" or a string username
-  ;;if get, return whatever data's in riak
+   {:keys [request-method] :as req}]
   (case request-method
-    :delete (try
-              (let [{:keys [token]} (sd/retrieve-token-from-service-description-or-hostname headers headers waiter-hostname)
-                    authenticated-user (get req :authorization/user)
-                    request-params (:query-params (ring-params/params-request req))
-                    hard-delete (utils/request-flag request-params "hard-delete")]
-                (if token
-                  (let [{:keys [service-description-template token-metadata]} (sd/token->token-description kv-store token :include-deleted hard-delete)]
-                    (if (and service-description-template (not-empty service-description-template))
-                      (let [token-owner (get token-metadata "owner")]
-                        (if hard-delete
-                          (when-not (authz/administer-token? entitlement-manager authenticated-user token token-metadata)
-                            (throw (ex-info "Cannot hard-delete token"
-                                            {:metadata token-metadata
-                                             :status 403
-                                             :user authenticated-user})))
-                          (when-not (authz/manage-token? entitlement-manager authenticated-user token token-metadata)
-                            (throw (ex-info "User not allowed to delete token"
-                                            {:owner token-owner
-                                             :status 403
-                                             :user authenticated-user}))))
-                        (delete-service-description-for-token clock synchronize-fn kv-store token token-owner :hard-delete hard-delete)
-                        ; notify peers of token delete and ask them to refresh their caches
-                        (make-peer-requests-fn "tokens/refresh"
-                                               :body (json/write-str {:owner token-owner, :token token})
-                                               :method :post)
-                        (utils/map->json-response {:delete token, :hard-delete hard-delete, :success true}))
-                      (throw (ex-info (str "Token " token " does not exist")
-                                      {:status 404 :token token}))))
-                  (throw (ex-info "Couldn't find token in request"
-                                  {:status 400 :token token}))))
-              (catch Exception ex
-                (utils/exception->response ex req)))
-    :get (try
-           (let [request-params (:query-params (ring-params/params-request req))
-                 include-deleted (utils/request-flag request-params "include-deleted")
-                 {:keys [token]} (sd/retrieve-token-from-service-description-or-hostname headers headers waiter-hostname)]
-             (let [{:keys [service-description-template token-metadata]} (sd/token->token-description kv-store token :include-deleted include-deleted)]
-               (if (and service-description-template (not-empty service-description-template))
-                 ;;NB do not ever return the password to the user
-                 (do
-                   (log/info "successfully retrieved token " token)
-                   (utils/map->json-response (merge service-description-template token-metadata)))
-                 (do
-                   (throw (ex-info (str "Couldn't find token " token)
-                                   {:status 404 :token token}))))))
-           (catch Exception ex
-             (utils/exception->response ex req)))
-    :post (try
-            (let [request-params (:query-params (ring-params/params-request req))
-                  authenticated-user (get req :authorization/user)
-                  {:strs [token] :as new-token-description} (json/read-str (slurp (:body req)))
-                  new-token-metadata (select-keys new-token-description sd/token-metadata-keys)
-                  {:strs [authentication permitted-user run-as-user] :as new-service-description-template}
-                  (select-keys new-token-description sd/service-description-keys)
-                  {existing-token-metadata :token-metadata} (sd/token->token-description kv-store token)
-                  owner (or (get new-token-metadata "owner")
-                            (get existing-token-metadata "owner")
-                            authenticated-user)]
-              (when (str/blank? token)
-                (throw (ex-info "Must provide the token" {:status 400})))
-              (when (= waiter-hostname token)
-                (throw (ex-info "Token name is reserved" {:status 403 :token token})))
-              (when-not (re-matches valid-token-re token)
-                (throw (ex-info "Token must match pattern"
-                                {:status 400 :token token :pattern (str valid-token-re)})))
-              (validate-service-description-fn new-service-description-template)
-              (let [unknown-keys (set/difference (-> new-token-description keys set)
-                                                 (set sd/token-description-keys)
-                                                 #{"token"})]
-                (when (not-empty unknown-keys)
-                  (throw (ex-info (str "Unsupported key(s) in token: " (str (vec unknown-keys)))
-                                  {:status 400 :token token}))))
-              (when (= authentication "disabled")
-                (when (not= permitted-user "*")
-                  (throw (ex-info (str "Tokens with authentication disabled must specify"
-                                       " permitted-user as *, instead provided " permitted-user)
-                                  {:status 400 :token token})))
-                ;; partial tokens not supported when authentication is disabled
-                (when-not (sd/required-keys-present? new-service-description-template)
-                  (throw (ex-info "Tokens with authentication disabled must specify all required parameters"
-                                  {:missing-parameters (->> sd/service-required-keys
-                                                            (remove #(contains? new-service-description-template %1)) seq)
-                                   :service-description new-service-description-template
-                                   :status 400}))))
-              (case (get request-params "update-mode")
-                "admin"
-                (when-not (authz/administer-token? entitlement-manager authenticated-user token new-token-metadata)
-                  (throw (ex-info "Cannot administer token"
-                                  {:status 403
-                                   :token-metadata new-token-metadata
-                                   :user authenticated-user})))
-
-                nil
-                (do
-                  (when (and run-as-user (not= "*" run-as-user))
-                    (when-not (authz/run-as? entitlement-manager authenticated-user run-as-user)
-                      (throw (ex-info "Cannot run as user"
-                                      {:authenticated-user authenticated-user
-                                       :run-as-user run-as-user
-                                       :status 403}))))
-                  (let [existing-service-description-owner (get existing-token-metadata "owner")]
-                    (if-not (str/blank? existing-service-description-owner)
-                      (when-not (authz/manage-token? entitlement-manager authenticated-user token existing-token-metadata)
-                        (throw (ex-info "Cannot change owner of token"
-                                        {:existing-owner existing-service-description-owner
-                                         :new-user owner
-                                         :status 403})))
-                      (when-not (authz/run-as? entitlement-manager authenticated-user owner)
-                        (throw (ex-info "Cannot create token as user"
-                                        {:authenticated-user authenticated-user
-                                         :owner owner
-                                         :status 403})))))
-                  (when (contains? new-token-metadata "last-update-time")
-                    (throw (ex-info "Cannot modify last-update-time token metadata"
-                                    {:status 400
-                                     :token-metadata new-token-metadata}))))
-                (throw (ex-info "Invalid update-mode"
-                                {:mode (get request-params "update-mode")
-                                 :status 400})))
-
-              ; Store the token
-              (let [new-token-metadata (merge {"last-update-time" (.getMillis ^DateTime (clock))
-                                               "owner" owner}
-                                              new-token-metadata)]
-                (store-service-description-for-token synchronize-fn kv-store token new-service-description-template new-token-metadata))
-              ; notify peers of token update
-              (make-peer-requests-fn "tokens/refresh"
-                                     :method :post
-                                     :body (json/write-str {:token token, :owner owner}))
-              (utils/map->json-response {:message (str "Successfully created " token)
-                                         :service-description new-service-description-template}))
-            (catch Exception ex
-              (utils/exception->response ex req)))))
+    :delete (handle-token-delete-request clock synchronize-fn kv-store waiter-hostname entitlement-manager
+                                         make-peer-requests-fn req)
+    :get (handle-get-token-request kv-store waiter-hostname req)
+    :post (handle-post-token-request clock synchronize-fn kv-store waiter-hostname entitlement-manager
+                                     make-peer-requests-fn validate-service-description-fn req)))

 (defn handle-list-tokens-request
   [kv-store {:keys [request-method] :as req}]
@@ -320,7 +336,7 @@
                   flatten
                   utils/map->streaming-json-response))
       (throw (ex-info "Only GET supported" {:request-method request-method
-                                             :status 405})))
+                                            :status 405})))
     (catch Exception ex
       (utils/exception->response ex req))))

@@ -336,7 +352,7 @@
       :get (let [owner->owner-ref (token-owners-map kv-store)]
              (utils/map->json-response owner->owner-ref))
       (throw (ex-info "Only GET supported" {:request-method request-method
-                                             :status 405})))
+                                            :status 405})))
     (catch Exception ex
       (utils/exception->response ex req))))

@@ -361,13 +377,13 @@
   [synchronize-fn make-peer-requests-fn kv-store list-tokens-fn {:keys [request-method] :as req}]
   (try
     (case request-method
-      :post (let [tokens (list-tokens-fn)]
+      :post (let [tokens (list-tokens-fn)]
               (reindex-tokens synchronize-fn kv-store tokens)
               (make-peer-requests-fn "tokens/refresh"
                                      :method :post
                                      :body (json/write-str {:index true}))
               (utils/map->json-response {:message "Successfully re-indexed" :tokens (count tokens)}))
       (throw (ex-info "Only POST supported" {:request-method request-method
-                                              :status 405})))
-    (catch Exception ex
-      (utils/exception->response ex req))))
+                                             :status 405})))
+    (catch Exception ex
+      (utils/exception->response ex req))))


fix cursor weirdness with non-editable links

--- app/src/semtag_web/rendering.cljs
+++ app/src/semtag_web/rendering.cljs
@@ -161,8 +161,11 @@
       (dom/set-text! elem (dom/attr elem "title")))))

 (defn enable-editable-table [dom-id input-queue]
-  (dom/set-attr! (css/sel (str domid " td.editable ")) "contentEditable" true)
-  (dom/set-attr! (css/sel (str domid " td.editable a")) "contentEditable" false)
+  (dom/set-attr! (css/sel (str domid " td.editable")) "contentEditable" true)
+  ;; this makes links clickable without pushing the cursor out of the cell
+  ;; note - these links aren't clickable for vimium
+  (dom/set-attr! (css/sel (str domid " td.editable a")) "onmouseover" "this.contentEditable = false")
+  (dom/set-attr! (css/sel (str domid " td.editable a")) "onmouseout"  "this.contentEditable = true")

   (doseq [elem (.querySelectorAll js/document (str domid " td.editable"))]
     ;; didn't use events/send-on because it was overriding default keypress behavior


fixed unit test failure

fixed unit test failure

--- storm-core/test/clj/backtype/storm/nimbus_test.clj
+++ storm-core/test/clj/backtype/storm/nimbus_test.clj
@@ -1329,7 +1329,7 @@
                      {"spout" (thrift/mk-spout-spec (TestPlannerSpout. true) :parallelism-hint 3)}
                      {})]
         (submit-local-topology nimbus "t1" {TOPOLOGY-WORKERS 1} topology)
-        (.debug nimbus "t1" "spout" true))))
+        (.debug nimbus "t1" "spout" true 100))))

 (deftest test-debug-on-global
   (with-local-cluster [cluster]
@@ -1338,4 +1338,4 @@
                      {"spout" (thrift/mk-spout-spec (TestPlannerSpout. true) :parallelism-hint 3)}
                      {})]
       (submit-local-topology nimbus "t1" {TOPOLOGY-WORKERS 1} topology)
-      (.debug nimbus "t1" "" true))))
+      (.debug nimbus "t1" "" true 100))))


Rewrite wrap-exception in routing

Rewrite wrap-exception in routing

--- src/cider_ci/utils/routing.clj
+++ src/cider_ci/utils/routing.clj
@@ -6,6 +6,8 @@
 (ns cider-ci.utils.routing
   (:require
     [logbug.catcher :as catcher]
+    [logbug.thrown :as thrown]
+
     [clojure.tools.logging :as logging]
     [compojure.core :as cpj]
     ))
@@ -20,9 +22,13 @@
     (cpj/ANY "*" [] {:status 404})))

-(defn wrap-log-exception [handler]
+(defn wrap-exception [handler]
   (fn [request]
-    (catcher/with-logging {}
+    (catcher/snatch
+      {:level :warn
+       :return-fn (fn [e]
+                    {:status 500
+                     :body (thrown/stringify e)})}
       (handler request))))

 ;### shutdown #################################################################


Add a ch-num key to the chapter-list maps

--- src/clj/comic_reader/sites.clj
+++ src/clj/comic_reader/sites.clj
@@ -1,6 +1,7 @@
 (ns comic-reader.sites
   (:refer-clojure :exclude [list])
-  (:require [clojure.string :as s]))
+  (:require [comic-reader.utils :refer [safe-read-string]]
+            [clojure.string :as s]))

 (defn gen-link->map [process-name process-url]
   (fn [{[name] :content
@@ -36,7 +37,11 @@
         {:url comic-url
          :selector [:div#chapters :ul.chlist
                     :li :div #{:h3 :h4} :a]
-         :normalize link->map})
+         :normalize (comp
+                     (gen-add-key-from-url :ch-num
+                                           #"/c0*(\d+)/"
+                                           safe-read-string)
+                     link->map)})
       :page-list-data-for-comic-chapter
       (fn [chapter-url]
         {:url chapter-url
@@ -74,7 +79,11 @@
       (fn [comic-url]
         {:url comic-url
          :selector [:div#chapterlist :tr :td :a]
-         :normalize link->map})
+         :normalize (comp
+                     (gen-add-key-from-url :ch-num
+                                           #"/0+(\d+)(/\d+)?"
+                                           safe-read-string)
+                     link->map)})
       :page-list-data-for-comic-chapter
       (fn [chapter-url]
         {:url chapter-url


Added cleanup-domains function which calls cleanup(1) for each domain's VersionStore (get rid of old versions of domain and only keep the last correctly loaded version).

--- src/clj/elephantdb/service.clj
+++ src/clj/elephantdb/service.clj
@@ -55,18 +55,15 @@
         remote-vs (DomainStore. fs remote-path)
         local-vs (DomainStore. lfs local-domain-root (.getSpec remote-vs))]
     (if (domain-needs-update? local-vs remote-vs)
-      (do
-        (doto lfs (clear-dir local-domain-root))  ;; clear domain dir first
-        (load-domain fs
-                     local-config
-                     local-domain-root
-                     remote-path
-                     (domain/host-shards (domains-info domain))))
+      (load-domain fs
+                   local-config
+                   local-domain-root
+                   remote-path
+                   (domain/host-shards (domains-info domain)))
       ;; use cached domain from local-dir (no update needed)
       (open-domain local-config
                    (str (path local-dir domain))
-                   (domain/host-shards (domains-info domain)))
-      )))
+                   (domain/host-shards (domains-info domain))))))

 (defn delete-deleted-domains [domains-info global-config local-config]
   "Deletes all domains from local filesystem that have been deleted from the global config."
@@ -84,6 +81,16 @@
                         (fn [domain]
                           (use-cache-or-update domain domains-info global-config local-config))))

+(defn cleanup-domains [fs domains-info global-config local-config]
+  (let [lfs (local-filesystem)
+        local-dir (:local-dir local-config)]
+    (doseq [domain (keys domains-info)]
+      (let [local-domain-root (str (path local-dir domain))
+            remote-path (-> global-config :domains (get domain))
+            remote-vs (DomainStore. fs remote-path)
+            local-vs (DomainStore. lfs local-domain-root (.getSpec remote-vs))]
+        (log-message "Cleaning up local domain versions (only keeping latest version) for domain: " domain)
+        (.cleanup local-vs 1)))))

 (defn sync-updated [global-config local-config token]
   "Only fetch domains from remote if a newer version is available.
@@ -97,6 +104,7 @@
       (try
         (delete-deleted-domains domains-info global-config local-config)
         (sync-data-updated domains-info global-config local-config)
+        (cleanup-domains fs domains-info global-config local-config)
         (log-message "Caching global config " cache-config)
         (cache-global-config! local-config cache-config)
         (log-message "Cached config " (read-cached-global-config local-config))
@@ -126,7 +134,6 @@
     domains-info
     ))

-;; should delete any domains that don't exist in config as well
 ;; returns map of domain to domain info and launches futures that will fill in the domain info
 (defn- sync-data [global-config local-config token]
   (if (cache? global-config token)


Character Assassination resource trash should be unpreventable

--- src/clj/game/cards-agendas.clj
+++ src/clj/game/cards-agendas.clj
@@ -101,7 +101,7 @@
     :choices {:req #(and (installed? %)
                          (is-type? % "Resource"))}
     :msg (msg "trash " (:title target))
-    :effect (effect (trash target))}
+    :effect (effect (trash target {:unpreventable true}))}

    "Chronos Project"
    {:msg "remove all cards in the Runner's Heap from the game"


Enable Browse and Edit buttons when "All" is selected

Before this change Browse button only enabled when "Doc" is selected,
and Edit button only enabled when "Source" is selected.

--- src/clj_ns_browser/browser.clj
+++ src/clj_ns_browser/browser.clj
@@ -325,9 +325,9 @@
       (b/transform (fn [o] (selection doc-cbx)))
       (b/transform (fn [o]
         (case o
-          "Doc" (invoke-soon (config! browse-btn :enabled? true))
-
-          ("All" "Examples" "See alsos" "Comments")
+          ("All" "Doc") (invoke-soon (config! browse-btn :enabled? true))
+
+          ("Examples" "See alsos" "Comments")
           (if-let [fqn (config doc-tf :text)]
             (future
               (let [url (clojuredocs-url fqn)
@@ -340,15 +340,15 @@
     (b/bind
       (apply b/funnel [doc-tf doc-cbx])
       (b/transform (fn [o] (selection doc-cbx)))
-      (b/transform (fn [o] (if (= "Source" o) true false)))
+      (b/transform (fn [o] (if (get #{"Source" "All"} o) true false)))
       (b/transform (fn [o]
         (when o (if (meta-when-file (config doc-tf :text))
                   true
                   false))))
       (b/notify-soon)
       (b/property edit-btn :enabled?))
-    ;
-      ;; browser-btn pressed =>
+    ;;
+    ;; browser-btn pressed =>
     ;; bring up browser with url
     (b/bind
       browse-btn-atom
@@ -358,9 +358,9 @@
           (when-let [fqn (config doc-tf :text)]
             (future
               (case o
-                "Doc" (bdoc* fqn)
-
-                ("All" "Examples" "See alsos" "Comments")
+                ("All" "Doc") (bdoc* fqn)
+
+                ("Examples" "See alsos" "Comments")
                 (when-let [url (clojuredocs-url fqn)]
                   (clojure.java.browse/browse-url url))


RR: uncomment show numeric and time-fields fields

--- src/cljs/hatti/map/viewby.cljs
+++ src/cljs/hatti/map/viewby.cljs
@@ -1,7 +1,7 @@
 (ns hatti.map.viewby
   (:require-macros [cljs.core.async.macros :refer [go go-loop]])
   (:require [clojure.string :as s]
-;            [ona.utils.charts :refer [evenly-spaced-bins]]
+            [hatti.charting :refer [evenly-spaced-bins]]
             [hatti.ona.forms :as f]
             [hatti.map.utils :as mu]))

@@ -51,12 +51,12 @@
   "Preproccesses answers depending on the field. For multi-selects, return type
    is a list of list of strings. For other types, a list of strings."
   (cond
-   (f/select-one? field) raw-answers
-   (f/calculate? field) raw-answers
-;   (f/numeric? field)    (evenly-spaced-bins raw-answers 5 "int")
-;   (f/time-based? field) (evenly-spaced-bins raw-answers 5 "date")
-   (f/select-all? field) (->> raw-answers
-                              (map #(when % (s/split % #" "))))))
+    (f/select-one? field) raw-answers
+    (f/calculate? field) raw-answers
+    (f/numeric? field) (evenly-spaced-bins raw-answers 5 "int")
+    (f/time-based? field) (evenly-spaced-bins raw-answers 5 "date")
+    (f/select-all? field) (->> raw-answers
+                               (map #(when % (s/split % #" "))))))

 (defn field->colors [field]
   "Returns the appropriate set of colors given the field."


pushed a channels to children components to experiment

--- src/cljs/tic_tac_toe/core.cljs
+++ src/cljs/tic_tac_toe/core.cljs
@@ -6,6 +6,7 @@
             [om-tools.core :refer-macros [defcomponent defcomponentk]]))

 (enable-console-print!)
+

 (defonce app-state (atom {:text "Hello Chestnut!"}))

@@ -17,11 +18,28 @@
   [pair]
   (get-in pair [1]))

+(defn eq-pos? [pos1 pos2]
+  (and (= (x-cord pos1) (x-cord pos2))
+       (= (y-cord pos1) (y-cord pos2))))

-(defcomponent cell [data owner {:keys [pos]}]
+(defcomponent cell [data owner {:keys [pos rand-chan]}]
   (init-state [_]
               {:clicked false})
-  (render-state [this {:keys [info]}]
+  (will-mount [_]
+              (if (om/get-state owner :fun-chan)
+                (let [fun-chan (om/get-state owner :fun-chan)]
+                  (go (loop []
+                        (let [my-pos (<! fun-chan)]
+                          (js/console.log "the pos received in is  in cell" (x-cord my-pos) (y-cord my-pos))
+                          (js/console.log "the current pos is" (x-cord pos) (y-cord pos))
+                          (if (eq-pos? pos my-pos)
+                            (om/update-state! owner :clicked not))
+                          (recur)))))
+                (js/console.log "um not there")))
+  (render-state [this {:keys [info fun-chan]}]
+          (if fun-chan
+            (js/console.log "it existst")
+            (js/console.log "it doesn't exist"))
           (dom/td #js {:className "cell"
                        :id (if (= true (om/get-state owner :clicked))
                              "light-blue"
@@ -46,35 +64,44 @@
     (init-state [_]
       {:x-cell (range 3), :y-cell (range 3)})
     (render-state [_ state]
+                  (if (:fun-chan state)
+                    (js/console.log "yolo")
+                    (js/console.log "hehe"))
       (apply dom/table #js {:id "chess-board"}
         (for [y (:x-cell state)]
           (apply dom/tr nil
                  (for [x (:y-cell state)]
                    (om/build cell (cell-col x y)
                              {:opts {:pos [x y]}
-                              :init-state {:info (:info state)}})))))))
+                              :init-state {:info (:info state) :fun-chan (when (and (= 0 y)(= 0 x))(:fun-chan state))}})))))))

 (defcomponent main-view
   [data owner]
   (init-state [_]
     {:info (chan)
-     :req-chan     (chan)
+     :fun-chan     (chan)
      :pub-chan     (chan)})

   (will-mount [_]
-      (let [info (om/get-state owner :info)]
+      (let [info (om/get-state owner :info)
+            fun-chan (om/get-state owner :fun-chan)]
         (go (loop []
               (let [pos (<! info)]
                 (js/console.log "the cords are " (x-cord pos) ", " (y-cord pos))
+                (om/set-state! owner :pos pos)
+                (js/console.log "the cur pos is" (om/get-state owner :pos))
+                (put! fun-chan pos)
                 (recur))))))

-  (render-state [_ {:keys [info]}]
+  (render-state [_ {:keys [info fun-chan]}]
                 (when info
                   (js/console.log "info tnsieraotn"))
     (dom/div nil
+        (dom/h1 nil "lol world")
         (om/build board nil {:init-state {:info info}})
-        (om/build board nil {:init-state {:info info}})
-        (om/build board nil {:init-state {:info info}}))))
+        (om/build board nil {:init-state {:info info :fun-chan fun-chan}})
+        (om/build board nil {:init-state {:info info :fun-chan fun-chan}})
+        (dom/button #js {:onClick #(js/console.log "yo")} "click me"))))

 (defcomponent my-test
   [data owner]


Use doall command

Use doall command

--- src/clojure/nightcode/lein.clj
+++ src/clojure/nightcode/lein.clj
@@ -202,9 +202,8 @@
   [path project]
   (cond
     (android-project? path)
-    (when-let [project (read-android-project project)]
-      (doseq [cmd ["build" "apk" "install" "run"]]
-        (leiningen.droid/execute-subtask project cmd [])))
+    (some-> (read-android-project project)
+            (leiningen.droid/doall []))
     (ios-project? path)
     (leiningen.fruit/fruit project "doall")
     (clr-project? path)


Fixed typo.

Fixed typo.

--- src/cmr/transmit/echo/rest.clj
+++ src/cmr/transmit/echo/rest.clj
@@ -86,4 +86,4 @@
     (if (= 200 status-code)
       {:ok? true}
       {:ok? false
-       :problem (format "Recieved %d from availability check. %s" status-code (:body response))})))
+       :problem (format "Received %d from availability check. %s" status-code (:body response))})))


Nope, get https errors, too

Nope, get https errors, too

--- src/com/okl/tokenmgr/views.clj
+++ src/com/okl/tokenmgr/views.clj
@@ -49,7 +49,7 @@
    [:title title]
    [:script {:src
              "https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"}]
-   [:script {:src "https://malsup.github.com/jquery.form.js"}]
+   [:script {:src "http://malsup.github.com/jquery.form.js"}]
    [:link {:rel "stylesheet"
            :href "/slick-grid/slick.grid.css"
            :type "text/css"}]


Implement 'partition-by-size' function

Implement 'partition-by-size' function

--- src/gml_to_featured/runner.clj
+++ src/gml_to_featured/runner.clj
@@ -83,20 +83,42 @@
            (mapcat member->map)
            (map log-progress)
            (filter #(not= unknown %)))))
+
+  (defn- partition-by-size [max-size coll]
+    (letfn [(partition-id [current-id init-size coll]
+              (when-let [head (first coll)]
+                (let [item-size (count head)
+                      [current-size current-id] (if (< (- max-size item-size) init-size)
+                                                    [item-size (inc current-id)]
+                                                    [(+ init-size item-size) current-id])]
+                  (cons
+                    current-id
+                    (lazy-seq
+                      (partition-id
+                        current-id
+                        current-size
+                        (next coll)))))))]
+      (->> (map
+             vector
+             (partition-id 0 0 coll)
+             coll)
+        (partition-by first)
+        (map (partial map second)))))

   (defn process [reader, dataset-name, validity]
     (let [features (process-stream reader)
           features (if validity
                      (map #(assoc % :_validity validity) features)
                      features)]
-      (list
-        (concat
-          (cons
-            (str "{\"dataset\":\"" dataset-name "\",\n\"features\":[")
-            (->> features
-              (map json/generate-string)
-              (interpose ",\n")))
-          (list "]}")))))
+      (->> features
+        (map json/generate-string)
+        (partition-by-size 50000000)
+        (map
+          #(concat
+            (cons
+              (str "{\"dataset\":\"" dataset-name "\",\n\"features\":[")
+              (interpose ",\n" %))
+            (list "]}"))))))

   (defn parse-translator-tag [expr]
     (eval (code/translator (:type expr) (:mapping expr) (or (:arrays expr) (constantly false)))))