Skip to content

Instantly share code, notes, and snippets.

View skwid138's full-sized avatar
πŸ…
Tiger Style

Hunter Rancourt skwid138

πŸ…
Tiger Style
View GitHub Profile
@skwid138
skwid138 / functions.sh
Last active March 8, 2025 17:46
Simple Functions
#!/bin/bash
## Count all files including hidden in a given directory
countf() {
ls -lAR "$1" | grep '^-' | wc -l
}
## Count all non-hidden files in a given directory
countf_a() {
ls -lR \$1 | grep '^-' | wc -l
@skwid138
skwid138 / base64_2_json.sh
Created February 24, 2025 19:23
This script decodes base64-encoded strings to JSON and pretty-prints the output, supporting both direct command-line input and standard macOS base64 options.
#!/bin/bash
# Script to decode base64 and pretty-print JSON while supporting standard base64 options
# Check for jq dependency
check_dependencies() {
if ! command -v jq &>/dev/null; then
echo "Error: This script requires 'jq' but it's not installed." >&2
echo "To install jq on macOS, run: brew install jq" >&2
echo "For other platforms, visit: https://stedolan.github.io/jq/download/" >&2
@skwid138
skwid138 / mov2gif.sh
Last active January 22, 2025 23:50
Script that converts any video to an optimized GIF using FFmpeg’s two-pass palette generation method
#!/usr/bin/env bash
#
# mov2gif - Convert a video to an optimized GIF using FFmpeg.
# Utilizes a two-pass palette generation method.
# Default values
FPS=10
SCALE=320
OUTPUT=""
@skwid138
skwid138 / git_detect_conflict.sh
Created January 8, 2025 17:20
Compare branches in a Git repository, detect merge conflicts, and display detailed outputs with options for verbosity and branch customization.
#!/bin/bash
# Default values
base_branch=""
compare_branch=""
verbose=false
compare_all=false
# Help documentation
usage() {
@skwid138
skwid138 / aliases.sh
Last active March 1, 2025 22:52
Some handy aliases
#!/bin/bash
## List all files and exclude directories in current directory (ls -p adds trailing slash to directories | ls -x displays mul$
alias lsf="ls -apx | grep -v /"
## List only directories in current path
alias lsd="ls -d -1 */ | lolcat"
@skwid138
skwid138 / auto_nvm.sh
Last active December 6, 2024 15:55
Automatically look for a .nvmrc file, install and/or change the version of node to the version listed in the .nvmrc. Works for ZSH and BASH
#!/bin/bash
# Store the last checked directory to avoid redundant `.nvmrc` checks
LAST_NVM_DIR=""
# Load the correct Node.js version based on the `.nvmrc` file
load_nvmrc() {
# Get the current working directory
local current_dir="$(pwd)"
@skwid138
skwid138 / cmd_docker_restart.sh
Created December 5, 2024 18:25
Dynamically get a running container name, execute a command in the container, and restart the container.
#!/bin/bash
# Find the correct docker-compose file
if [ -f "docker-compose.yml" ]; then
DOCKER_COMPOSE_FILE="docker-compose.yml"
elif [ -f "docker-compose.yaml" ]; then
DOCKER_COMPOSE_FILE="docker-compose.yaml"
else
echo "Error: Could not find 'docker-compose.yml' or 'docker-compose.yaml'."
exit 1
@skwid138
skwid138 / npm_cmd_docker.sh
Last active March 12, 2025 21:46
Dynamically parse a Dockerfile to find the image used and run commands in that image. Useful for installing packages in the exact environment the app will run in.
#!/bin/bash
### Keep the Gist updated!
# https://gist.github.com/skwid138/b360dbab95bee28a424f350301454092
###
# File paths
DOCKERFILE="Dockerfile"
# Extract the image used in the builder stage (case-insensitive)
@skwid138
skwid138 / git_rev_list.sh
Last active November 25, 2024 19:43
This script compares the number of commits between a base branch and a specified or current branch in a Git repository.
#!/bin/bash
# Default values
base_branch=""
compare_branch=""
# Help documentation
usage() {
echo "Usage: $0 [OPTIONS]"
echo ""
@skwid138
skwid138 / github_workflow_tail.sh
Last active December 2, 2024 23:36
This script monitors the a GitHub Actions Workflow for the current repository. Defualts to the latest workflow, allows for providing an optional voice notification upon completion, with customizable voice and message options.
#!/bin/bash
# Default values for optional arguments
VOICE=""
MESSAGE="workflow completed"
WORKFLOW_NAME=""
function show_help() {
echo "Usage: workflow_tail.sh [options]"
echo ""