This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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| | |
# ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import six | |
from mock import patch | |
from six.moves import configparser as ConfigParser | |
data = """ | |
[section] | |
key = value | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
snippet #! "Shebang header for python scripts" b | |
#!/usr/bin/env python | |
# encoding: utf-8 | |
""" | |
$1 | |
`!p snip.rv = ''.join(['=' for i in range(0, len(t[1]))])` | |
$2 | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!pydsl|stateconf -ps | |
state('.repo') \ | |
.git.latest( | |
name='https://github.com/itagenten/tree', | |
rev='json', | |
target='/tmp/tree') | |
state('.make') \ | |
.cmd.wait( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!pydsl|stateconf -ps | |
include('apt-transport-https', 'python-software-properties') | |
lxc_docker = state('.lxc-docker') | |
lxc_docker.pkgrepo.managed( | |
name='deb https://get.docker.io/ubuntu docker main', | |
keyserver='hkp://keyserver.ubuntu.com:80', | |
keyid='36A1D7869245C8950F966E92D8576A8BA88D21E9') | |
lxc_docker.pkg.installed('lxc-docker') \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (s *subscription) consume() { | |
for { | |
client := s.client | |
// Connect to Redis Pubsub Channel | |
pubsub := client.PubSub() | |
err := pubsub.Subscribe(s.channel) | |
// On error sleep for 1 second, log and continue to the next loop iteration | |
if err != nil { | |
log.Errorf("Redis Connection Error: %s", err) | |
time.Sleep(time.Second) |
OlderNewer