code-rag-bench/online-tutorials huggingface dataset:
PostgreSQL – Reset Password For Postgres

22 Apr, 2022
In this article, we will look into the step-by-step process of resetting the Postgres user password in case the user forgets it.
PostgreSQL uses the pg_hba.conf configuration file stored in the database data directory (e.g., C:\Program Files\PostgreSQL\12\data on Windows) and is used to handle user authentication. The hba in pg_hba.conf means host-based authentication.
As resetting the password requires modification in the pg_hba.conf file, you will need to login to the Postgres role without any password.
Follow the below steps to reset a password for the postgres user:
Step 1: Create a backup of the pg_hba.conf file by copying it to a different location or just rename it to pg_hba.conf.bk
Step 2: Now change the pg_hba.conf file by making all local connections from md5 to trust. This will help you to log in to the PostgreSQL database server without using a password.
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
host    replication     all             127.0.0.1/32            trust
host    replication     all             ::1/128                 trust
Step 3: Now restart the PostgreSQL server. On a Windows machine, you can restart the PostgreSQL from Services.
          Or use the below command from the window terminal:
pg_ctl -D "C:\Program Files\PostgreSQL\12\data" restart
The “C:\Program Files\PostgreSQL\12\data” is the data directory.
Step 4: Finally connect to the PostgreSQL database server using any tool such as psql or pgAdmin(In pgAdmin, press ok while it prompts you to enter the password without entering anything in the field.):
psql -U postgres
At this stage, you will not be asked for any authentication.
Step 5: Use the below command to set a new password for the postgres user.
ALTER USER postgres WITH PASSWORD 'new_password';
This will change the user’s password as shown below:
Step 6:Now restart the PostgreSQL database server. At this stage, you can connect to the PostgreSQL database server with the new password.
Follow the above steps to successfully reset the Postgres password and do not forget to restore the pg_hba.conf file after the reset to successfully store the credentials for future verification.
arjun8991
postgreSQL-administration
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to make Range Slider and Selector in Plotly? - GeeksforGeeks

01 Oct, 2020
A Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library.
In plotly, the range slider is a custom range-type input control. It allows selecting a value or a range of values between a specified minimum and maximum range. And the range selector is a tool for selecting ranges to display within the chart. It provides buttons to select pre-configured ranges in the chart. It also provides input boxes where the minimum and maximum dates can be manually input.
Example:
Python3
import plotly.graph_objects as pximport plotly.express as goimport numpy as np  df = go.data.tips()  x = df['total_bill']y = df['day']  plot = px.Figure(data=[px.Scatter(    x=x,    y=y,    mode='lines',)])  plot.update_layout(    xaxis=dict(        rangeselector=dict(            buttons=list([                dict(count=1,                     step="day",                     stepmode="backward"),            ])        ),        rangeslider=dict(            visible=True        ),    ))  plot.show()
Output:
Media error: Format(s) not supported or source(s) not found
Python-Plotly
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Python Dictionary
Taking input in Python
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
What are the rules for the Publisher interface in Java 9?

A Publisher is a provider of an unbounded number of sequenced elements publishing them according to demand received from its Subscribers. Publisher<T> interface is responsible for publishing elements of type T and provides a subscribe() method for subscribers to connect to it.
public interface Publisher<T> {
   public void subscribe(Subscriber<? super T> s);
}
Rules for Publisher interface:
The total number of onNext() methods signaled by Publisher to a Subscriber must be less than or equal to a total number of elements requested by Subscriber ́s Subscription at all times.
A Publisher may signal fewer onNext() methods than requested, and terminate the Subscription by calling onComplete() or onError() methods.
The onSubscribe(), onNext(), onError(), and onComplete() methods signaled to a Subscriber must be signaled serially.
If Publisher fails, then it must signal an onError() method.
If Publisher terminates successfully, then it must signal an onComplete() method.
If Publisher signals either onError() or onComplete() method on Subscriber, then Subscriber’s Subscription must be canceled.
Once terminal state has signaled (onError(), onComplete()), it is required that no further signals can occur.
If Subscription is canceled, its Subscriber must stop being signaled.
Publisher.subscribe() method must call onSubscribe() method on the provided Subscriber prior to any other signals to that Subscriber and returns normally, except when the provided Subscriber is null. In this case, it must throw a NullPointerException to the caller.
Publisher.subscribe() method may call as many times as required with a different Subscriber each time.
A Publisher may support multiple Subscribers and decides whether each Subscription can be unicast or multicast.
Style Bootstrap 4 card with bg-success class

To set positive action to a card in Bootstrap, use the bg-success class with the card class
Set positive action and use “card bg-success” −
<div class="card bg-success text-white">
Now add the body of the card using the card-body class −
<div class="card bg-success text-white">
  <div class="card-body">India won by 7 wickets</div>
</div>
You can try to run the following code to implement the card-success class −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>  
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  </head>
<body>
  <div class="container">
    <h3>Result</h3>
    <p>Result of the first two matches between India and Australia:</p>
    <div class="card bg-success text-white">
      <div class="card-body">India won by 10 runs</div>
    </div><br>
    <div class="card bg-success text-white">
      <div class="card-body">India won by 7 wickets</div>
    </div>
  </div>
</body>
</html>
Python program to sort a List according to the Length of the Elements?

Here we use one user input array and we have to sorted the list according to the length of the elements. Here we use Python inbuilt function sorted().
Input::[“mona”,”pp”,”aaa”]
Lengths are [4,2,3]
So, the sorted array should be [2,3,4]
Output::[“pp”,”aaa”,”mona”]

Step 1: Input list element.
Step 2: apply sorted (A,len) function.

# To sort a list 
def sortedlist(A):
   newlist = sorted(A, key=len)
   return newlist
# Driver code
A=list()
n=int(input("Enter the size of the List ::"))
print("Enter the Element ::")
for i in range(int(n)):
   k=input("")
   A.append(k)
print("SORTED LIST ::>",sortedlist(A))
Enter the size of the List ::5
Enter the Element ::
mona
gulli
adwaita
aadrika
pinki
SORTED LIST ::> ['mona', 'gulli', 'pinki', 'adwaita', 'aadrika']
Python unittest - How to nicely mock a web crawler function? - GeeksforGeeks

01 Apr, 2021
Prerequisite: Python | Unit Test Objects Patching
Unit Testing is the first level of software testing where the smallest testable parts of the software are tested. This is used to validate that each unit of the software performs as designed. The Unittest framework is python’s xUnit style framework. Before deep-diving into “How to nicely mock a web crawler” let us understand some fundamentals about that.
Mock is a submodule (class) of unittest module. The mock module allows us to replace particular portions of the whole system that we are testing with mock objects.
Import mock class from unittest.mock module.
Create an instance of the Mock class.
Set mock object’s method.
Print result
Let’s understand mock by mimicking another python class. In this example, we will see methods that were called on our mocked class, also what parameters were passed to them.
Python3
# importing mock from unittest.mock modulefrom unittest.mock import Mock  # defining instance of our mockour_mock = Mock()  # defining mock object’s __str__ methodour_mock.__str__ = Mock(return_value='GeeksforGeeks Mocking Example')  # executing str function for outputprint(str(our_mock))
Output:
GeeksforGeeks Mocking Example
Picked
Python-ctype
python-modules
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Selecting rows in pandas DataFrame based on conditions
Create a directory in Python
Python | Pandas dataframe.groupby()
CSS to put icon inside an input element in a form

To show how to put an icon inside an input element in a form using CSS, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/fontawesome.
min.css"
/>
<style>
body {
   font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
form {
   max-width: 450px;
   margin: auto;
}
.inputContainer i {
   position: absolute;
}
.inputContainer {
   width: 100%;
   margin-bottom: 10px;
}
.icon {
   padding: 15px;
   color: rgb(49, 0, 128);
   width: 70px;
   text-align: left;
}
.Field {
   width: 100%;
   padding: 10px;
   text-align: center;
   font-size: 20px;
   font-weight: 500;
}
</style>
</head>
<body>
<h1 style="text-align: center;">Icons inside input element example</h1>
<form>
<div class="inputContainer">
<i class="fa fa-user icon"> </i>
<input class="Field" type="text" placeholder="Username" />
</div>
<div class="inputContainer">
<i class="fa fa-envelope icon"> </i>
<input class="Field" type="text" placeholder="Email" />
</div>
<div class="inputContainer">
<i class="fa fa-key icon"> </i>
<input class="Field" type="password" placeholder="Password" />
</div>
</form>
</body>
</html>
The above code will produce the following output −
BigDecimal scale() Method in Java - GeeksforGeeks

04 Dec, 2018
The java.math.BigDecimal.scale() is an inbuilt method in java that returns the scale of this BigDecimal.
For zero or positive value, the scale is the number of digits to the right of the decimal point.
For negative value, the unscaled value of the number is multiplied by ten to the power of the negation of the scale.
Syntax:
public int scale()

Parameters: This method does not accepts any parameter.
Return value: This method returns the scale of this BigDecimal object.
Below program illustrates the working of the above mentioned method:
Program 1:
// Java program to demonstrate the// scale() method  import java.math.*;  public class Gfg {      public static void main(String[] args)    {          BigDecimal b1 = new BigDecimal("456.0");        BigDecimal b2 = new BigDecimal("-1.456");          // Assign the result of scale on        // BigDecimal Objects b1, b2 to int objects i1, i2        int i1 = b1.scale();        int i2 = b2.scale();          // Print the values of i1, i2;        System.out.println("The scale of " + b1 + " is " + i1);        System.out.println("The scale of " + b2 + " is " + i2);    }}
The scale of 456.0 is 1
The scale of -1.456 is 3

Program 2:
// Java program to demonstrate the// scale() method  import java.math.*;  public class Gfg {      public static void main(String[] args)    {          BigDecimal b1 = new BigDecimal("745");        BigDecimal b2 = new BigDecimal("-174");          // Assign the result of scale on        // BigDecimal Objects b1, b2 to int objects i1, i2        int i1 = b1.scale();        int i2 = b2.scale();          // Print the values of i1, i2;        System.out.println("The scale of " + b1 + " is " + i1);        System.out.println("The scale of " + b2 + " is " + i2);    }}
The scale of 745 is 0
The scale of -174 is 0

Reference: https://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html#scale()
Java-BigDecimal
Java-Functions
java-math
Java-math-package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HashMap in Java with Examples
Initialize an ArrayList in Java
Interfaces in Java
Object Oriented Programming (OOPs) Concept in Java
ArrayList in Java
How to iterate any Map in Java
Multidimensional Arrays in Java
Singleton Class in Java
Stack Class in Java
Set in Java
Python Program to Determine Whether a Given Number is Even or Odd Recursively

When it is required to check if a given number is an odd number or an even number using recursion, recursion can be used.
The recursion computes output of small bits of the bigger problem, and combines these bits to give the solution to the bigger problem.
Below is a demonstration for the same −
 Live Demo
def check_odd_even(my_num):
   if (my_num < 2):
      return (my_num % 2 == 0)
   return (check_odd_even(my_num - 2))
my_number = int(input("Enter the number that needs to be checked:"))
if(check_odd_even(my_number)==True):
   print("The number is even")
else:
   print("The number is odd!")
Enter the number that needs to be checked:48
The number is even
A method named ‘check_odd_even’ is defined, that takes a number as parameter.
If the number is less than 2, the remainder of the number when divided by 2 is computed, and checked wih 0.
The function is called again, and this time, the parameter passed is the number decremented by 2.
Outside the function, a number is taken as input by the user.
The function is called, and checked to see if it is ‘True’, if yes, it is determined as an even number.
Else it is considered an odd number.
It is returned as output.
What are mixed arrays in C#?

Mixed arrays are a combination of multi-dimension arrays and jagged arrays.
Note − The mixed arrays type is obsolete now since .NET 4.0 update removed it.
Let us see how you can declare a mixed array −
var x = new object[] {89,45,"jacob",9.8}
We can also set them as −
var x = new object[] {87, 33,"tim",6.7, new List<string>() {"football","tennis","squash",“cricket”} }
Since, mixed arrays are obslete now. For the same work, use the List collection. Here, we have set int and string in the list −
Tuple<int, string> tuple = new Tuple<int, string>(60, "John");
The same example is displayed below:
using System;
using System.Collections.Generic;

class Program {
   static void Main() {
      // Initializing collections
      Tuple tuple = new Tuple(99, "Jack");
      if (t.Item1 == 99) {
         Console.WriteLine(tuple.Item1);
      }
   }
}
Tryit Editor v3.7

HTML Input types
Tryit: HTML input button
MySQL query to check if a string contains a word?

For this, you can use the LIKE operator along with CONCAT() function. Let us first create a table −
mysql> create table DemoTable
(
   Value text
);
Query OK, 0 rows affected (0.63 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('MySQL');
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable values('Is');
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable values('Relational');
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable values('Database');
Query OK, 1 row affected (0.13 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------------+
| Value      | 
+------------+
| MySQL      |
| Is         |
| Relational |
| Database   |
+------------+
4 rows in set (0.00 sec)
Following is the query to check if a string contains a word in a column −
Note − Below displays for a single word as a column value. The same works for an entire line or string, wherein you need to find only a word −
mysql> select Value from DemoTable where 'Relational' LIKE concat('%',Value,'%');
This will produce the following output −
+------------+
| Value      |
+------------+
| Relational |
+------------+
1 row in set (0.00 sec)
Firebase - Environment Setup

In this chapter, we will show you how to add Firebase to the existing application. We will need NodeJS. Check the link from the following table, if you do not have it already.
NodeJS and NPM
NodeJS is the platform needed for Firebase development. Checkout our NodeJS Environment Setup.
You can create a Firebase account here.
You can create new app from the dashboard page. The following image shows the app we created. We can click the Manage App button to enter the app.
You just need to create a folder where your app will be placed. Inside that folder, we will need index.html and index.js files. We will add Firebase to the header of our app.
<html>
   <head>
      <script src = "https://cdn.firebase.com/js/client/2.4.2/firebase.js"></script>
      <script type = "text/javascript" src = "index.js"></script>
   </head>
	
   <body>

   </body>
</html>
If you want to use your existing app, you can use Firebase NPM or Bowers packages. Run one of the following command from your apps root folder.
npm install firebase --save

bower install firebase


    60 Lectures 
     5 hours 

 University Code

    28 Lectures 
     2.5 hours 

 Appeteria

    85 Lectures 
     14.5 hours 

 Appeteria

    46 Lectures 
     2.5 hours 

 Gautham Vijayan

    13 Lectures 
     1.5 hours 

 Nishant Kumar

    85 Lectures 
     16.5 hours 

 Rahul Agarwal
 Print
 Add Notes
 Bookmark this page
SQLite - DELETE Query

SQLite DELETE Query is used to delete the existing records from a table. You can use WHERE clause with DELETE query to delete the selected rows, otherwise all the records would be deleted.
Following is the basic syntax of DELETE query with WHERE clause.
DELETE FROM table_name
WHERE [condition];

You can combine N number of conditions using AND or OR operators.
Consider COMPANY table with the following records.
ID          NAME        AGE         ADDRESS     SALARY
----------  ----------  ----------  ----------  ----------
1           Paul        32          California  20000.0
2           Allen       25          Texas       15000.0
3           Teddy       23          Norway      20000.0
4           Mark        25          Rich-Mond   65000.0
5           David       27          Texas       85000.0
6           Kim         22          South-Hall  45000.0
7           James       24          Houston     10000.0
Following is an example, which will DELETE a customer whose ID is 7.
sqlite> DELETE FROM COMPANY WHERE ID = 7;
Now COMPANY table will have the following records.
ID          NAME        AGE         ADDRESS     SALARY
----------  ----------  ----------  ----------  ----------
1           Paul        32          California  20000.0
2           Allen       25          Texas       15000.0
3           Teddy       23          Norway      20000.0
4           Mark        25          Rich-Mond   65000.0
5           David       27          Texas       85000.0
6           Kim         22          South-Hall  45000.0
If you want to DELETE all the records from COMPANY table, you do not need to use WHERE clause with DELETE query, which will be as follows −
sqlite> DELETE FROM COMPANY;
Now, COMPANY table does not have any record as all the records have been deleted by DELETE statement.

    25 Lectures 
     4.5 hours 

 Sandip Bhattacharya

    17 Lectures 
     1 hours 

 Laurence Svekis

    5 Lectures 
     51 mins

 Vinay Kumar
 Print
 Add Notes
 Bookmark this page
Push Down Automata

Theory of Computation
The Pushdown Automata is investigated by Sheila Greibach. It is a part in theoretical computer science which employs a stack. It is called "pushed-down" as it works on the principal of stack i.e., Last In First Out. Always the operation is first performed on the top most element. The push down automata is less capable than a Turning Machine and more capable than a Finite State Machine.
Pushdown automata machine recognizes best for a wider class of language. The context free language is language recognized by pushdown automata. This also plays an important role in determining the organization of computer programs being processed by a compiler.
These are the following components of Pushdown automata -
Input tape: The input tape is divided in many cells. The input head is read-only and may only move from left to right, each cell in turn.
Finite control: The finite control has some pointer which focuses the current symbol which is to be read.
Stack: In stack, elements are inserted and removed from only one end. In PDA, the stack is utilized to store the items temporarily.
The formal definition of a Pushdown Automata is defined as -
(Q,Σ,Γ,δ,q0,Z0,F)
Q- It is the finite set of states, Σ - finite set of input alphabet, Γ - finite set of stack alphabet, δ - transition function, Q x (Σ ∪ ∈) x Γ x Q x Γ* q0 - start state, Z0 - initial pushdown symbol, F - the set of finite state.
These are the some symbols used for connecting pairs of ID's.
The Instantaneous description is called as an informal notation, and clarifies how a Push down automata (PDA) computes a given input string and makes a decision whether that string is accepted or rejected. The instantaneous description of Pushdown Automata is represented by -
(q,w,s)
q - current state, w - unconsumed part or remaining input, s - stack contents, top at the left. 
Here is the example of Pushdown Automata -
where δu000e contains the following transitions -
C# program to sort an array in descending order

Initialize the array.
int[] myArr = new int[5] {98, 76, 99, 32, 77};
Compare the first element in the array with the next element to find the largest element, then the second largest, etc.
if(myArr[i] < myArr[j]) {
   temp = myArr[i];
   myArr[i] = myArr[j];
   myArr[j] = temp;
}
Above, i and j are initially set to.
i=0;
j=i+1;
Try to run the following code to sort an array in descending order.
 Live Demo
using System;
public class Demo {
   public static void Main() {
      int[] myArr = new int[5] {98, 76, 99, 32, 77};
      int i, j, temp;
      Console.Write("Elements: \n");
      for(i=0;i<5;i++) {
         Console.Write("{0} ",myArr[i]);
      }
      for(i=0; i<5; i++) {
         for(j=i+1; j<5; j++) {
            if(myArr[i] < myArr[j]) {
               temp = myArr[i];
               myArr[i] = myArr[j];
               myArr[j] = temp;
            }
         }
      }
      Console.Write("\nDescending order:\n");
      for(i=0; i<5; i++) {
         Console.Write("{0} ", myArr[i]);
      }
      Console.Write("\n\n");
   }
}
Elements:
98 76 99 32 77
Descending order:
99 98 77 76 32
Python - Convert Binary tuple to Integer - GeeksforGeeks

02 Sep, 2020
Given Binary Tuple representing  binary representation of number, convert to integer.
Input : test_tup = (1, 1, 0)Output : 6Explanation : 4 + 2 = 6.
Input : test_tup = (1, 1, 1)Output : 7Explanation : 4 + 2 + 1 = 7.
Method #1 : Using join() + list comprehension + int()
In this, we concatenate the binary tuples in string format using join() and str(), then convert to integer by mentioning base as 2.
Python3
# Python3 code to demonstrate working of # Convert Binary tuple to Integer# Using join() + list comprehension + int()  # initializing tupletest_tup = (1, 1, 0, 1, 0, 0, 1)  # printing original tupleprint("The original tuple is : " + str(test_tup))  # using int() with base to get actual numberres = int("".join(str(ele) for ele in test_tup), 2)   # printing result print("Decimal number is : " + str(res)) 
The original tuple is : (1, 1, 0, 1, 0, 0, 1)
Decimal number is : 105

Method #2 : Using bit shift and | operator
In this we perform left bit shift and use or operator to get binary addition and hence compute the result.
Python3
# Python3 code to demonstrate working of # Convert Binary tuple to Integer# Using bit shift and | operator  # initializing tupletest_tup = (1, 1, 0, 1, 0, 0, 1)  # printing original tupleprint("The original tuple is : " + str(test_tup))    res = 0for ele in test_tup:           # left bit shift and or operator     # for intermediate addition    res = (res << 1) | ele   # printing result print("Decimal number is : " + str(res)) 
The original tuple is : (1, 1, 0, 1, 0, 0, 1)
Decimal number is : 105

Python tuple-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python OOPs Concepts
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
Python program to check whether a number is Prime or not
C++ Program to Compute Cross Product of Two Vectors

This is a C++ program to compute Cross Product of Two Vectors.
Let us suppose,
M = m1 * i + m2 * j + m3 * k
N = n1 * i + n2 * j + n3 * k.
So, cross product = (m2 * n3 – m3 * n2) * i + (m1 * n3 – m3 * n1) * j + (m1 * n1 – m2 * n1) * k
where m2 * n3 – m3 * n2, m1 * n3 – m3 * n1 and m1 * n1 – m2 * n1 are the coefficients of unit vector along i, j and k directions.
Begin
   Declare a function cProduct().
      Declare three vectors v_A[], v_B[], c_P[] of the integer
      datatype.
      c_P[0] = v_A[1] * v_B[2] - v_A[2] * v_B[1].
      c_P[1] = -(v_A[0] * v_B[2] - v_A[2] * v_B[0]).
      c_P[2] = v_A[0] * v_B[1] - v_A[1] * v_B[0].
   Initialize values in v_A[] vector.
   Initialize values in v_B[] vector.
   Initialize c_P[] vector with an integer variable n.
   Print “Cross product:”.
   Call the function cProduct() to perform cross product within v_A[] and
v_B[].
   for (int i = 0; i < n; i++)
      print the value of c_P[] vector.
End.
#include
#define n 3
using namespace std;
void crossProduct(int v_A[], int v_B[], int c_P[]) {
   c_P[0] = v_A[1] * v_B[2] - v_A[2] * v_B[1];
   c_P[1] = -(v_A[0] * v_B[2] - v_A[2] * v_B[0]);
   c_P[2] = v_A[0] * v_B[1] - v_A[1] * v_B[0];
}
int main() {
   int v_A[] = { 7, 6, 4 };
   int v_B[] = { 2, 1, 3 };
   int c_P[n];
   cout << "Cross product:";
   crossProduct(v_A, v_B, c_P);
   for (int i = 0; i < n; i++)
      cout << c_P[i] << " ";
   return 0;
}
Cross product: 14 13 -5
Difference between Write-Output and Write-Host command in PowerShell?

Have we ever wondered, Write-Output and Write-Host both are used to print the strings or the output of the command then what is the difference between them?
PS C:\> Write-Output "Test String"
Test String
PS C:\> Write-Host "Test String"
Test String
The output remains the same.
The first major difference is storing the output using the Pipeline structure. Write-Output and Write-Host both support the pipeline structure for example,
"Test String" | Write-Output
Test String

"Test String" | Write-Host
Test String
The output remains the same.
The first major difference is storing the output using the Pipeline structure. Write-Output and Write-Host both support the pipeline structure for example,
"Test String" | Write-Output
Test String

"Test String" | Write-Host
Test String
But when we store the output then it shows the difference between two commands.
$a = "Test String" | Write-Output

Get-Variable a

Name Value
---- -----
a Test String


$b = "Test String" | Write-Host
Test String

Get-Variable b

Name Value
---- -----
b
In the above example, when the string output is stored into a variable, Write-Output can store it while Write-Host displays the output in the console and the output is not assigned to a variable because Write-Host produces output directly to the console while Write-Output produces and store the output inside the variable. That is the reason it is not recommended to use the Write-Host for the PowerShell remoting if scripter is not aware of the remote host having the console working properly or not.
Another difference is, with the Write-Host cmdlet, you can decorate the output with background and foreground (text) color and this is not possible in Write-Output command.
Write-Host "Dark green backgound with White text" -BackgroundColor DarkGreen -ForegroundColor White

Dark green backgound with White text
Difference between %p and %x in C/C++

Here we will see what are the differences between %p and %x in C or C++. The %p is used to print the pointer value, and %x is used to print hexadecimal values. Though pointers can also be displayed using %u, or %x. If we want to print some value using %p and %x then we will not feel any major differences. The only difference that can be noticed is that the %p will print some leading zeros, but %x doesn’t.
#include<stdio.h>
main() {
   int x = 59;
   printf("Value using %%p: %p\n", x);
   printf("Value using %%x: %x\n", x);
}
Value using %p: 000000000000003B
Value using %x: 3b
Tryit Editor v3.7

Tryit: Different text transformations
How to add rounded corners to a button with CSS?

To add rounded corners to a button, use the border-radius property.
You can try to run the following code to add rounded corners −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         .button {
            background-color: yellow;
            color: black;
            text-align: center;
            font-size: 15px;
            padding: 20px;
            border-radius: 15px;
         }
      </style>
   </head>
   <body>
      <h2>Result</h2>
      <p>Click below for result:</p>
      <button class = "button">Result</button>
   </body>
</html>
How to find items in one list that are not in another list in C#?

LINQ Except operator comes under Set operators category in LINQ
The Except() method requires two collections and find those elements which are not present in second collection
Except extension method doesn't return the correct result for the collection of complex types.
 Live Demo
using System;
using System.Collections.Generic;
using System.Linq;
namespace DemoApplication {
   class Program {
      static void Main(string[] args) {
         List<string> animalsList1 = new List<string> {
            "tiger", "lion", "dog"
         };
         Console.WriteLine($"Values in List1:");
         foreach (var val in animalsList1) {
            Console.WriteLine($"{val}");
         }
         List<string> animalsList2 = new List<string> {
            "tiger", "cat", "deer"
         };
         Console.WriteLine($"Values in List2:");
         foreach (var val in animalsList1) {
            Console.WriteLine($"{val}");
         }
         var animalsList3 = animalsList1.Except(animalsList2);
         Console.WriteLine($"Value in List1 that are not in List2:");
         foreach (var val in animalsList3) {
            Console.WriteLine($"{val}");
         }
         Console.ReadLine();
      }
   }
}
The output of the above code is
Values in List1:
tiger
lion
dog
Values in List2:
tiger
lion
dog
Value in List1 that are not in List2:
lion
dog
 Live Demo
using System;
using System.Collections.Generic;
using System.Linq;
namespace DemoApplication {
   class Program {
      static void Main(string[] args) {
         List<Fruit> fruitsList1 = new List<Fruit> {
            new Fruit {
               Name = "Apple",
               Size = "Small"
            },
            new Fruit {
               Name = "Orange",
               Size = "Small"
            }
         };
         Console.WriteLine($"Values in List1:");
         foreach (var val in fruitsList1) {
            Console.WriteLine($"{val.Name}");
         }
         List<Fruit> fruitsList2 = new List<Fruit> {
            new Fruit {
               Name = "Apple",
               Size = "Small"
            },
            new Fruit {
               Name = "Mango",
               Size = "Small"
            }
         };
         Console.WriteLine($"Values in List2:");
         foreach (var val in fruitsList2) {
            Console.WriteLine($"{val.Name}");
         }
         var fruitsList3 = fruitsList1.Where(f1 => fruitsList2.All(f2 => f2.Name != f1.Name));
         Console.WriteLine($"Values in List1 that are not in List2:");
         foreach (var val in fruitsList3) {
            Console.WriteLine($"{val.Name}");
         }
         Console.ReadLine();
      }
   }
   public class Fruit {
      public string Name { get; set; }
      public string Size { get; set; }
   }
}
The output of the above code is
Values in List1:
Apple
Orange
Values in List2:
Apple
Mango
Values in List1 that are not in List2:
Orange
How to get a list of all the fonts currently available for Matplotlib?

To get a list of all the fonts currently available for matplotlib, we can use the font_manager.findSystemFonts() method.
Print a statement.
Print a statement.
Use font_manager.findSystemFonts() method to get a list of fonts availabe.
Use font_manager.findSystemFonts() method to get a list of fonts availabe.
from matplotlib import font_manager

print("List of all fonts currently available in the matplotlib:\n")
print(*font_manager.findSystemFonts(fontpaths=None, fontext='ttf'), sep="\n")
/usr/share/fonts/truetype/Nakula/nakula.ttf
/usr/share/fonts/truetype/ubuntu/Ubuntu-L.ttf
/usr/share/fonts/truetype/tlwg/Loma-BoldOblique.ttf
.................................................................
............................................................................
.................................................................................
........
/usr/share/fonts/truetype/lohit-malayalam/Lohit-Malayalam.ttf
/usr/share/fonts/truetype/tlwg/TlwgTypist-Oblique.ttf
/usr/share/fonts/truetype/liberation2/LiberationMono-Bold.ttf
Git Pull Branch from GitHub

Now continue working on our new branch in our local Git.
Lets pull from our GitHub repository again so that our code is up-to-date:
git pull
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 851 bytes | 9.00 KiB/s, done.
From https://github.com/w3schools-test/hello-world
 * [new branch]      html-skeleton -> origin/html-skeleton
Already up to date.
Now our main branch is up todate. And we can see that there is a new 
branch 
available on GitHub.
Do a quick status check:
git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
And confirm which branches we have, and where we are working at the moment:
git branch
* master
So, we do not have the new branch on our local Git. But 
we know it is available on 
GitHub. So we can use the -a option to see all local and remote branches:
git branch -a
* master
  remotes/origin/html-skeleton
  remotes/origin/master
Note: branch -r is for remote branches only.
We see that the branch html-skeleton is available remotely, but not on our local git. Lets check it out:
git checkout html-skeleton
Switched to a new branch 'html-skeleton'
Branch 'html-skeleton' set up to track remote branch 'html-skeleton' from 'origin'.
And check if it is all up to date:
git pull
Already up to date.
Which branches do we have now, and where are we working from?
git branch
* html-skeleton
  master
Now, open your favourite editor and confirm that the changes from the GitHub branch carried over.
That is how you pull a GitHub branch to your local Git.
List all local and remote branches of the current Git.
git  


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.
Max() and Min() function in MS Access - GeeksforGeeks

02 Sep, 2020
1. Max() Function :max() function return the maximum value of given set. In the function a query is passed and in the eligible records which value will be maximum that will return as result. A expression will be pass as parameter and it will return the maximum value in the expression.
Syntax :
Max (expression)
Demo Database for example :
Table name : student
Example-1 :
SELECT Max(Marks) AS marks 
FROM student;
Output –
Example-2 :
SELECT Max(Marks) AS marks 
FROM student
where Marks<80;
Output –
2. Min() Function :min() function works like max() function but it will return the minimum value of the expression. In this function a query will be passed as parameter and it will return the minimum record.
Syntax :
 Min(expression)
Example-1 :
SELECT Min(Marks) AS marks 
FROM student;
Output –
Example-2 :
SELECT Min(Marks) AS marks 
FROM student
where Marks>50;
Output –
DBMS-SQL
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Update Multiple Columns in Single Update Statement 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 | Subquery
How to Write a SQL Query For a Specific Date Range and Date Time?
SQL Query to Convert VARCHAR to INT
SQL Query to Delete Duplicate Rows
SQL Query to Compare Two Dates
Window functions in SQL
How to use diff command in linux

The diff command analyzes line by line and displays a list of changes between two files. As a special case, diff compares a copy of standard input to itself. This article describes “How to use diff command in Linux.
Recognize the changes between one version of a file
Compare two configuration or program files
Create a patch file which can be applied with the Linux / Unix program patch
For example, we have two files as file.txt and file1.txt. The data has been inserted into file.txt as shown below –
I need to buy apples.
I need to run the laundry.
I need to wash the dog.
I need to get the car detailed.
file1.txt contains the data as shown below
I need to buy apples.
I need to do the laundry.
I need to wash the car.
I need to get the dog detailed.
Use the diff command to compare both the files as shown below –
linux@linux:~$ diff /home/linux/Desktop/file.txt /home/linux/Desktop/file1.txt
The above command should give the result as shown below –
linux@linux:~$ diff /home/linux/Desktop/file.txt /home/linux/Desktop/file1.txt
2,4c2,4
< I need to run the laundry.
< I need to wash the dog.
< I need to get the car detailed. --- > I need to do the laundry.
> I need to wash the car.
> I need to get the dog detailed.
The options of the result should be like this –
a -Added the text to file
 c -Changes are made in the file
 d -Deletion operation is performed
 <  Lines from the first file
 >  Lines from the second file
From the output, 2,4c2,4 means “Lines 2 through 4 in the first file needs to be changed in order to match lines 2 through 4 in the second file”
Let’s look at another example, two text files should be like this-
file.txt
I need to go to the store.
I need to buy some apples.
When I get home, I'll wash the dog.
file1.txt
I need to go to the store.
I need to buy some apples.
Oh yeah, I also need to buy grated cheese.
When I get home, I'll wash the dog.
Use the diff command to compare both files. The command should be like this-
$ diff /home/linux/Desktop/file.txt /home/linux/Desktop/file1.txt
The above command should give the result as shown below –
2a3
> Oh yeah, I also need to buy grated cheese.
From the output, 2a3 means “After line 2 in the first file, a line needs to be added: line 3 from the second file”.
Congratulations! Now, you know “How to use diff command in Linux”. We’ll learn more about these types of commands in our next Linux post. Keep reading!
When will be an IllegalStateException (unchecked) thrown in Java?

An IllegalStateException is an unchecked exception in Java. This exception may arise in our java program mostly if we are dealing with the collection framework of java.util.package. There are many collections like List, Queue, Tree, Map out of which List and Queues (Queue and Deque) to throw this IllegalStateException at particular conditions.
An IllegalStateExceptionexception will be thrown, when we try to invoke a particular method at an inappropriate time.
In case of java.util.List collection, we use next() method of the ListIterator interface to traverse through the java.util.List. If we call the remove() method of the ListIterator interface before calling the next() method then this exception will be thrown as it will leave the List collection in an unstable state.
If we want to modify a particular object we will use the set() method of the ListIterator interface
In the case of queues, if we try to add an element to a Queue, then we must ensure that the queue is not full. If this queue is full then we cannot add that element, then it will cause an IllegalStateExceptionexception to be thrown.
Live Demo
import java.util.*;
public class IllegalStateExceptionTest {
   public static void main(String args[]) {
      List list = new LinkedList();
      list.add("Welcome");
      list.add("to");
      list.add("Tutorials");
      list.add("Point");
      ListIterator lIterator = list.listIterator();
      lIterator.next();
      lIterator.remove();// modifying the list
      lIterator.set("Tutorix");
      System.out.println(list);
   }
}
Exception in thread "main" java.lang.IllegalStateException
        at java.util.LinkedList$ListItr.set(LinkedList.java:937)
        at IllegalStateExceptionTest.main(IllegalStateExceptionTest.java:15)
How to install PIP in Linux? - GeeksforGeeks

20 Jan, 2020
Prerequisite: Python Language Introduction Before we start with how to install pip for Python on Linux, let’s first go through the basic introduction to Python. Python is a widely-used general-purpose, high-level programming language. Python is a programming language that lets you work quickly and integrate systems more efficiently.
PIP is a package management system used to install and manage software packages/libraries written in Python. These files are stored in a large “on-line repository” termed as Python Package Index (PyPI).
pip uses PyPI as the default source for packages and their dependencies. So whenever you type:
pip install package_name
pip will look for that package on PyPI and if found, it will download and install the package on your local system.
pip can be downloaded and installed using the terminal in Linux by going through the following command:
sudo apt-get install python3-pip python-dev
Beginning the installation:
Getting Started:
Providing Disk Space:
Downloading Libraries:
Unpacking File bundles:
Finishing up the Installation:
One can easily verify if the pip has been installed correctly by performing a version check on the same. Just go to the command-line and execute the following command:
pip3 --version
python-basics
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Check if element exists in list in Python
Selecting rows in pandas DataFrame based on conditions
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python | Get unique values from a list
Python | Pandas dataframe.groupby()
What is a pageContext Object in JSP?

The pageContext object is an instance of a javax.servlet.jsp.PageContext object. The pageContext object is used to represent the entire JSP page.
This object is intended as a means to access information about the page while avoiding most of the implementation details.
This object stores references to the request and response objects for each request. The application, config, session, and out objects are derived by accessing attributes of this object.
The pageContext object also contains information about the directives issued to the JSP page, including the buffering information, the errorPageURL, and page scope.
The PageContext class defines several fields, including PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, and APPLICATION_SCOPE, which identify the four scopes. It also supports more than 40 methods, about half of which are inherited from the javax.servlet.jsp.JspContext class.
One of the important methods is removeAttribute. This method accepts either one or two arguments. For example, pageContext.removeAttribute ("attrName") removes the attribute from all scopes, while the following code only removes it from the page scope −
pageContext.removeAttribute("attrName", PAGE_SCOPE);
Is it better to have one big JavaScript file or multiple light files?

To avoid multiple server requests, group your JavaScript files into one. Whatever you use for performance, try to minify JavaScript to improve the load time of the web page.
If you are using single page application, then group all the scripts in a single file.
If you are using multiple files, then minify all of your scripts and separate them into categories.
<script src =”/js/core.js”> - Place JavaScript to be used in every page.
This can be the core script of the file.
<script src =”/js/plugins.js”> - Place your plugins here
Rest, add other scripts in a JavaScript file. It’s good to maintain it in different files.
Tryit Editor v3.7

Padding & Spacing
Tryit: HTML table - cellpadding
regexp_replace(string, pattern, replacement)

presto:default> SELECT regexp_replace('1a 2b 3c 6f', '(\d+)([abc]) ', 'aa$2 ') 
as expression;
 expression 
---------------- 
 aaa aab aac 6f 
 (1 row)

Replace the instance of the string matched for the expression with the pattern and replacement string ‘aa’.

    46 Lectures 
     3.5 hours 

 Arnab Chakraborty

    23 Lectures 
     1.5 hours 

 Mukund Kumar Mishra

    16 Lectures 
     1 hours 

 Nilay Mehta

    52 Lectures 
     1.5 hours 

 Bigdata Engineer

    14 Lectures 
     1 hours 

 Bigdata Engineer

    23 Lectures 
     1 hours 

 Bigdata Engineer
 Print
 Add Notes
 Bookmark this page
Selenium and Headless Environment.

We can execute Selenium in a headless environment. The headless execution is a new trend followed in industry today since it is fast and supports more than one browser.
Firefox in headless mode, can be run once we configure the geckodriver path. We shall then use the FirefoxOptions class, and send the headless knowledge to the browser with setHeadless method and pass true as a parameter to it.
FirefoxOptions o = new FirefoxOptions();
o.setHeadless(true);
WebDriver driver = new FirefoxDriver(o);
Code Implementation.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import java.util.concurrent.TimeUnit;
public class HeadlessFirefox{
   public static void main(String[] args) {
      System.setProperty("webdriver.gecko.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\geckodriver.exe");
      //FirefoxOptions object creation
      FirefoxOptions o = new FirefoxOptions();
      //set true to headless mode
      o.setHeadless(true);
      // add options parameter to Firefox driver
      WebDriver driver = new FirefoxDriver(o);
      // wait of 5 seconds
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      driver.get("https://www.tutorialspoint.com/questions/index.php");
      // get page title
      System.out.println("Page Title in headless mode: " + driver.getTitle());
   }
}