Skip to content

Instantly share code, notes, and snippets.

View mnot's full-sized avatar

Mark Nottingham mnot

View GitHub Profile
@mnot
mnot / uri_validate.py
Last active March 3, 2022 14:32
uri_validate.py: Validation regex for URIs, URI references, and relative URIs
#!/usr/bin/env python
"""
Regex for URIs
These regex are directly derived from the collected ABNF in RFC3986
(except for DIGIT, ALPHA and HEXDIG, defined by RFC2234).
Additional regex are defined to validate the following schemes according to
their respective specifications:
@mnot
mnot / link_header.py
Created October 15, 2009 00:41
link_header.py: HTTP Link header parsing
@mnot
mnot / rename with date.applescript
Last active January 27, 2021 06:39
Applescript to rename a selected file, appending the current date
(*
Rename with Date 0.1
Copyright 2004 Mark Nottingham <mnot@mnot.net>
THIS SOFTWARE IS SUPPLIED WITHOUT WARRANTY OF ANY KIND, AND MAY BE
COPIED, MODIFIED OR DISTRIBUTED IN ANY WAY, AS LONG AS THIS NOTICE
AND ACKNOWLEDGEMENT OF AUTHORSHIP REMAIN.
*)
@mnot
mnot / libxslt_web.py
Created October 29, 2009 12:47
libxslt_web.py: use XSLT on the "normal" Web
#!/usr/bin/env python2.4
"""
libxslt_web - XSLT Extension Functions for the HTML Web
This is a set of XSLT extension functions that give access to HTTP mechanisms and HTML
documents (even those that are invalid) on the Web.
In particular, it offers;
- GET and POST support, with control over the POST body and content-type
@mnot
mnot / RSS.py
Created October 29, 2009 12:48
RSS.py: work with RSS channels as data structures
#!/usr/bin/env python
"""
RSS.py
Classes for working with RSS channels as arbitrary data structures.
Requires Python 2.2 or newer and PyXML 0.7.1 or newer.
ChannelBase - Base class for RSS Channels.
CollectionChannel - RSS Channel modeled as a URI-per-entry
@mnot
mnot / sparkogram.py
Created October 29, 2009 12:49
sparkogram.py: Sparkline histogram generator
#!/usr/bin/env python
"""
sparkogram.py - Sparkline histogram generator
This is quick and dirty. Based on Joe Gregorio's sparkline thoughts;
<http://bitworking.org/news/Sparklines_in_data_URIs_in_Python>.
"""
__license__ = """
@mnot
mnot / c_zlib.py
Created November 25, 2009 04:03
c_zlib.py: zlib for Python using ctypes
#!/usr/bin/env python
"""
c_zlib - zlib for Python using ctypes.
This is a quick and nasty implementation of zlib using Python ctypes, in order to expose the ability
to set a compression dictionary (which isn't available in the zlib module).
"""
__license__ = """
@mnot
mnot / isodate.py
Created December 1, 2009 05:28
isodate.py: W3C datetime functions
#!/usr/bin/env python
"""
isodate.py
Functions for manipulating a subset of ISO8601 date, as specified by
<http://www.w3.org/TR/NOTE-datetime>
Exposes:
- parse(s)
@mnot
mnot / urlnorm.py
Created December 1, 2009 05:29
urlnorm.py: URL normalisation
#!/usr/bin/env python
"""
urlnorm.py - URL normalisation routines
urlnorm normalises a URL by;
* lowercasing the scheme and hostname
* taking out default port if present (e.g., http://www.foo.com:80/)
* collapsing the path (./, ../, etc)
* removing the last character in the hostname if it is '.'
@mnot
mnot / http_conn_timer.py
Created December 20, 2009 04:40
http_conn_timer.py: find out how long a HTTP server keeps connections open
#!/usr/bin/env python
"""
http_conn_timer.py
by Mark Nottingham <mnot@pobox.com>
How long does a given HTTP server hold persistent connections open?
Requires Twisted <http://twistedmatrix.com/>
"""