Skip to content

Instantly share code, notes, and snippets.

View prestontimmons's full-sized avatar

Preston Timmons prestontimmons

View GitHub Profile
@prestontimmons
prestontimmons / gist:3800756
Created September 28, 2012 16:19
Django test with test template loader
from django.template import Template
from django.test import TestCase
from django.test.client import RequestFactory
from django.test.utils import (
setup_test_template_loader,
restore_template_loaders,
override_settings,
)
class TemplateTest(TestCase):
set softtabstop=2
set shiftwidth=2
set tabstop=2
set expandtab "expandtab (whitespace)
set number "line numbers
set ai "autoindent
set si "smartindent
set tw=79 "wrap on 79
set sta "smarttab
set history=100 "remember more than 20 cmd-history
@rakhmad
rakhmad / clojure.md
Created April 17, 2012 15:55
Setting Up Clojure on OS X

Setting Up Clojure on OS X

I spent a lot of time trying to find a pretty optimal (for me) setup for Clojure… at the same time I was trying to dive in and learn it. This is never optimal; you shouldn't be fighting the environment while trying to learn something.

I feel like I went through a lot of pain searching Google, StackOverflow, blogs, and other sites for random tidbits of information and instructions.

This is a comprehensive "what I learned and what I ended up doing" that will hopefully be of use to others and act as a journal for myself if I ever have to do it again. I want to be very step-by-step and explain what's happening (and why) at each step.

Step 1: Getting Clojure (1.3)

@prestontimmons
prestontimmons / testcase.py
Created October 24, 2011 22:19
Lazy man's Django testcase
"""
Decrease the verbosity of writing view tests.
Old way:
self.client.get(reverse("my-view"))
self.client.post(reverse("my-view"), data={"key": "value"})
self.client.login("username", "password")
self.client.get(reverse("my-other-view"))
self.client.logout()
@jezdez
jezdez / ps1.bash
Created May 30, 2011 12:18 — forked from zain/ps1.bash
PS1 that looks smexy (with added hg support)
#### PS1 customization ####
NONE="\[\033[0m\]" # unsets color to term fg color
# regular colors
K="\[\033[0;30m\]" # black
R="\[\033[0;31m\]" # red
G="\[\033[0;32m\]" # green
Y="\[\033[0;33m\]" # yellow
B="\[\033[0;34m\]" # blue
M="\[\033[0;35m\]" # magenta
@macdonst
macdonst / audio.html
Created May 18, 2011 19:48
PhoneGap Media Class Example
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>PhoneGap Back Button Example</title>
<script type="text/javascript" charset="utf-8" src="phonegap.0.9.5.js"></script>
<script type="text/javascript" charset="utf-8">
var myMedia = null;
@mikeyk
mikeyk / redis_session_backend.py
Created April 8, 2011 18:01
A redis backend for Django Sessions, tested on Django 1.3+
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(
@toastdriven
toastdriven / setZeroTimeout.html
Created March 24, 2011 16:42
This is amazingly fast. Don't want to lose it.
<!DOCTYPE HTML>
<!-- zero-timeout.html, L. David Baron <dbaron@dbaron.org>, 2010-03-07, 2010-03-09 -->
<!--
Copyright (c) 2010, The Mozilla Foundation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@toastdriven
toastdriven / autocomplete.py
Created February 21, 2011 19:12
How to make multiple word autocomplete work in Haystack.
import operator
from haystack.query import SearchQuerySet, SQ
query = 'lil way'
sqs = SearchQuerySet().filter(reduce(operator.__and__, [SQ(name=word.strip()) for word in query.split(' ')]))
@prestontimmons
prestontimmons / gist:348152
Created March 29, 2010 17:42
Search and Replace in Linux

Search and Replace Utilities

sed

The sed command makes it easy to modify text.

$ sed -i "s/django.conf.urls.defaults/django.conf.urls/g" urls.py