code-rag-bench/online-tutorials huggingface dataset:
SQL - Group By

The SQL GROUP BY clause is used in collaboration with the SELECT statement to arrange identical data into groups. This GROUP BY clause follows the WHERE clause in a SELECT statement and precedes the ORDER BY clause.
The basic syntax of a GROUP BY clause is shown in the following code block. The GROUP BY clause must follow the conditions in the WHERE clause and must precede the ORDER BY clause if one is used.
SELECT column1, column2
FROM table_name
WHERE [ conditions ]
GROUP BY column1, column2
ORDER BY column1, column2

Consider the CUSTOMERS table is 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 |
+----+----------+-----+-----------+----------+

If you want to know the total amount of the salary on each customer, then the GROUP BY query would be as follows.
SQL> SELECT NAME, SUM(SALARY) FROM CUSTOMERS
   GROUP BY NAME;
This would produce the following result −
+----------+-------------+
| NAME     | SUM(SALARY) |
+----------+-------------+
| Chaitali |     6500.00 |
| Hardik   |     8500.00 |
| kaushik  |     2000.00 |
| Khilan   |     1500.00 |
| Komal    |     4500.00 |
| Muffy    |    10000.00 |
| Ramesh   |     2000.00 |
+----------+-------------+

Now, let us look at a table where the CUSTOMERS table has the following records with duplicate names −
+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Ramesh   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | kaushik  |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
Now again, if you want to know the total amount of salary on each customer, then the GROUP BY query would be as follows −
SQL> SELECT NAME, SUM(SALARY) FROM CUSTOMERS
   GROUP BY NAME;
This would produce the following result −
+---------+-------------+
| NAME    | SUM(SALARY) |
+---------+-------------+
| Hardik  |     8500.00 |
| kaushik |     8500.00 |
| Komal   |     4500.00 |
| Muffy   |    10000.00 |
| Ramesh  |     3500.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
Random.NextDouble() Method in C#

The Random.NextDouble() method in C# is used to return a random floating-point number that is greater than or equal to 0.0, and less than 1.0.
The syntax is as follows −
public virtual double NextDouble ();
Let us now see an example −
 Live Demo
using System;
public class Demo {
   public static void Main(){
      Random r1 = new Random();
      Random r2 = new Random();
      Byte[] arr = new Byte[2];
      r1.NextBytes(arr);
      Console.WriteLine("Random numbers in the byte array...");
      for (int i = 0; i < 2; i++)
         Console.WriteLine(arr[i]);
      Console.WriteLine("\nRandom floating point numbers...");
      for (int i = 0; i < 5; i++)
         Console.WriteLine(r2.NextDouble());
   }
}
This will produce the following output −
Random numbers in the byte array...
124
141
Random floating point numbers...
0.93591266727816
0.36406785872023
0.122396959514542
0.795166163144245
0.954394097884369
Let us now see another example −
 Live Demo
using System;
public class Demo {
   public static void Main(){
      int[] val = new int[7];
      Random r = new Random();
      double d;
      for (int i = 0; i 50; i++) {
         d = r.NextDouble();
         val[(int) Math.Ceiling(d*5)] ++;
      }
      Console.WriteLine("Random Numbers...");
      for (int i = 0; i < 7; i++)
         Console.WriteLine(val[i]);
   }
}
This will produce the following output −
Random Numbers...
0
13
9
12
8
8
0
Changing Layouts Based on Screen Size using CSS

To change the layouts based on screen size in CSS, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
body {
   font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
* {
   box-sizing: border-box;
}
.col {
   color: white;
   float: left;
   width: 25%;
   padding: 10px;
}
.colContainer:after {
   content: "";
   display: table;
   clear: both;
}
@media screen and (max-width: 900px) {
   .col {
      width: 50%;
   }
}
@media screen and (max-width: 600px) {
   .col {
      width: 100%;
   }
}
</style>
</head>
<body>
<h1>Changing layout on screen size using CSS</h1>
<h2>Resize the screen to see the below divs resize themselves</h2>
<div class="colContainer">
<div class="col" style="background-color: rgb(153, 29, 224);">
<h2>First col</h2>
</div>
<div class="col" style="background-color: rgb(12, 126, 120);">
<h2>Second col</h2>
</div>
<div class="col" style="background-color: rgb(207, 41, 91);">
<h2>Third col</h2>
</div>
<div class="col" style="background-color: rgb(204, 91, 39);">
<h2>Fourth col</h2>
</div>
</div>
</body>
</html>
The above code will produce the following output −
How to remove all leading whitespace in string in Python?

The lstrip() method will remove leading whitespaces, newline and tab characters on a string beginning. You can use it in the following way:
>>> '     hello world!'.lstrip()
'hello world!'
You can also use the strip() function to remove both trailing and leading whitespace in the same manner. For example:
>>> '     hello world!    '.strip()
'hello world!'
Elixir - Variables

A variable provides us with named storage that our programs can manipulate. Each variable in Elixir has a specific type, which determines the size and layout of the variable's memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable.
Elixir supports the following basic types of variables.
These are used for Integers. They are of size 32bit on a 32bit architecture and 64 bits on a 64-bit architecture. Integers are always signed in elixir. If an integer starts to expand in size above its limit, elixir convers it in a Big Integer which takes up memory in range 3 to n words whichever can fit it in memory.
Floats have a 64-bit precision in elixir. They are also like integers in terms of memory. When defining a float, exponential notation can be used.
They can take up 2 values which is either true or false.
Strings are utf-8 encoded in elixir. They have a strings module which provides a lot of functionality to the programmer to manipulate strings.
These are functions that can be defined and assigned to a variable, which can then be used to call this function.
There are a lot of collection types available in Elixir. Some of them are Lists, Tuples, Maps, Binaries, etc. These will be discussed in subsequent chapters.
A variable declaration tells the interpreter where and how much to create the storage for the variable. Elixir does not allow us to just declare a variable. A variable must be declared and assigned a value at the same time. For example, to create a variable named life and assign it a value 42, we do the following −
life = 42

This will bind the variable life to value 42. If we want to reassign this variable a new value, we can do this by using the same syntax as above, i.e.,
life = "Hello world"

Naming variables follow a snake_case convention in Elixir, i.e., all variables must start with a lowercase letter, followed by 0 or more letters(both upper and lower case), followed at the end by an optional '?' OR '!'.
Variable names can also be started with a leading underscore but that must be used only when ignoring the variable, i.e., that variable will not be used again but is needed to be assigned to something.
In the interactive shell, variables will print if you just enter the variable name. For example, if you create a variable −
life = 42 

And enter 'life' in your shell, you'll get the output as −
42

But if you want to output a variable to the console (When running an external script from a file), you need to provide the variable as input to IO.puts function −
life = 42  
IO.puts life 
or
life = 42 
IO.puts(life) 
This will give you the following output −
42


    35 Lectures 
     3 hours 

 Pranjal Srivastava

    54 Lectures 
     6 hours 

 Pranjal Srivastava, Harshit Srivastava

    80 Lectures 
     9.5 hours 

 Pranjal Srivastava

    43 Lectures 
     4 hours 

 Mohammad Nauman
 Print
 Add Notes
 Bookmark this page
Python Program for Insertion Sort

In this article, we will learn about the implementation of the Insertion sort in Python 3.x. Or earlier.
1. Iterate over the input elements by growing the sorted array at each iteration.
2. Compare the current element with the largest value available in the sorted array.
3. If the current element is greater, then it leaves the element in its place 
   and moves on to the next element else it finds its correct position in the 
   sorted array and moves it to that position in the array.
4. This is achieved by shifting all the elements towards the right, which are 
   larger than the current element, in the sorted array to one position ahead.
Now let’s see the visual representation of the algorithm −
Now let’s see the implementation
 Live Demo
def insertionSort(arr):
   for i in range(1, len(arr)):
      key = arr[i]
      # Move elements of arr[0..i-1], that are greater than key,
      # to one position ahead of their current position
      j = i-1
      while j >=0 and key < arr[j] :
         arr[j+1] = arr[j]
         j -= 1          
       arr[j+1] = key
# main
arr = ['t','u','t','o','r','i','a','l']
insertionSort(arr)
print ("The sorted array is:")
for i in range(len(arr)):
   print (arr[i])
The sorted array is:
a
i
l
o
r
t
t
u
Time Complexity − O(n*2)
Auxiliary Space − O(1)
All the variables are declared in the global frame as shown in the figure below −
In this article, we learned about the Insertion sort and its implementation in Python 3.x. or earlier.
Tryit Editor v3.7

CSS Grid Intro
Tryit: Grid elements
How to create dynamic values and objects in JavaScript ?

23 Feb, 2021
In JavaScript, you can choose dynamic values or variable names and object names and choose to edit the variable name in the future without accessing the array.
To do, so you can create a variable and assign it a particular value. Then while in the array, when you are declaring the variable use square brackets with the variable name in it, and with this when in the future you decide to change the variable name you need not access the whole array, instead you can just update the value of the variable and the variable in the array automatically changes.
Syntax:
const var_name = 'Name';
const = { [var_name] = 'GeeksForGeeks'};
Example 1:
Javascript
<script>  const dynamic1 = "Age";  const dynamic2 = "Marks";  const user = {                  Name : "GeeksForGeeks",                  [dynamic1] : "57",                  [dynamic2] : "42"                };    console.log(user);</script>
Output: In this output dynamic1 is assigned the value ‘Age’, hence in the output it is shown by the name of ‘Age’, on the other hand, dynamic2 is assigned with ‘Marks’ and it is shown by the name of ‘Marks’ in the output also.
{
  Age: "57",
  Marks: "42",
  Name: "GeeksForGeeks"
}
Example 2: Let us look at what if we change the two assigned values of dynamic1 and dynamic2 respectively.
Javascript
<script>  const dynamic1 = "Marks";  const dynamic2 = "Age";  const user = {                  Name : "GeeksForGeeks",                  [dynamic1] : "57",                  [dynamic2] : "42"                };    console.log(user);</script>
Output: Hence from the above code, it is clear that changing the names of the variables above the change is visible in the array attributes as well. Hence using this method we can make sure that we need not go through the array every time we wish to update any variable name or its value.
{
  Age: "42",
  Marks: "57",
  Name: "GeeksForGeeks"
}
javascript-object
JavaScript
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to compare values in two Pandas Dataframes?

12 Jan, 2022
Let’s discuss how to compare values in the Pandas dataframe. Here are the steps for comparing values in two pandas Dataframes:
Step 1 Dataframe Creation: The dataframes for the two datasets can be created using the following code: 
Python3
import pandas as pd # elements of first datasetfirst_Set = {'Prod_1': ['Laptop', 'Mobile Phone',                        'Desktop', 'LED'],             'Price_1': [25000, 8000, 20000, 35000]             } # creation of Dataframe 1df1 = pd.DataFrame(first_Set, columns=['Prod_1', 'Price_1'])print(df1) # elements of second datasetsecond_Set = {'Prod_2': ['Laptop', 'Mobile Phone',                         'Desktop', 'LED'],              'Price_2': [25000, 10000, 15000, 30000]              } # creation of Dataframe 2df2 = pd.DataFrame(second_Set, columns=['Prod_2', 'Price_2'])print(df2)
Output:
Step 2 Comparison of values: You need to import numpy for the successful execution of this step. Here is the general template to perform the comparison:
df1[‘new column for the comparison results’] = np.where(condition, ‘value if true’, ‘value if false’)
Example: After execution of this code, the new column with the name Price_Matching will be formed under df1. Columns result will be displayed according to the following conditions: 
If Price_1 is equal to Price_2, then assign the value of True
Otherwise, assign the value of False.
Python3
import numpy as np # add the Price2 column from# df2 to df1df1['Price_2'] = df2['Price_2'] # create new column in df1 to# check if prices matchdf1['Price_Matching'] = np.where(df1['Price_1'] == df2['Price_2'],                                 'True', 'False') df1
Output:
kumar_satyam
Python pandas-dataFrame
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Clojure - Strings

A String literal is constructed in Clojure by enclosing the string text in quotations. Strings in Clojure need to be constructed using the double quotation marks such as “Hello World”.
Following is an example of the usage of strings in Clojure.
(ns clojure.examples.hello
   (:gen-class))
(defn hello-world []
   (println "Hello World")
   (println "This is a demo application"))
(hello-world)
The above program produces the following output.
Hello World
This is a demo application

Clojure has a number of operations that can be performed on strings. Following are the operations.
The concatenation of strings can be done by the simple str function.
The formatting of strings can be done by the simple format function. The format function formats a string using java.lang.String.format.
Returns the number of characters in the string.
Returns the substring of ‘s’ beginning at start inclusive, and ending at end (defaults to length of string), exclusive.
Returns a negative number, zero, or a positive number when ‘x’ is logically 'less than', 'equal to', or 'greater than' ‘y’.
Converts string to all lower-case.
Converts string to all upper-case.
Returns a string of all elements in collection, as returned by (seq collection), separated by an optional separator.
Splits string on a regular expression.
Split strings is based on the escape characters \n or \r\n.
Reverses the characters in a string.
Replaces all instance of a match in a string with the replacement string.
Removes whitespace from both ends of the string.
Removes whitespace from the left hand side of the string.
Removes whitespace from the right hand side of the string.
 Print
 Add Notes
 Bookmark this page
ReactJS - Building & Deployment

Let us learn how to do production build and deployment of React application in this chapter.
Once a React application development is done, application needs to be bundled and deployed to a production server. Let us learn the command available to build and deploy the application in this chapter.
A single command is enough to create a production build of the application.
npm run build
> expense-manager@0.1.0 build path\to\expense-manager
> react-scripts build

Creating an optimized production build...
Compiled with warnings.

File sizes after gzip:

   41.69 KB   build\static\js\2.a164da11.chunk.js
    2.24 KB   build\static\js\main.de70a883.chunk.js
    1.4  KB   build\static\js\3.d8a9fc85.chunk.js
    1.17 KB   build\static\js\runtime-main.560bee6e.js
  493     B   build\static\css\main.e75e7bbe.chunk.css

The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.
You may serve it with a static server:

   npm install -g serve
   serve -s build

Find out more about deployment here:

   https://cra.link/deployment

Once the application is build, the application is available under build/static folder.
By default, profiling option is disable and can be enabled through –profile command line option. –profile will include profiling information in the code. The profiling information can be used along with React DevTools to analyse the application.
npm run build -- --profile

Once the application is build, it can be deployed to any web server. Let us learn how to deploy a React application in this chapter.
Local deployment can be done using serve package. Let us first install serve package using below command −
npm install -g server

To start the application using serve, use the below command −
cd /go/to/app/root/folder 
serve -s build

By default, serve serve the application using port 5000. The application can be viewed @ http://localhost:5000.
Production deployment can be easily done by copying the files under build/static folder to the production application’s root directory. It will work in all web server including Apache, IIS, Nginx, etc.
By default, the production build is created assuming that the application will be hosted in the root folder of a web application. If the application needs to be hosted in a subfolder, then use below configuration in the package.json and then build the application.
{ ... "homepage": "http://domainname.com/path/to/subfolder", ... }


    20 Lectures 
     1.5 hours 

 Anadi Sharma

    60 Lectures 
     4.5 hours 

 Skillbakerystudios

    165 Lectures 
     13 hours 

 Paul Carlo Tordecilla

    63 Lectures 
     9.5 hours 

 TELCOMA Global

    17 Lectures 
     2 hours 

 Mohd Raqif Warsi
 Print
 Add Notes
 Bookmark this page
How to find the action attribute and method of a form in JavaScript?

Action attribute and method are not inbuilt in a form, they have to be specified in a form externally. Javascript has provided document.action and document.method methods to get the action attribute and method of a form respectively. Let's discuss them individually.
In the following example, the action attribute of the form is found out using document.action attribute and displayed the result in the output.
Live Demo
<html>
<body>
<form id="frm1" action="/online_javascript_editor.php" method="get"></form>
<p id="demo"></p>
<script>
   var act = document.getElementById("frm1").action;
   document.getElementById("demo").innerHTML = act;
</script>
</body>
</html>
https://www.tutorialspoint.com/online_javascript_editor.php
In the following example, the method of the form is found out using document.method attribute and displayed the result in the output.
Live Demo
<html>
<body>
<form id="frm1" action="/online_javascript_editor.php" method="get"></form>
<p id="demo"></p>
<script>
   var met = document.getElementById("frm1").method;
   document.getElementById("demo").innerHTML = met;
</script>
</body>
</html>
get
Java Examples - Read a file

How to read a file ?
This example shows how to read a file using readLine method of BufferedReader class. 
import java.io.*;

public class Main {
   public static void main(String[] args)  {
      try {
         BufferedReader in = new BufferedReader(new FileReader("c:\\filename"));
         String str;
         
         while ((str = in.readLine()) != null) {
            System.out.println(str);
         }
         System.out.println(str);
      } catch (IOException e) {
      }
   }
}
The above code sample will produce the following result.
aString

The following is another sample example of read a file in Java
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class BufferedReaderExample {
   public static void main(String[] args) {
      try (BufferedReader br = new BufferedReader(
         new FileReader("C:\\\\Users\\\\TutorialsPoint7\\\\Desktop\\\\bbc.txt"))) { 
         
         String sCurrentLine;
         while ((sCurrentLine = br.readLine()) != null) {
				System.out.println(sCurrentLine);
			} 
      } catch (IOException e) {
         e.printStackTrace();
      } 
   }
}  
The above code sample will produce the following result.
BUILD SUCCESSFUL 

 Print
 Add Notes
 Bookmark this page
How to use the Reverse() method of array class in C#

The Reverse() method in array class reverses the sequence of the elements in the entire one-dimensional Array.
To reverse an array, just use the Array.Reverse() method −
Array.Reverse(temp);
Within the reverse method, set the elements like the following code snippet.
int[] list = { 29, 15, 30, 98};
int[] temp = list;
You can try to run the following code to implement Reverse() method in C#.
 Live Demo
using System;
namespace Demo {
   class MyArray {
      static void Main(string[] args) {
         int[] list = { 29, 15, 30, 98};
         int[] temp = list;
         Console.Write("Original Array: ");
         foreach (int i in list) {
            Console.Write(i + " ");
         }
         Console.WriteLine();
         // reverse the array
         Array.Reverse(temp);
         Console.Write("Reversed Array: ");
         foreach (int i in temp) {
            Console.Write(i + " ");
         }
         Console.ReadKey();
      }
   }
}
Original Array: 29 15 30 98
Reversed Array: 98 30 15 29
JavaScript Sleep() function?

With the help of Sleep() we can make a function to pause execution for a fixed amount of time. In programming languages such as C and
Php we would call sleep(sec). Java has thread.sleep(), python has time.sleep() and GO has time.Sleep(2 * time.Second).
javascript doesn't have these kinds of sleep functions. But we should thank promises and async/await function in ES 2018. Because these features have helped us to use sleep() as easy as possible. Let's discuss it in a nutshell.
sleep(Time in ms).then(() => {
//// code
})
We can use the sleep function with then call back as shown above.
const work = async () => {
await sleep(Time in ms)
//code
}
work()
We can use the sleep function with async/await function as shown above.
In the following example, we have used the sleep() with async/await function. Here sleep function is accompanied with await to continue the proceedings. Initially the text in the async function "Hello Tutorix" is displayed once the function is started. Later on, the function is paused using sleep function for 3 seconds. Once the time period is completed, the text("Welcome to ........") following the sleep function is displayed. It is repeated until the loop terminates, meaning that in total the text is going to be repeated for 19 times as shown in the output. 
<html>
<body>
<script>
   function sleep(ms) {
      return new Promise(resolve => setTimeout(resolve, ms));
   }
   async function Tutor() {
      document.write('Hello Toturix');
      for (let i = 1; i <20 ; i++) {        
         await sleep(3000);
         document.write( i +" "+"Welcome to tutorix" + " " + "</br>");
      }
   }
   Tutor()
</script>
</body>
</html>
Hello Tutorix
// after 3 secs
1 Welcome to tutorix
// after 3sec...and the text will repeat until the loop terminates for every 3 sec
2 Welcome to tutorix
3 Welcome to tutorix
4 Welcome to tutorix
5 Welcome to tutorix
6 Welcome to tutorix
7 Welcome to tutorix
8 Welcome to tutorix
9 Welcome to tutorix
10 Welcome to tutorix
11 Welcome to tutorix
12 Welcome to tutorix
13 Welcome to tutorix
14 Welcome to tutorix
15 Welcome to tutorix
16 Welcome to tutorix
17 Welcome to tutorix
18 Welcome to tutorix
19 Welcome to tutorix
Java Program to convert java.util.Date to LocalDate

At first set the date with java.util.Date −
java.util.Date date = new Date();
Now, convert the date to LocalDate −
Instant instant = Instant.ofEpochMilli(date.getTime());
System.out.println("LocalDate = "+LocalDateTime.ofInstant(instant, ZoneId.systemDefault()).toLocalDate());
 Live Demo
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
public class Demo {
   public static void main(String[] args) {
      java.util.Date date = new Date();
      System.out.println("Date = "+date);
      Instant instant = Instant.ofEpochMilli(date.getTime());
      System.out.println("LocalDate = "+LocalDateTime.ofInstant(instant, ZoneId.systemDefault()).toLocalDate());
   }
}
Date = Thu Apr 18 23:51:06 IST 2019
LocalDate = 2019-04-18
How to compare two dates in String format in Java?

The java.text.SimpleDateFormat class is used to format and parse a string to date and date to string.
One of the constructors of this class accepts a String value representing the desired date format and creates SimpleDateFormat object. 
To parse/convert a string as a Date object Instantiate this class by passing desired format string.
Parse the date string using the parse() method.
The util.Date class represents a specific instant time This class provides various methods such as before(), after() and, equals() to compare two dates
Once you create date objects from strings you can compare them using either of these methods as shown below −
Live Demo
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Demo {
   public static void main(String args[])throws ParseException {  
      SimpleDateFormat formatter = new SimpleDateFormat("yyyy-dd-MM");      
      String dateStr1 = "2007-11-25";
      String dateStr2 = "1999-9-12";
      //Parsing the given String to Date object
      Date date1 = formatter.parse(dateStr1);  
      Date date2 = formatter.parse(dateStr2);      
      Boolean bool1 = date1.after(date2);  
      Boolean bool2 = date1.before(date2);
      Boolean bool3 = date1.equals(date2);
      if(bool1){
         System.out.println(dateStr1+" is after "+dateStr2);
      }else if(bool2){
         System.out.println(dateStr1+" is before "+dateStr2);
      }else if(bool3){
          System.out.println(dateStr1+" is equals to "+dateStr2);
      }
   }
}
2007-11-25 is after 1999-9-12
2007-11-25 is after 1999-9-12
The parse() method of the LocalDate class accepts a String value representing a date and returns a LocalDate object.
Live Demo
import java.time.LocalDate;
public class Test {
   public static void main(String args[]){
      String dateStr1 = "2007-11-25";
      String dateStr2 = "1999-9-12";
      LocalDate date1 = LocalDate.parse(dateStr1);
      LocalDate date2 = LocalDate.parse(dateStr1);
      Boolean bool1 = date1.isAfter(date2);  
      Boolean bool2 = date1.isBefore(date2);
      Boolean bool3 = date1.isEqual(date2);
      if(bool1){
          System.out.println(dateStr1+" is after "+dateStr2);
       }else if(bool2){
          System.out.println(dateStr1+" is before "+dateStr2);
       }else if(bool3){
          System.out.println(dateStr1+" is equal to "+dateStr2);
       }
    }
}
2007-11-25 is equal to 1999-9-12
2007-11-25 is equal to 1999-9-12
Java Program to adjust LocalDate to last Day of Month with TemporalAdjusters class

Let us first set a date:
LocalDate localDate = LocalDate.of(2019, Month.JUNE, 15)
Now, adjust LocalDate to last Day of month;
LocalDate day = localDate.with(TemporalAdjusters.lastDayOfMonth());
import java.time.LocalDate;
import java.time.Month;
import java.time.temporal.TemporalAdjusters;
public class Demo {
   public static void main(String[] args) {
      LocalDate localDate = LocalDate.of(2019, Month.JUNE, 15);
      System.out.println("Current Date = "+localDate);
      System.out.println("Current Month = "+localDate.getMonth());
      LocalDate day = localDate.with(TemporalAdjusters.firstDayOfMonth());
      System.out.println("First day of month = "+day);
      day = localDate.with(TemporalAdjusters.lastDayOfMonth());
      System.out.println("Last day of month = "+day);
      day = localDate.with(TemporalAdjusters.firstDayOfNextMonth());
      System.out.println("First day of next month = "+day);
   }
}
Current Date = 2019-06-15
Current Month = JUNE
First day of month = 2019-06-01
Last day of month = 2019-06-30
First day of next month = 2019-07-01
How to center a JLabel in a JPanel with GridBagLayout in Java?

Center a component in a JPanel with GridBagLayout. Let us first create a JFrame and JPanel inside it -
JFrame frame = new JFrame("Demo Frame");
JPanel panel = new JPanel();
Now, we will add our components −
JLabel label = new JLabel("Demo Label (Centered)");
label.setForeground(Color.white);
JCheckBox checkBox = new JCheckBox("Checkbox (Centered)");
Set the layout −
panel.setLayout(new GridBagLayout());
The following is an example to center a label in a panel with GridBagLayout −
package my;
import java.awt.Color;
import java.awt.GridBagLayout;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
public class SwingDemo {
   public static void main(String[] args) {
      JFrame frame = new JFrame("Demo Frame");
      JPanel panel = new JPanel();
      JLabel label = new JLabel("Demo Label (Centered)");
      label.setForeground(Color.white);
      JCheckBox checkBox = new JCheckBox("Checkbox (Centered)");
      panel.setLayout(new GridBagLayout());
      panel.add(label);
      panel.add(checkBox);
      panel.setBackground(Color.blue);
      frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
      frame.add(panel);
      frame.setSize(600, 400);
      frame.setVisible(true);
   }
}
Plot Arrows Between Points in a Graph in R Programming - arrows() Function - GeeksforGeeks

25 Jun, 2020
arrows() function in R Language is used to create arrows between the points on the graph specified.
Syntax: arrows(x0, y0, x1, y1, length)
Parameters:x0: represents x-coordinate of point from which to draw the arrowy0: represents y-coordinate of point from which to draw the arrowx1: represents x-coordinate of point to which the arrow is drawny1: represents y-coordinate of point to which the arrow is drawnlength: represents length of the edge of the arrow head (in inches)
Example 1:
# Specifying pointsx0 <- 1y0 <- 1x1 <- 5y1 <- 5x <- c(x0, x1)y <- c(y0, y1)  # Output to be present as PNG filepng(file = "arrows1GFG.png")  # Create plot graphplot(x, y, main = "Arrows Function")  # Create arrow between the pointsarrows(x0, y0, x1, y1)  # Saving the filedev.off()
Output:
Example 2:
# Specifying pointsx <- runif(10, 0, 1)y <- runif(10, 1, 5)  # Output to be present as PNG filepng(file = "arrows2GFG.png")  # Create plot graphplot(x, y, main = "Arrows Function")  # Create arrow between the pointss <- seq(length(x) - 1)arrows(x[s], y[s], x[s + 1], y[s + 1])  # Saving the filedev.off()
Output:
R Plot-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
How to filter R dataframe by multiple conditions?
R - if statement
How to import an Excel File into R ?
Time Series Analysis in R
Print system time in C++ (3 different ways)

10 Dec, 2018
First MethodPrinting current date and time using time()
Second Method
// CPP program to print current date and time// using time and ctime.#include <stdio.h>#include <stdlib.h>#include <time.h>  int main(){    // declaring argument of time()    time_t my_time = time(NULL);      // ctime() used to give the present time    printf("%s", ctime(&my_time));    return 0;}
Output:
It will show the current day, date and localtime, 
in the format Day Month Date hh:mm:ss Year

Third MethodHere we have used chrono library to print current date and time . The chrono library is a flexible collection of types that tracks time with varying degrees of precision .The chrono library defines three main types as well as utility functions and common typedefs.-> clocks-> time points-> durations
Code to print current date, day and time .
// CPP program to print current date and time// using chronos.#include <chrono>#include <ctime>#include <iostream>  using namespace std;  int main(){    // Here system_clock is wall clock time from    // the system-wide realtime clock    auto timenow =      chrono::system_clock::to_time_t(chrono::system_clock::now());      cout << ctime(&timenow) << endl;}
Output:
It will show the current day, date and localtime, 
in the format Day Month Date hh:mm:ss Year

sanskar27jain
cpp-puzzle
date-time-program
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream count() method in Java with examples

06 Dec, 2018
long count() returns the count of elements in the stream. This is a special case of a reduction (A reduction operation takes a sequence of input elements and combines them into a single summary result by repeated application of a combining operation). This is a terminal operation i.e, it may traverse the stream to produce a result or a side-effect. After the terminal operation is performed, the stream pipeline is considered consumed, and can no longer be used.
Syntax :
long count()

Note : The return value of count operation is the count of elements in the stream.
Example 1 : Counting number of elements in array.
// Java code for Stream.count()// to count the elements in the stream.import java.util.*;  class GFG {      // Driver code    public static void main(String[] args)    {          // creating a list of Integers        List<Integer> list = Arrays.asList(0, 2, 4, 6,                                           8, 10, 12);          // Using count() to count the number        // of elements in the stream and        // storing the result in a variable.        long total = list.stream().count();          // Displaying the number of elements        System.out.println(total);    }}
Output :
7

Example 2 : Count number of distinct elements in a list.
// Java code for Stream.count()// to count the number of distinct// elements in the stream.import java.util.*;  class GFG {      // Driver code    public static void main(String[] args)    {          // creating a list of Strings        List<String> list = Arrays.asList("GFG", "Geeks", "for", "Geeks",                                          "GeeksforGeeks", "GFG");          // Using count() to count the number        // of distinct elements in the stream and        // storing the result in a variable.        long total = list.stream().distinct().count();          // Displaying the number of elements        System.out.println(total);    }}
Output :
4

Java - util package
Java-Functions
java-stream
Java-Stream interface
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
numpy.mod() in Python

10 Feb, 2019
numpy.mod() is another function for doing mathematical operations in numpy.It returns element-wise remainder of division between two array arr1 and arr2 i.e. arr1 % arr2 .It returns 0 when arr2 is 0 and both arr1 and arr2 are (arrays of) integers.
Syntax : numpy.mod(arr1, arr2, /, out=None, *, where=True, casting=’same_kind’, order=’K’, dtype=None, subok=True[, signature, extobj], ufunc ‘remainder’)
Parameters :arr1 : [array_like] Dividend array.arr2 : [array_like] Divisor array.dtype : The type of the returned array. By default, the dtype of arr is used.out : [ndarray, optional] A location into which the result is stored.  -> If provided, it must have a shape that the inputs broadcast to.  -> If not provided or None, a freshly-allocated array is returned.where : [array_like, optional] Values of True indicate to calculate the ufunc at that position, values of False indicate to leave the value in the output alone.**kwargs : Allows to pass keyword variable length of argument to a function. Used when we want to handle named argument in a function.
Return : [ndarray] The element-wise remainder i.e arr1 % arr2 .
Code #1 :
# Python program explaining# numpy.mod() function  import numpy as geekin_num1 = 6in_num2 = 4  print ("Dividend : ", in_num1)print ("Divisor : ", in_num2)    out_num = geek.mod(in_num1, in_num2) print ("Remainder : ", out_num) 
Dividend :  6
Divisor :  4
Remainder :  2

 
Code #2 :
# Python program explaining# numpy.mod() function  import numpy as geek  in_arr1 = geek.array([2, -4, 7])in_arr2 = geek.array([2, 3, 4])   print ("Dividend array : ", in_arr1)print ("Divisor array : ", in_arr2)       out_arr = geek.mod(in_arr1, in_arr2) print ("Output remainder array: ", out_arr) 
Dividend array :  [ 2 -4  7]
Divisor array :  [2 3 4]
Output remainder array:  [0 2 3]

Python numpy-Mathematical Function
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Changed SAP password not working while resetting using BAPI

You are using the structure Password for resetting the password. It is of type “BAPIPWD” and comprises of a field which is again named as “BAPIPWD”
When you need to reset the password, you need to specify the correct field name instead of password.
JCO.Structure structPassword = userChangeInput.getStructure("PASSWORD");
sPassword.setValue(nPassword, "BAPIPWD");
Create n-child process from same parent process using fork() in C - GeeksforGeeks

03 Nov, 2017
fork() is a system call function which can generate child process from parent main process. Using some conditions we can generate as many child process as needed.
We have given n , we have to create n-child processes from same parent process (main process ).
Examples:
Input :3
Output :[son] pid 25332 from [parent] pid 25329
        [son] pid 25331 from [parent] pid 25329
        [son] pid 25330 from [parent] pid 25329

here 25332, 25331,25330 are child processes from same parent process
with process id 25329 

Input :5
Output :[son] pid 28519 from [parent] pid 28518
        [son] pid 28523 from [parent] pid 28518
        [son] pid 28520 from [parent] pid 28518
        [son] pid 28521 from [parent] pid 28518
        [son] pid 28522 from [parent] pid 28518

here 28519, 28519,28520,28521,28522 are child processes from same parent process
with process id 28518 


#include<stdio.h>    int main(){    for(int i=0;i<5;i++) // loop will run n times (n=5)    {        if(fork() == 0)        {            printf("[son] pid %d from [parent] pid %d\n",getpid(),getppid());            exit(0);        }    }    for(int i=0;i<5;i++) // loop will run n times (n=5)    wait(NULL);      }
Output:
[son] pid 28519 from [parent] pid 28518
[son] pid 28523 from [parent] pid 28518
[son] pid 28520 from [parent] pid 28518
[son] pid 28521 from [parent] pid 28518
[son] pid 28522 from [parent] pid 28518

This article is contributed by Dibyendu Roy Chaudhuri. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
C Language
C Programs
Misc
Misc
Misc
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
rand() and srand() in C/C++
Left Shift and Right Shift Operators in C/C++
Command line arguments in C/C++
Substring in C++
Function Pointer in C
Strings in C
Arrow operator -> in C/C++ with Examples
C Program to read contents of Whole File
UDP Server-Client implementation in C
Header files in C/C++ and its uses
numpy.matmul()

The numpy.matmul() function returns the matrix product of two arrays. While it returns a normal product for 2-D arrays, if dimensions of either argument is >2, it is treated as a stack of matrices residing in the last two indexes and is broadcast accordingly.
On the other hand, if either argument is 1-D array, it is promoted to a matrix by appending a 1 to its dimension, which is removed after multiplication.
# For 2-D array, it is matrix multiplication 
import numpy.matlib 
import numpy as np 

a = [[1,0],[0,1]] 
b = [[4,1],[2,2]] 
print np.matmul(a,b)
It will produce the following output −
[[4  1] 
 [2  2]] 

# 2-D mixed with 1-D 
import numpy.matlib 
import numpy as np 

a = [[1,0],[0,1]] 
b = [1,2] 
print np.matmul(a,b) 
print np.matmul(b,a)
It will produce the following output −
[1  2] 
[1  2] 

# one array having dimensions > 2 
import numpy.matlib 
import numpy as np 

a = np.arange(8).reshape(2,2,2) 
b = np.arange(4).reshape(2,2) 
print np.matmul(a,b)
It will produce the following output −
[[[2   3] 
   [6   11]] 
  [[10  19] 
   [14  27]]]


    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
How to add a Time picker in Form using HTML5 ? - GeeksforGeeks

25 Oct, 2021
As we know that a Time picker is used to provide tp select single value from a pre-determined set. Basically, it creates an input field that accepts a time. We can open a time picker by clicking on a clock icon. The UI Design of the Time picker is different from browser to browsers.
Follow the below approach to complete the task:
Firstly, we create an HTML document that contains a Form element.
Add an <input> tag under the form.
Use the type attribute with the input element.
Set the type attribute to value “time”.
Syntax:
<input type="time"> 
Example:
HTML
<!DOCTYPE html><html>  <head>    <title>        How to add a Time picker         in Form using HTML5?    </title></head>  <body style="text-align:center;">    <h1 style="color:green;">        GeeksForGeeks    </h1>      <h2>        How to add a Time picker         in Form using HTML5?    </h2>      <form action="#">        <legend>            Select Time:             <input type="time" name="time">        </legend>          <br><br>        <input type="submit" value="Submit">    </form></body>  </html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Questions
HTML-Tags
HTML5
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
REST API (Introduction)
Design a web page using HTML and CSS
Form validation using jQuery
How to place text on image using HTML and CSS?
How to auto-resize an image to fit a div container using CSS?
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
Can constructors be marked final, abstract or static in Java?

Except public, protected and, private constructor does not allow any other modifier.
When you use a final keyword with a method or constructor it cannot be overridden. But, a constructor in Java cannot be overridden therefore, there is no need of using the final keyword with the constructor.
When you use a final keyword with a method or constructor it cannot be overridden. But, a constructor in Java cannot be overridden therefore, there is no need of using the final keyword with the constructor.
Since you cannot override a constructor you cannot provide body to it if it is made abstract. Therefore, you cannot use abstract keyword with the constructor.
Since you cannot override a constructor you cannot provide body to it if it is made abstract. Therefore, you cannot use abstract keyword with the constructor.
If you want to invoke a member of a class before instantiating the class you need to use static before it. But, contractors are called implicitly at the time of instantiation. Therefore, there is no point in using static with constructors.
If you want to invoke a member of a class before instantiating the class you need to use static before it. But, contractors are called implicitly at the time of instantiation. Therefore, there is no point in using static with constructors.
public class Sample {
   public final static Sample(){
      System.out.println("Hello");
   }
   public static void main(String args[]) throws Exception{
      Sample obj = new Sample();
   }
}
C:\Sample>javac Sample.java
Sample.java:2: error: modifier static, final not allowed here
public final static Sample(){
                    ^
1 error
Tryit Editor v3.7

RWD Media Queries
Tryit: Using media queries
C# Program to remove whitespaces in a string

Let’s say the following is the string −
StringBuilder str = new StringBuilder("Patience is key!");
To remove whitespace, you can use the replace method.
str.Replace(" ", "");
Let us see the complete code.
 Live Demo
using System;
using System.Text;
class Demo {
   static void Main() {
      // Initial String
      StringBuilder str = new StringBuilder("Patience is key!");
      Console.WriteLine(str.ToString());

      // Replace
      str.Replace(" ", "");

      // New String
      Console.WriteLine(str.ToString());
      Console.ReadLine();
   }
}
Patience is key!
Patienceiskey!
How to create a password field using JavaFX?

The text field accepts and displays the text. In the latest versions of JavaFX, it accepts only a single line. In JavaFX the javafx.scene.control.TextField class represents the text field, this class inherits the javafx.scene.control.TextInputControl (base class of all the text controls) class. Using this you can accept input from the user and read it to your application.
Similar to text field a password field accepts text but instead of displaying the
given text, it hides the typed characters by displaying an echo string.
In JavaFX the javafx.scene.control.PasswordField represents a password field and it inherits the Text class. To create a password field you need to instantiate this class.
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class PasswordFieldExample extends Application {
   public void start(Stage stage) {
      //Creating nodes
      TextField textField = new TextField();
      PasswordField pwdField = new PasswordField();
      //Creating labels
      Label label1 = new Label("Name: ");
      Label label2 = new Label("Pass word: ");
      //Adding labels for nodes
      HBox box = new HBox(5);
      box.setPadding(new Insets(25, 5 , 5, 50));
      box.getChildren().addAll(label1, textField, label2, pwdField);
      //Setting the stage
      Scene scene = new Scene(box, 595, 150, Color.BEIGE);
      stage.setTitle("Password Field Example");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]){
      launch(args);
   }
}