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 __future__ import absolute_import | |
import json | |
import re | |
from django import template | |
from django.utils.html import format_html_join | |
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
""" | |
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
""" file mytest.py """ | |
# you require to return a HttpResponse instance in your view | |
from django.http import HttpResponse | |
# handler* are required for the urlresolver | |
from django.conf.urls.defaults import patterns, handler404, handler500 | |
# minimal settings | |
DEBUG = True | |
# tell django to use this file to find urlpatterns. see below | |
ROOT_URLCONF = "mytest" |
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($) { | |
window.FlashMessages = { | |
init: function() { | |
this.container = $("#flash-messages") | |
.find("a.message-close") | |
.fadeIn("slow") | |
.live("click", function() { | |
$(this).parent() | |
.fadeOut("slow", function() { | |
$(this).remove(); |
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 multiprocessing import Process | |
from django.core import serializers | |
from django.core.management import call_command | |
from StringIO import StringIO | |
def dump_database(): | |
sio = StringIO() | |
call_command('dumpdata', stdout=sio, natural=True) | |
return sio.getvalue() |
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 gi.repository import Notify | |
Notify.Notification.new('Incoming call', 'From %s' % number, 'phone-google-nexus-one').show() |
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
LOGGING = { | |
"version": 1, | |
"disable_existing_loggers": True, | |
"handlers": { | |
"mail_admins": { | |
"level": "ERROR", | |
"class": "django.utils.log.AdminEmailHandler" | |
}, | |
}, | |
"loggers": { |
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/python | |
# -*- coding: utf-8 -*- | |
# -*- Mode: python; c-basic-offset: 4 -*- | |
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: | |
'''Interactive Python Gir (Gtk3) Console | |
@author: Jiahua Huang <jhuangjiahua@gmail.com> | |
@license: LGPLv3+ | |
''' |
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
# Python/Twisted/Redis backed DNS server - resolves from NAME to IP addrs | |
# fallback to google or any other DNS server to resolv domains not present on Redis | |
# to set a new domain on redis, just issue a SET domain.tld ip_addr | |
# run with twistd -ny txredns.tac | |
# gleicon 2011 | |
from twisted.names import dns, server, client, cache | |
from twisted.application import service, internet | |
from twisted.internet import defer | |
from twisted.python import log |
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 scrapy.selector import HtmlXPathSelector | |
from scrapy.spider import BaseSpider | |
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor | |
from scrapy.utils.url import urljoin_rfc | |
from scrapy.http import Request | |
class MySpider(BaseSpider): | |
name = ’test’ | |
allowed_domains = [’xxxx.com’] | |
start_urls = [ |
OlderNewer