Skip to content

Instantly share code, notes, and snippets.

View vijayhardaha's full-sized avatar
💻
Working on WordPress

Vijay Hardaha vijayhardaha

💻
Working on WordPress
View GitHub Profile
@vijayhardaha
vijayhardaha / discover-and-clean-up-plugin-generated-custom-post-meta-keys-and-options.md
Created October 6, 2023 11:13
Discover and Clean Up Plugin-Generated Custom Post Meta Keys and Options

Discover and Clean Up Plugin-Generated Custom Post Meta Keys and Options

When managing WordPress plugins, it's crucial to identify and remove any lingering custom post meta keys and options created by plugins you no longer use. This custom shell function, scan-plugin-meta-options-keys(), simplifies the process of searching for and identifying these meta keys and options within your WordPress database.

How to Use the Function in Your Shell Configuration Files

You can add the scan-plugin-meta-keys() function to your shell configuration files (e.g., .bashrc, .bash_profile, or .zshrc) to make it available each time you start a new terminal session. Here's how to add and utilize the function in your shell configuration:

  1. Open Visual Studio Code or your preferred code editor.
@vijayhardaha
vijayhardaha / effortless-node-js-cleanup-remove-package-lock-files-and-node-modules.md
Last active October 6, 2023 11:04
Effortless Node.js Cleanup: Remove Package Lock Files and node_modules Folder

Node.js Cleanup: Remove Package Lock Files and node_modules Folder

If you've worked with Node.js projects, you're probably familiar with the package-lock.json, yarn.lock, pnpm-lock.yaml files, and the node_modules folder. While these are essential for managing dependencies, they can take up significant space and sometimes need a clean slate.

Here's a handy alias that removes these files and the node_modules folder from the current directory:

alias rm-node-modules='rm -v package-lock.json yarn.lock pnpm-lock.yaml && rm -rfv node_modules'
@vijayhardaha
vijayhardaha / alias-for-removing-ds-store-files.md
Last active October 6, 2023 11:03
Effortless Cleanup: Removing .DS_Store Files Recursively with One Command

Alias for Removing .DS_Store Files

If you're a macOS user, you've probably come across those pesky .DS_Store files that macOS creates to store metadata about directories. These files can clutter your file system, and sometimes you just want to get rid of them.

Here's a useful alias that finds and deletes all .DS_Store files within the current directory and its subdirectories, while providing verbose output so you can see which files are being removed:

alias rm-dsstore='find . -name ".DS_Store" -type f -exec rm -v {} \;'
@vijayhardaha
vijayhardaha / reinstall-wordpress-core-skip-content-forcefully.md
Last active September 24, 2023 19:09
Reinstall WordPress Core (Skip Content) Forcefully

Reinstall WordPress Core (Skip Content) Forcefully

Occasionally, you might need to reinstall the WordPress core files without affecting your website's content. This alias, wp-reinstall, simplifies the process of downloading and reinstalling the WordPress core files, excluding the content directory, to ensure a fresh core installation.

How to Use the Alias

You can use the wp-reinstall alias in your terminal to trigger the WordPress core reinstallation. Here are the steps:

  1. Open Your Terminal: Launch your terminal or command prompt.
@vijayhardaha
vijayhardaha / get-and-copy-your-public-ip-addresses-in-cli.md
Created September 24, 2023 19:01
Get and Copy Your Public IP Addresses in the Command Line

Get and Copy Your Public IP Addresses in the Command Line

Frequently, you might need to retrieve and use your public IP addresses in various scenarios. These aliases, ip6 and ip4, simplify the process of obtaining your public IPv6 and IPv4 addresses and copying them to your clipboard.

How to Add and Use the Aliases in Your Shell Configuration Files

You can add the ip6 and ip4 aliases to your shell configuration files (.bashrc, .bash_profile, or .zshrc) for convenient access in every terminal session. Follow these steps to add and use the aliases in your shell configuration:

  1. Open Visual Studio Code or your preferred code editor.
@vijayhardaha
vijayhardaha / find-all-git-repositories-in-cli.md
Created September 24, 2023 18:59
Find All Git Repositories in a directory using the Command Line

Find All Git Repositories within a directory using the Command Line

When working with multiple Git repositories in various directories, it's helpful to quickly locate them within the command line. This custom shell function, find-git-dirs(), allows you to search for all Git repositories in the current directory and its subdirectories.

How to Use the Function in Your Shell Configuration Files

You can add the find-git-dirs() function to your shell configuration files (.bashrc, .bash_profile, or .zshrc) to make it available each time you start a new terminal session. Here's how to add and utilize the function in your shell configuration:

  1. Open Visual Studio Code or your preferred code editor.
@vijayhardaha
vijayhardaha / find-large-size-files-in-cli.md
Created September 24, 2023 18:56
Find Large Size Files in the Command Line

Find Large Size Files in the Command Line

When managing your files and directories in the command line, it's important to locate and manage large files that may be consuming significant storage space. This custom shell function, find-large-files(), enables you to search for files larger than a specified size.

How to Use the Function in Your Shell Configuration Files

You can add the find-large-files() function to your shell configuration files (.bashrc, .bash_profile, or .zshrc) to make it available each time you start a new terminal session. Here's how to add and utilize the function in your shell configuration:

  1. Open Visual Studio Code or your preferred code editor.
@vijayhardaha
vijayhardaha / find-large-size-directories-in-cli.md
Created September 24, 2023 18:55
Find Large Size Directories in the Command Line

Find Large Size Directories in the Command Line

When managing your files and directories in the command line, it's often useful to identify large directories that may be consuming a significant amount of storage space. This custom shell function, find-large-dirs(), allows you to search for directories larger than a specified size.

How to Use the Function in Your Shell Configuration Files

You can add the find-large-dirs() function to your shell configuration files (.bashrc, .bash_profile, or .zshrc) to make it available every time you start a new terminal session. Follow these steps to add and use the function in your shell configuration:

  1. Open Visual Studio Code or your preferred code editor.
@vijayhardaha
vijayhardaha / whatsapp-30-seconds-video-splitter.md
Last active September 24, 2023 18:36
Split a video into 30 seconds video for whatsapp video status

Split a Video into 30-Second Clips for WhatsApp Video Status

WhatsApp status updates are a popular way to share short video clips with your contacts. However, WhatsApp has a limitation where video status updates must be 30 seconds or less in duration. To make it easier to create these short video clips, you can use a simple bash script that splits a longer video into multiple 30-second segments.

Prerequisites

Before we dive into the script, ensure you have the following prerequisites:

  • A Linux or macOS system.
  • FFmpeg installed on your system. You can typically install it using your system's package manager.
@vijayhardaha
vijayhardaha / cloudflare-firewall-rules-generation.md
Last active September 24, 2023 18:41
A Node Script for Generating Cloudflare Firewall Rules: Blocking Bots by Matching User Agents, Hostnames, and IP Addresses.

Generate Cloudflare Firewall Blocking Rules to Block Bots

Cloudflare is a widely used content delivery network (CDN) and security service that allows you to protect your website from various threats, including malicious bots. One way to block bots is by creating firewall rules that match specific user agents, hostnames, and IP addresses. This Node.js script automates the generation of such rules and has been tested on Node.js version 16.

Prerequisites

Before we dive into the script, make sure you have the following prerequisites:

  • Node.js installed on your system.
  • NPM (Node Package Manager) installed.