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
""" | |
WSGI middleware that authenticates against a Django user database. | |
DJANGO_SETTINGS_MODULE should point to a valid Django settings module. | |
In addition, the following settings are available: | |
- BASIC_AUTH_LOGIN_URL: DjangoAuth will trigger basic authentication on this | |
URL. Since browsers only propagate auth to resources on the same level or | |
below, this URL will usually be '/<something>' without a trailing slash. |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Vega - bug 259</title> | |
<script src="http://vega.github.io/vega/lib/d3.v3.min.js"></script> | |
<script src="http://vega.github.io/vega/vega.min.js"></script> | |
</head> | |
<body> | |
<div id="chart"></div> | |
<script type="text/javascript"> |
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 optparse import make_option | |
from django.test.simple import DjangoTestSuiteRunner | |
def fake_create_test_db(self, verbosity=1, autoclobber=False): | |
"""Simplified version of BaseDatabaseCreation.create_test_db.""" | |
test_database_name = self._get_test_db_name() | |
if verbosity >= 1: |
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 cms.models import Title | |
from django.contrib.redirects.models import Redirect | |
titles_with_redirect = Title.objects.exclude(redirect__isnull=True).exclude(redirect=u'') | |
for title in titles_with_redirect.select_related('page__site'): | |
Redirect.objects.create( | |
site=title.page.site, | |
old_path=u'/%s/' % title.path, | |
new_path=title.redirect, |
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
"""Build a mapping between svn commits and git changesets. | |
Usage: python build_svn_to_git_mapping.py > svn_to_git.py | |
This script should be run in a clone of the git repository, | |
with a checkout of https://code.djangoproject.com/svn/django in ../django-svn. | |
""" | |
import os | |
import pprint |
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 python3.4 | |
"""Git pre-commit hook""" | |
import os | |
import subprocess | |
import sys | |
def run_linter(cmd, files): |
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 | |
# Copyright (c) 2014 Aymeric Augustin | |
# Released under the WTFPLv2 - http://www.wtfpl.net/txt/copying/ | |
""" | |
Quick'n'dirty solver for http://gameaboutsquares.com/. | |
Install requests or save http://gameaboutsquares.com/game.c.js next to this | |
file. Then run: python gameaboutsquares.py. Tested with Python 2.7 and 3.4. |
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 datetime | |
import hashlib | |
from django.views.decorators.cache import cache_page | |
from django.views.decorators.http import condition | |
from django.views.i18n import javascript_catalog | |
def get_version(): | |
# Write your own! That depends on your deployment strategy. | |
# This example won't work if you release more than once a day. |
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
export function addYears(date, numYears) { | |
// Make a copy to avoid mutating the date argument | |
date = new Date(date.getTime()) | |
// If adding years to a February 29th ends up in a non-leap year, this | |
// returns March 1st, which is the expected result. | |
date.setFullYear(date.getFullYear() + numYears) | |
// DST can also mess with us. Thanks, JavaScript, for not having dates. | |
if (date.getHours() === 23) { |
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
export const DAYS_IN_MONTH = [null, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] | |
function daysInMonth(year, month) { | |
// isValidDate checked that year and month are integers already. | |
// February of leap years. Assumes that the Gregorian calendar extends | |
// infinitely in the future and in the past. | |
if (month === 2 && (year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0))) { | |
return 29 | |
} |
OlderNewer