Skip to content

Instantly share code, notes, and snippets.

Jon Udell judell

Block or report user

Report or block judell

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
@judell
judell / internal_and_public_id
Created Aug 7, 2019
convert between hypothesis internal and public ids
View internal_and_public_id
import base64, uuid, binascii, traceback
ES_FLAKE_MAGIC_BYTE = ['e', '5']
def _must_b64_decode(data, expected_size=None):
result = base64.urlsafe_b64decode(data)
if expected_size is not None and len(result) != expected_size:
raise TypeError('incorrect data size')
return result
View addMembers.js
names = [
'user a',
'user b',
'user c',
]
for (let i = 0; i < names.length; i++) {
Array.from(document.querySelectorAll('button')).filter(b => b.innerText == 'Add member')[0].click()
}
@judell
judell / wsclient.js
Last active Dec 3, 2018
minimal hypothesis websocket client for js
View wsclient.js
function connect() {
return new Promise(resolve => {
var ws = new WebSocket('wss://hypothes.is/ws?access_token=...')
function waitSocket() {
if (ws.readyState == 1) {
clearInterval(interval)
resolve(ws)
}
}
var interval = setInterval(waitSocket, 1000)
@judell
judell / wsclient.py
Last active Jun 14, 2019
minimal hypothesis websocket client for python
View wsclient.py
import asyncio
import ssl
import uuid
import json
import certifi
import websockets
import traceback
def _ssl_context(verify=True):
ssl_context = ssl.create_default_context(cafile=certifi.where())
View Hypothesis System Overview.md

An overview of the Hypothesis system

The Hypothesis project delivers a set of components and capabilities that work together to enable a wide range of annotation-powered applications. Here we summarize the state of play in November 2018. The major components are:

  • An annotation viewer and editor that runs as an overlay in the browser ("the client").

  • An annotation service that stores, searches, and displays annotations, manages users and groups, and delivers the client into pages that actively embed it ("the service").

  • A Chrome extension that injects the client into web pages that don't embed it ("the extension").

View nav-by-highlight.js
delete hypothesisHighlights
hypothesisHighlights = Array.from(document.body.querySelectorAll('hypothesis-highlight'))
var hypothesisIndex = 0
document.body.addEventListener('keydown', function (e) {
let hl
if (e.key === 'ArrowDown' && hypothesisIndex < hypothesisHighlights.length) {
document.body.scrollIntoView(true)
@judell
judell / hypothesis shortcode
Created Jul 6, 2018
wordpress shortcode implementation for embedding hypothesis annotations
View hypothesis shortcode
add_action( "wp_enqueue_scripts", "hypothesis_annotation_enqueue_scripts_styles" );
function hypothesis_annotation_enqueue_scripts_styles() {
wp_enqueue_style("hlib.css", "https://jonudell.info/hlib/hlib.css");
wp_enqueue_script("hlib.bundle.js", "https://jonudell.info/hlib/hlib.bundle.js");
wp_enqueue_script("showdown.js", "https://jonudell.info/hlib/showdown.js");
}
function hypothesis_annotation($args) {
$id = $args["id"];
View gist:5ca5e2bae6b15dd19fc8b9103d592503
24633418, 10.1007/s11095-014-1350-2
22328479,
25352860, 10.3389/fgene.2014.00314
22252949, 10.1136/ebmh.2011.100485
27402678, 10.1093/database/baw104
25381999, 10.1002/ajhb.22653
25526083, 10.1371/journal.pone.0115069
12493661, 10.1136/bmj.325.7378.1449
19008233, 10.1074/jbc.m806974200
25072471, 10.1038/ncomms5510
View gist:40991252881f9c200fb0fec09ed20b53
10029393
10069051
10091204
10173177
10194578
10185143
10202165
10232298
10344553
10340298
View consistency check results
internal_id e8edb860-e681-11e7-b97e-1b1896a44024, public_id 6O24YOaBEee5fhsYlqRAJA, status 404
internal_id e4fd8780-e681-11e7-b2ab-5f7934f23511, public_id 5P2HgOaBEeeyq195NPI1EQ, status 404
internal_id 1507560a-e677-11e7-b2a8-1b131d939add, public_id FQdWCuZ3EeeyqBsTHZOa3Q, status 404
internal_id 54e74a1c-e674-11e7-a8a3-c374e93e85b6, public_id VOdKHOZ0Eeeoo8N06T6Ftg, status 200
internal_id 79eae3c6-4af9-11e7-a87d-63f43901af13, public_id eerjxkr5EeeofWP0OQGvEw, status 200
internal_id 03ca0616-4afb-11e7-82cb-a7677816217f, public_id A8oGFkr7EeeCy6dneBYhfw, status 200
internal_id 8865a09c-4afb-11e7-b73f-0b0af0ebc396, public_id iGWgnEr7Eee3PwsK8OvDlg, status 200
internal_id 6723f15e-4afb-11e7-86ed-3b958ff15fa1, public_id ZyPxXkr7EeeG7TuVj_FfoQ, status 200
internal_id 88bcae8e-4b8a-11e7-b75e-0363f9924889, public_id iLyujkuKEee3XgNj-ZJIiQ, status 200
internal_id 6263fe86-4b8a-11e7-90a5-0f82a3098967, public_id YmP-hkuKEeeQpQ-CowmJZw, status 200
You can’t perform that action at this time.