Skip to content

Instantly share code, notes, and snippets.

View dhoeric's full-sized avatar

Eric Ho dhoeric

View GitHub Profile
@dhoeric
dhoeric / check_cloudflare_ips.py
Created December 22, 2022 02:10
Check if IP address belongs to Cloudflare
import requests
import ipaddress
# Get Cloudflare IP Ranges
# ref: https://www.cloudflare.com/ips/
def get_cf_ips():
ips = []
for urls in [
"https://www.cloudflare.com/ips-v4",
"https://www.cloudflare.com/ips-v6"
@dhoeric
dhoeric / 0_README.md
Last active August 23, 2023 04:27
Add Name tag by S3 bucket name

Add Name tag by S3 bucket name

S3 bucket usually don't add any tag when creation, which is difficult for us to check the cost spend by each bucket. The add_tags.py basically add/update Name tags to align with S3 bucket name and allow us easier to check the bills.

pipenv shell --three
pipenv install boto3

# Copy add_tags.py into local
@dhoeric
dhoeric / 0_README.md
Last active April 25, 2024 13:24
Google Calendar - Public Holiday Calendars
@dhoeric
dhoeric / backup.py
Created March 5, 2019 15:36
Backup Script for Pivotal Tracker
##
# Backup.py
# ---
# To dump stories, memberships, labels and releases on Pivotal Tracker projects
#
# Dependency:
# pip install requests
#
# Usage:
# python backup.py --token xxx
@dhoeric
dhoeric / upgrade-ecs-agent.yml
Created May 2, 2018 10:14
[Ansible playbook to upgrade ecs-agent] #ansible #ecs
---
- name: Upgrade ecs services
hosts: xxx
user: ec2-user
tasks:
- yum:
name: "ecs-init"
state: latest
become: true
@dhoeric
dhoeric / README.md
Created May 2, 2018 04:13
[shell tricks] #unix #shell #find
@dhoeric
dhoeric / README.md
Last active April 23, 2018 02:51
[Check listening port] #troubleshoot #linux

Check all listening ports in server

$ sudo netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN
tcp6 0 0 :::22 :::* LISTEN
@dhoeric
dhoeric / json2yaml.md
Last active November 7, 2017 03:59
json2yaml

Usage

pip install pyyaml
cat whatever.json | python ./main.py

Example

-> % cat test.json
{
version: '3'
services:
app:
image: ghost:alpine
ports:
- 8080:2368
volumes:
- ./blog/content:/var/lib/ghost/content

Keybase proof

I hereby claim:

  • I am dhoeric on github.
  • I am dhoeric (https://keybase.io/dhoeric) on keybase.
  • I have a public key ASCYOMc3sblrgOG6ZdsJUrKJW7lUlIPWkmi6E-BkssZMDQo

To claim this, I am signing this object: