Welcome to ShallowDepth

Hi! My name is Stan. I am a Python and Javascript developer. Here I write about software development – from vetting ideas, planning, and project management to implementation details.

Why useNavigate hook in react-router v6 triggers waste re-renders and how to solve it

While optimizing performance in one of my React.js projects I stumbled upon components re-rendering for no apparent reason whatsoever. After some experiments the culprit was found: import { useNavigate } from "react-router-dom" // v6 const Component = () => { const navigate = useNavigate() ... } Turns out that if you use the useNavigate hook in a component, it will re-render on every call to navigate() or click on <Link />, even if the path has not changed....

2022-04-28 · 3 min
TodoX -- task manager and time tracker

TodoX: task manager and time tracker

For the past 1.5 years, I’ve been developing TodoX in my free time – a task manager and time tracker. Now the project is in the state I am not too ashamed to show to other people. This post is not only a shameless plug 🥸, but a story about reasons for creating TodoX, choosing the stack, testing, DevOps, challenges, good and bad decisions. Does the world need one more “productivity” tool?...

2022-04-14 · 9 min

New section: Useful bits

Working in IT requires a lot of general and tool-specific knowledge. Most of these skills, tips and tricks are too small to deserve a separate post. Therefore, I compiled this knowledge into a sort of today-I-learned or Cheat-sheet summaries in a new section: Useful bits. This is an ongoing process, both of codifying already known, and of recording new findings.

2022-03-15 · 1 min

Performance of application-defined functions and collations in SQLite

When writing the post on Unicode case-insensitive search in SQLite I got interested in the performance of application-defined functions and collations: they must introduce overhead, the question is how much and whether it is something to be concerned about. To answer these questions I made a simple test suite measuring the performance of both built-in SQLite and application-defined functions and collations – the full code is at the very end of the post....

2022-01-26 · 10 min

Transform any Telegram bot into (almost) an app

Telegram bots are powerful tools that can do a lot of things. However, they have at least one major drawback: to use a bot you have to find the Telegram app, open it, find and, finally, open the bot. It introduces significant overhead and friction, reducing the likelihood that the bot will be used. Turns out, you can create a shortcut for any one on one chat with a bot – it will open the Telegram app and required chat automatically....

2022-01-13 · 3 min

5 ways to implement case-insensitive search in SQLite with full Unicode support

Recently I needed a case-insensitive search in SQLite to check if an item with the same name already exists in one of my projects – listOK. At first, it looked like a simple task, but upon deeper dive, it turned out to be easy, but not simple at all, with many twists and turns. Built-in SQLite capabilities and their drawbacks In SQLite you can get a case-insensitive search in three ways:...

2022-01-10 · 13 min

What would this look like if it were easy?

Have you ever started a project, be it personal or professional, software or not, but it lost steam even before the first version? Or, if the project got to the finish line, you already hated it for taking too long and being much more demanding than expected? Asking for a friend. In all seriousness, been there, tried that, more times than I care to admit. And I have seen it happen to other people as well....

2021-12-20 · 4 min

End-to-end tests for Telegram bots

I think there is no need to say that automatic testing is a must in software development. Tests improve the quality of the code, give confidence in it and make it more stable. However, not all tests are created equal: they differ both in what they test and how hard it is to set them up and maintain. For instance, it is relatively easy to write unit tests. In turn, they tell you very little about how your system will behave in production....

2021-12-13 · 12 min

Using Python decorators to process and authorize requests

When building any system that interacts with users you always need to check that they are who they are claiming to be and whether they are allowed to do what they are trying to do. In other words, you need to authenticate and authorize users. Chatbots are no exception. Strictly speaking, with chatbots you do not need to authenticate users yourself – the platform does it for you. However, on each request you still have to load the user model and authorize it....

2021-12-06 · 5 min

Chia (XCH): farm vs. buy – a model for comparison

Let’s assume that we what to invest some money in Chia, either we believe in it or just as a speculative bet, preferably part of a diversified crypto portfolio. Is it better today to buy the hardware and farm or just buy Chia tokens XCH?

2021-11-29 · 11 min