Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Handle nil values in match validations.
(ns clj-record.test.validation-built-ins-test (:use clojure.contrib.test-is) (:require [clj-record.validation.built-ins :as vfn])) (deftest match-creates-a-matching-fn-for-the-given-pattern (let [matches-foo? (vfn/match #"foo")] (is (matches-foo? "yes foo does")) (are (not (matches-foo? _1)) "no bar doesn't" nil))) (deftest non-match-creates-an-anti-matching-fn-for-the-given-pattern (let [non-matches-foo? (vfn/non-match #"foo")] (is (not (non-matches-foo? "foo doesn't not"))) (are (non-matches-foo? _1) "bar non-matches" nil)))
(ns clj-record.test.validation-built-ins-test (:use clojure.contrib.test-is) (:require [clj-record.validation.built-ins :as vfn])) (deftest match-creates-a-matching-fn-for-the-given-pattern (let [matches-foo? (vfn/match #"foo")] (is (matches-foo? "yes foo does")) (are (not (matches-foo? _1)) "no bar doesn't" nil 123))) (deftest non-match-creates-an-anti-matching-fn-for-the-given-pattern (let [non-matches-foo? (vfn/non-match #"foo")] (is (not (non-matches-foo? "foo doesn't not"))) (are (non-matches-foo? _1) "bar non-matches" nil 123)))
Prepare for next release cycle.
(defproject org.onyxplatform/onyx-datomic "0.8.1.0-alpha3" :description "Onyx plugin for Datomic" :url "https://github.com/MichaelDrogalis/onyx-datomic" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :dependencies [[org.clojure/clojure "1.7.0"] ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}} [org.onyxplatform/onyx "0.8.1-alpha3"]] :profiles {:dev {:dependencies [[midje "1.7.0"] [com.datomic/datomic-free "0.9.5153"]] :plugins [[lein-midje "3.1.3"] [lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]} :circle-ci {:jvm-opts ["-Xmx4g"]}})
(defproject org.onyxplatform/onyx-datomic "0.8.1.0-SNAPSHOT" :description "Onyx plugin for Datomic" :url "https://github.com/MichaelDrogalis/onyx-datomic" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :dependencies [[org.clojure/clojure "1.7.0"] ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}} [org.onyxplatform/onyx "0.8.1-alpha3"]] :profiles {:dev {:dependencies [[midje "1.7.0"] [com.datomic/datomic-free "0.9.5153"]] :plugins [[lein-midje "3.1.3"] [lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]} :circle-ci {:jvm-opts ["-Xmx4g"]}})
Prepare for next release cycle.
(defproject onyx-app/lein-template "0.13.3.0" :description "Onyx Leiningen application template" :url "https://github.com/onyx-platform/onyx-template" :license {:name "MIT License" :url "http://choosealicense.com/licenses/mit/#"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :plugins [[lein-set-version "0.4.1"]] :profiles {:dev {:plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}} :eval-in-leiningen true)
(defproject onyx-app/lein-template "0.13.3.1-SNAPSHOT" :description "Onyx Leiningen application template" :url "https://github.com/onyx-platform/onyx-template" :license {:name "MIT License" :url "http://choosealicense.com/licenses/mit/#"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :plugins [[lein-set-version "0.4.1"]] :profiles {:dev {:plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}} :eval-in-leiningen true)
Change version to snapshot again
;; 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 "0.3.2" :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.1.4"]])
;; 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 "0.3.2-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.1.4"]])
Revert "kill tests for funcs that do not exist anymore"
(ns riemann.test.common (:use riemann.common) (:use clojure.test))
(ns riemann.test.common (:use riemann.common) (:use clojure.test)) (deftest subset-test (are [a b] (subset? a b) [] [] [] [1 2 3] [1] [1] [1] [2 1 3] [1 2] [1 2 3] [1 2] [2 3 1]) (are [a b] (not (subset? a b)) [1] [] [1 2] [1] [1] [2] [1] [2 3] [1 2] [1 3] [1 2] [3 1])) (deftest overlap-test (are [a b] (overlap? a b) [1 2] [1] [1] [1] [1 2] [2 3] [3 2] [1 3] [1 3] [3 1]) (are [a b] (not (overlap? a b)) [] [] [1] [] [1] [2] [3] [1 2] [1 2] [3 4])) (deftest disjoint-test (are [a b] (disjoint? a b) [] [] [1] [] [1] [2] [3] [1 2] [1 2] [3 4]) (are [a b] (not (disjoint? a b)) [1 2] [1] [1] [1] [1 2] [2 3] [3 2] [1 3] [1 3] [3 1]))
Add fetch project by token repo functions.
;; This Source Code Form is subject to the terms of the Mozilla Public ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; ;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz> (ns uxbox.main.repo.projects "A main interface for access to remote resources." (:require [beicon.core :as rx] [uxbox.config :refer (url)] [uxbox.main.repo.impl :refer (request send!)])) (defmethod request :fetch/projects [type data] (let [url (str url "/projects")] (send! {:url url :method :get}))) (defmethod request :create/project [_ data] (let [params {:url (str url "/projects") :method :post :body data}] (send! params))) (defmethod request :delete/project [_ id] (let [url (str url "/projects/" id)] (send! {:url url :method :delete})))
;; This Source Code Form is subject to the terms of the Mozilla Public ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; ;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz> (ns uxbox.main.repo.projects "A main interface for access to remote resources." (:require [beicon.core :as rx] [uxbox.config :refer (url)] [uxbox.main.repo.impl :refer (request send!)])) (defmethod request :fetch/projects [type data] (let [url (str url "/projects")] (send! {:url url :method :get}))) (defmethod request :fetch/project [_ id] (let [url (str url "/projects/" id)] (send! {:url url :method :get}))) (defmethod request :fetch/project-by-token [_ token] (let [url (str url "/projects-by-token/" token)] (send! {:url url :method :get}))) (defmethod request :create/project [_ data] (let [params {:url (str url "/projects") :method :post :body data}] (send! params))) (defmethod request :delete/project [_ id] (let [url (str url "/projects/" id)] (send! {:url url :method :delete})))
Fix dumbass mistake in string concat. Do it the easy way
(ns cljparse.core (:require [instaparse.core :as insta] [clojure.java.io :as io] [clojure.tools.cli :refer [parse-opts]] [cljparse.config.parser :as config]) (:gen-class)) (def configname "chaincode.conf") (def cli-options ;; An option with a required argument [["-p" "--path PATH" "path to project to build" :default "./"] ["-h" "--help"]]) (defn exit [status msg] (do (println msg) status)) (defn -main [& args] (let [ {:keys [options arguments errors summary]} (parse-opts args cli-options) ] (cond (:help options) (exit 0 summary) (not= errors nil) (exit -1 (str "Error: " errors)) :else (let [ path (:path options) file (io/file path configname) ] (do (cond (not (.isFile file)) (exit -1 (str ("Configuration not found at " path))) :else (do (println "Starting cljparse on:" (.getAbsolutePath file) "and errors:" errors) (config/parser file))))))))
(ns cljparse.core (:require [instaparse.core :as insta] [clojure.java.io :as io] [clojure.tools.cli :refer [parse-opts]] [cljparse.config.parser :as config]) (:gen-class)) (def configname "chaincode.conf") (def cli-options ;; An option with a required argument [["-p" "--path PATH" "path to project to build" :default "./"] ["-h" "--help"]]) (defn exit [status msg & rest] (do (println msg rest) status)) (defn -main [& args] (let [ {:keys [options arguments errors summary]} (parse-opts args cli-options) ] (cond (:help options) (exit 0 summary) (not= errors nil) (exit -1 "Error: " errors) :else (let [ path (:path options) file (io/file path configname) ] (do (cond (not (.isFile file)) (exit -1 "Configuration not found at " path) :else (do (println "Starting cljparse on:" (.getAbsolutePath file) "and errors:" errors) (config/parser file))))))))
Tag generated json as a String.
(ns clj-json (:import (clj_json JsonExt) (org.codehaus.jackson JsonFactory JsonParser) (java.io StringWriter StringReader BufferedReader)) (:use (clojure.contrib [def :only (defvar-)]))) (defvar- #^JsonFactory factory (JsonFactory.)) (defn generate-string [obj] (let [sw (StringWriter.) generator (.createJsonGenerator factory sw)] (JsonExt/generate generator obj) (.flush generator) (.toString sw))) (defn parse-string [string] (JsonExt/parse (.createJsonParser factory (StringReader. string)) true nil)) (defn- parsed-seq* [#^JsonParser parser] (let [eof (Object.)] (lazy-seq (let [elem (JsonExt/parse parser true eof)] (if-not (identical? elem eof) (cons elem (parsed-seq* parser))))))) (defn parsed-seq [#^BufferedReader reader] (parsed-seq* (.createJsonParser factory reader)))
(ns clj-json (:import (clj_json JsonExt) (org.codehaus.jackson JsonFactory JsonParser) (java.io StringWriter StringReader BufferedReader)) (:use (clojure.contrib [def :only (defvar-)]))) (defvar- #^JsonFactory factory (JsonFactory.)) (defn generate-string {:tag String} [obj] (let [sw (StringWriter.) generator (.createJsonGenerator factory sw)] (JsonExt/generate generator obj) (.flush generator) (.toString sw))) (defn parse-string [string] (JsonExt/parse (.createJsonParser factory (StringReader. string)) true nil)) (defn- parsed-seq* [#^JsonParser parser] (let [eof (Object.)] (lazy-seq (let [elem (JsonExt/parse parser true eof)] (if-not (identical? elem eof) (cons elem (parsed-seq* parser))))))) (defn parsed-seq [#^BufferedReader reader] (parsed-seq* (.createJsonParser factory reader)))
Add error handler plugin to intro example
(ns com.wsscode.pathom.book.intro.demo (:require [com.wsscode.pathom.core :as p] [com.wsscode.pathom.connect :as pc])) (pc/defresolver answer [_ _] {::pc/output [:answer-to-everything]} {:answer-to-everything 42}) (pc/defresolver answer-plus-one [_ {:keys [answer-to-everything]}] {::pc/input #{:answer-to-everything} ::pc/output [:answer-plus-one]} {:answer-plus-one (inc answer-to-everything)}) (def parser (p/parallel-parser {::p/env {::p/reader [p/map-reader pc/parallel-reader pc/open-ident-reader p/env-placeholder-reader] ::p/placeholder-prefixes #{">"}} ::p/mutate pc/mutate-async ::p/plugins [(pc/connect-plugin {::pc/register [answer answer-plus-one]}) p/trace-plugin]}))
(ns com.wsscode.pathom.book.intro.demo (:require [com.wsscode.pathom.core :as p] [com.wsscode.pathom.connect :as pc])) (pc/defresolver answer [_ _] {::pc/output [:answer-to-everything]} {:answer-to-everything 42}) (pc/defresolver answer-plus-one [_ {:keys [answer-to-everything]}] {::pc/input #{:answer-to-everything} ::pc/output [:answer-plus-one]} {:answer-plus-one (inc answer-to-everything)}) (def parser (p/parallel-parser {::p/env {::p/reader [p/map-reader pc/parallel-reader pc/open-ident-reader p/env-placeholder-reader] ::p/placeholder-prefixes #{">"}} ::p/mutate pc/mutate-async ::p/plugins [(pc/connect-plugin {::pc/register [answer answer-plus-one]}) p/error-handler-plugin p/trace-plugin]}))
Make sure to stop the synth. This prevents it from making some garbage noise at the end of the program.
(ns rule110.core (:require [rule110.midi :as midi])) (def grid-size 1024 ) (def max-steps 100) (def step-rule { [1 1 1] 0, [1 1 0] 1, [1 0 1] 1, [1 0 0] 0, [0 1 1] 1, [0 1 0] 1, [0 0 1] 1, [0 0 0] 0 }) (defn step "Apply the rule to each cell in the grid and return a new grid" [grid] (let [torus (concat [(last grid)] grid [(first grid)])] (map step-rule (partition 3 1 torus)))) (defn random-grid "Generate a random grid of size size with x percent of the cells set to 1" [size percent-on] (mapv (fn [_] (if (<= (rand-int 100) percent-on) 1 0)) (range size))) (defn draw-grid "Simple drawing of grid to terminal and return grid" [grid] (doseq [c grid] (print (if (= 1 c) "*" " "))) (println "") grid) (defn -main [& args] (reduce (fn [s v] (-> s step draw-grid midi/play-grid)) (random-grid 100 25) (range 250)) nil)
(ns rule110.core (:require [rule110.midi :as midi])) (def grid-size 1024 ) (def max-steps 100) (def step-rule { [1 1 1] 0, [1 1 0] 1, [1 0 1] 1, [1 0 0] 0, [0 1 1] 1, [0 1 0] 1, [0 0 1] 1, [0 0 0] 0 }) (defn step "Apply the rule to each cell in the grid and return a new grid" [grid] (let [torus (concat [(last grid)] grid [(first grid)])] (map step-rule (partition 3 1 torus)))) (defn random-grid "Generate a random grid of size size with x percent of the cells set to 1" [size percent-on] (mapv (fn [_] (if (<= (rand-int 100) percent-on) 1 0)) (range size))) (defn draw-grid "Simple drawing of grid to terminal and return grid" [grid] (doseq [c grid] (print (if (= 1 c) "*" " "))) (println "") grid) (defn -main [& args] (reduce (fn [s v] (-> s step draw-grid midi/play-grid)) (random-grid 100 25) (range 250)) (midi/stop) nil)
Break out function for calculating piece css class
(ns chess.core (:require [om.core :as om :include-macros true] [om.dom :as dom :include-macros true] [chess.board :as board])) (defonce app-state (atom {:board board/start-position})) (defn piece [p owner] (reify om/IRender (render [_] (dom/div #js {:className (str "piece " (board/colour p) " " (board/pieces p))} nil)))) (defn main [] (om/root (fn [app owner] (reify om/IRender (render [_] (apply dom/div #js {:className "board"} (map-indexed (fn [i r] (apply dom/div #js {:className "row"} (map-indexed (fn [j s] (dom/div #js {:className "square" :id (board/from-board-ks j i)} (if s (om/build piece s)))) r))) (:board 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] [chess.board :as board])) (defonce app-state (atom {:board board/start-position})) (defn piece-class-name [p] (str "piece " (board/colour p) " " (board/pieces p))) (defn piece [p owner] (reify om/IRender (render [_] (dom/div #js {:className (piece-class-name p)} nil)))) (defn main [] (om/root (fn [app owner] (reify om/IRender (render [_] (apply dom/div #js {:className "board"} (map-indexed (fn [i r] (apply dom/div #js {:className "row"} (map-indexed (fn [j s] (dom/div #js {:className "square" :id (board/from-board-ks j i)} (if s (om/build piece s)))) r))) (:board app)))))) app-state {:target (. js/document (getElementById "app"))}))
Add function for calculating value of coalition
(ns baustellen) (defn distance [p1 p2] (Math/sqrt (apply + (map (fn [c1 c2] (Math/pow (- c1 c2) 2)) p1 p2)))) (defn cost "Returns the cost for transporting cnt units of skill over a dist. The basis cost for transporting one unit of skill over one unit of distance is taken from skill-costs. Currently the cost increases linearly with the distance and squareroot-ly with the number of skill-units transported." [dist skill cnt skill-costs] (* dist (Math/sqrt cnt) (get skill-costs skill)))
(ns baustellen) (defn distance [p1 p2] (Math/sqrt (apply + (map (fn [c1 c2] (Math/pow (- c1 c2) 2)) p1 p2)))) (defn cost "Returns the cost for transporting cnt units of skill over a dist. The basis cost for transporting one unit of skill over one unit of distance is taken from skill-costs. Currently the cost increases linearly with the distance and squareroot-ly with the number of skill-units transported." [dist skill cnt skill-costs] (* dist (Math/sqrt cnt) (get skill-costs skill))) (defn sum-allocations [skill allocation] (apply + (vals (get allocation skill)))) (defn sufficient-allocation? "True if the allocated skills meet the demand of the site." [{:keys [site allocation]} sites] (let [demand (:skills (get sites site))] (every? (fn [skill] (>= (sum-allocations skill allocation) (get demand skill))) (keys demand)))) (defn cost-in-coal [agent {:keys [site allocation]} sites agents skill-costs] (let [skill (:skill (get agents agent)) cnt (get-in allocation [skill agent])] (cost (distance (:location (get sites site)) (:location (get agents agent))) skill cnt skill-costs))) (defn total-cost [{:keys [site allocation] :as coal} sites agents skill-costs] (let [agents-in-coal (mapcat keys (vals allocation))] (apply + (map (fn [a] (cost-in-coal a coal sites agents skill-costs)) agents-in-coal)))) (defn coalition-value [coalition sites agents skill-costs] (if (sufficient-allocation? coalition sites) (- (:payoff (get sites (:site coalition))) (total-cost coalition sites agents skill-costs)) 0))
Add url to silence Leiningen
;; Copyright © 2014 JUXT LTD. ;; We call this project modular to make the invocation: lein new modular appname (defproject modular/lein-template "0.6.13" :description "Leiningen template for a full-featured component based app using modular extensions." :license {:name "The MIT License" :url "http://opensource.org/licenses/MIT"} :dependencies [[org.clojure/clojure "1.7.0-alpha4"] ;; EDN reader with location metadata [org.clojure/tools.reader "0.8.3"] [org.clojure/tools.logging "0.2.6"]] :eval-in-leiningen true)
;; Copyright © 2014 JUXT LTD. ;; We call this project modular to make the invocation: lein new modular appname (defproject modular/lein-template "0.6.13" :description "Leiningen template for a full-featured component based app using modular extensions." :url "http://modularity.org/" :license {:name "The MIT License" :url "http://opensource.org/licenses/MIT"} :dependencies [[org.clojure/clojure "1.7.0-alpha4"] ;; EDN reader with location metadata [org.clojure/tools.reader "0.8.3"] [org.clojure/tools.logging "0.2.6"]] :eval-in-leiningen true)
Fix bug in robot-kata-routes test
(ns robot-kata.server-test (:require [clojure.test :refer :all] [robot-kata.server :refer :all])) (deftest robot-kata-routes-test (testing "Routes work as expected" (testing "Default route" (let [resp (robot-kata-routes {:request-method :get :uri "/"})] (is (= 302 (:status resp)) "Default route redirects") (is (= "/robot-kata.html" ((:headers resp) "Location")) "Default route redirects to '/robot-kata.html'") ) ) (testing "Resource route" (let [resp (robot-kata-routes {:request-method :get :uri "/robot-kata.html" :headers {"if-modified-since" "Sat, 29 Oct 1994 19:43:31 GMT"}})] (is (= 200 (:status resp)) "GET of '/robot-kata.html' returns 200 status") (is (= "text/html" ((:headers resp) "Content-Type")) "GET of '/robot-kata.html' returns content type 'text/html'") (is (> ((:headers resp) "Content-Length") 0) "GET of '/robot-kata.html' returns content of length > 0") ) ) (testing "Page not found" (is (= 0 1) "Implement page not found tests!") ) ) )
(ns robot-kata.server-test (:require [clojure.test :refer :all] [robot-kata.server :refer :all])) (deftest robot-kata-routes-test (testing "Routes work as expected" (testing "Default route" (let [resp (robot-kata-routes {:request-method :get :uri "/"})] (is (= 302 (:status resp)) "Default route redirects") (is (= "/robot-kata.html" ((:headers resp) "Location")) "Default route redirects to '/robot-kata.html'") ) ) (testing "Resource route" (let [resp (robot-kata-routes {:request-method :get :uri "/robot-kata.html" :headers {"if-modified-since" "Sat, 29 Oct 1994 19:43:31 GMT"}})] (is (= 200 (:status resp)) "GET of '/robot-kata.html' returns 200 status") (is (= "text/html" ((:headers resp) "Content-Type")) "GET of '/robot-kata.html' returns content type 'text/html'") (is (> (Integer. ((:headers resp) "Content-Length")) 0) "GET of '/robot-kata.html' returns content of length > 0") ) ) (testing "Page not found" (is (= 0 1) "Implement page not found tests!") ) ) )
Allow uberjar to run migration/rollback
(ns time-tracker.core (:gen-class) (:require [time-tracker.web.service :as web-service] [time-tracker.db :as db] [time-tracker.logging :as log] [org.httpkit.server :as httpkit] [time-tracker.util :as util])) (defn init! [] (log/configure-logging!) (db/init-db!)) (defn teardown! [] (log/teardown-logging!)) (defn start-server! ([] (start-server! (web-service/app))) ([app-handler] (init!) (log/info {:event ::server-start}) (let [stop-fn (httpkit/run-server app-handler {:port (Integer/parseInt (util/from-config :port))})] (fn [] (stop-fn) (log/info {:event ::server-stop}) (teardown!))))) (defn -main [& args] (start-server!))
(ns time-tracker.core (:gen-class) (:require [org.httpkit.server :as httpkit] [time-tracker.migration :refer [migrate-db rollback-db]] [time-tracker.db :as db] [time-tracker.logging :as log] [time-tracker.util :as util] [time-tracker.web.service :as web-service])) (defn init! [] (log/configure-logging!) (db/init-db!)) (defn teardown! [] (log/teardown-logging!)) (defn start-server! ([] (start-server! (web-service/app))) ([app-handler] (init!) (log/info {:event ::server-start}) (let [stop-fn (httpkit/run-server app-handler {:port (Integer/parseInt (util/from-config :port))})] (fn [] (stop-fn) (log/info {:event ::server-stop}) (teardown!))))) (defn -main [& args] (condp = (first args) "migrate" (migrate-db) "rollback" (rollback-db) (start-server!)))
Disable advanced target to speed up "lein cljsbuild test whitespace"
(defproject kukui "0.1.0-pre" :dependencies [[org.clojure/clojure "1.6.0"] [org.clojure/clojurescript "0.0-2227"]] :profiles {:dev {:plugins [[lein-cljsbuild "1.0.3"] [com.cemerick/clojurescript.test "0.3.1"]] :hooks [leiningen.cljsbuild]}} :cljsbuild {:builds {:whitespace {:source-paths ["test"] :compiler {:output-to "target/cljsbuild/whitespace/kukui.js" :optimizations :whitespace :pretty-print true}} :advanced {:source-paths ["test"] :compiler {:output-to "target/cljsbuild/advanced/kukui.js" :pretty-print false :optimizations :advanced}}} :test-commands {"whitespace" ["phantomjs" :runner "target/cljsbuild/whitespace/kukui.js"] "advanced" ["phantomjs" :runner "target/cljsbuild/advanced/kukui.js"]}})
(defproject kukui "0.1.0-pre" :dependencies [[org.clojure/clojure "1.6.0"] [org.clojure/clojurescript "0.0-2227"]] :profiles {:dev {:plugins [[lein-cljsbuild "1.0.3"] [com.cemerick/clojurescript.test "0.3.1"]] :hooks [leiningen.cljsbuild]}} :cljsbuild {:builds {:whitespace {:source-paths ["test"] ;; can't include src because of LT :compiler {:output-to "target/cljsbuild/whitespace/kukui.js" :optimizations :whitespace :pretty-print true}} ;; avoid advanced recompilation when testing ;; :advanced {:source-paths ["src" "test"] ;; :compiler ;; {:output-to "target/cljsbuild/advanced/kukui.js" ;; :pretty-print false ;; :optimizations :advanced}} } :test-commands {"whitespace" ["phantomjs" :runner "target/cljsbuild/whitespace/kukui.js"] "advanced" ["phantomjs" :runner "target/cljsbuild/advanced/kukui.js"]}})
Update compojure from 1.3.3 to 1.4.0
(defproject statuses "1.0.0-SNAPSHOT" :description "Statuses app for innoQ" :url "https://github.com/innoq/statuses" :license {:name "Apache License, Version 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0" :distribution :repo :comments "A business-friendly OSS license"} :dependencies [[org.clojure/clojure "1.7.0"] [ring "1.4.0"] [compojure "1.3.3"] [clj-time "0.9.0"] [org.clojure/data.json "0.2.6"] [org.clojure/tools.cli "0.3.3"]] :pedantic? :abort :plugins [[jonase/eastwood "0.2.0"]] :profiles {:dev {:dependencies [[ring-mock "0.1.5"]]} :uberjar {:aot [statuses.server]}} :main statuses.server :aliases {"lint" "eastwood"} :eastwood {:exclude-linters [:constant-test]})
(defproject statuses "1.0.0-SNAPSHOT" :description "Statuses app for innoQ" :url "https://github.com/innoq/statuses" :license {:name "Apache License, Version 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0" :distribution :repo :comments "A business-friendly OSS license"} :dependencies [[org.clojure/clojure "1.7.0"] [ring "1.4.0"] [compojure "1.4.0"] [clj-time "0.9.0"] [org.clojure/data.json "0.2.6"] [org.clojure/tools.cli "0.3.3"]] :pedantic? :abort :plugins [[jonase/eastwood "0.2.0"]] :profiles {:dev {:dependencies [[ring-mock "0.1.5"]]} :uberjar {:aot [statuses.server]}} :main statuses.server :aliases {"lint" "eastwood"} :eastwood {:exclude-linters [:constant-test]})
Make some indentation more Clojurey.
(ns metrics.counters (:use [metrics.utils :only (metric-name)]) (:import (com.yammer.metrics Metrics)) (:import (com.yammer.metrics.core Counter))) ; Create ---------------------------------------------------------------------- (defn counter "Create and return a new Counter metric with the given title. Title can be a plain string like \"foo\" or a vector of three strings (group, type, and title) like: [\"myapp\" \"webserver\" \"connections\"] " [title] (Metrics/newCounter (metric-name title))) (defmacro defcounter "Define a new Counter metric with a given title, or group, type and title." ([title] `(def ~title (counter ~(str title)))) ([group type title] `(def ~title (counter ~(vec (map str [group type title])))))) ; Read ------------------------------------------------------------------------ (defn value "Return the current value of the counter." [^Counter c] (.count c)) ; Write ----------------------------------------------------------------------- (defn inc! "Increment the counter by the given amount (or 1 if not specified)." ([^Counter c] (inc! c 1)) ([^Counter c n] (.inc c n) c)) (defn dec! "Decrement the counter by the given amount (or 1 if not specified)." ([^Counter c] (dec! c 1)) ([^Counter c n] (.dec c n) c)) (defn clear! "Clear the given counter, resetting its value to zero." [^Counter c] (.clear c) c)
(ns metrics.counters (:use [metrics.utils :only (metric-name)]) (:import (com.yammer.metrics Metrics)) (:import (com.yammer.metrics.core Counter))) ; Create ---------------------------------------------------------------------- (defn counter "Create and return a new Counter metric with the given title. Title can be a plain string like \"foo\" or a vector of three strings (group, type, and title) like: [\"myapp\" \"webserver\" \"connections\"] " [title] (Metrics/newCounter (metric-name title))) (defmacro defcounter "Define a new Counter metric with a given title, or group, type and title." ([title] `(def ~title (counter ~(str title)))) ([group type title] `(def ~title (counter ~(vec (map str [group type title])))))) ; Read ------------------------------------------------------------------------ (defn value "Return the current value of the counter." [^Counter c] (.count c)) ; Write ----------------------------------------------------------------------- (defn inc! "Increment the counter by the given amount (or 1 if not specified)." ([^Counter c] (inc! c 1)) ([^Counter c n] (.inc c n) c)) (defn dec! "Decrement the counter by the given amount (or 1 if not specified)." ([^Counter c] (dec! c 1)) ([^Counter c n] (.dec c n) c)) (defn clear! "Clear the given counter, resetting its value to zero." [^Counter c] (.clear c) c)
Work on frame grab code
(ns telegenic.core (:import [org.jcodec.api FrameGrab]))
(ns telegenic.core (:import [org.jcodec.api FrameGrab]) (:import [java.io File]) (:import [java.awt.image BufferedImage]) (:import [org.jcodec.common.model Picture]) ) (set! *warn-on-reflection* true) (set! *unchecked-math* true) (defprotocol PGetFrame (get-frame [video frame-number])) (extend-protocol PGetFrame String (get-frame [s frame-number] (get-frame (File. s) frame-number)) File (get-frame [file frame-number] (let [^Picture nf (FrameGrab/getNativeFrame file (int frame-number)) bi (.toBufferedImage nf)] bi)))
Move loom dependency to tests
(defproject asystant "0.1.1-SNAPSHOT" :description "A simple, flexible helper for building modular systems with clojure/core.async" :url "https://github.com/monteithpj/asystant" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.7.0"] [org.clojure/core.async "0.1.346.0-17112a-alpha"] [org.clojure/core.match "0.3.0-alpha4"] [aysylu/loom "0.5.4"]] :aliases {"repl" ["with-profile" "+test" "repl"]} :profiles {:test {:dependencies [[org.clojure/test.check "0.8.2"] [com.gfredericks/test.chuck "0.2.0"] [com.velisco/herbert "0.7.0-alpha1"]]}} :plugins [[codox "0.8.15"]] :codox {:src-dir-uri "https://github.com/monteithpj/asystant/blob/master"})
(defproject asystant "0.1.1-SNAPSHOT" :description "A simple, flexible helper for building modular systems with clojure/core.async" :url "https://github.com/monteithpj/asystant" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.7.0"] [org.clojure/core.async "0.1.346.0-17112a-alpha"] [org.clojure/core.match "0.3.0-alpha4"]] :aliases {"repl" ["with-profile" "+test" "repl"]} :profiles {:test {:dependencies [[org.clojure/test.check "0.8.2"] [com.gfredericks/test.chuck "0.2.0"] [com.velisco/herbert "0.7.0-alpha1"] [aysylu/loom "0.5.4"]]}} :plugins [[codox "0.8.15"]] :codox {:src-dir-uri "https://github.com/monteithpj/asystant/blob/master"})
Update dependency org.onyxplatform/onyx to version 0.7.3-20150901_142736-gd0de107.
(defproject org.onyxplatform/onyx-datomic "0.7.2.0" :description "Onyx plugin for Datomic" :url "https://github.com/MichaelDrogalis/onyx-datomic" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.7.0"] ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}} [org.onyxplatform/onyx "0.7.3-20150901_140443-g6e4750b"]] :profiles {:dev {:dependencies [[midje "1.7.0"] [com.datomic/datomic-free "0.9.5153"]] :plugins [[lein-midje "3.1.3"]]} :circle-ci {:jvm-opts ["-Xmx4g"]}})
(defproject org.onyxplatform/onyx-datomic "0.7.2.0" :description "Onyx plugin for Datomic" :url "https://github.com/MichaelDrogalis/onyx-datomic" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.7.0"] ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}} [org.onyxplatform/onyx "0.7.3-20150901_142736-gd0de107"]] :profiles {:dev {:dependencies [[midje "1.7.0"] [com.datomic/datomic-free "0.9.5153"]] :plugins [[lein-midje "3.1.3"]]} :circle-ci {:jvm-opts ["-Xmx4g"]}})
Add metadata to appease clojars
(defproject com.draines/postal "1.12-SNAPSHOT" :repositories {"java.net" "http://download.java.net/maven/2"} :dependencies [[commons-codec "1.9"] [javax.mail/mail "1.4.4" :exclusions [javax.activation/activation]]] :profiles {:dev {:dependencies [[org.clojure/clojure "1.5.1"]]} :1.3 {:dependencies [[org.clojure/clojure "1.3.0"]]} :1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]}})
(defproject com.draines/postal "1.12-SNAPSHOT" :description "JavaMail on Clojure" :url "https://github.com/drewr/postal" :license {:name "MIT" :url "http://en.wikipedia.org/wiki/MIT_License" :distribution :repo :comments "Use at your own risk"} :repositories {"java.net" "http://download.java.net/maven/2"} :dependencies [[commons-codec "1.9"] [javax.mail/mail "1.4.4" :exclusions [javax.activation/activation]]] :profiles {:dev {:dependencies [[org.clojure/clojure "1.5.1"]]} :1.3 {:dependencies [[org.clojure/clojure "1.3.0"]]} :1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]}})
Prepare for next release cycle.
(defproject org.onyxplatform/onyx-datomic "0.7.4" :description "Onyx plugin for Datomic" :url "https://github.com/MichaelDrogalis/onyx-datomic" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :dependencies [[org.clojure/clojure "1.7.0"] ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}} [org.onyxplatform/onyx "0.7.4-20150916_205458-gf33df5b"]] :profiles {:dev {:dependencies [[midje "1.7.0"] [com.datomic/datomic-free "0.9.5153"]] :plugins [[lein-midje "3.1.3"] [lein-set-version "0.4.1"] [lein-pprint "1.1.1"]]} :circle-ci {:jvm-opts ["-Xmx4g"]}})
(defproject org.onyxplatform/onyx-datomic "0.7.5-SNAPSHOT" :description "Onyx plugin for Datomic" :url "https://github.com/MichaelDrogalis/onyx-datomic" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :dependencies [[org.clojure/clojure "1.7.0"] ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}} [org.onyxplatform/onyx "0.7.4-20150916_205458-gf33df5b"]] :profiles {:dev {:dependencies [[midje "1.7.0"] [com.datomic/datomic-free "0.9.5153"]] :plugins [[lein-midje "3.1.3"] [lein-set-version "0.4.1"] [lein-pprint "1.1.1"]]} :circle-ci {:jvm-opts ["-Xmx4g"]}})
Revert "Trying to add contrib dep to make lein-release work"
(defproject se.haleby/stub-http "0.2.8" :description "A client library agonistic way to stub HTTP responses" :url "https://github.com/johanhaleby/stub-http" :license {:name "MIT License" :url "http://www.opensource.org/licenses/mit-license.php" :distribution :repo} :lein-release {:deploy-via :clojars} :min-lein-version "2.0.0" :dependencies [[org.nanohttpd/nanohttpd "2.3.1"]] :profiles {:dev {:dependencies [[org.clojure/clojure "1.8.0"] [cheshire "5.5.0"] [clj-http-lite "0.3.0"] ;; needed for java>=11: [javax.xml.bind/jaxb-api "2.3.1"] ;; needed for clj-release [org.clojure/clojure-contrib "1.20"]]}} :repositories [["releases" {:url "http://clojars.org/repo" :creds :gpg}]] :plugins [[lein-codox "0.9.4"]])
(defproject se.haleby/stub-http "0.2.8" :description "A client library agonistic way to stub HTTP responses" :url "https://github.com/johanhaleby/stub-http" :license {:name "MIT License" :url "http://www.opensource.org/licenses/mit-license.php" :distribution :repo} :lein-release {:deploy-via :clojars} :min-lein-version "2.0.0" :dependencies [[org.nanohttpd/nanohttpd "2.3.1"]] :profiles {:dev {:dependencies [[org.clojure/clojure "1.8.0"] [cheshire "5.5.0"] [clj-http-lite "0.3.0"] ;; needed for java>=11: [javax.xml.bind/jaxb-api "2.3.1"]]}} :repositories [["releases" {:url "http://clojars.org/repo" :creds :gpg}]] :plugins [[lein-codox "0.9.4"]])
Add clj-ml dependency for patrec.
(defproject cadence "0.2.0-SNAPSHOT" :description "Use pattern recognition to match users with Cadence.js output." :min-lein-version "2.0.0" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.3.0"] [net.tanesha.recaptcha4j/recaptcha4j "0.0.7"] [com.novemberain/monger "1.0.0-beta4"] ;[clauth "1.0.0-rc1"] [amalloy/ring-gzip-middleware "0.1.1"] [fuziontech/ring-json-params "0.2.0"] [com.cemerick/friend "0.0.8"] [svm-clj "0.0.1-SNAPSHOT"] ;[ring-middleware-format "0.1.1"] ;[noir-cljs "0.2.5"] [noir "1.2.2"]] :main cadence.server)
(defproject cadence "0.2.0-SNAPSHOT" :description "Use pattern recognition to match users with Cadence.js output." :min-lein-version "2.0.0" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.3.0"] [net.tanesha.recaptcha4j/recaptcha4j "0.0.7"] [com.novemberain/monger "1.0.0-beta4"] ;[clauth "1.0.0-rc1"] [amalloy/ring-gzip-middleware "0.1.1"] [fuziontech/ring-json-params "0.2.0"] [com.cemerick/friend "0.0.8"] ;[com.ml/libsvm "2.89"] ;[svm-clj "0.0.1-SNAPSHOT"] ;[edu.berkely.compbio/jlibsvm "0.902"] ;[clj-ml "0.0.3-SNAPSHOT"] [com.leadtune/clj-ml "0.2.1"] ;[ring-middleware-format "0.1.1"] ;[noir-cljs "0.2.5"] [noir "1.2.2"]] :main cadence.server)
Add a docstring for block-forever!
(ns desdemona.launcher.utils (:require [clojure.core.async :as a])) (defn block-forever! [] (a/<!! (a/chan)))
(ns desdemona.launcher.utils (:require [clojure.core.async :as a])) (defn block-forever! "Blocks forever." [] (a/<!! (a/chan)))
Update library dependencies and release clostache
;; Copyright © 2014 JUXT LTD. (defproject juxt.modular/clostache "0.6.0" :description "A modular extension that provides a Clostache templater for juxt.modular/template" :url "https://github.com/juxt/modular/tree/master/modules/clostache" :license {:name "The MIT License" :url "http://opensource.org/licenses/MIT"} :dependencies [[com.stuartsierra/component "0.2.1"] [de.ubercode.clostache/clostache "1.3.1"] [juxt.modular/template "0.6.0"] ])
;; Copyright © 2014 JUXT LTD. (defproject juxt.modular/clostache "0.6.1" :description "A modular extension that provides a Clostache templater for juxt.modular/template" :url "https://github.com/juxt/modular/tree/master/modules/clostache" :license {:name "The MIT License" :url "http://opensource.org/licenses/MIT"} :dependencies [[com.stuartsierra/component "0.2.2"] [de.ubercode.clostache/clostache "1.4.0"] [juxt.modular/template "0.6.2"] ])
Sort posts by updated-at or the most recent comment updated-at, return only the first tot posts.
(ns oc.storage.util.sort) (defn- activity-sort " Compare function to sort 2 entries and/or activity by their `created-at` or `published-at` order respectively, in the order (:asc or :desc) provided. " [order x y] (let [order-flip (if (= order :desc) -1 1)] (* order-flip (compare (or (:published-at x) (:created-at x)) (or (:published-at y) (:created-at y)))))) (defn sort-activity "Given a set of entries, return up to the default limit of them, intermixed and sorted." [entries order limit] (take limit (sort (partial activity-sort order) entries)))
(ns oc.storage.util.sort (:require [clojure.pprint :as pp] [clj-time.core :as t] [clj-time.format :as f])) (defn- max-comment-timestamp "Return a map {entry-uuid most-recent-comment-timestap} excluding the user authored comments" [user-id entry] (let [all-comments (filterv #(and (:body %) (not= (-> % :author :user-id) user-id)) (:interactions entry)) sorted-comments (sort-by :updated-at all-comments)] (when (seq sorted-comments) (hash-map (:uuid entry) (-> sorted-comments last :updated-at))))) (defn sort-activity "Given a set of entries, return up to the default limit of them, intermixed and sorted." [entries sorting order limit user-id] (let [all-published-at (apply merge (map #(hash-map (:uuid %) (:published-at %)) entries)) sorting-by-most-recent? (= sorting :most-recent) all-comments (if sorting-by-most-recent? (apply merge (remove nil? (map (partial max-comment-timestamp user-id) entries))) {}) to-sort-map (merge all-published-at all-comments) order-flip (if (= order :desc) -1 1) sorted-map (into (sorted-map-by (fn [key1 key2] (* order-flip (compare [(get to-sort-map key1) key1] [(get to-sort-map key2) key2])))) to-sort-map) limited-uuids (take limit (keys sorted-map))] (remove nil? (map (fn [entry-uuid] (first (filter #(= (:uuid %) entry-uuid) entries))) limited-uuids))))
Add more stuff to my .lein.
{:user {:plugins [[lein-marginalia "0.7.1"] [cider/cider-nrepl "0.7.0-SNAPSHOT"] [lein-try "0.4.1"] [lein-clojars "0.9.1"] [lein-ancient "0.5.5"] [lein-pprint "1.1.1"]] :dependencies [[com.gfredericks/clj-usage-graph "0.1.3"]] }}
{:user {:plugins [[lein-marginalia "0.7.1"] [cider/cider-nrepl "0.7.0-SNAPSHOT"] [lein-try "0.4.1"] [lein-clojars "0.9.1"] [lein-ancient "0.5.5"] [lein-exec "0.3.4"] [lein-pprint "1.1.1"]] :dependencies [[com.gfredericks/clj-usage-graph "0.1.3"] [org.clojure/tools.trace "0.7.8"]]}}
Update Mac file name possibilities
(ns app.analysis "GitHub releases URL analysis" (:require [taoensso.timbre :as timbre :refer-macros [info]])) (defn get-os [url] (cond (boolean (re-find #"windows" url)) "Windows" (boolean (re-find #"linux" url)) "Linux" (boolean (re-find #".dmg" url)) "Mac OS X" :else "Other")) (defn get-word-size [url] (cond (boolean (re-find #"x86_64" url)) "64-bit" (boolean (re-find #"x64" url)) "64-bit" (boolean (re-find #"x86" url)) "32-bit" :else "")) (defn get-file-type [url] (cond (boolean (re-find #".zip" url)) "Portable" (boolean (re-find #".tar.gz" url)) "Portable" (boolean (re-find #".dmg" url)) "Disk Image" :else "Installer")) (defn analyze-download-url [asset-info] (let [{url :browser-download-url} asset-info] {:os (get-os url) :word-size (get-word-size url) :file-type (get-file-type url) :url url})) (defn build-download-map [asset-info-vector] (group-by :os (map analyze-download-url asset-info-vector)))
(ns app.analysis "GitHub releases URL analysis" (:require [taoensso.timbre :as timbre :refer-macros [info]])) (defn get-os [url] (cond (boolean (re-find #"windows" url)) "Windows" (boolean (re-find #"linux" url)) "Linux" (boolean (re-find #"mac|.dmg" url)) "Mac OS X" :else "Other")) (defn get-word-size [url] (cond (boolean (re-find #"x86_64" url)) "64-bit" (boolean (re-find #"x64" url)) "64-bit" (boolean (re-find #"x86" url)) "32-bit" :else "")) (defn get-file-type [url] (cond (boolean (re-find #".zip" url)) "Portable" (boolean (re-find #".tar.gz" url)) "Portable" (boolean (re-find #".dmg" url)) "Disk Image" :else "Installer")) (defn analyze-download-url [asset-info] (let [{url :browser-download-url} asset-info] {:os (get-os url) :word-size (get-word-size url) :file-type (get-file-type url) :url url})) (defn build-download-map [asset-info-vector] (group-by :os (map analyze-download-url asset-info-vector)))
Add more setup for alembic
;; See: https://github.com/kumarshantanu/lein-localrepo {:user {:plugins [;; Try new api quickly using the repl [lein-try "0.4.3"] ;;[lein-localrepo "0.5.4"] ;; Convert pom.xml to project.clj ;; Note: from https://github.com/thickey/lein-nevam [lein-nevam "0.1.2"] ;; A Leiningen plugin for a superior development environment ;; See: [Introduction Blog Post](https://blog.venanti.us/ultra/) ;; https://github.com/venantius/ultra ;;[venantius/ultra "0.5.2"] ;; Pretty-print a representation of the project map [lein-pprint "1.2.0"] ;; Keep adding more stuff here ] ;; Experimental :dependencies [[pjstadig/humane-test-output "0.8.3"] ;; See: https://github.com/pallet/alembic [alembic "0.3.2"]] :injections [(require 'pjstadig.humane-test-output) (pjstadig.humane-test-output/activate!)]}}
;; See: https://github.com/kumarshantanu/lein-localrepo {:user {:plugins [;; Try new api quickly using the repl [lein-try "0.4.3"] ;;[lein-localrepo "0.5.4"] ;; Convert pom.xml to project.clj ;; Note: from https://github.com/thickey/lein-nevam [lein-nevam "0.1.2"] ;; A Leiningen plugin for a superior development environment ;; See: [Introduction Blog Post](https://blog.venanti.us/ultra/) ;; https://github.com/venantius/ultra ;;[venantius/ultra "0.5.2"] ;; Pretty-print a representation of the project map [lein-pprint "1.2.0"] ;; For quick typing [com.palletops/lein-shorthand "0.4.0"]] ;; See: https://github.com/pallet/alembic :shorthand {. [alembic.still/distill alembic.still/lein]} ;; Experimental :dependencies [[pjstadig/humane-test-output "0.8.3"] ;; See: https://github.com/pallet/alembic [alembic "0.3.2"]] :injections [(require 'pjstadig.humane-test-output) (pjstadig.humane-test-output/activate!)]}}
Test for the correct clojure version.
;; Copyright 2008-2014 Red Hat, Inc, and individual contributors. ;; ;; This is free software; you can redistribute it and/or modify it ;; under the terms of the GNU Lesser General Public License as ;; published by the Free Software Foundation; either version 2.1 of ;; the License, or (at your option) any later version. ;; ;; This software is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. ;; ;; You should have received a copy of the GNU Lesser General Public ;; License along with this software; if not, write to the Free ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ;; 02110-1301 USA, or see the FSF site: http://www.fsf.org. (ns no-clojure-jar.tests (:use clojure.test)) (deftest bundled-clojure-version (is (= "1.5.1" (clojure-version))))
;; Copyright 2008-2014 Red Hat, Inc, and individual contributors. ;; ;; This is free software; you can redistribute it and/or modify it ;; under the terms of the GNU Lesser General Public License as ;; published by the Free Software Foundation; either version 2.1 of ;; the License, or (at your option) any later version. ;; ;; This software is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. ;; ;; You should have received a copy of the GNU Lesser General Public ;; License along with this software; if not, write to the Free ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ;; 02110-1301 USA, or see the FSF site: http://www.fsf.org. (ns no-clojure-jar.tests (:use clojure.test)) (deftest bundled-clojure-version (is (= "1.6.0" (clojure-version))))
Add "-client" to JVM opts for quickstart projects.
(defproject {{ project_name }} "0.0.1-SNAPSHOT" :source-paths ["topologies"] :resource-paths ["_resources"] :aot :all :target-path "_build" :min-lein-version "2.0.0" :dependencies [[org.apache.storm/storm-core "0.9.1-incubating"] [com.parsely/streamparse "0.0.1-SNAPSHOT"] [org.clojure/clojure "1.5.1"] [org.clojure/data.json "0.2.4"] [org.clojure/tools.cli "0.3.1"] ] )
(defproject {{ project_name }} "0.0.1-SNAPSHOT" :source-paths ["topologies"] :resource-paths ["_resources"] :aot :all :target-path "_build" :min-lein-version "2.0.0" :jvm-opts ["-client"] :dependencies [[org.apache.storm/storm-core "0.9.1-incubating"] [com.parsely/streamparse "0.0.1-SNAPSHOT"] [org.clojure/clojure "1.5.1"] [org.clojure/data.json "0.2.4"] [org.clojure/tools.cli "0.3.1"]] )
Add docstrings to chapter 5 stubs.
(ns little-clojurer.chapter5 (:require [little-clojurer.chapter4 :refer :all])) (defn rember* [a l] nil) (defn insertR* [new old l] nil) (defn occur* [a l] nil) (defn subst* [new old l] nil) (defn insertL* [new old l] nil) (defn member* [a l] nil) (defn leftmost [l] nil)
(ns little-clojurer.chapter5 (:require [little-clojurer.chapter4 :refer :all])) (defn rember* "find all occurrances of a in l deeply recursively and remove them" [a l] nil) (defn insertR* "find all occurrances of old in l deeply recursively and append new to the right of the occurrances" [new old l] nil) (defn occur* "count the number of times a occurs in l deeply recursively" [a l] nil) (defn subst* "find all occurrances of a in l deeply recursively and replace them with new" [new old l] nil) (defn member* "check if a occurs in l deeply recursively" [a l] nil) (defn leftmost "finds the leftmost atom in l deeply recursively. l cannot be empty and cannot contain empty lists." [l] nil)
Simplify arguments the editing component gets from the cell component
(ns reabledit.components (:require [reabledit.util :as util])) (defn data-table-cell-input [columns data nth-row nth-col state] (let [k (:key (nth columns nth-col))] [:input {:type "text" :auto-focus true :value (get (get-in @state [:edit :updated]) k) :on-change #(swap! state assoc-in [:edit :updated k] (-> % .-target .-value))}])) (defn data-table-cell [columns data v nth-row nth-col state] (let [selected? (= (:selected @state) [nth-row nth-col]) edit? (:edit @state)] [:td {:class (if selected? "selected") :on-click #(util/set-selected! state nth-row nth-col)} (if (and selected? edit?) [data-table-cell-input columns data nth-row nth-col state] [:span v])])) (defn data-table-row [columns data row-data nth-row state] [:tr ;; TODO: run map-indexed to columns only once (for [[nth-col {:keys [key value]}] (map-indexed vector columns)] ^{:key nth-col} [data-table-cell columns data (get row-data key) nth-row nth-col state])]) (defn data-table-headers [columns] [:thead [:tr (for [{:keys [key value]} columns] ^{:key key} [:th value])]])
(ns reabledit.components (:require [reabledit.util :as util] [reagent.core :as reagent])) (defn data-table-cell-input [cursor] [:input {:type "text" :auto-focus true :value @cursor :on-change #(reset! cursor (-> % .-target .-value))}]) (defn data-table-cell [columns data v nth-row nth-col state] (let [selected? (= (:selected @state) [nth-row nth-col]) edit? (:edit @state) key (:key (nth columns nth-col)) cursor (reagent/cursor state [:edit :updated key])] [:td {:class (if selected? "selected") :on-click #(util/set-selected! state nth-row nth-col)} (if (and selected? edit?) [data-table-cell-input cursor] [:span v])])) (defn data-table-row [columns data row-data nth-row state] [:tr ;; TODO: run map-indexed to columns only once (for [[nth-col {:keys [key value]}] (map-indexed vector columns)] ^{:key nth-col} [data-table-cell columns data (get row-data key) nth-row nth-col state])]) (defn data-table-headers [columns] [:thead [:tr (for [{:keys [key value]} columns] ^{:key key} [:th value])]])
Fix arity of interop call
(ns interop.Sample (:gen-class)) (defn -main [] (throw (UnsupportedOperationException. "Not yet implemented")))
(ns interop.Sample (:gen-class)) (defn -main [& _] (throw (UnsupportedOperationException. "Not yet implemented")))
Fix list of known commands in help message
(ns leiningen.pallet-release "Pallet release commands to support the PalletOps release workflow." (:require [leiningen.pallet-release.core :refer [fail]] [leiningen.pallet-release.release :as release] [leiningen.pallet-release.travis :as travis])) (defn pallet-release "Pallet release commands to support the PalletOps release workflow." ^{:subtasks [#'release/init #'release/start #'release/finish #'travis/push #'release/publish]} [project & [cmd & args]] (case cmd "init" (release/init project args) "start" (release/start project args) "finish" (release/finish project args) "push" (travis/push project args) "publish" (release/publish project args) (fail "Known cmds are init, start, finish, and push")))
(ns leiningen.pallet-release "Pallet release commands to support the PalletOps release workflow." (:require [leiningen.pallet-release.core :refer [fail]] [leiningen.pallet-release.release :as release] [leiningen.pallet-release.travis :as travis])) (defn pallet-release "Pallet release commands to support the PalletOps release workflow." ^{:subtasks [#'release/init #'release/start #'release/finish #'travis/push #'release/publish]} [project & [cmd & args]] (case cmd "init" (release/init project args) "start" (release/start project args) "finish" (release/finish project args) "push" (travis/push project args) "publish" (release/publish project args) (fail "Known cmds are init, start, finish, and publish.")))
Fix merge issue in last commit.
(ns onyx.types) <<<<<<< HEAD (defrecord Message [id payload]) (defrecord Leaf [message id acker-id completion-id ack-val hash-group route]) ======= (defrecord Leaf [message id acker-id completion-id ack-val ack-vals route routes hash-group]) (defn leaf ([message] (->Leaf message nil nil nil nil nil nil nil nil))) >>>>>>> ba78b0e... Read vpeer-id separately to rest of buffer so that (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]) (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])
Test allegedly better error reporting
(ns icecap.schema-test (:require [icecap.schema :refer :all] [clojure.test :refer :all] [schema.core :as s])) (def simple-http-request {:target "http://example.test"}) (def simple-https-request {:target "https://example.test"}) (def simple-ftp-request {:target "ftp://example.test"}) (deftest RequestSpecTests (testing "Correct request specs validate" (are [example] (s/validate RequestSpec example) simple-http-request simple-https-request #{simple-http-request simple-https-request})) (testing "Request specs with unknown/unsupported schemes don't validate" (are [example] (thrown? Throwable (s/validate RequestSpec example)) simple-ftp-request)))
(ns icecap.schema-test (:require [icecap.schema :refer :all] [clojure.test :refer :all] [schema.core :as s])) (def simple-http-request {:target "http://example.test"}) (def simple-https-request {:target "https://example.test"}) (def simple-ftp-request {:target "ftp://example.test"}) (deftest RequestSpecTests (testing "Correct request specs validate" (are [example] (s/validate RequestSpec example) simple-http-request simple-https-request #{simple-http-request simple-https-request})) (testing "Request specs with unknown/unsupported schemes don't validate" (are [example reason] (= (s/check RequestSpec example) reason) simple-ftp-request {:target (not ("supported-scheme?" "ftp://example.test"))})))
Fix stack overflow during startup
(ns lcmap.clownfish.system (:require [again.core :as again] [clojure.tools.logging :as log] ;; requiring this ensures the server component will start [lcmap.clownfish.server :as server] [lcmap.clownfish.setup.cassandra] [lcmap.clownfish.setup.rabbitmq] [mount.core :refer [defstate] :as mount])) (defstate hook :start (do (log/debugf "registering shutdown handler") (.addShutdownHook (Runtime/getRuntime) (Thread. #(mount/stop) "shutdown-handler")))) (def default-retry-strategy (again/max-retries 10 (again/constant-strategy 5000))) (defn start ([environment] (start default-retry-strategy)) ([environment startup-retry-strategy] (again/with-retries startup-retry-strategy (do (log/info "Stopping mount components") (mount/stop) (log/info "Starting mount components...") ;; insulation to make sure these states do not get accidentally ;; started (mount/start-without #'lcmap.clownfish.setup.cassandra/setup #'lcmap.clownfish.setup.cassandra/teardown #'lcmap.clownfish.setup.rabbitmq/setup (mount/with-args {:environment environment})))))) (defn stop [] (mount/stop))
(ns lcmap.clownfish.system (:require [again.core :as again] [clojure.tools.logging :as log] ;; requiring this ensures the server component will start [lcmap.clownfish.server :as server] [lcmap.clownfish.setup.cassandra] [lcmap.clownfish.setup.rabbitmq] [mount.core :refer [defstate] :as mount])) (defstate hook :start (do (log/debugf "registering shutdown handler") (.addShutdownHook (Runtime/getRuntime) (Thread. #(mount/stop) "shutdown-handler")))) (def default-retry-strategy (again/max-retries 10 (again/constant-strategy 5000))) (defn start ([environment] (start environment default-retry-strategy)) ([environment startup-retry-strategy] (again/with-retries startup-retry-strategy (do (log/info "Stopping mount components") (mount/stop) (log/info "Starting mount components...") ;; insulation to make sure these states do not get accidentally ;; started (mount/start-without #'lcmap.clownfish.setup.cassandra/setup #'lcmap.clownfish.setup.cassandra/teardown #'lcmap.clownfish.setup.rabbitmq/setup (mount/with-args {:environment environment})))))) (defn stop [] (mount/stop))
Make sure page component is started before server
(ns de.otto.tesla.example.example-system (:require [de.otto.tesla.system :as system] [de.otto.tesla.example.calculating :as calculating] [de.otto.tesla.example.example-page :as example-page] [com.stuartsierra.component :as c]) (:gen-class)) (defn example-calculation-function [input] (.toUpperCase input)) (defn example-system [runtime-config] (-> (system/empty-system runtime-config) (assoc :calculator (c/using (calculating/new-calculator example-calculation-function) [:metering :app-status])) (assoc :example-page (c/using (example-page/new-example-page) [:routes :calculator :app-status])))) (defn -main "starts up the production system." [& args] (system/start-system (example-system{})))
(ns de.otto.tesla.example.example-system (:require [de.otto.tesla.system :as system] [de.otto.tesla.example.calculating :as calculating] [de.otto.tesla.example.example-page :as example-page] [com.stuartsierra.component :as c]) (:gen-class)) (defn example-calculation-function [input] (.toUpperCase input)) (defn example-system [runtime-config] (-> (system/empty-system runtime-config) (assoc :calculator (c/using (calculating/new-calculator example-calculation-function) [:metering :app-status])) (assoc :example-page (c/using (example-page/new-example-page) [:routes :calculator :app-status])) (c/system-using {:server [:example-page]}))) (defn -main "starts up the production system." [& args] (system/start-system (example-system{})))
Remove useless stuff and set ring handler
(defproject shurly "1.0.0-SNAPSHOT" :description "FIXME: write description" :url "http://shurly.herokuapp.com" :license {:name "FIXME: choose" :url "http://example.com/FIXME"} :dependencies [[org.clojure/clojure "1.6.0"] [compojure "1.1.8"] [ring/ring-jetty-adapter "1.2.2"] [ring/ring-devel "1.2.2"] [ring-basic-authentication "1.0.5"] [environ "0.5.0"] [com.cemerick/drawbridge "0.0.6"]] :min-lein-version "2.0.0" :plugins [[environ/environ.lein "0.2.1"]] :hooks [environ.leiningen.hooks] :uberjar-name "shurly-standalone.jar" :profiles {:production {:env {:production true}}})
(defproject shurly "1.0.0-SNAPSHOT" :description "A URL shortener" :url "http://shurly.herokuapp.com" :dependencies [[org.clojure/clojure "1.6.0"] [compojure "1.1.8"] [ring/ring-jetty-adapter "1.2.2"] [ring/ring-devel "1.2.2"] [environ "0.5.0"]] :min-lein-version "2.0.0" :plugins [[environ/environ.lein "0.2.1"]] :hooks [environ.leiningen.hooks] :uberjar-name "shurly-standalone.jar" :ring {:handler shurly.web/app} :profiles {:production {:env {:production true}}})
Update pretty dependency to 0.1.6
(defproject io.aviso/twixt "0.1.5" :description "An extensible asset pipeline for Clojure web applications" :url "https://github.com/AvisoNovate/twixt" :license {:name "Apache Sofware Licencse 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0.html"} :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/tools.logging "0.2.6"] [ring/ring-core "1.2.0"] [org.mozilla/rhino "1.7R4"] [com.github.sommeri/less4j "1.1.2"] [de.neuland/jade4j "0.3.15"] [io.aviso/pretty "0.1.5"] [hiccup "1.0.4"]] :repositories [["jade4j" "https://raw.github.com/neuland/jade4j/master/releases"]] :codox {:src-dir-uri "https://github.com/AvisoNovate/twixt/blob/master/" :src-linenum-anchor-prefix "L"} :profiles {:dev {:dependencies [[log4j "1.2.17"] [ring/ring-jetty-adapter "1.2.0"]]}})
(defproject io.aviso/twixt "0.1.5" :description "An extensible asset pipeline for Clojure web applications" :url "https://github.com/AvisoNovate/twixt" :license {:name "Apache Sofware Licencse 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0.html"} :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/tools.logging "0.2.6"] [ring/ring-core "1.2.0"] [org.mozilla/rhino "1.7R4"] [com.github.sommeri/less4j "1.1.2"] [de.neuland/jade4j "0.3.15"] [io.aviso/pretty "0.1.6"] [hiccup "1.0.4"]] :repositories [["jade4j" "https://raw.github.com/neuland/jade4j/master/releases"]] :codox {:src-dir-uri "https://github.com/AvisoNovate/twixt/blob/master/" :src-linenum-anchor-prefix "L"} :profiles {:dev {:dependencies [[log4j "1.2.17"] [ring/ring-jetty-adapter "1.2.0"]]}})
Make clean-tokyo task also use conch.
(ns leiningen.clean-tokyo (:use [clojure.java.shell :only [sh]] [clojure.java.io :only [file]])) (defn clean [srcdir] (when (.exists (file srcdir "Makefile")) (println (:out (sh "make" "distclean" :dir (file srcdir)))))) (defn clean-tokyo [] (clean (file "src/tokyocabinet")) (clean (file "src/tokyocabinet-java")))
(ns leiningen.clean-tokyo (:use [clojure.java.io :only [file]]) (:require [conch.core :as sh])) (defn clean [srcdir] (when (.exists (file srcdir "Makefile")) (sh/stream-to-out (sh/proc "make" "distclean" :dir (file srcdir)) :out))) (defn clean-tokyo [] (clean (file "src/tokyocabinet")) (clean (file "src/tokyocabinet-java")))
Add sum and diff tests
(ns jest.arithmetic-test (:require [clojure.test :refer :all] [jest.utils :refer :all] :verbose)) (deftest product-test-1 (test-code "val x = 1 * 2;" ["(def x (* 1 2))"])) (deftest product-test-2 (test-code "val x = 1 * 2 * 3;" ["(def x (* (* 1 2) 3))"])) (deftest quotent-test-1 (test-code "val x = 1 / 2;" ["(def x (/ 1 2))"])) (deftest quotent-test-2 (test-code "val x = 1 / 2 / 3;" ["(def x (/ (/ 1 2) 3))"])) (deftest multiply-divide-test (test-code "val x = 1 * 2 / 3;" ["(def x (/ (* 1 2) 3))"]))
(ns jest.arithmetic-test (:require [clojure.test :refer :all] [jest.utils :refer :all] :verbose)) (deftest sum-test-1 (test-code "val x = 1 + 2;" ["(def x (+ 1 2))"])) (deftest sum-test-2 (test-code "val x = 1 + 2 + 3;" ["(def x (+ (+ 1 2) 3))"])) (deftest product-test-1 (test-code "val x = 1 * 2;" ["(def x (* 1 2))"])) (deftest product-test-2 (test-code "val x = 1 * 2 * 3;" ["(def x (* (* 1 2) 3))"])) (deftest quotent-test-1 (test-code "val x = 1 / 2;" ["(def x (/ 1 2))"])) (deftest quotent-test-2 (test-code "val x = 1 / 2 / 3;" ["(def x (/ (/ 1 2) 3))"])) (deftest multiply-divide-test (test-code "val x = 1 * 2 / 3;" ["(def x (/ (* 1 2) 3))"]))
Use byddy.crypto utils function for get a byte array from string on make-secret-key function.
(ns buddy.crypto.keys (:import java.security.Key)) (defn make-secret-key "Generates a Key instance from given raw string key." [^String skey] (let [rawkey (.getBytes skey "UTF-8")] (proxy [Key] [] (getFormat [] nil) (getEncoded [] rawkey) (toString [] skey))))
(ns buddy.crypto.keys (:require [buddy.crypto.core :refer [str->bytes]]) (:import java.security.Key)) (defn make-secret-key "Generates a Key instance from given raw string key." [^String skey] (let [rawkey (str->bytes skey)] (proxy [Key] [] (getFormat [] nil) (getEncoded [] rawkey) (toString [] skey))))
Add cut handler to read-only cell
(ns reabledit.cells.read-only (:require [reabledit.util :as util])) (defn read-only-cell [{:keys [row-data column-key]}] (let [v (get row-data column-key)] [:div.reabledit-read-only-cell {:title v} [:input.reabledit-read-only-cell__input.reabledit-focused {:type "text" :value "" :on-key-down #(if (= (.-keyCode %) 13) (.stopPropagation %)) :on-copy #(util/set-clipboard-data % v)}] [:span.reabledit-read-only-cell__view v]]))
(ns reabledit.cells.read-only (:require [reabledit.util :as util])) (defn read-only-cell [{:keys [row-data column-key]}] (let [v (get row-data column-key)] [:div.reabledit-read-only-cell {:title v} [:input.reabledit-read-only-cell__input.reabledit-focused {:type "text" :value "" :on-key-down #(if (= (.-keyCode %) 13) (.stopPropagation %)) :on-copy #(util/set-clipboard-data % v) :on-cut #(util/set-clipboard-data % v)}] [:span.reabledit-read-only-cell__view v]]))
Replace fake json route by /images route
(ns silly-image-store.handler (:require [silly-image-store.store :as store] [environ.core :refer [env]] [compojure.core :refer :all] [ring.middleware.json :refer :all] [compojure.handler :as handler] [compojure.route :as route])) (def images-dir (env :base-store-dir)) (defn image-not-found [image] (route/not-found (str "No image '" image "' found"))) (defn serve-image [image] (let [image-file (store/load-image images-dir image)] (or image-file (image-not-found image)))) (defroutes app-routes (GET "/blah" [] {:status 200 :body {:def [123 456 789]}}) (GET "/images/:image" [image] (serve-image image)) (route/resources "/") (route/not-found "Not Found")) (def app (-> (handler/site app-routes) (wrap-json-response)))
(ns silly-image-store.handler (:require [silly-image-store.store :as store] [environ.core :refer [env]] [compojure.core :refer :all] [ring.middleware.json :refer :all] [compojure.handler :as handler] [compojure.route :as route])) (def images-dir (env :base-store-dir)) (defn image-not-found [image] (route/not-found (str "No image '" image "' found"))) (defn serve-image [image] (let [image-file (store/load-image images-dir image)] (or image-file (image-not-found image)))) (defroutes app-routes (GET "/images" [] "nothing") (GET "/images/:image" [image] (serve-image image)) (route/resources "/") (route/not-found "Not Found")) (def app (-> (handler/site app-routes) (wrap-json-response)))
Use unification to constrain results
(ns desdemona.query (:require [clojure.core.logic :as l])) (defn ^:private gen-query [n-answers query events] `(l/run ~n-answers [results#] (l/fresh [~'x] (l/membero ~'x results#) (l/everyg #(l/membero % results#) ~events) ~query))) (defn run-query ([query events] (run-query 1 query events)) ([n-answers query events] (eval (gen-query n-answers query events))))
(ns desdemona.query (:require [clojure.core.logic :as l])) (defn ^:private gen-query [n-answers query events] `(l/run ~n-answers [results#] (l/fresh [~'x] (l/everyg #(l/membero % results#) ~events) (l/== [~'x] results#) ~query))) (defn run-query ([query events] (run-query 1 query events)) ([n-answers query events] (eval (gen-query n-answers query events))))
Add workaround to fix ClojureScript
(ns clojuresque.tasks.repl (:require [clojuresque.cli :as cli] [clojuresque.util :as util] [clojure.tools.nrepl.server :as repl])) (def barrier (promise)) (def server nil) (cli/deftask start-repl "Start a nrepl server on the given port. An optional handler may be given as fully-qualified symbol. The repl server may be stopped via clojuresque.tasks.repl/stop-server." [[port p "server port"] [handler h "handler function" nil]] (let [p (Long/parseLong port) h (if handler (let [custom-handler (util/resolve-required handler)] (when-not custom-handler (throw (Exception. (str "Unknown handler Var: " handler)))) (custom-handler)) (repl/default-handler)) s (repl/start-server :port p :handler h)] (println "Repl started on port" port) (alter-var-root #'server (constantly s))) @barrier) (defn stop-repl [] (when server (repl/stop-server server) (deliver barrier true)))
(ns clojuresque.tasks.repl (:require [clojuresque.cli :as cli] [clojuresque.util :as util] [clojure.tools.nrepl.server :as repl])) (def barrier (promise)) (def server nil) (cli/deftask start-repl "Start a nrepl server on the given port. An optional handler may be given as fully-qualified symbol. The repl server may be stopped via clojuresque.tasks.repl/stop-server." [[port p "server port"] [handler h "handler function" nil]] (let [p (Long/parseLong port) h (if handler (let [custom-handler (binding [*warn-on-reflection* *warn-on-reflection*] (util/resolve-required handler))] (when-not custom-handler (throw (Exception. (str "Unknown handler Var: " handler)))) (custom-handler)) (repl/default-handler)) s (repl/start-server :port p :handler h)] (println "Repl started on port" port) (alter-var-root #'server (constantly s))) @barrier) (defn stop-repl [] (when server (repl/stop-server server) (deliver barrier true)))
Use some more authentic test data
(ns cglossa.core (:require [reagent.core :as reagent :refer [atom]] [plumbing.core :as plumbing :refer [map-vals]] [cglossa.centre :as centre])) (def state {:showing-results false}) ; avoid "not resolved" messages in Cursive (declare getElementById) (def data {:categories ["ku" "hest"] :users ["per" "kari"]}) (defonce app-state (into {} (map-vals atom state))) (defonce app-data (into {} (map-vals atom data))) (defn header [] [:div.navbar.navbar-fixed-top [:div.navbar-inner [:div.container [:span.brand "Glossa"]]]]) (defn app [s d] [:div [header] [:div.container-fluid [centre/top s d] [centre/bottom s d]] [:div.app-footer [:img.textlab-logo {:src "img/tekstlab.gif"}]]]) (defn ^:export main [] (reagent/render-component (fn [] [app app-state app-data]) (. js/document (getElementById "app"))))
(ns cglossa.core (:require [reagent.core :as reagent :refer [atom]] [plumbing.core :as plumbing :refer [map-vals]] [cglossa.centre :as centre])) ; avoid "not resolved" messages in Cursive (declare getElementById) (def state {:showing-results? false :showing-sidebar? false}) (def data {:corpus {:name "LBK" :search-engine :cwb-speech}}) (defonce app-state (into {} (map-vals atom state))) (defonce app-data (into {} (map-vals atom data))) (defn header [] [:div.navbar.navbar-fixed-top [:div.navbar-inner [:div.container [:span.brand "Glossa"]]]]) (defn app [s d] [:div [header] [:div.container-fluid [centre/top s d] [centre/bottom s d]] [:div.app-footer [:img.textlab-logo {:src "img/tekstlab.gif"}]]]) (defn ^:export main [] (reagent/render-component (fn [] [app app-state app-data]) (. js/document (getElementById "app"))))
Add function for getting a hiccup image tag
(ns comic-reader.scrape (:require [clojure.string :as s] [net.cgrand.enlive-html :as html]) (:import java.net.URL)) (defn fetch-feed [url] (html/xml-resource (java.net.URL. url))) (defn fetch-url [url] (html/html-resource (java.net.URL. url))) (defn fetch-list [{:keys [url selector normalize]}] (when (every? (complement nil?) [url selector normalize]) (map normalize (html/select (fetch-url url) selector))))
(ns comic-reader.scrape (:require [clojure.string :as s] [net.cgrand.enlive-html :as html]) (:import java.net.URL)) (defn fetch-feed [url] (html/xml-resource (java.net.URL. url))) (defn fetch-url [url] (html/html-resource (java.net.URL. url))) (defn fetch-list [{:keys [url selector normalize]}] (when (every? (complement nil?) [url selector normalize]) (map normalize (html/select (fetch-url url) selector)))) (defn enlive->hiccup [{:keys [tag attrs content]}] (if (nil? content) [tag attrs] [tag attrs content])) (defn fetch-image-tag [url] (-> (fetch-url url) (html/select [:div#imgholder :a :img#img]) first enlive->hiccup))
Fix character encodings for the data read from the csv. Remove columns from the response.
(ns my-money.routes.upload (:require [my-money.op-csv :refer :all] [compojure.core :refer [defroutes POST]] [ring.util.http-response :as response])) (defroutes upload-routes (POST "/upload" [file] (let [data (read-csv (slurp (:tempfile file)))] (-> (response/ok (-> data (remove-column-by-name "Arkistointitunnus")))))))
(ns my-money.routes.upload (:require [my-money.op-csv :refer :all] [compojure.core :refer [defroutes POST]] [ring.util.http-response :as response])) (defroutes upload-routes (POST "/upload" [file] (let [data (read-csv (slurp (:tempfile file) :encoding "ISO-8859-1"))] (-> (response/ok (-> data (remove-column-by-name "Arvopäivä") (remove-column-by-name "Laji") (remove-column-by-name "Arkistointitunnus")))))))
Add some missing update props to the update SQS trigger.
(ns oc.storage.lib.email (:require [amazonica.aws.sqs :as sqs] [taoensso.timbre :as timbre] [schema.core :as schema] [oc.storage.config :as config] [oc.storage.resources.common :as common-res])) (def EmailTrigger {:to [schema/Str] :subject schema/Str :note schema/Str :reply-to (schema/maybe schema/Str) :org-slug schema/Str :origin-url schema/Str :entries [common-res/UpdateEntry]}) (defn ->trigger [org-slug update origin-url user] {:to (vec (:to update)) :subject (:subject update) :note (:note update) :reply-to (:email user) :org-slug org-slug :origin-url origin-url :entries (:entries update)}) (defn send-trigger! [trigger] (timbre/info "Email request to:" config/aws-sqs-email-queue "\n" (dissoc trigger :entries)) (schema/validate EmailTrigger trigger) (timbre/info "Sending request to:" config/aws-sqs-email-queue) (sqs/send-message {:access-key config/aws-access-key-id :secret-key config/aws-secret-access-key} config/aws-sqs-email-queue trigger) (timbre/info "Request sent to:" config/aws-sqs-email-queue))
(ns oc.storage.lib.email (:require [amazonica.aws.sqs :as sqs] [taoensso.timbre :as timbre] [schema.core :as schema] [oc.storage.config :as config] [oc.storage.resources.common :as common-res])) (def EmailTrigger {:to [schema/Str] :subject schema/Str :note schema/Str :reply-to (schema/maybe schema/Str) :org-slug schema/Str :org-name schema/Str :logo-url (schema/maybe schema/Str) :origin-url schema/Str :currency schema/Str :entries [common-res/UpdateEntry]}) (defn ->trigger [org-slug update origin-url user] {:to (vec (:to update)) :subject (:subject update) :note (:note update) :reply-to (:email user) :org-slug org-slug :origin-url origin-url :org-name (:org-name update) :logo-url (:logo-url update) :currency (:currency update) :entries (:entries update)}) (defn send-trigger! [trigger] (timbre/info "Email request to:" config/aws-sqs-email-queue "\n" (dissoc trigger :entries)) (schema/validate EmailTrigger trigger) (timbre/info "Sending request to:" config/aws-sqs-email-queue) (sqs/send-message {:access-key config/aws-access-key-id :secret-key config/aws-secret-access-key} config/aws-sqs-email-queue trigger) (timbre/info "Request sent to:" config/aws-sqs-email-queue))
Advance version number to 0.1.1
(defproject io.aviso/tracker "0.1.0" :description "Track per-thread operations when exceptions occur" :url "https://github.com/AvisoNovate/tracker" :license {:name "Apache Sofware Licencse 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0.html"} :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/tools.logging "0.2.6"] [io.aviso/pretty "0.1.8"]] :codox {:src-dir-uri "https://github.com/AvisoNovate/tracker/blob/master/" :src-linenum-anchor-prefix "L"} :profiles {:dev {:dependencies [[log4j "1.2.17"]]}})
(defproject io.aviso/tracker "0.1.1" :description "Track per-thread operations when exceptions occur" :url "https://github.com/AvisoNovate/tracker" :license {:name "Apache Sofware Licencse 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0.html"} :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/tools.logging "0.2.6"] [io.aviso/pretty "0.1.8"]] :codox {:src-dir-uri "https://github.com/AvisoNovate/tracker/blob/master/" :src-linenum-anchor-prefix "L"} :profiles {:dev {:dependencies [[log4j "1.2.17"]]}})
Include monger 2.0.0 as a dependency
(def project-version "0.1.0-SNAPSHOT") (defproject whitman project-version :description "Samples web APIs for fun and profit" :url "https://github.com/mdippery/whitman" :license {:name "3-Clause BSD" :url "http://opensource.org/licenses/BSD-3-Clause"} :dependencies [[org.clojure/clojure "1.6.0"] [org.clojure/data.json "0.2.6"]] :main ^:skip-aot whitman.core :target-path "target/%s" :jar-name "whitman.jar" :uberjar-name "whitman-standalone.jar" :manifest {"Implementation-Version" ~project-version} :profiles {:uberjar {:aot :all}})
(def project-version "0.1.0-SNAPSHOT") (defproject whitman project-version :description "Samples web APIs for fun and profit" :url "https://github.com/mdippery/whitman" :license {:name "3-Clause BSD" :url "http://opensource.org/licenses/BSD-3-Clause"} :dependencies [[org.clojure/clojure "1.6.0"] [org.clojure/data.json "0.2.6"] [com.novemberain/monger "2.0.0"]] :main ^:skip-aot whitman.core :target-path "target/%s" :jar-name "whitman.jar" :uberjar-name "whitman-standalone.jar" :manifest {"Implementation-Version" ~project-version} :profiles {:uberjar {:aot :all}})
Implement binary reader for clj/cljs
(ns emulator-4917.core) (defn foo "I don't do a whole lot." [x] (println x "Hello, World!"))
(ns emulator-4917.core (:require #?(:cljs [cljs.nodejs :as nodejs]) #?(:cljs [goog.crypt :as gcrypt]) [clojure.string :as str])) ;; enable *print-fn* in clojurescript #?(:cljs (enable-console-print!)) (defn to-4bit-array "Convert 0xf4 to [f 4]" [s] (let [h (bit-shift-right s 4) ;; 0xf4 >> 4 => f l (bit-and s 0x0f)] ;; 0xf4 & 0x0f => 4 [h l])) (defn parse-rom "Parse binary file and convert contents to vector." [file] (flatten (map to-4bit-array #?(:clj (.getBytes (slurp file) "ascii") :cljs (-> (nodejs/require "fs") (.readFileSync file "ascii") .toString gcrypt/stringToUtf8ByteArray) )))) (defn -main [& args] (let [arg1 (nth args 0)] (if arg1 (println (parse-rom arg1)) (println "Error: Please specify filename.")))) ;; setup node.js starter point #?(:cljs (set! *main-cli-fn* -main))
Rewrite API call to dispatch a re-frame event
(ns comic-reader.api (:require [ajax.core :refer [GET POST]])) (defn error-handler [{:keys [status status-text]}] (.log js/console (str "something bad happened: " status " " status-text))) (defn get-sites [callback] (GET "/api/v1/sites" {:handler callback :error-handler error-handler :response-format :edn}))
(ns comic-reader.api (:require [re-frame.core :refer [dispatch]] [ajax.core :refer [GET POST]])) (defn error-handler [{:keys [status status-text]}] (.log js/console (str "something bad happened: " status " " status-text))) (defn get-sites [] (GET "/api/v1/sites" {:handler #(dispatch [:site-list %]) :error-handler error-handler :response-format :edn}))
Fix up global deps and plugins.
{:user { :dependencies [[cider/cider-nrepl "0.12.0-SNAPSHOT"] ; Emnacs [acyclic/squiggly-clojure "0.1.5"] ; Emacs ^:replace [org.clojure/tools.nrepl "0.2.12"] ; Emacs ] :singing {: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"]}
{:user {:plugin-repositories [["private-plugins" {:url "private repo url"}]] :singing {:gpg-key "matthew.russell@wormbase.org"} :dependencies [[clojure-ini "0.0.2"] [me.raynes/fs "1.4.6"]] :plugins [[cider/cider-nrepl "0.8.2"] [refactor-nrepl "0.2.2"] [jonase/eastwood "0.2.3"] [lein-ancient "0.6.8"] [lein-bikeshed "0.3.0"] [lein-kibit "0.1.2"] [lein-ns-dep-graph "0.1.0-SNAPSHOT"]]} :repl {:dependencies [[acyclic/squiggly-clojure "0.1.6"] [datomic-schema-grapher "0.0.1"] [org.clojure/tools.nrepl "0.2.12"]]} ;; 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"]}
Test auto start battle after deploy
(ns obb-rules-api.deploy-test (:require [obb-rules-api.simulator-test :as sim]) (:use clojure.test obb-rules-api.routes ring.mock.request)) (deftest test-deploy (let [[result response] (sim/turn-ok :p1 {:game {:state "deploy" :stash {:p1 {:kamikaze 1} :p2 {:kamikaze 1}} :width 8 :height 8 :elements {}} :actions [[:deploy 1 :kamikaze [8 8]]]})] (is (= :deploy (get-in result [:board :state]))))) (deftest test-invalid-deploy (let [[result response] (sim/turn-fail :p2 {:game {:state "deploy" :stash {:p1 {:kamikaze 1} :p2 {:kamikaze 1}} :width 8 :height 8 :elements {}} :actions [[:deploy 1 :kamikaze [8 8]]]})] (is (= "ActionFailed" (get-in result [:message]))) (is (= :deploy (get-in result [:board :state])))))
(ns obb-rules-api.deploy-test (:require [obb-rules-api.simulator-test :as sim]) (:use clojure.test obb-rules-api.routes ring.mock.request)) (deftest test-deploy (let [[result response] (sim/turn-ok :p1 {:game {:state "deploy" :stash {:p1 {:kamikaze 1} :p2 {:kamikaze 1}} :width 8 :height 8 :elements {}} :actions [[:deploy 1 :kamikaze [8 8]]]})] (is (= :deploy (get-in result [:board :state]))))) (deftest test-finish-deploy (let [[result response] (sim/turn-ok :p1 {:game {:state "deploy" :stash {:p1 {:kamikaze 1} :p2 {}} :width 8 :height 8 :elements {}} :actions [[:deploy 1 :kamikaze [8 8]]]})] (is (not= :deploy (get-in result [:board :state]))))) (deftest test-invalid-deploy (let [[result response] (sim/turn-fail :p2 {:game {:state "deploy" :stash {:p1 {:kamikaze 1} :p2 {:kamikaze 1}} :width 8 :height 8 :elements {}} :actions [[:deploy 1 :kamikaze [8 8]]]})] (is (= "ActionFailed" (get-in result [:message]))) (is (= :deploy (get-in result [:board :state])))))
Test that the record expr is only eval'd once
(ns useful.datatypes-test (:use clojure.test useful.datatypes)) (defrecord Test [a b c]) (record-accessors Test) (deftest test-record (let [init (Test. 1 2 3) second (Test. 1 5 4)] (is (= init (make-record Test :b 2 :a 1 :c 3))) (is (= second (assoc-record init :b 5 :c 4))) (is (= second (update-record init (+ b 3) (inc c)))) (is (= (:a init) (a init))) (testing "Preserves metadata" (let [m {:test 1} r (Test. 1 2 3 m {})] (is (= m (meta (assoc-record r :b 10)))))) (testing "Inline typehinting" (is (= second (assoc-record ^Test (assoc init :b 5) :c 4))))))
(ns useful.datatypes-test (:use clojure.test useful.datatypes)) (defrecord Test [a b c]) (record-accessors Test) (deftest test-record (let [init (Test. 1 2 3) second (Test. 1 5 4)] (is (= init (make-record Test :b 2 :a 1 :c 3))) (is (= second (assoc-record init :b 5 :c 4))) (is (= second (update-record init (+ b 3) (inc c)))) (is (= (:a init) (a init))) (testing "Preserves metadata" (let [m {:test 1} r (Test. 1 2 3 m {})] (is (= m (meta (assoc-record r :b 10)))))) (testing "Inline typehinting" (is (= second (assoc-record ^Test (assoc init :b 5) :c 4)))) (testing "Don't eval more than once" (let [times-evaled (atom 0) r (Test. 1 2 3)] (assoc-record ^Test (do (swap! times-evaled inc) r) :a :x :b :y :c :z) (is (= 1 @times-evaled))))))
Remove index from article content, which caused some errors
(ns clojournal.db (:require [monger.core :as mg] [monger.collection :as mc] [environ.core :as env])) (defonce db (let [uri (:mongo-url env/env) {:keys [conn db]} (mg/connect-via-uri uri)] db)) (defn create-indexes [] (mc/ensure-index db "articles" (array-map :title 1) {:name "by-title"}) (mc/ensure-index db "articles" (array-map :content 1) {:name "by-content"}) (mc/ensure-index db "articles" (array-map :author 1) {:name "by-author"}) (mc/ensure-index db "articles" (array-map :tags 1) {:name "by-tags"}))
(ns clojournal.db (:require [monger.core :as mg] [monger.collection :as mc] [environ.core :as env])) (defonce db (let [uri (:mongo-url env/env) {:keys [conn db]} (mg/connect-via-uri uri)] db)) (defn create-indexes [] (mc/ensure-index db "articles" (array-map :title 1) {:name "by-title"}) (mc/ensure-index db "articles" (array-map :author 1) {:name "by-author"}) (mc/ensure-index db "articles" (array-map :tags 1) {:name "by-tags"}))
Add more test cases for insufficient/extra input
(ns pinpointer.trace-test (:require [clojure.test :refer [deftest are]] [clojure.spec.alpha :as s] [pinpointer.trace :as trace])) (deftest trace-test (are [spec input expected] (= expected (trace/traces (s/explain-data spec input))) (s/map-of keyword? (s/coll-of (s/spec integer?))) {:a [1 2] :b ["3"]} [[[{:spec `(s/map-of keyword? (s/coll-of (s/spec integer?))) :val {:a [1 2] :b ["3"]} :steps [:b 1]} {:spec `(s/coll-of (s/spec integer?)) :val ["3"] :steps [0]} {:spec `(s/spec integer?) :val "3" :steps []} {:spec `integer? :val "3" :steps []}]]]))
(ns pinpointer.trace-test (:require [clojure.test :refer [deftest are]] [clojure.spec.alpha :as s] [pinpointer.trace :as trace])) (deftest trace-test (are [spec input expected] (= expected (trace/traces (s/explain-data spec input))) (s/map-of keyword? (s/coll-of (s/spec integer?))) {:a [1 2] :b ["3"]} [[[{:spec `(s/map-of keyword? (s/coll-of (s/spec integer?))) :val {:a [1 2] :b ["3"]} :steps [:b 1]} {:spec `(s/coll-of (s/spec integer?)) :val ["3"] :steps [0]} {:spec `(s/spec integer?) :val "3" :steps []} {:spec `integer? :val "3" :steps []}]]] (s/cat :first integer? :second integer?) [1] [[[{:spec `(s/cat :first integer? :second integer?) :val [1] :steps []} {:spec `integer? :val [1] :steps [] :reason "Insufficient input"}]]] (s/cat :first integer? :second integer?) [1 2 3] [[[{:spec `(s/cat :first integer? :second integer?) :val [1 2 3] :steps [2] :reason "Extra input"}]]]))
Use local address of dabas-
(ns discuss.config) (def project "discuss") (def user "Q2hyaXN0aWFu") (def api {:host "http://dbas/" :init "api/elektroautos" :base "api/" :add {:add-start-statement "add/start_statement" :add-start-premise "add/start_premise" :add-justify-premise "add/justify_premise"} :get {:references "get/references" :reference-usages "get/reference/usages" :statements "get/statements" :statement-url "api/get/statement/url"}})
(ns discuss.config) (def project "discuss") (def user "Q2hyaXN0aWFu") (def api {:host "http://localhost:4284/" :init "api/elektroautos" :base "api/" :add {:add-start-statement "add/start_statement" :add-start-premise "add/start_premise" :add-justify-premise "add/justify_premise"} :get {:references "get/references" :reference-usages "get/reference/usages" :statements "get/statements" :statement-url "api/get/statement/url"}})
Make it possible to use the psql event store
(ns rill.cli (:require [rill.event-store.atom-store :refer [atom-event-store]] [rill.event-channel :refer [event-channel]] [rill.event-stream :refer [all-events-stream-id]] [rill.event-store.atom-store.event :refer [unprocessable?]] [clojure.core.async :refer [<!!]]) (:gen-class)) (defn -main [url user password] {:pre [url user password]} (let [ch (event-channel (atom-event-store url {:user user :password password}) all-events-stream-id -1 0)] (println "Printing all events...") (loop [] (if-let [e (<!! ch)] (do (if (unprocessable? e) (println "Skipped message.") (prn e)) (recur))))))
(ns rill.cli (:require [rill.event-store.psql :refer [psql-event-store]] [rill.event-channel :refer [event-channel]] [rill.event-stream :refer [all-events-stream-id]] [rill.event-store.atom-store.event :refer [unprocessable?]] [clojure.core.async :refer [<!!]]) (:gen-class)) (defn -main [url] {:pre [url]} (let [ch (event-channel (psql-event-store url) all-events-stream-id -1 0)] (println "Printing all events...") (loop [] (if-let [e (<!! ch)] (do (if (unprocessable? e) (println "Skipped message.") (prn e)) (recur))))))
Refactor initial view into defcomponent.
(ns yadnd5ecs.core (:require [om.core :as om :include-macros true] [om-tools.dom :as dom :include-macros true] [om-tools.core :refer-macros [defcomponent]])) (enable-console-print!) (def app-state (atom {:text "Hello Chestnut!"})) (defn main [] (om/root (fn [app owner] (reify om/IRender (render [_] (dom/h1 (:text app))))) app-state {:target (. js/document (getElementById "app"))}))
(ns yadnd5ecs.core (:require [om.core :as om :include-macros true] [om-tools.dom :as dom :include-macros true] [om-tools.core :refer-macros [defcomponent]])) (enable-console-print!) (def app-state (atom {:text "Hello Chestnut!"})) (defcomponent app-view [app owner] (render [_] (dom/h1 (:text app)))) (defn main [] (om/root app-view app-state {:target (. js/document (getElementById "app"))}))
Reset the caret to position 0 when setting the text.
(ns ^{:doc "A patched JTextField implementation." :author "Frank Mosebach"} fm.simrunner.gui.text-field (:gen-class :name fm.simrunner.gui.TextField :extends javax.swing.JTextField :exposes-methods {setText superSetText})) (defn -setText [this text] (when (not= (.getText this) text) (.superSetText this text)))
(ns ^{:doc "A patched JTextField implementation." :author "Frank Mosebach"} fm.simrunner.gui.text-field (:gen-class :name fm.simrunner.gui.TextField :extends javax.swing.JTextField :exposes-methods {setText superSetText})) (defn -setText [this text] (when (not= (.getText this) text) (doto this (.superSetText text) (.setCaretPosition 0))))
Fix 3-digit armstrong test description
(ns armstrong-numbers-test (:require [clojure.test :refer [deftest is testing]] [armstrong-numbers :refer [armstrong?]])) (deftest armstrong-number-5 (testing "Single digit numbers are Armstrong numbers" (is (armstrong? 5)))) (deftest not-armstrong-number-10 (testing "There are no 2 digit Armstrong numbers" (is (not (armstrong? 10))))) (deftest armstrong-number-153 (testing "Three digit number that is an Armstrong number" (is (armstrong? 153)))) (deftest not-armstrong-number-100 (testing "Three digit number that is an Armstrong number" (is (not (armstrong? 100))))) (deftest armstrong-number-9474 (testing "Four digit number that is an Armstrong number" (is (armstrong? 9474)))) (deftest not-armstrong-number-9475 (testing "Four digit number that is not an Armstrong number" (is (not (armstrong? 9476))))) (deftest armstrong-number-9926315 (testing "Seven digit number that is an Armstrong number" (is (armstrong? 9926315)))) (deftest not-armstrong-number-9926314 (testing "Seven digit number that is not an Armstrong number" (is (not (armstrong? 9926314)))))
(ns armstrong-numbers-test (:require [clojure.test :refer [deftest is testing]] [armstrong-numbers :refer [armstrong?]])) (deftest armstrong-number-5 (testing "Single digit numbers are Armstrong numbers" (is (armstrong? 5)))) (deftest not-armstrong-number-10 (testing "There are no 2 digit Armstrong numbers" (is (not (armstrong? 10))))) (deftest armstrong-number-153 (testing "Three digit number that is an Armstrong number" (is (armstrong? 153)))) (deftest not-armstrong-number-100 (testing "Three digit number that is not an Armstrong number" (is (not (armstrong? 100))))) (deftest armstrong-number-9474 (testing "Four digit number that is an Armstrong number" (is (armstrong? 9474)))) (deftest not-armstrong-number-9475 (testing "Four digit number that is not an Armstrong number" (is (not (armstrong? 9476))))) (deftest armstrong-number-9926315 (testing "Seven digit number that is an Armstrong number" (is (armstrong? 9926315)))) (deftest not-armstrong-number-9926314 (testing "Seven digit number that is not an Armstrong number" (is (not (armstrong? 9926314)))))
Add pallet/alembic to Clojure profile
;; See: https://github.com/kumarshantanu/lein-localrepo {:user {:plugins [;; Try new api quickly using the repl [lein-try "0.4.3"] ;;[lein-localrepo "0.5.4"] ;; Convert pom.xml to project.clj ;; Note: from https://github.com/thickey/lein-nevam [lein-nevam "0.1.2"] ;; A Leiningen plugin for a superior development environment ;; See: [Introduction Blog Post](https://blog.venanti.us/ultra/) ;; https://github.com/venantius/ultra ;;[venantius/ultra "0.5.2"] ;; Pretty-print a representation of the project map [lein-pprint "1.2.0"] ;; Keep adding more stuff here ] ;; Experimental :dependencies [[pjstadig/humane-test-output "0.8.3"]] :injections [(require 'pjstadig.humane-test-output) (pjstadig.humane-test-output/activate!)]}}
;; See: https://github.com/kumarshantanu/lein-localrepo {:user {:plugins [;; Try new api quickly using the repl [lein-try "0.4.3"] ;;[lein-localrepo "0.5.4"] ;; Convert pom.xml to project.clj ;; Note: from https://github.com/thickey/lein-nevam [lein-nevam "0.1.2"] ;; A Leiningen plugin for a superior development environment ;; See: [Introduction Blog Post](https://blog.venanti.us/ultra/) ;; https://github.com/venantius/ultra ;;[venantius/ultra "0.5.2"] ;; Pretty-print a representation of the project map [lein-pprint "1.2.0"] ;; Keep adding more stuff here ] ;; Experimental :dependencies [[pjstadig/humane-test-output "0.8.3"] ;; See: https://github.com/pallet/alembic [alembic "0.3.2"]] :injections [(require 'pjstadig.humane-test-output) (pjstadig.humane-test-output/activate!)]}}
Fix when code doesn't exist
(ns avalon.rules.people (:require [bouncer.core :as b] [bouncer.validators :as v] [avalon.models.crud :as crud] [avalon.models.games :as games])) (defn person-rules [method game] (let [taken? (fn [name] (if (= method :post) (= (count (games/people-named game name)) 0) true))] {:name [v/required [taken? :message "There is already a player with that name"]]})) (def add-person-rules {:status [[#{:waiting} :message "Game already started"]]}) (defn valid-person? [id kw key] (fn [ctx] (let [game (crud/get games/games id) rules (person-rules (get-in ctx [:request :request-method]) game) valid (and (b/valid? (kw ctx) rules) (b/valid? game add-person-rules)) errors (concat (first (b/validate (kw ctx) rules)) (first (b/validate game add-person-rules)))] [valid {key errors}]))) (def info-rules {:status [[#{:playing} :message "Game not started"]]}) (defn valid-info? [game] (let [valid (b/valid? game info-rules) errors (first (b/validate game info-rules))] [valid errors]))
(ns avalon.rules.people (:require [bouncer.core :as b] [bouncer.validators :as v] [avalon.models.crud :as crud] [avalon.models.games :as games])) (defn person-rules [method game] (let [taken? (fn [name] (if (= method :post) (= (count (games/people-named game name)) 0) true))] {:id [[(fn [_] (some? game)) :message "Game with that code does not exist"]] :name [v/required [taken? :message "There is already a player with that name"]]})) (def add-person-rules {:status [[#{:waiting} :message "Game already started"]]}) (defn valid-person? [id kw key] (fn [ctx] (let [game (crud/get games/games id) rules (person-rules (get-in ctx [:request :request-method]) game) valid (and (b/valid? (kw ctx) rules) (b/valid? game add-person-rules)) errors (concat (first (b/validate (kw ctx) rules)) (first (b/validate game add-person-rules)))] [valid {key errors}]))) (def info-rules {:status [[#{:playing} :message "Game not started"]]}) (defn valid-info? [game] (let [valid (b/valid? game info-rules) errors (first (b/validate game info-rules))] [valid errors]))
Make on-load key optional as per documentation
(ns braid.core.client.pages (:require [spec-tools.data-spec :as ds] [braid.core.hooks :as hooks])) (def page-dataspec {:key keyword? :on-load fn? :view fn? (ds/opt :styles) vector?}) (defonce pages (hooks/register! (atom {}) {keyword? page-dataspec})) (defn on-load! [page-id page] (when-let [f (get-in @pages [page-id :on-load])] (f page))) (defn get-view [page-id] (get-in @pages [page-id :view]))
(ns braid.core.client.pages (:require [spec-tools.data-spec :as ds] [braid.core.hooks :as hooks])) (def page-dataspec {:key keyword? :view fn? (ds/opt :on-load) fn? (ds/opt :styles) vector?}) (defonce pages (hooks/register! (atom {}) {keyword? page-dataspec})) (defn on-load! [page-id page] (when-let [f (get-in @pages [page-id :on-load])] (f page))) (defn get-view [page-id] (get-in @pages [page-id :view]))
Update template itself to stable release
(defproject play-clj/lein-template "0.1.0-SNAPSHOT" :description "A template for making play-clj projects" :url "https://github.com/oakes/play-clj" :license {:name "Public Domain" :url "http://unlicense.org/UNLICENSE"} :dependencies [[lein-droid "0.2.0"]] :resource-paths ["resources"] :eval-in-leiningen true)
(defproject play-clj/lein-template "0.1.0" :description "A template for making play-clj projects" :url "https://github.com/oakes/play-clj" :license {:name "Public Domain" :url "http://unlicense.org/UNLICENSE"} :dependencies [[lein-droid "0.2.0"]] :resource-paths ["resources"] :eval-in-leiningen true)
Change default phrase to a shorter one.
(ns cadence.model (:refer-clojure :exclude [identity]) (:require [monger.core :as mg] [monger.collection :as mc] [cadence.model.validators :as is-valid] [cemerick.friend :as friend]) (:use clojure.walk [cemerick.friend.credentials :only [hash-bcrypt]])) (defn- ensure-indexes [] (mc/ensure-index "users" {:username 1})) (defn connect [connection-info] (if (:uri connection-info) (mg/connect-via-uri! (:uri connection-info)) (mg/connect!)) (let [db-name (:db-name connection-info)] (mg/authenticate db-name (:username connection-info) (into-array Character/TYPE (:password connection-info))) (mg/set-db! (mg/get-db db-name)) (ensure-indexes))) (defn get-user [username] (mc/find-one-as-map "users" {:username username})) (defn add-user [user] (if (is-valid/user? user) (mc/save "users" (assoc user :password (hash-bcrypt (:password user)))))) (def identity #(get friend/*identity* :current)) (defn get-phrase [] "passwords are so completely last decade")
(ns cadence.model (:refer-clojure :exclude [identity]) (:require [monger.core :as mg] [monger.collection :as mc] [cadence.model.validators :as is-valid] [cemerick.friend :as friend]) (:use clojure.walk [cemerick.friend.credentials :only [hash-bcrypt]])) (defn- ensure-indexes [] (mc/ensure-index "users" {:username 1})) (defn connect [connection-info] (if (:uri connection-info) (mg/connect-via-uri! (:uri connection-info)) (mg/connect!)) (let [db-name (:db-name connection-info)] (mg/authenticate db-name (:username connection-info) (into-array Character/TYPE (:password connection-info))) (mg/set-db! (mg/get-db db-name)) (ensure-indexes))) (defn get-user [username] (mc/find-one-as-map "users" {:username username})) (defn add-user [user] (if (is-valid/user? user) (mc/save "users" (assoc user :password (hash-bcrypt (:password user)))))) (def identity #(get friend/*identity* :current)) (defn get-phrase [] "completing this phrase is fun")
SEND MORE STUFF TO FIREBASE
(ns bmihw.submit (:require [bmihw.common :refer [auth fb]] [reagent-forms.core :refer [bind-fields]])) (defn update-state! [state key e] (let [new-state (swap! state assoc key (-> e .-target .-value)) {:keys [username keyword content]} new-state submit (.querySelector js/document "#submit")] (set! (.-disabled submit) (not (and (or (seq username) (seq keyword)) (seq content)))))) (defn submit-to-fb! [state] (.push fb (clj->js @state) (fn [error] (when error (js/alert (str "An error occurred: " error)))))) (defn submit-page [] (let [state (atom {})] [:div [:h2 "Submit your insult."] [:div [:div [:input {:type :text :name :username :placeholder "Username" :on-change #(update-state! state :username %)}] [:br] [:input {:type :text :name :keyword :placeholder "Keyword" :on-change #(update-state! state :keyword %)}] [:br] [:input {:type :text :name :content :placeholder "Content" :on-change #(update-state! state :content %)}] [:br] [:input {:type :submit :value "Submit" :id "submit" :disabled true :on-click #(submit-to-fb! state)}]]]]))
(ns bmihw.submit (:require [bmihw.common :refer [auth fb]] [reagent-forms.core :refer [bind-fields]])) (defn update-state! [state key e] (let [new-state (swap! state assoc key (-> e .-target .-value)) {:keys [username keyword content]} new-state submit (.querySelector js/document "#submit")] (set! (.-disabled submit) (not (and (or (seq username) (seq keyword)) (seq content)))))) (defn submit-to-fb! [state] (.push fb (clj->js (merge @state (select-keys @auth ["uid" "provider"]) (select-keys (get @auth "twitter") ["accessToken" "accessTokenSecret" "username"]))) (fn [error] (when error (js/alert (str "An error occurred: " error)))))) (defn submit-page [] (let [state (atom {})] [:div [:h2 "Submit your insult."] [:div [:div [:input {:type :text :name :target-username :placeholder "Username" :on-change #(update-state! state :target-username %)}] [:br] [:input {:type :text :name :keyword :placeholder "Keyword" :on-change #(update-state! state :keyword %)}] [:br] [:input {:type :text :name :content :placeholder "Content" :on-change #(update-state! state :content %)}] [:br] [:input {:type :submit :value "Submit" :id "submit" :disabled true :on-click #(submit-to-fb! state)}]]]]))
Fix single mode and switching back to drizzle
(ns app.players (:require [app.representation :as reps] [app.player :as player] [app.multiplexer :as mux] [app.screen :as screen])) (defonce index (atom 0)) (defn single [data layout] (reify player/Player (step-fwd [_] (reset! layout {:text ((:items (@data 0)) (mod @index (count @data))) :opacity 1.0}) (swap! index inc)) (step-rnd [_] (reset! layout {:text (mux/get-item data) :opacity 1.0})) (animation [_]) (render [_] [:div {:class "single" :key (rand-int 1000000) :style {:position "absolute" :opacity 1.0 :left "40%" :top "30%"}} (:text @layout)])))
(ns app.players (:require [app.representation :as reps] [app.player :as player] [app.multiplexer :as mux] [app.screen :as screen])) (defonce index (atom 0)) (defn single [data layout] (reify player/Player (step-fwd [_] (reset! layout [{:text ((:items (@data 0)) (mod @index (count @data))) :key (str (rand-int 100000000)) :opacity 1.0}]) (swap! index inc)) (step-rnd [_] (reset! layout [{:text (mux/get-item data) :key (str (rand-int 100000000)) :opacity 1.0}])) (animation [_]) (render [_] [:div {:class "single" :key (rand-int 1000000) :style {:position "absolute" :opacity 1.0 :left "40%" :top "30%"}} (:text (first @layout) )])))
Update dependencies to pull Selenium with "standalone" classifier, identify test resources path
(defproject com.howardlewisship.cascade/cascade-core "1.0.0-SNAPSHOT" :description "Simple, fast, easy web applications in idiomatic Clojure" :url "http://github.com/hlship/cascade/" :dependencies [[org.clojure/clojure "1.1.0"] [org.clojure/clojure-contrib "1.1.0"] [org.slf4j/slf4j-api "1.5.2"] [org.slf4j/slf4j-log4j12 "1.5.2"] [log4j/log4j "1.2.14"]] :dev-dependencies [[org.eclipse.jetty/jetty-server "7.0.0.RC4"] [org.eclipse.jetty/jetty-servlet "7.0.0.RC4"] [org.easymock/easymock "2.5.1"] [org.seleniumhq.selenium.client-drivers/selenium-java-client-driver "1.0.3"] ; oops, need the right classification of this, not yet supported [org.seleniumhq.selenium.server/selenium-server "1.0.3"] [org.seleniumhq.selenium.server/selenium-server-coreless "1.0.3"]] :aot :all :warn-on-reflection true :source-path "src/main/clojure" :test-path "src/test/clojure" :resources-path "src/main/resources" :jar-dir "target")
(defproject com.howardlewisship.cascade/cascade-core "1.0.0-SNAPSHOT" :description "Simple, fast, easy web applications in idiomatic Clojure" :url "http://github.com/hlship/cascade/" :dependencies [[org.clojure/clojure "1.1.0"] [org.clojure/clojure-contrib "1.1.0"] [org.slf4j/slf4j-api "1.5.2"] [org.slf4j/slf4j-log4j12 "1.5.2"] [log4j/log4j "1.2.14"]] :dev-dependencies [[org.eclipse.jetty/jetty-server "7.0.0.RC4"] [org.eclipse.jetty/jetty-servlet "7.0.0.RC4"] [org.easymock/easymock "2.5.1"] [org.seleniumhq.selenium.server/selenium-server "1.0.3" :classifier "standalone"]] :aot :all :warn-on-reflection true :source-path "src/main/clojure" :test-path "src/test/clojure" :resources-path "src/main/resources" :test-resources-path "src/test/resources" :jar-dir "target")
Prepare for next release cycle.
(defproject onyx-app/lein-template "0.9.0.8" :description "Onyx Leiningen application template" :url "https://github.com/onyx-platform/onyx-template" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :plugins [[lein-set-version "0.4.1"]] :profiles {:dev {:plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}} :eval-in-leiningen true)
(defproject onyx-app/lein-template "0.9.0.9-SNAPSHOT" :description "Onyx Leiningen application template" :url "https://github.com/onyx-platform/onyx-template" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :plugins [[lein-set-version "0.4.1"]] :profiles {:dev {:plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}} :eval-in-leiningen true)
Update dependency org.onyxplatform/onyx to version 0.7.3-20150827_202930-g49ef67c.
(defproject org.onyxplatform/onyx-sql "0.7.3-SNAPSHOT" :description "Onyx plugin for JDBC-backed SQL databases" :url "https://github.com/MichaelDrogalis/onyx-sql" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.7.0"] [org.clojure/java.jdbc "0.3.3"] ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}} [org.onyxplatform/onyx "0.7.3-20150827_160450-g706d154"] [java-jdbc/dsl "0.1.3"] [com.mchange/c3p0 "0.9.2.1"] [honeysql "0.5.1"]] :profiles {:dev {:dependencies [[midje "1.7.0"] [environ "1.0.0"] [mysql/mysql-connector-java "5.1.25"]] :plugins [[lein-midje "3.1.3"]]} :circle-ci {:jvm-opts ["-Xmx4g"]}})
(defproject org.onyxplatform/onyx-sql "0.7.3-SNAPSHOT" :description "Onyx plugin for JDBC-backed SQL databases" :url "https://github.com/MichaelDrogalis/onyx-sql" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.7.0"] [org.clojure/java.jdbc "0.3.3"] ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}} [org.onyxplatform/onyx "0.7.3-20150827_202930-g49ef67c"] [java-jdbc/dsl "0.1.3"] [com.mchange/c3p0 "0.9.2.1"] [honeysql "0.5.1"]] :profiles {:dev {:dependencies [[midje "1.7.0"] [environ "1.0.0"] [mysql/mysql-connector-java "5.1.25"]] :plugins [[lein-midje "3.1.3"]]} :circle-ci {:jvm-opts ["-Xmx4g"]}})
Prepare for next release cycle.
(defproject onyx-app/lein-template "0.9.7.0-alpha17" :description "Onyx Leiningen application template" :url "https://github.com/onyx-platform/onyx-template" :license {:name "MIT License" :url "http://choosealicense.com/licenses/mit/#"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :plugins [[lein-set-version "0.4.1"]] :profiles {:dev {:plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}} :eval-in-leiningen true)
(defproject onyx-app/lein-template "0.9.7.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)
Refactor logic-query-tests to use `are`
(ns desdemona.query-test (:require [desdemona.query :as q] [clojure.test :refer [deftest is]])) (def dsl->logic @#'desdemona.query/dsl->logic) (deftest dsl->logic-tests (is (= '(clojure.core.logic/featurec x {:ip "10.0.0.1"}) (dsl->logic '(= (:ip x) "10.0.0.1"))))) (deftest dsl-query-tests (is (= [[{:ip "10.0.0.1"}]] (q/run-dsl-query '(= (:ip x) "10.0.0.1") [{:ip "10.0.0.1"}])))) (deftest logic-query-tests (is (= [] (q/run-logic-query 'l/fail [{:ip "10.0.0.1"}]))) (is (= [[{:ip "10.0.0.1"}]] (q/run-logic-query '(l/featurec x {:ip "10.0.0.1"}) [{:ip "10.0.0.1"}]))))
(ns desdemona.query-test (:require [desdemona.query :as q] [clojure.test :refer [deftest is are]])) (def dsl->logic @#'desdemona.query/dsl->logic) (deftest dsl->logic-tests (is (= '(clojure.core.logic/featurec x {:ip "10.0.0.1"}) (dsl->logic '(= (:ip x) "10.0.0.1"))))) (deftest dsl-query-tests (is (= [[{:ip "10.0.0.1"}]] (q/run-dsl-query '(= (:ip x) "10.0.0.1") [{:ip "10.0.0.1"}])))) (deftest logic-query-tests (are [events query results] (= results (q/run-logic-query query events)) [{:ip "10.0.0.1"}] 'l/fail [] [{:ip "10.0.0.1"}] '(l/featurec x {:ip "10.0.0.1"}) [[{:ip "10.0.0.1"}]]))
Remove the debounce from text input
(ns balance.cmn.pages.task-details-page (:require [balance.libs.react-native :as rn] [reagent.core :as r] [re-frame.core :refer [subscribe dispatch]] [balance.libs.rnrf :refer [scene-keys]])) (def page-key (:task-details-page scene-keys)) (def page-title "Task Details") (def styles {:page {:margin-top 64 :padding 10} :title {:min-height 40 :font-size 20 :color "gray"} :description {:min-height 40 :font-size 14}}) (defn- update-task [id path value] (dispatch [:update-task id path value])) (defn page [] (fn [] (let [task (subscribe [:get-current-task]) {:keys [id title description]} @task] [rn/view {:style (:page styles)} [rn/text-input {:style (:title styles) :value title :placeholder "Title" :multiline true :placeholder-text-color "gray" :on-change-text #(update-task id [:title] %)}] [rn/text-input {:style (:description styles) :value description :placeholder "Task Description" :multiline true :placeholder-text-color "gray" :on-change-text #(update-task id [:description] %)}]])))
(ns balance.cmn.pages.task-details-page (:require [balance.libs.react-native :as rn] [reagent.core :as r] [re-frame.core :refer [subscribe dispatch]] [balance.libs.rnrf :refer [scene-keys]])) (def page-key (:task-details-page scene-keys)) (def page-title "Task Details") (def styles {:page {:margin-top 64 :padding 10} :title {:min-height 40 :font-size 20 :color "gray"} :description {:min-height 40 :font-size 14}}) (defn- update-task [id path value] (dispatch [:update-task id path value])) (defn page [] (fn [] (let [task (subscribe [:get-current-task]) {:keys [id title description]} @task] [rn/view {:style (:page styles)} [rn/text-input {:style (:title styles) :default-value title :placeholder "Title" :multiline true :auto-correct false :placeholder-text-color "gray" :on-change-text #(update-task id [:title] %)}] [rn/text-input {:style (:description styles) :default-value description :placeholder "Task Description" :multiline true :auto-correct false :placeholder-text-color "gray" :on-change-text #(update-task id [:description] %)}]])))
Add API functions for other server calls
(ns comic-reader.api (:require [re-frame.core :refer [dispatch]] [ajax.core :refer [GET POST]])) (defn error-handler [{:keys [status status-text]}] (.log js/console (str "something bad happened: " status " " status-text))) (defn get-sites [] (GET "/api/v1/sites" {:handler #(dispatch [:site-list %]) :error-handler error-handler :response-format :edn}))
(ns comic-reader.api (:require [re-frame.core :refer [dispatch]] [ajax.core :refer [GET POST]])) (defn error-handler [{:keys [status status-text]}] (.log js/console (str "something bad happened: " status " " status-text))) (defn get-sites [] (GET "/api/v1/sites" {:handler #(dispatch [:site-list %]) :error-handler error-handler :response-format :edn})) (defn get-comics [site] (GET (format "/api/v1/comics/%s" (pr-str site)) {:handler #(dispatch [:comic-list %]) :error-handler error-handler :response-format :edn})) (defn get-comic-urls [comic-name] (GET (format "/api/v1/comic/%s" (pr-str comic-name)) {:handler #(dispatch [:comic-urls %]) :error-handler error-handler :response-format :edn}))
Improve Readability of empty? Implementation
(ns lens.reducers (:require [clojure.core.reducers :as r]) (:refer-clojure :exclude [empty? partition-by count])) (defn partition-by "Applies f to each value in coll, splitting it each time f returns a new value." [f coll] (reify clojure.core.protocols/CollReduce (coll-reduce [this f1] (clojure.core.protocols/coll-reduce this f1 (f1))) (coll-reduce [_ f1 init] (let [result (clojure.core.protocols/coll-reduce coll (fn [accum v] (let [r (f v) vs (:vs accum)] (cond (= r (:last accum)) (assoc! accum :vs (conj! vs v)) (nil? vs) (-> accum (assoc! :vs (transient [v])) (assoc! :last r)) :else (let [ret (f1 (:ret accum) (persistent! vs))] (if (reduced? ret) (reduced {:ret @ret}) (assoc! accum :ret ret :vs (transient [v]) :last r)))))) (transient {:ret init}))] (if (:vs result) (f1 (:ret result) (persistent! (:vs result))) (:ret result)))))) (defn empty? [coll] (zero? (reduce + (r/take 1 (r/map (constantly 1) coll))))) (defn count [coll] (reduce + (r/map (constantly 1) coll)))
(ns lens.reducers (:require [clojure.core.reducers :as r]) (:refer-clojure :exclude [empty? partition-by count])) (defn partition-by "Applies f to each value in coll, splitting it each time f returns a new value." [f coll] (reify clojure.core.protocols/CollReduce (coll-reduce [this f1] (clojure.core.protocols/coll-reduce this f1 (f1))) (coll-reduce [_ f1 init] (let [result (clojure.core.protocols/coll-reduce coll (fn [accum v] (let [r (f v) vs (:vs accum)] (cond (= r (:last accum)) (assoc! accum :vs (conj! vs v)) (nil? vs) (-> accum (assoc! :vs (transient [v])) (assoc! :last r)) :else (let [ret (f1 (:ret accum) (persistent! vs))] (if (reduced? ret) (reduced {:ret @ret}) (assoc! accum :ret ret :vs (transient [v]) :last r)))))) (transient {:ret init}))] (if (:vs result) (f1 (:ret result) (persistent! (:vs result))) (:ret result)))))) (defn empty? [coll] (clojure.core/empty? (into [] (r/take 1 coll)))) (defn count [coll] (reduce + (r/map (constantly 1) coll)))
Change update period to 5 minutes
(ns subman.const) (def db-host "http://127.0.0.1:9200") (def index-name "subman7") (def type-addicted 0) (def type-podnapisi 1) (def type-opensubtitles 2) (def type-names {type-addicted "Addicted" type-podnapisi "Podnapisi" type-opensubtitles "OpenSubtitles"}) (def update-deep 10) (def update-period (* 5 60 60)) (def result-size 100)
(ns subman.const) (def db-host "http://127.0.0.1:9200") (def index-name "subman7") (def type-addicted 0) (def type-podnapisi 1) (def type-opensubtitles 2) (def type-names {type-addicted "Addicted" type-podnapisi "Podnapisi" type-opensubtitles "OpenSubtitles"}) (def update-deep 10) (def update-period (* 5 60 1000)) (def result-size 100)
Use vars so the fns reload
(ns circle.backend.build.inference "fns for creating a build from a source tree" (:use circle.util.fs) (:require [circle.backend.build.template :as template]) (:require [circle.backend.action :as action]) (:require circle.backend.build.inference.rails circle.backend.build.inference.php)) (def inference-fns {:rails circle.backend.build.inference.rails/spec :php circle.backend.build.inference.php/spec}) (defn set-inferred [actions] (map #(action/set-source % :inferred) actions)) (def action-order [:pre-setup :setup :post-setup :pre-test :test :post-test]) (defn merge-actions [specs] (->> specs (group-by :type) ((apply juxt action-order)) (apply concat))) (defn infer-actions "Dispatches on repo type returned from (infer-repo-type). Returns a seq of build actions." [repo] (let [actions (->> inference-fns (vals) (mapcat #(% repo)) (merge-actions) (set-inferred))] ;; if we do an inference, and come up with nothing useful, don't ;; add the template, because that would start nodes. Just return [] (if (seq actions) (template/apply-template :build actions) [])))
(ns circle.backend.build.inference "fns for creating a build from a source tree" (:use circle.util.fs) (:require [circle.backend.build.template :as template]) (:require [circle.backend.action :as action]) (:require circle.backend.build.inference.rails circle.backend.build.inference.php)) (def inference-fns {:rails (var circle.backend.build.inference.rails/spec) :php (var circle.backend.build.inference.php/spec)}) (defn set-inferred [actions] (map #(action/set-source % :inferred) actions)) (def action-order [:pre-setup :setup :post-setup :pre-test :test :post-test]) (defn merge-actions [specs] (->> specs (group-by :type) ((apply juxt action-order)) (apply concat))) (defn infer-actions "Dispatches on repo type returned from (infer-repo-type). Returns a seq of build actions." [repo] (let [actions (->> inference-fns (vals) (mapcat #(% repo)) (merge-actions) (set-inferred))] ;; if we do an inference, and come up with nothing useful, don't ;; add the template, because that would start nodes. Just return [] (if (seq actions) (template/apply-template :build actions) [])))
Prepare for next release cycle.
(defproject onyx-app/lein-template "0.11.0.0-alpha2" :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.11.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)
Bump template version to SNAPSHOT
(defproject re-frame/lein-template "0.3.20" :description "Leiningen template for a Reagent web app that implements the re-frame pattern." :url "https://github.com/Day8/re-frame-template" :license {:name "MIT"} :deploy-repositories [["releases" :clojars] ["snapshots" :clojars]] :scm {:name "git" :url "https://github.com/Day8/re-frame-template"} :eval-in-leiningen true)
(defproject re-frame/lein-template "0.3.21-SNAPSHOT" :description "Leiningen template for a Reagent web app that implements the re-frame pattern." :url "https://github.com/Day8/re-frame-template" :license {:name "MIT"} :deploy-repositories [["releases" :clojars] ["snapshots" :clojars]] :scm {:name "git" :url "https://github.com/Day8/re-frame-template"} :eval-in-leiningen true)
Update JavaMail (now Jakarta Mail) to 1.6.5
(defproject com.draines/postal "3.0.0-SNAPSHOT" :description "JavaMail on Clojure" :url "https://github.com/drewr/postal" :license {:name "MIT" :url "http://en.wikipedia.org/wiki/MIT_License" :distribution :repo :comments "Use at your own risk"} :deploy-repositories [["releases" :clojars]] :dependencies [[commons-codec "1.9"] [com.sun.mail/javax.mail "1.6.2"] [javax.mail/javax.mail-api "1.6.2"]] :global-vars {*warn-on-reflection* true} :profiles {:dev {:dependencies []} :1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]} :1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]} :1.9 {:dependencies [[org.clojure/clojure "1.9.0"]]}} :aliases {"test-all" ["with-profile" "dev,1.7:dev,1.8:dev,1.9" "test"]})
(defproject com.draines/postal "3.0.0-SNAPSHOT" :description "JavaMail on Clojure" :url "https://github.com/drewr/postal" :license {:name "MIT" :url "http://en.wikipedia.org/wiki/MIT_License" :distribution :repo :comments "Use at your own risk"} :deploy-repositories [["releases" :clojars]] :dependencies [[commons-codec "1.9"] [com.sun.mail/jakarta.mail "1.6.5"]] :global-vars {*warn-on-reflection* true} :profiles {:dev {:dependencies []} :1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]} :1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]} :1.9 {:dependencies [[org.clojure/clojure "1.9.0"]]}} :aliases {"test-all" ["with-profile" "dev,1.7:dev,1.8:dev,1.9" "test"]})
Update clojure version to 1.7.0 and tools.namespace to 0.2.11.
(defproject cats "0.5.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 [] :deploy-repositories {"releases" :clojars "snapshots" :clojars} :source-paths ["src"] :test-paths ["test"] :cljsbuild {:test-commands {"test" ["node" "output/tests.js"]} :builds [{:id "test" :source-paths ["src" "test"] :notify-command ["node" "output/tests.js"] :compiler {:output-to "output/tests.js" :output-dir "output" :source-map true :static-fns true :cache-analysis false :main cats.runner :optimizations :none :target :nodejs :pretty-print true}}]} :jar-exclusions [#"\.swp|\.swo"] :profiles {:dev {:dependencies [[org.clojure/tools.namespace "0.2.10"] [org.clojure/clojure "1.7.0-RC2"] [org.clojure/clojurescript "0.0-3308"]] :codeina {:sources ["src"] :output-dir "doc/codeina"} :plugins [[funcool/codeina "0.1.0-SNAPSHOT" :exclusions [org.clojure/clojure]] [lein-cljsbuild "1.0.6"]]}})
(defproject cats "0.5.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 [] :deploy-repositories {"releases" :clojars "snapshots" :clojars} :source-paths ["src"] :test-paths ["test"] :cljsbuild {:test-commands {"test" ["node" "output/tests.js"]} :builds [{:id "test" :source-paths ["src" "test"] :notify-command ["node" "output/tests.js"] :compiler {:output-to "output/tests.js" :output-dir "output" :source-map true :static-fns true :cache-analysis false :main cats.runner :optimizations :none :target :nodejs :pretty-print true}}]} :jar-exclusions [#"\.swp|\.swo"] :profiles {:dev {:dependencies [[org.clojure/tools.namespace "0.2.11"] [org.clojure/clojure "1.7.0"] [org.clojure/clojurescript "0.0-3297"]] :codeina {:sources ["src"] :output-dir "doc/codeina"} :plugins [[funcool/codeina "0.1.0-SNAPSHOT" :exclusions [org.clojure/clojure]] [lein-cljsbuild "1.0.6"]]}})
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 "0.4.0" :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 "0.4.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"]])
Prepare for next release cycle.
(defproject onyx-app/lein-template "0.8.8.2" :description "Onyx Leiningen application template" :url "https://github.com/onyx-platform/onyx-template" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :plugins [[lein-set-version "0.4.1"]] :profiles {:dev {:plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}} :eval-in-leiningen true)
(defproject onyx-app/lein-template "0.8.8.3-SNAPSHOT" :description "Onyx Leiningen application template" :url "https://github.com/onyx-platform/onyx-template" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :repositories {"snapshots" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false} "releases" {:url "https://clojars.org/repo" :username :env :password :env :sign-releases false}} :plugins [[lein-set-version "0.4.1"]] :profiles {:dev {:plugins [[lein-set-version "0.4.1"] [lein-update-dependency "0.1.2"] [lein-pprint "1.1.1"]]}} :eval-in-leiningen true)
Make node links clickable, redirect to the right view for now
(ns web.components.node-link (:require [om.next :as om :refer-macros [defui]] [om.dom :as dom])) (defui Badge Object (render [this] (let [{:keys [kind]} (om/props this)] (dom/span #js {:className "badge"} (case kind "requirement" "r" "component" "c" "work-item" "w" "tag" "t" "?"))))) (def badge (om/factory Badge)) (defui NodeLink static om/Ident (ident [this props] [:node (:name props)]) static om/IQuery (query [this] [:name :title :kind]) Object (render [this] (let [{:keys [name title kind]} (om/props this)] (dom/div #js {:className "node-link"} (badge {:kind kind}) (dom/span #js {:className "node-link-title"} title) (dom/span #js {:className "node-link-name"} name))))) (def node-link (om/factory NodeLink {:key-fn :name}))
(ns web.components.node-link (:require [om.next :as om :refer-macros [defui]] [om.dom :as dom] [web.routing :as routing])) (defui Badge Object (render [this] (let [{:keys [kind]} (om/props this)] (dom/span #js {:className "badge"} (case kind "requirement" "r" "component" "c" "work-item" "w" "tag" "t" "?"))))) (def badge (om/factory Badge)) (def kind->view {"requirement" :requirements "component" :components "work-item" :work-items "tag" :tags}) (defn node->route [{:keys [kind name]}] {:handler (kind->view kind) :route-params {:state '?state :node name}}) (defui NodeLink static om/Ident (ident [this props] [:node (:name props)]) static om/IQuery (query [this] [:name :title :kind]) Object (render [this] (let [{:keys [name title kind]} (om/props this) route (node->route (om/props this))] (dom/a #js {:onClick #(routing/activate-route! route) :className "node-link"} (badge {:kind kind}) (dom/span #js {:className "node-link-title"} title) (dom/span #js {:className "node-link-name"} name))))) (def node-link (om/factory NodeLink {:key-fn :name}))
Use the clojars version of boot-junit
(set-env! :source-paths #{"src/main/java" "src/test/java"} :dependencies '[[radicalzephyr/boot-junit "0.1.0" :scope "test"]]) (def +version+ "0.1.0") (require '[radicalzephyr.boot-junit :refer [junit]]) (task-options! pom {:project 'http-server :version +version+ :description "A Java HTTP server." :url "https://github.com/RadicalZephyr/http-server" :scm {:url "https://github.com/RadicalZephyr/http-server.git"} :licens {"MIT" "http://opensource.org/licenses/MIT"}} junit {:packages '#{net.zephyrizing.http_server}}) (deftask test "Compile and run my jUnit tests." [] (comp (javac) (junit))) (deftask build "Build my http server." [] (comp (javac) (pom) (jar)))
(set-env! :source-paths #{"src/main/java" "src/test/java"} :dependencies '[[radicalzephyr/boot-junit "0.1.0-SNAPSHOT" :scope "test"]]) (def +version+ "0.1.0") (require '[radicalzephyr.boot-junit :refer [junit]]) (task-options! pom {:project 'http-server :version +version+ :description "A Java HTTP server." :url "https://github.com/RadicalZephyr/http-server" :scm {:url "https://github.com/RadicalZephyr/http-server.git"} :licens {"MIT" "http://opensource.org/licenses/MIT"}} junit {:packages '#{net.zephyrizing.http_server}}) (deftask test "Compile and run my jUnit tests." [] (comp (javac) (junit))) (deftask build "Build my http server." [] (comp (javac) (pom) (jar)))
Add a page to display the range method.
(ns my-noir-lab.views.welcome (:require [my-noir-lab.views.common :as common] [noir.content.getting-started]) (:use [noir.core :only [defpage]] [hiccup.core :only [html]])) (defpage "/welcome" [] (common/layout [:p "Welcome to my-noir-lab"])) (defpage "/my-page" [] (common/site-layout [:h1 "Welcome to my site!"] [:p#wrapper "Hope you like it!"]))
(ns my-noir-lab.views.welcome (:require [my-noir-lab.views.common :as common] [noir.content.getting-started]) (:use [noir.core :only [defpage]] [hiccup.core :only [html]])) (defpage "/welcome" [] (common/layout [:p "Welcome to my-noir-lab"])) (defpage "/my-page" [] (common/site-layout [:h1 "Welcome to my site!"] [:p#wrapper "Hope you like it!"])) (defpage "/range" [] (common/site-layout [:h1 "range 1 100"] [:p#wrapper (map #(str "<i>" % "</i>&nbsp;") (range 1 100))]))
Sort speakers by creation date
(ns auricle.subs (:require [re-frame.core :refer [reg-sub]])) (reg-sub :current-speaker (fn [db _] (:current-speaker db))) (reg-sub :db (fn [db _] db)) (reg-sub :loading (fn [db _] (:loading db))) (defn format-speaker [speaker] (-> speaker (update :love count) (update :smile count) (update :neutral count) (update :sleep count))) (defn format-speakers [speakers] (map format-speaker speakers)) (reg-sub :speakers (fn [db _] (-> db :speakers vals (or {}) (format-speakers))))
(ns auricle.subs (:require [re-frame.core :refer [reg-sub]])) (reg-sub :current-speaker (fn [db _] (:current-speaker db))) (reg-sub :db (fn [db _] db)) (reg-sub :loading (fn [db _] (:loading db))) (defn format-speaker [speaker] (-> speaker (update :love count) (update :smile count) (update :neutral count) (update :sleep count))) (defn format-speakers [speakers] (->> speakers (map format-speaker) (sort-by :created >))) (reg-sub :speakers (fn [db _] (-> db :speakers vals (or {}) (format-speakers))))
Use s/conditional instead of s/either
(ns icecap.schema (:require [schema.core :as s]) (:import [java.net URI])) (def supported-schemes "The currently supported schemes." #{"http" "https"}) (defn get-scheme "Gets the scheme of a (String) URL." [url] (.getScheme (URI. url))) (def supported-scheme? "Does the given URL have a supported scheme?" (comp supported-schemes get-scheme)) (def SimpleRequest "A simple request." {:target (s/both s/Str (s/pred supported-scheme? "supported-scheme?"))}) (def RequestSpec (s/either SimpleRequest [(s/recursive #'RequestSpec)] #{(s/recursive #'RequestSpec)}))
(ns icecap.schema (:require [schema.core :as s]) (:import [java.net URI])) (def supported-schemes "The currently supported schemes." #{"http" "https"}) (defn get-scheme "Gets the scheme of a (String) URL." [url] (.getScheme (URI. url))) (def supported-scheme? "Does the given URL have a supported scheme?" (comp supported-schemes get-scheme)) (def SimpleRequest "A simple request." {:target (s/both s/Str (s/pred supported-scheme? "supported-scheme?"))}) (def RequestSpec "A request specification. Please note that this uses prismatic/schema's `conditional` with type dispatch, rather than the (perhaps more obvious) `either`. The problem with `either` is that it didn't know which of the schemas *probably* should have validated: if you give it a bogus `SimpleRequest`, it can only tell you that it: - wasn't a valid `SimpleRequest` - wasn't an unordered collection of valid `SimpleRequests` - wasn't an ordered collection of valid `SimpleRequests` ... but it fails to tell you that it *was* something that looked like a SimpleRequest but didn't validate because, for example, its target was `ftp`, which is an unsupported URL scheme. That would've been far more useful. Using `conditional` allows us to return this (useful) error message. " (s/conditional map? SimpleRequest vector? [(s/recursive #'RequestSpec)] set? #{(s/recursive #'RequestSpec)}))
Support for handler in constructor
;; Copyright © 2014 JUXT LTD. (ns modular.aleph (:require [com.stuartsierra.component :refer (Lifecycle)] [schema.core :as s] [modular.ring :refer (request-handler WebRequestHandler)] [aleph.http :as http])) (defrecord Webserver [] Lifecycle (start [component] (if-let [provider (first (filter #(satisfies? WebRequestHandler %) (vals component)))] (let [h (request-handler provider)] (assert h) (let [server (http/start-server h component)] (assoc component :server server))) (throw (ex-info (format "aleph http server requires the existence of a component that satisfies %s" WebRequestHandler) {:component component}))) ) (stop [component] (when-let [server (:server component)] (.close server) (dissoc component :server)))) (def new-webserver-schema {:port s/Int s/Keyword s/Any}) (defn new-webserver [& {:as opts}] (->> opts (merge {:port 0}) (s/validate new-webserver-schema) map->Webserver))
;; Copyright © 2014 JUXT LTD. (ns modular.aleph (:require [com.stuartsierra.component :refer (Lifecycle)] [schema.core :as s] [modular.ring :refer (request-handler WebRequestHandler)] [aleph.http :as http] )) (defn get-handler "Extract the Ring handler from the component" [component] (or ;; Handlers can be specified as a constructor arg (:handler component) ;; Or as a dependency (which satisfies WebRequestHandler) (when-let [provider (first (filter #(satisfies? WebRequestHandler %) (vals component)))] (request-handler provider)) ;; Or an exception is thrown (throw (ex-info (format "aleph http server requires a handler, or a dependency that satisfies %s" WebRequestHandler))))) (defrecord Webserver [handler] Lifecycle (start [component] (let [server (http/start-server (get-handler component) component)] (assoc component :server server))) (stop [component] (when-let [server (:server component)] (.close server) (dissoc component :server)))) (def new-webserver-schema {:port s/Int s/Keyword s/Any}) (defn new-webserver [& {:as opts}] (->> opts (merge {:port 0}) (s/validate new-webserver-schema) map->Webserver))
Replace missing translations with keys
(ns salava.core.i18n #?(:cljs (:require-macros [taoensso.tower :as tower-macros])) (:require #?@(:cljs [[reagent.session :as session] [taoensso.tower :as tower :refer-macros (with-tscope)]]) #?(:clj [taoensso.tower :as tower :refer (with-tscope)]))) (def tconfig #?(:clj {:fallback-locale :en :dev-mode? true :dictionary "i18n/dict.clj"} :cljs {:fallback-locale :en :compiled-dictionary (tower-macros/dict-compile* "i18n/dict.clj")})) (def translation (tower/make-t tconfig)) ; create translation fn (defn t [key] (let [lang #?(:clj "en" :cljs (session/get :lang))] (translation lang key)))
(ns salava.core.i18n #?(:cljs (:require-macros [taoensso.tower :as tower-macros])) (:require #?@(:cljs [[reagent.session :as session] [taoensso.tower :as tower :refer-macros (with-tscope)]]) #?(:clj [taoensso.tower :as tower :refer (with-tscope)]))) (def tconfig #?(:clj {:fallback-locale :en :dev-mode? true :dictionary "i18n/dict.clj"} :cljs {:fallback-locale :en :compiled-dictionary (tower-macros/dict-compile* "i18n/dict.clj")})) (def translation (tower/make-t tconfig)) ; create translation fn (defn t [key] (let [lang #?(:clj "en" :cljs (session/get :lang)) out-str (translation lang key)] (if-not (= out-str "") out-str (str "[" key "]"))))
Fix unexpected exception on default service handler.
;; This Source Code Form is subject to the terms of the Mozilla Public ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; ;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz> (ns uxbox.services.core (:require [clojure.walk :as walk] [cuerdas.core :as str] [uxbox.util.exceptions :as ex])) (defmulti novelty :type) (defmulti query :type) (defmethod novelty :default [{:keys [type] :as data}] (ex/raise :code ::not-implemented :message-category :novelty :message-type type)) (defmethod query :default [data] (ex/raise :code ::not-implemented :message-category :query :message-type type))
;; This Source Code Form is subject to the terms of the Mozilla Public ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; ;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz> (ns uxbox.services.core (:require [clojure.walk :as walk] [cuerdas.core :as str] [uxbox.util.exceptions :as ex])) (defmulti novelty :type) (defmulti query :type) (defmethod novelty :default [{:keys [type] :as data}] (ex/raise :code ::not-implemented :message-category :novelty :message-type type)) (defmethod query :default [{:keys [type] :as data}] (ex/raise :code ::not-implemented :message-category :query :message-type type))
Mark mock tweets as favorites
(ns tutorial.moan.lib (:require [tutorial.moan.db :as db])) (defn favorites [] [{:id 1 :text "This is a fantastic tweet" :author {:name "Elon Musk" :username "fakeelonmusk"}} {:id 2 :text "Lord but I dislike poetry. How can anyone remember words that aren't put to music?" :author {:name "Arliden" :username "arl_the_bard"}}])
(ns tutorial.moan.lib (:require [tutorial.moan.db :as db])) (defn favorites [] [{:id 1 :text "This is a fantastic tweet" :author {:name "Elon Musk" :username "fakeelonmusk"} :favorite? true} {:id 2 :text "Lord but I dislike poetry. How can anyone remember words that aren't put to music?" :author {:name "Arliden" :username "arl_the_bard"} :favorite? true}])