code-rag-bench/online-tutorials huggingface dataset:
How to rotate a video in OpenCV using C++?

Rotating a video is similar to rotate an image. The only difference is instead of load a still picture into an image matrix, we have loaded a video or take video stream from the camera.
Here, we are not loading the video but taking a video using the camera. If you want to use a video file, just put the address of the video file properly.
The following program demonstrates how to rotate a video in OpenCV using C++.
#include<iostream>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
using namespace std;
using namespace cv;
int main(int argc, char* argv[]) {
   VideoCapture loadvideo(0);//capture video from default camera//
   namedWindow("OriginalVideo");//declaring window to show original video stream//
   namedWindow("RotatedVideo");//declaring window to show rotated video stream//
   int rotating_angle = 180;//initial rotation angle//
   createTrackbar("Rotation", "RotatedVideo", &rotating_angle, 360);//creating trackbar for rotation//
   while (true) {
      Mat before_Rotating;//declaring matrix for image before rotation//
      bool temp = loadvideo.read(before_Rotating);//load frames from video source to matrix//
      imshow("OriginalVideo", before_Rotating);//show image frames before rotation//
      Mat for_Rotation = getRotationMatrix2D(Point(before_Rotating.cols / 2, before_Rotating.rows / 2), (rotating_angle - 180), 1);//affine transformation matrix for the 2D rotation//
      Mat after_Rotating;//declaring matrix for image after rotation//
      warpAffine(before_Rotating, after_Rotating, for_Rotation, before_Rotating.size());//applying affine transformation//
      imshow("RotatedVideo", after_Rotating);//show image after rotating//
      if (waitKey(30) == 27){ //wait till Esc key is pressed from keyboard//
         break;
      }
   }
   return 0;
}
How to make a canvas in Java Swing?

To make a canvas with Java Swing, use the Graphics2D class −
public void paint(Graphics g) {
   Graphics2D graphic2d = (Graphics2D) g;
   graphic2d.setColor(Color.BLUE);
   graphic2d.fillRect(100, 50, 60, 80);
}
Above, we have created a rectangle and also added color to it.
The following is an example to make a canvas in Java −
package my;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class SwingDemo extends JPanel {
   @Override
   public void paint(Graphics g) {
      Graphics2D graphic2d = (Graphics2D) g;
      graphic2d.setColor(Color.BLUE);
      graphic2d.fillRect(100, 50, 60, 80);
   }
   public static void main(String[] args) {
      JFrame frame = new JFrame("Demo");
      frame.add(new SwingDemo());
      frame.setSize(550, 250);
      frame.setVisible(true);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   }
}
This will produce the following output −
How do threads communicate with each other in Java?

Inter-thread communication involves the communication of threads with each other. The three methods that are used to implement inter-thread communication in Java
This method causes the current thread to release the lock. This is done until a specific amount of time has passed or another thread calls the notify() or notifyAll() method for this object.
This method wakes a single thread out of multiple threads on the current object’s monitor. The choice of thread is arbitrary.
This method wakes up all the threads that are on the current object’s monitor.
class BankClient {
   int balAmount = 5000;
   synchronized void withdrawMoney(int amount) {
      System.out.println("Withdrawing money");
      balAmount -= amount;
      System.out.println("The balance amount is: " + balAmount);
   }
   synchronized void depositMoney(int amount) {
      System.out.println("Depositing money");
      balAmount += amount;
      System.out.println("The balance amount is: " + balAmount);
      notify();
   }
}
public class ThreadCommunicationTest {
   public static void main(String args[]) {
      final BankClient client = new BankClient();
      new Thread() {
         public void run() {
            client.withdrawMoney(3000);
         }
      }.start();
      new Thread() {
         public void run() {
           client.depositMoney(2000);
         }
      }.start();
   }
}
Withdrawing money
The balance amount is: 2000
Depositing money
The balance amount is: 4000
Appending suffix to numbers in JavaScript

We are required to write a JavaScript function that takes in a number, num, as the first and the
only argument.
The task of our function is to append ‘st’, ‘nd’, ‘rd’, ‘th’ to the number according to the following
rules:
st is used with numbers ending in 1 (e.g. 1st, pronounced first)
nd is used with numbers ending in 2 (e.g. 92nd, pronounced ninety-second)
rd is used with numbers ending in 3 (e.g. 33rd, pronounced thirty-third)
As an exception to the above rules, all the "teen" numbers ending with 11, 12 or 13 use -
th (e.g. 11th, pronounced eleventh, 112th, pronounced one hundred [and] twelfth)
th is used for all other numbers (e.g. 9th, pronounced ninth).
For example, if the input to the function is −
Input
const num = 4513;
Output
const output = '4513th';
Output Explanation
Even though 4513 ends with three, 13 is an exception case that must be appended with th
Following is the code −
 Live Demo
const num = 4513;
const appendText = (num = 1) => {
   let suffix = "th";
   if (num == 0) suffix = "";
   if (num % 10 == 1 && num % 100 != 11) suffix = "st";
   if (num % 10 == 2 && num % 100 != 12) suffix = "nd";
   if (num % 10 == 3 && num % 100 != 13) suffix = "rd";

   return num + suffix;
};
console.log(appendText(num));
4513th
Scatter plot and Color mapping in Python

We can create a scatter plot using the scatter() method and we can set the color for every data point.
Create random values (for x and y) in a given shape, using np.random.rand() method.
Create random values (for x and y) in a given shape, using np.random.rand() method.
Create a scatter plot of *y* vs. *x* with varying marker size and/or color, using the scatter method where color range would be in the range of (0, 1000).
Create a scatter plot of *y* vs. *x* with varying marker size and/or color, using the scatter method where color range would be in the range of (0, 1000).
Show the figure using plt.show().
Show the figure using plt.show().
import matplotlib.pyplot as plt
import numpy as np

x = np.random.rand(1000)
y = np.random.rand(1000)

plt.scatter(x, y, c=[i for i in range(1000)])
plt.show()
How to add Video Player in NextJS ?

14 Dec, 2021
In this article, we are going to learn how we can add Video Player in NextJs. NextJS is a React-based framework. It has the power to Develop beautiful Web applications for different platforms like Windows, Linux, and mac. 
Approach: To add our Video Player we are going to use the react-player package. The react-player package helps us to add a video player anywhere in our app. So first, we will install the react-player package and then we will add a video player on our homepage.
Create NextJS Application: You can create a new NextJs project using the below command:
npx create-next-app gfg
 
Install the required package: Now we will install the react-player package using the below command:
npm i react-player
Project Structure: It will look like this.
Adding the Video Player: After installing the package we can easily add Video Player to our app. For this example, we are going to add a video player to our homepage.
index.js
import React from 'react'import ReactPlayer from 'react-player'  export default function VideoPlayer(){  return (    <div>      <h2>NextJs VideoPlayer - GeeksforGeeks</h2>      <ReactPlayer url='https://www.youtube.com/watch?v=wWgIAphfn2U' />    </div>  )}
Explanation: In the above example first, we are importing our ReactPlayer component from the installed package. After that, we are using the ReactPlayer component inside a new function. We can enter the link of the video that we want to play.
Steps to run the application: Run the below command in the terminal to run the app.
npm run dev
Next.js
JavaScript
ReactJS
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
Remove elements from a JavaScript Array
Roadmap to Learn JavaScript For Beginners
Difference Between PUT and PATCH Request
JavaScript | Promises
How to fetch data from an API in ReactJS ?
Axios in React: A Guide for Beginners
How to redirect to another page in ReactJS ?
ReactJS Functional Components
What are the differences between Widening Casting (Implicit) and Narrowing Casting (Explicit) in Java?

A Type casting in Java is used to convert objects or variables of one type into another. When we are converting or assigning one data type to another they might not compatible. If it is suitable then it will do smoothly otherwise chances of data loss.
Java Type Casting is classified into two types.
Widening Casting (Implicit) – Automatic Type Conversion
Narrowing Casting (Explicit) – Need Explicit Conversion
Widening
Type Conversion can happen if both types are compatible and the target type is larger than source type. Widening Casting takes place when two types are compatible and the target type is larger than the source type.
Live Demo
public class ImplicitCastingExample {
   public static void main(String args[]) {
      byte i = 40;
      // No casting needed for below conversion
      short j = i;
      int k = j;
      long l = k;
      float m = l;
      double n = m;
      System.out.println("byte value : "+i);
      System.out.println("short value : "+j);
      System.out.println("int value : "+k);
      System.out.println("long value : "+l);
      System.out.println("float value : "+m);
      System.out.println("double value : "+n);
   }
}
byte value : 40
short value : 40
int value : 40
long value : 40
float value : 40.0
double value : 40.0
In the below example, Child class is the smaller type we are assigning it to Parent class type which is a larger type hence no casting is required.
Live Demo
class Parent {
   public void display() {
      System.out.println("Parent class display() called");
   }
}
public class Child extends Parent {
   public static void main(String args[]) {
      Parent p = new Child();
      p.display();
   }
}
Parent class display() method called
When we are assigning a larger type to a smaller type, Explicit Casting is required.
Live Demo
public class ExplicitCastingExample {
   public static void main(String args[]) {
      double d = 30.0;
      // Explicit casting is needed for below conversion
      float f = (float) d;
      long l = (long) f;
      int i = (int) l;
      short s = (short) i;
      byte b = (byte) s;
      System.out.println("double value : "+d);
      System.out.println("float value : "+f);
      System.out.println("long value : "+l);
      System.out.println("int value : "+i);
      System.out.println("short value : "+s);
      System.out.println("byte value : "+b);
   }
}
double value : 30.0
float value : 30.0
long value : 30
int value : 30
short value : 30
byte value : 30
When we are assigning larger type to a smaller type, then we need to explicitly
typecast it.
Live Demo
class Parent {
   public void display() {
      System.out.println("Parent class display() method called");
   }
}
public class Child extends Parent {
   public void display() {
      System.out.println("Child class display() method called");
   }
   public static void main(String args[]) {
      Parent p = new Child();
      Child c = (Child) p;
      c.display();
   }
}
Child class display() method called
Difference between Indirect and Implied Addressing Modes

04 Jul, 2022
1. Indirect Addressing Mode: This is the mode of addressing where the instruction contains the address of the location where the target address is stored. So in this way, it is Indirectly storing the address of the target location in another memory location. So it is called Indirect Addressing mode. 
Prerequisite - Addressing Modes 
There are 2 types(or versions) of Indirect Addressing Mode: Memory Indirect, and Register Indirect. 
1. Memory Indirect: In this type, we directly mention the address of the memory location in the instruction either enclosed by parenthesis or preceded by the ‘@’ character. 
Example :
LOAD R1, (1005) 
or 
LOAD R1, @1005 
2. Register Indirect: In this type, the address of the target memory location will be stored in the register and the register will be mentioned in the instruction. 
Example: 
MOV R@, 1005
LOAD R1, (R2) 
2. Implied Addressing Mode : This is the mode of addressing where the operand is specified implicitly in the definition of the instruction. This mode of addressing is normally used in zero address (e.g., Stack operations) and one address (e.g., MUL AL) instructions. Hence the operand is implied inside the instruction, it is called Implied Addressing Mode. 
Example : 
MOV CL, 05
L1: INC AL
    LOOP L1 
Here AL will be incremented by 1 every time the loop executes. Hence 1 is implied inside the instruction INC AL. 
Difference between Indirect and Implied Addressing Modes : 
 
chhabradhanvi
annieahujaweb2020
Picked
Computer Organization & Architecture
Difference Between
GATE CS
Write From Home
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Matplotlib.pyplot.axvline() in Python

21 Apr, 2020
Matplotlib is a plotting library for creating static, animated, and interactive visualizations in Python. Matplotlib can be used in Python scripts, the Python and IPython shell, web application servers, and various graphical user interface toolkits like Tkinter, awxPython, etc.
Note: For more information, refer to Python Matplotlib – An Overview
Pyplot is a Matplotlib module which provides a MATLAB-like interface. Matplotlib is designed to be as usable as MATLAB, with the ability to use Python and the advantage of being free and open-source.
Note: For more information, refer to Pyplot in Matplotlib
This function add the vertical lines across the axes of the plot
Syntax:matplotlib.pyplot.axvline(x=0, ymin=0, ymax=1, **kwargs)
Parameters:x : x position in data coordinates to place the vertical lineymin :vertical line starting position on y axis, it will take values between 0 and 1, 0 being bottom of the axis, 1 being top of the axisymax :vertical line ending position on y axis, it will take values between 0 and 1, 0 being bottom of the axis, 1 being top of the axis**kwargs :Other optional parameters to change the properties of the line, likechanging color, linewidth etc
Example-1:
# Importing matplotlib.pyplot as pltimport matplotlib.pyplot as plt    # Initialising values of x and yx =[0, 5, 10, 15, 20]y =[1, 3, 5, 6, 9]  # Plotting the graphplt.plot(x, y)  # Drawing red vertical line at# x = 2.5 starting at half the #length of y axis(ymin = 0.5) and #continuing till the end(ymax = 1)# And setting the color of line to redplt.axvline(x = 2.5, ymin = 0.5, ymax = 1,            color ='red')  plt.show()
Output :
Example-2 :
import matplotlib.pyplot as plt  x =[0, 5, 10, 15, 20]y =[1, 3, 5, 6, 9]  plt.plot(x, y)# Drawing vertical line from 25 % # of the y-axis length to 80 % # And also increasing the linewidthplt.axvline(x = 2.5, ymin = 0.25, ymax = 0.80,            linewidth = 8, color ='green')  plt.show()
Output:
Example-3 :
import matplotlib.pyplot as plt  x =[0, 5, 10, 15, 20]y =[1, 3, 5, 6, 9]  plt.plot(x, y)  # Drawing vertical line from 25 %# of the y-axis length to 75 % # And also changing the linestyleplt.axvline(x = 2.5, ymin = 0.25, ymax = 0.75,            linewidth = 4, linestyle ="--",            color ='red')  plt.show()
Output:
Python-matplotlib
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
Iterate over a list in Python
Python OOPs Concepts
How to print string with double quotes in Golang?

04 May, 2020
Whenever the user wants to double-quote a string, he can’t simply write the string within double quotes inside the fmt.Printf() command. This prints only the text written inside those quotes. To print the string along with quotes, he can use various methods including certain escape characters. There are different ways in Golang to print a string with double-quotes.
1) Quoting a string using %q:
Syntax:
fmt.Printf("%q", output)
package main  import "fmt"  func main() {    var result = "Welcome to GeeksforGeeks."    fmt.Printf("%q", result)}
Output:
"Welcome to GeeksforGeeks."
Explanation: In the above example, we used “%q” to display our string with double-quotes.
2) Quoting a string using an escape character “\”:
Syntax:
fmt.Println("\"string\"")
package main  import "fmt"  func main() {    fmt.Println("\"GeeksforGeeks is a computer science portal\"")}
Output:
"GeeksforGeeks is a computer science portal"
Explanation: In the above example, we used an escape character “\” to print a string with double-quotes. We can simply do so by adding a backslash(\) before the double-quotes.
3) Double quoting a string using a raw string lateral (`):
Syntax:
fmt.Println(`"string\"`)
package main  import "fmt"  func main() {    fmt.Println(`"GeeksforGeeks"`)}
Output:
"GeeksforGeeks"
Explanation: In the above example, we used a raw string lateral (`) to print a string with double-quotes.
Picked
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
fmt.Sprintf() Function in Golang With Examples
Arrays in Go
Golang Maps
How to Split a String in Golang?
Interfaces in Golang
Slices in Golang
Different Ways to Find the Type of Variable in Golang
How to convert a string in lower case in Golang?
How to Parse JSON in Golang?
How to Trim a String in Golang?
HTML | download Attribute

29 Apr, 2022
The HTML download Attribute is used to download the element when the user clicks on the hyperlink. It is used only when the href attribute is set. The downloaded file name will be the value of the attribute. The value of the attribute will be the name of the downloaded file. If the value is removed then original filename used.Uses: It is used in <a> and<area> Element. Syntax: 
<Element download="filename">
Attribute Values: It contains single value filename which is optional. It specifies the new filename for the downloaded file.
The below example illustrates the use of download attribute in anchor Element. Example:
html
<!DOCTYPE html><html>  <head>    <title>HTML a download Attribute</title>  </head>   <body>     <p>Click on image to download</p>       <p>      <a href="https://media.geeksforgeeks.org/wp-content/uploads/20190221234751/geeksforgeeks-logo1.png"        download      >        <img          src="https://media.geeksforgeeks.org/wp-content/uploads/20190221234751/geeksforgeeks-logo1.png"          alt="gfg"          width="500"          height="200"        />      </a>    </p>   </body></html>
Output: 
Supported Browsers: The browsers supported by download Attribute are listed below: 
Google Chrome
Internet Explorer
Firefox
Opera
 
hritikbhatnagar2182
chhabradhanvi
hellodnzk
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Restoring and Building with MSBuild

In this chapter, we will discuss how to restore and build your MSBuild (*.csproj) file using the command line utility. To see what commands are available in .NET Core 2.0 preview 1, let us run the following command.
dotnet help 

You will see all the commands like new, restore, build, etc.
Following is the default implementation in Program.cs file.
using System;  
namespace MSBuild { 
   class Program { 
      static void Main(string[] args) { 
         Console.WriteLine("Hello World!"); 
      } 
   } 
} 
Let us now execute the following command to see the progress.
dotnet build

You will see a lot of errors. These errors need to be rectified.
Let us now run the following command.
dotnet restore

You can see that all the packages are restored. Some new folders and files have also been generated.
To see the directory structure, let us run the following command.
tree /f 

Following is the directory structure −
Let us now rebuild the project running the following command again.
dotnet build

Now you project will build successfully without any error(s) and MSBuild.dll is also created.
To see the output, let us run the following command −
dotnet run 

You can see the following output on your console.
How to change the size of Form controls in Bootstrap ?

25 Nov, 2021
Bootstrap allows to change the size of form controls using .form-control classes. For default size .form-control is used, for smaller size we can use .form-control class along with .form-control-sm and for larger size we can use .form-control class along with .form-control-lg.
 For default size:
class="form-control"                            
For small size:
class="form-control form-control-sm"
For large size:
class="form-control form-control-lg"
Include Bootstrap and jQuery CDN into the <head> tag before all other stylesheets to load our CSS.
<link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css”> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js”></script> <script src=”https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js”></script> <script src=”https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js”></script>  
Add .form-control class for default size, .form-control-sm for small sized form control and .form-control-lg for large sized form control in the class of <input>tag
<input class=”form-control form-control-lg” type=”text” placeholder=”.form-control-lg” aria-label=”.form-control-lg example”> <input class=”form-control” type=”text” placeholder=”Default input” aria-label=”default input example”> <input class=”form-control form-control-sm” type=”text” placeholder=”.form-control-sm” aria-label=”.form-control-sm example”>  
HTML
<!DOCTYPE html><html>   <head>      <title>Bootstrap Form Control Size Example</title>      <!--Include Latest Bootstrap, jQuery and CSS CDN -->      <link rel="stylesheet"            href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">     </script>      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js">     </script>      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js">     </script>   </head>   <body style="padding:100px;">     <!-- Add class .form-control-lg after     .form-control to display large size form control-->     <input class="form-control form-control-lg"            type="text"            placeholder=".form-control-lg"            aria-label=".form-control-lg example">     <br>      <!-- Add class .form-control to display          default size form control-->     <input class="form-control" type="text"            placeholder="Default input"            aria-label="default input example">     <br>      <!-- Add class .form-control-sm after          .form-control to display small form control-->     <input class="form-control form-control-sm"            type="text"            placeholder=".form-control-sm"            aria-label=".form-control-sm example">   </body></html>
surindertarika1234
rajeev0719singh
Bootstrap-4
Bootstrap-Questions
HTML-Tags
Picked
Bootstrap
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python program to create dynamically named variables from user input - GeeksforGeeks

19 May, 2021
Given a string input, the task is to write a Python program to create a variable from that input (as a variable name) and to assign it some value. Below are the methods to create dynamically named variables from user input: 
Method 1: Using globals() method.
Python3
# Dynamic_Variable_Name can be# anything the user wantsDynamic_Variable_Name = "geek" # The value 2020 is assigned# to "geek" variableglobals()[Dynamic_Variable_Name] = 2020 # Display variableprint(geek)
Output:
2020
Method 2: Using locals() method.
Python3
# Dynamic_Variable_Name can be# anything the user wants.Dynamic_Variable_Name = "geek" # The value 2020 is assigned# to "geek" variablelocals()[Dynamic_Variable_Name] = 2020 # Display variableprint(geek)
Output:
2020
Method 3: Using exec() method.
Python3
# Dynamic_Variable_Name can be# anything the user wants.Dynamic_Variable_Name = "geek" # The value 2020 is assigned# to "geek" variableexec("%s = %d" % (Dynamic_Variable_Name, 2020)) # Display variableprint(geek)
Output:
2020
Method 4: Using vars() method
Python3
# Dynamic_Variable_Name can be# anything the user wants.Dynamic_Variable_Name = "geek" # The value 2020 is assigned# to "geek" variablevars()[Dynamic_Variable_Name] = 2020 # Display variableprint(geek)
Output:
2020
arorakashish0911
python-basics
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Python - Filter unequal elements of two lists corresponding same index - GeeksforGeeks

27 Dec, 2019
Sometimes, while working with Python data, we can have a problem in which we require to extract the values across multiple lists which are unequal and have similar index. This kind of problem can come in many domains. Let’s discuss certain ways in which this problem can be solved.
Method #1 : Using loop + zip()The combination of above functions can be used to solve this problem. In this, we extract combine the index elements using zip and then extract and check for dissimilarity using conditional statement in loop.
# Python3 code to demonstrate working of# Unequal Equi-index elements# using loop + zip()  # initialize liststest_list1 = ["a", "b", "c", "d"]test_list2 = ["g", "b", "s", "d"]  # printing original listsprint("The original list 1 : " + str(test_list1))print("The original list 2 : " + str(test_list2))  # Unequal Equi-index elements# using loop + zip()res = []for i, j in zip(test_list1, test_list2):    if i != j:        res.append(i)  # printing resultprint("Unequal index elements in lists : " + str(res))
The original list 1 : ['a', 'b', 'c', 'd']
The original list 2 : ['g', 'b', 's', 'd']
Unequal index elements in lists : ['a', 'c']

 
Method #2 : Using zip() + list comprehensionCombination of these functionalities can also be used to solve this problem. In this, we use similar method as above, just a shorthand logic compressed using list comprehension.
# Python3 code to demonstrate working of# Unequal Equi-index elements# using list comprehension + zip()  # initialize liststest_list1 = ["a", "b", "c", "d"]test_list2 = ["g", "b", "s", "d"]  # printing original listsprint("The original list 1 : " + str(test_list1))print("The original list 2 : " + str(test_list2))  # Unequal Equi-index elements# using list comprehension + zip()res = [i for i, j in zip(test_list1, test_list2) if i != j]  # printing resultprint("Unequal index elements in lists : " + str(res))
The original list 1 : ['a', 'b', 'c', 'd']
The original list 2 : ['g', 'b', 's', 'd']
Unequal index elements in lists : ['a', 'c']

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Add array elements in Ruby - GeeksforGeeks

20 Jul, 2021
In this article, we will learn how to add elements to an array in Ruby.Method #1: Using Index 
Ruby
# Ruby program to add elements # in array   # creating string using []str = ["GFG", "G4G", "Sudo", "Geeks"]   str[4] = "new_ele";print str # in we skip the elementsstr[6] = "test";
Output:
["GFG", "G4G", "Sudo", "Geeks", "new_ele"]

["GFG", "G4G", "Sudo", "Geeks", "new_ele", nil, "test"]
Method #2: Insert at next available index (using push() method) –
Ruby
# Ruby program to add elements # in array   # creating string using []str = ["GFG", "G4G", "Sudo", "Geeks"]   str.push("Geeksforgeeks")print str
Output:
 ["GFG", "G4G", "Sudo", "Geeks", "Geeksforgeeks"] 
Method #3: Using << syntax instead of the push method – 
Ruby
# Ruby program to add elements # in array   # creating string using []str = ["GFG", "G4G", "Sudo", "Geeks"]   str << "Geeksforgeeks"print str
Output:
 ["GFG", "G4G", "Sudo", "Geeks", "Geeksforgeeks"] 
Method #4: Add element at the beginning –  
Ruby
# Ruby program to add elements # in array   # creating string using []str = ["GFG", "G4G", "Sudo", "Geeks"]   str.unshift("ele_1")print str
Output:
 ["ele_1", "GFG", "G4G", "Sudo", "Geeks"] 
 
surinderdawra388
Ruby Array
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Include v/s Extend in Ruby
Global Variable in Ruby
Ruby | Hash delete() function
Ruby | Types of Variables
Ruby | Enumerator each_with_index function
Ruby | Case Statement
Ruby | Array select() function
Ruby | Data Types
Ruby | Numeric round() function
Ruby | String capitalize() Method
mailx in Linux - GeeksforGeeks

24 Jul, 2020
Linux has an inbuilt Mail User Agent program called mailx. As the name suggests, it is a console application that is used for sending and receiving emails. The mailx utility is an enhanced version of the mail command. Along with the functionality provided by the original mail command, it provides extra features like the ability to send attachments by using the -a flag.  The mailx command is available from a variety of different packages: 
bsd-mailx 
heirloom-mailx 
mailutils  
For Ubuntu/Debian: 
sudo apt-get install bsd-mailx

For fedore/centos:  
sudo yum install mailx

Note: Even though the mailx command is a newer version of the original mail utility, it can still be referenced with the ‘mail’ keyword.  
1. Writing the message directly in the command line: To send a simple email, use the “-s” flag to set the subject in quotes which is followed by the email of the receiver. After this, mailx waits for the content of the email. To enter new lines, keep hitting enter. After the content is written, press Ctrl+D & EOT will be displayed by mailx.  
$ mail -s "A mail sent using mailx" person@example.com
Hey person,
Hope you're fine these days
Thanks
EOT

2.  Taking the message from a file 
$ mail -s "A mail sent using mailx" person@example.com < /path/to/file

3.  Using pipes 
$ echo "Example Message" | mail - s "A mail sent using mailx" person@example.com

4. Sending same Mail to Multiple Recipients: We can send the same email to multiple receivers (not by cc or bcc) as follows: 
$ mail - s "A mail sent using mailx" personONE@example.com, personTWO@example.com < /path/to/file

5. Adding CC & BCC 
We can send a carbon copy (CC) or a blind carbon copy (BCC) to send the same email to multiple recipients (visibly or in a hidden manner). For CC, we use the “-c” option & for BCC we use the “-b” option which is followed by the email addresses. 
$ mail - s "A mail sent using mailx" personONE@example.com -c personTWO@example.com -b personTHREE@example.com 

6. Adding AttachmentsAttachments are a vital part of email communication. We can attach documents, images, text files, etc. by using the “-a” option followed by the path of the file that we want to attach. 
$ mail - s "A mail sent using mailx" personONE@example.com -a Attachment.txt

Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scp command in Linux with Examples
mv command in Linux with examples
Docker - COPY Instruction
SED command in Linux | Set 2
chown command in Linux with Examples
nohup Command in Linux with Examples
Named Pipe or FIFO with example C program
Thread functions in C/C++
uniq Command in LINUX with examples
Start/Stop/Restart Services Using Systemctl in Linux
Python - Draw Octagonal shape Using Turtle Graphics - GeeksforGeeks

19 Oct, 2020
In this article, we will learn how to Make an Octagon using Turtle Graphics in Python. For that lets first know what is Turtle Graphics.
backward(length): moves the pen in the backward direction by x unit.
right(angle): rotate the pen in the clockwise direction by an angle x.
left(angle): rotate the pen in the anticlockwise direction by an angle x.
penup(): stop drawing of the turtle pen.
pendown(): start drawing of the turtle pen.
Import the turtle modules.
Get a screen to draw on
Define an instance for the turtle.
For a drawing, an Octagon executes a loop 8 times.
In every iteration move the turtle 100 units forward and move it left 45 degrees( corresponding to 135 degrees between two sides, so 180-135=45 degrees).
This will make up an angle of 135 degrees between 2 sides.
8 iterations will make up an Octagon perfectly. Below is the Python implementation of the above approach:
Python3
# import for turtle moduleimport turtle # making a workScreenws = turtle.Screen() # defining a turtle instancegeekyTurtle = turtle.Turtle() # iterating the loop 8 timesfor i in range(8):       # moving turtle 100 units forward    geekyTurtle.forward(100)         # turning turtle 45 degrees so    # as to make perfect angle for an octagon    geekyTurtle.left(45)
Output:
Octagon
anshitaagarwal
Python-turtle
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
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
Lodash _.intersectionWith() Method - GeeksforGeeks

22 Jul, 2020
Lodash is a JavaScript library that works on the top of Underscore.js. Lodash helps in working with arrays, strings, objects, numbers etc.The _.intersectionwith() method is used to take the intersection of the one or more arrays. It is same as the intersection function in lodash only difference is that it accepts a comparator which is invoked to compare elements of arrays.
Syntax:
intersectionWith([arrays], [comparator])
Parameter: This method accepts two parameters as mention above and describe below:
arrays: It takes an array as a parameter.
comparator: It is the function that iterates over each value of the array and compares the values with the given comparator function.
Return Value: It returns the array after intersection of arrays.
Note: Please install lodash module by using command npm install lodash before using the code given below. 
Example 1: 
Javascript
// Requiring the lodash libraryconst _ = require("lodash");  // Original arraylet array1 = [    { "a": 1 }, { "b": 2 },    { "b": 2, "a": 1 }]  let array2 = [    { "a": 1, "b": 2 },    { "a": 1 }]  // Using _.intersectionWith() methodlet newArray = _.intersectionWith(    array1, array2, _.isEqual);  // Printing original Arrayconsole.log("original Array1: ", array1)console.log("original Array2: ", array2)  // Printing the newArrayconsole.log("new Array: ", newArray)
Output:
Example 2: When not using comparator function i.e. _.isequal() then output is empty array.
Javascript
// Requiring the lodash libraryconst _ = require("lodash");  // Original arraylet array1 = [    { "a": 1 }, { "b": 2 },    { "b": 2, "a": 1 }]  let array2 = [    { "a": 1, "b": 2 },    { "a": 1 }]  // Using _.intersectionWith() method// and no comparator functionlet newArray = _.intersectionWith(    array1, array2);  // Printing original Arrayconsole.log("original Array1: ", array1)console.log("original Array2: ", array2)  // Printing the newArrayconsole.log("new Array: ", newArray)
Output:
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
How to Synchronize HashMap in Java? - GeeksforGeeks

28 Dec, 2020
HashMap is part of the Collection’s framework of java. It stores the data in the form of key-value pairs.  These values of the HashMap can be accessed by using their respective keys. The key-value pairs can be accessed using their indexes (of Integer type).
HashMap is similar to HashTable in java. The main difference between HashTable and HashMap is that HashTable is synchronized but HashMap is not synchronized. Also, a HashMap can have one null key and any number of null values. The insertion order is not preserved in the HashMap.
Synchronization means controlling the access of multiple threads to any shared resource. A synchronized resource can be accessed by only one thread at a time.
HashMap can be synchronized using the Collections.synchronizedMap() method.
The synchronizedMap() method of java.util.Collections class is used to return a synchronized (thread-safe) map backed by the specified map. In order to guarantee serial access, it is critical that all access to the backing map is accomplished through the returned map.
Syntax:
public static <K, V> Map<K, V> synchronizedMap(Map<K, V> m)
Parameters: This method takes the map as a parameter to be “wrapped” in a synchronized map.
Return Value: This method returns a synchronized view of the specified map.
Code:
Java
// Java program to demonstrate// synchronization of HashMap  import java.util.*;  public class GFG {    public static void main(String[] argv) throws Exception    {          try {            // create a HashMap object            Map<String, String> hMap                = new HashMap<String, String>();                        // add elements into the Map            hMap.put("1", "Welcome");            hMap.put("2", "To");            hMap.put("3", "Geeks");            hMap.put("4", "For");            hMap.put("5", "Geeks");                        System.out.println("Map : " + hMap);                        // Synchronizing the map            Map<String, String> sMap                = Collections.synchronizedMap(hMap);              // printing the Collection            System.out.println("Synchronized map is : "                               + sMap);        }          catch (IllegalArgumentException e)         {            System.out.println("Exception thrown : " + e);        }    }}
Map : {1=Welcome, 2=To, 3=Geeks, 4=For, 5=Geeks}
Synchronized map is : {1=Welcome, 2=To, 3=Geeks, 4=For, 5=Geeks}
Java-HashMap
Picked
Technical Scripter 2020
Java
Java Programs
Technical Scripter
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
Java Programming Examples
Convert Double to Integer in Java
Implementing a Linked List in Java using Class
How to Iterate HashMap in Java?
Iterate through List in Java
Ruby | String inspect Method - GeeksforGeeks

09 Dec, 2019
inspect is a String class method in Ruby which is used to return a printable version of the given string, surrounded by quote marks, with special characters escaped.
Syntax: str.inspect
Parameters:
Returns: Here, str is the given string.
Example 1:
# Ruby program to demonstrate # the inspect method        # Taking a string and # using the methodputs "Sample".inspectputs "Articles".inspect
Output:
"Sample"
"Articles"

Example 2:
# Ruby program to demonstrate # the inspect method        # Taking a string and # using the methodputs "Ru \n y".inspectputs "Ar\b\\bcles".inspect
Output:
"Ru \n y"
"Ar\b\\bcles"

Ruby String-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Ruby | Array count() operation
Include v/s Extend in Ruby
Global Variable in Ruby
Ruby | Hash delete() function
Ruby | Types of Variables
Ruby | Enumerator each_with_index function
Ruby | Case Statement
Ruby | Array select() function
Ruby | Data Types
Ruby | Numeric round() function
JavaScript Date getDay() Method - GeeksforGeeks

12 Oct, 2021
Below is the example of Date getDay() method.  
Example:  
javascript
<script>    // Here a date has been assigned    // while creating Date object    var A = new Date('October 15, 1996 05:35:32');     // Day of the week from above Date Object is    // being extracted using getDay()    var Day = A.getDay();     // Printing day of the week    document.write("Number of Day: " +Day);</script>                   
 
Output:  
Number of Day: 2
The date.getDay() method is used to fetch the day of a week(0 to 6) from a given Date object.Syntax:  
DateObj.getDay()
Parameter: This method does not accept any parameters.Return Values: It returns the day of the week for the given date. Day of the week will be returned in the form of integer value ranging from 0 to 6 means 0 for Sunday, 1 for Monday, and so on till 6 for Saturday.More codes for the above method are as follows:Program 1: If the date of the month is not given, by default the function considers it as the first date of the month and hence accordingly it returns the day of the week. It is an exceptional case.  
javascript
<script>  // Here a date has been assigned  // While creating a Date object  var A = new Date('July 1974');    var B = A.getDay();    // Printing day  document.write("Number of Day: "+B);</script>                   
Output:  
Number of Day: 1
Program 2: The date of the month should must lie in between 1 to 31 because none of the month have date greater than 31 that is why it returns NaN i.e, not a number because date for the month does not exist.  
javascript
<script>  // Here a date has been assigned  // while creating Date object  var A = new Date('October 35, 1996 05:35:32');   // Day of the week from above Date Object  // is being extracted using getDay()  var B = A.getDay();   // Printing day of the week.  document.write(B);</script>
Output:  
NaN
Program 3: If nothing as parameter is given, it returns current day of the current week.  
javascript
<script>  // Creating Date Object  var A = new Date();   // day of the week from above object  // is being extracted using getDay().  var B = A.getDay()   // Printing day of the week.  document.write(B);</script>
Output:  
5
Supported Browsers: The browsers supported by JavaScript Date getDay() method are listed below:  
Google Chrome 1 and above
Edge 12 and above
Firefox 1 and above
Internet Explorer 3 and above
Opera 3 and above
Safari 1 and above
 
Akanksha_Rai
ysachin2314
javascript-date
javascript-functions
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
Cards in React-Bootstrap - GeeksforGeeks

16 Feb, 2021
Introduction: React-Bootstrap is a front-end framework that was designed keeping react in mind. Bootstrap was re-built and revamped for React, hence it is known as React-Bootstrap. Cards are a type of section or containers which consists of information in a structured and organized way. 
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 required modules using the following command.
Properties: The Card component has many properties that we can use to organize data. In below table, the properties are explained
Title: It acts as a title for the card.
SubTitle: It acts as a subtitle for the mentioned title.
Text: In this section, we will mention all the necessary data.
Link: This property is used to add the links for our cards.
npm install react-bootstrap bootstrap
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 Card from "react-bootstrap/Card";import React from "react";  export default function App() {  return (    <>      <Card style={{ width: "22rem" }}>        <Card.Body>          <Card.Title style={{ color: "green" }}>GEEKSFORGEEKS</Card.Title>          <Card.Subtitle className="mb-2 text-muted">            One Stop For all CS subjects          </Card.Subtitle>          <Card.Text>            GeeksforGeeks provides a platform for all the students to study            about all the subjects in CSE.          </Card.Text>          <Card.Link href="#"> For Students</Card.Link>        </Card.Body>      </Card>    </>  );}
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.
Picked
React-Bootstrap
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to apply style to parent if it has child with CSS?
How to execute PHP code using command line ?
Difference Between PUT and PATCH Request
REST API (Introduction)
How to redirect to another page in ReactJS ?
HTML | <input> Hidden attribute - GeeksforGeeks

28 Oct, 2020
The HTML input hidden attribute is used to define the visibility of Input field elements. It contains a boolean value. If this attribute is used then browsers will not display elements that have the hidden attribute specified. The hidden attribute can be seen using some condition or JavaScript used to see the hidden content.
Syntax:
<input hidden>
Example:
<!DOCTYPE html><html>  <head>    <title>input hidden attribute</title>    <style>        body {            text-align: center;        }                  h1 {            color: green;        }    </style></head>  <body>    <h1>GeeksforGeeks</h1>    <h2>HTML <input>hidden attribute</h2>      <!-- hidden attribute -->    <input type="text" hidden>  </body>  </html>
Output:
Supported Browsers: The browsers supported by <input> Hidden attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Apple Safari
Opera
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
arorakashish0911
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript