Skip to content

Instantly share code, notes, and snippets.

View mnguyenngo's full-sized avatar

Nguyen Ngo mnguyenngo

View GitHub Profile
@mnguyenngo
mnguyenngo / docker-push.sh
Created August 24, 2018 22:25
Typical workflow for pushing docker images to a remote repository
# see all images
sudo docker images
# docker tag command help
docker tag --help
# add your tag to the image
sudo docker tag monolith:1.0.0 <your username>/monolith:1.0.0
# you can also rename the image
sudo docker tag monolith:1.0.0 udacity/example-monolith:1.0.0
@mnguyenngo
mnguyenngo / docker-image.sh
Last active August 24, 2018 21:11
Typical workflow for creating a Docker image and pushing the image to docker hub
"""simple Dockerfile
FROM alpine:3.1 # starter image (typical)
MAINTAINER <name> <email>
ADD hello /usr/bin/hello # ADD <bin> <path-on-image>
ENTRYPOINT ["hello"] # run hello app on startup
"""
# install GO
wget https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz
rm -rf /usr/local/bin/go
@mnguyenngo
mnguyenngo / docker-quickstart.sh
Last active August 24, 2018 20:21
Typical workflow for starting docker on a new VM
# install docker
sudo apt-get install docker
# the above command did not work (8/24/18); try the command below
sudo curl -sSL https://get.docker.com/ | sh
# pull nginx image
sudo docker pull nginx:1.10.0
sudo docker images
# verify the versions match
@mnguyenngo
mnguyenngo / nginx-quickstart.sh
Last active August 24, 2018 19:45
Typical workflow for nginx on a new VM
# update the virtual machine
sudo apt-get update
# install nginx
sudo apt-get install nginx
# check version
sudo nginx -v
# start the nginx service
@mnguyenngo
mnguyenngo / read_yaml.py
Last active August 31, 2018 00:50
Reading a yaml file
import yaml
with open("apikey.yaml", 'r') as f:
try:
credentials_dict = yaml.load(f)
except yaml.YAMLError as exc:
print(exc)
@mnguyenngo
mnguyenngo / zscore.py
Last active April 12, 2022 04:55
Code to calculate and plot the z-score
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as scs
def z_val(sig_level=0.05, two_tailed=True):
"""Returns the z value for a given significance level"""
z_dist = scs.norm()
if two_tailed:
sig_level = sig_level/2
area = 1 - sig_level
@mnguyenngo
mnguyenngo / min_sample_size.py
Last active January 27, 2024 14:40
Determine Minimum Sample Size for A/B test
import scipy.stats as scs
def min_sample_size(bcr, mde, power=0.8, sig_level=0.05):
"""Returns the minimum sample size to set up a split test
Arguments:
bcr (float): probability of success for control, sometimes
referred to as baseline conversion rate
mde (float): minimum change in measurement between control