Skip to content

Instantly share code, notes, and snippets.

View shubhamagarwal92's full-sized avatar
☃️
Focusing

Shubham Agarwal shubhamagarwal92

☃️
Focusing
View GitHub Profile
@shubhamagarwal92
shubhamagarwal92 / git_submodules.sh
Last active April 5, 2021 08:36
Adding and removing git submodules
## Adding submodules
git submodule add https://github.com/path/to/the_submodule
git submodule init
git submodule update
## Removing submodules
# https://stackoverflow.com/a/21211232/3776827
git rm the_submodule
rm -rf .git/modules/the_submodule
@shubhamagarwal92
shubhamagarwal92 / install_torch7_cuda10.sh
Created March 7, 2019 15:55
Installing torch7 on cuda 10 and ubuntu 18
# Installing torch 7 can be a nightmare on cuda 10. Luckily @nagadomi simplified it.
# https://github.com/nagadomi/waifu2x/issues/253#issuecomment-445448928
git clone https://github.com/nagadomi/distro.git ~/torch --recursive
cd ~/torch
./clean.sh
./update.sh
# Installing cudnn
git clone https://github.com/soumith/cudnn.torch.git -b R7
cd cudnn.torch
@shubhamagarwal92
shubhamagarwal92 / sshfs.sh
Last active March 7, 2019 16:48
Mount remote sshfs with tunneling
# Install sshfs on local machine
# https://superuser.com/q/139023
# First make a tunnel (MYPORT==2222)
ssh -f userA@machineB -L MYPORT:machineA:22 -N
# First create mylocalpath folder on local machine
mkdir -p mylocalpath
# And then mount the remote file system
@shubhamagarwal92
shubhamagarwal92 / get_parent_dir.sh
Created March 10, 2019 22:34
Go the parent directory of the current bash file
export CURRENT_DIR=${PWD}
export PARENT_DIR="$(dirname "$CURRENT_DIR")"
echo "You are in: "
echo $CURRENT_DIR
echo "Parent directory is: "
echo $PARENT_DIR
@shubhamagarwal92
shubhamagarwal92 / check_os.sh
Created March 21, 2019 18:32
OS related bash commands
# Check the version of OS
lsb_release -a
# https://www.cyberciti.biz/faq/how-do-i-find-out-what-ports-are-listeningopen-on-my-linuxfreebsd-server/
# Check the open ports
netstat -vtan
@shubhamagarwal92
shubhamagarwal92 / create_dot_notations_for_dic.py
Created March 25, 2019 14:52
Create dot notation access to dictionary attributes
# Shamelessly taken from https://github.com/huggingface/pytorch-openai-transformer-lm/blob/master/model_pytorch.py
class dotdict(dict):
"""dot.notation access to dictionary attributes"""
__getattr__ = dict.get
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__
config = dotdict({
@shubhamagarwal92
shubhamagarwal92 / download_drive_file.sh
Created April 9, 2019 22:52
Get file from google drive using terminal
# https://stackoverflow.com/a/52076633/3776827
# Run as download_drive_file.sh file_id
# where file_id is google drive file id
# https://drive.google.com/file/d/0B-u9nH58139bTy1XRFdqaVEzUGs/view
# Eg. file_id here is 0B-u9nH58139bTy1XRFdqaVEzUGs
curl gdrive.sh | bash -s $1
@shubhamagarwal92
shubhamagarwal92 / Pycharm.txt
Last active January 29, 2020 15:27
Pycharm important basic (Mac OS)
1. To see the method declaration => cmd + Click / cmd + alt + right
2. To go back after 1. => cmd + alt + left
3. To change these settings => Pycharm -> Preferences -> Keymap -> Main menu -> Navigate -> Back/Forward
4. To change the Python Interpreter => Pycharm -> Preferences -> Project:XYZ -> Project Interpreter
# https://www.jetbrains.com/help/pycharm/reformat-and-rearrange-code.html
5. Formatting indentation => select code and opt+command+L
@shubhamagarwal92
shubhamagarwal92 / get_storage.sh
Created June 5, 2019 22:58
Get the storage of the current folder and the mount system
# Usage of the current folder
du -sh
# Get the storage used by each sub-directory in the folder
du -h
# Get filesystem, size, used avail and mounted info
df -h
@shubhamagarwal92
shubhamagarwal92 / mojave_jsonnet.sh
Created June 13, 2019 19:04
Jsonnet (Allennlp) installation issue with Mojave
# See https://github.com/recognai/biome-text/issues/14
xcode-select --install
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg