Skip to content

Instantly share code, notes, and snippets.

View dhoeric's full-sized avatar

Eric Ho dhoeric

View GitHub Profile
@dhoeric
dhoeric / 0_README.md
Last active September 25, 2026 06:46
Google Calendar - Public Holiday Calendars
@dhoeric
dhoeric / Ubuntu 16.04
Last active April 7, 2026 11:38
install-docker-aws-ec2-user-data
#!/bin/bash
# Install docker
apt-get update
apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update
@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 / 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 / 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 / docker-cheat-cheat.md
Last active April 20, 2018 06:25
[Docker Cheat Sheet] #docker

Export vm-based variable to environment

eval `docker-machine env your-vm`

Remove non-tagged docker image

docker rmi $(docker images | grep "^<none>" | awk '{print $3}' | tr '\n' ' ')
@dhoeric
dhoeric / ip2geo.sh
Last active April 20, 2018 06:05
Get geographic location by IP address #scripts
# Put into .bashrc, source .bashrc, (max. 1000 requests per day)
# Example:
# $ ip2geo 8.8.8.8
# {
# "ip": "8.8.8.8",
# "hostname": "google-public-dns-a.google.com",
# "city": "Mountain View",
# "region": "California",
# "country": "US",
# "loc": "37.3860,-122.0838",