Skip to main content


Javascript/Node.js: 2 Features that you might not know.

This is a very short article where we will be discussing two Javascript features that you may not know. Also, you may like this article about two new Node.js features.    So let's start, 1)Exponentiation operator(**): This operator was added in ES6 and is supported by most of the browsers but excluding internet explorer. It is also called an Infix operator for Exponentiation. Before for exponentiation, we have to use Math.pow(x,y). But now you can use x**y. For example: 2**5 //returns 32 2)Numeric Separators: Large numeric literals are difficult for the human eye to parse quickly, especially when there are lots of repeating digits. To improve readability, you can use underscores as separators in numeric literals. For example: let value= 100_000_000_00 //Is same as 10000000000 As of May 2020, It is supported by all major browsers (Chrome[75+], Firefox[70+], Edge, Safari[13+], Opera) ( source 1 , source 2 for more details about differe

Node.js: Bundling your Node.js application to single executable for Windows.

In this article, we will see how to bundle Node.js application to a single executable for Windows. What's the need? Well recently, I had taken a work where I needed to convert pdf's(Of similar format) to excel sheet. So I was reading the pdf's from a folder in desktop and I was storing the output excel sheet into a separate folder on the desktop. I used Node.js for the program. Now the client wanted it to install the program on 25 windows machine and his budget was really low. So it was also not possible for me to install node.js for 25 machines and then install the required dependency for each one. One of the solution: While I was searching for an easy solution I found this amazing npm module pkg . This module can make your node.js app work like plug and play type. No need to install Node.js on the client machine or any other dependency.  It helps to make a commercial or trial version of your node.js application without exposing the source code. I found

Node.js: Extract text from image using Tesseract.

In this article, we will see how to extract text from images using Tesseract . So let's start with this use-case, Suppose you have 300 screenshot images in your mobile which has an email attribute that you need for some reason like growing your network or for email marketing. To get an email from all these images manually into CSV or excel will take a lot of time. So now we will check how to automate this thing. First, you need to install Tesseract OCR( An optical character recognition engine ) pre-built binary package for a particular OS. I have tested it for Windows 10. For Windows 10, you can install  it from here. For other OS you make check  this link. So once you install Tesseract from windows setup, you also need to set path variable probably, 'C:\Program Files\Tesseract-OCR' to access it from any location. Then you need to install textract library from npm. To read the path of these 300 images we can select all images and can rename it to som

JavaScript: MediaDevices(Opening webcam to capturing image and downloading it)

In this article, we will see how to open a webcam in chrome and how to capture the image and download it. So let's start, We will be using Navigator.mediaDevices which provides access to connected media input devices like cameras and microphones, as well as screen sharing. The Navigator object contains information about the browser. There is no public standard that applies to the navigator object, but all major browsers support it. HTML CODE: <!DOCTYPE html> <html> <head>   <meta charset='utf-8'>   <meta http-equiv='X-UA-Compatible' content='IE=edge'>   <meta name='viewport' content='width=device-width, initial-scale=1'>   <link rel='stylesheet' type='text/css' media='screen' href='main.css'>   <script src='video.js'></script> </head> <body>   <div class='container'>       <video autoplay>&

What are Webhooks? Example use case of payment Gateway.

In this article, we will see what is webhooks? and a use case for it and how to test webhook locally. Webhooks: Webhooks are just like callbacks but the only difference is there are HTTP callbacks. It is triggered by some event in web application. Let's see this use-case in detail. UseCase: Suppose we have an online site which sells T-shirts and for that we need some payment gateway.  For that, we have decided to use a Razorpay payment gateway. So here the flow will be somewhat like this. Client-side: Users log in to the website and add some T-shirts into the cart and do checkout. Backend side when a user does checkout: Will create an order for the user with payment status 'pending' and will log that in our database with respect to that user. Then we create a payment order for the user using Razorpay APIs and send a payment checkout link to the user. (Consider this payment checkout link is of third party i.e Razorpay) How will w

Node.js/Angular: SheetJS js-xlsx library with issues and fixes.

In this article, we will see how SheetJS js-xlsx library is used to export  data to xlsx file for a particular use case and also, I am covering a few issues that I found and fixes for that. So let's start without wasting time, Use Case: We need to export a html table (containing all columns and rows) into xlsx file. Angular Example Link: I have used the reference of this example in this article. So please check the Angular Example Link. Here, I have 2 tables with 3 columns Name, Dob in dd/mm/yyyy format, and Id which is a string but sometimes its value maybe number 20 digit. So let's see the happy case: In this example I have imported xlsx library and has 2 functions importTable1() and importTable2() which use xlsx util functions to export the tables into xlsx files. Issues Found: (Export Table One  button will export xlsx sheet for table1 which has these issues) 1) When you ex

JavaScript: Throttling

In this article, we will check what is throttling and how it is different than debouncing. Before that, if you don't know what is debouncing then, I will suggest you read this article on Debouncing(UI interview question for Flipkart). Throttling is a technique to control how many times a function to be executed over time. Why it is important? In 2011, Issue in the Twitter website, when you were scrolling down your Twitter feed, it became slow and unresponsive. John Resig published a blog post about the problem where it was explained how bad of an idea it is to directly attach expensive functions to the scroll event. John Resig: The creator of the most popular JavaScript library in the world: jQuery. How it is different from Debouncing? Well, the debouncing technique is useful for example like search bar in Flipkart, Amazon where we limit the API call to the server. If we are searching for some product and when we take pause(200ms) the API will get called.