Skip to content

Instantly share code, notes, and snippets.

View mnot's full-sized avatar

Mark Nottingham mnot

View GitHub Profile
from collections import defaultdict
from datetime import datetime
import csv
import sys
__doc__ = """
This is a script that uses CSV input data (for example, collected by a Google Form) to find the acceptable times for a meeting.
The CSV columns are:
from typing import Tuple
def decode_integer(data: bytes) -> Tuple[int, int]:
v = data[0]
prefix = v >> 6
length = 1 << prefix
v = v & 0x3F
for i in range(1, length):
v = (v << 8) + data[i]
#!/usr/bin/env python3
""" Use the W3C API to understand what document licenses are in use."""
import re
import sys
import time
from urllib.parse import urlparse, urlunparse, urljoin
from bs4 import BeautifulSoup, SoupStrainer
@mnot
mnot / crossref-lookup.applescript
Last active April 30, 2023 20:29
Look up PDFs on crossref.org in DevonThink
-- Look up document metadata on CrossRef.org in DevonThink 3
--
-- Currently sets:
-- * Created date to the document's publication date
-- * Title in document properties
-- * Author in document properties (first author only)
-- * Crossref DOI URL in document properties
-- * A tag for the type of document
-- * Finder comments to a formatted citation (see below)
@mnot
mnot / structured-fields.blab
Created July 9, 2020 11:08
structured fields blab
sf {
sf-string = DQUOTE chr* DQUOTE
sf-list = list-member ( OWS "," OWS list-member )*
list-member = sf-item
| inner-list
inner-list = "(" SP* ( sf-item ( SP+ sf-item )* SP* )? ")" parameters
@mnot
mnot / http.rrtext
Last active November 11, 2019 03:22
Railroad diagrams of HTTP semantics
# Generated from the ABNF at <https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html#collected.abnf>
# using <https://github.com/katef/kgt>
Accept:
,---------------------------------------------------------------------------------------------------------------------------.
| |
||--^--v----------------- "," ------------------>--v------------------------------------------------------------------------->-->--||
| | | |
| ,-------------------. | | ,-----------------------------------------------. |
| | | | | | | |
@mnot
mnot / example.py
Created March 22, 2017 04:30
This dies in a fire on 3.5.2, works on 3.6.
#!/usr/bin/env python
from typing import Optional, Type
class Foo(object):
pass
class Bar(Foo):
pass
@mnot
mnot / req_hdrs.md
Last active July 7, 2019 11:23
Interesting request headers
  • X-FCCKV2 - Fortinet antivirus
  • Via - various (includ McAffee Web Gateway)
  • X-Bluecoat-Via
  • X-Cool-Jobs-Contact - meraki
  • X-OSSProxy - marketscore spyware
  • X-Forwarded-For

In response to the Call for Proposals to HTTP/2, PHK published a draft with a number of suggested requirements.

This is a summary of those requirements, indicating those that have been met.

  • 3.3 Avoid header field encodings/transformations in intermediaries
  • 3.3 and 9 Envelope / content header field distinction
  • 3.3 Add session as "flow-label"
  • 3.3 Use prefix coding for length
  • 3.3 Indicate presence of body clearly
  • 4 Support legitimate cryptography
#!/usr/bin/python
from __future__ import division
from bitarray import bitarray
from hashlib import sha256
from math import log
import struct
def gcs_hash(w, (N,P)):