Skip to content

Instantly share code, notes, and snippets.

Cory Benfield Lukasa

Block or report user

Report or block Lukasa

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
Lukasa /
Created Aug 6, 2012
An example script for sending a text file to yourself via email
#!/usr/bin/env python
'''A script that sends the contents of a file in a plain-text email.'''
# Imports
import smtplib
import sys
# Important constants.
FROM_PASS = 'thisisntarealpassword'
Lukasa /
Created Aug 6, 2012
A script to test the health of ZFS pools.
# This script checks the state of all zpools. If an error is found, it
# emails the contents of zpool status to the administrator.
mkdir -p ~/.zpool_status
cd ~/.zpool_status
result=`zpool status -x`
Lukasa / gist:3379184
Created Aug 17, 2012
Post-commit hook for use with Django's collectstatic.
View gist:3379184
# This script should be placed in the .git/hooks directory and marked
# executable. It has the effect of minifying all of the files in the
# _static/css directory and placing them in the static/css directory, before
# pushing them to S3.
set -e
# Set some constants
Lukasa /
Created Mar 31, 2013
Requests and Beautiful Soup example, following the form of
from BeautifulSoup import BeautifulSoup
import requests
import urlparse
URL = ''
s = requests.Session()
def fetch(url, data=None):
if data is None:
return s.get(url).content
Lukasa /
Created Sep 28, 2013
An example of how to persist cookies in Requests.
Lukasa / certdata-in.txt
Created Oct 24, 2013
Go: extract-nss-root-certs
View certdata-in.txt
This file has been truncated, but you can view the full file.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at
CVS_ID "@(#) $RCSfile: certdata.txt,v $ $Revision: 1.87 $ $Date: 2012/12/29 16:32:45 $"
# certdata.txt
Lukasa /
Last active Aug 29, 2015
HTTP/1.1 and HTTP/2.0 test

The plan here is to investigate the network efficiency of HTTP/2.0 versus HTTP/1.1 by gently hitting Twitter's API. The above script does 5 HTTP requests to Twitter and gets the responses.

In my tests I'm showing an insane different, whereby HTTP/2.0 transfers 250 kB of data and HTTP/1.1 transfers 2.2 MB. This difference seems insane to me, so I'd like to work out why it's happening.

To run this, you'll need Python 3.3. Install the requirements listed in requirements.txt, and then go to Twitter's API page and set up an application. Get the values listed in the script for your application, fill them in, and run them, using Wireshark to check how much traffic was sent. Let me know what you find!


Keybase proof

I hereby claim:

  • I am Lukasa on github.
  • I am lukasa ( on keybase.
  • I have a public key whose fingerprint is 90DC AE40 FEA7 4B14 9B70 662D F25F 2144 EEC1 373D

To claim this, I am signing this object:

import itertools
def blocks(size, total_sum):
def ascending(iterable):
last = 0
for elem in iterable:
if elem < last:
return False
last = elem
return True
Lukasa /
Created Mar 25, 2014
Hey Google, you know what this isn't? Valid JSON.

A Thankyou To Google

Dear Google,

I'd just like to thank you for disabusing me of the idea that JSON is under some requirement of well-formedness. I'd been labouring under the tyrannical misapprehension that some standards body had written down how JSON was supposed to work and that if I wanted to claim I was using JSON I would have to comply with that specification.

However, I today received a bug report indicating that a project to which I contribute was unable to make HTTP requests your Google Flights website could understand. I found this perplexing, but my eyes were opened when I saw your HTTP request. In particular, I enjoyed your freeform and inclusive definition of JSON. Allow me to show you what you've called JSON by showing you my SPDY request:
You can’t perform that action at this time.