Skip to content

Instantly share code, notes, and snippets.

@89465127
89465127 / deepcopy.py
Created March 26, 2013 23:32
recurses over a mixed data structure of tuples, lists, and dicts, and returns a copy.
# this simple example recurses over a mixed data structure of tuples, lists, and dicts, and returns a copy.
num_recursions = 0
def r(current):
global num_recursions
num_recursions += 1
if isinstance(current, list):
return [r(i) for i in current]
elif isinstance(current, dict):
@89465127
89465127 / gloss.py
Last active December 14, 2015 17:19
Wikipedia glossary generator
#! /usr/bin/python
import bs4
import json
import urllib2
import html2text
import nltk
import collections
# to do, lets turn this into a full class (that can be imported)
# and use argparse (which invokes serializing it to a file)
@89465127
89465127 / perudo.py
Last active December 14, 2015 15:38
Perudo Game Assistant
#! /usr/bin/python
import operator
import re
import numpy as np
class Perudo():
def __init__(self):
print "-- New Game --\nNumber of players?"
num_players = int(self.user_input())