Skip to content

Instantly share code, notes, and snippets.

2015-05-20 19:56:18 -0700
./configure
--disable-debug
--disable-dependency-tracking
--prefix=/usr/local/Cellar/phash/0.9.6_1
--enable-shared
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
2015-04-13 16:58:39 -0700
./configure
--disable-debug
--disable-dependency-tracking
--prefix=/usr/local/Cellar/phash/0.9.6_1
--enable-shared
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
@ericflo
ericflo / token.go
Created March 13, 2015 21:38
Golang mock generator?
package models
type TokenAPI interface {
GetTokenById(id string) (*Token, error)
CreateToken(userId string) (token *Token, err error)
}
@ericflo
ericflo / gist:90a852b58a6f7fa8fe8b
Created November 4, 2014 09:44
Let's say you want to deploy a PostgreSQL database
Let's say you want to deploy a PostgreSQL database
Is it better to?
1) Use Ansible to install and configure PostgreSQL via an Ansible Playbook role
2) Use Ansible, Terraform, or CloudFormation's AWS RDS provisioner to set up a
PostgreSQL RDS instance
3) Use Terraform or Ansible to provision an instance and run shell commands to
install a PostgreSQL docker image
4) Use Packer to set up a machine image that has PostgreSQL installed, and
deploy that using Ansible, Terraform, or CloudFormation
@ericflo
ericflo / undo.js
Last active September 15, 2016 09:31
Adds undo capabilities into your React.js component.
var UndoMixin = {
getInitialState: function() {
return {
undo: []
};
},
handleUndo: function() {
if (this.state.undo.length === 0) {
return;
@ericflo
ericflo / reactdropzone.js
Last active September 15, 2016 09:00
ReactDropzone, a react component for interfacing with http://www.dropzonejs.com/
/** @jsx React.DOM */
var ReactDropzone = React.createClass({
componentDidMount: function() {
var options = {};
for (var opt in Dropzone.prototype.defaultOptions) {
var prop = this.props[opt];
if (prop) {
options[opt] = prop;
continue;
@ericflo
ericflo / logscoop.py
Last active December 28, 2015 02:39
Low tech Flask logging with UDP, JSON, and Twisted.
import os
import subprocess
from sqlalchemy import Column, String, Integer, Float, MetaData, Table
from sqlalchemy import create_engine
from alchimia import TWISTED_STRATEGY
from flask import json
@ericflo
ericflo / send_template_mail.py
Created March 23, 2012 21:12
Send a templated mail
from django.conf import settings
from django.template import Context, loader
from django.core.mail import send_mail
def send_template_mail(slug, context, recipient_list, from_email=settings.DEFAULT_FROM_EMAIL):
if isinstance(recipient_list, basestring):
recipient_list = [recipient_list]
if not isinstance(context, Context):
context = Context(context)
subject_tmpl = loader.get_template('mail/%s/subject.txt' % (slug,))
@ericflo
ericflo / stripe.py
Created March 21, 2012 00:15
Replaced my use of Stripe's Python API with this
import httplib
import base64
import contextlib
import simplejson
import urllib
from django.conf import settings
def stripe_fetch(resource, method='GET', params=None, secret=settings.STRIPE_SECRET, prefix='/v1'):
@ericflo
ericflo / get_and_update_or_create.py
Created January 2, 2012 20:21
Utility function for querying for and updating a model at the same time.
def get_and_update_or_create(model, unique, update):
"""
Given a model, a dictionary of lookup arguments, and a dictionary of update
arguments, this convenience function gets an object and updates it in the
database if necessary.
Returns a tuple (object, int) where int is 0 if the object was not updated,
1 if the object was created, and 2 if the object was updated in the
database.