code-rag-bench/online-tutorials huggingface dataset:
TIMESTAMPDIFF() function in MYSQL

30 Dec, 2020
TIMESTAMPDIFF() :
This function in MySQL is used to return a value after subtracting a DateTime expression from another.
Syntax :
TIMESTAMPDIFF(unit,expr1,expr2)
Parameters : 
It will accept three parameters.
unit – It denotes the unit for the result. It can be one of the following.MICROSECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR 
expr1 – First date or DateTime expressions. 
expr2 – Second date or DateTime expressions.
Returns :
It returns the DateTime expressions after subtraction.
Example 1 :
Getting the differences between two specified time values where the time is specified in the format of YYYY-MM-DD HH-MM-SS. Here expr2 is greater than expr1, so the return value is positive.
SELECT TIMESTAMPDIFF(SECOND, '2010-01-01 10:10:20', '2010-01-01 10:45:59') AS SECONDDIFFERENCE;
Output :
Example 2:
Getting the differences between two specified time values where the time is specified in the format of YYYY-MM-DD HH-MM-SS. Here expr2 is lesser than expr1, so the return value is negative.
SELECT TIMESTAMPDIFF(SECOND, '2010-01-01 10:10:20', '2010-01-01 09:45:59') AS SECONDDIFFERENCE;
Output:
Example 3:
Getting the differences between two specified date values in the month when the date is specified in the format of YYYY-MM-DD.
SELECT TIMESTAMPDIFF(MONTH, '2019-08-01', '2020-11-01') AS MONTHDIFFERENCE;
Output:
Example 4:
Calculating Total Work experience of an Employee using the TIMESTAMPDIFF function. 
Creating an Employee table –
CREATE TABLE Employee(
    id INT AUTO_INCREMENT PRIMARY KEY,
    Full_Name VARCHAR(50) NOT NULL,
    Joining_Date DATE NOT NULL
);
Inserting values into the table –
INSERT INTO Employee(Full_Name , Joining_Date )
VALUES('Riya Jana', '2000-01-01'),
      ('Sayan Ghosh', '2005-09-26'),
      ('Rinki Sharma', '2014-08-12'),
      ('Aniket Singh', '2019-11-05');
Now, we will use the TIMESTAMPDIFF to calculate the work experience of each employee in the year.
SELECT 
    id,
    Full_Name,
    Joining_Date ,
    TIMESTAMPDIFF(YEAR, Joining_Date,'2020-11-26') AS WorkExperience
FROM
    Employee ;
Output :
DBMS-SQL
mysql
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Sub queries in From Clause
Window functions in SQL
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
What is Temporary Table in SQL?
SQL using Python
RANK() Function in SQL Server
SQL Query to Convert VARCHAR to INT
SQL Query to Convert Rows to Columns in SQL Server
SQL Query to Compare Two Dates
HTML | <meta> http-equiv Attribute

06 Jun, 2022
The HTML <meta> http-equiv Attribute is used to provide header information or value of the content Attribute. It can be used to simulate an HTTP Header response. It can be used in meta Element.Syntax:
<meta http-equiv="content-type | default-style | refresh">
Example:  
html
<!DOCTYPE html><html> <head>    <title>    HTML Meta http-equiv Attribute    </title>    <meta name="keywords about"        content="Meta Tags, Metadata" />         <meta name="description"        content="Learning about Meta Tags." />         <meta name="revised about"        content="GeeksforGeeks" />         <meta http-equiv="refresh"        content="8" /></head> <body>    <center>        <h1 style="color:green">        GeeksforGeeks    </h1>        <h2>        HTML Meta http-equiv Attribute    </h2>    </center></body> </html>                      
Output:  
Supported Browsers: The browser supported by HTML Meta http-equiv attribute are listed below:  
Google Chrome 1 and above
Edge 12 and above
Internet Explorer 6 and above
Firefox 1 and above
Opera 12.1 and above
Safari 4 and above
 
arorakashish0911
hritikbhatnagar2182
kumargaurav97520
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Why 0.3 – 0.2 is not equal to 0.1 in Python?

26 Nov, 2020
In this article, we will see why 0.3 – 0.2 is not equal to 0.1 in Python. The reason behind it is called “precision”, and it’s due to the fact that computers do not compute in Decimal, but in Binary. Computers do not use a base 10 system, they use a base 2 system (also called Binary code).
Below is the Implementation. 
Python3
# codeprint(0.3 - 0.2)print(0.3 - 0.2 == 0.1)
0.09999999999999998
False

As you can see in the output, 0.3 – 0.2 does not give 0.1 but 0.09999999999999998.  We do calculations using decimal (base 10), while computer does calculations using binary(base 2).
Let us consider 1 / 3 in decimal which is 0.3333333, 2 / 3 in decimal is 0.6666666, if we add both we will only get 0.9999999, which is not equal to 1. Similarly, 0.3, 0.2 cannot be represented accurately in binary no matter how many significant digits you use. Fractions with denominator in multiples of 5 and 2 can only be represented precisely in decimal, similarly fractions with denominator in multiples of 2 can only be represented precisely in binary. Floating-point numbers are stored internally using IEEE standard 754 which is correct only from 15-17 significant digits.
We can use inbuilt decimal module to change precision and get accurate results. getcontext().prec can be used to set precision of each decimal value. Default precision is 28 digits.
Python3
from decimal import *    getcontext().prec = 6print(Decimal("0.3") - Decimal("0.2"))print(Decimal("0.3") - Decimal("0.2") == Decimal("0.1"))
0.1
True

Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C program to perform intersection operation on two arrays

If array 1 = { 1,2,3,4,6}
  Array 2 = {1,2,5,6,7}
Then, intersection of array1 and array 2 is
Array1 ^ array 2 = {1,2,3,4,6} ^ {1,2,5,6,7}
                 = {1,2,6}
Set of common elements is called an intersection.
The logic for intersection is as follows −
k=0;
for(i=0;i<size1;i++){
   for(j=0;j<size2;j++){
      if(a[i]==b[j]){
         intersection[k]=a[i];
         k++;
      }
   }
}
Following is the C program to perform intersection operation on two arrays −
 Live Demo
#include<stdio.h>
int removerepeated(int size,int a[]);
void sort(int size,int a[]);
main(){
   int i,size1,size2,size,j=0,k,intersectionsize;
   printf("Enter size of an array1\n");
   scanf("%d",&size1);
   printf("Enter size of an array2\n");
   scanf("%d",&size2);
   int a[size1],b[size2],uni[size1+size2];
   if(size1<size2){
      intersectionsize=size1;
   }else if(size1>size2){
      intersectionsize=size2;
   }else{
      intersectionsize=size1;
   }
   int intersection[intersectionsize];
   printf("Enter numbers for array 1\n");
   for(i=0;i<size1;i++){
      scanf("%d",&a[i]);
   }
   printf("Enter numbers for array 2\n");
   for(i=0;i<size2;i++){
      scanf("%d",&b[i]);
   }
   //Intersection starts
   k=0;
   for(i=0;i<size1;i++){
      for(j=0;j<size2;j++){
         if(a[i]==b[j]){
            intersection[k]=a[i];
            k++;
         }
      }
   }
   //Sorting
   sort(k,intersection);
   //Removing
   size=removerepeated(k,intersection);
   printf("Array after intersection\n");
   if(size>0){
      for(i=0;i<size;i++){
         printf("%d\n",intersection[i]);
      }
   }else{
      printf("No intersection\n");
   }
}
int removerepeated(int size,int a[]){
   int i,j,k;
   for(i=0;i<size;i++){
      for(j=i+1;j<size;){
         if(a[i]==a[j]){
            for(k=j;k<size;k++){
               a[k]=a[k+1];
            }
            size--;
         }else{
            j++;
         }
      }
   }
   return(size);
}
void sort(int size,int a[]){
   int i,j,temp;
   for(i=0;i<size;i++){
      for(j=i+1;j<size;j++){
         if(a[i]>a[j]){
            temp=a[i];
            a[i]=a[j];
            a[j]=temp;
         }
      }
   }
}
When the above program is executed, it produces the following result −
Enter size of an array1
5
Enter size of an array2
2
Enter numbers for array 1
4
5
6
7
8
Enter numbers for array 2
4
1
Array after intersection
4
What is modulo % operator in Python?

The % symbol is defined in Python as modulo operator. It can also be called remainder operator. It returns remainder of division of two numeric operands (except complex numbers).
>>> a=10
>>> b=3
>>> a%b
1
>>> a=12.25
>>> b=4
>>> a%b
0.25
>>> a=-10
>>> b=6
>>> a%b
2
>>> a=1.55
>>> b=0.05
>>> a%b
0.04999999999999996
losetup - Unix, Linux Command

losetup: set up and control loop devices.
 losetup loopdev

    losetup -l [-a]

    losetup -j file [-o offset]

       Detach a loop device:

        losetup -d loopdev...

       Detach all associated loop devices:

            losetup -D

       Print the name of the first unused loop device:

            losetup -f

       Set up a loop device:

            losetup [-o offset] [--sizelimit size]
                    [-Pr] [--show] -f|loopdev file

       Resize a loop device:

            losetup -c loopdev
 
 losetup loopdev

    losetup -l [-a]

    losetup -j file [-o offset]

 Detach a loop device:

        losetup -d loopdev...

 Detach all associated loop devices:

            losetup -D

Print the name of the first unused loop device:

            losetup -f

Set up a loop device:

            losetup [-o offset] [--sizelimit size]
                    [-Pr] [--show] -f|loopdev file

Resize a loop device:

            losetup -c loopdev
losetup  is  used to associate loop devices with regular files or block
       devices, to detach loop devices and to  query  the  status  of  a  loop
       device.  If  only  the loop_device argument is given, the status of the
       corresponding loop deviceis shown.

Example-1:
To detach file or device associated with loop device :
# losetup -e des /dev/loop0 /file
OR
# losetup -d /dev/loop0
Example-2:
The following commands can be used as an example of using the loop device.
 # dd if=/dev/zero of=~/file.img bs=1MiB count=10
 # losetup --find --show ~/file.img /dev/loop0
 # mkfs -t ext2 /dev/loop0
 # mount /dev/loop0 /mnt
 ...
 # umount /dev/loop0
 # losetup --detach /dev/loop0 
	  

    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Java - String matches() Method

This method tells whether or not this string matches the given regular expression. An invocation of this method of the form str.matches(regex) yields exactly the same result as the expression Pattern.matches(regex, str).
Here is the syntax of this method −
public boolean matches(String regex)

Here is the detail of parameters −
regex − the regular expression to which this string is to be matched.
regex − the regular expression to which this string is to be matched.
This method returns true if, and only if, this string matches the given regular expression.
This method returns true if, and only if, this string matches the given regular expression.
import java.io.*;
public class Test {

   public static void main(String args[]) {
      String Str = new String("Welcome to Tutorialspoint.com");

      System.out.print("Return Value :" );
      System.out.println(Str.matches("(.*)Tutorials(.*)"));

      System.out.print("Return Value :" );
      System.out.println(Str.matches("Tutorials"));

      System.out.print("Return Value :" );
      System.out.println(Str.matches("Welcome(.*)"));
   }
}
This will produce the following result −
Return Value :true
Return Value :false
Return Value :true


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
How to make a page redirect using jQuery?

To redirect to another webpage in jQuery, use attr(). You can try to run the following code to redirect to another webpage −
<html>
   <head>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
      </script>
      <script>
         $(document).ready(function() {
            $(location).attr('href','http://qries.com');
         });
      </script>
   </head>
   <body>
   </body>
</html>
Javascript | Window Blur() and Window Focus() Method - GeeksforGeeks

22 Nov, 2021
Window.blur() MethodThe blur() method is used to remove focus from the current window. i.e, It send the new open Window to the background.
Syntax:
Window.blur()
Parameter: It does not require any parameters.
Return Value: It does not Return any value.
Window.focus() MethodThe focus() method is used to focus on the new open window. i.e bringing back the blur window to the foreground.
Syntax:
window.focus()
Parameter: It does not require any parameters.
Return Value: It does not Return any value.
Below example illustrates the window.blur() and window.focus() method in JavaScript:
Example:
<!DOCTYPE html><html>  <head>    <title>      window Blur and Focus method    </title>    <style>        body {            text-align: center;        }                  .gfg {            font-size: 40px;            font-weight: bold;            color: green;        }    </style></head>  <body>    <div class="gfg">GeeksforGeeks</div>    <h2>Blur and Focus</h2>    <script>        var Window;          // Function that open the new Window         function windowOpen() {            Window = window.open(              "https://www.geeksforgeeks.org/",                "_blank", "width=400, height=450");        }          // function that Closes the open Window         function windowClose() {            Window.close();        }          //function that blur the open Window        function windowBlur() {            Window.blur();        }          //function that focus on open Window        function windowFocus() {            Window.focus();        }    </script>    <button onclick="windowOpen()">      Open GeeksforGeeks    </button>    <button onclick="windowBlur()">      Blur GeeksforGeeks    </button>    <button onclick="windowFocus()">      Focus GeeksforGeeks    </button>    <button onclick="windowClose()">      Close GeeksforGeeks     </button></body>  </html>
Output: If click on blur GeeksforGeeks button then geeksforgeeks.org page will move to the background and if click on focus GeeksforGeeks button then the geeksforgeeks.oge windows will come to foreground.
Click on the Blur:
Click on the Focus:
Supported Browser: The browser supported by Window Blur() and Window Focus() Method are listed below:
Google Chrome 1 and above
Edge 12 and above
Firefox 1 and above
Internet Explorer 4 and above
Opera 12.1 and above
Safari 1 and above
ysachin2314
javascript-functions
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
Difference between var, let and const keywords in JavaScript
How to Open URL in New Tab using JavaScript ?
JavaScript | console.log() with Examples
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
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?
Construct a ∈-NFA for the language L = (a* + b*)

The ε transitions in Non-deterministic finite automata (NFA) are used to move from one state to another without having any symbol from input set Σ
ε-NFA is defined in five-tuple representation
{Q, q0, Σ, δ, F}
Where,
δ − Q × (Σ∪ε)→2Q
δ − Q × (Σ∪ε)→2Q
Q − Finite set of states
Q − Finite set of states
Σ − Finite set of the input symbol
Σ − Finite set of the input symbol
q0 − Initial state
q0 − Initial state
F − Final state
F − Final state
δ − Transition function
δ − Transition function
NFA is defined in five tuple representation
{Q, q0, Σ, δ, F}
Where,
δ − Q X Σ→ 2Q
δ − Q X Σ→ 2Q
Q − Finite set of states
Q − Finite set of states
Σ − Finite set of the input symbol
Σ − Finite set of the input symbol
q0 − Initial state
q0 − Initial state
F − Final state
F − Final state
δ − Transition function
δ − Transition function
NFA and NFA with epsilon both are almost the same; the only difference is their transition function.
Let’s consider the given language L = (a*+b*)
Step 1 − NFA with epsilon for a* is as follows −
a* means there can be any number of ‘a’ in the expression, even 0 ( if the input symbol is null then also it is valid).
Step 2 − NFA with epsilon for b* is as follows −
b* means there can be any number of b’s in the expression, even 0 (if input symbol is null then also it is valid).
Step 3 − Now construct a*+b* using first and second steps.
The given language is divided into two parts like a* and b* and add two steps by using ‘+’ sign to get the result.
Convex Hull Graham Scan in C++

In this tutorial, we will be discussing a program to find the convex hull of a given set of points.
Convex hull is the smallest polygon convex figure containing all the given points either on the boundary on inside the figure.
In Graham Scan, firstly the pointes are sorted to get to the bottommost point. Then the points are traversed in order and discarded or accepted to be on the boundary on the basis of their order.
#include <iostream>
#include <stack>
#include <stdlib.h>
using namespace std;
struct Point{
   int x, y;
};
//point reference for sorting other points
Point p0;
//moving to the next top in stack
Point nextToTop(stack<Point> &S){
   Point p = S.top();
   S.pop();
   Point res = S.top();
   S.push(p);
   return res;
}
//swapping two points
int swap(Point &p1, Point &p2){
   Point temp = p1;
   p1 = p2;
   p2 = temp;
}
//calculating the square of difference
int distSq(Point p1, Point p2){
   return (p1.x - p2.x)*(p1.x - p2.x) +
   (p1.y - p2.y)*(p1.y - p2.y);
}
//checking the orientation of points
int orientation(Point p, Point q, Point r){
   int val = (q.y - p.y) * (r.x - q.x) -
   (q.x - p.x) * (r.y - q.y);
   if (val == 0) return 0;
   return (val > 0)? 1: 2;
}
//sorting and comparing the points
int compare(const void *vp1, const void *vp2){
   Point *p1 = (Point *)vp1;
   Point *p2 = (Point *)vp2;
   int o = orientation(p0, *p1, *p2);
   if (o == 0)
   return (distSq(p0, *p2) >= distSq(p0, *p1))? -1 : 1;
   return (o == 2)? -1: 1;
}
//printing convex hull
void convexHull(Point points[], int n){
   int ymin = points[0].y, min = 0;
   for (int i = 1; i < n; i++){
      int y = points[i].y;
      if ((y < ymin) || (ymin == y &&
      points[i].x < points[min].x))
      ymin = points[i].y, min = i;
   }
   swap(points[0], points[min]);
   p0 = points[0];
   qsort(&points[1], n-1, sizeof(Point), compare);
   for (int i=1; i<n; i++){
      while (i < n-1 && orientation(p0, points[i],
      points[i+1]) == 0)
         i++;
      points[m] = points[i];
      m++; //updating size of modified array
   }
   if (m < 3) return;
   stack<Point> S;
   S.push(points[0]);
   S.push(points[1]);
   S.push(points[2]);
   for (int i = 3; i < m; i++){
      while (orientation(nextToTop(S), S.top(), points[i]) != 2)
      S.pop();
      S.push(points[i]);
   }
   while (!S.empty()){
      Point p = S.top();
      cout << "(" << p.x << ", " << p.y <<")" << endl;
      S.pop();
   }
}
int main(){
   Point points[] = {{0, 3}, {1, 1}, {2, 2}, {4, 4},
   {0, 0}, {1, 2}, {3, 1}, {3, 3}};
   int n = sizeof(points)/sizeof(points[0]);
   convexHull(points, n);
   return 0;
}
(0, 3)
(4, 4)
(3, 1)
(0, 0)
SQL Tryit Editor v1.6

SELECT * FROM Customers
WHERE CustomerID=1;
​
Edit the SQL Statement, and click "Run SQL" to see the result.
This SQL-Statement is not supported in the WebSQL Database.
The example still works, because it uses a modified version of SQL.
Your browser does not support WebSQL.
Your are now using a light-version of the Try-SQL Editor, with a read-only Database.
If you switch to a browser with WebSQL support, you can try any SQL statement, and play with the Database as much as you like. The Database can also be restored at any time.
Our Try-SQL Editor uses WebSQL to demonstrate SQL.
A Database-object is created in your browser, for testing purposes.
You can try any SQL statement, and play with the Database as much as you like. The Database can be restored at any time, simply by clicking the "Restore Database" button.
WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object.
WebSQL is supported in Chrome, Safari, Opera, and Edge(79).
If you use another browser you will still be able to use our Try SQL Editor, but a different version, using a server-based ASP application, with a read-only Access Database, where users are not allowed to make any changes to the data.
Why variable name does not start with numbers in C ? - GeeksforGeeks

06 Jul, 2020
In C, apart from keywords, everything in the C program is treated as Identifier. Identifiers can be the names given to variables, constants, functions, and user-defined data. A variable name can consist of alphabets (upper case, lower case), numbers (0-9), and _ (underscore) character. But the name of any variable must not start with a number. Now we must have the answer that why can’t we name a variable starting with number. The following might be the reason for it. The compiler has 7 phase as follows:
    Lexical Analysis
    Syntax Analysis
    Semantic Analysis
    Intermediate Code Generation
    Code Optimization
    Code Generation
    Symbol Table

Backtracking is avoided in the lexical analysis phase while compiling the piece of code. The variable like Apple;, the compiler will know it an identifier right away when it meets the letter ‘A’ character in the lexical analysis phase. However, a variable like 123apple; , compiler won’t be able to decide if its a number or identifier until it hits ‘a’ and it needs backtracking to go in the lexical analysis phase to identify that it is a variable. But it is not supported in the compiler.When you’re parsing the token you only have to look at the first character to determine if it’s an identifier or literal and then send it to the correct function for processing. So that’s a performance optimization.
This article is contributed by Bishal Kumar Dubey. 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.
om_mishra
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Multidimensional Arrays in C / C++
rand() and srand() in C/C++
Left Shift and Right Shift Operators in C/C++
fork() in C
Core Dump (Segmentation fault) in C/C++
Command line arguments in C/C++
Substring in C++
Function Pointer in C
Different methods to reverse a string in C/C++
TCP Server-Client implementation in C
Typing Enter/Return key in Selenium.

We can type Enter/Return key in Selenium. We shall use the sendKeys method and pass Keys.ENTER as an argument to the method. Also, we can use pass Keys.RETURN as an argument to the sendKeys method for the same purpose.
To use the Keys class, we have to incorporate import org.openqa.selenium.Keys to the code. Let us type Enter/Return after inputting text within the below edit box.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
public class TypeEnter{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver",
      "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.get("https://www.tutorialspoint.com/index.htm");
      // identify element
      WebElement m=driver.findElement(By.id("gsc−i−id1"));
      m.sendKeys("Java");
      // type enter with sendKeys method and pass Keys.ENTER
      m.sendKeys(Keys.ENTER);
      driver.quit();
   }
}
Code Implementation with Keys.RETURN.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
public class TypeReturn{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver",
      "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.get("https://www.tutorialspoint.com/index.htm");
      // identify element
      WebElement m=driver.findElement(By.id("gsc−i−id1"));
      m.sendKeys("Java");
      // type enter with sendKeys method and pass Keys.RETURN
      m.sendKeys(Keys.RETURN);
      driver.quit();
   }
}
How to Change Root Password in Kali Linux? - GeeksforGeeks

28 Jul, 2020
After completing the installation of the Kali Linux machine the most highly performed task and asked question is to change the root password of your Kali Linux machine.
Note: This is not exclusive only just with Kali Linux machine, you can perform the steps in any Linux machine with grub, we are using Kali as an example.
The default credentials of logging into the new kali machine are username: “kali”  and password: “kali”. Which opens a session as user “kali” and to access root you need to use this user password following “sudo”.
Changing the root password is easy, but you need to ensure these few things:
You are using an active grub boot loaderYour boot loader is not locked
You are using an active grub boot loader
Your boot loader is not locked
If everything is okay  then just follow the steps:
Step 1: Boot into your machine to grub menu, do not choose anything or boot into Kali.
Step 2: Now you need to edit the grub entries, so you can spawn a root session. Press “e” key to enter edit mode.
Now you need to find the keyword “linux”, in our case you can see that the last line starts with “linux”, which is kernel selection. In our case “/boot/v,linuz-5.5.0.0-kali2-amd64” represents our active kernel.
Navigate in the line to “ro” (read only) and replace it with “rw” (read and write).
In the same line navigate to “quite splash” and replace it with 
init=/bin/bash

These changes are not saved permanently and grub uses default configurations, once you have made these changes press key “f10” to boot. This will create a terminal session with root privileges
Step 3: Once you are in the terminal session you just need to enter the command:
passwd root

After applying your new password reboot your system.
Kali-Linux
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
tar command in Linux with examples
UDP Server-Client implementation in C
Named Pipe or FIFO with example C program
Mutex lock for Linux Thread Synchronization
'crontab' in Linux with Examples
Cat command in Linux with examples
echo command in Linux with Examples
Thread functions in C/C++
touch command in Linux with Examples
Conditional Statements | Shell Script
PHP Syntax

A PHP script is executed on the server, and the plain HTML result is sent back to the browser.
A PHP script can be placed anywhere in the document.
A PHP script starts with <?php and ends with 
?>:
The default file extension for PHP files is ".php".
A PHP file normally contains HTML tags, and some PHP scripting code.
Below, we have an example of a simple PHP file, with a PHP script that uses a 
built-in PHP function "echo" to output the text
"Hello World!" on a web page:
Note: PHP statements end with a semicolon (;).
In PHP, keywords (e.g. if, 
else, while, 
echo, etc.), classes, functions, 
and user-defined functions are not case-sensitive.
In the example below, all three echo statements below are equal and legal:
Note: However; all variable names are case-sensitive!
Look at the example below; only the first statement will display the value of the 
$color variable! This is because 
$color, $COLOR, and 
$coLOR are treated as three 
different variables:
Insert the missing part of the code below to output "Hello World".
 "Hello World";

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.
Remove Leading Zeros from an Array using C++

We are provided an array, and we are tasked to remove the leading zeros from the given array and then print the array.
Input : arr[] = {0, 0, 0, 1, 2, 3}
Output : 1 2 3

Input : arr[] = {0, 0, 0, 1, 0, 2, 3}
Output : 1 0 2 3
We can make a new array that doesn’t contain the leading zeroes of the previous array in the given problem.
In this approach, we will go through the array and insert all the numbers but no leading zeros.
#include <iostream>

using namespace std;

int main() {
   int arr[] = {0, 0, 0, 1, 2, 0, 4};
   int n = sizeof(arr) / sizeof(int); // size of given array.
   int last = -1;
   for(int i = 0; i < n; i++) { // finding the first non zero element
      if(arr[i] != 0) {
      last = i;
      break;
      }
   }
   if(last == -1)
      cout << "Empty\n";
   else {
      int b[n - last]; // the new array.
      for(int i = last; i < n; i++) // inserting the elements in the new array
         b[i-last] = arr[i];

      for(int i = 0; i < n-last; i++) // printing the array
   cout << b[i] << " ";
   }
}
1 2 0 4
In the given program, we are firstly traversing through the array arr and finding the first non-zero element's index, which we store in variable called last now if last is -1 after the traversal, so that means our whole array is made up of zeroes, so we print our "Empty."
Now, as we got the index of the first non-zero elements, we can determine our new array's size, i.e. (n - last), and now we run a for loop from last till less than n. We insert these elements in the new array and print the new array.
In this article, we solve a problem to Remove leading zeros from an array. We also learned the C++ program for this problem and the complete approach we solved. We can write the same program in other languages such as C, java, python, and other languages. We hope you find this article helpful.
SQL Tryit Editor v1.6

DROP TABLE Shippers;
​
Edit the SQL Statement, and click "Run SQL" to see the result.
This SQL-Statement is not supported in the WebSQL Database.
The example still works, because it uses a modified version of SQL.
Your browser does not support WebSQL.
Your are now using a light-version of the Try-SQL Editor, with a read-only Database.
If you switch to a browser with WebSQL support, you can try any SQL statement, and play with the Database as much as you like. The Database can also be restored at any time.
Our Try-SQL Editor uses WebSQL to demonstrate SQL.
A Database-object is created in your browser, for testing purposes.
You can try any SQL statement, and play with the Database as much as you like. The Database can be restored at any time, simply by clicking the "Restore Database" button.
WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object.
WebSQL is supported in Chrome, Safari, Opera, and Edge(79).
If you use another browser you will still be able to use our Try SQL Editor, but a different version, using a server-based ASP application, with a read-only Access Database, where users are not allowed to make any changes to the data.
Program to find number of arithmetic sequences from a list of numbers in Python?

Suppose we have a list of numbers called nums, we have to find the number of contiguous arithmetic sequences of length ≥ 3. As we know an arithmetic sequence is a list of numbers where the difference between one number and the next number is the same.
So, if the input is like nums = [6, 8, 10, 12, 13, 14], then the output will be 4, as we have the arithmetic sequences like: [6, 8, 10] [8, 10, 12] [6, 8, 10, 12] [12, 13, 14]
To solve this, we will follow these steps −
count := 0, ans := 0
count := 0, ans := 0
for i in range 2 to size of nums, doif nums[i] - nums[i - 1] is same as nums[i - 1] - nums[i - 2], thencount := count + 1otherwise,ans := ans + quotient of (count * (count + 1)) / 2count := 0
for i in range 2 to size of nums, do
if nums[i] - nums[i - 1] is same as nums[i - 1] - nums[i - 2], thencount := count + 1
if nums[i] - nums[i - 1] is same as nums[i - 1] - nums[i - 2], then
count := count + 1
count := count + 1
otherwise,ans := ans + quotient of (count * (count + 1)) / 2count := 0
otherwise,
ans := ans + quotient of (count * (count + 1)) / 2
ans := ans + quotient of (count * (count + 1)) / 2
count := 0
count := 0
if count is non-zero, thenans := ans + quotient of (count *(count + 1)) / 2
if count is non-zero, then
ans := ans + quotient of (count *(count + 1)) / 2
ans := ans + quotient of (count *(count + 1)) / 2
return ans
return ans
Let us see the following implementation to get better understanding:
 Live Demo
class Solution:
   def solve(self, nums):
      count = 0
      ans = 0
      for i in range(2, len(nums)):
         if nums[i] - nums[i - 1] == nums[i - 1] - nums[i - 2]:
            count += 1
         else:
            ans += (count * (count + 1)) // 2
            count = 0
      if count:
         ans += (count * (count + 1)) // 2
      return ans

ob = Solution()
nums = [6, 8, 10, 12, 13, 14]
print(ob.solve(nums))
[6, 8, 10, 12, 13, 14]
4
How to set the decoration of a text with JavaScript?

Use the textDecoration property in JavaScript to decorate the text. You can underline a text using this property.
You can try to run the following code to set the decoration of a text with JavaScript −
<!DOCTYPE html>
<html>
   <body>
      <div id = "myText">This is demo text.</div><br>

      <button onclick = "display()">Set Text Decoration</button>
      <script>
         function display() {
            document.getElementById("myText").style.textDecoration = "underline";
         }
      </script>
   </body>
</html>
Program to print a pattern of numbers in C++

In this tutorial, we will be discussing a program to print a given pattern of numbers.
Our task is to make use of looping structure in the code and print the given pattern −
     1
    232
   34543
 4567654
567898765
 Live Demo
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n = 5, i, j, num = 1, gap;
   gap = n - 1;
   for ( j = 1 ; j <= n ; j++ ){
      num = j;
      for ( i = 1 ; i <= gap ; i++ )
      cout << " ";
      gap --;
      for ( i = 1 ; i <= j ; i++ ){
         cout << num;
         num++;
      }
      num--;
      num--;
      for ( i = 1 ; i < j ; i++){
         cout << num;
         num--;
      }
      cout << "\n";
   }
   return 0;
}
    1
   232
  34543
 4567654
567898765
ISRO | ISRO CS 2016 | Question 35 - GeeksforGeeks

10 May, 2020
What is the highest type number that can be assigned to the following grammar?
S → Aa
A → Ba
B → abc
(A) Type 0(B) Type 1(C) Type 2(D) Type 3Answer: (D)Explanation: According to Chomsky Hierarchy, option (D) is correct.Quiz of this Question
ApurvaRaj
ISRO
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
ISRO | ISRO CS 2009 | Question 30
ISRO | ISRO CS 2015 | Question 51
ISRO | ISRO CS 2013 | Question 8
ISRO | ISRO CS 2013 | Question 7
ISRO | ISRO CS 2013 | Question 22
ISRO | ISRO CS 2014 | Question 31
ISRO | ISRO CS 2013 | Question 31
ISRO | ISRO CS 2017 - May | Question 21
ISRO | ISRO CS 2017 | Question 42
ISRO | ISRO CS 2017 | Question 57
Count number of elements between two given elements in array in C++

We are given an array containing integer elements and two numbers start and end and the task is to calculate the count of elements present between start and end in an array.
Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. If the start element is occurring multiple times then we will consider the first occurrence of the start element and if the end element is occurring multiple times then we will consider the end occurrence of the end element.
Input − int arr[] = {1, 2, 3, 4, 5, 6, 7}
      Start = 1 and End = 7
Output − count is 5
Explanation − In the given array, there are 7 elements and the range is 1-7. So, in between this range there are a total of 5 elements.
Input − int arr[] = {1, 2, 3, 4, 5, 6, 7}
      Start = 7 and End = 9
Output − count is 0
Explanation − In the given array, there are 7 elements and the range is 7-9. So, in between this range there is no element so the count is 0.
Input an array let’s say, int arr[]
Input an array let’s say, int arr[]
Calculate the length of both the arrays using the length() function that will return an integer value as per the elements in an array.
Calculate the length of both the arrays using the length() function that will return an integer value as per the elements in an array.
Start the loop from i to 0 till i less than size of an array
Start the loop from i to 0 till i less than size of an array
Inside the loop, check if arr[i] = start then break
Inside the loop, check if arr[i] = start then break
Check if i>size-1 then return
Check if i>size-1 then return
Start another loop with j to size-1 and j>=i+1 and j--
Start another loop with j to size-1 and j>=i+1 and j--
Check if arr[j]=end then break
Check if arr[j]=end then break
Check if j=1 then return 0
Check if j=1 then return 0
Return j-i-1
Return j-i-1
Print the result.
Print the result.
 Live Demo
#include <iostream>
using namespace std;
// For counting the numbers between the two elements
int countelements(int ar[], int n, int start, int end){
   // Find start
   int i = 0;
   for (i = 0; i < n; i++){
      if (ar[i] == start){
         break;
      }
   }
   // If start is not present or present at the last
   if (i >= n-1){
      return 0;
   }
   // Find end
   int j;
   for (j = n-1; j >= i+1; j--){
      if (ar[j] == end){
         break;
      }
   }
   // If end is not present
   if (j == i){
      return 0;
   }
   // number of elements between the two elements
   return (j - i - 1);
}
// Main Function
int main(){
   int ar[] = { 1, 6, 2, 5, 9, 8, 3, 7, 4 };
   int n = sizeof(ar) / sizeof(ar[0]);
   int start = 5, end = 4;
   cout <<"count is " <<countelements(ar, n, start, end);
   return 0;
}
If we run the above code we will get the following output −
count is 4
LocalDate atStartOfDay() method in Java with Examples - GeeksforGeeks

28 Nov, 2018
The atStartOfDay() method of LocalDate class in Java is combines this date with the time of midnight to create a LocalDateTime at the start of this date.
Syntax:
public ZonedDateTime atStartOfDay(ZoneId zone)

Parameter: This method accepts a parameter zone which is the zone ID to be used and not necessary null. The parameter is not mandatory.
Return Value: It returns the the local date-time of midnight at the start of this date, not null.
Below programs illustrate the atStartOfDay() method of LocalDate in Java:
Program 1:
// Program to illustrate the atStartOfDay() method  import java.util.*;import java.time.*;  public class GfG {    public static void main(String[] args)    {        // parses the local date        LocalDate dt = LocalDate.parse("2019-11-01");        System.out.println(dt);          // Function call        LocalDateTime dt1 = dt.atStartOfDay();        System.out.println(dt1);    }}
2019-11-01
2019-11-01T00:00

Program 2: Program with parameters.
// Program to illustrate the atStartOfDay() method  import java.util.*;import java.time.*;  public class GfG {    public static void main(String[] args)    {          // parses the local date        LocalDate dt = LocalDate.parse("2018-01-20");        System.out.println(dt);          // Function call        ZonedDateTime dt1 = dt.atStartOfDay(ZoneId.systemDefault());        System.out.println(dt1);    }}
2018-01-20
2018-01-20T00:00Z[Etc/UTC]

Reference: https://docs.oracle.com/javase/10/docs/api/java/time/LocalDate.html#atStartOfDay()
Java-Functions
Java-LocalDate
Java-time package
Java
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
Difference between Abstract Class and Interface in Java
final Keyword in Java
How to Create Array of Objects in Java?
Java Math random() method with Examples
Java | Implementing Iterator and Iterable Interface
Using CX_Freeze in Python

Sometimes we feel to create something different which is very exciting, and according to human nature, we always love to share it.
Python also fulfills those wishes. Using Python, if we want to share our Python program with our friends we can do that, only need to have the same version of Python installed with all the modules those are used in program of their machine.
First we need to install CX_Freeze module using pip install CX_Frezze command in command prompt.
First step is to solve this assignment, a python program conversion. We need standard library modules, here we use urllib and re module where we parsed python.com.
import urllib.request
import urllib.parse
import re
import time
my_url = 'https://www.python.com/'
my_values = {'s' : 'basics',
          'submit' : 'search'}
my_data = urllib.parse.urlencode(my_values)
my_data = data.encode('utf-8')
my_req = urllib.request.Request(my_url, my_data)
my_resp = urllib.request.urlopen(my_req)
my_respData = my_resp.read()
my_paragraphs = re.findall(r'<p>(.*?)</p>',str(my_respData))
for p in my_paragraphs:
   print(p)
time.sleep(20)
Here we use 20 second sleep at the end, so we can see the output before it closes.
This program is saved as "pythonCX_Freeze.py" file name.
Now next step is to create setup file and this file is called "setup.py"
from cx_Freeze import setup, Executable
setup(name = "pythonCX_Freeze" ,
   version = "0.1" ,
   description = "" ,
   executables = [Executable("pythonCX_Freeze.py")])
In this program we importing pythonCX_Freeze setup and executable. Next we call setup() function with 4 parameters. First parameter name, this is the name of the program that we want to execute, second is version, this is the version number to give it, description if we want then we write necessary line otherwise blank it and last one is executable function with one parameter.
Next we open cmd.exe then navigate the directory where has the setup.py and the script.
Then we run python setup.py build.
Now given a build directory and within this directory we find another directory and within that directory we find our executable. If every step is done correctly then it should parse the search result of basic form on python.com and display result for 20 seconds before closing.
How to create an array of linked lists in java?

A linked list is a sequence of data structures, which are connected together via links.
To create an array of linked lists, create required linked lists and, create an array of objects with them.
Live Demo
import java.util.LinkedList;

public class ArrayOfLinkedList {
   public static void main(String args[]) {
      LinkedList list1 = new LinkedList();
      list1.add("JavaFX");
      list1.add("Hbase");
     
      LinkedList list2 = new LinkedList();
      list2.add("OpenCV");
      list2.add("Mahout");
     
      LinkedList list3 = new LinkedList();
      list3.add("WebGL");
      list3.add("CoffeeScript");
      Object[] obj = {list1, list2, list3};
     
      for (int i=0; i<obj.length; i++) {
         System.out.println(obj[i].toString());
      }
   }
}
[JavaFX, Hbase]
[OpenCV, Mahout]
[WebGL, CoffeeScript]
You can also create Array list of linked lists as –
Live Demo
import java.util.ArrayList;
import java.util.LinkedList;

public class ArrayOfLinkedList {
   public static void main(String args[]) {
      LinkedList list1 = new LinkedList();
      list1.add("JavaFX");
      list1.add("Hbase");
     
      LinkedList list2 = new LinkedList();
      list2.add("OpenCV");
      list2.add("Mahout");
     
      LinkedList list3 = new LinkedList();
      list3.add("WebGL");
      list3.add("CoffeeScript");
     
      ArrayList <LinkedList> aList = new ArrayList<LinkedList>();
      aList.add(list1);
      aList.add(list2);
      aList.add(list1);
      System.out.println(aList);
   }
}
[[JavaFX, Hbase], [OpenCV, Mahout], [JavaFX, Hbase]]
Java Program to check the end of a string

To check the end of a string, use the endsWith() method.
Let’s say the following is our string.
String str = "demo";
Now, check for the substring “mo” using the endsWith() method in an if-else condition.
if(str.endsWith("mo")) {
   System.out.println("The string ends with the word mo");
} else {
   System.out.println("The string does not end with the word mo");
}
The following is the complete example with output.
 Live Demo
public class Demo {
    public static void main(String[] args) {
       String str = "demo";
       if(str.endsWith("mo")) {
          System.out.println("The string ends with the word mo");
       } else {
          System.out.println("The string does not end with the word mo");
       }
    }
}
The string ends with the word mo
Python Program to find whether a no is power of two

In this article, we will learn about the solution to the problem statement given below.
Problem statement − We are given a number, we need to check that the number is a power of two or not.
We can solve this using two approaches as discussed below.
 Live Demo
# power of 2
def find(n):
   if (n == 0):
      return False
   while (n != 1):
      if (n % 2 != 0):
         return False
      n = n // 2
   return True
# Driver code
if(find(98)):
   print('Yes')
else:
   print('No')
No
 Live Demo
# power of 2
def find(x):
   # if x is 0 or not
   return (x and (not(x & (x - 1))) )
# Driver code
if(find(98)):
   print('Yes')
else:
   print('No')
No
In this article, we have learned how we can check that the given number is a power of two.
Get the position of the maximum element in each Row of a Matrix in R Programming - max.col() Function - GeeksforGeeks

16 Jun, 2020
max.col() function in R Language check for maximum value in each row and returns the column no. for it.
Syntax: max.col(x, ties.method)
Parameters:x: Numeric matrixties.method: It takes random, first, and last as value and returns the position accordingly in case of a tie.
Example 1:
# R program to find positions # of maximum elements of a matrix  # Creating matricesm1 <- matrix(c(1:4), 2)m2 <- matrix(c(4, 1, 2, 3), 2)m3 <- matrix(c(1:9), 3, 3)  # Calling max.col() functionmax.col(m1)max.col(m2)max.col(m3)
Output:
[1] 2 2
[1] 1 2
[1] 3 3 3

Example 2:
# R program to find positions # of maximum elements of a matrix  # Creating matricesm1 <- matrix(c(2, 3, 2, 4), 2)m2 <- matrix(c(2, 3, 2, 4), 2)m3 <- matrix(c(2, 3, 2, 4), 2)m1  # Calling max.col() functionmax.col(m1, ties.method = "random")max.col(m2, ties.method = "first")max.col(m3, ties.method = "last")
Output:
     [, 1] [, 2]
[1, ]    2    2
[2, ]    3    4
[1] 2 2
[1] 1 2
[1] 2 2

R Matrix-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Replace specific values in column in R DataFrame ?
Filter data by multiple conditions in R using Dplyr
Loops in R (for, while, repeat)
Change Color of Bars in Barchart using ggplot2 in R
How to change Row Names of DataFrame in R ?
Printing Output of an R Program
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
Remove rows with NA in one column of R DataFrame
K-Means Clustering in R Programming
Tryit Editor v3.7

CSS Grid Intro
Tryit: Grid lines