Skip to content

Instantly share code, notes, and snippets.

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 Jun 16, 2020
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

View epubjs-selection-highlight-event-notes.md

epub.js is working on integrating Hypothesis into their reader. Although ePub content is HTML and therefore they can use Hypothesis' existing code for annotating web content, their reader is somewhat different than a typical web page and consequently the built-in method of scrolling to an annotation when the user selects it in the sidebar does not work.

epub.js' reader consists of viewer controls, with an <iframe> in the middle of the page, which displays the HTML for the current chapter. The <iframe> can be set to be the full height of the document.

The current integration works by embedding Hypothesis in the outer document, and also loading Hypothesis into the <iframe> but only loading Annotator.Guest in the <iframe> instead of the sidebar. The guest then connects to the sidebar in the host document.

@robertknight
robertknight / notes.md
Last active Apr 29, 2020
Selection change event notes
View notes.md

Notes on selection events in mobile browsers (April 2016)

Notes on events that are fired during text selection in current desktop and mobile browsers.

Testing steps:

  1. Serve test.html from local dev server and open on device
  2. Make an initial selection via long-press on the text, observing reported events
  3. Modify the selection using drag handles and observe reported events
@robertknight
robertknight / gist:4268111
Created Dec 12, 2012
Mendeley Desktop 1.7 command line options
View gist:4268111
Usage: ./Mendeley Desktop [options]
--account [email address] Changes the active Mendeley Web account to [email address]
--help Show this list.
--http Use http instead of https.
--identifiers-only Extract only identifiers (DOI/arXiv/PMID) during metadata extraction from PDFs
--ignore-ssl-errors Ignore SSL negotiation errors.
--log-to-stderr Output logging information to standard error.
--no-style Disable all custom styling.
--password [password or SHA-1 hash] Set the password to log in to Mendeley Web with.
@robertknight
robertknight / istanbul.md
Last active Mar 10, 2020
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 / shallowRender.js
Created Apr 1, 2017
Shallow rendering implementation for Preact
View shallowRender.js
import { options, render } from 'preact';
import { ATTR_KEY } from 'preact/src/constants';
/**
* Returns the input properties that were passed to an element when it was
* rendered.
*
* See `shallowRender` documentation for usage example.
*/
@robertknight
robertknight / hypothesis-client-wcag-a11y.md
Last active Feb 25, 2020
Hypothesis client remaining a11y work
View hypothesis-client-wcag-a11y.md

This is a brain-dump of remaining work to achieve a fully accessible [1] Hypothesis client.

[1] fully accessible means that you can use all the functionality with a keyboard (or keyboard-emulating input device) and screen reader (or other assistive tech) conveniently and that it meets (both in letter and spirit) all the WCAG criteria. That doesn't necessarily mean that everything is as fully optimized as it could be (eg. in terms of what keyboard shortcuts are available to speed up various workflows).

Development tasks:

  1. Make it possible to activate highlights with the keyboard
  2. Make it easier to execute Annotate / Highlight commands using the keyboard
@robertknight
robertknight / reviewing-dependency-updates.md
Last active Feb 3, 2020
How I review dependency updates
View reviewing-dependency-updates.md

How I review dependency updates

These are some notes on my process when I review dependency updates for both JavaScript and Python projects at Hypothesis.

Before you add a dependency

Before adding a dependency to a project, consider the impact on future maintenance. If what the dependency does for the project can be implemented with only a few lines of code, or can be implemented in an alternative way using dependencies the project already has, it may be a better choice to do that and avoid the dependency.

Dependency update process

@robertknight
robertknight / README.md
Last active Feb 3, 2020
Using Hypothesis in a JavaScript SPA with client-side routing
View README.md

This is a sample which demonstrates how to use Hypothesis <= v0.21.0 in a JavaScript Single Page Application which does client-side routing.

The current version of Hypothesis at the time of writing does not automatically update the loaded annotations when the page URL changes. This sample takes the heavy-handed approach of completely removing and reloading Hypothesis when the URL changes. In future we'll look to build this into Hypothesis automatically in a much more performant way.

Running the demo

  1. Download files from this gist and extract into a directory
  2. Run python -m SimpleHTTPServer 8000
You can’t perform that action at this time.