code-rag-bench/online-tutorials huggingface dataset:
PHP - Arithmetic Operators Example

Try following example to understand all the arithmetic operators. Copy and paste following PHP program in test.php file and keep it in your PHP Server's document root and browse it using any browser.
<html>
   
   <head>
      <title>Arithmetical Operators</title>
   </head>
   
   <body>
   
      <?php
         $a = 42;
         $b = 20;
         
         $c = $a + $b;
         echo "Addtion Operation Result: $c <br/>";
         
         $c = $a - $b;
         echo "Substraction Operation Result: $c <br/>";
         
         $c = $a * $b;
         echo "Multiplication Operation Result: $c <br/>";
         
         $c = $a / $b;
         echo "Division Operation Result: $c <br/>";
         
         $c = $a % $b;
         echo "Modulus Operation Result: $c <br/>";
         
         $c = $a++; 
         echo "Increment Operation Result: $c <br/>";
         
         $c = $a--; 
         echo "Decrement Operation Result: $c <br/>";
      ?>
   
   </body>
</html>
This will produce the following result −
Addtion Operation Result: 62 
Substraction Operation Result: 22 
Multiplication Operation Result: 840 
Division Operation Result: 2.1 
Modulus Operation Result: 2 
Increment Operation Result: 42 
Decrement Operation Result: 43 


    45 Lectures 
     9 hours 

 Malhar Lathkar

    34 Lectures 
     4 hours 

 Syed Raza

    84 Lectures 
     5.5 hours 

 Frahaan Hussain

    17 Lectures 
     1 hours 

 Nivedita Jain

    100 Lectures 
     34 hours 

 Azaz Patel

    43 Lectures 
     5.5 hours 

 Vijay Kumar Parvatha Reddy
 Print
 Add Notes
 Bookmark this page
ASP BinaryWrite Method - GeeksforGeeks

26 Apr, 2021
The ASP BinaryWrite Method is used to specify to write the data to the current HTTP output. without any character conversion. This method is used to write the non-string information such as Binary data required for the image. It is a predefined method of the Response type Object.
Syntax:
response.BinaryWrite data 
Parameter Values:
data: It specify the binary information that will be sent
Return Value: This method has no return value.Example: If you have an object that generates an array of bytes, you can use the following call to BinaryWrite to send the bytes to a custom application:  
javascript
<%   Set objBinaryGen=Server.CreateObject("MyComponents.BinaryGenerator")   pic = objBinaryGen.MakePicture   response.BinaryWrite pic %>
References:
https://docs.microsoft.com/en-us/previous-versions/iis/6.0-sdk/ms524861(v=vs.90)
hritikbhatnagar2182
ASP-Properties
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 create footer to stay at the bottom of a Web page?
How to set the default value for an HTML <select> element ?
File uploading in React.js
Node.js fs.readFileSync() Method
How to set input type date in dd-mm-yyyy format using HTML ?
How to create a categorical variable using a data frame column in R?

If a variable is numerical then it can be converted into a categorical variable by defining the lower and upper limits. For example, age starting from 21 and ending at 25 can be converted into a category say 21−25. To convert an R data frame column into a categorical variable, we can use cut function.
 Live Demo
Consider the below data frame −
set.seed(141)
x1<−rnorm(20,2,0.3)
x2<−LETTERS[1:20]
df1<−data.frame(x1,x2)
df1
x1 x2
1 2.154308 A
2 1.966167 B
3 2.019302 C
4 1.803427 D
5 2.150517 E
6 1.749425 F
7 1.797508 G
8 1.949084 H
9 2.147742 I
10 1.895026 J
11 1.922780 K
12 1.755871 L
13 2.410873 M
14 2.580489 N
15 1.910219 O
16 1.805713 P
17 2.166996 Q
18 2.074431 R
19 1.749257 S
20 2.004867 T
Creating a categorical column for x1 in df1 −
df1$x1_category<−cut(df1$x1,c(0,1,2,3))
df1
x1 x2 x1_category
1 2.154308 A (2,3]
2 1.966167 B (1,2]
3 2.019302 C (2,3]
4 1.803427 D (1,2]
5 2.150517 E (2,3]
6 1.749425 F (1,2]
7 1.797508 G (1,2]
8 1.949084 H (1,2]
9 2.147742 I (2,3]
10 1.895026 J (1,2]
11 1.922780 K (1,2]
12 1.755871 L (1,2]
13 2.410873 M (2,3]
14 2.580489 N (2,3]
15 1.910219 O (1,2]
16 1.805713 P (1,2]
17 2.166996 Q (2,3]
18 2.074431 R (2,3]
19 1.749257 S (1,2]
20 2.004867 T (2,3]
 Live Demo
y1<−sample(c("Child","Teen","Adult","Old"),20,replace=TRUE)
y2<−rpois(20,5)
df2<−data.frame(y1,y2)
df2
y1 y2
1 Old 6
2 Teen 3
3 Old 2
4 Teen 5
5 Adult 6
6 Teen 6
7 Old 5
8 Adult 6
9 Child 5
10 Child 3
11 Child 9
12 Old 8
13 Teen 2
14 Teen 2
15 Teen 5
16 Adult 7
17 Adult 4
18 Teen 4
19 Adult 2
20 Child 8
Creating a categorical column for x2 in df2 −
df2$y2_category<−cut(df2$y2,c(0,1,2,3,4,5,6,7,8,9,10))
df2
y1 y2 y2_category
1 Old 6 (5,6]
2 Teen 3 (2,3]
3 Old 2 (1,2]
4 Teen 5 (4,5]
5 Adult 6 (5,6]
6 Teen 6 (5,6]
7 Old 5 (4,5]
8 Adult 6 (5,6]
9 Child 5 (4,5]
10 Child 3 (2,3]
11 Child 9 (8,9]
12 Old 8 (7,8]
13 Teen 2 (1,2]
14 Teen 2 (1,2]
15 Teen 5 (4,5]
16 Adult 7 (6,7]
17 Adult 4 (3,4]
18 Teen 4 (3,4]
19 Adult 2 (1,2]
20 Child 8 (7,8]
How to retrieve the Azure VM RAM and CPU size using PowerShell?

Azure VM RAM and CPU size depend on the hardware profile chosen for the VM. In this example, we will retrieve VM (TestMachine2k16) hardware profile and then we can find how much RAM or CPU is allocated to it.
To get the Size of the Azure VM,
PS C:\> $azvm = Get-AzVM -VMName 'TestMachine2k16'
PS C:\> $azvm.HardwareProfile.VmSize
Standard_DS2_v2
You can check the above size on the Microsoft Azure website to know how much RAM and CPU are associated with it and another way using the PowerShell by using the Get-AZVmSize command.
PS C:\> $vmsize = $azvm.HardwareProfile.VmSize
PS C:\> Get-AzVMSize -VMName $azvm.Name -ResourceGroupName $azvm.ResourceGroupName | where{$_.Name -eq $vmsize}
You can see that the CPU allocated is 2, RAM is 7168 MB.
Alternate Lower Upper String Sort in C++

A string is an array of characters. And this problem is to sort the elements of the string with alternate upper and lower case.
Problem Description − Alternate lower upper string sort, is a problem in which we are provided an unordered string which contains mixed upper and lowercase characters and we need to sort this string in such a way that upper and lower case characters are placed in alternate positions but are in a sorted manner.
Let’s take an example to understand the topic better,
Input : aFegrAfStRzsV
Output : AaFeRfSgVrstz
Explanation :
Upper case characters : A F R S V
Lower case characters : a e f g r s t z
Both are in a sorted manner so we can now place them in alternate order.
Now, since we have understood the problem. Let's create a solution for it. One way is creating arrays for both uppercase and lowercase letters in sorted order and then alternating them in the final string. We have created an algorithm based on this logic.
Step 1 : In an array lowercount[] add all lowercase characters in sorted order.
Step 2 : In an array uppercount[] add all uppercase characters in sorted order.
Step 3 : Create the final string using alternate values from both arrays.
Step 4 : Print the result array.
 Live Demo
#include <iostream>
using namespace std;
#define MAX 26
void alternateULSort(string& s) ;
int main(){
   string str = "aFegrAfStRzsV";
   cout<<"The unsorted string is : "<<str;
   cout<<"\nThe alternate lower upper sorted string is ";
   alternateULSort(str);
   cout << str << "\n";
}
void alternateULSort(string& s){
   int n = s.length();
   int lowerCount[MAX] = { 0 }, upperCount[MAX] = { 0 };
   for (int i = 0; i < n; i++) {
      if (isupper(s[i]))
         upperCount[s[i] - 'A']++;
      else
         lowerCount[s[i] - 'a']++;
   }
   int i = 0, j = 0, k = 0;
   while (k < n) {
      while (i < MAX && upperCount[i] == 0)
         i++;
      if (i < MAX) {
         s[k++] = 'A' + i;
         upperCount[i]--;
         }
      while (j < MAX && lowerCount[j] == 0)
         j++;
      if (j < MAX) {
         s[k++] = 'a' + j;
         lowerCount[j]--;
      }
   }
}
The unsorted string is : aFegrAfStRzsV
The alternate lower upper sorted string is AaFeRfSgVrstz
BigInteger longValue() Method in Java - GeeksforGeeks

04 Dec, 2018
The java.math.BigInteger.longValue() converts this BigInteger to a long value. If the value return by this function is too big to fit into long value, then it will return only the low-order 64 bits. There is chance that this conversion can loose information about the overall magnitude of the BigInteger value. This method can also return the result with opposite sign.
Syntax:
public long longValue()
Returns: The method returns a long value which represents long value for this BigInteger.
Examples:
Input: BigInteger1=3214558191
Output: 3214558191
Explanation: BigInteger1.longValue()=3214558191.

Input: BigInteger1=32145535361361525377
Output: -4747952786057577855
Explanation: BigInteger1.longValue()=-4747952786057577855. This BigInteger is too big for 
longValue so it is returning lower 64 bit.

Example 1: Below programs illustrate longValue() method of BigInteger class
// Java program to demonstrate longValue() method of BigInteger  import java.math.BigInteger;  public class GFG {      public static void main(String[] args)    {          // Creating 2 BigInteger objects        BigInteger b1, b2;          b1 = new BigInteger("3214553537");        b2 = new BigInteger("76137217351");          // apply longValue() method        long longValueOfb1 = b1.longValue();        long longValueOfb2 = b2.longValue();          // print longValue        System.out.println("longValue of "                           + b1 + " : " + longValueOfb1);        System.out.println("longValue of "                           + b2 + " : " + longValueOfb2);    }}
longValue of 3214553537 : 3214553537
longValue of 76137217351 : 76137217351

Example 2: when return long is too big for long value.
// Java program to demonstrate longValue() method of BigInteger  import java.math.BigInteger;  public class GFG {      public static void main(String[] args)    {        // Creating 2 BigInteger objects        BigInteger b1, b2;          b1 = new BigInteger("32145535361361525377");        b2 = new BigInteger("7613721535372632367351");          // apply longValue() method        long longValueOfb1 = b1.longValue();        long longValueOfb2 = b2.longValue();          // print longValue        System.out.println("longValue of "                           + b1 + " : " + longValueOfb1);        System.out.println("longValue of "                           + b2 + " : " + longValueOfb2);    }}
longValue of 32145535361361525377 : -4747952786057577855
longValue of 7613721535372632367351 : -4783767069412450057

Reference:BigInteger longValue() Docs
java-basics
Java-BigInteger
Java-Functions
java-math
Java-math-package
Java
Java-BigInteger
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Different ways of Reading a text file in Java
Exceptions in Java
Functional Interfaces in Java
Generics in Java
Comparator Interface in Java with Examples
Introduction to Java
HashMap get() Method in Java
Strings in Java
How to set the min and max height or width of a Frame in Tkinter?

In order to manage too many widgets in the window, we can use Frame widgets in Tkinter. In order to place the widgets inside the frame widget, we have to set the relative width and height of the frame. To configure the relative height and width of the frame, we have to configure it using the place(relx, rely) method.
Now, let us create a frame and add a button to it.
#import required libraries
from tkinter import *
from tkinter import ttk

#Create an instance of Tkinter frame
win= Tk()

#Set the geometry of the window
win.geometry("750x250")

#Create a LabelFrame
frame= Frame(win, width= 100, height= 100, background= "green")
frame.pack(fill= BOTH, expand= True)

#Configure the Frame
frame.place(relx=0.3, rely=.3, anchor= "c")

#Create Button widget in Frame
ttk.Button(frame, text= "Button").pack()

win.mainloop()
Running the above code will display a frame that has a minimum and maximum width/height is set.
Tk - Combobox Widget

Combobox widget is a widget that combines an entry with a list of choices available to the use. The syntax for combobox widget is shown below −
combobox comboboxName options

The options available for the combobox widget are listed below in table.
-background color
Used to set background color for widget.
-borderwidth width
Used to draw with border in 3D effects.
-font fontDescriptor
Used to set font for widget.
-foreground color
Used to set foreground color for widget.
-textvariable varName
Variable associated with the widget. When the text of widget changes, the variable is set to text of widget.
-values array
Arbitrary values for combobox widget.
-width number
Sets the width for widget.
-justify alignment
Sets the alignment of text, which can be left, center, or right.
-state requiredState
Sets the state, which can be read_only, disabled, or normal.
-postcommand command
Procedure to be executed post action.
A simple example for combobox widget is shown below −
#!/usr/bin/wish

set mylist [list C C++ Lua Tcl]
pack [ttk::combobox .s1  -textvariable combovalue -values $mylist -background yellow
   -font {Helvetica -18 bold} -foreground red -width 40 -justify left -state normal]
set combovalue "C"
When we run the above program, we will get the following output −
 Print
 Add Notes
 Bookmark this page
Java - min() Method

The method gives the smaller of the two arguments. The argument can be int, float, long, double.
This method has the following variants −
double min(double arg1, double arg2)
float min(float arg1, float arg2)
int min(int arg1, int arg2)
long min(long arg1, long arg2)

Here is the detail of parameters −
This method accepts any primitive data type as a parameter.
This method returns the smaller of the two arguments.
public class Test {

   public static void main(String args[]) {
      System.out.println(Math.min(12.123, 12.456));      
      System.out.println(Math.min(23.12, 23.0));  
   }
}
This will produce the following result −
12.123
23.0


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
SQL indexes

04 Oct, 2021
An index is a schema object. It is used by the server to speed up the retrieval of rows by using a pointer. It can reduce disk I/O(input/output) by using a rapid path access method to locate data quickly. An index helps to speed up select queries and where clauses, but it slows down data input, with the update and the insert statements. Indexes can be created or dropped with no effect on the data. In this article, we will see how to create, delete, and uses the INDEX in the database. 
For example, if you want to reference all pages in a book that discusses a certain topic, you first refer to the index, which lists all the topics alphabetically and is then referred to one or more specific page numbers. 
Syntax:
 CREATE INDEX index
 ON TABLE column;
where the index is the name given to that index and TABLE is the name of the table on which that index is created and column is the name of that column for which it is applied. 
 Syntax:
 CREATE INDEX index
 ON TABLE (column1, column2,.....);
Unique indexes are used for the maintenance of the integrity of the data present in the table as well as for the fast performance, it does not allow multiple values to enter into the table.  Syntax:
CREATE UNIQUE INDEX index
 ON TABLE column;
A column contains a wide range of values.
A column does not contain a large number of null values.
One or more columns are frequently used together in a where clause or a join condition.
When should indexes be avoided: 
The table is small
The columns are not often used as a condition in the query
The column is updated frequently
Removing an Index:
To remove an index from the data dictionary by using the DROP INDEX command. 
Syntax:
DROP INDEX index;
To drop an index, you must be the owner of the index or have the DROP ANY INDEX privilege.  
To modify an existing table’s index by rebuilding, or reorganizing the index.
ALTER INDEX IndexName 
ON TableName REBUILD;
You can check the different indexes present in a particular table given by the user or the server itself and their uniqueness. 
Syntax:
select * from USER_INDEXES;
It will show you all the indexes present in the server, in which you can locate your own tables too. 
 You can use the system stored procedure sp_rename to rename any index in the database.
Syntax:
EXEC sp_rename  
   index_name,  
   new_index_name,  
   N'INDEX'; 
sunny94
swchoi442
khushboogoyal499
varshachoudhary
DBMS Indexing
DBMS-SQL
SQL-basics
DBMS
SQL
DBMS
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
boost::trim in C++ library

14 Jul, 2021
This function is included in the “boost/algorithm/string” library. The Boost String Algorithms Library provides a generic implementation of string-related algorithms which are missing in STL. The trim function is used to remove all leading or trailing white spaces from the string. The input sequence is modified in place.
trim_left(): Removes all leading white spaces from the string.
trim_right(): Removes all trailing white spaces from the string.
trim(): Removes all leading and trailing white spaces from the string.
Syntax:
Template:trim(Input, Loc);
Parameters:Input: An input sequenceLoc: A locale used for ‘space’ classification
Returns: The modified input sequence without leading or trailing white spaces.
Examples:
Input: ”    geeks_for_geeks    ” Output: Applied left trim: “geeks_for_geeks    ” Applied right trim: ”    geeks_for_geeks” Applied trim: “geeks_for_geeks” Explanation: The trim_left() function removes all the leading white spaces.The trim_right() function removes all the trailing white spaces.The trim() function removes all the leading and trailing white spaces.
Below is the implementation to remove white spaces from string using the function boost::trim():
C++
// C++ program to remove white spaces// from string using the function// boost::trim function#include <boost/algorithm/string.hpp>#include <iostream>using namespace boost::algorithm;using namespace std;  // Driver Codeint main(){    // Given Input    string s1 = "    geeks_for_geeks    ";    string s2 = "    geeks_for_geeks    ";    string s3 = "    geeks_for_geeks    ";      // Apply Left Trim on string, s1    cout << "The original string is: \""         << s1 << "\" \n";    trim_left(s1);    cout << "Applied left trim: \""         << s1 << "\" \n\n";      // Apply Right Trim on string, s2    cout << "The original string is: \""         << s2 << "\" \n";    trim_right(s2);    cout << "Applied right trim: \""         << s2 << "\" \n\n";      // Apply Trim on string, s3    cout << "The original string is: \""         << s3 << "\" \n";    trim(s3);    cout << "Applied trim: \"" << s3         << "\" \n";      return 0;}
The original string is: "    geeks_for_geeks    " 
Applied left trim: "geeks_for_geeks    " 

The original string is: "    geeks_for_geeks    " 
Applied right trim: "    geeks_for_geeks" 

The original string is: "    geeks_for_geeks    " 
Applied trim: "geeks_for_geeks"

Time Complexity: O(N)Auxiliary Space: O(1)
CPP-Functions
CPP-Library
C++
C++ Programs
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python – math.acos() function

28 May, 2020
Math module contains a number of functions which is used for mathematical operations. The math.acos() function returns the arc cosine value of a number. The value passed in this function should be in between -1 to 1.
Syntax: math.acos(x)
Parameter:This method accepts only single parameters.
x :This parameter is the value to be passed to acos()
Returns:This function returns the arc cosine value of a number.
Below examples illustrate the use of above function:
Example 1:
# Python code to implement# the acos()function       # importing "math"# for mathematical operations  import math        a = math.pi / 6       # returning the value of arc cosine of pi / 6  print ("The value of arc cosine of pi / 6 is : ", end ="")  print (math.acos(a))
Output:
The value of arc cosine of pi / 6 is : 1.0197267436954502

Example 2:
# Python code implementation of # the acos() functionimport math import numpy as np import matplotlib.pyplot as plt      in_array = np.linspace(-(1 / 3.5 * np.pi), 1 / 3.5 * np.pi, 20)     out_array = []     for i in range(len(in_array)):     out_array.append(math.acos(in_array[i]))     i += 1     print("Input_Array : \n", in_array)  print("\nOutput_Array : \n", out_array)      plt.plot(in_array, out_array, "go-")  plt.title("math.acos()")  plt.xlabel("X")  plt.ylabel("Y")  plt.show() 
Output:
Input_Array :  
[-0.8975979  -0.80311391 -0.70862992 -0.61414593 -0.51966194 -0.42517795
 -0.33069396 -0.23620997 -0.14172598 -0.04724199  0.04724199  0.14172598
  0.23620997  0.33069396  0.42517795  0.51966194  0.61414593  0.70862992
  0.80311391  0.8975979 ]

Output_Array :  
[2.6850860217724004, 2.50329950258761, 2.358350863035667, 2.2320996324218134, 
2.1172515505585388, 2.009954812757658, 1.9078351422171613, 1.809259917693194,
1.7130011090538158, 1.6180559117526183, 1.5235367418371748, 1.4285915445359774,
1.3323327358965993, 1.233757511372632, 1.131637840832135, 1.0243411030312544,
0.9094930211679799, 0.783241790554126, 0.6382931510021833, 0.45650663181739287]

Python math-library
Python math-library-functions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas Series.unique()

17 Sep, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages, and makes importing and analyzing data much easier.
While analyzing the data, many times the user wants to see the unique values in a particular column, which can be done using Pandas unique() function.
To download the CSV file used, Click Here.
Syntax: Series.unique()
Return Type: Numpy array of unique values in that column
Example #1: Using Series.unique()In this example, unique() method is used to know all type of unique values in Team column.
# importing pandas packageimport pandas as pd  # making data frame from csv filedata = pd.read_csv("employees.csv")  # storing unique value in a variablearr = data["Team"].unique()  # printing arrayprint(arr)
Output:As shown in the output image, an array with all of the unique values in the column is returned.
Error and Exceptions:
This method works only on series and not on Data Frames
As shown in the output, this method includes NULL value as a unique value.
Python pandas-series
Python pandas-series-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Introduction To PYTHON
Python OOPs Concepts
Convert integer to string in Python
Matplotlib.axes.Axes.add_patch() in Python

21 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
The Axes.add_patch() function in axes module of matplotlib library is used to add a Patch to the axes’ patches; return the patch.
Syntax: Axes.add_patch(self, p)
Parameters: This method accepts the following parameters.
line: This parameter is the Patch to the axes’ patches.
Return value: This method returns the Patch .
Below examples illustrate the matplotlib.axes.Axes.add_patch() function in matplotlib.axes:
Example 1:
# Implementation of matplotlib functionimport numpy as npimport matplotlib.pyplot as plt  y, x = np.mgrid[:5, 1:6]poly_coords = [    (0.25, 2.75), (3.25, 2.75),    (2.25, 0.75), (0.25, 0.75)]fig, ax = plt.subplots()  cells = ax.plot(x, y, x + y, color ='green')ax.add_patch(    plt.Polygon(poly_coords, color ='forestgreen',                alpha = 0.5)    )ax.margins(x = 0.1, y = 0.05)ax.set_aspect('equal')  fig.suptitle('matplotlib.axes.Axes.add_patch() \function Example\n\n', fontweight ="bold")plt.show()
Output:
Example 2:
# Implementation of matplotlib functionimport matplotlib.path as mpathimport matplotlib.patches as mpatchesimport matplotlib.pyplot as plt  Path = mpath.Path  fig, ax = plt.subplots()pp1 = mpatches.PathPatch(    Path([(0, 0), (1, 0), (1, 1), (0, 0)],         [Path.MOVETO, Path.CURVE3,           Path.CURVE3, Path.CLOSEPOLY]),    fc ="none", transform = ax.transData)  ax.add_patch(pp1)ax.plot([0.75], [0.25], "go-")  fig.suptitle('matplotlib.axes.Axes.add_patch() \function Example\n\n', fontweight ="bold")plt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL | LIKE

20 Aug, 2020
Sometimes we may require tuples from the database which match certain patterns. For example, we may wish to retrieve all columns where the tuples start with the letter ‘y’, or start with ‘b’ and end with ‘l’, or even more complicated and restrictive string patterns. This is where the LIKE Clause comes to rescue, often coupled with the WHERE Clause in SQL.
There are two kinds of wildcards used to filter out the results:
% : Used to match zero or more characters. (Variable Length)
_ : Used to match exactly one character. (Fixed Length)
The following are the rules for pattern matching with the LIKE Clause:
Example:
Say we have a relation, Supplier. We want to test various patterns using the LIKE clause:
Supplier Table:
Sample Queries and Outputs:
SELECT SupplierID, Name, Address
FROM Suppliers
WHERE Name LIKE 'Ca%';

Output:
SELECT *
FROM Suppliers
WHERE Address LIKE '%Okhla%';

Output:
SELECT SupplierID, Name, Address
FROM Suppliers
WHERE Name LIKE '_ango%';

Output:
Application: The LIKE operator is extremely resourceful in situations such as address filtering wherein we know only a segment or a portion of the entire address (such as locality or city) and would like to retrieve results based on that. The wildcards can be resourcefully exploited to yield even better and more filtered tuples based on the requirement.
This article is contributed by Anannya Uberoi. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
aditimantri2196
khushboogoyal499
SQL-Clauses-Operators
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Writer write(int) method in Java with Examples - GeeksforGeeks

29 Jan, 2019
The write(int) method of Writer Class in Java is used to write the specified byte value on the writer. This byte value is specified using the ASCII value of the byte value passed as an integer value. This integer value is taken as a parameter.
Syntax:
public void write(int ascii)
Parameters: This method accepts a mandatory parameter ascii which is the ASCII value of the byte value to be written on the writer.
Return Value: This method do not returns any value.
Below methods illustrates the working of write(int) method:
Program 1:
// Java program to demonstrate// Writer write(int) method  import java.io.*;  class GFG {    public static void main(String[] args)    {          try {              // Create a Writer instance            Writer writer                = new PrintWriter(System.out);              // Write the byte value '0' to this writer            // using write() method            // This will put the string in the writer            // till it is printed on the console            writer.write(48);              writer.flush();        }        catch (Exception e) {            System.out.println(e);        }    }}
0

Program 2:
// Java program to demonstrate// Writer write(int) method  import java.io.*;  class GFG {    public static void main(String[] args)    {          try {              // Create a Writer instance            Writer writer                = new PrintWriter(System.out);              // Write the byte value 'A' to this writer            // using write() method            // This will put the string in the writer            // till it is printed on the console            writer.write(65);              writer.flush();        }        catch (Exception e) {            System.out.println(e);        }    }}
A

Java-Functions
Java-IO package
Java-Writer
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
HashMap in Java with Examples
How to iterate any Map in Java
Initialize an ArrayList in Java
Interfaces in Java
ArrayList in Java
Multidimensional Arrays in Java
Stack Class in Java
Singleton Class in Java
LinkedList in Java
Collections in Java
How to Install OpenCV for Python on Windows? - GeeksforGeeks

05 Oct, 2021
Prerequisite: Python Language Introduction OpenCV is the huge open-source library for computer vision, machine learning, and image processing and now it plays a major role in real-time operation which is very important in today’s systems. By using it, one can process images and videos to identify objects, faces, or even the handwriting of a human. When it integrated with various libraries, such as Numpuy, python is capable of processing the OpenCV array structure for analysis. To Identify image patterns and its various features we use vector space and perform mathematical operations on these features.
To install OpenCV, one must have Python and PIP, preinstalled on their system. To check if your system already contains Python, go through the following instructions:
Open the Command line(search for cmd in the Run dialog( + R).Now run the following command:
python --version

If Python is already installed, it will generate a message with the Python version available.
If Python is not present, go through How to install Python on Windows? and follow the instructions provided. PIP is a package management system used to install and manage software packages/libraries written in Python. These files are stored in a large “on-line repository” termed as Python Package Index (PyPI).To check if PIP is already installed on your system, just go to the command line and execute the following command:
pip -V
If PIP is not present, go through How to install PIP on Windows? and follow the instructions provided.
OpenCV can be directly downloaded and installed with the use of pip (package manager). To install OpenCV, just go to the command-line and type the following command:
pip install opencv-python
Beginning with the installation:
Type the command in the Terminal and proceed:
Collecting Information and downloading data:
Installing Packages:
Finished Installation:
To check if OpenCV is correctly installed, just run the following commands to perform a version check:
python
>>>import cv2
>>>print(cv2.__version__)

how-to-install
OpenCV
python-basics
How To
Installation Guide
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 Find the Wi-Fi Password Using CMD in Windows?
How to install Jupyter Notebook on Windows?
How to Align Text in HTML?
Java Tutorial
How to Install PIP on Windows ?
Installation of Node.js on Linux
How to install Jupyter Notebook on Windows?
How to Install FFmpeg on Windows?
How to Install and Run Apache Kafka on Windows?
Finding the first non-repeating character of a string in JavaScript

We are required to write a JavaScript function that takes in a string as the first and the only argument.
The function should find and return the index of first character it encounters in the string which appears only once in the string.
If the string does not contain any unique character, the function should return -1.
For example −
If the input string is −
const str = 'hellohe';
Then the output should be −
const output = 4;
Following is the code −
const str = 'hellohe';
const firstUnique = (str = '') => {
   let obj = {};
   for(let i = 0; i < str.length; i++){
      if(str[i] in obj){
         let temp = obj[str[i]];
         let x = parseInt(temp[0]);
         x += 1;
         temp[0] = x;
         obj[str[i]] = temp;
      } else {
         obj[str[i]] = [1, i]
      }
   }
   let arr = Object.keys(obj);
   for(let i = 0; i < arr.length; i++){
      let z = obj[arr[i]]
      if(z[0] === 1){
         return z[1];
      }
   }
   return -1;
};
console.log(firstUnique(str));
Following is the console output −
4
Find the Nth highest value of a vector in R - GeeksforGeeks

27 Jan, 2022

In this article, we will see how to find the Nth largest value of a vector in the R Programming Language.
Steps for finding nth largest element in vector R:
Step 1: Create a vector and take input from the user.
Syntax : variable name = readline()
Where 
Variable is the valid identifier.
readline() will take input from user.
Step 2: Convert our data from string to int.
Syntax: variable 1= as.integer(variable2);
Where
Variable1 is the valid identifier which will store integer value of variable 2
Variable 2 is string which is needed to convert to integer. 
Step 3: Finding nth largest number using 
Syntax: sort(vector name ,True) [n value])
Where 
Vector name is the vector that we created.
Here True is used as we needed this vector in descending order.
N value is which the largest number you want to print.
Example 1:
In this example, we are reading a value from the user. As it is in string format we are converting it into an integer. After that, we are sorting vector by using sort() and in sort, we are passing vector name, TRUE, and nth largest element.Here we are passing True as we need it in descending order. 
R
 

 
 










a<- c(1000,3000,4000)
 
x = readline();
 
# we are converting data from string to
# int and storing in x.
x = as.integer(x); 
 
# we are sorting vector and printing
# nth element.As this vector is in sorted 
# way we will get xth largest number 
print(sort(a,TRUE)[x])






Output:
[1] 4000
Here user input is 1 so the output is 4000 as we need to find the first largest element.
Example 2: In this example, we are reading a value from the user. As it is in string format we are converting it into an integer. After that, we are sorting vector by using sort() and in sort, we are passing vector name, TRUE, and yth the largest element.Here we are passing True as we need it in descending order. 
R
 

 
 










b<- c(1500, 334000, 33000)
 
# we are storing value given by user into y
y = readline();
 
# we are converting data from string to int and storing in y.
y = as.integer(y); 
 
# we are sorting vector and printing yth element. 
# As this vector is in sorted way(descending order)
# we will get yth largest number 
print(sort(b,TRUE)[y])






Output:
[1] 33000
Here user input is 2 so the output is 33000 as we need to find the second largest element.
as5853535
clintra

Picked


R Vector-Programs


R-Vectors


R Language


R Programs

Writing code in comment? 
                                    Please use ide.geeksforgeeks.org, 
                                    generate link and share the link here.
                                
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
Data Visualization in R
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
How to filter R dataframe by multiple conditions?
Merge DataFrames by Column Names in R
CSS3 Left to right Gradient

You can try to run the following code to implement left to right gradient in CSS3
Live Demo
<html>
   <head>
      <style>
         #grad1 {
            height: 100px;
            background: -webkit-linear-gradient(left, red , blue);
            background: -o-linear-gradient(right, red, blue);
            background: -moz-linear-gradient(right, red, blue);
            background: linear-gradient(to right, red , blue);
         }
      </style>
   </head>
   <body>
      <div id = "grad1"></div>
   </body>
</html>
How to Install Z Shell(zsh) on Linux? - GeeksforGeeks

05 Oct, 2021
The ZSH or Z Shell is a Unix based shell or can be called as a command-line interpreter. It is an extended version of the good old Bourne shell (sh). It does have some features form Bash with lots of added features like automatic cd (Change Directory), spell check, path expansion, and many more. It also supports plugins and themes.
Step 1: First, we will have to update the repository by running the following command:
sudo apt-get update
Step 2: Now we will install the zsh by running the following command:
sudo apt-get install zsh -y
Step 3: Now we have to make the zsh as our default shell using the following command:
chsh -s /usr/bin/zsh
Note: You will need to enter your password for the user after running the command.
Step 4: Now that we have set the zsh as our default shell, we have to configure it. So, we will run zsh in the terminal to execute it. This will show the Z shell configuration.
Step 5: Here you can do what is specified by typing the character given at the start of every line. You can quit, go in the main menu and configure the shell your self or you can go for the recommended configuration for the shell by pressing 2, which is what we have done.
Step 6: After this, the Z shell is ready to use. But the shell is not changed from bash to zsh.
Step 7: You will have to logout of your system and log back in to see the change. Open terminal and you should see the Z shell started. To check run the following command:
echo $SHELL
As you can see, it showed /usr/bin/zsh, which means it is successfully set as the default shell.
how-to-install
How To
Installation Guide
Linux-Unix
Technical Scripter
TechTips
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install FFmpeg on Windows?
How to Set Git Username and Password in GitBash?
How to Install Selenium on MacOS?
How to Set Java Path in Windows and Linux?
How to Create and Setup Spring Boot Project in Eclipse IDE?
Installation of Node.js on Linux
How to Install FFmpeg on Windows?
How to Install Selenium on MacOS?
How to Install Pygame on Windows ?
How to Install Jupyter Notebook on MacOS?
Underscore.JS - uniq method

_.uniq(array, [isSorted], [iteratee])

uniq method returns a array of unique values from an array. It uses type safe equaliy(===) check. If array is sorted, pass true to run a faster algorithm. A iteratee function can be passed to determine the uniqueness of items.
var _ = require('underscore');

var list1 = [11, 2, 14, 14, 2, 6]
var list2 = [1, 2, 3, 3, 3, 4, 5]
//Example 1: uniq values
result = _.uniq(list1);
console.log(result)

//Example 2: uniq values of an sorted array
result = _.uniq(list2, true);
console.log(result)
Save the above program in tester.js. Run the following command to execute this program.
\>node tester.js

[ 11, 2, 14, 6 ]
[ 1, 2, 3, 4, 5 ]

 Print
 Add Notes
 Bookmark this page
Erlang - If statement

The first decision making statement we will look at is the ‘if’ statement. The general form of this statement in Erlang is shown in the following program −
if
condition ->
   statement#1;
true ->
   statement #2
end.

In Erlang, the condition is an expression which evaluates to either true or false. If the condition is true, then statement#1 will be executed else statement#2 will be executed.
The following program is an example of the simple if expression in Erlang −
-module(helloworld). 
-export([start/0]). 

start() -> 
   A = 5, 
   B = 6, 
   
   if 
      A == B -> 
         io:fwrite("True"); 
      true -> 
         io:fwrite("False") 
   end.
The following important things need to be noted about the above program −
The expression being used here is the comparison between the variables A and B.
The expression being used here is the comparison between the variables A and B.
The -> operator needs to follow the expression.
The -> operator needs to follow the expression.
The ; needs to follow statement#1.
The ; needs to follow statement#1.
The -> operator needs to follow the true expression.
The -> operator needs to follow the true expression.
The statement ‘end’ needs to be there to signify the end of the ‘if’ block.
The statement ‘end’ needs to be there to signify the end of the ‘if’ block.
The output of the above program will be −
False

 Print
 Add Notes
 Bookmark this page
VBScript Month Function

The Month function returns a number between 1 and 12 that represents the month of the specified date.
Month(date) 

<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         document.write(Month("2013-06-30"))
       
      </script>
   </body>
</html>
When you save it as .html and execute it in Internet Explorer, then the above script will produce the following result −
6


    63 Lectures 
     4 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page
ExpressJS - Scaffolding

Scaffolding allows us to easily create a skeleton for a web application. We manually create our public directory, add middleware, create separate route files, etc. A scaffolding tool sets up all these things for us so that we can directly get started with building our application. 
The scaffolder we will use is called Yeoman. It is a scaffolding tool built for Node.js but also has generators for several other frameworks (like flask, rails, django, etc.). To install Yeoman, enter the following command in your terminal −
npm install -g yeoman

Yeoman uses generators to scaffold out applications. To check out the generators available on npm to use with Yeoman, you can click on this link. In this tutorial, we will use the 'generator-Express-simple'. To install this generator, enter the following command in your terminal −
npm install -g generator-express-simple

To use this generator, enter the following command −
yo express-simple test-app

You will be asked a few simple questions like what things you want to use with your app. Select the following answers, or if you already know about these technologies then go about choosing how you want them to be.
express-simple comes with bootstrap and jquery
[?] Select the express version you want: 4.x
[?] Do you want an mvc express app: Yes
[?] Select the css preprocessor you would like to use: sass
[?] Select view engine you would like to use: jade
[?] Select the build tool you want to use for this project: gulp
[?] Select the build tool you want to use for this project: gulp
[?] Select the language you want to use for the build tool: javascript
   create public/sass/styles.scss
   create public/js/main.js
   create views/layout.jade
   create views/index.jade
   create views/404.jade
   create app.js
   create config.js
   create routes/index.js
   create package.json
   create bower.json
identical .bowerrc
identical .editorconfig
identical .gitignore
identical .jshintrc
   create gulpfile.js

I'm all done. Running bower install & npm install for you to install the
required dependencies. If this fails, try running the command yourself.

It will then create a new application for you, install all the dependencies, add few pages to your application(home page, 404 not found page, etc.) and give you a directory structure to work on.
This generator creates a very simple structure for us. Explore the many generators available for Express and choose the one that fits you right. Steps to working with all generators is the same. You will need to install a generator, run it using Yeoman; it will ask you some questions and then create a skeleton for your application based on your answers.

    16 Lectures 
     1 hours 

 Anadi Sharma
 Print
 Add Notes
 Bookmark this page
What is the difference between BIT and TINYINT in MySQL?

BIT can be used to store the value of 1 bit. It could be 0 or 1. We cannot store, for example 2 with data type BIT. If we try to insert 2 with BIT data type, MySQL raises an error.
TINYINT can be used to store value of 8 bits. The maximum value we can store is 127.We cannot store, for example 987 with 8 bit value. If we try to insert 987 with TINYINT data type, MySQL raises an error.
Let us work it through MySQL version 8.0.12.
To check the version installed on your system.
mysql> select version();
The following is the output.
+-----------+
| version() |
+-----------+
| 8.0.12    |
+-----------+
1 row in set (0.00 sec)

Creating a table with BIT type.
mysql> create table BitDemo
   -> (
   -> Id BIT
   -> );
Query OK, 0 rows affected (0.56 sec)
Inserting records into the table ‘BitDemo’.
mysql> insert into BitDemo values(1);
Query OK, 1 row affected (0.13 sec)

mysql>  insert into BitDemo values(0);
Query OK, 1 row affected (0.33 sec)
We get an error whenever we insert 2 into Bit.
mysql> insert into BitDemo values(2);
ERROR 1406 (22001): Data too long for column 'Id' at row 1
Creating a table with TINYINT data type.
mysql> create table TinyIntDemo
   -> (
   -> Id TINYINT
   -> );
Query OK, 0 rows affected (0.69 sec)
Inserting records.
mysql> insert into TinyIntDemo values(123);
Query OK, 1 row affected (0.17 sec)

mysql>  insert into TinyIntDemo values(97);
Query OK, 1 row affected (0.15 sec)

mysql>  insert into TinyIntDemo values(127);
Query OK, 1 row affected (0.16 sec)
We get an error whenever we try to insert value exceeding 127.
mysql> insert into TinyIntDemo values(9876);
ERROR 1264 (22003): Out of range value for column 'Id' at row 1
mysql>  insert into TinyIntDemo values(987);
ERROR 1264 (22003): Out of range value for column 'Id' at row
mysql> insert into TinyIntDemo values(255);
ERROR 1264 (22003): Out of range value for column 'Id' at row 1
mysql> insert into TinyIntDemo values(254);
ERROR 1264 (22003): Out of range value for column 'Id' at row 1
mysql>  insert into TinyIntDemo values(200);
ERROR 1264 (22003): Out of range value for column 'Id' at row 1
mysql>  insert into TinyIntDemo values(199);
ERROR 1264 (22003): Out of range value for column 'Id' at row 1
The maximum value we can store is 127.
To display all valid inserted records, let us use the SELECT command.
mysql> select *from TinyIntDemo;
Here is the output.
+------+
| Id   |
+------+
|  123 |
|   97 |
|  127 |
+------+
3 rows in set (0.00 sec)
Understanding Array IndexOutofBoundsException in C#

Array IndexOutofBoundsException occurs in Java. The equivalent of it in C# is IndexOutOfRangeException.
The IndexOutOfRangeException occurs when Index is outside the bounds of the array.
 Live Demo
using System;
using System.IO;
using System.Collections.Generic;
namespace Demo {
   class Program {
      static void Main(string[] args) {
         int[] arr = new int[3];
         arr[0] = 5;
         arr[1] = 7;
         arr[2] = 8;
         arr[4] = 24; // this shows an error
      }
   }
}
The following is the output. It shows the following error −
Unhandled Exception:
System.IndexOutOfRangeException: Index was outside the bounds of the array.