Skip to content

Instantly share code, notes, and snippets.

@develmaycare
develmaycare / Form.php
Created April 14, 2012 14:37
Sample Form Class for the Dead Simple Framework
<?php
/*! DeadSimple_Form allows you to work with a form template (created with
PHP) rather than dynamically added fields (as with Zend_Form or HTML_QuickForm).
This is most useful when your favorite form API cannot easily reproduce the
the desired form in a programmatic way.
Two things are required to utilize this class:
1. A script that instantiates and validates the form. A "controller", if you will.
@develmaycare
develmaycare / get_virtual_host_name.py
Created March 22, 2011 18:34
A simple recipe for getting the virtual host name from within a Django view using RequestSite.
from django.contrib.sites.models import RequestSite
from django.shortcuts import render_to_response
def my_view(request):
domain = RequestSite(request).domain
# ... do some domain specific things here ...
return render_to_response("my_view.html")
@develmaycare
develmaycare / import_email.py
Created October 20, 2010 12:49
Tinkering I've done to check email and import the result in to a Django application.
#! /usr/bin/env python
"""
Import email for a given frequency. For example, to activate importers set
up for every 15 minutes, run:
./import_email.py 15
Set this up in your crontab for 5, 10, 15, 30, 45, and 60 as needed.