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
Lukasa / send_email.py
Created Aug 6, 2012
An example script for sending a text file to yourself via email
View send_email.py
#!/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 Aug 6, 2012
A script to test the health of ZFS pools.
View zfs_report.sh
#!/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 Aug 17, 2012
Post-commit hook for use with Django's collectstatic.
View gist:3379184
#!/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 Mar 31, 2013
Requests and Beautiful Soup example, following the form of http://bpaste.net/show/kMetvCdrfnzh5RgiUKU4/
View example.py
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 Sep 28, 2013
An example of how to persist cookies in Requests.
View cookie_test.py
@Lukasa
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 http://mozilla.org/MPL/2.0/.
CVS_ID "@(#) $RCSfile: certdata.txt,v $ $Revision: 1.87 $ $Date: 2012/12/29 16:32:45 $"
#
# certdata.txt
#
@Lukasa
Lukasa / README.md
Last active Aug 29, 2015
HTTP/1.1 and HTTP/2.0 test
View README.md

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!

View keybase.md

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:

View tash.py
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 Mar 25, 2014
Hey Google, you know what this isn't? Valid JSON.
View wtfgoogle.md

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
You can’t perform that action at this time.