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 / 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 / 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
## ls only directories
# https://unix.stackexchange.com/questions/1645/is-there-any-option-with-ls-command-that-i-see-only-the-directories
ls -ld -- */
@shubhamagarwal92
shubhamagarwal92 / .gitignore
Created June 14, 2019 20:39
Generic git ignore
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
.idea/
.DS_Store/
# C extensions
*.so
# Distribution / packaging
@shubhamagarwal92
shubhamagarwal92 / get_current_date.sh
Created July 10, 2019 18:45
Get current date as variable in shell script
today="$(date '+%Y-%m-%d')"
yesterday="$(date -d yesterday '+%Y-%m-%d')"
echo $today
echo $yesterday