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 / 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 / counter_dictionary.py
Last active March 3, 2020 14:55
maintain a counter of items using dic
from collections import defaultdict
# method 1
my_dict = defaultdict(int)
my_dict[key] += 1
# method 2
my_dict = {}
my_dict[key] = my_dict.get(key, 0) + 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 / 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 / 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
@shubhamagarwal92
shubhamagarwal92 / wget.sh
Created September 30, 2019 15:27
different wget flags
# Provide the path where to download
wget https://www.dropbox.com/s/twmtutniktom7tu/VisualDialog_val2018.zip?dl=0 -P ./data
# Provide the name of the file
wget https://www.dropbox.com/s/twmtutniktom7tu/VisualDialog_val2018.zip?dl=0 -O VisualDialog_val2018.zip
@shubhamagarwal92
shubhamagarwal92 / recursive_copy_except_ext_files.sh
Created September 20, 2019 19:34
To copy all files recursively in a folder except .ext files
# To copy all files recursively in a folder except .pth files
# Be careful no "/" in source_dir whle "/" in final_dir
rsync -avr --exclude=*.pth source_dir final_dir/
# For a file in just one folder
cp -r !(*.png) dest