Found 26504 Articles for Server Side Programming

Find the Number of Pentagons and Hexagons on a Football using C++

Prateek Jangid
Updated on 24-Nov-2021 07:27:22

250 Views

As we all know, pentagons and hexagons are equally essential parts of football. These shapes fit together like a puzzle for forming a perfectly spherical shape. So here we have a football, in which we have to find the hexagons and pentagons.We will use the Euler characteristic to solve the problem easily. Euler characteristic is a number that works to describe a specific shape or structure of any topological space. So we can use it for calculating the number of Pentagons and Hexagons on the football.In Euler characteristics −chi(S) − Integer for a specific surface SF − facesG − GraphV ... Read More

Find the Number of Paths of Weight W in a K-ary tree using C++

Prateek Jangid
Updated on 24-Nov-2021 07:22:58

199 Views

In this article, we'll use C++ to calculate the number of weight W paths in a K-ary tree in this article. We've given a K-ary tree, which is a tree in which each node has K children and each edge has a weight assigned to it, with weights descending from 1 to K from one node to all of its children.We need to count the cumulative number of paths beginning from the root that have a weight of W and at least one edge with a weight of M. So, here's example −Input : W = 4, K = 3, ... Read More

Node.js – dns.lookupService() Method

Mayank Agarwal
Updated on 24-Nov-2021 07:25:17

216 Views

The dns.lookupService() method resolves a given address and port into a hostname and service. This method uses the operating system's underlying getnameinfo implementation. A TypeError will be thrown if the address is not a valid IP address.Syntaxdns.lookupService(address, port, callback)Parametersaddress - This parameter takes input for the IP address that needs to be resolved.port - This parameter takes input for the port number that is attached with the IP address.callback - It will catch errors, if any.Example 1Create a file with the name "lookupService.js" and copy the following code. After creating the file, use the command "node lookupService.js" to run this ... Read More

Node.js – diffieHellman.setPrivateKey() Method

Mayank Agarwal
Updated on 24-Nov-2021 07:22:03

125 Views

The diffieHellman.setPrivateKey() sets the Diffie-Hellman generated private key. The private key will be a string if an encoding argument is provided. If no encoding is provided, the private key will be of type buffer.SyntaxdiffieHellman.setPrivateKey( privateKey, [encoding] )Parametersencoding - This parameter specifies the encoding of the private Key.Example 1Create a file with the name "privateKey.js" and copy the following code. After creating the file, use the command "node privateKey.js" to run this code as shown in the example below// diffieHellman.setPrivateKey() Demo Example // Importing the crypto module const crypto = require('crypto') // Generating the key pairs(public & private) crypto.generateKeyPair('rsa', ... Read More

Node.js – Process Warning Event

Mayank Agarwal
Updated on 24-Nov-2021 07:15:45

366 Views

A 'warning' event is emitted whenever a Node.js event emits a process warning. The process warning is similar to an error that describes the exceptional conditions that are being brought to the user's attention.Node.js can emit warnings whenever it encounters any bad coding practices that could lead to poor performance or bugs.SyntaxEvent : 'warning'Example 1Create a file with the name "warning.js" and copy the following code. After creating the file, use the command "node warning.js" to run this code, as shown in the example below// Event: warning Demo Example // Importing the process module const process = require('process'); ... Read More

Node.js – Timeout-ref() & Timeout-unref() method

Mayank Agarwal
Updated on 24-Nov-2021 07:14:23

996 Views

The Timeout object is internally created and is returned from the setTimeout() and setInterval() methods. You can use this object and pass it to either clearTimeout() or clearInterval() if you want to cancel the scheduled actions.Following are the timeout class ref objects that can be used to control the default behaviour −1. timeout.ref()This method is called if the timeout object's event loop does not exist. The actual use of this method is only after the timeout.unref() is called, and you need to reference the timeout object again.Syntaxtimeout.ref()2. timeout.unref()This method will tell the timeout object that the Node.js event loop does not ... Read More

Node.js – Monitor mode in Redis

Mayank Agarwal
Updated on 24-Nov-2021 07:11:39

596 Views

Redis also supports the monitor command that lets the user to see all the commands received by the Redis server across all the client connections. These connections include commands from everywhere, including other client libraries and computers as well.The monitor event will monitor all the commands which are executed on the Redis server where monitor is enabled. The callback from the monitor receives the timestamp from the Redis server, an array of commands along with the raw monitoring string.Syntaxclient.monitor( function(callback) )Example 1Create a file with the name "monitor.js" and copy the following code. After creating the file, use the command "node ... Read More

Node.js – stringDecoder.end() Method

Mayank Agarwal
Updated on 24-Nov-2021 07:08:25

142 Views

The stringDecoder.end() method will return any remaining input that is left in the internal buffer as a string. Bytes that are left incomplete and represent UTF-8 and UTF-16 characters are replaced with the substitution characters appropriate for character encoding.StringDecoder.write() method is called before returning the remaining input if any buffer argument is provided. The stringDecoder can be reused for taking new inputs once the end() method is called.SyntaxstringDecoder.end( [buffer] )Parametersbuffer - This parameter takes input for the bytes to decode. It can take buffer, TypedArray or DataView as the input parameters.Example 1Create a file with the name "end.js" and copy ... Read More

Node.js – retry_strategy Property in Redis

Mayank Agarwal
Updated on 24-Nov-2021 07:07:08

3K+ Views

The retry_strategy is a function that receives objects as parameters including the retry attempt, total_retry_time that indicates the time passed after it was connected the last time, the error due to which the connection was lost, and the number of times_connected in total.If a number is returned from this function, the next retry will take place after that time only in milliseconds and if you send a non-number, no further retry will take place.Syntaxretry_strategy: funciton(options)Example 1Create a file with the name "retryStrategy.js" and copy the following code. After creating the file, use the command "node retryStrategy.js" to run this code ... Read More

Node.js – process.noDeprecation() Method

Mayank Agarwal
Updated on 24-Nov-2021 07:01:55

156 Views

This process.noDeprecation() method states whether the --no- Deprecation flag is set or not on the current Node.js project. This Boolean flag controls whether the deprecation warning messages are printed to stderr or not. Setting this flag as True will silence all the deprecation warnings.Syntaxprocess.noDeprecation( )Example 1Create a file with the name "noDeprecation.js" and copy the following code. After creating the file, use the command "node noDeprecation.js" to run this code as shown in the example below// process.noDeprecation() Demo Example // Importing the process module const process = require('process'); // Printing noDeprecation default value console.log(process.noDeprecation);Output 1undefined Output 2trueExample 2Let's ... Read More

Advertisements