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
from django.views.decorators.http import require_http_methods | |
@require_http_methods(["GET", "POST"]) | |
def my_view(request): | |
# I can assume now that only GET or POST requests make it this far | |
# ... | |
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
{ | |
background: white; | |
border-radius: 5px; | |
padding: 20px; | |
-moz-box-shadow: inset 0 0 5px #999; | |
-webkit-box-shadow: inset 0 0 6px #757575; | |
box-shadow: inner 0 0 5px #999; | |
} |
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 new_user(username, admin='no', comment="No comment provided"): | |
log_action("New User (%s): %s" % (username, comment)) | |
pass | |
$ fab new_user:myusername | |
$ fab new_user:username=myusername | |
$ fab new_user:myusername,yes | |
$ fab new_user:myusername,admin=yes | |
$ fab new_user:myusername,admin=no,comment='Gary\, new developer (starts Monday)' |
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 uuid | |
uuid.uuid1().hex |
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
from functools import wraps | |
from django.utils.decorators import available_attrs | |
def my_decorator(parameter_name): | |
def decorator(view_func): | |
@wraps(view_func, assigned=available_attrs(view_func)) | |
def _wrapped_view(request, *args, **kwargs): | |
return view_func(request, *args, **kwargs) | |
return _wrapped_view |
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
var viewportwidth; | |
var viewportheight; | |
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight | |
if (typeof window.innerWidth != 'undefined') | |
{ | |
viewportwidth = window.innerWidth, | |
viewportheight = window.innerHeight | |
} |
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
// look here for more details : https://developer.mozilla.org/en-US/docs/DOM/event.initMouseEvent | |
var mouseMoveEvent = document.createEvent("MouseEvents"); | |
mouseMoveEvent.initMouseEvent( | |
"mousemove", //event type : click, mousedown, mouseup, mouseover, mousemove, mouseout. | |
true, //canBubble | |
false, //cancelable | |
window, //event's AbstractView : should be window | |
1, // detail : Event's mouse click count |
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
// gecko and webkit | |
// details here https://developer.mozilla.org/en-US/docs/DOM/event.initKeyEvent | |
var keyboardEvent = document.createEvent("KeyboardEvent"); | |
var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? "initKeyboardEvent" : "initKeyEvent"; | |
keyboardEvent[initMethod]( | |
"keydown", // event type : keydown, keyup, keypress | |
true, // bubbles |
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
{ | |
-webkit-box-shadow: white 0 1px 0 0; | |
-moz-box-shadow: #fff 0 1px 0 0; | |
-ms-box-shadow: #fff 0 1px 0 0; | |
-o-box-shadow: #fff 0 1px 0 0; | |
box-shadow: white 0 1px 0 0; | |
border-bottom: 1px solid #EBEAE5; | |
} |
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
// Kudos to Grumdrig | |
// http://stackoverflow.com/questions/1207008/how-do-i-lock-the-orientation-to-portrait-mode-in-a-iphone-web-application | |
$(document).ready(function () { | |
function reorient(e) { | |
var portrait = (window.orientation % 180 == 0); | |
$("body > div").css("-webkit-transform", !portrait ? "rotate(-90deg)" : ""); | |
} | |
window.onorientationchange = reorient; | |
window.setTimeout(reorient, 0); |
OlderNewer