code-rag-bench/online-tutorials huggingface dataset:
Matcher group() method in Java with Examples - GeeksforGeeks

26 Nov, 2018
The group() method of Matcher Class is used to get the input subsequence matched by the previous match result.
Syntax:
public String group()

Parameters: This method do not takes any parameter.
Return Value: This method returns the String which is the input subsequence matched by the previous match.
Exception: This method throws IllegalStateException if no match has yet been attempted, or if the previous match operation failed.
Below examples illustrate the Matcher.group() method:
Example 1:
// Java code to illustrate end() method  import java.util.regex.*;  public class GFG {    public static void main(String[] args)    {          // Get the regex to be checked        String regex = "(G*s)";          // Create a pattern from regex        Pattern pattern            = Pattern.compile(regex);          // Get the String to be matched        String stringToBeMatched            = "GeeksForGeeks";          // Create a matcher for the input String        Matcher matcher            = pattern                  .matcher(stringToBeMatched);          // Get the current matcher state        MatchResult result            = matcher.toMatchResult();        System.out.println("Current Matcher: "                           + result);          while (matcher.find()) {            // Get the group matched using group() method            System.out.println(matcher.group());        }    }}
Current Matcher: java.util.regex.Matcher[pattern=(G*s) region=0, 13 lastmatch=]ss
Example 2:
// Java code to illustrate end() method  import java.util.regex.*;  public class GFG {    public static void main(String[] args)    {          // Get the regex to be checked        String regex = "(G*G)";          // Create a pattern from regex        Pattern pattern            = Pattern.compile(regex);          // Get the String to be matched        String stringToBeMatched            = "GFG FGF GFG";          // Create a matcher for the input String        Matcher matcher            = pattern                  .matcher(stringToBeMatched);          // Get the current matcher state        MatchResult result            = matcher.toMatchResult();        System.out.println("Current Matcher: "                           + result);          while (matcher.find()) {            // Get the group matched using group() method            System.out.println(matcher.group());        }    }}
Current Matcher: java.util.regex.Matcher[pattern=(G*G) region=0, 11 lastmatch=]GGGGG
Reference: Oracle Doc
Java - util package
Java-Functions
Java-Matcher
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
Node.js os.freemem() Method - GeeksforGeeks

13 Oct, 2021
The os.freemem() method is an inbuilt application programming interface of the os module which is used to get the amount of free system memory.
Syntax:
os.freemem()
Parameters: This method does not accept any parameters.
Return Value: This method returns an integer value that specifies the amount of free system memory in bytes.
Below examples illustrate the use of os.freemem() method in Node.js:
Example 1:
// Node.js program to demonstrate the   // os.freemem() method  // Allocating os moduleconst os = require('os');  // Printing os.freemem() valueconsole.log(os.freemem());
Output:
4158910464

Example 2:
// Node.js program to demonstrate the   // os.freemem() method  // Allocating os moduleconst os = require('os');  // Printing os.freemem() valuevar free_memory = os.freemem();var free_mem_in_kb = free_memory/1024;var free_mem_in_mb = free_mem_in_kb/1024;var free_mem_in_gb = free_mem_in_mb/1024;   free_mem_in_kb = Math.floor(free_mem_in_kb);free_mem_in_mb = Math.floor(free_mem_in_mb);free_mem_in_gb = Math.floor(free_mem_in_gb);   free_mem_in_mb = free_mem_in_mb%1024;free_mem_in_kb = free_mem_in_kb%1024;free_memory = free_memory%1024;  console.log("Free memory: " + free_mem_in_gb + "GB "      + free_mem_in_mb + "MB " + free_mem_in_kb      + "KB and " + free_memory + "Bytes");
Output:
Free memory: 4GB 110MB 88KB and 0Bytes

Note: The above program will compile and run by using the node index.js command.
Reference: https://nodejs.org/api/os.html#os_os_freemem
Node.js-os-module
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
Node.js fs.readFileSync() Method
Node.js fs.writeFile() Method
How to update NPM ?
Difference between promise and async await in Node.js
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
HTML | DOM baseURI Property - GeeksforGeeks

13 Aug, 2021
The DOM baseURI property is used to return the base Uniform Resource Identifier (URI) of the document. This property is used for read-only. This property returns a string value that represents the base URI of the page.Syntax:  
node.baseURI
Return Value: It returns a string value which represents the URL of the node;s page. 
Example:  
html
<!DOCTYPE html><html>    <body>        <title>baseURI property</title>        <style>            h1 {                color:green;            }            body {                text-align:center;            }        </style>    </head>    <body>        <h1>GeeksforGeeks</h1>        <h2>DOM baseURI Property</h2>        </h2>        <button onclick = "geeks()">Submit</button>        <p id="gfg"></p>          <script>            function geeks() {                var x = document.baseURI;                document.getElementById("gfg").innerHTML =                    "The base URI of the page: " + x;            }        </script>    </body></html>                   
Output:  
Supported Browsers: The browser supported by DOM baseURI  Property are listed below:  
Google Chrome
Firefox
Opera
Safari
 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
hritikbhatnagar2182
HTML-DOM
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to create footer to stay at the bottom of a Web page?
How to apply style to parent if it has child with CSS?
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
Difference between Traditional and Agile Software Development - GeeksforGeeks

03 Oct, 2019
Traditional Software Development:Traditional software development is the software development process used to design and develop the simple software. It is basically used when the security and many other factors of the software are not much important. It is used by freshers in order to develop the software.It consists of five phases:
1. Requirements analysis
2. Design
3. Implementation
4. Coding and Testing
5. Maintenance 
Agile Software Development:Agile software development is the software development process used to design complicated software. It is basically used when the software is quite sensitive and complicated. It is used when security is much important. It is used by professionals in order to develop the software.It consists of three phases:
1. Project initiation
2. Sprint planning
3. Demos 
Difference between Traditional and Agile Software Development:
Difference Between
Software Engineering
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
Differences between IPv4 and IPv6
Difference Between Method Overloading and Method Overriding in Java
Stack vs Heap Memory Allocation
Differences between JDK, JRE and JVM
Types of Software Testing
Software Engineering | COCOMO Model
Software Engineering | Classical Waterfall Model
Differences between Verification and Validation
Software Testing | Basics
Python | Pandas Panel.add() - GeeksforGeeks

28 Jan, 2019
In Pandas, Panel is a very important container for three-dimensional data. The names for the 3 axes are intended to give some semantic meaning to describing operations involving panel data and, in particular, econometric analysis of panel data.
In Pandas Panel.add() function is used for element-wise addition of series and series/dataframe.
Syntax: Panel.add(other, axis=0)
Parameters:other : DataFrame or Panelaxis : Axis to broadcast over
Returns: Panel
Code #1:
# importing pandas module  import pandas as pd  import numpy as np     df1 = pd.DataFrame({'a': ['Geeks', 'For', 'geeks', 'for', 'real'],                      'b': [11, 1.025, 333, 114.48, 1333]})                         data = {'item1':df1, 'item2':df1}     # creating Panel  panel = pd.Panel.from_dict(data, orient ='minor')     print("panel['b'] is - \n\n", panel['b'], '\n')     print("\nAdding panel['b'] with df1['b'] using add() method - \n")   print("\n", panel['b'].add(df1['b'], axis = 0)) 
Output: 
Code #2:
# importing pandas module  import pandas as pd  import numpy as np     df1 = pd.DataFrame({'a': ['Geeks', 'For', 'geeks', 'for', 'real'],                      'b': [11, 1.025, 333, 114.48, 1333]})     data = {'item1':df1, 'item2':df1}     # creating Panel  panel = pd.Panel.from_dict(data, orient ='minor') print("panel['b'] is - \n\n", panel['b'], '\n')   # Create a 5 * 5 dataframe df2 = pd.DataFrame(np.random.rand(5, 2), columns =['item1', 'item2']) print("Newly create dataframe with random values is - \n\n", df2)  print("\nAdding panel['b'] with df2  using add() method - \n")  print(panel['b'].add(df2, axis = 0)) 
Output: 
Code #3:
# importing pandas module import pandas as pd import numpy as np   df1 = pd.DataFrame({'a': ['Geeks', 'For', 'geeks', 'real'],                     'b': [-11, +1.025, -114.48, 1333]})   df2 = pd.DataFrame({'a': ['I', 'am', 'dataframe', 'two'],                     'b': [100, 100, 100, 100]})                       data = {'item1':df1, 'item2':df2}  # creating Panel panel = pd.Panel.from_dict(data, orient ='minor') print("panel['b'] is - \n\n", panel['b'])   print("\nAdding panel['b'] with df2['b'] using add() method - \n")   print("\n", panel['b'].add(df2['b'], axis = 0)) 
Output: 
Python pandas-panel
Python pandas-panel-methods
Python-pandas
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()
Practice Quiz for Sudo Placement - GeeksforGeeks

28 Dec, 2020
main()
{
char g[] = "geeksforgeeks";
printf("%s", g + g[6] - g[8]);
}
char g[] = “geeksforgeeks”;  

// g now has the base address string “geeksforgeeks”  

// g[6] is ‘o’ and g[1] is ‘e’.  

// g[6] – g[1] = ASCII value of ‘o’ – ASCII value of ‘e’ = 8

// So the expression  g + g[6] – g[8] becomes g + 8 which is  

// base address of string “geeks”  

printf(“%s”, g + g[6] – g[8]);  // prints geeks 
while (true) // infinite condition
{
A :____;
printf("%d", 1);
printf("%d", 1);
B:____;
}
while (true) // infinite condition
{
C:____;
printf("%d", 0);
printf("%d", 0);
D:____;
}
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Must Do Coding Questions for Product Based Companies
C Program For Finding Length Of A Linked List
How to calculate MOVING AVERAGE in a Pandas DataFrame?
How to Convert Categorical Variable to Numeric in Pandas?
How to Replace Values in Column Based on Condition in Pandas?
How to Fix: SyntaxError: positional argument follows keyword argument in Python
How to Fix: KeyError in Pandas
C Program to read contents of Whole File
How to Append Pandas DataFrame to Existing CSV File?
How to Replace Values in a List in Python?
Node.js querystring.decode() Function - GeeksforGeeks

08 Mar, 2021
The querystring.decode() method is used to parse a URL query string into an object that contains the key and pair values of the query URL. The object returned does not inherit prototypes from the JavaScript object, therefore usual Object methods will not work. During parsing, the UTF-8 encoding format is assumed unless there is an alternative character encoding format. To decode alternative character encoding, the decodeURIComponent option has to be specified.
Syntax:  
querystring.decode( str, sep, eq, options )
Parameters: This function accepts four parameters as mentioned above and described below:  
str: String that specifies the URL query that has to be parsed.
sep: String that specifies the substring used to delimit the key and value pairs in the specified query string. The default value is “&”.
eq: String that specifies the substring used to delimit keys and values in the specified query string. The default value is “=”.
options: It is an object which can be used to modify the behavior of the method. It has the following parameters:decodeURIComponent: It is a function that would be used to decode percent-encoded characters in the query string. The default value is querystring.unescape().maxKeys: It is a number which specifies the maximum number of keys that should be parsed from the query string. A value of “0” would remove all the counting limits. The default value is “1000”.
decodeURIComponent: It is a function that would be used to decode percent-encoded characters in the query string. The default value is querystring.unescape().
maxKeys: It is a number which specifies the maximum number of keys that should be parsed from the query string. A value of “0” would remove all the counting limits. The default value is “1000”.
Return Value: It returns an object that has the key and value pairs parsed from the query string.
Example 1:
Javascript
const querystring = require('querystring');  let str = "user=pratik&isMale=true&role=Coder";  let output = querystring.decode(str);  console.log("Output: ", output);
Output:
Example 2:
Javascript
const querystring = require('querystring');  let str = "user->pratik/isMale->true/role->Coder/role->Engineer";  let output = querystring.decode(str, '/', '->');  console.log("Output 1 : ", output);  output = querystring.decode(str, '/', '->', {maxKeys: 2});  console.log("Output 2 : ", output);
Output:
Reference:https://nodejs.org/api/querystring.html#querystring_querystring_decode
NodeJS-function
Picked
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to connect Node.js with React.js ?
Node.js Export Module
Difference between dependencies, devDependencies and peerDependencies
Mongoose Populate() Method
Mongoose find() Function
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
Python OpenCV - waitKeyEx() Function - GeeksforGeeks

17 Oct, 2021
Python OpenCv waitKeyEx() method is similar to waitKey() method but it also returns the full key code. The key code which is returned is implementation-specific and depends on the used backend: QT/GTK/Win32/etc.
Syntax: cv2.waitKey(delay)
Parameters:
delay: The time in milliseconds after which windows needs to destroyed. If given 0 it waits for infinite till any key is pressed to destroy window.
Return : This method return the full key code of the key which is pressed. If no key is pressed it return -1.
In the below example we have implemented the waitKeyEx() method we have made a window that has an image named “gfg_logo.png” and then we display it and using waitKeyEx() method we delay the closing of the window and then press a key to close it. We store the returned value in the full_key_code variable and print it.
Python
# importing cv2 moduleimport cv2  # read the imageimg = cv2.imread("gfg_logo.png")  # showing the imagecv2.imshow('gfg', img)  # waiting using waitKeyEX method and storing# the returned value in full_key_codefull_key_code = cv2.waitKeyEx(0)  # printing the variableprint("The key code is:"+str(full_key_code))
Output:
The key code is:13
In the output, the value of full_key_code will be printed according to the key pressed When we press enter the value that is printed is as follows.
Another Example we can see is where we don’t press any key and wait for the window to destroy automatically after the delay that is given. We will pass 5000 as a parameter to wait for 5 seconds and then a window will close automatically without the need of pressing any key. In this case the function will return -1 as no key was pressed.
Python
# importing cv2 moduleimport cv2  # read the imageimg = cv2.imread("gfg_logo.png")  # showing the imagecv2.imshow('gfg', img)  # waiting using waitKeyEX method and# storing the returned value in full_key_codefull_key_code = cv2.waitKeyEx(5000)  # printing the variableprint("The key code is:"+str(full_key_code))
Output:
The key code is:-1
Picked
Python-OpenCV
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()
fileinput.input() in Python - GeeksforGeeks

22 Apr, 2020
With the help of fileinput.input() method, we can get the file as input and to can be used to update and append the data in the file by using fileinput.input() method.
Syntax : fileinput.input(files)
Return : Return the data of the file.
Example #1 :In this example we can see that by using fileinput.input() method, we are able to get the data of the file line by line by using this method.
Input File –
# import fileinputimport fileinput  # Using fileinput.input() methodfor line in fileinput.input(files ='gfg.txt'):    print(line)
Output : Example #2 :
Input Files –
# import fileinputimport fileinput  # Using fileinput.input() methodfor line in fileinput.input(files =('gfg.txt', 'gfg1.txt')):    print(line)
Output :
Python fileinput-library
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
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Check if element exists in list in Python
Style <input> elements with a "readonly" attribute with CSS

To select elements that are read-only, use the CSS :read-only selector.
You can try to run the following code to implement the :read-only selector
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         input:read-only {
            background-color: blue;
            color: white;
         }
      </style>
   </head>
   <body>
      <form>
         Subject: <input type = "text" name = "subject" value = "Maths"><br>
         Student: <input type = "text" name = "student" readonly value = "Amit"><br>
      </form>
   </body>
</html>
What is $(document).ready() method in jQuery?

The ready() method is used to make a function available after the document is loaded. Whatever code you write inside the $(document ).ready() method will run once the page DOM is ready to execute JavaScript code.
You can try to run the following code to learn how to use $(document).ready() method in jQuery:
Live Demo
<html>

   <head>
      <title>jQuery Function</title>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

      <script>
        $(document).ready(function() {
          $("div").click(function() {
            alert("Hello, world!");
          });
        });
      </script>
   </head>
   
   <body>
      <div id = "mydiv">
         Click on this to see a dialogue box.
      </div>
   </body>
</html>
Mahotas – Convolution of Image - GeeksforGeeks

29 Jul, 2021
In this article, we will see how we can do convolution of the image in mahotas. Convolution is a simple mathematical operation which is fundamental to many common image processing operators. Convolution provides a way of `multiplying together’ two arrays of numbers, generally of different sizes, but of the same dimensionality, to produce a third array of numbers of the same dimensionality.
In this tutorial, we will use “lena” image, below is the command to load it.   
mahotas.demos.load('lena')
Below is the lena image 
In order to do this we will use mahotas.convolve method
Syntax : mahotas.convolve(img, weight)
Argument : It takes image object and numpy nd array objectas argument
Return : It returns image object
Note : Input image should be filtered or should be loaded as grey
In order to filter the image we will take the image object which is numpy.ndarray and filter it with the help of indexing, below is the command to do this 
image = image[:, :, 0]
Below is the implementation 
Python3
# importing required librariesimport mahotasimport mahotas.demosfrom pylab import gray, imshow, showimport numpy as np   # loading imageimg = mahotas.demos.load('lena')   # filtering imageimg = img.max(2) # otsu methodT_otsu = mahotas.otsu(img)     # image values should be greater than otsu valueimg = img > T_otsu   print("Image threshold using Otsu Method")   # showing imageimshow(img)show()   # weightweight = np.ones((5, 5), float) # convolving imagenew_img = mahotas.convolve(img, weight)  print("Convolved Image") # showing imageimshow(new_img)show()
Output : 
Image threshold using Otsu Method
Convolved Image
Another example  
Python3
# importing required librariesimport mahotasimport numpy as npfrom pylab import gray, imshow, showimport os  # loading imageimg = mahotas.imread('dog_image.png')  # filtering imageimg = img[:, :, 0]   # otsu methodT_otsu = mahotas.otsu(img)     # image values should be greater than otsu valueimg = img > T_otsu   print("Image threshold using Otsu Method")   # showing imageimshow(img)show()   # weightweight = np.ones((5, 5), float) # convolving imagenew_img = mahotas.convolve(img, weight)  print("Convolved Image") # showing imageimshow(new_img)show()
Output : 
Image threshold using Otsu Method 
Convolved Image
 
surinderdawra388
sweetyty
Python-Mahotas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python program to convert a list to string
Python String | replace()
Reading and Writing to text files in Python
sum() function in Python
Using proptypes in React.js

Use of proptypes ensures the type safety of receiving props on the components and also helps in making correct calculation.
Example − If we are receiving name as string and age as number then it should be received with the same type. If we receive age in string then it can result into incorrect calculation.
To use proptypes we have to install below package.
npm install –save prop-types
This package is provided by React Team. To use it on component, we will import it first
import PropType from ‘prop-types’;
we can use it on any type of component (Stateful or stateless).
At the end of component before exporting it we write it as −
Player.propTypes={};
Note the propType on name of component as shown above.
Player.propTypes={
   age:PropType.number,
   name:PropType.string
}
With the JavaScript object we are specifying the name of prop and its valid data type. If we pass an incorrect data type we will receive a warning in browser console.
The available prop types are −
any => it can be of any type
Boolean
String
Number
func => means function
array
object
symbol
Showing a warning message in browser console if there is a mismatch in prop type will help the developer correct its mistake.
Though we can use the proptype on every component, but should be used if the component is going to be used by other developers and there is considerable use of data types.
We can manipulate the dom element by getting hold on to it using ref.
<input value={this.props.name}
ref={(myInput)=>{this.testInput=myInput}}/>
we can use it on componentDidMount
componentDidMount(){
   this.testInput.focus();
}
The alternate latest approach to use Ref
Inside constructor we can create a ref
constructor(props){
   super(props);
   this.testInputRef=React.createRef();
}
We can use the created ref on input element like below −
<input value={this.props.name}
ref={this.testInputRef }/>
how to access this new way in componentDidMount
componentDidMount(){
   this.testInputRef.current.focus();
}
We have to use the current on the ref element to make it work.
This way we can avoid the creation of anonymous function to create reference for inputs.
We can create ref using useRef
import React, { useRef} from ‘react’;
const myFunction=(props)=>{
   const inputRef = useRef(null);// we can give some value to ref using its constructor
}
We can use the ref similar like created in stateful component earlier.
Note that this ref should not be used immediately as the jsx code will not be prepared by that time.
We can use the ref element inside useEffect. the useEffect function runs after the render of jsx code so that we can sure the ref variables are attached to the actual elements and are ready to use.
These refs will be accessed like above using current keyword.
This.inputRef.current.click();
With the creation of ref, we are keeping a mutable field in our component to handle it easily.
Note that change in ref does not trigger re-render. There is an useCallback method which can notify the changes and work asynchronously.
Perl gmtime Function

This function returns a list of values corresponding to the date and time as specified by EXPR, or date and time returned by the time function if EXPR is omitted, localized for the standard Greenwich mean time. The values returned are as follows −
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
All list elements are numeric, and come straight out of the C `struct tm'. $sec, $min, and $hour are the seconds, minutes, and hours of the specified time. $mday is the day of the month, and $mon is the month itself, in the range 0..11 with 0 indicating January and 11 indicating December. $year is the number of years since 1900. That is, $year is 123 in year 2023. $wday is the day of the week, with 0 indicating Sunday and 3 indicating Wednesday. $yday is the day of the year, in the range 0..364 (or 0..365 in leap years). $isdst is always 0 .
Following is the simple syntax for this function −
gmtime EXPR

gmtime

This function returns a string of the form: Thu Sep 21 14:52:52 2000 in scalar context and in list context the individual time component values (seconds, minutes, hours, day of month, month, year, day of week, day of year, daylight savings time).
Following is the example code showing its basic usage −
#!/usr/bin/perl

@weekday = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");

$local_time = gmtime();

print "Local time = $local_time\n";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
$year = $year + 1900;
print "Formated time = $mday/$mon/$year $hour:$min:$sec $weekday[$wday]\n";
When above code is executed, it produces the following result −
Local time = Sun Sep  1 09:06:41 2013
Formated time = 1/8/2013 9:6:41 Sun


    46 Lectures 
     4.5 hours 

 Devi Killada

    11 Lectures 
     1.5 hours 

 Harshit Srivastava

    30 Lectures 
     6 hours 

 TELCOMA Global

    24 Lectures 
     2 hours 

 Mohammad Nauman

    68 Lectures 
     7 hours 

 Stone River ELearning

    58 Lectures 
     6.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
Kth Largest Element in an Array

From a set of data, this algorithm will find the largest element to kth largest element of the array.
This problem can be solved easily by sorting the array. We can sort them either in ascending order or in descending order. Solving it in descending order, we can get first k elements to find our result.
Input:
The elements of an array: {1, 23, 12, 9, 30, 2, 50, 63, 87, 12, 45, 21}, K = 4
Output:
4 largest elements are 87 63 50 45
kthLargestElement(array, n, k)
Input: The array, number of elements in the array, place k.
Output: Display largest element to kth largest elements of the array.
Begin
   sort the array in descending order
   for i := 0 to k-1, do
      display array[i]
   done
End
#include<iostream>
#include<algorithm>
using namespace std;

bool compare(int a, int b) {
   return a>b;
}

void kthLargestElement(int array[], int n, int k) {
   sort(array, array+n, compare);

   for (int i = 0; i < k; i++)    //largest to kth largest element
      cout << array[i] << " ";
}

int main() {
   int array[] = {1, 23, 12, 9, 30, 2, 50, 63, 87, 12, 45, 21};
   int n = 12;
   int k = 4;
   kthLargestElement(array, n, k);
}
87 63 50 45
How to create a bold text using JavaScript?

To create a bold text using JavaScript, use the bold() text. This method causes a string to be displayed as bold as if it were in a <b> tag.
You can try to run the following code to create a bold text with JavaScript −
Live Demo
<html>
   <head>
      <title>JavaScript String bold() Method</title>
   </head>

   <body>
      <script>
         var str = new String("Demo Text");
         document.write(str.bold());
         alert(str.bold());
      </script>
   </body>
</html>
Python Program to find the factorial of a number without recursion

When it is required to find the factorial of a number without using recursion, the ‘while’ loop can be used.
Below is a demonstration for the same −
 Live Demo
my_num = int(input("Enter a number :"))
my_factorial = 1
while(my_num>0):
   my_factorial = my_factorial*my_num
   my_num=my_num-1
print("The factorial of the number is : ")
print(my_factorial)
Enter a number :7
The factorial of the number is :
5040
The input number is takne from the user.
A variable is assigned to 1.
It is checked to see for being 0.
If not, it is multiplied by the previous value in the variable.
It is assigned to the same variable.
This is done until the number reaches 0.
It is then displayed as output on the console.
RequireJS - Dojo

Dojo is a JavaScript toolkit which is based on the AMD module architecture that provides additional modules to add extra functionality to the web application and also saves time and scale in the web application development process.
The following example shows the usage of Dojo along with RequireJS. Create an html file with the name index.html and place the following code in it −
<!DOCTYPE html>
<html>
   <head>
      <title>RequireJS Dojo</title>
      <script data-main="app" src="lib/require.js"></script>
   </head>
   
   <body>
      <h2>RequireJS  Dojo</h2>
      <p>
         Hello... ...
      </p>
   </body>
</html>
Create a js file with the name app.js and add the following code in it −
require ({
   //You can configure loading modules from the lib directory
   baseUrl: 'lib',
   
   paths: {
      //mapping of package
      dojo: 'http://sfoster.dojotoolkit.org/dojobox/1.7-branch/dojo'
   }
   
}, [
      //modules which we are using here
      'dojo/dom'
   ], function(dom) { 
   
      //using the 'byId' method from dom module
      var mydojo = dom.byId('dojo_val')
      mydojo.innerHTML = "The text is displaying via dojo/dom";   
   }
);
Open the HTML file in a browser; you will receive the following output −
 Print
 Add Notes
 Bookmark this page
TypeScript - Bitwise Operators Examples

Assume variable A = 2 and B = 3
var a:number = 2;   // Bit presentation 10 
var b:number = 3;   // Bit presentation 11
 
var result; 
     
result = (a & b);     
console.log("(a & b) => ",result)
          
result = (a | b);          
console.log("(a | b) => ",result)  
       
result = (a ^ b);  
console.log("(a ^ b) => ",result);
 
result = (~b); 
console.log("(~b) => ",result);

result = (a << b); 
console.log("(a << b) => ",result); 

result = (a >> b); 
console.log("(a >> b) => ",result);

On compiling, it will generate the following JavaScript code −
//Generated by typescript 1.8.10
var a = 2;   // Bit presentation 10
var b = 3;   // Bit presentation 11
var result;

result = (a & b);
console.log("(a & b) => ", result);

result = (a | b);
console.log("(a | b) => ", result);

result = (a ^ b);
console.log("(a ^ b) => ", result);

result = (~b);
console.log("(~b) => ", result);

result = (a << b);
console.log("(a << b) => ", result);

result = (a >> b);
console.log("(a >> b) => ", result);

The output of the above program is given below −
(a & b) =>  2 
(a | b) =>  3 
(a ^ b) =>  1 
(~b) =>  -4 
(a << b) =>  16 
(a >> b) =>  0


    45 Lectures 
     4 hours 

 Antonio Papa

    41 Lectures 
     7 hours 

 Haider Malik

    60 Lectures 
     2.5 hours 

 Skillbakerystudios

    77 Lectures 
     8 hours 

 Sean Bradley

    77 Lectures 
     3.5 hours 

 TELCOMA Global

    19 Lectures 
     3 hours 

 Christopher Frewin
 Print
 Add Notes
 Bookmark this page
How to filter object array based on attributes in jQuery?

To filter object array based on attributes in jQuery, use the map() method with JSON.
You can try to run the following code to learn how to filter object array based on attributes in jQuery,
Live Demo
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
   $(document).ready(function(){
    var json ={"DEPARTMENT": [
            {
                "id":"1",
                "deptemp":"840",
                "shares":"1100",
             
            },
            {
                "id":"2",
                "deptemp":"1010",
                "shares":"1900",      
            }, {
                "id":"1",
                "deptemp":"350",
                "shares":"510",
            },
            {
                "id":"2",
                "deptemp":"575",
                "shares":"1900",
            }]};

           json.DEPARTMENT = $.map(json.DEPARTMENT,function(val,key) {
              if(Number(val.deptemp) <= 500 && Number(val.shares) >= 500) return val;
           });
   
    for(var i in json.DEPARTMENT)
       $("p").html("Department Employees: "+json.DEPARTMENT[i].deptemp+" ,  Shares:"+json.DEPARTMENT[i].shares)
    });
});
</script>
</head>
<body>

<p></p>
<div></div>

</body>
</html>
Batch Script - String length - GeeksforGeeks

04 Jan, 2022
In this article , we are going to learn how to find length of any String using Batch Script.
@echo off
set str=Geeks For Geeks
call :strLen str strlen
echo String is %strlen% characters long
pause
exit /b

:strLen
setlocal enabledelayedexpansion

:strLen_Loop
   if not "!%1:~%len%!"=="" set /A len+=1 & goto :strLen_Loop
(endlocal & set %2=%len%)
goto :eof
In Batch Scripting there no function for checking length of string ,So we will create a function to find length of string.
By using ‘ set ‘ we are getting our input string whose length is to calculated.
In above code we are creating a Function “strLen” , which we can use to find our string length.
From ‘:strLen’ our function is started , then we will initialize our Loop with ‘strLen_Loop’.
(“!%1:~%len%!”) this statement is checking that our string is ended or not by using (==””).
if not "!%1:~%len%!"=="" set /A len+=1 & goto :strLen_Loop
During execution of our ‘if’ statement its checking if (“!%1:~%len%!”==””) this argument is True then it will Break the Loop and if its False , it will be continued.
Now if our argument is False then we will set our ‘len’ variable as ‘len=len+1’ (also written as len+=1).
By using ‘goto :strLen_Loop’ we are continuing our Loop.
Now , again it will check whether our string is ended or not by using command (“!%1:~%len%!”==””) and increase ‘len’ by 1 if argument is False.
Now let’s assume when our argument is True , loop will break and our string length is set in ‘strlen’.
When ‘strlen’ is called it will print our string length.
Output:
Batch-script
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scp command in Linux with Examples
SED command in Linux | Set 2
mv command in Linux with examples
Docker - COPY Instruction
chown command in Linux with Examples
nohup Command in Linux with Examples
Named Pipe or FIFO with example C program
Thread functions in C/C++
uniq Command in LINUX with examples
Basic Operators in Shell Scripting
Bootstrap .tooltip("hide") method

Use the tooltip(“hide”) method in Bootstrap to hide the tooltip. The tooltip hides on button click as shown below −
$(".btn-default").click(function(){
  $("[data-toggle='tooltip']").tooltip('hide');
});
Above the data-toggle attribute can be seen which we set before on <a> element. Now the toggle will generate from the link when the button is clicked −
<a href="#" data-toggle="tooltip" title="Tooltip is visible!">
  Tooltip will be visible here
</a>
You can try to run the following code to implement the tooltip(“hide”) method −
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/3.3.7/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/3.3.7/js/bootstrap.min.js"></script>
  </head>

<body>
  <div class="container">
    <h3>Demo</h3>
    <a href="#" data-toggle="tooltip" title="Tooltip is visible!">Tooltip will be visible here</a>
    <div>
      <button type="button" class="btn btn-primary">Show Tooltip</button>
      <button type="button" class="btn btn-default">Hide Tooltip</button>
    </div>  
</div>

<script>
  $(document).ready(function(){
    $(".btn-primary").click(function(){
      $("[data-toggle='tooltip']").tooltip('show');
    });
    $(".btn-default").click(function(){
      $("[data-toggle='tooltip']").tooltip('hide');
    });
  });
</script>

</body>
</html>
Java Data Types

As explained in the previous chapter, a variable in Java must be a specified data type:
int myNum = 5;               // Integer (whole number)
float myFloatNum = 5.99f;    // Floating point number
char myLetter = 'D';         // Character
boolean myBool = true;       // Boolean
String myText = "Hello";     // String


Try it Yourself »

Data types are divided into two groups:
Primitive data types - includes byte, short, int, long, 
 float, double, boolean and char
Non-primitive data types - such as String, Arrays and  Classes (you will learn more about these in a later chapter)
A primitive data type specifies the size and type of variable values, and it has no 
additional methods.
There are eight primitive data types in Java:
Add the correct data type for the following variables:
 myNum = 9;
 myFloatNum = 8.99f;
 myLetter = 'A';
 myBool = false;
 myText = "Hello World";

Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
isalpha() and isdigit() functions in C with cstring examples.

23 Jun, 2022
isalpha(c) is a function in C which can be used to check if the passed character is an alphabet or not. It returns a non-zero value if it’s an alphabet else it returns 0. For example, it returns non-zero values for ‘a’ to ‘z’ and ‘A’ to ‘Z’ and zeroes for other characters.Similarly, isdigit(c) is a function in C which can be used to check if the passed character is a digit or not. It returns a non-zero value if it’s a digit else it returns 0. For example, it returns a non-zero value for ‘0’ to ‘9’ and zero for others.Avoiding common errors : It is important to note this article does not cover strings! Only Cstrings. Cstrings are an array of single characters (char) in their behaviour. There are advantages and disadvantages to this.Example Problem : Given a cstring str, find the number of alphabetic letters and number of decimal digits in that cstring.Examples: 
Input: 12abc12
Output: Alphabetic_letters = 3, Decimal_digits = 4

Input: 123 GeeksForGeeks is Number 1
Output: Alphabetic_letters = 21, Decimal_digits = 4
Explanation And Approach: 
C
// C program to demonstrate working of isalpha() and// isdigit().#include <ctype.h>#include <stdio.h>#include <stdlib.h> int main(){    char str[] = "12abc12";     int alphabet = 0, number = 0, i;    for (i = 0; str[i] != '\0'; i++)    {             // check for alphabets        if (isalpha(str[i]) != 0)            alphabet++;         // check for decimal digits        else if (isdigit(str[i]) != 0)            number++;    }     printf("Alphabetic_letters = %d, "           "Decimal_digits = %d\n",           alphabet, number);     return 0;}
Output: 
Alphabetic_letters = 3, Decimal_digits = 4
Let us see the differences in a tabular form -: 
Its syntax is -:
isalpha(int c);
Its syntax is -:
isdigit(int c);
This article is contributed by Mazhar Imam Khan. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
BrenlyDrake
vardaangpt
mayank007rawa
C-Library
CPP-Library
C Language
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Function Pointer in C
std::string class in C++
Unordered Sets in C++ Standard Template Library
Enumeration (or enum) in C
Memory Layout of C Programs
Vector in C++ STL
Map in C++ Standard Template Library (STL)
Initialize a vector in C++ (7 different ways)
Set in C++ Standard Template Library (STL)
Priority Queue in C++ Standard Template Library (STL)
Python | Get first K items in dictionary

26 Jul, 2019
While working with dictionaries, we can come across a problem in which we might have to get just some of the initial keys in dictionary. This problem can typically occur in cases of web development domain. Let’s discuss certain ways in which this problem can be solved.
Method #1 : Using items() + list slicingTo solve this problem, combination of above functions have to implied. The items function can be used to get all the dictionary items and main task is done by list slicing, which limits the dictionary key-value pair.
# Python3 code to demonstrate working of# Get first K items in dictionary# Using items() + list slicing  # Initialize dictionarytest_dict = {'gfg' : 1, 'is' : 2, 'best' : 3, 'for' : 4, 'CS' : 5}  # printing original dictionaryprint("The original dictionary : " +  str(test_dict))  # Initialize limitK = 3  # Using items() + list slicing# Get first K items in dictionaryres = dict(list(test_dict.items())[0: K])      # printing result print("Dictionary limited by K is : " + str(res))
The original dictionary : {‘is’: 2, ‘CS’: 5, ‘best’: 3, ‘gfg’: 1, ‘for’: 4}Dictionary limited by K is : {‘is’: 2, ‘CS’: 5, ‘best’: 3}
 
Method #2 : Using islice() + items()The combination of above functions can be used to perform this particular task. In these, we perform the slice using the islice() and items function allows to get the items out of iterable.
# Python3 code to demonstrate working of# Get first K items in dictionary# Using islice() + items()import itertools  # Initialize dictionarytest_dict = {'gfg' : 1, 'is' : 2, 'best' : 3, 'for' : 4, 'CS' : 5}  # printing original dictionaryprint("The original dictionary : " +  str(test_dict))  # Initialize limitK = 3  # Using islice() + items()# Get first K items in dictionaryres = dict(itertools.islice(test_dict.items(), K))      # printing result print("Dictionary limited by K is : " + str(res))
The original dictionary : {‘is’: 2, ‘CS’: 5, ‘best’: 3, ‘gfg’: 1, ‘for’: 4}Dictionary limited by K is : {‘is’: 2, ‘CS’: 5, ‘best’: 3}
Python dictionary-programs
Python
Python Programs
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
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
Lodash | _.pull() Method

29 Apr, 2020
The _.pull() method is used to remove all the given values from a given array.
Syntax:
_.pull(array, [values])
Parameters: This method accepts two or more parameters as mentioned above and described below:
Array: This parameter holds the query array.
values: This parameter holds one or multiple element that need to be removed from array.
Return Value: It return an array that contains remaining element.
Example 1: This example removes all the values from array that matches with given values.
const _ = require('lodash');  let ar = [1, 2, 3, 4, 5]  let value = _.pull(ar, 3, 5)  console.log(value)
Here, const _ = require('lodash') is used to import the lodash library into the file.
Output:
[ 1, 2, 4 ]

Example 2: This example removes all the values from array that matches with given values.
const _ = require('lodash');  let ar = [1, 2, 3, 1, 3, 4, 1, 5]  let value = _.pull(ar, 1, 5)  console.log(value)
Output:
[ 2, 3, 3, 4 ]

Example 3: This example removes all the values from array that matches with given values.
const _ = require('lodash');  let ar = ['a', 'b', 'c', 'd']  let value = _.pull(ar, 'c')  console.log(value)
Output:
[ 'a', 'b', 'd' ]

Note: It will not work in normal JavaScript because it requires the library lodash to be installed.
Reference: https://lodash.com/docs/4.17.15#pull
JavaScript-Lodash
JavaScript
Web Technologies
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
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
How to Open URL in New Tab using JavaScript ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?