code-rag-bench/online-tutorials huggingface dataset:
Difference between ArrayList.clear() and ArrayList.removeAll() in java?

The ArrayList class in Java is a Resizable-array implementation of the List interface. It allows null values.
The clear() method this class removes all the elements from the current List object.
 Live Demo
import java.util.ArrayList;
public class ClearExample {
   public static void main(String[] args){
      //Instantiating an ArrayList object
      ArrayList<String> list = new ArrayList<String>();
      list.add("JavaFX");
      list.add("Java");
      list.add("WebGL");
      list.add("OpenCV");
      list.add("Impala");
      System.out.println("Contents of the Array List: \n"+list);
      //Removing the sub list
      list.clear();
      System.out.println("Contents of the ArrayList object after invoking the clear() method: "+list);
   }
}
Contents of the Array List:
[JavaFX, Java, WebGL, OpenCV, Impala]
Contents of the ArrayList object after invoking the clear() method: []
Whereas, the removeAll() method of the ArrayList class accepts another collection object as a parameter and removes all the contents of it from the current ArrayList.
 Live Demo
import java.util.ArrayList;
public class ClearExample {
   public static void main(String[] args){
      //Instantiating an ArrayList object
      ArrayList<String> list1 = new ArrayList<String>();
      list1.add("JavaFX");
      list1.add("Java");
      list1.add("WebGL");
      list1.add("OpenCV");
      list1.add("OpenNLP");
      list1.add("JOGL");
      list1.add("Hadoop");
      list1.add("HBase");
      list1.add("Flume");
      list1.add("Mahout");
      list1.add("Impala");
      System.out.println("Contents of the Array List1 : \n"+list1);
      ArrayList<String> list2 = new ArrayList<String>();
      list2.add("JOGL");
      list2.add("Hadoop");
      list2.add("HBase");
      list2.add("Flume");
      list2.add("Mahout");
      list2.add("Impala");
      System.out.println("Contents of the Array List1 : \n"+list2);
      //Removing elements
      list1.removeAll(list2);
      System.out.println("Contents of the Array List after removal: \n"+list1);
   }
}
Contents of the Array List1 :
[JavaFX, Java, WebGL, OpenCV, OpenNLP, JOGL, Hadoop, HBase, Flume, Mahout, Impala]
Contents of the Array List1 :
[JOGL, Hadoop, HBase, Flume, Mahout, Impala]
Contents of the Array List after removal:
[JavaFX, Java, WebGL, OpenCV, OpenNLP]
Time Functions in C#

The DateTime has methods and properties for Date and Time as well like how to get the number of hours or minutes of a day, etc.
Let us only focus on the time functions −
Refer MSDN (Microsoft Developer Network) for all the functions −
Let us learn about a Time function i.e. AddMilliseconds(Double) to add the specified number of milliseconds to the value of this instance.
 Live Demo
using System;

public class Demo {
   public static void Main() {
      string dateFormat = "MM/dd/yyyy hh:mm:ss.fffffff";
      DateTime dateCurrent = new DateTime(2018, 7, 23, 13, 0, 0);
      Console.WriteLine("Original date: {0} ({1:N0} ticks)\n", dateCurrent.ToString(dateFormat),          dateCurrent.Ticks);

      DateTime dateNew = dateCurrent.AddMilliseconds(1);
      Console.WriteLine("Next date: {0} ({1:N0} ticks)", dateNew.ToString(dateFormat),          dateNew.Ticks);

   }
}
Original date: 07/23/2018 01:00:00.0000000 (636,679,476,000,000,000 ticks)
Next date: 07/23/2018 01:00:00.0010000 (636,679,476,000,010,000 ticks)
Difference Between Where and Having Clause in SQL

In this post, we will understand the difference between WHERE clause and HAVING clause in SQL.
It is used to filter the records from the table based on a specific condition.
It is used to filter the records from the table based on a specific condition.
It can be used without the ‘GROUP BY’ clause.
It can be used without the ‘GROUP BY’ clause.
It can be used with row operations.
It can be used with row operations.
It can’t contain the aggregate functions.
It can’t contain the aggregate functions.
It can be used with the ‘SELECT’, ‘UPDATE’, and ‘DELETE’ statements.
It can be used with the ‘SELECT’, ‘UPDATE’, and ‘DELETE’ statements.
It is used before the ‘GROUP BY’ clause if required.
It is used before the ‘GROUP BY’ clause if required.
It is used with a single row function such as ‘UPPER’, ‘LOWER’.
It is used with a single row function such as ‘UPPER’, ‘LOWER’.
It is used to filter out records from the groups based on a specific condition.
It is used to filter out records from the groups based on a specific condition.
It can’t be used without the ‘GROUP BY’ clause.
It can’t be used without the ‘GROUP BY’ clause.
It works with the column operation.
It works with the column operation.
It can contain the aggregate functions.
It can contain the aggregate functions.
It can only be used with the ‘SELECT’ statement.
It can only be used with the ‘SELECT’ statement.
It is used after the ‘GROUP BY’ clause.
It is used after the ‘GROUP BY’ clause.
It can be used with multiple row functions such as ‘SUM’, ‘COUNT’.
It can be used with multiple row functions such as ‘SUM’, ‘COUNT’.
SELECT column1, column2
FROM table1, table2
WHERE [ conditions ]
GROUP BY column1, column2
HAVING [ conditions ]
ORDER BY column1, column2
How to get MySQL query result in same order as given by IN clause?

For this, you can use IN() along with ORDER BY FIELD(). Let us first create a table −
mysql> create table DemoTable
(
   Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   FirstName varchar(100)
);
Query OK, 0 rows affected (0.64 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(FirstName) values('Chris');
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable(FirstName) values('Robert');
Query OK, 1 row affected (0.08 sec)
mysql> insert into DemoTable(FirstName) values('Mike');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable(FirstName) values('Sam');
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable(FirstName) values('Carol');
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable(FirstName) values('David');
Query OK, 1 row affected (0.42 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+----+-----------+
| Id | FirstName |
+----+-----------+
|  1 | Chris     |
|  2 | Robert    |
|  3 | Mike      |
|  4 | Sam       |
|  5 | Carol     |
|  6 | David     |
+----+-----------+
6 rows in set (0.00 sec)
The following is how to get query results in the same order as given by the IN clause.
mysql> select FirstName from DemoTable where Id IN(4,5,6) order by field(Id,4,5,6);
This will produce the following output −
+-----------+
| FirstName |
+-----------+
| Sam       |
| Carol     |
| David     |
+-----------+
3 rows in set (0.00 sec)
IDE | GeeksforGeeks | A computer science portal for geeks

Please enter your email address or userHandle.
12345678910111213141516171819202122232425262728293031323334353637// C++ program sort array in even and odd manner.// The odd numbers are to be sorted in descending// order and the even numbers in ascending order#include<bits/stdc++.h>using namespace std;// To do two way sort. First sort even numbers in// ascending order, then odd numbers in descending// order.void twoWaySort(int arr[], int n){    int count_pos = 0;    // Make all odd numbers negative    for (int i=0 ; i<n ; i++)        if (arr[i] & 1){ // Check for odd            // counting only positive odd numbers            if(arr[i] > 0){                count_pos++;            }            arr[i] *= -1;        }    // Sort positive odd and all even all numbers    sort(arr, arr+n);    // Retaining original array    for (int i=0 ; i<n ; i++)        if (arr[i] & 1)            arr[i] *= -1;    // sorts all the numbers.    sort(arr+count_pos, arr+n);}// Driver codeint main(){ההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
https://ide.geeksforgeeks.org/xXobxp
7 1 -5 -3 2 4
Print all sequences of given length in C++

In this problem, we are given two integer values, k, and n. And we have to
print all the sequences of length k from numbers from 1 to n in sorted order.
Let’s take an example to understand the topic −
Input:k = 2 ; n = 3
Output:
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
So in this problem, we have to print the sequence as stated above.
A simple way to solve this problem is by incrementing integers of the sequence till they get to the max value i.e. n. The following is a detailed description of the solution.
1) Create an array of size k with all values = 1 i.e. {1, 1, ..ktimes}.
2) Repeat step 3 and 4 till the array becomes {n, n, ..., n}.
3) Print the array.
4) Increment the value such that the elements of the array become the next value. For example, {1, 1, 1} incremented to {1, 1, 2} and {1, 3, 3} incremented to {2, 1, 1}. For this we need to check the kth element of the array, if it’s equal to n become update, then check k-1 element in the sequence and so on for the same condition.
The following program will make the concept more clear to you.
 Live Demo
#include<iostream>
using namespace std;
void printSequence(int arr[], int size){
   for(int i = 0; i < size; i++)
      cout<<arr[i]<<"\t";
   cout<<endl;
   return;
}
int nextElement(int arr[], int k, int n){
   int s = k - 1;
   while (arr[s] == n)
      s--;
   if (s < 0)
      return 0;
   arr[s] = arr[s] + 1;
   for(int i = s + 1; i < k; i++)
      arr[i] = 1;
   return 1;
}
void generateSequence(int n, int k){
   int *arr = new int[k];
   for(int i = 0; i < k; i++)
      arr[i] = 1;
   while(1){
      printSequence(arr, k);
   if(nextElement(arr, k, n) == 0)
      break;
   }
   return;
}
int main(){
   int n = 3;
   int k = 2;
   cout<<"The sequence is :\n";
   generateSequence(n, k);
   return 0;
}
The sequence is −
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
This method is easy to understand but can be made better and more efficient.
This method uses recursion and an extra index to check for sequence offset (value after which the sequence will be flipped). The function will be called recursively and will not update the terms till index. And recure the function for next terms after index.
 Live Demo
#include<iostream>
using namespace std;
void printSequence (int arr[], int size){
   for (int i = 0; i < size; i++)
      cout << arr[i] << "\t";
   cout << endl;
   return;
}
void generateSequence (int arr[], int n, int k, int index){
   int i;
   if (k == 0){
      printSequence (arr, index);
   }
   if (k > 0){
      for (i = 1; i <= n; ++i){
         arr[index] = i;
         generateSequence (arr, n, k - 1, index + 1);
      }
   }
}
int main (){
   int n = 3;
   int k = 2;
   int *arr = new int[k];
   cout<<"The sequence is:\n";
   generateSequence (arr, n, k, 0);
   return 0;
}
The sequence is −
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
How to change the visibility of the Cursor of Console in C#

To change the visibility of the Cursor, use the Console.CursorVisible property.
Let us see an example −
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Demo {
   public static void Main (string[] args) {
      Console.BackgroundColor = ConsoleColor. Black;
      Console.WriteLine("Background color changed = "+Console.BackgroundColor);
      Console.ForegroundColor = ConsoleColor.White;
      Console.WriteLine("\nForeground color changed = "+Console.ForegroundColor);
      Console.InputEncoding = Encoding.ASCII;
      Console.WriteLine("Input Encoding Scheme = "+Console.InputEncoding);
      Console.OutputEncoding = Encoding.ASCII;
      Console.WriteLine("Output Encoding Scheme = "+Console.OutputEncoding);
      Console.CursorVisible = false;
      Console.Write("\nCursor is Visible? "+ Console.CursorVisible);
   }
}

This will produce the following output −
Difference Between Packages and Interfaces in Java

In this post, we will understand the difference between packages and interfaces in Java.
It is a group of classes and/or interfaces that are together.
It is a group of classes and/or interfaces that are together.
It can be created using the "Package" keyword.
It can be created using the "Package" keyword.
It can be imported.
It can be imported.
It can be done using the "import" keyword.
It can be done using the "import" keyword.
package package_name;
public class class_name {
   .
   (body of class)
   .
}
It is a group of abstract methods and constants.
It is a group of abstract methods and constants.
It can be created using the "Interface" keyword.
It can be created using the "Interface" keyword.
It can be extended by another interface.
It can be extended by another interface.
It can also be implemented by a class.
It can also be implemented by a class.
It can be implemented using the ‘implement’ keyword.
It can be implemented using the ‘implement’ keyword.
interface interface_name {
   variable declaration;
   method declaration;
}
Write program to shutdown a system in C/C++

A program to shutdown the system works on the operating systems like windows, linux or macOS. To shut it off and close all opened applications.
Shut down or Power off a computer means removing power from a computer's main components in an organised prescribed way and turning off all the works that are done by the computer i.e. all applications and processings are shut off. After a computer is shut down, the main components such as CPU, RAM modules and hard disk drives are powered down, although some internal components, such as an internal clock, may access power.
This program turns off, i.e., shut down your computer system. System function of "stdio.h" is to run an executable file shutdown.exe which is present in C:\WINDOWS\system32 folder in Windows.
For Linux program the process is similar and is mentioned below.
#include <stdio.h>
int main() {
   system("c:\\windows\\system32\\shutdown /i");
   return 0;
}
The program works as a command that commands the operating system to close all applications and shutdown the system.
#include <stdio.h>
int main() {
   system("shutdown -P now");
   return 0;
}
This is a code that can shut any linux based operating systems. Code directly puts a command for the system which executes it and shuts the system as soon as possible.
Program to print multiplication table of any number in PHP - GeeksforGeeks

27 Oct, 2021

In this article, we will see how to print the multiplication table of any given number using PHP. To make the multiplication table, first, we get a number input from the user and then use for loop to display the multiplication table.
We use HTML and PHP to display the multiplication table. The HTML part is used to design a form to get the input from the user and the PHP part is used to execute the multiplication and display the results in table format.
Example:
PHP
 

 
 










<!DOCTYPE html> 
<html> 
  
<body> 
    <center> 
        <h1 style="color: green;"> 
            GeeksforGeeks 
        </h1> 
  
        <h3> 
            Program to print multiplication<br> 
            table of any number in PHP 
        </h3> 
  
        <form method="POST"> 
            Enter a number:  
            <input type="text" name="number"> 
              
            <input type="Submit" 
                value="Get Multiplication Table"> 
        </form> 
    </center> 
</body> 
  
</html> 
  
<?php 
if($_POST) { 
    $num = $_POST["number"]; 
  
    echo nl2br("<p style='text-align: center;'> 
        Multiplication Table of $num: </p> 
    "); 
          
    for ($i = 1; $i <= 10; $i++) { 
        echo ("<p style='text-align: center;'>$num"
            . " X " . "$i" . " = " 
            . $num * $i . "</p> 
        "); 
    } 
} 
?>






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


loop


PHP-math


PHP-Questions


HTML


PHP


Web Technologies

Writing code in comment? 
                                    Please use ide.geeksforgeeks.org, 
                                    generate link and share the link here.
                                
How to update Node.js and NPM to next version ?
How to Insert Form Data into Database  using PHP ?
REST API (Introduction)
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
How to execute PHP code using command line ?
How to Insert Form Data into Database  using PHP ?
PHP in_array() Function
How to pop an alert message box using PHP ?
How to convert array to string in PHP ?
Jagged Array in Java

Jagged array is a multidimensional array where member arrays are of different size. For example, we can create a 2D array where first array is of 3 elements, and is of 4 elements. Following is the example demonstrating the concept of jagged array.
 Live Demo
public class Tester {
   public static void main(String[] args){
      int[][] twoDimenArray = new int[2][];

      //first row has 3 columns
      twoDimenArray[0] = new int[3];

      //second row has 4 columns
      twoDimenArray[1] = new int[4];

      int counter = 0;
      //initializing array
      for(int row=0; row < twoDimenArray.length; row++){

         for(int col=0; col < twoDimenArray[row].length; col++){
            twoDimenArray[row][col] = counter++;
         }
      }

      //printing array
      for(int row=0; row < twoDimenArray.length; row++){
         System.out.println();
         for(int col=0; col < twoDimenArray[row].length; col++){
            System.out.print(twoDimenArray[row][col] + " ");
         }
      }
   }
}
0 1 2
3 4 5 6
Interfacing a speaker with Arduino

In this tutorial, we will interface a simple piezo-buzzer with Arduino to create beeping sounds. Such an arrangement can be used in applications like burglar alarms, or water level indicators or such similar projects.
As you can see, the circuit diagram is quite straightforward. You need to connect the buzzer’s GND to Arduino’s GND, and the other wire to one GPIO of the Arduino (we have chosen pin 7). You can optionally add a small resistor (~100 Ohm), between the GPIO and the buzzer.
The entire code is given below −
#define buzzerPin 7                // buzzer to arduino uno pin 7

void setup(){
   pinMode(buzzerPin, OUTPUT);    // Set buzzer - pin 9 as an output
}

void loop(){
   tone(buzzerPin, 2000);     // Send 2000Hz sound signal...
   delay(500);                // ...for 0.5 sec
   noTone(buzzerPin);         // Stop sound...
   delay(500);                // ...for 0.5 sec
}
As you can see, the code is pretty straightforward. We first define the buzzerPin
#define buzzerPin 7 //buzzer to arduino uno pin 7
In the Setup, we just initialize the pin as OUTPUT.
void setup(){
   pinMode(buzzerPin, OUTPUT); // Set buzzer - pin 9 as an output
}
In the loop, we use the tone() function to create a 2000 Hz tone on the buzzerPin for half a second, after which we stop the tone using the noTone() function, for another half second. This goes on in the loop and creates the beeping effect. You can read more about the tone() function here.
void loop(){
   tone(buzzerPin, 2000);          // Send 2000Hz sound signal...
   delay(500);                    // ...for 0.5 sec
   noTone(buzzerPin);             // Stop sound...
   delay(500);                   // ...for 0.5 sec
}
CSS | ::after Selector

20 Dec, 2018
::after selector is used to add same content multiple times after the content of other elements. This selector is same as ::before selector.
Syntax:
::after{
        content:
}

Below HTMl/CSS code shows the functionality of ::after selector :
<!DOCTYPE html><html>  <head>    <style>        p::after {            content: " - Remember this";            background-color: blue;        }    </style></head>  <body>    <h3>After Selector</h3>    <p>User ID: @dmor1</p>    <p>Name: dharam</p></body>  </html>
Output:
Supported Browsers
Google Chrome 4.0
Edge 9.0
Firefox 3.5
Safari 3.1
Opera 7.0
Note: Internet Explorer 8 and Opera 4-6 supports with single-colon.(:after)
CSS-Selectors
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Display an Image in Grayscale in Matplotlib?

01 Feb, 2022
In this article, we are going to depict images using matplotlib module in grayscale representation i.e. image representation using two colors only i.e. black and white.
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The Image module provides a class with the same name which is used to represent a PIL image. The module also provides a number of factory functions, including functions to load images from files, and to create new images. PIL.Image.open() method in PIL module opens and identifies the given image file.
Matplotlib is a plotting library for creating static, animated, and interactive visualizations in Python. The matplotlib module can be used in Python scripts, the Python and IPython shell, web application servers, and various graphical user interface toolkits like Tkinter, awxPython, etc.
Step-by-step Approach:
Import required modules
Python3
# importing libraries.import numpy as npimport matplotlib.pyplot as pltfrom PIL import Image
Displaying Original picture.
Python3
# storing image pathfname = r'g4g.png' # opening image using pilimage = Image.open(fname) # plottingimageplt.imshow(image)plt.show()
Output:
Displaying Grayscale image, store the image path here let’s say it fname. Now open the image using PIL image method and convert it to L mode If you have an L mode image, that means it is a single-channel image – normally interpreted as grayscale. It only stores a grayscale, not color. Plotting the image as cmap = ‘gray’ convert the colours. All the work is done you can now see your image.
Python3
# storing image pathfname = r'g4g.png' # opening image using pilimage = Image.open(fname).convert("L") # maping image to gray scaleplt.imshow(image, cmap='gray')plt.show()
Output:
Below are some programs which depict how to display an image in grayscale using Matplotlib module:
Example 1:
Image used:
Python3
# importing libraries.import numpy as npimport matplotlib.pyplot as pltfrom PIL import Image  # storing image pathfname = r'gfg.png' # opening image using pilimage = Image.open(fname).convert("L") # mapping image to gray scaleplt.imshow(image, cmap='gray')plt.show()
Output:
Example 2:
Image Used:
Python3
# importing libraries.import numpy as npimport matplotlib.pyplot as pltfrom PIL import Image  # storing image pathfname = r'geeks.png' # opening image using pilimage = Image.open(fname).convert("L") # mapping image to gray scaleplt.imshow(image, cmap='gray')plt.show()
Output:
adnanirshad158
clintra
Picked
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Get current time in milliseconds using Python

27 Dec, 2019
Time module in Python provides various time-related functions. This module comes under Python’s standard utility modules, so there is no need to install it externally.
time.time() method of Time module is used to get the time in seconds since epoch. The handling of leap seconds is platform dependent.
Note: The epoch is the point where the time starts, and is platform dependent. On Windows and most Unix systems, the epoch is January 1, 1970, 00:00:00 (UTC) and leap seconds are not counted towards the time in seconds since the epoch. To check what the epoch is on a given platform we can use time.gmtime(0).
Syntax: time.time()
Return type: This method returns a float value which represents the time in seconds since the epoch.
Example 1:
# Python program to get# time in milliseconds  # Import class time from time modulefrom time import time  # time() function is multiplied with # 1000 to convert seconds into milliseconds.milliseconds = int(time() * 1000)  print("Time in milliseconds since epoch", milliseconds)
Output:
Time in milliseconds since epoch 1576071104408

Example 2: Using lambda function
# Python program to get# time in milliseconds    # Import class time from time modulefrom time import time  # Get time in milliseconds using# lambda functionmilliseconds = lambda: int(time() * 1000)  print("Time in milliseconds since epoch", milliseconds())
Output:
Time in milliseconds since epoch 1576071316487

Python time-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Tryit Editor v3.7

Tryit: A list with i, ii, iii
MINUTE(), MICROSECOND() and HOUR() functions in MySQL - GeeksforGeeks

09 Dec, 2021
1. MINUTE() : The MySQL MINUTE() function is used for return the minute part of a datetime value. It can be between 0 to 59.When the datetime is passed in MINUTE() function then it will return the minute value . 
Syntax – 
MINUTE(datetime) 
Parameter – It take parameter a dateline value. 
Return – It returns a minute numeric value between 0 to 59. 
Example-1:  
SELECT MINUTE ("2020-06-29 10:34:00"); 
Output –  
34
Example-2:  
SELECT MINUTE("4:10:17");
Output –  
10
2. MICROSECOND() – The Mysql function MICROSECOND() is used for return the microsecond part of datetime value .It can be between 0 to 999999.When the datetime is passed in MINUTE() function then it will return the microsecond value . 
Syntax [-  
MICROSECOND(datetime)
Parameter – A datetime value. 
Return – Return an integer 
Example-1:  
SELECT MICROSECOND("2010-07-20 06:24:10.967423"); 
Output –  
967423
Example-2:  
SELECT MICROSECOND("2005-10-10 12:24:17.000007"); 
Output –  
7
3. HOUR() : The MySQL function HOUR() returns the hour part of a given datetime. It can be between 0 to 838. 
Syntax –  
HOUR(datetime) 
Parameter – A datetime value. 
Return – It return an integer value. 
Example-1:  
SELECT HOUR("12:24:17.000007"); 
Output –  
12
Example-2:  
SELECT MICROSECOND(""838:59:59""); 
Output –  
838
Supported Versions of MySQL :  
MySQL 4.0
MySQL 4.1
MySQL 5.0
MySQL 5.1
MySQL 5.5
MySQL 5.6
MySQL 5.7 
surindertarika1234
DBMS-SQL
mysql
DBMS
SQL
DBMS
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL Trigger | Student Database
Introduction of B-Tree
Difference between Clustered and Non-clustered index
Introduction of ER Model
Introduction of DBMS (Database Management System) | Set 1
SQL | DDL, DQL, DML, DCL and TCL Commands
How to find Nth highest salary from a table
SQL | ALTER (RENAME)
SQL Trigger | Student Database
CTE in SQL
Character constants vs String literals in C#

Character literals are enclosed in single quotes. For example, 'x' and can be stored in a simple variable of char type. A character literal can be a plain character (such as 'x'), an escape sequence (such as '\t'), or a universal character (such as '\u02C0').
Certain characters in C# are preceded by a backslash. They have special meaning and they are used to represent like newline (\n) or tab (\t).
 Live Demo
using System;
namespace Demo {
   class MyApplication {
      static void Main(string[] args) {
         Console.WriteLine("Welcome\t to the website\n\n");
         Console.ReadLine();
      }
   }
}
Welcome to the website
String literals or constants are enclosed in double quotes "" or with @"". A string contains characters that are similar to character literals: plain characters, escape sequences, and universal characters.
How MySQL IF ELSE statement can be used in a stored procedure?

MySQL IF ELSE statement implements a basic conditional construct when the expression evaluates to false. Its syntax is as follows −
IF expression THEN
   statements;
ELSE
   else-statements;
END IF;
The statements must end with a semicolon.
To demonstrate the use of IF ELSE statement within MySQL stored procedure, we are creating the following stored procedure which is based on the values, as shown below, of the table named ‘student_info’ −
mysql> Select * from student_info;
+------+---------+------------+------------+
| id   | Name    | Address    | Subject    |
+------+---------+------------+------------+
| 101  | YashPal | Amritsar   | History    |
| 105  | Gaurav  | Jaipur     | Literature |
| 125  | Raman   | Shimla     | Computers  |
+------+---------+------------+------------+
3 rows in set (0.00 sec)
The following query will create a procedure named ‘coursedetails_IFELSE’ which have IF ELSE statements in it −
mysql> DELIMITER // ;
mysql> CREATE PROCEDURE coursedetails_IFELSE(IN S_Subject Varchar(20), OUT S_Course varchar(50))
   -> BEGIN
   -> DECLARE Sub Varchar(20);
   -> SELECT Subject INTO SUB
   -> FROM Student_info WHERE S_Subject = Subject;
   -> IF Sub = 'Computers' THEN
   -> SET S_Course = 'B.Tech(CSE)';
   -> ELSE
   -> SET S_Course = 'Subject Not in the table ';
   -> END IF;
   -> END //
Query OK, 0 rows affected (0.00 sec)
Now, we can see the result below when we invoke this procedure −
mysql> Delimiter ; //
mysql> CALL coursedetails_IFELSE('Computers', @S_Course);
Query OK, 1 row affected (0.00 sec)

mysql> Select @S_Course;
+-------------+
| @S_Course   |
+-------------+
| B.Tech(CSE) |
+-------------+
1 row in set (0.00 sec)

mysql> CALL coursedetails_IFELSE ('History', @S_Course);
Query OK, 0 rows affected (0.00 sec)

mysql> Select @S_Course;
+--------------------------------+
| @S_Course                      |
+--------------------------------+
| Subject Not in the table       |
+--------------------------------+
1 row in set (0.00 sec)
string::npos in C++ with Examples

16 Jul, 2021
What is string::npos:
It is a constant static member value with the highest possible value for an element of type size_t.
It actually means until the end of the string.
It is used as the value for a length parameter in the string’s member functions.
As a return value, it is usually used to indicate no matches.
Syntax:
static const size_t npos = -1;Where, npos is constant static value with the highest possible value for an element of type size_t and it is defined with -1.
Program 1: Below is the C++ program to illustrate the use of string::npos:
C++
// C++ program to demonstrate the use// of string::npos#include <bits/stdc++.h>using namespace std; // Function that using string::npos// to find the index of the occurrence// of any string in the given stringvoid fun(string s1, string s2){    // Find position of string s2    int found = s1.find(s2);     // Check if position is -1 or not    if (found != string::npos) {         cout << "first " << s2             << " found at: "             << (found) << endl;    }     else        cout << s2 << " is not in"             << "the string" << endl;} // Driver Codeint main(){    // Given strings    string s1 = "geeksforgeeks";    string s2 = "for";    string s3 = "no";     // Function Call    fun(s1, s2);     return 0;}
  
first for found at: 5
 
 
Explanation: In the above program string:npos constant is defined with a value of -1, because size_t is an unsigned integral type, and -1 is the largest possible representable value for this type.
 
raghavrakh
shivprakash0820
chawla19gurpreet
cpp-string
cpp-strings
cpp-strings-library
C++
C++ Programs
Strings
cpp-strings
Strings
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Sorting a vector in C++
Polymorphism in C++
std::string class in C++
Friend class and function in C++
Pair in C++ Standard Template Library (STL)
Header files in C/C++ and its uses
Sorting a Map by value in C++ STL
Program to print ASCII Value of a character
How to return multiple values from a function in C or C++?
C++ program for hashing with chaining
AngularJS | ng-mouseover Directive

26 Mar, 2019
The ng-mouseover Directive in AngularJS is used to apply custom behavior when an mouseover event occurs on a specific HTML element. It can be used to show popup alert when mouse moves over a specific element. It is supported by all HTML elements.
Syntax:
<element ng-mouseover="expression"> Contents... </element>
Example 1: This example uses ng-mouseover Directive to display content when mouse move over the element.
<!DOCTYPE html><html>      <head>    <title>ng-mouseover Directive</title>      <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">    </script>      <style type="text/css">        .geek {            border: 1px solid black;            width: 400px;            background-color: green;            border-radius: 4px;            height: 20px;            color: white;        }    </style></head>  <body ng-app="">    <center>        <h1 style="color:green">            GeeksforGeeks        </h1>                  <h2>ng-mouseover Directive</h2>                  <div ng-init="geek=false">                      <button ng-mouseover="geek=true"                     ng-mouseleave="geek=false">                Mouse over me!            </button>                          <br><br>                          <div class="geek" ng-show="geek">                GeeksforGeeks is the computer                 science portal for geeks.            </div>        </div>    </center></body>  </html>
Output:Before mouseover the element:After mouseover the element:
Example 2: This example uses ng-mouseover Directive to display an alert message when mouse move over element.
<!DOCTYPE html><html>      <head>    <title>ng-mouseover Directive</title>      <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">    </script></head>  <body  ng-app="app" style="text-align:center">          <h1 style="color:green">GeeksforGeeks</h1>    <h2>ng-mouseover Directive</h2>       <div ng-controller="app">        Input: <input type="text" ng-mouseover="alert()"                ng-model="click" />    </div>          <script>        var app = angular.module("app", []);        app.controller('app', ['$scope', function ($scope) {            $scope.click = 'geeksforgeeks';            $scope.alert = function () {                alert($scope.click);            }        }]);    </script></body>  </html>
Output:Before mouseover the element:After mouseover the element:
AngularJS-Directives
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
REST API (Introduction)
Node.js fs.readFileSync() Method
How to set the default value for an HTML <select> element ?
How to create footer to stay at the bottom of a Web page?
How to set input type date in dd-mm-yyyy format using HTML ?
Roadmap to Learn JavaScript For Beginners
How to markup postal address in HTML?

To markup postal address in HTML, use the <address> tag. The <address>...</address> tag is to add contact information. It can also be used to add contact information for the author of an article or document.
Just keep in mind too that each line should be followed by a <br> tag, as in address.
You can try to run the following code to add the postal address in HTML.
<!DOCTYPE html>
<html>
   <head>
      <title>HTML address tag</title>
   </head>

   <body>
      <h1>Contact us</h1>
      <address>
         52nd Street<br>
         New York,<br>
         NY 10019<br>
         USA
      </address>
   </body>
</html>
How to add an audio player to an HTML webpage?

The HTML <audio> element is used to add audio to web page. To add an audio player, add the controls attribute.
The following three audio formats are supported in HTML − MP3, Wav, and Ogg.
You can try to run the following code to add an audio player to an HTML web page
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>HTML audio Tag</title>
   </head>
   <body>
      <p>Click on Play button...</p>
      <p>(Song: Kalimba which is provided as a Sample Music in Windows)</p>
      <audio controls>
         <source src = "/html/Kalimba.mp3" type = "audio/mpeg">
      </audio>
   </body>
</html>
Img-circle Bootstrap class

Use the img-circle Bootstrap class to style your image and make it completely round.
You can try to run the following code to implement the img-circle class
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Images</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <p>Styling images with Bootstrap</p>
      <h1>Original Image</h1>
      <img src = "https://www.tutorialspoint.com/videotutorials/images/numerical_ability_home.jpg">
      <h1>Image with Rounded Corners</h1>
      <img src = "https://www.tutorialspoint.com/videotutorials/images/numerical_ability_home.jpg" class = "img-circle">
   </body>
</html>
Display all the dates for a particular month using NumPy - GeeksforGeeks

07 Sep, 2021
In NumPy to display all the dates for a particular month, we can do it with the help of NumPy.arrange() pass the first parameter the particular month and the second parameter the next month and the third parameter is the datatype datetime64[D]. It will return all the dates for the particular month.
Syntax: numpy.arrange([start, ] stop, [step, ] dtype=None)
Parameters:
start : Start of interval
stop : End of interval
Step : Spacing between values
dtype : The type of the output array. If dtype is not given, infer the data type from the other input arguments.
Returns:
arrange : ndarray
Example 1#:
Python3
import numpy as np  # dates of july  2020print(np.arrange('2012-07', '2020-08',                dtype='datetime64[D]'))
Output:
[‘2012-07-01’ ‘2012-07-02’ ‘2012-07-03’ ... ‘2020-07-29’ ‘2020-07-30’ ‘2020-07-31’]  
Example 2#:
Python3
import numpy as np # dates of september  2020print(np.arrange('2012-09', '2020-10',                dtype='datetime64[D]'))
Output:
[‘2012-09-01’ ‘2012-09-02’ ‘2012-09-03’ ... ‘2020-09-28’ ‘2020-09-29’ ‘2020-09-30’]  
Example 3#:
Python3
import numpy as np # dates of Feb  2020print(np.arrange('2012-02', '2020-03',                dtype='datetime64[D]'))
Output:
[‘2012-02-01’ ‘2012-02-02’ ‘2012-02-03’ ... ‘2020-02-27’ ‘2020-02-28’ ‘2020-02-29’]  
akshaysingh98088
Python numpy-program
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Selecting rows in pandas DataFrame based on conditions
Create a directory in Python
Python | Pandas dataframe.groupby()
How to deal with error 'height' must be a vector or a matrix while creating barplot?

The error 'height' must be a vector or a matrix while creating barplot occurs when we provide data frame name instead of column names or read it with as.matrix. If we want to create bar plot for columns in a data frame then the data frame needs to be read as matrix.
For Example, if we have a data frame called df then we can create the barplot of columns in df by using the command given below −
barplot(as.matrix(df))
Following snippet creates a sample data frame −
df<-data.frame(x=rpois(20,2),y=rpois(20,5))
df
The following dataframe is created
    x y
1  2 10
2  2 3
3  1 6
4  2 6
5  4 4
6  2 5
7  3 4
8  2 4
9  2 9
10 3 5
11 3 4
12 2 2
13 1 4
14 2 6
15 1 8
16 2 2
17 4 1
18 1 5
19 4 4
20 2 9
To create the bar plot with data frame name on the above created data frame, add the following code to the above snippet −
df<-data.frame(x=rpois(20,2),y=rpois(20,5))
barplot(df)
Error in barplot.default(df) : 'height' must be a vector or a matrix
The correct way to create the bar plot is as follows −
df<-data.frame(x=rpois(20,2),y=rpois(20,5))
barplot(as.matrix(df))
If you execute all the above given snippets as a single program, it generates the following Output −
Angular forms FormGroupDirective

02 Jun, 2021
In this article, we are going to see what is FormGroupDirective in Angular 10 and how to use it.
FormGroupDirective is used to Bind an existing FormGroup to a DOM element.
Syntax:
<form [FormGroup] ="name">
Exported from:
ReactiveFormsModule
 
Selectors:
[FormGroup]
Approach: 
Create the Angular app to be used
In app.component.ts make an object that contains a value for the input.
In app.component.html use FormGroup to get values.
Serve the angular app using ng serve to see the output.
Example 1:
app.component.ts
import { Component, Inject } from '@angular/core';  import { FormGroup, FormControl, FormArray } from '@angular/forms'  @Component({    selector: 'app-root',    templateUrl: './app.component.html',    styleUrls: [ './app.component.css' ]  })  export class AppComponent  {    form = new FormGroup({      name: new FormControl()    });      get name(): any {      return this.form.get('name');    }        onSubmit(): void {      console.log(this.form.value);     }      }
app.component.html
<br><form [formGroup]="form" (ngSubmit)="onSubmit()">  <input formControlName="name" placeholder="Name">  <br>  <button type='submit'>Submit</button>  <br>  <br></form>
Output:
Reference: https://angular.io/api/forms/FormGroupDirective
Angular10
AngularJS-Directives
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
WEEKOFYEAR() Function in MySQL

05 Oct, 2020
WEEKOFYEAR() function in MySQL is used to find the week number for a given date. If the date is NULL, the WEEKOFYEAR function will return NULL. Otherwise, it returns the value of week which ranges between 1 to 53.
Syntax :
WEEKOFYEAR( date)
Parameter :This method accepts only one parameter.
date –The date or datetime from which we want to extract the week number.
Returns :It returns the   week number.
Example-1 :Finding the Current week number Using WEEKOFYEAR() Function on 29/09/2020.
SELECT WEEKOFYEAR(NOW()) AS Current_Week;

Output :
So, the current week number is 40.
Example-2 :Finding the Week from given DateTime Using WEEKOFYEAR() Function.
SELECT WEEKOFYEAR('2018-04-22 08:09:22') 
AS Week_Number ;

Output :
So, the week number is 16 in this example.
Example-3 :Finding the Week from given date Using WEEKOFYEAR() Function.
SELECT WEEKOFYEAR('2019-07-25 ') 
AS Week_Number ;

Output :
Example-4 :Finding the Week number from given datetime Using WEEKOFYEAR() Function  when the date is NULL.
SELECT WEEKOFYEAR(NULL) 
AS Week_Number;

Output :
Example-4 :In this example, we are going to find the number of students enrolled in a course for every week in a year. To demonstrate create a table named.Course.
CREATE TABLE  Course
(
    Course_name  VARCHAR(100) NOT NULL,
    Student_id INT NOT NULL,  
    Student_name VARCHAR(100) NOT NULL,
    Enroll_Date Date NOT NULL,
    PRIMARY KEY(Student_id)
);

Now inserting some data to the Course table.
INSERT INTO
Course(Course_Name, Student_id, Student_name, Enroll_Date)
VALUES
    ( 'CS101', 161011, 'Amit Singh', '2019-10-06' ),
    ( 'CS101', 161029, 'Arun Kumar', '2019-10-23' ),
    ( 'CS101', 161031, 'Sanya Jain', '2019-11-08' ),
    ( 'CS101', 161058, 'Riya Shah', '2019-11-20' ),
    ( 'CS101', 162051, 'Amit Sharma', '2019-11-30' ),
    ( 'CS101', 161951, 'Sayan Singh', '2019-12-07' ),
    ( 'CS101', 167051, 'Rishi Jana', '2019-12-15' ),
    ( 'CS101', 168001, 'Aniket Dravid', '2019-12-25' ),
    ( 'CS101', 168051, 'Rita Singh', '2019-12-28' ),
    ( 'CS101', 166051, 'Kalyan Ghandi', '2019-12-29' ) ;

So, Our table looks like.
Now, we are going to find the number of students enrolled in the course every week.
SELECT
WEEKOFYEAR(Enroll_Date) Week_Number,
COUNT(Student_id) Student_Enrolled
FROM
    Course
    GROUP BY WEEKOFYEAR(Enroll_Date)
    ORDER BY WEEKOFYEAR(Enroll_Date);

Output :
DBMS-SQL
mysql
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL | Views
Difference between DELETE, DROP and TRUNCATE
CTE in SQL
SQL Trigger | Student Database
Difference between SQL and NoSQL
SQL using Python
Difference between DELETE and TRUNCATE
SQL | DDL, DML, TCL and DCL
SQL - ORDER BY
Window functions in SQL
XSS-Freak – XSS Scanner Fully Written in Kali Linux

14 Sep, 2021
XSS or Cross-Site Scripting is the most emerging security flaw in Web Applications. When the arbitrary or malicious JavaScript is executed by the web application then it is said to be an XSS Vulnerable Website. There are various XSS Scanners through which we can detect the XSS on the target domain. XSS-Freak is an XSS Scanner developed in the Python Language. XSS-Freak tool is an open-source and free-to-use tool also available on GitHub. XSS-Freak tool crawls the target domain for all possible links and directories to increase the chances of attack.
Note: Make Sure You have Python Installed on your System, as this is a python-based tool. Click to check the Installation process – Python Installation Steps on Linux
Once the Script is executed through Python Interpreter, the user needs to specify the list of XSS payloads that will be tested on the target domain. XSS-Freak tool then crawls the directories and links and analysis the parameters from which the payloads can be inserted and the testing process can be done. Then the XSS-Freak tool adds all the found HTML INPUTS to its attack scope then the XSS-Freak tool launches an ATTACK on all HTML INPUTS with the XSS payloads the user provided from the list. if the HTML INPUT IS NOT SANITIZED PROPERLY and Filtered The Script Will Instantly Detect It and Will Print Out The Vulnerable Parameter.
XSS-Freak tool has support for Multi-threading for Higher Efficiency and Faster Performance Processing.
XSS-Freak has the Crawling ability over complete websites.
XSS-Freak tool is Versatile.
Not supported on the phones
Requires a high-speed Internet connection
Requires advanced hardware
Step 1: Use the following command to install the tool in your Kali Linux operating system.
git clone https://github.com/AssetX/XSS-Freak.git
Step 2: Now use the following command to move into the directory of the tool. You have to move in the directory in order to run the tool.
cd XSS-Freak
Step 3: You are in the directory of the XSS-Freak. Now you have to install a dependency of the XSS-Freak using the following command.
sudo pip3 install -r requirements.txt
Step 4: All the dependencies have been installed in your Kali Linux operating system. Now use the following command to run the tool and check the help section.
python3 XSS-Freak.py -h
Example 1: We will be testing http://geeksforgeeks.org target domain
In this example, We will be testing the geeksforgeeks.org domain. We will specify the list of XSS consisting of Payloads.
As geeksforgeeks.org is Secured Website, the tool has not detected any vulnerable parameters.
Example 2: We will be testing http://testphp.vulnweb.com target domain
In this example, We will be scanning the testphp.vulnweb.com domain.
We have got one vulnerable parameter or input through which we can insert the payload.
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between Servlet and JSP

29 Jun, 2022
Brief Introduction: Servlet technology is used to create a web application. A servlet is a Java class that is used to extend the capabilities of servers that host applications accessed by means of a request-response model. Servlets are mainly used to extend the applications hosted by web services. 
JSP is used to create web applications just like Servlet technology. A JSP is a text document that contains two types of text: static data and dynamic data. The static data can be expressed in any text-based format (like HTML, XML, SVG, and WML), and the dynamic content can be expressed by JSP elements. Difference between Servlet and JSP
The difference between Servlet and JSP is as follows:
To read more about them in detail, read these articles on Servlet and JSP.
priyansh70890
siddharthredhu01
parkalevaibhav27
Java-JSP
java-servlet
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.