Skip to content

Instantly share code, notes, and snippets.

View rmanocha's full-sized avatar

Rishabh Manocha rmanocha

View GitHub Profile
#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
#!/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
#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 }}'))
@rmanocha
rmanocha / gist:158602
Created July 30, 2009 07:03
A Bash Script to automate the process of dropping, creating and importing data into a PostgreSQL DB
#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
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
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 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.
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)