The Ultimate
Snippet Library.

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

SQL

Pivot Data from Rows to Columns with Conditional Aggregation

Transform your row-based data into a cross-tabular report by pivoting values from a specific column into multiple new columns using SQL's CASE statements and aggregate functions.

View Snippet →
SQL

Traverse Hierarchical Data with Recursive SQL CTEs

Explore how to query and navigate hierarchical or tree-like data structures, such as organizational charts, threaded comments, or bill of materials, using SQL's powerful recursive Common Table Expressions.

View Snippet →
SQL

Identify and Remove Duplicate Rows Keeping One Instance

Learn to clean your database by identifying duplicate records based on specific columns and efficiently removing them, ensuring data integrity by retaining a single unique entry for each set.

View Snippet →
SQL

Calculate Running Total or Cumulative Sum in SQL

Discover how to compute a running total or cumulative sum for a series of values, ordered by a specific column, using SQL window functions for financial, sales, and analytical reports.

View Snippet →
JAVASCRIPT

Extract All URLs from Text

Discover how to use a JavaScript regex pattern to efficiently find and extract all complete URLs (http/https) embedded within a larger string of text.

View Snippet →
JAVASCRIPT

Parse Semantic Version Strings

Use regex in JavaScript to accurately parse semantic version strings (e.g., '1.2.3-beta.4'), extracting major, minor, patch, and pre-release components.

View Snippet →
BASH

Automating MySQL Database Backup and Compression

Learn to create a robust Bash script for automating MySQL database backups, compressing them, and storing them with a timestamp for easy recovery.

View Snippet →
BASH

Basic Web Service Availability Check

Implement a simple Bash script to check the availability of a web service by making a GET request and verifying the HTTP status code (e.g., 200 OK).

View Snippet →
BASH

Deploying Static Website Files with Rsync

Streamline your static website deployments using a Bash script with `rsync` to efficiently synchronize local files to a remote server over SSH.

View Snippet →
BASH

Automatically Purging Old Log Files

Create a Bash script to automatically identify and delete log files older than a specified number of days, helping manage disk space on web servers.

View Snippet →
BASH

Generating Dynamic Nginx Virtual Host Configuration

Learn to dynamically generate Nginx virtual host configuration files using a Bash script, useful for automating the setup of new web projects or domains.

View Snippet →
JAVASCRIPT

Extract All Numeric Digits from Text

Discover how to extract all contiguous numeric digits from any string using JavaScript's `match` method with a global regular expression. Useful for data parsing and cleaning.

View Snippet →