Skip to content

Instantly share code, notes, and snippets.

View clok's full-sized avatar
👾
I can do this all day.

Derek Smith clok

👾
I can do this all day.
View GitHub Profile
@clok
clok / branching.md
Last active August 29, 2015 14:19
Development to production branching notes

General Workflow

  • the develop branch is where ALL development starts from and merges to.
  • the master branch ALWAYS matches production
  • typical workflow would be branch a feature branch from develop, code and commit often. When code is readt for review & merge, open a Pull Request from the branch to develop.
  • a typical deploy to production will take the develop branch and merge to master. The master branch will then be deployed to production machines.
  • a hotfix is defined as a mission critical change that must be deployed to production with expediency.
    • the proper way to handle a hotfix is to branch from master and open a Pull Request from the branch to master
@clok
clok / rails-console.sh
Created May 18, 2015 16:44
ElasticBeanstalk Rails Console and Rake Task Runners
#!/usr/bin/env bash
#
# Rails console script that can be run on AWS Elastic Beanstalk.
#
# Run this script from the app dir (/var/app/current) as root (sudo script/rails-console)
#
set -xe
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
cat VARSFILE.env | awk -F '=' 'BEGIN {ORS=" "} {print $1"=\""$2"\""}'
# Show all EB Deployed versions
aws --profile eb-cli elasticbeanstalk describe-environments | jq -r '.Environments[] | .EnvironmentName + ": " + .Status + "/" + .Health + "\t (" + .VersionLabel + ")"' | sort
# Show EB envs that are NOT Ready
aws --profile eb-cli elasticbeanstalk describe-environments | jq -r '.Environments[] | .EnvironmentName + ": " + .Status + "/" + .Health + "\t (" + .VersionLabel + ")"' | sort | grep -v Ready
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream app {
server 127.0.0.1:3838 fail_timeout=0;
}
server {
@clok
clok / datadog.service
Created April 6, 2016 14:38
DataDog Fleet service with teardown
[Unit]
Description=Datadog
Requires=docker.socket
After=docker.socket
[Service]
ExecStartPre=-/usr/bin/docker stop dd-agent
ExecStartPre=-/usr/bin/docker rm dd-agent
ExecStartPre=/bin/sh -c "docker history datadog/docker-dd-agent:latest >/dev/null || docker pull datadog/docker-dd-agent:latest"
ExecStart=/usr/bin/docker run --privileged --name dd-agent -h %H -v /var/run/docker.sock:/var/run/docker.sock -v /proc/mounts:/host/proc/mounts:ro -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro -e API_KEY=DATADOG_API_KEY datadog/docker-dd-agent
@clok
clok / s3-analysis.rb
Created May 4, 2016 15:07
S3 Bucket usage for the past 24 hours
require 'optparse'
require 'ostruct'
require 'json'
require 'date'
def opts
@opts ||= OpenStruct.new(
verbose: false,
region: 'us-east-1',
aws_profile: 'default',
@clok
clok / netuitive.service
Created May 4, 2016 17:13
Netuitive Fleet service
[Unit]
Description=Netuitive
Requires=docker.socket
After=docker.socket
[Service]
ExecStartPre=-/usr/bin/docker stop netuitive-agent
ExecStartPre=-/usr/bin/docker rm netuitive-agent
ExecStartPre=/bin/sh -c "docker history netuitive/docker-agent:latest >/dev/null || docker pull netuitive/docker-agent:latest"
ExecStart=/usr/bin/docker run --privileged --name netuitive-agent -h %H -v /proc:/host_proc:ro -v /var/run/docker.sock:/var/run/docker.sock:ro -e DOCKER_HOSTNAME=%H -e APIKEY=efbda858cbadc958ccbb62c675180412 netuitive/docker-agent
@clok
clok / docker.cfg
Last active February 4, 2017 16:10
global config for shared credentials
# https://wdullaer.com/blog/2016/02/28/pass-credentials-to-the-awslogs-docker-logging-driver-on-ubuntu/
root@ip-10-0-4-212:~# cat /etc/default/docker
# Docker Upstart and SysVinit configuration file
#
# THIS FILE DOES NOT APPLY TO SYSTEMD
#
# Please see the documentation for "systemd drop-ins":
# https://docs.docker.com/engine/articles/systemd/
@clok
clok / app-cron
Created February 20, 2017 18:38
Docker cron daemon pattern example
# /etc/cron.d/app-cron
0 0 * * * root bash -l -c '/usr/bin/rake.sh rake:task1 >> /dev/console 2>&1'
*/5 * * * * root bash -l -c '/usr/bin/rake.sh rake:task2 >> /dev/console 2>&1'
*/10 * * * * root bash -l -c '/usr/bin/rake.sh rake:task3 >> /dev/console 2>&1'