(ns detritus.variants
  (:require [detritus.update :refer [take-when]]))

(defmacro defvariant
  {:doc "Defines a variant constructor with a namespace qualified tag, and keyword named members."
   :arglists '([name doc-string? attr-map? members])}
  [vname & args]
  (let [;; Parse direct args
        [?docstring args] (take-when string? "" args)
        [?attr-map args]  (take-when map? {} args)
        members           (first args)

        ;; FIXME inline guards are a bad habit of mine
        _                 (assert (vector? members) "Members is not a vector!")
        _                 (assert (every? symbol? members) "Members may contain only symbols!")

        ;; Build used datastructures
        kw-members        (map (comp keyword name) members)
        kw-tag            (keyword (name (ns-name *ns*))
                                   (name vname))
        ?attr-map         (assoc ?attr-map
                                 :variant true
                                 :variant/members kw-members
                                 :variant/tag kw-tag)]
    `(defn ~vname ~?docstring ~?attr-map ~members
       [~kw-tag (hash-map ~@(interleave kw-members members))])))

(ns detritus.variants
  (:require [detritus.update :refer [take-when]]))

(defmacro defvariant
  "Defines a variant constructor with a namespace qualified tag, and keyword
  named members. Preconditions on members may be specified by the pre-map.

  Ex. (defvariant test \"A demo variant\" [a b]
        {:pre [(number? a) (vector? b)]})"
  {:arglists '([name doc-string? attr-map? members pre-map?])}
  [vname & args]
  (let [;; Parse direct args
        [?docstring args]    (take-when string? "" args)
        [?attr-map args]     (take-when map? {} args)
        [members args]       (take-when vector? nil args)
        [?pre-map args] (take-when map? {} args)

        ;; FIXME inline guards are a bad habit of mine
        _                    (assert (vector? members) "Members is not a vector!")
        _                    (assert (every? symbol? members) "Members may contain only symbols!")

        ;; Build used datastructures
        kw-members           (map (comp keyword name) members)
        kw-tag               (keyword (name (ns-name *ns*))
                                      (name vname))
        ?attr-map            (assoc ?attr-map
                                    :variant true
                                    :variant/members kw-members
                                    :variant/tag kw-tag)]
  `(defn ~vname ~?docstring ~?attr-map ~members
     ~?pre-map
     [~kw-tag (hash-map ~@(interleave kw-members members))])))

Add support for preconditions, example

Add support for preconditions, example


;; 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.repo.users
  "A main interface for access to remote resources."
  (:refer-clojure :exclude [do])
  (:require [beicon.core :as rx]
            [uxbox.repo.core :refer (request url send!)]
            [uxbox.state :as ust]))

(defmethod request :fetch/profile
  [type _]
  (let [url (str url "/profile/me")]
    (send! {:method :get :url url})))

(defmethod request :update/profile
  [type data]
  (let [params {:url (str url "/profile/me")
                :method :put
                :body data}]
    (send! params)))

(defmethod request :update/password
  [type data]
  (let [params {:url (str url "/profile/me/password")
                :method :put
                :body data}]
    (send! params)))

;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>

(ns uxbox.repo.users
  "A main interface for access to remote resources."
  (:require [beicon.core :as rx]
            [uxbox.repo.core :refer (request url send!)]
            [uxbox.util.transit :as t]))

(defn- decode-payload
  [{:keys [payload] :as rsp}]
  (let [metadata (:metadata payload)]
    (assoc rsp :payload
           (assoc payload :metadata (t/decode metadata)))))

(defmethod request :fetch/profile
  [type _]
  (let [url (str url "/profile/me")
        params {:method :get :url url}]
    (->> (send! params)
         (rx/map decode-payload))))

(defmethod request :update/profile
  [type {:keys [metadata id] :as body}]
  (let [body (assoc body :metadata (t/encode metadata))
        params {:url (str url "/profile/me")
                :method :put
                :body body}]
    (->> (send! params)
         (rx/map decode-payload))))

(defmethod request :update/password
  [type data]
  (let [params {:url (str url "/profile/me/password")
                :method :put
                :body data}]
    (send! params)))

Add support for new profile persistence.


(ns metrics.gauges
  (:use [metrics.utils :only (metric-name)])
  (:import (com.yammer.metrics Metrics))
  (:import (com.yammer.metrics.core Gauge)))

; Create ----------------------------------------------------------------------
(defmacro gauge
  "Create a new Gauge metric with the given title.

  The body exprs will be used to retrieve the value of the Gauge when requested."
  [title & body]
  `(Metrics/newGauge (metric-name ~title)
                     (proxy [Gauge] []
                       (value [] (do ~@body)))))

(defn gauge-fn
  "Create a new Gauge metric with the given title.

  The given function will be called (with no arguments) to retrieve the value of
  the Gauge when requested."
  [title f]
  (Metrics/newGauge (metric-name title)
                    (proxy [Gauge] []
                      (value [] (f)))))

(defmacro defgauge
  "Define a new Gauge metric with the given title.

  The rest of the arguments may be a body form or function to call to
  retrieve the value of the Gauge."
  [title & body]
  (cond (and (= 1 (count body)) (and (symbol? (first body))
                                     (fn? (eval (first body)))))
        `(gauge-fn ~(str title) ~(first body))
        true
        `(gauge ~(str title) ~@body)))

; Read ------------------------------------------------------------------------
(defn value
  "Return the value of the given Gauge."
  [^Gauge g]
  (.value g))

(ns metrics.gauges
  (:use [metrics.utils :only (metric-name)])
  (:import (com.yammer.metrics Metrics))
  (:import (com.yammer.metrics.core Gauge)))

; Create ----------------------------------------------------------------------
(defmacro gauge
  "Create a new Gauge metric with the given title.

  The body exprs will be used to retrieve the value of the Gauge when requested."
  [title & body]
  `(Metrics/newGauge (metric-name ~title)
                     (proxy [Gauge] []
                       (value [] (do ~@body)))))

(defn gauge-fn
  "Create a new Gauge metric with the given title.

  The given function will be called (with no arguments) to retrieve the value of
  the Gauge when requested."
  [title f]
  (Metrics/newGauge (metric-name title)
                    (proxy [Gauge] []
                      (value [] (f)))))

(defmacro defgauge
  "Define a new Gauge metric with the given title.

  The rest of the arguments may be a body form or function to call to
  retrieve the value of the Gauge."
  [title & [b & bs :as body]]
  (if (and (empty? bs)
           (symbol? b)
           (fn? (eval b)))
    `(def ~title (gauge-fn ~(str title) ~b))
    `(def ~title (gauge ~(str title) ~@body))))

; Read ------------------------------------------------------------------------
(defn value
  "Return the value of the given Gauge."
  [^Gauge g]
  (.value g))

Clean up the defgauge macro a bit.

Clean up the defgauge macro a bit.


(ns {{namespace}}
  (:require [play-clj.core :refer :all])
  (:import [com.badlogic.gdx.graphics Color]
           [com.badlogic.gdx.graphics.g2d BitmapFont]
           [com.badlogic.gdx.scenes.scene2d.ui Label Label$LabelStyle]))

(defn on-show
  [screen]
  (create-renderer! screen :type :stage)
  (let [style (Label$LabelStyle. (BitmapFont.) (Color. 1 1 1 1))
        label (Label. "Hello world!" style)]
    (set-entities! screen [label])))

(defn on-render
  [screen]
  (clear!)
  (draw! screen (get-entities screen)))

(defscreen main-screen
  :on-show on-show
  :on-render on-render)

(defgame {{app-name}}
  :on-create (fn [this]
               (set-screen! this main-screen)))

(ns {{namespace}}
  (:require [play-clj.core :refer :all])
  (:import [com.badlogic.gdx.graphics Color]
           [com.badlogic.gdx.graphics.g2d BitmapFont]
           [com.badlogic.gdx.scenes.scene2d.ui Label Label$LabelStyle]))

(defscreen main-screen
  :on-show
  (fn [screen entities]
    (create-renderer! screen :type :stage)
    (let [style (Label$LabelStyle. (BitmapFont.) (Color. 1 1 1 1))
          label (Label. "Hello world!" style)]
      [label]))
  :on-render
  (fn [screen entities]
    (clear!)
    (draw! screen entities)
    entities))

(defgame {{app-name}}
  :on-create
  (fn [this]
    (set-screen! this main-screen)))

Update clojure game template to use new entity system


(ns circle.util.fs
  "utilities for working with files and directories"
  (:require fs)
  (:require [clojure.java.io :as io])
  (:import org.apache.commons.io.FileUtils)
  (:import (org.apache.commons.io.filefilter
            IOFileFilter
            TrueFileFilter))
  (:require [circle.sh :as sh]))

(def symlink-filter (reify IOFileFilter
                      (accept [this file]
                        (not (FileUtils/isSymlink file)))))

(defn all-files
  "Returns a list of all files in the repos"
  [dir]
  (when (fs/exists? dir)
    (FileUtils/listFiles (io/as-file dir)
                         symlink-filter
                         symlink-filter)))

(defn files-matching
  "Returns a list of files that match re."
  [dir re]
  (->> dir
       (all-files)
       (filter #(re-find re %))))

(defn re-file?
  "True if the contents of the file match the regex"
  [file re]
  (when (fs/exists? file)
    (boolean (seq (re-find re (slurp file))))))

(defn line-count
  "returns the number of lines in the file"
  [file]
  (if (fs/exists? file)
    (->> file (slurp) (re-seq #"\n") (count))
    0))

(ns circle.util.fs
  "utilities for working with files and directories"
  (:require fs)
  (:require [clojure.java.io :as io])
  (:import org.apache.commons.io.FileUtils)
  (:import (org.apache.commons.io.filefilter
            IOFileFilter
            TrueFileFilter))
  (:require [circle.sh :as sh]))

(def symlink-filter (reify IOFileFilter
                      (accept [this file]
                        (not (FileUtils/isSymlink file)))))

(defn all-files
  "Returns a list of all files in the repos"
  [dir]
  (when (fs/exists? dir)
    (map str (FileUtils/listFiles (io/as-file dir)
                                  symlink-filter
                                  symlink-filter))))

(defn files-matching
  "Returns a list of files that match re."
  [dir re]
  (->> dir
       (all-files)
       (filter #(re-find re %))))

(defn re-file?
  "True if the contents of the file match the regex"
  [file re]
  (when (fs/exists? file)
    (boolean (seq (re-find re (slurp file))))))

(defn line-count
  "returns the number of lines in the file"
  [file]
  (if (fs/exists? file)
    (->> file (slurp) (re-seq #"\n") (count))
    0))

Convert files to strs, makes it easier to regex later


(ns org.scode.httpgctest
  (:gen-class)
  (:require [clojure.contrib.duck-streams :as duck-streams])
  (:use [compojure]
	        [compojure.http response])
  (:import (java.io ByteArrayOutputStream
                    ByteArrayInputStream
                    FileInputStream
                    File)))

(defn gen-recursive-garbage [lvl garbage]
  (if (> 0 lvl)
    (gen-recursive-garbage (dec lvl) {:some-nice-garbage [1 2 3 4 5 6 7 8 9 10]})
    (do
      (Thread/sleep (rand 1000))
      garbage)))

(defn serve-gengarbage [request]
  (do
    (doseq [future (doall (for [i (range 10)] (future (gen-recursive-garbage 50 []))))]
      @future)
    {:status 200
     :headers {}
     :body "Garbage all around."}))

(def data (ref ["data"]))

(defn serve-gendata [request]
  (dosync
   (alter data #(concat %1 (repeat (count %1) "data"))))
  {:status 200
   :headers {}
   :body (str "size is now " (count @data))})

(defroutes greeter
  (GET "/gengarbage"
       serve-gengarbage)
  (GET "/gendata"
       serve-gendata))

(defn -main [& args]
  (run-server {:port 9191}
              "/*" (servlet greeter)))

(ns org.scode.httpgctest
  (:gen-class)
  (:require [clojure.contrib.duck-streams :as duck-streams])
  (:use [compojure]
	        [compojure.http response])
  (:import (java.io ByteArrayOutputStream
                    ByteArrayInputStream
                    FileInputStream
                    File)))

(defn gen-recursive-garbage [lvl garbage]
  (if (> 0 lvl)
    (gen-recursive-garbage (dec lvl) {:some-nice-garbage [1 2 3 4 5 6 7 8 9 10]})
    (do
      (Thread/sleep (rand 1000))
      garbage)))

(defn serve-gengarbage [request]
  (do
    (doseq [future (doall (for [i (range 10)] (future (gen-recursive-garbage 50 []))))]
      @future)
    {:status 200
     :headers {}
     :body "Garbage all around."}))

(def data (ref ["data"]))

(defn serve-gendata [request]
  (let [amount (let [amstr (:amount (:query-params request))]
                 (if amstr
                   (Integer/parseInt amstr)
                   (count @data)))]
    (dosync
     (alter data #(concat %1 (repeat amount "data"))))
  {:status 200
   :headers {}
   :body (str "size is now " (count @data))}))

(defroutes greeter
  (GET "/gengarbage"
       serve-gengarbage)
  (GET "/gendata"
       serve-gendata))

(defn -main [& args]
  (run-server {:port 9191}
              "/*" (servlet greeter)))

Support optional 'amount' query param to gendata, overriding default behavior of doubling.


(ns leiningen.grim
  (:require [leiningen.core.eval :refer [eval-in-project]]))

(def deps
  ['[org.clojure/tools.namespace "0.2.7"]
   '[org.clojure/java.classpath "0.2.2"]
   '[org.clojure-grimoire/lib-grimoire "0.1.1"]
   '[org.clojure-grimoire/lein-grim "0.1.1"] ;; FIXME: do this better?
   '[me.arrdem/detritus "0.2.0"]])

(defn grim
  [project & args]
  (let [args (concat ((juxt :group :name :version) project) args)]
    (eval-in-project
     (update-in project [:dependencies] concat deps)
     `(do (require 'grimoire.doc)
          (grimoire.doc/-main ~@args)))))

(ns leiningen.grim
  (:require [leiningen.core.eval :refer [eval-in-project]]))

(def deps
  ['[org.clojure/tools.namespace "0.2.7"]
   '[org.clojure/java.classpath "0.2.2"]
   '[org.clojure-grimoire/lib-grimoire "0.1.1"]
   '[org.clojure-grimoire/lein-grim "0.1.1"] ;; FIXME: do this better?
   '[me.arrdem/detritus "0.2.0"]])

(defn grim
  "Usage: lein grim src <dst>
      : lein grim artifact <groupid> <artifactid> <version> <dst>

In source mode, lein-grim traverses the source paths of the current project,
enumerating and documenting all namespaces. This is intended for documenting
projects for which you have both source and a lein project.

In artifact mode, lein-grim traverses an artifact on the classpath enumerating
and documenting the namespaces therein. This is intended for documenting
projects such as clojure.core which may not exist as a covenient lein project
but which do exist as artifacts."
  [project mode & args]
  {:pre [(#{"src" "artifact"} mode)]}
  (let [args (if (= "src" mode)
               (concat ((juxt :group :name :version) project) args)
               args)
        paths (if (= "src" mode)
                (vec (:source-paths project))
                :classpath)]
    (eval-in-project
     (update-in project [:dependencies] concat deps)
     `(do (require 'grimoire.doc)
          (grimoire.doc/-main ~@args ~paths)))))

Implement "src" and "artifact" modes in loader


(defproject org.onyxplatform/onyx-kafka "0.7.3-SNAPSHOT"
  :description "Onyx plugin for Kafka"
  :url "https://github.com/MichaelDrogalis/onyx-kafka"
  :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-20150827_202930-g49ef67c"]
                 [clj-kafka "0.3.2" :exclusions [org.apache.zookeeper/zookeeper zookeeper-clj]]
                 [com.stuartsierra/component "0.2.3"]
                 [cheshire "5.5.0"]
                 [zookeeper-clj "0.9.3" :exclusions [io.netty/netty org.apache.zookeeper/zookeeper]]]
  :profiles {:dev {:dependencies [[midje "1.7.0"]]
                   :plugins [[lein-midje "3.1.3"]]}
             :circle-ci {:jvm-opts ["-Xmx4g"]}})

(defproject org.onyxplatform/onyx-kafka "0.7.3-SNAPSHOT"
  :description "Onyx plugin for Kafka"
  :url "https://github.com/MichaelDrogalis/onyx-kafka"
  :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-20150828_152050-gd122e3e"]
                 [clj-kafka "0.3.2" :exclusions [org.apache.zookeeper/zookeeper zookeeper-clj]]
                 [com.stuartsierra/component "0.2.3"]
                 [cheshire "5.5.0"]
                 [zookeeper-clj "0.9.3" :exclusions [io.netty/netty org.apache.zookeeper/zookeeper]]]
  :profiles {:dev {:dependencies [[midje "1.7.0"]]
                   :plugins [[lein-midje "3.1.3"]]}
             :circle-ci {:jvm-opts ["-Xmx4g"]}})

Update dependency org.onyxplatform/onyx to version 0.7.3-20150828_152050-gd122e3e.

Automatic commit by lein-traffic-control.


(defproject io.replikativ/konserve "0.3.0-beta1"
  :description "Durable cross-platform key-value store protocol with core.async."
  :url "http://github.com/replikativ/konserve"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :source-paths ["src"]
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.clojure/clojurescript "1.7.48"]
                 [org.clojure/core.async "0.1.346.0-17112a-alpha"]
                 [io.replikativ/incognito "0.1.1"]]

  :plugins [[lein-cljsbuild "1.0.6"]]

  :profiles {:dev {:plugins [[com.cemerick/austin "0.1.6"]]}}

  :cljsbuild
  {:builds
   [{:source-paths ["src"]
     :compiler
     {:output-to "resources/public/js/main.js"
      :optimizations :simple
      :pretty-print true}}]})

(defproject io.replikativ/konserve "0.3.0-beta2"
  :description "Durable cross-platform key-value store protocol with core.async."
  :url "http://github.com/replikativ/konserve"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :source-paths ["src"]
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.clojure/clojurescript "1.7.48"]
                 [org.clojure/core.async "0.1.346.0-17112a-alpha"]
                 [io.replikativ/incognito "0.1.2"]]

  :plugins [[lein-cljsbuild "1.0.6"]]

  :profiles {:dev {:plugins [[com.cemerick/austin "0.1.6"]]}}

  :cljsbuild
  {:builds
   [{:source-paths ["src"]
     :compiler
     {:output-to "resources/public/js/main.js"
      :optimizations :simple
      :pretty-print true}}]})

Use safe incognito set reader.

Use safe incognito set reader.


(defproject funcool/promesa "1.2.0"
  :description "A promise library for ClojureScript"
  :url "https://github.com/funcool/promesa"
  :license {:name "BSD (2 Clause)"
            :url "http://opensource.org/licenses/BSD-2-Clause"}
  :dependencies [[org.clojure/clojure "1.8.0" :scope "provided"]
                 [org.clojure/clojurescript "1.8.51" :scope "provided"]
                 [funcool/cats "1.2.1" :scope "provided"]]
  :deploy-repositories {"releases" :clojars
                        "snapshots" :clojars}
  :source-paths ["src" "assets"]
  :test-paths ["test"]
  :jar-exclusions [#"\.swp|\.swo|user.clj"]
  :codeina {:sources ["src"]
            :reader :clojure
            :target "doc/dist/latest/api"}
  :plugins [[funcool/codeina "0.3.0"]
            [lein-ancient "0.6.7" :exclusions [org.clojure/tools.reader]]])

(defproject funcool/promesa "1.2.0"
  :description "A promise library for ClojureScript"
  :url "https://github.com/funcool/promesa"
  :license {:name "BSD (2 Clause)"
            :url "http://opensource.org/licenses/BSD-2-Clause"}
  :dependencies [[org.clojure/clojure "1.8.0" :scope "provided"]
                 [org.clojure/clojurescript "1.9.36" :scope "provided"]]
  :deploy-repositories {"releases" :clojars
                        "snapshots" :clojars}
  :source-paths ["src" "assets"]
  :test-paths ["test"]
  :jar-exclusions [#"\.swp|\.swo|user.clj"]
  :codeina {:sources ["src"]
            :reader :clojure
            :target "doc/dist/latest/api"}
  :plugins [[funcool/codeina "0.3.0"]
            [lein-ancient "0.6.7" :exclusions [org.clojure/tools.reader]]])

Update cljs compiler to 1.9.36

Update cljs compiler to 1.9.36


(ns clj-spotify.test-utils
  (:require
            [clojure.data.json :as json]
            [clojure.data :as data]
            [clj-http.client :as client]
            [clojure.data.codec.base64 :as b64]
            ))

(def enc-auth-string
  (str "Basic "
  (->
    (str (System/getenv "SPOTIFY_CLIENT_ID") ":" (System/getenv "SPOTIFY_SECRET_TOKEN"))
    (.getBytes)
    (b64/encode)
    (String. "UTF-8"))))

(defonce spotify-oauth-token (->
                           "https://accounts.spotify.com/api/token"
                           (client/post {:form-params {:grant_type "client_credentials"} :headers {:Authorization enc-auth-string}})
                           :body
                           (json/read-str :key-fn keyword)
                           :access_token))

(defn reset-volatile-vals
  "Function to reset values that change over time such as amount of followers or popularity ranking."
  [k v]
  (condp
    :followers {:href nil, :total 0}
    :popularity 0
    :total 0
    :snapshot_id "123456"
    (and (string? v) (.contains v "scdn.co")) "https://scdn.co/preview/ref"
    :else v))

 (defn test-json-string-to-map [s]
  "Read string and transform to json but ignore certain keys."
  (json/read-str s :value-fn reset-volatile-vals :key-fn keyword))

(ns clj-spotify.test-utils
  (:require
            [clojure.data.json :as json]
            [clj-http.client :as client]
            ))

(defonce spotify-oauth-token
  (-> "https://accounts.spotify.com/api/token"
      (client/post {:form-params {:grant_type "client_credentials"}
                    :basic-auth [(System/getenv "SPOTIFY_CLIENT_ID")
                                 (System/getenv "SPOTIFY_SECRET_TOKEN")]
                    :as :json})
      :body
      :access_token))

(defn reset-volatile-vals
  "Function to reset values that change over time such as amount of followers or popularity ranking."
  [k v]
  (condp
    :followers {:href nil, :total 0}
    :popularity 0
    :total 0
    :snapshot_id "123456"
    (and (string? v) (.contains v "scdn.co")) "https://scdn.co/preview/ref"
    :else v))

 (defn test-json-string-to-map [s]
  "Read string and transform to json but ignore certain keys."
  (json/read-str s :value-fn reset-volatile-vals :key-fn keyword))

Simplify Basic auth and json parsing in test-utils/spotify-oauth-token


(ns comic-reader.comic-repository)

(defprotocol ComicRepository
  (list-sites         [this] "List all the comic sites available from this repository.")
  (list-comics        [this site] "List all the comics available on this site.")
  (previous-locations [this site comic-id location n] "Get up-to n locations that precede `location' in a comic.")
  (next-locations     [this site comic-id location n] "Get up-to n locations that follow `location' in a comic.")
  (image-tag          [this site location] "Get the hiccup image tag for this comic location."))

(defprotocol WritableComicRepository
  (store-sites [this sites] "Store a seq of site records.")
  (store-comics [this site-id comics] "Store a seq of comic records.")
  (store-locations [this site-id comic-id locations] "Store a seq of location records."))

(ns comic-reader.comic-repository)

(defprotocol ComicRepository
  (list-sites         [this] "List all the comic sites available from this repository.")
  (list-comics        [this site-id] "List all the comics available on this site.")
  (previous-locations [this site-id comic-id location n] "Get up-to n locations that precede `location' in a comic.")
  (next-locations     [this site-id comic-id location n] "Get up-to n locations that follow `location' in a comic.")
  (image-tag          [this site-id location] "Get the hiccup image tag for this comic location."))

(defprotocol WritableComicRepository
  (store-sites [this sites] "Store a seq of site records.")
  (store-comics [this site-id comics] "Store a seq of comic records.")
  (store-locations [this site-id comic-id locations] "Store a seq of location records."))

Use site-id in ComicRepository protocol method arguments


(ns user
  (:use
    speclj.config
    io.aviso.tracker
    io.aviso.repl
    clojure.pprint
    [io.aviso.twixt :only [get-asset-uris default-options]]
    io.aviso.twixt.startup
    ring.adapter.jetty)
  (:require
    ;; See https://github.com/slagyr/speclj/issues/79
    speclj.run.standard))

(install-pretty-exceptions)

(alter-var-root #'default-config assoc :color true :reporters ["documentation"])

(defn handler
  [request]
  (track "Invoking handler (that throws exceptions)"
         (if (= (:uri request) "/fail")
           ;; This will fail at some depth:
           (doall
             (get-asset-uris (:twixt request) "invalid-coffeescript.coffee")))))

(defn app
  []
  (wrap-with-twixt handler default-options true))

(defn launch []
  (let [server (run-jetty (app) {:port 8888 :join? false})]
    #(.stop server)))

(ns user
  (:use speclj.config
        io.aviso.tracker
        io.aviso.repl
        clojure.pprint
        [io.aviso.twixt :only [get-asset-uris default-options]]
        io.aviso.exception
        io.aviso.twixt.startup
        ring.adapter.jetty)
  ;; See https://github.com/slagyr/speclj/issues/79
  (:require speclj.run.standard))

(install-pretty-exceptions)

(alter-var-root #'*default-frame-filter*
                (fn [default-frame-filter]
                  (fn [frame]
                    (if (= (:package frame) "speclj")
                      :terminate
                      (default-frame-filter frame)))))

(alter-var-root #'default-config assoc :color true :reporters ["documentation"])

(defn handler
  [request]
  (track "Invoking handler (that throws exceptions)"
         (if (= (:uri request) "/fail")
           ;; This will fail at some depth:
           (doall
             (get-asset-uris (:twixt request) "invalid-coffeescript.coffee")))))

(defn app
  []
  (wrap-with-twixt handler default-options true))

(defn launch []
  (let [server (run-jetty (app) {:port 8888 :join? false})]
    #(.stop server)))

Terminate stack traces at any "speclj" namespace


(set-env!
  :dependencies '[[org.clojure/clojure "1.6.0"]
                  [boot-jruby "0.2.0"]]
  :source-paths #{"resources"})

(require
  '[clojure.java.io :as io]
  '[boot.jruby :refer [jruby make-jruby]])

(deftask haml
  "convert haml to html"
  []
  (let [jrb (make-jruby)]
    (with-pre-wrap fileset
      (jrb fileset
           ;; installs the haml gem, unless it's already installed
           :gem [["haml" "4.0.5"]]
           ;; sets data from clojure in the ruby runtime, as globals
           :set-var {"$haml_files" (->> fileset input-files (by-ext [".haml"]) (mapv #(.getAbsolutePath (tmpfile %))))
                     "$data"       {:what_the "nuts"}}
           ;; evaluates resources/render_haml.rb, that does the actual work
           :eval-file [(-> "render_haml.rb" io/resource io/file .getAbsolutePath)]))))

(deftask show-files
  "A debug task to println any files with :ext in the fileset"
  [e ext PATH [str] "extensions to show"]
  (with-pre-wrap fileset
    (doseq [:let [out-f (output-files fileset)]
            f (if (seq ext) (by-ext ext out-f) out-f)]
      (println (str "\n" (tmppath f) ":\n\n")
        (slurp (tmpfile f))))
    fileset))

(set-env!
  :dependencies '[[org.clojure/clojure "1.6.0"]
                  [boot-jruby "0.2.0"]]
  :source-paths #{"resources"})

(require
  '[clojure.java.io :as io]
  '[boot.jruby :refer [jruby make-jruby]])

(deftask haml
  "convert haml to html"
  []
  (let [jrb (make-jruby)]
    (with-pre-wrap fileset
      (jrb fileset
           ;; installs the haml gem, unless it's already installed
           :gem [["haml" "4.0.5"]]
           ;; sets data from clojure in the ruby runtime, as globals
           :set-var {"$haml_files" (->> fileset input-files (by-ext [".haml"]) (mapv #(.getAbsolutePath (tmpfile %))))
                     "$data"       {:what_the "nuts"}}
           ;; evaluates resources/render_haml.rb, that does the actual work
           :eval-file [(-> "render_haml.rb" io/resource io/file .getAbsolutePath)]))))

(deftask show-files
  "A debug task to println any files with :ext in the fileset"
  [e ext PATH [str] "extensions to show"]
  (with-pre-wrap fileset
    (doseq [:let [out-f (->> [user-files input-files output-files]
                          (mapcat #(% fileset))
                          set)]
            f (if (seq ext) (by-ext ext out-f) out-f)]
      (println (str "\n" (tmppath f) ":\n\n")
        (slurp (tmpfile f))))
    fileset))

Update show-files task to show input and user files as well.


(ns toucan.util
  "Utility functions used by other Toucan modules."
  (:require [clojure.string :as s])
  (:import java.util.Locale))

(defn keyword->qualified-name
  "Return keyword K as a string, including its namespace, if any (unlike `name`).

     (keyword->qualified-name :type/FK) -> \"type/FK\""
  [k]
  (when k
    (s/replace (str k) #"^:" "")))

(defn lower-case
  "Locale-agnostic version of `clojure.string/lower-case`.
  `clojure.string/lower-case` uses the default locale in conversions, turning
  `ID` into `ıd`, in the Turkish locale. This function always uses the
  `Locale/US` locale."
  [s]
  (.. s toString (toLowerCase (Locale/US))))

(ns toucan.util
  "Utility functions used by other Toucan modules."
  (:require [clojure.string :as s])
  (:import java.util.Locale))

(defn keyword->qualified-name
  "Return keyword K as a string, including its namespace, if any (unlike `name`).

     (keyword->qualified-name :type/FK) -> \"type/FK\""
  [k]
  (when k
    (s/replace (str k) #"^:" "")))

(defn lower-case
  "Locale-agnostic version of `clojure.string/lower-case`.
  `clojure.string/lower-case` uses the default locale in conversions, turning
  `ID` into `ıd`, in the Turkish locale. This function always uses the
  `Locale/US` locale."
  [^CharSequence s]
  (.. s toString (toLowerCase (Locale/US))))

Tag parameter `s` as `CharSequence`

Tag parameter `s` as `CharSequence`


(ns funnel-front.actions.app-actions

  (:use [funnel-front.lib.helpers :only [clog!]]
        [funnel-front.stores.main-store :only [app-state]]))

(defn update-app-state [event]
  (let [data (.parse js/JSON (.-data event))
        queries (.-query_ids data)
        body (.parse js/JSON (.-body data))]
    (.log js/console data)
    (swap! app-state
           update-in
           [:queries (keyword (first queries)) :items]
           conj {:body body})))

(ns funnel-front.actions.app-actions

  (:use [funnel-front.lib.helpers :only [clog!]]
        [funnel-front.stores.main-store :only [app-state]]))

(defn update-app-state [event]
  (let [data (.parse js/JSON (.-data event))
        queries (.-queries data)
        body (.parse js/JSON (.-body data))]
    (.log js/console data)
    (.log js/console "first match :" (.-id (first queries)))
    (swap! app-state
           update-in
           [:queries (keyword (.-id (first queries))) :items]
           conj {:body (js->clj body)})
    (.log js/console @app-state)
    ))

Use new data format for sse data and translate them to clojure data


(ns comic-reader.system
  (:require [clojure.tools.namespace.repl :refer [refresh]]
            [comic-reader.server :as server]
            [comic-reader.sites :as sites]
            [com.stuartsierra.component :as component]
            [environ.core :refer [env]]))

(defn comic-reader-system [config-options]
  (let [{:keys [app port]} config-options]
    (component/system-map
     :site-scraper (sites/new-site-scraper)
     :server       (component/using
                    (server/new-server app port)
                    [:site-scraper]))))

(def system nil)

(defn init [config-options]
  (alter-var-root #'system
    (constantly (comic-reader-system config-options))))

(defn start []
  (alter-var-root #'system component/start))

(defn stop []
  (alter-var-root #'system
    (fn [s] (when s (component/stop s)))))

(defn go [config-options]
  (init config-options)
  (start))

(defn reset []
  (stop)
  (refresh :after 'comic-reader.system/-main))

(defn -main [& [port]]
  (let [port (Integer. (or port (env :port) 10555))]
    (go {:app server/app
         :port port})))

(ns comic-reader.system
  (:require [clojure.tools.namespace.repl :refer [refresh]]
            [comic-reader.server :as server]
            [comic-reader.sites :as sites]
            [com.stuartsierra.component :as component]
            [environ.core :refer [env]]))

(defn comic-reader-system [config-options]
  (let [{:keys [app port]} config-options]
    (component/system-map
     :site-scraper (sites/new-site-scraper)
     :server       (component/using
                    (server/new-server app port)
                    [:site-scraper]))))

(def system nil)

(defn init [config-options]
  (alter-var-root #'system
    (constantly (comic-reader-system config-options))))

(defn start []
  (alter-var-root #'system component/start))

(defn stop []
  (alter-var-root #'system
    (fn [s] (when s (component/stop s)))))

(defn go [& [port]]
  (let [port (Integer. (or port (env :port) 10555))]
    (init {:app server/app
           :port port})
    (start)))

(defn reset []
  (stop)
  (refresh :after 'comic-reader.system/go))

(defn -main [& args]
  (apply go args))

Move default port calculation to `go` fn


(ns nth-prime)

(defn sqrt
  "Wrapper around java's sqrt method."
  [number]
  (int (Math/ceil (Math/sqrt number))))

(defn divides?
  "Helper function to decide if a number is evenly divided by divisor."
  [number divisor]
  (zero? (mod number divisor)))

(defn- prime-by-trial-division?
  "Simple trial division prime check."
  [number]
  (empty? (for [n (range 3 (inc (sqrt number)) 2) :when (divides? number n)] n)))

(defn prime? [number]
  (cond
    (= 2 number) true
    (even? number) false
    :else (prime-by-trial-division? number)))

(defn next-prime [start]
  (loop [n (inc start)]
    (if (prime? n)
      n
      (recur (inc n)))))

(defn nth-prime [index]
  (when (not (pos? index))
    (throw (IllegalArgumentException. "nth-prime expects a positive integer for an argument")))
  (loop [cur-prime 2
         num-times 1]
    (if (= num-times index)
      cur-prime
      (recur (next-prime cur-prime) (inc num-times)))))

(ns nth-prime)

(defn sqrt
  "Wrapper around java's sqrt method."
  [number]
  (int (Math/ceil (Math/sqrt number))))

(defn divides?
  "Helper function to decide if a number is evenly divided by divisor."
  [number divisor]
  (zero? (mod number divisor)))

(defn- prime-by-trial-division?
  "Simple trial division prime check."
  [number]
  (empty? (for [n (range 3 (inc (sqrt number)) 2) :when (divides? number n)] n)))

(defn prime? [number]
  (cond
    (= 2 number) true
    (even? number) false
    :else (prime-by-trial-division? number)))

(defn next-prime [start]
  (loop [n (inc start)]
    (if (prime? n)
      n
      (recur (inc n)))))

(def primes (iterate next-prime 1))

(defn nth-prime [index]
  (when (not (pos? index))
    (throw (IllegalArgumentException. "nth-prime expects a positive integer for an argument")))
  (nth primes index))

Replace loop-recur with iterate in nth-prime

In order to make a simple lazy seq, this commit wraps next-prime in an
interate call. Then nth-prime is as simple as calling nth on the primes
var.


(ns com.wsscode.pathom.diplomat.http.clj-http
  (:require [clj-http.client :as client]
            [com.wsscode.pathom.diplomat.http :as http]
            [clojure.spec.alpha :as s]))

(defn request [req]
  (s/assert ::http/request req)
  (client/request req))

(s/fdef request
  :args (s/cat :request ::http/request)
  :ret ::http/response)

(ns com.wsscode.pathom.diplomat.http.clj-http
  (:require [clj-http.client :as client]
            [com.wsscode.pathom.diplomat.http :as http]
            [clojure.spec.alpha :as s]))

; TODO not working at this point, will be implemented later

(defn request [req]
  (s/assert ::http/request req)
  (client/request req))

(s/fdef request
  :args (s/cat :request ::http/request)
  :ret ::http/response)

Add note about clj http implementation of http


(ns adzerk.boot-cljs.util
  (:require [clojure.java.io :as io]
            [clojure.string :as string]))

(defn path->js
  "Given a path to a CLJS namespace source file, returns the corresponding
  Google Closure namespace name for goog.provide() or goog.require()."
  [path]
  (-> path
      (string/replace #"\.clj[s|c]$" "")
      (string/replace #"[/\\]" ".")))

(defn path->ns
  "Given a path to a CLJS namespace source file, returns the corresponding
  CLJS namespace name."
  [path]
  (-> (path->js path) (string/replace #"_" "-")))

(defn get-name
  [path-or-file]
  (-> path-or-file io/file .getName))

(defn path [& parts]
  (.getPath (apply io/file parts)))

(ns adzerk.boot-cljs.util
  (:require [clojure.java.io :as io]
            [clojure.string :as string]))

(defn path->js
  "Given a path to a CLJS namespace source file, returns the corresponding
  Google Closure namespace name for goog.provide() or goog.require()."
  [path]
  (-> path
      (string/replace #"\.clj([s|c])?$" "")
      (string/replace #"[/\\]" ".")))

(defn path->ns
  "Given a path to a CLJS namespace source file, returns the corresponding
  CLJS namespace name."
  [path]
  (-> (path->js path) (string/replace #"_" "-")))

(defn get-name
  [path-or-file]
  (-> path-or-file io/file .getName))

(defn path [& parts]
  (.getPath (apply io/file parts)))

Add clj support for path->ns

Add clj support for path->ns


(defproject dropwizard-clojure/dropwizard-clojure "0.1.1"
  :description "Dropwizard for Clojure"
  :url "https://github.com/stevensurgnier/dropwizard-clojure"
  :license {:name "Apache License 2.0"
            :url "http://www.apache.org/licenses/LICENSE-2.0.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/tools.logging "0.3.1"]
                 [io.dropwizard/dropwizard-core "0.7.1"]]
  :source-paths ["src/main/clojure"]
  :test-paths ["src/test/clojure"]
  :profiles {:uberjar {:aot :all}}
  :global-vars {*warn-on-reflection* true})

(defproject dropwizard-clojure/dropwizard-clojure "0.2.0"
  :description "Dropwizard for Clojure"
  :url "https://github.com/stevensurgnier/dropwizard-clojure"
  :license {:name "Apache License 2.0"
            :url "http://www.apache.org/licenses/LICENSE-2.0.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/tools.logging "0.3.1"]
                 [io.dropwizard/dropwizard-core "0.8.2"]]
  :source-paths ["src/main/clojure"]
  :test-paths ["src/test/clojure"]
  :profiles {:uberjar {:aot :all}}
  :global-vars {*warn-on-reflection* true})

Update dropwizard to v0.8.2, bump minor version


(meditations
  "There is a wide range of ways to generate a sequence"
  (= __ (range 1 5))

  "The range starts at the beginning by default"
  (= __ (range 5))

  "It's important to only take what you need from a big sequence"
  (= [0 1 2 3 4 5 6 7 8 9]
     (take __ (range 100)))

  "You can also limit results by dropping what you don't need"
  (= [95 96 97 98 99]
     (drop __ (range 100)))

  "Iteration provides an infinite lazy sequence"
  (= __ (take 20 (iterate inc 0)))

  "Repetition is key"
  (= [:a :a :a :a :a :a :a :a :a :a ]
     (repeat 10 __))

  "Iteration can be used for repetition"
  (= (repeat 100 :foo)
     (take 100 (iterate ___ :foo))))

(meditations
  "There is a wide range of ways to generate a sequence"
  (= '(1 2 3 4) (range 1 5))

  "The range starts at the beginning by default"
  (= '(0 1 2 3 4) (range 5))

  "It's important to only take what you need from a big sequence"
  (= [0 1 2 3 4 5 6 7 8 9]
     (take 10 (range 100)))

  "You can also limit results by dropping what you don't need"
  (= [95 96 97 98 99]
     (drop 95 (range 100)))

  "Iteration provides an infinite lazy sequence"
  (= (range 0 20) (take 20 (iterate inc 0)))

  "Repetition is key"
  (= [:a :a :a :a :a :a :a :a :a :a ]
     (repeat 10 :a))

  "Iteration can be used for repetition"
  (= (repeat 100 :foo)
     (take 100 (iterate identity :foo))))

Complete lazy sequences koans test

Complete lazy sequences koans test


{:dev
 {:aliases {"test-all" ["with-profile" "dev,1.7:dev" "test"]}
  :dependencies [[com.nimbusds/nimbus-jose-jwt "4.13.1"]]
  :codeina {:sources ["src"]
            :reader :clojure
            :target "doc/dist/latest/api"
            :src-uri "http://github.com/funcool/buddy-core/blob/master/"
            :src-uri-prefix "#L"}
  :plugins [[funcool/codeina "0.4.0"]
            [lein-ancient "0.6.10"]]}
 :1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]}}

{:dev
 {:aliases {"test-all" ["with-profile" "dev,1.7:dev,1.8:dev" "test"]}
  :dependencies [[com.nimbusds/nimbus-jose-jwt "4.13.1"]]
  :codeina {:sources ["src"]
            :reader :clojure
            :target "doc/dist/latest/api"
            :src-uri "http://github.com/funcool/buddy-core/blob/master/"
            :src-uri-prefix "#L"}
  :plugins [[funcool/codeina "0.4.0"]
            [lein-ancient "0.6.10"]]}
 :1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]}
 :1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]}}

Add clojure 1.8 to the test suite.

Add clojure 1.8 to the test suite.


(ns clj-center.core
  (:require [clojure.java.io :as io]
            [clojure.tools.logging :as log]
            [clojure.tools.nrepl.server :refer [start-server]])
  (:gen-class))

(def ^:dynamic *nrepl-file*
  (io/file (System/getProperty "user.home") ".clj-center-nrepl-port"))

(defn -main []
  (let [nrepl-file (io/file *nrepl-file*)
        nrepl-file-str (str *nrepl-file*)
        _ (when (.exists nrepl-file)
            (throw (RuntimeException. (str "file already exists: "
                                           nrepl-file-str))))
        server (start-server)]
    (log/debug server)
    (spit nrepl-file (:port server))
    (log/info "write nrepl port info to file: " nrepl-file-str)
    (.deleteOnExit nrepl-file)))

(ns clj-center.core
  (:require [clojure.java.io :as io]
            [clojure.tools.logging :as log]
            [clojure.tools.nrepl.server :refer [start-server]])
  (:import (java.nio.file Files attribute.PosixFilePermission))
  (:gen-class))

(def ^:dynamic *nrepl-file*
  (io/file (System/getProperty "user.home") ".clj-center-nrepl-port"))

(defn -main []
  (let [nrepl-file (io/file *nrepl-file*)
        nrepl-file-str (str *nrepl-file*)
        _ (when (.exists nrepl-file)
            (throw (RuntimeException. (str "file already exists: "
                                           nrepl-file-str))))
        server (start-server)]
    (log/debug server)
    (spit nrepl-file (:port server))
    (try
      (Files/setPosixFilePermissions (.toPath nrepl-file)
                                     #{PosixFilePermission/OWNER_READ
                                       PosixFilePermission/OWNER_WRITE})
      (catch UnsupportedOperationException _))
    (log/info "write nrepl port info to file: " nrepl-file-str)
    (.deleteOnExit nrepl-file)))

Change permission of nrepl port file

Change permission of nrepl port file


(defproject org.clojure-grimoire/lib-grimoire "0.9.1"
  :description "A shared library for Grimoire infrastructure"
  :url "http://github.com/clojure-grimoire/lib-grimoire"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [version-clj "0.1.0"
                  :exclusions [org.clojure/clojure]]
                 [me.arrdem/guten-tag "0.1.0-SNAPSHOT"
                  :exclusions [org.clojure/clojure]]
                 [org.clojure/core.match "0.3.0-alpha4"
                  :exclusions [org.clojure/clojure]]
                 [com.cemerick/url "0.1.1"
                  :exclusions [com.cemerick/clojurescript.test
                               org.clojure/clojure]]]
  :profiles {:dev {:dependencies [[org.clojure/test.check "0.6.1"
                                   :exclusions [org.clojure/clojure]]]}})

(defproject org.clojure-grimoire/lib-grimoire "0.9.1"
  :description "A shared library for Grimoire infrastructure"
  :url "http://github.com/clojure-grimoire/lib-grimoire"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [version-clj "0.1.0"
                  :exclusions [org.clojure/clojure]]
                 [me.arrdem/guten-tag "0.1.0"
                  :exclusions [org.clojure/clojure]]
                 [org.clojure/core.match "0.3.0-alpha4"
                  :exclusions [org.clojure/clojure]]
                 [com.cemerick/url "0.1.1"
                  :exclusions [com.cemerick/clojurescript.test
                               org.clojure/clojure]]]
  :profiles {:dev {:dependencies [[org.clojure/test.check "0.6.1"
                                   :exclusions [org.clojure/clojure]]]}})

Use the 0.1.0 of guten-tag

Use the 0.1.0 of guten-tag


(defproject trotter "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [com.palletops/pallet "0.8.0-RC.9"]
                 [com.palletops/pallet-jclouds "1.7.3"]
                 [org.apache.jclouds.provider/rackspace-cloudservers-us "1.8.0"]]
  :profiles {:dev {:plugins [[com.palletops/pallet-lein "0.8.0-alpha.1"]]}})

(defproject trotter "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [com.palletops/pallet "0.8.0-RC.9"]
                 [com.palletops/pallet-jclouds "1.7.3"]
                 [org.apache.jclouds.provider/rackspace-cloudservers-us "1.8.0"]
                 [compojure "1.1.8"]
                 [ring/ring-core "1.3.0"]
                 [ring/ring-jetty-adapter "1.3.0"]
                 [ring/ring-json "0.3.1"]]
  :profiles {:dev {:plugins [[com.palletops/pallet-lein "0.8.0-alpha.1"]]}})

Add some compojure and ring for good measure


(defproject fault "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :profiles {:dev {:dependencies [[junit/junit "4.11"]
                                  [org.mockito/mockito-core "1.10.8"]]
                   :junit ["test/java"]
                   :java-source-paths ["src/java" "test/java"]
                   :plugins [[lein-junit "1.1.3"]]
                   :junit-formatter "brief"}}
  :javac-target "1.7"
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [criterium "0.4.3"]]
  :java-source-paths ["src/java"])

(defproject fault "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :profiles {:dev {:dependencies [[junit/junit "4.11"]
                                  [org.mockito/mockito-core "1.10.8"]]
                   :junit ["test/java"]
                   :java-source-paths ["src/java" "test/java"]
                   :plugins [[lein-junit "1.1.3"]]
                   :junit-formatter "brief"}}
  :javac-target "1.7"
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [criterium "0.4.3"]]
  :source-paths ["src/clojure"]
  :java-source-paths ["src/java"])

Make sure that the clojure source is included


(defproject lein-difftest "1.3.2-SNAPSHOT"
  :description "Run tests, display better test results."
  :dependencies [[org.clojars.brenton/difform "1.1.0"]
                 [clj-stacktrace "0.2.0" :exclusions [org.clojure/clojure]]
                 [clansi "1.0.0"]]
  :hooks [leiningen.hooks.difftest]
  :test-path "test-fail")

(defproject lein-difftest "1.3.2-SNAPSHOT"
  :description "Run tests, display better test results."
  :dependencies [[org.clojars.brenton/difform "1.1.1"]
                 [clj-stacktrace "0.2.0" :exclusions [org.clojure/clojure]]
                 [clansi "1.0.0" :exclusions [org.clojure/clojure]]]
  :dev-dependencies [[org.clojure/clojure "1.2.0"]
                     [org.clojure/clojure-contrib "1.2.0"]]
  :hooks [leiningen.hooks.difftest]
  :test-path "test-fail")

Update to latest difform. Add clojure 1.2 as a dev dependency.


(defproject org.onyxplatform/onyx-metrics "0.8.0.3"
  :description "Instrument Onyx workflows"
  :url "https://github.com/MichaelDrogalis/onyx"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [interval-metrics "1.0.0"]
                 [stylefruits/gniazdo "0.4.0"]]
  :java-opts ^:replace ["-server" "-Xmx3g"]
  :global-vars  {*warn-on-reflection* true
                 *assert* false
                 *unchecked-math* :warn-on-boxed}
  :profiles {:dev {:dependencies [^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}}
                                  [org.onyxplatform/onyx "0.8.0"]
                                  [riemann-clojure-client "0.4.1"]]
                   :plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}})

(defproject org.onyxplatform/onyx-metrics "0.8.0.4-SNAPSHOT"
  :description "Instrument Onyx workflows"
  :url "https://github.com/MichaelDrogalis/onyx"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [interval-metrics "1.0.0"]
                 [stylefruits/gniazdo "0.4.0"]]
  :java-opts ^:replace ["-server" "-Xmx3g"]
  :global-vars  {*warn-on-reflection* true
                 *assert* false
                 *unchecked-math* :warn-on-boxed}
  :profiles {:dev {:dependencies [^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}}
                                  [org.onyxplatform/onyx "0.8.0"]
                                  [riemann-clojure-client "0.4.1"]]
                   :plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}})

Prepare for next release cycle.

Prepare for next release cycle.


(defproject overtone "0.7.0-SNAPSHOT"
  :description "Programmable Music."
  :url "http://project-overtone.org"
  :dependencies [[org.clojure/clojure "1.3.0"]
                 [org.clojure/core.incubator "0.1.0"]
                 [org.clojure/data.json "0.1.2"]
                 [overtone/scsynth-jna "0.1.2-SNAPSHOT"]
                 [overtone/at-at "0.2.1"]
                 [overtone/osc-clj "0.7.1"]
                 [overtone/byte-spec "0.3.1"]
                 [overtone/midi-clj "0.2.1"]
                 [clj-glob "1.0.0"]
                 [org.clojure/core.match "0.2.0-alpha6"]
                 [seesaw "1.3.1-SNAPSHOT"]]
  :jvm-opts ["-Xms256m" "-Xmx1g" "-XX:+UseConcMarkSweepGC"])

(defproject overtone "0.7.0-SNAPSHOT"
  :description "Programmable Music."
  :url "http://project-overtone.org"
  :dependencies [[org.clojure/clojure "1.3.0"]
                 [org.clojure/core.incubator "0.1.0"]
                 [org.clojure/data.json "0.1.2"]
                 [overtone/scsynth-jna "0.1.2-SNAPSHOT"]
                 [overtone/at-at "0.2.1"]
                 [overtone/osc-clj "0.7.1"]
                 [overtone/byte-spec "0.3.1"]
                 [overtone/midi-clj "0.2.1"]
                 [clj-glob "1.0.0"]
                 [org.clojure/core.match "0.2.0-alpha6"]
                 [seesaw "1.4.0"]]
  :jvm-opts ["-Xms256m" "-Xmx1g" "-XX:+UseConcMarkSweepGC"])

Use Seesaw 1.4.0. No more SNAPSHOT for the time being.


(defproject me.arrdem/oxcart (slurp "VERSION")
  :description "An experimental optimizing compiler for Clojure code"
  :url "http://github.com/arrdem/oxcart"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [
                 [org.clojure/clojure            "1.5.1"]
                 [org.clojure/tools.analyzer     "0.2.2"]
                 [org.clojure/tools.analyzer.jvm "0.2.2"]
                 [org.clojure/tools.emitter.jvm  "0.0.1-SNAPSHOT"]
                 [org.clojure/tools.reader       "0.8.5"]
                 [com.taoensso/timbre            "3.2.1"]
                 ]
  :injections [(set! *print-length* 10)
               (set! *print-level*  10)])

(defproject me.arrdem/oxcart (slurp "VERSION")
  :description "An experimental optimizing compiler for Clojure code"
  :url "http://github.com/arrdem/oxcart"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [
                 [org.clojure/clojure            "1.5.1"]
                 [org.clojure/tools.analyzer     "0.2.3"]
                 [org.clojure/tools.analyzer.jvm "0.2.2"]
                 [org.clojure/tools.emitter.jvm  "0.0.1-SNAPSHOT"]
                 [org.clojure/tools.reader       "0.8.5"]
                 [com.taoensso/timbre            "3.2.1"]
                 ]
  :whitelist #"oxcart"
  :injections [(set! *print-length* 10)
               (set! *print-level*  10)])

Fix my radagast pattern & bump dep versions


(defproject incise "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [speclj "2.1.2"]
                 [ring "1.2.0"]
                 [hiccup "1.0.2"]
                 [compojure "1.1.5"]
                 [http-kit "2.1.1"]
                 [robert/hooke "1.3.0"]
                 [me.raynes/cegdown "0.1.0"]
                 [org.clojure/java.classpath "0.2.0"]
                 [org.clojure/tools.namespace "0.2.4"]
                 [org.clojure/tools.cli "0.2.4"]
                 [clj-time "0.5.1"]
                 [com.taoensso/timbre "2.6.1"]
                 [com.ryanmcg/stefon "0.5.1"]]
  :profiles {:dev {:dependencies [[speclj "2.5.0"]]}}
  :plugins [[speclj "2.5.0"]]
  :test-paths ["spec/"]
  :main incise.core)

(defproject incise "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [speclj "2.1.2"]
                 [ring "1.2.0"]
                 [hiccup "1.0.2"]
                 [compojure "1.1.5"]
                 [http-kit "2.1.10"]
                 [robert/hooke "1.3.0"]
                 [me.raynes/cegdown "0.1.0"]
                 [org.clojure/java.classpath "0.2.0"]
                 [org.clojure/tools.namespace "0.2.4"]
                 [org.clojure/tools.cli "0.2.4"]
                 [clj-time "0.5.1"]
                 [com.taoensso/timbre "2.6.1"]
                 [com.ryanmcg/stefon "0.5.0"]]
  :profiles {:dev {:dependencies [[speclj "2.5.0"]]}}
  :plugins [[speclj "2.5.0"]]
  :test-paths ["spec/"]
  :main incise.core)

Adjust stefon and http-kit versions.

Adjust stefon and http-kit versions.


(ns {{namespace}}
  (:require [play-clj.core :refer :all]
            [play-clj.ui :refer :all]))

(defscreen main-screen
  :on-show
  (fn [screen entities]
    (update! screen :renderer (stage))
    (label "Hello world!" (color :white)))
  :on-render
  (fn [screen entities]
    (clear!)
    (render! screen entities)))

(defgame {{app-name}}
  :on-create
  (fn [this]
    (set-screen! this main-screen)))

Add line between defscreen functions

Add line between defscreen functions


;; Copyright 2008-2011 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 immutant.registry
  (:import (org.jboss.msc.service ServiceName)))

(def registry nil)

(defn set-registry [v]
  (def registry v))

(defn service [name]
  (if registry
    (let [key (ServiceName/parse name)
          value (.getService registry key)]
      (and value (.getValue value)))))

;; Copyright 2008-2011 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 immutant.registry
  (:import (org.jboss.msc.service ServiceName)))

(def registry nil)

(defn set-registry [v]
  (def registry v))

(defn service [name]
  (if registry
    (let [key (if (string? name) (ServiceName/parse name) name)
          value (.getService registry key)]
      (and value (.getValue value)))))

Allow lookup by ServiceName or String

Allow lookup by ServiceName or String


(ns clojurewerkz.cassaforte.debug-utils
  (:use clojure.stacktrace))

(defmacro output-debug
  "Prints debugging statements out."
  [q]
  `(do
     (println "Built query: " ~q)
     ~q))

(defmacro catch-exceptions
  "Catches driver exceptions and outputs stacktrace."
  [& forms]
  `(try
     (do ~@forms)
     (catch com.datastax.driver.core.exceptions.DriverException ire#
       (println (print-stack-trace ire# 5))
       (println "Error came from server:" (.getMessage ire#)))))

(ns clojurewerkz.cassaforte.debug-utils
  (:use clojure.stacktrace))

(defmacro output-debug
  "Prints debugging statements out."
  [q]
  `(do
     (println "Built query: " ~q)
     ~q))

(defmacro catch-exceptions
  "Catches driver exceptions and outputs stacktrace."
  [& forms]
  `(try
     (do ~@forms)
     (catch com.datastax.driver.core.exceptions.DriverException ire#
       (println (.getMessage ire#))
       (print-cause-trace ire#))))

Improve debug utils as per @michaelklishin ocmment


(defproject {{app-name}} "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[com.badlogicgames.gdx/gdx "0.9.9-SNAPSHOT"]
                 [com.badlogicgames.gdx/gdx-backend-robovm "0.9.9-SNAPSHOT"]]
  :repositories [["sonatype"
                  "https://oss.sonatype.org/content/repositories/snapshots/"]]
  :java-source-paths ["src" "../desktop/src-common"]
  :javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"]
  :ios {:robovm-opts ["-libs" "libs/libObjectAL.a:libs/libgdx.a"
                      "-frameworks" "UIKit:OpenGLES:QuartzCore:CoreGraphics:OpenAL:AudioToolbox:AVFoundation"
                      "-resources" "../desktop/resources/**"]}
  :aot :all
  :main {{ios-namespace}})

(defproject {{app-name}} "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[com.badlogicgames.gdx/gdx "0.9.9-SNAPSHOT"]
                 [com.badlogicgames.gdx/gdx-backend-robovm "0.9.9-SNAPSHOT"]]
  :repositories [["sonatype"
                  "https://oss.sonatype.org/content/repositories/snapshots/"]]
  :java-source-paths ["src" "../desktop/src-common"]
  :javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"]
  :java-only true
  :ios {:robovm-opts ["-libs" "libs/libObjectAL.a:libs/libgdx.a"
                      "-frameworks" "UIKit:OpenGLES:QuartzCore:CoreGraphics:OpenAL:AudioToolbox:AVFoundation"
                      "-resources" "../desktop/resources/**"]}
  :aot :all
  :main {{ios-namespace}})

Add :java-only to Java game template

Add :java-only to Java game template


(ns clstreams.core
  (:gen-class)
  (:require [clojure.tools.logging :as log]
            [com.stuartsierra.component :as component]
            [signal.handler :as signal]
            [clstreams.pipelines]))

(defn run-system
  [system]
  (let [system-state (atom system)
        stop? (promise)]

    (signal/with-handler :int
      (log/info "Received SIGINT")
      (deliver stop? true))

    (swap! system-state component/start)
    (log/info "Topology initialized successfully")

    @stop?

    (log/info "Stopping topology")
    (swap! system-state component/stop)
    (log/info "Topology stopped")
    (System/exit 0)))

(defn -main
  [func-name]
  (let [system (eval (symbol func-name))]
    (run-system system)))

(ns clstreams.core
  (:gen-class)
  (:require [clojure.tools.logging :as log]
            [com.stuartsierra.component :as component]
            [signal.handler :as signal]
            [clstreams.pipelines]))

(defn run-system
  [system-state-var]
  (let [next-step (promise)
        orig-handlers
        (->
         {}
         (into (for [sgn [:term :int]]
                 [sgn
                  (signal/with-handler sgn
                    (log/debugf "Received SIG%s" (-> sgn name .toUpperCase))
                    (deliver next-step :end))]))
         (into (for [sgn [:hup]]
                 [sgn
                  (signal/with-handler sgn
                    (log/debugf "Received SIG%s" (-> sgn name .toUpperCase))
                    (deliver next-step :restart))])))]

    (log/info "Starting topology")
    (alter-var-root system-state-var component/start)

    (let [ns @next-step]

      (doseq [[sgn orig-handler] orig-handlers]
        (sun.misc.Signal/handle (signal/->signal :int) orig-handler))

      (log/info "Stopping topology")
      (alter-var-root system-state-var component/stop)

      (case ns
        :end (System/exit 0)
        :restart (recur system-state-var)))))

(defn -main
  [func-name]
  (def system-state (eval (symbol func-name)))
  (run-system #'system-state))

Make SIGHUP restart the system and SIGTERM stop it

SIGINT still works to stop the system. The code is now much cleaner
and uses a var in the core namespace to store the system state, so
that it remains globally accessible.


(ns catalog.core
  (:require [catalog.layout
             [dtbook :as layout.dtbook]
             [fop :as layout.fop]]
            [catalog.vubis :as vubis]
            [clojure.java.io :as io]))

(defn neu-im-sortiment [in out]
  (-> in
   vubis/read-file
   vubis/order-and-group
   (layout.fop/document :all-formats)
   (layout.fop/generate-pdf! out)))

(defn neue-grossdruckbücher [in out]
  (-> in
   vubis/read-file
   vubis/order-and-group
   (layout.fop/document :grossdruck)
   (layout.fop/generate-pdf! out)))

(defn neue-hörbücher [in out]
  (-> in
   vubis/read-file
   vubis/order-and-group
   (layout.fop/document :hörbuch)
   (layout.fop/generate-pdf! out)))

(defn neue-braillebücher [in out]
  (->> in
   vubis/read-file
   vubis/order-and-group
   :braille
   layout.dtbook/dtbook
   (spit (io/file out))))

(ns catalog.core
  (:require [catalog.layout
             [dtbook :as layout.dtbook]
             [fop :as layout.fop]]
            [catalog.vubis :as vubis]
            [clojure.java.io :as io]))

(defn neu-im-sortiment [in out]
  (-> in
   vubis/read-file
   vubis/order-and-group
   (layout.fop/document :all-formats)
   (layout.fop/generate-pdf! out)))

(defn neu-in-grossdruck [in out]
  (-> in
   vubis/read-file
   vubis/order-and-group
   (layout.fop/document :grossdruck)
   (layout.fop/generate-pdf! out)))

(defn neu-als-hörbuch [in out]
  (-> in
   vubis/read-file
   vubis/order-and-group
   (layout.fop/document :hörbuch)
   (layout.fop/generate-pdf! out)))

(defn neu-in-braille [in out]
  (->> in
   vubis/read-file
   vubis/order-and-group
   :braille
   layout.dtbook/dtbook
   (spit (io/file out))))

Rename functions to how the catalogs are named


(ns desdemona.launcher.aeron-media-driver
  (:gen-class)
  (:require [clojure.core.async :refer [chan <!!]]
            [clojure.tools.cli :refer [parse-opts]])
  (:import [uk.co.real_logic.aeron Aeron$Context]
           [uk.co.real_logic.aeron.driver MediaDriver MediaDriver$Context]))

(def cli-options
   ["-h" "--help"]])
  [["-d" "--delete-dirs"
    "Delete the media drivers directory on startup"
    :default false]

(defn -main [& args]
  (let [opts (parse-opts args cli-options)
        {:keys [help delete-dirs]} (:options opts)
        ctx (cond-> (MediaDriver$Context.)
              delete-dirs (.dirsDeleteOnStart delete-dirs))
        media-driver (try (MediaDriver/launch ctx)
                          (catch IllegalStateException ise
                            (throw (Exception. "Error starting media driver. This may be due to a media driver data incompatibility between versions. Check that no other media driver has been started and then use -d to delete the directory on startup" ise))))]
    (when help
      (run! (fn [opt]
              (println (clojure.string/join " " (take 3 opt))))
            cli-options)
      (System/exit 0))
    (println "Launched the Media Driver. Blocking forever...")
    (<!! (chan))))

(ns desdemona.launcher.aeron-media-driver
  (:gen-class)
  (:require [clojure.core.async :refer [chan <!!]]
            [clojure.tools.cli :refer [parse-opts]])
  (:import [uk.co.real_logic.aeron Aeron$Context]
           [uk.co.real_logic.aeron.driver MediaDriver MediaDriver$Context]))

(def cli-options
  [["-d" "--delete-dirs"
    "Delete the media drivers directory on startup"
    :default false]
   ["-h" "--help"
    "Display a help message"]])

(defn -main [& args]
  (let [opts (parse-opts args cli-options)
        {:keys [help delete-dirs]} (:options opts)
        ctx (cond-> (MediaDriver$Context.)
              delete-dirs (.dirsDeleteOnStart delete-dirs))
        media-driver (try (MediaDriver/launch ctx)
                          (catch IllegalStateException ise
                            (throw (Exception. "Error starting media driver. This may be due to a media driver data incompatibility between versions. Check that no other media driver has been started and then use -d to delete the directory on startup" ise))))]
    (when help
      (run! (fn [opt]
              (println (clojure.string/join " " (take 3 opt))))
            cli-options)
      (System/exit 0))
    (println "Launched the Media Driver. Blocking forever...")
    (<!! (chan))))

Add a help message for --help

Add a help message for --help


(ns scrape-trs.core
  (:require [scrape-trs.cascade-climbers.core :as cc]))

(comment
  "TODO:
   - add SPScrapeTripReport
   - upgrade get-trip-reports to return [errors, trip-reports]
     based on try-slurp that returns [error, contents]
   - add docs and tests for get-trip-reports
   - implement save-trip-reports!
   - make scrape-wa-trs project that
       retrieves cc.com tr list pages for each region in WA (POST)
       retrieves sp.com tr list page for WA
       get-trip-reports on each page and concat all together
       save to csv"

  (def cascade-climbers-washington-regions
    #{"Alpine Lakes"
      "Central/Eastern  Washington"
      "Columbia River Gorge"
      "Ice Climbing Forum"
      "Mount Rainier NP"
      "North Cascades"
      "Olympic Peninsula"
      "Rock Climbing Forum"
      "Southern WA Cascades"
      "the *freshiezone*"}))

(defn get-implementation
  [url]
  (let [base-url (re-find #"https?://.*?/" url)]
    (condp = base-url
      cc/base-url (cc/->CCScrapeTripReport))))

(defn get-trip-reports
  ""
  [implementation list-page]
  (let [pager-urls (.extract-pager-urls implementation list-page)
        list-pages (if pager-urls (map slurp pager-urls) [list-page])
        trip-report-urls (mapcat #(.extract-trip-report-urls implementation %)
                                 list-pages)
        trip-reports (map #(.extract-trip-report implementation %1 %2)
                          trip-report-urls
                          (map slurp trip-report-urls))]
    trip-reports))

(defn save-trip-reports!
  ""
  [f trip-reports])

(ns scrape-trs.core
  (:require [scrape-trs.cascade-climbers.core :as cc]
            [scrape-trs.summitpost.core :as sp]))

(defn get-implementation
  [url]
  (let [base-url (re-find #"https?://.*?/" url)]
    (condp = base-url
      cc/base-url (cc/->CCScrapeTripReport)
      sp/base-url (sp/->SPScrapeTripReport))))

(defn get-trip-reports
  ""
  [implementation list-page]
  (let [pager-urls (.extract-pager-urls implementation list-page)
        list-pages (if pager-urls (map slurp pager-urls) [list-page])
        trip-report-urls (mapcat #(.extract-trip-report-urls implementation %)
                                 list-pages)
        trip-reports (map #(.extract-trip-report implementation %1 %2)
                          trip-report-urls
                          (map slurp trip-report-urls))]
    trip-reports))

(defn save-trip-reports!
  ""
  [f trip-reports])

Remove comment and add SPScrapeTripReport to get-implementation.


(ns leiningen.droid.compatibility
  "Contains utilities for letting lein-droid to cooperate with
  ant/Eclipse build tools."
  (:require [clojure.java.io :as io])
  (:use [leiningen.core
         [main :only [info]]
         [classpath :only [resolve-dependencies]]]
        [leiningen.droid.utils :only [ensure-paths]]))

(defn gather-dependencies
  "Compatibility task. Copies the dependency libraries into the libs/ folder."
  [{:keys [root] :as project} & {dir ":dir", :or {dir "libs"} :as other}]
  (println (class (first (keys other))))
  (info "Copying dependency libraries into" (str dir "..."))
  (let [destination-dir (io/file root dir)
        dependencies (resolve-dependencies :dependencies project)]
    (.mkdirs destination-dir)
    (doseq [dep dependencies]
      (io/copy dep
               (io/file destination-dir (.getName ^java.io.File dep))))))

(defn create-repl-port-file
  "Creates a file named `repl-port` in target directory with port
  number inside, so fireplace.vim can connect to the REPL."
  [{{:keys [repl-local-port]} :android, target-path :target-path :as project}]
  (ensure-paths target-path)
  (spit (io/file target-path "repl-port") repl-local-port))

(ns leiningen.droid.compatibility
  "Contains utilities for letting lein-droid to cooperate with
  ant/Eclipse build tools."
  (:require [clojure.java.io :as io])
  (:use [leiningen.core
         [main :only [info]]
         [classpath :only [resolve-dependencies]]]
        [leiningen.droid.utils :only [ensure-paths]]))

(defn gather-dependencies
  "Compatibility task. Copies the dependency libraries into the libs/ folder."
  [{:keys [root] :as project} & {dir ":dir", :or {dir "libs"} :as other}]
  (println (class (first (keys other))))
  (info "Copying dependency libraries into" (str dir "..."))
  (let [destination-dir (io/file root dir)
        dependencies (resolve-dependencies :dependencies project)]
    (.mkdirs destination-dir)
    (doseq [dep dependencies]
      (io/copy dep
               (io/file destination-dir (.getName ^java.io.File dep))))))

(defn create-repl-port-file
  "Creates a file named `.nrepl-port` in project directory with port
  number inside, so that fireplace.vim can connect to the REPL."
  [{{:keys [repl-local-port]} :android, root :root}]
  (spit (io/file root ".nrepl-port") repl-local-port))

Create ".nrepl-port" file instead of "repl-port"


(ns cadence.views.landing
  (:require [cadence.views.common :as common]
            [noir.response :as response]
            [noir.cookies :as cook])
  (:use noir.core
        hiccup.core
        hiccup.page-helpers))

(defpage root "/" []
  (common/layout
    [:h1 "Cadence"]
    [:p "Welcome to cadence"]))

(defpage login "/login" []
  (common/layout
    [:h1 "Login"]
    [:p "WELCOME TO THE LOGIN PAGE!"]
    [:form [:post "/login"]
     [:input "Username"]
     [:input "Password"]
     [:input "Login"]]))

(defpage login-check [:post "/login"] []
  (response/empty {:hello "world"}))

(defpage signup "/signup" []
  (common/layout
    [:h1 "Login"]
    [:p "WELCOME TO THE LOGIN PAGE!"]))

(defpage about "/about" []
  (common/layout
    [:h1 "About"]
    [:p "derpderpderp"]))

(ns cadence.views.landing
  (:require [cadence.views.common :as common]
            [noir.response :as response]
            [noir.cookies :as cook])
  (:use noir.core
        hiccup.core
        hiccup.page-helpers
        hiccup.form-helpers))

(defpage root "/" []
  (common/layout
    [:h1 "Cadence"]
    [:p "Welcome to cadence"]))

(defn alabel [name] (label name name))

(defpartial form-with-labels
  "Returns labels and text fields for each name in the given collection."
  [coll]
  (for [field coll]
    (alabel field)
    ((if ((.toLower field) == "password") password-field text-field) field)))

(defpage login "/login" []
  (common/layout
    [:h1 "Login"]
    [:p "WELCOME TO THE LOGIN PAGE!"]
    (with-group "login"
                (form-to [:post "/login"]
                         (form-with-labels ["Username" "Password"])
                         (submit-button "Login")))))

(defpage login-check [:post "/login"] []
  (response/empty {:hello "world"}))

(defpage signup "/signup" []
  (common/layout
    [:h1 "Login"]
    [:p "WELCOME TO THE LOGIN PAGE!"]))

(defpage about "/about" []
  (common/layout
    [:h1 "About"]
    [:p "derpderpderp"]))

Use form helpers to create login form.

Use form helpers to create login form.


{:user {:signing {:gpg-key "8ED1CE42"}

        :dependencies [[alembic "0.2.1"]
                       [clj-stacktrace "0.2.7"]
                       [criterium "0.4.2"]
                       [org.clojure/tools.namespace "0.2.4"]
                       [slamhound "1.5.3"]
                       [spyscope "0.1.4"]]

        :plugins [[cider/cider-nrepl "0.7.0-SNAPSHOT"]
                  [codox "0.6.6"]
                  [jonase/eastwood "0.1.4"]
                  [lein-ancient "0.5.5" :exclusions [commons-codec]]
                  [lein-cljsbuild "1.0.3"]
                  [lein-clojars "0.9.1"]
                  [lein-cloverage "1.0.2"]
                  [lein-difftest "2.0.0"]
                  [lein-kibit "0.0.8"]
                  [lein-marginalia "0.7.1"]
                  [lein-pprint "1.1.1"]
                  [lein-swank "1.4.4"]]

        :injections [(require
                      '[alembic.still :refer [distill]]
                      '[clojure.repl :refer [source]]
                      '[clojure.tools.namespace.repl :as repl]
                      '[criterium.core :refer [bench quick-bench]]
                      'spyscope.core)]

        :aliases {"slamhound" ["run" "-m" "slam.hound"]}
        :search-page-size 50}}

{:user {:signing {:gpg-key "8ED1CE42"}

        :dependencies [[alembic "0.2.1"]
                       [clj-stacktrace "0.2.7"]
                       [criterium "0.4.2"]
                       [org.clojure/tools.namespace "0.2.4"]
                       [slamhound "1.5.3"]
                       [spyscope "0.1.4"]]

        :plugins [[cider/cider-nrepl "0.7.0"]
                  [codox "0.6.6"]
                  [jonase/eastwood "0.1.4"]
                  [lein-ancient "0.5.5" :exclusions [commons-codec]]
                  [lein-cljsbuild "1.0.3"]
                  [lein-clojars "0.9.1"]
                  [lein-cloverage "1.0.2"]
                  [lein-difftest "2.0.0"]
                  [lein-kibit "0.0.8"]
                  [lein-marginalia "0.7.1"]
                  [lein-pprint "1.1.1"]
                  [lein-swank "1.4.4"]]

        :injections [(require
                      '[alembic.still :refer [distill]]
                      '[clojure.repl :refer [source]]
                      '[clojure.tools.namespace.repl :as repl]
                      '[criterium.core :refer [bench quick-bench]]
                      'spyscope.core)]

        :aliases {"slamhound" ["run" "-m" "slam.hound"]}
        :search-page-size 50}}

Move from SNAPSHOT to cider-nrepl 0.7.0

Move from SNAPSHOT to cider-nrepl 0.7.0


(ns gigrig.components.pedal-search
  (:require [redux.core :refer [dispatch!]]
            [gigrig.actions :as a]))

(defn- search-field [{:keys [handle-change]}]
  [:input {:type "text"
           :placeholder "Search for a pedal"
           :on-change #(handle-change (.. % -target -value))}])

(defn- suggestion [i props]
  ^{:key i} [:li
             [:strong (:model props)]
             (:brand props)])

(defn dropdown [props]
  [:ul
   (map-indexed suggestion (:suggestions props))])

(defn component [props]
  [:div
   [search-field {:handle-change (fn [val] (dispatch! a/searchfield-key-pressed val))}]
   [dropdown (select-keys props [:suggestions])]])

(ns gigrig.components.pedal-search
  (:require [redux.core :refer [dispatch!]]
            [reagent.core :as reagent]
            [gigrig.actions :as a]))

(defn- search-field [{:keys [on-focus on-blur handle-change]}]
  [:input {:type "text"
           :placeholder "Search for a pedal"
           :on-focus on-focus
           :on-blur on-blur
           :on-change #(handle-change (.. % -target -value))}])

(defn- suggestion [i props]
  ^{:key i} [:li
             [:strong (:model props)]
             (:brand props)])

(defn dropdown [props]
  [:ul
   (map-indexed suggestion (:suggestions props))])

(defn component []
  (let [dropdown-visible (reagent/atom false)]
    (fn [props]
      [:div
       [search-field {:on-focus #(do (reset! dropdown-visible true) nil)
                      :on-blur #(do (reset! dropdown-visible false) nil)
                      :handle-change (fn [val] (dispatch! a/searchfield-key-pressed val))}]
       (if @dropdown-visible
         [dropdown (select-keys props [:suggestions])])])))

Hide dropdown when no focus

Hide dropdown when no focus


(ns clojars.unit.certs-test
  (:require [clojure.test :refer [deftest is]]))

(def sixty-days (* 86400 1000 60))

(deftest fail-when-gpg-key-is-about-to-expire
  (let [expire-date #inst "2021-12-25T00:00:00.000-00:00"]
    (is (< (System/currentTimeMillis)
          (- (.getTime expire-date) sixty-days))
      (format "Security GPG key expires on %s" expire-date))))

(deftest fail-when-tls-cert-is-about-to-expire
  (let [expire-date #inst "2020-06-17T00:00:00.000-00:00"]
    (is (< (System/currentTimeMillis)
          (- (.getTime expire-date) sixty-days))
      (format "clojars.org TLS cert expires on %s.\nBe sure to give lein a copy of the new one: %s"
        expire-date "https://github.com/technomancy/leiningen/blob/master/leiningen-core/resources/clojars.pem"))))

Remove unneeded TLS cert expiration test

The certs are now managed automatically by AWS.


(ns mikron.runtime.util
  "Generic utility functions."
  (:require [mikron.compiler.util :as compiler.util])
  #?(:cljs (:require-macros [mikron.runtime.util])))

#?(:cljs
   (defn node-env?
     "Returns `true` if compiled for Node.js, `false` otherwise."
     []
     (= "nodejs" cljs.core/*target*)))

(defmacro safe
  "Evaluates each expression of `body` and returns `ex-value` if an exception occured.
  Otherwise returns the value of the last expression in `body`."
  [ex-value & body]
  `(try
     (do ~@body)
     (catch ~(if (compiler.util/cljs?) `js/Object `Throwable) e#
       ~ex-value)))

(ns mikron.runtime.util
  "Generic utility functions."
  (:require [mikron.compiler.util :as compiler.util])
  #?(:cljs (:require-macros [mikron.runtime.util])))

#?(:cljs
   (defn node-env?
     "Returns `true` if compiled for Node.js, `false` otherwise."
     []
     (= "nodejs" cljs.core/*target*)))

(defmacro safe
  "Evaluates each expression of `body` and returns `ex-value` if an exception occured.
  Otherwise returns the value of the last expression in `body`."
  [ex-value & body]
  `(try
     (do ~@body)
     (catch ~(if (compiler.util/cljs?) :default `Throwable) e#
       ~ex-value)))

Change caught js exception type to :default


(ns discuss.utils.extensions
  "Extending JS types to be better accessible in CLJS.")

(def types [js/NodeList
            js/HTMLCollection
            js/HTMLDocument
            js/HTMLDivElement
            js/HTMLParagraphElement
            js/HTMLSpanElement])

(defn extend-type-fn
  "Given a type t, apply extensions."
  [t]
  (extend-type t
    ISeqable
    (-seq [array] (array-seq array 0))
    ICounted
    (-count [a] (alength a))
    IIndexed
    (-nth
      ([array n]
       (if (< n (alength array)) (aget array n)))
      ([array n not-found]
       (if (< n (alength array)) (aget array n)
                                 not-found)))
    ILookup
    (-lookup
      ([array k]
       (aget array k))
      ([array k not-found]
       (-nth array k not-found)))
    IReduce
    (-reduce
      ([array f]
       (ci-reduce array f))
      ([array f start]
       (ci-reduce array f start)))))

(doall (map extend-type-fn types))

(ns discuss.utils.extensions
  "Extending JS types to be better accessible in CLJS.")

(def types [js/NodeList
            js/HTMLCollection
            js/HTMLDocument
            js/HTMLDivElement
            js/HTMLParagraphElement
            js/HTMLSpanElement])

(defn extend-type-fn
  "Given a type t, apply extensions."
  [t]
  (extend-type t
    ISeqable
    (-seq [array] (array-seq array 0))
    ICounted
    (-count [a] (alength a))
    IIndexed
    (-nth
      ([array n]
       (if (< n (alength array)) (aget array n)))
      ([array n not-found]
       (if (< n (alength array)) (aget array n)
                                 not-found)))
    ILookup
    (-lookup
      ([array k]
       (aget array k))
      ([array k not-found]
       (-nth array k not-found)))
    IReduce
    (-reduce
      ([array f]
       (ci-reduce array f))
      ([array f start]
       (ci-reduce array f start)))))

(run! extend-type-fn types)

Replace fn with idiomatic function

Replace fn with idiomatic function


(ns hydrofoil.expectations.utils
  (:require [expectations :refer :all]
            [hydrofoil.core :refer :all]
            [hydrofoil.evolution :refer :all]))

;;; --------- Utils Tests ------------

(expect 2
        (+ 1 1))

(ns hydrofoil.expectations.utils
  (:require [expectations :refer :all]
            [hydrofoil.utils :refer :all]))

;;; --------- Utils Tests ------------

;; round-double tests
; Four Digits or less
(expect 0.1000
        (round-double 0.1000))
(expect 0.9999
        (round-double 0.9999))

; Over four digits
(expect 0.1
        (round-double 0.100001))
(expect 1.0
        (round-double 0.99999))

;; rand-double tests
(expect true
        (<= 0.0 (rand-double 0 1) 1))
(expect true
        (<= 0.5 (rand-double 0.5 12) 12))
(expect true
        (<= -1.0 (rand-double -1.0 1.0) 1.0))
(expect 0.0
        (rand-double 0 0))

Write tests for util functions

Write tests for util functions


(ns jugsclojure.server
  (:require [clojure.java.io :as io]
            [compojure.core :refer [ANY GET PUT POST DELETE defroutes]]
            [compojure.route :refer [resources]]
            [ring.middleware.defaults :refer [wrap-defaults api-defaults]]
            [ring.middleware.gzip :refer [wrap-gzip]]
            [ring.middleware.logger :refer [wrap-with-logger]]
            [environ.core :refer [env]]
            [ring.adapter.jetty :refer [run-jetty]])
  (:gen-class))

(defroutes routes
  (GET "/" _
    {:status 200
     :headers {"Content-Type" "text/html; charset=utf-8"}
     :body (io/input-stream (io/resource "public/index.html"))})
  (resources "/"))

(def http-handler
  (-> routes
      (wrap-defaults api-defaults)
      wrap-with-logger
      wrap-gzip))

(defonce server (atom nil))

(defn restart-server [& [port]]
  (swap! server (fn [value]
                  (when value (.stop value))
                  (run-jetty #'http-handler {:port (or port 10555) :join? false}))))

(defn -main [& [port]]
  (let [port (Integer. (or port (env :port)))]
    (restart-server port)))

(ns jugsclojure.server
  (:require [clojure.java.io :as io]
            [compojure.core :refer [ANY GET PUT POST DELETE defroutes]]
            [compojure.route :refer [resources]]
            [ring.middleware.defaults :refer [wrap-defaults api-defaults]]
            [ring.middleware.gzip :refer [wrap-gzip]]
            [ring.middleware.logger :refer [wrap-with-logger]]
            [environ.core :refer [env]]
            [ring.adapter.jetty :refer [run-jetty]])
  (:gen-class))

(defroutes routes
  (GET "/" _
    {:status 200
     :headers {"Content-Type" "text/html; charset=utf-8"}
     :body (io/input-stream (io/resource "public/index.html"))})
  (resources "/"))

(def http-handler
  (-> routes
      (wrap-defaults api-defaults)
      wrap-with-logger
      wrap-gzip))

(defonce server (atom nil))

(defn restart-server [& [port]]
  (swap! server (fn [value]
                  (when value (.stop value))
                  (run-jetty #'http-handler {:port (or port 10555) :join? false}))))

(defn -main [& [port]]
  (let [port (some-> (or port (env :port)) (Integer.))]
    (restart-server port)))

Fix command line port handling

Fix command line port handling


(defproject buddy/buddy-sign "0.6.0"
  :description "High level message signing for Clojure"
  :url "https://github.com/funcool/buddy-sign"
  :license {:name "Apache 2.0"
            :url "http://www.apache.org/licenses/LICENSE-2.0"}
  :dependencies [[org.clojure/clojure "1.7.0" :scope "provided"]
                 [com.taoensso/nippy "2.9.0"]
                 [buddy/buddy-core "0.6.0"]
                 [cats "0.4.0"]
                 [clj-time "0.9.0"]
                 [cheshire "5.5.0"]]
  :source-paths ["src"]
  :javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"]
  :test-paths ["test"])

(defproject buddy/buddy-sign "0.6.0"
  :description "High level message signing for Clojure"
  :url "https://github.com/funcool/buddy-sign"
  :license {:name "Apache 2.0"
            :url "http://www.apache.org/licenses/LICENSE-2.0"}
  :dependencies [[org.clojure/clojure "1.7.0" :scope "provided"]
                 [com.taoensso/nippy "2.9.0"]
                 [buddy/buddy-core "0.6.0"]
                 [funcool/cats "0.5.0"]
                 [clj-time "0.9.0"]
                 [cheshire "5.5.0"]]
  :source-paths ["src"]
  :javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"]
  :test-paths ["test"])

Update cats dependency to 0.5.0

Update cats dependency to 0.5.0


(defproject onyx-app/lein-template "0.9.7.0-alpha13"
  :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)

Prepare for next release cycle.

Prepare for next release cycle.


(defproject bolt "0.1.0-SNAPSHOT"
  :description "FIXME: write this!"
  :url "http://example.com/FIXME"

  :dependencies [[org.clojure/clojure "1.6.0" :scope "provided"]
                 [org.clojure/clojurescript "0.0-3149" :scope "provided"]
                 [rum "0.2.6"]
                 [org.clojure/core.async "0.1.346.0-17112a-alpha"]
                 [secretary "1.2.2"]]

  :plugins [[lein-cljsbuild "1.0.5"]]

  :cljsbuild {
              :builds [{:id "dev"
                        :source-paths ["src"]
                        :compiler {:main "bolt.core"
                                   :output-to "resources/public/js/bolt.js"
                                   :output-dir "resources/public/js/out"
                                   :optimizations :none
                                   :source-map true
                                   :warnings {:single-segment-namespace false}
                                   :asset-path "js/out"}}
                       {:id "prod"
                        :source-paths ["src"]
                        :notify-command ["say"]
                        :compiler {:output-to "resources/public/js/bolt.js"
                                   :output-dir "resources/public/js/prod-out"
                                   :optimizations :advanced
                                   :source-map "resources/public/js/bolt.js.map"
                                   :pretty-print false
                                   :asset-path "js/prod-out"
                                   :warnings {:single-segment-namespace false}
                                   :externs ["resources/externs/w3c_speech.js"]}}]})

(defproject bolt "0.1.0-SNAPSHOT"
  :description "FIXME: write this!"
  :url "http://example.com/FIXME"

  :dependencies [[org.clojure/clojure "1.8.0" :scope "provided"]
                 [org.clojure/clojurescript "1.7.228" :scope "provided"]
                 [rum "0.2.6"]
                 [org.clojure/core.async "0.1.346.0-17112a-alpha"]
                 [secretary "1.2.2"]]

  :plugins [[lein-cljsbuild "1.1.2"]]

  :cljsbuild {
              :builds [{:id "dev"
                        :source-paths ["src"]
                        :compiler {:main "bolt.core"
                                   :output-to "resources/public/js/bolt.js"
                                   :output-dir "resources/public/js/out"
                                   :optimizations :none
                                   :source-map true
                                   :warnings {:single-segment-namespace false}
                                   :asset-path "js/out"}}
                       {:id "prod"
                        :source-paths ["src"]
                        :notify-command ["say"]
                        :compiler {:output-to "resources/public/js/bolt.js"
                                   :output-dir "resources/public/js/prod-out"
                                   :optimizations :advanced
                                   :source-map "resources/public/js/bolt.js.map"
                                   :pretty-print false
                                   :asset-path "js/prod-out"
                                   :warnings {:single-segment-namespace false}
                                   :externs ["resources/externs/w3c_speech.js"]}}]})

Use modern clj + cljs versions

Use modern clj + cljs versions


(defproject twitter-collector "0.1.0-SNAPSHOT"
  :description "A Twitter collector with a Datomic stream."
  :url "https://github.com/replikativ/twitter-collector"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.8.0"]

                 [io.replikativ/gezwitscher "0.2.0-SNAPSHOT"]
                 [io.replikativ/replikativ "0.2.1"]
                 [employeerepublic/slf4j-timbre "0.4.2"]
                 [com.datomic/datomic-free "0.9.5554"
                  :exclusions [commons-codec]]
                 [incanter "1.5.7"]]

  :main twitter-collector.core)

(defproject twitter-collector "0.1.0-SNAPSHOT"
  :description "A Twitter collector with a Datomic stream."
  :url "https://github.com/replikativ/twitter-collector"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.8.0"]

                 [io.replikativ/gezwitscher "0.2.0-SNAPSHOT"]
                 [io.replikativ/kabel "0.2.1-SNAPSHOT"]
                 [io.replikativ/replikativ "0.2.1"]
                 [employeerepublic/slf4j-timbre "0.4.2"]
                 [com.datomic/datomic-free "0.9.5554"
                  :exclusions [commons-codec]]
                 [incanter "1.5.7"]]

  :main twitter-collector.core)

Use a kabel version with bigger incoming buffer.


(ns lt.objs.notifos
  (:require [lt.object :as object]
            [lt.objs.statusbar :as statusbar]
            [lt.objs.command :as cmd]
            [lt.util.js :refer [wait]]
            [crate.binding :refer [map-bound bound deref?]])
  (:require-macros [lt.macros :refer [behavior defui]]))

(def standard-timeout 10000)

(defn working [msg]
  (when msg
    (set-msg! msg))
  (statusbar/loader-inc))

(defn done-working
  ([]
   (statusbar/loader-dec))
  ([msg]
   (set-msg! msg)
   (statusbar/loader-dec)))

(defn msg* [m & [opts]]
  (let [m (if (string? m)
            m
            (pr-str m))]
    (object/merge! statusbar/statusbar-loader (merge {:message m :class ""} opts))))

(defn set-msg! [msg opts]
  (msg* msg opts)
  (js/clearTimeout cur-timeout)
  (set! cur-timeout (wait standard-timeout #(msg* ""))))

(cmd/command {:command :reset-working
              :desc "Statusbar: Reset working indicator"
              :exec (fn []
                      (statusbar/loader-set 0)
                      )})

(ns lt.objs.notifos
  (:require [lt.object :as object]
            [lt.objs.statusbar :as statusbar]
            [lt.objs.command :as cmd]
            [lt.util.js :refer [wait]]
            [crate.binding :refer [map-bound bound deref?]])
  (:require-macros [lt.macros :refer [behavior defui]]))

(def standard-timeout 10000)

(defn working [msg]
  (when msg
    (set-msg! msg))
  (statusbar/loader-inc))

(defn done-working
  ([]
   (statusbar/loader-dec))
  ([msg]
   (set-msg! msg)
   (statusbar/loader-dec)))

(defn msg* [m & [opts]]
  (let [m (if (string? m)
            m
            (pr-str m))]
    (object/merge! statusbar/statusbar-loader (merge {:message m :class ""} opts))))

(defn set-msg!
  ([msg]
   (msg* msg)
   (js/clearTimeout cur-timeout)
   (set! cur-timeout (wait standard-timeout #(msg* ""))))
  ([msg opts]
   (msg* msg opts)
   (js/clearTimeout cur-timeout)
   (set! cur-timeout (wait (or (:timeout opts)
                               standard-timeout) #(msg* "")))))

(cmd/command {:command :reset-working
              :desc "Statusbar: Reset working indicator"
              :exec (fn []
                      (statusbar/loader-set 0)
                      )})

Extend set-msg! with custom timeout

Extend set-msg! with custom timeout

The function notifos/set-msg! accepts a :timeout key/value pair in the opts map
to set a custom timeout.