Skip to content

Instantly share code, notes, and snippets.

View Lukasa's full-sized avatar

Cory Benfield Lukasa

View GitHub Profile
@Lukasa
Lukasa / send_email.py
Created August 6, 2012 18:44
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_ADDR = 'name@example.com'
FROM_PASS = 'thisisntarealpassword'
@Lukasa
Lukasa / zfs_report.sh
Created August 6, 2012 19:54
A script to test the health of ZFS pools.
#!/bin/bash
# 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
Lukasa / gist:3379184
Created August 17, 2012 14:33
Post-commit hook for use with Django's collectstatic.
#!/bin/bash
# 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
INDIR="_static/css"
@Lukasa
Lukasa / example.py
Created March 31, 2013 16:28
Requests and Beautiful Soup example, following the form of http://bpaste.net/show/kMetvCdrfnzh5RgiUKU4/
from BeautifulSoup import BeautifulSoup
import requests
import urlparse
URL = 'example.com'
s = requests.Session()
def fetch(url, data=None):
if data is None:
return s.get(url).content
@Lukasa
Lukasa / cookie_test.py
Created September 28, 2013 15:12
An example of how to persist cookies in Requests.
@Lukasa
Lukasa / certdata-in.txt
Created October 24, 2013 12:32
Go: extract-nss-root-certs
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 http://mozilla.org/MPL/2.0/.
CVS_ID "@(#) $RCSfile: certdata.txt,v $ $Revision: 1.87 $ $Date: 2012/12/29 16:32:45 $"
#
# certdata.txt
#
# This file contains the object definitions for the certs and other
@Lukasa
Lukasa / README.md
Last active August 29, 2015 13:56
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!

@Lukasa
Lukasa / keybase.md
Created March 7, 2014 20:18
Keybase proof

Keybase proof

I hereby claim:

  • I am Lukasa on github.
  • I am lukasa (https://keybase.io/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:

@Lukasa
Lukasa / tash.py
Last active August 29, 2015 13:57
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
Lukasa / wtfgoogle.md
Created March 25, 2014 09:27
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:

:host:www.google.fr