This file contains hidden or 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
<?php | |
// This is a sample PHP script that demonstrates accepting a POST from the | |
// Unbounce form submission webhook, and then sending an email notification. | |
function stripslashes_deep($value) { | |
$value = is_array($value) ? | |
array_map('stripslashes_deep', $value) : | |
stripslashes($value); | |
return $value; | |
} |
This file contains hidden or 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/env bash | |
# Written by William Ting for the following blog post: | |
# http://williamting.com/posts/2012/04/18/set-up-python-and-django-on-dreamhost/ | |
rcfile="${HOME}/.bashrc" | |
version="2.7.3" | |
setuptools_version="2.7" | |
tmp_dir="${HOME}/tmp-${RANDOM}" | |
if [[ ${#} == 0 ]]; then |
This file contains hidden or 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
import os, sys | |
import site | |
# Remember original sys.path. | |
prev_sys_path = list(sys.path) | |
# we add currently directory to path and change to it | |
pwd = os.path.dirname(os.path.abspath(__file__)) | |
os.chdir(pwd) | |
sys.path = [pwd] + sys.path |
This file contains hidden or 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
Page.create_content_type(ApplicationContent, APPLICATIONS=( | |
('elephantblog.urls', _('Blog')), | |
)) |
This file contains hidden or 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
########## ELEPHANTBLOG CONFIGURATION | |
def elephantblog_entry_url_app(self): | |
from feincms.content.application.models import app_reverse | |
return app_reverse('elephantblog_entry_detail', 'elephantblog.urls', kwargs={ | |
'year': self.published_on.strftime('%Y'), | |
'month': self.published_on.strftime('%m'), | |
'day': self.published_on.strftime('%d'), | |
'slug': self.slug, | |
}) |
This file contains hidden or 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 django.db import models | |
from django.utils.text import ugettext_lazy as _ | |
from .contact_form_amended import ContactForm, ContactFormContent | |
class MultiContactFormContent(ContactFormContent): | |
FORM_CLASSES = {'simple-contact': ContactForm} | |
FORM_CHOICES = (('simple-contact', _('Simple contact form')),) |
This file contains hidden or 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
export PYTHONPATH=~/modules/ | |
export PATH=~/modules/bin:~/modules/:$PATH | |
export WORKON_HOME=$HOME/.virtualenvs | |
source ~/modules/virtualenvwrapper.sh | |
export PIP_REQUIRE_VIRTUALENV=true | |
export PIP_RESPECT_VIRTUALENV=true | |
export PIP_VIRTUALENV_BASE=$WORKON_HOME | |
# source .bash_profile |
This file contains hidden or 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 django.conf import settings | |
from django.contrib.auth.models import User | |
class EmailOrUsernameModelBackend(object): | |
def authenticate(self, username=None, password=None): | |
if '@' in username: | |
kwargs = {'email': username} | |
else: | |
kwargs = {'username': username} | |
try: |
This file contains hidden or 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
class NextUrlField(forms.CharField): | |
widget = forms.HiddenInput | |
def __init__(self, *args, **kwargs): | |
super(NextUrlField, self).__init__(*args, **kwargs) | |
self.required = False | |
def clean(self, value): | |
if not value: | |
return getattr(settings, 'LOGIN_REDIRECT_URL', '/') | |
else: | |
return value |
This file contains hidden or 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
# Example how to add rich editor capabilities to your models in admin. | |
from django.contrib.admin import site, ModelAdmin | |
import models | |
# we define our resources to add to admin pages | |
class CommonMedia: | |
js = ( | |
'https://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js', |
OlderNewer