Eval in space

Eval in space

--- src/fugue/space.cljs
+++ src/fugue/space.cljs
@@ -1,12 +1,16 @@
 (ns fugue.space
-  (:require [clojure.zip :as zip]
+  (:require-macros [fugue.env :refer [analyzer-state]])
+  (:require [cljs.js]
+            [fugue.api]
+            [clojure.zip :as zip]
             [reagent.core :as r]))

-(def init-state
-  {:boxes [1 [2 3]]
+(def init-state-m
+  {:boxes '(1 (2 3))
    :active-box 1
    :next-id 4
-   :files {1 "foo" 2 "bar" 3 "biz"}})
+   :result nil
+   :files {1 "(+ 82 34)" 2 "bar" 3 "biz"}})

 (defn in-row? [loc]
   (-> (zip/path loc)
@@ -14,10 +18,13 @@
       (mod 2)
       (= 1)))

-(defn insert [boxes box new-box direction]
+(defn insert [boxes direction box new-box]
   (loop [loc (zip/seq-zip boxes)]
+    (print (zip/node loc))
     (if (zip/end? loc)
-      (zip/root loc)
+      (do
+        (print "end")
+        (zip/root loc))
       (if (= box (zip/node loc))
         (zip/root
           (case direction
@@ -27,26 +34,52 @@
             :left (if (in-row? loc)
                     (zip/insert-left loc new-box)
                     (zip/edit loc #(list new-box %)))
-            :down (if (in-row? loc)
-                    (zip/edit loc #(list % new-box))
-                    (zip/insert-right loc new-box))
-            :up (if (in-row? loc)
-                  (zip/edit loc #(list new-box %))
-                  (zip/insert-left loc new-box))))
+            :below (if (in-row? loc)
+                     (zip/edit loc #(list % new-box))
+                     (zip/insert-right loc new-box))
+            :above (if (in-row? loc)
+                     (zip/edit loc #(list new-box %))
+                     (zip/insert-left loc new-box))))
         (recur (zip/next loc))))))

-(defn boxes [node is-row]
+
+(defn init-state [state]
+  (assoc-in state [:cljs.analyzer/namespaces 'cljs.user]
+            (analyzer-state 'fugue.api)))
+
+(def state (cljs.js/empty-state init-state))
+
+(def eval-settings
+  {:eval cljs.js/js-eval
+   :context :statement})
+
+(defn eval-str [source load-fn cb]
+  (cljs.js/eval-str state source nil (assoc eval-settings :load load-fn) cb))
+
+(defn do-eval [state cb]
+  (let [text (get-in state [:files (:active-box state)])
+        load-fn (fn [m cb]
+                  (if-let [source (get-in state [:files (str (:name m))])]
+                    (cb {:lang :clj :source source})
+                    (cb nil)))]
+    (eval-str text load-fn cb)))
+
+(defn boxes [files box is-row]
   [:div {:style {:display "flex"
                  :flex-grow 0
                  :flex-flow (if is-row "row" "column")}}
-   (if (seqable? node)
-     (map #(boxes % (not is-row)) node)
-     [:p (str node)])])
+   (if (seqable? box)
+     (map #(boxes files % (not is-row)) box)
+     [:p (str (get files box))])])

 (defn app []
-  (let [state (r/atom init-state)]
+  (let [state (r/atom init-state-m)]
     (fn []
-      (boxes (:boxes @state) true))))
+      [:div
+       [:button {:on-click #(do-eval @state (partial swap! state update :boxes insert :below (:active-box @state)))}
+        "Click me"]
+       [:p (str @state)]
+       (boxes (:files @state) (:boxes @state) true)])))


OO: Fix formatting

OO: Fix formatting

--- src/hatti/views/table.cljs
+++ src/hatti/views/table.cljs
@@ -305,8 +305,7 @@

 (defn get-table-view-height
   []
-  (let [body (-> "body"
-                 js/document.querySelector)
+  (let [body (js/document.querySelector "body")
         body-height (.-clientHeight body)
         body-width (.-clientWidth body)
         main-navigation-height (-> "#dataview-menu"


* src/clj/cljs/core.clj: always emit arity for protocol impl

--- src/clj/cljs/core.clj
+++ src/clj/cljs/core.clj
@@ -419,9 +419,7 @@
         method (fn [[fname & sigs]]
                  (let [sigs (take-while vector? sigs)
                        slot (symbol (str prefix (name fname)))
-                       arity-name-fn (if (clojure.core/> (count sigs) 1)
-                                       (fn [sym sig] (symbol (str sym "__" (count sig))))
-                                       (fn [sym sig] sym))]
+                       arity-name-fn (fn [sym sig] (symbol (str sym "__" (count sig))))]
                    `(defn ~fname ~@(map (fn [sig]
                                           (expand-sig fname
                                                       (arity-name-fn slot sig)


cleaned up a bit

cleaned up a bit

--- src/grid/render.cljs
+++ src/grid/render.cljs
@@ -18,20 +18,23 @@
                                       :onClick (:onClick h)} (:title h)))
                        header))))

+(defn render-rows [rows header-meta]
+  (map (fn [row]
+         (Row row header-meta)) rows))
+
 (defn render-body [model]
   (let [header-meta (get-in model [:meta :header])]
     [(apply d/tbody {}
-             (map (fn [row]
-                    (Row row header-meta)) (:data model)))]))
+             (render-rows (:data model) header-meta))]))

 (defn render-grouped-body [model f]
   (let [grouped (group-by f (:data model))
         header-meta (get-in model [:meta :header])]
-    (map (fn [[k v]]
+    (map (fn [[k rows]]
             (apply d/tbody {}
                    (cons (d/tr {:className "group-header"}
-                               (d/td {:colSpan (count header-meta)} (str k " (" (count v) ")") ))
-                         (map (fn [r] (Row r header-meta)) v)))) grouped)))
+                               (d/td {:colSpan (count header-meta)} (str k " (" (count rows) ")") ))
+                         (render-rows rows header-meta)))) grouped)))

 (q/defcomponent Grid [model]
   (let [header-meta (get-in model [:meta :header])


Document ns-stringifier

Document ns-stringifier

--- src/grimoire/doc.clj
+++ src/grimoire/doc.clj
@@ -93,7 +93,9 @@
             (str text)))))))

 (defn ns-stringifier
-
+  "Function something (either a Namespace instance, a string or a symbol) to a
+  string naming the input. Intended for use in computing the logical \"name\" of
+  the :ns key which could have any of these values."
   [x]
   (cond (instance? clojure.lang.Namespace x)
         ,,(name (ns-name x))


add test for past perfect of "be born"

add test for past perfect of "be born"

--- test/babel/test/en.cljc
+++ test/babel/test/en.cljc
@@ -503,6 +503,17 @@
     (is (not (nil? result)))
     (is (= "I had talked" (morph result)))))

+(deftest past-perfect-born
+  (let [result (generate {:root {:english {:english "be born"}}
+                          :modified false
+                          :synsem {:cat :verb
+                                   :subcat ()
+                                   :sem {:aspect :perfect
+                                         :obj :unspec
+                                         :subj {:pred :I}
+                                         :tense :past}}})]
+    (is (not (nil? result)))
+    (is (= "I had been born" (morph result)))))


Fixing schema description

Fixing schema description

--- src/helda/schema.clj
+++ src/helda/schema.clj
@@ -25,7 +25,7 @@
     (s/optional-key :description) s/Str

     :extends [s/Keyword]
-    :fields {s/Keyword s/Str} ;{field schema}
+    :fields {s/Keyword s/Str} ;{field description or type at least}
     :actions {s/Keyword Action}
   })


Issue #61 (4) Examine result file of `create-mpileup` based on (2)

--- test/cljam/t_pileup.clj
+++ test/cljam/t_pileup.clj
@@ -215,5 +215,4 @@
                       :after (clean-cache!)}
     (let [out-file (str temp-dir "/test.pileup")]
       (is (not-throw? (plp/create-mpileup test-sorted-bam-file out-file)))
-      ;; TODO: check out-file
-      )))
+      (is (same-file? out-file test-pileup-file)))))


enabled private variables to be set

enabled private variables to be set

--- test/iroh/test_core.clj
+++ test/iroh/test_core.clj
@@ -3,6 +3,8 @@
   (:require [iroh.core :refer :all]))

-(.? java.lang.Class :method :private)
+(try ((first (.? java.lang.Class :constructor :private)))
+     )
+(>pst)

 (.? java.lang.Object :method :private)


fixing oracle endpoint to lov

fixing oracle endpoint to lov

--- server/src/server/system.clj
+++ server/src/server/system.clj
@@ -39,7 +39,7 @@
                 :join true
                 :auto-reload? true})

-(def oracle-sparql-endpoint "http://dbpedia.org/sparql")
+(def oracle-sparql-endpoint "http://lov.okfn.org/endpoint/lov_aggregator")

 (def sparqlify-opts {:host "http://localhost"
                      :port 7531})


fix repl prompt

fix repl prompt


Fix typo

Fix typo

--- src/transit/write.clj
+++ src/transit/write.clj
@@ -441,7 +441,7 @@
   (rep [inst] (.getTime inst))
   (str-rep [inst]
     (let [format (.get thread-local-utc-date-format)]
-      (.format foramt inst)))
+      (.format format inst)))

   java.util.UUID
   (tag [uuid] "u")


fill bug fixed

fill bug fixed

--- src/webdriver/dsl.clj
+++ src/webdriver/dsl.clj
@@ -28,9 +28,6 @@
 (defn find-element-from-element [element term]
   (api/find-element-from-element *session* element (make-selector term)))

-(defn element-value [element text]
-  (api/element-value *session* element text))
-
 (defmacro with-element [term & body]
   `(if (bound? #'*element*)
      (with-bindings {#'*element* (find-element-from-element *element* ~term)}
@@ -48,10 +45,11 @@
   (api/get-url *session*))

 (defn fill
-  ([text] (fill *element* text))
+  ([text]
+   (api/element-value *session* *element* text))
   ([term text]
    (let [element (api/find-element *session* (make-selector term))]
-     (element-value element text))))
+     (api/element-value *session* element text))))

 (defn click
   ([]
@@ -77,7 +75,8 @@
     (go-url "http://ya.ru")
     (wait 7)
     (with-xpath
-      (fill "//input[@id=\"text\"]" "test"))
+      (with-element "//input[@id=\"text\"]"
+        (fill "test")))
     (wait 5)
     (is 1)))


Fix eating from ground bug

Fix eating from ground bug

--- src/robinson/update.clj
+++ src/robinson/update.clj
@@ -600,7 +600,7 @@
         (fn [hunger]
           (let [new-hunger (- hunger (item :hunger))]
             (max 0 new-hunger))))
-      (arg-if-> [state] (contains? (map :hotkey (player-inventory state)) keyin)
+      (arg-if-> [state] (contains? (set (map :hotkey (player-inventory state))) keyin)
         ;; remove the item from inventory
         (dec-item-count (get item :id))
         ;; remove the item from the current-cell


Differentiate between a slow and a fast queue

--- worker/src/worker/main.clj
+++ worker/src/worker/main.clj
@@ -9,24 +9,47 @@

 (defn message-handler
   [channel {:keys [content-type delivery-tag type] :as meta} ^bytes payload]
-  (println (String. payload "UTF-8"))
+  (println (str type (String. payload "UTF-8")))
   (lb/ack channel delivery-tag))

 (defn start-consumer
-  [connection channel queue-name]
-  (.start (Thread. #(lc/subscribe channel queue-name message-handler :auto-ack false))))
+  [connection channel queue-name handler-fn]
+  (.start (Thread. #(lc/subscribe channel queue-name handler-fn :auto-ack false))))

 (defn -main
     [& args]

       (let [connection (rmq/connect)
-          channel (lch/open connection)
-          queue-name "geocommit.jobs"]
-        (println (str "connected " (.getChannelNumber channel)))
-        (lq/declare channel queue-name :durable true :exclusive false :auto-delete false)
+          channel-fast (lch/open connection)
+          channel-slow (lch/open connection)]
+        (println (str "connected " (.getChannelNumber channel-fast)))
+        (lq/declare channel-fast "geocommit.job.fast" :durable true :exclusive false :auto-delete false)
+        (lq/declare channel-fast "geocommit.job.slow" :durable true :exclusive false :auto-delete false)
         (if (= (first args) "fill")
           (do
-            (lb/publish channel default-exchange-name queue-name "{\"url\": \"github.com/foo/bar\"}" :content-type "application/json" :type "geocommit.job.init")
-            (rmq/close channel)
+            (lb/publish
+              channel-fast
+              default-exchange-name
+              "geocommit.job.fast"
+              "{\"url\": \"github.com/already/exists\"}"
+              :content-type "application/json"
+              :type "geocommit.job.update")
+            (lb/publish
+              channel-slow
+              default-exchange-name
+              "geocommit.job.slow"
+              "{\"url\": \"github.com/new/repo\"}"
+              :content-type "application/json"
+              :type "geocommit.job.init")
+            (lb/publish
+              channel-fast
+              default-exchange-name
+              "geocommit.job.fast" "{\"url\": \"github.com/new/repo\"}"
+              :content-type "application/json"
+              :type "geocommit.job.update")
+            (rmq/close channel-fast)
+            (rmq/close channel-slow)
             (rmq/close connection))
-          (start-consumer connection channel queue-name))))
+          (do
+            (start-consumer connection channel-fast "geocommit.job.fast" message-handler)
+            (start-consumer connection channel-slow "geocommit.job.slow" message-handler)))))


Remove obsolete datomic test

Remove obsolete datomic test

--- test/clj/potoo/datomic_test.clj
+++ test/clj/potoo/datomic_test.clj
@@ -1,40 +0,0 @@
-(ns potoo.datomic-test
-  (:require [clojure.test :refer :all]
-            [potoo.datomic :refer :all]
-            [datomic.api :as d]
-            [clj-time.core :as t]
-            [clj-time.coerce :as c]))
-
-(defn create-test-db []
-  (let [uri "datomic:mem://localhost:4334/test"
-        _ (d/delete-database uri)
-        datomic (new-empty-database uri)]
-    (-> (.start datomic) :db-conn)))
-
-(deftest user-tests
-  (testing "creating a user"
-    (let [conn (create-test-db)
-          _    (create-user conn "Morty" "Morty")]
-      (is (find-user-id conn "Morty"))
-      (is (not (find-user-id conn "Rick"))))))
-
-(deftest db-ops-test
-  (testing "creating potoos"
-    (let [conn (create-test-db)
-          date (c/to-date (t/date-time 1986 10 14 4 3 27 456))
-          _    (create-user conn "Morty" "Morty")
-          _ (create-potoo conn "Foo Bar" "Morty" date)]
-      (is (= #{["Foo Bar" "Morty" #inst "1986-10-14T04:03:27.456-00:00"]}
-             (find-potoos conn)))))
-  (testing "finding potoos for user"
-    (let [conn (create-test-db)
-          date (c/to-date (t/date-time 1986 10 14 4 3 27 456))
-          _ (create-user conn "Morty" "")
-          _ (create-user conn "Rick" "")
-          _ (create-potoo conn "Foo" "Rick" date)
-          _ (create-potoo conn "Bar" "Rick" date)
-          _ (create-potoo conn "Baz" "Morty" date)]
-      (is (= #{["Foo" #inst "1986-10-14T04:03:27.456-00:00"]
-               ["Bar" #inst "1986-10-14T04:03:27.456-00:00"]}
-             (find-potoos-for-user conn "Rick"))))))
-


adding test for valued anagrams

adding test for valued anagrams

--- test/clj/scrabble/core_test.clj
+++ test/clj/scrabble/core_test.clj
@@ -72,6 +72,9 @@
     (t/are [ans word] (= (scrabble/anagrams word) ans)
       #{"ab" "cab" "cb" "ac" "ca" "abc" "ba" "bc"} "abc")))

+(t/deftest valued-anagrams-test
+  (t/testing "valued-anagrams"
+    (t/is (= (scrabble/valued-anagrams "211e1" "friend") '(["fined" 14] ["fired" 13] ["fried" 13] ["finer" 13] ["infer" 10] ["diner" 9])) )))

 (t/deftest matches-test
   (t/testing "get the best possible placements"


Added one test into test-calendar module

--- test/clouseau/test_calendar.clj
+++ test/clouseau/test_calendar.clj
@@ -111,3 +111,10 @@
             (is (=  (.get calendar (java.util.Calendar/DAY_OF_MONTH)) 1)))
 ))

+(deftest test-format-date-using-desired-format
+    "Check the function clouseau.calendar/format-date-using-desired-format"
+    (testing "the function clouseau.calendar/format-date-using-desired-format."
+        (let [calendar (get-calendar)]
+            (.set calendar 2000 01 01 10 20 30)
+)))
+


CMR-1843: Removed an unused namespace

CMR-1843: Removed an unused namespace

--- umm-spec-lib/src/cmr/umm_spec/test/umm_generators.clj
+++ umm-spec-lib/src/cmr/umm_spec/test/umm_generators.clj
@@ -4,7 +4,6 @@
             [cmr.common.test.test-check-ext :as ext-gen]
             [com.gfredericks.test.chuck.generators :as chgen]
             [cmr.umm-spec.json-schema :as js]
-            [cmr.common.util :as util]
             [cmr.umm-spec.record-generator :as record-gen]
             [clojure.set :as set]))


allow re-releasing to github

allow re-releasing to github

--- tasks.clj
+++ tasks.clj
@@ -70,7 +70,7 @@
       (spit (file "releases/stable") version))
     (binding [*root* "releases"]
       (git "add" jar "cake" "current" "stable")
-      (git "commit" "-m" (format "'release cake %s'" (:version *project*)))
+      (git "commit" "--allow-empty" "-m" (format "'release cake %s'" (:version *project*)))
       (git "push"))
     (when-not snapshot?
       (let [gem (str "cake-" version ".gem")]


Avoid overwriting core function

Avoid overwriting core function

--- integration-tests/apps/xa-old-jdbc/src/immutant/init.clj
+++ integration-tests/apps/xa-old-jdbc/src/immutant/init.clj
@@ -15,7 +15,7 @@
  (sql/with-connection spec
    (sql/insert-records :things {:name "success"})))

-(defn read []
+(defn read-names []
   (sql/with-connection spec
     (sql/with-query-results rows ["select name from things"]
       (:name (first rows)))))
@@ -24,5 +24,5 @@
 (defn handler [req]
   {:status 200
    :headers {"Content-Type" "text/plain"}
-   :body (pr-str (read))})
+   :body (pr-str (read-names))})
 (web/start "/thing" handler)


remove erroneous use of (fail-path)

remove erroneous use of (fail-path)

--- src/babel/lexiconfn.cljc
+++ src/babel/lexiconfn.cljc
@@ -514,7 +514,7 @@
    applications of all of the rules."
   (cond (= lexical-entry :fail) :fail
         (fail? lexical-entry)
-        (do (log/warn (str "lexical-entry " lexical-entry " was fail before applying any rules; fail path was: " (fail-path lexical-entry)))
+        (do (log/warn (str "lexical-entry " lexical-entry " was fail before applying any rules."))
             :fail)

         true


corrected error

corrected error

--- src/lobos/config.clj
+++ src/lobos/config.clj
@@ -2,7 +2,7 @@
   (:use lobos.connectivity)
   (:require [heroku-database-url-to-jdbc.core :as heroku-url]))

-(def db (or (heroku-url (System/getenv "DATABASE_URL"))
+(def db (or (heroku-url/jdbc-connection-string (System/getenv "DATABASE_URL"))
   {:classname "org.postgresql.Driver"
    :subprotocol "postgresql"
    :subname "//localhost:5432/barmap"}))


jme3 tutorial 4

jme3 tutorial 4

http://jmonkeyengine.org/wiki/doku.php/jme3:beginner:hello_main_event_loop

--- src/maqueta/core.clj
+++ src/maqueta/core.clj
@@ -1,59 +1,30 @@
 (ns maqueta.core
   (:use maqueta.assets)
-  (:import (com.jme3.app SimpleApplication)
-           (com.jme3.system AppSettings)
-           (com.jme3.font BitmapText)
-           (com.jme3.light DirectionalLight)
-           (com.jme3.math Vector3f)
-           (com.jme3.scene Geometry)
-           (com.jme3.scene.shape Box))
+  (:import com.jme3.app.SimpleApplication
+           com.jme3.system.AppSettings
+           com.jme3.math.ColorRGBA
+           com.jme3.math.Vector3f
+           com.jme3.scene.Geometry
+           com.jme3.scene.shape.Box)
   (:gen-class))

 (def ^:dynamic *app-settings* (doto (AppSettings. true)
                                 (.setFullscreen false)
                                 (.setTitle "maqueta")))

+(def player (let [box (Box. Vector3f/ZERO 1 1 1)
+                  geo (Geometry. "blue cube" box)
+                  mat (load-material "Common/MatDefs/Misc/Unshaded.j3md")]
+              (.setColor mat "Color" ColorRGBA/Blue)
+              (.setMaterial geo mat)
+              geo))
+
 (def app (proxy [SimpleApplication] []
            (simpleInitApp []
-             (let [teapot (load-model "Models/Teapot/Teapot.obj")
-                   mat-default (load-material "Common/MatDefs/Misc/ShowNormals.j3md")
-                   wall (Geometry. "Box" (Box. Vector3f/ZERO 2.5 2.5 1.0))
-                   mat-brick (load-material "Common/MatDefs/Misc/Unshaded.j3md")
-                   gui-font (load-font "Interface/Fonts/Default.fnt")
-                   hello-text (BitmapText. gui-font false)
-                   ninja (load-model "Models/Ninja/Ninja.mesh.xml")
-                   sun (DirectionalLight.)]
+             (.attachChild (.getRootNode this) player))

-               (.setMaterial teapot mat-default)
-
-               (.setTexture mat-brick "ColorMap"
-                            (load-texture "Textures/Terrain/BrickWall/BrickWall.jpg"))
-
-               (doto wall
-                 (.setMaterial mat-brick)
-                 (.setLocalTranslation 2.0 -2.5 0.0))
-
-               (doto hello-text
-                 (.setSize (.getRenderedSize (.getCharSet gui-font)))
-                 (.setText "Hello World")
-                 (.setLocalTranslation 300 (.getLineHeight hello-text) 0))
-
-               (doto (.getGuiNode this)
-                 .detachAllChildren
-                 (.attachChild hello-text))
-
-               (doto ninja
-                 (.scale 0.05 0.05 0.05)
-                 (.rotate 0.0 -3.0 0.0)
-                 (.setLocalTranslation 0.0 -5.0 -2.0))
-
-               (.setDirection sun (Vector3f. -0.1 -0.7 -1.0))
-
-               (doto (.getRootNode this)
-                 (.attachChild teapot)
-                 (.attachChild wall)
-                 (.attachChild ninja)
-                 (.addLight sun))))))
+           (simpleUpdate [tpf]
+             (.rotate player 0 (* 2 tpf) 0))))

 (defn -main [& args]
   (doto app


Config parameter for repositories.ini in config module

--- src/arachnida/config.clj
+++ src/arachnida/config.clj
@@ -2,8 +2,11 @@

 (require '[clojure-ini.core :as clojure-ini])

+(def repositories-ini-file
+    "config/repositories.ini")
+
 (defn load-repositories
     "Load repositories from the provided INI file."
-    [ini-file-name]
-    (clojure-ini/read-ini ini-file-name :keywordize? true))
+    []
+    (clojure-ini/read-ini repositories-ini-file :keywordize? true))


Common HTTP handler

Common HTTP handler

--- src/arachnida/server.clj
+++ src/arachnida/server.clj
@@ -10,6 +10,7 @@

 (require '[arachnida.db-interface :as db-interface])
 (require '[arachnida.calendar     :as calendar])
+(require '[arachnida.html-renderer :as html-renderer])

 (defn read-stat-per-weeks
     [first-day last-day]
@@ -243,7 +244,7 @@
            :stat-for-all stat-for-all
            :stat-for-author stat-for-author})))

-(defn handler
+(defn handler-
     [request]
     (let [params          (:params  request)
           cookies         (:cookies request)
@@ -266,10 +267,53 @@
               (println "Outgoing cookies: " (get response :cookies))
               response)))

+(defn continue-processing
+    [html-output]
+    (-> (http-response/response html-output)
+        (http-response/content-type "text/html; charset=utf-8")))
+
+(defn perform-index-page
+    [request]
+    (let [products (db-interface/read-product-names)
+          authors  (db-interface/read-author-names)]
+         (-> (html-renderer/render-index-page products authors)
+             continue-processing)))
+
+(defn perform-author-page
+    [request]
+    (let [params (:params request)
+          author-name (get params "name")
+          statistic   (db-interface/read-statistic-for-author author-name)]
+(println author-name)
+(println statistic)
+        (-> (html-renderer/render-author-page author-name statistic)
+            continue-processing)))
+
+(defn perform-product-page
+    [request]
+    (let [params (:params request)
+          product-name (get params "name")
+          product-id   (db-interface/read-product-id product-name)
+          repositories (db-interface/read-repo-list product-id)]
+        (-> (html-renderer/render-product-page product-name repositories)
+            continue-processing)))
+
+(defn handler
+    "Handler that is called by Ring for all requests received from user(s)."
+    [request]
+    (println "request URI: " (request :uri))
+    (let [uri (request :uri)]
+        (condp = uri
+            "/"            (perform-index-page request)
+            "/author"      (perform-author-page request)
+            "/product"     (perform-product-page request)
+            "/favicon.ico" nil
+        )))
+
 (def app
     (-> handler
         cookies/wrap-cookies
-        http-params/wrap-params))
+        (http-params/wrap-params :encoding "UTF-8")))

 (defn start-server
     []


Grammar

Grammar

--- src/buddy/core/nonce.clj
+++ src/buddy/core/nonce.clj
@@ -27,7 +27,7 @@
 (defn random-bytes
   "Generate a byte array of scpecified length with random
   bytes taken from secure random number generator.
-  This method should be used for generate a random
+  This method should be used to generate a random
   iv/salt or arbitrary length."
   ([^long numbytes]
    (random-bytes numbytes (SecureRandom.)))


add fns for other request methods

add fns for other request methods

--- src/myshelf/core.clj
+++ src/myshelf/core.clj
@@ -54,6 +54,45 @@
         (http/get url
                   {:query-params (merge credentials
                                         params)})))))
+
+(defn make-auth-request-POST
+  [consumer access-token url params]
+    (let [{:keys [oauth_token oauth_token_secret]} access-token
+        credentials (oauth/credentials consumer
+                                       oauth_token
+                                       oauth_token_secret
+                                       :POST
+                                       url
+                                       params)]
+      (http/post url
+                 {:query-params (merge credentials
+                                       params)})))
+
+(defn make-auth-request-PUT
+  [consumer access-token url params]
+    (let [{:keys [oauth_token oauth_token_secret]} access-token
+        credentials (oauth/credentials consumer
+                                       oauth_token
+                                       oauth_token_secret
+                                       :PUT
+                                       url
+                                       params)]
+      (http/put url
+                {:query-params (merge credentials
+                                      params)})))
+
+(defn make-auth-request-DELETE
+  [consumer access-token url params]
+    (let [{:keys [oauth_token oauth_token_secret]} access-token
+        credentials (oauth/credentials consumer
+                                       oauth_token
+                                       oauth_token_secret
+                                       :DELETE
+                                       url
+                                       params)]
+      (http/delete url
+                   {:query-params (merge credentials
+                                         params)})))

 (defn get-user-id
   "Fetch the Goodreads user id for the user that has granted access"


JavaScript files are a build artifact. Compile ClojureScript's cljs files as they are required.

--- src/clj/cljs/closure.clj
+++ src/clj/cljs/closure.clj
@@ -6,15 +6,11 @@
 ;   the terms of this license.
 ;   You must not remove this notice, or any other, from this software.

-(set! *warn-on-reflection* true)
-
 (ns cljs.closure
   "Compile ClojureScript to JavaScript with optimizations from Google
    Closure Compiler producing runnable JavaScript.

-   The classpath must contain compiler.jar and cljs/core.js as well as
-   any other compiled ClojureScript files that you will need, all of
-   which must be under cljs/.
+   The Closure Compiler (compiler.jar) must be on the classpath.

    Use the 'build' function for end-to-end compilation.

@@ -54,10 +50,6 @@
            com.google.javascript.jscomp.JSError
            com.google.javascript.jscomp.CommandLineRunner))

-;; The prefix under which compiled ClojureScript files may be found on
-;; the classpath.
-(def cljs-classpath-root "cljs/")
-
 (def name-chars (map char (concat (range 48 57) (range 65 90) (range 97 122))))

 (defn random-char []
@@ -243,16 +235,23 @@
         (doseq [form forms]
           (comp/emit (comp/analyze (empty-env) form)))))))

-(defn compile-file
-  "Compile a single cljs file in memory returning the JavaScript
-  source as a String. The IJavaScript protocol is extended to String so
-  this result is suitable to be passed to anything that expects to see
-  IJavaScript."
-  [^File file]
-  (compile-form-seq (comp/forms-seq file)))
-
 (defn output-directory [opts]
   (or (:output-dir opts) "out"))
+
+(defn compile-file
+  "Compile a single cljs file. If no output-file is specified, returns
+  a string of compiled JavaScript. With an output-file option, the
+  compiled JavaScript will written to this location and the function
+  returns a JavaScriptFile. In either case the return value satisfies
+  IJavaScript."
+  [^File file {:keys [output-file] :as opts}]
+  (if output-file
+    (let [out-file (io/file (output-directory opts) output-file)
+          ns-info (comp/compile-file file out-file)]
+      (javascript-file (to-url (:file ns-info))
+                       (:provides ns-info)
+                       (:requires ns-info)))
+    (compile-form-seq (comp/forms-seq file))))

 (defn compile-dir
   "Recursively compile all cljs files under the given source
@@ -264,13 +263,40 @@
            (javascript-file (to-url file) [ns] requires))
          compiled-info)))

+(defn mkdirs
+  "Create all parent directories the the passed file."
+  [f]
+  (.mkdirs (.getParentFile (.getCanonicalFile f))))
+
+(defn path-from-jarfile
+  "Given the URL of a file within a jar, return the path of the file
+  from the root of the jar."
+  [^URL url]
+  (last (string/split (.getFile url) #"\.jar!/")))
+
+(defn jar-file-to-disk
+  "Copy a file contained within a jar to disk. Return the created file."
+  [url out-dir]
+  (let [out-file (io/file out-dir (path-from-jarfile url))
+        content (slurp (io/reader url))]
+    (do (mkdirs out-file)
+        (spit out-file content)
+        out-file)))
+
 (extend-protocol Compilable

   File
   (-compile [this opts]
     (if (.isDirectory this)
       (compile-dir this opts)
-      (compile-file this)))
+      (compile-file this opts)))
+
+  URL
+  (-compile [this opts]
+    (case (.getProtocol this)
+      "file" (-compile (.getFile this) opts)
+      "jar" (let [out-file (jar-file-to-disk this (output-directory opts))]
+              (-compile out-file opts))))

   clojure.lang.PersistentList
   (-compile [this opts]
@@ -286,6 +312,8 @@
 (comment
   ;; compile a file in memory
   (-compile "samples/hello/src/hello/core.cljs" {})
+  ;; compile a file to disk - see file @ 'out/cljs/set.js'
+  (-compile (io/resource "cljs/set.cljs") {:output-file "cljs/set.js"})
   ;; compile a project
   (-compile (io/file "samples/hello/src") {})
   ;; compile a project with a custom output directory
@@ -302,7 +330,8 @@
 ;; ============
 ;;
 ;; Find all dependencies from files on the classpath. Eliminates the
-;; need for closurebuilder.
+;; need for closurebuilder. cljs dependencies will be compiled as
+;; needed.

 (defn build-index
   "Index a list of dependencies by namespace and file name. There can
@@ -328,24 +357,6 @@
         :when (.endsWith file ".js")]
     file))

-(defn all-cljs-js
-  "Return the list of all ClojureScript JavaScript files. First try to
-  get them from a directory on the classpath. Then, and only then,
-  look in jar files."
-  []
-  (letfn [(compiled-cljs? [d f] (and (.startsWith f (str (.getPath d) File/separator cljs-classpath-root))
-                                      (.endsWith f ".js")))
-          (remove-dot-prefix [s] (if (.startsWith s (str "." File/separator))
-                                   (.substring s (count (str "." File/separator)))
-                                   s))]
-    (let [compiled-cljs (for [dir (remove jar-file? (classpath))
-                              path (map #(.getPath %) (file-seq dir))
-                              :when (compiled-cljs? dir path)]
-                          (remove-dot-prefix path))]
-      (if (seq compiled-cljs)
-        compiled-cljs
-        (for [j (classpath-jarfiles) f (filenames-in-jar j) :when (.startsWith f cljs-classpath-root)] f)))))
-
 (defn dependency-index*
   "Create an index of dependencies by namespace and file name."
   []
@@ -355,7 +366,7 @@
                           line-seq
                           parse-js-ns
                           (assoc :file res)))]
-    (let [all-nodes (map graph-node (concat (all-goog-js) (all-cljs-js)))]
+    (let [all-nodes (map graph-node (all-goog-js))]
       (build-index all-nodes))))

 (def dependency-index (memoize dependency-index*))
@@ -364,7 +375,7 @@
   "Topologically sort a collection of dependencies."
   [coll]
   (let [state (build-index coll)]
-    (:order (reduce comp/dependency-order-visit (assoc state :order []) (keys state)))))
+    (distinct (:order (reduce comp/dependency-order-visit (assoc state :order []) (keys state))))))

 (defn dependencies
   "Given a sequence of Closure namespace strings, return the list of
@@ -377,32 +388,83 @@
       (if (seq requires)
         (let [node (get index (first requires))]
           (recur (concat (rest requires) (:requires node)) (conj deps node)))
-        (cons "goog/base.js" (map :file (distinct (dependency-order deps))))))))
+        (cons "goog/base.js" (map :file (dependency-order deps)))))))

 (comment
   ;; find dependencies
-  (dependencies ["cljs.core"])
   (dependencies ["goog.array"])
-  (dependencies ["cljs.core" "goog.array"])
+  )
+
+(def compiled-cljs (atom {}))
+
+(defn get-compiled-cljs
+  "If not already compiled, compile the given cljs namespace. Return
+  an IJavaScript for this file. Compiled output will be written to the
+  working directory."
+  [opts ns]
+  (let [file (str (string/replace ns "." "/") ".cljs")
+        js-file (comp/rename-to-js file)
+        out-file (io/file (output-directory opts) js-file)
+        javascript (if (and (.exists out-file) (get @compiled-cljs ns))
+                     (get @compiled-cljs ns)
+                     (-compile (io/resource file)
+                               (merge opts {:output-file js-file})))]
+    (do (swap! compiled-cljs (fn [old] (assoc old ns javascript)))
+        javascript)))
+
+(defn cljs-dependencies
+  "Given a list of all required namespaces, return a list of
+  IJavaScripts which are the cljs dependencies in dependency
+  order. The returned list will not only include the explicitly
+  required files but any transative depedencies as well. JavaScript
+  files will be compiled to the working directory if they do not
+  already exist."
+  [opts requires]
+  (letfn [(cljs-deps [coll] (filter #(.startsWith % "cljs.") coll))]
+    (loop [requires (cljs-deps requires)
+           deps {}]
+      (if (seq requires)
+        (let [next-ns (first requires)
+              js (get-compiled-cljs opts next-ns)
+              new-requires (remove #(or (contains? deps %)
+                                        (contains? (set requires) %))
+                                   (cljs-deps (-requires js)))]
+          (recur (concat (rest requires) new-requires) (assoc deps next-ns js)))
+        (dependency-order (vals deps))))))
+
+(comment
+  ;; only get cljs deps
+  (cljs-dependencies {} ["goog.string" "cljs.core"])
+  ;; get transative deps
+  (cljs-dependencies {} ["cljs.string"])
+  ;; don't get cljs.core twice
+  (cljs-dependencies {} ["cljs.core" "cljs.string"])
   )

 (defn add-dependencies
   "Given one or more IJavaScript objects in dependency order, produce
   a new sequence of IJavaScript objects which includes the input list
   plus all dependencies in dependency order."
-  [& inputs]
-  (let [required (dependencies (mapcat -requires inputs))
+  [opts & inputs]
+  (let [requires (mapcat -requires inputs)
+        required-cljs (cljs-dependencies opts requires)
+        required (dependencies (concat (mapcat -requires required-cljs) requires))
         index (dependency-index)]
     (concat (map #(javascript-file (io/resource %)
                                    (:provides (get index %))
                                    (:requires (get index %))) required)
+            required-cljs
             inputs)))

 (comment
   ;; add dependencies to literal js
-  (add-dependencies "goog.provide('test.app');\ngoog.require('goog.array');")
+  (add-dependencies {} "goog.provide('test.app');\ngoog.require('cljs.core');")
+  (add-dependencies {} "goog.provide('test.app');\ngoog.require('goog.array');")
+  (add-dependencies {} (str "goog.provide('test.app');\n"
+                            "goog.require('goog.array');\n"
+                            "goog.require('cljs.set');"))
   ;; add dependencies to a JavaScriptFile record
-  (add-dependencies (javascript-file (to-url "samples/hello/src/hello/core.cljs")
+  (add-dependencies {} (javascript-file (to-url "samples/hello/src/hello/core.cljs")
                                      ["hello.core"]
                                      ["goog.array"]))
   )
@@ -450,7 +512,7 @@

   ;; optimize a project
   (println (->> (-compile "samples/hello/src" {})
-                (apply add-dependencies)
+                (apply add-dependencies {})
                 (apply optimize {:optimizations :simple :flags #{:pretty-print}})))
   )

@@ -471,7 +533,7 @@
 ;; If inputs are optimized then the output string will be the complete
 ;; application with all dependencies included.
 ;;
-;; For unoptimized output the string will be a Closure deps file
+;; For unoptimized output, the string will be a Closure deps file
 ;; describing where the JavaScript files are on disk and their
 ;; dependencies. All JavaScript files will be located in the working
 ;; directory, including any dependencies from the Closure library.
@@ -513,13 +575,15 @@
   (apply str (interpose "\n" (map #(add-dep-string opts %) sources))))

 (comment
-  (path-relative-to (io/file "out/goog/base.js") {:url (io/resource "cljs/core.js")})
-  (add-dep-string {} {:url (io/resource "cljs/core.js") :requires ["goog.string"] :provides ["cljs.core"]})
-  (deps-file {} [{:url (io/resource "cljs/core.js") :requires ["goog.string"] :provides ["cljs.core"]}])
+  (path-relative-to (io/file "out/goog/base.js") {:url (io/resource "out/cljs/core.js")})
+  (add-dep-string {} {:url (io/resource "out/cljs/core.js") :requires ["goog.string"] :provides ["cljs.core"]})
+  (deps-file {} [{:url (io/resource "out/cljs/core.js") :requires ["goog.string"] :provides ["cljs.core"]}])
   )

 (defn output-one-file [{:keys [output-to]} js]
-  (if output-to (spit output-to js) js))
+  (cond (nil? output-to) js
+        (string? output-to) (spit output-to js)
+        :else (println js)))

 (defn output-deps-file [opts sources]
   (output-one-file opts (deps-file opts sources)))
@@ -530,7 +594,7 @@
   directory."
   [js]
   (if-let [url ^URL (-url js)]
-    (last (string/split (.getFile url) #"\.jar!/"))
+    (path-from-jarfile url)
     (str (random-string 5) ".js")))

 (defn write-javascript
@@ -541,7 +605,7 @@
         out-name (output-path js)
         out-file (io/file out-dir out-name)]
     (do (when-not (.exists out-file)
-          (do (.mkdirs (.getParentFile (.getCanonicalFile out-file)))
+          (do (mkdirs out-file)
               (spit out-file (-source js))))
         {:url (to-url out-file) :requires (-requires js) :provides (-provides js)
          :library (when (.startsWith out-name "goog/") :goog)})))
@@ -563,7 +627,7 @@
                   {:url (io/resource "goog/base.js")
                    :source (slurp (io/reader (io/resource "goog/base.js")))})
   ;; doesn't write a file that is already on disk
-  (source-on-disk {} {:url (io/resource "core.js")})
+  (source-on-disk {} {:url (io/resource "cljs/core.cljs")})
   )

 (defn output-unoptimized [opts & sources]
@@ -577,8 +641,9 @@
   ;; output unoptimized alone
   (output-unoptimized {} "goog.provide('test');\ngoog.require('cljs.core');\nalert('hello');\n")
   ;; output unoptimized with all dependencies
-  (apply output-unoptimized {} (add-dependencies
-                                "goog.provide('test');\ngoog.require('cljs.core');\nalert('hello');\n"))
+  (apply output-unoptimized {}
+         (add-dependencies {}
+                           "goog.provide('test');\ngoog.require('cljs.core');\nalert('hello');\n"))
   ;; output unoptimized and write deps file to 'out/test.js'
   (output-unoptimized {:output-to "out/test.js"}
                       "goog.provide('test');\ngoog.require('cljs.core');\nalert('hello');\n")
@@ -589,8 +654,8 @@
   [source opts]
   (let [compiled (-compile source opts)
         js-sources (if (coll? compiled)
-                     (apply add-dependencies compiled)
-                     (add-dependencies compiled))]
+                     (apply add-dependencies opts compiled)
+                     (add-dependencies opts compiled))]
     (if (:optimizations opts)
       (->> js-sources
            (apply optimize opts)
@@ -603,14 +668,15 @@
                     (defn ^{:export greet} greet [n] (str "Hola " n))
                     (defn ^:export sum [xs] 42)]
                   {:optimizations :simple :flags #{:pretty-print}}))
-
+
+
   ;; build a project with optimizations
   (build "samples/hello/src" {:optimizations :advanced})
   (build "samples/hello/src" {:optimizations :advanced :output-to "samples/hello/hello.js"})
   ;; open 'samples/hello/hello.html' to see the result in action
-
+
   ;; build a project without optimizations
-  (build "samples/hello/src" {:output-to "samples/hello/hello.js"})
+  (build "samples/hello/src" {:output-dir "samples/hello/out" :output-to "samples/hello/hello.js"})
   ;; open 'samples/hello/hello-dev.html' to see the result in action
   ;; notice how each script was loaded individually

@@ -618,6 +684,6 @@
   (build '[(ns hello.core)
            (defn ^{:export greet} greet [n] (str "Hola " n))
            (defn ^:export sum [xs] 42)]
-         {:output-to "samples/hello/hello.js"})
+         {:output-dir "samples/hello/out" :output-to "samples/hello/hello.js"})
   ;; open 'samples/hello/hello-dev.html' to see the result in action
   )


change `cljs.closure/watch` to always build at least once

--- src/clj/cljs/closure.clj
+++ src/clj/cljs/closure.clj
@@ -1128,10 +1128,19 @@
         env/*compiler*
         (env/default-compiler-env opts))))
   ([source opts compiler-env]
-    (let [path (Paths/get (.toURI (io/file source)))
-          fs   (.getFileSystem path)]
+    (let [path   (Paths/get (.toURI (io/file source)))
+          fs     (.getFileSystem path)
+          buildf (fn []
+                   (let [start (util/now)]
+                     (build source opts compiler-env)
+                     (println " done. Elapsed"
+                       (util/to-secs (unchecked-subtract (util/now) start)) "seconds")
+                     (flush)))]
       (try
-        (println "Watching path:" path)
+        (print "Building...")
+        (flush)
+        (buildf)
+        (println "Watching path:" source)
         (let [service  (.newWatchService fs)
               key nil]
           (. path
@@ -1142,15 +1151,11 @@
               (into-array [SensitivityWatchEventModifier/HIGH])))
           (loop [key nil]
             (when (or (nil? key) (. ^WatchKey key reset))
-              (let [key (. service take)
-                    start (util/now)]
+              (let [key (. service take)]
                 (when (seq (.pollEvents key))
                   (print "Change detected, recompiling...")
                   (flush)
-                  (build source opts compiler-env)
-                  (println " done. Elapsed"
-                    (util/to-secs (unchecked-subtract (util/now) start)) "seconds")
-                  (flush))
+                  (buildf))
                 (recur key)))))
         (catch Exception e
           (.printStackTrace e)


clicks on shapes

clicks on shapes

--- src/nonaga/draw.cljs
+++ src/nonaga/draw.cljs
@@ -4,35 +4,44 @@
   (:use-macros [dommy.macros :only [sel1]]))

 (defn hex->svg [[hex-x hex-y]]
-  (let [x (+ 20 (* 40 hex-x) (if (odd? hex-y) 20 0))
-        y (+ 20 (* 40 hex-y))]
-    [x y]))
+  (let [width  40
+        half (/ width 2)
+        svg-x (+ half (* width hex-x) (if (odd? hex-y) half 0))
+        svg-y (+ half (* width hex-y))]
+    [svg-x svg-y]))

-(defn ring [[x y :as coord]]
-  (circle {"cx"          x
-           "cy"          y
-           "r"           14
-           "fill"        "transparent"
-           "stroke"      "grey"
-           "strokeWidth" "7px"
-           "key"         (str "ring:" x "," y)}))
+(defn ring
+  ([coord] (ring nil coord))
+  ([click [x y :as coord]]
+   (circle {"cx"          x
+            "cy"          y
+            "r"           14
+            "fill"        "transparent"
+            "stroke"      "grey"
+            "strokeWidth" "7px"
+            "onClick"     click
+            "key"         (str "ring:" x "," y)})))

-(defn marble [color [x y :as coord]]
-  (circle {"cx"   x
-           "cy"   y
-           "r"    8
-           "fill" color
-           "key"  (str "marble" x "," y)}))
+(defn marble
+  ([color coord] (marble color nil coord))
+  ([color click [x y :as coord]]
+   (circle {"cx"      x
+            "cy"      y
+            "r"       8
+            "fill"    color
+            "onClick" click
+            "key"     (str "marble" x "," y)})))

 (defn draw [shape coords]
   (map (comp shape hex->svg) coords))

 (def board
   (create-class
-    "render" #(svg {}
-                   (draw ring (:rings n/initial-game))
-                   (draw (partial marble "red") (:whites n/initial-game))
-                   (draw (partial marble "blue") (:blacks n/initial-game)))))
+    "render" (fn []
+               (svg {}
+                    (draw ring (:rings n/initial-game))
+                    (draw (partial marble "red") (:whites n/initial-game))
+                    (draw (partial marble "blue") (:blacks n/initial-game))))))

 (defn start []
   (render-component (board) (sel1 :#content)))


put back the environ port

put back the environ port

--- src/clj/scrabble/api.clj
+++ src/clj/scrabble/api.clj
@@ -6,6 +6,7 @@
             [clojure.data.json :as json]
             [compojure.handler :refer [site]]
             [scrabble.core :as scrabble]
+            [environ.core :as env]
             [ring.adapter.jetty :as jetty]
             [ring.middleware.json :refer [wrap-json-response]]
             [ring.middleware.defaults :refer [api-defaults wrap-defaults]]))
@@ -45,5 +46,5 @@
   (wrap-json-response app-routes api-defaults))

 (defn -main [& [port]]
-  (let [port (Integer. (or port 5000))]
+  (let [port (Integer. (or port (env :port) 5000))]
     (jetty/run-jetty (site #'app) {:port port :join? false})))


Log simulation start to console

Log simulation start to console

--- src/clj_gatling/core.clj
+++ src/clj_gatling/core.clj
@@ -19,7 +19,7 @@
 (defn run-simulation [scenario users]
  (let [result (simulation/run-simulation scenario users)
        csv (csv/write-csv (report/create-result-lines result) :delimiter "\t" :end-of-line "\n")]
-   (println csv)
+   (println (str "Running scenario " (:name scenario) " with " users " users."))
    (create-results-dir)
    (spit "results/1/simulation.log" csv)
    (create-chart "results")


Cleanup

Cleanup

--- src/cljs/ufo/client.cljs
+++ src/cljs/ufo/client.cljs
@@ -91,9 +91,7 @@
   (render
    [this]
    (let [{:keys [cols] :as prm} (om/props this)]
-     (html
-      [:tr (map (fn [val] (th {:val (str val)}))
-                cols)]))))
+     (html [:tr (map (fn [v] (th {:val (str v)})) cols)]))))
 (def thead-row (om/factory THeadRow))

 (defn td [row id kw]
@@ -107,10 +105,8 @@
   Object
   (render
    [this]
-   (let [{:keys [row cols]} (om/props this)
-         id (:id row)]
-     (html
-      [:tr (map (fn [kw] (td row id kw)) cols)]))))
+   (let [{:keys [row cols]} (om/props this)]
+     (html [:tr (map (fn [kw] (td row (:id row) kw)) cols)]))))
 (def tbody-row (om/factory TBodyRow))

 (defui TBodySalaries
@@ -147,21 +143,6 @@
    (let [{:keys [tid tname sqlfn cols] :as prm} (om/props this)]
      (html
       [:div
-       #_[:button
-        {:onClick
-         (fn [e]
-           (let [tbeg (time/now)]
-             (utils/ednxhr
-              {:reqprm {:f fname :log t :nocache t}
-               :on-complete
-               (fn [resp]
-                 ;; map returs a lazy sequence therefore doseq must be used
-                 ;; (map #(add-row! this %) (:rows resp))
-                 (doseq [p (:rows resp)]
-                   (add-row! this p cols))
-                 #_{:resp (str resp) :tbeg tbeg :tend (time/now)})
-               :on-error (fn [resp] (println resp))})))}
-        "fetch data"]
        [:div tname]
        [:table
         [:thead (thead-row prm)]
@@ -185,7 +166,4 @@
   (render
    [this]
    (let [{:keys [list/tables]} (om/props this)]
-     (html
-      [:div
-       [:div (for [table-desc tables]
-               (table table-desc))]]))))
+     (html [:div (map table tables)]))))


Experiment more with meta-errors

Experiment more with meta-errors

--- src/clojush/evaluate.clj
+++ src/clojush/evaluate.clj
@@ -597,7 +597,7 @@
                          (= e (max p1e p2e)) 4
                          :else 5)))
                 (vec (repeat (count (:errors ind)) 6)))
-              (if (and (:parent1-errors ind)
+              #_(if (and (:parent1-errors ind)
                        (:parent2-errors ind))
                 (vec (for [[e p1e p2e] (mapv #(vector %1 %2 %3)
                                              (:errors ind)
@@ -611,6 +611,57 @@
                          (= e (max p1e p2e)) 4
                          :else 5)))
                 (vec (repeat (count (:errors ind)) 6)))
+              #_(if (and (:parent1-errors ind)
+                       (:parent2-errors ind))
+                (vec (for [[e p1e p2e] (mapv #(vector %1 %2 %3)
+                                             (:errors ind)
+                                             (:parent1-errors ind)
+                                             (:parent2-errors ind))]
+                       (cond
+                         (or (zero? e) (< e (min p1e p2e))) 0
+                         (some #{e} [p1e p2e]) 3
+                         (< e (max p1e p2e)) 1
+                         :else 2)))
+                (vec (repeat (count (:errors ind)) 3)))
+              #_(if (and (:parent1-errors ind)
+                       (:parent2-errors ind))
+                (vec (for [[e p1e p2e] (mapv #(vector %1 %2 %3)
+                                             (:errors ind)
+                                             (:parent1-errors ind)
+                                             (:parent2-errors ind))]
+                       (cond
+                         (zero? e) 0
+                         (< e (min p1e p2e)) 1
+                         (some #{e} [p1e p2e]) 4
+                         (< e (max p1e p2e)) 2
+                         :else 3)))
+                (vec (repeat (count (:errors ind)) 4)))
+              #_(if (and (:parent1-errors ind)
+                       (:parent2-errors ind))
+                (vec (for [[e p1e p2e] (mapv #(vector %1 %2 %3)
+                                             (:errors ind)
+                                             (:parent1-errors ind)
+                                             (:parent2-errors ind))]
+                       (cond
+                         (zero? e) 0
+                         (< e (min p1e p2e)) 1
+                         (some #{e} [p1e p2e]) 3
+                         (< e (max p1e p2e)) 2
+                         :else 4)))
+                (vec (repeat (count (:errors ind)) 4)))
+              (if (and (:parent1-errors ind)
+                       (:parent2-errors ind))
+                (vec (for [[e p1e p2e] (mapv #(vector %1 %2 %3)
+                                             (:errors ind)
+                                             (:parent1-errors ind)
+                                             (:parent2-errors ind))]
+                       (cond
+                         (zero? e) 1
+                         (< e (min p1e p2e)) 1
+                         (some #{e} [p1e p2e]) 3
+                         (< e (max p1e p2e)) 2
+                         :else 4)))
+                (vec (repeat (count (:errors ind)) 4)))
               ;
               (= cat :error-neglect)
               #_(if (and (:parent1-errors ind) (:parent2-errors ind))


Reversed terminology on fidelity/consistency meta-errors

--- src/clojush/evaluate.clj
+++ src/clojush/evaluate.clj
@@ -175,26 +175,26 @@
                                            ;(+ (first case-history) (* 1000 (/ 1.0 sum)))
                                            (- 1.0 sum)
                                            )))))))
-                          (= cat :reproductive-fidelity)
+                          (= cat :reproductive-infidelity)
                           (let [g (:genome ind)]
                             (- 1.0
                                (sequence-similarity
                                  g
                                  (produce-child-genome-by-autoconstruction g g argmap))))
                           ;
-                          (= cat :reproductive-infidelity)
+                          (= cat :reproductive-fidelity)
                           (let [g (:genome ind)]
                             (sequence-similarity
                               g
                               (produce-child-genome-by-autoconstruction g g argmap)))
                           ;
-                          (= cat :reproductive-consistency)
+                          (= cat :reproductive-inconsistency)
                           (let [g (:genome ind)]
                             (- 1.0
                                (sequence-similarity
                                  (produce-child-genome-by-autoconstruction g g argmap)
                                  (produce-child-genome-by-autoconstruction g g argmap))))
-                          (= cat :reproductive-inconsistency)
+                          (= cat :reproductive-consistency)
                           (let [g (:genome ind)]
                             (sequence-similarity
                               (produce-child-genome-by-autoconstruction g g argmap)


Remove comment

Remove comment

--- src/oi_lang/obj.cljs
+++ src/oi_lang/obj.cljs
@@ -44,7 +44,6 @@
      :string  (fn [& chars] [:string (apply str chars)])
      :arglist reduce-arglist
      :message (fn [& args]
-                ;(println (first (first args)))
                 (if (and (= 1 (count args)) (= (first (first args)) :op-message))
                   (let [[_ op & args] (first args)]
                     [:message op (vec (cons :arglist args))])


wip: inching closer to final control flow

--- src/otto/control.clj
+++ src/otto/control.clj
@@ -1,11 +1,11 @@
 (ns otto.control
-  (:require [clojure.core.async :as async :refer [<! alts!! chan go timeout]]
+  (:require [clojure.core.async :as async :refer [<! alts!! chan close! go timeout]]
             [otto.github :as github]))

 (defn- update-repository
-  [repos r]
-  (println r)
-  (not (nil? r)))
+  [repos v k]
+  (println v k)
+  (not (nil? v)))

 (defn- update-repositories
   [orgs user update-fn]
@@ -14,13 +14,15 @@
     (doseq [o orgs]
       (github/fetch-repositories o user r))
     (loop []
-      (if (update-fn (first (alts!! [r t])))
-        (recur)))))
+      (if (update-fn (alts!! [r t]))
+        (recur)
+        (do (close! r)
+            (close! t))))))

 (defn periodically-update
   [orgs user interval repos]
-  (let [f (fn [r] (update-repository repos r))]
+  (let [update-fn #(apply update-repository repos %)]
     (go (loop []
           (<! (timeout interval))
-          (update-repositories orgs user f)
+          (update-repositories orgs user update-fn)
           (recur)))))


Cleaned up fields selected in mod-poll

Cleaned up fields selected in mod-poll

--- src/polismath/db.clj
+++ src/polismath/db.clj
@@ -81,8 +81,8 @@
   [last-mod-timestamp]
   (try
     (kdb/with-db (db-spec)
-      (ko/select
-        comments
+      (ko/select comments
+        (ko/fields :zid :tid :mod :modified)
         (ko/where {:modified [> last-mod-timestamp]
                    :mod [not= 0]})
         (ko/order [:zid :tid :modified] :asc)))


removed "code" from "hospital code" in data/table

--- src/prais2/data.cljs
+++ src/prais2/data.cljs
@@ -623,7 +623,7 @@
      (0-16 years old)."]

     [:p.col-sm-9
-     "Clicking on a hospital code will bring up specific information for
+     "Clicking on a hospital will bring up specific information for
      that hospital along with an interpretation of its survival rate. It is " [:strong "only"] " valid to compare a hospital's survival
      rate to its predicted range of survival and not to other hospitals. Read more about this in "
      [:a (core/href "faqs") "Everything Else."]]


endpoint is per instance property

endpoint is per instance property

--- src/celestial/config.clj
+++ src/celestial/config.clj
@@ -58,8 +58,7 @@
   [c]
   (validate-nest c [:hypervisor :aws]
     [:access-key] [v/required cv/str?]
-    [:secret-key] [v/required cv/str?]
-    [:endpoint] [v/required cv/str?]))
+    [:secret-key] [v/required cv/str?]))

 (defn validate-conf
   "applies all validations on a configration map"


Go easy on the `:refer`

Go easy on the `:refer`

--- test/hiccup_find/core_test.cljc
+++ test/hiccup_find/core_test.cljc
@@ -1,10 +1,7 @@
 (ns hiccup-find.core-test
   (:require #?(:cljs [cljs.test :refer-macros [deftest is]]
                :clj [clojure.test :refer [deftest is]])
-            [hiccup-find.core :as hf :refer [hiccup-find
-                                             hiccup-string
-                                             hiccup-symbol-matches?
-                                             hiccup-text]]))
+            [hiccup-find.core :as hf]))

 (deftest test-hiccup-form-matches?
   (is (hf/hiccup-form-matches? :p [:p.lol]))
@@ -24,121 +21,130 @@
   (is (hf/hiccup-form-matches? :p.lol [:p.haha {:class ["hihi" "lol"]}])))

 (deftest test-hiccup-symbol-matches?
-  (is (hiccup-symbol-matches? :p :p.class))
-  (is (not (hiccup-symbol-matches? :p.class :p)))
-  (is (hiccup-symbol-matches? :.class :p.class.more))
-  (is (hiccup-symbol-matches? :p.more.class :p.class.more)))
+  (is (hf/hiccup-symbol-matches? :p :p.class))
+  (is (not (hf/hiccup-symbol-matches? :p.class :p)))
+  (is (hf/hiccup-symbol-matches? :.class :p.class.more))
+  (is (hf/hiccup-symbol-matches? :p.more.class :p.class.more)))

 (deftest test-hiccup-find
   (is (= (list [:p.image "Yes 1"]
                [:p.image "Yes 2"])
-         (hiccup-find [:p.image]
-                      [:html
-                       [:body
-                        [:p.img "No"]
-                        [:p.image "Yes 1"]
-                        [:p.images "No"]
-                        [:div.image
-                         [:p.image "Yes 2"]]]])))
+         (hf/hiccup-find
+          [:p.image]
+          [:html
+           [:body
+            [:p.img "No"]
+            [:p.image "Yes 1"]
+            [:p.images "No"]
+            [:div.image
+             [:p.image "Yes 2"]]]])))

   (is (= (list [:p {:class "image"} "Yes 1"]
                [:p {:class "image"} "Yes 2"])
-         (hiccup-find [:p.image]
-                      [:html
-                       [:body
-                        [:p.img "No"]
-                        [:p {:class "image"} "Yes 1"]
-                        [:p.images "No"]
-                        [:div.image
-                         [:p {:class "image"} "Yes 2"]]]])))
+         (hf/hiccup-find
+          [:p.image]
+          [:html
+           [:body
+            [:p.img "No"]
+            [:p {:class "image"} "Yes 1"]
+            [:p.images "No"]
+            [:div.image
+             [:p {:class "image"} "Yes 2"]]]])))

   (is (= (list [:p "Yes 1"]
                [:p "Yes 2"])
-         (hiccup-find [:div :p]
-                      [:html
-                       [:body
-                        [:p "No"]
-                        [:div [:p "Yes 1"]]
-                        [:div
-                         [:table
-                          [:tr
-                           [:td
-                            [:p "Yes 2"]]]]]]])))
+         (hf/hiccup-find
+          [:div :p]
+          [:html
+           [:body
+            [:p "No"]
+            [:div [:p "Yes 1"]]
+            [:div
+             [:table
+              [:tr
+               [:td
+                [:p "Yes 2"]]]]]]])))

   (is (= (list [:p "Yes 1"]
                [:p "Yes 2"]
                [:p "Yes 3"])
-         (hiccup-find [:div :p]
-                      [:html
-                       [:body
-                        [:div
-                         [:table
-                          [:tr
-                           [:td
-                            [:p "Yes 1"]]]]]
-                        [:div
-                         [:table
-                          [:tr
-                           [:td
-                            [:p "Yes 2"]]]
-                          [:tr
-                           [:td
-                            [:p "Yes 3"]]]]]]])))
+         (hf/hiccup-find
+          [:div :p]
+          [:html
+           [:body
+            [:div
+             [:table
+              [:tr
+               [:td
+                [:p "Yes 1"]]]]]
+            [:div
+             [:table
+              [:tr
+               [:td
+                [:p "Yes 2"]]]
+              [:tr
+               [:td
+                [:p "Yes 3"]]]]]]])))

   (is (= (list [:p "Yes 1"]
                [:p "Yes 2"]
                [:p "Yes 3"])
-         (hiccup-find [:div :p]
-                      [:html
-                       [:body
-                        [:div
-                         [:table
-                          [:tr
-                           [:td
-                            [:p "Yes 1"]]]]]
-                        [:div
-                         [:table
-                          [:tr
-                           [:td
-                            [:p "Yes 2"]]]
-                          [:tr
-                           [:td
-                            [:p "Yes 3"]]]]]]]))))
+         (hf/hiccup-find
+          [:div :p]
+          [:html
+           [:body
+            [:div
+             [:table
+              [:tr
+               [:td
+                [:p "Yes 1"]]]]]
+            [:div
+             [:table
+              [:tr
+               [:td
+                [:p "Yes 2"]]]
+              [:tr
+               [:td
+                [:p "Yes 3"]]]]]]]))))

 (deftest test-hiccup-text
   (is (= "Text here"
-         (hiccup-text [:p "Text here"])))
+         (hf/hiccup-text [:p "Text here"])))

   (is (= "Text here"
-         (hiccup-text [:p [:span "Text here"]])))
+         (hf/hiccup-text [:p [:span "Text here"]])))

   (is (= "Text here"
-         (hiccup-text [:p {:class "something"} "Text here"])))
+         (hf/hiccup-text [:p {:class "something"} "Text here"])))

   (is (= "Text here"
-         (hiccup-text [:p {:class "something"} "Text " [:strong "here"]])))
+         (hf/hiccup-text [:p {:class "something"} "Text " [:strong "here"]])))

   (is (= (str "Welcome, earthling\n"
               "Hope you enjoy your stay")
-         (hiccup-text [:html
-                       [:body
-                        [:h1 "Welcome, earthling"]
-                        [:p "Hope you " [:strong "enjoy"] " your stay"]]])))
+         (hf/hiccup-text
+          [:html
+           [:body
+            [:h1 "Welcome, earthling"]
+            [:p "Hope you " [:strong "enjoy"] " your stay"]]])))

   (is (= "Number 42"
-         (hiccup-text [:html
-                       [:body
-                        [:p "Number " [:strong 42]]]]))))
+         (hf/hiccup-text
+          [:html
+           [:body
+            [:p "Number " [:strong 42]]]]))))

 (deftest test-hiccup-string
   (is (= "Welcome, earthling Hope you enjoy your stay"
-         (hiccup-string [:html
-                         [:body
-                          [:h1 "Welcome, earthling"]
-                          [:p "Hope you " [:strong "enjoy"] " your stay"]]])))
+         (hf/hiccup-string
+          [:html
+           [:body
+            [:h1 "Welcome, earthling"]
+            [:p "Hope you " [:strong "enjoy"] " your stay"]]])))

   (is (= "Welcome! Hope you enjoy your stay"
-         (hiccup-string [:html
-                         [:body
-                          [:h1 "Welcome!"]
-                          [:p "Hope you   " [:strong "enjoy"] " your stay"]]]))))
+         (hf/hiccup-string
+          [:html
+           [:body
+            [:h1 "Welcome!"]
+            [:p "Hope you   " [:strong "enjoy"] " your stay"]]]))))


No longer a need to include midje.checkers.

--- test/midje/unprocessed_test.clj
+++ test/midje/unprocessed_test.clj
@@ -1,8 +1,7 @@
 (ns midje.unprocessed-test
+  (:use clojure.test)
   (:use [midje.unprocessed] :reload-all)
   (:use [midje.semi-sweet :only [fake]])
-  (:use [midje.checkers])
-  (:use [clojure.test])
   (:use [midje.test-util]))


Fix a couple of silly bugs.

Fix a couple of silly bugs.

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

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -376,8 +376,7 @@
 (defn store-new-z-reference []
   (let [z-drive (@state :default-z-drive)]
     (when (and (or (not (core isContinuousFocusEnabled))
-                   (core isContinuousFocusDrive z-drive))
-               (not (z-in-msp z-drive)))
+                   (core isContinuousFocusDrive z-drive)))
       (state-assoc! :reference-z (get-z-stage-position z-drive)))))

 ;; startup and shutdown
@@ -438,32 +437,33 @@
                          (-> current-position get-msp (z-in-msp z-drive) not)
                          (or (:autofocus event)
                              (:wait-time-ms event)))]
-    (flatten
-      (list
-        #(log event)
-        (for [[axis pos] (:axes (MultiStagePosition-to-map (get-msp current-position))) :when pos]
-          #(apply set-stage-position axis pos))
-        (for [[d p v] (get-in event [:channel :properties])]
-          #(set-property [d p v]))
-        #(when-lets [exposure (:exposure event)
-                     camera (core getCameraDevice)]
-           (device-best-effort camera (core setExposure exposure)))
-        #(when check-z-ref
-           (set-stage-position z-drive (@state :reference-z)))
-        #(when-let [wait-time-ms (:wait-time-ms event)]
-           (acq-sleep wait-time-ms))
-        #(when (:autofocus event)
-           (run-autofocus))
-        #(when check-z-ref
-           (store-new-z-reference))
-        #(when z-drive
-           (let [z (compute-z-position event)]
-             (set-stage-position z-drive z)))
-        (event :runnables)
-        #(do (wait-for-pending-devices)
-             (expose event)
-             (collect event out-queue)
-             (stop-trigger))))))
+    (filter identity
+            (flatten
+              (list
+                #(log event)
+                (for [[axis pos] (:axes (MultiStagePosition-to-map (get-msp current-position))) :when pos]
+                  #(apply set-stage-position axis pos))
+                (for [[d p v] (get-in event [:channel :properties])]
+                  #(set-property [d p v]))
+                #(when-lets [exposure (:exposure event)
+                             camera (core getCameraDevice)]
+                            (device-best-effort camera (core setExposure exposure)))
+                #(when check-z-ref
+                   (set-stage-position z-drive (@state :reference-z)))
+                #(when-let [wait-time-ms (:wait-time-ms event)]
+                   (acq-sleep wait-time-ms))
+                #(when (:autofocus event)
+                   (run-autofocus))
+                #(when check-z-ref
+                   (store-new-z-reference))
+                #(when z-drive
+                   (let [z (compute-z-position event)]
+                     (set-stage-position z-drive z)))
+                (event :runnables)
+                #(do (wait-for-pending-devices)
+                     (expose event)
+                     (collect event out-queue)
+                     (stop-trigger)))))))

 (defn execute [event-fns]
   (doseq [event-fn event-fns :while (not (:stop @state))]


Add simple :pan control to the sample players.  Example usage I tested with:

;; mono sample
(def kick (sample (freesound-path 2086)))
(kick :pan -1)

and

;; stereo sample
(def sol-do (sample (freesound-path 44929)))
(sol-do :pan 1)

--- src/overtone/sc/sample.clj
+++ src/overtone/sc/sample.clj
@@ -17,35 +17,37 @@
   (do
     (defsynth mono-player
       "Plays a single channel audio buffer."
-      [buf 0 rate 1.0 start-pos 0.0 loop? 0 vol 1 out-bus 0]
+      [buf 0 rate 1.0 start-pos 0.0 loop? 0 vol 1 pan 0 out-bus 0]
       (out out-bus (* vol
                       (pan2
                        (scaled-play-buf 1 buf rate
                                         1 start-pos loop?
-                                        FREE)))))
+                                        FREE)
+                       pan))))

     (defsynth stereo-player
       "Plays a dual channel audio buffer."
-      [buf 0 rate 1.0 start-pos 0.0 loop? 0 vol 1 out-bus 0]
-      (out out-bus (* vol
-                      (scaled-play-buf 2 buf rate
-                                       1 start-pos loop?
-                                       FREE))))
+      [buf 0 rate 1.0 start-pos 0.0 loop? 0 vol 1 pan 0 out-bus 0]
+      (let [s (scaled-play-buf 2 buf rate
+                               1 start-pos loop?
+                               FREE)]
+            (out out-bus (* vol (balance2 (first s) (second s) pan)))))

     (defsynth mono-stream-player
       "Plays a single channel streaming buffer-cue. Must be freed manually when
       done."
-      [buf 0 rate 1 loop? 0 vol 1 out-bus 0]
+      [buf 0 rate 1 loop? 0 vol 1 pan 0 out-bus 0]
       (out out-bus (* vol
                       (pan2
-                       (scaled-v-disk-in 1 buf rate loop?)))))
+                       (scaled-v-disk-in 1 buf rate loop?)
+                       pan))))

     (defsynth stereo-stream-player
       "Plays a dual channel streaming buffer-cue. Must be freed manually when
       done."
-      [buf 0 rate 1 loop? 0 vol 1 out-bus 0]
-      (out out-bus (* vol
-                      (scaled-v-disk-in 2 buf rate loop?))))))
+      [buf 0 rate 1 loop? 0 vol 1 pan 0 out-bus 0]
+      (let [s (scaled-v-disk-in 2 buf rate loop?)]
+        (out out-bus (* vol (balance2 (first s) (second s) pan)))))))

 (defonce loaded-samples* (atom {}))
 (defonce cached-samples* (atom {}))


fixed source/static.clj to reflect new dist to border file


Use while loop instead of explicit recur and if

--- src/petulant_life/main.clj
+++ src/petulant_life/main.clj
@@ -34,16 +34,13 @@

 ; Running the simulation / graphics.
 (defn run []
-  (loop [running true]
-    (if (and running (not (Display/isCloseRequested)))
-      (do (GL11/glClear GL11/GL_COLOR_BUFFER_BIT)
-          (r/draw-rectangles [[10 10 50 50]
-                              [70 10 50 50]
-                              [10 70 50 50]
-                              [70 70 50 50]] nil)
-          (Display/update)
-          (recur true))
-      nil)))
+  (while (and running (not (Display/isCloseRequested)))
+    (do (GL11/glClear GL11/GL_COLOR_BUFFER_BIT)
+        (r/draw-rectangles [[10 10 50 50]
+                            [70 10 50 50]
+                            [10 70 50 50]
+                            [70 70 50 50]] nil)
+        (Display/update))))

 ; Entry point.
 (defn -main [& args]


easy fix fix

easy fix fix

--- src-clj/acha/achievement.clj
+++ src-clj/acha/achievement.clj
@@ -172,7 +172,7 @@
                (= ((first diff) 1) ((last diff) 1))
                ; line number absolute difference is 1
                (= 1 (Math/abs (- (last (first diff)) (last (last diff)))))))]
-       (when (some two-line-swapped? diffs)
+       (when (and (= (count diffs) 1) (some two-line-swapped? diffs))
          {:username author
           :time time})))])


feat(web/project.clj): add 'lein auto compile' for sassc

--- web/project.clj
+++ web/project.clj
@@ -40,7 +40,8 @@
             [lein-ancient "0.6.5"]
             [org.clojars.punkisdead/lein-cucumber "1.0.4"]
             [lein-cljsbuild "1.0.4"]
-            [lein-sassc "0.10.4"]]
+            [lein-sassc "0.10.4"]
+            [lein-auto "0.1.2"]]

   :cucumber-feature-paths ["test/features"]

@@ -53,7 +54,10 @@
   :import-path "resources/scss"}]

   :hooks [leiningen.sassc]
-
+
+  :auto {"compile"  {:paths ["resources/scss"]
+                   :file-pattern  #"\.(scss)$"}}
+

   :ring {:handler web.handler/app
          :init    web.handler/init


Can add items

Can add items

--- test/layzee/integration/storage/dynamo_db_examples.clj
+++ test/layzee/integration/storage/dynamo_db_examples.clj
@@ -37,13 +37,27 @@
   (doseq [name (list-tables amazon-credential)]
     (delete-table amazon-credential name)))

+(defn save[amazon-credential table-name item]
+  (far/put-item (client-opts amazon-credential) (symbol table-name) item))
+
 (def test-table-name "lazy-web-test")

 (facts "The basics"
        ;;(delete-all-tables settings/amazon-credential)

        (future-fact "It fails with error when table already exists")
-       (fact "like this"
+
+       (fact "create a new table like this"
              (delete-table settings/amazon-credential test-table-name)
              (new-table settings/amazon-credential test-table-name)
-             (list-tables settings/amazon-credential) => '(:lazy-web-test)))+             (list-tables settings/amazon-credential) => '(:lazy-web-test)))
+
+(facts "Can add items to a table"
+       (new-table settings/amazon-credential test-table-name)
+
+       (future-fact "You can only add maps -- NOT strings for example")
+
+       (fact "for example"
+             (save settings/amazon-credential test-table-name
+                   {:id 0
+                    :name "Bang" :data (far/freeze {:id_str "abc" :text "The tweet text"} )})))


Version 0.1.0

Version 0.1.0

--- ClojureScript/project.clj
+++ ClojureScript/project.clj
@@ -1,4 +1,4 @@
-(defproject bocko-ios "0.1.0-SNAPSHOT"
+(defproject bocko-ios "0.1.0"
   :description "Use Bocko on iOS"
   :dependencies [[org.clojure/clojure "1.7.0-beta2"]
                  [org.clojure/clojurescript "0.0-3255"]


Formatting adjustment and remove println.

--- src/cadence/views/common.clj
+++ src/cadence/views/common.clj
@@ -46,12 +46,13 @@

 (defn alert
   "Displays an alert box."
-  ([class type message show-close?] [:div {:id "flash" :class (str "alert fade in alert-" (name class))}
-                                     (when show-close?
-                                       [:a.close {:data-dismiss "alert"} "×"])
-                                     [:strong (if (keyword? type)
-                                                (string/capitalize (name type))
-                                                type) " "] message])
+  ([class type message show-close?]
+   [:div {:id "flash" :class (str "alert fade in alert-" (name class))}
+    (when show-close?
+      [:a.close {:data-dismiss "alert"} "×"])
+    [:strong (if (keyword? type)
+               (string/capitalize (name type))
+               type) " "] message])
   ([class type message] (alert class type message true))
   ([type message] (alert type type message true)))

@@ -78,7 +79,6 @@
     [:div#main-wrapper
      [:div#main.container
       (when-let [{t :type c :class m :message} (flash/get)]
-        (println (name t))
         (alert (if (nil? c) t c) t m))
       content]]))


Remove configfile resource (-> now in repository)

--- src/cider_ci/builder/web.clj
+++ src/cider_ci/builder/web.clj
@@ -88,35 +88,11 @@
        :body (str "Server error.\n\n"
                   (thrown/stringify e))})))

-
-(defn configfile [request]
-  (try
-    (let [configfile-content (cider-ci.builder.configfile/get-configfile
-                            (-> request :route-params :tree_id))]
-      (logging/debug {:configfile-content configfile-content})
-      {:status 200
-       :headers {"content-type" "application/json;charset=utf-8"}
-       :body (util/json-write-str configfile-content)})
-    (catch clojure.lang.ExceptionInfo e
-      (logging/warn "DOTFILE " (thrown/stringify e))
-      (case (-> e .getData :object :status)
-        404  {:status 404
-              :body (str "The configfile itself or a included resource doesn't exist. \n\n"
-                         (-> e .getData :object ))}
-        {:status 500
-         :body (str "ERROR " (thrown/stringify e))}))
-    (catch Throwable e
-      (logging/error "DOTFILE " (thrown/stringify e))
-      {:status 500
-       :body (str "See the builder logs for more details. "
-                  "\n\n"  (thrown/stringify e))})))
-
 (defn wrap-jobs [default-handler]
   (cpj/routes
     (cpj/GET "/jobs/available/:tree_id" request #'available-jobs)
     (cpj/POST "/jobs/" request #'create-job)
     (cpj/POST "/jobs" request #'create-job)
-    (cpj/GET "/configfile/:tree_id" request #'configfile)
     (cpj/ANY "*" request default-handler)))


Remove repository and commits from build

--- src/circle/backend/build.clj
+++ src/circle/backend/build.clj
@@ -79,10 +79,7 @@
                      build_num    ;; int
                      vcs_url
                      vcs_revision ;; if present, the commit that caused the build to be run, or nil
-                     aws_credentials ;; map containing :user and :password
                      notify_emails ;; a seq of email addresses to notify when build is done
-                     repository
-                     commits
                      actions      ;; a seq of actions
                      action-results
                      node         ;; Map containing keys required by ec2/start-instance


Add chaikin-curve-retain-ends fn

Add chaikin-curve-retain-ends fn

--- src/clj/genartlib/curves.clj
+++ src/clj/genartlib/curves.clj
@@ -17,7 +17,7 @@

    The tightness parameter controls how sharp the corners will be,
    and should be a value between 0.0 and 0.5.  A value of 0.0 retains
-   full sharpness, and 0.5 creates maximum smoothness.
+   full sharpness, and 0.25 creates maximum smoothness.

    The depth parameter controls how many recursive steps will occur.
    The more steps, the smoother the curve is (assuming tightness is
@@ -32,3 +32,18 @@

   ([points depth tightness]
    (nth (iterate #(single-chaikin-step % tightness) points) depth)))
+
+(defn chaikin-curve-retain-ends
+  "Like chaikin-curve, but retains the first and last point in the
+   original `points` seq."
+  ([points] (chaikin-curve points 4))
+  ([points depth] (chaikin-curve points depth 0.25))
+  ([points depth tightness]
+   (if (<= (count points) 2)
+     points
+     (let [first-point (first points)
+           last-point (last points)
+           processed-points (chaikin-curve points depth tightness)]
+       (concat [first-point]
+               processed-points
+               [last-point])))))


required true

required true

--- src/clj/yambox/templates.clj
+++ src/clj/yambox/templates.clj
@@ -151,6 +151,7 @@
                  [:form {:role "form" :method "POST"}
                   [:div.form-group
                    [:input.header.control {:value (:name campaign)
+                                           :required "required"
                                            :name  "name"}]]
                   [:div.form-group
                    [:label "Ссылка на страницу кампании:"]
@@ -189,16 +190,19 @@
               [:form {:role "form" :method "POST"}
                [:div.form-group
                 [:input.header.control {:placeholder "Название кампании"
+                                        :required "required"
                                         :name "name"}]
                 [:div.descr "Например, "
                  "«Сбор денег для проведения избирательной кампании»"]]
                [:div.form-group
                 [:label "Ссылка на страницу кампании (буквы a-z, тире и цифры; например, kittens-unlimited):"]
-                [:input.control {:name "slug"}]]
+                [:input.control {:name "slug"
+                                 :required "required"}]]
                [:div.form-group
                 [:label "Собираемая сумма (в рублях):"]
                 [:input.control {:type "number"
-                                 :name "target-money"}]]
+                                 :name "target-money"
+                                 :required "required"}]]
                [:input.btn.btn-default {:type "submit" :value "Создать"}]]]
              [:div.col-sm-4.tips
               [:p "Кампания привязана к номеру кошелька Яндекс.Денег, поэтому "


district filter

district filter

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

 (defonce app-cms
   (atom
-   {:title "IdeaBox"
+   {:title "Support local ideas!"
+    :subtitle ""
     :instructions-district "1. Choose your district"
     :instructions-vote     "2. Check ideas you want to support!"
     :instructions-add      "3. Add your won ideas"
@@ -84,9 +85,19 @@
    ["Shops" "Security" "Green" "Other..."]))

 (def app-districts
-  (atom ["Manhattan" "Brooklyn" "Queens"]))
-
-
+  (atom ["Manhattan" "Brooklyn" "Queens" "Other"]))
+
+
+;;; STATE
+
+(def app-state
+  (atom
+   {:selected-districts @app-districts
+    :added-ideas nil
+    :added-user  nil}))
+
+
+;;; FNS

 (defn row [label input]
   [:div.row
@@ -112,9 +123,9 @@

    [:h3 "1. Choose your district"]
    [:div.btn-group {:field :multi-select :id :every.position}
-    [:button.btn.btn-default {:key :left} "Manhattan"]
-    [:button.btn.btn-default {:key :middle} "Brooklyn"]
-    [:button.btn.btn-default {:key :right} "Queens"]]
+    (for [d @app-districts]
+      [:button.btn.btn-default {:key (keyword d)} d])]
+

    [:h3 "2. Check ideas you want to support!"]


add ai tracing

add ai tracing

--- src/cljs/triboard/ai/ai.cljs
+++ src/cljs/triboard/ai/ai.cljs
@@ -10,6 +10,8 @@
 ;; -----------------------------------------
 ;; Private
 ;; -----------------------------------------
+
+(def eval-counter (atom 0))

 (defprotocol AIStrategy
   (optimized-score [this scores] "Extract data from the score to compare")
@@ -48,6 +50,7 @@

 (defn- leaf-score
   [ai {:keys [scores] :as turn}]
+  (swap! eval-counter inc)
   (min-max-step ai turn
     (fn look-ahead [_ transition]
       (optimized-score ai (scores/update-scores scores transition))
@@ -86,14 +89,15 @@
   [{:keys [blue red green] :as scores}]
   (and (< red blue) (< green blue)))

-(defn- play-best-move
+(defn play-best-move
   [game]
+  (reset! eval-counter 0)
   (let [turn (game/current-turn game)
         hard-mode? (is-player-first? (:scores turn))
-        ai ((if hard-mode? make-cheating-ai make-ai) (:player turn))]
-    (game/play-at game
-      (time (best-move ai turn)) ;; TODO - Remove time + find a way to correlate with moves + sort then and take best
-      )))
+        ai ((if hard-mode? make-cheating-ai make-ai) (:player turn))
+        m (time (best-move ai turn))]  ;; TODO - Remove time + find a way to correlate with moves + sort then and take best
+    (js/console.log @eval-counter)
+    (game/play-at game m)))

 ;; -----------------------------------------


Remove unnecessary type printing methods.

--- src/clojure/inet/data/ip.clj
+++ src/clojure/inet/data/ip.clj
@@ -305,15 +305,3 @@
     ([this] false)
     ([this length] (network?* (address-bytes this) length)))
   (network-length [this] (address-length this)))
-
-(defmethod clojure.core/print-method IPAddress
-  ([^IPAddress net ^java.io.Writer w]
-     (.write w "#<IPAddress ")
-     (.write w (str net))
-     (.write w ">")))
-
-(defmethod clojure.core/print-method IPNetwork
-  ([^IPNetwork net ^java.io.Writer w]
-     (.write w "#<IPNetwork ")
-     (.write w (str net))
-     (.write w ">")))


Shorten conf API names; expand conf API.

--- src/clojure/parkour/conf.clj
+++ src/clojure/parkour/conf.clj
@@ -1,14 +1,16 @@
 (ns parkour.conf
+  (:refer-clojure :exclude [assoc!])
   (:require [clojure.string :as str]
             [parkour.util :refer [returning]])
   (:import [java.util List Map Set]
-           [org.apache.hadoop.conf Configuration]))
+           [org.apache.hadoop.conf Configuration]
+           [org.apache.hadoop.mapred JobConf]))

 (defmulti ^:private conf-set*
   "Internal implementation multimethod for setting value in Hadoop config."
   (fn [_ _ val] (type val)))

-(defmacro def-conf-set*
+(defmacro ^:private def-conf-set*
   [[conf key val] & pairs]
   (let [conf (vary-meta conf assoc :tag `Configuration)
         key (vary-meta key assoc :tag `String)]
@@ -38,14 +40,33 @@
   (let [kv-str (fn [[k v]] (str (conf-coerce k) "=" (conf-coerce v)))]
     (str/join "," (map kv-str val))))

-(defn conf-set!
+(defn set!
   "Set `conf` parameter `key` to `val`."
   [conf key val]
   (returning conf
     (conf-set* conf (name key) (conf-coerce val))))

-(defn conf-merge!
+(defn merge!
   "Merge `coll` of key-value pairs into Hadoop configuration `conf`."
   [conf coll]
   (returning conf
-    (doseq [[k v] coll] (conf-set! conf k v))))
+    (doseq [[k v] coll] (parkour.conf/set! conf k v))))
+
+(defn assoc!
+  "Merge key-value pairs `kvs` into Hadoop configuration `conf`."
+  [conf & kvs] (merge! conf (partition 2 kvs)))
+
+(defmacro ^:private make-conf-fn
+  [name class]
+  `(defn ~name
+     ~(str "Create a new " class ".")
+     ([] (new ~class))
+     ([~'conf-map]
+        (if (map? ~'conf-map)
+          (doto (~name) (merge! ~'conf-map))
+          (new ~class ~(with-meta 'conf-map {:tag class}))))
+     ([~'conf ~'conf-map]
+        (merge! ~'conf ~'conf-map))))
+
+(make-conf-fn job-conf JobConf)
+(make-conf-fn conf Configuration)


Convert ChaincodeInput args

Convert ChaincodeInput args

--- src/clojure_fabric/proto.clj
+++ src/clojure_fabric/proto.clj
@@ -70,16 +70,14 @@
   [& {:keys [name version path] :or {version "" path ""}}]
   (map->ChaincodeID {:name name :version version :path path}))

+(declare convert-args)
 (defrecord ChaincodeInput [^Iterable args ^java.util.Map decorations]
   ICljToProto
   (clj->proto [this]
     ;; Iterable - repeated
     ;; map has putAll* method
     (-> (Chaincode$ChaincodeInput/newBuilder)
-        (.addAllArgs (mapv #(cond (utils/bytes? %) (ByteString/copyFrom #^bytes %)
-                                  (instance? ChaincodeDeploymentSpec %) (.toByteString ^Chaincode$ChaincodeDeploymentSpec (clj->proto %))
-                                  :else (ByteString/copyFromUtf8 (str %)))
-                           args))
+        (.addAllArgs (convert-args args))
         (.putAllDecorations decorations)
         (.build))))

@@ -338,6 +336,13 @@
   [& {:keys [transaction-envelope validation-code]}]
   (map->ProcessedTransaction {:transaction-envelope transaction-envelope :validation-code validation-code}))

+
+(defn- convert-args
+  [args]
+  (mapv #(cond (utils/bytes? %) (ByteString/copyFrom #^bytes %)
+                                  (instance? ChaincodeDeploymentSpec %) (.toByteString ^Chaincode$ChaincodeDeploymentSpec (clj->proto %))
+                                  :else (ByteString/copyFromUtf8 (str %)))
+                           args))

 (extend-protocol IProtoToClj


manifold.deferred is no longer used

manifold.deferred is no longer used

--- src/icecap/handlers/core.clj
+++ src/icecap/handlers/core.clj
@@ -1,8 +1,7 @@
 (ns icecap.handlers.core
   "The core handler API and behavior."
   (:require [schema.core :as s]
-            [manifold.stream :as ms]
-            [manifold.deferred :as md]))
+            [manifold.stream :as ms]))

 (def get-schema nil) ;; anti-defonce behaavior of get-schema
 (defmulti get-schema


Address zeromq import issue.

Address zeromq import issue.

Partial work towards #1.

--- src/ipython_clojure/core.clj
+++ src/ipython_clojure/core.clj
@@ -5,7 +5,7 @@
             [zeromq.zmq :as zmq]
             [clj-time.core :as time]
             [clj-time.format :as time-format])
-  (:import [org.jeromq ZMQ])
+  (:import [org.zeromq ZMQ])
   (:gen-class :main true))

 (defn prep-config [args]
@@ -212,5 +212,3 @@
     (println (str "Connecting shell to " shell-addr))
     (println (str "Connecting iopub to " iopub-addr))
     (shell-loop shell-addr iopub-addr)))
-
-


bring back *out* used by pprint

bring back *out* used by pprint

--- src/main/cljs/cljs/core.cljs
+++ src/main/cljs/cljs/core.cljs
@@ -30,6 +30,10 @@
   ^{:dynamic true
     :doc "Var bound to the current namespace. Only used for bootstrapping."}
   *ns* nil)
+
+(def
+  ^{:dynamic true}
+  *out* nil)

 (def
   ^{:dynamic true}


I didn't like that indentation

I didn't like that indentation

--- src/metabase/models/user.clj
+++ src/metabase/models/user.clj
@@ -8,9 +8,7 @@
 (defentity User
   (table :core_user)
   (has-many OrgPerm {:fk :user_id})
-  (assoc :hydration-keys #{:author
-                           :creator
-                           :user}))
+  (assoc :hydration-keys #{:author :creator :user}))

 ;; fields to return for Users other `*than current-user*`
 (defmethod default-fields User [_]


note on mixin state

note on mixin state

--- src/om_bootstrap/button.cljs
+++ src/om_bootstrap/button.cljs
@@ -117,6 +117,9 @@

 #_
 (defmixin dropdown-mixin
+  "Note that we're going to have to do some magic to get the state
+  setting to work
+  here. https://github.com/Prismatic/om-tools/issues/28"
   (setDropdownState [_ new-state on-state-change-complete]))


Make embedded driver delete dirs on startup #481

--- src/onyx/messaging/aeron.clj
+++ src/onyx/messaging/aeron.clj
@@ -192,7 +192,10 @@
           threading-mode (get-threading-model (arg-or-default :onyx.messaging.aeron/embedded-media-driver-threading opts))

           media-driver-context (if embedded-driver?
-                                 (-> (MediaDriver$Context.) (.threadingMode threading-mode)) )
+                                 (-> (MediaDriver$Context.)
+                                     (.threadingMode threading-mode)
+                                     (.dirsDeleteOnStart true)))
+
           media-driver (if embedded-driver?
                          (MediaDriver/launch media-driver-context))


Fix a race condition when starting the DB pool from the connection macro.

--- src/open_company/db/pool.clj
+++ src/open_company/db/pool.clj
@@ -71,13 +71,14 @@
                         (throw (RuntimeException. msg))))

     ;; return the new state of the pool, and the connection we got
-    (trace "Using connection: " connection)
+    (trace "Using connection: " (:id connection))
     [pool connection]))

 (defn release-connection
   "Low level function for releasing. Use with-connection macro instead."
   [{:keys [connections] :as pool} {res-id :id :as connection}]
   ;; Get the connection to be released from the pool
+  (trace "Releasing connection:" res-id)
   (let [busy-connection (first (filter #(= (:id %) res-id) connections))
         connections (disj connections busy-connection) ; out of the pool
         connections (conj connections connection)] ; back into the pool w/o busy
@@ -101,7 +102,8 @@
   [[connection] & body]
   `(do
     (trace "Starting DB pool connection macro.")
-    (when (nil? @rethinkdb-pool) (debug "DB pool not started. Starting.") (start))
+    (locking rethinkdb-pool
+      (when (nil? @rethinkdb-pool) (debug "DB pool not started. Starting.") (start)))
     (let [[new-pool# conn#] (get-connection (deref rethinkdb-pool))]
       (reset! rethinkdb-pool new-pool#)
       (try


Add joint! macro

Add joint! macro

--- src/play_clj/g2d_physics.clj
+++ src/play_clj/g2d_physics.clj
@@ -93,6 +93,10 @@
   `(let [object# (~(joint-init k))]
      (u/fields! object# ~@options)))

+(defmacro joint!
+  [object k & options]
+  `(u/call! ^Joint ~object ~k ~@options))
+
 (defn create-joint!*
   [screen j-def]
   (box-2d! screen :create-joint j-def))
@@ -109,6 +113,10 @@
   `(let [^FixtureDef object# (FixtureDef.)]
      (u/fields! object# ~@options)
      object#))
+
+(defmacro fixture!
+  [object k & options]
+  `(u/call! ^Fixture ~object ~k ~@options))

 ; shapes

@@ -169,10 +177,6 @@
 (defmacro contact!
   [object k & options]
   `(u/call! ^Contact ~object ~k ~@options))
-
-(defmacro fixture!
-  [object k & options]
-  `(u/call! ^Fixture ~object ~k ~@options))

 (defn find-body
   [body entities]


Give better names in middleware to improve stack traces

--- src/re_frame/middleware.cljs
+++ src/re_frame/middleware.cljs
@@ -16,7 +16,7 @@
   If you strip away the error/efficiency checks, this middleware is just:
      (reset! app-db (handler @app-db event-vec))"
   [handler]
-  (fn new-handler
+  (fn pure-handler
     [app-db event-vec]
     (assert (satisfies? IReactiveAtom app-db)
             (str "re-frame: pure not given a Ratom."
@@ -36,7 +36,7 @@
   Includes a clojure.data/diff of the db, before vs after, showing the changes
   caused by the event."
   [handler]
-  (fn new-handler
+  (fn debug-handler
     [db v]
     (if (satisfies? IReactiveAtom db)
       (str "re-frame: \"debug\" middleware used without prior \"pure\"."))
@@ -52,7 +52,7 @@
 (defn undoable
   "Middleware which stores an undo checkpoint."
   [handler]
-  (fn new-handler
+  (fn undoable-handler
     [app-db event-vec]
     (store-now!)
     (handler app-db event-vec)))
@@ -83,7 +83,7 @@
   ([p default-fn]
     (fn middleware
       [handler]
-      (fn new-handler
+      (fn path-handler
         [db v]
         (if (satisfies? IReactiveAtom db)
           (str "re-frame: \"path\" used in middleware, without prior \"pure\"."))
@@ -117,7 +117,7 @@
   [f]
   (fn middleware
     [handler]
-    (fn new-handler
+    (fn validate-handler
       [db v]
       (f (handler db v)))))

@@ -131,7 +131,7 @@
   [f]
   (fn middleware
     [handler]
-    (fn new-handler
+    (fn after-handler
       [db v]
       (let [new-db (handler db v)]
         (f new-db)   ;; call f for side effects


Switch order of params in create-dataset-file\!.

--- project/analyze-data/src/analyze_data/create_dataset.clj
+++ project/analyze-data/src/analyze_data/create_dataset.clj
@@ -28,13 +28,13 @@
 (defn create-dataset-file!
   "Like create-dataset, but expects a file name for input and output.

+  dataset-type: the type of dataset to create
   in: path to a csv file. It should contain the headers 'document-label' and
       'document-text'
   out: path where the dataset will be written as a serialized map.  You may
        read this data back in using analyze-data.serialize/read-object, make
-       sure you use the same core.matrix implementation on each end.
-  dataset-type: the type of dataset to create"
-  [in out dataset-type]
+       sure you use the same core.matrix implementation on each end."
+  [dataset-type in out]
   (with-open [reader (io/reader in)]
     (let [corpus (csv-to-map reader)
           dataset (create-dataset dataset-type corpus)]


update

update

--- src/service/core.clj
+++ src/service/core.clj
@@ -29,7 +29,9 @@

 (defroutes all-routes
   (GET "/" [] (home))
-  (not-found "
Page not found.
")) ;; all other, return 404
+  (not-found {:status  200
+   :headers {"Content-Type" "text/html"}
+   :body    "resource not found"}))

 (defonce server (atom nil))

@@ -39,8 +41,5 @@
     (reset! server nil)))

 (defn -main []
-  ;; The #' is useful when you want to hot-reload code
-  ;; You may want to take a look: https://github.com/clojure/tools.namespace
-  ;; and http://http-kit.org/migration.html#reload
   (log/info "server listening on port " port)
   (reset! server (srv/run-server #'all-routes {:port port})))


Clean up client/modify-session!.

Clean up client/modify-session!.

--- src/shale/client.clj
+++ src/shale/client.clj
@@ -68,13 +68,16 @@
                            :or {reserved nil
                                 tags nil}}]
   (let [url (map->session-url id)
-        body (into {} [(if (nil? reserved) {} {:reserved reserved})
-                      (if (nil? tags) {} {:tags tags})])
-        response (try+ (client/put url
-                         {:body (json/generate-string body)
-                          :content-type :json
-                          :accept :json})
-                   (catch [:status 400] {:keys [body]} (error body) (throw+)))]
+        body (merge (if (nil? reserved) {} {:reserved reserved})
+                    (if (nil? tags) {} {:tags tags}))
+        response (try+
+                   (client/put url
+                               {:body (json/generate-string body)
+                                :content-type :json
+                                :accept :json})
+                   (catch [:status 400] {:keys [body]}
+                     (error body)
+                     (throw+)))]
     (json/parse-string (response :body))))

 (defn reserve-session! [id]


apply configs in same thread

apply configs in same thread

--- src/shuppet/core.clj
+++ src/shuppet/core.clj
@@ -133,7 +133,7 @@
 (defn- concurrent-config-update [environment]
   (let [names (app-names environment)]
     (doall
-     (pmap (fn [app-name]
+     (map (fn [app-name]
              (try+
               {:app app-name
                :report (*apply-config environment app-name)}