This file contains hidden or 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.contrib.sessions.backends.base import SessionBase, CreateError | |
from django.conf import settings | |
from django.utils.encoding import force_unicode | |
import redis | |
class SessionStore(SessionBase): | |
""" Redis store for sessions""" | |
def __init__(self, session_key=None): | |
self.redis = redis.Redis( |
This file contains hidden or 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 get_form(self, request, obj=None): | |
form = super(WapSiteAdmin,self).get_form(request, obj) | |
pl = Platform.objects.get(id=obj.platform_type_id) | |
rev_alert=WapSite.objects.filter(pub=obj.pub,pub_share__gt= str(obj.pub_share)).count() | |
if rev_alert !=0: | |
rev_msg='<b style ="color:red;">Please check the rev share ,publisher has got sites running on rev share greater then this</b>' | |
else: | |
rev_msg='<b>Please select the rev_share</b>' | |
messege = 'Click here to get filter info' |
This file contains hidden or 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
virtualenv --no-site-packages . | |
source bin/activate | |
bin/pip install Django psycopg2 django-sentry | |
bin/pip freeze > requirements.txt | |
bin/django-admin.py startproject mysite | |
cat >.gitignore <<EOF | |
bin/ | |
include/ | |
lib/ | |
EOF |
This file contains hidden or 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
class YourAdmin(ModelAdmin): | |
def changelist_view(self, request, extra_context=None): | |
ref = request.META.get('HTTP_REFERER','') | |
path = request.META.get('PATH_INFO','') | |
if not ref.split(path)[-1].startswith('?'): | |
q = request.GET.copy() | |
q['usertype'] = 'Publisher' | |
q['user_status__exact'] = 'activated' | |
request.GET = q | |
request.META['QUERY_STRING'] = request.GET.urlencode() |
This file contains hidden or 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 copy import copy | |
def get_count(new_art, a): | |
return sum([el.count(a) for el in new_art]) | |
def format_output(tiles): | |
nr = [] | |
for r in tiles: | |
nr.append("".join(r)) | |
tr_str = "\n".join(nr) |
This file contains hidden or 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
#include <cstdlib> | |
#include <iostream> | |
#include <fstream> | |
#include <sstream> | |
#include <conio.h> | |
#define IN "A-large-practice.in" | |
#define OUT "A-large-practice.out" | |
using namespace std; |
This file contains hidden or 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 compute_count(case): | |
hops = int(case[0]) | |
hop = 1 | |
total_time = 0 | |
pos = {'O':1, | |
'B':1} | |
available_time = 0 | |
consumed_time = {'robot':'O', | |
'time': 0} | |
while hop<hops*2+1: |
This file contains hidden or 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
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// KuNG FU JS v.1 20yrsplus.info | |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
//alert('Photo Uploaded! Please wait 1-2 minutes without leaving this page until we process your picture!'); | |
function readCookie(name) { | |
var nameEQ = name + "="; | |
var ca = document.cookie.split(';'); |
This file contains hidden or 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.core.cache import cache | |
def cache_for(seconds,fetch=0): | |
def cache_it(func): | |
def deco_func(self): | |
val = cache.get(self.get_cache_key(fetch)) | |
if not val: | |
val = func(self) | |
cache.set(self.get_cache_key(fetch), val, seconds) | |
return val | |
return deco_func |
This file contains hidden or 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
lakshman@localhost:~/clients/netnoir.com$ ls -ltr | |
total 308 | |
drwxrwxrwx 6 www-data shabda3 4096 Jan 4 22:00 wp-includes | |
drwxrwxrwx 8 www-data shabda3 4096 Jan 4 22:00 wp-admin | |
-rwxrwxrwx 1 www-data root 2594 Feb 6 07:34 wp-config.php | |
-rwxrwxrwx 1 www-data shabda3 7578 Feb 16 03:57 wp-mail.php | |
drwxrwxrwx 6 www-data shabda3 4096 Feb 16 03:57 wp-content | |
-rwxrwxrwx 1 www-data shabda3 93445 Feb 16 03:57 xmlrpc.php | |
-rwxrwxrwx 1 www-data shabda3 3693 Feb 16 03:57 wp-trackback.php | |
-rwxrwxrwx 1 www-data shabda3 23097 Feb 16 03:57 wp-settings.php |