Liking cljdoc? Tell your friends :D

libmisc-clj.misc


base64-string?clj

(base64-string? s)

Is s a Base-64 encoded string?

Is `s` a Base-64 encoded string?
sourceraw docstring

email?clj

(email? s)

Is STRING a valid email address?

Is STRING a valid email address?
sourceraw docstring

filter-hashmapclj

(filter-hashmap func amap)

returns map filtered by a function func

returns map filtered by a function `func`
sourceraw docstring

format-bytesclj

(format-bytes num-bytes)

Nicely format num-bytes as kilobytes/megabytes/etc. (format-bytes 1024) ; -> 2.0 KB

Nicely format `num-bytes` as kilobytes/megabytes/etc.
(format-bytes 1024) ; -> 2.0 KB
sourceraw docstring

hexadecimal-string?clj

(hexadecimal-string? new-value)

Returns truthy if new-value is a hexadecimal-string

Returns truthy if `new-value` is a hexadecimal-string
sourceraw docstring

host-port-up?clj

(host-port-up? hostname port)
(host-port-up? hostname port timeout)

Returns true if the port is active on a given host, false otherwise. Uses InetSocketAddress and Socket.connect (i.e. reliable TCP proto) under the hood. The hostname is always treated as name to be used to determine the IP address of a host. If it fails the results is also negative. By default, waits 5 seconds till return, this may be configured using an optional parameter timeout (time to wait in milliseconds)

Returns true if the port is active on a given host, false otherwise.
Uses `InetSocketAddress` and `Socket.connect` (i.e. reliable TCP proto) under the hood.
The `hostname` is always treated as name to be used to determine
the IP address of a host. If it fails the results is also negative.
By default, waits 5 seconds till return, this may be configured using
an optional parameter `timeout` (time to wait in milliseconds)
sourceraw docstring

host-up?clj

(host-up? hostname)
(host-up? hostname timeout)

Returns true if the host given by hostname is reachable, false otherwise. The hostname is always treated as name to be used to determine the IP address of a host. If it fails the results is also negative. By default, waits 5 seconds till return, this may be configured using an optional parameter timeout (time to wait in milliseconds)

Returns true if the host given by hostname is reachable, false otherwise.
The `hostname` is always treated as name to be used to determine
the IP address of a host. If it fails the results is also negative.
By default, waits 5 seconds till return, this may be configured using
an optional parameter `timeout` (time to wait in milliseconds)
sourceraw docstring

in?clj

(in? x coll)

Return true if x is in coll or false otherwise

Return true if x is in coll or false otherwise
sourceraw docstring

index-ofclj

(index-of pred coll)

Return index of the first element in coll for which pred reutrns true.

Return index of the first element in `coll` for which `pred` reutrns true.
sourceraw docstring

int->bytesclj

(int->bytes value)

Converts int value into a sequence of 4 bytes. The zeroes are padded to the beginning in order to make the BigInteger constructor working

Converts int value into a sequence of 4 bytes.
The zeroes are padded to the beginning in order to make
the BigInteger constructor working
sourceraw docstring

jnio->stringclj

(jnio->string byte-buffer)
(jnio->string byte-buffer charset)
source

limit-strlencljmacro

(limit-strlen s max)
source

literal?clj

(literal? s)
source

localdate-nowclj

(localdate-now tz)
source

long->bytesclj

(long->bytes value)

Converts long value into a sequence of 8 bytes. The zeroes are padded to the beginning in order to make the BigInteger constructor working

Converts long value into a sequence of 8 bytes.
The zeroes are padded to the beginning in order to make
the BigInteger constructor working
sourceraw docstring

map-valuesclj

(map-values m ks)
source

maybe?clj

(maybe? f x)

Returns true if X is nil, otherwise calls (F X). This can be used to see something is either nil or statisfies a predicate function: (string? nil) -> false (string? "A") -> true (maybe? string? nil) -> true (maybe? string? "A") -> true It can also be used to make sure a given function won't throw a NullPointerException: (s/lower-case nil) -> NullPointerException (s/lower-case "ABC") -> "abc" (maybe? s/lower-case nil) -> true (maybe? s/lower-case "ABC") -> "abc" The latter use-case can be useful for things like sorting where some values in a collection might be nil: (sort-by (partial maybe? s/lower-case) some-collection)

Returns `true` if X is `nil`, otherwise calls (F X).
This can be used to see something is either `nil` or statisfies a predicate function:
  (string? nil)          -> false
  (string? "A")        -> true
  (maybe? string? nil)   -> true
  (maybe? string? "A") -> true
It can also be used to make sure a given function won't throw a `NullPointerException`:
  (s/lower-case nil)            -> NullPointerException
  (s/lower-case "ABC")        -> "abc"
  (maybe? s/lower-case nil)     -> true
  (maybe? s/lower-case "ABC") -> "abc"
The latter use-case can be useful for things like sorting where some values in a collection
might be `nil`:
  (sort-by (partial maybe? s/lower-case) some-collection)
sourceraw docstring

multi-mergeclj

(multi-merge maps)
(multi-merge {:keys [collect?] :or {collect? false} :as opts} maps)

Merges maps recursively

Merges maps recursively
sourceraw docstring

nn?clj

source

not-nil?clj

source

nz?clj

source

round-to-decimalsclj

(round-to-decimals decimal-place number)

Round (presumabily floating-point) NUMBER to DECIMAL-PLACE. Returns a Double. (round-to-decimals 2 35.5058998M) -> 35.51

Round (presumabily floating-point) NUMBER to DECIMAL-PLACE. Returns a `Double`.
(round-to-decimals 2 35.5058998M) -> 35.51
sourceraw docstring

safe-incclj

(safe-inc n)

Increment N if it is non-nil, otherwise return 1 (e.g. as if incrementing 0).

Increment N if it is non-`nil`, otherwise return `1` (e.g. as if incrementing `0`).
sourceraw docstring

select-valuesclj

(select-values m ks)
source

sequence-of-maps?clj

(sequence-of-maps? coll)

Is COLL a sequence of maps?

Is COLL a sequence of maps?
sourceraw docstring

string->jnioclj

(string->jnio string)
(string->jnio string charset)
source

sym->varclj

(sym->var val)
source

update-in-whenclj

(update-in-when m k f & args)

Like clojure.core/update-in but does not create new keys if they do not exist. Useful when you don't want to create cruft.

Like clojure.core/update-in but does not create new keys if they do not exist.
Useful when you don't want to create cruft.
sourceraw docstring

update-whenclj

(update-when m k f & args)

Like clojure.core/update but does not create a new key if it does not exist. Useful when you don't want to create cruft.

Like clojure.core/update but does not create a new key if it does not exist.
Useful when you don't want to create cruft.
sourceraw docstring

url?clj

(url? s)

Is STRING a valid HTTP/HTTPS URL? (This only handles localhost and domains like metabase.com; URLs containing IP addresses will return false.)

Is STRING a valid HTTP/HTTPS URL? (This only handles `localhost` and domains like `metabase.com`; URLs containing
IP addresses will return `false`.)
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close