some refactoring

some refactoring

--- iwaswhere-web/src/cljs/iwaswhere_web/new_entry.cljs
+++ iwaswhere-web/src/cljs/iwaswhere_web/new_entry.cljs
@@ -20,54 +20,45 @@
 (defn new-entry-view
   "Renders New Entry component."
   [{:keys [local put-fn]}]
-  [:div.l-box-lrg.pure-g
-   [:div.pure-u-1
-    (let [tags (:tags (:entry @local))]
-      [:div.hashtags
-       (when (seq tags)
-         (for [hashtag tags]
-           ^{:key (str "tag-" hashtag)}
-           [:span.hashtag.float-left hashtag]))])
-    [:div.textentry
-     [:textarea#new-entry-textbox
-      {:type      "text"
-       :value     (:md (:entry @local))
-       ; TODO: occasionally store content into localstorage
-       :on-change (fn [ev]
-                    (let [prev-tags (or (:prev-tags @local) #{})
-                          target (.. ev -target)
-                          new-state (merge (h/parse-entry (.. target -value))
-                                           {:timestamp (st/now)})
-                          cursor-pos (.. target -selectionEnd)
-                          new-tags (:tags new-state)]
-                      (swap! local assoc-in [:entry] new-state)
-                      (put-fn [:new-entry/tmp-save new-state])
-                      (when (not= prev-tags new-tags)
-                        (put-fn [:state/get {:tags new-tags}])
-                        (swap! local assoc-in [:prev-tags] new-tags))))}]]
-    #_(h/pp-div @local)
-    [:div.entry-footer
-      [:button.pure-button.pure-button-primary.button-xsmall
-       {:on-click #(let [ts (st/now)
-                         entry (merge (h/parse-entry "...") {:timestamp ts})]
-                    (put-fn [:text-entry/persist entry])
-                    (put-fn [:cmd/toggle {:timestamp ts :key :show-edit-for}])
-                    (send-w-geolocation entry put-fn))}
-       [:span.fa.fa-plus-square] " new"]
-      [:button.pure-button.pure-button-primary.button-xsmall
-       {:on-click #(let [entry (:entry @local)]
-                    (put-fn [:text-entry/persist entry])
-                    (send-w-geolocation entry put-fn))}
-       [:span.fa.fa-floppy-o] " save"]
-      [:button.pure-button.button-xsmall
-       {:on-click #(put-fn [:import/photos])}
-       [:span.fa.fa-camera-retro] " import"]
-      [:button.pure-button.button-xsmall
-       {:on-click #(put-fn [:import/geo])}
-       [:span.fa.fa-map-o] " import"]
-      [:button.pure-button.button-xsmall
-       {:on-click #(put-fn [:import/phone])}
-       [:span.fa.fa-mobile-phone] " import"]]]])
+  (let [on-change-fn #(let [prev-tags (or (:prev-tags @local) #{})
+                            new-state (merge (h/parse-entry (.. % -target -value)) {:timestamp (st/now)})
+                            new-tags (:tags new-state)]
+                       (swap! local assoc-in [:entry] new-state)
+                       (put-fn [:new-entry/tmp-save new-state])
+                       (when (not= prev-tags new-tags)
+                         (put-fn [:state/get {:tags new-tags}])
+                         (swap! local assoc-in [:prev-tags] new-tags)))
+        new-entry-fn #(let [ts (st/now)
+                            entry (merge (h/parse-entry "...") {:timestamp ts})]
+                       (put-fn [:text-entry/persist entry])
+                       (put-fn [:cmd/toggle {:timestamp ts :key :show-edit-for}])
+                       (send-w-geolocation entry put-fn))
+        save-entry-fn #(let [entry (:entry @local)]
+                        (put-fn [:text-entry/persist entry])
+                        (send-w-geolocation entry put-fn))]
+    [:div.l-box-lrg.pure-g
+     [:div.pure-u-1
+      (let [tags (:tags (:entry @local))]
+        [:div.hashtags
+         (when (seq tags)
+           (for [hashtag tags]
+             ^{:key (str "tag-" hashtag)}
+             [:span.hashtag.float-left hashtag]))])
+      [:div.textentry
+       [:textarea#new-entry-textbox {:type      "text"
+                                     :value     (:md (:entry @local))
+                                     :on-change on-change-fn}]]
+      [:div.entry-footer
+       [:button.pure-button.pure-button-primary.button-xsmall {:on-click new-entry-fn}
+        [:span.fa.fa-plus-square] " new"]
+       [:button.pure-button.pure-button-primary.button-xsmall {:on-click save-entry-fn}
+        [:span.fa.fa-floppy-o] " save"]
+       [:button.pure-button.button-xsmall {:on-click #(put-fn [:import/photos])}
+        [:span.fa.fa-camera-retro] " import"]
+       [:button.pure-button.button-xsmall {:on-click #(put-fn [:import/geo])}
+        [:span.fa.fa-map-o] " import"]
+       [:button.pure-button.button-xsmall {:on-click #(put-fn [:import/phone])}
+        [:span.fa.fa-mobile-phone] " import"]]]]))

 (defn cmp-map
   [cmp-id]


Fix Clojure solution output for problem 1

--- solutions/problem_1/solution.clj
+++ solutions/problem_1/solution.clj
@@ -3,7 +3,7 @@
     (zero? (mod number 3) )
     (zero? (mod number 5) ) ))
 (def startTime (double (. java.lang.System (clojure.core/nanoTime))))
-(println (reduce + (filter divisibleBy3or5 (range 1000)) ) )
+(println (str "=> Result: " (reduce + (filter divisibleBy3or5 (range 1000)) ) ))
 (def endTime (double (. java.lang.System (clojure.core/nanoTime))))
 (def seconds (double (/ (- endTime startTime) 1000000000.0)))
-(println (str "Time: " seconds "s"))
+(println (str "=> Time: " seconds "s"))


[Fix #70] fix for NPE in used-symbols-from-refer

--- src/refactor_nrepl/ns/dependencies.clj
+++ src/refactor_nrepl/ns/dependencies.clj
@@ -151,7 +151,7 @@

 (defn- used-symbols-from-refer [libspecs symbols-used-in-macros]
   (let [referred (set (remove nil? (mapcat get-referred-symbols libspecs)))]
-    (filter #(referred (symbol (:suffix %))) symbols-used-in-macros)))
+    (filter #(and (:suffix %) (referred (symbol (:suffix %)))) symbols-used-in-macros)))

 (defn- filter-imports [imports symbols-used]
   (let [used (set symbols-used)]


Re-establish source-map caching for require, etc

Fixes #397

--- planck-cljs/src/planck/repl.cljs
+++ planck-cljs/src/planck/repl.cljs
@@ -1519,11 +1519,20 @@
           (println (wrap-warning-font (form-indicator column @current-ns))))
         (print (wrap-warning-font warning-string))))))

+(defn- call-form?
+  [expression-form allowed-operators]
+  (contains? allowed-operators (and (list? expression-form)
+                                    (first expression-form))))
+
 (defn- macroexpand-form?
   "Determines if the expression is a macroexpansion expression."
   [expression-form]
-  (contains? '#{macroexpand macroexpand-1} (and (seq? expression-form)
-                                                (first expression-form))))
+  (call-form? expression-form '#{macroexpand macroexpand-1}))
+
+(defn- load-form?
+  "Determines if the expression is a form that loads code."
+  [expression-form]
+  (call-form? expression-form '#{require require-macros}))

 (defn- process-execute-source
   [source-text expression-form
@@ -1544,12 +1553,14 @@
            {:ns         initial-ns
             :verbose    (:verbose @app-env)
             :static-fns (:static-fns @app-env)}
-           (if-not expression? {:source-map true})
-           (if expression?
+           (when (or (not expression?)
+                     (load-form? expression-form))
+             (merge {:source-map true}
+               (when (:cache-path @app-env)
+                 {:cache-source (cache-source-fn source-text)})))
+           (when expression?
              {:context       :expr
-              :def-emits-var true}
-             (when (:cache-path @app-env)
-               {:cache-source (cache-source-fn source-text)})))
+              :def-emits-var true}))
          (fn [{:keys [ns value error] :as ret}]
            (if expression?
              (when-not error


Lisää client-ip-tieto myös lokaalisti

Lisää client-ip-tieto myös lokaalisti

X-Real-Ip- ja X-Forwarded-For-otsakkeet ovat vain
palvelinympäristöissä käytössä.

--- clj-ring-db-cas-session/src/clj_ring_db_session/session/session_client.clj
+++ clj-ring-db-cas-session/src/clj_ring_db_session/session/session_client.clj
@@ -5,7 +5,8 @@
   (fn [{:keys [headers] :as req}]
       (let [user-agent (:user-agent headers)
             client-ip  (or (get headers "x-real-ip")
-                           (get headers "x-forwarded-for"))]
+                           (get headers "x-forwarded-for")
+                           (:remote-addr req))]
         (handler (-> req
                      (assoc-in [:session :user-agent] user-agent)
                      (assoc-in [:session :client-ip] client-ip))))))


That change broke the tests

That change broke the tests

--- dev/clojure/staircase/assets.clj
+++ dev/clojure/staircase/assets.clj
@@ -171,18 +171,23 @@
     (when-let [last-seen (ring-time/parse-date mod-since)]
       (.after last-seen (get-modification-time file)))))

-(defn pipeline [& {:keys [strategy] :as options}]
-  "Take options and return a function that will wrap a ring handler in
-  an assets pipeline. Routes served by the handler take precedence. Requests
-  that produce 404 or nil will then be processed as asset-requests."
-
-  (letfn [(serve [req] (settings/with-options options
+(defn serve
+  "Handle a request, given a set of options"
+  [options req]
+  (settings/with-options options
     (when (is-asset-req req)
       (when-let [asset-file (asset-file-for req options)]
         (if (asset-not-modified-since? req asset-file)
           {:status 304 :body ""}
           (serve-asset asset-file options
-                       (get-in req [:headers "if-none-match"])))))))]
+                       (get-in req [:headers "if-none-match"])))))))
+
+(defn pipeline [& {:keys [strategy] :as options}]
+  "Take options and return a function that will wrap a ring handler in
+  an assets pipeline. Routes served by the handler take precedence. Requests
+  that produce 404 or nil will then be processed as asset-requests."
+
+  (let [serve-asset (partial serve options)]
     (case strategy

       :prefer-compiled
@@ -190,13 +195,13 @@
         (fn [req]
           (let [response (handler req)]
             (if (or (nil? response) (= 404 (:status response)))
-              (or (serve req) response {:status 404})
+              (or (serve-asset req) response {:status 404})
               response))))

       (fn [handler] ;; Tries to find assets first. Prefers live updates.
         (fn [req]
           (or
-            (serve req)
+            (serve-asset req)
             (handler req)
             {:status 404}))))))


removed git-plus

removed git-plus

--- main/src/dda/pallet/dda_managed_ide/domain/atom.clj
+++ main/src/dda/pallet/dda_managed_ide/domain/atom.clj
@@ -31,7 +31,7 @@
   ["proto-repl"  "clojure-plus" "parinfer" "lisp-paredit" "linter-clojure"])

 (def git-plugins
-  ["git-plus" "tree-view-git-status" "git-time-machine" "language-diff" "split-diff"])
+  ["tree-view-git-status" "git-time-machine" "language-diff" "split-diff"])

 (s/defn atom-config
   "create a atom configuration"


add test for previous commit

add test for previous commit

--- src/test/shadow/build/ns_form_test.clj
+++ src/test/shadow/build/ns_form_test.clj
@@ -216,6 +216,17 @@
     ;; (pprint ast-resolved)
     ))

+(deftest test-rename-clears-refer
+  (let [test
+        '(ns something (:require [other :refer (foo xzy) :rename {foo bar}]))
+
+        ast
+        (ns-form/parse test)]
+
+    (is (= '{xzy other} (:uses ast)))
+    (is (= '{bar other/foo} (:renames ast)))
+    ))
+
 (deftest test-parse-repl-require
   (let [test-ns
         '(ns cljs.user)


Fix discount

Fix discount

--- src/bot/brain.clj
+++ src/bot/brain.clj
@@ -109,7 +109,7 @@
                                  (assoc item :distance (manhattan-distance my-pos [(:x item-pos) (:y item-pos)])))) items)]
     (->> items-with-dist
          (sort-by :distance)
-         (remove #(< money (* (:price %) (- 100 (:discountPercent %) 0.01))))
+         (remove #(< money (* (:price %) (- 100 (:discountPercent %)) 0.01)))
          first
          get-coordinates)))


Cleanup

Cleanup

--- src-cljs/photon/ui/frontend.cljs
+++ src-cljs/photon/ui/frontend.cljs
@@ -20,23 +20,6 @@
             [om.dom :as dom])
   (:import goog.net.IframeIo
            goog.net.EventType))
-
-#_(defui FullPage
-  Object
-  (render
-   [this]
-   (dom/div
-    nil
-    (dom/div
-     nil
-     (condp = (:active-page @app-state)
-       "Dashboard" (omo/build widget-dashboard state)
-       "Streams" (omo/build widget-streams (assoc state :full-page-owner owner))
-       "Projections" (omo/build widget-projections (assoc state :full-page-owner owner))
-       "New Projection" (omo/build widget-new-projection state)
-       "New Stream" (omo/build widget-new-stream state)
-       "Analyse Data" (when (contains? state :streams)
-                        (omo/build widget-analyse state)))))))

 (defonce reconciler
   (om/reconciler {:state st/app-state


revert core.clj

revert core.clj

--- src/cai/core.clj
+++ src/cai/core.clj
@@ -2,7 +2,6 @@
   (:gen-class)
   (:require [compojure.core :refer :all]
             [compojure.route :as route]
-            [cai.message :as message]
             [ring.middleware.defaults :refer :all]
             [ring.middleware.json :refer [wrap-json-params]]
             [ring.middleware.keyword-params :refer [wrap-keyword-params]]
@@ -118,9 +117,6 @@
         result
         {:status 403}))))

-(def outmessage)
-
-
 (def app
   (-> (wrap-defaults fb-routes api-defaults)
       (wrap-keyword-params)


Add a task for running a ns-qualified symbols as pre and post tasks

--- build.boot
+++ build.boot
@@ -94,19 +94,49 @@
  '[adzerk.boot-reload    :refer [reload]]
  '[pandeiro.boot-http    :refer [serve]]
  '[crisptrutski.boot-cljs-test :refer [test-cljs]]
- '[powerlaces.boot-cljs-devtools :refer [cljs-devtools]])
-
-(swap! boot.repl/*default-middleware*
-       conj
-       'refactor-nrepl.middleware/wrap-refactor
-       'cider.nrepl/cider-middleware)
+ '[powerlaces.boot-cljs-devtools :refer [cljs-devtools]]
+ '[clojure.string :as str]
+ '[boot.util :as util])

 (deftask build []
   (comp (notify :visual true)
         (cljs)))

+(deftask run-sym
+  "Run vars as a pre- and post- tasks."
+  [b before SYM sym "The symbol to run inside a pre-wrap task"
+   a after  SYM sym "The symbol to run inside a post-wrap task"]
+  (let [get-ns (fn [str] (let [[ns s] (str/split (name str) #"/" 2)] (when s (symbol ns))))
+        run-symbol (fn [s]
+                     (when s
+                       (when-let [ns (get-ns s)]
+                         (require ns))
+                       (if-let [v (resolve s)]
+                         (v)
+                         (util/warn "Could not find var '%s\n" s))))
+        before-ns (when before (get-ns before))
+        after-ns (when after (get-ns after))]
+    (if (or
+         (and before (not before-ns))
+         (and after  (not after-ns)))
+      (util/warn "Symbols should be fully namespace qualified\n"))
+    (comp
+     (if before
+       (with-pass-thru _
+         (run-symbol before))
+       identity)
+     (if after
+       (with-post-wrap _
+         (run-symbol after))
+       identity))))
+
+(deftask run-server []
+  (run-sym :before 'comic-reader.system/stop
+           :after  'comic-reader.system/go))
+
 (deftask run []
   (comp (watch)
+        (run-server)
         (cljs-repl-env)
         (cljs-devtools)
         (reload)


Updaated to use plan-schema 0.2.16

Updaated to use plan-schema 0.2.16

--- build.boot
+++ build.boot
@@ -31,7 +31,7 @@
                     [com.fzakaria/slf4j-timbre    "0.3.2"]
                     [org.clojure/tools.logging    "0.3.1"]
                     [com.novemberain/langohr      "3.6.1"]
-                    [dollabs/plan-schema          "0.2.15"]
+                    [dollabs/plan-schema          "0.2.16"]
                     ;; web server
                     [org.clojure/data.json        "0.2.6"]
                     [ring/ring-core               "1.5.0"]


Update to latest ClojureScript, boot-cljs and Om

--- build.boot
+++ build.boot
@@ -4,14 +4,14 @@
   :source-paths #{"less" "src"}
   :resource-paths #{"html" "resources"}
   :dependencies '[; Boot setup
-                  [adzerk/boot-cljs "1.7.48-6"]
+                  [adzerk/boot-cljs "1.7.170-1"]
                   [adzerk/boot-reload "0.4.1"]
                   [deraen/boot-less "0.4.2"]
                   [pandeiro/boot-http "0.7.0-SNAPSHOT"]

                   ; App dependencies
-                  [org.clojure/clojurescript "1.7.145"]
-                  [org.omcljs/om "1.0.0-alpha14-SNAPSHOT"]
+                  [org.clojure/clojurescript "1.7.170"]
+                  [org.omcljs/om "1.0.0-alpha18-SNAPSHOT"]

                   ; Other dependencies
                   [devcards "0.2.0-8"]])


bump versions

bump versions

--- build.boot
+++ build.boot
@@ -1,8 +1,8 @@
 (set-env!
  :source-paths    #{"src"}
  :resource-paths  #{"html" "conf"}
- :dependencies    '[[adzerk/boot-cljs   "0.0-2629-8"]
-                    [pandeiro/boot-http "0.5.0"]])
+ :dependencies    '[[adzerk/boot-cljs   "0.0-2760-0"]
+                    [pandeiro/boot-http "0.6.2"]])

 (require
  '[adzerk.boot-cljs   :refer [cljs]]


Deploy to clojars by default

Deploy to clojars by default

--- build.boot
+++ build.boot
@@ -31,6 +31,7 @@
         :ensure-release true
         :ensure-clean   true
         :gpg-sign       true
+        :repo     "clojars"
         :repo-map [["clojars" {:url "https://clojars.org/repo/"}]]}
   target  {:dir #{"target"}})


Add :parallel-build and :dump-core false

Plus some other fixes that were needed for building and deploying.

--- build.boot
+++ build.boot
@@ -99,6 +99,8 @@
    :elide-asserts true
    :pretty-print false
    :source-map-timestamp true
+   :dump-core false
+   :parallel-build true
    :foreign-libs foreign-libs})

 (defmulti options
@@ -152,7 +154,7 @@
         (add-resource (java.io.File. ".") :include #{#"^version\.properties$"})
         commit!)))

-(deftask source
+(deftask src
   []
   (comp (with-pre-wrap [fs]
           (boot.util/info "Pack source files...\n")
@@ -171,7 +173,11 @@
     (set-system-properties! (:props options))
     (comp (version-file)
           (apply cljs (reduce #(into %2 %1) [] (:cljs options)))
-          (source))))
+          (if (= :prod (:type options))
+            (sift :include #{#"main.out"}
+                  :invert true)
+            identity)
+          (src))))

 (deftask dev
   "Start the dev interactive environment."
@@ -185,7 +191,7 @@
           (cljs-repl)
           (reload :on-jsload 'cljs-repl-web.core/main)
           (apply cljs (reduce #(into %2 %1) [] (:cljs options)))
-          (source)
+          (src)
           (serve))))

 ;;;;;;;;;;;;;;
@@ -197,6 +203,7 @@
   (let [bucket (get (env/env) "AWS_BUCKET")]
     (boot.util/info "Deploying on bucket %s...\n" bucket)
     (sync-bucket #_:dry-run #_true
+                 :prune true
                  :bucket bucket
                  :access-key (get (env/env) "AWS_ACCESS_KEY")
                  :secret-key (get (env/env) "AWS_SECRET_KEY"))))


Require bootlaces commands

Require bootlaces commands

--- build.boot
+++ build.boot
@@ -8,7 +8,7 @@
                           [adzerk/bootlaces "0.1.13" :scope "test"]])

 (require '[adzerk.boot-test :refer [test]]
-         '[adzerk.bootlaces :refer [bootlaces!]])
+         '[adzerk.bootlaces :refer [bootlaces! build-jar push-repo]])

 (task-options!
  pom {:project     project


move keyword-params middleware

move keyword-params middleware

--- src/clj/clj_money/web/server.clj
+++ src/clj/clj_money/web/server.clj
@@ -254,10 +254,9 @@
   (wrap-routes all-routes
                [wrap-anti-forgery                   "anti-forgery"     (complement api?)]
                [wrap-multipart-params               "multipart params" (complement api?)]
-               [wrap-keyword-params                 "keyword params"   (complement api?)]
+               [wrap-keyword-params                 "keyword params"]
                [wrap-json-params                    "json params"      api?]
                [wrap-json-response                  "json response"    api?]
-               [wrap-keyword-params                 "keyword params"]
                [wrap-params                         "params"]
                [wrap-exception-handling             "excpetion handling"]
                [wrap-content-type                   "content-type"]


fix error in api commodities route

fix error in api commodities route

--- src/clj/clj_money/web/server.clj
+++ src/clj/clj_money/web/server.clj
@@ -172,7 +172,7 @@
   (model-route PATCH "/api/entities/:id" entities-api/update)
   (model-route DELETE "/api/entities/:id" entities-api/delete)

-  (model-route GET "/api/entities/:id/commodities" commodities-api/index)
+  (model-route GET "/api/entities/:entity-id/commodities" commodities-api/index)
   (model-route PATCH "/api/commodities/:id" commodities-api/update)
   (model-route DELETE "/api/commodities/:id" commodities-api/delete)


Tests for Street Peddler, including #708 and #578.

--- src/clj/test/cards-resources.clj
+++ src/clj/test/cards-resources.clj
@@ -25,6 +25,62 @@
       (card-ability state :runner (refresh kati) 1)
       (is (= 14 (:credit (get-runner))) "Take 6cr from Kati")
       (is (zero? (:counter (refresh kati))) "No counters left on Kati"))))
+
+(deftest street-peddler-ability
+  "Street Peddler - Ability"
+  (do-game
+    (new-game (default-corp) (default-runner [(qty "Street Peddler" 1) (qty "Gordian Blade" 1) (qty "Torch" 1)
+                                              (qty "Sure Gamble" 2)]))
+    (take-credits state :corp)
+    ; move Gordian back to deck
+    (core/move state :runner (find-card "Gordian Blade" (:hand (get-runner))) :deck)
+    (core/move state :runner (find-card "Sure Gamble" (:hand (get-runner))) :deck)
+    (core/move state :runner (find-card "Torch" (:hand (get-runner))) :deck)
+    (play-from-hand state :runner "Street Peddler")
+    (let [sp (get-in @state [:runner :rig :resource 0])]
+      (is (= 3 (count (:hosted sp))) "Street Peddler is hosting 3 cards")
+      (card-ability state :runner sp 0)
+      (is (= 1 (count (:choices (first (:prompt (get-runner)))))) "Only 1 choice to install off Peddler")
+      (core/resolve-prompt state :runner {:card (find-card "Gordian Blade" (:hosted sp))}) ; choose to install Gordian
+      (is (= "Gordian Blade" (:title (get-in @state [:runner :rig :program 0]))) "Gordian Blade was installed")
+      (is (= 3 (:memory (get-runner))) "Gordian cost 1 mu"))))
+
+(deftest street-peddler-kate-discount
+  "Street Peddler - Interaction with Kate discount"
+  (do-game
+    (new-game (default-corp) (make-deck "Kate \"Mac\" McCaffrey: Digital Tinker"
+                                        [(qty "Street Peddler" 1) (qty "Gordian Blade" 1) (qty "Sure Gamble" 2)]))
+    (take-credits state :corp)
+    ; move Gordian back to deck
+    (core/move state :runner (find-card "Gordian Blade" (:hand (get-runner))) :deck)
+    (core/move state :runner (find-card "Sure Gamble" (:hand (get-runner))) :deck)
+    (core/move state :runner (find-card "Sure Gamble" (:hand (get-runner))) :deck)
+    (play-from-hand state :runner "Street Peddler")
+    (let [sp (get-in @state [:runner :rig :resource 0])]
+      (core/lose state :runner :credit 3) ; should still be able to afford Gordian w/ Kate discount
+      (card-ability state :runner sp 0)
+      (is (= 1 (count (:choices (first (:prompt (get-runner)))))) "Only 1 choice to install off Peddler")
+      (core/resolve-prompt state :runner {:card (find-card "Gordian Blade" (:hosted sp))}) ; choose to install Gordian
+      (is (= "Gordian Blade" (:title (get-in @state [:runner :rig :program 0]))) "Gordian Blade was installed")
+      (is (= 3 (:memory (get-runner))) "Gordian cost 1 mu"))))
+
+(deftest street-peddler-memory-units
+  "Street Peddler - Programs Should Cost Memory. Issue #708"
+  (do-game
+    (new-game (default-corp) (default-runner [(qty "Street Peddler" 1) (qty "Corroder" 3)]))
+    (take-credits state :corp)
+    ; move Corroders back to deck
+    (core/move state :runner (find-card "Corroder" (:hand (get-runner))) :deck)
+    (core/move state :runner (find-card "Corroder" (:hand (get-runner))) :deck)
+    (core/move state :runner (find-card "Corroder" (:hand (get-runner))) :deck)
+    (play-from-hand state :runner "Street Peddler")
+    (is (= 4 (:memory (get-runner))) "No memory cost for hosting on Street Peddler")
+    (let [sp (get-in @state [:runner :rig :resource 0])]
+      (is (= "Corroder" (:title (first (:hosted sp)))) "Street Peddler is hosting Corroder")
+      (card-ability state :runner sp 0)
+      (core/resolve-prompt state :runner {:card (first (:hosted sp))}) ; choose to install Gordian
+      (is (= "Corroder" (:title (get-in @state [:runner :rig :program 0]))) "Corroder was installed")
+      (is (= 3 (:memory (get-runner))) "Corroder cost 1 mu"))))

 (deftest virus-breeding-ground-gain
   "Virus Breeding Ground - Gain counters"


CMR-599: refined validation logic per Jason's comment.

--- search-app/src/cmr/search/validators/validation.clj
+++ search-app/src/cmr/search/validators/validation.clj
@@ -16,12 +16,9 @@
 (defn validate-result-format
   "Validate requested search result format."
   [concept-type result-format]
-  (let [mime-type (mt/format->mime-type result-format)
-        valid-mime-types (set (map mt/format->mime-type
-                                   (concept-type->supported-result-formats concept-type)))]
-    (if-not (get valid-mime-types mime-type)
-      [(format "The mime type [%s] is not supported for %ss." mime-type (name concept-type))]
-      [])))
+  (let [mime-type (mt/format->mime-type result-format)]
+    (when-not (get (concept-type->supported-result-formats concept-type) result-format)
+      [(format "The mime type [%s] is not supported for %ss." mime-type (name concept-type))])))

 (defprotocol Validator
   "Defines the protocol for validating query conditions.
@@ -35,9 +32,7 @@
   (validate
     [{:keys [concept-type result-format condition]}]
     (let [errors (validate-result-format concept-type result-format)]
-      (if-not (empty? errors)
-        errors
-        (validate condition))))
+      (if (seq errors) errors (validate condition))))

   cmr.search.models.query.ConditionGroup
   (validate


Add player test for first-collidable-object

--- test/clj/robinson/world_test.clj
+++ test/clj/robinson/world_test.clj
@@ -102,6 +102,11 @@
          (let [state first-collidable-cells-state]
            (rw/first-collidable-object state :up 3)))))

+(deftest first-collidable-cells-1
+  (is (= {:player {:pos {:x 2 :y 2}}}
+         (let [state first-collidable-cells-state]
+           (rw/first-collidable-object state 1 2 :right 3)))))
+
 (def assoc-cells-state
   {:world {:viewport {:width 5
                      :height 5}


Fix typo in event name used for creating new group

--- src/braid/core/client/gateway/forms/create_group/views.cljs
+++ src/braid/core/client/gateway/forms/create_group/views.cljs
@@ -114,7 +114,7 @@
                   [:group-name
                    :group-url
                    :group-type]
-                  :dispatch-when-valid [:braid.core.client.gateway.forms.create-group.events/remote-create-group]}]))}
+                  :dispatch-when-valid [:braid.core.client.gateway.forms.create-group.events/remote-create-group!]}]))}
    [group-name-field-view]
    [group-url-field-view]
    [group-type-field-view]


Fixed typo.

Fixed typo.

--- src/cljs/wombats_web_client/components/countdown_timer.cljs
+++ src/cljs/wombats_web_client/components/countdown_timer.cljs
@@ -58,7 +58,7 @@
      {:reagent-render
       (fn [start-time]
         ;; Force timer to redraw every second
-        (if (time-left? start-time)
+        (when (time-left? start-time)
           (.setTimeout js/window
                        #(swap! cmpnt-state update-in [:update] not)
                        1000))


Macros: Notes.

Macros: Notes.


Added test checking assumption of ever-increasing IDs in destinations.xml - ever-increasing IDs assumption in both destinations and taxonomy exploited directly in taxonomy lookup structure (keyed by IDs as integers) - properly expressed generate-destinations-data test (left out 'is' call)

--- test/lonelyplanet/model_test.clj
+++ test/lonelyplanet/model_test.clj
@@ -6,7 +6,9 @@
             [clojure.zip :as z]
             [clojure.data.xml :as x]
             [clojure.data.zip :as dz]
-            [clojure.data.zip.xml :as zx]))
+            [clojure.data.zip.xml :as zx]
+
+            [aprint.core :refer [aprint]]))

 (deftest parse-taxonomy
   (let [test-zip (-> (gen-reader "resources/test" "taxonomy.xml")
@@ -34,4 +36,13 @@
   (let [destinations (generate-destinations
                        (gen-reader "resources/test" "taxonomy.xml")
                        (gen-reader "resources/test" "destinations.xml"))]
-    (= (count destinations) 25)))
+    (testing "Expected number of destinations parsed"
+      (is (= (count destinations) 24)))))                   ;; excludes 'World' found in taxonomy.xml
+
+(deftest destination-ordering
+  (let [destination-ids (->> (gen-reader "resources/test" "destinations.xml")
+                             gen-parser
+                             :content
+                             (map (comp #(Integer. ^String %) :atlas_id :attrs)))]
+    (testing "Assumption of continually-increasing :atlas_id codes in destinations.xml"
+      (is (= (apply < destination-ids) true)))))


catch errors in simple-get_permissions

catch errors in simple-get_permissions

remove entries where reading permissions fails with an 'access denied
error'.

--- src/brainbot/nozzle/fsworker.clj
+++ src/brainbot/nozzle/fsworker.clj
@@ -12,34 +12,48 @@
   (:require [brainbot.nozzle.vfs :as vfs]))

-(defn get-permissions-for-entry
-  [fs directory {relpath :relpath, {type :type} :stat, error :error :as entry}]
-  (if (and (= type "file") (not error))
-    (assoc entry "permissions" (vfs/get-permissions fs (vfs/join fs [directory relpath])))
+(defn entry-is-type-ok?
+  [type entry]
+  (and
+   (not (:error entry))
+   (= (get-in entry [:stat :type]) type)))
+
+(def entry-is-directory-ok? (partial entry-is-type-ok? "directory"))
+(def entry-is-file-ok? (partial entry-is-type-ok? "file"))
+
+
+(defn assoc-permissions-for-entry
+  [fs directory {relpath :relpath :as entry}]
+  (assoc entry "permissions"
+         (vfs/get-permissions fs (vfs/join fs [directory relpath]))))
+
+
+(defn safe-assoc-permissions-for-file-entry
+  [fs directory entry]
+  (if (entry-is-file-ok? entry)
+    (try
+      (assoc-permissions-for-entry fs directory entry)
+      (catch Exception err
+        (if (vfs/access-denied-exception? fs err)
+          nil
+          (assoc entry
+            :error (str err)))))
     entry))
+

 (defn get-permissions
   [fs directory entries]
-  (map (partial get-permissions-for-entry fs directory)
-       entries))
-
-
-(defn entry-is-type?
-  [type entry]
-  (= (get-in entry [:stat :type]) type))
-
-(def entry-is-directory? (partial entry-is-type? "directory"))
-(def entry-is-file? (partial entry-is-type? "file"))
+  (remove nil?
+          (map
+           (partial safe-assoc-permissions-for-file-entry fs directory)
+           entries)))

 (defn simple-get_permissions
   [fs {:keys [directory entries] :as body} {publish :publish}]
-  (let [entries-with-permissions (get-permissions fs directory entries)]
-    (doseq [entry (filter (fn [entry]
-                            (and (entry-is-directory? entry)
-                                 (not (:error entry))))
-                          entries-with-permissions)]
+  (let [entries-with-permissions (doall (get-permissions fs directory entries))]
+    (doseq [entry (filter entry-is-directory-ok? entries-with-permissions)]
       (let [subdirectory-path (vfs/join fs [directory (:relpath entry)])]
         (publish "listdir" {:path subdirectory-path})))
     (publish "update_directory" (assoc body :entries entries-with-permissions))))


no more badges

no more badges

--- src/checkmate/views/overview.clj
+++ src/checkmate/views/overview.clj
@@ -8,22 +8,23 @@
     [:div
      (for [[letter items] ordered]
        [:div
-        [:h4 letter]
+        [:h3 letter]
         (for [i items]
           (let [num-done (count (filter :checked? (:items i)))
                 num-all (count (:items i))
                 cls-link (keyword (if-not (= num-all num-done) "strong" "strong.checked"))]
             [(keyword (format "div#%s.row" (:_id i)))
-             [:div.col-md-4
-              [cls-link (elm/link-to (str "/show/" (:_id i)) (:name i)) " " [:span.badge (str num-done "/" num-all)]]]
-             [:div.col-md-8
-              [:div.btn-group
-               [:a {:class "btn btn-default btn-xs" :href (str "/edit/" (:_id i))} [:span.glyphicon.glyphicon-edit] "Edit"]
-               [:a {:class "btn btn-default btn-xs":href "#" :onclick (format "checkmate.views.overview.try_delete_list('%s', '%s');" (:_id i) (:name i))} [:span.glyphicon.glyphicon-trash] "Delete"]]]]))])]))
+             [:p
+              [:div.col-md-8
+               [cls-link (elm/link-to (str "/show/" (:_id i)) (str (:name i) "  (" num-done "/" num-all ")"))]]
+              [:div.col-md-4
+               [:div.btn-group
+                [:a {:class "btn btn-default btn-xs" :href (str "/edit/" (:_id i))} [:span.glyphicon.glyphicon-edit] "Edit"]
+                [:a {:class "btn btn-default btn-xs":href "#" :onclick (format "checkmate.views.overview.try_delete_list('%s', '%s');" (:_id i) (:name i))} [:span.glyphicon.glyphicon-trash] "Delete"]]]]]))])]))

 (defn render [lists]
   (let [grouped (group-by (comp first string/upper-case :name) lists)]
-    {:body [:div
+    {:body [:div.container
             [:h3 "All checklists"]
             [:div.row
              [:div.col-md-12


update from address email

update from address email

--- src/clj/freestuffly/notifier.clj
+++ src/clj/freestuffly/notifier.clj
@@ -36,7 +36,7 @@
   []
   (let [credentials {:api-key (System/getenv "MAILGUN_API_KEY") :domain (System/getenv "YOUR_DOMAIN")}
         params {
-                :from "emile.swarts123@gmail.com"
+                :from "emile@fierce-everglades-57947.herokuapp.com"
                 :to "emile.swarts123@gmail.com"
                 :subject "Free stuffly"
                 :text (presentable (content-for (parsed-html (client/get my-group-urls))))}]


Pull ns-switching outside the let

Pull ns-switching outside the let

def doesn't work as I expected inside a let or binding, regardless of
any ns/in-ns incantations I threw at it.

--- src/clj/reply/initialization.clj
+++ src/clj/reply/initialization.clj
@@ -94,56 +94,60 @@
   "Assumes cd-client will be on the classpath when this is evaluated."
   []
   `(do
-    (println "REPL-y" ~(version/get-version "reply" "reply"))
-    (println "Clojure" (clojure-version))
+     (println "REPL-y" ~(version/get-version "reply" "reply"))
+     (println "Clojure" (clojure-version))

-    (use '[clojure.repl :only ~'[source apropos dir]])
-    ; doc and find-doc live in clojure.core in 1.2
-    (when (ns-resolve '~'clojure.repl '~'pst)
-      (refer 'clojure.repl :only '~'[pst doc find-doc]))
+     (use '[clojure.repl :only ~'[source apropos dir]])
+     ; doc and find-doc live in clojure.core in 1.2
+     (when (ns-resolve '~'clojure.repl '~'pst)
+       (refer 'clojure.repl :only '~'[pst doc find-doc]))

-    (use '[clojure.java.javadoc :only ~'[javadoc]])
-    (use '[clojure.pprint :only ~'[pp pprint]])
+     (use '[clojure.java.javadoc :only ~'[javadoc]])
+     (use '[clojure.pprint :only ~'[pp pprint]])

-    (let [original-ns# ~'*ns*]
-      (ns reply.exports)
-      ~(export-definition 'reply.initialization/intern-with-meta)
+     (create-ns 'reply.exports)
+     (~'intern '~'reply.exports '~'original-ns ~'*ns*)
+     (in-ns '~'reply.exports)
+     (clojure.core/refer '~'clojure.core)

-      (binding [*err* (java.io.StringWriter.)]
-        ~(export-definition 'reply.initialization/repl-defn)
-        (~'intern-with-meta '~'user '~'defn ~'#'repl-defn))
+     ~(export-definition 'reply.initialization/intern-with-meta)

-      ~(export-definition 'reply.initialization/help)
-      (~'intern-with-meta '~'user '~'help ~'#'help)
+     (binding [*err* (java.io.StringWriter.)]
+       ~(export-definition 'reply.initialization/repl-defn)
+       (~'intern-with-meta '~'user '~'defn ~'#'repl-defn))

-      ~(export-definition 'reply.initialization/sourcery)
-      (~'intern-with-meta '~'user '~'sourcery ~'#'sourcery)
+     ~(export-definition 'reply.initialization/help)
+     (~'intern-with-meta '~'user '~'help ~'#'help)

-      ~(export-definition 'reply.initialization/clojuredocs-available?)
-      ~(export-definition 'reply.initialization/call-with-ns-and-name)
-      ~(export-definition 'reply.initialization/handle-fns-etc)
-      ~(export-definition 'reply.initialization/lazy-clojuredocs)
-      (~'intern-with-meta '~'user '~'clojuredocs ~'#'lazy-clojuredocs)
-      (~'intern-with-meta '~'user '~'cdoc ~'#'lazy-clojuredocs)
+     ~(export-definition 'reply.initialization/sourcery)
+     (~'intern-with-meta '~'user '~'sourcery ~'#'sourcery)

-      (try
-        (require '[complete.core])
-        ; hack for 1.2 support until we release the next clojure-complete version
-        ~(export-definition 'reply.initialization/resolve-class)
-        (~'intern-with-meta '~'complete.core '~'resolve-class ~'#'resolve-class)
+     ~(export-definition 'reply.initialization/clojuredocs-available?)
+     ~(export-definition 'reply.initialization/call-with-ns-and-name)
+     ~(export-definition 'reply.initialization/handle-fns-etc)
+     ~(export-definition 'reply.initialization/lazy-clojuredocs)
+     (~'intern-with-meta '~'user '~'clojuredocs ~'#'lazy-clojuredocs)
+     (~'intern-with-meta '~'user '~'cdoc ~'#'lazy-clojuredocs)

-        (catch Exception e#
-          (try
-            (eval '~(formify-file
-                      (ClassLoader/getSystemResource "complete/core.clj")))
-            (catch Exception f#
-              (intern (create-ns '~'complete.core) '~'completions
-                      (fn [prefix# ns#] []))
-              (println "Unable to initialize completions.")))))
+     (try
+       (require '[complete.core])
+       ; hack for 1.2 support until we release the next clojure-complete version
+       ~(export-definition 'reply.initialization/resolve-class)
+       (~'intern-with-meta '~'complete.core '~'resolve-class ~'#'resolve-class)

-      (in-ns (ns-name original-ns#)))
-    (~'user/help)
-    nil))
+       (catch Exception e#
+         (try
+           (eval '~(formify-file
+                     (ClassLoader/getSystemResource "complete/core.clj")))
+           (catch Exception f#
+             (intern (create-ns '~'complete.core) '~'completions
+                     (fn [prefix# ns#] []))
+             (println "Unable to initialize completions.")))))
+
+     (in-ns (ns-name ~'original-ns))
+
+     (~'user/help)
+     nil))

 (defn eval-in-user-ns [code]
   (let [original-ns (symbol (str *ns*))]


Added parsing

Added parsing

--- src/clojure_web_scraper/core.clj
+++ src/clojure_web_scraper/core.clj
@@ -1,18 +1,18 @@
 (ns clojure-web-scraper.core
   (:require [org.httpkit.client :as http])
   (:require [clojure.data.json :as json])
+  (:require [clojure.string :as string])
   (:require [hickory.core :as hickory])
   (:require [hickory.select :as s])
   (:require [clojure.core.async :as async :refer [go go-loop put! take! <! >! <!! timeout chan alt! go]]))

 (def surfing-urls [
-                   "http://magicseaweed.com/East-Wittering-Surf-Report/14/"
-                   "http://magicseaweed.com/West-Wittering-Surf-Report/3765/"
-                   "http://magicseaweed.com/Morocco-Surf-Forecast/12/"
-                   "http://magicseaweed.com/Central-Morocco-Surfing/42/"
-                   "http://magicseaweed.com/Southern-Morocco-Surfing/44/"
-                  ])
+                    "http://magicseaweed.com/East-Wittering-Surf-Report/14/"
+                    "http://magicseaweed.com/West-Wittering-Surf-Report/3765/"
+                    "http://magicseaweed.com/Tamri-Surf-Report/1086/"
+                    "http://magicseaweed.com/Haouzia-Surf-Report/3118/"
+                    ])

 (defn http-get [url]
@@ -23,31 +23,36 @@
               (fn [err] (println (str "error occured:" err))))
     c))

-(defn call-all-the-urls
-  "This function is going to call all the urls async and return the results"
-  []
-  (go
-    (time ;; 3520
-      (doseq [url surfing-urls]
-        (println (<! (http-get url)))))))
+(defn selector-get-waves-size-text [hickory-tree] (-> (s/select (s/class "rating-text") hickory-tree)
+                                                 first :content first string/trim))

-(call-all-the-urls)
+(defn transform-text-number
+  [text]
+    (if (= (string/lower-case text) "flat")
+      (int 0)
+      (if (integer? text)
+        (int text)
+        (second (re-matches #"\d+-(\d+)" text)))))

-(defn selector [hickory-tree] (s/select (s/child  (s/class "nomargin")) hickory-tree))
+(if (number? "1") "1" nil)
+(transform-text-number "1")
+(re-matches #"\d+-(\d+)" "1")
+
+(integer? "12---2")

 (defn call-all-the-urls-optn
   []
   (go
-    (time ;; 2274.652699  msecs
-      (let [chans (doall (for [url surfing-url]
-                           (http-get url)))]
-        (println chans)
-        (doseq [c chans]
-          (println "Channel value:" (-> c
-                                        <!
-                                        :body
-                                        hickory/parse
-                                        selector)))))))
+    (let [urls-channels (doall (for [url surfing-urls]
+                                 [url (http-get url)]))]
+      (doseq [url-channel urls-channels]
+        (println "Channel value:" "for url:" (first url-channel) (-> (second url-channel)
+                                                                     <!
+                                                                     :body
+                                                                     hickory/parse
+                                                                     hickory/as-hickory
+                                                                     selector-get-waves-size-text
+                                                                     transform-text-number))))))

 (call-all-the-urls-optn)

@@ -56,3 +61,14 @@

 (def parsed-doc (hickory/parse "foo"))
 (hickory/as-hiccup parsed-doc)
+
+
+;; (defn call-all-the-urls
+;;   "This function is going to call all the urls async and return the results"
+;;   []
+;;   (go
+;;     (time ;; 3520
+;;       (doseq [url surfing-urls]
+;;         (println (<! (http-get url)))))))
+
+;; (call-all-the-urls)


Fix docstring.

Fix docstring.

--- src/clucy/positions_searcher.clj
+++ src/clucy/positions_searcher.clj
@@ -42,7 +42,7 @@

 (defn stemming-text [^String text
                      & {:keys [format] :or {format #{}}}]
-  "Convert words from dictionary set into stemmed form according to *analyzer*."
+  "Convert words from text into stemmed form according to *analyzer*."
   (let [^TokenStream ts (.tokenStream *analyzer* (as-str *field-name*) text)
         ^CharTermAttribute ta (.addAttribute ts CharTermAttribute)
         next-token (fn []


CMR-564: Removed unneeded require.

CMR-564: Removed unneeded require.

--- src/cmr/transmit/transformer.clj
+++ src/cmr/transmit/transformer.clj
@@ -4,7 +4,6 @@
             [cmr.common.services.errors :as errors]
             [cmr.transmit.config :as config]
             [cheshire.core :as cheshire]
-            [clojure.walk :as walk]
             [cmr.system-trace.http :as ch]
             [cmr.system-trace.core :refer [deftracefn]]
             [cmr.transmit.connection :as conn]))


Add new word with new attributes (to be finished)

--- src/zg/server.clj
+++ src/zg/server.clj
@@ -135,15 +135,21 @@
 (defn process-add-word
     "Add word provided by user (together with its description) to the blacklist or into atomic typos."
     [request title emender-page mode]
+    (println request)
     (let [word         (read-string-parameter request "new-word")
           description  (read-string-parameter request "description")
           correct-form (read-string-parameter request "correct-word")
+          word-class   (read-string-parameter request "class")
+          internal     (read-string-parameter request "internal")
+          copyright    (read-string-parameter request "copyright")
+          source       (read-string-parameter request "source")
           proper-word  (dictionary-interface/proper-word-for-blacklist? word)
           user-name    (get-user-name request)
-          message      (add-word-message word proper-word)]
+          message      (add-word-message word proper-word)
+          sources      (db-interface/read-sources)]
           (if (and proper-word (seq word))
               (dictionary-interface/store-word word correct-form description user-name mode))
-        (finish-processing request nil nil message title emender-page mode)))
+        (finish-processing request nil sources message title emender-page mode)))

 (defn process-add-words
     [request title emender-page mode]


Fixed typo in job-does-not-exist-response

--- src/emender_jenkins/rest_api.clj
+++ src/emender_jenkins/rest_api.clj
@@ -93,7 +93,7 @@
     [job-name command]
     {:status "error"
      :job-name job-name
-     :command "start"
+     :command command
      :message "Job does not exist"})

 (defn start-job


Redirect user to home page if an unauthorized message comes back from any ajax call

--- src/cljs/org/broadinstitute/firecloud_ui/utils.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/utils.cljs
@@ -88,12 +88,15 @@
           call-on-done (fn []
                          (let [status-code (.-status xhr)
                                get-parsed-response #(parse-json-string (.-responseText xhr))]
-                           (on-done {:xhr xhr
-                                     :status-code status-code
-                                     :success? (and (>= status-code 200)
-                                                    (< status-code 300))
-                                     :status-text (.-statusText xhr)
-                                     :get-parsed-response get-parsed-response})))]
+                           ; TODO: Fix this with a real log-out once the login bug is fixed and logout is implemented.
+                           (if (= status-code 401)
+                             (set! (-> js/window .-location) (str js/window.location.protocol "//" js/window.location.hostname))
+                             (on-done {:xhr xhr
+                                       :status-code status-code
+                                       :success? (and (>= status-code 200)
+                                                      (< status-code 300))
+                                       :status-text (.-statusText xhr)
+                                       :get-parsed-response get-parsed-response}))))]
       (when with-credentials?
         (set! (.-withCredentials xhr) true))
       (if canned-response-params


New module: git-interface

New module: git-interface


Remove unused debug component in core

Remove unused debug component in core


Fix test

Fix test

--- test/skidskytte/test/handler.clj
+++ test/skidskytte/test/handler.clj
@@ -1,14 +1,13 @@
 (ns skidskytte.test.handler
   (:use clojure.test
-        ring.mock.request
+        ring.mock.request
         skidskytte.handler))

 (deftest test-app
   (testing "main route"
     (let [response (app (request :get "/"))]
-      (is (= (:status response) 200))
-      (is (= (:body response) "Hello World"))))
-
+      (is (= (:status response) 200))))
+
   (testing "not-found route"
     (let [response (app (request :get "/invalid"))]
       (is (= (:status response) 404)))))


read-ledger-entries takes additional args


add gene species

add gene species


Extract unbox node function

Extract unbox node function

--- src/graphql_clj/validator/transformations/unbox.clj
+++ src/graphql_clj/validator/transformations/unbox.clj
@@ -2,19 +2,21 @@
   (:require [graphql-clj.visitor :as v]
             [graphql-clj.box :as box]))

+(defn- unbox-node [n]
+  (cond-> n
+          (:type-name n)      (update :type-name     box/box->val)
+          (:field-name n)     (update :field-name    box/box->val)
+          (:argument-name n)  (update :argument-name box/box->val)
+          (:variable-name n)  (update :variable-name box/box->val)
+          (:implements n)     (update-in [:implements :type-names] #(mapv box/box->val %))
+          (:type-condition n) (update-in [:type-condition :type-name] box/box->val)
+          (:type-names n)     (update :type-names #(mapv box/box->val %))
+          (:inner-type n)     (update-in [:inner-type :type-name] box/box->val)
+          (:on n)             (update-in [:on :type-name] box/box->val)
+          (:value n)          (update :value box/box->val)))
+
 (declare unbox)
 (v/defmapvisitor unbox :post [n s]
-  (when (:node-type n)
-    (cond-> {:node n}
-            (:type-name n)      (update-in [:node :type-name]     box/box->val)
-            (:field-name n)     (update-in [:node :field-name]    box/box->val)
-            (:argument-name n)  (update-in [:node :argument-name] box/box->val)
-            (:variable-name n)  (update-in [:node :variable-name] box/box->val)
-            (:implements n)     (update-in [:node :implements :type-names] #(mapv box/box->val %))
-            (:type-condition n) (update-in [:node :type-condition :type-name] box/box->val)
-            (:type-names n)     (update-in [:node :type-names] #(mapv box/box->val %))
-            (:inner-type n)     (update-in [:node :inner-type :type-name] box/box->val)
-            (:on n)             (update-in [:node :on :type-name] box/box->val)
-            (:value n)          (update-in [:node :value] box/box->val))))
+  (when (:node-type n) {:node (unbox-node n)}))

 (def rules [unbox])


Reuse Korma DB connection pools instead of creating new ones all the time

--- src/metabase/models/database.clj
+++ src/metabase/models/database.clj
@@ -27,16 +27,27 @@
    This will reuse `*jdbc-metadata*` if it's already set (to avoid opening extra connections).
    Otherwise it will open a new metadata connection and bind `*jdbc-metadata*` so it's available in subsequent calls to `with-jdbc-metadata` within F."
   [{:keys [connection]} f]
+  {:pre [(delay? connection)]}
   (if *jdbc-metadata* (f *jdbc-metadata*)
       (jdbc/with-db-metadata [md @connection]
         (binding [*jdbc-metadata* md]
           (f *jdbc-metadata*)))))

+;; Cache the Korma DB connections for given Database
+;; instead of creating new ones every single time
+(def ^:private connection->korma-db
+  (memoize
+   (fn [connection]
+     {:pre [(map? connection)]}
+     (log/debug "CREATING A NEW DB CONNECTION...")
+     (kdb/create-db connection))))
+
 (defn korma-db
   "Return a Korma database definition for DATABASE."
   [{:keys [connection]}]
+  {:pre [(delay? connection)]}
   (log/debug "CREATING A NEW DB CONNECTION...")
-  (kdb/create-db @connection))
+  (connection->korma-db @connection))

 (defn table-names
   "Fetch a list of table names for DATABASE."


Enable public boards by default.

Enable public boards by default.

--- src/oc/storage/resources/org.clj
+++ src/oc/storage/resources/org.clj
@@ -27,7 +27,7 @@
 (def default-promoted false)

 (def content-visibility {:disallow-secure-links false
-                         :disallow-public-board true
+                         :disallow-public-board false
                          :disallow-public-share false})

 ;; ----- Utility functions -----


Remove vestigial DIRE compile time logging checks

--- src/onyx/peer/task_lifecycle.clj
+++ src/onyx/peer/task_lifecycle.clj
@@ -36,12 +36,9 @@

 (defn munge-start-lifecycle [event]
   (let [rets ((:onyx.core/compiled-start-task-fn event) event)]
-    (when (or (nil? level-compile-time)
-              (= level-compile-time :info)
-              (= level-compile-time :trace))
-      (when-not (:onyx.core/start-lifecycle? rets)
-        (timbre/info (format "[%s / %s] Lifecycle chose not to start the task yet. Backing off and retrying..."
-                             (:onx.core/id rets) (:onyx.core/lifecycle-id rets)))))
+    (when-not (:onyx.core/start-lifecycle? rets)
+      (timbre/info (format "[%s / %s] Lifecycle chose not to start the task yet. Backing off and retrying..."
+                           (:onx.core/id rets) (:onyx.core/lifecycle-id rets))))
     rets))

 (defn add-acker-id [peers m]
@@ -190,9 +187,8 @@
   (let [rets (-> event
                  (merge ((:onyx.core/compiled-before-batch-fn event) event))
                  (assoc :onyx.core/lifecycle-id (java.util.UUID/randomUUID)))]
-    (when (or (nil? level-compile-time) (= level-compile-time :trace))
-      (taoensso.timbre/trace (format "[%s / %s] Started a new batch"
-                                     (:onyx.core/id rets) (:onyx.core/lifecycle-id rets))))
+    (taoensso.timbre/trace (format "[%s / %s] Started a new batch"
+                                   (:onyx.core/id rets) (:onyx.core/lifecycle-id rets)))
     rets))

 (defn read-batch [event]
@@ -275,30 +271,25 @@
         (if (:onyx/bulk? (:onyx.core/task-map event))
           (apply-fn-bulk event)
           (apply-fn-single event))]
-    (when (or (nil? level-compile-time)
-              (= level-compile-time :trace))
-      (taoensso.timbre/trace (format "[%s / %s] Applied fn to %s segments"
-                                     (:onyx.core/id rets)
-                                     (:onyx.core/lifecycle-id rets)
-                                     (count (:onyx.core/results rets)))))
+    (taoensso.timbre/trace (format "[%s / %s] Applied fn to %s segments"
+                                   (:onyx.core/id rets)
+                                   (:onyx.core/lifecycle-id rets)
+                                   (count (:onyx.core/results rets))))
     rets))

 (defn write-batch [event]
   (let [rets (merge event (p-ext/write-batch event))]
-    (when (or (nil? level-compile-time) (= level-compile-time :trace))
-      (= level-compile-time :trace)
-      (taoensso.timbre/trace (format "[%s / %s] Wrote %s segments"
-                                     (:onyx.core/id rets)
-                                     (:onyx.core/lifecycle-id rets)
-                                     (count (:onyx.core/results rets)))))
+    (taoensso.timbre/trace (format "[%s / %s] Wrote %s segments"
+                                   (:onyx.core/id rets)
+                                   (:onyx.core/lifecycle-id rets)
+                                   (count (:onyx.core/results rets))))
     rets))

 (defn close-batch-resources [event]
   (let [rets (merge event ((:onyx.core/compiled-after-batch-fn event) event))]
-    (when (or (nil? level-compile-time) (= level-compile-time :trace))
-      (taoensso.timbre/trace (format "[%s / %s] Closed batch plugin resources"
-                                     (:onyx.core/id rets)
-                                     (:onyx.core/lifecycle-id rets))))
+    (taoensso.timbre/trace (format "[%s / %s] Closed batch plugin resources"
+                                   (:onyx.core/id rets)
+                                   (:onyx.core/lifecycle-id rets)))
     rets))

 (defn launch-aux-threads!


Do not close go-loops so that later reads block

until the go-loops have finished execution after task-kill-ch is closed

--- src/onyx/peer/task_lifecycle.clj
+++ src/onyx/peer/task_lifecycle.clj
@@ -455,8 +455,6 @@
       (l-ext/close-lifecycle-resources* event)

       (close! (:seal-ch component))
-      (close! (:aux-ch component))
-      (close! (:replay-messages-ch component))
       (close! (:task-lifecycle-ch component))

       ;; Ensure task operations are finished before closing peer connections


only display vs errors for the correct platform

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

--- buildscripts/buildcheck/src/buildcheck/core.clj
+++ buildscripts/buildcheck/src/buildcheck/core.clj
@@ -25,12 +25,13 @@
         before (- now (* time-limit-hours MS-PER-HOUR))]
     (< (.lastModified file) before)))

-(defn vs-log-files []
+(defn vs-log-files [bits]
   (->> micromanager
        file-seq
-       (filter #(= "BuildLog.htm" (.getName %)))
-       (filter #(.contains (.getAbsolutePath %) "Release"))
-       (filter #(not (old-file? % 24)))))
+       (filter #(and (= "BuildLog.htm" (.getName %))
+                     (.contains (.getAbsolutePath %) "Release")
+                     (.contains (.getAbsolutePath %) (str bits))
+                     (not (old-file? % 24))))))

 (defn vs-log-text [f]
   (->> (slurp f :encoding "utf-16")
@@ -44,8 +45,8 @@
                log-text)
     true false))

-(defn visual-studio-errors []
-  (filter contains-errors? (map vs-log-text (vs-log-files))))
+(defn visual-studio-errors [bits]
+  (filter contains-errors? (map vs-log-text (vs-log-files bits))))

 (defn javac-errors [result-text]
   (map first
@@ -160,7 +161,7 @@
 (defn report-build-errors [bits mode test]
   (let [f (result-file bits mode)
         result-txt (slurp f)
-        vs-errors (visual-studio-errors)
+        vs-errors (visual-studio-errors bits)
         outdated-dlls (map #(.getName %) (old-dlls (bin-dir bits) 24))
         javac-errs (javac-errors result-txt)
         outdated-jars (map #(.getName %)


update auth test to cleanup launched servers

--- test/clj/backtype/storm/security/auth/auth_test.clj
+++ test/clj/backtype/storm/security/auth/auth_test.clj
@@ -113,103 +113,109 @@
         server (ThriftServer. conf (Nimbus$Processor. service-handler) (int (conf NIMBUS-THRIFT-PORT)))]
     (.addShutdownHook (Runtime/getRuntime) (Thread. (fn [] (.stop server))))
     (.start (Thread. #(.serve server)))
-    (wait-for-condition #(.isServing server))))
+    (wait-for-condition #(.isServing server))
+    server ))
+
+(defmacro with-server [args & body]
+  `(let [server# (launch-server ~@args)]
+      ~@body
+      (.stop server#)
+      ))

 (deftest Simple-authentication-test
-  (launch-server 6627 nil nil "backtype.storm.security.auth.SimpleTransportPlugin")
-
-  (let [storm-conf (merge (read-storm-config)
-                          {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.SimpleTransportPlugin"})
-        client (NimbusClient. storm-conf "localhost" 6627 nimbus-timeout)
-        nimbus_client (.getClient client)]
-    (.activate nimbus_client "security_auth_test_topology")
-    (.close client))
-
-  (let [storm-conf (merge (read-storm-config)
-                          {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
-                           "java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest.conf"})]
-    (testing "(Negative authentication) Server: Simple vs. Client: Digest"
-             (is (thrown-cause?  java.net.SocketTimeoutException
-                           (NimbusClient. storm-conf "localhost" 6627 nimbus-timeout))))))
+  (with-server [6627 nil nil "backtype.storm.security.auth.SimpleTransportPlugin"]
+    (let [storm-conf (merge (read-storm-config)
+                            {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.SimpleTransportPlugin"})
+          client (NimbusClient. storm-conf "localhost" 6627 nimbus-timeout)
+          nimbus_client (.getClient client)]
+      (.activate nimbus_client "security_auth_test_topology")
+      (.close client))
+
+    (let [storm-conf (merge (read-storm-config)
+                            {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
+                             "java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest.conf"})]
+      (testing "(Negative authentication) Server: Simple vs. Client: Digest"
+               (is (thrown-cause?  java.net.SocketTimeoutException
+                             (NimbusClient. storm-conf "localhost" 6627 nimbus-timeout)))))))

 (deftest positive-authorization-test
-  (launch-server 6628  nil
-                        "backtype.storm.security.auth.authorizer.NoopAuthorizer"
-                        "backtype.storm.security.auth.SimpleTransportPlugin")
-  (let [storm-conf (merge (read-storm-config)
-                           {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.SimpleTransportPlugin"})
-        client (NimbusClient. storm-conf "localhost" 6628 nimbus-timeout)
-        nimbus_client (.getClient client)]
-    (testing "(Positive authorization) Authorization plugin should accept client request"
-             (.activate nimbus_client "security_auth_test_topology"))
-    (.close client)))
+  (with-server [6627 nil
+                "backtype.storm.security.auth.authorizer.NoopAuthorizer"
+                "backtype.storm.security.auth.SimpleTransportPlugin"]
+    (let [storm-conf (merge (read-storm-config)
+                             {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.SimpleTransportPlugin"})
+          client (NimbusClient. storm-conf "localhost" 6627 nimbus-timeout)
+          nimbus_client (.getClient client)]
+      (testing "(Positive authorization) Authorization plugin should accept client request"
+               (.activate nimbus_client "security_auth_test_topology"))
+      (.close client))))

 (deftest deny-authorization-test
-  (launch-server 6629 nil
-                        "backtype.storm.security.auth.authorizer.DenyAuthorizer"
-                        "backtype.storm.security.auth.SimpleTransportPlugin")
-  (let [storm-conf (merge (read-storm-config)
-                           {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.SimpleTransportPlugin"
-                           Config/NIMBUS_HOST "localhost"
-                           Config/NIMBUS_THRIFT_PORT 6629
-                           Config/NIMBUS_TASK_TIMEOUT_SECS nimbus-timeout})
-        client (NimbusClient/getConfiguredClient storm-conf)
-        nimbus_client (.getClient client)]
-    (testing "(Negative authorization) Authorization plugin should reject client request"
-             (is (thrown? TTransportException
-                          (.activate nimbus_client "security_auth_test_topology"))))
-             (.close client)))
+  (with-server [6627 nil
+                "backtype.storm.security.auth.authorizer.DenyAuthorizer"
+                "backtype.storm.security.auth.SimpleTransportPlugin"]
+    (let [storm-conf (merge (read-storm-config)
+                             {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.SimpleTransportPlugin"
+                             Config/NIMBUS_HOST "localhost"
+                             Config/NIMBUS_THRIFT_PORT 6627
+                             Config/NIMBUS_TASK_TIMEOUT_SECS nimbus-timeout})
+          client (NimbusClient/getConfiguredClient storm-conf)
+          nimbus_client (.getClient client)]
+      (testing "(Negative authorization) Authorization plugin should reject client request"
+               (is (thrown? TTransportException
+                            (.activate nimbus_client "security_auth_test_topology"))))
+               (.close client))))

 (deftest digest-authentication-test
-  (launch-server 6630
-                        "test/clj/backtype/storm/security/auth/jaas_digest.conf"
-                        nil
-                        "backtype.storm.security.auth.digest.DigestSaslTransportPlugin")
-  (let [storm-conf (merge (read-storm-config)
-                           {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
-                            "java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest.conf"})
-        client (NimbusClient. storm-conf "localhost" 6630 nimbus-timeout)
-        nimbus_client (.getClient client)]
-    (testing "(Positive authentication) valid digest authentication"
-             (.activate nimbus_client "security_auth_test_topology"))
-    (.close client))
-
-  (let [storm-conf (merge (read-storm-config)
-                           {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.SimpleTransportPlugin"})
-        client (NimbusClient. storm-conf "localhost" 6630 nimbus-timeout)
-        nimbus_client (.getClient client)]
-    (testing "(Negative authentication) Server: Digest vs. Client: Simple"
-             (is (thrown-cause? java.net.SocketTimeoutException
-                                (.activate nimbus_client "security_auth_test_topology"))))
-    (.close client))
+  (with-server [6630
+                "test/clj/backtype/storm/security/auth/jaas_digest.conf"
+                nil
+                "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"]
+    (let [storm-conf (merge (read-storm-config)
+                             {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
+                              "java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest.conf"})
+          client (NimbusClient. storm-conf "localhost" 6630 nimbus-timeout)
+          nimbus_client (.getClient client)]
+      (testing "(Positive authentication) valid digest authentication"
+               (.activate nimbus_client "security_auth_test_topology"))
+      (.close client))

-  (let [storm-conf (merge (read-storm-config)
-                          {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
-                           "java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest_bad_password.conf"})]
-    (testing "(Negative authentication) Invalid  password"
-             (is (thrown? TTransportException
-                          (NimbusClient. storm-conf "localhost" 6630 nimbus-timeout)))))
+    (let [storm-conf (merge (read-storm-config)
+                             {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.SimpleTransportPlugin"})
+          client (NimbusClient. storm-conf "localhost" 6630 nimbus-timeout)
+          nimbus_client (.getClient client)]
+      (testing "(Negative authentication) Server: Digest vs. Client: Simple"
+               (is (thrown-cause? java.net.SocketTimeoutException
+                                  (.activate nimbus_client "security_auth_test_topology"))))
+      (.close client))
+
+    (let [storm-conf (merge (read-storm-config)
+                            {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
+                             "java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest_bad_password.conf"})]
+      (testing "(Negative authentication) Invalid  password"
+               (is (thrown? TTransportException
+                            (NimbusClient. storm-conf "localhost" 6630 nimbus-timeout)))))
+
+    (let [storm-conf (merge (read-storm-config)
+                             {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
+                              "java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest_unknown_user.conf"})]
+      (testing "(Negative authentication) Unknown user"
+               (is (thrown? TTransportException
+                            (NimbusClient. storm-conf "localhost" 6630 nimbus-timeout)))))
+
+    (let [storm-conf (merge (read-storm-config)
+                             {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
+                              "java.security.auth.login.config" "test/clj/backtype/storm/security/auth/nonexistent.conf"})]
+      (testing "(Negative authentication) nonexistent configuration file"
+               (is (thrown? RuntimeException
+                            (NimbusClient. storm-conf "localhost" 6630 nimbus-timeout)))))

-  (let [storm-conf (merge (read-storm-config)
-                           {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
-                            "java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest_unknown_user.conf"})]
-    (testing "(Negative authentication) Unknown user"
-             (is (thrown? TTransportException
-                          (NimbusClient. storm-conf "localhost" 6630 nimbus-timeout)))))
-
-  (let [storm-conf (merge (read-storm-config)
-                           {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
-                            "java.security.auth.login.config" "test/clj/backtype/storm/security/auth/nonexistent.conf"})]
-    (testing "(Negative authentication) nonexistent configuration file"
-             (is (thrown? RuntimeException
-                          (NimbusClient. storm-conf "localhost" 6630 nimbus-timeout)))))
-
-  (let [storm-conf (merge (read-storm-config)
-                          {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
-                           "java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest_missing_client.conf"})]
-    (testing "(Negative authentication) Missing client"
-             (is (thrown-cause? java.io.IOException
-                                (NimbusClient. storm-conf "localhost" 6630 nimbus-timeout))))))
+    (let [storm-conf (merge (read-storm-config)
+                            {STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
+                             "java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest_missing_client.conf"})]
+      (testing "(Negative authentication) Missing client"
+               (is (thrown-cause? java.io.IOException
+                                  (NimbusClient. storm-conf "localhost" 6630 nimbus-timeout)))))))

 (deftest test-GetTransportPlugin-throws-RuntimeException


Prime number finder using Church numerals.

--- SICP/ex_2_6.clj
+++ SICP/ex_2_6.clj
@@ -1,6 +1,9 @@
 ; :mode=clojure:

-; Church numerals
+; Church numerals, and prime number finder.
+; Doesn't use any primitive data types (e.g. int or bool), only functions (and nil).
+; Initially prompted by ex 2.6 from SICP.
+

 (def zero (fn [f] (fn [x] x)))

@@ -24,17 +27,116 @@
 ; subtraction (not part of the exercise)
 (def sub (fn [a b] ((b dec-1) a)))

-; Convenience to convert to normal primitive integer
+; multiplication (not part of the exercise)
+(def mul (fn [a b] (a b)))
+
+; 'true'
+(def true-val (fn [a _] a))
+
+; 'false'
+(def false-val (fn [_ b] b))
+
+; 'if'
+(def if-op (fn [p a b] ((p a b))))
+
+; test for zero
+(def is-zero? (fn [n] ((n (fn [_] false-val)) true-val)))
+
+; test for equality
+(def are-equal? (fn [a b]
+    (if-op (is-zero? (sub a b))
+        (fn [] (is-zero? (sub b a)))
+        (fn [] false-val))))
+
+; boolean negation
+(def not-op (fn [p] (fn [a b] (p b a))))
+
+; a < b
+(def less-than? (fn [a b]
+    (not-op (is-zero? (sub b a)))))
+
+; a mod b
+(def mod-op (fn [a b]
+    (if-op (less-than? a b)
+        (fn [] a)
+        (fn [] (mod-op (sub a b) b)))))
+
+(def is-prime-imp?
+    (fn [n t]
+        (if-op (less-than? t n)
+            (fn []
+                (if-op (is-zero? (mod-op n t))
+                    (fn [] false-val)
+                    (fn [] (is-prime-imp? n (add-1 t)))))
+            (fn [] true-val))))
+
+; Test for primality.
+(def is-prime? (fn [n] (is-prime-imp? n two)))
+
+; 'cons'
+(def pair (fn [h t] (fn [p] (p h t))))
+
+; 'first' (similar to true-val, but implementing independently for clarity)
+(def first-op (fn [c] (c (fn [h _] h))))
+; 'rest' (similar to false-val, but implementing independently for clarity)
+(def rest-op (fn [c] (c (fn [_ t] t))))
+
+; List of all primes less than or equal to 'n'.
+(def all-primes-up-to (fn [n]
+    (if-op (less-than? n two)
+        (fn [] nil)
+        (fn [] (
+            (fn [r]
+                (if-op (is-prime? n)
+                    (fn [] (pair n r))
+                    (fn [] r)))
+            (all-primes-up-to (dec-1 n)))))))
+
+
+; --------------------------------------
+
+; Convenience to convert to normal clojure integer
 (defn to-int [n] ((n inc) 0))

+; Convenience to convert from normal clojure integer
+(defn from-int [n] (nth (iterate add-1 zero) n))
+
+; Convenience to convert to normal clojure boolean
+(defn to-bool [p] (p true false))
+
+; Convenience to convert to normal clojure list
+(defn to-list [c]
+    (if (nil? c) (list) (cons (first-op c) (to-list (rest-op c)))))
+
 ; Some tests
-(println
+(dorun (map println [
+    (to-bool true-val) ; true
+    (to-bool false-val) ; false
+    (to-bool (are-equal? zero zero)) ; true
+    (to-bool (are-equal? zero one)) ; false
+    (to-bool (are-equal? one zero)) ; false
+    (to-bool (are-equal? two two)) ; true
+    (to-bool (are-equal? two one)) ; false
+    (to-bool (are-equal? one two)) ; false
+    (to-bool (is-zero? zero)) ; true
+    (to-bool (is-zero? one)) ; false
+    (to-bool (is-zero? two)) ; false
+    (to-bool (is-zero? (sub two two))) ; true
     (to-int (add-1 (add-1 (add-1 (add-1 zero))))) ; 4
     (to-int one) ; 1
     (to-int two) ; 2
     (to-int (dec-1 two)) ; 1
     (to-int (add one two)) ; 3
-    (to-int (add (add-1 (add-1 (add-1 zero))) (add-1 (add-1 zero)))) ; 5
-    (to-int (sub (add-1 (add-1 (add-1 (add-1 zero)))) (add-1 (add-1 zero)))) ; 2
-)
+    (to-int (mul two two)) ; 4
+    (to-int (mod-op (from-int 5) (from-int 3))) ; 2
+    (to-int (add (from-int 3) (from-int 2))) ; 5
+    (to-int (sub (from-int 4) (from-int 2))) ; 2
+    (to-bool (is-prime? (from-int 2))) ; true
+    (to-bool (is-prime? (from-int 3))) ; true
+    (to-bool (is-prime? (from-int 4))) ; false
+    (to-bool (is-prime? (from-int 5))) ; true
+    (to-bool (is-prime? (from-int 6))) ; false
+    (map to-int (to-list (all-primes-up-to (from-int 100)))) ; all primes <= 100
+]))

+


fixes typo in :service-d (#1130)

fixes typo in :service-d (#1130)

--- waiter/src/waiter/state/maintainer.clj
+++ waiter/src/waiter/state/maintainer.clj
@@ -648,7 +648,7 @@
                                                         :num-expired-unhealthy-instances (count expired-unhealthy-instances)
                                                         :num-healthy-instances (count healthy-instances)
                                                         :num-unhealthy-instance-ids (count unhealthy-instance-ids)
-                                                        :service-d service-id}
+                                                        :service-id service-id}
                                                        (if (seq new-instance-ids) (str "New healthy instances: " new-instance-ids ".") "")
                                                        (if (seq rem-instance-ids) (str "Removed healthy instances: " rem-instance-ids ".") "")
                                                        (if (seq unhealthy-instance-ids) (str "Unhealthy instances: " unhealthy-instance-ids ".") ""))))


Remove unused java object unpacking functions

--- src/radicalzephyr/boot_junit.clj
+++ src/radicalzephyr/boot_junit.clj
@@ -14,19 +14,6 @@
            (org.reflections.util ClasspathHelper
                                  ConfigurationBuilder
                                  FilterBuilder)))
-
-(defn- failure->map [failure]
-  {:description (.. failure (getDescription) (toString))
-   ;;:exception (.getException failure)
-   :message (.getMessage failure)})
-
-(defn- result->map [result]
-  {:successful? (.wasSuccessful result)
-   :run-time (.getRunTime result)
-   :run     (.getRunCount result)
-   :ignored (.getIgnoreCount result)
-   :failed  (.getFailureCount result)
-   :failures (map failure->map (.getFailures result))})

 (defn- build-package-config [^String package]
   (.. (ConfigurationBuilder.)


Use real beachball colors

Use real beachball colors

--- config.clj
+++ config.clj
@@ -93,9 +93,11 @@
 (defmode ant 2.0 4)

 (defmode beachball
-  [(color/rgb 1 0 0)
+  [(color/rgb 1 1 1)
+   (color/rgb 1 0 0)
    (color/rgb 1 1 1)
    (color/rgb 1 1 0)
+   (color/rgb 1 1 1)
    (color/rgb 0 0 1)])

 (defmode bombs)


replaced more user-id stuff

replaced more user-id stuff

--- src/server/client-interface.cljs
+++ src/server/client-interface.cljs
@@ -152,202 +152,233 @@
     (fn [position]
       (println "Received pause signal with position" position
                "from" (.-id socket))
-      (rooms/get-room-from-user-id (.-id socket)
-        (fn [room]
-          (rooms/cooldown room "play-pause"
-            (fn [ok?]
-              (if ok?
-                (rooms/pause-current-track room position
-                  (fn []
-                    (.emit (.to io room) "pause" position))))))))))
+
+      (rooms/get-user-id-from-socket (.-id socket)
+        (fn [user-id]
+          (rooms/get-room-from-user-id user-id
+            (fn [room]
+              (rooms/cooldown room "play-pause"
+                (fn [ok?]
+                  (if ok?
+                    (rooms/pause-current-track room position
+                      (fn []
+                        (.emit (.to io room) "pause" position))))))))))))

   (.on socket "resume"
     (fn []
       (println "Received resume signal from" (.-id socket))
-      (rooms/get-room-from-user-id (.-id socket)
-        (fn [room]
-          (rooms/cooldown room "play-pause"
-            (fn [ok?]
-              (if ok?
-                (rooms/resume-current-track room
-                  (fn []
-                    (.emit (.to io room) "resume"))))))))))
+      (rooms/get-user-id-from-socket (.-id socket)
+        (fn [user-id]
+          (rooms/get-room-from-user-id user-id
+            (fn [room]
+              (rooms/cooldown room "play-pause"
+                (fn [ok?]
+                  (if ok?
+                    (rooms/resume-current-track room
+                      (fn []
+                        (.emit (.to io room) "resume"))))))))))))

   (.on socket "position-change"
     (fn [position]
       (println "Received position-change signal with position" position
                "from" (.-id socket))
-      (rooms/get-room-from-user-id (.-id socket)
-        (fn [room]
-          (rooms/cooldown room "position-change"
-            (fn [ok?]
-              (if ok?
-                (rooms/get-current-sound-id room
-                  (fn [sound-id]
-                    (if-not (nil? sound-id)
-                      (rooms/change-current-track-position room position
-                        (fn []
-                          (.emit (.to io room) "position-change" position)))))))))))))
+      (rooms/get-user-id-from-socket (.-id socket)
+        (fn [user-id]
+          (rooms/get-room-from-user-id user-id
+            (fn [room]
+              (rooms/cooldown room "position-change"
+                (fn [ok?]
+                  (if ok?
+                    (rooms/get-current-sound-id room
+                      (fn [sound-id]
+                        (if-not (nil? sound-id)
+                          (rooms/change-current-track-position room position
+                            (fn []
+                              (.emit (.to io room) "position-change" position)))))))))))))))

   (.on socket "start-looping"
     (fn []
       (println "Received start-looping signal from" (.-id socket))
-      (rooms/get-room-from-user-id (.-id socket)
-        (fn [room]
-
-          (rooms/cooldown room "looping"
-            (fn [ok?]
-              (if ok?
-                (rooms/start-looping room
-                  (fn []
-                    (.emit (.to io room) "set-loop" true))))))))))
+      (rooms/get-user-id-from-socket (.-id socket)
+        (fn [user-id]
+          (rooms/get-room-from-user-id user-id
+            (fn [room]
+              (rooms/cooldown room "looping"
+                (fn [ok?]
+                  (if ok?
+                    (rooms/start-looping room
+                      (fn []
+                        (.emit (.to io room) "set-loop" true))))))))))))

   (.on socket "stop-looping"
     (fn []
       (println "Received stop-looping signal from" (.-id socket))
-      (rooms/get-room-from-user-id (.-id socket)
-        (fn [room]
-          (rooms/cooldown room "looping"
-            (fn [ok?]
-              (if ok?
-                (rooms/stop-looping room
-                  (fn []
-                    (.emit (.to io room) "set-loop" false))))))))))
+      (rooms/get-user-id-from-socket (.-id socket)
+        (fn [user-id]
+          (rooms/get-room-from-user-id user-id
+            (fn [room]
+              (rooms/cooldown room "looping"
+                (fn [ok?]
+                  (if ok?
+                    (rooms/stop-looping room
+                      (fn []
+                        (.emit (.to io room) "set-loop" false))))))))))))

   (.on socket "mute-user"
     (fn []
       (println "Socket id " (.-id socket) " is muted!")
-      (rooms/mute-user (.-id socket)
-        (fn []
-          (rooms/get-room-from-user-id (.-id socket)
+      (rooms/get-user-id-from-socket (.-id socket)
+        (fn [user-id]
+          (rooms/mute-user user-id
+            (fn []
+              (rooms/get-room-from-user-id (.-id socket)
+                (fn [room-id]
+                  (.emit (.to io room-id) "user-muted" (.-id socket))))))))))
+
+  (.on socket "unmute-user"
+    (fn []
+      (println "Socket id " (.-id socket) " is unmuted!")
+      (rooms/get-user-id-from-socket (.-id socket)
+        (fn [user-id]
+          (rooms/unmute-user user-id
+            (fn []
+              (rooms/get-room-from-user-id (.-id socket)
+                (fn [room-id]
+                  (.emit (.to io room-id) "user-unmuted" (.-id socket))))))))))
+
+
+  (.on socket "track-complete"
+    (fn []
+      (println "Received track-complete signal from " (.-id socket))
+      (rooms/get-user-id-from-socket (.-id socket)
+        (fn [user-id]
+          (rooms/get-room-from-user-id user-id
+            (fn [room]
+              (rooms/client-sync room "track-complete" (.-id socket)
+                (fn [synced?]
+                  (if synced?
+                    (rooms/clear-track-complete room
+                      (fn []
+                        (rooms/is-looping? room
+                          (fn [looping?]
+                            (if looping?
+                              (rooms/set-current-track-position room 0
+                                (fn []
+                                  (.emit (.to io room) "position-change" 0)))
+                              (rooms/next-track room
+                                (fn [track-id sound-id]
+                                  (rooms/track-complete room
+                                    (fn []
+                                      (if-not (nil? track-id)
+                                        (rooms/clear-ready-to-start room
+                                          (fn []
+                                            (rooms/set-waiting-to-start-flag room
+                                              (fn []
+                                                (.emit (.to io room)
+                                                       "track-change"
+                                                       track-id
+                                                       sound-id))))))))))))))))))))))))
+
+  (.on socket "track-deleted"
+    (fn []
+      (println "Received track-delete signal from" (.-id socket))
+
+      (rooms/get-user-id-from-socket (.-id socket)
+        (fn [user-id]
+          (rooms/get-room-from-user-id user-id
+            (fn [room]
+              (rooms/client-sync room "track-deleted" (.-id socket)
+                (fn [synced?]
+                  (if synced?
+                    (rooms/track-complete room
+                      (fn []
+                        (rooms/delete-client-sync room "track-deleted"
+                          (fn []
+                            (rooms/clear-ready-to-start room
+                              (fn []
+                                (rooms/clear-track-complete room
+                                  (fn []
+                                    (rooms/next-track room
+                                      (fn [track-id sound-id]
+                                        (println "next-track returned track-id:" track-id)
+                                        (if-not (nil? track-id)
+                                          (.emit (.to io room)
+                                                 "track-change"
+                                                 track-id
+                                                 sound-id)))))))))))))))))))))
+
+
+  (.on socket "clear-songs"
+    (fn []
+      (println "Received clear-songs signal from" (.-id socket))
+
+      (rooms/get-user-id-from-socket (.-id socket)
+        (fn [user-id]
+          (rooms/get-room-from-user-id user-id
             (fn [room-id]
-              (.emit (.to io room-id) "user-muted" (.-id socket))))))))
-
-  (.on socket "unmute-user"
-    (fn []
-      (println "Socket id " (.-id socket) " is unmuted!")
-      (rooms/unmute-user (.-id socket)
-        (fn []
-          (rooms/get-room-from-user-id (.-id socket)
-            (fn [room-id]
-              (.emit (.to io room-id) "user-unmuted" (.-id socket))))))))
-
-
-  (.on socket "track-complete"
-    (fn []
-      (println "Received track-complete signal from " (.-id socket))
-      (rooms/get-room-from-user-id (.-id socket)
-        (fn [room]
-          (rooms/client-sync room "track-complete" (.-id socket)
-            (fn [synced?]
-              (if synced?
-                (rooms/clear-track-complete room
-                  (fn []
-                    (rooms/is-looping? room
-                      (fn [looping?]
-                        (if looping?
-                          (rooms/set-current-track-position room 0
-                            (fn []
-                              (.emit (.to io room) "position-change" 0)))
-                          (rooms/next-track room
-                            (fn [track-id sound-id]
-                              (rooms/track-complete room
-                                (fn []
-                                  (if-not (nil? track-id)
-                                    (rooms/clear-ready-to-start room
-                                      (fn []
-                                        (rooms/set-waiting-to-start-flag room
-                                          (fn []
-                                            (.emit (.to io room)
-                                                   "track-change"
-                                                   track-id
-                                                   sound-id))))))))))))))))))))))
-
-  (.on socket "track-deleted"
-    (fn []
-      (println "Received track-delete signal from" (.-id socket))
-      (rooms/get-room-from-user-id (.-id socket)
-        (fn [room]
-          (rooms/client-sync room "track-deleted" (.-id socket)
-            (fn [synced?]
-              (if synced?
-                (rooms/track-complete room
-                  (fn []
-                    (rooms/delete-client-sync room "track-deleted"
-                      (fn []
-                        (rooms/clear-ready-to-start room
-                          (fn []
-                            (rooms/clear-track-complete room
-                              (fn []
-                                (rooms/next-track room
-                                  (fn [track-id sound-id]
-                                    (println "next-track returned track-id:" track-id)
-                                    (if-not (nil? track-id)
-                                      (.emit (.to io room)
-                                             "track-change"
-                                             track-id
-                                             sound-id)))))))))))))))))))
-
-
-  (.on socket "clear-songs"
-    (fn []
-      (println "Received clear-songs signal from" (.-id socket))
-      (rooms/get-room-from-user-id (.-id socket)
-        (fn [room-id]
-          (rooms/clear-songs room-id
-            (fn []
-              (.emit (.to io room-id) "clear-songs")))))))
+              (rooms/clear-songs room-id
+                (fn []
+                  (.emit (.to io room-id) "clear-songs")))))))))

   (.on socket "delete-track"
     (fn [track-id]
       (println "Received delete-track signal for track-id" track-id
                "from" (.-id socket))
-      (rooms/get-room-from-user-id (.-id socket)
-        (fn [room-id]
-          (rooms/delete-track room-id track-id
-            (fn [next-track-num]
-              (rooms/set-delete-flag room-id
-                (fn []
-                  (if-not (nil? next-track-num)
-                    (.emit (.to io room-id) "delete-track" track-id))))))))))
+      (rooms/get-user-id-from-socket (.-id socket)
+        (fn [user-id]
+          (rooms/get-room-from-user-id user-id
+            (fn [room-id]
+              (rooms/delete-track room-id track-id
+                (fn [next-track-num]
+                  (rooms/set-delete-flag room-id
+                    (fn []
+                      (if-not (nil? next-track-num)
+                        (.emit (.to io room-id) "delete-track" track-id))))))))))))

   (.on socket "track-order-change"
     (fn [track-id destination-track-num]
       (println "Track order change of track-id:" track-id
                "to track-num:" destination-track-num)
-
-      (rooms/get-room-from-user-id (.-id socket)
-        (fn [room-id]
-          (rooms/cooldown room-id "track-order-change"
-            (fn [ok?]
-              (if ok?
-                (rooms/change-track-order room-id track-id destination-track-num
-                  (fn [new-track-order]
-                    (.emit (.to io room-id) "track-order-change" new-track-order))))))))))
+      (rooms/get-user-id-from-socket (.-id socket)
+        (fn [user-id]
+          (rooms/get-room-from-user-id user-id
+            (fn [room-id]
+              (rooms/cooldown room-id "track-order-change"
+                (fn [ok?]
+                  (if ok?
+                    (rooms/change-track-order room-id track-id destination-track-num
+                      (fn [new-track-order]
+                        (.emit (.to io room-id) "track-order-change" new-track-order))))))))))))

   (.on socket "change-track"
     (fn [track-num sound-id]
       (println "Received change-track signal to track-num" track-num
                "with sound-id" sound-id
                "from" (.-id socket))
-      (rooms/get-room-from-user-id (.-id socket)
-        (fn [room]
-          (rooms/cooldown room "change-track"
-            (fn [ok?]
-              (if ok?
-                (change-track room track-num sound-id))))))))
+      (rooms/get-user-id-from-socket (.-id socket)
+        (fn [user-id]
+          (rooms/get-room-from-user-id user-id
+            (fn [room]
+              (rooms/cooldown room "change-track"
+                (fn [ok?]
+                  (if ok?
+                    (change-track room track-num sound-id))))))))))

   (.on socket "lastfm-auth"
     (fn [token]
-      (lastfm/authenticate! (.-id socket) token
-        (fn [status username]
-          (if (= :success status)
-            (.emit socket "lastfm-auth" "success" username)
-            (.emit socket "lastfm-auth" "failure" nil))))))
+      (rooms/get-user-id-from-socket (.-id socket)
+        (fn [user-id]
+          (lastfm/authenticate! user-id token
+            (fn [status username]
+              (if (= :success status)
+                (.emit socket "lastfm-auth" "success" username)
+                (.emit socket "lastfm-auth" "failure" nil))))))))

   (.on socket "lastfm-scrobble"
     (fn [artist track]
-      (lastfm/scrobble! (.-id socket) artist track)))
+      (rooms/get-user-id-from-socket (.-id socket)
+        (fn [user-id]
+          (lastfm/scrobble! user-id artist track)))))

   (.on socket "change-upload-slots"
     (fn [new-upload-slots]


Added the FN to show the Direction and Distance given the start point

--- src/gps/data.clj
+++ src/gps/data.clj
@@ -1,6 +1,7 @@
 (ns gps.data
   (:require [datomic.api :as d]
-            [geohash.core :as geohash]))
+            [geohash.core :as geohash]
+            [gps.core :as gps]))

 (def uri "datomic:mem://gps")

@@ -81,7 +82,23 @@

 (save-deal 53.98193516 -6.41601562 "Dundalk shop" "Free coffee")

-(defn print-entity[entity]
+;; Calculate heading and distance given two GPS co-ordinates
+(defn heading-distance[gps-start gps-end]
+  (let [lat-start (:lat gps-start)
+        lon-start (:lon gps-start)
+        lat-end (:lat gps-end)
+        lon-end (:lon gps-end)
+        NS (if (< lat-start lat-end) :north :south)
+        EW (if (< lon-start lon-end) :east :west)
+        ]
+    (vector NS EW (gps/haversine gps-start gps-end))))
+
+(heading-distance {:lat 56.99134711 :lon -6.40017986}
+                  {:lat 54.99031266 :lon -4.40017986})
+
+
+
+(defn print-entity[start-lat start-lon entity]
   (let [location-ent (d/entity (d/db conn) (first entity))
         vendor-ent (first (:location/vendor location-ent))
         geocode (:location/geocode location-ent)
@@ -95,16 +112,18 @@
     (println (str "lon:     " lon))
     (println (str "Vendor:  " vendor-name))
     (println (str "Deal:    " vendor-deal))
+    (println  (heading-distance {:lat start-lat :lon start-lon}
+                                {:lat lat :lon lon}))
     (println)))

-(defn show-all-deals[]
+(defn show-all-deals[start-lat start-lon]
   (let [results (d/q '[:find ?e :where [?e :location/geocode]] (d/db conn))]
     (doseq[r results]
-      (print-entity r))))
+      (print-entity start-lat start-lon r))))

-(show-all-deals)
+(show-all-deals 53.99134711 -6.40017986)

 (defn get-nearest-deals
   "Get deals within a certain radius"
@@ -123,7 +142,7 @@
     (println end)
     (println (count res))
     (doseq[r res]
-      (print-entity r))))
+      (print-entity lat lon r))))

 ;(get-nearest-deals 53.98193516 -6.41601562 8)
 (get-nearest-deals 53.99134711 -6.39824867 6)
@@ -135,15 +154,10 @@
 (save-deal 53.99086773 -6.3988924  "End of grass"  "Deal 2")
 (save-deal 53.99031266 -6.40017986 "Junction DublinRD" "Deal 3")
 (save-deal 53.98908894 -6.39942884 "Hospital Junction" "Deal4")
+(save-deal 53.99369399 -6.39780177 "Tom Bellew Avenue" "Small Shop")
+(save-deal 53.99369399 -6.39516288 "Bellew Ave" "At round about")

-;; Calculate heading and distance given two GPS co-ordinates
-(defn heading-distance[gps-start gps-end]
-  (let [lat-start (:lat gps-start)
-        lon-start (:lon gps-end)
-        lat-end (:lat gps-end)
-        lon-end (:lon gps-end)
-        ]
-    ))
+

 (d/delete-database uri)