(ns todo-repl-webapp.views
  (:require [hiccup.form :as form]
            [hiccup.page :as page]
            [hiccup.core :as core]))

(defn home [& _]
  (core/html [:head
          [:title "todo-repl"]
          (page/include-css "css/bootstrap.min.css")
          (page/include-js "http://code.jquery.com/jquery-1.10.1.min.js"
                           "js/bootstrap.min.js")]
        [:body
          [:div.col-md-7.col-md-offset-2
            [:h1 "todo-repl"]
            (form/form-to {:id "todoForm"}
                          [:post "/eval"]
                          (form/text-area {:class "form-control"}
                                          "evalInput"
                                          "blah")
                          [:br]
                          (form/submit-button {:id "todoSubmitButton"}
                                              "Eval"))]
          [:div#display.col-md-7.col-md-offset-2]
          (page/include-js "js/eval.js")]))

(defn eval [x & xs]
  (core/html [:h1 "Eval"]
        [:h2 x]))

(ns todo-repl-webapp.views
  (:require [hiccup.form :as form]
            [hiccup.page :as page]
            [hiccup.core :as core]))

(defn home [& _]
  (core/html [:head
          [:title "todo-repl"]
          (page/include-css "css/bootstrap.min.css")
          (page/include-js "http://code.jquery.com/jquery-1.10.1.min.js"
                           "js/bootstrap.min.js")]
        [:body
          [:div.col-md-7.col-md-offset-2
            [:h1 "todo-repl"]
            (form/form-to {:id "todoForm"}
                          [:post "/eval"]
                          (form/text-area {:class "form-control"}
                                          "evalInput"
                                          "(tasks)")
                          [:br]
                          (form/submit-button {:id "todoSubmitButton"}
                                              "Eval"))]
          [:div#display.col-md-7.col-md-offset-2]
          (page/include-js "js/eval.js")]))

(defn task-item
  "Given a task (map), return a div representing the task"
  [task-map]
  (core/html
    [:div
      [:div.col-md-7.col-md-offset-1
        (:name task-map)]]))
(defn task-line-item
  "When given a single task (map), return a html table line representing the task"
  [task-map]
  (core/html [:tr
               [:td (task-item task-map)]]))

(defn task-table
  "When given a vector of tasks (maps), return an html table representing those tasks"
  [task-vec]
  (core/html
    [:table.table.table-bordered
      (clojure.string/join
        (map task-line-item task-vec))]))

(defn display [x & xs]
  (if-not (empty? x)
    (core/html [:h2 "list"]
          [:h3 x]
            (task-table (vec x)))))

Add functions to format tasks into a table.


(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.2.1"]
                 [org.apache.kafka/kafka-clients "0.10.2.1" :classifier "test"]
                 [org.apache.kafka/kafka-streams "0.10.2.1"]
                 [org.apache.kafka/kafka-streams "0.10.2.1" :classifier "test"]

                 [com.stuartsierra/component "0.3.2"]
                 [spootnik/signal "0.2.1"]]

  :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.2.1"]
                 [org.apache.kafka/kafka-clients "0.10.2.1" :classifier "test"]
                 [org.apache.kafka/kafka-streams "0.10.2.1"]
                 [org.apache.kafka/kafka-streams "0.10.2.1" :classifier "test"]
                 [org.slf4j/slf4j-jdk14 "1.7.25"]

                 [com.stuartsierra/component "0.3.2"]
                 [spootnik/signal "0.2.1"]]

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

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

Add Log4j as SLF4J implementation

Add Log4j as SLF4J implementation

Now Kafka Streams reveals its soul as soon as you initialize it.


(ns cmr.transmit.test.echo.rest
  "Tests for cmr.transmit.echo.rest namespace"
  (:require [clojure.test :refer :all]
            [cmr.transmit.echo.rest :as rest]))

(deftest test-error-masked
  (let [error-message "Unexpected error message: Token 123 does not exist."
       status 500]
    (is (= (format "Unexpected status %d from response. body: %s" status "Token does not exist")
           (rest/unexpected-status-error! status error-message)))))

(ns cmr.transmit.test.echo.rest
  "Tests for cmr.transmit.echo.rest namespace"
  (:require [clojure.test :refer :all]
            [cmr.transmit.echo.rest :as rest]))

(deftest test-error-masked
  (let [error-message "Unexpected error message: Token 123 does not exist."
        status 500]
    (is (thrown-with-msg?
        java.lang.Exception
        ;; Fixme - (format "%d %s" status message) was getting the error:
        ;; java.lang.ClassCastException: java.lang.String cannot be cast to java.util.regex.Pattern
        #"Unexpected status 500 from response. body: Token does not exist"
        (rest/unexpected-status-error! status error-message)))))

Fix test and add comment

Fix test and add comment


(ns comic-reader.ui.site-list
  (:refer-clojure :exclude [get set]
                  :rename {get cget})
  (:require [re-frame.core :as re-frame]
            [reagent.ratom :refer-macros [reaction]]
            [comic-reader.ui.base :as base]))

(defn get [db]
  (cget db :site-list))

(defn set [db [_ sites]]
  (assoc db :site-list sites))

(defn setup! []
  (re-frame/register-sub
   :site-list
   (fn [app-db v]
     (reaction (get @app-db))))

  (re-frame/register-handler
   :set-site-list
   set))

(defn site-list [view-site sites]
  (base/list-with-loading
   {:heading "Comic Sites"
    :list-element [:ul.inline-list]
    :item->li (fn [site]
                [:a.large.button.radius
                 {:on-click #(view-site (:id site))}
                 (:name site)])}
   sites))

(defn site-list-container []
  (let [sites (re-frame/subscribe [:site-list])]
    (fn [] [site-list
            (fn [site-id]
              (re-frame/dispatch [:view-site site-id]))
            (deref sites)])))

(ns comic-reader.ui.site-list
  (:refer-clojure :exclude [get set])
  (:require [re-frame.core :as re-frame]
            [reagent.ratom :refer-macros [reaction]]
            [comic-reader.ui.base :as base]))

(defn get [db]
  (clojure.core/get db :site-list))

(defn set [db [_ sites]]
  (assoc db :site-list sites))

(defn setup! []
  (re-frame/register-sub
   :site-list
   (fn [app-db v]
     (reaction (get @app-db))))

  (re-frame/register-handler
   :set-site-list
   set))

(defn site-list [view-site sites]
  (base/list-with-loading
   {:heading "Comic Sites"
    :list-element [:ul.inline-list]
    :item->li (fn [site]
                [:a.large.button.radius
                 {:on-click #(view-site (:id site))}
                 (:name site)])}
   sites))

(defn site-list-container []
  (let [sites (re-frame/subscribe [:site-list])]
    (fn [] [site-list
            (fn [site-id]
              (re-frame/dispatch [:view-site site-id]))
            (deref sites)])))

Stop using potentially not-real feature of require


(defproject me.arrdem/oxcart (slurp "VERSION")
  :description "An experimental optimizing compiler for Clojure code"
  :url "http://github.com/arrdem/oxcart"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [
                 [org.clojure/clojure            "1.5.1"]
                 [org.clojure/tools.analyzer.jvm "0.1.0-SNAPSHOT"]
                 [org.clojure/tools.emitter.jvm  "0.0.1-SNAPSHOT"]
                 [org.clojure/tools.reader       "0.8.4"]
                 ])

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

Add injections to keep myself from killing repls


(ns frontend.devtools
  (:require [environ.core :refer [env]]))

(defmacro require-devtools! []
  (when (:devtools env)
    '(js/goog.require "frontend.devtools")))

(ns frontend.devtools
  (:require [environ.core :refer [env]]))

(defmacro require-devtools! []
  (when (:devtools env)
    ;; TODO: Replace this with a ClojureScript require function
    '(js/goog.require "frontend.devtools")))

Add note to replace goog.require with require


(ns obb-api.handlers.play-game-test
  (:require [clojure.test :refer :all]
            [obb-api.service-test :as service]
            [obb-rules.stash :as stash]
            [obb-api.handlers.deploy-game-test :as deploy-game-test]
            [io.pedestal.test :refer :all]
            [io.pedestal.http :as bootstrap]))

(deftest play-game-smoke
  (let [[game _] (deploy-game-test/create-deployed-game)
        data {}
        [response status] (service/put-json "donbonifacio"
                                            (str "/game/" (game :_id) "/turn")
                                            data)]
    (is (not= 404 status))
    (is (#{"p1" "p2"} (get-in game [:board :state])))))

(ns obb-api.handlers.play-game-test
  (:require [clojure.test :refer :all]
            [obb-api.service-test :as service]
            [obb-rules.stash :as stash]
            [obb-api.handlers.deploy-game-test :as deploy-game-test]
            [io.pedestal.test :refer :all]
            [io.pedestal.http :as bootstrap]))

(defn- create-game
  "Creates a game where p1 is the first to play"
  []
  (-> (deploy-game-test/create-deployed-game)))

(deftest play-game-smoke
  (let [[game _] (create-game)
        data {}
        [response status] (service/put-json "donbonifacio"
                                            (str "/game/" (game :_id) "/turn")
                                            data)]
    (is (not= 404 status))))

Arrange smoke test on play game

Arrange smoke test on play game


;; Define template options here
; @layout  default
; @title   home

;; Your own function in template
(defn page-header [[fs & rs]]
  [:div {:class "page-header"}
   [:h1 [:span fs] rs]])

; Template is compiled with hiccup
(header
  (:title site)
	"The blog of Peter Barnett."
	[:br]
  (link "github.com/Pance" "https://github.com/Pance")
  )

;; Sample posts
(page-header "Posts")
(post-list)
(prev-next-page-link)

;; Sample post tags
(page-header "Tags")
(tag-list)

;; Define template options here
; @layout  default
; @title   home

;; Your own function in template
(defn page-header [[fs & rs]]
  [:div {:class "page-header"}
   [:h1 [:span fs] rs]])

; Template is compiled with hiccup
(header
  (:title site)
    [:p.text-center "Hello, I'm Peter Barnett"]
    [:p.text-center "I am a developer[github] who believes code and design can be beautiful."]
    [:p.text-center "I work in an accelerated development program as a software developer at HEB Grocery Company[link]."]
    [:p.text-center
      (link "github.com/Pance" "https://github.com/Pance")
      "  "
      (link "soundcloud.com/DJPance" "https://soundcloud.com/djpance")]
    [:p.text-center "I am a Texan, hacker, gamer and a bedroom DJ. I am interested in the web, personal data tracking, automation, people, cars, fitness and electronic dance music."]
    [:p.text-center "I'm currently building a todo-list web app using Clojure called todo-repl[link]."]

	[:br]
  )

;; Sample posts
(page-header "Posts")
(post-list)
(prev-next-page-link)

;; Sample post tags
(page-header "Tags")
(tag-list)

Add some content to front page

Add some content to front page


(ns
  ^{:author "Brian Craft"
    :doc "A set of core functions for use with cavm.query.expression."}
  cavm.query.functions
  (:use clojure.core.matrix)
  (:use clojure.core.matrix.operators)
  (:refer-clojure :exclude  [* - + == /])
  (:gen-class))

(set-current-implementation :vectorz)

(defn- meannan1d [m]
  (let [NaN Double/NaN
        [sum n] (ereduce
                  (fn [[acc cnt] x] (if (Double/isNaN x) [acc cnt] [(+ acc x) (inc cnt)]))
                  [0 0]
                  m)]
    (if (= 0 n) NaN (/ sum n))))

; XXX this handling of dim is wrong for dim > 1
; XXX do we need to fill nan values, like we do in python?
(defn- meannan [m dim]
    (let [new-shape (assoc (vec (shape m)) (long dim) 1)]
      (reshape (matrix (map meannan1d (slices m (- 1 dim)))) new-shape)))

(def functions
  {'+ +
   '/ /
   '* emul
   '> >
   '< <
   '>= >=
   '<= <=
   '- -
   '= ==
   'map map
   'get get
   'assoc assoc
   'cons cons
   'car first
   'cdr rest
   'group-by group-by
   'mean meannan
   'apply apply}) ; XXX is this a security hole? Can the user pass in clojure symbols?

(ns
  ^{:author "Brian Craft"
    :doc "A set of core functions for use with cavm.query.expression."}
  cavm.query.functions
  (:use clojure.core.matrix)
  (:use clojure.core.matrix.operators)
  (:refer-clojure :exclude  [* - + == /])
  (:gen-class))

(set-current-implementation :vectorz)

(defn- meannan1d [m]
  (let [NaN Double/NaN
        [sum n] (ereduce
                  (fn [[acc cnt] x] (if (Double/isNaN x) [acc cnt] [(+ acc x) (inc cnt)]))
                  [0 0]
                  m)]
    (if (= 0 n) NaN (/ sum n))))

; XXX this handling of dim is wrong for dim > 1
; XXX do we need to fill nan values, like we do in python?
(defn- meannan [m dim]
    (let [new-shape (assoc (vec (shape m)) (long dim) 1)]
      (reshape (matrix (map meannan1d (slices m (- 1 dim)))) new-shape)))

(def functions
  {'+ +
   '/ /
   '* emul
   '> >
   '< <
   '>= >=
   '<= <=
   '- -
   '= ==
   'map map
   'get get
   'assoc assoc
   'cons cons
   'car first
   'cdr rest
   'group-by group-by
   'mean meannan
   'count count
   'apply apply}) ; XXX is this a security hole? Can the user pass in clojure symbols?

Add 'count' to web api.

Add 'count' to web api.


(ns hxgm30.language.io
  (:require
    [clojure.edn :as edn]
    [clojure.java.io :as io]
    [clojure.string :as string]))

(defn load-lines
  [fullpath]
  (->> fullpath
       io/resource
       io/reader
       line-seq))

(defn load-clean-lines
  [fullpath]
  (->> fullpath
       load-lines
       (mapcat #(string/split % #" "))
       (remove empty?)
       (map (comp string/lower-case
                  #(string/replace % "\"" "")
                  #(string/replace % "'s" "")
                  #(string/replace % "'ll" "")
                  #(string/replace % "'d" "")
                  #(string/replace % "'re" "")))
       sort))

(defn dump
  [fullpath data]
  (spit fullpath data))

(defn undump
  [fullpath]
  (->> fullpath
       io/resource
       slurp
       edn/read-string))

(ns hxgm30.language.io
  (:require
    [clojure.edn :as edn]
    [clojure.java.io :as io]
    [clojure.pprint :as pprint]
    [clojure.string :as string]))

(defn load-lines
  [fullpath]
  (->> fullpath
       io/resource
       io/reader
       line-seq))

(defn load-clean-lines
  [fullpath]
  (->> fullpath
       load-lines
       (mapcat #(string/split % #" "))
       (remove empty?)
       (map (comp string/lower-case
                  #(string/replace % "\"" "")
                  #(string/replace % "'s" "")
                  #(string/replace % "'ll" "")
                  #(string/replace % "'d" "")
                  #(string/replace % "'re" "")))
       sort))

(defn dump
  [fullpath data]
  (spit fullpath (with-out-str (pprint/pprint data))))

(defn undump
  [fullpath]
  (->> fullpath
       io/resource
       slurp
       edn/read-string))

Save stats as pretty-printed data.

Save stats as pretty-printed data.

This makes reating diffs easier as well as visual examination of data files
easier.


(defproject io.aviso/rook "0.1.3"
  :description "Ruby on Rails-style resource mapping for Clojure/Compojure web apps"
  :url "https://github.com/AvisoNovate/rook"
  :license {:name "Apache Sofware Licencse 2.0"
            :url  "http://www.apache.org/licenses/LICENSE-2.0.html"}
  ;; Normally we don't AOT compile; only when tracking down reflection warnings.
  :profiles {:reflection-warnings {:aot         :all
                                   :global-vars {*warn-on-reflection* true}}
             :dev {:dependencies [[ring-mock "0.1.5"]]}}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.clojure/tools.logging "0.2.6"]
                 [compojure "1.1.6"]]
  :plugins [[test2junit "1.0.1"]])

(defproject io.aviso/rook "0.1.4-SNAPSHOT"
  :description "Ruby on Rails-style resource mapping for Clojure/Compojure web apps"
  :url "https://github.com/AvisoNovate/rook"
  :license {:name "Apache Sofware Licencse 2.0"
            :url  "http://www.apache.org/licenses/LICENSE-2.0.html"}
  ;; Normally we don't AOT compile; only when tracking down reflection warnings.
  :profiles {:reflection-warnings {:aot         :all
                                   :global-vars {*warn-on-reflection* true}}
             :dev {:dependencies [[ring-mock "0.1.5"]]}}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.clojure/tools.logging "0.2.6"]
                 [compojure "1.1.6"]]
  :plugins [[test2junit "1.0.1"]])

Advance version number to 0.1.4-SNAPSHOT


(defproject deadman "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [ring "1.3.0"]
                 [compojure "1.1.8"]
                 [ring/ring-json "0.3.1"]
                 [ring-json-params "0.1.0"]
                 [org.clojure/data.json "0.2.5"]]
  :plugins [[lein-ring "0.8.11"]]
  :resource-paths ["lib/*"]
  :ring {:handler deadman.core/app})

(defproject deadman "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"}
  :uberjar-name "deadman-standalone.jar"
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [ring "1.3.0"]
                 [compojure "1.1.8"]
                 [ring/ring-json "0.3.1"]
                 [ring-json-params "0.1.0"]
                 [org.clojure/data.json "0.2.5"]]
  :plugins [[lein-ring "0.8.11"]]
  :resource-paths ["lib/*"]
  :ring {:handler deadman.core/app})

Set up uberjar for use with the Procfile


(defproject io.aviso/tracker "0.1.6"
            :description "Track per-thread operations when exceptions occur"
            :url "https://github.com/AvisoNovate/tracker"
            :license {:name "Apache Sofware Licencse 2.0"
                      :url  "http://www.apache.org/licenses/LICENSE-2.0.html"}
            :dependencies [[org.clojure/clojure "1.6.0"]
                           [org.clojure/tools.logging "0.3.0"]
                           [io.aviso/pretty "0.1.15"]
                           [io.aviso/toolchest "0.1.1"]]
            :plugins [[lein-shell "0.4.0"]]
            :shell {:commands {"scp" {:dir "doc"}}}
            :aliases {"deploy-doc" ["shell"
                                    "scp" "-r" "." "hlship_howardlewisship@ssh.phx.nearlyfreespeech.net:io.aviso/tracker"]
                      "release"    ["do"
                                    "clean,"
                                    "doc,"
                                    "deploy-doc,"
                                    "deploy" "clojars"]}
            :codox {:src-dir-uri               "https://github.com/AvisoNovate/tracker/blob/master/"
                    :src-linenum-anchor-prefix "L"
                    :defaults                  {:doc/format :markdown}}
            :profiles {:dev {:dependencies [[org.slf4j/slf4j-api "1.7.6"]
                                            [ch.qos.logback/logback-classic "1.1.1"]]}})

(defproject io.aviso/tracker "0.1.7-SNAPSHOT"
            :description "Track per-thread operations when exceptions occur"
            :url "https://github.com/AvisoNovate/tracker"
            :license {:name "Apache Sofware Licencse 2.0"
                      :url  "http://www.apache.org/licenses/LICENSE-2.0.html"}
            :dependencies [[org.clojure/clojure "1.6.0"]
                           [org.clojure/tools.logging "0.3.0"]
                           [io.aviso/pretty "0.1.15"]
                           [io.aviso/toolchest "0.1.1"]]
            :plugins [[lein-shell "0.4.0"]]
            :shell {:commands {"scp" {:dir "doc"}}}
            :aliases {"deploy-doc" ["shell"
                                    "scp" "-r" "." "hlship_howardlewisship@ssh.phx.nearlyfreespeech.net:io.aviso/tracker"]
                      "release"    ["do"
                                    "clean,"
                                    "doc,"
                                    "deploy-doc,"
                                    "deploy" "clojars"]}
            :codox {:src-dir-uri               "https://github.com/AvisoNovate/tracker/blob/master/"
                    :src-linenum-anchor-prefix "L"
                    :defaults                  {:doc/format :markdown}}
            :profiles {:dev {:dependencies [[org.slf4j/slf4j-api "1.7.6"]
                                            [ch.qos.logback/logback-classic "1.1.1"]]}})

Advance version number to 0.1.7

Advance version number to 0.1.7


(defproject coolant "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/clojurescript  "0.0-3211"]]
  :source-paths ["src" "test"])

(defproject coolant "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/clojurescript  "0.0-3211" :scope "provided"]]
  :source-paths ["src" "test"])

Make cljs dep :scope :provided

Make cljs dep :scope :provided


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

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


(ns build-mon.test.vso-api
  (:require [midje.sweet :refer :all]
            [clojure.java.io :as io]
            [build-mon.vso-api :as api]))

(fact "vso-api-get-fn wraps an api token and returns a function which can be called with just a URL"
      (let [result (api/vso-api-get-fn "SOME API TOKEN")]
        (fn? result) => truthy
        (result "NOT A REAL URL") => (throws java.net.MalformedURLException)))

(fact "vso-api-fns returns a map of the exposed functions"
      (let [get-fn (fn [url] "API RESPONSE")
            result (api/vso-api-fns get-fn "ACCOUNT_NAME" "PROJECT_NAME")]
        (fn? (:retrieve-build-info result)) => truthy
        (fn? (:retrieve-build-definitions result)) => truthy))

(ns build-mon.test.vso-api
  (:require [midje.sweet :refer :all]
            [clojure.java.io :as io]
            [build-mon.vso-api :as api]))

(def account "VSO_ACCOUNT_NAME")
(def project "VSO_PROJECT_NAME")
(def token "VSO_API_TOKEN")

(fact "vso-api-get-fn wraps an api token and returns a function which makes a HTTP GET request on a url"
      (let [result (api/vso-api-get-fn token)]
        (fn? result) => truthy
        (result "NOT A REAL URL") => (throws java.net.MalformedURLException)))

(fact "vso-api-fns returns a map of the exposed functions"
      (let [get-fn (fn [url] "API RESPONSE")
            result (api/vso-api-fns get-fn account project)]
        (fn? (:retrieve-build-info result)) => truthy
        (fn? (:retrieve-build-definitions result)) => truthy))

(defn get-fn-stub-request [stubbed-url response]
  (fn [url]
    (when (= stubbed-url url) response)))

(fact "retrieve-build-definitions retrieves build definitions"
      (let [expected-url "https://VSO_ACCOUNT_NAME.visualstudio.com/defaultcollection/VSO_PROJECT_NAME/_apis/build/definitions?api-version=2.0"
            stub-json-body "{\"count\":2,\"value\":[{\"A_BUILD_DEFINITION_KEY\": \"A_VALUE\"},
                                                    {\"ANOTHER_BUILD_DEFINITION_KEY\": \"ANOTHER_VALUE\"}]}"
            stub-response {:status 200 :body stub-json-body}
            get-fn-stubbed (get-fn-stub-request expected-url stub-response)
            vso-api (api/vso-api-fns get-fn-stubbed account project)]
        ((:retrieve-build-definitions vso-api)) => [{:A_BUILD_DEFINITION_KEY "A_VALUE"}
                                                    {:ANOTHER_BUILD_DEFINITION_KEY "ANOTHER_VALUE"}]))

Test retrieve-build-definitions function stubbing the api request


;; Copyright (c) Daniel Borchmann. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file LICENSE at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.

(use 'clojure.tools.cli)

;;

(defn- run-repl []
  (clojure.main/repl :init #(use 'conexp.main)))

(with-command-line *command-line-args*
  "conexp-clj -- a general purpose tool for Formal Concept Analysis\n"
  [[gui? "Start the graphical user interface"]
   [load "Load script and run"]]
  (when gui?
    (clojure.main/repl :init #(do
                                (use 'conexp.main)
                                (use 'conexp.contrib.gui)
                                (@(ns-resolve 'conexp.contrib.gui 'gui)
                                 :default-close-operation javax.swing.JFrame/EXIT_ON_CLOSE))))
  (when load
    (use 'conexp.main)
    (load-file load))
  (when-not (or load gui?)
    (clojure.main/repl :init #(use 'conexp.main))))

;;

nil

;; Copyright (c) Daniel Borchmann. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file LICENSE at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.

(use 'clojure.tools.cli)

;;

(defn- run-repl []
  (clojure.main/repl :init #(use 'conexp.main)))

(let [options (cli *command-line-args*
                   (optional ["--gui" "Start the graphical user interface"])
                   (optional ["--load" "Load a given script"]))]
  (when (options :gui)
    (clojure.main/repl :init #(do
                                (use 'conexp.main)
                                (use 'conexp.contrib.gui)
                                (@(ns-resolve 'conexp.contrib.gui 'gui)
                                 :default-close-operation javax.swing.JFrame/EXIT_ON_CLOSE))))
  (when (options :load)
    (use 'conexp.main)
    (load-file (options :load)))
  (when-not (or (options :gui)
                (options :load))
    (clojure.main/repl :init #(use 'conexp.main))))

;;

nil

Use new tools.cli functionality for command line parsing

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>


(ns app.operations
  (:require [fulcro.client.mutations :as m :refer [defmutation]]))

(defmutation toggle-item-checked?!
  [{:keys [id]}]
  (action [{:keys [state]}]
          (let [ident [:item/by-id id]
                current-item (get-in @state ident)
                updated-item (update current-item :item/checked? not)]
            (swap! state assoc-in ident updated-item))))

(defmutation delete-item!
  [{:keys [id]}]
  (action [{:keys [state]}]
          (let [ident [:item/by-id id]
                current-items (get-in @state [:item-list :item-list/items])
                updated-items (vec (remove #(= ident %) current-items))]
            (swap! state assoc-in [:item-list :item-list/items] updated-items))))

(defmutation update-input-value!
  [{:keys [input-value]}]
  (action [{:keys [state]}]
          (swap! state assoc-in [:item-adder :item-adder/input-value] input-value)))

(ns app.operations
  (:require [fulcro.client.mutations :as m :refer [defmutation]]))

(defmutation toggle-item-checked?!
  [{:keys [id]}]
  (action [{:keys [state]}]
          (let [ident [:item/by-id id]
                current-item (get-in @state ident)
                updated-item (update current-item :item/checked? not)]
            (swap! state assoc-in ident updated-item))))

(defmutation delete-item!
  [{:keys [id]}]
  (action [{:keys [state]}]
          (let [remove-ident (fn [items] (vec (remove #(= [:item/by-id id] %) items)))]
            (swap! state #(-> %
                              (update-in [:item-list :item-list/items] remove-ident)
                              (update :item/by-id dissoc id))))))

(defmutation update-input-value!
  [{:keys [input-value]}]
  (action [{:keys [state]}]
          (swap! state assoc-in [:item-adder :item-adder/input-value] input-value)))

Delete the item from the list and the table


(defproject beehive-http "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.7.0"]
                 [net.uncontended/Precipice-Implementations "0.1.0"]
                 [net.uncontended/beehive "0.5.3"]])

(defproject beehive-http "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.7.0"]
                 [net.uncontended/Precipice-Implementations "0.1.0"]
                 [net.uncontended/beehive "0.5.4"]])

Update to new version of beehive

Update to new version of beehive


(defproject soy-clj "0.3.3-SNAPSHOT"
  :description "An idiomatic Clojure wrapper for Google's Closure templating system."
  :url "https://github.com/codahale/soy-clj"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[com.codahale/guava-cache-clj "0.1.2"]
                 [com.google.template/soy "2017-02-01"
                  :exclusions [args4j
                               com.google.gwt/gwt-user
                               com.google.guava/guava-testlib
                               org.json/json
                               com.google.code.gson/gson]]]
  :plugins []
  :test-selectors {:default #(not-any? % [:bench])
                   :bench   :bench}
  :aliases {"bench" ["test" ":bench"]}
  :deploy-repositories [["releases" :clojars]
                        ["snapshots" :clojars]]
  :global-vars {*warn-on-reflection* true}
  :profiles {:dev [:project/dev :profiles/dev]
             :test [:project/test :profiles/test]
             :profiles/dev {:dependencies [[org.clojure/clojure "1.8.0"]
                                           [criterium "0.4.4"]]}
             :profiles/test {}
             :project/dev {:source-paths ["dev"]
                           :repl-options {:init-ns user}}
             :project/test {:dependencies []}})

(defproject com.codahale/soy-clj "0.3.3-SNAPSHOT"
  :description "An idiomatic Clojure wrapper for Google's Closure templating system."
  :url "https://github.com/codahale/soy-clj"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[com.codahale/guava-cache-clj "0.1.2"]
                 [com.google.template/soy "2017-02-01"
                  :exclusions [args4j
                               com.google.gwt/gwt-user
                               com.google.guava/guava-testlib
                               org.json/json
                               com.google.code.gson/gson]]]
  :plugins []
  :test-selectors {:default #(not-any? % [:bench])
                   :bench   :bench}
  :aliases {"bench" ["test" ":bench"]}
  :deploy-repositories [["releases" :clojars]
                        ["snapshots" :clojars]]
  :global-vars {*warn-on-reflection* true}
  :profiles {:dev [:project/dev :profiles/dev]
             :test [:project/test :profiles/test]
             :profiles/dev {:dependencies [[org.clojure/clojure "1.8.0"]
                                           [criterium "0.4.4"]]}
             :profiles/test {}
             :project/dev {:source-paths ["dev"]
                           :repl-options {:init-ns user}}
             :project/test {:dependencies []}})

Switch to a namespaced artifact.

Switch to a namespaced artifact.


(defproject hello-world "0.20.0-SNAPSHOT"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.9.0"]
                 [uncomplicate/neanderthal "0.20.0-SNAPSHOT"]]
  :exclusions [[org.jcuda/jcuda-natives :classifier "apple-x86_64"]
               [org.jcuda/jcublas-natives :classifier "apple-x86_64"]])

(defproject hello-world "0.20.0"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.9.0"]
                 [uncomplicate/neanderthal "0.20.0"]]
  :exclusions [[org.jcuda/jcuda-natives :classifier "apple-x86_64"]
               [org.jcuda/jcublas-natives :classifier "apple-x86_64"]])

Update hello-world version to the latest release.


(ns incise.once
  (:require (incise [load :refer [load-parsers-and-layouts]]
                    [config :as conf]
                    [utils :refer [delete-recursively directory?]])
            [clojure.java.io :refer [file]]
            [incise.parsers.core :refer [parse-all-input-files]]
            [taoensso.timbre :refer [info]]
            (stefon [settings :refer [with-options]]
                    [core :refer [precompile]])))

(defn once
  "Incise just once. This requires that config is already loaded."
  [& {:as config}]
  (conf/merge! config)
  (conf/avow!)
  (let [{:keys [out-dir precompiles stefon in-dir]} (conf/get)
        manifest-file-path (.getPath (file in-dir "manifest.json"))]
    (info "Clearing out" (str \" out-dir \"))
    (delete-recursively (file out-dir))
    (with-options (merge {:mode :production
                          :serving-root out-dir
                          :manifest-file manifest-file-path
                          :precompiles (or precompiles [])} stefon)
      (info "Precompiling assets...")
      (precompile nil)
      (info "Done.")
      (load-parsers-and-layouts)
      (doall (parse-all-input-files)))))

(ns incise.once
  (:require (incise [load :refer [load-parsers-and-layouts]]
                    [config :as conf]
                    [utils :refer [delete-recursively directory?]])
            [clojure.java.io :refer [file]]
            [incise.parsers.core :refer [parse-all-input-files]]
            [taoensso.timbre :refer [info]]
            (stefon [settings :refer [with-options]]
                    [core :refer [precompile]])))

(defn once
  "Incise just once. This requires that config is already loaded."
  [& {:as config}]
  (conf/merge! config)
  (conf/avow!)
  (let [{:keys [out-dir precompiles stefon in-dir]} (conf/get)
        manifest-file-path (.getPath (file out-dir "manifest.json"))]
    (info "Clearing out" (str \" out-dir \"))
    (delete-recursively (file out-dir))
    (with-options (merge {:mode :production
                          :serving-root out-dir
                          :manifest-file manifest-file-path
                          :precompiles (or precompiles [])} stefon)
      (info "Precompiling assets...")
      (precompile nil)
      (info "Done.")
      (load-parsers-and-layouts)
      (doall (parse-all-input-files)))))

Use out-dir instead of in-dir for manifest.json.


;; 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.media
  "A media storage persistence layer."
  (:require [uxbox.media.proto :as p]
            [uxbox.media.fs :as fs]
            [uxbox.media.impl]))

(defn save
  "Perists a file or bytes in the storage. This function
  returns a relative path where file is saved.

  The final file path can be different to the one provided
  to this function and the behavior is totally dependen on
  the storage implementation."
  [storage path content]
  (p/-save storage path content))

(defn lookup
  "Resolve provided relative path in the storage and return
  the local filesystem absolute path to it.
  This method may be not implemented in all storages."
  [storage path]
  {:pre [(satisfies? p/ILocalStorage storage)]}
  (p/-lookup storage path))

(defn exists?
  "Check if a  relative `path` exists in the storage."
  [storage path]
  (p/-exists? storage path))

(defn delete
  "Delete a file from the storage."
  [storage path]
  (p/-delete storage path))

(defn path
  "Create path from string or more than one string."
  [fst & more]
  (if (seq more)
    (p/-path (cons fst more))
    (p/-path fst)))

;; 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.media
  "A media storage impl for uxbox."
  (:require [mount.core :as mount :refer (defstate)]
            [cuerdas.core :as str]
            [storages.core :as st]
            [storages.fs :refer (filesystem)]
            [storages.misc :refer (hashed)]
            [uxbox.config :refer (config)]))

(defn- resolve-basedir
  [^String basedir]
  (or (io/resource basedir)
      basedir))

(defn- initialize-storage
  [{:keys [basedir baseuri] :as config}]
  (let [basedir (resolve-basedir basedir)]
    (-> (filesystem {:basedir basedir
                     :baseuri baseuri})
        (hashed))))

(defstate storage
  :start (initialize-storage (:storage config)))

Add dedicated namespace for storage initialization.


(ns retroboard.config)

(def ws-url "ws://arcane-bastion-5301.herokuapp.com/ws")

(ns retroboard.config)

(def ws-url "ws://retroboard.herokuapp.com/ws")

Change prod env to retroboard.herokuapp.com


(ns flare.report-test
  (:require [clojure.test.check :as tc]
            [clojure.test.check.clojure-test :refer [defspec]]
            [clojure.test.check.generators :as gen]
            [clojure.test.check.properties :as prop]
            [clojure.test :refer [is deftest]]
            [flare.diff :refer [diff*]]
            [flare.generators :refer [distinct-values]]
            [flare.report :refer [report* report]]))

(deftest reports-swallows-exceptions-test
  (with-redefs [report* (fn [_] (throw (ex-info "what ever" {})))]
    (is (nil? (report :whatever)))))

(defspec generate-report-always-returns-non-empty-list-when-given-diffs
  100
  (prop/for-all [[a b] (distinct-values gen/any gen/any)]
                (not-empty (report (diff* a b)))))

(ns flare.report-test
  (:require [clojure.test.check :as tc]
            [clojure.test.check.clojure-test :refer [defspec]]
            [clojure.test.check.generators :as gen]
            [clojure.test.check.properties :as prop]
            [clojure.test :refer [is deftest]]
            [flare.diff :refer [diff*]]
            [flare.generators :refer [distinct-values]]
            [flare.report :refer [report* report]]))

(deftest reports-swallows-exceptions-test
  (with-redefs [report* (fn [_] (throw (ex-info "what ever" {})))]
    (is (nil? (report :whatever)))))

#_(defspec generate-report-always-returns-non-empty-list-when-given-diffs
  100
  (prop/for-all [[a b] (distinct-values gen/any gen/any)]
                (not-empty (report (diff* a b)))))

Disable generative test for now

Disable generative test for now


(ns logic.util)

(import '(org.sat4j.minisat SolverFactory)
        '(org.sat4j.minisat.core Solver)
        '(org.sat4j.core VecInt)
        '(org.sat4j.specs IProblem)
        '(org.sat4j.reader DimacsReader))

(defn sat4j-solve
  [dimacs-map]
  (let [solver (SolverFactory/newDefault)
        reader (DimacsReader. solver)
        clauses (:clauses dimacs-map)
        MAXVAR (:num-vars dimacs-map)
        NBCLAUSES (:num-clauses dimacs-map)]
    (.newVar solver MAXVAR)
    (.setExpectedNumberOfClauses solver NBCLAUSES)

    (doall (map
             #(.addClause solver (VecInt. (int-array (subvec % 0 (dec (count %))))))
             clauses))

    (if (.isSatisfiable solver)
      (do
        (println "Satisfiable!")
        (.decode reader (.model solver)))
      (println "Unsatisfiable!"))))

(defn sat-solve
  "Returns one result as vector. The vector is epmty if the formula is unsatisfiable."
  [dimacs-map]
  (let [res-str (sat4j-solve dimacs-map)]
    (if (nil? res-str)
              []
              (vec (filter #(not= 0 %) (map #(Integer. %) (clojure.string/split res-str #" ")))))))

(ns logic.util)

(import '(org.sat4j.minisat SolverFactory)
        '(org.sat4j.minisat.core Solver)
        '(org.sat4j.core VecInt)
        '(org.sat4j.specs IProblem)
        '(org.sat4j.reader DimacsReader))

(defn sat4j-solve
  [dimacs-map]
  (let [solver (SolverFactory/newDefault)
        reader (DimacsReader. solver)
        clauses (:clauses dimacs-map)
        MAXVAR (:num-vars dimacs-map)
        NBCLAUSES (:num-clauses dimacs-map)]
    (.newVar solver MAXVAR)
    (.setExpectedNumberOfClauses solver NBCLAUSES)

    (doall (map
             #(.addClause solver (VecInt. (int-array %)))
             clauses))

    (when (.isSatisfiable solver)
      (.decode reader (.model solver)))))

(defn sat-solve
  "Returns one result as vector. The vector is epmty if the formula is unsatisfiable."
  [dimacs-map]
  (let [res-str (sat4j-solve dimacs-map)]
    (if (nil? res-str)
              []
              (vec (filter #(not= 0 %) (map #(Integer. %) (clojure.string/split res-str #" ")))))))

Update sat4j-solve after changing generate-dimacs-clauses


(ns uxbox.ui.core
  (:require [beicon.core :as rx]))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Actions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defonce actions-lock (atom :nothing))
(defonce actions-s (rx/bus))

(defn acquire-action!
  [type]
  (when-let [result (compare-and-set! actions-lock :nothing type)]
    ;; (println "acquire-action!" type)
    (rx/push! actions-s type)))

(defn release-action!
  [type]
  (when-let [result (compare-and-set! actions-lock type :nothing)]
    ;; (println "release-action!" type)
    (rx/push! actions-s :nothing)))

(ns uxbox.ui.core
  (:require [beicon.core :as rx]))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Actions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defonce actions-lock (atom :nothing))
(defonce actions-s (rx/bus))

;; TODO: implement that as multimethod for add specific validation
;; layer for different kind of action payloads

(defn acquire-action!
  ([type]
   (acquire-action! type nil))
  ([type payload]
   (when-let [result (compare-and-set! actions-lock :nothing type)]
     (rx/push! actions-s {:type type :payload payload}))))

(defn release-action!
  [type]
  (when-let [result (compare-and-set! actions-lock type :nothing)]
    (rx/push! actions-s {:type :nothing})))

(defn release-all-actions!
  []
  (reset! actions-lock :nothing)
  (rx/push! actions-s {:type :nothing}))

Add the ability to actions subsystem pass payload.

Signed-off-by: Andrey Antukh <8e6a32ae7580b30ec348e03f34a0953d9b475a56@niwi.nz>


(defproject ring/ring-jetty-adapter "1.8.0"
  :description "Ring Jetty adapter."
  :url "https://github.com/ring-clojure/ring"
  :scm {:dir ".."}
  :license {:name "The MIT License"
            :url "http://opensource.org/licenses/MIT"}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [ring/ring-core "1.8.0"]
                 [ring/ring-servlet "1.8.0"]
                 [org.eclipse.jetty/jetty-server "9.4.24.v20191120"]]
  :aliases {"test-all" ["with-profile" "default:+1.8:+1.9:+1.10" "test"]}
  :profiles
  {:dev  {:dependencies [[clj-http "3.10.0"]]
          :jvm-opts ["-Dorg.eclipse.jetty.server.HttpChannelState.DEFAULT_TIMEOUT=500"]}
   :1.8  {:dependencies [[org.clojure/clojure "1.8.0"]]}
   :1.9  {:dependencies [[org.clojure/clojure "1.9.0"]]}
   :1.10 {:dependencies [[org.clojure/clojure "1.10.1"]]}})

(defproject ring/ring-jetty-adapter "1.8.0"
  :description "Ring Jetty adapter."
  :url "https://github.com/ring-clojure/ring"
  :scm {:dir ".."}
  :license {:name "The MIT License"
            :url "http://opensource.org/licenses/MIT"}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [ring/ring-core "1.8.0"]
                 [ring/ring-servlet "1.8.0"]
                 [org.eclipse.jetty/jetty-server "9.4.28.v20200408"]]
  :aliases {"test-all" ["with-profile" "default:+1.8:+1.9:+1.10" "test"]}
  :profiles
  {:dev  {:dependencies [[clj-http "3.10.0"]]
          :jvm-opts ["-Dorg.eclipse.jetty.server.HttpChannelState.DEFAULT_TIMEOUT=500"]}
   :1.8  {:dependencies [[org.clojure/clojure "1.8.0"]]}
   :1.9  {:dependencies [[org.clojure/clojure "1.9.0"]]}
   :1.10 {:dependencies [[org.clojure/clojure "1.10.1"]]}})

Update Jetty version to 9.4.28.v20200408


(ns brew-monitor.test-data-creator
  (:require [clojurewerkz.elastisch.rest :as es]
            [clojurewerkz.elastisch.rest.document :as esd]
            [clj-time.core :as time]
            [clj-time.format :as time-f]))

(def temps [20.0, 20.1, 20.2, 20.3, 20.5, 20.7, 21.0, 22.0, 21.9, 21.9, 21.8, 19.0, 19.5, 19.8, 19.9])

(def repeated-temps (cycle temps))

(defn get-iso-time []
  (time-f/unparse (time-f/formatters :date-time) (time/now)))

(defn send-temp [temp]
  (let [conn (es/connect "http://localhost:9200")
        doc { :time (get-iso-time), :temp temp }]
    (esd/create conn "temp_gauge" "reading" doc)))

(defn -main []
  (doseq [temp repeated-temps]
    (send-temp temp)
    (Thread/sleep 10000)))

(ns brew-monitor.test-data-creator
  (:require [clojurewerkz.elastisch.rest :as es]
            [clojurewerkz.elastisch.rest.document :as esd]
            [clj-time.core :as time]
            [clj-time.format :as time-f]))

(def temps [20.0, 20.1, 20.2, 20.3, 20.5, 20.7, 21.0, 22.0, 21.9, 21.9, 21.8, 19.0, 19.5, 19.8, 19.9])

(def repeated-temps (cycle temps))

(defn get-iso-time []
  (time-f/unparse (time-f/formatters :date-time) (time/now)))

(defn send-temp [temp]
  (let [conn (es/connect "http://localhost:9200")
        doc { :time (get-iso-time), :temp temp }]
    (esd/create conn "temp_gauge" "reading" doc)))

(defn -main []
  (doseq [temp repeated-temps]
    (send-temp temp)
    (Thread/sleep 1000)))

Test data creator updates every second

Test data creator updates every second

10 seconds is toooo slow


(ns lt.util.ipc
  "Util functions for the ipc renderer - https://github.com/atom/electron/blob/master/docs/api/ipc-renderer.md")

(def ipc "Provides access to the ipc renderer." (.-ipcRenderer (js/require "electron")))

;; `send` and `on` are declared here with their bodies defined later as otherwise Codox will use the
;; redefined `send` and `on` in the below when block instead.
(declare send)

(declare on)

;; Set $IPC_DEBUG to debug incoming and outgoing ipc messages for the renderer process
(when (aget js/process.env "IPC_DEBUG")
  (let [old-send send
        old-on on]
    (def send (fn [& args]
                (prn "RENDERER->" args)
                (apply old-send args)))
    (def on (fn [channel cb]
              (old-on channel (fn [_ & args]
                                (prn "->RENDERER" channel args)
                                (apply cb args)))))))

(defn send
  "Delegates to ipc.send, which asynchronously sends args to the browser process's channel."
  [channel & args]
  (apply (.-send ipc) channel (clj->js args)))

(defn on
  "Delegates to ipc.on, which defines a callback to fire for the given channel."
  [channel cb]
  (.on ipc channel cb))

(ns lt.util.ipc
  "Util functions for the ipc renderer - https://github.com/atom/electron/blob/master/docs/api/ipc-renderer.md")

(def ipc "Provides access to the ipc renderer." (.-ipcRenderer (js/require "electron")))

;; `send` and `on` are declared here with their bodies defined later as otherwise Codox will use the
;; redefined `send` and `on` in the below when block instead.
(declare transport)

(declare start)

;; Set $IPC_DEBUG to debug incoming and outgoing ipc messages for the renderer process
(when (aget js/process.env "IPC_DEBUG")
  (let [old-send transport
        old-on start]
    (def transport (fn [& args]
                     (prn "RENDERER->" args)
                     (apply old-send args)))
    (def start (fn [channel cb]
                 (old-on channel (fn [_ & args]
                                   (prn "->RENDERER" channel args)
                                   (apply cb args)))))))

(defn send
  "Delegates to ipc.send, which asynchronously sends args to the browser process's channel."
  [channel & args]
  (apply (.-send ipc) channel (clj->js args)))

(defn on
  "Delegates to ipc.on, which defines a callback to fire for the given channel."
  [channel cb]
  (.on ipc channel cb))

Fix warnings which block the CI builds

Fix warnings which block the CI builds

Signed-off-by: Pratik Karki <48ee16e89cc3ed79ec6f449232f648624dd8c0a8@gmail.com>


(ns fcms.lib.http-mock)

(def req) ; mock HTTP request
(def bod) ; body of the mock HTTP request or response
(def resp) ; mock HTTP response

(defn request
  ([] req)
  ([new-req] (def req new-req)))

(defn body
  ([] bod)
  ([new-body] (def bod new-body)))

(defn response
  ([] resp)
  ([new-resp] (def resp new-resp)))

(ns fcms.lib.http-mock)

(def mock-data (atom {:request {} :body "" :response {}}))

(defn request
  ([] (:request @mock-data))
  ([new-request] (swap! mock-data assoc :request new-request)))

(defn body
  ([] (:body @mock-data))
  ([new-body] (swap! mock-data assoc :body new-body)))

(defn response
  ([] (:response @mock-data))
  ([new-response] (swap! mock-data assoc :response new-response)))

Change how the mock data state is held for cucumber tests.


(ns incise.parsers.helpers
  (:require (clj-time [core :as tm]
                      [coerce :as tc])
            [clojure.string :as s])
  (:import [java.io File]))

(defn dashify
  "Dashify a title, replacing all non word characters with a dash."
  [^String title]
  (str \/ (-> title
              (s/lower-case)
              (s/replace #"[^\w]" "-"))))

(defn date-time->path
  "Convert a DateTime to a path like string."
  [date-time]
  (str (when date-time
         (str \/ (tm/year date-time)
              \/ (tm/month date-time)
              \/ (tm/day date-time)))))

(def date-str->path (comp date-time->path tc/from-string))

(defn Parse->path
  [^Parse {:keys [date title extension]}]
  (str (date-str->path date) (dashify title) extension))

(defn extension [^File file]
  "Get the extension, enforcing lower case, on the given file."
  (-> file
      (.getName)
      (s/split #"\.")
      (last)
      (s/lower-case)))

(ns incise.parsers.helpers
  (:require (clj-time [core :as tm]
                      [coerce :as tc])
            [clojure.string :as s])
  (:import [java.io File]))

(defn dashify
  "Dashify a title, replacing all non word characters with a dash."
  [^String title]
  (-> title
      (s/lower-case)
      (s/replace #"[^\w]" "-")))

(defn date-time->path
  "Convert a DateTime to a path like string."
  [date-time]
  (str (when date-time
         (str (tm/year date-time) \/
              (tm/month date-time) \/
              (tm/day date-time) \/))))

(def date-str->path (comp date-time->path tc/from-string))

(defn Parse->path
  [^Parse {:keys [path layout date title extension]}]
  (or path
      (str (when (= layout :post) (date-str->path date))
           (dashify title)
           extension)))

(defn extension [^File file]
  "Get the extension, enforcing lower case, on the given file."
  (-> file
      (.getName)
      (s/split #"\.")
      (last)
      (s/lower-case)))

Change how path creating is done slightly, allowing path override.


(ns mikron.test.core-macros
  "Unit tests for each processor."
  (:require [clojure.test :as test]
            [mikron.runtime.core :as mikron]
            [mikron.compiler.util :as compiler.util])
  #?(:cljs (:require-macros [mikron.test.core-macros])))

(defmulti test-mikron
  "Test function for :pack, :diff, :valid? and :interp processors."
  (fn [method schema dataset] method))

(defmacro def-mikron-tests
  "Generates test methods for all the test cases."
  [test-methods test-cases]
  (compiler.util/macro-context {:gen-syms [schema dataset]}
    `(do ~@(for [[schema-name schema-def] test-cases]
             `(let [~schema  (mikron/schema ~schema-def :diff true :interp true)
                    ~dataset (repeatedly 100 #(mikron/gen ~schema))]
                ~@(for [method test-methods]
                    `(test/deftest ~(gensym (str (name method) "-" (name schema-name)))
                       (test-mikron ~method ~schema ~dataset))))))))

(ns mikron.test.core-macros
  "Unit tests for each processor."
  (:require [clojure.test :as test]
            [mikron.runtime.core :as mikron]
            [mikron.compiler.util :as compiler.util])
  #?(:cljs (:require-macros [mikron.test.core-macros])))

(defmulti test-mikron
  "Test function for :pack, :diff, :valid? and :interp processors."
  (fn [method schema dataset] method))

(defmacro def-mikron-tests
  "Generates test methods for all the test cases."
  [test-methods test-cases]
  (compiler.util/macro-context {:gen-syms [schema dataset]}
    `(do ~@(for [[schema-name schema-def] test-cases]
             `(let [~schema  (mikron/schema ~schema-def :diff-paths true :interp-paths true)
                    ~dataset (repeatedly 100 #(mikron/gen ~schema))]
                ~@(for [method test-methods]
                    `(test/deftest ~(gensym (str (name method) "-" (name schema-name)))
                       (test-mikron ~method ~schema ~dataset))))))))

Fix `diff-paths` and `interp-paths` in tests


(ns test-run
  (:use [clojure.test]
        [clojure.java.io :only [delete-file]]
        [leiningen.core :only [read-project]]
        [leiningen.run]
        [leiningen.util.file :only [tmp-dir]]))

(def out-file (format "%s/lein-test" tmp-dir))

(def project (binding [*ns* (find-ns 'leiningen.core)]
               (read-project "test_projects/tricky-name/project.clj")))

(use-fixtures :each (fn [f]
                      (delete-file out-file :silently)
                      (f)))

(deftest test-basic
  (is (zero? (run project "1")))
  (is (= "nom:1" (slurp out-file))))

(deftest test-alt-main
  (is (zero? (run project "-m" "org.domain.tricky-name.munch" "1")))
  (is (= ":munched (\"1\")" (slurp out-file))))

(deftest test-aliases
    (is (zero? (run project ":bbb" "1")))
    (is (= "BRUNCH" (slurp out-file)))
    (delete-file out-file :silently)
    (is (zero? (run project ":mmm" "1")))
    (is (= ":munched (\"1\")" (slurp out-file))))

(ns test-run
  (:use [clojure.test]
        [clojure.java.io :only [delete-file]]
        [leiningen.core :only [read-project]]
        [leiningen.run]
        [leiningen.util.file :only [tmp-dir]]))

(def out-file (format "%s/lein-test" tmp-dir))

(def project (binding [*ns* (find-ns 'leiningen.core)]
               (read-project "test_projects/tricky-name/project.clj")))

(use-fixtures :each (fn [f]
                      (delete-file out-file :silently)
                      (f)))

(deftest test-basic
  (is (zero? (run project "1")))
  (is (= "nom:1" (slurp out-file))))

(deftest test-alt-main
  (is (zero? (run project "-m" "org.domain.tricky-name.munch" "1")))
  (is (= ":munched (\"1\")" (slurp out-file))))

(deftest test-aliases
    (is (zero? (run project ":bbb" "1")))
    (is (= "BRUNCH" (slurp out-file)))
    (delete-file out-file :silently)
    (is (zero? (run project ":mmm" "1")))
    (is (= ":munched (:mmm \"1\")" (slurp out-file))))

Fix test to reflect run task bugfix.

Fix test to reflect run task bugfix.


(ns langnostic.files
  (:require [markdown.core :as md]

            [clojure.java.io :as io]))

(def resources (.getCanonicalFile (io/file "resources")))

(defn file-in? [file path]
  (.startsWith (.getPath (.getCanonicalFile file))
               (.getPath (.getCanonicalFile path))))

(defn file-in-resources? [file]
  (file-in? file resources))

(defn linkify-headers [text state]
  [(if (or (state :heading) (state :inline-heading))
     (let [[_ hn text] (re-find #"<(h\d)>(.*?)</\1>" text)
           name (clojure.string/replace (.toLowerCase text) #"\W+" "-")]
       (str "<" hn ">"
            ""
            ""
            text
            "</" hn ">"))
     text)
   state])

(defn file-content [fname]
  (md/md-to-html-string
   (slurp fname)
   :custom-transformers [linkify-headers]
   :replacement-transformers (remove #(= % markdown.common/dashes) markdown.transformers/transformer-vector)
   :footnotes? true))

(ns langnostic.files
  (:require [markdown.core :as md]

            [clojure.java.io :as io]))

(def resources (.getCanonicalFile (io/file "resources")))

(defn file-in? [file path]
  (.startsWith (.getPath (.getCanonicalFile file))
               (.getPath (.getCanonicalFile path))))

(defn file-in-resources? [file]
  (file-in? file resources))

(defn linkify-headers [text state]
  [(if (or (state :heading) (state :inline-heading))
     (let [[_ hn text] (re-find #"<(h\d)>(.*?)</\1>" text)
           name (clojure.string/replace (.toLowerCase text) #"\W+" "-")]
       (str "<" hn ">"
            ""
            ""
            text
            "</" hn ">"))
     text)
   state])

(def new-transformers
  (concat
   (remove #(= % markdown.common/dashes) markdown.transformers/transformer-vector)
   [linkify-headers]))

(defn file-content [fname]
  (md/md-to-html-string
   (slurp fname)
   :replacement-transformers new-transformers
   :footnotes? true))

Fix bug with linkifying headers

Fix bug with linkifying headers


(use 'cucumber.runtime.clojure.belly)

(def some-state (atom "'Before' hasn't run."))

(Before []
  (reset! some-state "'Before' has run.")
  (println "Executing 'Before'."))

(After []
  (println (str "Executing 'After' " @some-state)))

(Given #"^I have (\d+) cukes in my belly$" [cuke-count]
  (eat (Float. cuke-count)))

(Given #"^I have this many cukes in my belly:$" [cuke-table]
  (doseq [x (.raw cuke-table)] (eat (Float. (first x)))))

(When #"^there are (\d+) cukes in my belly$" [expected]
  (assert (= (last-meal) (Float. expected))))

(Then #"^the (.*) contains (.*)$" [container ingredient]
  (assert (= "glass" container)))

(When #"^I add (.*)$" [liquid]
  (assert (= "milk" liquid)))

(Given #"^(\d+) unimplemented step$" [arg1]
  (comment  Express the Regexp above with the code you wish you had  )
  (throw (cucumber.runtime.PendingException.)))

(use 'cucumber.runtime.clojure.belly)

(def some-state (atom "'Before' hasn't run."))

(Before []
  (reset! some-state "'Before' has run.")
  (println "Executing 'Before'."))

(After []
  (println (str "Executing 'After' " @some-state)))

(Given #"^I have (\d+) cukes in my belly$" [cuke-count]
  (eat (Float. cuke-count)))

(Given #"^I have this many cukes in my belly:$" [cuke-table]
  (doseq [x (.raw cuke-table)] (eat (Float. (first x)))))

(When #"^there are (\d+) cukes in my belly$" [expected]
  (assert (= (last-meal) (Float. expected))))

(Then #"^the (.*) contains (.*)$" [container ingredient]
  (assert (= "glass" container)))

(When #"^I add (.*)$" [liquid]
  (assert (= "milk" liquid)))

(Given #"^(\d+) unimplemented step$" [arg1]
  (comment  Express the Regexp above with the code you wish you had  )
  (throw (cucumber.runtime.PendingException. "This is pending. Seeing a stacktrace here is normal.")))

Add a message ensuring that a stack trace here is normal. At least until stack trace filtering is implemented in the clojure module.


(defproject dropout "0.1.0-SNAPSHOT"
  :description "Cortex dropout example project implementing http://jmlr.org/papers/volume15/srivastava14a/srivastava14a.pdf"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.8.0"]
                 [thinktopic/cortex "0.1.1-SNAPSHOT"]
                 [thinktopic/cortex-datasets "0.1.0"]
                 [thinktopic/cortex-gpu "0.1.0-SNAPSHOT"]
                 [net.mikera/imagez "0.10.0"]
                 [thinktopic/tsne-core "0.1.0-SNAPSHOT"]
                 [incanter/incanter-core "1.5.7"]
                 [incanter/incanter-charts "1.5.7"]]

  :main dropout.core)

(defproject dropout "0.1.0-SNAPSHOT"
  :description "Cortex dropout example project implementing http://jmlr.org/papers/volume15/srivastava14a/srivastava14a.pdf"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.8.0"]
                 [thinktopic/cortex "0.1.1-SNAPSHOT"]
                 [thinktopic/cortex-datasets "0.1.0"]
                 [thinktopic/cortex-gpu "0.1.0-SNAPSHOT"]
                 [net.mikera/imagez "0.10.0"]
                 [thinktopic/tsne-core "0.1.0"]
                 [incanter/incanter-core "1.5.7"]
                 [incanter/incanter-charts "1.5.7"]]

  :main dropout.core)

Switch to using release version of tsne lib


(ns {{ns-name}}.views
    (:require [re-frame.core :as re-frame]))

;; home

(defn home-panel []
  (let [name (re-frame/subscribe [:name])]
    (fn []
      [:div (str "Hello from " @name ". This is the Home Page.")
       [:div [:a {:href "#/about"} "go to About Page"]]])))

;; about

(defn about-panel []
  (fn []
    [:div "This is the About Page."
     [:div [:a {:href "#/"} "go to Home Page"]]]))

;; main

(defmulti panels identity)
(defmethod panels :home-panel [] [home-panel])
(defmethod panels :about-panel [] [about-panel])
(defmethod panels :default [] [:div])

(defn main-panel []
  (let [active-panel (re-frame/subscribe [:active-panel])]
    (fn []
      [panels @active-panel])))

(ns {{ns-name}}.views
    (:require [re-frame.core :as re-frame]))

;; home

(defn home-panel []
  (let [name (re-frame/subscribe [:name])]
    (fn []
      [:div (str "Hello from " @name ". This is the Home Page.")
       [:div [:a {:href "#/about"} "go to About Page"]]])))

;; about

(defn about-panel []
  (fn []
    [:div "This is the About Page."
     [:div [:a {:href "#/"} "go to Home Page"]]]))

;; main

(defmulti panels identity)
(defmethod panels :home-panel [] [home-panel])
(defmethod panels :about-panel [] [about-panel])
(defmethod panels :default [] [:div])

(defn show-panel
  [panel-name]
  [panels panel-name])

(defn main-panel []
  (let [active-panel (re-frame/subscribe [:active-panel])]
    (fn []
      [show-panel @active-panel])))

Fix use of form-2 components with multimethods


(ns braid.core.client.ui.styles.reconnect-overlay
  (:require
   [braid.core.client.ui.styles.mixins :as mixins]
   [braid.core.client.ui.styles.vars :as vars]
   [garden.arithmetic :as m]))

(def reconnect-overlay
  [:>.reconnect-overlay
   {:position "absolute"
    :bottom 0
    :left 0
    :right 0
    :top 0
    :background "rgba(242,242,242,0.75)"
    :z-index 5000}

   [:>.info
    {:position "absolute"
     :bottom vars/pad
     :height (m/* vars/pad 4)
     :left 0
     :right 0
     :padding vars/pad
     :box-sizing "border-box"
     :background "red"
     :color "white"
     :z-index 5001}

    [:>h1
     {:font-size "1em"
      :margin 0}]

    [:>.message

     [:>button
      (mixins/outline-button {:text-color "#fff"
                              :border-color "#fff"
                              :hover-text-color "#fff"
                              :hover-border-color "fff"})]]]])

(ns braid.core.client.ui.styles.reconnect-overlay
  (:require
   [braid.core.client.ui.styles.mixins :as mixins]
   [braid.core.client.ui.styles.vars :as vars]
   [garden.arithmetic :as m]))

(def reconnect-overlay
  [:>.reconnect-overlay
   {:position "absolute"
    :bottom 0
    :left 0
    :right 0
    :top 0
    :background "rgba(242,242,242,0.75)"
    :z-index 10000}

   [:>.info
    {:position "absolute"
     :bottom vars/pad
     :height (m/* vars/pad 4)
     :left 0
     :right 0
     :padding vars/pad
     :box-sizing "border-box"
     :background "red"
     :color "white"
     :z-index 5001}

    [:>h1
     {:font-size "1em"
      :margin 0}]

    [:>.message

     [:>button
      (mixins/outline-button {:text-color "#fff"
                              :border-color "#fff"
                              :hover-text-color "#fff"
                              :hover-border-color "fff"})]]]])

Fix reconnect-overlay being under sidebar


(ns berry.lexical-analysis.scan-number
    (:require [berry.lexical-analysis.context-handler :refer [++ --]]
            [berry.lexical-analysis.character :refer :all]
            [berry.lexical-analysis.error-handler :refer :all]
            [berry.lexical-analysis.token :as token]))

(defn scan-number
  [source context buffer]
  )

(ns berry.lexical-analysis.scan-number
  (:require [berry.lexical-analysis.context-handler :refer [++ --]]
            [berry.lexical-analysis.character :refer :all]
            [berry.lexical-analysis.error-handler :refer :all]
            [berry.lexical-analysis.token :as token]))

(declare scan-digits handle-end-of-input handle-non-digit
         ends-with-digit? scan-fractional-part scan-exponential-part)

(defn scan-number
  [source buffer context]
  (let [char (first source)]
    (cond
      (empty? source)
      (handle-end-of-input buffer context)
      (dot? char)
      (scan-fractional-part (rest source)
                            (conj buffer char)
                            (++ context))
      (exponent-sign? char)
      (scan-exponential-part (rest source)
                             (conj buffer char)
                             (++ context))
      (not (digit? char))
      (handle-non-digit char buffer context)
      :else
      (recur (rest source)
             (conj buffer char)
             (++ context)))))

(defn- handle-end-of-input [buffer context]
  (if (digit? (last buffer))
    (token/number buffer context)
    (unexpected-end-of-input context)))

(defn- scan-fractional-part
  [source buffer context]
  (let [char (first source)]
    (cond
      (nil? char)
      (handle-end-of-input buffer context)
      (and (exponent-sign? char) (ends-with-digit? buffer))
      (scan-exponential-part (rest source)
                             (conj buffer char)
                             (++ context))
      (not (digit? char))
      (handle-non-digit char buffer context)
      :else
      (recur (rest source)
             (conj buffer char)
             (++ context)))))

(defn- scan-exponential-part
  [source buffer context]
  (let [char (first source)]
    (cond
      (nil? char)
      (unexpected-end-of-input context)
      (or (plus-sign? char) (minus-sign? char) (digit? char))
      (scan-digits (rest source)
                   (conj buffer char)
                   (++ context))
      :else
      (unexpected-token char context))))

(defn- scan-digits
  [source buffer context]
  (let [char (first source)]
    (cond
      (empty? source)
      (handle-end-of-input buffer context)
      (not (digit? char))
      (handle-non-digit char buffer context)
      :else
      (recur (rest source)
             (conj buffer char)
             (++ context)))))

(defn- handle-non-digit
  [char buffer context]
  (if (ends-with-digit? buffer)
    (token/number buffer context)
    (unexpected-token char context)))

(defn- ends-with-digit?
  [buffer]
  (digit? (last buffer)))

Improve the function scan-number (tests and refactoring will be necessary yet).


(ns kiries.layout
  (:use hiccup.core)
  (:use hiccup.page))

(defn full-layout [title & content]
  (html5
   [:head
    (include-css "/kibana/common/css/bootstrap.light.min.css")
    (include-css "/kibana/common/css/bootstrap-responsive.min.css")
    (include-css "/kibana/common/css/font-awesome.min.css")
    [:title title]]
   [:body
    [:div.container-fluid.main
     [:div.row-fluid
      content]]]))

(ns kiries.layout
  (:use hiccup.core)
  (:use hiccup.page))

(defn full-layout [title & content]
  (html5
   [:head
    (include-css "/kibana/css/bootstrap.light.min.css")
    (include-css "/kibana/css/bootstrap-responsive.min.css")
    (include-css "/kibana/css/font-awesome.min.css")
    [:title title]]
   [:body
    [:div.container-fluid.main
     [:div.row-fluid
      content]]]))

Update CSS to point at new Kibana.

Update CSS to point at new Kibana.


(ns mikron.runtime.test-util
  (:require [mikron.runtime.processor.validate :as runtime.processor.validate]
            [clojure.walk :as walk])
  #?(:clj (:import [java.util Arrays])))

(defn nan?
  "Returns `true` if value is NaN, `false otherwise`."
  [value]
  #?(:clj  (Double/isNaN value)
     :cljs (js/isNaN value)))

#?(:cljs
   (defn arraybuffer->seq
     "Converts an ArrayBuffer `value` to a sequence."
     [value]
     (seq (.from js/Array (js/Int8Array. value)))))

(defn fix-for-equality*
  "Returns a more 'equal friendly' value, if necessary."
  [value]
  (condp contains? (type value)
    #{runtime.processor.validate/binary-type}
    [:mikron/binary #?(:clj  (seq value)
                       :cljs (arraybuffer->seq value))]

    #?(:clj  #{java.lang.Double java.lang.Float}
       :cljs #{js/Number})
    (if (nan? value)
      :mikron/nan
      (double value))

    value))

(defn fix-for-equality
  "Returns a more 'equal friendly' value, if necessary."
  [value]
  (walk/postwalk fix-for-equality* value))

(defn equal?
  "Checks whether the given values are equal."
  [value-1 value-2]
  (= (fix-for-equality value-1)
     (fix-for-equality value-2)))

(ns mikron.runtime.test-util
  (:require [clojure.walk :as walk]
            [mikron.runtime.processor.validate :as runtime.processor.validate]))

(defn nan?
  "Returns `true` if value is NaN, `false otherwise`."
  [value]
  #?(:clj  (Double/isNaN value)
     :cljs (js/isNaN value)))

#?(:cljs
   (defn arraybuffer->seq
     "Converts an ArrayBuffer `value` to a sequence."
     [value]
     (seq (.from js/Array (js/Int8Array. value)))))

(defn fix-for-equality*
  "Returns a more 'equal friendly' value, if necessary."
  [value]
  (condp contains? (type value)
    #{runtime.processor.validate/binary-type}
    [:mikron/binary #?(:clj  (seq value)
                       :cljs (arraybuffer->seq value))]

    #?(:clj  #{java.lang.Double java.lang.Float}
       :cljs #{js/Number})
    (if (nan? value)
      :mikron/nan
      (double value))

    value))

(defn fix-for-equality
  "Returns a more 'equal friendly' value, if necessary."
  [value]
  (walk/postwalk fix-for-equality* value))

(defn equal?
  "Checks whether the given values are equal."
  [value-1 value-2]
  (= (fix-for-equality value-1)
     (fix-for-equality value-2)))

Clean up test-util ns form

Clean up test-util ns form


(ns lambdaui.trigger
  (:require [clojure.core.async :as async]
            [lambdacd.execution :as execution]
            [clojure.walk :refer [keywordize-keys]]))

;{:post [(v/is-not-nil-or-empty? (:branch (:global %)))
;        (v/is-not-nil-or-empty? (:revision (:global %)))
;        (v/is-valid-revision? (:revision (:global %)))]}

(defn trigger-new-build [{pipeline-def :pipeline-def context :context} {query-param :query-params}]
  (async/thread

    ;(println "Starting new build " )
    ;(when-let [git-commit (:git (keywordize-keys query-param))] (println "requested commit was" git-commit))
    (execution/run pipeline-def context)
    ))

(ns lambdaui.trigger
  (:require [clojure.core.async :as async]
            [clojure.walk :refer [keywordize-keys]]
            [lambdacd.execution.core :as execution-core]))

;{:post [(v/is-not-nil-or-empty? (:branch (:global %)))
;        (v/is-not-nil-or-empty? (:revision (:global %)))
;        (v/is-valid-revision? (:revision (:global %)))]}

(defn trigger-new-build [{pipeline-def :pipeline-def context :context} {query-param :query-params}]
  (async/thread

    ;(println "Starting new build " )
    ;(when-let [git-commit (:git (keywordize-keys query-param))] (println "requested commit was" git-commit))
    (execution-core/run-pipeline pipeline-def context)
    ))

Replace deprecated lambdad.execution/run function with the current alternative


(ns user
  (:use
    clojure.repl
    io.aviso.repl
    io.aviso.logging
    speclj.config))

(install-pretty-exceptions)
(install-pretty-logging)
(install-uncaught-exception-handler)

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

(ns user
  (:use
    clojure.repl
    io.aviso.repl
    io.aviso.exception
    io.aviso.logging
    speclj.config))

(install-pretty-exceptions)
(install-pretty-logging)
(install-uncaught-exception-handler)

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

(alter-var-root #'*default-frame-filter*
                (fn [default]
                  (fn [frame]
                    (if (-> frame :name (.startsWith "speclj."))
                      :terminate
                      (default frame)))))

Terminate stack listings when the speclj functions are reached


(ns lambdaui.dummy-data
  (:require [ring.util.response :refer [response]]))

(def summaries {:summaries [{:buildId   1
                             :state     :running
                             :startTime "11pm"              ; TODO decide on format (ISO timestamp?)
                             :duration  "30 seconds"        ; TODO decide on format (maybe seconds?)
                             },
                            {:corrupted :build}
                            ]

                })

(defn hello-response [] (response "haallo welt"))
(defn build-summaries [] (response summaries))

(ns lambdaui.dummy-data
  (:require [ring.util.response :refer [response header]]))

(def summaries {:summaries [{:buildId   1
                             :buildNumber 1                 ; TODO differentiate between build Number (alias) and id?
                             :state     :running
                             :startTime "11pm"              ; TODO decide on format (ISO timestamp?)
                             :duration  "30 seconds"        ; TODO decide on format (maybe seconds?)
                             },
                            {:corrupted :build}
                            ]

                })

(defn hello-response [] (response "haallo welt"))
(defn build-summaries [] (header (response summaries) "Access-Control-Allow-Origin" "*"))

Add CORS header. Add buildNumber attribute to BuildSummaries


(ns lexemic.core
  (:require [lexemic.sentiment.simple :as sentiment]))

(def ^:private usage-banner "Usage: lexemic [command] [target]")
(def ^:private supported-commands #{"help" "sentiment"})

(defn- show-help []
  (do
    (println usage-banner)))

(defn- run [cmd text]
  (condp = cmd
    "sentiment" (println (sentiment/analyse text))))

(defn -main [& args]
  (let [command (first args)
        input (second args)]
    (if-let [cmd (supported-commands command)]
      (run cmd input)
      (show-help))))

(set! *main-cli-fn* -main)

(ns lexemic.core
  (:require [cljs.nodejs :as node]
            [lexemic.sentiment.simple :as sentiment]))

(def ^:private fs
  (node/require "fs"))

(def ^:private usage-banner "Usage: lexemic [command] [target]")
(def ^:private supported-commands #{"help" "sentiment"})

(defn- help []
  (str usage-banner))

(defn- run [cmd text]
  (condp = cmd
    "sentiment" (sentiment/analyse text)))

(defn -main [& args]
  (let [command (first args)
        target (second args)
        input (if (.existsSync fs target)
                (.readFileSync fs target "utf8")
                target)]
    (if-let [cmd (supported-commands command)]
      (println (run cmd input))
      (println (help)))))

(set! *main-cli-fn* -main)

Add support for sentiment analysis from file.


(ns subman.const)

(def db-host "http://127.0.0.1:9200")

(def index-name "subman7")

(def type-all -1)

(def type-addicted 0)

(def type-podnapisi 1)

(def type-opensubtitles 2)

(def type-subscene 3)

(def type-none -2)

(def type-names {type-addicted "Addicted"
                 type-podnapisi "Podnapisi"
                 type-opensubtitles "OpenSubtitles"
                 type-subscene "Subscene"
                 type-all "all"})

(def update-deep 10)

(def update-period (* 5 60 1000))

(def result-size 100)

(def default-port "3000")

(def conection-timeout 1000)

(def static-path "/static/")

(def show-name-boost 5)

(def version-boost 2)

(def languages-limit 100)

(def autocomplete-limit 5)

(def default-language "english")

(def default-type type-all)

(ns subman.const)

(def db-host "http://127.0.0.1:9200")

(def index-name "subman7")

(def type-all -1)

(def type-addicted 0)

(def type-podnapisi 1)

(def type-opensubtitles 2)

(def type-subscene 3)

(def type-none -2)

(def type-names {type-addicted "Addicted"
                 type-podnapisi "Podnapisi"
                 type-opensubtitles "OpenSubtitles"
                 type-subscene "Subscene"
                 type-all "all"})

(def update-deep 50)

(def update-period (* 5 60 1000))

(def result-size 100)

(def default-port "3000")

(def conection-timeout 1000)

(def static-path "/static/")

(def show-name-boost 5)

(def version-boost 2)

(def languages-limit 100)

(def autocomplete-limit 5)

(def default-language "english")

(def default-type type-all)

Increase indexing deep to 50

Increase indexing deep to 50


(defproject wort "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/data.json "0.2.6"]
                 [com.amazonaws/aws-lambda-java-core "1.0.0"]
                 [uswitch/lambada "0.1.2"]
                 [pjstadig/humane-test-output "0.8.2"]
                 [compojure "1.6.0"]
                 [ring/ring-defaults "0.2.1"]]
  :ring {:handler wort.handler/app}
  :injections [(require 'pjstadig.humane-test-output)
               (pjstadig.humane-test-output/activate!)]
  :plugins [[lein-cljfmt "0.5.6"]
	    [lein-ring "0.9.7"]]
  :main ^:skip-aot wort.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})

(defproject wort "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/data.json "0.2.6"]
                 [com.amazonaws/aws-lambda-java-core "1.0.0"]
                 [uswitch/lambada "0.1.2"]
                 [pjstadig/humane-test-output "0.8.2"]
                 [compojure "1.6.0"]
                 [ring/ring-defaults "0.2.1"]]
  :ring {:handler wort.handler/app}
  :injections [(require 'pjstadig.humane-test-output)
               (pjstadig.humane-test-output/activate!)]
  :plugins [[lein-cljfmt "0.5.6"]
	    [lein-ring "0.12.1"]]
  :main ^:skip-aot wort.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})

Update dependencies to latest version

compojure-server: Update dependencies to latest version


(ns overtone.synth.sampled-piano
  (:use [overtone.core]
        [overtone.samples.piano :only [index-buffer]]))

(defsynth sampled-piano
  [note 60 level 1 rate 1 loop? 0
   attack 0 decay 1 sustain 1 release 0.1 curve -4 gate 1 out-bus 0]
  (let [buf (index:kr (:id index-buffer) note)
        env (env-gen (adsr attack decay sustain release level curve)
                     :gate gate
                     :action FREE)]
    (out out-bus (* env (scaled-play-buf 2 buf :level level :loop loop? :action FREE)))))

(ns overtone.synth.sampled-piano
  (:use [overtone.core]
        [overtone.samples.piano :only [index-buffer]]))

(defsynth sampled-piano
  [note 60 level 1 rate 1 loop? 0
   attack 0 decay 1 sustain 1 release 0.1 curve -4 gate 1 out-bus 0 amp 1]
  (let [buf (index:kr (:id index-buffer) note)
        env (env-gen (adsr attack decay sustain release level curve)
                     :gate gate
                     :action FREE)]
    (out out-bus (* env amp (scaled-play-buf 2 buf :level level :loop loop? :action FREE)))))

Add amp param to sampled-piano synth

Add amp param to sampled-piano synth


(ns made-merits.service.winner-calculator
  (:require [clojure.set :as set]
            [clojure.walk :as walk]))

(defn- with-status
  [scored-users]
  (let [max-score (apply max (map :score scored-users))]
    (vec (map (fn [scored-user]
                (assoc scored-user
                       :status
                       (if (= max-score (:score scored-user))
                         "winner"
                         "loser")))
              scored-users))))

(defn- mark-everyone-as-a-loser
  [users-with-status]
  (map
    (fn [user-with-status]
      (assoc user-with-status :status "loser"))
    users-with-status))

(defn- more-than-one-winner?
  [users-with-status]
  (not= 1
        (:winner
          (walk/keywordize-keys
            (frequencies
              (map :status users-with-status))))))

(defn with-winner
  [scored-users]
  (let [users-with-status (with-status scored-users)]
    (if (more-than-one-winner? users-with-status)
      (mark-everyone-as-a-loser users-with-status)
      users-with-status)))

(ns made-merits.service.winner-calculator
  (:require [clojure.set :as set]
            [clojure.walk :as walk]))

(defn with-winner
  [scored-users]
  (let [users-with-status (with-status scored-users)]
    (if (more-than-one-winner? users-with-status)
      (mark-everyone-as-a-loser users-with-status)
      users-with-status)))

(defn- with-status
  [scored-users]
  (let [max-score (apply max (map :score scored-users))]
    (vec (map (fn [scored-user]
                (assoc scored-user
                       :status
                       (if (= max-score (:score scored-user))
                         "winner"
                         "loser")))
              scored-users))))

(defn- mark-everyone-as-a-loser
  [users-with-status]
  (map
    (fn [user-with-status]
      (assoc user-with-status :status "loser"))
    users-with-status))

(defn- more-than-one-winner?
  [users-with-status]
  (not= 1
        (:winner
          (walk/keywordize-keys
            (frequencies
              (map :status users-with-status))))))

Put public function at the top for readability.


(ns hu.ssh.github-changelog.dependencies.bundler
  (:require
    [clojure.string :refer [split-lines]]
    [clojure.java.io :as io]))

(defn- get-specs [reader]
  (->> (doall (line-seq reader))
       (drop-while #(not= % "  specs:"))
       (drop 1)
       (take-while seq)))

(defn- parse-spec [spec]
  {:name (second spec) :version (nth spec 2)})

(defn- parse-specs [specs]
  (->> (map #(re-matches #"^\s{4}(\S+) \((.*)\)$" %) specs)
       (remove empty?)
       (map parse-spec)))

(defn parse [file]
  (with-open [reader (io/reader file)]
    (parse-specs (get-specs reader))))

(ns hu.ssh.github-changelog.dependencies.bundler
  (:require
    [clojure.string :refer [split-lines]]
    [clojure.java.io :as io]))

(defn- get-specs [reader]
  (->> (line-seq reader)
       (drop-while #(not= % "  specs:"))
       (drop 1)
       (take-while seq)
       doall))

(defn- parse-spec [spec]
  {:name (second spec) :version (nth spec 2)})

(defn- parse-specs [specs]
  (->> (map #(re-matches #"^\s{4}(\S+) \((.*)\)$" %) specs)
       (remove empty?)
       (map parse-spec)))

(defn parse [file]
  (with-open [reader (io/reader file)]
    (parse-specs (get-specs reader))))

Move doall to the end of get-specs

Move doall to the end of get-specs


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

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

(defn get-trip-reports
  "implementation: type that implements scrape-trs.protocol/ScrapeTripReport
  list-page: page (as a string) that lists trip reports and corresponds to the given implementation

  Scrape all trip reports from the list-page, paging through pagination if
  necessary, and return a sequence of scrape-trs.protocol/TripReport instances."
  [implementation list-page]
  (let [pager-urls (.extract-pager-urls implementation list-page)
        list-pages (if pager-urls (map slurp pager-urls) [list-page])
        trip-report-urls (mapcat #(.extract-trip-report-urls implementation %)
                                 list-pages)
        trip-reports (map #(.extract-trip-report implementation %1 %2)
                          trip-report-urls
                          (map slurp trip-report-urls))]
    trip-reports))

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

Remove save-trip-reports! since scrape-trs is now a library.


(ns tensorflow-clj.core-test
  (:require [clojure.test :refer :all]
            [tensorflow-clj.core :refer :all]))

(deftest scalar-tensor
  (testing "Scalar tensor"
    (let [t (org.tensorflow.Tensor/create 123.0)]
      (is (= org.tensorflow.DataType/DOUBLE (.dataType t)))
      (is (= 0 (.numDimensions t)))
      (is (= [] (vec (.shape t)))))))

(deftest vector-tensor
  (testing "Vector tensor"
    (let [t (org.tensorflow.Tensor/create (into-array [1.0 2.0 3.0]))]
      (is (= org.tensorflow.DataType/DOUBLE (.dataType t)))
      (is (= 1 (.numDimensions t)))
      (is (= [3] (vec (.shape t)))))))

(deftest graph-variable
  (testing "Graph variable"
    (with-graph
      (variable :x))))

(deftest graph-constant
  (testing "Graph constant"
    (with-graph
      (constant :k 123.0))))

;; (deftest session
;;   (testing "Session"
;;     (with-graph
;;       (constant :k 123.0)
;;       (run-feed-and-fetch :k))))

(deftest protobuf-session
  (testing "Session from Protocol Buffers file"
    (with-graph-file "misc/constant.pb"
      (run-and-fetch :Const))))

(ns tensorflow-clj.core-test
  (:require [clojure.test :refer :all]
            [tensorflow-clj.core :refer :all]))

(deftest scalar-tensor
  (testing "Scalar tensor"
    (let [t (org.tensorflow.Tensor/create 123.0)]
      (is (= org.tensorflow.DataType/DOUBLE (.dataType t)))
      (is (= 0 (.numDimensions t)))
      (is (= [] (vec (.shape t)))))))

(deftest vector-tensor
  (testing "Vector tensor"
    (let [t (org.tensorflow.Tensor/create (into-array [1.0 2.0 3.0]))]
      (is (= org.tensorflow.DataType/DOUBLE (.dataType t)))
      (is (= 1 (.numDimensions t)))
      (is (= [3] (vec (.shape t)))))))

(deftest graph-variable
  (testing "Graph variable"
    (with-graph
      (variable :x))))

(deftest graph-constant
  (testing "Graph constant"
    (with-graph
      (constant :k 123.0))))

;; (deftest session
;;   (testing "Session"
;;     (with-graph
;;       (constant :k 123.0)
;;       (run-feed-and-fetch :k))))

(deftest protobuf-session
  (testing "Session from Protocol Buffers file"
    (with-graph-file "misc/constant.pb"
      (let [t (run-and-fetch :Const)]
        (is (= org.tensorflow.Tensor (type t)))
        (is (= [] (vec (.shape t))))
        (is (= 123.0 (.floatValue t)))))))

Check that we got the right constant back


(ns rpi-challenger.core
  (:require [net.cgrand.enlive-html :as html]
            [ring.util.response :as response])
  (:use [net.cgrand.moustache :only [app]]
        [ring.adapter.jetty :only [run-jetty]]
        [ring.middleware.file :only [wrap-file]]
        [ring.middleware.reload :only [wrap-reload]]
        [ring.middleware.stacktrace :only [wrap-stacktrace]]))

(def layout (html/html-resource "resources/layout.html"))

(def routes
  (app
    [""] (fn [req] (response/response "the index page"))
    [&] (fn [req] (response/not-found "Page Not Found"))))

(ns rpi-challenger.core
  (:require [net.cgrand.enlive-html :as html])
  (:use ring.util.response
        [net.cgrand.moustache :only [app]]))

(def layout (html/html-resource "resources/layout.html"))

(def routes
  (app
    [""] (fn [req] (->
                     (response "the index page")
                     (content-type "text/html")
                     (charset "UTF-8")))
    [&] (fn [req] (->
                    (not-found "Page Not Found")
                    (content-type "text/html")
                    (charset "UTF-8")))))

Set content-type and charset correctly

Set content-type and charset correctly


(ns clojurewerkz.statistiker.descriptive
  (:require [clojurewerkz.statistiker.fast-math :refer :all]))

(defn get-rank
  [amount percentile]
  (assert (<= percentile 100))
  (-> (* (/ percentile 100) (dec amount))
      Math/ceil
      int))

(def percentiles
  {:min 0
   :max 100
   :median 50
   :25 25
   :75 75})

(defn fivenum
  [values]
  (let [sorted (sort values)
        amount (count values)]
    {:min    (nth sorted (get-rank amount 0))
     :25     (nth sorted (get-rank amount 25))
     :median (nth sorted (get-rank amount 50))
     :75     (nth sorted (get-rank amount 75))
     :max    (nth sorted (get-rank amount 100) )}))

(ns clojurewerkz.statistiker.descriptive
  (:import [org.apache.commons.math3.stat.descriptive.rank Percentile])
  (:require [clojurewerkz.statistiker.fast-math :refer :all]))

(def percentiles
  {:min 1
   :max 100
   :median 50
   :25 25
   :75 75})

(defn fivenum
  [values]
  (let [p (Percentile.)]
    (.setData p (double-array values))
    (reduce (fn [acc [k v]]
              (assoc acc k (.evaluate p (double v))))
            {}
            percentiles)))

(defn iqr
  [values]
  (let [p              (Percentile.)
        _              (.setData p (double-array values))
        first-quartile (.evaluate p (double 25))
        third-quartile (.evaluate p (double 75))]
    (- third-quartile first-quartile)))

Add IQR, re-do fivenum a bit

Add IQR, re-do fivenum a bit


(ns yetibot.core.db
  (:require
    [yetibot.core.config :refer [get-config config-for-ns conf-valid?]]
    [yetibot.core.loader :refer [find-namespaces]]
    [datomico.db :as db]
    [datomico.core :as dc]
    [datomic.api :as api]
    [taoensso.timbre :refer [info warn error]]))

(def db-ns-pattern #"(yetibot|plugins).*\.db\..+")

(defn schemas []
  (let [nss (find-namespaces db-ns-pattern)]
    (apply require nss)
    (for [n nss :when (ns-resolve n 'schema)]
      (deref (ns-resolve n 'schema)))))

(defn start [& [opts]]
  (if (conf-valid? (get-config :yetibot :db))
    (do
      (info "☐ Loading Datomic schemas")
      (dc/start (merge opts {:uri (:datomic-url (get-config :yetibot :db))
                             :schemas (filter identity (schemas))}))
      (info "☑ Datomic connected"))
    (warn ":datomic-url is not configured, unable to connect.")))

(def repl-start (partial start {:dynamic-vars true}))

(ns yetibot.core.db
  (:require
    [yetibot.core.config :refer [get-config config-for-ns conf-valid?]]
    [yetibot.core.loader :refer [find-namespaces]]
    [datomico.db :as db]
    [datomico.core :as dc]
    [datomic.api :as api]
    [taoensso.timbre :refer [info warn error]]))

(def db-ns-pattern #"(yetibot|plugins).*\.db\..+")

(defn schemas []
  (let [nss (find-namespaces db-ns-pattern)]
    (apply require nss)
    (for [n nss :when (ns-resolve n 'schema)]
      (deref (ns-resolve n 'schema)))))

(defn start [& [opts]]
  (if (conf-valid? (get-config :yetibot :db))
    (do
      (info "☐ Loading Datomic schemas at" (:datomic-url (get-config :yetibot :db)))
      (dc/start (merge opts {:uri (:datomic-url (get-config :yetibot :db))
                             :schemas (filter identity (schemas))}))
      (info "☑ Datomic connected"))
    (warn ":datomic-url is not configured, unable to connect.")))

(def repl-start (partial start {:dynamic-vars true}))

Add database url to loading schemas logs


(ns rill.event-store.atom-store.event-test
  (:require [rill.event-store.atom-store.event :as event]
            [rill.message :as message :refer [defevent]]
            [rill.uuid :refer [new-id]]
            [schema.core :as s]
            [clojure.test :refer [deftest is]]))

(defevent MySerializableEvent
  :foo s/Uuid)

(def my-event (my-serializable-event (new-id)))

(deftest serializable-events?
  (is (string? (:edn (:data (event->entry my-event)))))
  (is (= (entry->event (event->entry my-event))
         my-event)))

(ns rill.event-store.atom-store.event-test
  (:require [rill.event-store.atom-store.event :as event]
            [rill.temp-store :refer [message=]]
            [rill.message :as message :refer [defevent]]
            [rill.uuid :refer [new-id]]
            [schema.core :as s]
            [clojure.test :refer [deftest is]]))

(defevent MySerializableEvent
  :foo s/Uuid)

(def my-event (my-serializable-event (new-id)))

(deftest serializable-events?
  (is (string? (:edn (:data (event/event->entry my-event)))))
  (is (message= (event/entry->event (event/event->entry my-event))
         my-event)))

Make test work with proper namespaces

Make test work with proper namespaces


(ns com.stuartsierra.lazytest
  (:use [com.stuartsierra.lazytest.contexts
         :only (context?)]
        [com.stuartsierra.lazytest.arguments
         :only (or-nil)]))

;;; Examples and ExampleGroups

(defrecord ExampleGroup [contexts examples])

(defn new-example-group
  "Creates an ExampleGroup."
  ([contexts examples] (new-example-group contexts examples nil))
  ([contexts examples metadata]
     {:pre [(or-nil vector? contexts)
            (or-nil vector? examples)
            (every? context? contexts)
            (every? fn? examples)
            (or-nil map? metadata)]
      :post [(isa? (type %) ExampleGroup)]}
     (ExampleGroup. contexts examples nil metadata)))

;;; Public API

(defmacro thrown?
  "Returns true if body throws an instance of class c."
  [c & body]
  `(try ~@body false
        (catch ~c e# true)))

(defmacro thrown-with-msg?
  "Returns true if body throws an instance of class c whose message
  matches re (with re-find)."
  [c re & body]
  `(try ~@body false
        (catch ~c e# (re-find ~re (.getMessage e#)))))

(defmacro ok?
  "Returns true if body does not throw anything."
  [& body]
  `(do ~@body true))

(ns com.stuartsierra.lazytest)

(defmacro thrown?
  "Returns true if body throws an instance of class c."
  [c & body]
  `(try ~@body false
        (catch ~c e# true)))

(defmacro thrown-with-msg?
  "Returns true if body throws an instance of class c whose message
  matches re (with re-find)."
  [c re & body]
  `(try ~@body false
        (catch ~c e# (re-find ~re (.getMessage e#)))))

(defmacro ok?
  "Returns true if body does not throw anything."
  [& body]
  `(do ~@body true))

Cut everything except some assertion macros from core ns


(ns rdf-path-examples.diversification-test
  (:require [rdf-path-examples.diversification :as divers]
            [clojure.set :refer [union]]
            [clojure.test :refer :all]))

(deftest greedy-construction
  (let [distances {#{1 2} 0.5
                   #{1 3} 1
                   #{2 3} 0.5}
        distance-fn (fn [a b] (get distances (hash-set a b)))
        paths (apply union (keys distances))]
    (with-redefs [rand-nth (constantly 1)] ; Start with path 1
      (is (= (divers/greedy-construction paths distance-fn 2) #{1 3})))))

(ns rdf-path-examples.diversification-test
  (:require [rdf-path-examples.diversification :as divers]
            [clojure.set :refer [union]]
            [clojure.test :refer :all]))

(deftest greedy-construction
  (let [distances {#{1 2} 0.5
                   #{1 3} 1
                   #{1 4} 1
                   #{2 3} 0.5
                   #{2 4} 0.5
                   #{3 4} 0}
        distance-fn (fn [a b] (get distances (hash-set a b)))
        paths (apply union (keys distances))]
    (with-redefs [rand-nth (constantly 1)] ; Start with path 1
      (is (= (divers/greedy-construction paths distance-fn 3) #{1 2 3})))))

Test greedy construction for 3 selected items