Skip to content

Instantly share code, notes, and snippets.

View coltenkrauter's full-sized avatar
🔥
Fire

Colten Krauter coltenkrauter

🔥
Fire
  • Stevensville, MT
View GitHub Profile
@coltenkrauter
coltenkrauter / auto-brightness-plugged-in-macos.md
Created February 19, 2025 03:44
Automatically sets macOS screen brightness to 100% when plugged into power. Uses a LaunchDaemon and pmset to listen for power state changes in real-time. Event-driven, no polling.

Real-Time Brightness Adjustment When Charging (macOS)

This solution automatically sets your macOS display brightness to 100% when the power adapter is connected. It leverages a LaunchDaemon that runs a persistent script listening for power state changes via pmset. This event-driven approach ensures immediate response without unnecessary polling.

Requirements

  • macOS (tested on recent versions)
  • brightness CLI (install directly from GitHub, see below)
  • Administrative privileges
@coltenkrauter
coltenkrauter / git-branch-status.sh
Created January 30, 2025 00:29
This script checks the status of your current Git branch against the remote default branch. It informs you of uncommitted changes, unpushed commits, and whether your branch is ahead or behind the default branch, with clear, color-coded output.
git_branch_status() {
# Define colors
local GREEN="\033[0;32m"
local RED="\033[0;31m"
local YELLOW="\033[0;33m"
local CYAN="\033[0;36m"
local RESET="\033[0m"
# Get current and default branches
local CURRENT_BRANCH=$(git branch --show-current)
@coltenkrauter
coltenkrauter / find-all-truenas-vm-ips.sh
Created January 14, 2025 16:41
This script identifies the IP addresses of all VMs running on TrueNAS SCALE. It queries the system using midclt to retrieve MAC addresses for each VM and uses arp to resolve them to IP addresses.
midclt call vm.query | jq -r '
.[] |
select(.status.state=="RUNNING") |
.devices[] |
select(.dtype=="NIC") |
.attributes.mac' | while read -r mac; do
echo -n "$mac: "
arp -a | grep -i "$mac" | awk '{print $1, $2}'
done
@coltenkrauter
coltenkrauter / feature-brancher.sh
Last active November 8, 2024 18:23
Automatically switches to main, pulls latest changes, and creates a branch feature/user/YYYY-MM-DD/INDEX, incrementing the index if branches exist for the day. Streamlines date-indexed feature branch creation in Git.
# Creates a feature branch with date-indexed naming based on $USER.
# Add this function to your .bashrc or .zshrc file for easy access in every terminal session.
#
# Example:
# If $USER is "ckrauter" and today is 2024-11-08:
# Running `fb` creates a branch like `feature/ckrauter/2024-11-08/1`.
# Running `fb utils package` creates `feature/ckrauter/utils-package/2024-11-08/1`.
feature_branch() {
local main_branch="main"
@coltenkrauter
coltenkrauter / traefik-proxy-for-home-assistant-lan-ip-configuration.md
Created November 4, 2024 15:56
Traefik configuration file for proxying Home Assistant running on a LAN IP within a TrueNAS Scale VM. This configuration allows Traefik to handle HTTPS requests and route them to the Home Assistant service, ensuring secure access to your smart home environment.

Traefik Proxy for Home Assistant on LAN IP

This guide explains how to set up Traefik as a reverse proxy for Home Assistant running on a local network IP. It includes creating a dataset for Traefik configs, setting up a Docker Compose file, creating the necessary Docker volume and network, and configuring Home Assistant to trust the proxy.

1. Create a Docker Network

Before running the Traefik stack, create a Docker network that Traefik will use:

docker network create traefik_proxy
@coltenkrauter
coltenkrauter / remove-ip-ban-truenas.md
Created November 4, 2024 15:37
Instructions to remove `ip_bans.yaml` in Home Assistant OS on TrueNAS Scale VM.

Remove IP Ban in Home Assistant OS on TrueNAS Scale VM

This guide explains how to access the TrueNAS Scale VM's serial shell, delete the ip_bans.yaml file in Home Assistant OS, and optionally edit configuration.yaml.

Accessing the Serial Shell in TrueNAS Scale VM

  1. Open TrueNAS Scale UI:

    • Log into your TrueNAS Scale dashboard.
  2. Navigate to Virtual Machines:

@coltenkrauter
coltenkrauter / high-availability.md
Last active October 23, 2024 03:22
High Availability

High Availability

This document is intended to facilitate discussions and promote industry best practices for cloud-based services to achieve a resilient posture, or high availability. Achieving a highly resilient posture means being prepared for all kinds of failures such as natural disasters, security breaches, network failures, software bugs, high traffic loads, unexpected user behaviors, and the capacity to handle the unexpected gracefully and lightning fast. High availability is the product of coordinated efforts in people, processes, and technical strategy, including but not limited to,

  • Disaster Recovery strategy (ranging from backups to full active/active multi-cloud deployments)
  • Continuous deployment (infrastructure-as-code, automated unit/integration/load testing, staggered deployments to multiple regions with bake-time and rollback alarms)
  • Observability (covering KPIs, health indicators, and assum
@coltenkrauter
coltenkrauter / correct-commit-author-for-all-commits.sh
Created September 6, 2024 17:00
Update all commits of a branch with new author and committer information.
NEW_AUTHOR_NAME="John Doe"
NEW_AUTHOR_EMAIL="[email protected]" # Private Git Email
# Start filter-branch to rewrite the author information for all commits
git filter-branch -f --env-filter '
CORRECT_NAME="'"$NEW_AUTHOR_NAME"'"
CORRECT_EMAIL="'"$NEW_AUTHOR_EMAIL"'"
export GIT_COMMITTER_NAME="$CORRECT_NAME"
@coltenkrauter
coltenkrauter / detailed-home-assistant-os-installation-in-vm-on-truenas-scale.md
Last active February 14, 2025 23:34
Comprehensive instructions for installing Home Assistant OS in a VM on TrueNAS SCALE.