Skip to content

Instantly share code, notes, and snippets.

@kgaughan
kgaughan / tls.py
Last active May 3, 2017 17:05
asyncore TLS handshaker
"""
SSL/TLS negotiation.
"""
import asyncore
import logging
import socket
import ssl
@kgaughan
kgaughan / gist:b7d64be13b06c7edf5b3
Last active August 29, 2015 14:08
Example standalone uWSGI config.
[uwsgi]
virtualenv = /path/to/my/virtualenv
chdir = /path/to/my/app
master = true
threads = 5
; Use a free port.
socket = localhost:6000
env = LC_ALL=en_IE.UTF-8
env = LANG=en_IE.UTF-8
module = mysite.wsgi:application
@kgaughan
kgaughan / gist:3b7889c4c20ca8657ce8
Last active August 29, 2015 14:08
Example emperor mode uWSGI configuration skeleton.
[uwsgi]
chdir = /home/keith/sites/weblogs
logto = /home/keith/sites/weblogs/logs/%n.uwsgi.log
master = true
threads = 5
socket = /var/run/uwsgi/weblog.%n.sock
pythonpath = /home/keith/sites/weblogs
env = LC_ALL=en_IE.UTF-8
env = LANG=en_IE.UTF-8
module = %n.wsgi:application
@kgaughan
kgaughan / test.rs
Created April 21, 2014 14:06
Experiment with unique pointers, pattern matching, union types, closures, and tasks.
enum List {
Cons(u32, ~List),
Nil,
}
fn main() {
let list = Cons(1, ~Cons(2, ~Cons(3, ~Nil)));
let mut head = ~list;
loop {
match head {
@kgaughan
kgaughan / fetch-ca-chain.sh
Last active August 29, 2015 13:58
Given an SSL/TLS certificate, walk all its intermediates to construct a CA bundle. This is a bit of a hack, but at least it more-or-less works.
#!/bin/sh
#
# Given an SSL/TLS certificate, walk all its intermediates to construct a CA bundle.
#
if test "x$1" = "x"; then
echo Please provide a certificate. >&2
exit 2
fi
if test ! -e $1; then

Keybase proof

I hereby claim:

  • I am kgaughan on github.
  • I am talideon (https://keybase.io/talideon) on keybase.
  • I have a public key whose fingerprint is 59C0 C696 FC51 A3B6 ADE9 1408 682D 43CC CF9F 6473

To claim this, I am signing this object:

#!/bin/bash
#
# Cleans up basic whitespace problems in .rst and .py files. Run before
# commits.
#
# Tabs to spaces.
for i in `fgrep -rl $'\t' --include=\*.py --include=\*.rst .`; do
if test -f $i; then
tmp=`mktemp`
@kgaughan
kgaughan / gist:9207738
Created February 25, 2014 12:14
Stack overflow redirects.
$ curl --head http://www.podtrac.com/pts/redirect.mp3/feeds.soundcloud.com/stream/135361168-stack-exchange-stack-exchange-podcast-54.mp3
HTTP/1.1 302 Found
Content-Length: 206
Location: http://feeds.soundcloud.com/stream/135361168-stack-exchange-stack-exchange-podcast-54.mp3
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Tue, 25 Feb 2014 12:04:14 GMT
$ curl --head http://feeds.soundcloud.com/stream/135361168-stack-exchange-stack-exchange-podcast-54.mp3
HTTP/1.1 301 Moved Permanently
@kgaughan
kgaughan / gist:8320971
Created January 8, 2014 17:41
List all the ports with servers listening on them on localhost.
lsof -P -i @127.0.0.1 -sTCP:LISTEN
@kgaughan
kgaughan / gist:6309193
Created August 22, 2013 16:00
Sphinx makefile changes to aid with uploading to a PyPI-style documentation server. This creates a new target, 'upload', to build and upload documentation generated by Sphinx.
SPHINX_SERVER = https://pypidocs.example.com/
SPHINX_NAME = handbook
upload: clean html
@which zip 2>&1 >/dev/null || (echo "zip required."; exit 1)
@which curl 2>&1 >/dev/null || (echo "curl required."; exit 1)
@( \
echo "Uploading..."; \
cd $(BUILDDIR)/html; \
zip -9 --recurse-paths --quiet - . | \