Skip to content

Snippets

A searchable catalogue of reusable code snippets and helpers, organised by language and tags, providing developers with a central place to discover practical examples, reusable utilities, and ready-to-use solutions for common programming tasks and everyday development workflows.

Latest Snippets

  • Get Latest Tag


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

  • Get Default Branch


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

  • Sort by Several Columns


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

  • Pad or Truncate


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

  • 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.

  • Parse CLI Flags


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

  • Check Prerequisites


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

  • GitHub Default Branch


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

  • Netmask to CIDR Prefix


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