Skip to content

Instantly share code, notes, and snippets.

View DerekBuntin's full-sized avatar

Derek Buntin DerekBuntin

View GitHub Profile
@DerekBuntin
DerekBuntin / gist:c4f1f615ff20e009e947619667c9bd55
Created August 26, 2024 05:48
Find and remove folders recursively - Terminal
# One Liner
find . -type d \( -name "thumbs" -o -name "list" \) -exec rm -rf {} +
# Array
#!/bin/bash
@DerekBuntin
DerekBuntin / gist:a5abd2524f1bb46f4057c85009515015
Last active August 26, 2024 05:44
Find all images within a folder and recursively convert to webp and resize.
#!/bin/bash
# Define the main images folder
main_images_folder="images"
# Define the desired width for the images
target_width=738
# Find and process all image files recursively
find "${main_images_folder}" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.gif" -o -iname "*.tif" -o -iname "*.tiff" -o -iname "*.bmp" -o -iname "*.webp" \) | while read file; do
@DerekBuntin
DerekBuntin / gist:f78de4eb1ad90bc3c33dcc61bd02d5b5
Created July 30, 2024 08:08
Short Number Formatter for PHP & Laravel Helper (1000 to 1K; 1M; 1B; 1T)
/**
* Format numbers to their abbreviated form
*
* Converts the given number to an abbreviated string representation, adding a suffix of 'K', 'M', 'B', or 'T'
* to represent thousands, millions, billions, and trillions, respectively.
*
* @param float $number The number to format
* @param int $precision The decimal precision to use for the formatted number
* @return string The abbreviated string representation of the number
*/