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

  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/clojurescript "0.0-2199"]
                 [org.clojure/core.async "0.1.278.0-76b25b-alpha"]
                 [om "0.5.3"]
                 [com.taoensso/sente "0.9.0"]
                 [http-kit "2.1.18"]
                 [compojure "1.1.6"]]

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

  :source-paths ["src/clj"]

  :cljsbuild {
    :builds [{:id "om-sente"
              :source-paths ["src/cljs"]
              :compiler {
                :output-to "om_sente.js"
                :output-dir "out"
                :optimizations :none
                :source-map true}}]})

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

  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/clojurescript "0.0-2199"]
                 [org.clojure/core.async "0.1.278.0-76b25b-alpha"]
                 [om "0.5.3"]
                 [com.taoensso/sente "0.9.0"]
                 [http-kit "2.1.18"]
                 [compojure "1.1.6"]
                 [ring/ring-core "1.2.2"]
                 [jetty/javax.servlet "5.1.12"]]

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

  :source-paths ["src/clj"]

  :cljsbuild {
    :builds [{:id "om-sente"
              :source-paths ["src/cljs"]
              :compiler {
                :output-to "om_sente.js"
                :output-dir "out"
                :optimizations :none
                :source-map true}}]})

Add Ring and Servlet dependencies

Add Ring and Servlet dependencies


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


;; Copyright 2014-2016 Andrey Antukh <niwi@niwi.nz>
;;
;; Licensed under the Apache License, Version 2.0 (the "License")
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;;     http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.

(ns buddy.core.codecs.base64
  "Util functions for make conversion between string, bytes
  and encode them to base64 ot hex format."
  (:require [buddy.core.codecs :as codecs])
  (:import org.apache.commons.codec.binary.Base64))

(defn encode
  "Encode data to byte array base64.
  Accepts String and byte array as argument."
  ([data]
   (encode data false))
  ([data urlsafe?]
   (let [data (codecs/to-bytes data)]
     (if urlsafe?
       (Base64/encodeBase64URLSafe ^bytes data)
       (Base64/encodeBase64 ^bytes data)))))

(defn decode
  "Decode base64 data into byte array.
  Accepts String and byte array as input
  argument."
  [data]
  (let [data (codecs/to-bytes data)]
    (Base64/decodeBase64 ^bytes data)))

;; Copyright 2014-2016 Andrey Antukh <niwi@niwi.nz>
;;
;; Licensed under the Apache License, Version 2.0 (the "License")
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;;     http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.

(ns buddy.core.codecs.base64
  "Util functions for make conversion between string, bytes
  and encode them to base64 hex format."
  (:require [buddy.core.codecs :as codecs])
  (:import org.apache.commons.codec.binary.Base64))

(defn encode
  "Encode data to byte array base64.
  Accepts String and byte array as argument."
  ([data]
   (encode data false))
  ([data urlsafe?]
   (let [data (codecs/to-bytes data)]
     (if urlsafe?
       (Base64/encodeBase64URLSafe ^bytes data)
       (Base64/encodeBase64 ^bytes data)))))

(defn decode
  "Decode base64 data into byte array.
  Accepts String and byte array as input
  argument."
  [data]
  (let [data (codecs/to-bytes data)]
    (Base64/decodeBase64 ^bytes data)))

Fix typo in ns docstring

Fix typo in ns docstring


(ns clj-gatling.httpkit
  (:require [org.httpkit.client :as http])
  (:import  [org.httpkit PrefixThreadFactory]
            [org.httpkit.client HttpClient]
            [java.util.concurrent ThreadPoolExecutor LinkedBlockingQueue TimeUnit]))

(defonce cache-dns-forever (java.security.Security/setProperty "networkaddress.cache.ttl" "-1"))

(defonce pool-size (* 2 (.availableProcessors (Runtime/getRuntime))))

(defonce httpkit-pool (repeatedly pool-size #(HttpClient.)))

(defn- get-httpkit-client [^long idx]
  (nth httpkit-pool (mod idx pool-size)))

(defonce httpkit-callback-pool (let [pool-size (.availableProcessors (Runtime/getRuntime))
                                     queue (LinkedBlockingQueue.)
                                     factory (PrefixThreadFactory. "httpkit-callback-worker-")]
                                     (ThreadPoolExecutor. pool-size pool-size 60 TimeUnit/SECONDS queue factory)))

(defn async-http-request [url user-id context callback]
  (let [check-status (fn [{:keys [^long status]}]
                        (callback (= 200 status)))]
    (http/get url {:worker-pool httpkit-callback-pool :client (get-httpkit-client user-id)} check-status)))

(ns clj-gatling.httpkit
  (:require [org.httpkit.client :as http])
  (:import  [org.httpkit PrefixThreadFactory]
            [org.httpkit.client HttpClient]
            [java.util.concurrent ThreadPoolExecutor LinkedBlockingQueue TimeUnit]))

(defonce cache-dns-forever (java.security.Security/setProperty "networkaddress.cache.ttl" "-1"))

(defonce pool-size (* 2 (.availableProcessors (Runtime/getRuntime))))

(defonce httpkit-pool (repeatedly pool-size #(HttpClient.)))

(defn- get-httpkit-client [^long idx]
  (nth httpkit-pool (mod idx pool-size)))

(defonce httpkit-callback-pool (let [pool-size (.availableProcessors (Runtime/getRuntime))
                                     queue (LinkedBlockingQueue.)
                                     factory (PrefixThreadFactory. "httpkit-callback-worker-")]
                                     (ThreadPoolExecutor. pool-size pool-size 60 TimeUnit/SECONDS queue factory)))

(defn async-http-request [url user-id context callback]
  (let [check-status (fn [{:keys [status]}]
                        (callback (= 200 status)))]
    (http/get url {:worker-pool httpkit-callback-pool :client (get-httpkit-client user-id)} check-status)))

Remove type from http status response to avoid nil problems when status code is missing


(ns posthere.util.uuid
  "UUIDs and the heat death of the Universe..."
  (:require [clojure.string :as s]))

(defn uuid
  "Simple wrapper for Java's UUID"
  []
  (str (java.util.UUID/randomUUID)))

(ns posthere.util.uuid
  "UUIDs and the heat death of the Universe...")

(defn uuid
  "Simple wrapper for Java's UUID"
  []
  (str (java.util.UUID/randomUUID)))

Remove unused namespace include to make Eastwood happy.


(ns {{app-name}}.lifecycles.sample-lifecycle
  (:require [clojure.core.async :refer [chan sliding-buffer >!!]]
            [onyx.plugin.core-async :refer [take-segments!]]
            [onyx.static.planning :refer [find-task]]
            [{{app-name}}.utils :as u]))

;;;; Lifecycle hook to debug segments by logging them to the console.
(defn log-batch [event lifecycle]
  (doseq [m (map :message (mapcat :leaves (:tree (:onyx.core/results event))))]
    (prn "Logging segment: " m))
  {})

(def log-calls
  {:lifecycle/after-batch log-batch})

(defn build-lifecycles []
  [{:lifecycle/task :read-lines
    :lifecycle/calls :{{app-name}}.plugins.http-reader/reader-calls
    :lifecycle/replaceable? true
    :lifecycle/doc "Lifecycle for reading from a core.async chan"}
   {:lifecycle/task :write-lines
    :core.async/id (java.util.UUID/randomUUID)
    :lifecycle/replaceable? true
    :lifecycle/calls :onyx.plugin.core-async/writer-calls
    :lifecycle/doc "Lifecycle for injecting a core.async writer chan"}
   {:lifecycle/task :write-lines
    :lifecycle/calls ::log-calls
    :lifecycle/doc "Lifecycle for printing the output of a task's batch"}])

(ns {{app-name}}.lifecycles.sample-lifecycle
  (:require [clojure.core.async :refer [chan sliding-buffer >!!]]
            [onyx.plugin.core-async :refer [take-segments!]]
            [onyx.static.planning :refer [find-task]]
            [{{app-name}}.utils :as u]))

;;;; Lifecycle hook to debug segments by logging them to the console.
(defn log-batch [event lifecycle]
  (doseq [m (map :message (mapcat :leaves (:tree (:onyx.core/results event))))]
    (prn "Logging segment: " m))
  {})

(def log-calls
  {:lifecycle/after-batch log-batch})

(defn build-lifecycles []
  [{:lifecycle/task :read-lines
    :lifecycle/calls :{{app-name}}.plugins.http-reader/reader-calls
    :lifecycle/replaceable? true
    :lifecycle/doc "Lifecycle for reading from a core.async chan"}
   {:lifecycle/task :write-lines
    :lifecycle/calls :{{app-name}}.utils/out-calls
    :core.async/id (java.util.UUID/randomUUID)
    :lifecycle/replaceable? true
    :lifecycle/doc "Lifecycle for your output task. When using in-memory-lifecycles, this will be replaced"}
   {:lifecycle/task :write-lines
    :lifecycle/calls :onyx.plugin.core-async/writer-calls
    :lifecycle/doc "Lifecycle for injecting a core.async writer chan"}
   {:lifecycle/task :write-lines
    :lifecycle/calls ::log-calls
    :lifecycle/doc "Lifecycle for printing the output of a task's batch"}])

Document how lifecycle gets replaced in test


 (ns cruncher.rename
   (:require [om.next :as om :refer-macros [defui]]
             [om.dom :as dom :include-macros true]
             [goog.dom :as gdom]
             [cruncher.utils.views :as vlib]
             [cruncher.utils.lib :as lib]))

(defui RenamingControls
       Object
       (render [this]
               (dom/div nil
                        (dom/p #js {:className "lead"} "Rename Pokemon")
                        "hm?")))
(def controls (om/factory RenamingControls))

(ns cruncher.rename
  (:require [om.next :as om :refer-macros [defui]]
            [om.dom :as dom :include-macros true]
            [goog.dom :as gdom]
            [cruncher.utils.views :as vlib]
            [cruncher.utils.lib :as lib]))

(defui SelectSchemes
  Object
  (render [this]
    (let [selected (or (om/get-state this :selected) "rename-scheme-1")]
      (dom/div nil
               (dom/div #js {:className "form-group"}
                        (dom/select #js {:className "form-control"
                                         :onChange  #(println "click")
                                         :value     selected}
                                    (dom/option #js {:value "rename-scheme-1"} "IV% AT/DF/ST")
                                    (dom/option #js {:value "rename-scheme-2"} "AT/DF/ST")
                                    (dom/option #js {:value "rename-scheme-3"} "IV%")))
               (dom/div #js {:className "form-group"})))))
(def select-schemes (om/factory SelectSchemes {}))

(defui RenamingControls
  Object
  (render [this]
    (dom/div nil
             (dom/p #js {:className "lead"} "Renaming")
             (dom/label #js {:className "control-label"} "Renames selected Pokemon. Not reversible.")
             (dom/div #js {:className "row"}
                      (dom/div #js {:className "col-md-3"}
                               (select-schemes (om/props this)))))))
(def controls (om/factory RenamingControls))

Add ui to select scheme

Add ui to select scheme


(ns circle.util.retry
  (:use [arohner.utils :only (inspect)])
  (:use [circle.util.except :only (throw-if-not)])
  (:use [robert.bruce :only (try-try-again)]))

(defn parse-args [args]
  (if (map? (first args))
    {:options (first args)
     :f (second args)
     :args (drop 2 args)}
    {:f (first args)
     :args (rest args)}))

(defn wait-for
  "Like robert bruce, but waits for arbitrary results rather than just
  exceptions.

  Takes all arguments exactly the same as robert bruce. Extra arguments to wait-for may be passed in the robert bruce options:

 - success-fn: a fn of one argument, the return value of f. Stop retrying if success-fn returns truthy. If not specified, wait-for returns when f returns truthy"

  {:arglists
   '([fn] [fn & args] [options fn] [options fn & args])}
  [& args]
  (let [{:keys [options f args] :as parsed-args} (parse-args args)
        success (-> options :success-fn)]
    (throw-if-not (-> parsed-args :f fn?) "couldn't find fn")
    (let [f (fn []
              (let [result (apply f args)]
                (if success
                  (throw-if-not (success result) "(success) did not return truthy in time")
                  (throw-if-not result "f did not return truthy in time"))))]
      (try-try-again options f))))

(ns circle.util.retry
  (:use [circle.util.except :only (throw-if-not)])
  (:use [robert.bruce :only (try-try-again)]))

(defn parse-args [args]
  (if (map? (first args))
    {:options (first args)
     :f (second args)
     :args (drop 2 args)}
    {:f (first args)
     :args (rest args)}))

(defn wait-for
  "Like robert bruce, but waits for arbitrary results rather than just
  exceptions.

  Takes all arguments exactly the same as robert bruce. Extra arguments to wait-for may be passed in the robert bruce options:

 - success-fn: a fn of one argument, the return value of f. Stop retrying if success-fn returns truthy. If not specified, wait-for returns when f returns truthy"

  {:arglists
   '([fn] [fn & args] [options fn] [options fn & args])}
  [& args]
  (let [{:keys [options f args] :as parsed-args} (parse-args args)
        success (-> options :success-fn)]
    (throw-if-not (-> parsed-args :f fn?) "couldn't find fn")
    (let [f (fn []
              (let [result (apply f args)]
                (if success
                  (throw-if-not (success result) "(success) did not return truthy in time")
                  (throw-if-not result "f did not return truthy in time"))
                result))]
      (try-try-again options f))))

Return the result after waiting

Return the result after waiting


{
 :name "wgseq-phase2",
 :path  "",

 :graph {:dir  {:type "func"
                :name "get-comparison-files"
                :args ["#1", "#2" "#3"]} ; eid, comparison-file, :NA here
         :take {:type "func"
                :name "strm-take"
                :args [10]}
         :bseq {:type "func"
                :name "breseq-runs"}
         :aggr {:type "func"
                :name "aggregate"}
         :mail {:type "func"
                :name "mailp2"
                :args ["#4"        ; recipient
                       "Aerobio job status: wgseq phase-2"
                       "Finished"]}      ; subject, body intro
         :edges {:dir  [:take]
                 :take [:bseq]
                 :bseq [:aggr]
                 :aggr [:mail]}}

 ;; instructional data used in /help
 :description ""
 }

{
 :name "wgseq-phase2",
 :path  "",

 :graph {:dir  {:type "func"
                :name "get-comparison-files"
                :args ["#1", "#2" "#3"]} ; eid, comparison-file, :NA here
         :bseq {:type "func"
                :name "sfj-breseq-runs"}
         :mail {:type "func"
                :name "mailp2"
                :args ["#4"        ; recipient
                       "Aerobio job status: wgseq phase-2"
                       "Finished"]}      ; subject, body intro
         :edges {:dir  [:bseq]
                 :bseq [:mail]}}

 ;; instructional data used in /help
 :description "Run a full set of breseq runs for experiment '#1' EID, with comparison file '#2' and sending completion msg to recipient '#4'. Uses streaming 'fork/join' breseq runner, which is also able to restart run after last completed run in case of server interruptions."
 }

Move to streaming 'fork/join' for breseq runs


(ns faceboard.whitelabel
  (:require-macros [faceboard.macros.model :refer [transform-app-state]]
                   [faceboard.macros.logging :refer [log log-err log-warn log-info]])
  (:require [faceboard.env :as env]
            [faceboard.model :as model]
            [faceboard.helpers.utils :as utils]))

(def domain-mappings
  [[#"fb\.local.*" "test-localhost-whitelabel"]             ; just a test local host
   [#".*hackerparadise\.org" "hp"]])                        ; http://faceboard.hackerparadise.org

(defn domain->boad-id [domain]
  (if-let [match (utils/find-first #(re-matches (first %) domain) domain-mappings)]
    (second match)))

(defn whitelabel-board []
  (domain->boad-id env/domain))

(defn init-hp! []
  (transform-app-state
    (model/set [:ui :filters :active :groups] #{"present"})))

(defn init-test-localhost! []
  (log "test localhost whitelabel init"))

(defn init! []
  (condp = (domain->boad-id env/domain)
    "test-localhost-whitelabel" (init-test-localhost!)
    "hp" (init-hp!)
    nil))

(ns faceboard.whitelabel
  (:require-macros [faceboard.macros.model :refer [transform-app-state]]
                   [faceboard.macros.logging :refer [log log-err log-warn log-info]])
  (:require [faceboard.env :as env]
            [faceboard.model :as model]
            [faceboard.helpers.utils :as utils]))

(def domain-mappings
  [[#"fb\.local.*" "test-localhost-whitelabel"]             ; just a test local host
   [#".*hackerparadise\.org" "3a8450f9a0cb45d99c1a"]])      ; http://faceboard.hackerparadise.org

(defn domain->boad-id [domain]
  (if-let [match (utils/find-first #(re-matches (first %) domain) domain-mappings)]
    (second match)))

(defn whitelabel-board []
  (domain->boad-id env/domain))

(defn init-hp! []
  (transform-app-state
    (model/set [:ui :filters :active :groups] #{"present"})))

(defn init-test-localhost! []
  (log "test localhost whitelabel init"))

(defn init! []
  (condp = (domain->boad-id env/domain)
    "test-localhost-whitelabel" (init-test-localhost!)
    "hp" (init-hp!)
    nil))

Switch hacker-paradise board to less guessable id


(ns yadnd5ecs.core
  (:require [om.core :as om :include-macros true]
            [om-tools.dom :as dom :include-macros true]
            [om-tools.core :refer-macros [defcomponent]]))

(enable-console-print!)

(def app-state (atom {:text "Hello Chestnut!"}))

(defcomponent app-view
  [app owner]
  (render [_]
          (dom/h1 (:text app))))

(defn main []
  (om/root
    app-view
    app-state
    {:target (. js/document (getElementById "app"))}))

(ns yadnd5ecs.core
  (:require [om.core :as om :include-macros true]
            [om-tools.dom :as dom :include-macros true]
            [om-tools.core :refer-macros [defcomponent]]))

(enable-console-print!)

(def app-state (atom {:name {:player "Bob"
                             :character "Bruenor"}}))

(defcomponent name-view
  [name owner]
  (render
   [_]
   (let [{:keys [player
                 character]} name]
     (dom/span
      (dom/h1 (str "Name: " player))
      (dom/h1 (str "Character: " character))))))

(defcomponent app-view
  [app owner]
  (render
   [_]
   (dom/div
    (dom/h1 (str "Hello " (-> app :name :character)
                 (when-let [name (-> app :name :player)]
                   (str " (" name ")"))
                 "!"))
    (om/build name-view (:name app)))))

(defn main []
  (om/root
    app-view
    app-state
    {:target (. js/document (getElementById "app"))}))

Add name for player and character

Add name for player and character


(ns vip.data-processor.validation.v5.hours-open
  (:require [korma.core :as korma]
            [vip.data-processor.db.postgres :as postgres]
            [vip.data-processor.validation.v5.util :as util]))

(defn valid-time-with-zone? [time]
  (re-matches
   #"(?:(?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]|(?:24:00:00))(?:Z|[+-](?:(?:0[0-9]|1[0-3]):[0-5][0-9]|14:00))"
   time))

(defn validate-times [{:keys [import-id] :as ctx}]
  (let [hours-open-path "VipObject.0.HoursOpen.*{1}.Schedule.*{1}.Hours.*{1}"
        start-times (util/select-path import-id
                                      (str hours-open-path ".StartTime.*{1}"))
        end-times (util/select-path import-id
                                    (str hours-open-path ".EndTime.*{1}"))
        invalid-times #(remove (comp valid-time-with-zone? :value) %)
        invalid-start-times (invalid-times start-times)
        invalid-end-times (invalid-times end-times)]
    (reduce (fn [ctx row]
              (update-in ctx
                         [:errors :hours-open (-> row :path .getValue) :format]
                         conj (:value row)))
            ctx (concat invalid-start-times invalid-end-times))))

(ns vip.data-processor.validation.v5.hours-open
  (:require [vip.data-processor.validation.v5.util :as util]))

(defn valid-time-with-zone? [time]
  (re-matches
   #"(?:(?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]|(?:24:00:00))(?:Z|[+-](?:(?:0[0-9]|1[0-3]):[0-5][0-9]|14:00))"
   time))

(defn validate-times [{:keys [import-id] :as ctx}]
  (let [hours-open-path "VipObject.0.HoursOpen.*{1}.Schedule.*{1}.Hours.*{1}"
        start-times (util/select-path import-id
                                      (str hours-open-path ".StartTime.*{1}"))
        end-times (util/select-path import-id
                                    (str hours-open-path ".EndTime.*{1}"))
        invalid-times #(remove (comp valid-time-with-zone? :value) %)
        invalid-start-times (invalid-times start-times)
        invalid-end-times (invalid-times end-times)]
    (reduce (fn [ctx row]
              (update-in ctx
                         [:errors :hours-open (-> row :path .getValue) :format]
                         conj (:value row)))
            ctx (concat invalid-start-times invalid-end-times))))

Remove vestigial reqs from hours-open validation


(ns decktouch.card-data)

(defn get-card-list-from-storage []
  "Get the list of cards from localStorage, or [] if it is empty"
  (let [key "card-list"
        list (.getItem js/localStorage key)]
    (do
      (.log js/console key list)
      (if (undefined? list)
        []
        (.parse (js/JSON))))))

(def cards [])

(ns decktouch.card-data)

(defn get-card-list-from-storage []
  "Get the list of cards from localStorage, or [] if it is empty"
  (let [key "card-list"
        list (.getItem js/localStorage key)]
    (if (undefined? list)
      []
      (map (fn [n] {:name n}) (js->clj (.parse js/JSON list))))))

(def cards (get-card-list-from-storage))

Fix fn that loads cards from local storage


(defproject metrics-clojure-ring "2.1.0-SNAPSHOT"
  :description "Various things gluing together metrics-clojure and ring."
  :dependencies [[cheshire "5.3.1"]
                 [metrics-clojure "2.0.0"]]
  :profiles {:dev {:dependencies [[ring "1.2.2"]]}})

(defproject metrics-clojure-ring "2.1.1-SNAPSHOT"
  :description "Various things gluing together metrics-clojure and ring."
  :dependencies [[cheshire "5.3.1"]
                 [metrics-clojure "2.0.0"]]
  :profiles {:dev {:dependencies [[ring "1.2.2"]]}})

Increment version number to 2.1.1

Increment version number to 2.1.1


(ns graphql-clj.validator.transformations.inline-types
  "Inline field and parent field types for execution phase"
  (:require [graphql-clj.visitor :as v]
            [graphql-clj.spec :as spec]
            [clojure.spec :as s]
            [graphql-clj.box :as box]))

(defn- of-kind [{:keys [kind required inner-type]} s]
  (if (:type-name inner-type)
    (let [base (spec/get-type-node (spec/named-spec s [(:type-name inner-type)]) s)]
      (select-keys base [:kind :required]))
    {:kind kind :required required :of-kind (of-kind inner-type s)}))

(defn- parent-type [{:keys [spec]}]
  (if-let [base-spec (s/get-spec spec)]
    (if (keyword? base-spec) base-spec spec)
    spec))

(def whitelisted-keys
  #{:v/parentk :node-type :selection-set :type-name :field-name :name :args-fn :kind :of-kind :required :parent-type-name})

(declare inline-types)
(v/defnodevisitor inline-types :post :field
  [{:keys [field-name parent-type-name spec v/path v/parent] :as n} {:keys [resolver] :as s}]
  {:node (cond-> (select-keys n whitelisted-keys)
                 parent-type-name (assoc :parent-type-name (box/box->val parent-type-name))
                 resolver (assoc :resolver-fn (resolver parent-type-name field-name)))})

(def rules [inline-types])

(ns graphql-clj.validator.transformations.inline-types
  "Inline field and parent field types for execution phase"
  (:require [graphql-clj.visitor :as v]
            [graphql-clj.box :as box]))

(def whitelisted-keys
  #{:v/parentk :node-type :selection-set :type-name :field-name :name :args-fn :kind :of-kind :required :parent-type-name})

(declare inline-types)
(v/defnodevisitor inline-types :post :field
  [{:keys [field-name parent-type-name spec v/path v/parent] :as n} {:keys [resolver] :as s}]
  {:node (cond-> (select-keys n whitelisted-keys)
                 parent-type-name (assoc :parent-type-name (box/box->val parent-type-name))
                 resolver (assoc :resolver-fn (resolver parent-type-name field-name)))})

(def rules [inline-types])

Remove unused functions from inline types


(ns uxbox.core
  (:require-macros [uxbox.util.syntax :refer [define-once]])
  (:require [beicon.core :as rx]
            [cats.labs.lens :as l]
            [uxbox.state :as st]
            [uxbox.router :as rt]
            [uxbox.rstore :as rs]
            [uxbox.ui :as ui]
            [uxbox.data.load :as dl]))

(enable-console-print!)

(defn- main
  []
  (let [lens (l/select-keys [:pages-by-id
                             :shapes-by-id
                             :colors-by-id
                             :projects-by-id])
        stream (->> (l/focus-atom lens st/state)
                    (rx/from-atom)
                    (rx/dedupe)
                    (rx/debounce 1000)
                    (rx/tap #(println "[save]")))]
    (rx/on-value stream #(dl/persist-state %))))

(define-once :setup
  (println "bootstrap")
  (st/init)
  (rt/init)
  (ui/init)

  (rs/emit! (dl/load-data))

  ;; During development, you can comment the
  ;; following call for disable temprary the
  ;; local persistence.
  (main))

(ns uxbox.core
  (:require-macros [uxbox.util.syntax :refer [define-once]])
  (:require [beicon.core :as rx]
            [cats.labs.lens :as l]
            [uxbox.state :as st]
            [uxbox.router :as rt]
            [uxbox.rstore :as rs]
            [uxbox.ui :as ui]
            [uxbox.data.load :as dl]))

(enable-console-print!)

(def ^:const ^:private +persistent-keys+
  [:auth
   :pages-by-id
   :shapes-by-id
   :colors-by-id
   :projects-by-id])

(defn- main
  []
  (let [lens (l/select-keys +persistent-keys+)
        stream (->> (l/focus-atom lens st/state)
                    (rx/from-atom)
                    (rx/dedupe)
                    (rx/debounce 1000)
                    (rx/tap #(println "[save]")))]
    (rx/on-value stream #(dl/persist-state %))))

(define-once :setup
  (println "bootstrap")
  (st/init)
  (rt/init)
  (ui/init)

  (rs/emit! (dl/load-data))

  ;; During development, you can comment the
  ;; following call for disable temprary the
  ;; local persistence.
  (main))

Add auth to the persistente vector.

Add auth to the persistente vector.

With minor mostly cosmetic changes in the ns.


(ns incise.parsers.html
  (:require [incise.parsers.helpers :as help]
            [incise.parsers.core :refer [map->Parse]]
            [clojure.edn :as edn]
            [clojure.string :as s]
            [clojure.java.io :refer [reader]])
  (:import [java.io File]))

(defn File->Parse
  [to-html ^File file]
  (let [file-str (slurp file)
        parse-meta (edn/read-string file-str)
        content (to-html (second (s/split file-str #"\}" 2)))]
    (map->Parse (assoc parse-meta
                       :extension "/index.html"
                       :content content))))

(defn write-Parse
  [^incise.parsers.core.Parse parse-data]
  (spit (str "resources/public/" (help/Parse->path parse-data))))

(defn html-parser
  "Take a function that parses a string into HTML and returns an HTML parser.

   An HTML parser is a function which takes a file, reads it and writes it out
   as html to the proper place under public. If it is a page it should appear at
   the root, if it is a post it will be placed under a directory strucutre based
   on its date."
  [to-html]
  (comp write-Parse (partial File->Parse to-html)))

(ns incise.parsers.html
  (:require (incise.parsers [helpers :as help]
                            [core :refer [map->Parse]])
            [incise.layouts.core :refer [Parse->string]]
            [clojure.edn :as edn]
            [clojure.string :as s]
            [clojure.java.io :refer [reader]])
  (:import [java.io File]))

(defn File->Parse
  [to-html ^File file]
  (let [file-str (slurp file)
        parse-meta (edn/read-string file-str)
        content (to-html (second (s/split file-str #"\}" 2)))]
    (map->Parse (assoc parse-meta
                       :extension "/index.html"
                       :content content))))

(defn write-Parse
  [^incise.parsers.core.Parse parse-data]
  (let [file-path (File. (str "resources/public/"
                              (help/Parse->path parse-data)))]
    (-> file-path
        (.getParentFile)
        (.mkdirs))
    (spit file-path (Parse->string parse-data))))

(defn html-parser
  "Take a function that parses a string into HTML and returns an HTML parser.

   An HTML parser is a function which takes a file, reads it and writes it out
   as html to the proper place under public. If it is a page it should appear at
   the root, if it is a post it will be placed under a directory strucutre based
   on its date."
  [to-html]
  (comp write-Parse (partial File->Parse to-html)))

Make directory structure in write-Parse.


(defproject onyx-app/lein-template "0.13.4.0"
  :description "Onyx Leiningen application template"
  :url "https://github.com/onyx-platform/onyx-template"
  :license {:name "MIT License"
            :url "http://choosealicense.com/licenses/mit/#"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :plugins [[lein-set-version "0.4.1"]]
  :profiles {:dev {:plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}}
  :eval-in-leiningen true)

(defproject onyx-app/lein-template "0.13.4.1-SNAPSHOT"
  :description "Onyx Leiningen application template"
  :url "https://github.com/onyx-platform/onyx-template"
  :license {:name "MIT License"
            :url "http://choosealicense.com/licenses/mit/#"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :plugins [[lein-set-version "0.4.1"]]
  :profiles {:dev {:plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}}
  :eval-in-leiningen true)

Prepare for next release cycle.

Prepare for next release cycle.


(defproject org.onyxplatform/onyx-datomic "0.10.0.0-alpha5"
  :description "Onyx plugin for Datomic"
  :url "https://github.com/onyx-platform/onyx-datomic"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :dependencies [[org.clojure/clojure "1.8.0"]
                 ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}}
                 [org.onyxplatform/onyx "0.10.0-alpha5"]]
  :test-selectors {:default (complement :ci)
                   :ci :ci
                   :all (constantly true)}
  :profiles {:dev {:dependencies [[com.datomic/datomic-free "0.9.5544"]
                                  [aero "0.2.0"]]
                   :plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]
                   :resource-paths ["test-resources/"]}
             :circle-ci {:jvm-opts ["-Xmx4g"]}})

(defproject org.onyxplatform/onyx-datomic "0.10.0.0-SNAPSHOT"
  :description "Onyx plugin for Datomic"
  :url "https://github.com/onyx-platform/onyx-datomic"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :dependencies [[org.clojure/clojure "1.8.0"]
                 ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}}
                 [org.onyxplatform/onyx "0.10.0-alpha5"]]
  :test-selectors {:default (complement :ci)
                   :ci :ci
                   :all (constantly true)}
  :profiles {:dev {:dependencies [[com.datomic/datomic-free "0.9.5544"]
                                  [aero "0.2.0"]]
                   :plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]
                   :resource-paths ["test-resources/"]}
             :circle-ci {:jvm-opts ["-Xmx4g"]}})

Prepare for next release cycle.

Prepare for next release cycle.


(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-20150821_215046-g67feccf"]
                 [clj-kafka "0.2.8-0.8.1.1" :exclusions [org.apache.zookeeper/zookeeper zookeeper-clj]]
                 [cheshire "5.4.0"]
                 [zookeeper-clj "0.9.1" :exclusions [io.netty/netty org.apache.zookeeper/zookeeper]]]
  :profiles {:dev {:dependencies [[midje "1.7.0" :exclusions [commons-codec]]]
                   :plugins [[lein-midje "3.1.3"]]}
             :circle-ci {:jvm-opts ["-Xmx4g"]}})

Test commit from CircleCI box.

Test commit from CircleCI box. [ci skip]


(ns comic-reader.scrolling
  (:require [re-frame.core :as rf]))

(defn throttle [type key target]
  (let [target (or target js/window)
        running (atom false)
        toggle! #(swap! running not)
        throttler (fn []
                    (when (not @running)
                      (toggle!)
                      (js/requestAnimationFrame
                       (fn []
                         (rf/dispatch [key])
                         (toggle!)))))]
    (.addEventListener target type throttler)))

(defn setup-scrolling-events! []
  (throttle "scroll" :scroll))

(ns comic-reader.scrolling
  (:require [re-frame.core :as rf]))

(defn throttle [type key & [target]]
  (let [target (or target js/window)
        running (atom false)
        toggle! #(swap! running not)
        throttler (fn []
                    (when (not @running)
                      (toggle!)
                      (js/requestAnimationFrame
                       (fn []
                         (rf/dispatch [key])
                         (toggle!)))))]
    (.addEventListener target type throttler)))

(defn setup-scrolling-events! []
  (throttle "scroll" :scroll))

Make the target optional for throttle

Make the target optional for throttle


{:user
  {:plugins [;;Try new api quickly using the repl
             ;;[lein-try "0.4.3"]

             ;;=> https://github.com/kumarshantanu/lein-localrepo
             ;;[lein-localrepo "0.5.4"]

             ;;Convert pom.xml to project.clj
             ;;[lein-nevam "0.1.2"]

             ;;A Leiningen plugin for a superior development environment
             ;;[Introduction Blog Post](https://blog.venanti.us/ultra/)
             ;;=> https://github.com/venantius/ultra
             ;;[venantius/ultra "0.5.2"]

             ;;=> Pretty-print a representation of the project map
             [lein-pprint "1.2.0"]

             ;;=> https://github.com/pallet/alembic
             [com.palletops/lein-shorthand "0.4.0"]]
   :shorthand {. [alembic.still/distill alembic.still/lein]}
   :dependencies [[alembic "0.3.2"]
                  [pjstadig/humane-test-output "0.8.3"]]

   :injections [(require 'pjstadig.humane-test-output)
                (pjstadig.humane-test-output/activate!)]}}

{:user
  {:plugins [[lein-localrepo "0.5.4"] ;; https://github.com/kumarshantanu/lein-localrepo
             [lein-nevam "0.1.2"]     ;; Convert pom.xml to project.clj
             [lein-pprint "1.2.0"]]   ;; Pretty-print a representation of the project map
   :dependencies [[alembic "0.3.2"]
                  [pjstadig/humane-test-output "0.8.3"]]
   :injections [(require 'pjstadig.humane-test-output)
                (pjstadig.humane-test-output/activate!)]}}

Remove ultra as it gives some nrepl error


(ns app
  (:require [ajax.core :refer [GET]]
            [domina :refer [by-id set-text!]]
            [domina.css :refer [sel]]
            [domina.events :refer [listen!]]
            [lively.core :as lively]))

(lively/start "/js/app.js" {:on-reload #(.log js/console "Reloaded!")})

(defn set-result! [result]
  (set-text! (by-id "result") result))

(defn ping []
  (GET "http://localhost:8080/ping" {:handler #(set-result! %)}))

(listen! (sel "button") :click #(ping))

(ns app
  (:require-macros [cljs.core.async.macros :refer [go]])
  (:require [ajax.core :refer [GET]]
            [domina :refer [by-id set-text!]]
            [domina.css :refer [sel]]
            [domina.events :refer [listen!]]
            [cljs.core.async :as async :refer [<! >!]]
            [lively.core :as lively]))

;(lively/start "/js/app.js" {:on-reload #(.log js/console "Reloaded!")})

(def c (async/chan))

(defn set-result! [result]
  (set-text! (by-id "result") result))

(defn ping []
  (GET "http://localhost:8080/ping" {:handler #(go (>! c %))}))

(listen! (sel "button") :click #(ping))

(go
  (while true
    (let [result (<! c)]
      (set-result! result))))

Add core.async to Clojurescript example

Add core.async to Clojurescript example


(ns useful.io
  (:use [clojure.java.io :only [reader]])
  (:import (java.io Reader PushbackReader)))

(defprotocol PushbackFactory
  (^{:added "1.4"} pushback-reader [x] "Creates a PushbackReader from an object."))

(extend-protocol PushbackFactory
  PushbackReader
  (pushback-reader [this]
    this)

  Reader
  (pushback-reader [this]
    (PushbackReader. this))

  Object
  (pushback-reader [this]
    (pushback-reader (reader this))))

(let [sentinel (Object.)
      valid? #(not (identical? % sentinel))]
  (defn read-seq
    "Read a lazy sequence of Clojure forms from an input reader."
    [in]
    (let [in (pushback-reader in)]
      (take-while valid?
                  (repeatedly #(read in false sentinel))))))

(ns useful.io
  (:use [clojure.java.io :only [reader]]
        [useful.ns :only [defalias]])
  (:import (java.io Reader PushbackReader)))

(defprotocol PushbackFactory
  (^{:added "1.4"} pushback-reader [x] "Creates a PushbackReader from an object."))

(extend-protocol PushbackFactory
  PushbackReader
  (pushback-reader [this]
    this)

  Reader
  (pushback-reader [this]
    (PushbackReader. this))

  Object
  (pushback-reader [this]
    (pushback-reader (reader this))))

(defalias pbr pushback-reader)

(let [sentinel (Object.)
      valid? #(not (identical? % sentinel))]
  (defn read-seq
    "Read a lazy sequence of Clojure forms from an input reader."
    [in]
    (let [in (pushback-reader in)]
      (take-while valid?
                  (repeatedly #(read in false sentinel))))))

Add pbr as alias to pushback-reader. Best name ever.


 (ns silly-image-store.handler
  (:require [silly-image-store.store :as store]
            [environ.core :refer [env]]
            [compojure.core :refer :all]
            [ring.middleware.json :refer :all]
            [compojure.handler :as handler]
            [compojure.route :as route]))

(def images-dir
  (env :base-store-dir))

(defn image-not-found [image]
  (route/not-found (str "No image '" image "' found")))

; TODO refactor links stuff
(defn list-images [{scheme :scheme, {host "host"} :headers}]
  (let [image-names (store/list-images images-dir)
        base-url (str (name scheme) "://" host "/images/")
        to-json (fn [n] {:name n :link (str base-url n)})]
    (map to-json image-names)))

(defn serve-image [image]
  (let [image-file (store/load-image images-dir image)]
    (or image-file (image-not-found image))))

(defroutes app-routes
  (GET "/images" request list-images)
  (GET "/images/:image" [image] (serve-image image)) ; TODO handler as list-image
  (route/resources "/")
  (route/not-found "Not Found"))

(def app
  (-> (handler/site app-routes)
      (wrap-json-response)))

 (ns silly-image-store.handler
  (:require [silly-image-store.store :as store]
            [environ.core :refer [env]]
            [compojure.core :refer :all]
            [ring.middleware.json :refer :all]
            [compojure.handler :as handler]
            [compojure.route :as route]))

(def images-dir
  (env :base-store-dir))

(defn image-not-found [image]
  (route/not-found (str "No image '" image "' found")))

; TODO refactor links stuff
(defn- list-images-route [{scheme :scheme, {host "host"} :headers}]
  (let [image-names (store/list-images images-dir)
        base-url (str (name scheme) "://" host "/images/")
        to-json (fn [n] {:name n :link (str base-url n)})]
    (map to-json image-names)))

(defn- serve-image-route [{{image :image} :params}]
  (let [image-file (store/load-image images-dir image)]
    (or image-file (image-not-found image))))

(defroutes app-routes
  (GET "/images" request list-images-route)
  (GET "/images/:image" request serve-image-route)
  (route/resources "/")
  (route/not-found "Not Found"))

(def app
  (-> (handler/site app-routes)
      (wrap-json-response)))

Change serve image route fn to handle request


;; Copyright © 2014-2017, JUXT LTD.

(def VERSION "1.3.0-alpha4")

(defproject yada VERSION
  :description "A complete batteries-included bundle of yada"
  :license {:name "The MIT License"
            :url "https://opensource.org/licenses/MIT"}
  :pedantic? :abort

  :dependencies [[yada/aleph ~VERSION]
                 [yada/async ~VERSION]
                 [yada/bidi ~VERSION]
                 [yada/core ~VERSION]
                 [yada/json ~VERSION]
                 [yada/json-html ~VERSION]
                 [yada/jwt ~VERSION]
                 [yada/multipart ~VERSION]
                 [yada/oauth2 ~VERSION]
                 [yada/swagger ~VERSION]
                 [yada/transit ~VERSION]
                 [yada/webjars ~VERSION]]

  :profiles {:test {:dependencies [[org.clojure/clojure "1.8.0"]
                                   [org.webjars/bootstrap "3.3.6"]]}})

;; Copyright © 2014-2017, JUXT LTD.

(def VERSION "1.3.0-alpha4")

(defproject yada VERSION
  :description "A complete batteries-included bundle of yada"
  :license {:name "The MIT License"
            :url "https://opensource.org/licenses/MIT"}
  :pedantic? :abort

  :dependencies [[yada/aleph ~VERSION]
                 [yada/async ~VERSION]
                 [yada/bidi ~VERSION]
                 [yada/core ~VERSION]
                 [yada/json ~VERSION]
                 [yada/json-html ~VERSION]
                 [yada/jwt ~VERSION]
                 [yada/multipart ~VERSION]
                 [yada/oauth2 ~VERSION]
                 [yada/swagger ~VERSION :exclusions [clj-time]]
                 [yada/transit ~VERSION]
                 [yada/webjars ~VERSION]]

  :profiles {:test {:dependencies [[org.clojure/clojure "1.8.0"]
                                   [org.webjars/bootstrap "3.3.6"]]}})

Fix abort issue due to dependency conflict


(ns com.frereth.server.logging
  (require [com.postspectacular.rotor :as rotor]
           [com.stuartsierra.component :as component]
           [taoensso.timbre :as log
            :refer (trace debug info warn error fatal spy with-log-level)]))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Schema

(defrecord Logger []
  component/Lifecycle

  (start
    [this]
    (log/set-config!
     [:appenders :rotor]
     {:doc "Writes to (:path (:rotor :shared-appender-config)) file and creates optional backups"
      :min-level :trace
      :enabled? true
      :async? false
      :max-message-per-msecs nil
      :fn rotor/append})
    (log/set-config!
     [:shared-appender-config :rotor]
     {:path "logs/app.log" :max-size (* 512 1024) :backlog 5})
    (log/warn "FIXME: Log to a database instead")
    this)

  (stop
    [this]
    this))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Public

(defn ctor
  [_]
  (->Logger))

(ns com.frereth.server.logging
  (require [com.stuartsierra.component :as component]
           [taoensso.timbre :as log
            :refer (trace debug info warn error fatal spy with-log-level)]
           [taoensso.timbre.appenders.3rd-party.rotor :as rotor]))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Schema

(defrecord Logger []
  component/Lifecycle

  (start
    [this]
    (log/merge-config!
     {:appenders {:rotor (rotor/rotor-appender {:path "logs/app.log"
                                                :max-size (* 512 1024)
                                                :backlog 5})}})
    (log/warn "FIXME: Log to a database instead")
    this)

  (stop
    [this]
    this))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Public

(defn ctor
  [_]
  (->Logger))

Update to new log rotor

Update to new log rotor


(ns oc.storage.resources.reaction)

(defn- reaction-collapse
  "Reducer function that collapses reactions into count and sequence of author based on common reaction unicode."
  [reactions reaction]
  (let [unicode (:reaction reaction)
        author (-> reaction :author :name)
        author-id (-> reaction :author :user-id)]
    (if-let [existing-reaction (reactions unicode)]
      ;; have this unicode already, so add this reaction to it
      (assoc reactions unicode (-> existing-reaction
                                  (update :count inc)
                                  (update :authors #(conj % author))
                                  (update :author-ids #(conj % author-id))))
      ;; haven't seen this reaction unicode before, so init a new one
      (assoc reactions unicode {:reaction unicode :count 1 :authors [author] :author-ids [author-id]}))))

(defn aggregate-reactions
  "
  Given a sequence of individual reaction interactions, collapse it down to a set of distinct reactions
  that include the count of how many times reacted and the list of author names and IDs that reacted.
  "
  [entry-reactions]
  (or (vals (reduce reaction-collapse {} (map #(assoc % :count 1) entry-reactions))) []))

(ns oc.storage.resources.reaction)

(defn- reaction-collapse
  "Reducer function that collapses reactions into count and sequence of author based on common reaction unicode."
  [reactions reaction]
  (let [unicode (:reaction reaction)
        author (-> reaction :author :name)
        author-id (-> reaction :author :user-id)]
    (if-let [existing-reaction (reactions unicode)]
      ;; have this unicode already, so add this reaction to it
      (assoc reactions unicode (-> existing-reaction
                                  (update :count + (:count reaction))
                                  (update :authors #(remove nil? (conj % author)))
                                  (update :author-ids #(remove nil? (conj % author-id)))))
      ;; haven't seen this reaction unicode before, so init a new one
      (assoc reactions unicode {:reaction unicode
                                :count (if author 1 0)
                                :authors (remove nil? [author])
                                :author-ids (remove nil? [author-id])}))))

(defn aggregate-reactions
  "
  Given a sequence of individual reaction interactions, collapse it down to a set of distinct reactions
  that include the count of how many times reacted and the list of author names and IDs that reacted.
  "
  [entry-reactions]
  (let [fixed-entry-reactions (conj (map #(assoc % :count 1) entry-reactions) {:reaction "👍" :count 0})
        collapsed-reactions (vals (reduce reaction-collapse {} fixed-entry-reactions))]
    (or collapsed-reactions [])))

Add default thumbup rection to every entry.


(ns exploud.info
  "## For grabbing information about the things we're dealing with"
  (:require [exploud
             [asgard :as asgard]
             [onix :as onix]
             [tyranitar :as tyr]]))

(defn applications
  "The list of applications Asgard knows about."
  []
  {:names (map :name (asgard/applications))})

(defn application
  "The information about a particular application."
  [region application-name]
  (if-let [full-application (asgard/application region application-name)]
    (merge {:name application-name}
           (select-keys (:app full-application)
                        [:description :email :owner]))))

(defn upsert-application
  "Upserts an application into Onix, Tyranitar and Asgard. This function can be
   run many times, it won't fail if the application is present in any of the
   stores."
  [region application-name details]
  (let [onix-application (onix/upsert-application application-name)
        tyranitar-application (tyr/upsert-application application-name)]
    (asgard/upsert-application application-name details)
    (merge (application region application-name) tyranitar-application)))

(ns exploud.info
  "## For grabbing information about the things we're dealing with"
  (:require [exploud
             [asgard :as asgard]
             [onix :as onix]
             [tyranitar :as tyr]]))

(defn applications
  "The list of applications Onix knows about."
  []
  {:names (map :name (onix/applications))})

(defn application
  "The information about a particular application."
  [region application-name]
  (if-let [full-application (asgard/application region application-name)]
    (merge {:name application-name}
           (select-keys (:app full-application)
                        [:description :email :owner]))))

(defn upsert-application
  "Upserts an application into Onix, Tyranitar and Asgard. This function can be
   run many times, it won't fail if the application is present in any of the
   stores."
  [region application-name details]
  (let [onix-application (onix/upsert-application application-name)
        tyranitar-application (tyr/upsert-application application-name)]
    (asgard/upsert-application application-name details)
    (merge (application region application-name) tyranitar-application)))

Make Exploud list the applications from Onix


(ns discuss.config)

(def project "discuss")

(def user "Q2hyaXN0aWFu")

(def api {:host  "http://localhost:4284/"
          :init  "api/elektroautos"
          :base  "api/"
          :login "api/login"
          :add   {:add-start-statement "api/add/start_statement"
                  :add-start-premise   "api/add/start_premise"
                  :add-justify-premise "api/add/justify_premise"}
          :get   {:references       "api/get/references"
                  :reference-usages "api/get/reference/usages"
                  :statements       "api/get/statements"
                  :statement-url    "api/get/statement/url"}})

(ns discuss.config)

(def project "discuss")

(def user "Q2hyaXN0aWFu")

(def api {:host  "http://localhost:4284/"
          :init  "api/cat-or-dog"
          :base  "api/"
          :login "api/login"
          :add   {:add-start-statement "api/add/start_statement"
                  :add-start-premise   "api/add/start_premise"
                  :add-justify-premise "api/add/justify_premise"}
          :get   {:references       "api/get/references"
                  :reference-usages "api/get/reference/usages"
                  :statements       "api/get/statements"
                  :statement-url    "api/get/statement/url"}})

Set default issue to an english one

Set default issue to an english one


(ns test-fb.handler
  (:require [ring.middleware.defaults :refer (wrap-defaults site-defaults secure-site-defaults)]
            [ring.util.response :refer (not-found response)]
            [taoensso.timbre :as log]
            [clojure.string :refer (trim blank?)]
            [clojure.java.io :as io]
            ))

(defn handler [request]
  (response "hello world"))

(def app
  (-> handler
      (wrap-defaults site-defaults)))

; TODO authentication
#_(def site
  (if-let [location (get-public-files-location)]
    (do
      (log/info "Serves files from" location)
      (-> handler
          (wrap-defaults
            (assoc site-defaults :static {:files (io/as-file (io/as-url location))}))))
    (do
      (log/error public-files-location-str "not specified")
      (System/exit 1))
    ))

(ns test-fb.handler
  (:require [ring.middleware.defaults :refer (wrap-defaults site-defaults secure-site-defaults)]
            [ring.util.response :refer (not-found response content-type)]
            [taoensso.timbre :as log]
            [clojure.string :refer (trim blank?)]
            [clojure.java.io :as io]
            ))

(defn handler [request]
  (->
    (response "hello world")
    (content-type "text/plain")
    ))

(def app
  (-> handler
      (wrap-defaults site-defaults)))

; TODO authentication
#_(def site
  (if-let [location (get-public-files-location)]
    (do
      (log/info "Serves files from" location)
      (-> handler
          (wrap-defaults
            (assoc site-defaults :static {:files (io/as-file (io/as-url location))}))))
    (do
      (log/error public-files-location-str "not specified")
      (System/exit 1))
    ))

Add content type to default route

Add content type to default route


(ns advent-2017.day-06
  (:require
   #?(:cljs [planck.core :refer [slurp read-string]])
   [#?(:clj clojure.java.io :cljs planck.io) :as io]
   [clojure.string :as str]))

(def input (-> "advent_2017/day_06/input" io/resource slurp))

(def data (as-> input x (str/trim x) (str/split x #"\t") (mapv read-string x)))

(defn redistribute [banks]
  (let [max-ndx     (.indexOf banks (apply max banks))
        target-ndxs (map #(mod (+ max-ndx 1 %) (count banks))
                      (range (banks max-ndx)))]
    (merge-with + (assoc banks max-ndx 0) (frequencies target-ndxs))))

(defn solve [banks]
  (reduce (fn [[last-seen banks] steps]
            (if (last-seen banks)
              (reduced [steps (last-seen banks)])
              [(assoc last-seen banks steps) (redistribute banks)]))
    [{} banks]
    (range)))

(defn part-1 []
  (first (solve data)))

(defn part-2 []
  (apply - (solve data)))

(ns advent-2017.day-06
  (:require
   #?(:cljs [planck.core :refer [slurp read-string]])
   [#?(:clj clojure.java.io :cljs planck.io) :as io]
   [clojure.string :as str]))

(def input (-> "advent_2017/day_06/input" io/resource slurp))

(def data (as-> input x (str/trim x) (str/split x #"\t") (mapv read-string x)))

(defn redistribute [banks]
  (let [max-val     (apply max (vals banks))
        max-ndx     (apply min (keep (fn [[k v]] (when (= max-val v) k)) banks))
        target-ndxs (map #(mod (+ max-ndx 1 %) (count banks))
                      (range (banks max-ndx)))]
    (merge-with + (assoc banks max-ndx 0) (frequencies target-ndxs))))

(defn solve [banks]
  (reduce (fn [[last-seen banks] steps]
            (if (last-seen banks)
              (reduced [steps (last-seen banks)])
              [(assoc last-seen banks steps) (redistribute banks)]))
    [{} (zipmap (range) banks)]
    (range)))

(defn part-1 []
  (first (solve data)))

(defn part-2 []
  (apply - (solve data)))

Work in terms of maps so merge-with use is correct


(ns rabbitmq.tutorials.emit-log-direct
  (:require [langohr.core :as lc]
            [langohr.channel :as lch]
            [langohr.exchange :as le]
            [langohr.basic :as lb]
            [clojure.string :as s]))

(def ^{:const true} x "direct_logs")

(defn -main
  [severity & args]
  (with-open [conn (lc/connect)]
    (let [ch      (lch/open conn)
          payload (if (empty? args)
                    "Hello, world!"
                    (s/join " " args))]
      (le/direct ch x :durable false :auto-delete false)
      (lb/publish ch x severity payload)
      (println (format " [x] Sent %s" payload)))))

(ns rabbitmq.tutorials.emit-log-direct
  (:require [langohr.core :as lc]
            [langohr.channel :as lch]
            [langohr.exchange :as le]
            [langohr.basic :as lb]
            [clojure.string :as s]))

(def ^{:const true} x "direct_logs")

(defn -main
  [severity & args]
  (with-open [conn (lc/connect)]
    (let [ch      (lch/open conn)
          severity (or severity "info")
          payload  (if (empty? args)
                     "Hello, world!"
                     (s/join " " args))]
      (le/direct ch x :durable false :auto-delete false)
      (lb/publish ch x severity payload)
      (println (format " [x] Sent %s" payload)))))

Use the same default as Ruby example

Use the same default as Ruby example


(ns github-changelog.util
  (:require [clojure.string :refer [join ends-with?]]))

(defn str-map [f & sqs] (join (apply map f sqs)))

(defn extract-params [query-string]
  (into {} (for [[_ k v] (re-seq #"([^&=]+)=([^&]+)" query-string)]
             [(keyword k) v])))

(defn strip-trailing
  ([s] (strip-trailing s "/"))
  ([s end]
   (if (ends-with? s end)
     (recur (join (butlast s)) end)
     s)))

(ns github-changelog.util
  (:require [clojure.string :refer [join ends-with?]]))

(defn str-map [f & sqs] (join (apply map f sqs)))

(defn extract-params [query-string]
  (into {} (for [[_ k v] (re-seq #"([^&=]+)=([^&]+)" query-string)]
             [(keyword k) v])))

(defn strip-trailing
  ([s] (strip-trailing s "/"))
  ([s end]
   (if (ends-with? s end)
     (recur (join (drop-last s)) end)
     s)))

Use the lazy version instead

Use the lazy version instead


(defproject clstreams "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}

  :dependencies [[org.clojure/clojure "1.8.0"]
                 [org.apache.kafka/kafka-clients "0.10.1.0"]
                 [org.apache.kafka/kafka-streams "0.10.1.0"]]

  :main ^:skip-aot clstreams.core
  :target-path "target/%s"

  :profiles {:uberjar {:aot :all}})

(defproject clstreams "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}

  :dependencies [[org.clojure/clojure "1.8.0"]
                 [org.clojure/tools.namespace "0.3.0-alpha3"]

                 [org.apache.kafka/kafka-clients "0.10.1.0"]
                 [org.apache.kafka/kafka-streams "0.10.1.0"]]

  :main ^:skip-aot clstreams.core
  :target-path "target/%s"

  :profiles {:uberjar {:aot :all}})

Add tools.namespace to the dependencies.


(ns user
  "A dev namespace that supports Proto-REPL.

  It seems that Proto-REPL doesn't support the flexible approach that lein
  uses: any configurable ns can be the starting ns for a REPL. As such, this
  minimal ns was created for Proto-REPL users, so they too can have an env
  that supports startup and shutdown."
  (:require
   [cheshire.core :as json]
   [clojure.java.io :as io]
   [clojure.pprint :refer [pprint]]
   [clojure.tools.namespace.repl :as repl]
   [clojusc.system-manager.core :refer :all]
   [cmr.opendap.dev :as dev]
   [org.httpkit.client :as httpc]))

(ns user
  "A dev namespace that supports Proto-REPL.

  It seems that Proto-REPL doesn't support the flexible approach that lein
  uses: any configurable ns can be the starting ns for a REPL. As such, this
  minimal ns was created for Proto-REPL users, so they too can have an env
  that supports startup and shutdown."
  (:require
   [cheshire.core :as json]
   [clojure.java.io :as io]
   [clojure.pprint :refer [pprint]]
   [clojure.tools.namespace.repl :as repl]
   [clojusc.system-manager.core :refer :all]
   [clojusc.twig :as logger]
   [cmr.opendap.dev :as dev]
   [org.httpkit.client :as httpc]))

(logger/set-level! '[cmr org.httpkit] :trace logger/no-color-log-formatter)

CMR-5131: Determine OPeNDAP URL based on tag association data for a collection.


;; 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.projects
  "A main interface for access to remote resources."
  (:refer-clojure :exclude [do])
  (:require [httpurr.client.xhr :as http]
            [httpurr.status :as http.status]
            [promesa.core :as p :include-macros true]
            [beicon.core :as rx]
            [uxbox.repo.core :as urc]
            [uxbox.state :as ust]))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Login
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defmethod urc/-do :fetch/projects
  [type data]
  (urc/req! {:url (str urc/+uri+ "/projects") :method :get}))

(defmethod urc/-do :fetch/pages
  [type data]
  (urc/req! {:url (str urc/+uri+ "/pages") :method :get}))

(defmethod urc/-do :create/page
  [type {:keys [id] :as data}]
  (let [params {:url (str urc/+uri+ "/pages")
                :method :post
                :body data}]
    (urc/req! params)))

(defmethod urc/-do :update/page
  [type {:keys [id] :as data}]
  (let [params {:url (str urc/+uri+ "/pages/" id)
                :method :put
                :body data}]
    (urc/req! params)))

Add page create and update repo methods.


(ns pot.core.act
  (:require-macros [cljs.core.async.macros :refer [go alt!]])
  (:require [cljs.reader :refer [read-string]]
            [pot.core.hand :refer [move-handler undo-handler state-watcher history-watcher]]))

(def ^:private msg-handler-map
  {:move      move-handler
   :undo      undo-handler})

(defn- process-msg
  [{action-key :msg :as msg} state history]
  (let [{action-handler action-key} msg-handler-map]
    (action-handler msg state history)))

(defn listen-channels
  [state history {:keys [actions]}]
  (go (while true
        (alt!
          actions ([msg] (process-msg msg state history))))))

(defn watch-changes
  [state history storage]
  (add-watch state :state-watcher (state-watcher state history))
  (add-watch history :history-watcher (history-watcher storage :history)))

(defn restore-state
  [state history storage]
  (when-let [stored-history (.get storage :history)]
    (when-let [restored-history (read-string stored-history)]
      (when-let [restored-state (get-in restored-history [:snapshots (:cursor restored-history)])]
        (reset! state restored-state))
      (reset! history restored-history))))

(ns pot.core.act
  (:require-macros [cljs.core.async.macros :refer [go alt!]])
  (:require [cljs.reader :refer [read-string]]
            [pot.core.hand :refer [move-handler undo-handler state-watcher history-watcher]]))

(def ^:private msg-handler-map
  {:move      move-handler
   :undo      undo-handler})

(defn- process-msg
  [{action-key :msg :as msg} state history]
  (let [{action-handler action-key} msg-handler-map]
    (when action-handler
      (action-handler msg state history))))

(defn listen-channels
  [state history {:keys [actions]}]
  (go (while true
        (alt!
          actions ([msg] (process-msg msg state history))))))

(defn watch-changes
  [state history storage]
  (add-watch state :state-watcher (state-watcher state history))
  (add-watch history :history-watcher (history-watcher storage :history)))

(defn restore-state
  [state history storage]
  (when-let [stored-history (.get storage :history)]
    (when-let [restored-history (read-string stored-history)]
      (when-let [restored-state (get-in restored-history [:snapshots (:cursor restored-history)])]
        (reset! state restored-state))
      (reset! history restored-history))))

Check handler before call it

Check handler before call it


#!/usr/bin/env boot

#tailrecursion.boot.core/version "2.3.1"

(set-env!
  :dependencies  [['tailrecursion/boot.task   "2.1.2"]
                  ['tailrecursion/hoplon      "5.7.0"]
                  ['markdown-clj              "0.9.41"]
                  ['org.clojure/clojurescript "0.0-2156"]]
  :src-paths     #{"src"}
  :out-path      "resources/public")

(add-sync! (get-env :out-path) #{"resources/assets"})

(require
  ['tailrecursion.boot.task   :refer :all]
  ['tailrecursion.hoplon.boot :refer :all])

(deftask dev
  "Build hoplon.io for local development."
  []
  (comp (watch) (hoplon {:pretty-print  true
                         :prerender     false
                         :optimizations :whitespace})))

(deftask prod
  "Build hoplon.io for production deployment."
  []
  (hoplon {:optimizations :advanced}))

#!/usr/bin/env boot

#tailrecursion.boot.core/version "2.3.1"

(set-env!
  :dependencies  '[[tailrecursion/boot.task   "2.1.2"]
                   [tailrecursion/hoplon      "5.7.0"]
                   [markdown-clj              "0.9.41"]
                   [tailrecursion/boot.ring   "0.1.0-SNAPSHOT"]
                   [org.clojure/clojurescript "0.0-2156"]]
  :src-paths     #{"src"}
  :out-path      "resources/public")

(add-sync! (get-env :out-path) #{"resources/assets"})

(require
  '[tailrecursion.boot.task   :refer :all]
  '[tailrecursion.boot.task.ring   :refer [dev-server]]
  '[tailrecursion.hoplon.boot :refer :all])

(deftask dev
  "Build hoplon.io for local development."
  []
  (comp (watch) (hoplon {:pretty-print  true
                         :prerender     false
                         :optimizations :whitespace}) (dev-server)))

(deftask prod
  "Build hoplon.io for production deployment."
  []
  (hoplon {:optimizations :advanced}))

Add dev-server to stop Hyphenator errors


{:user {:dependencies [[clj-stacktrace "0.2.5"]
                       [spyscope "0.1.0"]
                       [limit-break "0.1.0-SNAPSHOT"]]
        :plugins [[lein-difftest "1.3.7"]
                  [lein-drip "0.1.1-SNAPSHOT"]
                  [lein-clojars "0.9.1"]
                  [lein-pprint "1.1.1"]
                  [lein-ring "0.8.0"]
                  [slamhound "1.3.1"]
                  [lein-cljsbuild "0.1.9"]
                  [lein-deps-tree "0.1.2"]
                  [lein-marginalia "0.7.1"]]
        :repl-options {:timeout 120000}
        :injections [(let [orig (ns-resolve (doto 'clojure.stacktrace require)
                                            'print-cause-trace)
                           new (ns-resolve (doto 'clj-stacktrace.repl require)
                                           'pst)]
                       (alter-var-root orig (constantly @new)))]
        :vimclojure-opts {:repl true}}}

{:user {:dependencies [[clj-stacktrace "0.2.5"]
                       [spyscope "0.1.2"]
                       [limit-break "0.1.0-SNAPSHOT"]]
        :plugins [[lein-difftest "1.3.7"]
                  [lein-drip "0.1.1-SNAPSHOT"]
                  [lein-clojars "0.9.1"]
                  [lein-pprint "1.1.1"]
                  [lein-ring "0.8.0"]
                  [slamhound "1.3.1"]
                  [lein-cljsbuild "0.1.9"]
                  [lein-deps-tree "0.1.2"]
                  [lein-marginalia "0.7.1"]]
        :repl-options {:timeout 120000}
        :injections [(require 'spyscope.core)
                     (let [orig (ns-resolve (doto 'clojure.stacktrace require)
                                            'print-cause-trace)
                           new (ns-resolve (doto 'clj-stacktrace.repl require)
                                           'pst)]
                       (alter-var-root orig (constantly @new)))]
        :vimclojure-opts {:repl true}}}

Fix spyscope dependency. Add its injection.


(ns
  ^{:doc

  "Dispatching Input Events of a SimRunner Application."

    :author "Frank Mosebach"}
  fm.simrunner.input
  (:require
    [fm.simrunner.config :as cfg]))

(defmulti on-input {:private true} (fn [id & _] id))

(defmethod on-input :default [id app & args]
  (println (format "on-input{id: %s args: %s}" id args)))

(defn- handle-input? [{app-state :state}]
  (let [{ui :ui} @app-state]
    (and (not (:locked? ui))
         (not (:rendering? ui)))))

(defn dispatch [id app args]
  (when (handle-input? app)
    (apply on-input id app args)))

(ns
  ^{:doc

  "Dispatching Input Events of a SimRunner Application."

    :author "Frank Mosebach"}
  fm.simrunner.input
  (:require
    [fm.simrunner.config :as cfg]))

(defn- value->param [id value]
  (if (= :calc-err id)
    (if value "1" "0")
    (str value)))

(defn- update-values [app-state id value]
  (assoc-in app-state [:ui :model :values id] value))

(defn- update-config [app-state id value]
  (let [config (-> (get-in app-state [:model :config])
                   (cfg/with-value id (value->param id value)))]
    (-> app-state
        (assoc-in [:model :config] config)
        (assoc-in [:model :changed?] true)
        (assoc-in [:model :valid?] (cfg/complete? config)))))

(defn- on-input [id {app-state :state} & [widget value :as args]]
  (println (format "on-input{id: %s value: %s}" id value))
  (swap! app-state
         (fn [app-state]
           (-> app-state
               (update-values id value)
               (update-config id value)))))

(defn- handle-input? [{app-state :state}]
  (let [{ui :ui} @app-state]
    (and (not (:locked? ui))
         (not (:rendering? ui)))))

(defn dispatch [id app args]
  (when (handle-input? app)
    (apply on-input id app args)))

Update the app's model according to incoming events.


;; https://github.com/technomancy/leiningen/blob/stable/doc/PROFILES.md
{:user
 {:plugins
  [[cider/cider-nrepl "0.27.2"]
   [lein-ancient "1.0.0-RC3"]
   [lein-check-namespace-decls "1.0.4"]
   [lein-cljfmt "0.8.0"]
   [lein-nsorg "0.3.0"]
   [nrepl "0.9.0-beta3"]
   [refactor-nrepl "3.0.0-alpha13"]]}
  :dependencies
   [#_[alembic "0.3.2"]
    [clj-kondo "RELEASE"]
    [antq "RELEASE"]
    [vvvvalvalval/scope-capture "0.3.2"]]
  :injections [(require 'sc.api)]
  :aliases {"clj-kondo" ["run" "-m" "clj-kondo.main"]
            "outdated"  ["run" "-m" "antq.core"]}}

;; https://github.com/technomancy/leiningen/blob/stable/doc/PROFILES.md
{:user
 {:plugins
  [[cider/cider-nrepl "0.27.4"]
   [lein-ancient "1.0.0-RC3"]
   [lein-check-namespace-decls "1.0.4"]
   [lein-cljfmt "0.8.0"]
   [lein-nsorg "0.3.0"]
   [nrepl "0.9.0"]
   [refactor-nrepl "3.1.0"]]}
  :dependencies
   [#_[alembic "0.3.2"]
    [clj-kondo "RELEASE"]
    [antq "RELEASE"]
    [vvvvalvalval/scope-capture "0.3.2"]]
  :injections [(require 'sc.api)]
  :aliases {"clj-kondo" ["run" "-m" "clj-kondo.main"]
            "outdated"  ["run" "-m" "antq.core"]}}

Update config for Clojure projects

Update config for Clojure projects


(ns cmr.common.test.cache
  (:require [clojure.test :refer :all]
            [cmr.common.cache :as c]))

(def counter (atom 0))

(defn increment-counter
  "Increments the counter atom and returns it"
  []
  (swap! counter inc))

(deftest cache-test
  (testing "cache hit, miss and reset"
    (let [cache-atom (c/create-cache)]
      (is (= 1 (c/cache-lookup cache-atom "key" increment-counter)))
      ;; look up again will not call the increment-counter function
      (is (= 1 (c/cache-lookup cache-atom "key" increment-counter)))
      (c/reset-cache cache-atom)
      (is (= 2 (c/cache-lookup cache-atom "key" increment-counter)))
      (is (= 2 (c/cache-lookup cache-atom "key" increment-counter))))))

(ns cmr.common.test.cache
  (:require [clojure.test :refer :all]
            [cmr.common.cache :as c]))

(def counter (atom 0))

(defn increment-counter
  "Increments the counter atom and returns it"
  []
  (swap! counter inc))

(deftest cache-test
  (testing "cache hit, miss and reset"
    (let [cache-atom (c/create-cache)]
      (reset! counter 0)
      (is (= 1 (c/cache-lookup cache-atom "key" increment-counter)))
      ;; look up again will not call the increment-counter function
      (is (= 1 (c/cache-lookup cache-atom "key" increment-counter)))
      (c/reset-cache cache-atom)
      (is (= 2 (c/cache-lookup cache-atom "key" increment-counter)))
      (is (= 2 (c/cache-lookup cache-atom "key" increment-counter))))))

Reset counter so the test can be run multiple times in repl.


(ns pro.juxt.edge.doc-site
  (:require
    [integrant.core :as ig]
    [clojure.java.io :as io]
    [edge.asciidoctor :refer [load-doc]]
    [yada.yada :as yada]))

(defn routes [engine]
  [["" (merge
         (yada/redirect ::doc-resource {:route-params {:name "index"}})
         {:id ::doc-index})]
   [[:name ".html"]
    (yada/resource
      {:id ::doc-resource
       :methods
       {:get
        {:produces [{:media-type "text/html;q=0.8" :charset "utf-8"}
                    {:media-type "application/json"}]
         :response (fn [ctx]
                     (let [path (str "doc/sources/" (-> ctx :parameters :path :name) ".adoc")]
                       (try
                         (.convert
                           (load-doc
                             ctx
                             engine
                             (-> ctx :parameters :path :name)
                             (slurp (io/resource path))))
                         (catch Exception e
                           (throw (ex-info (format "Failed to convert %s" path)
                                           {:path path} e))))))}}})]])

(defmethod ig/init-key ::routes [_ {:keys [edge.asciidoctor/engine]}]
  (routes engine))

(ns pro.juxt.edge.doc-site
  (:require
    [integrant.core :as ig]
    [clojure.java.io :as io]
    [edge.asciidoctor :refer [load-doc]]
    [yada.yada :as yada]))

(defn routes [engine]
  [["" (merge
         (yada/redirect ::doc-resource {:route-params {:name "index"}})
         {:id ::doc-index})]
   [[;; regex derived from bidi's default, but adding / to allow directories
     [#"[A-Za-z0-9\\-\\_\\.\/]+" :name] ".html"]
    (yada/resource
      {:id ::doc-resource
       :methods
       {:get
        {:produces [{:media-type "text/html;q=0.8" :charset "utf-8"}
                    {:media-type "application/json"}]
         :response (fn [ctx]
                     (let [path (str "doc/sources/" (-> ctx :parameters :path :name) ".adoc")]
                       (try
                         (.convert
                           (load-doc
                             ctx
                             engine
                             (-> ctx :parameters :path :name)
                             (slurp (io/resource path))))
                         (catch Exception e
                           (throw (ex-info (format "Failed to convert %s" path)
                                           {:path path} e))))))}}})]])

(defmethod ig/init-key ::routes [_ {:keys [edge.asciidoctor/engine]}]
  (routes engine))

Add support for nested directories to doc-site


(ns klangmeister.processing
  (:require
    [klangmeister.eval :as eval]
    [klangmeister.music :as music]
    [klangmeister.instruments :as instrument]
    [klangmeister.actions :as action]
    [klangmeister.framework :as framework]
    [cljs.js :as cljs]))

(extend-protocol framework/Action
  action/Refresh
  (process [{expr-str :text} _ {original-music :music :as state}]
    (let [{:keys [value error]} (eval/uate expr-str)
          music (or value original-music)]
      (-> state
          (assoc :error error)
          (assoc :text expr-str)
          (assoc :music music))))

  action/Stop
  (process [_ handle! state]
    (assoc state :looping? false))

  action/Play
  (process [this handle! state]
    (framework/process (action/->Loop) handle! (assoc state :looping? true)))

  action/Loop
  (process [this handle! {notes :music :as state}]
    (when (:looping? state)
      (music/play-on! instrument/beep! notes)
      (let [duration (->> notes (map :duration) (reduce +) (* 1000))]
        (js/setTimeout #(handle! this) duration)))
    state))

(ns klangmeister.processing
  (:require
    [klangmeister.eval :as eval]
    [klangmeister.music :as music]
    [klangmeister.instruments :as instrument]
    [klangmeister.actions :as action]
    [klangmeister.framework :as framework]
    [cljs.js :as cljs]))

(extend-protocol framework/Action
  action/Refresh
  (process [{expr-str :text} _ {original-music :music :as state}]
    (let [{:keys [value error]} (eval/uate expr-str)
          music (or value original-music)]
      (-> state
          (assoc :error error)
          (assoc :text expr-str)
          (assoc :music music))))

  action/Stop
  (process [_ handle! state]
    (assoc state :looping? false))

  action/Play
  (process [this handle! state]
    (framework/process (action/->Loop) handle! (assoc state :looping? true)))

  action/Loop
  (process [this handle! {notes :music :as state}]
    (when (:looping? state)
      (music/play-on! instrument/beep! notes)
      (let [duration (->> notes
                          (map (fn [{:keys [time duration]}] (+ time duration)))
                          (apply max)
                          (* 1000))]
        (js/setTimeout #(handle! this) duration)))
    state))

Adjust duration calculation for polyphony.


(ns onyx.peer.log-version)

(def version "0.10.0-SNAPSHOT")

(defn check-compatible-log-versions! [cluster-version]
  (when-not (or (re-find #"-SNAPSHOT" version)
                 (= version cluster-version))
    (throw (ex-info "Incompatible versions of the Onyx cluster coordination log.
                     A new, distinct, :onyx/tenancy-id should be supplied when upgrading or downgrading Onyx."
                    {:cluster-version cluster-version
                     :peer-version version}))))

(ns onyx.peer.log-version)

(def version "0.10.0-SNAPSHOT")

(defn check-compatible-log-versions! [cluster-version]
  (when-not (or (re-find #"-" version)
                 (= version cluster-version))
    (throw (ex-info "Incompatible versions of the Onyx cluster coordination log.
                     A new, distinct, :onyx/tenancy-id should be supplied when upgrading or downgrading Onyx."
                    {:cluster-version cluster-version
                     :peer-version version}))))

Revert "Make alpha/beta/etc versions incompatible with each other."

This reverts commit ae9cd69e738069965b2a97784bb7b7fd833be8b6.


(ns scrape-summitpost-data.extract-result-links-test
  (:require [clojure.string :as string]
            [clojure.test :refer [deftest is]]
            [scrape-summitpost-data.extract-result-links :as test-ns]))

(defn- make-test-page
  [url]
  (let [template "

"]
    (string/replace template "{}" url)))

(deftest extract-result-links-test
  (let [page (make-test-page "/test-item-name/12345")]
    (is (= ["/test-item-name/12345"]
           (test-ns/extract-result-links page))
        "extracts link to item from search results table")))

(ns scrape-summitpost-data.extract-result-links-test
  (:require [clojure.string :as string]
            [clojure.test :refer [deftest is]]
            [scrape-summitpost-data.extract-result-links :as test-ns]))

(defn- make-test-page
  [urls]
  (let [header "

"
        row-template "

"
        footer "

"
        rows (mapv #(string/replace row-template "{}" %) urls)
        page (conj (cons header rows) footer)]
    (apply str page)))

(deftest extract-result-links-test
  (let [urls ["/test1"]]
    (is (= urls
           (test-ns/extract-result-links (make-test-page urls)))
        "extracts single link from search results table"))
  (let [urls ["/test1" "/test2" "/test3"]]
    (is (= urls
           (test-ns/extract-result-links (make-test-page urls)))
        "extracts multiple links from search results table")))

Improve make-test-page to allow multiple urls and add multiple url test for extract-result-links.


(ns kanban.components.boards-menu
  (:require [goog.object :as gobj]
            [om.next :as om :refer-macros [defui]]
            [om.dom :as dom]))

(defui BoardMenuItem
  static om/Ident
  (ident [this props]
    [:board/by-id (:id props)])
  static om/IQuery
  (query [this]
    [:id :name])
  Object
  (render [this]
    (dom/li nil
      (let [{:keys [name activate-fn]} (om/props this)]
        (dom/a #js {:onClick #(activate-fn (om/get-ident this))}
          name)))))

(def board-menu-item (om/factory BoardMenuItem {:keyfn :id}))

(defui BoardsMenu
  Object
  (render [this]
    (dom/div #js {:className "header-menu"}
      (dom/a nil "Boards")
      (dom/ul nil
        (let [{:keys [boards activate-fn]} (om/props this)]
          (for [board boards]
            (board-menu-item
              (assoc board :activate-fn activate-fn))))))))

(def boards-menu (om/factory BoardsMenu))

(ns kanban.components.boards-menu
  (:require [goog.object :as gobj]
            [om.next :as om :refer-macros [defui]]
            [om.dom :as dom]))

(defui BoardMenuItem
  static om/Ident
  (ident [this props]
    [:board/by-id (:id props)])
  static om/IQuery
  (query [this]
    [:id :name])
  Object
  (render [this]
    (dom/li nil
      (let [{:keys [name activate-fn]} (om/props this)]
        (dom/a #js {:onClick #(activate-fn (om/get-ident this))}
          name)))))

(def board-menu-item (om/factory BoardMenuItem {:keyfn :id}))

(defui BoardsMenu
  Object
  (render [this]
    (dom/div #js {:className "header-menu"}
      (dom/a nil "▾ Boards")
      (dom/ul nil
        (let [{:keys [boards activate-fn]} (om/props this)]
          (for [board boards]
            (board-menu-item
              (assoc board :activate-fn activate-fn))))))))

(def boards-menu (om/factory BoardsMenu))

Add a triangle symbol to the board menu to make its purpose obvious


(defproject exegesis "0.2.0-SNAPSHOT"
  :description "Simplify reflection of annotations on Java types."
  :url "http://github.com/tobyclemson/exegesis"
  :license {:name "The MIT License"
            :url  "https://opensource.org/licenses/MIT"}
  :dependencies [[org.clojure/clojure "1.8.0"]]
  :source-paths ["src/clojure"]
  :test-paths ["test/clojure"]
  :java-source-paths ["src/java" "test/java"])

(defproject exegesis "0.2.0-SNAPSHOT"
  :description "Simplify reflection of annotations on Java types."
  :url "http://github.com/tobyclemson/exegesis"
  :license {:name "The MIT License"
            :url  "https://opensource.org/licenses/MIT"}
  :dependencies [[org.clojure/clojure "1.8.0"]]
  :source-paths ["src/clojure"]
  :test-paths ["test/clojure"]
  :java-source-paths ["src/java" "test/java"]
  :deploy-repositories [["releases" {:url     "https://clojars.org/repo/"
                                     :creds   :gpg}]])

Use GPG lookup for clojars credentials.

Use GPG lookup for clojars credentials.


(defproject lein-xjc "0.1.0-SNAPSHOT"
  :description "Call xjc from leiningen."
  :url "http://lein-xjc.ferdinandhofherr.de"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :eval-in-leiningen true)

(defproject lein-xjc "0.1.0-SNAPSHOT"
  :description "Call xjc from leiningen."
  :url "http://lein-xjc.ferdinandhofherr.de"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :eval-in-leiningen true
  :profiles {:dev {:source-paths ["dev"]
                   :dependencies [[midje "1.6.0"]
                                  [cljito "0.2.1"]
                                  [org.mockito/mockito-all "1.9.5"]]
                   :plugins [[lein-midje "3.1.3"]]}})

Add dependency to cljito and mockito.

Add dependency to cljito and mockito.


(defproject onyx-app/lein-template "0.10.0.0-beta4"
  :description "Onyx Leiningen application template"
  :url "https://github.com/onyx-platform/onyx-template"
  :license {:name "MIT License"
            :url "http://choosealicense.com/licenses/mit/#"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :plugins [[lein-set-version "0.4.1"]]
  :profiles {:dev {:plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}}
  :eval-in-leiningen true)

(defproject onyx-app/lein-template "0.10.0.0-SNAPSHOT"
  :description "Onyx Leiningen application template"
  :url "https://github.com/onyx-platform/onyx-template"
  :license {:name "MIT License"
            :url "http://choosealicense.com/licenses/mit/#"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :plugins [[lein-set-version "0.4.1"]]
  :profiles {:dev {:plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}}
  :eval-in-leiningen true)

Prepare for next release cycle.

Prepare for next release cycle.


(defproject inet.data "0.5.0-SNAPSHOT"
  :description "Represent and manipulate various Internet entities as data."
  :url "http://github.com/llasram/inet.data"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [hier-set "1.1.2"]]
  :plugins [[lein-ragel "0.1.0"]]
  :source-paths ["src/clojure"]
  :java-source-paths ["src/java" "target/ragel"]
  :ragel-source-paths ["src/ragel"]
  :javac-options ["-g"]
  :prep-tasks [ragel javac]
  :warn-on-reflection true
  :profiles {:dev {:dependencies [[byteable "0.2.0"]
                                  [criterium "0.2.1"]]}})

(defproject inet.data "0.5.0-SNAPSHOT"
  :description "Represent and manipulate various Internet entities as data."
  :url "http://github.com/llasram/inet.data"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [hier-set "1.1.2"]]
  :plugins [[lein-ragel "0.1.0"]]
  :source-paths ["src/clojure"]
  :java-source-paths ["src/java" "target/ragel"]
  :ragel-source-paths ["src/ragel"]
  :javac-options ["-g"]
  :prep-tasks ["ragel" "javac"]
  :warn-on-reflection true
  :profiles {:dev {:dependencies [[byteable "0.2.0"]
                                  [criterium "0.2.1"]]}})

Update :prep-tasks for most recent lein.


(defproject onyx-app/lein-template "0.8.11.9"
  :description "Onyx Leiningen application template"
  :url "https://github.com/onyx-platform/onyx-template"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :plugins [[lein-set-version "0.4.1"]]
  :profiles {:dev {:plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}}
  :eval-in-leiningen true)

(defproject onyx-app/lein-template "0.8.11.10-SNAPSHOT"
  :description "Onyx Leiningen application template"
  :url "https://github.com/onyx-platform/onyx-template"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :plugins [[lein-set-version "0.4.1"]]
  :profiles {:dev {:plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}}
  :eval-in-leiningen true)

Prepare for next release cycle.

Prepare for next release cycle.


(defproject com.hypirion/bencode "0.1.0-SNAPSHOT"
  :description "Java implementation Bencode."
  :url "https://github.com/hyPiRion/java-bencode"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies []
  :source-paths []
  :java-source-paths ["src"]
  :javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"]
  :scm {:dir ".."}
  :aliases {"javadoc" ["shell" "javadoc" "-d" "javadoc/${:version}"
                       "-sourcepath" "src" "com.hypirion.bencode"
                       "-link" "http://docs.oracle.com/javase/8/docs/api/"]}
  :plugins [[lein-shell "0.5.0"]]
  :profiles {:uberjar {:aot :all}
             :dev {:dependencies [[org.clojure/clojure "1.8.0"]
                                  [org.clojure/test.check "0.9.0"]]}})

(defproject com.hypirion/bencode "0.1.0-SNAPSHOT"
  :description "Java implementation of Bencode."
  :url "https://github.com/hyPiRion/java-bencode"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :deploy-repositories [["releases" :clojars]]
  :dependencies []
  :source-paths []
  :java-source-paths ["src"]
  :javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"]
  :scm {:dir ".."}
  :aliases {"javadoc" ["shell" "javadoc" "-d" "javadoc/${:version}"
                       "-sourcepath" "src" "com.hypirion.bencode"
                       "-link" "http://docs.oracle.com/javase/8/docs/api/"]}
  :plugins [[lein-shell "0.5.0"]]
  :profiles {:uberjar {:aot :all}
             :dev {:dependencies [[org.clojure/clojure "1.8.0"]
                                  [org.clojure/test.check "0.9.0"]]}})

Use Clojars as default deploy repository


(defproject sqls "0.1.0-SNAPSHOT"
  :description "SQLS"
  :url "https://github.com/mpietrzak/sqls"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [
                 [org.clojure/clojure "1.6.0"]
                 [org.clojure/data.json "0.2.4"]
                 [org.clojure/java.jdbc "0.3.3"]
                 [org.clojure/tools.logging "0.2.6"]
                 [org.xerial/sqlite-jdbc "3.7.2"]
                 [seesaw "1.4.4"]
                 ]
  :main sqls.core
  :java-source-paths ["src"]
  :target-path "target/%s"
  :plugins [[codox "0.6.7"]
            [lein-ancient "0.5.5"]]
  :codox {:output-dir "doc/codox"}
  :profiles {:uberjar {:aot :all}}
  :jvm-opts ["-Xms4M" "-Xmx1G" "-XX:-PrintGC"])
  :profiles {:uberjar {:aot :all}
             :dev {:global-vars {*warn-on-reflection* true}}}

(defproject sqls "0.1.0-SNAPSHOT"
  :description "SQLS"
  :url "https://github.com/mpietrzak/sqls"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [
                 [org.clojure/clojure "1.6.0"]
                 [org.clojure/data.json "0.2.5"]
                 [org.clojure/java.jdbc "0.3.4"]
                 [org.clojure/tools.logging "0.3.0"]
                 [org.xerial/sqlite-jdbc "3.7.2"]
                 [seesaw "1.4.4"]
                 ]
  :main sqls.core
  :java-source-paths ["src"]
  :target-path "target/%s"
  :plugins [[codox "0.8.10"]
            [lein-ancient "0.5.5"]]
  :codox {:output-dir "doc/codox"}
  :profiles {:uberjar {:aot :all}
             :dev {:global-vars {*warn-on-reflection* true}
                   :jvm-opts ["-Xms4M" "-Xmx1G" "-XX:+PrintGC" "-XX:+UseG1GC"]}})

Update dependencies and move gc logging options to dev profile


(ns scavenger.core
  (:require [compojure.core :refer :all]
            [compojure.route :as route]
            [ring.middleware.defaults :refer [wrap-defaults site-defaults]]
            [ring.util.response :refer [header content-type response resource-response]])
  (:use [datomic.api :only [db q] :as d]))

(def uri "datomic:free://localhost:4334/items")

(def conn (d/connect uri))

(defn get-all-items []
  (map first (q '[:find (pull ?c [*]) :where [?c item/name]] (db conn))))

(defroutes app-routes
  (GET "/items" []
    (response (str (into [] (get-all-items)))))
  (POST "/items" {body :body}
    (let [tempid (d/tempid :items)
          data (merge (read-string (slurp body)) {:db/id tempid})
          tx @(d/transact conn [data])
          id (d/resolve-tempid (db conn) (:tempids tx) tempid)]
      (response (str (d/touch (d/entity (db conn) id))))))
  (GET "/" []
    (-> (resource-response "index.html" {:root "public"})
        (content-type "text/html")))
  (route/not-found "Page not found"))

(def app
  (wrap-defaults app-routes (assoc site-defaults :security nil)))

(ns scavenger.core
  (:require [compojure.core :refer :all]
            [compojure.route :as route]
            [ring.middleware.defaults :refer [wrap-defaults site-defaults]]
            [ring.util.response :refer [header content-type response resource-response]])
  (:use [datomic.api :only [db q] :as d]))

(def uri "datomic:free://localhost:4334/items")

(def conn (d/connect uri))

(defn get-all-items []
  (map first (q '[:find (pull ?c [*]) :where [?c item/name]] (db conn))))

(defn generate-response [data & [status]]
  {:status (or status 200)
   :headers {"Content-Type" "application/edn"}
   :body (pr-str data)})

(defroutes app-routes
  (GET "/items" []
    (generate-response (into [] (get-all-items))))
  (POST "/items" {body :body}
    (let [tempid (d/tempid :items)
          data (merge (read-string (slurp body)) {:db/id tempid})
          tx @(d/transact conn [data])
          id (d/resolve-tempid (db conn) (:tempids tx) tempid)]
      (generate-response (d/touch (d/entity (db conn) id)))))
  (GET "/" []
    (-> (resource-response "index.html" {:root "public"})
        (content-type "text/html")))
  (route/not-found "Page not found"))

(def app
  (wrap-defaults app-routes (assoc site-defaults :security nil)))

Add helper for generating a server response

Add a helper for generating a server response with the correct
Content-Type and a reasonable status code.


(ns silly-image-store.store
  (:require [clojure.java.io :as io]))

(def exists? #(and % (.exists %)))
(def file? #(.isFile %))
(def filename #(.getName %))

(defn load-image [& paths]
  (let [file (apply io/file paths)]
    (if (exists? file) file nil)))

(defn list-images [& paths]
  (let [image-directory (apply load-image paths)]
    (if (exists? image-directory)
      (->> image-directory
       .listFiles
       (filter file?)
       (map filename))
      nil)))

(defn random-image [basedir]
  (let [random-image-name (rand-nth (list-images basedir))]
    (load-image basedir random-image-name)))

(ns silly-image-store.store
  (:require [clojure.java.io :as io]))

(def exists? #(and % (.exists %)))
(def file? #(.isFile %))
(def filename #(.getName %))

(defn load-image [& paths]
  (let [file (apply io/file paths)]
    (if (exists? file) file)))

(defn list-images [& paths]
  (let [image-directory (apply load-image paths)]
    (if (exists? image-directory)
      (->> image-directory
       .listFiles
       (filter file?)
       (map filename)))))

(defn random-image [basedir]
  (let [random-image-name (rand-nth (list-images basedir))]
    (load-image basedir random-image-name)))

Remove nils as it's redundnnat

Remove nils as it's redundnnat