code-rag-bench/online-tutorials huggingface dataset:
HTML | <tr> valign Attribute

25 Feb, 2022
The HTML <tr> valign Attribute is used to specify the vertical alignment of text content in a table row. It is not supported by HTML 5.
Syntax:
<tr valign= "top | middle | bottom | baseline">
Attribute Values:
top: It sets the content to top-align.
middle: It sets the content to middle-align.
bottom: It sets the content to bottom-align.
baseline: It sets the content to baseline. The baseline is the line where most of the characters sit. It has a default value.
Example:
<!DOCTYPE html><html>  <head>    <title>      HTML tr valign Attribute  </title></head>  <body>    <h1>GeeksforGeeks</h1>      <h2>HTML tr valign Attribute</h2>      <table style="height:200px" border="1">        <tr valign="top">            <th>Name</th>            <th>Expenses</th>        </tr>          <tr valign="bottom">            <td>BITTU</td>            <td>2500.00</td>        </tr>          <tr valign="middle">            <td>RAKESH</td>            <td>1400.00</td>        </tr>    </table></body>  </html>
Output:
Supported Browsers: The browser supported by HTML <tr> valign attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
chhabradhanvi
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
Types of CSS (Cascading Style Sheet)
Design a Tribute Page using HTML & CSS
HTTP headers | Content-Type
How to Insert Form Data into Database using PHP ?
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Tree Entropy in R Programming

25 Aug, 2020
Entropy in R Programming is said to be a measure of the contaminant or ambiguity existing in the data. It is a deciding constituent while splitting the data through a decision tree. An unsplit sample has an entropy equal to zero while a sample with equally split parts has entropy equal to one. Two major factors that are considered while choosing an appropriate tree are- information gain (IG) and entropy.
Formula :
where, p(x) is the probability
For example, consider a school data set of a decision tree whose entropy needs to be calculated.
Hence, it is clearly seen that a student’s performance is affected by three factors – library available, coaching joined, and parent’s education. A decision tree can be constructed using the information of these three variables for the prediction of student’s performance and hence are called predictor variables. The variables with more information are considered a better splitter of the decision tree.
So to calculate the entropy of parent node – Student’s performance, the above entropy formula is used but probability needs to be calculated first.
There are four values in the Student’s performance column out of which two performances are good and two are bad.
Hence, total entropy of parent can be calculated as below
Information gain is a parameter used to decide the best variable available for splitting the data at every node in the decision tree. So IG of every predictor variable can be calculated and the variable with the highest IG wins the race of deciding factor for splitting of root nodes.
Formula:
Information Gain(IG) = Entropyparent – (weighted average * Entropychildren)
Now to calculate IG of the predictor variable coaching joined, firstly split the parent node according to this variable.
Now there are two parts and their entropy is first calculated individually.
There are two types of output available – good and bad. On the left part, there are three total outcomes with two being bad and one being good. Hence, Pgood and Pbad is calculated again as follows:
There is only one component in right, ie, bad performance. Hence, the probability becomes one. And the entropy becomes 0 because there is only one category to which output can belong to.  
Calculating the weighted average with Entropy of children
There are 3 outcomes in left child node and 1 in the right node. While, Entropyleft node has been calculated as 0.9 and Entropyright node is 0.
Now keeping the values in the formula above we get a weighted average for this example: 
Now putting the calculated weighted average in IG formula simply to obtain IG of ‘coaching joined’.  
IG(coaching joined) = Entropyparent - (weighted average * Entropychildren)
IG(coaching joined) = 0.811 - 0.675 = 0.136
Using the same steps and formula IG of other predictor variables is calculated, compared, and variable with the highest IG is therefore selected for splitting the data at every node. 
Picked
R-Statistics
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE CS 2012 | Question 30

06 Dec, 2018
Fetch_And_Add(X,i) is an atomic Read-Modify-Write instruction that reads the value of memory location X, increments it by the value i, and returns the old value of X. It is used in the pseudocode shown below to implement a busy-wait lock. L is an unsigned integer shared variable initialized to 0. The value of 0 corresponds to lock being available, while any non-zero value corresponds to the lock being not available.
  AcquireLock(L){
         while (Fetch_And_Add(L,1))
               L = 1;
   }
  ReleaseLock(L){
         L = 0;
   }
This implementation(A) fails as L can overflow(B) fails as L can take on a non-zero value when the lock is actually available(C) works correctly but may starve some processes(D) works correctly without starvationAnswer: (B)Explanation: Take closer look the below while loop.
     while (Fetch_And_Add(L,1))
               L = 1;  // A waiting process 
                       // can be here just after 
                       // the lock is released, 
                       // and can make L = 1.

Consider a situation where a process has just released the lock and made L = 0. Let there be one more process waiting for the lock, means executing the AcquireLock() function. Just after the L was made 0, let the waiting processes executed the line L = 1. Now, the lock is available and L = 1. Since L is 1, the waiting process (and any other future coming processes) can not come out of the while loop.
The above problem can be resolved by changing the AcuireLock() to following.
  AcquireLock(L){
         while (Fetch_And_Add(L,1))
         { // Do Nothing }
   }

Overflow can occur only when larger number of processes than size of ‘int’ execute the check condition of while loop but not L = 1, i.e., preemption required.But when L is 1, the process repeats in the while loop- there is no overflow because after each increment to L, L is again made equal to 1.Option (b) is best choice over option (a).
Source :  https://www.geeksforgeeks.org/operating-systems-set-17/
Quiz of this Question
GATE-CS-2012
GATE-GATE CS 2012
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE-CS-2014-(Set-3) | Question 20
GATE | GATE CS 2008 | Question 46
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2014-(Set-1) | Question 51
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE CS 1996 | Question 63
GATE | GATE-CS-2015 (Set 2) | Question 55
GATE | GATE CS 2008 | Question 40
Python tell() function

28 Sep, 2021
Python too supports file handling and provides inbuilt functions for creating, writing and reading files. There are two types of files that can be handled in python, normal text files and binary files (written in binary language,0s and 1s). 
Text files: In this type of file, Each line of text is terminated with a special character called EOL (End of Line), which is the new line character (‘\n’) in python by default.  
Binary files: In this type of file, there is no terminator for a line and the data is stored after converting it into machine understandable binary language.  
Refer the below articles to get the idea about basics of File handling.
Basics or file handling
Reading and Writing to file
Access modes
Access modes govern the type of operations possible in the opened file. It refers to how the file will be used once it’s opened. These modes also define the location of the File Handle in the file. File handle is like a cursor, which defines from where the data has to be read or written in the file. Sometimes it becomes important for us to know the position of the File Handle. tell() method can be used to get the position of File Handle. tell() method returns current position of file object. This method takes no parameters and returns an integer value. Initially file pointer points to the beginning of the file(if not opened in append mode). So, the initial value of tell() is zero.syntax :  
file_object.tell()
Let’s suppose the text file named “myfile” looks like this: 
# Example 1: Position of File Handle before reading or writing to file.  
Python3
# Python program to demonstrate# tell() method    # Open the file in read modefp = open("myfile.txt", "r")  # Print the position of handleprint(fp.tell())  #Closing filefp.close()
output :  
0
# Example 2: Position of File Handle after reading data from file. 
Python3
# Python program to demonstrate# tell() method  # Opening filefp = open("sample.txt", "r")fp.read(8)  # Print the position of handleprint(fp.tell())  # Closing filefp.close()
Output :  
8
# Example 3: For binary files. Let’s create a binary file and we will notice the position of handle before writing and after writing to binary file. 
Python3
# Python program to demonstrate# tell() method  # for reading binary file we# have to use "wb" in file mode.fp = open("sample2.txt", "wb")print(fp.tell())  # Writing to filefp.write(b'1010101')  print(fp.tell())  # Closing filefp.close()
Output :  
0
7
 
sagar0719kumar
python-file-handling
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install Matplotlib on MacOS? - GeeksforGeeks

30 Sep, 2021
In this article, we will learn how to install Matplotlib in Python on MacOS. Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python.
Follow the below steps to install the Matplotlib package on macOS using pip:
Step 1: Install the latest Python3 in MacOS
Step 2: Check if pip3 and python3 are correctly installed.
python3 --version
pip3 --version
Step 3: Upgrade your pip to avoid errors during installation.
pip3 install --upgrade pip
Step 4: Enter the following command to install Matplotlib using pip3.
pip3 install matplotlib
Follow the below steps to install the Matplotlib package on macOS using the setup.py file:
Step 1: Download the latest source package of Matplotlib for python3 from here.
curl https://files.pythonhosted.org/packages/21/37/197e68df384ff694f78d687a49ad39f96c67b8d75718bc61503e1676b617/matplotlib-3.4.3.tar.gz > matplotlib.tar.gz
Step 2: Extract the downloaded package using the following command.
tar -xzvf matplotlib.tar.gz
Step 3: Go inside the folder and Enter the following command to install the package.
Note: You must have developer tools for XCode MacOS installed in your system
cd matplotlib-3.4.3
python3 setup.py install
Make the following import in your python terminal to verify if the installation has been done properly:
import matplotlib 
If there is any error while importing the module then is not installed properly.
how-to-install
Picked
Python-matplotlib
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install FFmpeg on Windows?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Set Git Username and Password in GitBash?
How to create a nested RecyclerView in Android
How to Install Jupyter Notebook on MacOS?
Installation of Node.js on Linux
How to Install FFmpeg on Windows?
How to Install Pygame on Windows ?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Install Jupyter Notebook on MacOS?
Node.js path.relative() Method - GeeksforGeeks

13 Oct, 2021
The path.relative() method is used to find the relative path from a given path to another path based on the current working directory. If both the given paths are the same, it would resolve to a zero-length string.
Syntax:
path.relative( from, to )
Parameters: This method accept two parameters as mentioned above and described below:
from: It is the file path that would be used as base path.
to: It is the file path that would be used to find the relative path.
Return Value: It returns a string with the normalized form of the path.
Below program illustrates the path.relative() method in Node.js:
Example:
// Node.js program to demonstrate the    // path.relative() method      // Import the path moduleconst path = require('path');   path1 = path.relative("geeks/website", "geeks/index.html");console.log(path1)   path2 = path.relative("users/admin", "admin/files/website");console.log(path2)   // When both the paths are same// It returns blank stringpath3 = path.relative("users/admin", "users/admin");console.log(path3)
Output:
..\index.html
..\..\admin\files\website


Reference: https://nodejs.org/api/path.html#path_path_relative_from_to
Node.js-path-module
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to install the previous version of node.js and npm ?
Difference between promise and async await in Node.js
How to use an ES6 import in Node.js?
Express.js res.render() Function
Mongoose | findByIdAndUpdate() Function
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
PHP | mysqli_error() Function - GeeksforGeeks

23 Apr, 2020
The mysqli_error() function is used to return the error in the most recent MySQL function call that failed. If there are multiple MySQL function calls, the error in the last statement is the one that is pointed out by the function.
Syntax:
mysqli_error("database_name")

Parameters: This function accepts single parameter as mentioned above and described below:
database_name: It is the database on which operations are being performed. It is a mandatory parameter.
Program 1:
<?php$conn = mysqli_connect(    "localhost", "root", "", "Persons");         // Check connection if (mysqli_connect_errno()) {     echo "Database connection failed."; }   // Check for error in queryif (!mysqli_query($link, "SET Age=1")) {    printf("Error message: %s\n", mysqli_error($conn));}      mysqli_close($conn);?>
Suppose the operation is being carried out on the table given below:
The output will be:
Error message: Unknown system variable 'Age'

Program 2:
<?php$conn = mysqli_connect(    "localhost", "root", "", "Persons");         // Check connection if (mysqli_connect_errno()) {     echo "Database connection failed."; }   // Check for error in queryif (!mysqli_query($link, "SET Firstname='Arkadyuti'")) {    printf("Error message: %s\n", mysqli_error());}      mysqli_close($conn);?>
Output:
Error message: mysqli_error() expects exactly 1 parameter, 0 given

This example also demonstrates that mysqli_error() needs a database as a parameter.
PHP-function
PHP-MySQL
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to fetch data from localserver database and display on HTML table using PHP ?
PHP str_replace() Function
How to create admin login page using PHP?
Different ways for passing data to view in Laravel
How to pass form variables from one page to other page in PHP ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
How to Select All Records from One Table That Do Not Exist in Another Table in SQL? - GeeksforGeeks

04 Aug, 2021
We can get the records in one table that doesn’t exist in another table by using NOT IN or NOT EXISTS with the subqueries including the other table in the subqueries. In this let us see How to select All Records from One Table That Do Not Exist in Another Table step-by-step.
Use the below command to create a database named GeeksforGeeks:
CREATE DATABASE GeeksforGeeks
To use the GeeksforGeeks database use the below command:
USE GeeksforGeeks
Create a table employee_details with  4 columns using the following SQL query: 
CREATE TABLE employee_details(
   emp_id VARCHAR(8),
   emp_name VARCHAR(20),
   emp_designation VARCHAR(20),
   emp_age INT);
CREATE TABLE employee_resigned(
   emp_id VARCHAR(8),
   emp_name VARCHAR(20),
   emp_designation VARCHAR(20),
   emp_age INT);
To view the description of the tables in the database using the following SQL query:
EXEC sp_columns employee_details;
EXEC sp_columns employee_resigned;
Inserting rows into employee_details and employee_resigned tables using the following SQL query:
INSERT INTO employee_details VALUES
  ('E40001','PRADEEP','H.R',36),
  ('E40002','ASHOK','MANAGER',28),
  ('E40003','PAVAN KUMAR','ASST MANAGER',28),
  ('E40004','SANTHOSH','STORE MANAGER',25),
  ('E40005','THAMAN','GENERAL MANAGER',26),
('E40006','HARSH',' ANALYST',25),
  ('E40007','SAMHITH','GENERAL MANAGER',26),
('E40008','SAMEER','SENIOR ANALYST',25),
  ('E40009','RISABH','BUSINESS ANALYST',26);
INSERT INTO employee_resigned VALUES('E40001','PRADEEP','H.R',36),
  ('E40004','SANTHOSH','STORE MANAGER',25),
  ('E40005','THAMAN','GENERAL MANAGER',26);
Viewing the table employee_details after inserting rows by using the following SQL query:
SELECT* FROM employee_details;
SELECT* FROM employee_resigned;
Query to find out the employee id and names of those who were not resigned using NOT EXISTS.
SELECT emp_id,emp_name  
FROM employee_details
WHERE NOT EXISTS
(SELECT *  
   FROM  employee_resigned
   WHERE employee_details.emp_id = employee_resigned.emp_id);
Query to find out the employee details of those who were not resigned using NOT IN.
SELECT *
FROM employee_details
WHERE emp_id NOT IN
  (SELECT emp_id  
  FROM employee_resigned)
Picked
SQL-Query
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Subquery
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL Query to Convert VARCHAR to INT
SQL using Python
How to Write a SQL Query For a Specific Date Range and Date Time?
How to Select Data Between Two Dates and Times in SQL Server?
SQL Query to Compare Two Dates
Java Program to Reverse a Sentence Using Recursion - GeeksforGeeks

24 Nov, 2020
A sentence is a sequence of characters separated by some delimiter. This sequence of characters starts at the 0th index and the last index is at len(string)-1. By reversing the string, we interchange the characters starting at 0th index and place them from the end. The first character becomes the last, the second becomes the second last, and so on. 
Example:
Input : GeeksforGeeks
Output:    skeegrofskeeG

Input : Alice
Output: ecilA

Approach:
Check if the string is empty or not, return null if String is empty.If the string is empty then return the null string.Else return the concatenation of sub-string part of the string from index 1 to string length with the first character of a string. e.g. return substring(1)+str.charAt(0); which is for string “Mayur” return will be “ayur” + “M”.
Check if the string is empty or not, return null if String is empty.
If the string is empty then return the null string.
Else return the concatenation of sub-string part of the string from index 1 to string length with the first character of a string. e.g. return substring(1)+str.charAt(0); which is for string “Mayur” return will be “ayur” + “M”.
Below is the implementation of the above approach:
Java
// Java Program to Reverse a Sentence Using Recursionimport java.io.*;  public class GFG {    public static String reverse_sentence(String str)    {        // check if str is empty        if (str.isEmpty())            // return the string            return str;        else {                        // extract the character at 0th index, that is            // the character at beginning            char ch = str.charAt(0);                        // append character extracted at the end            // and pass the remaining string to the function            return reverse_sentence(str.substring(1)) + ch;        }    }      public static void main(String[] args)    {        // specify the string to reverse        String str = "Geeksforgeeks";                // call the method to reverse sentence        String rev_str = reverse_sentence(str);                // print the reversed sentence        System.out.println(            "Sentence in reversed form is :  " + rev_str);          // creating another string with numbers        // and special characters        String str2 = "Alice";                String rev_str2 = reverse_sentence(str2);                // print the reversed sentence        System.out.println(            "Sentence in reversed form is :  " + rev_str2);    }}
Sentence in reversed form is :  skeegrofskeeG
Sentence in reversed form is :  ecilA
Time Complexity: O(N), where N is the length of the string.
Picked
Java
Java Programs
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Java Programming Examples
Convert Double to Integer in Java
Implementing a Linked List in Java using Class
How to Iterate HashMap in Java?
Program to print ASCII Value of a character
Convert C/C++ program to Preprocessor code - GeeksforGeeks

29 Aug, 2018
We use g++ compiler to turn provided Cpp code into preprocessor code. To see the preprocessor code generated by the CPP compiler, we can use the “-E” option on the command line:Preprocessor include all the # directives in the code. and also expands MACRO function.
Syntax:
g++ -E filename.cpp

// MACRO named MAX initialism to 10#define MAX 10  int main(){      int a = MAX, b = MAX;      // Add two values.    int c = a + b;      return 0;}
Running the command:
g++ -E geeks.cc

Output :
int main()
{

    int a = 10, b = 10;

    // Add two values.
    int c = a + b;

    return 0;
}

C Language
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
Exception Handling in C++
Multithreading in C
'this' pointer in C++
Arrow operator -> in C/C++ with Examples
Vector in C++ STL
Initialize a vector in C++ (6 different ways)
Inheritance in C++
Map in C++ Standard Template Library (STL)
C++ Classes and Objects
Node.js stats.mtime Property - GeeksforGeeks

08 Oct, 2021
The stats.mtime property is an inbuilt application programming interface of the fs.Stats class is used to get the timestamp when the file is modified last time.
Syntax:
stats.mtime;
Parameters: Properties does not have any parameter.
Return Value: It returns a Date which represents the timestamp when the file is modified last time.
Below examples illustrate the use of stats.mtime property in Node.js:
Example 1:
// Node.js program to demonstrate the   // stats.mtime Property  // Accessing fs moduleconst fs = require('fs');  // Calling fs.Stats stats.mtime// using statfs.stat('./', (err, stats) => {    if (err) throw err;      // The timestamp when the file    // is last modified       console.log("Using stat: " + stats.mtime);});  //using lstatfs.lstat('./filename.txt', (err, stats) => {    if (err) throw err;      // The timestamp when the file    // is last modified       console.log("Using lstat: " + stats.mtime);});
Output:
Using stat: Sun Jun 21 2020 01:08:08 GMT+0530 (India Standard Time)
Using lstat: Sun Jun 21 2020 01:10:16 GMT+0530 (India Standard Time)

Example 2:
// Node.js program to demonstrate the   // stats.mtime Property  // Accessing fs moduleconst fs = require('fs').promises;  // Calling fs.Stats stats.mtime(async () => {    const stats = await fs.stat('./filename.txt');      // The timestamp when the file    // is last modified      console.log("Using stat synchronous: "                + stats.mtime);})().catch(console.error)
Output:
Using stat synchronous: Sun Jun 21 2020 01:10:16 GMT+0530
                                    (India Standard Time)

Note: The above program will compile and run by using the node filename.js command and use the file_path correctly.
Reference: https://nodejs.org/api/fs.html#fs_stats_mtime
Node.js-fs-module
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between dependencies, devDependencies and peerDependencies
How to connect Node.js with React.js ?
Node.js Export Module
Mongoose find() Function
Mongoose Populate() Method
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
What is the usage of DelegatingHandler in Asp.Net webAPI C#?

In a message handler, a series of message handlers are chained together. The first handler receives an HTTP request, does some processing, and gives the request to the next handler. At some point, the response is created and goes back up the chain. This pattern is called a delegating handler.
Along with the built-in Server-side Message Handlers, we can also create our own Server-Side HTTP Message Handlers. To create a custom Server-Side HTTP
Message Handler in ASP.NET Web API, we make use of DelegatingHandler. We have to create a class deriving from System.Net.Http.DelegatingHandler. That custom class then should override the SendAsync method.
Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,
CancellationToken cancellationToken);
The method takes an HttpRequestMessage as input and asynchronously returns an
HttpResponseMessage. A typical implementation does the following −
Process the request message.
Call base.SendAsync to send the request to the inner handler.
The inner handler returns a response message. (This step is asynchronous.)
Process the response and return it to the caller.
public class CustomMessageHandler : DelegatingHandler{
   protected async override Task<HttpResponseMessage> SendAsync(
   HttpRequestMessage request, CancellationToken cancellationToken){
      Debug.WriteLine("CustomMessageHandler processing the request");
      // Calling the inner handler
      var response = await base.SendAsync(request, cancellationToken);
      Debug.WriteLine("CustomMessageHandler processing the response");
      return response;
   }
}
A delegating handler can also skip the inner handler and directly create the response.
public class CustomMessageHandler: DelegatingHandler{
   protected override Task<HttpResponseMessage> SendAsync(
   HttpRequestMessage request, CancellationToken cancellationToken){
      // Create the response
      var response = new HttpResponseMessage(HttpStatusCode.OK){
         Content = new StringContent("Skipping the inner handler")
      };
      // TaskCompletionSource creates a task that does not contain a delegate
      var taskCompletion = new TaskCompletionSource<HttpResponseMessage>();
      taskCompletion.SetResult(response);
      return taskCompletion.Task;
   }
}
Difference between intermediate and terminal operations in Java 8

Stream is introduced in Java 8, it is only used for processing group of data not for the storting elements.. It does not modify the actual collection, they only provide the result as per the pipelined methods.
Stream api supports multiple operations and operations are divided into two parts −
Intermediate Operation- These operations are used to pipeline other methods and to transform into the other streams. They don’t produce results because these operation does not invoke until the terminal operation gets executed. Below are the examples −
sorted(Comparator<T>)
peek(Consumer<T>)
distinct()
Terminal operations - These operations are used to produce results. They can’t be used for chaining the other methods. Below are the examples −
forEach
count
toArray
public class Main {
   public static void main(String args[]) throws InterruptedException, ExecutionException {
      List<String> laptopList = new ArrayList();
      laptopList.add("DELL");
      laptopList.add("ACER");
      laptopList.add("HCL");

      // Intermediate operation
      laptopList.sort((p1, p2) -> p1.compareTo(p2));

      // Terminal Operation
      laptopList.forEach(a -> {
         System.out.println(a);
      });
   }
}
Differences between String and StringBuffer

String is an immutable class and its object can’t be modified after it is created but definitely reference other objects. They are very useful in multithreading environment because multiple threads can’t change the state of the object so immutable objects are thread safe.
String buffer is mutable classes which can be used to do operation on string object such as reverse of string, concating string and etc. We can modify string without creating new object of the string. String buffer is also thread safe.
Also, string concat + operator internally uses StringBuffer or StringBuilder class. Below are the differences.
public class Main {
   public static void main(String args[]) {
      String s1 = "Hello Tutorials Point";
      String upperCase = s1.toUpperCase();
      System.out.println(upperCase);
   }
}
public class StringBufferExample{
   public static void main(String[] args){
      StringBuffer buffer=new StringBuffer("Hi");
      buffer.append("Java 8");
      System.out.println("StringBufferExample" +buffer);
   }
}
C library function - setvbuf()

The C library function int setvbuf(FILE *stream, char *buffer, int mode, size_t size) defines how a stream should be buffered.
Following is the declaration for setvbuf() function.
int setvbuf(FILE *stream, char *buffer, int mode, size_t size)
stream − This is the pointer to a FILE object that identifies an open stream.
stream − This is the pointer to a FILE object that identifies an open stream.
buffer − This is the user allocated buffer. If set to NULL, the function automatically allocates a buffer of the specified size.
buffer − This is the user allocated buffer. If set to NULL, the function automatically allocates a buffer of the specified size.
mode − This specifies a mode for file buffering −
mode − This specifies a mode for file buffering −
_IOFBF
Full buffering − On output, data is written once the buffer is full. On Input the buffer is filled when an input operation is requested and the buffer is empty.
_IOLBF
Line buffering − On output, data is written when a newline character is inserted into the stream or when the buffer is full, what so ever happens first. On Input, the buffer is filled till the next newline character when an input operation is requested and buffer is empty.
_IONBF
No buffering − No buffer is used. Each I/O operation is written as soon as possible. The buffer and size parameters are ignored.
size − This is the buffer size in bytes
size − This is the buffer size in bytes
This function returns zero on success else, non-zero value is returned.
The following example shows the usage of setvbuf() function.
#include <stdio.h>

int main () {
   char buff[1024];

   memset( buff, '\0', sizeof( buff ));

   fprintf(stdout, "Going to set full buffering on\n");
   setvbuf(stdout, buff, _IOFBF, 1024);

   fprintf(stdout, "This is tutorialspoint.com\n");
   fprintf(stdout, "This output will go into buff\n");
   fflush( stdout );

   fprintf(stdout, "and this will appear when programm\n");
   fprintf(stdout, "will come after sleeping 5 seconds\n");

   sleep(5);

   return(0);
}
Let us compile and run the above program to produce the following result. Here program keeps buffering the output into buff until it faces first call to fflush(), after which it again starts buffering the output and finally sleeps for 5 seconds. It sends remaining output to the STDOUT before the program comes out.
Going to set full buffering on
This is tutorialspoint.com
This output will go into buff
and this will appear when programm
will come after sleeping 5 seconds
How to implement inheritance in ES6 ?

08 Nov, 2021
In this article, we will know how inheritance is implemented in es6. The ES6 JavaScript supports Object-Oriented programming components such as Object, Class and Methods. Further in Classes we can implement inheritance to make child inherits all methods of Parent Class. This can be done using the extends and super keywords.
We use the extends keyword to implement the inheritance in ES6. The class to be extended is called a base class or parent class. The class that extends the base class or parent class is called the derived class or child class. The super() method in the constructor is used to access all parent’s properties and methods that are used by the derived class.
The below example will demonstrate the use of the extends and super keywords.
Example: Let us create a Shop class that will inherit the methods from the parent “Mall” class.
HTML
<!DOCTYPE html><html><body>    <h2>JavaScript Class Inheritance</h2>    <p id="demo"></p>        <script>        class Mall {            constructor(shopname) {                this.shopname = shopname;            }            shopispresent() {                return this.shopname +                   ' is present in the  ';            }        }          class Shop extends Mall {            constructor(name, mallname) {                super(name);                this.mallname = mallname;            }            showshop() {                return this.shopispresent() +                  this.mallname;            }        }          let newMall = new Shop(          "Domino", "Select City Walk Mall"        );        document.getElementById("demo")                .innerHTML = newMall.showshop();    </script></body></html>
Output:
Explanation:
In the above example, the super keyword is used as a “function” which calls the parent class Mall with the parameter passed to Shop. This is a key step to be carried out in order to make sure that  Shop is an instance of  Mall.
On the other hand, extends keyword is used to set Shop as a subclass or child class of Mall. The use of extends is a must to set some class as a child of other class.
ES6
JavaScript-Questions
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
Roadmap to Learn JavaScript For Beginners
JavaScript | Promises
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
scipy stats.kurtosis() function | Python

20 Jun, 2022
scipy.stats.kurtosis(array, axis=0, fisher=True, bias=True) function calculates the kurtosis (Fisher or Pearson) of a data set. It is the fourth central moment divided by the square of the variance. It is a measure of the “tailedness” i.e. descriptor of shape of probability distribution of a real-valued random variable. In simple terms, one can say it is a measure of how heavy tail is compared to a normal distribution. Its formula – 
Parameters : array : Input array or object having the elements. axis : Axis along which the kurtosis value is to be measured. By default axis = 0. fisher : Bool; Fisher’s definition is used (normal 0.0) if True; else Pearson’s definition is used (normal 3.0) if set to False. bias : Bool; calculations are corrected for statistical bias, if set to False. Returns : Kurtosis value of the normal distribution for the data set.
Code #1: 
Python3
# Graph using numpy.linspace()# finding kurtosis from scipy.stats import kurtosisimport numpy as npimport pylab as p x1 = np.linspace( -5, 5, 1000 )y1 = 1./(np.sqrt(2.*np.pi)) * np.exp( -.5*(x1)**2  ) p.plot(x1, y1, '*')  print( '\nKurtosis for normal distribution :', kurtosis(y1)) print( '\nKurtosis for normal distribution :',      kurtosis(y1, fisher = False)) print( '\nKurtosis for normal distribution :',      kurtosis(y1, fisher = True))
Output :

Kurtosis for normal distribution : -0.3073930877422071

Kurtosis for normal distribution : 2.692606912257793

Kurtosis for normal distribution : -0.3073930877422071
simmytarika5
Python scipy-stats-functions
Python-scipy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
MassDNS – High-Performance DNS Stub Resolver Tool

08 Nov, 2021
MassDNS is a C language-based tool that is simple and has high-performance DNS root resolver capability for those who seek to resolve a massive number of domain names in the order of billions. Without suitable configuration, MassDNS is steady at resolving 346000 words per second using publicly available resolvers. MassDNS tool is a single-threaded tool designed for situations in which the network scope is massive. Only finding Subdomains of the Target domain is not important; most of them aren’t live anymore, so it would be better to remove them from your list or subdomains.txt. If you perform the mass scanning, then you can filter out the active or live hosts. MassDNS is intended to be run in servers with high-speed upload and download bandwidths. Internally, the MassDNS tool uses a hash map technique to control the concurrency of domain lookups.
Step 1: Open your Kali Linux terminal and move to the desktop using the following command. On the desktop, we have to create a directory in which we will install the tool or clone the tool from GitHub.
cd Desktop/
Step 2: Now, we are on the desktop. We will create a new directory called MassDNS using the following command.
mkdir MassDNS
cd MassDNS/
Step 3: Now you are under MassDNS directory. Here you have to clone the MassDNS tool. GitHub To clone the tool, use the following command.
git clone https://github.com/blechschmidt/massdns.git
Step 4: Now, the tool has been cloned successfully to the MassDNS directory. Now list out the contents of the tool using the following commands.
ls
Step 5: You can see a new directory here, massdns created. Move to this directory using the following command.
cd massdns/
Step 6: Check if make is available on your system or not.
make
Step 7: Install the tool using the make, use the following command.
sudo make install
Step 8: Tool is installed now, check the help menu page to get a better understanding of the MassDNS tool. Use the following command.
massdns -h
Example 1: We are running assetfinder tool for subdomains and massDNS tool for resolving.
assetfinder att.com –subs-only | massdns -r lists/resolvers.txt -o S -w resolved.txt
Detailed Result of Information Gathering is shown in the following Screenshot. OK Response Number, NXDOMAIN,  SERVERFAIL, etc.
Detailed Domain ,Subdomain with CNAME and IP address is shown for att.com
Filtering Results, using sed command to filter:
sed ‘s/A.*//’ resolved.txt | sed ‘s/CN.*//’ | sed ‘s/\..$//’
ruhelaa48
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ZIP command in Linux with examples
tar command in Linux with examples
curl command in Linux with Examples
SORT command in Linux/Unix with examples
'crontab' in Linux with Examples
Tail command in Linux with examples
Conditional Statements | Shell Script
TCP Server-Client implementation in C
Docker - COPY Instruction
scp command in Linux with Examples
Python – Test if all elements in list are of same type

09 Mar, 2020
Sometimes, while working with Python, we can have a problem in which we need to test if all the elements of argument are of same type or not. This can have application in many domains such as data Science and day-day programming. Lets discuss certain ways in which this task can be performed.
Method #1 : Using loop + isinstance()The combination of above functionalities can be used to perform this task. In this, we test for type using isinstance() and check for all elements if they match same type as of 1st element.
# Python3 code to demonstrate # Test if all elements in list are of same type# using loop + isinstance()  # Initializing liststest_list = [5, 6, 2, 5, 7, 9]  # printing original listprint("The original list is : " + str(test_list))  # Test if all elements in list are of same type# using loop + isinstance()res = Truefor ele in test_list:    if not isinstance(ele, type(test_list[0])):        res = False         break  # printing result print ("Do all elements have same type : " + str(res))
The original list is : [5, 6, 2, 5, 7, 9]
Do all elements have same type : True

 
Method #2 : Using all() + isinstance()This is yet another way to perform this task. In this, we instead of iterating perform the task in one line using all and instance().
# Python3 code to demonstrate # Test if all elements in list are of same type# using all() + isinstance()  # Initializing liststest_list = [5, 6, 2, 5, 7, 9]  # printing original listprint("The original list is : " + str(test_list))  # Test if all elements in list are of same type# using all() + isinstance()res = all(isinstance(sub, type(test_list[0])) for sub in test_list[1:])  # printing result print ("Do all elements have same type : " + str(res))
The original list is : [5, 6, 2, 5, 7, 9]
Do all elements have same type : True

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
Python program to convert a list to string
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Python | Split string into list of characters
Java Program to generate random number array within a range and get min and max value

At first, create a double array −
double[] val = new double[10];
Now, generate and display random numbers in a loop that loops until the length of the above array. We have used nextInt here for random numbers −
for (int i = 0; i < val.length; i++) {
   val[i] = new Random().nextInt(100);
   System.out.println(val[i]);
}
Now, get the min and max values. Compare each value of the random array with the MIN and MAX values −
double min = Double.MAX_VALUE;
double max = Double.MIN_VALUE;
for (int i = 0; i < val.length; i++) {
   if (val[i] < min)
      min = val[i];
   if (val[i] > max)
      max = val[i];
}
 Live Demo
import java.util.Random;
public class Demo {
   public static void main(String[] args) {
      double[] val = new double[10];
      double min = Double.MAX_VALUE;
      double max = Double.MIN_VALUE;
      System.out.println("Random number array...");
      for (int i = 0; i < val.length; i++) {
         val[i] = new Random().nextInt(100);
         System.out.println(val[i]);
      }
      for (int i = 0; i < val.length; i++) {
         if (val[i] < min)
            min = val[i];
         if (val[i] > max)
            max = val[i];
      }
      System.out.println("Minimum element = " + min);
      System.out.println("Maximum element = " + max);
   }
}
Random number array...
75.0
42.0
47.0
71.0
12.0
70.0
86.0
97.0
14.0
41.0
Minimum element = 12.0
Maximum element = 97.0
Python – Remove numbers with repeating digits

28 Apr, 2022
Given a list of numbers, the task is to write a Python program to remove all numbers with repetitive digits.
Examples:
Input : test_list = [4252, 6578, 3421, 6545, 6676]
Output : test_list = [6578, 3421]
Explanation : 4252 has 2 occurrences of 2 hence removed. Similar case for all other removed.
Input : test_list = [4252, 6578, 3423, 6545, 6676]
Output : test_list = [6578]
Explanation : 4252 has 2 occurrences of 2 hence removed. Similar case for all other removed.
Method #1 : Using set() + len() + list comprehension
In this, we perform the task of eliminating repeating elements using set() and then compare the length to be equal to the original length. If found, True is returned, else False is returned.
Python3
# Python3 code to demonstrate working of# Remove numbers with repeating digits# Using set() + len() + list comprehension # initializing listtest_list = [4252, 6578, 3421, 6545, 6676] # printing original listprint("The original list is : " + str(test_list)) # set() used to remove digitsres = [sub for sub in test_list if len(set(str(sub))) == len(str(sub))] # printing resultprint("List after removing repeating digit numbers : " + str(res))
Output:
The original list is : [4252, 6578, 3421, 6545, 6676]
List after removing repeating digit numbers : [6578, 3421]
Method #2 : Using regex()
Appropriate regex can also be used for the task of checking for each digit repetition only once.
Python3
# Python3 code to demonstrate working of# Remove numbers with repeating digits# Using regex()import re # initializing listtest_list = [4252, 6578, 3421, 6545, 6676] # printing original listprint("The original list is : " + str(test_list)) # regex used to remove elements with repeating digitsregex = re.compile(r"(\d).*\1")res = [sub for sub in test_list if not regx.search(str(sub))] # printing resultprint("List after removing repeating digit numbers : " + str(res))
Output:
The original list is : [4252, 6578, 3421, 6545, 6676]
List after removing repeating digit numbers : [6578, 3421]
rajeev0719singh
sweetyty
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Python | Convert string dictionary to dictionary