Skip to content

Archive / page 86

All articles

Every practical article from the Nalar archive, newest first.

Python 02 Sep 2026 9 min read

Practical Queues and Sliding Windows with Python deque

Many programs need a sequence that changes at both ends. A worker may append new jobs on the right and consume the oldest job from the left. A monitoring loop may keep only the most recent measurements. An algorithm may need to add or remove candidates from either side while scanning an input stream. A Python list is excellent when random access and operations near the right end dominate. It is a poor fit for a FIFO queue that repeatedly removes index zero, because the remaining list elements must be shifted. The collections.deque type is designed for efficient appends and pops at both ends.

Python 02 Sep 2026 10 min read

Practical Priority Queues in Python with heapq

Many programs need to repeatedly choose the most important pending item rather than process items in insertion order. Schedulers pick the next deadline, graph algorithms choose the lowest-cost candidate, and streaming systems keep only the best few observations seen so far. A sorted list can solve these problems, but maintaining full ordering is often unnecessary. Python’s heapq module provides a heap: a compact data structure that keeps one extreme element immediately available while doing only enough work to preserve that property.

Python 02 Sep 2026 8 min read

Practical Function Specialization in Python with functools.partial

Functions often expose more parameters than a particular caller needs to choose. A parser may always use the same base, a callback may need access to one application object, or a formatting function may use a fixed prefix throughout one subsystem. Python’s functools.partial() can turn such a general callable into a more focused callable by binding some arguments in advance. The result remains callable, so it can be passed to APIs that expect a function-like object without introducing a wrapper function solely to carry configuration.

Python 02 Sep 2026 9 min read

Practical File Paths in Python with pathlib

Filesystem paths look simple until code has to run from a different working directory, support multiple operating systems, handle symbolic links, or distinguish path manipulation from actual filesystem access. Python’s pathlib module provides path objects that make those distinctions explicit. Instead of repeatedly joining and splitting strings, code can express operations such as “the parent directory,” “this file’s suffix,” or “this path relative to that directory” directly. The most useful habit is not merely replacing os.path calls with methods. It is understanding which pathlib operations are lexical, which consult the filesystem, and when resolving a path changes its meaning.

Cybersecurity 02 Sep 2026 5 min read

Practical CSRF Defense with SameSite Cookies and Tokens

Cross-site request forgery (CSRF) abuses the fact that browsers can automatically attach a user’s cookies to requests. If a state-changing endpoint trusts only the presence of an authenticated cookie, another site may be able to trigger that endpoint from the user’s browser. Modern cookie controls reduce the attack surface, but robust applications still need to reason about request semantics and trust boundaries. Understand the condition that makes CSRF possible A typical CSRF attack needs three ingredients:

CSS 02 Sep 2026 6 min read

Practical Conditional Styling with the CSS :has() Selector

CSS traditionally selects an element from information about that element or its ancestors. The :has() relational pseudo-class adds a different capability: an element can match according to relative selectors evaluated from that element. This makes many parent-aware and sibling-aware styles possible without adding state classes solely for presentation. The useful mental model is not “select the parent,” but “select this element if a related element matches a condition.” Read :has() from the outside in Consider a card that should use a different layout when it contains a direct image child:

Database 02 Sep 2026 7 min read

PostgreSQL Partial Indexes for Focused Query Workloads

A normal PostgreSQL index contains entries for every table row that has indexable values. That is often appropriate, but some workloads repeatedly query a small, well-defined subset of a much larger table. A partial index stores entries only for rows that satisfy an index predicate. When the predicate matches a stable access pattern, the index can be smaller and cheaper to maintain than an equivalent full-table index. The trade-off is specificity: PostgreSQL can use the partial index only when it can determine at planning time that the query condition implies the index predicate.

Software Engineering 02 Sep 2026 5 min read

Parallel Change for Safe Interface Refactoring

Changing a shared interface is risky when many callers depend on it. A large “update everything at once” patch can work in a small codebase, but it becomes harder to review, deploy, and roll back as dependencies spread across modules or services. Parallel change is a refactoring technique that keeps old and new interfaces working side by side for a limited period. The migration happens in three stages: expand, migrate, and contract.

Tech 02 Sep 2026 6 min read

Mesh Wi-Fi vs a Traditional Router: What Changes at Home?

A traditional home Wi-Fi setup often has one wireless router serving the entire house. A mesh Wi-Fi system instead uses multiple coordinated access points, commonly called nodes, placed in different areas. The main reason to choose mesh is coverage. It can bring a strong local Wi-Fi signal closer to rooms that are difficult for one router to reach. It does not, however, create a faster internet subscription or guarantee higher speeds everywhere.

Software Engineering 02 Sep 2026 7 min read

Managing Dependencies as Explicit Boundaries

Third-party libraries save engineering time, but every dependency also adds a contract that your software must live with. That contract includes more than function signatures. It can include configuration formats, exceptions, lifecycle rules, performance characteristics, release policies, and assumptions that spread through application code. Dependency management is therefore partly a software design problem. The goal is not to avoid dependencies. It is to make important dependencies explicit, contained, and inexpensive to change.

Python 02 Sep 2026 8 min read

Maintain Sorted Sequences in Python with bisect

A sorted list is useful when a program needs ordered iteration and frequent searches but does not require the repeated minimum extraction of a priority queue. Python’s bisect module provides binary-search operations for this exact representation. The module does not create a special container. It works with an existing sorted sequence and finds the position where a value belongs. That makes it small and predictable, but it also means the caller is responsible for preserving sorted order and understanding that inserting into a Python list still requires moving elements.

Cloud Computing 02 Sep 2026 5 min read

Load Shedding and Overload Protection for Cloud Services

Autoscaling is useful, but it is not instantaneous. Traffic can rise faster than new instances start, a dependency can slow down, or a retry storm can multiply work. When demand exceeds safe capacity, accepting every request can make the entire service slower until almost nothing completes. Load shedding is the deliberate rejection or degradation of work to keep the system inside a recoverable operating range. Overload is often a queueing problem Imagine a service that safely handles 200 concurrent requests. A downstream dependency slows from 50 ms to 2 seconds.

Software Engineering 02 Sep 2026 7 min read

Load Shedding and Bounded Queues for Overload Control

A service can be healthy at 500 requests per second and unusable at 700. The extra load does not merely make every request 40 percent slower. Queues grow, deadlines expire while work is still waiting, memory usage rises, retries create more traffic, and useful requests compete with work that can no longer finish in time. Overload control keeps that failure mode bounded. Instead of accepting unlimited work, a service limits concurrency and queueing, then rejects or degrades excess work early enough for the remaining requests to succeed.

Go 02 Sep 2026 4 min read

Lazy Initialization in Go with sync.OnceValue and sync.OnceValues

Lazy initialization is useful when a value is expensive to build and may never be needed. The difficulty is making that initialization safe when several goroutines request the value at the same time. Go has long provided sync.Once. Since Go 1.21, the sync package also includes OnceValue and OnceValues, helpers that return functions which compute results once and reuse them for later calls. The manual sync.Once pattern A classic implementation looks like this:

JavaScript 02 Sep 2026 6 min read

JavaScript Property Descriptors with Object.defineProperty

Most JavaScript properties are created with assignment or object literals. That is usually the right choice, but it hides several controls that every property carries: whether the property can be assigned, whether common enumeration APIs expose it, and whether its definition can later be changed. Property descriptors make those controls explicit. They are useful for library APIs, metadata, computed properties, compatibility layers, and cases where ordinary assignment exposes more behavior than intended.

Rust 02 Sep 2026 4 min read

Interior Mutability in Rust with RefCell

Rust normally enforces borrowing at compile time: either one mutable reference or any number of immutable references may exist at a given moment. That rule prevents data races and many aliasing bugs before the program runs. Sometimes the compiler cannot prove that a safe mutation pattern is valid, even though the program can enforce the rule dynamically. RefCell<T> provides interior mutability for those cases by moving borrow checking from compile time to runtime.

Linux 02 Sep 2026 5 min read

Inspect Process Isolation with Linux Namespaces

Containers rely on several Linux kernel features, but namespaces provide much of the process-level isolation people notice first. They let different groups of processes see different views of resources such as process IDs, mounts, hostnames, and network interfaces. You do not need a container runtime to inspect namespaces. Standard Linux tools and /proc expose the relationships directly. What a namespace changes A namespace virtualizes one class of global system resource.

CSS 02 Sep 2026 4 min read

Individual CSS Transform Properties for Maintainable UI Motion

For years, CSS transforms were commonly written as one transform declaration: .card { transform: translateY(-4px) scale(1.02); } That works, but it couples every transform operation to one property. A component that needs to change only its translation must either reproduce the existing scale or overwrite it.

Web Development 02 Sep 2026 5 min read

HTTP Range Requests for Efficient Partial Downloads

HTTP range requests let a client ask for only part of a representation instead of downloading the entire body. They are useful for resumable downloads, media seeking, large files, and clients that need a known byte segment. The core mechanism is simple, but correct servers need to distinguish valid ranges, unsatisfiable ranges, validators, and ordinary full responses. A client requests a byte range A request can include: Range: bytes=1000-1999 If the server supports the request and the selected representation is 8,000 bytes long, it can respond:

Web Development 02 Sep 2026 5 min read

HTTP Content Negotiation and Correct Vary Headers

One URL can sometimes represent the same resource in several formats. An API might return JSON or CSV, while a documentation endpoint might return HTML or plain text. HTTP content negotiation lets a client express which representation it can accept. The server chooses a response and tells caches which request headers influenced that choice. The second part is easy to miss: if the response changes based on a request header, shared caches need the correct Vary metadata.

Tech 02 Sep 2026 6 min read

How to Free Up Phone Storage Without Deleting the Wrong Things

A phone can run low on storage even when it does not seem to contain many obvious files. Photos, videos, app data, downloads, offline media, message attachments, cached files, and temporary data can all grow quietly over time. The safest way to recover space is not to start deleting at random. First identify what is using storage, then remove items whose purpose you understand. That reduces the chance of losing important photos, documents, conversations, or app data.

Tech 02 Sep 2026 7 min read

How Phone Hotspots Share Mobile Internet

A phone can do more than use its own mobile data connection. With a mobile hotspot, it can also share that connection with a laptop, tablet, or another device. This is useful when normal Wi-Fi is unavailable, but a hotspot is not simply a miniature replacement for a home broadband connection. Its performance depends on both the phone’s cellular link and the local connection between the phone and the device using it.

Tech Updated 15 Sep 2026 8 min read

How Bluetooth Audio Codecs Affect Wireless Listening

Wireless headphones often advertise support for audio codecs such as SBC, AAC, aptX, or LDAC. These names can make Bluetooth audio seem more complicated than it needs to be. A codec is simply part of the process used to represent audio efficiently enough to send it over a Bluetooth connection. Codec support can influence sound quality, latency, bandwidth use, and connection stability, but the codec name alone does not determine how good a pair of headphones will sound.

Tech Updated 15 Sep 2026 7 min read

How Adaptive Brightness Works on Phones and Laptops

Modern phones and many laptops can change screen brightness automatically as lighting conditions change. Walk from a dim room into bright daylight and the display may become brighter; return indoors and it may gradually dim again. This feature is commonly called adaptive brightness, automatic brightness, or a similar name. It can make a display easier to see while reducing unnecessary power use, but it does not simply choose one fixed brightness for every room.