Skip to content

Instantly share code, notes, and snippets.

View tym-xqo's full-sized avatar
🖤

Thomas Yager-Madden tym-xqo

🖤
View GitHub Profile
-- other generic comment
/* :meta
foo: bar
columns:
- foo
- bar
- quux
- quuux
params:
select c.table_schema
, c.constraint_name
, c.table_name
, k.column_name
, u.table_schema as foreign_table_schema
, u.table_name as foreign_table_name
, u.column_name as foreign_column_name
from information_schema.table_constraints as c
join information_schema.key_column_usage as k
on c.constraint_name = k.constraint_name
@tym-xqo
tym-xqo / README.md
Last active March 26, 2025 17:04
`psql` invocation with automatic ssh tunnel

psql invocation with automatic ssh tunnel

The idea here is you set yourself up with an entry in your ~/.ssh/config with a LocalForward to the Postgres port on the host you want to connect to. (The SSH connection itself might be to the same host or a remote bastion. LocalForward is a honey badger.) Then, create or add to your ~/.pg_service.conf file with a service name that matches the host name from your SSH config. See examples below, and just edit the included dummy values to suit your environment. Note that matching the host names between the two config files is the key to making this work nicely.

(Which port you choose to forward is arbitrary, but it's a good idea NOT to use the default Postgres port of 5432, to avoid any potential conflict with any Postgres service you might have running locally.)

Once you have that configured, the teeny but mighty bash script below will create an [auto-closing SSH tunnel](https://www.g-loaded.e

pluscodes

Code from google/open-location-code is not usable in my environment. So I made a simple wrapper.

encode and decode are only methods in index. They ruturn false instead of throwing error

yarn add gist:70446302e9c04d29713c96cb94c55e3f

@tym-xqo
tym-xqo / incremental_pull.py
Last active April 15, 2019 15:49
Incremental session data pull
import os
from argparse import ArgumentParser
from pathlib import Path
import records
from dotenv import load_dotenv
from sh import psql
from sqlalchemy.exc import ProgrammingError
load_dotenv()
@tym-xqo
tym-xqo / Nadir.itermcolors
Last active January 25, 2019 22:19
Dark variant adapted from Apex theme <https://github.com/heidar/iterm2-apex> for iTerm2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.0</real>
@tym-xqo
tym-xqo / app.py
Created November 29, 2018 23:26
Responder routing with optional path
import responder
api = responder.API()
@api.route("/")
def hmm(req, resp):
resp.media = {"status": "ok"}
#!/usr/bin/env bash
# invoke with `watch -n 5`
hostname
uptime | cut -d ',' -f 4-6
free -h
echo ''
psql -U postgres -c 'select count(*) as conns, state from pg_stat_activity group by 2;'
psql -U postgres -c 'select pid, locktype, mode, granted from pg_locks where not granted;'
@tym-xqo
tym-xqo / namer.bash
Created November 1, 2018 15:39
script to call namer cloud function
#!/bin/bash
# get name from namer, copy to clipboard and echo to console
http -b https://us-central1-whereami-map.cloudfunctions.net/namer | tr -d '\n' |pbcopy
pbpaste
echo
@tym-xqo
tym-xqo / README.md
Last active July 27, 2018 17:09
Gcloud static site deployer

Usage

  • Download gcloud-static-deploy.sh
  • chmod +x gcloud-static-deploy.sh; mv gcloud-static-deploy.sh /usr/local/bin/gcloud-static-deploy
  • cd to directory with your static site, then invoke the script with gcloud-static-deploy

NB: Assumes you have httpie installed, in addition GCloud SDK installed and authorized