Skip to main content

Measure the execution time of a function or endpoint in Flask

· 4 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

The best way to precisely measure the execution time of a function or endpoint in Flask is by using a decorator or middleware. This approach allows you to wrap your functions with timing logic without directly altering the original function's code, which keeps your application clean and maintainable.

Measure execution time of a function or endpoint in FastAPI

· 4 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

The best and most precise way to measure the execution time of a function or endpoint in FastAPI is by using a custom decorator or a middleware. This approach allows you to wrap your functions with timing logic without modifying the function's code itself, promoting clean, reusable, and maintainable code.

Annotate JSON schema properties in Python with msgspec

· 4 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

To annotate JSON schema properties in Python using msgspec, you use msgspec.field to provide metadata and constraints for a struct field. This allows you to define a more detailed schema beyond just the Python type hints, including documentation, default values, and validation rules.

JSON encode python with msgspec

· 3 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

To JSON-encode a Python object using msgspec, you use the msgspec.json.encode() function. This function takes a Python object and returns a bytes object containing the JSON representation. msgspec is known for its high performance and correctness in handling data serialization.

Here's a simple guide with examples.

Covert msgspec object to dict

· 2 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

To convert a msgspec object to a dict, you can use the msgspec.structs.asdict() function. This function recursively converts a msgspec.Struct instance into a dictionary, including any nested Struct objects.

Supabase Django integration

· 5 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Supabase Integration with Django

Here's a guide to integrating Supabase with a Django application. We will use the requests library to make API calls to Supabase, as there is no official Django-specific Supabase ORM.

Supabase FastAPI integration

· 4 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Supabase Integration with FastAPI

Here's a guide to integrating Supabase with a FastAPI application. We'll cover environment setup, connecting to Supabase, and performing basic CRUD operations.

Supabase Flask integration

· 5 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Here's a simple example of how to integrate Supabase with a Flask application. This guide will cover how to set up the environment, connect to your Supabase project, and perform basic CRUD (Create, Read, Update, Delete) operations.

Fix - you have divergent branches in Git

· 6 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

How to Fix "You have divergent branches" Error

The "You have divergent branches" error is a Git warning, not a hard error that stops your operation. It appears when your local branch and the corresponding remote branch have both moved forward, creating a divergent history. Git is telling you that a simple fast-forward merge is not possible and you need to choose a strategy to reconcile the differences before your next git pull.

The error message itself provides the three main solutions: merge, rebase, or fast-forward only.

OpenAPI $ref reusable parameter

· 4 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Using $ref to reference a reusable parameter in an OpenAPI specification is a key practice for keeping your API definitions clean, consistent, and maintainable. This method centralizes common parameters, like Authorization headers or a userId path parameter, in a single location and allows you to reference them from any endpoint.