Skip to content

Instantly share code, notes, and snippets.

@micahhausler
micahhausler / cache.go
Last active December 31, 2015 19:43
Go map Data Race
package cache
import (
"sync"
)
// UserCache stores a concurrent-safe cache of authenticated users
type UserCache struct {
mu sync.RWMutex // guards Cache
Cache map[string]string
@micahhausler
micahhausler / 0_reuse_code.js
Created December 10, 2015 21:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@micahhausler
micahhausler / uwsgi.sh
Created November 16, 2015 23:13
uwsgi command parameters
newrelic-admin run-program /usr/local/bin/uwsgi \
--stats=/path/to/socket/socket.sock \
--close-on-exec \
--enable-threads \
--master \
--max-requests=100 \
--module=project.wsgi \
--harakiri=60 \
--env=DJANGO_SETTINGS_MODULE=project.settings \
--py-tracebacker=/path/to/traceback/socket \
@micahhausler
micahhausler / master.sh
Last active January 23, 2016 08:42
Docker Orca (0.4.0) Quickstart instructions
#!/bin/bash
#
# Requires docker-toolbox >= 1.9.0d
# https://github.com/docker/toolbox/releases
MACHINE_NAME="orcamaster"
docker-machine create -d virtualbox $MACHINE_NAME
eval $(docker-machine env $MACHINE_NAME)
@micahhausler
micahhausler / keybase.md
Created October 26, 2015 20:17
keybase.md

Keybase proof

I hereby claim:

  • I am micahhausler on github.
  • I am micahhausler (https://keybase.io/micahhausler) on keybase.
  • I have a public key whose fingerprint is 7151 8EA6 23DA 1ABE 1D54 F693 D5EC 627D 9DCE 5FEB

To claim this, I am signing this object:

@micahhausler
micahhausler / .bashrc
Created October 1, 2015 16:25
docker-clean
docker-clean(){
EXITED=$(docker ps -f status=exited -q)
if [ -n "$EXITED" ]; then
docker rm $EXITED
fi
DANGLING=$(docker images -f dangling=true -q)
if [ -n "$DANGLING" ]; then
docker rmi $DANGLING
fi
}
@micahhausler
micahhausler / version.sh
Last active September 11, 2015 17:44
Docker 1.8.2 Go version
$ brew update && brew install docker docker-machine
...
$ docker-machine --version
docker-machine version 0.4.1 (HEAD)
$ docker-machine upgrade dev
Stopping machine to do the upgrade...
Upgrading machine dev...
Downloading https://github.com/boot2docker/boot2docker/releases/download/v1.8.2/boot2docker.iso to /Users/micahhausler/.docker/machine/cache/boot2docker.iso...
Starting machine back up...
@micahhausler
micahhausler / server.conf
Created July 9, 2015 15:35
Graylog Server Default Config 1.1.4
# If you are running more than one instances of graylog2-server you have to select one of these
# instances as master. The master will perform some periodical tasks that non-masters won't perform.
is_master = true
# The auto-generated node ID will be stored in this file and read after restarts. It is a good idea
# to use an absolute file path here if you are starting graylog2-server from init scripts or similar.
node_id_file = /etc/graylog/server/node-id
# You MUST set a secret to secure/pepper the stored user passwords here. Use at least 64 characters.
# Generate one by using for example: pwgen -N 1 -s 96
@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'),
)
@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):