Skip to content

Instantly share code, notes, and snippets.


Will Price willprice

View GitHub Profile
View gist:9ff820a4e622fab6bbe6ca47cf428187
$ 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 Mar 2, 2021
TP-LINK Archer WiFi adapters on linux
View gist:cb9452b1b2a32eae7fb20daa5bd09958
USB ID 2357:0120 ->
USB ID 2357:0138 -> (follow the manual DKMS setup guide)
willprice /
Created Feb 28, 2021
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 Feb 17, 2021
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 Feb 12, 2021
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
View gist:4dc8e0888e56106b643f211f034b6004
# 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 Dec 17, 2020
How to sample N positive integers whose sum equals M
View sampling_n_positive_integers_summing_to_m.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
willprice /
Created Dec 17, 2020
Rand index computation
# Heavily inspired by the answer by Tom in
def rand_score(labels_true, labels_pred):
labels_true: Array of shape :math:`(N)` denoting the class identities of each element.
labels_pred: Array of shape :math:`(N)` denoting the cluster identities of each element.
(Unadjusted) Rand index.
willprice /
Last active Oct 20, 2020
Convert video array to mp4 blob
from io import BytesIO
import av
import numpy as np
def video_array_to_mp4_blob(video: np.ndarray, fps: float = 24) -> bytes:
video: Video array of shape :math:`(T, H, W, 3)` and range :math:`[0, 255]` with type ``np.uint8``.