Skip to content

Instantly share code, notes, and snippets.

pmod prerakmody

View GitHub Profile
@prerakmody
prerakmody / remove_dir.py
Created Jun 23, 2020
Python and Unix Commands
View remove_dir.py
from pathlib import Path
def rm_tree(path):
for child in path.iterdir():
if child.is_file():
child.unlink()
else:
rm_tree(child)
path.rmdir()
View open3d.py
import numpy as np
import open3d as o3d
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(np.random.random(10,10,10))
o3d.io.write_point_cloud("mypcd.pcd", pcd)
pcd_new, _ = pcd.remove_statistical_outlier(nb_neighbors=5,std_ratio=2.0)
View opencv.py
import cv2
import tqdm
images_path = []
video_path = ''
frame = cv2.imread(str(images_path[0]))
height, width, layers = frame.shape
video = cv2.VideoWriter(str(video_path), cv2.VideoWriter_fourcc('X','V','I','D'), 3, (width,height))
@prerakmody
prerakmody / .gitignore
Last active Jun 23, 2020
Python Command Line Tool
View .gitignore
# Local
.idea
.vscode/
# Media
.mp4
.png
.db
# Python
@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
You can’t perform that action at this time.