Skip to content

Instantly share code, notes, and snippets.

View havencruise's full-sized avatar

Prashanth Padmanabh havencruise

View GitHub Profile
@dblock
dblock / getWeek.js
Created July 13, 2011 22:49
get week of the year in JavaScript
function( d ) {
// Create a copy of this date object
var target = new Date(d.valueOf());
// ISO week date weeks start on monday
// so correct the day number
var dayNr = (d.getDay() + 6) % 7;
// Set the target to the thursday of this week so the
@havencruise
havencruise / gist:4014709
Created November 5, 2012 01:22
Django - Custom decorator involving processing the request
# Django provides some great and easy to use decorators
# that accept simple functions that you could use to
# perform certain tests on the user. However, if your test
# depends on some parameter within the request object (like mine did),
# you could do something like:
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.utils.decorators import available_attrs
from django.utils.http import urlquote