code-rag-bench/online-tutorials huggingface dataset:
OpenDoor - OWASP Directory Access Scanner in Kali Linux - GeeksforGeeks

14 Sep, 2021
Brute-Forcing is an automated process through which Usernames, Passwords can be detected by querying the possible credentials on the target domain login pages. We can also brute-force hidden files and directories on the target server by specifying the possible word-list which contains the phrases that will be tested on the domain. This process saves a lot of time for the tester as manual testing can be very unreliable. OpenDoor is the tool used for brute-forcing the credentials, admin pages, files, and directories on the target domain server. An OpenDoor tool is an automated tool developed in the Python language. OpenDoor application will scan the site directories and find all possible ways to log in, empty directories, and entry points. OpenDoor tool is free and available on GitHub. This tool is also Open-source so anyone can contribute to the repository and add some new features to it. 
Note: Make Sure You have Python Installed on your System, as this is a python-based tool. Click to check the Installation process – Python Installation Steps on Linux
Step 1: Use the following command to install the tool in your Kali Linux operating system.
git clone https://github.com/stanislav-web/OpenDoor.git
Step 2: Now use the following command to move into the directory of the tool. You have to move to the directory to run the tool.
cd OpenDoor 
Step 3: You are in the directory of the OpenDoor. Now you have to install a dependency of the OpenDoor using the following command.
sudo pip3 install -r requirements.txt
Step 4: All the dependencies have been installed in your Kali Linux operating system. Now use the following command to run the tool and check the help section.
python3 opendoor.py -h
Example 1: Target host (ip); –host http://example.com
python3 opendoor.py --host "http://geeksforgeeks.org"
In this example, we are enumerating hidden directories on the target domain geeksforgeeks.org. 
OpenDoor tool is performing brute-forcing for detection of directories and files on the target server.
Example 2: Scan type scan=directories or scan=subdomains
python3 opendoor.py --host "http://geeksforgeeks.org" --scan subdomains
In this example, we are performing subdomain enumeration on geeksforgeeks.org. We have used –scan tag for enumerating subdomains.
OpenDoor tool is performing brute-forcing for detection of subdomains on the target server.
Example 3: Allowed threads
python3 opendoor.py --host "http://geeksforgeeks.org" --threads 10
In this example, we are specifying the value of the threads for faster performance. We have used the –threads tag for setting the value as 10.
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scp command in Linux with Examples
Docker - COPY Instruction
mv command in Linux with examples
SED command in Linux | Set 2
chown command in Linux with Examples
nohup Command in Linux with Examples
Named Pipe or FIFO with example C program
Thread functions in C/C++
uniq Command in LINUX with examples
Start/Stop/Restart Services Using Systemctl in Linux
Python - Rayleigh Distribution in Statistics - GeeksforGeeks

14 Jan, 2020
scipy.stats.rayleigh() is a Rayleigh continuous random variable. It is inherited from the of generic methods as an instance of the rv_continuous class. It completes the methods with details specific for this particular distribution.
Parameters :
q : lower and upper tail probabilityx : quantilesloc : [optional]location parameter. Default = 0scale : [optional]scale parameter. Default = 1size : [tuple of ints, optional] shape or random variates.moments : [optional] composed of letters [‘mvsk’]; ‘m’ = mean, ‘v’ = variance, ‘s’ = Fisher’s skew and ‘k’ = Fisher’s kurtosis. (default = ‘mv’).
Results : Rayleigh continuous random variable
Code #1 : Creating Rayleigh continuous random variable
# importing library  from scipy.stats import rayleigh     numargs = rayleigh .numargs a, b = 4.32, 3.18rv = rayleigh (a, b)     print ("RV : \n", rv) 
Output :
RV : 
 scipy.stats._distn_infrastructure.rv_frozen object at 0x000002A9D843A9C8

Code #2 : Rayleigh continuous variates and probability distribution
import numpy as np quantile = np.arange (0.01, 1, 0.1)   # Random Variates R = rayleigh.rvs(a, b) print ("Random Variates : \n", R)   # PDF R = rayleigh.pdf(a, b, quantile) print ("\nProbability Distribution : \n", R) 
Output :
Random Variates : 
 6.581597763121607

Probability Distribution : 
 [0.00000000e+00 4.48155819e-22 1.03102695e-05 1.37280742e-02
 1.42084729e-01 3.60395757e-01 5.34360887e-01 6.23116939e-01
 6.45372583e-01 6.28111099e-01]


Code #3 : Graphical Representation.
import numpy as np import matplotlib.pyplot as plt      distribution = np.linspace(0, np.minimum(rv.dist.b, 3)) print("Distribution : \n", distribution)      plot = plt.plot(distribution, rv.pdf(distribution)) 
Output :
Distribution : 
 [0.         0.04081633 0.08163265 0.12244898 0.16326531 0.20408163
 0.24489796 0.28571429 0.32653061 0.36734694 0.40816327 0.44897959
 0.48979592 0.53061224 0.57142857 0.6122449  0.65306122 0.69387755
 0.73469388 0.7755102  0.81632653 0.85714286 0.89795918 0.93877551
 0.97959184 1.02040816 1.06122449 1.10204082 1.14285714 1.18367347
 1.2244898  1.26530612 1.30612245 1.34693878 1.3877551  1.42857143
 1.46938776 1.51020408 1.55102041 1.59183673 1.63265306 1.67346939
 1.71428571 1.75510204 1.79591837 1.83673469 1.87755102 1.91836735
 1.95918367 2.        ]
  
Code #4 : Varying Positional Arguments
import matplotlib.pyplot as plt import numpy as np      x = np.linspace(0, 5, 100)      # Varying positional arguments y1 = rayleigh .pdf(x, 1, 3, 5) y2 = rayleigh .pdf(x, 1, 4, 4) plt.plot(x, y1, "*", x, y2, "r--") 
Output :
Python scipy-stats-functions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Firebase - Write Transactional Data

Transactional data is used when you need to return some data from the database then make some calculation with it and store it back.
Let us say we have one player inside our player list.
We want to retrieve property, add one year of age and return it back to Firebase.
The amandaRef is retrieving the age from the collection and then we can use the transaction method. We will get the current age, add one year and update the collection.
var ref = new Firebase('https://tutorialsfirebase.firebaseio.com');

var amandaAgeRef = ref.child("players").child("-KGb1Ls-gEErWbAMMnZC").child('age');

amandaAgeRef.transaction(function(currentAge) {
   return currentAge + 1;
});
If we run this code, we can see that the age value is updated to 21.

    60 Lectures 
     5 hours 

 University Code

    28 Lectures 
     2.5 hours 

 Appeteria

    85 Lectures 
     14.5 hours 

 Appeteria

    46 Lectures 
     2.5 hours 

 Gautham Vijayan

    13 Lectures 
     1.5 hours 

 Nishant Kumar

    85 Lectures 
     16.5 hours 

 Rahul Agarwal
 Print
 Add Notes
 Bookmark this page
How to compile packages in Java

Let us look at an example that creates a package called animals. It is a good practice to use names of packages with lower case letters to avoid any conflicts with the names of classes and interfaces.
Following package example contains interface named animals −
/* File name : Animal.java */
package animals;
interface Animal {
   public void eat();
   public void travel();
}
Now, let us implement the above interface in the same package animals −
package animals;
/* File name : MammalInt.java */
public class MammalInt implements Animal {
   public void eat() {
      System.out.println("Mammal eats");
   }
   public void travel() {
      System.out.println("Mammal travels");
   }
   public int noOfLegs() {
      return 0;
   }
   public static void main(String args[]) {
      MammalInt m = new MammalInt();
      m.eat();
      m.travel();
   }
}
Now compile the java files as shown below −
$ javac -d . Animal.java
$ javac -d . MammalInt.java
Now a package/folder with the name animals will be created in the current directory and these class files will be placed in it as shown below.
PostgreSQL - TRIM Function - GeeksforGeeks

01 Feb, 2021
In PostgreSQL, the TRIM() function is used to remove the longest string consisting of spaces or any specified character from a string. By default, the TRIM() function removes all spaces (‘ ‘) if not specified  explicitly. The TRIM() function, can also be used to remove the longest string containing a character starting from the start to the end of the string.It is generally used for data cleansing.
The following is the syntax of the TRIM() function:
Syntax: TRIM([LEADING | TRAILING | BOTH] [characters] FROM string)
Example 1:
The following statement removes leading, trailing, and both leading and trailing spaces from strings:
SELECT
    TRIM (
        LEADING
        FROM
            '  Geeks ForGeeks'
    ),
    TRIM (
        TRAILING
        FROM
            'Geeks ForGeeks   '
    ),
    TRIM ('  Geeks ForGeeks  ');
Output:
Example 2:
The following statement removes the leading zero (0) from a number. As the function only accepts string values we have to use a type cast to convert the number into a string before passing it to the TRIM() function.
SELECT
    TRIM (
        LEADING '0'
        FROM
            CAST (0009100 AS TEXT)
    );
Output:
PostgreSQL-function
PostgreSQL-String-function
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
PostgreSQL - GROUP BY clause
PostgreSQL - DROP INDEX
PostgreSQL - LIMIT with OFFSET clause
PostgreSQL - Cursor
PostgreSQL - LEFT JOIN
PostgreSQL - Select Into
PostgreSQL - Record type variable
PostgreSQL - Copy Table
PostgreSQL - ROW_NUMBER Function
PostgreSQL - NOT NULL Constraint
Python – Specific Range Addition in List

01 Mar, 2020
Sometimes, while working with Python, we need to perform edition in Python list. And sometimes we need to perform this to specific index range in it. This kind of application can have application in many domains. Lets discuss certain ways in which this task can be performed.
Method #1 : Using loopThis is brute way in which this task can be performed. In this, we just iterate through the specified range in which the edition has to be performed.
# Python3 code to demonstrate # Specific Range Addition in List# using loop  # Initializing listtest_list = [4, 5, 6, 8, 10, 11]  # printing original list print("The original list is : " + str(test_list))  # Initializing range i, j = 2, 5  # Specific Range Addition in List# using loopfor idx in range(i, j):    test_list[idx] += 3  # printing result print ("List after range addition : " + str(test_list))
The original list is : [4, 5, 6, 8, 10, 11]
List after range addition : [4, 5, 9, 11, 13, 11]

 
Method #2 : Using list comprehensionThis task can also be performed using list comprehension. This method uses same way as above but its a shorthand to above.
# Python3 code to demonstrate # Specific Range Addition in List# using list comprehension  # Initializing listtest_list = [4, 5, 6, 8, 10, 11]  # printing original list print("The original list is : " + str(test_list))  # Initializing range i, j = 2, 5  # Specific Range Addition in List# using list comprehensiontest_list[i : j] = [ele + 3 for ele in test_list[i : j]]  # printing result print ("List after range addition : " + str(test_list))
The original list is : [4, 5, 6, 8, 10, 11]
List after range addition : [4, 5, 9, 11, 13, 11]

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
OS CPU Scheduling - GeeksforGeeks

03 Oct, 2019
  p2  p1  p2  p1  p2  p0  p1   p2   p0   p1   p2
0   4   5   6   7   8   9   10    11   12   13   14 

 idle   p0    p1     p2    idle
0    2     9     23     44     47

Process           Arrival time         Time Units Required
   P1                0                         5
   P2                1                         7
   P3                3                         4
FCFS: P1, P2, P3
 RR2: P1, P2, P3
 FCFS: P1, P3, P2
 RR2: P1, P3, P2
FCFS: P1, P2, P3
 RR2: P1, P3, P2
FCFS: P1, P3, P2 
RR2: P1, P2, P3
FCFS is clear.  

In RR, time slot is of 2 units.  

Processes are assigned in following order
p1, p2, p1, p3, p2, p1, p3, p2, p2

Process   Arrival time   Burst Time
P0            0 ms          9 ms
P1            1 ms          4 ms
P2            2 ms          9 ms
I. Shortest remaining time first scheduling may cause starvation
II. Preemptive scheduling may cause starvation
III. Round robin is better than FCFS in terms of response time
I. If a process makes a transition D, it would result in 
   another process making transition A immediately.
II. A process P2 in blocked state can make transition E 
    while another process P1 is in running state.
III. The OS uses preemptive scheduling.
IV. The OS uses non-preemptive scheduling.
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Use different y-axes on the left and right of a Matplotlib plot

23 Jan, 2022
In this article, we are going to discuss how to create y-axes of both sides of a Matplotlib plot.
Sometimes for quick data analysis, it is required to create a single graph having two data variables with different scales. For this purpose twin axes methods are used i.e. dual X or Y-axes. The matplotlib.axes.Axes.twinx() function in axes module of matplotlib library is used to create a twin Axes sharing the X-axis.
Syntax :
matplotlib.axes.Axes.twinx(self)
This method does not take any parameters, raise an error if provided. It returns the ax_twin object which indicates that a new Axes instance is created. Below examples illustrate the matplotlib.axes.Axes.twinx() function in matplotlib.axes:
Example 1:
Python3
# import librariesimport numpy as npimport matplotlib.pyplot as plt # Creating datasetx = np.arange(1.0, 100.0, 0.191)dataset_1 = np.exp(x**0.25) - np.exp(x**0.5)dataset_2 = np.sin(0.4 * np.pi * x**0.5) + np.cos(0.8 * np.pi * x**0.25) # Creating plot with dataset_1fig, ax1 = plt.subplots() color = 'tab:red'ax1.set_xlabel('X-axis')ax1.set_ylabel('Y1-axis', color = color)ax1.plot(x, dataset_1, color = color)ax1.tick_params(axis ='y', labelcolor = color) # Adding Twin Axes to plot using dataset_2ax2 = ax1.twinx() color = 'tab:green'ax2.set_ylabel('Y2-axis', color = color)ax2.plot(x, dataset_2, color = color)ax2.tick_params(axis ='y', labelcolor = color) # Adding titleplt.title('Use different y-axes on the left and right of a Matplotlib plot', fontweight ="bold") # Show plotplt.show()
Output:
Example 2:
Python3
# import librariesimport numpy as npimport matplotlib.pyplot as pltfrom matplotlib import rcrc('mathtext', default='regular') # Creating datasetx = np.arange(10)dataset_1 = np.random.random(10)*30dataset_2 = np.random.random(10)*60dataset_3 = np.random.random(10)*100 # Creating figurefig = plt.figure() # Plotting dataset_2ax = fig.add_subplot(111)ax.plot(x, dataset_2, '-', label='dataset_2')ax.plot(x, dataset_3, '-', label='dataset_3') # Creating Twin axes for dataset_1ax2 = ax.twinx()ax2.plot(x, dataset_1, '-r', label='dataset_1') # Adding titleplt.title('Use different y-axes on the left and right of a Matplotlib plot',          fontweight="bold") # Adding legendax.legend(loc=0)ax2.legend(loc=0) # adding gridax.grid() # Adding labelsax.set_xlabel("X-axis")ax.set_ylabel(r"Y1-axis")ax2.set_ylabel(r"Y2-axis") # Setting Y limitsax2.set_ylim(0, 35)ax.set_ylim(-20, 100) # Show plotplt.show()
Output:
sagar0719kumar
Picked
Python-matplotlib
Technical Scripter 2020
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
numpy.take() in Python

09 Mar, 2022
The numpy.take() function returns elements from array along the mentioned axis and indices. 
Syntax: numpy.take(array, indices, axis = None, out = None, mode ='raise')
Parameters : 
array   : array_like, input array
indices : index of the values to be fetched
axis    : [int, optional] axis over which we need to fetch the elements; 
                  By Default[axis = None], flattened input is used
mode    : [{‘raise’, ‘wrap’, ‘clip’}, optional] mentions how out-of-bound indices will behave
                  raise : [default]raise an error 
                  wrap  : wrap around
                  clip  : clip to the range
out     : [ndarray, optional]to place result within array
Returns : 
ndarray; array has the same type
 
Python
# Python Program illustrating# numpy.take method import numpy as geek #array = geek.arange(10).reshape(2, 5)array = [[5, 6, 2, 7, 1],         [4, 9, 2, 9, 3]]print("Original array : \n", array) # indices = [0, 4]print("\nTaking Indices\n", geek.take(array, [0, 4])) # indices = [0, 4] with axis = 1print("\nTaking Indices\n", geek.take(array, [0, 4], axis = 1))
Output :  
Original array : 
 [[5, 6, 2, 7, 1], [4, 9, 2, 9, 3]]

Taking Indices
 [5 1]

Taking Indices
 [[5 1]
 [4 3]]
References : https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.take.html#numpy.take Note : These codes won’t run on online IDE’s. So please, run them on your systems to explore the working.This article is contributed by Mohit Gupta_OMG . If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@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. 
vinayedula
Python numpy-Indexing
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
How to Install PIP on Windows ?
Python String | replace()
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Perl | chomp() Function

07 May, 2019
The chomp() function in Perl is used to remove the last trailing newline from the input string.
Syntax: chomp(String)
Parameters:String : Input String whose trailing newline is to be removed
Returns: the total number of trailing newlines removed from all its arguments
Example 1:
#!/usr/bin/perl  # Initialising a string$string = "GfG is a computer science portal\n";  # Calling the chomp() function$A  = chomp($string);  # Printing the chopped string and # removed trailing newline characterprint "Chopped String is : $string\n";print "Number of Characters removed : $A";
Chopped String is : GfG is a computer science portal
Number of Characters removed : 1

In the above code, it can be seen that input string containing a newline character (\n) which is removed by chomp() function.
Example 2:
#!/usr/bin/perl  # Initialising two strings$string1 = "Geeks for Geeks\n\n";$string2 = "Welcomes you all\n";  # Calling the chomp() function$A  = chomp($string1, $string2);  # Printing the chopped string and # removed trailing newline characterprint "Chopped String is : $string1$string2\n";print "Number of Characters removed : $A\n";
Chopped String is : Geeks for Geeks
Welcomes you all
Number of Characters removed : 2

In the above code, it can be seen that the input string1 containing two newline characters (\n\n) out of which only last newline character is removed by chomp() function and second last newline character is utilized which can be seen in the output.
Perl-function
Perl-String-Functions
Perl
Perl
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
React Native Flexbox flexDirection Property

25 May, 2021
In this article, We are going to see the Flexbox flexDirection Property in React Native. Flexbox has three main properties. One of them is flexDirection. The flexDirection property is used to determine the alignment of its elements in the horizontal or vertical directions. It established the main axis of the layout. 
Syntax:
flexDirection: 'column|row|column-reverse|row-reverse'
Property Values:
column: It is the default value of flexDirection property. It aligns the children items from top to bottom directions.
row: It aligns the children’s items from left to right directions.
column-reverse: It aligns the children items from bottom to top directions. It is the reverse of the column value.
row-reverse: It aligns the children from right to left directions.
Implementation:
Step 1: Open your terminal and install expo-cli by the following command.npm install -g expo-cli
npm install -g expo-cli
Step 2: Now create a project by the following command.expo init myapp
expo init myapp
Step 3: Now go into your project folder i.e. myapp. cd myapp
 cd myapp
Project Structure: It will look like this.
Example: Here in this example, flexDirection is set to the column.
App.js
import React,{Component} from 'react';import { View, StyleSheet } from 'react-native';  const App = (props) => {  return (     <View style = {styles.container}>        <View style = {[styles.item,{backgroundColor:'green'}]} />        <View style = {[styles.item,{backgroundColor:'blue'}]} />        <View style = {[styles.item,{backgroundColor:'red'}]} />     </View>  )}  export default App;  const styles = StyleSheet.create ({  container: {  flex:1,     flexDirection: 'column',  },  item:{    height:100,    width:100  }})
Start the server by using the following command.
npm run android
Output: If your emulator did not open automatically then you need to do it manually. First, go to your android studio and run the emulator. Now start the server again.
Now we will keep the entire code the same and just do the changes in flexDirection property value to see the change.
Property row illustration, use the following syntax:flexDirection: 'row'
flexDirection: 'row'
Property column-reverse illustration, use the following syntax:flexDirection: 'column-reverse'
flexDirection: 'column-reverse'
Property row-reverse illustration, use the following syntax:flexDirection: 'row-reverse'
flexDirection: 'row-reverse'
Reference: https://reactnative.dev/docs/flexbox#flex-direction
Picked
React-Native
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
List frequency of elements in Python

In this article, we are going to learn how to find the frequency of elements in a list. We can solve the problem in different ways. Let's see two of them.
Follow the below steps to write the code.
Initialize the list with elements and an empty dictionary.
Iterate over the list of elements.Check whether the element is present in the dictionary or not.If the element is already present in the dictionary, then increase its count.If the element is not present in the dictionary, then initialize its count with 1.
Check whether the element is present in the dictionary or not.
If the element is already present in the dictionary, then increase its count.
If the element is not present in the dictionary, then initialize its count with 1.
Print the dictionary.
Let's see the code.
 Live Demo
# initializing the list
random_list = ['A', 'A', 'B', 'C', 'B', 'D', 'D', 'A', 'B']
frequency = {}

# iterating over the list
for item in random_list:
   # checking the element in dictionary
   if item in frequency:
      # incrementing the counr
      frequency[item] += 1
   else:
      # initializing the count
      frequency[item] = 1

# printing the frequency
print(frequency)
If you run the above code, then you will get the following result.
{'A': 3, 'B': 3, 'C': 1, 'D': 2}

Follow the below steps to the problem in another way. We are going to use a module method to find the frequency of elements.
Import the collections module.
Initialize the list with elements.
Get the frequency of elements using Counter from collections module.
Convert the result to dictionary using dict and print the frequency.
Let's see the code.
# importing the module
import collections

# initializing the list
random_list = ['A', 'A', 'B', 'C', 'B', 'D', 'D', 'A', 'B']

# using Counter to find frequency of elements
frequency = collections.Counter(random_list)

# printing the frequency
print(dict(frequency))
{'A': 3, 'B': 3, 'C': 1, 'D': 2}
If you run the above code, then you will get the following result.
{'A': 3, 'B': 3, 'C': 1, 'D': 2}

If you have any queries in the article, mention them in the comment section.
C++ Program to Check for balanced paranthesis by using Stacks

Here we will discuss how to check the balanced brackets using stacks. We not only check the opening and closing brackets but also check the ordering of brackets. For an example we can say that the expression "[{} () {()}]" it is correct, but "{[}]" it is not correct.
Input: Some expression with brackets "{()}[]"
Output: They are balanced
Step 1: Define a stack to hold brackets
Step 2: Traverse the expression from left to right
Step 2.1: If the character is opening bracket (, or { or [, then push it into stack
Step 2.2: If the character is closing bracket ), } or ] Then pop from stack, and if the popped character is matched with the starting bracket then it is ok. otherwise they are not balanced.
Step 3: After traversal if the starting bracket is present in the stack then it is not balanced.
 Live Demo
#include<iostream>
#include<stack>
using namespace std;
bool isBalanced(string expr) {
   stack<char> s;
   char ch;
   for (int i=0; i<expr.length(); i++) {    //for each character in the expression, check conditions
      if (expr[i]=='('||expr[i]=='['||expr[i]=='{') {    //when it is opening bracket, push into     stack
         s.push(expr[i]);
         continue;
      }
      if (s.empty())    //stack cannot be empty as it is not opening bracket, there must be closing     bracket
         return false;
         switch (expr[i]) {
            case ')':    //for closing parenthesis, pop it and check for braces and square brackets
               ch = s.top();
               s.pop();
               if (ch=='{' || ch=='[')
                  return false;
                  break;
            case '}': //for closing braces, pop it and check for parenthesis and square brackets
               ch = s.top();
               s.pop();
               if (ch=='(' || ch=='[')
                  return false;
                  break;
            case ']': //for closing square bracket, pop it and check for braces and parenthesis
               ch = s.top();
               s.pop();
               if (ch =='(' || ch == '{')
                  return false;
                  break;
         }
      }
      return (s.empty()); //when stack is empty, return true
}
main() {
   string expr = "[{}(){()}]";
   if (isBalanced(expr))
      cout << "Balanced";
   else
      cout << "Not Balanced";
}
Balanced
Get Application Version using Python

In software industries, whenever developers add a new feature, fix bugs in a particular application, they name the application to a new version, as it helps to recognize the recently updated features in that application.
Using Python, we can get the version of any application. We will use pywin32 to interact with the executable files. It provides access to the win32 API which gives the ability to create COM and objects.
First, install the required package by typing pip install pywin32 in the command shell.
First, install the required package by typing pip install pywin32 in the command shell.
Import Dispatch to get the version number of the application.
Import Dispatch to get the version number of the application.
Create a variable to store the location of the application.
Create a variable to store the location of the application.
Define a function for getting the version that takes the location of the executable file and parses using the Dispatch method.
Define a function for getting the version that takes the location of the executable file and parses using the Dispatch method.
Return the version number using GetFileVersion(app_location) method.
Return the version number using GetFileVersion(app_location) method.
In this example, we try to get the version of Chrome Application in our System,
#Import the required Module
from win32com.client import Dispatch
def get_version_number(app_location):
   parser = Dispatch("Scripting.FileSystemObject")
   version = parser.GetFileVersion(app_location)
   return version
app_location = r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
version = get_version_number(app_location)
print(version)
Running the above code will print the version of the Chrome Application.
89.0.4389.114
Now, try to give the location of another application to retrieve its version number.
Git Getting Started

You can download Git for free from the following website: https://www.git-scm.com/
To start using Git, we are first going to open up our Command shell.
For Windows, you can use Git bash, which comes included in Git for Windows. 
For Mac and Linux you can use the built-in terminal.
The first thing we need to do, is to check if Git is properly installed:
git --version
git version 2.30.2.windows.1
If Git is installed, it should show something like git version X.Y
Now let Git know who you are. This is important for version control systems, 
as each Git commit uses this information:
git config --global user.name "w3schools-test"
git config --global user.email "test@w3schools.com"
Change the user name and e-mail address to your own. You will probably also want to use this when registering to GitHub 
later on.
Note: Use global to set the username and e-mail for every repository on your computer.
If you want to set the username/e-mail for just the current repo, you can remove global
Now, let's create a new folder for our project:
mkdir myproject
cd myproject
mkdir makes a new directory.
cd changes the current working directory.
Now that we are in the correct directory. We can start by initializing Git!
Note: If you already have a folder/directory you would 
  like to use for Git:
Navigate to it in command line, or open it in your file explorer, right-click and select "Git Bash here"
Once you have navigated to the correct folder, you can initialize Git on that 
folder:
git init 
Initialized empty Git repository in /Users/user/myproject/.git/
You just created your first Git Repository!
Note: Git now knows that it should watch the folder you 
  initiated it on.
Git creates a hidden folder to keep track of changes.
Insert the missing part of the command to check which version of Git (if any) 
is installed.
git 


Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
python | Numpy masked_equal() method - GeeksforGeeks

19 Sep, 2019
With the help of numpy.ma.masked_equal() method, we can get the mask a value that in an array by using numpy.ma.masked_equal() method.
Syntax : numpy.ma.masked_equal(array, value)
Return : Return the array after removing mask value.
Example #1 :
In this example we can see that by using numpy.ma.masked_equal() method, we are able to get the new array after removing mask value which is passed along with an array.
# import numpyimport numpy.ma as ma  # using numpy.ma.masked_equal() methodgfg = ma.masked_equal([1, 2, 3, 4], 3)  print(gfg)
Output :
[1 2 — 4]
Example #2 :
# import numpyimport numpy.ma as ma  # using numpy.ma.masked_equal() methodgfg = ma.masked_equal([[1, 2, 3, 4],                       [6, 7, 8, 9]], 6)  print(gfg)
Output :
[[1 2 3 4][– 7 8 9]]
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Golang Program to Find Largest Element in an Array - GeeksforGeeks

10 May, 2020
The task is to find the largest element of an array in Golang by taking input values from the user.
Example:
Input: Enter the number of elements: 4
Enter the number : 40Enter the number : 69Enter the number : 89Enter the number : -54
Output: The largest number is : 89
In this program, the user needs to enter the total number of elements in which he wants to perform the comparison and the values. The program will compare all the elements and will return the value of the largest element.
// Golang Program to Find Largest Element in an Arraypackage main  import "fmt"  func main() {  // taking an array variable    var n [100]float64    var total int    fmt.Print("Enter number of elements: ")          // taking user input    fmt.Scanln(&total)    for i := 0; i < total; i++ {        fmt.Print("Enter the number : ")        fmt.Scan(&n[i])    }    for j := 1; j < total; j++ {        if n[0] < n[j] {            n[0] = n[j]        }      }      fmt.Print("The largest number is : ", n[0])}
Output:
Enter number of elements: 5Enter the number : 20Enter the number : -219Enter the number : 219Enter the number : 54.87Enter the number : -1000The largest number is : 219
Explanation: In the above program, we first take input values from the user. We take a variable temp which will store the size of an array. Then, the comparison is being made until we reach the last element. The loop is then terminated and the value of the largest element is returned to the user.
Golang-Arrays
Golang-Program
Picked
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
6 Best Books to Learn Go Programming Language
How to Parse JSON in Golang?
Strings in Golang
Time Durations in Golang
Structures in Golang
How to iterate over an Array using for loop in Golang?
Rune in Golang
Defer Keyword in Golang
Loops in Go Language
Class and Object in Golang
Kotlin Elvis Operator(?:) - GeeksforGeeks

29 Nov, 2019
Elvis Operator (?:)It is used to return the not null value even the conditional expression is null. It is also used to check the null safety of values.
In some cases, we can declare a variable which can hold a null reference. If a variable st which contains null reference, before using st in program we will check its nullability. If variable st found as not null then its property will use otherwise use some other non-null value.
// Kotlin Program without using Elvis Operatorfun main(args: Array<String>){  var st: String? = null var st1: String? = "Geeks for Geeks" var len1:  Int = if (st != null) st.length else -1 var len2:  Int = if (st1 != null) st1.length else -1 println("Length of st is ${len1}")  println("Length of st1 is ${len2}")  }  
Output:
Length of st is -1
Length of st1 is 15

// Kotlin Program using Elvis Operatorfun main(args: Array<String>){    var st: String? = null var st1: String? = "Geeks for Geeks" var len1:  Int = st ?.length ?: -1 var len2:  Int = st1 ?.length ?:  -1      println("Length of st is ${len1}")  println("Length of st1 is ${len2}")  } 
Output:
Length of st is -1
Length of st1 is 15

Kotlin Basics
Kotlin
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Retrofit with Kotlin Coroutine in Android
How to Get Current Location in Android?
ImageView in Android with Example
How to Build a Weather App in Android?
Android SQLite Database in Kotlin
Suspend Function In Kotlin Coroutines
ScrollView in Android
Kotlin Coroutines on Android
Kotlin extension function
How to Use View Binding in RecyclerView Adapter Class in Android?
Python Tkinter | grid_location() and grid_size() method

21 Jun, 2022
Tkinter is used to develop GUI (Graphical User Interface) applications. It supports a variety of widgets as well as a variety of widgets methods or universal widget methods. 
This method returns a tuple containing (column, row) of any specified widget. Since this method is a widget method you cannot use it with master object ( or Tk() object). In order to use this method, you should first create a Frame and treat it as a parent (or master). 
Syntax: widget.grid_location(x, y)Parameters: x and y are the positions, relative to the upper left corner of the widget (parent widget).  
In below example, grid_location() is used to get the location of the widget in the Frame widget. 
Python3
# This imports all functions in tkinter modulefrom tkinter import * from tkinter.ttk import * # creating master windowmaster = Tk() # This method is used to get the position# of the desired widget available in any# other widgetdef click(event):         # Here retrieving the size of the parent    # widget relative to master widget    x = event.x_root - f.winfo_rootx()    y = event.y_root - f.winfo_rooty()     # Here grid_location() method is used to    # retrieve the relative position on the    # parent widget    z = f.grid_location(x, y)     # printing position    print(z) # Frame widget, will work as# parent for buttons widgetf = Frame(master)f.pack() # Button widgetsb = Button(f, text = "Button")b.grid(row = 2, column = 3) c = Button(f, text = "Button2")c.grid(row = 1, column = 0) # Here binding click method with mousemaster.bind("<Button-1>", click) # infinite loopmainloop()
This method is used to get the total number of grids present in any parent widget. This is a widget method so one cannot use it with master object. One has to create a Frame widget. 
Syntax: (columns, rows) = widget.grid_size()Return Value: It returns total numbers of columns and rows (grids).  
Below is the Python code- 
Python3
# This imports all functions in tkinter modulefrom tkinter import * from tkinter.ttk import * # creating master windowmaster = Tk() # This method is used to get the size# of the desired widget i.e number of grids# available in the widgetdef grids(event):         # Here, grid_size() method is used to get    # the total number grids available in frame    # widget    x = f.grid_size()     # printing (columns, rows)    print(x) # Frame widget, will work as# parent for buttons widgetf = Frame(master)f.pack() # Button widgetsb = Button(f, text = "Button")b.grid(row = 1, column = 2) c = Button(f, text = "Button2")c.grid(row = 1, column = 0) # Here binding click method with mousemaster.bind("<Button-1>", grids) # infinite loopmainloop()
Output: Every time you click the mouse button it will return the same value until more widgets are not added OR number of rows and columns are not increased. 
(3, 2)
 
rs1686740
germanshephered48
Python-gui
Python-tkinter
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scipy.ifft() in Python

29 Aug, 2020
With the help of scipy.ifft() method, we can compute the inverse fast fourier transformation by passing simple 1-D numpy array and it will return the transformed array by using this method.
Inverse Fast Fourier Transformation
Syntax : scipy.ifft(y)
Return : Return the transformed array.
Example #1 :
In this example we can see that by using scipy.ifft() method, we are able to get the inverse fast fourier transformation and return the transformed array.
Python3
# import scipy and numpyimport scipyimport numpy as np  x = np.array(np.arange(10))gfg_transformed = scipy.fft(x)# Using scipy.ifft() methodgfg_inversed = scipy.ifft(gfg_transformed)  print(gfg_inversed)
Output :
[0.-1.77635684e-16j 1.+0.00000000e+00j 2.+1.43710287e-16j
3.+0.00000000e+00j 4.-5.48924451e-17j 5.+0.00000000e+00j
6.-5.48924451e-17j 7.+0.00000000e+00j 8.+1.43710287e-16j
9.+0.00000000e+00j]
Example #2 :
Python3
# import scipy and numpyimport scipyimport numpy as np  x = np.array(np.arange(5))gfg_transformed = scipy.fft(x)# Using scipy.ifft() methodgfg_inversed = scipy.ifft(gfg_transformed)  print(gfg_inversed)
Output :
[0.+0.j 1.+0.j 2.+0.j 3.+0.j 4.+0.j]
Python scipy-stats-functions
Python-scipy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Python | datetime.timedelta() function
unordered_map rehash in C++ STL

18 May, 2022
The std::unordered_map::rehash() is a built in function C++ STL which sets the number of buckets in container to n or more. Syntax 
void rehash( size_type s );
If s is greater than the current buckets into the container then rehashed is done. The new bucket count can be greater than or equal to n.
If s is less than current bucket count then there may or may not be any effect of function. It totally depends upon compiler
Parameters : It takes New number of buckets into the container. Return type : Its return type is none. 
Example-1: 
CPP
// C++ code to illustrate the method// unordered_map rehash#include <bits/stdc++.h> using namespace std; int main(){    unordered_map<char, int> sample;     // Map initialization    sample = { { 'a', 2 }, { 'b', 4 }, { 'c', 6 } };     cout << " Size of container : " << sample.size() << endl;    cout << " Initial bucket count : " << sample.bucket_count() << endl;     // changing rehash     sample.rehash(30);    cout << " Size of container : " << sample.size() << endl;    cout << " Now bucket count is :  " << sample.bucket_count() << endl;    return 0;}
Size of container : 3
 Initial bucket count : 5
 Size of container : 3
 Now bucket count is :  31
Example-2: 
CPP
// C++ code to illustrate the method// unordered_map rehash#include <bits/stdc++.h> using namespace std; int main(){    unordered_map<int, int> sample;     // Map initialization    sample = { { 2, 2 }, { 3, 4 }, { 4, 6 }, { 5, 8 } };     cout << " Size of container : " << sample.size() << endl;    cout << " Initial bucket count : " << sample.bucket_count() << endl;     // changing rehash     sample.rehash(20);    cout << " Size of container : " << sample.size() << endl;    cout << " Now bucket count is :  " << sample.bucket_count() << endl;    return 0;}
Size of container : 4
 Initial bucket count : 7
 Size of container : 4
 Now bucket count is :  23
sweetyty
cpp-unordered_map
cpp-unordered_map-functions
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Bitwise Operators in C/C++
vector erase() and clear() in C++
Inheritance in C++
Priority Queue in C++ Standard Template Library (STL)
The C++ Standard Template Library (STL)
Substring in C++
Object Oriented Programming in C++
C++ Classes and Objects
Sorting a vector in C++
2D Vector In C++ With User Defined Size
HTML Comments

21 Jun, 2022
The comment tag (   ) is used to insert comments in the HTML code. It is a good practice of coding, so that coder and the reader can get help to understand the code. It is useful to understand steps of the complex code. The comment tag is helpful while the debugging of codes.
It is a simple piece of code that is wiped off (ignore) by web browsers i.e. , not displayed by the browser.
It helps the coder and reader to understand the piece of code used for especially in complex source code.
Syntax: 
<!-- Comments here -->
Types of HTML Comments: There are three types of comments in HTML which are: 
Single-line comment
Multi-lines comment
Using <comment> tag
Single-line comment:  Single line comment is given inside the ( <!–  comment –> ) tag. 
Implementation of the above concept is shown below:
HTML
<!DOCTYPE html><html> <body>    <!--This is heading Tag, It wont be displayed by the browser -->               <h1>GeeksforGeeks</h1>       <!--This is single line comment,It wont be displayed by the browser -->               <h2>This is single line comment</h2>   </body> </html>
Output: Here you can see the single-line comment. Single line comment will not display in the output.
Multi-line comment: Multiple lines can be given by the syntax (<!– –>), Basically it’s the same as we used in single line comment, difference is half part of the comment (” –> “), is appended where the intended comment line ends. 
Implementation of the above concept is shown below:
HTML
<!DOCTYPE html><html>  <body>        <!-- This is         heading tag -->        <h1>GeeksforGeeks</h1>     <!-- This is         multi-line         comment -->         <h2>This is multi-line comment</h2>     </body></html>
Output: Here we can see that in the comment section we have used multiple lines but still it’s not printed.
Using <comment> tag: There used to be an HTML <comment> tag, but currently it is not supported by any modern browser.
Implementation of the above browser is shown below:
HTML
<!DOCTYPE html><html> <body>    <comment>This is heading tag</comment>                 <h1>GeeksforGeeks</h1>       <comment>This is multi-line             comment    </comment>                 <h2>This is a comment using</h2>   </body> </html>
Output:  
Note: The <comment> tag is not supported by modern browsers. 
nidhi_biet
shubhamyadav4
kanheremahesh1729
HTML-Basics
HTML-Tags
HTML
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Number of days in a month in Python

Suppose we have one year Y and a month M, we have to return the number of days of that month for the given year. So if the Y = 1992 and M = 7, then the result will be 31, if the year is 2020, and M = 2, then the result is 29.
To solve this, we will follow these steps −
if m = 2, thenif y is a leap year, return 29, otherwise 28
if y is a leap year, return 29, otherwise 28
make an array with elements [1,3,5,7,8,10,12]
if m is in the list, then return 31, otherwise, return 30.
Let us see the following implementation to get a better understanding −
 Live Demo
class Solution(object):
   def numberOfDays(self, y, m):
      leap = 0
      if y% 400 == 0:
         leap = 1
      elif y % 100 == 0:
         leap = 0
      elif y% 4 == 0:
         leap = 1
      if m==2:
         return 28 + leap
      list = [1,3,5,7,8,10,12]
      if m in list:
         return 31
      return 30
ob1 = Solution()
print(ob1.numberOfDays(2020, 2))
2020
2
29