Skip to content

Instantly share code, notes, and snippets.

@mmguero
mmguero / get-docker-shasums.sh
Created May 5, 2026 20:28
get the sha256 sums of some docker images matching a pattern
for IMG in $(docker images --format json | jq -r '"\(.Repository):\(.Tag)"' | grep -P "idaholab/malcolm.+:26\.05\.0"); do img='IMAGE:TAG'; docker inspect --format='{{range .RepoDigests}}{{println .}}{{end}}' "$IMG" | awk -v repo="${IMG%:*}" '$0 ~ "^"repo"@sha256:" {print; exit}'; done
@mmguero
mmguero / resize-image.sh
Created April 23, 2026 20:38
resize raspberry pi .img file
#!/bin/bash
set -euo pipefail
usage() {
cat <<EOF
Usage:
$0 <image-file> [new-size] [partition-number]
Arguments:
image-file Path to the disk image
@mmguero
mmguero / age-functions.sh
Created April 4, 2026 21:44
wrappers for password-based decrypt/encrypt with age
# shred a file if possible, and rm it if not
function shred_file {
TARGET="$1"
if [[ -n $TARGET ]] && [[ -f "$TARGET" ]]; then
type shred >/dev/null 2>&1 && shred -f -u "$TARGET" || rm -f "$TARGET"
fi
[[ -n $TARGET ]] && [[ ! -f "$TARGET" ]] && return 0 || return 1
}
# shred a file with user-provided confirmation
@mmguero
mmguero / .envrc
Last active March 10, 2026 20:11
pull artifacts from GitLab and load with docker
export GITLAB_URL=https://repo.example.org
export GITLAB_ACCESS_TOKEN=
export PROJECT_ID=
export PROJECT_BRANCH=development
export JOB_ID=create-tar
export OUTPUT_DIR=./artifacts
export CLEAN_OUTPUT_DIR=true
export EXTRACT_ARTIFACTS=true
@mmguero
mmguero / pcap-times.sh
Created February 19, 2026 18:35
PCAP file time ranges
for f in *.*; do
IFS=$'\t' read -r start end <<EOF
$(capinfos -a -e "$f" |
awk -F'time:[[:space:]]*' '/time:/{sub(/\..*/,"",$2); print $2}' |
paste -sd $'\t' -)
EOF
jo -n -- "$f=$(jo start="$start" end="$end")"
done
@mmguero
mmguero / llama-server.sh
Created January 9, 2026 05:02
run llama-server on a CPU-only box with a bunch of RAM
File: llama-server.sh
#!/usr/bin/env bash
# Paths
LLAMA_BIN="./llama.cpp/build/bin/llama-server"
MODELS_DIR="./models"
# Network
HOST="127.0.0.1"
PORT="8081"
@mmguero
mmguero / redis-keys.sh
Last active January 8, 2026 22:20
get redis keys/values
export REDISCLI_AUTH="$REDIS_PASSWORD" && \
redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" -n "$REDIS_FILESCAN_PRESERVATION_DATABASE" --scan |
while read -r key; do
type=$(redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" -n "$REDIS_FILESCAN_PRESERVATION_DATABASE" TYPE "$key")
echo "KEY: $key ($type)"
case "$type" in
list)
redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" -n "$REDIS_FILESCAN_PRESERVATION_DATABASE" LRANGE "$key" 0 -1 | jq
;;
esac
@mmguero
mmguero / inpainting_experiment.json
Created December 11, 2025 04:28
inpainting_experiment.json
{
"id": "5f2a65e4-b103-48d4-9c24-daefba71eeff",
"revision": 0,
"last_node_id": 23,
"last_link_id": 37,
"nodes": [
{
"id": 7,
"type": "CLIPTextEncode",
"pos": [
@mmguero
mmguero / JSONata query.md
Created November 20, 2025 15:56
JSONata for Uptime Kuma to check Malcolm's ready api

This can check the results of the Malcolm ready API with JSONata.

  • sample data:
{"arkime":true,"dashboards":true,"dashboards_maps":true,"filebeat_tcp":true,"freq":true,"logstash_lumberjack":true,"logstash_pipelines":true,"netbox":true,"opensearch":true,"pcap_monitor":true,"zeek_extracted_file_logger":true,"zeek_extracted_file_monitor":true}
  • query:
$sum($map($.*, function($v){ $v ? 1 : 0 })) = $count($.*)
@mmguero
mmguero / broken-md-links.sh
Created November 18, 2025 23:41
find broken anchor links in a directory of markdown (.md) files that reference each otehr