Skip to content

Instantly share code, notes, and snippets.

pmod prerakmody

Block or report user

Report or block prerakmody

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@prerakmody
prerakmody / vispy_3d.py
Last active Nov 18, 2019
3D Visualizations
View vispy_3d.py
"""
Get cylinder points in 3D grid given start and end point of cylinder axis
"""
import sys
import pdb
import copy
import numpy as np
from scipy.spatial import distance
@prerakmody
prerakmody / regex.py
Last active Oct 28, 2019
Regex Samples
View regex.py
"""
Ref: https://regexr.com/
"""
import re
# Sample 1 - Finding between two chars
str1 = 'M 50.77925000000002 398.604 a 2.5 2.5 0 1 0 5 0 a 2.5 2.5 0 1 0 -5 0' # find string between 'M' and 'a'
str2 = 'M226.31525000000002,401.996a2.5,2.5 0 1,0 5,0a2.5,2.5 0 1,0 -5,0'
out1 = [s.strip() for s in re.findall(r'M([\d,. ]+)a', str1)]
@prerakmody
prerakmody / gradient.py
Last active Jun 21, 2019
Optimization Techniques
View gradient.py
from autograd import grad
import autograd.numpy as anp
def objective():
return
if __name__ == "__main__":
W = np.random.normal(0, 1,X_train.shape[1])
gradient = grad(objective)
W -= gradient(W, X_11, X_12, X_21, X_22) * LR
@prerakmody
prerakmody / drivers.md
Last active May 17, 2019
Ubuntu Hacks
View drivers.md

Bluetooth

Commands

  • HCI = Host Controller Interface of Bluetooth Protocol Stack
  • hciconfig -a
    • Check the LMP version to know the bluetooth version
  • Check MAC address by using hcitool dev
  • Check Bluetooth connections via hcitool con
  • Find device info via hcitool info BB:BB:BB:BB:BB:BB
  • Run bluetoothctl devices to check which devices are available and just general logs
@prerakmody
prerakmody / check_gpu_usage.py
Last active May 25, 2019
Google Colab Hacks
View check_gpu_usage.py
# memory footprint support libraries/code
# ! ln -sf /opt/bin/nvidia-smi /usr/bin/nvidia-smi
# ! pip install humanize
# ! pip install jupyter_contrib_nbextensions
# ! jupyter contrib nbextension install --user
# ! jupyter nbextension enable codefolding/main
# ! jupyter nbextension enable hinterland/hinterland
import psutil
View scikit_kickstarter_binary.py
from sklearn import metrics
from sklearn import preprocessing
from sklearn.preprocessing import normalize
from sklearn.metrics import confusion_matrix
from sklearn.model_selection import train_test_split
from sklearn.model_selection import StratifiedKFold
from imblearn.over_sampling import SMOTE
from sklearn.svm import SVC
View pandas_hacks.py
import pdb; #pdb.set_trace()
import pandas as pd
from IPython.display import display
# 1. Kick Off
df = pd.read_csv('myfile.csv')
print (df.head())
print (df.head(n=10))
print (df.columns)
col_Y = ''
@prerakmody
prerakmody / bar.m
Last active Jun 4, 2019
MATLAB Hacks
View bar.m
\newcommand*\xbar[1]{%
\hbox{%
\vbox{%
\hrule height 0.5pt % The actual bar
\kern0.5ex% % Distance between bar and symbol
\hbox{%
\kern-0.1em% % Shortening on the left side
\ensuremath{#1}%
\kern-0.1em% % Shortening on the right side
}%
@prerakmody
prerakmody / install.md
Last active Jun 9, 2019
Jupyter Notebook Hacks
View install.md

Fresh Install

  • pip install jupyter

Check Installations

  • pip freeze | grep jupyter
  • pip freeze | grep ipy
  • pip freeze | grep notebook

Notes

  • To upgrade any specific package : pip install --upgrade
View Pseduo - Code
\usepackage[]{algorithm2e}
\RestyleAlgo{boxruled}
\LinesNumbered
\begin{algorithm}[H]
\caption{Lawler's pseudo-polynomial algorithm}
\SetAlgoLined
\KwData{S(i,j,k) with S sorted by due-date}
\KwResult{integer representing the minimum tardiness of a schedule S}
You can’t perform that action at this time.