Skip to content

Instantly share code, notes, and snippets.

@tsprlng
tsprlng / README
Created April 4, 2012 00:48
The Pysh Language
This is a Pysh script based on an 'idealized' partial re-implementation of my uta utility.
Pysh will basically be a language (or set of ugly macros) for quickly hacking shell-scripty tasks in Python.
Theoretically you get the luxury of Python idioms like generators, context managers, and meaningful whitespace, with the flexibility to hurl data between other programs in various convenient ways that don't involve Popen.
All the best languages have quirky special characters, right? (It's not like Perl, I promise.)
#!/usr/bin/ruby
unsurprising = "## master...origin/master"
check = "git status --porcelain -b"
show = "git status -sb"
system show unless `#{check}`.strip == unsurprising
@tsprlng
tsprlng / vpc-hosts-hack.rb
Last active August 29, 2015 14:20
Amazon VPC /etc/hosts hack
#!/usr/bin/env ruby
require 'pp'
require 'json'
require 'fileutils'
require 'set'
# Filter for specific Route 53 hosted zones
#
# Fix word-break characters
defaults write .GlobalPreferences AppleTextBreakLocale en_US_POSIX
# Apply user's Dvorak layout settings to the startup login screen
sudo mv /Library/Preferences/com.apple.HIToolbox.plist{,.old}
sudo cp {$HOME,}/Library/Preferences/com.apple.HIToolbox.plist
sudo chown root:wheel /Library/Preferences/com.apple.HIToolbox.plist
sudo chmod 644 /Library/Preferences/com.apple.HIToolbox.plist
@tsprlng
tsprlng / authorized_keys
Created June 13, 2016 11:12
¿Sufficiently? paranoid deploy script
# Allow the 'deployer' key to run only the redeploy script; pass the given arguments (i.e. service name) to the script
# e.g. $ ssh deployer@server restartable-thing
#
command="/home/deployer/redeploy.sh $SSH_ORIGINAL_COMMAND",no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding ssh-rsa «public-key» deployer@ci-server
@tsprlng
tsprlng / README.md
Created November 28, 2016 13:49
windows-vpn-route-silliness

Config

Configure the VPN not to be the default route (Untick "Use default gateway on remote network", buried way down in the adapter TCP settings), otherwise this is a bit pointless.

Triggering

Set up scheduled tasks triggered on 'an event':

@tsprlng
tsprlng / README.md
Created April 4, 2018 19:39
Working around the pain of moving from aws_security_group with ingress/egress to aws_security_group_rules in Terraform

In Terraform you might want to replace ingress/egress rules directly on an aws_security_group with individual aws_security_group_rules, so that they work properly.

To do this, first make the required *.tf changes. Great. Now the plan contains only rule additions, and application fails due to the collision with the undeleted old rules.

    terraform state rm aws_security_group.the_sg
    terraform import aws_security_group.the_sg sg-deadbeef

Great. Now it's imported a bunch of aws_security_group_rules called aws_security_group_rule.the_sg and aws_security_group_rule.the_sg-1 up to -whatever, rather than the aws_security_group_rule.descriptive_name you wanted.

Keybase proof

I hereby claim:

  • I am tsprlng on github.
  • I am tsprlng (https://keybase.io/tsprlng) on keybase.
  • I have a public key whose fingerprint is 27A6 F882 EE9D C295 4B3A 8974 F952 1BA7 ABB6 1EF3

To claim this, I am signing this object:

@tsprlng
tsprlng / zoom
Last active December 30, 2020 23:41
zoom.us without ruining my arch install
#!/usr/bin/zsh
meeting_id="$1"
image_name='tsprlng/zoom' # Originally mdouchement/zoom-us:latest but ran `docker commit` once correct config was set
# TODO build a smaller image (sadly jessfraz's won't speak to my pulse server -- older lib version?)
# TODO build a tar for runc instead of using docker
args=()
#!/bin/zsh -eu
set -o pipefail
# Main directory full of Git repos
GIT_DIRECTORY=~/work/git
# Branches to ensure (if they exist) are checked out and constantly updated from origin.
# Anything weird I'm doing that could fail to rebase should be in a nicely separated branch / worktree anyway!
# TODO replace this fixed list with pattern filter on remote branches
CANONICAL_SYNC_BRANCHES=(master develop v2.{2..9})