Skip to content

Instantly share code, notes, and snippets.

Avatar

Robert Knight robertknight

View GitHub Profile
@robertknight
robertknight / using-nvda-in-a-windows-vm-on-mac.md
Created Jul 3, 2017
Testing the Windows screenreader NVDA on a Mac
View using-nvda-in-a-windows-vm-on-mac.md

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 / Build.md
Last active Jul 8, 2022
Minimal Webpack DllPlugin example
View Build.md

Compile with:

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

Use with the following index.html

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

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 https://hypothes.is/embed.js to http://localhost:5000
@robertknight
robertknight / orientation-test.html
Created Jun 4, 2022
ImageBitmap orientation test
View orientation-test.html
<html>
<title>Canvas drawImage EXIF orientation test</title>
<style>
#dropZone {
width: 300px;
height: 100px;
background-color: #aaa;
border: 1px solid #ccc;
}
@robertknight
robertknight / info.md
Last active Mar 4, 2022
Promises + IndexedDB Test
View info.md

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
robertknight / istanbul.md
Last active Jan 17, 2022
How Istanbul works
View istanbul.md

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
robertknight / license-report.md
Created Jan 7, 2022
License report for Hypothesis project dependencies
View license-report.md
@robertknight
robertknight / wrap.html
Created Oct 11, 2016
Using min-width and overflow-wrap to wrap long words in flexbox layouts
View wrap.html
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<style>
.container {
display: flex;
flex-direction: row;
max-width: 100%;
@robertknight
robertknight / private-memory-stats.py
Last active Jul 20, 2021
Estimate private memory usage of a list of processes
View private-memory-stats.py
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":