Skip to content

Instantly share code, notes, and snippets.

View eduardoluizgs's full-sized avatar

Eduardo Luiz eduardoluizgs

View GitHub Profile
@eduardoluizgs
eduardoluizgs / use_pfx_with_requests.py
Created December 27, 2017 14:02 — forked from erikbern/use_pfx_with_requests.py
How to use a .pfx file with Python requests – also works with .p12 files
import contextlib
import OpenSSL.crypto
import os
import requests
import ssl
import tempfile
@contextlib.contextmanager
def pfx_to_pem(pfx_path, pfx_password):
''' Decrypts the .pfx file to be used with requests. '''
@eduardoluizgs
eduardoluizgs / mutable_namedtuple_comparison.py
Created September 11, 2018 01:26 — forked from grantjenks/mutable_namedtuple_comparison.py
Performance Comparison of namedtuple, namedlist, and recordclass
import sys
class Record(object):
__slots__ = ()
def __init__(self, *args):
assert len(self.__slots__) == len(args)
for field, value in zip(self.__slots__, args):
setattr(self, field, value)