Skip to content

Instantly share code, notes, and snippets.

@bartolootrit
bartolootrit / victoria_metrics_test.py
Last active August 3, 2026 09:16
Getting recent changes from VictoriaMetrics (single-node version) for testing purposes
import requests
from random import randint
from time import sleep
from urllib.parse import urljoin
val = randint(1, 100)
requests.post(
urljoin(host, '/api/v1/import/prometheus'),
data=f'requests_per_second{{method="post"}} {val}'
@bartolootrit
bartolootrit / decorator.py
Last active November 26, 2018 07:34
Python decorator for static functions and instance methods
# Author: aurzenligl (https://stackoverflow.com/users/7249587/aurzenligl)
# see https://stackoverflow.com/a/48836522/704244
from functools import wraps
def _declassify(fun, args):
if len(args):
met = getattr(args[0], fun.__name__, None)
if met:
wrap = getattr(met, '__func__', None)
if getattr(wrap, 'original', None) is fun: