Skip to content

Instantly share code, notes, and snippets.

@stj
stj / reroute.sh
Created April 27, 2021 23:45
Reroute dynamic docker port to fixed local port
function pgreroute() {
re=':::([0-9]{1,5})->5432';
[[ $(docker ps -f "expose=5432") =~ $re ]];
port=${BASH_REMATCH[1]};
sudo iptables -t nat -I PREROUTING -p tcp --dport 5432 -j REDIRECT --to-ports $port;
sudo iptables -t nat -I OUTPUT -p tcp -o lo --dport 5432 -j REDIRECT --to-ports $port;
}
@stj
stj / keybase.md
Created October 8, 2019 16:21
onboarding

Keybase proof

I hereby claim:

  • I am stj on github.
  • I am stj (https://keybase.io/stj) on keybase.
  • I have a public key ASD3nxDDgpfqOIklwknCLhkX9Wl0xJxROLt0MnWy7zXumAo

To claim this, I am signing this object:

docker images | grep <whatever> | awk '{ print $3 }' | xargs docker rmi -f
@stj
stj / gist:b9f39f897c2bbefd9bdc471e7dfe1f87
Created May 10, 2018 17:45
[pytest] Run each test seperate to find tests that break the isolated/independent principal
pytest --collect-only | grep Function | cut -d"'" -f 2 | cut -d"[" -f 1 | uniq | xargs -n 1 pytest -qq -k
@stj
stj / debug_post_http_server.py
Created March 24, 2017 00:16
python3 debug post http server
import http.server
class DebugPostHandler(http.server.BaseHTTPRequestHandler):
def _set_headers(self):
self.send_response(200)
self.send_header('Content-type', 'text/plain; charset=utf-8')
self.end_headers()
def do_HEAD(self):
self._set_headers()