This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# execute an interactive python shell on a remote machine, | |
# over ssh, after coping my local pythonrc to that machine | |
# (my pythonrc available here: https://gist.github.com/lonetwin/5902720) | |
function rpython { | |
DEST='/tmp/.pythonrc.py' | |
scp -q $PYTHONSTARTUP $1:$DEST | |
ssh -t $1 -- "PYTHONSTARTUP=$DEST python" | |
ssh $1 "rm $DEST" | |
} | |
# - setup completion for rpython |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import pip | |
from importlib import import_module | |
from importlib.abc import MetaPathFinder | |
class PipMetaPathFinder(MetaPathFinder): | |
"""A importlib.abc.MetaPathFinder to auto-install missing modules using pip | |
""" | |
def find_spec(fullname, path, target=None): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# With nose, this test will (incorrectly) pass | |
# With nose2, this test will (correctly) fail | |
import unittest | |
class TestSomething(unittest.TestCase): | |
def validate(self, x, y): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
""" tracer.py: Quick and dirty python 'strace' | |
""" | |
import os | |
import os.path | |
import sys | |
import linecache | |
from functools import wraps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import re | |
from itertools import chain | |
from functools import reduce, partial | |
def apply_substitutions(text, substitutions): | |
"""Apply an ordered list of string transformations to input text |
OlderNewer