Skip to content

Instantly share code, notes, and snippets.

View msbanik's full-sized avatar

Madhusudan Banik msbanik

View GitHub Profile
@msbanik
msbanik / countries.md
Created February 16, 2017 21:46 — forked from richjenks/countries.md
ISO 3166 countries by region — AMER, EMEA & APAC
Country ISO 3166 Region
Afghanistan AF EMEA
Åland Islands AX EMEA
Albania AL EMEA
Algeria DZ EMEA
American Samoa AS APAC
Andorra AD EMEA
Angola AO EMEA
Anguilla AI AMER
@msbanik
msbanik / elasticsearch-with-typeahead-js-editted.markdown
Created August 20, 2016 17:21
ElasticSearch with Typeahead.js - editted
@msbanik
msbanik / latency.txt
Created March 23, 2016 05:16 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@msbanik
msbanik / flask_rest_server.py
Created April 8, 2015 04:17
Flask rest server
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask.ext.httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'miguel':
@msbanik
msbanik / execQuery.py
Created June 20, 2014 16:56
connect to mysql db and exec query
import pymysql
conn = pymysql.connect(host='172.19.3.126', user='vson', passwd='VsonSql', db='ems_cache')
query = ""
cur = conn.cursor()
cur.execute(query)
@msbanik
msbanik / gist:7551991
Created November 19, 2013 20:28
update all packages in python repo
import pip
from subprocess import call
for dist in pip.get_installed_distributions():
call("pip install --upgrade " + dist.project_name, shell=True)
@msbanik
msbanik / string_format_python
Created October 18, 2013 05:42
python string format specifier
format_spec ::= [[fill]align][sign][#][0][width][,][.precision][type]
fill ::= <a character other than '{' or '}'>
align ::= "<" | ">" | "=" | "^"
sign ::= "+" | "-" | " "
width ::= integer
precision ::= integer
type ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"
@msbanik
msbanik / dateformat.txt
Last active December 25, 2015 17:59
date format python
+-------------+----------------------------------+--------------------------+---------+
| Directive | Meaning | Example | Notes |
+=============+==================================+==========================+=========+
| %a | Weekday as locale's abbreviated | Sun, Mon, ..., Sat | (1) |
| | name. | (en_US);So, Mo, ..., Sa | |
| | | (de_DE) | |
+-------------+----------------------------------+--------------------------+---------+
| %A | Weekday as locale's full name. | Sunday, Monday, ..., | (1) |
| | | Saturday | |
| | | (en_US);Sonntag, Montag, | |
@msbanik
msbanik / profile_grash.sh
Created May 16, 2013 19:40
Terminal color Grash
gconftool-2 --set /apps/gnome-terminal/profiles/Default/foreground_color --type string "#FEEEA2"
gconftool-2 --set /apps/gnome-terminal/profiles/Default/background_color --type string "#1B763F"
gconftool-2 --set /apps/gnome-terminal/profiles/Default/bold_color --type string "#FDAF48"
@msbanik
msbanik / zip.sh
Last active December 11, 2015 01:49
zip and unzip
#uncompress .gz file
gunzip -d file_name
# compress
tar -cvzf tarballname.tar.gz itemtocompress
#uncompress
gunzip filename.tar.gz
tar -xvf filename.tar