code-rag-bench/online-tutorials huggingface dataset:
How to use select list in selenium?

We can select an option from the dropdown list with Selenium webdriver. The Select class is used to handle static dropdown. A dropdown is identified with the <select> tag in an html code.
Let us consider the below html code for <select> tag.
We have to import org.openqa.selenium.support.ui.Select to work with methods under Select class in our code. Let us see some of the Select methods−
selectByVisibleText(arg) – An option is selected if the text visible on the dropdown is the same as the parameter arg passed as an argument to the method.Syntaxsel = Select (driver.findElement(By.id ("option")));sel.selectByVisibleText ("Selenium");
selectByVisibleText(arg) – An option is selected if the text visible on the dropdown is the same as the parameter arg passed as an argument to the method.
sel = Select (driver.findElement(By.id ("option")));
sel.selectByVisibleText ("Selenium");
selectByValue(arg) – An option is selected if the value on the dropdown which is the same as the parameter arg passed as an argument to the method.Syntaxsel = Select (driver.findElement(By.id("option")));sel.selectByValue ("val");
selectByValue(arg) – An option is selected if the value on the dropdown which is the same as the parameter arg passed as an argument to the method.
sel = Select (driver.findElement(By.id("option")));
sel.selectByValue ("val");
selectByIndex(arg) – An option is selected if the index on the dropdown which is the same as the parameter arg passed as an argument to the method. The index starts from 0.Syntaxsel = Select (driver.findElement(By.id("option")));sel.selectByIndex(3);
selectByIndex(arg) – An option is selected if the index on the dropdown which is the same as the parameter arg passed as an argument to the method. The index starts from 0.
sel = Select (driver.findElement(By.id("option")));
sel.selectByIndex(3);
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.support.ui.Select

public class SelectItem{
   public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      String url ="https://www.tutorialspoint.com/selenium/selenium_automation_practice.htm"
      driver.get(url);
      driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS);
      // identify element
      WebElement p=driver.findElement(By.xpath("//[@name='continents']"));
      //Select class
      Select sel= new Select(p);
      // select with text visible
      sel.selectByVisibleText("Africa");
      // select with index
      sel.selectByIndex(5);
      driver.quit();
   }
}
Granting _SYS_REPO with SELECT to user schema in SAP HANA

In SAP HANA system _SYS_REPO user is required to create run time objects that are saved in HANA database under _SYS_BIC schema. When you activate modeling views in HANA, SYS REPO provides the read access to users on these modeling views. That is why it is required to grant _SYS_REPO with SELECT with GRANT privilege to user schemas.
GRANT SELECT ON SCHEMA "SCHEMA_NAME" TO _SYS_REPO WITH GRANT OPTION
This is required when you use objects of a table/view of a schema to build HANA Modeling Views. You need to grant _SYS_REPO the SELECT WITH GRANT privilege on this schema.
Use of :even and :odd pseudo-classes with list items in CSS

16 Dec, 2021
The:nth-child() selector in CSS is used to match the elements based on their position in a group of siblings. It matches every element that is the nth-child. The: even and: odd pseudo-class is used with the list of items such as paragraph, article items which is basically a list content. 
odd: The use of odd pseudo-class in any list item that will affect only the odd index number list. Syntax:
li:nth-child( odd ) {
    // CSS Property   
}
Example:
HTML
<!DOCTYPE html><html>     <head>    <title>        CSS :nth-child(odd) Selector    </title>         <!-- Style to uses :nth-child(odd)            Selector -->    <style>        li:nth-child(odd) {            background: green;            font-size: 24px;            color:white;        }    </style></head> <body>    <li>GeeksforGeeks</li>    <li>A Computer Science portal</li>    <li>Welcome to GeeksforGeeks</li></body> </html>                               
Output:  
even: The use of even pseudo-class in any list item that will effect only the even index number list. Syntax:
li:nth-child( even ) {
    // CSS Property
}
Example:
HTML
<!DOCTYPE html><html>     <head>    <title>        CSS :nth-child(even) Selector    </title>         <!-- Style to uses :nth-child(odd)            Selector -->    <style>        li:nth-child(even) {            background: green;            font-size: 24px;            color:white;        }    </style></head> <body>    <li>GeeksforGeeks</li>    <li>A Computer Science portal</li>    <li>Welcome to GeeksforGeeks</li></body> </html>                                  
Output:  
Example: This example uses both :even and :odd pseudo-class selector.
HTML
<!DOCTYPE html><html>     <head>         <style>        li:nth-child(odd) {            background: green;            font-size: 36px;            color:white;        }        li:nth-child(even) {            background: Blue;            font-size: 36px;            color:yellow;        }    </style></head> <body>    <h1>GeeksforGeeks</h1>         <h2>:even and :odd pseudo-class</h2>         <li>Data Structure</li>    <li>Operating System</li>    <li>Computer Networks</li>    <li>C Programming</li></body> </html>                   
Output:
Supported Browsers:
Google Chrome 4.0
Internet Explorer 9.0
Firefox 3.5
Opera 9.6
Safari 3.2
ysachin2314
sagar0719kumar
CSS-Selectors
Picked
CSS
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a Tribute Page using HTML & CSS
How to set space between the flexbox ?
Build a Survey Form using HTML and CSS
Create a Responsive Navbar using ReactJS
How to auto-resize an image to fit a div container using CSS?
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
PyQt5 QListWidget – Setting Selection Mode

06 Aug, 2020
In this article we will see how we can set the selection mode property to the QListWidget. QListWidget is a convenience class that provides a list view with a classic item-based interface for adding and removing items. QListWidget uses an internal model to manage each QListWidgetItem in the list. This property holds which selection mode the view operates in. This property controls whether the user can select one or many items and, in many-item selections, whether the selection must be a continuous range of items.
In order to do this we will use setSelectionMode method with the list widget object.
Syntax : list_widget.setSelectionMode(mode)
Argument : It takes selection mode object as argument
Return : It returns None
Below is the implementation
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 500, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()          # method for components    def UiComponents(self):          # creating a QListWidget        list_widget = QListWidget(self)          # setting geometry to it        list_widget.setGeometry(50, 70, 150, 60)          # list widget items        item1 = QListWidgetItem("A")        item2 = QListWidgetItem("B")        item3 = QListWidgetItem("C")          # adding items to the list widget        list_widget.addItem(item1)        list_widget.addItem(item2)        list_widget.addItem(item3)          # setting selection mode property        list_widget.setSelectionMode(QAbstractItemView.MultiSelection)          # creating a label        label = QLabel("GeesforGeeks", self)          # setting geometry to the label        label.setGeometry(230, 80, 280, 80)          # making label multi line        label.setWordWrap(True)      # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python PyQt-QListWidget
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Method Chaining in JavaScript

31 Mar, 2021
As a good programming practice, we should write individual functions/methods for dealing with individual actions. And, writing only one method/function for all actions is a thing. However, sticking to good practice takes a toll on the readability and comprehensibility of the code, because defining a separate function for each action means that the output of a single function/method is input. This makes code comprehensibility even worse, as the function needs to be nested in reverse order. This is where method chaining comes to the rescue.
Method Chaining is a programming strategy that simplifies and embellishes your code. It is a mechanism of calling a method on another method of the same object.
this keyword in JavaScript refers to the current object in which it is called. Thus, when a method returns this, it simply returns an instance of the object in which it is returned. Since the returned value is an instance of an object, it is, therefore, possible to call another method of an object to the returned value, which is its instance. And this makes method chaining possible in JavaScript.
Example: In this example, each method in Land.prototype returns this, which refers to the entire instance of that Land object. And this would help in calling a method on another method of the same object.
Javascript
//creating a function Land()function Land() {this.area = '';this.status = 'for Sale';}//Setting status open for saleLand.prototype.open = function() {this.status = 'Open for Sale';return this;}//Setting status not for saleLand.prototype.close = function() {this.status = 'Not for Sale';return this;}//Setting ParametersLand.prototype.setParams = function(area) {this.area = area;return this;}//printing land statusLand.prototype.doorStatus = function() {console.log('The',this.area,'Land is',this.status);return this;}//creating a land objectvar land = new Land();land.setParams("500 sq ft").close().doorStatus().open().doorStatus();
Output:
The 500 sq ft Land is Not for Sale
The 500 sq ft Land is Open for Sale
Land { area: ‘500 sq ft’, status: ‘Open for Sale’ }
JavaScript-Questions
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stored Procedures classification based on Input and Output Parameters in SQL Server

18 Aug, 2021
Stored Procedure:
The stored procedure has the following key points as follows.
It is a collection of SQL statements such as if you want to write and read data from a database then you can use create a statement for write and select statement for reading the data from database and SQL command logic for the same, which is compiled and stored on the database.A stored procedure is a group of T-SQL (Transact SQL) statements.If you have a situation, where you can write the same query over and over again, you can save that specific query as a stored procedure and call it just by its name.
It is a collection of SQL statements such as if you want to write and read data from a database then you can use create a statement for write and select statement for reading the data from database and SQL command logic for the same, which is compiled and stored on the database.
A stored procedure is a group of T-SQL (Transact SQL) statements.
If you have a situation, where you can write the same query over and over again, you can save that specific query as a stored procedure and call it just by its name.
Classification of Stored Procedure
Create Stored Procedure without Parameter :
 You can use the following stored procedure given below to create the stored procedure without a parameter.
create procedure sp_get_empno
as  
begin  
select * from emp where ename='WARD'  
end
exec sp_get_empno
Create a Stored Procedure with Output Parameter :
 You can use the following stored procedure given below to create the stored procedure with an output parameter.
declare @empId int
exec GetEmployeeID (@empId int out)
create procedure sp_get_empid(@name varchar(10) out)
as  
begin  
select id from emp where ename="Sam"
end
exec sp_get_empid @empID
Create a Stored Procedure with Input Parameter :
 You can use the following stored procedure given below to create the stored procedure with an Input parameter.
USE Db1
GO
CREATE PROCEDURE dbo.GetEmployeeID(@Email varchar(30))
AS
SELECT *  FROM employeeDetails WHERE email= @Email
GO
Create a Stored Procedure with both input and Output Parameter :
 You can use the following stored procedure given below to create the stored procedure with both an input and output parameter.
create procedure sp_get_empname(@name varchar(10) out, @id int)
as
begin
select ename from emp where empno=@id
end
declare @en varchar(10)
exec sp_get_empname @en,7521
print @en
simranarora5sos
DBMS-SQL
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Sub queries in From Clause
Window functions in SQL
What is Temporary Table in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL using Python
SQL Query to Convert VARCHAR to INT
RANK() Function in SQL Server
How to Import JSON Data into SQL Server?
SQL Query to Compare Two Dates
MongoDB SELECT COUNT GROUP BY?

You can achieve this with the help of an aggregate framework. To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −
> db.countGroupByDemo.insertOne({"StudentId":10,"StudentName":"John"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c7700871e9c5dd6f1f78296")
}
> db.countGroupByDemo.insertOne({"StudentId":10,"StudentName":"Carol"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c77008f1e9c5dd6f1f78297")
}
> db.countGroupByDemo.insertOne({"StudentId":20,"StudentName":"Sam"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c7700971e9c5dd6f1f78298")
}
> db.countGroupByDemo.insertOne({"StudentId":30,"StudentName":"Mike"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c7700a21e9c5dd6f1f78299")
}
> db.countGroupByDemo.insertOne({"StudentId":30,"StudentName":"David"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c7700aa1e9c5dd6f1f7829a")
}
> db.countGroupByDemo.insertOne({"StudentId":10,"StudentName":"Maxwell"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c7700b41e9c5dd6f1f7829b")
}
> db.countGroupByDemo.insertOne({"StudentId":20,"StudentName":"Bob"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c7700bd1e9c5dd6f1f7829c")
}
Display all documents from a collection with the help of find() method. The query is as follows −
> db.countGroupByDemo.find().pretty();
{
   "_id" : ObjectId("5c7700871e9c5dd6f1f78296"),
   "StudentId" : 10,
   "StudentName" : "John"
}
{
   "_id" : ObjectId("5c77008f1e9c5dd6f1f78297"),
   "StudentId" : 10,
   "StudentName" : "Carol"
}
{
   "_id" : ObjectId("5c7700971e9c5dd6f1f78298"),
   "StudentId" : 20,
   "StudentName" : "Sam"
}
{
   "_id" : ObjectId("5c7700a21e9c5dd6f1f78299"),
   "StudentId" : 30,
   "StudentName" : "Mike"
}
{
   "_id" : ObjectId("5c7700aa1e9c5dd6f1f7829a"),
   "StudentId" : 30,
   "StudentName" : "David"
}
{
   "_id" : ObjectId("5c7700b41e9c5dd6f1f7829b"),
   "StudentId" : 10,
   "StudentName" : "Maxwell"
}
{
   "_id" : ObjectId("5c7700bd1e9c5dd6f1f7829c"),
   "StudentId" : 20,
   "StudentName" : "Bob"
}
Here is the query to select count group by −
> db.countGroupByDemo.aggregate([
... {"$group":{_id:"$StudentId",counter:{$sum:1}}}]);
{ "_id" : 30, "counter" : 2 }
{ "_id" : 20, "counter" : 2 }
{ "_id" : 10, "counter" : 3 }
Restricting MySQL Connections to Secure Transport

MySQL will make secure connections easier when it has streamlined key generation for both MySQL Community and MySQL Enterprise. This way, the security is improved by expanding support for TLSv1.1 and TLSv1.2. This also helps administrators determine if clients are connecting securely or not with enhanced visibility into connection types.
Extending this importance on secure connections, MySQL server introduced a new server-side configuration option that allows MySQL administrators to restrict connections to clients who use secure transport. When we say about the connection needing secure transport, the first question that needs to be addressed is the kind of transport it uses.
Let us see the kinds of transport that are considered secure −
SSL/TLS
SSL/TLS
Socket
Socket
Shared Memory
Shared Memory
In particular, connections on Windows machines that use the named pipe transport are not considered to be secure. These connections are usually made locally, and named pipe connections can be made remotely. But they also lack data encryption that would protect payloads which are sent over the wire.
The - -require_secure_transport configuration option was newly added. Here, the boolean option default is OFF. This means that connections that use any of the above mentioned supported
protocols are accepted, if they are consistent with legacy behaviour. Setting -- require_secure_transport=ON makes the server reject new connections which don’t use one of the connection types shown above.
Clients that are rejected due to insecure connections would receive the below mentioned error −
D:\mysql-advanced-5.7.10-winx64>bin\mysql -uroot -P3310 --skip-ssl
ERROR 3159 (HY000): Connections using insecure transport are prohibited while
--require_secure_transport=ON.
D:\mysql-advanced-5.7.10-winx64>bin\mysql -uroot -P3310 --skip-ssl
ERROR 3159 (HY000): Connections using insecure transport are prohibited while
--require_secure_transport=ON.
MySQL also supports requiring TLS for specific accounts. This is done by including the REQUIRE SSL clause in CREATE or ALTER USER commands. The new --require_secure_transport option will add these account-level requirements by enforcing secure transport at a global level.
Minimum operations required to make all the array elements equal in C++

Given an array with n positive integers. We need to find the minimum number of operation to make all elements equal. We can perform addition, multiplication, subtraction or division with any element on an array element.
If input array is = {1, 2, 3, 4} then we require minimum 3 operations to make all elements equal. For example, we can make elements 4 by doing 3 additions.
1. Select element with maximum frequency. Let us call it ‘x’ 
2. Now we have to perform n-x operations as there are x element with same value
 Live Demo
#include <bits/stdc++.h>
using namespace std;
int getMinOperations(int *arr, int n) {
   unordered_map<int, int> hash;
   for (int i = 0;i < n; ++i) {
      hash[arr[i]]++;
   }
int maxFrequency = 0;
   for (auto elem : hash) {
      if (elem.second > maxFrequency) {
         maxFrequency = elem.second;
      }
   }
   return (n - maxFrequency);
}
int main() {
   int arr[] = {1, 2, 3, 4};
   int n = sizeof(arr) / sizeof(arr[0]);
   cout << "Minimum required operations = " <<
   getMinOperations(arr, n) << endl;
   return 0;
}
When you compile and execute above program. It generates following output:
Minimum required operations = 3
How to Make a DIV 100% of the Window Height using CSS

The CSS height property helps us specify the height of an element.
The syntax of CSS height property is as follows −
Selector {
   height: /*value*/
}
The following examples illustrate CSS height property.
 Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Page Title</title>
      <style>
         html, body {
            margin: 0px;
            height: 100vh;
         }
         div {
            height: 100%;
            text-align: center;
            background: mistyrose;
         }
      </style>
   </head>
   <body>
      <div>100% height!!</div>
   </body>
</html>
This gives the following output
 Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Page Title</title>
      <style>
         html, body {
            display: flex;
            flex-direction: row;
            justify-content: space-around;
            margin: 0px;
            height: 100vh;
            box-shadow: inset 0 0 40px lightblue;
         }
         div {
            width: 40%;
            height: 100vh;
            text-align: center;
            box-shadow: inset 0 0 20px lightcoral;
         }
      </style>
   </head>
   <body>
      <div>Watch This!</div>
      <div>Let Me Show You How The Boss Does It!!</div>
      <div>Open Up The Sky!!</div>
      <div>GO! GO! GO!!</div>
   </body>
</html>
This gives the following output
8085 program to add three 16 bit numbers stored in registers - GeeksforGeeks

22 May, 2018
Problem – Write an assembly language program to add three 16 bit numbers stored in register HL, DE, BC and store the result in DE with minimum number of instructions.
Example –
Assumptions –
Numbers to be added are already stored in register HL, DE, BCNumbers stored in register are such that final result should not be greater than FFFF
Numbers to be added are already stored in register HL, DE, BC
Numbers stored in register are such that final result should not be greater than FFFF
DAD D performs the following task:
  H <- H + D 
  L <- L + E 
DAD instruction take one argument and that argument can be register B, D, H or SP XCHG instruction exchanges the content of register D with H and E with L
Algorithm –
Add the content of DE register in HL and store the result in HL by help of DAD instructionMove the content of register B in D and C in ERepeat step 1Use XCHG instruction to swap the content of DE with HL. We will get the result in DE
Add the content of DE register in HL and store the result in HL by help of DAD instruction
Move the content of register B in D and C in E
Repeat step 1
Use XCHG instruction to swap the content of DE with HL. We will get the result in DE
Program –
Explanation –
DAD D – adds the content of register D in H and register E in L and store the result in HLMOV D, B – moves the value of register B in register DMOV E, C moves the value of register C in register ESame as step 1XCHG – exchange the content of register H with register D and L with E.HLT – stops executing the program and halts any further execution
DAD D – adds the content of register D in H and register E in L and store the result in HL
MOV D, B – moves the value of register B in register D
MOV E, C moves the value of register C in register E
Same as step 1
XCHG – exchange the content of register H with register D and L with E.
HLT – stops executing the program and halts any further execution
microprocessor
system-programming
Computer Organization & Architecture
microprocessor
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Addressing modes in 8085 microprocessor
Logical and Physical Address in Operating System
Architecture of 8085 microprocessor
Computer Organization and Architecture | Pipelining | Set 1 (Execution, Stages and Throughput)
Memory Hierarchy Design and its Characteristics
Architecture of 8086
I/O Interface (Interrupt and DMA Mode)
Computer Organization | RISC and CISC
Computer Organization | Booth's Algorithm
Flag register in 8085 microprocessor
The extern storage class in C++

The extern storage class specifier lets you declare objects that several source files can use. An extern declaration makes the described variable usable by the succeeding part of the current source file. This declaration does not replace the definition. The declaration is used to describe the variable that is externally defined.
An extern declaration can appear outside a function or at the beginning of a block. If the declaration describes a function or appears outside of a function and describes an object with external linkage, the keyword extern is optional.
If a declaration for an identifier already exists at file scope, any extern declaration of the same identifier found within a block refers to that same object. If no other declaration for the identifier exists at file scope, the identifier has external linkage.
C++ restricts the use of the extern storage class specifier to the names of objects or functions. Using the extern specifier with type declarations is illegal. An extern declaration cannot appear in class scope.
You can use the extern keyword as follows to share the variable across files −
file3.h
extern int global_variable;  /* Declaration of the variable */
file1.c
#include "file3.h"  /* Declaration made available here */
#include "prog1.h"  /* Function declarations */
/* Variable defined here */
int global_variable = 37;    /* Definition checked against declaration */

int increment(void) {
   return global_variable++;
}
file2.c
#include "file3.h"
#include "prog1.h"
#include <stdio.h>

void use_it(void)
{
   printf("Global variable: %d\n", global_variable++);
}
The following question at stackoverflow completely captures the essence of the extern keyword: https://stackoverflow.com/questions/1433204/how-do-i-use-extern-to-share-variables-between-source-files.
How to add rows in an R data frame?

To add rows in an R data frame, we can follow the below steps −
First of all, create a data frame.
First of all, create a data frame.
Then, use rbind function and the vectors that will be added as rows to the data frame.
Then, use rbind function and the vectors that will be added as rows to the data frame.
Let’s create a data frame as shown below −
x<-rpois(25,5)
y<-rpois(25,2)
df<-data.frame(x,y)
df
On executing, the above script generates the below output(this output will vary on your system due to randomization) −
    x y
1   9 3
2   4 1
3   5 0
4   8 1
5   5 2
6   6 3
7   7 2
8   3 4
9   5 1
10  2 2
11  5 2
12  2 2
13  8 2
14 12 4
15  7 4
16  3 2
17  4 0
18  8 2
19  6 1
20  2 4
21  3 1
22  4 1
23  4 1
24  4 3
25  2 2
Add rows in the data frame
Using rbind function and the vectors to add rows in the data frame as shown below −
x<-rpois(25,5)
y<-rpois(25,2)
df<-data.frame(x,y)
df<-rbind(df,c(5,5),c(2,1),c(0,1),c(5,4),c(3,6))
df
    x y
1   9 3
2   4 1
3   5 0
4   8 1
5   5 2
6   6 3
7   7 2
8   3 4
9   5 1
10  2 2
11  5 2
12  2 2
13  8 2
14 12 4
15  7 4
16  3 2
17  4 0
18  8 2
19  6 1
20  2 4
21  3 1
22  4 1
23  4 1
24  4 3
25  2 2
26  5 5
27  2 1
28  0 1
29  5 4
30  3 6
How to use typeof with arguments in JavaScript?

Arguments object is the arguments passed to a function. It is a variable accessible for all functions. Let’s say two arguments are passed to a function, then you can access them like the following:
arguments[0]
arguments[1]
In the same way, you can use a type of with arguments in JavaScript. Firstly, let’s see how to work with the type of. The type of operator is a unary operator that is placed before its single operand, which can be of any type. 
The following code shows how to implement type of operator
Live Demo
<html>
   <body>
      <script>
         var a = 20;
         var b = "String";
         var linebreak = "<br />";

         result = (typeof b == "string" ? "B is String" : "B is Numeric");
         document.write("Result => ");
         document.write(result);
         document.write(linebreak);

         result = (typeof a == "string" ? "A is String" : "A is Numeric");
         document.write("Result => ");
         document.write(result);
         document.write(linebreak);
      </script>
   </body>
</html>
Let us now see how to use typeof with arguments in JavaScript. The typeof arguments will return an object like this:
document.write(typeof arguments);
Let’s say you have two arguments, then with typeof, you can refer them like the following, which will return the typeof arguments.
document.write(typeof arguments[0]);
document.write(typeof arguments[1]);
How to compare two arrays in C#?

Firstly, set the two arrays to be compared −
// two arrays
int[] arr = new int[] { 99, 87, 56, 45};
int[] brr = new int[] { 99, 87, 56, 45 };
Now, use SequenceEqual() to compare the two arrays −
arr.SequenceEqual(brr);
The following is the code to compare two arrays −
using System;
using System.Linq;

namespace Demo {
   class Program {

      static void Main(string[] args) {

         // two arrays
         int[] arr = new int[] { 99, 87, 56, 45};
         int[] brr = new int[] { 99, 87, 56, 45 };

         // compare
         Console.WriteLine(arr.SequenceEqual(brr));
      }
   }
}
java.time.LocalDate.minusMonths() Method Example

The java.time.LocalDate.minusMonths(long monthsToSubtract) method returns a copy of this date with the specified months subtracted.
Following is the declaration for java.time.LocalDate.minusMonths(long monthsToSubtract) method.
public LocalDate minusMonths(long monthsToSubtract)

monthsToSubtract − the months to subtract, may be negative.
a LocalDate based on this date with the months subtracted, not null.
DateTimeException − if the result exceeds the supported date range.
The following example shows the usage of java.time.LocalDate.minusMonths(long monthsToSubtract) method.
package com.tutorialspoint;

import java.time.LocalDate;

public class LocalDateDemo {
   public static void main(String[] args) {
	  
      LocalDate date = LocalDate.parse("2017-02-03");
      System.out.println(date.minusMonths(2));  
   }
}
Let us compile and run the above program, this will produce the following result −
2016-12-03

 Print
 Add Notes
 Bookmark this page
Async/Await Function in JavaScript - GeeksforGeeks

02 Dec, 2021
We all know that Javascript is a Synchronous which means that it has an event loop that allows you to queue up an action that won’t take place until the loop is available sometime after the code that queued the action has finished executing. But there’s a lot of functionalities in our program which makes our code Asynchronous. One of them is the Async/Await functionality.
Async/Await is the extension of promises which we get as a support in the language. You can refer Promises in Javascript to know more about it.
Async:It simply allows us to write promises based code as if it was synchronous and it checks that we are not breaking the execution thread. It operates asynchronously via the event-loop. Async functions will always return a value. It makes sure that a promise is returned and if it is not returned then javascript automatically wraps it in a promise which is resolved with its value.
Examples:
const getData = async() => {    var data = "Hello World";    return data;}  getData().then(data => console.log(data));
Output:
Hello World

Await:Await function is used to wait for the promise. It could be used within the async block only. It makes the code wait until the promise returns a result. It only makes the async block wait.
const getData = async() => {    var y = await "Hello World";    console.log(y);}  console.log(1);getData();console.log(2);
Output:
1
2
Hello World

Notice that the console prints 2 before the “Hello World”. This is due to the usage of the await keyword.
Supported Browsers: The browsers supported by Async/Await Function are listed below:
Google Chrome 55 and above
Firefox 52 and above
Apple Safari 10.1 and above
Opera 42 and above
Edge 14 and above
JavaScript is best known for web page development but it is also used in a variety of non-browser environments. You can learn JavaScript from the ground up by following this JavaScript Tutorial and JavaScript Examples.
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
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
How to Open URL in New Tab using JavaScript ?
Top 10 Front End Developer Skills That You Need 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?
How to predict an image using CNN with Keras? | by Anh T. Dang | Towards Data Science

There are the following six steps to determine what object does the image contains?
Load an image.
Resize it to a predefined size such as 224 x 224 pixels.
Scale the value of the pixels to the range [0, 255].
Select a pre-trained model.
Run the pre-trained model.
Display the results.
Install TensorFlow and Keras.
pip install tensorflow
First of all, we set up the environment.
# TensorFlow and tf.kerasimport tensorflow as tffrom tensorflow.keras.applications.resnet50 import preprocess_input, decode_predictionsfrom tensorflow.keras.preprocessing import image# Helper librariesimport numpy as npimport matplotlib.pyplot as plprint(tf.__version__)
Then, we load and try to display the image that we want to predict.
img_path = "./samples/dog_1100x628.jpg"plt.imshow(img)plt.show()
It shows a vizsla dog, so how our model predict this image?
Keep in mind that before feeding any image to Keras, we need to convert it to a standard format since pre-trained models expect the input to be of a specific size. In this case, we need to resize our images to 224 x 224 pixels.
img = image.load_img(img_path, target_size=(224, 224))
The second is most deep learning models expect a batch of images as input. In this case, we create a batch of one image.
img_array = image.img_to_array(img)img_batch = np.expand_dims(img_array, axis=0)
The third is models perform well when they are fed with data within a consistent range. In this case, the image pixel values are range from 0 to 255. So, if we run the preprocess_input() function from Keras on input images will normalize each pixel to a standard range.
img_preprocessed = preprocess_input(img_batch)
Here, we will use a CNN network called ResNet-50.
model = tf.keras.applications.resnet50.ResNet50()
prediction = model.predict(img_preprocessed)
Keras also provides the decode_predictions function which tells us the probability of each category of objects contained in the image.
print(decode_predictions(prediction, top=3)[0])
Here is the output while running this program.
[(‘n02099601’, ‘golden_retriever’, 0.75317645), (‘n02100583’, ‘vizsla’, 0.061531797), (‘n02099267’, ‘flat-coated_retriever’, 0.04048888)]
The predicted categories for this image are various types of dog.
Full source code for the finished.
How can we see MySQL temporary tables in the list of tables?

As we know that we can see the list of tables in a database with the help of SHOW TABLES statement. But MySQL temporary tables are not stored in this list or in other words we can say that we cannot see the temporary tables with the help of SHOW TABLES statement. To illustrate it we are using the following example −
In this example, we are trying to get the temporary table named ‘SalesSummary’ from SHOW TABLES statement as follows −
mysql> SHOW TABLES LIKE '%Sales%';
Empty set (0.00 sec)

mysql> SHOW TABLES LIKE '%SalesSummary%';
Empty set (0.00 sec)
The above query shows the empty result set means that the temporary table ‘SalesSummary’ is not in the table list of database.
Tryit Editor v3.7

HTML Input types
Tryit: HTML input password
strnset() function in C

26 Sep, 2018
The strnset() function is a builtin function in C and it sets the first n characters of a string to a given character. If n is greater than the length of string, the length of string is used in place of n.
Syntax:
char *strnset(const char *str, char ch, int n);

Parameters:
str: This is the original string in which some character are replaced by a given character.
ch: ch represents the given character.
n: n represents the number of character which is replaced by the given character.
Return Value: It returns the modified string obtained after replacing the first  characters of the given string str.
Below programs illustrate the strnset() function in C:
Program 1:
// C program to illustrate // the strnset() function  #include <stdio.h>#include <string.h>  int main(){    char str[] = "GeeksforGeeks";          printf("Original String: %s\n", str);          // First 5 character of string str    // replaced by character '*'    printf("Modified String: %s\n", strnset(str, '*', 5));          return 0;}
Output:
Original String: GeeksforGeeks
Modified String: *****forGeeks

Program 2:
// C program to illustrate // the strnset() function  #include <stdio.h>#include <string.h>  int main(){    char str[] = "Computer Science";          printf("Original String: %s\n", str);          // First 5 character of string str    // replaced by character '*'    printf("Modified String: %s\n", strnset(str, '*', 5));          return 0;}
Output:
Original String: Computer Science
Modified String: *****ter Science

Note: The strnset() function is not a part of the standard C library and thus might not run on the online compilers.
C-Functions
C-String
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Unordered Sets in C++ Standard Template Library
What is the purpose of a function prototype?
Operators in C / C++
Exception Handling in C++
TCP Server-Client implementation in C
Smart Pointers in C++ and How to Use Them
'this' pointer in C++
Ways to copy a vector in C++
Understanding "extern" keyword in C
Storage Classes in C
Joining two Pandas DataFrames using merge()

17 Aug, 2020
Let us see how to join two Pandas DataFrames using the merge() function.
Syntax : DataFrame.merge(parameters)
Parameters :
right : DataFrame or named Series
how : {‘left’, ‘right’, ‘outer’, ‘inner’}, default ‘inner’
on : label or list
left_on : label or list, or array-like
right_on : label or list, or array-like
left_index : bool, default False
right_index : bool, default False
sort : bool, default False
suffixes : tuple of (str, str), default (‘_x’, ‘_y’)
copy : bool, default True
indicator : bool or str, default False
validate : str, optional
Returns : A DataFrame of the two merged objects.
Example 1 : Merging two Dataframe with same number of elements :
# importing the moduleimport pandas as pd  # creating the first DataFramedf1 = pd.DataFrame({"fruit" : ["apple", "banana", "avocado"],                    "market_price" : [21, 14, 35]})display("The first DataFrame")display(df1)  # creating the second DataFramedf2 = pd.DataFrame({"fruit" : ["banana", "apple", "avocado"],                    "wholesaler_price" : [65, 68, 75]})display("The second DataFrame")display(df2)  # joining the DataFramesdisplay("The merged DataFrame")pd.merge(df1, df2, on = "fruit", how = "inner")
Output :
Example 2 : Merging two Dataframe with different number of elements :
# importing the moduleimport pandas as pd  # creating the first DataFramedf1 = pd.DataFrame({"fruit" : ["apple", "banana",                                "avocado", "grape"],                    "market_price" : [21, 14, 35, 38]})display("The first DataFrame")display(df1)  # creating the second DataFramedf2 = pd.DataFrame({"fruit" : ["apple", "banana", "grape"],                    "wholesaler_price" : [65, 68, 71]})display("The second DataFrame")display(df2)  # joining the DataFrames# here both common DataFrame elements are in df1 and df2, # so it extracts apple, banana, grapes from df1 and df2.  display("The merged DataFrame")pd.merge(df1, df2, on = "fruit", how = "inner")
Output :
If we use how = "Outer", it returns all elements in df1 and df2 but if element column are null then its return NaN value.
pd.merge(df1, df2, on = "fruit", how = "outer")
Output :
If we use how = "left", it returns all the elements that present in the left DataFrame.
pd.merge(df1, df2, on = "fruit", how = "left")
Output :
If we use how = "right", it returns all the elements that present in the right DataFrame.
pd.merge(df1, df2, on = "fruit", how = "right")
Output :
pandas-dataframe-program
Python pandas-dataFrame
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list
Count distinct elements in an array in Python

In a list in Python we may have duplicate elements. When we count the length of the list we get the total length including the duplicate elements. But in this article we will see how to get the total count of the distinct elements or unique elements in a list.
In the below example we use the counter() from the collections module. In this module a Counter is a dict subclass for counting hashable objects. Counter is an unordered collection where elements are stored as dictionary keys and their counts are stored as dictionary values. So from the original list we create another list made up of only the elements whose key values are present once. This is a distinct list of elements. And then we find the length of this new list.
from collections import Counter
list = ['Mon', 'Tue', 'Wed', 'Mon','Tue']
print("Length of original list",len(list))

distinct_list= (Counter(list).keys())
print("List with distinct elements:\n",distinct_list)
print("Length of distinct list:",len(distinct_list))
Running the above code gives us the following result −
Length of original list 5
List with distinct elements:
   dict_keys(['Mon', 'Tue', 'Wed'])
Length of distinct list: 3
How to apply functions in a Group in a Pandas DataFrame?

03 Jan, 2021
In this article, let’s see how to apply functions in a group in a Pandas Dataframe. Steps to be followed for performing this task are – 
Import the necessary libraries.
Set up the data as a Pandas DataFrame.
Use apply function to find different statistical measures like Rolling Mean, Average, Sum, Maximum, and Minimum. You can use the lambda function for this.
Below is the implementation-
Let’s create the dataframe.
Python3
#import librariesimport pandas as pd  # set up the datadata_dict = {"Student House": ["Lavender", "Lavender", "Lavender",                               "Lavender", "Daisy", "Daisy",                                "Daisy", "Daisy", "Daffodils",                                "Daffodils", "Daffodils", "Daffodils"],                            "Points": [10, 4, 6, 7, 3, 8, 9, 10, 4, 5, 6, 7]}  data_df = pd.DataFrame(data_dict)print("Dataframe : ")data_df
Output:
Example 1:
Python3
# finding rolling meanrolling_mean = data_df.groupby("Student House")["Points"].apply(    lambda x: x.rolling(center=False, window=2).mean())  print("Rolling Mean:")print(rolling_mean)
Output:
Example 2:
Python3
# finding meanmean = data_df.groupby("Student House")["Points"].apply(  lambda x: x.mean())  print("Mean:")print(mean)
Output:
Example 3:
Python3
# finding sumsum = data_df.groupby("Student House")["Points"].apply(  lambda x: x.sum())  print("Sum:")print(sum)
Output:
Picked
Python pandas-groupby
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
Return all dates between two dates in an array in PHP

21 Nov, 2018
Given two dates (start date and end date) and the task is to return all the dates in an array.
Example 1: In this example, use date interval class which stores fixed amount of time (in years, months, days, hours etc) or relative time string in the format that DateTime.
<?php  // Function to get all the dates in given rangefunction getDatesFromRange($start, $end, $format = 'Y-m-d') {          // Declare an empty array    $array = array();          // Variable that store the date interval    // of period 1 day    $interval = new DateInterval('P1D');      $realEnd = new DateTime($end);    $realEnd->add($interval);      $period = new DatePeriod(new DateTime($start), $interval, $realEnd);      // Use loop to store date into array    foreach($period as $date) {                         $array[] = $date->format($format);     }      // Return the array elements    return $array;}  // Function call with passing the start date and end date$Date = getDatesFromRange('2010-10-01', '2010-10-05');  var_dump($Date);  ?>
array(5) {
  [0]=>
  string(10) "2010-10-01"
  [1]=>
  string(10) "2010-10-02"
  [2]=>
  string(10) "2010-10-03"
  [3]=>
  string(10) "2010-10-04"
  [4]=>
  string(10) "2010-10-05"
}

Example 2: This example use strtotime() function which is used to convert an English textual date-time description to a UNIX timestamp. It returns a timestamp on success, False otherwise.
<?php  // Declare two dates$Date1 = '01-10-2010';$Date2 = '05-10-2010';  // Declare an empty array$array = array();  // Use strtotime function$Variable1 = strtotime($Date1);$Variable2 = strtotime($Date2);  // Use for loop to store dates into array// 86400 sec = 24 hrs = 60*60*24 = 1 dayfor ($currentDate = $Variable1; $currentDate <= $Variable2;                                 $currentDate += (86400)) {                                      $Store = date('Y-m-d', $currentDate);$array[] = $Store;}  // Display the dates in array formatprint_r($array);?>
Array
(
    [0] => 2010-10-01
    [1] => 2010-10-02
    [2] => 2010-10-03
    [3] => 2010-10-04
    [4] => 2010-10-05
)

PHP-date-time
Picked
PHP
PHP Programs
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to execute PHP code using command line ?
How to Insert Form Data into Database using PHP ?
PHP in_array() Function
How to delete an array element based on key in PHP?
How to convert array to string in PHP ?
How to execute PHP code using command line ?
How to Insert Form Data into Database using PHP ?
How to delete an array element based on key in PHP?
How to convert array to string in PHP ?
How to pop an alert message box using PHP ?