Skip to content

Instantly share code, notes, and snippets.

View krak3n's full-sized avatar
🏳️‍🌈

Chris Reeves krak3n

🏳️‍🌈
View GitHub Profile
@krak3n
krak3n / .zshrc
Created July 25, 2014 14:32
OSX boot2docker auto start & auto export DOCKER_HOST
# Add this to your bashrc or zshrc or whatever
port=`boot2docker info | awk -F=":" -v RS="," '$1~/"DockerPort"/ {print}' | sed 's/\"//g' | sed 's/DockerPort://'`
export DOCKER_HOST="tcp://:${port}"
@krak3n
krak3n / gist:9fa1268ee0a92a67f71a
Created July 4, 2014 13:38
Avoid DetachedInstanceError in Flask-SQLAlchemy
# The following produces DetachedInstanceError
app = Flask(__name__)
db = SQLAlchemy(app)
class Foo(db.Model):
id = db.Column(db.Integer, primary_key=True)
foo = Foo()
db.session.add(foo)
@krak3n
krak3n / forms.py
Created April 23, 2014 14:01
Flask login form
class AuthenticationForm(Form):
email = TextField()
password = PasswordField()
def validate_password(form, field):
user = db.session.query(User).filter_by(email=form.email.data).first()
if not user:
raise ValidationError('Inccorect Email or Password combination')
if not verify_and_update_password(field.data, user):
raise ValidationError('Inccorect Email or Password combination')
@krak3n
krak3n / gist:5884788
Created June 28, 2013 13:46
Facio's new CLI interface
Facio
Facio is a project scaffolding tool originally developed for Django and
expanded to be framework agnostic. You can use Facio to bootstrap any sort
of project.
Documentation:
https://facio.readthedocs.org
Usage:
@krak3n
krak3n / gist:5884562
Last active March 2, 2019 19:37
Mocking open for ConfigParser.RawConfigParser.readfp() for unit testing.
import io
import six
from mock import patch
from six.moves import configparser as ConfigParser
data = """
[section]
key = value
"""
@krak3n
krak3n / gist:3476269
Created August 26, 2012 08:40
Enable symlinks in Vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
#
# Ensure you set your file system mount to NFS, you'll need to provide the VM with a static IP for a hostonly network.
#
Vagrant::Config.run do |config|
# ...