Development

How to keep the screen awake using JavaScript

How to keep the screen awake using JavaScript

  • March 5, 2024

Some new features in JavaScript are great to see, and the wake lock API is one of those. It allows us to interact with the host system and can help the developer instruct the operating system to keep the screen awake using JavaScript! This can be particularly useful for cases...

Using RegEx groups for Search & replace  in VS Code

Using RegEx groups for Search & replace in VS Code

  • February 29, 2024

VS Code has a nifty tool for doing search and replace using RegEx, which I prefer using whenever doing bulk updates. It has saved me quite a few times while refactoring across multiple files. Let us look at how search & replace using RegEx groups works in Visual Studio Code....

How To Fix ReferenceError: __dirname is not defined

How To Fix ReferenceError: __dirname is not defined

  • February 15, 2024

I recently tried to use __dirname inside a ES module. It turns out, that I cannot. It throws an error. So let us see how To Fix ReferenceError: __dirname is not defined. For people who do not know what it is, let us first discuss what __dirname is. __dirname is a global variable in Node.js...

How to detect caps lock with JavaScript

How to detect caps lock with JavaScript

  • February 11, 2024

The need to verify and notify the user if the Caps Lock key is on is fairly common. It is particularly significant when constructing password inputs because users do not realize they are typing with their caps lock on. Let us see how to detect caps lock with JavaScript to do...

Creating new TypeScript types using template literal types

Creating new TypeScript types using template literal types

  • February 5, 2024

TypeScript is way more powerful than I give it credit for. I recently learned about creating new TypeScript types using template literal types, and I was pretty surprised to know that TypeScript can do that. Let us assume we wanted to create a type for the CSS properties margin and...

React TypeScript: Simplify Imports with Path Aliases

React TypeScript: Simplify Imports with Path Aliases

  • January 27, 2024

As codebases grow larger and more complex in structure, imports can become unmanageable. As more directories are added, imports become intricately long and obscure clarity. Fortunately, we can simplify imports with path aliases. The problem The following is a fairly common occurrence in a large project: This can be burdensome...