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 / pyenv.Dockerfile
Created October 31, 2022 15:28
pyenv.Dockerfile
# syntax=docker/dockerfile:1.3.0-labs
# This dockerfile uses new-ish buildkit syntax.
# Details on how to run are on the bottom of the file.
# (docker devs: todo unconsequential heredocs)
FROM nvidia/cuda:11.4.3-cudnn8-devel-ubuntu20.04
ARG PYTHON_VERSION=3.10.5
ARG PYENV_VERSION=v2.3.3
@Erotemic
Erotemic / install_python_pyenv.rst
Created October 31, 2022 15:26
install_python_pyenv.rst

An fully FOSS alternative to a conda environment is pyenv. The only real drawback to pyenv is that you must be able to compile Python itself.

On ubuntu this can be setup as follows:

### Based on code in https://github.com/Erotemic/local/blob/main/tools/pyenv_ext/pyenv_ext_commands.sh
@Erotemic
Erotemic / ijson_ext.py
Created October 28, 2022 15:10
ijson_ext.py
"""
Add NaN parsing to normal ijson pure-python parsing backend.
Example:
>>> import ijson_ext as ijson
>>> text = ub.codeblock(
>>> '''
>>> {"id": 246, "image_id": 123, "flag": true, "empty": null, "category_id": 2, "bbox": [ NaN, 5, 130, 290 ] }
>>> ''')
>>> import io
@Erotemic
Erotemic / gitlab-ci-example.yml
Last active September 16, 2022 19:15
gitlab-ci-example.yml
# Abuse YAML notation to make a heredoc. This will be ignored by the CI.
stages:
- build
- test
- gpgsign
- deploy
### TEMPLATES ###
@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")