Skip to content

Instantly share code, notes, and snippets.

View zacharyvoase's full-sized avatar

Zack Voase zacharyvoase

View GitHub Profile
Index: openssl-1.0.1c/Makefile
===================================================================
--- openssl-1.0.1c.orig/Makefile
+++ openssl-1.0.1c/Makefile
@@ -644,7 +644,7 @@ install_docs:
@pod2man="`cd ./util; ./pod2mantest $(PERL)`"; \
here="`pwd`"; \
filecase=; \
- if [ "$(PLATFORM)" = "DJGPP" -o "$(PLATFORM)" = "Cygwin" -o "$(PLATFORM)" = "mingw" ]; then \
+ if [ "$(PLATFORM)" = "DJGPP" -o "$(PLATFORM)" = "Cygwin" -o "$(PLATFORM)" = "mingw" -o "$(PLATFORM)" = "darwin64-x86_64-cc" ]; then \
@zacharyvoase
zacharyvoase / curlwhat.py
Created November 13, 2012 18:22
Use curl to make requests from Python. License: http://unlicense.org/
"""
>>> response = curl('http://news.ycombinator.com/')
>>> response.status
200
>>> response.getheader('content-type')
'text/html; charset=utf-8'
>>> response.read(6)
'<html>'
>>> response.close()
"""
@zacharyvoase
zacharyvoase / capture.py
Created November 10, 2012 04:08
An implementation of teena.Capture. Works surprisingly well.
from functools import partial
import cStringIO
import os
import threading
from tornado import ioloop
import teena
@zacharyvoase
zacharyvoase / process_local.py
Created September 1, 2012 05:31
A fork-friendly threading.local().
import os
import threading
class ObjectProxy(object):
"""Wrap a target object and provide an interface to its underlying object.
This is especially useful when you're defining an interface which overrides
the attribute access magic methods, but you still need to access named
@zacharyvoase
zacharyvoase / test.py
Created September 1, 2012 02:43 — forked from winhamwr/test.py
Nose generator tests example
from nose.tools import assert_equal
addition_cases = [
(
'2 + 2',
2,
2,
4
),
(
@zacharyvoase
zacharyvoase / prob-m2m.md
Created August 22, 2012 01:11
Probabilistic M2M relationships using Bloom filters

Here’s an idea that’s been kicking around inside my head recently.

A standard M2M relationship, as represented in SQL, looks like this:

CREATE TABLE movie (
  id SERIAL PRIMARY KEY,
  name VARCHAR(255)
);
"""
Refactor out similarities between JSON objects.
"""
import abc
from mm import multimethod # TODO: implement.
def latest_common_ancestor(type1, type2):
"""Get the latest common ancestor of two types.
@zacharyvoase
zacharyvoase / yield_from.py
Created August 3, 2012 03:10
yield from, for Python 2.5+ (WIP)
"""
>>> @yields_from
... def example():
... yield 1
... yield 2
... yield from_(iter(xrange(3, 6)))
... yield 6
>>> for i in example():
... print i
@zacharyvoase
zacharyvoase / pentypea.md
Created June 29, 2012 01:20 — forked from anonymous/gist:3014636
Pen type a

Project Update #27: The Storm For backers only, Posted by cw&t Hi backers!

First, for those of you still waiting for your pen(s), we're still on schedule. The schedule was posted a few updates ago (update #22). The 3 remaining batches are shipped from our manufacturer in China on July 7th (480 pens) July 23rd (480) August 7th (494)

In the last couple months, we fought hard to speed up production. We advanced more money and were promised ship dates by our manufacturer and none were met. In their eyes, delays were caused by us because we were so picky about the details, but the truth is we weren't asking for anything out of the ordinary. All we asked for was for them to follow the specifications in our drawings they agreed to on day one. They weren't able to meet the specifications, so they blamed production delays on little changes made during production to help make the pen more manufacturable.

@zacharyvoase
zacharyvoase / README.md
Created June 14, 2012 19:05
hstore-based localized fields in Django

This could be the basis of a localized field implementation using hstore.

It mostly uses django-hstore, but then some simple JS in the admin replaces the default textarea with a richer key/value-oriented widget. The textarea is hidden, and changes in the keys and values of the form are just JSON-serialized back into the textarea—so it works with django-hstore as it is currently implemented, allows for easier programmatic access + manipulation, and doesn't require a lot of hacking.

The main change, code-wise, is that the hstore textareas need to be given an HTML class of 'hstore'. This requires more work than I think should be necessary—you need to wire the model field up to a form field, and the form field up to a widget, which replaces the class.