Skip to content

Instantly share code, notes, and snippets.

View mariocesar's full-sized avatar

Mario-César mariocesar

View GitHub Profile
""" 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"
@shnjp
shnjp / tunnel.py
Created March 5, 2011 06:29
ssh tunnel for Fabric
"""
Fabric tunneling utilities
by shn@glucose.jp
class ForwardServer and relates things are refere Robey Pointer's paramiko example.
(http://bazaar.launchpad.net/~robey/paramiko/trunk/annotate/head%3A/demos/forward.py)
usage::
with make_tunnel('user@192.168.0.2:10022') as t:
(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();
@JasonGiedymin
JasonGiedymin / Advanced Django 1.3.x+ Logging
Created March 25, 2011 18:47
A Django 1.3.x+ settings.py snippet with Advanced logging formatters using RFC 2822, TimedRotatingFileHandler, and a WatchedFileHandler.
#
# Advanced Django 1.3.x+ Logging
#
# Author:
# Jason Giedymin < jasong _[_a-t_]_ apache d-o-t org >
#
# Description:
# A Django 1.3.x+ settings.py snippet with Advanced logging formatters using RFC 2822,
# TimedRotatingFileHandler, and a WatchedFileHandler.
#
@abyx
abyx / list_filter_collapse.js
Created June 9, 2011 20:09
java script trick to hide the "filter" in a django admin view
(function($){
ListFilterCollapsePrototype = {
bindToggle: function(){
var that = this;
this.$filterTitle.click(function(){
that.$filterContent.slideToggle();
that.$list.toggleClass('filtered');
});
},
init: function(filterEl) {
@fogus
fogus / about.md
Created August 11, 2011 00:28 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
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+
'''