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 calendar import timegm | |
from datetime import datetime | |
from rfc822 import parsedate | |
from urllib import urlencode | |
from urllib2 import urlopen | |
from django import template | |
from django.utils import simplejson | |
register = template.Library() |
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 ($) { | |
$.fn.defaultValue = function (defaultValue) { | |
return this.each(function (i) { | |
var currentField = $(this); | |
// Only apply the default value to text, password or textareas. | |
if (currentField.is(':not(input:text)') && | |
currentField.is(':not(input:password)') && | |
currentField.is(':not(textarea)')) { | |
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
<?php | |
function get_month_range($start_date, $end_date) | |
{ | |
if (!is_int($start_timestamp)) : | |
$start_timestamp = strtotime($start_date); | |
if ($start_timestamp === false) : | |
throw new Exception("Invalid value provided for the start date!"); | |
endif; | |
endif; |
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 PhoneNumberMultiWidget(forms.MultiWidget): | |
def __init__(self, attrs=None): | |
self.widgets = ( | |
forms.TextInput(attrs={'size': 3, 'maxlength': 3, 'class': 'areacode'}), | |
forms.TextInput(attrs={'size': 3, 'maxlength': 3, 'class': 'exchange'}), | |
forms.TextInput(attrs={'size': 4, 'maxlength': 4, 'class': 'lastfour'}) | |
) | |
super(PhoneNumberMultiWidget, self).__init__(self.widgets, attrs) | |
def format_output(self, rendered_widgets): |
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 os | |
import tempfile | |
from compress.filter_base import FilterBase | |
class LessCSSFilter(FilterBase): | |
""" | |
A filter for django-compress that adds LessCSS support. | |
Based off of "compress.filters.csstidy.CSSTidyFilter". | |
Supported 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
<?php | |
// You'll want to change this to reflect the proper include path. | |
// I just put it in dump/ or a directory like that. | |
require_once '../wp-config.php'; | |
$filename = sprintf('dump-%s.sql', time()); | |
$file = fopen($filename, 'a'); | |
$command = sprintf('mysqldump %s -h %s -u %s --password=%s', DB_NAME, DB_HOST, DB_USER, DB_PASSWORD); |
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 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | |
<title>Open Page in Browserlab</title> | |
</head> |
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 python2.6 | |
def find_anagrams(input_word): | |
words = (word[:-1] for word in open('/usr/share/dict/words').readlines()) | |
return [word for word in words if (sorted(word) == sorted(input_word) and word != input_word)] | |
if __name__ == '__main__': | |
import sys | |
print find_anagrams(sys.argv[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
#!/usr/bin/env python | |
import timeit | |
params = { | |
'domain': 'example.com', | |
'host': 'www.example.com:8000' | |
} | |
string_test = """\ | |
import string |
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 copy import copy | |
from hashlib import md5 | |
from urllib import urlencode | |
from django import template | |
from django.conf import settings | |
register = template.Library() | |
class GravatarNode(template.Node): | |
def __init__(self, user, size=None): |