Skip to content

Instantly share code, notes, and snippets.

@datagrok
datagrok / gist:2199506
Last active April 8, 2023 17:36
Virtualenv's `bin/activate` is Doing It Wrong
@hrldcpr
hrldcpr / tree.md
Last active May 1, 2024 00:11
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@anthonywu
anthonywu / graceful_auto_reconnect.py
Created January 29, 2012 01:25
Gracefully handle a PyMongo AutoReconnect
import functools
import pymongo
import logging
import time
MAX_AUTO_RECONNECT_ATTEMPTS = 5
def graceful_auto_reconnect(mongo_op_func):
"""Gracefully handle a reconnection event."""
@functools.wraps(mongo_op_func)
@mikeyk
mikeyk / reconnect.diff
Created June 30, 2011 21:05
Automatically retry on AutoReconnect exception in pymongo
diff --git a/pymongo/connection.py b/pymongo/connection.py
index b444f50..7635c78 100644
--- a/pymongo/connection.py
+++ b/pymongo/connection.py
@@ -46,6 +46,7 @@ from pymongo import (database,
helpers,
message)
from pymongo.cursor_manager import CursorManager
+from pymongo.decorators import reconnect
from pymongo.errors import (AutoReconnect,
@mtigas
mtigas / gist:952344
Last active April 3, 2024 07:57
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.


Updated Apr 5 2019:

because this is a gist from 2011 that people stumble into and maybe you should AES instead of 3DES in the year of our lord 2019.

some other notes: