Actually remove the commments

Actually remove the commments

--- src/terraboot/vpc.clj
+++ src/terraboot/vpc.clj
@@ -124,38 +124,6 @@
                                                 :associate_public_ip_address true
                                                 })

-              ;; (aws-instance "influxdb" {:ami default-ami
-              ;;                           :instance_type "m4.large"
-              ;;                           :vpc_security_group_ids [(vpc-id-of "aws_security_group" "influxdb")
-              ;;                                                    (id-of "aws_security_group" "allow_ssh")
-              ;;                                                    (vpc-id-of "aws_security_group" "allow_elb_grafana")
-              ;;                                                    (vpc-id-of "aws_security_group" "all-servers")
-              ;;                                                    ]
-              ;;                           :subnet_id (vpc-id-of "aws_subnet" (stringify "public-" (first azs)))
-              ;;                           :root_block_device {:volume_size 100}})
-
-              ;; (elb "grafana" resource {:name "grafana"
-              ;;                          :health_check {:healthy_threshold 2
-              ;;                                         :unhealthy_threshold 3
-              ;;                                         :target "HTTP:80/status"
-              ;;                                         :timeout 5
-              ;;                                         :interval 30}
-              ;;                          :internal true
-              ;;                          :listener [(elb-listener (if cert-name
-              ;;                                                     {:lb-port 443 :lb-protocol "https" :port 80 :protocol "http" :cert-name cert-name}
-              ;;                                                     {:port 80 :protocol "http"}))]
-              ;;                          :instances [(id-of "aws_instance" "influxdb")]
-              ;;                          :subnets (mapv #(id-of "aws_subnet" (stringify  vpc-name "-public-" %)) azs)
-              ;;                          :security_groups (mapv #(id-of "aws_security_group" %) ["allow_outbound"
-              ;;                                                                                "allow_external_http_https"
-              ;;                                                                                (vpc-unique "elb_grafana")])
-              ;;                          })
-              ;; (private_route53_record "grafana" vpc-name {:zone_id  (vpc-id-of "aws_route53_zone" "mesos")
-              ;;                                             :name "grafana"
-              ;;                                             :alias {:name (output-of "aws_elb" "grafana" "dns_name")
-              ;;                                                     :zone_id (output-of "aws_elb" "grafana" "zone_id")
-              ;;                                                     :evaluate_target_health true}})
-              ;; (private_route53_record "influxdb" vpc-name {:records [(output-of "aws_instance" "influxdb" "private_ip")]})

               (private_route53_record "kibana" vpc-name {:records [(vpc-output-of "aws_instance" "logstash" "private_ip")]})
               (private_route53_record "logstash" vpc-name {:records [(vpc-output-of "aws_instance" "logstash" "private_ip")]})
@@ -176,10 +144,6 @@
                                    :source_security_group_id (vpc-id-of "aws_security_group" "sends_influx")})

               (vpc-security-group "sends_influx" {})
-
-              ;; (resource "aws_eip" "influxdb"
-              ;;           {:vpc true
-              ;;            :instance (id-of "aws_instance" "influxdb")})

               (vpc-resource "aws_eip" "vpn" {:instance (vpc-id-of "aws_instance" "vpn")
                                              :vpc true})


Added logging to print aggregation id if user hits an aggregation found in the database.

--- src/qu/cache.clj
+++ src/qu/cache.clj
@@ -83,7 +83,8 @@
            (do (metrics/increment "cache.hit.count")
              (extract-result collection query))
            (do (metrics/increment "cache.wait.count")
-               not-found))))))
+               not-found))
+        (log/info "FOUND Cached Aggregation - Id:" collection)))))

 (defn add-to-cache
   "Add the specified aggregation to the cache by running it through


cleaning up some build error reporting

cleaning up some build error reporting

--- sidecar/src/figwheel_sidecar/auto_builder.clj
+++ sidecar/src/figwheel_sidecar/auto_builder.clj
@@ -60,6 +60,10 @@
    {:builds  builds
     :builder (builder figwheel-server)
     :each-iteration-hook (fn [_] (fig/check-for-css-changes figwheel-server))}))
+
+(defn check-autobuild-config [all-builds build-ids figwheel-server]
+  (let [builds (config/narrow-builds* all-builds build-ids)]
+    (config/check-config figwheel-server builds)))

 (defn autobuild-ids [{:keys [all-builds build-ids figwheel-server]}]
   (let [builds (config/narrow-builds* all-builds build-ids)
@@ -132,16 +136,21 @@
                             (mapv cbuild/clean-build (map :build-options builds))
                             (println "Deleting ClojureScript compilation target files.")))
         run-autobuilder (fn [figwheel-server build-ids]
-                          (when-not (builder-running?)
-                            (build-once* build-ids)
-                            (binding [*out* log-writer
-                                      *err* log-writer]
-                              (when-let [abuild (autobuild-ids
-                                                 { :all-builds all-builds
-                                                   :build-ids build-ids
-                                                   :figwheel-server figwheel-server })]
-                                (reset! state-atom { :autobuilder abuild
-                                                     :focus-ids build-ids})))))
+                          (if-let [errors (not-empty (check-autobuild-config all-builds build-ids figwheel-server))]
+                            (do
+                              (display-focus-ids build-ids)
+                              (mapv println errors))
+                            (when-not (builder-running?)
+                              (build-once* build-ids)
+                              (binding [*out* log-writer
+                                        *err* log-writer]
+                                (when-let [abuild (autobuild-ids
+                                                   { :all-builds all-builds
+                                                    :build-ids build-ids
+                                                    :figwheel-server figwheel-server })]
+                                  (println "Started Figwheel autobuilder see:" logfile-path )
+                                  (reset! state-atom { :autobuilder abuild
+                                                        :focus-ids build-ids}))))))
         stop-autobuild*  (fn [_]
                            (if (builder-running?)
                              (do
@@ -152,8 +161,7 @@
         start-autobuild* (fn [ids]
                            (if-not (builder-running?)
                              (when-let [build-ids' (not-empty (get-ids ids))]
-                               (run-autobuilder figwheel-server build-ids')
-                               (println "Started Figwheel autobuilder see:" logfile-path ))
+                               (run-autobuilder figwheel-server build-ids'))
                              (println "Autobuilder already running.")))
         switch-to-build*     (fn [ids]
                                (when-not (empty? ids)
@@ -198,7 +206,7 @@
     (when-let [id (:id repl-build)] (println " for build:" id))
     (println (repl-function-docs))
     (println "Prompt will show when figwheel connects to your application")
-    ;; it would be cool to switch the repl's build as well, is this possible?
+    ;; TODO it would be cool to switch the repl's build as well
     (fig-repl/repl repl-build figwheel-server {:special-fns special-fns})))

 (defn autobuild [src-dirs build-options figwheel-options]


avoid directly referencing static fields of closure classes

--- src/main/shadow/build/closure.clj
+++ src/main/shadow/build/closure.clj
@@ -59,62 +59,15 @@
    :off CheckLevel/OFF})

 (def warning-types
-  {:access-controls DiagnosticGroups/ACCESS_CONTROLS
-   :ambiguous-function-decl DiagnosticGroups/AMBIGUOUS_FUNCTION_DECL
-   :analyzer-checks DiagnosticGroups/ANALYZER_CHECKS
-   :check-eventful-object-disposal DiagnosticGroups/CHECK_EVENTFUL_OBJECT_DISPOSAL
-   :check-regexp DiagnosticGroups/CHECK_REGEXP
-   :check-types DiagnosticGroups/CHECK_TYPES
-   :check-useless-code DiagnosticGroups/CHECK_USELESS_CODE
-   :check-variables DiagnosticGroups/CHECK_VARIABLES
-   :closure-dep-method-usage-checks DiagnosticGroups/CLOSURE_DEP_METHOD_USAGE_CHECKS
-   :conformance-violations DiagnosticGroups/CONFORMANCE_VIOLATIONS
-   :const DiagnosticGroups/CONST
-   :constant-property DiagnosticGroups/CONSTANT_PROPERTY
-   :debugger-statement-present DiagnosticGroups/DEBUGGER_STATEMENT_PRESENT
-   :deprecated DiagnosticGroups/DEPRECATED
-   :deprecated-annotations DiagnosticGroups/DEPRECATED_ANNOTATIONS
-   :duplicate-message DiagnosticGroups/DUPLICATE_MESSAGE
-   :duplicate-vars DiagnosticGroups/DUPLICATE_VARS
-   :es3 DiagnosticGroups/ES3
-   :es5-strict DiagnosticGroups/ES5_STRICT
-   :externs-validation DiagnosticGroups/EXTERNS_VALIDATION
-   :extra-require DiagnosticGroups/EXTRA_REQUIRE
-   :fileoverview-jsdoc DiagnosticGroups/FILEOVERVIEW_JSDOC
-   :function-params DiagnosticGroups/FUNCTION_PARAMS
-   :global-this DiagnosticGroups/GLOBAL_THIS
-   ;; :inferred-const-checks DiagnosticGroups/INFERRED_CONST_CHECKS
-   :internet-explorer-checks DiagnosticGroups/INTERNET_EXPLORER_CHECKS
-   :invalid-casts DiagnosticGroups/INVALID_CASTS
-   :j2cl-checks DiagnosticGroups/J2CL_CHECKS
-   :late-provide DiagnosticGroups/LATE_PROVIDE
-   :lint-checks DiagnosticGroups/LINT_CHECKS
-   :message-descriptions DiagnosticGroups/MESSAGE_DESCRIPTIONS
-   :misplaced-type-annotation DiagnosticGroups/MISPLACED_TYPE_ANNOTATION
-   :missing-getcssname DiagnosticGroups/MISSING_GETCSSNAME
-   :missing-override DiagnosticGroups/MISSING_OVERRIDE
-   :missing-polyfill DiagnosticGroups/MISSING_POLYFILL
-   :missing-properties DiagnosticGroups/MISSING_PROPERTIES
-   :missing-provide DiagnosticGroups/MISSING_PROVIDE
-   :missing-require DiagnosticGroups/MISSING_REQUIRE
-   :missing-return DiagnosticGroups/MISSING_RETURN
-   :non-standard-jsdoc DiagnosticGroups/NON_STANDARD_JSDOC
-   :report-unknown-types DiagnosticGroups/REPORT_UNKNOWN_TYPES
-   :strict-missing-require DiagnosticGroups/STRICT_MISSING_REQUIRE
-   :strict-module-dep-check DiagnosticGroups/STRICT_MODULE_DEP_CHECK
-   :strict-requires DiagnosticGroups/STRICT_REQUIRES
-   :suspicious-code DiagnosticGroups/SUSPICIOUS_CODE
-   :tweaks DiagnosticGroups/TWEAKS
-   :type-invalidation DiagnosticGroups/TYPE_INVALIDATION
-   :undefined-names DiagnosticGroups/UNDEFINED_NAMES
-   :undefined-variables DiagnosticGroups/UNDEFINED_VARIABLES
-   :underscore DiagnosticGroups/UNDERSCORE
-   :unknown-defines DiagnosticGroups/UNKNOWN_DEFINES
-   :unused-local-variable DiagnosticGroups/UNUSED_LOCAL_VARIABLE
-   :unused-private-property DiagnosticGroups/UNUSED_PRIVATE_PROPERTY
-   :use-of-goog-base DiagnosticGroups/USE_OF_GOOG_BASE
-   :violated-module-dep DiagnosticGroups/VIOLATED_MODULE_DEP
-   :visiblity DiagnosticGroups/VISIBILITY})
+  (reduce
+    (fn [warnings [registered-name group]]
+      (let [kw (-> registered-name
+                   (str/replace #"[A-Z]" #(str "-" (str/lower-case %)))
+                   keyword)]
+        (assoc warnings kw group)))
+    {}
+    (-> (DiagnosticGroups.)
+        (.getRegisteredGroups))))

 (defn ^CompilerOptions$LanguageMode lang-key->lang-mode [key]
   (case (keyword (str/replace (name key) #"^es" "ecmascript"))
@@ -131,7 +84,7 @@
     :ecmascript-next CompilerOptions$LanguageMode/ECMASCRIPT_NEXT))

 (defn set-options
-  [^CompilerOptions closure-opts opts]
+  [^CompilerOptions closure-opts opts state]

   (when-let [level
              (case (:optimizations opts)
@@ -176,7 +129,11 @@

   (when (contains? opts :closure-warnings)
     (doseq [[type level] (:closure-warnings opts)]
-      (. closure-opts (setWarningLevel (get warning-types type) (get check-levels level)))))
+      (let [group (get warning-types type)
+            check-level (get check-levels level)]
+        (if-not (and group check-level)
+          (util/warn state {:type ::invalid-closure-warning :key type :level level})
+          (. closure-opts (setWarningLevel group check-level))))))

   (when (contains? opts :closure-extra-annotations)
     (. closure-opts (setExtraAnnotationNames (map name (:closure-extra-annotations opts)))))
@@ -817,7 +774,7 @@
           ;; (js/React...) will otherwise just work without externs
           (.setWarningLevel DiagnosticGroups/UNDEFINED_VARIABLES CheckLevel/WARNING))]

-    (set-options closure-opts compiler-options)
+    (set-options closure-opts compiler-options state)

     (when source-map?
       ;; FIXME: path is not used at all but needs to be set
@@ -863,8 +820,10 @@
     (let [cc (make-closure-compiler)
           co
           (doto (make-options)
-            (set-options {:optimizations :simple
-                          :language-in :ecmascript5}))
+            (set-options
+              {:optimizations :simple
+               :language-in :ecmascript5}
+              state))

           externs
           (load-externs state false)
@@ -1284,7 +1243,7 @@

         co
         (doto (make-options)
-          (set-options co-opts))
+          (set-options co-opts state))

         co
         (if (false? (get-in state [:compiler-options :rewrite-polyfills]))
@@ -1603,7 +1562,7 @@

         closure-opts
         (doto (make-options)
-          (set-options co-opts)
+          (set-options co-opts state)
           (.resetWarningsGuard)

           (.setStrictModeInput false)


pep-038 wip

pep-038 wip


randomize attachments folder

randomize attachments folder

--- code/clojure/src/ekade/leemail.clj
+++ code/clojure/src/ekade/leemail.clj
@@ -30,15 +30,14 @@

 (defn get-attachments
   [attachments]
-  (doseq [att attachments]
-    (let [filename (str "/tmp/emajliramo/")]))
+  (def attfolder (format "/tmp/emajliramo/%s-%s/" (System/currentTimeMillis) (rand-int 100000)))
   (for [att attachments
         :let [zipped (zip/xml-zip att)
               content-type (first (xml-> zipped :mimeType text))
               filename (first (xml-> zipped :fileName text))
-              filepath (str "/tmp/emajliramo/" filename)
+              filepath (str attfolder filename)
               file-content (first (xml-> zipped :content text))]]
-    (prepare-attachment content-type filename filepath file-content)))
+    (prepare-attachment content-type filename filepath file-content)))

 (defn pripremi-emajl
   [le-xml]


Finish removing korma from load-from-h2 :honey_pot:

--- src/metabase/cmd/load_from_h2.clj
+++ src/metabase/cmd/load_from_h2.clj
@@ -83,48 +83,38 @@

 ;; TODO - `e` is a bad variable name! This should be something like `entity`
 (defn- insert-entity! [e objs]
-  (print (u/format-color 'blue "Transfering %d instances of %s..." (count objs) (:name e)))
+  (print (u/format-color 'blue "Transfering %d instances of %s..." (count objs) (:name e))) ; TODO - I don't think the print+flush is working as intended :/
   (flush)
   ;; The connection closes prematurely on occasion when we're inserting thousands of rows at once. Break into smaller chunks so connection stays alive
-  (println "inserting" (count objs) "like\n" (u/pprint-to-str (first objs)) "...")
   (doseq [chunk (partition-all 300 objs)]
     (print (color/blue \.))
     (flush)
-    (apply jdbc/insert! *target-db-connection* (:table e) (condp = e
-                                                            DashboardCard
+    (apply jdbc/insert! *target-db-connection* (:table e) (if (= e DashboardCard)
                                                             ;; mini-HACK to fix h2 lowercasing these couple attributes
                                                             ;; luckily this is the only place in our schema where we have camel case names
                                                             (mapv #(set/rename-keys % {:sizex :sizeX, :sizey :sizeY}) chunk)
-
-                                                            User
-                                                            (for [user chunk]
-                                                              (dissoc user :google_auth)) ; NOCOMMIT
-
                                                             chunk)))
   (println (color/green "[OK]")))

 (defn- insert-self-referencing-entity! [e objs]
-  (println "insert-self-referencing-entity!" e)
-  (let [self-ref-attr    (condp = e
-                           RawColumn :fk_target_column_id
-                           Field     :fk_target_field_id)
-        self-referencing (filter self-ref-attr objs)
+  (let [self-ref-attrs   (condp = e
+                           RawColumn #{:fk_target_column_id}
+                           Field     #{:fk_target_field_id :parent_id})
+        self-referencing (for [obj   objs
+                               :when (reduce #(or %1 %2) (for [attr self-ref-attrs] ; a self-referencing object is an object where *any* of the self-referencing attributes is non-nil
+                                                           (attr obj)))]
+                           obj)
         others           (set/difference (set objs) (set self-referencing))]
     ;; first insert the non-self-referencing objects
-    (println "self-referencing:" (count self-referencing) "others:" (count others) "total:" (count objs))
-    (println "self-referencing:" (u/pprint-to-str (for [field self-referencing]
-                                                    (select-keys field [:id :fk_target_field_id]))))
     (insert-entity! e others)
-    (println "inserted others <3")
-    ;; then insert the rest, which should be safe to insert now
-    (insert-entity! e self-referencing)
-    (println "inserted self-referencing <3")))
+    ;; then insert the rest, which *should* be safe to insert now (TODO - this could break if a self-referencing entity depends on another self-referencing entity </3)
+    (insert-entity! e self-referencing)))

 (defn- set-postgres-sequence-values! []
   (print (u/format-color 'blue "Setting postgres sequence ids to proper values..."))
   (flush)
   (doseq [e    (filter #(not (contains? entities-without-autoinc-ids %)) entities)
-          :let [table-name (:table e)
+          :let [table-name (name (:table e))
                 seq-name   (str table-name "_id_seq")
                 sql        (format "SELECT setval('%s', COALESCE((SELECT MAX(id) FROM %s), 1), true) as val" seq-name (name table-name))]]
     (jdbc/db-query-with-resultset *target-db-connection* [sql] :val))


Implement the closure of closures for letfn

Correctly hoisting letfn requires that as the letfn terms are presumably
mutually recursive and may contain closures that the  closed-overs set
for any given letfn term when hoisted is not the naive closed-overs set
but rather is the fixed point merge of the closed-overs set of all
reachable expressions including the hoists of the other letfn
functions.

This patch makes the appropriate modifications to the handling of letfn
so that when letfn bodies are rewritten into partials the generated
rewritten functions and partials will correctly reflect the subset of
the hoisted environment which must be passed as arguments.

--- src/oxcart/passes/lambda_lift.clj
+++ src/oxcart/passes/lambda_lift.clj
@@ -80,9 +80,17 @@

 (defn rewrite-closed-overs
   [mapping binding]
-  (let [name (pattern/binding->symbol binding)]
-    (assoc-in binding [:init :closed-overs] (get mapping name))))
-
+  {:pre [(map? mapping)
+         (pattern/binding? binding)]}
+  (assert (pattern/binding? binding))
+  (let [name         (pattern/binding->symbol binding)
+        closed-overs (get mapping name)]
+    (assoc-in binding [:init :closed-overs]
+              (->> (for [[l le] (:locals (:env binding))
+                         :when (contains? closed-overs
+                                          (:name le))]
+                     [l le])
+                   (into {})))))

 (defn lift-fns
@@ -179,11 +187,9 @@
                    (fix merge-deps
                         locals->closed-overs)))

-          (println @locals->closed-overs)
-
           (let [;; rewrite the bindings to share closed-over information
                 bindings' (mapv (partial rewrite-closed-overs
-                                         locals->closed-overs)
+                                         @locals->closed-overs)
                                 bindings)

                 fns       (zipmap (map pattern/binding->symbol bindings')
@@ -191,19 +197,17 @@

                 ;; compute the mapping from symbols to partial applications
                 fns'      (map-vals fns
-                                    (partial lift-fns defs-atom))]
-            (println fns')
+                                    (partial lift-fns (atom [])))]

             (-> ast
                 (assoc :bindings (->> bindings'
-                                      (mapv (fn [binding]
-                                              (ast/prewalk binding
-                                                           (partial rewrite-locals
-                                                                    fns'))))
-                                      (mapv #(ast/prewalk %1
+                                      (mapv #(ast/prewalk %
+                                                          (partial rewrite-locals
+                                                                   fns')))
+                                      (mapv #(ast/prewalk %
                                                           (partial rewrite-locals
                                                                    @locals->vars)))))
-
+
                 ;; force to a let form
                 (assoc :op :let))))


Deduplication

Deduplication

--- src-cljs/pepa/components/page.cljs
+++ src-cljs/pepa/components/page.cljs
@@ -54,18 +54,22 @@

 (ui/defcomponent thumbnail [page owner {:keys [enable-rotate?]}]
   (render-state [_ {:keys [overlay?]}]
-    (if (and enable-rotate?
-             (= :processing-status/processed (:render-status page)))
-      (dom/div #js {:className "thumbnail"
-                    :onMouseEnter (fn [e]
-                                    (when (>= (.-width (style/getSize (om/get-node owner)))
-                                              +min-rotate-width+)
-                                      (om/set-state! owner :overlay? true)))
-                    :onMouseLeave (fn [e] (om/set-state! owner :overlay? false))}
-               (when overlay?
-                 (om/build rotate-buttons page))
-               (om/build page-image page {:opts {:size-fn min}}))
-      (om/build page-image page {:opts {:size-fn min}}))))
+    (let [page-image (om/build page-image page
+                               {:opts {:size-fn min}
+                                :key :id})]
+      (if (and enable-rotate?
+               (= :processing-status/processed (:render-status page)))
+        (dom/div #js {:className "thumbnail"
+                      :onMouseEnter (fn [e]
+                                      (when (>= (.-width (style/getSize (om/get-node owner)))
+                                                +min-rotate-width+)
+                                        (om/set-state! owner :overlay? true)))
+                      :onMouseLeave (fn [e] (om/set-state! owner :overlay? false))}
+                 (when overlay?
+                   (om/build rotate-buttons page))
+                 page-image)
+        page-image))))

 (defn full [page owner _]
-  (page-image page owner {:size-fn max}))
+  (page-image page owner {:size-fn max
+                          :key :id}))


Expand tests to clinicalMatrix.

Expand tests to clinicalMatrix.

--- test/cavm/db_test.clj
+++ test/cavm/db_test.clj
@@ -140,7 +140,7 @@
                   (doseq [f# ["test.h2.db" "test.lock.db" "test.trace.db"]]
                     (io/delete-file f# true)))))))

-(def ^:dynamic *test-runs* 100)
+(def ^:dynamic *test-runs* 40)

 (defn check-matrix [db id tsv]
   (let [{:keys [probes samples matrix]} tsv
@@ -291,21 +291,33 @@

 (defmacro with-file
   "Execute body, ensuring that file is always deleted before returning."
-  [[bindvar file] & body]
-  `(let [~bindvar ~file]
-     (try
-       ~@body
-       (finally (when *delete-tmp-files*
-                  (io/delete-file (io/file ~bindvar) true))))))
+  [bindings & body]
+  (if (= (count bindings) 0)
+    `(do ~@body)
+    `(let ~(subvec bindings 0 2)
+       (try
+         (with-file ~(subvec bindings 2) ~@body)
+         (finally (when *delete-tmp-files*
+                    (io/delete-file (io/file ~(bindings 0)) true)))))))
+
+(defn write-clinical-meta [file]
+  (spit (io/file file)
+        "{\"type\": \"clinicalMatrix\"}"))
+
+(defn transpose [m]
+  (apply map vector m))

 (defn write-genomic-matrix
   "Write a genomic matrix to a file."
-  [file {:keys [matrix probes samples]}]
+  [file {:keys [matrix probes samples]} clinical meta-file]
   (let [header (cons "sampleID" samples)
+        trans (if clinical transpose identity)
         rows (map (fn [probe row] (cons probe row)) probes matrix)]
+    (when clinical
+      (write-clinical-meta meta-file))
     (spit (io/file file)
           (s/join "\n"
-                  (map #(s/join "\t" (map str-nan %)) (cons header rows))))))
+                  (map #(s/join "\t" (map str-nan %)) (trans (cons header rows)))))))

 (defn trim-tsv
   "Rewrite tsv with probes and samples trimmed of leading and trailing
@@ -319,9 +331,10 @@
 (defn genomic-matrix-loader-run
   "Run a generated genomic-matrix-loader test case. Useful for repeated failed
   cases. Run with *verbose* to print detailed test failures"
-  [tsv id]
-  (with-file [file (str (io/file docroot "generated" id))]
-    (write-genomic-matrix file tsv)
+  [tsv id clinical]
+  (with-file [file (str (io/file docroot "generated" id))
+              meta-file (str file ".json")]
+    (write-genomic-matrix file tsv clinical meta-file)
     (db-disk-fixture
       db
       (loader db detector docroot file)
@@ -331,8 +344,9 @@
   *test-runs*
   (prop/for-all
     [tsv gen-tsv
-     id (gen/such-that not-empty gen/string-alpha-numeric)]
-    (genomic-matrix-loader-run tsv id)))
+     id (gen/such-that not-empty gen/string-alpha-numeric)
+     clinical gen/boolean]
+    (genomic-matrix-loader-run tsv id clinical)))

 (defn matrix2 [db]
   (ct/testing "tsv matrix from file"


refactor to make rotate method private and change starts-with-any method to no longer return a function

--- exercises/pig-latin/src/example.clj
+++ exercises/pig-latin/src/example.clj
@@ -1,45 +1,47 @@
 (ns pig-latin
   (:require [clojure.string :as str]))

-(defn starts-with-any [prefixes]
-  (fn [word]
-    (some (partial str/starts-with? word) prefixes)))
+(defn starts-with-any [prefixes word]
+  (some (partial str/starts-with? word) prefixes))

 (defn- starts-with-vowel-like? [word]
-  ((starts-with-any #{"yt" "xr"}) word))
+  (starts-with-any #{"yt" "xr"} word))

 (defn starts-with-vowel? [word]
-  ((starts-with-any #{"a" "e" "i" "o" "u"}) word))
+  (starts-with-any #{"a" "e" "i" "o" "u"} word))

 (defn- starts-with-two-letter-prefix? [word]
-  ((starts-with-any #{"ch" "qu" "th"}) word))
+  (starts-with-any #{"ch" "qu" "th"} word))

 (defn- starts-with-three-letter-prefix? [word]
-  ((starts-with-any #{"thr" "sch"}) word))
+  (starts-with-any #{"thr" "sch"} word))

 (defn- starts-with-qu-and-preceeding-constanant? [word]
   (and (not (starts-with-vowel? word))
        (str/starts-with? (subs word 1) "qu")))

-(defn rotate [word n]
+(defn- rotate [word n]
   (str (subs word n) (subs word 0 n)))
+
+(defn append-ay [word]
+  (str word "ay"))

 (defn- translate-word [word]
   (cond
     (or (starts-with-vowel? word)
         (starts-with-vowel-like? word))
-    (str word "ay")
+    (append-ay word)

     (or
      (starts-with-three-letter-prefix? word)
      (starts-with-qu-and-preceeding-constanant? word))
-    (str (rotate word 3) "ay")
+    (append-ay (rotate word 3))

     (starts-with-two-letter-prefix? word)
-    (str (rotate word 2) "ay")
+    (append-ay (rotate word 2))

     :else
-    (str (rotate word 1) "ay")))
+    (append-ay (rotate word 1))))

 (defn translate [words]
   (->> (str/split words #" ")


Crude experiment adding an async GET handler to the word count example

--- clstreams/src/clstreams/examples/count_words/webapi.clj
+++ clstreams/src/clstreams/examples/count_words/webapi.clj
@@ -1,6 +1,6 @@
 (ns clstreams.examples.count-words.webapi
   (:require [bidi.ring :as bidi]
-            [clojure.core.async :refer [<! go timeout]]
+            [clojure.core.async :refer [<! >! chan go timeout]]
             [clstreams.webapi.component :refer [new-aleph]]
             [manifold.stream :as stream]
             [ring.middleware.json :refer [wrap-json-body wrap-json-response]]
@@ -22,22 +22,17 @@
                     (fn [ctx]
                       (let [word (get-in ctx [:parameters :path :word])
                             store (.store kstreams "Counts"
-                                          (QueryableStoreTypes/keyValueStore))]
-                        (->> word (.get store) (#(if % % 0)) str)))}}}))
+                                          (QueryableStoreTypes/keyValueStore))
+                            content (chan)]
+                        (go
+                          (<! (timeout 1))
+                          (>! content (->> word (.get store) (#(if % % 0)) str)))
+                        (-> content stream/->source stream/take!)))}}}))

 (defn make-main-handler [component]
   (bidi/make-handler
    ["/" {["word-count/" :word] (make-word-count-handler component)
          "hello" (yada/handler "Hello World!\n")}]))
-
-(defn make-async-handler [component]
-  (fn [request]
-    (let [handler (make-main-handler component)]
-      (-> (go
-            (<! (timeout 1))
-            (handler request))
-          stream/->source
-          stream/take!))))

 (defn make-app [component]
   (-> (make-main-handler component)


Fix result in is test

Fix result in is test

--- test/is/map.cljs
+++ test/is/map.cljs
@@ -1,5 +1,5 @@

 (println "Map Function Tests")

-(is (= (map inc [1 2 3]) [2 3 4]))
+(is (= (map inc [1 2 3]) '(2 3 4)))


Make console output from tests more colorful

--- test/runner.cljs
+++ test/runner.cljs
@@ -62,11 +62,11 @@
   (println (:fail m) "failures," (:error m) "errors.")
   (aset js/window "test-failures" (+ (:fail m) (:error m))))

-(defn pretty-print-diffs [diffs]
+(defn pretty-print-diffs [diffs color]
   (let [printer (fn [[op data]]
                   (cond
-                    (= op js/DIFF_DELETE) (str (ansi :red) data (ansi :reset))
-                    (= op js/DIFF_INSERT) (str (ansi :green) data (ansi :reset))
+                    (= op js/DIFF_DELETE) (str (ansi :red) data (ansi color))
+                    (= op js/DIFF_INSERT) (str (ansi :green) data (ansi color))
                     :else data))]
     (apply str (map printer diffs))))

@@ -80,16 +80,16 @@
           dmp (diff-match-patch-class.)
           diffs (.diff_main dmp json-b json-a)]
       (.diff_cleanupSemantic dmp diffs)
-      (println (pretty-print-diffs diffs)))))
+      (println (ansi :bg-white) (ansi :black) (pretty-print-diffs diffs :black) (ansi :reset)))))

 (defmethod report [::test/default :fail] [m]
   (test/inc-report-counter! :fail)
   (println (ansi :red) "\nFAIL in" (test/testing-vars-str m) (ansi :reset))
   (when (seq (:testing-contexts (test/get-current-env)))
-    (println (test/testing-contexts-str)))
-  (when-let [message (:message m)] (println message))
-  (println "expected:" (pr-str (:expected m)))
-  (println "  actual:" (pr-str (:actual m)))
+    (println (ansi :blue) (test/testing-contexts-str) (ansi :reset)))
+  (when-let [message (:message m)] (println (ansi :magenta) message (ansi :reset)))
+  (println "expected:" (ansi :green) (pr-str (:expected m)) (ansi :reset))
+  (println "  actual:" (ansi :yellow) (pr-str (:actual m)) (ansi :reset))
   (present-diff-if-applicable (:actual m)))

 (test/run-tests


Small style changes in problem61.clj

Small style changes in problem61.clj

--- euler_clojure/src/euler/problem61.clj
+++ euler_clojure/src/euler/problem61.clj
@@ -48,7 +48,7 @@
   [node]
   (every? #(apply cyclic? %) (for [i (range (count node))]
                                [(nth node i)
-                                (nth node (mod (+ i 1) (count node)))])))
+                                (nth node (mod (inc i) (count node)))])))

 (defn fourdigit? [n] (= 4 (count (str (int n)))))

@@ -56,7 +56,8 @@
   "Given a function representing a polygonal type, return all four-digit
   members of that type."
   [func]
-  (let [dw (drop-while (complement fourdigit?) (for [i (iterate inc 0)] (func i)))]
+  (let [dw (drop-while (complement fourdigit?)
+                       (for [i (iterate inc 0)] (func i)))]
     (take-while fourdigit? dw)))

 (defn problem61 []
@@ -68,7 +69,7 @@
         ;; We will build up candidate solutions incrementally. The starting
         ;; frontier is therefore full of one-length vectors of all the four
         ;; digit numbers for the first polygonal type of this permutation.
-        (loop [frontier (vec (for [x (fourdigit-polys (nth perm 0))] (vector x)))]
+        (loop [frontier (vec (for [x (fourdigit-polys (nth perm 0))] [x]))]
           (let [node (peek frontier)
                 z (count node)]
             (cond


Begin v0.6.0.alpha1

Begin v0.6.0.alpha1

--- examples/todomvc/project.clj
+++ examples/todomvc/project.clj
@@ -2,7 +2,7 @@
   :dependencies [[org.clojure/clojure       "1.7.0"]
                  [org.clojure/clojurescript "1.7.145"]
                  [reagent "0.5.1"]
-                 [re-frame "0.5.0"]
+                 [re-frame "0.6.0.alpha1"]
                  [figwheel "0.2.6"]
                  [secretary "1.2.3"]
                  [prismatic/schema "1.0.3"]]


Upgrade todomvc example ClojureScript to 1.10.597

--- examples/todomvc/project.clj
+++ examples/todomvc/project.clj
@@ -1,7 +1,7 @@
 (defproject todomvc-re-frame "lein-git-inject/version"

   :dependencies [[org.clojure/clojure        "1.10.1"]
-                 [org.clojure/clojurescript  "1.10.520"
+                 [org.clojure/clojurescript  "1.10.597"
                   :exclusions [com.google.javascript/closure-compiler-unshaded
                                org.clojure/google-closure-library
                                org.clojure/google-closure-library-third-party]]


Update auth.clj

Update auth.clj

--- backend/src/akvo/lumen/lib/auth.clj
+++ backend/src/akvo/lumen/lib/auth.clj
@@ -79,7 +79,7 @@
                                                       set)
                                    auth-datasets (auth-datasets dss permissions)]
                                {:auth-datasets auth-datasets})
-                             {})]
+                             {:auth-datasets (mapv :id dss)})]
         (handler (assoc request
                         :db-query-service
                         (new-dbqs (p/connection tenant-manager tenant)


Return the total audio length in the meta data

As specified in http://www.daisy.org/z3986/2005/Z3986-2005.html#Clock

--- src/mdr2/dtb.clj
+++ src/mdr2/dtb.clj
@@ -103,6 +103,18 @@
   (let [audio-files (filter wav-file? (file-seq (file dtb)))]
     (reduce + (map file-audio-length audio-files))))

+(defn audio-total-time
+  "Return the total audio length for a given DAISY Talking Book in a
+  format according to
+  http://www.daisy.org/z3986/2005/Z3986-2005.html#Clock"
+  [dtb]
+  (let [duration (audio-length dtb)
+        hours (quot duration 3600)
+        minutes (quot (mod duration 3600) 60)
+        seconds (mod duration 60)
+        millis (* 1000 (mod duration 1))]
+    (format "%02.0f:%02.0f:%02.0f.%03.0f" hours minutes seconds millis)))
+
 (defn- file-audio-channels
   "Return the number of audio channels for a given audio `file`"
   [file]
@@ -141,8 +153,8 @@
 (defn meta-data
   "Return a map containing all queried meta data for a given DAISY Talking Book"
   [dtb]
-  (let [keys [:multimedia_type :audio_format :audio_length]
-        fns [multimedia-type audio-format audio-length]]
+  (let [keys [:multimedia_type :audio_format :total_time]
+        fns [multimedia-type audio-format audio-total-time]]
     ;; of course we could look up the fn using (ns-resolve ns (symbol
     ;; (name kw))) but there is a balance between readybility and
     ;; cleverness


add rollbar to straight-jacket

add rollbar to straight-jacket

--- src/pc/utils.clj
+++ src/pc/utils.clj
@@ -42,10 +42,7 @@
            ~@body)
          (catch Object e#
            (log/error e# "1st straight jacket")
-           ;; need rollbar integration
-           ;; (rollbar/rollbar :exception (-> ~'&throw-context :throwable)
-           ;;                    :data {:cmd (str (quote ~body))})
-           ))
+           (rollbar/report-exception e#)))
         (catch Object _#
           (let [t# (-> ~'&throw-context :throwable)]
             (.printStackTrace ^Throwable t#)


Revert "Make `(sift :move)` create resources (#680)"

This reverts commit 37fa9fbc4d7ae60c7fd505f1e0352fe556e264e7.

--- boot/core/src/boot/task_helpers.clj
+++ boot/core/src/boot/task_helpers.clj
@@ -117,14 +117,12 @@
 (defmethod sift-action :move
   [_ _ args]
   (let [proc    #(reduce-kv string/replace % args)
-        mkreducer (fn [dir]
-                    (fn [xs k v]
-                      (let [k (proc k)]
-                        (assoc xs k (assoc v :path k :dir dir)))))]
+        reducer (fn [xs k v]
+                  (let [k (proc k)]
+                    (assoc xs k (assoc v :path k))))]
     (fn [fileset]
-      (let [dir (#'core/get-add-dir fileset #{:resource})]
-        (->> (partial reduce-kv (mkreducer dir) {})
-             (update-in fileset [:tree]))))))
+      (->> (partial reduce-kv reducer {})
+           (update-in fileset [:tree])))))

 (defmethod sift-action :add-jar
   [v? _ args]


Add section on native React interop

Add section on native React interop

--- demo/reagentdemo/news/news060.cljs
+++ demo/reagentdemo/news/news060.cljs
@@ -281,6 +281,24 @@
         section, you now have to specify "[:code "cljsjs/react-dom"]"
         and "[:code "cljsjs/react-dom-server"]" instead."]]

+       [:section.demo-text
+        [:h2 "Better interop with native React"]
+
+        [:p "The output of "[:code "create-class"]" can now be used
+        directly in JSX."]
+
+        [:p "”Native React components” can now be used directly in
+        Reagent’s hiccup forms, using this syntax: "[:code "[:>
+        nativeComp {:key \"value\"}]"]". This might sometimes be more
+        convenient than using "[:code "adapt-react-class"]". "]
+
+        [:p "Reagent should now also be a bit easier to use in
+        node.js. If global React is not
+        defined (i.e "[:code "React"]", "[:code "ReactDOM"]"
+        and "[:code "ReactDOMServer"]"), Reagent tries to
+        use "[:code "require"]" instead, to get react, react-dom and
+        react-dom/server from npm."]]
+
        ])]])

 (tools/register-page url [#'main] title)


fix order of stateless-transforms, add warning comment

--- src/chat/client/views/helpers.cljs
+++ src/chat/client/views/helpers.cljs
@@ -118,12 +118,14 @@
   "Given the text of a message body, turn it into dom nodes, making urls into
   links"
   [text]
-  (let [stateless-transform (map (comp
-                                   url-replace
-                                   user-replace
-                                   tag-replace
-                                   emoji-shortcodes-replace
-                                   emoji-ascii-replace))
+  (let [; Caution: order of transforms is important! url-replace should come before
+        ; user/tag replace at least so urls with octothorpes or at-signs don't get
+        ; wrecked
+        stateless-transform (map (comp emoji-ascii-replace
+                                       emoji-shortcodes-replace
+                                       tag-replace
+                                       user-replace
+                                       url-replace))
         statefull-transform (comp extract-code-blocks extract-code-inline extract-emphasized)]
     (->> (into [] (comp statefull-transform stateless-transform) (string/split text #" "))
          (interleave (repeat " "))


Fix submodule arguments call

Fix submodule arguments call

--- src/cider_ci/ex/git/submodules.clj
+++ src/cider_ci/ex/git/submodules.clj
@@ -64,11 +64,11 @@

 (declare update)

-(defn update-submodule [dir path bare-dir]
+(defn update-submodule [dir path bare-dir clone-options]
   (system/exec-with-success-or-throw
     ["git" "submodule" "update" "--init" "--reference" bare-dir path]
     {:dir dir :watchdog 10000})
-  (update (str dir (java.io.File/separator) path)))
+  (update (str dir (java.io.File/separator) path) clone-options))

  (defn update [dir clone-options]
    (doseq [[_ submodule] (gitmodules-conf dir)]
@@ -78,7 +78,7 @@
            commit-id (get-commit-id-of-submodule dir path)
            bare-dir (repository/serialized-initialize-or-update-if-required url commit-id)]
        (when (clone-path? path clone-options)
-         (update-submodule dir path bare-dir)))))
+         (update-submodule dir path bare-dir clone-options)))))

 ;### Debug #####################################################################
 ;(logging-config/set-logger! :level :debug)


add limit and offset to ents->json

add limit and offset to ents->json

--- src/clj/traveler/datomic/utils.clj
+++ src/clj/traveler/datomic/utils.clj
@@ -39,8 +39,19 @@
           {}
           convert-data))

-(defn ents->json [attr output-model]
-  (let [entities (ents attr)]
-    (map (fn ents->json- [e]
-           (generate-string (ent->map output-model e)))
-         entities)))
+(defn ents->json
+  ([attr output-model]
+   (let [entities (ents attr)]
+     (map (fn ents->json- [e]
+            (generate-string (ent->map output-model e)))
+          entities)))
+  ([attr output-model limit]
+   (let [entities (ents attr limit)]
+     (map (fn ents->json- [e]
+            (generate-string (ent->map output-model e)))
+          entities)))
+  ([attr output-model limit offset]
+   (let [entities (ents attr limit offset)]
+     (map (fn ents->json- [e]
+            (generate-string (ent->map output-model e)))
+          entities))))


fix acceptable income docs

fix acceptable income docs

--- src/cljs/apply/personal/views.cljs
+++ src/cljs/apply/personal/views.cljs
@@ -213,7 +213,7 @@
        [:p "We want to ensure that individuals interested in joining our
        communities are able to stay connected to other members without hiccups."]
        [:p "You can verify your income by providing your most recent pay stub,
-       last year's W2, or your bank statements for the past three months."]
+       an offer letter or your bank statements for the past three months."]
        [:div.form-container
         [:div.form-group
          [:label.label


RR: add hatti.views.overview import

RR: add hatti.views.overview import

--- src/cljs/hatti/views/dataview.cljs
+++ src/cljs/hatti/views/dataview.cljs
@@ -1,19 +1,20 @@
 (ns hatti.views.dataview
   (:require-macros [cljs.core.async.macros :refer [go]])
   (:require [cljs.core.async :refer [put!]]
-             [om.core :as om :include-macros true]
-             [sablono.core :as html :refer-macros [html]]
-             [hatti.ona.forms :as f]
-             [hatti.shared :as shared]
-             [hatti.views :refer [tabbed-dataview
-                                  dataview-infobar dataview-actions
-                                  map-page table-page chart-page details-page
-                                  overview-page]]
-             [hatti.views.map]
-             [hatti.views.table]
-             [hatti.views.chart]
-             [hatti.views.details]
-             [hatti.utils :refer [click-fn pluralize-number]]))
+            [om.core :as om :include-macros true]
+            [sablono.core :as html :refer-macros [html]]
+            [hatti.ona.forms :as f]
+            [hatti.shared :as shared]
+            [hatti.views :refer [tabbed-dataview
+                                 dataview-infobar dataview-actions
+                                 map-page table-page chart-page details-page
+                                 overview-page]]
+            [hatti.views.map]
+            [hatti.views.table]
+            [hatti.views.chart]
+            [hatti.views.details]
+            [hatti.views.overview]
+            [hatti.utils :refer [click-fn pluralize-number]]))

 (def dataview-map
   {:overview {:view "overview"


show stack trace on test failure

show stack trace on test failure

--- src/cljs/wilkerdev/util/macros.clj
+++ src/cljs/wilkerdev/util/macros.clj
@@ -29,4 +29,4 @@
        ~@body
        (.log js/console "Passed:" ~title)
        (catch js/Error e#
-         (.log js/console "Failed:" ~title ":" e#)))))
+         (.log js/console "Failed:" ~title ":" (.-stack e#))))))


Add IDeref implementation for exception success and error.

--- src/cljx/cats/monad/exception.cljx
+++ src/cljx/cats/monad/exception.cljx
@@ -52,6 +52,16 @@
   (get-value [_] v)

   #+clj
+  clojure.lang.IDeref
+  #+clj
+  (deref [_] v)
+
+  #+cljs
+  IDeref
+  #+cljs
+  (-deref [_] v)
+
+  #+clj
   Object
   #+clj
   (equals [self other]
@@ -76,6 +86,16 @@
   proto/Context
   (get-context [_] exception-monad)
   (get-value [_] e)
+
+  #+clj
+  clojure.lang.IDeref
+  #+clj
+  (deref [_] e)
+
+  #+cljs
+  IDeref
+  #+cljs
+  (-deref [_] e)

   #+clj
   Object


add sparse instance creation

add sparse instance creation

--- src/clojure/zensols/model/weka.clj
+++ src/clojure/zensols/model/weka.clj
@@ -214,6 +214,55 @@
        :attrib-count attrib-count
        :label-attrib label-attrib})))

+(defn sparse-instances
+  "Create a sparse `core.weka.Instance` using a sequence of maps (`map`).
+  The keys of the maps are the class with the values maps each with the key as
+  the index and the value the weight.  The `dim` parameter is the dimension of
+  each instance.
+
+  Keys
+  ----
+  * **:pattern** a [[format]] using one integer as the index (default: `f%d`)
+  * **:class-attribute** the name of the output class (values are given from the keys of `maps`)
+  * **instance-name** the name of the `Instance` created object and defaults to `inst`
+  * **:add-class?** if `true` add the class that comes from the key in **maps**
+  * **default-value** if a double replace missing values not in th emap with
+  this value, otherwise missing values will be used"
+  [maps dim & {:keys [pattern class-attribute-name instance-name
+                      add-class? default-value]
+               :or {pattern "f%d"
+                    class-attribute-name "class"
+                    instance-name "inst"
+                    add-class? true}}]
+  (let [labels (-> maps keys)
+        label-map (zipmap labels (range (count labels)))
+        label-attrib (classifier-label-attrib [class-attribute-name labels])
+        attrib-vec (FastVector. (inc dim))
+        def-array (if default-value
+                    (into-array Double/TYPE (repeat (inc dim) default-value)))]
+    (->> (range dim)
+         (map #(format pattern %))
+         (map #(create-attrib % 'numeric))
+         (map #(.addElement attrib-vec %))
+         doall)
+    (.addElement attrib-vec label-attrib)
+    (let [insts (Instances. instance-name attrib-vec 0)]
+      (->> maps
+           (map (fn [[name weights]]
+                  (let [inst (weka.core.Instance. (inc dim))]
+                    (->> weights
+                         (map (fn [[idx weight]]
+                                (.setValueSparse inst idx weight)))
+                         doall)
+                    (if add-class?
+                     (.setValueSparse inst (.index label-attrib) (label-map name)))
+                    (if def-array
+                      (.replaceMissingValues inst def-array))
+                    (.add insts inst)
+                    (.setClassIndex insts (.index label-attrib)))))
+           doall)
+      insts)))
+
 (defn- populate-instance
   "Populate an `Instance` with data from a map for a set of attributes.

@@ -490,14 +539,3 @@
                  ~sym- res#]
              ~@forms))
          (finally (remove-ns ns-sym#))))))
-
-(defn word-count-instances
-  "Create an instances "
-  [inst & {:keys [word-count lower-case]
-           :or {word-count true
-                lower-case false}}]
-  (Filter/useFilter inst
-                    (doto (StringToWordVector.)
-                      (.setInputFormat inst)
-                      (.setOutputWordCounts word-count)
-                      (.setLowerCaseTokens lower-case))))


Replaced Jdbc4Array with PgArray because of internal API changes

--- frameworks/Clojure/luminus/hello/src/hello/db/core.clj
+++ frameworks/Clojure/luminus/hello/src/hello/db/core.clj
@@ -6,7 +6,7 @@
     [environ.core :refer [env]]
     [mount.core :refer [defstate]])
   (:import org.postgresql.util.PGobject
-           org.postgresql.jdbc4.Jdbc4Array
+           org.postgresql.jdbc.PgArray
            clojure.lang.IPersistentMap
            clojure.lang.IPersistentVector
            [java.sql
@@ -48,7 +48,7 @@
   Timestamp
   (result-set-read-column [v _ _] (to-date v))

-  Jdbc4Array
+  PgArray
   (result-set-read-column [v _ _] (vec (.getArray v)))

   PGobject


rdf:Property not rdfs:Property!

rdf:Property not rdfs:Property!

--- src/grafter/rdf/ontologies/rdf.clj
+++ src/grafter/rdf/ontologies/rdf.clj
@@ -7,7 +7,7 @@

 (def rdf:a (rdf "type"))

-(def rdf:Property (rdfs "Property"))
+(def rdf:Property (rdf "Property"))
 (def rdfs:subPropertyOf (rdfs "subPropertyOf"))

 (def rdfs:Class (rdfs "Class"))


Defend against bad property details data.

--- src/kixi/hecuba/api/properties.clj
+++ src/kixi/hecuba/api/properties.clj
@@ -24,6 +24,15 @@
                              (keep identity)
                              (map #(clojure.string/replace % ".jpg" ".png"))))
     property_data))
+
+;; FIXME: This is only here because the data is currently dirty and
+;; some of the property data is in edn rather than json.
+(defn parse-property-data [property_data]
+  (try
+    (json/parse-string property_data keyword)
+    (catch Throwable t
+      (log/errorf "Got edn property data when we expected json: %s" property_data)
+      (edn/read-string property_data))))

 (defn- property-devices [entity_id session]
   (if-let [devices (db/execute session
@@ -52,7 +61,7 @@
                        (map #(assoc %
                                :property_data (if-let [property_data (:property_data %)]
                                                 (-> property_data
-                                                    (json/parse-string keyword)
+                                                    parse-property-data
                                                     tech-icons)
                                                 {})
                                :photos (if-let [photos (:photos %)] (mapv (fn [p] (json/parse-string p keyword)) photos) [])


Add comfort functions to reset search results

--- src/discuss/components/search/statements.cljs
+++ src/discuss/components/search/statements.cljs
@@ -69,6 +69,17 @@
   "Reset the search results."
   []
   (set-search-results! []))
+
+(defn remove-selected-search-result!
+  "Remove currently selected search result."
+  []
+  (om/transact! parser/reconciler `[(search/selected {:value ~nil})]))
+
+(defn remove-all-search-related-results-and-selections
+  "Clear list of results and currently selected search result."
+  []
+  (om/transact! parser/reconciler `[(search/selected {:value ~nil})
+                                    (search/results {:value []})]))

 (defn- handle-dbas-search-results
   "Handler which is called with the results from ElasticSearch. Extract statements


Added newline.

Added newline.

--- src/hxgm30/language/syntagmata/lang/merge.clj
+++ src/hxgm30/language/syntagmata/lang/merge.clj
@@ -121,4 +121,5 @@
   (let [sys (system-manager/system)
         world (keyword (first args))
         language (keyword (second args))]
-    (run sys world language)))
+    (run sys world language)
+    (println)))


clean number ops

clean number ops

--- src/jvm/clojure/lang/platform/equivalence.clj
+++ src/jvm/clojure/lang/platform/equivalence.clj
@@ -29,9 +29,9 @@

 (extend-type Short
   NumberCoercions
-  (->short [this] this)
-  (->int   [this] (.intValue this))
-  (->long  [this] (.longValue this))
+  (->short  [this] this)
+  (->int    [this] (.intValue this))
+  (->long   [this] (.longValue this))
   (->float  [this] (.floatValue this))
   (->double [this] (.doubleValue this))
   (->bigint [this] (BigInteger. (.toString this)))
@@ -73,7 +73,7 @@

 (extend-type Float
   NumberCoercions
-  (->float [this] this)
+  (->float  [this] this)
   (->double [this] (.doubleValue this))
   (->bigdec [this] (BigDecimal. (.doubleValue this))))


improve logging

improve logging

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -78,7 +78,7 @@
   (log/trace (str "generate-all: generating from spec with cat "
                   (get-in spec [:synsem :cat])))
   (log/debug (str "generate-all:"
-                  (strip-refs spec) "^" total-depth))
+                  (strip-refs (get-in spec [:synsem :cat])) "^" total-depth))

   (let [total-depth (if total-depth total-depth 0)]
     (->
@@ -103,9 +103,8 @@
       (add-all-comps-with-paths
        (lazy-mapcat
         (fn [bolt]
-          (log/debug (str "+comps: '" ((:morph language-model) bolt) "'@"
-                          "[" (string/join " " path) "]"
-                          "^" total-depth))
+          (log/debug (str "add-all-comps-with-paths: " (show-bolt bolt path language-model)
+                          "@[" (string/join " " path) "]" "^" total-depth))
           (add-complement-to-bolt bolt path
                                   language-model (+ total-depth (count path))
                                   :max-total-depth max-total-depth))
@@ -123,8 +122,8 @@
 (defn add-complement-to-bolt [bolt path language-model total-depth
                               & {:keys [max-total-depth]
                                  :or {max-total-depth max-total-depth}}]
-  (log/debug (str "add-complement-to-bolt: " (show-bolt bolt path language-model) "@"
-                  "[" (string/join " " path) "]" "^" total-depth))
+  (log/debug (str "add-complement-to-bolt: " (show-bolt bolt path language-model)
+                  "@[" (string/join " " path) "]" "^" total-depth))
   (let [index (:index language-model)
         lexicon (:lexicon language-model)
         from-bolt bolt ;; so we can show what (add-complement-to-bolt) did to the input bolt, for logging.


+TODOs

+TODOs

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -89,6 +89,7 @@
        (lightning-bolts language-model spec 0 total-depth :max-total-depth max-total-depth)
        (add-all-comps language-model total-depth false max-total-depth)))))

+;; TODO: catch exception thrown by add-complement-by-bolt: "could generate neither phrasal nor lexical complements for bolt"
 (defn add-all-comps [bolts language-model total-depth truncate-children max-total-depth]
   (log/trace (str "add-all-comps with (empty? bolts): " (empty? bolts)))
   (lazy-mapcat
@@ -99,6 +100,7 @@
                                truncate-children max-total-depth))
    bolts))

+;; TODO: make this non-recursive by using mapcat.
 (defn add-all-comps-with-paths [bolts language-model total-depth comp-paths truncate-children max-total-depth]
   (if (not (empty? comp-paths))
     (let [path (first comp-paths)


more simplification

more simplification

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -152,9 +152,7 @@
                   comp-bolts (pmap #(comp-path-to-bolts bolt-at % model (+ 1 depth) max-depth)
                                    comp-paths)]
               (when (not (some empty? comp-bolts))
-                (mapfn #(if (= bolt bolt-at)
-                          %
-                          (assoc-in bolt path %))
+                (mapfn #(assoc-in bolt path %)
                        (add-comps bolt-at
                                   model
                                   comp-paths


Updating listen (so that it can work even when there's no stdin present)

--- jvm-runner/test/codewars/zmq_test.clj
+++ jvm-runner/test/codewars/zmq_test.clj
@@ -41,24 +41,25 @@
       (is (= {:result nil, :stderr "", :stdout "blorg\n"} @server)))))

 (deftest main-check
-  (let [main (future-call -main)]
-    (with-open
-        [req (doto (zmq/socket (zmq/zcontext) :req)
-               (zmq/bind codewars.zmq/addr))]
-      (testing "main wraps a ping"
-        (zmq/send-str req (json/generate-string "PONG"))
-        (is (= (json/parse-string (String. (zmq/receive req)))
-               {"type"   "status"
-                "status" "ready"
-                "message" "PONG"})))
-      (testing "main responds to a request"
-        (zmq/send-str req
-                      (json/generate-string
-                       {:language "java"
-                        :code "class AwesomeSauce { static int main(String [] args) {return 1;} }"}))
-        (is (= (json/parse-string (String. (zmq/receive req)))
-               {"type" "execution response",
-                "result" 1,
-                "stderr" "",
-                "stdout" ""})))
-      (is (= {:result 1, :stderr "", :stdout ""} @main)))))
+  (with-redefs [codewars.stdin/listen #(Thread/sleep 1000000)]
+    (let [main (future-call -main)]
+      (with-open
+          [req (doto (zmq/socket (zmq/zcontext) :req)
+                 (zmq/bind codewars.zmq/addr))]
+        (testing "main wraps a ping"
+          (zmq/send-str req (json/generate-string "PONG"))
+          (is (= (json/parse-string (String. (zmq/receive req)))
+                 {"type"   "status"
+                  "status" "ready"
+                  "message" "PONG"})))
+        (testing "main responds to a request"
+          (zmq/send-str req
+                        (json/generate-string
+                         {:language "java"
+                          :code "class AwesomeSauce { static int main(String [] args) {return 1;} }"}))
+          (is (= (json/parse-string (String. (zmq/receive req)))
+                 {"type" "execution response",
+                  "result" 1,
+                  "stderr" "",
+                  "stdout" ""})))
+        (is (= {:result 1, :stderr "", :stdout ""} @main))))))


Don't assume Go.cd is hosted under /go. Fixes #11

--- src/buildviz/gosync.clj
+++ src/buildviz/gosync.clj
@@ -169,10 +169,12 @@
       (list (:url file-node))
       [])))

-(defn replace-host-part-for-basic-auth [url]
+(defn replace-file-url-host-part-for-basic-auth [url]
   ;; Replace host part with go url supplied by user
   ;; Also works around broken Go domain setup
-  (clojure.string/replace url #"https?://[^/]+/go" go-url))
+  (clojure.string/replace url
+                          #"https?://[^/]+(/.+?)?/files/"
+                          (clojure.string/join [go-url "/files/"])))

 (defn try-get-artifact-tree [{pipeline-name :pipelineName
                               pipeline-run :pipelineRun
@@ -190,7 +192,7 @@

 (defn xml-artifacts-for-job-run [job-instance]
   (let [file-tree (try-get-artifact-tree job-instance)]
-    (map replace-host-part-for-basic-auth
+    (map replace-file-url-host-part-for-basic-auth
          (mapcat filter-xml-files file-tree))))

 (defn augment-job-instance-with-junit-xml [job-instance]


defconsts is the only really sane API

defconsts is the only really sane API

--- src/caesium/binding.clj
+++ src/caesium/binding.clj
@@ -113,23 +113,14 @@
   (symbol (str "." c-name)))

 (defmacro defconsts
-  "Given constant names (syms) in the C pseudo-namespace corresponding
-  to the current namespace, call the corresponding libsodium function
-  the get the constants and assign them to vars."
+  "Define a number of constants by name.
+
+  Uses the *ns* to figure out the const-returning fn in libsodium."
   [consts]
   `(do ~@(for [const consts
-               :let [c-name (c-name *ns* const)]]
+               :let [c-name (c-name *ns* const)
+                     docstring (str "Constant returned by `" c-name "`. "
+                                    "See libsodium docs.")]]
            `(def ~const
+              ~docstring
               (~(java-call-sym c-name) sodium)))))
-
-(defmacro defbindings
-  "Creates relevant bindings in the C pseudo-namespace corresponding
-  to the current namespace."
-  [fs]
-  `(do ~@(for [f fs
-               :let [c-name (c-name *ns* f)
-                     args (->> (bound-fns c-name)
-                               (mapv (fn [args] (with-meta args {}))))]]
-           `(defn ~f
-              ~args
-              (~(java-call-sym c-name) sodium ~@args)))))


render-author-week-repo-page

render-author-week-repo-page

--- src/arachnida/html_renderer.clj
+++ src/arachnida/html_renderer.clj
@@ -171,11 +171,12 @@
                 [:h3 (str "Status for week: " selected-week)]
                 [:table {:class "table table-condensed table-hover table-bordered" :rules "all"}
                     [:tr [:th {:colspan 3} "Week statistic"]]
-                    [:tr [:th "Repository"] [:th "Commits"] [:th "Files"] [:th "Insertions"] [:th "Deletions"]]
+                    [:tr [:th "Product"] [:th "Repository"] [:th "Commits"] [:th "Files"] [:th "Insertions"] [:th "Deletions"]]
                 (for [s (:statistic-for-week stat-for-week)]
                     [:tr
-                         [:td (:reponame s)]
-                         [:td (:commits s)]
+                         [:td (:product s)]
+                         [:td [:a {:href (str "/author-week-repo?name=" author-name "&week=" selected-week "&product=" (:product s) "&repo=" (:reponame s)) } (:reponame s)]]
+                         [:td [:a {:href (str "/author-week-repo?name=" author-name "&week=" selected-week "&product=" (:product s) "&repo=" (:reponame s)) } (:commits s)]]
                          [:td (:files s)]
                          [:td (:insertions s)]
                          [:td (:deletions s)]
@@ -187,3 +188,30 @@
         ] ; </body>
     ))

+(defn render-author-week-repo-page
+    [author-name selected-week stat-for-week product repo]
+    (page/xhtml
+        (render-html-header)
+        [:body
+            [:div {:class "container"}
+                (render-navigation-bar-section)
+                [:h1 (str "Author: " author-name)]
+                [:h3 (str "Status for week: " selected-week)]
+                [:h3 (str "Product " product)]
+                [:h3 (str "Repository: " repo)]
+                [:br][:br][:br][:br]
+                [:table {:class "table table-condensed table-hover table-bordered" :rules "all"}
+                    [:tr [:th "Date"] [:th "Message"] [:th "sha"]]
+                (for [c (:commits-for-week stat-for-week) :when (and (= repo (:repo c))
+                                                                     (= product (:product c)))]
+                    [:tr
+                         [:td (:date c)]
+                         [:td (:message c)]
+                         [:td (:sha c)]
+                     ])
+                ]
+                (render-html-footer)
+            ] ; </div class="container">
+        ] ; </body>
+    ))
+


Update compression codec ns.

Update compression codec ns.

--- src/multicodec/codecs/compress.clj
+++ src/multicodec/codecs/compress.clj
@@ -12,57 +12,30 @@
       GZIPOutputStream)))

-(defrecord CompressionCodec
-  [header codec wrap-input wrap-output]
+;; ## GZIP

-  codec/Encoder
+(defcodec GZIPCodec
+  [header]

-  (encodable?
-    [this value]
-    (codec/encodable? codec value))
+  (processable?
+    [this hdr]
+    (= hdr header))

-  (encode!
-    [this output value]
-    (codec/encode! codec (wrap-output output) value))
+  (encode-stream
+    [this _ stream]
+    ; TODO: assert stream is an OutputStream
+    (codec/write-header! stream header)
+    (GZIPOutputStream. ^OutputStream stream))

-  codec/Decoder
-
-  (decodable?
-    [this header']
-    (codec/decodable? codec header'))
-
-
-  (decode!
-    [this input]
-    (codec/decode! codec (wrap-input input))))
-
-
-(alter-meta! #'->CompressionCodec assoc :private true)
-(alter-meta! #'map->CompressionCodec assoc :private true)
-
-
-(defn compress-codec
-  "Creates a new compression codec, wrapping the given codec. The wrapper
-  functions are called on the input and output streams passed to the next
-  codec.
-
-  - `:header` string which overrides inheriting the codec's header
-  - `:input` function which will transform bytes after they are encoded
-  - `:output` function which will transform bytes before they are decoded"
-  [codec & {:as opts}]
-  (->FilterCodec
-    (:header opts)
-    codec
-    (:input opts)
-    (:output opts)))
+  (decode-stream
+    [this _ stream]
+    ; TODO: assert stream is an InputStream
+    (GZIPInputStream. ^InputStream stream)))

 (defn gzip-codec
   "Creates a compression codec which will apply GZIP to the encoded data."
   [codec]
-  (compress-codec codec
-    :header "/gzip"
-    :input #(GZIPInputStream. ^InputStream %)
-    :output #(GZIPOutputStream. ^OutputStream %)))
+  (->GZIPCodec "/gzip/"))


+head-is-conjugated-and-present-infl

+head-is-conjugated-and-present-infl

--- src/babel/francais/grammar.cljc
+++ src/babel/francais/grammar.cljc
@@ -411,15 +411,16 @@

                    ;; [nous [être + naître]] => nous somme nées
                    (unify h22
-                           root-is-comp
-                           (let [obj-agr (atom :top)] ;; TODO: Remove: this obj-agr is not used.
-                             {:head {:phrasal false}
-                              :rule "vp-aux-22"
-                              :synsem {:aux true
-                                       :cat :verb
-                                       :infl :present
-                                       :sem {:reflexive true
-                                             :tense :past}}}))
+                          root-is-comp
+                          head-is-conjugated-and-present-infl
+                          (let [obj-agr (atom :top)] ;; TODO: Remove: this obj-agr is not used.
+                            {:head {:phrasal false}
+                             :rule "vp-aux-22"
+                             :synsem {:aux true
+                                      :cat :verb
+                                      :infl :present
+                                      :sem {:reflexive true
+                                            :tense :past}}}))
                    (unify h21
                            {:rule "vp-future"
                             :synsem {:aux false


+(defn model)

+(defn model)

--- src/babel/italiano/grammar.cljc
+++ src/babel/italiano/grammar.cljc
@@ -540,6 +540,30 @@
                 (filter #(not (= false (get-in % [:generate-with] true))) v)]
             (if (not (empty? filtered-v))
               [k filtered-v])))))
+
+(defn model [lexicon-filter-fn grammar-filter-fn]
+  "create a model using a lexicon derived from the supplied filtering function."
+  (let [lexicon
+        (into {}
+              (for [[k v] @lexicon]
+                (let [filtered-v
+                      (filter lexicon-filter-fn v)]
+                  (if (not (empty? filtered-v))
+                    [k filtered-v]))))
+        grammar (filter grammar-filter-fn grammar)]
+    {:language "it"
+     :language-keyword :italiano
+     :morph fo
+     :morph-ps (fn [arg] (fo-ps1 arg))
+     :lookup (fn [arg]
+               (analyze arg lexicon))
+     :enrich enrich
+     :generate {:lexicon lexicon}
+     :grammar grammar
+     :lexicon lexicon
+     :lexical-cache (atom (cache/fifo-cache-factory {} :threshold 1024))
+     :index (create-index grammar (flatten (vals lexicon)) head-principle)}))
+
 (def small
   (future
     (let [lexicon @lexicon


fix typo

fix typo

--- src/babel/italiano/lexicon.cljc
+++ src/babel/italiano/lexicon.cljc
@@ -1607,9 +1607,8 @@
                          :present {:1sing "ottengo"
                                    :2sing "ottieni"
                                    :3sing "ottiene"
-                                   :3plur "otttengono"}
+                                   :3plur "ottengono"}
                          :future-stem "otterr"}}
-
    "pane"
    ;; inherently singular.
    (unify agreement-noun


make read-attributes work on windows

make read-attributes work on windows

--- src/brainbot/nozzle/real_fs.clj
+++ src/brainbot/nozzle/real_fs.clj
@@ -19,13 +19,18 @@
 (def ^:private no-follow-links
   (into-array [LinkOption/NOFOLLOW_LINKS]))

+(def ^:private empty-link-options
+  (into-array java.nio.file.LinkOption []))
+
 (defn- get-path
   [path & args]
   (Paths/get path (into-array String args)))

-(defn- read-attributes
-  [path]
-  (Files/readAttributes (get-path path) PosixFileAttributes no-follow-links))
+(let [klass (if is-windows BasicFileAttributes PosixFileAttributes)
+      link-options (if is-windows empty-link-options no-follow-links)]
+  (defn- read-attributes
+    [path]
+    (Files/readAttributes (get-path path) klass link-options)))

 (defn- type-from-attribute
   [attr]


move user to other group if they get kicked

--- src/chat/client/dispatcher.cljs
+++ src/chat/client/dispatcher.cljs
@@ -6,6 +6,7 @@
             [chat.client.schema :as schema]
             [chat.shared.util :as util]
             [chat.client.router :as router]
+            [chat.client.routes :as routes]
             [chat.client.xhr :refer [edn-xhr]]
             [braid.desktop.notify :as notify]))

@@ -332,7 +333,6 @@
 (defmethod sync/event-handler :user/left-group
   [[_ [group-id group-name]]]
   (store/remove-group! {:id group-id})
-  ; TODO: move the user if they're current in that group?
   (store/display-error!
     (str "left-" group-id)
     (str "You have been removed from " group-name)
@@ -340,7 +340,9 @@
   (when-let [sidebar-order (:groups-order (store/user-preferences))]
     (store/add-preferences!
       {:groups-order (into [] (remove (partial = group-id))
-                           sidebar-order)})))
+                           sidebar-order)}))
+  (when (= group-id (store/open-group-id))
+    (routes/go-to! (routes/index-path))))

 (defmethod sync/event-handler :user/connected
   [[_ user-id]]


Swagger info

Swagger info

--- src/clj/salava/core/plugins.clj
+++ src/clj/salava/core/plugins.clj
@@ -7,6 +7,13 @@
                      :routes (fn [~'ctx]
                                (api {:components {:context ~'ctx}}
                                     (swagger-ui "/swagger-ui")
-                                    (swagger-docs {:info {:title "Salava public API" :description ""}})
+                                    (swagger-docs {:info  {:version "0.1.0"
+                                                           :title "Salava public API"
+                                                           :description ""
+                                                           :contact  {:name "Discendum Oy"
+                                                                      :email "contact@openbadgepassport.com"
+                                                                      :url "http://salava.org"}
+                                                           :license  {:name "Apache 2.0"
+                                                                      :url "http://www.apache.org/licenses/LICENSE-2.0"}}})
                                     ~@router
                                     salava.core.routes/route-def))})))


Expose SPARQL language constructs via the API

--- src/clj/sparqlab/routes/api.clj
+++ src/clj/sparqlab/routes/api.clj
@@ -9,7 +9,8 @@
             [clj-http.client :as client]
             [slingshot.slingshot :refer [try+]]
             [ring.util.response :refer [response]]
-            [cheshire.core :refer [generate-string]]))
+            [cheshire.core :refer [generate-string]]
+            [clojure.set :as set]))

 (defn sparql-query
   "Execute a SPARQL query in an HTTP GET request using `params` and HTTP `headers`."
@@ -38,6 +39,18 @@
     (cond-> (response solution)
       (not= exercise-status "solved") (cookie/mark-exercise-as-revealed id))))

+(defn get-sparql-constructs
+  "Get SPARQL language constructs with labels in given `lang`."
+  [lang]
+  (let [sparql-constructs (-> "get_sparql_constructs"
+                              (sparql/sparql-template {:language lang})
+                              store/select-query)
+        format-construct (fn [construct]
+                           (-> construct
+                               (dissoc :lang)
+                               (set/rename-keys {:construct :value})))]
+    (generate-string (map format-construct sparql-constructs))))
+
 (defroutes api-routes
   (context "/api" []
            (GET "/query"
@@ -47,4 +60,7 @@
            (GET "/exercise-solution"
                 {{id :id} :params
                  :as request}
-                (get-exercise-solution request id))))
+                (get-exercise-solution request id))
+           (GET "/sparql-constructs"
+                {lang :accept-lang}
+                (get-sparql-constructs lang))))


Fix hunger/thirst for crafting

Fix hunger/thirst for crafting

--- src/cljc/robinson/crafting.cljc
+++ src/cljc/robinson/crafting.cljc
@@ -180,10 +180,10 @@
                         state)
                       (add-by-ids state add (get recipe :place :inventory))
                       (exhaust-by-ids state exhaust)
-                      (rp/player-update-hunger (fn [current-hunger] (min (+ hunger current-hunger)
-                                                                         (rp/player-max-hunger state))))
-                      (rp/player-update-thirst (fn [current-thirst] (min (+ hunger current-thirst)
-                                                                         (rp/player-max-thirst state))))
+                      (rp/player-update-hunger state (fn [current-hunger] (min (+ hunger current-hunger)
+                                                                               (rp/player-max-hunger state))))
+                      (rp/player-update-thirst state (fn [current-thirst] (min (+ hunger current-thirst)
+                                                                               (rp/player-max-thirst state))))
                       (reduce rp/update-crafted state (map (fn [id] {:id id}) add)))]
           state)
         (rc/ui-hint state (format "You have multiple items that can be used to make this. Wield one of them")))


try using just data from my server

try using just data from my server

--- src/cljs/montheway/mmodern.cljs
+++ src/cljs/montheway/mmodern.cljs
@@ -225,7 +225,8 @@
      (let [yelp-url (str "http://localhost:3000/yelp-bounds?bounds="
                                    (:sw-lat map-bounds) "," (:sw-lng map-bounds) "|"
                                    (:ne-lat map-bounds) "," (:ne-lng map-bounds))
-           yelp-response (<! (http/get yelp-url))
+           yelp-url-2 "http://dipity.bennetthiles.com/yelp-bounds?bounds=45.5179568%2C-122.6886258%7C45.5357952%2C-122.6762918"
+           yelp-response (<! (http/get yelp-url-2))
            businesses (-> yelp-response :body)
            relevant-biz (->> businesses
                              (find-businesses-on-the-way lat-lngs)


fix start/end points in mobile cljs

fix start/end points in mobile cljs

--- src/cljs/montheway/mmodern.cljs
+++ src/cljs/montheway/mmodern.cljs
@@ -243,8 +243,8 @@
   [{:start-lat :start-lng :end-lat :end-lng}, ...]"
   (go
    (let [lat-lngs (<! (fetch-mapquest-lat-lngs to from))
-         start-point (-> lat-lngs first (select-keys [:start-lat :start-lng]) vals)
-         end-point (-> lat-lngs last (select-keys [:end-lat :end-lng]) vals)
+         end-point (-> lat-lngs first (select-keys [:start-lat :start-lng]) vals)
+         start-point (-> lat-lngs last (select-keys [:end-lat :end-lng]) vals)
          last-lat-lng (last lat-lngs)
          lines (concat
                 (map


Add type hints to some functions on core.keys namespace

--- src/clojure/buddy/core/keys.clj
+++ src/clojure/buddy/core/keys.clj
@@ -23,7 +23,7 @@
  (org.bouncycastle.jce.provider.BouncyCastleProvider.))

 (defn read-pem->privkey
-  [reader passphrase]
+  [reader ^String passphrase]
   (let [parser    (PEMParser. reader)
         keypair   (.readObject parser)
         converter (doto (JcaPEMKeyConverter.)
@@ -44,7 +44,7 @@
     (.getPublicKey converter keyinfo)))

 (defn private-key
-  [^String path & [passphrase]]
+  [^String path & [^String passphrase]]
   (with-open [reader (io/reader path)]
     (.getPrivate
       (read-pem->privkey reader passphrase))))


Added file watching and hot reloading for imap server

--- src/clojure/neveragain/imap.clj
+++ src/clojure/neveragain/imap.clj
@@ -3,7 +3,7 @@
     (clojure [string :as string]
              [set :as set-lib]
              [pprint :as pprint])
-    (clojure.core [async :refer [>! <! >!! alts! go go-loop]])
+    (clojure.core [async :refer [>! <! >!! alts! go go-loop chan]])
     (swiss [arrows :refer :all])
     (clojure.java [jdbc :as j])
     (neveragain [common :as common]
@@ -14,6 +14,7 @@
                 [async-serv :as as]))
   (:import
     (java.util Date)
+    (java.io File)
     (org.mindrot.jbcrypt BCrypt)))

 (defn pnr [x] (println x) x)
@@ -600,21 +601,23 @@
                   "LOGOUT" (wrap-pure-imap-verb logout)
                   "UID" (wrap-pure-imap-verb uid-mux)})

+(def reload-chan (chan 2))
+
 (defn connection-handler
   [r-chan w-chan]
   (>!! w-chan
        "* OK Hail! ChainMail IMAP server at thine service my liege!\r\n")
-  (go-loop [read-val (<! r-chan)
+  (go-loop [[read-val source] (alts! [r-chan reload-chan])
             session {}]
     (try
       (let [[line tag verb args] (re-matches #"(.+?)\s(\S+)\s?(.+)?" read-val)]
         (if-not line
           (do
             (>!! w-chan "* BAD Hark knave, thine command parses not!\r\n")
-            (recur (<! r-chan) session))
+            (recur (alts! [r-chan reload-chan]) session))
           (let [handler (get handler-map (.toUpperCase verb) null-verb)
                 new-session (handler session r-chan w-chan [line tag verb args])]
-            (recur (<! r-chan) new-session))))
+            (recur (alts! [r-chan reload-chan]) new-session))))
       (catch Exception e
         (do
           (>!! w-chan
@@ -622,9 +625,21 @@
           (println "Wowah, exception:\n" e)
           (.printStackTrace e))))))

+(def imap-ns (ns-name *ns*))

 (defn serve-forever
   [port]
+  (if (pos?  settings/reload-interval)
+    (future ; Run the reloader in another thread
+      (loop [file (File. "src/clojure/neveragain/imap.clj")
+             last-mod (.lastModified file)]
+        (Thread/sleep (* settings/reload-interval 1000))
+        (if (> (.lastModified file) last-mod)
+          (do
+            (println "Reloading imap namespace")
+            (require imap-ns :reload)
+            (recur file (.lastModified file)))
+          (recur file last-mod)))))
   (as/serve-forever port connection-handler))

 (defn -main [& args]


disallow opening non-whitelisted file types on Java 6 or lower

--- src/clojure/nightcode/utils.clj
+++ src/clojure/nightcode/utils.clj
@@ -136,15 +136,14 @@
                           (into-array Class param-classes))
       (.invoke nil (into-array Object args))))

-(def ^:const max-length (* 1024 1024 10))
-
 (defn is-text-file?
   "Returns true if the file is of type text, false otherwise."
   [^File file]
-  (if-let [files-klass (Class/forName "java.nio.file.Files")]
-    (let [path-klass (Class/forName "java.nio.file.Path")]
-      (-> files-klass
-          (call-static-method "probeContentType" [path-klass] (.toPath file))
-          (or "")
-          (.startsWith "text")))
-    (< (.length file) max-length)))
+  (try (let [files-klass (Class/forName "java.nio.file.Files")
+             path-klass (Class/forName "java.nio.file.Path")]
+         (-> files-klass
+             (call-static-method "probeContentType" [path-klass] (.toPath file))
+             (or "")
+             (.startsWith "text")))
+       (catch ClassNotFoundException _
+         false)))


Adding more error handling

Adding more error handling

--- src/com/okl/tokenmgr/tokens.clj
+++ src/com/okl/tokenmgr/tokens.clj
@@ -7,6 +7,13 @@

 (def base-path "/applications")
 (def storage (get-container))
+
+(defn- read-json-str [data]
+  "try to read json data, and error with the bad json if there's an error"
+  (try
+    (json/read-str data)
+    (catch Exception e
+      (throw (IllegalStateException. (str "Error processsing " data ":\n" (.getMessage e)))))))

 (defn- coalesce-map [map1 map2]
   "recursively merge maps"
@@ -24,7 +31,7 @@
   (let [value (:value data)]
     (if (empty? value)
       ""
-      (get (json/read-str value) "type"))))
+      (get (read-json-str value) "type"))))

 (defn- token? [data]
   "returns true if the json provided is of type token"
@@ -32,7 +39,10 @@

 (defn- app? [data]
   "returns true if the json provided is of type application"
-  (= "application" (get-type data)))
+  (try
+    (= "application" (get-type data))
+    (catch IllegalStateException e
+       (throw (IllegalStateException. (str "Unable to determine if " data " is an app:\n" (.getMessage e)))))))

 (defn- path->full-path [path]
   "adds the base path back in"
@@ -62,7 +72,7 @@
         item (.get-item storage (path->full-path app))
         old-json (if (empty? item)
                    {}
-                   (walk/keywordize-keys (json/read-str (:value item))))
+                   (walk/keywordize-keys (read-json-str (:value item))))
         json (json/write-str
               {:type "application"
                :description description})]
@@ -86,7 +96,7 @@
         item (.get-item storage full-path)
         json (if (empty? item)
                {}
-               (walk/keywordize-keys (json/read-str (:value item))))
+               (walk/keywordize-keys (read-json-str (:value item))))
         new-json {:description description
                   :values {(keyword good-envt) {:value value :source path}}
                   :type "token"}
@@ -104,7 +114,7 @@
   (let [full-path (path->full-path path)]
   (map
    #(hash-map :name (subs (get % :name) (inc (count base-path)))
-              :description (get (json/read-str (get % :value)) "description"))
+              :description (get (read-json-str (get % :value)) "description"))
    (filter
     app?
     (.subtree storage full-path)))))
@@ -125,8 +135,8 @@
          (map
           #(let [pathname (:name %)
                  name (subs pathname (inc (.lastIndexOf pathname "/")))
-                 description (get (json/read-str (:value %)) "description")
-                 values (get (json/read-str (:value %)) "values")]
+                 description (get (read-json-str (:value %)) "description")
+                 values (get (read-json-str (:value %)) "values")]
              {:name name
               :description description
               :values values
@@ -194,7 +204,7 @@
   (log/info (str "Trying to delete " pathname " " envt))
   (let [full-path (path->full-path pathname)
         json (:value (.get-item storage full-path))
-        token (json/read-str json)
+        token (read-json-str json)
         values (get token "values")
         new-values (into {} (remove #(= envt (first %)) values))
         new-token {:description (get token "description")


Add file type to cli DSL type checker (fixes #89)

--- boot/core/src/boot/cli.clj
+++ boot/core/src/boot/cli.clj
@@ -1,6 +1,7 @@
 (ns boot.cli
   (:require
    [boot.util :as util]
+   [clojure.java.io :as io]
    [clojure.string :as string]
    [clojure.pprint :as pprint]
    [boot.from.clojure.tools.cli :as cli]))
@@ -24,7 +25,8 @@
     bool  identity
     edn   (fnil read-string "nil")
     regex (fnil re-pattern "")
-    code  (fnil (comp eval read-string) "nil")))
+    code  (fnil (comp eval read-string) "nil")
+    file  io/file))

 (defn- assert-atom [type]
   (case type
@@ -37,7 +39,8 @@
     bool  #(contains? #{true false} %)
     edn   (constantly true)
     regex #(instance? java.util.regex.Pattern %)
-    code  (constantly true)))
+    code  (constantly true)
+    file  #(instance? java.io.File %)))

 (defn- parse-fn [optarg]
   (fn [arg]


Cleanup.

Cleanup.

--- clj_record/core.clj
+++ clj_record/core.clj
@@ -11,9 +11,7 @@
   (model-metadata-for model-name :table-name))

 (defn set-table-name [model-name tbl-name]
-  (dosync
-    (let [m (model-metadata-for model-name)]
-      (ref-set m (assoc @m :table-name tbl-name)))))
+  (dosync (set-model-metadata-for model-name :table-name tbl-name)))

 (defn to-conditions
   "Converts the given attribute map into a clojure.contrib.sql style 'where-params,'


Cleanup now that I'm using tashafa's cleaner (val (first (first rows))) to read the id.

--- clj_record/util.clj
+++ clj_record/util.clj
@@ -13,10 +13,6 @@
     (re-sub #"y$" "ies" word)
     (str word "s")))

-(defmulti get-key-for-autoincrement-value (fn [{db :subprotocol}] (.toUpperCase db)))
-(defmethod get-key-for-autoincrement-value "DERBY" [db-spec] :1)
-(defmethod get-key-for-autoincrement-value "POSTGRESQL" [db-spec] :last_value)
-
 (defn postgresql-id-sequence-name [table-name]
   (str table-name "_id_seq"))


revert -- not necessary after all

revert -- not necessary after all

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

--- plugins/SlideExplorer2/src/slide_explorer/reactive.clj
+++ plugins/SlideExplorer2/src/slide_explorer/reactive.clj
@@ -7,16 +7,16 @@
            (clojure.lang IRef))
   (:require [clojure.pprint :as pprint]))

-(defmacro add-watch-simple
+(defn add-watch-simple
   "Adds a watch (more simple than clojure core/add-watch). The function
    should have arguments [old-state new-state]."
   [reference function]
   (let [key (UUID/randomUUID)]
-    `(add-watch ~reference key
-               (fn [_# _# old-state# new-state#]
+    (add-watch reference key
+               (fn [_ _ old-state new-state]
                  (try
-                   (~function old-state# new-state#)
-                   (catch Throwable e# (println e#)))))))
+                   (function old-state new-state)
+                   (catch Throwable e (println e)))))))

 (defn remove-watches
   "Removes all watches from a reference (ref/atom/agent)."


Revert older use of send! in zeromq (seems more failsave)

--- common/src/patavi/common/zeromq.clj
+++ common/src/patavi/common/zeromq.clj
@@ -45,16 +45,16 @@

 (defn send!
   "Sends a vector of parts over the ZMQ socket as a `ZMsg`.
-   Optionally receives :prefix-empty which adds a zero byte as first frame"
+   Optionally receives :prefix-empty which adds a zero byte as first part"
   [^ZMQ$Socket socket parts & flags]
   (let [frames (map #(ZFrame. (bytes-from %)) parts)
         content (interleave frames (repeat empty-frame))
         msg (ZMsg.)]
-    (doall (map #(.add msg %)
-                (if (contains? (set flags) :prefix-empty)
-                  (concat [empty-frame] content)
-                  content)))
-    (.send msg socket true)))
+    (if (contains? (set flags) :prefix-empty)
+      (.addAll msg (concat [empty-frame] content))
+      (.addAll msg content))
+    (.send msg socket)))
+

 (defn- parse-frame
   [^ZFrame frame type]


Add java-map to example.

Add java-map to example.

--- test/dsbdp/test/data_processing_dsl_tests.clj
+++ test/dsbdp/test/data_processing_dsl_tests.clj
@@ -30,9 +30,11 @@
         data-proc-fn-csv-str (create-proc-fn dsl-expression)
         data-proc-fn-json-str (create-proc-fn (assoc dsl-expression :output-type :json-str))
         data-proc-fn-clj-map (create-proc-fn (assoc dsl-expression :output-type :clj-map))
+        data-proc-fn-java-map (create-proc-fn (assoc dsl-expression :output-type :java-map))
         ]
     (is (= expected-csv-str (str (data-proc-fn-csv-str in-vector))))
     (is (= expected-json-str (str (data-proc-fn-json-str in-vector))))
+    (is (= expected-clj-map (data-proc-fn-java-map in-vector)))
     (is (= expected-clj-map (data-proc-fn-clj-map in-vector)))))


More lein plugins

More lein plugins

--- leiningen/.lein/profiles.clj
+++ leiningen/.lein/profiles.clj
@@ -1 +1,3 @@
-{:user {:plugins [[lein-ancient "0.6.10"]]}}
+{:user {:plugins [[lein-ancient "0.6.10"]
+                  [lein-cljfmt "0.5.6"]
+                  [lein-kibit "0.1.3"]]}}