Skip to content

Instantly share code, notes, and snippets.

View bhishanpdl's full-sized avatar

Bhishan Poudel bhishanpdl

View GitHub Profile
lst1 = [1,2,3,4,5,6,7]
lst2 = [4,5,6,7,1,2,3]
def rotation(lst1, lst2):
# check equal length
if len(lst1) != len(lst2):
return False
# keys
key = lst1[0] # first element of lst1
from numpy import sin,cos,tan,arcsin,arccos,arctan, pi, modf
from datetime import datetime
def Length_of_day(latitude,day_of_year):
"""
latitude = latitude in degrees (eg. 39.3292 for Athens Ohio)
Example:
import datetime
day_of_year = datetime.datetime.now().timetuple().tm_yday

Dependent Sample

e.g drug test on sampe samples before and after

xbar = df['diff'].mean()
s = df['diff'].std()
n = df.shape[0]
std_err = s/np.sqrt(n)
@bhishanpdl
bhishanpdl / rename_seq_files.sh
Created November 14, 2018 16:06
Rename files sequentially in bash
# rename files sequentially
num=0; for i in *; do mv "$i" "$(printf 'hello_%04d' $num).${i#*.}"; ((num++)); done
@bhishanpdl
bhishanpdl / install_cv2.md
Last active July 31, 2019 19:20
Install opencv3 (cv2)

Install opencv in MacOS Mojave (Oct 22, 2018)

conda create -n cv2 python=3.5
source activate cv2
conda install -n cv2 -c conda-forge numpy # cv2 needs numpy

#conda install anaconda-client # to search anaconda
#anaconda search -t conda opencv3
# I got https://conda.anaconda.org/menpo opencv3 for osx
@bhishanpdl
bhishanpdl / bokeh_interactive_histogram.py
Created October 5, 2018 03:42
Bokeh interactive histogram #bokeh #histogram #interactive
def interactive_histogram(df,col,n_bins,bin_range,title,x_axis_label,x_tooltip):
"""Plot interactive histogram using bokeh.
df: pandas dataframe
col: column of panda dataframe to plot (eg. age of users)
n_bins: number of bins, e.g. 9
bin_range: list with min and max value. e.g. [10,100] age of users.
title: title of plot. e.g. 'Airnb Users Age Distribution'
x_axis_label: x axis label. e.g. 'Age (years)'.
x_tooltip: x axis tooltip string. e.g. 'Age'
@bhishanpdl
bhishanpdl / html preview.js
Last active September 13, 2018 23:14
Render raw html in github etc.. #javascript #html
// Bookmark any webpage and change content with this javascript
javascript:top.location=%22http://htmlpreview.github.com/?%22+document.URL
@bhishanpdl
bhishanpdl / svim.vim
Last active September 11, 2018 00:23
" Settings
map "b" scrollToBottom
map "," previousTab
map "." nextTab
let blacklists = [ "https://*.overleaf.com/*", "*://localhost:*", "*://codepen.io/*", "*://draw.io/*", "*://*slack.com/*", "*://codesandbox.io/*", "*://codewars.com/*", "*://discordapp.com/*", "://gitter.im/*"]
let scrollstep = 120
" Settings
let blacklists = [ "*://localhost.com*/*", "*://localhost:*", "*://codepen.io/*", "*://draw.io/*", "*://*slack.com/*", "*://codesandbox.io/*", "*://codewars.com/*", "*://discordapp.com/*", "://gitter.im/*"]