code-rag-bench/online-tutorials huggingface dataset:
How to remove question mark from corrplot in R?

When we have NAs present in the data frame or matrix then correlation matrix contains NA values. Now if we create the correlation matrix plot using corrplot function the Output display question marks.
If we want to create the correlation matrix without question marks then we can use the na.label argument and set it to blank as shown in the below Example.
Following snippet creates a sample matrix −
M<-matrix(sample(c(NA,2,5,3),16,replace=TRUE),ncol=4)
M
The following matrix is created −
    [,1] [,2] [,3] [,4]
[1,] 3    2    5   NA
[2,] NA  NA    5    2
[3,] NA   2    5    2
[4,] 3    2   NA    2
To remove the question mark from the corrplot in R, on the above created data frame, add the following code to the above snippet −
M<-matrix(sample(c(NA,2,5,3),16,replace=TRUE),ncol=4)
M_corr<-cor(M)
M_corr
If you execute all the above given snippets as a single program, it generates the following Output −
    [,1] [,2]   [,3] [,4]
[1,]  1    NA    NA   NA
[2,] NA     1    NA   NA
[3,] NA    NA     1   NA
[4,] NA    NA    NA    1
To remove the question mark from the corrplot in R, on the above created data frame, add the following code to the above snippet −
M<-matrix(sample(c(NA,2,5,3),16,replace=TRUE),ncol=4)
M_corr<-cor(M)
corrplot(M_corr)
If you execute all the above given snippets as a single program, it generates the following Output −
To remove the question mark from the corrplot in R, on the above created data frame, add the following code to the above snippet −
M<-matrix(sample(c(NA,2,5,3),16,replace=TRUE),ncol=4)
M_corr<-cor(M)
corrplot(M_corr,na.label=" ")
If you execute all the above given snippets as a single program, it generates the following Output −
We can also replace question mark with NA as shown below −
M<-matrix(sample(c(NA,2,5,3),16,replace=TRUE),ncol=4)
M_corr<-cor(M)
corrplot(M_corr,na.label="NA")
If you execute all the above given snippets as a single program, it generates the following Output −
PHP include and require

The include (or require) statement takes all the text/code/markup that exists in the specified file and copies it into
the file that uses the include statement.
Including files is very useful when you want to include the same PHP,
HTML, or text on multiple pages of a website.
It is possible to insert the content of one PHP file into another PHP file (before the 
server executes it), with the include or require statement.
The include and require statements are identical, except upon failure:
require will produce a fatal error (E_COMPILE_ERROR) and stop the script
include will only produce a warning (E_WARNING) and the script will continue
So, if you want the execution to go on and show users the output, even if the 
include file is missing, use the include statement. Otherwise, in case of FrameWork, CMS, or a 
complex PHP application coding, always use the require statement to include a key file to the 
flow of execution. This will help avoid compromising your application's security 
and integrity, just in-case one key file is accidentally missing.
Including files saves a lot of work. This means that 
you can create a standard header, footer, or menu file for all your web pages. 
Then, when the header needs to be updated, you can only 
update the header include file.
Assume we have a standard footer file called "footer.php", that looks like this:
To include the footer file in a page, use the include statement:
Assume we have a standard menu file called "menu.php":
All pages in the Web site should use this menu file. Here is how it can be done 
(we are using a <div> element so that the menu easily can be styled with CSS later):
Assume we have a file called "vars.php", with some variables defined:
Then, if we include the "vars.php" file, the variables can be used in the calling file:
The require statement is also used to include a file into the PHP code.
However, there is one big difference between include and require; when a 
file is included with the include statement and PHP cannot find it, the script 
will continue to execute:
If we do the same example using the require statement, the 
echo statement will not be executed because the script execution dies after the 
require statement returned a fatal error:
Use require when the file is required by the application.
Use include when the file is not required and application should continue when file is not found.
Write a correct syntax to include a file named "footer.php".
<?php ;?>

We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Using post request in middleware in express

We used use() function to execute middleware’s . Example we used below will be executed for both http GET and POST method −
const http = require('http');
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.urlencoded({extended: false}));
app.use('/', (req, res,next)=>{
   next();
});
app.use('/add-username', (req, res,next)=>{
   res.send('<form action="/post-username" method="POST"> <input type="text" name="username"> <button    type="submit"> Send </button> </form>');
});
app.use('/post-username', (req, res, next)=>{
   console.log('data: ', req.body.username);
   res.redirect('/');
});
app.use('/', (req, res,next)=>{
   res.send('<h1> first midleware: Hello Tutorials Point </h1>');
});
const server = http.createServer(app);
server.listen(3000);
How to restrict middleware only for GET or only for POST http method etc.
We have http methods like get() and post() etc function similar to use() function.
app.post('/post-username', (req, res, next)=>{
   console.log('data: ', req.body.username); res.redirect('/');
});
In above code snippet we used post() function. It will restrict a http request to only post types for url path ‘/post-username’
get() function −
app.get('/add-username', (req, res,next)=>{
   res.send('<form action="/post-username" method="POST"> <input type="text" name="username"> <button    type="submit"> Send</button> </form>');
});
Similar to get() and post(), we have delete(), patch, put() functions for respective http requests.
Complete App.js with get() and post() −
const http = require('http');
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.urlencoded({extended: false}));
app.use('/', (req, res,next)=>{
   next();
});
app.get('/add-username', (req, res,next)=>{
   res.send('<form action="/post-username" method="POST"> <input type="text" name="username"> <button    type="submit"> Send </button> </form>');
});
app.post('/post-username', (req, res, next)=>{
   console.log('data: ', req.body.username);
   res.redirect('/'); });
   app.use('/', (req, res,next)=>{
   res.send('<h1> first midleware: Hello Tutorials Point </h1>');
});
const server = http.createServer(app);
server.listen(3000);
Execute : npm start
Browser output −
localhost:300/add-username
localhost:3000/post-username
Write an algorithm that takes an array and moves all of the zeros to the end JavaScript

We have to write a function that takes in an array and moves all the zeroes present in that array
to the end of the array without using any extra space. We will use the Array.prototype.forEach()
method here along with Array.prototype.splice() and Array.prototype.push().
The code for the function will be −
const arr = [34, 6, 76, 0, 0, 343, 90, 0, 32, 0, 34, 21, 54];
const moveZero = (arr) => {
   for(ind = 0; ind < arr.length; ind++){
      const el = arr[ind];
      if(el === 0){
         arr.push(arr.splice(ind, 1)[0]);
         ind--;
      };
   }
};
moveZero(arr);
console.log(arr);
The output in the console will be −
[34, 6, 76, 343, 90, 32, 34, 21, 54, 0, 0, 0, 0]
C# | Add element to HashSet - GeeksforGeeks

01 Feb, 2019
A HashSet is an unordered collection of the unique elements. It comes under System.Collections.Generic namespace. It is used in a situation where we want to prevent duplicates from being inserted in the collection. As far as performance is concerned, it is better in comparison to the list. Elements can be added to HashSet using HashSet.Add(T) Method.
Syntax:
mySet.Add(T item);
Here mySet is the name of the HashSet.
Parameter:
item: The element to add to the set.
Return Type: This method returns true if the element is added to the HashSet object. If the element is already present then it returns false.
Below given are some examples to understand the implementation in a better way:
Example 1:
// C# code to add element to HashSetusing System;using System.Collections.Generic;  class GFG {      // Driver code    public static void Main()    {          // Creating a HashSet of odd numbers        HashSet<int> odd = new HashSet<int>();          // Inserting elements in HashSet        for (int i = 0; i < 5; i++) {            odd.Add(2 * i + 1);        }          // Displaying the elements in the HashSet        foreach(int i in odd)        {            Console.WriteLine(i);        }    }}
1
3
5
7
9

Example 2:
// C# code to add element to HashSetusing System;using System.Collections.Generic;  class GFG {      // Driver code    public static void Main()    {          // Creating a HashSet of strings        HashSet<string> mySet = new HashSet<string>();          // Inserting elements in HashSet        mySet.Add("Geeks");        mySet.Add("GeeksforGeeks");        mySet.Add("GeeksClasses");        mySet.Add("GeeksQuiz");          // Displaying the elements in the HashSet        foreach(string i in mySet)        {            Console.WriteLine(i);        }    }}
Geeks
GeeksforGeeks
GeeksClasses
GeeksQuiz

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1.add?view=netframework-4.7.2
CSharp-Generic-HashSet
CSharp-Generic-Namespace
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Delegates
Difference between Ref and Out keywords in C#
Destructors in C#
C# | Constructors
Extension Method in C#
C# | String.IndexOf( ) Method | Set - 1
Introduction to .NET Framework
C# | Abstract Classes
C# | Class and Object
C# | Data Types
Node.js crypto.randomUUID( ) Function - GeeksforGeeks

22 Apr, 2021
The crypto.randomUUID() is  an inbuilt application programming interface of class Crypto within crypto module which is used to generate a random RFC 4122 Version 4 UUID.
Syntax:
const crypto.randomUUID([options])
Parameters: This function takes the disableEntropyCache as a parameter
Return Value: This function returns a random RFC 4122 Version 4 UUID.
Example 1:
index.js
<script>  // Node.js program to demonstrate the    // crypto.randomUUID() api    // Importing crypto module  const crypto = require('crypto')    // getting a random RFC 4122 Version 4 UUID  // by using randomUUID() method  const val = crypto.randomUUID({disableEntropyCache : true});    // display the result  console.log("RFC 4122 Version 4 UUID : " + val)</script>
Run the index.js file using the following command.
node index.js
Output:
RFC 4122 Version 4 UUID : 88368f2a-d5db-47d8-a05f-534fab0a0045
Example 2:
index.js
<script>  // Node.js program to demonstrate the    // crypto.randomUUID() api    // Importing crypto module  const crypto = require('crypto')    // getting a random RFC 4122 Version 4 UUID  // by using randomUUID() method  console.log(crypto.randomUUID())</script>
Run the index.js file using the following command.
node index.js
Output:
e2d3286f-2d8f-471a-bacb-1e5d28d8727e
Reference: https://nodejs.org/dist/latest-v15.x/docs/api/crypto.html#crypto_crypto_randomuuid_options
Node.js-crypto-module
NodeJS-function
Picked
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Express.js express.Router() Function
JWT Authentication with Node.js
Node.js Event Loop
Mongoose Populate() Method
Mongoose find() Function
Roadmap to Become a Web Developer in 2022
How to fetch data from an API in ReactJS ?
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
Can we define multiple methods in a class with the same name in Java?

Yes, we can define multiple methods in a class with the same name but with different types of parameters. Which method is to get invoked will depend upon the parameters passed.
In the below example, we have defined three display methods with the same name but with different parameters. Depending on the parameters, the appropriate method will be called.
public class MethodWthSameNameTest {
   public void display() { // method with no parameters
      System.out.println("display() method with no parameter");
   }
   public void display(String name) { // method with a single parameter
      System.out.println("display() method with a single parameter");
   }
   public void display(String firstName, String lastName) { // method with multiple parameters
      System.out.println("display() method with multiple parameters");
   }
   public static void main(String args[]) {
      MethodWthSameNameTest test = new MethodWthSameNameTest();
      test.display();
      test.display("raja");
      test.display("raja", "ramesh");
   }
}
display() method with no parameter
display() method with a single parameter
display() method with multiple parameters
SUBDATE() function in MySQL - GeeksforGeeks

27 Nov, 2020
SUBDATE() function in MySQL is used to subtracts a time value (as interval) from a given date.
Syntax :
SUBDATE(date, INTERVAL expr unit)

Parameter : This function accepts three parameters as given below :
date : First specified date.
expr : The value of the time/date interval to subtract.
unit : The type of interval. It Can be one of the following values :
MICROSECOND
SECOND
MINUTE
HOUR
DAY
WEEK
MONTH
QUARTER
YEAR
SECOND_MICROSECOND
MINUTE_MICROSECOND
MINUTE_SECOND
HOUR_MICROSECOND
HOUR_SECOND
HOUR_MINUTE
DAY_MICROSECOND
DAY_SECOND
DAY_MINUTE
DAY_HOUR
YEAR_MONTH
Returns :It returns the date after subtracting a time/date interval.
Example-1 :Subtracting a interval value from a date and returning the date where date is specified in the format of YYYY-MM-DD and Interval in Days :
SELECT SUBDATE("2020-11-25", INTERVAL 30 DAY) 
AS RESULTANTDATE;

Output :
Example-2 :Subtracting a interval value from a date and returning the date where date is specified in the format of YYYY-MM-DD and Interval in Negative months :
SELECT SUBDATE("2020-11-25", INTERVAL -02 MONTH) 
AS RESULTANTDATE;

Output :
Example-3 :Subtracting a interval value from a date and returning the date where date is specified in the format of YYYY-MM-DD and Interval in HOUR.
SELECT SUBDATE("2020-11-25 04:12:06",  INTERVAL 09 HOUR) 
AS RESULTANTDATE;

Output :
Example-4 :Subtracting a interval value from a date and returning the date where date is specified in the format of YYYY-MM-DD and Interval in QUARTER.
SELECT SUBDATE("2020-11-25 04:12:06",  INTERVAL 09 QUARTER) 
AS RESULTANTDATE;

Output :
Example 5 :Subtracting a interval value from a date and returning the date where date is specified in the format of YYYY-MM-DD and Interval in -YEAR.
SELECT SUBDATE("2020-11-25 12:19:36",  INTERVAL -01 YEAR) 
AS RESULTANTDATE;

Output :
DBMS-SQL
mysql
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Update Multiple Columns in Single Update Statement in SQL?
What is Temporary Table in SQL?
SQL Query for Matching Multiple Values in the Same Column
SQL using Python
SQL Query to Insert Multiple Rows
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL | Subquery
SQL | SEQUENCES
SQL | DROP, TRUNCATE
SQL Query to Convert VARCHAR to INT
How to find a Computer product serial number using PowerShell?

Generally, Product serial numbers are available at the back of the laptop on the company sticker and we can use the Third-party or manufacturer software to find the Product details. The product serial number can also be found using the BIOS utility or command. We can either use the BIOS command for the cmd or using PowerShell.
To get the product serial number using PowerShell, we can use WMI or CIMInstance command. For example,
Get-CimInstance Win32_BIOS
We can also use the WMI command. For example,
Get-WmiObject Win32_BIOS
SMBIOSBIOSVersion : F.13
Manufacturer      : AMI
Name              : F.13
SerialNumber      : HJJE244L
Version           : HPQOEM – 1072332
You can see the serial number in the above output. To retrieve only the serial number,
Get-WmiObject Win32_BIOS | Select SerialNumber
To find the product serial number using cmd we can use the below command.
wmic bios get serialnumber
C program to rotate the bits for a given number

Consider the factors given below to write a C program to rotate the bits for a given number.
Rotating the bit from left to right or right to left.
Rotating the bit from left to right or right to left.
In left rotation, the bits are shifted from left to right.
In left rotation, the bits are shifted from left to right.
In right rotation, the bits are shifted from right to left.
In right rotation, the bits are shifted from right to left.
Take a number and try to rotate either left or right based on user program.
Take a number and try to rotate either left or right based on user program.
User has to enter the number rotation at run time along with a number.
User has to enter the number rotation at run time along with a number.
Following is the C program to apply left rotation for a given number.
 Live Demo
#include<stdio.h>
#include<stdlib.h>
int main(){
   int number, rotate, Msb, size;
   printf("Enter any number:");
   scanf("%d",&number);
   printf("Enter number of rotations:\n");
   scanf("%d",&rotate);
   size = sizeof(int) * 8;
   rotate %= size;
   while(rotate--){
      Msb = (number >> size) & 1;
      number = (number << 1) | Msb;
   }
   printf("After Left rotation the value is = %d\n",number);
   return 0;
}
When the above program is executed, it produces the following result −
Enter any number:12
Enter number of rotations:
2
After Left rotation the value is = 48
Given below is the C program to apply right rotation for a given number.
 Live Demo
#include<stdio.h>
#include<stdlib.h>
int main(){
   int number,rotate, Lsb, size;
   printf("Enter any number:");
   scanf("%d",&number);
   printf("Enter number of rotations:\n");
   scanf("%d",&rotate);
   size = sizeof(int) * 8;
   rotate %= size;
   while(rotate--){
      Lsb = number & 1;
      number = (number >> 1) &(~(1<<size));
      number=number|(Lsb<<size);
   }
   printf("After right rotation the value is = %d\n",number);
   return 0;
}
When the above program is executed, it produces the following result −
Enter any number:18
Enter number of rotations:
2
After right rotation the value is = 4
How to alter multiple columns in a single statement in MySQL?

Alter multiple columns in a single statement with the help of CHANGE command. The syntax is as follows −
alter table yourTableName
change yourOldColumnName1 yourNewColumnName1 dataType,
yourOldColumnName2 yourNewColumnName2 dataType,
.
.
.
N
To understand the above syntax, let us create a table. The query to create a table is as follows −
mysql> create table AlterMultipleColumns
   −> (
   −> Id int,
   −> Name varchar(200)
   −> );
Query OK, 0 rows affected (0.93 sec)
Now we have two columns with Id and Name. We will alter both the columns.
Here, we will alter Id with StudentId and Name with StudentName. The query to alter multiple columns is as follows −
mysql> alter table AlterMultipleColumns
   −> change Id StudentId varchar(10),
   −> change Name StudentName varchar(100);
Query OK, 0 rows affected (1.82 sec)
Records: 0 Duplicates: 0 Warnings: 0
Now you can check the columns have been altered or not with help of desc command. The query is as follows −
mysql> desc AlterMultipleColumns;
The following is the output −
+-------------+--------------+------+-----+---------+-------+
| Field       | Type         | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| StudentId   | varchar(10)  | YES  |     | NULL    |       |
| StudentName | varchar(100) | YES  |     | NULL    |       |
+-------------+--------------+------+-----+---------+-------+
2 rows in set (0.06 sec)
How scriptblock works in PowerShell?

Scriptblock is a set of commands which can be executed together when they are invoked. In PowerShell, generally, we write individual commands. Scriptblock can be written with two curly brackets.
$sb = {Get-Process powershell; Get-Service W32Time}
Here we have written two commands under scriptblock. If you directly run this command, scriptblock treats them as a string.
PS C:\> $sb
Get-Process powershell; Get-Service W32Time
To run the commands inside the scritblock, use Invoke-Command with the -Scriptblock parameter.
Invoke-Command -ScriptBlock $sb
Handles NPM(K)    PM(K)    WS(K)    CPU(s)    Id    SI    ProcessName
------- ------    -----    -----    ------    --    --    -----------
529       44    240240    256164    36.02    7668    1    powershell
Status : Running
Name   : W32Time
DisplayName : Windows Time
To run the commands on the remote computers, use -ComputerName parameter.
Invoke-Command -ComputerName Test1-Win2k16,Test1-Win2k12 -ScriptBlock $sb
PS C:\Scripts\AppdInstallation_Remote> Invoke-Command -ComputerName Test1-
Win2k16,Test1-Win2k12 -ScriptBlock $sb
Handles    NPM(K)    PM(K)    WS(K)    CPU(s)    Id    SI P   rocessName
PSComputerName
------- -   -----    -----    -----    ------    --    --    -----------
--------------
434          29     46200    47564    0.70     3228   1    powershell
Test1-Win2k12
Status          : Running
Name            : Spooler
DisplayName     : Print Spooler
PSComputerName  : Test1-Win2k12
583    29    57892    64636    0.59    4524    1    powershell    Test1-Win2k16
Status         : Stopped
Name           : Spooler
DisplayName    : Print Spooler
PSComputerName : Test1-Win2k16
You can also pass the parameters inside the scriptblock using -ArgumentList parameter in InvokeCommand cmdlet. Declaration of param will be the same as the function in PowerShell.
Invoke-Command -ComputerName Test1-Win2k16,Test1-Win2k12 -ScriptBlock $sb
$sb = {
   param($process,$service)
   Get-Process -Name $process
   Get-Service -Name $service
}
Invoke-Command -ScriptBlock $sb -ArgumentList "PowerShell","W32Time"
NPM(K)    PM(M)    WS(M)    CPU(s)    Id    SI    ProcessName
------    -----    -----    ------    --    --    -----------
43       234.39    22.84    43.61    7668    1    powershell
Status       : Running
Name         : W32Time
DisplayName  : Windows Time
How to create an ordered list with list items numbered with uppercase letters in HTML?

To create ordered list in HTML, use the <ol> tag. Ordered list starts with the <ol> tag. The list item starts with the <li> tag and will be marked as numbers, lowercase letters uppercase letters, roman letters, etc. The default numbers for list items.
For creating an ordered list with uppercase letters, use the <ol> tag attribute type. This attribute will assign an uppercase letter i.e. <ol type = “A”> to create ordered list numbered with uppercase letters.
You can try to run the following code to create an ordered list of list items numbered with uppercase letters in HTML −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>World Cup Teams</title>
   </head>
   <body>
      <h1>List of teams for World Cup</h1>
      <ol type = "A">
         <li>India</li>
         <li>Australia</li>
         <li>South Africa</li>
         <li>New Zealand</li>
         <li>Pakistan</li>
         <li>Srilanka</li>
         <li>West Indies</li>
         <li>Bangladesh</li>
      </ol>
   </body>
 </html>
Difference between Hash Join and Sort Merge Join

29 Jul, 2020
1. Hash Join :It is also known as “go-to-guy” in case of join operators. This means that in case no other join is preferred (maybe due to no sorting or indexing etc), then, Hash join is used. Hash join is best algorithm when large, unsorted, and non-indexed data (residing in tables) is to be joined. Hash join algorithm consists of probe phase and build phase.
In the case of 2 relations named R and S, algorithm for Hash join would be as follows :
Hash records of R, one by one, using A values
(Use same M buckets and same hash function h)
Hash matching pair of records into same bucket
End
2. Sort Merge Join :Sort Merge Join as name suggests, has 2 phases in join algorithm, namely, sort phase and merge phase. Merge algorithm is fastest join algorithm. This is reason that Sort Merge Join is fastest in case of sorted relations. Assuming that 2 sorted relations R and S need to be merged, algorithm is as follows :
If R is sorted on A, S is sorted on B do
Merge R and S to get join result
End
Difference between Hash Join and Sort Merge Join :
DBMS
Difference Between
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
CTE in SQL
Difference between Clustered and Non-clustered index
Introduction of DBMS (Database Management System) | Set 1
SQL Trigger | Student Database
Introduction of B-Tree
Class method vs Static method in Python
Difference between BFS and DFS
Difference between var, let and const keywords in JavaScript
Difference Between Method Overloading and Method Overriding in Java
Differences between JDK, JRE and JVM
PyCairo – Fill Solid Colors

23 Jan, 2022
In this article we will learn how  to fill colors in a closed pattern using PyCairo in python. Pycairo is a Python module providing bindings for the cairo graphics library. This library is used for creating SVG i.e vector files in python. The easiest and quickest way to open an SVG file to view it (read only) is with a modern web browser like Chrome, Firefox, Edge, or Internet Explorer—nearly all of them should provide some sort of rendering support for the SVG format.
Here we will use the fill ( ) method. 
A color is an object representing a combination of Red, Green, and Blue (RGB) intensity values. PyCairo valid RGB values are in the range 0 to 1.
Steps of Implementation :
Import the PyCairo module.Create a SVG surface object and add context to it.Setting color of the context & line widthCreating a rectangular shapeThe source is used to fill the interior of a rectangle by calling the fill ( ) method.
Import the PyCairo module.
Create a SVG surface object and add context to it.
Setting color of the context & line width
Creating a rectangular shape
The source is used to fill the interior of a rectangle by calling the fill ( ) method.
Example :
Python
# importing pycairoimport cairo # creating a SVG surface# here geek95 is file name & 700, 700 is dimensionwith cairo.SVGSurface("geek95.svg", 700, 700) as surface:     # creating a cairo context object for SVG surface    # using Context method    context = cairo.Context(surface)     # setting color of the context    context.set_source_rgb(0.2, 0.23, 0.9)    # creating a rectangle    context.rectangle(10, 15, 90, 60)     # Fill the color inside the rectangle    context.fill()     # setting color of the context    context.set_source_rgb(0.9, 0.1, 0.1)    # creating a rectangle    context.rectangle(130, 15, 90, 60)     # Fill the color inside the rectangle    context.fill()     # setting color of the context    context.set_source_rgb(0.4, 0.9, 0.4)    # creating a rectangle    context.rectangle(250, 15, 90, 60)     # Fill the color inside the rectangle    context.fill()     # printing message when file is saved    print("File Saved")
Output :
Note: The set_source_rgb ( ) method sets the source to an opaque color. The parameters are the Red, Green, Blue intensity values. 
saurabh1990aror
Python-PyCairo
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Iterate over a list in Python
Matplotlib.axis.Axis.set_major_formatter() function in Python

03 Jun, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. It is an amazing visualization library in Python for 2D plots of arrays and used for working with the broader SciPy stack. 
The Axis.set_major_formatter() function in axis module of matplotlib library is used to set the formatter of the major ticker. 
Syntax: Axis.set_major_formatter(self, formatter)
Parameters: This method accepts the following parameters. 
formatter: This parameter is the Formatter.
Return value: This method does not returns any value. 
Below examples illustrate the matplotlib.axis.Axis.set_major_formatter() function in matplotlib.axis:Example 1: 
Python3
# Implementation of matplotlib function import numpy as npfrom matplotlib.axis import Axis  import matplotlib.pyplot as pltimport matplotlib.ticker as ticker     np.random.seed(19680801)  fig, ax = plt.subplots()ax.plot(100*np.random.rand(20))  formatter = ticker.FormatStrFormatter('?%1.2f')Axis.set_major_formatter(ax.yaxis, formatter)  for tick in ax.yaxis.get_major_ticks():    tick.label1.set_color('green')  plt.title("Matplotlib.axis.Axis.set_major_formatter()\n\Function Example", fontsize = 12, fontweight ='bold')   plt.show()
Output:  
Example 2: 
Python3
# Implementation of matplotlib function from matplotlib.axis import Axisimport datetime import matplotlib.pyplot as plt from matplotlib.dates import DayLocator, HourLocator, DateFormatter, drange import numpy as np       date1 = datetime.datetime(2020, 4, 2) date2 = datetime.datetime(2020, 4, 6) delta = datetime.timedelta(hours = 6) dates = drange(date1, date2, delta)       y = np.arange(len(dates))       fig, ax = plt.subplots() ax.plot_date(dates, y ** 2, 'g')       ax.set_xlim(dates[0], dates[-1])       ax.xaxis.set_major_locator(DayLocator()) ax.xaxis.set_minor_locator(HourLocator(range(0, 25, 6))) ax.xaxis.set_major_formatter(plt.NullFormatter())       ax.fmt_xdata = DateFormatter('% Y-% m-% d % H:% M:% S') fig.autofmt_xdate()    plt.title("Matplotlib.axis.Axis.set_major_formatter()\n\Function Example", fontsize = 12, fontweight ='bold')   plt.show()
Output:  
 
Matplotlib-Axis Class
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
Matplotlib.pyplot.rc() in Python

19 Apr, 2020
Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack.
matplotlib.pyplot.rc() function is used to the rc params. Grouping in rc is done through the ‘group'(eg, for lines). For lines in axes the group is linewidth. The group for axes is facecolor and so on. A list or tuple can also act as a group name(eg, xtick, ytick). Kwargs act as a name value pair which broadly is a dictionary, eg:
Syntax:
rc(‘lines’, linewidth=3, color=’g’)
It sets the current rc params and is same as
rcParams[‘lines.linewidth’] = 3rcParams[‘lines.color’] = ‘g’
To save typing for interactive users the following aliases are available:
Therefore once could abbreviate the above rc commands as follows
rc(‘lines’, lw=3, c=’g’)
Note: One can use the pythons kwargs dictionary to store dictionaries of its default parameters. For example,
font = {‘family’ : ‘monospace’,‘weight’ : ‘italic’,‘size’ : ‘medium’}# pass in the font dict as kwargsrc(‘font’, **font)
This helps in easily switching among different configurations. you can also use matplotlib.style.use(‘default’) or rcdefaults() to restore back the rc params after change.
Example 1:
from cycler import cyclerimport numpy as npimport matplotlib.pyplot as plt    # setting up a custom cyclersample_cycler = (cycler(color =['r', 'g',                                 'b', 'y']) +                 cycler(lw =[1, 2, 3, 4]))  # using the rc functionplt.rc('lines', linewidth = 4)plt.rc('axes', prop_cycle = sample_cycler)  A = np.linspace(0, 2 * np.pi, 50)line_offsets = np.linspace(0, 2 * np.pi, 4,                            endpoint = False)  B = np.transpose([np.sin(A + phi) for phi in line_offsets])  figure, (axes0, axes1) = plt.subplots(nrows = 2)axes0.plot(B)axes0.set_title('Set default color cycle to 1st plot')  axes1.set_prop_cycle(sample_cycler)axes1.plot(B)axes1.set_title('Set axes color cycle to 2nd plot')  # Adding space between the two plots.figure.subplots_adjust(hspace = 0.4)plt.show()
Output:
Example 2:
import matplotlib.pyplot as plt    plt.subplot(332)plt.plot([1, 2, 3, 4])  # setting  the axes attributes # before the call to subplotplt.rc('font', weight ='bold')plt.rc('xtick.major', size = 5, pad = 7)plt.rc('xtick', labelsize = 15)  # setting aliases for color, linestyle # and linewidth; gray, solid, thickplt.rc('grid', c ='0.3', ls ='-', lw = 4)plt.rc('lines', lw = 2, color ='g')plt.subplot(312)  plt.plot([1, 2, 3, 4])plt.grid(True)  # set changes to default valueplt.rcdefaults()plt.subplot(313)plt.plot([1, 2, 3, 4])plt.grid(True)plt.show()
Output:
Python-matplotlib
Python
Write From Home
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JavaScript | uneval() with Examples

31 May, 2022
The uneval() is an inbuilt function in JavaScript which is used to create a string representation of the source code of an Object. 
Syntax:
uneval(object)
Note: This function has been DEPRECATED and is no longer recommended.
Parameters: It accepts an object which may be a JavaScript expression or statement. 
Return Value: It returns a string which represents the source code of the given Object.JavaScript code to show the working of this function:
Code #1: If the number is passed to the function uneval() then the function will return a string with the value of the object passed. 
javascript
<script>   var obj = 2;  document.write(eval(obj)); </script>
Output:
2
Code #2: If the char is passed to the function uneval() then the function will return a string with the value of the object passed. 
javascript
<script>   var obj = '2';  document.write(uneval(obj)); </script>
Output:
"2"
Code #3: If the number is passed to the function uneval() then the function will return a string with the value of the object passed. 
javascript
<script>   var obj = uneval(function func() { return 'Geeksforgeeks'; });  var func1 = eval(obj);  document.write(func1()); </script>
Output:
GeeksforGeeks
Difference between eval() and uneval() functions: The uneval() function returns the source of a given object whereas the eval() function evaluates that source code in a different memory area. 
Note: Above codes will run only in Firefox web browser.
kumargaurav97520
javascript-functions
JavaScript
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
Roadmap to Learn JavaScript For Beginners
JavaScript | Promises
How to filter object array based on attributes?
Lodash _.debounce() Method
JavaScript String includes() Method
JavaScript | fetch() Method
Lodash _.groupBy() Method
Get the stack size and set the stack size of thread attribute in C

22 Sep, 2017
Prerequisite : Multithreading
Syntax :
// to get size of stackint pthread_attr_getstacksize(const pthread_attr_t* restrict attr,                                          size_t* restrict stacksize);  // to set size of stackint pthread_attr_setstacksize(pthread_attr_t* attr, size_t stacksize);
.pthread_attr_getstacksize() :It is use for get threads stack size. The stacksize attribute gives the minimum stack size allocated to threads stack. When successfully run then it gives 0 otherwise gives any value.
First argument – It takes pthread attribute.Second argument – It takes a variable and give the size of the thread attribute.
pthread_attr_setstacksize() :It is use for set new threads stack size. The stacksize attribute gives the minimum stack size allocated to threads stack. When successfully run then it gives 0 otherwise if error gives any value.
First argument – It takes pthread attribute.Second argument – It takes the size of new stack (In bytes)
#include <stdio.h>#include <stdlib.h>#include <pthread.h>  int main(){      // for takes the size of threads stack    size_t stksize;      // attribute declaration    pthread_attr_t atr;      // it gets the threads stack size and give     // value in stksize variable    pthread_attr_getstacksize(&atr, &stksize);      // print the current threads stack size    printf("Current stack size - > %d\n", stksize);      // then set the new threads stack size    pthread_attr_setstacksize(&atr, 320000034);    pthread_attr_getstacksize(&atr, &stksize);      // print the new stack size    printf("New stack size-> %d\n", stksize);    return 0;}
Output :
Current stack size - > 4196464
New stack size-> 320000034
 
For compile use gcc program_name.c -lpthreadThis article is contributed by Devanshu Agarwal. 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.
C-Library
system-programming
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Unordered Sets in C++ Standard Template Library
Operators in C / C++
Exception Handling in C++
What is the purpose of a function prototype?
Sorting Vector of Pairs in C++ | Set 1 (Sort by first and second)
Storage Classes in C
'this' pointer in C++
Ways to copy a vector in C++
TCP Server-Client implementation in C
Smart Pointers in C++ and How to Use Them
How to plot matrix columns as lines in base R?

To plot matrix columns as lines in base R, we can use matplot function but we need to read the matrix as a data frame using as.data.frame function and for creating lines the type argument will be used. For example, if we have a matrix called M then the columns of M can be plotted as lines using the command matplot(as.data.frame(M),type="l").
Consider the below data frame −
 Live Demo
M<-matrix(rpois(100,10),nrow=20)
M
    [,1] [,2] [,3] [,4] [,5]
[1,] 13    5    5   11   11
[2,] 10   18    8    6    5
[3,] 12    8    9    9   10
[4,]  8    5    8    8    9
[5,] 15    7   15   15   10
[6,]  9    9    6   11    8
[7,]  9   18   12    9   14
[8,]  6   17    9    7    8
[9,] 14   15   13    8    9
[10,] 5    6   10   16    9
[11,] 6   10   11    9   12
[12,] 4    9    4    8   18
[13,] 15  11   10    7    7
[14,]  7   8    6    9    9
[15,]  9   7    6   14    9
[16,]  7   7   10   11   10
[17,]  6   9    3    7    8
[18,] 11  12    7    8    9
[19,]  9  12   12    7   10
[20,]  6  11    8    8   10
Creating a plot of columns of matrix M with lines −
matplot(as.data.frame(M),type="l")
Note : Find common elements in three sorted arrays by dictionary intersection

13 May, 2022
Given three arrays sorted in non-decreasing order, print all common elements in these arrays.
Examples:
Input:  ar1 = [1, 5, 10, 20, 40, 80]
        ar2 = [6, 7, 20, 80, 100]
        ar3 = [3, 4, 15, 20, 30, 70, 80, 120]
Output: [80, 20]

Input:  ar1 = [1, 5, 5]
        ar2 = [3, 4, 5, 5, 10]
        ar3 = [5, 5, 10, 20]
Output: [5, 5]

We have existing solution for this problem please refer Find common elements in three sorted arrays link. We can solve this problem quickly in python using intersection of dictionaries. Approach is simple,
First convert all three lists into dictionaries having elements as keys and their frequencies as value, using Counter() method.Now perform intersection operation for three dictionaries, this will result us dictionary having common elements among three array list with their frequencies.
First convert all three lists into dictionaries having elements as keys and their frequencies as value, using Counter() method.
Now perform intersection operation for three dictionaries, this will result us dictionary having common elements among three array list with their frequencies.
# Function to find common elements in three# sorted arraysfrom collections import Counter  def commonElement(ar1,ar2,ar3):     # first convert lists into dictionary     ar1 = Counter(ar1)     ar2 = Counter(ar2)     ar3 = Counter(ar3)          # perform intersection operation     resultDict = dict(ar1.items() & ar2.items() & ar3.items())     common = []           # iterate through resultant dictionary     # and collect common elements     for (key,val) in resultDict.items():          for i in range(0,val):               common.append(key)       print(common)  # Driver programif __name__ == "__main__":    ar1 = [1, 5, 10, 20, 40, 80]    ar2 = [6, 7, 20, 80, 100]    ar3 = [3, 4, 15, 20, 30, 70, 80, 120]    commonElement(ar1,ar2,ar3)
Output:
[80, 20]

Python dictionary-programs
python-dict
Python
python-dict
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Data Structures | Linked List | Question 6

03 Feb, 2013
What is the output of following function for start pointing to first node of following linked list?
1->2->3->4->5->6
void fun(struct node* start){  if(start == NULL)    return;  printf("%d  ", start->data);      if(start->next != NULL )    fun(start->next->next);  printf("%d  ", start->data);}
(A) 1 4 6 6 4 1(B) 1 3 5 1 3 5(C) 1 2 3 5(D) 1 3 5 5 3 1Answer: (D)Explanation: fun() prints alternate nodes of the given Linked List, first from head to end, and then from end to head. If Linked List has even number of nodes, then skips the last node.
Data Structures
Data Structures-Linked List
Linked Lists
Data Structures
Data Structures
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Year isLeap() method in Java with Examples

27 Nov, 2018
The isLeap() method of Year class in Java is used to check if this Year object is a leap year or not according to the proleptic calendar system rules.
A year is a leap year if it has 366 days in it.
According to the proleptic calendar system rules, a year is a Leap year if:
If it is divisible by 4.
It is not divisible by 100 but it can be divisible by 400.
Syntax:
public boolean isLeap()

Parameter: This method does not accepts any parameter.
Return Value: It returns a boolean True value if this Year object’s value is a leap year according to the proleptic calendar system rules, otherwise it returns False.
Below programs illustrate the isLeap() method of Year in Java:
Program 1:
// Program to illustrate the isLeap() method  import java.util.*;import java.time.*;  public class GfG {    public static void main(String[] args)    {        // Create first Year object        Year firstYear = Year.of(2016);          // Check if this year object's value is        // a leap year or not        System.out.println(firstYear.isLeap());    }}
true

Program 2:
// Program to illustrate the isLeap() method  import java.util.*;import java.time.*;  public class GfG {    public static void main(String[] args)    {        // Create first Year object        Year firstYear = Year.of(1990);          // Check if this year object's value is        // a leap year or not        System.out.println(firstYear.isLeap());    }}
false

Reference: https://docs.oracle.com/javase/8/docs/api/java/time/Year.html#isLeap–
Java-Functions
Java-time package
Java-Year
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Hello World in Ruby

03 Oct, 2019
Ruby is a dynamic, reflective, object-oriented, general-purpose programming language. Hello World the program is the most basic and first program when we start a new programming language. This simply prints Hello World on the screen. Below is the program to write hello world”.
We can use various online IDE. which can be used to run Ruby programs without installing.
puts "Hello World"
Output :
Hello World
Above code will run on online IDE. Here, puts keyword is used to print any thing on the screen.
Using Command-Line Firstly, open a text editor Notepad or Notepad++. write the code in the text editor and save the file with (.rb) extension. open the command prompt follow step by step process on our system.
To run the hello.rb Ruby script, run the command ruby hello.rb it will print the output.
Using Command-Line write ruby -v on command line window to show ruby version. Below is the image to better understand.To start the IRB prompt, open your command-line and run the irb command. after this we can write the ruby code and it will run on command line.In above image we use puts keyword to print the output and it returned nil.
Ruby-Basics
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Make a Custom Array of Hashes in Ruby?
Include v/s Extend in Ruby
Global Variable in Ruby
Ruby | Data Types
Ruby | Enumerator each_with_index function
Ruby | Array select() function
Ruby | Hash delete() function
Ruby | Case Statement
Ruby | String capitalize() Method
Ruby | String gsub! Method
Performance analysis of Row major and Column major order of iterating arrays in C

31 May, 2022
In computing, row-major order and column-major order are methods for storing multidimensional arrays in linear storage such as random access memory.The two mentioned ways differ from each other with respect to the order in which elements are stored contiguously in the memory. The elements in row-major order are arranged consecutively along the row and that in the column-major order are arranged consecutively along the column. While the terms allude to the rows and columns of a two-dimensional array, i.e. a matrix, the orders can be generalized to arrays of any dimension by noting that the terms row-major and column-major are equivalent to lexicographic and lexicographic orders, respectively.In C (and many other languages like C++, Java etc), 2-D arrays are stored in row-major order.(though Pascal and Fortran follows column major order)
This program DOES NOT illustrates that row major order storing of arrays in C is more efficient than column-major order.
It only shows that in C language, 2-D arrays are stored in row major order and thus iterating its elements in a row major order is more efficient.
In languages like Pascal and Fortran, iterating by column major order will be more efficient because 2-D arrays are stored in column major order there.
The reason for this is explained properly here https://cs.stackexchange.com/questions/71985/row-major-vs-column-major-order-2d-arrays-access-in-programming-languages.  
C
#include <stdio.h>#include <time.h>int m[999][999];//Taking both dimensions same so that while running the loops,//number of operations (comparisons, iterations, initializations)//are exactly the same. Refer this for more// https://www.geeksforgeeks.org/a-nested-loop-puzzle/ void main() {    int i, j;    clock_t start, stop;    double d = 0.0;     start = clock();    for (i = 0; i < 999; i++)        for (j = 0; j < 999; j++)            m[i][j] = m[i][j] + (m[i][j] * m[i][j]);     stop = clock();    d = (double)(stop - start) / CLOCKS_PER_SEC;    printf("The run-time of row major order is %lf\n", d);     start = clock();    for (j = 0; j < 999; j++)        for (i = 0; i < 999; i++)            m[i][j] = m[i][j] + (m[i][j] * m[i][j]);     stop = clock();    d = (double)(stop - start) / CLOCKS_PER_SEC;    printf("The run-time of column major order is %lf", d);}
The run-time of row major order is 0.067300
The run-time of column major order is 0.136622
 
Time Complexity: O(999*999), as we are using nested loops to traverse 999*999 times.
Auxiliary Space: O(999*999), as we are  using extra space for matrix.
KshitizSh
rohanthakurarmy
rohitsingh57
Arrays
C Programs
Matrix
Arrays
Matrix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.