Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Upgrade simple example lein-shadow to 0.1.6 | (defproject simple "0.11.0-rc2-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.10.1"]
[org.clojure/clojurescript "1.10.520"
:exclusions [com.google.javascript/closure-compiler-unshaded
org.clojure/google-closure-library]]
[thheller/shadow-cljs "2.8.52"]
[reagent "0.9.0-rc1"]
[re-frame "0.11.0-rc2-SNAPSHOT"]]
:plugins [[lein-shadow "0.1.5"]]
:clean-targets ^{:protect false} [:target-path
"shadow-cljs.edn"
"package.json"
"package-lock.json"
"resources/public/js"]
:shadow-cljs {:nrepl {:port 8777}
:builds {:client {:target :browser
:output-dir "resources/public/js"
:modules {:client {:init-fn simple.core/run}}
:devtools {:http-root "resources/public"
:http-port 8280}}}}
:aliases {"dev-auto" ["shadow" "watch" "client"]})
| (defproject simple "0.11.0-rc2-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.10.1"]
[org.clojure/clojurescript "1.10.520"
:exclusions [com.google.javascript/closure-compiler-unshaded
org.clojure/google-closure-library]]
[thheller/shadow-cljs "2.8.52"]
[reagent "0.9.0-rc1"]
[re-frame "0.11.0-rc2-SNAPSHOT"]]
:plugins [[lein-shadow "0.1.6"]]
:clean-targets ^{:protect false} [:target-path
"shadow-cljs.edn"
"package.json"
"package-lock.json"
"resources/public/js"]
:shadow-cljs {:nrepl {:port 8777}
:builds {:client {:target :browser
:output-dir "resources/public/js"
:modules {:client {:init-fn simple.core/run}}
:devtools {:http-root "resources/public"
:http-port 8280}}}}
:aliases {"dev-auto" ["shadow" "watch" "client"]})
|
Test that the count works with nested sexprs. | (ns kolmogorov-music.test.kolmogorov
(:require [kolmogorov-music.kolmogorov :as kolmogorov]
[midje.sweet :refer :all]))
(defn foo [x] (inc x))
(def bar (comp foo foo))
(fact "Kolmogorov complexity is how many symbols a definition comprises."
(kolmogorov/complexity foo) => 2)
(fact "The symbol count is recursive within the current namespace."
(kolmogorov/complexity bar) => 7)
(fact "Symbols outside the current namespace are considered atoms."
(kolmogorov/complexity inc) => 0)
| (ns kolmogorov-music.test.kolmogorov
(:require [kolmogorov-music.kolmogorov :as kolmogorov]
[midje.sweet :refer :all]))
(defn foo [x] (inc x))
(defn bar [x] (+ (inc x) x))
(def baz (comp foo foo))
(fact "Kolmogorov complexity is how many symbols a definition comprises."
(kolmogorov/complexity foo) => 2)
(fact "The symbol count includes nested sexprs."
(kolmogorov/complexity bar) => 4)
(fact "The symbol count is recursive within the current namespace."
(kolmogorov/complexity baz) => 7)
(fact "Symbols outside the current namespace are considered atoms."
(kolmogorov/complexity inc) => 0)
|
Fix a warning reported by eastwood | (ns ktra-indexer.config
"Namespace for configuration reading functions"
(:require [clojure.edn :as edn]))
(defn load-config
"Given a filename, load and return a config file."
[filename]
(edn/read-string (slurp filename)))
(defn get-conf-value
"Return a key value from the configuration."
[property & {:keys [k use-sample]
:or {k nil
use-sample false}}]
(let [config (load-config
(clojure.java.io/resource
(if use-sample
"config.edn_sample"
"config.edn")))]
(if k
(k (property config))
(property config))))
(defn db-conf
"Returns the value of the requested database configuration key"
[k & [use-sample]]
(get-conf-value :database :k k :use-sample use-sample))
| (ns ktra-indexer.config
"Namespace for configuration reading functions"
(:require [clojure.edn :as edn]
[clojure.java.io :refer [resource]]))
(defn load-config
"Given a filename, load and return a config file."
[filename]
(edn/read-string (slurp filename)))
(defn get-conf-value
"Return a key value from the configuration."
[property & {:keys [k use-sample]
:or {k nil
use-sample false}}]
(let [config (load-config
(resource (if use-sample
"config.edn_sample"
"config.edn")))]
(if k
(k (property config))
(property config))))
(defn db-conf
"Returns the value of the requested database configuration key"
[k & [use-sample]]
(get-conf-value :database :k k :use-sample use-sample))
|
Enable "lein run migrate" command for db migration | (ns five-three-one.server
(:require [five-three-one.handler :refer [app]]
[environ.core :refer [env]]
[ring.adapter.jetty :refer [run-jetty]]
[five-three-one.model.migration :refer [migrate]])
(:gen-class))
(defn -main [& args]
(let [port (Integer/parseInt (or (env :port) "3000"))]
(migrate)
(run-jetty app {:port port :join? false})))
| (ns five-three-one.server
(:require [five-three-one.handler :refer [app]]
[environ.core :refer [env]]
[ring.adapter.jetty :refer [run-jetty]]
[five-three-one.model.migration :refer [migrate]])
(:gen-class))
(defn -main [& args]
(if (some #{"migrate"} args)
(migrate)
(let [port (Integer/parseInt (or (env :port) "3000"))]
(run-jetty app {:port port :join? false}))))
|
Implement API call to get stats of a sidekiq instance | (ns ^:figwheel-always sidequarter-frontend.api
(:require-macros [sidequarter-frontend.env :refer [cljs-env]]
[cljs.core.async.macros :refer [go]])
(:require [cljs-http.client :as http]
[cljs.core.async :refer [<! >! put! chan]]))
(def api-url (cljs-env :api-url))
(defn get-sidekiqs []
(http/jsonp api-url {:callback-name "callback"}))
| (ns ^:figwheel-always sidequarter-frontend.api
(:require-macros [sidequarter-frontend.env :refer [cljs-env]]
[cljs.core.async.macros :refer [go]])
(:require [cljs-http.client :as http]
[cljs.core.async :refer [<! >! put! chan]]
[clojure.string :refer [join]]))
(def api-url (cljs-env :api-url))
(defn get-sidekiqs []
(http/jsonp api-url {:callback-name "callback"}))
(defn stats-path [sidekiq-id]
(join "/" [api-url sidekiq-id "stats"]))
(defn get-stats [sidekiq-id]
(let [url (stats-path sidekiq-id)]
(http/jsonp url {:callback-name "callback"})))
|
Throw 400 if slug name already taken :scream_cat: | (ns metabase.models.label
(:require [korma.core :as k]
[metabase.db :as db]
[metabase.models.interface :as i]
[metabase.util :as u]))
(i/defentity Label :label)
(defn- pre-insert [{label-name :name, :as label}]
(assoc label :slug (u/slugify label-name)))
(defn- pre-update [{label-name :name, :as label}]
(if-not label-name
label
(assoc label :slug (u/slugify label-name))))
(defn- pre-cascade-delete [{:keys [id]}]
(db/cascade-delete 'CardLabel :label_id id))
(u/strict-extend (class Label)
i/IEntity
(merge i/IEntityDefaults
{:can-read? (constantly true)
:can-write? (constantly true)
:pre-insert pre-insert
:pre-update pre-update
:pre-cascade-delete pre-cascade-delete}))
| (ns metabase.models.label
(:require [korma.core :as k]
[metabase.db :as db]
[metabase.models.interface :as i]
[metabase.util :as u]))
(i/defentity Label :label)
(defn- assert-unique-slug [slug]
(when (db/exists? Label :slug slug)
(throw (ex-info "Name already taken" {:status-code 400, :errors {:name "A label with this name already exists"}}))))
(defn- pre-insert [{label-name :name, :as label}]
(assoc label :slug (u/prog1 (u/slugify label-name)
(assert-unique-slug <>))))
(defn- pre-update [{label-name :name, :as label}]
(if-not label-name
label
(assoc label :slug (u/prog1 (u/slugify label-name)
(assert-unique-slug <>)))))
(defn- pre-cascade-delete [{:keys [id]}]
(db/cascade-delete 'CardLabel :label_id id))
(u/strict-extend (class Label)
i/IEntity
(merge i/IEntityDefaults
{:can-read? (constantly true)
:can-write? (constantly true)
:pre-insert pre-insert
:pre-update pre-update
:pre-cascade-delete pre-cascade-delete}))
|
Fix backup tool by updating to latest version of google API. | (defproject hatnik/tools.backup "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.6.0"]
[com.google.apis/google-api-services-storage "v1beta2-rev43-1.18.0-rc"]
[com.google.http-client/google-http-client-jackson2 "1.17.0-rc"]
[com.google.oauth-client/google-oauth-client-jetty "1.17.0-rc"]]
:main hatnik.tools.backup
:aot :all)
| (defproject hatnik/tools.backup "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.6.0"]
[com.google.apis/google-api-services-storage "v1-rev22-1.19.0"]
[com.google.http-client/google-http-client-jackson2 "1.19.0"]
[com.google.oauth-client/google-oauth-client-jetty "1.19.0"]]
:main hatnik.tools.backup
:aot :all)
|
Use release versions instead of SNAPSHOT | (defproject io.atomix/trinity "1.0.0-SNAPSHOT"
:description "A sweet little Clojure API for Atomix"
:url "http://github.com/atomix/trinity"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.8.0"]
[io.atomix/atomix-all "1.0.1-SNAPSHOT"]
[io.atomix.catalyst/catalyst-netty "1.1.2"]]
:repositories [["sonatype-nexus-snapshots" {:url "https://oss.sonatype.org/content/repositories/snapshots"}]]
:plugins [[lein-codox "0.9.0"]
[lein-localrepo "0.5.3"]]
:codox {:output-path "target/docs/api"
:metadata {:doc/format :markdown}
:source-uri "http://github.com/atomix/trinity/blob/master/{filepath}#L{line}"})
| (defproject io.atomix/trinity "1.0.0"
:description "A sweet little Clojure API for Atomix"
:url "http://github.com/atomix/trinity"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.8.0"]
[io.atomix/atomix-all "1.0.0"]
[io.atomix.catalyst/catalyst-netty "1.1.2"]]
:repositories [["sonatype-nexus-snapshots" {:url "https://oss.sonatype.org/content/repositories/snapshots"}]]
:plugins [[lein-codox "0.9.0"]
[lein-localrepo "0.5.3"]]
:codox {:output-path "target/docs/api"
:metadata {:doc/format :markdown}
:source-uri "http://github.com/atomix/trinity/blob/master/{filepath}#L{line}"})
|
Set cats version to 1.0.0 final. | (defproject funcool/promesa "0.5.0-SNAPSHOT"
:description "A promise library for ClojureScript"
:url "https://github.com/funcool/promesa"
:license {:name "BSD (2 Clause)"
:url "http://opensource.org/licenses/BSD-2-Clause"}
:dependencies [[org.clojure/clojure "1.7.0" :scope "provided"]
[org.clojure/clojurescript "1.7.48" :scope "provided"]
[funcool/cats "1.0.0-SNAPSHOT"]]
:deploy-repositories {"releases" :clojars
"snapshots" :clojars}
:source-paths ["src" "assets"]
:test-paths ["test"]
:jar-exclusions [#"\.swp|\.swo|user.clj"]
:codeina {:sources ["src"]
:reader :clojurescript
:target "doc/dist/latest/api"}
:plugins [[funcool/codeina "0.3.0"]
[lein-externs "0.1.3"]])
| (defproject funcool/promesa "0.5.0-SNAPSHOT"
:description "A promise library for ClojureScript"
:url "https://github.com/funcool/promesa"
:license {:name "BSD (2 Clause)"
:url "http://opensource.org/licenses/BSD-2-Clause"}
:dependencies [[org.clojure/clojure "1.7.0" :scope "provided"]
[org.clojure/clojurescript "1.7.48" :scope "provided"]
[funcool/cats "1.0.0"]]
:deploy-repositories {"releases" :clojars
"snapshots" :clojars}
:source-paths ["src" "assets"]
:test-paths ["test"]
:jar-exclusions [#"\.swp|\.swo|user.clj"]
:codeina {:sources ["src"]
:reader :clojurescript
:target "doc/dist/latest/api"}
:plugins [[funcool/codeina "0.3.0"]
[lein-externs "0.1.3"]])
|
Add better error checking to Steam reader. | (ns bltool.data.steam
(:require [bltool.data.default :refer [read-games]])
(:require [bltool.flags :refer :all])
(:require [clj-http.client :as http])
(:require [clojure.data.xml :as xml])
(:require [clojure.string :refer [trim]]))
(register-flags ["--steam-name" "Steam Community name"]
["--steam-platform" "Default platform to use for Steam games (recommended: PC, PCDL, or Steam)" :default "PC"])
(defn- xml-to-map
[tag]
(let [tag-content (fn [tag] [(:tag tag) (apply str (:content tag))])]
(into {} (map tag-content (:content tag)))))
(defmethod read-games "steam" [_]
(let [name (:steam-name *opts*)
url (str "http://steamcommunity.com/id/" name "/games?tab=all&xml=1")]
(->> url http/get :body xml/parse-str xml-seq (filter #(= :game (:tag %)))
(map (comp trim :name xml-to-map))
sort
(map (fn [name] { :id "0" :name name :platform (:steam-platform *opts*) :progress "unplayed" })))))
| (ns bltool.data.steam
(:require [bltool.data.default :refer [read-games]])
(:require [bltool.flags :refer :all])
(:require [clj-http.client :as http])
(:require [clojure.data.xml :as xml])
(:require [slingshot.slingshot :refer [throw+]])
(:require [clojure.string :refer [trim]]))
(register-flags ["--steam-name" "Steam Community name"]
["--steam-platform" "Default platform to use for Steam games (recommended: PC, PCDL, or Steam)" :default "PC"])
(defn- xml-to-map
[tag]
(let [tag-content (fn [tag] [(:tag tag) (apply str (:content tag))])]
(into {} (map tag-content (:content tag)))))
(defn- check-games
[games]
(if (empty? games)
(throw+ (str "Couldn't find any games at http://steamcommunity.com/id/" (:steam-name *opts*)
" -- are you sure you specified the right --steam-name?"))
games))
(defmethod read-games "steam" [_]
(if (not (:steam-name *opts*))
(throw+ "No Steam Community name specified - use the --steam-name option."))
(let [name (:steam-name *opts*)
url (str "http://steamcommunity.com/id/" name "/games?tab=all&xml=1")]
(->> url http/get :body xml/parse-str xml-seq (filter #(= :game (:tag %)))
(map (comp trim :name xml-to-map))
sort
(map (fn [name] { :id "0" :name name :platform (:steam-platform *opts*) :progress "unplayed" }))
check-games)))
|
Use figwheel main for cursive | (use 'figwheel-sidecar.repl-api)
(start-figwheel!) ;; <-- fetches configuration
(cljs-repl) | (require '[figwheel.main.api :as fig])
(fig/start "dev")
|
Fix no DB connection when running tests | (ns territory-bro.handler-test
(:require [clojure.test :refer :all]
[ring.mock.request :refer :all]
[territory-bro.handler :refer :all]))
(deftest test-app
(testing "main route"
(let [response (app (request :get "/"))]
(is (= 200 (:status response)))))
(testing "not-found route"
(let [response (app (request :get "/invalid"))]
(is (= 404 (:status response))))))
| (ns territory-bro.handler-test
(:require [clojure.test :refer :all]
[ring.mock.request :refer :all]
[territory-bro.handler :refer :all]
[territory-bro.db.migrations :as migrations]
[territory-bro.db.core :as db]))
(use-fixtures
:once
(fn [f]
(db/connect!)
(migrations/migrate ["migrate"])
(f)))
(deftest test-app
(testing "main route"
(let [response (app (request :get "/"))]
(is (= 200 (:status response)))))
(testing "not-found route"
(let [response (app (request :get "/invalid"))]
(is (= 404 (:status response))))))
|
Document :on-duplicate-key-update clause order number | (ns onyx.plugin.mysql
"Implementation of MySQL-specific utility functions."
(:require [honeysql.core :as hsql]
[honeysql.format :as hformat]))
(defn upsert
"Using honeysql-postgres, construct a SQL string to do upserts with Postgres.
We expect the key in the 'where' map to be a primary key."
[table row where]
(hsql/format {:insert-into table
:values [(merge where row)]
:on-duplicate-key-update row}))
(defmethod hformat/format-clause :on-duplicate-key-update [[_ values] _]
(str "ON DUPLICATE KEY UPDATE "
(hformat/comma-join (for [[k v] values]
(str (hformat/to-sql k) " = "
(hformat/to-sql v))))))
(hformat/register-clause! :on-duplicate-key-update 225)
| (ns onyx.plugin.mysql
"Implementation of MySQL-specific utility functions."
(:require [honeysql.core :as hsql]
[honeysql.format :as hformat]))
(defn upsert
"Using honeysql-postgres, construct a SQL string to do upserts with Postgres.
We expect the key in the 'where' map to be a primary key."
[table row where]
(hsql/format {:insert-into table
:values [(merge where row)]
:on-duplicate-key-update row}))
(defmethod hformat/format-clause :on-duplicate-key-update [[_ values] _]
(str "ON DUPLICATE KEY UPDATE "
(hformat/comma-join (for [[k v] values]
(str (hformat/to-sql k) " = "
(hformat/to-sql v))))))
;; This number is used to insert the clause towards the end of the constructed
;; SQL string. honeysql-postgres was used as reference:
;; https://github.com/nilenso/honeysql-postgres/blob/master/src/honeysql_postgres/format.clj#L19
(def clause-order 225)
(hformat/register-clause! :on-duplicate-key-update clause-order)
|
Add clj-http and lein-ancient to lein profile | {
;; inf-clojure support
:jvm-opts ["-Dclojure.server.repl={:port 5555 :accept clojure.core.server/repl}"]
;; for all that repl goodness
:user { :dependencies [[org.clojure/tools.namespace "0.3.0-alpha4"]
[eftest "0.5.1"]]
:plugins [[lein-cljfmt "0.4.1" :exclusions [org.clojure/clojure]]
[lein-cloverage "1.0.6" :exclusions [org.clojure/clojure]]
[lein-ancient "0.6.10", :exclusions [org.clojure/clojure]]]}
}
| {
;; inf-clojure support
:jvm-opts ["-Dclojure.server.repl={:port 5555 :accept clojure.core.server/repl}"]
;; for all that repl goodness
:user { :dependencies [[org.clojure/tools.namespace "0.3.0-alpha4"]
[clj-http "3.9.0"]
[eftest "0.5.1"]]
:plugins [[lein-cljfmt "0.4.1" :exclusions [org.clojure/clojure]]
[lein-cloverage "1.0.6" :exclusions [org.clojure/clojure]]
[lein-ancient "0.6.15", :exclusions [org.clojure/clojure]]]}
}
|
Upgrade todomvc example lein-shadow to 0.1.6 | (defproject todomvc-re-frame "0.11.0-rc2-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.10.1"]
[org.clojure/clojurescript "1.10.520"
:exclusions [com.google.javascript/closure-compiler-unshaded
org.clojure/google-closure-library]]
[thheller/shadow-cljs "2.8.52"]
[reagent "0.9.0-rc1"]
[re-frame "0.11.0-rc2-SNAPSHOT"]
[binaryage/devtools "0.9.10"]
[clj-commons/secretary "1.2.4"]
[day8.re-frame/tracing "0.5.3"]]
:plugins [[lein-shadow "0.1.5"]]
:clean-targets ^{:protect false} [:target-path
"shadow-cljs.edn"
"package.json"
"package-lock.json"
"resources/public/js"]
:shadow-cljs {:nrepl {:port 8777}
:builds {:client {:target :browser
:output-dir "resources/public/js"
:modules {:client {:init-fn todomvc.core/main}}
:devtools {:http-root "resources/public"
:http-port 8280}}}}
:aliases {"dev-auto" ["shadow" "watch" "client"]})
| (defproject todomvc-re-frame "0.11.0-rc2-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.10.1"]
[org.clojure/clojurescript "1.10.520"
:exclusions [com.google.javascript/closure-compiler-unshaded
org.clojure/google-closure-library]]
[thheller/shadow-cljs "2.8.52"]
[reagent "0.9.0-rc1"]
[re-frame "0.11.0-rc2-SNAPSHOT"]
[binaryage/devtools "0.9.10"]
[clj-commons/secretary "1.2.4"]
[day8.re-frame/tracing "0.5.3"]]
:plugins [[lein-shadow "0.1.6"]]
:clean-targets ^{:protect false} [:target-path
"shadow-cljs.edn"
"package.json"
"package-lock.json"
"resources/public/js"]
:shadow-cljs {:nrepl {:port 8777}
:builds {:client {:target :browser
:output-dir "resources/public/js"
:modules {:client {:init-fn todomvc.core/main}}
:devtools {:http-root "resources/public"
:http-port 8280}}}}
:aliases {"dev-auto" ["shadow" "watch" "client"]})
|
Update format of fav posts output | (ns ecregister.favorites
(:gen-class)
(:require [ecregister.posts :as posts])
(:require [clj-time.core :as t])
(:require [clj-time.format :as f]))
(defn parse-date [str]
(f/parse (f/formatters :date-time-no-ms) str))
(defn is-more-recent [date post]
"checks if post is more recent than date"
(when-let [post-date (parse-date (:date post))]
(t/within? (t/interval date (t/today-at 23 59))
post-date)))
(defn print-post [p]
(prn (format "<a href=\"%s\">%s</a>, автор <ls user=\"%s\"/> (%s голосов)"
(:link p) (:title p) (:author p) (:fav-count p))))
(defn print-favorites [since-date]
(let [all-posts (posts/fetch-aw-posts #(is-more-recent since-date %))]
(dorun (take 15 (map print-post
(sort-by #(Integer/parseInt (:fav-count %)) #(compare %2 %1) all-posts))))
))
(defn print-favorites-of-month []
;; print favs with dates more recent than month ago
(print-favorites (t/minus (t/today-at 0 0) (t/months 1))))
;;(print-favorites-of-month)
| (ns ecregister.favorites
(:gen-class)
(:require [ecregister.posts :as posts])
(:require [clj-time.core :as t])
(:require [clj-time.format :as f]))
(defn parse-date [str]
(f/parse (f/formatters :date-time-no-ms) str))
(defn is-more-recent [date post]
"checks if post is more recent than date"
(when-let [post-date (parse-date (:date post))]
(t/within? (t/interval date (t/today-at 23 59))
post-date)))
(defn print-post [p]
(println (format "<a href=\"%s\">%s</a>, автор <ls user=\"%s\"/>"
(:link p) (:title p) (:author p))))
(defn print-favorites [since-date]
(let [all-posts (posts/fetch-aw-posts #(is-more-recent since-date %))]
(dorun (take 15 (map print-post
(sort-by #(Integer/parseInt (:fav-count %)) #(compare %2 %1) all-posts))))
))
(defn print-favorites-of-month []
;; print favs with dates more recent than month ago
(print-favorites (t/minus (t/today-at 0 0) (t/months 1))))
;;(print-favorites-of-month)
|
Update search query only if it necessary | (ns subman.routes
(:require [secretary.core :as secretary :include-macros true :refer [defroute]]
[goog.events :as gevents]
[goog.history.EventType :as history-event]
[subman.deps :as d]))
(defn set-search-query
"Set value of stable search query"
[value]
(when-let [state (secretary/get-config :state)]
(swap! state assoc
:stable-search-query value
:search-query value)))
(defn change-url!
"Change page url"
[url]
(when @d/history
(.setToken @d/history url)))
(defn init-routes
"Init history and spy to atom"
[state]
(when @d/history
(secretary/set-config! :state state)
(secretary/dispatch! (.getToken @d/history))
(gevents/listen @d/history history-event/NAVIGATE
#(secretary/dispatch! (.-token %)))))
(defroute main-page "/" []
(set-search-query ""))
(defroute search-page "/search/*query" {:keys [query]}
(set-search-query query))
| (ns subman.routes
(:require [secretary.core :as secretary :include-macros true :refer [defroute]]
[goog.events :as gevents]
[goog.history.EventType :as history-event]
[subman.deps :as d]))
(defn set-search-query
"Set value of stable search query"
[value]
(when-let [state (secretary/get-config :state)]
(when (not= (:search-query @state) value)
(swap! state assoc
:stable-search-query value
:search-query value)
(swap! state update-in
[:search-query-counter] inc))))
(defn change-url!
"Change page url"
[url]
(when @d/history
(.setToken @d/history url)))
(defn init-routes
"Init history and spy to atom"
[state]
(when @d/history
(secretary/set-config! :state state)
(secretary/dispatch! (.getToken @d/history))
(gevents/listen @d/history history-event/NAVIGATE
#(secretary/dispatch! (.-token %)))))
(defroute main-page "/" []
(set-search-query ""))
(defroute search-page "/search/*query" {:keys [query]}
(set-search-query query))
|
Increase lein repl timeout to two minutes. | {:user {:dependencies [[clj-stacktrace "0.2.4"]]
:plugins [[lein-tarsier "0.9.4-SNAPSHOT"]
[lein-swank "1.4.4"]
[lein-difftest "1.3.7"]
[lein-clojars "0.9.1"]
;[jark/jark-server "0.4.0"]
[lein-pprint "1.1.1"]
[slamhound "1.2.0"]
[lein-cljsbuild "0.1.9"]
[lein-deps-tree "0.1.1"]
;[lein-autodoc "0.9.0"]
[lein-marginalia "0.7.1"]]
:repl-options {:timeout 60000}
: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.4"]]
:plugins [[lein-tarsier "0.9.4-SNAPSHOT"]
[lein-swank "1.4.4"]
[lein-difftest "1.3.7"]
[lein-clojars "0.9.1"]
;[jark/jark-server "0.4.0"]
[lein-pprint "1.1.1"]
[slamhound "1.2.0"]
[lein-cljsbuild "0.1.9"]
[lein-deps-tree "0.1.1"]
;[lein-autodoc "0.9.0"]
[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}}}
|
Change name of generated uberjar to statuses.jar | (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.2"]
[compojure "1.3.3"]
[clj-time "0.9.0"]
[org.clojure/data.json "0.2.6"]
[org.clojure/tools.cli "0.3.3"]]
: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]})
| (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.2"]
[compojure "1.3.3"]
[clj-time "0.9.0"]
[org.clojure/data.json "0.2.6"]
[org.clojure/tools.cli "0.3.3"]]
: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"}
:uberjar-name "statuses.jar"
:eastwood {:exclude-linters [:constant-test]})
|
Prepare for next release cycle. | (defproject onyx-app/lein-template "0.10.0.0-beta14"
: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)
|
Add dependendy to http-kit to enable http requests | (defproject clj-gatling "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.5.1"]
[org.clojure/core.async "0.1.267.0-0d7780-alpha"]
[clojure-csv/clojure-csv "2.0.1"]
[clj-time "0.6.0"]
[io.gatling/gatling-charts "2.0.0-M3a"]
[io.gatling.highcharts/gatling-charts-highcharts "2.0.0-M3a"]]
:repositories { "excilys" "http://repository.excilys.com/content/groups/public" }
:main clj-gatling.core)
| (defproject clj-gatling "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.5.1"]
[org.clojure/core.async "0.1.267.0-0d7780-alpha"]
[clojure-csv/clojure-csv "2.0.1"]
[clj-time "0.6.0"]
[http-kit "2.1.16"]
[io.gatling/gatling-charts "2.0.0-M3a"]
[io.gatling.highcharts/gatling-charts-highcharts "2.0.0-M3a"]]
:repositories { "excilys" "http://repository.excilys.com/content/groups/public" }
:main clj-gatling.core)
|
Switch back to snapshot version. | (defproject cli4clj "1.1.1"
;(defproject cli4clj "1.1.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.8.0"]
[clj-assorted-utils "1.12.0"]
[jline/jline "2.14.2"]]
: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"]]
:profiles {:repl {:dependencies [[jonase/eastwood "0.2.2" :exclusions [org.clojure/clojure]]]}}
)
| ;(defproject cli4clj "1.1.1"
(defproject cli4clj "1.1.2-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.8.0"]
[clj-assorted-utils "1.12.0"]
[jline/jline "2.14.2"]]
: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"]]
:profiles {:repl {:dependencies [[jonase/eastwood "0.2.2" :exclusions [org.clojure/clojure]]]}}
)
|
Remove dependency on the marginalia snapshot | (defproject clj-fst "0.1.0"
:description "Finite State Transducers (FST) for Clojure"
:url "https://github.com/structureddynamics/clj-fst"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]
[org.apache.lucene/lucene-core "4.10.2"]
[org.apache.lucene/lucene-misc "4.10.2"]
[lein-marginalia "0.8.1-SNAPSHOT"]]
:source-paths ["src/clojure"]
:java-source-paths ["src/java"]
:target-path "target/%s"
:marginalia {:exclude ["utils.clj"]})
| (defproject clj-fst "0.1.0"
:description "Finite State Transducers (FST) for Clojure"
:url "https://github.com/structureddynamics/clj-fst"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]
[org.apache.lucene/lucene-core "4.10.2"]
[org.apache.lucene/lucene-misc "4.10.2"]
[lein-marginalia "0.8.0"]]
:source-paths ["src/clojure"]
:java-source-paths ["src/java"]
:target-path "target/%s"
:marginalia {:exclude ["utils.clj"]})
|
Prepare for next release cycle. | (defproject onyx-plugin/lein-template "0.8.1.2"
:description "A Leiningen 2.0 template for new Onyx plugins"
:url "http://github.com/MichaelDrogalis/onyx-plugin"
: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-plugin/lein-template "0.8.1.3-SNAPSHOT"
:description "A Leiningen 2.0 template for new Onyx plugins"
:url "http://github.com/MichaelDrogalis/onyx-plugin"
: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)
|
Downgrade to incanter 1.9.0 because 1.9.1 doesn't appear to be working. | ; vi: ft=clojure
(set-env!
:resource-paths #{"src"}
:dependencies '[[org.clojure/clojure "1.8.0"]
[incanter "1.9.1"]])
(task-options!
aot {:all true}
pom {:project 'analyze-data
:version "0.0.0"}
jar {:main 'analyze-data.core})
(deftask build []
(comp (aot) (pom) (uber) (jar) (target)))
| ; vi: ft=clojure
(set-env!
:resource-paths #{"src"}
:dependencies '[[org.clojure/clojure "1.8.0"]
[incanter "1.9.0"]])
(task-options!
aot {:all true}
pom {:project 'analyze-data
:version "0.0.0"}
jar {:main 'analyze-data.core})
(deftask build []
(comp (aot) (pom) (uber) (jar) (target)))
|
Use x as var for now | (ns desdemona.query-test
(:require
[desdemona.query :as q]
[clojure.test :refer [deftest is]]))
(deftest query-tests
(is (= [{:ip "10.0.0.1"}]
(q/query '(== (:ip entry) "10.0.0.1")
[{:ip "10.0.0.1"}]))))
| (ns desdemona.query-test
(:require
[desdemona.query :as q]
[clojure.test :refer [deftest is]]))
(deftest query-tests
(is (= [{:ip "10.0.0.1"}]
(q/query '(== (:ip x) "10.0.0.1")
[{:ip "10.0.0.1"}]))))
|
Add clojars as deploy repo | (defproject com.gfredericks/goog-integer "0.1.0-SNAPSHOT"
:description "Temporary fork of goog.math.Integer from the google closure library."
:url "https://github.com/gfredericks/goog-integer"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.7.0"]])
| (defproject com.gfredericks/goog-integer "0.1.0-SNAPSHOT"
:description "Temporary fork of goog.math.Integer from the google closure library."
:url "https://github.com/gfredericks/goog-integer"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.7.0"]]
:deploy-repositories [["releases" :clojars]])
|
Set nodejs as the target | (defproject clojurescript-npm "0.2.0-SNAPSHOT"
:description "The ClojureScript Programming Language, packaged for Node.js"
:url "https://github.com/nasser/clojurescript-npm"
:license {:name "Eclipse Public License"
:url "http://nasser.github.io/clojurescript-npm/blob/master/LICENSE"}
:dependencies [[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.170"]
[replumb/replumb "0.2.1"]]
:clean-targets [:target-path "out"]
:plugins [[lein-cljsbuild "1.1.1"]]
:cljsbuild {
:builds [{
:source-paths ["src"]
:compiler {
:main clojurescript.core
:output-to "lib/bootstrap.js"
:output-dir "out"
:optimizations :simple}}]}) | (defproject clojurescript-npm "0.2.0-SNAPSHOT"
:description "The ClojureScript Programming Language, packaged for Node.js"
:url "https://github.com/nasser/clojurescript-npm"
:license {:name "Eclipse Public License"
:url "http://nasser.github.io/clojurescript-npm/blob/master/LICENSE"}
:dependencies [[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.170"]
[replumb/replumb "0.2.1"]]
:clean-targets [:target-path "out"]
:plugins [[lein-cljsbuild "1.1.1"]]
:cljsbuild {
:builds [{
:source-paths ["src"]
:compiler {
:main clojurescript.core
:output-to "lib/bootstrap.js"
:output-dir "out"
:target :nodejs
:optimizations :simple}}]})
|
Upgrade simple example lein-shadow to 0.1.7 | (defproject simple "lein-git-inject/version"
:dependencies [[org.clojure/clojure "1.10.1"]
[org.clojure/clojurescript "1.10.520"
:exclusions [com.google.javascript/closure-compiler-unshaded
org.clojure/google-closure-library
org.clojure/google-closure-library-third-party]]
[thheller/shadow-cljs "2.8.76"]
[reagent "0.9.0-rc2"]
[re-frame "0.11.0-rc2"]]
:plugins [[day8/lein-git-inject "0.0.2"]
[lein-shadow "0.1.6"]]
:middleware [leiningen.git-inject/middleware]
:clean-targets ^{:protect false} [:target-path
"shadow-cljs.edn"
"package.json"
"package-lock.json"
"resources/public/js"]
:shadow-cljs {:nrepl {:port 8777}
:builds {:client {:target :browser
:output-dir "resources/public/js"
:modules {:client {:init-fn simple.core/run}}
:devtools {:http-root "resources/public"
:http-port 8280}}}}
:aliases {"dev-auto" ["shadow" "watch" "client"]})
| (defproject simple "lein-git-inject/version"
:dependencies [[org.clojure/clojure "1.10.1"]
[org.clojure/clojurescript "1.10.520"
:exclusions [com.google.javascript/closure-compiler-unshaded
org.clojure/google-closure-library
org.clojure/google-closure-library-third-party]]
[thheller/shadow-cljs "2.8.76"]
[reagent "0.9.0-rc2"]
[re-frame "0.11.0-rc2"]]
:plugins [[day8/lein-git-inject "0.0.2"]
[lein-shadow "0.1.7"]]
:middleware [leiningen.git-inject/middleware]
:clean-targets ^{:protect false} [:target-path
"shadow-cljs.edn"
"package.json"
"package-lock.json"
"resources/public/js"]
:shadow-cljs {:nrepl {:port 8777}
:builds {:client {:target :browser
:output-dir "resources/public/js"
:modules {:client {:init-fn simple.core/run}}
:devtools {:http-root "resources/public"
:http-port 8280}}}}
:aliases {"dev-auto" ["shadow" "watch" "client"]})
|
Add documentation for ring middlewares. | (ns memoria.handlers.app
(:require [compojure.core :refer :all]
[compojure.route :as route]
[ring.middleware.params :refer [wrap-params]]
[ring.middleware.json :refer [wrap-json-response wrap-json-body]]
[taoensso.timbre :as timbre]
[memoria.db :as db]
[memoria.handlers.cards :as cards-handler]))
(defn wrap-request-logging [app]
(fn [request]
(timbre/info (str "Received request: " request))
(let [response (app request)]
(timbre/info (str "Response: " response "\n"))
response)))
(defn wrap-db-conn [app]
(fn [request]
(let [datasource (if (= "test" (get-in request [:headers "memoria-mode"]))
(db/test-datasource)
(db/datasource))]
(binding [db/*conn* datasource]
(app request)))))
(defroutes app-routes
cards-handler/cards-routes)
(def app
(-> app-routes
wrap-params
wrap-json-body
wrap-json-response
wrap-db-conn
wrap-request-logging))
| (ns memoria.handlers.app
(:require [compojure.core :refer :all]
[compojure.route :as route]
[ring.middleware.params :refer [wrap-params]]
[ring.middleware.json :refer [wrap-json-response wrap-json-body]]
[taoensso.timbre :as timbre]
[memoria.db :as db]
[memoria.handlers.cards :as cards-handler]))
(defn wrap-request-logging
"Logs the data received in the request and the data generated in the response. Useful
for debugging."
[app]
(fn [request]
(timbre/info (str "Received request: " request))
(let [response (app request)]
(timbre/info (str "Response: " response "\n"))
response)))
(defn wrap-db-conn
"Gets a new connection from the database connection pool and binds that to the
memoria.db/*conn* dynamic var.
If the `memoria-mode` header is present in the request and its value is `test`,
then the test connection pool will be used. Otherwise, the default pool is used."
[app]
(fn [request]
(let [datasource (if (= "test" (get-in request [:headers "memoria-mode"]))
(db/test-datasource)
(db/datasource))]
(binding [db/*conn* datasource]
(app request)))))
(defroutes app-routes
cards-handler/cards-routes)
(def app
(-> app-routes
wrap-params
wrap-json-body
wrap-json-response
wrap-db-conn
wrap-request-logging))
|
Support for parsing large numbers | ;; 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.util)
(defn uuid []
"Create a GUID string."
(str (java.util.UUID/randomUUID)))
(defn parse-uint [s]
"a2uint"
(Integer. (re-find #"\d+" s )))
(defn find-first [f coll]
"Get first item in a seq matching a predicate."
(first (filter f coll)))
| ;; 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.util)
(defn uuid []
"Create a GUID string."
(str (java.util.UUID/randomUUID)))
(defn parse-uint [s]
"a2uint (nil if not a number)"
(if (re-find #"^\d+$" s)
(read-string s)))
(defn find-first [f coll]
"Get first item in a seq matching a predicate."
(first (filter f coll)))
|
Use environment variables if present | (ns robb1e.web
(:require [compojure.core :refer [defroutes]]
[ring.adapter.jetty :as container]
[compojure.handler :as handler]
[compojure.route :as route]
[robb1e.controllers.home :as homeController])
(:gen-class))
(defroutes routes
(homeController/routes "postgresql://localhost:5432/robb1e")
(route/resources "/"))
(def application (handler/site routes))
(defn start [port]
(container/run-jetty application {:port port :join? false}))
(defn -main []
(start 8080))
| (ns robb1e.web
(:require [compojure.core :refer [defroutes]]
[ring.adapter.jetty :as container]
[compojure.handler :as handler]
[compojure.route :as route]
[robb1e.controllers.home :as homeController])
(:gen-class))
(def port
(Integer. (or (System/getenv "PORT") "8080")))
(def db
(or (System/getenv "DATABASE_URL") "postgresql://localhost:5432/robb1e"))
(defroutes routes
(homeController/routes db)
(route/resources "/"))
(def application (handler/site routes))
(defn start [port]
(container/run-jetty application {:port port :join? false}))
(defn -main []
(start port))
|
Add error handling to query functions | (ns fivethreeonern.sqlite
(:require [mount.core :refer-macros [defstate]]))
(def node-module (js/require "react-native-sqlite-storage"))
(defstate sqlite
:start (.openDatabase node-module #js {:name "531.db" :location "default"} #(js/console.log "sql ok") #(js/console.log "sql error")))
(defn execute-sql [tx final-cb [query & other-queries]]
(.executeSql tx query #js [] (fn [tx results]
(if (empty? other-queries)
(let [results (-> results .-rows .raw js->clj)]
(final-cb results))
(execute-sql tx final-cb other-queries)))))
(defn transaction [query-strings final-cb]
(.transaction @sqlite
(fn [tx]
(execute-sql tx final-cb query-strings))))
(defn query [query-str cb]
(transaction [query-str] cb))
| (ns fivethreeonern.sqlite
(:require [mount.core :refer-macros [defstate]]))
(def node-module (js/require "react-native-sqlite-storage"))
(defstate sqlite
:start (.openDatabase node-module #js {:name "531.db" :location "default"} #(js/console.log "sql ok") #(js/console.log "sql error")))
(defn- execute-sql [tx [query & other-queries] final-cb on-error]
(.executeSql tx query #js []
(fn [tx results]
(if (empty? other-queries)
(let [results (-> results .-rows .raw js->clj)]
(final-cb results))
(execute-sql tx other-queries final-cb on-error)))
on-error))
(defn transaction
([query-strings final-cb]
(transaction query-strings final-cb (fn [_])))
([query-strings final-cb on-error]
(.transaction @sqlite
(fn [tx]
(execute-sql tx query-strings final-cb on-error)))))
(defn query
([query-str cb]
(query query-str cb (fn [_])))
([query-str cb on-error]
(transaction [query-str] cb on-error)))
|
Fix bug - wrong name! |
{:name "rnaseq-phase0-b",
:path "",
:graph {:strtscratch {:type "func"
:name "start-scratch-space"
:args ["#1"]}
:bcstats {:type "func"
:name "collect-barcode-stats"}
:wrtstats {:type "func"
:name "write-bcmaps"}
:setexp {:type "func"
:name "set-exp"}
:split-filter {:type "func"
:name "split-filter-fastqs"}
:coll {:type "func"
:name "collapser"}
:mail {:type "func"
:name "mailit"
:args ["#2" ; recipient
"Aerobio job status: tnseq phase-0b"
"Finished"]} ; subject, body intro
:edges {:strtscratch [:bcstats]
:bcstats [:wrtstats]
:wrtstats [:setexp]
:setexp [:split-filter]
:split-filter [:coll]
:coll [:mail]}}
:description "Tn-Seq w/o bcl2fastq - start-scratch-space through barcode stats and filter/splitter. Using (prebuilt) fastq files creates scratch space for fastq file processing, copies fastqs to canonical dir in scratch area, collects barcode and NT stats, then writes that to canonical area, sets the experiments db value, splits and filters fastqs by replicates and lastly collapses those fqs."
}
|
{:name "tnseq-phase0-b",
:path "",
:graph {:strtscratch {:type "func"
:name "start-scratch-space"
:args ["#1"]} ; EID
:bcstats {:type "func"
:name "collect-barcode-stats"}
:wrtstats {:type "func"
:name "write-bcmaps"}
:setexp {:type "func"
:name "set-exp"}
:split-filter {:type "func"
:name "split-filter-fastqs"}
:coll {:type "func"
:name "collapser"}
:mail {:type "func"
:name "mailit"
:args ["#2" ; recipient
"Aerobio job status: tnseq phase-0b"
"Finished"]} ; subject, body intro
:edges {:strtscratch [:bcstats]
:bcstats [:wrtstats]
:wrtstats [:setexp]
:setexp [:split-filter]
:split-filter [:coll]
:coll [:mail]}}
:description "Tn-Seq w/o bcl2fastq - start-scratch-space through barcode stats and filter/splitter. Using (prebuilt) fastq files creates scratch space for fastq file processing, copies fastqs to canonical dir in scratch area, collects barcode and NT stats, then writes that to canonical area, sets the experiments db value, splits and filters fastqs by replicates and lastly collapses those fqs."
}
|
Update dependency org.clojure:clojure to v1.10.2 | (defproject strava-activity-graphs "0.1.0-SNAPSHOT"
:description "Generate statistical charts for Strava activities"
:url "https://github.com/nicokosi/strava-activity-graphs"
:license {:name "Creative Commons Attribution 4.0"
:url "https://creativecommons.org/licenses/by/4.0/"}
:dependencies [[org.clojure/clojure "1.10.1"]
[incanter/incanter-core "1.9.3"]
[incanter/incanter-charts "1.9.3"]
[incanter/incanter-io "1.9.3"]
[org.clojure/data.json "1.0.0"]
[clj-http "3.11.0"]
[slingshot "0.12.2"]]
:plugins [[lein-cljfmt "0.7.0"]]
:main ^:skip-aot strava-activity-graphs.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
| (defproject strava-activity-graphs "0.1.0-SNAPSHOT"
:description "Generate statistical charts for Strava activities"
:url "https://github.com/nicokosi/strava-activity-graphs"
:license {:name "Creative Commons Attribution 4.0"
:url "https://creativecommons.org/licenses/by/4.0/"}
:dependencies [[org.clojure/clojure "1.10.2"]
[incanter/incanter-core "1.9.3"]
[incanter/incanter-charts "1.9.3"]
[incanter/incanter-io "1.9.3"]
[org.clojure/data.json "1.0.0"]
[clj-http "3.11.0"]
[slingshot "0.12.2"]]
:plugins [[lein-cljfmt "0.7.0"]]
:main ^:skip-aot strava-activity-graphs.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
|
Revert back to snapshot version. | (defproject cli4clj "1.2.3"
;(defproject cli4clj "1.2.3-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.8.0"]
[clj-assorted-utils "1.12.0"]
[jline/jline "2.14.2"]]
: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"]]
:profiles {:repl {:dependencies [[jonase/eastwood "0.2.2" :exclusions [org.clojure/clojure]]]}}
)
| ;(defproject cli4clj "1.2.3"
(defproject cli4clj "1.2.4-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.8.0"]
[clj-assorted-utils "1.12.0"]
[jline/jline "2.14.2"]]
: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"]]
:profiles {:repl {:dependencies [[jonase/eastwood "0.2.2" :exclusions [org.clojure/clojure]]]}}
)
|
Set quil/processing-js version same as version of current supported Processing.js. | (defproject quil/processing-js "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"})
| (defproject quil/processing-js "1.4.8"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"})
|
Update eastwood from 0.2.0 to 0.2.2 | (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.7.0"]
[ring "1.4.0"]
[compojure "1.4.0"]
[clj-time "0.11.0"]
[org.clojure/data.json "0.2.6"]
[org.clojure/tools.cli "0.3.3"]]
: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]})
| (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.7.0"]
[ring "1.4.0"]
[compojure "1.4.0"]
[clj-time "0.11.0"]
[org.clojure/data.json "0.2.6"]
[org.clojure/tools.cli "0.3.3"]]
:pedantic? :abort
:plugins [[jonase/eastwood "0.2.2"]]
:profiles {:dev {:dependencies [[ring-mock "0.1.5"]]}
:uberjar {:aot [statuses.server]}}
:main statuses.server
:aliases {"lint" "eastwood"}
:eastwood {:exclude-linters [:constant-test]})
|
Change func to return file response, instead of litteral path | (ns wort.handler
(:require [compojure.core :refer :all]
[compojure.route :as route]
[ring.util.response :as resp]
[wort.core :as core]
[ring.middleware.defaults :refer [wrap-defaults site-defaults]]))
(defroutes app-routes
(GET "/" []
(resp/content-type (resp/resource-response "index.html" {:root "public"}) "text/html"))
(GET "/sound" []
(resp/response "../resources/a-team_crazy_fool_x.wav"))
(route/resources "/")
(route/not-found "Not Found"))
(def app
(wrap-defaults app-routes site-defaults))
| (ns wort.handler
(:require [compojure.core :refer :all]
[compojure.route :as route]
[ring.util.response :as resp]
[wort.core :as core]
[ring.middleware.defaults :refer [wrap-defaults site-defaults]]))
(defroutes app-routes
(GET "/" []
(resp/content-type (resp/resource-response "index.html" {:root "public"}) "text/html"))
(GET "/sound" []
(resp/file-response "../resources/a-team_crazy_fool_x.wav"))
(route/resources "/")
(route/not-found "Not Found"))
(def app
(wrap-defaults app-routes site-defaults))
|
Make the packages argument mandatory | (ns radicalzephyr.boot-junit
{:boot/export-tasks true}
(:require [boot.core :as core])
(:import org.junit.runner.JUnitCore))
(defn failure->map [failure]
{:description (.. failure (getDescription) (toString))
:exception (.getException failure)
:message (.getMessage failure)})
(defn result->map [result]
{:successful? (.wasSuccessful result)
:run-time (.getRunTime result)
:run (.getRunCount result)
:ignored (.getIgnoredCount result)
:failed (.getFailureCount result)
:failures (map failure->map (.getFailures result))})
(core/deftask junit
"Run the jUnit test runner."
[p packages PACKAGE #{sym} "The set of Java packages to run tests in."]
(core/with-pre-wrap fileset
(let [result (JUnitCore/runClasses
(into-array Class
[#_ (magic goes here to find all test classes)]))]
(when (> (.getFailureCount result) 0)
(throw (ex-info "There were some test failures."
(result->map result)))))
fileset))
| (ns radicalzephyr.boot-junit
{:boot/export-tasks true}
(:require [boot.core :as core])
(:import org.junit.runner.JUnitCore))
(defn failure->map [failure]
{:description (.. failure (getDescription) (toString))
:exception (.getException failure)
:message (.getMessage failure)})
(defn result->map [result]
{:successful? (.wasSuccessful result)
:run-time (.getRunTime result)
:run (.getRunCount result)
:ignored (.getIgnoredCount result)
:failed (.getFailureCount result)
:failures (map failure->map (.getFailures result))})
(core/deftask junit
"Run the jUnit test runner."
[p packages PACKAGE #{sym} "The set of Java packages to run tests in."]
(core/with-pre-wrap fileset
(if (seq packages)
(let [result (JUnitCore/runClasses
(into-array Class
[#_ (magic goes here to find all test classes)]))]
(when (> (.getFailureCount result) 0)
(throw (ex-info "There were some test failures."
(result->map result)))))
(println "No packages were tested."))
fileset))
|
Set cert test to check for new cert expire date | (ns clojars.test.unit.certs
(:require [clojure.test :refer :all]))
(def sixty-days (* 86400 1000 60))
(deftest fail-when-gpg-key-is-about-to-expire
(let [expire-date #inst "2017-09-04T00:00:00.000-00:00"]
(is (< (System/currentTimeMillis)
(- (.getTime expire-date) sixty-days))
(format "Security GPG key expires on %s" expire-date))))
(deftest fail-when-tls-cert-is-about-to-expire
(let [expire-date #inst "2016-08-12T00:00:00.000-00:00"]
(is (< (System/currentTimeMillis)
(- (.getTime expire-date) sixty-days))
(format "clojars.org TLS cert expires on %s" expire-date))))
| (ns clojars.test.unit.certs
(:require [clojure.test :refer :all]))
(def sixty-days (* 86400 1000 60))
(deftest fail-when-gpg-key-is-about-to-expire
(let [expire-date #inst "2017-09-04T00:00:00.000-00:00"]
(is (< (System/currentTimeMillis)
(- (.getTime expire-date) sixty-days))
(format "Security GPG key expires on %s" expire-date))))
(deftest fail-when-tls-cert-is-about-to-expire
(let [expire-date #inst "2018-06-18T00:00:00.000-00:00"]
(is (< (System/currentTimeMillis)
(- (.getTime expire-date) sixty-days))
(format "clojars.org TLS cert expires on %s" expire-date))))
|
Allow to configure the data directory | (ns buildviz.main
(:require [buildviz.build-results :as results]
[buildviz.handler :as handler]
[buildviz.http :as http]
[buildviz.storage :as storage]))
(def jobs-filename "buildviz_jobs")
(def tests-filename "buildviz_tests")
(defn- persist-jobs! [build-data]
(storage/store! build-data jobs-filename))
(defn- persist-tests! [tests-data]
(storage/store! tests-data tests-filename))
(def app
(let [builds (storage/load-from-file jobs-filename)
tests (storage/load-from-file tests-filename)]
(-> (handler/create-app (results/build-results builds tests)
persist-jobs!
persist-tests!)
http/wrap-log-request
http/wrap-log-errors)))
| (ns buildviz.main
(:require [buildviz.build-results :as results]
[buildviz.handler :as handler]
[buildviz.http :as http]
[buildviz.storage :as storage]
[clojure.java.io :as io]
[clojure.string :as str]))
(defn- path-for [file-name]
(if-let [data-dir (System/getenv "BUILDVIZ_DATA_DIR")]
(.getPath (io/file data-dir file-name))
file-name))
(def jobs-filename (path-for "buildviz_jobs"))
(def tests-filename (path-for "buildviz_tests"))
(defn- persist-jobs! [build-data]
(storage/store! build-data jobs-filename))
(defn- persist-tests! [tests-data]
(storage/store! tests-data tests-filename))
(def app
(let [builds (storage/load-from-file jobs-filename)
tests (storage/load-from-file tests-filename)]
(-> (handler/create-app (results/build-results builds tests)
persist-jobs!
persist-tests!)
http/wrap-log-request
http/wrap-log-errors)))
|
Use subs(tring) instead of seq operations and inline if | (ns hu.ssh.github-changelog
(:require
[environ.core :refer [env]]
[tentacles.core :as core]
[tentacles.repos :as repos]
[tentacles.pulls :as pulls]
[clj-semver.core :as semver]))
(defn repo
"Gets the repository from its name"
([name] (repo "pro" name))
([org repo] [org repo]))
(defn parse-semver
"Checks for semantic versions with or without v predicate"
[tag]
(let [version (:name tag)
parse #(try (semver/parse %)
(catch java.lang.AssertionError _e nil))]
(if (= \v (first version))
(parse (apply str (rest version)))
(parse version))))
(defn changelog
"Fetches the changelog"
[user repo]
(let [tags (delay (map #(assoc % :version (parse-semver %)) (repos/tags user repo)))
pulls (delay (pulls/pulls user repo {:state "closed"}))
commits (delay (repos/commits user repo))]
(println (first @tags))))
(core/with-defaults {:oauth-token (env :github-token) :all_pages true}
(changelog "raszi" "node-tmp"))
| (ns hu.ssh.github-changelog
(:require
[environ.core :refer [env]]
[tentacles.core :as core]
[tentacles.repos :as repos]
[tentacles.pulls :as pulls]
[clj-semver.core :as semver]))
(defn repo
"Gets the repository from its name"
([name] (repo "pro" name))
([org repo] [org repo]))
(defn parse-semver
"Checks for semantic versions with or without v predicate"
[tag]
(let [version (:name tag)
parse #(try (semver/parse %)
(catch java.lang.AssertionError _e nil))]
(parse
(if (= \v (first version))
(subs version 1)
version))))
(defn changelog
"Fetches the changelog"
[user repo]
(let [tags (delay (map #(assoc % :version (parse-semver %)) (repos/tags user repo)))
pulls (delay (pulls/pulls user repo {:state "closed"}))
commits (delay (repos/commits user repo))]
(println (first @tags))))
(core/with-defaults {:oauth-token (env :github-token) :all_pages true}
(changelog "raszi" "node-tmp"))
|
Use io/as-url instead of the URL constructor | (ns comic-reader.scrape
(:require [clojure.string :as s]
[net.cgrand.enlive-html :as html])
(:import java.net.URL))
(defn fetch-url [url]
(html/html-resource (URL. url)))
(defn extract-list [html selector normalize]
(map normalize (html/select html selector)))
(defn fetch-list [{:keys [url selector normalize]}]
(when (every? (complement nil?) [url selector normalize])
(extract-list (fetch-url url) selector normalize)))
(defn enlive->hiccup [{:keys [tag attrs content]}]
(if (nil? content)
[tag attrs]
[tag attrs content]))
(defn clean-image-tag [[tag attrs & content]]
[tag (select-keys attrs [:alt :src])])
(defn extract-image-tag [html selector]
(some-> html
(html/select selector)
seq
first
enlive->hiccup
clean-image-tag))
(defn fetch-image-tag [{:keys [url selector]}]
(when (every? (complement nil?) [url selector])
(-> (fetch-url url)
(extract-image-tag selector))))
| (ns comic-reader.scrape
(:require [clojure.string :as s]
[clojure.java.io :as io]
[net.cgrand.enlive-html :as html])
(:import java.net.URL))
(defn fetch-url [url]
(html/html-resource (io/as-url url)))
(defn extract-list [html selector normalize]
(map normalize (html/select html selector)))
(defn fetch-list [{:keys [url selector normalize]}]
(when (every? (complement nil?) [url selector normalize])
(extract-list (fetch-url url) selector normalize)))
(defn enlive->hiccup [{:keys [tag attrs content]}]
(if (nil? content)
[tag attrs]
[tag attrs content]))
(defn clean-image-tag [[tag attrs & content]]
[tag (select-keys attrs [:alt :src])])
(defn extract-image-tag [html selector]
(some-> html
(html/select selector)
seq
first
enlive->hiccup
clean-image-tag))
(defn fetch-image-tag [{:keys [url selector]}]
(when (every? (complement nil?) [url selector])
(-> (fetch-url url)
(extract-image-tag selector))))
|
Fix to warnings on repl | (ns user
(:refer-clojure :exclude [dec < range <= min long int > - time / >= inc + max complement atom])
(:require
[tick.alpha.api :refer :all]
;;[tick.deprecated.cal :refer [holidays-in-england-and-wales weekend?]]
[tick.viz :refer [show-canvas view label]]
;;[tick.deprecated.schedule :as sch :refer [schedule]]
[clojure.spec.alpha :as s]
clojure.test)
(:import [java.time DayOfWeek]))
(defn test-all []
(require 'tick.alpha.api-test 'tick.core-test 'tick.interval-test)
(clojure.test/run-all-tests #"(tick).*test$"))
| (ns user
(:require
[tick.alpha.api :as t]
;;[tick.deprecated.cal :refer [holidays-in-england-and-wales weekend?]]
[tick.viz :refer [show-canvas view label]]
;;[tick.deprecated.schedule :as sch :refer [schedule]]
[clojure.spec.alpha :as s]
clojure.test)
(:import [java.time DayOfWeek]))
(defn test-all []
(require 'tick.alpha.api-test 'tick.core-test 'tick.interval-test)
(clojure.test/run-all-tests #"(tick).*test$"))
|
Remove snapshots from dependencies, fix :license key | (defproject io.nervous/hildebrand "0.2.1"
:description "High-level, asynchronous AWS client library"
:url "https://github.com/nervous-systems/hildebrand"
:License {:name "Unlicense" :url "http://unlicense.org/UNLICENSE"}
:scm {:name "git" :url "https://github.com/nervous-systems/hildebrand"}
:deploy-repositories [["clojars" {:creds :gpg}]]
:signing {:gpg-key "moe@nervous.io"}
:global-vars {*warn-on-reflection* true}
:source-paths ["src" "test"]
:plugins [[codox "0.8.11"]]
:codox {:include [hildebrand]
:defaults {:doc/format :markdown}}
:dependencies
[[org.clojure/clojure "1.6.0"]
[org.clojure/core.async "0.1.346.0-17112a-alpha"]
[io.nervous/eulalie "0.1.1-SNAPSHOT"]
[io.nervous/glossop "0.1.0-SNAPSHOT"]
[prismatic/plumbing "0.4.1"]]
:exclusions [[org.clojure/clojure]])
| (defproject io.nervous/hildebrand "0.2.1"
:description "High-level, asynchronous AWS client library"
:url "https://github.com/nervous-systems/hildebrand"
:license {:name "Unlicense" :url "http://unlicense.org/UNLICENSE"}
:scm {:name "git" :url "https://github.com/nervous-systems/hildebrand"}
:deploy-repositories [["clojars" {:creds :gpg}]]
:signing {:gpg-key "moe@nervous.io"}
:global-vars {*warn-on-reflection* true}
:source-paths ["src" "test"]
:plugins [[codox "0.8.11"]]
:codox {:include [hildebrand]
:defaults {:doc/format :markdown}}
:dependencies
[[org.clojure/clojure "1.6.0"]
[org.clojure/core.async "0.1.346.0-17112a-alpha"]
[io.nervous/eulalie "0.1.1"]
[io.nervous/glossop "0.1.0"]
[prismatic/plumbing "0.4.1"]]
:exclusions [[org.clojure/clojure]])
|
Update intro page clojure example | (def scenes [{:subject "Frankie"
:action "say"
:object "relax"}
{:subject "Lucy"
:action "❤s"
:object "Clojure"}
{:subject "Rich"
:action "tries"
:object "a new conditioner"}])
(println "People:" (->> scenes
(map :subject)
(interpose ", ")
(reduce str)))
;;=> People: Frankie, Lucy, Rich
| ;; Let's define some data using list / map
;; literals:
(def scenes [{:subject "Frankie"
:action "say"
:object "relax"}
{:subject "Lucy"
:action "❤s"
:object "Clojure"}
{:subject "Rich"
:action "tries"
:object "a new conditioner"}])
;; Who's in our scenes?
(println "People:" (->> scenes
(map :subject)
(interpose ", ")
(reduce str)))
;;=> People: Frankie, Lucy, Rich
|
Make ES src dir configurable | (ns clj-git.test.core-test
(:require [clojure.java.io :as io]
[clojure.test :refer :all])
(:require [clj-git.core :as git] :reload-all))
(def es-src-dir (-> "clj_git"
io/resource
io/file
.getParent
(io/file "elasticsearch-src")
.getCanonicalPath))
(defn maybe-prep-repo [dir]
(if (.exists (io/file dir ".git"))
(do
(print "Elasticsearch source already cloned. Pulling...")
(flush)
(git/git-pull (git/load-repo dir)))
(do
(print "Elasticsearch source missing. Cloning...")
(flush)
(git/git-clone
dir
"https://github.com/elastic/elasticsearch.git")))
(println " Done."))
(deftest parse-commit
(maybe-prep-repo es-src-dir)
(time
(testing "the first thousand commits can parse"
(is (= 1000 (->> es-src-dir
git/load-repo
git/git-log
(take 1000)
count))))))
| (ns clj-git.test.core-test
(:require [clojure.java.io :as io]
[clojure.test :refer :all]
[environ.core :as environ])
(:require [clj-git.core :as git] :reload-all))
(defn abspath [path]
(-> path
io/file
.getCanonicalPath))
(def es-src-dir
(abspath
(or (environ/env :elasticsearch-src)
(-> "clj_git"
io/resource
io/file
.getParent
(io/file "elasticsearch-src")))))
(defn maybe-prep-repo [dir]
(if (.exists (io/file dir ".git"))
(do
(printf "Elasticsearch source already cloned in %s. Pulling..." dir)
(flush)
(git/git-pull (git/load-repo dir)))
(do
(printf "Elasticsearch source missing in %s. Cloning..." dir)
(flush)
(git/git-clone
dir
"https://github.com/elastic/elasticsearch.git")))
(println " Done."))
(deftest parse-commit
(maybe-prep-repo es-src-dir)
(time
(testing "the first thousand commits can parse"
(is (= 1000 (->> es-src-dir
git/load-repo
git/git-log
(take 1000)
count))))))
|
Update catacumba version on debugging example. | (defproject debugging "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://github.com/funcool/catacumba"
:license {:name "BSD (2-Clause)"
:url "http://opensource.org/licenses/BSD-2-Clause"}
:dependencies [[org.clojure/clojure "1.7.0-RC1"]
[funcool/catacumba "0.1.0-alpha2"]
[prone "0.8.1"]]
:main ^:skip-aot debugging.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
| (defproject debugging "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://github.com/funcool/catacumba"
:license {:name "BSD (2-Clause)"
:url "http://opensource.org/licenses/BSD-2-Clause"}
:dependencies [[org.clojure/clojure "1.7.0-RC1"]
[funcool/catacumba "0.2.0"]
[prone "0.8.1"]]
:main ^:skip-aot debugging.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
|
Use JNDI to find the data source | (ns hyphen-keeper.db
"Persistence for the hyphenation dictionary"
(:require [yesql.core :refer [defqueries]]))
(def ^:private db "jdbc:mysql://localhost:3306/hyphenation?user=hyphenation&serverTimezone=UTC")
(defqueries "hyphen_keeper/queries.sql" {:connection db})
(defn read-words
"Return a coll of words for given `spelling`"
[spelling]
(-> {:spelling spelling} words))
(defn read-words-paginated
"Return a coll of words for given `spelling` using `max-rows` and `offset` for pagination"
[spelling offset max-rows]
(-> {:spelling spelling :max_rows max-rows :offset offset}
words-paginated))
(defn search-words
"Return a coll of words for given `spelling` and given `search` term"
[spelling search]
(-> {:spelling spelling :search search}
words-search))
(defn save-word!
"Persist `word` with given `hyphenation` and `spelling`"
[word hyphenation spelling]
(-> {:word word :hyphenation hyphenation :spelling spelling}
save-word-internal!))
(defn remove-word! [word spelling]
(-> {:word word :spelling spelling}
remove-word-internal!))
| (ns hyphen-keeper.db
"Persistence for the hyphenation dictionary"
(:require [yesql.core :refer [defqueries]]))
(def ^:private db {:name "java:jboss/datasources/old-productions"})
(defqueries "hyphen_keeper/queries.sql" {:connection db})
(defn read-words
"Return a coll of words for given `spelling`"
[spelling]
(-> {:spelling spelling} words))
(defn read-words-paginated
"Return a coll of words for given `spelling` using `max-rows` and `offset` for pagination"
[spelling offset max-rows]
(-> {:spelling spelling :max_rows max-rows :offset offset}
words-paginated))
(defn search-words
"Return a coll of words for given `spelling` and given `search` term"
[spelling search]
(-> {:spelling spelling :search search}
words-search))
(defn save-word!
"Persist `word` with given `hyphenation` and `spelling`"
[word hyphenation spelling]
(-> {:word word :hyphenation hyphenation :spelling spelling}
save-word-internal!))
(defn remove-word! [word spelling]
(-> {:word word :spelling spelling}
remove-word-internal!))
|
Add queries to database layer | (ns madouc.db
(:require [mount.core :refer [defstate]]
[conman.core :as conman]
[madouc.config :refer [env]]))
(defn- make-pool-spec
[host db user pass]
{:jdbc-url (format "jdbc:postgresql://%s/%s" host db)
:username user
:password pass})
(defstate con
:start (conman/connect! (make-pool-spec
(env :db-host)
(env :db-name)
(env :db-user)
(env :db-password)))
:stop (conman/disconnect! con))
| (ns madouc.db
(:require [mount.core :refer [defstate]]
[conman.core :as conman]
[madouc.config :refer [env]]))
(defn- make-pool-spec
[host db user pass]
{:jdbc-url (format "jdbc:postgresql://%s/%s" host db)
:username user
:password pass})
(defstate con
:start (conman/connect! (make-pool-spec
(env :db-host)
(env :db-name)
(env :db-user)
(env :db-password)))
:stop (conman/disconnect! con))
(conman/bind-connection con "sql/queries.sql")
|
Allow navigating strings as a base data structure | (ns themis.extended-protos
(:require [themis.protocols :as protocols]))
(extend-protocol protocols/Navigable
clojure.lang.PersistentVector
(-navigate [t coordinate-vec]
(get-in t coordinate-vec))
clojure.lang.IPersistentMap
(-navigate [t coordinate-vec]
(get-in t coordinate-vec)))
| (ns themis.extended-protos
(:require [themis.protocols :as protocols]))
(extend-protocol protocols/Navigable
clojure.lang.PersistentVector
(-navigate [t coordinate-vec]
(get-in t coordinate-vec))
clojure.lang.IPersistentMap
(-navigate [t coordinate-vec]
(get-in t coordinate-vec))
java.lang.String
(-navigate [t coordinate-vec]
(get-in t coordinate-vec)))
|
Convert keyword to a string name | (ns ^{:doc "Functions dealing with making various forms of
Midje output be ergonomically colorful."}
midje.emission.colorize
(:require [colorize.core :as color]
[clojure.string :as str]
[midje.config :as config])
(:use [midje.util.ecosystem :only [getenv on-windows?]]))
(defn colorize-setting []
(config/choice :colorize))
(defn- colorize-config-as-str []
(let [setting-as-str (str (colorize-setting))]
(when-not (str/blank? setting-as-str) setting-as-str)))
(defn- colorize-choice []
(str/upper-case (or (getenv "MIDJE_COLORIZE")
(colorize-config-as-str)
(str (not (on-windows?))))))
(defn init! []
(case (colorize-choice)
"TRUE" (do
(def fail color/red)
(def pass color/green)
(def note color/cyan))
("REVERSE" ":REVERSE") (do
(def fail color/red-bg)
(def pass color/green-bg)
(def note color/cyan-bg))
(do
(def fail str)
(def pass str)
(def note str))))
| (ns ^{:doc "Functions dealing with making various forms of
Midje output be ergonomically colorful."}
midje.emission.colorize
(:require [colorize.core :as color]
[clojure.string :as str]
[midje.config :as config])
(:use [midje.util.ecosystem :only [getenv on-windows?]]))
(defn colorize-setting []
(config/choice :colorize))
(defn- colorize-config-as-str []
(let [setting (colorize-setting)
setting (if (keyword? setting) (name setting) setting)
setting-as-str (str setting)]
(when-not (str/blank? setting-as-str) setting-as-str)))
(defn- colorize-choice []
(str/upper-case (or (getenv "MIDJE_COLORIZE")
(colorize-config-as-str)
(str (not (on-windows?))))))
(defn init! []
(case (colorize-choice)
"TRUE" (do
(def fail color/red)
(def pass color/green)
(def note color/cyan))
"REVERSE" (do
(def fail color/red-bg)
(def pass color/green-bg)
(def note color/cyan-bg))
(do
(def fail str)
(def pass str)
(def note str))))
|
Make tests only run once when figwheel reloads | (ns devsetup
(:require [demo :as site]
[runtests]
[reagent.core :as r]
[figwheel.client :as fw]))
(defn test-results []
[runtests/test-output-mini])
(defn start! []
(demo/start! {:test-results test-results})
(runtests/run-tests))
(when r/is-client
(fw/start
{:websocket-url "ws://localhost:3449/figwheel-ws"
:jsload-callback #(start!)
:heads-up-display true
:load-warninged-code false}))
(start!)
| (ns ^:figwheel-always devsetup
(:require [demo :as site]
[runtests]
[reagent.core :as r]
[figwheel.client :as fw]))
(when r/is-client
(fw/start
{:websocket-url "ws://localhost:3449/figwheel-ws"}))
(defn test-results []
[runtests/test-output-mini])
(defn start! []
(demo/start! {:test-results test-results})
(runtests/run-tests))
(start!)
|
Move portal to :provided section | ;; https://github.com/technomancy/leiningen/blob/stable/doc/PROFILES.md
{:provided
{:dependencies
[[djblue/portal "0.21.2"]]}
: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"]
[antq "RELEASE"]
[clj-kondo "RELEASE"]]
:aliases {"clj-kondo" ["run" "-m" "clj-kondo.main"]
"outdated" ["run" "-m" "antq.core"]}}
| ;; https://github.com/technomancy/leiningen/blob/stable/doc/PROFILES.md
{:provided
{:dependencies
[[djblue/portal "0.21.2"]
[fipp "0.6.24"]]}
: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"]
[antq "RELEASE"]
[clj-kondo "RELEASE"]]
:aliases {"clj-kondo" ["run" "-m" "clj-kondo.main"]
"outdated" ["run" "-m" "antq.core"]}}
|
Fix on-close handler so it can return any type, not only nil. | (ns quil.helpers.applet-listener
(:gen-class
:name quil.helpers.AppletListener
:main false
:init init
:state listeners
:constructors {[java.util.Map] []}
:methods [["dispose" [] java.lang.Void]]))
(defn safe-call [fn]
(when fn (fn)))
(defn -init [listeners]
[[] listeners])
(defn -dispose [this]
(safe-call (:on-dispose (.listeners this)))) | (ns quil.helpers.applet-listener
(:gen-class
:name quil.helpers.AppletListener
:main false
:init init
:state listeners
:constructors {[java.util.Map] []}
:methods [["dispose" [] java.lang.Object]]))
(defn safe-call [fn]
(when fn (fn)))
(defn -init [listeners]
[[] listeners])
(defn -dispose [this]
(safe-call (:on-dispose (.listeners this)))) |
Add data.csv, boot-test, and set up for testing. | ; vi: ft=clojure
(set-env!
:resource-paths #{"src"}
:dependencies '[[org.clojure/clojure "1.8.0"]
[incanter "1.9.0"]])
(task-options!
aot {:all true}
pom {:project 'analyze-data
:version "0.0.0"}
jar {:main 'analyze-data.core})
(deftask build []
(comp (aot) (pom) (uber) (jar) (target)))
| ; vi: ft=clojure
(set-env!
:resource-paths #{"src", "test"}
:dependencies '[[org.clojure/clojure "1.8.0"]
[org.clojure/data.csv "0.1.3"]
[incanter "1.9.0"]
[adzerk/boot-test "1.2.0" :scope "test"]])
(require '[adzerk.boot-test :refer [test]])
(task-options!
aot {:all true}
pom {:project 'analyze-data
:version "0.0.0"}
jar {:main 'analyze-data.core})
(deftask build []
(comp (aot) (pom) (uber) (jar) (target)))
|
Fix EOF bug when reading ECN files. | (ns clj-chess.ecn
"Functions for reading chess games in ECN (extensible chess notation)
format."
(:require [clojure.edn :as edn]
[clojure.java.io :as io])
(:import (java.io PushbackReader)))
(defn reader
"Convenience function for creating a java PushbackReader for the given
file name. Why isn't this included in Clojure?"
[filename]
(PushbackReader. (io/reader filename)))
(defn edn-seq
"A lazy sequence of EDN objects in from the provided reader."
[rdr]
(when-let [game (edn/read rdr)]
(cons game (lazy-seq (edn-seq rdr)))))
(defn game-headers
"Returns a lazy sequence of the game headers of an ECN file."
[rdr]
(map (comp rest second) (edn-seq rdr)))
(defn games-in-file [ecn-file]
(edn-seq (reader ecn-file))) | (ns clj-chess.ecn
"Functions for reading chess games in ECN (extensible chess notation)
format."
(:require [clojure.edn :as edn]
[clojure.java.io :as io])
(:import (java.io PushbackReader)))
(defn reader
"Convenience function for creating a java PushbackReader for the given
file name. Why isn't this included in Clojure?"
[filename]
(PushbackReader. (io/reader filename)))
(defn edn-seq
"A lazy sequence of EDN objects in from the provided reader."
[rdr]
(when-let [game (edn/read {:eof nil} rdr)]
(cons game (lazy-seq (edn-seq rdr)))))
(defn game-headers
"Returns a lazy sequence of the game headers of an ECN file."
[rdr]
(map (comp rest second) (edn-seq rdr)))
(defn games-in-file [ecn-file]
(edn-seq (reader ecn-file))) |
Add toString implementation to TextNode | (ns selmer.node
" Node protocol for the objects that get accum'd in the post-parse vector.
Same vector that will be processed by the runtime context-aware renderer.
Currently only TextNodes and FunctionNodes. Anything that requires action
upon context map data at runtime is handled by a generated anonymous function. "
(:gen-class))
;; Generic INode protocol
(defprotocol INode
(render-node [this context-map] "Renders the context"))
;; Implements fn handler for the context map. fn handlers can
;; access any data in the context map.
(deftype FunctionNode [handler]
INode
(render-node [this context-map]
(handler context-map)))
;; Implements dumb text content injection at runtime.
(deftype TextNode [text]
INode
(render-node [this context-map]
text))
| (ns selmer.node
" Node protocol for the objects that get accum'd in the post-parse vector.
Same vector that will be processed by the runtime context-aware renderer.
Currently only TextNodes and FunctionNodes. Anything that requires action
upon context map data at runtime is handled by a generated anonymous function. "
(:gen-class))
;; Generic INode protocol
(defprotocol INode
(render-node [this context-map] "Renders the context"))
;; Implements fn handler for the context map. fn handlers can
;; access any data in the context map.
(deftype FunctionNode [handler]
INode
(render-node [this context-map]
(handler context-map)))
;; Implements dumb text content injection at runtime.
(deftype TextNode [text]
INode
(render-node [this context-map]
text)
(toString [_]
text))
|
Use string replacement to display short version of proc-fns. | ;;;
;;; Copyright 2015 Ruediger Gad
;;;
;;; This software is released under the terms of the Eclipse Public License
;;; (EPL) 1.0. You can find a copy of the EPL at:
;;; http://opensource.org/licenses/eclipse-1.0.php
;;;
(ns
^{:author "Ruediger Gad",
:doc "Helper that are primarily used during experiments"}
dsbdp.experiment-helper
(:require
[clojure.walk :refer :all]
[dsbdp.byte-array-conversion :refer :all]))
(defmacro create-proc-fns
[fn-1 fn-n n]
(loop [fns (prewalk-replace {:idx 0} [fn-1])]
(if (< (count fns) n)
(recur (conj fns (prewalk-replace {:idx (count fns)} fn-n)))
(do
(println "proc-fns-full:" fns)
fns))))
(defmacro create-no-op-proc-fns
[n]
`(create-proc-fns (fn [~'_ ~'_]) (fn [~'_ ~'_]) ~n))
(defmacro create-inc-proc-fns
[n]
`(create-proc-fns (fn [~'i ~'_] (inc ~'i)) (fn [~'_ ~'o] (inc ~'o)) ~n))
| ;;;
;;; Copyright 2015 Ruediger Gad
;;;
;;; This software is released under the terms of the Eclipse Public License
;;; (EPL) 1.0. You can find a copy of the EPL at:
;;; http://opensource.org/licenses/eclipse-1.0.php
;;;
(ns
^{:author "Ruediger Gad",
:doc "Helper that are primarily used during experiments"}
dsbdp.experiment-helper
(:require
[clojure.walk :refer :all]
[dsbdp.byte-array-conversion :refer :all]))
(defmacro create-proc-fns
[fn-1 fn-n n]
(loop [fns (prewalk-replace {:idx 0} [fn-1])]
(if (< (count fns) n)
(recur (conj fns (prewalk-replace {:idx (count fns)} fn-n)))
(do
(println "proc-fns-full:" fns)
(println "proc-fns-short:" (.replaceAll (str fns) "(?<=\\()([a-zA-Z\\.\\-]++/)" ""))
fns))))
(defmacro create-no-op-proc-fns
[n]
`(create-proc-fns (fn [~'_ ~'_]) (fn [~'_ ~'_]) ~n))
(defmacro create-inc-proc-fns
[n]
`(create-proc-fns (fn [~'i ~'_] (inc ~'i)) (fn [~'_ ~'o] (inc ~'o)) ~n))
|
Remove cache when deleting an item | (ns tixi.mutators.delete
(:require [tixi.data :as d]
[tixi.mutators.shared :as msh]
[tixi.mutators.locks :as ml]
[tixi.mutators.undo :as mu]
[tixi.items :as i]))
(defn delete-items! [ids]
(when (not-empty ids)
(mu/snapshot!)
(doseq [id ids]
(ml/delete-from-locks! id (d/completed-item id))
(msh/update-state! update-in [:completed] dissoc id))))
| (ns tixi.mutators.delete
(:require [tixi.data :as d]
[tixi.mutators.shared :as msh]
[tixi.mutators.locks :as ml]
[tixi.mutators.undo :as mu]
[tixi.items :as i]))
(defn delete-items! [ids]
(when (not-empty ids)
(mu/snapshot!)
(doseq [id ids]
(swap! d/data update-in [:cache] dissoc id)
(ml/delete-from-locks! id (d/completed-item id))
(msh/update-state! update-in [:completed] dissoc id))))
|
Delete to lower case to allow tests to pass | (ns etcd-clojure.core-test
(:require [clojure.test :refer :all]
[etcd-clojure.core :as etcd]))
(defn setup-test []
(etcd/connect! "http://127.0.0.1:4001"))
(defn teardown-test []
(println "teardown"))
(defn once-fixtures [f]
(setup-test)
(try
(f)
(finally (teardown-test))))
(use-fixtures :once once-fixtures)
(deftest test-set
(testing "should set a value"
(is (= "bar" (get (etcd/set "foo" "bar") "value")))))
(deftest test-create
(testing "should set a value"
(is (= "bar" (get (etcd/create "foo" "bar") "value")))))
(deftest test-delete
(testing "should delete a value"
(etcd/set "foo" "bar")
(is (= "DELETE" (get (etcd/delete "foo") "action")))))
(deftest test-get
(testing "should get a value"
(etcd/set "foo" "bar")
(is (= "bar" (etcd/get "foo")))))
| (ns etcd-clojure.core-test
(:require [clojure.test :refer :all]
[etcd-clojure.core :as etcd]))
(defn setup-test []
(etcd/connect! "http://127.0.0.1:4001"))
(defn teardown-test []
(println "teardown"))
(defn once-fixtures [f]
(setup-test)
(try
(f)
(finally (teardown-test))))
(use-fixtures :once once-fixtures)
(deftest test-set
(testing "should set a value"
(is (= "bar" (get (etcd/set "foo" "bar") "value")))))
(deftest test-create
(testing "should set a value"
(is (= "bar" (get (etcd/create "foo" "bar") "value")))))
(deftest test-delete
(testing "should delete a value"
(etcd/set "foo" "bar")
(is (= "delete" (get (etcd/delete "foo") "action")))))
(deftest test-get
(testing "should get a value"
(etcd/set "foo" "bar")
(is (= "bar" (etcd/get "foo")))))
|
Use if instead of cond | (ns dna)
(defn- strand-convert [ch]
(cond
(= \T ch) \U
:else ch
)
)
(defn to-rna [dna]
(apply str (map strand-convert dna))
) | (ns dna)
(defn- strand-convert [ch]
(if (= \T ch) \U ch)
)
(defn to-rna [dna]
(apply str (map strand-convert dna))
) |
Allow debug output during tests. | (ns matross.test.helper
"Helper functions for writing and running tests"
(:require [me.raynes.conch :refer [with-programs]]
[matross.connections.ssh :refer [translate-ssh-config ssh-connection]]
[matross.connections.core :refer [connect disconnect]]))
(defn get-available-vms []
(with-programs [vagrant grep cut]
(cut "-f1" "-d "
(vagrant "status" {:seq true})
{:seq true})))
(def vagrant-test-connection
(memoize (fn [] (translate-ssh-config (slurp (System/getenv "TEST_SSH_CONF"))))))
(defmacro task-tests
"Evaluate the body against the test vm connection, exposed as conn"
[conn & body]
`(let [~conn (ssh-connection (vagrant-test-connection))]
(connect ~conn)
~@body
(disconnect ~conn)))
| (ns matross.test.helper
"Helper functions for writing and running tests"
(:require [me.raynes.conch :refer [with-programs]]
[matross.connections.ssh :refer [translate-ssh-config ssh-connection]]
[matross.connections.debug :refer [debug-connection]]
[matross.connections.core :refer [connect disconnect]]))
(defn get-available-vms []
(with-programs [vagrant grep cut]
(cut "-f1" "-d "
(vagrant "status" {:seq true})
{:seq true})))
(def vagrant-test-connection
(memoize (fn [] (translate-ssh-config (slurp (System/getenv "TEST_SSH_CONF"))))))
(defn test-connection []
(let [conn (ssh-connection (vagrant-test-connection))]
(if-let [debug (System/getenv "TEST_DEBUG")]
(debug-connection conn)
conn)))
(defmacro task-tests
"Evaluate the body against the test vm connection, exposed as conn"
[conn & body]
`(let [~conn (test-connection)]
(connect ~conn)
~@body
(disconnect ~conn)))
|
Remove requirement that lifecycle functions must be passed as literal map | (ns ^:figwheel-always re-view.core
(:require [clojure.string :as string]))
(defn parse-name [n]
(str (name (ns-name *ns*)) "/" n))
(defmacro defview
([view-name methods]
`(def ~view-name
(~'re-view.core/view ~(assoc methods
:display-name (str (last (string/split (name (ns-name *ns*)) #"\.")) "/" view-name)))))
([view-name a1 a2 & body]
(let [[methods args body] (if (map? a1)
[a1 a2 body]
[{} a1 (cons a2 body)])]
`(~'re-view.core/defview ~view-name
~(assoc methods :render `(~'fn ~args (~'re-view.hiccup/element (do ~@body))))))))
| (ns ^:figwheel-always re-view.core
(:require [clojure.string :as string]))
(defn parse-name [n]
(str (name (ns-name *ns*)) "/" n))
(defmacro defview
([view-name methods]
`(def ~view-name
(~'re-view.core/view (assoc ~methods
:display-name ~(str (last (string/split (name (ns-name *ns*)) #"\.")) "/" view-name)))))
([view-name a1 a2 & body]
(let [[methods args body] (if (vector? a1)
[{} a1 (cons a2 body)]
[a1 a2 body])]
`(~'re-view.core/defview ~view-name
(~'assoc ~methods :render (~'fn ~args (~'re-view.hiccup/element (do ~@body))))))))
|
Use new logging shell command. | (ns dragon.data.sources.core
(:require [clojure.java.shell :as shell]
[dragon.config :as config]
[taoensso.timbre :as log]))
(defn execute-db-command!
[component]
(let [start-cfg (config/db-start-config component)
home (:home start-cfg)
args (:args start-cfg)]
(shell/with-sh-dir home
(log/debugf "Running command in %s ..." home)
(log/debug "Using shell/sh args:" args)
(apply shell/sh args))))
(defn remove-connection
[component]
(assoc component :conn nil))
| (ns dragon.data.sources.core
(:require [clojure.java.shell :as shell]
[dragon.config :as config]
[dragon.util :as util]
[taoensso.timbre :as log]))
(defn execute-db-command!
[component]
(let [start-cfg (config/db-start-config component)
home (:home start-cfg)
args (:args start-cfg)]
(shell/with-sh-dir home
(log/debugf "Running command in %s ..." home)
(log/debug "Using shell/sh args:" args)
(apply util/shell! args))))
(defn remove-connection
[component]
(assoc component :conn nil))
|
Change signature of IBuffer related functions. | (ns bytebuf.buffer
"Buffer abstractions."
(:import java.nio.ByteBuffer
io.netty.buffer.ByteBuf
io.netty.buffer.ByteBufAllocator))
(defprotocol IBuffer
(read-integer* [_] "Read an integer (32 bits) from buffer.")
(read-long* [_] "Read an long (64 bits) from buffer.")
(tell* [_] "Get the current position index of buffer.")
(seek* [_ val] "Set the current position index on buffer."))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; NIO ByteBuffer implementation
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(extend-type ByteBuffer
IBuffer
(read-integer* [buff]
(.getInt buff))
(read-long* [buff]
(.getLong buff))
(tell* [buff]
(.position buff))
(seek* [buff val]
(.position buff val)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Public Api
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def ^{:private true}
allocator (ByteBufAllocator/DEFAULT))
(defn allocate
([size] (allocate size {}))
([size {:keys [type impl] :or {type :heap impl :nio}}]
(case impl
:nio (case type
:heap (ByteBuffer/allocate size)
:direct (ByteBuffer/allocateDirect size))
:netty (case type
:heap (.heapBuffer allocator size)
:direct (.directBuffer allocator size)))))
(defn seek!
"Set the position index on the buffer."
[buff ^long pos]
(seek! buff pos))
| (ns bytebuf.buffer
"Buffer abstractions."
(:import java.nio.ByteBuffer
io.netty.buffer.ByteBuf
io.netty.buffer.ByteBufAllocator))
(defprotocol IBuffer
(read-int [_ pos] "Read an integer (32 bits) from buffer.")
(write-int [_ pos value] "Write an integer to the buffer.")
(read-long [_ pos] "Read an long (64 bits) from buffer.")
(write-long [_ pos value] "Write an long to the buffer."))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; NIO ByteBuffer implementation
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(extend-type ByteBuffer
IBuffer
(read-integer* [buff]
(.getInt buff))
(read-long* [buff]
(.getLong buff))
(tell* [buff]
(.position buff))
(seek* [buff val]
(.position buff val)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Public Api
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def ^{:private true}
allocator (ByteBufAllocator/DEFAULT))
(defn allocate
([size] (allocate size {}))
([size {:keys [type impl] :or {type :heap impl :nio}}]
(case impl
:nio (case type
:heap (ByteBuffer/allocate size)
:direct (ByteBuffer/allocateDirect size))
:netty (case type
:heap (.heapBuffer allocator size)
:direct (.directBuffer allocator size)))))
(defn seek!
"Set the position index on the buffer."
[buff ^long pos]
(seek! buff pos))
|
Fix html spec to work with coerced dates. | (ns incise.parsers.html-spec
(:require [incise.parsers.html :refer :all]
[incise.parsers.core :refer [map->Parse]]
[clojure.java.io :refer [file resource]]
[speclj.core :refer :all]))
(describe "File->Parse"
(with short-md-file (file (resource "spec/short-sample.md")))
(it "reads some stuff out of a file, yo"
(should= (map->Parse {:title "My Short Page"
:layout :page
:date "2013-08-12"
:path "2013/8/12/my-short-page/index.html"
:tags [:cool]
:category :blarg
:content "\n\nHey there!\n"
:extension "/index.html"})
(File->Parse identity @short-md-file))))
(run-specs)
| (ns incise.parsers.html-spec
(:require [incise.parsers.html :refer :all]
[incise.parsers.core :refer [map->Parse]]
[clj-time.coerce :refer [to-date]]
[clojure.java.io :refer [file resource]]
[speclj.core :refer :all]))
(describe "File->Parse"
(with short-md-file (file (resource "spec/short-sample.md")))
(it "reads some stuff out of a file, yo"
(should= (map->Parse {:title "My Short Page"
:layout :page
:date (to-date "2013-08-12")
:path "2013/8/12/my-short-page/index.html"
:tags [:cool]
:category :blarg
:content "\n\nHey there!\n"
:extension "/index.html"})
(File->Parse identity @short-md-file))))
(run-specs)
|
Support Term-Seq. Shows even more why should be refactored to multimethods! |
{
:name "split-filter-fastqs",
:path "",
:func (fn [eid & data]
(if (pg/eoi? eid)
(pg/done)
(let [exp (cmn/get-exp-info eid :exp)]
(infof "Splitting and filtering fastqs by replicates for %s" eid)
;; This case dispatching is lame! Need to fix with mmethod
(case exp
:tnseq (htts/split-filter-fastqs eid)
:rnaseq (htrs/split-filter-fastqs eid)
:wgseq (htws/split-filter-fastqs eid))
eid)))
:description "Uses experiment id EID to obtain set of initial fastqs for experiment and then splits them by experiment sample barcodes and filters these for quality, then writes new fastqs for all replicates.",
}
|
{
:name "split-filter-fastqs",
:path "",
:func (fn [eid & data]
(if (pg/eoi? eid)
(pg/done)
(let [exp (cmn/get-exp-info eid :exp)]
(infof "Splitting and filtering fastqs by replicates for %s" eid)
;; This case dispatching is lame! Need to fix with mmethod
(case exp
:tnseq (htts/split-filter-fastqs eid)
:rnaseq (htrs/split-filter-fastqs eid)
:termseq (httm/split-filter-fastqs eid)
:wgseq (htws/split-filter-fastqs eid))
eid)))
:description "Uses experiment id EID to obtain set of initial fastqs for experiment and then splits them by experiment sample barcodes and filters these for quality, then writes new fastqs for all replicates.",
}
|
Insert the gate into the mix | (ns audio-utils.recorder
(:require [om.next :as om :refer-macros [defui]]
[om.dom :as dom]
[audio-utils.util :refer [audio-context get-user-media]]
[audio-utils.gate :as g]))
(defui Recorder
Object
(start [this]
(let [audio-ctx (audio-context)
gate (g/gate {:audio-ctx audio-ctx})]
(om/update-state! this assoc
:audio-ctx audio-ctx
:gate gate)
(get-user-media {:audio true}
#(.connect-audio-nodes this %)
js/console.warn)))
(connect-audio-nodes [this stream]
(let [{:keys [audio-ctx gate]} (om/get-state this)
source (.createMediaStreamSource audio-ctx
stream)]
(.connect source (.-destination audio-ctx))))
(stop [this]
(let [audio-ctx (:audio-ctx (om/get-state this))]
(.close audio-ctx)
(om/update-state! this dissoc :audio-ctx)))
(componentWillReceiveProps [this new-props]
(when (not= (:record? (om/props this))
(:record? new-props))
(if (:record? new-props)
(.start this)
(.stop this))))
(render [this]
(dom/div nil)))
(def recorder (om/factory Recorder))
| (ns audio-utils.recorder
(:require [om.next :as om :refer-macros [defui]]
[om.dom :as dom]
[audio-utils.util :refer [audio-context get-user-media]]
[audio-utils.gate :as g]))
(defui Recorder
Object
(start [this]
(let [audio-ctx (audio-context)
gate (g/gate {:audio-ctx audio-ctx})]
(om/update-state! this assoc
:audio-ctx audio-ctx
:gate gate)
(get-user-media {:audio true}
#(.connect-audio-nodes this %)
js/console.warn)))
(connect-audio-nodes [this stream]
(let [{:keys [audio-ctx gate]} (om/get-state this)
source (.createMediaStreamSource audio-ctx
stream)]
(.connect source gate)
(.connect gate (.-destination audio-ctx))))
(stop [this]
(let [audio-ctx (:audio-ctx (om/get-state this))]
(.close audio-ctx)
(om/update-state! this dissoc :audio-ctx)))
(componentWillReceiveProps [this new-props]
(when (not= (:record? (om/props this))
(:record? new-props))
(if (:record? new-props)
(.start this)
(.stop this))))
(render [this]
(dom/div nil)))
(def recorder (om/factory Recorder))
|
Update to latest Clojure RC5 | (defproject thinktopic/cortex "0.1.0-SNAPSHOT"
:description "A neural network toolkit for Clojure."
:dependencies [[org.clojure/clojure "1.8.0-RC4"]
[com.taoensso/timbre "4.2.0"]
[net.mikera/vectorz-clj "0.40.0"]
[org.clojure/test.check "0.9.0"]]
:jvm-opts ["-Xmx8g"
"-XX:+UseConcMarkSweepGC"
"-XX:-OmitStackTraceInFastThrow"])
| (defproject thinktopic/cortex "0.1.0-SNAPSHOT"
:description "A neural network toolkit for Clojure."
:dependencies [[org.clojure/clojure "1.8.0-RC5"]
[com.taoensso/timbre "4.2.0"]
[net.mikera/vectorz-clj "0.40.0"]
[org.clojure/test.check "0.9.0"]]
:jvm-opts ["-Xmx8g"
"-XX:+UseConcMarkSweepGC"
"-XX:-OmitStackTraceInFastThrow"])
|
Prepare for develoment version 0.2.3-SNAPSHOT | (defproject com.stuartsierra/component "0.2.2"
:description "Managed lifecycle of stateful objects"
:url "https://github.com/stuartsierra/component"
:license {:name "The MIT License"
:url "http://opensource.org/licenses/MIT"}
:min-lein-version "2.1.3" ; added :global-vars
:dependencies [[com.stuartsierra/dependency "0.1.1"]]
:global-vars {*warn-on-reflection* true}
:aliases {"test-all"
["with-profile" "clj1.4:clj1.5:clj1.6:clj1.7" "test"]}
:profiles {:dev {:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/tools.namespace "0.2.4"]]
:source-paths ["dev"]}
:clj1.7 {:dependencies [[org.clojure/clojure "1.7.0-master-SNAPSHOT"]]
:repositories {"sonatype-oss-public"
"https://oss.sonatype.org/content/groups/public"}}
:clj1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}
:clj1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]}
:clj1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]}})
| (defproject com.stuartsierra/component "0.2.3-SNAPSHOT"
:description "Managed lifecycle of stateful objects"
:url "https://github.com/stuartsierra/component"
:license {:name "The MIT License"
:url "http://opensource.org/licenses/MIT"}
:min-lein-version "2.1.3" ; added :global-vars
:dependencies [[com.stuartsierra/dependency "0.1.1"]]
:global-vars {*warn-on-reflection* true}
:aliases {"test-all"
["with-profile" "clj1.4:clj1.5:clj1.6:clj1.7" "test"]}
:profiles {:dev {:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/tools.namespace "0.2.4"]]
:source-paths ["dev"]}
:clj1.7 {:dependencies [[org.clojure/clojure "1.7.0-master-SNAPSHOT"]]
:repositories {"sonatype-oss-public"
"https://oss.sonatype.org/content/groups/public"}}
:clj1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}
:clj1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]}
:clj1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]}})
|
Set source and target javac to 1.6 | (defproject me.manuelp/confunion "0.1.1-SNAPSHOT"
:description "Library for managing configuration based on EDN files."
:url "http://github.com/manuelp/confunion"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:min-lein-version "2.0.0"
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/tools.logging "0.2.6"]]
:plugins [[lein-marginalia "0.7.1"]]
:source-paths ["src/clojure"]
:test-paths ["test/clojure"]
:java-source-paths ["src/java"]
:javac-options ["-target" "1.7"
"-source" "1.7"])
| (defproject me.manuelp/confunion "0.1.1"
:description "Library for managing configuration based on EDN files."
:url "http://github.com/manuelp/confunion"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:min-lein-version "2.0.0"
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/tools.logging "0.2.6"]]
:plugins [[lein-marginalia "0.7.1"]]
:source-paths ["src/clojure"]
:test-paths ["test/clojure"]
:java-source-paths ["src/java"]
:javac-options ["-target" "1.6"
"-source" "1.6"])
|
Update dependencies and version info and deploy to clojars. | ;(defproject cli4clj "1.2.5"
(defproject cli4clj "1.2.6-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.8.0"]
[clj-assorted-utils "1.15.0"]
[jline/jline "2.14.2"]]
: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.2.5"] [lein-html5-docs "3.0.3"]]
:profiles {:repl {:dependencies [[jonase/eastwood "0.2.3" :exclusions [org.clojure/clojure]]]}}
)
| (defproject cli4clj "1.2.6"
;(defproject cli4clj "1.2.6-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.8.0"]
[clj-assorted-utils "1.17.1"]
[jline/jline "2.14.2"]]
: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.2.5"] [lein-html5-docs "3.0.3"]]
:profiles {:repl {:dependencies [[jonase/eastwood "0.2.3" :exclusions [org.clojure/clojure]]]}}
)
|
Add ring-devel for reload win. | (defproject kiries "0.1.0-SNAPSHOT"
:description "A bundled deployment of Kibana, Riemann, and ElasticSearch"
:license "Eclipse Public License v1.0"
:dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/tools.cli "0.2.1"]
[clj-logging-config "1.9.6"]
[riemann "0.2.2"]
[clj-time "0.6.0"]
[clojurewerkz/elastisch "1.2.0"]
[org.elasticsearch/elasticsearch "0.90.3"]
[compojure "1.1.5"]
[hiccup "1.0.4"]
[org.markdownj/markdownj "0.3.0-1.0.2b4"]
[ring/ring-core "1.2.0"]
[ring/ring-jetty-adapter "1.2.0"]
[clojure-csv/clojure-csv "1.3.2"]
]
:resource-paths ["." "resources"]
:jar-exclusions [#"^htdocs"]
:main kiries.core
:aliases {"server" ["trampoline" "run" "-m" "kiries.core"]})
| (defproject kiries "0.1.0-SNAPSHOT"
:description "A bundled deployment of Kibana, Riemann, and ElasticSearch"
:license "Eclipse Public License v1.0"
:dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/tools.cli "0.2.1"]
[clj-logging-config "1.9.6"]
[riemann "0.2.2"]
[clj-time "0.6.0"]
[clojurewerkz/elastisch "1.2.0"]
[org.elasticsearch/elasticsearch "0.90.3"]
[compojure "1.1.5"]
[hiccup "1.0.4"]
[org.markdownj/markdownj "0.3.0-1.0.2b4"]
[ring/ring-core "1.2.0"]
[ring/ring-devel "1.2.0"]
[ring/ring-jetty-adapter "1.2.0"]
[clojure-csv/clojure-csv "1.3.2"]
]
:resource-paths ["." "resources"]
:jar-exclusions [#"^htdocs"]
:main kiries.core
:aliases {"server" ["trampoline" "run" "-m" "kiries.core"]})
|
Revert back to snapshot version. | (defproject cli4clj "1.5.2"
;(defproject cli4clj "1.5.3-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.9.0"]
[clj-assorted-utils "1.18.2"]
[org.clojure/core.async "0.4.474"]
[jline/jline "2.14.6"]]
: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.3.3"] [lein-html5-docs "3.0.3"]]
:profiles {:repl {:dependencies [[jonase/eastwood "0.2.6" :exclusions [org.clojure/clojure]]]}}
)
| ;(defproject cli4clj "1.5.2"
(defproject cli4clj "1.5.3-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.9.0"]
[clj-assorted-utils "1.18.2"]
[org.clojure/core.async "0.4.474"]
[jline/jline "2.14.6"]]
: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.3.3"] [lein-html5-docs "3.0.3"]]
:profiles {:repl {:dependencies [[jonase/eastwood "0.2.6" :exclusions [org.clojure/clojure]]]}}
)
|
Prepare for next release cycle. | (defproject onyx-app/lein-template "0.10.0.0-alpha6"
: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)
|
Drop all tables only within the test database. | (ns time-tracker.fixtures
(:require [clojure.java.jdbc :as jdbc]
[time-tracker.migration :refer [migrate-db]]
[time-tracker.db :as db]
[time-tracker.core :refer [app]]
[time-tracker.auth.core :as auth]
[time-tracker.auth.test-helpers :refer [fake-token->credentials]]
[environ.core :as environ]
[time-tracker.config :as config])
(:use org.httpkit.server))
(defn init! [f]
(time-tracker.core/init!)
(f))
(defn destroy-db []
(jdbc/execute! config/db-spec [(str "DROP OWNED BY " (environ/env :test-db-username))]))
(defn migrate-test-db [f]
(migrate-db)
(f)
(destroy-db))
(defn serve-app [f]
(with-redefs [auth/token->credentials
fake-token->credentials]
(let [stop-fn (run-server app {:port 8000})]
(f)
(stop-fn :timeout 100))))
(defn isolate-db [f]
(jdbc/with-db-transaction [conn (db/connection)]
(jdbc/db-set-rollback-only! conn)
(with-redefs [db/connection (fn [] conn)]
(f))))
| (ns time-tracker.fixtures
(:require [clojure.java.jdbc :as jdbc]
[time-tracker.migration :refer [migrate-db]]
[time-tracker.db :as db]
[time-tracker.core :refer [app]]
[time-tracker.auth.core :as auth]
[time-tracker.auth.test-helpers :refer [fake-token->credentials]]
[environ.core :as environ]
[time-tracker.config :as config])
(:use org.httpkit.server))
(defn init! [f]
(time-tracker.core/init!)
(f))
(defn destroy-db []
(jdbc/with-db-transaction [conn (db/connection)]
(jdbc/execute! conn "DROP SCHEMA IF EXISTS public CASCADE;")
(jdbc/execute! conn "CREATE SCHEMA IF NOT EXISTS public;")))
(defn migrate-test-db [f]
(migrate-db)
(f)
(destroy-db))
(defn serve-app [f]
(with-redefs [auth/token->credentials
fake-token->credentials]
(let [stop-fn (run-server app {:port 8000})]
(f)
(stop-fn :timeout 100))))
(defn isolate-db [f]
(jdbc/with-db-transaction [conn (db/connection)]
(jdbc/db-set-rollback-only! conn)
(with-redefs [db/connection (fn [] conn)]
(f))))
|
Make layouts use strings by calling name. | (ns incise.layouts.core
(:refer-clojure :exclude [get]))
(def layouts (atom {}))
(defn exists?
"Check for the existance of a layout with the given name."
[layout-with-name]
(contains? @layouts layout-with-name))
(defn get [& args]
(apply clojure.core/get @layouts args))
(defn register
"Register a layout function to a shortname"
[short-name layout-fn]
(swap! layouts
assoc (str short-name) layout-fn))
| (ns incise.layouts.core
(:refer-clojure :exclude [get]))
(def layouts (atom {}))
(defn exists?
"Check for the existance of a layout with the given name."
[layout-with-name]
(contains? @layouts (name layout-with-name)))
(defn get [layout-name]
(@layouts (name layout-name)))
(defn register
"Register a layout function to a shortname"
[short-name layout-fn]
(swap! layouts
assoc (name short-name) layout-fn))
|
Use ligher theme from Kibana for docs. | (ns kiries.layout
(:use hiccup.core)
(:use hiccup.page))
(defn full-layout [title & content]
(html5
[:head
(include-css "/kibana/common/css/bootstrap.dark.min.css")
(include-css "/kibana/common/css/bootstrap-responsive.min.css")
(include-css "/kibana/common/css/font-awesome.min.css")
[:title title]]
[:body
[:div.container-fluid.main
[:div.row-fluid
content]]]))
| (ns kiries.layout
(:use hiccup.core)
(:use hiccup.page))
(defn full-layout [title & content]
(html5
[:head
(include-css "/kibana/common/css/bootstrap.light.min.css")
(include-css "/kibana/common/css/bootstrap-responsive.min.css")
(include-css "/kibana/common/css/font-awesome.min.css")
[:title title]]
[:body
[:div.container-fluid.main
[:div.row-fluid
content]]]))
|
Prepare for next release cycle. | (defproject onyx-app/lein-template "0.12.0.0-rc2"
: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.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)
|
Add copper clip search test. | (ns haystack.search-test
(:require [haystack.search :as sut :refer [search]]
;; [clojure.test :as t :refer :all]
[haystack.helpers :refer :all]
))
(test-search
matnrs-check
{:search "2843977 2542450"}
(max-docs 50)
(in-top 2843977 2)
(in-top 2542450 2)
)
(test-search
upcs-check
{:search "078477045442 980100350109"}
(max-docs 500)
(in-top 199152 2)
(in-top 2542450 2)
)
| (ns haystack.search-test
(:require [haystack.search :as sut :refer [search]]
;; [clojure.test :as t :refer :all]
[haystack.helpers :refer :all]
))
(test-search
matnrs-check
{:search "2843977 2542450"}
(max-docs 50)
(in-top 2843977 2)
(in-top 2542450 2)
)
(test-search
upcs-check
{:search "078477045442 980100350109"}
(max-docs 500)
(in-top 199152 2)
(in-top 2542450 2)
)
(test-search
copper-clip-check
{:search "copper clip" :num-per-page 100}
(max-docs 100)
(in-top 20127 100) ;; "copper" and "clip" not in the same field
(in-top 3336524 100) ;; "clip" is in the part number
)
|
Check msg meta to determine sendmail or SMTP. | (ns com.draines.postal.core
(:use [com.draines.postal.sendmail :only [sendmail-send]]
[com.draines.postal.smtp :only [smtp-send]]))
(defn send-message [msg]
(when-not (and (:from msg)
(:to msg)
(:subject msg)
(:body msg))
(throw (Exception. "message needs at least :from, :to, :subject, and :body")))
(if (:host msg)
(smtp-send msg)
(sendmail-send msg)))
| (ns com.draines.postal.core
(:use [com.draines.postal.sendmail :only [sendmail-send]]
[com.draines.postal.smtp :only [smtp-send]]))
(defn send-message [msg]
(when-not (and (:from msg)
(:to msg)
(:subject msg)
(:body msg))
(throw (Exception. "message needs at least :from, :to, :subject, and :body")))
(if (:host ^msg)
(smtp-send msg)
(sendmail-send msg)))
|
Fix coming to search page via link not setting bar text | (ns braid.search.ui.search-bar
(:require
[reagent.core :as r]
[re-frame.core :refer [subscribe dispatch]]
[braid.core.client.routes :as routes]
[braid.lib.color :as color]))
(defn search-bar-view
[]
(r/with-let [search-query (r/atom @(subscribe [:braid.search/query]))
prev-page (r/atom (:type @(subscribe [:page])))]
(let [current-page (:type @(subscribe [:page]))]
(when (not= @prev-page current-page)
(when (= @prev-page :search)
(reset! search-query ""))
(reset! prev-page current-page)))
[:div.search-bar
[:input {:type "text"
:placeholder "Search..."
:value @search-query
:on-change
(fn [e]
(reset! search-query (.. e -target -value))
(dispatch [:braid.search/update-query! (.. e -target -value)]))}]
(if (and @search-query (not= "" @search-query))
[:a.action.clear
{:on-click (fn [] (reset! search-query ""))
:href (routes/group-page-path {:group-id @(subscribe [:open-group-id])
:page-id "inbox"})
:style {:color (color/->color @(subscribe [:open-group-id]))}}]
[:div.action.search])]))
| (ns braid.search.ui.search-bar
(:require
[reagent.core :as r]
[re-frame.core :refer [subscribe dispatch]]
[braid.core.client.routes :as routes]
[braid.lib.color :as color]))
(defn search-bar-view
[]
(r/with-let [search-query (r/atom @(subscribe [:braid.search/query]))
prev-page (r/atom (:type @(subscribe [:page])))]
(let [current-page (:type @(subscribe [:page]))]
(when (not= @prev-page current-page)
(if (= @prev-page :search)
(reset! search-query "")
(reset! search-query @(subscribe [:braid.search/query])))
(reset! prev-page current-page)))
[:div.search-bar
[:input {:type "text"
:placeholder "Search..."
:value @search-query
:on-change
(fn [e]
(reset! search-query (.. e -target -value))
(dispatch [:braid.search/update-query! (.. e -target -value)]))}]
(if (and @search-query (not= "" @search-query))
[:a.action.clear
{:on-click (fn [] (reset! search-query ""))
:href (routes/group-page-path {:group-id @(subscribe [:open-group-id])
:page-id "inbox"})
:style {:color (color/->color @(subscribe [:open-group-id]))}}]
[:div.action.search])]))
|
Prepare for next release cycle. | (defproject onyx-app/lein-template "0.9.9.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.9.9.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)
|
Update PostgreSQL JDBC library dependency | (defproject ktra-indexer "0.1.0-SNAPSHOT"
:description "A simple application for indexing and searching KTRA track
listings"
:url "https://github.com/terop/ktra-indexer"
:min-lein-version "2.0.0"
:dependencies [[org.clojure/clojure "1.8.0"]
[compojure "1.5.1"]
[ring/ring-defaults "0.2.1"]
[ring/ring-devel "1.5.0"]
[org.immutant/web "2.1.5"]
[selmer "1.0.7"]
[cheshire "5.6.3"]
[org.postgresql/postgresql "9.4.1207"]
[org.clojure/java.jdbc "0.6.1"]
[honeysql "0.7.0"]
[clj-time "0.12.0"]
[buddy/buddy-auth "1.1.0"]
[com.yubico/yubico-validation-client2 "3.0.1"]
[org.apache.commons/commons-lang3 "3.4"]]
:main ktra-indexer.handler
:aot [ktra-indexer.handler]
:plugins [[lein-environ "1.0.3"]]
:profiles
{:dev {:dependencies [[ring/ring-mock "0.3.0"]]
:resource-paths ["resources"]
:env {:squiggly {:checkers [:eastwood :kibit :typed]}}}})
| (defproject ktra-indexer "0.1.0-SNAPSHOT"
:description "A simple application for indexing and searching KTRA track
listings"
:url "https://github.com/terop/ktra-indexer"
:min-lein-version "2.0.0"
:dependencies [[org.clojure/clojure "1.8.0"]
[compojure "1.5.1"]
[ring/ring-defaults "0.2.1"]
[ring/ring-devel "1.5.0"]
[org.immutant/web "2.1.5"]
[selmer "1.0.7"]
[cheshire "5.6.3"]
[org.postgresql/postgresql "9.4.1209"]
[org.clojure/java.jdbc "0.6.1"]
[honeysql "0.7.0"]
[clj-time "0.12.0"]
[buddy/buddy-auth "1.1.0"]
[com.yubico/yubico-validation-client2 "3.0.1"]
[org.apache.commons/commons-lang3 "3.4"]]
:main ktra-indexer.handler
:aot [ktra-indexer.handler]
:plugins [[lein-environ "1.0.3"]]
:profiles
{:dev {:dependencies [[ring/ring-mock "0.3.0"]]
:resource-paths ["resources"]
:env {:squiggly {:checkers [:eastwood :kibit :typed]}}}})
|
Change core.cache version to 0.6.1. | (defproject stencil "0.3.0-SNAPSHOT"
:description "Mustache in Clojure"
:dependencies [[org.clojure/clojure "1.3.0"]
[scout "0.1.0"]
[slingshot "0.8.0"]
[org.clojure/core.cache "0.5.0"]]
:profiles {:dev {:dependencies [[org.clojure/data.json "0.1.2"]]}
:clj1.2 {:dependencies [[org.clojure/clojure "1.2.1"]]}
:clj1.3 {:dependencies [[org.clojure/clojure "1.3.0"]]}
:clj1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]}}
:extra-files-to-clean ["test/spec"]) | (defproject stencil "0.3.0-SNAPSHOT"
:description "Mustache in Clojure"
:dependencies [[org.clojure/clojure "1.3.0"]
[scout "0.1.0"]
[slingshot "0.8.0"]
[org.clojure/core.cache "0.6.1"]]
:profiles {:dev {:dependencies [[org.clojure/data.json "0.1.2"]]}
:clj1.2 {:dependencies [[org.clojure/clojure "1.2.1"]]}
:clj1.3 {:dependencies [[org.clojure/clojure "1.3.0"]]}
:clj1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]}}
:extra-files-to-clean ["test/spec"]) |
Set development version to 0.1.5-SNAPSHOT | (defproject io.aviso/rook "0.1.4"
:description "Ruby on Rails-style resource mapping for Clojure/Compojure web apps"
:url "https://github.com/AvisoNovate/rook"
:license {:name "Apache Sofware Licencse 2.0"
:url "http://www.apache.org/licenses/LICENSE-2.0.html"}
;; Normally we don't AOT compile; only when tracking down reflection warnings.
:profiles {:reflection-warnings {:aot :all
:global-vars {*warn-on-reflection* true}}
:dev {:dependencies [[ring-mock "0.1.5"]]}}
:dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/tools.logging "0.2.6"]
[compojure "1.1.6"]]
:plugins [[test2junit "1.0.1"]])
| (defproject io.aviso/rook "0.1.5-SNAPSHOT"
:description "Ruby on Rails-style resource mapping for Clojure/Compojure web apps"
:url "https://github.com/AvisoNovate/rook"
:license {:name "Apache Sofware Licencse 2.0"
:url "http://www.apache.org/licenses/LICENSE-2.0.html"}
;; Normally we don't AOT compile; only when tracking down reflection warnings.
:profiles {:reflection-warnings {:aot :all
:global-vars {*warn-on-reflection* true}}
:dev {:dependencies [[ring-mock "0.1.5"]]}}
:dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/tools.logging "0.2.6"]
[compojure "1.1.6"]]
:plugins [[test2junit "1.0.1"]])
|
Prepare for next development iteration (0.1.3-SNAPSHOT) | (defproject cljam "0.1.2"
:description "A DNA Sequence Alignment/Map (SAM) library for Clojure"
:url "https://chrovis.github.io/cljam"
:license {:name "Apache License, Version 2.0"
:url "http://www.apache.org/licenses/LICENSE-2.0.html"}
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/tools.logging "0.2.6"]
[org.clojure/tools.cli "0.3.1"]
[me.raynes/fs "1.4.5"]
[pandect "0.3.2"]
[clj-sub-command "0.2.0"]
[bgzf4j "0.1.0"]]
:plugins [[lein-midje "3.1.3"]
[lein-bin "0.3.4"]
[lein-marginalia "0.7.1"]]
:profiles {:dev {:dependencies [[midje "1.6.3"]
[criterium "0.4.3"]
[cavia "0.1.2"]
[primitive-math "0.1.3"]]
:global-vars {*warn-on-reflection* true}}}
:main cljam.main
:aot [cljam.main]
:bin {:name "cljam"}
:repl-options {:init-ns user})
| (defproject cljam "0.1.3-SNAPSHOT"
:description "A DNA Sequence Alignment/Map (SAM) library for Clojure"
:url "https://chrovis.github.io/cljam"
:license {:name "Apache License, Version 2.0"
:url "http://www.apache.org/licenses/LICENSE-2.0.html"}
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/tools.logging "0.2.6"]
[org.clojure/tools.cli "0.3.1"]
[me.raynes/fs "1.4.5"]
[pandect "0.3.2"]
[clj-sub-command "0.2.0"]
[bgzf4j "0.1.0"]]
:plugins [[lein-midje "3.1.3"]
[lein-bin "0.3.4"]
[lein-marginalia "0.7.1"]]
:profiles {:dev {:dependencies [[midje "1.6.3"]
[criterium "0.4.3"]
[cavia "0.1.2"]
[primitive-math "0.1.3"]]
:global-vars {*warn-on-reflection* true}}}
:main cljam.main
:aot [cljam.main]
:bin {:name "cljam"}
:repl-options {:init-ns user})
|
Fix "checkout-dir handles spaces" test by checking what is being tested better. | (ns circle.backend.test-build
(:use midje.sweet)
(:use [circle.backend.build.test-utils :only (minimal-build)])
(:use circle.model.build))
(fact "checkout-dir handles spaces"
(let [b (minimal-build :build_num 42)]
(checkout-dir b) => "Dummy-Project-42"))
(fact "ensure-project-id works"
(let [b (minimal-build)]
@b => (contains {:_project_id truthy}))) | (ns circle.backend.test-build
(:use midje.sweet)
(:use [circle.backend.build.test-utils :only (minimal-build)])
(:use circle.model.build))
(fact "checkout-dir handles spaces"
(let [b (minimal-build)]
(checkout-dir b) => #"Dummy-Project-\d+"))
(fact "ensure-project-id works"
(let [b (minimal-build)]
@b => (contains {:_project_id truthy}))) |
Fix result in is test |
(println "Map Function Tests")
(is (= (map inc [1 2 3]) [2 3 4]))
|
(println "Map Function Tests")
(is (= (map inc [1 2 3]) '(2 3 4)))
|
Add tests for replication behavior. | (ns blocks.store.replica-test
(:require
(blocks.store
[memory :refer [memory-store]]
[replica :refer [replica-store]]
[tests :refer [test-block-store]])
[clojure.test :refer :all]))
; TODO: test that writes actually populate all backing stores.
; TODO: test that removing blocks from one store still returns all blocks.
; TODO: test that listing provides merged block list.
(deftest ^:integration test-replica-store
(let [store (replica-store [(memory-store) (memory-store)])]
(test-block-store
"replica-store" store
:max-size 1024
:blocks 25)))
| (ns blocks.store.replica-test
(:require
[blocks.core :as block]
(blocks.store
[memory :refer [memory-store]]
[replica :refer [replica-store]]
[tests :refer [test-block-store]])
[clojure.test :refer :all]))
(deftest replica-behavior
(let [replica-1 (memory-store)
replica-2 (memory-store)
store (replica-store [replica-1 replica-2])
a (block/read! "foo bar baz")
b (block/read! "abracadabra")
c (block/read! "123 xyz")]
(block/put! store a)
(block/put! store b)
(block/put! store c)
(is (= 3 (count (block/list replica-1))))
(is (every? (partial block/get replica-1)
(map :id [a b c]))
"all blocks are stored in replica-1")
(is (= 3 (count (block/list replica-2))))
(is (every? (partial block/get replica-2)
(map :id [a b c]))
"all blocks are stored in replica-2")
(is (= 3 (count (block/list store))))
(block/delete! replica-1 (:id a))
(block/delete! replica-2 (:id c))
(is (= 3 (count (block/list store)))
"replica lists all available blocks")))
(deftest ^:integration test-replica-store
(let [store (replica-store [(memory-store) (memory-store)])]
(test-block-store
"replica-store" store
:max-size 1024
:blocks 25)))
|
Fix up one bar sequencer | (ns example.one-bar-sequencer
(:use overtone.live))
(def metro (metronome 128))
; Our bar is a map of beat to instruments to play
(def bar {0 [kick]
0.5 [c-hat]
1 [kick snare]
1.5 [c-hat]
2 [kick]
2.5 [c-hat]
3 [kick snare]
3.5 [c-hat]})
; For every tick of the metronome, we loop through all our beats
; and find the apropriate one my taking the metronome tick mod 4.
; Then we play all the instruments for that beat.
(defn player
[tick]
(dorun
(for [k (keys bar)]
(let [beat (Math/floor k)
offset (- k beat)]
(if (= 0 (mod (- tick beat) 4))
(let [instruments (bar k)]
(dorun
(for [instrument instruments]
(at (metro (+ offset tick)) (instrument))))))))))
| (ns example.one-bar-sequencer
(:use [overtone.live]
[overtone.inst drum]))
(def metro (metronome 128))
; Our bar is a map of beat to instruments to play
(def bar {0 [kick]
0.5 [c-hat]
1 [kick snare]
1.5 [c-hat]
2 [kick]
2.5 [c-hat]
3 [kick snare]
3.5 [c-hat]})
; For every tick of the metronome, we loop through all our beats
; and find the apropriate one my taking the metronome tick mod 4.
; Then we play all the instruments for that beat.
(defn player
[tick]
(dorun
(for [k (keys bar)]
(let [beat (Math/floor k)
offset (- k beat)]
(if (= 0 (mod (- tick beat) 4))
(let [instruments (bar k)]
(dorun
(for [instrument instruments]
(at (metro (+ offset tick)) (instrument))))))))))
;; define a run fn which will call our player fn for each beat and will schedule
;; itself to be called just before the next beat
(defn run
[m]
(let [beat (m)]
(player beat)
(apply-at (m (inc beat)) #'run [m])))
;; make beats!
(run metro)
;; stop
(stop)
|
Add debug-form macro, which expands and pretty-prints an unevaluated form. | ; Copyright 2009 Howard M. Lewis Ship
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
; implied. See the License for the specific language governing permissions
; and limitations under the License.
(ns cascade.utils)
(defmacro lcond
"A reimplementation of Clojure's cond, with the addition of a special :let
keyword that injects an implicit let into the logic."
[& clauses]
(when clauses
(if (= 1 (count clauses))
(throw (IllegalArgumentException. "lcond requires an even number of forms")))
(let
[tst (first clauses)
expr (second clauses)
rst (next (next clauses))]
(if (= tst :let)
`(let [~@expr] (lcond ~@rst))
`(if ~tst ~expr (lcond ~@rst))))))
| ; Copyright 2009 Howard M. Lewis Ship
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
; implied. See the License for the specific language governing permissions
; and limitations under the License.
(ns cascade.utils
(:use
(clojure.contrib pprint macro-utils)))
(defmacro lcond
"A reimplementation of Clojure's cond, with the addition of a special :let
keyword that injects an implicit let into the logic."
[& clauses]
(when clauses
(if (= 1 (count clauses))
(throw (IllegalArgumentException. "lcond requires an even number of forms")))
(let
[tst (first clauses)
expr (second clauses)
rst (next (next clauses))]
(if (= tst :let)
`(let [~@expr] (lcond ~@rst))
`(if ~tst ~expr (lcond ~@rst))))))
(defmacro debug-form
"Expands all macros in a form, recursively, and prints the result. Returns nil."
[form]
`(pprint (mexpand-all '~form)))
|
Simplify so that we do not need to map the ns-resolve methods. | ;; This is usefull to display the functions, ask the user for the
;; input parameters, and then execute them, presenting the result to
;; the user.
;; Intended to expose the functions in a Browser, but it could be
;; anything else: command line, rich client, ...
;;
(ns fnx.meta.expose
"Get the public functions of a namespace"
(:use [midje.sweet]))
;;
;; * First we load the ns with `require`
;; * Then we get the public functions (read from bottom to top):
;; * We want only functions, not the other vars: We can spot them because they have an `:arglists` in their meta.
;; * Don't really know why, but we need to `ns-resolve` the symbols(?)
;; * Get the public vars with `ns-publics`
;;
(defn ns-public-fn
"Given a ns symbol, returns all the public fns of this ns."
[ns] (do (require ns)
(filter #(:arglists (meta %))
(map #(ns-resolve ns %)
(keys (ns-publics (find-ns ns)))))))
(fact "ns-public-fn"
(second (ns-public-fn 'fnx.meta.example)) => (resolve 'fnx.meta.example/hello-noir))
(fact "ns-public-fn: listing functions and calling them (it's more an example of usage than a true test)"
(map (fn [f] (apply f
(range 0 (count (first (:arglists (meta f)))))))
(ns-public-fn 'fnx.meta.example)) => ["arg=0", "Hello noir" "args=0,1"])
| ;; This is usefull to display the functions, ask the user for the
;; input parameters, and then execute them, presenting the result to
;; the user.
;; Intended to expose the functions in a Browser, but it could be
;; anything else: command line, rich client, ...
;;
(ns fnx.meta.expose
"Get the public functions of a namespace"
(:use [midje.sweet]))
;;
;; * First we load the ns with `require`
;; * Then we get the public functions (read from bottom to top):
;; * We want only functions, not the other vars: We can spot them because they have an `:arglists` in their meta.
;; * Get the public vars with `ns-publics`
;;
(defn ns-public-fn
"Given a ns symbol, returns all the public fns of this ns."
[ns] (do (require ns)
(filter #(:arglists (meta %))
(vals (ns-publics (find-ns ns))))))
(fact "ns-public-fn"
(second (ns-public-fn 'fnx.meta.example)) => (resolve 'fnx.meta.example/hello-noir))
(fact "ns-public-fn: listing functions and calling them (it's more an example of usage than a true test)"
(map (fn [f] (apply f
(range 0 (count (first (:arglists (meta f)))))))
(ns-public-fn 'fnx.meta.example)) => ["arg=0", "Hello noir" "args=0,1"])
|
Make sure it warns when running production-mode code. | (ns vinculum.main
(:require [vinculum.core :as core]))
(core/main)
| (ns vinculum.main
(:require [vinculum.core :as core]))
(js/console.log "Starting production mode CLJS!")
(core/main)
|
Add repl restart function helper. | (ns pfrt.main
(:require [pfrt.pf :refer [packet-filter]]
[pfrt.web :refer [web-server]]
[pfrt.core.app :as app]
[pfrt.settings :as settings])
(:gen-class))
;; Global var, only used for store
;; a global app instance when this is
;; used from REPL.
(def main-app nil)
;; System private constructor with
;; clear and explicit dependency injection
;; on each app components.
(defn- make-app []
(let [config (settings/cfg)
pf (packet-filter config)
webserver (web-server config pf)]
(-> (app/->App [pf webserver])
(assoc :config config)
(app/init))))
;; Start function that should
;; only be used from REPL.
(defn start []
(alter-var-root #'main-app
(constantly (make-app)))
(start main-app))
;; Stop function that should
;; only be used from REPL.
(defn stop []
(app/stop main-app))
;; Main entry point
(defn -main
[& args]
(let [app-instance (make-app)]
(app/start app-instance)
(println "Application started.")))
| (ns pfrt.main
(:require [pfrt.pf :refer [packet-filter]]
[pfrt.web :refer [web-server]]
[pfrt.core.app :as app]
[pfrt.settings :as settings])
(:gen-class))
;; Global var, only used for store
;; a global app instance when this is
;; used from REPL.
(def main-app nil)
;; System private constructor with
;; clear and explicit dependency injection
;; on each app components.
(defn- make-app []
(let [config (settings/cfg)
pf (packet-filter config)
webserver (web-server config pf)]
(-> (app/->App [pf webserver])
(assoc :config config)
(app/init))))
;; Start function that should
;; only be used from REPL.
(defn start []
(alter-var-root #'main-app
(constantly (make-app)))
(start main-app))
;; Stop function that should
;; only be used from REPL.
(defn stop []
(app/stop main-app))
;; Helper function that executes
;; stop and start.
(defn restart []
(start)
(stop))
;; Main entry point
(defn -main
[& args]
(let [app-instance (make-app)]
(app/start app-instance)
(println "Application started.")))
|
Rename to header and footer | (ns cglossa.core
(:require [reagent.core :as reagent :refer [atom]]
[plumbing.core :as plumbing :refer [map-vals]]
[cglossa.centre :as centre]))
(def state {:showing-results false})
(def data {:categories ["ku" "hest"]
:users ["per" "kari"]})
(defonce app-state (into {} (map-vals atom state)))
(defonce app-data (into {} (map-vals atom data)))
(defn navbar []
[:div.navbar.navbar-fixed-top [:div.navbar-inner [:div.container [:span.brand "Glossa"]]]])
(defn bottom [_ {:keys [categories]}]
[:div (for [cat @categories]
[:div cat])])
(defn app [s d]
[:div
[navbar]
[:div.container-fluid
[centre/top s d]]
[bottom s d]])
(defn ^:export main []
(reagent/render-component
(fn []
[app app-state app-data])
(. js/document (getElementById "app"))))
| (ns cglossa.core
(:require [reagent.core :as reagent :refer [atom]]
[plumbing.core :as plumbing :refer [map-vals]]
[cglossa.centre :as centre]))
(def state {:showing-results false})
(def data {:categories ["ku" "hest"]
:users ["per" "kari"]})
(defonce app-state (into {} (map-vals atom state)))
(defonce app-data (into {} (map-vals atom data)))
(defn header []
[:div.navbar.navbar-fixed-top [:div.navbar-inner [:div.container [:span.brand "Glossa"]]]])
(defn footer [_ {:keys [categories]}]
[:div (for [cat @categories]
[:div cat])])
(defn app [s d]
[:div
[header]
[:div.container-fluid
[centre/top s d]
[centre/bottom s d]]
[footer s d]])
(defn ^:export main []
(reagent/render-component
(fn []
[app app-state app-data])
(. js/document (getElementById "app"))))
|
Allow enabling/disabling of logger in running app | (ns ^{:doc "When this library is loaded, create a logger named
'events' and send all application-specific events to it.
To view log messages in the browser console, add a call
to `(log/console-output)` to this namespace or evaluate this from the
REPL.
For more information see library.logging."}
one.repmax.logging
(:require [one.dispatch :as dispatch]
[one.logging :as log]))
(def ^{:doc "The logger that receives all application-specific events."}
logger (log/get-logger "events"))
(dispatch/react-to (constantly true)
(fn [t d] (log/info logger (str (pr-str t) " - " (pr-str d)))))
;; log to the console
(log/start-display (log/console-output))
| (ns ^{:doc "When this library is loaded, create a logger named 'events'.
See comments at end of file for example usage.
For more information see one.logging."}
one.repmax.logging
(:require [one.dispatch :as dispatch]
[one.logging :as log]))
(def ^{:doc "The logger that receives all application-specific events."}
logger (log/get-logger "events"))
(defn log!
"Create a new reaction that will react to ALL events and log them to the
given logger.
WARNING: For events that have a large amount of data (which is the case for
most :model-change events in One Rep Max), sending these events to the logger
has a significant negative performance impact on the application. You are
recommended to log events ONLY For debugging purposes."
[logger]
(dispatch/react-to (constantly true)
(fn [t d] (log/info logger (str (pr-str t) " - " (pr-str d))))))
(comment
;; register a reaction that will react to ALL events and log them to the 'events' logger
(def logging-reaction (log! logger))
;; send the the log output to the console
(log/start-display (log/console-output))
;; stop logging events
(dispatch/delete-reaction logging-reaction)
;; change the logging level
(log/set-level logger :fine)
)
|
Update Jetty dependency to 9.4.38 | (defproject ring/ring-jetty-adapter "1.9.1"
: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.9.1"]
[ring/ring-servlet "1.9.1"]
[org.eclipse.jetty/jetty-server "9.4.36.v20210114"]]
:aliases {"test-all" ["with-profile" "default:+1.8:+1.9:+1.10" "test"]}
:profiles
{:dev {:dependencies [[clj-http "3.10.0"]
[less-awful-ssl "1.0.6"]]
: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"]]}
:1.10 {:dependencies [[org.clojure/clojure "1.10.2"]]}})
| (defproject ring/ring-jetty-adapter "1.9.1"
: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.9.1"]
[ring/ring-servlet "1.9.1"]
[org.eclipse.jetty/jetty-server "9.4.38.v20210224"]]
:aliases {"test-all" ["with-profile" "default:+1.8:+1.9:+1.10" "test"]}
:profiles
{:dev {:dependencies [[clj-http "3.10.0"]
[less-awful-ssl "1.0.6"]]
: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"]]}
:1.10 {:dependencies [[org.clojure/clojure "1.10.2"]]}})
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.