code-rag-bench/online-tutorials huggingface dataset:
PHP | filesize( ) Function - GeeksforGeeks

05 May, 2018
The filesize() function in PHP is an inbuilt function which is used to return the size of a specified file. The filesize() function accepts the filename as a parameter and returns the size of a file in bytes on success and False on failure.
The result of the filesize() function is cached and a function called clearstatcache() is used to clear the cache.
Syntax:
filesize($filename)
Parameters: The filesize() function in PHP accepts only one parameter $filename. It specifies the filename of the file whose size you want to check.
Return Value: It returns the size of a file in bytes on success and False on failure.
Errors And Exception:
For files which are larger than 2GB some filesystem functions may return unexpected results since PHP’s integer type is signed and many platforms use 32bit integers.The buffer must be cleared if the filesize() function is used multiple times.The filesize() function emits an E_WARNING in case of a failure.
For files which are larger than 2GB some filesystem functions may return unexpected results since PHP’s integer type is signed and many platforms use 32bit integers.
The buffer must be cleared if the filesize() function is used multiple times.
The filesize() function emits an E_WARNING in case of a failure.
Examples:

Input : echo filesize("gfg.txt");
Output : 256

Input : $myfile = 'gfg.txt';
        echo $myfile . ': ' . filesize($myfile) . ' bytes';
Output : gfg.txt : 256 bytes

Below programs illustrate the filesize() function.
Program 1:
<?php  // displaying file size using// filesize() functionecho filesize("gfg.txt");  ?>
Output:
256
Program 2:
<?php  // displaying file size using// filesize() function$myfile = 'gfg.txt';  echo $myfile . ': ' . filesize($myfile) . ' bytes';  ?>
Output:
gfg.txt : 256 bytes
Reference:http://php.net/manual/en/function.filesize.php
PHP-file-handling
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
Comparing two dates in PHP
How to receive JSON POST with PHP ?
PHP | Converting string to Date and DateTime
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
C++ Program for sum of arithmetic series

Given with ‘a’(first term), ‘d’(common difference) and ‘n’ (number of values in a string) and the task is to generate the series and thereby calculating their sum.
Arithmetic series is the sequence of numbers with common difference where the first term of a series is fixed which is ‘a’ and the common difference between them is ‘d’.
It is represented as −
a, a + d, a + 2d, a + 3d, . . .
Input-: a = 1.5, d = 0.5, n=10
Output-: sum of series A.P is : 37.5
Input : a = 2.5, d = 1.5, n = 20
Output : sum of series A.P is : 335
Approach used below is as follows −
Input the data as the first term(a), common difference(d) and the numbers of terms in a series(n)
Traverse the loop till n and keep adding the first term to a temporary variable with the difference
Print the resultant output
Start
Step 1-> declare Function to find sum of series
   float sum(float a, float d, int n)
   set float sum = 0
   Loop For int i=0 and i<n and i++
      Set sum = sum + a
      Set a = a + d
   End
   return sum
Step 2-> In main()
   Set int n = 10
   Set float a = 1.5, d = 0.5
   Call sum(a, d, n)
Stop
 Live Demo
#include<bits/stdc++.h>
using namespace std;
// Function to find sum of series.
float sum(float a, float d, int n) {
   float sum = 0;
   for (int i=0;i<n;i++) {
      sum = sum + a;
      a = a + d;
   }
   return sum;
}
int main() {
   int n = 10;
   float a = 1.5, d = 0.5;
   cout<<"sum of series A.P is : "<<sum(a, d, n);
   return 0;
}
sum of series A.P is : 37.5
Java Examples - print stack trace

How to print stack of the Exception ?
This example shows how to print stack of the exception using printStack() method of the exception class.
public class Main{
   public static void main (String args[]) {
      int array[] = {20,20,40};
      int num1 = 15, num2 = 10;
      int result = 10;
      try { 
         result = num1/num2;
         System.out.println("The result is" +result);
         
         for(int i = 5; i >= 0; i--) {
            System.out.println("The value of array is" +array[i]);
         }
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
}
The above code sample will produce the following result.
The result is1
java.lang.ArrayIndexOutOfBoundsException: 5
	at Main.main(Main.java:11)

The following is an another example of print stack of the Exception in Java.
public class Demo {
   public static void main(String[] args) {
      try {
         ExceptionFunc();
      } catch(Throwable e) {
         e.printStackTrace();
      }
   }
   public static void ExceptionFunc() throws Throwable {
      Throwable t = new Throwable("This is new Exception in Java...");
      
      StackTraceElement[] trace = new StackTraceElement[] {
         new StackTraceElement("ClassName","methodName","fileName",5)
      };
      t.setStackTrace(trace);
      throw t;
   }
}  
The above code sample will produce the following result.
java.lang.Throwable: This is new Exception in Java...
	at ClassName.methodName(fileName:5)

 Print
 Add Notes
 Bookmark this page
DateTime.ToLongTimeString() Method in C#

The DateTime.ToLongTimeString() method in C# is used to convert the value of the current DateTime object to its equivalent long time string representation.
Following is the syntax −
public string ToLongTimeString ();
Let us now see an example to implement the DateTime.ToLongTimeString() method −
using System;
using System.Globalization;
public class Demo {
   public static void Main() {
      DateTime d = DateTime.Now;
      Console.WriteLine("Date = {0}", d);
      Console.WriteLine("Current culture = "+CultureInfo.CurrentCulture.Name);
      var pattern = CultureInfo.CurrentCulture.DateTimeFormat;
      string str = d.ToLongTimeString();
      Console.WriteLine("Long time string = {0}", pattern.LongTimePattern);
      Console.WriteLine("Long time string representation = {0}", str);
   }
}
This will produce the following output −
Date = 10/16/2019 8:41:03 AM
Current culture = en-US
Long time string = h:mm:ss tt
Long time string representation = 8:41:03 AM
Let us now see another example to implement the DateTime.ToLongTimeString() method −
using System;
public class Demo {
   public static void Main() {
      DateTime d = new DateTime(2019, 11, 11, 7, 11, 25);
      Console.WriteLine("Date = {0}", d);
      string str = d.ToLongTimeString();
      Console.WriteLine("Long time string representation = {0}", str);
   }
}
This will produce the following output −
Date = 11/11/2019 7:11:25 AM
Long time string representation = 7:11:25 AM
How to create footer for Bootstrap 4 card

To create a footer in Bootstrap 4 card, use the card-footer class.
Set the footer −
<div class="card-footer">
  Footer message
</div>
The footer class comes after the card-body and card-header class, since the footer is always in the bottom as the footer of a web page. Here is the complete code −
<div class=”card”>
  <div class="card-header">Venue: 811, KY Road, New York</div>
  <div class="card-body">Timings: 9AM-11AM</div>
  <div class="card-footer">Reach before 9AM</div>
</div>
Let us see how to create card footer in Bootstrap 4 −
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">
    <h2>Church Worship</h2>
    <div class="card">
      <div class="card-header">Venue: 811, KY Road, New York</div>
      <div class="card-body">Timings: 9AM-11AM</div>
      <div class="card-footer">Reach before 9AM</div>
    </div>
  </div>

</body>
</html>
How  to Convert Kilometres to Miles using Python?

The ratio of Km to Mile is 1 km = 0.621371 mile
>>> km=5
>>> m=km*0.621371
>>> m
3.106855
DateTime.AddMonths() Method in C#

The DateTime.AddMonths() method in C# is used to add the specified number of months to the value of this instance.
Following is the syntax −
public DateTime AddMonths (int val);
Above, Val is the number of months. If you want to subtract months, then set it as negative.
Let us now see an example to implement the DateTime.AddMonths() method −
using System;
public class Demo {
   public static void Main(){
      DateTime d1 = new DateTime(2019, 05, 15, 5, 15, 25);
      DateTime d2 = d1.AddMonths(5);
      System.Console.WriteLine("Initial DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d1);
      System.Console.WriteLine("\nNew DateTime (After adding months) = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d2);
   }
}
This will produce the following output −
Initial DateTime = 15 May 2019, 05:15:25
New DateTime (After adding months) = 15 October 2019, 05:15:25
Let us now see another example to implement the DateTime.AddMonths() method −
using System;
public class Demo {
   public static void Main(){
      DateTime d1 = new DateTime(2019, 08, 20, 3, 30, 50);
      DateTime d2 = d1.AddMonths(-2);
      System.Console.WriteLine("Initial DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d1);
      System.Console.WriteLine("\nNew DateTime (After subtracting months) = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d2);
   }
}
This will produce the following output −
Initial DateTime = 20 August 2019, 03:30:50
New DateTime (After subtracting months) = 20 June 2019, 03:30:50
Check if a string contains a sub-string in C++

Here we will see how the string library functions can be used to match strings in C++. Here we are using the find() operation to get the occurrences of the substring into the main string. This find() method returns the first location where the string is found. Here we are using this find() function multiple times to get all of the matches.
If the item is found, this function returns the position. But if it is not found, it will return string::npos.
So for checking whether the substring is present into the main string, we have to check the return value of find() is string::npos or not.
Here we are simply getting the position where the substring is present.
Input: The main string “aabbabababbbaabb” and substring “abb”
Output: The locations where the substrings are found. [1, 8, 13]
Input − The main string and the substring to check
Output − The positions of the substring in the main string
pos := 0
while index = first occurrence of sub_str into the str in range pos to end of the string, do
   print the index as there is a match
   pos := index + 1
done
 Live Demo
#include
using namespace std;
main() {
   string str1 = "aabbabababbbaabb";
   string str2 = "abb";
   int pos = 0;
   int index;
   while((index = str1.find(str2, pos)) != string::npos) {
      cout << "Match found at position: " << index << endl;
      pos = index + 1; //new position is from next element of index
   }
}
Match found at position: 1
Match found at position: 8
Match found at position: 13
Entity Framework - Views

A view is an object that contains data obtained by a predefined query. A view is a virtual object or table whose result set is derived from a query. It is very similar to a real table because it contains columns and rows of data. Following are some typical uses of views −
Filter data of underlying tables
Filter data for security purposes
Centralize data distributed across several servers
Create a reusable set of data
Views can be used in a similar way as you can use tables. To use view as an entity, first you will need to add database views to EDM. After adding views to your model then you can work with it the same way as normal entities except for Create, Update, and Delete operations.
Let’s take a look, how to add views into the model from the database.
Step 1 − Create a new Console Application project.
Step 2 − Right-click on project in solution explorer and select Add → New Item.
Step 3 − Select ADO.NET Entity Data Model from the middle pane and enter name ViewModel in the Name field.
Step 4 − Click Add button which will launch the Entity Data Model Wizard dialog.
Step 5 − Select EF Designer from database and click Next button.
Step 6 − Select the existing database and click Next.
Step 7 − Choose Entity Framework 6.x and click Next.
Step 8 − Select tables and views from your database and click Finish.
You can see in the designer window that a view is created and you can use it in the program as an entity.
In the solution explorer, you can see that MyView class is also generated from the database.
Let’s take an example in which all data is retrieved from view. Following is the code −
class Program {

   static void Main(string[] args) {

      using (var db = new UniContextEntities()) {

         var query = from b in db.MyViews
            orderby b.FirstMidName select b;

         Console.WriteLine("All student in the database:");

         foreach (var item in query) {
            Console.WriteLine(item.FirstMidName + " " + item.LastName);
         }

         Console.WriteLine("Press any key to exit...");
         Console.ReadKey();
      }
   }
}
When the above code is executed, you will receive the following output −
All student in the database:
Ali Khan
Arturo   finand
Bill Gates
Carson Alexander
Gytis Barzdukas
Laura Norman
Meredith Alonso
Nino Olivetto
Peggy Justice
Yan Li
Press any key to exit...

We recommend you to execute the above example in a step-by-step manner for better understanding.

    19 Lectures 
     5 hours 

 Trevoir Williams

    33 Lectures 
     3.5 hours 

 Nilay Mehta

    21 Lectures 
     2.5 hours 

 TELCOMA Global

    89 Lectures 
     7.5 hours 

 Mustafa Radaideh
 Print
 Add Notes
 Bookmark this page
Java - DataOutputStream

The DataOutputStream stream lets you write the primitives to an output source.
Following is the constructor to create a DataOutputStream.
DataOutputStream out = DataOutputStream(OutputStream out);

Once you have DataOutputStream object in hand, then there is a list of helper methods, which can be used to write the stream or to do other operations on the stream.
public final void write(byte[] w, int off, int len)throws IOException
Writes len bytes from the specified byte array starting at point off, to the underlying stream.
Public final int write(byte [] b)throws IOException
Writes the current number of bytes written to this data output stream. Returns the total number of bytes written into the buffer.
(a) public final void  writeBooolean()throws IOException,
(b) public final void  writeByte()throws IOException,
(c) public final void  writeShort()throws IOException
(d) public final void  writeInt()throws IOException
These methods will write the specific primitive type data into the output stream as bytes.
Public void flush()throws IOException
Flushes the data output stream.
public final void writeBytes(String s) throws IOException
Writes out the string to the underlying output stream as a sequence of bytes. Each character in the string is written out, in sequence, by discarding its high eight bits.
Following is an example to demonstrate DataInputStream and DataOutputStream. This example reads 5 lines given in a file test.txt and converts those lines into capital letters and finally copies them into another file test1.txt.
import java.io.*;
public class DataInput_Stream {

   public static void main(String args[])throws IOException {

      // writing string to a file encoded as modified UTF-8
      DataOutputStream dataOut = new DataOutputStream(new FileOutputStream("E:\\file.txt"));
      dataOut.writeUTF("hello");

      // Reading data from the same file
      DataInputStream dataIn = new DataInputStream(new FileInputStream("E:\\file.txt"));

      while(dataIn.available()>0) {
         String k = dataIn.readUTF();
         System.out.print(k+" ");
      }
   }
}
Here is the sample run of the above program −
THIS IS TEST 1  ,
THIS IS TEST 2  ,
THIS IS TEST 3  ,
THIS IS TEST 4  ,
THIS IS TEST 5  ,


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
Wildcard Matching in Python

Suppose we have an input string s and another input string p. Here is the main string and p is the pattern. We have to define one method, that can match pattern in the string. So we have to implement this for a regular expression, that supports wildcard characters like ‘?’ And ‘*’.
Dot ‘?’ Matches any single character
Dot ‘?’ Matches any single character
Star ‘*’ Matches zero or more characters.
Star ‘*’ Matches zero or more characters.
So for example, if the input is like s = “aa” and p = “a?”, then it will be true, for the same input string, if the patter is “?*”, then it will be true.
To solve this, we will follow these steps −
ss := size of s and ps := size of p
ss := size of s and ps := size of p
make dp a matrix of size ss x ps, and fill this using false value
make dp a matrix of size ss x ps, and fill this using false value
Update p and s by adding one blank space before these
Update p and s by adding one blank space before these
For i in range 1 to ps −if p[i] = star, thendp[0, i] := dp[0, i - 1]
For i in range 1 to ps −
if p[i] = star, thendp[0, i] := dp[0, i - 1]
if p[i] = star, then
dp[0, i] := dp[0, i - 1]
dp[0, i] := dp[0, i - 1]
for i in range 1 to ssfor j in range 1 to psif s[i] is p[j], or p[j] is ‘?’, thendp[i, j] := dp[i – 1, j – 1]otherwise when p[j] is star, thendp[i, j] := max of dp[i – 1, j] and dp[i, j – 1]
for i in range 1 to ss
for j in range 1 to psif s[i] is p[j], or p[j] is ‘?’, thendp[i, j] := dp[i – 1, j – 1]otherwise when p[j] is star, thendp[i, j] := max of dp[i – 1, j] and dp[i, j – 1]
for j in range 1 to ps
if s[i] is p[j], or p[j] is ‘?’, thendp[i, j] := dp[i – 1, j – 1]
if s[i] is p[j], or p[j] is ‘?’, then
dp[i, j] := dp[i – 1, j – 1]
dp[i, j] := dp[i – 1, j – 1]
otherwise when p[j] is star, thendp[i, j] := max of dp[i – 1, j] and dp[i, j – 1]
otherwise when p[j] is star, then
dp[i, j] := max of dp[i – 1, j] and dp[i, j – 1]
dp[i, j] := max of dp[i – 1, j] and dp[i, j – 1]
return dp[ss, ps]
return dp[ss, ps]
Let us see the following implementation to get better understanding −
 Live Demo
class Solution(object):
   def isMatch(self, s, p):
      sl = len(s)
      pl = len(p)
      dp = [[False for i in range(pl+1)] for j in range(sl+1)]
      s = " "+s
      p = " "+p
      dp[0][0]=True
      for i in range(1,pl+1):
         if p[i] == '*':
            dp[0][i] = dp[0][i-1]
      for i in range(1,sl+1):
         for j in range(1,pl+1):
            if s[i] == p[j] or p[j] == '?':
               dp[i][j] = dp[i-1][j-1]
            elif p[j]=='*':
               dp[i][j] = max(dp[i-1][j],dp[i][j-1])
      return dp[sl][pl]
ob = Solution()
print(ob.isMatch("aa", "a?"))
print(ob.isMatch("aaaaaa", "a*"))
"aa", "a."
"aaaaaa", "a*"
True
True
How to hide a div in JavaScript on button click?

Let’s say the following is our div −
<div id="showOrHide">
Welcome in JavaScript
</div>
Following is our button. On clicking, the above div should hide −
<button onclick="showOrHideDiv()">Click The Button</button>
Use the style.display concept in JavaScript to hide div. Following is the code −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initialscale=1.0">
<title>Document</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<button onclick="showOrHideDiv()">Click The Button</button>
<div id="showOrHide">
Welcome in JavaScript
</div>
<script>
   function showOrHideDiv() {
      var v = document.getElementById("showOrHide");
      if (v.style.display === "none") {
         v.style.display = "block";
      } else {
         v.style.display = "none";
      }
   }
</script>
</body>
</html>
To run the above program, save the file name “anyName.html(index.html)” and right click on the file. Select the option “Open with Live Server” in VS Code editor.
This will produce the following output −
When the user clicks on the button, the div hides. The screenshot is as follows −
Map function and Lambda expression in Python to replace characters - GeeksforGeeks

20 Oct, 2018
Given a string S, c1 and c2. Replace character c1 with c2 and c2 with c1.Examples:
Input : str = 'grrksfoegrrks'
        c1 = e, c2 = r 
Output : geeksforgeeks 

Input : str = 'ratul'
        c1 = t, c2 = h 
Output : rahul

We have existing solution for this problem in C++ please refer Replace a character c1 with c2 and c2 with c1 in a string S link. We will solve this problem quickly in Python using Lambda expression and map() function. We will create a lambda expression where character c1 in string will be replaced by c2 and c2 will be replaced by c1 and other will remain same, then we will map this expression on each character of string and will get updated string.
# Function to replace a character c1 with c2 # and c2 with c1 in a string S   def replaceChars(input,c1,c2):       # create lambda to replace c1 with c2, c2      # with c1 and other will remain same      # expression will be like "lambda x:     # x if (x!=c1 and x!=c2) else c1 if (x==c2) else c2"     # and map it onto each character of string     newChars = map(lambda x: x if (x!=c1 and x!=c2) else \                c1 if (x==c2) else c2,input)       # now join each character without space     # to print resultant string     print (''.join(newChars))  # Driver programif __name__ == "__main__":    input = 'grrksfoegrrks'    c1 = 'e'    c2 = 'r'    replaceChars(input,c1,c2)
Output:
geeksforgeeks

python-lambda
Python
Strings
Strings
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
Reverse a string in Java
Write a program to reverse an array or string
C++ Data Types
Longest Common Subsequence | DP-4
Write a program to print all permutations of a given string
Python | Pandas Series.str.isdecimal() - GeeksforGeeks

28 Sep, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas isdecimal() is used to check whether all characters in a string are decimal. This method works in a similar way to str.isdigit() method, but there is a difference that the latter is more expansive with respect to non ASCII digits. This will be cleared with the help of an example.
Syntax: Series.str.isdecimal()Return type: Boolean series
Example #1:In this example, a new data frame is created with just one column and some values are passed to it. Then str.isdecimal() method is called on that column and output is returned to a new column Bool.
# importing pandas module import pandas as pd  # creating data framedata = pd.DataFrame(["hey", "gfg", 3, "4", 5, "5.5"])  # calling method and returning seriesdata["Bool"]= data[0].str.isdecimal()  # displaydata
Output:As shown in the output image, the decimal returns True for decimal values in string form. If the element is in int, float or any other data type other than string, NaN is returned ( No matter if it’s a decimal number )
 Example #2:In this example, numbers with power are also added to that column. Both str isdigit() and str.isdecimal() are called and output is stored in different columns to compare the difference between both.
# importing pandas module import pandas as pd  # creating data framedata = pd.DataFrame(["hey", "gfg", 3, "42", 5, "5.5", "1292"])  # calling method and returning seriesdata["Bool"]= data[0].str.isdecimal()  # calling method and returning seriesdata["Bool2"]= data[0].str.isdigit()  # displaydata
Output:As shown in the Output image, the isdigit () returns True for numbers with power but isdecimal () returns False for those values.
Python pandas-series
Python pandas-series-methods
Python-pandas
Python-pandas-series-str
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
Tryit Editor v3.6 - Show Python

a = mymodule.person1["age"]
How to create a split screen (50/50) with CSS?

To create a split screen with CSS, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
   body {
      font-family: Arial;
      color: white;
   }
   h1{
      padding:20px;
   }
   .left,.right {
      height: 100%;
      width: 50%;
      position: fixed;
      z-index: 1;
      top: 0;
      overflow-x: hidden;
      padding-top: 20px;
   }
   .left {
      left: 0;
      background-color: rgb(36, 0, 95);
   }
   .right {
      right: 0;
      background-color: rgb(56, 1, 44);
   }
   .centered {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      text-align: center;
   }
   .centered img {
      width: 150px;
      border-radius: 50%;
   }
</style>
</head>
<body>
<div class="left">
<h1>Some random text on the left</h1>
</div>
<div class="right">
<h1>Some random text on the right</h1>
</div>
</body>
</html>
The above code will produce the following output −
How to create a Mochawesome report in Cypress?

We can create a Mochawesome report in Cypress. Cypress is bundled with Mocha, so any reports that can be generated for Mocha can also be utilized with Cypress.
The Mochawesome report is one of the most important reports in Cypress. To install mochawesome, run the command −
   npm install mochawesome --save-dev
To install mocha, run the command −
   npm install mocha --save-dev
To merge mochawesome json reports, run the command −
   npm install mochawesome-merge --save-dev
All these packages after installation should get reflected on the package.json file.
To merge multiple reports in a single report, run the command −
   npm run combine-reports
In the cypress.json file, we can set the following configurations for the mochawesome reports −
overwrite – if its value is set to false there should not be any overwriting from the prior generated reports.
overwrite – if its value is set to false there should not be any overwriting from the prior generated reports.
reportDir – the location where reports are to be saved.
reportDir – the location where reports are to be saved.
quiet – if its value is set to true, there should not be any Cypress-related output. Only the mochawesome output to be printed.
quiet – if its value is set to true, there should not be any Cypress-related output. Only the mochawesome output to be printed.
html – if its value is set to false, there should not be any generation of html reports after execution.
html – if its value is set to false, there should not be any generation of html reports after execution.
json – if its value is set to true, a json file with execution details will be generated.
json – if its value is set to true, a json file with execution details will be generated.
Implementation in cypress.json
{
   "reporter": "mochawesome",
   "reporterOptions": {
      "reportDir": "cypress/results",
      "overwrite": false,x
      "html": false,
      "json": true
   }
}
To generate a report for all specs in the integration folder of the Cypress project, run the command −
   npx cypress run
For running a particular test, run the command −
   npx cypress run --spec "<path of spec file>"
After execution is completed, the mochawesome-report folder gets generated within the Cypress project containing reports in html and json formats.
Right-click on the mochawesome.html report, select the Copy Path option, and open the path copied on the browser.
The mochawesome report gets opened with details of the execution results, duration, test case name, test steps, and so on. On clicking on the icon (highlighted in the above image) on the left upper corner of the screen, more options get displayed.
We can get the different views to select the passed, failed, pending, skipped test cases, and the hooks applied to the test.
How to transform JSON text to a JavaScript object ? - GeeksforGeeks

01 Dec, 2021
JSON (JavaScript Object Notation) is a lightweight data-interchange format. As its name suggests, JSON is derived from the JavaScript programming language, but it’s available for use by many languages including Python, Ruby, PHP, and Java, and hence, it can be said as language-independent. For humans, it is easy to read and write and for machines, it is easy to parse and generate. It is very useful for storing and exchanging data.
A JSON object is a key-value data format that is typically rendered in curly braces. JSON object consists of curly braces ( { } ) at either end and has key-value pairs inside the braces. Each key-value pair inside braces are separated by a comma (, ). JSON object looks something like this :
{
   "key":"value",
   "key":"value",
   "key":"value",
}
Example for a JSON object :
{
   "rollno":101",
   "name":"Nikita",
   "age":21,
}
 
Conversion of JSON text to Javascript Object: JSON text/object can be converted into Javascript object using the function JSON.parse().
The JSON.parse() method in JavaScript is used to parse a JSON string which is written in a JSON format and returns a JavaScript object.
Syntax:
JSON.parse(string, function)
Parameters: This method accepts two parameters as mentioned above and described below
string: It is a required parameter and it contains a string that is written in JSON format.
function: It is an optional parameter and is used to transform results. The function called for each item.
Example:
HTML
<script>    var obj = JSON.parse('{"rollno":101,         "name": "Nikita", "age": 21}');    document.write("Roll no is " + obj.rollno + "<br>");    document.write("Name is " + obj.name + "<br>");    document.write("Age is " + obj.age + "<br>");</script>
Output:
Roll no is 101
Name is Nikita
Age is 21
Example 2:
HTML
<html>  <body>    <h2>JavaScript JSON parse() Method</h2>    <p id="Geek"></p>  </body><script>    var obj = JSON.parse('{"var1":"Hello","var2":"Geeks!"}');    document.getElementById("Geek").innerHTML        = obj.var1 + " " + obj.var2;</script>  </html>
Output:
References:
https://www.geeksforgeeks.org/javascript-json-parse-method/
https://www.geeksforgeeks.org/javascript-json/
javascript-object
JavaScript-Questions
JSON
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
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
basic_istream::putback() in C++ with Examples - GeeksforGeeks

28 May, 2020
The basic_istream::putback() used to put the character back in the input string. This function is present in the iostream header file. Below is the syntax for the same:
Header File:
#include<iostream>

Syntax:
basic_istream& putback (char_type ch);

Parameter:
ch: It represents the character to be put into the input string back.
Return Value: The iostream::basic_istream::putback() return the basic_istream object.
Below are the programs to understand the implementation of std::basic_istream::putback() in a better way:
Program 1:
// C++ code for basic_istream::putback()#include <bits/stdc++.h>  using namespace std;  int main(){    stringstream gfg1("GeeksforGeeks");    gfg1.get();      // putback A into the input string    if (gfg1.putback('A'))        cout << gfg1.rdbuf() << endl;      istringstream gfg2("GeeksforGeeks");    gfg2.get();      if (gfg2.putback('A'))        cout << gfg2.rdbuf() << endl;    else        cout << "putback is failed here\n";      gfg2.clear();      // Again putback G in the string    if (gfg2.putback('G'))        cout << gfg2.rdbuf() << endl;}
AeeksforGeeks
putback is failed here
GeeksforGeeks

Program 2:
// C++ code for basic_istream::putback()#include <bits/stdc++.h>  using namespace std;  int main(){    stringstream gfg1("GOOD");    gfg1.get();      // putback B into the input string    if (gfg1.putback('B'))        cout << gfg1.rdbuf() << endl;      istringstream gfg2("GOOD");    gfg2.get();      if (gfg2.putback('B'))        cout << gfg2.rdbuf() << endl;    else        cout << "putback is failed here\n";      gfg2.clear();      // Again putback G in the string    if (gfg2.putback('G'))        cout << gfg2.rdbuf() << endl;}
BOOD
putback is failed here
GOOD

Reference: http://www.cplusplus.com/reference/istream/istream/putback/
CPP-Functions
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Friend class and function in C++
Sorting a vector in C++
std::string class in C++
Pair in C++ Standard Template Library (STL)
Inline Functions in C++
Queue in C++ Standard Template Library (STL)
Array of Strings in C++ (5 Different Ways to Create)
Convert string to char array in C++
Python Program for Common Divisors of Two Numbers - GeeksforGeeks

30 Nov, 2018
Given two integer numbers, the task is to find count of all common divisors of given numbers?
Input : a = 12, b = 24
Output: 6
// all common divisors are 1, 2, 3, 
// 4, 6 and 12

Input : a = 3, b = 17
Output: 1
// all common divisors are 1

Input : a = 20, b = 36
Output: 3
// all common divisors are 1, 2, 4

# Python Program to find # Common Divisors of Two Numbers  a = 12b = 24n = 0  for i in range(1, min(a, b)+1):    if a%i==b%i==0:        n+=1      print(n)  # Code contributed by Mohit Gupta_OMG
Output:
6

Please refer complete article on Common Divisors of Two Numbers for more details!
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Appending to list in Python dictionary
Python program to interchange first and last elements in a list
How to inverse a matrix using NumPy
Python | Get the first key in dictionary
Differences and Applications of List, Tuple, Set and Dictionary in Python
Python Program for Merge Sort
Python | Find most frequent element in a list
Python - Convert JSON to string
Python | Difference between two dates (in minutes) using datetime.timedelta() method
Python program to find smallest number in a list
jQuery UI Dialog modal Option - GeeksforGeeks

13 Jan, 2021
‘modal option’ if set to true will disable the other items in the dialog box. By default, value is false.
Syntax:
$( ".selector" ).dialog({
  modal: false
});
Approach: First, add jQuery UI scripts needed for your project.
<link href = “https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css” rel = “stylesheet”><script src = “https://code.jquery.com/jquery-1.10.2.js”></script><script src = “https://code.jquery.com/ui/1.10.4/jquery-ui.js”></script>
Example 1:
HTML
<!doctype html>                                             <html lang = "en">    <head>  <meta charset = "utf-8">  <link rel = "stylesheet" href ="https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css">      <script src ="https://code.jquery.com/jquery-1.10.2.js">  </script>      <script src ="https://code.jquery.com/ui/1.10.4/jquery-ui.js">  </script>    <script>     $(function() {        $( "#gfg" ).dialog({           autoOpen: false,           modal : true        });        $( "#geeks" ).click(function() {           $( "#gfg" ).dialog( "open" );        });     });  </script></head>  <body>  <div id = "gfg" title = "GeeksforGeeks">    Jquery UI| modal dialog option  </div>      <button id = "geeks">Open Dialog</button></body>    </html>
Output:
Example 2:
HTML
<!doctype html>                                             <html lang = "en">    <head>  <meta charset = "utf-8">  <link rel = "stylesheet" href ="https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css">      <script src ="https://code.jquery.com/jquery-1.10.2.js">  </script>      <script src ="https://code.jquery.com/ui/1.10.4/jquery-ui.js">  </script>    <script>     $(function() {        $( "#gfg" ).dialog({           autoOpen: false,           modal : false        });        $( "#geeks" ).click(function() {           $( "#gfg" ).dialog( "open" );        });     });  </script></head>  <body>  <div id = "gfg" title ="GeeksforGeeks">    Jquery UI| modal dialog option  </div>      <button id = "geeks">Open Dialog</button></body>    </html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
jQuery-UI
HTML
JQuery
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
HTML Cheat Sheet - A Basic Guide to HTML
Design a web page using HTML and CSS
Form validation using jQuery
Angular File Upload
JQuery | Set the value of an input text field
Form validation using jQuery
How to change selected value of a drop-down list using jQuery?
How to change the background color after clicking the button in JavaScript ?
How to fetch data from JSON file and display in HTML table using jQuery ?
Python program to print all even numbers in a range - GeeksforGeeks

25 Apr, 2022
Given starting and end points, write a Python program to print all even numbers in that given range. Example:
Input: start = 4, end = 15
Output: 4, 6, 8, 10, 12, 14

Input: start = 8, end = 11
Output: 8, 10
Example #1: Print all even numbers from given list using for loop Define start and end limit of range. Iterate from start till the range in the list using for loop and check if num % 2 == 0. If the condition satisfies, then only print the number. 
Python3
for num in range(4,15,2):  #here inside range function first no dentoes starting, second denotes end and third denotes the interval    print(num)
Output:
4 6 8 10 12 14 
  Example #2: Taking range limit from user input 
Python3
# Python program to print Even Numbers in given range start = int(input("Enter the start of range: "))end = int(input("Enter the end of range: ")) # iterating each number in listfor num in range(start, end + 1):         # checking condition    if num % 2 == 0:        print(num, end = " ")
Output:
Enter the start of range: 4
Enter the end of range: 10
4 6 8 10 
rohhitrz
Python list-programs
python-list
Python
Python Programs
School Programming
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python String | replace()
*args and **kwargs in Python
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
PrintWriter printf(String, Object) method in Java with Examples - GeeksforGeeks

31 Jan, 2019
The printf(String, Object) method of PrintWriter Class in Java is used to print a formatted string in the stream. The string is formatted using specified format and arguments passed as the parameter.
Syntax:
public PrintWriter printf(String format, Object...args)
Parameters: This method accepts two mandatory parameter:
format which is the format according to which the String is to be formatted.
args which is the number of arguments for the formatted string. It can be optional, i.e. no arguments or any number of arguments according to the format.
Return Value: This method returns this PrintWriter instance.
Exception: This method throws following exceptions:
NullPointerException This is thrown if the format is null.
IllegalFormatException This is thrown if the format specified is illegal or there are insufficient arguments.
Below methods illustrates the working of printf(String, Object) method:
Program 1:
// Java program to demonstrate// PrintWriter printf(String, Object) method  import java.io.*;  class GFG {    public static void main(String[] args)    {          try {              // Get the parameters            double arg = 47.65734;              String format = "GeeksForGeeks %.8f";              // Create a PrintWriter instance            PrintWriter writer                = new PrintWriter(System.out);              // print the formatted string            // to this writer using printf() method            writer.printf(format, arg);              writer.flush();        }        catch (Exception e) {            System.out.println(e);        }    }}
GeeksForGeeks 47.65734000

Program 2:
// Java program to demonstrate// PrintWriter printf(String, Object) method  import java.io.*;  class GFG {    public static void main(String[] args)    {          try {              // Get the parameters              String arg1 = "GFG";            String arg2 = "GeeksforGeeks";              String format = "A Computer Science "                            + "Portal  %1$s, %1$s and %2$s";              // Create a PrintWriter instance            PrintWriter writer                = new PrintWriter(System.out);              // print the formatted string            // to this writer using printf() method            writer.printf(format, arg1, arg2);              writer.flush();        }        catch (Exception e) {            System.out.println(e);        }    }}
A Computer Science Portal  GFG, GFG and GeeksforGeeks

Java-Functions
Java-IO package
Java-PrintWriter
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Generics in Java
Introduction to Java
Comparator Interface in Java with Examples
Internal Working of HashMap in Java
Strings in Java
p5.js | frameRate() Function - GeeksforGeeks

09 Jul, 2019
The frameRate() function in p5.js is used to specify the number of frames to be displayed every second. Calling frameRate() with no arguments returns the current framerate. The draw function must run at least once before it will return a value. This function is same as getFrameRate() function.
Syntax
frameRate( c )
Parameters: The function accepts single parameter c which stores the value of frame rate variable.
Below program illustrates the frameRate() function in p5.js:
Example:
function setup() {        // Create canvas of given size    createCanvas(500, 200);          // Set the font size    textSize(20);        // Use frameRate() function    frameRate(3);}   function draw() {          // Set the background color    background(0, 153, 0);          // Display the output    text("Frame Count with frameRate " +          int(getFrameRate()), 100, 100);}
Output:
Reference: https://p5js.org/reference/#/p5/frameRate
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to calculate the number of days between two dates in javascript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
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
Generate current month in C#

To display current month, firstly use “Now“ to get the current date.
DateTime dt = DateTime.Now;
Now, use the Month property to get the current month.
dt.Month
Let us see the complete code.
 Live Demo
using System;
using System.Linq;
public class Demo {
   public static void Main() {
      DateTime dt = DateTime.Now;
      Console.WriteLine(dt.Month);
   }
}
9
To display current month’s name.
 Live Demo
using System;
using System.Linq;
public class Demo {
   public static void Main() {
      DateTime dt = DateTime.Now;
      Console.WriteLine(dt.ToString("MMM"));
   }
}
Sep
What is the meaning of DOCTYPE in HTML ? - GeeksforGeeks

06 Apr, 2021
The HTML document type declaration or Doctype is an instruction used by web browsers to fetch what version of HTML the website is written in. It helps browsers in understanding how the document should be interpreted thus eases the rendering process. It is neither an element nor a tag. The doctype should be placed on the top of the document. It must not contain any content and does not need a closing tag.
Syntax:
<!DOCTYPE html>
Example 1:
HTML
<!-- This resembles doctype for HTML5 file  --><!DOCTYPE html><html>  <head>    <title>Page Title</title></head>  <body>    <h2>Welcome To GFG</h2>    <p>Default code has been loaded into the Editor.</p></body>  </html>
Example 2:
HTML
<!-- Below is declaration of XHTML 1.1 document --><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html>  <head>    <title>Page Title</title></head>  <body>    <h2>Welcome To GFG</h2>    <p>Default code has been loaded into the Editor.</p></body>  </html>
Following are some doctype files to be included with the following document types:
XHTML 1.1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
XHTML 1.0 Frameset
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
XHTML 1.0 Transitional
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
XHTML 1.0 Strict
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
HTML 4.01 Frameset
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" 
"http://www.w3.org/TR/html4/frameset.dtd">
HTML 4.01 Transitional
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
HTML 4.01 Strict
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd">
HTML 5
<!DOCTYPE html>
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Questions
HTML-Tags
Picked
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
REST API (Introduction)
Design a web page using HTML and CSS
Form validation using jQuery
How to place text on image using HTML and CSS?
How to auto-resize an image to fit a div container using CSS?
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript