Skip to content

Instantly share code, notes, and snippets.

@julienb74
julienb74 / settings.py
Created July 27, 2011 13:19
The default settings.py I use in all my Django 1.2 and 1.3 projects. It already depends on Django South and the Django Debug Toolbar. It doesn't use the new static media handling of Django 1.3. This file is inspired by Martin Mahner. (http://www.mahner.or
# -*- coding: utf-8 -*-
import os
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
PROJECT_NAME = os.path.split(PROJECT_ROOT)[-1]
# -- DEBUG -----------------------------------------------------------------------------------------
DEBUG = True
@julienb74
julienb74 / Advanced Django 1.3.x+ Logging
Created July 27, 2011 13:33 — forked from JasonGiedymin/Advanced Django 1.3.x+ Logging
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.
#
@julienb74
julienb74 / settings.py
Created February 12, 2012 00:15 — forked from palewire/settings.py
My current default Django LOGGING configuration
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
},
'null': {
'level':'DEBUG',
@julienb74
julienb74 / bootstrap.sh
Created February 13, 2012 22:41 — forked from anonymous/bootstrap.sh
Django on Heroku with Celery and Sentry
virtualenv --no-site-packages .
source bin/activate
bin/pip install Django psycopg2 django-sentry
bin/pip freeze > requirements.txt
bin/django-admin.py startproject mysite
cat >.gitignore <<EOF
bin/
include/
lib/
EOF
@julienb74
julienb74 / gist:2157266
Created March 22, 2012 09:10 — forked from firedfox/gist:2037945
find google ads with phantomjs
var page = require('webpage').create();
page.settings.loadImages = false;
page.onConsoleMessage = function(msg) { console.log(msg); };
page.onLoadFinished = function() {
page.evaluate(function() {
var getFrames = function(doc) {
var frames = doc.querySelectorAll('iframe');
for (var i = frames.length - 1; i >= 0; i--) {
var fdoc = frames[i].contentWindow.document;
@julienb74
julienb74 / gist:2157299
Created March 22, 2012 09:23 — forked from firedfox/gist:2037411
check google ads with phantomjs
var page = require('webpage').create();
page.settings.loadImages = false;
page.onConsoleMessage = function(msg) { console.log(msg); };
var pageUrl = 'http://www.bloggersentral.com/2010/08/how-put-add-adsense-on-blogger.html';
var num = 0;
var max = 2;
page.onLoadFinished = function() {
var text = page.evaluate(function() {
@julienb74
julienb74 / map2pdf.js
Created March 23, 2012 22:24 — forked from gka/map2pdf.js
Rendering a Kartograph map to PDF using PhantomJS
var page = new WebPage(),
url = "http://kartograph.org/showcase/italia/",
output = "italia.pdf";
page.viewportSize = { width: 1100, height: 750 };
page.open(url, function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
} else {
@julienb74
julienb74 / datetime.py
Created March 24, 2012 00:22 — forked from temoto/datetime.py
Python datetime timezone utils.
# coding: utf-8
from __future__ import absolute_import
"""Datetime utils.
To store time use `naive_to_utc(dt, tz_name)`.
To display time use `utc_to_local(dt, tz_name)`.
"""
import datetime as stdlib_datetime
import pytz
@julienb74
julienb74 / postsql.sql
Created May 19, 2012 09:02 — forked from tobyhede/postsql.sql
PostgreSQL as JSON Document Store
-- PostgreSQL 9.2 beta (for the new JSON datatype)
-- You can actually use an earlier version and a TEXT type too
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8
-- Inspired by
-- http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html
-- http://ssql-pgaustin.herokuapp.com/#1
-- JSON Types need to be mapped into corresponding PG types
--
@julienb74
julienb74 / settings.py
Created May 30, 2012 22:55 — forked from richleland/settings.py
S3BotoStorage subclass for media and static buckets
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
STATICFILES_STORAGE = 'path.to.storage.S3StaticStorage'
THUMBNAIL_DEFAULT_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_ACCESS_KEY_ID = 'YOUR KEY'
AWS_SECRET_ACCESS_KEY = 'YOUR KEY'
AWS_STORAGE_BUCKET_NAME = 'media.YOURSITE.com'
AWS_STATIC_BUCKET_NAME = 'static.YOURSITE.com'
AWS_S3_CUSTOM_DOMAIN = AWS_STORAGE_BUCKET_NAME
AWS_STATIC_CUSTOM_DOMAIN = AWS_STATIC_BUCKET_NAME
STATIC_URL = 'http://%s/' % AWS_STATIC_BUCKET_NAME