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 / custom-dns-resolver.go
Created January 19, 2025 01:08
A small Go snippet demonstrating how to use a custom DNS resolver to lookup IPs.
package main
import (
"context"
"fmt"
"net"
"time"
)
func main() {
@mike-weiner
mike-weiner / slack.sh
Created January 5, 2025 01:58
A simple Bash script that can be used to send Slack messages via curl to a Slack Channel using the Slack Block API.
#!/bin/bash
SLACK_CHANNEL="automation"
SLACK_URL="https://slack.com/api/chat.postMessage"
AS_USER=true
slackMsgHeaderBlock=$(
jq -n '{
type: "rich_text",
elements: [
@mike-weiner
mike-weiner / basic-linux-security.md
Last active January 23, 2025 02:04
An explanation of how to do basic security hardening of a Linux box.

Basic Linux Server Hardening

This document is meant to serve as a basic guide for hardening a Linux server.

Change Default Port Used by SSH

  1. sudo nano /etc/ssh/sshd_config
  2. Uncomment #Port 22 and change it to Port <SSH_PORT>. (Replace <SSH_PORT> with your desired port to use for SSH connectivity.)
  3. sudo systemctl restart ssh
  4. reboot
@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 March 25, 2025 08:27
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:

@mike-weiner
mike-weiner / weather-link-v2.py
Last active December 11, 2024 20:06
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>