Skip to content

Instantly share code, notes, and snippets.

@chrisklaiber
chrisklaiber / image_to_cs.py
Created August 30, 2012 21:09
Convert an image to drawing instructions
"""
Convert an image to drawing instructions.
Dependencies:
* PIL, the Python Imaging Library
This basically write color values for each pixel, with minor cleverness to
reduce output size:
@chrisklaiber
chrisklaiber / WebPageTest.org Analysis Scaffold.ipynb
Last active August 29, 2015 14:15
Analyzing Deferred JavaScript with WebPageTest.org
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chrisklaiber
chrisklaiber / namedmap.py
Last active September 16, 2016 22:07
namedmap and tuplemap: quacks like a dict, has the memory footprint of a tuple (eh, good enough)
"""A space-efficient frozen (write-once) mapping class.
A named map has two key properties:
1. The interface is like a dict.
2. Memory usage is like an object that defines __slots__.
Call namedmap.frozennamedmap() to define a subclass, passing the name
of the type and an iterable of key names.
@chrisklaiber
chrisklaiber / SimpleHTTPServer6.py
Created February 15, 2018 16:16
Python SimpleHTTPServer over IPv6. Run as `python -m SimpleHTTPServer6 [PORT]`
import BaseHTTPServer
import SimpleHTTPServer
import socket
class HTTPServer6(BaseHTTPServer.HTTPServer):
address_family = socket.AF_INET6
if __name__ == '__main__':