code-rag-bench/online-tutorials huggingface dataset:
JavaScript | date.getYear() Function - GeeksforGeeks

30 Jul, 2021
The date.getYear() method in JavaScript is use to get the year in a specified date according to universal time. The year we get from the method getYear() is the current year minus 1900.
Syntax: 
date.getYear()
Here, date is the object of Date() class.
Parameter: This function does not accept any parameters.Return Value: This method returns a value which is subtracted from 1900 to current year.
Example 1: This example returns the year of the specified date according to universal time. 
Javascript
<script> // "date" is object of Date() classvar date = new Date(); // Use "getYear()" method and stores// the returned value to "n"var n = date.getYear(); // Display the resultdocument.write("The value returned by getYear() method: " + n) </script>                   
Output: 
The value returned by getYear() method: 119
Example 2: This example only send the year to the constructor. 
Javascript
<script> // Year 2000 is assign to the// constructor of Date() classvar date = new Date('2000')   // Use "getYear()" method and stores// the returned value to "n"var n = date.getYear();   // Display the returned value// The value is the subtraction of// 2000 and 1900  document.write("The value returned by getYear() method: " + n)   </script>
Output: 
The value returned by getYear() method: 100
Example 3: Here, we pass a full date to the constructor, the format of the date is month-day-year-time, such as October 15, 2010 02:05:32.
Javascript
<script> // Full date is assign to the constructor of Date() classvar date = new Date('October 15, 2010, 02:05:32') // Use "getYear()" method and stores the// returned value in "n"    var n = date.getYear();   // Display the returned value// The value is the subtraction of 2010 and 1900  document.write("The value returned by getYear() method: " + n)   </script>
Output: 
The value returned by getYear() method: 110
arorakashish0911
javascript-date
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
Matplotlib.pyplot.axvspan() in Python - GeeksforGeeks

12 Apr, 2020
Matplotlib is a plotting library for creating static, animated, and interactive visualizations in Python.\ Pyplot is a Matplotlib module which provides a MATLAB-like interface. Matplotlib is designed to be as usable as MATLAB, with the ability to use Python and the advantage of being free and open-source.
This function sets the vertical rectangle across the axes of the plot
Syntax: matplotlib.pyplot.axvspan(xmin, xmax, ymin=0, ymax=1, **kwargs)
Parameters:xmin :Number indicating the starting position of the vertical rectangle on X-axisxmin :Number indicating the ending position of the vertical rectangle on X-axisymin :vertical rectangle starting position on y axis, it will take values between 0 and 1, 0 being bottom of the axis, 1 being top of the axisymax :vertical rectangle ending position on y axis, it will take values between 0 and 1, 0 being bottom of the axis, 1 being top of the axis**kwargs :Other optional parameters to change the properties of the rectangle, like changing color etc.
Example #1:
# Importing matplotlib.pyplot as pltimport matplotlib.pyplot as plt  # Initializing x and yx =[1, 15, 27, 48, 50]y =[1, 12, 22, 45, 67]  # Plotting the graphplt.plot(x, y)  # Drawing rectangle starting # x = 5 and extending till x = 20# With vertical span starting at # half the length of y-axis(ymin = 0.5)# And extending till the top of # axis(ymax = 1)plt.axvspan(5, 20, ymin = 0.5, ymax = 1)plt.show()
Output:
Example #2:
import matplotlib.pyplot as plt    x =[1, 15, 27, 48, 50]y =[1, 12, 22, 45, 67]  plt.plot(x, y)  # Drawing rectangle starting # x = 5 and extending till x = 15# With vertical span starting at# 25 % the length of y-axis# And extending till the 80 % of# axis And also we are setting # the color of rectangle to yellow # and its edge color to blueplt.axvspan(5, 15, ymin = 0.25,            ymax = 0.80, ec ='blue',             color ='yellow')  plt.show()
Output :
Example #3:
import matplotlib.pyplot as plt    x =[1, 15, 27, 48, 50]y =[1, 12, 22, 45, 67]  plt.plot(x, y)  # Setting alpha will make # the rectangle transparentplt.axvspan(10, 30, ymin = 0.15,             ymax = 0.70, ec ='blue',            color ='yellow',            alpha = 0.5)  plt.show()
Output :
Python-matplotlib
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 ?
Different ways to create Pandas Dataframe
Python String | replace()
Reading and Writing to text files in Python
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
How To Convert Python Dictionary To JSON?
Convert integer to string in Python
Why can't Java generics be used for static methods?

Generics is a concept in Java where you can enable a class, interface and, method, accept all (reference) types as parameters. In other words it is the concept which enables the users to choose the reference type that a method, constructor of a class accepts, dynamically. By defining a class as generic you are making it type-safe i.e. it can act up on any datatype.
We can use generics for static methods
 Live Demo
public class GenericMethod {
   static <T>void sampleMethod(T[] array) {
      for(int i=0; i<array.length; i++) {
         System.out.println(array[i]);
      }
   }
   public static void main(String args[]) {
      GenericMethod obj = new GenericMethod();
      Integer intArray[] = {45, 26, 89, 96};
      sampleMethod(intArray);
      String stringArray[] = {"Krishna", "Raju", "Seema", "Geeta"};
      sampleMethod(stringArray);
      Character charArray[] = {'a', 's', 'w', 't'};
      sampleMethod(charArray);
   }
}
45
26
89
96
Krishna
Raju
Seema
Geeta
a
s
w
t
What we can’t use is static before the type parameters of generic class.
 Live Demo
class Student<T>{
   static T age;
   Student(T age){
      this.age = age;
   }
   public void display() {
      System.out.println("Value of age: "+this.age);
   }
}
public class GenericsExample {
   public static void main(String args[]) {
      Student<Float> std1 = new Student<Float>(25.5f);
      std1.display();
   }
}
GenericsExample.java:3: error: non-static type variable T cannot be referenced from a static context
      static T age;
            ^
1 error
Python | Plotting Google Map using gmplot package

11 Jun, 2018
gmplot is a matplotlib-like interface to generate the HTML and javascript to render all the data user would like on top of Google Maps.
Command to install gmplot :
pip install gmplot
 Code #1 : To create a Base Map
# import gmplot packageimport gmplot  # GoogleMapPlotter return Map object# Pass the center latitude and# center longitudegmap1 = gmplot.GoogleMapPlotter(30.3164945,                                78.03219179999999, 13 )  # Pass the absolute pathgmap1.draw( "C:\\Users\\user\\Desktop\\map11.html" )
Output : Code #2 : Another method To create a Base map
# import gmplot packageimport gmplot  # from_geocode method return the# latitude and longitude of given location .gmap2 = gmplot.GoogleMapPlotter.from_geocode( "Dehradun, India" )  gmap2.draw( "C:\\Users\\user\\Desktop\\map12.html" )
Output : Code #3 : Scatter points on the google map and draw a line in between them .
# import gmplot packageimport gmplot  latitude_list = [ 30.3358376, 30.307977, 30.3216419 ]longitude_list = [ 77.8701919, 78.048457, 78.0413095 ]  gmap3 = gmplot.GoogleMapPlotter(30.3164945,                                78.03219179999999, 13)  # scatter method of map object # scatter points on the google mapgmap3.scatter( latitude_list, longitude_list, '# FF0000',                              size = 40, marker = False )  # Plot method Draw a line in# between given coordinatesgmap3.plot(latitude_list, longitude_list,            'cornflowerblue', edge_width = 2.5)  gmap3.draw( "C:\\Users\\user\\Desktop\\map13.html" )
Output : Code #4 : To Show a heat map plot
# import gmplot packageimport gmplot  latitude_list = [30.3358376, 30.307977, 30.3216419, 30.3427904,                  30.378598, 30.3548185, 30.3345816, 30.387299,                    30.3272198, 30.3840597, 30.4158, 30.340426,                             30.3984348, 30.3431313, 30.273471]  longitude_list = [77.8701919, 78.048457, 78.0413095, 77.886958,                  77.825396, 77.8460573, 78.0537813, 78.090614,                    78.0355272, 77.9311923, 77.9663, 77.952092,                            78.0747887, 77.9555512, 77.9997158]  gmap4 = gmplot.GoogleMapPlotter.from_geocode("Dehradun, India")  # heatmap plot heating Type# points on the Google mapgmap4.heatmap( latitude_list, longitude_list )  gmap4.draw( "C:\\Users\\user\\Desktop\\map14.html" )
Output : Code #5 : To draw a polygon on the google map
# import gmplot packageimport gmplot  latitude_list = [ 30.3358376, 30.307977, 30.3216419 ]longitude_list = [ 77.8701919, 78.048457, 78.0413095 ]  gmap5 = gmplot.GoogleMapPlotter(30.3164945,                                78.03219179999999, 13)  gmap5.scatter( latitude_list, longitude_list, '# FF0000',                                size = 40, marker = False)  # polygon method Draw a polygon with# the help of coordinatesgmap5.polygon(latitude_list, longitude_list,                   color = 'cornflowerblue')  gmap5.draw( "C:\\Users\\user\\Desktop\\map15.html" )
Output :
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Vector size() Method in Java

17 Aug, 2018
The java.util.vector.size() method in Java is used to get the size of the Vector or the number of elements present in the Vector.
Syntax:
Vector.size()
Parameters: The method does not take any parameter.
Return Value: The method returns the size or the number of elements present in the Vector.
Below programs illustrate the Java.util.Vector.size() method:
Program 1: Vector with string elements.
// Java code to illustrate size()import java.util.*;  public class VectorDemo {    public static void main(String args[])    {        // Creating an empty Vector        Vector<String> vec_tor = new Vector<String>();          // Use add() method to add elements into the Vector        vec_tor.add("Welcome");        vec_tor.add("To");        vec_tor.add("Geeks");        vec_tor.add("4");        vec_tor.add("Geeks");          // Displaying the Vector        System.out.println("Vector: " + vec_tor);          // Displaying the size of Vector        System.out.println("The size is: " + vec_tor.size());    }}
Vector: [Welcome, To, Geeks, 4, Geeks]
The size is: 5

Program 2: Vector with integer elements.
// Java code to illustrate size()import java.util.*;  public class VectorDemo {    public static void main(String args[])    {        // Creating an empty Vector        Vector<Integer> vec_tor = new Vector<Integer>();          // Use add() method to add elements into the Vector        vec_tor.add(10);        vec_tor.add(15);        vec_tor.add(30);        vec_tor.add(20);        vec_tor.add(5);          // Displaying the Vector        System.out.println("Vector: " + vec_tor);          // Displaying the size of Vector        System.out.println("The size is: " + vec_tor.size());    }}
Vector: [10, 15, 30, 20, 5]
The size is: 5

Java - util package
Java-Collections
Java-Functions
Java-Vector
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Tkinter Fonts

There may be up to three ways to specify type style.
As a tuple whose first element is the font family, followed by a size in points, optionally followed by a string containing one or more of the style modifiers bold, italic, underline and overstrike.
("Helvetica", "16") for a 16-point Helvetica regular.
("Helvetica", "16") for a 16-point Helvetica regular.
("Times", "24", "bold italic") for a 24-point Times bold italic.
("Times", "24", "bold italic") for a 24-point Times bold italic.
You can create a "font object" by importing the tkFont module and using its Font class constructor −
import tkFont

font = tkFont.Font ( option, ... )
Here is the list of options −
family − The font family name as a string.
family − The font family name as a string.
size − The font height as an integer in points. To get a font n pixels high, use -n.
size − The font height as an integer in points. To get a font n pixels high, use -n.
weight − "bold" for boldface, "normal" for regular weight.
weight − "bold" for boldface, "normal" for regular weight.
slant − "italic" for italic, "roman" for unslanted.
slant − "italic" for italic, "roman" for unslanted.
underline − 1 for underlined text, 0 for normal.
underline − 1 for underlined text, 0 for normal.
overstrike − 1 for overstruck text, 0 for normal.
overstrike − 1 for overstruck text, 0 for normal.
helv36 = tkFont.Font(family = "Helvetica",size = 36,weight = "bold")
If you are running under the X Window System, you can use any of the X font names.
For example, the font named "-*-lucidatypewriter-medium-r-*-*-*-140-*-*-*-*-*-*" is the author's favorite fixed-width font for onscreen use. Use the xfontsel program to help you select pleasing fonts.
Output of C++ Program | Set 12

28 Sep, 2018
Predict the output of following C++ programs.
Question 1
#include <iostream>using namespace std;  int fun(int a, int b  = 1, int c =2){    return (a + b + c);}  int main(){    cout << fun(12, ,2);    return 0;}
Output: Compiler Error in function call fun(12, ,2)With default arguments, we cannot skip an argument in the middle. Once an argument is skipped, all the following arguments must be skipped. The calls fun(12) and fun(12, 2) are valid.
Question 2
#include<iostream>using namespace std;  /* local variable is same as a member's name */class Test{private:    int x;public:    void setX (int x) { Test::x = x; }    void print() { cout << "x = " << x << endl; }};  int main(){    Test obj;    int x = 40;    obj.setX(x);    obj.print();    return 0;}
Output:
x = 40
Scope resolution operator can always be used to access a class member when it is made hidden by local variables. So the line “Test::x = x” is same as “this->x = x”
Question 3
#include<iostream>using namespace std;  class Test {private:    int x;    static int count;public:    Test(int i = 0) : x(i) {}    Test(const Test& rhs) : x(rhs.x) { ++count;  }    static int getCount() { return count; }};  int Test::count = 0;  Test fun() {    return Test();}  int main(){    Test a = fun();    cout<< Test::getCount();    return 0;}
Output: Compiler DependentThe line “Test a = fun()” may or may not call copy constructor. So output may be 0 or 1. If copy elision happens in your compiler, the copy constructor will not be called. If copy elision doesn’t happen, copy constructor will be called. The gcc compiler produced the output as 0.
Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above.
CPP-Output
Program Output
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Runtime Errors
Different ways to copy a string in C/C++
Output of Java Program | Set 3
Output of Java Programs | Set 12
Output of C++ programs | Set 47 (Pointers)
Output of Java Program | Set 7
Output of C Programs | Set 3
Output of C programs | Set 59 (Loops and Control Statements)
Output of Java program | Set 15 (Inner Classes)
unsigned specifier (%u) in C with Examples
Sorting a Strings in Java

In order to sort a string in java we could use the arrays API and its inbuilt method sort which internally implementing sorting algorithm and would return a sorted string.
First we will convert our string into a character array and then sort this array using sort method of Arrays class in Java now we have sorted array from which we would construct a new string using sorted array as its parameter in constructor.
 Live Demo
import java.util.Arrays;
public class StringSort {
   public static void main(String[] args) {
      String str ="fghryisnskfg";
      char[] arr = str.toCharArray();
      Arrays.sort(arr);
      String str1 = new String(arr);
      System.out.println(str1);
   }
}
myCSV.csv file created with following text −
ffgghiknrssy
Seaborn - Kernel Density Estimates

Kernel Density Estimation (KDE) is a way to estimate the probability density function of a continuous random variable. It is used for non-parametric analysis.
Setting the hist flag to False in distplot will yield the kernel density estimation plot.
import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt
df = sb.load_dataset('iris')
sb.distplot(df['petal_length'],hist=False)
plt.show()

distplot() is used to visualize the parametric distribution of a dataset.
import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt
df = sb.load_dataset('iris')
sb.distplot(df['petal_length'])
plt.show()

Bivariate Distribution is used to determine the relation between two variables. This mainly deals with relationship between two variables and how one variable is behaving with respect to the other.
The best way to analyze Bivariate Distribution in seaborn is by using the jointplot() function.
Jointplot creates a multi-panel figure that projects the bivariate relationship between two variables and also the univariate distribution of each variable on separate axes.
Scatter plot is the most convenient way to visualize the distribution where each observation is represented in two-dimensional plot via x and y axis.
import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt
df = sb.load_dataset('iris')
sb.jointplot(x = 'petal_length',y = 'petal_width',data = df)
plt.show()

The above figure shows the relationship between the petal_length and petal_width in the Iris data. A trend in the plot says that positive correlation exists between the variables under study.
Hexagonal binning is used in bivariate data analysis when the data is sparse in density i.e., when the data is very scattered and difficult to analyze through scatterplots.
An addition parameter called ‘kind’ and value ‘hex’ plots the hexbin plot.
import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt
df = sb.load_dataset('iris')
sb.jointplot(x = 'petal_length',y = 'petal_width',data = df,kind = 'hex')
plt.show()

Kernel density estimation is a non-parametric way to estimate the distribution of a variable. In seaborn, we can plot a kde using jointplot().
Pass value ‘kde’ to the parameter kind to plot kernel plot.
import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt
df = sb.load_dataset('iris')
sb.jointplot(x = 'petal_length',y = 'petal_width',data = df,kind = 'hex')
plt.show()


    11 Lectures 
     4 hours 

 DATAhill Solutions Srinivas Reddy

    11 Lectures 
     2.5 hours 

 DATAhill Solutions Srinivas Reddy
 Print
 Add Notes
 Bookmark this page
How MySQL REPEAT loop statement can be used in stored procedure?

As we know that MySQL provides us loop statements that allow us to execute a block of SQL code repeatedly based on a condition. A REPEAT loop statement is one of such kind of loop statement. Its syntax is as follows −
REPEAT
   statements;
UNTIL expression
END REPEAT
First of all, MySQL executes the statements, and then it evaluates the expression. If the expression evaluates to FALSE, MySQL executes the statements repeatedly until the expression evaluates to TRUE. The REPEAT loop checks the expression after the statements execute, that is why it is also called a post-test loop.
To demonstrate the use of a REPEAT loop with stored procedures, the following is an example −
mysql> Delimiter //
mysql> CREATE PROCEDURE Repeat_Loop()
   -> BEGIN
   -> DECLARE A INT;
   -> DECLARE XYZ Varchar(50);
   -> SET A = 1;
   -> SET XYZ = '';
   -> REPEAT
   -> SET XYZ = CONCAT(XYZ,A,',');
   -> SET A = A + 1;
   -> UNTIL A > 10
   -> END REPEAT;
   -> SELECT XYZ;
   -> END //
Query OK, 0 rows affected (0.04 sec)
Now, we can see the result below when we invoke this procedure −
mysql> DELIMITER ;
mysql> CALL Repeat_Loop();
+-----------------------+
| XYZ                   |
+-----------------------+
| 1,2,3,4,5,6,7,8,9,10, |
+-----------------------+
1 row in set (0.00 sec)

Query OK, 0 rows affected (0.01 sec)
Piece-wise Linear Transformation

05 Dec, 2019
Piece-wise Linear Transformation is type of gray level transformation that is used for image enhancement. It is a spatial domain method. It is used for manipulation of an image so that the result is more suitable than the original for a specific application.
Some commonly used piece-wise linear transformations are:
Contrast Stretching:Low contrast image occur often due to improper illumination or non-linearly or small dynamic range of an imaging sensor. It increases the dynamic range of grey levels in the image.
Contrast Stretching Transform is given by:
S = l.r, 0 <= r < a
S = m.(r-a) + v, a <= r < b
S = n.(r-b) + w, b <= r < L-1
where l, m, n are slopes 
Clipping:A special case of contrast stretching is clipping where l=n=0. It is used for noise reduction when the input signal is known. It puts all grey levels below r1 to black(0) and above r2 to white(1).
Thresholding:Another special case of contrast stretching is thresholding where l=m=t. It is also used for noise reduction. It preserves the grey levels beyond r1.
Grey level slicing:Highlighting a specific range of grey level in an image.
Case-I:
To display a high value for all grey levels in the range of interest.
To display a low value for all grey levels.
Case-II:
Brighten the desired range og grey level.
Preserve the background quality in the range.
Bit Extraction:An 8-bit image can be represented in the form of bit plane. Each plane represents one bit of all pixel values. Bit plane 7 contains the most significant bit (MSB) and bit plane 0 contains least significant bit (LSB). The 4 MSB planes contains most of visually significant data. This technique is useful for image compression and steganography.
computer-graphics
Image-Processing
Misc
Misc
Misc
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between readFile and createReadStream in Node.js

03 Aug, 2021
In this article, we will discuss the difference between readFile and createReadStream in Nodejs. Both are modules that allow us to open a file/stream and read data present in it.
1. readFile: fs module contains the readFile method. It is used to read a file by bringing it into the buffer. It is an asynchronous method and due to this, it reads the file without blocking the execution of the code. First, we bring the fs module into our app then use the readFile method inside it.
Syntax:
fs.readFile( filename, encoding, callback_function)
Parameters:
filename: It holds the path to the file which has to be read.
encoding: It holds the encoding of the file. If no option is specified, then the raw buffer is returned, Default value is ‘utf8’.
callback_function: It is a function that gets called after reading the file and contains two parameters err and data. If any error is encountered then it gets stored in err else content of the file is stored in data.
Return Value: It returns the content of a file.
Example: In this example, we are reading the file using the readFile method, File to be read is output.txt.
output.txt file:
This is an output file read from readFile method.
index.js
const fs = require('fs');fs.readFile('output.txt', 'utf8', (err, data) => {  console.log(`Data present in the file is::    ${data}`);});console.log('Outside readFile method');
Output:
Outside readFile method
Data present in the file is::   
This is an output file read from readFile method.
2. createReadStream: fs module contains the inbuilt API(Application programming interface) createReadStream.It allows us to open a file/stream and reads the data present inside it.
Syntax:
fs.createReadStream(path, options)
Parameters:
path: It holds the path to the file which has to be read. It could be the string, URL of the buffer.
options: It is an optional parameter. We can pass a string or object to it.
Return Value: It returns the object of ReadObject Stream.
 
Example: In this example, We are reading file name output.txt by createReadStream.on method.
Output.txt file:
This is an output file read from createReadStream method.
index.js
const fs = require('fs');const createReader = fs.createReadStream('output.txt');  createReader.on('data', (data) => {  console.log(data.toString());});  console.log('Outside createReader.on method');
Output:
Outside createReader.on method
This is an output file read from createReadStream method.
Difference between readFile and createReadStream:
readFile
createReadStream
It reads the file into the memory before making it available 
to the user.
It will not scale in case of too many requests as it will try to load
them all at the same time.
It is scalable as it pipes the content directly to the HTTP
response object
Due to its property, it is easier for nodejs to handle cleaning of memory in this case.
NodeJS-Questions
Picked
Difference Between
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Node.js os.homedir() Method

13 Oct, 2021
The os.homedir() method is an inbuilt application programming interface of the os module which is used to get path of the home directory for the current user.
Syntax:
os.homedir()
Parameters: This method does not accept any parameters.
Return Value: This method returns a string specifies the path of the home directory for the current user.
On windows, It collects its value from an environment variable called USERPROFILE if defined. Otherwise, it returns the path to the profile directory for the current user.
On POSIX, It collects its value from an environment variable called $HOME if defined. Otherwise, it returns the home directory for some effective UID.
Below examples illustrate the use of os.homedir() method in Node.js:
Example 1:
// Node.js program to demonstrate the   // os.homedir() method  // Allocating os moduleconst os = require('os');  // Printing os.homedir() valueconsole.log(os.homedir());
Output:
C:\Users\gekcho

Example 2: Alternative way to find home directory
// Node.js program to demonstrate the   // os.homedir() method  // Allocating os moduleconst os = require('os');  console.log(getUserHome());   function getUserHome() {          // Return the value using process.env    return process.env[(process.platform ==           'win32') ? 'USERPROFILE' : 'HOME'];}
Output:
C:\Users\gekcho

Note: The above program will compile and run by using the node index.js command.
Reference: https://nodejs.org/api/os.html#os_os_homedir
Node.js-os-module
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Count number of a class objects created in Java

10 Oct, 2019
The idea is to use static member in the class to count objects. A static member is shared by all objects of the class, all static data is initialized to zero when the first object is created if no other initialization is present, And constructor and static member function can only access static data member, other static member functions and any other functions from outside the class.
We create a static int type variable and put this a static variable with an increment operator so that it increases by 1 in the constructor.
// Java program Find Out the Number of Objects Created// of a Classclass Test {      static int noOfObjects = 0;      // Instead of performing increment in the constructor    // instance block is preferred to make this program generic.    {        noOfObjects += 1;    }      // various types of constructors    // that can create objects    public Test()    {    }    public Test(int n)    {    }    public Test(String s)    {    }      public static void main(String args[])    {        Test t1 = new Test();        Test t2 = new Test(5);        Test t3 = new Test("GFG");          // We can also write t1.noOfObjects or        // t2.noOfObjects or t3.noOfObjects        System.out.println(Test.noOfObjects);    }}
3

amanbaidkdl
Java-Class and Object
Technical Scripter 2018
Java
Technical Scripter
Java-Class and Object
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Val() and Sum() Function in MS Access

02 Sep, 2020
1. Val() Function :val() function returns the number found in the string. In this function, it takes a string as a parameter and it will return the number in the string.
Note : This function will stop reading when the first non-numeric character comes.
Syntax :
Val(string) 
Example-1 :
SELECT Val("234geeksforgeeks12") 
AS ValNum;
Output –
Example-2 :
SELECT Val("345") 
AS ValNum;
Output –
2. Sum() Function :Sum() function returns the sum of the set of value. In this function, the set of value is passed as a parameter and it will return the sum.
Note : Null value will be ignored by this function.
Syntax :
Sum(expression) 
Demo Database for example :
Table name : student
Example-1 :
SELECT Sum(marks) AS Total 
From student;
Output –
Example-2 :
SELECT Sum(marks) AS Total 
From student Where marks>50;
Output –
DBMS-SQL
SQL-Server
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 Interview Questions
SQL | Sub queries in From Clause
Difference between DDL and DML in DBMS
Difference between DELETE, DROP and TRUNCATE
MySQL | Group_CONCAT() Function
SQL Correlated Subqueries
SQL | GROUP BY
Window functions in SQL
Difference between DELETE and TRUNCATE
Python 3 - Tkinter Frame

The Frame widget is very important for the process of grouping and organizing other widgets in a somehow friendly way. It works like a container, which is responsible for arranging the position of other widgets.
It uses rectangular areas in the screen to organize the layout and to provide padding of these widgets. A frame can also be used as a foundation class to implement complex widgets.
Here is the simple syntax to create this widget −
 w = Frame ( master, option, ... )

master − This represents the parent window.
master − This represents the parent window.
options − Here is the list of most commonly used options for this widget. These options can be used as key-value pairs separated by commas.
options − Here is the list of most commonly used options for this widget. These options can be used as key-value pairs separated by commas.
bg
The normal background color displayed behind the label and indicator.
bd
The size of the border around the indicator. Default is 2 pixels.
cursor
If you set this option to a cursor name (arrow, dot etc.), the mouse cursor will change to that pattern when it is over the checkbutton.
height
The vertical dimension of the new frame.
highlightbackground
Color of the focus highlight when the frame does not have focus.
highlightcolor
Color shown in the focus highlight when the frame has the focus.
highlightthickness
Thickness of the focus highlight.
relief
With the default value, relief = FLAT, the checkbutton does not stand out from its background. You may set this option to any of the other styles
width
The default width of a checkbutton is determined by the size of the displayed image or text. You can set this option to a number of characters and the checkbutton will always have room for that many characters.
Try the following example yourself −
# !/usr/bin/python3
from tkinter import *

root = Tk()
frame = Frame(root)
frame.pack()

bottomframe = Frame(root)
bottomframe.pack( side = BOTTOM )

redbutton = Button(frame, text = "Red", fg = "red")
redbutton.pack( side = LEFT)

greenbutton = Button(frame, text = "Brown", fg="brown")
greenbutton.pack( side = LEFT )

bluebutton = Button(frame, text = "Blue", fg = "blue")
bluebutton.pack( side = LEFT )

blackbutton = Button(bottomframe, text = "Black", fg = "black")
blackbutton.pack( side = BOTTOM)

root.mainloop()
When the above code is  executed, it produces the following result −

    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
DateTime.Compare() Method in C#

The DateTime.Compare() method in C# is used for comparison of two DateTime instances. It returns an integer value,
<0 − If date1 is earlier than date2
0 − If date1 is the same as date2
>0 − If date1 is later than date2
Following is the syntax −
public static int Compare (DateTime d1, DateTime d2);
Above, d1 and d2 are the two dates to be compared.
Let us now see an example to implement the DateTime.Compare() method −
using System;
public class Demo {
   public static void Main(){
      DateTime d1 = new DateTime(2019, 11, 20, 6, 20, 40);
      DateTime d2 = d1.AddYears(5);
      Console.WriteLine("Initial DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d1);
      Console.WriteLine("New DateTime (adding years) = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d2);
      int res = DateTime.Compare(d1, d2);
      // returns <0 since d1 is earlier than d2
      Console.WriteLine(res);
   }
}
This will produce the following output −
Initial DateTime = 20 November 2019, 06:20:40
New DateTime (adding years) = 20 November 2024, 06:20:40
-1
Let us now see another example to implement the DateTime.Compare() method −
using System;
public class Demo {
   public static void Main(){
      DateTime d1 = new DateTime(2019, 11, 20, 6, 20, 40);
      DateTime d2 = new DateTime(2019, 11, 20, 6, 20, 40);
      Console.WriteLine("DateTime 1 = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d1);
      Console.WriteLine("DateTime 2 = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d2);
      int res = DateTime.Compare(d1, d2);
      // returns equal to 0 since d1 is equal to d2
      Console.WriteLine(res);
   }
}
This will produce the following output −
DateTime 1 = 20 November 2019, 06:20:40
DateTime 2 = 20 November 2019, 06:20:40
0
Creating a button in tkinter in Python

As a library for Python Tkinter offers many ways to create a button on the tkinter canvas. In this article we will see how we can create a tkinter button with normal tkinter module as well as how to get it without using the themed tkinter module.
In the program below we first create a canvas and then apply the Button method to create a button. We import the entire tkinter module, so the themes get applied to the button we create.
# import everything from tkinter module
from tkinter import *

# create canvas
canv = Tk()

# Open canvas
canv.geometry('200x150')

# Create a Button
btn = Button(canv, text='Welcome to Tkinter!', bd='5',
            command=canv.destroy)

# Set the button position.
btn.pack(side='top')

canv.mainloop()
Running the above code gives us the following result −
We repeat the above process but this time we also include the tkinter.ttk module. It does not have the border (bd) option but it provides a light blue highlight colour when the mouse is brought over the button.
# import everything from tkinter module
from tkinter import *
from tkinter.ttk import *

# create a canvas
canv = Tk()


# Open a window
canv.geometry('200x150')

# Create a Button
btn = Button(canv, text='Welcome to Tkinter!',
            command=canv.destroy)

# Set the button position.

btn.pack(side='top')

canv.mainloop()
Running the above code gives us the following result −
Execution of printf with ++ operators in C

In some problems we can find some printf() statements are containing some lines with ++ operator. In some questions of competitive examinations, we can find these kind of questions to find the output of that code. In this section we will see an example of that kind of question and try to figure out what will be the answer.
#include<stdio.h>
int main() {
   volatile int x = 20;
   printf("%d %d\n", x, x++);
   x = 20;
   printf("%d %d\n", x++, x);
   x = 20;
   printf("%d %d %d ", x, x++, ++x);
   return 0;
}
Now we will try to guess what will be the output. Most of the compilers takes each parameter of printf() from right to left. So in the first printf() statement, the last parameter is x++, so this will be executed first, it will print 20, after that increase the value from 20 to 21. Now print the second last argument, and show 21. Like that other lines are also calculated in this manner. For ++x, it will increase the value before printing, and for x++, it prints the value at first, then increase the value.
Please check the output to get the better understanding.
21 20
20 20
22 21 21
JQuery | makeArray() Method - GeeksforGeeks

29 Apr, 2020
This makeArray() method in jQuery is used to convert an array-like object into a true JavaScript array.
Syntax:
jQuery.makeArray( obj )
Parameters: This method accept a single parameter which is mentioned above and described below:
obj : This parameter holds an object to turn into a native Array.
Return Value: It returns the array.
Below examples illustrate the use of makeArray() method in jQuery:
Example 1: This example use jQuery.makeArray() method and turn a collection of HTMLElements into an Array of them.
<!DOCTYPE html><html>  <head>    <meta charset="utf-8">    <title>JQuery | makeArray() method</title>    <script src="https://code.jquery.com/jquery-3.4.1.js">    </script>  </head>  <body style="text-align:center;">      <h1 style="color: green">         GeeksforGeeks     </h1>      <h3>JQuery | makeArray () method</h3>    <p>Geeks1</p>    <p>Geeks2</p>    <p>Geeks3</p>    <button onclick="geek()">Click</button>    <br>    <br>    <b id="root"></b>      <script>        function geek() {            var elems = document.getElementsByTagName("p");            var x = jQuery.makeArray(elems);            var t = x[1];            x[1] = x[2];            x[2] = t;            $(x).appendTo(document.body);        }    </script></body>  </html>
Output:
Example 2: This example use jQuery.makeArray() method and convert an array-like string into the actual array.
<!DOCTYPE html><html>  <head>    <meta charset="utf-8">    <title>JQuery | makeArray() method</title>    <script src="https://code.jquery.com/jquery-3.4.1.js">    </script>  </head>  <body style="text-align:center;">      <h1 style="color: green">         GeeksforGeeks     </h1>      <h3>JQuery | makeArray() method</h3>    <b>String = "[2, 5, 6, 3, 8, 9]"</b>    <br>    <br>    <button onclick="geek()">Click</button>    <br>    <br>    <b id="root"></b>      <script>        function geek() {            var el = document.getElementById('root');            var arr = "[2, 5, 6, 3, 8, 9]";              var newArr = jQuery.makeArray(arr)            el.innerHTML = jQuery.type(newArr) + " = " + newArr;        }    </script></body>  </html>                   
Output:
jQuery-Methods
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Form validation using jQuery
How to Dynamically Add/Remove Table Rows using jQuery ?
Scroll to the top of the page using JavaScript/jQuery
How to get the ID of the clicked button using JavaScript / jQuery ?
jQuery | children() with Examples
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
How to specify the width and height of the canvas using HTML ? - GeeksforGeeks

30 Sep, 2020
The <canvas> tag in HTML is used to draw graphics on web page using JavaScript. It can be used to draw paths, boxes, texts, gradient, and adding images. By default, it does not contain borders and text.
Syntax:
<canvas id="canvasID"> HTML Contents... <canvas>

Attributes: The canvas tag has two attributes which are listed below.
height: This attribute is used to set the height of canvas.
width: This attribute is used to set the width of canvas.
Example 1:
HTML
<!-- HTML code to illustrate height and     width attribute of canvas tag --><!DOCTYPE html><html>  <body style="text-align:center;">    <h1 style="color:green;">        GeeksforGeeks    </h1>    <h3>        How to specify the width        and height of the canvas?    </h3>      <canvas id="canvasID" height="200" width="200"         style="border:1px solid black">    </canvas></body></html>
Output:
Example 2:
HTML
<!-- HTML code to illustrate height and    width attribute of canvas tag --><!DOCTYPE html><html>  <body style="text-align:center;">    <h1 style="color:green;">        GeeksforGeeks    </h1>    <h3>        How to specify the width        and height of the canvas?    </h3>      <canvas id="canvasID" height="200" width="200"         style="border:1px solid black">    </canvas>      <script>        var canvas = document.getElementById("canvasID");        // Getting a drawing context in the canvas        var context = canvas.getContext("2d");        context.beginPath();        context.arc(100, 100, 90, 0, 2 * Math.PI);        context.stroke();     </script></body>  </html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Canvas
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
HTML Cheat Sheet - A Basic Guide to HTML
Design a web page using HTML and CSS
Form validation using jQuery
Angular File Upload
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
How to Export and import CSV file manually in PowerShell?

When you run a command Export-Csv in PowerShell, it automatically creates a CSV file to the specific location.
Get-Service | Select Name, Starttype, Status | Export-Csv C:\temp\services.csv -NoTypeInformation
In the above example, Services.csv file created in C:\Temp folders with the header Name, Starttype, and Status headers.
Similarly, you can use the other commands to get the output into the CSV file format.
If you want to check this file from the PowerShell console, you need to use Import-CSV command.
Import-Csv C:\temp\Services.csv | ft -Autosize
Name                                     StartType       Status
----                                     ---------       ------
AarSvc_7a82a                             Manual          Stopped
AdobeARMservice                          Automatic       Running
AdobeFlashPlayerUpdateSvc                Manual          Stopped
AJRouter                                 Manual          Stopped
ALG                                      Manual          Stopped
AppIDSvc                                 Manual          Stopped
Appinfo                                  Manual          Running
AppMgmt                                  Manual          Stopped
AppReadiness                             Manual          Stopped
AppVClient                               Disabled        Stopped
AppXSvc                                  Manual          Stopped
AssignedAccessManagerSvc                 Manual          Stopped
AudioEndpointBuilder                    Automatic        Running
If you need only Name and Status then you can use Select command after pipeline
Import-Csv C:\temp\Services.csv | Select Name,Status
Name                                        Status
----                                        ------
AarSvc_7a82a                                Stopped
AdobeARMservice                             Running
AdobeFlashPlayerUpdateSvc                   Stopped
AJRouter                                    Stopped
ALG                                         Stopped
AppIDSvc                                    Stopped
Appinfo                                     Running
AppMgmt                                     Stopped
AppReadiness                                Stopped
AppVClient                                  Stopped
AppXSvc                                     Stopped
Move Axis Label Closer to Plot in Base R - GeeksforGeeks

29 Jun, 2021
In this article, we will discuss how to move the axis label closer to the plot in R Programming Language.
Before changing the distance, let us see how the initial plot will look like.
Example:
R
x <- seq(-pi,pi,0.1)  plot(x, sin(x),    main="The Sine Function",    ylab="sin(x)",    type="l",    col="blue")
Output:
Output 1- See the gap between sin(x) and y variable points
In the above example simply add the title() function with line argument. To move axis labels closer to the axis pass appropriate value to the line argument.
Example:
R
x <- seq(-pi,pi,0.1)  plot(x, sin(x),    main="The Sine Function",    ylab="",    type="l",    col="blue")  title(ylab="sin(x)", line=2, cex.lab=1.2)
Output:
Now check the difference!
The second way to achieve the same desired output will be to adjust the mgp values. The default value for distance between axis and axis name is 3. Reduce the value to reduce the distance between them.
Syntax:
mgp(title, labels, line margin )
Parameters:
title margin line for the axis title and its default value is 3.
labels margin line for the axis labels and its default value is 1.
Line margin value for the axis line and its default line is 0.
Example:
R
x <- seq(-pi,pi,0.1)  plot(x, sin(x),    main="The Sine Function",    ylab="",    type="l",    col="blue")  title(ylab="sin(x)", mgp=c(2,1,0),cex.lab=1.2)
Output:
Difference is same as line= 2.
Picked
R-Charts
R-Graphs
R-plots
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
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?
Logistic Regression in R Programming
How to import an Excel File into R ?
How to filter R DataFrame by values in a column?
How to change the order of bars in bar chart in R ?
R - if statement
Replace Specific Characters in String in R