Skip to main content

How to Find a Bug with `git bisect` (Binary Search Debugging)

5 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

Finding a bug is like detective work-except the crime scene is your code, and the suspect is one of your last 200 commits. You know the code worked last week, and you know it's broken now, but finding the exact moment it failed can take hours of manual checking.

Enter git bisect. It uses a binary search algorithm to find the offending commit with mathematical efficiency. Instead of checking every commit, it cuts the search area in half every single time.

Use `git worktree` for Hotfixes: A Better Alternative to Stash

6 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

We have all been there: you are deep in the zone, half-way through building a complex new feature, and your terminal is full of uncommitted changes. Suddenly, you get a message from your team: "Critical bug in production! We need a hotfix right now!"

The traditional response is to use git stash, switch to main, fix the bug, and then try to un-stash your messy feature branch later. But if you have complex dependencies (like node_modules or .venv) or untracked files, stashing can lead to absolute chaos.

This is where git worktree comes in. It is the professional's secret weapon for parallel development.

How to Fix 'fatal: cannot delete branch used by worktree' in Git

6 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

Git provides safeguards to protect your active code branches from accidental deletion. When you try to delete a branch and receive the error: fatal: cannot delete branch 'xyz' used by worktree at '/path/to/folder', Git is warning you that the branch is currently checked out and actively linked to another working directory on your machine.

Here is why this error occurs, how to resolve it using three different methods, and how to use the listing commands to manage your workspace.

How to create a 5-color palette where EVERY color is readable against EVERY other color with Python

6 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

Creating a color palette where every color is readable against every other color is a high-level design challenge. As the number of colors in your palette increases, the "contrast space" shrinks significantly.

In this article, we'll build a script that uses an iterative "Collision-Check" algorithm. It generates a candidate color, checks it against every color already in the palette, and only keeps it if it passes the WCAG AA threshold against all of them.

Contrast Checker: How to Calculate Color Contrast in Python

6 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

Designing a beautiful UI is pointless if half your users can't read it. Whether it's a person with a visual impairment or someone trying to check their phone on a sunny day, color contrast is the secret sauce of accessible design.

The WCAG (Web Content Accessibility Guidelines) provides a mathematical way to ensure text stands out against its background. Let's integrate a "Contrast Checker" into our Python toolkit.

How to convert colors in Python: A Comprehensive Guide to RGB, HSL, HWB, CMYK, and HEX

6 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

Converting colors in Python is a fascinating mix of dictionary lookups (for names like "tomato") and coordinate geometry. While we can use the built-in colorsys module for some parts, we'll need the webcolors library to handle CSS names and some custom math to reach the more "exotic" formats like HWB and CMYK.

Detect Google AdSense with Python: From Fast HTTP Scraping to Playwright Stealth

8 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

Detecting whether a website is running Google AdSense is a common task for digital marketers, SEO researchers, and competitive intelligence analysts. AdSense works by injecting a specific JavaScript library into the page, accompanied by a unique Publisher ID (formatted as pub-xxxxxxxxxxxxxxxx) and ad container tags (<ins class="adsbygoogle">).

Depending on whether the target website uses static HTML, lazy loading, or Web Application Firewalls (Cloudflare/Akamai), you need different strategies ranging from lightweight HTTP requests to full browser automation with Playwright.

How to Download YouTube Thumbnails in Python (Without Pytube)

5 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

Downloading a YouTube thumbnail is a classic Python task that involves two main steps: extracting the unique Video ID from a URL and then fetching the image from Google's thumbnail servers.

Because YouTube uses a predictable URL structure for its images, you don't actually need the heavy pytube library just to get the thumbnail-standard requests will do the trick!

Analyzing YouTube Data: Comment Sentiment and Metadata Extraction with Python

7 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

Analyzing video metrics and comment threads is a powerful way to leverage Python for data science, market research, or content optimization. By analyzing the public reception of a video, you can measure audience mood and extract key metadata features.

This guide demonstrates how to build a complete YouTube data extraction pipeline using two separate strategies:

  1. Metadata Extraction: Retrieving views, tags, categories, and upload details using yt-dlp (no API key required).
  2. Comment Sentiment Analysis: Scoping comment sections to calculate positive or negative audience polarity using the official YouTube Data API v3 and TextBlob.

SimpleEval with Examples

5 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

While simpleeval is great for basic calculators, its true power shines in production environments where you need to let users define their own logic-like setting up custom alerts, dynamic pricing discounts, or conditional triggers-without exposing your server to malicious code execution.

Looking for more content?
Hrekov Blog contains 165 articles. Browse the blog archive or Explore the full timeline.