Skip to content

Instantly share code, notes, and snippets.

@willprice
willprice / convert_to_wbfs.sh
Created December 17, 2017 23:58
Convert iso/ciso to wbfs using wit
#!/usr/bin/env bash
find . -iregex '.*\.\(c\)?iso' -print0 |
while IFS= read -r -d $'\0' iso; do
id6="$(wit id6 "$iso")"
target_dir="${iso%.*} [$id6]"
target="${target_dir}/$id6.wbfs"
if [[ ! -f "$target" ]]; then
echo "Converting $iso to wbfs"
wit copy --wbfs "$iso" .
@willprice
willprice / cli.py
Created January 8, 2019 15:09
Python argparse logging verbosity
import argparse
import logging
parser = argparse.ArgumentParser(
description="Demo of setting logging verbosity using -vvvv style args",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument("-v", "--verbose", dest="verbosity", action="count", default=0,
help="Verbosity (between 1-4 occurrences with more leading to more "
"verbose logging). CRITICAL=0, ERROR=1, WARN=2, INFO=3, "
"DEBUG=4")
@willprice
willprice / csv_points_to_segments.py
Last active February 20, 2022 19:27
Convert CSV to SRT subtitles
import argparse
from pathlib import Path
import numpy as np
import pandas as pd
parser = argparse.ArgumentParser(
description="",
import argparse
import io
import re
import sys
from pathlib import Path
import random
import subprocess
import shutil
import tempfile
@willprice
willprice / frame_server.py
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.
@willprice
willprice / README-opencv-3.1-raspberry-pi-installation.md
Last active May 14, 2021 08:24
How to install OpenCV 3.1 on Raspbian Jessie (Lite)

Installing OpenCV 3.1 on Raspbian Jessie

Prerequisites

  • Keep your system up to date:
    • $ sudo apt-get update
    • $ sudo apt-get upgrade
    • $ sudo reboot
  • Make sure you've got an internet connection.
  • Make sure you've got
  • wget
@willprice
willprice / gist:1579856
Created January 8, 2012 21:57
Python Gmail Checker
#!/usr/bin/python2
# Author: Will Price
# Date: Jan 2011
# Import statements:
# - Feedparser - needed to extract mailcount
# - Serial - needed to send command to Arduino
# - Time - waiting for gmail to be read
import feedparser, serial, time
@willprice
willprice / PIL-image-cheatsheet.md
Created May 15, 2018 12:00
PIL Image cheat sheet

PIL Image cheat sheet

  • Image.open(path) -> Image
  • np.array(img) -> np.array
  • Image.fromarray(arr) -> Image
$ 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
willprice / create_env.sh
Last active March 2, 2021 09:10
Install jupyter kernels addons
conda create -n jupyter -c conda-forge -y \
python=3.8 \
pip \
nb_conda_kernels \
jupyterlab \
widgetsnbextension \
black \
isort \
nodejs
conda activate jupyter