How I Built a Vehicle Cost Comparison Tool That Doesn't Ignore Depreciation

I was replacing a 2014 petrol MPV with a used EV. Along the way I collected insurance quotes, checked the vehicle tax bracket, asked for a battery health certificate, got a trade-in offer, and compared a cash price against a dealer’s financing plan. Somewhere in the middle of all that I wanted one simple thing: a single number telling me what switching would actually cost per year, compared to just keeping the car I already had. ...

How to Resolve Vitest `EMFILE: too many open files` Errors on a High Thread Count Machine

If you’re running your Vitest suite on a high thread count machine—like an 8-core or 16-core development machine—you may encounter a frustrating error that looks like this: EMFILE: too many open files This issue can be cryptic at first, especially when your system doesn’t seem anywhere near running out of resources. But the root cause might not be in your system limits—it could be in your import statements. The Unexpected Culprit: Named Imports from MUI In my case, after hours of digging, I discovered that the error was caused by using named imports from Material UI (MUI) components and icons. These named imports, when used across many test files, were triggering Vitest to open an excessive number of files behind the scenes. ...

How to Update Nested Array Subdocuments Using Main Document Field with Mongoose

Updating nested array subdocuments based on a field in the main document is a common task when working with MongoDB and Mongoose. Here’s a simple guide and example to help you accomplish this. Plan Use Model.updateMany() or Model.findOneAndUpdate() to update multiple or a single document. Use an aggregation pipeline ([{}]) as the second argument to reference document fields. Use the $set stage within the pipeline to update the nested array. Use the $$ROOT variable to reference fields from the main document. Example Assume you have a User model where each user has an array of posts, and you want to set each post’s authorName field based on the user’s name field. ...

How to sanitize NestJS API responses with Interceptor

In any API development project, ensuring that sensitive or unnecessary data is not exposed in the responses is crucial for security and efficiency. In NestJS, interceptors provide a powerful way to manipulate the flow of data. In this blog post, we’ll explore how to use an interceptor to sanitize API responses by removing specific properties. We’ll also look at how to write tests to ensure the interceptor behaves as expected. ...

How to resolve Intel Graphics Command Center port conflict

For developers working on .NET Core and other development servers, encountering port conflicts can be a common issue. Recently, I came accross with the default port (5000) used for local development server and the Intel(R) Graphics Command Center server. In this blog post, I’ll introduce a workaround that involves editing the Windows registry to resolve the conflict and ensure smooth development processes. Understanding the Issue: The Intel(R) Graphics Command Center server, specifically the OneApp.IGCC.WinService.exe executable, by default, utilizes port 5000. However, this port is commonly used for development servers in the .NET Core ecosystem and other software development environments. When both the Intel(R) Graphics Command Center server and a development server attempt to bind to port 5000 simultaneously, a conflict arises. ...