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 / cpkt_error_mwe.py
Created March 10, 2023 02:42
cpkt_error_mwe.py
import torch
import torch.nn
from torch import nn
from torch.utils.data import Dataset
import numpy as np
import pytorch_lightning as pl
from pytorch_lightning.cli import LightningCLI
from typing import List, Dict
@Erotemic
Erotemic / jsonargparse_scriptconfig_poc.py
Last active February 19, 2023 02:09
jsonargparse_scriptconfig_poc.py
import jsonargparse
import inspect
from jsonargparse.parameter_resolvers import ParamData
from jsonargparse.signatures import get_signature_parameters
from jsonargparse.signatures import get_doc_short_description
from typing import List, Set, Union, Optional, Tuple, Type, Any
from jsonargparse.util import get_import_path, iter_to_set_str
from argparse import SUPPRESS
from jsonargparse.typing import is_final_class
@Erotemic
Erotemic / transfer_assets.py
Created November 28, 2022 16:34
transfer_assets - POC non-copyrighted SM64 generated randomized assets.
"""
make VERSION=us -j16
build/us_pc/sm64.us
SeeAlso:
https://github.com/TechieAndroid/sm64redrawn
"""
import ubelt as ub
import aifc
import kwimage
@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