This file contains 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
#Git | |
## Create a new branch | |
git branch {branch-name} | |
## List all branches | |
git branch | |
## List all remote (central repository) branches | |
git branch -r | |
## Select/checkout a branch | |
git checkout {branch-name} | |
## Push a branch to remote repo |
This file contains 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
#!/bin/bash | |
# Runs Clojure using the classpath specified in the `.clojure` file of the | |
# current directory. | |
# | |
# Mark Reid <http://mark.reid.name> | |
# Edited by Rishabh Manocha | |
# CREATED: 2009-03-29 | |
# EDITED: 2010-02-27 | |
JAVA=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin/java | |
CLJ_DIR=$HOME/Library/Clojure/lib |
This file contains 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
#A quick script to import posts from my WP blog sql dump into posterous using Posterous' API | |
#The posterous api calls part has been bummed from http://millenniumhand.co.uk/python-posterous-and-rss-import | |
from base64 import b64encode | |
import urllib | |
import urllib2 | |
def send_post(title, body, date): | |
#Enter your own posterous account email address and password in the next line | |
auth = b64encode('%s:%s' % ('{{ email }}', '{{ pass }}')) |
This file contains 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
#A quick bash script to automate the process of dropping, creating and importing data into a postgresql database. | |
#It takes 2 arguments, the first being the database name and the second being the psql dump file. | |
#This script has only been tested on Mac OS X and assumes your PostgreSQL binaries are in /usr/local/pgsql/bin/ | |
#!/bin/bash | |
export PGPASSWORD='FILL ME' | |
echo "Dropping $1" | |
/usr/local/pgsql/bin/dropdb $1 |
This file contains 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 base64 | |
try: | |
import cPickle as pickle | |
except: | |
import pickle | |
class EncodedPickleType(types.TypeDecorator): | |
""" | |
This class should be used whenever pickled data needs to be stored | |
(instead of using the in-built PickleType). The reason for this is |
This file contains 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
function getGoogleContent(elem, searchtype, query) { | |
$.getJSON('http://ajax.googleapis.com/ajax/services/search/' + searchtype + '?v=1.0&q=' + query + '&callback=?', | |
function(data) { | |
if(data.responseData.results.length == 0) | |
elem.html($('<p></p>').html('No results').attr('style','text-align: center; font-weight: bold; font-size: 1.2em;')); | |
else { | |
elemliststr = elem.attr('id') + '-list'; | |
elem.html($('<ul></ul>').attr('id',elemliststr).attr('style','list-style-type: disc; padding-left: 30px;')); | |
elemlistobj = $('#' + elemliststr); | |
$.each(data.responseData.results, function(i, item) { |
This file contains 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
#This is the custom form being used at http://govcheck.net/petitions/add/. It allows users to specify a list of | |
#email addresses to share this petition with upon it's creation. It also allows users to tag the given petition | |
#with other objects in the site (using models.PetitionRelatedObject) | |
from django.forms.fields import email_re | |
def is_valid_email(email): | |
""" | |
This function checks that the given email address is in-fact valid. It uses the same | |
RegExp as used by django.forms to make sure an EmailField is valid. |
This file contains 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
def loggedin_check(request, *args, **kwargs): | |
""" | |
This view will be a light wrapper around other views which need to ensure that the user is logged out | |
""" | |
if request.user.is_authenticated(): | |
return HttpResponseRedirect(reverse("show-homepage")) | |
else: | |
view_func = kwargs.pop('view_func') | |
return view_func(request, *args, **kwargs) | |