Skip to content

Instantly share code, notes, and snippets.

View ahopkins's full-sized avatar

Adam Hopkins ahopkins

View GitHub Profile

Keybase proof

I hereby claim:

  • I am ahopkins on github.
  • I am admhpkns (https://keybase.io/admhpkns) on keybase.
  • I have a public key whose fingerprint is F7EB FB5E 0003 E06F 64DE 76AC E8D8 907B 4272 FA55

To claim this, I am signing this object:

@ahopkins
ahopkins / flatten.py
Created January 29, 2017 22:24
Recursively flatten an arbitrary number of nested iterators.
l = [1, 2, 3, [4, 5, 6, [9, 8, 7, [12, 11, 10], 13, 14], 15, 16], 17, 18]
def flatten(input):
""" Flatten nested iterators. Looks specifically for lists, tuples, and sets, and returns them sorted"""
# Prepare the ourput variable
output = []
# Look for wheter an input is a list, tuple, or set
@ahopkins
ahopkins / extract_emails_from_text.py
Created November 17, 2016 00:35 — forked from dideler/example.md
A python script for extracting email addresses from text files. You can pass it multiple files. It prints the email addresses to stdout, one address per line. For ease of use, remove the .py extension and place it in your $PATH (e.g. /usr/local/bin/) to run it like a built-in command.
#!/usr/bin/env python
#
# Extracts email addresses from one or more plain text files.
#
# Notes:
# - Does not save to file (pipe the output to a file if you want it saved).
# - Does not check for duplicates (which can easily be done in the terminal).
#
# (c) 2013 Dennis Ideler <[email protected]>