Skip to content

Instantly share code, notes, and snippets.

qtangs / terraform_state_cloudformation_template.yml
Created November 21, 2020 13:12
CloudFormation Template for creating S3 bucket and DynamoDB table to hold Terraform state and locks
View terraform_state_cloudformation_template.yml
AWSTemplateFormatVersion: 2010-09-09
Description: >
Template for creating S3 bucket and DynamoDB table to hold Terraform state and locks
Validate: aws cloudformation validate-template --template-body file://terraform_state.yml
Deploy: aws cloudformation create-stack --region us-east-1 --stack-name Terraform-State-Resources --enable-termination-protection --template-body file://terraform_state.yml --parameters ParameterKey=TerraformStateBucketPrefix,ParameterValue=terraform-state ParameterKey=TerraformStateLockTableName,ParameterValue=terraform-state-locks
Type: String
Default: terraform-state
Description: A prefix for S3 bucket name, account id will be added to ensure global uniqueness
qtangs /
Last active August 21, 2021 02:51
Get packages for AWS Lambda Layer
export PKG_DIR="python"
rm -rf ${PKG_DIR} && mkdir -p ${PKG_DIR}
docker run --rm -v $(pwd):/foo -w /foo lambci/lambda:build-python3.6 \
pip install -r requirements.txt --no-deps -t ${PKG_DIR}
qtangs /
Created June 10, 2020 02:51
2020 Code Challenges

Problem #1 (Kubernetes)

We will be using kubernetes to manage our containers, and we need to know how basic kubernetes objects work, and how to provision them.


Write the k8 config required to deploy a basic nginx webserver with this image nginxdemos/hello, using minikube to provision your cluster control plane.

Your resulting created objects should look similar to the likes of the below:

NAME                                     READY   STATUS    RESTARTS   AGE
pod/nginx-hello-world-84c67f76c4-4g5sd   1/1     Running   0          6s
qtangs /
Last active March 15, 2020 09:17
Covid 19 Dashboard
python -c '''
import dash; import dash_html_components as html; app = dash.Dash(); app.layout=html.H1("Yay! It works!"); app.run_server()
qtangs /
Last active March 15, 2020 09:07
Covid 19 Dashboard
cd covid-19-dashboard
python -m venv venv # or python3 -m venv venv
source venv/bin/activate
pip list # ensure that only pip and setuptools are listed
echo "dash==1.9.1" > requirements.txt
pip install -r requirements.txt
qtangs / file_structure.txt
Last active March 12, 2020 16:52
Covid 19 Dashboard file_structure.txt
View file_structure.txt
|_ dashboard
|_ assets
|_ data
|_ .gitignore
|_ Procfile
qtangs /
Created March 12, 2020 15:26
Covid 19 Dashboard
### Output:
Running on
Debugger PIN: 853-611-907
* Serving Flask app "app" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
Running on
qtangs /
Last active March 12, 2020 15:18
Covid 19 Dashboard
import dash
import dash_core_components as dcc
import dash_html_components as html
external_stylesheets = ['']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(children=[
html.H1(children='Hello Dash'),
import pandas as pd
COUNTRY_COLUMN = "Country/Region"
# i. Download sample data and extract features and label (fraud/nonfraud).
# ii. Convert the n-dimensional arrays into RecordIO format (a highly efficient data format).
import as smac
buf = io.BytesIO()
smac.write_numpy_to_dense_tensor(buf, features, labels)
# iii. Store the RecordIO data into S3 bucket.