Skip to content

Instantly share code, notes, and snippets.

View theothermattm's full-sized avatar

Matt M. theothermattm

View GitHub Profile
@theothermattm
theothermattm / tmux-sessions.sh
Created January 30, 2024 15:17
Setup predefined TMUX sessions with splits
#!/bin/zsh
# https://superuser.com/a/440082
SESSIONNAME="number1"
tmux has-session -t $SESSIONNAME &> /dev/null
if [ $? != 0 ]
then
tmux new-session -s $SESSIONNAME -n script -d
tmux split-window -v -t $SESSIONNAME
@theothermattm
theothermattm / postgres_restore.sql
Created September 8, 2023 16:38
Simple bash script to restore a postgres backup
#!/bin/bash
# helper script to import a postgres export locally
if [[ -z $1 || -z $2 ]];
then
echo 'example usage: ./database-import.sh name-of-export.sh database_name'
exit 1
fi
set -o nounset
@theothermattm
theothermattm / randomized-pairing.py
Created September 7, 2023 20:41
Randomized name pairing in python
"""Console script for python_boilerplate."""
import argparse
import random
import sys
import math
def main():
"""Console script for python_boilerplate."""
parser = argparse.ArgumentParser()
@theothermattm
theothermattm / aws-client-vpn.tf
Created August 22, 2023 13:37
Terraform for creating AWS Client VPN
# source: https://spak.no/blog/article/63f519260faeadeeeb968af2
# good resource: https://spak.no/blog/article/63f519260faeadeeeb968af2
# generating PKI certs using easyrsa: https://docs.aws.amazon.com/vpn/latest/clientvpn-admin/mutual.html
resource "aws_acm_certificate" "server_vpn_cert" {
certificate_body = file("pki/server.crt")
private_key = file("pki/server.key")
certificate_chain = file("pki/ca.crt")
@theothermattm
theothermattm / mastodon.mermaid
Created December 15, 2022 18:17
Mastodon Architecture
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@theothermattm
theothermattm / scans.sql
Created October 25, 2022 16:37
Identify Sequential Scans in PostGreSQL
SELECT relname,
seq_scan,
seq_tup_read,
idx_scan,
idx_tup_fetch,
seq_tup_read / seq_scan
FROM pg_stat_user_tables
WHERE seq_scan > 0
ORDER BY seq_tup_read DESC;
@theothermattm
theothermattm / load-envs.sh
Created June 3, 2022 15:23
Bash: Load environment vars from .env file
# Load Environment Variables from .env
if [ -f .env ]; then
export $(cat .env | grep -v '#' | sed 's/\r$//' | awk '/=/ {print $1}' )
fi
@theothermattm
theothermattm / engineering-management.md
Created December 9, 2021 20:49
Go To Engineering Management Resources
@theothermattm
theothermattm / vim-movement.ahk
Created December 2, 2021 16:54
Windows AutoHotKey Remap CAPSLOCK+HJKL to Vim Movement Keys
; Main Navigation
CAPSLOCK & j::MoveCursor("{DOWN}")
CAPSLOCK & l::MoveCursor("{RIGHT}")
CAPSLOCK & k::MoveCursor("{UP}")
CAPSLOCK & h::MoveCursor("{LEFT}")
; Navigation Combos
MoveCursor(key) {
shift := GetKeyState("SHIFT","P")
control := GetKeyState("CONTROL","P")
<html>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/charts.css/dist/charts.min.css">
<body >
<h1>
Are charts awesome? </h1>
<table class="charts-css [ column ] [ show-primary-axis show-4-secondary-axes ] [ data-spacing-4 reverse-data ]">
<caption>Are charts awesome?</caption>