Skip to content

Instantly share code, notes, and snippets.

@johnslavik
johnslavik / terms.txt
Created December 18, 2023 14:28
Polish math terms
abak
abakus
aksjomat
aksjomat Euklidesa
aksjomaty planimetrii
aksjomatyczna teoria mnogości
alef zero
alternatywa
analiza matematyczna
arcus cosinus
from __future__ import annotations
import re
import xmlrpc.client
from functools import cache
from posixpath import basename
import pandas as pd
from httpx import HTTPStatusError, get
from pypistats import recent
@johnslavik
johnslavik / descriptor_source_check.py
Last active September 17, 2023 16:47
Check whether the descriptor was called from the owner's method or from somewhere else.
# (C) 2023, bswck
import inspect
from collections.abc import Callable
from types import MethodType
class Descriptor:
def __init__(
self,
stack_offset: int = 1,
@johnslavik
johnslavik / xss.jpg
Last active January 22, 2023 14:36
xss.svg
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg">
<rect width="300" height="100" style="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)" />
<script type="text/javascript">
alert("XSS");
</script>
</svg>
@johnslavik
johnslavik / emailing.py
Last active November 11, 2022 20:21
Minimal, persistent and multi-threaded e-mail delivery system in Flask
"""
Remember to set the SMTP_HOST environment variable
or pass it as a keyword argument to EmailWorker()!
Requirements:
pip install flask-mail persist-queue
Usage:
# To deliver an e-mail
from flask_mail import Message
import functools
from reprlib import recursive_repr
from typing import Iterable
class TreeOverflow(OverflowError, ValueError):
pass
def _solve_args(**kwds):
@johnslavik
johnslavik / encoding.py
Created August 11, 2021 11:04
non-ASCII ASCII
b'\xbfa\xbf\xf3\xb3\xe6 g\xea\x9cl\xb9 ja\x9f\xf1' # -> żażółć gęślą jaźń
# TODO: figure out what the heck is the encoding