fix indentations (#66)

fix indentations (#66)

* add GCD in clojure

* add functionality for negative numbers

* add clojure implementation for euclidean subtraction method

* add clojure implementation for euclidean modular method

* clojure example code at the end of the page

* add clojure to bogo sort in fundamental algorithms

* Add clojure to book.json and update implemented chapters.

* fix typo

* fix indentation in euclidean algorithm in fundamental algorithms

used [this page](https://github.com/bbatsov/clojure-style-guide "clojure-style") as a guide for

--- chapters/fundamental_algorithms/euclidean_algorithm/code/clojure/euclidean_example.clj
+++ chapters/fundamental_algorithms/euclidean_algorithm/code/clojure/euclidean_example.clj
@@ -1,17 +1,18 @@
 (defn euclid-sub [a b]
   (loop [i (Math/abs a) j (Math/abs b)]
-	(if (= i j)
-	    i
-	  (if (> i j)
-	      (recur (- i j) j)
-	    (recur i (- j i))))))
+    (if (= i j)
+      i
+      (if (> i j)
+        (recur (- i j) j)
+        (recur i (- j i))))))
 (defn euclid-mod [a b]
   (loop [i (Math/abs a) j (Math/abs b)]
-	(if (zero? j)
-	    i
-	  (recur j (% i j)))))
+    (if (zero? j)
+      i
+      (recur j (% i j)))))

-(print (euclid-sub (* 64 67)
-		   (* 64 81))
-       (euclid-mod (* 128 12)
-		   (* 128 77)))
+(print
+ (euclid-sub (* 64 67)
+             (* 64 81))
+ (euclid-mod (* 128 12)
+             (* 128 77)))


allows for jetty to not use chunked encoding for http/1.1 requests (#1133)

--- waiter/integration/waiter/trailers_test.clj
+++ waiter/integration/waiter/trailers_test.clj
@@ -56,14 +56,13 @@
             (assert-response-status response http-200-ok)
             (is (= http-version (get body-json "protocol")) (str body-json))
             (when (= "http" backend-proto)
-              (is (= "chunked" (get-in body-json ["headers" "Transfer-Encoding"]))
-                  (str body-json))
-              (is (= "chunked" (get-in response [:headers "transfer-encoding"]))
-                  (-> response :headers str)))
-            (is (= {} (get body-json "trailers"))
-                (-> response :headers str))
-            (is (nil? (some-> response :trailers))
-                (-> response :headers str))))
+              ;; http/1.1 request/responses from Jetty may not always be chunked
+              (if-let [te-header (get-in body-json ["headers" "Transfer-Encoding"])]
+                (is (= "chunked" te-header) (str body-json))
+                (is (= (str request-length) (get-in body-json ["headers" "Content-Length"])) (str body-json)))
+              (is (= "chunked" (get-in response [:headers "transfer-encoding"])) (-> response :headers str)))
+            (is (= {} (get body-json "trailers")) (-> response :headers str))
+            (is (nil? (some-> response :trailers)) (-> response :headers str))))

         (let [request-trailer-delay-ms 100
               response-trailer-delay-ms 100]


clean up and improve performance of clojure version

--- cjmt/src/cjmt/core.clj
+++ cjmt/src/cjmt/core.clj
@@ -7,56 +7,82 @@
 (def ^:const NUM_RECORDS (* 50 1000 444))

 (definterface IMemTest
-  (^Long gtradeId []) (^Long gclientId []) (^Long gvenueId []) (^Long ginstrumentCode []) (^Long gprice [])
-  (^Long gquantity []) (^Character gside [])
-  (stradeId [^Long v]) (sclientId [^Long v]) (svenueId [^Long v]) (sinstrumentCode [^Long v]) (sprice [^Long v])
-  (squantity [^Long v]) (sside [^Character v]))
+  (^long gtradeId [])
+  (^long gclientId [])
+  (^long gvenueId [])
+  (^long ginstrumentCode [])
+  (^long gprice [])
+  (^long gquantity [])
+  (^char gside [])
+  (stradeId [^long v])
+  (sclientId [^long v])
+  (svenueId [^long v])
+  (sinstrumentCode [^long v])
+  (sprice [^long v])
+  (squantity [^long v])
+  (sside [^char v]))

-(deftype CJMemTest [^:unsynchronized-mutable ^Long tradeId ^:unsynchronized-mutable ^Long clientId ^:unsynchronized-mutable ^Long venueId
-                   ^:unsynchronized-mutable ^Long instrumentCode ^:unsynchronized-mutable ^Long price ^:unsynchronized-mutable ^Long quantity
-                   ^:unsynchronized-mutable ^Character side]
+(deftype CJMemTest [^:unsynchronized-mutable ^long tradeId
+                    ^:unsynchronized-mutable ^long clientId
+                    ^:unsynchronized-mutable ^long venueId
+                    ^:unsynchronized-mutable ^long instrumentCode
+                    ^:unsynchronized-mutable ^long price
+                    ^:unsynchronized-mutable ^long quantity
+                    ^:unsynchronized-mutable ^char side]
   IMemTest
-  (gtradeId [_] tradeId)(gclientId [_] clientId)(gvenueId [_] venueId)(ginstrumentCode [_] instrumentCode)
-  (gprice [_] price)(gquantity [_] quantity)(gside [_] side)
-  (stradeId [this v] (set! tradeId v)) (sclientId [this v] (set! clientId v)) (svenueId [this v] (set! venueId v))
-  (sinstrumentCode [this v] (set! instrumentCode v))
-  (sprice [this v] (set! price v)) (squantity [this v] (set! quantity v))(sside [this v] (set! side v)))
+  (gtradeId [_] tradeId)
+  (gclientId [_] clientId)
+  (gvenueId [_] venueId)
+  (ginstrumentCode [_] instrumentCode)
+  (gprice [_] price)
+  (gquantity [_] quantity)
+  (gside [_] side)
+  (stradeId [this v] (set! tradeId v) nil)
+  (sclientId [this v] (set! clientId v) nil)
+  (svenueId [this v] (set! venueId v) nil)
+  (sinstrumentCode [this v] (set! instrumentCode v) nil)
+  (sprice [this v] (set! price v) nil)
+  (squantity [this v] (set! quantity v) nil)
+  (sside [this v] (set! side v) nil))

-(def trades ^"[Ljava.lang.Object;" (make-array Object NUM_RECORDS))
+(def trades ^objects (make-array IMemTest NUM_RECORDS))

 (defn init-trades []
-    (dotimes [i NUM_RECORDS]
-      (let [trade-ref ^CJMemTest (aget ^"[Ljava.lang.Object;" trades i)]
-        (do (.stradeId trade-ref i)
-               (.sclientId trade-ref 1)
-               (.svenueId trade-ref 123)
-               (.sinstrumentCode trade-ref 321)
-               (.sprice trade-ref i)
-               (.squantity trade-ref i)
-               (if (odd? i)
-                   (.sside trade-ref \S)
-                   (.sside trade-ref \B))))))
+  (let [trades ^objects trades]
+    (loop [i 0]
+      (when (< i NUM_RECORDS)
+        (doto ^CJMemTest (aget trades i)
+          (.stradeId i)
+          (.sclientId i)
+          (.svenueId 123)
+          (.sinstrumentCode 321)
+          (.sprice i)
+          (.squantity i)
+          (.sside (if (zero? (bit-and i 1)) \S \B)))
+        (recur (inc i))))))

-(defn perform-run [^Long run-num]
-  (let  [start-t (System/currentTimeMillis)]
-    (do
-      (def buy-cost (long 0))
-      (def sell-cost (long 0))
-      (init-trades)
-      (dotimes [i NUM_RECORDS]
-        (let [trade-ref ^CJMemTest (aget ^"[Ljava.lang.Object;" trades i)]
-          (if (= (.gside trade-ref) \B)
-              (def buy-cost (+' buy-cost (* (.gprice trade-ref) (.gquantity trade-ref))))
-              (def sell-cost (+' sell-cost (* (.gprice trade-ref) (.gquantity trade-ref)))))))
-      ;(printf "Run %d had duration %.6f seconds\n" run-num (- (System/currentTimeMillis) start-t) )
-      (printf "Run %d had duration " run-num)
-      (print (- (System/currentTimeMillis) start-t))
-      (println "ms")
-      (printf "buycost = %d sellCost = %d \n" (biginteger buy-cost) (biginteger sell-cost) ))))
+(defn perform-run [^long run-num]
+  (let  [start-t (System/currentTimeMillis)
+         trades ^objects trades
+         tlen (alength trades)]
+    (init-trades)
+    (loop [idx 0
+           buy-cost (bigint 0)
+           sell-cost (bigint 0)]
+      (if (< idx tlen)
+        (let [trade-ref ^CJMemTest (aget trades idx)]
+          (if (= \B (.gside trade-ref))
+            (recur (inc idx) (+ buy-cost (* (.gprice trade-ref) (.gquantity trade-ref))) sell-cost)
+            (recur (inc idx) buy-cost (+ sell-cost (* (.gprice trade-ref) (.gquantity trade-ref))))))
+        (do
+          (printf "Run %d had duration " run-num)
+          (print (- (System/currentTimeMillis) start-t))
+          (println "ms")
+          (printf "buycost = %d sellCost = %d \n" (biginteger buy-cost) (biginteger sell-cost)))))))

 (defn run []
-  (dotimes [i NUM_RECORDS] (aset ^"[Ljava.lang.Object;" trades i (CJMemTest. 1 1 1 1 1 1 \a)))
-  (dotimes [i 5] (perform-run i)))
+  (dotimes [i NUM_RECORDS] (aset ^objects trades i (CJMemTest. 1 1 1 1 1 1 \a)))
+  (dotimes [i 5] (System/gc) (perform-run i)))

 (defn -main []
   (run))


fix cluster require of core.matrix.selection and corr mat example

--- src/polismath/math/clusters.clj
+++ src/polismath/math/clusters.clj
@@ -15,6 +15,7 @@
             [polismath.math.named-matrix :as nm]
             [clojure.core.matrix :as matrix]
             [clojure.core.matrix.stats :as matrix-stats]
+            [clojure.core.matrix.selection :as matrix.selection]
             [clojure.core.matrix.operators :refer :all]))

@@ -476,7 +477,7 @@
         matrix (:matrix corr-matrix)
         members (:members (first clusters))
         member-indices (mapv #(.indexOf comments %) members)]
-    {:matrix (clojure.core.matrix.selection/sel matrix member-indices member-indices)
+    {:matrix (matrix.selection/sel matrix member-indices member-indices)
      :comments members}))

@@ -552,20 +553,26 @@
            '[polismath.system :as system])
   (runner/run! system/base-system {:math-env :preprod})
   ;; Load the data for 15117 (zinvite 2ez5beswtc)
-  (def conv (conv-man/load-or-init (:conversation-manager runner/system) 15117))
+  ;(def focus-id 15117)
+  (def focus-zinvite "36jajfnhhn")
+  (def focus-id 15228)
+  (def conv (conv-man/load-or-init (:conversation-manager runner/system) focus-id))
+  ;conv
   (matrix/shape (nm/get-matrix (:rating-mat conv)))
   ;; Compute hclust on a cleaned, transposed rating matrix
   (def hclusters (hclust (cleaned-rating-mat-transpose conv)))
   (count (-> hclusters first :members))
   ;; Compute corr matrix
   (def corr-mat (correlation-matrix conv))
-  corr-mat
+  (keys corr-mat)
   (matrix/shape (:matrix corr-mat))
   (def corr-mat' (blockify-corr-matrix corr-mat hclusters))
+  (keys corr-mat')
+  (:comments corr-mat')
   ;; Spit this out
-  (spit-matrix "2ez5beswtc.corrmat.json" {:matrix corr-mat :comments (nm/colnames (:rating-mat conv))})
-  (spit-matrix "2ez5beswtc.corrmat-whclust.json" {:matrix corr-mat :comments (nm/colnames (:rating-mat conv))})
-  (spit-hclust "2ez5beswtc.hclust.json" {:matrix corr-mat :comments (nm/colnames (:rating-mat conv))})
+  (spit-matrix (str focus-zinvite ".corrmat.json") corr-mat)
+  (spit-matrix (str focus-zinvite ".corrmat-whclust.json") corr-mat')
+  (spit-hclust (str focus-zinvite ".hclust.json") hclusters)
   ;; All done
   :endcomment)


Track the no. of times a user has verified a code.

--- src/rsvp_backend/db/invitee.clj
+++ src/rsvp_backend/db/invitee.clj
@@ -35,13 +35,19 @@
   "Given the passcode, get the prefilled invitee details"
   [code]
   (let [entry (try (ddb/get-item client-opts db-name {:code code})
-                   (catch Exception e "AWS_ERROR"))]
+                   (catch Exception e "AWS_ERROR"))
+        times-verified (or (:times_verified entry) 0)]
     (cond
       (and (not (nil? entry))
            (= (:rsvp_state entry) "UNVERIFIED"))
       (do (try (ddb/update-item client-opts db-name {:code code}
-                                {:update-map {:rsvp_state [:put "VERIFIED"]}})
-               (catch Exception e "AWS_ERROR"))))
+                                {:update-map {:rsvp_state [:put "VERIFIED"]
+                                              :times_verified [:put 1]}})
+               (catch Exception e "AWS_ERROR")))
+      (not (nil? entry))
+      (try (ddb/update-item client-opts db-name {:code code}
+                            {:update-map {:times_verified [:put (+ 1 times-verified)]}})
+               (catch Exception e "AWS_ERROR")))
     entry))

 (defn update-invitee-metadata


New tests: test-job-name->url-not-NPE and test-job-name->url-NPE

--- test/clj_jenkins_api/jenkins_api_test.clj
+++ test/clj_jenkins_api/jenkins_api_test.clj
@@ -88,3 +88,16 @@
             "jenkins-url:8080/job/job%20name"        (job-name->url "jenkins-url:8080/" "job name")
             "jenkins-url:8080/job/long%20job%20name" (job-name->url "jenkins-url:8080/" "long job name"))))

+(deftest test-job-name->url-not-NPE
+    "Check that the clj-jenkins-api.jenkins-api/job-name->url definition exists."
+    (testing "if the clj-jenkins-api.jenkins-api/job-name->url definition exists."
+        (are [x y] (= x y)
+            "job/"  (job-name->url ""  "")
+            "job/"  (job-name->url nil ""))))
+
+(deftest test-job-name->url-NPE
+    "Check that the clj-jenkins-api.jenkins-api/job-name->url definition exists."
+    (testing "if the clj-jenkins-api.jenkins-api/job-name->url definition exists."
+        (is (thrown? NullPointerException (job-name->url ""  nil)))
+        (is (thrown? NullPointerException (job-name->url nil nil)))))
+


quick and easy type stats for search table

--- src/semtag_web/client/main.cljs
+++ src/semtag_web/client/main.cljs
@@ -95,13 +95,23 @@
                              :type "POST"
                              :data {:id id})))))

+(defn type-stats-string [tagged]
+  (format "%s (%s)"
+          (count (map :url tagged))
+          (->>
+           (map #(:type %) tagged)
+           (reduce #(assoc %1 %2 (inc (%1 %2 0))) {})
+           (sort-by #(second %1) (fn [a b] (> a b)))
+           (map #(format "%s %s" (second %1) (name (first %1))))
+           (clojure.string/join ", "))))
+
 (defn- create-search-table [parent data]
   (jq/remove ($ :#search_table))
   (jq/after (jq/find parent :h2)
             (generate-table "search_table" data
                             :fields [:type :name :url :desc :tags]
                             :row-partial view/tag-search-row
-                            :caption (str "Total: " (count data))))
+                            :caption (str "Total: " (type-stats-string data))))

   (make-table-editable)
   (add-sort-to parent))


Refer missing chan/alts!! fn in test

Refer missing chan/alts!! fn in test

--- test/onyx/plugin/input_benchmark_test.clj
+++ test/onyx/plugin/input_benchmark_test.clj
@@ -1,5 +1,5 @@
 (ns onyx.plugin.input-benchmark-test
-  (:require [clojure.core.async :refer [<!! go pipe timeout]]
+  (:require [clojure.core.async :refer [<!! go pipe timeout chan alts!!]]
             [clojure.core.async.lab :refer [spool]]
             [clojure.test :refer [deftest is]]
             [com.stuartsierra.component :as component]


(maint) clj-time.core/secs is deprecated

Move from secs to the non-deprecated seconds function:
https://github.com/clj-time/clj-time/blob/v0.9.0/src/clj_time/core.clj#L488-L496

--- test/puppetlabs/cthun/testutils/certs.clj
+++ test/puppetlabs/cthun/testutils/certs.clj
@@ -22,7 +22,7 @@
   [ca-ttl :- schema/Int]
   (let [now        (time/now)
         not-before (time/minus now (time/days 1))
-        not-after  (time/plus now (time/secs ca-ttl))]
+        not-after  (time/plus now (time/seconds ca-ttl))]
     {:not-before (.toDate not-before)
      :not-after  (.toDate not-after)}))

@@ -115,4 +115,4 @@

 (defn -main
   [& args]
-  (gen-cthun-certs "./test-resources/ssl"))+  (gen-cthun-certs "./test-resources/ssl"))


generators.clj: no longer an executable file


fixing >v3 macro overusage when things weren't gameobjects

--- core.clj
+++ core.clj
@@ -6,7 +6,7 @@
     ArcadiaState
     Hard.Helper))

-(declare position! >v3)
+(declare position!)

 (defn playing? [] (. Application isPlaying))

@@ -36,6 +36,9 @@

 (def  ->go arcadia.core/gobj)
 (defn ->transform [v] (arcadia.core/cmpt v UnityEngine.Transform))
+
+(defmacro >v3 [o]
+  `(.position (.transform ~o)))

 (defn X [o] (.x (>v3 o)))
 (defn Y [o] (.y (>v3 o)))
@@ -142,7 +145,7 @@

 (defn ^UnityEngine.Vector3
   local-position! [^UnityEngine.GameObject o pos]
-  (set! (.localPosition (.transform o)) (>v3 pos)) o)
+  (set! (.localPosition (.transform o)) pos) o)

 (defn ^UnityEngine.Vector3
   local-direction [^GameObject o ^UnityEngine.Vector3  v]
@@ -151,33 +154,33 @@
 (defn ^UnityEngine.Vector3
   transform-point [o v]
   (when-let [o (->go o)]
-    (.TransformPoint (.transform o) (>v3 v))))
+    (.TransformPoint (.transform o) v)))

 (defn ^UnityEngine.Vector3
   inverse-transform-point [o v]
   (when-let [o (->go o)]
-    (.InverseTransformPoint (.transform o) (>v3 v))))
+    (.InverseTransformPoint (.transform o) v)))

 (defn ^UnityEngine.Vector3
   inverse-transform-direction [o v]
   (when-let [o (->go o)]
-    (.InverseTransformDirection (.transform o) (>v3 v))))
+    (.InverseTransformDirection (.transform o) v)))

 (defn move-towards [v1 v2 step]
   (Vector3/MoveTowards v1 v2 step))

 (defn ^UnityEngine.Vector3 lerp [^UnityEngine.Vector3 v1 ^UnityEngine.Vector3 v2 ratio]
-  (Vector3/Lerp (>v3 v1) (>v3 v2) ratio))
+  (Vector3/Lerp v1 v2 ratio))

 (defn ^UnityEngine.GameObject local-scale [^UnityEngine.GameObject o]
   (when-let [o (->go o)] (.localScale (.transform o) )))

 (defn ^UnityEngine.GameObject local-scale! [^UnityEngine.GameObject o ^UnityEngine.Vector3 v]
-  (when-let [o (->go o)] (set! (.localScale (.transform o)) (>v3 v)) o))
+  (when-let [o (->go o)] (set! (.localScale (.transform o)) v) o))

 (defn rotate-around! [o point axis angle]
   (when-let [o (->go o)]
-  (. (.transform o) (RotateAround (>v3 point) (>v3 axis) angle))))
+  (. (.transform o) (RotateAround point axis angle))))

 (defn rotation [o]
   (when-let [o (->go o)] (.rotation (.transform o) )))
@@ -196,11 +199,11 @@
     (set! (.localRotation (.transform o)) rot)) o)

 (defn look-at!
-  ([a b] (.LookAt (->transform a) (>v3 b)))
-  ([a b c] (.LookAt (->transform a) (>v3 b) (>v3 c))))
+  ([a b] (.LookAt (->transform a) b))
+  ([a b c] (.LookAt (->transform a) b c)))

 (defn look-quat [a b]
-  (Quaternion/LookRotation  (>v3 (arcadia.linear/v3- (>v3 b) (>v3 a)))))
+  (Quaternion/LookRotation (arcadia.linear/v3- b (>v3 a))))

 (defn lerp-look! [^UnityEngine.GameObject a b ^double v]
   (let [^UnityEngine.Transform at (.transform a)
@@ -250,8 +253,6 @@

 ;MACROS
-(defmacro >v3 [o]
-  `(.position (.transform ~o)))

 (defmacro >v2 [o]
   `(UnityEngine.Vector2.


Join animation

Join animation

--- src/twentyfortyeight/logic.cljs
+++ src/twentyfortyeight/logic.cljs
@@ -40,7 +40,7 @@

 (defn- join-tiles
   [first-tile second-tile]
-  {:id (:id first-tile)
+  {:id (or (:id second-tile)(:id first-tile))
    :value (+ (:value first-tile) (:value second-tile))
    :position (or (:position second-tile) (:position first-tile))})


Fix warning

Fix warning

--- test/tick/alpha/api/dates_test.clj
+++ test/tick/alpha/api/dates_test.clj
@@ -1,7 +1,7 @@
 ;; Copyright © 2016-2018, JUXT LTD.

 (ns tick.alpha.api.dates-test
-  (:refer-clojure :exclude [dec < range <= min long int > extend - time / >= inc + max complement atom swap-vals! reset-vals! compare-and-set! reset! swap! second group-by])
+  (:refer-clojure :exclude [dec < range <= min long int > extend - time / >= inc + max complement atom swap-vals! reset-vals! compare-and-set! reset! swap! second group-by conj])
   (:require
    [clojure.spec.alpha :as s]
    [clojure.test :refer :all]


WIP.  Added dynamic templated tile input query to build-input-url

--- src/lcmap/clownfish/changes.clj
+++ src/lcmap/clownfish/changes.clj
@@ -6,6 +6,7 @@
             [clj-time.coerce :as tc]
             [clojure.tools.logging :as log]
             [clojure.string :as str]
+            [clostache.parser :as template]
             [compojure.core :refer :all]
             [langohr.exchange :as le]
             [langohr.basic :as lb]
@@ -89,16 +90,14 @@

 (def tile-spec {:tile_x 10 :tile_y 10 :shift_x 0 :shift_y 0})

+;;;  :tile_url can be templated using clostache syntax: {{target}}
+;;;; example: http://localhost:5678/landsat/tiles?x={{x}}&y={{y}}
 (defn build-input-url [{:keys [x y algorithm] :as data}]
-  (let [algorithm (:inputs_endpoint (get-algorithm data))
-        endpoint (strip (:inputs_endpoint algorithm))
-        ubids (slurp (str endpoint "/ubids" (:ubids_query algorithm)))]
-    (str endpoint
-         "/landsat/tiles"
-         "?x=" x
-         "&y=" y
-         "&acquired=*/*"
-         (map (str "&ubid=" %) ubids))))
+  "Constructs url to retrieve tiles for algorithm input."
+  (let [alg       (get-algorithm data)
+        ubids     (slurp (:ubid_query alg))
+        tiles_url (template/render (:tiles_url alg) data)]
+    (str/join tile_url #(map (str "&ubid=" %) (sort ubids)))))

 (defn snap [x y]
   (tile/snap x y tile-spec))


catch malformed column default json

catch malformed column default json

--- src/cljs/org/broadinstitute/firecloud_ui/page/workspace/data/tab.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/workspace/data/tab.cljs
@@ -71,7 +71,10 @@
             [EntityTable
              {:ref "entity-table"
               :workspace-id workspace-id
-              :column-defaults (utils/parse-json-string (get-in workspace [:workspace :workspace-attributes :workspace-column-defaults]))
+              :column-defaults (try
+                                 (utils/parse-json-string (get-in workspace [:workspace :workspace-attributes :workspace-column-defaults]))
+                                 (catch js/Object e
+                                   nil))
               :toolbar (fn [built-in]
                          [:div {}
                           [:div {:style {:float "left"}} built-in]


Changed the conds in utils to cases.

Changed the conds in utils to cases.

--- src/longshi/fressian/utils.cljs
+++ src/longshi/fressian/utils.cljs
@@ -32,14 +32,14 @@
            byte-size (cond (<= code 0x007f) 1 (> code 0x07ff) 3 :else 2)]
        (if (and (< i str-length) (<= (+ buf-pos byte-size) buf-length))
          (do
-           (cond
-             (== byte-size 1)
+           (case byte-size
+             1
              (aset string-buffer buf-pos code)
-             (== byte-size 2)
+             2
              (do
                  (aset string-buffer buf-pos (bit-or (bit-and (bit-shift-right code 6) 0x1f) 0xc0))
                  (aset string-buffer (inc buf-pos) (bit-or (bit-and (bit-shift-right code 0) 0x3f) 0x80)))
-             (== byte-size 3)
+             3
             (do
                 (aset string-buffer buf-pos (bit-or (bit-and (bit-shift-right code 12) 0x0f) 0xe0))
                 (aset string-buffer (inc buf-pos) (bit-or (bit-and (bit-shift-right code 6) 0x3f) 0x80))
@@ -87,18 +87,18 @@
       (if (< pos length)
         (let [ch (aget buffer pos)]
           (let [bsch (bit-shift-right ch 4)]
-            (cond
-              (<= 0 bsch 7)
+            (case bsch
+              (1 2 3 4 5 6 7)
               (do
                 (aset read-codes i ch)
                 (recur (inc i) (inc pos)))
-              (<= 12 bsch 13)
+              (12 13)
               (let [ch1 (aget buffer (inc pos))]
                 (do
                   (aset read-codes i
                     (bit-or (bit-and ch1 0x3f) (bit-shift-left (bit-and ch 0x1f) 6)))
                   (recur (inc i) (+ 2 pos))))
-              (== bsch 14)
+              14
               (let [ch1 (aget buffer (inc pos))
                     ch2 (aget buffer (+ 2 pos))]
                 (do
@@ -108,7 +108,6 @@
                       (bit-shift-left (bit-and ch1 0x3f) 6)
                       (bit-shift-left (bit-and ch 0x0f) 12)))
                   (recur (inc i) (+ 3 pos))))
-              :else
               (throw (js/Error. (str "Invalid UTF Character (" ch ")"))))))
         i)))


fixed bug in group handling

fixed bug in group handling

--- pigpen-cascading/src/main/clojure/pigpen/cascading.clj
+++ pigpen-cascading/src/main/clojure/pigpen/cascading.clj
@@ -78,7 +78,8 @@
         fields (cfields field-names)
         cogroup-opts (get-in flowdef [:cogroup-opts pipe])]
     (if-not (nil? cogroup-opts)
-      (let [key-separate-from-value (> (count (first (map :args code-defs))) (:num-streams cogroup-opts))
+      (let [key-separate-from-value (or (= udf :algebraic)
+                                        (> (count (first (map :args code-defs))) (:num-streams cogroup-opts)))
             buffer (case (:group-type cogroup-opts)
                      :group (GroupBuffer. inits funcs fields (:num-streams cogroup-opts)
                                           (:group-all cogroup-opts)
@@ -137,9 +138,10 @@
                                        (group-key-cfields keys join-nils)
                                        (cfields fields)
                                        joiner))
-        (add-val [:cogroup-opts] id {:group-id   id
-                                     :group-type :join
-                                     :all-args   (true? (:all-args opts))}))))
+        (add-val [:cogroup-opts] id {:group-id    id
+                                     :group-type  :join
+                                     :num-streams (count ancestors)
+                                     :all-args    (true? (:all-args opts))}))))

 (defmethod command->flowdef :projection-flat
   [{:keys [code alias pipe field-projections]} flowdef]


Ready to release 0.5.2 of bidi

Ready to release 0.5.2 of bidi

--- modules/bidi/project.clj
+++ modules/bidi/project.clj
@@ -1,6 +1,6 @@
 ;; Copyright © 2014 JUXT LTD.

-(defproject juxt.modular/bidi "0.5.2-SNAPSHOT"
+(defproject juxt.modular/bidi "0.5.2"
   :description "A modular extension that provides support for bidi routing"
   :url "https://github.com/juxt/modular/tree/master/modules/bidi"
   :license {:name "The MIT License"


fix typo

fix typo

--- src/metabase/api/annotation.clj
+++ src/metabase/api/annotation.clj
@@ -23,7 +23,7 @@

 (defannotation AnnotationType [symb value :nillable]
   (annotation:IsInteger symb value)
-  (checkp-contains? (set annotation-description annotation-general) symb value))
+  (checkp-contains? (set [annotation-description annotation-general]) symb value))

 (defendpoint GET "/" [org object_model object_id]


fix typo

fix typo

--- src/metabase/models/hydrate.clj
+++ src/metabase/models/hydrate.clj
@@ -55,7 +55,7 @@
   `hydrate` will do a batched `sel` if a corresponding key ending with `_id`
   is found in the objects being hydrated.

-  `defentity` threads resulting map through its forms using `->`, so define
+  `defentity` threads the resulting map through its forms using `->`, so define
   `:hydration-keys` with `assoc`:

     (defentity User


Version updated

Version updated

--- gift-desktop/project.clj
+++ gift-desktop/project.clj
@@ -1,4 +1,4 @@
-(defproject gift/gift-desktop "0.1.0-SNAPSHOT"
+(defproject gift/gift-desktop "0.1.0"
   :description "Create gif files (version for desktop platform)"
   :url "https://github.com/split-brain/gift"
   :license {:name "Eclipse Public License"


add comments and debugging

add comments and debugging

--- src/polismath/darwin/export.clj
+++ src/polismath/darwin/export.clj
@@ -502,11 +502,12 @@
       (clojure.string/replace ":" "")
       (Integer/parseInt)))

-;; Should be using the
+;; Should be using the conv-man to load the conversation if it's already there
 (defn load-conv
   [darwin & {:keys [zid zinvite] :as args}]
   (assert (utils/xor zid zinvite))
   (let [zid (or zid (postgres/get-zid-from-zinvite (:postgres darwin) zinvite))]
+    (log/debug "Loading conversation" zid)
     (->
       (mongo/load-conv (:mongo darwin) zid)
       ;; This should be ok here right?


check that ini-section arguments exist

check that ini-section arguments exist

--- src/brainbot/nozzle/main.clj
+++ src/brainbot/nozzle/main.clj
@@ -71,9 +71,18 @@
    "esconnect" esconnect/esconnect-run-section
    "manage" manage/manage-run-section})

+(defn ensure-sections-exist
+  [iniconfig sections]
+  (let [cfg-sections (set (keys iniconfig))
+        sections-set (set sections)
+        missing (clojure.set/difference sections-set cfg-sections)]
+    (when (seq missing)
+      (die (str "the following sections are missing in " (:source (meta iniconfig)) ": "
+                (clojure.string/join ", " missing))))))

 (defn run-all-sections
   [iniconfig sections]
+  (ensure-sections-exist iniconfig sections)
   (doseq [section sections]
     (let [type (get-in iniconfig [section "type"])
           run-section (type->run-section type)]


Removed orphan markup.clj file.

Removed orphan markup.clj file.

--- src/leiningen/new/cryogen/src/cryogen/markup.clj
+++ src/leiningen/new/cryogen/src/cryogen/markup.clj
@@ -1,33 +0,0 @@
-(ns cryogen.markup
-  (:require [markdown.core :refer [md-to-html-string]]
-            [clojure.string :as s]
-            [cryogen-core.markup :as m])
-  (:import org.asciidoctor.Asciidoctor$Factory
-           java.util.Collections))
-
-(defn- markdown []
-  (reify m/Markup
-    (dir [this] "md")
-    (ext [this] ".md")
-    (render-fn [this]
-      (fn [rdr]
-        (md-to-html-string
-         (->> (java.io.BufferedReader. rdr)
-              (line-seq)
-              (s/join "\n"))
-         :heading-anchors true)))))
-
-(defn- asciidoc []
-  (reify m/Markup
-    (dir [this] "asc")
-    (ext [this] ".asc")
-    (render-fn [this]
-      (fn [rdr]
-        (.convert (Asciidoctor$Factory/create)
-         (->> (java.io.BufferedReader. rdr)
-              (line-seq)
-              (s/join "\n"))
-         (Collections/emptyMap))))))
-
-(defn markups []
-  [(markdown) (asciidoc)])


Move tag

Move tag

--- src/reagent/impl/component.cljs
+++ src/reagent/impl/component.cljs
@@ -311,13 +311,13 @@
         get-initial-state (:getInitialState body)
         construct (:constructor body)
         cmp (fn [props context updater]
-              (this-as this
+              (this-as ^clj this
                 (.call react/Component this props context updater)
                 (when construct
                   (construct this props))
                 (when get-initial-state
                   (set! (.-state this) (get-initial-state this)))
-                (set! (.-cljsMountOrder ^clj this) (batch/next-mount-count))
+                (set! (.-cljsMountOrder this) (batch/next-mount-count))
                 this))]

     (gobj/extend (.-prototype cmp) (.-prototype react/Component) methods)


Fix build/project-name, for projects that don't have a project name in the DB

--- src/circle/backend/build.clj
+++ src/circle/backend/build.clj
@@ -14,7 +14,9 @@
   (:require [somnium.congomongo :as mongo])
   (:require [circle.util.mongo :as c-mongo])
   (:require [circle.sh :as sh])
-  (:use [clojure.tools.logging :only (log)]))
+  (:use [clojure.tools.logging :only (log)])
+  (:use [circle.util.string :only (non-empty?)])
+  (:require [circle.backend.github-url :as github-url]))

 (def build-coll :builds) ;; mongo collection for builds

@@ -85,8 +87,10 @@
     (insert! b)))

 (defn project-name [b]
-  {:pre [(-> @b :_project_id)]}
-  (-> @b :_project_id (project/get-by-id) :name))
+  {:pre [(-> @b :_project_id)]
+   :post [(non-empty? %)]}
+  (or (-> @b :_project_id (project/get-by-id) :name)
+      (-> @b :vcs_url (github-url/parse) :project)))

 (defn build [{:keys [build_num    ;; int
                      vcs_url


Core utils, added fallback db-spec for development

--- src/clj/salava/core/util.clj
+++ src/clj/salava/core/util.clj
@@ -19,18 +19,25 @@
            (java.net URLEncoder)
            (java.util Base64)))

+(defn get-datasource
+  "Get datasource in context or default db-spec for testing."
+  [ctx]
+  (if (:db ctx)
+    {:datasource (:db ctx)}
+    {:dbtype "mysql"
+     :dbname "salava"
+     :user "salava"
+     :password "salava"}))
+
 (defn get-db [ctx]
-  {:connection {:datasource (:db ctx)}})
-
-(defn get-datasource [ctx]
-  {:datasource (:db ctx)})
+  {:connection (get-datasource ctx)})

 (defn get-db-1 [ctx]
-  {:connection {:datasource (:db ctx)}
+  {:connection (get-datasource ctx)
    :result-set-fn first})

 (defn get-db-col [ctx kw]
-  {:connection {:datasource (:db ctx)}
+  {:connection (get-datasource ctx)
    :row-fn kw})

 (defn get-data-dir [ctx]


add google signin button to home page

add google signin button to home page

--- src/cljs/clj_money/core.cljs
+++ src/cljs/clj_money/core.cljs
@@ -28,7 +28,11 @@
 (defn home-page []
   [:div.jumbotron.mt-3
    [:h1.display-5 "clj-money"]
-   [:p "This is a double-entry accounting application that aims to be available anywhere."]])
+   [:p "This is a double-entry accounting application that aims to be available anywhere."]
+   [:a#login.btn.btn-light {:href "/auth/google/start"
+                              :title "Click here to sign in with a Google account"}
+    (html/google-g)
+    [:span "Sign in with Google"]]])

 (secretary/defroute "/" []
     (swap! app-state assoc :page (if @current-user


barf unwanted element from form

barf unwanted element from form

--- src/cljs/clj_money/data.cljs
+++ src/cljs/clj_money/data.cljs
@@ -28,8 +28,8 @@

 (defn update-entity
   ([entity success-fn error-fn]
-   (go (let [response (<! (http/patch (path :entities (:id entity) {:headers {"Content-Type" "application/json"
-                                                                              "Accept" "application/json"}})))]
+   (go (let [response (<! (http/patch (path :entities (:id entity)) {:headers {"Content-Type" "application/json"
+                                                                               "Accept" "application/json"}}))]
          (if (= 204 (:status response))
            (success-fn)
            (do


fixed organize refs

fixed organize refs

--- src/cljs/smgui/organize.cljs
+++ src/cljs/smgui/organize.cljs
@@ -60,14 +60,14 @@
   (reify
     om/IDidMount
     (did-mount [_]
-      (-> owner .-renode .-input .getDOMNode (.setAttribute "nwdirectory" "nwdirectory")))
+      (-> owner .-refs .-input .getDOMNode (.setAttribute "nwdirectory" "nwdirectory")))

     om/IRenderState
     (render-state [_ {k :path}]
       (dom/div nil
         (dom/div #js {:style #js {:cursor "pointer"}
                       :className "mh-20"
-                      :onClick #(-> owner .-renode .-input .getDOMNode .click)}
+                      :onClick #(-> owner .-refs .-input .getDOMNode .click)}
                  (get cursor k "Pick a directory"))
         (dom/input #js {:type "file"
                         :ref "input"


remove redundant test expectation

remove redundant test expectation

--- test/clj_money/trading_test.clj
+++ test/clj_money/trading_test.clj
@@ -128,8 +128,6 @@
         "The result contains the transaction associated with the purchase")
     (is (= expected-transaction actual-transaction)
         "The resulting transaction has the correct attributes")
-    (is (= 1 (-> result :transaction :lot-items count))
-        "The transaction contains a lot item")
     (is (empty? (-> result :transaction validation/error-messages))
         "The transaction is valid")
     (is (:lot result)


add tab section extraction code print

add tab section extraction code print

--- ohack/src/ohack/core.clj
+++ ohack/src/ohack/core.clj
@@ -163,3 +163,10 @@
 (def fast-car-html (slurp "http://tabs.ultimate-guitar.com/t/tracy_chapman/fast_car_ver8_tab.htm"))
 ;; verify we grabbed some html?
 (print (.substring fast-car-html 2000 3000))
+;; we're just going to extract the tab section by visual inspection...
+(print
+ (-> fast-car-html
+     (.split "Tabbed by")
+     second
+     (.split "hammer-on")
+     first))


Use a threadpool in the tree worker

Use a threadpool in the tree worker

--- src/cyanite_remover/core.clj
+++ src/cyanite_remover/core.clj
@@ -637,6 +637,7 @@
         (when-not @clog/print-log?
           (println title)
           (prog/init paths-count))
+        (dorun (cp/upmap tpool walk (t-get tree-impl [])))
         (walk [])
         (when-not @clog/print-log?
           (prog/done))


Minor

Minor

--- src/discuss/utils/views.cljs
+++ src/discuss/utils/views.cljs
@@ -26,8 +26,9 @@
 (defn safe-html
   "Creates DOM element with interpreted HTML."
   [string]
-  (dom/span #js {:className (lib/prefix-name "converted-bubbles")
-                 :dangerouslySetInnerHTML #js {:__html string}}))
+  (dom/span #js {:className               (lib/prefix-name "converted-bubbles")
+                 :dangerouslySetInnerHTML #js {:__html string}
+                 :key                     (lib/get-unique-key)}))

 (defn safe-space
   "Create a safed spacer."


Ignore .- prefixed files

Ignore .- prefixed files

This allows me to use dotfiles to "hold" logically empty examples
directories "open" in git so that the web example addition UI will
actually just work. Otherwise GH won't `mkdir -p` some involved path if
you try to add/edit it via the web UI.

--- src/grimoire/api/fs/read.clj
+++ src/grimoire/api/fs/read.clj
@@ -141,7 +141,8 @@
              :let        [v (t/thing->name (t/thing->version prior-thing))
                           h (impl/thing->handle config :examples prior-thing)]
              ex          (.listFiles h)
-             :when       (.isFile ex)]
+             :when       (.isFile ex)
+             :when       (not (.startsWith (.getName ex) "."))]
          (let [rhs (.toPath ex)
                p   (.relativize lhs rhs)]
            (-> thing


some sort try - failed

some sort try - failed

--- src/hackerrank/even_tree.clj
+++ src/hackerrank/even_tree.clj
@@ -99,3 +99,8 @@
 (cons (first t) (cons (cons 'a nil) nil))

 ; (sort [[3] 1 [2]])
+
+(sort  #(or (> (last %1) (last %2))
+             (and (= (last %1) (last %2))
+                  (< (first %1) (first %2))))
+       (shuffle '((3) 1 (2))))


Remove misleading comment

Remove misleading comment

--- src/io/aviso/twixt/utils.clj
+++ src/io/aviso/twixt/utils.clj
@@ -21,8 +21,6 @@
   "Merges any number of maps together, recursively. When merging values:
   - two maps are merged, recursively
   - two seqs are concatinated
-  - one map and one non-map is an error
-  - one seq and one non-seq is an error
   - otherwise, the 'right' value overwrites the 'left' value"
   [& maps]
   (apply merge-with merge-values maps))


Ready to play.

Ready to play.

--- src/kolmogorov_music/geb.clj
+++ src/kolmogorov_music/geb.clj
@@ -37,9 +37,9 @@
                   (phrase (repeat 32 1/2) (cycle [4 2 2 0 -1]))
                   (phrase (repeat 64 1/4) (cycle [4 2 5 4 5 4 7 7])))
         decoration (phrase (repeat 64 1/4) (cycle [7 8 9 11 7 6]))]
-    (->> ;(with bass double-canon)
+    (->> (with bass double-canon)
+         ;(with alt-bass twiddle decoration)
          ;(with riff)
-         ;(with alt-bass twiddle decoration)
          ;robot
          (times 2)
          (wherever (comp not :theme) :pitch (comp B minor))


add symbol-identical?

add symbol-identical?

--- src/main/cljs/cljs/core.cljs
+++ src/main/cljs/cljs/core.cljs
@@ -2910,9 +2910,17 @@
   [x y]
   (if (identical? x y)
     true
-    (if (and (keyword? x)
-             (keyword? y))
+    (if (and (keyword? x) (keyword? y))
       (identical? (.-fqn x) (.-fqn y))
+      false)))
+
+(defn ^boolean symbol-identical?
+  "Efficient test to determine that two symbol are identical."
+  [x y]
+  (if (identical? x y)
+    true
+    (if (and (symbol? x) (symbol? y))
+      (identical? (.-str x) (.-str y))
       false)))

 (defn namespace


[#3083] Add data-groups support for update/import-data-to-table

--- backend/src/akvo/lumen/lib/update.clj
+++ backend/src/akvo/lumen/lib/update.clj
@@ -5,6 +5,7 @@
             [akvo.lumen.lib :as lib]
             [akvo.lumen.lib.env :as env]
             [akvo.lumen.lib.transformation.engine :as engine]
+            [akvo.lumen.lib.import.data-groups :as import.data-groups]
             [akvo.lumen.util :as util]
             [clojure.java.jdbc :as jdbc]
             [clojure.set :as set]
@@ -12,6 +13,7 @@
             [clojure.data :as d]
             [akvo.lumen.db.dataset-version :as db.dataset-version]
             [clojure.tools.logging :as log]
+            [akvo.lumen.db.data-group :as db.data-group]
             [akvo.lumen.db.transformation :as db.transformation]
             [akvo.lumen.db.job-execution :as db.job-execution]
             [clojure.walk :as walk]))
@@ -180,6 +182,66 @@
                  :importer-columns (mapv coerce-column-fn importer-columns) :imported-dataset-columns imported-dataset-columns
                  :latest-dataset-version latest-dataset-version}))))))))

+(defn- import-data-to-table-2 [tenant-conn import-config dataset-id job-execution-id data-source-spec]
+  (jdbc/with-db-transaction [conn tenant-conn]
+    (let [environment (env/all conn)]
+      (with-open [importer (import/datagroups-importer (get data-source-spec "source")
+                                                       (assoc import-config :environment environment))]
+        (let [initial-dataset-version  (let [dsv (db.transformation/initial-dataset-version-2-to-update-by-dataset-id conn {:dataset-id dataset-id})]
+                                         (assoc dsv :columns (db.data-group/get-all-columns conn {:dataset-version-id (:id dsv)})))
+              latest-dataset-version (let [dsv (db.transformation/latest-dataset-version-2-by-dataset-id conn {:dataset-id dataset-id})]
+                                       (assoc dsv :columns (db.data-group/get-all-columns conn {:dataset-version-id (:id dsv)})))
+              imported-dataset-columns (vec (:columns initial-dataset-version))
+              importer-columns         (p/columns importer)
+              columns-used (columns-used-in-txs
+                            (import/importer-type (get data-source-spec "source"))
+                            initial-dataset-version
+                            latest-dataset-version)
+              imported-dataset-columns-checked (reduce (fn [c co]
+                                                         (if (contains? columns-used (get co "columnName"))
+                                                           (conj c co)
+                                                           c)) [] imported-dataset-columns)]
+          (if-let [compatible-errors (compatible-columns-error? imported-dataset-columns-checked
+                                                                importer-columns)]
+            (do
+              (failed-update conn job-execution-id
+                             (cond-> "Column mismatch"
+                               (seq (:missed-columns compatible-errors))
+                               (str ".\n Following columns are missed in new data version: " (:missed-columns compatible-errors))
+                               (seq (:wrong-types compatible-errors))
+                               (str ".\n Following columns have changed the column type in new data version: " (:wrong-types compatible-errors))))
+              {:success? false})
+            (let [{:keys [columns group-table-names]} (import.data-groups/adapt-columns importer-columns)]
+              (doseq [[groupId cols] (group-by :groupId columns)]
+                (postgres/create-dataset-table conn (get group-table-names groupId) cols))
+              (doseq [response (take import/rows-limit (p/records importer))]
+                (doseq [[groupId iterations] response]
+                  (let [table-name (get group-table-names groupId)]
+                    (jdbc/insert-multi! conn table-name (mapv postgres/coerce-to-sql iterations)))))
+              (doseq [[groupId cols] (group-by :groupId columns)]
+                (let [table-name (get group-table-names groupId)]
+                  (db.job-execution/clone-data-table conn {:from-table table-name
+                                                           :to-table (util/table-name-to-imported table-name)}
+                                                     {}
+                                                     {:transaction? false})))
+              (let [coerce-column-fn (fn [{:keys [title id type key multipleId multipleType groupName groupId] :as column}]
+                                       (cond-> {"type" type
+                                                "title" title
+                                                "columnName" id
+                                                "groupName" groupName
+                                                "groupId" groupId
+                                                "sort" nil
+                                                "direction" nil
+                                                "hidden" false}
+                                         key           (assoc "key" (boolean key))
+                                         multipleType (assoc "multipleType" multipleType)
+                                         multipleId   (assoc "multipleId" multipleId)))]
+                {:success? true
+                 :group-table-names group-table-names
+                 :importer-columns (mapv coerce-column-fn columns)
+                 :imported-dataset-columns imported-dataset-columns
+                 :latest-dataset-version latest-dataset-version}))))))))
+
 (defn update-dataset [tenant-conn caddisfly import-config error-tracker dataset-id data-source-id data-source-spec]
   (if-let [current-tx-job (db.transformation/pending-transformation-job-execution tenant-conn {:dataset-id dataset-id})]
     (lib/bad-request {:message "A running transformation still exists, please wait to update this dataset ..."})
@@ -189,22 +251,41 @@
                                                                         :dataset-id dataset-id})
      (future
        (try
-         (let [{:keys [table-name imported-table-name
-                       importer-columns imported-dataset-columns
-                       latest-dataset-version success?]}  (import-data-to-table tenant-conn
-                                                                                import-config
-                                                                                dataset-id
-                                                                                job-execution-id
-                                                                                data-source-spec)]
-           (when success?
-             (let [{:keys [columns transformations]} (engine/apply-dataset-transformations-on-table tenant-conn
-                                                                                caddisfly
-                                                                                dataset-id
-                                                                                (:transformations latest-dataset-version)
-                                                                                table-name
-                                                                                importer-columns
-                                                                                imported-dataset-columns)]
-               (successful-update tenant-conn job-execution-id dataset-id table-name imported-table-name latest-dataset-version columns transformations))))
+         (if (get (env/all tenant-conn) "data-groups")
+           (let [{:keys [group-table-names
+                         importer-columns imported-dataset-columns
+                         latest-dataset-version success?] :as foo} (import-data-to-table-2 tenant-conn
+                                                                                import-config
+                                                                                dataset-id
+                                                                                job-execution-id
+                                                                                data-source-spec)]
+             (throw  (ex-info "foo" foo))
+             #_(when success?
+               (let [{:keys [columns transformations]}
+                     (engine/apply-dataset-transformations-on-table-2 tenant-conn
+                                                                      caddisfly
+                                                                      dataset-id
+                                                                      (:transformations latest-dataset-version)
+                                                                      table-name
+                                                                      importer-columns
+                                                                      imported-dataset-columns)]
+                 (successful-update-2 tenant-conn job-execution-id dataset-id table-name imported-table-name latest-dataset-version columns transformations))))
+           (let [{:keys [table-name imported-table-name
+                         importer-columns imported-dataset-columns
+                         latest-dataset-version success?]}  (import-data-to-table tenant-conn
+                                                                                import-config
+                                                                                dataset-id
+                                                                                job-execution-id
+                                                                                data-source-spec)]
+             (when success?
+               (let [{:keys [columns transformations]} (engine/apply-dataset-transformations-on-table tenant-conn
+                                                                                caddisfly
+                                                                                dataset-id
+                                                                                (:transformations latest-dataset-version)
+                                                                                table-name
+                                                                                importer-columns
+                                                                                imported-dataset-columns)]
+                 (successful-update tenant-conn job-execution-id dataset-id table-name imported-table-name latest-dataset-version columns transformations)))))
          (catch Exception e
            (failed-update tenant-conn job-execution-id (.getMessage e))
            (p/track error-tracker e)


Show something that makes sense if there's no credit card.

--- src-cljs/frontend/components/org_settings.cljs
+++ src-cljs/frontend/components/org_settings.cljs
@@ -520,12 +520,19 @@
                   [:th "Card type"]
                   [:th "Card Number"]
                   [:th "Expiry"]]
-                 [:tbody
-                  [:tr
-                   [:td (:name card)]
-                   [:td (:type card)]
-                   [:td "xxxx-xxxx-xxxx-" (:last4 card)]
-                   [:td (gstring/format "%02d" (:exp_month card)) \/ (:exp_year card)]]]]]]
+                 (if (not (empty? card))
+                   [:tbody
+                    [:tr
+                     [:td (:name card)]
+                     [:td (:type card)]
+                     [:td "xxxx-xxxx-xxxx-" (:last4 card)]
+                     [:td (gstring/format "%02d" (:exp_month card)) \/ (:exp_year card)]]]
+                   [:tbody
+                    [:tr
+                     [:td "N/A"]
+                     [:td "N/A"]
+                     [:td "N/A"]
+                     [:td "N/A"]]])]]]
               [:div.row-fluid
                [:div.offset1.span7
                 [:form.form-horizontal


Backward state machine.

Backward state machine.

--- src/mash_commander/core.cljs
+++ src/mash_commander/core.cljs
@@ -8,51 +8,57 @@

 (enable-console-print!)

+(defonce app-state
+  (atom {:line {:state [:empty]
+                :letters [" " "!" "h" "s" "a" "m"]}}))
+
+(defn line []
+  (om/ref-cursor (:line (om/root-cursor app-state))))
+
 (defonce valid-words #{"hello" "world"})
 (defonce valid-letters (set (str/split "abcdefghijklmnopqrstuvwyz" "")))

 (defn recognize? [letters]
-  (let [last-word (last (str/split (str/join "" letters) " "))]
+  (let [last-word (str/join (reverse (take-while #(not= " " %) letters)))]
     (contains? valid-words last-word)))
-
-(defonce app-state
-  (atom {:line {:input-state-stack [:empty]
-                :letters ["m" "a" "s" "h" "!" " "]}}))
-
-(defn line []
-  (om/ref-cursor (:line (om/root-cursor app-state))))

 (defn handle-keydown [owner e]
   (let [key (.-key e)]
-    (om/transact! (om/observe owner (line))
-                  #(let [state (first (:input-state-stack %))
-                         new-state
-                         (cond
-                           ;; Typing a letter
-                           (contains? valid-letters key)
-                           (as-> % c
-                             (assoc c :letters (conj (:letters %) key))
-                             (if (recognize? (:letters c))
-                               (assoc c :input-state-stack (cons :typing (:input-state-stack %)))
-                               (assoc c :input-state-stack (cons :mashing (:input-state-stack %)))))
-                           ;; Pressing additional spaces
-                           (and (= " " key) (contains? #{:typing-space :mashing-space} state)) %
-                           ;; Pressing first space
-                           (= " " key)
-                           (as-> % c
-                             (assoc c :letters (conj (:letters %) key))
-                             (if (= :typing (first (:input-state-stack %)))
-                               (assoc c :input-state-stack (cons :typing-space (:input-state-stack %)))
-                               (assoc c :input-state-stack (cons :mashing-space (:input-state-stack %)))))
-                           :default %)]
-                     (print "state:" new-state)
-                     new-state))))
+    (om/transact!
+     (om/observe owner (line))
+     #(let [state (first (:state %))]
+        (cond
+          ;; Typing a letter
+          (contains? valid-letters key)
+          (as-> % c
+            (assoc c :letters (cons key (:letters %)))
+            (if (recognize? (:letters c))
+              (assoc c :state (cons :typing (:state %)))
+              (assoc c :state (cons :mashing (:state %)))))
+          ;; Ignore additional spaces
+          (and (= " " key) (contains? #{:typing-space :mashing-space} state)) %
+          ;; Pressing first space
+          (= " " key)
+          (as-> % c
+            (assoc c :letters (cons key (:letters %)))
+            (if (= :typing (first (:state %)))
+              (assoc c :state (cons :typing-space (:state %)))
+              (assoc c :state (cons :mashing-space (:state %)))))
+          ;; Ignore backspace on empty
+          (and (= "Backspace" key) (= :empty state)) %
+          ;; Backspace
+          (= "Backspace" key)
+          (as-> % c
+            (assoc c :state (rest (:state c)))
+            (assoc c :letters (rest (:letters c))))
+          ;; Ignore everything else
+          :default %)))))

 (defn line-view [cursor]
   (reify
     om/IRender
     (render [_]
-      (let [words (str/split (str/join "" (:letters cursor)) " ")]
+      (let [words (str/split (str/join (reverse (:letters cursor))) " ")]
         (apply dom/div nil
                (interleave
                 (map #(if (contains? valid-words %)


Changing Exception to Error makes a formula test pass. Guh.

--- src/midje/ideas/formulas.clj
+++ src/midje/ideas/formulas.clj
@@ -22,7 +22,7 @@
   (fn [new-val]
     (if (pos? new-val)
       true
-      (throw (Exception. (str "*num-trials* must be an integer 1 or greater. You tried to set it to: " new-val))))))
+      (throw (Error. (str "*num-trials* must be an integer 1 or greater. You tried to set it to: " new-val))))))

 (defn- formula-fact [docstring body]


first hacks on dropdown button

first hacks on dropdown button

--- src/om_bootstrap/button.cljs
+++ src/om_bootstrap/button.cljs
@@ -3,11 +3,13 @@
   (:require [om.core :as om]
             [om-bootstrap.types :as t]
             [om-bootstrap.util :as u]
+            [om-tools.core :refer-macros [defcomponentk]]
             [om-tools.dom :as d :include-macros true]
+            [om-tools.mixin :refer-macros [defmixin]]
             [schema.core :as s])
   (:require-macros [schema.macros :as sm]))

-;; ## Schema
+;; ## Basic Button

 (def Button
   (t/bootstrap
@@ -64,6 +66,8 @@
                                            :disabled (:disabled? bs)})
                      children))))

+;; ## Button Toolbar
+
 (sm/defn toolbar :- t/Component
   "Renders a button toolbar."
   [opts & children]
@@ -71,6 +75,8 @@
     (d/div {:role "toolbar"
             :class (d/class-set (t/bs-class-set bs))}
            children)))
+
+;; ## Button Group

 (sm/defn button-group :- t/Component
   "Renders the supplied children in a wrapping button-group div."
@@ -82,3 +88,101 @@
                         :btn-group-justified (:justified? bs)})]
     (d/div (u/merge-props props {:class (d/class-set classes)})
            children)))
+
+;; ## Dropdown Button
+
+(def DropdownButton
+  (t/bootstrap
+   {(s/optional-key :title) t/Renderable
+    (s/optional-key :href) s/Str
+    (s/optional-key :on-click) (sm/=> s/Any s/Any)
+    (s/optional-key :on-select) (sm/=> s/Any s/Any)
+    (s/optional-key :pull-right?) s/Bool
+    (s/optional-key :dropup?) s/Bool
+    (s/optional-key :nav-item?) s/Bool}))
+
+(defn render-nav-item [props open? children]
+  (let [classes {:dropdown true
+                 :open open?
+                 :dropup (:dropup? props)}]
+    (d/li {:class (d/class-set classes)}
+          children)))
+
+(defn render-button-group [props open? children]
+  (let [group-classes {:open open?
+                       :dropup (:dropup? props)}]
+    (button-group {:bs-size (:bs-size props)
+                   :class (d/class-set group-classes)}
+                  children)))
+
+#_
+(defmixin dropdown-mixin
+  (setDropdownState [_ new-state on-state-change-complete]))
+
+
+(def DropdownMenu
+  (t/bootstrap
+   {(s/optional-key :pull-right?) s/Bool
+    (s/optional-key :on-select) (sm/=> s/Any s/Any)}))
+
+(sm/defn dropdown-menu
+  [opts :- DropdownMenu & children]
+  (let [[bs props] (t/separate DropdownMenu opts)
+        classes {:dropdown-menu true
+                 :dropdown-menu-right (:pull-right? bs)}]
+    (d/ul (u/merge-props props {:class (d/class-set classes)
+                                :role "menu"})
+          (if-let [on-select (:on-select bs)]
+            (map #(u/clone-with-props % {:on-select on-select}) children)
+            children))))
+
+(defcomponentk dropdown-button* [owner]
+  (render
+   [_]
+   (let [open? true
+         {:keys [opts children]} (om/get-props owner)
+         [bs props] (t/separate DropdownButton opts {:href "#"})
+         set-dropdown (aget owner "setDropdownState")
+         render-fn (partial (if (:nav-item? bs)
+                              render-button-group
+                              render-nav-item)
+                            bs open?)]
+     (render-fn
+      [(button
+        (u/merge-props props
+                       {:ref "dropdownButton"
+                        :class "dropdown-toggle"
+                        :key 0
+                        :nav-dropdown? (:nav-item? bs)
+                        ;; Why are these here?
+                        :nav-item? nil
+                        :title nil
+                        :pull-right? nil
+                        :dropup? nil
+                        :on-click (fn [e]
+                                    (.preventDefault e)
+                                    (set-dropdown (not open?)))})
+        (:title bs) " " (d/span {:class "caret"}))
+       (dropdown-menu
+        {:ref "menu"
+         :aria-labelledby (:id props)
+         :pull-right? (:pull-right? bs)
+         :key 1}
+        (map
+         #(u/clone-with-props
+           % (fn [props]
+               (let [handle (when (or (:on-select (:opts props))
+                                      (:on-select bs))
+                              (fn [key]
+                                (if-let [os (:on-select bs)]
+                                  (os key)
+                                  (set-dropdown false))))]
+                 (update-in props [:opts]
+                            u/merge-props
+                            {:on-select handle}))))
+         children))]))))
+
+(sm/defn dropdown-button
+  [opts :- DropdownButton & children]
+  (->dropdown-button* {:opts opts
+                       :children children}))


Only deref once in cond block.

Only deref once in cond block.

--- src/onyx/messaging/aeron.clj
+++ src/onyx/messaging/aeron.clj
@@ -127,22 +127,23 @@
   (let [msg-type (protocol/read-message-type buffer offset)
         offset (inc ^long offset)
         peer-id (protocol/read-vpeer-id buffer offset)
-        offset (unchecked-add offset protocol/short-size)]
+        offset (unchecked-add offset protocol/short-size)
+        v-peers @virtual-peers]
     (cond (= msg-type protocol/ack-msg-id)
           (let [ack (protocol/read-acker-message buffer offset)]
-            (when-let [acking-ch (pm/peer-channels @virtual-peers peer-id)]
+            (when-let [acking-ch (pm/peer-channels v-peers peer-id)]
               (>!! acking-ch ack)))

           (= msg-type protocol/batched-ack-msg-id)
           (let [acks (protocol/read-acker-messages buffer offset)]
-            (when-let [acking-ch (pm/peer-channels @virtual-peers peer-id)]
+            (when-let [acking-ch (pm/peer-channels v-peers peer-id)]
               (run! (fn [ack]
                       (>!! acking-ch ack))
                     acks)))

           (= msg-type protocol/messages-msg-id)
           (let [segments (protocol/read-messages-buf decompress-f buffer offset)]
-            (when-let [chs (pm/peer-channels @virtual-peers peer-id)]
+            (when-let [chs (pm/peer-channels v-peers peer-id)]
               (let [inbound-ch (:inbound-ch chs)]
                 (run! (fn [segment]
                         (>!! inbound-ch segment))
@@ -150,12 +151,12 @@

           (= msg-type protocol/completion-msg-id)
           (let [completion-id (protocol/read-completion buffer offset)]
-            (when-let [chs (pm/peer-channels @virtual-peers peer-id)]
+            (when-let [chs (pm/peer-channels v-peers peer-id)]
               (>!! (:release-ch chs) completion-id)))

           (= msg-type protocol/retry-msg-id)
           (let [retry-id (protocol/read-retry buffer offset)]
-            (when-let [chs (pm/peer-channels @virtual-peers peer-id)]
+            (when-let [chs (pm/peer-channels v-peers peer-id)]
               (>!! (:retry-ch chs) retry-id))))))

 (defn start-subscriber! [bind-addr port stream-id virtual-peers decompress-f idle-strategy]


Add some more chords

Add some more chords


fix missing space

fix missing space

--- src/overtone/studio/midi.clj
+++ src/overtone/studio/midi.clj
@@ -346,7 +346,7 @@

 (defn midi-note-on
   "Send a MIDI note on msg to the receiver. See connected-midi-receivers
-   for a full listof available receivers."
+   for a full list of available receivers."
   ([rcv note-num vel]
      (midi/midi-note-on rcv note-num vel))
   ([rcv note-num vel channel]


RS & AB | 15 | Delete print statements

RS & AB | 15 | Delete print statements

--- test/stonecutter/integration/kerodon_helpers.clj
+++ test/stonecutter/integration/kerodon_helpers.clj
@@ -29,9 +29,6 @@
   state)

 (defn selector-includes-content [state selector content]
-  (prn "STATE" state)
-  (prn "SELECTOR" selector)
-  (prn "CONTENT" (-> state :enlive (html/select selector) first html/text))
   (fact {:midje/name "Check if element contains string"}
         (-> state :enlive (html/select selector) first html/text) => (contains content))
   state)


Comments

Comments

--- src/angelic/search/implicit/dash_astar_opt.clj
+++ src/angelic/search/implicit/dash_astar_opt.clj
@@ -57,7 +57,7 @@
 ;; TODO: pseudo-solve
 ;; TODO: smarter summary updates (i.e., pass child)
 ;; TODO: enforce consistency across the board.
-;; TODO: Fix lazy updates.
+;; Note: regular lazy seems impossible, need at least some pseudo...
 ;;    Top-down bounds render these untenable, since an apparent decrease may be an increase? (See hard-dm 3-3)
 ;;    I.e., live decrease -50 to -49, now blocked sibling becomes best; above is -50 TDB;

@@ -65,6 +65,14 @@
 ;; TODO: actually, top-down bounds break a lot of things -- ?
 ;;   I.e., if we have TDB, blocked status can hide behind unblocked, expand things needlessly.
 ;;   How can we fix this?
+;;   ;; (This includes subsumption parents, as well).
+;;   One could try to build top-down bounding into all summaries ... but
+;;   it may actually be unfixable, in the presence of sums
+;;    (keeping bounds across sums means downwards updates with every up...)
+
+;; Note: with good descriptions, subsumption/TDB has two purposes?
+;;  1.  Give stubs a bound before evaluated.
+;;  2.  Account for necessary inconsistency with implicit descriptions.

 ;;;;; SP caching
 ;; TODO: tail (i.e., pair) caching? -- Only help for >2 len refs...


Remove debug messages

Remove debug messages

--- src/cljs/chocolatier/engine/components/collidable.cljs
+++ src/cljs/chocolatier/engine/components/collidable.cljs
@@ -75,6 +75,5 @@
         ;; empty and must have a falsey value
         colliding? (and (every? boolean collisions) (seq collisions))]
     (if colliding?
-      (do (log/debug "Colliding!!!")
-          [component-state [[:collision entity-id {:colliding? true}]]])
+      [component-state [[:collision entity-id {:colliding? true}]]]
       component-state)))


Clean up some dependency issues

Clean up some dependency issues

--- lein/profiles.clj
+++ lein/profiles.clj
@@ -1,11 +1,8 @@
 ;; TODO:
 ;; Have a :plugins vector.
 ;; Add [lein-outdated "1.0.0"] to it
-;; Q: Does that make any sense at all?
-;; Hasn't it been superseded by lein-ancient?
 {:user {:aliases {"slamhound" ["run" "-m" "slam.hound"]}  ; Q: Will I ever find occasion to actually use this?
-        :dependencies [[alembic "0.3.2"]   ; Q: what's this for?
-                       #_[clj-ns-browser "1.3.1" :exclusions [hiccup]]
+        :dependencies [[alembic "0.3.2"]   ; Q: what's this really for?
                        ;; We inherit this next through vinyasa.
                        ;; Shouldn't need to declare it
                        ;; Actually, this doesn't make sense in here. Its entire purpose
@@ -16,7 +13,8 @@
                        ;; (I'm pretty sure it doesn't, because my general profiles.clj
                        ;; doesn't have this)
                        #_[im.chit/hara "2.1.11"]
-                       ;; TODO: Replace this with whatever replaced it
+                       ;; This should probably go away
+                       ;; Q: Did hara replace this too?
                        [im.chit/vinyasa "0.3.4" :exclusions [org.codehaus.plexus/plexus-utils]]
                        [io.aviso/pretty "0.1.20"]
                        [leiningen #= (leiningen.core.main/leiningen-version)  :exclusions [cheshire
@@ -31,23 +29,19 @@
                                                                                org.apache.maven.wagon/wagon-provider-api
                                                                                org.clojure/tools.cli
                                                                                org.clojure/tools.reader
-                                                                                ;;org.codehaus.plexus/plexus-utils
                                                                                org.jsoup/jsoup
                                                                                potemkin]]
                        ;; How many of any of the rest of these do I actually use?
                        [nrepl-inspect "0.3.0"]
-                       [org.codehaus.plexus/plexus-utils "3.0"]
-                       [org.clojure/java.classpath "0.2.2"]
+                       [org.codehaus.plexus/plexus-utils "3.0.17"]
                        [org.clojure/tools.namespace "0.2.10"]
                        ;; I know I have a lot of projects that transitively rely on this, but they really shouldn't
                        [org.clojure/tools.nrepl "0.2.12" :exclusions [org.clojure/clojure]]
                        [pjstadig/humane-test-output "0.7.0"]
                        ;; Q: Is there any point to this next one?
                        [ritz/ritz-nrepl-middleware "0.7.0"]
-                       [slamhound "1.5.5"]
-                       [spyscope "0.1.5" :exclusions [clj-time]]]
-        :injections [(require 'spyscope.core)
-                     (require '[vinyasa.inject :as inject])
+                       [slamhound "1.5.5"]]
+        :injections [(require '[vinyasa.inject :as inject])
                      ;; TODO: call install-pretty-exception
                      (require 'io.aviso.repl)
                      (inject/in
@@ -75,13 +69,18 @@
                      (require 'pjstadig.humane-test-output)
                      (pjstadig.humane-test-output/activate!)]
         ;;:local-repo "repo"
-        :plugins [[cider/cider-nrepl "0.10.1" :exclusions [org.clojure/java.classpath]]
-                  [com.jakemccrary/lein-test-refresh "0.9.0"]
+        :plugins [[cider/cider-nrepl "0.10.2" :exclusions [org.clojure/java.classpath]]
+                  [com.jakemccrary/lein-test-refresh "0.13.0"]
                   [jonase/eastwood "0.2.2" :exclusions [org.clojure/clojure]]
-                  [lein-ancient "0.6.8" :exclusions [cheshire common-codec commons-codec org.clojure/clojure org.clojure/tools.reader slingshot]]
+                  [lein-ancient "0.6.8" :exclusions [cheshire
+                                                     common-codec
+                                                     commons-codec
+                                                     org.clojure/clojure
+                                                     org.clojure/tools.reader
+                                                     slingshot]]
                   ;; This next one's super useful, but its dependencies are out of date
                   ;; TODO: Update!
-                  #_[lein-kibit "0.0.8"]
+                  [lein-kibit "0.1.2"]
                   [lein-pprint "1.1.1"]
                   [mvxcvi/whidbey "0.6.0"]]
         :repl-options {:nrepl-middleware
@@ -95,4 +94,5 @@
                   :extend-notation true
                   :print-meta true
                   :color-scheme {}
-                  :print-color true}}}
+                  :print-color true}}
+  :repl {:plugins [[cider/cider-nrepl "0.10.1" :exclusions [org.clojure/java.classpath]]]}}


Cosmetics

Cosmetics

--- src/clojure/clojurewerkz/cassaforte/client.clj
+++ src/clojure/clojurewerkz/cassaforte/client.clj
@@ -286,7 +286,7 @@
                                                         args
                                                         (cons *default-session* args))
         ^Query statement (if prepared
-                           (if (coll? query )
+                           (if (coll? query)
                              (build-statement (prepare session (first query))
                                               (second query))
                              (throw (Exception. "Query is meant to be executed as prepared, but no values were supplied.")))


Pass the bookmarked-at value to the client as a flag for bookmark status.

--- src/oc/storage/representations/entry.clj
+++ src/oc/storage/representations/entry.clj
@@ -25,7 +25,7 @@
                            :team-id :author :publisher :published-at
                            :video-id :video-processed :video-image :video-duration
                            :created-at :updated-at :revision-id :follow-ups
-                           :new-at :new-comments-count :bookmarked])
+                           :new-at :new-comments-count :bookmarked-at])

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

@@ -191,7 +191,7 @@
         board-access (:access board)
         draft? (= :draft (keyword (:status entry)))
         entry-with-comments (assoc entry :interactions comments)
-        bookmarked? ((set (:bookmarks entry)) user-id)
+        bookmark (some #(when (= (:user-id %) user-id) %) (:bookmarks entry))
         enrich-entry? (and (not draft?)
                            user-id)
         entry-read (when enrich-entry?
@@ -199,7 +199,7 @@
         full-entry (merge {:board-slug board-slug
                            :board-access board-access
                            :board-name (:name board)
-                           :bookmarked (boolean bookmarked?)
+                           :bookmarked-at (:bookmarked-at bookmark)
                            :new-comments-count (when enrich-entry?
                                                  (if entry-read
                                                    (new-comments-count entry-with-comments user-id entry-read)
@@ -214,7 +214,7 @@
                         []
                         (take config/inline-comment-count (reverse (sort-by :created-at comments))))
         bookmarks-links (when (not= access-level :public)
-                          (if bookmarked?
+                          (if bookmark
                             (remove-bookmark-link org-slug board-slug entry-uuid)
                             (add-bookmark-link org-slug board-slug entry-uuid)))
         links (if secure-access?


need to filter tags on search results

need to filter tags on search results

--- src/chat/server/sync.clj
+++ src/chat/server/sync.clj
@@ -121,8 +121,10 @@
 (defmethod event-msg-handler :chat/search
   [{:keys [event id ?data ring-req ?reply-fn send-fn] :as ev-msg}]
   (when-let [user-id (get-in ring-req [:session :user-id])]
-    (let [threads (db/with-conn (->> (db/search-threads-as user-id ?data)
-                                     (map db/get-thread)
+    (let [user-tags (db/with-conn (db/get-user-visible-tag-ids user-id))
+          filter-tags (fn [t] (update-in t [:tag-ids] (partial filter user-tags)))
+          threads (db/with-conn (->> (db/search-threads-as user-id ?data)
+                                     (map (comp filter-tags db/get-thread))
                                      doall))]
       (when ?reply-fn
         (?reply-fn {:threads threads})))))


limit message length server-side

limit message length server-side

--- src/chat/server/sync.clj
+++ src/chat/server/sync.clj
@@ -109,7 +109,9 @@
   [{:as ev-msg :keys [event id ?data ring-req ?reply-fn send-fn]}]
   (when-let [user-id (get-in ring-req [:session :user-id])]
     (when (user-can-message? user-id ?data)
-      (do (db/with-conn (db/create-message! (assoc ?data :created-at (java.util.Date.))))
+      (do (db/with-conn (db/create-message! (-> ?data
+                                                (update-in [:content] #(apply str (take 5000 %)))
+                                                (assoc :created-at (java.util.Date.)))))
         (broadcast-thread (?data :thread-id) [])))))

 (defmethod event-msg-handler :user/subscribe-to-tag


yeah, I guess that's all of them

yeah, I guess that's all of them

--- src/clj/libsearch/db.clj
+++ src/clj/libsearch/db.clj
@@ -120,10 +120,12 @@
   [[(list '.startsWith '?libname (str val "/"))]])

 (defn watchers [f val]
-  [['?repo :repo/watchers-count '?watchers] [(list f '?watchers val)]])
+  [['?repo :repo/watchers-count '?watchers]
+   [(list f '?watchers val)]])

 (defn forks [f val]
-  [['?repo :repo/forks-count '?forks] [(list f '?forks val)]])
+  [['?repo :repo/forks-count '?forks]
+   [(list f '?forks val)]])

 ;; these date ones aren't very good yet... I want to be able to
 ;; pass the comparison fn into it and I don't know how to reference


ignore

ignore

--- src/cljc/seria/util.cljc
+++ src/cljc/seria/util.cljc
@@ -73,7 +73,7 @@
            {:index        index
             :symbol       (if tuple?
                             (postfix-gensym value (str index))
-                            (name index))
+                            (gensym (name index)))
             :inner-schema (inner-schemas index)
             :inner-value  (if tuple?
                             `(~value ~index)


bigger map

bigger map

--- src/cljs/mpd/assets.cljs
+++ src/cljs/mpd/assets.cljs
@@ -32,7 +32,7 @@
   (puke_sprite "images/crosshair.png" 1.0 false))

 (def background_tiling_sprite
-  (let [bg (PIXI.extras.TilingSprite.fromImage "images/floor.png" 5000 5000)]
+  (let [bg (PIXI.extras.TilingSprite.fromImage "images/floor.png" 10000 10000)]
     (aset bg "scale" (js-obj "x" 0.5 "y" 0.5))
     (aset bg "anchor" (js-obj "x" 0.5 "y" 0.5))
     bg))


pixelperfection

pixelperfection

--- src/cljs/mpd/player.cljs
+++ src/cljs/mpd/player.cljs
@@ -49,8 +49,8 @@
 ; FIRE

 (defn make-bullet [player]
-  {:x (+ (:x player) (* (Math/cos (:rotation player)) 80))
-   :y (+ (:y player) (* (Math/sin (:rotation player)) 80))
+  {:x (+ (:x player) (* (Math/cos (+ 0.17 (:rotation player))) 80))
+   :y (+ (:y player) (* (Math/sin (+ 0.17 (:rotation player))) 80))
    :angle (:rotation player)
    :speed 10
    :distance 100


Use into instead of vec and concat

Use into instead of vec and concat

--- src/cljx/cats/types.cljx
+++ src/cljx/cats/types.cljx
@@ -140,7 +140,6 @@
 ;; Clojure types
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-
 #+clj
 (extend-type clojure.lang.PersistentVector
   proto/Monad
@@ -149,7 +148,7 @@

   proto/MonadPlus
   (mzero [_] [])
-  (mplus [mv mv'] (vec (concat mv mv')))
+  (mplus [mv mv'] (into mv mv'))

   proto/Functor
   (fmap [self f] (vec (map f self)))


Trim whitespace from pgp key if a pgp key is present

--- src/clojars/web/user.clj
+++ src/clojars/web/user.clj
@@ -95,15 +95,16 @@
                        (submit-button "Update")))))

 (defn update-profile [account {:keys [email password confirm ssh-key pgp-key]}]
-  (if-let [errors (apply validate {:email email
-                                   :username account
-                                   :password password
-                                   :ssh-key ssh-key
-                                   :pgp-key pgp-key}
-                         (update-user-validations confirm))]
-    (profile-form account (apply concat (vals  errors)))
-    (do (update-user account email account password ssh-key pgp-key)
-        (redirect "/profile"))))
+  (let [pgp-key (and pgp-key (.trim pgp-key))]
+    (if-let [errors (apply validate {:email email
+                                     :username account
+                                     :password password
+                                     :ssh-key ssh-key
+                                     :pgp-key pgp-key}
+                           (update-user-validations confirm))]
+      (profile-form account (apply concat (vals  errors)))
+      (do (update-user account email account password ssh-key pgp-key)
+          (redirect "/profile")))))

 (defn show-user [account user]
   (html-doc account (h (user :user))


(PDB-4636) services: defer db pool inits until needed

Particularly so that we don't have to worry about attempting
migration checks until after the db has ben initialized.

--- src/puppetlabs/puppetdb/cli/services.clj
+++ src/puppetlabs/puppetdb/cli/services.clj
@@ -538,83 +538,83 @@
         {:keys [pretty-print max-enqueued]} developer
         {:keys [gc-interval node-purge-ttl schema-check-interval]} database
         {:keys [disable-update-checking]} puppetdb
-        {:keys [cmd-event-mult cmd-event-ch]} context
-
-        write-db (jdbc/pooled-datasource (assoc database
-                                                :pool-name "PDBWritePool"
-                                                :expected-schema desired-schema-version)
-                                         database-metrics-registry)
-        read-db (jdbc/pooled-datasource (assoc read-database
-                                               :read-only? true
-                                               :pool-name "PDBReadPool"
-                                               :expected-schema desired-schema-version)
-                                        database-metrics-registry)]
+        {:keys [cmd-event-mult cmd-event-ch]} context]

     (when-let [v (version/version)]
       (log/info (trs "PuppetDB version {0}" v)))

     (init-with-db database config)

-    (let [population-registry (get-in metrics/metrics-registries [:population :registry])]
-      (pop/initialize-population-metrics! population-registry read-db))
-
-    ;; Error handling here?
-    (let [stockdir (conf/stockpile-dir config)
-          command-chan (async/chan
-                         (queue/sorted-command-buffer
-                          max-enqueued
-                          (fn [cmd ver] (cmd/update-counter! :invalidated cmd ver inc!))
-                          (fn [cmd ver] (cmd/update-counter! :ignored cmd ver inc!))))
-          emit-cmd-events? (or (conf/pe? config) emit-cmd-events?)
-          maybe-send-cmd-event! (partial maybe-send-cmd-event! emit-cmd-events? cmd-event-ch)
-          [q load-messages] (queue/create-or-open-stockpile (conf/stockpile-dir config)
-                                                            maybe-send-cmd-event!
-                                                            cmd-event-ch)
-          globals {:scf-read-db read-db
-                   :scf-write-db write-db
-                   :pretty-print pretty-print
-                   :q q
-                   :dlo (dlo/initialize (get-path stockdir "discard")
-                                        (get-in metrics-registries
-                                                [:dlo :registry]))
-                   :node-purge-ttl node-purge-ttl
-                   :command-chan command-chan
-                   :cmd-event-mult cmd-event-mult
-                   :maybe-send-cmd-event! maybe-send-cmd-event!}
-          clean-lock (ReentrantLock.)
-          command-loader (when load-messages
-                           (future
-                             (load-messages command-chan cmd/inc-cmd-depth)))]
-
-      ;; send the queue-loaded cmd-event if the command-loader didn't
-      (when-not command-loader
-        (async/>!! cmd-event-ch {:kind ::queue/queue-loaded}))
-
-      ;; Pretty much this helper just knows our job-pool and gc-interval
-      (let [job-pool (mk-pool)
-            gc-interval-millis (to-millis gc-interval)]
-        (when-not disable-update-checking
-          (maybe-check-for-updates config read-db job-pool))
-        (when (pos? schema-check-interval)
-          (interspaced schema-check-interval
-                       #(check-schema-version desired-schema-version
-                                              context
-                                              (:scf-read-db globals)
-                                              service
-                                              shutdown-on-error)
-                       job-pool))
-        (when (pos? gc-interval-millis)
-          (let [request (db-config->clean-request database)]
-            (interspaced gc-interval-millis
-                         #(coordinate-gc-with-shutdown write-db clean-lock
-                                                       database request
-                                                       (:stop-status context))
-                         job-pool)))
-        (assoc context
-               :job-pool job-pool
-               :shared-globals globals
-               :clean-lock clean-lock
-               :command-loader command-loader)))))
+    (let [read-db (jdbc/pooled-datasource (assoc read-database
+                                                 :read-only? true
+                                                 :pool-name "PDBReadPool"
+                                                 :expected-schema desired-schema-version)
+                                          database-metrics-registry)]
+
+      (let [population-registry (get-in metrics/metrics-registries [:population :registry])]
+        (pop/initialize-population-metrics! population-registry read-db))
+
+      ;; Error handling here?
+      (let [stockdir (conf/stockpile-dir config)
+            command-chan (async/chan
+                          (queue/sorted-command-buffer
+                           max-enqueued
+                           (fn [cmd ver] (cmd/update-counter! :invalidated cmd ver inc!))
+                           (fn [cmd ver] (cmd/update-counter! :ignored cmd ver inc!))))
+            emit-cmd-events? (or (conf/pe? config) emit-cmd-events?)
+            maybe-send-cmd-event! (partial maybe-send-cmd-event! emit-cmd-events? cmd-event-ch)
+            [q load-messages] (queue/create-or-open-stockpile (conf/stockpile-dir config)
+                                                              maybe-send-cmd-event!
+                                                              cmd-event-ch)
+            dlo (dlo/initialize (get-path stockdir "discard")
+                                (get-in metrics-registries
+                                        [:dlo :registry]))
+            clean-lock (ReentrantLock.)
+            command-loader (when load-messages
+                             (future
+                               (load-messages command-chan cmd/inc-cmd-depth)))]
+
+        ;; send the queue-loaded cmd-event if the command-loader didn't
+        (when-not command-loader
+          (async/>!! cmd-event-ch {:kind ::queue/queue-loaded}))
+
+        ;; Pretty much this helper just knows our job-pool and gc-interval
+        (let [job-pool (mk-pool)
+              gc-interval-millis (to-millis gc-interval)
+              write-db (jdbc/pooled-datasource (assoc database
+                                                      :pool-name "PDBWritePool"
+                                                      :expected-schema desired-schema-version)
+                                               database-metrics-registry)]
+          (when-not disable-update-checking
+            (maybe-check-for-updates config read-db job-pool))
+          (when (pos? schema-check-interval)
+            (interspaced schema-check-interval
+                         #(check-schema-version desired-schema-version
+                                                context
+                                                read-db
+                                                service
+                                                shutdown-on-error)
+                         job-pool))
+          (when (pos? gc-interval-millis)
+            (let [request (db-config->clean-request database)]
+              (interspaced gc-interval-millis
+                           #(coordinate-gc-with-shutdown write-db clean-lock
+                                                         database request
+                                                         (:stop-status context))
+                           job-pool)))
+          (assoc context
+                 :job-pool job-pool
+                 :shared-globals {:scf-read-db read-db
+                                  :scf-write-db write-db
+                                  :pretty-print pretty-print
+                                  :q q
+                                  :dlo dlo
+                                  :node-purge-ttl node-purge-ttl
+                                  :command-chan command-chan
+                                  :cmd-event-mult cmd-event-mult
+                                  :maybe-send-cmd-event! maybe-send-cmd-event!}
+                 :clean-lock clean-lock
+                 :command-loader command-loader))))))

 (defn db-unsupported-msg
   "Returns a message describing which databases are supported."


Update simplify example

Update simplify example

--- src/examples/handleinputinmain.clj
+++ src/examples/handleinputinmain.clj
@@ -22,41 +22,16 @@

 (defn -main [& _]
   ;; render in background thread
-   (let [colorShift    (atom 0.0001)
-         brightness    (atom 0.68)
-         contrast      (atom 2.46)
-         scanlineDepth (atom 0.94)
-         time          (atom 0.0)
-         noise         (atom 0.0016)
-         terminal   (zgl/make-terminal [:text :rainbow]
+   (let [terminal   (zgl/make-terminal [:text :rainbow]
                                        {:title "Zaffre demo"
                                         :columns 80 :rows 24
                                         :default-fg-color [250 250 250]
                                         :default-bg-color [5 5 8]
                                         :windows-font (TTFFont. "Consolas" 12)
-                                        ;:else-font "/home/santos/Downloads/cour.ttf"
-                                        ;:else-font (TTFFont. "/home/santos/Downloads/cour.ttf" 12)
-                                        ;:else-font (TTFFont. "Monospaced" 12)
-                                        ;:else-font (TTFFont. "/home/santos/src/robinson/fonts/Boxy/Boxy.ttf" 12)
-                                        ;:else-font (CP437Font. "http://dwarffortresswiki.org/images/2/29/Potash_8x8.png" :green 2)
-                                        ;:else-font (CP437Font. "http://dwarffortresswiki.org/images/2/29/Potash_8x8.png" :green 2)
-                                        ;:else-font (CP437Font. "http://dwarffortresswiki.org/images/b/b7/Kein_400x125.png" :green 2)
-                                        ;:else-font (CP437Font. "http://dwarffortresswiki.org/images/0/03/Alloy_curses_12x12.png" :green 2)
-                                        :else-font (CP437Font. "http://dwarffortresswiki.org/images/b/be/Pastiche_8x8.png" :green 1)
-                                        ;:else-font (CP437Font. "/home/santos/Pictures/LN_EGA8x8.png" :green 2)
-                                        :antialias true
-                                        ;:fullscreen true
+                                        :else-font (TTFFont. "Monospaced" 12)
                                         :icon-paths ["images/icon-16x16.png"
                                                      "images/icon-32x32.png"
-                                                     "images/icon-128x128.png"]
-                                        :fx-shader {:name     "retro.fs"
-                                                    :uniforms [["time" @time]
-                                                               ["noise" @noise]
-                                                               ["colorShift" @colorShift]
-                                                               ["scanlineDepth" @scanlineDepth]
-                                                               ["brightness" @brightness]
-                                                               ["contrast" @contrast]]}})
-        fullscreen-sizes (zat/fullscreen-sizes terminal)
+                                                     "images/icon-128x128.png"]})
         last-key    (atom nil)
         ;; Every 10ms, set the "Rainbow" text to have a random fg color
         fx-chan     (go-loop []
@@ -64,7 +39,6 @@
                         (doseq [x (range (count "Rainbow"))
                                 :let [rgb (hsv->rgb (double (rand 360)) 1.0 1.0)]]
                             (zat/set-fx-fg! terminal :rainbow (inc x) 1 rgb)))
-                        (zat/assoc-fx-uniform! terminal "time" (swap! time inc))
                         (zat/refresh! terminal)
                       (Thread/sleep 10)
                       (recur))
@@ -82,7 +56,6 @@
                           ;; ~30fps
                         (Thread/sleep 33)
                         (recur))]
-    (log/info "Fullscreen sizes" fullscreen-sizes)
     ;; get key presses in fg thread
     (loop []
       (let [new-key (async/<!! (zat/get-key-chan terminal))]
@@ -90,35 +63,6 @@
         (log/info "got key" (or (str @last-key) "nil"))
         ;; change font size on s/m/l keypress
         (case new-key
-          \s (zat/apply-font! terminal
-               (CP437Font. "http://dwarffortresswiki.org/images/b/be/Pastiche_8x8.png" :green 1)
-               (CP437Font. "http://dwarffortresswiki.org/images/b/be/Pastiche_8x8.png" :green 1))
-          \m (zat/apply-font! terminal
-               (CP437Font. "http://dwarffortresswiki.org/images/b/be/Pastiche_8x8.png" :green 2)
-               (CP437Font. "http://dwarffortresswiki.org/images/b/be/Pastiche_8x8.png" :green 2))
-          \l (zat/apply-font! terminal
-               (CP437Font. "http://dwarffortresswiki.org/images/b/be/Pastiche_8x8.png" :green 3)
-               (CP437Font. "http://dwarffortresswiki.org/images/b/be/Pastiche_8x8.png" :green 3))
-          \f (zat/fullscreen! terminal (first fullscreen-sizes))
-          \w (zat/fullscreen! terminal false)
-          \0 (zat/assoc-fx-uniform! terminal "brightness" (swap! brightness #(- % 0.02)))
-          \1 (zat/assoc-fx-uniform! terminal "brightness" (swap! brightness #(+ % 0.02)))
-          \2 (do (swap! contrast #(- % 0.02))
-                 (log/info "contrast" @contrast)
-                 (zat/assoc-fx-uniform! terminal "contrast" @contrast))
-          \3 (zat/assoc-fx-uniform! terminal "contrast" (swap! contrast #(+ % 0.02)))
-          \4 (zat/assoc-fx-uniform! terminal "scanlineDepth" (swap! scanlineDepth #(- % 0.02)))
-          \5 (zat/assoc-fx-uniform! terminal "scanlineDepth" (swap! scanlineDepth #(+ % 0.02)))
-          \6 (zat/assoc-fx-uniform! terminal "colorShift" (swap! colorShift #(- % 0.0001)))
-          \7 (zat/assoc-fx-uniform! terminal "colorShift" (swap! colorShift #(+ % 0.0001)))
-          \8 (zat/assoc-fx-uniform! terminal "noise" (swap! noise #(- % 0.0001)))
-          \9 (zat/assoc-fx-uniform! terminal "noise" (swap! noise #(+ % 0.0001)))
-          \p (log/info "brightness" @brightness
-                       "contrast" @contrast
-                       "scanlineDepth" @scanlineDepth
-                       "colorShift" @colorShift
-                       "noise" @noise
-                       "time" @time)
           \q (zat/destroy! terminal)
           nil)
         (if (= new-key :exit)


handle server port correctly

handle server port correctly

--- figwheel-main/src/figwheel/main.clj
+++ figwheel-main/src/figwheel/main.clj
@@ -322,6 +322,8 @@
 (defn config-clean [cfg]
   (update cfg :options dissoc :watch))

+;; TODO create connection
+
 #_(defn config-repl-connection [cfg]
   (if-not (or (::repl? cfg) (::figwheel-mode? cfg))

@@ -365,7 +367,7 @@
       (cond
         source
         (bapi/build source options cenv)
-        ;; TODO need compile paths
+        ;; TODO need :compile-paths config param
         (not-empty watch-dirs)
         (bapi/build (apply bapi/inputs watch-dirs) options cenv)))))

@@ -394,6 +396,14 @@
       (when-let [server @(:server renv)]
         (.join server)))))

+(defn update-server-host-port [repl-env-options [f address-port & args]]
+  (if (and (#{"-s" "--serve"} f) address-port)
+    (let [[_ host port] (re-matches #"(.*):(\d*)" address-port)]
+      (cond-> repl-env-options
+        (not (string/blank? host)) (assoc-in [:ring-server-options :host] host)
+        (not (string/blank? port)) (assoc-in [:ring-server-options :port] (Integer/parseInt port))))
+    repl-env-options))
+
 ;; TODO make this into a figwheel-start that
 ;; takes the correct config
 ;; and make an adapter function that produces the correct args for this fn
@@ -409,10 +419,12 @@
           (when-not (= mode :build-once)
             (cond
               (= mode :repl)
+              ;; this forwards command line args
               (repl repl-env repl-env-options (get-repl-options cfg))
               (or (= mode :serve) fw-mode?)
+              ;; we need to get the server host:port args
               (serve repl-env
-                     repl-env-options
+                     (update-server-host-port repl-env-options)
                      (get-repl-options cfg)
                      (when fw-mode? "(figwheel.core/start-from-repl)")))))))))


fixing un-guarded call to name

fixing un-guarded call to name

--- src/strictly_specking/edn_string_nav.clj
+++ src/strictly_specking/edn_string_nav.clj
@@ -30,9 +30,11 @@
 (def symbol-node?  (partial node-test :symbol))

 (defn is-keyword? [k n]
-  (and (keyword-node? n)
-       (= (get-in n [:content 1 :content])
-          [(name k)])))
+  (and
+   (keyword? k)
+   (keyword-node? n)
+   (= (get-in n [:content 1 :content])
+      [(name k)])))

 (defn is-project? [n]
   (and (name-node? n)


Revert "test: more test to ensure safety of read and read-string"

This reverts commit c57495d360b47c92bb5751966ea83f7d5815814d.

--- src/test/clojure/clojure/tools/reader_test.clj
+++ src/test/clojure/clojure/tools/reader_test.clj
@@ -1,6 +1,6 @@
 (ns clojure.tools.reader-test
   (:refer-clojure :exclude [read-string])
-  (:require [clojure.tools.reader :refer [read-string default-data-reader-fn unsafe-read-string]]
+  (:require [clojure.tools.reader :refer [read-string default-data-reader-fn]]
             [clojure.test :refer [deftest is]])
   (:import clojure.lang.BigInt))

@@ -295,11 +295,7 @@
   (is (= 14 ((eval (read-string "#(apply + % %1 %3 %&)")) 1 2 3 4 5))))

 (deftest read-eval
-  (is (= 3 (binding [*read-eval* true]
-             (unsafe-read-string "#=(+ 1 2)"))))
-  (is (thrown-with-msg? Exception #"#= only allowed when using the unsafe- variants of read and read-string"
-        (binding [*read-eval* true]
-          (read-string "#=(+ 1 2)")))))
+  (is (= 3 (read-string "#=(+ 1 2)"))))

 (deftest read-tagged
   (is (= #inst "2010-11-12T13:14:15.666"


Minor cosmetic changes on icons sidebar widget component.

--- src/uxbox/main/ui/workspace/sidebar/icons.cljs
+++ src/uxbox/main/ui/workspace/sidebar/icons.cljs
@@ -56,9 +56,8 @@
   {:mixins [(mx/local) mx/reactive]
    :will-mount icons-toolbox-will-mount
    :will-unmount icons-toolbox-will-unmount}
-  [own]
-  (let [local (:rum/local own)
-        drawing (mx/react drawing-shape)
+  [{:keys [rum/local] :as own}]
+  (let [drawing (mx/react drawing-shape)

         colls-map (mx/react icons/collections-ref)
         colls (->> (vals colls-map)