Skip to content

Instantly share code, notes, and snippets.

View xandyn's full-sized avatar

Ruslan.V xandyn

View GitHub Profile
// ADD NEW MESSAGE
$('#submit').keydown(function (e) {
switch (e.keyCode) {
case 13:
break;
default:
var $body = $('#body').val().trim();
if ($body.length > 0) {
$.ajax({
Delivered-To: [email protected]
Received: by 10.194.22.233 with SMTP id h9csp30207wjf;
Tue, 17 Sep 2013 01:38:36 -0700 (PDT)
X-Received: by 10.14.88.130 with SMTP id a2mr187894eef.120.1379407115990;
Tue, 17 Sep 2013 01:38:35 -0700 (PDT)
Return-Path: <[email protected]>
Received: from mx.doffee.me (mx.doffee.me. [37.139.13.18])
by mx.google.com with ESMTPS id 47si19673080eea.241.1969.12.31.16.00.00
(version=TLSv1.2 cipher=RC4-SHA bits=128/128);
Tue, 17 Sep 2013 01:38:35 -0700 (PDT)
//AJAX POST CSRF PROTECTION
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
# views.py
def home(request):
users = MyUser.objects.all()
paginator = Paginator(users, 3)
page = request.GET.get('page')
try:
users = paginator.page(page)
except PageNotAnInteger:
users = paginator.page(1)
except EmptyPage: