Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env -S uv run
# /// script
# requires-python = ">=3.10"
# ///
"""Convert a Pipfile to requirements.txt format.
Usage:
pipfile-to-reqs.py [-d|--dev] [Pipfile]
This will output the dependencies in a format suitable for a requirements.txt file.
@datavudeja
datavudeja / utils.py
Created January 25, 2026 21:11 — forked from robpotter89/utils.py
assorted util functions
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2010 Radim Rehurek <[email protected]>
# Licensed under the GNU LGPL v2.1 - http://www.gnu.org/licenses/lgpl.html
"""Various general utility functions."""
from __future__ import with_statement
from contextlib import contextmanager
@datavudeja
datavudeja / cache.py
Created January 25, 2026 21:08 — forked from bschug/cache.py
SQLite-backed function call cache for storing expensive calculations or data generated from API calls.
import logging
from datetime import datetime, timedelta
from contextlib import closing, contextmanager
import sqlite3
logger = logging.getLogger('util.cache')
logger.setLevel(logging.WARNING)
import argparse
import os
import sys
import time
from collections import defaultdict
from datetime import datetime
from pathlib import Path
from types import SimpleNamespace
import cv2
@datavudeja
datavudeja / conftest.py
Created January 21, 2026 14:20 — forked from HardMax71/conftest.py
Pydantic model <-> neomodel OGM (neo4j) <-> python dict converter
# ./tests/conftest.py
import pytest
from neomodel import config, db
from converter import Converter
@pytest.fixture(scope="session")
def db_connection():
"""Setup Neo4j database connection for all tests"""
"""Inference pipelines and utilities.
This module contains the classes and high level APIs for predicting instances on new
data using trained models.
The inference logic is implemented at two levels:
- Low-level `InferenceModel`s which subclass `tf.keras.Model` and implement the core
TensorFlow operations surrounding inference. These should only be used when
implementing custom inference routines, such as real-time or performance-critical
@datavudeja
datavudeja / README.md
Created January 21, 2026 14:13 — forked from leonardbinet/README.md
Python spier decorator

Suppose you want to want to track all calls (args, kwargs and result) made to a given method while running a command, you can do it using the simple decorator defined in the spy.py module of this gist.

Usage

You can use it to spy either on a single instance or to all instances of given class.

The calls will be stored in a list that must be passed by instantiated beforehand and passed to the decorator.

Spy on single instance

@datavudeja
datavudeja / countmeta.py
Created January 21, 2026 14:11 — forked from isubuz/countmeta.py
Counting instances per class using metaclass
"""
A mechanism to keep track of no. of class instances created.
"""
from __future__ import print_function
class CountInstances(type):
def __new__(meta, classname, supers, classdict):
classdict['numInstances'] = 0
return type.__new__(meta, classname, supers, classdict)
@datavudeja
datavudeja / shell_cmd.py
Created January 8, 2026 17:59 — forked from awesomebytes/shell_cmd.py
Spawn a shell with a command with some extra options
#!/usr/bin/env python
import subprocess
import tempfile
import os
import signal
class ShellCmd:
"""Helpful class to spawn commands and keep track of them"""
@datavudeja
datavudeja / cloudflare_ddns.py
Created January 8, 2026 17:57 — forked from nourselim0/cloudflare_ddns.py
Cloudflare Dynamic DNS
import json
import os
import sys
import tempfile
from typing import cast
import requests
from requests.models import Response
CLOUDFLARE_API_TOKEN = "YOUR_API_TOKEN"