Instantly share code, notes, and snippets.

View rate_limit_test.py
#!/usr/bin/env python3
from binascii import hexlify
import time
from random import randint
import requests
regular_url = "http://localhost:5000/_status"
View README.md

This is a browser bookmarklet which hides annoying overlays on web pages that are positioned at fixed locations on the page and don't move as you scroll. This is particularly useful for smaller desktop screens (I have a 13" MacBook Pro). Examples include:

  • Cookie banners
  • Banners at the top and bottom of the page on Medium-powered blogs telling you to sign in
  • Navigation bars on web pages that don't scroll out of the way when you scroll down

Usage

  1. Create a new bookmark
  2. Copy the content of toggle-fixed-element.js
View schema.py
class ColanderSearchParamsSchema(colander.Schema):
# Fields that affect search result number and ordering.
sort = colander.SchemaNode(colander.String(),
validator=colander.OneOf(["updated", "created", "id", "group", "user"]),
missing="updated")
order = colander.SchemaNode(colander.String(),
validator=colander.OneOf(["asc", "desc"]),
missing="desc")
View using-dev-client-with-secure-websites.md
View check-index-status.go
package main
import (
"bufio"
"bytes"
"encoding/base64"
"encoding/hex"
"encoding/json"
"fmt"
"net/http"
View elife-notes-2017-09-05.md

eLife tech discussion

Present

  • chdorner
  • dthompson
  • robertknight

Agenda

View copy-button.diff
diff --git a/src/sidebar/components/share-dialog.js b/src/sidebar/components/share-dialog.js
index 652d1b8d..534597e4 100644
--- a/src/sidebar/components/share-dialog.js
+++ b/src/sidebar/components/share-dialog.js
@@ -2,6 +2,21 @@
var VIA_PREFIX = 'https://via.hypothes.is/';
+function copyToClipboard(text) {
+ // Temporarily add a hidden input element and populate it with the text we
View config.json
{
"showHighlights": "whenSidebarOpen",
"branding": {
"accentColor": "#0288D1",
"appBackgroundColor": "white",
"ctaBackgroundColor": "#0288D1",
"ctaTextColor": "white",
"selectionFontFamily": "Georgia, Times, serif",
"annotationFontFamily": "Georgia, Times, serif"
},
View info.md

This gist demonstrates a problem with IndexedDB & Promises in Firefox which makes using IndexedDB very unergonomic in some cases in Firefox.

The test below reads, updates & writes a counter value to an IndexedDB database 10 times in the same transaction and then prints the result. To make the code easier to read, it uses async + await, which requires converting the IndexedDB requests (IDBRequest objects) to promises with a simple helper.

In Chrome, multiple promise callbacks can be executed with auto-committing an IDB transaction, allowing read-modify-write steps to work. In Firefox however, the IDB transaction gets auto-committed before the promise callback is fired, which means that read-modify-write operations have to use callbacks rather than promises.