Skip to content

Instantly share code, notes, and snippets.

@nickstenning
nickstenning / KEEPFILE
Last active June 28, 2016 08:46
Hypothesis client history extraction
.hound.yml
.jscsrc
.jshintignore
.jshintrc
^h/css/
^h/images/
^h/js/
^h/lib/
^h/sass/
^h/static/
function page(path, callback) {
if (window.location.pathname === path) {
document.addEventListener('DOMContentLoaded', callback, false);
}
}
@nickstenning
nickstenning / dynamic-document-and-annotations-properties.diff
Last active February 25, 2016 14:33
Dynamic document and annotations properties
diff --git a/h/api/models/annotation.py b/h/api/models/annotation.py
index 87d5b33..353e8f0 100644
--- a/h/api/models/annotation.py
+++ b/h/api/models/annotation.py
@@ -5,11 +5,12 @@ from __future__ import unicode_literals
from pyramid import security
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql as pg
+from sqlalchemy.ext.associationproxy import association_proxy
+from sqlalchemy.ext.hybrid import hybrid_property
from pyramid.authentication import SessionAuthenticationPolicy
from pyramid.interfaces import IAuthenticationPolicy
from zope.interface import implementer
...
@implementer(IAuthenticationPolicy)
class AuthenticationPolicy(object):
#!/usr/bin/env python2
import argparse
import elasticsearch
import json
def get_from_ids(host, port, index, type, ids):
es = elasticsearch.Elasticsearch([{'host': host, 'port': port}])
def lfsr17(key):
if len(key) != 17:
raise TypeError('need 17 bits of init state')
register = key
while True:
# x^17 ^ x^14 ^ 1
nextbit = int(register[0], 2) ^ int(register[3], 2) ^ 1
register = register[1:] + str(nextbit)
yield int(register[0], 2)
#!/usr/bin/env python2
import argparse
import elasticsearch
from elasticsearch import helpers
def migrate_annotations(host, port, index, group_hashid, group_pubid):
es = elasticsearch.Elasticsearch([{'host': host, 'port': port}])
diff --git a/h/static/styles/help-page.scss b/h/static/styles/help-page.scss
index 890548c..a6a9c6f 100644
--- a/h/static/styles/help-page.scss
+++ b/h/static/styles/help-page.scss
@@ -3,9 +3,10 @@
$base-font-size: 16px;
$base-line-height: 22px;
-@import 'reset';
-@import 'common';
from wsgiref.simple_server import demo_app
def make_app(global_config, **local_config):
return demo_app
from wsgiref.simple_server import demo_app
def make_app(global_config, **local_config):
return demo_app