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 / Vagrantfile
Created November 21, 2016 12:25
My working minimalist Vagrantfile with everything I have used so far in my use of Vagrant
VAGRANTFILE_CLIENT_NAME = "example"
Vagrant.configure(2) do |config|
config.vm.define VAGRANTFILE_CLIENT_NAME do |localdevbox|
localdevbox.vm.box = "localdev"
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
@willpower232
willpower232 / reset_home_directory_permissions.sh
Created December 13, 2017 16:24
Reset Linux Home directory permissions based on /etc/passwd
#!/bin/bash
chown root:root /home
chmod 755 /home
USERS=$(grep '/home' /etc/passwd | tr "\n" "\n")
for USER in $USERS
do
@willpower232
willpower232 / apt-check.sh
Last active January 10, 2018 15:47
Output pending apt updates as a string and do something with it, good for crons. Aptitude based version of https://gist.github.com/willpower232/ebc91827347c18501030ea0bb70f1a2a
#!/bin/bash
# count package updates by the number of lines
# - just-print bypasses the sudo lock requirement
# - have to narrow it down to lines with brackets to avoid simulation warning that has whitespace at the start
# also note this will include any packages on hold, you should use apt pinning to hide them from the update process
UPDATES_COUNT=$(apt-get --just-print -V -u upgrade --assume-no | grep "(" | grep "^\s" | wc -l)
# store the hostname for later
HOSTNAME=$(hostname)
@willpower232
willpower232 / yum-check.sh
Last active January 10, 2018 15:49
Output pending yum updates as a string and do something with it, good for crons. Based on https://relativkreativ.at/articles/simple-update-notifications-for-your-centos-redhat-server
#!/bin/bash
# count package updates by the number of lines
# note that this will include packages pending replacement because of needing system reboot
UPDATES_COUNT=$(yum check-update --quiet | grep -v "^$" | wc -l)
# count security updates with a substring
SECURITY_UPDATES=$(yum --debuglevel 2 --security check-update 2>/dev/null | grep -P '(?<! 0 packages) available$' | cut -d ',' -f 1)
# store the hostname for later
@willpower232
willpower232 / notes.md
Last active April 16, 2019 13:15
Setting up my perfect development environment in virtualbox

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 June 19, 2019 14:29
Guess I have to get into vim one day
" 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 / 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`