Skip to content

Instantly share code, notes, and snippets.

View L3viathan's full-sized avatar
🦊

Jonathan Oberländer L3viathan

🦊
View GitHub Profile
@L3viathan
L3viathan / atomic_contextmanager.py
Last active May 2, 2024 11:49
Go backwards in time when something went wrong
import os
import sys
import inspect
import signal
from contextlib import contextmanager
def _kill_self(signum, frame):
os._exit(0)
@contextmanager
@romainl
romainl / breakhere.vim
Created May 26, 2017 09:13
Universal opposite of J
function! BreakHere()
s/^\(\s*\)\(.\{-}\)\(\s*\)\(\%#\)\(\s*\)\(.*\)/\1\2\r\1\4\6
call histdel("/", -1)
endfunction
nnoremap <key> :<C-u>call BreakHere()<CR>
@kgullion
kgullion / checker.py
Created April 7, 2017 01:54
Code checker for Answer-Chaining Fibonacci at http://codegolf.stackexchange.com/q/115591/32604
def checker(code, restricted):
r = set(restricted)
c = set(code)
chars = {*'\t\n', *map(chr, range(32, 127))}
if c == chars - r:
print('Good to go!')
else:
if r & c:
print('Illegal characters: {}'.format(''.join(r & c)))
if chars - r - c:
@liuw
liuw / ctype_async_raise.py
Created April 17, 2012 16:02
Nasty hack to raise exception for other threads
#!/usr/bin/env python
# liuw
# Nasty hack to raise exception for other threads
import ctypes # Calm down, this has become standard library since 2.5
import threading
import time
NULL = 0