Skip to content

Instantly share code, notes, and snippets.

View seekshreyas's full-sized avatar
🐼
\_(*|*)_/

Shreyas seekshreyas

🐼
\_(*|*)_/
  • DocuSign
  • San Francisco, CA
View GitHub Profile
from pylab import *
from scipy.stats import uniform, binom, expon, beta
true_gamma = 0.5
N = 600
T = 15
data = zeros((2, N), dtype=float)
event_times = data[0,:]
event_times[:] = uniform(0,15).rvs(N)
@seekshreyas
seekshreyas / retroDesign.py
Created June 22, 2020 05:26 — forked from chums2020/retroDesign.py
Translates Gelman's retrodesign function from R to Python
from scipy.stats import t
def retroDesign(A, s, alpha=0.05, df=1000000, n_sims=10000):
"""
:param A: the hypothesized true effect size
:param s: standard error
:param alpha: confidence level
:param df: degree of freedom
@seekshreyas
seekshreyas / ka_bnet_numpy.py
Created August 29, 2017 06:08 — forked from kohlmeier/ka_bnet_numpy.py
Bayes net example in Python with Khan Academy data
#!/usr/bin/env python
from numpy import asmatrix, asarray, ones, zeros, mean, sum, arange, prod, dot, loadtxt
from numpy.random import random, randint
import pickle
MISSING_VALUE = -1 # a constant I will use to denote missing integer values
def impute_hidden_node(E, I, theta, sample_hidden):
@seekshreyas
seekshreyas / pmml_bayesnet.ipynb
Created August 25, 2017 20:22 — forked from rtbs-dev/pmml_bayesnet.ipynb
Bayesian Network Models in PyMC3 and NetworkX
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@seekshreyas
seekshreyas / ajaxListener.js
Created April 12, 2017 21:21 — forked from icodejs/ajaxListener.js
JS: Listen to ajax calls from Javascript
var open = window.XMLHttpRequest.prototype.open,
send = window.XMLHttpRequest.prototype.send,
onReadyStateChange;
function openReplacement(method, url, async, user, password) {
var syncMode = async !== false ? 'async' : 'sync';
console.warn(
'Preparing ' +
syncMode +
' HTTP request : ' +

Screencapture and animated gifs

I say "animated gif" but in reality I think it's irresponsible to be serving "real" GIF files to people now. You should be serving gfy's, gifv's, webm, mp4s, whatever. They're a fraction of the filesize making it easier for you to deliver high fidelity, full color animation very quickly, especially on bad mobile connections. (But I suppose if you're just doing this for small audiences (like bug reporting), then LICEcap is a good solution).

Capturing (Easy)

  1. Launch quicktime player
  2. do Screen recording

screen shot 2014-10-22 at 11 16 23 am

"""quick way to create a data frame to try things out"""
df = pd.DataFrame(np.random.randn(5, 4), columns=['a', 'b', 'c', 'd'])
df['A'] """ will bring out a col """ df.ix[0] """will bring out a row, #0 in this case"""
"""Given a dataframe df to filter by a series s:"""
df[df['col_name'].isin(s)]
"""to do the same filter on the index instead of arbitrary column"""
df.ix[s]
#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)]
@seekshreyas
seekshreyas / python-pandas-redshift.py
Last active August 29, 2015 14:06 — forked from elliottcordo/gist:59d3c90b158331fe6ed7
Connecting python to redshift
import sys
import logging
import psycopg2
import pandas as pd
import pandas.io.sql as sqlio
import ConfigParser
import argparse
import statistics
from pandas import pivot_table, crosstab
from datetime import datetime