Skip to content

Instantly share code, notes, and snippets.

View JamesWatling's full-sized avatar
🎧
Wired In

James Watling JamesWatling

🎧
Wired In
View GitHub Profile
@JamesWatling
JamesWatling / README.md
Created May 29, 2025 18:03
Mac OSX simulate poor network conditions

📡 simulate-network

A simple macOS utility to simulate different network conditions (e.g. 3G, 4G, edge, wifi) for all TCP and UDP traffic. Useful for testing how your app behaves under degraded or limited network environments.


✅ Features

  • Simulate bandwidth throttling, latency, and packet loss
  • Affects all TCP and UDP traffic (including WebRTC)
@JamesWatling
JamesWatling / gist:ef37e683c2f92cb576e90f9848422c06
Created September 13, 2024 00:03
Delete all local branches more than a month old that don't contain prod/staging/release/main with confirmation
#!/bin/bash
# Function to check branch age and filter out excluded branches
get_old_branches() {
git for-each-ref --sort=-committerdate refs/$1/ \
--format='%(refname:short)' \
| grep -v -E '(prod|staging|release|main)' \
| xargs -n 1 -I {} git log -1 --format="%ci {}" {} \
| awk -v date="$(date -v-30d +%Y-%m-%d)" '$1 <= date {print $4}'
}
@JamesWatling
JamesWatling / replace-debian-with-arch.txt
Created January 29, 2016 02:50 — forked from m-ou-se/replace-debian-with-arch.txt
Instructions to replace a live Debian installation with Arch
# Download latest archlinux bootstrap package, see https://www.archlinux.org/download/
wget http://ftp.nluug.nl/os/Linux/distr/archlinux/iso/2016.01.01/archlinux-bootstrap-2016.01.01-x86_64.tar.gz
# Make sure you'll have enough entropy for pacman-key later.
apt-get install haveged
# Install the arch bootstrap image in a tmpfs.
mount -t tmpfs none /mnt
cd /mnt
tar xvf ~/archlinux-bootstrap-2016.01.01-x86_64.tar.gz --strip-components=1
@JamesWatling
JamesWatling / Cleanup merged branches except develop and staging
Last active January 22, 2016 03:42
Bash script to remove all merged branches except production and staging
#Credit to http://snippets.freerobby.com/post/491644841/remove-merged-branches-in-git for the script on which this is based
current_branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
if [ "$current_branch" != "master" ]; then
echo "WARNING: You are on branch $current_branch, NOT master."
fi
echo "Fetching merged branches..."
git remote prune origin
remote_branches=$(git branch -r --merged | grep -v '/master$' | grep -v "/$current_branch$")
local_branches=$(git branch --merged | grep -v 'master$' | grep -v "$current_branch$")
if [ -z "$remote_branches" ] && [ -z "$local_branches" ]; then