2019-06-05 03:26:05 -05:00
|
|
|
;; 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/.
|
|
|
|
;;
|
2021-04-10 02:43:04 -05:00
|
|
|
;; Copyright (c) UXBOX Labs SL
|
2019-06-05 03:26:05 -05:00
|
|
|
|
|
|
|
(ns user
|
2019-11-18 05:52:57 -05:00
|
|
|
(:require
|
2022-02-07 06:00:26 -05:00
|
|
|
[app.common.data :as d]
|
2021-02-15 07:14:05 -05:00
|
|
|
[app.common.exceptions :as ex]
|
2022-01-12 14:23:25 -05:00
|
|
|
[app.common.geom.matrix :as gmt]
|
|
|
|
[app.common.perf :as perf]
|
|
|
|
[app.common.transit :as t]
|
2020-12-24 08:32:19 -05:00
|
|
|
[app.config :as cfg]
|
|
|
|
[app.main :as main]
|
2021-03-08 07:14:52 -05:00
|
|
|
[app.util.blob :as blob]
|
2021-12-21 09:25:21 -05:00
|
|
|
[app.util.fressian :as fres]
|
2022-01-12 14:23:25 -05:00
|
|
|
[app.util.json :as json]
|
2020-12-24 08:32:19 -05:00
|
|
|
[app.util.time :as dt]
|
2022-01-12 14:23:25 -05:00
|
|
|
[clj-async-profiler.core :as prof]
|
|
|
|
[clojure.contrib.humanize :as hum]
|
2020-12-24 08:32:19 -05:00
|
|
|
[clojure.java.io :as io]
|
2021-03-08 07:14:52 -05:00
|
|
|
[clojure.pprint :refer [pprint print-table]]
|
2020-12-24 08:32:19 -05:00
|
|
|
[clojure.repl :refer :all]
|
2019-11-26 07:34:37 -05:00
|
|
|
[clojure.spec.alpha :as s]
|
2020-12-27 16:47:31 -05:00
|
|
|
[clojure.spec.gen.alpha :as sgen]
|
2020-12-24 08:32:19 -05:00
|
|
|
[clojure.test :as test]
|
2019-11-18 05:52:57 -05:00
|
|
|
[clojure.tools.namespace.repl :as repl]
|
|
|
|
[clojure.walk :refer [macroexpand-all]]
|
2022-01-12 14:23:25 -05:00
|
|
|
[datoteka.core]
|
2021-03-08 07:14:52 -05:00
|
|
|
[integrant.core :as ig]))
|
2020-12-24 08:32:19 -05:00
|
|
|
|
|
|
|
(repl/disable-reload! (find-ns 'integrant.core))
|
2021-12-21 09:25:21 -05:00
|
|
|
(set! *warn-on-reflection* true)
|
2020-12-24 08:32:19 -05:00
|
|
|
|
|
|
|
(defonce system nil)
|
2019-06-05 03:26:05 -05:00
|
|
|
|
|
|
|
;; --- Development Stuff
|
|
|
|
|
2020-01-13 09:14:29 -05:00
|
|
|
(defn- run-tests
|
2021-05-28 06:50:42 -05:00
|
|
|
([] (run-tests #"^app.*-test$"))
|
2019-06-05 03:26:05 -05:00
|
|
|
([o]
|
2020-02-03 16:29:59 -05:00
|
|
|
(repl/refresh)
|
2019-06-05 03:26:05 -05:00
|
|
|
(cond
|
|
|
|
(instance? java.util.regex.Pattern o)
|
|
|
|
(test/run-all-tests o)
|
|
|
|
|
|
|
|
(symbol? o)
|
|
|
|
(if-let [sns (namespace o)]
|
|
|
|
(do (require (symbol sns))
|
|
|
|
(test/test-vars [(resolve o)]))
|
|
|
|
(test/test-ns o)))))
|
2020-02-24 09:29:12 -05:00
|
|
|
|
2020-12-24 08:32:19 -05:00
|
|
|
(defn- start
|
|
|
|
[]
|
|
|
|
(alter-var-root #'system (fn [sys]
|
|
|
|
(when sys (ig/halt! sys))
|
2021-03-30 07:55:19 -05:00
|
|
|
(-> main/system-config
|
2020-12-24 08:32:19 -05:00
|
|
|
(ig/prep)
|
|
|
|
(ig/init))))
|
|
|
|
:started)
|
|
|
|
|
|
|
|
(defn- stop
|
|
|
|
[]
|
|
|
|
(alter-var-root #'system (fn [sys]
|
|
|
|
(when sys (ig/halt! sys))
|
|
|
|
nil))
|
|
|
|
:stoped)
|
|
|
|
|
|
|
|
(defn restart
|
|
|
|
[]
|
|
|
|
(stop)
|
|
|
|
(repl/refresh :after 'user/start))
|
|
|
|
|
|
|
|
(defn restart-all
|
|
|
|
[]
|
|
|
|
(stop)
|
|
|
|
(repl/refresh-all :after 'user/start))
|
2021-03-08 07:14:52 -05:00
|
|
|
|
|
|
|
(defn compression-bench
|
|
|
|
[data]
|
2021-12-21 09:25:21 -05:00
|
|
|
(let [humanize (fn [v] (hum/filesize v :binary true :format " %.4f "))]
|
|
|
|
(print-table
|
|
|
|
[{:v1 (humanize (alength (blob/encode data {:version 1})))
|
|
|
|
:v2 (humanize (alength (blob/encode data {:version 2})))
|
|
|
|
:v3 (humanize (alength (blob/encode data {:version 3})))
|
|
|
|
:v4 (humanize (alength (blob/encode data {:version 4})))
|
|
|
|
}])))
|
|
|
|
|
2021-12-24 06:40:44 -05:00
|
|
|
(defonce debug-tap
|
|
|
|
(do
|
|
|
|
(add-tap #(locking debug-tap
|
|
|
|
(prn "tap debug:" %)))
|
|
|
|
1))
|