Skip to content

Instantly share code, notes, and snippets.

View robertknight's full-sized avatar

Robert Knight robertknight

View GitHub Profile
@robertknight
robertknight / cr-icaart2011-latexml.xml
Last active August 29, 2015 14:22
Design of Automatically Adaptable Web Wrappers - TeX source, LaTeXML output
<?xml version="1.0" encoding="UTF-8"?>
<?latexml searchpaths="/home/robert/projects/seed/content-mine/latex-xml"?>
<?latexml class="article" options="a4paper,twoside"?>
<?latexml package="amssymb"?>
<?latexml package="amstext"?>
<?latexml package="amsmath"?>
<?latexml package="multicol"?>
<?latexml package="pslatex"?>
<?latexml package="apalike"?>
<?latexml package="fancyhdr"?>
@robertknight
robertknight / mendeley-api-with-async-await.js
Created July 8, 2015 11:46
Mendeley API demo with Babel async/await
require('babel/polyfill');
var commander = require('commander');
var fetch = require('isomorphic-fetch');
function extractNextLink(headers) {
var linkHeaders = headers.get('Link').split(',');
for (var i=0; i < linkHeaders.length; i++) {
var header = linkHeaders[i];
var parts = /<([^>]+)>; rel="([^"]+)"/;
This file has been truncated, but you can view the full file.
The key "target-densitydpi" is not supported.
Failed to load resource: the server responded with a status of 400 (Bad Live Resource)
Uncaught Error: invalid version specified
Skipping www.rollingstone.com not http:/
Skipping www.rollingstone.com not apis.google.com/se/0/wm/1
Failed to load resource: the server responded with a status of 401 (Unauthorized)
DOMException: Blocked a frame with origin "https://via.hypothes.is" from accessing a cross-origin frame.
at Error (native)
at init_iframe_wombat (https://via.hypothes.is/static/__pywb/wombat.js:1805:48)
at HTMLIFrameElement.getter [as contentWindow] (https://via.hypothes.is/static/__pywb/wombat.js:1351:13)
@robertknight
robertknight / disabled-button-click-propagation.html
Created September 29, 2015 21:01
Click events in children of disabled buttons can propagate through the button in Chrome but not Firefox
<label for="enable-check">Enable button</label>
<input id="enable-check" type="checkbox">
<div id="parent">
<button id="child" disabled><div>Click me</div></button>
</div>
<script>
var enableCheckbox = document.querySelector('#enable-check');
enableCheckbox.addEventListener('click', function() {
@robertknight
robertknight / pipe.ts
Created November 1, 2015 12:30
Cancelable callbacks for promises
/**
* A Pipe is a proxy for a function which supports cancelation.
* When a pipe is called, it will pass its arguments to the underlying
* function, unless it is canceled in which case it will become a no-op.
*
* Pipes are useful as a way to cancel promise callbacks by wrapping
* the fulfilment or rejection handler.
*
* eg.
* aPipe = pipe(arg => doSomethingWithArg(arg));
@robertknight
robertknight / elm-setup-notes.md
Created November 14, 2015 07:29
Elm setup notes

Elm Tutorial Notes

  1. Went to elm-lang hopepage, skimmed the initial instructions, went for the Install option so I could develop in my preferred editor (Atom).
  2. Not obvious where to go next after that, went to the Docs link at the top. Was expecting to find an 'Intro to Elm' guide. In lieu of that, picked the next most obvious thing which was walking through the Quick Start links.
@robertknight
robertknight / pywb.md
Last active July 8, 2018 22:31
PyWB live rewriting notes

pywb implementation notes

Server-side components

  • Static server-side rewriting implemented by classes in pywb/rewrite/*

    html_rewriter.py

    • Takes an HTML feed as input via feed() method, the handler_*() methods are called as the HTML
@robertknight
robertknight / wombat_options.ts
Created November 27, 2015 13:37
Wombat options interface
/** Options to specify which DOM operations
* are intercepted and overridden in order to rewrite
* URLs when dynamic content and location changes
* are made to the page.
*/
interface WombatOptions {
embedded?: boolean;
/**
* If true, disable rewriting of elements
@robertknight
robertknight / epubjs-selection-highlight-event-notes.md
Last active June 9, 2020 09:35
ePubJS customized embedding notes

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 / date-formatting.js
Last active December 21, 2015 12:02
Date formatting benchmark
var Benchmark = require('benchmark');
var moment = require('moment');
var formatOpts = {
year: 'numeric',
month: 'short',
day: '2-digit',
weekday: 'long',
hour: '2-digit',
minute: '2-digit',