Skip to content

Instantly share code, notes, and snippets.

@mambroziak
mambroziak / timezone-picker.ps1
Created September 16, 2021 03:35
PowerShell Time Zone Picker
clear
$tz_found = $false
do {
$q = "`nEnter the first 3 letters of time zone you want to set (e.g. Eastern = eas)"
do {
$tz_query = Read-Host -Prompt $q
} until ($tz_query.Length -gt 2)
$timezone_list = Get-TimeZone -Name "*$($tz_query)*" -ErrorAction SilentlyContinue
if ($timezone_list.Length -gt 0) {
@mambroziak
mambroziak / disable_iptables_ubuntu.sh
Last active March 6, 2023 18:50
"Disable" iptables on Ubuntu
# "Disable" iptables on Ubuntu
sudo iptables-save > ~/firewall.rules
sudo iptables -X
sudo iptables -t nat -F
sudo iptables -t nat -X
sudo iptables -t mangle -F
sudo iptables -t mangle -X
sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -P OUTPUT ACCEPT
@mambroziak
mambroziak / awsEc2MetadataShortcuts.sh
Last active November 1, 2023 22:34
AWS EC2 Instance Metadata to BASH Script Variables
#!/bin/bash
# JQ is required to more easily parse json.
AWS_IAM_ROLE=`curl -sL http://169.254.169.254/latest/meta-data/iam/security-credentials/`
AWS_ACCESS_KEY_ID=`curl -sL http://169.254.169.254/latest/meta-data/iam/security-credentials/$AWS_IAM_ROLE/ | jq -r '.AccessKeyId'`
AWS_SECRET_ACCESS_KEY=`curl -sL http://169.254.169.254/latest/meta-data/iam/security-credentials/$AWS_IAM_ROLE/ | jq -r '.SecretAccessKey'`
AWS_TOKEN=`curl -sL http://169.254.169.254/latest/meta-data/iam/security-credentials/$AWS_IAM_ROLE/ | jq -r '.Token'`
AWS_AZ=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone`
AWS_DEFAULT_REGION="`echo \"$AWS_AZ\" | sed -e 's:\([0-9][0-9]*\)[a-z]*\$:\\1:'`"
LOCAL_IP=`curl -sL http://169.254.169.254/latest/meta-data/local-ipv4`
PUBLIC_IP=`curl -sL http://169.254.169.254/latest/meta-data/public-ipv4`