Skip to content

Instantly share code, notes, and snippets.

import argparse
import io
import re
import sys
from pathlib import Path
import random
import subprocess
import shutil
import tempfile
willprice /
Created July 6, 2021 10:11
A simple webserver for serving videos from a directory of dumped frames
A simple webserver for serving videos dumped as frames as real videos.
Point it towards a file hierarchy that looks like so:
| root
| |- video_1
| | |- frame_0001.jpg
| | |- frame_0002.jpg
| | |- frame_0003.jpg
Video frames are read in 'natural order' by the `natsort` library.
$ conda create -n rapids-0.18 -c rapidsai -c nvidia -c conda-forge -c defaults rapids=0.18 python=3.8 cudatoolkit=11.0
Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json)
willprice / gist:cb9452b1b2a32eae7fb20daa5bd09958
Created March 2, 2021 10:49
TP-LINK Archer WiFi adapters on linux
USB ID 2357:0120 ->
USB ID 2357:0138 -> (follow the manual DKMS setup guide)
willprice /
Created February 28, 2021 09:52
Pillow-SIMD with libjpeg/turbo
# The following steps are based on

$ conda install -y -c conda-forge gxx_linux-64 
$ conda uninstall -y --force jpeg libtiff
$ conda install -y -c conda-forge libjpeg-turbo --no-deps
$ pip uninstall -y pillow
$ export CXX=x86_64-conda-linux-gnu-g++
$ export CC=x86_64-conda-linux-gnu-gcc
willprice /
Created February 17, 2021 17:39
A little helper for finetuning networks
from torch import nn
import torch
from typing import List
def filter_parameters_for_finetuning(module: nn.Module) -> List[torch.Tensor]:
module: A :py:class:`nn.Module` object where some of the children may have
willprice /
Created February 12, 2021 11:44
GNU parallel cheat sheet
find . -type '*.pkl' | parallel python "{}" --write-to-csv "{.}.csv"
# Expands to
# > python my_pickle.pkl --write-to-csv my_pickle.csv
# To launch the jobs run
# python
prog = """
import sys
import os
print(sys.argv[1], os.environ['CUDA_VISIBLE_DEVICES'])
if (sys.argv[1] == '2'):
willprice / sampling_n_positive_integers_summing_to_m.ipynb
Created December 17, 2020 17:15
How to sample N positive integers whose sum equals M
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.