Skip to content

Instantly share code, notes, and snippets.

View nvdarekar's full-sized avatar

Nitin Darekar nvdarekar

View GitHub Profile
@nvdarekar
nvdarekar / squash-commits.sh
Created October 23, 2016 14:15 — forked from jbub/squash-commits.sh
git squash last two commits into one
git rebase --interactive HEAD~2
# we are going to squash c into b
pick b76d157 b
pick a931ac7 c
# squash c into b
pick b76d157 b
s a931ac7 c
function obj(o) {
function F() {}
F.prototype = o;
return new F();
}
function inheritPrototype(sub, sup) {
var p = obj(sup.prototype);
p.constructor = sub;
sub.prototype = p;
@nvdarekar
nvdarekar / useful_pandas_snippets.py
Created March 19, 2016 06:24 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
#List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
#Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
#Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(value_list)]
@nvdarekar
nvdarekar / postgres-tips.sh
Created March 8, 2016 05:08 — forked from nepsilon/3-postgres-tips.md
3 tips for a better PostgreSQL usage
# 1. Use your editor to write queries:
# Tell the terminal what editory to use
$ export EDITOR=subl
# Then in psql type:
psql> \e
# It will open SublimeText with the last query.
# Close the file and the query will run.
# 2. Turn too long columns into lines: