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 / rate_limit_test.py
Last active Nov 16, 2018
Rate limiting test script
View rate_limit_test.py
#!/usr/bin/env python3
from binascii import hexlify
import time
from random import randint
import requests
regular_url = "http://localhost:5000/_status"
@robertknight
robertknight / putty-port-forwarding.png
Last active Oct 25, 2018
Testing and debugging Hypothesis on mobile devices and in virtual machines
@robertknight
robertknight / README.md
Last active Sep 18, 2018
Bookmarklet to toggle visibility of fixed overlays on screen
View README.md

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 Aug 27, 2018
Colander schemas for query string parsing
View schema.py
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 Mar 5, 2018
Using the Hypothesis development client on secure websites
View using-dev-client-with-secure-websites.md
@robertknight
robertknight / check-index-status.go
Last active Jan 19, 2018
Script to check for presence of annotations in an h Elasticsearch index
View check-index-status.go
package main
import (
"bufio"
"bytes"
"encoding/base64"
"encoding/hex"
"encoding/json"
"fmt"
"net/http"
@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.

You can’t perform that action at this time.