Skip to content

Instantly share code, notes, and snippets.

View TimFletcher's full-sized avatar

Tim Fletcher TimFletcher

View GitHub Profile
{% block scripts %}
<script type="text/javascript" charset="utf-8">
$(function(){
$('#submit').click(function(){
var username = $("input#id_username").val();
var password = $("input#id_password").val();
$form = $('#login_form');
$form.find('.errorlist').remove();
errordata = '<ul class="errorlist"><li>There was a server error processing your login. Please try again.</li></ul>'
$.ajax({
<IfModule mod_rewrite.c>
RewriteEngine On
# Don't allow users to view robots.txt file
# RewriteCond %{REQUEST_URI} !^/robots\.txt$
# Force add 'www' to URIs without 'www' (permanent redirect)
# RewriteCond %{HTTP_HOST} ^yourdomainname\.com$ [NC]
# RewriteRule ^(.*)$ http://www.yourdomainname.com/$1 [L,R=301]
# man apachectl
sudo apachectl start
sudo apachectl stop
sudo apachectl restart
sudo apachectl configtest
#!/bin/sh
# You must have your virtualenv activated to run this script
NAME=gunicorn_timothyfletcher
PID=/home/fire/www/timothyfletcher.com/conf/gunicorn.pid
SETTINGS=/home/fire/www/timothyfletcher.com/timothyfletcher/settings.py
LOGFILE=/home/fire/www/timothyfletcher.com/logs/gunicorn.log
WORKERS=12
BIND_ADDRESS=127.0.0.1:8000
{% if is_paginated %}
<div class="pagination">
{% for p in paginator.page_range %}
{% if forloop.first %}{% if page_obj.has_previous %}<a href ="?page={{ page_obj.previous_page_number }}" id="previous">&laquo; previous</a>{% endif %}{% endif %}
<span{% ifequal page_obj.number p %} class="current"{% endifequal %}><a href="?page={{ p }}" >{{ p }}</a></span>
{% if forloop.last %}{% if page_obj.has_next %}<a href ="?page={{ page_obj.next_page_number }}" id="next">next &raquo;</a>{% endif %}{% endif %}
{% endfor %}
</div>
{% endif %}
@TimFletcher
TimFletcher / run_gunicorn.sh
Created September 21, 2010 01:43
Gunicorn Management
#!/bin/sh
# You must have your virtualenv activated to run this script
NAME=gunicorn_timothyfletcher
PID=/home/fire/www/timothyfletcher.com/conf/gunicorn.pid
SETTINGS=/home/fire/www/timothyfletcher.com/timothyfletcher/settings.py
LOGFILE=/home/fire/www/timothyfletcher.com/logs/gunicorn.log
WORKERS=8
BIND_ADDRESS=127.0.0.1:8000
@TimFletcher
TimFletcher / search.py
Created August 2, 2011 22:31
Simple Django Search
import re
from django.db.models import Q
from django.shortcuts import render_to_response
from django.template import RequestContext
from apps.missions.models import Mission
from apps.profiles.models import Profile
def normalize_query(query_string,
@TimFletcher
TimFletcher / gunicorn_startup.sh
Created August 20, 2011 14:45
Gunicorn Startup Script
#!/bin/sh
# http://nathanvangheem.com/news/gunicorn-startup-script-for-django
# Place the script in the file - /etc/init.d/gunicorn or whatever you'd like to call it
# make it executable - chmod +x /etc/init.d/gunicorn
# And finally, wire it up - update-rc.d gunicorn defaults
ADDRESS='127.0.0.1'
PYTHON="/opt/django/bin/python"
GUNICORN="/opt/django/bin/gunicorn_django"
Timothys-MacBook-Air:~ tim$ brew install macvim
==> Downloading https://github.com/b4winckler/macvim/tarball/snapshot-63
######################################################################## 100.0%
==> ./configure --with-features=huge --with-tlib=ncurses --enable-multibyte --with-macarchs=x86_64 --enable-perlinter
==> make
==> Caveats
MacVim.app installed to:
/usr/local/Cellar/macvim/7.3-63
To link the application to a normal Mac OS X location:
@TimFletcher
TimFletcher / gist:1690634
Created January 27, 2012 20:00
Installing Rails with rbenv and bundler
# Install rails 'globally' for a ruby version
RBENV_VERSION=1.9.2-p290 rbenv exec gem install rails
# We're installing gems into vendor/bundle so don't run bundler when creating a new rails project
RBENV_VERSION=1.9.2-p290 rbenv exec rails new my_project --skip-bundle
# Install gems
cd my_project
rbenv local 1.9.2-p290
bundle install --path vendor/bundle