Skip to content

Archive / page 73

All articles

Every practical article from the Nalar archive, newest first.

Software Engineering 05 Sep 2026 8 min read

Isolating Volatile Dependencies Behind Stable Boundaries

A dependency can be technically easy to call and still be expensive to change. A pricing library may rename operations between releases. A shipping provider may expose a model that changes as its API evolves. An internal rules engine may be rewritten while the business workflow around it stays largely the same. When application code uses those changing details everywhere, each dependency change becomes an application-wide edit. The problem is not simply that the dependency changes. The problem is that knowledge of how it works today has spread into code that has different reasons to change.

Tech 05 Sep 2026 8 min read

How Night Mode Helps Phone Cameras in Low Light

A phone can produce a surprisingly bright photo in a scene that looks very dark to your eyes. The result can seem as if the camera simply turned up the brightness, but modern night modes usually do much more than that. In low light, the camera has a basic problem: it receives fewer photons, the individual packets of light that an image sensor measures. With less light to work with, useful image information becomes harder to separate from noise. Night mode gives the camera more information and more time to build the final picture.

Tech 05 Sep 2026 8 min read

How File Thumbnails Work and Why Previews Sometimes Disappear

Open a folder of photos and you may see dozens of miniature images before opening a single file. A video may show a frame from the recording, while a document may display a tiny version of its first page. These small images are thumbnails: previews created to help you recognise files quickly. A thumbnail is usually not the file itself. It is a smaller representation that the operating system, file manager, photo application, or another program creates from the original data. That distinction explains why previews can appear slowly, become outdated, or disappear even when the original files are still intact.

Artificial Intelligence 05 Sep 2026 10 min read

Handle Label Noise in Supervised Learning

Supervised learning assumes that training examples come with useful target labels. Real datasets rarely satisfy that assumption perfectly. A support ticket may be assigned to the wrong queue, an image may receive the wrong class, or two annotators may interpret an ambiguous policy differently. These errors create label noise: the recorded target does not reliably represent the target the model is supposed to learn. Enough noise can teach a model contradictory patterns, distort evaluation, and make apparently difficult modeling problems into data-quality problems.

Software Engineering 05 Sep 2026 8 min read

Flattening Nested Conditionals with Guard Clauses

A function can be correct and still make its reader carry too much context. One common cause is deeply nested conditionals: before understanding the line in front of you, you must remember every condition that surrounds it. A guard clause handles a condition that prevents the main work from continuing, then exits the current operation early. Used carefully, guard clauses turn exceptional, invalid, or already-finished cases into short branches and leave the normal path at a shallower indentation level.

Cybersecurity 05 Sep 2026 11 min read

Fail Closed When Authorization Cannot Be Evaluated

An application may have correct authorization rules and still lose its security boundary when the component that evaluates those rules fails. A policy service can time out. A role lookup can return an error. Configuration can be unavailable. A programmer can catch the exception and continue because keeping the application online seems preferable to rejecting the request. If that fallback grants access, an availability problem has become an authorization bypass. The application is no longer saying, “this principal is allowed.” It is saying, “I could not determine whether this principal is allowed, so I will allow the action anyway.”

Artificial Intelligence 05 Sep 2026 11 min read

Evaluate Neural Networks with Exponential Moving Average Weights

Neural network parameters do not move smoothly toward a final solution. Stochastic optimization updates them using noisy minibatch gradients, so the weights used after one training step can differ slightly from those used after the next. Saving only the final step therefore makes one particular point on that training path responsible for evaluation and deployment. An exponential moving average, or EMA, keeps a second copy of the parameters that changes more gradually. Instead of replacing this copy with every new set of training weights, each update blends the previous average with the current parameters.

Artificial Intelligence 05 Sep 2026 12 min read

Estimate Neural Network Uncertainty with Monte Carlo Dropout

A neural network can produce a confident-looking prediction even when the input is unlike the data it learned from. A single output such as 0.93 tells you what one forward pass predicts; by itself, it does not tell you how sensitive that prediction is to uncertainty in the learned model. Monte Carlo dropout is a practical way to obtain an additional uncertainty signal from some neural networks that were trained with dropout. Instead of disabling dropout at inference time, you keep it active, run the same input through the network multiple times, and inspect how much the predictions vary.

Cybersecurity 05 Sep 2026 11 min read

Do Not Trust the Request Host for Security-Sensitive URLs

Applications sometimes need to create an absolute URL. A password-reset email, email-verification message, or security notification may need a link such as https://accounts.example.com/reset/... rather than a relative path. A tempting implementation takes the host name from the current HTTP request and combines it with the path. That is convenient, but it can quietly move a security decision into attacker-controlled input. If the deployment accepts an unexpected host value, the application may generate a valid security token inside a link pointing at the wrong site.

Artificial Intelligence 05 Sep 2026 9 min read

Diversify RAG Context with Maximum Marginal Relevance

A retrieval-augmented generation (RAG) system can retrieve highly relevant passages and still build poor context. The problem appears when several top results say almost the same thing. Sending all of them to the language model consumes context without adding much evidence, while a slightly lower-ranked passage containing a different useful fact may be excluded. Maximum marginal relevance (MMR) is a selection strategy for this situation. Instead of choosing passages only by their relevance to the query, MMR repeatedly chooses a passage that is both relevant and sufficiently different from passages already selected.

Artificial Intelligence 05 Sep 2026 9 min read

Direct Preference Optimization for Language Models

A language model can learn to imitate examples with supervised fine-tuning, but imitation alone does not directly express a common requirement: for the same prompt, one acceptable response may be preferable to another. Preference data represents that requirement as comparisons. A training record contains a prompt, a chosen response, and a rejected response. Direct preference optimization (DPO) uses those pairs to adjust a language model so that the chosen response becomes more favored relative to the rejected one, while comparing the update with a fixed reference model.

Software Engineering 05 Sep 2026 11 min read

Designing with Preconditions and Postconditions

A function can have a precise type signature and still leave its most important rules implicit. A transfer operation may accept two accounts and an amount, yet the signature does not tell you whether the amount may be zero, whether the source needs enough funds, or what must be true after a successful transfer. When these rules remain scattered through comments, conditionals, and tests, callers have to reconstruct the contract themselves. That makes misuse easier and changes harder to reason about.

Software Engineering 05 Sep 2026 8 min read

Designing Modules Around Information Hiding

A module can have a small public API and still be difficult to change. The problem appears when callers must know details that supposedly belong inside the module: a storage layout, a retry rule, a naming convention, a calculation step, or the order in which internal operations happen. When those details change, callers change too. The boundary exists in the code, but it does not contain the knowledge that creates maintenance work.

Software Engineering 05 Sep 2026 9 min read

Designing Interfaces Around Client Needs

A shared component often starts with a small interface. As more callers arrive, new methods are added until every caller sees operations it never uses. The interface still works, but it now connects unrelated needs through one contract. That matters because an interface is a dependency. When a client depends on a broad contract, changes to unrelated parts of that contract can affect its compilation, tests, mocks, generated code, or understanding of the component even when the client needs only one capability.

Software Engineering 05 Sep 2026 9 min read

Designing Idempotent Operations for Safe Retries

A caller sends a request to create a payment. The server processes it, but the response is lost because the connection closes. The caller now has a difficult choice: retry and risk charging twice, or stop and risk leaving the payment incomplete. This is not mainly a networking problem. It is an operation-design problem. When a caller cannot tell whether an attempt succeeded, retrying is only safe when the system has a way to recognize that the new attempt represents the same intent.

Cybersecurity 05 Sep 2026 9 min read

Design Recovery Codes as Backup Authenticators

Strong authentication creates a recovery problem: what happens when the user loses the device, key, or application that normally proves who they are? If recovery is much weaker than normal sign-in, an attacker can ignore the strong authenticator and target the fallback instead. If recovery is too difficult, legitimate users can permanently lose access. A recovery code is a secret generated in advance and kept by the user for this failure case. It acts as a backup authenticator: possession of the code can restore access when the normal authenticator is unavailable.

Cybersecurity 05 Sep 2026 11 min read

Design Encryption for Cryptographic Erasure

Deleting a database row or object does not necessarily remove every physical copy of its bytes. Storage systems may keep replicas, snapshots, backups, or blocks that are no longer visible through the application. When sensitive data must become inaccessible, finding and overwriting every copy can therefore be difficult. Encryption can change this problem. If data is encrypted under a key that can be reliably destroyed, destroying that key can make the remaining ciphertext infeasible to decrypt. This technique is called cryptographic erasure.

Database 05 Sep 2026 10 min read

Derive Row Values in SQLite with Generated Columns

Applications often store values that can be calculated from other columns: an order-line total from quantity and unit price, a normalized search key from text, or a duration from two timestamps. The tempting approach is to calculate the value in application code and save both the inputs and the result. That creates two sources of truth. If one code path updates the inputs but forgets to update the derived value, the row becomes internally inconsistent.

Linux 05 Sep 2026 9 min read

Create Sealable In-Memory Files on Linux with memfd_create

Applications often need a temporary chunk of data that behaves like a file without needing a persistent pathname. A process may build a configuration snapshot, compiled artifact, or serialized message, then map it into memory or pass it to another process. A regular temporary file can do that, but it introduces filesystem naming, cleanup, permissions, and lifetime concerns. An anonymous mmap() avoids the pathname, but it does not produce an ordinary file descriptor that can be passed to APIs expecting file-backed data.

Artificial Intelligence 05 Sep 2026 12 min read

Contrastive Decoding with Expert and Amateur Models

A language model can assign high probability to text that is fluent but unhelpfully generic, repetitive, or too close to an easy pattern. Changing temperature or top-p changes how tokens are sampled from one model’s distribution, but it does not ask a different question: which candidate tokens are especially characteristic of a stronger model rather than a weaker one? Contrastive decoding asks exactly that. It uses two language models at inference time: a stronger expert and a weaker amateur. A candidate is favored when the expert scores it well relative to the amateur, while a plausibility constraint prevents the decoder from choosing bizarre tokens merely because the amateur dislikes them even more.

Artificial Intelligence 05 Sep 2026 10 min read

Combine Retrieval Rankings with Reciprocal Rank Fusion

A retrieval-augmented generation (RAG) system often has more than one useful way to find evidence. Keyword retrieval is good at exact names, identifiers, and rare terms. Embedding retrieval can find passages that express the same idea with different wording. Using both can improve candidate coverage, but it creates a practical problem: their scores usually do not mean the same thing. A keyword score of 12.4 and a cosine similarity of 0.81 cannot be safely averaged just because both are numbers. Their scales, distributions, and even direction conventions depend on the retrieval methods and implementations.

Artificial Intelligence 05 Sep 2026 9 min read

Classifier-Free Guidance in Diffusion Models

A conditional diffusion model may understand a prompt and still produce samples that only weakly reflect it. During generation, developers therefore often want a way to push the denoising trajectory toward the condition without training a separate classifier for every prompt or label. Classifier-free guidance (CFG) is a widely used way to do that. At each denoising step, the model is evaluated with the condition and without it. The difference between those predictions gives a direction associated with the condition, and a guidance scale controls how strongly sampling moves along that direction.

Software Engineering 05 Sep 2026 9 min read

Characterization Tests for Legacy Code

Refactoring unfamiliar code creates an uncomfortable problem: you want to improve the implementation, but you may not know which parts of its current behavior callers depend on. Existing documentation can be incomplete, and a thin test suite may describe only the obvious cases. A characterization test helps by recording what the software does now. Instead of starting from a specification of what the code should do, you exercise existing behavior, observe the result, and turn that observation into a test. The test then warns you when a later change alters that behavior.

Python 05 Sep 2026 9 min read

Build Reliable Priority Queues in Python with heapq

A priority queue answers one question repeatedly: which pending item should run next? Schedulers, retry systems, graph algorithms, simulations, and background workers all need some version of that operation. A list can hold pending items, but finding the best one by scanning costs linear time each time. Keeping the whole list sorted makes retrieval cheap, but insertion has to preserve that full ordering. Python’s heapq module uses a heap instead. A heap is partially ordered: it guarantees that the smallest item is at heap[0], but it does not keep every element globally sorted. Push and pop operations take logarithmic time, while reading the current minimum is constant time.