Skip to content

Instantly share code, notes, and snippets.

View mariocesar's full-sized avatar

Mario-César mariocesar

View GitHub Profile
@evansd
evansd / json.py
Last active August 29, 2015 14:01
from __future__ import absolute_import
import json
import re
from django import template
from django.utils.html import format_html_join
register = template.Library()
@aaugustin
aaugustin / djangoauth.py
Created July 29, 2014 12:49
WSGI middleware that authenticates against a Django user database.
"""
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.
""" 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"
(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();
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()
from gi.repository import Notify
Notify.Notification.new('Incoming call', 'From %s' % number, 'phone-google-nexus-one').show()
LOGGING = {
"version": 1,
"disable_existing_loggers": True,
"handlers": {
"mail_admins": {
"level": "ERROR",
"class": "django.utils.log.AdminEmailHandler"
},
},
"loggers": {
@shellexy
shellexy / pygirconsole.py
Created November 15, 2011 12:38
提供 PyGtk3 的交互 shell
#!/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+
'''
@jrossi
jrossi / txredns.py
Created January 19, 2012 04:51 — forked from fcoury/txredns.py
Python/Twisted/Redis backed DNS server.
# 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
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 = [