code-rag-bench/online-tutorials huggingface dataset:
Set max_size() function in C++ STL

In this article we are going to discuss the set::max_size() in C++ STL, their syntax, working and their return values.
Sets in C++ STL are the containers which must have unique elements in a general order. Sets must have unique elements because the value of the element identifies the element. Once added a value in set container later can’t be modified, although we can still remove or add the values to the set. Sets are used as binary search trees.
max_size() is an inbuilt function in C++ STL which is declared in <set> header file. max_size() returns the maximum size of the set container associated with it. In other words, it returns the maximum size that a container can reach, however there is no guarantee it can allocate the elements of that size, it can still fail to allocate the storage to a specific point of a set container.
name_of_set.max_size();
This function accepts no parameter.
This function returns the maximum size of the associated set container.
Input: set<int> myset;
myset.max_size();
Output: size of a set before inserting elements: 461168601842738790
 Live Demo
#include <bits/stdc++.h>
using namespace std;
int main(){
   set<int> data_1, data_2;
   data_1.insert(100);
   cout<<"size of a set after inserting values : "<<data_1.max_size()<< endl;
   cout<<"size of a set before inserting values : "<<data_2.max_size();
   return 0;
}
If we run the above code it will generate the following output −
size of a set after inserting values : 461168601842738790
size of a set before inserting values : 461168601842738790
 Live Demo
#include <iostream>
#include <set>
int main (){
   int i;
   std::set<int> Set;
   if(Set.max_size()>1000){
      for (i=0; i<=1000; i++)
         Set.insert(i);
      std::cout<<"There are 1000 elements in a set.\n";
   }
   else
      std::cout<<"There can't be 1000 elements in a set.\n";
   return 0;
}
If we run the above code it will generate the following output −
There are 1000 elements in a set.
Rust – Match Operator

15 Nov, 2021
Match Operator is a powerful operator which lets you match a particular value with a range of values and execute some operations or code for it. It is similar to switch() in Java.
For checking for a group of values, where the value to be checked is “cp”.
Syntax :
 let gfg = String::from("cp");
 
    // match operator
    match &*gfg {
        "ds" => println!("Data Structure"),
        "cp" => println!("Competitive programming"),
        "fg" => println!("FAANG"),
        _ => println!("not in GFG topics")
    }
For checking multiple conditions in one case here gfg value to be checked is “cp”.
Syntax :
   let gfg = String::from("cp");
   
    // match operator
    match &*gfg {
        "ds"|"cp"|"fg" => println!("topics includede in gfg"),
        _ => println!("Not in gfg topics")
    }
For checking a range of values from 2 to 100.
Syntax :
   let gfg = 101;

   // match operator
    match gfg {
        2..=100 => println!("between 2 to 100"),
        _ => println!("either 1 or above 100"),
    }
Example 1: Below is the Rust program for match operator having multiple cases 
Here we will use variable gfg to store string “cp” then we will use the match operator to match the given list options.
If it is matched the option is printed accordingly and if no match found then the output will be “not in gfg topics”.
Rust
fn main() {     // create string variable gfg  let gfg = String::from("cp");       // match with operator    match &*gfg {        "ds" => println!("Data Structure"),        "cp" => println!("Competitive programming"),        "fg" => println!("FAANG"),        _ => println!("not in gfg topics")    }}
Output :
Competitive programming
Example 2: Below is the Rust program for match operator having multiple conditions in one case.
Here we will use gfg variable to hold the string “cp” but now we will check multiple conditions using one case only.
If it does not match in this condition then the output will be “Not in GFG topics”.
Rust
fn main() {    let gfg = String::from("cp");    match &*gfg {        "ds"|"cp"|"fg" => println!("topics included in gfg"),        _ => println!("Not in GFG topics")    }     }
Output :
topics included in gfg
Example 3: Below is the Rust program for match operator having a range of values.
Here we will use the gfg variable having value 101, and now we will match values for a range of values in a condition.
The condition for matching will be between 2 and 100  if it’s not in this range the output will be “either 1 or above 100”.
Rust
fn main() {      // gfg variable having value 101    let gfg = 101;        // checking for value is between 2 to 100 or not    match gfg {        2..=100 => println!("between 2 to 100"),        _ => println!("either 1 or above 100"),    }}
Output :
either 1 or above 100
akshaysingh98088
Picked
Rust-Operators
Rust
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TypeScript | String Length Property

18 Jun, 2020
The Length Property() in TypeScript which is used to get the length of the string Syntax:
string.length 
Return Value: This method returns the length to the String function that created the object. Below examples illustrate the String Length Property in TypeScript
Example 1: 
JavaScript
<script>    // Original strings    var str = "Geeksforgeeks - Best Platform";            // use of length Property    var newstr = str.length    console.log("Return Value of Length property:", newstr);</script>
Output: 
Return Value of Length property: 
29
Example 2: 
JavaScript
<script>    // Original strings    var str = new String("TypeScript - String length Property");        // use of length Property    var newstr = str.length     console.log("Length:", newstr);</script>
Output: 
Length: 
35

TypeScript
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Roadmap to Learn JavaScript For Beginners
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
Roadmap to Learn JavaScript For Beginners
How to fetch data from an API in ReactJS ?
How to get the length of a string in JavaScript?

To get the length of a string in JavaScript, use the length property. The length property returns the number of characters in a string.
You can try to run the following code to learn how to get the length of a string
Live Demo
<html>
   <head>
      <title>JavaScript String length Property</title>
   </head>
 
   <body>
      <script>
         var str = new String( "Tutorialspoint Tutorials" );
         document.write("Length of string:" + str.length);
      </script>
   </body>
</html>
How to copy a file to a remote server in Python using SCP or SSH?

The easiest way to copy files from one server to another over ssh is to use the scp command. For calling scp you'd need the subprocess module. 
import subprocess
p = subprocess.Popen(["scp", "my_file.txt", "username@server:path"])
sts = os.waitpid(p.pid, 0)
You need the waitpid call to wait for the copying to complete.
Another solution is to open a ssh connection and use the scp module. 
from paramiko import SSHClient
from scp import SCPClient
ssh = SSHClient()
ssh.load_system_host_keys()
ssh.connect('user@server:path')
with SCPClient(ssh.get_transport()) as scp:
    scp.put('my_file.txt', 'my_file.txt') # Copy my_file.txt to the server
Python time strptime() function - GeeksforGeeks

13 Sep, 2021
The strptime() function in Python is used to format and return a string representation of date and time. It takes in the date, time, or both as an input, and parses it according to the directives given to it. It raises ValueError if the string cannot be formatted according to the provided directives.
Syntax:
time.strptime(date_time_srting,directive)
Here,
date_time_string: It is a necessary string parameter where the date to be formatted is provided.
directive: This parameter represents the condition for parsing the given string. It is also a necessary parameter.
The following tables list the supported directives in python.
Python3
import time  formatted_date = time.strptime(" 02 Dec 1996",                               " %d %b %Y")print(formatted_date)
Output:
time.struct_time(tm_year=1996, tm_mon=12, tm_mday=2, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=0, tm_yday=337, tm_isdst=-1)
Python3
import time  print(time.strptime("02/12/1996 5:53","%m/%d/%Y %H:%M"))
Output:
time.struct_time(tm_year=1996, tm_mon=2, tm_mday=12, tm_hour=5, tm_min=53, tm_sec=0, tm_wday=0, tm_yday=43, tm_isdst=-1)
In this example, if time directives will not match then occurred error.
Python3
import time as datetime  datetime_str = '08/1/18 3:55:6'  try:    datetime_object = datetime.strptime(datetime_str, '%m/%d/%y')except ValueError as e:    print('ValueError Raised:', e)    time_str = '25::55::26'  try:    time_object = time.strptime(time_str, '%H::%M::%S')except ValueError as e:    print('ValueError:', e)
Output:
ValueError Raised: unconverted data remains:  3:55:6
ValueError: time data '25::55::26' does not match format '%H::%M::%S'
Blogathon-2021
Picked
Python time-module
Blogathon
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Import JSON Data into SQL Server?
How to Install Tkinter in Windows?
SQL - Multiple Column Ordering
How to pass data into table from a form using React Components
How to Create a Table With Multiple Foreign Keys in SQL?
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Redis - Keys

Redis keys commands are used for managing keys in Redis. Following is the syntax for using redis keys commands.
redis 127.0.0.1:6379> COMMAND KEY_NAME

redis 127.0.0.1:6379> SET tutorialspoint redis 
OK 
redis 127.0.0.1:6379> DEL tutorialspoint 
(integer) 1

In the above example, DEL is the command, while tutorialspoint is the key. If the key is deleted, then the output of the command will be (integer) 1, otherwise it will be (integer) 0.
Following table lists some basic commands related to keys.
This command deletes the key, if it exists.
This command returns a serialized version of the value stored at the specified key.
This command checks whether the key exists or not.
Sets the expiry of the key after the specified time.
Sets the expiry of the key after the specified time. Here time is in Unix timestamp format.
Set the expiry of key in milliseconds.
Sets the expiry of the key in Unix timestamp specified as milliseconds.
Finds all keys matching the specified pattern.
Moves a key to another database.
Removes the expiration from the key.
Gets the remaining time in keys expiry in milliseconds.
Gets the remaining time in keys expiry.
Returns a random key from Redis.
Changes the key name.
Renames the key, if a new key doesn't exist.
Returns the data type of the value stored in the key.

    22 Lectures 
     40 mins

 Skillbakerystudios
 Print
 Add Notes
 Bookmark this page
Password Hashing with MD5 module in Node.js - GeeksforGeeks

27 Apr, 2020
MD5 module in node.js uses a message-digest algorithm and it is a widely used hash function producing a 128-bit hash value. Password hashing is an important concept because, in the database, the actual password should not be stored as its a bad practice and also make the system less secure, so the password is stored in hashed form into the database which makes the system more secured.
Introduction:
It’s easy to get started and easy to use.It is widely used and popular module for hashing password.It produces a 128-bit hash value.
It’s easy to get started and easy to use.
It is widely used and popular module for hashing password.
It produces a 128-bit hash value.
Installation of MD5 module:
You can visit the link Install MD5 module. You can install this package by using the following command.npm install md5After installing multer you can check your md5 version in command prompt using the command.npm version md5After that, you can create a folder and add a file for example index.js, To run this file you need to run the following command.node index.jsRequiring module: You need to include md5 module in your file by using these lines.var md5 = require('md5');
You can visit the link Install MD5 module. You can install this package by using the following command.npm install md5
npm install md5
After installing multer you can check your md5 version in command prompt using the command.npm version md5
npm version md5
After that, you can create a folder and add a file for example index.js, To run this file you need to run the following command.node index.js
node index.js
Requiring module: You need to include md5 module in your file by using these lines.var md5 = require('md5');
var md5 = require('md5');
Filename: index.js
const md5 = require('md5')  var password = 'geeks123'  console.log('Normal password : ', password)console.log('Hashed password : ', md5(password))
Steps to run the program:
The project structure will look like this:Make sure you have install md5 module using following commands:npm install md5Run index.js file using below command:node index.js
The project structure will look like this:
Make sure you have install md5 module using following commands:npm install md5
npm install md5
Run index.js file using below command:node index.js
node index.js
So this is how you can hash password in node js using MD5 module. There are other modules in the market for hashing like Bcrypt, Crypto, etc.
Node.js-Misc
Node.js
Web Technologies
Write From Home
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Node.js fs.writeFile() Method
Node.js fs.readFile() Method
How to install the previous version of node.js and npm ?
Difference between promise and async await in Node.js
How to use an ES6 import in Node.js?
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
Data Structures | Stack | Question 6 - GeeksforGeeks

28 Jun, 2021
The following postfix expression with single digit operands is evaluated using a stack:
              8 2 3 ^ / 2 3 * + 5 1 * - 
Note that ^ is the exponentiation operator. The top two elements of the stack after the first * is evaluated are:(A) 6, 1(B) 5, 7(C) 3, 2(D) 1, 5Answer: (A)Explanation: The algorithm for evaluating any postfix expression is fairly straightforward:
1. While there are input tokens left
    o Read the next token from input.
    o If the token is a value
       + Push it onto the stack.
    o Otherwise, the token is an operator 
      (operator here includes both operators, and functions).
       * It is known a priori that the operator takes n arguments.
       * If there are fewer than n values on the stack
        (Error) The user has not input sufficient values in the expression.
       * Else, Pop the top n values from the stack.
       * Evaluate the operator, with the values as arguments.
       * Push the returned results, if any, back onto the stack.
2. If there is only one value in the stack
    o That value is the result of the calculation.
3. If there are more values in the stack
    o (Error)  The user input has too many values.
Source for algorithm: http://en.wikipedia.org/wiki/Reverse_Polish_notation#The_postfix_algorithm
Let us run the above algorithm for the given expression.First three tokens are values, so they are simply pushed. After pushing 8, 2 and 3, the stack is as follows
    8, 2, 3
When ^ is read, top two are popped and power(2^3) is calculated
    8, 8
When / is read, top two are popped and division(8/8) is performed
    1
Next two tokens are values, so they are simply pushed. After pushing 2 and 3, the stack is as follows
    1, 2, 3
When * comes, top two are popped and multiplication is performed.
    1, 6
Quiz of this Question
Data Structures
Data Structures-Stack
Data Structures
Data Structures
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Data Structures | Tree Traversals | Question 4
Difference between Singly linked list and Doubly linked list
Advantages and Disadvantages of Linked List
Data Structures | Stack | Question 1
FIFO vs LIFO approach in Programming
C program to implement Adjacency Matrix of a given Graph
Introduction to Data Structures
Data Structures | Queue | Question 11
Binary Search Tree | Set 3 (Iterative Delete)
Advantages of vector over array in C++
rint() in Java (Rounding to int) - GeeksforGeeks

18 Mar, 2019
rint() is an inbuilt method in Java which is used to round of the floating-point argument to an integer value (in floating-point format).
Syntax:
Math.rint(double n)
Parameters:The rint() function takes a mandatory single argument value to round.
Returns:A double value is returned. This method returns the integer that is closest in value to the argument.
Code#1: Program demonstrating the use of rint() function
// Java program for implementation of// rint() methodimport java.util.*;class GFG {      // Driver Code    public static void main(String args[])    {        double x = 12.6;        double y = 12.2;          // rint() method use to return the         // closest value to the argument        double rintx = Math.rint(x);        double rinty = Math.rint(y);          // Prints the rounded numbers        System.out.println(rintx);        System.out.println(rinty);    }}
Output:
13.0
12.0

Exception:In case of 0.5 at decimal places it will round off to nearest even double value.
Code#2: Program explaining the exceptions
// Java program for implementation of// rint() method exceptionimport java.util.*;class GFG {      // Driver Code    public static void main(String args[])    {        double x = 1.5;        double y = 2.5;          // rounds upto 2 which is the nearest        // even double value        double rintx = Math.rint(x);        double rinty = Math.rint(y);          System.out.println(rintx);        System.out.println(rinty);    }}
Output:
2.0
2.0

aadityakrishnajaiswal
NavoneelKarmakar
java-math
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Generics in Java
Introduction to Java
Comparator Interface in Java with Examples
Internal Working of HashMap in Java
Strings in Java
How to use Button Component in ReactJS?

22 Jan, 2021
Buttons allow users to take actions, and make choices, with a single tap. Material UI for React has this component available for us and it is very easy to integrate. We can use the Button component 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 modules using the following command:
npm install @material-ui/core
Project Structure: It will look like the following.
Project Structure
App.js: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
Javascript
import React from 'react';import Button from '@material-ui/core/Button';  const App = () => {    return (    <div style={{      display: 'flex',      margin: 'auto',      width: 400,      flexWrap: 'wrap',    }}>      <div style={{ width: '100%', float: 'left' }}>        <h3>How to use Button Component in ReactJS?</h3> <br />      </div>      <Button variant="contained">Default Button</Button>      <Button variant="contained" color="primary">        Primary Button      </Button>      <Button variant="contained" color="secondary">        Secondary Button      </Button>      <Button variant="contained" disabled>        Disabled Button      </Button>      <Button variant="contained" color="primary"        href="#">        Link Button      </Button>    </div>  );}  export default App;
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:
JavaScript
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2015 (Set 2) | Question 45

11 Oct, 2021
Consider alphabet ∑ = {0, 1}, the null/empty string λ and the sets of strings X0, X1 and X2 generated by the corresponding non-terminals of a regular grammar. X0, X1 and X2 are related as follows:
X0 = 1 X1
X1 = 0 X1 + 1 X2
X2 = 0 X1 + {λ} 
Which one of the following choices precisely represents the strings in X0?
(A) 10 (0* + (10)*)1(B) 10 (0* + (10)*)*1(C) 1(0* + 10)*1(D) 10 (0 + 10)*1 + 110 (0 + 10)*1Answer: (C)Explanation:
The smallest possible string by given grammar is "11".
X0 = 1X1
   = 11X2  [Replacing X1 with 1X2]
   = 11    [Replacing X2 with λ]

The string "11" is only possible with option (C).

GATE PYQ's on Theory of Computation with Praddyumn Shukla | GeeksforGeeks GATE | GATE CSE - YouTubeGeeksforGeeks GATE Computer Science17.6K subscribersGATE PYQ's on Theory of Computation with Praddyumn Shukla | GeeksforGeeks GATE | GATE CSEWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.More videosMore videosYou're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:0044:04 / 56:33•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=iNOmopKv0aY" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
GATE-CS-2015 (Set 2)
GATE-GATE-CS-2015 (Set 2)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to add a README to your GitHub profile?

28 Jul, 2020
Github has recently added a really cool feature that allows you to add a README to your GitHub profile.It’s just like an “About Me” or “Bio” section for your GitHub. It can be used to showcase your skills, your hobbies, or anything that you want the world to know about you.
User can customize the Info on the README as per its choice. Adding a README to the GitHub profile is quite an easier task. You can follow the steps given below to do the same:
Step 1: Create a new repository with your GitHub username.
Go to https://github.com/new and enter the same name as your GitHub username into the Repository name field.
Go to https://github.com/new and enter the same name as your GitHub username into the Repository name field.
Leave the repo as a Public repo (by default).
Also, make sure to initialize it with a README to get started.
Step 2: Add some content to your README.
You can list all your projects, websites, social media links, and many more things to it.
You can use markdown formatting (https://guides.github.com/features/mastering-markdown/ ) to style the text or add images/links.
GitHub also gives some suggestions to get started:
Step 3: Commit the changes to add a ReadMe to your GitHub Account.
You can even add Github Readme Stats, Github Extra Pins, and GitHub Profile View Counter in your README.
Github readme stats allows you to simply add a markdown image link and it will show you realtime stats for your GitHub account.
Usage:
Copy and paste this line into your markdown content and change the ‘?username= value’ to your GitHubs’s username
![Github stats](https://github-readme-stats.vercel.app/api?username=yourGithubUsername)
Preview:
Github extra pins allow you to pin more than 6 repositories in your profile by using the GitHub readme profile.
Usage:
Copy-paste this code into your readme and change the username and repo.
![ReadMe Card](https://github-readme-stats.vercel.app/api/pin/?username=YourUsername&repo=YourRepositoryName)
Preview:
You can track Github profile views and display them in your profile readme.
Usage:
Copy this workflow to your Pipedream account (https://pipedream.com/@/p_G6CNmN/edit?copy=true ) 
Add the Profile views counter-image to your Github Readme (use your Pipedream endpoint URL)![counter](https://[YourEndpoint].m.pipedream.net)
![counter](https://[YourEndpoint].m.pipedream.net)
Preview:Your profile views will be counted and displayed:
Finally, commit all your changes and view your cool Github profile.
GBlog
Git
How To
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
numpy.ppmt() in Python

29 Nov, 2018
numpy.ppmt(rate, nper, pv, fv, when = ‘end’) : This financial function helps user to compute payment value as per the principal value only.
Parameters :rate : [scalar or (M, )array] Rate of interest as decimal (not per cent) per periodnper : [scalar or (M, )array] total compounding periodsfv : [scalar or (M, )array] Future valuepv : [scalar or (M, )array] present valuewhen : at the beginning (when = {‘begin’, 1}) or the end (when = {‘end’, 0}) of each period.Default is {‘end’, 0}
Return : Payment value as per the principal value only.
Equation being solved :
fv + pv*(1+rate)**nper + pmt*(1 + rate*when)/rate*((1 + rate)**nper – 1) == 0
or when rate == 0fv + pv + pmt * nper == 0
Code:
# Python program explaining # ppmt() function   import numpy as np   ''' Question :   monthly payment needed to pay off a $10, 000 loanin 12 years at an annual interest rate of 10 %'''  # rate     np         pv Solution = np.ppmt(0.10 / 12, 12 * 12,  10, 000)   # Here fv = 0 ; Also Default value of fv = 0 print("Solution : ", Solution) 
Output:
Solution :  -0.1195078262827336

Python numpy-Financial Functions
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Copy and Paste Images onto other Image using Pillow

18 Jan, 2022
In this article, we will learn how to copy an image over another image using pillow library. We will use image module from pillow and copy() and paste() methods to achieve this task. We will need to create copies of both images so that it does not affect the original image with the help of copy() method and then paste the image on the other image with the help of paste() method.Input images – Image1: 
 Image2:  
Example 1:  
Python3
# import image module from pillowfrom PIL import Image # open the imageImage1 = Image.open('D:\cat.jpg') # make a copy the image so that the# original image does not get affectedImage1copy = Image1.copy()Image2 = Image.open('D:\core.jpg')Image2copy = Image2.copy() # paste image giving dimensionsImage1copy.paste(Image2copy, (0, 0)) # save the imageImage1copy.save('D:\pasted2.png')
Output:  
Example 2: Changing parameters to place the Image2 on face of the cat in the Image1. 
Python3
# import image module from pillowfrom PIL import Image # open the imageImage1 = Image.open('D:\cat.jpg') # make a copy the image so that# the original image does not get affectedImage1copy = Image1.copy()Image2 = Image.open('D:\core.jpg')Image2copy = Image2.copy() # paste image giving dimensionsImage1copy.paste(Image2copy, (70, 150)) # save the imageImage1copy.save('D:\pasted2.png')
Output:  
 
Akanksha_Rai
sagar0719kumar
Python-pil
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Find the Position of a Number in an Array in MATLAB?

04 Jul, 2021
Finding the position of a number in an array, which can be done using the find() function. The find() function is used to find the indices and values of the specified nonzero elements.
find(X)
Parameters: This function accepts a parameter.
X: This is the specified number whose position is going to be found in the array.
Return Value: It returns the position of the given number in a specified array.
Example 1  
Matlab
% MATLAB code for getting the position % of element 4X = [2 4 4 5 6 4]; % Initializing an array % of some elements  % Calling the find() function to find % the position of 4Position_of_4 = find(X==4)
Output:
Example 2 
Matlab
% MATLAB code for getting the position % of element 4 in terms of rows and columns.X = [2 4 4 5 6 4];   % Calling the find() function to find % the position of 4 in terms of rows % and columns[Row, column] = find(X==4)
Output:
MATLAB
MATLAB-programs
Picked
MATLAB
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Puppet - SSL Sign Certificate Setup

When the Puppet agent software runs for the first time on any Puppet node, it generates a certificate and sends the certificate signing request to the Puppet master. Before the Puppet server is able to communicate and control the agent nodes, it must sign that particular agent node’s certificate. In the following sections, we will describe how to sign and check for the signing request.
On the Puppet master, run the following command to see all unsigned certificate requests.
$ sudo /opt/puppetlabs/bin/puppet cert list

As we have just set up a new agent node, we will see one request for approval. Following will be the output.
"Brcleprod004.brcl.com" (SHA259) 
15:90:C2:FB:ED:69:A4:F7:B1:87:0B:BF:F7:ll:
B5:1C:33:F7:76:67:F3:F6:45:AE:07:4B:F 6:E3:ss:04:11:8d 

It does not contain any + (sign) in the beginning, which indicates that the certificate is still not signed.
In order to sign the new certificate request which was generated when the Puppet agent run took place on the new node, the Puppet cert sign command would be used, with the host name of the certificate, which was generated by the newly configured node that needs to be signed. As we have Brcleprod004.brcl.com’s certificate, we will use the following command.
$ sudo /opt/puppetlabs/bin/puppet cert sign Brcleprod004.brcl.com 

Following will be the output.
Notice: Signed certificate request for Brcle004.brcl.com 
Notice: Removing file Puppet::SSL::CertificateRequest Brcle004.brcl.com at 
'/etc/puppetlabs/puppet/ssl/ca/requests/Brcle004.brcl.com.pem' 

The puppet sever can now communicate to the node, where the sign certificate belongs.
$ sudo /opt/puppetlabs/bin/puppet cert sign --all 

There are conditions on configuration of kernel rebuild when it needs to removing the host from the setup and adding it again. These are those conditions which cannot be managed by the Puppet itself. It could be done using the following command.
$ sudo /opt/puppetlabs/bin/puppet cert clean hostname 

The following command will generate a list of signed certificates with + (sign) which indicates that the request is approved.
$ sudo /opt/puppetlabs/bin/puppet cert list --all

Following will be its output.
+ "puppet" (SHA256) 5A:71:E6:06:D8:0F:44:4D:70:F0:
BE:51:72:15:97:68:D9:67:16:41:B0:38:9A:F2:B2:6C:B 
B:33:7E:0F:D4:53 (alt names: "DNS:puppet", "DNS:Brcle004.nyc3.example.com")  

+ "Brcle004.brcl.com" (SHA259) F5:DC:68:24:63:E6:F1:9E:C5:FE:F5:
1A:90:93:DF:19:F2:28:8B:D7:BD:D2:6A:83:07:BA:F E:24:11:24:54:6A 

+ " Brcle004.brcl.com" (SHA259) CB:CB:CA:48:E0:DF:06:6A:7D:75:E6:CB:22:BE:35:5A:9A:B3 

Once the above is done, we have our infrastructure ready in which the Puppet master is now capable of managing newly added nodes.
 Print
 Add Notes
 Bookmark this page
JavaScript Quicksort recursive

We are required to write a JavaScript function that takes in an array of Numbers. The function should apply the algorithm of quicksort to sort the array either in increasing or decreasing order.
Quicksort follows the below steps −
Step 1 − Make any element as the pivot (preferably first or last, but any element can be the pivot)
Step 2 − Partition the array on the basis of pivot
Step 3 − Apply a quick sort on the left partition recursively
Step 4 − Apply a quick sort on the right partition recursively
The average and best case time complexity of QuickSort are O(nlogn) whereas in worst cases, it can slow up to O(n^2).
The code for this will be −
const arr = [5,3,7,6,2,9];
const swap = (arr, leftIndex, rightIndex) => {
   let temp = arr[leftIndex];
   arr[leftIndex] = arr[rightIndex];
   arr[rightIndex] = temp;
};
const partition = (arr, left, right) => {
   let pivot = arr[Math.floor((right + left) / 2)];
   let i = left;
   let j = right;
   while (i <= j) {
      while (arr[i] < pivot) {
         i++;
      };
      while (arr[j] > pivot) {
         j--;
      };
      if (i <= j) {
         swap(arr, i, j); //sawpping two elements
         i++;
         j--;
      };
   };
   return i;
}
const quickSort = (arr, left = 0, right = arr.length - 1) => {
   let index;
   if (arr.length > 1) {
      index = partition(arr, left, right);
      if (left < index - 1) {
         quickSort(arr, left, index - 1);
      };
      if (index < right) {
         quickSort(arr, index, right);
      };
   }
   return arr;
}
let sortedArray = quickSort(arr);
console.log(sortedArray);
And the output in the console will be −
[ 2, 3, 5, 6, 7, 9 ]
Java Examples - Create a temporary File

How to create a temporary file ?
This example shows how to create a temporary file using createTempFile() method of File class.
import java.io.*;

public class Main {
   public static void main(String[] args) throws Exception {
      File temp = File.createTempFile ("pattern", ".suffix");
      temp.deleteOnExit(); 
      BufferedWriter out = new BufferedWriter (new FileWriter(temp));
      out.write("aString");
      System.out.println("temporary file created:");
      out.close();
   }
}
The above code sample will produce the following result.
temporary file created:

The following is another sample example of create a temporary file in java
import java.io.File;
import java.io.IOException;

public class CreateTempFileExample { 
   public static void main(String[] args) { 
      try { 
         File f1 = File.createTempFile("temp-file-name", ".tmp");
    	   System.out.println("Temp file : " + f1.getAbsolutePath());
      } catch(IOException e) { 
         e.printStackTrace();
      } 
   }
}
The above code sample will produce the following result.
Temp file : C:\Users\TUTORI~1\AppData\Local\Temp\temp-file-name3671918809488333932.tmp

 Print
 Add Notes
 Bookmark this page
Java program to implement linear search

Linear search is a very simple search algorithm. In this type of search, a sequential search is done for all items one by one. Every item is checked and if a match is found then that particular item is returned, otherwise the search continues till the end of the data collection.
1.Get the length of the array.
2.Get the element to be searched store it in a variable named value.
3.Compare each element of the array with the variable value.
4.In case of a match print a message saying element found.
5.else, print a message saying element not found
Live Demo
public class LinearSearch {
   public static void main(String args[]){
      int array[] = {10, 20, 25, 63, 96, 57};
      int size = array.length;
      int value = 63;

      for (int i=0 ;i< size-1; i++){
         if(array[i]==value){
            System.out.println("Element found index is :"+ i);
         }else{
            System.out.println("Element not found");
         }
      }
   }
}
Element found index is :3
\widehat - Tex Command

\widehat - Used to create widehat symbol.
{ \widehat}
\widehat command draws widehat symbol.

\widehat a

a^


\widehat A

A^


\widehat AB

A^B


\widehat{AB}

AB^



\widehat a

a^


\widehat a
\widehat A

A^


\widehat A
\widehat AB

A^B


\widehat AB
\widehat{AB}

AB^


\widehat{AB}

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
DAX Date & Time - DATEDIFF function

Returns the count of interval boundaries crossed between two dates.
DAX DATEDIFF function is new in Excel 2016.
DATEDIFF (<start_date>, <end_date>, <interval>) 

start_date
A scalar datetime value.
end_date
A scalar datetime value.
interval
The interval to use when comparing the dates. The value can be one of the following −
SECOND
MINUTE
HOUR
DAY
WEEK
MONTH
QUARTER
YEAR
A whole number.
If start_date is larger than end_date, an error value is returned.
The values given to the parameter interval are constants and not strings. Hence, they should not be enclosed in double quotation marks.
= DATEDIFF (DATE (2016,1,1), DATE (2016,3,31), MONTH) returns 2. 
= DATEDIFF (DATE (2016,1,1), DATE (2016,4,1), MONTH) returns 3. 
= DATEDIFF (DATE (2016,1,1), DATE (2016,3,31), DAY) returns 90. 
= DATEDIFF (DATE (2016,1,1), DATE (2016,3,31), HOUR) returns 2160. 
= DATEDIFF (DATE (2016,1,1), DATE (2016,3,31), SECOND) returns 7776000. 

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
Python - Sort by Uppercase Frequency - GeeksforGeeks

24 Oct, 2020
Given a list of strings, perform sorting by frequency of uppercase characters. 
Input : test_list = [“Gfg”, “is”, “FoR”, “GEEKS”] Output : [‘is’, ‘Gfg’, ‘FoR’, ‘GEEKS’] Explanation : 0, 1, 2, 5 uppercase letters in strings respectively. 
Input : test_list = [“is”, “GEEKS”] Output : [‘is’, ‘GEEKS’] Explanation : 0, 5 uppercase letters in strings respectively. 
Method #1 : Using sort() + isupper()
In this, we perform task of checking for uppercase using isupper(), and sort() to perform task of sorting.
Python3
# Python3 code to demonstrate working of# Sort by Uppercase Frequency# Using isupper() + sort()    # helper functiondef upper_sort(sub):      # len() to get total uppercase characters    return len([ele for ele in sub if ele.isupper()])    # initializing listtest_list = ["Gfg", "is", "BEST", "FoR", "GEEKS"]  # printing original listprint("The original list is: " + str(test_list))  # using external function to perform sortingtest_list.sort(key=upper_sort)  # printing resultprint("Elements after uppercase sorting: " + str(test_list))
Output:
The original list is: ['Gfg', 'is', 'BEST', 'FoR', 'GEEKS']
Elements after uppercase sorting: ['is', 'Gfg', 'FoR', 'BEST', 'GEEKS']
Method #2 : Using sorted() + lambda function
In this, we perform the task of sorting using sorted(), and lambda function is used rather than external sort() function to perform task of sorting.
Python3
# Python3 code to demonstrate working of# Sort by Uppercase Frequency# Using sorted() + lambda function    # initializing listtest_list = ["Gfg", "is", "BEST", "FoR", "GEEKS"]  # printing original listprint("The original list is: " + str(test_list))  # sorted() + lambda function used to solve problemres = sorted(test_list, key=lambda sub: len(    [ele for ele in sub if ele.isupper()]))  # printing resultprint("Elements after uppercase sorting: " + str(res))
Output:
The original list is: ['Gfg', 'is', 'BEST', 'FoR', 'GEEKS']
Elements after uppercase sorting: ['is', 'Gfg', 'FoR', 'BEST', 'GEEKS']
Python list-programs
Python string-programs
Python
Python Programs
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
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Python program to convert a list to string
Defaultdict in Python
Python | Split string into list of characters
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Does MySQL support table inheritance?

MySQL uses foreign key constraint instead of inheritance. MySQL does not support table inheritance.
You can achieve the same with the help of foreign key constraint. Let us create a table and use the foreign key constraint. The query to create the first table is as follows −
mysql> create table Parent_Table
   -> (
   -> ParentId int,
   -> PRIMARY KEY(ParentId)
   -> );
Query OK, 0 rows affected (3.59 sec)
Now create the second table. The query to create the second table is as follows −
mysql> create table Child_Table
   -> (
   -> ChildId int references Parent_Table,
   -> PRIMARY KEY(ChildId)
   -> );
Query OK, 0 rows affected (0.73 sec)
Now add the foreign key relationship between two tables. The query is as follows −
mysql> alter table Child_Table add constraint FK_Child Foreign key(ChildId) references Parent_Table(ParentId);
Query OK, 0 rows affected (2.28 sec)
Records: 0 Duplicates: 0 Warnings: 0
Google Cloud Platform - Introduction to PhoneInfoga an OSINT Reconnaissance Tool - GeeksforGeeks

27 May, 2021
PhoneInfoga is one of the most advanced tools which one can use to scan phone numbers and get detailed information about them using only free resources. The motive is to gather basic information such as country, area, line, and carrier on any international phone numbers with very good accuracy. Then try to determine the VoIP provider or search for footprints on search engines to try to identify the owner.
It checks if the phone number that you have searched, exists or not.
It gathers information about phone numbers such as country, area, carrier, and line type.
OSINT footprints using external APIs, Google Hacking, search engine, and phone books.
Check for reputation reports, social media, disposable numbers, and more.
Scan several numbers at once.
Run your web instances as a service.
Important
It does not allow to hack a phone.
It does not allow to get the precise phone location.
It does not allow to track phone or it’s owner in real time.
Follow the below steps to use PhoneInfoga on Google Cloud Console:
Step 1: Log in to Google Cloud Console using any of your google accounts and click on the icon shown below.
(This is actually launching your Google cloud shell and giving you access to a machine where you can use “PhoneInfoga“)
Step 2: Now there 2 options, either you can install PhoneInfoga like an application just by typing these commands into your terminal.
Or, you can go the easier way and use Docker.
Step 3: Since the Google cloud console has already installed docker, we can go ahead and type this command on the console.
Step 4: Press enter after typing the command and your console should be looking like this.
Step 5: Now we are going to run it, enter this command and at the end of it type the phone number with the country code: 
docker run -it sundowndev/phoneinfoga scan -n 13526006900
Step 6: Let’s see what all the information we were able to get using “PhoneInfoga“.
As you can see, PhoneInfoga first ran numverify scan to check whether the number exists or not, and it returned, ‘true’ indicating the number exists.
We can also see that the location is, ‘Weekichspg‘ and the line type is of landline. Let’s further see what else we have here,
We can see here the social media footprints like on which social media platform this number is used to create an account. So it is quite clear that a tool like PhoneInfoga can prove to be very useful in gathering information on international phone numbers using only free resources.
Cloud-Computing
Google Cloud Platform
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Must Do Coding Questions for Product Based Companies
How to calculate MOVING AVERAGE in a Pandas DataFrame?
What is Transmission Control Protocol (TCP)?
Difference Between Skewness and Kurtosis
How to Convert Categorical Variable to Numeric in Pandas?
Sed Command in Linux/Unix with examples
AWK command in Unix/Linux with examples
grep command in Unix/Linux
cut command in Linux with examples
cp command in Linux with examples
Run Animation backward first and then forwards with CSS

Use the animation-direction property to run animation in first backward and then forward. The property is used with the alternate-reverse animation value to achieve this.
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            width: 150px;
            height: 200px;
            position: relative;
            background-color: yellow;
            animation-name: myanim;
            animation-duration: 2s;
            animation-direction: alternate-reverse;
            animation-iteration-count: 3;
         }
         @keyframes myanim {
            0% {background-color:green; left:0px; top:0px;}
            50% {background-color:maroon; left:100px; top:100px;}
            100% {background-color:gray; left:0px; top:0px;}
         }
      </style>
   </head>
   <body>
      <div></div>
   </body>
</html>
How to convert Long array list to long array in Java?

Firstly, declare a Long array list and add some elements to it:
ArrayList < Long > arrList = new ArrayList < Long > ();
arrList.add(100000 L);
arrList.add(200000 L);
arrList.add(300000 L);
arrList.add(400000 L);
arrList.add(500000 L);
Now, set the same size for the newly created long array:
final long[] arr = new long[arrList.size()];
int index = 0;
Each and every element of the Long array list is assigned to the long array:
for (final Long value : arrList) {
   arr[index++] = value;
}
import java.util.ArrayList;
public class Demo {
   public static void main(String[] args) {
      ArrayList<<Long> arrList = new ArrayList<Long>();
      arrList.add(100000L);
      arrList.add(200000L);
      arrList.add(300000L);
      arrList.add(400000L);
      arrList.add(500000L);
      arrList.add(600000L);
      arrList.add(700000L);
      arrList.add(800000L);
      arrList.add(900000L);
      arrList.add(1000000L);
      final long[] arr = new long[arrList.size()];
      int index = 0;
      for (final Long value : arrList) {
         arr[index++] = value;
      }
      System.out.println("Elements of Long array...");
      for (Long i : arr) {
         System.out.println(i);
      }
   }
}
Elements of Long array...
100000
200000
300000
400000
500000
600000
700000
800000
900000
1000000
Python Number seed() Method

Python number method seed() sets the integer starting value used in generating random numbers. Call this function before calling any other random module function.
Following is the syntax for seed() method −
seed ( [x] )

Note − This function is not accessible directly, so we need to import the random module and then we need to call this function using random static object.
x − This is the seed for the next random number. If omitted, then it takes system time to generate next random number.
x − This is the seed for the next random number. If omitted, then it takes system time to generate next random number.
This method does not return any value.
The following example shows the usage of seed() method.
#!/usr/bin/python
import random

random.seed( 10 )
print "Random number with seed 10 : ", random.random()

# It will generate same random number
random.seed( 10 )
print "Random number with seed 10 : ", random.random()

# It will generate same random number
random.seed( 10 )
print "Random number with seed 10 : ", random.random()
When we run above program, it produces following result −
Random number with seed 10 :  0.57140259469
Random number with seed 10 :  0.57140259469
Random number with seed 10 :  0.57140259469


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page