code-rag-bench/online-tutorials huggingface dataset:
Program to find whether a string is alphanumeric.

Any word that contains numbers and letters is known as alphanumeric. The following regular expression matches the combination of numbers and letters.
"^[a-zA-Z0-9]+$";
The matches method of the String class accepts a regular expression (in the form of a String) and matches it with the current string in case the match this method returns true else it returns false.
Therefore, to find whether a particular string contains alpha-numeric values −
Get the string.
Invoke the match method on it bypassing the above mentioned regular expression.
Retrieve the result.
import java.util.Scanner;
public class AlphanumericString {
   public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter input string: ");
      String input = sc.next();
      String regex = "^[a-zA-Z0-9]+$";
      boolean result = input.matches(regex);
      if(result) {
         System.out.println("Given string is alpha numeric");
      } else {
         System.out.println("Given string is not alpha numeric");
      }
   }
}
Enter input string:
abc123*
Given string is not alpha numeric
You can also compile a regular expression and match it with a particular string using the classes and methods (APIs) of the java.util.regex package. The following program is written using these APIs and it verifies whether a given string is alpha-numeric.
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Test {
   public static void main( String args[] ) {
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter input string: ");
      String input = sc.nextLine();
      String regex = "^[a-zA-Z0-9]+$";
      String data[] = input.split(" ");
      //Creating a pattern object
      Pattern pattern = Pattern.compile(regex);
      for (String ele : data){
         //creating a matcher object
         Matcher matcher = pattern.matcher(ele);
         if(matcher.matches()) {
            System.out.println("The word "+ele+": is alpha numeric");
         } else {
            System.out.println("The word "+ele+": is not alpha numeric");
         }
      }
   }
}
Enter input string:
hello* this$ is sample text
The word hello*: is not alpha numeric
The word this$: is not alpha numeric
The word is: is alpha numeric
The word sample: is alpha numeric
The word text: is alpha numeric
Ruby | Enumerable each_cons() function - GeeksforGeeks

05 Dec, 2019
The each_cons() of enumerable is an inbuilt method in Ruby iterates for consecutive N elements starting from each element every time. If no block is given, it returns the enumerator.
Syntax: enu.each_cons(N) { |obj| block }
Parameters: The function takes the block which is used to check the condition and N which specifies the number of consecutive elements to take.
Return Value: It returns the elements iterative consecutive for each element.
Example 1:
# Ruby program for each_cons method in Enumerable  # Initializeenu = (1.. 5)  # returns each element enu.each_cons(2){|obj| p obj}
Output:
[1, 2]
[2, 3]
[3, 4]
[4, 5]

Example 2:
# Ruby program for each_cons method in Enumerable  # Initializeenu = (1..10)  # returns each element enu.each_cons(4)
Output:
Enumerator: 1..10:each_cons(4)

Ruby Collections
Ruby Enumerable-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Ruby | Enumerator each_with_index function
How to Make a Custom Array of Hashes in Ruby?
Ruby | Decision Making (if, if-else, if-else-if, ternary) | Set - 1
Ruby | String concat Method
Ruby | pop() function
Ruby For Beginners
Ruby | String empty? Method
Ruby | Array shift() function
Ruby | Enumerable sum() function
Ruby | Class Method and Variables
Create empty dataframe in Pandas - GeeksforGeeks

28 Jul, 2020
The Pandas Dataframe is a structure that has data in the 2D format and labels with it. DataFrames are widely used in data science, machine learning, and other such places. DataFrames are the same as SQL tables or Excel sheets but these are faster in use.Empty DataFrame could be created with the help of pandas.DataFrame() as shown in below example:
Syntax: pandas.Dataframe()
Return: Return a Dataframe object.
Code:
Python3
# import pandas libraryimport pandas as pd  # create an empty dataframemy_df  = pd.DataFrame()  # show the dataframemy_df
Output:
The above output does not show anything lets us insert some heading to the DataFrame.
Code:
Python3
# import pandas libraryimport pandas as pd  # column name list col_names =  ['A', 'B', 'C']  # create an empty dataframe# with columnsmy_df  = pd.DataFrame(columns = col_names)  # show the dataframemy_df
Output:
The empty dataframe showing only headings.
Now let’s Insert some records in a dataframe.Code:
Python3
# import pandas libraryimport pandas as pd  # create a dataframemy_df = pd.DataFrame({'A': ['114', '345',                           '157788', '5626'],                       'B': ['shirt', 'trousers',                            'tie', 'belt'],                       'C': [1200, 1500,                            600, 352]}) # show the dataframemy_df
Output:
 
Python pandas-dataFrame
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Python | Get unique values from a list
Defaultdict in Python
Python | os.path.join() method
Python Classes and Objects
Create a directory in Python
Add headers inside the dropdown menu in Bootstrap

To add headers inside the dropdown menu, use the .dropdown-header class in Boostrap. The .dropdown-menu class is used to add a dropdown menu.
You can try to run the following code to implement the dropdown-header class in Bootstrap −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "container">
         <h2>Beverages</h2>
         <p>The following are the beverages available in India:</p>
         <div class = "dropdown">
            <button class = "btn btn-primary dropdown-toggle" type = "button" data-toggle="dropdown">Beverages
            <span class = "caret"></span></button>
            <ul class = "dropdown-menu">
               <li class = "dropdown-header">Energy Drinks</li>
               <li><a href = "#">Gatorade</a></li>
               <li><a href = "#">Sting</a></li>
               <li><a href = "#">Red Bull</a></li>
               <li class = "dropdown-header">Sof Drinks</li>
               <li><a href = "#">Pepsi</a></li>
               <li><a href = "#">Coca Cola</a></li>
            </ul>
         </div>
      </div>
   </body>
</html>
How to find the device driver version using PowerShell?

To find the device driver version using PowerShell, we need to use the class win32_PnpSignedDriver of the WMI object. For example,
Get-WmiObject win32_PnpSignedDriver
Or if you are using PowerShell core (PowerShell 6.0 or later), you can use the CIM Instance command. For example,
Get-CimInstance win32_PnpSignedDriver
To filter out the Drivers against their versions, use the below command to filter.
gwmi win32_PnpSignedDriver | Select Description, DriverVersion
ACPI x64-based PC                6.2.9200.16384    
UMBus Root Bus Enumerator        6.2.9200.16384    
WAN Miniport (IPv6)              6.2.9200.16384    
Composite Bus Enumerator         6.2.9200.16384    
WAN Miniport (IKEv2)             6.2.9200.16384    
WAN Miniport (SSTP)              6.2.9200.16384    
WAN Miniport (IP)                6.2.9200.16384
To search for the Specific driver with its name,
gwmi win32_PnpSignedDriver | where{$_.Description -eq "WAN Miniport (IPv6)"} | Select Description, DriverVersion
To search for the specific driver using wildcard character,
gwmi win32_PnpSignedDriver | where{$_.Description -like "Vmware*"} | Select Description, DriverVersion
To get the list of drivers on the remote computer use -ComputerName parameter in the WMI or CIM instance command as shown below.
gwmi win32_PnpSignedDriver -ComputerName Computer1
Rename all file names in your directory using Python

15 Aug, 2021
Given multiple files in a directory having different names, the task is to rename all those files in sorted order. We can use OS module in order to do this operation. The OS module in Python provides functions for interacting with the operating system and provides a portable way of using operating system-dependent functionality. We can go to the current working directory using os.getcwd() method and rename the files with os.rame() method.  
Below is the Python implementation : 
Python3
# Python program to rename all file# names in your directoryimport os os.chdir('D:\\Geeksforgeeks')print(os.getcwd()) for count, f in enumerate(os.listdir()):    f_name, f_ext = os.path.splitext(f)    f_name = "geek" + str(count)     new_name = f'{f_name}{f_ext}'    os.rename(f, new_name)
Output:  
 
Shivam_k
miguelrodrigo249
Python OS-file-module
Python os-module-programs
python-os-module
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Convert string tuples to list tuples

18 Oct, 2019
Sometimes, while working with Python we can have a problem in which we have a list of records in form of tuples in stringified form and we desire to convert them to list of tuples. This kind of problem can have it’s occurrence in data science domain. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using eval() + list comprehensionThis problem can be easily performed as one liner using the inbuilt function of eval(), which performs this task of string to tuple conversion and list comprehension.
# Python3 code to demonstrate working of# Converting string tuples to list tuples # using list comprehension + eval()  # Initializing list test_list = ["('gfg', 1)", "('is', 2)", "('best', 3)"]  # printing original list print("The original list is : " + str(test_list))  # Converting string tuples to list tuples # using list comprehension + eval()res = [eval(ele) for ele in test_list]  # printing resultprint("The list tuple after conversion : " + str(res))
The original list is : ["('gfg', 1)", "('is', 2)", "('best', 3)"]
The list tuple after conversion : [('gfg', 1), ('is', 2), ('best', 3)]

 
Method #2 : Using eval() + map()This task can also be performed using combination of above functions. The task performed by list comprehension above can be performed using map() in this method.
# Python3 code to demonstrate working of# Converting string tuples to list tuples # using map() + eval()  # Initializing list test_list = ["('gfg', 1)", "('is', 2)", "('best', 3)"]  # printing original list print("The original list is : " + str(test_list))  # Converting string tuples to list tuples # using map() + eval()res = list(map(eval, test_list))  # printing resultprint("The list tuple after conversion : " + str(res))
The original list is : ["('gfg', 1)", "('is', 2)", "('best', 3)"]
The list tuple after conversion : [('gfg', 1), ('is', 2), ('best', 3)]

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to auto like all the comments on a facebook post using JavaScript ?

07 Aug, 2020
In this article, we are going to learn how to like all the comments on a Facebook post automatically. Many times we want to like all the comments of friends on our post or on any other’s post, so this script helps us to save our time and effort by automatically liking all the comments on the post.
Approach:
Make a variable comments that points to an array of all the comment on the post.Run a loop to iterate all the comments.Now we check if the comment is not already liked.Then click on the like button of that comment.
Make a variable comments that points to an array of all the comment on the post.
Run a loop to iterate all the comments.
Now we check if the comment is not already liked.
Then click on the like button of that comment.
Below are the steps:
Go to facebook page using m.facebook.com
Sign in and open any post.
Open developer mode in Chrome by pressing Ctrl+Shift+I
Navigate to the console.
Now, run the below script.var comments =document.getElementsByClassName("touchable _2b0a");for(var i=0;i<comments.length;i++){    if(comments[i].style.color != "rgb(32, 120, 244)")    {        comments[i].click();    }}
var comments =document.getElementsByClassName("touchable _2b0a");for(var i=0;i<comments.length;i++){    if(comments[i].style.color != "rgb(32, 120, 244)")    {        comments[i].click();    }}
Output:
Output
Note: Please ensure that there is a stable internet connection available so that the script runs smoothly. Also ensure to visit facebook with m.facebook.com not www.facebook.com because this script works on mobile version of facebook only.
This tutorial is for educational purpose only, please don’t use it for disturbing anyone or any unethical way.
JavaScript-Misc
GBlog
JavaScript
TechTips
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
DSA Sheet by Love Babbar
GEEK-O-LYMPICS 2022 - May The Geeks Force Be With You!
Geek Streak - 24 Days POTD Challenge
What is Hashing | A Complete Tutorial
How To Switch From A Service-Based To A Product-Based Company?
Roadmap to Learn JavaScript For Beginners
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
Differences between Functional Components and Class Components in React
Hide or show elements in HTML using display property
PyQt5 - Auto Adjusting Progress Bar size - GeeksforGeeks

22 Apr, 2020
In this article we will see how to adjust the size of progress bar. Adjusting size means setting the size of progress bar as much as it is needed, nor too big nor to small, just the size which can comprise all the text in it. In order to do this we will use adjustSize method.
Note : Adjusting size will set the minimum required size. It doesn’t depend on the text added using setFormat method.
Syntax : bar.adjustSize()
Argument : It takes no argument.
Action performed : It will adjust the size according to the need.
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 progress bar        bar = QProgressBar(self)          # setting geometry to progress bar        bar.setGeometry(200, 100, 20, 50)          # setting the value        bar.setValue(100)                  # setting alignment to center        bar.setAlignment(Qt.AlignCenter)          # adjusting the size of the progress bar        bar.adjustSize()  App = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Defaultdict in Python
Python | Get unique values from a list
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
How do you throw an Exception without breaking a for loop in java?

Whenever an exception occurred in a loop the control gets out of the loop, by handling the exception the statements after the catch block in the method will get executed. But, the loop breaks.
 Live Demo
public class ExceptionInLoop{
   public static void sampleMethod(){
      String str[] = {"Mango", "Apple", "Banana", "Grapes", "Oranges"};
         try {
            for(int i=0; i<=10; i++) {
               System.out.println(str[i]);
               System.out.println(i);
            }
         }catch (ArrayIndexOutOfBoundsException ex){
            System.out.println("Exception occurred");
      }
      System.out.println("hello");
   }
   public static void main(String args[]) {
      sampleMethod();
   }
}
Mango
0
Apple
1
Banana
2
Grapes
3
Oranges
4
Exception occurred
Hello
One way to execute the loop without breaking is to move the code that causes the exception to another method that handles the exception.
If you have try catch within the loop it gets executed completely inspite of exceptions.
 Live Demo
public class ExceptionInLoop{
   public static void print(String str) {
      System.out.println(str);
   }
   public static void sampleMethod()throws ArrayIndexOutOfBoundsException {
      String str[] = {"Mango", "Apple", "Banana", "Grapes", "Oranges"};
         for(int i=0; i<=10; i++) {
            try {
               print(str[i]);
               System.out.println(i);
            } catch(Exception e){
            System.out.println(i);
         }
      }
   }
   public static void main(String args[]) {
      try{
         sampleMethod();
      }catch(ArrayIndexOutOfBoundsException e) {
         System.out.println("");
      }
   }
}
Mango
0
Apple
1
Banana
2
Grapes
3
Oranges
4
5
6
7
8
9
10
Animate transform-origin property with CSS Animation

To implement animation on the transform-origin property with CSS, you can try to run the following code
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         #demo1 {
            position: relative;
            height: 300px;
            width: 400px;
            border: 2px solid black;
            margin: 100px;
            padding: 5px;
         }
         #demo2 {
            padding: 30px;
            position: absolute;
            border: 1px solid black;
            background-color: orange;
            transform: rotate(45deg);
            transform-origin: 30% 10%;
            animation: mymove 3s infinite;
         }
         @keyframes mymove {
            30% {
               transform-origin: 0 0 0;
            }
         }
      </style>
   </head>
   <body>
      <h1>CSS transform-origin property</h1>
      <div id = "demo1">
         <div id="demo2">Demo</div>
      </div>
   </body>
</html>
How to create Definition Lists in HTML5?

Use the <dl> tag to add definition lists. The HTML <dl> tag is used for declaring a definition list. This tag is used within <dd> tag. A definition list is similar to other lists but in a definition list, each list item contains two entries; a term and a description.
You can try to run the following code to create Definition Lists in HTML5 −
<!DOCTYPE html>
<html>
   <head>
      <title>HTML dl Tag</title>
   </head>
   <body>
      <dl>
      <dt>Definition List</dt>
      <dd>A list of terms and their definitions/descriptions.</dd>
      <dt>C++</dt>
      <dd>C++ tutorial.</dd>
      <dt>Java</dt>
      <dd>Java tutorial.</dd>
      </dl>
   </body>
</html>
AI-Powered Code Completion in JupyterLab | by Robert Ritz | Towards Data Science

As a data scientist, you almost surely use a form of Jupyter Notebooks. Hopefully, you have moved over to the goodness of JupyterLab with its integrated sidebar, tabs, and more. When it first launched in 2018, JupyterLab was great but felt it was missing some things.
Now you can add a visual debugger and there is even a library called nbdev that allows you to author full Python packages and push them to PyPI. JupyterLab has become a complete IDE for data scientists. But one thing was still sub-optimal until recently, code completions.
Trying to use the built-in code completion in JupyterLab gets you something like this:
Kite, a company that makes code completion software for a variety of languages and IDE’s, recently launched Kite for JupyterLab. Now you can get something like this:
Simplify your life with logical autocompletion. It runs locally and doesn’t send your code to the cloud.
It isn’t perfect, and it certainly doesn’t read your mind. It IS a good upgrade for the default code completion though.
Kite for JupyterLab brings you one step closer to a full notebook based IDE.
Installing Kite for JupyterLab is fairly painless.
First, install Kite for Desktop. You can get the installer here. Versions are available for Windows, Mac, and Linux.Make sure your JupyterLab is version 2.2 or later. This is a pretty recent version of JupyterLab so you may need to upgrade with your install with conda or pip.Install the JupyterLab extension. You will need NodeJS installed just like for your other extensions.
First, install Kite for Desktop. You can get the installer here. Versions are available for Windows, Mac, and Linux.
Make sure your JupyterLab is version 2.2 or later. This is a pretty recent version of JupyterLab so you may need to upgrade with your install with conda or pip.
Install the JupyterLab extension. You will need NodeJS installed just like for your other extensions.
pip install jupyter-kitejupyter labextension install "@kiteco/jupyterlab-kite"
I’ve only used Kite for JupyterLab for about a week now. It’s not groundbreaking, but it certainly makes my coding experience that much better. Completions are noticeably faster than the native completions as well.
I’m using the free version of Kite, and the completions take place 100% locally. The best suggestion for me isn’t always at the top, but it’s usually in the top 5. As data scientists, we use LOTS of methods, and this is a nice way to get reminders when needed.
Happy coding!
Thanks for reading. You can find more about me here. Consider subscribing to get notifications when I publish. If you would like to directly support my articles you can use my referral link to sign up to become a Medium member.
Convert Dashes to CamelCase in PHP

Following is the code to convert dashes to CamelCase in PHP −
Sample input − this-is-a-test-string
Sample output − thisIsATestString
Note − There is no need to use regex or callbacks. It can be achieved using ucwords.
function dashToCamelCase($string, $capitalizeFirstCharacter = false) {
   $str = str_replace(' ', '', ucwords(str_replace('-', ' ', $string)));
   if (!$capitalizeFirstCharacter) {
      $str[0] = strtolower($str[0]);
   }
   return $str;
}
echo dashToCamelCase('this-is-a-string');
For PHP version>=5.3, the below code can be used −
function dashToCamelCase($string, $capitalizeFirstCharacter = false) {
   $str = str_replace('-', '', ucwords($string, '-'));
   if (!$capitalizeFirstCharacter) {
      $str = lcfirst($str);
   }
   return $str;
echo dashToCamelCase('this-is-a-test-string');
The 'lcfirst' function needs to be used instead of 'strtolower'.
Specify a path for a file or a directory in Java

The path for a file can be obtained using the method java.io.File.getPath(). This method returns the abstract pathname in the form of a pathname string and it requires no parameters.
A program that demonstrates this is given as follows −
 Live Demo
import java.io.File;
public class Demo {
   public static void main(String[] args) {
      File file = new File("C:" + File.separator + "jdk11.0.2" + File.separator, "demo1.java");
      System.out.println("Path = " + file.getPath());
   }
}
The output of the above program is as follows −
Path = C:/jdk11.0.2/demo1.java
Now let us understand the above program.
The path name of the file is printed using the method getPath(). A code snippet that demonstrates this is given as follows −
File file = new File("C:" + File.separator + "jdk11.0.2" + File.separator, "demo1.java");
System.out.println("Path = " + file.getPath());
How to delete registry key value (property) using PowerShell?

To delete the registry key value using PowerShell, we can use the Remove-ItemProperty command. Suppose we have the registry NodeSoftware and its Property is AppSecurity. We need to delete its key using the Remove-ItemProperty command.
PS C:\> Get-Item HKLM:\SOFTWARE\NodeSoftware
Hive: HKEY_LOCAL_MACHINE\SOFTWARE
Name    Property
----    --------
NodeSoftware    AppSecurity : 1
To delete the registry key,
PS C:\>Remove-ItemProperty HKLM:\SOFTWARE\NodeSoftware\ -Name AppSecurity -Force -Verbose
VERBOSE: Performing the operation "Remove Property" on target "Item: HKEY_LOCAL_MACHINE\SOFTWARE\NodeSoftware\ Property: AppSecurity".
You can also delete property by setting the location. For example,
PS C:\> Set-Location HKLM:\SOFTWARE\NodeSoftware
PS HKLM:\SOFTWARE\NodeSoftware> Remove-ItemProperty -Path . -Name AppSecurity -Force -Verbose
To remove Item property using Pipeline,
Get-Item HKLM:\SOFTWARE\NodeSoftware | Remove-ItemProperty -Name AppSecurity -Force -Verbose
Check if count of divisors is even or odd in Python

Suppose we have a number n, we have to find its total number of divisors are even or odd.
So, if the input is like n = 75, then the output will be Even, as the divisors are [1, 3, 5, 15, 25, 75].
To solve this we shall follow one simple and efficient approach. We have observed that when a number is perfect square then only it has odd number of divisors. So if the number is not perfect square then it will have even divisors. So here we will only check whether the number is perfect square or not and based on this we can return "odd" or "even" as output.
To solve this, we will follow these steps −
if n < 1 is non-zero, thenreturn
return
sqrt := square root of n
if sqrt*sqrt is same as n, thenreturn 'Odd'
return 'Odd'
otherwise,return 'Even'
return 'Even'
Let us see the following implementation to get better understanding −
 Live Demo
def solve(n):
   if n < 1:
      return
   sqrt = n**0.5
   if sqrt*sqrt == n:
      return 'Odd'
   else:
      return 'Even'
n = 75
print(solve(n))
75
Even
java.util.regex.Pattern.quote() Method

The java.util.regex.Pattern.quote(String s) method returns a literal pattern String for the specified String.
Following is the declaration for java.util.regex.Pattern.quote(String s) method.
public static String quote(String s)

s − The string to be literalized.
s − The string to be literalized.
A literal string replacement.
The following example shows the usage of java.util.regex.Pattern.quote(String s) method.
package com.tutorialspoint;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class PatternDemo {
   private static String REGEX = "dog$";
   private static String INPUT = "The dog$ says meow " + "All dog$ say meow.";
   private static String REPLACE = "cat";

   public static void main(String[] args) {
      Pattern pattern = Pattern.compile(Pattern.quote(REGEX));
      
      // get a matcher object
      Matcher matcher = pattern.matcher(INPUT); 
      INPUT = matcher.replaceAll(REPLACE);
      System.out.println(INPUT);
   }
}
Let us compile and run the above program, this will produce the following result −
The cat says meow All cat say meow.

 Print
 Add Notes
 Bookmark this page
Write a program in Java to find the missing positive number in a given array of unsorted integers

Let’s suppose we have given an array of unsorted integers. The task is to find the positive missing number which is not present in the given array in the range [0 to n]. For example,
Input-1 −
N = 9
arr = [0,2,5,9,1,7,4,3,6]
Output −
8
Explanation − In the given unsorted array, ‘8’ is the only positive integer that is missing, thus the output is ‘8’.
Input-2 −
N = 1
arr = [0]
Output −
1
Explanation − In the given array, ‘1’ is the only one positive integer which is missing, thus the output is ‘1’.
There are several approaches to solve this particular problem. However, we can solve this problem in linear time O(n) and constant space O(1).
Since we know that our array is of size n and it contains exactly elements in the range of [0 to n]. So, if we do XOR operation of each of the elements and its index with ‘n’, then we can find the resultant number as a unique number that is missing from the array.
Take Input of N size of the array with elements in the range [0 to n].
Take Input of N size of the array with elements in the range [0 to n].
An integer function findMissingNumber(int arr[], int size) takes an array and its size as input and returns the missing number.
An integer function findMissingNumber(int arr[], int size) takes an array and its size as input and returns the missing number.
Let’s take n as a missing number to perform XOR operation.
Let’s take n as a missing number to perform XOR operation.
Iterate over all the array elements and perform XOR operation with each of the array elements and its indexes with respect to missing number, i.e., n
Iterate over all the array elements and perform XOR operation with each of the array elements and its indexes with respect to missing number, i.e., n
Now return the missing number.
Now return the missing number.
public class Solution {
   public static int findMissingNumber(int arr[], int size){
      int missing_no= size;
      for(int i=0;i<size;i++){
         missing_no^= i^arr[i];
      }
      return missing_no;
   }
   public static void main(String[] args){
      int arr[] = {0,4,2,1,6,3};
      int n = arr.length;
      int a=findMissingNumber(arr, n);
      System.out.println(a);
   }
}
Running the above code will generate the output as,
5
In the given array {0,4,2,1,6,3}, ‘5’ is missing, thus we will return 5.
isalnum() function in C Language

The function isalnum() is used to check that the character is alphanumeric or not. It returns non-zero value, if the character is alphanumeric means letter or number otherwise, returns zero. It is declared in “ctype.h” header file.
Here is the syntax of isalnum() in C language,
int isalnum(int character);
Here,
character − The character which is to be checked.
Here is an example of isalnum() in C language,
 Live Demo
#include<stdio.h>
#include<ctype.h>
int main() {
   char val1 = 's';
   char val2 = '8';
   char val3 = '$';
   if(isalnum(val1))
   printf("The character is alphanumeric\n");
   else
   printf("The character is not alphanumeric\n");
   if(isalnum(val2))
   printf("The character is alphanumeric\n");
   else
   printf("The character is not alphanumeric");
   if(isalnum(val3))
   printf("The character is alphanumeric\n");
   else
   printf("The character is not alphanumeric");
   return 0;
}
The character is alphanumeric
The character is alphanumeric
The character is not alphanumeric
In the above program, three variables of char type are declared and initialized with the values. These variables are checked that these values are alphanumeric or not by using isalnum() function.
if(isalnum(val1))
printf("The character is alphanumeric\n");
else
printf("The character is not alphanumeric\n");
Print structured MySQL SELECT at command prompt

To print, the syntax is as follows −
mysql -uroot -t -e "your Select Query  " -p
To implement the above syntax, let us open the command prompt −
Now, reach the MySQL bin −
Let us implement the above syntax to easily print structured SQL select. Following is the query −
This will produce the following output −
Create a grid of cards using Bootstrap 4 .card-deck class

Use the card-deck class in Bootstrap to form a grid of cards with equal width and height.
Set the cards inside the following div −
<div class="card-deck">
  <! - - deck- - >
</div>
Let us set the grid of cards now in the card-deck class −
<div class="card-deck">
  <div class="card bg-primary">
    <div class="card-body text-center">
    <p class="card-text">Nothing new!</p>
  </div>
</div>
You can try to run the following code to implement the card-deck class
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  </head>

<body>

  <div class="container">  
    <h3>Demo Messages</h3>
    <p>Note: Resize the browser to check the effect.</p>
    <div class="card-deck">
      <div class="card bg-primary">
        <div class="card-body text-center">
          <p class="card-text">Nothing new!</p>
        </div>
      </div>
      <div class="card bg-warning">
        <div class="card-body text-center">
         <p class="card-text">Warning! Compile-time error!</p>
         <p class="card-text">Check again!</p>
      </div>
    </div>
    <div class="card bg-success">
      <div class="card-body text-center">
        <p class="card-text">We won!</p>
      </div>
    </div>
  </div>
</div>

</body>
</html>
How to convert date to timestamp in MongoDB

To convert date to timestamp in MongoDB, use aggregate(). Let us create a collection with documents −
> db.demo93.insertOne({"UserName":"Chris","ArrivalDate":new ISODate("2020-10-01")});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e2d4b6479799acab037af68")
}
> db.demo93.insertOne({"UserName":"David","ArrivalDate":new ISODate("2019-12-31")});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e2d4b7379799acab037af69")
}
Display all documents from a collection with the help of find() method −
> db.demo93.find();
This will produce the following output −
{ "_id" : ObjectId("5e2d4b6479799acab037af68"), "UserName" : "Chris", "ArrivalDate" : ISODate("2020-10-01T00:00:00Z") }
{ "_id" : ObjectId("5e2d4b7379799acab037af69"), "UserName" : "David", "ArrivalDate" : ISODate("2019-12-31T00:00:00Z") }
Following is the query to convert date to timestamp in MongoDB −
> db.demo93.aggregate([
...    { "$match": { "UserName": "Chris" }},
...    { "$addFields": {
...       "timestamp": { "$toLong": "$ArrivalDate" }
...    }}
... ]);
This will produce the following output −
{ "_id" : ObjectId("5e2d4b6479799acab037af68"), "UserName" : "Chris", "ArrivalDate" : ISODate("2020-10-01T00:00:00Z"), "timestamp" : NumberLong("1601510400000") }
Python - Tkinter  Relief styles

The relief style of a widget refers to certain simulated 3-D effects around the outside of the widget. Here is a screenshot of a row of buttons exhibiting all the possible relief styles −
Here is list of possible constants which can be used for relief attribute.
FLAT
RAISED
SUNKEN
GROOVE
RIDGE
from Tkinter import *
import Tkinter

top = Tkinter.Tk()

B1 = Tkinter.Button(top, text ="FLAT", relief=FLAT )
B2 = Tkinter.Button(top, text ="RAISED", relief=RAISED )
B3 = Tkinter.Button(top, text ="SUNKEN", relief=SUNKEN )
B4 = Tkinter.Button(top, text ="GROOVE", relief=GROOVE )
B5 = Tkinter.Button(top, text ="RIDGE", relief=RIDGE )

B1.pack()
B2.pack()
B3.pack()
B4.pack()
B5.pack()
top.mainloop()
When the above code is  executed, it produces the following result −

    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Python PIL | Image.save() method - GeeksforGeeks

17 Jul, 2019
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The Image module provides a class with the same name which is used to represent a PIL image. The module also provides a number of factory functions, including functions to load images from files, and to create new images.
Image.save() Saves this image under the given filename. If no format is specified, the format to use is determined from the filename extension, if possible.
Keyword options can be used to provide additional instructions to the writer. If a writer doesn’t recognise an option, it is silently ignored. The available options are described in the image format documentation for each writer.
You can use a file object instead of a filename. In this case, you must always specify the format. The file object must implement the seek, tell, and write methods, and be opened in binary mode.
Syntax: Image.save(fp, format=None, **params)
Parameters:
fp – A filename (string), pathlib.Path object or file object.format – Optional format override. If omitted, the format to use is determined from the filename extension. If a file object was used instead of a filename, this parameter should always be used.options – Extra parameters to the image writer.
Returns: None
Raises:
KeyError – If the output format could not be determined from the file name. Use the format option to solve this.IOError – If the file could not be written. The file may have been created, and may contain partial data.
Image Used:
     # Importing Image module from PIL package from PIL import Image import PIL   # creating a image object (main image) im1 = Image.open(r"C:\Users\System-Pc\Desktop\flower1.jpg")   # save a image using extensionim1 = im1.save("geeks.jpg")
Output:
Python-pil
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
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
Convert integer to string in Python
DecimalFormat setRoundingMode() method in Java - GeeksforGeeks

01 Apr, 2019
The setRoundingMode() method is a built-in method of the java.text.DecimalFomrat class in Java and is used to set the RoundingMode to be used with this DecimalFormat instance to round-off the decimal digits.
Syntax:
public void setRoundingMode(RoundingMode roundingMode)

Parameters: The function accepts a single parameter roundingMode which is the RoundingMode instance to be set for this DecimalFormat instance.
Return Value: The function does not returns any value.
Below is the implementation of the above function:
Program 1:
// Java program to illustrate the// setRoundingMode() method  import java.text.DecimalFormat;import java.text.DecimalFormatSymbols;import java.math.RoundingMode;import java.util.Currency;import java.util.Locale;  public class Main {    public static void main(String[] args)    {          // Create the DecimalFormat Instance        DecimalFormat deciFormat = new DecimalFormat();          // Set the rounding mode as CEILING        deciFormat.setRoundingMode(RoundingMode.CEILING);          System.out.println(deciFormat.format(1234.5555));    }}
1, 234.556

Program 2:
// Java program to illustrate the// setRoundingMode() method  import java.text.DecimalFormat;import java.text.DecimalFormatSymbols;import java.math.RoundingMode;import java.util.Currency;import java.util.Locale;  public class Main {    public static void main(String[] args)    {          // Create the DecimalFormat Instance        DecimalFormat deciFormat = new DecimalFormat();          // Set the rounding mode as HALF_DOWN        deciFormat.setRoundingMode(RoundingMode.HALF_DOWN);          System.out.println(deciFormat.format(1234.5555));    }}
1, 234.555

Reference: https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html#setRoundingMode(java.math.RoundingMode)
Java-DecimalFormat
Java-Functions
Java-text 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
Singleton Class in Java
Multidimensional Arrays in Java
How to Remove columns in Numpy array that contains non-numeric values? - GeeksforGeeks

25 Oct, 2020
Many times we have non-numeric values in NumPy array. These values need to be removed, so that array will be free from all these unnecessary values and look more decent. It is possible to remove all columns containing Nan values using the Bitwise NOT operator and np.isnan() function.
Example 1:
Python3
# Importing Numpy moduleimport numpy as np  # Creating 2X3 2-D Numpy arrayn_arr = np.array([[10.5, 22.5, np.nan],                  [41, 52.5, np.nan]])  print("Given array:")print(n_arr)  print("\nRemove all columns containing non-numeric elements ")print(n_arr[:, ~np.isnan(n_arr).any(axis=0)])
Output:
In the above example, we remove columns containing non-numeric values from the 2X3 Numpy array.
Example 2:
Python3
# Importing Numpy moduleimport numpy as np  # Creating 3X3 2-D Numpy arrayn_arr = np.array([[10.5, 22.5, 10.5],                  [41, 52.5, 25],                  [100, np.nan, 41]])  print("Given array:")print(n_arr)  print("\nRemove all columns containing non-numeric elements ")print(n_arr[:, ~np.isnan(n_arr).any(axis=0)])
Output:
In the above example, we remove columns containing non-numeric values from the 3X3 Numpy array.
Example 3:
Python3
# Importing Numpy moduleimport numpy as np  # Creating 5X3 2-D Numpy arrayn_arr = np.array([[10.5, 22.5, 3.8],                  [23.45, 50, 78.7],                  [41, np.nan, np.nan],                  [20, 50.20, np.nan],                  [18.8, 50.60, 8.8]])  print("Given array:")print(n_arr)  print("\nRemove all columns containing non-numeric elements ")print(n_arr[:, ~np.isnan(n_arr).any(axis=0)])
Output:
In the above example, we remove columns containing non-numeric values from the 5X3 Numpy array.
Python numpy-arrayManipulation
Python-numpy
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
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
numpy.tril_indices() function | Python - GeeksforGeeks

22 Apr, 2020
numpy.tril_indices() function return the indices for the lower-triangle of an (n, m) array.
Syntax : numpy.tril_indices(n, k = 0, m = None)Parameters :n : [int] The row dimension of the arrays for which the returned indices will be valid.k : [int, optional] Diagonal offset.m : [int, optional] The column dimension of the arrays for which the returned arrays will be valid. By default m is taken equal to n.Return : [tuple of arrays] The indices for the triangle. The returned tuple contains two arrays, each with the indices along one dimension of the array.
Code #1 :
# Python program explaining# numpy.tril_indices() function  # importing numpy as geek import numpy as geek  gfg = geek.tril_indices(3)  print (gfg)
Output :
(array([0, 1, 1, 2, 2, 2]), array([0, 0, 1, 0, 1, 2]))

 Code #2 :
# Python program explaining# numpy.tril_indices() function  # importing numpy as geek import numpy as geek  gfg = geek.tril_indices(3, 2)  print (gfg)
Output :
(array([0, 0, 0, 1, 1, 1, 2, 2, 2]), array([0, 1, 2, 0, 1, 2, 0, 1, 2]))

Python numpy-arrayManipulation
Python-numpy
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?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Defaultdict in Python
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
Java | Functions | Question 3 - GeeksforGeeks

28 Jun, 2021
class Test {public static void swap(Integer i, Integer j) {      Integer temp = new Integer(i);      i = j;      j = temp;   }   public static void main(String[] args) {      Integer i = new Integer(10);      Integer j = new Integer(20);      swap(i, j);      System.out.println("i = " + i + ", j = " + j);   }}
(A) i = 10, j = 20(B) i = 20, j = 10(C) i = 10, j = 10(D) i = 20, j = 20Answer: (A)Explanation: Parameters are passed by value in JavaQuiz of this Question
Functions
Java-Functions
Java Quiz
Functions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java | Constructors | Question 3
Java | Constructors | Question 5
Java | Exception Handling | Question 2
Java | final keyword | Question 1
Java | Class and Object | Question 1
Java | Abstract Class and Interface | Question 2
Java | Exception Handling | Question 4
Java | Exception Handling | Question 3
Java | Exception Handling | Question 7
Java | Exception Handling | Question 8
Difference between Append, Extend and Insert in Python - GeeksforGeeks

05 Jul, 2021
Lists are just like dynamically sized arrays, declared in other languages (vector in C++ and ArrayList in Java). Lists need not be homogeneous always which makes it the most powerful tool in Python. A single list may contain DataTypes like Integers, Strings, as well as Objects. 
Lists are mutable, and hence, they can be altered even after their creation. Lists have various methods, the most commonly used list method are append(), insert(), extend(), etc. In this article, we are going to discuss the difference between append(), insert(), and, extend() method in Python lists.
It adds an element at the end of the list. The argument passed in the append function is added as a single element at end of the list and the length of the list is increased by 1.
Syntax:
list_name.append(element)
The element can be a string, integer, tuple, or another list.
Example:
Python3
# python program to demonstrate# working of append function # assign listl = ['geeks'] # use methodl.append('for')l.append('geeks') # display listprint(l)
Output:
['geeks', 'for', 'geeks']
This method can be used to insert a value at any desired position. It takes two arguments-element and the index at which the element has to be inserted.
Syntax:
list_name(index,element)
The element can be a string, object, or integer.
Example:
Python3
# python program to demonstrate# working of insert function # assign listl = ['geeks', 'geeks'] # use methodl.insert(1, 'for') # display listprint(l)
Output:
['geeks', 'for', 'geeks']
This method appends each element of the iterable (tuple, string, or list) to the end of the list and increases the length of the list by the number of elements of the iterable passed as an argument.
Syntax:
list_name.extend(iterable)
Example:
Python3
# python program to demonstrate# working of extend function # assign listl = ['hello', 'welcome', 'to'] # use methodl.extend(['geeks', 'for', 'geeks']) # display listprint(l)
Output:
['hello', 'welcome', 'to', 'geeks', 'for', 'geeks']
Comparing the methods in a single program:
Python3
# Python program to demonstrate# comparison between the three methods # assign listslist_1 = [1, 2, 3]list_2 = [1, 2, 3]list_3 = [1, 2, 3] a = [2, 3] # use methodslist_1.append(a)list_2.insert(3, a)list_3.extend(a) # display listsprint(list_1)print(list_2)print(list_3)
Output:
[1, 2, 3, [2, 3]]
[1, 2, 3, [2, 3]]
[1, 2, 3, 2, 3]
rajeev0719singh
python-list
python-list-functions
Difference Between
Python
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Difference Between Method Overloading and Method Overriding in Java
Difference between Prim's and Kruskal's algorithm for MST
Difference between Internal and External fragmentation
Difference between Compile-time and Run-time Polymorphism in Java
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe