code-rag-bench/online-tutorials huggingface dataset:
Display the minimum of three integer values in Java

The following is an example displaying the minimum of three integer values.
 Live Demo
public class Demo {
   public static void main(String[] args) {
      int val1 = 99;
      int val2 = 87;
      int val3 = 130;
      System.out.println("Number 1 = "+val1);
      System.out.println("Number 2 = "+val2);
      System.out.println("Number 3 = "+val3);
      if (val2 < val1) {
         val1 = val2;
      }
      if (val3 < val1) {
         val1 = val3;
      }
      System.out.println("The smallest of three numbers: "+val1);
   }
}
Number 1 = 99
Number 2 = 87
Number 3 = 130
The smallest of three numbers: 87
In the above program, we have taken three integer variables, which will be compared.
int val1 = 99;
int val2 = 87;
int val3 = 130;
Now condition is used to check which of the integer value is the smallest.
if (val2 < val1) {
   val1 = val2;
}
if (val3 < val1) {
   val1 = val3;
}
The above returns the smallest value.
How To Change Default Shell In Linux - GeeksforGeeks

23 Dec, 2021
In most Linux systems, the default shell is bash but we can change that to any other shell-like zsh, fish, sh, and any other. In this article, we are going to show how to change that default shell to any other shell in Linux systems. To change the user’s shell, first, let’s find the current shell. There are many ways by which we can change the shell of any user on a Linux system. We are going to see three methods of changing the user’s shell.
In Linux systems, there is one file which is /etc/passwd. The /etc/passwd file stores essential information of user accounts, which is required during login. By using this file we can identify the current user login shell.
We are going to see the current user information in the /etc/file using the following command:
grep `whoami` /etc/passwd
In the above image we can see that the user nishant (current user) has home directory /home/nishant and the shell is /bin/sh
Now to change the shell, first, we need to see which shells are installed on the system. We can check installed shells using the following command :
cat /etc/shells
This will show all shells as follows:
Before moving further, first understand who can change the user shell
Users can change shell to any other shell listed in /etc/shells/.
The root account can be used to change any other user login shell.
If an account has a restricted login shell, then only the root can change that user’s shell.
usermod is a command that modifies the system account files. usemod can change the shell of Users by modifying file /etc/passwd. usermod command provides the -s or –shell option to change the user’s login shell.
In this example, we are going to change the shell of a user named nishant. We are going to change the shell from /bin/sh to /bin/bash of user nishant using usermod command.
sudo usermod --shell /bin/bash nishant
With usermod command mention shell and username after –shell option.
Now you can see the shell use changed. In the above commands, replace nishant with the user name whose shell has to change.
chsh is the utility to change a user’s login shell. chsh provides the -s option to change the user’s shell. This method also modifies the file /etc/passwd. Use the following command to change shells using chsh:
chsh -s /bin/bash nishant
 As we see in the above two methods, the usermod command and chsh utility modify the /etc/passwd file and change the user shell. We can do that manually also by editing the /etc/passwd file. Just change the shell after the username and home directory in the /etc/passwd file and save the file.
nano /etc/passwd
varshagumber28
How To
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install FFmpeg on Windows?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Set Git Username and Password in GitBash?
How to create a nested RecyclerView in Android
How to Install Jupyter Notebook on MacOS?
Sed Command in Linux/Unix with examples
AWK command in Unix/Linux with examples
grep command in Unix/Linux
cut command in Linux with examples
cp command in Linux with examples
Finding the Size Resolution of Image in Python - GeeksforGeeks

02 Sep, 2020
Let us see how to find the resolution of an image in Python. We will be solving this problem with two different libraries which are present in Python:
PIL
OpenCV
In our examples we will be using the following image:
The resolution of the above image is 600×135.
We will be using a library named Pillow to find the size(resolution) of the image. We will be using the function PIL.Image.open() to open and read our image and store the size in two variables by using the function img.size. 
Python3
# importing the moduleimport PILfrom PIL import Image  # loading the imageimg = PIL.Image.open("geeksforgeeks.png")  # fetching the dimensionswid, hgt = img.size  # displaying the dimensionsprint(str(wid) + "x" + str(hgt))
Output:
600x135

We will import OpenCV by importing the library cv2. We will load the image using the cv2.imread() function. After this, the dimensions can be found using the shape attribute. shape[0] will give us the height and shape[1] will give us the width. 
Python3
# importing the moduleimport cv2  # loading the imageimg = cv2.imread("geeksforgeeks.png")  # fetching the dimensionswid = img.shape[1]hgt = img.shape[0]  # displaying the dimensionsprint(str(wid) + "x" + str(hgt))
Output:
600x135

Python-OpenCV
Python-pil
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
Period parse() method in Java with Examples - GeeksforGeeks

28 Nov, 2018
The parse() method of Period Class is used to obtain a period from given string in the form of PnYnMnD where nY means n years, nM means n months and nD means n days.
Syntax:
public static Period parse(CharSequence text)
Parameters: This method accepts a single parameter text which is the String to be parsed.
Returns: This function returns the period which is the parsed representation of the String given as the parameter
Below is the implementation of Period.parse() method:
Example 1:
// Java code to demonstrate parse() method// to obtain period from given string  import java.time.Period;  class GFG {    public static void main(String[] args)    {          // Get the String to be parsed        String period = "P1Y2M21D";          // Parse the String into Period        // using parse() method        Period p = Period.parse(period);          System.out.println(p.getYears() + " Years\n"                           + p.getMonths() + " Months\n"                           + p.getDays() + " Days");    }}
1 Years
2 Months
21 Days

Example 2:
// Java code to demonstrate parse() method// to obtain period from given string  import java.time.Period;  class GFG {    public static void main(String[] args)    {          // Get the String to be parsed        String period = "-P1Y2M21D";          // Parse the String into Period        // using parse() method        Period p = Period.parse(period);          System.out.println(p.getYears() + " Years\n"                           + p.getMonths() + " Months\n"                           + p.getDays() + " Days");    }}
-1 Years
-2 Months
-21 Days

Reference: https://docs.oracle.com/javase/9/docs/api/java/time/Period.html#parse-java.lang.CharSequence-
Java-Functions
Java-Period
Java-time package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Stream In Java
Interfaces in Java
How to iterate any Map in Java
ArrayList in Java
Initialize an ArrayList in Java
Stack Class in Java
Multidimensional Arrays in Java
Singleton Class in Java
Implementation of Perceptron Algorithm for AND Logic Gate with 2-bit Binary Input - GeeksforGeeks

08 Jun, 2020
In the field of Machine Learning, the Perceptron is a Supervised Learning Algorithm for binary classifiers. The Perceptron Model implements the following function:
    
For a particular choice of the weight vector  and bias parameter , the model predicts output  for the corresponding input vector .
AND logical function truth table for 2-bit binary variables, i.e, the input vector  and the corresponding output  –
Now for the corresponding weight vector  of the input vector , the associated Perceptron Function can be defined as:
    
For the implementation, considered weight parameters are  and the bias parameter is .
Python Implementation:
# importing Python libraryimport numpy as np  # define Unit Step Functiondef unitStep(v):    if v >= 0:        return 1    else:        return 0  # design Perceptron Modeldef perceptronModel(x, w, b):    v = np.dot(w, x) + b    y = unitStep(v)    return y  # AND Logic Function# w1 = 1, w2 = 1, b = -1.5def AND_logicFunction(x):    w = np.array([1, 1])    b = -1.5    return perceptronModel(x, w, b)  # testing the Perceptron Modeltest1 = np.array([0, 1])test2 = np.array([1, 1])test3 = np.array([0, 0])test4 = np.array([1, 0])  print("AND({}, {}) = {}".format(0, 1, AND_logicFunction(test1)))print("AND({}, {}) = {}".format(1, 1, AND_logicFunction(test2)))print("AND({}, {}) = {}".format(0, 0, AND_logicFunction(test3)))print("AND({}, {}) = {}".format(1, 0, AND_logicFunction(test4)))
AND(0, 1) = 0
AND(1, 1) = 1
AND(0, 0) = 0
AND(1, 0) = 0

Here, the model predicted output () for each of the test inputs are exactly matched with the AND logic gate conventional output () according to the truth table for 2-bit binary input.Hence, it is verified that the perceptron algorithm for AND logic gate is correctly implemented.
Neural Network
Machine Learning
Python
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ML | Linear Regression
Reinforcement learning
Decision Tree
Decision Tree Introduction with example
Support Vector Machine Algorithm
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
ctime() Function in C/C++

The C library function char *ctime(const time_t *timer) returns a string representing the localtime based on the argument timer.
The returned string has the following format − Www Mmm dd hh:mm:ss yyyy, where Www is the weekday, Mmm the month in letters, dd the day of the month, hh:mm:ss the time, and yyyy the year.
The syntax is like below −
char *ctime(const time_t *timer)
This function takes the pointer to a time_t, which is containing the calendar time. It returns a string containing date, time info in human readable format.
 Live Demo
#include <stdio.h>
#include <time.h>
int main () {
   time_t curtime;
   time(&curtime);
   printf("Current time = %s", ctime(&curtime));
   return(0);
}
Current time = Thu May 23 17:18:43 2019
Dynamic method dispatch or Runtime polymorphism in Java

Runtime Polymorphism in Java is achieved by Method overriding in which a child class overrides a method in its parent. An overridden method is essentially hidden in the parent class, and is not invoked unless the child class uses the super keyword within the overriding method. This method call resolution happens at runtime and is termed as Dynamic method dispatch mechanism.
Let us look at an example.
class Animal {
   public void move() {
      System.out.println("Animals can move");
   }
}

class Dog extends Animal {
   public void move() {
      System.out.println("Dogs can walk and run");
   }
}

public class TestDog {

   public static void main(String args[]) {
   
      Animal a = new Animal(); // Animal reference and object
      Animal b = new Dog(); // Animal reference but Dog object

      a.move(); // runs the method in Animal class
      b.move(); // runs the method in Dog class
   }
}
This will produce the following result −
Animals can move
Dogs can walk and run
In the above example, you can see that even though b is a type of Animal it runs the move method in the Dog class. The reason for this is: In compile time, the check is made on the reference type. However, in the runtime, JVM figures out the object type and would run the method that belongs to that particular object.
Therefore, in the above example, the program will compile properly since Animal class has the method move. Then, at the runtime, it runs the method specific for that object.
How to use Swift to detect when AVPlayer video ends playing?

To detect the end of a video in swift we’ll need to create a video player, then use notifications to detect when the video stops playing. We’ll do this with help of an example in swift.
Let’s create a project and drag and drop any video with extension “mp4”, select copy resource if required and add to the target of our project.
Now we’ll programmatically first create a Video Player, then we’ll create url of the video in our project, and then we’ll play the video.
var videoPlayer: AVPlayer!
Now, in the viewDidAppear add the following code.
override func viewDidAppear(_ animated: Bool) {
   super.viewDidAppear(animated)
   let filepath: String? = Bundle.main.path(forResource: "Introduction", ofType: "mp4")
   if let videoPath = filepath {
      let url = URL.init(fileURLWithPath: videoPath)
      videoPlayer = AVPlayer(url: url)
      let playerLayer = AVPlayerLayer(player: videoPlayer)
      playerLayer.frame = self.view.bounds
      self.view.layer.addSublayer(playerLayer)
      videoPlayer.play()
   }
}
The above code will create a video player, and add it as a sublayer to our default view in the view controller.
Now we need to add an observer to our player, and also create an observer method that should be called when it detects the end of the video. Add the code block below to the viewDidAppear method.
NotificationCenter.default.addObserver(self, selector: #selector(videoDidEnd), name:
NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: nil)
Now we need to write the videoDidEnd method too, Inside this method you can perform any action you want, for now, we’ll just print “video ended” when the video ends and the notification center calls this method.
@objc func videoDidEnd(notification: NSNotification) {
   print("video ended")
}
When we run this code we get the following result.
Once the video stops playing we get output in our console.
Now, the above code does the required thing for us, but for efficient memory usage, we also need to remove the observer, which can be done using the code below.
deinit {
   NotificationCenter.default.removeObserver(self)
}
bitset count() in C++ STL - GeeksforGeeks

18 Jun, 2018
bitset::count() is an inbuilt STL in C++ which returns the number of set bits in the binary representation of a number.
Syntax:
int count() 

Parameter: The function accepts no parameter.
Return Value: The function returns the number of set bits. It returns the total number of ones or the number of set bits in the binary representation of the number if the passed number is an integer.
Below programs illustrates the bitset::count() function.
Program 1:
// CPP program to illustrate the// bitset::count() function#include <bits/stdc++.h>using namespace std;  int main(){    // Initialisation of a bitset    bitset<4> b1(string("1100"));    bitset<6> b2(string("001000"));      // Function to count the    // number of set bits in b1    int result1 = b1.count();    cout << b1 << " has " << result1         << " set bit\n";      // Function to count the    // number of set bits in b2    int result2 = b2.count();    cout << b2 << " has " << result2         << " set bit";      return 0;}
1100 has 2 set bit
001000 has 1 set bit

Program 2:
// CPP program to illustrate the// bitset::count() function// when the input is an integer#include <bits/stdc++.h>using namespace std;  int main(){    // Initialisation of a bitset    bitset<4> b1(16);    bitset<4> b2(18);      // Function to count the    // number of set bits in b1    int result1 = b1.count();    cout << b1 << " has " << result1         << " set bit\n";      // Function to count the    // number of set bits in b2    int result2 = b2.count();    cout << b2 << " has " << result2         << " set bit";      return 0;}
0000 has 0 set bit
0010 has 1 set bit

CPP-bitset
CPP-Functions
STL
C++
C++ Programs
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Iterators in C++ STL
Operator Overloading in C++
Friend class and function in C++
Polymorphism in C++
Inline Functions in C++
Header files in C/C++ and its uses
How to return multiple values from a function in C or C++?
C++ Program for QuickSort
C++ program for hashing with chaining
delete keyword in C++
Python – Check whether a string starts and ends with the same character or not (using Regular Expression)

18 May, 2021
Given a string. The task is to write a regular expression to check whether a string starts and ends with the same character.Examples:  
Input :  
abba
Output :  
Valid

Input :  
a
Output :  
Valid

Input :  
abc
Output :  
Invalid
Solution: The input can be divide into 2 cases:  
Single character string: All single character strings satisfies the condition that they start and end with the same character. The regex for a string with only 1 character will be-  
'^[a-z]$'
Multiple character string: Here we need to check whether the first and the last character is same or not. We do this using \1. The regex will be-  
'^([a-z]).*\1$'
The two regular expressions can be combined using |  
'^[a-z]$|^([a-z]).*\1$'
In this program, we will use search() method of re module.Below is the implementation. 
Python3
# Python program to check if a string starts# and ends with the same character # import re module as it provides# support for regular expressionsimport re # the regular  expressionregex = r'^[a-z]$|^([a-z]).*\1$' # function for checking the stringdef check(string):     # pass the regular expression    # and the string in the search() method    if(re.search(regex, string)):         print("Valid")     else:         print("Invalid")  if __name__ == '__main__' :     sample1 = "abba"    sample2 = "a"    sample3 = "abcd"     check(sample1)    check(sample2)    check(sample3)
Output :  
Valid
Valid
Invalid
 
surinderdawra388
Python Regex-programs
python-regex
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
PyQt5 – Getting the current index of selected item in ComboBox

22 Apr, 2020
In this article we will see how we can get the current index of the selected item the combo box. In order to do this we will use the currentIndex method.
Syntax : combo_box.currentIndex()
Argument : It takes no argument
Return : It return integer i.e index of selected item
Steps for implementation –
1. Create a combo box2. Add items to combo box3. Create push button4. Add action to the push button5. Create label to show count5. Inside the action get the index of current item selected in combo box with the help of currentIndex method and store it in variable6. Show the index in label with the help of setText method.
Below is the implementation –
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 600, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()      # method for widgets    def UiComponents(self):          # creating a combo box widget        self.combo_box = QComboBox(self)          # setting geometry of combo box        self.combo_box.setGeometry(200, 150, 120, 30)          # geek list        geek_list = ["Geek", "Geeky Geek", "Legend Geek", "Ultra Legend Geek"]          # adding list of items to combo box        self.combo_box.addItems(geek_list)          # creating push button        button = QPushButton("Show content ", self)          print(self.combo_box.count())          # adding action to button        button.pressed.connect(self.find)          # creating label         self.label = QLabel(self)          # setting geometry of the label        self.label.setGeometry(200, 200, 200, 30)      def find(self):          # finding the current item index  in combo box        index = self.combo_box.currentIndex()          # showing content on the screen though label        self.label.setText("Index : " + str(index))  # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python PyQt5-ComboBox
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Convert integer to string in Python
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Create a Pandas DataFrame from Lists
Python – Itertools.chain.from_iterable()

09 Mar, 2020
Python’s Itertool is a module that provides various functions that work on iterators to produce complex iterators. This module works as a fast, memory-efficient tool that is used either by themselves or in combination to form iterator algebra.
Note: For more information, refer to Python Itertools
The functions under itertools can be classified into 3 categories
Functions producing Infinite IteratorsFunctions producing Iterators terminating on the shortest input sequenceFunctions producing Combinatoric generators
Functions producing Infinite Iterators
Functions producing Iterators terminating on the shortest input sequence
Functions producing Combinatoric generators
The function chain.from_iterable() comes under the category of terminating iterators. This function takes a single iterable as an argument and all the elements of the input iterable should also be iterable and it returns a flattened iterable containing all the elements of the input iterable.
Syntax :
chain.from_iterable(iterable)

Example #1:
# Importing chain class from itertoolsfrom itertools import chain    # Single iterable containing iterable# elements(strings) is passed as inputfrom_iterable = chain.from_iterable(['geeks',                                     'for',                                      'geeks'])  # printing the flattened iterableprint(list(from_iterable))
Output :
[‘g’, ‘e’, ‘e’, ‘k’, ‘s’, ‘f’, ‘o’, ‘r’, ‘g’, ‘e’, ‘e’, ‘k’, ‘s’]
Example #2:
# Importing chain class from itertoolsfrom itertools import chain    # Single iterable containing iterable# elements(strings and list) is passed# as inputfrom_iterable = chain.from_iterable(['geeks',                                      'for',                                     'geeks',                                     ['w', 'i', 'n', 's']])  # printing the flattened iterableprint(list(from_iterable))
Output :
[‘g’, ‘e’, ‘e’, ‘k’, ‘s’, ‘f’, ‘o’, ‘r’, ‘g’, ‘e’, ‘e’, ‘k’, ‘s’, ‘w’, ‘i’, ‘n’, ‘s’]
Python-itertools
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 | os.path.join() method
Introduction To PYTHON
Python OOPs Concepts
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
Create a directory in Python
C++ Program To Check Whether The Length Of Given Linked List Is Even Or Odd

10 Jan, 2022
Given a linked list, the task is to make a function which checks whether the length of the linked list is even or odd. Examples:
Input : 1->2->3->4->NULL
Output : Even
Input : 1->2->3->4->5->NULL
Output : Odd
Method 1: Count the codes linearly Traverse the entire Linked List and keep counting the number of nodes. As soon as the loop is finished, we can check if the count is even or odd. You may try it yourself.Method 2: Stepping 2 nodes at a time Approach:
1. Take a pointer and move that pointer two nodes at a time
2. At the end, if the pointer is NULL then length is Even, else Odd.
C++
// C++ program to check length // of a given linklist #include <bits/stdc++.h>using namespace std;   // Defining structure class Node {     public:    int data;     Node* next; };   // Function to check the length // of linklist int LinkedListLength(Node* head) {     while (head && head->next)     {         head = head->next->next;     }     if (!head)         return 0;     return 1; }       // Push function void push(Node** head, int info) {     // Allocating node     Node* node = new Node();          // Info into node     node->data = info;           // Next of new node to head     node->next = (*head);       // head points to new node     (*head) = node; }   // Driver code int main(void) {     Node* head = NULL;           // Adding elements to Linked List     push(&head, 4);     push(&head, 5);     push(&head, 7);     push(&head, 2);     push(&head, 9);     push(&head, 6);     push(&head, 1);     push(&head, 2);     push(&head, 0);     push(&head, 5);     push(&head, 5);     int check = LinkedListLength(head);           // Checking for length of     // linklist     if(check == 0)     {         cout << "Even";     }     else    {         cout << "Odd";     }     return 0; } // This is code is contributed by rathbhupendra
Output:  
Odd
Time Complexity: O(n) Space Complexity: O(1)
Please refer complete article on Check whether the length of given linked list is Even or Odd for more details!
C++ Programs
Linked List
Linked List
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Passing a function as a parameter in C++
Const keyword in C++
cout in C++
Program to implement Singly Linked List in C++ using class
Different ways to print elements of vector
Linked List | Set 1 (Introduction)
Linked List | Set 2 (Inserting a node)
Reverse a linked list
Stack Data Structure (Introduction and Program)
Linked List | Set 3 (Deleting a node)
Can we declare the main () method as final in Java?

Yes, we can declare the main () method as final in Java. The compiler does not throw any error.
If we declare any method as final by placing the final keyword then that method becomes the final method.
The main use of the final method in Java is they are not overridden.
We can not override final methods in subclasses.
If we are using inheritance and we need some methods not to overridden in subclasses then we need to make it final so that those methods can't be overridden by subclasses.
We can access final methods in the subclass but we can not override final methods.
class BaseClass {
   public final void show(Object o) {
      System.out.println("BaseClass method");
   }
}
class DerivedClass extends BaseClass {
   public void show(Integer i) {
      System.out.println("DerivedClass method");
   }
}
public class Test {
   public static final void main(String[] args) { // declaring main () method with final keyword.
      BaseClass b = new BaseClass();
      DerivedClass d = new DerivedClass();
      b.show(new Integer(0));
      d.show(new Integer(0));
   }
}
BaseClass method
DerivedClass method
How do I find all documents with a field that is NaN in MongoDB?

To find all documents with a field that is NAN in MongoDB, use the following syntax
db.yourCollectionName.find( { yourFieldName: NaN })
Let us first create a collection with documents
> db.nanDemo.insertOne({"Score":0/0});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5ca251a26304881c5ce84b8a")
}
> db.nanDemo.insertOne({"Score":10/5});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5ca2520e6304881c5ce84b8b")
}
> db.nanDemo.insertOne({"Score":20/0});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5ca252156304881c5ce84b8c")
}
> db.nanDemo.insertOne({"Score":0/20});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5ca2521e6304881c5ce84b8d")
}
Following is the query to display all documents from a collection with the help of find() method
> db.nanDemo.find().pretty();
This will produce the following output
{ "_id" : ObjectId("5ca251a26304881c5ce84b8a"), "Score" : NaN }
{ "_id" : ObjectId("5ca2520e6304881c5ce84b8b"), "Score" : 2 }
{ "_id" : ObjectId("5ca252156304881c5ce84b8c"), "Score" : Infinity }
{ "_id" : ObjectId("5ca2521e6304881c5ce84b8d"), "Score" : 0 }
Following is the query to find all documents with a field that is NAN in MongoDB
> db.nanDemo.find( { Score: 0/0 });
This will produce the following output
{ "_id" : ObjectId("5ca251a26304881c5ce84b8a"), "Score" : NaN }
The alternate query is as follows
> db.nanDemo.find( { Score: NaN })
This will produce the following output
{ "_id" : ObjectId("5ca251a26304881c5ce84b8a"), "Score" : NaN }
Tryit Editor v3.7

HTML form attributes
Tryit: HTML form target attribute
403bypasser - Bypass 403 Restricted Directory - GeeksforGeeks

23 Sep, 2021
Access control is a fundamental component of data security that manages who’s allowed to access and use company data and resources. This access control technique is also applied to web-based applications. Development of certain web pages is done with high security. Although we can bypass this access control through automated tools. 
403bypasser tool automates the techniques used to circumvent access control restrictions on target pages. 403bypasser tool performs brute-forcing of possible directories in the target domain which can be bypassed. 403bypasser  tool is developed in the python language and is available on GitHub. 403bypasser  tool is an open-source tool and free to use. 403bypasser  tool supports multiple URLs scan at the same time. We can store the results on the text file for further use.
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/yunemse48/403bypasser.git
Step 2: Now use the following command to move into the directory of the tool. You have to move in the directory in order to run the tool.
cd 403bypasser
Step 3: You are in the directory of the 403Bypasser. Now you have to install a dependency of the 403Bypasser 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 403bypasser.py -h
Example 1: Single URL to scan
python3 403bypasser.py -u https://geeksforgeeks.org -d /secret
Example 2: Single directory to scan
python3 403bypasser.py -u https://geeksforgeeks.org -d /admin
Example 3: Path to list of URLs  
python3 403bypasser.py -U list.txt -d /admin
The results of https://geeksforgeeks.org are shown in the below screenshot.
The results of https://facebook.com are shown in the below screenshot.
The results of https://google.com are shown in the below screenshot.
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
Thread functions in C/C++
mv command in Linux with examples
nohup Command in Linux with Examples
scp command in Linux with Examples
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
Wiggle Animation Effect with CSS

The wiggle effect move or cause to move up and down or from side to side with small rapid movements.
You can try to run the following code to implement the winggle animation effect −
Live Demo
<html>
   <head>
      <style>

         .animated {
            background-image: url(/css/images/logo.png);
            background-repeat: no-repeat;
            background-position: left top;
            padding-top:95px;
            margin-bottom:60px;
            -webkit-animation-duration: 10s;
            animation-duration: 10s;
            -webkit-animation-fill-mode: both;
            animation-fill-mode: both;
         }

         @-webkit-keyframes wiggle {
            0% { -webkit-transform: skewX(9deg); }
            10% { -webkit-transform: skewX(-8deg); }
            20% { -webkit-transform: skewX(7deg); }
            30% { -webkit-transform: skewX(-6deg); }
            40% { -webkit-transform: skewX(5deg); }
            50% { -webkit-transform: skewX(-4deg); }
            60% { -webkit-transform: skewX(3deg); }
            70% { -webkit-transform: skewX(-2deg); }
            80% { -webkit-transform: skewX(1deg); }
            90% { -webkit-transform: skewX(0deg); }
            100% { -webkit-transform: skewX(0deg); }
         }

         @keyframes wiggle {
            0% { transform: skewX(9deg); }
            10% { transform: skewX(-8deg); }
            20% { transform: skewX(7deg); }
            30% { transform: skewX(-6deg); }
            40% { transform: skewX(5deg); }
            50% { transform: skewX(-4deg); }
            60% { transform: skewX(3deg); }
            70% { transform: skewX(-2deg); }
            80% { transform: skewX(1deg); }
            90% { transform: skewX(0deg); }
            100% { transform: skewX(0deg); }
         }

         .wiggle {
            -webkit-animation-name: wiggle;
            animation-name: wiggle;
            -webkit-animation-timing-function: ease-in;
            animation-timing-function: ease-in;
         }

         .animated.wiggle {
            -webkit-animation-duration: 0.75s;
            animation-duration: 0.75s;
         }
      </style>

   </head>
   <body>

      <div id="animated-example" class="animated wiggle"></div>
      <button onclick="myFunction()">Reload page</button>

      <script>
         function myFunction() {
            location.reload();
         }
      </script>
    </body>
</html>
Program to find minimum number of operations required to make one string substring of other in Python

Suppose we have two strings s and t, we have to find the minimum amount of operations required for s to make t a substring of s. Now, in each operation, we can choose any position in s and change the character at that position to any other character.
So, if the input is like s = "abbpqr", t = "bbxy", then the output will be 2, as we can take the substring "bbpq" and change 'p' to 'x' and 'q' to 'y'.
To solve this, we will follow these steps −
k := size of t, n := size of s
ans := 10^10
for i in range 0 to n - k, doss := substring of s[from index i to i+k-1]ans := minimum of ans and number of unmatched character of s and t
ss := substring of s[from index i to i+k-1]
ans := minimum of ans and number of unmatched character of s and t
return ans
Let us see the following implementation to get better understanding −
 Live Demo
class Solution:
   def solve(self, s, t):
      k, n = len(t), len(s)
      ans = 10**10
      for i in range(n - k + 1):
         ss = s[i:i+k]
         ans = min(ans, sum(ss[j]!=t[j] for j in range(k)))
      return ans
ob = Solution()
print(ob.solve("abbpqr", "bbxy"))
"abbpqr", "bbxy"
2
Java - log() Method

The method returns the natural logarithm of the argument.
double log(double d)

Here is the detail of parameters −
d − Any primitive data type.
d − Any primitive data type.
This method returns the natural logarithm of the argument.
public class Test { 

   public static void main(String args[]) {
      double x = 11.635;
      double y = 2.76;

      System.out.printf("The value of e is %.4f%n", Math.E);
      System.out.printf("log(%.3f) is %.3f%n", x, Math.log(x));
   }
}
This will produce the following result −
The value of e is 2.7183
log(11.635) is 2.454


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
What is the maximum length of string in Python?

Maximum length of a string is platform dependent and depends upon address space and/or RAM. The maxsize constant defined in sys module returns 263-1 on 64 bit system.
>>> import sys
>>> sys.maxsize
   9223372036854775807
The largest positive integer supported by the platform's Py_ssize_t type, is the maximum size lists, strings, dicts, and many other containers can have.
Difference between String class and StringBuffer class in Java

Strings, which are widely used in Java programming, are a sequence of characters. In Java programming language, strings are treated as objects. The Java platform provides the String class to create and manipulate strings.
Whereas, StringBuffer class is a thread-safe, mutable sequence of characters.
A string buffer is like a String, but can be modified.
It contains some particular sequence of characters, but the length and content of the sequence can be changed through certain method calls.
They are safe for use by multiple threads.
Every string buffer has a capacity.
Live Demo
public class Sample {
   public static void main(String args[]) {
      String str = new String("Hi welcome to tutorialspoint");
      System.out.println(str);
      StringBuffer sBuffer = new StringBuffer("test");
      sBuffer.append(" String Buffer");
      System.out.println(sBuffer);
   }
}
Hi welcome to tutorialspoint
test String Buffer
Create an option group in HTML

The HTML <optgroup> tag is used for grouping related options within your select list. This makes it easier for users to comprehend their choices when looking at a large list.
The following are the attributes −
You can try to run the following code to create an option group in HTML −
<!DOCTYPE html>
<html>
   <head>
      <title>HTML optgroup Tag</title>
   </head>
   <body>
      <select>
         <optgroup label = "India">
            <option value = "mumbai">Mumbai</option>
            <option value = "delhi">Delhi</option>
         </optgroup>
         <optgroup label = "USA">
            <option value = "florida">Florida</option>
            <option value = "newyork">New York</option>
         </optgroup>
      </select>
   </body>
</html>
C++ String Library - assign

It appends character c to the end of the string, increasing its length by one.
Following is the declaration for std::string::assign.
string& assign (const string& str);
string& assign (const string& str);
string& assign (const string& str);
c − It is a character object.
c − It is a character object.
str − It is a string object.
str − It is a string object.
It returns *this.
if an exception is thrown, there are no changes in the string.
In below example for std::string::assign.
#include <iostream>
#include <string>

int main () {
   std::string str;
   std::string base="Sairamkrishna is a one of the tech person in tutorialspoint.";

   str.assign(base);
   std::cout << str << '\n';

   str.assign(base,10,9);
   std::cout << str << '\n';

   str.assign("pangrams are cool",7);
   std::cout << str << '\n';

   str.assign("c-string");
   std::cout << str << '\n';

   str.assign(10,'*');
   std::cout << str << '\n';

   str.assign<int>(10,0x2D);
   std::cout << str << '\n';

   str.assign(base.begin()+16,base.end()-12);
   std::cout << str << '\n';

   return 0;
}
The sample output should be like this −
Sairamkrishna is a one of the tech person in tutorialspoint.
hna is a 
pangram
c-string
**********
----------
 a one of the tech person in tut

 Print
 Add Notes
 Bookmark this page
click_and_hold - Action Chains in Selenium Python - GeeksforGeeks

11 May, 2020
Selenium’s Python Module is built to perform automated testing with Python. ActionChains are a way to automate low-level interactions such as mouse movements, mouse button actions, keypress, and context menu interactions. This is useful for doing more complex actions like hover over and drag and drop. Action chain methods are used by advanced scripts where we need to drag an element, click an element, double click, etc.This article revolves around click_and_hold method on Action Chains in Python Selenium. click_and_hold method is used to hold down the left mouse button on an element.Syntax –
click_and_hold(on_element=None)
Example –
<input type ="text" name ="passwd" id ="passwd-id" />
To find an element one needs to use one of the locating strategies, For example,
element = driver.find_element_by_id("passwd-id")element = driver.find_element_by_name("passwd")
Now one can use click_and_hold method as an Action chain as below –
click_and_hold(on_element=element)

To demonstrate, click_and_hold method of Action Chains in Selenium Python. Let’ s visit https://www.geeksforgeeks.org/ and operate on an element.
Program –
# import webdriverfrom selenium import webdriver  # import Action chains from selenium.webdriver.common.action_chains import ActionChains  # create webdriver objectdriver = webdriver.Firefox()  # get geeksforgeeks.orgdriver.get("https://www.geeksforgeeks.org/")  # get element element = driver.find_element_by_link_text("Courses")  # create action chain objectaction = ActionChains(driver)  # click and hold  the itemaction.click_and_hold(on_element = element)  # perform the operationaction.perform()
Output –
Python-selenium
selenium
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Check if element exists in list in Python
Python | os.path.join() method
Selecting rows in pandas DataFrame based on conditions
Defaultdict in Python
Python | Get unique values from a list
Create a directory in Python
Python | Pandas dataframe.groupby()
Get current year in MySQL WHERE clause?

To get current year, use YEAR() along with CURDATE(). Let us first create a table −
mysql> create table DemoTable1360
    -> (
    -> JoiningYear int
    -> )
    -> ;
Query OK, 0 rows affected (0.51 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1360 values(1998);
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable1360 values(2018);
Query OK, 1 row affected (0.22 sec)
mysql> insert into DemoTable1360 values(2016);
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable1360 values(2019);
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable1360 values(2017);
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable1360 values(2015);
Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1360;
This will produce the following output −
+-------------+
| JoiningYear |
+-------------+
|        1998 |
|        2018 |
|        2016 |
|        2019 |
|        2017 |
|        2015 |
+-------------+
6 rows in set (0.00 sec)
Following is the query to get current year in MySQL where clause −
mysql> select * from DemoTable1360 where JoiningYear=year(curdate());
This will produce the following output −
+-------------+
| JoiningYear |
+-------------+
|        2019 |
+-------------+
1 row in set (0.00 sec)
How to change the code "Yes" to 1 in an R data frame column?

To change the code “Yes” to 1, we can use ifelse function and set the Yes to 1 and others to 0. For example, if we have a data frame called df that contains a character column x which has Yes and No values then we can convert those values to 1 and 0 using the command ifelse(df$x=="Yes",1,0).
Consider the below data frame −
 Live Demo
Agree<-sample(c("Yes","No"),20,replace=TRUE)
x<-rpois(20,5)
df1<-data.frame(Agree,x)
df1
  Agree x
1  No   6
2  No   4
3  Yes  5
4  No   9
5  No   4
6  No   0
7  Yes  4
8  No   5
9  No   6
10 No   5
11 No   6
12 No   2
13 No   6
14 No   2
15 Yes  3
16 Yes  9
17 No   3
18 Yes  3
19 No   0
20 Yes  7
Converting Yes to 1 and No to 0 in df1 −
df1$Agree<-ifelse(df1$Agree=="Yes",1,0)
df1
  Agree x
1  0    6
2  0    4
3  1    5
4  0    9
5  0    4
6  0    0
7  1    4
8  0    5
9  0    6
10 0    5
11 0    6
12 0    2
13 0    6
14 0    2
15 1    3
16 1    9
17 0    3
18 1    3
19 0    0
20 1    7
 Live Demo
Approved<-sample(c("Yes","No"),20,replace=TRUE)
y<-rnorm(20,30,2.4)
df2<-data.frame(Approved,y)
df2
   Approved   y
1  Yes     33.17910
2  No      31.69268
3  Yes     30.96484
4  Yes     34.12339
5  Yes     30.84079
6  No      27.57933
7  Yes     29.13050
8  No      32.55457
9  Yes     34.39399
10 No      30.22306
11 Yes     29.65322
12 Yes     29.42060
13 Yes     30.75312
14 No      32.25545
15 Yes     27.54001
16 No      25.93290
17 No      27.45960
18 Yes     26.28884
19 No      32.08387
20 Yes     28.60269
Converting Yes to 1 and No to 0 in df2 −
df2$Approved<-ifelse(df2$Approved=="Yes",1,0)
df2
  Approved     y
1  1      33.17910
2  0      31.69268
3  1      30.96484
4  1      34.12339
5  1      30.84079
6  0      27.57933
7  1      29.13050
8  0      32.55457
9  1      34.39399
10 0      30.22306
11 1      29.65322
12 1      29.42060
13 1      30.75312
14 0      32.25545
15 1      27.54001
16 0      25.93290
17 0      27.45960
18 1      26.28884
19 0      32.08387
20 1      28.60269