code-rag-bench/online-tutorials huggingface dataset:
expr - Unix, Linux Command

expr - Evaluate an expression
expr EXPRESSION
expr OPTION
expr is a command line Unix utility which evaluates an expression and outputs the corresponding value. 
expr evaluates integer or string expressions, including pattern matching regular expressions. 
Most of the challenge posed in writing expressions is preventing the invoking command line shell from acting on characters intended
for expr to process.

The operators available

for integers: addition, subtraction, multiplication, division and modulus
for strings: find regular expression, find a set of characters in a string; in some versions: find substring, length of string
for either: comparison (equal, not equal, less than, etc.)
Example-1:
To perform addition of two numbers:
$ expr 3 + 5
output:
8
Example-2:
To  perform substraction of two numbers:
$ expr 5 - 3
output:
2
Example-3:
To perform multiplication of two numbers ( note: The multiplication operator (*) must be escaped when used in an arithmetic expression with expr )
$ expr 5 \* 3
output:
15
Example-4:
To perform division operation:
$ expr 10 / 2
output:
5
Example-5:
To increament variable :
$ y=10
$ y=`expr $y + 1`
$ echo $y
output:11
Example-6:
To find length of string
a=hello
b=`expr length $a`
echo $b
output:
5
Example-7:
To find the index/position of character in a string
a=hello
b=`expr index $a l`
echo $b
output:
3 (  as letter l is at position 3.)
Example-8:
To find substring of string:
a=hello
b=`expr substr $a 2 3` ( where 2 is position and 3 is length, command is to get substring from position 2 of length 3 characters)
echo $b
output:
ell
Example-9:
The following is an example involving boolean expressions ( |-  or operator ):
$ expr length  "abcdef"  "<"  5  "|"  15  -  4  ">"  8output:1  
Example-10:
The following is an example involving boolean expressions ( & - and operator ):
$ expr length  "abcdef"  "<"  5  "&"  15  -  4  ">"  8output:0

    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Nuts and Bolt Problem

A list of different nuts and another list of bolts are given. Our task is to find the correct match of nuts and bolts from the given list, and assign that nut with the Bolt, when it is matched.
This problem is solved by the quick-sort technique. By taking the last element of the bolt as a pivot, rearrange the nuts list and get the final position of the nut whose bolt is the pivot element. After partitioning the nuts list, we can partition the bolts list using the selected nut. The same tasks are performed for left and right sub-lists to get all matches.
Input:
The lists of locks and keys.
nuts = { ),@,*,^,(,%, !,$,&,#}
bolts = { !, (, #, %, ), ^, &, *, $, @ }
Output:
After matching nuts and bolts:
Nuts:  ! # $ % & ( ) * @ ^
Bolts: ! # $ % & ( ) * @ ^
partition(array, low, high, pivot)
Input: One array, the low and high index, the pivot element.
Output: Final location of pivot element.
Begin
   i := low
   for j in range low to high, do
      if array[j] < pivot, then
         swap array[i] and array[j]
         increase i by 1
      else if array[j] = pivot, then
         swap array[j] and array[high]
         decrease j by 1
   done

   swap array[i] and array[high]
   return i
End
nutAndBoltMatch(nuts, bolts, low, high)
Input: The list of nuts, the list of bolts, lower and higher index of the array.
Output: Display which nut is for which bolt.
Begin
   pivotLoc := partition(nuts, low, high, bolts[high])
   partition(bolts, low, high, nuts[pivotLoc])
   nutAndBoltMatch(nuts, bolts, low, pivotLoc-1)
   nutAndBoltMatch(nuts, bolts, pivotLoc + 1, high)
End
#include<iostream>
using namespace std;

void show(char array[], int n) {
   for(int i = 0; i<n; i++)
      cout << array[i] << " ";
}

int partition(char array[], int low, int high, char pivot) {    //find location of pivot for quick sort
   int i = low;
   for(int j = low; j<high; j++) {
      if(array[j] <pivot) {    //when jth element less than pivot, swap ith and jth element
         swap(array[i], array[j]);
         i++;
      }else if(array[j] == pivot) {    //when jth element is same as pivot, swap jth and last element
         swap(array[j], array[high]);
         j--;
      }
   }
   swap(array[i], array[high]);
   return i;    //the location of pivot element
}

void nutAndBoltMatch(char nuts[], char bolts[], int low, int high) {
   if(low < high) {
      int pivotLoc = partition(nuts, low, high, bolts[high]);   //choose item from bolt to nut partitioning
      partition(bolts, low, high, nuts[pivotLoc]);    //place previous pivot location in bolt also
      nutAndBoltMatch(nuts, bolts, low, pivotLoc - 1);
      nutAndBoltMatch(nuts, bolts, pivotLoc+1, high);
   }
}

int main() {
   char nuts[] = {')','@','*','^','(','%','!','$','&','#'};
   char bolts[] = {'!','(','#','%',')','^','&','*','$','@'};
   int n = 10;
   nutAndBoltMatch(nuts, bolts, 0, n-1);
   cout << "After matching nuts and bolts:"<< endl;
   cout << "Nuts:  "; show(nuts, n); cout << endl;
   cout << "Bolts: "; show(bolts, n); cout << endl;
}
After matching nuts and bolts:
Nuts:  ! # $ % & ( ) * @ ^
Bolts: ! # $ % & ( ) * @ ^
Write a program for Linear Search in Python

Linear Search is a searching technique to search some particular value from an array. This is the simplest searching technique.
In this searching technique,
the value to be searched is compared with all the elements in the array.
the value to be searched is compared with all the elements in the array.
If the value is found, the index of the element is returned.
If the value is found, the index of the element is returned.
If the particular element is not present throughout the array, then return -1 or some relevant string message.
If the particular element is not present throughout the array, then return -1 or some relevant string message.
linearSearch(int array[], int value):
   for i=0 to len(array):
      if(array[i]==value):
         Element is Present
   //outside for loop
   Element Not Present // element not found in the whole array
 Live Demo
def linearSearch(arr,value):
   for i in range(len(arr)):
      if(arr[i]==value):
         return i
   return -1
array=[1,2,3,4,5,6,7,8,9,10]
value=5
a=linearSearch(array,value)
if(a==-1):
   print("Element not present")
else:
   print("Element present at index",a)
Element present at index 4
The worst case time complexity of linear search is O(n). The worst case occurs when the element is present at the last index of the array or not present at all.
The best case time complexity of linear search is O(1). The best case occurs when element is present at the first index of the array.
The worst case complexity of linear search can be improved to O(n/2). This can be done using two pointers, left and right and carrying on two comparisons at a time, hence reducing the worst case time complexity of linear search to O(n/2).
 Live Demo
def linearSearch(arr,value):
   left=0
   right=len(arr)-1
   while(left<=right):
      if(arr[left]==value):
         return left
      elif(arr[right]==value):
         return right
      left+=1
      right-=1
   return -1
array=[1,2,3,4,5,6,7,8,9,10]
value=10
a=linearSearch(array,value)
if(a==-1):
   print("Element not present")
else:
   print("Element present at index",a)
Element present at index 9
In the above example, the element present at the last index, is found in the first iteration itself. Using the first method, it would have taken 10 iterations to find this element.
If the element is not found, the worst case complexity is O(n/2), since the total number of iterations are n/2 in the second method.
Linear search is rarely used since there are better searching algorithms such as binary search which provide better time complexities. Linear search is not efficient for large input array.
How to reshape Pandas Series?

01 Oct, 2020
In this article, we will see how to reshaping Pandas Series. So, for reshaping the Pandas Series we are using reshape() method of Pandas Series object.
Syntax: Pandas.Series.values.reshape((dimension))
Return: return an ndarray with the values shape if the specified shape matches exactly the current shape, then return self (for compat)
Let’s see some of the examples:
Example 1:
Python3
# import pandas libraryimport pandas as pd  # make an arrayarray = [2, 4, 6, 8, 10, 12]  # create a seriesseries_obj = pd.Series(array)  # convert series object into arrayarr = series_obj.values  # reshaping series reshaped_arr = arr.reshape((3, 2))  # show reshaped_arr
Output:
Example 2:
Python3
# import pandas libraryimport pandas as pd  # make an arrayarray = ["ankit","shaurya",         "shivangi", "priya",         "jeet","ananya"]  # create a seriesseries_obj = pd.Series(array)  print("Given Series:\n", series_obj)  # convert series object into arrayarr = series_obj.values  # reshaping series reshaped_arr = arr.reshape((2, 3))  # show print("After Reshaping: \n", reshaped_arr)
Output:
Python pandas-series
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Enumerate() in Python
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Iterate over a list in Python
Introduction To PYTHON
Convert integer to string in Python
How to drop one or multiple columns in Pandas Dataframe
Semantic Web and RDF

12 Sep, 2019
Semantic Web is an extension to the World Wide Web. The purpose of the semantic web is to provide structure to the web and data in general. It emphasizes on representing a web of data instead of web of documents. It allows computers to intelligently search, combine and process the web content based on the meaning that the content has. Three main models of the semantic web are:
Building modelsComputing with KnowledgeExchanging Information
Building models
Computing with Knowledge
Exchanging Information
Building Models:Model is a simplified version or description of certain aspects of the real-time entities. Model gathers information which is useful for the understanding of the particular domain.
Computing Knowledge:Conclusions can be obtained from the knowledge present.Example: If two sentences are given as ‘John is the son of Harry’ and another sentence given is- ‘Hary’s father is Joey’, then the knowledge that can be computed from it is – ‘John is the grandson of Joey’Similarly, another example useful in the understanding of computing knowledge is-‘All A is B’ and ‘All B is C’, then the conclusion that can be drawn from it is – ‘All A are C’ respectively.
Exchanging Information:It is an important aspect. Various communication protocols have been implemented for the exchange of information like the TCP/IP, HTML, WWW. Web Services have also been used for the exchange of the data.
The technologies associated with the semantic web are:
RDF (Resource Description Framework)
OWL (Web Ontology Language)
DL (Description Language)
The query language used is:
SPARQL ( SPARQL Protocol and RDF query language).
SHACL (Shape Constraint Language). SHACL is used for validating the RDF graphs against a set of conditions.
RDF:It is the formal language for describing structured information. The primary goal of RDF is to exchange data on the web while preserving the original meaning of the data. It is a data model that is used to describe resources.For Example Physical Things, Abstract Concepts, Numbers and Strings.RDF allows the processing of information. RDF representation can be in the form of triples and graphs. RDF graph is a directed graph which is used to serve as a description language for data on the world wide web and other electronic networks.Resources are described using triples.Triples capture the relationship between the subject and the object. Triples have a subject, predicate and an object. Triples are enclosed within angular brackets.
Example: Delhi is capital of IndiaThe triple generated from this sentence is:
<Delhi> <capital of> <India>.
, where Delhi is the subject, capital of is the predicate and India is the object.The triples can also be represented in the form of URIs (Uniform Resource Identifier).Example of URI triple:
<http://www.abc.org/subject/Delhi> <http://www.abc.org/predicate/capitalOf> <http://www.abc.org/object/India>.
Every statement is terminated by a full-stop in RDF triple.
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to create multiple dropdown options as a tag in ReactJS?

24 Jan, 2021
Choosing multiple options and creating your own options from the dropdown means allowing the user to choose more than one option from the dropdown and add his own options. Material UI for React has this component available for us and it is very easy to integrate. We can choose multiple options and create multiple options using the following approach.
Creating React Application and Installing Module:
Step 1: Create a React application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:
cd foldername
Step 3: After creating the ReactJS application, Install the material-ui modules using the following command:
npm install @material-ui/core
Project Structure: It will look like the following.
Project Structure
App.js: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
Javascript
import React from 'react'import TextField from '@material-ui/core/TextField';import Chip from '@material-ui/core/Chip';import Autocomplete from '@material-ui/lab/Autocomplete';  const App = () => {    // Sample options for dropdown  const myOptions = ['One', 'Two', 'Three', 'Four', 'Five'];    return (    <div style={{ marginLeft: '40%', marginTop: '60px' }}>      <h3>Greetings from GeeksforGeeks!</h3>      <Autocomplete        multiple        freeSolo        style={{width:500}}        options={myOptions}        defaultValue={[myOptions[2]]}        renderTags={(value: string[], getTagProps) =>          value.map((option: string, index: number) => (            <Chip variant="outlined"              label={option}              {...getTagProps({ index })} />          ))        }        renderInput={(params) => (          <TextField {...params}            variant="outlined"            label="freeSolo"            placeholder="Enter fields" />        )}      />    </div>  );}  export default App
Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output:
In the above example, we have selected One and Two from the options available but also added our own options i.e. Random Number. This is how we can choose and create multiple options using Chip in ReactJS.
JavaScript
ReactJS
Technical Scripter
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas Series.keys()

12 Feb, 2019
Pandas series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index.
Pandas Series.keys() function is an alias for index. It returns the index labels of the given series object.
Syntax: Series.keys()
Parameter : None
Returns : index
Example #1: Use Series.keys() function to return the index labels of the given series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([10, 25, 3, 25, 24, 6])  # Create the Indexindex_ = ['Coca Cola', 'Sprite', 'Coke', 'Fanta', 'Dew', 'ThumbsUp']  # set the indexsr.index = index_  # Print the seriesprint(sr)
Output :
Now we will use Series.keys() function to return the index labels of the given series object.
# return the keysresult = sr.keys()  # Print the resultprint(result)
Output :
As we can see in the output, the Series.keys() function has returned all the index labels of the given series object. Example #2 : Use Series.keys() function to return the index labels of the given series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([11, 21, 8, 18, 65, 84, 32, 10, 5, 24, 32])  # Create the Indexindex_ = pd.date_range('2010-10-09', periods = 11, freq ='M')  # set the indexsr.index = index_  # Print the seriesprint(sr)
Output :
Now we will use Series.keys() function to return the index labels of the given series object.
# return the keysresult = sr.keys()  # Print the resultprint(result)
Output :As we can see in the output, the Series.keys() function has returned all the index labels of the given series object.
Python pandas-series
Python pandas-series-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Your Guide to Web Scrape Quora Q&As | by Yasser Elsedawy | Towards Data Science

In this tutorial, I will show you how to perform web scraping using Anaconda Jupyter notebook and the BeautifulSoup library.
We’ll be scraping Questions and Answers from Quora, and then we will export them to Pandas library dataframe and then to a .CSV file.
Let us get straight down to business, however, if you’re looking on a guide to understand Web Scraping in general, I advise you of reading this article from Dataquest.
Let’s import our libraries
import urllibimport requestsfrom bs4 import BeautifulSoupimport pandas as pd
Insert your Quora URL, an example is shown.
url = ‘https://www.quora.com/Should-I-move-to-London'
Then let’s make a GET request to the web server, which will download the HTML contents of a given web page for us.
page = requests.get(url)
Now, We can use the BeautifulSoup library to parse this page, and extract the text from it. We first have to create an instance of the BeautifulSoup class to parse our document:
soup = BeautifulSoup(page.content, ‘html.parser’)
Then we will create Pandas DataFrame to contain our Q&As wanted.
df = pd.DataFrame({‘question’: [],’answers’:[]})
It’s now time to choose the Q&As classes from the web page, classes are used when scraping to specify specific elements we want to scrape.
question = soup.find(‘span’, {‘class’: ‘ui_qtext_rendered_qtext’})answers = soup.find_all(‘div’, attrs={‘class’: ‘ui_qtext_expanded’})
And then we can conclude by adding the results to our DataFrame created before.
for answer in answers:     df = df.append({‘question’: question.text,         ‘answers’: answer.text          }, ignore_index=True)df
Time to export the results to a CSV file.
df.to_csv(‘One_URLs.csv’)
This time we will work together to scrape more than one page in the same time. The process is almost identical with relative changes.
Start by importing your libraries
import urllibimport requestsfrom bs4 import BeautifulSoupimport pandas as pd
Add all the URLs that you need, we will have 2 at this time
url = [‘https://www.quora.com/What-are-best-places-to-relocate-and-settle-in-UK', ‘https://www.quora.com/Should-I-relocate-to-the-UK']
Create our DataFrame
df = pd.DataFrame({‘question’: [],’answers’:[]})
Now, we will do a for loop that will iterate over the two URLs to do the same process and then it can save our results to a DataFrame.
for i in url:   page = requests.get(i)   soup = BeautifulSoup(page.content, “html.parser”)   question = soup.find(‘span’,             {‘class’:      ‘ui_qtext_rendered_qtext’})   answers = soup.find_all(‘div’,                 attrs={‘class’:    ‘ui_qtext_expanded’})   for answer in answers:        df = df.append({‘question’: question.text,          ‘answers’: answer.text            }, ignore_index=True)df
Now, let’s export the DataFrame to a CSV file.
df.to_csv(‘Two_URLs.csv’)
You should now have a good understanding of how to scrape and extract data from Quora. A good next step for you if you are familiar a bit with web scraping it to pick a site and try some web scraping on your own.
How to quit/ exit from MySQL stored procedure?

We can quit/ exit from MySQL stored procedure with the help of the LEAVE command.
The following is the syntax.
Leave yourLabelName;

The following is an example. Here, we are creating a new procedure.
mysql> delimiter //
mysql> CREATE PROCEDURE ExitQuitDemo2(IN Var1 VARCHAR(20))
   -> proc_Exit:BEGIN
   -> IF Var1 IS NULL THEN
   -> LEAVE proc_Exit;
   -> END IF;
   -> END //
Query OK, 0 rows affected (0.16 sec)
Above, we have set the following LEAVE command to exit from the procedure. If Var1 is “NULL”, the procedure will exit.
LEAVE proc_Exit;
To change the delimiter to ‘;’.
mysql>delimiter ;
mysql>
To call stored procedure, we need to use CALL command followed by the procedure name.
The following is the syntax.
call yourStoredProcedureName;
Java Program to sort String Stream with reversed Comparator

Let us first create a String List:
List<String> list = Arrays.asList("Tom", "Jack", "Ryan", "Kevin", "Loki", "Thor");
Now compare each element for reverse:
Comparator<String> comp = (aName, bName) -> aName.compareTo(bName);
Now, perform sort:
list.stream().sorted(comp.reversed())
The following is an example to sort String Stream with reversed Comparator:
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
public class Demo {
   public static void main(String[] args) {
      List<String> list = Arrays.asList("Tom", "Jack", "Ryan", "Kevin", "Loki", "Thor");
      System.out.println("Initial List = "+list);
      System.out.println("Reverse...");
      Comparator<String> comp = (aName, bName) -> aName.compareTo(bName);
      list.stream().sorted(comp.reversed()) .forEach(System.out::println);
   }
}
Initial List = [Tom, Jack, Ryan, Kevin, Loki, Thor]
Reverse...
Tom
Thor
Ryan
Loki
Kevin
Jack
How can we implement a Custom HashSet in Java?

A HashSet implements Set interface which does not allow duplicate values. A HashSet is not synchronized and is not thread-safe. When we can add any duplicate element to a HashSet, the add() method returns false and does not allow to add a duplicate element to HashSet.
Syntax
public class HashSet<E> extends AbstractSet<E> implements Set<E>, Cloneable, Serializable
In the below example, we can implement a Custom HashSet.
import java.util.*;
public class CustomHashSetTest extends AbstractSet {
   private HashMap<Object, Object> map = null;
   private static final Object tempObject = new Object();
   public CustomHashSetTest() {
      map = new HashMap<>();
   }
   public boolean add(Object object) {
      return map.put(object, tempObject)==null;
   }
   public static void main(String[] args) {
      CustomHashSetTest test = new CustomHashSetTest();
      test.add("India");
      test.add("Australia");
      test.add("England");
      test.add("Australia");
      for(Object object : test) {
         System.out.println(object.toString());
      }
   }
   @Override
   public Iterator iterator() {
      return map.keySet().iterator();
   }
   @Override
   public int size() {
      return map.size();
   }
}
England
Australia
India
BigInteger shiftRight() Method in Java - GeeksforGeeks

04 Dec, 2018
prerequisite : BigInteger Basics
The java.math.BigInteger.shiftRight(int n) method returns a BigInteger whose value is (this >> n). The shift distance, n, may be negative, in which case this method performs a left shift. The shiftRight() method will move each digit in a number’s binary representation right by n times and the last bit in the direction of the shift is replaced by 0. This shiftRight() method Computes floor(this / 2^n).
Syntax:
public BigInteger shiftRight(int n)
Parameter: The method takes one parameter n of integer type which refers to the shift distance in bits.
Return Value: The method returns the BigInteger after shifting the bits to right by n times.
Exceptions: The method might throws an ArithmeticException if the shift distance is an Integer.MIN_VALUE.
Examples:
Input: BigInteger = 2300, n = 3
Output: 287
Explanation:
Binary Representation of 2300 = 100011111100
Shift distance, n = 3. 
After shifting 100011111100 right 3 times,
Binary Representation becomes 100011111
and Decimal equivalent of 100011111 is 287.

Input: BigInteger = 35000, n = 5
Output: 1093

Below program illustrates shiftRight(index) method of BigInteger:
// Program to demonstrate shiftRight()// method of BigInteger   import java.math.*;  public class GFG {      public static void main(String[] args)    {          // Create BigInteger object        BigInteger biginteger = new BigInteger("2300");          // Create a int i for Shift Distance        int i = 3;          // Call shiftRight() method on bigInteger at index i        // store the return value as BigInteger        BigInteger changedvalue = biginteger.shiftRight(i);          String result = "After applying shiftRight by Shift Distance " + i +         " on " + biginteger + " New Value is " + changedvalue;          // Print result        System.out.println(result);    }}
After applying shiftRight by Shift Distance 3 on 2300 New Value is 287

Reference: https://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html#shiftRight(int)
Java-BigInteger
Java-Functions
java-math
Java-math-package
Java
Java-BigInteger
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Initialize an ArrayList in Java
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Interfaces in Java
How to iterate any Map in Java
ArrayList in Java
Multidimensional Arrays in Java
Stream In Java
Stack Class in Java
Singleton Class in Java
How to create Date Picker in ReactJS? - GeeksforGeeks

20 Jan, 2021
Date pickers provide a simple way to select a single value from a pre-determined set. Material UI for React has this component available for us and it is very easy to integrate. We can create a Date Picker in ReactJS using the following approach:
Creating React Application And Installing Module:
Step 1: Create a React application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:
cd foldername
Step 3: After creating the ReactJS application, Install the material-ui modules using the following command:
npm install @material-ui/core
Project Structure: It will look like the following.
Project Structure
App.js: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
Javascript
import React from 'react';import TextField from '@material-ui/core/TextField';  const App = () => {    return (    <div style={{      margin: 'auto',      display: 'block',      width: 'fit-content'    }}>      <h3>How to create Date Picker in ReactJS?</h3>      <TextField        id="date"        label="Choose your birthdate"        type="date"        defaultValue="2017-05-24"        InputLabelProps={{          shrink: true,        }}      />    </div>  );}  export default App;
Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output:
JavaScript
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
How to get character array from string in JavaScript?
Remove elements from a JavaScript Array
How to get selected value in dropdown list using JavaScript ?
How to fetch data from an API in ReactJS ?
How to redirect to another page in ReactJS ?
How to pass data from child component to its parent in ReactJS ?
How to pass data from one component to other component in ReactJS ?
ReactJS Functional Components
VBA - DateAdd Function

A Function, which returns a date to which a specified time interval has been added.
DateAdd(interval,number,date) 

Interval − A required parameter. It can take the following values.

d - day of the year
m - month of the year
y - year of the year
yyyy - year
w - weekday
ww - week
q - quarter
h - hour
m - minute
s - second


Interval − A required parameter. It can take the following values.
d - day of the year
d - day of the year
m - month of the year
m - month of the year
y - year of the year
y - year of the year
yyyy - year
yyyy - year
w - weekday
w - weekday
ww - week
ww - week
q - quarter
q - quarter
h - hour
h - hour
m - minute
m - minute
s - second
s - second
Number − A required parameter. It can take both positive and negative parameters.
Number − A required parameter. It can take both positive and negative parameters.
Date − A required parameter. A variant or literal representing the date to which an interval is added.
Date − A required parameter. A variant or literal representing the date to which an interval is added.
Private Sub Constant_demo_Click()
   ' Positive Interal
   date1 = 27-Jun-1894
   msgbox("Line 1 : " &DateAdd("yyyy",1,date1))
   msgbox("Line 2 : " &DateAdd("q",1,date1))
   msgbox("Line 3 : " &DateAdd("m",1,date1))
   msgbox("Line 4 : " &DateAdd("y",1,date1))
   msgbox("Line 5 : " &DateAdd("d",1,date1))
   msgbox("Line 6 : " &DateAdd("w",1,date1))
   msgbox("Line 7 : " &DateAdd("ww",1,date1))
   msgbox("Line 8 : " &DateAdd("h",1,"01-Jan-2013 12:00:00"))
   msgbox("Line 9 : " &DateAdd("n",1,"01-Jan-2013 12:00:00"))
   msgbox("Line 10 : "&DateAdd("s",1,"01-Jan-2013 12:00:00"))
  
   ' Negative Interval
   msgbox("Line 11 : " &DateAdd("yyyy",-1,date1))
   msgbox("Line 12 : " &DateAdd("q",-1,date1))
   msgbox("Line 13 : " &DateAdd("m",-1,date1))
   msgbox("Line 14 : " &DateAdd("y",-1,date1))
   msgbox("Line 15 : " &DateAdd("d",-1,date1))
   msgbox("Line 16 : " &DateAdd("w",-1,date1))
   msgbox("Line 17 : " &DateAdd("ww",-1,date1))
   msgbox("Line 18 : " &DateAdd("h",-1,"01-Jan-2013 12:00:00"))
   msgbox("Line 19 : " &DateAdd("n",-1,"01-Jan-2013 12:00:00"))
   msgbox("Line 20 : " &DateAdd("s",-1,"01-Jan-2013 12:00:00")) 
End Sub
When you execute the above function, it produces the following output.
Line 1 : 27/06/1895
Line 2 : 27/09/1894
Line 3 : 27/07/1894
Line 4 : 28/06/1894
Line 5 : 28/06/1894
Line 6 : 28/06/1894
Line 7 : 4/07/1894
Line 8 : 1/01/2013 1:00:00 PM
Line 9 : 1/01/2013 12:01:00 PM
Line 10 : 1/01/2013 12:00:01 PM
Line 11 : 27/06/1893
Line 12 : 27/03/1894
Line 13 : 27/05/1894
Line 14 : 26/06/1894
Line 15 : 26/06/1894
Line 16 : 26/06/1894
Line 17 : 20/06/1894
Line 18 : 1/01/2013 11:00:00 AM
Line 19 : 1/01/2013 11:59:00 AM
Line 20 : 1/01/2013 11:59:59 AM


    101 Lectures 
     6 hours 

 Pavan Lalwani

    41 Lectures 
     3 hours 

 Arnold Higuit

    80 Lectures 
     5.5 hours 

 Prashant Panchal

    25 Lectures 
     2 hours 

 Prashant Panchal

    26 Lectures 
     2 hours 

 Arnold Higuit

    92 Lectures 
     10.5 hours 

 Vijay Kumar Parvatha Reddy
 Print
 Add Notes
 Bookmark this page
What are associative Arrays in JavaScript?

Associative arrays are basically objects in JavaScript where indexes are replaced by user defined keys. They do not have a length property like normal array and cannot be traversed using normal for loop.
Following is the code for associative arrays in JavaScript −
 Live Demo
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result {
      font-size: 20px;
      font-weight: 500;
   }
</style>
</head>
<body>
<h1>Associative array in JavaScript</h1>
<div style="color: green;" class="result"></div>
<button class="Btn">CLICK HERE</button>
<h3>
Click on the above button to create a associative array and display it
</h3>
<script>
   let resEle = document.querySelector(".result");
   document.querySelector(".Btn").addEventListener("click", () => {
      let arr = { Name: "Rohan", Class: 9, Age: 16 };
      for (i in arr) {
         resEle.innerHTML += "Key = " + i + " : Value = " + arr[i] + "<br>";
      }
   });
</script>
</body>
</html>
The above code will produce the following output −
On clicking the ‘CLICK HERE’ button −
How to make a redirect in PHP? - GeeksforGeeks

11 Oct, 2021
Redirection from one page to another in PHP is commonly achieved using the following two ways:Using Header Function in PHP: The header() function is an inbuilt function in PHP which is used to send the raw HTTP (Hyper Text Transfer Protocol) header to the client. Syntax: 
header( $header, $replace, $http_response_code )
Parameters: This function accepts three parameters as mentioned above and described below:  
$header: This parameter is used to hold the header string.
$replace: This parameter is used to hold the replace parameter which indicates the header should replace a previous similar header, or add a second header of the same type. It is optional parameter.
$http_response_code: This parameter hold the HTTP response code.
Below program illustrates the header() function in PHP:Program: 
php
<?php // Redirect browserheader("Location: https://www.geeksforgeeks.org"); exit;?>
Note: The die() or exit() function after header is mandatory. If die() or exit() is not put after after the header(‘Location: ....’) then script may continue resulting in unexpected behavior. For example, result in content being disclosed that actually wanted to prevent with the redirect (HTTP 301). Using JavaScript via PHP: The windows.location object in JavaScript is used to get the current page address(URL) and to redirect the browser to a new page. The window.location object contains the crucial information about a page such as hostname, href, pathname, port etc.Example: 
html
<html>    <head>        <title>window.location function</title>    </head>    <body>    <p id="demo"></p>     <script>        document.getElementById("demo").innerHTML =            "URL: " + window.location.href +"</br>";        document.getElementById("demo").innerHTML =        document.getElementById("demo").innerHTML +        "Hostname: " + window.location.hostname + "</br>";        document.getElementById("demo").innerHTML =        document.getElementById("demo").innerHTML +        "Protocol: " + window.location.protocol + "</br>";    </script>    </body></html>                   
Output: 
URL: https://ide.geeksforgeeks.org/tryit.php
Hostname: ide.geeksforgeeks.org
Protocol: https:
PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples.
kashishsoda
Picked
Technical Scripter 2018
PHP
PHP Programs
Technical Scripter
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Insert Form Data into Database using PHP ?
How to run JavaScript from PHP?
PHP | Converting string to Date and DateTime
How to fetch data from localserver database and display on HTML table using PHP ?
How to display logged in user information in PHP ?
How to run JavaScript from PHP?
How to encrypt and decrypt passwords using PHP ?
How to pass a PHP array to a JavaScript function?
How to fetch data from localserver database and display on HTML table using PHP ?
How to declare a global variable in PHP?
Constructor Overloading In Java programming

Similar to method overloading, constructor loading is the creation and usage of constructors with diffrent type of arguments. We can use this operator to refer to constructors.See the example below.
 Live Demo
class A {
   public int a;
   public A() {
      this(-1);
   }
   public A(int a) {
      this.a = a;
   }
   public String toString() {
      return "[ a= " + this.a + "]";
   }
}
public class Tester {
   public static void main(String args[]) {
      A a = new A(10);
      System.out.println(a);
      A a1 = new A();
   System.out.println(a1);
   }
}
[ a= 10]
[ a= -1]
How to create a subset based on levels of a character column in R?

In R programming, mostly the columns with string values can be either represented by character data type or factor data type. For example, if we have a column Group with four unique values as A, B, C, and D then it can be of character or factor with four levels. If we want to take the subset of these columns then subset function can be used. Check out the example below.
Consider the below data frame −
set.seed(888)
Grp<-sample(c("A","B","C"),20,replace=TRUE)Age<-sample(21:50,20)
df1<-data.frame(Grp,Age)
df1
   Grp  Age
1   A   35
2   C   40
3   C   48
4   C   46
5   C   36
6   C   33
7   B   47
8   A   45
9   B   43
10  B   37
11  B   30
12  A   24
13  C   39
14  C   50
15  C   25
16  A   34
17  B   49
18  A   44
19  C   38
20  B   26
str(df1) 'data.frame': 20 obs. of 2 variables:
$ Grp: chr "A" "C" "C" "C" ...
$ Age: int 35 40 48 46 36 33 47 45 43 37 ...
Taking subset of df1 based on Grp column values A and C −
subset(df1, Grp %in% c("A","C"))
Grp Age
1 A 35
2 C 40
3 C 48
4 C 46
5 C 36
6 C 33
8 A 45
12 A 24
13 C 39
14 C 50
15 C 25
16 A 34
18 A 44
19 C 38
Let’s have a look at another example −
 Live Demo
Class<-sample(c("First","Second","Third","Fourth"),20,replace=TRUE)
Score<-sample(1:10,20,replace=TRUE)
df2<-data.frame(Class,Score)
df2
   Class  Score
1  First   10
2  First   3
3  First   1
4  First   7
5  First   1
6  Third   4
7  First   3
8  First   3
9  Second  2
10 First   8
11 Fourth  1
12 Third   6
13 First   6
14 Second  1
15 First   8
16 Fourth  4
17 Third   7
18 Fourth  4
19 Third   7
20 Fourth  1
str(df2) 'data.frame': 20 obs. of 2 variables:
$ Class: chr "First" "Third" "Second" "First" ...
$ Score: int 1 4 9 8 9 10 2 8 5 8 ...
Taking subset of df2 based on Class column values First and Fourth −
subset(df2, Class %in% c("First","Fourth"))
Class Score
1 First 1
4 First 8
5 First 9
6 Fourth 10
7 Fourth 2
9 Fourth 5
10 Fourth 8
11 Fourth 8
13 Fourth 7
14 Fourth 10
15 First 7
16 Fourth 10
17 Fourth 4
19 First 2
20 First 10
C library function - clearerr()

The C library function void clearerr(FILE *stream) clears the end-of-file and error indicators for the given stream.
Following is the declaration for clearerr() function.
void clearerr(FILE *stream)
stream − This is the pointer to a FILE object that identifies the stream.
stream − This is the pointer to a FILE object that identifies the stream.
This should not fail and do not set the external variable errno but in case it detects that its argument is not a valid stream, it must return -1 and set errno to EBADF.
The following example shows the usage of clearerr() function.
#include <stdio.h>

int main () {
   FILE *fp;
   char c;

   fp = fopen("file.txt", "w");

   c = fgetc(fp);
   if( ferror(fp) ) {
      printf("Error in reading from file : file.txt\n");
   }
   clearerr(fp);
   
   if( ferror(fp) ) {
      printf("Error in reading from file : file.txt\n");
   }
   fclose(fp);

   return(0);
}
Assuming we have a text file file.txt, which is an empty file, let us compile and run the above program, this will produce the following result because we try to read a file which we opened in write only mode.
Error reading from file "file.txt"


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
p5.js | Constants | HALF_PI - GeeksforGeeks

12 Apr, 2019
The HALF_PI is a mathematical constant and its value is 1.57079632679489661923. The HALF_PI is the half ratio of the circumference of a circle to its diameter.
Syntax:
HALF_PI
Below program illustrates the usage of HALF_PI in p5.js:
Example:
function setup() {      // Create Canvas of size 300*200    createCanvas(300, 200);}  function draw() {          // Set the background Color    background(220);          // Set the stroke color    stroke(255, 204, 0);          // Set the stroke weight    strokeWeight(4);          // Use of constant HALF_PI    arc(50, 50, 280, 280, 0, HALF_PI/2);           noStroke();          // Set the font size    textSize(20);          // Display result    text("Value of HALF_PI is "            + HALF_PI, 30, 180);}
Output:
Reference: https://p5js.org/reference/#/p5/HALF_PI
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
How to calculate the number of days between two dates in javascript?
File uploading in React.js
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
JavaScript while Loop

Loops can execute a block of code
as long as a specified condition is true.
The while loop loops through a block of code as long as a specified condition is true.
In the following example, the code in the loop will run, over and over again, as long as 
a variable (i) is less than 10:
If you forget to increase the variable used in the condition, the loop will never end.
This will crash your browser.
The do while loop is a variant of the while loop. This loop will 
execute the code block once, before checking if the condition is true, then it will
repeat the loop as long as the condition is true.
The example below uses a do while loop. The loop will always be 
executed at least once, even if the condition is false, because the code block 
is executed before the condition is tested:
Do not forget to increase the variable used in the condition, otherwise 
the loop will never end!
If you have read the previous chapter, about the for loop, you will discover that a while loop is 
much the same as a for loop, with statement 1 and statement 3 omitted.
The loop in this example uses a for loop to collect the car 
names from the cars array:
The loop in this example uses a while loop to collect the 
car names from the cars array:
Create a loop that runs as long as i is less than 10.
let i = 0;
 (i  10) {
  console.log(i);
  i++
}

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.
Impala - Distinct Operator

The distinct operator in Impala is used to get the unique values by removing duplicates.
Following is the syntax of the distinct operator.
select distinct columns... from table_name;

Assume that we have a table named customers in Impala and its contents are as follows −
[quickstart.cloudera:21000] > select distinct id, name, age, salary from customers; 
Query: select distinct id, name, age, salary from customers

Here you can observe the salary of the customers Ramesh and Chaitali entered twice and using the distinct operator, we can select the unique values as shown below.
[quickstart.cloudera:21000] > select distinct name, age, address from customers;

On executing, the above query gives the following output.
Query: select distinct id, name from customers
+----------+-----+-----------+ 
| name     | age | address   | 
+----------+-----+-----------+ 
| Ramesh   | 32  | Ahmedabad |
| Khilan   | 25  | Delhi     | 
| kaushik  | 23  | Kota      | 
| Chaitali | 25  | Mumbai    |
| Hardik   | 27  | Bhopal    |
| Komal    | 22  | MP        | 
+----------+-----+-----------+
Fetched 9 row(s) in 1.46s

 Print
 Add Notes
 Bookmark this page
Cl0neMast3r - Cloning Tool in Kali Linux - GeeksforGeeks

05 Aug, 2021
Cl0neMast3r is a Python script that was coded to add, update, delete tools easier. It allows the user to choose tools from GitHub and install them on their system with the help of just two-three clicks. Also, one can ensure that he has the latest version of his favorite tool.
Python3
Requests
BeautifulSoup4
Step 1: First, we need to clone this tool.
git clone https://github.com/Abdulraheem30042/Cl0neMast3r.git
Step 2: After cloning, change the directory to Cl0neMast3r.
cd Cl0neMast3r/
Also, there are some requirements that need to be installed, so execute the following command:
pip install -r requirements.txt
Fig 1: Successfully installed Cl0neMast3r.
Step 3: We need to change the permissions of the file.
chmod +x Cl0neMast3r.py
Step 4: Now to start the tool, type the following command.
python Cl0neMast3r.py
Fig 2: Cl0neMast3r.
As we can see, cl0neMast3r provides us many options such as finding a tool on GitHub, Updating tools, Adding a tool, etc.
Let’s start by using it’s finding a tool on GitHub option, type F, and enter the tool name you want to download.
Fig 3: Find a tool on GitHub.
Cl0neMast3r has found 4 pages, now we need to tell the tool that if we want to see all the pages found or only 1, let’s display all the pages, type 4.
Fig 4: Tool number and author shown by the Cl0neMast3r.
As we can see almost 40 tools were found, and now we need to tell the tool number which we need to get installed.
Fig 5: After providing the tool no., specified tool gets installed.
Let’s use the update your tool option, type u, and then type 1 or 2 depending upon your requirement that whether you want to update all tools or just old tools. Let’s select 2, type 2.
Fig 6: Update your tool.
After selecting 2, our most recent tool gets updated.
Fig 7: Tool gets updated.
Let’s display our tools, type S.
Fig 8: Displaying our tools and their status.
In conclusion, Cl0neMast3r gives us the flexibility not only to add, delete tools, but also one can update them with the help of two-three clicks which in turn helps us to achieve our pen testing tasks in an efficient and convenient way.
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
scp command in Linux with Examples
nohup Command in Linux with Examples
mv command in Linux with examples
Thread functions in C/C++
Docker - COPY Instruction
chown command in Linux with Examples
nslookup command in Linux with Examples
SED command in Linux | Set 2
Named Pipe or FIFO with example C program
uniq Command in LINUX with examples
How to remove all child nodes from a parent in jQuery?

To remove all child nodes from a parent in jQuery, use the empty() method.
The jQuery empty() method removes all child nodes of the set of matched elements from the DOM.
Live Demo
<!DOCTYPE html>
<html>
<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function() {
    $("#demo").empty();
  });
});
</script>
</head>
<body>

<ul id='demo'>
  <li>India</li>
  <li>US</li>
  <li>UK</li>
</ul>
<button>Remove all child nodes</button>

</body>
</html>