Node.js DNS Lookup Method

Mayank Agarwal
Updated on 29-Oct-2021 07:31:40

687 Views

The dns.lookup() method resolves the host name (e.g., tutorialspoint.com) into the first found A IPv4) or AAAA (IPv6) record. The properties available under the options are optional. dns.lookup() does not have anything to do with the DNS protocol. The implementation uses an OS facility that can associate names with addresses and vice versa.Syntaxdns.lookup(hostname, [options], callback)ParametersThe above parameters are defined as below −hostname – This is the website hostname for which you want to look up the DNS values.options – It can have the following optionsfamily – It can have the values 4, 6, or 0 only. The value "0" indicates ... Read More

Stack Implementation of Shift-Reduce Parsing in Compiler Design

Ginni
Updated on 29-Oct-2021 07:30:22

7K+ Views

Shift reduce parser is a type of bottom-up parser. It uses a stack to hold grammar symbols. A parser goes on shifting the input symbols onto the stack until a handle comes on the top of the stack. When a handle occurs on the top of the stack, it implements reduction.There are the various steps of Shift Reduce Parsing which are as follows −It uses a stack and an input buffer.Insert $ at the bottom of the stack and the right end of the input string in Input Buffer.Shift: Parser shifts zero or more input symbols onto the stack until ... Read More

Node.js DNS Resolvers Method

Mayank Agarwal
Updated on 29-Oct-2021 07:27:42

108 Views

The dns.resolveNs() method uses the DNS protocol to resolve the nameserver records (NS Records) for the hostname. The addresses argument passed to the callback function will contain an array of nameserver records for the hostname.Syntaxdns.resolveNs(hostname, callback)ParametersThe above parameters are defined as below −hostname – This parameter takes input for the hostname to be resolved.callback – This function will catch errors, if any.records – Returns the nameserver (NS) records for the hostname.Example 1Create a file "resolveNs.js" and copy the following code snippet. After creating the file, use the command "node resolveNs.js" to run this code:// dns.resolveNs() Demo Example // Importing ... Read More

Node.js Process Connected Property

Mayank Agarwal
Updated on 29-Oct-2021 07:24:49

130 Views

The process.connected property returns True if an IPC channel is connected and will return False after the process.disconnect() method is called. This happens only when the node process is spawned with an IPC channel (i.e., Child process and Cluster).Once the process.connected property is false, no messages can be sent over the IPC channel.Syntaxprocess.connectedExample 1Create two files "parent.js" and "child.js" as follows −parent.js// process.connected Property Demo Example // Importing the child_process modules const fork = require('child_process').fork; // Attaching the child process file const child_file = 'util.js'; // Spawning/calling child process const child = fork(child_file);child.jsconsole.log('In Child') // Check ... Read More

What is Top-Down Parsing

Ginni
Updated on 29-Oct-2021 06:59:41

13K+ Views

In top-down parsing, the parse tree is generated from top to bottom, i.e., from root to leaves & expand till all leaves are generated.It generates the parse tree containing root as the starting symbol of the Grammar. It starts derivation from the start symbol of Grammar & performs leftmost derivation at each step.Drawback of Top-Down ParsingTop-down parsing tries to identify the left-most derivation for an input string ω which is similar to generating a parse tree for the input string ω that starts from the root and produce the nodes in a pre-defined order.The reason that top-down parsing follow the ... Read More

Parsing Techniques in Compiler Design

Ginni
Updated on 29-Oct-2021 06:57:11

16K+ Views

Parsing is known as Syntax Analysis. It contains arranging the tokens as source code into grammatical phases that are used by the compiler to synthesis output generally grammatical phases of the source code are defined by parse tree. There are various types of parsing techniques which are as follows −Top-Down ParserIt generates the Parse Tree from root to leaves. In top-down parsing, the parsin begins from the start symbol and changes it into the input symbol.An example of a Top-Down Parser is Predictive Parsers, Recursive Descent Parser.Predictive Parser − Predictive Parser is also known as Non-Recursive Predictive Parsing. A predictive ... Read More

Create Data Table Object of Combination of Correlation Coefficients

Nizamuddin Siddiqui
Updated on 28-Oct-2021 15:01:09

197 Views

To create a data.table object of combination of correlation coefficients, we first need to find the correlation matrix then the combination of variables for which the correlation matrix is created then data.table will be used to combine the combination of variables and the correlation coefficients.Check out the below Examples to understand how it can be done.Example 1Following snippet creates a sample data frame −x1

Select Columns of an R Data Frame and Skip If Does Not Exist

Nizamuddin Siddiqui
Updated on 28-Oct-2021 14:02:39

835 Views

Sometimes we have a large number of columns in the data frame and we know the name of some columns but among known ones some does not exist in the data frame. Now if we want to select the columns that we know and skip the ones that do not exist then we can use the subsetting.For Example, if we have a data frame called df that contains twenty columns and we believe that x, y, z exists in df but z is not there in reality. Now the selection of columns x, y, z that will skip z can ... Read More

Divide Columns of a Matrix by Vector Elements in R

Nizamuddin Siddiqui
Updated on 28-Oct-2021 13:49:11

2K+ Views

Suppose we have a vector say V that contains five elements and a matrix say M that has five columns. Now again, suppose that we want to divide each column in M by corresponding value in vector V, which means first column in M will be divided by first value in the V and so on then we can use the sweep function as shown below −sweep(M,2,V,FUN="/")Example 1Consider the below matrix and vector −M1

What is Payback Period in Capital Budgeting

Probir Banerjee
Updated on 28-Oct-2021 12:26:47

3K+ Views

Payback is a method related to capital budgeting. The payback period in capital budgeting refers to the time required for the return on an investment (ROI) to "repay" or pay back the total sum of the original investment.Payback is a popular method of evaluation of investment because it is easy to understand and calculate regardless of what it actually means.Despite being a non-DCF evaluation method, payback is used extensively in the evaluation of investments for its simplicity in calculation and application. It is quite useful in comparing the calculation of similar investments.The payback method doesn’t have any specific criteria for ... Read More

Advertisements