Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Server Side Programming Articles
Page 1841 of 2109
Node.js - dns.reverse() Method
The dns.reverse() method is somewhat opposite of the method dns.lookup().This method performs a reverse DNS query that resolves an IPv4 or IPv6 to an array of host names.Syntaxdns.reverse(ip, callback)Parametersip – This takes an input for ip as a string, for which the DNS needs to be found.callback – It will catch errors, if any.Example 1Create a file with the name "reverse.js" and copy the following code snippet. After creating the file, use the command "node reverse.js" to run this code as shown in the example below −// dns.reverse() method Demo Example // Importing the dns module const dns = ...
Read MoreHow to exit a process in Node.js?
There are some cases where we need to exit a certain process in Node.js based upon a condition. For this condition, we have the following methods where we can escape or exit any Node.js Process.Method 1: Using the Ctrl+C keyI hope everyone knows this shortcut to exit any Node.js process from outside. This shortcut can be used to stop any running process by hitting this command on terminal.Method 2: Using the process.exit() functionThis function instructs Node.js to end the process that is running at an instant with an exit code. Node.js will force the current running process to stop execution ...
Read MoreNode.js – dnsPromises.reverse() Method
The dnsPromises.reverse() method performs a reverse DNS search to resolve the IPv4 or Ipv6 address to an array of hostnames. The promise is rejected with an Error object if a Success status is not encountered.SyntaxdnsPromises.reverse( ip )where, ip is the parameter that takes the input for the IP address to be resolved.Example 1Create a file with the name "reverse.js" and copy the following code snippet. After creating the file, use the command "node reverse.js" to run this code as shown in the example below −// dns.reverse() Demo Example // Importing the dns module const dns = require('dns'); const ...
Read MoreNode.js – dns.resolveSoa() Method
The dns.resolveSoa() method uses the DNS protocol to resolve the start of authority records for the hostname. The address argument passed to the callback function will be an object that will contain the following properties −nsnamehostmasterserialrefreshentryexpireSyntaxdns.resolveSoa(hostname, callback)ParametersIt accepts the following parameters −hostname – This parameter takes the input for the hostname to be resolved.callback – This function will catch errors, if any.records – Returns the start of authority records for the hostname.ExampleCreate a file with the name "resolveSoa.js" and copy the following code snippet. After creating the file, use the command node "resolveSoa.js" to run this code as shown in ...
Read MoreHow to download a file using Node.js?
We can download file using Node.js by either using third-party libraries or using some inbuilt packages.Method 1: Using 'https' and 'fs' moduleWe can use the http GET method to fetch the files that are to be downloaded.The createWriteStream() method from fs module creates a writable stream and receives the argument with the location of the file where it needs to be saved.pipe() is another method from fs that reads the data from the readable stream and writes it onto the writable stream and file.Example 1Create a file with the name downloadFile.js and copy the following code snippet. After creating the ...
Read MoreNode.js - diffieHellman.computeSecret() Method
The diffieHellman.computeSecret() is used for computing the shared secret using the public key of other's party and returning the computed shared secret. The suppliedKey is interpreted using the specified inputEncoding and the secret is encoded using the specified outputEncoding. If the inputEncoding is not specified the other publicKey is expected to be a buffer, DataView.SyntaxdiffieHellman.computeSecret(otherPublicKey, [inputEncoding], [outputEncoding])ParametersotherPublicKey – This is the public key that is used to compute the secret.inputEncoding – This encoding is used to interpret the supplied key.outputEncoding – This encoding is used for encoding the computed secret value.Example 1Create a file with the name "computeSecret.js" and copy ...
Read MorePyTorch – torch.linalg.cond()
To compute the condition number of a matrix with respect to a matrix norm, we could apply torch.linalg.cond() method. It returns a new tensor with computed condition number. It accepts a matrix, a batch of matrices and also batches of matrices. A matrix is a 2D torch Tensor. It supports input of float, double, cfloat, and cdouble data typesSyntaxtorch.linalg.cond(M, p=None)ParametersM – A matrix or batch of matrices.p – A type of matrix norm to be used in computation of condition number. Default matrix norm is 2-norm.It returns a real-valued tensor of condition number.StepsWe could use the following steps to compute the ...
Read MorePyTorch – How to compute the pseudoinverse of a matrix?
To compute the pseudoinverse of a square matrix, we could apply torch.linalg.pinv() method. It returns a new tensor with pseudoinverse of the given matrix. It accepts a matrix, a batch of matrices and also batches of matrices. A matrix is a 2D torch Tensor. It supports input of float, double, cfloat, and cdouble data types.Syntaxtorch.linalg.pinv(M)Where M is a matrix or batches of matrices.StepsWe could use the following steps to compute the pseudoinverse of a matrix −Import the required library. In all the following examples, the required Python library is torch. Make sure you have already installed it.import torchDefine a matrix. ...
Read MorePyTorch – How to compute the inverse of a square matrix?
To compute the inverse of a square matrix, we could apply torch.linalg.inv() method. It returns a new tensor with inverse of the given matrix. It accepts a square matrix, a batch of square matrices, and also batches of square matrices.A matrix is a 2D torch Tensor. It supports input of float, double, cfloat, and cdouble data types. The inverse matrix exists if and only if the square matrix is invertible.Syntaxtorch.linalg.inv(M)Where M is a square matrix or a batch of square matrices. It returns the inverse matrix.StepsWe could use the following steps to compute the inverse of a square matrix −Import ...
Read MorePyTorch – How to compute the norm of a vector or matrix?
To compute the norm of a vector or a matrix, we could apply torch.linalg.norm() method. It returns a new tensor with computed norm. It accepts a vector, matrix, a batch of matrices and also batches of matrices.A vector is a 1D torch Tensor where a matrix is a 2D torch Tensor. It supports input of float, double, cfloat, and cdouble data types. We can compute the norm of the matrix or batch/es of matrices along the different dimensions. For example, we could compute the norm of a matrix along dimension 0 or along dimension1.Syntaxtorch.linalg.norm(A)A is a vector, matrix or batch/s ...
Read More