code-rag-bench/online-tutorials huggingface dataset:
Math operations for BigDecimal in Java

Let us apply the following operations on BigDecimal using the in-built methods in Java −
Addition: add() method
Subtraction: subtract() method
Multiplication: multiply() method
Division: divide() method
Let us create three BigInteger objects −
BigDecimal val1 = new BigDecimal("37578975587.876876989");
BigDecimal val2 = new BigDecimal("62567875598.976876569");
BigDecimal val3 = new BigDecimal("72567875598.376876569");
Apply mathematical operations on them −
val1 = val1.add(val2);
System.out.println("Addition Operation = " + val1);
val1 = val1.multiply(val2);
System.out.println("Multiplication Operation = " + val1);
val2 = val3.subtract(val2);
System.out.println("Subtract Operation = " + val2);
The following is an example −
 Live Demo
import java.math.BigDecimal;
public class Demo {
   public static void main(String[] argv) throws Exception {
      BigDecimal val1 = new BigDecimal("37578975587.876876989");
      BigDecimal val2 = new BigDecimal("62567875598.976876569");
      BigDecimal val3 = new BigDecimal("72567875598.376876569");
      System.out.println("Value 1 : "+val1);
      System.out.println("Value 2 : "+val2);
      val1 = val1.add(val2);
      System.out.println("Addition Operation = " + val1);
      val1 = val1.multiply(val2);
      System.out.println("Multiplication Operation = " + val1);
      val2 = val3.subtract(val2);
      System.out.println("Subtract Operation = " + val2);
      val2 = val3.divide(val2,BigDecimal.ROUND_UP);
      System.out.println("Division Operation = " + val2);
   }
}
Value 1 : 37578975587.876876989
Value 2 : 62567875598.976876569
Addition Operation = 100146851186.853753558
Multiplication Operation = 6265975726688315418019.861150364510582502
Subtract Operation = 9999999999.400000000
Division Operation = 7.256787561
React State

React components has a built-in state 
object. 
The state object is where you 
store property values that belongs to the component.
When the state object changes, 
the component re-renders.
The state object is initialized in the constructor:
Specify the state object in the constructor method:
class Car extends React.Component {
  constructor(props) {
    super(props);
    this.state = {brand: "Ford"};
  }
  render() {
    return (
      <div>
        <h1>My Car</h1>
      </div>
    );
  }
}
 

The state object can contain as many properties as you like:
Specify all the properties your component need:
class Car extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      brand: "Ford",
      model: "Mustang",
      color: "red",
      year: 1964
    };
  }
  render() {
    return (
      <div>
        <h1>My Car</h1>
      </div>
    );
  }
}
 
 
 
 
 
 

Refer to the state object anywhere in the component by using the
this.state.propertyname syntax:
Refer to the state object in the 
  render() method:
class Car extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      brand: "Ford",
      model: "Mustang",
      color: "red",
      year: 1964
    };
  }
  render() {
    return (
      <div>
        <h1>My {this.state.brand}</h1>
        <p>
          It is a {this.state.color}
          {this.state.model}
          from {this.state.year}.
        </p>
      </div>
    );
  }
}
 
 
 
 
 
 


Run 
Example »

To change a value in the state object, use the this.setState() method.
When a value in the state object changes, 
the component will re-render, meaning that the output will change according to 
the new value(s).
Add a button with an onClick event that 
  will change the color property:
class Car extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      brand: "Ford",
      model: "Mustang",
      color: "red",
      year: 1964
    };
  }
  changeColor = () => {
    this.setState({color: "blue"});
  }
  render() {
    return (
      <div>
        <h1>My {this.state.brand}</h1>
        <p>
          It is a {this.state.color}
          {this.state.model}
          from {this.state.year}.
        </p>
        <button
          type="button"
          onClick={this.changeColor}
        >Change color</button>
      </div>
    );
  }
}
 
 
 
 
 
 
 


Run 
Example »

Always use the setState() method to change the state object,
it will ensure that the component knows its been updated and calls the render() method
(and all the other lifecycle methods).
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
What is Common Locale Data Repository (CLDR) in Java 9?


Internationalization enhancements for Java 9 include enabling of CLDR Locale Data by Default.
There are four distinct sources for locale data identified by using the below keywords:
CLDR: The locale data provided by a Unicode Common Locale Data Repository (CLDR) project.
HOST: The current user’s customization of an underlying operating system’s settings. Depending on the operating system, formats like date, time, number, and currency can be supported.
SPI: The locale-sensitive services implemented in installed SPI providers.
COMPAT (JRE): The locale data that is compatible with releases prior to Java 9. The JRE can still be used as a value but deprecated, and removed in the future.
In Java 8 and previous versions, JRE is default locale data. Java 9 sets CLDR as the highest priority by default. We select a locale data source in preferred order by using java.locale.providers system property. If a provider has failed to request locale data, the next provider can be processed.
java.locale.providers=COMPAT,CLDR,HOST,SPI
If we don’t set the property, the default behavior is:
java.locale.providers=CLDR,COMPAT,SPI
To make compatible with Java 8, keep COMPAT ahead of CLDR.
java.locale.providers=COMPAT,CLDR
C Program for Activity Selection Problem

The activity selection problem is a problem in which we are given a set of activities with their starting and finishing times. And we need to find all those activities that a person can do performing the single activity at a time.
The greedy algorithm is appointed in this problem to select the next activity that is to be performed. Let’s first understand the greedy algorithm.
Greedy Algorithm is an algorithm that tries to find the solution to a problem by finding the solution step by step. For selecting the next step, the algorithm also selected the step that seems to be the most promising i.e. can lead to the optimised solution immediately as compared to rest. The greedy algorithm is used to solve optimization problems as it tries to find the most optimized solution for the next intermediate step that leads to an optimal solution to the whole problem.
Though the greedy algorithm is a good solution but there are some problems with which it cannot be applied. For example, 0-1 knapsack cannot be solved using the greedy algorithm.
Some standard greedy algorithm is −
1) Dijkstrata’s Shortest Path
2) Minimum Spanning Tree (MST) {prim’s and kruskal’s}
3) Huffman coding
Inactivity selection problem, we are given n problems with starting and finishing time. And we need to select the maximum number of activities that can be performed by an individual is given that he can do a single activity at a point of time.
There are 3 activities which are sorted in order of their finishing time,
Start = [1 , 5 , 12 ]
End = [10, 13, 23]
Here, the person will be able to perform two activities at most. Activities that can be executed are [0, 2].
 Live Demo
#include<stdio.h>
int main(){
   int start[] = {1 , 5 , 12};
   int finish[] = {10, 13, 23};
   int activities = sizeof(start)/sizeof(start[0]);
   int i, j;
   printf ("Following activities are selected \t");
   i = 0;
   printf("%d\t", i);
   for (j = 1; j < activities; j++){
      if (start[j] >= finish[i]){
         printf ("%d ", j);
         i = j;
      }
   }
   return 0;
}
Following activities are selected 0 2
Gson - Tree Model

Tree Model prepares an in-memory tree representation of the JSON document. It builds a tree of JsonObject nodes. It is a flexible approach and is analogous to DOM parser for XML.
JsonParser provides a pointer to the root node of the tree after reading the JSON. Root Node can be used to traverse the complete tree. Consider the following code snippet to get the root node of a provided JSON String.
//Create an JsonParser instance 
JsonParser parser = new JsonParser(); 

String jsonString = 
"{\"name\":\"Mahesh Kumar\", \"age\":21,\"verified\":false,\"marks\": [100,90,85]}"; 

//create tree from JSON 
JsonElement rootNode = parser.parse(jsonString);

Get each node using relative path to the root node while traversing the tree and process the data. The following code snippet shows how you can traverse a tree.
JsonObject details = rootNode.getAsJsonObject(); 

JsonElement nameNode = details.get("name"); 
System.out.println("Name: " +nameNode.getAsString()); 

JsonElement ageNode = details.get("age"); 
System.out.println("Age: " + ageNode.getAsInt()); 

Create a Java class file named GsonTester in C:\>GSON_WORKSPACE.
File − GsonTester.java
import com.google.gson.JsonArray; 
import com.google.gson.JsonElement; 
import com.google.gson.JsonObject; 
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;  

public class GsonTester { 
   public static void main(String args[]) { 
   
      String jsonString = 
         "{\"name\":\"Mahesh Kumar\", \"age\":21,\"verified\":false,\"marks\": [100,90,85]}";
      JsonParser parser = new JsonParser();  
      JsonElement rootNode = parser.parse(jsonString);  
      
      if (rootNode.isJsonObject()) { 
         JsonObject details = rootNode.getAsJsonObject();  
         JsonElement nameNode = details.get("name"); 
         System.out.println("Name: " +nameNode.getAsString());  
         
         JsonElement ageNode = details.get("age"); 
         System.out.println("Age: " + ageNode.getAsInt());  
         
         JsonElement verifiedNode = details.get("verified"); 
         System.out.println("Verified: " + (verifiedNode.getAsBoolean() ? "Yes":"No"));  
         JsonArray marks = details.getAsJsonArray("marks"); 
         
         for (int i = 0; i < marks.size(); i++) { 
            JsonPrimitive value = marks.get(i).getAsJsonPrimitive(); 
            System.out.print(value.getAsInt() + " ");  
         } 
      } 
   }   
}
Compile the classes using javac compiler as follows −
C:\GSON_WORKSPACE>javac GsonTester.java 

Now run the GsonTester to see the result −
C:\GSON_WORKSPACE>java GsonTester 

Verify the output.
Name: Mahesh Kumar 
Age: 21 
Verified: No 
100 90 85

 Print
 Add Notes
 Bookmark this page
Java Program to convert from decimal to binary

To convert decimal to binary, Java has a method “Integer.toBinaryString()”. The method returns a string representation of the integer argument as an unsigned integer in base 2.
Let us first declare and initialize an integer variable.
int dec = 25;
Convert it to binary.
String bin = Integer.toBinaryString(dec);
Now display the “bin” string, which consists of the Binary value. Here is the complete example.
 Live Demo
public class Demo {
   public static void main( String args[] ) {
      int dec = 25;
      // converting to binary and representing it in a string
      String bin = Integer.toBinaryString(dec);
      System.out.println(bin);
   }
}
11001
How to add JList to Scroll pane in Java?

To add JList to Scroll pane in Java, use JScrollPane:
JList list = new JList(sports);
JScrollPane scrollPane = new JScrollPane(list);
After that set it to Container:
Container contentPane = frame.getContentPane();
contentPane.add(scrollPane, BorderLayout.CENTER);
The following is an example to add JList to Scroll pane:
package my;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
class SwingDemo extends JFrame {
   static JFrame frame;
   static JList list;
   public static void main(String[] args) {
      frame = new JFrame("JList Demo");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      String sports[]= {"Tennis","Archery","Football","Fencing","Cricket","Squash","Hockey","Rugby"};
      list = new JList(sports);
      JScrollPane scrollPane = new JScrollPane(list);
      Container contentPane = frame.getContentPane();
      contentPane.add(scrollPane, BorderLayout.CENTER);
      frame.setSize(400,100);
      frame.setVisible(true);
   }
}
The output is as follows. As you can see ScrollPane is visible for the items:
How to get device make and model on iOS?

When we talk about the device make, we refer to the Phone manufacturer (e.g. Apple, Samsung, Nokia and so on) and device model is generally the specific product such as iPhone, iPad/TAB etc.
Any mobile devices will be categorized using make and model only.
Now let’s understand how do I get device make and model in iOS?
There are two ways to get make and model the first way is to directly open your iOS device, navigate to setting, tap on general and in the about section you can find the details of your iOS device
The second way is getting make and model using
Open Xcode → New Project and add the below code in ViewController’s viewDidLoad method.
let modelName = UIDevice.current.model
let name = UIDevice.current.name

print(modelName) // iPhone
print(name) // iPhone XR
UIDevice.current.model, gives you a model whether you have an iPhone, iPad, UIDevice.current.name gives you a name identifying the device.
NODE_ENV Variables and How to Use Them ? - GeeksforGeeks

22 Jul, 2020
Introduction: NODE_ENV variables are environment variables that are made popularized by the express framework. The value of this type of variable can be set dynamically depending on the environment(i.e., development/production) the program is running on. The NODE_ENV works like a flag which indicates whether the server is running on development or production mode. The express framework checks the flag value in the runtime and sets value depending on the environment.
Setting NODE_ENV Variable: Setting up the NODE_ENV variable depends on the operating system and also on the user’s setup.
To set the environment variable globally to some value, we can run the code from the command line.
For Linux and Mac Operating System:
export NODE_ENV = production
For Windows Operating System
$env:NODE_ENV = 'production'
We can also apply the environment variable in the application initialization command using the code below assuming we are running a script called app.js.
NODE_ENV = production node app.js
In Windows, the code is different. We use the code below:
set NODE_ENV=production&&node app.js
Because different operating systems require different command, there is a package available called cross-env which makes the command cross-platform. 
npx cross-env NODE_ENV=production node app.js
The above code will work on any platform where the cross-env package is installed as a developer dependency.
If we are using express, we can provide environment-specific settings that are automatically called based on the environment we are working on.
Syntax:
if(process.env.NODE_ENV == 'development') {   // Code for Development Mode} else {   // Code for Testing Mode}
Suppose our database server is the localhost when we are working on development mode and we’ll be using https://production-server.com for production. The code can be set accordingly.
if(process.env.NODE_ENV == 'development') {    db.connect('localhost:1234')} else {    db.connect('https://production-server.com')}
The above code will check the environment and will set it’s server accordingly.
Conclusion: Use of the production environment is a good practice because in the production environment, usually logging is kept minimum also more caching levels take place for optimized performance. So, it is always a good practice to set up the environment variable to production mode whenever we are deploying our app to the production server.
Node.js-Misc
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Express.js express.Router() Function
Node.js fs.readFile() Method
Node.js fs.writeFile() Method
How to install the previous version of node.js and npm ?
Difference between promise and async await in Node.js
Roadmap to Become a Web Developer in 2022
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Convert a string to an integer in JavaScript
How to upload files using Selenium Webdriver?

We can upload files using Selenium Webdriver. This is achieved by the sendKeys method. We have to first identify the element which performs the file selection by mentioning the file path [to be uploaded].
This is only applied to an element having a type attribute set to file as a value along with the element tag name as input. The below html code shows the element with type = file value set.
Code Implementation.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class WndsFileUpl{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver",
      "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();

      //implicit wait
      driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

      //launch application
      driver.get("https://www.tutorialspoint.com/selenium/selenium_automation_practice.htm");

      // identify element
      WebElement m=driver.findElement(By.xpath("//input[@type='file']"));

      // windows file upload with file path
      m.sendKeys("C:\\Users\\Pictures\\Logo.jpg");

      //browser close
      driver.close();
   }
}
Batch Script - Input / Output - GeeksforGeeks

28 Nov, 2021
In this article, we are going to learn how to take input from users using Batch Script.
@echo off
echo Batch Script to take input.
set /p input= Type any input
echo Input is: %input%
pause
The first ‘echo’ command is used to print a string.
In the next line, ‘set  /p’ command is used to take user input followed by a variable that will hold user input.
set /p input= Type any input
Then for printing the user input we will use ‘%’ on both ends of our variable which is used for holding user input in the previous step.
echo Input is : %input%
‘ pause ‘ is used to hold the screen until any key is pressed.
code for taking user input
1. After saving the above code with .bat format. When we will run the file, the below cmd screen will be shown.
After running the file
2. In the next step we will provide any input, as shown.
Giving input as Geeks For Geeks
3. After pressing enter we will get user input data as Output, as shown in the below image.
Final Output is displayed
Batch-script
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scp command in Linux with Examples
Docker - COPY Instruction
SED command in Linux | Set 2
mv command in Linux with examples
chown command in Linux with Examples
nohup Command in Linux with Examples
Named Pipe or FIFO with example C program
Thread functions in C/C++
uniq Command in LINUX with examples
Start/Stop/Restart Services Using Systemctl in Linux
NumPy - Histogram Using Matplotlib

NumPy has a numpy.histogram() function that is a graphical representation of the frequency distribution of data. Rectangles of equal horizontal size corresponding to class interval called bin and variable height corresponding to frequency.
The numpy.histogram() function takes the input array and bins as two parameters. The successive elements in bin array act as the boundary of each bin.
import numpy as np 
   
a = np.array([22,87,5,43,56,73,55,54,11,20,51,5,79,31,27]) 
np.histogram(a,bins = [0,20,40,60,80,100]) 
hist,bins = np.histogram(a,bins = [0,20,40,60,80,100]) 
print hist 
print bins 
It will produce the following output −
[3 4 5 2 1]
[0 20 40 60 80 100]

Matplotlib can convert this numeric representation of histogram into a graph. The plt() function of pyplot submodule takes the array containing the data and bin array as parameters and converts into a histogram.
from matplotlib import pyplot as plt 
import numpy as np  
   
a = np.array([22,87,5,43,56,73,55,54,11,20,51,5,79,31,27]) 
plt.hist(a, bins = [0,20,40,60,80,100]) 
plt.title("histogram") 
plt.show()
It should produce the following output −

    63 Lectures 
     6 hours 

 Abhilash Nelson

    19 Lectures 
     8 hours 

 DATAhill Solutions Srinivas Reddy

    12 Lectures 
     3 hours 

 DATAhill Solutions Srinivas Reddy

    10 Lectures 
     2.5 hours 

 Akbar Khan

    20 Lectures 
     2 hours 

 Pruthviraja L

    63 Lectures 
     6 hours 

 Anmol
 Print
 Add Notes
 Bookmark this page
Java program to check if a string contains any special character

To check if a string contains any special character, the Java program is as follows −
 Live Demo
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Demo {
   public static void main(String[] args){
      String my_str="This is a sample only !$@";
      Pattern my_pattern = Pattern.compile("[^a-z0-9 ]", Pattern.CASE_INSENSITIVE);
      Matcher my_match = my_pattern.matcher(my_str);
      boolean check = my_match.find();
      if (check)
         System.out.println("Special character found in the string");
      else
         System.out.println("Special character not found in the string");
   }
}
Special character found in the string
A class named Demo contains the main function, where a string is defined, with some special
characters. A pattern is defined that uses regular expressions to check if the string has any special
characters. A Boolean value is defined, that checks to see for the same. If the value of Bool is true, a
success message is printed, otherwise, a message stating the absence of these special characters is
printed on the screen.
Java Program to Swap Two Numbers Using Bitwise XOR Operation - GeeksforGeeks

09 Nov, 2020
Given two numbers x and y. We have to write a Java Program to Swap the contents of two numbers using Bitwise XOR Operation.
Input 1: x = 5, y = 10
Output : x = 10, y = 5
Explaination :
1. x = x ^ y -> x = 15
2. y = x ^ y -> y = 5
3. x = x ^ y -> x = 10

Input 2: x = 15, y = 20
Output : x = 20, y = 15

The bitwise XOR operator(represented by ^) compares corresponding bits of two operands and returns 1 if they are equal and 0 if they are not equal.  Let’s say we have two numbers x and y, so what actually x^y will do is that it will compare every corresponding bit of x and y, and if they are different, it will generate 1 as the output of that two bits(one of x and one of y)  taken into consideration and if bits are same, then it will generate 0 as the output of two bits.
Below is the code implementation of the above approach:-
Java
// Java program to swap the elements using XOR Operatorimport java.io.*;class GFG {    public static void main(String[] args)    {        int x = 5, y = 10;        // binary equivalent of 5 is 0101        // binary equivalent of 10 is 1010          // binary equivalent of x  will become 1111 ie x=15        x = x ^ y;        // binary equivalent of y  will become 0101 ie y=5        y = x ^ y;        // binary equivalent of x  will become 1010 ie x=10        x = x ^ y;        System.out.println("The value of x is " + x                           + " and the value of y is " + y);    }}
The value of x is 10 and the value of y is 5

Technical Scripter 2020
Java
Java Programs
Technical Scripter
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Hashtable in Java
Constructors in Java
Different ways of Reading a text file in Java
Comparator Interface in Java with Examples
HashMap containsKey() Method in Java
Convert a String to Character array 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?
Cypress - Get and Post

The Get and Post methods are a part of the Application Programming Interface (API) testing, which can be performed by Cypress.
To perform a Get operation, we shall make a HTTP request with the cy.request() and pass the method Get and URL as parameters to that method.
The status code reflects, if the request has been accepted and handled correctly. The code 200(means ok) and 201(means created).
The implementation of Get method in Cypress is explained below −
describe("Get Method", function(){
   it("Scenario 2", function(){
      cy.request("GET", "https://jsonplaceholder.cypress.io/comments", {
      }).then((r) => {
         expect(r.status).to.eq(200)
         expect(r).to.have.property('headers')
         expect(r).to.have.property('duration')
      });
   })
})
Execution Results
The output is as follows −
While using the Post method, we are actually sending information. If we have a group of
entities, we can append new ones at the end, with the help of Post.
To perform a Post operation, we shall make a HTTP request with the cy.request() and
pass the method Post and URL as parameters to that method.
Given below is an implementation of Post method in Cypress −
describe("Post Method", function(){
   it("Scenario 3", function(){
      cy.request('https://jsonplaceholder.cypress.io/users?_limit=1')
      .its('body.0') // yields the first element of the returned list
      // make a new post on behalf of the user
      cy.request('POST', 'https://jsonplaceholder.cypress.io/posts', {
         title: 'Cypress',
         body: 'Automation Tool',
      })
   })
});
Execution Results
The output is given below −

    73 Lectures 
     12 hours 

 Rahul Shetty
 Print
 Add Notes
 Bookmark this page
How to remove all CSS classes using jQuery ? - GeeksforGeeks

31 Dec, 2020
In this article, we will remove all CSS classes for an element using jQuery. To remove all CSS classes of an element, we use removeClass() method.
The removeClass() method is used to remove one or more class names from the selected element.
Syntax:
$(selector).removeClass(class_name, function(index, class_name))
Parameters: This function accepts two parameters as mentioned above and described below:
class_name: It is optional parameter which is used to specify the class name (one or more class) to remove. Multiple class name separated with space.
function: It is optional parameter and it returns one or more class name which need to be removed.index: This parameter is used to return index of element.current_class_name: This parameter returns the class name of selected elements.
index: This parameter is used to return index of element.current_class_name: This parameter returns the class name of selected elements.
index: This parameter is used to return index of element.
current_class_name: This parameter returns the class name of selected elements.
Example:
HTML
<!DOCTYPE html><html lang="en">  <head>    <title>        How to remove all CSS classes using jQuery?    </title>      <style>        .GFG1 {            color: green;        }          .GFG2 {            font-size: 30px;            font-weight: bold;        }    </style>      <!-- Import jQuery cdn library -->    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>      <script>        $(document).ready(function () {            $("button").click(function () {                $("p").removeClass();            });        });    </script></head>  <body style="text-align: center;">    <h1 style="color: green;">        GeeksforGeeks    </h1>      <h3>        How to remove all CSS classes using jQuery?    </h3>      <p class="GFG1 GFG2">        Computer Science Portal    </p>      <button>Click Here!</button></body>  </html>
Output:
Before button Click:
After Button Click:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Misc
HTML-Misc
jQuery-Misc
CSS
HTML
JQuery
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Design a web page using HTML and CSS
Form validation using jQuery
How to set space between the flexbox ?
Search Bar using HTML, CSS and JavaScript
How to style a checkbox using CSS?
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
Hide or show elements in HTML using display property
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
SQL - Handling Duplicates

There may be a situation when you have multiple duplicate records in a table. While fetching such records, it makes more sense to fetch only unique records instead of fetching duplicate records.
The SQL DISTINCT keyword, which we have already discussed is used in conjunction with the SELECT statement to eliminate all the duplicate records and by fetching only the unique records.
The basic syntax of a DISTINCT keyword to eliminate duplicate records is as follows.
SELECT DISTINCT column1, column2,.....columnN 
FROM table_name
WHERE [condition]

Consider the CUSTOMERS table having the following records.
+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
First, let us see how the following SELECT query returns duplicate salary records.
SQL> SELECT SALARY FROM CUSTOMERS
   ORDER BY SALARY;
This would produce the following result where the salary of 2000 is coming twice which is a duplicate record from the original table.
+----------+
| SALARY   |
+----------+
|  1500.00 |
|  2000.00 |
|  2000.00 |
|  4500.00 |
|  6500.00 |
|  8500.00 |
| 10000.00 |
+----------+

Now, let us use the DISTINCT keyword with the above SELECT query and see the result.
SQL> SELECT DISTINCT SALARY FROM CUSTOMERS
   ORDER BY SALARY;
This would produce the following result where we do not have any duplicate entry.
+----------+
| SALARY   |
+----------+
|  1500.00 |
|  2000.00 |
|  4500.00 |
|  6500.00 |
|  8500.00 |
| 10000.00 |
+----------+


    42 Lectures 
     5 hours 

 Anadi Sharma

    14 Lectures 
     2 hours 

 Anadi Sharma

    44 Lectures 
     4.5 hours 

 Anadi Sharma

    94 Lectures 
     7 hours 

 Abhishek And Pukhraj

    80 Lectures 
     6.5 hours 

 Oracle Master Training | 150,000+ Students Worldwide

    31 Lectures 
     6 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
How can I create a stored procedure to insert values in a MySQL table?

We can create a stored procedure with an IN operator to insert values in a MySQL table. To make it understand we are taking an example of a table named ‘student_info’ having the following data −
mysql> Select * from student_info;
+------+---------+-----------+------------+
| id   | Name    | Address   | Subject    |
+------+---------+-----------+------------+
| 100  | Aarav   | Delhi     | Computers  |
| 101  | YashPal | Amritsar  | History    |
| 105  | Gaurav  | Jaipur    | Literature |
| 110  | Rahul  | Chandigarh | History    |
+------+---------+------------+------------+
4 rows in set (0.00 sec)
Now, by creating the procedure named ‘insert_studentinfo’ as follow, we can insert the values in ‘student_info’ table −
mysql> DELIMITER // ;
mysql> Create PROCEDURE insert_studentinfo(IN p_id int, IN p_name varchar(20),IN p_Address Varchar(20), IN p_subject Varchar(20))
    -> BEGIN
    -> insert into student_info(id, name, address, subject) values (p_id, p_name,p_address, p_subject);
    -> END //
Query OK, 0 rows affected (0.09 sec)
Now, invoke the procedure with the values we want to insert in the table as follows −
mysql> CALL insert_studentinfo(125,'Raman','Bangalore','Computers')//
Query OK, 1 row affected (0.78 sec)

mysql> DELIMITER ; //

mysql> Select * from Student_info;
+-----+---------+------------+------------+
| id  | Name    | Address    | Subject    |
+-----+---------+------------+------------+
| 100 | Aarav   | Delhi      | Computers  |
| 101 | YashPal | Amritsar   | History    |
| 105 | Gaurav  | Jaipur     | Literature |
| 110 | Rahul   | Chandigarh | History    |
| 125 | Raman   | Bangalore  | Computers  |
+------+---------+------------+-----------+
5 rows in set (0.00 sec)
The above result set shows that the values get inserted in the table.
Generate Random Float type number in Java

In order to generate Random float type numbers in Java, we use the nextFloat() method of the java.util.Random class. This returns the next random float value between 0.0 (inclusive) and 1.0 (exclusive) from the random generator sequence.
Declaration −The java.util.Random.nextFloat() method is declared as follows −
public float nextFloat()
Let us see a program to generate random float type numbers in Java.
 Live Demo
import java.util.Random;
public class Example {
   public static void main(String[] args) {
      Random rd = new Random(); // creating Random object
      System.out.println(rd.nextFloat()); // displaying a random float value between 0.0 and 1.0
   }
}
0.7739767
Note − The output might vary on Online Compilers.
Tcl - Break Statement

The break statement in Tcl language is used for terminating a loop. When the break statement is encountered inside a loop, the loop is immediately terminated and program control resumes at the next statement following the loop.
If you are using nested loops (i.e., one loop inside another loop), the break statement will stop the execution of the innermost loop and start executing the next line of code after the block.
The syntax for a break statement in Tcl is as follows −
break;

#!/usr/bin/tclsh

set a 10

# while loop execution 
while {$a < 20 } {
   puts "value of a: $a"
   incr a
   if { $a > 15} {
      # terminate the loop using break statement 
      break
   }
}
When the above code is compiled and executed, it produces the following result −
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15

 Print
 Add Notes
 Bookmark this page
Whirlpool Hash Function in Python

13 Jul, 2021
Hash Function is a function which has a huge role in making a System Secure as it converts normal data given to it as an irregular value of fixed length. We can imagine it to be a Shaker in our homes. When we put data into this function it outputs an irregular value. The Irregular value it outputs is known as “Hash Value”.Hash Values are simply number but are often written in Hexadecimal. Computers manage values as Binary. Hash value is also a data and are often managed in Binary. 
 
Whirlpool is a cryptographic hash function created by Vincent Rijmen and Paulo S.L.M. Barreto. It was first published in 2000 and revised in 2001 and 2003. It was derived form square and Advanced Encryption Standard. It is a block cipher hash function and designed after square block cipher. It takes less than 2^256 bits length input and convert it in 512 bit hash. The first version of whirlpool is called Whirlpool-0 and changed to Whirlpool-T after it’s first revision in 2001 . In this version the S-box is changed and become easier to use in hardware. In 2002 a vulnerability was founded in the Whirlpool-0’s diffusion matrix which was removed by changing the matrix and the name was also changed from Whirlpool-T to Whirlpool.Every block cipher in whirlpool is a 8*8 matrix. The state of the function changes in ever round by using four operations: 
 
Hash Value is calculated by using the formula: 
 State = MR*AK*SC*SB(State)
Install whirlpool library using  
pip install whirlpool
Example 1: 
Python3
# Python program to demonstrate# whirlpool hash function  import whirlpool  string = b"GeeksforGeeks" h1 = whirlpool.new(string)hashed_output = h1.hexdigest() print("The hashed value is")print(hashed_output)
Output: 
The hashed value is 95cb4d2d765eb26a922b3ade5a5837a3bc6b18f9a68cec6392f7bf4284c996dd0dd8775dc77964bb9dd92f204d067d3b2c0f36f968607c88cd378ce094438e5a  
Example 2: 
Python3
# Python program to demonstrate# whirlpool hash function  import whirlpool  string = b"GeeksforGeeks" h1 = whirlpool.new(string)hashed_output = h1.hexdigest() h1.update(b"Geeks")hashed_output = h1.hexdigest() print("The hashed value is")print(hashed_output)
Output: 
The hashed value is c3a2aea5a2b487f1a3ee848870dff8ca5af0adcf7eae2a58b40927e87027918c2e9438909c50c2d2bb73f15392c8fde22c94c85a8ef5d8c3b3e86a839909d58b
 
 
rajeev0719singh
python-utility
Python
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
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Convert integer to string in Python
HTML | <th> nowrap Attribute

26 Jun, 2019
The HTML <th> nowrap Attribute is used to specify that the content present inside the header cell should not wrap. It contains the Boolean value. It is not supported by HTML 5.
Syntax:
<th nowrap>
Example:
<!DOCTYPE html><html>  <head>    <title>        HTML th nowrap Attribute    </title></head>  <body>    <h1>GeeksforGeeks</h1>      <h2>HTML th nowrap Attribute</h2>      <table border="1">        <tr>            <th>NAME</th>            <th nowrap>              GeeksforGeeks is a computer science portal          </th>        </tr>          <tr>            <td>BITTU</td>            <td>CSE</td>        </tr>          <tr>            <td>RAKESH</td>            <td>EC</td>        </tr>    </table></body>  </html>
Output:
Supported Browsers: The browser supported by HTML <th> nowrap attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
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)
Design a Tribute Page using HTML & CSS
Build a Survey Form using HTML and CSS
Angular File Upload
Form validation using jQuery
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
Merge two dataframes with same column names

05 Apr, 2021
In order to merge two data frames with the same column names, we are going to use the pandas.concat(). This function does all the heavy lifting of performing concatenation operations along with an axis of Pandas objects while performing optional set logic (union or intersection) of the indexes (if any) on the other axes.
Syntax: concat(objs, axis, join, ignore_index, keys, levels, names, verify_integrity, sort, copy)
Import module
Create or load first dataframe
Create or load second dataframe
Concatenate on the basis of same column names
Display result
Below are various examples that depict how to merge two data frames with the same column names:
Example 1: 
Python3
# import moduleimport pandas as pd  # assign dataframesdata1 = pd.DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]],                     columns=['A', 'B', 'C'])  data2 = pd.DataFrame([[3, 4], [5, 6]],                     columns=['A', 'C'])  # display dataframesprint('Dataframes:')display(data1)display(data2)  # merge two data framesprint('After merging:')pd.concat([data1, data2], axis=0)
Output:
Example 2:
Python3
# import moduleimport pandas as pd  # assign dataframesdata1 = pd.DataFrame([[25, 77.5, 'A'], [30, 60.2, 'B']],                     columns=['Students', 'Avg Marks', 'Section'])  data2 = pd.DataFrame([[52, 'C'], [25, 'A']],                     columns=['Students', 'Section'])  # display dataframesprint('Dataframes:')display(data1)display(data2)  # merge two data framesprint('After merging:')pd.concat([data1, data2], axis=0)
Output:
Example 3:
Python3
# import moduleimport pandas as pd  # assign dataframesdata1 = pd.DataFrame([[25, 77.5, 'A'], [30, 60.2, 'B'],                      [25, 70.7, 'C']],                     columns=['Students', 'Avg Marks', 'Section'])  data2 = pd.DataFrame([[30, 70.2, 'A'], [25, 65.2, 'B'],                      [35, 77.7, 'C']],                     columns=['Students', 'Avg Marks', 'Section'])    # display dataframesprint('Dataframes:')display(data1)display(data2)  # merge two data framesprint('After merging:')pd.concat([data1, data2], axis=0)
Output:
Picked
Python pandas-dataFrame
Python Pandas-exercise
Python-pandas
Python
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
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Convert integer to string in Python
Introduction To PYTHON
Python Tkinter – Canvas Widget

31 Aug, 2021
Tkinter is a GUI toolkit used in python to make user-friendly GUIs.Tkinter is the most commonly used and the most basic GUI framework available in python. Tkinter uses an object-oriented approach to make GUIs.Note: For more information, refer to Python GUI – tkinter
The Canvas widget lets us display various graphics on the application. It can be used to draw simple shapes to complicated graphs. We can also display various kinds of custom widgets according to our needs.
Syntax: 
C = Canvas(root, height, width, bd, bg, ..)
Optional parameters: 
root = root window.
height = height of the canvas widget.
width = width of the canvas widget.
bg = background colour for canvas.
bd = border of the canvas window.
scrollregion (w, n, e, s)tuple defined as a region for scrolling left, top, bottom and right.
highlightcolor colour shown in the focus highlight.
cursor It can be defined as a cursor for the canvas which can be a circle, a do, an arrow etc.
confine decides if canvas can be accessed outside the scroll region.
relief type of the border which can be SUNKEN, RAISED, GROOVE and RIDGE.  
Creating an Oval
 oval = C.create_oval(x0, y0, x1, y1, options)
Creating an arc
 arc = C.create_arc(20, 50, 190, 240, start=0, extent=110, fill="red")
Creating a Line
 line = C.create_line(x0, y0, x1, y1, ..., xn, yn, options)
Creating a polygon
 oval = C.create_polygon(x0, y0, x1, y1, ...xn, yn, options)
Example 1: Simple Shapes Drawing 
Python3
from tkinter import *  root = Tk() C = Canvas(root, bg="yellow",           height=250, width=300) line = C.create_line(108, 120,                     320, 40,                     fill="green") arc = C.create_arc(180, 150, 80,                   210, start=0,                   extent=220,                   fill="red") oval = C.create_oval(80, 30, 140,                     150,                     fill="blue") C.pack()mainloop()
Output: 
Example 2: Simple Paint App 
Python3
from tkinter import *  root = Tk() # Create Titleroot.title(  "Paint App ") # specify sizeroot.geometry("500x350") # define function when # mouse double click is enableddef paint( event ):        # Co-ordinates.    x1, y1, x2, y2 = ( event.x - 3 ),( event.y - 3 ), ( event.x + 3 ),( event.y + 3 )         # Colour    Colour = "#000fff000"         # specify type of display    w.create_line( x1, y1, x2,                  y2, fill = Colour )  # create canvas widget.w = Canvas(root, width = 400, height = 250) # call function when double# click is enabled.w.bind( "<B1-Motion>", paint ) # create label.l = Label( root, text = "Double Click and Drag to draw." )l.pack()w.pack() mainloop()
Output: 
adityanarayan890singh
shubhamkochar
Python-tkinter
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
Iterate over a list in Python
F# - Structures

A structure in F# is a value type data type. It helps you to make a single variable, hold related data of various data types. The struct keyword is used for creating a structure.
Syntax for defining a structure is as follows −
[ attributes ]
type [accessibility-modifier] type-name =
   struct
      type-definition-elements
   end
// or
[ attributes ]
[<StructAttribute>]
type [accessibility-modifier] type-name =
   type-definition-elements

There are two syntaxes. The first syntax is mostly used, because, if you use the struct and end keywords, you can omit the StructAttribute attribute.
The structure definition elements provide −
Member declarations and definitions.
Constructors and mutable and immutable fields.
Members and interface implementations.
Unlike classes, structures cannot be inherited and cannot contain let or do bindings. Since, structures do not have let bindings; you must declare fields in structures by using the val keyword.
When you define a field and its type using val keyword, you cannot initialize the field value, instead they are initialized to zero or null. So for a structure having an implicit constructor, the val declarations be annotated with the DefaultValue attribute.
The following program creates a line structure along with a constructor. The program calculates the length of a line using the structure −
type Line = struct
   val X1 : float
   val Y1 : float
   val X2 : float
   val Y2 : float

   new (x1, y1, x2, y2) =
      {X1 = x1; Y1 = y1; X2 = x2; Y2 = y2;}
end
let calcLength(a : Line)=
   let sqr a = a * a
   sqrt(sqr(a.X1 - a.X2) + sqr(a.Y1 - a.Y2) )

let aLine = new Line(1.0, 1.0, 4.0, 5.0)
let length = calcLength aLine
printfn "Length of the Line: %g " length
When you compile and execute the program, it yields the following output −
Length of the Line: 5

 Print
 Add Notes
 Bookmark this page
How can I draw inline line labels in Matplotlib?

To draw inline labels in Matplotlib, we can use labelLines() method. −
Set the figure size and adjust the padding between and around the subplots.
Create random data points x using numpy and a list of data points, A.
Iterate the list of A, and plot X and a (iterated item) with label.
Label all the lines with their respective legends, for lines drawn.
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt
from labellines import labelLines

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

X = np.linspace(0, 1, 500)
A = [1, 2, 5, 10, 20]

for a in A:
   plt.plot(X, np.arctan(a*X), label=str(a))

labelLines(plt.gca().get_lines(), zorder=2.5)

plt.show()
How to implement the IntPredicate interface using lambda and method reference in Java?

IntPredicate interface is a built-in functional interface defined in java.util.function package. This functional interface accepts one int-valued argument as input and produces a boolean value as an output. This interface is a specialization of the Predicate interface and used as an assignment target for a lambda expression or method reference. It provides only one abstract method, test ().
@FunctionalInterface
public interface IntPredicate {
 boolean test(int value);
}
import java.util.function.IntPredicate;

public class IntPredicateLambdaTest {
   public static void main(String[] args) {
      IntPredicate intPredicate = (int input) -> {   // lambda expression
         if(input == 100) {
            return true;
         } else
            return false;
      };
      boolean result = intPredicate.test(100);
      System.out.println(result);
   }
}
true
import java.util.function.IntPredicate;

public class IntPredicateMethodReferenceTest {
   public static void main(String[] args) {
      IntPredicate intPredicate = IntPredicateMethodReferenceTest::test;   // method reference
      boolean result = intPredicate.test(100);
      System.out.println(result);
   }
   static boolean test(int input) {
      if(input == 50) {
         return true;
      } else
         return false;
   }
}
false