Skip to content

Instantly share code, notes, and snippets.

@micahhausler
micahhausler / heartbeat.py
Last active January 2, 2016 08:09
Django heartbeat configuration for ELB Health Check
from django.http import HttpResponse
def HeartBeat(request):
"""
This method is for the AWS load balancer health check.
"""
return HttpResponse('{\'data\': {\'status\': \'healthy\'}}')
@micahhausler
micahhausler / nginx.conf
Last active January 2, 2016 08:09
NGINX configuration for a Django heartbeat.
server {
listen 10.10.10.10:80;
server_name demo.ambition.io;
location /heartbeat {
set $my_host $host;
if ($host ~ "\d+\.\d+\.\d+\.[\d\:]+") {
set $my_host "demo.ambition.io";
}
@micahhausler
micahhausler / gist:9055862
Last active August 29, 2015 13:56 — forked from anonymous/gist:9053693
Git command counter (OS X)
history -w /dev/stdout | grep -o "^git [a-zA-Z]*\( -\{1,2\}\([a-zA-Z]\)*\)*" | sort | uniq -c | sort -rg
@micahhausler
micahhausler / Vagrantfile
Created September 10, 2014 20:47
Vagrant CoreOS setup (w/ rudder)
# -*- mode: ruby -*-
# # vi: set ft=ruby :
require 'fileutils'
Vagrant.require_version ">= 1.6.0"
CLOUD_CONFIG_PATH = File.join(File.dirname(__FILE__), "user-data")
CONFIG = File.join(File.dirname(__FILE__), "config.rb")
@micahhausler
micahhausler / etcd_setup.sh
Created September 17, 2014 20:35
confd nested ranges
etcdctl mkdir services/web/cust1/
etcdctl mkdir services/web/cust2/
etcdctl set services/web/cust1/1 '{"ip": "10.0.0.1"}'
etcdctl set services/web/cust1/2 '{"ip": "10.0.0.2"}'
etcdctl set services/web/cust2/1 '{"ip": "10.0.0.3"}'
etcdctl set services/web/cust2/2 '{"ip": "10.0.0.4"}'
@micahhausler
micahhausler / Dockerfile
Created October 2, 2014 21:43
Volume Dockerfile
# Shared Volume
FROM busybox:buildroot-2014.02
MAINTAINER micah hausler, micah.hausler@ambition.com
VOLUME /data
CMD ["/bin/sh"]
@micahhausler
micahhausler / get_gemfury_packages.py
Last active August 29, 2015 14:11
Gemfury Download
#!/usr/bin/env python
# Copyright (C) Micah Hausler, 2014
# Using MIT License <http://opensource.org/licenses/MIT>
#
__doc__ = """
This is a quick hack to download all your python packages from Gemfury.
$ virtualenv venv
$ source ./venv/bin/activate
@micahhausler
micahhausler / setup.py
Created January 9, 2015 19:32
gross setup.py work-around
from setuptools import setup
import sys
if 'sdist' in sys.argv and sys.version_info < (2, 7, 9, 'final', 0):
import os
del os.link
setup(
# ...
)
@micahhausler
micahhausler / 0001_initial.py
Last active February 15, 2016 02:03
Custom User Model Switch
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import django.utils.timezone
import django.core.validators
#### SEE LINE 25!
class Migration(migrations.Migration):
@micahhausler
micahhausler / register_task.py
Last active April 4, 2017 19:25
Boto3 ECS register_task_definition
import os
import boto3
def connect_ecs(region=None):
return boto3.client(
'ecs',
aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID'),
aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY'),
region_name=region or os.environ.get('AWS_EC2_REGION', 'us-east-1'),
)