Skip to content

Instantly share code, notes, and snippets.

Avatar
🤓
Hey there! I am using GitHub.

Will Power willpower232

🤓
Hey there! I am using GitHub.
View GitHub Profile
@willpower232
willpower232 / postal_database_size.sql
Last active Feb 3, 2020
get the Postal database size for each mail server
View postal_database_size.sql
SELECT sizes.dbname, orgs.`name` AS org, servers.`name` AS `server`, sizes.size
FROM (
SELECT substring(sizes.table_schema, 15) AS fakeid, sizes.table_schema AS dbname, ROUND(SUM(sizes.data_length + sizes.index_length) / 1024 / 1024, 1) AS size
FROM information_schema.`TABLES` AS sizes
GROUP BY sizes.table_schema
) AS sizes, postal.servers AS servers, postal.organizations AS orgs
WHERE servers.id = sizes.fakeid
AND servers.organization_id = orgs.id
ORDER BY org, `server`
@willpower232
willpower232 / downloadgithubasset.sh
Created Jan 27, 2020
Interactive terminal menu to download an asset from a known github repo release
View downloadgithubasset.sh
#!/bin/bash
# usage
# downloadgithubasset.sh mozilla/sops
# downloadgithubasset.sh mozilla/sops 3.4.0
if ! [ -x "$(command -v jq)" ]; then
echo 'Error: jq is not installed.' >&2
exit 1
fi
@willpower232
willpower232 / create_delegated_dns_zone.sh
Created Dec 13, 2019
Create an AWS Route53 zone in a delegation set and change the NS record to match your vanity nameservers
View create_delegated_dns_zone.sh
#!/bin/bash
if [ -z "$1" ]; then
echo "Please specify domain name"
exit 1
fi
initials="WH"
delegationsetid="YOUR-DELEGATED-SET-ID"
@willpower232
willpower232 / download_interactively_from_s3.sh
Created Dec 13, 2019
How to loop through folders in AWS S3, select a file, and download it
View download_interactively_from_s3.sh
#!/bin/bash
target="s3://your-AWS-bucket-here/"
file=""
# if you're looking for a specific file extension
# you can do something like this instead
# while [[ "$target" != *.tgz ]]; do
# while there is a slash at the end of the path
@willpower232
willpower232 / passmenu.sh
Last active Nov 11, 2019
dmenu script for pass
View passmenu.sh
#!/usr/bin/env bash
# 1 - source copy from https://geluk.io/p/passmenu.sh (https://github.com/Baggykiin/pass-winmenu)
# 2 - make dmenu case insensitive
# 3 - correct include_username variable
# 4 - only pick out usernames if they are the start of the sentence, i.e. ignore non-primary usernames listed in the file (mostly for bitbucket)
# 5 - dependency test and install
shopt -s nullglob globstar
@willpower232
willpower232 / notes.md
Last active Apr 16, 2019
Setting up my perfect development environment in virtualbox
View notes.md

OS

Mint

Definitely more ready out of the box also seems to cope with 3D in Virtualbox better

Standard

save 1.1GB for base install of 5.5GB apt remove mintstick transmission-gtk timeshift thunderbird xed simple-scan rhythmbox redshift-gtk pix xplayer libreoffice-* xviewer hexchat gimp firefox xreader baobab gnome-calendar gnome-calculator gnome-terminal blueberry gufw tomboy && apt autoremove

@willpower232
willpower232 / my.vimrc
Last active Jun 19, 2019
Guess I have to get into vim one day
View my.vimrc
" syntax highlighting
syntax on
" todo: experiment with colour schemes
"colorscheme elflord
" might help vim cope with random terminals and colours
" by reminding it that the background is dark
set background=dark
@willpower232
willpower232 / gogocertbot.sh
Created Jan 22, 2018
Certbot with DNS verification and AWS route53 plugin
View gogocertbot.sh
#!/bin/bash
# run these first to install certbot globally with the route53 plugin
# $ sudo apt install python-setuptools
# $ sudo easy_install pip
# $ sudo -H pip install certbot-dns-route53
# verify the route53 plugin is present
# $ certbot plugins
@willpower232
willpower232 / reset_home_directory_permissions.sh
Created Dec 13, 2017
Reset Linux Home directory permissions based on /etc/passwd
View reset_home_directory_permissions.sh
#!/bin/bash
chown root:root /home
chmod 755 /home
USERS=$(grep '/home' /etc/passwd | tr "\n" "\n")
for USER in $USERS
do
@willpower232
willpower232 / etc_nginx_sites-enabled_test
Last active Oct 22, 2020
Run Nginx on WSL (Ubuntu on Windows) with automatic domain names and environment for local development
View etc_nginx_sites-enabled_test
server {
listen 80;
listen 443 ssl http2;
# make yourself an SSL certificate for *.test.test (and your dhparam file if you're so inclined)
ssl_certificate /etc/nginx/ssl/test.cert;
ssl_certificate_key /etc/nginx/ssl/test.key;
# your other favourite SSL settings go here
You can’t perform that action at this time.