WIP body in binary when gzip

WIP body in binary when gzip

--- ssclj/jar/src/main/clojure/com/sixsq/slipstream/ssclj/middleware/proxy_redirect.clj
+++ ssclj/jar/src/main/clojure/com/sixsq/slipstream/ssclj/middleware/proxy_redirect.clj
@@ -37,6 +37,13 @@
     (let [buf (byte-array len)]
       (.read rdr buf)
       buf)))
+
+(defn- slurp-body-binary
+  [request]
+  (if-let [len (when (:body request) (get-in request [:headers "content-length"]))]
+    (-> request
+        :body
+        (slurp-binary (Integer/parseInt len)))))

 (defn- slurp-body
   [request]
@@ -161,7 +168,11 @@

         response (request-fn @client redirected-url
                              {:query-params (merge (to-query-params (:query-string request)) (:params request))
-                              :body         (slurp-body request)
+                              :body         (if-let [accept (get-in request [:request "accept-encoding"])]
+                                              (if (.startsWith accept "gzip")
+                                                (slurp-body-binary request)
+                                                (slurp-body request))
+                                              (slurp-body request))
                               :headers      (-> request
                                                 :headers
                                                 (dissoc "host" "content-length"))})]


scheduler: Allow upgrading backfilled unknown instances.

Hopefully this will avoid the situation where a persistent backfilled
unknown instance causes basically everything to get marked as
backfilled until it is reconciled.

--- scheduler/src/cook/mesos/scheduler.clj
+++ scheduler/src/cook/mesos/scheduler.clj
@@ -445,10 +445,11 @@
 (gauges/defgauge [cook-mesos scheduler front-of-job-queue-cpus] (fn [] @front-of-job-queue-cpus-atom))

 (defn ids-of-backfilled-instances
-  "Returns a list of the ids of running, backfilled instances of the given job"
+  "Returns a list of the ids of running-or-unknown, backfilled instances of the given job"
   [job]
   (->> (:job/instance job)
-       (filter #(and (= :instance.status/running (:instance/status %))
+       (filter #(and (contains? #{:instance.status/running :instance.status/unknown}
+                                (:instance/status %))
                      (:instance/backfilled? %)))
        (map :db/id)))


State.

State.

--- test/com/nomistech/clojure_the_language/c_400_state_and_concurrency/s_020_atoms.clj
+++ test/com/nomistech/clojure_the_language/c_400_state_and_concurrency/s_020_atoms.clj
@@ -180,12 +180,10 @@
               (dotimes [_ n-competitors]
                 (.start (Thread. long-running-inc-on-atom!))))
             (report-on-what-is-happening []
-              (loop []
-                (println "[value n-attempts] =" (get-info))
-                (when (< @competing-updates-atom
-                         n-competitors)
-                  (Thread/sleep 1000)
-                  (recur))))]
+              (while (< @competing-updates-atom
+                        n-competitors)
+                (Thread/sleep 1000)
+                (println "[value n-attempts] =" (get-info))))]
       (create-competing-threads)
       (report-on-what-is-happening)
       (get-info))))


Remove items that no longer exist in Closure

--- planck-cljs/src/planck/bundle.cljs
+++ planck-cljs/src/planck/bundle.cljs
@@ -14,7 +14,6 @@
     goog.Throttle
     goog.Timer
     goog.Uri
-    goog.array.ArrayLike
     goog.color
     goog.color.Hsl
     goog.color.Hsv
@@ -28,7 +27,6 @@
     goog.crypt.Cbc
     goog.crypt.Hash
     goog.crypt.Hmac
-    goog.crypt.JpegEncoder
     goog.crypt.Md5
     goog.crypt.Sha1
     goog.crypt.Sha2


Fix more render issues

Fix more render issues


Removed no longer needed id-types

Removed no longer needed id-types

--- kabob-build/src/main/clojure/edu/ucdenver/ccp/kabob/build/id_sets/generate.clj
+++ kabob-build/src/main/clojure/edu/ucdenver/ccp/kabob/build/id_sets/generate.clj
@@ -15,12 +15,12 @@
 ;;; id types
 ;;;-------------------------------------------------------------------

-(def id-types '(kiao/DrugIdentifier
-                kiao/DNAIdentifier
-                kiao/ProteinIdentifier
-                kiao/DiseaseIdentifier
-                kiao/RNAIdentifier
-                kiao/mRNAIdentifier))
+;(def id-types '(kiao/DrugIdentifier
+;                kiao/DNAIdentifier
+;                kiao/ProteinIdentifier
+;                kiao/DiseaseIdentifier
+;                kiao/RNAIdentifier
+;                kiao/mRNAIdentifier))

 ;;;-------------------------------------------------------------------
 ;;; extract ids from source kb, group in temp graph db, output to file
@@ -155,9 +155,9 @@
   (prn "Clojure version: " *clojure-version*)
   (prn "Server URL: " (:server-url args))
   (prn "Repo name: " (:repo-name args))
-  (prn "Output directory: " (:output-directory args))
-  (prn "ID types: ")
-  (pprint id-types))
+  (prn "Output directory: " (:output-directory args)))
+;  (prn "ID types: ")
+;  (pprint id-types))

 ;; (defn source-kb [args]
 ;;   ;; Init source KB connection


Final touches

Final touches

--- src/literate_2048/core.cljs
+++ src/literate_2048/core.cljs
@@ -1,6 +1,6 @@
 (ns literate-2048.core
   (:require [goog.events :as events]
-            [cljs.core.async :refer (<! chan timeout put!)]
+            [cljs.core.async :refer (<! chan dropping-buffer timeout put!)]
             [quiescent :as q :include-macros true]
             [quiescent.dom :as d])
   (:require-macros [cljs.core.async.macros :refer (go-loop)]))
@@ -22,8 +22,8 @@
 ;; The chosen representation for the board is a vector of 16 (4*4) elements. It
 ;; will contain the squares from the first row, followed by the squares from the
 ;; second, and so on. Intuitively, it seems that the natural representation for
-;; such a board is a vector of vectors, but it will make things more complicated
-;; than they need to be.
+;; such a board is a vector of vectors, but it will only make things more
+;; complicated than they need to be.

 ;; The simplest board, and our starting point, is one that is completely empty.
 ;; An empty square is represented by nil.
@@ -70,7 +70,7 @@

 ;; The goal of the game is to merge tiles together until a tile that is not able
 ;; to be merged appears. Therefore, we need to tell if a tile can be merged with
-;; another tiles and a mechanism to obtain the result of the merge of two given
+;; another tiles and a mechanism to obtain the result of merging two given
 ;; tiles.

 ;; Since 'merge' is already a map operation, let's name the process 'synthesis'.
@@ -84,10 +84,7 @@
      another ITile when they can be synthesized or nil when they can't. No tile
      can be synthesized with nil."))

-;; While two tiles might be able to participate in a synthesis they might not be
-;; able to be synthesized together.
-
-;; Since we don't know beforehand how many tiles will participate in a
+;; Because we don't know beforehand how many tiles will participate in a
 ;; synthesis, we'll synthesize a collection containing an arbitrary number of
 ;; them. This is easily accomplished by following the guidelines below.

@@ -147,8 +144,8 @@
 ;; - and applying synth-adjacent to the result solves the 'merge' part.
 ;; However, the previous function applications lead to an undesired consequence.
 ;; The resulting sequence is not a proper row because of the lack of nil
-;; elements. Fortunately, in this case, nils must be aligned to the right and
-;; can be appended with take-exactly.
+;; elements. Fortunately in this case, nils must be aligned to the right and can
+;; be appended with take-exactly.

 (defn slide-synth-line
   "Returns the result of moving non nil elements of line to the beginning,
@@ -171,7 +168,8 @@

 ;; - Obtaining the lines. Rows are partitions of 4 elements of our board
 ;;   representation and columns are transposition of them. For the 'right' and
-;;   'up' move, rows and columns need to be reversed to obtain the correct line.
+;;   'up' move, the rows and columns need to be reversed to obtain the correct
+;;   line.
 ;; - Slide and synth the lines.
 ;; - Reassemble the resulting sequences, that is rows or columns possibly
 ;;   reversed, back to our board representation.
@@ -191,7 +189,7 @@
             :up (->> cols (map slide-synth-line) transpose)
             :down (->> cols (map reverse-slide-synth-line) transpose))))))

-;; A tile is added when the board changes.
+;; To complete a move, a tile is added when the board changes.

 (defn move
   "Returns a new board that results from sliding and synthesizing the tiles of
@@ -202,8 +200,9 @@
   (let [board' (slide-synth board direction)]
     (when (not= board board') (add-tile tile-fn board'))))

-;; As stated in the 'Tile synthesis' section, the player wins the game when a
-;; tile that is not able to be merged appears.
+;; Sadly, moves can’t be made indefinitely. As stated in the 'Tile synthesis'
+;; section, the player wins the game when a tile that is not able to be merged
+;; appears.

 (defn won?
   "Returns true if board contains a tile for which -synth? is falsey."
@@ -253,10 +252,10 @@
 ;; updates the DOM it tries to do it in the most efficiently manner by recycling
 ;; what is already there. It does not provide (by default) any guarantee that
 ;; the same DOM node will be used for our example div across render passes.
-;; Fortunately, the only reason React can't keep a mapping between our
+;; Lucky for us, the only reason React can't keep a mapping between our
 ;; specification and the DOM is that it doesn't have a way to identify the
 ;; elements we specify. We can solve the problem if we provide React the
-;; information it needs by assigning a key to our divs. The
+;; information it needs by assigning a 'key' to our divs. The
 ;; [official documentation](http://facebook.github.io/react/docs/reconciliation.html)
 ;; is a great place to learn more about React's reconciliation process.

@@ -279,7 +278,7 @@
   []
   (d/div {:className "square"}))

-;; To render the board we need to draw a square in every position.
+;; And we need to draw one in every position to render the board.

 (defn squares-view
   "Returns a div containing a square for each position of a board with the given
@@ -291,8 +290,8 @@

 ;; Tiles are styled differently according to their value. We'll use the
 ;; class "tile" to apply styles shared by all tiles and "tile-val", where val is
-;; the tile's value, to apply the right color, font size, shadow, etc. However,
-;; a tile might have another classes.
+;; the tile value, to apply the right color, font size, shadow, etc. However, a
+;; tile might have another classes.

 ;;
2

@@ -358,10 +357,10 @@
   ([val] {:val val :key (keyword (gensym ""))})
   ([x y] (assoc (build-tile (+ (:val x) (:val y))) :src [x y])))

-;; Before going further, an implementation of the ITile protocol, presented in
-;; section 'Tile synthesis', must be provided. The synthesis of two tiles with
-;; the same :val is another tile (described above), but the synthesis of two
-;; tiles with different :val is nil. In addition, a tile with a :val of 2048
+;; Before going any further, an implementation of the ITile protocol, presented
+;; in section 'Tile synthesis', must be provided. The synthesis of two tiles
+;; with the same :val is another tile (described above), but the synthesis of
+;; two tiles with different :val is nil. In addition, a tile with a :val of 2048
 ;; can't be synthesized anymore.

 (extend-type cljs.core/PersistentArrayMap
@@ -379,7 +378,7 @@
 ;; tile appears randomly.

 ;; As you can probably guess, our board representation needs to be transformed
-;; into something that SquareBoard, defined in section 'Rendering', can make
+;; into something that SquareBoard (defined in section 'Rendering') can make
 ;; sense of. Additionaly, the transformation must remove the novelty when the
 ;; slide phase is rendered. The next steps illustrate a way to achieve that.
 ;; - Keep only the tiles of the board by removing the empty squares and
@@ -424,8 +423,8 @@
                                       (:src x) "highlight"))))
        (sort-by :key)))

-;; A Game component will wrap SquareBoard and supply it with the tile sequence
-;; it expects from a board and a phase. Remember we want to render new and
+;; A Game component will wrap SquareBoard and will supply the tile sequence it
+;; expects from a board and a phase. Remember we want to render new and
 ;; synthesized tiles on the :reveal phase, but not on :slide. The component will
 ;; also be responsible for showing a message when the game ends.

@@ -495,9 +494,9 @@
   []
   (let [key-map {37 :left 38 :up 39 :right 40 :down}]
     (events->chan js/document goog.events.EventType.KEYUP
-      (chan 1 (comp (map #(.-keyCode %))
-                    (filter (set (keys key-map)))
-                    (map key-map))))))
+      (chan (dropping-buffer 1) (comp (map #(.-keyCode %))
+                                      (filter (set (keys key-map)))
+                                      (map key-map))))))

 ;; ## The game loop

@@ -508,8 +507,8 @@

 ;; ### Rendering the board

-;; The list below describes an iteration when the value for action binding is
-;; :render. Given the initial state consist of a random initial board and the
+;; The list below describes an iteration when the value for the action binding
+;; is :render. Given the initial state consist of a random initial board and the
 ;; :render action, this will take place at the very beginning.

 ;; - The board is rendered in the slide phase, and we wait a bit while the


Remove unused macros file

Remove unused macros file

--- lein-light-nrepl/src/lt/macros.clj
+++ lein-light-nrepl/src/lt/macros.clj
@@ -1,98 +0,0 @@
-(ns lt.macros
-  (:require [clojure.walk :as walk]))
-
-(defn- namify [type keyword]
-  (symbol (str "__" type "__" (.replace (name keyword) "." "__DOT__"))))
-
-(defmacro behavior [name & {:keys [reaction] :as r}]
-  (if (and (seq? reaction) (= 'fn (first reaction)))
-    (let [[_ args & body] reaction]
-      `(do
-         (defn- ~(namify "BEH" name) ~args ~@body)
-         (lt.object/behavior* ~name ~@(apply concat (assoc r :reaction (namify "BEH" name))))))
-    `(lt.object/behavior* ~name ~@(apply concat r))))
-
-(defmacro defui [sym params hiccup & events]
-  `(defn ~sym ~params
-     (let [e# (crate.core/html ~hiccup)]
-       (doseq [[ev# func#] (partition 2 ~(vec events))]
-         (lt.util.dom/on e# ev# func#))
-       e#)))
-
-(defmacro timed [ev & body]
-  `(let [start# (lighttable.util.js/now)
-         res# (do ~@body)]
-     (lighttable.components.logger/log ~ev (- (lighttable.util.js/now) start#))
-     res#))
-
-(defn ->params [body]
-  (if (vector? (first body))
-    [(first body) (rest body)]
-    [[] body]))
-
-(defmacro on [name & body]
-  `(lighttable.command/on ~name (fn ~@body)))
-
-(defmacro in [ctx & body]
-  (let [[params body] (->params body)]
-    `(assoc ~ctx :in (fn ~params ~@body))))
-
-(defmacro out [ctx & body]
-  (let [[params body] (->params body)]
-    `(assoc ~ctx :out (fn ~params ~@body))))
-
-(defmacro defcontext [name & body]
-  `(let [ctx# {:name ~name}]
-     (lighttable.context/add-context!
-       (-> ctx#
-           ~@body))))
-
-(defmacro extract [elem kvs & body]
-  (let [defs (vec (apply concat (for [[k v] (partition 2 kvs)]
-                                  `[~k (lt.util.dom/$ ~v ~elem)])))]
-    `(let ~defs
-       ~@body)))
-
-(defmacro foreach [xs & body]
-  `(let [xs# ~(second xs)
-         len# (.-length xs#)]
-     (loop [left# 0]
-       (when (< left# len#)
-         (let [~(first xs) (aget xs# left)]
-           ~@body
-           (recur (inc left#)))))))
-
-(defmacro with-time [& body]
-  (let [start (gensym "start")
-        body (walk/postwalk-replace {'time (list '- '(.getTime (js/Date.)) start)} body)]
-  `(let [~start (.getTime (js/Date.))]
-     ~@body)))
-
-(defmacro background [func]
-  `(lt.objs.thread/thread*
-    (fn ~(gensym "tfun") []
-      (let [orig# (js/argsArray js/arguments)
-            msg# (.shift orig#)
-            args# (.map orig# cljs.reader/read-string)
-            ~'raise (fn [obj# k# v#]
-                     (js/_send obj# k# (pr-str v#) "clj"))]
-        (.unshift args# (.-obj msg#))
-        (.apply ~func nil args#)))))
-
-(comment
-
-  (worker (fn [v]
-            (do-something v))
-          :zomg (fn [r]
-                  ))
-
-  (defui cool [l]
-    [:li (bound l)]
-
-    :click (fn [e]
-             (this-as me
-                      ))
-    :hover (fn [e]
-             ))
-
-  )


Use x- prefix on operation identifier (not defined by Swagger spec)

--- src/io/aviso/rook/swagger.clj
+++ src/io/aviso/rook/swagger.clj
@@ -307,7 +307,7 @@
                                       ;; This is required inside a Operation object:
                                       :responses      {}
                                       ;; This aligns very nicely with Rook:
-                                      :operation-id (:function endpoint-meta)}))
+                                      :x-operation-id (:function endpoint-meta)}))
           (path-params-injector swagger-options % routing-entry params-key)
           (query-params-injector swagger-options % routing-entry params-key)
           (body-params-injector swagger-options % routing-entry params-key)


Add not-found route.

Add not-found route.

--- src/mvxcvi/body/web/app.clj
+++ src/mvxcvi/body/web/app.clj
@@ -8,7 +8,9 @@
       [middleware :refer [api-middleware]]
       [routes :as routes]
       [swagger :as swagger])
-    [compojure.core :as compojure]
+    (compojure
+      [core :as compojure]
+      [route :as croute])
     [hiccup.core :as hiccup]
     [mvxcvi.body.web.middleware :refer :all]
     [mvxcvi.body.web.views.common :refer [index-page]]
@@ -55,8 +57,9 @@
   (compojure/routes
     (compojure/GET "/" []
       (render (index-page)))
-    (compojure/context "/api" []
-      (routes/api-root
+
+    (routes/api-root
+      (context* "/api" []
         (swagger/swagger-ui)
         (swagger/swagger-docs)

@@ -64,4 +67,6 @@
           :tags ["foo"]

           (GET* "/" []
-            {:foo :bar}))))))
+            {:foo :bar}))))
+
+    (croute/not-found "Not Found")))


factor out {:conjugated true}

factor out {:conjugated true}

--- src/babel/francais/grammar.cljc
+++ src/babel/francais/grammar.cljc
@@ -29,6 +29,16 @@
                                 :tense :past}}}
    "past perfect" {:synsem {:sem {:aspect :perfect
                                   :tense :past}}}})
+
+(def head-is-conjugated-and-imperfect-infl
+  {:head {:français {:imperfect {:conjugated true}}
+          :phrasal false
+          :synsem {:infl :imperfect}}})
+
+(def head-is-conjugated-and-present-infl
+  {:head {:français {:present {:conjugated true}}
+          :phrasal false
+          :synsem {:infl :present}}})

 (declare against-pred)
 (declare matching-head-lexemes)
@@ -353,12 +363,10 @@
                                      :sem {:aspect :progressive
                                            :tense :past}}})
                    (unify c10
-                           root-is-head
+                          root-is-head
+                          head-is-conjugated-and-imperfect-infl
                            {:rule "s-imperfect-nonphrasal"
-                            :head {:phrasal false
-                                   :français {:present {:conjugated true}}}
-                            :synsem {:aux false
-                                     :infl :imperfect
+                            :synsem {:aux false
                                      :cat :verb
                                      :sem {:aspect :progressive
                                            :tense :past}}})
@@ -373,11 +381,9 @@
                                            :tense :present}}})
                    (unify c10
                           root-is-head
+                          head-is-conjugated-and-present-infl
                           {:rule "s-present-nonphrasal"
-                           :head {:phrasal false
-                                  :français {:present {:conjugated true}}}
                            :synsem {:aux false
-                                    :infl :present
                                     :cat :verb
                                     :sem {:aspect :progressive
                                           :tense :present}}})
@@ -396,14 +402,13 @@
                                      :infl :infinitive
                                      :cat :verb}})
                    (unify h21a
-                           root-is-comp
-                           {:rule "vp-aux"
-                            :head {:phrasal false}
-                            :synsem {:aux true
-                                     :infl :present
-                                     :sem {:tense :past}
-                                     :cat :verb}})
-
+                          root-is-comp
+                          head-is-conjugated-and-present-infl
+                          {:rule "vp-aux"
+                           :synsem {:aux true
+                                    :sem {:tense :past}
+                                    :cat :verb}})
+
                    ;; [nous [être + naître]] => nous somme nées
                    (unify h22
                            root-is-comp


Clean up a little.

Clean up a little.

--- src/onyx/plugin/datomic.clj
+++ src/onyx/plugin/datomic.clj
@@ -3,7 +3,9 @@
             [datomic.api :as d]
             [onyx.peer.pipeline-extensions :as p-ext]))

-(defn unroll-datom [db datom]
+(defn unroll-datom
+  "Turns a datom into a vector of :eavt+op."
+  [db datom]
   [(:e datom)
    (d/ident db (:a datom))
    (:v datom)
@@ -12,7 +14,9 @@

 (defn datoms-between
   "Returns a reducible collection of datoms created
-  between the start and end dates in a single partition."
+   between the start and end dates in a single partition.
+
+   https://github.com/candera/strangeloop-2013-datomic/blob/master/slides.org#the-code"
   [db partition start end]
   (let [start-e (d/entid-at db partition start)
         end-e (d/entid-at db partition end)]
@@ -24,9 +28,11 @@
    :onyx/direction :input
    :onyx/medium :datomic}
   [{:keys [task-map] :as pipeline}]
-  (let [{:keys [datomic/uri datomic/partition-size datomic/t datomic/partition]} task-map
-        conn (d/connect uri)
-        partitions (partition-all 2 1 (range 0 t partition-size))]
+  (let [conn (d/connect (:datomic/uri task-map))
+        t (:datomic/t task-map)
+        partition (:datomic/partition task-map)
+        size (:datomic/partition-size task-map)
+        partitions (partition-all 2 1 (range 0 t size))]
     {:results (map (fn [[low high]] {:low low :high (or high t) :t t :partition partition})
                    partitions)}))


unsetting follow-up

unsetting follow-up

--- iwaswhere-web/src/cljs/iwaswhere_web/ui/entry/task.cljs
+++ iwaswhere-web/src/cljs/iwaswhere_web/ui/entry/task.cljs
@@ -14,7 +14,8 @@
         (fn [entry]
           (fn [ev]
             (let [sel (js/parseInt (-> ev .-nativeEvent .-target .-value))
-                  updated (assoc-in entry [:task :follow-up-hrs] sel)]
+                  follow-up-hrs (when-not (js/isNaN sel) sel)
+                  updated (assoc-in entry [:task :follow-up-hrs] follow-up-hrs)]
               (put-fn [:entry/update-local updated]))))]
     (fn [entry put-fn edit-mode?]
       (when (contains? (:tags entry) "#task")
@@ -46,6 +47,7 @@
               [:option {:value 3} "3"]
               [:option {:value 6} "6"]
               [:option {:value 12} "12"]
+              [:option {:value 18} "18"]
               [:option {:value 24} "24"]
               [:option {:value 48} "48"]]
              [:span "hours"]])]]))))


implement Midori

implement Midori

--- src/clj/game/cards-upgrades.clj
+++ src/clj/game/cards-upgrades.clj
@@ -141,7 +141,7 @@
                  :effect (req (resolve-ability state side trash-program card nil)
                               (trash state side card {:cause :ability-cost})
                               (lose state :runner :tag 1))}]}
-
+
    "Marcus Batty"
    {:abilities [{:label "[Trash]: Start a Psi game" :msg "start a Psi game"
                  :psi {:not-equal {:req (req this-server)
@@ -149,6 +149,26 @@
                                    :msg (msg "resolve a subroutine on " (:title target))
                                    :effect (effect (trash card {:cause :ability-cost}))}}}]}

+   "Midori"
+   {:abilities
+    [{:req (req this-server)
+      :label "Swap the ICE being approached with a piece of ICE from HQ"
+      :prompt "Choose a piece of ICE" :choices (req (filter #(has? % :type "ICE") (:hand corp))) :once :per-run
+      :msg (msg "swap " (if (:rezzed current-ice) (:title current-ice) "the approached ICE") " with a piece of ICE from HQ")
+      :effect (req (let [hqice target
+                         c current-ice]
+                     (resolve-ability state side
+                       {:effect (req (let [newice (assoc hqice :zone (:zone c))
+                                           cndx (ice-index state c)
+                                           ices (get-in @state (cons :corp (:zone c)))
+                                           newices (apply conj (subvec ices 0 cndx) newice (subvec ices cndx))]
+                                       (swap! state assoc-in (cons :corp (:zone c)) newices)
+                                       (swap! state update-in [:corp :hand]
+                                              (fn [coll] (remove-once #(not= (:cid %) (:cid hqice)) coll)))
+                                       (trigger-event state side :corp-install newice)
+                                       (move state side c :hand)
+                                       (update-run-ice state side)))} card nil)))}]}
+
    "NeoTokyo Grid"
    {:events {:advance {:req (req (= (butlast (:zone target)) (butlast (:zone card)))) :once :per-turn
                        :msg "gain 1 [Credits]" :effect (effect (gain :credit 1))}}}
@@ -181,7 +201,7 @@
    "Rutherford Grid"
    {:events {:pre-init-trace {:req (req this-server)
                               :effect (effect (init-trace-bonus 2))}}}
-
+
    "Ryon Knight"
    {:abilities [{:label "[Trash]: Do 1 brain damage"
                  :msg "do 1 brain damage" :req (req (and this-server (zero? (:click runner))))


implement Mumbad City Grid

implement Mumbad City Grid

--- src/clj/game/cards-upgrades.clj
+++ src/clj/game/cards-upgrades.clj
@@ -175,6 +175,30 @@
                                        (move state side c :hand)
                                        (update-run-ice state side)))} card nil)))}]}

+   "Mumbad City Grid"
+   {:abilities [{:req (req (and this-server
+                                (< (:position run) (count (:ices run)))
+                                (> (count (:ices run)) 1)))
+                 :label "Swap the ICE just passed with another piece of ICE protecting this server"
+                 :effect (req (let [passed-ice (nth (get-in @state (vec (concat [:corp :servers] (:server run) [:ices])))
+                                                                                (:position run))
+                                    ice-zone (:zone passed-ice)]
+                                 (resolve-ability state :corp
+                                   {:prompt (msg "Select a piece of ICE to swap with " (:title passed-ice))
+                                    :choices {:req #(and (= ice-zone (:zone %)) (ice? %))}
+                                    :effect (req (let [fndx (ice-index state passed-ice)
+                                                       sndx (ice-index state target)
+                                                       fnew (assoc passed-ice :zone (:zone target))
+                                                       snew (assoc target :zone (:zone passed-ice))]
+                                                   (swap! state update-in (cons :corp ice-zone)
+                                                          #(assoc % fndx snew))
+                                                   (swap! state update-in (cons :corp ice-zone)
+                                                          #(assoc % sndx fnew))
+                                                   (update-ice-strength state side fnew)
+                                                   (update-ice-strength state side snew)))} card nil)
+                                 (system-msg state side (str "uses Mumbad City Grid to swap " (card-str state passed-ice)
+                                                             " with " (card-str state target)))))}]}
+
    "NeoTokyo Grid"
    {:events {:advance {:req (req (= (butlast (:zone target)) (butlast (:zone card)))) :once :per-turn
                        :msg "gain 1 [Credits]" :effect (effect (gain :credit 1))}}}


make Heinlein Grid manually triggered by Corp

--- src/clj/game/cards-upgrades.clj
+++ src/clj/game/cards-upgrades.clj
@@ -117,17 +117,10 @@
                                 :msg "gain 1 [Credits]" :effect (effect (gain :credit 1))}}}

    "Heinlein Grid"
-   {:effect (req (add-watch state (keyword (str "heinlein" (:cid card)))
-                   (fn [k ref old new]
-                     (let [clicknew (get-in new [:runner :click])
-                           clickold (get-in old [:runner :click])]
-                       (when (< clicknew clickold)
-                         (resolve-ability ref side
-                           {:req (req this-server)
-                            :msg (msg "force the Runner to lose all " (:credit runner) " [Credits]") :once :per-run
-                            :effect (effect (lose :runner :credit :all))}
-                          card nil))))))
-    :leave-play (req (remove-watch state (keyword (str "heinlein" (:cid card)))))}
+   {:abilities [{:req (req this-server)
+                 :label "Force the Runner to lose all [Credits] from spending or losing a [Click]"
+                 :msg (msg "force the Runner to lose all " (:credit runner) " [Credits]") :once :per-run
+                 :effect (effect (lose :runner :credit :all))}]}

    "Hokusai Grid"
    {:events {:successful-run {:req (req this-server) :msg "do 1 net damage"


Simplify condition for foreign key column name in belongs-to.

--- src/clj_record/associations.clj
+++ src/clj_record/associations.clj
@@ -53,9 +53,8 @@
   (let [opts (apply hash-map options)
         associated-model-name (str (or (:model opts) association-name))
         find-fn-name (symbol (str "find-" association-name))
-        foreign-key-attribute (keyword (cond
-                                        (:fk opts) (:fk opts)
-                                        (:model opts) (str (dashes-to-underscores (str association-name)) "_id")
-                                        :else (str (dashes-to-underscores associated-model-name) "_id")))]
+        foreign-key-attribute (keyword (or
+                                        (:fk opts)
+                                        (str (dashes-to-underscores (str association-name)) "_id")))]
     `(defn ~find-fn-name [record#]
       (clj-record.core/get-record ~associated-model-name (~foreign-key-attribute record#)))))


Make sure we do not throw when detecting directories

--- src/cljs/bundled/lumo/util.cljs
+++ src/cljs/bundled/lumo/util.cljs
@@ -212,7 +212,7 @@

 (defn file-seq [dir]
   (tree-seq
-    (fn [f] (.isDirectory (fs/statSync f) ()))
+    (fn [f] (directory? f))
     (fn [d] (map #(path/join d %) (fs/readdirSync d)))
     dir))

@@ -329,7 +329,7 @@
   ([dir]
    (let [fseq (tree-seq
                (fn [f]
-                 (and (.isDirectory (fs/lstatSync f))
+                 (and (directory? f)
                       (not (boolean
                             (re-find #"node_modules[\\\/].*[\\\/]node_modules" f)))))
                (fn [d] (map #(path/join d %) (fs/readdirSync d)))


Add the removal of the task from a card (inefficient)

--- src/cljs/clojure_rest/core.cljs
+++ src/cljs/clojure_rest/core.cljs
@@ -61,18 +61,31 @@

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-; TODO - Separate concerns : cards values and their id (for better association)
+; TODO - Separate concerns:
+; - cards values and their id, and the order in which they appear
+; - tasks values and their id

 (def card-list (r/atom []))

 (defn add-task-to!
-  "Add a new task in the card-list"
+  "Add a new task in the card"
   [card-id task]
   (defn add-if! [card]
     (if (= card-id (:card-id card))
       (update-in card [:tasks] conj (create-task! task false))
       card))
   (swap! card-list #(mapv add-if! %)))
+
+(defn remove-task-from!
+  "Remove a task from a card"
+  [card-id task-id]
+  (defn remove-if! [card]
+    (if (= card-id (:card-id card))
+      (update-in card [:tasks]
+        (fn [tasks]
+          (filterv #(not= (:task-id %) task-id) tasks)))
+      card))
+  (swap! card-list #(mapv remove-if! %)))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

@@ -112,21 +125,20 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (defn render-task
-  [task]
+  [card-id task]
   [:li.checklist__task
    [:input {:type "checkbox" :default-checked (:done task)}]
    (:name task)
    [:a.checklist__task--remove
-    {:href "#"
-     :on-click #(js/alert "TODO - remove the task")}]
+    {:href "#" :on-click #(remove-task-from! card-id (:task-id task))}]
   ])

 (defn render-tasks
-  [tasks]
+  [card-id tasks]
   [:div.checklist
    [:ul
     (for [t tasks]
-      ^{:key (:task-id t)} [render-task t])]
+      ^{:key (:task-id t)} [render-task card-id t])]
   ])

 (defn card-side-color
@@ -161,7 +173,7 @@
        (when @show-details
          [:div.card__details
           (:description card)
-          [render-tasks (:tasks card)]
+          [render-tasks (:card-id card) (:tasks card)]
           [render-add-list (:card-id card)]
          ])
        ])
@@ -185,7 +197,7 @@
 (defn render-app
   []
   (let [search-text (r/atom "")
-        on-search-enter (fn [e] (reset! search-text (.. e -target -value)))]
+        on-search-enter #(reset! search-text (.. % -target -value))]
     (fn []
       [:div
        [:input.search-input


Components initialised with atom representing ref

--- src/cljs/hacker_agent/core.cljs
+++ src/cljs/hacker_agent/core.cljs
@@ -10,9 +10,60 @@
             [hacker-agent.session :as session :refer [global-state global-put!]])
   (:import goog.History))

+(defonce hacker-root "https://hacker-news.firebaseio.com/v0")
+;; -------------------------
+;; Utils
+(defn snapshot->clj [snapshot]
+  (js->clj (.val snapshot) :keywordize-keys true))
+
+(defn id->fbref [id]
+  (.. (js/Firebase. hacker-root)
+      (child "item")
+      (child id)))
+
+(defn- fb->chan
+  ([fbref]
+   (let [events [:child_added :child_changed :child_removed]
+         chans (map (fn [event]
+                      (fb->chan fbref event))
+                    events)]
+     (merge chans)))
+  ([fbref event]
+   (let [c (chan)]
+     (.on fbref (clojure.core/name event)
+          (fn [snapshot]
+            (put! c [event
+                     (keyword (.key snapshot))
+                     (js->clj (.val snapshot))])))
+     c)))
+
+(defn- fb->atom [fbref]
+  (let [c (fb->chan fbref)
+        data (atom {})]
+    (go-loop [msg (<! c)]
+      (let [[event key val] msg]
+        (case event
+          :child_added (swap! data assoc key val)
+          :child_changed (swap! data assoc key val)
+          :child_removed (swap! data dissoc key)))
+      (recur (<! c)))
+    data))
+
+(defn listen
+  "Listens for events on the given firebase ref"
+  [root korks]
+  (let [root (p/walk-root root korks)
+        events [:child_added :child_removed :child_changed]
+        td (map (fn [[evt snap]]
+                  [evt (.name snap) (.val snap)]))
+        chans (map (fn [event]
+                     (fb->chan root event)) events)]
+    (merge chans)))
+
 ;; -------------------------
 ;; State
-(defonce app-state (atom {:text "Hello, this is: "}))
+
+(defonce app-state (atom {}))

 (defonce firebase
   (let [fb (js/Firebase. "https://hacker-news.firebaseio.com/v0")]
@@ -28,47 +79,61 @@
                  (child db)
                  (on "value"
                      (fn [snapshot]
-                       (let [curr (js->clj (.val snapshot) :keywordize-keys true)]
+                       (let [curr (snapshot->clj snapshot)]
                          (global-put! :current-item curr)))))
              (global-put! :max-item db))))
     fb))

 ;; -------------------------
 ;; Components
-(defmulti hacker-item (fn [item]
-                        (if-let [type (#{"comment" "story"} (:type item))]
-                          type
-                          :default)))
+;; (defmulti hacker-item (fn [item]
+;;                         (if-let [type (#{"comment" "story"} (:type item))]
+;;                           type
+;;                           :default)))

-(defmethod hacker-item "comment"
-  [item]
-  (let [{:keys [id by text type time]} item]
-    [:ul
-     [:li "ID: " id]
-     [:li "By: " by]
-     [:li {:dangerouslySetInnerHTML {:__html (str "Text: " text)}}]
-     [:li "Time: " time]]))
+;; (defmethod hacker-item "comment"
+;;   [item]
+;;   (let [{:keys [id by kids text type time]} item]
+;;     [:ul
+;;      [:li "ID: " id]
+;;      [:li "By: " by]
+;;      [:li {:dangerouslySetInnerHTML {:__html (str "Text: </br>" text)}}]
+;;      [:li "Number of Comments: " (count kids)]
+;;      [:li "Time: " time]]))

-(defmethod hacker-item "story"
-  [item]
-  [:p "TODO: render story item"])
+;; (defmethod hacker-item "story"
+;;   [item]
+;;   [:p "TODO: render story item"])

-(defmethod hacker-item :default
-  [item]
-  [:p "Item cannot be rendered"])
+;; (defmethod hacker-item :default
+;;   [item]
+;;   [:p "Item cannot be rendered"])
+
+(defn item [id]
+  (let [data (fb->atom (id->fbref id))]
+    (fn [id]
+      (let [{:keys [id by title kids type time url]} @data]
+        [:ul
+         [:li "ID: " id]
+         [:li "Title: " title]
+         [:li "URL: " url]
+         [:li "By: " by]
+         [:li "Comments: " (count kids)]
+         [:li "Time: " time]]))))

 (defn hacker []
-  (let [fb (js/Firebase. "https://hacker-news.firebaseio.com/v0/topstories")]
-    [:div
-     [:h2 "Home Page"]
-     [:div
-      [:h3 "Latest Item"]
-      [hacker-item (global-state :current-item)]]
-     [:div
-      [:h3 "Top Stories"]
-      [:ul
-       (for [item (global-state :stories)]
-         ^{:key item} [:li item])]]]))
+  [:div
+   [:h2 "Home Page"]
+   [:div
+    [:h3 "Test Story"]
+    [item 8678847]
+    ]
+   [:div
+    [:h3 "Top Stories"]
+    [:ul
+     (for [story (global-state :stories)]
+       ^{:key story} [:li [item story]])]
+    ]])

 ;; -------------------------
 ;; Views


remove ajax-chan from state

remove ajax-chan from state

--- src/cljs/tumblrsearch/core.cljs
+++ src/cljs/tumblrsearch/core.cljs
@@ -76,6 +76,13 @@
                  ))
   (go (async-search @data ajax-chan)))

+(defn maybe-search [data state owner]
+  (when (not (empty? (:text state)))
+    (print @data)
+    (set! js/window.location.hash
+          ((-> @data :routes :search) {:query (:text state)}))
+    (om/set-state! owner :text "")))
+
 ; Key handling ---

 (def ENTER 13)
@@ -91,11 +98,7 @@
   (let [k (key-event->keycode e)]
     (when (legal-key k)
       (condp = k
-        ENTER (do
-                (when (not (empty? (:text state)))
-                  (set! js/window.location.hash ((-> @data :routes :search)
-                                                 {:query (:text state)}))
-                  (om/set-state! owner :text "")))
+        ENTER (maybe-search data state owner)
         ESC   (om/set-state! owner :text "")))))

 ; render ---
@@ -120,10 +123,7 @@
                (dom/button
                  #js {:onClick (fn [e]
                                  (.preventDefault e)
-                                 (when (not (empty? (:text state)))
-                                   (set! js/window.location.hash ((-> @data :routes :search)
-                                                                  {:query (:text state)}))
-                                   (om/set-state! owner :text ""))
+                                 (maybe-search data state owner)
                                  )}
                  "Search")
                ; clear button
@@ -201,7 +201,7 @@
                       (dom/button
                         #js {:onClick (fn [e]
                                         (.preventDefault e)
-                                        (set! js/window.location.hash ((-> @data :routes :index)))
+                                        (set! js/window.location.hash "")
                                         )}
                         "Reset")
                       ; loading
@@ -310,45 +310,48 @@

 (defn async-window-scroll [data ajax-chan]
   (.addEventListener js/window "scroll"
-                     (fn []
-                       (when
-                         (and
-                           (= :loaded (:current-state @data))
-                           (let [body (.. js/document -body)
-                                 html  (.. js/document -documentElement)
-                                 height (max (.. body -scrollHeight)
-                                             (.. body -offsetHeight)
-                                             (.. html -clientHeight)
-                                             (.. html -scrollHeight)
-                                             (.. html -offsetHeight)
-                                             )]
-                             (> 100
-                                (- height
-                                   (+ (.. js/window -innerHeight)
-                                      (.. js/window -scrollY))))))
-                         (om/transact! data #(assoc % :current-state :loading))
-                         (go (async-search @data ajax-chan))))))
+  (fn []
+    (when
+      (and
+        (= :loaded (:current-state @data))
+        (let [body (.. js/document -body)
+              html  (.. js/document -documentElement)
+              height (max (.. body -scrollHeight)
+                          (.. body -offsetHeight)
+                          (.. html -clientHeight)
+                          (.. html -scrollHeight)
+                          (.. html -offsetHeight)
+                          )]
+          (> 100
+              (- height
+                (+ (.. js/window -innerHeight)
+                    (.. js/window -scrollY))))))
+      (om/transact! data #(assoc % :current-state :loading))
+      (go (async-search @data ajax-chan))))))

 (defn async-window-resize [data]
   (.addEventListener
     js/window "resize"
     (fn []
-      (om/transact! data #(assoc % :window-width (.. js/window -innerWidth))))))
+      (om/transact! data
+                    #(assoc % :window-width
+                            (.. js/window -innerWidth))))))

 (defn setup-navigation [data ajax-chan]
-
   (secretary/set-config! :prefix "#")

-  (defroute search-route "/search/:query" [query]
-    (new-search data query ajax-chan))
-
-  (defroute index-route "/" []
-    (om/transact! data reset-state))
-
-  (om/transact! data #(assoc % :routes
-                             {:index index-route
-                              :search search-route}))
+  (om/transact!
+    data #(assoc % :routes
+                 {
+                  :index
+                  (defroute "/" []
+                    (om/transact! data reset-state))
+
+                  :search
+                  (defroute "/search/:query" [query]
+                    (new-search data query ajax-chan))
+                  }))

   (let [h (History.)]
     (goog.events/listen h EventType/NAVIGATE #(secretary/dispatch! (.-token %)))
@@ -361,17 +364,15 @@
       om/IWillMount
       (will-mount [_]
         (let [ajax-chan (chan 1)]
-          (om/set-state! owner :ajax-chan ajax-chan)
           (async-response-loop data ajax-chan)
           (async-window-scroll data ajax-chan)
           (async-window-resize data)
-          (setup-navigation data ajax-chan)))
+          (setup-navigation    data ajax-chan)))
       om/IRenderState
       (render-state [this local-state]
         (dom/div nil
                  (case (:current-state data)
-                   :search  (om/build render-search data
-                                      {:state {:ajax-chan (om/get-state owner :ajax-chan)}})
+                   :search  (om/build render-search data)
                    :loading (om/build render-loading data)
                    :loaded  (om/build render-loaded data)
                    :loaded-final (om/build render-loaded data)


coerce msg-id to integer

coerce msg-id to integer

--- src/common/plastic/servant.cljs
+++ src/common/plastic/servant.cljs
@@ -106,7 +106,7 @@
              (transit/write (:writer context) args))))

 (defn unpack-payload [context payload]
-  {:msg-id  (aget payload "msg-id")
+  {:msg-id  (int (aget payload "msg-id"))
    :sender  (keyword (aget payload "sender"))
    :command (keyword (aget payload "command"))
    :event   (measure-time (benchmark? context) transit-label ["decode args"]


A set please, not an arbitrarily orderd list.

--- src/org/scode/sob/repos.clj
+++ src/org/scode/sob/repos.clj
@@ -16,7 +16,7 @@
   A repos has at least these keys:

     :path - the path given to this function
-    :pages - arbitrarily ordered list of pages
+    :pages - a set of pages
  "
  [path]
  ; Perform an immediate scan because it tends to be helpful to see
@@ -26,7 +26,7 @@
         :last-scan 0
         :scan-interval 1
         :scan-checkpoint 0
-        :pages []}))
+        :pages #{}}))

 (defn- now [] (System/currentTimeMillis))


Add a little more output to uberjar task.

--- src/leiningen/uberjar.clj
+++ src/leiningen/uberjar.clj
@@ -42,9 +42,9 @@
 the dependency jars. Suitable for standalone distribution."
   [project]
   (jar project)
-  (let [jarname-root  (str (:name project) \- (:version project))]
-    (with-open [out (-> (file (:root project)
-                              (str jarname-root "-standalone.jar"))
+  (let [jarname-root  (str (:name project) \- (:version project))
+        standalone-filename (str jarname-root "-standalone.jar")]
+    (with-open [out (-> (file (:root project) standalone-filename)
                         (FileOutputStream.) (ZipOutputStream.))]
       (let [deps (->> (.listFiles (file (:library-path project)))
                       (filter #(.endsWith (.getName %) ".jar"))
@@ -61,4 +61,5 @@
                          :content
                          components}]})
             (.flush *out*))
-          (.closeEntry out))))))
+          (.closeEntry out))))
+    (println "Created" (str jarname-root "-standalone.jar"))))


Add load-data-readers! function

Add load-data-readers! function

--- boot/core/src/boot/core.clj
+++ boot/core/src/boot/core.clj
@@ -159,6 +159,12 @@
   [deps]
   (vec (remove (comp (partial = 'org.clojure/clojure) first) deps)))

+(defn load-data-readers!
+  "Refresh *data-readers* with readers from newly acquired dependencies."
+  []
+  (#'clojure.core/load-data-readers)
+  (set! *data-readers* (.getRawRoot #'*data-readers*)))
+
 (defn- add-dependencies!
   "Add Maven dependencies to the classpath, fetching them if necessary."
   [old new env]


Triangle division code to create geodesics.

--- src/org/playasophy/wonderdome/geodesic.clj
+++ src/org/playasophy/wonderdome/geodesic.clj
@@ -1,8 +1,7 @@
 (ns org.playasophy.wonderdome.geodesic
   (:require
     [quil.core :refer :all]
-    [quil.helpers.drawing :refer [line-join-points]]
-    [quil.helpers.calc :refer [mul-add]]))
+    [quil.helpers.drawing :refer [line-join-points]]))

 (def strut-counts-3V
@@ -19,33 +18,115 @@
    :c 0.41241})

-; chord-factor n = 2*sin(theta/2)
-; theta = central angle
-; length of chord = r*n
-
-; 0.3486 = 1*2*sin(t/2)
-; 0.3486/2 = sin(t/2)
-; arcsin(0.3486/2) = t/2
-; 2*arcsin(ratio/2)
+(defn- to-unit-radius
+  "Projects a point to the same vector on the surface of the unit sphere."
+  [p]
+  (let [m (apply mag p)]
+    (vec (map #(/ % m) p))))

+; TODO: find a way to generate this mathematically
 (def icosahedron
-  "An icosahedron with unit radius."
+  "The set of faces making up an icosahedron with unit radius. Each face is a
+  set of three coordinate vectors."
   (let [phi (/ (+ 1 (Math/sqrt 5.0)) 2)
         -phi (- phi)
         points
-        {:A [ 0.0  1.0  phi] :B [ 0.0 -1.0  phi]
-         :C [ 0.0 -1.0 -phi] :D [ 0.0  1.0 -phi]
-         :E [ phi  0.0  1.0] :F [-phi  0.0  1.0]
-         :G [-phi  0.0 -1.0] :H [ phi  0.0 -1.0]
-         :I [ 1.0  phi  0.0] :J [-1.0  phi  0.0]
-         :K [-1.0 -phi  0.0] :L [ 1.0 -phi  0.0]}
+        {:A [ 0.0  1.0  phi]
+         :B [ 0.0 -1.0  phi]
+         :C [ 0.0 -1.0 -phi]
+         :D [ 0.0  1.0 -phi]
+         :E [ phi  0.0  1.0]
+         :F [-phi  0.0  1.0]
+         :G [-phi  0.0 -1.0]
+         :H [ phi  0.0 -1.0]
+         :I [ 1.0  phi  0.0]
+         :J [-1.0  phi  0.0]
+         :K [-1.0 -phi  0.0]
+         :L [ 1.0 -phi  0.0]}
         faces
         [[:A :I :J] [:A :J :F] [:A :F :B] [:A :B :E] [:A :E :I]
          [:B :F :K] [:B :K :L] [:B :L :E] [:C :D :H] [:C :H :L]
          [:C :L :K] [:C :K :G] [:C :G :D] [:D :G :J] [:D :J :I]
          [:D :I :H] [:E :L :H] [:E :H :I] [:F :J :G] [:F :G :K]]]
-    (set (map (comp set (partial map points)) faces))))
+    (set (map (comp set (partial map (comp to-unit-radius points))) faces))))
+
+
+(defn- midpoint
+  "Returns a new point that is a fraction of the distance towards point b
+  from point a."
+  [p a b]
+  (->>
+    (map - b a)
+    (map (partial * p))
+    (map + a)
+    to-unit-radius))
+
+
+(defn split-face
+  "Splits the edges of a triangular face into n smaller segments, then pushes
+  all the new points out to the surface of a unit sphere. Returns a set of new
+  faces."
+  [face n]
+  (if (<= n 1)
+    #{face}
+    (let [[a b c] (seq face)]
+      (cond
+        (= 0 (mod n 2))
+        ;       a
+        ;      / \
+        ;     f---d
+        ;    / \ / \
+        ;   c---e---b
+        (let [d (midpoint 1/2 a b)
+              e (midpoint 1/2 b c)
+              f (midpoint 1/2 c a)]
+          (->>
+            [         #{a d f}
+             #{f e c} #{f d e} #{d b e}]
+            (mapcat #(split-face % (/ n 2)))
+            set))
+
+        (= 0 (mod n 3))
+        ;       a
+        ;      / \
+        ;     i---d
+        ;    / \ / \
+        ;   h---j---e
+        ;  / \ / \ / \
+        ; c---g---f---b
+        (let [d (midpoint 1/3 a b)
+              e (midpoint 2/3 a b)
+              f (midpoint 1/3 b c)
+              g (midpoint 2/3 b c)
+              h (midpoint 1/3 c a)
+              i (midpoint 2/3 c a)
+              j (midpoint 1/2 h e)]
+          (->>
+            [                  #{a d i}
+                      #{i j h} #{i d j} #{d e j}
+             #{h g c} #{h j g} #{j f g} #{j e f} #{e f b}]
+            (mapcat #(split-face % (/ n 3)))
+            set))
+
+        :else
+        (throw (IllegalArgumentException.
+                 (str n " is not divisible by any supported prime")))))))
+
+
+(defn split-faces
+  [shape n]
+  (set (mapcat #(split-face % n) shape)))
+
+
+(defn- face->lines
+  "Converts a face (set of three points) into a sequence of edge lines."
+  [face]
+  (as-> face points
+    (vec points)
+    (conj points (first points))
+    (partition 2 points)))
+

 ;;;;; SKETCH CODE ;;;;;
@@ -58,29 +139,18 @@
 (defn draw []
   (background 255)
   (translate (/ (width) 2) (/ (height) 2) 0)
-  (rotate-y (* (frame-count) 0.03))
-  (rotate-x (* (frame-count) 0.04))
-  (doseq [face icosahedron]
+  (rotate-y (* (frame-count) 0.01))
+  ;(rotate-x (* (frame-count) 0.04))
+  (doseq [face (split-faces icosahedron 3)]
     (-> face
         (as-> points
-          (map #(vec (map (partial * 50) %)) points)   ; scale the points
+          (map #(vec (map (partial * 100) %)) points)   ; scale the points
           (vec points)
           (conj points (first points)))                ; repeat the last point
         line-join-points
         (as-> lines
           (map (partial apply line) lines))
-        dorun))
-  #_
-  (let [line-args (for [t (range 0 180)]
-                    (let [s (* t 18)
-                          radian-s (radians s)
-                          radian-t (radians t)
-                          x (* radius (cos radian-s) (sin radian-t))
-                          y (* radius (sin radian-s) (sin radian-t))
-                          z (* radius (cos radian-t))]
-                      [x y z]))]
-    (dorun
-     (map #(apply line %) (line-join-points line-args)))))
+        dorun)))

 (defsketch geodesic-dome


(maint) - Change queue in/out serialization to json form edn

--- src/puppetlabs/cthun/queueing/activemq.clj
+++ src/puppetlabs/cthun/queueing/activemq.clj
@@ -19,7 +19,7 @@
         mq-endpoint topic]
     (log/info "queueing message" message)
     (with-open [conn (mq/activemq-connection mq-spec)]
-      (mq/connect-and-publish! conn mq-endpoint (pr-str message)))))
+      (mq/connect-and-publish! conn mq-endpoint (json/generate-string message)))))

 (defn subscribe-to-topic
   [consumer-count queues topic callback-fn]
@@ -30,7 +30,8 @@
                                          {:endpoint   topic
                                           :on-message (fn [message]
                                                         (log/info "consuming message" (:body message))
-                                                        (callback-fn (edn/read-string (:body message))))
+                                                        ; TODO(ploubser): Take another look at using edn instead
+                                                        (callback-fn (json/parse-string (:body message) true)))
                                           :transacted true
                                           :on-failure #(log/error "error consuming message" (:exception %))})]
           (mq-cons/start consumer))))))


Added function to deactivate a User resource. Fixes #15

--- src/prop_shop/data/user.clj
+++ src/prop_shop/data/user.clj
@@ -32,3 +32,10 @@
 	{:added "0.1"}
 	[uuid name]
 	(b/update-entity-by-uuid uuid {:name name}))
+
+
+(defn deactivate-user
+  "Deactivates the User specified by the UUID."
+  {:added "0.1"}
+	[uuid]
+	(b/deactivate-entity uuid))


- minor datepicker demo cleanups

- minor datepicker demo cleanups

--- src/re_demo/datepicker.cljs
+++ src/re_demo/datepicker.cljs
@@ -10,6 +10,10 @@
     [re-demo.utils     :refer [panel-title title2 args-table github-hyperlink status-text]]))

+(def ^:private days-map
+     {:Su "S" :Mo "M" :Tu "T" :We "W" :Th "T" :Fr "F" :Sa "S"})
+
+
 (defn- toggle-inclusion!
   "convenience function to include/exclude member from"
   [set-atom member]
@@ -18,54 +22,55 @@
             (disj @set-atom member)
             (conj @set-atom member))))

-(def ^:private days-map
-  {:Su "S" :Mo "M" :Tu "T" :We "W" :Th "T" :Fr "F" :Sa "S"})
+
+(defn- checkbox-for-day
+  [day enabled-days]
+  [v-box
+   :align    :center
+   :children [[label
+               :style {:font-size "smaller"}
+               :label (day days-map)]
+              [checkbox
+               :model     (@enabled-days day)
+               :on-change #(toggle-inclusion! enabled-days day)]]])

 (defn- parameters-with
+  "Toggle controls for some parameters."
   [content enabled-days disabled? show-today? show-weeks?]
-  (let [day-check (fn [day] [v-box
-                       :align    :center
-                       :children [[:label {:class "day-enabled"} (day days-map)]
-                                  [checkbox
-                                   :model     (@enabled-days day)
-                                   :on-change #(toggle-inclusion! enabled-days day)
-                                   :style     {:margin-top "-2px"}]]])]
-    (fn []
-      [v-box
-       :width    "600px"
-       :gap      "20px"
-       :align    :start
-       :children [[gap :size "20px"]
-                  [title :level :level3 :label "Parameters"]
-                  [h-box
-                   :gap      "20px"
-                   :align    :start
-                   :children [[checkbox
-                               :label     [box :align :start :child [:code ":disabled?"]]
-                               :model     disabled?
-                               :on-change #(reset! disabled? %)]
-                              [checkbox
-                               :label     [box :align :start :child [:code ":show-today?"]]
-                               :model     show-today?
-                               :on-change #(reset! show-today? %)]
-                              [checkbox
-                               :label     [box :align :start :child [:code ":show-weeks?"]]
-                               :model     show-weeks?
-                               :on-change #(reset! show-weeks? %)]]]
-                  [h-box
-                   :gap      "2px"
-                   :align    :center
-                   :children [[day-check :Su]
-                              [day-check :Mo]
-                              [day-check :Tu]
-                              [day-check :We]
-                              [day-check :Th]
-                              [day-check :Fr]
-                              [day-check :Sa]
-                              [gap :size "5px"]
-                              [box :align :start :child [:code ":selectable-fn"]]]]
-                  [:span [:code "e.g. (fn [date] (#{1 2 3 4 5 6 7} (day-of-week date)))"]]
-                  content]])))
+  [v-box
+   :gap      "15px"
+   :align    :start
+   :children [[gap :size "20px"]
+              [title :level :level3 :label "Parameters"]
+              [h-box
+               :gap      "20px"
+               :align    :start
+               :children [[checkbox
+                           :label     [box :align :start :child [:code ":disabled?"]]
+                           :model     disabled?
+                           :on-change #(reset! disabled? %)]
+                          [checkbox
+                           :label     [box :align :start :child [:code ":show-today?"]]
+                           :model     show-today?
+                           :on-change #(reset! show-today? %)]
+                          [checkbox
+                           :label     [box :align :start :child [:code ":show-weeks?"]]
+                           :model     show-weeks?
+                           :on-change #(reset! show-weeks? %)]]]
+              [h-box
+               :gap      "2px"
+               :align    :center
+               :children [[checkbox-for-day :Su enabled-days]
+                          [checkbox-for-day :Mo enabled-days]
+                          [checkbox-for-day :Tu enabled-days]
+                          [checkbox-for-day :We enabled-days]
+                          [checkbox-for-day :Th enabled-days]
+                          [checkbox-for-day :Fr enabled-days]
+                          [checkbox-for-day :Sa enabled-days]
+                          [gap :size "5px"]
+                          [box :align :start :child [:code ":selectable-fn"]]]]
+              [:span [:code "e.g. (fn [date] (#{1 2 3 4 5 6 7} (day-of-week date)))"]]
+              content]])

 (defn- date->string
@@ -88,7 +93,7 @@
         selectable-pred (fn [date] (@as-days (day-of-week date))) ; Simply allow selection based on day of week.
         label-style     {:font-style "italic" :font-size "smaller" :color "#777"}]
     (case variation
-      :inline [(fn
+      :inline [(fn inline-fn
                  []
                  [parameters-with
                   [h-box
@@ -125,7 +130,7 @@
                   disabled?
                   show-today?
                   show-weeks?])]
-      :dropdown [(fn
+      :dropdown [(fn dropdown-fn
                    []
                    [parameters-with
                     [h-box
@@ -152,10 +157,10 @@
    {:id :dropdown :label "Dropdown"}])

-(defn panel2
+(defn datepicker-examples
   []
   (let [selected-variation (reagent/atom :inline)]
-    (fn []
+    (fn examples-fn []
       [v-box
        :size     "auto"
        :gap      "10px"
@@ -190,4 +195,4 @@
 ;; core holds a reference to panel, so need one level of indirection to get figwheel updates
 (defn panel
   []
-  [panel2])
+  [datepicker-examples])


Failure test earlier to avoid infinite loops

--- src/refactor_nrepl/util.clj
+++ src/refactor_nrepl/util.clj
@@ -142,24 +142,25 @@
               ready false]
          (let [[ch & chars] chars
                char-index (dec cnt)]
-           (cond (and ready (pred op-cl))
-                 (if (and (= (nth s char-index) \{)
-                          (not= 0 char-index)
-                          (= (nth s (prev-char-fn char-index)) \#))
-                   (prev-char-fn char-index)
-                   char-index)
-
-                 (open ch)
-                 (recur chars (inc cnt) (inc op-cl) true)
-
-                 (close ch)
-                 (recur chars (inc cnt) (dec op-cl) true)
-
-                 (> cnt (count s)) (throw (IllegalArgumentException.
-                                           "Can't find sexp boundary!"))
-
-                 :else
-                 (recur chars (inc cnt) op-cl ready))))
+           (cond
+             (> cnt (count s)) (throw (IllegalArgumentException.
+                                       "Can't find sexp boundary!"))
+
+             (and ready (pred op-cl))
+             (if (and (= (nth s char-index) \{)
+                      (not= 0 char-index)
+                      (= (nth s (prev-char-fn char-index)) \#))
+               (prev-char-fn char-index)
+               char-index)
+
+             (open ch)
+             (recur chars (inc cnt) (inc op-cl) true)
+
+             (close ch)
+             (recur chars (inc cnt) (dec op-cl) true)
+
+             :else
+             (recur chars (inc cnt) op-cl ready))))
        0))))

 (defn- cut-sexp [code sexp-start sexp-end]


comment out difform for now

comment out difform for now

--- bake/bake/test.clj
+++ bake/bake/test.clj
@@ -1,8 +1,7 @@
 (ns bake.test
   (:use [cake.contrib.find-namespaces :only [find-namespaces-in-dir]])
   (:require clojure.test
-            [clojure.stacktrace :as stack]
-            [com.georgejahad.difform :as diff]))
+            [clojure.stacktrace :as stack]))

 (defn map-tags [nses]
   (reduce (partial merge-with concat)
@@ -68,7 +67,7 @@
       (println ".")
       (print-results m))))

-(defn diff-actual [[f [_ expected actual]]]
+(comment defn diff-actual [[f [_ expected actual]]]
   (diff/clean-difform expected actual))

 (defmethod clojure.test/report :fail [m]
@@ -81,7 +80,7 @@
           actual   (:actual m)]
       (println "expected:" (pr-str expected))
       (println "  actual:" (pr-str actual))
-      (when (seq? actual)
+      (comment when (seq? actual)
         (diff-actual actual)))))

 (declare start-time)


Use destructuring

Use destructuring

--- src/github_changelog/semver.clj
+++ src/github_changelog/semver.clj
@@ -5,10 +5,10 @@
             [clojure.string :as str]
             [github-changelog.spec :as spec]))

-(defn- map->str [m]
-  (cond-> (->> (map m [:major :minor :patch]) (str/join \.))
-    (:pre-release m) (str "-" (:pre-release m))
-    (:build m) (str "+" (:build m))))
+(defn- map->str [{:keys [major minor patch pre-release build]}]
+  (cond-> (str/join \. [major minor patch])
+    pre-release (str "-" pre-release)
+    build (str "+" build)))

 (s/def ::major nat-int?)
 (s/def ::minor nat-int?)


Formatting

Formatting

--- src/onyx/plugin/kafka.clj
+++ src/onyx/plugin/kafka.clj
@@ -168,9 +168,8 @@
     (catch InterruptedException e
       (throw e))))

-(defn check-num-peers-equals-partitions [{:keys [onyx/min-peers onyx/max-peers
-                                                 kafka/partition] :as task-map}
-                                         n-partitions]
+(defn check-num-peers-equals-partitions
+  [{:keys [onyx/min-peers onyx/max-peers kafka/partition] :as task-map} n-partitions]
   (let [fixed-partition? (and partition (= 1 max-peers))
         all-partitions-covered? (= n-partitions min-peers max-peers)
         one-partition? (= 1 n-partitions max-peers)]


HTML escaping due to colleagues' slightly annoying sense of humor

--- src/statuses/views/main.clj
+++ src/statuses/views/main.clj
@@ -9,7 +9,8 @@
         [noir.request :only [ring-request]]
         [hiccup.element]
         [hiccup.form]
-        [hiccup.page]))
+        [hiccup.page]
+        [hiccup.util]))

 (defn user []
   (or (get-in (ring-request) [:headers "remote_user"]) "guest"))
@@ -32,6 +33,7 @@
         hashtag (fn [[_ m]] (str "#" m ""))
         anchor  (fn [[m _]] (str "" m ""))]
     (-> text
+        escape-html
         (clojure.string/replace #"@(\w*)" handle)
         (clojure.string/replace uri anchor)
         (clojure.string/replace #"#(\w*)" hashtag))))


Fix heading.

Fix heading.

--- src/stuttaford/radiant.cljs
+++ src/stuttaford/radiant.cljs
@@ -125,7 +125,7 @@
                      (case current-datoms-index
                        :eavt [:tr [:th "E"] [:th "A"] [:th "V"]]
                        :aevt [:tr [:th "A"] [:th "E"] [:th "V"]]
-                       :avet [:tr [:th "A"] [:th "V"] [:th "T"]])]
+                       :avet [:tr [:th "A"] [:th "V"] [:th "E"]])]
                     [:tbody
                      (for [{:keys [e a v]} datoms]
                        (case current-datoms-index


Remove sample state. Show empty div when no view is selected.

--- src/stuttaford/radiant.cljs
+++ src/stuttaford/radiant.cljs
@@ -31,17 +31,10 @@
        (p/panel {:header (components/->top-nav data {:opts {:nav-items nav-items}})}
                 (when schema-visible?
                   (components/->schema data))
-                (when view-component
-                  (om/build view-component data)))))))
+                (if view-component
+                  (om/build view-component data)
+                  (html [:div])))))))

 (defn ^:export init
   [app-id state-id debug?]
-  (common/start
-    app-id state-id app-view
-    {:view                      :datalog
-     :query                     "[:find ?tag ?title :in $ :where [?link-id :link/title ?title] [?link-id :link/tags ?tag-id] [?tag-id :tag/name ?tag]]"
-     :current-datoms-index      :avet
-     :current-datoms-components {:a ":link/title"}
-     :schema-visible?           false
-     :shared                    {:control-chan (chan)}}
-    debug?))
+  (common/start app-id state-id app-view {:shared {:control-chan (chan)}} debug?))


still have to load schema ents

still have to load schema ents

--- src/pc/datomic/schema.clj
+++ src/pc/datomic/schema.clj
@@ -521,5 +521,6 @@

 (defn init []
   ;; TODO: remove migrating check after migration
-  (when-not (pc.profile/migrating-to-new-storage?)
+  (if (pc.profile/migrating-to-new-storage?)
+    (reset! schema-ents (get-schema-ents (pcd/default-db)))
     (ensure-schema)))


CMR-7958: Updated error message.

CMR-7958: Updated error message.

--- common-app-lib/src/cmr/common_app/services/search/elastic_search_index.clj
+++ common-app-lib/src/cmr/common_app/services/search/elastic_search_index.clj
@@ -130,7 +130,7 @@
           (info "Execute ES query failed due to" body)
           (errors/throw-service-error
            :too-many-requests
-           "Trying to create too many scroll contexts.
+           "CMR is currently experiencing too many scroll searches to complete this request.
            Scroll is deprecated in CMR. Please consider switching your scroll requests to use search-after.
            See https://cmr.earthdata.nasa.gov/search/site/docs/search/api.html#search-after.
            This will make your workflow simpler (no more clear-scroll calls) and improve the stability of both your searches and CMR Elasticsearch cluster.


Added scaling/rotation to entity drawing

use fields :scale-x :scale-y :origin-x :origin-x and :angle to scale/rotate entities
when angle and both scales are not set, this will still use the simpler drawing

--- src/play_clj/entities.clj
+++ src/play_clj/entities.clj
@@ -18,12 +18,19 @@
   (draw-entity! [this screen batch]))

 (defrecord TextureEntity [object] Entity
-  (draw-entity! [{:keys [^TextureRegion object x y width height]} _ batch]
+  (draw-entity! [{:keys [^TextureRegion object x y width height scale-x scale-y angle origin-x origin-y]} _ batch]
     (let [x (float (or x 0))
           y (float (or y 0))
           width (float (or width (.getRegionWidth object)))
           height (float (or height (.getRegionHeight object)))]
-      (.draw ^SpriteBatch batch object x y width height))))
+      (if (or scale-x scale-y angle)
+        (let [scale-x (or scale-x 1)
+              scale-y (or scale-y 1)
+              origin-x (or origin-x (/ width 2))
+              origin-y (or origin-y (/ width 2))
+              angle (or angle 0)]
+          (.draw ^SpriteBatch batch object x y origin-x origin-y width height scale-x scale-y angle))
+        (.draw ^SpriteBatch batch object x y width height)))))

 (defrecord NinePatchEntity [object] Entity
   (draw-entity! [{:keys [^NinePatch object x y width height]} _ batch]


implement selection function

implement selection function

--- markov-clj/src/markov_clj/markov.clj
+++ markov-clj/src/markov_clj/markov.clj
@@ -7,7 +7,6 @@
   (let [key (vec (drop-last tuple))
         value (last tuple)]
     [key value]))
-

 (defn index-frequencies [database [key val]]
   (if-let [val-at-key (database key)]
@@ -26,8 +25,22 @@

 ;; TODO map-filtered somethingwhatsit
+
+(defn next-word [prefix database]
+  (let [value-map (database prefix)]
+    (select-randomly value-map)))
+
+(defn select-randomly [val-map]
+  (-> val-map
+      (map (fn [[k v]] (repeat v k)) ,,)
+      (apply conj ,,)
+      flatten
+      rand-nth))
+
+(select-randomly {"foggy" 1, "sunny" 5, "cloudy" 1, "blue" 1})
+
 (defn create-sentence [seed database]
-  )
+  (iterate #(next-word % database) seed))

 (defn lookup [key database]
   (database key))


making test less flaky

making test less flaky

--- test/com/ig/swagger/search/parser_test.clj
+++ test/com/ig/swagger/search/parser_test.clj
@@ -61,16 +61,16 @@
 (deftest parse-swagger-response-v2-api-path
   (facts "parsing the swagger v2 response with only path and method"
          (parse-v2 "parser_v2_minimum_fields.json") =>
-         (just [{:path                    "/ping/abc"
-                 :method                  "GET"
-                 :service-name            nil,
-                 :service-version         nil,
-                 :swagger-version         "2.0"
-                 :servlet-context         nil
-                 :summary-and-description ""
-                 :responses               []
-                 :parameters              []
-                 :ui-api-path             "/default/GET_ping_abc"}]
+         (just [(contains {:path                    "/ping/abc"
+                           :method                  "GET"
+                           :service-name            nil,
+                           :service-version         nil,
+                           :swagger-version         "2.0"
+                           :servlet-context         nil
+                           :summary-and-description ""
+                           :responses               []
+                           :parameters              []
+                           :ui-api-path             "/default/GET_ping_abc"})]
                :in-any-order)))

 (deftest parse-swagger-response-v1


Refactor make-jmessage.

Refactor make-jmessage.

--- src/clj/com/draines/postal/message.clj
+++ src/clj/com/draines/postal/message.clj
@@ -43,6 +43,11 @@
                         (.setContent (:content part) (:type part))))))
     (.setContent jmsg mp)))

+(defn add-body! [jmsg body]
+  (if (string? body)
+    (doto jmsg (.setText body))
+    (doto jmsg (add-multipart! body))))
+
 (defn make-jmessage
   ([msg]
      (let [{:keys [sender from host port]} msg
@@ -55,16 +60,14 @@
   ([msg session]
      (let [{:keys [from to cc bcc date subject body]} msg
            jmsg (MimeMessage. session)]
-       (add-recipients! jmsg Message$RecipientType/TO to)
-       (add-recipients! jmsg Message$RecipientType/CC cc)
-       (add-recipients! jmsg Message$RecipientType/BCC bcc)
-       (.setFrom jmsg (InternetAddress. from))
-       (.setSubject jmsg subject)
-       (if (string? body)
-         (.setText jmsg body)
-         (add-multipart! jmsg body))
-       (.setSentDate jmsg (or date (make-date)))
-       jmsg)))
+       (doto jmsg
+         (add-recipients! Message$RecipientType/TO to)
+         (add-recipients! Message$RecipientType/CC cc)
+         (add-recipients! Message$RecipientType/BCC bcc)
+         (.setFrom (InternetAddress. from))
+         (.setSubject subject)
+         (.setSentDate (or date (make-date)))
+         (add-body! body)))))

 (deftest test-simple
   (let [m {:from "fee@bar.dom"


Fix to rm unecessary threading

Fix to rm unecessary threading

--- src/clj/kixi/hecuba/api/programmes.clj
+++ src/clj/kixi/hecuba/api/programmes.clj
@@ -30,13 +30,13 @@
 (defn filter-programmes [allowed-programmes allowed-projects programme-ids-for-projects all-programmes]
   (let [allowed-programme-ids      (into #{} (keys allowed-programmes))
         allowed-project-ids        (into #{} (keys allowed-projects))]
-    (->> all-programmes
-         (keep (fn [programme]
-                (let [programme-id (:programme_id programme)]
-                  (cond
-                   (some #{programme-id} allowed-programme-ids) (enrich-by-role (get allowed-programmes programme-id) programme)
-                   (some #{programme-id} programme-ids-for-projects) (enrich-by-role :kixi.hecuba.security/user programme)
-                   (:public_access programme) (assoc programme :editable false))))))))
+    (keep (fn [programme]
+            (let [programme-id (:programme_id programme)]
+              (cond
+                (some #{programme-id} allowed-programme-ids) (enrich-by-role (get allowed-programmes programme-id) programme)
+                (some #{programme-id} programme-ids-for-projects) (enrich-by-role :kixi.hecuba.security/user programme)
+                (:public_access programme) (assoc programme :editable false))))
+          all-programmes)))

 (defn allowed?*
   ([allowed-programmes allowed-projects role request-method store]


don't execute "ignore__" response from server

--- src/cljs/ubolonton/xulrunner/repl.cljs
+++ src/cljs/ubolonton/xulrunner/repl.cljs
@@ -39,9 +39,15 @@
     (go-loop [code (<! incoming)]
       ;; XXX: repl/evaluate-javascript takes conn but does nothing
       ;; with it, we just pass it nil
+      (util/log "repl:got code" code)
       (when-not (nil? code)
-        (>! result (repl/evaluate-javascript nil code))
+        ;; XXX: This should not be here. But where?
+        (when-not (= code "ignore__")
+          (util/log "repl:executing")
+          (>! result (repl/evaluate-javascript nil code))
+          (util/log "repl:executed"))
         (recur (<! incoming)))
+      (util/log "repl:closing")
       (close! result)
       (close! print))))


Use ->ConditionType instead of ConditionType. etc. in macro-generated code.

This avoids problems with AOT compilation.

--- src/cljx/active/clojure/condition.cljx
+++ src/cljx/active/clojure/condition.cljx
@@ -195,12 +195,12 @@
   `(do
      (let [total-field-count# (+ ~(count ?field-specs) (:total-field-count ~?supertype))]
        (def ~?condition-type
-         (ConditionType. '~?condition-type ~?supertype
-                         '[~@(map first ?field-specs)] total-field-count#))
+         (->ConditionType '~?condition-type ~?supertype
+                          '[~@(map first ?field-specs)] total-field-count#))
        (defn ~?constructor
          [& args#]
          {:pre [(= (count args#) total-field-count#)]}
-         (make-condition [(ConditionComponent. ~?condition-type (vec args#))]))
+         (make-condition [(->ConditionComponent ~?condition-type (vec args#))]))
        (def ~?predicate (condition-predicate ~?condition-type))
        ~@(map (fn [[?field-name ?accessor]]
                 `(def ~?accessor (condition-accessor ~?condition-type '~?field-name)))


additional sanity check

additional sanity check

--- test/matross/tasks/file_streaming_test.clj
+++ test/matross/tasks/file_streaming_test.clj
@@ -19,4 +19,5 @@
      (let [result-buffer (new StringWriter)
            get-result (run-task test-conn
                                 {:type :stream-from-file :src target :dest result-buffer})]
+       (is (:succeeded? get-result) "retrieved file")
        (is (= (.toString result-buffer) file-contents))))))


Update docstrings.

Update docstrings.

--- src/rosado/processing.clj
+++ src/rosado/processing.clj
@@ -877,9 +877,8 @@
   the lifespan of the program). The resulting value will always be
   between 0.0 and 1.0. Processing can compute 1D, 2D and 3D noise,
   depending on the number of coordinates given. The noise value can be
-  animated by moving through the noise space as demonstrated in the
-  example above. The 2nd and 3rd dimension can also be interpreted as
-  time.
+  animated by moving through the noise space and the 2nd and 3rd
+  dimensions can also be interpreted as time.

   The actual noise is structured similar to an audio signal, in
   respect to the function's use of frequencies. Similar to the concept
@@ -890,7 +889,7 @@
   scale of the input coordinates. As the function works within an
   infinite space the value of the coordinates doesn't matter as such,
   only the distance between successive coordinates does (eg. when
-  using noise() within a loop). As a general rule the smaller the
+  using noise within a loop). As a general rule the smaller the
   difference between coordinates, the smoother the resulting noise
   sequence will be. Steps of 0.005-0.03 work best for most
   applications, but this will differ depending on use."
@@ -1000,7 +999,17 @@

 (defn print-projection [] (.printProjection *applet*))

-(defn push-matrix [] (.pushMatrix *applet*))
+(defn push-matrix
+  "Pushes the current transformation matrix onto the matrix
+  stack. Understanding push-matrix and pop-matrix requires
+  understanding the concept of a matrix stack. The push-matrix
+  function saves the current coordinate system to the stack and
+  pop-matrix restores the prior coordinate system. push-matrix and
+  pop-matrix are used in conjuction with the other transformation
+  methods and may be embedded to control the scope of the
+  transformations."
+  []
+  (.pushMatrix *applet*))

 (defn quad
   "A quad is a quadrilateral, a four sided polygon. It is similar to a
@@ -1073,15 +1082,69 @@
 (defn reverse-array [arr] (PApplet/reverse arr))

 (defn rotate
+  "Rotates a shape the amount specified by the angle parameter. Angles
+  should be specified in radians (values from 0 to TWO-PI) or
+  converted to radians with the radians function.
+
+  Objects are always rotated around their relative position to the
+  origin and positive numbers rotate objects in a clockwise
+  direction. Transformations apply to everything that happens after
+  and subsequent calls to the function accumulates the effect. For
+  example, calling (rotate HALF-PI) and then (rotate HALF-PI) is the
+  same as (rotate PI). All tranformations are reset when draw begins
+  again.
+
+  Technically, rotate multiplies the current transformation matrix by
+  a rotation matrix. This function can be further controlled by the
+  push-matrix and pop-matrix."
   ([angle] (.rotate *applet* (float angle)))
   ([angle vx vy vz] (.rotate *applet* (float angle)
                              (float vx) (float vy) (float vz))))

-(defn rotate-x [angle] (.rotateX *applet* (float angle)))
-
-(defn rotate-y [angle] (.rotateY *applet* (float angle)))
-
-(defn rotate-z [angle] (.rotateZ *applet* (float angle)))
+(defn rotate-x
+  "Rotates a shape around the x-axis the amount specified by the angle
+  parameter. Angles should be specified in radians (values from 0 to
+  (* PI 2)) or converted to radians with the radians function. Objects are
+  always rotated around their relative position to the origin and
+  positive numbers rotate objects in a counterclockwise
+  direction. Transformations apply to everything that happens after
+  and subsequent calls to the function accumulates the effect. For
+  example, calling (rotate-x HALF-PI) and then (rotate-x HALF-PI) is
+  the same as (rotate-x PI). If rotate-x is called within the draw fn,
+  the transformation is reset when the loop begins again. This
+  function requires passing P3D or OPENGL into the size parameter."
+  [angle]
+  (.rotateX *applet* (float angle)))
+
+(defn rotate-y
+  "Rotates a shape around the y-axis the amount specified by the angle
+  parameter. Angles should be specified in radians (values from 0
+  to (* PI 2)) or converted to radians with the radians function.
+  Objects are always rotated around their relative position to the
+  origin and positive numbers rotate objects in a counterclockwise
+  direction. Transformations apply to everything that happens after
+  and subsequent calls to the function accumulates the effect. For
+  example, calling (rotate-y HALF-PI) and then (rotate-y HALF-PI) is
+  the same as (rotate-y PI). If rotate-y is called within the draw fn,
+  the transformation is reset when the loop begins again. This
+  function requires passing P3D or OPENGL into the size parameter."
+  [angle]
+  (.rotateY *applet* (float angle)))
+
+(defn rotate-z
+  "Rotates a shape around the z-axis the amount specified by the angle
+  parameter. Angles should be specified in radians (values from 0
+  to (* PI 2)) or converted to radians with the radians function.
+  Objects are always rotated around their relative position to the
+  origin and positive numbers rotate objects in a counterclockwise
+  direction. Transformations apply to everything that happens after
+  and subsequent calls to the function accumulates the effect. For
+  example, calling (rotate-z HALF-PI) and then (rotate-z HALF-PI) is
+  the same as (rotate-z PI). If rotate-y is called within the draw fn,
+  the transformation is reset when the loop begins again. This
+  function requires passing P3D or OPENGL into the size parameter."
+  [angle]
+  (.rotateZ *applet* (float angle)))

 (defn round [what] (PApplet/round (float what)))

@@ -1327,6 +1390,16 @@
 (def tint tint-float)

 (defn translate
+  "Specifies an amount to displace objects within the display
+  window. The x parameter specifies left/right translation, the y
+  parameter specifies up/down translation, and the z parameter
+  specifies translations toward/away from the screen.  Transformations
+  apply to everything that happens after and subsequent calls to the
+  function accumulates the effect. For example, calling (translate 50
+  0) and then (translate 20,h 0) is the same as (translate 70, 0). If
+  translate is called within draw, the transformation is reset when
+  the loop begins again. This function can be further controlled by
+  the push-matrix and pop-matrix."
   ([v] (apply translate v))
   ([tx ty] (.translate *applet* (float tx) (float ty)))
   ([tx ty tz] (.translate *applet* (float tx) (float ty) (float tz))))


test complete

test complete

--- src/clj/starcity/views/landing.clj
+++ src/clj/starcity/views/landing.clj
@@ -40,7 +40,7 @@
    (head "Starcity")
    [:body
     [:div#app
-     [:h1 "Hello, Jocelyn!"]]
+     [:h1 "Hello, Starcity!"]]
     ;; TODO: advanced cljs
     ;; (apply include-js BODY-JS)
     ]))


Expand `deftest replaces-ns-references-in-dependents`

Closes https://github.com/clojure-emacs/refactor-nrepl/issues/172, which was already (inadvertently) fixed in https://github.com/clojure-emacs/refactor-nrepl/pull/365.

--- testproject/src/com/move/dependent_ns1.clj
+++ testproject/src/com/move/dependent_ns1.clj
@@ -19,6 +19,9 @@
   (let [^com.move.ns_to_be_moved.TypeToBeMoved x (fn-to-be-moved :_)]
     x)

+  ;; https://github.com/clojure-emacs/refactor-nrepl/issues/172
+  (partial instance? com.move.ns_to_be_moved.TypeToBeMoved)
+
   (com.move.ns_to_be_moved.TypeToBeMoved. :ok)

   (macro-to-be-moved


Reverted an unneeded change.

Reverted an unneeded change.

--- src/cljs/wombats_web_client/components/modals/winner-modal.cljs
+++ src/cljs/wombats_web_client/components/modals/winner-modal.cljs
@@ -25,6 +25,5 @@
      (if tied? [tied-info wombats] [winner-info (first wombats)])
      [:div.redirect-buttons
       [:div.return-to-lobby [:a {:href "/"
-                                 :on-click (fn [evt]
-                                             (re-frame/dispatch [:set-modal nil]))}
+                                 :on-click #(re-frame/dispatch [:set-modal nil])}
                              "RETURN TO LOBBY"]]]]))


:bug: Fix single text shape rendering.

:bug: Fix single text shape rendering.

--- exporter/src/app/http/export_svg.cljs
+++ exporter/src/app/http/export_svg.cljs
@@ -87,7 +87,7 @@
                                  :scale 4})
              (bwr/set-cookie! page cookie)
              (bwr/navigate! page uri)
-             (bwr/eval! page (js* "() => document.body.style.background = 'transparent'"))
+             ;; (bwr/eval! page (js* "() => document.body.style.background = 'transparent'"))
              page))

           (convert-to-ppm [pngpath]


CMR-2124: Reverting accidental change.

CMR-2124: Reverting accidental change.

--- metadata-db-app/int_test/cmr/metadata_db/int_test/concepts/search_test.clj
+++ metadata-db-app/int_test/cmr/metadata_db/int_test/concepts/search_test.clj
@@ -64,7 +64,7 @@
              (set errors))))))

 (deftest get-concepts-with-one-invalid-id-test-allow-missing
-  (doseq [provider-id ["REG_PROV" #_"SMAL_PROV1"]]
+  (doseq [provider-id ["REG_PROV" "SMAL_PROV1"]]
     (let [coll1 (util/create-and-save-collection provider-id 1)
           tuples [[(:concept-id coll1) 1]
                   [(:concept-id coll1) 2]


Hide dragged item on sitemap sidebar widget.

--- frontend/src/uxbox/main/ui/workspace/sidebar/sitemap.cljs
+++ frontend/src/uxbox/main/ui/workspace/sidebar/sitemap.cljs
@@ -42,14 +42,16 @@

 (mx/defcs page-item
   {:mixins [(mx/local) mx/static mx/reactive]}
-  [own page total active?]
-  (let [local (:rum/local own)
-        classes (classnames
-                 :selected active?
-                 :drag-active (:dragging @local)
-                 :drag-top (= :top (:over @local))
-                 :drag-bottom (= :bottom (:over @local))
-                 :drag-inside (= :middle (:over @local)))]
+  [{:keys [rum/local] :as own} page total active?]
+  (let [body-classes (classnames
+                      :selected active?
+                      :drag-active (:dragging @local)
+                      :drag-top (= :top (:over @local))
+                      :drag-bottom (= :bottom (:over @local))
+                      :drag-inside (= :middle (:over @local)))
+        li-classes (classnames
+                    :selected active?
+                    :hide (:dragging @local))]
     (letfn [(on-edit [event]
               (udl/open! :page-form {:page page}))

@@ -96,9 +98,9 @@
               (swap! local assoc :over true))
             (on-drag-leave [event]
               (swap! local assoc :over false))]
-    [:li {:class (when active? "selected")}
+    [:li {:class li-classes}
      [:div.element-list-body
-      {:class classes
+      {:class body-classes
        :style {:opacity (if (:dragging @local)
                           "0.5"
                           "1")}


Päivitä riippuvuuksia

Päivitä riippuvuuksia

--- clj-log/project.clj
+++ clj-log/project.clj
@@ -1,10 +1,10 @@
-(defproject oph/clj-log "0.2.4-SNAPSHOT"
+(defproject oph/clj-log "0.3.0-SNAPSHOT"
             :description "oph clojure logging utilities"
             :url "http://example.com/FIXME"
             :license {:name "EUPL"
                       :url "http://www.osor.eu/eupl/"}
             :plugins [[lein-modules "0.3.11"]]
-            :dependencies [[org.clojure/tools.logging "0.4.0"]
-                           [clj-time "0.14.2"]
-                           [cheshire "5.8.0"]
+            :dependencies [[org.clojure/tools.logging "1.0.0"]
+                           [clj-time "0.15.2"]
+                           [cheshire "5.10.0"]
                            [slingshot "0.12.2"]])


update versions and break stuff

update versions and break stuff

--- clojure/project.clj
+++ clojure/project.clj
@@ -2,23 +2,25 @@
   :description "FIXME: write this!"
   :url "http://example.com/FIXME"

-  :min-lein-version "2.5.3"
+  :min-lein-version "2.7.1"

-  :dependencies [[org.clojure/clojure "1.7.0"]
-                 [org.clojure/clojurescript "1.7.170"]
+  :dependencies [[org.clojure/clojure "1.8.0"]
+                 [org.clojure/clojurescript "1.9.946"]
                  [com.rpl/specter "1.0.3"]
                  ]

   ;:jvm-opts ["-Dclojure.server.repl={:port 5555 :accept clojure.core.server/repl}"]

-  :plugins [[lein-cljsbuild "1.1.1"]
-            [lein-figwheel "0.5.0-2"]]
+  :plugins [[lein-cljsbuild "1.1.7"]
+            [lein-figwheel "0.5.13"]]

   :source-paths ["src"]

-  :profiles {:dev {:dependencies [[com.cemerick/piggieback "0.2.2"]
-                                  [figwheel-sidecar "0.5.8"]]}}
-  :repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}
+  :profiles {:dev {:dependencies [[figwheel-sidecar "0.5.13"]
+                                  [com.cemerick/piggieback "0.2.2"]]
+                   :source-paths ["src" "dev"]
+                   :repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}
+                   }}

   :clean-targets ["server.js"


Update company REST API order to keep resources together.

--- src/open_company/api/companies.clj
+++ src/open_company/api/companies.clj
@@ -62,49 +62,7 @@
     ;; update the company
     {:updated-company (company/put-company slug (merge original-company patch-updates) user)}))

-;; ----- Resources - see: http://clojure-liberator.github.io/liberator/assets/img/decision-graph.svg
-
-;; A resource for a specific company.
-(defresource company
-  [slug]
-  common/open-company-anonymous-resource ; verify validity of JWToken if it's provided, but it's not required
-
-  :available-media-types [company-rep/media-type]
-  :exists? (fn [_] (get-company slug))
-  :known-content-type? (fn [ctx] (common/known-content-type? ctx company-rep/media-type))
-
-  :allowed? (by-method {
-    :options (fn [ctx] (common/allow-anonymous ctx))
-    :get (fn [ctx] (common/allow-anonymous ctx))
-    :put (fn [ctx] (common/allow-org-members slug ctx))
-    :patch (fn [ctx] (common/allow-org-members slug ctx))
-    :delete (fn [ctx] (common/allow-org-members slug ctx))})
-
-  :processable? (by-method {
-    :options true
-    :get true
-    :put (fn [ctx] (common/check-input (company/valid-company slug (add-slug slug (:data ctx)))))
-    :patch (fn [ctx] true)}) ;; TODO validate for subset of company properties
-
-  ;; Handlers
-  :handle-ok (by-method {
-    :get (fn [ctx] (company-rep/render-company (:company ctx) (common/authorized-to-company? ctx)))
-    :put (fn [ctx] (company-rep/render-company (:updated-company ctx)))
-    :patch (fn [ctx] (company-rep/render-company (:updated-company ctx)))})
-  :handle-not-acceptable (fn [_] (common/only-accept 406 company-rep/media-type))
-  :handle-unsupported-media-type (fn [_] (common/only-accept 415 company-rep/media-type))
-  :handle-unprocessable-entity (fn [ctx] (unprocessable-reason (:reason ctx)))
-  :handle-options (fn [ctx] (options-for-company slug ctx))
-
-  ;; Delete a company
-  :delete! (fn [_] (company/delete-company slug))
-
-  ;; Create or update a company
-  ;; TODO remove possibility to create company
-  :new? (by-method {:put (not (company/get-company slug))})
-  :put! (fn [ctx] (put-company slug (add-slug slug (:data ctx)) (:user ctx)))
-  :patch! (fn [ctx] (patch-company slug (add-slug slug (:data ctx)) (:user ctx)))
-  :handle-created (fn [ctx] (company-location-response (:updated-company ctx))))
+;; ----- Validations -----

 (defn malformed-post-req?
   "If the request contains valid JSON POST data to create
@@ -135,6 +93,50 @@
     (s/check common-res/Slug slug) [false {:reason :invalid-slug-format}]
     (not (company/slug-available? slug)) [false {:reason :slug-taken}]))

+;; ----- Resources - see: http://clojure-liberator.github.io/liberator/assets/img/decision-graph.svg
+
+;; A resource for a specific company.
+(defresource company
+  [slug]
+  common/open-company-anonymous-resource ; verify validity of JWToken if it's provided, but it's not required
+
+  :available-media-types [company-rep/media-type]
+  :exists? (fn [_] (get-company slug))
+  :known-content-type? (fn [ctx] (common/known-content-type? ctx company-rep/media-type))
+
+  :allowed? (by-method {
+    :options (fn [ctx] (common/allow-anonymous ctx))
+    :get (fn [ctx] (common/allow-anonymous ctx))
+    :put (fn [ctx] (common/allow-org-members slug ctx))
+    :patch (fn [ctx] (common/allow-org-members slug ctx))
+    :delete (fn [ctx] (common/allow-org-members slug ctx))})
+
+  :processable? (by-method {
+    :options true
+    :get true
+    :put (fn [ctx] (common/check-input (company/valid-company slug (add-slug slug (:data ctx)))))
+    :patch (fn [ctx] true)}) ;; TODO validate for subset of company properties
+
+  ;; Handlers
+  :handle-ok (by-method {
+    :get (fn [ctx] (company-rep/render-company (:company ctx) (common/authorized-to-company? ctx)))
+    :put (fn [ctx] (company-rep/render-company (:updated-company ctx)))
+    :patch (fn [ctx] (company-rep/render-company (:updated-company ctx)))})
+  :handle-not-acceptable (fn [_] (common/only-accept 406 company-rep/media-type))
+  :handle-unsupported-media-type (fn [_] (common/only-accept 415 company-rep/media-type))
+  :handle-unprocessable-entity (fn [ctx] (unprocessable-reason (:reason ctx)))
+  :handle-options (fn [ctx] (options-for-company slug ctx))
+
+  ;; Delete a company
+  :delete! (fn [_] (company/delete-company slug))
+
+  ;; Create or update a company
+  ;; TODO remove possibility to create company
+  :new? (by-method {:put (not (company/get-company slug))})
+  :put! (fn [ctx] (put-company slug (add-slug slug (:data ctx)) (:user ctx)))
+  :patch! (fn [ctx] (patch-company slug (add-slug slug (:data ctx)) (:user ctx)))
+  :handle-created (fn [ctx] (company-location-response (:updated-company ctx))))
+
 ;; A resource for a list of all the companies the user has access to.
 (defresource company-list
   []


Tweaks

Tweaks

--- src/overtone_workspace/core.clj
+++ src/overtone_workspace/core.clj
@@ -3,7 +3,7 @@
             [quil.middleware :as m])
   (:use [quil-layer layer layers]
         [quil-layer.layers fadeout-layer layer-example2]
-        ; [overtone-workspace.layers layer-example vol-circles-layer]
+        ;[overtone-workspace.layers vol-circles-layer]
         [overtone-workspace.layers layer-example background-layer lines-layer]
         )
   )


Keep current cljs snippet between refreshes.

--- test/cljs/quil/snippet.cljs
+++ test/cljs/quil/snippet.cljs
@@ -93,8 +93,10 @@

 (defn run-selected-test [event]
   (let [select (.-target event)
-        option (aget select (.-selectedIndex select))]
+        index (.-selectedIndex select)
+        option (aget select index)]
     (remove-canvases)
+    (aset js/location "hash" index)
     ((:fn (.-testData option)))))

 (defn init-test-selection [input]
@@ -108,7 +110,10 @@
           (.appendChild optgroup option)))
       (.appendChild input optgroup)))
   (events/listen input EventType/CHANGE
-                 run-selected-test))
+                 run-selected-test)
+  (when-let [hash (aget js/location "hash")]
+    (aset input "selectedIndex" (js/parseInt (subs hash 1)))
+    (.dispatchEvent input (js/Event. EventType/CHANGE))))

 (defn init []
   (when-let [input (.querySelector js/document "#test-select")]


fortune

fortune

--- src/rpi_wall/fortune/server.clj
+++ src/rpi_wall/fortune/server.clj
@@ -3,9 +3,7 @@

 (defn get-quote
   []
-  (let [x (:out (sh "fortune" "-s"))]
-    (println x)
-    x))
+  (:out (sh "fortune" "-s")))

 (defonce quote-state
   (atom []))


Remove unused requires

Remove unused requires

--- src/vip/data_processor/validation/v5/ballot_measure_contest.clj
+++ src/vip/data_processor/validation/v5/ballot_measure_contest.clj
@@ -1,7 +1,5 @@
 (ns vip.data-processor.validation.v5.ballot-measure-contest
-  (:require [vip.data-processor.validation.v5.util :as util]
-            [korma.core :as korma]
-            [vip.data-processor.db.postgres :as postgres]))
+  (:require [vip.data-processor.validation.v5.util :as util]))

 (def validate-ballot-measure-types
   (util/validate-enum-elements :ballot-measure-type :errors))


expected * found void on void return

expected * found void on void return

--- src/latte_compiler/static_analysis.clj
+++ src/latte_compiler/static_analysis.clj
@@ -438,7 +438,7 @@
                )
       :vret (m/domonad util/phase-m
               [[type _] (lookup-var vars "_return_" location)
-               res (check-types [:void] type [vars [:vret]] location)]
+               res (check-types type [:void] [vars [:vret]] location)]
               res)
       :ret (m/domonad util/phase-m
              [[nvars expr] (annotate-expr glob-state vars (second code))


Update documentation for return and bind

--- src/simple_check/generators.clj
+++ src/simple_check/generators.clj
@@ -176,7 +176,8 @@

 (defn return
   "Create a generator that always returns `value`,
-  and never shrinks."
+  and never shrinks. You can think of this as
+  the `constantly` of generators."
   [value]
   (gen-pure (rose-pure value)))

@@ -202,9 +203,6 @@
                 ;; chooses a random element from it
                 gen/elements)

-  Aside: technically this is not bind for a particular monad, since
-  we're dealing with two nested monads (Gen and RoseTree). The name
-  is kept for backward compatibility.
   "
   [generator k]
   (gen-bind generator (bind-helper k)))


Use more clojure idomatic _last_ function.

--- clojure/bob/bob.clj
+++ clojure/bob/bob.clj
@@ -4,7 +4,7 @@
 	(cond
 		(str/blank? x) "Fine, be that way."
 		(= (str/upper-case x) x) "Woah, chill out!"
-		(= \? (get x (- (count x) 1))) "Sure."
+		(= \? (last x)) "Sure."
 		:else "Whatever."
 	)
 )


add :entityType to mock Configuration list to match AGORAs schema

--- src/cljs/org/broadinstitute/firecloud_ui/endpoints.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/endpoints.cljs
@@ -260,6 +260,7 @@
          "entityType" "Workflow"
          "snapshotId" (rand-int 10)
          "namespace" "broad-dsde-dev"}
+        :entityType "Configuration"
         :name (str "Configuration " (inc i))
         :url (str "http://agora-ci.broadinstitute.org/configurations/joel_test/jt_test_config/1")
         :namespace (rand-nth ["Broad" "nci" "public" "ISB"])