Skip to content

Archive / page 81

All articles

Every practical article from the Nalar archive, newest first.

Artificial Intelligence 03 Sep 2026 10 min read

Stabilize Neural Network Training with Gradient Clipping

Neural network training can look healthy for many steps and then suddenly become unstable. The loss may jump, parameters may receive an unusually large update, or numerical values may become non-finite. One possible cause is an exploding gradient: the gradient becomes large enough that the resulting optimization step is destructive. Gradient clipping puts a limit on gradients before the optimizer uses them. It is especially useful when occasional gradient spikes are expected, but it is not a general repair for a bad learning rate, broken data, or an incorrect training loop.

Artificial Intelligence 03 Sep 2026 10 min read

Speculative Decoding for Faster LLM Inference

Autoregressive language models generate text sequentially. After processing the prompt, the model predicts a next token, appends that token to the sequence, and repeats the process. That dependency makes generation difficult to parallelize across time: token 101 cannot normally be generated until token 100 is known. Speculative decoding changes the amount of useful work performed during each expensive target-model step. A cheaper draft process proposes several future tokens, then the target model verifies those proposals together. When enough proposals are accepted, the application can advance by multiple tokens while invoking the large model fewer times.

Tech 03 Sep 2026 7 min read

Sleep vs Hibernate: What Happens to Your Computer

Closing a laptop lid can make the screen go dark almost instantly, yet opening it later may bring back the same applications and documents. Hibernate can appear similar, but the computer can remain without external power for much longer without losing that saved working state. The difference comes down to where the computer keeps the information it needs to resume. Sleep generally keeps the current working state in memory while most other activity is reduced or stopped. Hibernate saves that state to persistent storage so the computer can power down more completely.

Cybersecurity 03 Sep 2026 10 min read

Separate High-Risk Actions with Dual Control

Some actions are too consequential to depend on one authenticated account making one correct decision. Deleting a production backup, changing a payment destination, disabling a security control, granting organization-wide administrator access, or rotating a recovery credential can all be legitimate operations. The problem is that a stolen administrator session, a compromised account, or a simple human mistake may turn the same capability into a serious incident. Dual control reduces this risk by separating a sensitive action into at least two independent decisions. One person requests the action, and another authorized person approves it before the system executes it.

Artificial Intelligence 03 Sep 2026 6 min read

Self-Attention in Transformer Models

Transformers can process relationships between tokens without stepping through a sequence one token at a time. The mechanism that makes this possible is self-attention: each token builds a weighted view of other tokens in the same context. The formula is compact. The sections below show what the calculation does, how masking sets the information boundary, and where the computational cost comes from. Start with token representations Before attention runs, each input token is represented by a vector. Let the matrix X contain those token representations. A transformer layer applies learned projections to produce three matrices:

Cybersecurity 03 Sep 2026 7 min read

Secure File Upload Handling

File uploads cross a security boundary. A file supplied by a user may have a misleading name, unexpected content, excessive size, malicious active content, or a structure designed to exploit the software that processes it. Secure upload handling therefore requires more than checking a filename extension. Treat every uploaded file as untrusted until the application has validated, stored, processed, and served it according to an explicit policy. Start with a narrow upload policy Define what the feature actually needs to accept. An avatar service may need only a small set of image formats, while a document workflow may need PDF files and nothing else.

Software Engineering 03 Sep 2026 7 min read

Replacing Legacy Systems with the Strangler Pattern

Replacing a large legacy system in one release is attractive on a diagram and dangerous in practice. The old system usually contains years of behaviour, undocumented edge cases, operational knowledge, and integrations that are difficult to reproduce all at once. The strangler pattern takes a different approach: place a boundary in front of the existing system, move one capability at a time to a new implementation, and gradually reduce the responsibilities of the old system until it can be retired.

Software Engineering 03 Sep 2026 6 min read

Refactoring Legacy Code with Characterization Tests

Legacy code is difficult to change when its important behaviour is poorly understood and existing tests do not provide enough confidence. The risk is not only that a refactoring introduces a bug. The deeper problem is that developers may not know which behaviours are intentional, accidental, or relied on by other parts of the system. Characterization tests help reduce that uncertainty. Instead of beginning with a specification of what the code should do, they capture what the code does today. That behavioural baseline can make structural improvement safer while the team learns the system.

Software Engineering 03 Sep 2026 11 min read

Reducing Temporal Coupling in Code

Some APIs look simple because each method is simple. The difficulty appears only when the methods must be called in exactly the right order. A report builder might require loadData() before render(). A client might require connect() before send(). A job might require prepare() before execute() and execute() before publish(). When those rules exist but are not visible in the interface, callers must remember history: What has already happened to this object? That dependency on operation order is called temporal coupling.

Artificial Intelligence 03 Sep 2026 7 min read

Reduce LLM Hallucinations with Grounding and Verification

Large language models can produce fluent answers that contain incorrect facts, invented details, or unsupported claims. This behavior is commonly called hallucination. Hallucinations are not simply random mistakes. A language model generates tokens that are plausible given its input and learned parameters. Plausible text is not necessarily true text, especially when the model lacks reliable evidence for the question being asked. For developers, the practical goal is therefore not to find a single setting that eliminates hallucinations. It is to design the application so that factual claims are grounded in appropriate evidence, uncertainty is handled explicitly, and important outputs are verified.

Cybersecurity 03 Sep 2026 9 min read

Reduce Breach Impact with Data Minimization

Security controls often focus on stopping unauthorized access. That is necessary, but it leaves another useful question unanswered: if access controls fail, how much valuable data is available to expose? Data minimization reduces that potential impact. The idea is simple: collect sensitive data only when there is a clear need, keep only the fields and copies that serve that need, and remove the data when the required lifetime ends. This is not a replacement for authentication, authorization, encryption, monitoring, or backups. It changes a different part of the risk equation. A system cannot leak a sensitive value that it never collected, and an old copy cannot be stolen after it has been reliably removed.

Python 03 Sep 2026 10 min read

Read and Write CSV Reliably in Python

CSV looks simple because a small file may resemble plain text with commas between values. That mental model breaks as soon as a field itself contains a comma, quote, or newline. Consider one valid record: 42,"Nguyen, Mai","Line one Line two" Splitting this text on commas cannot recover the three fields correctly. The comma inside the name is data, and the newline inside the quoted field belongs to the same record.

Software Engineering 03 Sep 2026 12 min read

Put Decisions Next to the Data They Need

A method can look perfectly reasonable while depending on far more knowledge than it should. Imagine checkout code that asks a customer object for membershipLevel, joinedAt, and totalOrders, then combines those values to decide whether the customer receives priority support. The calculation works, but checkout now knows both the customer’s data and the rule that gives that data meaning. When the rule changes, every caller that reconstructed it becomes a possible edit site.

Cybersecurity 03 Sep 2026 10 min read

Protect Encryption Keys with Envelope Encryption

Encrypting sensitive data is only useful if the keys are protected as carefully as the data itself. A common mistake is to focus on the encryption algorithm while treating key storage as a secondary detail. If an attacker can obtain both the ciphertext and the key that decrypts it, the encryption no longer provides the intended protection. Envelope encryption addresses this operational problem by using different keys for different jobs. A data encryption key encrypts the data, while a separate key-encryption key protects the data key. This separation makes it possible to encrypt many pieces of data without storing their plaintext data keys beside them.

Cybersecurity 03 Sep 2026 12 min read

Protect Audit Logs from Tampering

Audit logs are most valuable when something has already gone wrong. They help answer who changed a permission, which account performed a sensitive action, and what happened before an incident was detected. But there is a difficult dependency hidden in that design: if the same compromised system can freely rewrite its own audit history, the evidence may become unreliable exactly when responders need it most. The defensive goal is therefore not merely to record events. It is to make important audit records harder to alter without authorization and make suspicious loss or modification easier to detect.

Cybersecurity 03 Sep 2026 8 min read

Prioritize Vulnerability Remediation by Real Risk

A vulnerability scanner can produce hundreds or thousands of findings. Treating every finding as equally urgent creates a different security problem: teams spend limited time on low-impact work while vulnerabilities that are easier to exploit or expose more valuable systems wait in the same queue. Effective vulnerability management therefore needs more than a severity score. The practical question is: which weakness should we reduce first, given how our system is actually deployed?

Cybersecurity 03 Sep 2026 6 min read

Prioritize Security Patches by Risk

Security patching is a risk-reduction process, not a race to install every available update at the same speed. Teams usually have more vulnerabilities than they can remediate immediately, while rushed changes can create outages of their own. A useful patching strategy therefore answers two questions: which fixes matter most, and how can they be deployed without creating unnecessary operational risk? Start with an accurate inventory You cannot reliably patch assets you do not know exist.

Python 03 Sep 2026 9 min read

Practical Frequency Counting in Python with collections.Counter

Counting repeated values looks simple until the surrounding code starts accumulating special cases. A plain dictionary can tally events, words, status codes, or inventory units, but the implementation also has to initialize missing keys, rank frequent values, merge counts, and decide what zero or negative counts mean. Python’s collections.Counter packages those operations into a dictionary-like type designed for counting hashable objects. It is useful when the problem is fundamentally about frequencies or multisets rather than arbitrary key-value storage.

Artificial Intelligence 03 Sep 2026 10 min read

Positional Information in Transformer Models

Self-attention can compare every token with other tokens in a context, but the comparison alone does not tell the model where those tokens occur. A sentence is not just a collection of words: changing their order can change the meaning. Transformer models therefore need a way to represent positional information. This mechanism lets the network distinguish, for example, the first occurrence of a token from a later occurrence and reason about relationships such as “the previous token” or “far earlier in the document.”

Cybersecurity 03 Sep 2026 10 min read

Patch Security Vulnerabilities with Controlled Rollouts

Installing a security patch closes a known weakness, but the change can also alter application behaviour, dependencies, resource use, or compatibility. Delaying every patch until a long maintenance cycle leaves known exposure open. Deploying every patch everywhere immediately can turn a security fix into an avoidable outage. The useful goal is therefore not simply patch fast or patch carefully. It is to reduce security exposure as quickly as the situation requires while controlling the operational risk introduced by the change.

Python 03 Sep 2026 10 min read

Parse and Render Shell Arguments Safely with Python shlex

Command-line text looks deceptively simple. Splitting on spaces works until an argument contains whitespace. Concatenating strings works until a filename contains shell metacharacters. Logging a list of arguments works, but the result may be difficult for a human to copy and inspect. Python’s shlex module handles a useful middle ground: shell-like lexical analysis for Unix-style command text. Its split(), quote(), and join() helpers let programs move deliberately between a string representation and a sequence of argument tokens.

Tech 03 Sep 2026 9 min read

OLED vs LCD Screens: What the Difference Means in Everyday Use

Phones, laptops, monitors, and televisions can look similar from the outside while using very different technology to produce an image. Two common display types are OLED and LCD. The most useful difference is simple: an OLED pixel can produce its own light, while an LCD pixel controls light coming from a separate backlight. That one distinction explains many of the differences people notice in black levels, contrast, power use, screen thickness, and long-term ageing.

Software Engineering 03 Sep 2026 7 min read

Mutation Testing for Stronger Test Suites

A test suite can execute every important line of code and still miss serious defects. Coverage tells you which code ran, but it does not tell you whether the tests would notice if that code behaved incorrectly. Mutation testing examines that gap. It makes small, systematic changes to production code and runs the tests against each changed version. If the tests fail, the mutation is killed. If they still pass, the mutation survives and points to a place where the suite may not distinguish correct behaviour from incorrect behaviour.

Software Engineering 03 Sep 2026 8 min read

Modeling Workflows with Explicit State Transitions

Many business objects have a lifecycle. An order may be created, approved, fulfilled, or cancelled. A support ticket may be open, assigned, resolved, or reopened. Problems begin when those lifecycle rules are represented only by a status field and scattered if statements. As the system grows, different code paths can start disagreeing about which changes are legal. One handler allows a cancelled order to be approved, another silently ignores the request, and a third checks a different set of statuses. The status values are visible, but the rules connecting them are not.