Skip to content

Instantly share code, notes, and snippets.

View robertknight's full-sized avatar

Robert Knight robertknight

View GitHub Profile
@robertknight
robertknight / uuids-to-hexids.py
Created June 16, 2017 15:40
Convert UUIDs from the annotations table in Hypothesis' database to annotation IDs as seen in the API
#!/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 June 13, 2017 13:23
Intermittent failure fetching ReadTheDocs URL
(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 April 1, 2017 09:15
Shallow rendering implementation for Preact
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 March 23, 2017 15:46
Intercepting undefined variable accesses in expressions in Angular 1.x templates
'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 February 28, 2017 19:09
Computing visible annotation tags and notifying host page
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');
@robertknight
robertknight / typo.ts
Created January 9, 2017 19:21
How TypeScript handles optional properties when checking for structural compatibility of types
type MyType = {
foo: string;
bar?: string;
}
function doStuffWithMyType(_: MyType) {}
function typoExample() {
doStuffWithMyType({
foo: 'herp',
@robertknight
robertknight / annotation-urls.txt
Created December 2, 2016 18:19
URLs found in 50K recent public annotations
This file has been truncated, but you can view the full file.
https://hypothes.is/groups/j3eoYn2b/curation-strategies
http://www.thetimes.co.uk/tto/public/cyclesafety/article3812452.ece
http://www.hhbr.co.uk/projects/regeneration/006.htm
http://bit.ly/2fZCClq
http://bit.ly/2fNO1Gq
http://www.wordreference.com/fren/ravissant
http://foreignpolicy.com/2016/11/23/ten-ways-to-tell-if-your-president-is-a-dictator/
https://www.youtube.com/watch?v=xwtdhWltSIg
http://www.mandolincafe.com/forum/attachment.php?attachmentid=120567&d=1402874523
http://www.songfacts.com/detail.php?id=1256
@robertknight
robertknight / form.html
Created November 25, 2016 13:26
Firefox form submittion workaround
<html>
<head><meta charset="UTF-8"></head>
<body>
<form>
<button type="submit">
Clicking this button should submit the form and reload the page
</button>
</form>
<script>
const form = document.querySelector('form');
@robertknight
robertknight / test-hypothesis-cors.html
Created November 11, 2016 10:59
Hypothesis CORS support test
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<script>
function createNote(uri, text) {
return fetch('http://localhost:5000/api/annotations', {
method: 'POST',
headers: {
@robertknight
robertknight / BannerArtComponent.ngfactory.js
Created November 4, 2016 12:48
The code.gov banner art component code
var styles_BannerArtComponent = ['html[_ngcontent-%COMP%] {\n box-sizing: border-box; }\n\n*[_ngcontent-%COMP%], *[_ngcontent-%COMP%]::after, *[_ngcontent-%COMP%]::before {\n box-sizing: inherit; }\n\n@-webkit-keyframes fadeInUp {\n from {\n -webkit-transform: translateY(0.5em);\n opacity: 0;\n visibility: hidden; }\n to {\n -webkit-transform: translateY(0);\n opacity: 1;\n visibility: visible; } }\n\n@-moz-keyframes fadeInUp {\n from {\n -moz-transform: translateY(0.5em);\n opacity: 0;\n visibility: hidden; }\n to {\n -moz-transform: translateY(0);\n opacity: 1;\n visibility: visible; } }\n\n@keyframes fadeInUp {\n from {\n -webkit-transform: translateY(0.5em);\n -moz-transform: translateY(0.5em);\n -ms-transform: translateY(0.5em);\n -o-transform: translateY(0.5em);\n transform: translateY(0.5em);\n opacity: 0;\n visibility: hidden; }\n to {\n -webkit-transform: translateY(0);\n -moz-transform: translateY(0);\n -ms-transform: translat