Liking cljdoc? Tell your friends :D

tupelo.misc

Miscellaneous functions.

Miscellaneous functions.
raw docstring

*os-shell*clj

source

boolean->binaryclj/s

(boolean->binary arg)

Inputs: [arg :- s/Bool] Returns: s/Int

Convert true => 1, false => 0

Inputs: [arg :- s/Bool]
Returns: s/Int

Convert true => 1, false => 0
sourceraw docstring

byte-signed->hexclj/s

(byte-signed->hex signed-byte)

Inputs: [signed-byte] Returns: s/Str

Converts a sequence of unsigned bytes [0..255] to a hex string, where each byte becomes 2 hex digits.

Inputs: [signed-byte]
Returns: s/Str

Converts a sequence of unsigned bytes [0..255] to a hex string, where each byte becomes 2 hex digits.
sourceraw docstring

byte-signed->unsignedclj/s

(byte-signed->unsigned signed-byte)

Inputs: [signed-byte :- s/Int]

Converts a signed byte [-128..127] into an unsigned byte [0..255].

Inputs: [signed-byte :- s/Int]

Converts a signed byte [-128..127] into an unsigned byte [0..255].
sourceraw docstring

byte-unsigned->hexclj/s

(byte-unsigned->hex unsigned-byte)

Inputs: [unsigned-byte :- s/Int] Returns: s/Str

Converts a sequence of unsigned bytes [0..255] to a hex string, where each byte becomes 2 hex digits.

Inputs: [unsigned-byte :- s/Int]
Returns: s/Str

Converts a sequence of unsigned bytes [0..255] to a hex string, where each byte becomes 2 hex digits.
sourceraw docstring

byte-unsigned->signedclj/s

(byte-unsigned->signed unsigned-int)

Inputs: [unsigned-int :- s/Int]

Converts an unsigned int value [0..255] into a signed byte [-128..127].

Inputs: [unsigned-int :- s/Int]

Converts an unsigned int value [0..255] into a signed byte [-128..127].
sourceraw docstring

bytes-signed->hex-strclj/s

(bytes-signed->hex-str signed-bytes)

Inputs: [signed-bytes :- [s/Int]] Returns: s/Str

Converts a sequence of signed bytes [-128..127] to a hex string, where each byte becomes 2 hex digits.

Inputs: [signed-bytes :- [s/Int]]
Returns: s/Str

Converts a sequence of signed bytes [-128..127] to a hex string, where each byte becomes 2 hex digits.
sourceraw docstring

bytes-signed->unsignedclj/s

(bytes-signed->unsigned byte-vals)

Inputs: [byte-vals]

Converts a vector of signed byte values [-128..127] into one of unsigned byte values [0..255]

Inputs: [byte-vals]

Converts a vector of signed byte values [-128..127] into one of unsigned byte values [0..255] 
sourceraw docstring

bytes-unsigned->hex-strclj/s

(bytes-unsigned->hex-str unsigned-bytes)

Inputs: [unsigned-bytes :- [s/Int]] Returns: s/Str

Converts a sequence of unsigned bytes [0..255] to a hex string, where each byte becomes 2 hex digits.

Inputs: [unsigned-bytes :- [s/Int]]
Returns: s/Str

Converts a sequence of unsigned bytes [0..255] to a hex string, where each byte becomes 2 hex digits.
sourceraw docstring

bytes-unsigned->signedclj/s

(bytes-unsigned->signed byte-vals)

Inputs: [byte-vals]

Converts a vector of unsigned byte values [0..255] into one of signed byte values [-128..127]

Inputs: [byte-vals]

Converts a vector of unsigned byte values [0..255] into one of signed byte values [-128..127]
sourceraw docstring

dotclj

(dot)

Prints a single dot (flushed) to the console, keeping a running count of dots printed. Wraps to a newline when 100 dots have been printed. Displays the running dot count at the beginning of each line. Usage:

  (ns demo.core
    (:require [tupelo.misc :as tm]))
  (tm/dots-config! {:decimation 10} )
  (tm/with-dots
    (doseq [ii (range 2345)]
      (tm/dot)
      (Thread/sleep 5)))
Prints a single dot (flushed) to the console, keeping a running count of dots printed.  Wraps to a
newline when 100 dots have been printed. Displays the running dot count at the beginning of each line.
Usage:

      (ns demo.core
        (:require [tupelo.misc :as tm]))
      (tm/dots-config! {:decimation 10} )
      (tm/with-dots
        (doseq [ii (range 2345)]
          (tm/dot)
          (Thread/sleep 5)))
sourceraw docstring

dot-counter-watch-fnclj

(dot-counter-watch-fn key dot-counter-ref old-count new-count)
source

dots-config!clj

(dots-config! ctx)
source

edn->shaclj/s

(edn->sha edn-data)

Inputs: [edn-data] Returns: s/Str

Converts EDN data into a normalized SHA-1 string

Inputs: [edn-data]
Returns: s/Str

Converts EDN data into a normalized SHA-1 string
sourceraw docstring

find-patternclj/s

(find-pattern pattern-vec data-vec)

Inputs: [pattern-vec :- tsk/List data-vec :- tsk/List] Returns: [s/Int]

Searches for pattern-vec within data-vec, returning a lazy seq of indexes into data-vec.

Inputs: [pattern-vec :- tsk/List data-vec :- tsk/List]
Returns: [s/Int]

Searches for pattern-vec within data-vec, returning a lazy seq of indexes into data-vec.
sourceraw docstring

fn-infoclj

(fn-info)

Inputs: [] Returns: tsk/KeyMap

Returns a map of info about the current function, like:

       {:ns-name     'demo.core'
        :fn-name     'add2'
        :class-name  'demo.core$add2'
        :file-name   'core.clj'
        :line-num    57
        :method-name 'invokeStatic' }
Inputs: []
Returns: tsk/KeyMap

Returns a map of info about the current function, like:

           {:ns-name     'demo.core'
            :fn-name     'add2'
            :class-name  'demo.core$add2'
            :file-name   'core.clj'
            :line-num    57
            :method-name 'invokeStatic' }
          
sourceraw docstring

fn-info-callerclj

(fn-info-caller)

Inputs: [] Returns: tsk/KeyMap

Returns a map of info about the caller of the current function, like:

       {:ns-name     'demo.core'
        :fn-name     'add2'
        :class-name  'demo.core$add2'
        :file-name   'core.clj'
        :line-num    57
        :method-name 'invokeStatic' }
Inputs: []
Returns: tsk/KeyMap

Returns a map of info about the caller of the current function, like:

           {:ns-name     'demo.core'
            :fn-name     'add2'
            :class-name  'demo.core$add2'
            :file-name   'core.clj'
            :line-num    57
            :method-name 'invokeStatic' }
          
sourceraw docstring

get-osclj

(get-os)
source

get-pathclj

(get-path path-str)

Wrapper for Java Paths/get to work around the varargs strangeness

Wrapper for Java Paths/get to work around the varargs strangeness
sourceraw docstring

groupercljs

(grouper re input-str)

Uses js/RegExp to find matching groups. Sample output:

  (grouper #"[a-z0-9][A-Z]"  "aTaTa")  =>
    [ {:groups ["aT"]  :match "aT"  :index 0  :last-index 2  :input "aTaTa" }
      {:groups ["aT"]  :match "aT"  :index 2  :last-index 4  :input "aTaTa" } ]

  (grouper  #"((\d+)-(\d+))" "672-345-456-3212")  =>
    [ {:groups ["672-345"  "672-345"  "672" "345" ]  :match "672-345"   :index 0  :last-index  7  :input "672-345-456-3212" }
      {:groups ["456-3212" "456-3212" "456" "3212"]  :match "456-3212"  :index 8  :last-index 16  :input "672-345-456-3212" } ]

Note that the JS value returned by :last-index is the index of the first char in the input string after the current match.

Uses js/RegExp to find matching groups.  Sample output:

      (grouper #"[a-z0-9][A-Z]"  "aTaTa")  =>
        [ {:groups ["aT"]  :match "aT"  :index 0  :last-index 2  :input "aTaTa" }
          {:groups ["aT"]  :match "aT"  :index 2  :last-index 4  :input "aTaTa" } ]

      (grouper  #"((\d+)-(\d+))" "672-345-456-3212")  =>
        [ {:groups ["672-345"  "672-345"  "672" "345" ]  :match "672-345"   :index 0  :last-index  7  :input "672-345-456-3212" }
          {:groups ["456-3212" "456-3212" "456" "3212"]  :match "456-3212"  :index 8  :last-index 16  :input "672-345-456-3212" } ]

Note that the JS value returned by `:last-index` is the index of the first char in the input string *after* the current match.
sourceraw docstring

hash->hexclj/s≠

clj
(hash->hex & args)
cljs
(hash->hex & rest116738)

Inputs: [& args] Returns: s/Str

Given arbitrary arguments, uses clojure.lang/hash to generate a 32-bit hex hashcode.

Inputs: [& args]
Returns: s/Str

Given arbitrary arguments, uses clojure.lang/hash to generate a 32-bit hex hashcode.
sourceraw docstring

hex->intclj/s

source

hex-charsclj/s

source

hex-str->signed-bytesclj/s

(hex-str->signed-bytes hex-str)

Inputs: [hex-str :- s/Str]

Converts a hex string to a vector of unsigned bytes

Inputs: [hex-str :- s/Str]

Converts a hex string to a vector of unsigned bytes
sourceraw docstring

hex-str->unsigned-bytesclj/s

(hex-str->unsigned-bytes hex-str)

Inputs: [hex-str :- s/Str]

Converts a hex string to a vector of unsigned bytes

Inputs: [hex-str :- s/Str]

Converts a hex string to a vector of unsigned bytes
sourceraw docstring

HIDclj/s

source

hid->widclj

(hid->wid hid)

Inputs: [hid :- HID] Returns: s/Keyword

Uses an HID to look up a human-friendly Word-ID (WID) from an English dictionary. Useful for debugging purposes.

Inputs: [hid :- HID]
Returns: s/Keyword

Uses an HID to look up a human-friendly Word-ID (WID) from an English dictionary.
     Useful for debugging purposes.
sourceraw docstring

hid?clj/s

(hid? arg)

Inputs: [arg] Returns: s/Bool

Returns true if the arg is a legal HexID

Inputs: [arg]
Returns: s/Bool

Returns true if the arg is a legal HexID
sourceraw docstring

int->hexclj/s

source

log-uncaught-exceptionsclj

(log-uncaught-exceptions)
source

new-hidclj/s

(new-hid)

Inputs: [] Returns: HID

Returns a new HexID

Inputs: []
Returns: HID

Returns a new HexID
sourceraw docstring

normalized-sortedclj/s

(normalized-sorted edn-data)

Walks EDN data, converting all collections to vector, sorted-map-generic, or sorted-set-generic

Walks EDN data, converting all collections to vector, sorted-map-generic, or sorted-set-generic
sourceraw docstring

sha-uuidclj/s

(sha-uuid)

Inputs: [] Returns: s/Str

Returns a string that is the SHA-1 hash of the

  Clojure:         (clj-uuid/v1)
  ClojureScript:   (cljs.core/random-uuid)
Inputs: []
Returns: s/Str

Returns a string that is the SHA-1 hash of the

      Clojure:         (clj-uuid/v1)
      ClojureScript:   (cljs.core/random-uuid)
      
sourceraw docstring

shell-cmdclj

(shell-cmd cmd-str)

Runs a command string in the default OS shell (/bin/bash); returns result in a Clojure map. Example:

 (shell-cmd "ls -ldF *")

   ;=>   {:exit    0     ; unix exit status (0 -> normal)
          :err    ''     ; text from any errors
          :out    '...'  ; text output as would printed to console
         }
Runs a command string in the default OS shell (/bin/bash); returns result in a Clojure map.
Example:

     (shell-cmd "ls -ldF *")

       ;=>   {:exit    0     ; unix exit status (0 -> normal)
              :err    ''     ; text from any errors
              :out    '...'  ; text output as would printed to console
             }
sourceraw docstring

stacktrace-infoclj

(stacktrace-info throwable)

Inputs: [throwable :- Throwable] Returns: [tsk/KeyMap]

Returns a map with the caller's namespace and function names as strings, like: {:ns-name 'tst.demo.core' :fn-name 'funky'}

Inputs: [throwable :- Throwable]
Returns: [tsk/KeyMap]

Returns a map with the caller's namespace and function names as strings, like:
         {:ns-name 'tst.demo.core' :fn-name 'funky'} 
sourceraw docstring

str->byte-arrayclj/s

(str->byte-array str-val)

Inputs: [str-val :- s/Str]

Inputs: [str-val :- s/Str]
sourceraw docstring

str->shaclj/s≠

clj

Returns the SHA-1 hex string for a string

Returns the SHA-1 hex string for a string
cljs
(str->sha str-val)

Inputs: [str-val :- s/Str]

Inputs: [str-val :- s/Str]
source (clj)source (cljs)raw docstring

take-distclj/s

(take-dist n coll)

Returns a sequence of n items from a collection, distributed evenly between first & last elements, which are always included.

Returns a sequence of n items from a collection, distributed
evenly between first & last elements, which are always included.
sourceraw docstring

uuid->shaclj/s

(uuid->sha uuid)

Returns the SHA-1 hex string for a UUID's string representation

Returns the SHA-1 hex string for a UUID's string representation
sourceraw docstring

walk-map->sortedclj/s

(walk-map->sorted data)

Recursively walks a data structure, converting maps (but not records!) into (plain) sorted maps.

Recursively walks a data structure, converting maps (but not records!) into (plain) sorted maps.
sourceraw docstring

walk-map->sorted-genericclj/s

(walk-map->sorted-generic data)

Recursively walks a data structure, converting maps (but not records!) into generic sorted maps. A generic sort allows keys of different categories such as keyword, string, int, nil, etc.

Recursively walks a data structure, converting maps (but not records!) into generic sorted maps.
A generic sort allows keys of different categories such as keyword, string, int, nil, etc.
sourceraw docstring

walk-rec->mapclj/s

(walk-rec->map data)
source

with-dotsclj/smacro

(with-dots & body)

Increments indentation level of all spy, spyx, or spyxx expressions within the body.

Increments indentation level of all spy, spyx, or spyxx expressions within the body.
sourceraw docstring

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

× close