Skip to content

Instantly share code, notes, and snippets.

@judell
judell / GeniusToWapo.py
Created November 14, 2017 17:29
genius to wapo import
# using https://github.com/judell/Hypothesis
def genius_test():
h = Hypothesis(username="judell",
token='6879-... a3df5',
group='Pk...EgL')
anno_id = '11978830'
genius_token = 'yOalMhaO8KhZBzqRgIe1gDvF0wGqRTF4uWHMxoxMlIrNWksSv0gJTpQM-kQR4MuU'
@judell
judell / consistency.py
Last active December 22, 2017 07:14
consistency check
import base64, uuid, binascii, traceback, requests
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
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
10029393
10069051
10091204
10173177
10194578
10185143
10202165
10232298
10344553
10340298
@judell
judell / gist:5ca5e2bae6b15dd19fc8b9103d592503
Created February 8, 2018 23:01
map of pubmed commons pmids to dois, by way of http://europepmc.org/downloads
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
@judell
judell / hypothesis shortcode
Created July 6, 2018 17:17
wordpress shortcode implementation for embedding hypothesis annotations
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"];
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)

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").

@judell
judell / README.md
Last active September 20, 2021 14:48
minimal hypothesis websocket client for python

This example shows how to listen on a websocket for updates to Hypothesis.

@judell
judell / wsclient.js
Last active November 7, 2021 17:07
minimal hypothesis websocket client for 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)