Skip to content

Instantly share code, notes, and snippets.

@ibrezm1
ibrezm1 / subnet.py
Last active June 22, 2022 05:05 — forked from nboubakr/subnet.py
A simple python script converts a Classless Inter-Domain Routing (CIDR)-formatted IP address into an IP range and netmask.
#!/usr/bin/env python
# python subnet.py 200.100.33.65/26
# from: curl -O https://gist.github.com/ibrezm1/4b4274006dc2a5d5ad48e6b2c395633b/subnet.py
import sys
# Get address string and CIDR string from command line
(addrString, cidrString) = sys.argv[1].split('/')
# Split address into octets and turn CIDR into int
@ibrezm1
ibrezm1 / gcp-iam-restrict-user-bucket.sh
Created June 21, 2022 15:30 — forked from pydevops/gcp-iam-restrict-user-bucket.sh
Google Cloud Platform example to add IAM role restricting user to specific storage buckets with conditions
#!/usr/bin/env bash
export PROJECT_ID=$(gcloud config get-value project)
export PROJECT_USER=$(gcloud config get-value core/account) # set current user
export PROJECT_NUMBER=$(gcloud projects describe $PROJECT_ID --format="value(projectNumber)")
export IDNS=${PROJECT_ID}.svc.id.goog # workload identity domain
export GCP_REGION="us-central1"
export GCP_ZONE="us-central1-a"