code-rag-bench/online-tutorials huggingface dataset:
Bootstrap 5 | Close button

05 May, 2022
Bootstrap 5 provides a new component which is a Close button which can be used for dismissing content like modals and alerts. It can be included in the webpage using bootstrap.js or bootstrap.min.js. This component can be combined with models, alerts, and popovers. Disabled close buttons have pointer-events: none; applied to, preventing hover and active states from triggering. 
Example:
HTML
<!DOCTYPE html><html><head>    <title>        Bootstrap 5 | Close button    </title>    <!-- Load Bootstrap -->    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css"        integrity="sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I"        crossorigin="anonymous">    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"        integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"        crossorigin="anonymous">    </script>    <script src="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js"        integrity="sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/"        crossorigin="anonymous">    </script></head><body style="text-align: center;">    <div class="container mt-3">        <h1 style="color: green;">            GeeksforGeeks        </h1>        Close icon        <button type="button" class="close"            aria-label="Close">            <span aria-hidden="true">×</span>        </button>        <br/>        Close disabled icon        <button type="button" class="close"            aria-label="Close" disabled>            <span aria-hidden="true">×</span>        </button>    </div></body></html>
Output:
 Reference: https://v5.getbootstrap.com/docs/5.0/components/close-button/
sahilintern
Bootstrap-Misc
Bootstrap
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to change navigation bar color in Bootstrap ?
Form validation using jQuery
How to set Bootstrap Timepicker using datetimepicker library ?
How to pass data into a bootstrap modal?
How to align navbar items to the right in Bootstrap 4 ?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Generating all possible permutations of array in JavaScript

We are given an array of distinct integers, and we are required to return all possible permutations of the integers in the array.
For example −
If the input array is −
const arr = [1, 2, 3];
Then the output should be −
const output = [
   [1,2,3],
   [1,3,2],
   [2,1,3],
   [2,3,1],
   [3,1,2],
   [3,2,1]
];
The code for this will be −
const arr = [1, 2, 3];
const findPermutations = (arr = []) => {
   let res = []
   const helper = (arr2) => {
      if (arr2.length==arr.length)
      return res.push(arr2)
      for(let e of arr)
      if (!arr2.includes(e))
      helper([...arr2, e])
   };
   helper([])
   return res;
};
console.log(findPermutations(arr));
And the output in the console will be −
[
   [ 1, 2, 3 ],
   [ 1, 3, 2 ],
   [ 2, 1, 3 ],
   [ 2, 3, 1 ],
   [ 3, 1, 2 ],
   [ 3, 2, 1 ]
]
strstr() in C/C++

19 Nov, 2019
In C++, std::strstr() is a predefined function used for string handling. string.h is the header file required for string functions.
This function takes two strings s1 and s2 as an argument and finds the first occurrence of the sub-string s2 in the string s1. The process of matching does not include the terminating null-characters(‘\0’), but function stops there.
Syntax:
char *strstr (const char *s1, const char *s2);

Parameters:
s1: This is the main string to be examined.
s2: This is the sub-string to be searched in s1 string.

Return Value: This function returns a pointer points to the first character of the found s2 in s1 otherwise a null pointer if s2 is not present in s1. If s2 points to an empty string, s1 is returned.
Example:
// CPP program to illustrate strstr()#include <string.h>#include <stdio.h>  int main(){    // Take any two strings    char s1[] = "GeeksforGeeks";    char s2[] = "for";    char* p;      // Find first occurrence of s2 in s1    p = strstr(s1, s2);      // Prints the result    if (p) {        printf("String found\n");        printf("First occurrence of string '%s' in '%s' is '%s'", s2, s1, p);    } else        printf("String not found\n");      return 0;}
Output:
String found
First occurrence of string 'for' in 'GeeksforGeeks' is 'forGeeks'

Application : Replace a string with anotherIn this example with the help of strstr() function we first searches for the occurrence of STL sub-string in s1 and after that replaces that word with Strings.
// CPP program to illustrate strstr()#include <string.h>#include <stdio.h>  int main(){    // Take any two strings    char s1[] = "Fun with STL";    char s2[] = "STL";    char* p;      // Find first occurrence of s2 in s1    p = strstr(s1, s2);      // Prints the result    if (p) {        strcpy(p, "Strings");        printf("%s", s1);    } else        printf("String not found\n");      return 0;}
Output:
Fun with Strings

This article is contributed by Akash Gupta. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
nidhi_biet
cpp-strings-library
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Writing First C++ Program - Hello World Example
Basic Input / Output in C++
Functions that cannot be overloaded in C++
Switch Statement in C/C++
Polymorphism in C++
Queue in C++ Standard Template Library (STL)
std::string class in C++
Sorting a vector in C++
Friend class and function in C++
Pair in C++ Standard Template Library (STL)
Ruby | Array compact() operation

08 Jan, 2020
Array#compact () : compact () is a Array class method which returns the array after removing all the ‘nil’ value elements (if any) from the array.
Syntax:  Array.compact()

Parameter:  Array to remove the 'nil' value from. 

Return:  removes all the nil values from the array. 

Code #1 : Example for compact() method
# Ruby code for compact() method# showing how to remove nil values  # declaring arraya = [18, 22, 33, nil, 5, 6]  # declaring arrayb = [5, 4, nil, 1, 88, 9]  # declaring arrayc = [18, 22, nil, 40, 50, 6]  # removing nil value from arrayputs "removing nil value : #{a.compact}\n\n"  # removing nil value from arrayputs "removing nil value : #{b.compact}\n\n"  # removing nil value from arrayputs "removing nil value : #{c.compact}\n\n"
Output :
removing nil value : [18, 22, 33, 5, 6]

removing nil value : [5, 4, 1, 88, 9]

removing nil value : [18, 22, 40, 50, 6]

Code #2 : Example for compact() method
# Ruby code for compact() method# showing how to remove nil values  # declaring arraya = ["abc", "nil", "dog"]  # declaring arrayb = ["cow", nil, "dog"]  # declaring arrayc = ["cat", nil, nil]  # removing nil value from arrayputs "removing nil value : #{a.compact}\n\n"  # removing nil value from arrayputs "removing nil value : #{b.compact}\n\n"  # removing nil value from arrayputs "removing nil value : #{c.compact}\n\n"
Output :
removing nil value : ["abc", "nil", "dog"]

removing nil value : ["cow", "dog"]

removing nil value : ["cat"]

Ruby Array-class
Ruby Collections
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Ruby | Array sample() function
Instance Variables in Ruby
Ruby | String empty? Method
Ruby | String concat Method
Ruby | unless Statement and unless Modifier
Ruby | Hash key() function
Ruby Integer times function with example
Ruby | Operators
Lambda Function - Ruby
Ruby | String reverse Method
Hide content with Bootstrap

To hide content with Bootstrap, use the .hidden class in Bootstrap. You can try to run the following code to hide content:
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "row" style = "padding: 91px 100px 19px 50px;">
         <div class = "show" style = "left-margin:10px; width:300px; background-color:#ccc;">
            Content is visible.
         </div>
         <div class = "hidden" style = "width:200px; background-color:#ccc;">
            Content is hidden.
         </div>
      </div>
   </body>
</html>
How to combine the levels of a factor variable in an R data frame?

An R data frame can have numeric as well as factor variables. It has been seen that, factor levels in the raw data are recorded as synonyms even in different language versions but it is rare. For example, a factor variable can have hot and cold as levels but it is possible that hot is recorded as garam by a Hindi native speaker because garam is Hindi form of hot. Therefore, we need to combine the similar levels into one so that we do not have unnecessary factor levels for a variable.
Consider the below data frame −
set.seed(109)
x1<-rep(c("Sweet","Meetha","Bitter","Salty"),times=5)
x2<-sample(1:100,20)
x3<-rpois(20,5)
df1<-data.frame(x1,x2,x3)
df1
   x1 x2 x3
1 Sweet 8 4
2 Meetha 22 6
3 Bitter 25 3
4 Salty 85 10
5 Sweet 90 13
6 Meetha 10 0
7 Bitter 55 7
8 Salty 92 7
9 Sweet 95 4
10 Meetha 31 4
11 Bitter 5 4
12 Salty 56 6
13 Sweet 32 4
14 Meetha 78 6
15 Bitter 16 10
16 Salty 48 9
17 Sweet 49 4
18 Meetha 35 4
19 Bitter 37 9
20 Salty 11 8
Since Meetha is the Hindi version of Sweet, we might want to convert Meetha to Sweet and it can be done as shown below −
levels(df1$x1)[levels(df1$x1)=="Meetha"] <-"Sweet"
df1
x1 x2 x3
1 Sweet 8 4
2 Sweet 22 6
3 Bitter 25 3
4 Salty 85 10
5 Sweet 90 13
6 Sweet 10 0
7 Bitter 55 7
8 Salty 92 7
9 Sweet 95 4
10 Sweet 31 4
11 Bitter 5 4
12 Salty 56 6
13 Sweet 32 4
14 Sweet 78 6
15 Bitter 16 10
16 Salty 48 9
17 Sweet 49 4
18 Sweet 35 4
19 Bitter 37 9
20 Salty 11 8
Let’s have a look at another example −
ID <-1:20
Class<-rep(c("First","Second","Third","Fourth","One"),each=4)
df2<-data.frame(ID,Class)
df2
ID Class
1 1 First
2 2 First
3 3 First
4 4 First
5 5 Second
6 6 Second
7 7 Second
8 8 Second
9 9 Third
10 10 Third
11 11 Third
12 12 Third
13 13 Fourth
14 14 Fourth
15 15 Fourth
16 16 Fourth
17 17 One
18 18 One
19 19 One
20 20 One
levels(df2$Class)[levels(df2$Class)=="One"] <-"First"
df2
ID Class
1 1 First
2 2 First
3 3 First
4 4 First
5 5 Second
6 6 Second
7 7 Second
8 8 Second
9 9 Third
10 10 Third
11 11 Third
12 12 Third
13 13 Fourth
14 14 Fourth
15 15 Fourth
16 16 Fourth
17 17 First
18 18 First
19 19 First
20 20 First
Java 8 | BooleanSupplier Interface with Examples - GeeksforGeeks

10 Oct, 2018
The BooleanSupplier Interface is a part of the java.util.function package which has been introduced since Java 8, to implement functional programming in Java. It represents a function which does not take in any argument but produces a boolean value.
The lambda expression assigned to an object of BooleanSupplier type is used to define its getAsBoolean() which eventually applies the given operation on its argument. It is similar to using an object of type Supplier<Boolean>
The BooleanSupplier interface consists of the only one function:
This method does not take in any value but produces a boolean result.
Syntax:
boolean getAsBoolean()
Return Value: This method returns a boolean value.
Below is the code to illustrate getAsBoolean() method:
Program:
// Java program to illustrate// getAsBoolean() method of// BooleanSupplier Interface  import java.util.function.BooleanSupplier;  public class GFG {    public static void main(String args[])    {          // Create a BooleanSupplier instance        BooleanSupplier sup = () -> true;          // Get the boolean value        // Using getAsBoolean() method        System.out.println(sup.getAsBoolean());    }}
true

Java - util package
Java 8
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
HashMap in Java with Examples
Initialize an ArrayList in Java
Object Oriented Programming (OOPs) Concept in Java
Interfaces 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 Scatter Plot with Multiple Y values for each X

To make a scatter plot with multiple Y values for each X, we can create x and y data points using numpy, zip and iterate them together to create the scatter plot.
Set the figure size and adjust the padding between and around the subplots.
Set the figure size and adjust the padding between and around the subplots.
Create random xs and ys data points using numpy.
Create random xs and ys data points using numpy.
Zip xs and ys. Iterate them together.
Zip xs and ys. Iterate them together.
Make a scatter plot with each x and y values.
Make a scatter plot with each x and y values.
To display the figure, use show() method.
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
xs = np.random.rand(100)
ys = np.random.rand(100)
for x, y in zip(xs, ys):
   plt.scatter(x, y, cmap="copper")
plt.show()
What are the differences between JRadioButton and JCheckBox in Java?

Both JRadioButton and JCheckBox components can extend JToggleButton class, the main difference is that JRadioButton is a group of buttons in which only one button can be selected at a time whereas JCheckBox is a group of checkboxes in which multiple items can be selected at a time.
A JRadioButton is a component that represents an item with a state selected or unselected. Usually, a group of radio buttons is created to provide options to the user, but only
one option can be selected at a time.
JRadioButton will generate an ActionListener, ChangeListener, and ItemListener interfaces.
The radio buttons are often used in a group to display multiple options, therefore, they are used with ButtonGroup class. The ButtonGroup has a property that only one button in a group is selected at a given time and it does not have the visual appearance.
The important methods of JRadioButton are setText(), getText(), setEnabled(),setMnemonic() and etc.
import java.awt.*;
import javax.swing.*;
public class JRadioButtonTest extends JFrame {
   public JRadioButtonTest() {
      super("JRadioButton Test");
      JRadioButton jrb1 = new JRadioButton("Java");
      JRadioButton jrb2 = new JRadioButton("Python");
      JRadioButton jrb3 = new JRadioButton("Scala");
      ButtonGroup group = new ButtonGroup();
      group.add(jrb1);
      group.add(jrb2);
      group.add(jrb3);
      setLayout(new FlowLayout());
      add(jrb1);
      add(jrb2);
      add(jrb3);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setSize(450,375);
      setLocationRelativeTo(null);
      setVisible(true);
   }
   public static void main(String[] args) {
      SwingUtilities.invokeLater(new Runnable() {
         @Override
         public void run() {
            new JRadioButtonTest();
        }
      });
   }
}
A JCheckBox is a component that represents an item which shows a state of selected or unselected. We can change this state by clicking on the checkbox of the component.
A standard JCheckBox component contains a checkbox and a label that describes the purpose of the checkbox.
A JCheckBox can generate either ItemListener or ActionListener interfaces.
The important methods of JCheckBox are setLabel(), getLabel(), setState(), getState() and etc.
import java.awt.*;
import javax.swing.*;
public class JCheckBoxTest extends JFrame {
   JCheckBoxTest() {
      super("JCheckBox Test");
      JLabel lblHobbies = new JLabel("Languages");
      JCheckBox chkSports = new JCheckBox("Java");
      JCheckBox chkMusic = new JCheckBox("Python ",true);
      JCheckBox chkReading = new JCheckBox("Scala");
      setLayout(new FlowLayout());
      add(lblHobbies);
      add(chkSports);
      add(chkMusic);
      add(chkReading);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setSize(450,375);
      setLocationRelativeTo(null);
      setVisible(true);
   }
   public static void main(String[] args) {
      SwingUtilities.invokeLater(new Runnable() {
         @Override
         public void run() {
            new JCheckBoxTest();
         }
      });
   }
}
Auto-complete feature using Trie

We have a Trie, and when a user enters a character, we have to show the matching string the Trie. This feature we call it as auto-completion. For example, if a Trie contains "xyzzzz,""xyz," "xxxyyxzzz" and when the user enter xy, then we have to show them xyzzzz, xyz, etc..,
Steps to achieve the result.
Search for the string using the standard Trie algorithm.
Search for the string using the standard Trie algorithm.
If the string is not present, then return -1.
If the string is not present, then return -1.
If the string is present and is the end of a word in Trie, then print the string.
If the string is present and is the end of a word in Trie, then print the string.
If the matching string doesn't have any node, then return.
If the matching string doesn't have any node, then return.
Else print all the nodes.
Else print all the nodes.
Let's start coding.
# class for Trie Node
   class TrieNode():
   def __init__(self):
# initialising trie node
   self.trie_node = {}
   self.last_node = False
   class Trie():
   def __init__(self):
# initialising the trie
   self.root = TrieNode()
# list to store the words
   self.words = []
   def create_trie(self, keys):
# creating the Trie using data
   for key in keys:
# inserting one key to the trie
   self.insert_node(key)
   def insert_node(self, key):
   node = self.root
for obj in list(key):
   if not node.trie_node.get(obj):
   # creating a TrieNode
      node.trie_node[obj] = TrieNode()
      node = node.trie_node[obj]
   # making leaf node
   node.last_node = True
   def search(self, key):
# searching for the key
   node = self.root
   is_found = True
for obj in list(key):
   if not node.trie_node.get(obj):
      is_found = False
   break
      node = node.trie_node[obj]
return node and node.last_node and is_found
   def matches(self, node, word):
if node.last_node:
   self.words.append(word)
for obj, n in node.trie_node.items():
   self.matches(n, word + obj)
   def show_auto_completion(self, key):
   node = self.root
   is_found = False
   temp = ''
for obj in list(key):
   # checking the word
if not node.trie_node.get(obj):
   is_found = True
break
   temp += obj
   node = node.trie_node[obj]
if is_found:
   return 0
elif node.last_node and not node.trie_node:
   return -1
   self.matches(node, temp)
for string in self.words:
   print(string)
return 1
   # data for the Trie
strings = ["xyz", "xyzzzz", "xyabad", "xyyy", "abc", "abbccc", "xyx", "xyxer",
a"]
   # word for auto completion
   string = "xy"
   status = ["Not found", "Found"]
# instantiating Trie class
   trie = Trie()
# creating Trie using the strings
   trie.create_trie(strings)
# getting the auto completion words for the string from strings
   result = trie.show_auto_completion(string)
if result == -1 or result == 0:
   print("No matches")
If you run the above code, you will get the following result.
xyz
xyzzzz
xyabad
xyyy
xyx
xyxer
MomentJS - Using Locale in Browser

We can start working with locale by including the locale file in script tag. You can get the minified files for all locales from the MomentJS home page as shown below −
The same can be included in your application as shown here −
<html>
   <head>
      <title>MomentJS - Adding locale</title>
      <script type="text/JavaScript" src="https://MomentJS.com/downloads/moment.js"></script>
      <script type="text/JavaScript" src="https://MomentJS.com/downloads/moment-with-locales.js"></script>
      <style>
         div {
            border: solid 1px #ccc;
            padding:10px;
            font-family: "Segoe UI",Arial,sans-serif;
            width: 40%;
         }
      </style>
   </head>
   <body>
      <h1>MomentJS - Adding locale</h1>
      <div style="font-size:25px" id="currentdate"></div>
      <br/>
      <br/>
      <div style="font-size:25px" id="changeddate"></div>
      <script type="text/JavaScript">
         moment.locale("pt");
         var a = moment().format('LLLL');
         moment.locale("hi");
         var b = moment().format('LLLL');
         document.getElementById("currentdate").innerHTML = "Output locale: " + a;
         document.getElementById("changeddate").innerHTML = "Output in hindi locale: " + b;
      </script>
   </body>
</html>
 Print
 Add Notes
 Bookmark this page
List remove(Object obj) method in Java with Examples

11 Dec, 2018
The remove(Object obj) method of List interface in Java is used to remove the first occurrence of the specified element obj from this List if it is present in the List.
Syntax:
boolean remove(Object obj)

Parameters: It accepts a single parameter obj of List type which represents the element to be removed from the given List.
Return Value: It returns a boolean value True after removing the first occurrence of the specified element from the List and otherwise if the element is not present in the List then this method will return False.
Below program illustrate the remove(Object obj) method of List in Java:
Program 1:
// Program to illustrate the// remove(int index) method  import java.util.*;  public class GFG {    public static void main(String[] args)    {          // Declare an empty List of size 5        List<Double> list = new ArrayList<Double>(5);          // Add elements to the list        list.add(5.0);        list.add(10.5);        list.add(15.1);        list.add(20.6);        list.add(25.2);          // Element needed to be removed        double obj = 15.1;          // Initial list        System.out.println("Initial List: " + list);          // remove element        list.remove(obj);          // Final list        System.out.println("Final List: " + list);    }}
Initial List: [5.0, 10.5, 15.1, 20.6, 25.2]
Final List: [5.0, 10.5, 20.6, 25.2]

Program 2:
// Program to illustrate the// remove(int index) method  import java.util.*;  public class GFG {    public static void main(String[] args)    {          // Declare an empty List of size 5        List<String> list = new ArrayList<String>(5);          // Add elements to the list        list.add("Welcome");        list.add("to");        list.add("Geeks");        list.add("for");        list.add("Geeks");          // Element to be removed        String obj = "for";          // Initial list        System.out.println("Initial List: " + list);          // remove element        list.remove(obj);          // Final list        System.out.println("Final List: " + list);    }}
Initial List: [Welcome, to, Geeks, for, Geeks]
Final List: [Welcome, to, Geeks, Geeks]

Note: Be careful while using a List of integers as while passing an integer element to the remove method, the list will treat the method as remove(int index). It will consider the element as index and not actual element.
Reference: https://docs.oracle.com/javase/8/docs/api/java/util/List.html#remove-java.lang.Object-
Java-Collections
Java-Functions
java-list
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TravClan Interview Experience 2021

06 Sep, 2021
TravClan visited my campus in August 2021. They had 2 online rounds and 2 Interviews.
Round 1:
The first round was on google form with simple questions on aptitude and programming.
Round 2 :
The first question was on printing a pattern like :
*
**
***
****
The second question was based on designing an app like dunzo and write its OO’s classes.
The last question was on writing the output of the SQL query.
Round 3: Interview 1
What is OOPS? All conceptsBasic Questions on REACT JS: States, Hooks, etcBasic DSA Questions like what type of data structures will you use for getting top 10 students marks etc.This was a very tough question. He asked me how would you make a get request from C++ and pull any image of a product from Flipkart. I could not solve this. But anyways I was selected for the next round.
What is OOPS? All concepts
Basic Questions on REACT JS: States, Hooks, etc
Basic DSA Questions like what type of data structures will you use for getting top 10 students marks etc.
This was a very tough question. He asked me how would you make a get request from C++ and pull any image of a product from Flipkart. I could not solve this. But anyways I was selected for the next round.
Round 4:Interview 2:
Basic hr questionswhat do you look for in a job?where do you see yourself in a few years?
Basic hr questions
what do you look for in a job?
where do you see yourself in a few years?
Marketing
TravClan
Interview Experiences
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
lvalue and rvalue in C

An lvalue (locator value) represents an object that occupies some identifiable location in memory (i.e. has an address).
rvalues are defined by exclusion. Every expression is either an lvalue or an rvalue, so, an rvalue is an expression that does not represent an object occupying some identifiable location in memory.
For example, An assignment expects an lvalue as its left operand, so the following is valid:
int i = 10;
But this is not:
int i;
10 = i;
This is because i has an address in memory and is a lvalue. While 10 doesn't have an identifiable memory location and hence is an rvalue. So assigning the value of i to 10 doesn't make any sense.
Boolean.ToString(IFormatProvider) Method in C#

The Boolean.ToString() method in C# is used to convert the value of this instance to its equivalent string representation.
The syntax is as follows −
public string ToString (IFormatProvider provider);
Above, the parameter provider is an IFormatProvider object.
Let us now see an example −
 Live Demo
using System;
using System.Globalization;
public class Demo {
   public static void Main(String[] args) {
      bool val1 = true;
      bool val2 = false;
      Console.WriteLine("Value1 (Hashcode) = "+val1.GetHashCode());
      Console.WriteLine("Value1 (TypeCode) = "+val1.GetTypeCode());
      Console.WriteLine("Value2 (Hashcode) = "+val2.GetHashCode());
      Console.WriteLine("Value2 (TypeCode) = "+val2.GetTypeCode());
      CultureInfo provider = new CultureInfo("en-us");
      Console.WriteLine("Value1 = "+val1.ToString(provider));
      Console.WriteLine("Value2 = "+val2.ToString(provider));
   }
}
This will produce the following output −
Value1  (Hashcode) = 1
Value1 (TypeCode) = Boolean
Value2  (Hashcode) = 0
Value2 (TypeCode) = Boolean
Value1 = True
Value2 = False
Let us now see another example −
 Live Demo
using System;
using System.Globalization;
public class Demo {
   public static void Main(String[] args) {
      bool val1 = true;
      bool val2 = false;
      Console.WriteLine("Value1 (Hashcode) = "+val1.GetHashCode());
      Console.WriteLine("Value1 (TypeCode) = "+val1.GetTypeCode());
      Console.WriteLine("Value2 (Hashcode) = "+val2.GetHashCode());
      Console.WriteLine("Value2 (TypeCode) = "+val2.GetTypeCode());
      // changed the culture
      CultureInfo provider = new CultureInfo("fr-FR");
      Console.WriteLine("Value1 = "+val1.ToString(provider));
      Console.WriteLine("Value2 = "+val2.ToString(provider));
   }
}
This will produce the following output −
Value1  (Hashcode) = 1
Value1 (TypeCode) = Boolean
Value2  (Hashcode) = 0
Value2 (TypeCode) = Boolean
Value1 = True
Value2 = False
MomentJS - As ISO 8601 String

This method formats a string to the ISO8601 standard. It gives the timestamp in UTC form.
moment().toISOString();
moment().toISOString(keepOffset);

var a = moment().toISOString();
To avoid the display in UTC form use true in toISOString(true) as shown
var a = moment().toISOString(true);
 Print
 Add Notes
 Bookmark this page
Fade in on Button hover with CSS

You can try to run the following code to fade in on button hover with CSS
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         .btn {
            background-color: orange;
            color: white;
            padding: 10px;
            text-align: center;
            font-size: 16px;
            margin: 5px;
            opacity: 0.5;
            transition: 0.5s;
            display: inline-block;
            text-decoration: none;
            cursor: pointer;
         }
         .btn:hover {
            opacity: 2
         }
      </style>
   </head>
   <body>
      <button class = "btn">Result</button>
   </body>
</html>
Program to find GCD or HCF of two numbers using Middle School Procedure in C++

In this tutorial, we will be discussing a program to find GCD or HCF of two numbers using Middle School Procedure.
For this we will be provided with two numbers. Our task is to find the GCD (greatest common divisor) or HCF (highest common factor) for the given values.
 Live Demo
#include <bits/stdc++.h>
#define MAXFACTORS 1024
using namespace std;
//structure to store factorization
typedef struct{
   int size;
   int factor[MAXFACTORS + 1];
   int exponent[MAXFACTORS + 1];
} FACTORIZATION;
void FindFactorization(int x, FACTORIZATION* factorization){
   int i, j = 1;
   int n = x, c = 0;
   int k = 1;
   factorization->factor[0] = 1;
   factorization->exponent[0] = 1;
   for (i = 2; i <= n; i++) {
      c = 0;
      while (n % i == 0) {
         c++;
         n = n / i;
      }
      if (c > 0) {
         factorization->exponent[k] = c;
         factorization->factor[k] = i;
         k++;
      }
   }
   factorization->size = k - 1;
}
//printing the factors
void DisplayFactorization(int x, FACTORIZATION factorization){
   int i;
   cout << "Prime factor of << x << = ";
   for (i = 0; i <= factorization.size; i++) {
      cout << factorization.factor[i];
      if (factorization.exponent[i] > 1)
         cout << "^" << factorization.exponent[i];
      if (i < factorization.size)
         cout << "*";
      else
         cout << "\n";
   }
}
//gcd using Middle School procedure
int gcdMiddleSchoolProcedure(int m, int n){
   FACTORIZATION mFactorization, nFactorization;
   int r, mi, ni, i, k, x = 1, j;
   FindFactorization(m, &mFactorization);
   DisplayFactorization(m, mFactorization);
   FindFactorization(n, &nFactorization);
   DisplayFactorization(n, nFactorization);
   int min;
   i = 1;
   j = 1;
   while (i <= mFactorization.size && j <= nFactorization.size) {
      if (mFactorization.factor[i] < nFactorization.factor[j])
         i++;
      else if (nFactorization.factor[j] < mFactorization.factor[i])
         j++;
      else{
         min = mFactorization.exponent[i] > nFactorization.exponent[j] ? nFactorization.exponent[j] : mFactorization.exponent[i];
         x = x * mFactorization.factor[i] * min;
         i++;
         j++;
      }
   }
   return x;
}
int main(){
   int m = 10, n = 15;
   cout << "GCD(" << m << ", " << n << ") = " << gcdMiddleSchoolProcedure(m, n);
   return (0);
}
GCD(10, 15) = Prime factor of << x << = 1*2*5
Prime factor of << x << = 1*3*5
5
List consisting of all the alternate elements in Python

In this article, we are going to learn how to get alternate elements from the list. We'll see two different ways to solve the problem.
Follow the below steps to solve the problem in one way.
Initialize the list.
3Iterate over the list and store all the elements from the odd index.
Print the result.
Let's see the code.
 Live Demo
# Initializing the list
numbers = [1, 2, 3, 4, 5]

# finding alternate elements
result = [numbers[i] for i in range(len(numbers)) if i % 2 != 0]

# printing the result
print(result)
If you run the above code, then you will get the following result.
[2, 4]

We'll get all the odd positioned elements using slicing. Follow the below steps to solve the problem.
Initialize the list.
Get element which are in odd index using [1::2] slicing.
Print the result.
Let's see the code.
 Live Demo
# Initializing the list
numbers = [1, 2, 3, 4, 5]

# finding alternate elements
result = numbers[1::2]

# printing the result
print(result)
If you run the above code, then you will get the following result.
[2, 4]

If you have any queries in the article, mention them in the comment section.
How to initialize a vector in C++?

Initialization vector can be done in many ways
Begin
   Declare v of vector type.
   Call push_back() function to insert values into vector v.
   Print “Vector elements:”.
   for (int a : v)
      print all the elements of variable a.
End.
 Live Demo
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
   vector<int> v;
   v.push_back(6);
   v.push_back(7);
   v.push_back(10);
   v.push_back(12);
   cout<<"Vector elements:"<<endl;
   for (int a : v)
      cout << a << " ";
   return 0;
}
Vector elements:
6 7 10 12
Begin
   Create a vector v.
   Initialize vector like array.
   Print the elements.
End.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
int main() {
   vector<int> v{ 1, 2, 3, 4, 5, 6, 7 };
   cout<<"vector elements:"<<endl;
   for (int a : v)
      cout << a << " ";
   return 0;
}
vector elements:
1 2 3 4 5 6 7
Begin
   Create a vector v1.
   Initialize vector v1 by array.
   Initialize vector v2 by v1.
   Print the elements.
End.
 Live Demo
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
   vector<int> v1{ 1, 2, 3, 4, 5, 6, 7 };
   vector<int> v2(v1.begin(), v1.end());
   cout<<"vector elements:"<<endl;
   for (int a : v2)
      cout << a << " ";
   return 0;
}
vector elements:
1 2 3 4 5 6 7
Begin
   Initialize a variable s.
   Create a vector v with size s and all values with 7.
   Initialize vector v1 by array.
   Initialize vector v2 by v1.
   Print the elements.
End.
 Live Demo
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
   int s= 5;
   vector<int> v(s, 7);
   cout<<"vector elements:"<<endl;
   for (int a : v)
      cout << a << " ";
   return 0;
}
vector elements:
7 7 7 7 7
Returning the highest number from object properties value – JavaScript

Suppose, we have an object that contains rating of a property over some criteria like this −
const rating = {
   "overall": 92,
   "atmosphere": 93,
   "cleanliness": 94,
   "facilities": 89,
   "staff": 94,
   "security": 92,
   "location": 88,
   "valueForMoney": 92
}
We are required to write a JavaScript function that takes in one such object and returns the key value pair that has the highest value.
For example, for this very object, the output should be −
const output = {
   "staff": 94
};
Following is the code −
const rating = {
   "overall": 92,
   "atmosphere": 93,
   "cleanliness": 94,
   "facilities": 89,
   "staff": 94,
   "security": 92,
   "location": 88,
   "valueForMoney": 92
}
const findHighest = obj => {
   const values = Object.values(obj);
   const max = Math.max.apply(Math, values);
   for(key in obj){
      if(obj[key] === max){
         return {
            [key]: max
         };
      };
   };
};
console.log(findHighest(rating));
This will produce the following output in console −
{ cleanliness: 94 }
SQL Tryit Editor v1.6

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

To disable the first index, on the click of a button, let us implement for index > 0 i.e. item 2:
System.out.println("Index 0 (First Item) is disabled... ");
comboBox.addItemListener(e -> {
   if (comboBox.getSelectedIndex() > 0) {
      System.out.println("Index = " + comboBox.getSelectedIndex());
   }
});
By implementing above, we have disabled the first item.
The following is an example to disable the first item on a JComboBox:
import javax.swing.*;
public class SwingDemo {
   JFrame frame;
   SwingDemo(){
      frame = new JFrame("ComboBox");
      String Sports[]={"Select","Tennis","Cricket","Football"};
      JComboBox comboBox = new JComboBox(Sports);
      comboBox.setBounds(50, 50,90,20);
      frame.add(comboBox);
      frame.setLayout(null);
      frame.setSize(400,500);
      frame.setVisible(true);
      System.out.println("Index 0 (First Item) is disabled... ");
      comboBox.addItemListener(e -> {
         if (comboBox.getSelectedIndex() > 0) {
            System.out.println("Index = " + comboBox.getSelectedIndex());
         }
      });
   }
   public static void main(String[] args) {
      new SwingDemo();
   }
}
The output is as follows. You can now select all the indexes except index 0 (first item). Let us select the first index i.e. the second item:
Meanwhile, while selecting Tennis above, the following is displayed on Console:
MySQL find/ replace string in fields?

To find/replace string in fields, the syntax is as follows −
update yourTableName
set yourColumnName =REPLACE(yourColumnName,yourOldValue,yourNewValue);
To understand the above syntax, let us create a table. The query to create a table is as follows −
mysql> create table FindReplaceDemo
   -> (
   -> FileId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> FileDirectory text
   -> );
Query OK, 0 rows affected (0.92 sec)
Now you can insert some records in the table using insert command. The query is as follows −
mysql> insert into FindReplaceDemo(FileDirectory) values('C://User//MySQL');
Query OK, 1 row affected (0.19 sec)
mysql> insert into FindReplaceDemo(FileDirectory) values('D://WebsiteImage//image1.jpg');
Query OK, 1 row affected (0.12 sec)
mysql> insert into FindReplaceDemo(FileDirectory) values('E://Java//AdvancedJava');
Query OK, 1 row affected (0.20 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from FindReplaceDemo;
Here is the output −
+--------+------------------------------+
| FileId | FileDirectory                |
+--------+------------------------------+
| 1      | C://User//MySQL              |
| 2      | D://WebsiteImage//image1.jpg |
| 3      | E://Java//AdvancedJava       |
+--------+------------------------------+
3 rows in set (0.00 sec)
Here is the query to find/replace string in fields −
mysql> update FindReplaceDemo
   -> set FileDirectory =REPLACE(FileDirectory,'E://Java//AdvancedJava','E://Java//SpringAndHibernateFramework');
Query OK, 1 row affected (0.12 sec)
Rows matched: 3 Changed: 1 Warnings: 0
Now let us check the table records once again. The query is as follows −
mysql> select *from FindReplaceDemo;
The output is as follows with replaced values −
+--------+---------------------------------------+
| FileId | FileDirectory                         |
+--------+---------------------------------------+
| 1      | C://User//MySQL                       |
| 2      | D://WebsiteImage//image1.jpg          |
| 3      | E://Java//SpringAndHibernateFramework |
+--------+---------------------------------------+
3 rows in set (0.00 sec)
PostgreSQL – Errors and Messages

28 Aug, 2020
In this article, we will look into the Errors in that are inbuilt in PostgreSQL and the process of raising an error in PostgreSQL through RAISE statement and to use the ASSERT statement to insert debugging checks into PL/pgSQL blocks.
To raise an error message user can implement the RAISE statement as follows:
Syntax: RAISE level format;

Let’s explore into the raise statement a bit more. Following the RAISE statement is the level option that specifies the error severity. PostgreSQL provides the following levels:
DEBUG
LOG
NOTICE
INFO
WARNING
EXCEPTION
If users don’t specify the level, by default, the RAISE statement will use the EXCEPTION level that raises an error and stops the current transaction. We will discuss the RAISE EXCEPTION later in the next section.
The format is a string that specifies the message. The format uses percentage ( %) placeholders that will be substituted by the next arguments. The number of placeholders must match the number of arguments, otherwise, PostgreSQL will report the following error message:
[Err] ERROR:  too many parameters specified for RAISE

Example:
The following example illustrates the RAISE statement that reports different messages at the current time.
DO $$ 
BEGIN 
  RAISE INFO 'information message %', now() ;
  RAISE LOG 'log message %', now();
  RAISE DEBUG 'debug message %', now();
  RAISE WARNING 'warning message %', now();
  RAISE NOTICE 'notice message %', now();
END $$;

Output:
Note: Not all messages are reported back to the client, only INFO, WARNING, and NOTICE level messages are reported to the client. This is controlled by the client_min_messages and log_min_messages configuration parameters.
To raise errors, you use the EXCEPTION level after the RAISE statement. Note that the RAISE statement uses the EXCEPTION level by default. Besides raising an error, you can add more detailed information by using the following clause with the RAISE statement:
USING option = expression

The options can be any one of the below:
MESSAGE: set error message text
HINT: provide the hint message so that the root cause of the error is easier to be discovered.
DETAIL:  give detailed information about the error.
ERRCODE: identify the error code, which can be either by condition name or directly five-character SQLSTATE code.
Example 1:
DO $$ 
DECLARE
  email varchar(255) := 'raju@geeksforgeeks.org';
BEGIN 
  -- check email for duplicate
  -- ...
  -- report duplicate email
  RAISE EXCEPTION 'Duplicate email: %', email 
        USING HINT = 'Check the email again';
END $$;

Output:
Example 2:
The following examples illustrate how to raise an SQLSTATE and its corresponding condition:
DO $$ 
BEGIN 
    --...
    RAISE SQLSTATE '2210B';
END $$;
DO $$ 
BEGIN 
    --...
    RAISE invalid_regular_expression;
END $$;

Output:
postgreSQL-managing-database
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
p5.js | noLoop() Function

23 Aug, 2019
The noLoop() function is used to stop the program after executing the draw() function. The loop() function runs the draw() function again and again. If noLoop() function is used in setup() function then it should be the last line inside the block. If noLoop() function is used then it is not possible to change or access the screen inside event handling functions such as mousePressed() or keyPressed().
Syntax:
noLoop()
Below examples illustrate the noLoop() function in p5.js:
Example 1:
function setup() {      // Create canvas of given size  createCanvas(500, 300);      // Set the background color  background('green');      // Use noLoop() function  noLoop();}  function draw() {      // Set the stroke color  stroke('white');      // Set the stroke width  strokeWeight(4);      // Function to draw the line  line(50, 50, 450, 250);    }
Output:
Example 2:
let l = 0;  function setup() {      // Create canvas of given size  createCanvas(500, 300);      // Set the background color  background('green');  }  function draw() {      // Set the stroke color  stroke('white');      l = l + 0.5;  if (l > width) {    l = 0;  }      // Function to draw the line  line(l, 0, l, height);    }  function mousePressed() {  noLoop();}  function mouseReleased() {  loop();}
Output:
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to select a drop-down menu value using Selenium in Python?

11 Oct, 2020
Prerequisite: Browser Automation Using Selenium
Selenium is an effective device for controlling an internet browser through the program. It is purposeful for all browsers, works on all fundamental OS and its scripts are written in numerous languages i.e Python, Java, C#, etc, we will be using Python.
Requirement:
You need to download install chrome driver from here Click Here and set path. 
Working with Drop-down list:
Initially you have to import the Select class and afterward you have to make the case of Select class. After making the case of Select class, you can perform select strategies on that occasion to choose the choices from dropdown list.
Importing Select class:
from selenium.webdriver.support.ui import Select


For selection:
drop=Select(driver.find_element_by_id(' ')

drop.select_by_value(" ")


Step-by-step approach:
Import webdriver from selenium module.
Python3
# Import required modulefrom selenium import webdriver
Import Select class module.
Python3
# Importing Select classfrom selenium.webdriver.support.ui import Select
Using a web page for drop down list(example: URL).
Navigate the id of option bar.
Navigate options value in html web page.
Below is complete program of the above approach:
Python3
# Import required moduleimport timefrom selenium import webdriver  # Import Select classfrom selenium.webdriver.support.ui import Select      # Using chrome driverdriver = webdriver.Chrome()  # Web page urldriver.get("https://fs2.formsite.com/meherpavan/form2/index.html?1537702596407")      # Find id of optionx = driver.find_element_by_id('RESULT_RadioButton-9')drop = Select(x)  # Select by valuedrop.select_by_value("Radio-0")time.sleep(4)driver.close()
Output:
Python-selenium
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Aptitude | Arithmetic Aptitude 5 | Question 5 - GeeksforGeeks

28 Jun, 2021
The product of two numbers is 108 and the sum of their squares is 225. The difference of the number is:
(A) 5(B) 4(C) 3(D) None of theseAnswer: (C)Explanation:
Let the numbers be x and y.
Then xy = 108 and x2 + y2 = 225
(x –y)2 = x2 + y2 – 2xy
(x –y)2 = 225 – 216
(x –y)2 = 9
Therefore (x –y) = 3
Quiz of this Question
Aptitude
Aptitude-Arithmetic Aptitude 5
Arithmetic Aptitude 5
Aptitude
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Puzzle | How much money did the man have before entering the bank?
Aptitude | GATE CS 1998 | Question 49
Order and Ranking Questions & Answers
Puzzle | Splitting a Cake with a Missing Piece in two equal portion
C | C Quiz - 113 | Question 1
Average of Cubes of first N natural numbers
Length of race track based on the final distance between participants
Program to find Surface Area and Volume of Octagonal Prism
Aptitude | Syllogism | Question 3
Puzzle | The Bridge Riddle
How to create a frequency polygon in R?

Frequency polygons are the graphs of the values to understand the shape of the distribution of the values. They are useful in comparing different data sets and visualising cumulative frequency distribution of the data sets. In base R, we can use polygon function to create the frequency polygon but first we should create a line plot for the two variables under consideration.
Consider the below vectors x and y −
set.seed(999)
x<-1:10
y<-sample(2:10,10,replace=TRUE)
Creating the frequency polygon with red color −
plot(x,y,type="l") polygon(c(1,x,10),c(0,y,0),col="red")
Creating the frequency polygon with blue color −
polygon(c(1,x,10),c(0,y,0),col="blue")