Skip to content

Instantly share code, notes, and snippets.

View ojii's full-sized avatar

Jonas Obrist ojii

View GitHub Profile
@stefanfoulis
stefanfoulis / search_indexes.py
Created May 4, 2010 08:08 — forked from beniwohli/search_indexes.py
fork with support for cms placeholders (upcoming cms 2.1 release)
from django.conf import settings
from django.utils.translation import string_concat, ugettext_lazy
from django.utils.html import strip_tags
from haystack import indexes, site
from cms.models.managers import PageManager
from cms.models.pagemodel import Page
from cms.models.pluginmodel import CMSPlugin
@chrisglass
chrisglass / autodiscover_local_memcaches
Created December 21, 2010 08:49
This makes Django settings autodiscover local memcaches! :)
import os
import socket
class IP(object):
def __init__(self):
self.base = None
def get(self, end):
if not self.base:
@ojii
ojii / example.html
Created January 12, 2011 15:39
example settings.py for the django CMS
{% load cms_tags %}
<!doctype html>
<head>
<title>{{ request.current_page.get_title }}</title>
{% plugins_media %}
</head>
<body>
{% placeholder "main" %}
</body>
@chrisglass
chrisglass / install_django_cms.sh
Created January 12, 2011 18:18
This will install a "naked" version of Django-CMS to use as a demonstration.
#!/bin/bash
# This should be run on a relatvely modern version of Ubuntu (9.10 or later,
# without any sort of confidence)
PROJECT_NAME=$1
if [ x$PROJECT_NAME = "x" ] ; then
# No project name!
echo "Usage: $0 <project name>"
exit 1
@evildmp
evildmp / convert_to_placeholders.html
Created January 13, 2011 15:39
Convert to Placeholders is a routine that converts text fields in other applications to Django CMS placeholders.
<h3>Summary</h3>
{% if not execute %}
<p>This is a <strong>dry run</strong>. Nothing has been changed.</p>
<p>Please check the results. If you are satisfied, <a href="/convert_to_placeholders/True/">perform the actions listed below</a>, or <a href="/convert_to_placeholders/">do another dry run</a>.</p>
{% else %}
<p><a href="/convert_to_placeholders/">Perform a dry run instead</a>. It's probably too late though.</p>
{% endif %}
<ul>
@chrisglass
chrisglass / inspect_urls.py
Created February 13, 2011 16:42
Creates a flat list of all your url resolvers in Django
from django.core.urlresolvers import get_resolver
from django.core.urlresolvers import RegexURLResolver, RegexURLPattern
def _recurse_resolver(resolver, prefix=[]):
patterns = []
for obj in resolver.url_patterns:
if isinstance(obj, RegexURLPattern):
patterns.append(prefix + [obj.regex.pattern])
elif isinstance(obj, RegexURLResolver):
@chrisglass
chrisglass / wisdom.txt
Created May 26, 2011 14:31
Engineering Wisdom
1. Knowledge is Power.
2. Time is Money.
As every engineer knows:
Power = Work / Time
Since:
Knowledge = Power
Time = Money
@stefanfoulis
stefanfoulis / how_it_work.rst
Created July 19, 2011 07:06
An example nginx conf for mogilefs and gunicorn

Private media

Browser accesses URL of Application:

http://www.example.com/private_media/my_file.pdf

The Permissions are checked by the application backend. If Access is denied the application backend returns a 403 and thats the end of it.

@beniwohli
beniwohli / gist:1173019
Created August 26, 2011 09:04
Sentry Example Config
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
@jacobian
jacobian / authuser.md
Created March 30, 2012 00:35
Upgrading auth.User - the profile approach

Upgrading auth.User - the profile approach

This proposal presents a "middle ground" approach to improving and refactoring auth.User, based around a new concept of "profiles". These profiles provide the main customization hook for the user model, but the user model itself stays concrete and cannot be replaced.

I call it a middle ground because it doesn't go as far as refactoring the whole auth app -- a laudable goal, but one that I believe will ultimately take far too long -- but goes a bit further than just fixing the most egregious errors (username length, for example).

This proposal includes a fair number of design decisions -- you're reading the fifth or sixth draft. To keep things clear, the options have been pruned out and on the one I think is the "winner" is still there. But see the FAQ at the end for some discussion and justification of various choices.

The User model