Skip to content

Instantly share code, notes, and snippets.

View jogardi's full-sized avatar

Joseph Gardi jogardi

  • Dasion
  • Claremont, California
View GitHub Profile
set visualbell
set noerrorbells
set surround
set hlsearch
nnoremap <silent> <Esc><Esc> <Esc>:nohlsearch<CR><Esc>
map <leader>r :register<ENTER>
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Auto install from https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'majutsushi/tagbar', { 'do': 'cp -R ./plugin ~/.vim/' }
Plug 'nathanaelkane/vim-indent-guides'
def f(x):
return x * np.sin(x)
xs = np.linspace(-1, 11, 2000)
ys = f(xs)
def train_dict_and_plot(num_train, quantize_scale):
train_x = xs[::len(xs)//num_train]
train_y = ys[::len(xs)//num_train]
db = {}
def quantize(x):
return int(x * quantize_scale)
@jogardi
jogardi / resources.py
Last active June 14, 2022 16:45
Example of managing resources and datasets for ML
import joblib, os, torch
from functools import cached_property
from google.cloud import storage
from google.oauth2 import service_account
import torchvision.transforms as transforms
def prep_dir(path: str) -> str:
if not os.path.exists(path):
os.mkdir(path)
import csv
import os.path
def save_scores(scores):
with open('scores.csv', 'w+') as f:
for score in scores:
f.write(str(score) +"\n")
def load_scores_from_file():