Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3.8
import sys
from inject_blame import inject_blame
from traceback import print_exception
sys.excepthook = print_exception
inject_blame("/home/ofer/Sources/easypy/easypy/collections.py")
from easypy.collections import ListCollection
lc = ListCollection()
import re
import time
import linecache
from subprocess import check_output
DAY = 60 * 60 * 24
BLAME_REGEX = re.compile(
r"(?P<commit>\w+)\s+"
r"(?P<file>\S+)\s+"
# replace exception hook
import sys
from traceback import print_exception
sys.excepthook = print_exception
# meddle with a code line using linecache
import linecache
lineno = 423
fname = "/home/ofer/Sources/easypy/easypy/collections.py"
@koreno
koreno / excepthook.py
Created February 11, 2021 21:54
Setting sys.excepthook
from traceback import print_exception
sys.excepthook = print_exception
@koreno
koreno / linecache_demo.2.py
Last active February 11, 2021 22:16
Messing with linecache
size, mtime, lines, fullname = linecache.cache[fname]
lines[lineno - 1]
# ' return random.randint(minimum, maximum)\n'
lines[lineno - 1] = "Nothing to see here, please move along..."
linecache.getline(fname, lineno)
# 'Nothing to see here, please move along...'
@koreno
koreno / linecache_demo.1.py
Last active February 11, 2021 22:16
linecache example
import linecache
lineno = 423
fname = "/home/ofer/Sources/easypy/easypy/collections.py"
linecache.getline(fname, lineno)
# ' return random.randint(minimum, maximum)\n'
@koreno
koreno / traceback_demo.py
Last active February 11, 2021 22:14
Traceback Example #1
from easypy.collections import ListCollection
lc = ListCollection()
lc.pop_some(1)
Traceback (most recent call last):
File "./traceback_demo.py", line 7, in <module>
lc.pop_some(1)
File "/home/ofer/Sources/easypy/easypy/collections.py", line 481, in pop_some
sample_size = self._choose_sampling_size(minimum, maximum)
File "/home/ofer/Sources/easypy/easypy/collections.py", line 423, in _choose_sampling_size
@koreno
koreno / README.md
Last active April 1, 2020 10:44
'rebaser' improves on 'git rebase -i' by adding information per commit regarding which files it touched.

Prebase

git-prebase improves on 'git rebase -i' by adding information per commit regarding which files it touched.

  • Each file gets an alpha-numeric identifier at a particular column, a list of which appears below the commit list. (The identifiers wrap around after the 62nd file)
  • Commits can be moved up and down safely (without conflicts) as long as their columns don't clash (they did not touch the same file).

Installation

Add the executable to your path and git will automatically expose it as