The Ultimate
Snippet Library.

Hundreds of production-ready scripts and coding solutions.
Brought to you by the experts at DigitalCodeLabs.

BASH

Check if a Port is in Use or a Service is Running

Write a Bash script to verify if a specific TCP port is actively being used by a process or if a given service process is currently running on the system.

View Snippet →
BASH

Batch Rename Multiple Files with a Specific Pattern

Learn to use a Bash script to efficiently rename multiple files in a directory by applying a common prefix, suffix, or replacing parts of their names.

View Snippet →
PHP

Find Common Values Across Multiple PHP Arrays

Efficiently identify and extract all values that are present in every one of several PHP arrays using the `array_intersect` function, useful for data validation or finding common elements.

View Snippet →
PHP

Re-index PHP Array After Element Removal

Understand how to reset and re-sequence numeric keys in a PHP array after elements have been removed using `unset`, ensuring sequential indexing starting from zero.

View Snippet →
CSS

Prevent Orphaned Last Flex Item in `space-between` Layout

Prevent the last flex item from being left alone at the start of a row when using `justify-content: space-between` and `flex-wrap`, ensuring consistent distribution.

View Snippet →
CSS

Responsive CSS Grid Two-Column Layout with Sidebar

Create a flexible, responsive two-column layout using CSS Grid, transitioning from a stacked mobile view to a sidebar and main content desktop view.

View Snippet →
CSS

Truncate Text with Ellipsis Inside a Flex Item

Learn how to correctly apply `text-overflow: ellipsis` to text within a flex item, preventing text from overflowing and ensuring a clean, truncated display.

View Snippet →
CSS

Overlay Text or Badges on an Image Using CSS Grid

Create dynamic overlays like captions, badges, or buttons on top of images or cards efficiently using CSS Grid for precise positioning and stacking.

View Snippet →
CSS

Dynamic Flexbox Item Distribution with `gap` and `flex-grow`

Create a responsive layout where flex items distribute dynamically, fill available space, and maintain consistent spacing using `gap` and `flex-grow` properties.

View Snippet →
PHP

Filter an Array by Custom Criteria in PHP

Learn how to filter PHP arrays using a custom callback function with `array_filter` to keep only elements meeting specific conditions, enhancing data manipulation.

View Snippet →
PHP

Custom Sort an Array of Associative Arrays in PHP

Discover how to sort complex PHP arrays of associative arrays or objects using `usort()` with a custom comparison function for flexible, multi-criteria ordering.

View Snippet →
PHP

Extract a Column from an Array of Arrays in PHP

Learn how to efficiently extract specific values from a designated column within an array of associative arrays using PHP's powerful `array_column()` function.

View Snippet →