Skip to content

Instantly share code, notes, and snippets.

View seanh's full-sized avatar

Sean Hammond seanh

View GitHub Profile
@seanh
seanh / how-the-client-is-configured.markdown
Last active September 22, 2019 19:05
How the Hypothesis client configures itself

How the client is configured

There are several different files in the client source code that read configuration (also sometimes called "options" or "settings") from different places.

An additional difficulty is that the client consists of two separate components:

  1. The code in src/annotator/ is JavaScript code that's injected directly
@seanh
seanh / README.markdown
Last active April 23, 2023 11:13
Embedding Hypothesis in a Single Page App

This is a very rough demonstration of how to embed Hypothesis in a single page app.

When you click on the "Go to page two" button it loads the second "page" of the app. This page is just loaded by JavaScript, without having the browser load a new page as it would normally do when following a link. Importantly the JavaScript code does change URL in the browser's location bar though, using history.pushState(). Before changing the URL it unloads Hypothesis from the page, and after changing the URL it reloads Hypothesis into the page. This is to work around a limitation with Hypothesis - it doesn't detect URL changes done by pushState() and reload the annotations.

tmux

Notes about [tmux][] from various sources, including:

  • [tmux: Productive Mouse-Free Development][]
  • [Practical Tmux][]
  • [Arabesque's tmux posts][]
  • [Tmux on the ArchWiki][]
@seanh
seanh / contentScript.js
Last active December 22, 2015 18:44
Chrome extension PDF detection with GET request from event page and using activeTab permission
/**
* Check if the request is a PDF file.
* @param {Object} details First argument of the webRequest.onHeadersReceived
* event. The properties "responseHeaders" and "url"
* are read.
* @return {boolean} True if the resource is a PDF file.
*/
function isPdfFile(response, url) {
var header = response.getResponseHeader('content-type');
if (header) {
@seanh
seanh / 2645a9c857af1402bf63.crx
Last active December 22, 2015 18:29
Chrome extension PDF detection with GET request from event page
@seanh
seanh / 27bdaa36aca3b6d6ffa9.crx
Last active December 22, 2015 18:19
Chrome extension PDF detection with GET request from content script
@seanh
seanh / 85c02c1a0f309abab988.crx
Last active December 22, 2015 18:18
Chrome extension PDF detection with webRequest
@seanh
seanh / README.markdown
Last active October 2, 2015 20:41
How to setup your local dev instance of h with a Dockerised PostgreSQL

One-time startup:

docker run -d --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=pass postgres
echo 'localhost:5432:postgres:postgres:pass' >> ~/.pgpass
chmod go-rwx ~/.pgpass
pip install psycopg2

After this you just have to run docker start postgres to start it (e.g. after rebooting your laptop).

The SQLAlchemy URL in conf/development.ini should be:

@seanh
seanh / grab.py
Last active September 22, 2015 11:04
Copy an annotatation from one Hypothesis instance to another
#!/usr/bin/env python2.7
import argparse
import json
import requests
def get_annotation(url, id_):
return requests.get(url + "/api/annotations/" + id_).json()
diff --git a/h/static/scripts/app.coffee b/h/static/scripts/app.coffee
index 62cccba..5c98e67 100644
--- a/h/static/scripts/app.coffee
+++ b/h/static/scripts/app.coffee
@@ -112,6 +112,7 @@ module.exports = angular.module('h', [
.directive('match', require('./directive/match'))
.directive('tabbable', require('./directive/tabbable'))
.directive('tabReveal', require('./directive/tab-reveal'))
+.directive('scrollToMe', require('./directive/scrolltome'))