Skip to content

Instantly share code, notes, and snippets.

View robertknight's full-sized avatar

Robert Knight robertknight

View GitHub Profile
@robertknight
robertknight / putty-port-forwarding.png
Last active October 25, 2018 10:55
Testing and debugging Hypothesis on mobile devices and in virtual machines
putty-port-forwarding.png
@robertknight
robertknight / README.md
Last active September 18, 2018 06:46
Bookmarklet to toggle visibility of fixed overlays on screen

This is a browser bookmarklet which hides annoying overlays on web pages that are positioned at fixed locations on the page and don't move as you scroll. This is particularly useful for smaller desktop screens (I have a 13" MacBook Pro). Examples include:

  • Cookie banners
  • Banners at the top and bottom of the page on Medium-powered blogs telling you to sign in
  • Navigation bars on web pages that don't scroll out of the way when you scroll down

Usage

  1. Create a new bookmark
  2. Copy the content of toggle-fixed-element.js
@robertknight
robertknight / schema.py
Created August 27, 2018 15:08
Colander schemas for query string parsing
class ColanderSearchParamsSchema(colander.Schema):
# Fields that affect search result number and ordering.
sort = colander.SchemaNode(colander.String(),
validator=colander.OneOf(["updated", "created", "id", "group", "user"]),
missing="updated")
order = colander.SchemaNode(colander.String(),
validator=colander.OneOf(["asc", "desc"]),
missing="desc")
@robertknight
robertknight / using-dev-client-with-secure-websites.md
Last active March 5, 2018 13:56
Using the Hypothesis development client on secure websites
@robertknight
robertknight / check-index-status.go
Last active January 19, 2018 17:15
Script to check for presence of annotations in an h Elasticsearch index
package main
import (
"bufio"
"bytes"
"encoding/base64"
"encoding/hex"
"encoding/json"
"fmt"
"net/http"
@robertknight
robertknight / elife-notes-2017-09-05.md
Last active September 7, 2017 14:21
eLIFE tech discussion - 2017-09-05

eLife tech discussion

Present

  • chdorner
  • dthompson
  • robertknight

Agenda

@robertknight
robertknight / copy-button.diff
Created August 8, 2017 05:59
Add copy button to share dialog
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 August 4, 2017 06:50
eLife Hypothesis Config
{
"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 March 4, 2022 05:59
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
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.