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
#!/usr/bin/env python | |
''' | |
Takes a GitHub service hook POST and automatically updates the associated repo. | |
''' | |
__license__ = ''' | |
Copyright 2009 Jake Wharton | |
hookpuller is free software: you can redistribute it and/or modify |
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
'''Manager-based polymorphic model inheritance. | |
This module provides a non-intrusive approach for accessing polymorphically | |
instances of a model hierarchy. Non-intrusive means: | |
- It does not require extending a custom ``Model`` base class or metaclass. | |
- It does not require a ``ForeignKey`` to ``ContentType`` or the ``contenttypes`` | |
app in general. Instead the real class of an instance is determined based on | |
the value (**polymorphic identity**) of a user-specified discriminating field | |
(**polymorphic on**). | |
- It does not override the default (or any other) model ``Manager`` (unless |
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
# | |
# Advanced Django 1.3.x+ Logging | |
# | |
# Author: | |
# Jason Giedymin < jasong _[_a-t_]_ apache d-o-t org > | |
# | |
# Description: | |
# A Django 1.3.x+ settings.py snippet with Advanced logging formatters using RFC 2822, | |
# TimedRotatingFileHandler, and a WatchedFileHandler. | |
# |
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
from django.contrib.sessions.backends.base import SessionBase, CreateError | |
from django.conf import settings | |
from django.utils.encoding import force_unicode | |
import redis | |
class SessionStore(SessionBase): | |
""" Redis store for sessions""" | |
def __init__(self, session_key=None): | |
self.redis = redis.Redis( |
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
virtualenv --no-site-packages . | |
source bin/activate | |
bin/pip install Django psycopg2 django-sentry | |
bin/pip freeze > requirements.txt | |
bin/django-admin.py startproject mysite | |
cat >.gitignore <<EOF | |
bin/ | |
include/ | |
lib/ | |
EOF |
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
# Based on http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/ | |
# Converter to coffeescript by Wes Bos - http://wesbos.com | |
window.log = -> | |
log.history = log.history or [] | |
log.history.push arguments | |
console.log Array::slice.call arguments if @console | |
return |
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
<!-- this usually goes in <project-root>/templates/uni_form/field.html --> | |
{% if field.is_hidden %} | |
{{ field }} | |
{% else %} | |
<div class="clearfix {% if field.errors %}error{% endif %}"> | |
<label for="{{ field.auto_id }}" {% if field.field.required %}class="requiredField"{% endif %}> | |
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %} | |
</label> | |
<div class="input"> |
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 basic idea here is to substantiate the claims made by this square post: | |
http://corner.squareup.com/2011/06/postgresql-data-is-important.html | |
In PostgreSQL, and MySQL (MyISAM and InnoDB) I create millions of rows and then add | |
and remove columns and add and remove indexes. For columns without defaults this is | |
basically free in PostgreSQL and O(n) in MySQL. For adding indexes its at best O(n) | |
everywhere, but with PostgreSQL it claims not to do any locking that would otherwise | |
prevent table interaction. | |
Also, PostgreSQL has _awsome_ documentation (it has real examples!). I always get |
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
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
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
(function(){ | |
document.addEventListener("drop", function( e ) { | |
e.preventDefault(); | |
var blob = e.dataTransfer.files[0].slice(); | |
var binaryReader = new FileReader(); | |
$('.req').removeClass('.req'); | |
binaryReader.addEventListener("load", function( file ) { | |
var notFound = ''; | |
file.target.result.trim().replace(/==.*/g,'').split(/\n/).forEach(function(pack){ |
OlderNewer