Fire side effects.

Fire side effects.

--- src/onyx/peer/virtual_peer.clj
+++ src/onyx/peer/virtual_peer.clj
@@ -10,18 +10,21 @@
    :fn (:fn entry)
    :args (:args entry)})

-(defn warm-up-processing-loop [log inbox-ch outbox-ch p-ch kill-ch]
-  (loop [local {:replica {} :local-state {}}]
-    (let [position (first (alts!! [kill-ch inbox-ch] :priority? true))]
+(defn warm-up-processing-loop [id log inbox-ch outbox-ch p-ch kill-ch]
+  (loop [local {:replica {} :local-state {:id id :log log}}]
+    (let [old-replica (:replica local)
+          old-state (:local-state local)
+          position (first (alts!! [kill-ch inbox-ch] :priority? true))]
       (when position
         (let [entry (extensions/read-log-entry log position)
               bundled (bundle-entry entry position)
-              new-replica (extensions/apply-log-entry bundled (:replica local))
-              diff (extensions/replica-diff bundled (:replica local) new-replica)
-              reactions (extensions/reactions entry (:replica local) new-replica diff)]
+              new-replica (extensions/apply-log-entry bundled old-replica)
+              diff (extensions/replica-diff bundled old-replica new-replica)
+              reactions (extensions/reactions entry old-replica new-replica diff)
+              new-state (extensions/fire-side-effects! bundled old-replica new-replica diff old-state)]
           (doseq [reaction reactions]
             (extensions/hold-in-outbox outbox-ch reaction))
-          (recur (assoc local :replica new-replica)))))))
+          (recur (assoc local :replica new-replica :local-state new-state)))))))

 (defrecord VirtualPeer [opts]
   component/Lifecycle
@@ -37,7 +40,7 @@
         (extensions/register-pulse log id)
         (extensions/write-to-outbox entry)

-        (thread (warm-up-processing-loop log inbox-ch outbox-ch nil kill-ch))
+        (thread (warm-up-processing-loop id log inbox-ch outbox-ch nil kill-ch))
         (thread (processing-loop))
         (assoc component :id id :inbox-ch inbox :outbox-ch outbox :kill-ch kill-ch))))


Don't update project tree if it isn't found

--- src/clojure/nightcode/ui.clj
+++ src/clojure/nightcode/ui.clj
@@ -185,9 +185,11 @@
 (defn update-project-tree!
   "Updates the project tree, optionally with a new selection."
   ([]
-    (update-project-tree! (get-project-tree) nil))
+    (some-> (get-project-tree)
+            (update-project-tree! nil)))
   ([^String new-selection]
-    (update-project-tree! (get-project-tree) new-selection))
+    (some-> (get-project-tree)
+            (update-project-tree! new-selection)))
   ([^JTree tree ^String new-selection]
     ; put new data in the tree
     (.setModel tree (create-project-tree!))


Added a little bit of debug output to the console.

--- src/clj/traveler/templates.clj
+++ src/clj/traveler/templates.clj
@@ -62,6 +62,7 @@
 (defn nav-side
   "Generate the sidebar"
   [request]
+  (prn (h-uri/relative-uri-str request (h-nav/id->uri-path request :traveler/dashboard)))
   (timber/main-menu
    [{:menu-name "Dashboard"
      :menu-url  (h-uri/relative-uri-str request (h-nav/id->uri-path request :traveler/dashboard))}


Allow :lifecycle/doc in lifecycle calls map

--- src/onyx/static/validation.clj
+++ src/onyx/static/validation.clj
@@ -148,7 +148,8 @@
       (select-keys lifecycle [:lifecycle/task :lifecycle/calls :lifecycle/doc]))))

 (defn validate-lifecycle-map [m]
-  (schema/validate {(schema/optional-key :lifecycle/start-task?) Function
+  (schema/validate {(schema/optional-key :lifecycle/doc) schema/Str
+                    (schema/optional-key :lifecycle/start-task?) Function
                     (schema/optional-key :lifecycle/before-task-start) Function
                     (schema/optional-key :lifecycle/before-batch) Function
                     (schema/optional-key :lifecycle/after-batch) Function


special components for inline types

special components for inline types

--- src/cljs/greffe/doc_comps.cljs
+++ src/cljs/greffe/doc_comps.cljs
@@ -26,7 +26,16 @@
                                  (and
                                    (contains? val :content)
                                    (contains? val :tag))
-                                 :elem
+                                 (let [el-type (get-in mk/markup [(:tag val) :type])]
+                                   (cond
+                                     (#{:container :multi-chunk :chunk} el-type)
+                                     :elem
+
+                                     (= :inner el-type)
+                                     :inner-elem
+
+                                     (= :empty el-type)
+                                     :empty-elem))

                                  true
                                  :wtf))))
@@ -36,7 +45,7 @@
   (reify
     om/IRenderState
     (render-state [_ state]
-      (dom/div nil elem))))
+      (dom/span #js {:className "xml-text-element"} elem))))

 (defmethod element-component :elem [elem owner]
   (reify
@@ -100,6 +109,22 @@
            (apply dom/div #js {:className "block-contents col-md-10"}
              (om/build-all element-component (:content elem)))))))))

+
+(defmethod element-component :inner-elem [elem owner]
+  (reify
+    om/IRender
+    (render [_]
+      (apply dom/span #js {:className (str "xml-" (name (:tag elem)) " tei-inner")}
+        (om/build-all element-component (:content elem))))))
+
+
+(defmethod element-component :empty-elem [elem owner]
+  (reify
+    om/IRender
+    (render [_]
+      (dom/span #js {:className (str "xml-" (name (:tag elem)) " tei-empty")}
+        " "))))
+
 (defmethod element-component :wtf [elem owner]
   (reify
     om/IRender


Delete pointless edit button

Delete pointless edit button

--- src/cljs/retrobard/client.cljs
+++ src/cljs/retrobard/client.cljs
@@ -248,12 +248,7 @@
                                     nil)
                       :onBlur (fn [e]
                                 (when (om/get-state owner :editing)
-                                  (end-edit text owner on-edit)))})
-                (dom/div
-                 #js {:className "edit-note-button"
-                      :style (display (not editing))
-                      :onClick #(om/set-state! owner :editing true)}
-                 "Edit"))))))
+                                  (end-edit text owner on-edit)))}))))))

 (defn note-view [app owner]
   (reify


Make button-row component, eventually expand to support broadcasting.

--- src/clum/app/components.cljs
+++ src/clum/app/components.cljs
@@ -32,6 +32,12 @@
     :value    "Play animation"
     :on-click #(ws/send-transit-msg! {:action "play-animation"})}])

+(defn broadcast-button
+  "Creates a button that will send a group of changes to the
+   server to be broadcasted to all (or some) connected clients."
+  []
+  :implement-me)
+
 (defn app-debugger
   [state]
   [:table
@@ -41,6 +47,13 @@
     [:tr
      [:td (:tick @state)]]]])

+(defn button-row
+  [state x]
+  [:div.button-row {:key x}
+   (doall
+    (for [y (range 8)]
+      (button x y state)))])
+
 (defn main-component
   [state]
   (let [{:keys [tick activity-log] :as state-value} @state]
@@ -48,10 +61,7 @@
      [:div#buttons
       (doall
        (for [x (range 8)]
-         [:div.button-row {:key x}
-          (doall
-           (for [y (range 8)]
-             (button x y state)))]))]
+         (button-row state x)))]
      ;;[anim-button]
      ;;[#(app-debugger state)]
      [:div#activity-log


Ensure post and post-delayed are macros

Ensure post and post-delayed are macros

--- src/clojure/neko/threading.clj
+++ src/clojure/neko/threading.clj
@@ -37,7 +37,7 @@
   [^View view ^IFn f]
   (.post view (reify Runnable (run [this] (f)))))

-(defn post
+(defmacro post
   "Causes the macro body to be added to the message queue.  It will execute on
   the UI thread.  Returns true if successfully placed in the message queue."
   [^View view & body]
@@ -51,7 +51,7 @@
   [^View view ^long millis  ^IFn f]
   (.postDelayed view (reify Runnable (run [this] (f))) millis ))

-(defn post-delayed
+(defmacro post-delayed
   "Causes the macro body to be added to the message queue.  It will execute on
   the UI thread.  Returns true if successfully placed in the message queue."
   [view millis & body]


http-kit/clojure: Add error messages related to starting the server.

--- src/clojure/src/dnsresolvh.clj
+++ src/clojure/src/dnsresolvh.clj
@@ -29,6 +29,11 @@
 (defmacro ERR-PORT-MUST-BE-POSITIVE-INT [](str ": <port_number> must be "
                                                "a positive integer value, "
                                                "in the range 1024-49151."))
+(defmacro ERR-CANNOT-START-SERVER       [] ": FATAL: Cannot start server ")
+(defmacro ERR-SRV-UNKNOWN-REASON        [](str "for an unknown reason. "
+                                               "Exiting..."              ))
+(defmacro ERR-SRV-PORT-IS-IN-USE        [](str "due to the port requested "
+                                               "is in use. Exiting..."   ))

 ; Print this error message when there are no any args passed.
 (defmacro ERR-MUST-BE-ONE-TWO-ARGS-1 [](str ": There must be one or two args "


Uncomment out job checking for items to delete.

--- src/cmr/metadata_db/system.clj
+++ src/cmr/metadata_db/system.clj
@@ -45,10 +45,9 @@

     (db-holder/set-db! db)

-    ;; Skipping background jobs to improve bootstrapping performance.
-    #_(when-not (or (re-find #"MemoryDB" (str (type db)))
+    (when-not (or (re-find #"MemoryDB" (str (type db)))
                   (:skip-background-jobs started-system)
-      (jobs/start db)))
+                  (jobs/start db)))

     (info "Metadata DB started")
     started-system))


CMR Hotfix: Support normalization of both strings and keywords.

--- src/cmr/opendap/query/util.clj
+++ src/cmr/opendap/query/util.clj
@@ -8,10 +8,10 @@
 (defn normalize-param
   [param]
   (-> param
-      name
+      (#(if (keyword? param) (name %) %))
       (string/replace "_" "-")
       (string/lower-case)
-      keyword))
+      (#(if (keyword? param) (keyword %) %))))

 (defn normalize-params
   [params]


Adding in description.

Adding in description.

--- src/com/okl/tokenmgr/cli.clj
+++ src/com/okl/tokenmgr/cli.clj
@@ -76,10 +76,10 @@
        "with values\n\n"
        "           load path_to_csv app -- loads in a new csv into a specified "
        "application\n\n"
-       "           export path_to_csv -- exports the entire repository into a "
-       "csv file\n\n"
-       "           import path_to_csv -- loads the entire repository from a "
-       "csv file"))
+       "           export app path_to_csv -- exports the entire repository into"
+       "a csv file\n\n"
+       "           import app path_to_csv -- loads the entire repository from a"
+       " csv file"))

 (defn- usage [parsed-opts]
   (if (:errors parsed-opts)
@@ -124,7 +124,7 @@
          (get token envt))))))

 (defn- token->value-list [token environments]
-  [(concat [(:name token)]
+  [(concat [(:name token) (:description token)]
           (map #(let [value (get (get (:values token) %) "value")]
                   (if (nil? value)
                     ""
@@ -138,7 +138,8 @@
   (let [tokens (get-tokens app)
         environments (set (flatten (map #(keys (:values %)) tokens)))]
     (with-open [wrtr (io/writer filename)]
-      (.write wrtr (csv/write-csv [(concat ["key_name"] environments)]
+      (.write wrtr (csv/write-csv [(concat ["key_name" "description"]
+                                           environments)]
                                    :delimiter delimiter))
       (doall (map #(.write wrtr
                            (csv/write-csv (token->value-list % environments)


Changing sequencer test code to use drums.

--- src/overtone/gui/sequencer.clj
+++ src/overtone/gui/sequencer.clj
@@ -5,10 +5,10 @@
   (:require [seesaw.bind :as bind]))

 (defn- make-initial-state [metro steps instruments]
-  {:playing?  false
+  {:playing?  false
    :metronome metro
    :step      0
-   :rows      (into
+   :rows      (into
                 {}
                 (for [i instruments]
                   [(:name i) (vec (repeat steps false))]))})
@@ -21,7 +21,7 @@

 (defn- step-player
   [state-atom beat steps instruments]
-  (let [state @state-atom]
+  (let [state @state-atom]
     (when (:playing? state)
       (let [metro (:metronome state)
             index (mod beat steps)
@@ -52,14 +52,14 @@
           play-btn     (button :text "play")
           bpm-spinner  (spinner :model (spinner-model (metro :bpm) :from 20 :to 300 :by 1)
                                 :maximum-size [60 :by 100])
-          step-lbls    (vec (for [i (range steps)] (label :size [25 :by 25]
+          step-lbls    (vec (for [i (range steps)] (label :size [25 :by 25]
                                                           :background "#22F"
                                                           :opaque? false
                                                           :border (line-border :color "#22A"))))
-          control-pane (toolbar :floatable? false
+          control-pane (toolbar :floatable? false
                                 :items [play-btn
                                         :separator
-                                        bpm-spinner
+                                        bpm-spinner
                                         [:fill-h 5]
                                         "bpm"])
           seq-pane     (mig-panel :constraints [(str "wrap " (inc steps)) "" ""]
@@ -79,7 +79,7 @@
                    (repaint! step-lbls)))
       (listen play-btn :action
               (fn [e]
-                (let [playing? (:playing? (swap! state-atom toggle-playing))]
+                (let [playing? (:playing? (swap! state-atom toggle-playing))]
                   (config! play-btn :text (if playing? "stop" "play"))
                   (if playing?
                     (step-player state-atom (metro) steps instruments)))))
@@ -92,7 +92,7 @@
   (use 'overtone.live)
   (use 'overtone.gui.sequencer)
   (use 'overtone.gui.control)
-  (use 'overtone.inst.synth)
+  (use 'overtone.inst.drum)
   (def m (metronome 128))
-  (step-sequencer m 8 ks1 ping)
+  (step-sequencer m 8 kick closed-hat snare)
 )


Removed old session code

Removed old session code

--- src/compojure/http/session.clj
+++ src/compojure/http/session.clj
@@ -1,243 +0,0 @@
-;; Copyright (c) James Reeves. All rights reserved.
-;; The use and distribution terms for this software are covered by the Eclipse
-;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which
-;; can be found in the file epl-v10.html at the root of this distribution. By
-;; using this software in any fashion, you are agreeing to be bound by the
-;; terms of this license. You must not remove this notice, or any other, from
-;; this software.
-
-(ns compojure.http.session
-  "Functions for creating and updating HTTP sessions."
-  (:use compojure.str-utils)
-  (:use compojure.http.helpers)
-  (:use compojure.http.request)
-  (:use compojure.http.response)
-  (:use compojure.encodings)
-  (:use compojure.crypto)
-  (:use clojure.contrib.except))
-
-;; Override these mulitmethods to create your own session storage.
-;; Uses the Compojure repository pattern.
-
-(defmulti create-session
-  "Create a new session map. Should not attempt to save the session."
-  (fn [repository] (:type repository)))
-
-(defmulti read-session
-  "Read in the session using the supplied data. Usually the data is a key used
-  to find the session in a store."
-  (fn [repository data] (:type repository)))
-
-(defmulti write-session
-  "Write a new or existing session to the session store."
-  (fn [repository session] (:type repository)))
-
-(defmulti destroy-session
-  "Remove the session from the session store."
-  (fn [repository session] (:type repository)))
-
-(defmulti session-cookie
-  "Return the session data to be stored in the cookie. This is usually the
-  session ID."
-  (fn [repository new? session] (:type repository)))
-
-;; Default implementations of create-session and set-session-cookie
-
-(defmethod create-session :default
-  [repository]
-  {:id (gen-uuid)})
-
-(defmethod session-cookie :default
-  [repository new? session]
-  (if new?
-    (session :id)))
-
-;; In memory sessions
-
-(def memory-sessions (ref {}))
-
-(defmethod read-session :memory
-  [repository id]
-  (@memory-sessions id))
-
-(defmethod write-session :memory
-  [repository session]
-  (dosync
-    (alter memory-sessions
-      assoc (session :id) session)))
-
-(defmethod destroy-session :memory
-  [repository session]
-  (dosync
-    (alter memory-sessions
-      dissoc (session :id))))
-
-;; Cookie sessions
-
-(def default-session-key
-  (delay (gen-secret-key {:key-size 128})))
-
-(defn- get-session-key
-  "Get the session key from the repository or use the default key."
-  [repository]
-  (force (repository :session-key default-session-key)))
-
-(defmethod create-session :cookie
-  [repository]
-  {})
-
-(defmethod session-cookie :cookie
-  [repository new? session]
-  (let [session-key (get-session-key repository)
-        cookie-data (seal session-key session)]
-    (if (> (count cookie-data) 4000)
-      (throwf "Session data exceeds 4K")
-      cookie-data)))
-
-(defmethod read-session :cookie
-  [repository data]
-  (unseal (get-session-key repository) data))
-
-(defmethod write-session :cookie
-  [repository session])
-
-(defmethod destroy-session :cookie
-  [repository session])
-
-;; Session middleware
-
-(defn timestamp-after
-  "Return the current time plus seconds as milliseconds."
-  [seconds]
-  (+ (* seconds 1000) (System/currentTimeMillis)))
-
-(defn assoc-expiry
-  "Associate an :expires-at key with the session if the session repository
-  contains the :expires key."
-  [repository session]
-  (if-let [expires (:expires repository)]
-    (assoc session :expires-at (timestamp-after expires))
-    session))
-
-(defn session-expired?
-  "True if this session's timestamp is in the past."
-  [session]
-  (if-let [expires-at (:expires-at session)]
-    (< expires-at (System/currentTimeMillis))))
-
-(defn- get-session
-  "Retrieve the session using the 'session' cookie in the request."
-  [repository request]
-  (if-let [session-data (-> request :cookies :compojure-session)]
-    (read-session repository session-data)))
-
-(defn- assoc-new-session
-  "Associate a new session with a request."
-  [repository request]
-  (assoc request
-    :session (assoc-expiry repository (create-session repository))
-    :new-session? true))
-
-(defn assoc-session
-  "Associate the session with the request."
-  [request repository]
-  (if-let [session (get-session repository request)]
-    (if (session-expired? session)
-      (do
-        (destroy-session repository session)
-        (assoc-new-session repository request))
-      (assoc request :session
-        (assoc-expiry repository session)))
-    (assoc-new-session repository request)))
-
-(defn assoc-flash
-  "Associate the session flash with the request and remove it from the
-  session."
-  [request]
-  (let [session (:session request)]
-    (-> request
-      (assoc :flash   (session :flash {}))
-      (assoc :session (dissoc session :flash)))))
-
-(defn set-session-cookie
-  "Set the session cookie on the response if required."
-  [repository request response session]
-  (let [new?   (:new-session? request)
-        cookie (session-cookie repository new? session)
-        update (set-cookie :compojure-session cookie
-                           :path (repository :path "/"))]
-    (if cookie
-      (update-response request response update)
-      response)))
-
-(defn save-handler-session
-  "Save the session for a handler if required."
-  [repository request response session]
-  (when (and (contains? response :session)
-             (nil? (response :session)))
-    (destroy-session repository session))
-  (when (or (:session response)
-            (:new-session? request)
-            (not-empty (:flash request))
-            (contains? repository :expires))
-    (write-session repository session)))
-
-(defn- keyword->repository
-  "If the argument is a keyword, expand it into a repository map."
-  [repository]
-  (if (keyword? repository)
-    {:type repository}
-    repository))
-
-(defn with-session
-  "Wrap a handler in a session of the specified type. Session type defaults to
-  :memory if not supplied."
-  ([handler]
-    (with-session handler :memory))
-  ([handler repository]
-    (fn [request]
-      (let [repo     (keyword->repository repository)
-            request  (-> request (assoc-cookies)
-                                 (assoc-session repo)
-                                 (assoc-flash))
-            response (handler request)
-            session  (if (contains? response :session)
-                       (:session response)
-                       (:session request))]
-        (when response
-          (save-handler-session repo request response session)
-          (set-session-cookie   repo request response session))))))
-
-;; Useful functions for modifying the session
-
-(defn set-session
-  "Return a response map with the session set."
-  [session]
-  {:session session})
-
-(defn clear-session
-  "Set the session to nil."
-  []
-  (set-session nil))
-
-(defn alter-session
-  "Use a function to alter the session."
-  [func & args]
-  (fn [request]
-    (set-session
-      (apply func (request :session) args))))
-
-(defn session-assoc
-  "Associate key value pairs with the session."
-  [& keyvals]
-  (apply alter-session assoc keyvals))
-
-(defn session-dissoc
-  "Dissociate keys from the session."
-  [& keys]
-  (apply alter-session dissoc keys))
-
-(defn flash-assoc
-  "Associate key value pairs with the session flash."
-  [& keyvals]
-  (alter-session merge {:flash (apply hash-map keyvals)}))


Reset filter input to empty string

Reset filter input to empty string

--- src/day8/re_frame/trace.cljs
+++ src/day8/re_frame/trace.cljs
@@ -128,7 +128,9 @@
                :auto-focus  true
                :on-change   #(reset! val (-> % .-target .-value))
                :on-key-down #(case (.-which %)
-                               13 (save)
+                               13 (do
+                                    (save)
+                                    (reset! val ""))
                                nil)}])))

 (defn render-traces []


Missed off the last commit.

Missed off the last commit.

--- Clojure/seven_lang/src/seven_lang/core.clj
+++ Clojure/seven_lang/src/seven_lang/core.clj
@@ -1,10 +1,14 @@
 (ns seven-lang.core
-  (require seven-lang.dayone))
+  (require seven-lang.dayone)
+  (require seven-lang.daytwo)
+  )

 (defn hello
   "simple hello world"
   []
   (println "Hello there clojure"))
+
+

 (defn run
   "runs today's exercises"
@@ -17,6 +21,11 @@
     (seven-lang.dayone/collection-type ["Light Arrows", "Fire Arrows", "Ice Arrows"]))
   (println
     (seven-lang.dayone/collection-type {:dodongo "Bomb", :keese "Hookshot"}))
+  (seven-lang.daytwo/unless false (println "true!"))
+  (seven-lang.daytwo/unless true (println "true!"))
+  (seven-lang.daytwo/unlesselse true (println "true!") (println "false!"))
+  (seven-lang.daytwo/unlesselse false (println "true!") (println "false!"))
+  (seven-lang.daytwo/test-things)
   )

 (run)


Add frozen pattern and regex

Add frozen pattern and regex

--- src/degasolv/resolver_spec.clj
+++ src/degasolv/resolver_spec.clj
@@ -73,6 +73,7 @@
            ::package
            :into [])))

+(def str-equals-pattern "==")
 (def str-relation-pattern "(>=|==|!=|<=|<|>)")
 (def str-id-pattern "[^>=<!;,|]+")
 (def str-version-predicate-pattern
@@ -89,6 +90,7 @@
     "(;"
     str-version-conj-predicate-pattern
     ")*"))
+
 (def str-alternative-pattern
   (str
     "!?"
@@ -110,5 +112,19 @@
    str-requirement-pattern
    "$")))

+(def str-frozen-pattern
+  (str
+    str-id-pattern
+    "=="
+    str-version-pattern))
+
+(def str-frozen-regex
+  (re-pattern
+    (str
+      "^"
+      str-frozen-pattern
+      "$")))
+
 (s/def ::requirement-string
        #(re-matches str-requirement-regex %))
+


Update to ClojureScript 0.0-2843

Update to ClojureScript 0.0-2843

--- ClojureScript/project.clj
+++ ClojureScript/project.clj
@@ -1,7 +1,7 @@
 (defproject shrimp "0.1.0-SNAPSHOT"
             :description "Demo project for Goby."
             :dependencies [[org.clojure/clojure "1.6.0"]
-                           [org.clojure/clojurescript "0.0-2760"]
+                           [org.clojure/clojurescript "0.0-2843"]
                            [org.clojure/core.async "0.1.346.0-17112a-alpha"]
                            [goby "0.1.0"]
                            [weasel "0.5.0"]]


Job data fetcher should be started from the main thread

--- src/emender_jenkins/core.clj
+++ src/emender_jenkins/core.clj
@@ -18,11 +18,12 @@

 (require '[clojure.tools.cli       :as cli])

-(require '[emender-jenkins.server       :as server])
-(require '[emender-jenkins.results      :as results])
-(require '[emender-jenkins.config       :as config])
-(require '[emender-jenkins.middleware   :as middleware])
-(require '[emender-jenkins.process-info :as process-info])
+(require '[emender-jenkins.server           :as server])
+(require '[emender-jenkins.results          :as results])
+(require '[emender-jenkins.config           :as config])
+(require '[emender-jenkins.middleware       :as middleware])
+(require '[emender-jenkins.process-info     :as process-info])
+(require '[emender-jenkins.job-data-fetcher :as job-data-fetcher])

 (def cli-options
     "Definitions of all command line options that are  currenty supported."
@@ -181,6 +182,7 @@
                  (config/load-configuration-from-ini "config.ini")
                  (config/override-options-by-cli jenkins-url test-jobs-suffix))]
             (results/reload-all-results configuration)
+            (job-data-fetcher/run-fetcher-in-thread (-> configuration :fetcher :delay))
             (start-server configuration (get-port port) openshift-port openshift-ip))))

 (defn -main


CMR-603: Added additional test cases and fixed the original one I added.


Add pointless variable

Add pointless variable


Ignore duplicate exceptions from aws

Ignore duplicate exceptions from aws

--- src/shuppet/securitygroups.clj
+++ src/shuppet/securitygroups.clj
@@ -15,6 +15,13 @@
 (def ^:const ^:private ec2-url (env :service-aws-ec2-url))
 (def ^:const ^:private ec2-version (env :service-aws-ec2-api-version))

+(defn- acceptable-error?
+  [action status body];AWS sometimes doesnt return all the ip ranges!!!
+  (and
+   (or (= action "AuthorizeSecurityGroupIngress") (= action "AuthorizeSecurityGroupEgress"))
+   (= status 400)
+   (= "InvalidPermission.Duplicate" (xml1-> body :Errors :Error :Code text))))
+
 (defn- get-request
   [params]
   (let [url (v2-url ec2-url (merge {"Version" ec2-version} params))
@@ -24,7 +31,9 @@
         body (-> (:body response)
                  (xml/parse)
                  (zip/xml-zip))]
-    (if (= 200 status)
+    (if (or
+         (= 200 status)
+         (acceptable-error? (get params "Action") status body))
       body
       (throw-aws-exception "EC2" (get params "Action") url status body))))

@@ -132,8 +141,8 @@
 (defn- compare-sg
   [sg-id aws local]
   (let [remote (build-config aws)
-        ingress (compare-config  (set (:Ingress local)) (set (:Ingress remote)))
-        egress  (compare-config (set (:Egress local)) (set (:Egress remote)))]
+        ingress (compare-config  (:Ingress local) (:Ingress remote))
+        egress  (compare-config (:Egress local) (:Egress remote))]
     (ensure-ingress (:GroupName local) sg-id ingress)
     (ensure-egress (:GroupName local) sg-id egress)))


Avoid need for catch block

Avoid need for catch block

--- src/irresponsible/overload.clj
+++ src/irresponsible/overload.clj
@@ -73,11 +73,8 @@
         in case of other, the class, primitive or var named"
   [sym]
   (when-let [[t v :as all] (-> sym str about)]
-    (letfn [(overload' [sym]
-              (try (resolve sym)
-                   (catch Exception e nil)))
-            (symbol' [sym]
-              (when-let [r (overload' sym)]
+    (letfn [(symbol' [sym]
+              (when-let [r (try (resolve sym))]
                   (cond (var? r)   [:var r]
                         (class? r) [:class r]
                         :otherwise nil)))]


keyboard-key

keyboard-key

--- informing/src/app/core.cljs
+++ informing/src/app/core.cljs
@@ -37,12 +37,12 @@
           :viewport {:width nil :height nil}
           }
     :ech {:dom-viewport-resize nil
-          :env-key-press nil
+          :env-keyboard-key nil
           :env-mouse-down nil
           :env-mouse-move nil
           :env-mouse-up nil
           }
-    :env {:key-press nil
+    :env {:keyboard-key nil
           :mouse-down nil
           :mouse-move nil
           :mouse-up nil
@@ -78,8 +78,7 @@
     (swap-event-channel!
      :dom-viewport-resize (poly/channel-for-viewport-resize!))
     (swap-event-channel!
-;     :env-key-press (poly/listen-put! (poly/get-body) :key-press (poly/keyboard-e-chan)))
-     :env-key-press (poly/listen-put! js/window :key-press (poly/keyboard-e-chan)))
+     :env-keyboard-key (poly/listen-put! js/window :key (poly/keyboard-e-chan)))
     (swap-event-channel!
      :env-mouse-down (poly/listen-put! js/window :mouse-down (poly/mouse-e-chan)))
     (swap-event-channel!
@@ -127,8 +126,8 @@
 (defonce rc-dom-viewport-w
   (cc-dom [:viewport :width]))

-(defonce rc-env-key-press
-  (cc-env [:key-press]))
+(defonce rc-env-keyboard-key
+  (cc-env [:keyboard-key]))

 (defonce rc-env-mouse-down
   (cc-env [:mouse-down]))
@@ -165,8 +164,8 @@
 (defn mutate-env-time! []
   (reset! rc-env-time (poly/js-now)))

-(defn mutate-env-key-press! [m]
-  (reset! rc-env-key-press m))
+(defn mutate-env-keyboard-key! [m]
+  (reset! rc-env-keyboard-key m))

 (defn mutate-env-mouse-down! [m]
   (reset! rc-env-mouse-down m))
@@ -190,8 +189,8 @@
 (defn on-dom-window-load [e]
   (mutate-dom-viewport-size! (poly/get-viewport-width) (poly/get-viewport-height)))

-(defn on-env-key-press [m]
-  (mutate-env-key-press! m))
+(defn on-env-keyboard-key [m]
+  (mutate-env-keyboard-key! m))

 (defn on-env-mouse-down [m]
   (mutate-env-mouse-down! m))
@@ -215,7 +214,7 @@
 (defonce setup-event-take-backs!
   (do
     (poly/take-back! (get-event-channel :dom-viewport-resize) on-dom-viewport-resize)
-    (poly/take-back! (get-event-channel :env-key-press) on-env-key-press)
+    (poly/take-back! (get-event-channel :env-keyboard-key) on-env-keyboard-key)
     (poly/take-back! (get-event-channel :env-mouse-down) on-env-mouse-down)
     (poly/take-back! (get-event-channel :env-mouse-move) on-env-mouse-move)
     (poly/take-back! (get-event-channel :env-mouse-up) on-env-mouse-up)
@@ -346,7 +345,7 @@
     [:p "Document height " rc-dom-document-h "px"]
 ;    [:p "Document scroll " rc-dom-document-scroll-x " by " rc-dom-document-scroll-y]
 ;    [:p "Mouse position " "(" rc-env-mouse-pos-x ", " rc-env-mouse-pos-y ")"]
-    [:p "Key Press " (rx (str (into (sorted-map) @rc-env-key-press)))]
+    [:p "Keyboard Key " (rx (str (into (sorted-map) @rc-env-keyboard-key)))]
     [:p "Mouse Move " (rx (str (into (sorted-map) @rc-env-mouse-move)))]
     [:p "Mouse Down " (rx (str (into (sorted-map) @rc-env-mouse-down)))]
     [:p "Mouse Up " (rx (str (into (sorted-map) @rc-env-mouse-up)))]


updated

updated

--- src/hivewing_core/worker.clj
+++ src/hivewing_core/worker.clj
@@ -50,7 +50,7 @@
   [{apiary-uuid :apiary_uuid hive-uuid :hive_uuid :as parameters}]
   (let [clean-params (assoc parameters
                             :hive_uuid (ensure-uuid hive-uuid))]
-    :apiary_uuid (ensure-uuid apiary-uuid)
+                            :apiary_uuid (ensure-uuid apiary-uuid)
     (first (jdbc/insert! sql-db :workers clean-params))))

 (defn worker-join-hive


Documentation for previous functions

Documentation for previous functions

--- src/wishlistd/models/redis.clj
+++ src/wishlistd/models/redis.clj
@@ -14,14 +14,16 @@
         code))))

 (defn create-wishlist [wishlist]
+  "Gets a fresh code and adds the wishlist to the datastore."
   (let [code (new-code)
         with-code (assoc wishlist :code code)
         as-json (encode with-code)]
     (r/with-server db
       (r/set code as-json))
-    code))
+    code)) ; return the code

 (defn read-wishlist [code]
+  "Get a single wishlist from datastore."
   (r/with-server db
     (decode
       (r/get code))))


Remove console clutter

Remove console clutter

--- src/kixi/hecuba/web/amon.clj
+++ src/kixi/hecuba/web/amon.clj
@@ -94,8 +94,6 @@

   :handle-created
   (fn [{{routes :jig.bidi/routes {entity-id :amon/entity-id} :route-params} :request device-id :amon/device-id}]
-    (println {:amon/entity-id entity-id
-              :amon/device-id (str device-id)})
     (let [location
           (path-for routes (:device @handlers)
                     :amon/entity-id entity-id


Fix file path normalization

Fix file path normalization

--- src/lein_typescript/core.clj
+++ src/lein_typescript/core.clj
@@ -23,8 +23,8 @@

 (defn- clean-path [p]
   (if os/windows?
-    (string/replace p #"/" "\\")
-    (string/replace p #"\\" "/")))
+    (string/replace p "/" "\\")
+    (string/replace p "\\" "/")))

 (defn- to-coll [e] (if (nil? e) [] (if (sequential? e) e [e])))
 (defn- scan-files [patterns] (set (mapcat fs/glob (map clean-path patterns))))


Fix on-val binding name

Fix on-val binding name

--- src/onyx/peer/virtual_peer.clj
+++ src/onyx/peer/virtual_peer.clj
@@ -76,11 +76,11 @@
         high-water-ratio (/ high-water-pct 100)]
     (while (not (Thread/interrupted))
       (let [ratio (/ (count buf) (.n buf))
-            on-val? @on?]
+            on-val @on?]
         (cond (and (not on-val) (> ratio high-water-ratio))
-              (do (reset! on-val? true)
+              (do (reset! on-val true)
                   (>!! outbox-ch (create-log-entry :backpressure-on {:peer id})))
-              (and on-val? (< ratio low-water-ratio))
+              (and on-val (< ratio low-water-ratio))
               (do (reset! on? false)
                   (>!! outbox-ch (create-log-entry :backpressure-off {:peer id})))))
       (Thread/sleep check-interval))))


optimize function case of with-meta

optimize function case of with-meta

--- src/main/cljs/cljs/core.cljs
+++ src/main/cljs/cljs/core.cljs
@@ -1795,7 +1795,7 @@
   "Returns an object of the same type and value as obj, with
   map m as its metadata."
   [o meta]
-  (if (and (fn? o) (not (satisfies? IWithMeta o)))
+  (if ^boolean (goog/isFunction o)
     (MetaFn. o meta)
     (when-not (nil? o)
       (-with-meta o meta))))


Add indexed position query.

Add indexed position query.

--- src/cavm/h2.clj
+++ src/cavm/h2.clj
@@ -11,7 +11,7 @@
   (:require [honeysql.format :as hsqlfmt])
   (:require [honeysql.types :as hsqltypes])
   (:require [clojure.data.json :as json])
-  (:use [cavm.binner :only (calc-bin)])
+  (:require [cavm.binner :refer [calc-bin overlapping-bins]])
   (:use [clj-time.format :only (formatter unparse)])
   (:use [cavm.hashable :only (ahashable)])
   (:require [cavm.db :refer [XenaDb]])
@@ -1139,6 +1139,29 @@
 (defn fetch-genes [field-id values]
   (into (sorted-set) (field-genes field-id values)))

+; position
+
+(def ^:private field-position-one-query
+  (cached-statement
+    "SELECT `row` FROM `field_position`
+    WHERE `field_id` = ? AND `chrom` = ? AND
+    (`bin` >= ? AND `bin` <= ?) AND `chromStart` <= ? AND `chromEnd` >= ?"
+    true))
+
+; [:in "position" [["chr17" 100 20000]]]
+(defn field-position [field-id values]
+  (->>
+    (mapcat (fn [[chr start end]]
+              (let [istart (int start)
+                    iend (int end)
+                    bins (overlapping-bins istart iend)]
+                (mapcat (fn [[s e]] (field-position-one-query field-id chr s e iend istart)) bins)))
+            values)
+    (map :row)))
+
+(defn fetch-position [field-id values]
+  (into (sorted-set) (field-position field-id values)))
+
 ; fetch-indexed doesn't cache, and it's unclear
 ; if we should cache the indexed fields during 'restrict'.
 ; h2 also has caches, so it might be better to rely on them,
@@ -1151,8 +1174,8 @@
 (defn fetch-indexed [fields field values]
   (let [field-id (fields field)]
     (cond
-      (has-position? field-id) #{}) ; XXX fix this! Maybe should be a bin query?
-      (has-genes? field-id) (fetch-genes field-id values)))
+      (has-position? field-id) (fetch-position field-id values)
+      (has-genes? field-id) (fetch-genes field-id values))))

 ;
 ; sql eval methods


Including the java class

Including the java class

--- src/civs/io.clj
+++ src/civs/io.clj
@@ -20,6 +20,7 @@
   (:use clojure.java.io))

 (import '(com.github.lands.World))
+(import '(com.github.langgen.Language))
 (import '(com.github.lands.IncorrectFileException))
 (import '(java.io.IOException))


Fixed type (bzip_rot -> zip_rot, thanks Kyle).

--- src/clojush.clj
+++ src/clojush.clj
@@ -441,7 +441,7 @@
 (define-registered float_rot (rotter :float))
 (define-registered code_rot (rotter :code))
 (define-registered boolean_rot (rotter :boolean))
-(define-registered bzip_rot (rotter :zip))
+(define-registered zip_rot (rotter :zip))

 (defn flusher
   "Returns a function that empties the stack of the given state."


whitespace

whitespace

--- src/polismath/conversation.clj
+++ src/polismath/conversation.clj
@@ -63,7 +63,7 @@
      :proj  (plmb/fnk [mat pca]
                       (pca-project mat pca))

-   :base-clusters
+     :base-clusters
           (plmb/fnk [conv rating-mat proj opts']
            (sort-by :id
             (kmeans (assoc rating-mat :matrix proj)
@@ -71,7 +71,7 @@
                 :last-clusters (:base-clusters conv)
                 :cluster-iters (:base-iters opts'))))

-    :group-clusters
+     :group-clusters
         (plmb/fnk [conv rating-mat base-clusters opts']
           (sort-by :id
           (kmeans
@@ -89,7 +89,7 @@
                 group-clusters
                 base-clusters))))

-   :bid-to-pid
+     :bid-to-pid
            (plmb/fnk [base-clusters]
              (map :members(sort-by :id (:base-clusters base-clusters))))
      }))


Fix RAF bind on Node

Fix RAF bind on Node

--- src/reagent/impl/batching.cljs
+++ src/reagent/impl/batching.cljs
@@ -14,15 +14,15 @@
   (js/setTimeout f 16))

 (def next-tick
-  (.bind (if-not is-client
-           fake-raf
-           (let [w js/window]
-             (or (.-requestAnimationFrame w)
+  (if-not is-client
+    fake-raf
+    (let [w js/window]
+      (.bind (or (.-requestAnimationFrame w)
                  (.-webkitRequestAnimationFrame w)
                  (.-mozRequestAnimationFrame w)
                  (.-msRequestAnimationFrame w)
-                 fake-raf)))
-         js/window))
+                 fake-raf)
+             w))))

 (defn compare-mount-order
   [^clj c1 ^clj c2]


fix ^:dev/always ns meta not propagating to the client properly

so files marked to always reload didn't reload when in jars.

fixes #462

--- src/main/shadow/cljs/devtools/server/worker/impl.clj
+++ src/main/shadow/cljs/devtools/server/worker/impl.clj
@@ -180,6 +180,7 @@
   "for every cljs build source collect all defs that are marked with special metadata"
   [{:keys [build-sources] :as build-state}]
   (-> {:never-load #{}
+       :always-load #{}
        :after-load []
        :before-load []}
       (reduce->
@@ -215,7 +216,12 @@
               (or (:dev/never-load meta)
                   (:dev/once meta) ;; can't decide on which meta to use
                   (:figwheel-noload meta))
-              (update :never-load conj name))
+              (update :never-load conj name)
+
+              (or (:dev/always-load meta)
+                  (:dev/always meta)
+                  (:figwheel-always meta))
+              (update :always-load conj name))

             (reduce-kv->
               (fn [info def-sym {:keys [name meta] :as def-info}]


Choose push instructions more than bindings

--- src/search/algorithms/push.clj
+++ src/search/algorithms/push.clj
@@ -11,12 +11,11 @@

 (defnk-fn ->instruction :- s/Any
   "Returns a random push instruction from those defined in the `push-interpreter`
-   and the bindings names. Choose a push instruction half the time and a bindings
-   half the time, if any exist`"
+   and the bindings names.`"
   [interpreter]
   []
   (let [bindings (push/binding-names interpreter)]
-    (-> {(push/known-instructions interpreter) 1
+    (-> {(push/known-instructions interpreter) 5
          bindings (if (empty? bindings) 0 1)}
       clojure.data.generators/weighted
       clojure.data.generators/rand-nth)))


Cleaning up

Cleaning up

--- src/shuppet/securitygroups.clj
+++ src/shuppet/securitygroups.clj
@@ -5,7 +5,8 @@
    [clojure.tools.logging :as log]
    [clojure.xml :as xml]
    [clojure.zip :as zip]
-   [clojure.data.zip.xml :refer [xml1-> attr xml-> text text= attr=]]))
+   [clojure.data.zip.xml :refer [xml1-> text]]))
+

 (defn- xml-to-map [xml-string]
   (zip/xml-zip (xml/parse (java.io.ByteArrayInputStream. (.getBytes xml-string)))))
@@ -15,10 +16,18 @@
          params
          (for [[k v] params :when (nil? v)] k)))

-(defn in?
+(defn- in?
   "true if seq contains element"
   [seq element]
   (some #(= element %) seq))
+
+(defn list-to-member [prefix list]
+  (apply hash-map (flatten (map #(do [(str prefix ".member." %1) %2]) (iterate inc 1) list))))
+
+(defn- build-network-params [index [k v]]
+  (if (= (name k) "IpRanges")
+    {(str "IpPermissions." index ".IpRanges.1.CidrIp") v}
+    {(str "IpPermissions." index "." (name k)) v}))

 (defn- process-list-of-maps [func opts]
   (loop [count (count opts)
@@ -38,7 +47,7 @@
   (assoc opts :IpRanges val))

 (defn- first-level [sub-key opts]
- (map #(nested-level opts %1) (get opts sub-key)))
+  (map #(nested-level opts %1) (get opts sub-key)))

 (defn- expand [opts key sub-key]
   (flatten (map #(first-level sub-key %1) (get opts key))))
@@ -46,7 +55,7 @@
 (defn- compare-config
   "Returns a list of two vectors
    First vector is what is present in the remote config , which are not present in the local config
-   and the second vector element is otherwise"
+   and the second vector is those present in the local config, which are not applied to the aws config yet"
   [local remote]
   (concat (list (vec (filter #(not (in? (set local) %)) (set remote))))
           (list (vec (filter #(not (in? (set remote) %)) (set local))))))
@@ -59,21 +68,10 @@
 (defn- create
   "Creates a security group and returns the id"
   [opts]
-  (let [cr-params (create-params opts)]
-    (if-let [response (ec2-request (merge cr-params {"Action" "CreateSecurityGroup"}))]
+  (let [params (create-params opts)]
+    (if-let [response (ec2-request (merge params {"Action" "CreateSecurityGroup"}))]
       (do
-        (first (xml-> (xml-to-map response) :groupId text))))))
-
-
-(defn process [action params]
-  (condp = (keyword action)
-    :CreateSecurityGroup (create params)
-    (ec2-request (merge params {"Action" (name action)}))))
-
-(defn- build-network-params [index [k v]]
-  (if (= (name k) "IpRanges")
-    {(str "IpPermissions." index ".IpRanges.1.CidrIp") v}
-    {(str "IpPermissions." index "." (name k)) v}))
+        (xml1-> (xml-to-map response) :groupId text)))))

 (defn- network-action [sg-id opts action]
   (let [params (process-list-of-maps build-network-params opts)]
@@ -81,11 +79,18 @@

 (defn- configure-network [sg-id opts]
   (when-let [ingress (expand opts :Ingress :IpRanges)]
-    (network-action sg-id ingress "AuthorizeSecurityGroupIngress"))
+    (network-action sg-id ingress :AuthorizeSecurityGroupIngress))
   (when-let [egress (expand opts  :Egress :IpRanges)]
-    (network-action sg-id egress "AuthorizeSecurityGroupEgress")))
+    (network-action sg-id egress :AuthorizeSecurityGroupEgress)))
+
+(defn- delete-sg [sg-name]
+  (let [response (xml-to-map (process :DescribeSecurityGroups {"Filter.1.Name" "group-name"
+                                                               "Filter.1.Value" sg-name} ))]
+    (if-let [sg-id (xml1-> response :securityGroupInfo :item :groupId text) ]
+      (process :DeleteSecurityGroup {"GroupId" sg-id}))))

 (defn- build-sg [opts]
+  (delete-sg (get opts :GroupName))
   (if-let [sg-id (create opts)]
     (configure-network sg-id opts)
     (prn "security group already exists")))
@@ -98,48 +103,49 @@
    "Filter.3.Name" "description"
    "Filter.3.Value" (get opts :GroupDescription)})

-(defn- network-map [params]
-  (remove-nil {:IpProtocol (first (xml-> params :ipProtocol text))
-               :FromPort (first (xml-> params :fromPort text))
-               :ToPort (first (xml-> params :toPort text))
+(defn- network-config [params]
+  (remove-nil {:IpProtocol (xml1-> params :ipProtocol text)
+               :FromPort (xml1-> params :fromPort text)
+               :ToPort (xml1-> params :toPort text)
                :IpRanges (vec (xml-> params :ipRanges :item :cidrIp text))}))

-(defn- build-config-map [opts]
-  (let [ingress (map network-map (xml-> opts :securityGroupInfo :item :ipPermissions :item))
-        egress (map network-map (xml-> opts :securityGroupInfo :item :ipPermissionsEgress :item))]
-    {:Ingress (vec ingress)
-     :Egress (vec egress)}))
+(defn- build-config [opts]
+  {:Ingress (vec (map network-config (xml-> opts :securityGroupInfo :item :ipPermissions :item)))
+   :Egress (vec (map network-config (xml-> opts :securityGroupInfo :item :ipPermissionsEgress :item)))})

 (defn- balance-ingress [sg-id opts]
   (let [revoke-config (nth opts 0)
         add-config (nth opts 1)]
     (when-not (empty? add-config)
-      (network-action sg-id add-config "AuthorizeSecurityGroupIngress"))
+      (network-action sg-id add-config :AuthorizeSecurityGroupIngress))
     (when-not (empty? revoke-config)
-      (network-action sg-id revoke-config "RevokeSecurityGroupIngress"))))
+      (network-action sg-id revoke-config :RevokeSecurityGroupIngress))))

 (defn- balance-egress [sg-id opts]
   (let [revoke-config (nth opts 0)
         add-config (nth opts 1)]
     (when-not (empty? add-config)
-      (network-action sg-id add-config "AuthorizeSecurityGroupEgress"))
+      (network-action sg-id add-config :AuthorizeSecurityGroupEgress))
     (when-not (empty? revoke-config)
-      (network-action sg-id revoke-config "RevokeSecurityGroupEgress"))))
+      (network-action sg-id revoke-config :RevokeSecurityGroupEgress))))

 (defn- compare-sg [sg-id aws local]
-  (let [remote (build-config-map aws)
+  (let [remote (build-config aws)
         ingress (compare-config  (expand local :Ingress :IpRanges) (expand remote :Ingress :IpRanges))
         egress  (compare-config  (expand local :Egress :IpRanges) (expand remote :Egress :IpRanges))]
     (balance-ingress sg-id ingress)
     (balance-egress sg-id egress)))

+(defn- process [action params]
+  (condp = (keyword action)
+    :CreateSecurityGroup (create params)
+    (ec2-request (merge params {"Action" (name action)}))))

-
-(defn ensure [opts]
-;describe security group
-;if not present create and apply ingress/outgress
-;if present compare with the config
-                                        ;delete if needed
+(defn ensure
+  "Describe the security security group
+   if not present create and apply ingress/outgress
+   if present compare with the local config and apply changes if needed"
+  [opts]
   (let [response (xml-to-map (process :DescribeSecurityGroups (filter-params opts)))]
     (if-let [sg-id (first (xml-> response :securityGroupInfo :item :groupId text)) ]
       (compare-sg sg-id response opts)


Replaced calls to println with debug

Replaced calls to println with debug

--- desktop/src-common/escape_game/core.clj
+++ desktop/src-common/escape_game/core.clj
@@ -52,12 +52,12 @@
           (do (set-screen! escape-game-game main-screen)
               nil)
           (= (:key screen) (key-code :c))
-          (do (println (count entities) (count (:inventory screen)))
+          (do (debug (count entities) (count (:inventory screen)))
               nil)
           (= (:key screen) (key-code :r))
           (do (room->entities (:current-room screen) rooms))
           ;; (= (:key screen) (key-code :s))
-          ;; (do (input! :get-text-input #(println %) "Spawn item" "text" "hint")
+          ;; (do (input! :get-text-input #(debug %) "Spawn item" "text" "hint")
           ;;     nil)
           (= (:key screen) (key-code :q))
           (do (app! :exit)
@@ -125,7 +125,7 @@
           (do (set-screen! escape-game-game main-screen)
               nil)
           (= (:key screen) (key-code :c))
-          (do (println (count entities) (count (:inventory screen)))
+          (do (debug (count entities) (count (:inventory screen)))
               nil)
           (= (:key screen) (key-code :q))
           (do (app! :exit)


Add TTL

Add TTL

--- src/uuuurrrrllll/cassandra.clj
+++ src/uuuurrrrllll/cassandra.clj
@@ -18,7 +18,7 @@

 (defn add-text! [text]
   (let [short-code (gen-short-url 7)]
-    (insert pastes {:short_code short-code :message text})
+    (insert pastes {:short_code short-code :message text} (using :ttl 3600))
     short-code))

 (defn get-entry [short]


Reorder ns.

Reorder ns.

--- src/onyx/messaging/aeron.clj
+++ src/onyx/messaging/aeron.clj
@@ -5,11 +5,11 @@
               [onyx.messaging.acking-daemon :as acker]
               [onyx.compression.nippy :refer [compress decompress]]
               [onyx.extensions :as extensions])
-    (:import [uk.co.real_logic.aeron.driver MediaDriver]
-             [uk.co.real_logic.aeron Aeron]
+    (:import [uk.co.real_logic.aeron Aeron]
              [uk.co.real_logic.aeron Aeron$Context]
              [uk.co.real_logic.agrona.concurrent UnsafeBuffer]
              [uk.co.real_logic.agrona CloseHelper]
+             [uk.co.real_logic.aeron.driver MediaDriver]
              [uk.co.real_logic.aeron.common.concurrent.logbuffer DataHandler]
              [uk.co.real_logic.aeron.common BackoffIdleStrategy]
              [java.util.function Consumer]


Twitter streaming kinda working.

Twitter streaming kinda working.

--- src/orbitingnews/twitter.clj
+++ src/orbitingnews/twitter.clj
@@ -1,6 +1,6 @@
 (ns orbitingnews.twitter
   (:require [orbitingnews.config :as config])
-  (:import [twitter4j TwitterFactory Query QueryResult]
+  (:import [twitter4j TwitterFactory TwitterStreamFactory StreamListener StatusListener Query QueryResult FilterQuery]
            [twitter4j.auth AccessToken])
   (:gen-class))

@@ -19,6 +19,42 @@
       (.setOAuthAccessToken access-token))
     twitter))

+(defn- oauth-stream
+  "Create a twitter client with OAuth authentication"
+  []
+  (let [access-token (AccessToken. *access-token* *access-secret*)
+        twitter (.getInstance (TwitterStreamFactory.))]
+    (doto twitter
+      (.setOAuthConsumer *consumer-key* *consumer-secret*)
+      (.setOAuthAccessToken access-token))
+    twitter))
+
+(defn status-listener []
+  "Implementation of twitter4j's StatusListener interface"
+  (proxy [StatusListener] []
+    (onStatus [^twitter4j.Status status] (println (.getText status)))
+    (onException [^java.lang.Exception e] (.printStackTrace e))
+    (onDeletionNotice [^twitter4j.StatusDeletionNotice statusDeletionNotice] ())
+    (onScrubGeo [userId upToStatusId] ())
+    (onTrackLimitationNotice [numberOfLimitedStatuses] ())))
+
+(defn do-sample-stream []
+  (let [stream (oauth-stream)]
+    (.addListener stream (status-listener))
+    (.sample stream)))
+
+(defn do-filter-stream []
+  ; We want tweets with the word tweet in them
+  (let [filter-query (FilterQuery. 0 (long-array []) (into-array String ["#ChristianChavezNoRaulGil"]))
+        stream (oauth-stream)]
+    (.addListener stream (status-listener))
+    (.filter stream filter-query)))
+
+(defn link-stream []
+  (let [stream (oauth-stream)]
+    (.addListener stream (status-listener))
+    (.links stream 0)))
+
 (defn search
   "Returns tweets from search"
   [query-string]


update pitch fns - improve REVERSE-NOTES, add canonical-pitch-class-name and also add match-note

--- src/overtone/music/pitch.clj
+++ src/overtone/music/pitch.clj
@@ -4,7 +4,8 @@
           intervals, etc."
      :author "Jeff Rose, Sam Aaron & Marius Kempe"}
   overtone.music.pitch
-  (:use [overtone.util old-contrib]
+  (:use [clojure.string :only [capitalize]]
+        [overtone.util old-contrib]
         [overtone.algo chance])
   (:require [clojure.string :as string]))

@@ -87,16 +88,44 @@
             :G# 8  :g# 8  :Ab 8  :ab 8  :AB 8  :aB 8
             :A  9  :a  9
             :A# 10 :a# 10 :Bb 10 :bb 10 :BB 10 :bB 10
-            :B  11 :b  11 :Cb 11 :cb 11 :CB 11 :cB 11
-})
+            :B  11 :b  11 :Cb 11 :cb 11 :CB 11 :cB 11})

 (def REVERSE-NOTES
-  (into {} (map (fn [[k v]] [v k]) NOTES)))
+  {0 :C
+   1 :C#
+   2 :D
+   3 :Eb
+   4 :E
+   5 :F
+   6 :F#
+   7 :G
+   8 :Ab
+   9 :A
+   10 :Bb
+   11 :B})
+
+(defn canonical-pitch-class-name
+  "Returns the canonical version of the specified pitch class pc."
+  [pc]
+  (let [pc (keyword (name pc))]
+      (REVERSE-NOTES (NOTES pc))))

 (def MIDI-NOTE-RE-STR "([a-gA-G][#bB]?)([-0-9]+)" )
 (def MIDI-NOTE-RE (re-pattern MIDI-NOTE-RE-STR))
 (def ONLY-MIDI-NOTE-RE (re-pattern (str "\\A" MIDI-NOTE-RE-STR "\\Z")))

+(defn- parse-note-match
+  "Takes a match array returned by a regexp match and returns a map of note info"
+  [match]
+  (let [[match pitch-class octave] match
+        pitch-class                (canonical-pitch-class-name pitch-class)
+        octave                     (Integer. octave)
+        interval                   (NOTES (keyword pitch-class))]
+    {:match       match
+     :pitch-class pitch-class
+     :octave      (Integer. octave)
+     :interval    interval
+     :midi-note   (octave-note octave interval)}))

 (defn note
   "Resolves note to MIDI number format. Resolves upper and lower-case keywords
@@ -119,25 +148,38 @@
    (integer? n) (if (>= n 0)
                     n
                     (throw (IllegalArgumentException.
-                            (str "Unable to resolve note: " n ". Value is out of range. Lowest value is 0"))))
+                            (str "Unable to resolve note: "
+                                 n
+                                 ". Value is out of range. Lowest value is 0"))))
    (keyword? n) (note (name n))
-   (string? n) (let [separated (re-find ONLY-MIDI-NOTE-RE n)
-                        _ (when (nil? separated)
-                            (throw (IllegalArgumentException.
-                                    (str "Unable to resolve note: " n ". Does not appear to be in MIDI format i.e. C#4"))))
-
-                        [_ pitch-class octave] separated
-                        octave (Integer. octave)
-                        _ (when (< octave -1)
-                            (throw (IllegalArgumentException.
-                                    (str "Unable to resolve note: " n ". Octave is out of range. Lowest octave value is -1"))))
-                        interval (NOTES (keyword (string/lower-case pitch-class)))
-
-                        _ (when (nil? interval)
-                            (throw (IllegalArgumentException.
-                                    (str "Unable to resolve note: " n ". Not a valid pitch class such as C or Db"))))]
-                    (+ interval 12 (* 12 octave)))
+   (string? n) (let [match (re-find ONLY-MIDI-NOTE-RE n)
+                     _ (when (nil? match)
+                         (throw (IllegalArgumentException.
+                                 (str "Unable to resolve note: "
+                                      n
+                                      ". Does not appear to be in MIDI format i.e. C#4"))))
+                     note-match (parse-note-match match)
+                     _ (when (< (:octave note-match) -1)
+                         (throw (IllegalArgumentException.
+                                 (str "Unable to resolve note: "
+                                      n
+                                      ". Octave is out of range. Lowest octave value is -1"))))]
+                 (:midi-note note-match))
    :else (throw (IllegalArgumentException. (str "Unable to resolve note: " n ". Wasn't a recognised format (either an integer, keyword, string or nil)")))))
+
+(defn match-note
+  "Returns the first midi-note formatted substring in s. If passed optional prev
+   and pos strings will use them to generate positive look ahead and behind
+   matchers. "
+  ([s] (match-note s "" ""))
+  ([s prev-str post-str]
+     (let [look-behind (if prev-str (str "(?<=" prev-str ")") "")
+           look-ahead (if post-str (str "(?=" post-str ")") "")
+           match (re-find (re-pattern (str look-behind MIDI-NOTE-RE-STR look-ahead)) s)]
+       (when match
+         (parse-note-match match)))))
+
+

 ;; * Each note in a scale acts as either a generator or a collector of other notes,
 ;; depending on their relations in time within a sequence.


make code a bit more readable in misc.clj

--- src/brainbot/nozzle/misc.clj
+++ src/brainbot/nozzle/misc.clj
@@ -22,10 +22,11 @@

 (defn ensure-endswith-slash
-  [a-string]
-  (if (.endsWith a-string "/")
-    a-string
-    (str a-string "/")))
+  "append slash to String s if it doesn't already end with a slash"
+  [^String s]
+  (if (.endsWith s "/")
+    s
+    (str s "/")))

 (defn die
   "print error message msg and exit the program with named argument
@@ -38,10 +39,12 @@

 (defn trimmed-lines-from-string
   "split string at newline and return non-empty trimmed lines"
-  [s]
+  [^String s]
   (if s
-    (remove string/blank?
-            (map string/trim (string/split-lines s)))))
+    (->> s
+         string/split-lines
+         (map string/trim)
+         (remove string/blank?))))

 (defn setup-logging!


Ensure macros expand to breeze.quiescent namespace

--- src/breeze/quiescent/dom.clj
+++ src/breeze/quiescent/dom.clj
@@ -12,18 +12,18 @@
        ([]
          (~f nil))
        ([~'attrs]
-         (~f (quiescent.dom/js-props ~'attrs)))
+         (~f (breeze.quiescent.dom/js-props ~'attrs)))
        ([~'attrs ~'c]
-         (~f (quiescent.dom/js-props ~'attrs) ~'c))
+         (~f (breeze.quiescent.dom/js-props ~'attrs) ~'c))
        ([~'attrs ~'c1 ~'c2]
-         (~f (quiescent.dom/js-props ~'attrs) ~'c1 ~'c2))
+         (~f (breeze.quiescent.dom/js-props ~'attrs) ~'c1 ~'c2))
        ([~'attrs ~'c1 ~'c2 ~'c3]
-         (~f (quiescent.dom/js-props ~'attrs) ~'c1 ~'c2 ~'c3))
+         (~f (breeze.quiescent.dom/js-props ~'attrs) ~'c1 ~'c2 ~'c3))
        ([~'attrs ~'c1 ~'c2 ~'c3 ~'c4]
-         (~f (quiescent.dom/js-props ~'attrs) ~'c1 ~'c2 ~'c3 ~'c4))
+         (~f (breeze.quiescent.dom/js-props ~'attrs) ~'c1 ~'c2 ~'c3 ~'c4))
        ([~'attrs ~'c1 ~'c2 ~'c3 ~'c4 ~'c5 & ~'children]
          (let [a# (cljs.core/make-array 6)]
-           (aset a# 0 (quiescent.dom/js-props ~'attrs))
+           (aset a# 0 (breeze.quiescent.dom/js-props ~'attrs))
            (aset a# 1 ~'c1)
            (aset a# 2 ~'c2)
            (aset a# 3 ~'c3)
@@ -38,7 +38,7 @@
       (nil? attrs) nil
       (instance? JSValue attrs) attrs
       (map? attrs) (cljs.tagged-literals/read-js attrs)
-      :else (list 'quiescent.dom/js-props attrs))))
+      :else (list 'breeze.quiescent.dom/js-props attrs))))

 (defmacro ^:private tag-macro*
   "Define a macro which calls a React.DOM factory."


Exclude clojure.core update function on buddy.core.mac.proto ns.

--- src/buddy/core/mac/proto.clj
+++ src/buddy/core/mac/proto.clj
@@ -14,7 +14,8 @@

 (ns buddy.core.mac.proto
   "Hash-based Message Authentication Codes
-  low level protocol definition.")
+  low level protocol definition."
+  (:refer-clojure :exclude [update]))

 (defprotocol IMac
   "Mac engine common interface definition."


fix alignments badge pdf export

fix alignments badge pdf export

--- src/clj/salava/badge/pdf.clj
+++ src/clj/salava/badge/pdf.clj
@@ -21,138 +21,139 @@
         badge-ids (map #(:badge_id (first (get-in % [:content]))) badge-with-content)
         temp (map #(select-multi-language-badge-content {:id %} (u/get-db ctx)) badge-ids)
         badges (map #(-> %1
-                           (dissoc :content)
-                           (assoc :qr_code (str->qr-base64 (badge-url ctx (:id %1)))
-                                  :endorsements (vec (select-badge-endorsements {:id (:badge_id %1)} (u/get-db ctx)))
-                                  :content %2)) badge-with-content temp)]
+                         (dissoc :content)
+                         (assoc :qr_code (str->qr-base64 (badge-url ctx (:id %1)))
+                           :endorsements (vec (select-badge-endorsements {:id (:badge_id %1)} (u/get-db ctx)))
+                           :content %2)) badge-with-content temp)]
+    #_(dump badges)
+
     badges))

 (defn generatePDF [ctx user-id input lang]
-    (let [data-dir (get-in ctx [:config :core :data-dir])
-          site-url (get-in ctx [:config :core :site-url])
-          badges (pdf-generator-helper ctx user-id input)
-          ul (:language (ud/user-information ctx user-id))
-          font-path  (first (mapcat #(get-in ctx [:config % :font] []) (get-plugins ctx)))
-          font  {:ttf-name (str site-url font-path)}
-          stylesheet {:heading-name {:color [127 113 121]
-                                     :family :times-roman
-                                     :align :center}
+  (let [data-dir (get-in ctx [:config :core :data-dir])
+        site-url (get-in ctx [:config :core :site-url])
+        badges (pdf-generator-helper ctx user-id input)
+        ul (:language (ud/user-information ctx user-id))
+        font-path  (first (mapcat #(get-in ctx [:config % :font] []) (get-plugins ctx)))
+        font  {:ttf-name (str site-url font-path)}
+        stylesheet {:heading-name {:color [127 113 121]
+                                   :family :times-roman
+                                   :align :center}

-                      :generic {:family :times-roman
-                                :color [127 113 121]
-                                :indent 20}
-                      :link {:family :times-roman
-                             :color [66 100 162]}
-                      :chunk {:size 11
-                              :style :bold}}
+                    :generic {:family :times-roman
+                              :color [127 113 121]
+                              :indent 20}
+                    :link {:family :times-roman
+                           :color [66 100 162]}
+                    :chunk {:size 11
+                            :style :bold}}

-          pdf-settings  (if (empty? font-path) {:stylesheet stylesheet  :bottom-margin 0 :footer {:page-numbers false :align :right}} {:font font :stylesheet stylesheet  :bottom-margin 0 :footer {:page-numbers false :align :right}})
-          badge-template (pdf/template
-                           (let [template #(cons [:paragraph]  [ (if (ends-with? (:image_file %) "png")
-                                                                   [:image {:width 100 :height 100 :align :center} (str data-dir "/" (:image_file %))]
-                                                                   [:image {:width 100 :height 100 :align :center :base64 true} $qr_code ]
+        pdf-settings  (if (empty? font-path) {:stylesheet stylesheet  :bottom-margin 0 :footer {:page-numbers false :align :right}} {:font font :stylesheet stylesheet  :bottom-margin 0 :footer {:page-numbers false :align :right}})
+        badge-template (pdf/template
+                         (let [template #(cons [:paragraph]  [ (if (ends-with? (:image_file %) "png")
+                                                                 [:image {:width 100 :height 100 :align :center} (str data-dir "/" (:image_file %))]
+                                                                 [:image {:width 100 :height 100 :align :center :base64 true} $qr_code ])

-                                                                   #_[:cell {:align :center :border true}[:svg #_{:scale 0.5 :translate [200 0]}
-                                                                                (io/file (str data-dir "/" (:image_file %)))]])
+                                                               [:heading.heading-name (:name %)]
+                                                               [:paragraph {:indent 20 :align :center}#_[:line] [:spacer]]
+                                                               [:paragraph.generic {:align :left :style :italic} (or (:description %) "-")][:spacer]
+                                                               [:paragraph.generic
+                                                                [:chunk.chunk (str (t :badge/Recipient ul)": ")] (str $first_name  " " $last_name ) "\n"
+                                                                [:chunk.chunk (str (t :badge/Issuedby ul)": ")] (or (:issuer_content_name %) "-")"\n"
+                                                                (when-not (blank? (:creator_name %))
+                                                                  [:paragraph.generic
+                                                                   [:chunk.chunk (str (t :badge/Createdby ul)": ")] (:creator_name %)])
+                                                                (when-not (blank? (str $issued_on))
+                                                                  [:chunk.chunk (str (t :badge/Issuedon ul)": ")] (date-from-unix-time (long (* 1000 $issued_on)) "date") "\n")
+                                                                (when-not (blank? (str $expires_on))
+                                                                  [:paragraph
+                                                                   [:chunk.chunk (str (t :badge/Expireson ul)": ")] (date-from-unix-time (long (* 1000 $expires_on)) "date")])

-                                                   [:heading.heading-name (:name %)]
-                                                   [:paragraph {:indent 20 :align :center}#_[:line] [:spacer]]
-                                                   [:paragraph.generic {:align :left} (or (:description %) "-")][:spacer]
-                                                   [:paragraph.generic
-                                                    [:chunk.chunk (str (t :badge/Recipient ul)": ")] (str $first_name  " " $last_name ) "\n"
-                                                    [:chunk.chunk (str (t :badge/Issuedby ul)": ")] (or (:issuer_content_name %) "-")"\n"
-                                                    (when-not (blank? (:creator_name %))
-                                                      [:paragraph.generic
-                                                        [:chunk.chunk (str (t :badge/Createdby ul)": ")] (:creator_name %)])
-                                                    (when-not (blank? (str $issued_on))
-                                                    [:chunk.chunk (str (t :badge/Issuedon ul)": ")] (date-from-unix-time (long (* 1000 $issued_on)) "date") "\n")
-                                                    (when-not (blank? (str $expires_on))
-                                                     [:paragraph
-                                                      [:chunk.chunk (str (t :badge/Expireson ul)": ")] (date-from-unix-time (long (* 1000 $expires_on)) "date")])
+                                                                (when-not (empty? $tags)
+                                                                  [:paragraph.generic
+                                                                   [:chunk.chunk (str (t :badge/Tags ul)": ")] (into [:phrase ] (for [t $tags] (str t " ")))])
+                                                                [:paragraph
+                                                                 (let [alignments (select-alignment-content {:badge_content_id (:badge_content_id %)} (u/get-db ctx))]
+                                                                   (when-not (empty? alignments)
+                                                                     [:paragraph.generic
+                                                                      [:spacer 0]
+                                                                      [:phrase {:size 12 :style :bold} (str (t :badge/Alignments ul)": " (count alignments))]"\n"
+                                                                      (into [:paragraph ] (for [a alignments]
+                                                                                [:paragraph
+                                                                                (or (:name a) "-")"\n"
+                                                                                [:chunk {:style :italic}(or (:description a) "-")] "\n"
+                                                                                [:chunk.link (or (:url a) "-")] [:spacer 0]]) )]))]
+                                                                [:paragraph
+                                                                 [:chunk.chunk (str (t :badge/Criteria ul)": ")] [:anchor {:target (:criteria_url %) :style{:family :times-roman :color [66 100 162]}} (or (:criteria_url %) "-")]]
+                                                                [:spacer 0]
+                                                                (when-not (blank? (:criteria_content %))
+                                                                  [:phrase.generic
+                                                                   [:chunk.chunk  (t :badge/Criteria ul)] ]"\n"
+                                                                  (markdown->clj-pdf {:spacer {:extra-starting-value 1 :allow-extra-line-breaks? true :single-value 2} :wrap {:global-wrapper :paragraph}} (:criteria_content %)))]

-                                                    (when-not (empty? $tags)
-                                                      [:paragraph.generic
-                                                        [:chunk.chunk (str (t :badge/Tags ul)": ")] (into [:phrase ] (for [t $tags] (str t " ")))])
-                                                    (when-not (empty? $alignments)
-                                                      [:paragraph.generic
-                                                       [:spacer 0]
-                                                       [:phrase {:size 12 :style :bold} (t :badge/Alignments ul)]
-                                                       [into [:paragraph ] (for [a $alignments]
-                                                                             [:paragraph
-                                                                              [:chunk.chunk "Name: "] (:name a) "\n"
-                                                                              [:chunk.chunk "Description: "] (:description a) "\n"
-                                                                              [:chunk.chunk "Url: "] (:url a) [:spacer 0]]) ]])
-                                                    [:paragraph
-                                                      [:chunk.chunk (str (t :badge/Criteria ul)": ")] [:anchor {:target (:criteria_url %) :style{:family :times-roman :color [66 100 162]}} (or (:criteria_url %) "-")]]
-                                                    [:spacer 0]
-                                                    (when-not (blank? (:criteria_content %))
-                                                    [:phrase.generic
-                                                     [:chunk.chunk  (t :badge/Criteria ul)] ]"\n"
-                                                     (markdown->clj-pdf {:spacer {:extra-starting-value 1 :allow-extra-line-breaks? true :single-value 2} :wrap {:global-wrapper :paragraph}} (:criteria_content %)))]
+                                                               (when-not (empty? $endorsements)
+                                                                 [:paragraph.generic
+                                                                  [:spacer 0]
+                                                                  [:phrase {:size 12 :style :bold} (t :badge/BadgeEndorsedBy ul)]
+                                                                  [:spacer 0]
+                                                                  (into [:paragraph {:indent 0} ] (for [e $endorsements]
+                                                                                [:paragraph
+                                                                                (or (:issuer_name e) "-") "\n"
+                                                                                [:anchor {:target (:issuer_url e) :style{:family :times-roman :color [66 100 162]}} (or (:issuer_url e) "-")] "\n"
+                                                                                [:chunk (date-from-unix-time (long (* 1000 (:issued_on e))))] "\n"
+                                                                                (when-not (blank? (:content e))
+                                                                                (markdown->clj-pdf {:wrap {:global-wrapper :paragraph}} (:content e)))]))])

-                                                  (when-not (empty? $endorsements)
-                                                    [:paragraph.generic
-                                                     [:spacer 0]
-                                                     [:phrase {:size 12 :style :bold} (t :badge/BadgeEndorsedBy ul)]
-                                                       [:spacer 0]
-                                                       (into [:paragraph {:indent 0} ] (for [e $endorsements]
-                                                           [:paragraph
-                                                            #_[:chunk.chunk "Endorser: " ] (or (:issuer_name e) "-") "\n"
-                                                            #_[:chunk.chunk "Issuer url: "] [:anchor {:target (:issuer_url e) :style{:family :times-roman :color [66 100 162]}} (or (:issuer_url e) "-")] "\n"
-                                                            #_[:chunk.chunk "Issued on: "][:chunk (date-from-unix-time (long (* 1000 (:issued_on e))))] "\n"
-                                                            (when-not (blank? (:content e))
-                                                            (markdown->clj-pdf (:content e)))]))])
+                                                               [:line {:dotted true}]
+                                                               [:spacer 0]
+                                                               [:heading.heading-name (t :badge/IssuerInfo ul)]
+                                                               [:spacer 0]
+                                                               (when-not (blank? (:issuer_description %))
+                                                                 [:paragraph.generic
+                                                                  [:chunk.chunk (str (t :badge/IssuerDescription ul)": ")] (or (:issuer_description %) "-")])
+                                                               [:spacer 1]
+                                                               [:paragraph.generic
+                                                                [:chunk.chunk (str (t :badge/IssuerWebsite ul)": ")]
+                                                                [:anchor {:target (:issuer_content_url %) :style{:family :times-roman :color [66 100 162]}} (or (:issuer_content_url %) "-")]]
+                                                               (when-not (blank? (:issuer_contact %))
+                                                                 [:paragraph.generic
+                                                                  [:chunk.chunk (str (t :badge/IssuerContact ul)": ")] (:issuer_contact %)])
+                                                               (when-not (blank? (:creator_description %))
+                                                                 [:paragraph.generic
+                                                                  [:chunk.chunk (str (t :badge/CreatorDescription ul)": ")] (:creator_description %)])
+                                                               (when-not (blank? (:creator_url %))
+                                                                 [:paragraph.generic
+                                                                  [:chunk.chunk (str (t :badge/CreatorWebsite ul)": ")] [:anchor {:target (:creator_url %) :style{:family :times-roman :color [66 100 162]}} (:creator_url %)] "\n"])
+                                                               (when-not (blank? (:creator_contact %))
+                                                                 [:paragraph.generic
+                                                                  [:chunk.chunk (str (t :badge/CreatorContact ul)": ")] (:creator_contact %)])
+                                                               (let [issuer-endorsement (select-issuer-endorsements {:id (:issuer_content_id %)} (u/get-db ctx))]
+                                                                 (when-not (empty? issuer-endorsement)
+                                                                   [:paragraph.generic
+                                                                    [:spacer]
+                                                                    [:phrase {:size 12 :style :bold} (t :badge/IssuerEndorsedBy ul)]
+                                                                    [:spacer 0]
+                                                                    (into [:paragraph {:indent 0} ]
+                                                                          (for [e issuer-endorsement]
+                                                                            [:paragraph {:indent 0}
+                                                                             (or (:issuer_name e) "-") "\n"
+                                                                             [:anchor {:target (:issuer_url e) :style{:family :times-roman :color [66 100 162]}} (or (:issuer_url e) "-")] "\n"
+                                                                             [:chunk.link (date-from-unix-time (long (* 1000 (:issued_on e))))] "\n"
+                                                                             (when-not (blank? (:content e))
+                                                                               (markdown->clj-pdf {:wrap {:global-wrapper :paragraph}} (:content e)))]))]))

-                                                    [:line {:dotted true}]
-                                                    [:spacer 0]
-                                                    [:heading.heading-name (t :badge/IssuerInfo ul)]
-                                                    [:spacer 0]
-                                                    (when-not (blank? (:issuer_description %))
-                                                      [:paragraph.generic
-                                                        [:chunk.chunk (str (t :badge/IssuerDescription ul)": ")] (or (:issuer_description %) "-")])
-                                                   [:spacer 1]
-                                                     [:paragraph.generic
-                                                      [:chunk.chunk (str (t :badge/IssuerWebsite ul)": ")]
-                                                      [:anchor {:target (:issuer_content_url %) :style{:family :times-roman :color [66 100 162]}} (or (:issuer_content_url %) "-")]]
-                                                    (when-not (blank? (:issuer_contact %))
-                                                      [:paragraph.generic
-                                                        [:chunk.chunk (str (t :badge/IssuerContact ul)": ")] (:issuer_contact %)])
-                                                    (when-not (blank? (:creator_description %))
-                                                      [:paragraph.generic
-                                                        [:chunk.chunk (str (t :badge/CreatorDescription ul)": ")] (:creator_description %)])
-                                                    (when-not (blank? (:creator_url %))
-                                                      [:paragraph.generic
-                                                        [:chunk.chunk (str (t :badge/CreatorWebsite ul)": ")] [:anchor {:target (:creator_url %) :style{:family :times-roman :color [66 100 162]}} (:creator_url %)] "\n"])
-                                                    (when-not (blank? (:creator_contact %))
-                                                      [:paragraph.generic
-                                                        [:chunk.chunk (str (t :badge/CreatorContact ul)": ")] (:creator_contact %)])
-                                                    (let [issuer-endorsement (select-issuer-endorsements {:id (:issuer_content_id %)} (u/get-db ctx))]
-                                                      (when-not (empty? issuer-endorsement)
-                                                          [:paragraph.generic
-                                                           [:spacer]
-                                                           [:phrase {:size 12 :style :bold} (t :badge/IssuerEndorsedBy ul)]
-                                                            [:spacer 0]
-                                                            (into [:paragraph {:indent 0} ]
-                                                              (for [e issuer-endorsement]
-                                                               [:paragraph {:indent 0}
-                                                                #_[:chunk.chunk "Endorser: " ] (or (:issuer_name e) "-") "\n"
-                                                                #_[:chunk.chunk "Issuer url: "] [:anchor {:target (:issuer_url e) :style{:family :times-roman :color [66 100 162]}} (or (:issuer_url e) "-")] "\n"
-                                                                #_[:chunk.chunk "Issued on: "][:chunk.link (date-from-unix-time (long (* 1000 (:issued_on e))))] "\n"
-                                                                (when-not (blank? (:content e))
-                                                                (markdown->clj-pdf {:wrap {:global-wrapper :paragraph}} (:content e)))]))]))
+                                                               [:pdf-table {:align :right :width-percent 100 :cell-border false}
+                                                                nil
+                                                                [[:pdf-cell [:paragraph {:align :right} [:chunk [:image  {:width 85 :height 85 :base64 true} $qr_code]]"\n"
+                                                                             [:phrase [:chunk.link {:style :italic} (str site-url "/badge/info/" $id)]]]]
+                                                                 ]]

-                                                    [:pdf-table {:align :right :width-percent 100 :cell-border false}
-                                                     nil
-                                                     [[:pdf-cell [:paragraph {:align :right} [:chunk [:image  {:width 85 :height 85 :base64 true} $qr_code]]"\n"
-                                                      [:phrase [:chunk.link {:style :italic} (str site-url "/badge/info/" $id)]]]]
-                                                     ]]
+                                                               [:pagebreak]])

-                                                    [:pagebreak]])
+                               content (if (= lang "all") (map template $content) (map template (filter #(= (:default_language_code %) (:language_code %)) $content)))]

-                                 content (if (= lang "all") (map template $content) (map template (filter #(= (:default_language_code %) (:language_code %)) $content)))]
-
-                             (reduce into [[:chapter ]] content)))]
-;;TODO Test alignments
- (fn [output-stream]
-   (pdf/pdf (into [pdf-settings] (badge-template badges)) output-stream)))
-)
+                           (reduce into [[:chapter ]] content)))]
+    ;;TODO Test alignments
+    (fn [output-stream]
+      (pdf/pdf (into [pdf-settings] (badge-template badges)) output-stream)))
+  )


Docstring time!

Docstring time!

--- src/cljs-blackjack/core.cljs
+++ src/cljs-blackjack/core.cljs
@@ -18,7 +18,7 @@
                      :dealer-feedback ""}))

 (def cardnames ["ace", "2", "3", "4", "5", "6", "7", "8", "9" "10" "J" "Q" "K"])
-(def suits [" of clubs" " of diamonds" " of hearts" " of spades"])
+(def suits ["clubs" "diamonds" "hearts" "spades"])

 (defn deal
   "Deal one card from the deck to a hand in the given
@@ -49,14 +49,14 @@
                      (min 10 card-mod))]
     [(+ acc card-value) (if (= card-mod 1) 1 ace-value)]))

-(defn english [[cval pos]]
+(defn english
+  "Given a card value and position (:up or :down),
+  return a string giving the card name."
+  [[cval pos]]
   (if (= pos :up)
-    (str (nth cardnames (rem cval 13))
+    (str (nth cardnames (rem cval 13)) " of "
          (nth suits (quot cval 13)))
     "face down card"))
-
-(defn english-hand [hand]
-    (reduce (fn [acc card] (conj acc (english card))) '[] hand))

 (defn evaluate-hand
   "Get total value of hand. Return a vector with total and
@@ -70,12 +70,9 @@
                   :else :bust)])))

 (defn immediate-win
-  "Given player hand and dealer hand, return
-  :none (nobody wins instantly)
-  :tie (both have blackjack)
-  :dealer-blackjack
-  :player-blackjack"
-  [player-hand dealer-hand]
+  "Given player hand and dealer hand, return true if someone
+  has blackjack, false otherwise."
+  [dealer-hand player-hand]
   (let [[ptotal _] (evaluate-hand player-hand)
         [dtotal _] (evaluate-hand dealer-hand)]
     (or (= ptotal 21) (= dtotal 21))))
@@ -87,11 +84,12 @@
   (let [result (vec (map (fn [card] [(first card) :up]) hand))]
     result))

-(defn feedback
-  [player dealer]
-  (swap! game assoc :player-feedback player :dealer-feedback dealer))
-
-(defn update-money [ptotal pstatus dtotal dstatus]
+(defn update-money
+  "Given the totals and status for dealer and player,
+  update the player's money. Make sure current bet is
+  between 0 and the current amount of money. This function
+  is awfully imperative. (Sorry.)"
+  [dtotal dstatus ptotal pstatus]
   (let [{:keys [player-money current-bet]} @game
         new-money (cond
                     (= ptotal dtotal) player-money ;; least common, but avoids lots of ugliness later
@@ -102,23 +100,36 @@
                     :else player-money)]
     (swap! game assoc :player-money new-money :current-bet (max 0 (min current-bet new-money)))))

-(defn end-game [dealer player]
+(defn feedback
+  "Given feedback for the dealer and player, update the reactive fields."
+  [dealer player]
+  (swap! game assoc :dealer-feedback dealer :player-feedback player))
+
+(defn end-game
+  "Evaluate the dealer's and player's hands when the
+  game has ended."
+  [dealer player]
   (let [[ptotal pstatus] (evaluate-hand player)
         [dtotal dstatus] (evaluate-hand dealer)]
 ;;    (println "Player:" player ptotal pstatus)
 ;;    (println "Dealer:" dealer dtotal dstatus)
     (cond
-      (> ptotal 21) (feedback "Sorry, you busted." "Dealer wins.")
-      (> dtotal 21) (feedback "You win!" "Dealer goes bust.")
-      (= ptotal dtotal) (feedback "Tie." "")
-      (= pstatus :blackjack) (feedback "You win with blackjack!" "")
-      (= dstatus :blackjack) (feedback "" "Dealer has blackjack.")
-      (< ptotal dtotal) (feedback "" "Dealer wins.")
-      (> ptotal dtotal) (feedback "You win!" ""))
-    (update-money ptotal pstatus dtotal dstatus)
+      (> ptotal 21) (feedback "Dealer wins." "Sorry, you busted.")
+      (> dtotal 21) (feedback "Dealer goes bust." "You win!")
+      (= ptotal dtotal) (feedback "" "Tie.")
+      (= pstatus :blackjack) (feedback "" "You win with blackjack!")
+      (= dstatus :blackjack) (feedback "Dealer has blackjack." "")
+      (< ptotal dtotal) (feedback "Dealer wins." "")
+      (> ptotal dtotal) (feedback "" "You win!")
+      :else (feedback "" "Unknown result (Shouldn't happen.)"))
+    (update-money dtotal dstatus ptotal pstatus)
     (swap! game assoc :playing false)))

-(defn start-game [event]
+(defn start-game
+  "Deal two cards to the player (both face up), and two to the dealer (one
+  face down and one face up). Update the game atom, and check for an immediate
+  win."
+  [event]
   (let [{:keys [deck discard-pile dealer-hand player-hand current-bet]} @game
         [player1 disc0] (discard [player-hand discard-pile])
         [dealer1 disc1] (discard [dealer-hand disc0])]
@@ -126,19 +137,26 @@
           [deck3 player2 disc3] (deal (deal [deck2 player1 disc2] :up) :up)]
       (swap! game assoc :playing true :discard-pile disc3 :player-hand player2
              :dealer-hand dealer2 :deck deck3 :dealer-feedback "" :player-feedback "")
-      (if (immediate-win player2 dealer2)
+      (if (immediate-win dealer2 player2)
         (do
           (swap! game assoc :dealer-hand (reveal dealer2))
           (end-game dealer2 player2))))))

-(defn hit-me [event]
+(defn hit-me
+  "Deal a card face up to the player, and evaluate the hand.
+  If the player went bust, end the game."
+  [event]
   (let [{:keys [deck discard-pile dealer-hand player-hand]} @game
         [deck2 player2 discard2] (deal [deck player-hand discard-pile] :up)
         [total status] (evaluate-hand player2)]
     (swap! game assoc :player-hand player2 :deck deck2 :discard-pile discard2)
     (if (= status :bust) (end-game dealer-hand player2))))

-(defn stand [event]
+(defn stand
+  "Player is satisfied with hand. Reveal the dealer's hand,
+  then deal cards one at a time until the dealer has to stand
+  or goes bust."
+  [event]
   (let [{:keys [deck dealer-hand player-hand discard-pile]} @game
         dhand (reveal dealer-hand)]
     (swap! game assoc :dealer-hand dhand)
@@ -154,16 +172,26 @@
             (swap! game assoc :dealer-hand new-hand)
             (recur new-deck new-hand new-discard)))))))

-(defn change-bet [event]
+(defn change-bet
+  "Allow user to change amount of bet, which must be between zero and
+  current amount of money."
+  [event]
   (let [val (.parseFloat js/window (.-value (.-target event)))
         amount (if (js/isNaN val) 0 val)
         total (:player-money @game)]
     (swap! game assoc :current-bet (max 0 (min amount total)))))

-(defn recharge-money [event]
+(defn recharge-money
+  "When player's money goes to zero, allow them to recharge
+  to $1000 with default bet of $10."
+  [event]
   (swap! game assoc :current-bet 10 :player-money 1000))

-(defn card-image [hand n]
+(defn card-image
+  "Display card number N from the given hand. Assign the
+  alt and title attributes of the image, and use relative
+  positioning to overlap the cards."
+  [hand n]
   (let [[card pos :as wholecard] (if (< n (count hand))
                                    (nth hand n)
                                    [-1 :up])
@@ -176,18 +204,22 @@
                    :height "133px"
                    :width "98px"}}]))

-(defn show-cards [hand]
+(defn show-cards
+  "Show all the cards in a hand."
+  [hand]
   (into [] (concat [:div {:class "cards"}]
                    (map (fn [x] (card-image hand x)) (range 0 (count hand))))))

-(defn tableau []
+(defn tableau
+  "Display the playing area (the tableau)."
+  []
   (let [{:keys [dealer-hand player-hand playing dealer-feedback player-feedback
                 player-money current-bet]} @game]
   [:div
-   [:h2 "Dealer’s Cards " [:span {:class "feedback"} dealer-feedback]]
+   [:h2 "Dealer’s Cards " [:span {:class "dealerFeedback"} dealer-feedback]]
    [show-cards dealer-hand]
    [:hr]
-   [:h2 "Your Cards " [:span {:class "feedback"} player-feedback]]
+   [:h2 "Your Cards " [:span {:class "playerFeedback"} player-feedback]]
    [show-cards player-hand]
    [:p
     [:input {:type "button"
@@ -208,11 +240,13 @@
               :on-change change-bet
               :value current-bet}]
      " Current money: $" player-money
-    "\u00a0"
+    "\u00a0 \u00a0" ;; spacing
     [:input {:type "button"
              :value "Recharge money"
              :on-click recharge-money
              :style {:display (if (= player-money 0) "inline" "none")}}]]]))

+;; Shuffle the deck initially and display the tableau.
+
 (swap! game assoc :deck (into [] (shuffle (range 0 52))))
 (reagent/render-component [tableau] (.getElementById js/document "tableau"))


Added Mithril m.request wrapper

Added Mithril m.request wrapper

--- src/cljs/repodoc/fathom.cljs
+++ src/cljs/repodoc/fathom.cljs
@@ -25,6 +25,13 @@
   "Get param from route params"
   ((aget (.-route js/m) "param") param))

+(defn request
+  "m.request wrapper with promise handling"
+  [options cb & err]
+  (.then (.request js/m (clj->js options))
+         (fn [resp] (cb (js->clj resp)))
+         (if (not err) #(.log js/console %) err)))
+
 ;
 ; Closure helpers
 ;


removed duplicate key.

removed duplicate key.

--- src/cljs/smarthome/data.cljs
+++ src/cljs/smarthome/data.cljs
@@ -37,7 +37,6 @@
    :user        {:current-location :out
                  :last-view        :home
                  :at-work?         false}
-   :time-of-day :morning
    :time        "08:05"
    :scenario    "Simulation stopped."})


refactoring of ai

refactoring of ai

--- src/cljs/triboard/ai/ai.cljs
+++ src/cljs/triboard/ai/ai.cljs
@@ -31,18 +31,20 @@
       (move/empty-cell-conversion player point))
     ))

-(defn- get-worst-possible-score-for
+(defn- next-worst-possible-score
   [{:keys [player other-players] :as ai-input} turn]
-  (let [all-adverse-moves (mapcat #(turn/get-moves-of turn %) other-players)
-        all-possible-scores (map #(score-move ai-input %) all-adverse-moves)]
-    (scores/min-delta-for player all-possible-scores)
-    ))
+  (scores/min-delta-for player
+    (eduction
+      (comp
+        (mapcat #(turn/get-moves-of turn %))
+        (map #(score-move ai-input %)))
+      other-players)))

 (defn- move-best-outcome
   [ai-input turn [coord converted :as move]]
   (let [new-turn (turn/play-move turn coord)
         move-diff (get (score-move ai-input move) (:player ai-input))
-        next-diff (get-worst-possible-score-for ai-input new-turn)]
+        next-diff (next-worst-possible-score ai-input new-turn)]
     (+ move-diff next-diff)))


Removing commented-out logging code

Removing commented-out logging code

--- src/cljs/tropology/core.cljs
+++ src/cljs/tropology/core.cljs
@@ -93,8 +93,6 @@
     (let [like-list (get-in app-state [:article-data :like-list])
           element   {:ref article-ref :code (:code current-article) :display (:display current-article) :image (:image current-article)}
           ]
-      ; (.log js/console current-article)
-      ; (.log js/console article-ref)
       (if (not (in-seq? like-list element))
         (assoc-in app-state [:article-data :like-list] (conj like-list element))
         app-state)
@@ -103,7 +101,6 @@
 (re-frame/register-handler
   :remove-like
   (fn [app-state [_ article-ref]]
-    #_ (.log js/console (str "Removing " article-ref))
     (let [new-like-list (remove #(= article-ref (:ref %)) (get-in app-state [:article-data :like-list]))
           no-likes?     (empty? new-like-list)
           show-graph?   (and (get-in app-state [:ui-state :show-graph?]) (not no-likes?))]


More clearly show the connection between add and connect.

--- src/cljs_bach/synthesis.cljs
+++ src/cljs_bach/synthesis.cljs
@@ -103,23 +103,22 @@
          (map #(run-with % context at duration))
          (apply f))))

+(defn join-in-series
+  [graph1 graph2]
+  (.connect (:output graph1) (:input graph2))
+  (subgraph (:input graph1) (:output graph2)))
+
 (defn ^:export connect
   "Use the output of one synth as the input to another."
   [upstream-synth downstream-synth]
-  (apply-to-graph
-    (fn [graph1 graph2]
-      (.connect (:output graph1) (:input graph2))
-      (subgraph (:input graph1) (:output graph2)))
-    upstream-synth
-    downstream-synth))
+  (apply-to-graph join-in-series upstream-synth downstream-synth))

 (defn connect->
   "Connect synths in series."
   [& nodes]
   (reduce connect nodes))

-(defn join
-  "Join the graphs in parallel, with upstream and downstream as the source and sink."
+(defn join-in-parallel
   [upstream downstream & graphs]
   (doseq [graph graphs]
     (.connect (:output graph) (:input downstream))
@@ -130,7 +129,7 @@
 (defn ^:export add
   "Add together synths by connecting them all to the same upstream and downstream gains."
   [& synths]
-    (apply apply-to-graph join pass-through pass-through synths))
+    (apply apply-to-graph join-in-parallel pass-through pass-through synths))

 ; Noise


Add console error output on worker

Add console error output on worker

--- src/cljs_workers/worker.cljs
+++ src/cljs_workers/worker.cljs
@@ -32,6 +32,8 @@
         (.postMessage js/self message)))

     (catch js/Object e
+      (when-let [c js/console]
+        (.error c e))
       (->> {:state :error, :message (.toString e)}
            clj->js
            (.postMessage js/self)))))
@@ -56,6 +58,8 @@
         (do-respond! result)))

     (catch js/Object e
+      (when-let [c js/console]
+        (.error c e))
       (->> {:state :error, :message (.toString e)}
            clj->js
            (.postMessage js/self)))))


Keep trying running altmetric embeds until it works

--- src/golden_kestrel/core.cljs
+++ src/golden_kestrel/core.cljs
@@ -105,6 +105,13 @@
         form-elem)
       (aget possibles 0))))

+(defn run-altmetric-embeds
+  []
+  (try
+    (js/_altmetric_embed_init)
+    (catch js/Object e
+      (js/setTimeout run-altmetric-embeds 200))))
+
 (defn ^:export init
   []
   (when-let [rootdom (. js/document (getElementById "golden-kestrel"))]
@@ -118,6 +125,6 @@
       (om/root
         app-state
         (fn [app owner]
-          (js/setTimeout js/_altmetric_embed_init 500)
+          (run-altmetric-embeds)
           (om/component (embed app)))
         embed-element))))


Replace an assert with an :pre condition

--- src/io/aviso/rook/client.clj
+++ src/io/aviso/rook/client.clj
@@ -30,7 +30,7 @@
   The handler is passed the Ring request map and returns a core.async channel that will receive
   the response. The handler is typically implemented using the core.async go or thread macros."
   [web-service-handler]
-  (assert web-service-handler)
+  {:pre [(some? web-service-handler)]}
   {:handler   web-service-handler
    ;; If there isn't an exact match on status code, the special keys :success and :failure
    ;; are checked. :success matches any 2xx code, :failure matches anything else.