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 / 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
@yolabingo
yolabingo / pg_delete_tables
Created June 10, 2021 16:11
delete all tables from a posgres database
DO $$ DECLARE
r RECORD;
BEGIN
-- if the schema you operate on is not "current", you will want to
-- replace current_schema() in query with 'schematodeletetablesfrom'
-- *and* update the generate 'DROP...' accordingly.
FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP
EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(r.tablename) || ' CASCADE';
END LOOP;
END $$;
update_config:
delay: 3m
parallelism: 1
failure_action: rollback