Skip to content

Instantly share code, notes, and snippets.

View robertknight's full-sized avatar

Robert Knight robertknight

View GitHub Profile
@robertknight
robertknight / session.md
Created January 20, 2026 08:25
ocrs clipboard flag addition

Session Prompts

  1. Review the code for the ocrs-cli crate which is a CLI tool for OCR. Then make a plan to implement a new feature which will allow processing images taken from the system clipboard. The feature should be behind a clipboard Cargo feature which is disabled by default. To read from the clipboard, the arboard crate (https://docs.rs/arboard/latest/arboard/) should be used.

  2. `Implement the following plan:

Plan: Clipboard Support for ocrs-cli

Overview

@robertknight
robertknight / export.py
Created September 30, 2025 14:26
Hypothesis annotations export script
#!/usr/bin/env python3
import argparse
import json
import os
import sys
import time
from datetime import datetime, timezone
from typing import List, Dict, Any, Optional
@robertknight
robertknight / hypothesis-notes.md
Created July 17, 2025 11:29
Hypothesis general development notes

General development notes

This document contains general instructions for agents making changes in Hypothesis projects.

Frontend

Our frontend tech stack uses TypeScript, Preact and Tailwind CSS.

  • After editing code, run yarn format
  • To check for errors, run yarn typecheck and yarn lint
@robertknight
robertknight / using-nvda-in-a-windows-vm-on-mac.md
Created July 3, 2017 13:23
Testing the Windows screenreader NVDA on a Mac

How to test NVDA screen reader behaviour on a Mac:

  1. Download Microsoft Edge VM from https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/
  2. Download Virtualbox and import the Edge VM image.

Then in the VM:

  1. Install guest addons in the VM
  2. Download & install latest NVDA from nvaccess.org
  3. Download & install SharpKeys and use it to map left an alternative key (eg. Left Ctrl) to the Insert key. This is needed because Macs do not typically have an “Insert” key which is the prefix for many NVDA commands.
@robertknight
robertknight / preact-default-value.html
Created February 12, 2025 13:31
Preact in vanilla HTML
<html>
<body>
<div id="app"></div>
<script type="importmap">
{
"imports": {
"preact": "https://unpkg.com/preact@10.25.4/dist/preact.module.js",
"preact/hooks": "https://unpkg.com/preact@10.25.4/hooks/dist/hooks.module.js"
}
}
@robertknight
robertknight / hypothesis-export.py
Created October 28, 2024 13:09
Minimalist Hypothesis export script
import getpass
import json
import re
import sys
import requests
GROUP_URL_PATTERN = "https://hypothes.is/groups/([^/]+)/.*"
api_token = getpass.getpass(
@robertknight
robertknight / find_pyramid_routes.py
Created October 8, 2024 08:52
Pyramid route-finding script
# Analysis of Hypothesis Python app routes as part of
# https://github.com/hypothesis/playbook/issues/1797#issuecomment-2397242000.
import os
import ast
import sys
def find_py_files(root_dir):
excluded_dirs = ["node_modules", "build", "test", "tests", "third_party"]
@robertknight
robertknight / youtube_captions_api_test.py
Last active August 1, 2024 12:11
YouTube captions API test
# Script to fetch and print the transcript for a YouTube video using the
# YouTube Data API v3.
#
# 1. Create a project in the Google API Console
# 2. Enable the YouTube Data API v3 for the new project
# 3. Create credentials for a "Desktop" OAuth client. Download the JSON file
# containing the credentials at the end of the setup process.
# 4. Create a new virtualenv and install dependencies with:
#
# ```
@robertknight
robertknight / accelerate_gemv.cpp
Created March 14, 2024 08:58
Apple Accelerate sgemv benchmark
#include <algorithm>
#include <chrono>
#include <iostream>
#include <iterator>
#include <random>
#include <vector>
#include <Accelerate/Accelerate.h>
#include <cblas.h>
@robertknight
robertknight / rectify.py
Last active March 2, 2024 09:48
Rectify a portion of an image using OpenCV
import cv2
import numpy as np
import argparse
def warp_quadrilateral(
input_path: str,
src_points: list[tuple[int, int]],
output_path: str,
output_size: tuple[int, int],