This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| show_help() { | |
| cat << EOF | |
| Usage: $(basename "$0") [OPTIONS] <target_directory> [exclude_subdir1] [exclude_subdir2] ... | |
| Recursively finds and completely removes all 'node_modules' directories inside | |
| <target_directory>, while skipping specified subdirectories. | |
| Arguments: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| Converts a Markdown file to a styled PDF using Pandoc and XeLaTeX. | |
| .DESCRIPTION | |
| Converts a specified Markdown (.md) file into a PDF using Pandoc with the | |
| XeLaTeX engine, 0.75-inch margins, Cambria for body text, and Consolas for | |
| monospace code blocks. If no output path is specified, the PDF is saved in | |
| the same directory with the same base filename. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { readdirSync } from "node:fs"; | |
| import { rename } from "node:fs/promises"; | |
| import { join } from "node:path"; | |
| const [searchPattern, replacePattern] = Bun.argv.slice(2); | |
| if (!searchPattern || !replacePattern) { | |
| console.log("Usage:\n bun rename-files.ts '<search_pattern>' '<replace_pattern>'"); | |
| console.log("Example:\n bun rename-files.ts 'Screenshot *.png' 'pic-*.png'"); | |
| process.exit(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/zsh | |
| confirm() { | |
| local prompt="$1" | |
| local response | |
| while true; do | |
| # -n prevents newline, read -r prevents backslash escapes | |
| read -r "?$prompt [y/N]: " response | |
| case "$response" in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env zsh | |
| # MongoDB Service Manager for macOS (using Homebrew) | |
| # Usage: ./mongodb-manager.sh [start|stop|restart|status] | |
| SERVICE_NAME="mongodb-community" | |
| SERVICE_PATH="mongodb/brew/$SERVICE_NAME" | |
| case "$1" in | |
| start) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bun | |
| import { readdir, writeFile, stat } from 'fs/promises'; | |
| import { resolve, join, extname } from 'path'; | |
| // Define common video file extensions (lowercase) | |
| const VIDEO_EXTENSIONS = new Set([ | |
| '.mp4', '.mkv', '.avi', '.mov', '.wmv', '.flv', '.webm', '.m4v', '.3gp' | |
| ]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/zsh | |
| # Script to synchronize source directory to target directory on external hard disk | |
| # Default: one-way sync without deleting files on target. | |
| # Options: | |
| # -d, --dry → Simulate deletions (dry-run with --delete) | |
| # -x, --prune → Perform actual deletions (--delete) | |
| # -h, --help → Show help menu | |
| show_help() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Define the path to the node_modules directory | |
| NODE_MODULES_DIR="node_modules" | |
| # Check if node_modules directory exists | |
| if [ ! -d "$NODE_MODULES_DIR" ]; then | |
| echo "node_modules directory does not exist." | |
| else | |
| # Get the last modified time of the most recently modified file in node_modules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Set the key file path | |
| KEY_PATH="$HOME/.ssh/id_rsa" | |
| # Check if the SSH key already exists | |
| if [ -f "$KEY_PATH.pub" ]; then | |
| echo "SSH key already exists at $KEY_PATH.pub" | |
| else | |
| echo "Generating a new SSH key..." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Function to get relative path from given absoule path & base path | |
| get_relative_path() { | |
| local absolute_path="$1" | |
| local base_path="$2" | |
| # Remove trailing slashes for consistency | |
| absolute_path="${absolute_path%/}" | |
| base_path="${base_path%/}" |
NewerOlder