Showing…
  • Absolute Value


    Print the absolute value of an integer argument, stripping a leading minus so downstream scripts always see a non-negative number.

  • Array Contains a Value


    Return success if a Bash nameref array contains a given value, or failure if the value is missing, without expanding the array yourself.

  • Ask Until Yes or No


    Prompt until the user types y/yes or n/no, then echo 1 or 0 so the answer can be captured instead of using the exit status.

  • Capitalise a String


    Allocate a copy with the first character uppercased and the rest lowercased, or NULL if allocation fails.

  • Capitalise Each Word


    Allocate a copy that uppercases the first letter after each space and lowercases the rest, or NULL if allocation fails.

  • Capture Command Output


    Run an argv list as a subprocess and return the exit status together with captured stdout and stderr as strings.

  • Center Terminal Text


    Print a line padded with spaces so the text sits in the middle of the current terminal width, using tput for the column count.

  • Check a Command Exists


    Return success if the named variable holds a command that command -v can find on PATH.

  • Check an Array is Set


    Return success if the named array exists and contains at least one element, using a nameref so callers pass the array name.

  • Check File Permissions


    Return success if the named path exists and its mode bits match the expected octal permissions, using GNU or BSD stat.

  • Check Prerequisites


    Search an expanded PATH for each command name and return its full path, or raise when any name is missing.

  • Check Required Commands


    Walk a COMMANDS list and exit with an error as soon as any required program name is missing from PATH.

  • Clean Up Docker Leftovers


    Remove exited and dead containers, containers stuck on untagged images, dangling images, and dangling volumes, or list them with -n.

  • Comma-Separate a Number


    Allocate a decimal string for an integer with commas every three digits, keeping a leading minus when the value is negative.

  • Compare Local Remote Tags


    List tags that exist only locally or only on a remote after confirming the current directory is a git work tree.

  • Compare Versions


    Compare two dotted numeric version strings and return a negative number, zero, or a positive number for less, equal, or greater.

  • Compare Versions


    Compare two numeric version strings and return 0 if they are equal, 1 if the first is greater, or 2 if it is less.

  • Count Frequencies


    Fold a slice into a HashMap that maps each value to how many times it occurs, incrementing the entry on each pass.

  • Count Indexes Per Table


    List each table in an Oracle schema with how many indexes it has, using ALL_INDEXES grouped and ordered by table name.

  • Days in a Month


    Return how many days a month has, using 29 for February in a Gregorian leap year and 0 when the month is out of range.

  • Detect TTY or Redirect


    Report whether stdout is attached to a terminal, a pipe, or a redirection so scripts can choose human or machine output.

  • Email PHP Errors


    Register an error handler that emails the number, file, line, and message to a chosen address, then stops on anything more severe than a notice.

  • End of a String


    Return a pointer to the byte after the terminating NUL of a C string, the one-past-end position.

  • Expand Network to IPs


    Print every IPv4 address in a CIDR or dotted-mask network, including the network and broadcast addresses.

  • Extract a Version


    Pull the first run of digits and dots out of a string so a human version line becomes a comparable numeric version.

  • Find Duplicate Column Values


    Group by a column and return each value that appears more than once, together with how many times it is duplicated.

  • Find the Git Root


    Print the top-level directory of a git work tree for the current or given path, or an error if that path is not a repository.

  • First Duplicate


    Walk a slice and return the first value that is already in a HashSet, using insert's false-on-duplicate result inside find.

  • Fork Pool Hang Cleanup


    Track worker PIDs and thread IDs in a Parallel::ForkManager pool, then kill children that exceed PATIENCE so hung jobs are cleaned up.

  • Forked Workers Timeout


    Run Parallel::ForkManager jobs and kill any child whose runtime exceeds PATIENCE seconds so hung workers cannot stall the pool.

  • ForkManager Worker Pool


    Fork a fixed-size Parallel::ForkManager worker pool, start each job in a child process, and wait until every worker has finished.

  • Get Default Branch


    Print the default branch name that origin reports as HEAD, trimmed of surrounding whitespace.

  • Get Latest Tag


    List version-sorted remote tags that match a dotted triple and print the highest name, skipping peeled annotated-tag objects.

  • Get the Real Client IP


    Walk common proxy headers and REMOTE_ADDR, then return the first public IP that is not private or reserved, or Unknown if none validate.

  • GitHub Default Branch


    Parse a GitHub repository URL and return its default branch name from the GitHub API.

  • Gregorian Leap Year


    Return true when a year is a Gregorian leap year: divisible by 4, but not by 100 unless also divisible by 400.

  • Join an Array


    Join nameref array values with a separator, and optionally use a different separator before the last item for natural-language lists.

  • Keep Min or Max


    Return the smaller or larger of two comparable values so callers can keep a running minimum or maximum without writing the comparison themselves.

  • Locate a Command


    Search PATH for an executable name and return its expanded filesystem path, or a not-installed marker when nothing matches.

  • Logger Middleware


    Wrap a Node.js request handler so each response logs method, URL, status, and elapsed milliseconds when the response finishes.

  • Look Up an Array Key


    Look up a value by array key, with an optional case-insensitive search that still returns the original stored value.

  • Lowercase a String


    Allocate a lowercase copy of a C string with tolower and return it, or NULL if allocation fails.

  • Minimal HTTP Router


    Start a Node.js HTTP server with no framework: exact-path routes for / and /health, and a 404 for everything else.

  • N Most Expensive Queries


    Return the SQL Server plans that have used the most CPU, with execution count, total and average worker time, query text, and the XML plan for review.

  • Netmask to CIDR Prefix


    Return /N for a dotted IPv4 netmask, and reject masks whose 1-bits are not a contiguous prefix.

  • Next Matching Character


    Walk a string to the first occurrence of a character, then to the last character of that run, or to the terminator if it is missing.

  • Ordinal Suffix


    Return st, nd, rd, or th for an integer, treating 11, 12, and 13 as th.

  • Ordinal Suffix


    Return the English ordinal form of an integer, including the special cases 11th, 12th, and 13th as well as 1st, 2nd, and 3rd.

  • Ordinal Suffix


    Return an integer with its English ordinal suffix, treating 11, 12, 13 and other teens as th, and 1, 2, 3 as st, nd, rd.

  • Pad or Truncate


    Cut a list to a target length, or extend it with a fill value when it is shorter.

  • Parse CLI Flags


    Parse help, version, aflag, and b from short or long flags, and return the values keyed by the long name.

  • Parse Query String


    Read query parameters from an incoming request with WHATWG URL and searchParams, using a fallback when the key is missing.

  • Partition an Array


    Split a list into p slices of roughly equal size, spreading any remainder across the first groups so lengths differ by at most one.

  • Pause Until Enter


    Block until the user presses Enter, then continue; treat end-of-file as a clean exit so piped input does not hang.

  • Post a Slack Message


    Post a text message to a Slack incoming webhook, optionally setting the channel and username on the JSON payload.

  • Print a Stack Trace


    Walk Bash caller frames from the current function back toward main and print each frame as a compact stack trace.

  • Read a Password Silently


    Prompt for a password with read -s so the characters never appear on the terminal, then restore the cursor to a new line.

  • Record Script Invocation


    Record the current script's path, name, sourced-or-executed status, and arguments in variables for later logging or usage text.

  • Rename a Git Tag


    Point a new tag at the old one, delete the old name locally and on origin, then push tags so the renamed tag is published.

  • Replace a Substring


    Allocate a copy of a string with each case-insensitive match of from replaced by to, or only the first match when single is set.

  • Replace Placeholders


    Substitute each key from a nameref associative array with its value inside a file, using in-place sed for the replacements.

  • Require GNU Getopt


    Fail unless getopt --test exits 4, which only util-linux GNU getopt does, and point macOS users at brew gnu-getopt instead of BSD getopt.

  • Retry a Block


    Re-run a block with exponential backoff until it succeeds or hits a retry limit, sleeping longer after each failed attempt.

  • Retry a Callable


    Re-call a function with exponential backoff until it succeeds or reaches a retry limit, sleeping longer after each failed attempt.

  • Seconds to HH:MM:SS


    Format an integer number of seconds as a zero-padded HH:MM:SS clock string, including hours beyond 24 when the duration is long.

  • Session Timeout Modal


    A jQuery plugin that starts a session timer, shows a stay-signed-in modal after inactivity, and redirects to a logout URL if the user does not respond.

  • Silent Mode Helper


    When VERBOSE is false, send stdout and stderr to /dev/null, while still allowing a forced-output helper to print essential lines.

  • Simple CLI Flag Parser


    Turn process.argv flags of the form --key=value into an object, treating a bare --key as true.

  • Single-Instance Lock


    Take an exclusive flock on a /tmp lock file so a cron job or script exits instead of overlapping a previous run, with a noclobber fallback when flock is missing.

  • Sort by Several Columns


    Sort mappings by column names. A leading minus on a name sorts that column descending.

  • Strip from the End


    Overwrite trailing CR, LF, and a chosen character with NULs so the string no longer ends on those bytes.

  • Strip from the Front


    Advance a pointer past every leading occurrence of a character and return the first position that is not that character.

  • Terminal Prompt


    Ask a question on stdin with node:readline, wait for the answer as a promise, then close the interface.

  • Test a Git Work Tree


    Return success if the current or given directory sits inside a git work tree, without printing the repository root.

  • Uncaught Error Handlers


    Log unhandled promise rejections and uncaught exceptions so a process does not fail silently, then exit after an uncaught exception.

  • Uppercase a String


    Allocate an uppercase copy of a C string with toupper and return it, or NULL if allocation fails.

  • Weekday Name


    Return the weekday as a 0-Sunday index or as a short or long English name for a day, month, and year.