Skip to content

Instantly share code, notes, and snippets.

View Erotemic's full-sized avatar
An eroteme is a question mark

Jon Crall Erotemic

An eroteme is a question mark
View GitHub Profile
@Erotemic
Erotemic / dvc_clean_poc.py
Created August 15, 2022 18:37
DVC Clean POC
def dvc_clean():
import ubelt as ub
import yaml
dvc_root = ub.Path('.').resolve()
subdir = dvc_root / 'MySubdirectory'
ub.Path(ub.cmd('dvc cache dir', cwd=dvc_root, check=True)['out'].strip())
def list_subdir_dvc_fpaths(subdir):
dvc_fpaths = []
prog = ub.ProgIter(desc='walking')
# import pycodestyle
import ubelt as ub
VERBOSE = 3
def exec_flake8(dpaths, select=None, ignore=None, max_line_length=79):
if VERBOSE > 1:
print('ignore = {!r}'.format(ignore))
args_list = ['--max-line-length', f'{max_line_length:d}']
@Erotemic
Erotemic / a_natural_number.txt
Last active January 14, 2022 19:19
A natural number
6190010320010213417794501427120152665560619838379962172624809259242413133662471762706831535160803392841378532145762285099722187617972879813538517518233083306753347260548612898631147332011693627724889751066418150260498985083827355788699194931492232877245108779894625292904047223527216984663982750718623034958051309209333582174176577416459542020450843576169829816732864243397351533895411990483910832697254726363069230161517405040607673995815031529773327058337354301354062371647075206440061759885500802331823316853484399773382885418238331848120196431594456195805808432630836739945562939048610470071338082942418797034098249235121992937130708313446300865889713718389590277346247758021822613993586445131379268791654064089880558143900268099653583909158946828975519742188414010911014106643945712874253761637932854216545020272237775646331705506726197042829531280095737537148740518436741171103518386444450294779963654796639163475149693245937407808337856106834434695344937970746060176768499672131001455338379607532097417780722737895226
@Erotemic
Erotemic / kwcoco_vectorized_demo.py
Created December 15, 2021 16:36
kwcoco_vectorized_demo.py
def demo_vectorized_interface():
"""
This demonstrates how to use the kwcoco vectorized interface for images /
categories / annotations.
"""
import kwcoco
import ubelt as ub
# Dummy data for the demo
coco_dset = kwcoco.CocoDataset.demo('vidshapes3', num_frames=5)
# Reroot to make file-paths more readable in this demo as relative paths
@Erotemic
Erotemic / normalize_quotes.py
Created September 8, 2021 03:06
Normalize quote
import redbaron
import ubelt as ub
import re
import xdev
# INPUT:
# fpath = <path-to-the-file>
text = open(fpath).read()
@Erotemic
Erotemic / benchmark_first_generator.py
Last active September 1, 2021 22:55
benchmark_first_generator.py
"""
References:
https://github.com/willmcgugan/rich/blob/master/rich/_loop.py
https://twitter.com/graingert/status/1432827783357607937
"""
from typing import Iterable, Tuple, TypeVar
T = TypeVar("T")
@Erotemic
Erotemic / napkin_math_hospotializations_by_age_2021.py
Created July 30, 2021 01:59
Napkin Math Hospitalizations By Age
# https://gis.cdc.gov/grasp/covidnet/COVID19_5.html
# 2020-21
import ubelt as ub
US_POP_APPROX = 330e6
SAMPLE_SIZE = US_POP_APPROX * 0.1
print(SAMPLE_SIZE)
# NOTE: These are lab-verified COVID numbers. The sample size is 190509. This
# represents about 10% of the US population. This chart says total observed
@Erotemic
Erotemic / autogen_skimage_filters_init.py
Created December 24, 2020 19:39
Demo auto-generated version of skimage.filters
def lazy_install(module_name, submodules, submod_attrs):
"""
Defines gettr for lazy import via PEP 562
https://www.python.org/dev/peps/pep-0562/
"""
import sys
import importlib
import importlib.util
all_funcs = []
for mod, funcs in submod_attrs.items():
"""
Experiment Script Related to Pytorch Memory Leak Issue
References:
https://github.com/pytorch/pytorch/issues/13246
https://gist.github.com/mprostock/2850f3cd465155689052f0fa3a177a50
"""
from torch.utils.data import Dataset, DataLoader
import numpy as np
import torch
@Erotemic
Erotemic / gist:244890e27b37aa2219ac2f3414f8c302
Created February 9, 2019 17:44
cant find temp ninja error
(py36) joncrall@Ooo:~/code/netharn$ python setup.py build
--------------------------------------------------------------------------------
-- Trying "Ninja" generator
--------------------------------
---------------------------
----------------------
-----------------
------------