Skip to content

Instantly share code, notes, and snippets.

@ddspell
ddspell / gist:31e3117108b9661561ea03c220baa5d2
Created September 18, 2025 16:59
AWS - List S3 Buckets for a Region
# S3 buckets are global
# If you want to know the buckets for a specific region, you need to specify the bucket endpoint (region)
# to use the bucket-region parameter.
aws s3api list-buckets --region "us-west-2" \
--bucket-region "us-west-2" \
--query "Buckets[].[CreationDate,Name]" \
--output text
@ddspell
ddspell / gist:af8a6e2eb40a31fc456de7f3ff10585a
Created September 18, 2025 16:46
Shell Function - Laptop Battery Gauge
# Add this to .zshrc or .zprofile
# Function to display battery percentage with a fuel gauge
bat() {
# Get the battery percentage
local CHARGE
CHARGE=$(system_profiler SPPowerDataType -json 2>/dev/null | jq -r '.SPPowerDataType[] | select(._name == "spbattery_information").sppower_battery_charge_info.sppower_battery_state_of_charge' 2>/dev/null)
# Validate input
if [[ ! $CHARGE =~ '^[0-9]+$' ]]; then
echo "Error: Could not retrieve valid battery percentage"
@ddspell
ddspell / gist:a447b02a066ec0087a66dbff067cc850
Created September 18, 2025 13:47
Viewing All AWS Resources using the CLI
# Prerequisit:
# Aggregate indexing to us-east-1 for all of the regions enabled for the account to us-east-1,
# or whatever region is standard for your organization
# Details can be found here:
# https://aws.amazon.com/blogs/aws/introducing-aws-resource-explorer-quickly-find-resources-in-your-aws-account/
# This list can be huge, thus dumping to a file where it can be viewed through an editor or a utility such as 'less'.
aws resource-explorer-2 list-resources --region "us-east-1" \
@ddspell
ddspell / Einstein.markdown
Last active September 18, 2025 16:44
Einstein