Skip to content

Instantly share code, notes, and snippets.

View isurfer21's full-sized avatar

Abhishek Kumar isurfer21

View GitHub Profile
@isurfer21
isurfer21 / clean-node-modules.sh
Created November 22, 2026 07:36
Bash script to recursively delete node_modules directories inside a target path while excluding specified subdirectories.
#!/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:
@isurfer21
isurfer21 / md2pdf.ps1
Created November 17, 2026 05:47
Markdown to PDF converter CLI wrapper made using Pandoc
<#
.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.
@isurfer21
isurfer21 / rename-files.ts
Created June 6, 2026 11:13
Bun based system utility to handle pattern matching, sorting, and renaming files flawlessly in batch.
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);
@isurfer21
isurfer21 / claude-uninstall.sh
Created April 17, 2026 05:43
A zsh script to uninstall claude code, if installed via curl or shell-script.
#!/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
@isurfer21
isurfer21 / mongodb-manager.sh
Created February 4, 2026 09:44
MongoDB Service Manager for macOS (using Homebrew)
#!/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)
@isurfer21
isurfer21 / gen-video-list.ts
Created December 4, 2025 16:17
A CLI tool to generate video list for a given directory to be used with FFmpeg app.
#!/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'
]);
@isurfer21
isurfer21 / sync-dir.sh
Created November 30, 2025 07:15
Shell script to synchronize source directory to target directory on external hard disk
#!/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() {
@isurfer21
isurfer21 / node_modules_age.sh
Last active August 5, 2025 05:33
A CLI tool which calculates the age of the node_modules directory in days.
#!/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
@isurfer21
isurfer21 / generate_ssh_key.sh
Created July 15, 2025 04:02
Here's a simple Bash script that generates an SSH key pair (if one doesn't already exist) and displays the public key so you can copy it to a remote system for SSH access:
#!/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..."
@isurfer21
isurfer21 / concatenate-files.sh
Last active July 3, 2025 09:03
Here's a Bash script that recursively traverses a directory, reads each file, and concatenates them into a single output file. It adds a comment at the top of each file's content using the appropriate syntax based on the file extension.
#!/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%/}"