Skip to content

Instantly share code, notes, and snippets.

Robert Knight robertknight

Block or report user

Report or block robertknight

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@robertknight
robertknight / elife-notes-2017-09-05.md
Last active Sep 7, 2017
eLIFE tech discussion - 2017-09-05
View elife-notes-2017-09-05.md

eLife tech discussion

Present

  • chdorner
  • dthompson
  • robertknight

Agenda

@robertknight
robertknight / copy-button.diff
Created Aug 8, 2017
Add copy button to share dialog
View copy-button.diff
diff --git a/src/sidebar/components/share-dialog.js b/src/sidebar/components/share-dialog.js
index 652d1b8d..534597e4 100644
--- a/src/sidebar/components/share-dialog.js
+++ b/src/sidebar/components/share-dialog.js
@@ -2,6 +2,21 @@
var VIA_PREFIX = 'https://via.hypothes.is/';
+function copyToClipboard(text) {
+ // Temporarily add a hidden input element and populate it with the text we
@robertknight
robertknight / config.json
Created Aug 4, 2017
eLife Hypothesis Config
View config.json
{
"showHighlights": "whenSidebarOpen",
"branding": {
"accentColor": "#0288D1",
"appBackgroundColor": "white",
"ctaBackgroundColor": "#0288D1",
"ctaTextColor": "white",
"selectionFontFamily": "Georgia, Times, serif",
"annotationFontFamily": "Georgia, Times, serif"
},
@robertknight
robertknight / info.md
Last active Mar 23, 2019
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 / 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 / uuids-to-hexids.py
Created Jun 16, 2017
Convert UUIDs from the annotations table in Hypothesis' database to annotation IDs as seen in the API
View uuids-to-hexids.py
#!/usr/bin/env python
import argparse
import base64
import binascii
import sys
import uuid
ES_FLAKE_MAGIC_BYTE = ['e', '5']
@robertknight
robertknight / gist:854a07bff300214a75fd49144ede7501
Created Jun 13, 2017
Intermittent failure fetching ReadTheDocs URL
View gist:854a07bff300214a75fd49144ede7501
(h) ~/h/r/h > curl -I 'https://h.readthedocs.io/en/latest/api/'
HTTP/1.1 200 OK
Server: nginx/1.10.0 (Ubuntu)
Date: Tue, 13 Jun 2017 13:20:52 GMT
Content-Type: text/html
Content-Length: 326
Last-Modified: Mon, 05 Jun 2017 09:11:35 GMT
Connection: keep-alive
Vary: Accept-Encoding
ETag: "59352047-146"
@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 / warn-on-undefined-expressions.js
Created Mar 23, 2017
Intercepting undefined variable accesses in expressions in Angular 1.x templates
View warn-on-undefined-expressions.js
'use strict';
/* global Proxy */
// Set of expressions for which warnings have been emitted
var warnedExpressions = {};
/**
* Return a proxy which warns on accesses to undefined properties in
* expressions.
@robertknight
robertknight / visible-anns.diff
Last active Feb 28, 2017
Computing visible annotation tags and notifying host page
View visible-anns.diff
diff --git a/src/sidebar/frame-sync.js b/src/sidebar/frame-sync.js
index 8a80563..6a505d7 100644
--- a/src/sidebar/frame-sync.js
+++ b/src/sidebar/frame-sync.js
@@ -2,6 +2,7 @@
var events = require('./events');
var bridgeEvents = require('../shared/bridge-events');
+var memoize = require('./util/memoize');
var metadata = require('./annotation-metadata');
You can’t perform that action at this time.