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
# Django Query Set Manager | |
# | |
# https://gist.github.com/1026248 | |
from django.db import models | |
class QuerySetManager(models.Manager): | |
""" |
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
# https://gist.github.com/1035190 | |
# See also: Snippets 85, 240, 880 at http://www.djangosnippets.org/ | |
# | |
# Minimally, the following settings are required: | |
# | |
# SSL_ENABLED = True | |
# SSL_URLS = ( | |
# r'^/some/pattern/', | |
# ) |
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
// store.js module for Spine.js | |
// https://github.com/marcuswestin/store.js | |
// http://maccman.github.com/spine/ | |
(function(Spine, $){ | |
Spine.Model.StoreJS = { | |
extended: function() { |
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.auth.models import User | |
class EmailOrUsernameModelBackend(object): | |
""" | |
Custom authentication backend against django.contrib.auth.models.User that | |
allows logging in using either username or email address. Intended to be | |
used in conjunction with django.contrib.auth.backends.ModelBackend. | |
""" |
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
# Convert Django DateTimeField values to ISO format in UTC | |
# Useful for making Django DateTimeField values compatible with the | |
# jquery.localtime plugin. | |
# | |
# https://gist.github.com/1195854 | |
from pytz import timezone, utc | |
from django.conf import settings | |
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
# A simple Django utility function for encrypting data using GnuPG | |
# | |
# https://gist.github.com/1327072 | |
import os | |
import subprocess | |
from django.core.exceptions import ImproperlyConfigured | |
from django.conf import settings |
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
# Django Export CSV admin action factory | |
# https://gist.github.com/1411467 | |
# | |
# Based on http://djangosnippets.org/snippets/2020/ | |
# and http://djangosnippets.org/snippets/1697/ | |
# | |
# Example usage: | |
# | |
# class MyUserAdmin(admin.ModelAdmin): | |
# actions = ( |
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
// Modified by bryanchow for namespace control and higher compressibility | |
// See https://gist.github.com/1649353 for full revision history from original | |
/* | |
* A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined | |
* in FIPS 180-2 | |
* Version 2.2 Copyright Angel Marin, Paul Johnston 2000 - 2009. | |
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet | |
* Distributed under the BSD License | |
* See http://pajhome.org.uk/crypt/md5 for details. |
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
# https://gist.github.com/1776202 | |
from os.path import join | |
from django.http import HttpResponse | |
from django.views.static import serve | |
from django.conf import settings | |
USE_X_ACCEL_REDIRECT = getattr(settings, 'USE_X_ACCEL_REDIRECT', False) | |
X_ACCEL_REDIRECT_PREFIX = getattr(settings, 'X_ACCEL_REDIRECT_PREFIX', '') |
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
/*jshint browser:true */ | |
/*global jQuery */ | |
/* | |
jquery.scrollpane-startstop.js | |
Custom start and stop scrolling events for jScrollPane | |
https://gist.github.com/1963544 | |
Usage: |
OlderNewer