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}
# .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
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.
@snarlysodboxer
snarlysodboxer / find_duplicates.rb
Created January 30, 2016 01:23
Find (and optionally delete) duplicate files in directories using md5sum
#!/usr/bin/env ruby
# Usage:
# `./find_duplicates.rb 'directory to search*'` for a dry run, and
# `./find_duplicates.rb 'directory to search*' --delete` to actually delete the duplicates.
find_path = ARGV[0]
delete = false
delete = true if ARGV[1] == "--delete"
files = `find #{find_path} -type f`.split "\n"
@snarlysodboxer
snarlysodboxer / white_space_police.sh
Created December 21, 2015 21:44
White space police for Ruby files
#!/bin/bash
# remove trailing whitespace
find ./ -name '*.rb' -exec sed -i "s/\s\+$//g" {} +
# switch tabs for two spaces
find ./ -name '*.rb' -exec sed -i "s/\t/ /g" {} +
# auto indent with Vim
# open any file in Vim, then:
:args ~/code/myproject/**/*.rb | argdo execute "normal gg=G" | update