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 / 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)
@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 / 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 / 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 / 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
package main
import (
"encoding/json"
"fmt"
)
type Response struct {
Action string
Node Nodes
import os
import sys
import subprocess
from optparse import OptionParser
from datetime import datetime
def run_shell_script(shell_script):
"""
Assuming that the script is comming from trusted source.
@haridas
haridas / android_sdk_cmd.md
Last active November 24, 2016 05:18
Manage Android sdk from command line

Some times it would be very handy to check / update android sdk from command line. For automation pipelines it surely helps. Here is few commands that can be used to check or update android sdk from command line.

List Installed SDK details

haridas@haridas-HP-ProBook-4440s:~$ android list sdk
Refresh Sources:
  Fetching https://dl.google.com/android/repository/addons_list-2.xml
  Validate XML
  Parse XML
  Fetched Add-ons List successfully
@haridas
haridas / reduce_git_repo_size.sh
Last active January 6, 2017 04:27
Remove old files completely from git history
## How to remove the old files/folder from all git commits.
#1. clone the repo freshly
git clone <repo.git>
#2. Do index-filter option to go through all the object indexs and look for give match
# And remove those matching objects.
git filter-branch \
--prune-empty \
--index-filter \
@haridas
haridas / Compile-python-from-source.md
Last active May 8, 2017 07:21
Compile python source from source, compile flags, and other settings for data science works.
  1. Ensure all the development files required to build custom bindings, mainly bzip2, and sqlite3 bingings are important.
  2. Build python with enabling the unicode flag usc4
$ sudo apt-get install libbz2-dev libsqlite3-dev
$ ./configure --enable-unicode=ucs4
$ make
$ make install