This file contains hidden or 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 socket | |
def sockrecv(sock): | |
d = '' | |
while not d or d[-1] != '\n': | |
d += sock.recv(8192) | |
return d | |
This file contains hidden or 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
<style> | |
html {visibility:hidden;} | |
</style> | |
<script> | |
if(self==top) { | |
document.documentElement.style.visibility='visible'; | |
} else { | |
top.location=self.location; | |
} | |
</script> |
This file contains hidden or 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 types | |
from django.conf import settings | |
from urllib import urlencode | |
from django.core.cache.backends.base import BaseCache | |
from django.utils.encoding import smart_str | |
#future-proofing against any Django upstream additions of new cache methods. | |
# If we didn't do this, we'd silently use the base class's methods, which wouldn't | |
# use the prefix as required. | |
_expected_methods = set(['__contains__', '__init__', 'add', 'close', |
This file contains hidden or 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
// Location shim 1.0 | |
// (c) Jeremy Dunck | |
// MIT License | |
function Location(url) { | |
obj = parseUri(url); | |
this.hash = obj.anchor ? "#" + obj.anchor : ""; | |
this.host = obj.authority; | |
this.hostname = obj.host; | |
this.href = url; |
This file contains hidden or 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 sys, os.path, logging | |
try: | |
import sysconfig | |
except ImportError: | |
sysconfig = None | |
def warn_on_path_overlap(): | |
""" |
This file contains hidden or 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 is intended to be run as part of a fab-suite, i.e. fab git_push, which runs tests, all files committed, etc. before pushing. | |
def ensure_no_duped_migrations(): | |
migration_dirs = local('find %s -type d -iname migrations' % ROOT_DIR, | |
True).split('\n') | |
for migration_dir in migration_dirs: | |
full_migration_dir = path.join(ROOT_DIR, migration_dir) | |
# FIXME: for GNU find, need regextype=posix-extended | |
dupe_checker = ("find -E %s -iregex '.*/[0-9]{4,}[^/]*\.py' -exec basename {} ';'| cut -d_ -f1 | sort | uniq -d" % |
This file contains hidden or 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 djcelery.models import PeriodicTask | |
from django.utils import importlib | |
bad_tasks = [] | |
good_tasks = [] | |
for pt in PeriodicTask.objects.iterator(): | |
path_name, task_name = pt.task.rsplit('.', 1) | |
try: | |
module = importlib.import_module(path_name) |
This file contains hidden or 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 el = document.createElement('div'), | |
b = document.getElementsByTagName('body')[0], | |
otherlib = false, | |
msg = ''; | |
el.style.position = 'fixed'; | |
el.style.height = '32px'; | |
el.style.width = '220px'; | |
el.style.marginLeft = '-110px'; | |
el.style.top = '0'; |
This file contains hidden or 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.db.models import Model | |
class ModelBase(Model): | |
class Meta: | |
abstract = True | |
def save(self, *args, **kwargs): | |
self.full_clean() | |
super(ModelBase, self).save(*args,**kwargs) |
This file contains hidden or 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
SELECT DISTINCT (contacts_itemcandidate.id is not null) AS `social_like`, (contacts_itemdistrict.id is not null) AS `in_district`, (contacts_item.api_voter_id > 0) AS `is_voter`, `contacts_item`.`id` | |
FROM `contacts_item` | |
INNER JOIN | |
`contacts_itemuser` | |
ON | |
(`contacts_item`.`id` = `contacts_itemuser`.`item_id`) | |
LEFT OUTER JOIN | |
`contacts_itemcandidate` | |
ON | |
(`contacts_item`.`id` = `contacts_itemcandidate`.`item_id`) |
OlderNewer