Skip to content

Instantly share code, notes, and snippets.

View dhoeric's full-sized avatar

Eric Ho dhoeric

View GitHub Profile
@dhoeric
dhoeric / Ubuntu 16.04
Last active February 27, 2025 23:01
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
#!/bin/bash -e
# To unset cluster config in ~/.kube/config
if [ -z "$1" ]
then
echo "Usage: unset-kube-cluster.sh [cluster-name]"
exit
fi
cluster_name=$1
@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",
@dhoeric
dhoeric / .zshrc
Last active August 25, 2017 04:06
A snippet for auto-load/unload virtualenv by calling `workon` on a directory. This can be added on .profile/.bashrc/.zshrc, etc.
# Call virtualenvwrapper's "workon" if .venv exists. This is modified from--
# http://justinlilly.com/python/virtualenv_wrapper_helper.html
# and https://gist.github.com/cjerdonek/7583644
has_virtualenv() {
if [ -e .venv ]; then
ENV_NAME=`cat .venv`
workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME"
elif [ $CD_VIRTUAL_ENV ]; then
deactivate && unset CD_VIRTUAL_ENV
fi