Skip to content

Instantly share code, notes, and snippets.

View trey's full-sized avatar
🏠
I'd rather be at home

Trey Piepmeier trey

🏠
I'd rather be at home
View GitHub Profile
@trey
trey / ISO 8601 in Django templates
Created August 23, 2008 15:34
ISO 8601 in Django templates
{{ value|date:"Y-m-d G:i:s" }}
{# For use with Timeago: http://timeago.yarp.com/ #}
<abbr class="timeago" title="{{ entry.created|date:"Y-m-d G:i:s" }}">Whatever</abbr>
@trey
trey / views.py
Created September 9, 2008 06:29
Doing multiple things on a single view / page (form and a list).
from django.http import HttpResponseRedirect
from django.views.generic import list_detail
from myapp.models import *
from myapp.forms import EntryForm
def entry_list(request, page=0):
if request.POST:
form = EntryForm(data=request.POST)
if form.is_valid():
form.save()
@trey
trey / vhost.conf
Created September 10, 2008 04:26
Redirecting a domain using a VirtualHost file.
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^(.*)?$ http://new-example.com$1 [R=301,L]
</VirtualHost>
@trey
trey / vhost.conf
Created September 10, 2008 04:32
No WWW
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
RewriteEngine On
# No WWW
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com$1 [R=301,L]
</VirtualHost>
@trey
trey / VirtualHost.conf
Created September 20, 2008 21:48
Using mod_wsgi for a Django project.
# http://www.technobabble.dk/2008/aug/25/django-mod-wsgi-perfect-match/
<VirtualHost *:80>
ServerAdmin you@example.com
ServerName example.com
DocumentRoot /home/you/public_html/example_com/public
# Django settings
WSGIScriptAlias / /home/you/public_html/example_com/wsgi_handler.py
WSGIDaemonProcess example_com user=you group=you processes=1 threads=10
@trey
trey / settings.py
Created September 24, 2008 02:40
Things I like to add to settings.py
import os.path
MEDIA_ROOT = os.path.join(os.path.dirname(__file__), "public/static/")
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__), "templates"),
)
FORCE_LOWERCASE_TAGS = True
SESSION_COOKIE_NAME = 'your_project'
@trey
trey / gist:15896
Created October 9, 2008 21:14
jQuery FadeToggle
// http://www.learningjquery.com/2008/02/simple-effects-plugins
jQuery.fn.fadeToggle = function(speed, easing, callback) {
return this.animate({opacity: 'toggle'}, speed, easing, callback);
};
@trey
trey / gist:15897
Created October 9, 2008 21:15
jQuery ToggleText
// http://dev.jquery.com/ticket/1092
jQuery.fn.toggleText = function(a, b) {
return this.each(function() {
jQuery(this).text(jQuery(this).text() == a ? b : a);
});
};
To delete a blank note in Backpack, open up the dashboard widget and enter some text in the note. Then you'll be able to get the hover delete widget on the website.
@trey
trey / gist:30333
Created November 29, 2008 22:19
iPhone Optimization
<!-- Screencast "Designing Web Content for iPhone @ 20:59 - "Viewport Examples"
<!-- Default viewport width = 980px -->
<!-- https://developer.apple.com/webapps/docs/documentation/AppleApplications/Reference/SafariWebContent/UsingtheViewport/chapter_4_section_5.html -->
<meta name="viewport" content="width=device-width, user-scalable=no">
<!-- or -->
<meta name="viewport" content="maximum-scale=1.0,width=device-width,initial-scale=1.0">