code-rag-bench/online-tutorials huggingface dataset:
Are quotes around tables and columns in a MySQL query really necessary?

If your table name or column name are any reserved words then you need to use quotes around table name and column name in a MySQL query. You need to use backticks around table name and column name. The syntax is as follows:
SELECT *FROM `table` where `where`=condition;
Here is the query to create a table without quotes with reserved words. You will get an error since they are predefined reserved words. The error is as follows:
mysql> create table table
   -> (
   -> where int
   -> );
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'table
(
   where int
)' at line 1
Let us now include quotes around the name of the table and column since ‘table’ and ‘where’ are reserved words. Here is the query with quotes:
mysql> create table `table`
   -> (
   -> `where` int
   -> );
Query OK, 0 rows affected (0.55 sec)
Insert records in the table using insert command. The query is as follows:
mysql> insert into `table`(`where`) values(1);
Query OK, 1 row affected (0.13 sec)
mysql> insert into `table`(`where`) values(100);
Query OK, 1 row affected (0.26 sec)
mysql> insert into `table`(`where`) values(1000);
Query OK, 1 row affected (0.13 sec)
Display a specific record from the table with the help of where condition. The query is as follows:
mysql> select *from `table` where `where`=100;
The following is the output:
+-------+
| where |
+-------+
| 100   |
+-------+
1 row in set (0.00 sec)
How to print calendar for a month in Python?

You can use the calender module to get the calender for a given month of a given year in Python. You need to provide the year and month as arguments. 
import calendar
y = 2017
m = 11
print(calendar.month(y, m))
This will give the output −
   November 2017
Mo Tu We Th Fr Sa Su
       1  2  3  4  5
 6  7  8  9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Rexx - do-until Loop

The do-until loop is a slight variation of the do while loop. This loop varies in the fact that is exits when the condition being evaluated is false.
The syntax of the do-until statement is as follows −
do until (condition) 
   statement #1 
   statement #2 
   ... 
end

The do-until statement is different from the do-while statement in the fact, that it will only execute the statements until the condition evaluated is true. If the condition is true, then the loop is exited.
The following diagram shows the diagrammatic explanation of this loop.
The key thing to note is that the code block runs till the condition in the do-until evaluates to false. As soon as the condition evaluates to true, the do loop exits.
The following program is an example of a do-until loop statement.
/* Main program */ 
j = 1 

do until (j <= 10) 
   say j 
   j = j + 1 
end
The output of the above code will be −
1 

 Print
 Add Notes
 Bookmark this page
ASP GetSpecialFolder Method - GeeksforGeeks

03 Mar, 2021
 The ASP GetSpecialFolder Method is used to return a reference to a specified special Folder. 
Syntax:
FileSystemObject.GetSpecialFolder(foldername) 
Parameter Values 
FolderName: Required attribute. It specifies the name of the special folder to be returned. It contains a numeric value between 0 and 2 which represents three different types of folders as shown below. 
0=WindowsFolder- Contains files installed by the Windows operating system
1=SystemFolder- Contains libraries, fonts, and device drivers.
2=TemporaryFolder- Used to store temporary files.
Example: Below code demonstrates the ASP GetSpecialFolder Method.  
ASP
<%dim fs,pset fs=Server.CreateObject("Scripting.FileSystemObject")set p=fs.GetSpecialFolder(1)Response.Write(p)set p=nothingset fs=nothing%>
Output:
C:\WINNT\system32
ASP-Basics
ASP-Methods
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Front End Developer Skills That You Need in 2022
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
How to redirect to another page in ReactJS ?
How to Insert Form Data into Database using PHP ?
How to pass data from child component to its parent in ReactJS ?
How to execute PHP code using command line ?
REST API (Introduction)
What is a JAR file?

A java archive file is a file format/ archiving tool which contains all the components of an executable Java application. All the predefined libraries are available in this format.
To include any of these (other than rt.jar) in to your project you need to set the class path for this particular JAR file. You can create a JAR file using the command line options or using any IDE’s.
You can create a Jar file using the jar command as shown below.
jar cf jar-file input-file(s)

Let us consider an example, create a Sample Java program with name Sample.java
public class Sample {
   public static void main(String args[]){
      System.out.println("Hi welcome to Tutorialspoint");
   }
}
If you compile this program using Javac command as shown below −
C:\Examples >javac Sample.java

This command compiles the given java file and generates a .class file (byte code)
Now, create a jar file for the generated class as −
C:\Sample>jar cvf sample.jar *.class
added manifest
adding: Sample.class(in = 434) (out= 302)(deflated 30%)

This will generate a jar file for all the classes in the current directory (since we used * instead of name) with specified name.
Angular forms FormGroupName Directive - GeeksforGeeks

04 Jul, 2021
In this article, we are going to see what is FormGroupName in Angular 10 and how to use it. The FormGroupName is used to sync a nested FormGroup to a DOM element.
Syntax:
<form [FormGroupName] ="details">
Exported from:
ReactiveFormsModule
Selectors:
[FormGroupName]
 
Approach: 
Create the Angular app to be used
In app.component.ts make an object that contain value for the input.
In app.component.html use FormGroupName to get values.
Serve the angular app using ng serve to see the output.
Example:
app.component.ts
import { Component, Inject } from '@angular/core';  import { FormGroup, FormControl, FormArray } from '@angular/forms'  @Component({    selector: 'app-root',    templateUrl: './app.component.html',    styleUrls: [ './app.component.css' ]  })  export class AppComponent  {    form = new FormGroup({      details: new FormGroup({        name: new FormControl(),        email: new FormControl()      })    });      get name(): any {      return this.form.get('details.name');    }    get email(): any {      return this.form.get('details.email');    }        onSubmit(): void {      console.log(this.form.value);     }      }
app.module.ts
import { NgModule } from '@angular/core';  // Importing forms moduleimport { FormsModule, ReactiveFormsModule  } from '@angular/forms';import { BrowserModule } from '@angular/platform-browser';import { BrowserAnimationsModule }     from '@angular/platform-browser/animations';  import { AppComponent }   from './app.component';   @NgModule({  bootstrap: [    AppComponent  ],  declarations: [    AppComponent  ],  imports: [    FormsModule,    BrowserModule,    BrowserAnimationsModule,    ReactiveFormsModule        ]})export class AppModule { }
app.component.html
<br><form [formGroup]="form" (ngSubmit)="onSubmit()">  <div formGroupName="details">    <input formControlName="name" placeholder="Name">    <input formControlName="email" placeholder="Email">  </div>  <br>      <button type='submit'>Submit</button>  <br><br></form>
Output:
Reference: https://angular.io/api/forms/FormGroupName
Angular10
AngularJS-Directives
Misc
Misc
Misc
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Properties of Fourier Transform
Univariate, Bivariate and Multivariate data and its analysis
Spatial Filtering and its Types
Advantages and Disadvantages of OOP
Lex Program to count number of words
Introduction to Internet of Things (IoT) | Set 1
Consensus Algorithms in Blockchain
Characteristics of Internet of Things
Transmission Impairment in Data Communication
Advantages and Disadvantages of E-mail
Age - GeeksforGeeks

23 Apr, 2019
Let the ages of children be x, (x+4), 
(x+8) and (x+12) years.

Then x + x + 4 + x + 8 + x +12 = 36
                       4x + 24 = 36
                             4x = 12
                              x = 3
Age of the youngest child = x = 3 years
Let C’s age be x years then B’s age be 3x
years and A’s age be (3x+5) years

Therefore  x + 3x + (3x + 5) = 40
                      7x + 5 = 40
                          7x = 35
                            x = 5
Then (3x+5) / (4x+5)  = 7 / 9 

∴ 9(3x + 5) = 7(4x + 5)
∴ 27x + 45 = 28x + 35
∴ x = 10
∴ Ashok’s present age = 4x = 40 years 
Let the present age of son and father be x years and 3x years respectively.

Then (3x + 15) = 2(x + 15)

∴ 3x + 15 = 2x + 30
∴ x = 15
∴ Son’s present age = x = 15 years. 
Let the present age of son and father be x years and 3x years respectively.

Then (3x + 15) = 2(x + 15)

∴ 3x + 15 = 2x + 30
∴ x = 15
∴ Son’s present age = x = 15 years. 
Let the present age of Ram and Shyam be 6x years and 5x years respectively.

Then 5x + 7 = 32
∴      5x = 25
∴        x = 5
∴ Present age of Ram = 6x = 30 years
Then (4x-9) + (5x-9) + (9x-9) =45
∴ 18x – 27 = 45
∴ 18x = 72
∴ x = 4
Then (3x + 12) = 2( x + 12)
∴ 3x + 12 = 2x + 24
∴ x = 12
∴ Present age of mother = 3x = 36 years 
A – B = C – A
∴ 2A = B + C
And also given that B + C = 68
∴ 2A = 68
∴   A = 34 

Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Must Do Coding Questions for Product Based Companies
Difference between var, let and const keywords in JavaScript
Array of Objects in C++ with Examples
How to Replace Values in Column Based on Condition in Pandas?
C Program to read contents of Whole File
How to Replace Values in a List in Python?
How to Read Text Files with Pandas?
How to Read Text File Into List in Python?
Python Data Structures and Algorithms
How to Change Axis Scales in R Plots?
Gerrit - Add SSH Key to use with Git

You can add SSH key to Git using the following commands −
Step 1 − Open Git Bash and get the ssh-agent using the following command.
Step 1 − Open Git Bash and get the ssh-agent using the following command.
$ eval 'ssh-agent'

Step 2 − Next, add the SSH key to the ssh-agent using the following command
Step 2 − Next, add the SSH key to the ssh-agent using the following command
$ ssh-add ~/.ssh/id_rsa

Step 3 − Now, run the ssh using the following command, which matches the SSH fingerprint used when logging for the first time.
Step 3 − Now, run the ssh using the following command, which matches the SSH fingerprint used when logging for the first time.
$ ssh -p 29418 <user_name>@gerrit.wikimedia.org

In the above screenshot, you can see that xyz123 is a instance shell account name, which is used while creating Gerrit account and Abc123 is a user name of your Gerrit account.
 Print
 Add Notes
 Bookmark this page
How can I set the default value for an HTML <select> element?

With HTML, you can easily create a simple drop down list of items to get user input in HTML forms. Use the <select> element for this, which is a select box, also called drop down box, with option to list down items.
Also, you can set the default value from the dropdown list of items in HTML forms. For that, add selected in the <option> tag for the value you want to preselect.
You can try to run the following code to learn how to set the default value for HTML <select> element −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>HTML Select Element</title>
   </head>
   <body>
      <p> Select any one:</p>
      <form>
         <select name = "dropdown">
            <option value = "Java">Java</option>
            <option value = "Discrete Mathematics" selected >Discrete Mathematics</option>
            <option value = "Chemistry">Chemistry</option>
         </select>
      </form>
   </body>
</html>
How to find a value is present in binary tree or not in JavaScript ?

We are required to write a JavaScript function on the prototype object of a BinarySearchTree data type that takes in a value and finds whether or not that value is contained in the BST.
The code for this will be -
// class for a single Node for BST
class Node {
   constructor(value) {
      this.value = value;
   }
}
// class for BST
// contains function to insert node and search for existing nodes
class BinarySearchTree {
   constructor() {
      this._root = null;
   };
   insert(value) {
      let node = this, side = '_root';
      while (node[side]) {
         node = node[side];
         if (value === node.value) {
            return;
         };
         side = value < node.value ? 'left' : 'right';
      };
      node[side] = new Node(value);
   };
   contains(value) {
      let current = this._root;
      while (current) {
         if (value === current.value) {
            return true;
         };
         current = value < current.value ? current.left : current.right;
      }
      return false;
   };
}
const tree = new BinarySearchTree();
for (let i = 0; i < 10; i++) {
   tree.insert(Math.floor(Math.random() * 1000));
};
tree.insert(34);
console.log(tree.contains(34));
console.log(tree.contains(334));
And the output in the console will be −
true
false
How can a MySQL stored procedure call another MySQL stored procedure inside it?

It is quite possible that a MySQL stored procedure can call another MySQL stored procedure inside it. To demonstrate it, we are taking an example in which a stored procedure will call another stored procedure to find out the last_insert_id.
mysql> Create table employee.tbl(Id INT NOT NULL AUTO_INCREMENT, Name Varchar(30) NOT NULL, PRIMARY KEY(id))//
Query OK, 0 rows affected (3.87 sec)

mysql> Create Procedure insert1()
   -> BEGIN insert into employee.tbl(name) values ('Ram');
   -> END//
Query OK, 0 rows affected (0.10 sec)
Now, in the next procedure insert2() we will call the 1st stored procedure i.e. insert1().
mysql> Create Procedure insert2()
   -> BEGIN
   -> CALL insert1();
   -> Select last_insert_id();
   -> END //
Query OK, 0 rows affected (0.11 sec)
mysql> Delimiter ;

mysql> Call insert2();
+------------------+
| last_insert_id() |
+------------------+
| 1                |
+------------------+
1 row in set (0.36 sec)
Query OK, 0 rows affected (0.37 sec)
The above result set shows that when we call insert1() then it inserted the first value in the table called employee.tbl and when we select last_insert_id() in 2nd stored procedure i.e. insert2() then it gives the output 1.
How to add placeholder to an Entry in tkinter?

Tkinter provides features to add widgets such as button, text, entry, dialogue and
other attributes that help to develop an application. However, tkinter doesn't
include a placeholder in the entry widget. Placeholders are the dummy text that
appears in the entry widget to inform the user about it.
In this article, we will add a placeholder in the entry widget using the insert(default value, text) function that takes a default value such as 0 along with the placeholder text.
#Import tkinter library
from tkinter import*

#Create an instance of frame
win= Tk()

#Set geometry
win.geometry("700x400")

#Create a text Label
Label(win, text="Notepad", font=('Poppins bold', 25)).pack(pady=20)
text= StringVar()

#Create an entry widget
test= Entry(win, textvariable=text)
test.pack(fill='x', expand=True, padx= 45, pady=45)
test.focus()

#Add a placeholder in the entry Widget
test.insert(0, "Enter any Text")
win.mainloop()
Running the above code will create an Entry Widget with some placeholder in it.
GATE | GATE-CS-2015 (Set 2) | Question 65 - GeeksforGeeks

28 Jun, 2021
A system has 6 identical resources and N processes competing for them. Each process can request atmost 2 resources. Which one of the following values of N could lead to a deadlock?
(A) 1(B) 2(C) 3(D) 4Answer: (D)Explanation: It seems to be wrong question in GATE exam. Below seems to be the worst case situation. In below situation P1 and P2 can continue as they have 2 resources each
P1 --> 2
P2 --> 2
P3 --> 1
P4 --> 1 
Quiz of this Question
GATE-CS-2015 (Set 2)
GATE-GATE-CS-2015 (Set 2)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-IT-2004 | Question 71
GATE | GATE CS 2011 | Question 7
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2016 (Set 1) | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 38
GATE | GATE CS 2018 | Question 37
GATE | GATE-IT-2004 | Question 83
GATE | GATE-CS-2016 (Set 1) | Question 63
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | GATE-CS-2007 | Question 64
How to remove all special characters, punctuation and spaces from a string in Python?

To remove all special characters, punctuation and spaces from string, iterate over the string and filter out all non alpha numeric characters. For example:
>>> string = "Hello $#! People   Whitespace 7331"
>>> ''.join(e for e in string if e.isalnum())
'HelloPeopleWhitespace7331'
Regular expressions can also be used to remove any non alphanumeric characters. re.sub(regex, string_to_replace_with, original_string) will substitute all non alphanumeric characters with empty string. For example,
>>> import re
>>> re.sub('[^A-Za-z0-9]+', '', "Hello $#! People   Whitespace 7331")
'HelloPeopleWhitespace7331'
C# Enum ToString() Method

The ToString() method converts the value of this instance to its equivalent string representation.
Firstly, set an enum.
enum Vehicle { Car, Bus, Truck, Motobike };
To convert it to an equivalent string representation, use ToString().
Vehicle.Car.ToString("d")
 Live Demo
using System;
public class Demo {
   enum Vehicle { Car, Bus, Truck, Motobike };
   public static void Main() {
      Console.WriteLine("Vehicle.Car = {0}", Vehicle.Car.ToString("d"));
      Console.WriteLine("Vehicle.Bus = {0}", Vehicle.Bus.ToString("d"));
   }
}
Vehicle.Car = 0
Vehicle.Bus = 1
Check if a binary string has a 0 between 1s or not | Set 2 (Regular Expression Approach) - GeeksforGeeks

11 Dec, 2017
Given a string of 0 and 1, we need to check that the given string is valid or not. The given string is valid when there is no zero is present in between 1’s. For example, 1111, 0000111110, 1111000 are valid strings but 01010011, 01010, 101 are not.
Examples:
Input : 100
Output : VALID

Input : 1110001
Output : NOT VALID
There is 0 between 1s

Input : 00011
Output : VALID

In Set 1, we have discussed general approach for validity of string.In this post, we will discuss regular expression approach for same and it is simple.
As we know that in a string if there is zero between 1’s, than string is not valid.Hence below is one of the regular expression for invalid string pattern.
10+1

So here is the simple regex algorithm.
Loop over the matcher(string)if above regex match is find in the matcher, then string is not valid, otherwise valid.
Loop over the matcher(string)
if above regex match is find in the matcher, then string is not valid, otherwise valid.
// Java regex program to check for valid string  import java.util.regex.Matcher;import java.util.regex.Pattern;  class GFG {    // Method to check for valid string    static boolean checkString(String str)    {        // regular expression for invalid string        String regex = "10+1";                  // compiling regex        Pattern p = Pattern.compile(regex);                  // Matcher object        Matcher m = p.matcher(str);                  // loop over matcher        while(m.find())        {            // if match found,            // then string is invalid            return false;        }                   // if match doesn't found        // then string is valid        return true;        }      // Driver method    public static void main (String[] args)    {        String str = "00011111111100000";                  System.out.println(checkString(str) ? "VALID" : "NOT VALID");    }}
Output:
VALID

This article is contributed by Gaurav Miglani. 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.
binary-string
java-regular-expression
Strings
Strings
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Top 50 String Coding Problems for Interviews
Naive algorithm for Pattern Searching
Vigenère Cipher
Hill Cipher
Count words in a given string
How to Append a Character to a String in C
Convert character array to string in C++
sprintf() in C
Program to count occurrence of a given character in a string
Converting Roman Numerals to Decimal lying between 1 to 3999
asctime() function in C++ - GeeksforGeeks

24 Sep, 2021
The asctime() function is defined in the ctime header file. The asctime() function converts the given calendar time of structure tm to a character representation i.e human readable form.
Syntax: 
char* asctime(const struct tm * time_ptr);
Parameter: This function accepts single parameter time_ptr i.e pointer to the tm object to be converted.
Return Value: This function returns the calendar time in the form “Www Mmm dd hh:mm:ss yyyy”
Below program illustrate the asctime() function in C++:
Example:- 
C++
// c++ program to demonstrate// example of asctime() function. #include <bits/stdc++.h>using namespace std; int main(){    time_t time_ptr;      time(&time_ptr);    cout << "Current date and time = "         << asctime(localtime(&time_ptr));     return 0;}
Current date and time = Mon Oct  1 10:21:26 2018
 
khushboogoyal499
CPP-Functions
CPP-Library
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Socket Programming in C/C++
Multidimensional Arrays in C / C++
Templates in C++ with Examples
Copy Constructor in C++
rand() and srand() in C/C++
Polymorphism in C++
unordered_map in C++ STL
Left Shift and Right Shift Operators in C/C++
Friend class and function in C++
Date validation using Java Regular Expressions

The date can be validated using the java.util.regex.Pattern.matches() method. This method matches the regular expression for the date and the given input date and returns true if they match and false otherwise.
A program that demonstrates this is given as follows:
 Live Demo
public class Demo {
   public static void main(String args[]) {
      String date = "15-11-2018";
      String regex = "\\d{1,2}-\\d{1,2}-\\d{4}";
      System.out.println("The date is: " + date);
      System.out.println("Is the above date valid? " + date.matches(regex));
   }
}
The date is: 15-11-2018
Is the above date valid? True
Now let us understand the above program.
The date is printed. The Pattern.matches() method matches the regular expression for the date and the given input date and the result is printed. A code snippet which demonstrates this is as follows:
String date = "15-11-2018";
String regex = "\\d{1,2}-\\d{1,2}-\\d{4}";

System.out.println("The date is: " + date);
System.out.println("Is the above date valid? " + date.matches(regex));
Python PIL | ImageChops.multiply() method

25 Jun, 2019
PIL.ImageChops.multiply() method superimposes two images on top of each other.If you multiply an image with a solid black image, the result is black. If you multiply with a solid white image, the image is unaffected. At least one of the images must have mode “1”.
Syntax: PIL.ImageChops.multiply(image1, image2)

Parameters:
image1: first image
image2: second image

Return Type: Image

Image1:
Image2:
# Importing Image and ImageChops module from PIL package from PIL import Image, ImageChops    # creating a image1 objectim1 = Image.open(r"C:\Users\sadow984\Desktop\i3.PNG")    # creating a image2 objectim2 = Image.open(r"C:\Users\sadow984\Desktop\c1.PNG")   # applying multiply methodim3 = ImageChops.multiply(im1, im2)   im3.show()
Output:
Image3:
Image4:
# Importing Image and ImageChops module from PIL package from PIL import Image, ImageChops    # creating a image3 objectim1 = Image.open(r"C:\Users\sadow984\Desktop\a2.PNG")    # creating a image4 objectim2 = Image.open(r"C:\Users\sadow984\Desktop\a3.PNG")   # applying multiply methodim3 = ImageChops.multiply(im1, im2)   im3.show()
Output:
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HTML | DOM removeChild() Method

10 Jun, 2022
The removeChild() method in HTML DOM is used to remove a specified child node of the given element. It returns the removed node as a node object or null if the node doesn’t exist.Syntax:  
node.removeChild(child)
Parameters: This method accepts single parameter child which is mandatory. It represents the node which need to be remove.Return Value: It returns a node object which represents the removed node, or null if the node doesn’t exist. Example:  
html
<!DOCTYPE html><html>    <head>        <title>            HTML DOM removeChild() Method        </title>    </head>         <body>             <h1 style="color: green;">            GeeksforGeeks        </h1>                 <h2>            DOM removeChild() Method        </h2>                   <p>Sorting Algorithm</p>          <ul id = "listitem"><li>Insertion sort</li>            <li>Merge sort</li>            <li>Quick sort</li>        </ul>                 <button onclick = "Geeks()">            Click Here!        </button>             <script>            function Geeks() {                var doc = document.getElementById("listitem");                doc.removeChild(doc.childNodes[0]);            }        </script>         </body></html>                   
Output: Before click on the button:  
After click on the button:  
Supported Browsers: The browser supported by DOM removeChild() method are listed below:  
Google Chrome 1 and above
Edge 12 and above
Internet Explorer 5 and above
Firefox 1 and above
Opera 7 and above
Safari 1.1 and above
 
simranarora5sos
kumargaurav97520
HTML-DOM
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas Timestamp.weekofyear

08 Jan, 2019
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.
Pandas Timestamp.weekofyear attribute return an integer value which is the ordinal value of the week in which the date of the given Timestamp object lies.
Syntax : Timestamp.weekofyear
Parameters : None
Return : week of year
Example #1: Use Timestamp.weekofyear attribute to find the ordinal value of the week in which the date of the given Timestamp object lies.
# importing pandas as pdimport pandas as pd  # Create the Timestamp objectts = pd.Timestamp(year = 2011,  month = 11, day = 21,            hour = 10, second = 49, tz = 'US/Central')  # Print the Timestamp objectprint(ts)
Output :
Now we will use the Timestamp.weekofyear attribute to find ordinal value of the week
# return the week numberts.weekofyear
Output :
As we can see in the output, the Timestamp.weekofyear attribute has returned 47 indicating that the date in the give Timestamp object falls in the 47th week of the year.
Example #2: Use Timestamp.weekofyear attribute to find the ordinal value of the week in which the date of the given Timestamp object lies.
# importing pandas as pdimport pandas as pd  # Create the Timestamp objectts = pd.Timestamp(year = 2009,  month = 5, day = 31,         hour = 4, second = 49, tz = 'Europe/Berlin')  # Print the Timestamp objectprint(ts)
Output :
Now we will use the Timestamp.weekofyear attribute to find ordinal value of the week
# return the week numberts.weekofyear
Output :
As we can see in the output, the Timestamp.weekofyear attribute has returned 22 indicating that the date in the give Timestamp object falls in the 22nd week of the year.
Python Pandas-Timestamp
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
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Iterate over a list in Python
Python Classes and Objects
Convert integer to string in Python
How to Calculate Euclidean Distance in Excel?

28 Jul, 2021
Euclidean distance is the distance between two real-valued vectors. It is calculated by the square root of the sum of the squared differences of the elements in the two vectors.
The formula to calculate Euclidean distance is :
In this article we are going to discuss how to calculate the Euclidean distance in Excel using a suitable example.
Example : Consider the dataset which consists of information about X and Y coordinates of ten points in a 2-D plane.
The functions used are :
1. SUMXMY2: It finds the sum of squared differences of the elements in array X and array Y.
2. SQRT: It is used to find the square root of the squared difference.
The steps to calculate Euclidean distance are :
1. Insert the coordinates in the Excel sheet as shown above. 
Column X consists of the x-axis data points and column Y contains y-axis data points.
2. Write the Excel formula in any one of the cells to calculate the Euclidean distance.
=SQRT(SUMXMY2(array_x,array_y))
The observations in array X are stored from A2 to A11.
The observations in array Y are stored from B2 to B11.
3. Click on Enter.
The Euclidean distance turns out to be 25.18 units approximately.
It is important to note that the number of observations in X and that of Y has to be the same. While calculating the distance Excel takes pairwise values of X and Y simultaneously.
 If any one of the values is missing in the worksheet then Excel will ignore that and move to the next data point. So, while entering the dataset we need to be careful to enter the observations X and Y pair-wise such that no data is missing. 
Picked
Excel
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
std::numeric_limits::digits in C++ with Example

12 Jun, 2020
The std::numeric_limits::digits function in C++ STL is present in the <limits> header file. The std::numeric_limits::digits function is used to find the number of radix digits that the data type can represent without loss of precision.
Header File:
#include<limits>

Template:
static const int digits;
static constexpr int digits;

Syntax:
std::numeric_limits<T>::digits

Parameter: The function std::numeric_limits<T>::digits does not accept any parameter.
Return Value: The function std::numeric_limits<T>::digits returns the number of radix digits that the type can represent without loss of precision.
Below is the program to demonstrate std::numeric_limits<T>::digits in C++:
Program:
// C++ program to illustrate// std::numeric_limits<T>::digits#include <bits/stdc++.h>#include <limits>using namespace std;  // Driver Codeint main(){    // Print the numeric digit for    // the various data type    cout << "For int: "         << numeric_limits<int>::digits         << endl;      cout << "For float: "         << numeric_limits<float>::digits         << endl;      cout << "For double: "         << numeric_limits<double>::digits         << endl;      cout << "For long double: "         << numeric_limits<long double>::digits         << endl;      return 0;}
For int: 31
For float: 24
For double: 53
For long double: 64

Reference: https://en.cppreference.com/w/cpp/types/numeric_limits/digits
CPP-Functions
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Sorting a vector in C++
Polymorphism in C++
Pair in C++ Standard Template Library (STL)
Friend class and function in C++
std::string class in C++
Queue in C++ Standard Template Library (STL)
std::find in C++
Unordered Sets in C++ Standard Template Library
List in C++ Standard Template Library (STL)
vector insert() function in C++ STL
p5.js | line() Function

10 Apr, 2019
The line() function is an inbuilt function in p5.js which is used to draw a line. In order to change the color of the line stroke() function is used and in order to change the width of the line strokeWeight() function is used.
Syntax:
line(x1, y1, x2, y2)
or
line(x1, y1, z1, x2, y2, z2)
Parameters: This function accepts six parameters as mentioned above and described below:
x1: This parameter takes the x-coordinate of the first point.
y1: This parameter takes the y-coordinate of the first point.
z1: This parameter takes the z-coordinate of the first point.
x2: This parameter takes the x-coordinate of the second point.
y2: This parameter takes the y-coordinate of the second point.
z2: This parameter takes the z-coordinate of the second point.
Below programs illustrates the line() function in P5.js:
Example 1: This example uses line() function to draw a line without using z-coordinate.
function setup() {      // Set the canvas size     createCanvas(400, 400);}   function draw() {          // Set the background color    background(220);          // Set the stroke weight    strokeWeight(6);          //x1, y1 = 38, 31; x2, y2 = 300, 20;    // Use line() function to draw line    line(38, 31, 30, 200); }
Output:
Example 2: This example uses line() function to draw the line using z-coordinate.
function setup() {      // Set the canvas size     createCanvas(400, 400);}   function draw() {          // Set the background color    background(220);          // Set the stroke weight    strokeWeight(6);          //x1, y1, z1 = 38, 31, 34;     // x2, y2, z2 = 300, 200, 45;    // Use line() function to draw line    line(38, 31, 34, 300, 200, 45); }
Output:
Reference: https://p5js.org/reference/#/p5/line
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Hide or show elements in HTML using display property
How to append HTML code to a div using JavaScript ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
HashSet size() Method in Java

26 Nov, 2018
The Java.util.HashSet.size() method is used to get the size of the HashSet or the number of elements present in the HashSet.
Syntax:
Hash_Set.size()

Parameters: This method does not takes any parameter.
Return Value: The method returns the size or the number of elements present in the HashSet.
Below program illustrate the Java.util.HashSet.size() method:
// Java code to illustrate HashSet.size() methodimport java.util.*;import java.util.HashSet;  public class HashSetDemo {    public static void main(String args[])    {        // Creating an empty HashSet        HashSet<String> set = new HashSet<String>();          // Use add() method to add elements into the Set        set.add("Welcome");        set.add("To");        set.add("Geeks");        set.add("4");        set.add("Geeks");          // Displaying the HashSet        System.out.println("HashSet: " + set);          // Displaying the size of the HashSet        System.out.println("The size of the set is: " + set.size());    }}
HashSet: [4, Geeks, Welcome, To]
The size of the set is: 4

Java - util package
Java-Collections
Java-Functions
java-hashset
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Interfaces in Java
Stream In Java
ArrayList in Java
Collections in Java
Singleton Class in Java
Multidimensional Arrays in Java
Stack Class in Java
Initializing a List in Java
Introduction to Java
Multithreading in Java
java.time.Month.valueOf() Method Example

The java.time.Month.valueOf(String name) method returns the enum constant of this type with the specified name.
Following is the declaration for java.time.Month.valueOf(String name) method.
public static Month valueOf(String name)

name − the name of the enum constant to be returned.
the enum constant with the specified name.
IllegalArgumentException − if this enum type has no constant with the specified name.
IllegalArgumentException − if this enum type has no constant with the specified name.
NullPointerException − if the argument is null.
NullPointerException − if the argument is null.
The following example shows the usage of java.time.Month.valueOf(String name) method.
package com.tutorialspoint;

import java.time.Month;

public class MonthDemo {
   public static void main(String[] args) {

      Month month = Month.valueOf("MARCH");
      System.out.println(month);
   }
}
Let us compile and run the above program, this will produce the following result −
Ruby | Symbol downcase value

10 Dec, 2019
Symbol#downcase() : downcase() is a Symbol class method which returns the downcased form of symbol based on the position of next capital form.
Syntax: Symbol.downcase()
Parameter: Symbol values
Return: the downcased form of symbol based on the position of next capital form.
Example #1 :
# Ruby code for Symbol.downcase() method  # declaring Symbol a = :aBcDeF  # declaring Symbolb = :"\u{e4 f6 fc}"  # declaring Symbolc = :ABCDEF  # Symbol puts "Symbol a : #{a}\n\n"puts "Symbol b : #{b}\n\n"puts "Symbol c : #{c}\n\n\n\n"    # downcase form puts "Symbol a downcase form : #{a.downcase}\n\n"puts "Symbol b downcase form : #{b.downcase}\n\n"puts "Symbol c downcase form : #{c.downcase}\n\n"
Output :
Symbol a : aBcDeF

Symbol b : äöü

Symbol c : ABCDEF



Symbol a downcase form : abcdef

Symbol b downcase form : äöü

Symbol c downcase form : abcdef


Example #2 :
# Ruby code for Symbol.downcase() method  # declaring Symbol a = :geeks  # declaring Symbolb = :"\u{e5 f6 f3}"  # declaring Symbolc = :GEEKS  # Symbol puts "Symbol a : #{a}\n\n"puts "Symbol b : #{b}\n\n"puts "Symbol c : #{c}\n\n\n\n"    # downcase form puts "Symbol a downcase form : #{a.downcase}\n\n"puts "Symbol b downcase form : #{b.downcase}\n\n"puts "Symbol c downcase form : #{c.downcase}\n\n"
Output :
Symbol a : geeks

Symbol b : åöó

Symbol c : GEEKS



Symbol a downcase form : geeks

Symbol b downcase form : åöó

Symbol c downcase form : geeks


Ruby Symbol-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Make a Custom Array of Hashes in Ruby?
Ruby | Array count() operation
Ruby | Array slice() function
Include v/s Extend in Ruby
Global Variable in Ruby
Ruby | Enumerator each_with_index function
Ruby | unless Statement and unless Modifier
Ruby | Hash delete() function
Ruby | Data Types
Ruby | Array class find_index() operation
Java Program to get the day of the week from GregorianCalendar

For GregorianCalendar class, import the following package.
import java.util.GregorianCalendar;
Create an object.
GregorianCalendar calendar = new GregorianCalendar();
To get the day of the week, use the following field.
GregorianCalendar.DAY_OF_WEEK
The following is an example.
 Live Demo
import java.util.Calendar;
import java.util.GregorianCalendar;
public class Demo {
   public static void main(String[] a) {
      GregorianCalendar calendar = new GregorianCalendar();
      System.out.println("Day of Week = " + calendar.get(GregorianCalendar.DAY_OF_WEEK));
      System.out.println("Date = " + calendar.get(GregorianCalendar.DATE));
      System.out.println("Month = " + calendar.get(GregorianCalendar.MONTH));
      System.out.println("Year = " + calendar.get(GregorianCalendar.YEAR));
   }
}
Day of Week = 2
Date = 19
Month = 10
Year = 2018
Detect the ENTER key in a text input field with JavaScript

You can use the keyCode 13 for ENTER key. Let’s first create the input −
<input type="text" id="txtInput">
Now, let’s use the on() with keyCode to detect the ENTER key. Following is the complete code −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initialscale=1.0">
<title>Document</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<input type="text" id="txtInput">
<script>
   $("#txtInput").on('keyup', function (event) {
      if (event.keyCode === 13) {
         console.log("Enter key pressed!!!!!");
      }
   });
</script>
</body>
</html>
To run the above program, save the file name “anyName.html(index.html)” and right click on the
file. Select the option “Open with Live Server” in VS Code editor.
This will produce the following output −
When you press an ENTER key, you will get the following message as in the below console output −
TypeORM - Working with CLI

This section explains about TypeORM CLI commands in detail.
typeorm init is the easiest and fastest way to setup a TypeORM project. You can create a new project as,
typeorm init --name Demoproject --database mysql

After executing the command, you will get the following output on your screen −
Project created inside /Users/workspace/TypeORM/Demoproject directory.

To create a new entity using CLI as,
typeorm entity:create -n Person

Now, Person entity is created inside your project src directory.
Entity /Users/workspace/TypeORM/Demoproject/src/entity/Person.ts has been created successfully.

If you have a multi-module project structure with multiple entities in different directories, you can use the below command,
typeorm entity:create -n Person -d src/Person/entity

To create a new subscriber using CLI as follows −
typeorm subscriber:create -n PersonSubscriber

You could see the following response −
Subscriber /path/to/TypeORM/Demoproject/src/subscriber/PersonSubscriber.ts has been created successfully.

You can create a new migration using CLI as mentioned below −
typeorm migration:create -n PersonMigration

The above command created a migration directory inside your project src. Migration files are stored inside it.
Migration /path/to/TypeORM/Demoproject/src/migration/1587395030750-PersonMigration.ts has been generated successfully.

To synchronize a database schema, use the below command −
typeorm schema:sync

To completely drop a database schema, use the below command −
typeorm schema:drop

If you want to execute any sql queries, we can execute directly from here. For example, to display all the records of customers, use the below query −
typeorm query "select * from customers"

If you want to clear everything stored in the cache. You can do it using the following command −
typeorm cache:clear

TypeORM is an excellent open source ORM framework to create high quality and scalable applications from small scale applications to large scale enterprise applications with multiple databases.
D3.js nest() Function

07 Jul, 2020
D3.js is a library built with javascript and particularly used for data visualization. D3.nest() function is used to group the data as groupBy clause does in SQL. It groups the data on the basis of keys and values.
Syntax:
d3.nest()
Parameters: This function does not accept any parameters.
Return Value: It returns the object with several properties as entries, keys, values, map, sort.
Example 1: In this example, the data is to be grouped on the basis of key “manufactured” we can group the data on the basis of multiple keys as well.
HTML
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8">    <meta name="viewport" path1tent=        "width=device-width, initial-scale=1.0">      <script src="https://d3js.org/d3.v4.min.js">    </script>      <title>        D3.js d3.nest() Function    </title></head>  <body>    <script>        var cars = [            { name: "car1", manufactured: "1950", model: "s51" },            { name: "car1", manufactured: "1950", model: "s51" },            { name: "car1", manufactured: "1951", model: "s50" },            { name: "car1", manufactured: "1951", model: "s50" },        ];        var groupedData = d3.nest()            .key(function (d) { return d.manufactured; })            .entries(cars);        console.log("ArrayData :", groupedData);        console.log("ArrayData[0] :", groupedData[0]);        console.log("ArrayData[1] :", groupedData[1]);    </script></body>  </html
Example 2: This example explains the grouping of data on the basis of multiple keys.
HTML
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8">    <meta name="viewport" path1tent=        "width=device-width, initial-scale=1.0">      <script src="https://d3js.org/d3.v4.min.js">    </script>      <title>        D3.js d3.nest() Function    </title></head>  <body>    <script>        var cars = [            { name: "car1", manufactured: "1950", model: "s51" },            { name: "car1", manufactured: "1950", model: "s51" },            { name: "car1", manufactured: "1951", model: "s50" },            { name: "car1", manufactured: "1951", model: "s50" },        ];        var groupedData = d3.nest()            .key(function (d) { return d.manufactured; })            .key(function (d) { return d.model; })            .entries(cars);        console.log("ArrayData :", groupedData);        console.log("ArrayData[0] :", groupedData[0]);        console.log("ArrayData[1] :", groupedData[1]);    </script></body>  </html>
D3.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ReactJS – useReducer hook

This hook is a better alternative of the useState hook, as it is used when we want to attach a function along with handling the state or when we want to handle the state based on the previous values.
const [state, dispatch] = useReducer(reducer, initialArgs, init);
Reducer − The function to handle or update the state
Reducer − The function to handle or update the state
initialArgs − Iitial state
initialArgs − Iitial state
Init − To load the state lazily or when it is required
Init − To load the state lazily or when it is required
In this example, we will build a simple calculator using the useReducer hook which takes the input from the user and displays the result accordingly.
App.jsx
import React, { useReducer } from 'react';

const initialState = 0;

const reducer = (state, action) => {
   switch (action) {
      case 1:
         return state + 1;
      case 2:
         return state + 2;
      case 3:
         return state + 3;
      case 'Reset':
         return 0;
      default:
      throw new Error('Error');
   }
};

const App = () => {
   const [ans, dispatch] = useReducer(reducer, initialState);
   return (
      <div>
         <h2>{ans}</h2>
         <button onClick={() => dispatch(1)}>Add 1</button>
         <button onClick={() => dispatch(2)}>Add 2</button>
         <button onClick={() => dispatch(3)}>Add 3</button>
         <button onClick={() => dispatch('Reset')}>reset</button>
      </div>
   );
};
export default App;
In the above example, when the user clicks on any button then the action is dispatched which updates the state and displays the updated state accordingly.
This will produce the following result.