Skip to content

Instantly share code, notes, and snippets.

@snarlysodboxer
snarlysodboxer / stern-all-contexts.sh
Created January 19, 2023 18:48
use stern across contexts
#!/usr/bin/env bash
set -o pipefail -o errexit
# use like:
# ./stern-all-contexts.sh <pod-name>
# or:
# EXCLUDE_CONTEXTS='docker-desktop|other-context' ./stern-all-contexts.sh <pod-name>
EXCLUDE_CONTEXTS=${EXCLUDE_CONTEXTS:-docker-desktop}
@snarlysodboxer
snarlysodboxer / zero_disk.sh
Last active June 19, 2020 10:32
Write zeros over all of the free space on your disk. Afterwards, remove a small file before removing the big file to help the system be more responsive in the meantime.
#!/bin/sh
dd if=/dev/zero of=$HOME/zero.small.file iflag=nocache oflag=direct bs=1024 count=102400
dd if=/dev/zero of=$HOME/zero.file iflag=nocache oflag=direct bs=4096
rm $HOME/zero.small.file
rm $HOME/zero.file
# .config/yamllint/config
---
extends: default
rules:
empty-lines:
max-end: 1
indentation:
indent-sequences: false
line-length:
@snarlysodboxer
snarlysodboxer / swap-imports.sh
Created June 4, 2020 16:09
Swap Go Imports, for working with forked repos
#!/bin/bash
if [ "$1" != "snarly" ] && [ "$1" != "fr" ]; then
echo "specify snarly or fr"
exit 1
fi
if [ "$1" == "snarly" ]; then
find . -name '*.go' | xargs sed -i.bak 's/ForgeRock\/secret-agent/snarlysodboxer\/secret-agent/'
sed -i.bak 's/ForgeRock\/secret-agent/snarlysodboxer\/secret-agent/' go.mod
@snarlysodboxer
snarlysodboxer / scaling_flat_file_ops.md
Created July 13, 2018 20:14
Notes on scaling file uploads, storage, retrieval, & background processing.

Scaling file uploads, storage, retrieval, & background processing

Storage

Object store systems like Openstack Swift, Minio, and Ceph are worth consideration. They offer various advantages in scalability, accessibility, and things like arbitrary object metadata. Most of them also have S3 compatible APIs if that makes things easier.

If instead we need or desire to read files from traditional mounted filesystems, GlusterFS is one option worth considering. With it's Distributed Replicated configuration, storage space can be scaled by adding more disks, and access speed can be scaled by adding more nodes. It's supported by Kubernetes, and has systems for asynchronous replication, usually used for syncing the data to another datacenter. It can support replicate

@snarlysodboxer
snarlysodboxer / main.go
Last active July 6, 2018 19:39
dead man switch, and other options
package main
import (
"flag"
"fmt"
"os"
"syscall"
"time"
)
@snarlysodboxer
snarlysodboxer / hambone_train_of_thought.md
Last active July 5, 2018 02:07
Train of thought for the development of hambone
  • We want an API server for CRUDing nearly identical k8s specs, but want to be able to customize anything about any one of them.
  • Chose gRPC/Protocol Buffers for the API, primarily for the free code generation, but also for the advanced networking smarts built into gRPC. Swagger docs and a JSON/Rest gateway can be auto-generated from the proto file.
  • A major goal for the project is replica safety. - We want to run multiple copies of the API server to eliminate the majority of types of downtime for clients.
  • I went through 2 major re-writes on this project.
    • The first version was a quick spike as a Golang package for use in custom apps. It uses jq (and yq) to render yaml templates and apply them via kubectl.
    • I then decided that with the right abstractions an open source app could be developed (hambone).
  • hambone's first version was built as a standalone binary, with plug-able state storage and k8s adapters. It hoped to avoid executing other processes (often miss-referenced as "shelling out",) and
@snarlysodboxer
snarlysodboxer / basic_pkgs
Last active December 9, 2016 16:03
Quickly install some basic packages on a Ubuntu machine.
#!/bin/bash
sudo apt-get update && sudo apt-get install -y htop tmux vim man nmap curl git-core sysstat bwm-ng iotop ipcalc sl mtr dnsutils
Mon Aug 15 17:26:01 UTC 2016
@snarlysodboxer
snarlysodboxer / mtrak.conf
Last active August 13, 2016 09:20
A config for Macbook Pro trackpad in mtrak in Ubuntu. https://github.com/BlueDragonX/xf86-input-mtrack/
Section "InputClass"
MatchIsTouchpad "on"
Identifier "Touchpads"
Driver "mtrack"
# TrackpadDisable - Disables trackpad touch input. A value of 0 will enable the trackpad. A value of 1 will disable tapping and gestures but not movement. A value of 2 will disable all input. A value of 3 will also disable physical buttons. Integer. Default is 0.
# Sensitivity - Adjusts the sensitivity (movement speed) of the touchpad. This is a real number greater than or equal to zero. Default is 1. A value of 0 will disable pointer movement.
Option "Sensitivity" "0.65"
# FingerHigh - Defines the pressure at which a finger is detected as a touch. This is a percentage represented as an integer. Default is 5.
Option "FingerHigh" "12"
# FingerLow - Defines the pressure at which a finger is detected as a release. This is a percentage represented as an integer. Default is 5.