Skip to content

Instantly share code, notes, and snippets.

@mnordhoff
mnordhoff / gist:2213179
Last active October 22, 2022 23:17
Python regular expressions for IPv4 and IPv6 addresses and URI-references, based on RFC 3986's ABNF.The URI-reference regular expression includes IPv6 address zone ID support (RFC 6874).
# Python regular expressions for IPv4 and IPv6 addresses and URI-references,
# based on RFC 3986's ABNF.
#
# ipv4_address and ipv6_address are self-explanatory.
# ipv6_addrz requires a zone ID (RFC 6874) follow the IPv6 address.
# ipv6_address_or_addrz allows an IPv6 address with optional zone ID.
# uri_reference is what you think of as a URI. (It uses ipv6_address_or_addrz.)
import re
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test</title>
</head>
<body>
<p>{{ '1'|test.foo() }}</p>
<p>{{ foo }}</p>
</body>
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Copyright (c) 2009, 2010, 2011, 2012 Matt Nordhoff <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# Replace blank variables with -
#
# map $foo $foo_h {
# default $foo;
# "" -;
# }
map $host $host_h { default $host; "" -; }
log_format lighttpd
'$remote_addr $host_h $remote_user [$time_local] "$request" $status '
'$body_bytes_sent "$http_referer" "$http_user_agent"';
66.249.64.3 1.m0n0wall.pool.ntp.org - [14/Nov/2013:01:43:35 +0000] "GET /?a=b&t=z&s=1GiB HTTP/1.1" 301 184 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
2001:470:5:932:2e0:b8ff:febb:161b mtr-atlanta.mn9.us - [14/Nov/2013:02:21:36 +0000] "GET / HTTP/1.1" 200 892 "-" "Mozilla/5.0 (X11; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0"
2001:470:5:932:2e0:b8ff:febb:161b mtr-atlanta.mn9.us - [14/Nov/2013:02:21:37 +0000] "GET /favicon.ico HTTP/1.1" 404 209 "-" "Mozilla/5.0 (X11; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0"
2001:470:5:932:2e0:b8ff:febb:161b mtr-atlanta.mn9.us - [14/Nov/2013:02:21:37 +0000] "GET /favicon.ico HTTP/1.1" 404 209 "-" "Mozilla/5.0 (X11; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0"
server {
listen 80;
listen [::]:80;
location / {
return 301 http://www.beta.grundclock.com$request_uri;
}
server_name .beta.grundclock.com;
}
server {
@mnordhoff
mnordhoff / ww.pl
Last active August 29, 2015 13:56
use vars qw($VERSION %IRSSI);
$VERSION = '0.1';
%IRSSI = (
authors => 'Matt Nordhoff',
contact => '[email protected]',
description => "/w/w 10",
name => 'ww',
);
sub send_text {
#!/usr/bin/env python
import sys
import getopt
import lzma
def compressor(infile, outfile):
with lzma.open(outfile, "w") as f:
f.write(infile)
#!/usr/bin/env python
import sys
import argparse
import lzma
def compressor(infile, outfile):
with lzma.open(outfile, 'w') as lzf:
lzf.write(infile)
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Copyright (c) 2014, 2016 Matt Nordhoff <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is