Skip to content

Instantly share code, notes, and snippets.

@get-data-
get-data- / create-deployment.sh
Created June 23, 2019 19:55
Bad ApplicationStop script blocking deployment
# Source: https://forums.aws.amazon.com/thread.jspa?threadID=166904
# S3 artifact
aws deploy create-deployment --application-name APPLICATION --deployment-group-name GROUP --ignore-application-stop-failures --s3-location bundleType=tar,bucket=BUCKET,key=KEY --description "Ignore ApplicationStop failures due to broken script"
# Github
aws deploy create-deployment --application-name APPLICATION --deployment-group-name GROUP --ignore-application-stop-failures --github-location commitId=`git rev-parse HEAD`,repository=ACCOUNT/PROJECT --description "Ignore ApplicationStop failures due to broken script"
@get-data-
get-data- / codedeploy_fix.sh
Created June 23, 2019 17:24
Wrap install command in while loop so install can try again when it gets blocked by other installations
#!/bin/bash
until service codedeploy-agent status >/dev/null 2>&1; do
sleep 60
rm -f install
wget https://aws-codedeploy-us-west-2.s3.amazonaws.com/latest/install
chmod +x ./install
sudo ./install auto
service codedeploy-agent restart
done
@get-data-
get-data- / code_deploy_instance.sh
Created June 21, 2019 14:20
Install Code Deploy, Docker, and Docker-Compose to a fresh EC2 instance
#!/bin/bash
sudo apt-get -y update
sudo apt-get -y install ruby
sudo apt-get -y install wget
cd /home/ubuntu
wget https://aws-codedeploy-us-east-1.s3.amazonaws.com/latest/install
sudo chmod +x ./install
sudo ./install auto
# update the packages index
@get-data-
get-data- / update-dc.sh
Created June 14, 2019 16:44
Update docker compose to latest version
# Remove old version
sudo apt-get remove docker-compose
# Discover newest version
# sudo apt install jq
VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | jq .name -r)
DESTINATION=/usr/local/bin/docker-compose
# Fetch latest version and give it permission
sudo curl -L https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m) -o $DESTINATION
@get-data-
get-data- / sqlalchemy.txt
Created May 21, 2019 22:20
SQLAlchemy Return All Distinct Column Values
Class.query.with_entities(Class.title).distinct()
titles = [r.title for r in session.query(Class.title).distinct()]
source:https://stackoverflow.com/questions/22275412/sqlalchemy-return-all-distinct-column-values
@get-data-
get-data- / time sync
Created February 7, 2019 00:54
stupid virtual env falling out of sync with real time? BLAST IT WITH SUDO
sudo service ntp stop
sudo ntpdate -s time.nist.gov
sudo service ntp start
sudo mount -t vboxsf NAME_OF_HOST_FOLDER ~/NAME_OF_GUEST_FOLDER/
@get-data-
get-data- / switching branches
Created July 30, 2017 04:57
how to switch to new branch
git remote update
git branch
git checkout --track origin/<branch_you_want_to_switch_to>
https://github.com/julianespinel/stockreader/wiki/Deploy-to-AWS-using-docker-machine-and-docker-compose
Deploy to AWS using docker-machine and docker-compose
1. Prepare your machine
Please follow this steps:
Install docker in your localhost. Installation link
Install docker-machine in your localhost. Installation link
@get-data-
get-data- / Docker CLI commands
Last active September 4, 2017 20:47
Helpful CLI commands
docker-compose rm -f
docker rmi -f $(docker images -qf dangling=true)
# Volumes
docker volume ls -f dangling=true
docker volume rm $(docker volume ls -f dangling=true -q)
# Compose in PROD
docker-compose -f docker-compose.yml -f production.yml up -d