Skip to main content


Node.js: Downloading a xml file from given url and reading its data elements.

In this article, we will see how we can download an XML file from a given URL and then access its elements. This can be used in many cases, for example, scraping data from a site which has data in the XML file or multiple files. The article is pretty short and most of it is just self-explanatory code. Also nowadays, you can get a lot of freelance jobs in data scrapping as data is the new oil today so this might be helpful. So let's begin with the code, var fs = require('fs') var https = require('https');//For accessing https url we need this module instead of http. var xml2js = require('xml2js');//Required for xml parsing. var file_name = 'data.xml'//This will be the name of file we will be generating. var DOWNLOAD_DIR =__dirname+'/'; //This function reads data from URL and writes data into new file //with respect to the given name and directory path. function download(){  var file_url='

2 JavaScript Interview Questions that you must know.

In this article, we will see in detail a couple of interview questions in Javascript. 1)What is a deep copy and Shallow copy? Shallow copy:  In shallow copy, all the top-level primitives get a copy excluding objects which are still connected to the original value. Note: If the array is of strings or number it gets copied but in case of an array of objects it is still connected to the original value. Primitive data types include the following: Number — e.g. 1 String — e.g. 'Hello' Boolean — e.g. true undefined null Example: var tshirt={     size:170,     sizeInLocal:'L',     sizeAvailable:{     'm':"Available"      } } Lets make a copy a shallow copy of tshirt object: var tshirt1=Object.assign({}, tshirt) tshirt1.sizeAvailable.m="NotAvailable"//Here tshirt.sizeAvailable.m will also become NotAvailable . tshirt1.size=150;//Only value of tshirt1.size is changed and not tshirt.size as size is of primitive type.  

4 html interview questions that you must know.

In this article, we will see some HTML interview questions I faced during interviews. So let's start, 1)What is Doctype in html? All HTML documents must start with a <!DOCTYPE> declaration. The declaration is not an HTML tag. It is an "information" to the browser about what document type to expect. In HTML 5, the declaration is simple: <!DOCTYPE html> Note: The <!DOCTYPE> declaration is NOT case sensitive. 2)What is DOM in html? The DOM (Document Object Model)is a W3C (World Wide Web Consortium) standard. The DOM defines a standard for accessing documents: The HTML DOM is a standard object model and programming interface for HTML. When a web page is loaded, the browser creates a Document Object Model of the page. It defines: The HTML elements as objects The properties of all HTML elements The methods to access all HTML elements The events for all HTML elements In other words: The HTML DOM is a standard for how to get, chan

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>&