Skip to content

Instantly share code, notes, and snippets.

View willpower232's full-sized avatar
🤓
Hey there! I am using GitHub.

Will Power willpower232

🤓
Hey there! I am using GitHub.
View GitHub Profile
@willpower232
willpower232 / download_interactively_from_s3.sh
Created December 13, 2019 10:06
How to loop through folders in AWS S3, select a file, and download it
#!/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 / create_delegated_dns_zone.sh
Created December 13, 2019 11:10
Create an AWS Route53 zone in a delegation set and change the NS record to match your vanity nameservers
#!/bin/bash
if [ -z "$1" ]; then
echo "Please specify domain name"
exit 1
fi
initials="WH"
delegationsetid="YOUR-DELEGATED-SET-ID"
@willpower232
willpower232 / downloadgithubasset.sh
Created January 27, 2020 16:47
Interactive terminal menu to download an asset from a known github repo release
#!/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 / postal_database_size.sql
Last active February 3, 2020 14:27
get the Postal database size for each mail server
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 / tailscaleToHostCtl.sh
Created August 6, 2022 11:06
add your tailscale IPs to your hosts file when you're scared of messing up your DNS
#!/bin/bash
tailscale status | while IFS= read -r aHost; do
hostname=$(echo "$aHost" | awk '{print $2}' | cut -d '-' -f 1)
ip=$(echo "$aHost" | awk '{print $1}')
hostctl add domains tailscale "$hostname.ts" --ip "$ip"
done