Skip to content

Instantly share code, notes, and snippets.

View bdowling's full-sized avatar
📈
Onward and Upward!

Brian Dowling bdowling

📈
Onward and Upward!
View GitHub Profile
@bdowling
bdowling / watch-for-changes-then
Last active February 20, 2023 13:45
Fun little script I use to watch for file changes with inotifywait and then run commands when they are modified.
#!/bin/bash
# quick script to make using inotifwatch easier for simple cases,
# such as when you are editiing files and you want to scp them to another
# system as soon as you make save changes.
#
# Brian Dowling
set -e
@bdowling
bdowling / cgroup-cpu-throttling
Last active September 22, 2024 20:06
This script started out briefly, but turned into an actual generally useful tool for inspecting cgroup hierarchy. Particularly useful for seeing the effect of Kubernetes CPU Requests and Limits and throttling that is occuring.
#!/usr/bin/env python3
#
# Script to help find cgroup cpu throttling in a k8s cluster
#
# Brian Dowling
#
import subprocess
import argparse
#!/bin/sh
# This script helps you find something if you have tons of open panes...
#
#
# $0 '[a]bcdef'
notthispane=$TMUX_PANE
if [ "$1" = "-a" ]; then
notthispane=''
@bdowling
bdowling / NATs-Replay.py
Last active August 20, 2019 02:25
These are just some sample scripts to dump the nats stream and replay it to a local NATs server.
#!/usr/bin/env python
from nats.aio.client import Client as NATS
import json
import asyncio
import logging
import argparse
import gzip
import glob
import time
#!/bin/sh
#
# Simple script to watch a source folder for changes and run rsync on demand as changes occur
#
SRC=$1
DEST=$2
@bdowling
bdowling / RESULTS
Last active January 18, 2019 22:54
Dead Simple Python Data Manipulation for Ansible
TASK [Filter data structures more easily] **********************************************************************************************************************************************************************************************
task path: /home/bdowling/src/plays/kiss.yaml:14
ok: [localhost] => {
"ansible_facts": {
"filtered": [
{
"age": 35,
"birthday": 1,
"id": 1,
"name": "Bob",
#!/usr/bin/env python
from __future__ import print_function
import argparse
import csv
import re
import os
import sys
def warn(*args, **kwargs):
@bdowling
bdowling / install_python3.6_opensuse42.3.sh
Created March 7, 2018 00:35 — forked from amoilanen/install_python3.6_opensuse42.3.sh
Installing Python 3.6 on OpenSUSE Leap 42.3
# !/bin/bash
# Step 1. Install pyenv
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc
# Step 2. Install missing headers for all the Python modules to be built
@bdowling
bdowling / ssh-by-ip-cache.sh
Last active July 13, 2017 15:11
Kinda simple but awesome way to ssh to hosts by IP but using the known_hosts name cache, e.g. if DNS is down or otherwise not resolving.
# yes, there are many ways to simpify this, but it's just a quick hack...
getsship() { fgrep $( fgrep "$1" ~/.ssh/known_hosts |head -1| awk '{print $3}') ~/.ssh/known_hosts | egrep -o '(^[0-9\.]+)'; }
sshbyip() { name=$1; shift; ssh $(getsship "$name") "$@"; }
# and if you want tab completion (assuming _ssh tab completion loaded)
# this test doesn't work, not sure yet what best way to copy the complete from 'ssh' comand is yet given how it is dynamically loaded.
# and not avaialble at .bashrc loading.. if type _ssh >/dev/null; then
if shopt -q progcomp && [ -n "$BASH_COMPLETION_COMPAT_DIR" ]; then
complete -F _ssh sshbyip
complete -F _ssh getsship
#!/bin/bash
#
# Script to start or restart a left and right tmux session
# Can be called multiple times and does the right thing(tm)
#
# Makes use of swind and xdotool to arrange windows on screen
# https://gist.github.com/bdowling/ad87c58362af7c28806bb2292436222d
#
# by Brian Dowling
#