Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div id="hello">hello</div>
</body>
@srkama
srkama / AddressMixin.py
Created May 29, 2014 10:52
A simple Gist to for Address mixin, When we Address fields in your model include this mixin
__author__ = 'Kamal.S'
__version__ = '0.0.1'
from django.db import models
class AddressMixin(models.Model):
"""
AddressMixin
"""
@srkama
srkama / jsbin.zovac.html
Last active August 29, 2015 14:02
Adding rows dynamically
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<a id="add">+</a></td>
$('#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 / deny_commit_tags.sh
Created August 19, 2015 08:32
This file is restrict the access to commit changes in tag.
output_error_and_exit() {
echo "$1" >&2
exit 1
}
changed_tags=$( $SVNLOOK changed -t "$TXN" "$REPOS" | grep "[ /]tags/." )
if [ "$changed_tags" ]
then
echo "$changed_tags" | egrep -v "^[AD] +(.*/)?tags/[^/]+/$" && output_error_and_exit "Modification of tags is not allowed."
@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 "";