revert px vals conversion

revert px vals conversion

--- src/cljss/core.clj
+++ src/cljss/core.clj
@@ -21,13 +21,7 @@

 (defn- collect-styles [cls idx styles]
   (let [dynamic (filterv dynamic? styles)
-        static (->> styles
-                    (filterv (comp not dynamic?))
-                    (mapv (fn [[rule value]]
-                            [rule
-                             (if (number? value)
-                               (str value "px")
-                               value)])))
+        static  (filterv (comp not dynamic?) styles)
         [vars idx]
         (reduce
           (fn [[vars idx] ds]
@@ -35,29 +29,27 @@
              (inc idx)])
           [[] idx]
           dynamic)
-        vals (mapv (fn [[_ var] [_ exp]] [var `(let [e# ~exp] (if (number? e#) (cljs.core/str e# "px") e#))])
-                   vars
-                   dynamic)
-        static (->> vars
-                    (map (fn [[rule var]] [rule (str "var(" var ")")]))
-                    (concat static)
-                    (build-css cls))]
+        vals    (mapv (fn [[_ var] [_ exp]] [var exp]) vars dynamic)
+        static  (->> vars
+                     (map (fn [[rule var]] [rule (str "var(" var ")")]))
+                     (concat static)
+                     (build-css cls))]
     [static vals idx]))

 (defn build-styles [cls styles]
-  (let [pseudo (filterv pseudo? styles)
-        styles (filterv (comp not pseudo?) styles)
+  (let [pseudo  (filterv pseudo? styles)
+        styles  (filterv (comp not pseudo?) styles)
         [static vals idx] (collect-styles cls 0 styles)
         pstyles (->> pseudo
                      (map (fn [[rule styles]]
                             (collect-styles (str cls (subs (name rule) 1)) idx styles))))
-        static (->> pstyles
-                    (map first)
-                    (apply str)
-                    (str static))
-        vals (->> pstyles
-                  (mapcat second)
-                  (into vals))]
+        static  (->> pstyles
+                     (map first)
+                     (apply str)
+                     (str static))
+        vals    (->> pstyles
+                     (mapcat second)
+                     (into vals))]
     [static vals]))

 (defn- ->status-styles [styles]
@@ -71,7 +63,7 @@
          (group-by first)
          (map (fn [[rule states]]
                 (let [svals (map last states)
-                      args (mapv (fn [_] (gensym "var")) svals)]
+                      args  (mapv (fn [_] (gensym "var")) svals)]
                   [rule
                    `(with-meta
                       (fn ~args
@@ -108,57 +100,53 @@
    Returns a var bound to the result of calling `cljss.core/styled`,
    which produces React element and injects styles."
   [tag styles cls]
-  (let [tag (name tag)
+  (let [tag    (name tag)
         styles (->status-styles styles)
         [static values] (build-styles cls styles)
         values (vals->array values)
-        attrs (->> styles vals (filterv keyword?))]
+        attrs  (->> styles vals (filterv keyword?))]
     [tag static values `(cljs.core/array ~@attrs)]))

 (defmacro make-styled []
   '(defn styled [cls static vars attrs create-element]
-     (let [clsn (str cls "-" (gensym))
+     (let [clsn   (str cls "-" (gensym))
            static (if ^boolean goog.DEBUG
                     (clojure.string/replace static cls clsn)
                     static)
-           vars (if ^boolean goog.DEBUG
-                  (->> vars (map (fn [[k v]] [(clojure.string/replace k cls clsn) v])))
-                  vars)
-           cls (if ^boolean goog.DEBUG clsn cls)]
+           vars   (if ^boolean goog.DEBUG
+                    (->> vars (map (fn [[k v]] [(clojure.string/replace k cls clsn) v])))
+                    vars)
+           cls    (if ^boolean goog.DEBUG clsn cls)]
        (fn [props & children]
          (let [[props children] (if (map? props)
                                   (array props children)
                                   (array {} (apply array props children)))
-               var-class (->> vars
-                              (map (fn [[cls v]]
-                                     (cond
-                                       (and (ifn? v) (satisfies? IWithMeta v))
-                                       (->> v meta list flatten (select-keys props) vals (apply v) (list cls))
-
-                                       (ifn? v)
-                                       (list cls (v props))
-
-                                       :else (list cls v))))
-                              (map (fn [[k v]]
-                                     [k (if (number? v)
-                                          (str v "px")
-                                          v)]))
-                              (cljss.core/css cls static))
+               var-class  (->> vars
+                               (map (fn [[cls v]]
+                                      (cond
+                                        (and (ifn? v) (satisfies? IWithMeta v))
+                                        (->> v meta list flatten (select-keys props) vals (apply v) (list cls))
+
+                                        (ifn? v)
+                                        (list cls (v props))
+
+                                        :else (list cls v))))
+                               (cljss.core/css cls static))
                meta-attrs (->> vars
                                (map second)
                                (filter #(satisfies? IWithMeta %))
                                (map meta)
                                flatten
                                set)
-               className (:className props)
-               className (str (when className (str className " ")) var-class)
-               props (assoc props :className className)
-               props (apply dissoc props (concat attrs meta-attrs))]
+               className  (:className props)
+               className  (str (when className (str className " ")) var-class)
+               props      (assoc props :className className)
+               props      (apply dissoc props (concat attrs meta-attrs))]
            (create-element props children))))))

 (defn- keyframes-styles [idx styles]
   (let [dynamic (filterv dynamic? styles)
-        static (filterv (comp not dynamic?) styles)
+        static  (filterv (comp not dynamic?) styles)
         [vars idx]
         (reduce
           (fn [[vars idx] [rule]]
@@ -166,13 +154,13 @@
              (inc idx)])
           [[] idx]
           dynamic)
-        vals (mapv (fn [[_ var] [_ exp]] [(str "var(" var ")") exp]) vars dynamic)
-        static (->> vars
-                    (map (fn [[rule var]] [rule (str "var(" var ")")]))
-                    (concat static)
-                    (map (fn [[rule val]] (str (name rule) ":" (escape-val rule val) ";")))
-                    (cstr/join "")
-                    (#(str "{" % "}")))]
+        vals    (mapv (fn [[_ var] [_ exp]] [(str "var(" var ")") exp]) vars dynamic)
+        static  (->> vars
+                     (map (fn [[rule var]] [rule (str "var(" var ")")]))
+                     (concat static)
+                     (map (fn [[rule val]] (str (name rule) ":" (escape-val rule val) ";")))
+                     (cstr/join "")
+                     (#(str "{" % "}")))]
     [static vals idx]))

 (defn- ->ks-key [k]


Delete fx button.

Delete fx button.

--- sonic-jam/src/sonic_jam/core.cljs
+++ sonic-jam/src/sonic_jam/core.cljs
@@ -284,18 +284,22 @@
                                  (dom/td #js {:onClick (fn [] (transition :init))} %)
                                  (dom/td nil nil)
                                  (dom/td nil nil))
+            remove #(do
+                      (om/transact! cursor (fn [c] (vec (into (subvec c 0 %)
+                                                              (subvec c (+ 1 %))))))
+                      (go (>! set-state-ch id)))
             body-rows (map #(dom/tr nil
-                                    (dom/td nil nil)
-                                    (dom/td nil (get % "fx"))
+                                    (dom/td #js {:onClick (fn [] (remove %2))} "X")
+                                    (dom/td nil (get %1 "fx"))
                                     (dom/td nil (om/build param-editor
-                                                          {:cursor %
-                                                           :id id
+                                                          {:cursor %1
+                                                          :id id
                                                            :set-state-ch set-state-ch})))
-                           cursor)
+                           cursor
+                           (range))
             commit #(let [new-fx {:fx (:fx state)
                                   :params {}}]
                       (transition :open)
-                      (print cursor)
                       (om/transact! cursor (fn [c] (clj->js (into c [new-fx]))))
                       (go (>! set-state-ch id)))]
         (condp = (:state state)


Add arb->tx fn

Add arb->tx fn

--- src/datemo/arb.clj
+++ src/datemo/arb.clj
@@ -68,3 +68,6 @@
           (if (string? (first items))
             (recur (conj hiccups (first items)) (next items))
             (recur (conj hiccups (arb->hiccup (first items))) (next items))))))))
+
+(defn tx->html [tx]
+  (-> tx (tx->arb) (arb->hiccup)))


memoized call to ohai

memoized call to ohai

--- src/fatty/ohai.clj
+++ src/fatty/ohai.clj
@@ -7,13 +7,18 @@
   (:require [clojure.contrib.string :as str])
   (:gen-class))

-(defn get-os-and-machine
+(defn ohai
   "Use Ohai to get our Operating System and Machine Architecture"
   []
+  (println "calling os-and-machine")
   (let [ohai-data (read-json ((sh "ohai") :out))]
     {:os (get ohai-data :os), :machine (get-in ohai-data [:kernel :machine])}))

-(def os-and-machine (ref (get-os-and-machine)))
+(def ohai (memoize ohai))
+
+(defn os-and-machine
+  [& ohai-keys]
+  (get-in (ohai) ohai-keys))

 (defn is-os?
   "Returns true if the current OS matches the argument"


Replace SC sample with something from freesound. Also modify the example now that samples can be used as buffers.

--- examples/fx.clj
+++ examples/fx.clj
@@ -79,18 +79,16 @@
 (defsynth ext-source [out-bus 10]
   (out out-bus (in (num-output-buses:ir))))

-; This sound comes with supercollider, otherwise replace with another wav or aiff file
-(def nasa (load-sample "a11wlk01-44_1.aiff"))
+;; Fetch a spoken countdown from freesound.org
+(def count-down (sample (freesound-path 71128)))

-(defsynth simple-sound
-  []
-  (let [input (pan2 (play-buf 1 nasa) -0.5)]
-    (out 0 input)))
+;; Play it unmodified:
+;;(count-down)

-; From Designing Sound in SuperCollider
+;; From Designing Sound in SuperCollider
 (defsynth schroeder-reverb
   []
-  (let [input (pan2 (play-buf 1 nasa) -0.5)
+  (let [input (pan2 (play-buf 1 count-down) -0.5)
         delrd (local-in 4)
         output (+ input [(first delrd) (second delrd)])
         sig [(+ (first output) (second output)) (- (first output) (second output))
@@ -103,4 +101,5 @@
         ]
     (out 0 output)))

-
+;;Spooky!
+;;(schroeder-reverb)


adds test to demonstrate problem

adds test to demonstrate problem

--- test/datascript/test/pull_api.cljc
+++ test/datascript/test/pull_api.cljc
@@ -336,6 +336,7 @@
                       [[:name "Elizabeth"]
                        [:name "Petr"]
                        [:name "Eunan"]
-                       [:name "Rebecca"]]))))
+                       [:name "Rebecca"]])))
+  (is (nil? (d/pull test-db '[*] [:name "No such name"]))))

 #_(t/test-ns 'datascript.test.pull-api)


fix test cases

fix test cases

--- test/graphql_clj/resolver_test.clj
+++ test/graphql_clj/resolver_test.clj
@@ -1,6 +1,11 @@
 (ns graphql-clj.resolver-test
   (:use graphql-clj.resolver)
-  (:require [clojure.test :refer :all]))
+  (:require [clojure.test :refer :all]
+            [graphql-clj.parser :as parser]
+            [graphql-clj.type :as type]
+            [graphql-clj.introspection :as introspection]))
+
+(def test-schema (type/create-schema nil (parser/parse introspection/introspection-schema)))

 (deftest test-default-resolver
   (testing "default resolver with value"
@@ -12,15 +17,15 @@
       (is (= test-field-value result)))))

 (deftest test-schema-introspection-resolver
-  (let [schema-resolver (schema-introspection-resolver-fn nil)]
+  (let [schema-resolver (schema-introspection-resolver-fn test-schema)]
     (testing "testing __schema"
-      (is (not (nil? (schema-resolver "QueryRoot" "__schema")))))))
+      (is (not (nil? (schema-resolver "Query" "__schema")))))))

 (deftest test-create-resolver-fn
   (testing "test create resolver fn"
-    (let [resolver-fn (create-resolver-fn nil nil)]
+    (let [resolver-fn (create-resolver-fn test-schema nil)]
       (testing "testing __schema"
-        (is (not (nil? (resolver-fn "QueryRoot" "__schema")))))
+        (is (not (nil? (resolver-fn "Query" "__schema")))))
       (testing "testing default field resolver"
         (let [resolver (resolver-fn "User" "fullname")]
           (is (= "Test User Fullname"


fix location of babel.italiano.grammar/lexicon

--- src/babel/italiano/benchmark.cljc
+++ src/babel/italiano/benchmark.cljc
@@ -1,8 +1,7 @@
 (ns babel.italiano.benchmark
   (:refer-clojure :exclude [get-in])
   (:require [babel.italiano :refer [analyze generate parse]]
-            [babel.italiano.grammar :refer [small medium np-grammar]]
-            [babel.italiano.lexicon :refer [lexicon]]
+            [babel.italiano.grammar :refer [small lexicon medium np-grammar]]
             [babel.italiano.morphology :as morph :refer [analyze-regular fo replace-patterns]]
             [babel.italiano.morphology.nouns :as nouns]
             [babel.italiano.morphology.verbs :as verbs]


Enable typemode selection through main program arguments

--- src/bogo_clojure/bg_websocket.clj
+++ src/bogo_clojure/bg_websocket.clj
@@ -1,17 +1,20 @@
 (ns bogo-clojure.bg-websocket
   (:gen-class)
   (:require [bogo-clojure.core :as bogo]
+            [bogo-clojure.bg-typemode :refer :all]
             [clojure.string :as string])
   (:use org.httpkit.server))

+(def typemode (atom TELEX))

 (defn process!
   [channel data]
   (let [[old-string key] (string/split-lines data)
-        new-string (bogo/process-key old-string key)]
+        new-string (bogo/process-key old-string key TELEX)]
     (println old-string key new-string)
     (send! channel new-string)
     ))
+
 (defn handler [req]
   (with-channel req channel
     (on-close channel (fn [status]
@@ -24,4 +27,7 @@

 (defn -main
   [& args]
+  (if (not (empty? args))
+    (reset! typemode (eval (symbol "bogo-clojure.bg-typemode" (string/uppercase (string/join args)))))
+    true)
   (run-server handler {:port 8080}))


listlpv output set to 'text'

listlpv output set to 'text'

--- src/clj/webapp/routes/listlpv.clj
+++ src/clj/webapp/routes/listlpv.clj
@@ -97,7 +97,7 @@
           (log/info "sparql result status: " (:status req))
           [:div
           [:pre (:body req)]
-           [:p header]
+           ;;[:p header]
            [:hr]
            ;;[:pre reqvec]
           [:hr]


Property access fix

Property access fix

--- src/cljs/clojure/browser/dom.cljs
+++ src/cljs/clojure/browser/dom.cljs
@@ -135,7 +135,7 @@
   "Set properties on an element"
   [e m]
   (gdom/setProperties (ensure-element e)
-                      (.strobj m)))
+                      (.-strobj m)))

 (defn set-value
   "Set the value property for an element."


fix issue with discard pile card display

--- src/cljs/netrunner/gameboard.cljs
+++ src/cljs/netrunner/gameboard.cljs
@@ -122,7 +122,7 @@
     [:div.panel.blue-shade.discard
      (om/build label discard {:opts {:name "Heap"}})
      (when-not (empty? discard)
-       (om/build card-view (first discard)))])))
+       (om/build card-view (last discard)))])))

 (defmethod discard-view "Corp" [{:keys [discard] :as cursor}]
   (om/component
@@ -130,7 +130,7 @@
     [:div.panel.blue-shade.discard
      (om/build label discard {:opts {:name "Archive"}})
      (when-not (empty? discard)
-       (om/build card-view (first discard)))])))
+       (om/build card-view (last discard)))])))

 (defn rfg-view [{:keys [rfg] :as cursor}]
   (om/component


removed useless include

removed useless include

--- src/cljs/triboard/logic/move.cljs
+++ src/cljs/triboard/logic/move.cljs
@@ -1,7 +1,6 @@
 (ns triboard.logic.move
   (:require
     [cljs.spec :as s :include-macros true]
-    [cljs.spec.impl.gen :as gen]
     [triboard.logic.board :as board]
     [triboard.logic.constants :as cst]
     ))


Make the as-set lens abide the second lens law.

--- src/cljx/active/clojure/lens.cljx
+++ src/cljx/active/clojure/lens.cljx
@@ -128,7 +128,11 @@

 (def ^{:doc "A lens that views a sequence as a set."}
   as-set
-  (xmap set seq))
+  (lens set
+        ; this is needed to abide the second lens law
+        #(if (= (set %1) %2)
+           %1
+           (seq %2))))

 (defn contains
   "Returns a lens showing the membership of the given value in a set."


Add another bang

Add another bang

--- src/clojure/nightcode/editors.clj
+++ src/clojure/nightcode/editors.clj
@@ -479,14 +479,14 @@
                   (lein/stop-process! process)
                   (s/config! toggle-btn :text (utils/get-string :start))
                   false)
-          toggle (fn [_]
-                   (reset! is-running? (if @is-running? (stop!) (start!)))
-                   (update-tabs! path))]
+          toggle! (fn [_]
+                    (reset! is-running? (if @is-running? (stop!) (start!)))
+                    (update-tabs! path))]
       ; add the toggle action to the button
-      (s/listen toggle-btn :action toggle)
+      (s/listen toggle-btn :action toggle!)
       ; create shortcuts
       (doto btn-group
-        (shortcuts/create-mappings! {:toggle-logcat-button toggle})
+        (shortcuts/create-mappings! {:toggle-logcat-button toggle!})
         shortcuts/create-hints!)
       ; return a map describing the logcat view
       {:view (s/border-panel :north btn-group :center console)


Ensure remote task function-vars are vars.

--- src/clojure/parkour/mapreduce.clj
+++ src/clojure/parkour/mapreduce.clj
@@ -9,6 +9,7 @@
             [parkour.mapreduce (source :as src) (sink :as snk)]
             [parkour.util :refer [returning ignore-errors]])
   (:import [java.io Writer]
+           [clojure.lang Var]
            [org.apache.hadoop.mapreduce Job]
            [org.apache.hadoop.mapreduce TaskAttemptContext TaskAttemptID]))

@@ -107,6 +108,7 @@
 Parkour will invoke the `var`-returned function with only the task context, and
 will ignore any return value."
   [conf var & args]
+  (assert (instance? Var var))
   (let [i (conf/get-int conf "parkour.mapper.next" 0)]
     (conf/assoc! conf
       "parkour.mapper.next" (inc i)
@@ -116,6 +118,7 @@

 (defn ^:private reducer!*
   [step conf var & args]
+  (assert (instance? Var var))
   (let [i (conf/get-int conf "parkour.reducer.next" 0)]
     (conf/assoc! conf
       "parkour.reducer.next" (inc i)
@@ -158,6 +161,7 @@
 Parkour will invoke the `var`-returned partitioner function with the raw (not
 unwrapped) tuple key and value objects."
   [conf var & args]
+  (assert (instance? Var var))
   (conf/assoc! conf
     "parkour.partitioner.var" (pr-str var)
     "parkour.partitioner.args" (pr-str args))


Added 1 code block to code_quote

Added 1 code block to code_quote

--- src/clojush/instructions/code.clj
+++ src/clojush/instructions/code.clj
@@ -258,7 +258,7 @@
 (define-registered code_fromboolean (with-meta (codemaker :boolean) {:stack-types [:code :boolean]}))
 (define-registered code_fromfloat (with-meta (codemaker :float) {:stack-types [:code :float]}))
 (define-registered code_frominteger (with-meta (codemaker :integer) {:stack-types [:code :integer]}))
-(define-registered code_quote (with-meta (codemaker :exec) {:stack-types [:code :exec]}))
+(define-registered code_quote (with-meta (codemaker :exec) {:stack-types [:code :exec] :parentheses 1}))

 (define-registered
   code_if


Require event-loop creator to supply 0mq context

That part needs to come from a completely differet Component

--- src/com/frereth/common/system.clj
+++ src/com/frereth/common/system.clj
@@ -40,14 +40,10 @@
 I'm not sure which alternatives make more sense."
   [{:keys [client-keys
            context
-           ctx-thread-count  ; obsolete
-           direction         ; obsolete
            event-loop-name
            server-key
-           socket-type       ; obsolete
            url]
-    :or {ctx-thread-count 1
-         socket-type :dealer
+    :or {socket-type :dealer
          direction :connect}}]
   (let [url (cond-> url
               (not (:protocol url)) (assoc :protocol :tcp)
@@ -56,21 +52,15 @@
     (let [defaults {:event-loop {:_name event-loop-name}
                     :ex-sock {:url url
                               :direction direction
-                              :sock-type socket-type}
-                    :zmq-context {:thread-count ctx-thread-count}}
+                              :sock-type socket-type
+                              :ctx context}}
           description {:structure '{:event-loop com.frereth.common.async-zmq/ctor
                                     :evt-iface com.frereth.common.async-zmq/ctor-interface
                                     :ex-chan com.frereth.common.async-component/chan-ctor
                                     :ex-sock com.frereth.common.zmq-socket/ctor
                                     :in-chan com.frereth.common.async-component/chan-ctor
-                                    :status-chan com.frereth.common.async-component/chan-ctor
-                                    :zmq-context com.frereth.common.zmq-socket/ctx-ctor}
+                                    :status-chan com.frereth.common.async-component/chan-ctor}
                        :dependencies {:evt-iface [:ex-sock :in-chan :status-chan]
                                       :event-loop {:interface :evt-iface
-                                                   :ex-chan :ex-chan}
-                                      :ex-sock {:ctx :zmq-context}}}
-          default-result (cpt-dsl/build description defaults)]
-      (if context
-        ;; Generally, callers will override
-        (assoc default-result :zmq-context context)
-        default-result))))
+                                                   :ex-chan :ex-chan}}}
+          default-result (cpt-dsl/build description defaults)])))


remove incorrect task

remove incorrect task

--- examples/blog/build.boot
+++ examples/blog/build.boot
@@ -31,7 +31,7 @@
         (sitemap)
         (rss :description "Hashobject blog")
         (atom-feed :filterer :original)
-        (debug)
+        (print-meta)
         (notify)))

 (deftask dev


Static resource service default uri-context

Setting this default to non-empty ensures that an empty string cannot be
matched, since bidi.ring/ResourcesMaybe avoids matching on an
empty-string.

Specifically this solves the problem of 'stealing' redirects.

--- modules/bidi/src/modular/bidi.clj
+++ modules/bidi/src/modular/bidi.clj
@@ -50,7 +50,7 @@
   (request-handlers [_] {})
   (routes [_]
     [uri-context (resources-maybe {:prefix resource-prefix})])
-  (uri-context [_] ""))
+  (uri-context [_] "/"))

 (def new-static-resource-service-schema
   {:uri-context s/Str


Tighter constraints on var flows

Tighter constraints on var flows

--- src/player/ha.cljs
+++ src/player/ha.cljs
@@ -540,7 +540,7 @@
     (doseq [[v f] flows]
       (if (deriv-var? v)
         (assert (or (= f 0) (and (vector? f) (= 2 (count f)) (every? number? f))))
-        (assert (or (number? f) (deriv-var? f)))))
+        (assert (or (number? f) (= f (keyword "v" (name v)))))))
     {:id id :enter-update on-enter :flows flows :edges edges}))

 (defn propset-get [ps key]


Refactor: re-name format-specific fns.

Refactor: re-name format-specific fns.

--- src/dsbdp/data_processing_dsl.clj
+++ src/dsbdp/data_processing_dsl.clj
@@ -140,7 +140,7 @@
     ~(create-bindings-vector input rules out-format-fn output nesting-level)
     ~(reverse (into '() (out-format-fn rules output nesting-level)))))

-(defn- create-let-body-vec-java-map-out
+(defn- java-out-format-fn
   [rules output nesting-level]
   (reduce
     (fn [v rule]
@@ -158,7 +158,7 @@
       '[doto ^java.util.Map output])
     rules))

-(defn- create-let-body-vec-clj-map-out
+(defn- clj-out-format-fn
   [rules output nesting-level]
   (reduce
     (fn [v rule]
@@ -178,7 +178,7 @@
       '[-> output])
     rules))

-(defn- create-let-body-vec-csv-str-out
+(defn- csv-str-out-format-fn
   [rules output nesting-level]
   (reduce
     (fn [v rule]
@@ -193,7 +193,7 @@
       '[doto ^java.lang.StringBuilder output])
     rules))

-(defn- create-let-body-vec-json-str-out
+(defn- json-str-out-format-fn
   [rules output nesting-level]
   (reduce
     (fn [v rule]
@@ -241,14 +241,14 @@
         output-sym (if (.endsWith output-type *incremental-indicator-suffix*)
                      'output)
         output-format-fn (condp (fn [^String v ^String s] (.startsWith s v)) output-type
-                           "java-map" create-let-body-vec-java-map-out
-                           "clj-map" create-let-body-vec-clj-map-out
-                           "csv-str" create-let-body-vec-csv-str-out
-                           "json-str" create-let-body-vec-json-str-out
+                           "java-map" java-out-format-fn
+                           "clj-map" clj-out-format-fn
+                           "csv-str" csv-str-out-format-fn
+                           "json-str" json-str-out-format-fn
                            (do
                              (println "Unknown output type:" output-type)
                              (println "Defaulting to :java-map as output type.")
-                             create-let-body-vec-java-map-out))
+                             java-out-format-fn))
 ;        _ (println "Created data processing function vector from DSL:" fn-body-vec)
         fn-body (create-let-expression input-sym rules output-format-fn output-sym 0)
 ;        _ (println "Created data processing function body:" fn-body)


pretty up migrations

pretty up migrations

--- src/foosball/models/migration.clj
+++ src/foosball/models/migration.clj
@@ -4,7 +4,9 @@
   (:use [taoensso.timbre :only [trace debug info warn error fatal spy]])
   (:require [foosball.util :as util]))

-(defn- ensure-players-users-have-roles [conn]
+(defn- ensure-players-users-have-roles
+  "Ensure every player has the default role"
+  [conn]
   (let [dbc                (db conn)
         players-with-names (->> (d/q '[:find ?pid :where [?pid :player/name _]] dbc)
                                 (map (fn [[id]] id))
@@ -14,7 +16,7 @@
                                 set)
         players-to-default (difference players-with-names players-with-roles)
         transaction        (map (fn [id] {:db/id id :user/role :user}) players-to-default)]
-    (info {:ensure-players-users-have-roles transaction})
+    (info "Players changed:" (count players-to-default))
     @(d/transact conn transaction)))

 (defn- get-leagues [dbc]
@@ -29,16 +31,19 @@
       (filter (fn [{:keys [name]}] (= name default-league-name)))
       first))

-(defn- ensure-atleast-one-league-exists [conn]
+(defn- ensure-atleast-one-league-exists
+  "Create a default league if one does not exist"
+  [conn]
   (let [dbc         (db conn)
         leagues     (get-leagues dbc)
         no-leagues? (empty? leagues)]
-    (info {:ensure-atleast-one-league-exists no-leagues?})
     (when no-leagues?
-      (info "creating league:" default-league-name)
+      (info "Creating default league:" default-league-name)
       @(d/transact conn [{:db/id (d/tempid :db.part/user) :league/name default-league-name}]))))

-(defn- ensure-all-players-have-atleast-one-league [conn]
+(defn- ensure-all-players-have-atleast-one-league
+  "Ensure that every player is in a league"
+  [conn]
   (let [dbc                      (db conn)
         default-league           (get-default-league dbc)
         players-with-names       (->> (d/q '[:find ?pid :where [?pid :player/name _]] dbc)
@@ -50,12 +55,12 @@
         players-to-give-a-league (difference players-with-names players-with-leagues)
         transaction              (map (fn [pid] {:db/id pid :player/leagues (:id  default-league)})
                                       players-to-give-a-league)]
-    (info (merge {:ensure-all-players-have-atleast-one-league players-to-give-a-league
-                  :count (count players-to-give-a-league)}
-                 (util/symbols-as-map default-league)))
+    (info "Players changed:" (count players-to-give-a-league))
     @(d/transact conn transaction)))

-(defn- ensure-all-matches-happened-in-a-league [conn]
+(defn- ensure-all-matches-happened-in-a-league
+  "Ensure that all matches have been played in a league"
+  [conn]
   (let [dbc                      (db conn)
         default-league           (get-default-league dbc)
         matches-played           (->> (d/q '[:find ?mid :where [?mid :match/time _]] dbc)
@@ -67,18 +72,16 @@
         matches-to-give-a-league (difference matches-played matches-with-leagues)
         transaction              (map (fn [mid] {:db/id mid :match/league (:id default-league)})
                                       matches-to-give-a-league)]
-    (info (merge {:ensure-all-matches-happened-in-a-league matches-to-give-a-league
-                  :count (count matches-to-give-a-league)}
-                 (util/symbols-as-map default-league)))
+    (info "Matches changed:" (count matches-to-give-a-league))
     @(d/transact conn transaction)))

 (def migrations "seq of idempotent migration functions"
-  [["ensure-players-users-have-roles" ensure-players-users-have-roles]
-   ["ensure-atleast-one-league-exists" ensure-atleast-one-league-exists]
-   ["ensure-all-players-have-atleast-one-league" ensure-all-players-have-atleast-one-league]
-   ["ensure-all-matches-happened-in-a-league" ensure-all-matches-happened-in-a-league]])
+  [#'ensure-players-users-have-roles
+   #'ensure-atleast-one-league-exists
+   #'ensure-all-players-have-atleast-one-league
+   #'ensure-all-matches-happened-in-a-league])

 (defn migrate-schema-and-data [conn]
-  (doseq [[name migration-fn] migrations]
-    (info "running migration:" name)
-    (migration-fn conn)))
+  (doseq [migration-var migrations]
+    (info "Running migration:" (:doc (meta migration-var)))
+    (migration-var conn)))


example of using array

example of using array

--- one/src/one/d.clj
+++ one/src/one/d.clj
@@ -90,7 +90,7 @@
 (defn collatz [n]
   (cond (== n 1) 1
         (even? n) (+ 1 (collatz (quot n 2)))
-        :else (+ 1 (collatz (+ 1 (* 3 n))))))
+        "else" (+ 1 (collatz (+ 1 (* 3 n))))))

 (defn sol14 [lim]
   (->> (range 1 lim)
@@ -101,30 +101,35 @@
 ;; sort-by group-by partition-by max-key merge-with
 ;; take-while drop-while reduce

+(defn ^long sol5 [^long n]
+  (let [refs (to-array (range (inc n)))]
+    (doseq [i (range 2 (inc n))]
+      (let [ith (aget refs i)]
+        (doseq [j (range (* 2 i) (inc n) i)]
+          (aset refs j (quot (aget refs j) ith)))))
+    (reduce * (rest (into [] refs)))))

+(defn ^long sol5a [^long n]
+  (let [refs (to-array (range (inc n)))]
+    (loop [i (int 2) res (int 1)]
+      (if (> i n)
+        res
+        (let [ith (aget refs i)]
+          (loop [j (int (* 2 i))]
+            (when (<= j n)
+              (aset refs j (quot (aget refs j) ith))
+              (recur (+ j i))))
+          (recur (+ i 1) (* ith res)))))))

+(defn solve [f & args]
+  (dotimes [i 10]
+    (let [res (time (apply f args))]
+      (println res))))

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+(defn sol4 [lim]
+  (->> (for [i (range 900 lim)
+             j (range 900 i)
+             :let [p (* i j)]
+             :when (let [pst (seq (str p))]
+                     (= pst (reverse pst)))] p)
+       (apply max)))


Almost have defconstrainedfn working.  Too tired to continue

--- src/fogus/me/trammel.clj
+++ src/fogus/me/trammel.clj
@@ -24,6 +24,21 @@
                                forms))]
     (list* 'fn name body)))

+(defn build-forms-map
+  [forms]
+  (for [[[e] & c] (map #(partition-by keyword? %) data)]
+    {e (apply hash-map c)}))
+
+(comment
+  {:cnstr ({[x] {(:requires)
+                 ((number? x) (pos? x)),
+                 (:body) ((float x)),
+                 (:ensures) ((float? %))}}
+
+           {[x y] {(:requires) ((every? number? [x y]) (every? pos? [x y])),
+                   (:body) ([(float x) (float y)]),
+                   (:ensures) ((every? float? %))}}), :doc "test", :name foo})
+
 (defmacro defconstrainedfn
   [name & body]
   (let [mdata (if (string? (first body))
@@ -32,9 +47,40 @@
         body  (if (:doc mdata)
                 (next body)
                 body)
-        parts
-        ]
-    `(merge {:name '~name} ~mdata {:body '~body})))
+        fmap  (build-forms-map body)]
+    `(list 'defn '~name
+           (:doc ~mdata)
+           (for [bd# '~fmap]
+             (let [arg# (first (keys bd#))
+                   b#   (first (vals bd#))]
+               (list arg#
+                     {:pre  (vec (b# '(requires)))
+                      :post (vec (b# '(ensures)))}
+                     (b# '(body))))))))
+
+(defconstrainedfn foo
+  "test"
+  ([x]
+     :requires
+     (number? x)
+     (pos? x)
+
+     :ensures
+     (float? %)
+
+     :body
+     (float x))
+  ([x y]
+     :requires
+     (every? number? [x y])
+     (every? pos?    [x y])
+
+     :ensures
+     (every? float? %)
+
+     :body
+     [(float x) (float y)]))
+

 (defconstrainedfn sqr
   "Calculates the square of a number."
@@ -48,6 +94,8 @@

      :body
      (* n n)))
+
+*assert*

 (comment
   (def doubler-contract


Eliminate debug printing

Eliminate debug printing

--- ClojureScript/planck/src/planck/core.cljs
+++ ClojureScript/planck/src/planck/core.cljs
@@ -112,7 +112,7 @@
       {:macros-ns macros-ns?
        :verbose   true}
       (fn [res]
-        (println "require result:" res)))))
+        #_(println "require result:" res)))))

 (defn ^:export read-eval-print [line]
   (binding [ana/*cljs-ns* @current-ns


Return string when reading

Return string when reading

--- src/pericles/routes.clj
+++ src/pericles/routes.clj
@@ -8,7 +8,7 @@

 (defroutes api-routes
   (GET "/" [] "Hello world!")
-  (GET "/readPort" [] (gpio/read-value @port))
+  (GET "/readPort" [] (name (gpio/read-value @port)))
   (GET "/writePort" [value] (gpio/write-value! @port value))
   (route/not-found "Not found!"))


remove printlns

remove printlns

--- src/pharrellel_test.clj
+++ src/pharrellel_test.clj
@@ -95,10 +95,8 @@
                 (fn []
                   (each-fixture
                     #(test-var results tvar))))
-              (println "finished running " tvar)
               (recur))
             (do
-              (println "finished on " worker-id)
               (deliver (nth finished worker-id) 1)))))
       (catch Throwable e
         (.printStackTrace e))


Grant the user who registers a congregation access to it

--- src/territory_bro/routes.clj
+++ src/territory_bro/routes.clj
@@ -136,20 +136,25 @@
             (response/content-type "application/octet-stream")
             (response/header "Content-Disposition" (str "attachment; filename=\"" file-name "\"")))))))

+(defn- current-user-id [conn]
+  (::user/id (user/get-by-subject conn (:sub auth/*user*))))
+
 (defn create-congregation [request]
   (auth/with-authenticated-user request
     (require-logged-in!)
     (let [name (get-in request [:params :name])]
-      (assert (not (str/blank? name))
+      (assert (not (str/blank? name)) ; TODO: test this
               {:name name})
       (db/with-db [conn {}]
-        (ok {:id (congregation/create-congregation! conn name)})))))
+        (let [cong-id (congregation/create-congregation! conn name)]
+          (congregation/grant-access! conn cong-id (current-user-id conn)) ; TODO: test this
+          (ok {:id cong-id}))))))

 (defn list-congregations [request]
   (auth/with-authenticated-user request
     (require-logged-in!)
     (db/with-db [conn {}]
-      (ok (->> (congregation/get-unrestricted-congregations conn)
+      (ok (->> (congregation/get-my-congregations conn (current-user-id conn))
                (map (fn [congregation]
                       {:id (::congregation/id congregation)
                        :name (::congregation/name congregation)})))))))


Make sure to use the correct defmutation

--- src/main/cawala/api/mutations.clj
+++ src/main/cawala/api/mutations.clj
@@ -4,7 +4,7 @@
    [com.wsscode.pathom.core :as p]
    [com.wsscode.pathom.connect :as pc]
    [cawala.api.read :as r]
-   [fulcro.server :refer [defmutation]]))
+   #_[fulcro.server :refer [defmutation]]))

 ;; Place your server mutations here
 #_(defmutation delete-person


[#12687] Icons in public chats and corresponding icons (default ones) of users are different

Signed-off-by: andrey <b713972e59b8e606e23253c4a13e948139fea4d1@gmail.com>

--- src/status_im/subs.cljs
+++ src/status_im/subs.cljs
@@ -1177,7 +1177,7 @@
    (let [contact (or (get contacts id)
                      (when (= id (:public-key multiaccount))
                        multiaccount)
-                     (if identicon
+                     (if (not (string/blank? identicon))
                        {:identicon identicon}
                        (contact.db/public-key->new-contact id)))]
      (multiaccounts/displayed-photo contact))))


throw error for item failure with in bulk request

--- src/wb_es/bulk/core.clj
+++ src/wb_es/bulk/core.clj
@@ -57,9 +57,20 @@
   (let [url-prefix (if index
                      (format "%s/%s" es-base-url index)
                      es-base-url)]
-    (http/post (format "%s/_bulk?refresh=%s" url-prefix (or refresh "false"))
-               {:headers {:content-type "application/x-ndjson"}
-                :body formatted-docs})))
+    (let [response (http/post (format "%s/_bulk?refresh=%s" url-prefix (or refresh "false"))
+                              {:headers {:content-type "application/x-ndjson"}
+                               :body formatted-docs})]
+      (->> (json/parse-string (:body response) true)
+           (:items)
+           (mapcat vals)
+           (map (fn [result]
+                     (let [status (:status result)]
+                       (if (>= status 300)
+                         (throw (Exception. "Item failed during indexing"))
+                         nil))))
+           (seq)
+           (doall)
+           ))))

 (defn get-eids-by-type
   "get all datomic entity ids of a given type


Remove `retrieve-icon` handler.

Remove `retrieve-icon` handler.

--- src/uxbox/frontend/icons.clj
+++ src/uxbox/frontend/icons.clj
@@ -81,19 +81,6 @@
     (-> (sv/query params)
         (p/then #(http/ok (rsp %))))))

-;; --- Retrieve Icon
-
-(s/def ::retrieve-icon
-  (s/keys :req-un [::us/id]))
-
-(defn retrieve-icon
-  [{user :identity params :route-params}]
-  (let [params (us/conform ::retrieve-icon params)
-        params (assoc params :user user :type :retrieve-icon)]
-    (->> (sv/query params)
-         (p/map rsp)
-         (p/map http/ok))))
-
 ;; --- Create Icon

 (s/def ::create-icon


attempt to avoid a rathole found in one test

--- test/babel/test/en.cljc
+++ test/babel/test/en.cljc
@@ -139,7 +139,8 @@

 (deftest mod-is-empty-list
   (let [result (generate {:modified false
-                          :synsem {:sem {:pred :name
+                          :synsem {:cat :verb
+                                   :sem {:pred :name
                                          :mod '()}}})]
     (is (= (get-in result [:synsem :sem :mod]
                    :undefined-should-not-return-this)


Scope rocksdb by job-id in addition to task-id. Fixes rocksdb db lock issue

--- src/onyx/state/filter/rocksdb.clj
+++ src/onyx/state/filter/rocksdb.clj
@@ -49,7 +49,7 @@
                 (fatal e)))
             (recur)))))))

-(defmethod state-extensions/initialize-filter :rocksdb [_ {:keys [onyx.core/peer-opts onyx.core/id onyx.core/task-id] :as event}]
+(defmethod state-extensions/initialize-filter :rocksdb [_ {:keys [onyx.core/peer-opts onyx.core/id onyx.core/job-id onyx.core/task-id] :as event}]
   (let [_ (RocksDB/loadLibrary)
         compression-opt (arg-or-default :onyx.rocksdb.filter/compression peer-opts)
         block-size (arg-or-default :onyx.rocksdb.filter/block-size peer-opts)
@@ -58,7 +58,7 @@
         bloom-filter-bits (arg-or-default :onyx.rocksdb.filter/bloom-filter-bits peer-opts)
         base-dir-path-file ^java.io.File (java.io.File. ^String base-dir-path)
         _ (when-not (.exists base-dir-path-file) (.mkdir base-dir-path-file))
-        db-dir (str base-dir-path "/" id "_" task-id)
+        db-dir (str base-dir-path "/" id "_" job-id "_" (name task-id))
         bloom-filter (BloomFilter. bloom-filter-bits false)
         block-config (doto (BlockBasedTableConfig.)
                        (.setBlockSize block-size)


formatting

formatting

--- src/overtone/studio/wavetable.clj
+++ src/overtone/studio/wavetable.clj
@@ -17,9 +17,9 @@
         len (count sig)]
     (loop [sig sig
            res []]
-      (let [a (float (first sig))
-            bs (second sig)
-            b (float (or bs (first signal)))
+      (let [a        (float (first sig))
+            bs       (second sig)
+            b        (float (or bs (first signal)))
             next-res (conj res (- (* 2 a) b) (- b a))]
         (if (nil? bs)
           next-res
@@ -41,18 +41,18 @@

 (defn linear-interpolate-wavetable
   [table idx-a idx-b]
-  (let [waves  (:waveforms table)
-        steps (dec (- idx-b idx-a))
-        data-a (seq (buffer-read (nth waves idx-a)))
-        data-b (seq (buffer-read (nth waves idx-b)))
+  (let [waves     (:waveforms table)
+        steps     (dec (- idx-b idx-a))
+        data-a    (seq (buffer-read (nth waves idx-a)))
+        data-b    (seq (buffer-read (nth waves idx-b)))
         step-data (drop 1 (drop-last
-                            (map
-                              (fn [[a b]]
-                                (linear-interpolate a b (+ 2 steps)))
-                              (partition 2 (interleave data-a data-b)))))
+                           (map
+                            (fn [[a b]]
+                              (linear-interpolate a b (+ 2 steps)))
+                            (partition 2 (interleave data-a data-b)))))
         step-data (map
-                    (fn [step]
-                      (map #(nth % step) step-data))
-                    (range steps))]
+                   (fn [step]
+                     (map #(nth % step) step-data))
+                   (range steps))]
     (dotimes [i steps]
       (buffer-write! (nth waves (+ (inc idx-a) i)) (nth step-data i)))))


this has been moved to samsara-core

this has been moved to samsara-core

--- moebius/src/moebius/samsara.clj
+++ moebius/src/moebius/samsara.clj
@@ -1,38 +0,0 @@
-(ns moebius.samsara
-  (:require [moebius.core :refer :all]))
-
-
-
-(defenrich inject-kibana-timestamp
-  #_"Adds the `ts` attribute suitable for Kibana4"
-  [{:keys [timestamp] :as event}]
-  (inject-as event :ts (java.util.Date. timestamp)))
-
-
-
-(defenrich is-timestamp-reliable
-  #_"It verifies if the client timestamp seems reliable,
-   and if it is it will inject and attribute `timeReliable`
-   true/false."
-  [{:keys [timestamp receivedAt publishedAt] :as event}]
-  (when (and timestamp receivedAt publishedAt)
-        (assoc event :timeReliable
-               (cond
-                ;; is the timestamp coming from
-                ;; the future
-                (> timestamp publishedAt)  false
-                (> publishedAt receivedAt) false
-                ;; is received - published within
-                ;; a reasonable time (10s) otherwise is bogus
-                (not (>= 10000 (- receivedAt publishedAt) 0)) false
-                ;; is the event generated within a
-                ;; reasonable time? 10d otherwise is bogus
-                (not (>= (* 10 24 60 60 1000) (- publishedAt timestamp) 0)) false
-                :else true))))
-
-
-
-(def samsara-pipeline
-  (pipeline
-   inject-kibana-timestamp
-   is-timestamp-reliable))


Performance tweak: swap protocol `partial` fns to anonymous fns (thanks to mpenet)

--- src/taoensso/carmine/protocol.clj
+++ src/taoensso/carmine/protocol.clj
@@ -164,8 +164,7 @@
                  :bin [payload payload-size]))))

       \* (let [bulk-count (Integer/parseInt (.readLine in))]
-           (utils/repeatedly* bulk-count (partial get-basic-reply! in
-                                                  throw-exceptions?)))
+           (utils/repeatedly* bulk-count #(get-basic-reply! in throw-exceptions?)))
       (throw (Exception. (str "Server returned unknown reply type: "
                               reply-type))))))

@@ -194,7 +193,7 @@

       (if (and (= reply-count 1) (not always-as-vec?))
         (get-reply! in true (first parsers))
-        (utils/mapv* (partial get-reply! in false) parsers)))))
+        (utils/mapv* #(get-reply! in false %) parsers)))))

 (defmacro with-context
   "Evaluates body in the context of a thread-bound connection to a Redis server.


Fix arity bug in IRC send-msg

Fix arity bug in IRC send-msg

--- src/yetibot/core/adapters/irc.clj
+++ src/yetibot/core/adapters/irc.clj
@@ -43,7 +43,9 @@
       (log/info "send message to channel" *target*)
       (try
         (if (> (count msg) irc-max-message-length)
-          (doall (map send-msg (split-msg-into-irc-max-length-chunks msg)))
+          (doall (map
+                   (partial send-msg adapter)
+                   (split-msg-into-irc-max-length-chunks msg)))
           (irc/message @conn *target* msg))
         (catch java.net.SocketException e
           ; it must have disconnect, try reconnecting again


hotfix error when no data present

hotfix error when no data present

--- src/cljs/org/broadinstitute/firecloud_ui/common/table.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/common/table.cljs
@@ -398,20 +398,22 @@
    (fn [{:keys [props state]} columns]
      (let [{{:keys [entity-types]} :server-response} @state]
        (fn [{:keys [current-page rows-per-page filter-text sort-column sort-order filter-group-index]} callback]
-         (let [type (nth entity-types filter-group-index)
-               sort-field (when (pos? sort-column)
-                            (get-in columns [sort-column :header]))]
-           (endpoints/call-ajax-orch
-             {:endpoint (endpoints/get-entities-paginated (:workspace-id props) type
-                                                          {"page" current-page
-                                                           "pageSize" rows-per-page
-                                                           "filterTerms" filter-text
-                                                           "sortField" sort-field
-                                                           "sortDirection" (name sort-order)})
-              :on-done (fn [{:keys [success? get-parsed-response]}]
-                         (if success?
-                           (let [{:strs [results]
-                                  {:strs [unfilteredCount filteredCount]} "resultMetadata"} (get-parsed-response)]
-                             (callback {:group-count unfilteredCount
-                                        :filtered-count filteredCount
-                                        :rows results}))))})))))})
+         (if (empty? entity-types)
+           (callback {:group-count 0 :filtered-count 0 :rows []})
+           (let [type (nth entity-types filter-group-index)
+                 sort-field (when (pos? sort-column)
+                              (get-in columns [sort-column :header]))]
+             (endpoints/call-ajax-orch
+               {:endpoint (endpoints/get-entities-paginated (:workspace-id props) type
+                                                            {"page" current-page
+                                                             "pageSize" rows-per-page
+                                                             "filterTerms" filter-text
+                                                             "sortField" sort-field
+                                                             "sortDirection" (name sort-order)})
+                :on-done (fn [{:keys [success? get-parsed-response]}]
+                           (if success?
+                             (let [{:strs [results]
+                                    {:strs [unfilteredCount filteredCount]} "resultMetadata"} (get-parsed-response)]
+                               (callback {:group-count unfilteredCount
+                                          :filtered-count filteredCount
+                                          :rows results}))))}))))))})


GUI: Added tikz to Filechooser

GUI: Added tikz to Filechooser

--- src/main/clojure/conexp/gui/draw/control/file_exporter.clj
+++ src/main/clojure/conexp/gui/draw/control/file_exporter.clj
@@ -2,7 +2,10 @@
   (:require [conexp.gui.draw.control.util :refer :all]
             [conexp.gui.draw.scenes :refer :all]
             [conexp.gui.util :refer :all]
-            [seesaw.core :refer [listen]])
+            [seesaw.core :refer [listen]]
+            [conexp.gui.draw.scene-layouts :refer :all]
+            [conexp.gui.draw.scenes :refer :all]
+            [conexp.io.layouts :refer :all])
   (:import java.io.File
            [javax.swing JButton JFileChooser]
            javax.swing.filechooser.FileNameExtensionFilter))
@@ -25,10 +28,12 @@
         ^JFileChooser fc (JFileChooser.),
         jpg-filter (FileNameExtensionFilter. "JPEG Files" (into-array ["jpg" "jpeg"])),
         gif-filter (FileNameExtensionFilter. "GIF Files"  (into-array ["gif"])),
+        tikz-filter (FileNameExtensionFilter. "TIKZ Files" (into-array ["tikz"]))
         png-filter (FileNameExtensionFilter. "PNG Files"  (into-array ["png"]))]
     (doto fc
       (.addChoosableFileFilter jpg-filter)
       (.addChoosableFileFilter gif-filter)
+      (.addChoosableFileFilter tikz-filter)
       (.addChoosableFileFilter png-filter))
     (listen save-button :action
             (fn [_]
@@ -36,7 +41,9 @@
                 (when (= retVal JFileChooser/APPROVE_OPTION)
                   (let [^File file (.getSelectedFile fc)]
                     (with-swing-error-msg frame "Error while saving"
-                      (save-image scn file (get-file-extension file)))))))))
+                      (if (= "tikz" (get-file-extension file))
+                        (write-layout :tikz (get-layout-from-scene scn) (.getAbsolutePath file))
+                          (save-image scn file (get-file-extension file))))))))))
   nil)

 ;;;


stack overflow ing enerator

stack overflow ing enerator

--- test/cljs/triboard/core_test.cljs
+++ test/cljs/triboard/core_test.cljs
@@ -85,7 +85,8 @@
 (def valid-game-gen
   "Generate a valid game, where each move is valid"
   (gen/bind
-    (gen/elements (range (inc max-number-of-turn-by-game)))
+    #_(gen/elements (range (inc max-number-of-turn-by-game)))
+    (gen/such-that #(< % 30) gen/int)  ;; 30 before stack overflow
     #(play-n-moves-gen (game/new-game) %)))


DRY up another case of company URL creation. Add hateoas link validation for report media type.

--- test/open_company/lib/hateoas.clj
+++ test/open_company/lib/hateoas.clj
@@ -2,7 +2,8 @@
   "Utility functions for testing HATEOAS https://en.wikipedia.org/wiki/HATEOAS"
   (:require [open-company.lib.check :refer (check)]
             [open-company.representations.common :refer (GET POST PUT PATCH DELETE)]
-            [open-company.representations.company :as company-rep]))
+            [open-company.representations.company :as company-rep]
+            [open-company.representations.report :as report-rep]))

 (defn- find-link [rel links]
   (some (fn [link] (if (= rel (:rel link)) link nil)) links))
@@ -19,8 +20,16 @@

 (defn verify-company-links [ticker links]
   (check (= (count links) 3))
-  (let [url (str "/v1/companies/" ticker)]
+  (let [url (company-rep/url ticker)]
     (verify-link "self" GET url company-rep/media-type links)
     (verify-link "update" PUT url company-rep/media-type links)
     ;(verify-link "partial-update" PATCH url company-rep/media-type links)
+    (verify-link "delete" DELETE url :no links)))
+
+(defn verify-report-links [ticker year period links]
+  (check (= (count links) 3))
+  (let [url (report-rep/url ticker year period)]
+    (verify-link "self" GET url report-rep/media-type links)
+    (verify-link "update" PUT url report-rep/media-type links)
+    ;(verify-link "partial-update" PATCH url report-rep/media-type links)
     (verify-link "delete" DELETE url :no links)))


add back in missing arena in tests

add back in missing arena in tests

--- test/wombats/test/arena/utils.clj
+++ test/wombats/test/arena/utils.clj
@@ -7,6 +7,9 @@

 (defonce test-4x5-empty-perimeter
   (load-file "resources/arena/4x5-empty-perimeter.edn"))
+
+(defonce test-4x4-empty-arena
+  (load-file "resources/arena/4x4-empty-arena.edn"))

 (deftest get-arena-dimensions
   (testing "calculates a square arena"


Changed order of comments.

Changed order of comments.

--- leiningen/cluster.clj
+++ leiningen/cluster.clj
@@ -17,7 +17,8 @@
    `(do (println (str (format "Create cluster of %s instances and %d nodes."
                               ~node-type ~node-count)))
         (forma.hadoop.cluster/create-cluster ~node-type ~node-count)
-        (println "Cluster created! Hit Control-C to exit."))))
+        (println "Cluster created!")
+        (println "Hit Control-C to exit."))))

 (defn destroy-cluster
   [project node-type]
@@ -25,7 +26,8 @@
    project
    `(do (println "Running destroy-cluster.")
         (forma.hadoop.cluster/destroy-cluster ~node-type)
-        (println "Cluster destroyed! Hit Control-C to exit."))))
+        (println "Cluster destroyed!")
+        (println "Hit Control-C to exit."))))

 (defn show-jobtracker-ip
   [project node-type]
@@ -33,7 +35,8 @@
    project
    `(do (if-let [jobtracker-ip# (forma.hadoop.cluster/jobtracker-ip ~node-type)]
           (println "The current jobtracker IP is " jobtracker-ip#)
-          (println "Sorry, no cluster seems to be running at the moment.")))))
+          (println "Sorry, no cluster seems to be running at the moment.")
+          (println "Hit Control-C to exit.")))))

 (defn execute-jar
   [project node-type & args]
@@ -45,7 +48,8 @@
      project
      `(do (let [jobtracker-ip# (forma.hadoop.cluster/jobtracker-ip ~node-type)]
             (println "Pretending to run some shit.")
-            (comment "scp uberjar up to jobtracker ip."))))))
+            (comment "scp uberjar up to jobtracker ip.")
+            (println "Hit Control-C to exit."))))))

 (defn cluster
   "Start or destroy a pallet-hadoop cluster.
@@ -61,8 +65,3 @@
                            "jobtracker-ip" show-jobtracker-ip
                            "execute" execute-jar)]
        (apply task-func project args))))
-
-;; Gotta figure out native deps in leiningen.
-
-
-


Fixes XML validation tests to display useful failure values.

--- umm-spec-lib/test/cmr/umm_spec/test/generate_and_parse.clj
+++ umm-spec-lib/test/cmr/umm_spec/test/generate_and_parse.clj
@@ -93,10 +93,9 @@
 (deftest generate-valid-xml
   (testing "valid XML is generated for each format"
     (are [fmt]
-        (->> example-record
-             (core/generate-metadata :collection fmt)
-             (core/validate-xml :collection fmt)
-             empty?)
+        (empty?
+         (core/validate-xml :collection fmt
+                            (core/generate-metadata :collection fmt example-record)))
       :echo10
       :dif
       :dif10


adding some feedback on initialization to punctuate the wait

--- plugin/src/leiningen/figwheel.clj
+++ plugin/src/leiningen/figwheel.clj
@@ -378,5 +378,6 @@
 (defn figwheel
   "Autocompile ClojureScript and serve the changes over a websocket (+ plus static file server)."
   [project & build-ids]
+  (println "Figwheel: Cutting some fruit, just a sec ...")
   (clean-on-dependency-change project)
   (fig-dispatch project build-ids))


[CS] Shuffle `lein run` processing pipeline

Moves `psql/start-run` to the top instead of waiting until after
everything's been loaded.

--- dev-src/dev/core.clj
+++ dev-src/dev/core.clj
@@ -12,12 +12,12 @@
             [democracyworks.squishy.data-readers]))

 (def pipeline
-  (concat [zip/assoc-file
+  (concat [psql/start-run
+           zip/assoc-file
            zip/extracted-contents
            t/attach-sqlite-db
            (data-spec/add-data-specs data-spec/data-specs)
-           t/xml-csv-branch]
-          [psql/start-run
+           t/xml-csv-branch
            psql/store-public-id]
           db/validations
           xml-output/pipeline


Set fenzo logging to warn, it is chatty

Set fenzo logging to warn, it is chatty

Signed-off-by: Wil <41c73e1c187a64e501bf473cfef5419e8eb5a640@twosigma.com>

--- scheduler/src/cook/components.clj
+++ scheduler/src/cook/components.clj
@@ -378,7 +378,10 @@
 (defn- init-logger
   ([] (init-logger {:levels {"datomic.db" :warn
                              "datomic.peer" :warn
-                             "datomic.kv-cluster" :warn}}))
+                             "datomic.kv-cluster" :warn
+                             "com.netflix.fenzo.AssignableVMs" :warn
+                             "com.netflix.fenzo.TaskScheduler" :warn
+                             "com.netflix.fenzo.AssignableVirtualMachine" :warn}}))
   ([{:keys [file] :or {file "log/cook.log"} {:keys [default] :or {default :info} :as overrides} :levels}]
    (try
      (.. (org.apache.log4j.Logger/getRootLogger)


Fix syntax error

Fix syntax error

--- scheduler/src/cook/components.clj
+++ scheduler/src/cook/components.clj
@@ -377,7 +377,7 @@
                              (when-not (:host riemann)
                                (throw (ex-info "You must specific the :host to send the riemann metrics to!" {:riemann riemann})))
                              (when-not (every? string? (:tags riemann))
-                               (throw (ex-info "Riemann tags must be a [\"list\", \"of\", \"strings\"]") riemann))
+                               (throw (ex-info "Riemann tags must be a [\"list\", \"of\", \"strings\"]" riemann)))
                              (let [config (merge {:port 5555
                                                   :local-host (.getHostName
                                                                 (java.net.InetAddress/getLocalHost))}


Make it so that we can see who is rate limited in our HTTP log. (#1521)

Co-authored-by: Scott Crosby <23e8f75489aff47cf2cd5a529e9a769a24e9501c@twosigma.com>

--- scheduler/src/cook/components.clj
+++ scheduler/src/cook/components.clj
@@ -255,9 +255,9 @@
                                   (cond-> {:ring-handler (routes
                                                            (route/resources "/resource")
                                                            (-> view
-                                                               tell-jetty-about-usename
                                                                (wrap-rate-limit {:storage rate-limit-storage
                                                                                :limit user-limit})
+                                                               tell-jetty-about-usename
                                                                impersonation-middleware
                                                                (conditional-auth-bypass authorization-middleware)
                                                                wrap-exception-logging


Ensure output indexes exist

Ensure output indexes exist

--- src/aurora/language.cljs
+++ src/aurora/language.cljs
@@ -175,7 +175,11 @@
                                    (aset output-fields (var->ix val) key))
                                  output-fields)))]

-          (Flow. solver output-kinds output-names output-fields))))))
+          ;; ensure at least one index per output
+          (dotimes [i (alength output-kinds)]
+            (.get-or-create-index kn (aget output-kinds i) (aget output-names i) (filter #(not (nil? %)) (aget output-fields i))))
+
+          (Flow. solver output-kinds output-names output-fields))))

 ;; TESTS


allow seqs of different length. coerce to interpolatable type. prevent infinite lazyness. fresh value protocol

--- src/bardo/interpolate.cljx
+++ src/bardo/interpolate.cljx
@@ -1,50 +1,131 @@
 (ns bardo.interpolate
-  (:require [clojure.set :refer [union]]))
+  (:require [clojure.set :refer [union]]
+            [clojure.core.match :refer [match]]))

 ;; a protocol for birthing new values from nil
-(defprotocol IBirth (birth [x]))
+(defprotocol IFresh
+  (fresh [x]))

-(extend-protocol IBirth
+(extend-protocol IFresh

-    #+clj java.lang.Number
-    #+cljs number
-    (birth [x]
-      0))
+  #+clj java.lang.Number
+  #+cljs number
+  (fresh [x]
+    0)

-(defprotocol IInterpolate (interpolate [start end]))
+  #+clj clojure.lang.Sequential
+  #+cljs Sequential
+  (fresh [x]
+    '())
+
+  #+clj clojure.lang.PersistentArrayMap
+  #+cljs PersistentArrayMap
+  (fresh [x]
+    {}))
+
+(defn wrap-nil
+  "if a value is nil, replace it with a fresh value of the other
+  value if it satisfies IFresh"
+  [start end]
+  (match [start end]
+         [nil nil] nil
+         [nil end] (if (satisfies? IFresh end)
+                     [(fresh end) end]
+                     [nil end])
+         [start nil] (if (satisfies? IFresh start)
+                       [start (fresh start)]
+                       [start nil])
+         [start end] [start end]))
+
+(defn is-lazy? [s]
+  (= clojure.lang.LazySeq (class s)))
+
+(defn prevent-infinite [x y]
+  (match (mapv is-lazy? [x y])
+         [true true] (throw
+                      (Exception. "Cannot interpolate between two LazySeq"))
+         [true _] [(take (count y) x) y]
+         [_ true] [x (take (count x) y)]
+         [_ _] [x y]))
+
+(defn coerce
+  "attempt to coerce values to the same type"
+  [x y]
+  (let [classes (mapv class [x y])]
+    (if (apply = classes)
+      (prevent-infinite x y)
+      (match [x y]
+             ;; [seq seq]
+             [([& _] :seq) ([& _] :seq)] (prevent-infinite x y)
+             ;; [vector seq]
+             [[& _] ([& _] :seq)] (coerce [(seq x) y])
+             ;; [seq vector]
+             [([& _] :seq) [& _]] (coerce [x (seq y)])
+             [_ _] [nil nil]))))
+
+(defprotocol IInterpolate (-interpolate [start end]))
+
+(defn interpolate [start end]
+  (let [coerced (some->> [start end]
+                         (apply wrap-nil)
+                         (apply coerce))]
+    (let [can-interpolate (->> coerced
+                               (mapv (partial satisfies? IInterpolate)))]
+      (if (apply = true can-interpolate)
+        (apply -interpolate coerced)
+        (do
+          (throw
+           (Exception. (str "Cannot interpolate between " start " and " end))))))))

 (extend-protocol IInterpolate

-  nil
-  (interpolate [start end]
-    (interpolate (birth end) end))
-
   #+clj java.lang.Number
   #+cljs number
-  (interpolate [start end]
-    (cond
-       (nil? end) (interpolate start (birth start))
-       :else (fn [t]
-               (+ start (* t (- end start))))))
+  (-interpolate [start end]
+    (fn [t]
+      (+ start (* t (- end start)))))

-  #+clj clojure.lang.PersistentVector
-  #+cljs PersistentVector
-  (interpolate [start end]
+  #+clj clojure.lang.Sequential
+  #+cljs Sequential
+  (-interpolate [start end]
     (fn [t]
-      (mapv (comp #(% t) interpolate) start end)))
+      (seq (for [k (range (Math/max (count start)
+                                    (count end)))]
+             (->> [(nth start k nil) (nth end k nil)]
+                  (apply wrap-nil)
+                  (apply interpolate)
+                  (#(% t)))))))

-  #+clj clojure.lang.PersistentList
-  #+cljs List
-  (interpolate [start end]
-    (fn [t]
-      (map (comp #(% t) interpolate) start end)))
-
-  #+clj clojure.lang.PersistentArrayMap
-  #+cljs PersistentArrayMap
-  (interpolate [start end]
+  #+clj clojure.lang.IPersistentMap
+  #+cljs IPersistentMap
+  (-interpolate [start end]
     (fn [t]
       (into {} (for [k (->> [start end]
                             (map keys)
                             (map set)
                             (apply union))]
-                 [k (apply (comp #(% t) interpolate) (map k [start end]))])))))
+                 [k (->> [start end]
+                         (map k)
+                         (apply interpolate)
+                         (#(% t)))])))))
+
+
+(comment
+  (defn intrpl [start end]
+    ((interpolate start end) 0.5))
+
+  (mapv #(satisfies? IInterpolate %) [1 ""])
+  (satisfies? IInterpolate "")
+  (intrpl 1 2)
+  (intrpl [1 2] [5 6])
+  ;; fails correctly
+  (intrpl [1 5] [2 [1 2]])
+  ;; works
+  (intrpl [1 2] (range 5))
+  (intrpl (range 5) [1 2])
+  (intrpl [1 2] (repeat 5))
+
+  (intrpl (repeat 5) (repeat 2))
+
+  (intrpl {:a 0 :c 1} {:a 5 :b 2})
+  )


Removed obsolete compilation instructions that used the command line.

--- src/cljs/ajaxify/main.cljs
+++ src/cljs/ajaxify/main.cljs
@@ -2,10 +2,6 @@
 ;; correct URLs and back/forward button behavior.
 ;; Just to mix things up a bit (and build up my Lisp cred)
 ;; this is written in ClojureScript.
-;; Compile by cding to the top-level directory, then invoking
-;; cljsc src '{optimizations :simple}' > ajaxify.js
-;; You can also do :whitespace for optimizations or set :pretty-print
-;; to true to produce more readable JavaScript for debugging.
 (ns ajaxify.main
   (:require-macros [ajaxify.macros :as macros]))


Select models in correct order

Select models in correct order

--- src/core/clj/virt/core.clj
+++ src/core/clj/virt/core.clj
@@ -28,7 +28,8 @@
 (defn get-channels [lon lat]
   (korma/select channels
     (korma/where
-      (korma/raw (str "ST_DWithin(location," (geoFromText lon lat) ",200)")))))
+      (korma/raw (str "ST_DWithin(location," (geoFromText lon lat) ",200)")))
+    (korma/order :id :DESC)))

 (defn add-channel [channel-name lon lat]
   (korma/insert channels
@@ -38,7 +39,8 @@

 (defn get-threads [channel-id]
   (korma/select threads
-    (korma/where {:channel_id channel-id})))
+    (korma/where {:channel_id channel-id})
+    (korma/order :id :DESC)))

 (defn add-chat-thread [channel-id thread-descr]
   (korma/insert threads
@@ -48,7 +50,8 @@
 (defn get-messages [channel-id thread-id]
   (korma/select messages
     (korma/where {:channel_id channel-id
-                  :thread_id thread-id})))
+                  :thread_id thread-id})
+    (korma/order :id :ASC)))

 (defn add-msg [channel-id thread-id msg]
   (korma/insert messages


add assert for recursive fragments

add assert for recursive fragments

--- src/cambo/component.cljc
+++ src/cambo/component.cljc
@@ -115,9 +115,13 @@
             pathsets (update-fragments (fn [fragment]
                                          (if (instance? RecursiveContainerFragment fragment)
                                            (if (> count 0)
-                                             [[[(RecursiveContainerFragment. (.-comp fragment)
-                                                                             (.-name fragment)
-                                                                             (dec count))]]]
+                                             (do
+                                               (assert (and (= comp (.-comp fragment))
+                                                            (= name (.-name fragment)))
+                                                       "recursive fragment can't contain other recursive fragments")
+                                               [[[(RecursiveContainerFragment. (.-comp fragment)
+                                                                               (.-name fragment)
+                                                                               (dec count))]]])
                                              [])
                                            [[[fragment]]]))
                                        (pathsets fragment))]


Clean up

Clean up

--- src/asteroids/core.clj
+++ src/asteroids/core.clj
@@ -167,29 +167,29 @@
      :else expr))
   ([expr] (get-expr-value expr nil)))

-(defn create-shot ([ammunition-type {ship-pos :position ship-size :size ship-dir :direction ship-speed :speed}]
-   (let [{:keys [spread size shape color acceleration direction rotation-speed damage life-time]} (get ammunition-types ammunition-type)
-         move-dir (if spread (+ ship-dir (random (- spread) spread)) ship-dir)
-         dir-vec (m/rotate-vec move-dir [0 1])
-         position (m/vec+vec ship-pos (m/num*vec ship-size dir-vec))
-         speed (m/vec+vec ship-speed (m/num*vec (-> ammunition-types ammunition-type :speed) dir-vec))]
-     {:type           ammunition-type
-
-      :size           (get-expr-value size)
-      :shape          (get-expr-value shape)
-      :color          (get-expr-value color)
-      :paint-method   fill-polygon
-
-      :position       position
-      :speed          speed
-      :acceleration   (get-expr-value acceleration 0)
-
-      :direction      (get-expr-value direction move-dir)
-      :rotation-speed (get-expr-value rotation-speed 0)
-
-      :collidable?    (get-expr-value damage)
-
-      :life-time      (get-expr-value life-time)})))
+(defn create-shot [ammunition-type {ship-pos :position ship-size :size ship-dir :direction ship-speed :speed}]
+  (let [{:keys [spread size shape color acceleration direction rotation-speed damage life-time]} (get ammunition-types ammunition-type)
+        move-dir (if spread (+ ship-dir (random (- spread) spread)) ship-dir)
+        dir-vec (m/rotate-vec move-dir [0 1])
+        position (m/vec+vec ship-pos (m/num*vec ship-size dir-vec))
+        speed (m/vec+vec ship-speed (m/num*vec (-> ammunition-types ammunition-type :speed) dir-vec))]
+    {:type           ammunition-type
+
+     :size           (get-expr-value size)
+     :shape          (get-expr-value shape)
+     :color          (get-expr-value color)
+     :paint-method   fill-polygon
+
+     :position       position
+     :speed          speed
+     :acceleration   (get-expr-value acceleration 0)
+
+     :direction      (get-expr-value direction move-dir)
+     :rotation-speed (get-expr-value rotation-speed 0)
+
+     :collidable?    (get-expr-value damage)
+
+     :life-time      (get-expr-value life-time)}))

 (defn create-explosion [position {:keys [size color life-time damage] :as explosion}]
   (if explosion


println

println

--- src/babel/english.cljc
+++ src/babel/english.cljc
@@ -19,7 +19,11 @@
   (if (and (not (nil? medium-model))
            (realized? medium-model))
     @medium-model
-    @(deliver medium-model (grammar/medium))))
+    @(do
+       (print (str "creating model..(will be slow the first time).."))
+       (let [result (deliver medium-model (grammar/medium))]
+         (println (str "done."))
+         result))))

 (declare morph)


fix war task

fix war task

--- src/cake/tasks/jar.clj
+++ src/cake/tasks/jar.clj
@@ -60,7 +60,7 @@

 (defn add-source-files [task & [opts]]
   (when-not (:omit-source *project*)
-    (add-path task :source-path {:includes "**/*.clj, **/*.java"}))
+    (add-path task :source-path (assoc opts :includes "**/*.clj, **/*.java")))
   (when (:bake *project*)
     (add-zipfileset task (bakepath opts :excludes "cake.clj"))))


Updated static documentation for gadm, ecoid, hansen, and vcf.

--- src/clj/forma/static.clj
+++ src/clj/forma/static.clj
@@ -32,27 +32,41 @@
    gadm :: administrative boundaries, found
    [here](http://goo.gl/2N5CT), and converted to a raster with the
    cell value given by ID_2, an integer value corresponding to the
-   most detailed administrative unit.
+   most detailed administrative unit. .01 degree resolution chosen
+   for simplicity, but should have limited impact on where a pixel
+   falls aside from at borders.

    ecoid :: ecoregions according to the World Wildlife Fund. The
    technical paper can be found [here](http://goo.gl/yvssq). The
    polygons are converted to a raster for sampling - much like the
    admin boundaries - where each cell is assigned the value of the
-   ecoregion id, the most detailed eco unit.
+   ecoregion id, the most detailed eco unit. .01 degree resolution
+   chosen for simplicity, but should have limited impact on where
+   a pixel falls aside from at borders.

    hansen :: forest cover loss hotspots data for training at 500m
    resolution, found [here](http://goo.gl/HqvCW). Note that this has
    been projected into WGS84 from Sinusoidal (463.3127m res).  The
-   time period is 2000-2005.
+   time period is 2000-2005. UPDATE: This may be superceded by the
+   use of an unreprojected ascii grid that lines up perfectly with
+   MODIS data and can therefore be assigned to MODIS pixels with
+   no error from reprojection.

    vcf :: vegetation continuous field index, derived from MODIS
    products for the year 2000, found [here](http://goo.gl/KW8y1), and
    used to define the extent of the sample area, given by the Forest
-   Cover Loss Hotspots training data set.
+   Cover Loss Hotspots training data set. UPDATE: This may be
+   superceded by the use of an unreprojected ascii grid that lines up
+   perfectly with MODIS data and can therefore be assigned to MODIS
+   pixels with no error from reprojection.

-   border :: distance in meters to a coastline, defined by the border
-   of land and large body of water.  Projected in MODIS coordinates
-   (463m resolution)." }
+   border :: index from 1-20 representing 500m increments of distance
+   to a coastline as defined by the GADM Level 0 dataset available at
+   GADM.org. Coastlines are defined as the border between land and large
+   bodies of water. Land is defined by the polygon of country boundaries.
+   Projected World Sinusoidal for distance calculations with ~463m
+   resolution. Then reprojected WGS84 with .0083333 resolution for
+   conversion to ascii grid, with bilinear interpolation of pixel values."}
   static-datasets
   {:precl  {:corner [0 -90]
             :travel [+ +]


function names changed to add-cookie and clear-cookies

--- src/clj_http/cookies.clj
+++ src/clj_http/cookies.clj
@@ -136,22 +136,14 @@
   (when cookie-store
     (into {} (map to-cookie (.getCookies cookie-store)))))

-<<<<<<< HEAD
 (defn add-cookie
-=======
-(defn add-cookie-to-cookie-store
->>>>>>> 4104028ab6c0893879ea93358c8c4a34b9aa55be
   "Add a ClientCookie to a cookie-store"
   [^CookieStore cookie-store ^ClientCookie cookie]
   (.addCookie cookie-store cookie)
   )

-<<<<<<< HEAD
 (defn clear-cookies
-=======
-(defn clear-cookies-from-cookie-store
->>>>>>> 4104028ab6c0893879ea93358c8c4a34b9aa55be
-  "Clears all cookies from cookie-store"
+ "Clears all cookies from cookie-store"
   [^CookieStore cookie-store]
   (.clear cookie-store)
   )


Changes requestes to send parameters in body instead of in url. Adds meta-data response http code as :status.

--- src/clj_spotify/core.clj
+++ src/clj_spotify/core.clj
@@ -9,15 +9,15 @@

 (def spotify-api-url "https://api.spotify.com/v1/")

-;TODO - add http response header type as meta-data.
 (defn response-to-map
   "Parse body of http respose to json"
   [response]
+  (with-meta
   (try
     (json/read-str (:body response) :key-fn keyword)
     (catch java.lang.NullPointerException e {:error {:status "NullPointerException"  :message (.getMessage e)}})
     (catch Exception e {:error {:status "Exception"  :message (.getMessage e)}})
-    )
+    ) {:status (:status response)})
   )

 (defn- build-new-url
@@ -45,7 +45,6 @@
     )))

 ;TODO - better doc string
-;TODO - Maybe change everything to be sent through request body?
 (defmacro def-spotify-api-call
   "Creates a function f with doc-string d that calls the http-verb verb for url url."
   [f verb url doc-string]
@@ -53,7 +52,7 @@
      ~doc-string
      ([m#] (~f m# nil))
      ([m# t#]
-      (let [query-params# {:query-params (apply dissoc m# template-keys) :oauth-token t#}]
+      (let [query-params# {:form-params (apply dissoc m# template-keys) :oauth-token t# :content-type :json}]
         (->
           (try
             (~verb (replace-url-values m# ~url) query-params#)
@@ -62,8 +61,7 @@
           (response-to-map)
           )))))

-;TODO - Replace all comma separated strings with maps?
-
+;TODO - Replace all comma separated strings with seqs?
 ;Albums
 (def-spotify-api-call get-an-album client/get (str spotify-api-url "albums/id")
 " Takes two arguments, a map m with query parameters and an optional oauth-token t.
@@ -216,7 +214,6 @@

     Example: (user-following-artists-or-users? {:type \"artist\" :ids \"3H6Js0rhywEhHda3UwuhGW,4r8bVMyYyGyARs9OfBvyj4\" } \"BQBw-JtC..._7GvA\")")

-;TODO - public:true in request body.
 (def-spotify-api-call follow-a-playlist client/put (str spotify-api-url "users/owner_id/playlists/playlist_id/followers")
 " Takes two arguments, a map m with query parameters and an optional oauth-token t.
     Compulsory keys in m are :owner_id and :playlist_id.
@@ -283,7 +280,6 @@

     Example: (get-a-list-of-a-users-playlists {:user_id \"elkalel\" :limit 50 :offset 50} \"BQBw-JtC..._7GvA\")")

-;TODO - Can you pass :limit and :offset here? Let's assume you can.
 ;TODO - Change this fields string to be a map?
 (def-spotify-api-call get-a-playlist client/get (str spotify-api-url "users/user_id/playlists/playlist_id")
 " Takes two arguments, a map m with query parameters and an optional oauth-token t.
@@ -311,7 +307,6 @@

     Example: (get-a-playlists-tracks {:user_id \"elkalel\" :playlist_id \"6IIjEBw2BrRXbrSLerA7A6\" :fields \"href,name,owner\":limit 50 :offset 50 :market \"SE\"} \"BQBw-JtC..._7GvA\")")

-;TODO - Deal with request body data for values of :name and :public.
 (def-spotify-api-call create-a-playlist client/post (str spotify-api-url "users/user_id/playlists")
 " Takes two arguments, a map m with query parameters and an optional oauth-token t.
     Compulsory keys in m are :user_id and :name, optional key is :public.
@@ -332,7 +327,6 @@
     Example: (add-tracks-to-playlist {:user_id \"elkalel\" :playlist_id \"6IIjEBw2BrRXbrSLerA7A6\" :uris \"spotify:track:4iV5W9uYEdYUVa79Axb7Rh,
 spotify:track:1301WleyT98MSxVHPZCA6M\" :position 2} \"BQBw-JtC..._7GvA\")")

-;TODO - Deal with request body data, very nescessary here.
 ;TODO - Deal with correct formatting of :tracks.
 ;TODO - Additional doc string with optional and required values in :tracks.
 (def-spotify-api-call remove-tracks-from-a-playlist client/delete (str spotify-api-url "users/user_id/playlists/playlist_id/tracks")


Lava now burns

Lava now burns

But only when moving. Once the life has run out, the game is over

--- src/cljs/kenny/core.cljs
+++ src/cljs/kenny/core.cljs
@@ -19,7 +19,7 @@
            [0 0 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
            [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
            [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
-           [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
+           [0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0]
            [0 1 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 1 0]
            [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]
            ])
@@ -46,10 +46,11 @@

 (def app-state (atom {:text "Hello Chestnut!"
                       :hero {:move false
+                             :life 100
                              :position (hero-start-position grid-content)
                              :jump {:time nil :bottom nil}
                              }
-
+                      :game-over false
                       :grid grid-content}))

 (defn ceil [i]
@@ -72,6 +73,11 @@
      ]
     ))

+(defn current-blocks [position]
+  (let [[left right] (hero-feet-coords position)
+        app @app-state]
+    [(get-in app (into [:grid] left)) (get-in app (into [:grid] right))]
+          ))

 (defn most-supportive-block [position]
   (let [[left right] (hero-feet-coords position)
@@ -160,21 +166,37 @@
       :right (move-right? app position))
     ))

+(defn in-lava [app]
+  (let [position (get-in app [:hero :position])]
+    (some #{4} (current-blocks position))
+    )
+  )
+
 (defn hero [app owner]
   (reify
     om/IWillMount
     (will-mount [_]
-      (go-loop []
+      (if (>= 0 (get-in @app [:hero :life]))
+        (om/update! app [:game-over] true)
+        (go-loop []
         (om/update! app [:hero :position :bottom] (vertical-position app))
         (when (= :left (get-in @app [:hero :move]))
           (when (can-move :left @app)
+            (when (in-lava @app)
+              (om/transact! app [:hero :life] (fn [old] (- old 1)))
+              )
             (om/transact! app [:hero :position :left] (fn [old] (- old 5)))))
         (when (= :right (get-in @app [:hero :move]))
           (when (can-move :right @app)
+            (when (in-lava @app)
+              (om/transact! app [:hero :life] (fn [old] (- old 1)))
+              )
             (om/transact! app [:hero :position :left] (fn [old] (+ old 5)))))
         (<! (timeout (/ 1000 60)))
         (recur)
-        ))
+        )
+        )
+      )
     om/IRenderState
     (render-state [this state]
       (dom/div #js {:className (hero-classes app) :style (hero-position app)} nil))
@@ -215,6 +237,13 @@
        dom/div nil
        (om/build-all row grid)))))

+(defn status-bar [hero owner]
+  (reify
+    om/IRender
+    (render [this]
+      (dom/h1 nil (hero :life))))
+  )
+
 (defn start-moving [e app]
   (condp = (aget e "keyCode")
     88 (om/update! app [:hero :move] :right)
@@ -240,9 +269,15 @@
       (reify
         om/IRender
         (render [_]
-          (dom/div #js {:className "grid" :tabIndex 0 :onKeyUp (fn [e] (stop-moving e app)) :onKeyDown (fn [e] (start-moving e app) (.preventDefault e))}
+          (console-log (get-in app [:hero :life]))
+          (if (>= 0 (get-in app [:hero :life]))
+            (dom/h1 nil "GAME OVER")
+            (dom/div #js {:className "grid" :tabIndex 0 :onKeyUp (fn [e] (stop-moving e app)) :onKeyDown (fn [e] (start-moving e app) (.preventDefault e))}
+                   (om/build status-bar (:hero app))
                    (om/build hero app)
                    (om/build grid (:grid app))
-                   ))))
+                   )
+            )
+          )))
     app-state
     {:target (. js/document (getElementById "app"))}))


Make :repeated-errors 1/(inc length-to-repeat), 0 for no repeats, 1 for no history

--- src/clojush/evaluate.clj
+++ src/clojush/evaluate.clj
@@ -278,7 +278,7 @@
                           (set (rest (:history ind))))
                     1
                     0))
-              (if (not (:print-history argmap))
+              #_(if (not (:print-history argmap))
                 (throw
                   (Exception.
                     ":print-history must be true for :repeated-errors"))
@@ -287,6 +287,17 @@
                               (set (take 3 (rest (:history ind))))))
                     1
                     0))
+              (if (not (:print-history argmap))
+                (throw
+                  (Exception.
+                    ":print-history must be true for :repeated-errors"))
+                (if (empty? (rest (:history ind)))
+                  1
+                  (if (some #{(first (:history ind))}
+                            (set (rest (:history ind))))
+                    (/ 1 (inc (count (take-while #(not= % (first (:history ind)))
+                                                 (rest (:history ind))))))
+                    0)))
               ;
               (= cat :case-family-variation)
               (if (not (:print-history argmap))


fix issue with targeting hosted program

fix issue with targeting hosted program

--- src/clj/game/cards.clj
+++ src/clj/game/cards.clj
@@ -1591,8 +1591,7 @@

    "Net-Ready Eyes"
    {:effect (effect (damage :meat 2 {:unboostable true :card card})) :msg "suffer 2 meat damage"
-    :events {:run {:choices {:req #(and (= (:zone %) [:rig :program])
-                                        (has? % :subtype "Icebreaker"))}
+    :events {:run {:choices {:req #(and (:installed %) (has? % :subtype "Icebreaker"))}
                    :msg (msg "give " (:title target) " +1 strength")
                    :effect (effect (pump target 1))}}}

@@ -2545,9 +2544,7 @@
    {:effect (effect (run :rd) (access-bonus 2))}

    "The Personal Touch"
-   {:hosting {:req #(and (has? % :subtype "Icebreaker")
-                         (or (= (last (:zone %)) :program)
-                             (= (first (:zone (:host %))) :rig)))}}
+   {:hosting {:req #(and (has? % :subtype "Icebreaker") (:installed %))}}

    "The Supplier"
    {:abilities [{:label "Host a resource or piece of hardware" :cost [:click 1]


Fix exit/quit for sjacket parsing (as strings)

--- src/clj/reply/exit.clj
+++ src/clj/reply/exit.clj
@@ -1,7 +1,8 @@
 (ns reply.exit)

 (defn done-commands [eof]
-  #{eof 'quit 'exit '(quit) '(exit)})
+  #{eof 'quit 'exit '(quit) '(exit)
+    "quit" "(quit)" "exit" "(exit)"})

 (defn done? [eof expression]
   ((done-commands eof) expression))


Add log (base 10) scale.

Add log (base 10) scale.

--- src/cljs/c2/scale.cljs
+++ src/cljs/c2/scale.cljs
@@ -10,3 +10,13 @@
          (* range-length
             (/ (- x (first domain))
                domain-length))))))
+
+
+(defn log [& {:keys [domain range]
+              :or {domain [1 10]
+                   range  [0 1]}}]
+  (let [log #(/ (.log js/Math %)
+                (.-LN10 js/Math))
+        lin (linear :domain (map log domain)
+                    :range range)]
+    (comp lin log)))


New function: fourth

New function: fourth

--- src/clouseau/utils.clj
+++ src/clouseau/utils.clj
@@ -45,6 +45,11 @@
     [coll]
     (nth coll 2 nil))

+(defn fourth
+    "Simple utility function - returns fourth item from a given sequence, nil if third item does not exist."
+    [coll]
+    (nth coll 3 nil))
+
 (defn substring
     "Call method String.substring()."
     ([^String s from to]


Added parameter argument list to route syntax

--- src/compojure/routes.clj
+++ src/compojure/routes.clj
@@ -25,47 +25,57 @@
           (= (.toUpperCase (name method)) form-method)
           (= method request-method)))))

-(defn- request-matcher
-  "Compiles a function to match a HTTP request against the supplied method
-  and route."
-  [method route]
-  (let [matcher (cond
-                  (string? route) (route-compile route)
-                  (seq? route)    (route-compile
-                                    (first route)
-                                    (apply hash-map (rest route)))
-                  :otherwise      route)]
-   `(fn [request#]
-      (and (method-matches ~method request#)
-           (route-matches ~matcher request#)))))
+(defn- assoc-binding
+  "Associate an argument with a map of bindings."
+  [bindings arg]
+  (assoc bindings (symbol (name arg)) (keyword (str arg))))

-(defmacro with-request-bindings
-  "Add shortcut bindings for the keys in a request map."
-  [request & body]
-  `(let [~'request ~request
-         ~'params  (:params  ~'request)
-         ~'cookies (:cookies ~'request)
-         ~'session (:session ~'request)
-         ~'flash   (:flash   ~'request)]
-     ~@body))
+(defn- single-bindings
+  "Create a binding map of all the single value arguments."
+  [args]
+  (reduce assoc-binding {} (take-while #(not= % '&) args)))
+
+(defn- assoc-rest-bindings
+  "Assoc the '& rest' argument to a binding map."
+  [bindings args]
+  (if-let [rest-arg (second (drop-while #(not= % '&) args))]
+    (assoc bindings :as rest-arg)
+    bindings))
+
+(defn- make-param-bindings
+  "Return a map of parameter bindings derived from the request map and a
+  vector of argument names."
+  [args]
+  (-> (single-bindings args)
+      (assoc-rest-bindings args)))
+
+(defn- prepare-route
+  "Pre-compile the route."
+  [route]
+  (cond
+    (string? route)
+      (route-compile route)
+    (seq? route)
+      (route-compile (first route) (apply hash-map (rest route)))
+    :else
+      route))

 (defn assoc-route-params
   "Associate route parameters with the request map."
   [request params]
-  (-> request
-    (assoc :route-params params)
-    (assoc :params (merge (:params request)
-                          (if (map? params) params)))))
+  (merge-with merge request {:route-params params, :params params}))

 (defn compile-route
   "Compile a route in the form (method path & body) into a function."
-  [method path body]
-  `(let [matcher# ~(request-matcher method path)]
-     (fn [request#]
-       (if-let [route-params# (matcher# request#)]
-         (let [request# (assoc-route-params request# route-params#)]
-           (create-response request#
-             (with-request-bindings request# ~@body)))))))
+  [method route args body]
+  (let [bindings (make-param-bindings args)]
+    `(let [route# ~(prepare-route route)]
+       (fn [request#]
+         (if (method-matches ~method request#)
+           (if-let [route-params# (route-matches route# request#)]
+             (let [request#  (assoc-route-params request# route-params#)
+                   ~bindings (request# :params)]
+               (create-response request# (do ~@body)))))))))

 (defn routes*
   "Create a Ring handler by combining several handlers into one."
@@ -92,25 +102,25 @@
       (routes ~@routes))))

 (defmacro GET "Generate a GET route."
-  [path & body]
-  (compile-route :get path body))
+  [path args & body]
+  (compile-route :get path args body))

 (defmacro POST "Generate a POST route."
-  [path & body]
-  (compile-route :post path body))
+  [path args & body]
+  (compile-route :post path args body))

 (defmacro PUT "Generate a PUT route."
-  [path & body]
-  (compile-route :put path body))
+  [path args & body]
+  (compile-route :put path args body))

 (defmacro DELETE "Generate a DELETE route."
-  [path & body]
-  (compile-route :delete path body))
+  [path args & body]
+  (compile-route :delete path args body))

 (defmacro HEAD "Generate a HEAD route."
-  [path & body]
-  (compile-route :head path body))
+  [path args & body]
+  (compile-route :head path args body))

 (defmacro ANY "Generate a route that matches any method."
-  [path & body]
-  (compile-route nil path body))
+  [path args & body]
+  (compile-route nil path args body))


Delete log

Delete log

--- src/export_server/core.clj
+++ src/export_server/core.clj
@@ -267,7 +267,6 @@
     (let [options @state/options
           mode (:mode options)]
       (reset! web/allow-script-executing (:allow-scripts-executing options))
-      (println options)
       (case mode
         "server" (start-server options summary)
         "cmd" (cmd-export options summary)


fix ##89

fix ##89

--- src/frontend/renderer.cljs
+++ src/frontend/renderer.cljs
@@ -75,8 +75,7 @@
       (dom/li nil (if (= (.-uploaderid data) (.-id app-state/socket))
                     (list
                       (dom/button #js {:onClick #(core/cancel-upload (.-id data))}       "CANCEL")
-                      (if (and (:paused? ((:uploads @app-state/app-state) (.-clientid data)))
-                               (not (:stopped? ((:uploads @app-state/app-state) (.-clientid data)))))
+                      (if (:paused? ((:uploads @app-state/app-state) (.-clientid data)))
                         (dom/button #js {:onClick #(core/resume-upload!  (.-clientid data))} "RESUME")
                         (dom/button #js {:onClick #(core/pause-upload!   (.-clientid data))} "PAUSE"))))
                   (if (:stopped? ((:uploads @app-state/app-state) (.-clientid data)))


Highlight numbers using green background.

--- src/garden/puzzle-view.clj
+++ src/garden/puzzle-view.clj
@@ -9,7 +9,7 @@

         [:td :th {:cursor "pointer"}]

-        [:.solved.num {:background-color "#c4faaf"}]]
+        [:.solved.num :.num-clicked {:background-color "#c4faaf"}]]

     [:.containter
         {:padding "30px"
@@ -69,8 +69,6 @@
                   {:color active-color
                    :cursor "pointer"}]]]

-    [:.num-clicked {:color "red"}]
-
     (for [dir ["top" "bottom" "left" "right"]]
       [(str ".thick-" dir)
        {(str "border-" dir) "2px solid black"}])


Pass media-count and total-media vars to format-answer function

--- src/hatti/views/table.cljs
+++ src/hatti/views/table.cljs
@@ -77,12 +77,15 @@
   "Formatter for slickgrid columns takes row,cell,value,columnDef,dataContext.
    Get one with (partial formatter field language)."
   [field language field-key row cell value columnDef dataContext]
-  (let [clj-value (js->clj value :keywordize-keys true)]
+  (let [clj-value (js->clj value :keywordize-keys true)
+        media-count (.-_media_count dataContext)
+        total-media (.-_total_media dataContext)]
     (format-answer field
                    (escape-for-type clj-value)
                    :language language
                    :compact? true
-                   :field-key field-key)))
+                   :field-key field-key
+                   :media-count media-count :total-media total-media)))

 (defmethod action-buttons :default
   [owner]


man bedroom description

man bedroom description

--- src/house/rooms/front.cljc
+++ src/house/rooms/front.cljc
@@ -32,7 +32,8 @@
                               " "))

 (def papers (item/make ["pile of papers" "papers"] "A pile of written papers."
-                       :read "We like the house because, apart from its being old and spacious (in a day when old houses go down for a profitable auction of their construction materials), it keeps the memories of great‐grandparents, our paternal grandfather, our parents and the whole of childhood. Irene and I got used to staying in the house by ourselves, which is crazy, eight people could live in this place and not get in each other's way. We rise at seven in the morning and get the cleaning done, and about eleven I leave Irene to finish off whatever rooms and go to the kitchen. We lunch at noon precisely; then there is nothing left to do but a few dirty plates. It is pleasant to take lunch and commune with the great hollow, silent house, and it is enough for us just to keep it clean..."))
+                       :read "We like the house because, apart from its being old and spacious (in a day when old houses go down for a profitable auction of their construction materials), it keeps the memories of great‐grandparents, our paternal grandfather, our parents and the whole of childhood. Irene and I got used to staying in the house by ourselves, which is crazy, eight people could live in this place and not get in each other's way. We rise at seven in the morning and get the cleaning done, and about eleven I leave Irene to finish off whatever rooms and go to the kitchen. We lunch at noon precisely; then there is nothing left to do but a few dirty plates. It is pleasant to take lunch and commune with the great hollow, silent house, and it is enough for us just to keep it clean…"
+                       :take "No need to carry that around."))

 (defn post-desk-open
   [_ gs]
@@ -47,6 +48,46 @@
                              :open {:pre true :say "I rolled up the cover." :post `post-desk-open}
                              :items #{papers large-key}))

+(def book (item/make "book" "L'école des indifférents by Jean Giraudoux." :read "I don't do french… books." :take "No, thanks."))
+
+(def album (item/make ["stamps album" "album" "stamps"] "I guess with enough free time you can turn anything into a hobby."
+                :take "Not a chance."
+                :open "Not a chance."
+                :read "Nothing to read in it."))
+
+(def window (item/make ["window" "street"] "It was dark outside."
+                       :break "I couldn’t, the window had bars on it."
+                       :open "There was no benefit in doing that."))
+
+(def drawers (item/make ["desk drawers" "drawers"] "The rolltop desk was full of them."
+                        :open "I had no time to go over the desk drawers, there were too many of them."))
+
+(defn post-open
+  [old gs]
+  (let [box (utils/find-first gs "box")
+        new-box (update-in box [:open] dissoc :say)]
+    (utils/replace-item gs box new-box)))
+
+(def cash (item/make ["bunch of cash" "cash" "money" "wads" "wads of cash"] "Around 15 thousand pesos, I estimated." :take true))
+(def box (item/make "box" "Shoes, I guessed."
+                    :take "I wasn’t interested in the box, but maybe in its contents."
+                    :open {:pre true
+                           :say "The box was full of wads of cash that I quickly estimated in around 15 thousand pesos."
+                           :post `post-open}
+                    :items #{cash}))
+(def wardrobe (item/make "wardrobe" "Big, old and expensive, like everything in the house."
+                         :closed true
+                         :open {:pre true
+                                :say "The wardrobe was full of man clothes. There was also a little box on its base."}
+                         :items #{box}))
+
 (def man-bedroom (->
-                  (room/make "Man's bedroom" " ")
-                  (room/add-item rolltop-desk)))
+                  (room/make "Man's bedroom" "A man’s bedroom with a bed, a night table, an wardrobe and a rolltop desk."
+                             :initial-description "The man’s bedroom was less furnished than the rest of the rooms: there were an old bed with a night table, a big wardrobe and a rolltop desk on the opposite side of the room.")
+                  (room/add-item rolltop-desk "")
+                  (room/add-item window "On the southern wall was the window I saw from the street.")
+                  (room/add-item book "There was a stamps album on the desk and a little book on the night table.")
+                  (room/add-item (item/make ["night table" "table"]) "")
+                  (room/add-item album "")
+                  (room/add-item drawers "")
+                  (room/add-item wardrobe "")))