Skip to content

Instantly share code, notes, and snippets.

@wladston
wladston / strip_database.py
Created February 6, 2013 20:59
Strip all strings that exist in a MongoDB database. It will work recursively to strip **ALL** your strings. Binary data won't be affected.
# -*- coding: utf-8; -*-
from bson import Binary
from pymongo import Connection
from pymongo.database import Database
db = Database(Connection(), "yourdb")
def _clean_dict(x):
dic = {}
@wladston
wladston / dcmst.py
Created March 5, 2012 23:07
Degree constrained minimum spanning tree with networkx
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
# This is the framework for graphs we use on this work
import networkx as nx
# Tool to determine wether elements are on the same set
from networkx.utils import UnionFind
# We need this in python to "clone" objects
import copy