Skip to content

Instantly share code, notes, and snippets.

View gavinwahl's full-sized avatar

Gavin Wahl gavinwahl

  • Fusionbox
  • Colorado
View GitHub Profile
@gavinwahl
gavinwahl / bulk_object_creator.py
Last active July 19, 2018 21:39
Bulk create your objects, but don't accidentally keep too many in memory
import contextlib
@contextlib.contextmanager
def bulk_object_creator(limit=100):
"""
Allows creation of model objects in bulk, intelligently not using too much memory.
with bulk_object_creator() as foo_creator:
for i in range(100000):
@eskil
eskil / m2crypto-certificates.py
Created April 8, 2012 17:07
Example of generating CA certs and CA signed certs using python m2crypto.
"""
Tools for creating a CA cert and signed server certs.
Divined from http://svn.osafoundation.org/m2crypto/trunk/tests/test_x509.py
The mk_temporary_xxx calls return a NamedTemporaryFile with certs.
Usage ;
# Create a temporary CA cert and it's private key
cacert, cakey = mk_temporary_cacert()