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
""" | |
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 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 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 StackOverflow auto documentation links | |
// @description Converts text enclosed in quotation marks like ?list.append()? to a link to the relevant documentation | |
// @version 1.3.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 always python 3 docs | |
// @description Automatically redirects from python 2 or python 3.x documentation to the latest python 3 documentation | |
// @version 1.3.4 | |
// @author Paul Pinterits | |
// @include /https?://docs\.python\.org/[\d.]+/.*/ | |
// @grant none | |
// @run-at document-start | |
// @updateURL https://gist.github.com/Aran-Fey/ecb80a7d3b3a955c9841bd6bea60d515/raw/always_python_3_docs.user.js | |
// @downloadURL https://gist.github.com/Aran-Fey/ecb80a7d3b3a955c9841bd6bea60d515/raw/always_python_3_docs.user.js |
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 hide user posts | |
// @description Hides all comments and answers from blocked users | |
// @version 1.3.8 | |
// @author Paul Pinterits | |
// @include /^https?://(meta\.)?(stackoverflow|serverfault|superuser|(.*\.)?stackexchange)\.com/questions(/tagged/.*)?$/?/ | |
// @namespace Aran-Fey | |
// @require https://github.com/Aran-Fey/userscript-lib/raw/ca6999d1bac2494421b70286f74d7a9a9ba636e7/userscript_lib.js | |
// @require https://github.com/Aran-Fey/SE-userscript-lib/raw/bf77f40b25d7fa88a6c3f474390c858446154ec2/SE_userscript_lib.js | |
// @grant 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
// ==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/* |
OlderNewer