code-rag-bench/online-tutorials huggingface dataset:
How to inverse a vector in MATLAB?

27 Jan, 2022
In this article, we are going to discuss the “Inversion of a vector” in MATLAB which can be done in three different approaches that are illustrated below:
The flipud() function is used for flipping the specified vector’s elements.
Syntax:
flipud(A)
Here, flipud(A) function is used to return a vector with reversed elements of the same length of the specified vector “A”.
Example 1:
Matlab
% MATLAB code for inverse a% vector using flipud()% Initializing a vector of some elementsv = [10;9;8;7;6;5] % Calling the flipud() function% over the above vector "v" to% reverse its elementsflipud(v)
Output:
Example 2:
Matlab
% MATLAB code for inverse vector using flip()% Initializing a 2*2 cell array of charactersA = {'a' 'b'; 'c' 'd'} % Calling the flipud() function% over the above cell array to% reverse its elementsflipud(A)
Output: 
The fliplr() function is used for flipping the specified row vector’s elements. 
Syntax:’
fliplr(A)
Here, fliplr(A) function is used to return a vector with reversed elements of the same length of the specified row vector “A”.
Example 1:
Matlab
% MATLAB code for fliplr()% Initializing a row vectorv = 10:20 % Calling the fliplr() function% over the above vector "v" to% reverse its elementsfliplr(v)
Output:
Example 2:
Matlab
% MATLAB code for fliplr()% Initializing a 2*2 cell% array of charactersA = {'a' 'b'; 'c' 'd'} % Calling the fliplr() function% over the above cell array "A" to% reverse its elementsfliplr(A)
Output:
The end keyword in MATLAB is used for  either finding a row or column index to reference the last element,
Example 1:
Matlab
% MATLAB code for find inverse% of vector using end keyword% Initializing a vector of some elementsv = [10;9;8;7;6;5] % Reversing the above vector's elementsv(end:-1:1)
Output:
Example 2:
Matlab
% MATLAB code for find inverse% of vector using end keyword% Initializing a row vectorv = 10:20 % Reversing the above vector's elementsv(end:-1:1)
Output: 
simranarora5sos
MATLAB Vector-Programs
MATLAB-programs
MATLAB
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL – CONCAT_WS Function

08 Oct, 2021
In PostgreSQL, the CONCAT_WS function is used to concatenate strings with a separator. Like the CONCAT function, the CONCAT_WS function is also variadic and ignored NULL values.
The following illustrates the syntax of the CONCAT_WS function.
Syntax: CONCAT_WS(separator, string_1, string_2, ...);
Let’s analyze the above syntax:
The separator is a string that is used to separate the resultant strings.
The string_1, string_2, are strings that is to be converted.
The CONCAT_WS function returns a combined string that is the combination of string_1, string_2, etc., separated by the separator.
Example 1:
The following statement concatenates the symbols (ie, ^,+,-,/):
SELECT CONCAT_WS ('^^^', '+++ ', '---', '///');
Output:
Example 2:
The below statement uses the CONCAT_WS function to concatenate three strings into one:
SELECT
 CONCAT_WS ('***', 'geeks ', 'for', 'geeks');
Output:
sooda367
PostgreSQL-function
PostgreSQL-String-function
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL - LIMIT with OFFSET clause
PostgreSQL - REPLACE Function
PostgreSQL - DROP INDEX
PostgreSQL - INSERT
PostgreSQL - TIME Data Type
PostgreSQL - ROW_NUMBER Function
PostgreSQL - CREATE SCHEMA
PostgreSQL - EXISTS Operator
PostgreSQL - LEFT JOIN
PostgreSQL - SELECT
SQL COUNT(), AVG() and SUM()

13 Aug, 2020
SQL COUNT() Function :The COUNT() function provides the number of rows that matches a specified condition.COUNT() Syntax –SELECT COUNT(column_name)
FROM table_name
WHERE condition; SQL AVG() Function :The AVG() function provides the average value of a numeric column.AVG() Syntax –SELECT AVG(column_name)
FROM table_name
WHERE condition;
SQL SUM() Function :The SUM() function provides the total sum of a numeric column.SUM() Syntax –SELECT SUM(column_name)
FROM table_name
WHERE condition;

SQL COUNT() Function :The COUNT() function provides the number of rows that matches a specified condition.COUNT() Syntax –SELECT COUNT(column_name)
FROM table_name
WHERE condition; 
COUNT() Syntax –
SELECT COUNT(column_name)
FROM table_name
WHERE condition; 
SQL AVG() Function :The AVG() function provides the average value of a numeric column.AVG() Syntax –SELECT AVG(column_name)
FROM table_name
WHERE condition;

AVG() Syntax –
SELECT AVG(column_name)
FROM table_name
WHERE condition;

SQL SUM() Function :The SUM() function provides the total sum of a numeric column.SUM() Syntax –SELECT SUM(column_name)
FROM table_name
WHERE condition;

SUM() Syntax –
SELECT SUM(column_name)
FROM table_name
WHERE condition;

Let us assume, we have a table “GeeksTab”.
COUNT() Example :The following SQL statement finds the number of Names in the “GeeksTab” table :SELECT COUNT(Name)
FROM GeeksTab; Output –7 AVG() Example :The following SQL statement finds the average price of salary in the “GeeksTab” table :SELECT AVG(Salary)
FROM GeeksTab; Output –6300 SUM() Example :The following SQL statement will find the sum of the Salary in the “GeeksTab” table :SELECT SUM(Salary)
FROM GeeksTab; Output –44100 
COUNT() Example :The following SQL statement finds the number of Names in the “GeeksTab” table :SELECT COUNT(Name)
FROM GeeksTab; Output –7 
SELECT COUNT(Name)
FROM GeeksTab; 
Output –
7 
AVG() Example :The following SQL statement finds the average price of salary in the “GeeksTab” table :SELECT AVG(Salary)
FROM GeeksTab; Output –6300 
SELECT AVG(Salary)
FROM GeeksTab; 
Output –
6300 
SUM() Example :The following SQL statement will find the sum of the Salary in the “GeeksTab” table :SELECT SUM(Salary)
FROM GeeksTab; Output –44100 
SELECT SUM(Salary)
FROM GeeksTab; 
Output –
44100 
DBMS-SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Sub queries in From Clause
Window functions in SQL
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
What is Temporary Table in SQL?
SQL using Python
RANK() Function in SQL Server
SQL Query to Convert VARCHAR to INT
SQL Query to Convert Rows to Columns in SQL Server
SQL Query to Compare Two Dates
PyQt5 QColorDialog – Setting Background Color

25 May, 2021
In this article we will see how we can set background color to the QColorDialog. QColorDialog is the pop up type widget in the PyQt5 used for selecting and creating colors. Color dialog is a huge widget that consists of lots of child widgets so it become tough to set stylesheet to the color dialog as it is a complex widget, below is how the background color to the QColorDialog widget looks like 
In order to do this we have to set the stylesheet to the QColorDialog object with the help of setStyleSheet method, below is the style sheet code  
background-color : lightgreen;
Below is the implementation  
Python3
# importing librariesfrom PyQt5.QtWidgets import *from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import *from PyQt5.QtCore import *import sys  class Window(QMainWindow):     def __init__(self):        super().__init__()         # setting title        self.setWindowTitle("Python ")         # setting geometry        self.setGeometry(100, 100, 500, 400)         # calling method        self.UiComponents()         # showing all the widgets        self.show()      # method for components    def UiComponents(self):         # creating a QColorDialog object        dialog = QColorDialog(self)         # setting custom colors        dialog.setCustomColor(1, Qt.red)        dialog.setCustomColor(2, Qt.green)        dialog.setCustomColor(3, Qt.yellow)        dialog.setCustomColor(4, Qt.blue)         # creating label        label = QLabel("Geeks for Geeks", self)         label.setAlignment(Qt.AlignCenter)         # making label multi line        label.setWordWrap(True)         # setting stylesheet of the label        label.setStyleSheet("QLabel"                            "{"                            "border : 5px solid black;"                            "}")          # getting the custom color        color = dialog.customColor(4)         # setting graphic effect to the label        graphic = QGraphicsColorizeEffect(self)         # setting color to the graphic        graphic.setColor(color)         # setting graphic to the label        label.setGraphicsEffect(graphic)         # adding label to the color dialog        layout = dialog.layout()        layout.addWidget(label)        dialog.setLayout(layout)         # setting style sheet to the color dialog        # adding background color        dialog.setStyleSheet("background-color : lightgreen;")         print(dialog.children())         # executing the color dialog        dialog.exec_()         # deleting the main window        self.deleteLater()   # create pyqt5 appApp = QApplication(sys.argv) # create the instance of our Windowwindow = Window() # start the appsys.exit(App.exec())
Output :  
 
anikakapoor
Python PyQt-QColorDialog
Python-gui
Python-PyQt
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
How to Install PIP on Windows ?
Python String | replace()
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
Changing row and column values of a Matrix in R Language - sweep() function - GeeksforGeeks

23 Dec, 2021
In this article, we will learn changing row and column values of a Matrix in R Programming Language.
sweep() function in R Language is used to apply the operation “+ or -” to the row or column in data matrix. It is used to sweep the values from the data-framework.
Syntax: sweep(x, MARGIN, STATS, FUN)
Parameters: 
x: Typically a matrix.
MARGIN: MARGIN = 1 means row; MARGIN = 2 means column.
STATS: the value that should be added or subtracted
FUN: The operation that has to be done (e.g. + or -)
Example 1: Sweep Matrix  
R
# R program to illustrate# sweep matrix # Create example matrixdata <- matrix(0, nrow = 6, ncol = 4) # Apply sweep in Rdata_ex1 <- sweep(x = data, MARGIN = 1,                  STATS = 5, FUN = "+") # Print example 1print(data_ex1)
Output: 
     [,1] [,2] [,3] [,4]
[1,]    5    5    5    5
[2,]    5    5    5    5
[3,]    5    5    5    5
[4,]    5    5    5    5
[5,]    5    5    5    5
[6,]    5    5    5    5
Here in the above code, the value of the matrix was 0, which was then swept by the sweep() function and the new value of the matrix became 5.
Example 2: Using sweep() with stats  
R
# R program to illustrate# sweep function with stats # Create example matrixdata <- matrix(0, nrow = 6, ncol = 4) # Sweep with Complex STATSdata_ex2 <- sweep(x = data, MARGIN = 1,                STATS = c(1, 2, 3, 4, 5, 6),                  FUN = "+") # Print example 2print(data_ex2)
Output: 
     [,1] [,2] [,3] [,4]
[1,]    1    1    1    1
[2,]    2    2    2    2
[3,]    3    3    3    3
[4,]    4    4    4    4
[5,]    5    5    5    5
[6,]    6    6    6    6
Here in the above example, we have used the sweep() function along with the stats. 
adnanirshad158
kumar_satyam
Programming Language
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Top 10 Programming Languages to Learn in 2022
Decorators with parameters in Python
Shallow Copy and Deep Copy in C++
C# | Data Types
Difference between Shallow and Deep copy of a class
Change column name of a given DataFrame in R
How to Replace specific values in column in R DataFrame ?
Filter data by multiple conditions in R using Dplyr
Adding elements in a vector in R programming - append() method
Loops in R (for, while, repeat)
When to use tuples in C#?

Tuples are used when you want to return multiple values from a method without using ref or out parameters.
Tuples are used to pass multiple values to a method through a single parameter. Tuples can also be nested together
Passig Tuples as a Parameter
class Program{
   static void DisplayTupleValues(Tuple<int, string, string> dummy){
      Console.WriteLine($"Id = { dummy.Item1}");
      Console.WriteLine($"Value1 = { dummy.Item2}");
      Console.WriteLine($"Value2 = { dummy.Item3}");
   }
   static void Main(){
      var dummy = Tuple.Create(1, "Dummy", "Tuple");
      DisplayTupleValues(dummy);
      Console.ReadLine();
   }
}
Id = 1
Value1 = Dummy
Value2 = Tuple
Tuple as a return type
class Program{
   static Tuple<int, string, string> ReturnTuple(){
      return Tuple.Create(1, "Value1", "Value2");
   }
   static void Main(){
      var returnValues = ReturnTuple();
      System.Console.WriteLine($"{returnValues.Item1} {returnValues.Item2}
      {returnValues.Item3}");
      Console.ReadLine();
   }
}
1 Value1 Value2
Differences between Pure and Slotted Aloha - GeeksforGeeks

09 May, 2019
Prerequisite – Computer Network | Multiple Access ProtocolsAloha is the type of Random access protocol, It have two types one is Pure Aloha and another is Slotted Aloha.In Pure Aloha, Stations transmit whenever data is available at arbitrary times and Colliding frames are destroyed. While In Slotted aloha, A station is required to wait for the beginning of the next slot to transmit. vulnerable period is halved as opposed to pure Aloha.
Now, we shall see the difference between these Protocols:
= G x e-2G
= G x e-G
= 18.4%
= 36.8%
Computer Networks
Difference Between
GATE CS
Computer Networks
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
RSA Algorithm in Cryptography
TCP Server-Client implementation in C
Differences between TCP and UDP
Socket Programming in Python
Data encryption standard (DES) | Set 1
Difference between BFS and DFS
Class method vs Static method in Python
Differences between TCP and UDP
Difference between var, let and const keywords in JavaScript
Difference between Process and Thread
Is it possible to change values of the array when doing foreach() in javascript?

Yes it is possible to change values of the array when doing foreach() in
javascript.
Let us take an example to see this −
let arr = [1, 2, 3, 4];
arr.forEach((val, index) => arr[index] = val * val);
console.log(arr);
This will give the output −
[ 1, 4, 9, 16 ]
We've modified the actual array here when iterating over it using forEach.
Foundation - The Grid

Foundation grid system scales up to 12 columns through the page. Grid systems are used to create page layouts through a series of rows and columns that house your content.
The following table tells briefly about how the Foundation grid system works in multiple devices.
The following is the basic structure of a Foundation grid −
<div class = "row">
   <div class = "small-*"></div>
   <div class = "medium-*"></div>
   <div class = "large-*"></div>
</div>

<div class = "row">
   ...
</div>
First, create a row class to create horizontal groups of columns.
First, create a row class to create horizontal groups of columns.
Content should be placed within the columns, and only columns may be the immediate children of rows.
Content should be placed within the columns, and only columns may be the immediate children of rows.
Grid columns are created by specifying the number of twelve available columns you wish to span. For example, for four equal columns we would use .large-3
Grid columns are created by specifying the number of twelve available columns you wish to span. For example, for four equal columns we would use .large-3
The following are the three classes used in the Foundation grid system −
The large-* classes is used for the large devices.
The medium-* class is used for the medium devices.
small-* class is used for the small devices.
The following are the advanced grid formats used in Foundation.
The column and row classes are used on the same element to get the full width column to use as a container.
We can nest the grid columns inside another columns.
Using large-offset-* or small-offset-* class, you can move the columns to the right.
Foundation floats the last element automatically to the right when the rows do not include columns up to 12.
Using the media query size, the collapse and uncollapse classes are included to the row element to show the paddings.
By including the class small-centered in the column, you can make the column at the center.
Source ordering class is used to shift the columns between the breakpoint.
Block-grid is used to split the content.
Using the set of SASS mixins, a grid CSS is generated which is used to build your own semantic grid. For more information click here
The following are the SASS reference for grid used in Foundation.
Using the sass variables we can modify the default styles of this component.
The final CSS output is build using the mixin.

    117 Lectures 
     5.5 hours 

 Shakthi Swaroop

    61 Lectures 
     1.5 hours 

 Hans Weemaes

    17 Lectures 
     4 hours 

 Stephen Kahuria

    8 Lectures 
     50 mins

 Zenva

    28 Lectures 
     2 hours 

 Sandra L

    16 Lectures 
     2.5 hours 

 GreyCampus Inc.
 Print
 Add Notes
 Bookmark this page
numpy string operations | count() function - GeeksforGeeks

23 Jan, 2019
numpy.core.defchararray.count(arr, sub, start=0, end=None) is another function for doing string operations in numpy.It returns an array with the number of non-overlapping occurrences of substring sub in the range start to end.
Parameters:arr : array_like of str or unicode.sub : [str or unicode] The substring which to be searched.start : [ int, optional] The starting location in each string.end : [ int, optional] The ending location in each string.
Returns : [ndarray] the number of non-overlapping occurrences of substring sub.
Code #1 :
# Python program explaining# numpy.char.count() method   # importing numpy as geekimport numpy as geek  # input arrays  in_arr = geek.array(['Sayantan', '  Sayan  ', 'Sayansubhra'])print ("Input array : ", in_arr)   # output arrays out_arr = geek.char.count(in_arr, sub ='an')print ("Output array: ", out_arr) 
Input array :  ['Sayantan' ' Sayan ' 'Sayansubhra']
Output array:  [2 1 1]


 Code #2 :
# Python program explaining# numpy.char.count() method   # importing numpy as geekimport numpy as geek  # input arrays  in_arr = geek.array(['Sayantan', '  Sayan  ', 'Sayansubhra'])print ("Input array : ", in_arr)   # output arrays out_arr = geek.char.count(in_arr, sub ='a', start = 1, end = 8)print ("Output array: ", out_arr) 
Input array :  ['Sayantan' ' Sayan ' 'Sayansubhra']
Output array:  [3 2 2]

Python numpy-String Operation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python program to convert a list to string
Reading and Writing to text files in Python
sum() function in Python
Create a Pandas DataFrame from Lists
Difference between static and constant function in C++ - GeeksforGeeks

04 May, 2021
Static Function: It is a member function that is used to access only static data members. It cannot access non-static data members not even call non-static member functions. It can be called even if no objects of the class exist. It is also used to maintain a single copy of the class member function across different objects of the class.
Program 1:
C++
// C++ program to illustrate the use// of static function#include "bits/stdc++.h"using namespace std;  class A {public:    static void f()    {        cout << "GeeksforGeeks!";    }};  // Driver Codeint main(){    A::f();}
GeeksforGeeks!

Constant Function: It is a function that is generally declared as constant in the program. It also guarantees that it will not allow modifying objects or call any non-const member functions. It specifies that function is a read-only function and does not modify the object for which it is called.  
Program 2:
C++
// C++ program to illustrate the use// of const keyword  #include <iostream>using namespace std;  // Driver Codeint main(){    const double a = 1;      // Using the below line of code    // gives error    // a = 2.21;      cout << a << endl;      return 0;}
1

Tabular Difference between static function and constant function:  
Static Function
Constant Function
C++-Static Keyword
Functions
C++
C++ Programs
Functions
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Iterators in C++ STL
Operator Overloading in C++
Friend class and function in C++
Polymorphism in C++
Inline Functions in C++
Header files in C/C++ and its uses
How to return multiple values from a function in C or C++?
C++ Program for QuickSort
C++ program for hashing with chaining
delete keyword in C++
Algorithms | Bit Algorithms | Question 1 - GeeksforGeeks

28 Jun, 2021
What is the return value of following function for arr[] = {9, 12, 2, 11, 2, 2, 10, 9, 12, 10, 9, 11, 2} and n is size of this array.
int fun(int arr[], int n){    int x = arr[0];    for (int i = 1; i < n; i++)        x = x ^ arr[i];    return x;}
(A) 0(B) 9(C) 12(D) 2Answer: (B)Explanation: Note that 9 is the only element with odd occurrences, all other elements have even occurrences.
If the input array has all elements with even occurrences except one, then the function returns the only element with odd occurrences. Note that XORing an element with itself results 0 and XOR of 0 with a number x is equal to x.
Try following complete program.
# include <iostream>
using namespace std;

int fun(int arr[], int n)
{
    int x = arr[0];
    for (int i = 1; i < n; i++)
        x = x ^ arr[i];
    return x;
}

int main()
{
  int arr[] = {9, 12, 2, 11, 10, 9, 12, 10, 9, 11, 2};
  int n = sizeof(arr)/sizeof(arr[0]);
  cout << fun(arr, n) << endl;
  return 0;
}
Quiz of this Question
Algorithms-Bit Algorithms
Bit Algorithms
Algorithms Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Algorithms | Backtracking | Question 1
Algorithms | Dynamic Programming | Question 2
Algorithms | Analysis of Algorithms | Question 12
Algorithms | Greedy Algorithms | Question 1
Algorithms Quiz | Dynamic Programming | Question 8
Algorithms | Dynamic Programming | Question 3
Algorithms | Sorting | Question 11
Algorithms | Dynamic Programming | Question 7
Algorithms | Sorting | Question 1
Algorithms | Graph Traversals | Question 12
C# program to find the index of a word in a string

Declare and initialize an array −
string[] str = new string[] {
   "Cat",
   "Mat",
   "Rat"
};
Now, ue IndexOf() method to find the index of the word “Mat” −
Array.IndexOf(str, "Mat");
The following is the code −
 Live Demo
using System;

public class Demo {
   public static void Main() {
      string[] str = new string[] {
         "Cat",
         "Mat",
         "Rat"
      };
      Console.WriteLine("Our Array =");
      for (int i = 0; i < str.Length; i++) {
         string res = str[i];
         Console.WriteLine(res);
      }
      int findIndex = Array.IndexOf(str, "Mat");
      Console.Write("Element Mat found at the following index: ");
      Console.WriteLine(findIndex);
   }
}
Our Array =
Cat
Mat
Rat
Element Mat found at the following index: 1
base64.urlsafe_b64decode(s) in Python - GeeksforGeeks

26 Mar, 2020
With the help of base64.urlsafe_b64decode() method, we can decode the binary string using url and file system safe alphabets into normal form of strings.
Syntax : base64.urlsafe_b64decode(b_string)
Return : Return the decoded string.
Example #1 :In this example we can see that by using base64.urlsafe_b64decode() method, we are able to get the decoded string which can be in binary form by using this method.
# import base64from base64 import urlsafe_b64decodefrom base64 import urlsafe_b64encode  s = b'GeeksForGeeks's = urlsafe_b64encode(s)# Using base64.urlsafe_b64decode() methodgfg = urlsafe_b64decode(s)  print(gfg)
Output :
b’GeeksForGeeks’
Example #2 :
# import base64from base64 import urlsafe_b64decodefrom base64 import urlsafe_b64encode  s = b'Hello World's = urlsafe_b64encode(s)# Using base64.urlsafe_b64decode() methodgfg = urlsafe_b64decode(s)  print(gfg)
Output :
b’Hello World’
Python base64-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Defaultdict in Python
Python | Get unique values from a list
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
SVG <animate> Element - GeeksforGeeks

31 Mar, 2022
SVG stands for Scalable Vector Graphic. It can be used to make graphics and animations like in HTML canvas.
The <animate> SVG element is used to animate an attribute or property of an element over time. It’s normally inserted inside the element which we want to animate.
Syntax:
<animate attributeName="" values="" dur="" repeatCount="" />
Attributes:
Animation Attributes: Attributes used to give animation effects, exp timing attributes, event attributes, and value attributes, etc.
Global Attributes: some global attributes used like core attributes and styling attributes, etc.
Below given are a few examples of the above element:
Example 1:
<!DOCTYPE html><html>  <body>    <svg viewBox="0 0 50 50">        <rect width="10" height="10" fill="green">            <animate attributeName="rx" values="0;20;0"                dur="2s" repeatCount="10" />        </rect>    </svg></body>  </html>
Output:
Example 2:
<!DOCTYPE html><html>  <body>    <h1 style="color:green">         GeeksforGeeks     </h1>      <h2>         SVG animate element     </h2>      <svg viewBox="0 0 50 50">        <rect width="7" height="7" fill="green">            <animate attributeType="CSS" attributeName="opacity"            from="1" to="0" dur="4s" repeatCount="indefinite" />        </rect>    </svg></body>  </html>
Output:
Browsers Supported: The following browsers are supported by this SVG element:
Chrome
Edge
Firefox
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.
HTML-SVG
SVG-Element
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Python: Check if a directory is empty - GeeksforGeeks

29 Dec, 2020
Python is a widely used general-purpose, high-level programming language. It provides many functionalities and one among them is checking whether a directory is empty or not. This can be achieved by using os module. The OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality. The os and os.path modules include many functions to interact with the file system.
To check whether a directory is empty or not os.listdir() method is used. os.listdir() method of os module is used to get the list of all the files and directories in the specified directory.
Syntax: os.listdir(path)
Parameters:path (optional): path of the directory
Return Type: This method returns the list of all files and directories in the specified path. The return type of this method is list.
Example #1: If the list returned by os.listdir() is empty then the directory is empty otherwise not. Below is the implementation.
# Python program to check whether# the directory empty or not    import os  # path of the directorypath = "D:/Pycharm projects/GeeksforGeeks/Nikhil"  # Getting the list of directoriesdir = os.listdir(path)  # Checking if the list is empty or notif len(dir) == 0:    print("Empty directory")else:    print("Not empty directory")
Output:
Empty directory

Example #2: Suppose the path specified in the above code is a path to a text file or is an invalid path, then, in that case, the above code will raise an OSError. To overcome this error we can use os.path.isfile() method and os.path.exists() method. Below is the implementation.
# Python program to check whether# the directory is empty or not    import os    # Function to Check if the path specified# specified is a valid directorydef isEmpty(path):    if os.path.exists(path) and not os.path.isfile(path):          # Checking if the directory is empty or not        if not os.listdir(path):            print("Empty directory")        else:            print("Not empty directory")    else:        print("The path is either for a file or not valid")    # path to a filepath = "D:/Pycharm projects/GeeksforGeeks/Nikhil/gfg.txt"isEmpty(path)print()  # valid pathpath = "D:/Pycharm projects/GeeksforGeeks/Nikhil/"isEmpty(path)
Output:
The path is either for a file or not valid

Not empty directory

Python file-handling-programs
Python OS-file-module
Python os-module-programs
python-file-handling
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
set emplace_hint() function in C++ STL - GeeksforGeeks

10 Jul, 2018
The set::emplace_hint() is a built-in function in C++ STL which inserts a new element in the set. A position is passed in the parameter of the function which acts as a hint from where the searching operation starts before inserting the element at its current position. The position only helps the process to get faster, it does not decide where the new element is to be inserted. The new element is inserted following the property of the set container only.
Syntax:
set_name.emplace_hint(iterator position, value) 

Parameters: The function accepts two mandatory parameters which are described below:
position: This parameter acts as a hint from where the searching operation is done before inserting the element at its current position. The position only helps the process to be faster, it does not decide where the new element is to be inserted. The new element is inserted following the property of the set container only.
value: This specifies the element to inserted in the set container. The value is inserted into the set if it is not present before.
Return Value: The function returns an iterator pointing to the position where the insertion is done. If the element passed in the parameter already exists, then it returns an iterator pointing to the position where the existing element is.
Below program illustrates the above function.
// CPP program to demonstrate the// set::emplace_hint() function#include <bits/stdc++.h>using namespace std;int main(){      set<int> s;    auto it = s.emplace_hint(s.begin(), 1);      // stores the position of 2's insertion    it = s.emplace_hint(it, 2);      // fast step as it directly    // starts the search step from    // position where 3 was last inserted    s.emplace_hint(it, 3);      // this is a slower step as    // it starts checking from the    // position where 3 was inserted    // but 0 is to be inserted before 1    s.emplace_hint(it, 0);      // prints the set elements    for (auto it = s.begin(); it != s.end(); it++)        cout << *it << " ";      return 0;}
0 1 2 3

CPP-Functions
cpp-set
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Friend class and function in C++
Sorting a vector in C++
std::string class in C++
Pair in C++ Standard Template Library (STL)
Inline Functions in C++
Array of Strings in C++ (5 Different Ways to Create)
Queue in C++ Standard Template Library (STL)
Convert string to char array in C++
Python | Pandas DataFrame.to_xarray - GeeksforGeeks

21 Feb, 2019
Pandas DataFrame is a two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). Arithmetic operations align on both row and column labels. It can be thought of as a dict-like container for Series objects. This is the primary data structure of the Pandas.
Pandas DataFrame.to_xarray() function return an xarray object from the pandas object.
Syntax: DataFrame.to_xarray()
Parameter : None
Returns : xarray.DataArray or xarray.Dataset
Example #1: Use DataFrame.to_xarray() function to construct an xarray object using the given dataframe.
# importing pandas as pdimport pandas as pd  # Creating the DataFramedf = pd.DataFrame({'Weight':[45, 88, 56, 15, 71],                   'Name':['Sam', 'Andrea', 'Alex', 'Robin', 'Kia'],                   'Age':[14, 25, 55, 8, 21]})  # Create the indexindex_ = pd.date_range('2010-10-09 08:45', periods = 5, freq ='H')  # Set the indexdf.index = index_  # Print the DataFrameprint(df)
Output :
Now we will use DataFrame.to_xarray() function to construct an xarray object using the given Dataframe.
# return an xarray objectresult = df.to_xarray()  # Print the resultprint(result)
Output :
As we can see in the output, the DataFrame.to_xarray() function has successfully constructed an xarray object using the given dataframe. Example #2: Use DataFrame.to_xarray() function to construct an xarray object using the given dataframe.
# importing pandas as pdimport pandas as pd  # Creating the DataFramedf = pd.DataFrame({"A":[12, 4, 5, None, 1],                    "B":[7, 2, 54, 3, None],                    "C":[20, 16, 11, 3, 8],                    "D":[14, 3, None, 2, 6]})   # Create the indexindex_ = ['Row_1', 'Row_2', 'Row_3', 'Row_4', 'Row_5']  # Set the indexdf.index = index_  # Print the DataFrameprint(df)
Output :
Now we will use DataFrame.to_xarray() function to construct an xarray object using the given Dataframe.
# return an xarray objectresult = df.to_xarray()  # Print the resultprint(result)
Output :As we can see in the output, the DataFrame.to_xarray() function has successfully constructed an xarray object using the given dataframe.
Python pandas-dataFrame
Python pandas-dataFrame-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
List remove() function in C++ STL

In this article we will be discussing the working, syntax and examples of remove() function in C++.
List is a data structure that allows constant time insertion and deletion anywhere in sequence. Lists are implemented as doubly linked lists. Lists allow non-contiguous memory allocation. List perform better insertion extraction and moving of element in any position in container than array, vector and deque. In List the direct access to the element is slow and list is similar to forward_list, but forward list objects are single linked lists and they can only be iterated forwards.
remove() is an inbuilt function in C++ STL which is declared in header file. remove() is used to remove any specific value/element from the list container. It takes the value which is passed as a parameter and removes all the elements with that value from the list container.The function calls destructor if the size of element removed is greater than the size of the list container.
list_name.remove(const value_type& value);
This function accepts a value which is to be searched from the list container and to be removed.
This function returns nothing, just removes element from the container.
 Live Demo
/*
In the code below we are inserting elements to the list and then we will try to remove the elements from the list using their values. */
#include <bits/stdc++.h>
using namespace std;
int main(){
   //create a list
   list<int> myList;
   //insert elements to the List
   myList.push_back(1);
   myList.push_back(1);
   myList.push_back(3);
   myList.push_back(2);
   myList.push_back(5);
   //my list before removing elements
   cout<<"List before removing elements: ";
   for (auto i = myList.begin(); i!=myList.end(); i++){
      cout << *i << " ";
   }
   //deleting 1 2 and 3 from the list
   myList.remove(1);
   myList.remove(2);
   myList.remove(3);
   // List after removing elements
   cout << "\nList after removing elements: ";
   for (auto i = myList.begin(); i!= myList.end(); i++){
      cout << *i << " ";
   }
   return 0;
}
If we run the above code then it will generate the following output
List before removing elements: 1 1 3 2 5
List after removing elements: 5
ZoneOffset ofTotalSeconds(int) method in Java with Examples - GeeksforGeeks

11 Dec, 2018
The ofTotalSeconds(int) method of ZoneOffset Class in java.time package is used to obtain an instance of ZoneOffset using the offset in totalSeconds passed as the parameter. This method takes the totalSeconds as parameter in the form of int and converts it into the ZoneOffset.
Syntax:
public static ZoneOffset
  ofTotalSeconds(int totalSeconds)

Parameters: This method accepts a parameter totalSeconds which is int to be converted into an ZoneOffset instance. ITs range is -64800 to +64800.
Return Value: This method returns a ZoneOffset instance parsed from the specified totalSeconds.
Exception: This method throws DateTimeException if the totalSeconds is invalid.
Below examples illustrate the ZoneOffset.ofTotalSeconds() method:
Example 1:
// Java code to illustrate ofTotalSeconds() method  import java.time.*;  public class GFG {    public static void main(String[] args)    {          // Get the totalSeconds        int totalSeconds = 5000;          // ZoneOffset using ofTotalSeconds() method        ZoneOffset zoneOffset            = ZoneOffset.ofTotalSeconds(totalSeconds);          System.out.println(zoneOffset);    }}
+01:23:20

Example 2: To demonstrate DateTimeException
// Java code to illustrate ofTotalSeconds() method  import java.time.*;  public class GFG {    public static void main(String[] args)    {          // Get the invalid totalSeconds        int totalSeconds = 100000;          try {            // ZoneOffset using ofTotalSeconds() method            ZoneOffset zoneOffset                = ZoneOffset.ofTotalSeconds(totalSeconds);        }          catch (Exception e) {            System.out.println(e);        }    }}
java.time.DateTimeException:
 Zone offset not in valid range:
 -18:00 to +18:00

Reference: Oracle Doc
Java-Functions
Java-time package
Java-ZoneOffset
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
PriorityQueue in Java
How to remove an element from ArrayList in Java?
The length of a string using pointers - GeeksforGeeks

11 Jan, 2018
Write a program to find the length of a string using pointers .
Examples:
Input : given_string = "geeksforgeeks"
Output : length of the string = 13

Input : given_string = "coding"
Output : length of the string = 6

Prerequisite : Pointer in C
Approach Used : In this program we make use of * operator. The * (asterisk) operator denotes the value of variable . The * operator at the time of declaration denotes that this is a pointer, otherwise it denotes the value of the memory location pointed by the pointer. In the below program, in string_length function we check if we reach the end of the string by checking for a null represented by ‘\0’ .
// C++ program  to find length of string// using pointer arithmetic.#include <iostream>using namespace std;  // function to find the length// of the string through pointersint string_length(char* given_string){    // variable to store the    // length of the string    int length = 0;    while (*given_string != '\0') {        length++;        given_string++;    }      return length;}  // Driver functionint main(){    // array to store the string    char given_string[] = "geeksforgeeks";    cout << string_length(given_string);    return 0;}
Output:
13

C-Pointers
C-String
C Language
C++ Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
Exception Handling in C++
'this' pointer in C++
Multithreading in C
Arrow operator -> in C/C++ with Examples
Header files in C/C++ and its uses
Program to print ASCII Value of a character
C++ Program for QuickSort
How to return multiple values from a function in C or C++?
Sorting a Map by value in C++ STL
How to use express in typescript ? - GeeksforGeeks

27 Jan, 2022
In this article, we will see how to use Express in TypeScript. The TypeScript is a superset of JavaScript that provides type notation with the JavaScript, so we can handle our server, and very scalable for the future. Express is web framework helps to create server-side handling with the help of Nodejs
Prerequisite:
Basic knowledge of NodeJS and Express.
Basic knowledge of TypeScript.
Steps to create an Express server in Typescript:
Step 1: Initiate the package.json file with your working folder with the following command.
npm init -y
Note: The ‘-y’ flag is used to make the default configuration.
After creating package.json file, the following will be the output.
Step 2: Install the required modules using the following command.
Add an express module for our server.
npm install express
Add typescript and ts-node for run typescript on the NodeJS.
npm i typescript ts-node nodemon --save-dev
Note: The ‘–save-dev’ is used to add dev dependency.
Add type declaration.
npm i @types/node @types/express
Step 3: Create a tsconfig.json file with the below code.
{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "rootDir": "./",
    "outDir": "./build",
    "esModuleInterop": true,
    "strict": true
  }
}
Step 4: Make the following change in the package.json file to run typescript directly.
Step 5: Create an index.ts file with the following code. Here we have created a minimal express server in typescript. Here, file name is index.ts.
Javascript
// Import the express in typescript fileimport express from 'express'; // Initialize the express engineconst app: express.Application = express(); // Take a port 3000 for running server.const port: number = 3000; // Handling '/' Requestapp.get('/', (_req, _res) => {    _res.send("TypeScript With Expresss");}); // Server setupapp.listen(port, () => {    console.log(`TypeScript with Express         http://localhost:${port}/`);});
Step 6: Start the server using the below command.
npm start
Output: We will see the following output on the terminal screen.
Step 7: Open the browser and go to http://localhost:3000, we will see the following output. 
Reference:
If you have to learn more about typescript refer to introduction-to-typescript article.
If you have to learn more about express refer to introduction-to-express article. 
adnanirshad158
gulshankumarar231
anikaseth98
clintra
Express.js
Picked
TypeScript
JavaScript
Node.js
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 filter object array based on attributes?
Installation of Node.js on Linux
How to update Node.js and NPM to next version ?
Node.js fs.readFileSync() Method
Node.js fs.writeFile() Method
Node.js fs.readFile() Method
Diamond operator for Anonymous Inner Class with Examples in Java - GeeksforGeeks

16 Jan, 2020
Prerequisite: Anonymous Inner Class
Diamond Operator: Diamond operator was introduced in Java 7 as a new feature.The main purpose of the diamond operator is to simplify the use of generics when creating an object. It avoids unchecked warnings in a program and makes the program more readable. The diamond operator could not be used with Anonymous inner classes in JDK 7. In JDK 9, it can be used with the anonymous class as well to simplify code and improves readability. Before JDK 7, we have to create an object with Generic type on both side of the expression like:
// Here we mentioned the generic type
// on both side of expression while creating object
List<String> geeks = new ArrayList<String>();

When Diamond operator was introduced in Java 7, we can create the object without mentioning generic type on right side of expression like:
List<String> geeks = new ArrayList<>();

Problem with Diamond Operator in JDK 7?
With the help of Diamond operator, we can create an object without mentioning the generic type on the right hand side of the expression. But the problem is it will only work with normal classes. Suppose you want to use the diamond operator for anonymous inner class then compiler will throw error message like below:
// Program to illustrate the problem// while linking diamond operator// with an anonymous inner class  abstract class Geeksforgeeks<T> {    abstract T add(T num1, T num2);}  public class Geeks {    public static void main(String[] args)    {        Geeksforgeeks<Integer> obj = new Geeksforgeeks<>() {            Integer add(Integer n1, Integer n2)            {                return (n1 + n2);            }        };        Integer result = obj.add(10, 20);        System.out.println("Addition of two numbers: " + result);    }}
Output:
prog.java:9: error: cannot infer type arguments for Geeksforgeeks
        Geeksforgeeks  obj = new Geeksforgeeks  () {
                                                        ^
  reason: cannot use '' with anonymous inner classes
  where T is a type-variable:
    T extends Object declared in class Geeksforgeeks
1 error

Java developer extended the feature of the diamond operator in JDK 9 by allowing the diamond operator to be used with anonymous inner classes too. If we run the above code with JDK 9, then code will run fine and we will generate the below output.
Output:
Addition of two numbers: 30

Algorithms
Java
Technical Scripter
Java
Algorithms
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
DSA Sheet by Love Babbar
Quadratic Probing in Hashing
SCAN (Elevator) Disk Scheduling Algorithms
K means Clustering - Introduction
Difference between Informed and Uninformed Search in AI
Arrays in Java
Split() String method in Java with examples
For-each loop in Java
Arrays.sort() in Java with examples
Reverse a string in Java