Instantly share code, notes, and snippets.

View testing.py
import os
import ipdb; ipdb.set_trace()
# other codes..
View bash-trap-usage.sh
END=""
trap 'increment && END=1' 2
increment() {
ls /
echo "Cleaned up"
}
View Compile-python-from-source.md
  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
View reduce_git_repo_size.sh
## 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 \
View android_sdk_cmd.md

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
View add_exif_record.py
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.
View json_unmarshalling.go
package main
import (
"encoding/json"
"fmt"
)
type Response struct {
Action string
Node Nodes
View new_memcached.py
"""
To Test this Script the start 8 memcache servers using this command.
$ memcached -d -p {PortNumber}
PortNumber:
11211
11212
11213
11214
View tcp_server_non_blocking.c
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
View virtualenv_alias.sh
# 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'