Skip to content

Instantly share code, notes, and snippets.

View alfredocambera's full-sized avatar

Alfredo Cambera alfredocambera

View GitHub Profile
print("Hello World")
alfredocambera /
Last active April 3, 2024 10:02
Lists cloudflare zones an DNS records
#!/usr/bin/env python
# prints all the records in all the zones in colums separated by ','.
# It uses raw mode to handle pagination to iterate over zones and records
import CloudFlare
cf = CloudFlare.CloudFlare(token='REPLACE_WITH_YOUR_OWN_CF_TOKEN', raw=True)
per_page = 10
alfredocambera /
Last active March 19, 2022 07:20
Certbot commands to work with Cloudflare's plugin

Certbot and CloudFlare

Example usage of Certbot's CloudFlare plugin:

Create certificates

$ sudo certbot certonly \
  --non-interactive \
 --agree-tos \
alfredocambera /
Last active May 10, 2021 23:01
How to get instance role creddentials using assigned EC2's IAM role using IMDSv2
#!/usr/bin/env bash
TOKEN_TTL=900 # 15 minutes
ROLE="$(curl -s"
TOKEN="$(curl -s -X PUT "" -H "X-aws-ec2-metadata-token-ttl-seconds: ${TOKEN_TTL}")"
CREDS="$(curl -s -H "X-aws-ec2-metadata-token: ${TOKEN}" "${ROLE}")"
REGION=$(curl -s | jq -r .region)
AWS_ACCESS_KEY_ID="$(echo "${CREDS}" | jq -r .AccessKeyId)"
AWS_SECRET_ACCESS_KEY="$(echo "${CREDS}" | jq -r .SecretAccessKey)"
alfredocambera /
Created March 8, 2019 00:00
generates a list of installed packages using the same format as the output generated by "pip3 freeze"
#!/usr/bin/env python3
import pkg_resources
dists = [str(d).replace(" ","==") for d in pkg_resources.working_set]
for i in dists: