Skip to content

Instantly share code, notes, and snippets.

View yolabingo's full-sized avatar

Todd Jacobsen yolabingo

  • New Mexico, USA
View GitHub Profile
@yolabingo
yolabingo / docker-nuke.sh
Last active July 22, 2020 04:22
remove all docker containers and volumes
#!/bin/sh
docker stop $( docker ps -qa ); docker container rm $( docker container ls -qa ); docker volume rm $( docker volume ls -q )
# Eternal bash history.
# ---------------------
# Undocumented feature which sets the size to "unlimited".
# http://stackoverflow.com/questions/9457233/unlimited-bash-history
HISTCONTROL=ignoreboth:erasedups
HISTFILESIZE=
HISTSIZE=
HISTTIMEFORMAT="%F %T "
# Change the file location because certain bash sessions truncate .bash_history file upon close.
name="dotcms"; ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519_$name -C $name
@yolabingo
yolabingo / pg_table.py
Last active October 30, 2020 06:24
separate a pg_dump file into individual tables
# first `mkdir tables`
dump_file = 'DUMPFILE.sql'
with open(dump_file, 'r') as sql:
table = None
for line in sql.readlines():
if line.startswith('COPY public.'):
t = line.split()[1]
print(f"opening {t}")
table = open(f"tables/{t}", 'w')
@yolabingo
yolabingo / server.xml
Created January 28, 2021 02:20
server.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@yolabingo
yolabingo / install-pg.sh
Created February 2, 2021 15:37
amazon linux install postgres 12
yum remove -y libpq.x86_64 postgresql.x86_64 postgresql-server.x86_64
cat <<EOF > /etc/yum.repos.d/pgdg.repo
[pgdg12]
name=PostgreSQL 12 for RHEL/CentOS 7 - x86_64
baseurl=https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-7-x86_64
enabled=1
gpgcheck=0
EOF
yum makecache
yum install postgresql12
@yolabingo
yolabingo / main.py
Created February 20, 2021 17:11 — forked from stewartadam/main.py
Simple Python proxy server based on Flask and Requests with support for GET and POST requests.
"""
A simple proxy server, based on original by gear11:
https://gist.github.com/gear11/8006132
Modified from original to support both GET and POST, status code passthrough, header and form data passthrough.
Usage: http://hostname:port/p/(URL to be proxied, minus protocol)
For example: http://localhost:5000/p/www.google.com
"""
import re
@yolabingo
yolabingo / sdm-completion.bash
Last active November 4, 2022 20:49
strongDM bash completion of hostnames for "sdm ssh [hostname]"
#/usr/bin/env bash
# fetch server hostnames from `sdm status` to use as completions for `sdm ssh [hostname]`
# save the sdm status to a local file from a cron job to speed this up a lot:
# sdm status --filter 'TYPE:ssh*' | tail -n +2 | awk '{print $1}' | sort -u > /var/tmp/sdm-status
# h/t https://iridakos.com/programming/2018/03/01/bash-programmable-completion-tutorial
update_frequency=4h
compwords_file=/var/tmp/sdm-status
@yolabingo
yolabingo / install-docker-compose.sh
Last active March 11, 2021 00:12
install docker-compose on amazon linux arm64
sudo yum install -y python3-devel gcc docker
sudo useradd -m -G docker -s /bin/bash docker
sudo su - docker
python3 -m venv python3-env
source python3-env/bin/activate
# or export PATH=$HOME/python3-env/bin:$PATH and add to .bash_profile
# upgrade pip first else you may get rust errors while building docker-compose
pip install --upgrade pip
pip install docker-compose

General OpenSSL Commands

Generate a new private key and Certificate Signing Request

openssl req -out CSR.csr -new -newkey rsa:2048 -nodes -keyout privateKey.key

Generate a self-signed certificate (see How to Create and Install an Apache Self Signed Certificate for more info)

openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout privateKey.key -out certificate.crt