Skip to content

Instantly share code, notes, and snippets.

@optionalg
optionalg / Terraform-Blue-Green-AWS.md
Created October 30, 2017 21:10 — forked from roustem/Terraform-Blue-Green-AWS.md
Blue-Green AWS Auto Scaling Deployments with Terraform

A quick note on how I'm currently handling Blue/Green or A/B deployments with Terraform and AWS EC2 Auto Scaling.

In my particular use case, I want to be able to inspect an AMI deployment manually before disabling the previous deployment.

Hopefully someone finds this useful, and if you have and feedback please leave a comment or email me.

Overview

I build my AMI's using Packer and Ansible.

@optionalg
optionalg / elasticat.json
Created October 28, 2017 20:49 — forked from donavanm/elasticat.json
CloudFormation EC2 & Route53 template
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Create an EC2 instance, set up Apache, and create Route53 A records",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
"Type" : "String",
@optionalg
optionalg / usproxy_wor53.json
Created October 28, 2017 20:49 — forked from Luzifer/usproxy_wor53.json
AWS Cloudformation template to create a running OpenVPN server in AWS US
{
"Description" : "Template to create a US proxy server",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
"Type" : "String"
},
"VPNServerPort" : {
"Description" : "TCP/IP port of the OpenVPN server",
"Type" : "String",
vagrant@precise64:~/cf$ bosh aws bootstrap micro
Deployment set to '/home/vagrant/cf/deployments/micro/micro_bosh.yml'
Deploying new micro BOSH instance `micro/micro_bosh.yml' to `https://10.10.0.6:25555' (type 'yes' to continue): yes
Deploy Micro BOSH
using existing stemcell (00:00:00)
creating VM from ami-9deebef4 (00:01:09)
waiting for the agent (00:01:54)
create disk (00:00:03)
mount disk (00:00:13)
@optionalg
optionalg / AWS Deployment
Created October 28, 2017 20:39 — forked from twoseat/AWS Deployment
Comparison between PWS and AWS deployments
$: cf push -n pharris-web-servlet-2-application
Using manifest file /Users/pharris/dev/sources/java-test-applications/web-servlet-2-application/manifest.yml
Creating app web-servlet-2-application in org system / space stream-test as admin...
OK
Creating route pharris-web-servlet-2-application.nebhale.co...
OK
Binding pharris-web-servlet-2-application.nebhale.co to web-servlet-2-application...
@optionalg
optionalg / jenkins_nginx_ci.template.json
Created October 28, 2017 18:20 — forked from fabito/jenkins_nginx_ci.template.json
AWS Cloudformation template which creates a server based on Amazon Linux and automatically installs jenkins with nginx (working as a reverse proxy).
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation template to deploy jenkins/nginx.",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
"Type" : "String",
@optionalg
optionalg / find_smallest_cycel.py
Created October 24, 2017 12:27 — forked from apua/find_smallest_cycel.py
說到比對就想到 regexp....
"""
Given cyclic list with elements integers.
Find the smallest cycle.
>>> find_smallest_cycle([10, 3, 999, 24, 10, 3, 999, 24, 10, 3])
[10, 3, 999, 24]
"""
def origin(mylist):
def make_tuple(list_a):
return list(set(map(tuple,list_a)))
@optionalg
optionalg / colors.py
Created October 24, 2017 12:25 — forked from arulrajnet/colors.py
python coloring for linux, based on this answer http://stackoverflow.com/a/26445590/3191896 and modified to make it more usable in a pythonic way.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class Color(object):
"""
reference from https://gist.github.com/Jossef/0ee20314577925b4027f and modified bit.
"""
def __init__(self, text, **user_styles):
@optionalg
optionalg / osx-install-media.md
Created October 20, 2017 05:41 — forked from cobyism/osx-install-media.md
Command to create installable OS X USB drive.

Creating a bootable macOS USB installer

  • First, plug in an 8GB (or bigger) USB drive, and use Disk Utility to erase it
  • If you use the default settings, you should wind up with a blank drive at /Volumes/Untitled.

With that volume in place, and with the macOS installer sitting in /Applications/Install\ macOS\ [VERSION].app, run the following command in your terminal to create a bootable install media (for Sierra):

sudo /Applications/Install\ macOS\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install\ macOS\ Sierra.app --nointeraction
@optionalg
optionalg / latency.txt
Created October 8, 2017 04:10 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD