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
def apdate_to_datetime(date): | |
""" | |
Takes an AP-formatted date string and returns a Python datetime | |
object. This will also work on any date formatted as either | |
'%b. %d, %Y' or '%B %d, %Y' | |
Examples: | |
>>> apdate_to_datetime("Sept. 4, 1986") | |
datetime.datetime(1986, 9, 4, 0, 0) | |
>>> apdate_to_datetime("Sep. 4, 1986") |
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
var intcomma = function(value) { | |
// inspired by django.contrib.humanize.intcomma | |
var origValue = String(value); | |
var newValue = origValue.replace(/^(-?\d+)(\d{3})/, '$1,$2'); | |
if (origValue == newValue){ | |
return newValue; | |
} else { | |
return intcomma(newValue); | |
} | |
}; |
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
# An example of the below | |
virtualenv "/home/dvcsmirrors/hg" do | |
owner "root" | |
group "dvcsmirrors" | |
mode 0775 | |
packages "Mercurial" => "1.6.3", | |
"hgsubversion" => "1.1.2" | |
end |
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
""" | |
jQuery templates use constructs like: | |
{{if condition}} print something{{/if}} | |
This, of course, completely screws up Django templates, | |
because Django thinks {{ and }} mean something. | |
Wrap {% verbatim %} and {% endverbatim %} around those | |
blocks of jQuery templates and this will try its best |
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 yaml | |
import yaml.constructor | |
try: | |
# included in standard lib from Python 2.7 | |
from collections import OrderedDict | |
except ImportError: | |
# try importing the backported drop-in replacement | |
# it's available on PyPI | |
from ordereddict import OrderedDict |
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() { | |
var Geocoder = function(address, cb) { | |
this.address = address; | |
this.geocoder = new google.maps.Geocoder(); | |
this.geocode(cb); | |
}; | |
Geocoder.prototype = { | |
geocode : function(cb) { | |
if (this.address === "") return false; |
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 HTML 4.01 Transitional//EN" | |
"http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head><title id="maintitle">Document Viewer</title> | |
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"> | |
<link href="css/document-cloud.css" media="all" rel="stylesheet" type="text/css"> | |
<!-- | |
Customized document viewer for use with DocumentCloud, at http://documentcloud.org. |
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
try: | |
from cStringIO import StringIO | |
except ImportError: | |
from StringIO import StringIO | |
import datetime | |
import decimal | |
from django.core.serializers.python import Serializer as PythonSerializer | |
from django.core.serializers.json import DjangoJSONEncoder | |
from django.utils.encoding import is_protected_type, smart_unicode |
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
#!/bin/sh | |
db_host="host"; | |
db_user="user"; | |
db_pass="password"; | |
db_name="database"; | |
domains=`mysql --silent --skip-column-names --host $db_host --user $db_user -p$db_pass $db_name --execute "SELECT domain FROM wp_blogs WHERE archived = '0' AND spam = '0' AND deleted = '0';"`; | |
for domain in $domains; do | |
the_date=`date`; |
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 re | |
from fabric.api import * | |
import yaml | |
""" | |
Base configuration | |
""" | |
# Ubuntu |
OlderNewer