code-rag-bench/online-tutorials huggingface dataset:
Explain the PowerShell Function.

Function in a PowerShell is to reduce the redundancy of the repeated codes this means codes which are repeating, bind them into a function and call the function whenever necessary, so you don’t need to write codes multiple times.
Let assume, you want to perform arithmetic operations (multiply, sum, divide and subtraction) of two values 5 and 4 in one go, so you will write different operations for two values or you will assign values to the variable called $val1 and $val2 and perform various operations on them as shown below in the example.
$val1 = 5
$val2 = 4

$val1 * $val2
$val1 + $val2
$val1 / $val2
$val1 - $val2
Now, assume value changes again, let say 20 and 10 and change the value of the variable and need to write the whole bunch of commands again. PowerShell function plays a vital role here. So the repetitive code can be written inside the function.
Before starting our first example, we will see the syntax first.
function FunctionName(Parameter1, Parameter2,.....,ParameterN) {
   //Operation commands
   // Conditions
}
In the below example, we have given a function name called math_operation, which performs all the operation of the two variables. The code is given below.
function math_Operation{
   $val1 = 10
   $val2 = 5
   Write-Host "Multiply : $($val1*$val2)"
   Write-Host "Addition : $($val1+$val2)"
   Write-Host "Subtraction : $($val1-$val2)"
   Write-Host "Divide : $($val1+$val2)"
}
math_Operation
To call this function, simply we can call it by its name as shown in the example.
Multiply : 50
Addition : 15
Subtraction : 5
Divide : 15
When you write the function execute the script then you can also call the function from PowerShell console with the function name. Here, you need to write math_operation in the terminal after script execution.
Now to use the function multiple times, you simply just need to pass those two values in the function so that operations between them can be performed. To do so, we use the Param block (which refers to Parameters) inside the function and declare the variables in it.
function math_Operation{
   param([int]$val1,[int]$val2)
   Write-Host "Multiply : $($val1*$val2)"
   Write-Host "Addition : $($val1+$val2)"
   Write-Host "Subtraction : $($val1-$val2)"
   Write-Host "Divide : $($val1+$val2)"
}
Execute the above code in the PowerShell console and in the terminal itself you can see you can use two values (val1andval2) as the parameters. So every time you need to pass two values to calculate the result.
PS E:\scripts\Powershell> math_Operation -val1 20 -val2 10
Multiply : 200
Addition : 30
Subtraction : 10
Divide : 30
You should avoid giving the standard cmdlets name to the function.
find_element_by_tag_name() driver method - Selenium Python - GeeksforGeeks

09 Sep, 2021
Selenium’s Python Module is built to perform automated testing with Python. Selenium Python bindings provide a simple API to write functional/acceptance tests using Selenium WebDriver. After you have installed selenium and checked out – Navigating links using get method, you might want to play more with Selenium Python. After one has opened a page using selenium such as geeksforgeeks, one might want to click some buttons automatically or fill a form automatically or any such automated task. 
This article revolves around how to grab or locate elements in a webpage using locating strategies of Selenium Web Driver. More specifically, find_element_by_tag_name() is discussed in this article. With this strategy, the first element with the given tag name will be returned. If no element has a matching tag name, a NoSuchElementException will be raised.
Syntax – 
driver.find_element_by_tag_name("Tag name")
Example – 
For instance, consider this page source:  
HTML
<html> <body>  <h1>Welcome</h1>   <p>Site content goes here.</p> </body><html>
Now after you have created a driver, you can grab an element using – 
login_form = driver.find_element_by_tag_name('h1') 
Let’s try to practically implement this method and get a element instance for “https://www.geeksforgeeks.org/”. Let’s try to grab first title using its tag “h2”. 
Create a file called run.py to demonstrate find_element_by_tag_name method –  
Python3
# Python program to demonstrate# selenium # import webdriverfrom selenium import webdriver # create webdriver objectdriver = webdriver.Firefox() # enter keyword to searchkeyword = "geeksforgeeks" # get geeksforgeeks.orgdriver.get("https://www.geeksforgeeks.org/") # get elementelement = driver.find_element_by_tag_name("h2") # print complete elementprint(element)
Now run using – 
Python run.py
First, it will open firefox window with geeksforgeeks, and then select the element and print it on terminal as shown below. 
Browser Output –  
Terminal Output – 
 
NaveenArora
surinderdawra388
Python-selenium
selenium
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python OOPs Concepts
How to Install PIP on Windows ?
Bar Plot in Matplotlib
Defaultdict in Python
Python Classes and Objects
Deque in Python
Check if element exists in list in Python
How to drop one or multiple columns in Pandas Dataframe
Python - Ways to remove duplicates from list
Class method vs Static method in Python
How do we count the total duplicate records in a column of MySQL table?

Suppose we have the following table named stock_item in which the column quantity is having duplicate values i.e. for item name ‘Notebooks’ and ‘Pencil’, the column ‘Quantity’ is having duplicate values ‘40’ and for items ‘Shirts’, ‘Shoes’ and ‘Trousers’ triplicate value 29 is hold by column ‘quantity’ as shown in the table.
mysql> Select * from stock_item;
+------------+----------+
| item_name  |quantity  |
+------------+----------+
| Calculator |       89 |
| Notebooks  |       40 |
| Pencil     |       40 |
| Pens       |       32 |
| Shirts     |       29 |
| Shoes      |       29 |
| Trousers   |       29 |
+------------+----------+
7 rows in set (0.00 sec)
It shows that there are two duplicate values i.e. 40 and 29 in ‘quantity’.
Now with the help of the following query, we can count the total duplicate records in the column ‘quantity’ of table ‘stock_item’.
mysql> Select count(*) AS Total_duplicate_count
    -> FROM (SELECT item_name FROM stock_item
    -> GROUP BY quantity HAVING COUNT(quantity) > 1) AS X;
+-----------------------+
| Total_duplicate_count |
+-----------------------+
|                     2 |
+-----------------------+
1 row in set (0.00 sec)
How to set the bottom margin of an element with JavaScript?

Use the marginBottom property in JavaScript, to set the bottom margin.
You can try to run the following code to set the bottom margin of an element with JavaScript −
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <p id="myID">This is demo text.</p>
      <button type="button" onclick="display()">Set bottom margin</button>
      <script>
         function display() {
            document.getElementById("myID").style.marginBottom = "95px";
         }
      </script>
   </body>
</html>
How to Append Data to a SQL Column? - GeeksforGeeks

12 Dec, 2021
In this Article we will update a record while keeping the existing record value if it exists. Whenever we need to just update the record after some time of creation the record
We will use Append Query in SQL. For Implementing the Append Query in SQL Here First of all we will create Database and inside the we will create a table with some Record.
Step 1: Create a Database
 For database creation there is query we will use in SQL Platform, like Mysql, oracle, etc.
Query:
Create database Sample;
Step 2 : Use Database 
After creation of database for using the database we will use a another query in SQL Platform like Mysql, oracle etc.
Query:
Use Sample;
Step 3: Creation table in Database
For creation a table in a database. We need to execute a query in SQL Platform. Like Mysql, Oracle etc. We will use this query ->
Query:
CREATE TABLE EMP1
( EMPNAME VARCHAR(25),
DEPT VARCHAR(20),
CONTACTNO BIGINT NOT NULL,
SALARY INT
); 
Step 4: To View schema of a table
Query:
EXEC sp_help EMP2021 
Output:
 
Step 5: Insert data into table
To insert data into table there is query we will use here in SQL.
Query:
INSERT INTO EMP2021
VALUES ('VISHAL','EXECUTIVE',9193458625,20000),
('VIPIN','SYSTEM ENGINEER',7352158944,32000),
('ROHIT','EXECUTIVE',7830246946,21000),
('RAHUL','SYSTEM ENGINEER',9635688441,35000),
('SANJAY','SYSTEM ENGINEER',9149335694,36000),
('ROHAN','MANAGER',7352158944,50000),
('RAJESH','SYSTEM ENGINEER',9193458625,30000),
('AMAN','MANAGER',78359941265,52000),
('RAKESH','SYSTEM ENGINEER',9645956441,29000),
('VIJAY','EXECUTIVE',9147844694,20000);
Step 6 :Verifying Inserted data 
After Inserting data in table We can confirm or Justify which data we have insert correctly or not. With the help of given Below Query. 
Query:
SELECT * FROM EMP2021;
Output:
Step 7: APPEND DATA IN SQL COLUMN
After Inserting the data in table now we will come on the last step of append Data in SQL Column Means update the data of existing Column Value with the help of Append Query. Here we will append data in Column(DEPT) . We will append SENIOR with SYSTEM ENGINEER Where SALARY is Greater then 30000 and less Then 50000.
Query: 
UPDATE EMP2021 SET DEPT = 'SENIOR '+ DEPT WHERE SALARY >30000 AND SALARY <50000; 
After Executing this query Column DEPT value will append with SYSTEM on the basis on Condition Where Salary is greater 30000 and Less then 50000. Changes we can see below
Output:
gulshankumarar231
anikaseth98
Picked
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?
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?
SQL | Subquery
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL Query to Convert VARCHAR to INT
SQL using Python
How to Write a SQL Query For a Specific Date Range and Date Time?
How to Select Data Between Two Dates and Times in SQL Server?
SQL Query to Compare Two Dates
Generate a random string in Java

Let us first declare a string array and initialize −
String[] strArr = { "P", "Q", "R", "S","T", "U", "V", "W" };
Now, create a Random object −
Random rand = new Random();
Generate random string −
int res = rand.nextInt(strArr.length);
 Live Demo
import java.util.Random;
public class Demo {
   public static void main(String[] args) {
      String[] strArr = { "P", "Q", "R", "S","T", "U", "V", "W" };
      Random rand = new Random();
      int res = rand.nextInt(strArr.length);
      System.out.println("Displaying a random string = " + strArr[res]);
   }
}
Displaying a random string = R
Let us run it again to get distinct random string −
Displaying a random string = Q
How to Print Out All Rows of a MySQL Table in Python?

26 Nov, 2020
MySQL server is an open-source relational database management system which is a major support for web-based applications. Databases and related tables are the main component of many websites and applications as the data is stored and exchanged over the web.  In order to access MySQL databases from a web server(here XAMPP) we use various modules in Python such as PyMySQL, mysql.connector, etc. 
In this article, we will see how to get the all rows of a MySQL table by making a database connection between python and MySQL.
First, we are going to connect to a database having a MySQL table. The SQL query to be used to get all the rows:
SELECT * FROM table-name 


 Finally, after getting all the rows, display each row in the table using an iterator.
Below are some programs which depict how to extract rows from a MySQL table in a Database:
Example 1:
Below is the table geeksdemo is database geek which is going to be accessed by a Python script:
Below is the program to get all the rows in an MYSQL table:
Python3
# import required modulesimport pymysqlpymysql.install_as_MySQLdb()import MySQLdb  # connect python with mysql with your hostname, # username, password and databasedb= MySQLdb.connect("localhost", "root", "", "GEEK")  # get cursor objectcursor= db.cursor()  # execute your querycursor.execute("SELECT * FROM geeksdemo")  # fetch all the matching rows result = cursor.fetchall()  # loop through the rowsfor row in result:    print(row)    print("\n")
Output:
Example 2:
Here is another example to extracts all the rows from a table in a given database, below is the table scheme and rows:
Below is the Python script extract all each row from the table:
Python3
# import required modulesimport MySQLdbimport pymysqlpymysql.install_as_MySQLdb()  # connect python with mysql with your hostname,# username, password and databasedb = MySQLdb.connect("localhost", "root", "", "techgeeks")  # get cursor objectcursor = db.cursor()  # execute your querycursor.execute("SELECT * FROM techcompanies")  # fetch all the matching rowsresult = cursor.fetchall()  # loop through the rowsfor row in result:    print(row, '\n')
Output:
mysql
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Saving a Video using OpenCV

01 Mar, 2020
OpenCV is an open-source and most popular computer vision library that contains several computer vision algorithms. You can read, display, write and doing lots of other operations on images and videos using OpenCV. The OpenCV module generally used in popular programming languages like C++, Python, Java. To save a video in OpenCV cv.VideoWriter() method is used.
Note: For more information, refer to Introduction to OpenCV.
Syntax: cv.VideoWriter(filename, fourcc, fps, frameSize)
Parameters:
filename: Input video filefourcc: 4-character code of codec used to compress the framesfps: framerate of videostreamframesize: Height and width of frame
Example:
# Python program to save a # video using OpenCV     import cv2     # Create an object to read # from cameravideo = cv2.VideoCapture(0)   # We need to check if camera# is opened previously or notif (video.isOpened() == False):     print("Error reading video file")  # We need to set resolutions.# so, convert them from float to integer.frame_width = int(video.get(3))frame_height = int(video.get(4))   size = (frame_width, frame_height)   # Below VideoWriter object will create# a frame of above defined The output # is stored in 'filename.avi' file.result = cv2.VideoWriter('filename.avi',                          cv2.VideoWriter_fourcc(*'MJPG'),                         10, size)    while(True):    ret, frame = video.read()      if ret == True:           # Write the frame into the        # file 'filename.avi'        result.write(frame)          # Display the frame        # saved in the file        cv2.imshow('Frame', frame)          # Press S on keyboard         # to stop the process        if cv2.waitKey(1) & 0xFF == ord('s'):            break      # Break the loop    else:        break  # When everything done, release # the video capture and video # write objectsvideo.release()result.release()    # Closes all the framescv2.destroyAllWindows()   print("The video was successfully saved")
Output:
Python-OpenCV
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Convert integer to string in Python
Python | Pandas Series.max()

11 Feb, 2019
Pandas series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index.
Pandas Series.max() function return the maximum of the underlying data in the given Series object. This function always returns Series even if only one value is returned.
Syntax: Series.max(axis=None, skipna=None, level=None, numeric_only=None, **kwargs)
Parameter :axis : Axis for the function to be applied on.skipna : Exclude NA/null values when computing the result.level : If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a scalar.numeric_only : Include only float, int, boolean columns.**kwargs : Additional keyword arguments to be passed to the function.
Returns : max : scalar or Series (if level specified)
Example #1: Use Series.max() function to find the maximum value among the underlying data in the given series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([10, 25, 3, 25, 24, 6])  # Create the Indexindex_ = ['Coca Cola', 'Sprite', 'Coke', 'Fanta', 'Dew', 'ThumbsUp']  # set the indexsr.index = index_  # Print the seriesprint(sr)
Output :
Now we will use Series.max() function to find the maximum value of the given series object.
# return the maximum value in the # series objectresult = sr.max()  # Print the resultprint(result)
Output :As we can see in the output, the Series.max() function has successfully returned the maximum value of the given series object. Example #2: Use Series.max() function to find the maximum value among the underlying data in the given series object. The given series object also contains some missing values.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([19.5, 16.8, None, 22.78, 16.8, 20.124, None, 18.1002, 19.5])  # Print the seriesprint(sr)
Output :
Now we will use Series.max() function to find the maximum value of the given series object. we are going to skip the missing value while finding the maximum value.
# return the maximum value in the series object# skip the missing valuesresult = sr.max(skipna = True)  # Print the resultprint(result)
Output :As we can see in the output, the Series.max() function has successfully returned the maximum value of the given series object.
Python pandas-series
Python pandas-series-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to pass a PHP array to a JavaScript function?

01 Aug, 2021
Passing PHP Arrays to JavaScript is very easy by using JavaScript Object Notation(JSON).
Method 1: Using json_encode() function: The json_encode() function is used to return the JSON representation of a value or array. The function can take both single dimensional and multidimensional arrays.
Steps:
Creating an array in PHP:<?php
$sampleArray = array(
        0 => "Geeks", 
        1 => "for", 
        2 => "Geeks", 
    );
?>

<?php
$sampleArray = array(
        0 => "Geeks", 
        1 => "for", 
        2 => "Geeks", 
    );
?>

Using json_encode() function to retrieve the array elementsvar passedArray = <?php echo json_encode($sampleArray); ?>
var passedArray = <?php echo json_encode($sampleArray); ?>
Example:
<?php     // Create an array$sampleArray = array(    0 => "Geeks",     1 => "for",     2 => "Geeks", )?>   <script>  // Access the array elementsvar passedArray =     <?php echo json_encode($sampleArray); ?>;       // Display the array elementsfor(var i = 0; i < passedArray.length; i++){    document.write(passedArray[i]);}</script>
Output:
GeeksforGeeks
Method 2: Using PHP implode() function: The implode() is used to join the elements of an array. The implode() function is the alias of join() function and works exactly same as that of join() function.The implode() function is used to build a string that becomes an array literal in JavaScript. So, if we have an array in PHP, we can pass it to JavaScript as follows:
var passedArray = <?php echo '["' . implode('", "', $sampleArray) . '"]' ?>;

Example:
<?php  // Creating a PHP Array$sampleArray = array('Car', 'Bike', 'Boat');  ?>  <script type="text/javascript">   // Using PHP implode() functionvar passedArray =     <?php echo '["' . implode('", "', $sampleArray) . '"]' ?>;   // Printing the passed array elementsdocument.write(passedArray);   </script>
Output:
Car, Bike, Boat
PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples.
Picked
JavaScript
PHP
PHP Programs
Web Technologies
Web technologies Questions
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Extract Numbers in Brackets in String

22 Apr, 2020
Sometimes, while working with Python strings, we can have a problem in which we have to perform the task of extracting numbers in string that are enclosed in brackets. Lets discuss certain way in which this task can be performed.
Method : Using regexThe way to solve this task is to construct a regex string that can return in all the numbers in a string that have brackets around them.
# Python3 code to demonstrate working of # Extract Numbers in Brackets in String# Using regeximport re  # initializing stringtest_str = "gfg is [1] [4] all geeks"  # printing original stringprint("The original string is : " + test_str)  # Extract Numbers in Brackets in String# Using regexres = re.findall(r"\[\s*\+?(-?\d+)\s*\]", test_str)  # printing result print("Extracted number list : " + str(res)) 
The original string is : gfg is [1] [4] all geeks
Extracted number list : ['1', '4']

Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
How to Install PIP on Windows ?
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
jQuery | clone() with Examples

13 Feb, 2019
The clone() is an inbuilt method in jQuery which is used to make a copy of selected elements including its child nodes, text and attributes.Syntax:
$(selector).clone(true|false)

Parameter: It accepts an optional parameter which could be either true or false specifies that event handler should be copied or not.Return Value : It returns the cloned elements for the selected element.
<html>  <head>    <script src="https://ajax.googleapis.com/ajax/libs/               jquery/3.3.1/jquery.min.js"></script>                     <!--In this example no parameter is passing to the         clone method-->    <script>        $(document).ready(function() {            $("button").click(function() {                $("p").clone().appendTo("body");            });        });    </script></head>  <body>    <p>Welcome to</p>    <p>GeeksforGeeks !!!</p>    <!--click on this method and see the clone element-->    <button>Click Me!</button></body>  </html>
Before clicking the “Click Me” button-
After clicking the “Click Me” button-
Code #2:In the below code, true is passed to the clone method.
<html>  <head>    <script src="https://ajax.googleapis.com/ajax/libs/                jquery/3.3.1/jquery.min.js"></script>    <!--here clone method is called with the true value passing-->    <script>        $(document).ready(function() {            $("button").click(function() {                $("body").append($("p:first").clone(true));            });            $("p").click(function() {                $(this).animate({                    fontSize: "+=1px"                });            });        });    </script></head>  <body>    <p>GeeksforGeeks !</p>    <p>Hello Writer !</p>    <!--click on this method and see the clone element-->    <button>Click Me!</button></body>  </html>
In this example code event handler animate will work when you click on the “GeeksforGeeks” and this will also reflect on the cloned elements.Output:Before clicking the “Click Me” button-
After clicking the “Click Me” button-
jQuery-HTML/CSS
JavaScript
JQuery
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
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Hide or show elements in HTML using display property
Roadmap to Learn JavaScript For Beginners
JQuery | Set the value of an input text field
How to change selected value of a drop-down list using jQuery?
Form validation using jQuery
How to add options to a select element using jQuery?
How to Dynamically Add/Remove Table Rows using jQuery ?
How to change the type of a field in MongoDB?

Let us convert string type to int for an example. Aggregation does not allow us to directly change the type of a field; therefore, you need to write a code to convert the type of a field.
At first, create a collection with document. After that we will get the type of every field. The query to create a collection with document is as follows
>db.changeDataType.insertOne({"StudentName":"Larry","StudentAge":23,"StudentZipCode":"
10001","isProgrammer":false});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c6ed4976fd07954a4890694")
}
Display all documents from a collection with the help of find() method. The query is as follows:
> db.changeDataType.find().pretty();
The following is the output:
{
   "_id" : ObjectId("5c6ed4976fd07954a4890694"),
   "StudentName" : "Larry",
   "StudentAge" : 23,
   "StudentZipCode" : "10001",
   "isProgrammer" : false
}
Now let us check type of every field in a collection. The query is as follows to check the type of every field:
> checkType=db.changeDataType.findOne();
{
   "_id" : ObjectId("5c6ed4976fd07954a4890694"),
   "StudentName" : "Larry",
   "StudentAge" : 23,
   "StudentZipCode" : "10001",
   "isProgrammer" : false
}
Now here we will use the above variable “checkType” to get the type of every variable. The query is as follows:
> typeof checkType._id;
object
> typeof checkType.StudentName;
string
> typeof checkType.StudentAge;
number
> typeof checkType.StudentZipCode;
string
> typeof checkType.isProgrammer;
boolean
Now, change the type of “StudentZipCode” from string to number type. The query is as follows:
> db.changeDataType.find().forEach(function(ch)
... {
... db.changeDataType.update({
... "_id":ch._id},
... {"$set":
... {
... "StudentZipCode":parseInt(ch.StudentZipCode)
... }
... });
... });
I have changed the type of “StudentZipCode” from string to number type. To verify, let us follow what we saw above to check the type of field in a collection:
> againCheckType=db.changeDataType.findOne();
{
   "_id" : ObjectId("5c6ed4976fd07954a4890694"),
   "StudentName" : "Larry",
   "StudentAge" : 23,
   "StudentZipCode" : 10001,
   "isProgrammer" : false
}
Use the above variable to check the type of field:
> typeof againCheckType.StudentZipCode;
number
Look at the above output now, the “StudentZipCode” field have been changed from String type to number.
MySQL INNER JOIN Keyword

The INNER JOIN keyword selects records that have matching values in both tables.
In this tutorial we will use the well-known Northwind sample database.
Below is a selection from the "Orders" table:
And a selection from the "Customers" table:
The following SQL statement selects all orders with customer information:
Note: The INNER JOIN keyword selects all rows from both 
tables as long as there is a match between the columns. If there are records in the 
"Orders" table that do not have matches in "Customers", these orders will not 
be shown!
The following SQL statement selects all orders with customer and shipper 
information:
Choose the correct JOIN clause to select all records from the two tables where there is a match in both tables.
SELECT *
FROM Orders

ON Orders.CustomerID=Customers.CustomerID;

Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
How to use the Timeout command in PowerShell?

Timeout.exe is actually a cmd command which can also be used in PowerShell. Let see the help related to Timeout command.
timeout /?
If we see the timeout parameters list we can use /T which indicates the Time in seconds and /NoBreak command, which Ignores any key for the specified time.
Write-Output "Timeout is for 10 seconds"
Timeout /T 10
Write-Output "This line will be executed after 10 seconds if not interuptted"
PS C:\> C:\Temp\TestPS1.ps1
Timeout is for 10 seconds
Waiting for 5 seconds, press a key to continue ...
Please note: In the above example, the user can interrupt the timeout seconds using any key to disallow the user interruption use /NoBreak Switch.
Write-Output "Timeout is for 10 seconds"
Timeout /NoBreak 10
Write-Output "This line will be executed after 10 seconds"
PS C:\> C:\Temp\TestPS1.ps1
Timeout is for 10 seconds
Waiting for 2 seconds, press CTRL+C to quit ...
If you enter the Ctrl+C, it will terminate the entire script execution.
How to open a PDF files in web browser using PHP? - GeeksforGeeks

31 Jul, 2021
PHP uses a standard code to display the pdf file in web browser. The process of displaying pdf involves location of the PDF file on the server and it uses various types of headers to define content composition in form of type, Disposition, Transfer-Encoding etc. PHP passes the PDF files to read it on the browser. Browser either shows it or download it from localhost server then display pdf.
Note: PHP is not actually reading the PDF file. It does not recognize File as pdf. It only passes the PDF file to the browser to be read there. If copy the pdf file inside htdocs folder of XAMPP then it does not need to specify the file path.
Example 1: This example display the pdf file on the browser.
<?php  // Store the file name into variable$file = 'filename.pdf';$filename = 'filename.pdf';  // Header content typeheader('Content-type: application/pdf');  header('Content-Disposition: inline; filename="' . $filename . '"');  header('Content-Transfer-Encoding: binary');  header('Accept-Ranges: bytes');  // Read the file@readfile($file);  ?>
Output:
Example 2:this examples displays a format and explains every section of code
<?php  // The location of the PDF file// on the server$filename = "/path/to/the/file.pdf";  // Header content typeheader("Content-type: application/pdf");  header("Content-Length: " . filesize($filename));  // Send the file to the browser.readfile($filename);?> 
Output:
PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples.
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 Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to Upload Image into Database and Display it using PHP ?
PHP | Converting string to Date and DateTime
Comparing two dates in PHP
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to call PHP function on the click of a Button ?
How to Upload Image into Database and Display it using PHP ?
Comparing two dates in PHP
How to use external “.js” files in an HTML file?

Create external JavaScript file with the extension .js. After creating, add it to the HTML file in the script tag. The src attribute is used to include that external JavaScript file.
If you have more than one external JavaScript file, then add it in the same web page to increase performance of the page.
Let’s say the following new.js is our external JavaScript file −
function display() {
   alert("Hello World!");
}
Now add the external JavaScript file to the HTML web page −
<html>
   <body>
      <form>
      <input type="button" value="Result" onclick="display()"/>
      </form>
      <script src="new.js">
      </script>
   </body>
</html>
Arduino - Boolean Operators

Assume variable A holds 10 and variable B holds 20 then −
void loop () {
   int a = 9,b = 4
   bool c = false;
   if((a > b)&& (b < a))
      c = true;
   else
      c = false;

   if((a == b)|| (b < a))
      c = true;
   else
      c = false;

   if( !(a == b)&& (b < a))
      c = true;
   else
      c = false;
}
c = true
c = true
c = true


    65 Lectures 
     6.5 hours 

 Amit Rana

    43 Lectures 
     3 hours 

 Amit Rana

    20 Lectures 
     2 hours 

 Ashraf Said

    19 Lectures 
     1.5 hours 

 Ashraf Said

    11 Lectures 
     47 mins

 Ashraf Said

    9 Lectures 
     41 mins

 Ashraf Said
 Print
 Add Notes
 Bookmark this page
What is the easiest way to reverse a String in Java?

The StringBuffer class provides you a method named reverse(). It reverses the contents of the current StringBuffer object and returns the resultant StringBuffer object. It is the easiest way to reverse a Sting using Java. To do so −
Instantiate the StringBuffer class by passing the required String as a parameter.
Instantiate the StringBuffer class by passing the required String as a parameter.
Invoke the reverse() method od the created object.
Invoke the reverse() method od the created object.
Convert it into String again using the toString() method.
Convert it into String again using the toString() method.
public class Sample {
   public static void main(String args[]) {
      String str = new String("Hello how are you");
      StringBuffer sb = new StringBuffer(str);
      String str2 = sb.reverse().toString();
      System.out.println(str2);
   }
}
uoy era woh olleH
Let us observe two more ways to reverse a String
Recursion is a process of calling a function within itself, following java program reverses a Sting using recursion −
public class StringReverse {
   public String reverseString(String str) {
      if(str.isEmpty()) {
         return str;
      }else {
         return reverseString(str.substring(1))+str.charAt(0);
      }
   }
   public static void main(String[] args) {
      StringReverse obj = new StringReverse();
      String result = obj.reverseString("Tutorialspoint");
      System.out.println(result);
   }
}
tniopslairotuT
You can also convert the String to a character array and swap the characters of the array.
To reverse an array, swap the first element with the last element and the second element with second last element and so on, if the array is of odd length leave the middle element as it is.
If i is the first element of the array (length of the array –i-1) will be the last element therefore, swap array[i] with array[(length of the array –i-1)] from the start to the midpoint of the array −
import java.util.Arrays;
public class StringReverse {
   public static void main(String[] args) {
      String str = "Tutorialspoint";
      char[] myArray = str.toCharArray();
      int size = myArray.length;
      for (int i = 0; i < size / 2; i++) {
         char temp = myArray[i];
         myArray[i] = myArray[size - 1 - i];
         myArray[size - 1 - i] = temp;
      }
      System.out.println("Array after reverse:: ");
      System.out.println(Arrays.toString(myArray));
   }
}
Array after reverse::
[t, n, i, o, p, s, l, a, i, r, o, t, u, T]
p5.js Touch | touchMoved() - GeeksforGeeks

15 Apr, 2019
The touchMoved() function in p5.js is called when a touch move is registered. If no touchMoved() function is defined, the mouseDragged() function will be called instead if it is defined.
Syntax:
touchMoved([Event])

Below program illustrates the touchMoved() function in p5.js:Example-1:
let valueX;let valueY;  function setup() {        // Create Canvas of size 500*500    createCanvas(500, 500);}  function draw() {        // set background color    background(200);        fill('green');    // set text and text size    textSize(25);        text('Hold and Move to change color', 30, 30);    // fill color according to touchStarted()     fill(valueX, 255 - valueY, 255 - valueX);        // draw ellipse      ellipse(mouseX, mouseY, 115, 115);  }  function touchMoved() {    valueX = mouseX % 255;    valueY = mouseY % 255;}
Output:
Example-2:
let valueX;let valueY;  function setup() {        // Create Canvas of size 500*500    createCanvas(500, 500);}  function draw() {    // set background color    background(200);        fill('green');    // set text and text size    textSize(25);        text('Touch and Move to change color', 30, 30);    // fill color according to mouseMoved()     fill(valueX, 255 - valueY, 255 - valueX);        // draw rectangle     rect(mouseX, mouseY, 115, 115);    fill(valueY, 255 - valueX, 255 - valueX);      rect(mouseX, mouseY + 115, 115, 115);    fill(255 - valueY, 255 - valueX, 255 - valueY);      rect(mouseX - 115, mouseY, 115, 115);    fill(255 - valueY, 255 - valueY, 255 - valueY);      rect(mouseX - 115, mouseY + 115, 115, 115);}  function touchMoved() {    valueX = mouseX % 255;    valueY = mouseY % 255;}
Output:Reference: https://p5js.org/reference/#/p5/touchMoved
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Difference Between PUT and PATCH Request
Remove elements from a JavaScript Array
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
How to sort HashSet in Java

To sort HashSet in Java, you can use another class, which is TreeSet.
Following is the code to sort HashSet in Java −
 Live Demo
import java.util.*;
public class Main {
   public static void main(String args[]) {
      Set<String> hashSet = new HashSet<String>();
      hashSet.add("green");
      hashSet.add("blue");
      hashSet.add("red");
      hashSet.add("cyan");
      hashSet.add("orange");
      hashSet.add("green");
      System.out.println("HashSet elements\n"+ hashSet);
      Set<String> treeSet = new TreeSet<String>(hashSet);
      System.out.println("Sorted elements\n"+ treeSet);
   }
}
HashSet elements
[red, orange, green, blue, cyan]
Sorted elements
[blue, cyan, green, orange, red]
Let us see another example wherein we will sort the HashSet in descending order using Collections.sort() method with reverseOrder() method −
 Live Demo
import java.util.*;
public class Main {
   public static void main(String args[]) {
      Set<String> hashSet = new HashSet<String>();
      hashSet.add("yellow");
      hashSet.add("green");
      hashSet.add("blue");
      hashSet.add("cyan");
      hashSet.add("orange");
      hashSet.add("green");
      System.out.println("HashSet elements\n"+ hashSet);
      List<String> myList = new ArrayList<String>(hashSet);
      Collections.sort(myList,Collections.reverseOrder());
      System.out.println("Sorted (descending order)\n"+ myList);
   }
}
HashSet elements
[orange, green, blue, yellow, cyan]
Sorted (descending order)
[yellow, orange, green, cyan, blue]
Lodash _.isEqual() Method

31 Jul, 2020
The Lodash _.isEqual() Method performs a deep comparison between two values to determine if they are equivalent. This method supports comparing arrays, array buffers, boolean, date objects, maps, numbers, objects, regex, sets, strings, symbols, and typed arrays. 
Syntax:
_.isEqual( value1, value2)

Parameters: This method accepts two parameters as mentioned above and described below:
value1: value1 to be checked.
value2: value2 to be checked.
Return Value: This method returns a Boolean value(Returns true if the two values are equal, else false).
Example 1: 
Javascript
// Defining Lodash variable const _ = require('lodash');   var val1 = { "a": "gfg" };  var val2 = { "a": "gfg" };  // Checking for Equal Value console.log("The Values are Equal : "        +_.isEqual(val1,val2));
Output:
The Values are Equal : true

Example 2: For arrays: 
Javascript
// Defining Lodash variable const _ = require('lodash');   var val1 = [1, 2, 3, 4]  var val2 = [1, 2, 3, 4]  // Checking for Equal Value console.log("The Values are Equal : "        +_.isEqual(val1,val2));
Output:
The Values are Equal : true

Example 3: For strings: 
Javascript
// Defining Lodash variable const _ = require('lodash');   var val1 = "gfg"  var val2 = "gfg"  // Checking for Equal Value console.log("The Values are Equal : "        +_.isEqual(val1,val2));
Output:
The Values are Equal : true

Example 4: For numbers: 
Javascript
// Defining Lodash variable const _ = require('lodash');   var val1 = 1  var val2 = 1  // Checking for Equal Value console.log("The Values are Equal : "        +_.isEqual(val1,val2));
Output:
The Values are Equal : true

Example 5: 
Javascript
// Defining Lodash variable const _ = require('lodash');   var val1 = 222  var val2 = 323  // Checking for Equal Value console.log("The Values are Equal : "        +_.isEqual(val1,val2));
Output:
The Values are Equal : false

JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PLSQL | SUBSTR Function

30 Sep, 2019
The PLSQL SUBSTR function is used for extracting a substring from a string.The SUBSTR function accepts three parameters which are input_string, start_position, length.SUBSTR calculates lengths using characters as defined by the input character set. SUBSTRB uses bytes instead of characters.
Note:
If position is 0, then it is treated as 1.
If position is positive, then Oracle Database counts from the beginning of char to find the first character.
If position is negative, then Oracle counts backward from the end of char.
If substring_length is omitted, then Oracle returns all characters to the end of char. If substring_length is less than 1, then Oracle returns null.
Syntax:
SUBSTR( input_string, start_position, length)
Parameters Used:
input_string – It is used to specify the source string.start_position – It is used to specify the starting position for extraction.length – It is an optional parameter which is used to specify the number of characters to extract.
input_string – It is used to specify the source string.
start_position – It is used to specify the starting position for extraction.
length – It is an optional parameter which is used to specify the number of characters to extract.
Return Value:The SUBSTR function in PLSQL returns a string value.
Supported Versions of Oracle/PLSQL:
Oracle 12cOracle 11gOracle 10gOracle 9iOracle 8i
Oracle 12c
Oracle 11g
Oracle 10g
Oracle 9i
Oracle 8i
Example-1: Passing all the three arguments in the SUBSTR function.
DECLARE 
   Test_String string(25) := 'Geeksforgeeks';
   
BEGIN 
   dbms_output.put_line(SUBSTR(Test_String, '6', '3')); 
   
END;      
Output:
for
Example-2: Omitting the length argument while passing parameters to the SUBSTR function.
DECLARE 
   Test_String string(25) := 'Geeksforgeeks';
   
BEGIN 
   dbms_output.put_line(SUBSTR(Test_String, '6')); 
   
END;    
Output:
forgeeks 
Example-3: Passing a negative value in the starting_position argument while passing the parameters to the SUBSTR function.
DECLARE 
   Test_String string(25) := 'Geeksforgeeks';
   
BEGIN 
   dbms_output.put_line(SUBSTR(Test_String, '-6', '3')); 
   
END;     
Output:
rge 
SUBSTR function starts from the end of the string and counts backwards if the starting-position argument has a negative value.
Example-4: Passing a value in the starting_position argument which is greater than the number of characters in the input_string.
DECLARE 
   Test_String string(25) := 'Geeksforgeeks';
   
BEGIN 
   dbms_output.put_line(SUBSTR(Test_String, '-16', '3')); 
   
END; 
Output:
NULL 
SUBSTR function returns NULL since the number of characters present in the input_string is less than the value passed in the starting-position argument.
Advantage:Floating-point numbers passed as arguments to SUBSTR are automatically converted to integers.
SQL-PL/SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to generate a random 128 bit strings using Python?

You can generate these just random 128-bit strings using the random module's getrandbits function that accepts a number of bits as an argument. 
import random
hash = random.getrandbits(128)
print(hex(hash))
This will give the output −
0xa3fa6d97f4807e145b37451fc344e58c
Subtract two Sets in Javascript

The difference of 2 sets means the set being subtracted should have all its elements removed from the set it is being subtracted from. So we can iterate over the second set and remove all the elements present in it from the first set. 
static difference(s1, s2) {
   if (!s1 instanceof MySet || !s2 instanceof MySet) {
      console.log("The given objects are not of type MySet");
      return null;
   }
   let newSet = new MySet();
   s1.forEach(elem => newSet.add(elem));
   s2.forEach(elem => newSet.delete(elem));
   return newSet;
}
You can test this using − 
const testSet1 = new MySet();
testSet1.add(1);
testSet1.add(2);

const testSet2 = new MySet();
testSet2.add(2);
testSet2.add(5);

let testSet3 = MySet.differnce(testSet1, testSet2);
testSet3.display();
This will give the output −
{ '1': 1 }
Note that the difference function is not there in the ES6 API as well. You can make this function be available in the Set class as follows −
Set.difference = function(s1, s2) {
   if (!s1 instanceof Set || !s2 instanceof Set) {
      console.log("The given objects are not of type Set");
      return null;
   }
   let newSet = new Set();
   s1.forEach(elem => newSet.add(elem));
   s2.forEach(elem => newSet.delete(elem));
   return newSet;
}
You can test this using −
let setA = new Set([1, 2, 3, 4]);
let setB = new Set([2, 3]);
console.log(Set.difference(setA, setB));
This will give the output −
Set { 1, 4 }
Load image from url and draw to HTML5 Canvas

You need to create an image object in JavaScript after that set the src.
However, you need to wait for the load event before drawing.
The following is the canvas:
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");

var myImg = new Image();
img.onload = function() {
   context.drawImage(myImg, 0, 0);
};
img.src = 'https://www.tutorialspoint.com/images/seaborn-4.jpg?v=2';
How to find the unicode category for a given character in Java?

A Character class is a subclass of an Object and it wraps a value of the primitive type char in an object. An object of type Character contains a single field whose type is char. We can determine the unicode category for a particular character by using the getType() method.  It is a static method of Character class and it returns an integer value of char ch representing in unicode general category.
public static int getType(char ch)
public class CharacterTypeTest {
   public static void main(String args[]) {
      System.out.println("T represnts unicode category of: " + Character.getType('T'));
      System.out.println("@ represnts unicode category of: " + Character.getType('@'));
      System.out.println(") represnts unicode category of: " + Character.getType(')'));
      System.out.println("1 represnts unicode category of: " + Character.getType('1'));
      System.out.println("- represnts unicode category of: " + Character.getType('-'));
      System.out.println("_ represnts unicode category of: " + Character.getType('_'));
      System.out.println("a represnts unicode category of: " + Character.getType('a'));
   }
}
T represnts unicode category of: 1
@ represnts unicode category of: 24
) represnts unicode category of: 22
1 represnts unicode category of: 9
- represnts unicode category of: 20
_ represnts unicode category of: 23
a represnts unicode category of: 2