Skip to content

Archive / page 60

All articles

Every practical article from the Nalar archive, newest first.

Artificial Intelligence 08 Sep 2026 9 min read

Masked Autoencoders for Visual Representation Learning

Labeled image datasets are expensive to build, but unlabeled images are often plentiful. A useful pretraining strategy is therefore to create a learning signal from each image itself instead of asking a human to annotate it. A masked autoencoder (MAE) does this by hiding part of an image and training a model to reconstruct the missing content. The reconstruction task is not usually the final product. Its purpose is to make the encoder learn visual representations that can later support tasks such as classification or detection.

Software Engineering 08 Sep 2026 10 min read

Making Resource Ownership Explicit

A function opens a file and returns a parser. A factory creates a client backed by a connection pool. A component starts a worker and hands another component a handle. Everything works until shutdown, an exception, or a refactor exposes a basic question that the design never answered: who is responsible for releasing the resource? Resource leaks are often described as missing cleanup calls. That is only the visible failure. The deeper design problem is ambiguous ownership. If several parts of the program can use a resource but none clearly owns its lifetime, cleanup becomes guesswork.

Software Engineering 08 Sep 2026 10 min read

Making Invalid States Hard to Represent

A function receives an Order and immediately checks whether its total is negative, its currency is missing, and its status is compatible with its payment state. Another function repeats some of those checks. A third forgets one. The codebase contains validation everywhere, yet invalid combinations still appear. The deeper problem is not a shortage of if statements. The program allows states that its own rules say should never exist, then asks every consumer to defend itself against them.

Cybersecurity 08 Sep 2026 10 min read

Make Destructive Actions Recoverable Before They Become Permanent

A delete button can turn one stolen session, one excessive permission, or one operator mistake into permanent data loss. Authentication and authorization still matter, but they answer only whether a request is allowed now. They do not answer whether the effect should become irreversible immediately. For data whose loss would be costly, a useful defensive pattern is to separate logical deletion from permanent deletion. The first step removes the object from normal use without destroying the underlying recovery copy. Permanent deletion happens later, after a defined recovery window or a stronger authorization step.

Artificial Intelligence 08 Sep 2026 9 min read

Load Balancing in Mixture-of-Experts Models

A mixture-of-experts model can contain many expert networks while activating only a small subset for each token. That sparse computation is attractive because the model can have more parameters without evaluating every parameter for every token. But sparsity creates a new problem: the router can send too many tokens to the same experts. If one expert receives most of a batch while others sit nearly idle, the model does not get the practical benefit that its expert count suggests. In systems with fixed expert capacity, overloaded experts can also overflow, so some token-to-expert assignments cannot be processed as intended.

Software Engineering 08 Sep 2026 8 min read

Keeping Behavior Close to the Data It Uses

A method can live in the wrong place even when its code is correct. One common sign is a method that repeatedly reads another object’s fields, interprets those values, and makes a decision that is really about that other object. This creates a maintenance problem. The data and the rules governing that data change for related reasons, but the code is stored in different places. A small change to the meaning of the data can then require developers to find and update distant callers.

Cybersecurity 08 Sep 2026 9 min read

Keep Untrusted Data Out of Object Deserializers

A serialized object can look like ordinary input: bytes arrive from a request, queue, cache, file, or database and the application turns them back into an object. The important difference is that some object deserializers do more than decode values. They can choose application types, reconstruct object graphs, and invoke type-specific behavior while reconstruction is happening. That makes object deserialization a security boundary. If an attacker can influence the serialized bytes, treating those bytes as instructions for rebuilding application objects can lead to unexpected state, denial of service, or, with some formats and available types, code execution.

Cybersecurity 08 Sep 2026 9 min read

Keep Sensitive Data Out of Security Logs

Security logs are supposed to help when something goes wrong. They become a new security problem when they copy the very data you are trying to protect. A login handler that records a submitted password, an API gateway that stores bearer tokens, or an error logger that captures an entire request body can move sensitive values into systems with different readers, retention periods, backups, and exports. A compromise of the logging path may then expose credentials or personal data even when the primary application database remains protected.

Python 08 Sep 2026 6 min read

Keep Request State Local with Python contextvars

Passing a request ID through every function is explicit, but after a few layers it can become noise. Logging is the example I keep running into: the logger needs the request ID, while most business functions do not actually care about it. A global variable looks tempting until two requests run concurrently. threading.local() fixes a different problem, but one event-loop thread can execute many asyncio tasks. Python’s contextvars module is designed for this kind of context-local state.

Python 08 Sep 2026 8 min read

Inspect ZIP Archives Before Extraction in Python

ZIP extraction looks like a single filesystem operation, but an archive is really a collection of filenames, metadata, and compressed byte streams supplied by whoever created the file. When the archive is untrusted, that metadata belongs at a trust boundary. Python’s zipfile module provides convenient extraction helpers, and those helpers include protections for suspicious path components. The documentation still warns against extracting untrusted archives without prior inspection. That distinction is useful: library normalization is not the same thing as an application-specific acceptance policy.

Software Engineering 08 Sep 2026 9 min read

Information Hiding as a Design Tool

A module can have private fields and still expose too much. Callers may know which storage format it uses, which sequence of operations is required, or which implementation rule determines a result. When that hidden-looking detail changes, code outside the module must change with it. Information hiding is a design principle for preventing that spread. The idea is simple: identify a design decision that other code should not need to know, then place that decision behind a boundary whose public contract can remain stable when the decision changes.

Tech Updated 15 Sep 2026 8 min read

Headphone Impedance vs Sensitivity: What Determines How Loud They Get

Two wired headphones can behave very differently when connected to the same phone, laptop, or audio interface. One may become comfortably loud at a modest volume setting, while another remains quiet even near the top of the volume range. The explanation is often reduced to one specification: impedance, measured in ohms. You may hear that low-impedance headphones are easy to drive and high-impedance headphones need an amplifier. That can be useful as a rough clue, but it leaves out another important specification: sensitivity.

Python 08 Sep 2026 8 min read

Handle Time Zones Correctly with Python zoneinfo

Time-zone code becomes difficult when an application needs more than a fixed UTC offset. Civil-time rules change, daylight-saving transitions can repeat or skip local clock readings, and the rules for a place are not captured by labels such as UTC+7 or UTC-5. Python 3.9 added zoneinfo to the standard library to provide IANA time-zone support through the familiar datetime API. It is the right starting point when an application needs rules for named zones such as Asia/Jakarta, Europe/Berlin, or America/New_York.

Database 08 Sep 2026 8 min read

Get Changed Rows Directly with SQLite RETURNING

A database write often creates information the application immediately needs. An INSERT may generate an ID and timestamp. An UPDATE may calculate a new counter. A DELETE may need to return enough data for an audit event. The familiar approach is to write first and query afterward, but SQLite has a cleaner option for many of these cases: RETURNING. Here’s the idea: INSERT INTO jobs (name) VALUES ('resize-images') RETURNING id, name, created_at; The write and the values I care about stay in one SQL statement. That is convenient, but the more interesting part is understanding exactly what RETURNING promises—and what it does not.

Python 08 Sep 2026 7 min read

Generate Time-Ordered IDs with Python UUIDv7

Random UUIDs are convenient identifiers: they can be generated without coordinating with a database, and the probability of collision is tiny. But a UUIDv4 primary key has one awkward property for ordered indexes: newly generated values are spread across the key space instead of tending toward the end of the index. UUID version 7 keeps the decentralized 128-bit UUID shape while putting a Unix-epoch millisecond timestamp at the front. Python 3.14 adds uuid.uuid7() to the standard library, so applications no longer need a third-party package just to generate RFC 9562 UUIDv7 values.

Software Engineering 08 Sep 2026 9 min read

Functional Core, Imperative Shell for Testable Business Logic

Business logic often becomes difficult to test for a reason that has little to do with the rule itself. A function that decides whether to approve a refund may also read a database, check the clock, call another service, write an audit record, and send a message. The decision is now mixed with the machinery required to obtain inputs and apply outputs. Tests must control all of that machinery just to ask, “What should happen for this refund?”

Software Engineering 08 Sep 2026 9 min read

Finding Regressions with Binary Search

A regression appears in the current build, but the same behavior worked two weeks ago. Since then, the team has merged 80 changes. Reading all 80 diffs is possible, but it is slow and gives every change equal attention even though only one boundary in history matters: the point where the behavior changed from working to broken. When revisions are ordered and you can classify a revision reliably as good or bad, you can search that history with the same idea as binary search. Test a revision near the middle. Its result tells you which half can still contain the first bad revision. Repeat until only the transition remains.

Artificial Intelligence 08 Sep 2026 11 min read

Filter Synthetic Training Data with Rejection Sampling

Generating synthetic examples is easy; generating synthetic examples that are worth training on is harder. A language model can produce thousands of candidate answers, but blindly adding them to a training set can reinforce factual errors, weak reasoning, unwanted style, or artifacts of the generator itself. Rejection sampling provides a simple mental model for controlling that pipeline: generate one or more candidates, evaluate each candidate with an acceptance rule, and keep only candidates that pass. The acceptance rule might use deterministic checks, a learned reward model, another language model, human review, or a combination of signals.

Artificial Intelligence 08 Sep 2026 8 min read

Estimate LLM Uncertainty with Semantic Entropy

A language model can produce a fluent answer even when it is uncertain. Token probabilities help describe uncertainty during generation, but they can be misleading at the answer level because many different strings can express the same meaning. Consider a question whose correct answer is Paris. A model might generate Paris, The answer is Paris, and France's capital is Paris. These strings differ, yet they represent the same answer. Treating them as three unrelated outcomes exaggerates the apparent uncertainty.

Software Engineering 08 Sep 2026 9 min read

Enforcing Architecture with Fitness Functions

A team can agree on a sensible architecture and still watch it erode one small change at a time. A developer imports an internal module because it is convenient. Another adds a direct dependency across layers. Months later, the diagram still shows clean boundaries, but the code no longer follows them. Code review can catch these changes, but reviewers must remember every architectural rule and notice every violation. For properties that matter repeatedly, memory is a weak enforcement mechanism.

Database 08 Sep 2026 8 min read

Enforce Column Types with SQLite STRICT Tables

SQLite’s flexible typing is useful until an application accidentally relies on it. I have seen schemas declare an INTEGER column and then assume that every stored value must be an integer. In an ordinary SQLite table, that assumption is too strong: SQLite can preserve a value that cannot be converted to the column’s preferred type. That flexibility is intentional, but for application data I often want mistakes to fail at the write boundary instead of surfacing later in a query.

Artificial Intelligence 08 Sep 2026 10 min read

Dynamical Isometry in Neural Networks

A deep neural network can look well scaled one layer at a time and still be difficult to optimize. Signals pass through many transformations, and small expansions or contractions can multiply with depth. By the time a gradient travels through the whole network, some directions may have nearly disappeared while others have been amplified dramatically. Dynamical isometry gives a precise way to reason about this problem. Instead of asking only whether the average gradient magnitude is reasonable, it asks how the network transforms different directions in its input space. The relevant object is the input-output Jacobian, and its singular values provide the main measurements.

Software Engineering 08 Sep 2026 10 min read

Differential Testing to Compare Implementations

Replacing an implementation creates an uncomfortable testing problem. You may know that the new code should preserve existing behavior, but writing an expected result for every possible input can be expensive. A parser may accept thousands of valid forms. A pricing engine may combine many rules. A rewritten library may have years of accumulated edge cases. In these situations, an implementation you already trust can help test another implementation. Differential testing runs the same input through two or more implementations that are expected to behave equivalently, then compares their observable results. A disagreement does not automatically prove which implementation is wrong. It does something more basic and extremely useful: it gives you a concrete case that requires explanation.

Cybersecurity 08 Sep 2026 11 min read

Detect Security Configuration Drift Before It Becomes Exposure

A service can start with a careful security configuration and still become exposed later. A debug endpoint is enabled during an incident and never disabled. An access rule is widened for a migration. A storage policy changes outside the normal deployment path. None of these failures requires a new software vulnerability. The security boundary changed because the running configuration stopped matching the state the team intended. This kind of divergence is configuration drift: a meaningful difference between an approved or expected configuration and the configuration that actually controls a system. Drift matters when the changed setting affects who can reach a resource, what they can do, what data is exposed, or which security controls remain active.