This file contains hidden or 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
| from __future__ import print_function | |
| class Watcher(object): | |
| def __init__(self, func): | |
| self.func = func | |
| self.before = [] | |
| self.after = [] | |
| def __call__(self, *args, **kargs): | |
| for callback in self.before: |
This file contains hidden or 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
| curzona@curzona-desktop:~/Desktop/hello_spacebox/agent (master)$ cp sample.env heroku.env | |
| curzona@curzona-desktop:~/Desktop/hello_spacebox/agent (master)$ vim heroku.env | |
| curzona@curzona-desktop:~/Desktop/hello_spacebox/agent (master)$ foreman run -e heroku.env ./tests/construction.js | |
| module.js:340 | |
| throw err; | |
| ^ | |
| Error: Cannot find module 'spacebox-common/src/three_helpers.js' | |
| at Function.Module._resolveFilename (module.js:338:15) | |
| at Function.Module._load (module.js:280:25) |
This file contains hidden or 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 time | |
| import inspect | |
| import types | |
| def _assert(func): | |
| if not func(): | |
| if isinstance(func, types.FunctionType): | |
| raise AssertionError(inspect.getsource(func).strip()) | |
| else: | |
| raise AssertionError() |
This file contains hidden or 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 time | |
| import subprocess | |
| import psutil, os | |
| def kill_proc_tree(pid, including_parent=True): | |
| parent = psutil.Process(pid) | |
| children = parent.children(recursive=True) | |
| for child in children: | |
| child.kill() |
This file contains hidden or 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 time | |
| import subprocess | |
| import threading | |
| cmd = ['timeout', '10'] | |
| p = subprocess.Popen(cmd) | |
| p.killed = False | |
| def timeout(): | |
| time.sleep(1) |
This file contains hidden or 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
| py.test -l --tb=long | |
| =========================== test session starts =========================== | |
| platform linux2 -- Python 2.7.6 -- py-1.4.26 -- pytest-2.6.4 | |
| plugins: ordering, bdd, instafail, cov, xdist | |
| collected 1 items | |
| test_bdd.py F | |
| ================================ FAILURES ================================= | |
| _________________ test_SomeDeterminableBusinessSituation __________________ |
This file contains hidden or 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 json | |
| import sys | |
| import argparse | |
| parser = argparse.ArgumentParser(prog='jsonformatter') | |
| parser.add_argument('input', type=str, help='Input file') | |
| parser.add_argument('output', type=str, nargs='?', help='Output file') | |
| args = parser.parse_args() |
This file contains hidden or 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
| from pprint import pprint | |
| a = _Dict({'a':'1'}) | |
| b = _Dict({'b':'2'}) | |
| pprint(a + b) |
This file contains hidden or 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
| data = open("myfile", "rb").read() | |
| width = 16 | |
| lines = [data[i:i+width] for i in range(0, len(data), width)] | |
| print "\n".join([" ".join(map(lambda x: "%02X" % x, map(ord, line))) for line in lines]) |
