(base64-string? s)
Is s
a Base-64 encoded string?
Is `s` a Base-64 encoded string?
(email? s)
Is STRING a valid email address?
Is STRING a valid email address?
(filter-hashmap func amap)
returns map filtered by a function func
returns map filtered by a function `func`
(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
(hexadecimal-string? new-value)
Returns truthy if new-value
is a hexadecimal-string
Returns truthy if `new-value` is a hexadecimal-string
(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)
(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)
(in? x coll)
Return true if x is in coll or false otherwise
Return true if x is in coll or false otherwise
(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.
(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
(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
(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)
(multi-merge maps)
(multi-merge {:keys [collect?] :or {collect? false} :as opts} maps)
Merges maps recursively
Merges maps recursively
(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
(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`).
(sequence-of-maps? coll)
Is COLL a sequence of maps?
Is COLL a sequence of maps?
(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.
(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.
(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`.)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close