Skip to content

Instantly share code, notes, and snippets.

@SuryaThiru
SuryaThiru / compiler.python.vim
Last active March 28, 2023 08:50
Simple compiler for vim to fill python traceback in the quickfix window. Copy the file to `.vim/compiler/python.vim`.
" https://vi.stackexchange.com/questions/5110/quickfix-support-for-python-tracebacks
if exists("current_compiler")
finish
endif
let current_compiler = "python"
let s:cpo_save = &cpo
set cpo&vim
@SuryaThiru
SuryaThiru / .tmux.conf
Created October 27, 2020 08:23
My tmux config for remote development
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"
# vim-like pane switching
bind -r k select-pane -U
bind -r j select-pane -D
bind -r h select-pane -L
bind -r l select-pane -R
# panes
set -g pane-border-style 'fg=colour19 bg=colour0'
@SuryaThiru
SuryaThiru / .vimrc
Last active October 23, 2020 07:17
My minimal vimrc for remote development
set nu
syntax on
set autoindent
colorscheme elflord
set background=dark
set tabstop=4
set shiftwidth=4
set smarttab
set expandtab
@SuryaThiru
SuryaThiru / pytorch utils.py
Last active February 11, 2019 15:45
My copy-paste functions for pytorch
def split_data(full_dataset, split_ratio=0.8):
"""
Take a single dataset and split into 2 datasets of given length
"""
train_size = int(split_ratio * len(full_dataset))
test_size = len(full_dataset) - train_size
train_dataset, test_dataset = torch.utils.data.random_split(full_dataset, [train_size, test_size])
return train_dataset, test_dataset
def save_checkpoint(state, checkpoint, is_best=False):
@SuryaThiru
SuryaThiru / interesting_plots.py
Last active March 9, 2023 04:42
Gist for functions that can plot beautiful and interesting plots stolen from people around the world
def build_legend(data):
"""
Build a legend for matplotlib plt from dict of key -> colors.
>> plt.legend(handles = build_legend(cmap))
"""
legend_elements = []
for key in data:
legend_elements.append(plt.Line2D([0], [0], marker='o', color='w', label=key,
markerfacecolor=data[key], markersize=10))