Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Change string variable name to not conflict with core function.
(ns cljs-nlp.tokenize.simple (:use [clojure.string :only [split]])) (defn space-tokenizer [str] (split str #"[ ]")) (defn tab-tokenizer [str] (split str #"\t")) (defn whitespace-tokenizer [str] (split str #"\s+")) (defn blankline-tokenizer [str] (split str #"\s*\n\s*\n\s*")) (defn char-tokenizer [str] (vec (seq str))) (defn line-tokenizer [str] (split str #"\n"))
(ns cljs-nlp.tokenize.simple (:use [clojure.string :only [split]])) (defn space-tokenizer [s] (split s #"[ ]")) (defn tab-tokenizer [s] (split s #"\t")) (defn whitespace-tokenizer [s] (split s #"\s+")) (defn blankline-tokenizer [s] (split s #"\s*\n\s*\n\s*")) (defn char-tokenizer [s] (vec (seq s))) (defn line-tokenizer [s] (split s #"\n"))
Change version back to snapshot
;; The Climate Corporation licenses this file to you under 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 ;; ;; See the NOTICE file distributed with this work for additional information ;; regarding copyright ownership. 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. (defproject com.climate/claypoole "1.1.1" :description "Claypoole: Threadpool tools for Clojure." :url "http://github.com/TheClimateCorporation/claypoole/" :license {:name "Apache License Version 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0" :distribution :repo} :min-lein-version "2.0.0" :source-paths ["src/clj"] :java-source-paths ["src/java"] :pedantic? :warn :profiles {:dev {:dependencies [[org.clojure/clojure "1.8.0"]]}} :plugins [[jonase/eastwood "0.2.3"] [lein-ancient "0.6.8"]])
;; The Climate Corporation licenses this file to you under 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 ;; ;; See the NOTICE file distributed with this work for additional information ;; regarding copyright ownership. 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. (defproject com.climate/claypoole "1.1.1-SNAPSHOT" :description "Claypoole: Threadpool tools for Clojure." :url "http://github.com/TheClimateCorporation/claypoole/" :license {:name "Apache License Version 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0" :distribution :repo} :min-lein-version "2.0.0" :source-paths ["src/clj"] :java-source-paths ["src/java"] :pedantic? :warn :profiles {:dev {:dependencies [[org.clojure/clojure "1.8.0"]]}} :plugins [[jonase/eastwood "0.2.3"] [lein-ancient "0.6.8"]])
Add Up Link to Error Representation
(ns lens.middleware.wan-exception (:require [clj-stacktrace.repl :refer [pst-on]])) (defn wrap-exception "Calls the handler in a try catch block returning a WAN error response." [handler] (fn [request] (try (handler request) (catch Throwable e (pst-on *err* false e) {:status 500 :body {:error (.getMessage e)}}))))
(ns lens.middleware.wan-exception (:require [clj-stacktrace.repl :refer [pst-on]])) (defn wrap-exception "Calls the handler in a try catch block returning a WAN error response." [handler] (fn [request] (try (handler request) (catch Throwable e (pst-on *err* false e) {:status 500 :body {:links {:up {:href "/"}} :error (.getMessage e)}}))))
Update test. Still have far too few...
(ns afterglow.effects.color-test (:require [clojure.test :refer :all] [afterglow.effects.color :refer :all] [afterglow.channels :as channels] [com.evocomputing.colors :as colors] [afterglow.fixtures.chauvet :as chauvet] [taoensso.timbre :as timbre :refer [error warn info debug spy]])) (deftest test-extract-rgb (testing "Finding RGB color channels") (is (= [2 3 4] (map :offset (#'afterglow.effects.color/extract-rgb [(chauvet/slimpar-hex3-irc)])))))
(ns afterglow.effects.color-test (:require [clojure.test :refer :all] [afterglow.effects.color :refer :all] [afterglow.channels :as channels] [com.evocomputing.colors :as colors] [afterglow.fixtures.chauvet :as chauvet] [taoensso.timbre :as timbre :refer [error warn info debug spy]])) (deftest test-extract-rgb (testing "Finding RGB color channels") (is (= [:12-channel-mix-uv] (map :mode (#'afterglow.effects.color/find-rgb-heads [(chauvet/slimpar-hex3-irc)])))))
Add simple pattern matching. Matchure and more complex matching weren't cutting it.
(ns proto.main (:require [clojure.contrib.io :as io]) (:require [clj-yaml.core :as yaml]) ) (defn init [& argv] (-> argv first io/reader slurp yaml/parse-string println)) (defn -main [& argv] (init *command-line-args*))
(ns proto.main (:require [clojure.contrib.io :as io]) (:require [clojure.contrib.generic.functor :as functor]) (:require [clj-yaml.core :as yaml])) (declare autotools-handler) (def handlers '(autotools-handler)) (defn run-handlers "Run all the handlers on a definition" [config] (map #(% config) handlers)) (defn process-handlers "For each project definition, run all the handlers on it" [configurations] (functor/fmap run-handlers configurations)) (defn autotools-handler [{type :type subdir :subdir configurations :configurations autoconf-version :autoconf-version}] (when (= type "autotools") "print autotools")) (defn init [& argv] (-> argv first io/reader slurp yaml/parse-string process-handlers)) (defn -main [& argv] (init *command-line-args*))
Send message when enter is pressed
(ns chatapp.view (:require [re-frame.core :as re-frame])) (defn message [message] [:li {:class "list-group-item"} (:message message)]) (defn message-list [] (let [messages (re-frame/subscribe [:messages])] (fn [] [:div {:class "row"} [:div {:class "col-lg-6"} [:ul {:class "list-group"} (for [m @messages] (message m))]]]))) (defn message-input [] (let [input (re-frame/subscribe [:message-input])] [:div {:class "row"} [:div {:class "col-lg-6"} [:div {:class "input-group"} [:input {:type "text" :value (:text @input) :placeholder "Enter text to reverse!" :class "form-control" :on-change #(re-frame/dispatch [:message-input-text (-> % .-target .-value)])}] [:span {:class "input-group-btn"} [:button {:type "button" :class "btn btn-default" :on-click #(re-frame/dispatch [:send-message])} "Send"]] ]]])) (defn chat-ui [] [:div {:class "container-fluid"} [:h1 "ChatApp"] [message-list] [message-input]])
(ns chatapp.view (:require [re-frame.core :as re-frame])) (defn message [message] [:li {:class "list-group-item"} (:message message)]) (defn message-list [] (let [messages (re-frame/subscribe [:messages])] (fn [] [:div {:class "row"} [:div {:class "col-md-6"} [:ul {:class "list-group"} (for [m @messages] (message m))]]]))) (defn message-input [] (let [input (re-frame/subscribe [:message-input])] (fn [] [:input {:type "text" :value (:text @input) :placeholder "Enter text to reverse!" :class "form-control" :auto-focus true :on-key-press #(when (= 13 (.-charCode %)) (re-frame/dispatch [:send-message])) :on-change #(re-frame/dispatch [:message-input-text (-> % .-target .-value)])}]))) (defn message-composer [] [:div {:class "row"} [:div {:class "col-md-6"} [:div {:class "input-group"} [message-input] [:span {:class "input-group-btn"} [:button {:type "button" :class "btn btn-default" :on-click #(re-frame/dispatch [:send-message])} "Send"]]]]]) (defn chat-ui [] [:div {:class "container-fluid"} [:div {:class "row"} [:div {:class "col-md-6"} [:h1 "ChatApp"]]] [message-list] [message-composer]])
Move Clojure to dev dependency
;; The Climate Corporation licenses this file to you under 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 ;; ;; See the NOTICE file distributed with this work for additional information ;; regarding copyright ownership. 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. (defproject com.climate/claypoole "1.0.0-SNAPSHOT" :description "Claypoole: Threadpool tools for Clojure." :url "http://github.com/TheClimateCorporation/claypoole/" :license {:name "Apache License Version 2.0" :url http://www.apache.org/licenses/LICENSE-2.0 :distribution :repo} :min-lein-version "2.0.0" :source-paths ["src/clj"] :java-source-paths ["src/java"] :pedantic? :warn :dependencies [[org.clojure/clojure "1.6.0"]] :plugins [[jonase/eastwood "0.2.1"]])
;; The Climate Corporation licenses this file to you under 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 ;; ;; See the NOTICE file distributed with this work for additional information ;; regarding copyright ownership. 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. (defproject com.climate/claypoole "1.0.0-SNAPSHOT" :description "Claypoole: Threadpool tools for Clojure." :url "http://github.com/TheClimateCorporation/claypoole/" :license {:name "Apache License Version 2.0" :url http://www.apache.org/licenses/LICENSE-2.0 :distribution :repo} :min-lein-version "2.0.0" :source-paths ["src/clj"] :java-source-paths ["src/java"] :pedantic? :warn :profiles {:dev {:dependencies [[org.clojure/clojure "1.7.0"]]}} :plugins [[jonase/eastwood "0.2.1"]])
Use Logback, avoid warning about missing logger implementation
(defproject rpi-challenger "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "https://github.com/solita" :license {:name "MIT License" :url "http://opensource.org/licenses/MIT"} :dependencies [[org.clojure/clojure "1.4.0"] [org.clojure/tools.cli "0.2.2"] [http.async.client "0.5.0-SNAPSHOT"] [ring/ring-core "1.1.6"] [ring/ring-devel "1.1.6"] [ring/ring-jetty-adapter "1.1.6"] [compojure "1.1.3"] [enlive "1.0.0"]] :main rpi-challenger.main)
(defproject rpi-challenger "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "https://github.com/solita" :license {:name "MIT License" :url "http://opensource.org/licenses/MIT"} :dependencies [[org.clojure/clojure "1.4.0"] [org.clojure/tools.cli "0.2.2"] [http.async.client "0.5.0-SNAPSHOT"] [ch.qos.logback/logback-classic "1.0.7"] [ring/ring-core "1.1.6"] [ring/ring-devel "1.1.6"] [ring/ring-jetty-adapter "1.1.6"] [compojure "1.1.3"] [enlive "1.0.0"]] :main rpi-challenger.main)
Make bukkit a provided dependency.
(defproject bukkure "0.4.2-SNAPSHOT" :description "Bringing Clojure to the Bukkit API" :url "http://github.com/SevereOverfl0w/Bukkure" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :java-source-paths ["javasrc"] :javac-options ["-d" "classes/" "-source" "1.7" "-target" "1.7"] :resource-paths ["resources/*"] :repositories [["spigot-repo" "https://hub.spigotmc.org/nexus/content/groups/public/"]] :plugins [[codox "0.8.13"]] :codox {:defaults {:doc/format :markdown}} :dependencies [[org.clojure/clojure "1.7.0"] [org.bukkit/bukkit "1.8.7-R0.1-SNAPSHOT"] [org.reflections/reflections "0.9.8"] [org.clojure/tools.nrepl "0.2.3"] [cheshire "5.2.0"]])
(defproject bukkure "0.4.2-SNAPSHOT" :description "Bringing Clojure to the Bukkit API" :url "http://github.com/SevereOverfl0w/Bukkure" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :java-source-paths ["javasrc"] :javac-options ["-d" "classes/" "-source" "1.7" "-target" "1.7"] :resource-paths ["resources/*"] :repositories [["spigot-repo" "https://hub.spigotmc.org/nexus/content/groups/public/"]] :plugins [[codox "0.8.13"]] :codox {:defaults {:doc/format :markdown}} :dependencies [[org.clojure/clojure "1.7.0"] [org.reflections/reflections "0.9.8"] [org.clojure/tools.nrepl "0.2.3"] [cheshire "5.2.0"]] :profiles {:provided {:dependencies [[org.bukkit/bukkit "1.8.7-R0.1-SNAPSHOT"]]}})
Prepare for next release cycle.
(defproject onyx-app/lein-template "0.10.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.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)
Comment out stuff in dev.clj
(ns user "Namespace to support hacking at the REPL." (:require [clojure.java.javadoc :refer [javadoc]] [clojure.pprint :refer [pp pprint]] [clojure.repl :refer :all] [clojure.string :as str] [clojure.tools.namespace.move :refer :all] [clojure.tools.namespace.repl :refer :all] [midje.repl :refer :all])) ;;;; ___________________________________________________________________________ ;;;; ---- u-classpath ---- (defn u-classpath [] (str/split (System/getProperty "java.class.path") #":")) ;;;; ___________________________________________________________________________ ;;;; ---- u-move-ns-dev-src-test ---- (defn u-move-ns-dev-src-test [old-sym new-sym source-path] (move-ns old-sym new-sym source-path ["dev" "src" "test"])) ;;;; ___________________________________________________________________________ ;;;; App-specific additional utilities for the REPL or command line (do (autotest :stop) (autotest :filter (complement :slow)))
(ns user "Namespace to support hacking at the REPL." (:require [clojure.java.javadoc :refer [javadoc]] [clojure.pprint :refer [pp pprint]] [clojure.repl :refer :all] [clojure.string :as str] [clojure.tools.namespace.move :refer :all] [clojure.tools.namespace.repl :refer :all] [midje.repl :refer :all])) ;;;; ___________________________________________________________________________ ;;;; ---- u-classpath ---- (defn u-classpath [] (str/split (System/getProperty "java.class.path") #":")) ;;;; ___________________________________________________________________________ ;;;; ---- u-move-ns-dev-src-test ---- (defn u-move-ns-dev-src-test [old-sym new-sym source-path] (move-ns old-sym new-sym source-path ["dev" "src" "test"])) ;;;; ___________________________________________________________________________ ;;;; App-specific additional utilities for the REPL or command line (comment (do (autotest :stop) (autotest :filter (complement :slow))) )
Document the process of adding namespaces to devcards home.
(ns {{name}}-devcards.core (:require [devcards.core :as dc :include-macros true] [{{name}}.core :as {{name}}] #_[om.core :as om :include-macros true] #_[sablono.core :as sab :include-macros true]) (:require-macros [devcards.core :refer [defcard is are= are-not=]])) (enable-console-print!) (devcards.core/start-devcard-ui!) (devcards.core/start-figwheel-reloader!) ;; remember to run lein figwheel and then browse to ;; http://localhost:3449/devcards/index.html (defcard devcard-intro (dc/markdown-card "# Devcards for {{ name }} I can be found in `devcards_src/{{sanitized}}_devcards/core.cljs`. If you add cards to this file, they will appear here on this page. You can add devcards to any file as long as you require `devcards.core` like so: ``` (:require [devcards.core :as dc :include-macros true]) ``` As you add cards to other namspaces, those namspaces will be listed on the Devcards **home** page. <a href=\"https://github.com/bhauman/devcards/blob/master/example_src/devdemos/core.cljs\" target=\"_blank\">Here are some Devcard examples</a>"))
(ns {{name}}-devcards.core (:require [devcards.core :as dc :include-macros true] [{{name}}.core :as {{name}}] #_[om.core :as om :include-macros true] #_[sablono.core :as sab :include-macros true]) (:require-macros [devcards.core :refer [defcard is are= are-not=]])) (enable-console-print!) (devcards.core/start-devcard-ui!) (devcards.core/start-figwheel-reloader!) ;; remember to run lein figwheel and then browse to ;; http://localhost:3449/devcards/index.html (defcard devcard-intro (dc/markdown-card "# Devcards for {{ name }} I can be found in `devcards_src/{{sanitized}}_devcards/core.cljs`. If you add cards to this file, they will appear here on this page. As you add cards to other namespaces, those namespaces will be listed on the Devcards **home** page, provided you require those files in `devcards_src/{{sanitized}}_devcards/core.cljs`. You can add devcards to any file as long as you require `devcards.core` like so: ``` (:require [devcards.core :as dc :include-macros true]) ``` <a href=\"https://github.com/bhauman/devcards/blob/master/example_src/devdemos/core.cljs\" target=\"_blank\">Here are some Devcard examples</a>"))
Implement part 2 of the Clojure day 3 solution.
(ns advent2016.day3 (:require [clojure.java.io :as io] [clojure.string :as s])) (defn read-sides [line] (map #(Integer/parseInt %) (remove s/blank? (s/split line #" ")))) (defn valid-triangle? [[a b c]] (and (> (+ a b) c) (> (+ a c) b) (> (+ b c) a))) (def solution (->> "../day3.data" io/reader line-seq (map read-sides) (filter valid-triangle?) count))
(ns advent2016.day3 (:require [clojure.java.io :as io] [clojure.string :as s])) (def puzzle (line-seq (io/reader "../day3.data"))) (defn read-sides [line] (map #(Integer/parseInt %) (remove s/blank? (s/split line #" ")))) (defn valid-triangle? [[a b c]] (and (> (+ a b) c) (> (+ a c) b) (> (+ b c) a))) (def solution1 (->> puzzle (map read-sides) (filter valid-triangle?) count)) (def solution2 (->> puzzle (map read-sides) (apply mapcat vector) (partition 3) (filter valid-triangle?) count))
Add simple example org.clojure/google-closure-library-third-party exclusion
(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]] [thheller/shadow-cljs "2.8.69"] [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.69"] [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"]})
Update nth-prime in response to PR feedback
(ns nth-prime) (defn sqrt "Wrapper around java's sqrt method." [number] (int (Math/ceil (Math/sqrt number)))) (defn divides? "Helper function to decide if a number is evenly divided by divisor." [number divisor] (zero? (mod number divisor))) (defn- prime-by-trial-division? "Simple trial division prime check." [number] (empty? (for [n (range 3 (inc (sqrt number)) 2) :when (divides? number n)] n))) (defn prime? [number] (cond (= 2 number) true (even? number) false :else (prime-by-trial-division? number))) (defn next-prime [start] (loop [n (inc start)] (if (prime? n) n (recur (inc n))))) (def primes (iterate next-prime 1)) (defn nth-prime [index] (when (not (pos? index)) (throw (IllegalArgumentException. "nth-prime expects a positive integer for an argument"))) (nth primes index))
(ns nth-prime) (defn sqrt "Wrapper around java's sqrt method." [number] (int (Math/ceil (Math/sqrt number)))) (defn divides? "Helper function to decide if a number is evenly divided by divisor." [number divisor] (zero? (mod number divisor))) (defn- prime-by-trial-division? "Simple trial division prime check." [number] (empty? (for [n (range 3 (inc (sqrt number)) 2) :when (divides? number n)] n))) (defn prime? [number] (or (= 2 number) (and (odd? number) (prime-by-trial-division? number)))) (defn next-prime [start] (loop [n (inc start)] (if (prime? n) n (recur (inc n))))) (def primes (iterate next-prime 1)) (defn nth-prime [index] (when-not (pos? index) (throw (IllegalArgumentException. "nth-prime expects a positive integer for an argument"))) (nth primes index))
Use ->(>) for the impl
(ns desdemona.lifecycles.logging (:require [taoensso.timbre :refer [info]])) (let [task-name (:onyx/name (:onyx.core/task-map event))] (doseq [m (map :message (mapcat :leaves (:tree (:onyx.core/results event))))] (defn log-batch [event lifecycle] (info task-name "logging segment:" m))) {}) (def log-calls {:lifecycle/after-batch log-batch}) (defn add-logging "Adds logging output to a task's output-batch." [job task] (if-let [entry (first (filter #(= (:onyx/name %) task) (:catalog job)))] (update-in job [:lifecycles] conj {:lifecycle/task task :lifecycle/calls ::log-calls})))
(ns desdemona.lifecycles.logging (:require [taoensso.timbre :refer [info]])) (defn log-batch [event lifecycle] (let [task-name (-> event :onyx.core/task-map :onyx/name)] (doseq [m (->> event :onyx.core/results :tree (mapcat :leaves) (map :message))] (info task-name "logging segment:" m))) {}) (def log-calls {:lifecycle/after-batch log-batch}) (defn add-logging "Adds logging output to a task's output-batch." [job task] (if-let [entry (first (filter #(= (:onyx/name %) task) (:catalog job)))] (update-in job [:lifecycles] conj {:lifecycle/task task :lifecycle/calls ::log-calls})))
Add skip option to example dev
(set-env! :resource-paths #{"resources"} :dependencies '[[org.clojure/clojure "1.8.0"] [afrey/boot-asset-fingerprint "1.3.1"] [tailrecursion/boot-jetty "0.1.3" :scope "test"]]) (require '[afrey.boot-asset-fingerprint :refer [asset-fingerprint]] '[tailrecursion.boot-jetty :as jetty]) (deftask dev [] (comp (watch) (asset-fingerprint :extensions [".css" ".html"]) (jetty/serve :port 5000) (target)))
(set-env! :resource-paths #{"resources"} :dependencies '[[org.clojure/clojure "1.8.0"] [afrey/boot-asset-fingerprint "1.3.1"] [tailrecursion/boot-jetty "0.1.3" :scope "test"]]) (require '[afrey.boot-asset-fingerprint :refer [asset-fingerprint]] '[tailrecursion.boot-jetty :as jetty]) (deftask dev [s skip bool] (comp (watch) (asset-fingerprint :extensions [".css" ".html"] :skip skip) (jetty/serve :port 5000) (target)))
Add input builder fn for use by plugins
(ns onyx.types) (defrecord Leaf [message id acker-id completion-id ack-val hash-group route]) (defrecord Route [flow exclusions post-transformation action]) (defrecord Ack [id completion-id ack-val timestamp]) (defrecord Results [tree acks segments]) (defrecord Result [root leaves]) (defrecord Link [link timestamp])
(ns onyx.types) (defrecord Leaf [message id acker-id completion-id ack-val hash-group route]) (defn input [id message] (->Leaf message id nil nil nil nil nil)) (defrecord Route [flow exclusions post-transformation action]) (defrecord Ack [id completion-id ack-val timestamp]) (defrecord Results [tree acks segments]) (defrecord Result [root leaves]) (defrecord Link [link timestamp])
Return nil instead of empty sequence from test-seq-for-ns
(ns lazytest.find (:use lazytest.suite)) (defn- find-tests-for-var [this-var] (if-let [f (:find-tests (meta this-var))] (do (assert (fn? f)) (f)) (when (bound? this-var) (let [value (var-get this-var)] (when (suite? value) value))))) (defn- test-seq-for-ns [this-ns] (vary-meta (remove nil? (map find-tests-for-var (vals (ns-interns this-ns)))) assoc :name (ns-name this-ns))) (defn- find-tests-in-namespace [this-ns] (when-not (= (the-ns 'clojure.core) this-ns) (if-let [f (:find-tests (meta this-ns))] (do (assert (fn? f)) (f)) (when-let [s (test-seq-for-ns this-ns)] (suite (fn [] (test-seq s))))))) (defn find-tests [x] "Returns a seq of runnable tests. Processes the :focus metadata flag. Recurses on all Vars in a namespace, unless that namespace has :find-tests metadata." (cond (symbol? x) (find-tests (the-ns x)) (instance? clojure.lang.Namespace x) (find-tests-in-namespace x) (var? x) (find-tests-for-var x) :else nil))
(ns lazytest.find (:use lazytest.suite)) (defn- find-tests-for-var [this-var] (if-let [f (:find-tests (meta this-var))] (do (assert (fn? f)) (f)) (when (bound? this-var) (let [value (var-get this-var)] (when (suite? value) value))))) (defn- test-seq-for-ns [this-ns] (let [s (remove nil? (map find-tests-for-var (vals (ns-interns this-ns))))] (when (seq s) (vary-meta s assoc :name (ns-name this-ns))))) (defn- find-tests-in-namespace [this-ns] (when-not (= (the-ns 'clojure.core) this-ns) (if-let [f (:find-tests (meta this-ns))] (do (assert (fn? f)) (f)) (when-let [s (test-seq-for-ns this-ns)] (suite (fn [] (test-seq s))))))) (defn find-tests [x] "Returns a seq of runnable tests. Processes the :focus metadata flag. Recurses on all Vars in a namespace, unless that namespace has :find-tests metadata." (cond (symbol? x) (find-tests (the-ns x)) (instance? clojure.lang.Namespace x) (find-tests-in-namespace x) (var? x) (find-tests-for-var x) :else nil))
Set CORS header on POSTs
(ns cmr.graph.rest.response (:require [cheshire.core :as json] [ring.util.http-response :as response] [taoensso.timbre :as log])) (defn ok [_request & args] (response/ok args)) (defn json [_request data] (-> data json/generate-string response/ok (response/content-type "application/json"))) (defn text [_request data] (-> data response/ok (response/content-type "text/plain"))) (defn not-found [_request] (response/content-type (response/not-found "Not Found") "plain/text")) (defn cors [request response] (case (:request-method request) :options (-> response (response/content-type "text/plain; charset=utf-8") (response/header "Access-Control-Allow-Origin" "*") (response/header "Access-Control-Allow-Methods" "POST, PUT, GET, DELETE, OPTIONS") (response/header "Access-Control-Allow-Headers" "Content-Type") (response/header "Access-Control-Max-Age" "2592000")) :get (response/header response "Access-Control-Allow-Origin" "*") response))
(ns cmr.graph.rest.response (:require [cheshire.core :as json] [ring.util.http-response :as response] [taoensso.timbre :as log])) (defn ok [_request & args] (response/ok args)) (defn json [_request data] (-> data json/generate-string response/ok (response/content-type "application/json"))) (defn text [_request data] (-> data response/ok (response/content-type "text/plain"))) (defn not-found [_request] (response/content-type (response/not-found "Not Found") "plain/text")) (defn cors [request response] (case (:request-method request) :options (-> response (response/content-type "text/plain; charset=utf-8") (response/header "Access-Control-Allow-Origin" "*") (response/header "Access-Control-Allow-Methods" "POST, PUT, GET, DELETE, OPTIONS") (response/header "Access-Control-Allow-Headers" "Content-Type") (response/header "Access-Control-Max-Age" "2592000")) :get (response/header response "Access-Control-Allow-Origin" "*") :post (response/header response "Access-Control-Allow-Origin" "*") response))
Make uberjar work at the command line with the name circle.Init.
(ns circle.Init ;; capitalized for JRuby ;; (:require circle.swank) (:require circle.db) (:require circle.web) (:require circle.repl) (:require circle.logging) ;; (:require circle.backend.nodes ;; circle.backend.project.rails ;; circle.backend.project.circle) (:gen-class :name circle.Init :main true) ) (def init* (delay (try (circle.logging/init) ;; workaround for Heroku not liking us starting up swank (when (System/getenv "SWANK") (require 'circle.swank) (.invoke (ns-resolve 'circle.swank 'init))) (circle.db/init) (circle.web/init) (circle.repl/init) (println (java.util.Date.)) true (catch Exception e (println "caught exception on startup:") (.printStackTrace e) (println "exiting") (System/exit 1))))) (defn init "Start everything up. idempotent." [] @init*) (defn -main [] (init))
(ns circle.Init ;; capitalized for JRuby ;; (:require circle.swank) (:require circle.db) (:require circle.web) (:require circle.repl) (:require circle.logging) ;; (:require circle.backend.nodes ;; circle.backend.project.rails ;; circle.backend.project.circle) (:gen-class :name circle.Init) ) (def init* (delay (try (circle.logging/init) ;; workaround for Heroku not liking us starting up swank (when (System/getenv "SWANK") (require 'circle.swank) (.invoke (ns-resolve 'circle.swank 'init))) (circle.db/init) (circle.web/init) (circle.repl/init) (println (java.util.Date.)) true (catch Exception e (println "caught exception on startup:") (.printStackTrace e) (println "exiting") (System/exit 1))))) (defn init "Start everything up. idempotent." [] @init*) (defn -main [] (init))
Update source and target javac properties to 1.8.
(defproject guangyin/guangyin "0.1.1-SNAPSHOT" :description "Clojure date and time library wrapping java.time" :url "https://github.com/juhovh/guangyin" :license {:name "MIT License" :url "http://opensource.org/licenses/MIT" :distribution :repo} :dependencies [[org.clojure/clojure "1.6.0"]] :min-lein-version "2.0.0" :source-paths ["src/clj"] :java-source-paths ["src/java"] :profiles {:dev {:plugins [[codox "0.8.11"] [lein-cloverage "1.0.2"]] :codox {:include [guangyin.core guangyin.format]}}})
(defproject guangyin/guangyin "0.1.1-SNAPSHOT" :description "Clojure date and time library wrapping java.time" :url "https://github.com/juhovh/guangyin" :license {:name "MIT License" :url "http://opensource.org/licenses/MIT" :distribution :repo} :dependencies [[org.clojure/clojure "1.6.0"]] :min-lein-version "2.0.0" :source-paths ["src/clj"] :java-source-paths ["src/java"] :javac-options ["-target" "1.8" "-source" "1.8"] :profiles {:dev {:plugins [[codox "0.8.11"] [lein-cloverage "1.0.2"]] :codox {:include [guangyin.core guangyin.format]}}})
Increase react version to 0.9.0.1 to fix missing article and aside externs.
(defproject breeze-quiescent "0.1.1-SNAPSHOT" :description "A minimal, functional ClojureScript wrapper for ReactJS" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/clojurescript "0.0-2173" :scope "provided"] [com.facebook/react "0.9.0"]] :source-paths ["src"] ;; development concerns :profiles {:dev {:source-paths ["src" "examples/src"] :resource-paths ["examples/resources"] :plugins [[lein-cljsbuild "1.0.1"]] :cljsbuild {:builds [{:source-paths ["src" "examples/src"] :compiler {:output-to "examples/resources/public/main.js" :output-dir "examples/resources/public/build" :optimizations :whitespace :preamble ["react/react.min.js"] :externs ["react/externs/react.js"] :pretty-print true :source-map "examples/resources/public/main.js.map" :closure-warnings {:non-standard-jsdoc :off}}}]}}})
(defproject breeze-quiescent "0.1.1-SNAPSHOT" :description "A minimal, functional ClojureScript wrapper for ReactJS" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/clojurescript "0.0-2173" :scope "provided"] [com.facebook/react "0.9.0.1"]] :source-paths ["src"] ;; development concerns :profiles {:dev {:source-paths ["src" "examples/src"] :resource-paths ["examples/resources"] :plugins [[lein-cljsbuild "1.0.1"]] :cljsbuild {:builds [{:source-paths ["src" "examples/src"] :compiler {:output-to "examples/resources/public/main.js" :output-dir "examples/resources/public/build" :optimizations :whitespace :preamble ["react/react.min.js"] :externs ["react/externs/react.js"] :pretty-print true :source-map "examples/resources/public/main.js.map" :closure-warnings {:non-standard-jsdoc :off}}}]}}})
Update deps for cloxp cljs integration
(defproject cljs-workspace "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"} :plugins [[lein-cljsbuild "1.0.4-SNAPSHOT"]] :source-paths ["src/clj", "src/cljs"] :dependencies [[org.clojure/clojure "1.6.0"] [org.clojure/clojurescript "0.0-2760"] [http-kit "2.1.16"] [compojure "1.1.5"] [ring "1.3.1"] [fogus/ring-edn "0.2.0"] [om "0.8.0-rc1"] [org.clojure/core.async "0.1.303.0-886421-alpha"] [cljs-tooling "0.1.3"]] :cljsbuild {:builds [{:id "om-test" :source-paths ["src/cljs"] :compiler { :main main.core :output-to "resources/public/js/om-test.js" :output-dir "resources/public/js/" :optimizations :none :source-map "resources/public/js/om-test.js.map"}}]})
(defproject cljs-workspace "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"} :plugins [[lein-cljsbuild "1.0.4-SNAPSHOT"]] :source-paths ["src/clj", "src/cljs"] :dependencies [[org.clojure/clojure "1.6.0"] [org.clojure/clojurescript "0.0-2760"] [org.rksm/cloxp-com "0.1.3"] [http-kit "2.1.19"] [compojure/compojure "1.3.2"] [ring "1.3.1"] [fogus/ring-edn "0.2.0"] [om "0.8.0-rc1"] [org.clojure/core.async "0.1.303.0-886421-alpha"] [cljs-tooling "0.1.3"]] :cljsbuild {:builds [{:id "om-test" :source-paths ["src/cljs"] :compiler { :main main.core :output-to "resources/public/js/om-test.js" :output-dir "resources/public/js/" :optimizations :none :source-map "resources/public/js/om-test.js.map"}}]})
Switch to website-hosted MVXCVI repo.
(defproject playasophy/wonderdome "1.0.0-SNAPSHOT" :description "Control and rendering software for driving an LED strip art project with various visualizations." :url "https://github.com/playasophy/wonderdome" :license {:name "Public Domain" :url "http://unlicense.org/"} :native-path "target/native" :jvm-opts ^:replace ["-Djava.library.path=target/native/linux"] ; TODO: write some simple dev code to search for dot files in the doc folder and generate SVG graphs. ;:aliases {"sysgraph" ["dot" "-Tsvg" "<" "doc/system-processes.dot" ">" "target/system-processes.svg"]} ; TODO: host this on a static S3 website :repositories [["local" "file:///home/greg/projects/playasophy/wonderdome/lib/repo"]] :dependencies [[com.codeminders/hidapi "1.1"] [com.heroicrobot/pixelpusher "20130916"] [com.stuartsierra/component "0.2.1"] [org.clojure/clojure "1.6.0"] [org.clojure/core.async "0.1.303.0-886421-alpha"]] :hiera {:cluster-depth 4 :vertical? false :ignore-ns #{com.stuartsierra quil}} :profiles {:dev {:source-paths ["dev"] :dependencies [[quil "2.1.0"] [org.clojure/tools.namespace "0.2.4"]]}})
(defproject playasophy/wonderdome "1.0.0-SNAPSHOT" :description "Control and rendering software for driving an LED strip art project with various visualizations." :url "https://github.com/playasophy/wonderdome" :license {:name "Public Domain" :url "http://unlicense.org/"} :native-path "target/native" :jvm-opts ^:replace ["-Djava.library.path=target/native/linux"] ; TODO: write some simple dev code to search for dot files in the doc folder and generate SVG graphs. ;:aliases {"sysgraph" ["dot" "-Tsvg" "<" "doc/system-processes.dot" ">" "target/system-processes.svg"]} :repositories [["mvxcvi" "http://mvxcvi.com/libs/repo"]] :dependencies [[com.codeminders/hidapi "1.1"] [com.heroicrobot/pixelpusher "20130916"] [com.stuartsierra/component "0.2.1"] [org.clojure/clojure "1.6.0"] [org.clojure/core.async "0.1.303.0-886421-alpha"]] :hiera {:cluster-depth 4 :vertical? false :ignore-ns #{com.stuartsierra quil}} :profiles {:dev {:source-paths ["dev"] :dependencies [[quil "2.1.0"] [org.clojure/tools.namespace "0.2.4"]]}})
Add predicate for checking if coordinates are within a bounding box
(ns rp.util.number) (defn nat-num? [x] (and (number? x) (not (neg? x)))) (defn longitude? [x] (and (number? x) (<= -180 x 180))) (defn latitude? [x] (and (number? x) (<= -90 x 90)))
(ns rp.util.number) (defn nat-num? [x] (and (number? x) (not (neg? x)))) (defn longitude? [x] (and (number? x) (<= -180 x 180))) (defn latitude? [x] (and (number? x) (<= -90 x 90))) (defn within-bounding-box? [[lng1 lat1 lng2 lat2] [longitude latitude]] (and (<= lng1 longitude lng2) (<= lat1 latitude lat2)))
Fix embed-stamp for new D4J methods
(do ;; Imports and aliases (clojure.core/use '[clojure.core]) (require '[clojure.string :as str]) (require '[clojure.pprint :as pp]) (require '[clojure.math.numeric-tower :as math]) ;; Convenience functions (defn codeblock [s & { type :type }] (str "```" type "\n" s "\n```")) (defn delete-self [] (alter-var-root #'k9.sandbox/*delete-self* (constantly true))) ;; Embed utilities (defn embed-create [title desc & fields] (let [builder (sx.blah.discord.util.EmbedBuilder.)] (do (when title (.withTitle builder title)) (when desc (.withDescription builder desc)) (doseq [[t d i] (partition 3 fields)] (.appendField builder t d i)) builder))) (defn embed-stamp [embed] (do (.withTimestamp embed (java.time.LocalDateTime/ofInstant (java.time.Instant/now) (java.time.ZoneId/of "UTC"))) embed)) ;; Simple embed function bindings (def embed-field (memfn appendField title desc inline)) (def embed-color (memfn withColor r g b)) (def embed-image (memfn withImage url)) (def embed-thumb (memfn withThumbnail url)) (def embed-url (memfn withUrl url)) (def embed-build (memfn build)) )
(do ;; Imports and aliases (clojure.core/use '[clojure.core]) (require '[clojure.string :as str]) (require '[clojure.pprint :as pp]) (require '[clojure.math.numeric-tower :as math]) ;; Convenience functions (defn codeblock [s & { type :type }] (str "```" type "\n" s "\n```")) (defn delete-self [] (alter-var-root #'k9.sandbox/*delete-self* (constantly true))) ;; Embed utilities (defn embed-create [title desc & fields] (let [builder (sx.blah.discord.util.EmbedBuilder.)] (do (when title (.withTitle builder title)) (when desc (.withDescription builder desc)) (doseq [[t d i] (partition 3 fields)] (.appendField builder t d i)) builder))) (defn embed-stamp [embed] (do (.withTimestamp embed (java.time.Instant/now) ) embed)) ;; Simple embed function bindings (def embed-field (memfn appendField title desc inline)) (def embed-color (memfn withColor r g b)) (def embed-image (memfn withImage url)) (def embed-thumb (memfn withThumbnail url)) (def embed-url (memfn withUrl url)) (def embed-build (memfn build)) )
Use capitalised letters to make the music read more like the lyrics.
(ns overtunes.songs.frere-jacques (:use [overtone.live]) (:use [overtunes.core]) (:use [overtunes.instruments.foo])) (def frère-jacques [:C4 :D4 :E4 :C4]) (def dormez-vous [:E4 :F4 :G4 :rest]) (def sonnez-les-matines [:G4 :G4 :E4 :C4]) (def din-dan-don [:C4 :G3 :C4 :rest]) (def melody (concat frère-jacques frère-jacques dormez-vous dormez-vous sonnez-les-matines sonnez-les-matines din-dan-don din-dan-don)) (defn frere-jacques-round [] (let [metro (metronome 120)] (play-melody melody foo metro) (play-melody melody foo (metronome-from metro 8)) (play-melody melody foo (metronome-from metro 16)) (play-melody melody foo (metronome-from metro 24))))
(ns overtunes.songs.frere-jacques (:use [overtone.live]) (:use [overtunes.core]) (:use [overtunes.instruments.foo])) (def Frère-Jacques [:C4 :D4 :E4 :C4]) (def Dormez-vous? [:E4 :F4 :G4 :rest]) (def Sonnez-les-matines! [:G4 :G4 :E4 :C4]) (def Din-dan-don [:C4 :G3 :C4 :rest]) (def melody (concat Frère-Jacques Frère-Jacques Dormez-vous? Dormez-vous? Sonnez-les-matines! Sonnez-les-matines! Din-dan-don Din-dan-don)) (defn frere-jacques [] (let [metro (metronome 120)] (play-melody melody foo metro) (play-melody melody foo (metronome-from metro 8)) (play-melody melody foo (metronome-from metro 16)) (play-melody melody foo (metronome-from metro 24))))
Make final if not in deploy state
(ns obb-rules.game-mode (:require [obb-rules.board :as board] [obb-rules.game :as game])) (defn final? "Checks if the game is finished" [game] (or (board/empty-board? game :p1) (board/empty-board? game :p2))) (defn winner "Gets the winner of the given game" [game] (cond (board/empty-board? game :p1) :p2 (board/empty-board? game :p2) :p1 :else :none)) (defn- finalize "Marks a game as final" [game] (game/state game :final)) (defn process "Checks if a given game is finished and updates it's state. Returns the given game if not finished" [game] (if (final? game) (finalize game) game))
(ns obb-rules.game-mode (:require [obb-rules.board :as board] [obb-rules.game :as game])) (defn final? "Checks if the game is finished" [game] (and (not (= game/state :deploy)) (or (board/empty-board? game :p1) (board/empty-board? game :p2)))) (defn winner "Gets the winner of the given game" [game] (cond (board/empty-board? game :p1) :p2 (board/empty-board? game :p2) :p1 :else :none)) (defn- finalize "Marks a game as final" [game] (game/state game :final)) (defn process "Checks if a given game is finished and updates it's state. Returns the given game if not finished" [game] (if (final? game) (finalize game) game))
Move Clojure dep to dev profile.
(defproject soy-clj "0.1.0-SNAPSHOT" :description "An idiomatic Clojure wrapper for Google's Closure templating system." :url "https://github.com/codahale/soy-clj" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.8.0-RC2"] [org.clojure/core.cache "0.6.4"] [com.google.template/soy "2015-04-10"]] :plugins [[codox "0.9.0"]])
(defproject soy-clj "0.1.0-SNAPSHOT" :description "An idiomatic Clojure wrapper for Google's Closure templating system." :url "https://github.com/codahale/soy-clj" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/core.cache "0.6.4"] [com.google.template/soy "2015-04-10"]] :profiles {:dev {:dependencies [[org.clojure/clojure "1.8.0-RC2"]]}} :plugins [[codox "0.9.0"]])
Add Clojure 1.4.0-beta1 to lein-multi deps.
(defproject stencil "0.2.0" :description "Mustache in Clojure" :dependencies [[clojure "1.3.0"] [slingshot "0.8.0"]] :multi-deps {"1.2" [[org.clojure/clojure "1.2.1"]] "1.3" [[org.clojure/clojure "1.3.0"]] :all [[slingshot "0.8.0"]]} :dev-dependencies [[ritz "0.2.0"] [org.clojure/data.json "0.1.1"]] :extra-files-to-clean ["test/spec"])
(defproject stencil "0.2.0" :description "Mustache in Clojure" :dependencies [[clojure "1.3.0"] [slingshot "0.8.0"]] :multi-deps {"1.2" [[org.clojure/clojure "1.2.1"]] "1.3" [[org.clojure/clojure "1.3.0"]] "1.4" [[org.clojure/clojure "1.4.0-beta1"]] :all [[slingshot "0.8.0"]]} :dev-dependencies [[ritz "0.2.0"] [org.clojure/data.json "0.1.1"]] :extra-files-to-clean ["test/spec"])
Prepare for next development iteration
(defproject naughtmq "0.0.1" :description "A native-embedding wrapper for jzmq" :url "https://github.com/gaverhae/naughtmq" :scm {:name "git" :url "https://github.com/gaverhae/naughtmq"} :signing {:gpg-key "gary.verhaegen@gmail.com"} :deploy-repositories [["clojars" {:creds :gpg}]] :pom-addition [:developers [:developer [:name "Gary Verhaegen"] [:url "https://github.com/gaverhae"] [:email "gary.verhaegen@gmail.com"] [:timezone "+1"]]] :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.6.0"] [com.taoensso/timbre "3.1.6"] [org.zeromq/jzmq "2.2.2"]] :java-source-paths ["src"])
(defproject naughtmq "0.0.2-SNAPSHOT" :description "A native-embedding wrapper for jzmq" :url "https://github.com/gaverhae/naughtmq" :scm {:name "git" :url "https://github.com/gaverhae/naughtmq"} :signing {:gpg-key "gary.verhaegen@gmail.com"} :deploy-repositories [["clojars" {:creds :gpg}]] :pom-addition [:developers [:developer [:name "Gary Verhaegen"] [:url "https://github.com/gaverhae"] [:email "gary.verhaegen@gmail.com"] [:timezone "+1"]]] :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.6.0"] [com.taoensso/timbre "3.1.6"] [org.zeromq/jzmq "2.2.2"]] :java-source-paths ["src"])
Implement moving to edit state upon double click
(ns reabledit.core (:require [reabledit.components :as components] [reabledit.keyboard :as keyboard] [reagent.core :as reagent])) ;; ;; Convenience API ;; (defn update-row [data nth-row new-row] (let [[init tail] (split-at nth-row data)] (into [] (concat init [new-row] (rest tail))))) ;; ;; Main component ;; (defn data-table [columns data row-change-fn] (let [state (reagent/atom {}) element-id (gensym "reabledit-focusable")] (fn [columns data row-change-fn] [:div.reabledit {:id element-id :tabIndex 0 :on-key-down #(keyboard/handle-key-down % columns data state row-change-fn element-id)} [:table [components/data-table-headers columns] [:tbody (for [[nth-row row-data] (map-indexed vector data)] ^{:key nth-row} [components/data-table-row columns data row-data nth-row state])]]])))
(ns reabledit.core (:require [reabledit.components :as components] [reabledit.keyboard :as keyboard] [reabledit.util :as util] [reagent.core :as reagent])) ;; ;; Convenience API ;; (defn update-row [data nth-row new-row] (let [[init tail] (split-at nth-row data)] (into [] (concat init [new-row] (rest tail))))) ;; ;; Main component ;; (defn data-table [columns data row-change-fn] (let [state (reagent/atom {}) element-id (gensym "reabledit-focusable")] (fn [columns data row-change-fn] [:div.reabledit {:id element-id :tabIndex 0 :on-key-down #(keyboard/handle-key-down % columns data state row-change-fn element-id) :on-double-click #(util/enable-edit! columns data state)} [:table [components/data-table-headers columns] [:tbody (for [[nth-row row-data] (map-indexed vector data)] ^{:key nth-row} [components/data-table-row columns data row-data nth-row state])]]])))
Remove the let hack by inlining it exactly, which is the idiom. Somehow it didn't occur to me to try that.
(ns clj_record.core (:require [clojure.contrib.sql :as sql])) (defn table-name [model-name] (if (keyword? model-name) (.getName model-name) model-name)) (defn find-record [model-name id] (sql/with-connection db (sql/with-results rows (format "select * from %s where id = %s" (table-name model-name) id) (merge {} (first rows))))) (defn create [model-name attributes] (sql/with-connection db (let [key-vector (keys attributes) val-vector (map attributes key-vector) id (sql/transaction (sql/insert-values (table-name model-name) key-vector val-vector) (sql/with-results rows "VALUES IDENTITY_VAL_LOCAL()" (:1 (first rows))))] (find-record model-name id)))) (defmacro setup-model [model-name] (let [find-record-fn-name 'find-record create-fn-name 'create] `[(defn ~find-record-fn-name [id#] (find-record ~model-name id#)) (defn ~create-fn-name [attributes#] (create ~model-name attributes#))]))
(ns clj_record.core (:require [clojure.contrib.sql :as sql])) (defn table-name [model-name] (if (keyword? model-name) (.getName model-name) model-name)) (defn find-record [model-name id] (sql/with-connection db (sql/with-results rows (format "select * from %s where id = %s" (table-name model-name) id) (merge {} (first rows))))) (defn create [model-name attributes] (sql/with-connection db (let [key-vector (keys attributes) val-vector (map attributes key-vector) id (sql/transaction (sql/insert-values (table-name model-name) key-vector val-vector) (sql/with-results rows "VALUES IDENTITY_VAL_LOCAL()" (:1 (first rows))))] (find-record model-name id)))) (defmacro setup-model [model-name] `[(defn ~'find-record [id#] (find-record ~model-name id#)) (defn ~'create [attributes#] (create ~model-name attributes#))])
Fix that damn docstring AGAIN
(ns useful.amalloy.debug) (defmacro ? "A useful debugging tool when you can't figure out what's going on: wrap a form with and-print, and the form will be printed alongside its result. The result will still be passed along." [val] `(let [x# ~val] (prn '~val '~'is x#) x#))
(ns useful.amalloy.debug) (defmacro ? "A useful debugging tool when you can't figure out what's going on: wrap a form with ?, and the form will be printed alongside its result. The result will still be passed along." [val] `(let [x# ~val] (prn '~val '~'is x#) x#))
Use babashka.deps instead of creating a separate .classpath file
;; Example of using clj-chrome-devtools with babashka ;; ;; Make a .classpath ;; $ clj -A:bb -Spath > .classpath ;; ;; Start Chrome in the background: ;; /some/chrome-binary --remote-debugging-port=9222 --headless & ;; ;; Run with: ;; $ bb --classpath $(cat .classpath) bb.clj (require '[clj-chrome-devtools.core :as core] '[clj-chrome-devtools.automation :as auto]) (println "Printing to bb.pdf") (def a (auto/create-automation (core/connect))) (auto/to a "https://babashka.org") (auto/print-pdf a "bb.pdf" {:print-background true :paper-width 8.3 :paper-height 11.7})
;; Example of using clj-chrome-devtools with babashka ;; ;; Start Chrome in the background: ;; /some/chrome-binary --remote-debugging-port=9222 --headless & ;; ;; Run with: ;; $ bb bb.clj (require '[babashka.deps :as deps]) (deps/add-deps '{:deps {tatut/devtools {:git/url "https://github.com/tatut/clj-chrome-devtools" :git/sha "cc96255433ca406aaba8bcee17d0d0b3b16dc423"} org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha" :git/sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}}}) (require '[clj-chrome-devtools.core :as core] '[clj-chrome-devtools.automation :as auto]) (println "Printing to bb.pdf") (def a (auto/create-automation (core/connect))) (auto/to a "https://babashka.org") (auto/print-pdf a "bb.pdf" {:print-background true :paper-width 8.3 :paper-height 11.7})
Bring color into Sunburst, but need to decide how to mimic D3's parent-based color scheme.
(ns sunburst (:refer-clojure :exclude [partition]) ;;avoid name conflict with base "partition" function (:use [c2.core :only [unify style]] [c2.maths :only [sqrt sin cos Tau]] ;;Life's short, don't waste it writing 2*Pi [c2.svg :only [arc]] [c2.layout.partition :only [partition]] [vomnibus.d3 :only [flare]])) (let [radius 170 ;;Partition will give us entries for every node; ;;we only want slices, so filter out the root node. slices (filter #(-> % :partition :depth (not= 0)) (partition flare :value :size :size [Tau (* radius radius)]))] [:svg {:width (* 2 radius) :height (* 2 radius)} [:g {:transform (str "translate(" radius "," radius ")")} (unify slices (fn [{name :name, bites :bites {:keys [x dx y dy]} :partition}] [:g.slice [:path {:d (arc :inner-radius (sqrt y) :outer-radius (sqrt (+ y dy)) :start-angle x :end-angle (+ x dx))}]]))]] )
(ns sunburst (:refer-clojure :exclude [partition]) ;;avoid name conflict with base "partition" function (:use [c2.core :only [unify style]] [c2.maths :only [sqrt sin cos Tau]] ;;Life's short, don't waste it writing 2*Pi [c2.svg :only [arc]] [c2.layout.partition :only [partition]] [vomnibus.d3 :only [flare]] [vomnibus.d3-color :only [Categorical-20]])) (let [radius 270 ;;Partition will give us entries for every node; ;;we only want slices, so filter out the root node. slices (filter #(-> % :partition :depth (not= 0)) (partition flare :value :size :size [Tau (* radius radius)])) ;;TODO: Rework partition to include reference to parent so we can match D3's coloring scheme? color-scale (apply hash-map (interleave (into #{} (map :name (filter :children slices))) (flatten (repeat Categorical-20))))] [:svg {:width (* 2 radius) :height (* 2 radius)} [:g {:transform (str "translate(" radius "," radius ")")} (unify slices (fn [{name :name, bites :bites {:keys [x dx y dy]} :partition}] [:g.slice [:path {:title name :d (arc :inner-radius (sqrt y) :outer-radius (sqrt (+ y dy)) :start-angle x :end-angle (+ x dx)) :fill "white"}]]))]] )
Use codox to generate docs
(defproject str "0.1.0-SNAPSHOT" :description "String manipulation library for clojure" :url "http://github.com/expez/str" :license {:name "MIT License" :url "http://www.opensource.org/licenses/mit-license.php"} :dependencies [[org.clojure/clojure "1.6.0"]] :profiles {:dev {:dependencies [[org.clojure/test.check "0.7.0"]]}})
(defproject str "0.1.0-SNAPSHOT" :description "String manipulation library for clojure" :url "http://github.com/expez/str" :license {:name "MIT License" :url "http://www.opensource.org/licenses/mit-license.php"} :dependencies [[org.clojure/clojure "1.6.0"]] :plugins [[codox "0.8.11"]] :codox {:src-dir-uri "http://github.com/expez/str/blob/master/" :src-linenum-anchor-prefix "L"} :profiles {:dev {:dependencies [[org.clojure/test.check "0.7.0"]]}})
Allow the use of the DATABASE_URL env variable.
(ns staircase.config (:use [clojure.java.io :as io] [clojure.string :only (replace-first)]) (:require [clojure.tools.reader.edn :as edn])) (defn- from-edn [fname] (if-let [is (io/resource fname)] (with-open [rdr (-> is io/reader java.io.PushbackReader.)] (edn/read rdr)) (throw (IllegalArgumentException. (str fname " not found"))))) (defn- options [opts prefix] (->> opts keys (map name) ;; From keyword -> str (filter #(.startsWith % prefix)) (reduce #(assoc %1 (keyword (replace-first %2 prefix "")) (opts (keyword %2))) {}))) ;; Empty secrets if not configured. (defn secrets [opts] (merge (try (from-edn "secrets.edn") (catch Exception e {})) (options opts "secret-"))) (def configuration (delay (from-edn "config.edn"))) (defn config [k] (k @configuration)) (defn db-options [opts] (options opts "db-")) (defn app-options [opts] (options opts "web-"))
(ns staircase.config (:use [clojure.java.io :as io] [clojure.string :only (replace-first)]) (:require [clojure.tools.reader.edn :as edn])) (defn- from-edn [fname] (if-let [is (io/resource fname)] (with-open [rdr (-> is io/reader java.io.PushbackReader.)] (edn/read rdr)) (throw (IllegalArgumentException. (str fname " not found"))))) (defn- options [opts prefix] (->> opts keys (map name) ;; From keyword -> str (filter #(.startsWith % prefix)) (reduce #(assoc %1 (keyword (replace-first %2 prefix "")) (opts (keyword %2))) {}))) ;; Empty secrets if not configured. (defn secrets [opts] (merge (try (from-edn "secrets.edn") (catch Exception e {})) (options opts "secret-"))) (def configuration (delay (from-edn "config.edn"))) (defn config [k] (k @configuration)) (defn db-options [opts] (if-let [uri (:database-url opts)] {:connection-uri uri} (options opts "db-"))) (defn app-options [opts] (options opts "web-"))
Fix `random-nonce` function (wrong params).
;; This Source Code Form is subject to the terms of the Mozilla Public ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; ;; This Source Code Form is "Incompatible With Secondary Licenses", as ;; defined by the Mozilla Public License, v. 2.0. ;; ;; Copyright (c) 2020 Andrey Antukh <niwi@niwi.nz> (ns sodi.prng "Random data generation helpers." (:require [clojure.string :as str] [sodi.util :as util]) (:import java.security.SecureRandom java.nio.ByteBuffer)) (defonce ^:no-doc rng (SecureRandom.)) (defn random-bytes "Generate a byte array of scpecified length with random bytes taken from secure random number generator. This method should be used to generate a random iv/salt or arbitrary length." [^long numbytes] (let [buffer (byte-array numbytes)] (.nextBytes rng buffer) buffer)) (defn random-nonce "Generate a secure nonce based on current time and additional random data obtained from secure random generator. The minimum value is 8 bytes, and recommended minimum value is 32." [^long numbytes] (let [buffer (ByteBuffer/allocate numbytes)] (.putLong buffer (System/currentTimeMillis)) (.put buffer (random-bytes (.remaining buffer) rng)) (.array buffer)))
;; This Source Code Form is subject to the terms of the Mozilla Public ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; ;; This Source Code Form is "Incompatible With Secondary Licenses", as ;; defined by the Mozilla Public License, v. 2.0. ;; ;; Copyright (c) 2020 Andrey Antukh <niwi@niwi.nz> (ns sodi.prng "Random data generation helpers." (:require [clojure.string :as str] [sodi.util :as util]) (:import java.security.SecureRandom java.nio.ByteBuffer)) (defonce ^:no-doc rng (SecureRandom.)) (defn random-bytes "Generate a byte array of scpecified length with random bytes taken from secure random number generator. This method should be used to generate a random iv/salt or arbitrary length." [^long numbytes] (let [buffer (byte-array numbytes)] (.nextBytes rng buffer) buffer)) (defn random-nonce "Generate a secure nonce based on current time and additional random data obtained from secure random generator. The minimum value is 8 bytes, and recommended minimum value is 32." [^long numbytes] (let [buffer (ByteBuffer/allocate numbytes)] (.putLong buffer (System/currentTimeMillis)) (.put buffer (random-bytes (.remaining buffer))) (.array buffer)))
Revert back to snapshot version.
;(defproject dsbdp "0.4.0-SNAPSHOT" (defproject dsbdp "0.3.0" :description "Dynamic Stream and Batch Data Processing (dsbdp)" :url "https://github.com/ruedigergad/dsbdp" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.8.0"] [org.clojure/core.async "0.2.374"] [clj-assorted-utils "1.17.1"] [org.clojure/tools.cli "0.3.3"]] :global-vars {*warn-on-reflection* true} :java-source-paths ["src-java"] ; :javac-options ["-target" "1.6" "-source" "1.6"] :profiles {:repl {:dependencies [[jonase/eastwood "0.2.2" :exclusions [org.clojure/clojure]]]}} :plugins [[lein-cloverage "1.0.6"]] :test2junit-output-dir "ghpages/test-results" :test2junit-run-ant true :html5-docs-docs-dir "ghpages/doc" :html5-docs-ns-includes #"^dsbdp.*" :html5-docs-repository-url "https://github.com/ruedigergad/dsbdp/blob/master" :aot :all :main dsbdp.main)
(defproject dsbdp "0.4.0-SNAPSHOT" ;(defproject dsbdp "0.3.0" :description "Dynamic Stream and Batch Data Processing (dsbdp)" :url "https://github.com/ruedigergad/dsbdp" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.8.0"] [org.clojure/core.async "0.2.374"] [clj-assorted-utils "1.17.1"] [org.clojure/tools.cli "0.3.3"]] :global-vars {*warn-on-reflection* true} :java-source-paths ["src-java"] ; :javac-options ["-target" "1.6" "-source" "1.6"] :profiles {:repl {:dependencies [[jonase/eastwood "0.2.2" :exclusions [org.clojure/clojure]]]}} :plugins [[lein-cloverage "1.0.6"]] :test2junit-output-dir "ghpages/test-results" :test2junit-run-ant true :html5-docs-docs-dir "ghpages/doc" :html5-docs-ns-includes #"^dsbdp.*" :html5-docs-repository-url "https://github.com/ruedigergad/dsbdp/blob/master" :aot :all :main dsbdp.main)
Move clj-time dependency to cmr-common-lib
(defproject nasa-cmr/cmr-umm-lib "0.1.0-SNAPSHOT" :description "The UMM (Unified Metadata Model) Library is responsible for defining the common domain model for Metadata Concepts in the CMR along with code to parse and generate the various dialects of each concept." :url "***REMOVED***projects/CMR/repos/cmr-umm-lib/browse" :dependencies [[org.clojure/clojure "1.6.0"] [nasa-cmr/cmr-common-lib "0.1.1-SNAPSHOT"] [nasa-cmr/cmr-spatial-lib "0.1.0-SNAPSHOT"] [camel-snake-kebab "0.1.5"] [clj-time "0.7.0"]] :plugins [[lein-test-out "0.3.1"]] :profiles {:dev {:dependencies [[org.clojure/tools.namespace "0.2.4"] [org.clojars.gjahad/debug-repl "0.3.3"]] :source-paths ["src" "dev" "test"]}})
(defproject nasa-cmr/cmr-umm-lib "0.1.0-SNAPSHOT" :description "The UMM (Unified Metadata Model) Library is responsible for defining the common domain model for Metadata Concepts in the CMR along with code to parse and generate the various dialects of each concept." :url "***REMOVED***projects/CMR/repos/cmr-umm-lib/browse" :dependencies [[org.clojure/clojure "1.6.0"] [nasa-cmr/cmr-common-lib "0.1.1-SNAPSHOT"] [nasa-cmr/cmr-spatial-lib "0.1.0-SNAPSHOT"] [camel-snake-kebab "0.1.5"]] :plugins [[lein-test-out "0.3.1"]] :profiles {:dev {:dependencies [[org.clojure/tools.namespace "0.2.4"] [org.clojars.gjahad/debug-repl "0.3.3"]] :source-paths ["src" "dev" "test"]}})
Fix a reflection warning on a static method argument type
(ns caesium.util "Internal utilities. This ns is not considered public API, and may break without semver major version increments." (:import (java.util Arrays) (org.apache.commons.codec.binary Hex))) (defn unhexify [^String s] (.decode (Hex.) (.getBytes s))) (defn hexify [b] (Hex/encodeHexString b)) (defn n->bytes "Turns n into a byte array of length len." [len n] (let [unpadded (.toByteArray (biginteger n)) bytelen (alength unpadded) output (byte-array len)] (System/arraycopy unpadded 0 output (- len bytelen) bytelen) output))
(ns caesium.util "Internal utilities. This ns is not considered public API, and may break without semver major version increments." (:import (java.util Arrays) (org.apache.commons.codec.binary Hex))) (defn unhexify [^String s] (.decode (Hex.) (.getBytes s))) (defn hexify [^bytes b] (Hex/encodeHexString b)) (defn n->bytes "Turns n into a byte array of length len." [len n] (let [unpadded (.toByteArray (biginteger n)) bytelen (alength unpadded) output (byte-array len)] (System/arraycopy unpadded 0 output (- len bytelen) bytelen) output))
Add async state transformation test.
(ns potok.tests (:require [cljs.test :as t :include-macros true] [beicon.core :as rx] [potok.core :as ptk])) (enable-console-print!) (defrecord IncrementBy [n] ptk/UpdateEvent (update [_ state] (update state :counter + n))) (defrecord AsyncIncrementBy [n] ptk/WatchEvent (watch [_ state stream] (rx/of (->IncrementBy n)))) (t/deftest synchronous-state-transformation-test (t/async done (let [store (ptk/store {:state {:counter 0}})] (-> (rx/take 1 store) (rx/subscribe (fn [{:keys [counter]}] (t/is (= counter 1))) nil done)) (ptk/emit! store (->IncrementBy 1))))) (set! *main-cli-fn* #(t/run-tests)) (defmethod t/report [:cljs.test/default :end-run-tests] [m] (if (t/successful? m) (set! (.-exitCode js/process) 0) (set! (.-exitCode js/process) 1)))
(ns potok.tests (:require [cljs.test :as t :include-macros true] [beicon.core :as rx] [potok.core :as ptk])) (enable-console-print!) (defrecord IncrementBy [n] ptk/UpdateEvent (update [_ state] (update state :counter + n))) (defrecord AsyncIncrementBy [n] ptk/WatchEvent (watch [_ state stream] (rx/of (->IncrementBy n)))) (t/deftest synchronous-state-transformation-test (t/async done (let [store (ptk/store {:state {:counter 0}})] (-> (rx/take 1 store) (rx/subscribe (fn [{:keys [counter]}] (t/is (= counter 1))) nil done)) (ptk/emit! store (->IncrementBy 1))))) (t/deftest asynchronous-state-transformation-test (t/async done (let [store (ptk/store {:state {:counter 0}})] (-> (rx/take 1 store) (rx/subscribe (fn [{:keys [counter]}] (t/is (= counter 2))) nil done)) (ptk/emit! store (->AsyncIncrementBy 2))))) (set! *main-cli-fn* #(t/run-tests)) (defmethod t/report [:cljs.test/default :end-run-tests] [m] (if (t/successful? m) (set! (.-exitCode js/process) 0) (set! (.-exitCode js/process) 1)))
Change the event handler into something more sensible.
(ns squelch.nodes.script-processor) ; ----------- ; Properties: ; ----------- (defn get-buffer-size "Read only. Returns an integer representing both the input and output buffer size. It's value can be a power of 2 value in the range 256–16384." [buffer-source] (.-bufferSize buffer-source)) ; --------------- ; Event handlers: ; --------------- (defn get-on-audio-process "Represents the EventHandler to be called." [buffer-source] (.-onaudioprocess buffer-source)) (defn set-on-audio-process "Represents the EventHandler to be called." [buffer-source audio-process-fn] (set! (.-onaudioprocess buffer-source) audio-process-fn))
(ns squelch.nodes.script-processor) ; ----------- ; Properties: ; ----------- (defn get-buffer-size "Read only. Returns an integer representing both the input and output buffer size. It's value can be a power of 2 value in the range 256–16384." [buffer-source] (.-bufferSize buffer-source)) ; --------------- ; Event handlers: ; --------------- (defn set-on-audio-process "Represents the EventHandler to be called. Instead of receiving the raw audio event the function receives input and output audio buffers. The signature of the handler should be [input-buffer output-buffer]." [buffer-source audio-process-fn] (let [process-proxy (fn [audio-event] (let [input-buffer (.-inputBuffer audio-event) output-buffer (.-outputBuffer audio-event)] (audio-process-fn input-buffer output-buffer)))] (set! (.-onaudioprocess buffer-source) process-proxy)))
Add example of do-it macro
(ns examples.describe1 (:use lazytest.describe)) (describe + (it "computes the sum of 3 and 4" (= 7 (+ 3 4)))) (describe + "given any 2 integers" (for [x (range 5), y (range 5)] (it "is commutative" (= (+ x y) (+ y x))))) (describe + (describe "with integers" (it "computes sums of small numbers" (= 7 (+ 3 4))) (it "computes sums of large numbers" (= 7000000 (+ 3000000 4000000)))) (describe "with floating point" (it "computes sums of small numbers" (= 0.0000007 (+ 0.0000003 0.0000004))) (it "computes sums of large numbers" (= 7000000.0 (+ 3000000.0 4000000.0)))))
(ns examples.describe1 (:use lazytest.describe)) (describe + (it "computes the sum of 3 and 4" (= 7 (+ 3 4)))) (describe + "given any 2 integers" (for [x (range 5), y (range 5)] (it "is commutative" (= (+ x y) (+ y x))))) (describe + (describe "with integers" (it "computes sums of small numbers" (= 7 (+ 3 4))) (it "computes sums of large numbers" (= 7000000 (+ 3000000 4000000)))) (describe "with floating point" (it "computes sums of small numbers" (= 0.0000007 (+ 0.0000003 0.0000004))) (it "computes sums of large numbers" (= 7000000.0 (+ 3000000.0 4000000.0))))) (describe "The do-it macro" (do-it "allows arbitrary code" (println "Hello, do-it!") (println "This test will succeed because it doesn't throw.")))
Reduce step size to travel back in time
(ns discuss.history (:require [discuss.utils.common :as lib])) (def discussion-history (atom [@lib/app-state])) (add-watch lib/app-state :history (fn [_ _ _ n] (when-not (= (last @discussion-history) n) (swap! discussion-history conj n)))) (defn back! "Travel one unit back in time!" [] (when (> (count @discussion-history) 1) (dotimes [_ 3] ; Workaround, because one action are currently x atom changes (swap! discussion-history pop)) (reset! lib/app-state (last @discussion-history))))
(ns discuss.history (:require [discuss.utils.common :as lib])) (def discussion-history (atom [@lib/app-state])) (add-watch lib/app-state :history (fn [_ _ _ n] (when-not (= (last @discussion-history) n) (swap! discussion-history conj n)))) (defn back! "Travel one unit back in time!" [] (when (> (count @discussion-history) 1) (dotimes [_ 2] ; Workaround, because one action are currently x atom changes (swap! discussion-history pop)) (reset! lib/app-state (last @discussion-history))))
Make the MessageFormatter work with keys
(ns rads.kafka.transit.MsgpackMessageFormatter (:require [cognitect.transit :as transit] [clojure.java.io :as io]) (:import (kafka.common MessageFormatter) (java.io PrintStream ByteArrayInputStream) (java.util Properties) (org.apache.kafka.clients.consumer ConsumerRecord)) (:gen-class :implements [kafka.common.MessageFormatter] :constructors {[] []})) (defn -init [this ^Properties props]) (defn -writeTo [this ^ConsumerRecord record ^PrintStream output] (let [input-stream (ByteArrayInputStream. (.value record)) reader (transit/reader input-stream :msgpack)] (.println output (pr-str (transit/read reader))))) (defn -close [this])
(ns rads.kafka.transit.MsgpackMessageFormatter (:require [cognitect.transit :as transit] [clojure.java.io :as io]) (:import (kafka.common MessageFormatter) (java.io PrintStream ByteArrayInputStream) (java.util Properties) (org.apache.kafka.clients.consumer ConsumerRecord)) (:gen-class :implements [kafka.common.MessageFormatter] :init init-state :state state :constructors {[] []})) (defn -init [this ^Properties props] (swap! (.state this) assoc :props props)) (defn -init-state [] [[] (atom {:props nil})]) (defn read-transit [value] (let [input-stream (ByteArrayInputStream. value) reader (transit/reader input-stream :msgpack)] (transit/read reader))) (defn -writeTo [this ^ConsumerRecord record ^PrintStream output] (when (.get (:props @(.state this)) "print.key") (.print output (str (pr-str (read-transit (.key record))) " "))) (.println output (pr-str (read-transit (.value record))))) (defn -close [this])
Change return format of query results
(ns decktouch.mtg-card-master (:require [clojure.data.json :as json])) (def mtg-cards (json/read-str (slurp "resources/AllCards.json"))) (def card-names (keys mtg-cards)) (defn match "Returns true if query is a substring in string" [query string] (some? (re-matches (re-pattern (str "(?i)" query ".*")) string))) (defn get-cards-matching-query "Return a list of maps of strings of card names that match the query for the card input autocomplete" [query] (let [match-query (partial match query)] (map (fn [thing] {:cardName thing}) (filter match-query card-names))))
(ns decktouch.mtg-card-master (:require [clojure.data.json :as json])) (def mtg-cards (json/read-str (slurp "resources/AllCards.json"))) (def card-names (keys mtg-cards)) (defn match "Returns true if query is a substring in string" [query string] (some? (re-matches (re-pattern (str "(?i)" query ".*")) string))) (defn get-cards-matching-query "Return a list of maps of strings of card names that match the query for the card input autocomplete" [query] (let [match-query (partial match query)] (map (fn [thing] (str thing)) (filter match-query card-names))))
Update buddy-core dependency to 0.9.0.
(defproject buddy/buddy-hashers "0.9.1" :description "A collection of secure password hashers for Clojure" :url "https://github.com/funcool/buddy-hashers" :license {:name "Apache 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0"} :dependencies [[org.clojure/clojure "1.7.0" :scope "provided"] [buddy/buddy-core "0.8.1"] [clojurewerkz/scrypt "1.2.0"]] :source-paths ["src/clojure"] :java-source-paths ["src/java"] :javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"] :test-paths ["test"])
(defproject buddy/buddy-hashers "0.9.1" :description "A collection of secure password hashers for Clojure" :url "https://github.com/funcool/buddy-hashers" :license {:name "Apache 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0"} :dependencies [[org.clojure/clojure "1.7.0" :scope "provided"] [buddy/buddy-core "0.9.0"] [clojurewerkz/scrypt "1.2.0"]] :source-paths ["src/clojure"] :java-source-paths ["src/java"] :javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"] :test-paths ["test"])
Update Apache Commons FileUpload to 1.3.1
(defproject ring/ring-core "1.3.2" :description "Ring core libraries." :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.3.0"] [org.clojure/tools.reader "0.8.1"] [ring/ring-codec "1.0.0"] [commons-io "2.4"] [commons-fileupload "1.3"] [clj-time "0.9.0"] [crypto-random "1.2.0"] [crypto-equality "1.0.0"]] :profiles {:provided {:dependencies [[javax.servlet/servlet-api "2.5"]]} :dev {:dependencies [[javax.servlet/servlet-api "2.5"]]} :1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]} :1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]} :1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}})
(defproject ring/ring-core "1.3.2" :description "Ring core libraries." :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.3.0"] [org.clojure/tools.reader "0.8.1"] [ring/ring-codec "1.0.0"] [commons-io "2.4"] [commons-fileupload "1.3.1"] [clj-time "0.9.0"] [crypto-random "1.2.0"] [crypto-equality "1.0.0"]] :profiles {:provided {:dependencies [[javax.servlet/servlet-api "2.5"]]} :dev {:dependencies [[javax.servlet/servlet-api "2.5"]]} :1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]} :1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]} :1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}})
Update dep because file descriptor leak bug in 1.3.0
(defproject tailrecursion/boot "0.1.0-SNAPSHOT" :description "Dependency setup/build tool for Clojure" :url "https://github.com/tailrecursion/boot" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.5.1"] [com.cemerick/pomegranate "0.2.0" :exclusions [org.clojure/clojure]] ; for pom middleware [org.apache.maven/maven-model "3.0.4" :exclusions [org.codehaus.plexus/plexus-utils]] ; for cljsbuild middleware [org.clojure/clojurescript "0.0-1820"] ; for mtime middleware [digest "1.3.0"]] :main tailrecursion.boot)
(defproject tailrecursion/boot "0.1.0-SNAPSHOT" :description "Dependency setup/build tool for Clojure" :url "https://github.com/tailrecursion/boot" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.5.1"] [com.cemerick/pomegranate "0.2.0" :exclusions [org.clojure/clojure]] ; for pom middleware [org.apache.maven/maven-model "3.0.4" :exclusions [org.codehaus.plexus/plexus-utils]] ; for cljsbuild middleware [org.clojure/clojurescript "0.0-1820"] ; for mtime middleware [digest "1.4.3"]] :main tailrecursion.boot)
Upgrade version of incise being used.
(defproject fixturex/fixturex "0.2.1" :description "A library of helpful test fixture macros and functions." :url "http://www.ryanmcg.com/fixturex/" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.6.0"]] :repack [{:type :clojure :levels 1 :path "src"}] :profiles {:dev {:dependencies [[incise-markdown-parser "0.2.0"] [incise-git-deployer "0.1.0"] [com.ryanmcg/incise-codox "0.1.0"] [incise-core "0.4.0"] [com.ryanmcg/incise-vm-layout "0.5.0"]] :plugins [[lein-repack "0.2.4"]] :aliases {"incise" ^:pass-through-help ["run" "-m" "incise.core"]}} :1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]} :1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]} :1.7 {:dependencies [[org.clojure/clojure "1.7.0-alpha4"]]}})
(defproject fixturex/fixturex "0.2.1" :description "A library of helpful test fixture macros and functions." :url "http://www.ryanmcg.com/fixturex/" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.6.0"]] :repack [{:type :clojure :levels 1 :path "src"}] :profiles {:dev {:dependencies [[incise "0.5.0"] [com.ryanmcg/incise-codox "0.1.0"] [com.ryanmcg/incise-vm-layout "0.5.0"]] :plugins [[lein-repack "0.2.4"]] :aliases {"incise" ^:pass-through-help ["run" "-m" "incise.core"]}} :1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]} :1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]} :1.7 {:dependencies [[org.clojure/clojure "1.7.0-alpha4"]]}})
Change namespace, description, URL to this fork's.
(defproject org.clojars.pntblnk/clj-ldap "0.0.9" :description "Clojure ldap client (development fork of alienscience's clj-ldap)." :url "https://github.com/pauldorman/clj-ldap" :dependencies [[org.clojure/clojure "1.3.0"] [com.unboundid/unboundid-ldapsdk "2.3.0"]] :dev-dependencies [[jline "0.9.94"] [org.apache.directory.server/apacheds-all "1.5.5"] [fs "1.1.2"] [org.slf4j/slf4j-simple "1.5.6"] [lein-clojars "0.7.0"]] :aot [clj-ldap.client] :license {:name "Eclipse Public License - v 1.0" :url "http://www.eclipse.org/legal/epl-v10.html" :distribution :repo :comments "same as Clojure"})
(defproject puppetlabs/clj-ldap "0.0.9" :description "Clojure ldap client (Puppet Labs's fork)." :url "https://github.com/puppetlabs/clj-ldap" :dependencies [[org.clojure/clojure "1.3.0"] [com.unboundid/unboundid-ldapsdk "2.3.0"]] :dev-dependencies [[jline "0.9.94"] [org.apache.directory.server/apacheds-all "1.5.5"] [fs "1.1.2"] [org.slf4j/slf4j-simple "1.5.6"] [lein-clojars "0.7.0"]] :aot [clj-ldap.client] :license {:name "Eclipse Public License - v 1.0" :url "http://www.eclipse.org/legal/epl-v10.html" :distribution :repo :comments "same as Clojure"})
Add and rename REPL functions
(ns play-clj.repl (:require [play-clj.core :refer :all])) (defn entities "Returns the entities in `screen-object`, optionally filtered by a supplied function. (entities main-screen :player)" ([screen-object] (-> screen-object :entities deref)) ([screen-object filter-fn] (filter filter-fn (entities screen-object)))) (defn entities! "Associates values to the entities in `screen-object` that match the supplied function. (entities! main-screen :player :health 10)" [screen-object filter-fn & args] (on-gl (swap! (:entities screen-object) (fn [entities] (for [e entities] (if (filter-fn e) (apply assoc e args) e))))) (entities screen-object filter-fn))
(ns play-clj.repl (:require [play-clj.core :refer :all])) (defn s "Returns the screen map in `screen-object`. (s main-screen)" [screen-object] (-> screen-object :screen deref)) (defn s! "Associates values to the screen map in `screen-object`. Returns the new screen map. (s! main-screen :camera (orthographic))" [screen-object & args] (apply swap! (:screen screen-object) assoc args)) (defn e "Returns the entities in `screen-object`, optionally filtered by a supplied function. (e main-screen :player)" ([screen-object] (-> screen-object :entities deref)) ([screen-object filter-fn] (filter filter-fn (e screen-object)))) (defn e! "Resets the entities in `screen-object`, or associates values to the entities in `screen-object` that match the supplied function. Returns the entities that were changed. (e! main-screen []) (e! main-screen :player :health 10)" ([screen-object new-entities] (reset! (:entities screen-object) new-entities)) ([screen-object filter-fn & args] (swap! (:entities screen-object) (fn [entities] (for [e entities] (if (filter-fn e) (apply assoc e args) e)))) (e screen-object filter-fn)))
Sort files by publish date in RSS feed.
(ns io.perun.rss (:require [io.perun.core :as perun] [clj-rss.core :as rss-gen])) (defn rss-definitions [files] (for [file files] {:link (:canonical-url file) :guid (:canonical-url file) :pubDate (:date-published file) :title (:title file) :description (:description file) :author (:author-email file)})) (defn generate-rss-str [files options] (let [rss-options {:title (:site-title options) :description (:description options) :link (:base-url options)} items (rss-definitions (filter :title files)) rss-str (apply rss-gen/channel-xml rss-options items)] rss-str)) (defn generate-rss [tgt-path files options] (let [rss-filepath (str (:out-dir options) "/" (:filename options)) rss-string (generate-rss-str files options)] (perun/create-file tgt-path rss-filepath rss-string) (perun/report-info "rss" "generated RSS feed and saved to %s" rss-filepath)))
(ns io.perun.rss (:require [io.perun.core :as perun] [clj-rss.core :as rss-gen])) (defn rss-definitions [files] (reverse (sort-by :pubDate (for [file files] {:link (:canonical-url file) :guid (:canonical-url file) :pubDate (:date-published file) :title (:title file) :description (:description file) :author (:author-email file)})))) (defn generate-rss-str [files options] (let [rss-options {:title (:site-title options) :description (:description options) :link (:base-url options)} items (rss-definitions (filter :title files)) rss-str (apply rss-gen/channel-xml rss-options items)] rss-str)) (defn generate-rss [tgt-path files options] (let [rss-filepath (str (:out-dir options) "/" (:filename options)) rss-string (generate-rss-str files options)] (perun/create-file tgt-path rss-filepath rss-string) (perun/report-info "rss" "generated RSS feed and saved to %s" rss-filepath)))
Fix unused var warning, rename widget to app
(ns iss.core (:require [om.core :as om :include-macros true] [om.dom :as dom :include-macros true] [iss.constants :refer [black white system-font-large]]) (:require-macros [iss.macros :as macros :refer [defstyles]])) (enable-console-print!) (def app-state (atom {:foo "bar"})) (defn widget [data owner] (reify om/ICheckState om/IInitState (init-state [_] {:count 0}) om/IWillMount (will-mount [_] (println "Hello widget mounting")) om/IWillUnmount (will-unmount [_] (println "Hello widget unmounting")) om/IRenderState (render-state [_ {:keys [count]}] (println "Render!") (dom/div #js {:className (.-container bump-app)} (dom/h2 nil "Hello world!") (dom/p nil (str "Count: " count)) (dom/button #js {:onClick #(do (println "I can read!" (:foo data)) (om/update-state! owner :count inc))} "Bump!") (dom/button #js {:onClick #(do (println "I can also read!" (:foo data)) (om/update-state! owner :count identity))} "Do Nothing"))))) (defstyles bump-app {:container {:backgroundColor white :color black :font system-font-large}}) (om/root widget app-state {:target (.-body js/document)})
(ns iss.core (:require [om.core :as om :include-macros true] [om.dom :as dom :include-macros true] [iss.constants :refer [black white system-font-large]]) (:require-macros [iss.macros :as macros :refer [defstyles]])) (enable-console-print!) (def app-state (atom {:foo "bar"})) (defstyles bump-app {:container {:backgroundColor white :color black :font system-font-large}}) (defn app [data owner] (reify om/ICheckState om/IInitState (init-state [_] {:count 0}) om/IWillMount (will-mount [_] (println "Hello app mounting")) om/IWillUnmount (will-unmount [_] (println "Hello app unmounting")) om/IRenderState (render-state [_ {:keys [count]}] (println "Render!") (dom/div #js {:className (.-container bump-app)} (dom/h2 nil "Hello world!") (dom/p nil (str "Count: " count)) (dom/button #js {:onClick #(do (println "I can read!" (:foo data)) (om/update-state! owner :count inc))} "Bump!") (dom/button #js {:onClick #(do (println "I can also read!" (:foo data)) (om/update-state! owner :count identity))} "Do Nothing"))))) (om/root app app-state {:target (.-body js/document)})
Stop using renamed junit task configuration
(set-env! :source-paths #{"src"} :resource-paths #{"src"} :dependencies '[[org.clojure/clojure "1.6.0" :scope "provided"] [boot/core "2.1.0" :scope "provided"] [junit "4.12" :scope "test"] [radicalzephyr/bootlaces "0.1.15-SNAPSHOT"]]) (require '[radicalzephyr.bootlaces :refer :all] '[radicalzephyr.boot-junit :refer [junit]]) (def +version+ "0.3.0-SNAPSHOT") (bootlaces! +version+) (task-options! pom {:project 'radicalzephyr/boot-junit :version +version+ :description "Run some jUnit tests in boot!" :url "https://github.com/radicalzephyr/boot-junit" :scm {:url "https://github.com/radicalzephyr/boot-junit"} :license {"Eclipse Public License" "http://www.eclipse.org/legal/epl-v10.html"}} junit {:packages '#{radicalzephyr.boot_junit.test}})
(set-env! :source-paths #{"src"} :resource-paths #{"src"} :dependencies '[[org.clojure/clojure "1.6.0" :scope "provided"] [boot/core "2.1.0" :scope "provided"] [junit "4.12" :scope "test"] [radicalzephyr/bootlaces "0.1.15-SNAPSHOT"]]) (require '[radicalzephyr.bootlaces :refer :all] '[radicalzephyr.boot-junit :refer [junit]]) (def +version+ "0.3.0-SNAPSHOT") (bootlaces! +version+) (task-options! pom {:project 'radicalzephyr/boot-junit :version +version+ :description "Run some jUnit tests in boot!" :url "https://github.com/radicalzephyr/boot-junit" :scm {:url "https://github.com/radicalzephyr/boot-junit"} :license {"Eclipse Public License" "http://www.eclipse.org/legal/epl-v10.html"}})
Revert back to stock lein-bin
(defproject kwho "0.1.0" :description "FIXME: write description" :url "https://github.com/jacobmorzinski/kwho" :license {:name "The MIT License" :url "http://opensource.org/licenses/MIT"} :dependencies [[org.clojure/clojure "1.6.0"]] :plugins [[lein-bin "0.3.6-SNAPSHOT"]] #_ "https://github.com/jacobmorzinski/lein-bin" :bin {:name "kwho.bat"} #_ "I wish I could use a conditional..." :main ^:skip-aot kwho.core :target-path "target/%s" :jar-exclusions [#"(^|\\|/)[._](.*\.|)s[a-w][a-z]$"] #_ "vim .swp files" :profiles {:uberjar {:aot :all}})
(defproject kwho "0.1.0" :description "FIXME: write description" :url "https://github.com/jacobmorzinski/kwho" :license {:name "The MIT License" :url "http://opensource.org/licenses/MIT"} :dependencies [[org.clojure/clojure "1.6.0"]] :plugins [[lein-bin "0.3.5"]] #_ "https://github.com/jacobmorzinski/lein-bin" :bin {:name "kwho.bat"} #_ "I wish I could use a conditional..." :main ^:skip-aot kwho.core :target-path "target/%s" :jar-exclusions [#"(^|\\|/)[._](.*\.|)s[a-w][a-z]$"] #_ "vim .swp files" :profiles {:uberjar {:aot :all}})
Add lein-pprint for complete profile
{:user {:plugins [[lein-vanity "0.2.0" :exclusions [org.clojure/clojure]] [lein-ancient "0.6.15"] [lein-hiera "1.0.0"] [lein-kibit "0.1.6"] [jonase/eastwood "0.2.9"] ;;[com.billpiel/sayid "0.0.10"] [lein-cljfmt "0.6.0"]] :dependencies [[slamhound "1.5.5"]] :aliases {"slamhound" ["run" "-m" "slam.hound"]}}}
{:user {:plugins [[lein-vanity "0.2.0" :exclusions [org.clojure/clojure]] [lein-ancient "0.6.15"] [lein-hiera "1.0.0"] [lein-kibit "0.1.6"] [lein-pprint "1.2.0"] [jonase/eastwood "0.2.9"] ;;[com.billpiel/sayid "0.0.10"] [lein-cljfmt "0.6.0"]] :dependencies [[slamhound "1.5.5"]] :aliases {"slamhound" ["run" "-m" "slam.hound"]}}}
Use a def for the short code length
(ns uuuurrrrllll.cassandra (:require [uuuurrrrllll.util :refer [gen-short-url]] [com.stuartsierra.component :as component]) (:use [clojurewerkz.cassaforte.client :as client] [clojurewerkz.cassaforte.cql] [clojurewerkz.cassaforte.query])) (def default-hosts ["localhost"]) (def keyspace "uuuurrrrllll") (def pastes "pastes") (def table "message") (defprotocol URLShortener (add-entry! [shortener body]) (get-entry [shortener short-code])) (defrecord Cassandra [conn] component/Lifecycle (start [cass] (let [conn (client/connect default-hosts)] (use-keyspace conn keyspace) (assoc cass :conn conn))) (stop [cass] (client/disconnect! conn)) URLShortener (add-entry! [cass body] (let [short-url (gen-short-url 5)] (insert (:conn cass) table (assoc body :short_url short-url)) short-url)) (get-entry [cass short-code] (first (select (:conn cass) table (where [[= :short_url short-code]]) (allow-filtering true)))))
(ns uuuurrrrllll.cassandra (:require [uuuurrrrllll.util :refer [gen-short-url]] [com.stuartsierra.component :as component]) (:use [clojurewerkz.cassaforte.client :as client] [clojurewerkz.cassaforte.cql] [clojurewerkz.cassaforte.query])) (def default-hosts ["localhost"]) (def keyspace "uuuurrrrllll") (def pastes "pastes") (def table "message") (def short-code-length 5) (defprotocol URLShortener (add-entry! [shortener body]) (get-entry [shortener short-code])) (defrecord Cassandra [conn] component/Lifecycle (start [cass] (let [conn (client/connect default-hosts)] (use-keyspace conn keyspace) (assoc cass :conn conn))) (stop [cass] (client/disconnect! conn)) URLShortener (add-entry! [cass body] (let [short-url (gen-short-url short-code-length)] (insert (:conn cass) table (assoc body :short_url short-url)) short-url)) (get-entry [cass short-code] (first (select (:conn cass) table (where [[= :short_url short-code]]) (allow-filtering true)))))
Write some tests for log-batch
(ns desdemona.lifecycles.logging-test (:require [desdemona.lifecycles.logging :as l] [clojure.test :refer [deftest is]])) (deftest log-batch-tests)
(ns desdemona.lifecycles.logging-test (:require [desdemona.lifecycles.logging :as l] [desdemona.test-macros :refer [with-out-str-and-result]] [clojure.test :refer [deftest is]] [clojure.string :as s] [clojure.core.match :refer [match]])) (def sample-event {:onyx.core/task-map {:onyx/name "xyzzy"} :onyx.core/results {:tree [{:leaves [{:message 1} {:message 2} {:message 3}]} {:leaves [{:message 4} {:message 5} {:message 6}]} {:leaves [{:message 7} {:message 8} {:message 9}]}]}}) (def sample-lifecycle nil) (deftest log-batch-tests (let [[result stdout] (with-out-str-and-result (l/log-batch sample-event sample-lifecycle)) lines (map #(s/split % #" " 7) (s/split-lines stdout)) parsed-lines (map (fn [line] (match [line] [[date time hostname level source sep message]] {:date date :time time :hostname hostname :level level :source source :sep sep :message message})) lines) match-message (fn [message] (-> #"xyzzy logging segment: (?<n>\d)" (re-matches message) (second)))] (is (= {} result)) (is (= (count lines) 9)) (is (apply = (map :hostname parsed-lines))) (is (apply = "INFO" (map :level parsed-lines))) (is (apply = "[desdemona.lifecycles.logging]" (map :source parsed-lines))) (is (apply = "-" (map :sep parsed-lines))) (is (= (map str (range 1 10)) (map (comp match-message :message) parsed-lines)))))
Add docstrings to the ->>asserts
(ns detritus.pred) (defn ->ensure ([v pred] (->ensure v pred "->assert failed!")) ([v pred error] (if (pred v) v (assert false error)))) (defn ->>ensure ([pred v] (->>ensure pred "->>assert failed!" v)) ([pred error v] (if (pred v) v (assert false error)))) (defn maybe-fix [pred resolution] (fn [x] (if-not (pred x) (resolution x) x)))
(ns detritus.pred) (defn ->assert "(λ T → ((λ T) → Bool)) → T (λ T → ((λ T) → Bool) → String) → T Function of a value, a predicate and optionally a string. If the predicate is not true of the value, this function will assert false giving the optional string or \"->assert failed!\" as the failure message. Otherwise returns the argument value. Example: (-> 1 inc inc dec (->assert number? \"oh god the types\"))" ([v pred] (->ensure v pred "->assert failed!")) ([v pred error] (if (pred v) v (assert false error)))) (defn ->>assert "(λ ((λ T) → Bool) → T) → T (λ ((λ T) → Bool) → T → String) → T Function of a predicate, optionally a string and a value. If the predicate is not true of the value, this function will assert false giving the optional string or \"->assert failed!\" as the failure message. Otherwise returns the argument value. Example: (->> 1 inc inc dec (->>assert number? \"oh god the types\"))" ([pred v] (->>ensure pred "->>assert failed!" v)) ([pred error v] (if (pred v) v (assert false error)))) (defn maybe-fix [pred resolution] (fn [x] (if-not (pred x) (resolution x) x)))
Fix setting Slack token :scream_cat:
(ns metabase.api.slack "/api/slack endpoints" (:require [clojure.set :as set] [clojure.tools.logging :as log] [compojure.core :refer [PUT]] [metabase.api.common :refer :all] [metabase.config :as config] [metabase.integrations.slack :as slack])) (defendpoint PUT "/settings" "Update the `slack-token`. You must be a superuser to do this." [:as {{slack-token :slack-token} :body}] {slack-token [Required NonEmptyString]} (check-superuser) (try ;; just check that channels.list doesn't throw an exception (that the connection works) (when-not config/is-test? (slack/GET :channels.list, :exclude_archived 1, :token slack-token)) {:ok true} (catch clojure.lang.ExceptionInfo info {:status 400, :body (ex-data info)}))) (define-routes)
(ns metabase.api.slack "/api/slack endpoints" (:require [clojure.set :as set] [clojure.tools.logging :as log] [compojure.core :refer [PUT]] [metabase.api.common :refer :all] [metabase.config :as config] [metabase.integrations.slack :as slack])) (defendpoint PUT "/settings" "Update the `slack-token`. You must be a superuser to do this." [:as {{slack-token :slack-token} :body}] {slack-token [Required NonEmptyString]} (check-superuser) (try ;; just check that channels.list doesn't throw an exception (that the connection works) (when-not config/is-test? (slack/GET :channels.list, :exclude_archived 1, :token slack-token)) (slack/slack-token slack-token) {:ok true} (catch clojure.lang.ExceptionInfo info {:status 400, :body (ex-data info)}))) (define-routes)
Use the fancy reply repl instead of raw trampoline.
{:user {:mirrors {"central" "http://s3pository.herokuapp.com/maven-central" ;; TODO: re-enable once clojars releases repo is up ;; "clojars" "http://s3pository.herokuapp.com/clojars" } :aliases {"repl" ["with-profile" "production" "trampoline" "repl"]}} :production {:mirrors {"central" "http://s3pository.herokuapp.com/maven-central" ;; "clojars" "http://s3pository.herokuapp.com/clojars" } :offline true} :heroku {:mirrors {"central" "http://s3pository.herokuapp.com/maven-central" ;; "clojars" "http://s3pository.herokuapp.com/clojars" }}}
{:user {:mirrors {"central" "http://s3pository.herokuapp.com/maven-central" ;; TODO: re-enable once clojars releases repo is up ;; "clojars" "http://s3pository.herokuapp.com/clojars" } :aliases {"repl" ["update-in" ":dependencies" "conj" "[reply \"0.1.6\"]" "--" "with-profile" "production" "trampoline" "run" "-m" "reply.main/launch-standalone" "nil"]}} :production {:mirrors {"central" "http://s3pository.herokuapp.com/maven-central" ;; "clojars" "http://s3pository.herokuapp.com/clojars" } :offline true} :heroku {:mirrors {"central" "http://s3pository.herokuapp.com/maven-central" ;; "clojars" "http://s3pository.herokuapp.com/clojars" }}}
Define board data structure and initial setup.
(ns chess.core (:require [om.core :as om :include-macros true] [om.dom :as dom :include-macros true])) (defonce app-state (atom {:text "Hello Chestnut!"})) (defn main [] (om/root (fn [app owner] (reify om/IRender (render [_] (dom/h1 nil (:text app))))) app-state {:target (. js/document (getElementById "app"))}))
(ns chess.core (:require [om.core :as om :include-macros true] [om.dom :as dom :include-macros true])) (def initial-board [[\r \n \b \q \k \b \n \r] [\p \p \p \p \p \p \p \p] [\. \. \. \. \. \. \. \.] [\. \. \. \. \. \. \. \.] [\. \. \. \. \. \. \. \.] [\. \. \. \. \. \. \. \.] [\P \P \P \P \P \P \P \P] [\R \N \B \Q \K \B \N \R]]) (defonce app-state (atom {:board initial-board})) (defn main [] (om/root (fn [app owner] (reify om/IRender (render [_] (dom/h1 nil (:text app))))) app-state {:target (. js/document (getElementById "app"))}))
Prepare for next release cycle.
(defproject org.onyxplatform/onyx-peer-http-query "0.10.0.0-beta4" :description "An Onyx health and query HTTP server" :url "https://github.com/onyx-platform/onyx-peer-http-query" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.8.0"] [ring/ring-core "1.5.1"] [org.clojure/java.jmx "0.3.3"] [ring-jetty-component "0.3.1"] [cheshire "5.7.0"] ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}} [org.onyxplatform/onyx "0.10.0-beta4"]] :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}} :profiles {:dev {:dependencies [[clj-http "3.4.1"]] :plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}})
(defproject org.onyxplatform/onyx-peer-http-query "0.10.0.0-SNAPSHOT" :description "An Onyx health and query HTTP server" :url "https://github.com/onyx-platform/onyx-peer-http-query" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.8.0"] [ring/ring-core "1.5.1"] [org.clojure/java.jmx "0.3.3"] [ring-jetty-component "0.3.1"] [cheshire "5.7.0"] ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}} [org.onyxplatform/onyx "0.10.0-beta4"]] :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}} :profiles {:dev {:dependencies [[clj-http "3.4.1"]] :plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}})
Update cljs compiler to 1.7.145
(defproject funcool/cats "1.1.0-SNAPSHOT" :description "Category Theory abstractions for Clojure" :url "https://github.com/funcool/cats" :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.107" :scope "provided"] [org.clojure/core.async "0.1.346.0-17112a-alpha" :scope "provided"] [manifold "0.1.0" :scope "provided"]] :deploy-repositories {"releases" :clojars "snapshots" :clojars} :source-paths ["src"] :test-paths ["test"] :jar-exclusions [#"\.swp|\.swo|user\.clj"])
(defproject funcool/cats "1.1.0-SNAPSHOT" :description "Category Theory abstractions for Clojure" :url "https://github.com/funcool/cats" :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.145" :scope "provided"] [org.clojure/core.async "0.1.346.0-17112a-alpha" :scope "provided"] [manifold "0.1.0" :scope "provided"]] :deploy-repositories {"releases" :clojars "snapshots" :clojars} :source-paths ["src"] :test-paths ["test"] :jar-exclusions [#"\.swp|\.swo|user\.clj"])
Prepare for next development iteration (0.4.0-SNAPSHOT)
(defproject jungerer "0.3.0" :description "Clojure network/graph library wrapping JUNG" :url "https://github.com/totakke/jungerer" :license {:name "The BSD 3-Clause License" :url "https://opensource.org/licenses/BSD-3-Clause"} :dependencies [[org.clojure/clojure "1.7.0"] [net.sf.jung/jung-algorithms "2.1.1"] [net.sf.jung/jung-api "2.1.1"] [net.sf.jung/jung-graph-impl "2.1.1"] [net.sf.jung/jung-io "2.1.1"] [net.sf.jung/jung-visualization "2.1.1"]] :profiles {:dev {:global-vars {*warn-on-reflection* true} :resource-paths ["dev-resources"]} :1.9 {:dependencies [[org.clojure/clojure "1.9.0-alpha12"]] :resource-paths ["dev-resources"]} :1.8 {:dependencies [[org.clojure/clojure "1.8.0"]] :resource-paths ["dev-resources"]}} :deploy-repositories [["snapshots" {:url "https://clojars.org/repo/" :username [:env/clojars_username :gpg] :password [:env/clojars_password :gpg]}]] :codox {:source-uri "https://github.com/totakke/jungerer/blob/{version}/{filepath}#L{line}"})
(defproject jungerer "0.4.0-SNAPSHOT" :description "Clojure network/graph library wrapping JUNG" :url "https://github.com/totakke/jungerer" :license {:name "The BSD 3-Clause License" :url "https://opensource.org/licenses/BSD-3-Clause"} :dependencies [[org.clojure/clojure "1.7.0"] [net.sf.jung/jung-algorithms "2.1.1"] [net.sf.jung/jung-api "2.1.1"] [net.sf.jung/jung-graph-impl "2.1.1"] [net.sf.jung/jung-io "2.1.1"] [net.sf.jung/jung-visualization "2.1.1"]] :profiles {:dev {:global-vars {*warn-on-reflection* true} :resource-paths ["dev-resources"]} :1.9 {:dependencies [[org.clojure/clojure "1.9.0-alpha12"]] :resource-paths ["dev-resources"]} :1.8 {:dependencies [[org.clojure/clojure "1.8.0"]] :resource-paths ["dev-resources"]}} :deploy-repositories [["snapshots" {:url "https://clojars.org/repo/" :username [:env/clojars_username :gpg] :password [:env/clojars_password :gpg]}]] :codox {:source-uri "https://github.com/totakke/jungerer/blob/{version}/{filepath}#L{line}"})
Update deps and version number.
(defproject cryogen/lein-template "0.6.2" :description "A Leiningen template for the Cryogen static site generator" :url "https://github.com/cryogen-project/cryogen" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :scm {:name "git" :url "https://github.com/cryogen-project/cryogen.git"} :dependencies [[org.clojure/core.unify "0.5.7"] [org.clojure/core.contracts "0.0.6"] [leinjacker "0.4.2" :exclusions [org.clojure/clojure org.clojure/core.contracts org.clojure/core.unify]] [org.clojure/tools.namespace "0.2.11" :exclusions [org.clojure/clojure]]] :eval-in-leiningen true)
(defproject cryogen/lein-template "0.6.3" :description "A Leiningen template for the Cryogen static site generator" :url "https://github.com/cryogen-project/cryogen" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :scm {:name "git" :url "https://github.com/cryogen-project/cryogen.git"} :dependencies [[org.clojure/core.unify "0.5.7"] [org.clojure/core.contracts "0.0.6"] [leinjacker "0.4.3" :exclusions [org.clojure/clojure org.clojure/core.contracts org.clojure/core.unify]] [org.clojure/tools.namespace "1.1.0" :exclusions [org.clojure/clojure]]] :eval-in-leiningen true)
Bring into line with other JVM implementations.
; This is a wrapper Clojure script that checks command line args and calls the ; methods we have defined in pi.clj. ; We could actually build in this script because of the way LISPs like Clojure ; work but that would mean building every time, so leave it to Make. (def n 10000000) (if (> (count *command-line-args*) 0) (def n(Integer/parseInt (first *command-line-args*))) ) (import 'pi) (println "Calculating PI using:") (println " " n "slices") (println " 1 processes") ; When referring to Java stuff the syntax is class/method. (def start (System/currentTimeMillis)) ; Call our function for estimating pi. (def mypi (pi/calcpi n)) (def stop (System/currentTimeMillis)) (def difference (/ (- stop start) 1000.0)) (println "Obtained value of PI:" mypi) (println "Time taken:" difference "seconds")
; This is a wrapper Clojure script that checks command line args and calls the ; methods we have defined in pi.clj. ; We could actually build in this script because of the way LISPs like Clojure ; work but that would mean building every time, so leave it to Make. (def n 50000000) (if (> (count *command-line-args*) 0) (def n(Integer/parseInt (first *command-line-args*))) ) (import 'pi) (println "Calculating PI using:") (println " " n "slices") (println " 1 processes") ; When referring to Java stuff the syntax is class/method. (def start (System/currentTimeMillis)) ; Call our function for estimating pi. (def mypi (pi/calcpi n)) (def stop (System/currentTimeMillis)) (def difference (/ (- stop start) 1000.0)) (println "Obtained value of PI:" mypi) (println "Time taken:" difference "seconds")
Tidy up indentation and clean up of generate-predicate-function.
(ns clj-record.query (:require [clojure.contrib.str-utils :as str-utils])) (defmacro generate-predicate [predicate join-predicate-params-with values] `(fn [attribute#] (let [[clause# params#] [(str-utils/str-join ~join-predicate-params-with (reduce (fn [predicate-params# value#] (conj predicate-params# (if (nil? value#) "NULL" "?"))) [] ~values)) (filter (complement nil?) ~values)]] [(format (str "%s " ~predicate) (name attribute#) clause#) params#]))) (defn between [value1 value2] (generate-predicate "BETWEEN %s" " AND " [value1 value2])) (defn in [& values] (generate-predicate "IN (%s)" ", " values)) (defn like [value] (generate-predicate "LIKE %s" "" [value]))
(ns clj-record.query (:require [clojure.contrib.str-utils :as str-utils])) (defn- generate-predicate-fn [predicate join-predicate-params-with values] (fn [attribute] (let [[clause params] [(str-utils/str-join join-predicate-params-with (reduce (fn [predicate-params value] (conj predicate-params (if (nil? value) "NULL" "?"))) [] values)) (filter (complement nil?) values)]] [(format (str "%s " predicate) (name attribute) clause) params]))) (defn between [value1 value2] (generate-predicate-fn "BETWEEN %s" " AND " [value1 value2])) (defn in [& values] (generate-predicate-fn "IN (%s)" ", " values)) (defn like [value] (generate-predicate-fn "LIKE %s" "" [value]))
Add WormBase signing key identity.
{:user { :plugins [[cider/cider-nrepl "0.12.0"] [lein-ancient "0.6.8"] [lein-bikeshed "0.3.0"] [jonase/eastwood "0.2.3"] [lein-kibit "0.1.2"] [lein-pprint "1.1.1"]] :dependencies [[org.clojure/clojure "1.7.0"] [org.clojure/tools.reader "1.0.0-alpha3"] [com.cemerick/url "0.1.1"] [datomic-schema-grapher "0.0.1"] [com.datomic/datomic-pro "0.9.5350"] [me.raynes/fs "1.4.6"] [clj-stacktrace "0.2.8"] [acyclic/squiggly-clojure "0.1.5"] ^:replace [org.clojure/tools.nrepl "0.2.12"] ;; Consider using typed? [org.clojure/core.typed "0.3.22"] ] } ;; VisualVM profiling opts :jvm-opts ["-Dcom.sun.management.jmxremote" "-Dcom.sun.management.jmxremote.ssl=false" "-Dcom.sun.management.jmxremote.authenticate=false" "-Dcom.sun.management.jmxremote.port=43210"]}
{:user { :plugins [[cider/cider-nrepl "0.12.0"] [lein-ancient "0.6.8"] [lein-bikeshed "0.3.0"] [jonase/eastwood "0.2.3"] [lein-kibit "0.1.2"] [lein-pprint "1.1.1"]] :dependencies [[org.clojure/clojure "1.7.0"] [org.clojure/tools.reader "1.0.0-alpha3"] [com.cemerick/url "0.1.1"] [datomic-schema-grapher "0.0.1"] [com.datomic/datomic-pro "0.9.5350"] [me.raynes/fs "1.4.6"] [clj-stacktrace "0.2.8"] [acyclic/squiggly-clojure "0.1.5"] ^:replace [org.clojure/tools.nrepl "0.2.12"]]} :signing {:gpg-key "matthew.russell@wormbase.org"} ;; VisualVM profiling opts :jvm-opts ["-Dcom.sun.management.jmxremote" "-Dcom.sun.management.jmxremote.ssl=false" "-Dcom.sun.management.jmxremote.authenticate=false" "-Dcom.sun.management.jmxremote.port=43210"]}
Simplify semver-type test with are
(ns github-changelog.semver-test (:require [github-changelog.semver :as semver] [github-changelog.schema :refer [Semver]] [github-changelog.schema-complete :refer [complete]] [github-changelog.version-examples :refer :all] [clojure.test :refer :all] [schema.core :as s])) (deftest extract (testing "with a v prefix" (are [version] (s/validate Semver (semver/extract version)) "v0.0.1" "v0.9.3-pre0" "v1.0.1")) (testing "without a v prefix" (are [version] (s/validate Semver (semver/extract version)) "0.0.1" "0.9.3-pre0" "1.0.1"))) (deftest newer? (let [high (complete {:major 1} Semver) low (complete {:major 0} Semver)] (is (semver/newer? high low)) (is (not (semver/newer? low high))))) (deftest semver-type (is (= (semver/get-type v-major) :major)) (is (= (semver/get-type v-minor) :minor)) (is (= (semver/get-type v-patch) :patch)) (is (= (semver/get-type v-pre-release) :pre-release)) (is (= (semver/get-type v-build) :build)))
(ns github-changelog.semver-test (:require [github-changelog.semver :as semver] [github-changelog.schema :refer [Semver]] [github-changelog.schema-complete :refer [complete]] [github-changelog.version-examples :refer :all] [clojure.test :refer :all] [schema.core :as s])) (deftest extract (testing "with a v prefix" (are [version] (s/validate Semver (semver/extract version)) "v0.0.1" "v0.9.3-pre0" "v1.0.1")) (testing "without a v prefix" (are [version] (s/validate Semver (semver/extract version)) "0.0.1" "0.9.3-pre0" "1.0.1"))) (deftest newer? (let [high (complete {:major 1} Semver) low (complete {:major 0} Semver)] (is (semver/newer? high low)) (is (not (semver/newer? low high))))) (deftest semver-type (are [type version] (= type (semver/get-type version)) :major v-major :minor v-minor :patch v-patch :pre-release v-pre-release :build v-build))
Change exception message and explanation to exception throw for tests
(ns io.pivotal.pcf.rabbitmq.main-test (:require [clojure.test :refer :all] [io.pivotal.pcf.rabbitmq.main :as main] [io.pivotal.pcf.rabbitmq.server :as server])) (defn FakeExit [^long status] (def FakeExitCalled status)) (defn FakeServerStart [m] (throw (Exception. "Something Terrible Happened"))) ; (Thread. (fn [] (prn "Started Fake Sever")))) (deftest initialization (testing "when server starts with an error" (with-redefs [server/start FakeServerStart main/exit FakeExit] (def FakeExitCalled nil) (main/-main "-c" "test/config/valid.yml") (is (= FakeExitCalled 1)))))
(ns io.pivotal.pcf.rabbitmq.main-test (:require [clojure.test :refer :all] [io.pivotal.pcf.rabbitmq.main :as main] [io.pivotal.pcf.rabbitmq.server :as server])) (defn FakeExit [^long status] (def FakeExitCalled status)) ; This exception is thrown to end the fake server ; We could not find any other reasonable way to achieve ; this. - (BC) (AS) (defn FakeServerStart [m] (throw (Exception. "End Of The TEST"))) ; (Thread. (fn [] (prn "Started Fake Sever")))) (deftest initialization (testing "when server starts with an error" (with-redefs [server/start FakeServerStart main/exit FakeExit] (def FakeExitCalled nil) (main/-main "-c" "test/config/valid.yml") (is (= FakeExitCalled 1)))))
Add trips resource to routes
(ns gtfve.handler (:require [compojure.core :refer [GET defroutes]] [compojure.route :refer [not-found resources]] [ring.middleware.defaults :refer [site-defaults wrap-defaults]] [selmer.parser :refer [render-file]] [prone.middleware :refer [wrap-exceptions]] [environ.core :refer [env]])) (defroutes routes (GET "/" [] (render-file "templates/index.html" {:dev (env :dev?)})) (resources "/") (not-found "Not Found")) (def app (let [handler (wrap-defaults routes site-defaults)] (if (env :dev?) (wrap-exceptions handler) handler)))
(ns gtfve.handler (:require [compojure.core :refer [GET defroutes]] [compojure.route :refer [not-found resources]] [ring.middleware.defaults :refer [site-defaults wrap-defaults]] [selmer.parser :refer [render-file]] [prone.middleware :refer [wrap-exceptions]] [environ.core :refer [env]] [gtfve.data.queries :as q])) (defroutes routes (GET "/" [] (render-file "templates/index.html" {:dev (env :dev?)})) (GET "/trips" [] (fn [req] {:status 200 :body (pr-str (q/trips)) :headers {"Content-Type" "application/edn"}})) (resources "/") (not-found "Not Found")) (def app (let [handler (wrap-defaults routes site-defaults)] (if (env :dev?) (wrap-exceptions handler) handler)))
Fix java.io.IOException: UT000034: Stream is closed
; Copyright © 2015-2018 Esko Luontola ; This software is released under the Apache License 2.0. ; The license text is at http://www.apache.org/licenses/LICENSE-2.0 (ns territory-bro.dev-middleware (:require [prone.middleware :refer [wrap-exceptions]] [ring-debug-logging.core :refer [wrap-with-logger]] [ring.middleware.reload :refer [wrap-reload]] [selmer.middleware :refer [wrap-error-page]])) (defn wrap-dev [handler] (-> handler wrap-with-logger wrap-reload wrap-error-page ;; FIXME: prone fails to load its own css, so the error pages are useless #_(wrap-exceptions {:app-namespaces ['territory-bro]})))
; Copyright © 2015-2018 Esko Luontola ; This software is released under the Apache License 2.0. ; The license text is at http://www.apache.org/licenses/LICENSE-2.0 (ns territory-bro.dev-middleware (:require [prone.middleware :refer [wrap-exceptions]] [ring-debug-logging.core :refer [wrap-with-logger]] [ring.middleware.reload :refer [wrap-reload]] [selmer.middleware :refer [wrap-error-page]])) (defn wrap-dev [handler] (-> handler ;; FIXME: wrap-with-logger will read the body destructively so that the handler cannot anymore read it #_wrap-with-logger wrap-reload wrap-error-page ;; FIXME: prone fails to load its own css, so the error pages are useless #_(wrap-exceptions {:app-namespaces ['territory-bro]})))
Fix typo in No layout registered with key expection.
(ns incise.layouts.core (:require [incise.parsers.parse] [incise.config :as conf]) (:refer-clojure :exclude [get])) (defonce 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 & more] (apply @layouts (name layout-name) more)) (defn Parse->string [^incise.parsers.parse.Parse parse-data] (if-let [layout-key (:layout parse-data)] (if-let [layout-fn (get layout-key)] (layout-fn (conf/get) parse-data) (throw (ex-info (str "No layout function of with registered with key " layout-key) {:layouts @layouts}))) (throw (ex-info (str "No layout key specified in given parse.") {:layouts @layouts :parse parse-data})))) (defn register "Register a layout function to a shortname" [short-names layout-fn] (swap! layouts merge (zipmap (map name short-names) (repeat layout-fn))))
(ns incise.layouts.core (:require [incise.parsers.parse] [incise.config :as conf]) (:refer-clojure :exclude [get])) (defonce 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 & more] (apply @layouts (name layout-name) more)) (defn Parse->string [^incise.parsers.parse.Parse parse-data] (if-let [layout-key (:layout parse-data)] (if-let [layout-fn (get layout-key)] (layout-fn (conf/get) parse-data) (throw (ex-info (str "No layout function registered with key " layout-key) {:layouts @layouts}))) (throw (ex-info (str "No layout key specified in given parse.") {:layouts @layouts :parse parse-data})))) (defn register "Register a layout function to a shortname" [short-names layout-fn] (swap! layouts merge (zipmap (map name short-names) (repeat layout-fn))))
Add helper to generate random uuid
(ns com.wsscode.pathom.misc) #?(:clj (def INCLUDE_SPECS true) :cljs (goog-define INCLUDE_SPECS true))
(ns com.wsscode.pathom.misc #?(:clj (:import (java.util UUID)))) #?(:clj (def INCLUDE_SPECS true) :cljs (goog-define INCLUDE_SPECS true)) (defn pathom-random-uuid [] #?(:clj (UUID/randomUUID) :cljs (random-uuid)))
Use an MD5 hash for ETags
(ns yada.etag) (defprotocol ETag "The version function returns material that becomes the ETag response header. This is left open for extension. The ETag must differ between representations, so the representation is given in order to be used in the algorithm. Must always return a string (to aid comparison with the strings the client will present on If-Match, If-None-Match." (to-etag [_ rep])) (extend-protocol ETag Object (to-etag [o rep] (str (hash {:value o :representation rep}))) nil (to-etag [o rep] nil))
(ns yada.etag (:require [yada.util :refer [md5-hash]])) (defprotocol ETag "The version function returns material that becomes the ETag response header. This is left open for extension. The ETag must differ between representations, so the representation is given in order to be used in the algorithm. Must always return a string (to aid comparison with the strings the client will present on If-Match, If-None-Match." (to-etag [_ rep])) (extend-protocol ETag Object (to-etag [o rep] (md5-hash (str (hash {:value o :representation rep})))) nil (to-etag [o rep] nil))
Allow Clojure files to be loaded
(ns nightmod.public (:require [nightmod.core :refer :all] [play-clj.core :refer :all])) (defn set-game-screen! [& screens] (->> (apply set-screen! nightmod (conj (vec screens) overlay-screen)) (fn []) (app! :post-runnable)))
(ns nightmod.public (:require [clojail.core :as jail] [clojure.java.io :as io] [nightmod.core :refer :all] [play-clj.core :refer :all])) (defn set-game-screen! [& screens] (->> (apply set-screen! nightmod (conj (vec screens) overlay-screen)) (fn []) (app! :post-runnable))) (defmacro load-game-file [n] (some->> (or (io/resource n) (throw (Throwable. (str "File not found:" n)))) slurp (format "(do %s\n)") jail/safe-read))
Make now workflow error fatal.
(ns incise.deploy.core (:require [taoensso.timbre :refer [warn]]) (:clojure-refer :exclude [get])) (def workflows (atom {})) (defn get [& args] (apply clojure.core/get @workflow args)) (defn deploy [] (let [{workflow-name :workflow :as settings} (conf/get :deploy) [workflow (get workflow-name)]] (if workflow (workflow settings) (warn "No workflow registered as" workflow-name)))) (defn register "Register a deployment workflow." [workflow-name workflow] (swap! workflows assoc (name workflow-name) workflow))
(ns incise.deploy.core (:require [incise.config :as conf] [taoensso.timbre :refer [fatal]]) (:refer-clojure :exclude [get])) (def workflows (atom {})) (defn get [& args] (apply clojure.core/get @workflows args)) (defn deploy [] (let [{workflow-name :workflow :as settings} (conf/get :deploy) workflow (get workflow-name)] (if workflow (workflow settings) (fatal "No workflow registered as" workflow-name)))) (defn register "Register a deployment workflow." [workflow-name workflow] (swap! workflows assoc (name workflow-name) workflow))
Update ClojureScript dep to 2138
(defproject {{name}} "0.1.0-SNAPSHOT" :description "FIXME: write this!" :url "http://example.com/FIXME" :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/clojurescript "0.0-2127"]] :plugins [[lein-cljsbuild "1.0.1"]] :source-paths ["src"] :cljsbuild { :builds [{:id "{{name}}" :source-paths ["src"] :compiler { :output-to "{{sanitized}}.js" :output-dir "out" :optimizations :none :source-map true}}]})
(defproject {{name}} "0.1.0-SNAPSHOT" :description "FIXME: write this!" :url "http://example.com/FIXME" :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/clojurescript "0.0-2138"]] :plugins [[lein-cljsbuild "1.0.1"]] :source-paths ["src"] :cljsbuild { :builds [{:id "{{name}}" :source-paths ["src"] :compiler { :output-to "{{sanitized}}.js" :output-dir "out" :optimizations :none :source-map true}}]})
Use a port that's easier to type for connecting Swank to a testing environment.
(ns circle.swank (:require swank.swank) (:require [circle.env :as env])) (defn port [] (cond (env/test?) 5004 :else 4005)) (defn init [] (when (= "true" (System/getenv "CIRCLE_SWANK")) (binding [*print-length* 100 *print-level* 20] (println "Starting Swank") (clojure.main/with-bindings (swank.swank/start-server :port (port) :encoding "utf-8")))))
(ns circle.swank (:require swank.swank) (:require [circle.env :as env])) (defn port [] (cond (env/test?) 4006 :else 4005)) (defn init [] (when (= "true" (System/getenv "CIRCLE_SWANK")) (binding [*print-length* 100 *print-level* 20] (println "Starting Swank") (clojure.main/with-bindings (swank.swank/start-server :port (port) :encoding "utf-8")))))
Update to latest parinfer dep
(defproject replete "0.1.0" :dependencies [[org.clojure/clojure "1.7.0"] [org.clojure/clojurescript "1.7.170"] [tailrecursion/cljson "1.0.7"] [parinfer "0.2.0"]] :clean-targets ["out" "target"] :plugins [[lein-cljsbuild "1.1.1"]] :cljsbuild {:builds {:test {:source-paths ["src" "test"] :compiler {:output-to "test/resources/compiled.js" :optimizations :whitespace :pretty-print true}}} :test-commands {"test" ["phantomjs" "test/resources/test.js" "test/resources/test.html"]}})
(defproject replete "0.1.0" :dependencies [[org.clojure/clojure "1.7.0"] [org.clojure/clojurescript "1.7.170"] [tailrecursion/cljson "1.0.7"] [parinfer "0.2.3"]] :clean-targets ["out" "target"] :plugins [[lein-cljsbuild "1.1.1"]] :cljsbuild {:builds {:test {:source-paths ["src" "test"] :compiler {:output-to "test/resources/compiled.js" :optimizations :whitespace :pretty-print true}}} :test-commands {"test" ["phantomjs" "test/resources/test.js" "test/resources/test.html"]}})
Use boot-jetty instead of boot-http in example
(set-env! :resource-paths #{"resources"} :dependencies '[[org.clojure/clojure "1.8.0"] [afrey/boot-asset-fingerprint "1.0.0-SNAPSHOT"] [pandeiro/boot-http "0.7.3" :scope "test"]]) (require '[afrey.boot-asset-fingerprint :refer [asset-fingerprint]] '[pandeiro.boot-http :refer [serve]]) (deftask dev [] (comp (watch) (serve :port 5000 :reload true) (asset-fingerprint) (target)))
(set-env! :resource-paths #{"resources"} :dependencies '[[org.clojure/clojure "1.8.0"] [afrey/boot-asset-fingerprint "1.0.0-SNAPSHOT"] [tailrecursion/boot-jetty "0.1.3" :scope "test"]]) (require '[afrey.boot-asset-fingerprint :refer [asset-fingerprint] :as fing] '[tailrecursion.boot-jetty :as jetty] '[clojure.java.io :as io]) (deftask dev [] (comp (watch) (asset-fingerprint) (jetty/serve :port 5000) (target)))
Upgrade simple example shadow-cljs to 2.8.59
(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"]})
(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.59"] [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"]})
Update dependencies to match compojure test updates
(defproject hello "compojure" :description "JSON/Database tests" :url "http://example.com/FIXME" :dependencies [[org.clojure/clojure "1.5.1"] [compojure "1.1.5"] [ring/ring-json "0.2.0"] [org.clojure/tools.cli "0.2.1"] [http-kit/dbcp "0.1.0"] [http-kit "2.0.1"] [log4j "1.2.15" :exclusions [javax.mail/mail javax.jms/jms com.sun.jdmk/jmxtools com.sun.jmx/jmxri]] [mysql/mysql-connector-java "5.1.6"]] :main hello.handler :aot [hello.handler] :uberjar-name "http-kit-standalone.jar" :profiles {:dev {:dependencies [[ring-mock "0.1.3"]]}})
(defproject hello "compojure" :description "JSON/Database tests" :url "http://example.com/FIXME" :dependencies [[org.clojure/clojure "1.5.1"] [compojure "1.1.6"] [ring/ring-json "0.2.0"] [org.clojure/tools.cli "0.2.1"] [http-kit/dbcp "0.1.0"] [http-kit "2.0.1"] [log4j "1.2.15" :exclusions [javax.mail/mail javax.jms/jms com.sun.jdmk/jmxtools com.sun.jmx/jmxri]] [mysql/mysql-connector-java "5.1.6"]] :main hello.handler :aot [hello.handler] :uberjar-name "http-kit-standalone.jar" :profiles {:dev {:dependencies [[ring-mock "0.1.5"]]}})
Use instructions to calculate floor
(ns solver.core (:gen-class)) (defn determine-floor [word] "Determines which floor Santa should deliver presents" (let [freqs (frequencies word)] (- (get freqs \( 0) (get freqs \) 0)))) (defn -main "I don't do a whole lot ... yet." [& args] (println (determine-floor (slurp "input"))))
(ns solver.core (:gen-class)) (defn determine-floor [xs] (let [to-direction (fn [index direction] {:index index :direction direction}) determine-floor (fn [floor data] (+ floor (case (data :direction) "(" +1 ")" -1)))] (reduce determine-floor 0 (map-indexed to-direction xs)))) (defn -main "I don't do a whole lot ... yet." [& args] (println (determine-floor (clojure.string/split (slurp "input") #""))))
Fix bug - missing arg for first node - eid
{:name "tnseq-phase0-d", :path "", :graph {:coll {:type "func" :name "collapser"} :mail {:type "func" :name "mailit" :args ["#2" ; recipient "Aerobio job status: tnseq phase-0d" "Finished"]} ; subject, body intro :edges {:coll [:mail]}} :description "Basically, Tn-Seq collapser. Unclear if this is really needed as the collapse node is now part of phase-0*" }
{:name "tnseq-phase0-d", :path "", :graph {:coll {:type "func" :name "collapser" :args ["#1"]} :mail {:type "func" :name "mailit" :args ["#2" ; recipient "Aerobio job status: tnseq phase-0d" "Finished"]} ; subject, body intro :edges {:coll [:mail]}} :description "Basically, Tn-Seq collapser. Unclear if this is really needed as the collapse node is now part of phase-0*" }
Add test for `look` at room.
(ns isla.test.story (:use [clojure.test]) (:use [clojure.pprint]) (:use [isla.story])) ;; story creation (deftest test-room-creation (let [story-str (str "palace is a room") story (init-story story-str)] (is (= (first (:rooms story)) (assoc (isla.interpreter/instantiate-type (get types "room")) :name "palace"))))) (deftest test-player-alteration (let [story-str (str "my name is 'mary'") story (init-story story-str)] (is (= (:player story) (assoc (isla.interpreter/instantiate-type (get types "_player")) :name "mary"))))) (deftest test-room-alteration (let [description "The floors are made of marble." story-str (str "palace is a room palace description is '" description "'") story (init-story story-str)] (is (= (first (:rooms story)) (assoc (isla.interpreter/instantiate-type (get types "room")) :name "palace" :description description)))))
(ns isla.test.story (:use [clojure.test]) (:use [clojure.pprint]) (:use [isla.story])) ;; story creation (deftest test-room-creation (let [story-str (str "palace is a room") story (init-story story-str)] (is (= (first (:rooms story)) (assoc (isla.interpreter/instantiate-type (get types "room")) :name "palace"))))) (deftest test-player-alteration (let [story-str (str "my name is 'mary'") story (init-story story-str)] (is (= (:player story) (assoc (isla.interpreter/instantiate-type (get types "_player")) :name "mary"))))) (deftest test-room-alteration (let [description "The floors are made of marble." story-str (str "palace is a room palace description is '" description "'") story (init-story story-str)] (is (= (first (:rooms story)) (assoc (isla.interpreter/instantiate-type (get types "room")) :name "palace" :description description))))) ;; story telling (deftest test-look-general (let [description "The floors are made of marble." story-str (str "palace is a room palace description is '" description "'") story (init-story story-str)] (is (= (run-command story "look") description))))
Make custom-emoji display in same dimensions as others
(ns braid.emoji.client.styles) (def autocomplete [:.app>.main>.page>.threads>.thread>.card [:>.message.new [:>.autocomplete-wrapper [:>.autocomplete [:>.result [:>.emoji.match [:>img {:display "block" :width "2em" :height "2em" :float "left" :margin "0.25em 0.5em 0.25em 0"}]]]]]]])
(ns braid.emoji.client.styles) (def autocomplete [:.app [:.message>.content [:.emoji.custom-emoji {:width "3ex" :height "3.1ex" :min-height "20px" :display "inline-block" :margin [["-0.2ex" "0.15em" "0.2ex"]] :line-height "normal" :vertical-align "middle" :min-width "20px"}]] [:>.main>.page>.threads>.thread>.card [:>.message.new [:>.autocomplete-wrapper [:>.autocomplete [:>.result [:>.emoji.match [:>img {:display "block" :width "2em" :height "2em" :float "left" :margin "0.25em 0.5em 0.25em 0"}]]]]]]]])
Allow om-root options from a component
(ns com.palletops.bakery.om-root "A component for an Om root element." (:require-macros [com.palletops.api-builder.api :refer [defn-api]]) (:require [com.palletops.leaven.protocols :refer [Startable Stoppable]] [om.core :as om :include-macros true] [schema.core :as schema])) (defrecord OmRoot [f value options] Startable (start [_] (om/root f value options)) Stoppable (stop [_] (om/detach-root (:target options)))) (def OmRootFun (schema/make-fn-schema schema/Any [[schema/Any schema/Any]])) (def OmRootOptions {:f OmRootFun :value schema/Any :options {schema/Keyword schema/Any}}) (defn-api om-root "Return an om-root component" {:sig [[OmRootOptions :- OmRoot] [OmRootFun schema/Any {schema/Keyword schema/Any} :- OmRoot]]} ([f value options] (->OmRoot f value options)) ([{:keys [f value options] :as args}] (map->OmRoot args)))
(ns com.palletops.bakery.om-root "A component for an Om root element." (:require-macros [com.palletops.api-builder.api :refer [defn-api]]) (:require [com.palletops.leaven.protocols :refer [Startable Stoppable]] [om.core :as om :include-macros true] [schema.core :as schema])) (defrecord OmRoot [f value options options-component] Startable (start [_] (om/root f value (merge options (:value options-component)))) Stoppable (stop [_] (om/detach-root (:target options)))) (def OmRootFun (schema/make-fn-schema schema/Any [[schema/Any schema/Any]])) (def OmRootOptions {:f OmRootFun :value schema/Any :options {schema/Keyword schema/Any} :options-component schema/Any}) (defn-api om-root "Return an om-root component" {:sig [[OmRootOptions :- OmRoot] [OmRootFun schema/Any {schema/Keyword schema/Any} :- OmRoot] [OmRootFun schema/Any {schema/Keyword schema/Any} schema/Any :- OmRoot]]} ([f value options] (->OmRoot f value options nil)) ([f value options options-component] (->OmRoot f value options options-component)) ([{:keys [f value options options-component] :as args}] (map->OmRoot args)))
Change a POST request to return json
(ns decktouch.handler (:require [decktouch.dev :refer [browser-repl start-figwheel]] [compojure.core :refer [GET POST defroutes]] [compojure.route :refer [not-found resources]] [ring.middleware.defaults :refer [site-defaults wrap-defaults]] [ring.middleware.params :refer [wrap-params]] [ring.middleware.reload :refer [wrap-reload]] [ring.adapter.jetty :as jetty] [selmer.parser :refer [render-file]] [environ.core :refer [env]] [prone.middleware :refer [wrap-exceptions]] [decktouch.mtg-card-master :as mtg-card-master] [clojure.data.json :as json])) (defroutes routes (GET "/" [] (render-file "templates/index.html" {:dev (env :dev?)})) (GET "/data/input/:query" [query] (json/write-str (mtg-card-master/get-cards-matching-query query))) (POST "/data/card" request (let [card-name ((request :params) "card-name")] (str (mtg-card-master/get-card-info card-name)))) (resources "/") (not-found "Not Found")) (def app (let [handler (wrap-reload (wrap-params routes site-defaults))] (if (env :dev?) (wrap-reload (wrap-exceptions handler)) handler)))
(ns decktouch.handler (:require [decktouch.dev :refer [browser-repl start-figwheel]] [compojure.core :refer [GET POST defroutes]] [compojure.route :refer [not-found resources]] [ring.middleware.defaults :refer [site-defaults wrap-defaults]] [ring.middleware.params :refer [wrap-params]] [ring.middleware.reload :refer [wrap-reload]] [ring.adapter.jetty :as jetty] [selmer.parser :refer [render-file]] [environ.core :refer [env]] [prone.middleware :refer [wrap-exceptions]] [decktouch.mtg-card-master :as mtg-card-master] [clojure.data.json :as json])) (defroutes routes (GET "/" [] (render-file "templates/index.html" {:dev (env :dev?)})) (GET "/data/input/:query" [query] (json/write-str (mtg-card-master/get-cards-matching-query query))) (POST "/data/card" request (let [card-name ((request :params) "card-name")] (json/write-str (mtg-card-master/get-card-info card-name)))) (resources "/") (not-found "Not Found")) (def app (let [handler (wrap-reload (wrap-params routes site-defaults))] (if (env :dev?) (wrap-reload (wrap-exceptions handler)) handler)))
Upgrade Clojure (1.9.0) / ClojureScript (1.9.946)
(defproject test-utils-cljs "0.1.0-SNAPSHOT" :description "FIXME: write this!" :url "http://example.com/FIXME" :dependencies [[org.clojure/clojure "1.8.0"] [org.clojure/clojurescript "1.8.51" :classifier "aot" :exclusion [org.clojure/data.json]] [org.clojure/data.json "0.2.6" :classifier "aot"]] :jvm-opts ^:replace ["-Xmx1g" "-server"] :plugins [[lein-npm "0.6.1"]] :npm {:dependencies [[source-map-support "0.3.2"]]} :source-paths ["src" "target/classes"] :clean-targets ["out" "release"] :target-path "target")
(defproject test-utils-cljs "0.1.0-SNAPSHOT" :description "FIXME: write this!" :url "http://example.com/FIXME" :dependencies [[org.clojure/clojure "1.9.0"] [org.clojure/clojurescript "1.9.946" :classifier "aot"] [kixi/stats "0.4.0"]] :jvm-opts ^:replace ["-Xmx1g" "-server"] :plugins [[lein-npm "0.6.1"]] :npm {:dependencies [[source-map-support "0.3.2"]]} :source-paths ["src" "target/classes"] :clean-targets ["out" "release"] :target-path "target")
Upgrade clojure, clojurescript, lein, figwheel to latest versions
(def root-ns "org.broadinstitute") (def build-dir-relative "target") (defproject org.broadinstitute/firecloud-ui "0.0.1" :dependencies [ ;; React library and cljs bindings for React. [dmohs/react "0.2.7"] [org.clojure/clojure "1.6.0"] [org.clojure/clojurescript "0.0-3211"] [inflections "0.9.14"] ] :plugins [[lein-cljsbuild "1.0.5"] [lein-figwheel "0.3.1"]] :hooks [leiningen.cljsbuild] :profiles {:dev {:cljsbuild {:builds {:client {:compiler {:optimizations :none :source-map true :source-map-timestamp true} :figwheel {:on-jsload ~(str root-ns ".firecloud-ui.main/dev-reload")}}}}} :release {:cljsbuild {:builds {:client {:compiler {:optimizations :advanced :pretty-print false :closure-defines {"goog.DEBUG" false}}}}}}} :cljsbuild {:builds {:client {:source-paths ["src/cljs"] :compiler {:output-dir ~(str build-dir-relative "/build") :output-to ~(str build-dir-relative "/compiled.js")}}}})
(def root-ns "org.broadinstitute") (def build-dir-relative "target") (defproject org.broadinstitute/firecloud-ui "0.0.1" :dependencies [ ;; React library and cljs bindings for React. [dmohs/react "0.2.7"] [org.clojure/clojure "1.7.0"] [org.clojure/clojurescript "1.7.48"] [inflections "0.9.14"] ] :plugins [[lein-cljsbuild "1.0.6"] [lein-figwheel "0.3.7"]] :hooks [leiningen.cljsbuild] :profiles {:dev {:cljsbuild {:builds {:client {:compiler {:optimizations :none :source-map true :source-map-timestamp true} :figwheel {:on-jsload ~(str root-ns ".firecloud-ui.main/dev-reload")}}}}} :release {:cljsbuild {:builds {:client {:compiler {:optimizations :advanced :pretty-print false :closure-defines {"goog.DEBUG" false}}}}}}} :cljsbuild {:builds {:client {:source-paths ["src/cljs"] :compiler {:output-dir ~(str build-dir-relative "/build") :output-to ~(str build-dir-relative "/compiled.js")}}}})
Add a simple test with a failing goal
(ns desdemona.query-test (:require [desdemona.query :as q] [clojure.test :refer [deftest is]])) (deftest query-tests (is (= [[{:ip "10.0.0.1"}]] (q/run-query '(== (:ip x) "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 (= [] (q/run-query 'l/fail [{:ip "10.0.0.1"}]))) (is (= [[{:ip "10.0.0.1"}]] (q/run-query '(== (:ip x) "10.0.0.1") [{:ip "10.0.0.1"}]))))
Make the template tests pass
(ns theatralia.core) ;;; This is an incorrect implementation, such as might be written by ;;; someone who was used to a Lisp in which an empty list is equal to ;;; nil. (defn first-element [sequence default] (if (nil? sequence) default (first sequence)))
(ns theatralia.core) (defn first-element [sequence default] (if (seq sequence) (first sequence) default))
Add proper import to namespace
(ns vadas.core) (defn start-listening "Test CMU Sphinx4 listener" [] (let [config (new edu.cmu.sphinx.api.Configuration)] (println "Created new configuration: " (str config)))) (defn -main "VADAS" [] (start-listening))
(ns vadas.core (:import (edu.cmu.sphinx.api Configuration))) (defn start-listening "Test CMU Sphinx4 listener" [] (let [config (new Configuration)] (println "Created new configuration: " (str config)))) (defn -main "VADAS" [] (start-listening))
Remove the no-op form returned by validates now that we check for a return value before including anything in the generated init-model expansion.
(ns clj-record.validation (:use clj-record.util) (:use clj-record.core)) (defn- validations-for [model-name] ((@all-models-metadata model-name) :validations)) (defn validate [model-name record] (reduce (fn [errors [attr message validation-fn]] (if (validation-fn (record attr)) errors (merge-with (fn [result addl-val] (apply conj result addl-val)) errors {attr [message]}))) {} (validations-for model-name))) (defn- validates [model-name attribute-name message function] (dosync (let [metadata (@all-models-metadata model-name) validations (or (@metadata :validations) [])] (ref-set metadata (assoc @metadata :validations (conj validations [(keyword (name attribute-name)) message (eval function)]))))) '(identity 1)) ; XXX: Have to return a no-op form since we don't need any defs.
(ns clj-record.validation (:use clj-record.util) (:use clj-record.core)) (defn- validations-for [model-name] ((@all-models-metadata model-name) :validations)) (defn validate [model-name record] (reduce (fn [errors [attr message validation-fn]] (if (validation-fn (record attr)) errors (merge-with (fn [result addl-val] (apply conj result addl-val)) errors {attr [message]}))) {} (validations-for model-name))) (defn- validates [model-name attribute-name message function] (dosync (let [metadata (@all-models-metadata model-name) validations (or (@metadata :validations) [])] (ref-set metadata (assoc @metadata :validations (conj validations [(keyword (name attribute-name)) message (eval function)]))))) nil)