code-rag-bench/online-tutorials huggingface dataset:
XHTML - Doctypes

The XHTML standard defines three Document Type Definitions (DTDs). The most commonly used and easy one is the XHTML Transitional document.
XHTML 1.0 document type definitions correspond to three DTDs −
Strict
Transitional
Frameset
There are few XHTML elements and attributes, which are available in one DTD but not available in another DTD. Therefore, while writing your XHTML document, you must select your XHTML elements or attributes carefully. However, XHTML validator helps you to identify valid and invalid elements and attributes.
Please check XHTML Validations for more detail on this.
If you are planning to use Cascading Style Sheet (CSS) strictly and avoiding to write most of the XHTML attributes, then it is recommended to use this DTD. A document conforming to this DTD is of the best quality.
If you want to use XHTML 1.0 Strict DTD then you need to include the following line at the top of your XHTML document.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
If you are planning to use many XHTML attributes as well as few Cascading Style Sheet properties, then you should adopt this DTD and you should write your XHTML document accordingly.
If you want to use XHTML 1.0 Transitional DTD, then you need to include the following line at the top of your XHTML document.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
You can use this when you want to use HTML Frames to partition the browser window into two or more frames.
If you want to use XHTML 1.0 Frameset DTD, then you need to include following line at the top of your XHTML document.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
Note − No matter what DTD you are using to write your XHTML document; if it is a valid XHTML document, then your document is considered as a good quality document.
Which function is used to prevent code running before document loading in jQuery ? - GeeksforGeeks

30 Dec, 2021
In this article, we will learn how to prevent code from running, before the document is finished loading.
Sometimes we might need to run a script after the entire document gets loaded, for example, if we want to calculate the size of images in the document then we need to wait until the entire document gets loaded.
The ready() method is an inbuilt method in jQuery that executes the code when the whole page is loaded. This method specifies the function to execute when the DOM is fully loaded.
Syntax:
$(document).ready(function)
Parameters:  This method takes one function as an argument. It is used to specify the function to run after the document is loaded.
CDN link:
<script src=”https://code.jquery.com/jquery-1.9.1.min.js”></script>
Approach:
We can do this by using the jQuery ready() function.
Create an HTML page and use the <script> tag which specify the src to embed the above jQuery CDN link.
In ready() method, write the function which need to be prevented form execution before the entire document loads.
Example: In the below code, line 20 is in ready() method, so lines 19 and 25 are executed and printed in the console before line 20, The line 20 is executed after the entire document gets loaded.
HTML
<!DOCTYPE html><html lang="en">  <head>    <script src="https://code.jquery.com/jquery-1.9.1.min.js">    </script></head>  <body>      <script>        console.log("This is on line 19 ");          $(document).ready(function () {            console.log("this line will execute after"            + " the webpage is loaded (on line 20)");        });          console.log("This is on line 25 ");    </script></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.
HTML-Questions
jQuery-Methods
jQuery-Questions
Picked
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 ?
Node.js process.cwd() Method - GeeksforGeeks

12 Oct, 2021
The process.cwd() method is an inbuilt application programming interface of the process module which is used to get the current working directory of the node.js process.
Syntax:
process.cwd()
Parameters: This method does not accept any parameters.
Return Value: This method returns a string specifying the current working directory of the node.js process.
Below examples illustrate the use of process.cwd() method in Node.js:
Example 1:
// Node.js program to demonstrate the    // process.cwd() Method  // Include process moduleconst process = require('process');  // Printing current directoryconsole.log("Current working directory: ",          process.cwd());
Output:
Current working directory: C:\nodejs\g\process

Example 2:
// Node.js program to demonstrate the    // process.cwd() Method  // Include process moduleconst process = require('process');  // Printing current directoryconsole.log("Current working directory: ",          process.cwd());  try {        // Change working directory  process.chdir('../');  console.log("Working directory after changing"      + " directory: ", process.cwd());} catch (err) {       // printing error if occurs  console.error("error occured while changing"          + " directory: ", err);}
Output:
Current working directory: C:\nodejs\g\process
Working directory after changing directory: C:\nodejs\g\os

Note: The above program will compile and run by using the node filename.js command.
Reference:https://nodejs.org/api/process.html#process_process_cwd
Node.js-process-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 ?
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
CSS | skew() Function - GeeksforGeeks

08 Aug, 2019
The skew() function is an inbuilt function which is used to transform an element in the 2D plane. Skew an element means to pick a point and push or pull it in different directions.
Syntax:
skew( ax )
or
skew( ax, ay )
Parameters:
ax: This parameter holds the angle representing the horizontal axis to distort an element.
ay: This parameter holds the angle representing the vertical axis to distort an element. If it is not defined then it takes the default value zero. It means completely skew in x direction.
Below examples illustrate the skew() function in CSS:
Example 1:
<!DOCTYPE html> <html>   <head>     <title>CSS skew() function</title>       <style>         body {            text-align:center;        }        h1 {            color:green;        }        .skew_image {            transform-origin: top left;            transform: skew(30deg, 0);        }    </style> </head>   <body>     <h1>GeeksforGeeks</h1>    <h2>CSS skew() function</h2>          <img class="skew_image" src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png"        alt="GeeksforGeeks logo"> </body>   </html>    
Output:
Example 2:
<!DOCTYPE html> <html>   <head>     <title>CSS skew() function</title>       <style>         body {            text-align:center;        }        h1 {            color:green;        }        .GFG {            font-size:35px;            font-weight:bold;            color:green;            transform: skew(45deg);        }    </style> </head>   <body>     <h1>GeeksforGeeks</h1>    <h2>CSS skew() function</h2>          <div class="GFG">Welcome to GeeksforGeeks</div> </body>   </html>    
Output:
Supported Browsers: The browsers supported by skew() function are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
CSS-Functions
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a web page using HTML and CSS
How to set space between the flexbox ?
Form validation using jQuery
Search Bar using HTML, CSS and JavaScript
How to style a checkbox using CSS?
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 ?
Difference between var, let and const keywords in JavaScript
Scala String equals() method with example - GeeksforGeeks

03 Oct, 2019
The equals() method is utilized to check if the stated string and object are equal.
Method Definition: Boolean equals(Object anObject)Return Type: It returns true if the string is same as the object stated else it returns false.
Example #1:
// Scala program of equals()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {        // Creating an array        val m1 = Array('N', 'i', 'd', 'h', 'i')                  // Applying equals() method        val result = "Nidhi".equals("Nidhi")                  // Displays output        println(result)          }} 
true

Example #2:
// Scala program of equals()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {        // Creating an array        val m1 = Array('N', 'i', 'd', 'h', 'i')                            // Applying equals() method        val result = "Nidhi".equals("Nidh")                  // Displays output        println(result)          }} 
false

Scala
Scala-Method
Scala-Strings
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Inheritance in Scala
Scala | Traits
Scala ListBuffer
Scala | Case Class and Case Object
Hello World in Scala
Scala | Functions - Basics
Scala | Decision Making (if, if-else, Nested if-else, if-else if)
Scala List map() method with example
Comments In Scala
Scala | Try-Catch Exceptions
How to convert decimal to octal in JavaScript ? - GeeksforGeeks

31 Dec, 2020
Given a number and the task is to convert the number from decimal to octal. This can be done by using number.toString(8) method. It takes the parameter which is the base of the converted string. In this case, the base will be 8.
Syntax:
number.toString(8)
Parameters:
number: It holds the number in a decimal format which needs to be converted.
Example:
Input: 34
       24680
Output: a = 42
        b = 60150
Input: 20
       56789
Output: 24
        156725
Example 1:
javascript
<!DOCTYPE html> <html>  <body>    <script>                var a = 34;        var b = 24680;                  document.write("a = " + a.toString(8) + "<br>");        document.write("b = " + b.toString(8) + "<br>");             </script></body>  </html>
Output:
a = 42
b = 60150
Example 2:
javascript
<!DOCTYPE html><html>  <body>    <script>        dec_to_bho = function (n, base) {            if (n < 0) {                n = 0xFFFFFFFF + n + 1;            }            switch (base) {                case 'O':                    return parseInt(n, 10).toString(8);                    break;                case 'P':                    return parseInt(n, 10).toString(8);                    break;                case 'Q':                    return parseInt(n, 10).toString(8);                    break;                default:                    return ("Wrong input");            }        }          console.log(dec_to_bho(20, 'O'));        console.log(dec_to_bho(56789, 'P'));        console.log(dec_to_bho(321, 'Q'));    </script></body>  </html>
Output:
24
156725
501
Example 3:
javascript
<!DOCTYPE html><html>  <body style="text-align:center;">    <h1 style="color:green;">        GeeksForGeeks    </h1>      <p id="up"></p>        <button onclick="myGFG()">        Convert to octal    </button>      <p id="down" style="color: green"></p>        <script>        var GFG_Var = 134;        var up = document.getElementById("up");        up.innerHTML = GFG_Var;        var down = document.getElementById("down");          function myGFG() {            var GFG_Var2 = GFG_Var.toString(8);            down = document.getElementById("down");            down.innerHTML = "oct of " + GFG_Var                + " is = " + GFG_Var2;        }     </script></body>  </html>
Output:
Before clicking the button:
After clicking the button:
HTML-Misc
JavaScript-Misc
CSS
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a web page using HTML and CSS
How to set space between the flexbox ?
Form validation using jQuery
Search Bar using HTML, CSS and JavaScript
How to style a checkbox using CSS?
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?
How to reload or re-render the entire page using AngularJS? - GeeksforGeeks

13 Aug, 2021
While working with AngularJS we might come across a time when we want our user to switch contexts and re-render everything again.AngularJS provides a method by which we can re-render or even reload the entire page. So in this article, we will see how we can reload the route instead of just reloading the entire page or application as refreshing the entire page just for some small chances may get problematic from time to time as well as we will also see how we can reload the entire page from the server or from the cache itself. AngularJS mainly provides two different methods for reloading and refresh
Using reload() method: Angular route service reload() method is used when we want just the current route to be reloaded instead of making our entire application reloading or refreshing. Let’s say the route’s controller has services that are called when the controller is instantiated and you need to re-call those exact same services when some condition happens to refresh the data. So what we can basically do to minimize all this reloading task is we can just call $route.reload(). This won’t refresh the entire page but will reload only the route which will re-instantiate the controller and therefore recall the services.
Example: 
Javascript
app.controller('ControllerName',               ['$scope', '$route', function($scope, $route) {    $scope.reloadRoute = function() {         // Reload only the route which will re-instantiate        $route.reload();    };}]);
Using location.reload() method: The location.reload() method is used to refresh or reload the entire page, optionally forcing a re-download of the content. This method gives the same result as when we use the refresh or reload button. It just reset our whole website state. By default, this method loads the page from the cache and when we set the forceGet property to true then the page gets reloaded from the server. This method doesn’t have any return type.
Syntax: 
location.reload(forceGet)
Example: The forceGet parameter is an optional parameter and should be only used when we want to force the entire website to reload from the server. Without forceGet property, the website will just be reloaded from the cache. 
Javascript
function locationreload() {         // To reload the entire page from the server        location.reload();              }
 
anikakapoor
AngularJS-Misc
Picked
AngularJS
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Angular File Upload
Angular PrimeNG Dropdown Component
Angular | keyup event
Auth Guards in Angular 9/10/11
How to Display Spinner on the Screen till the data from the API loads using Angular 8 ?
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 ?
How to insert spaces/tabs in text using HTML/CSS?
__name__ (A Special variable) in Python - GeeksforGeeks

22 Nov, 2020
Since there is no main() function in Python, when the command to run a python program is given to the interpreter, the code that is at level 0 indentation is to be executed. However, before doing that, it will define a few special variables. __name__ is one such special variable. If the source file is executed as the main program, the interpreter sets the __name__ variable to have a value “__main__”. If this file is being imported from another module, __name__ will be set to the module’s name.__name__ is a built-in variable which evaluates to the name of the current module. Thus it can be used to check whether the current script is being run on its own or being imported somewhere else by combining it with if statement, as shown below.
Consider two separate files File1 and File2.
# File1.py   print ("File1 __name__ = %s" %__name__)   if __name__ == "__main__":     print ("File1 is being run directly")else:     print ("File1 is being imported")
 
# File2.py   import File1   print ("File2 __name__ = %s" %__name__)   if __name__ == "__main__":     print ("File2 is being run directly")else:     print ("File2 is being imported")
Now the interpreter is given the command to run File1.py.
python File1.py
Output :
File1 __name__ = __main__
File1 is being run directly


And then File2.py is run.
python File2.py
Output :
File1 __name__ = File1
File1 is being imported
File2 __name__ = __main__
File2 is being run directly

As seen above, when File1.py is run directly, the interpreter sets the __name__ variable as __main__ and when it is run through File2.py by importing, the __name__ variable is set as the name of the python script, i.e. File1. Thus, it can be said that if __name__ == “__main__” is the part of the program that runs when the script is run from the command line using a command like python File1.py.
This article is contributed by Harshit Agrawal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@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.
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
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
Check if a string contains a number using Java.

To find whether a given string contains a number, convert it to a character array and find whether each character in the array is a digit using the isDigit() method of the Character class.
Live Demo
public class ContainsExample {
   public static void main(String args[]){
      String sample = "krishna64";
      char[] chars = sample.toCharArray();
      StringBuilder sb = new StringBuilder();
      for(char c : chars){
         if(Character.isDigit(c)){
            sb.append(c);
         }
      }
      System.out.println(sb);
   }
}
64
Matplotlib.axes.Axes.set_zorder() in Python - GeeksforGeeks

30 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
The Axes.set_zorder() function in axes module of matplotlib library is used to set the zorder for the artist.
Syntax: Axes.set_zorder(self, level)
Parameters: This method accepts only one parameters.
level: This parameter contains the float value.
Returns: This method does not return any value.
Below examples illustrate the matplotlib.axes.Axes.set_zorder() function in matplotlib.axes:
Example 1:
# Implementation of matplotlib functionimport numpy as npimport matplotlib.pyplot as plt   d = np.arange(100).reshape(10, 10)xx, yy = np.meshgrid(np.arange(11), np.arange(11))   fig, ax = plt.subplots()   ax.set_aspect(1)m = ax.pcolormesh(xx, yy, d)m.set_zorder(-15)   fig.suptitle('matplotlib.axes.Axes.set_zorder() function\ Example', fontweight ="bold")  plt.show()
Output:
Example-2:
# Implementation of matplotlib functionimport numpy as npimport matplotlib.pyplot as plt   xx = np.random.rand(16, 30)   fig, (ax3, ax4) = plt.subplots(1, 2)   m = ax3.pcolor(xx)   ax3.set_title("No Zorder value ")   m = ax4.pcolor(xx)m.set_zorder(-20)  ax4.set_title("Zorder Value : -20")   fig.suptitle('matplotlib.axes.Axes.set_zorder() \function Example', fontweight ="bold")  plt.show()
Output:
Matplotlib axes-class
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Writing to Files in R Programming - GeeksforGeeks

25 Nov, 2021
R programming Language is one of the very powerful languages specially used for data analytics in various fields. Analysis of data means reading and writing data from various files like excel, CSV, text files, etc. Today we will be dealing with various ways of writing data to different types of files using R programming. 
CSV stands for Comma Separated Values. These files are used to handle a large amount of statistical data. Following is the syntax to write to a CSV file: 
Syntax: 
R
write.csv(my_data, file = "my_data.csv")write.csv2(my_data, file = "my_data.csv")
Here, 
csv() and csv2() are the function in R programming. 
write.csv() uses “.” for the decimal point and a comma (“, ”) for the separator.
write.csv2() uses a comma (“, ”) for the decimal point and a semicolon (“;”) for the separator.
Text files are commonly used in almost every application in our day-to-day life as a step for the “Paperless World”. Well, writing to .txt files is very similar to that of the CSV files. Following is the syntax to write to a text file: 
Syntax: 
R
write.table(my_data, file = "my_data.txt", sep = "")
To write data to excel we need to install the package known as “xlsx package”, it is basically a java based solution for reading, writing, and committing changes to excel files. It can be installed as follows: 
install.packages("xlsx")
and can be loaded and General syntax of using it is: 
R
library("xlsx") write.xlsx(my_data, file = "result.xlsx",           sheetName = "my_data", append = FALSE).
 
kumar_satyam
Picked
R-FileHandling
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change column name of a given DataFrame in R
How to Replace specific values in column in R DataFrame ?
Filter data by multiple conditions in R using Dplyr
Loops in R (for, while, repeat)
Adding elements in a vector in R programming - append() method
How to change Row Names of DataFrame in R ?
Change Color of Bars in Barchart using ggplot2 in R
Convert Factor to Numeric and Numeric to Factor in R Programming
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
Difference of two columns in Pandas dataframe - GeeksforGeeks

24 Dec, 2018
Difference of two columns in pandas dataframe in Python is carried out by using following methods :
Method #1 : Using ” -” operator.
import pandas as pd  # Create a DataFramedf1 = { 'Name':['George','Andrea','micheal',                'maggie','Ravi','Xien','Jalpa'],        'score1':[62,47,55,74,32,77,86],        'score2':[45,78,44,89,66,49,72]}  df1 = pd.DataFrame(df1,columns= ['Name','score1','score2'])  print("Given Dataframe :\n", df1)  # getting Differencedf1['Score_diff'] = df1['score1'] - df1['score2']print("\nDifference of score1 and score2 :\n", df1)
Given Dataframe :
       Name  score1  score2
0   George      62      45
1   Andrea      47      78
2  micheal      55      44
3   maggie      74      89
4     Ravi      32      66
5     Xien      77      49
6    Jalpa      86      72

Difference of score1 and score2 :
       Name  score1  score2  Score_diff
0   George      62      45          17
1   Andrea      47      78         -31
2  micheal      55      44          11
3   maggie      74      89         -15
4     Ravi      32      66         -34
5     Xien      77      49          28
6    Jalpa      86      72          14

 Method #2 : Using sub() method of the Dataframe.
import pandas as pd  # Create a DataFramedf1 = { 'Name':['George','Andrea','micheal',                'maggie','Ravi','Xien','Jalpa'],        'score1':[62,47,55,74,32,77,86],        'score2':[45,78,44,89,66,49,72]}   df1 = pd.DataFrame(df1,columns= ['Name','score1','score2'])   print("Given Dataframe :\n", df1)  df1['Score_diff'] = df1['score1'].sub(df1['score2'], axis = 0)print("\nDifference of score1 and score2 :\n", df1)
Given Dataframe :
       Name  score1  score2
0   George      62      45
1   Andrea      47      78
2  micheal      55      44
3   maggie      74      89
4     Ravi      32      66
5     Xien      77      49
6    Jalpa      86      72

Difference of score1 and score2 :
       Name  score1  score2  Score_diff
0   George      62      45          17
1   Andrea      47      78         -31
2  micheal      55      44          11
3   maggie      74      89         -15
4     Ravi      32      66         -34
5     Xien      77      49          28
6    Jalpa      86      72          14

pandas-dataframe-program
Picked
Python pandas-dataFrame
Python-pandas
Technical Scripter 2018
Python
Technical Scripter
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
*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
How To Convert Python Dictionary To JSON?
sum() function in Python
PHP | Spreadsheet_Excel_Writer | addFormat() Function - GeeksforGeeks

04 Oct, 2021
The addFormat() function is an inbuilt function in PHP | Spreadsheet_Excel_Writer which is used to set the format of a spreadsheet.
Syntax: 
Workbook::&addFormat( $properties = array() )
Parameters: This function accepts single parameter $properties which accepts the array value. In order to set various formats, we use their corresponding functions like setBold() for Bold, setBorder() for borders, and many other functions.
Example 1:  
PHP
<?php require_once 'Spreadsheet/Excel/Writer.php'; // Add Workbook$workbook = new Spreadsheet_Excel_Writer(); // Add Format to spreadsheet$format_bold =& $workbook->addFormat(); // Set Bold Format$format_bold->setBold(); // Add Worksheet to Spreadsheet$worksheet =& $workbook->addWorksheet(); $format_bold->setBorder(2); // Write to Worksheet$worksheet->write(0, 0, "Details of GeeksforGeeks                     Contributors", $format_bold);$worksheet->write(1, 0, "Author", $format_bold);$worksheet->write(1, 1, "User Handle", $format_bold);$worksheet->write(2, 0, "Sarthak");$worksheet->write(2, 1, "sarthak_ishu11"); // Send .xlsx file to header$workbook->send('test.xls'); // Close Workbook Object$workbook->close();?>
Output: 
Example 2:  
PHP
<?php require_once 'Spreadsheet/Excel/Writer.php'; // Add Workbook$workbook = new Spreadsheet_Excel_Writer(); // Add Format to spreadsheet$format_border =& $workbook->addFormat(); // Add Worksheet to Spreadsheet$worksheet =& $workbook->addWorksheet(); // Set and Add Border Width$format_border->setBorder(2); // Set and Add Color to Border$format_border->setBorderColor('red'); // Write to Worksheet$worksheet->write(0, 0, "Details of GeeksforGeeks                      Contributors", $format_bold);$worksheet->write(1, 0, "Author", $format_border);$worksheet->write(1, 1, "User Handle", $format_border);$worksheet->write(2, 0, "Sarthak");$worksheet->write(2, 1, "sarthak_ishu11"); // Send .xlsx file to header$workbook->send('test.xls'); // Close Workbook Object$workbook->close();?>
Output: 
Reference: https://pear.php.net/manual/en/package.fileformats.spreadsheet-excel-writer.intro-format.php 
sooda367
PHP-function
PHP-Spreadsheet
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to convert array to string in PHP ?
PHP | Converting string to Date and DateTime
How to pass JavaScript variables to PHP ?
Split a comma delimited string into an array in PHP
How to get parameters from a URL string in PHP?
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 ?
How to insert spaces/tabs in text using HTML/CSS?
Python | Pandas Series.update() - GeeksforGeeks

29 Jan, 2019
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 series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index.
Pandas Series.update() function modify Series in place using non-NA values from passed Series object. The function aligns on index.
Syntax: Series.update(other)
Parameter :other: series
Returns : None
Example #1: Use Series.update() function to update the values of some cities in the given Series object
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series(['New York', 'Chicago', None, 'Toronto', 'Lisbon', 'Rio', 'Chicago', 'Lisbon'])  # Print the seriesprint(sr)
Output :
Now we will use Series.update() function to update the values identified the passed indexed in the given Series object.
# update the values at the passed index# from the values in the passed series objectsr.update(pd.Series(['Melbourne', 'Moscow'], index = [2, 7]))
Output :
As we can see in the output, the Series.update() function has successfully updated the values in the original series object from the passed series object.
Example #2: Use Series.update() function to update the values of some elements in the given Series object
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([100, 214, 325, 88, None, 325, None, 325, 100])  # Print the seriesprint(sr)
Output :
Now we will use Series.update() function to update the values identified the passed indexed in the given Series object.
# update the values at the passed index# from the values in the passed series objectsr.update(pd.Series([5000, 6000], index = [4, 6]))
Output :As we can see in the output, the Series.update() function has successfully updated the values in the original series object from the passed series object.
Python pandas-series
Python pandas-series-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()
D3.js tsv() Function - GeeksforGeeks

31 Aug, 2020
The d3.tsv() function is used to read “.tsv” file or file with “tab” character as a delimiter. In the function if “init” is specified then it will fetch and go through the given function call.
Syntax:
d3.tsv(input[, init][, row])
Parameters: This function accepts three parameters as mentioned above and described below.
inputFile: This parameter take the input file address.
init: This parameter accepts a function call.
row: This parameter accepts a optional row conversion function.
Example 1:
HTML
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8" />    <meta name="viewport" path1tent=        "width=device-width,          initial-scale=1.0" />              <script src=        "https://d3js.org/d3.v4.min.js">    </script></head>  <body>    <script>        // Data of sample.tsv file        // year    population        // 2010    3        // 2011    45        // 2009    68        // 2010    5        // 2014    59        // 2011    55        // 2005    5        d3.tsv("sample.tsv", function (d) {            console.log(d);        });    </script></body>  </html>
Note: Please create a file name “sample.tsv” and save it in the working folder before going through the code.
Output:
Example 2:
HTML
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8" />    <meta name="viewport" path1tent=        "width=device-width,          initial-scale=1.0" />      <script src=        "https://d3js.org/d3.v4.min.js">    </script></head>  <body>    <script>        // Data of sample.tsv file        // x    y        // 15    9        // 5    0        // 3    10        // 6    51        // 35    11        d3.tsv("sample.tsv", function (d) {            return d;        }, (d) => {            d.forEach((e) => {                console.log(e)            })        });    </script></body>  </html>
Output:
D3.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
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 ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
PyQt5 - QLineEdit - GeeksforGeeks

18 Aug, 2020
QLineEdit : It allows the user to enter and edit a single line of plain text with a useful collection of editing functions, including undo and redo, cut and paste, and drag and drop. It is the basic widget in PyQt5 to receive keyboard input, input can be text, numbers or even symbol as well. Below is how the line edit look like
Example :We will create a line edit and a label and when user enter text in it and when enter key is pressed, the label will display the entered text.
Below is the implementation
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 500, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()          # method for components    def UiComponents(self):          # creating a QLineEdit object        line_edit = QLineEdit("GeeksforGeeks", self)          # setting geometry        line_edit.setGeometry(80, 80, 150, 40)          # creating a label        label = QLabel("GfG", self)          # setting geometry to the label        label.setGeometry(80, 150, 120, 60)          # setting word wrap property of label        label.setWordWrap(True)          # adding action to the line edit when enter key is pressed        line_edit.returnPressed.connect(lambda: do_action())          # method to do action        def do_action():              # getting text from the line edit            value = line_edit.text()              # setting text to the label            label.setText(value)        # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Python PyQt-QLineEdit
Python-gui
Python-PyQt
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
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
How to use react-window Module in ReactJS? - GeeksforGeeks

05 Mar, 2021
React window works by only rendering part of a large data set. This module is very easy to integrate and reduces the amount of time which generally takes a while to render. This module avoids the over-allocation of DOM nodes. We can use the react-window module in ReactJS using the following approach.
Creating React Application And Installing Module:
Step 1: Create a React application using the following command.
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command.
cd foldername
Step 3: After creating the ReactJS application, Install the material-ui and react-window modules using the following command.
npm install @material-ui/core
npm install react-window
Project Structure: It will look like the following.
Project Structure
Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
App.js
import React from "react";import ListItem from "@material-ui/core/ListItem";import ListItemText from "@material-ui/core/ListItemText";import { FixedSizeList } from "react-window";  function renderOurRow(props) {  const { index } = props;    return (    <ListItem key={index} button>      <ListItemText primary={`Sample Item ${index + 1}`} />    </ListItem>  );}  export default function App() {  return (    <div style={{ display: "block", padding: 30 }}>      <h4>How to use react-window Module in ReactJS?</h4>      <FixedSizeList height={250}                      width={300}                      itemSize={100}                      itemCount={5}>        {renderOurRow}      </FixedSizeList>    </div>  );}
Step to Run Application: Run the application using the following command from the root directory of the project.
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output.
Reference: https://material-ui.com/components/lists/#virtualized-list
React-Questions
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
ReactJS useNavigate() Hook
How to set background images in ReactJS ?
How to navigate on path by button click in react router ?
How to create a table in ReactJS ?
How to parse JSON Data into React Table Component ?
Installation of Node.js on Linux
Roadmap to Become a Web Developer in 2022
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
How to initialize immutable collections in Java 9?

Java 9 provides factory methods to create immutable lists, sets, and maps. It can be useful to create empty or non-empty collection objects. In Java 8 and earlier versions, we can use collection class utility methods like unmodifiableXXX to create immutable collection objects. If we need to create an immutable list then use the Collections.unmodifiableList() method.
These factory methods allow us for easy initialization of immutable collections whether they are empty or non-empty.
Initialization of immutable list:
List<Integer> immutableEmptyList = List.of();
In the above, we have initialized an empty, immutable List.
Initialization of immutable set:
Set<Integer> immutableEmptySet = Set.of();
In the above, we have initialized an empty, immutable Set.
Initialization of immutable map:
Map<Integer, Integer> immutableEmptyMap = Map.of();
In the above, we have initialized an empty, immutable Map.
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class ImmutableCollectionTest {
   public static void main(String args[]) {
      List<String> list8 = new ArrayList<String>();
      list8.add("INDIA");
      list8.add("AUSTRALIA");
      list8.add("ENGLAND");
      list8.add("NEWZEALAND");
      List<String> immutableList8 = Collections.unmodifiableList(list8);
      immutableList8.forEach(System.out::println);
      System.out.println();
      List<String> immutableList = List.of("INDIA", "AUSTRALIA", "ENGLAND", "NEWZEALAND");
      immutableList.forEach(System.out::println);
      System.out.println();
      Set<String> immutableSet = Set.of("INDIA", "AUSTRALIA", "ENGLAND", "NEWZEALAND");
      immutableSet.forEach(System.out::println);
      System.out.println();
      Map<String, String> immutableMap = Map.of("INDIA", "India", "AUSTRALIA", "Australia", "ENGLAND", "England", "NEWZEALAND", "Newzealand");
      immutableMap.forEach((key, value) -> System.out.println(key + " : " + value));
      System.out.println();
   }
}
INDIA
AUSTRALIA
ENGLAND
NEWZEALAND

INDIA
AUSTRALIA
ENGLAND
NEWZEALAND

AUSTRALIA
ENGLAND
NEWZEALAND
INDIA

AUSTRALIA : Australia
ENGLAND : England
NEWZEALAND : Newzealand
INDIA : India
Path toUri() method in Java with Examples - GeeksforGeeks

18 Jul, 2019
The toUri() method of java.nio.file.Path interface used to return a URI to represent this path. This method converts this path into an absolute URI with a scheme equal to the URI scheme that identifies the provider. The exact form of the scheme-specific part is highly provider dependent. In the scenario of the default provider, the URI is hierarchical with a path component that is absolute. The query and fragment components are undefined. Whether the authority component is defined or not is implementation-dependent. There is no guarantee that the URI may be used to construct a java.io.File. In particular, if this path represents a Universal Naming Convention (UNC) path, then the UNC server name may be encoded in the authority component of the resulting URI. In the case of the default provider, and the file exists, and it can be determined that the file is a directory, then the resulting URI will end with a slash.
Syntax:
URI toUri()

Parameters: This method accepts nothing.
Return value: This method returns the URI representing this path.
Exception: This method throws following Exceptions:
IOError– if an I/O error occurs obtaining the absolute path, or where a file system is constructed to access the contents of a file as a file system, and the URI of the enclosing file system cannot be obtained
SecurityException– In the case of the default provider, and a security manager is installed, the toAbsolutePath method throws a security exception.
Below programs illustrate toUri() method:Program 1:
// Java program to demonstrate// java.nio.file.Path.toUri() method  import java.net.URI;import java.nio.file.Path;import java.nio.file.Paths;public class GFG {    public static void main(String[] args)    {          // create an object of Path        Path path            = Paths.get("\\temp\\Spring");          // call toUri() to convert        // path in URI        URI uri = path.toUri();          // print URI        System.out.println("URI: "                           + uri);    }}
Program 2:
// Java program to demonstrate// java.nio.file.Path.toUri() method  import java.net.URI;import java.nio.file.Path;import java.nio.file.Paths;public class GFG {    public static void main(String[] args)    {          // create an object of Path        Path path            = Paths.get("D:\\eclipse\\configuration"                        + "\\org.eclipse.update\\history");          // call toUri() to convert        // path in URI        URI uri = path.toUri();          // print URI        System.out.println("URI: "                           + uri);    }}
Reference: https://docs.oracle.com/javase/10/docs/api/java/nio/file/Path.html#toUri()
Java-Functions
Java-Path
java.nio.file package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
HashMap in Java with Examples
Interfaces in Java
Object Oriented Programming (OOPs) Concept in Java
ArrayList in Java
How to iterate any Map in Java
Initialize an ArrayList in Java
Overriding in Java
Singleton Class in Java
Collections in Java
Multithreading in Java
How to subscribe to an Event in C# and can we have multiple subscribers to one Event in a C#?

Events enable a class or object to notify other classes or objects when something of interest occurs.
The class that raises the event is called the publisher and the classes that handle the event are called subscribers.
In the Event
An event can have multiple subscribers. A subscriber can handle multiple events from multiple publishers.
Events that have no subscribers are never raised.
The publisher determines when an event is raised; the subscribers determine what action is taken in response to the event.
class Program {
   static void Main() {
      var video = new MP4() { Title = "Eminem" };
      var videoEncoder = new MP4EncoderNew();
      var mailService = new MailService();
      var messageService = new MessageService();
      videoEncoder.mp4Encoded += mailService.onVideoEncoded;
      videoEncoder.mp4Encoded += messageService.onVideoEncoded;
      videoEncoder.Encode(video);
      Console.ReadKey();
   }
}
public class MP4 {
   public string Title { get; set; }
}
public class MP4Args : EventArgs {
   public MP4 mp4 { get; set; }
}
public class MP4EncoderNew {
   public EventHandler mp4Encoded;
   public void Encode(MP4 video) {
      Console.WriteLine("Encoding MP4");
      Thread.Sleep(3000);
      OnVideoEncoded(video);
   }
   protected void OnVideoEncoded(MP4 video) {
      if (mp4Encoded != null) {
         mp4Encoded(this, new MP4Args() { mp4 = video });
      }
   }
}
//Subscriber 1
public class MailService {
   public void onVideoEncoded(object source, MP4Args e) {
      Console.WriteLine("Mail Service:,Sending an email {0}", e.mp4.Title);
   }
}
//Subscriber 2
public class MessageService {
   public void onVideoEncoded(object source, MP4Args e) {
      Console.WriteLine("Message Service:,Sending an Message {0}", e.mp4.Title);
   }
}
Encoding MP4
Mail Service:,Sending an email Eminem
Message Service:,Sending an Message Eminem
How can I fill out a Python string with spaces?

To pad the string on the right with spaces or any other character you can use the str.ljust(width[, fillchar]) method. The fillchar arg is used to specify the character to fill. For example:
To pad the string on the left with spaces or any other character you can use the str.ljust(width[, fillchar]) method. The fillchar arg is used to specify the character to fill. For example:
print('Mona Lisa'.ljust(12))
print('Mona Lisa'.ljust(12,'$'))
Mona Lisa  
Mona Lisa$$$