Skip to content

Instantly share code, notes, and snippets.

@tsprlng
tsprlng / http-server
Last active February 25, 2023 01:26
basic http server for local dev, but not too basic (i.e. supports index.html but also /dir)
#!/usr/bin/env python
import os.path as ospath
import socket
from http.server import *
class Server(HTTPServer):
address_family = socket.AF_INET6
pass
@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=()
@tsprlng
tsprlng / docker-lock-versions
Created April 30, 2020 15:53
Get docker image hash from tag name for lockfile purposes
#!/usr/bin/env python3
import base64
import json
import requests
from os import environ, path
try:
UserPass = environ['DOCKER_HUB_AUTH']
except:
@tsprlng
tsprlng / dt.rb
Last active November 1, 2019 19:33
Date converter utility for things that want shitty Unix timestamps
#!/usr/bin/ruby
# This program converts dates (from a semi-memorable, short format similar to the standard `date` utility).
# It will output them as unix timestamps (it will also accept ISO dates for this conversion).
# Or, it can output them in ISO8601, but this will always be in UTC because timezones are pointless.
require 'date'
class Usage < StandardError
end
@tsprlng
tsprlng / fix-aws-lb-listener-rule-priorities.rb
Created May 17, 2019 17:47
Correct aws_lb_listener_rule priorities to avoid Terraform recreating them unnecessarily
#!/usr/bin/ruby
# Terraform can't adjust priorities of `aws_lb_listener_rule`s without recreating them.
# If you have external dependencies on the ARNs this can be quite annoying.
# This script will fetch the ARNs out of terraform state and produce JSON to apply the defined priorities using `aws elbv2 set-rule-priorities`.
# Usage:
# $ terraform workspace select <environment-or-whatever>
# $ aws --region eu-west-1 elbv2 set-rule-priorities --rule-priorities $(./fix-aws-lb-listener-rule-priorities.rb)
var t = document.querySelector('.GEHJJTKDEAB table tbody'); var l=[]; for(let c of t.children){ l.push(c); } l.sort((a,b)=>{ let ta=a.children[1].innerText.split('.').reverse().join('.');let tb=b.children[1].innerText.split('.').reverse().join('.'); return (ta==tb)?0:(ta>tb)?1:-1}); t.innerHTML=''; l.forEach((c)=>{t.appendChild(c);});
#!/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})
@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.)

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 / 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.