Skip to content

Instantly share code, notes, and snippets.

@Niptlox
Niptlox / json_remove_keys.py
Created August 29, 2025 05:28
Recursively removes specified keys from nested dicts and lists, copying only changed parts.
def remove_keys_copy_on_write(obj, keys_to_delete):
"""
Recursively removes specified keys from a nested data structure (dicts and lists) using a
copy-on-write strategy. This means that only the parts of the structure containing the keys to be removed
are copied and modified, while the rest remains as references to the original objects.
Parameters:
- obj: The input nested data structure (can be a dict, list, or other types).
- keys_to_delete: A collection (set or list) of keys to be removed from dictionaries at any nesting level.
@Niptlox
Niptlox / Fastapi_log.py
Created August 22, 2025 07:42
Logging decorator for FastAPI
import logging
from fastapi import FastAPI, Request, Response
from functools import wraps
import json
app = FastAPI()
logger = logging.getLogger("my_logger")
def log_route(level: str = "info", log_body: bool = False):
def decorator(func):
Сумма_средних_длительностей_по_этапам =
VAR Этапы =
SUMMARIZE(
FILTER(
'этапы перевозки',
RELATED('перевозки'[продукт]) = SELECTEDVALUE('продукты'[id])
),
'этапы перевозки'[номер этапа],
"СредняяДлительность",
AVERAGEX(
@Niptlox
Niptlox / WorkManager.py
Last active July 15, 2025 12:42
Tkinter app for work task management
import tkinter as tk
from tkinter import ttk, messagebox, filedialog
import csv
from datetime import datetime
import os
import pandas as pd
class Task:
def __init__(self, name, archived=False):
self.name = name
DECLARE
v_count NUMBER;
BEGIN
FOR col IN (SELECT column_name FROM all_tab_columns WHERE table_name = 'WETAB') LOOP
EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM wetab WHERE ' || col.column_name || ' = 5000001'
INTO v_count;
IF v_count > 0 THEN
DBMS_OUTPUT.PUT_LINE('Значение найдено в столбце: ' || col.column_name);
END IF;
END LOOP;
@Niptlox
Niptlox / steps.py
Last active February 24, 2025 16:34
import logging
import math
import cv2
from rtmlib import Wholebody, draw_skeleton, BodyWithFeet, Body
from rtmlib.visualization import halpe26
log = logging.getLogger(__name__)