Skip to content

Instantly share code, notes, and snippets.

@mmguero
mmguero / a_list_of_steps.md
Last active July 31, 2025 21:13
example for k3s deployment for single-node cluster

Setup

  1. install k3s
    • curl -sfL https://get.k3s.io | sh -
    • or
    • k3sup install --local --k3s-channel v1.33 --k3s-extra-args="--data-dir=/media/extra/k3s --kubelet-arg=root-dir=/media/extra/kubelet"
  2. sudo cp /etc/rancher/k3s/k3s.yaml /home/user/kubeconfig
  3. sudo chown user:user /home/user/kubeconfig
  4. install ingress-nginx
    • kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.13.0/deploy/static/provider/cloud/deploy.yaml
@mmguero
mmguero / find_collisions.sh
Created July 17, 2025 15:53
find "collisions" (_version > 1) in an opensearch index (using a slow scroll)
#!/usr/bin/env bash
# Config
INDEX="arkime_sessions3-*"
SIZE=1000
SCROLL_DURATION="1m"
AUTH="--config /var/local/curlrc/.opensearch.primary.curlrc"
BASE_URL="https://opensearch:9200"
COLLISIONS_RAW="colliding_docs_raw.json"
COLLISIONS_PRETTY="colliding_docs_pretty.json"
@mmguero
mmguero / wireguard.conf
Created June 20, 2025 14:37
wireguard AllowedIPs for all public IP space
[Peer]
AllowedIPs = 0.0.0.0/5, 8.0.0.0/7, 11.0.0.0/8, 12.0.0.0/6, 16.0.0.0/4, 32.0.0.0/3, 64.0.0.0/2, 128.0.0.0/3, 160.0.0.0/5, 168.0.0.0/6, 172.0.0.0/12, 172.32.0.0/11, 172.64.0.0/10, 172.128.0.0/9, 173.0.0.0/8, 174.0.0.0/7, 176.0.0.0/4, 192.0.0.0/9, 192.128.0.0/11, 192.160.0.0/13, 192.169.0.0/16, 192.170.0.0/15, 192.172.0.0/14, 192.176.0.0/12, 192.192.0.0/10, 193.0.0.0/8, 194.0.0.0/7, 196.0.0.0/6, 200.0.0.0/5, 208.0.0.0/4, 224.0.0.0/3
@mmguero
mmguero / expect_party.sh
Created May 15, 2025 17:44
spawn a command with expect and interact with it
expect -c '
spawn your_command
sleep 30
send "\r"
interact
'
@mmguero
mmguero / scoop-update-all.ps1
Created May 6, 2025 18:59
scoop update all ignoring failures
scoop status | ForEach-Object {
if ($_ -match '^(@{Name=)?(\S+?);?\s+(\S+)\s+(\S+)\s+(.*)') {
$name = $matches[2]
$installedVersion = $matches[3]
$latestVersion = $matches[4]
if ($installedVersion -ne $latestVersion) {
try {
scoop update $name
} catch {
Write-Host "Failed to update $name" -ForegroundColor Red
@mmguero
mmguero / python_wc_testing.py
Last active March 25, 2025 15:02
Benchmarking different methods for getting text file line counts with Python (wc batched, wc thread pool, wc, and mmap)
#!/usr/bin/env python3
import os
import sys
import mmap
import subprocess
import time
from multiprocessing import Pool
@mmguero
mmguero / rename-seq.sh
Created November 4, 2024 05:49
rename files sequentially with leading zeroes, keeping extension
num=0; for i in *; do mv "$i" "$(printf '%04d' $num).${i#*.}"; ((num++)); done
@mmguero
mmguero / shake256file.py
Last active October 30, 2024 23:39
shake_256 hash of file
import hashlib
import sys
with open(sys.argv[1], 'rb', buffering=0) as f:
print(hashlib.file_digest(f, 'shake_256').hexdigest(8))
@mmguero
mmguero / podman-macos.md
Last active September 17, 2024 14:34
notes for running Podman on macOS
@mmguero
mmguero / git_add_parent_forks.sh
Created September 5, 2024 14:52
loop through directories and add remotes for parents when they exist
for DIR in *; do pushd "$DIR" >/dev/null 2>&1; export URL="https://api.github.com/repos/$(git remote -v| grep -P "origin.*push" | head -n 1 | cols 2 | sed "s/.*github\.com\///" | sed "s/\.git$//")"; export PARENT="$(curl -fsSL -H "Authorization: token $GITHUB_TOKEN" "$URL" | jq -r '.parent.html_url')"; [[ "$PARENT" != "null" ]] && export FORKNAME="$(echo "$PARENT" | cut -d'/' -f4)" && echo "$FORKNAME" && git remote add "$FORKNAME" "$PARENT"; popd >/dev/null 2>&1; done