Skip to content

Instantly share code, notes, and snippets.

View haridas's full-sized avatar
🎯
Focusing

Haridas N haridas

🎯
Focusing
View GitHub Profile
@haridas
haridas / new_memcached.py
Created March 24, 2015 03:10
Ketama based Consistent hashing implementation of python-memcache library.
"""
To Test this Script the start 8 memcache servers using this command.
$ memcached -d -p {PortNumber}
PortNumber:
11211
11212
11213
11214
@haridas
haridas / tcp_server_non_blocking.c
Created April 27, 2014 13:03
TCP server with non blocking socket.
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
@haridas
haridas / virtualenv_alias.sh
Created February 16, 2013 10:22
A Simple bash alias for python virtualenv. :)
# Python virtual env alias
alias activate='test -d ENV && source ./ENV/bin/activate || echo "No Virtualenv in the current folder"'
alias mkenv='test -d ENV && echo "Already exists" || virtualenv --system-site-packages ENV; activate'
@haridas
haridas / celeryd.sh
Created June 14, 2012 06:08
Celery Init.d script with Django settings.
#!/bin/bash -e
#=======================================
#
# :Usage: /etc/init.d/celeryd {start|stop|force-reload|restart|try-restart|status}
#
# :Configuration file: /etc/default/celeryd
#
# To configure celeryd you probably need to tell it where to chdir.
#
# EXAMPLE CONFIGURATION
@haridas
haridas / class_attr.py
Created January 22, 2012 18:06
Intercept Class attributes - Python
"""
Intercept class attributes, and more aboute the discriptors.
Discriptors - Assign a class object to an attribute of another class.
"""
class MetaClass(type):
#This attribute interceptor works when we call the class attributes.
def __getattribute__(self,attr):
print 'Inside Metaclass - class of a class : '
print "class: {}, attribute: {}".format(self,attr)