Skip to content

Instantly share code, notes, and snippets.


Robert Knight robertknight

View GitHub Profile
robertknight /
Created Jul 3, 2017
Testing the Windows screenreader NVDA on a Mac

How to test NVDA screen reader behaviour on a Mac:

  1. Download Microsoft Edge VM from
  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
  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 /
Last active Jul 8, 2022
Minimal Webpack DllPlugin example

Compile with:

webpack --config vendor.webpack.config.js
webpack --config app.webpack.config.js

Use with the following index.html

robertknight /
Created Jul 7, 2022
How Hypothesis interacts with canonical links (`<link rel=canonical>`)
robertknight /
Last active Jun 30, 2022
Testing VitalSource assignments with your local Hypothesis development environment

VitalSource assignments in the LMS are different than other assignment types because the document is being displayed in a reader maintained by a third-party (VitalSource) rather than Via. This third-party reader always tries to load the production version of Hypothesis, whereas when Via is used to deliver a document, your local instance of Via will use your local Hypothesis client. A workaround for this issue to enable local testing is to redirect the request for the client's boot script to point to your local client, and modify the local client to ignore parts of the Hypothesis configuration in the page where the client's boot script is loaded.

The approach documented here can also be used in other situations where you want to subtitute the production Hypothesis client with the local one, in a page or web application where we can't modify the script tag that loads the client.

  1. Configure your browser to redirect requests for the client's boot script at to http://localhost:5000
robertknight / orientation-test.html
Created Jun 4, 2022
ImageBitmap orientation test
View orientation-test.html
<title>Canvas drawImage EXIF orientation test</title>
#dropZone {
width: 300px;
height: 100px;
background-color: #aaa;
border: 1px solid #ccc;
robertknight /
Last active Mar 4, 2022
Promises + IndexedDB Test

This gist demonstrates a problem with IndexedDB & Promises in Firefox which makes using IndexedDB very unergonomic in some cases in Firefox.

The test below reads, updates & writes a counter value to an IndexedDB database 10 times in the same transaction and then prints the result. To make the code easier to read, it uses async + await, which requires converting the IndexedDB requests (IDBRequest objects) to promises with a simple helper.

In Chrome, multiple promise callbacks can be executed with auto-committing an IDB transaction, allowing read-modify-write steps to work. In Firefox however, the IDB transaction gets auto-committed before the promise callback is fired, which means that read-modify-write operations have to use callbacks rather than promises.

robertknight /
Last active Jan 17, 2022
How Istanbul works

Istanbul Notes

These are some notes I made while reviewing hypothesis/client#156 to understand how Istanbul works

Istanbul instruments code in order to generate code coverage metrics for tests by adding code to record lines, statements etc. that are executed.

It adds a global __coverage__ variable to the generated code which is a map from file path to coverage information. The code for each module is then augmented with:

robertknight /
Created Jan 7, 2022
License report for Hypothesis project dependencies
robertknight / wrap.html
Created Oct 11, 2016
Using min-width and overflow-wrap to wrap long words in flexbox layouts
View wrap.html
<meta charset="utf-8">
.container {
display: flex;
flex-direction: row;
max-width: 100%;
robertknight /
Last active Jul 20, 2021
Estimate private memory usage of a list of processes
import os
import sys
def process_private_memory(pid):
smaps_path = f"/proc/{pid}/smaps"
total = 0
for line in open(smaps_path, 'r'):
field, val = [val.strip() for val in line.split(':')]
if field != "Private_Dirty":