Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Add default thumbup rection to every entry.
(ns oc.storage.resources.reaction) (defn- reaction-collapse "Reducer function that collapses reactions into count and sequence of author based on common reaction unicode." [reactions reaction] (let [unicode (:reaction reaction) author (-> reaction :author :name) author-id (-> reaction :author :user-id)] (if-let [existing-reaction (reactions unicode)] ;; have this unicode already, so add this reaction to it (assoc reactions unicode (-> existing-reaction (update :count inc) (update :authors #(conj % author)) (update :author-ids #(conj % author-id)))) ;; haven't seen this reaction unicode before, so init a new one (assoc reactions unicode {:reaction unicode :count 1 :authors [author] :author-ids [author-id]})))) (defn aggregate-reactions " Given a sequence of individual reaction interactions, collapse it down to a set of distinct reactions that include the count of how many times reacted and the list of author names and IDs that reacted. " [entry-reactions] (or (vals (reduce reaction-collapse {} (map #(assoc % :count 1) entry-reactions))) []))
(ns oc.storage.resources.reaction) (defn- reaction-collapse "Reducer function that collapses reactions into count and sequence of author based on common reaction unicode." [reactions reaction] (let [unicode (:reaction reaction) author (-> reaction :author :name) author-id (-> reaction :author :user-id)] (if-let [existing-reaction (reactions unicode)] ;; have this unicode already, so add this reaction to it (assoc reactions unicode (-> existing-reaction (update :count + (:count reaction)) (update :authors #(remove nil? (conj % author))) (update :author-ids #(remove nil? (conj % author-id))))) ;; haven't seen this reaction unicode before, so init a new one (assoc reactions unicode {:reaction unicode :count (if author 1 0) :authors (remove nil? [author]) :author-ids (remove nil? [author-id])})))) (defn aggregate-reactions " Given a sequence of individual reaction interactions, collapse it down to a set of distinct reactions that include the count of how many times reacted and the list of author names and IDs that reacted. " [entry-reactions] (let [fixed-entry-reactions (conj (map #(assoc % :count 1) entry-reactions) {:reaction "👍" :count 0}) collapsed-reactions (vals (reduce reaction-collapse {} fixed-entry-reactions))] (or collapsed-reactions [])))
Make Exploud list the applications from Onix
(ns exploud.info "## For grabbing information about the things we're dealing with" (:require [exploud [asgard :as asgard] [onix :as onix] [tyranitar :as tyr]])) (defn applications "The list of applications Asgard knows about." [] {:names (map :name (asgard/applications))}) (defn application "The information about a particular application." [region application-name] (if-let [full-application (asgard/application region application-name)] (merge {:name application-name} (select-keys (:app full-application) [:description :email :owner])))) (defn upsert-application "Upserts an application into Onix, Tyranitar and Asgard. This function can be run many times, it won't fail if the application is present in any of the stores." [region application-name details] (let [onix-application (onix/upsert-application application-name) tyranitar-application (tyr/upsert-application application-name)] (asgard/upsert-application application-name details) (merge (application region application-name) tyranitar-application)))
(ns exploud.info "## For grabbing information about the things we're dealing with" (:require [exploud [asgard :as asgard] [onix :as onix] [tyranitar :as tyr]])) (defn applications "The list of applications Onix knows about." [] {:names (map :name (onix/applications))}) (defn application "The information about a particular application." [region application-name] (if-let [full-application (asgard/application region application-name)] (merge {:name application-name} (select-keys (:app full-application) [:description :email :owner])))) (defn upsert-application "Upserts an application into Onix, Tyranitar and Asgard. This function can be run many times, it won't fail if the application is present in any of the stores." [region application-name details] (let [onix-application (onix/upsert-application application-name) tyranitar-application (tyr/upsert-application application-name)] (asgard/upsert-application application-name details) (merge (application region application-name) tyranitar-application)))
Set default issue to an english one
(ns discuss.config) (def project "discuss") (def user "Q2hyaXN0aWFu") (def api {:host "http://localhost:4284/" :init "api/elektroautos" :base "api/" :login "api/login" :add {:add-start-statement "api/add/start_statement" :add-start-premise "api/add/start_premise" :add-justify-premise "api/add/justify_premise"} :get {:references "api/get/references" :reference-usages "api/get/reference/usages" :statements "api/get/statements" :statement-url "api/get/statement/url"}})
(ns discuss.config) (def project "discuss") (def user "Q2hyaXN0aWFu") (def api {:host "http://localhost:4284/" :init "api/cat-or-dog" :base "api/" :login "api/login" :add {:add-start-statement "api/add/start_statement" :add-start-premise "api/add/start_premise" :add-justify-premise "api/add/justify_premise"} :get {:references "api/get/references" :reference-usages "api/get/reference/usages" :statements "api/get/statements" :statement-url "api/get/statement/url"}})
Add content type to default route
(ns test-fb.handler (:require [ring.middleware.defaults :refer (wrap-defaults site-defaults secure-site-defaults)] [ring.util.response :refer (not-found response)] [taoensso.timbre :as log] [clojure.string :refer (trim blank?)] [clojure.java.io :as io] )) (defn handler [request] (response "hello world")) (def app (-> handler (wrap-defaults site-defaults))) ; TODO authentication #_(def site (if-let [location (get-public-files-location)] (do (log/info "Serves files from" location) (-> handler (wrap-defaults (assoc site-defaults :static {:files (io/as-file (io/as-url location))})))) (do (log/error public-files-location-str "not specified") (System/exit 1)) ))
(ns test-fb.handler (:require [ring.middleware.defaults :refer (wrap-defaults site-defaults secure-site-defaults)] [ring.util.response :refer (not-found response content-type)] [taoensso.timbre :as log] [clojure.string :refer (trim blank?)] [clojure.java.io :as io] )) (defn handler [request] (-> (response "hello world") (content-type "text/plain") )) (def app (-> handler (wrap-defaults site-defaults))) ; TODO authentication #_(def site (if-let [location (get-public-files-location)] (do (log/info "Serves files from" location) (-> handler (wrap-defaults (assoc site-defaults :static {:files (io/as-file (io/as-url location))})))) (do (log/error public-files-location-str "not specified") (System/exit 1)) ))
Work in terms of maps so merge-with use is correct
(ns advent-2017.day-06 (:require #?(:cljs [planck.core :refer [slurp read-string]]) [#?(:clj clojure.java.io :cljs planck.io) :as io] [clojure.string :as str])) (def input (-> "advent_2017/day_06/input" io/resource slurp)) (def data (as-> input x (str/trim x) (str/split x #"\t") (mapv read-string x))) (defn redistribute [banks] (let [max-ndx (.indexOf banks (apply max banks)) target-ndxs (map #(mod (+ max-ndx 1 %) (count banks)) (range (banks max-ndx)))] (merge-with + (assoc banks max-ndx 0) (frequencies target-ndxs)))) (defn solve [banks] (reduce (fn [[last-seen banks] steps] (if (last-seen banks) (reduced [steps (last-seen banks)]) [(assoc last-seen banks steps) (redistribute banks)])) [{} banks] (range))) (defn part-1 [] (first (solve data))) (defn part-2 [] (apply - (solve data)))
(ns advent-2017.day-06 (:require #?(:cljs [planck.core :refer [slurp read-string]]) [#?(:clj clojure.java.io :cljs planck.io) :as io] [clojure.string :as str])) (def input (-> "advent_2017/day_06/input" io/resource slurp)) (def data (as-> input x (str/trim x) (str/split x #"\t") (mapv read-string x))) (defn redistribute [banks] (let [max-val (apply max (vals banks)) max-ndx (apply min (keep (fn [[k v]] (when (= max-val v) k)) banks)) target-ndxs (map #(mod (+ max-ndx 1 %) (count banks)) (range (banks max-ndx)))] (merge-with + (assoc banks max-ndx 0) (frequencies target-ndxs)))) (defn solve [banks] (reduce (fn [[last-seen banks] steps] (if (last-seen banks) (reduced [steps (last-seen banks)]) [(assoc last-seen banks steps) (redistribute banks)])) [{} (zipmap (range) banks)] (range))) (defn part-1 [] (first (solve data))) (defn part-2 [] (apply - (solve data)))
Use the same default as Ruby example
(ns rabbitmq.tutorials.emit-log-direct (:require [langohr.core :as lc] [langohr.channel :as lch] [langohr.exchange :as le] [langohr.basic :as lb] [clojure.string :as s])) (def ^{:const true} x "direct_logs") (defn -main [severity & args] (with-open [conn (lc/connect)] (let [ch (lch/open conn) payload (if (empty? args) "Hello, world!" (s/join " " args))] (le/direct ch x :durable false :auto-delete false) (lb/publish ch x severity payload) (println (format " [x] Sent %s" payload)))))
(ns rabbitmq.tutorials.emit-log-direct (:require [langohr.core :as lc] [langohr.channel :as lch] [langohr.exchange :as le] [langohr.basic :as lb] [clojure.string :as s])) (def ^{:const true} x "direct_logs") (defn -main [severity & args] (with-open [conn (lc/connect)] (let [ch (lch/open conn) severity (or severity "info") payload (if (empty? args) "Hello, world!" (s/join " " args))] (le/direct ch x :durable false :auto-delete false) (lb/publish ch x severity payload) (println (format " [x] Sent %s" payload)))))
Use the lazy version instead
(ns github-changelog.util (:require [clojure.string :refer [join ends-with?]])) (defn str-map [f & sqs] (join (apply map f sqs))) (defn extract-params [query-string] (into {} (for [[_ k v] (re-seq #"([^&=]+)=([^&]+)" query-string)] [(keyword k) v]))) (defn strip-trailing ([s] (strip-trailing s "/")) ([s end] (if (ends-with? s end) (recur (join (butlast s)) end) s)))
(ns github-changelog.util (:require [clojure.string :refer [join ends-with?]])) (defn str-map [f & sqs] (join (apply map f sqs))) (defn extract-params [query-string] (into {} (for [[_ k v] (re-seq #"([^&=]+)=([^&]+)" query-string)] [(keyword k) v]))) (defn strip-trailing ([s] (strip-trailing s "/")) ([s end] (if (ends-with? s end) (recur (join (drop-last s)) end) s)))
Add tools.namespace to the dependencies.
(defproject clstreams "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.8.0"] [org.apache.kafka/kafka-clients "0.10.1.0"] [org.apache.kafka/kafka-streams "0.10.1.0"]] :main ^:skip-aot clstreams.core :target-path "target/%s" :profiles {:uberjar {:aot :all}})
(defproject clstreams "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.8.0"] [org.clojure/tools.namespace "0.3.0-alpha3"] [org.apache.kafka/kafka-clients "0.10.1.0"] [org.apache.kafka/kafka-streams "0.10.1.0"]] :main ^:skip-aot clstreams.core :target-path "target/%s" :profiles {:uberjar {:aot :all}})
Determine OPeNDAP URL based on tag association data for a collection.
(ns user "A dev namespace that supports Proto-REPL. It seems that Proto-REPL doesn't support the flexible approach that lein uses: any configurable ns can be the starting ns for a REPL. As such, this minimal ns was created for Proto-REPL users, so they too can have an env that supports startup and shutdown." (:require [cheshire.core :as json] [clojure.java.io :as io] [clojure.pprint :refer [pprint]] [clojure.tools.namespace.repl :as repl] [clojusc.system-manager.core :refer :all] [cmr.opendap.dev :as dev] [org.httpkit.client :as httpc]))
(ns user "A dev namespace that supports Proto-REPL. It seems that Proto-REPL doesn't support the flexible approach that lein uses: any configurable ns can be the starting ns for a REPL. As such, this minimal ns was created for Proto-REPL users, so they too can have an env that supports startup and shutdown." (:require [cheshire.core :as json] [clojure.java.io :as io] [clojure.pprint :refer [pprint]] [clojure.tools.namespace.repl :as repl] [clojusc.system-manager.core :refer :all] [clojusc.twig :as logger] [cmr.opendap.dev :as dev] [org.httpkit.client :as httpc])) (logger/set-level! '[cmr org.httpkit] :trace logger/no-color-log-formatter)
Check handler before call it
(ns pot.core.act (:require-macros [cljs.core.async.macros :refer [go alt!]]) (:require [cljs.reader :refer [read-string]] [pot.core.hand :refer [move-handler undo-handler state-watcher history-watcher]])) (def ^:private msg-handler-map {:move move-handler :undo undo-handler}) (defn- process-msg [{action-key :msg :as msg} state history] (let [{action-handler action-key} msg-handler-map] (action-handler msg state history))) (defn listen-channels [state history {:keys [actions]}] (go (while true (alt! actions ([msg] (process-msg msg state history)))))) (defn watch-changes [state history storage] (add-watch state :state-watcher (state-watcher state history)) (add-watch history :history-watcher (history-watcher storage :history))) (defn restore-state [state history storage] (when-let [stored-history (.get storage :history)] (when-let [restored-history (read-string stored-history)] (when-let [restored-state (get-in restored-history [:snapshots (:cursor restored-history)])] (reset! state restored-state)) (reset! history restored-history))))
(ns pot.core.act (:require-macros [cljs.core.async.macros :refer [go alt!]]) (:require [cljs.reader :refer [read-string]] [pot.core.hand :refer [move-handler undo-handler state-watcher history-watcher]])) (def ^:private msg-handler-map {:move move-handler :undo undo-handler}) (defn- process-msg [{action-key :msg :as msg} state history] (let [{action-handler action-key} msg-handler-map] (when action-handler (action-handler msg state history)))) (defn listen-channels [state history {:keys [actions]}] (go (while true (alt! actions ([msg] (process-msg msg state history)))))) (defn watch-changes [state history storage] (add-watch state :state-watcher (state-watcher state history)) (add-watch history :history-watcher (history-watcher storage :history))) (defn restore-state [state history storage] (when-let [stored-history (.get storage :history)] (when-let [restored-history (read-string stored-history)] (when-let [restored-state (get-in restored-history [:snapshots (:cursor restored-history)])] (reset! state restored-state)) (reset! history restored-history))))
Add dev-server to stop Hyphenator errors
#!/usr/bin/env boot #tailrecursion.boot.core/version "2.3.1" (set-env! :dependencies [['tailrecursion/boot.task "2.1.2"] ['tailrecursion/hoplon "5.7.0"] ['markdown-clj "0.9.41"] ['org.clojure/clojurescript "0.0-2156"]] :src-paths #{"src"} :out-path "resources/public") (add-sync! (get-env :out-path) #{"resources/assets"}) (require ['tailrecursion.boot.task :refer :all] ['tailrecursion.hoplon.boot :refer :all]) (deftask dev "Build hoplon.io for local development." [] (comp (watch) (hoplon {:pretty-print true :prerender false :optimizations :whitespace}))) (deftask prod "Build hoplon.io for production deployment." [] (hoplon {:optimizations :advanced}))
#!/usr/bin/env boot #tailrecursion.boot.core/version "2.3.1" (set-env! :dependencies '[[tailrecursion/boot.task "2.1.2"] [tailrecursion/hoplon "5.7.0"] [markdown-clj "0.9.41"] [tailrecursion/boot.ring "0.1.0-SNAPSHOT"] [org.clojure/clojurescript "0.0-2156"]] :src-paths #{"src"} :out-path "resources/public") (add-sync! (get-env :out-path) #{"resources/assets"}) (require '[tailrecursion.boot.task :refer :all] '[tailrecursion.boot.task.ring :refer [dev-server]] '[tailrecursion.hoplon.boot :refer :all]) (deftask dev "Build hoplon.io for local development." [] (comp (watch) (hoplon {:pretty-print true :prerender false :optimizations :whitespace}) (dev-server))) (deftask prod "Build hoplon.io for production deployment." [] (hoplon {:optimizations :advanced}))
Fix spyscope dependency. Add its injection.
{:user {:dependencies [[clj-stacktrace "0.2.5"] [spyscope "0.1.0"] [limit-break "0.1.0-SNAPSHOT"]] :plugins [[lein-difftest "1.3.7"] [lein-drip "0.1.1-SNAPSHOT"] [lein-clojars "0.9.1"] [lein-pprint "1.1.1"] [lein-ring "0.8.0"] [slamhound "1.3.1"] [lein-cljsbuild "0.1.9"] [lein-deps-tree "0.1.2"] [lein-marginalia "0.7.1"]] :repl-options {:timeout 120000} :injections [(let [orig (ns-resolve (doto 'clojure.stacktrace require) 'print-cause-trace) new (ns-resolve (doto 'clj-stacktrace.repl require) 'pst)] (alter-var-root orig (constantly @new)))] :vimclojure-opts {:repl true}}}
{:user {:dependencies [[clj-stacktrace "0.2.5"] [spyscope "0.1.2"] [limit-break "0.1.0-SNAPSHOT"]] :plugins [[lein-difftest "1.3.7"] [lein-drip "0.1.1-SNAPSHOT"] [lein-clojars "0.9.1"] [lein-pprint "1.1.1"] [lein-ring "0.8.0"] [slamhound "1.3.1"] [lein-cljsbuild "0.1.9"] [lein-deps-tree "0.1.2"] [lein-marginalia "0.7.1"]] :repl-options {:timeout 120000} :injections [(require 'spyscope.core) (let [orig (ns-resolve (doto 'clojure.stacktrace require) 'print-cause-trace) new (ns-resolve (doto 'clj-stacktrace.repl require) 'pst)] (alter-var-root orig (constantly @new)))] :vimclojure-opts {:repl true}}}
Update the app's model according to incoming events.
(ns ^{:doc "Dispatching Input Events of a SimRunner Application." :author "Frank Mosebach"} fm.simrunner.input (:require [fm.simrunner.config :as cfg])) (defmulti on-input {:private true} (fn [id & _] id)) (defmethod on-input :default [id app & args] (println (format "on-input{id: %s args: %s}" id args))) (defn- handle-input? [{app-state :state}] (let [{ui :ui} @app-state] (and (not (:locked? ui)) (not (:rendering? ui))))) (defn dispatch [id app args] (when (handle-input? app) (apply on-input id app args)))
(ns ^{:doc "Dispatching Input Events of a SimRunner Application." :author "Frank Mosebach"} fm.simrunner.input (:require [fm.simrunner.config :as cfg])) (defn- value->param [id value] (if (= :calc-err id) (if value "1" "0") (str value))) (defn- update-values [app-state id value] (assoc-in app-state [:ui :model :values id] value)) (defn- update-config [app-state id value] (let [config (-> (get-in app-state [:model :config]) (cfg/with-value id (value->param id value)))] (-> app-state (assoc-in [:model :config] config) (assoc-in [:model :changed?] true) (assoc-in [:model :valid?] (cfg/complete? config))))) (defn- on-input [id {app-state :state} & [widget value :as args]] (println (format "on-input{id: %s value: %s}" id value)) (swap! app-state (fn [app-state] (-> app-state (update-values id value) (update-config id value))))) (defn- handle-input? [{app-state :state}] (let [{ui :ui} @app-state] (and (not (:locked? ui)) (not (:rendering? ui))))) (defn dispatch [id app args] (when (handle-input? app) (apply on-input id app args)))
Update config for Clojure projects
;; https://github.com/technomancy/leiningen/blob/stable/doc/PROFILES.md {:user {:plugins [[cider/cider-nrepl "0.27.2"] [lein-ancient "1.0.0-RC3"] [lein-check-namespace-decls "1.0.4"] [lein-cljfmt "0.8.0"] [lein-nsorg "0.3.0"] [nrepl "0.9.0-beta3"] [refactor-nrepl "3.0.0-alpha13"]]} :dependencies [#_[alembic "0.3.2"] [clj-kondo "RELEASE"] [antq "RELEASE"] [vvvvalvalval/scope-capture "0.3.2"]] :injections [(require 'sc.api)] :aliases {"clj-kondo" ["run" "-m" "clj-kondo.main"] "outdated" ["run" "-m" "antq.core"]}}
;; https://github.com/technomancy/leiningen/blob/stable/doc/PROFILES.md {:user {:plugins [[cider/cider-nrepl "0.27.4"] [lein-ancient "1.0.0-RC3"] [lein-check-namespace-decls "1.0.4"] [lein-cljfmt "0.8.0"] [lein-nsorg "0.3.0"] [nrepl "0.9.0"] [refactor-nrepl "3.1.0"]]} :dependencies [#_[alembic "0.3.2"] [clj-kondo "RELEASE"] [antq "RELEASE"] [vvvvalvalval/scope-capture "0.3.2"]] :injections [(require 'sc.api)] :aliases {"clj-kondo" ["run" "-m" "clj-kondo.main"] "outdated" ["run" "-m" "antq.core"]}}
Reset counter so the test can be run multiple times in repl.
(ns cmr.common.test.cache (:require [clojure.test :refer :all] [cmr.common.cache :as c])) (def counter (atom 0)) (defn increment-counter "Increments the counter atom and returns it" [] (swap! counter inc)) (deftest cache-test (testing "cache hit, miss and reset" (let [cache-atom (c/create-cache)] (is (= 1 (c/cache-lookup cache-atom "key" increment-counter))) ;; look up again will not call the increment-counter function (is (= 1 (c/cache-lookup cache-atom "key" increment-counter))) (c/reset-cache cache-atom) (is (= 2 (c/cache-lookup cache-atom "key" increment-counter))) (is (= 2 (c/cache-lookup cache-atom "key" increment-counter))))))
(ns cmr.common.test.cache (:require [clojure.test :refer :all] [cmr.common.cache :as c])) (def counter (atom 0)) (defn increment-counter "Increments the counter atom and returns it" [] (swap! counter inc)) (deftest cache-test (testing "cache hit, miss and reset" (let [cache-atom (c/create-cache)] (reset! counter 0) (is (= 1 (c/cache-lookup cache-atom "key" increment-counter))) ;; look up again will not call the increment-counter function (is (= 1 (c/cache-lookup cache-atom "key" increment-counter))) (c/reset-cache cache-atom) (is (= 2 (c/cache-lookup cache-atom "key" increment-counter))) (is (= 2 (c/cache-lookup cache-atom "key" increment-counter))))))
Add support for nested directories to doc-site
(ns pro.juxt.edge.doc-site (:require [integrant.core :as ig] [clojure.java.io :as io] [edge.asciidoctor :refer [load-doc]] [yada.yada :as yada])) (defn routes [engine] [["" (merge (yada/redirect ::doc-resource {:route-params {:name "index"}}) {:id ::doc-index})] [[:name ".html"] (yada/resource {:id ::doc-resource :methods {:get {:produces [{:media-type "text/html;q=0.8" :charset "utf-8"} {:media-type "application/json"}] :response (fn [ctx] (let [path (str "doc/sources/" (-> ctx :parameters :path :name) ".adoc")] (try (.convert (load-doc ctx engine (-> ctx :parameters :path :name) (slurp (io/resource path)))) (catch Exception e (throw (ex-info (format "Failed to convert %s" path) {:path path} e))))))}}})]]) (defmethod ig/init-key ::routes [_ {:keys [edge.asciidoctor/engine]}] (routes engine))
(ns pro.juxt.edge.doc-site (:require [integrant.core :as ig] [clojure.java.io :as io] [edge.asciidoctor :refer [load-doc]] [yada.yada :as yada])) (defn routes [engine] [["" (merge (yada/redirect ::doc-resource {:route-params {:name "index"}}) {:id ::doc-index})] [[;; regex derived from bidi's default, but adding / to allow directories [#"[A-Za-z0-9\\-\\_\\.\/]+" :name] ".html"] (yada/resource {:id ::doc-resource :methods {:get {:produces [{:media-type "text/html;q=0.8" :charset "utf-8"} {:media-type "application/json"}] :response (fn [ctx] (let [path (str "doc/sources/" (-> ctx :parameters :path :name) ".adoc")] (try (.convert (load-doc ctx engine (-> ctx :parameters :path :name) (slurp (io/resource path)))) (catch Exception e (throw (ex-info (format "Failed to convert %s" path) {:path path} e))))))}}})]]) (defmethod ig/init-key ::routes [_ {:keys [edge.asciidoctor/engine]}] (routes engine))
Adjust duration calculation for polyphony.
(ns klangmeister.processing (:require [klangmeister.eval :as eval] [klangmeister.music :as music] [klangmeister.instruments :as instrument] [klangmeister.actions :as action] [klangmeister.framework :as framework] [cljs.js :as cljs])) (extend-protocol framework/Action action/Refresh (process [{expr-str :text} _ {original-music :music :as state}] (let [{:keys [value error]} (eval/uate expr-str) music (or value original-music)] (-> state (assoc :error error) (assoc :text expr-str) (assoc :music music)))) action/Stop (process [_ handle! state] (assoc state :looping? false)) action/Play (process [this handle! state] (framework/process (action/->Loop) handle! (assoc state :looping? true))) action/Loop (process [this handle! {notes :music :as state}] (when (:looping? state) (music/play-on! instrument/beep! notes) (let [duration (->> notes (map :duration) (reduce +) (* 1000))] (js/setTimeout #(handle! this) duration))) state))
(ns klangmeister.processing (:require [klangmeister.eval :as eval] [klangmeister.music :as music] [klangmeister.instruments :as instrument] [klangmeister.actions :as action] [klangmeister.framework :as framework] [cljs.js :as cljs])) (extend-protocol framework/Action action/Refresh (process [{expr-str :text} _ {original-music :music :as state}] (let [{:keys [value error]} (eval/uate expr-str) music (or value original-music)] (-> state (assoc :error error) (assoc :text expr-str) (assoc :music music)))) action/Stop (process [_ handle! state] (assoc state :looping? false)) action/Play (process [this handle! state] (framework/process (action/->Loop) handle! (assoc state :looping? true))) action/Loop (process [this handle! {notes :music :as state}] (when (:looping? state) (music/play-on! instrument/beep! notes) (let [duration (->> notes (map (fn [{:keys [time duration]}] (+ time duration))) (apply max) (* 1000))] (js/setTimeout #(handle! this) duration))) state))
Revert "Make alpha/beta/etc versions incompatible with each other."
(ns onyx.peer.log-version) (def version "0.10.0-SNAPSHOT") (defn check-compatible-log-versions! [cluster-version] (when-not (or (re-find #"-SNAPSHOT" version) (= version cluster-version)) (throw (ex-info "Incompatible versions of the Onyx cluster coordination log. A new, distinct, :onyx/tenancy-id should be supplied when upgrading or downgrading Onyx." {:cluster-version cluster-version :peer-version version}))))
(ns onyx.peer.log-version) (def version "0.10.0-SNAPSHOT") (defn check-compatible-log-versions! [cluster-version] (when-not (or (re-find #"-" version) (= version cluster-version)) (throw (ex-info "Incompatible versions of the Onyx cluster coordination log. A new, distinct, :onyx/tenancy-id should be supplied when upgrading or downgrading Onyx." {:cluster-version cluster-version :peer-version version}))))
Improve make-test-page to allow multiple urls and add multiple url test for extract-result-links.
(ns scrape-summitpost-data.extract-result-links-test (:require [clojure.string :as string] [clojure.test :refer [deftest is]] [scrape-summitpost-data.extract-result-links :as test-ns])) (defn- make-test-page [url] (let [template "<table class='srch_results'> <tbody> <tr> <td class='srch_results_lft'></td> <td class='srch_results_rht'> <a href='{}'></a> </td> </tr> </tbody> </table>"] (string/replace template "{}" url))) (deftest extract-result-links-test (let [page (make-test-page "/test-item-name/12345")] (is (= ["/test-item-name/12345"] (test-ns/extract-result-links page)) "extracts link to item from search results table")))
(ns scrape-summitpost-data.extract-result-links-test (:require [clojure.string :as string] [clojure.test :refer [deftest is]] [scrape-summitpost-data.extract-result-links :as test-ns])) (defn- make-test-page [urls] (let [header "<table class='srch_results'> <tbody>" row-template "<tr> <td class='srch_results_lft'></td> <td class='srch_results_rht'> <a href='{}'></a> </td> </tr>" footer " </tbody> </table>" rows (mapv #(string/replace row-template "{}" %) urls) page (conj (cons header rows) footer)] (apply str page))) (deftest extract-result-links-test (let [urls ["/test1"]] (is (= urls (test-ns/extract-result-links (make-test-page urls))) "extracts single link from search results table")) (let [urls ["/test1" "/test2" "/test3"]] (is (= urls (test-ns/extract-result-links (make-test-page urls))) "extracts multiple links from search results table")))
Use GPG lookup for clojars credentials.
(defproject exegesis "0.2.0-SNAPSHOT" :description "Simplify reflection of annotations on Java types." :url "http://github.com/tobyclemson/exegesis" :license {:name "The MIT License" :url "https://opensource.org/licenses/MIT"} :dependencies [[org.clojure/clojure "1.8.0"]] :source-paths ["src/clojure"] :test-paths ["test/clojure"] :java-source-paths ["src/java" "test/java"])
(defproject exegesis "0.2.0-SNAPSHOT" :description "Simplify reflection of annotations on Java types." :url "http://github.com/tobyclemson/exegesis" :license {:name "The MIT License" :url "https://opensource.org/licenses/MIT"} :dependencies [[org.clojure/clojure "1.8.0"]] :source-paths ["src/clojure"] :test-paths ["test/clojure"] :java-source-paths ["src/java" "test/java"] :deploy-repositories [["releases" {:url "https://clojars.org/repo/" :creds :gpg}]])
Add dependency to cljito and mockito.
(defproject lein-xjc "0.1.0-SNAPSHOT" :description "Call xjc from leiningen." :url "http://lein-xjc.ferdinandhofherr.de" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :eval-in-leiningen true)
(defproject lein-xjc "0.1.0-SNAPSHOT" :description "Call xjc from leiningen." :url "http://lein-xjc.ferdinandhofherr.de" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :eval-in-leiningen true :profiles {:dev {:source-paths ["dev"] :dependencies [[midje "1.6.0"] [cljito "0.2.1"] [org.mockito/mockito-all "1.9.5"]] :plugins [[lein-midje "3.1.3"]]}})
Prepare for next release cycle.
(defproject onyx-app/lein-template "0.10.0.0-beta4" :description "Onyx Leiningen application template" :url "https://github.com/onyx-platform/onyx-template" :license {:name "MIT License" :url "http://choosealicense.com/licenses/mit/#"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :plugins [[lein-set-version "0.4.1"]] :profiles {:dev {:plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}} :eval-in-leiningen true)
(defproject onyx-app/lein-template "0.10.0.0-SNAPSHOT" :description "Onyx Leiningen application template" :url "https://github.com/onyx-platform/onyx-template" :license {:name "MIT License" :url "http://choosealicense.com/licenses/mit/#"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :plugins [[lein-set-version "0.4.1"]] :profiles {:dev {:plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}} :eval-in-leiningen true)
Update :prep-tasks for most recent lein.
(defproject inet.data "0.5.0-SNAPSHOT" :description "Represent and manipulate various Internet entities as data." :url "http://github.com/llasram/inet.data" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.4.0"] [hier-set "1.1.2"]] :plugins [[lein-ragel "0.1.0"]] :source-paths ["src/clojure"] :java-source-paths ["src/java" "target/ragel"] :ragel-source-paths ["src/ragel"] :javac-options ["-g"] :prep-tasks [ragel javac] :warn-on-reflection true :profiles {:dev {:dependencies [[byteable "0.2.0"] [criterium "0.2.1"]]}})
(defproject inet.data "0.5.0-SNAPSHOT" :description "Represent and manipulate various Internet entities as data." :url "http://github.com/llasram/inet.data" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.4.0"] [hier-set "1.1.2"]] :plugins [[lein-ragel "0.1.0"]] :source-paths ["src/clojure"] :java-source-paths ["src/java" "target/ragel"] :ragel-source-paths ["src/ragel"] :javac-options ["-g"] :prep-tasks ["ragel" "javac"] :warn-on-reflection true :profiles {:dev {:dependencies [[byteable "0.2.0"] [criterium "0.2.1"]]}})
Prepare for next release cycle.
(defproject onyx-app/lein-template "0.8.11.9" :description "Onyx Leiningen application template" :url "https://github.com/onyx-platform/onyx-template" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :plugins [[lein-set-version "0.4.1"]] :profiles {:dev {:plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}} :eval-in-leiningen true)
(defproject onyx-app/lein-template "0.8.11.10-SNAPSHOT" :description "Onyx Leiningen application template" :url "https://github.com/onyx-platform/onyx-template" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :plugins [[lein-set-version "0.4.1"]] :profiles {:dev {:plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}} :eval-in-leiningen true)
Use Clojars as default deploy repository
(defproject com.hypirion/bencode "0.1.0-SNAPSHOT" :description "Java implementation Bencode." :url "https://github.com/hyPiRion/java-bencode" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [] :source-paths [] :java-source-paths ["src"] :javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"] :scm {:dir ".."} :aliases {"javadoc" ["shell" "javadoc" "-d" "javadoc/${:version}" "-sourcepath" "src" "com.hypirion.bencode" "-link" "http://docs.oracle.com/javase/8/docs/api/"]} :plugins [[lein-shell "0.5.0"]] :profiles {:uberjar {:aot :all} :dev {:dependencies [[org.clojure/clojure "1.8.0"] [org.clojure/test.check "0.9.0"]]}})
(defproject com.hypirion/bencode "0.1.0-SNAPSHOT" :description "Java implementation of Bencode." :url "https://github.com/hyPiRion/java-bencode" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :deploy-repositories [["releases" :clojars]] :dependencies [] :source-paths [] :java-source-paths ["src"] :javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"] :scm {:dir ".."} :aliases {"javadoc" ["shell" "javadoc" "-d" "javadoc/${:version}" "-sourcepath" "src" "com.hypirion.bencode" "-link" "http://docs.oracle.com/javase/8/docs/api/"]} :plugins [[lein-shell "0.5.0"]] :profiles {:uberjar {:aot :all} :dev {:dependencies [[org.clojure/clojure "1.8.0"] [org.clojure/test.check "0.9.0"]]}})
Update dependencies and move gc logging options to dev profile
(defproject sqls "0.1.0-SNAPSHOT" :description "SQLS" :url "https://github.com/mpietrzak/sqls" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [ [org.clojure/clojure "1.6.0"] [org.clojure/data.json "0.2.4"] [org.clojure/java.jdbc "0.3.3"] [org.clojure/tools.logging "0.2.6"] [org.xerial/sqlite-jdbc "3.7.2"] [seesaw "1.4.4"] ] :main sqls.core :java-source-paths ["src"] :target-path "target/%s" :plugins [[codox "0.6.7"] [lein-ancient "0.5.5"]] :codox {:output-dir "doc/codox"} :profiles {:uberjar {:aot :all}} :jvm-opts ["-Xms4M" "-Xmx1G" "-XX:-PrintGC"]) :profiles {:uberjar {:aot :all} :dev {:global-vars {*warn-on-reflection* true}}}
(defproject sqls "0.1.0-SNAPSHOT" :description "SQLS" :url "https://github.com/mpietrzak/sqls" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [ [org.clojure/clojure "1.6.0"] [org.clojure/data.json "0.2.5"] [org.clojure/java.jdbc "0.3.4"] [org.clojure/tools.logging "0.3.0"] [org.xerial/sqlite-jdbc "3.7.2"] [seesaw "1.4.4"] ] :main sqls.core :java-source-paths ["src"] :target-path "target/%s" :plugins [[codox "0.8.10"] [lein-ancient "0.5.5"]] :codox {:output-dir "doc/codox"} :profiles {:uberjar {:aot :all} :dev {:global-vars {*warn-on-reflection* true} :jvm-opts ["-Xms4M" "-Xmx1G" "-XX:+PrintGC" "-XX:+UseG1GC"]}})
Add helper for generating a server response
(ns scavenger.core (:require [compojure.core :refer :all] [compojure.route :as route] [ring.middleware.defaults :refer [wrap-defaults site-defaults]] [ring.util.response :refer [header content-type response resource-response]]) (:use [datomic.api :only [db q] :as d])) (def uri "datomic:free://localhost:4334/items") (def conn (d/connect uri)) (defn get-all-items [] (map first (q '[:find (pull ?c [*]) :where [?c item/name]] (db conn)))) (defroutes app-routes (GET "/items" [] (response (str (into [] (get-all-items))))) (POST "/items" {body :body} (let [tempid (d/tempid :items) data (merge (read-string (slurp body)) {:db/id tempid}) tx @(d/transact conn [data]) id (d/resolve-tempid (db conn) (:tempids tx) tempid)] (response (str (d/touch (d/entity (db conn) id)))))) (GET "/" [] (-> (resource-response "index.html" {:root "public"}) (content-type "text/html"))) (route/not-found "Page not found")) (def app (wrap-defaults app-routes (assoc site-defaults :security nil)))
(ns scavenger.core (:require [compojure.core :refer :all] [compojure.route :as route] [ring.middleware.defaults :refer [wrap-defaults site-defaults]] [ring.util.response :refer [header content-type response resource-response]]) (:use [datomic.api :only [db q] :as d])) (def uri "datomic:free://localhost:4334/items") (def conn (d/connect uri)) (defn get-all-items [] (map first (q '[:find (pull ?c [*]) :where [?c item/name]] (db conn)))) (defn generate-response [data & [status]] {:status (or status 200) :headers {"Content-Type" "application/edn"} :body (pr-str data)}) (defroutes app-routes (GET "/items" [] (generate-response (into [] (get-all-items)))) (POST "/items" {body :body} (let [tempid (d/tempid :items) data (merge (read-string (slurp body)) {:db/id tempid}) tx @(d/transact conn [data]) id (d/resolve-tempid (db conn) (:tempids tx) tempid)] (generate-response (d/touch (d/entity (db conn) id))))) (GET "/" [] (-> (resource-response "index.html" {:root "public"}) (content-type "text/html"))) (route/not-found "Page not found")) (def app (wrap-defaults app-routes (assoc site-defaults :security nil)))
Remove nils as it's redundnnat
(ns silly-image-store.store (:require [clojure.java.io :as io])) (def exists? #(and % (.exists %))) (def file? #(.isFile %)) (def filename #(.getName %)) (defn load-image [& paths] (let [file (apply io/file paths)] (if (exists? file) file nil))) (defn list-images [& paths] (let [image-directory (apply load-image paths)] (if (exists? image-directory) (->> image-directory .listFiles (filter file?) (map filename)) nil))) (defn random-image [basedir] (let [random-image-name (rand-nth (list-images basedir))] (load-image basedir random-image-name)))
(ns silly-image-store.store (:require [clojure.java.io :as io])) (def exists? #(and % (.exists %))) (def file? #(.isFile %)) (def filename #(.getName %)) (defn load-image [& paths] (let [file (apply io/file paths)] (if (exists? file) file))) (defn list-images [& paths] (let [image-directory (apply load-image paths)] (if (exists? image-directory) (->> image-directory .listFiles (filter file?) (map filename))))) (defn random-image [basedir] (let [random-image-name (rand-nth (list-images basedir))] (load-image basedir random-image-name)))
Fix concurrency issue when processing XSLT. Saxon XSLT transformers are not thread safe.
(ns cmr.search.services.xslt "Provides functions for invoking xsl on metadata." (:require [clojure.java.io :as io] [cmr.common.cache :as cache]) (:import javax.xml.transform.TransformerFactory java.io.StringReader java.io.StringWriter javax.xml.transform.stream.StreamSource javax.xml.transform.stream.StreamResult)) (def xsl-transformer-cache-name :xsl-transformers) (defn context->xsl-transformer-cache [context] (get-in context [:system :caches xsl-transformer-cache-name])) (defn- xsl->transformer "Returns the xsl transformer for the given xsl file" [xsl] (let [xsl-resource (new StreamSource (io/file xsl)) factory (TransformerFactory/newInstance)] (.newTransformer factory xsl-resource))) (defn transform "Transforms the given xml by appling the given xsl" [context xml xsl] (let [transformer (cache/cache-lookup (context->xsl-transformer-cache context) xsl #(xsl->transformer xsl)) source (new StreamSource (new StringReader xml)) result (new StreamResult (new StringWriter))] (.transform transformer source result) (.toString (.getWriter result))))
(ns cmr.search.services.xslt "Provides functions for invoking xsl on metadata." (:require [clojure.java.io :as io] [cmr.common.cache :as cache]) (:import javax.xml.transform.TransformerFactory java.io.StringReader java.io.StringWriter javax.xml.transform.stream.StreamSource javax.xml.transform.stream.StreamResult javax.xml.transform.Templates)) (def xsl-transformer-cache-name "This is the name of the cache to use for XSLT transformer templates. Templates are thread safe but transformer instances are not. http://www.onjava.com/pub/a/onjava/excerpt/java_xslt_ch5/?page=9" :xsl-transformer-templates) (defn context->xsl-transformer-cache [context] (get-in context [:system :caches xsl-transformer-cache-name])) (defn- xsl->transformer-template "Returns the xsl transformer template for the given xsl file" [xsl] (let [xsl-resource (new StreamSource (io/file xsl)) factory (TransformerFactory/newInstance)] (.newTemplates factory xsl-resource))) (defn transform "Transforms the given xml by appling the given xsl" [context xml xsl] (let [^Templates template (cache/cache-lookup (context->xsl-transformer-cache context) xsl #(xsl->transformer-template xsl)) transformer (.newTransformer template) source (new StreamSource (new StringReader xml)) result (new StreamResult (new StringWriter))] (.transform transformer source result) (.toString (.getWriter result))))
Add roundtrip test to mem-store
(ns icecap.store.mem-test (:require [caesium.crypto.util :refer [array-eq]] [icecap.store.api :refer :all] [icecap.store.mem :refer :all] [icecap.store.test-props :refer [store-roundtrip-prop]] [clojure.test :refer :all] [clojure.core.async :as a :refer [<!!]] [clojure.test.check.clojure-test :refer [defspec]])) (defspec mem-store-roundtrip (store-roundtrip-prop (mem-store)))
(ns icecap.store.mem-test (:require [caesium.crypto.util :refer [array-eq]] [icecap.store.api :refer :all] [icecap.store.mem :refer :all] [icecap.store.test-props :refer :all] [clojure.test :refer :all] [clojure.core.async :as a :refer [<!!]] [clojure.test.check.clojure-test :refer [defspec]])) (defspec mem-store-roundtrip (store-roundtrip-prop (mem-store))) (defspec mem-store-delete (store-delete-prop (mem-store)))
Extend array params to all Seqable.
(ns cavm.jdbc (:import [java.sql PreparedStatement]) (:require [clojure.java.jdbc :as jdbc])) (extend-protocol jdbc/ISQLParameter clojure.lang.PersistentVector (set-parameter [v ^PreparedStatement s ^long i] (.setObject s i (to-array v))))
(ns cavm.jdbc (:import [java.sql PreparedStatement]) (:require [clojure.java.jdbc :as jdbc])) (extend-protocol jdbc/ISQLParameter clojure.lang.Seqable (set-parameter [v ^PreparedStatement s ^long i] (.setObject s i (to-array v))))
Add unit tests for checking error conditions.
(ns berry.parsing.scan-literal-test (:require [berry.parsing.context-handler :as context] [berry.parsing.scan-literal :refer :all] berry.parsing.token [clojure.test :refer :all]) (:import [berry.parsing.token Token Location])) (deftest scan-literal-test (testing "With a true literal." (let [true-literal (Token. "literal" "true" (Location. 1 1) (Location. 1 4))] (is (= true-literal (scan-literal '("t" "r" "u" "e") context/begin))))) (testing "With a false literal." (let [false-literal (Token. "literal" "false" (Location. 1 1) (Location. 1 5))] (is (= false-literal (scan-literal '("f" "a" "l" "s" "e") context/begin))))) (testing "With a null literal." (let [null-literal (Token. "literal" "null" (Location. 1 1) (Location. 1 4))] (is (= null-literal (scan-literal '("n" "u" "l" "l") context/begin))))) )
(ns berry.parsing.scan-literal-test (:require [berry.parsing.context-handler :as context] [berry.parsing.scan-literal :refer :all] berry.parsing.token [clojure.test :refer :all]) (:import [berry.parsing.token Token Location])) (deftest scan-literal-test (testing "When a true literal is analyzed." (let [true-literal (Token. "literal" "true" (Location. 1 1) (Location. 1 4))] (is (= true-literal (scan-literal '("t" "r" "u" "e") context/begin))))) (testing "When a false literal is analyzed." (let [false-literal (Token. "literal" "false" (Location. 1 1) (Location. 1 5))] (is (= false-literal (scan-literal '("f" "a" "l" "s" "e") context/begin))))) (testing "When a null literal is analyzed." (let [null-literal (Token. "literal" "null" (Location. 1 1) (Location. 1 4))] (is (= null-literal (scan-literal '("n" "u" "l" "l") context/begin))))) (testing "When an unexpected token is found in the sequence." (is (thrown-with-msg? java.text.ParseException #"Unexpected token y at line 1, column 3." (scan-literal '("t" "r" "y" "e") context/begin))) (testing "When the input terminates unexpectedly." (is (thrown-with-msg? java.text.ParseException #"Unexpected end of input at line 1, column 4." (scan-literal '("f" "a" "l" "s") context/begin))))))
Handle less than 0 seconds.
(ns wombats-web-client.components.countdown-timer (:require [cljs-time.core :as t] [cljs-time.format :as f] [reagent.core :as reagent])) (defn- seconds-until [time] (t/in-seconds (t/interval (t/now) time))) (defn- format-time [time] (let [total-seconds (seconds-until time) seconds (mod total-seconds 60) minutes (/ (- total-seconds seconds) 60) seconds-display (if (< seconds 10) (str "0" seconds) seconds)] (str minutes ":" seconds-display))) (defn countdown-timer [start-time] (let [cmpnt-state (reagent/atom {:interval-fn nil})] (reagent/create-class {:component-will-mount (fn [] ;; Force timer to redraw every second (swap! cmpnt-state assoc :interval-fn (.setInterval js/window #(reagent/force-update-all) 1000))) :component-will-unmount (fn [] (.clearInterval js/window (:interval-fn @cmpnt-state))) :reagent-render (fn [] [:span {:class-name "countdown-timer"} (format-time start-time)])})))
(ns wombats-web-client.components.countdown-timer (:require [cljs-time.core :as t] [cljs-time.format :as f] [reagent.core :as reagent])) (defn- seconds-until [time] (t/in-seconds (t/interval (t/now) time))) (defn- format-time [time] (let [total-seconds (seconds-until time) seconds (mod total-seconds 60) minutes (/ (- total-seconds seconds) 60) seconds-formatted (if (< seconds 10) (str "0" seconds) seconds)] (if (< seconds 0) "0:00" (str minutes ":" seconds-formatted)))) (defn countdown-timer [start-time] (let [cmpnt-state (reagent/atom {:interval-fn nil})] (reagent/create-class {:component-will-mount (fn [] ;; Force timer to redraw every second (swap! cmpnt-state assoc :interval-fn (.setInterval js/window #(reagent/force-update-all) 1000))) :component-will-unmount (fn [] (.clearInterval js/window (:interval-fn @cmpnt-state))) :reagent-render (fn [] [:span {:class-name "countdown-timer"} (format-time start-time)])})))
Add regex anchors to time format regex
(ns vip.data-processor.validation.v5.hours-open (:require [vip.data-processor.validation.v5.util :as util])) (defn valid-time-with-zone? [time] (re-matches #"(?:(?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]|(?:24:00:00))(?:Z|[+-](?:(?:0[0-9]|1[0-3]):[0-5][0-9]|14:00))" time)) (defn validate-times [{:keys [import-id] :as ctx}] (let [hours-open-path "VipObject.0.HoursOpen.*{1}.Schedule.*{1}.Hours.*{1}" times (util/select-lquery import-id (str hours-open-path ".StartTime|EndTime.*{1}")) invalid-times (remove (comp valid-time-with-zone? :value) times)] (reduce (fn [ctx row] (update-in ctx [:errors :hours-open (-> row :path .getValue) :format] conj (:value row))) ctx invalid-times)))
(ns vip.data-processor.validation.v5.hours-open (:require [vip.data-processor.validation.v5.util :as util])) (defn valid-time-with-zone? [time] (re-matches #"\A(?:(?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]|(?:24:00:00))(?:Z|[+-](?:(?:0[0-9]|1[0-3]):[0-5][0-9]|14:00))\z" time)) (defn validate-times [{:keys [import-id] :as ctx}] (let [hours-open-path "VipObject.0.HoursOpen.*{1}.Schedule.*{1}.Hours.*{1}" times (util/select-lquery import-id (str hours-open-path ".StartTime|EndTime.*{1}")) invalid-times (remove (comp valid-time-with-zone? :value) times)] (reduce (fn [ctx row] (update-in ctx [:errors :hours-open (-> row :path .getValue) :format] conj (:value row))) ctx invalid-times)))
Fix missing quote in core-test
(ns libx.core-test (:require [clojure.test :refer [run-tests]] [libx.lang-test] [libx.deflogical-test] [libx.macros-test] [libx.tuple-rule-test] [libx.util-test] [libx.defaction-test] [libx.listeners-test])) (defn run [] (for [ns ['libx.lang-test 'libx.deflogical-test 'libx.macros-test 'libx.tuple-rule-test 'libx.util-test 'libx.defaction-test [libx.listeners-test]]] (dosync (-> ns (in-ns) (run-tests))))) (run)
(ns libx.core-test (:require [clojure.test :refer [run-tests]] [libx.lang-test] [libx.deflogical-test] [libx.macros-test] [libx.tuple-rule-test] [libx.util-test] [libx.defaction-test] [libx.listeners-test])) (defn run [] (for [ns ['libx.lang-test 'libx.deflogical-test 'libx.macros-test 'libx.tuple-rule-test 'libx.util-test 'libx.defaction-test '[libx.listeners-test]]] (dosync (-> ns (in-ns) (run-tests))))) (run)
Update Jetty dependency to 9.4.12.v20180830
(defproject ring/ring-jetty-adapter "1.7.0" :description "Ring Jetty adapter." :url "https://github.com/ring-clojure/ring" :scm {:dir ".."} :license {:name "The MIT License" :url "http://opensource.org/licenses/MIT"} :dependencies [[org.clojure/clojure "1.7.0"] [ring/ring-core "1.7.0"] [ring/ring-servlet "1.7.0"] [org.eclipse.jetty/jetty-server "9.2.24.v20180105"]] :aliases {"test-all" ["with-profile" "default:+1.8:+1.9" "test"]} :profiles {:dev {:dependencies [[clj-http "2.2.0"]] :jvm-opts ["-Dorg.eclipse.jetty.server.HttpChannelState.DEFAULT_TIMEOUT=500"]} :1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]} :1.9 {:dependencies [[org.clojure/clojure "1.9.0"]]}})
(defproject ring/ring-jetty-adapter "1.7.0" :description "Ring Jetty adapter." :url "https://github.com/ring-clojure/ring" :scm {:dir ".."} :license {:name "The MIT License" :url "http://opensource.org/licenses/MIT"} :dependencies [[org.clojure/clojure "1.7.0"] [ring/ring-core "1.7.0"] [ring/ring-servlet "1.7.0"] [org.eclipse.jetty/jetty-server "9.4.12.v20180830"]] :aliases {"test-all" ["with-profile" "default:+1.8:+1.9" "test"]} :profiles {:dev {:dependencies [[clj-http "2.2.0"]] :jvm-opts ["-Dorg.eclipse.jetty.server.HttpChannelState.DEFAULT_TIMEOUT=500"]} :1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]} :1.9 {:dependencies [[org.clojure/clojure "1.9.0"]]}})
Prepare for next release cycle.
(defproject onyx-app/lein-template "0.8.11.3" :description "Onyx Leiningen application template" :url "https://github.com/onyx-platform/onyx-template" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :plugins [[lein-set-version "0.4.1"]] :profiles {:dev {:plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}} :eval-in-leiningen true)
(defproject onyx-app/lein-template "0.8.11.4-SNAPSHOT" :description "Onyx Leiningen application template" :url "https://github.com/onyx-platform/onyx-template" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :plugins [[lein-set-version "0.4.1"]] :profiles {:dev {:plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}} :eval-in-leiningen true)
Prepare for next release cycle.
(defproject org.onyxplatform/onyx-metrics "0.8.1.1" :description "Instrument Onyx workflows" :url "https://github.com/MichaelDrogalis/onyx" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :dependencies [^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}} [org.onyxplatform/onyx "0.8.1"] [org.clojure/clojure "1.7.0"] [interval-metrics "1.0.0"] [stylefruits/gniazdo "0.4.0"]] :java-opts ^:replace ["-server" "-Xmx3g"] :global-vars {*warn-on-reflection* true *assert* false *unchecked-math* :warn-on-boxed} :profiles {:dev {:dependencies [[riemann-clojure-client "0.4.1"]] :plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}})
(defproject org.onyxplatform/onyx-metrics "0.8.1.2-SNAPSHOT" :description "Instrument Onyx workflows" :url "https://github.com/MichaelDrogalis/onyx" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :dependencies [^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}} [org.onyxplatform/onyx "0.8.1"] [org.clojure/clojure "1.7.0"] [interval-metrics "1.0.0"] [stylefruits/gniazdo "0.4.0"]] :java-opts ^:replace ["-server" "-Xmx3g"] :global-vars {*warn-on-reflection* true *assert* false *unchecked-math* :warn-on-boxed} :profiles {:dev {:dependencies [[riemann-clojure-client "0.4.1"]] :plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}})
Add utility for running benchmarks
(defproject caesium "0.8.0-SNAPSHOT" :description "libsodium for clojure" :url "https://github.com/lvh/caesium" :deploy-repositories [["releases" :clojars] ["snapshots" :clojars]] :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.8.0"] [com.github.jnr/jnr-ffi "2.0.9"] [commons-codec/commons-codec "1.10"] [byte-streams "0.2.2"] [org.clojure/math.combinatorics "0.1.3"]] :main ^:skip-aot caesium.core :target-path "target/%s" :profiles {:uberjar {:aot :all} :dev {:dependencies [[criterium "0.4.4"]]} :test {:plugins [[lein-cljfmt "0.3.0"] [lein-kibit "0.1.2"] [jonase/eastwood "0.2.3"] [lein-codox "0.9.4"] [lein-cloverage "1.0.7-SNAPSHOT"]] :test-selectors {:default (complement :benchmark) :benchmark :benchmark}}} :codox {:metadata {:doc/format :markdown} :output-path "doc"} :global-vars {*warn-on-reflection* true})
(defproject caesium "0.8.0-SNAPSHOT" :description "libsodium for clojure" :url "https://github.com/lvh/caesium" :deploy-repositories [["releases" :clojars] ["snapshots" :clojars]] :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.8.0"] [com.github.jnr/jnr-ffi "2.0.9"] [commons-codec/commons-codec "1.10"] [byte-streams "0.2.2"] [org.clojure/math.combinatorics "0.1.3"]] :main ^:skip-aot caesium.core :target-path "target/%s" :profiles {:uberjar {:aot :all} :dev {:dependencies [[criterium "0.4.4"]]} :test {:plugins [[lein-cljfmt "0.3.0"] [lein-kibit "0.1.2"] [jonase/eastwood "0.2.3"] [lein-codox "0.9.4"] [lein-cloverage "1.0.7-SNAPSHOT"]]} :benchmarks {:test-paths ^:replace ["benchmarks/"]}} :codox {:metadata {:doc/format :markdown} :output-path "doc"} :global-vars {*warn-on-reflection* true} :aliases {"benchmark" ["with-profile" "+benchmarks" "test"]})
Update Medley dependency to 0.6.0
(defproject compojure "1.3.3" :description "A concise routing library for Ring" :url "https://github.com/weavejester/compojure" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/tools.macro "0.1.5"] [clout "2.1.2"] [medley "0.5.5"] [ring/ring-core "1.3.2"] [ring/ring-codec "1.0.0"]] :plugins [[codox "0.8.10"]] :codox {:src-dir-uri "http://github.com/weavejester/compojure/blob/1.3.3/" :src-linenum-anchor-prefix "L"} :profiles {:dev {:jvm-opts ^:replace [] :dependencies [[ring/ring-mock "0.2.0"] [criterium "0.4.3"] [javax.servlet/servlet-api "2.5"]]} :1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]} :1.7 {:dependencies [[org.clojure/clojure "1.7.0-beta2"]]}})
(defproject compojure "1.3.3" :description "A concise routing library for Ring" :url "https://github.com/weavejester/compojure" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/tools.macro "0.1.5"] [clout "2.1.2"] [medley "0.6.0"] [ring/ring-core "1.3.2"] [ring/ring-codec "1.0.0"]] :plugins [[codox "0.8.10"]] :codox {:src-dir-uri "http://github.com/weavejester/compojure/blob/1.3.3/" :src-linenum-anchor-prefix "L"} :profiles {:dev {:jvm-opts ^:replace [] :dependencies [[ring/ring-mock "0.2.0"] [criterium "0.4.3"] [javax.servlet/servlet-api "2.5"]]} :1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]} :1.7 {:dependencies [[org.clojure/clojure "1.7.0-beta2"]]}})
Use in memory datomic db by default
;; Copyright (C) 2013 Anders Sundman <anders@4zm.org> ;; ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU Affero General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public License ;; along with this program. If not, see <http://www.gnu.org/licenses/>. (ns spira.core.system (:require [spira.dm.garden :as garden] [spira.dm.plant-desc :as plant-desc] [spira.dm.in-memory-repo :as mem-repo])) ;; A representation of the applications total top level state. (defrecord SystemState [garden-repo plant-desc-repo]) (defn dev-system [] "Create a light weight development state" (->SystemState (mem-repo/memory-garden-repo) (mem-repo/memory-plant-description-repo)))
;; Copyright (C) 2013 Anders Sundman <anders@4zm.org> ;; ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU Affero General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public License ;; along with this program. If not, see <http://www.gnu.org/licenses/>. (ns spira.core.system (:require [spira.dm.garden :as garden] [spira.dm.plant-desc :as plant-desc] [spira.dm.in-memory-repo :as mem-repo] [spira.datomic-adapter.repo :as da])) ;; A representation of the applications total top level state. (defrecord SystemState [garden-repo plant-desc-repo]) (defn mem-dev-system [] "Create a light weight development state" (->SystemState (mem-repo/memory-garden-repo) (mem-repo/memory-plant-description-repo))) (defn dev-system [] "Create a light weight development state" (let [uri da/test-uri] (da/create-test-db uri) (->SystemState (da/datomic-garden-repo uri) (da/datomic-plant-description-repo uri))))
Bring back timer stopping code
(ns nightmod.manager (:require [clojure.java.io :as io] [nightmod.utils :as u] [play-clj.core :refer :all]) (:import [com.badlogic.gdx.assets.loaders FileHandleResolver] [com.badlogic.gdx.files FileHandle])) ; make all assets load relative to the current project's directory (def manager (asset-manager* (reify FileHandleResolver (resolve [this file-name] (FileHandle. (io/file @u/project-dir file-name)))))) (set-asset-manager! manager) (defn clear-ns! [nspace] (doall (map #(ns-unmap nspace %) (keys (ns-interns nspace))))) (defn clean! [] (clear-ns! u/game-ns) (on-gl (asset-manager! manager :clear)))
(ns nightmod.manager (:require [clojure.java.io :as io] [nightmod.utils :as u] [play-clj.core :refer :all]) (:import [com.badlogic.gdx.assets.loaders FileHandleResolver] [com.badlogic.gdx.files FileHandle])) ; make all assets load relative to the current project's directory (def manager (asset-manager* (reify FileHandleResolver (resolve [this file-name] (FileHandle. (io/file @u/project-dir file-name)))))) (set-asset-manager! manager) ; keep a reference to all timers to we can stop them later (def timers (atom [])) (let [create-and-add-timer! (deref #'play-clj.core/create-and-add-timer!)] (intern 'play-clj.core 'create-and-add-timer! (fn [screen id] (let [t (create-and-add-timer! screen id)] (swap! timers conj t) t)))) (defn stop-timers! [] (doseq [t @timers] (.stop t)) (reset! timers [])) (defn clear-ns! [nspace] (doall (map #(ns-unmap nspace %) (keys (ns-interns nspace))))) (defn clean! [] (clear-ns! u/game-ns) (stop-timers!) (on-gl (asset-manager! manager :clear)))
Comment out ultra until it is fixed
{:user { :aliases { "lint" ["do" ["cljfmt" "check"] "kibit"] "fix" ["do" ["cljfmt" "fix"] ["kibit" "--replace" "--interactive"]]} :plugins [ [lein-drip "0.1.1-SNAPSHOT"];; faster JVM [venantius/ultra "0.6.0" :exclusions [org.clojure/clojure org.clojure/core.rrb-vector]];; pretty print [lein-auto "0.1.3"];; watch tasks [lein-try "0.4.3"];; REPL experimenting ;; Project Scaffolding [chestnut/lein-template "0.15.2"] ;; Dependency Management [com.livingsocial/lein-dependency-check "0.2.2"] [lein-ancient "0.6.10"] [lein-nvd "0.3.1"];; National Vulnerability Database dependency-checker ;; Code Quality [lein-cljfmt "0.5.7"] [lein-kibit "0.1.5"] [lein-bikeshed "0.4.1"] ;; Testing [lein-cloverage "1.0.9"]]}}
{:user { :aliases { "lint" ["do" ["cljfmt" "check"] "kibit"] "fix" ["do" ["cljfmt" "fix"] ["kibit" "--replace" "--interactive"]]} :plugins [ [lein-drip "0.1.1-SNAPSHOT"];; faster JVM ;; Ultra is awesome, but v0.6.0 has issues with JDK v11 ; [venantius/ultra "0.6.0"];; pretty print and stuff [lein-auto "0.1.3"];; watch tasks [lein-try "0.4.3"];; REPL experimenting ;; Project Scaffolding [chestnut/lein-template "0.15.2"] ;; Dependency Management [com.livingsocial/lein-dependency-check "0.2.2"] [lein-ancient "0.6.10"] [lein-nvd "0.3.1"];; National Vulnerability Database dependency-checker ;; Code Quality [lein-cljfmt "0.5.7"] [lein-kibit "0.1.5"] [lein-bikeshed "0.4.1"] ;; Testing [lein-cloverage "1.0.9"]]}}
Advance version number to 0.1.1
(defproject io.aviso/twixt "0.1.0" :description "An extensible asset pipeline for Clojure web applications" :url "https://github.com/AvisoNovate/twixt" :license {:name "Apache Sofware Licencse 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0.html"} :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/tools.logging "0.2.6"] [ring/ring-core "1.1.8"] [org.mozilla/rhino "1.7R4"] [com.github.sommeri/less4j "1.0.4"] [de.neuland/jade4j "0.3.12"]] :repositories [["jade4j" "https://raw.github.com/neuland/jade4j/master/releases"]] :profiles {:dev {:dependencies [[log4j "1.2.17"]]}})
(defproject io.aviso/twixt "0.1.1" :description "An extensible asset pipeline for Clojure web applications" :url "https://github.com/AvisoNovate/twixt" :license {:name "Apache Sofware Licencse 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0.html"} :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/tools.logging "0.2.6"] [ring/ring-core "1.1.8"] [org.mozilla/rhino "1.7R4"] [com.github.sommeri/less4j "1.0.4"] [de.neuland/jade4j "0.3.12"]] :repositories [["jade4j" "https://raw.github.com/neuland/jade4j/master/releases"]] :profiles {:dev {:dependencies [[log4j "1.2.17"]]}})
Add note about slf4j implementation
(defproject deraen/less4clj "0.3.4-SNAPSHOT" :description "Wrapper for Less4j" :url "https://github.com/deraen/less4clj" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html" :distribution :repo :comments "same as Clojure"} :dependencies [[org.clojure/clojure "1.7.0" :scope "provided"] [com.github.sommeri/less4j "1.15.4"] [com.github.sommeri/less4j-javascript "0.0.1" :exclusions [com.github.sommeri/less4j]] [org.webjars/webjars-locator "0.29"] [org.slf4j/slf4j-nop "1.7.13"] ;; For testing the webjars asset locator implementation [org.webjars/bootstrap "3.3.6" :scope "test"]] :profiles {:dev {:resource-paths ["test-resources"]} :1.8 {:dependencies [[org.clojure/clojure "1.8.0-RC4"]]} :1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}} :aliases {"all" ["with-profile" "dev:dev,1.6:dev,1.8"]})
(defproject deraen/less4clj "0.3.4-SNAPSHOT" :description "Wrapper for Less4j" :url "https://github.com/deraen/less4clj" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html" :distribution :repo :comments "same as Clojure"} :dependencies [[org.clojure/clojure "1.7.0" :scope "provided"] [com.github.sommeri/less4j "1.15.4"] [com.github.sommeri/less4j-javascript "0.0.1" :exclusions [com.github.sommeri/less4j]] [org.webjars/webjars-locator "0.29"] ;; FIXME: Will this cause problems if there is another ;; slf4j implementation already present? [org.slf4j/slf4j-nop "1.7.13"] ;; For testing the webjars asset locator implementation [org.webjars/bootstrap "3.3.6" :scope "test"]] :profiles {:dev {:resource-paths ["test-resources"]} :1.8 {:dependencies [[org.clojure/clojure "1.8.0-RC4"]]} :1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}} :aliases {"all" ["with-profile" "dev:dev,1.6:dev,1.8"]})
Add some GC tuning flags
(defproject mars-ogler "1.0.1-SNAPSHOT" :description "Holy cow, it's Mars!" :url "http://github.com/aperiodic/mars-ogler" :license {:name "GNU Affero GPL" :url "http://www.gnu.org/licenses/agpl"} :dependencies [[org.clojure/clojure "1.4.0"] [org.clojure/tools.cli "0.2.2"] [cheshire "5.2.0"] [clj-http "0.6.3"] [clj-time "0.4.4"] [compojure "1.1.3"] [enlive "1.0.1"] [hiccup "1.0.0"] [ring/ring-core "1.1.6"] [ring/ring-jetty-adapter "1.1.6"]] :plugins [[lein-ring "0.7.1"]] :main mars-ogler.main :uberjar-name "mars-ogler.jar" :jvm-opts ["-Xmx850m" "-XX:+UseConcMarkSweepGC" "-XX:+CMSIncrementalMode" "-XX:+UseCompressedOops"] :ring {:handler mars-ogler.routes/ogler-handler :init mars-ogler.images/setup!})
(defproject mars-ogler "1.0.1-SNAPSHOT" :description "Holy cow, it's Mars!" :url "http://github.com/aperiodic/mars-ogler" :license {:name "GNU Affero GPL" :url "http://www.gnu.org/licenses/agpl"} :dependencies [[org.clojure/clojure "1.4.0"] [org.clojure/tools.cli "0.2.2"] [cheshire "5.2.0"] [clj-http "0.6.3"] [clj-time "0.4.4"] [compojure "1.1.3"] [enlive "1.0.1"] [hiccup "1.0.0"] [ring/ring-core "1.1.6"] [ring/ring-jetty-adapter "1.1.6"]] :plugins [[lein-ring "0.7.1"]] :main mars-ogler.main :uberjar-name "mars-ogler.jar" :jvm-opts ["-Xmx850m" "-XX:+UseConcMarkSweepGC" "-XX:+CMSConcurrentMTEnabled" "-XX:+UseParNewGC" "-XX:ConcGCThreads=4" "-XX:ParallelGCThreads=4" "-XX:+UseCompressedOops"] :ring {:handler mars-ogler.routes/ogler-handler :init mars-ogler.images/setup!})
Prepare for next release cycle.
(defproject org.onyxplatform/onyx-datomic "0.10.0.0-beta5" :description "Onyx plugin for Datomic" :url "https://github.com/onyx-platform/onyx-datomic" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :dependencies [[org.clojure/clojure "1.8.0"] ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}} [org.onyxplatform/onyx "0.10.0-beta5"]] :test-selectors {:default (complement :ci) :ci :ci :all (constantly true)} :profiles {:dev {:dependencies [[com.datomic/datomic-free "0.9.5544"] [aero "0.2.0"]] :plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]] :resource-paths ["test-resources/"]} :circle-ci {:jvm-opts ["-Xmx4g"]}})
(defproject org.onyxplatform/onyx-datomic "0.10.0.0-SNAPSHOT" :description "Onyx plugin for Datomic" :url "https://github.com/onyx-platform/onyx-datomic" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :dependencies [[org.clojure/clojure "1.8.0"] ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}} [org.onyxplatform/onyx "0.10.0-beta5"]] :test-selectors {:default (complement :ci) :ci :ci :all (constantly true)} :profiles {:dev {:dependencies [[com.datomic/datomic-free "0.9.5544"] [aero "0.2.0"]] :plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]] :resource-paths ["test-resources/"]} :circle-ci {:jvm-opts ["-Xmx4g"]}})
Make sure immutant serves this at the root context
(defproject mdr2 "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :dependencies [[org.clojure/clojure "1.6.0"] [hiccup "1.0.5"] [compojure "1.1.6"] [com.gfredericks/java.jdbc "0.2.3-p3"] [org.xerial/sqlite-jdbc "3.7.2"]] :plugins [[lein-ring "0.8.10"]] :ring {:handler mdr2.web/app} :profiles {:dev {:dependencies [[javax.servlet/servlet-api "2.5"] [ring-mock "0.1.5"]]}})
(defproject mdr2 "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :dependencies [[org.clojure/clojure "1.6.0"] [hiccup "1.0.5"] [compojure "1.1.6"] [com.gfredericks/java.jdbc "0.2.3-p3"] [org.xerial/sqlite-jdbc "3.7.2"]] :plugins [[lein-ring "0.8.10"]] :ring {:handler mdr2.web/app} :immutant {:context-path "/"} :profiles {:dev {:dependencies [[javax.servlet/servlet-api "2.5"] [ring-mock "0.1.5"]]}})
Move test.check dependency to development profile
(defproject hu.ssh/github-changelog "0.1.0-SNAPSHOT" :description "GitHub changelog" :url "https://github.com/raszi/github-changelog" :main hu.ssh.github-changelog.cli :repl-options {:init-ns user} :license {:name "MIT" :url "http://choosealicense.com/licenses/mit/"} :dependencies [[org.clojure/clojure "1.7.0"] [org.clojure/core.match "0.3.0-alpha4"] [prismatic/schema "1.0.3"] [environ "1.0.1"] [org.clojure/tools.cli "0.3.3"] [clj-jgit "0.8.8"] [tentacles "0.4.0"] [grimradical/clj-semver "0.3.0-20130920.191002-3" :exclusions [org.clojure/clojure]] [org.clojure/test.check "0.9.0"]] :profiles {:dev {:dependencies [[org.clojure/tools.namespace "0.2.11"]] :source-paths ["dev"]} :uberjar {:aot :all}})
(defproject hu.ssh/github-changelog "0.1.0-SNAPSHOT" :description "GitHub changelog" :url "https://github.com/raszi/github-changelog" :main hu.ssh.github-changelog.cli :repl-options {:init-ns user} :license {:name "MIT" :url "http://choosealicense.com/licenses/mit/"} :dependencies [[org.clojure/clojure "1.7.0"] [org.clojure/core.match "0.3.0-alpha4"] [prismatic/schema "1.0.3"] [environ "1.0.1"] [org.clojure/tools.cli "0.3.3"] [clj-jgit "0.8.8"] [tentacles "0.4.0"] [grimradical/clj-semver "0.3.0-20130920.191002-3" :exclusions [org.clojure/clojure]]] :profiles {:dev {:dependencies [[org.clojure/tools.namespace "0.2.11"] [org.clojure/test.check "0.9.0"]] :source-paths ["dev"]} :uberjar {:aot :all}})
Prepare for next release cycle.
(defproject onyx-app/lein-template "0.12.5.0" :description "Onyx Leiningen application template" :url "https://github.com/onyx-platform/onyx-template" :license {:name "MIT License" :url "http://choosealicense.com/licenses/mit/#"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :plugins [[lein-set-version "0.4.1"]] :profiles {:dev {:plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}} :eval-in-leiningen true)
(defproject onyx-app/lein-template "0.12.5.1-SNAPSHOT" :description "Onyx Leiningen application template" :url "https://github.com/onyx-platform/onyx-template" :license {:name "MIT License" :url "http://choosealicense.com/licenses/mit/#"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :plugins [[lein-set-version "0.4.1"]] :profiles {:dev {:plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}} :eval-in-leiningen true)
Add support for writing sorted-map
(ns yaml.writer (:import (org.yaml.snakeyaml Yaml DumperOptions DumperOptions$FlowStyle))) (def flow-styles {:auto DumperOptions$FlowStyle/AUTO :block DumperOptions$FlowStyle/BLOCK :flow DumperOptions$FlowStyle/FLOW}) (defn- make-dumper-options [& {:keys [flow-style]}] (doto (DumperOptions.) (.setDefaultFlowStyle (flow-styles flow-style)))) (defn make-yaml [& {:keys [dumper-options]}] (if dumper-options (Yaml. ^DumperOptions (apply make-dumper-options (mapcat (juxt key val) dumper-options))) (Yaml.))) (defprotocol YAMLWriter (encode [data])) (extend-protocol YAMLWriter clojure.lang.IPersistentMap (encode [data] (into {} (for [[k v] data] [(encode k) (encode v)]))) clojure.lang.IPersistentSet (encode [data] (into #{} (map encode data))) clojure.lang.IPersistentCollection (encode [data] (map encode data)) clojure.lang.Keyword (encode [data] (name data)) Object (encode [data] data) nil (encode [data] data)) (defn generate-string [data & opts] (.dump ^Yaml (apply make-yaml opts) ^Object (encode data)))
(ns yaml.writer (:import (org.yaml.snakeyaml Yaml DumperOptions DumperOptions$FlowStyle))) (def flow-styles {:auto DumperOptions$FlowStyle/AUTO :block DumperOptions$FlowStyle/BLOCK :flow DumperOptions$FlowStyle/FLOW}) (defn- make-dumper-options [& {:keys [flow-style]}] (doto (DumperOptions.) (.setDefaultFlowStyle (flow-styles flow-style)))) (defn make-yaml [& {:keys [dumper-options]}] (if dumper-options (Yaml. ^DumperOptions (apply make-dumper-options (mapcat (juxt key val) dumper-options))) (Yaml.))) (defprotocol YAMLWriter (encode [data])) (extend-protocol YAMLWriter clojure.lang.IPersistentMap (encode [data] (into {} (for [[k v] data] [(encode k) (encode v)]))) clojure.lang.IPersistentSet (encode [data] (into #{} (map encode data))) clojure.lang.IPersistentCollection (encode [data] (map encode data)) clojure.lang.PersistentTreeMap (encode [data] (into (sorted-map) (for [[k v] data] [(encode k) (encode v)]))) clojure.lang.Keyword (encode [data] (name data)) Object (encode [data] data) nil (encode [data] data)) (defn generate-string [data & opts] (.dump ^Yaml (apply make-yaml opts) ^Object (encode data)))
Watch when running audio project
(set-env! :source-paths #{"src"} :resource-paths #{"resources"} :dependencies '[[org.clojure/clojure "1.8.0"] [alda "1.0.0-rc34"]]) (task-options! pom {:project '{{app-name}} :version "0.1.0-SNAPSHOT" :description "FIXME: write description"} aot {:namespace #{'{{namespace}}}} jar {:main '{{namespace}}}) (require '{{namespace}}) (deftask run [] (comp (with-pre-wrap fileset ({{namespace}}/-main) fileset))) (deftask build [] (comp (aot) (pom) (uber) (jar) (target)))
(set-env! :source-paths #{"src"} :resource-paths #{"resources"} :dependencies '[[org.clojure/clojure "1.8.0"] [alda "1.0.0-rc34"]]) (task-options! pom {:project '{{app-name}} :version "0.1.0-SNAPSHOT" :description "FIXME: write description"} aot {:namespace #{'{{namespace}}}} jar {:main '{{namespace}}}) (require '{{namespace}}) (deftask run [] (comp (watch) (with-pre-wrap fileset ({{namespace}}/-main) fileset))) (deftask build [] (comp (aot) (pom) (uber) (jar) (target)))
Add clojure.tools.namespace to user deps.
{:user {:dependencies [[clj-stacktrace "0.2.5"] [org.clojure/tools.trace "0.7.5"] [redl "0.1.0"] [spyscope "0.1.3"] [slamhound "1.3.3"]] :plugins [[lein-difftest "1.3.7"] [lein-drip "0.1.1-SNAPSHOT"] [lein-clojars "0.9.1"] [lein-pprint "1.1.1"] [lein-ring "0.8.0"] [lein-cljsbuild "0.1.9"] [lein-deps-tree "0.1.2"] [lein-marginalia "0.7.1"]] :repl-options {:timeout 120000} :injections [(require '[redl core complete]) (require 'spyscope.core) (let [orig (ns-resolve (doto 'clojure.stacktrace require) 'print-cause-trace) new (ns-resolve (doto 'clj-stacktrace.repl require) 'pst)] (alter-var-root orig (constantly @new)))] :vimclojure-opts {:repl true}}}
{:user {:dependencies [[clj-stacktrace "0.2.5"] [org.clojure/tools.trace "0.7.5"] [org.clojure/tools.namespace "0.2.3"] [redl "0.1.0"] [spyscope "0.1.3"] [slamhound "1.3.3"]] :plugins [[lein-difftest "1.3.7"] [lein-drip "0.1.1-SNAPSHOT"] [lein-clojars "0.9.1"] [lein-pprint "1.1.1"] [lein-ring "0.8.0"] [lein-cljsbuild "0.1.9"] [lein-deps-tree "0.1.2"] [lein-marginalia "0.7.1"]] :repl-options {:timeout 120000} :injections [(require '[redl core complete]) (require 'spyscope.core) (require 'clojure.tools.namespace) (let [orig (ns-resolve (doto 'clojure.stacktrace require) 'print-cause-trace) new (ns-resolve (doto 'clj-stacktrace.repl require) 'pst)] (alter-var-root orig (constantly @new)))] :vimclojure-opts {:repl true}}}
Enable typemode selection through main program arguments
(ns bogo-clojure.bg-websocket (:gen-class) (:require [bogo-clojure.core :as bogo] [clojure.string :as string]) (:use org.httpkit.server)) (defn process! [channel data] (let [[old-string key] (string/split-lines data) new-string (bogo/process-key old-string key)] (println old-string key new-string) (send! channel new-string) )) (defn handler [req] (with-channel req channel (on-close channel (fn [status] (println "channel closed"))) (if (websocket? channel) (println "WebSocket channel") (println "HTTP channel")) (on-receive channel (fn [data] (process! channel data))))) (defn -main [& args] (run-server handler {:port 8080}))
(ns bogo-clojure.bg-websocket (:gen-class) (:require [bogo-clojure.core :as bogo] [bogo-clojure.bg-typemode :refer :all] [clojure.string :as string]) (:use org.httpkit.server)) (def typemode (atom TELEX)) (defn process! [channel data] (let [[old-string key] (string/split-lines data) new-string (bogo/process-key old-string key TELEX)] (println old-string key new-string) (send! channel new-string) )) (defn handler [req] (with-channel req channel (on-close channel (fn [status] (println "channel closed"))) (if (websocket? channel) (println "WebSocket channel") (println "HTTP channel")) (on-receive channel (fn [data] (process! channel data))))) (defn -main [& args] (if (not (empty? args)) (reset! typemode (eval (symbol "bogo-clojure.bg-typemode" (string/uppercase (string/join args))))) true) (run-server handler {:port 8080}))
Make sure to use the correct defmutation
(ns cawala.api.mutations (:require [taoensso.timbre :as timbre] [com.wsscode.pathom.core :as p] [com.wsscode.pathom.connect :as pc] [cawala.api.read :as r] [fulcro.server :refer [defmutation]])) ;; Place your server mutations here #_(defmutation delete-person "Server Mutation: Handles deleting a person on the server" [{:keys [person-id]}] (action [{:keys [state]}] (timbre/info "Server deleting person" person-id) (swap! people-db dissoc person-id))) (def delete-person r/delete-person) #_(pc/defmutation delete-person [{::keys [db]} {:keys [person-id]}] {::pc/params [:person-id] ::pc/sym 'cawala.api.mutations/delete-person} (do (timbre/info "Server deleting person" person-id) (swap! db dissoc person-id) nil))
(ns cawala.api.mutations (:require [taoensso.timbre :as timbre] [com.wsscode.pathom.core :as p] [com.wsscode.pathom.connect :as pc] [cawala.api.read :as r] #_[fulcro.server :refer [defmutation]])) ;; Place your server mutations here #_(defmutation delete-person "Server Mutation: Handles deleting a person on the server" [{:keys [person-id]}] (action [{:keys [state]}] (timbre/info "Server deleting person" person-id) (swap! people-db dissoc person-id))) (def delete-person r/delete-person) #_(pc/defmutation delete-person [{::keys [db]} {:keys [person-id]}] {::pc/params [:person-id] ::pc/sym 'cawala.api.mutations/delete-person} (do (timbre/info "Server deleting person" person-id) (swap! db dissoc person-id) nil))
Add log-exceptions wrapper to watch.
(ns incise.watcher (:require [watchtower.core :refer [watcher rate file-filter extensions on-change]])) (defn watch [change-fn] (watcher ["resources/posts/" "resources/pages/"] (rate 300) (on-change change-fn))) (def watching nil) (defn start-watching [& args] (alter-var-root #'watching (fn [& _] (apply watch args)))) (defn stop-watching [] (when watching (future-cancel watching)))
(ns incise.watcher (:require [watchtower.core :refer [watcher rate file-filter extensions on-change]])) (defn log-exceptions [func & args] "Log (i.e. print) exceptions received from the given function." (try (apply func args) (catch Exception e (println (.getMessage e))))) (defn watch [change-fn] (watcher ["resources/posts/" "resources/pages/"] (rate 300) (on-change (partial log-exceptions change-fn)))) (def watching nil) (defn start-watching [& args] (alter-var-root #'watching (fn [& _] (apply watch args)))) (defn stop-watching [] (when watching (future-cancel watching)))
Load cljs.js and cljs.env before macrowbar is loaded (also - Trigger travis build)
(ns mikron.runtime.core-test2 "Property based testing namespace." (:require [clojure.test :as test] [clojure.test.check.clojure-test :as tc.test #?@(:cljs [:include-macros true])] [clojure.test.check.properties :as tc.prop #?@(:cljs [:include-macros true])] [clojure.test.check.generators :as tc.gen #?@(:cljs [:include-macros true])] [macrowbar.core :as macrowbar] [mikron.runtime.core :as mikron] [mikron.runtime.test-generators :as test-generators] [mikron.runtime.test-util :as test-util] ;; Load these for macrowbar [cljs.js] [cljs.env])) ;; Property based testing (def buffer (mikron/allocate-buffer 100000)) (macrowbar/emit :debug-self-hosted (tc.test/defspec core-test 100 (tc.prop/for-all [[schema value] (tc.gen/bind test-generators/schema-generator (fn [schema] (tc.gen/tuple (tc.gen/return (macrowbar/eval `(mikron/schema ~schema :processor-types #{:pack :unpack}))) (test-generators/value-generator schema))))] (test-util/equal? value (mikron/with-buffer buffer (->> value (mikron/pack schema) (mikron/unpack schema)))))))
(ns mikron.runtime.core-test2 "Property based testing namespace." (:require [clojure.test :as test] [clojure.test.check.clojure-test :as tc.test #?@(:cljs [:include-macros true])] [clojure.test.check.properties :as tc.prop #?@(:cljs [:include-macros true])] [clojure.test.check.generators :as tc.gen #?@(:cljs [:include-macros true])] ;; Load these for macrowbar [cljs.js] [cljs.env] [macrowbar.core :as macrowbar] [mikron.runtime.core :as mikron] [mikron.runtime.test-generators :as test-generators] [mikron.runtime.test-util :as test-util])) ;; Property based testing (def buffer (mikron/allocate-buffer 100000)) (macrowbar/emit :debug-self-hosted (tc.test/defspec core-test 100 (tc.prop/for-all [[schema value] (tc.gen/bind test-generators/schema-generator (fn [schema] (tc.gen/tuple (tc.gen/return (macrowbar/eval `(mikron/schema ~schema :processor-types #{:pack :unpack}))) (test-generators/value-generator schema))))] (test-util/equal? value (mikron/with-buffer buffer (->> value (mikron/pack schema) (mikron/unpack schema)))))))
Include low level number in route ID
(ns route-ccrs.active-routes (:require [clojure.java.jdbc :as jdbc] [yesql.core :refer [defquery]])) (defquery active-routes "route_ccrs/sql/active_routes.sql") (defn route-id [r] (select-keys r [:contract :part_no :bom_type_db :routing_revision_no :routing_alternative_no])) (defn sorted-operations [] (sorted-set-by (fn [x y] (compare (:operation_no x) (:operation_no y))) )) (defn transduce-routes [step] (let [routes (volatile! {})] (fn ([] (step)) ([r] (step (reduce step r @routes))) ([r o] (let [i (route-id o) route (conj (get @routes i (sorted-operations)) o) c (:operation_count o)] (if (and c (= (count route) c)) (step r route) (do (vreset! routes (assoc @routes i route)) r)))))))
(ns route-ccrs.active-routes (:require [clojure.java.jdbc :as jdbc] [yesql.core :refer [defquery]])) (defquery active-routes "route_ccrs/sql/active_routes.sql") (defn route-id [r] (select-keys r [:contract :part_no :lowest_level :bom_type_db :routing_revision_no :routing_alternative_no])) (defn sorted-operations [] (sorted-set-by (fn [x y] (compare (:operation_no x) (:operation_no y))) )) (defn transduce-routes [step] (let [routes (volatile! {})] (fn ([] (step)) ([r] (step (reduce step r @routes))) ([r o] (let [i (route-id o) route (conj (get @routes i (sorted-operations)) o) c (:operation_count o)] (if (and c (= (count route) c)) (step r route) (do (vreset! routes (assoc @routes i route)) r)))))))
Add global codeblock function for convenience
(do (clojure.core/use '[clojure.core]) (require '[clojure.string :as str]) (require '[clojure.pprint :as pp]) (require '[clojure.math.numeric-tower :as math]) ) (let [ res (->> "%s" str/split-lines (map (fn [x] (str " \"" (str/replace x "=" "\": \"") \"))) (str/join ",\n")) ] (str "{\n" res "\n}"))
(do ;; Imports and aliases (clojure.core/use '[clojure.core]) (require '[clojure.string :as str]) (require '[clojure.pprint :as pp]) (require '[clojure.math.numeric-tower :as math]) ;; Convenience functions (defn codeblock [s & { type :type }] (str "```" type "\n" s "\n```")) )
Remove unnecessary search page styles
(ns braid.search.ui.search-page-styles (:require [garden.units :refer [rem em px]] [braid.core.client.ui.styles.mixins :as mixins] [braid.core.client.ui.styles.vars :as vars])) (def avatar-size (rem 4)) (def card-style [:>.card {:margin-bottom "50%" :max-width (rem 25)} [:>.header {:overflow "auto"} [:>.pill.off :>.pill.on {:color [["white" "!important"]]}] [:>.status {:display "inline-block" :margin-left (em 0.5)} (mixins/mini-text)] [:>.badges {:display "inline-block" :margin [[0 (em 0.5)]]} [:>.admin::before {:display "inline-block" :-webkit-font-smoothing "antialiased"} (mixins/fontawesome \uf0e3)]] [:>img.avatar {:margin-top (px 2) :border-radius (px 3) :width avatar-size :height avatar-size :background "white" :float "left"}]] [:>.local-time [:&::after (mixins/fontawesome \uf017) {:margin-left (em 0.25)}]]]) (def >search-page [:>.page.search [:>.threads card-style] [:>.content card-style]])
(ns braid.search.ui.search-page-styles) (def >search-page [:>.page.search])
Add comment describing the rationale for the workaround
(ns status-im.ui.components.text-input.view (:require [status-im.ui.components.react :as react] [status-im.ui.components.text-input.styles :as styles] [status-im.ui.components.colors :as colors] [status-im.utils.platform :as platform] [status-im.ui.components.tooltip.views :as tooltip])) (defn text-input-with-label [{:keys [label content error style height container text] :as props}] [react/view (when label [react/text {:style styles/label} label]) [react/view {:style (merge (styles/input-container height) container)} [react/text-input (merge {:style (merge styles/input style) :placeholder-text-color colors/gray :auto-focus true :auto-capitalize :none} (dissoc props :style :height) (when-not platform/desktop? {:value text}))] (when content content)] (when error [tooltip/tooltip error (styles/error label)])])
(ns status-im.ui.components.text-input.view (:require [status-im.ui.components.react :as react] [status-im.ui.components.text-input.styles :as styles] [status-im.ui.components.colors :as colors] [status-im.utils.platform :as platform] [status-im.ui.components.tooltip.views :as tooltip])) (defn text-input-with-label [{:keys [label content error style height container text] :as props}] [react/view (when label [react/text {:style styles/label} label]) [react/view {:style (merge (styles/input-container height) container)} [react/text-input (merge {:style (merge styles/input style) :placeholder-text-color colors/gray :auto-focus true :auto-capitalize :none} (dissoc props :style :height) ;; Workaround until `value` TextInput field is available on desktop: ;; https://github.com/status-im/react-native-desktop/issues/320 (when-not platform/desktop? {:value text}))] (when content content)] (when error [tooltip/tooltip error (styles/error label)])])
Make the empty byte array a constant too
(ns caesium.crypto.generichash (:import (org.abstractj.kalium.crypto Hash))) (def ^:private sixteen-nuls (byte-array 16)) (defn blake2b "Computes the BLAKE2b digest of the given message, with optional salt, key and personalization parameters." ([message] (.blake2 (new Hash) message)) ([message & {salt :salt key :key personal :personal :or {salt sixteen-nuls personal sixteen-nuls key (byte-array 0)}}] (.blake2 (new Hash) message key salt personal)))
(ns caesium.crypto.generichash (:import (org.abstractj.kalium.crypto Hash))) (def ^:private empty-byte-array (byte-array 0)) (def ^:private sixteen-nuls (byte-array 16)) (defn blake2b "Computes the BLAKE2b digest of the given message, with optional salt, key and personalization parameters." ([message] (.blake2 (new Hash) message)) ([message & {salt :salt key :key personal :personal :or {salt sixteen-nuls personal sixteen-nuls key empty-byte-array}}] (.blake2 (new Hash) message key salt personal)))
Apply 'can always start the repl pattern'.
(ns user (:require [uswitch.bifrost.system :refer (make-system)] [clojure.tools.logging :refer (error)] [clojure.tools.namespace.repl :refer (refresh)] [com.stuartsierra.component :as component])) (def system nil) (defn init [] (alter-var-root #'system (constantly (make-system (read-string (slurp "./etc/config.edn")))))) (defn start [] (alter-var-root #'system (fn [s] (try (component/start s) (catch Exception e (error e "Error when starting system") nil))) )) (defn stop [] (alter-var-root #'system (fn [s] (when s (try (component/stop s) (catch Exception e (error e "Error when stopping system") nil)))))) (defn go [] (init) (start)) (defn reset [] (stop) (refresh :after 'user/go))
(ns user (:require [clojure.tools.logging :refer (error)] [clojure.tools.namespace.repl :refer (refresh)] [com.stuartsierra.component :as component])) (def system nil) (defn init [] ;; We do some gymnastics here to make sure that the REPL can always start ;; even in the presence of compilation errors. (require '[uswitch.bifrost.system]) (let [make-system (resolve 'uswitch.bifrost.system/make-system)] (alter-var-root #'system (constantly (make-system (read-string (slurp "./etc/config.edn"))))))) (defn start [] (alter-var-root #'system (fn [s] (try (component/start s) (catch Exception e (error e "Error when starting system") nil))) )) (defn stop [] (alter-var-root #'system (fn [s] (when s (try (component/stop s) (catch Exception e (error e "Error when stopping system") nil)))))) (defn go [] (init) (start)) (defn reset [] (stop) (refresh :after 'user/go))
Remove a load of hacky Clojure injections
{:user {:dependencies [[clj-stacktrace "0.2.7"] [im.chit/vinyasa "0.1.0"] [io.aviso/pretty "0.1.8"] [org.clojure/tools.namespace "0.2.4"] [slamhound "1.3.1"] [spyscope "0.1.4"] [criterium "0.4.2"]] :plugins [[codox "0.6.6"] [jonase/eastwood "0.0.2"] [lein-cljsbuild "1.0.0"] [lein-clojars "0.9.1"] [lein-cloverage "1.0.2"] [lein-difftest "2.0.0"] [lein-kibit "0.0.8"] [lein-marginalia "0.7.1"] [lein-pprint "1.1.1"] [lein-swank "1.4.4"]] :injections [(require 'spyscope.core 'vinyasa.inject 'io.aviso.repl 'clojure.repl 'clojure.main '[criterium.core :refer [bench quick-bench]]) (vinyasa.inject/inject 'clojure.core '[[vinyasa.inject [inject inject]] [vinyasa.pull [pull pull]] [vinyasa.lein [lein lein]] [clojure.repl apropos dir doc find-doc source [root-cause cause]] [clojure.tools.namespace.repl [refresh refresh]] [clojure.pprint [pprint >pprint]] [io.aviso.binary [write-binary >bin]]])] :aliases {"slamhound" ["run" "-m" "slam.hound"]} :source-paths ["/Users/jcf/.lein/dev"] :search-page-size 30}}
{:user {:dependencies [[clj-stacktrace "0.2.7"] [org.clojure/tools.namespace "0.2.4"] [slamhound "1.3.1"] [spyscope "0.1.4"] [criterium "0.4.2"]] :plugins [[codox "0.6.6"] [jonase/eastwood "0.0.2"] [lein-cljsbuild "1.0.0"] [lein-clojars "0.9.1"] [lein-cloverage "1.0.2"] [lein-difftest "2.0.0"] [lein-kibit "0.0.8"] [lein-marginalia "0.7.1"] [lein-pprint "1.1.1"] [lein-swank "1.4.4"]] :injections [(require 'spyscope.core '[criterium.core :refer [bench quick-bench]])] :aliases {"slamhound" ["run" "-m" "slam.hound"]} :search-page-size 30}}
Remove unneeded requires in RetentionContest validator
(ns vip.data-processor.validation.v5.retention-contest (:require [korma.core :as korma] [vip.data-processor.db.postgres :as postgres] [vip.data-processor.validation.v5.util :as util])) (def validate-no-missing-candidate-ids (util/build-xml-tree-value-query-validator :errors :retention-contests :missing :missing-candidate-id "SELECT xtv.path FROM (SELECT DISTINCT subltree(path, 0, 4) || 'CandidateId' AS path FROM xml_tree_values WHERE results_id = ? AND subltree(path, 0, 4) ~ 'VipObject.0.RetentionContest.*{1}') xtv LEFT JOIN (SELECT path FROM xml_tree_values WHERE results_id = ?) xtv2 ON xtv.path = subltree(xtv2.path, 0, 5) WHERE xtv2.path IS NULL" util/two-import-ids))
(ns vip.data-processor.validation.v5.retention-contest (:require [vip.data-processor.validation.v5.util :as util])) (def validate-no-missing-candidate-ids (util/build-xml-tree-value-query-validator :errors :retention-contests :missing :missing-candidate-id "SELECT xtv.path FROM (SELECT DISTINCT subltree(path, 0, 4) || 'CandidateId' AS path FROM xml_tree_values WHERE results_id = ? AND subltree(path, 0, 4) ~ 'VipObject.0.RetentionContest.*{1}') xtv LEFT JOIN (SELECT path FROM xml_tree_values WHERE results_id = ?) xtv2 ON xtv.path = subltree(xtv2.path, 0, 5) WHERE xtv2.path IS NULL" util/two-import-ids))
Add quotes to Open Sans
(ns braid.ui.styles.body) (def body [:body {:margin 0 :padding 0 :font-family "Open Sans, Helvetica, Arial, sans-serif" :font-size "12px" :background "#eee"}])
(ns braid.ui.styles.body) (def body [:body {:margin 0 :padding 0 :font-family "\"Open Sans\", Helvetica, Arial, sans-serif" :font-size "12px" :background "#eee"}])
Remove inline tests in favor of dedicated test files
; https://projecteuler.net/problem=1 (ns euler.001 (require [clojure.set :refer :all] [clojure.test :refer [is]])) (defn multiple-of-n? [n, num] (zero? (mod num n))) (defn multiple-of-3-or-5? [n] (or (multiple-of-n? 3 n) (multiple-of-n? 5 n))) ; Produce the entire range of numbers and then filter it down (defn multiples-3-and-5-sol1 [min max] (reduce + (filter multiple-of-3-or-5? (range min max)))) (is (= 233168 (multiples-3-and-5-sol1 0 1000))) ; Use `distinct` instead (defn multiples-3-and-5-sol2 [min max] (reduce + (distinct (concat (range min max 3) (range min max 5))))) (is (= 233168 (multiples-3-and-5-sol2 0 1000))) ; Produce two ranges and convert to `set` to deduplicate the range ; Apparently slightly more performant (but who cares) (defn multiples-3-and-5-sol3 [min max] (reduce + (set (concat (range min max 3) (range min max 5))))) (is (= 233168 (multiples-3-and-5-sol3 0 1000)))
; https://projecteuler.net/problem=1 (ns euler.001 (require [clojure.set :refer :all] [clojure.test :refer [is]])) (defn multiple-of-n? [n, num] (zero? (mod num n))) (defn multiple-of-3-or-5? [n] (or (multiple-of-n? 3 n) (multiple-of-n? 5 n))) ; Produce the entire range of numbers and then filter it down (defn multiples-3-and-5-sol1 [min max] (reduce + (filter multiple-of-3-or-5? (range min max)))) ; Use `distinct` instead (defn multiples-3-and-5-sol2 [min max] (reduce + (distinct (concat (range min max 3) (range min max 5))))) ; Produce two ranges and convert to `set` to deduplicate the range ; Apparently slightly more performant (but who cares) (defn multiples-3-and-5-sol3 [min max] (reduce + (set (concat (range min max 3) (range min max 5)))))
Add route to ping niantic server
(ns cruncher.config) (def api {:host "http://localhost:5000/" :init "api/init/" :base "api/" :login "api/login" :get-all-pokemon "api/pokemon" :toggle-favorite "api/pokemon/favorite" :crunch-selected-pokemon "api/pokemon/delete" :status-delete "api/status/delete" :get-player "api/player"})
(ns cruncher.config) (def api {:host "http://localhost:5000/" :init "api/init/" :base "api/" :login "api/login" :get-all-pokemon "api/pokemon" :toggle-favorite "api/pokemon/favorite" :crunch-selected-pokemon "api/pokemon/delete" :status-delete "api/status/delete" :get-player "api/player" :api-status "api/status/niantic"})
Add task to push without gpg
(set-env! :source-paths #{"src"} :dependencies '[[org.clojure/clojure "1.8.0" :scope "provided"] [adzerk/bootlaces "0.1.13" :scope "test"]]) (require '[adzerk.bootlaces :refer :all]) ;; tasks: build-jar push-snapshot push-release (def +version+ "1.0.0") (bootlaces! +version+) (task-options! pom {:project 'afrey/boot-asset-fingerprint :version +version+ :description "Boot task to fingerprint asset references in html files." :url "https://github.com/AdamFrey/boot-asset-fingerprint" :scm {:url "https://github.com/AdamFrey/boot-asset-fingerprint"} :license {"MIT" "https://opensource.org/licenses/MIT"}}) (deftask dev [] (comp (watch) (build-jar)))
(set-env! :source-paths #{"src"} :dependencies '[[org.clojure/clojure "1.8.0" :scope "provided"] [adzerk/bootlaces "0.1.13" :scope "test"]]) (require '[adzerk.bootlaces :as deploy]) (def +version+ "1.0.0") (deploy/bootlaces! +version+) (task-options! pom {:project 'afrey/boot-asset-fingerprint :version +version+ :description "Boot task to fingerprint asset references in html files." :url "https://github.com/AdamFrey/boot-asset-fingerprint" :scm {:url "https://github.com/AdamFrey/boot-asset-fingerprint"} :license {"MIT" "https://opensource.org/licenses/MIT"}}) (deftask dev [] (comp (watch) (deploy/build-jar))) (deftask push-release [] (comp (deploy/build-jar) (#'deploy/collect-clojars-credentials) (push :tag true :gpg-sign false :ensure-release true :repo "deploy-clojars")))
Fix test-pom to watch for abort.
(ns test-pom (:use [leiningen.core :only [read-project defproject]] [leiningen.util.maven :only [make-model]] [leiningen.pom :only [pom]]) (:use [clojure.test] [clojure.java.io :only [file delete-file]])) (def test-project (read-project "test_projects/sample/project.clj")) (deftest test-pom (let [pom-file (file (:root test-project) "pom.xml")] (delete-file pom-file true) (pom test-project) (is (.exists pom-file)))) (deftest test-make-model-includes-build-settings (let [model (make-model test-project)] (is (= "src" (-> model .getBuild .getSourceDirectory))) (is (= "test" (-> model .getBuild .getTestSourceDirectory))))) (deftest test-snapshot-checking (is (thrown? Exception (pom (assoc test-project :version "1.0" :dependencies [['clojure "1.0.0-SNAPSHOT"]])))))
(ns test-pom (:use [leiningen.core :only [read-project defproject]] [leiningen.util.maven :only [make-model]] [leiningen.pom :only [pom]]) (:use [clojure.test] [clojure.java.io :only [file delete-file]])) (def test-project (read-project "test_projects/sample/project.clj")) (deftest test-pom (let [pom-file (file (:root test-project) "pom.xml")] (delete-file pom-file true) (pom test-project) (is (.exists pom-file)))) (deftest test-make-model-includes-build-settings (let [model (make-model test-project)] (is (= "src" (-> model .getBuild .getSourceDirectory))) (is (= "test" (-> model .getBuild .getTestSourceDirectory))))) (deftest test-snapshot-checking (let [aborted? (atom false)] (binding [leiningen.core/abort (partial reset! aborted?)] (pom (assoc test-project :version "1.0" :dependencies [['clojure "1.0.0-SNAPSHOT"]])) (is @aborted?))))
Add speclj-tmux to lein user profile.
{:user {:dependencies [[clj-stacktrace "0.2.5"] [org.clojure/tools.trace "0.7.5"] [org.clojure/tools.namespace "0.2.3"] [redl "0.1.0"] [spyscope "0.1.3"] [slamhound "1.3.3"]] :plugins [[lein-difftest "1.3.7"] [lein-drip "0.1.1-SNAPSHOT"] [lein-exec "0.3.0"] [lein-clojars "0.9.1"] [lein-pprint "1.1.1"] [lein-ring "0.8.0"] [lein-cljsbuild "0.1.9"] [lein-deps-tree "0.1.2"] [lein-marginalia "0.7.1"]] :repl-options {:timeout 120000} :injections [(require '[redl core complete]) (require 'spyscope.core) (require 'clojure.tools.namespace) (let [orig (ns-resolve (doto 'clojure.stacktrace require) 'print-cause-trace) new (ns-resolve (doto 'clj-stacktrace.repl require) 'pst)] (alter-var-root orig (constantly @new)))] :vimclojure-opts {:repl true}}}
{:user {:dependencies [[clj-stacktrace "0.2.5"] [org.clojure/tools.trace "0.7.5"] [org.clojure/tools.namespace "0.2.3"] [redl "0.1.0"] [speclj-tmux "1.0.0"] [spyscope "0.1.3"] [slamhound "1.3.3"]] :plugins [[lein-difftest "1.3.7"] [lein-drip "0.1.1-SNAPSHOT"] [lein-exec "0.3.0"] [lein-clojars "0.9.1"] [lein-pprint "1.1.1"] [lein-ring "0.8.0"] [lein-cljsbuild "0.1.9"] [lein-deps-tree "0.1.2"] [lein-marginalia "0.7.1"]] :repl-options {:timeout 120000} :injections [(require '[redl core complete]) (require 'spyscope.core) (require 'clojure.tools.namespace) (let [orig (ns-resolve (doto 'clojure.stacktrace require) 'print-cause-trace) new (ns-resolve (doto 'clj-stacktrace.repl require) 'pst)] (alter-var-root orig (constantly @new)))] :vimclojure-opts {:repl true}}}
Make prod mode the default for noir
(ns engulf.core (:gen-class) (:require [engulf.benchmark :as benchmark] [noir.server :as nr-server]) (:use aleph.http noir.core lamina.core)) (defn start-webserver [args] (nr-server/load-views "src/engulf/views") (let [mode (keyword (or (first args) :dev)) port (Integer. (get (System/getenv) "PORT" "3000")) noir-handler (nr-server/gen-handler {:mode mode})] (start-http-server (wrap-ring-handler noir-handler) {:port port :websocket true}))) (defn -main [& args] (start-webserver args) (println "Engulf Started!"))
(ns engulf.core (:gen-class) (:require [engulf.benchmark :as benchmark] [noir.server :as nr-server]) (:use aleph.http noir.core lamina.core)) (defn start-webserver [args] (nr-server/load-views "src/engulf/views") (let [mode (keyword (or (first args) :prod)) port (Integer. (get (System/getenv) "PORT" "3000")) noir-handler (nr-server/gen-handler {:mode mode})] (start-http-server (wrap-ring-handler noir-handler) {:port port :websocket true}))) (defn -main [& args] (start-webserver args) (println "Engulf Started!"))
Handle 'ies' words in singularise fn
(ns tesq.utils (:require [clojure.string :refer [replace capitalize]])) (defn prettify "Turn table name into something more human friendly." [s] (-> s capitalize (replace #"_" " "))) (defn singularise "Turn plural string into singular." [s] (replace s #"s$" ""))
(ns tesq.utils (:require [clojure.string :refer [replace capitalize]])) (defn prettify "Turn table name into something more human friendly." [s] (-> s capitalize (replace #"_" " "))) (defn singularise "Turn plural string into singular." [s] (cond (re-find #"ies$" s) (replace s #"ies$" "y") :else (replace s #"s$" "") ))
Make prevent-default and stop-propagation functions nil safe.
;; This Source Code Form is subject to the terms of the Mozilla Public ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; ;; Copyright (c) 2015-2016 Andrey Antukh <niwi@niwi.nz> ;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com> (ns uxbox.util.dom (:require [goog.dom :as dom])) (defn get-element-by-class ([classname] (dom/getElementByClass classname)) ([classname node] (dom/getElementByClass classname node))) (defn stop-propagation [e] (.stopPropagation e)) (defn prevent-default [e] (.preventDefault e)) (defn event->inner-text [e] (.-innerText (.-target e))) (defn event->value [e] (.-value (.-target e))) (defn event->target [e] (.-target e))
;; This Source Code Form is subject to the terms of the Mozilla Public ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; ;; Copyright (c) 2015-2016 Andrey Antukh <niwi@niwi.nz> ;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com> (ns uxbox.util.dom (:require [goog.dom :as dom])) (defn get-element-by-class ([classname] (dom/getElementByClass classname)) ([classname node] (dom/getElementByClass classname node))) (defn stop-propagation [e] (when e (.stopPropagation e))) (defn prevent-default [e] (when e (.preventDefault e))) (defn event->inner-text [e] (.-innerText (.-target e))) (defn event->value [e] (.-value (.-target e))) (defn event->target [e] (.-target e))
Solve part two of day 5 puzzle
(ns solver.core (:gen-class)) (def vowels #{"a" "e" "i" "o" "u"}) (defn contains-at-least-three-vowels [word] (>= (count (filter vowels (clojure.string/split word #""))) 3)) (defn contains-repeated-letter [word] (re-find #"(\w)\1" word)) (defn contains-forbidden-string [word] (re-find #"ab|cd|pq|xy" word)) (defn nice-word [word] (and (contains-at-least-three-vowels word) (contains-repeated-letter word) (not (contains-forbidden-string word)))) (defn -main "I don't do a whole lot ... yet." [& args] (with-open [rdr (clojure.java.io/reader "input")] (println (count (filter nice-word (line-seq rdr))))))
(ns solver.core (:gen-class)) (def vowels #{"a" "e" "i" "o" "u"}) (defn contains-at-least-three-vowels [word] (>= (count (filter vowels (clojure.string/split word #""))) 3)) (defn contains-repeated-letter [word] (re-find #"(\w)\1" word)) (defn contains-forbidden-string [word] (re-find #"ab|cd|pq|xy" word)) (defn nice-word [word] (and (contains-at-least-three-vowels word) (contains-repeated-letter word) (not (contains-forbidden-string word)))) (defn contains-repeated-pair [word] (re-find #"(\w{2})\w*\1" word)) (defn contains-palindrome-trigram [word] (re-find #"(\w)\w\1" word)) (defn nice-word2 [word] (and (contains-repeated-pair word) (contains-palindrome-trigram word))) (defn -main "I don't do a whole lot ... yet." [& args] (with-open [rdr (clojure.java.io/reader "input")] (let [words (line-seq rdr)] (println (count (filter nice-word words))) (println (count (filter nice-word2 words))))))
Update pom urls for library
(set-env! :source-paths #{"src"} :dependencies '[[org.clojure/clojure "1.8.0" :scope "provided"] [adzerk/bootlaces "0.1.13" :scope "test"]]) (require '[adzerk.bootlaces :refer :all]) ;; tasks: build-jar push-snapshot push-release (def +version+ "1.0.0-SNAPSHOT") (bootlaces! +version+) (task-options! pom {:project 'afrey/boot-asset-fingerprint :version +version+ :description "Boot task to fingerprint asset references in html files." :url "https://github.com/pointslope/boot-fingerprint" :scm {:url "https://github.com/pointslope/boot-fingerprint"} :license {"EPL" "http://www.eclipse.org/legal/epl-v10.html"}})
(set-env! :source-paths #{"src"} :dependencies '[[org.clojure/clojure "1.8.0" :scope "provided"] [adzerk/bootlaces "0.1.13" :scope "test"]]) (require '[adzerk.bootlaces :refer :all]) ;; tasks: build-jar push-snapshot push-release (def +version+ "1.0.0-SNAPSHOT") (bootlaces! +version+) (task-options! pom {:project 'afrey/boot-asset-fingerprint :version +version+ :description "Boot task to fingerprint asset references in html files." :url "https://github.com/AdamFrey/boot-asset-fingerprint" :scm {:url "https://github.com/AdamFrey/boot-asset-fingerprint"} :license {"EPL" "http://www.eclipse.org/legal/epl-v10.html"}})
Use destruction in getting season-episode part
(ns subman.helpers (:require [net.cgrand.enlive-html :as html] [org.httpkit.client :as http] [subman.const :as const])) (defn remove-first-0 "Remove first 0 from string" [query] (clojure.string/replace query #"^(0+)" "")) (defn get-from-line "Get parsed html from line" [line] (html/html-resource (java.io.StringReader. line))) (defn fetch "Fetch url content" [url] (-> url (http/get {:timeout const/conection-timeout}) deref :body get-from-line)) (defn nil-to-blank "Replace nil with blank string" [item] (if (nil? item) "" item)) (defn make-safe "Make fnc call safe" [fnc fallback] (fn [x] (try (fnc x) (catch Exception e (do (println e) fallback))))) (defn get-season-episode "Add season and episode filters" [text] (if-let [nums (re-find #"[sS](\d+)[eE](\d+)" text)] [(remove-first-0 (get nums 1)) (remove-first-0 (get nums 2))] ["" ""])) (defn get-from-file "Get parsed html from file" [path] (html/html-resource (java.io.StringReader. (slurp path))))
(ns subman.helpers (:require [net.cgrand.enlive-html :as html] [org.httpkit.client :as http] [subman.const :as const])) (defn remove-first-0 "Remove first 0 from string" [query] (clojure.string/replace query #"^(0+)" "")) (defn get-from-line "Get parsed html from line" [line] (html/html-resource (java.io.StringReader. line))) (defn fetch "Fetch url content" [url] (-> url (http/get {:timeout const/conection-timeout}) deref :body get-from-line)) (defn nil-to-blank "Replace nil with blank string" [item] (if (nil? item) "" item)) (defn make-safe "Make fnc call safe" [fnc fallback] (fn [x] (try (fnc x) (catch Exception e (do (println e) fallback))))) (defn get-season-episode "Add season and episode filters" [text] (if-let [[_ season episode] (re-find #"[sS](\d+)[eE](\d+)" text)] [(remove-first-0 season) (remove-first-0 episode)] ["" ""])) (defn get-from-file "Get parsed html from file" [path] (html/html-resource (java.io.StringReader. (slurp path))))
Update jOOQ version to 3.4.4
(defproject suricatta "0.1.0-SNAPSHOT" :description "High level sql toolkit for clojure (backed by jooq library)" :url "http://example.com/FIXME" :license {:name "Apache 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0.txt"} :dependencies [[org.clojure/clojure "1.6.0"] [org.jooq/jooq "3.4.2"] [clojure.jdbc "0.3.0"] [postgresql "9.3-1101.jdbc41"] [com.h2database/h2 "1.3.176"]])
(defproject suricatta "0.1.0-SNAPSHOT" :description "High level sql toolkit for clojure (backed by jooq library)" :url "http://example.com/FIXME" :license {:name "Apache 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0.txt"} :dependencies [[org.clojure/clojure "1.6.0"] [org.jooq/jooq "3.4.4"] [clojure.jdbc "0.3.0"] [postgresql "9.3-1101.jdbc41"] [com.h2database/h2 "1.3.176"]])
Remove the contrib dep, since we're no longer depending on it.
(defproject cake "0.7.0-beta1" :description "Save your fork, there's cake!" :dependencies [[clojure "1.2.0"] [clojure-contrib "1.2.0"] [uncle "0.2.3"] [depot "0.1.7"] [classlojure "0.6.3"] [useful "0.7.4-alpha4"] [slingshot "0.7.2"] [org.clojure/tools.namespace "0.1.1" :exclusions [org.clojure/java.classpath]] [org.clojars.ninjudd/java.classpath "0.1.2-SNAPSHOT"] [org.clojars.ninjudd/data.xml "0.0.1-SNAPSHOT"] [com.jcraft/jsch "0.1.42"] [difform "1.1.1"] [org.clojars.rosejn/clansi "1.2.0-SNAPSHOT" :exclusions [org.clojure/clojure]] [clj-stacktrace "0.2.3"]] :copy-deps true)
(defproject cake "0.7.0-beta1" :description "Save your fork, there's cake!" :dependencies [[clojure "1.2.0"] [uncle "0.2.3"] [depot "0.1.7"] [classlojure "0.6.3"] [useful "0.7.4-alpha4"] [slingshot "0.7.2"] [org.clojure/tools.namespace "0.1.1" :exclusions [org.clojure/java.classpath]] [org.clojars.ninjudd/java.classpath "0.1.2-SNAPSHOT"] [org.clojars.ninjudd/data.xml "0.0.1-SNAPSHOT"] [com.jcraft/jsch "0.1.42"] [difform "1.1.1"] [org.clojars.rosejn/clansi "1.2.0-SNAPSHOT" :exclusions [org.clojure/clojure]] [clj-stacktrace "0.2.3"]] :copy-deps true)
Prepare for next release cycle.
(defproject org.onyxplatform/onyx-datomic "0.10.0.0-alpha6" :description "Onyx plugin for Datomic" :url "https://github.com/onyx-platform/onyx-datomic" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :dependencies [[org.clojure/clojure "1.8.0"] ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}} [org.onyxplatform/onyx "0.10.0-alpha6"]] :test-selectors {:default (complement :ci) :ci :ci :all (constantly true)} :profiles {:dev {:dependencies [[com.datomic/datomic-free "0.9.5544"] [aero "0.2.0"]] :plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]] :resource-paths ["test-resources/"]} :circle-ci {:jvm-opts ["-Xmx4g"]}})
(defproject org.onyxplatform/onyx-datomic "0.10.0.0-SNAPSHOT" :description "Onyx plugin for Datomic" :url "https://github.com/onyx-platform/onyx-datomic" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :dependencies [[org.clojure/clojure "1.8.0"] ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}} [org.onyxplatform/onyx "0.10.0-alpha6"]] :test-selectors {:default (complement :ci) :ci :ci :all (constantly true)} :profiles {:dev {:dependencies [[com.datomic/datomic-free "0.9.5544"] [aero "0.2.0"]] :plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]] :resource-paths ["test-resources/"]} :circle-ci {:jvm-opts ["-Xmx4g"]}})
Upgrade eastwood plugin to 0.2.0.
(defproject statuses "1.0.0-SNAPSHOT" :description "Statuses app for innoQ" :url "https://github.com/innoq/statuses" :license {:name "Apache License, Version 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0" :distribution :repo :comments "A business-friendly OSS license"} :dependencies [[org.clojure/clojure "1.6.0"] [ring "1.3.1"] [compojure "1.2.1"] [clj-time "0.8.0"] [org.clojure/data.json "0.2.5"]] :pedantic? :abort :plugins [[jonase/eastwood "0.1.5"]] :profiles {:dev {:dependencies [[ring-mock "0.1.5"]]} :uberjar {:aot [statuses.server]}} :main statuses.server :aliases {"lint" "eastwood"})
(defproject statuses "1.0.0-SNAPSHOT" :description "Statuses app for innoQ" :url "https://github.com/innoq/statuses" :license {:name "Apache License, Version 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0" :distribution :repo :comments "A business-friendly OSS license"} :dependencies [[org.clojure/clojure "1.6.0"] [ring "1.3.1"] [compojure "1.2.1"] [clj-time "0.8.0"] [org.clojure/data.json "0.2.5"]] :pedantic? :abort :plugins [[jonase/eastwood "0.2.0"]] :profiles {:dev {:dependencies [[ring-mock "0.1.5"]]} :uberjar {:aot [statuses.server]}} :main statuses.server :aliases {"lint" "eastwood"} :eastwood {:exclude-linters [:constant-test]})
Revert back to snapshot version.
(defproject cli4clj "1.0.0" ;(defproject cli4clj "1.0.1-SNAPSHOT" :description "Create simple interactive CLIs for Clojure applications." :url "https://github.com/ruedigergad/cli4clj" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.7.0"] [clj-assorted-utils "1.11.0"] [jline/jline "2.13"]] :global-vars {*warn-on-reflection* true} :html5-docs-docs-dir "ghpages/doc" :html5-docs-ns-includes #"^cli4clj.*" :html5-docs-repository-url "https://github.com/ruedigergad/cli4clj/blob/master" :test2junit-output-dir "ghpages/test-results" :test2junit-run-ant true :main cli4clj.example :plugins [[lein-cloverage "1.0.2"] [test2junit "1.1.3"] [lein-html5-docs "3.0.3"]])
;(defproject cli4clj "1.0.0" (defproject cli4clj "1.0.1-SNAPSHOT" :description "Create simple interactive CLIs for Clojure applications." :url "https://github.com/ruedigergad/cli4clj" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.7.0"] [clj-assorted-utils "1.11.0"] [jline/jline "2.13"]] :global-vars {*warn-on-reflection* true} :html5-docs-docs-dir "ghpages/doc" :html5-docs-ns-includes #"^cli4clj.*" :html5-docs-repository-url "https://github.com/ruedigergad/cli4clj/blob/master" :test2junit-output-dir "ghpages/test-results" :test2junit-run-ant true :main cli4clj.example :plugins [[lein-cloverage "1.0.2"] [test2junit "1.1.3"] [lein-html5-docs "3.0.3"]])
Use the official jline from central
(defproject reply "0.1.0-SNAPSHOT" :description "REPL-y: A fitter, happier, more productive REPL for Clojure." :dependencies [[org.clojure/clojure "1.3.0"] [org.clojars.trptcolin/jline "2.6-alpha1"] [org.thnetos/cd-client "0.3.1" :exclusions [org.clojure/clojure]] [clj-stacktrace "0.2.4"] [clojure-complete "0.2.1" :exclusions [org.clojure/clojure]] [org.clojure/tools.nrepl "0.2.0-beta1"]] :dev-dependencies [[midje "1.3-alpha4" :exclusions [org.clojure/clojure]] [lein-midje "[1.0.0,)"]] :aot [reply.reader.jline.JlineInputReader] :source-path "src/clj" :java-source-path "src/java")
(defproject reply "0.1.0-SNAPSHOT" :description "REPL-y: A fitter, happier, more productive REPL for Clojure." :dependencies [[org.clojure/clojure "1.3.0"] [jline "2.6"] [org.thnetos/cd-client "0.3.1" :exclusions [org.clojure/clojure]] [clj-stacktrace "0.2.4"] [clojure-complete "0.2.1" :exclusions [org.clojure/clojure]] [org.clojure/tools.nrepl "0.2.0-beta1"]] :dev-dependencies [[midje "1.3-alpha4" :exclusions [org.clojure/clojure]] [lein-midje "[1.0.0,)"]] :aot [reply.reader.jline.JlineInputReader] :source-path "src/clj" :java-source-path "src/java")
Prepare for next release cycle.
(defproject org.onyxplatform/onyx-metrics "0.8.1.0-0.8.1" :description "Instrument Onyx workflows" :url "https://github.com/MichaelDrogalis/onyx" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :dependencies [^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}} [org.onyxplatform/onyx "0.8.1"] [org.clojure/clojure "1.7.0"] [interval-metrics "1.0.0"] [stylefruits/gniazdo "0.4.0"]] :java-opts ^:replace ["-server" "-Xmx3g"] :global-vars {*warn-on-reflection* true *assert* false *unchecked-math* :warn-on-boxed} :profiles {:dev {:dependencies [[riemann-clojure-client "0.4.1"]] :plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}})
(defproject org.onyxplatform/onyx-metrics "0.8.1.1-SNAPSHOT" :description "Instrument Onyx workflows" :url "https://github.com/MichaelDrogalis/onyx" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :dependencies [^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}} [org.onyxplatform/onyx "0.8.1"] [org.clojure/clojure "1.7.0"] [interval-metrics "1.0.0"] [stylefruits/gniazdo "0.4.0"]] :java-opts ^:replace ["-server" "-Xmx3g"] :global-vars {*warn-on-reflection* true *assert* false *unchecked-math* :warn-on-boxed} :profiles {:dev {:dependencies [[riemann-clojure-client "0.4.1"]] :plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}})
Move declaration of GH token and Slack URL outside handler fn
(ns tako.core (:require [tako.github :as github] [tako.slack :as slack] [clojure.tools.logging :refer [info]]) (:gen-class :methods [^:static [handler [Object] String]])) (defn -handler [unused] (info (str "Called tako from lambda... " unused)) (binding [tako.github/github-token "herewego"] (slack/publish-notifications (github/poll-notifications)))) (defn -main "This function is included for testing purposes. It is NOT used by AWS lambda. It is intended to be used with `lein run your-github-token`" [& args] (info "Running tako from main...") (binding [tako.github/github-token (first args) tako.slack/slack-webhook-url (second args)] (slack/publish-notifications (github/poll-notifications))))
(ns tako.core (:require [tako.github :as github] [tako.slack :as slack] [clojure.tools.logging :refer [info]]) (:gen-class :methods [^:static [handler [Object] String]])) (def github-token "PLACE YOUR GITHUB TOKEN HERE") (def slack-webhook-url "PLACE THE SLACK WEBHOOK URL HERE") (defn -handler "This is the function called by AWS Lambda" [unused] (info (str "Called tako from lambda... ")) (binding [tako.github/github-token github-token tako.slack/slack-webhook-url slack-webhook-url] (slack/publish-notifications (github/poll-notifications)))) (defn -main "This function is included for testing purposes. It is NOT used by AWS lambda. It is intended to be used with `lein run your-github-token slack-url`" [& args] (info "Running tako from main...") (binding [tako.github/github-token (first args) tako.slack/slack-webhook-url (second args)] (slack/publish-notifications (github/poll-notifications))))
Improve logging on the graceful shutdown hook.
(ns circle.system (:require [circle.backend.build.run :as run]) (:require [circle.backend.ec2 :as ec2]) (:use [clojure.tools.logging :only (infof)])) (defn graceful-shutdown "Shutdown there are no more running builds." [] (letfn [(shutdown [] (infof "graceful shutdown watcher, count=%s" (count @run/in-progress)) (when (zero? (count @run/in-progress)) (let [id (ec2/self-instance-id)] (when id (infof "calling self-terminate on %s" id) (ec2/terminate-instances! id)))))] (add-watch run/in-progress :shutdown (fn [key in-progress old-state new-state] (shutdown))) (shutdown)))
(ns circle.system (:require [circle.backend.build.run :as run]) (:require [circle.backend.build :as build]) (:require [circle.backend.ec2 :as ec2]) (:use [clojure.tools.logging :only (infof)])) (defn graceful-shutdown "Shutdown there are no more running builds." [] (letfn [(shutdown [] (infof "graceful shutdown watcher, count=%s builds=%s" (count @run/in-progress) (map build/build-name @run/in-progress)) (when (zero? (count @run/in-progress)) (let [id (ec2/self-instance-id)] (when id (infof "calling self-terminate on %s" id) (ec2/terminate-instances! id)))))] (add-watch run/in-progress :shutdown (fn [key in-progress old-state new-state] (shutdown))) (shutdown)))
Set clojure 1.8 as default clj version.
(defproject buddy/buddy-core "0.9.0" :description "Cryptographic Api for Clojure." :url "https://github.com/funcool/buddy-core" :license {:name "Apache 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0"} :dependencies [[org.clojure/clojure "1.7.0" :scope "provided"] [commons-codec/commons-codec "1.10"] [org.bouncycastle/bcprov-jdk15on "1.54"] [org.bouncycastle/bcpkix-jdk15on "1.54"]] :source-paths ["src"] :test-paths ["test"] :jar-exclusions [#"\.cljx|\.swp|\.swo|user.clj"] :javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"])
(defproject buddy/buddy-core "0.9.0" :description "Cryptographic Api for Clojure." :url "https://github.com/funcool/buddy-core" :license {:name "Apache 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0"} :dependencies [[org.clojure/clojure "1.8.0" :scope "provided"] [commons-codec/commons-codec "1.10"] [org.bouncycastle/bcprov-jdk15on "1.54"] [org.bouncycastle/bcpkix-jdk15on "1.54"]] :source-paths ["src"] :test-paths ["test"] :jar-exclusions [#"\.cljx|\.swp|\.swo|user.clj"] :javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"])
Undo the last couple of useless tweaks
(ns swartz.models.core (:require [environ.core :refer [env]] [clojure.string :as str])) (def db {:connection-uri (str/replace (env :database-url) #":postgres:" ":postgresql:") :classname "org.postgresql.Driver"})
(ns swartz.models.core (:require [environ.core :refer [env]])) (def db {:connection-uri (env :database-url)})
Use deconstruction in parameters and save the let.
(ns etl (:require [clojure.string :as str])) (defn- pairs [pair] (let [[value key] pair] (map (fn [k] {(str/lower-case k) value}) key))) (defn transform [words] (into {} (flatten (map pairs words))))
(ns etl (:require [clojure.string :as str])) (defn- pairs [[value key]] (map (fn [k] {(str/lower-case k) value}) key)) (defn transform [words] (into {} (flatten (map pairs words))))
Drop a vestigial (->) form, which had only one arg
(ns foreclojure.ring (:use [compojure.core :only [GET]] [ring.util.response :only [response]]) (:require [clojure.java.io :as io] [clojure.string :as s]) (:import (java.net URL))) ;; copied from compojure.route, modified to use File instead of Stream (defn resources "A route for serving resources on the classpath. Accepts the following keys: :root - the root prefix to get the resources from. Defaults to 'public'." [path & [options]] (-> (GET path {{resource-path :*} :route-params} (let [root (:root options "public")] (when-let [res (io/resource (str root "/" resource-path))] (response (io/as-file res))))))) (defn wrap-url-as-file [handler] (fn [request] (when-let [{body :body :as resp} (handler request)] (if (and (instance? URL body) (= "file" (.getProtocol ^URL body))) (update-in resp [:body] io/as-file) resp)))) (defn wrap-strip-trailing-slash [handler] (fn [request] (handler (update-in request [:uri] s/replace #"(?<=.)/$" ""))))
(ns foreclojure.ring (:use [compojure.core :only [GET]] [ring.util.response :only [response]]) (:require [clojure.java.io :as io] [clojure.string :as s]) (:import (java.net URL))) ;; copied from compojure.route, modified to use File instead of Stream (defn resources "A route for serving resources on the classpath. Accepts the following keys: :root - the root prefix to get the resources from. Defaults to 'public'." [path & [options]] (GET path {{resource-path :*} :route-params} (let [root (:root options "public")] (when-let [res (io/resource (str root "/" resource-path))] (response (io/as-file res)))))) (defn wrap-url-as-file [handler] (fn [request] (when-let [{body :body :as resp} (handler request)] (if (and (instance? URL body) (= "file" (.getProtocol ^URL body))) (update-in resp [:body] io/as-file) resp)))) (defn wrap-strip-trailing-slash [handler] (fn [request] (handler (update-in request [:uri] s/replace #"(?<=.)/$" ""))))
Add missing require's on tests main function.
;; This Source Code Form is subject to the terms of the Mozilla Public ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; ;; Copyright (c) 2016-2019 Andrey Antukh <niwi@niwi.nz> (ns user (:require [clojure.tools.namespace.repl :as repl] [clojure.walk :refer [macroexpand-all]] [clojure.pprint :refer [pprint]] [clojure.test :as test])) (defn- run-test ([] (run-test #"^suricatta\..*test.*")) ([o] (repl/refresh) (cond (instance? java.util.regex.Pattern o) (test/run-all-tests o) (symbol? o) (if-let [sns (namespace o)] (do (require (symbol sns)) (test/test-vars [(resolve o)])) (test/test-ns o))))) (defn -main [& args] (let [{:keys [fail]} (run-test)] (if (pos? fail) (System/exit fail) (System/exit 0))))
;; This Source Code Form is subject to the terms of the Mozilla Public ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; ;; Copyright (c) 2016-2019 Andrey Antukh <niwi@niwi.nz> (ns user (:require [clojure.tools.namespace.repl :as repl] [clojure.walk :refer [macroexpand-all]] [clojure.pprint :refer [pprint]] [clojure.test :as test])) (defn- run-test ([] (run-test #"^suricatta\..*test.*")) ([o] (repl/refresh) (cond (instance? java.util.regex.Pattern o) (test/run-all-tests o) (symbol? o) (if-let [sns (namespace o)] (do (require (symbol sns)) (test/test-vars [(resolve o)])) (test/test-ns o))))) (defn -main [& args] (require 'suricatta.core-test) (require 'suricatta.extend-test) (require 'suricatta.dsl-test) (let [{:keys [fail]} (run-test)] (if (pos? fail) (System/exit fail) (System/exit 0))))
Add tests for missing output and resolver error
(ns com.wsscode.pathom.connect.run-graph-readers-test (:require [clojure.test :refer :all] [com.wsscode.pathom.connect :as pc] [com.wsscode.pathom.sugar :as ps] [com.wsscode.pathom.core :as p])) (defn run-parser [{::keys [resolvers query]}] (let [parser (ps/connect-serial-parser {::ps/connect-reader pc/reader3} resolvers)] (parser {} query))) (deftest test-runner3 (testing "simple resolver" (is (= (run-parser {::resolvers [(pc/resolver 'a {::pc/output [:a]} (fn [_ _] {:a 42}))] ::query [:a]}) {:a 42})) (is (= (run-parser {::resolvers [(pc/resolver 'a {::pc/output [:a :b]} (fn [_ _] {:a 42 :b "foo"}))] ::query [:a :b]}) {:a 42 :b "foo"}))) (testing "missed output" (is (= (run-parser {::resolvers [(pc/resolver 'a {::pc/output [:a]} (fn [_ _] {}))] ::query [:a]}) {:a ::p/not-found}))))
(ns com.wsscode.pathom.connect.run-graph-readers-test (:require [clojure.test :refer :all] [com.wsscode.pathom.connect :as pc] [com.wsscode.pathom.sugar :as ps] [com.wsscode.pathom.core :as p])) (defn run-parser [{::keys [resolvers query]}] (let [parser (ps/connect-serial-parser {::ps/connect-reader pc/reader3} resolvers)] (parser {} query))) (deftest test-runner3 (testing "single attribute" (is (= (run-parser {::resolvers [(pc/constantly-resolver :a 42)] ::query [:a]}) {:a 42})) (testing "missed output" (is (= (run-parser {::resolvers [(pc/resolver 'a {::pc/output [:a]} (fn [_ _] {}))] ::query [:a]}) {:a ::p/not-found}))) (testing "resolver error" (is (= (run-parser {::resolvers [(pc/resolver 'a {::pc/output [:a]} (fn [_ _] (throw (ex-info "Error" {:error "detail"}))))] ::query [:a]}) {:a :com.wsscode.pathom.core/reader-error :com.wsscode.pathom.core/errors {[:a] "class clojure.lang.ExceptionInfo: Error - {:error \"detail\"}"}})))) (testing "multiple attributes" (is (= (run-parser {::resolvers [(pc/resolver 'a {::pc/output [:a :b]} (fn [_ _] {:a 42 :b "foo"}))] ::query [:a :b]}) {:a 42 :b "foo"}))))
Add function to create an AudioBuffer from CLJS data
(ns audio-utils.web-audio) (defn audio-context [] (let [constructor (or js/window.AudioContext js/window.webkitAudioContext)] (constructor.))) (defn create-buffer [ctx n-channels size sample-rate] (.createBuffer ctx n-channels size sample-rate)) (defn create-buffer-source ([ctx] (.createBufferSource ctx)) ([ctx n-channels sample-rate data] (let [buf (create-buffer ctx n-channels (count (cond-> data (> n-channels 1) first)) sample-rate) src (create-buffer-source ctx)] (doseq [channel (range 0 n-channels) :let [channel-data (.getChannelData buf channel) input-data (cond-> data (> n-channels 1) (get channel))]] (doseq [[i x] (map-indexed vector input-data)] (aset channel-data i x))) (set! (.-buffer src) buf) src)))
(ns audio-utils.web-audio) (defn audio-context [] (let [constructor (or js/window.AudioContext js/window.webkitAudioContext)] (constructor.))) (defn create-buffer ([ctx n-channels size sample-rate] (.createBuffer ctx n-channels size sample-rate))) (defn create-buffer-from-data [ctx n-channels sample-rate data] (let [buf (create-buffer ctx n-channels (count (cond-> data (> n-channels 1) first)) sample-rate)] (doseq [channel (range 0 n-channels) :let [channel-data (.getChannelData buf channel) input-data (cond-> data (> n-channels 1) (get channel))]] (doseq [[i x] (map-indexed vector input-data)] (aset channel-data i x))) buf)) (defn create-buffer-source ([ctx] (.createBufferSource ctx)) ([ctx n-channels sample-rate data] (doto (create-buffer-source ctx) (aset "buffer" (create-buffer-from-data ctx n-channels sample-rate data)))))
Add cookies to the response when specified
(ns ontrail.core (:use lamina.core aleph.http compojure.core) (:gen-class) (:require [compojure.route :as route])) (require '[monger.collection :as mc]) (use 'ring.middleware.file) (use '[clojure.data.json :only (read-json json-str)]) (use '[ontrail.summary]) (defn json-response [data & [status]] {:status (or status 200) :headers {"Content-Type" "application/json"} :body (json-str data)}) (defroutes app-routes "Routes requests to their handler function. Captures dynamic variables." (GET "/summary/:user" [user] (json-response (get-overall-summary user))) (route/resources "/") (route/not-found "Page not found")) (defn -main [& args] "Main thread for the server which starts an async server with all the routes we specified and is websocket ready." (start-http-server (wrap-ring-handler app-routes) {:host "localhost" :port 8080 :websocket true}))
(ns ontrail.core (:use lamina.core aleph.http compojure.core) (:gen-class) (:require [compojure.route :as route])) (require '[monger.collection :as mc]) (use 'ring.middleware.file) (use 'ring.middleware.cookies) (use '[clojure.data.json :only (read-json json-str)]) (use '[ontrail.summary]) (defn json-response [data & [status authToken]] {:status (or status 200) :headers {"Content-Type" "application/json"} :cookies (if authToken {"authToken" authToken} {}) :body (json-str data)}) (defroutes app-routes "Routes requests to their handler function. Captures dynamic variables." (GET "/summary/:user" [user] (json-response (get-overall-summary user))) (route/resources "/") (route/not-found "Page not found")) (defn -main [& args] "Main thread for the server which starts an async server with all the routes we specified and is websocket ready." (start-http-server (-> app-routes wrap-cookies wrap-ring-handler) {:host "localhost" :port 8080 :websocket true}))
Add full URL to request log
(ns picard.log4j.CommonLogFormatLayout (:import [java.util Date] [java.text SimpleDateFormat] [org.apache.log4j Level Logger Layout] [org.apache.log4j.spi LoggingEvent]) (:gen-class :extends org.apache.log4j.Layout)) (def commons-date-formatter (SimpleDateFormat. "dd/MMM/yyyy:kk:mm:ss Z")) (defn format-commons-logging [request timestamp] (let [request-date (Date. (long timestamp)) request-time-string (.format commons-date-formatter request-date)] (format "%s - - [%s] \"%s %s HTTP/%d.%d\" %d %d\n" (first (:remote-addr request )) request-time-string (:request-method request) (:path-info request) (first (:http-version request)) (second (:http-version request)) (:response-status request) (:response-body-size request)))) (defn -format [this ^LoggingEvent logging-event] (format-commons-logging (.getMessage logging-event) (.getTimeStamp logging-event))) (defn -ignoresThrowable [_] true) (defn -activateOptions [_])
(ns picard.log4j.CommonLogFormatLayout (:use [picard.helpers :only [request-url]]) (:import [java.util Date] [java.text SimpleDateFormat] [org.apache.log4j Level Logger Layout] [org.apache.log4j.spi LoggingEvent]) (:gen-class :extends org.apache.log4j.Layout)) (def commons-date-formatter (SimpleDateFormat. "dd/MMM/yyyy:kk:mm:ss Z")) (defn format-commons-logging [request timestamp] (let [request-date (Date. (long timestamp)) request-time-string (.format commons-date-formatter request-date)] (format "%s - - [%s] \"%s %s HTTP/%d.%d\" %d %d\n" (first (:remote-addr request )) request-time-string (:request-method request) ;; TODO: maybe change api of request-url to only take headers? (request-url [request]) (first (:http-version request)) (second (:http-version request)) (:response-status request) (:response-body-size request)))) (defn -format [this ^LoggingEvent logging-event] (format-commons-logging (.getMessage logging-event) (.getTimeStamp logging-event))) (defn -ignoresThrowable [_] true) (defn -activateOptions [_])
Switch from 'mysql-test' to 'master'
(ns clj-record.test.model.config) (comment) (def db {:classname "org.apache.derby.jdbc.EmbeddedDriver" :subprotocol "derby" :subname "/tmp/clj-record.test.db" :create true}) (comment (def db {:classname "org.postgresql.Driver" :subprotocol "postgresql" :subname "//localhost:5432/test" :user "user" :password "pass"})) (comment (def db {:classname "com.mysql.jdbc.Driver" :subprotocol "mysql" :user "root" :password "root" :subname "//localhost/test"}))
(ns clj-record.test.model.config) (comment (def db {:classname "org.apache.derby.jdbc.EmbeddedDriver" :subprotocol "derby" :subname "/tmp/clj-record.test.db" :create true})) (comment (def db {:classname "org.postgresql.Driver" :subprotocol "postgresql" :subname "//localhost:5432/test" :user "user" :password "pass"})) (comment) (def db {:classname "com.mysql.jdbc.Driver" :subprotocol "mysql" :user "root" :password "root" :subname "//localhost/test"})
Use apply str instead of join
(ns github-changelog.util (:require [clojure.string :refer [join ends-with?]])) (defn str-map [f & sqs] (join (apply map f sqs))) (defn extract-params [query-string] (into {} (for [[_ k v] (re-seq #"([^&=]+)=([^&]+)" query-string)] [(keyword k) v]))) (defn strip-trailing ([s] (strip-trailing s "/")) ([s end] (if (ends-with? s end) (recur (join (drop-last s)) end) s)))
(ns github-changelog.util (:require [clojure.string :refer [ends-with?]])) (defn str-map [f & sqs] (apply str (apply map f sqs))) (defn extract-params [query-string] (into {} (for [[_ k v] (re-seq #"([^&=]+)=([^&]+)" query-string)] [(keyword k) v]))) (defn strip-trailing ([s] (strip-trailing s "/")) ([s end] (if (ends-with? s end) (recur (apply str (drop-last s)) end) s)))
Switch to using the separate boot junit runner
(set-env! :source-paths #{"src/main/java" "src/test/java"} :dependencies '[[junit "4.12" :scope "test"]]) (def +version+ "0.1.0") (task-options! pom {:project 'http-server :version +version+ :description "A Java HTTP server." :url "https://github.com/RadicalZephyr/http-server" :scm {:url "https://github.com/RadicalZephyr/http-server.git"} :licens {"MIT" "http://opensource.org/licenses/MIT"}}) (require 'clojure.set) (deftask junit "Run the jUnit test runner." [] (with-pre-wrap fileset fileset)) (deftask test "Compile and run my jUnit tests." [] (comp (javac) (junit))) (deftask build "Build my http server." [] (comp (javac) (pom) (jar)))
(set-env! :source-paths #{"src/main/java" "src/test/java"} :dependencies '[[radicalzephyr/boot-junit "0.1.0" :scope "test"]]) (def +version+ "0.1.0") (require '[radicalzephyr.boot-junit :refer [junit]]) (task-options! pom {:project 'http-server :version +version+ :description "A Java HTTP server." :url "https://github.com/RadicalZephyr/http-server" :scm {:url "https://github.com/RadicalZephyr/http-server.git"} :licens {"MIT" "http://opensource.org/licenses/MIT"}} junit {:packages '#{net.zephyrizing.http_server}}) (deftask test "Compile and run my jUnit tests." [] (comp (javac) (junit))) (deftask build "Build my http server." [] (comp (javac) (pom) (jar)))
Enforce login code for atom-event-store
(ns rill.event-store.atom-store "This is an event store implementation using the GetEventstore.com store as a backend. Code originally taken from https://github.com/jankronquist/rock-paper-scissors-in-clojure/tree/master/eventstore/src/com/jayway/rps " (:require [clojure.tools.logging :as log] [rill.event-store :refer [EventStore]] [rill.event-store.atom-store.cursor :as cursor] [rill.event-store.atom-store.event :as event] [rill.event-stream :refer [all-events-stream-id]] [rill.message :as msg])) (defn client-opts [user password] (if (and user password) {:basic-auth [user password]})) (deftype AtomStore [uri user password] EventStore (retrieve-events-since [_ stream-id cursor wait-for-seconds] (cursor/event-seq (if (= -1 cursor) (cursor/first-cursor uri (if (= all-events-stream-id stream-id) "%24all" stream-id) (client-opts user password)) (cursor/next-cursor cursor)) wait-for-seconds)) (append-events [_ stream-id from-version events] (event/post uri stream-id from-version events (client-opts user password)))) (defn atom-event-store [uri & [opts]] (->AtomStore uri (:user opts) (:password opts)))
(ns rill.event-store.atom-store "This is an event store implementation using the GetEventstore.com store as a backend. Code originally taken from https://github.com/jankronquist/rock-paper-scissors-in-clojure/tree/master/eventstore/src/com/jayway/rps " (:require [clojure.tools.logging :as log] [rill.event-store :refer [EventStore]] [rill.event-store.atom-store.cursor :as cursor] [rill.event-store.atom-store.event :as event] [rill.event-stream :refer [all-events-stream-id]] [rill.message :as msg])) (defn client-opts [user password] {:pre [user password]} (if (and user password) {:basic-auth [user password]})) (deftype AtomStore [uri user password] EventStore (retrieve-events-since [_ stream-id cursor wait-for-seconds] (cursor/event-seq (if (= -1 cursor) (cursor/first-cursor uri (if (= all-events-stream-id stream-id) "%24all" stream-id) (client-opts user password)) (cursor/next-cursor cursor)) wait-for-seconds)) (append-events [_ stream-id from-version events] (event/post uri stream-id from-version events (client-opts user password)))) (defn atom-event-store [uri & [{:keys [user password]}]] {:pre [user password uri]} (->AtomStore uri user password))
Clean up dependencies and build options
(defproject mkremins/flense-nw "0.0-SNAPSHOT" :dependencies [[org.clojure/clojure "1.6.0"] [org.clojure/clojurescript "0.0-2665"] [org.clojure/core.async "0.1.346.0-17112a-alpha"] [com.facebook/react "0.12.2.1"] [org.om/om "0.8.0"] [spellhouse/phalanges "0.1.4"] [mkremins/flense "0.0-SNAPSHOT"] [mkremins/fs "0.3.0"]] :plugins [[lein-cljsbuild "1.0.4"]] :source-paths ["src"] :cljsbuild {:builds [{:source-paths ["src"] :compiler {:preamble ["react/react.js"] :output-to "target/flense.js" :source-map "target/flense.js.map" :optimizations :whitespace :pretty-print true}}]})
(defproject mkremins/flense-nw "0.0-SNAPSHOT" :dependencies [[org.clojure/clojure "1.6.0"] [org.clojure/clojurescript "0.0-2727"] [org.clojure/core.async "0.1.346.0-17112a-alpha"] [org.omcljs/om "0.8.4"] [spellhouse/phalanges "0.1.4"] [mkremins/flense "0.0-SNAPSHOT"] [mkremins/fs "0.3.0"]] :plugins [[lein-cljsbuild "1.0.4"]] :cljsbuild {:builds [{:source-paths ["src"] :compiler {:main flense-nw.app :output-to "target/flense.js" :source-map "target/flense.js.map" :optimizations :none}}]})