Skip to content

Instantly share code, notes, and snippets.

View mnot's full-sized avatar

Mark Nottingham mnot

View GitHub Profile
@mnot
mnot / double-cl.js
Created September 15, 2010 01:07
double-cl.js - test how clients deal with two Content-Length headers
// simple & dirty node.js server to test how a client deals with two Content-Length headers.
function handle(req, res) {
res.writeHead(200, {
'Content-Length': '15',
});
m = res._header.split("\r\n");
console.log(m);
res._header = [m[0], "Content-Length: 10", ""].join("\r\n") +
@mnot
mnot / rip.sh
Created September 20, 2010 06:57
rip.sh
#!/bin/sh
DVD_DIR=/misc/dvd
NAS_DIR=/misc/media
DO_LO=1
DO_HI=1
DO_LIST=0
TRACK_NO=0
REGION=0
usage() {
@mnot
mnot / gexport.py
Created October 1, 2010 12:48
gexport.py - Export Google Docs to a local directory
#!/usr/bin/env python
"""\
gexport.py
Export Google Docs to a local directory.
Requires the GData Python client library:
http://code.google.com/p/gdata-python-client/
"""
@mnot
mnot / wikipedia_links.py
Created February 25, 2011 00:30
Pull links out of a Wikipedia XML dump, real fast.
@mnot
mnot / kindle_my_rfc.sh
Created March 12, 2011 01:06
Quick and dirty way to get Internet-Drafts onto your kindle
#!/bin/sh
# Kindle My RFC (or Internet-Draft)
#
# Sends an Internet Draft to your kindle
# Invocation:
# > kindle_my_rfc [path/to/rfc2629-xml-file]
# > kindle_my_rfc [draft-name-with-number-00]
#
# Requires:
@mnot
mnot / sun buffering goes wild
Created August 11, 2011 02:32
The raw HTTP of a GET response from http://www.sun.com/ (before the Oracle acquisition), reproduced here in its entirety.
HTTP/1.1 200 OK
Server: Sun-Java-System-Web-Server/7.0
Date: Mon, 07 Dec 2009 07:25:34 GMT
P3p: policyref="http://www.sun.com/p3p/Sun_P3P_Policy.xml", CP="CAO DSP COR CUR ADMa DEVa TAIa PSAa PSDa CONi TELi OUR SAMi PUBi IND PHY ONL PUR COM NAV INT DEM CNT STA POL PRE GOV"
Cache-control: public
Set-cookie: JROUTE=W2VMz2yu926eYGvP; Path=/
X-powered-by: JSP/2.1
Set-cookie: JSESSIONID=80765ae114eab08df95a11208c62; Path=/
Content-type: text/html;charset=UTF-8
Via: 1.1 https-www
@mnot
mnot / weird_date
Created April 18, 2012 16:07
IIS Split date line - only on partial responses, one site
HTTP/1.1 206 Partial Content
Cache-Control: max-age=86400
Content-Type: text/css
Last-Modified: Mon, 15 Mar 2010 17:41:22 GMT
Accept-Ranges: bytes
ETag: "0cd3ba66c4ca1:0"
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Connection: Keep-Alive
Date: Wed, 18 Apr 2012 16:20
@mnot
mnot / iri_to_uri.py
Created January 20, 2013 03:15
Convert an IRI to a URI
import urllib
import urlparse
def iri_to_uri(iri, encoding='Latin-1'):
"Takes a Unicode string that can contain an IRI and emits a URI."
scheme, authority, path, query, frag = urlparse.urlsplit(iri)
scheme = scheme.encode(encoding)
if ":" in authority:
host, port = authority.split(":", 1)
authority = host.encode('idna') + ":%s" % port
@mnot
mnot / update.sh
Last active July 9, 2019 04:55
Update all projects in a directory from their master repositories.
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
for PROJECT in $DIR/*
do
if [ -d $PROJECT ] ; then
cd $PROJECT
# Git
@mnot
mnot / htlook.py
Last active December 16, 2015 09:19
Summarise how a list of HTTP servers handles a particular request to a set of URLs.
"""
htlook.py
Summarise how a list of HTTP servers handles a particular request to a
set of URLs.
You can modify the request by either:
* Adding headers with the -a flag; e.g.,