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 functools, inspect | |
def proper_cache(*lru_args, **lru_kwargs): | |
def deco(func): | |
signature = inspect.signature(func) | |
# if the function has no default parameters, return a normal lru_cache | |
if all(p.default is inspect.Parameter.empty for p in signature.parameters.values()): |
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 inspect | |
import re | |
def called_with_wrong_args(func, locals=None, exc_info=None): | |
""" | |
Finds out whether an exception was raised because invalid arguments were passed to a function. | |
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
""" | |
Auto-detects objects defined in the current module and generates a | |
suitable `__all__`-list. | |
Must be called at the bottom of the file, after everything has been defined. | |
""" | |
import sys | |
import types | |
import inspect |
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
// ==UserScript== | |
// @name StackOverflow hammer stopwatch | |
// @description Displays how long it took for a question to be closed as duplicate | |
// @version 1.2 | |
// @author Paul Pinterits | |
// @include *://*.stackexchange.com/questions/* | |
// @include *://meta.serverfault.com/questions/* | |
// @include *://meta.stackoverflow.com/questions/* | |
// @include *://meta.superuser.com/questions/* | |
// @include *://serverfault.com/questions/* |
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
debug = False | |
debug_output = False | |
def dbg(*args): | |
if not debug: | |
return | |
print(*args) | |
import os |
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
""" | |
This code gains access to the builtins from a simple literal. As a consequence, | |
we can conclude that `eval` and `exec` are insecure even if the evaluated code | |
has no (direct) access to the builtins or globals. | |
Of course, there are ways to break this particular exploit - for example, | |
executing | |
import abc | |
del abc.__loader__ | |
will prevent it from working. But that only protects you against this particular |
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
// ==UserScript== | |
// @name StackExchange bigger text boxes | |
// @description Changes the default size of the answer box (and the question box) on StackExchange | |
// @version 1.3 | |
// @author Paul Pinterits | |
// @include *://*.stackexchange.com/questions/* | |
// @include *://meta.serverfault.com/questions/* | |
// @include *://meta.stackoverflow.com/questions/* | |
// @include *://meta.superuser.com/questions/* | |
// @include *://serverfault.com/questions/* |
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
// ==UserScript== | |
// @name SOchat [mcve] shortcut | |
// @description Enables the [mcve] shortcut in StackOverflow chat | |
// @version 1.1.3 | |
// @author Paul Pinterits | |
// @include *://chat.stackoverflow.com/rooms/* | |
// @grant none | |
// @updateURL https://gist.github.com/Aran-Fey/e5a3fbd5de70d093e7b490ad46117819/raw/SOchat_mcve_shortcut.user.js | |
// @downloadURL https://gist.github.com/Aran-Fey/e5a3fbd5de70d093e7b490ad46117819/raw/SOchat_mcve_shortcut.user.js | |
// ==/UserScript== |
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
// ==UserScript== | |
// @name StackOverflow auto edit | |
// @description Automatically detects low quality questions and attempts to improve them | |
// @version 1.1.11 | |
// @author Paul Pinterits | |
// @include *://*.stackexchange.com/questions/* | |
// @include *://meta.serverfault.com/questions/* | |
// @include *://meta.stackoverflow.com/questions/* | |
// @include *://meta.superuser.com/questions/* | |
// @include *://serverfault.com/questions/* |
OlderNewer