Skip to content

Instantly share code, notes, and snippets.

View mike-weiner's full-sized avatar

Michael Weiner mike-weiner

View GitHub Profile
@mike-weiner
mike-weiner / Dockerfile.network-debug
Created September 10, 2024 00:28
A Docker container image that can be used to conduct network troubleshooting and debugging.
# Useage:
# 1. Build Image: docker build -t network-debug -f Dockerfile.network-debug .
# 1a. Ensure Image is Built: docker images
# 2. Create Container from Image: docker run -d network-debug
# 3. Exec into Container: docker exe -it <containerID> bash
# 4. Stop Container After Usage: docker stop <containerID>
FROM alpine:latest
RUN apk upgrade --allow-untrusted && \
@mike-weiner
mike-weiner / kubectl.md
Last active August 13, 2024 18:18
Helpful `kubectl` Commands

Helpful kubectl Commands

This Markdown file is a collection of helpful kubectl commands that I repeadetly finding myself using.

Pods

  • Print the name of every container in a pod on a newline: kubectl get pod -n <namespace> <podname> -o jsonpath='{range .spec.containers[*]}{.name}{"\n"}{end}'
  • Print the name of every container (and its image) found inside of a pod: kubectl get pod -n -o jsonpath='{range .spec.containers[*]}{.name}{" | "}{.image}{"\n"}{end}
@mike-weiner
mike-weiner / echoserver-daemonset.yaml
Created March 29, 2024 12:44
A k8s echoserver Daemonset that can be helpful for debugging. Not intended for production use.
# This YAML describes a rudimentary echoserver DaemonSet
# that can be useful for debugging purposes, especially
# when it comes to Services.
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: echoserver-debug
namespace: default
labels:
@mike-weiner
mike-weiner / brew-install-specific-formula.md
Last active April 4, 2024 20:30
An explanation of how to install a specific version of a Homebrew formula.

Install Previous Homebrew Formula

Sometimes you need to install a specific, older version of an existing Homebrew Formula. In this guide I am going to demonstrate how to install an older version of kubectl, but it can be generalized for an Formula.

The Kubernetes CLI is available as a Homebrew Formulae: https://formulae.brew.sh/formula/kubernetes-cli#default

At the time of writing, my only options to install kubectl via Homebrew are:

  • brew install kubectl
    • Would install the default version of v1.29
  • brew install kubectl@1.29 or brew install kubectl@1.28
@mike-weiner
mike-weiner / weather-link-v2.py
Last active June 13, 2024 16:24
A Python script to serve as a template for WeatherLink API calls using the newer authentication method.
@mike-weiner
mike-weiner / weatherlink-stations.sh
Created June 3, 2023 19:48
A curl command to obtain the weather stations that your WeatherLink account has access to.
@mike-weiner
mike-weiner / discord-webhook.sh
Created May 29, 2023 16:06
A curl command to send automated bot messages via a webhook into a Discord channel.
curl \
-H "Content-Type: application/json" \
-d '{"content":"Your bot's message for the Discord channel goes here!"}' \
<your-discord-webhook-url>
@mike-weiner
mike-weiner / videocrop.sh
Last active January 11, 2023 02:48
A bash script that uses FFmpeg to crop a video.
#!/bin/bash
# Function that will print requirements if the user passes in the -help flag as the first argument.
function help
{
echo "Parameters are: "
echo " <filename>: The full filename of the video that you want to crop."
}
# Check for '-help' flag.
@mike-weiner
mike-weiner / git-command-line-prompt.sh
Created May 21, 2022 00:27
Modifies the command line prompt to include Git repository information (if applicable).
# Modifies the Command Line Prompt to the following format:
# <Username> <Current Directory Name> <Current Git Branch Name (if applicable)> %
# Load version control information
autoload -Uz vcs_info
precmd() { vcs_info }
# Format the vcs_info_msg_0_ variable
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' formats '(%b)'
@mike-weiner
mike-weiner / docker-alias.sh
Created May 21, 2022 00:24
An alias to start Docker Desktop from the command line.
alias startdocker='open -a docker'