Skip to content

Instantly share code, notes, and snippets.

View defrank's full-sized avatar

Derek F defrank

View GitHub Profile
defrank / cd
Created January 15, 2018 20:52
Override builtin cd to source closest virtual environment
# Source closest virtual environment, ``venv``, if exists in any parent
# directory.
cd () {
local venv_dir="venv" prevpwd="$PWD"
builtin cd "$@"
if [ "$prevpwd" != "$PWD" ]; then
local base_dir="$PWD"
defrank /
Created July 2, 2017 02:51
Flatten a sequence in Python 3
#!/usr/bin/env python3
def flatten(myseq):
"""Lazily flatten a given sequence."""
for x in myseq:
if isinstance(x, (list, tuple, set, dict)):
yield from flatten(x)
yield x
defrank /
Created April 9, 2017 00:42
Keybase proof

Keybase proof

I hereby claim:

  • I am defrank on github.
  • I am dmf ( on keybase.
  • I have a public key ASDiHADv5nOP1vdb1mK0CwOZepikxPJW_e6jNQiI5a06Fwo

To claim this, I am signing this object: