Skip to content

Instantly share code, notes, and snippets.

View anujonthemove's full-sized avatar
Working

Anuj Khandelwal anujonthemove

Working
View GitHub Profile
@anujonthemove
anujonthemove / Python - Vectorization - Double For Loop.ipynb
Created March 21, 2022 02:22
Double For Loop Vectorization using Numpy
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@anujonthemove
anujonthemove / Python - Vectorization - Single For Loop.ipynb
Last active March 21, 2022 02:22
Single For Loop Vectorization using Numpy
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@anujonthemove
anujonthemove / run-commands-without-history.sh
Last active January 26, 2022 14:11
Use this function to avoid adding linux commands to history.
# https://stackoverflow.com/questions/10307280/how-to-define-a-shell-script-with-variable-number-of-arguments
run(){
my_cmd=$1;
# cmd_str='history -d $((HISTCMD)) && $my_cmd';
shift
#echo $my_cmd "$@"
history -d $((HISTCMD-1)) && $my_cmd "$@"
}
@anujonthemove
anujonthemove / rename-terminal-tab.sh
Created December 30, 2021 04:09
Rename terminal tab on Ubuntu 20.x
# directly taken from: https://unix.stackexchange.com/questions/177572/how-to-rename-terminal-tab-title-in-gnome-terminal
function set-title() {
if [[ -z "$ORIG" ]]; then
ORIG=$PS1
fi
TITLE="\[\e]2;$*\a\]"
PS1=${ORIG}${TITLE}
}
@anujonthemove
anujonthemove / install-latest-protobuf-ubuntu-18-04.md
Last active September 26, 2021 01:59
Google Protobuf installation on Ubuntu 18.04 LTS
sudo apt-get install autoconf automake libtool curl make g++ unzip -y
git clone https://github.com/google/protobuf.git
cd protobuf
git submodule update --init --recursive
./autogen.sh
./configure
make
make check
sudo make install
@anujonthemove
anujonthemove / .gitignore
Last active June 4, 2022 02:32
My .gitignore file
.ipynb_checkpoints
*/.ipynb_checkpoints/*
*.pyc
.vscode
*/.vscode/*
@anujonthemove
anujonthemove / uniform-random-learning-rate.py
Created July 25, 2021 09:05
Generate learning rate value from a uniform random distribution between a given range of values
import os
import numpy as np
def sample_learning_rate_value(low = 0.0001, high = 1):
log_low = np.log10(low)
log_high = np.log(high)
r = np.random.randint(log_low, log_high)*np.random.rand()
alpha = 10**r
return alpha
@anujonthemove
anujonthemove / save_and_read_pickle.py
Created July 23, 2021 09:55
Save and read objects to and from pickle file
def save_pickle(pkl_object, name):
with open(name, 'wb') as handle:
pickle.dump(pkl_object, handle, protocol=pickle.HIGHEST_PROTOCOL)
def read_pickle(pickle_file):
b = None
with open(pickle_file, 'rb') as handle:
b = pickle.load(handle)
return b
@anujonthemove
anujonthemove / get_classification_report.py
Last active June 8, 2021 11:12 — forked from fclesio/get_classification_report.py
Scikit Learn Classification Report in Dataframe
def get_classification_report(y_test, y_pred):
'''Source: https://stackoverflow.com/questions/39662398/scikit-learn-output-metrics-classification-report-into-csv-tab-delimited-format'''
from sklearn import metrics
report = metrics.classification_report(y_test, y_pred, output_dict=True)
df_classification_report = pd.DataFrame(report).transpose()
df_classification_report = df_classification_report.sort_values(by=['f1-score'], ascending=False)
return df_classification_report
@anujonthemove
anujonthemove / pet_label_map.csv
Created May 17, 2021 02:35
Pet lables in csv along with their object ids for TensorFlow 1.15 Object Detection API models.
'Abyssinian' 1
'american_bulldog' 2
'american_pit_bull_terrier' 3
'basset_hound' 4
'beagle' 5
'Bengal' 6
'Birman' 7
'Bombay' 8
'boxer' 9
'British_Shorthair' 10