Skip to content

Instantly share code, notes, and snippets.

@bradwright
bradwright / mkflask.sh
Created May 13, 2012 19:41 — forked from urschrei/mkflask.sh
Bootstrap a Flask project
#!/bin/bash -e
# opinionated Flask bootstrap script
# assumes you'll be using MySQL, Fabric, and Blueprints
# creates a virtualenv and an Alembic migrations system
# The script will halt on any error, and remove the project dir if it created one
# accepts a single argument: a new directory name under which to create the project
# check that Python is installed
type python >/dev/null 2>&1 || { echo >&2 "Python doesn't appear to be installed. Aborting."; exit 1; }
Vagrantfile:
Vagrant::Config.run do |config|
config.vm.define :web do |web_config|
web_config.vm.provision :puppet, :options => "--verbose --debug" do |web_puppet|
web_puppet.module_path = "puppet/modules"
web_puppet.manifests_path = "puppet/manifests"
web_puppet.manifest_file = "web.pp"
end
@bradwright
bradwright / gist:2490524
Created April 25, 2012 15:15 — forked from czottmann/gist:2490462
The Unfollow Manifesto

The Unfollow Manifesto

At some point in the past, I've decided to follow you on Twitter or any other social network, because you appeared to be a person whose postings I might be interested in.

But recently you noticed me unfollowing you.

Now you're confused/sad/angry. Don't be. Because here are the three simple rules I adhere to.

  1. You may unfollow me at any given time, because what I post might not be your cup of tea. It's okay, no hard feelings. I won't take that as an insult. (Really.) I assume we're still cool outside said service, unless of course I wrote some horrible shit that offended you, in which case I am probably sorry.
@bradwright
bradwright / gist:595081
Created September 24, 2010 08:57 — forked from andyhd/gist:595058
# a heavy int is one where the average of the digits is greater than 7
# eg: 8678 is heavy because (8 + 6 + 7 + 8) / 4 = 7.25
# 8677 is not heavy because ( 8 + 6 + 7 + 7) / 4 = 7
def is_heavy(my_number, heaviness=7):
# cast @my_number to a string so we can iterate over it, then create a list of
# numbers greater than @heaviness. if this list length is greater to or equal than half
# the length of the original list, it's heavy
return len([i for i in str(my_number) if int(i) > heaviness]) >= (len(str(my_number)) / 2)
all_possible_plays = Play.objects.filter(preview_only=False, play_start__gte=start_date,
play_start__lt=end_date, users__is_staff=False)
for play in all_possible_plays:
if play_history.has_key(play.song.pk):
#increment tallies
play_history[play.song.pk]['plays'] += 1
if play.credit_taken:
play_history[play.song.pk]['credit_plays'] += 1
#!/bin/sh
FOO="Hello, world"
`exec erl -kernel bar "${FOO}"`
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
import random
sys.path.insert( 0, os.path.join( os.path.dirname( __file__ ) ) )
from jinja2 import Template, Environment, FileSystemLoader
env = Environment( loader=FileSystemLoader( '.', encoding='utf-8' ) )