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 logging | |
root = logging.getLogger() | |
handler = logging.FileHandler('debug.log') | |
fmt = logging.Formatter('%(asctime)s %(process)s/%(thread)s %(levelname)s %(name)s %(filename)s:%(lineno)s %(message)s') | |
handler.setFormatter(fmt) | |
root.addHandler(handler) |
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
# ... | |
# There are models Subscription and MailList defined above. | |
# MailList has a many to many field 'managers'. This field | |
# defines which manager is able to edit/add subscriptions to | |
# a maillist. | |
# | |
# To filter choices in the Django's admin, I use following code: | |
class SubscriptionAdmin(admin.ModelAdmin): | |
list_display = ('id', 'mail_list', 'email', 'name') |
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
""" | |
XHTML cleaner, based on Cleaner from lxml.html. | |
""" | |
import copy | |
from lxml.html import clean | |
from lxml.html import tostring, fromstring, bytes | |
def _transform_result(typ, result): |
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.db import DEFAULT_DB_ALIAS | |
def select_for_update(queryset): | |
""" Returns query, rewrited to use SELECT ... FOR UPDATE. | |
Can be used in transaction to get lock on selected rows. | |
Database must support this SQL statements. | |
Example: | |
>>> query = select_for_update(MyModel.objects.filter(blah = 'minor')) | |
>>> unicode(query.query) |
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.conf import settings | |
from functools import wraps | |
class _s: | |
def __init__(self, a=10, b=None): | |
self.a, self.b = a,b | |
def _override_settings(overrides): | |
_orig = {} | |
_missing = [] |
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/bash | |
# A script to build Django from the given SVN revision | |
REV=$1 | |
UPLOAD_TO=locum:www/pypi | |
pushd . | |
svn co -r $REV http://code.djangoproject.com/svn/django/trunk/ django-$REV | |
cd django-$REV |
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 | |
""" | |
Console output colorizator | |
Author: Alexander Artemenko <svetlyak.40wt@gmail.com> | |
Usage: tail -f some.log | colorize.py 'one.*pattern' 'another' | |
DON'T DOWNLOAD THIS SCRIPT. JUST INSTALL IT USING easy_install colorize | |
OR FORK IT https://github.com/svetlyak40wt/colorize | |
""" |
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 test_utf8(): | |
src = py.code.Source(""" | |
# coding: utf-8 | |
def fn(): | |
\"\"\"тест\"\"\" | |
a = 1 | |
set_trace() | |
return a | |
""") |
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 foo(arg1, arg2): | |
print 'foo:', arg1, arg2 | |
def bar(arg1, arg2): | |
print 'bar:', arg1, arg2 | |
def main(callback): | |
callback('blah', 'minor') | |
if __name__ == '__main__': |
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
fastcgi_param PATH_INFO $fastcgi_script_name; | |
fastcgi_param REQUEST_METHOD $request_method; | |
fastcgi_param REQUEST_URI $request_uri; | |
fastcgi_param QUERY_STRING $query_string; | |
fastcgi_param CONTENT_TYPE $content_type; | |
fastcgi_param CONTENT_LENGTH $content_length; | |
fastcgi_pass_header Authorization; | |
fastcgi_intercept_errors off; | |
fastcgi_param GATEWAY_INTERFACE CGI/1.1; |