biff.util

Utility functions with almost no dependencies.

The only exception is clojure.tools.namespace.repl, which is used by refresh.

add-deref

(add-deref form syms)

add-seconds

(add-seconds date seconds)

anom

(anom category & [message & [opts]])

anom->http-status

(anom->http-status anomaly)

anom-category

(anom-category {:keys [cognitect.anomalies/category]})

anomaly?

(anomaly? x)

base64-decode

(base64-decode s)

base64-encode

(base64-encode bs)

between-hours?

(between-hours? t h1 h2)

catchall

macro

(catchall & body)

compare<

(compare< x y)

compare<=

(compare<= x y)

compare=

(compare= x y)

compare>

(compare> x y)

compare>=

(compare>= x y)

day-of-week

(day-of-week t)

distinct-by

(distinct-by f coll)

ellipsize

(ellipsize n s)

fix-print

macro

(fix-print & body)

format-columns

(format-columns rows)
Formats rows of text into columns.

Example:
```
(doseq [row (format-columns [["hellooooooooo " "there"]
["foo " "bar"]
["one column"]])]
(println row))
hellooooooooo there
foo           bar
one column
```

format-date

(format-date date)(format-date date out-format)

http-status->msg

join

(join sep xs)

last-midnight

(last-midnight t)

letdelay

macro

(letdelay bindings & body)

map-from

(map-from f xs)

map-from-to

(map-from-to f g xs)

map-keys

(map-keys f m)

map-to

(map-to f xs)

map-vals

(map-vals f m)

nest-string-keys

(nest-string-keys m ks)

ns-contains?

(ns-contains? nspace sym)

ns-parts

(ns-parts nspace)

only-keys

(only-keys & {:keys [req opt req-un opt-un]})
Like clojure.spec.alpha/keys, but closed.

pad

(pad n _val coll)

parse-date

(parse-date date)(parse-date date in-format)

parse-format-date

(parse-format-date date in-format out-format)

ppr-str

(ppr-str x)

pprint

(pprint x)

pprint-ex

macro

(pprint-ex & body)

prepend-keys

(prepend-keys ns-segment m)

prepend-ns

(prepend-ns ns-segment k)

print-table

(print-table header-info table)
Prints a nicely formatted table.

Example:
```
(print-table
[[:foo "Foo"] [:bar "Bar"]]
[{:foo 1 :bar 2} {:foo 3 :bar 4}])
=> Foo  Bar
1    2
3    4
```

read-env

(read-env env-keys)
Returns a map populated from environment variables.

Takes a collection of variable descriptors. For example, assuming the
environment has FOO=hello and BAR=123:

(read-env [["FOO" :foo]
           ["BAR" :bar #(Long/parseLong %)]
           ["NOT_DEFINED" :not-defined]])
=> {:foo "hello"
    :bar 123}

The third element of each descriptor, if present, will be used to coerce
non-empty values.

realize

(realize x)

refresh

(refresh)
Stops the system, refreshes source files, and restarts the system.

The system is stopped by calling all the functions in (:biff/stop
@biff.util/system). (:after-refresh @system) is a fully-qualified symbol which
will be resolved and called after refreshing.

See start-system.

rfc3339

sdefs

macro

(sdefs & body)

select-as

(select-as m key-map)

select-ns

(select-ns m nspace)

select-ns-as

(select-ns-as m ns-from ns-to)

sh

(sh & args)
Runs a shell command.

Returns the output if successful; otherwise, throws an exception.

split-by

(split-by pred xs)

sppit

(sppit f x)

start-system

(start-system config components)
Starts a system from a config map and a collection of Biff components.

Stores the system in the biff.util/system atom. See
See https://biff.findka.com/#system-composition and refresh.

system

take-str

(take-str n s)

throw-anom

(throw-anom & args)

verbose

macro

(verbose & body)

wrap-wtf

(wrap-wtf handler)