Skip to content

Instantly share code, notes, and snippets.

$('#participantes-table').dataTable({
bProcessing: true,
bServerSIde: true,
sAjaxSource: "/path/to/your/tastypie/api/list/objects/?format=json",
sAjaxDataProp: "objects",
aoColumns: [
// Put the resource name that corresponds to each table column
{'mData': "your"},
{'mData': "columns"},
],
from django.conf.urls.defaults import *
from tastypie.paginator import Paginator
from tastypie.exceptions import BadRequest
from tastypie.resources import ModelResource
from tastypie.utils import trailing_slash
from haystack.query import SearchQuerySet, EmptySearchQuerySet
from clips.models import Clip
@srkama
srkama / gist:100ab1ee31cc7d94a71b
Created November 25, 2015 16:01 — forked from aj-justo/gist:3228782
SSL setup with Nginx + Gunicorn + Django 1.3 or 1.4

Configuring Nginx to serve SSL content is straight forward, once you have your certificate and key ready: server {    listen 443 default ssl;    root /path/to/source;    server_name mydomain;

   ssl_certificate      /path/to/cert;    ssl_certificate_key  /path/to/key;

// Bonfire: Return Largest Numbers in Arrays
// Author: @srkama
// Challenge: http://www.freecodecamp.com/challenges/bonfire-return-largest-numbers-in-arrays?solution=function%20largestOfFour(arr)%20%7B%0A%20%20maxArray%20%3D%20new%20Array(arr.length)%3B%0A%20%20for(i%3D0%3Bi%3Carr.length%3Bi%2B%2B)%7B%0A%20%20%20%20maxArray%5Bi%5D%3DMath.max.apply(null%2Carr%5Bi%5D)%3B%0A%20%20%7D%0A%20%20%2F%2F%20You%20can%20do%20this!%0A%20%20return%20maxArray%3B%0A%7D%0A%0AlargestOfFour(%5B%5B4%2C%205%2C%201%2C%203%5D%2C%20%5B13%2C%2027%2C%2018%2C%2026%5D%2C%20%5B32%2C%2035%2C%2037%2C%2039%5D%2C%20%5B1000%2C%201001%2C%20857%2C%201%5D%5D)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function largestOfFour(arr) {
maxArray = new Array(arr.length);
for(i=0;i<arr.length;i++){
maxArray[i]=Math.max.apply(null,arr[i]);
}
// Bonfire: Confirm the Ending
// Author: @srkama
// Challenge: http://www.freecodecamp.com/challenges/bonfire-confirm-the-ending
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function end(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
return target===str.slice(target.length*-1);
}
// Bonfire: Repeat a string repeat a string
// Author: @srkama
// Challenge: http://www.freecodecamp.com/challenges/bonfire-repeat-a-string-repeat-a-string?solution=function%20repeat(str%2C%20num)%20%7B%0A%20%20%2F%2F%20repeat%20after%20me%0A%20%20if(num%20%3C%200)%0A%20%20%20%20%7B%0A%20%20%20%20%20%20return%20%22%22%3B%0A%20%20%20%20%7D%0A%20%20resultStr%3D%22%22%3B%0A%20%20for(i%3D1%3Bi%3C%3Dnum%3Bi%2B%2B)%20%7B%0A%20%20%20%20resultStr%3DresultStr.concat(str)%3B%0A%20%20%7D%0A%20%20return%20resultStr%3B%0A%7D%0A%0Arepeat(%22abc%22%2C%203)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function repeat(str, num) {
// repeat after me
if(num < 0)
{
return "";
// Bonfire: Truncate a string
// Author: @srkama
// Challenge: http://www.freecodecamp.com/challenges/bonfire-truncate-a-string?solution=function%20truncate(str%2C%20num)%20%7B%0A%20%20%2F%2F%20Clear%20out%20that%20junk%20in%20your%20trunk%0A%20%20if(num%3Cstr.length)%20%7B%0A%20%20%20%20return%20num%3E3%20%3F%20str.slice(0%2Cnum-3).concat(%27...%27)%3Astr.slice(0%2Cnum).concat(%27...%27)%3B%0A%20%20%7D%0A%20%20return%20str%3B%0A%7D%0A%0Atruncate(%22A-tisket%20a-tasket%20A%20green%20and%20yellow%20basket%22%2C%2011)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function truncate(str, num) {
// Clear out that junk in your trunk
if(num<str.length) {
return num>3 ? str.slice(0,num-3).concat('...'):str.slice(0,num).concat('...');
}
// Bonfire: Chunky Monkey
// Author: @srkama
// Challenge: http://www.freecodecamp.com/challenges/bonfire-chunky-monkey?solution=function%20chunk(arr%2C%20size)%20%7B%0A%20%20resultArray%20%3D%20%5B%5D%3B%0A%20%20flag%3Dtrue%3B%0A%20%20start%3D0%3B%0A%20%20end%3Dsize%3B%0A%20%20%2F%2F%20Break%20it%20up.%0A%20%20while(flag)%20%7B%0A%20%20%20%20%20a%20%3D%20arr.slice(start%2Cend)%3B%0A%20%20%20%20%20if(a.length)%20%7B%0A%20%20%20%20%20%20%20resultArray.push(a)%3B%0A%20%20%20%20%20%20%20start%3Dend%3B%0A%20%20%20%20%20%20%20end%3Dend%2Bsize%3B%0A%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20flag%3Dfalse%3B%0A%20%20%20%20%20%7D%0A%20%20%7D%0A%20%20return%20resultArray%3B%0A%7D%0A%0Achunk(%5B%22a%22%2C%20%22b%22%2C%20%22c%22%2C%20%22d%22%5D%2C%202)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function chunk(arr, size) {
resultArray = [];
flag=true;
start=0;
end=size;
// Bonfire: Mutations
// Author: @srkama
// Challenge: http://www.freecodecamp.com/challenges/bonfire-mutations?solution=function%20mutation(arr)%20%7B%0A%20%20list%20%3D%20arr%5B1%5D.toLowerCase().split(%22%22)%3B%0A%20%20for(i%3D0%3Bi%3Clist.length%3Bi%2B%2B)%7B%0A%20%20%20%20if(arr%5B0%5D.toLowerCase().indexOf(list%5Bi%5D)%3C0)%20%7B%0A%20%20%20%20%20%20return%20false%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20return%20true%3B%0A%7D%0A%0A%0Amutation(%5B%22hello%22%2C%20%22hey%22%5D)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function mutation(arr) {
list = arr[1].toLowerCase().split("");
for(i=0;i<list.length;i++){
if(arr[0].toLowerCase().indexOf(list[i])<0) {
return false;
// Bonfire: Falsy Bouncer
// Author: @srkama
// Challenge: http://www.freecodecamp.com/challenges/bonfire-falsy-bouncer?solution=function%20bouncer(arr)%20%7B%0A%20%20%2F%2F%20Don%27t%20show%20a%20false%20ID%20to%20this%20bouncer.%0A%20%20return%20arr.filter(function(value)%20%7B%0A%20%20%20%20return%20value%3Ftrue%3Afalse%3B%0A%20%20%7D)%3B%0A%7D%0A%0Abouncer(%5B7%2C%20%22ate%22%2C%20%22%22%2C%20false%2C%209%5D)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function bouncer(arr) {
// Don't show a false ID to this bouncer.
return arr.filter(function(value) {
return value?true:false;
});