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 / gdrive_download.sh
Created October 11, 2023 18:02
GDrive download
# Fixed https://github.com/alexandre01/deepsvg/blob/master/dataset/download.sh
#!/usr/bin/env bash
function gdrive_download () {
CONFIRM=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate "https://docs.google.com/uc?export=download&id=$1" -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')
wget --no-check-certificate --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$CONFIRM&id=$1" -O $2
rm -rf /tmp/cookies.txt
}
@shubhamagarwal92
shubhamagarwal92 / install_conda.sh
Last active December 27, 2022 14:57
Installing latest conda
# Following https://stackoverflow.com/questions/38080407/how-can-i-install-the-latest-anaconda-with-wget
latest=$(wget -qO- https://repo.anaconda.com/archive/ |
grep -Eo "(href=\")(Anaconda3-.*-Linux-x86_64.sh)*\"" |
sed 's/href=//g' | sed 's/\"//g' | head -n 1); wget "https://repo.anaconda.com/archive/$latest"
bash $latest -b
rm $latest
echo 'export PATH="~/anaconda3/bin:$PATH"' >> ~/.bashrc
@shubhamagarwal92
shubhamagarwal92 / combinePDF.sh
Last active May 13, 2020 19:32
combine pdfs
# https://cmdlinetips.com/2016/03/how-to-join-pdf-files-in-mac-on-terminal/
# On mac
/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py -o pages.pdf 1.pdf 2.pdf
# Another command
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combine.pdf -dBATCH 1.pdf 2.pdf
# sed 's/>>> //g ' combinePDF.py >> combinePDF.py
@shubhamagarwal92
shubhamagarwal92 / sample_PRs.md
Last active March 17, 2020 15:28
Apart from my private and public repos, some PRs in the other projects
@shubhamagarwal92
shubhamagarwal92 / ssh_config_pycharm.md
Last active August 14, 2020 08:25
ssh config for PyCharm

Pre-requisite: You should be able to do ssh without entering password. See this

Steps (Fig 1 and 2)

  1. Open project in PyCharm
  2. Make directory on server
  3. Test you can ssh without entering password. (Save your rsa key on server)
  4. Preferences -> Deployment
  5. Enable automatic upload https://www.jetbrains.com/help/pycharm/deployment-in-pycharm.html#upload-to-default-server
  6. First time upload your directory. Right click project folder -> deployment -> deploy to <machine_name>
  7. Add multiple directories if want to deploy on different servers.
@shubhamagarwal92
shubhamagarwal92 / install_git.md
Last active January 15, 2020 15:56 — forked from derhuerst/intro.md
Installing Git on Linux, Mac OS X and Windows
@shubhamagarwal92
shubhamagarwal92 / pip_no_cache.sh
Last active November 16, 2019 16:49
Ignore cache when installing package
pip install --no-cache-dir <pkg>
# Currently conda doesnt allow ignoring cache
# https://github.com/conda/conda/issues/7741
conda clean --all --force-pkgs-dirs
# https://stackoverflow.com/a/57994079/3776827
@shubhamagarwal92
shubhamagarwal92 / setup_new_machine.sh
Last active September 7, 2021 14:55
Setup new machine
# Check number of cpus
grep -c ^processor /proc/cpuinfo
sudo apt-get install tmux
sudo apt-get install htop
sudo apt install git
# Conda
sudo mkdir -p /scratch/shubham/packages
sudo chown -R shubham /scratch/shubham
@shubhamagarwal92
shubhamagarwal92 / pandas_excel.py
Last active November 14, 2019 17:18
Write multiple dataframes to excel spreadsheets
# Taken from https://datascience.stackexchange.com/a/46451
# https://stackoverflow.com/questions/57334052/how-to-fix-pandas-compat-has-no-attribute-string-types-error-in-python3
# https://github.com/pydata/pandas-datareader/issues/655
# pip install --upgrade pandas==0.24.2
# pip install xlswriter
import pandas as pd
@shubhamagarwal92
shubhamagarwal92 / pytorch_memory_leak.py
Last active November 14, 2019 16:55
Pytorch issue allocating memory on gpu0
# Thanks to https://github.com/andreavanzo for figuring this out
# device should be integer here and not torch.device
# do
torch.cuda.set_device(device)
# before
torch.cuda.empty_cache()
# Also do empty cache after every epoch