code-rag-bench/online-tutorials huggingface dataset:
PostgreSQL – Create Database

28 Aug, 2020
PostgreSQL has multiple ways to create a database. In this article we will discuss multiple ways to do so.
1. Using psql Shell:
To create a database through the psql shell we make the use of the CREATE DATABASE statement as below:
CREATE DATABASE db_name
 OWNER =  role_name
 TEMPLATE = template
 ENCODING = encoding
 LC_COLLATE = collate
 LC_CTYPE = ctype
 TABLESPACE = tablespace_name
 CONNECTION LIMIT = max_concurrent_connection

The various options provided by the CREATE DATABASE statement are explained below:
db_name: It is the name of the new database that you want to create.It must always be a unique name.
role_name: It is the role name of the user who will own the new database.
template: It is the name of the database template from which the new database gets created.
encoding: It specifies the character set encoding for the new database. By default, it is the encoding of the template database.
collate: It specifies a collation for the new database.
ctype: It specifies the character classification for the new database like digit, lower and upper.
tablespace_name: It specifies the tablespace name for the new database.
max_concurrent_connection: It specifies the maximum concurrent connections to the new database.
Example 1:Here we will create a test database with all default settings.
CREATE DATABASE my_test_db1;
Output:
Example 2:Here we will create a test database with the following parameters:
Encoding: utf-8.
Owner: GeeksForGeeks with postgres as the user.
Maximum concurrent connections: 30.
CREATE DATABASE my_test_db2
 WITH ENCODING='UTF8'
 OWNER=GeeksForGeeks
 CONNECTION LIMIT=30;
Output:
2. Using pgAdmin:
Follow the below steps to create a new database using pgAdmin.
Step 1: Log in to PostgreSQL via pgAdmin.
Step 2: Right click on the Databases menu and then click on New Database... sub-menu item as depicted below:
Step 3: Now enter the new database name, owner, and configure parameters and click the OK button as depicted below:
postgreSQL-operators
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Vector elements() Method in Java

17 Aug, 2018
The java.util.vector.elements() method of Vector class in Java is used to get the enumeration of the values present in the Vector.
Syntax:
Enumeration enu = Vector.elements()
Parameters: The method does not take any parameters.
Return value: The method returns an enumeration of the values of the Vector.
Below programs are used to illustrate the working of the java.util.Vector.elements() method:
Program 1:
// Java code to illustrate the elements() methodimport java.util.*;  public class Vector_Demo {    public static void main(String[] args)    {          // Creating an empty Vector        Vector<String> vec_tor = new Vector<String>(5);          // Inserting elements into the table        vec_tor.add("Geeks");        vec_tor.add("4");        vec_tor.add("Geeks");        vec_tor.add("Welcomes");        vec_tor.add("You");          // Displaying the Vector        System.out.println("The Vector is: " + vec_tor);          // Creating an empty enumeration to store        Enumeration enu = vec_tor.elements();          System.out.println("The enumeration of values are:");          // Displaying the Enumeration        while (enu.hasMoreElements()) {            System.out.println(enu.nextElement());        }    }}
The Vector is: [Geeks, 4, Geeks, Welcomes, You]
The enumeration of values are:
Geeks
4
Geeks
Welcomes
You

Program 2 :
import java.util.*;  public class Vector_Demo {    public static void main(String[] args)    {          // Creating an empty Vector        Vector<Integer> vec_tor = new Vector<Integer>(5);          // Inserting elements into the table        vec_tor.add(10);        vec_tor.add(15);        vec_tor.add(20);        vec_tor.add(25);        vec_tor.add(30);          // Displaying the Vector        System.out.println("The Vector is: " + vec_tor);          // Creating an empty enumeration to store        Enumeration enu = vec_tor.elements();          System.out.println("The enumeration of values are:");          // Displaying the Enumeration        while (enu.hasMoreElements()) {            System.out.println(enu.nextElement());        }    }}
The Vector is: [10, 15, 20, 25, 30]
The enumeration of values are:
10
15
20
25
30

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.
Create a Donut Chart using Recharts in ReactJS

27 Jul, 2021
Introduction: Rechart JS is a library that is used for creating charts for React JS. This library is used for building Line charts, Bar charts, Pie charts, etc, with the help of React and D3 (Data-Driven Documents).  
To create Donut Chart using Recharts, we create a dataset that contains actual data. Then we define the slices using donaut element with data property which will have the data of the dataset created and with datakey property which is the property name with a value for the slices.
Creating React Application And Installing Module:
Step 1: Create a React application using the following command.npx create-react-app foldername
Step 1: Create a React application using the following command.
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command.cd foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command.
cd foldername
Step 3: After creating the ReactJS application, Install the required modules using the following command.npm install --save recharts
Step 3: After creating the ReactJS application, Install the required modules using the following command.
npm install --save recharts
Project Structure: It will look like the following.
Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
App.js
import React from 'react';import { PieChart, Pie} from 'recharts';    const App = () => {  // Sample dataconst data = [  {name: 'Geeksforgeeks', students: 400},  {name: 'Technical scripter', students: 700},  {name: 'Geek-i-knack', students: 200},  {name: 'Geek-o-mania', students: 1000}];    return (        <PieChart width={700} height={700}>          <Pie data={data} dataKey="students" outerRadius={250} innerRadius={150} fill="green" />        </PieChart>);}  export default App;
Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output:
Output
React-Questions
Recharts
JavaScript
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
Roadmap to Learn JavaScript For Beginners
Difference Between PUT and PATCH Request
JavaScript | Promises
How to fetch data from an API in ReactJS ?
Axios in React: A Guide for Beginners
How to redirect to another page in ReactJS ?
ReactJS Functional Components
How to pass data from one component to other component in ReactJS ?
Difference between Static binding and dynamic binding in Java

Binding is a mechanism creating link between method call and method actual implementation. As per the polymorphism concept in Java , object can have many different forms. Object forms can be resolved at compile time and run time. If linking between method call  and method implementation is resolved at compile time then we call it static binding or  If it is resolved at run time then it dynamic binding. Dynamic binding uses object to resolve binding but static binding use type of the class and fields. 
1
Basic 
It is resolved at compile time 
It is resolved at run time 
2
        Resolve mechanism 
 static binding use type of the class and fields
Dynamic binding uses object to resolve binding 
3
Example 
Overloading is an example of static binding 
Method overriding is the example of Dynamic binding 
4.
Type of Methods 
private, final and static methods and variables uses static binding
Virtual methods use dynamic binding 
public class FastFood {
   public void create() {
      System.out.println("Creating in FastFood class");
   }
}
public class Pizza extends FastFood {
   public void create() {
      System.out.println("Creating in Pizza class");
   }
}
public class Main {
   public static void main(String[] args) {
      FastFood fastFood= new FastFood();
      fastFood.create();
      //Dynamic binding
      FastFood pza= new Pizza();
      pza.create();
   }
}
SQL INSERT INTO Statement

The INSERT INTO statement is used to insert new records in a table.
It is possible to write the INSERT INTO 
statement in two ways:
1. Specify both the column names and the values to be inserted:
2. If you are adding values for all the columns of the table, you do not need to 
specify the column names in the SQL query. However, make sure the order of the 
values is in the same order as the columns in the table. Here, the 
INSERT INTO syntax 
would be as follows:
Below is a selection from the "Customers" table in the Northwind 
sample database:
The following SQL statement inserts a new record in the "Customers" table:
The selection from the "Customers" table will now look like this:
Did you notice that we did not insert any number into the CustomerID 
field?The CustomerID column is 
an auto-increment field and will be 
generated automatically when a new record is inserted into the table.
It is also possible to only insert data in specific columns.
The following SQL statement will insert a new record, but only insert data in the "CustomerName", 
"City", and "Country" columns (CustomerID will 
be updated automatically):
The selection from the "Customers" table will now look like this:
Insert a new record in the Customers table.
 Customers 
CustomerName, 
Address, 
City, 
PostalCode,
Country
 
'Hekkan Burger',
'Gateveien 15',
'Sandnes',
'4306',
'Norway';

Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
How to use an animated image in HTML page?

Animated images in HTML are an image on a web page that moves. It is in GIF format i.e. Graphics Interchange Format file.
To add an animated image in HTML is quite easy. You need to use the <image> tag with the src attribute. The src attribute adds the URL of the image.
Also, set the height and width of the image using the height and width attribute.
You can try to run the following to work with the animated image in HTML −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Animated Image</title>
   </head>
   <body>
      <h1>Animated Image</h1>
      <img src="https://media.giphy.com/media/3o6UBpHgaXFDNAuttm/giphy.gif">
   </body>
</html>
How can I change the text color with jQuery?

To change the text color with jQuery, use the jQuery css() method. The color css property is used to change text color.
You can try to run the following code to learn how to change text color with jQuery −
Live Demo
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("p").on({
        mouseenter: function(){
            $(this).css("color", "red");
        }
    });    
});
</script>
</head>
<body>
<p>Move the mouse pointer on the text to change the text color.</p>
</body>
</html>
Dorkify - Perform Google Dork Search - GeeksforGeeks

28 Nov, 2021
Dorkify is a free and open-source tool available on GitHub. Dorkify is used to perform google Dorking from the Linux terminal. Google Dorking is a technique used by hackers to find security loopholes in websites and servers. Google Dorking can be performed using mathematical operators such as ? ,” ” etc.  Google search engine uses different strings to specify which query is user searching for. Dorkify helps to perform google Dorking easily by using the kali Linux command line(Terminal).
Step 1: Open your kali Linux operating system and use the following command to install the tool. Use the second command to move into the directory of the tool.
git clone https://github.com/hhhrrrttt222111/Dorkify.git
cd Dorkify
Step 2: Use the following command to install the requirements of the tool.
python3 -m pip install -r requirements.txt
Step 3: Use the following command to run the tool.
python3 dorkify.py --help
The tool has been downloaded and installed successfully. Now we will see examples to use the tool.
choose option 1 "google"
The tool has started performing google search Dorking.
choose option 2
Now choose option 2.
The tool has started searching on specific URL google dork. The tool is free and open source. This is one of the most famous tools used for google dorking.
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
nohup Command in Linux with Examples
Thread functions in C/C++
scp command in Linux with Examples
mv command in Linux with examples
chown command in Linux with Examples
SED command in Linux | Set 2
Docker - COPY Instruction
Array Basics in Shell Scripting | Set 1
Basic Operators in Shell Scripting
Named Pipe or FIFO with example C program
What is the difference between String.valueOf() and toString() in Java?

The toString() method of the String class returns itself a string.
Live Demo
import java.io.*;
public class Test {
   public static void main(String args[]) {
      String Str = new String("Welcome to Tutorialspoint.com");
      System.out.print("Return Value :");
      System.out.println(Str.toString());
   }
}
Return Value :Welcome to Tutorialspoint.com
The value of method variants of the String class accepts different variables such as integer, float, boolean etc.. and converts them into String.
Live Demo
public class Sample {
   public static void main(String args[]){
      int i = 200;
      float f = 12.0f;
      char c = 's';
      char[] ch = {'h', 'e', 'l', 'l', 'o'};
      String data = String.valueOf(i);
      System.out.println(String.valueOf(i));
      System.out.println(String.valueOf(f));
      System.out.println(String.valueOf(c));
      System.out.println(String.valueOf(ch));
   }
}
200
12.0
s
hello
GATE | GATE-CS-2014-(Set-1) | Question 65

10 Nov, 2021
A machine has a 32-bit architecture, with 1-word long instructions. It has 64 registers, each of which is 32 bits long. It needs to support 45 instructions, which have an immediate operand in addition to two register operands. Assuming that the immediate operand is an unsigned integer, the maximum value of the immediate operand is ____________.(A) 16383(B) 16338(C) 16388(D) 16484Answer: (A)Explanation:
1 Word = 32 bits 
Each instruction has 32 bits. To support 45 instructions, opcode must contain 6-bits
Register operand1 requires 6 bits, since the total registers are 64. Register operand 2 also requires 6 bits. So total 18 bits for all 45 instruction and two register operands. So
32-18 = 14 
14-bits are left over for immediate Operand Using 14-bits, now
2^14 - 1 = 16383 
We can give maximum 16383.
YouTube<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=luB_5ufimJg" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
Akhilesh_Raturi
GATE-CS-2014-(Set-1)
GATE-GATE-CS-2014-(Set-1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE CS 2008 | Question 46
GATE | GATE CS 1996 | Question 63
GATE | Gate IT 2005 | Question 52
GATE | GATE CS 2012 | Question 18
GATE | GATE CS 2008 | Question 40
GATE | GATE-CS-2001 | Question 50
What does ‘<?=’ short open tag mean in PHP ?

05 Feb, 2019
The <php is used to identify the start of a PHP document.
In PHP whenever it reads a PHP document, It looks for:
<?php ?>
It process the codes in between the above tags only and leaves the other codes around them.
For example :
<?phpecho "Hello PHP !";?>
Hello PHP !

Note : But a special case is when you write a PHP file the end tag can be omitted, Only the start tag is needed.
The below code works fine as well:
<?php  echo "Hello PHP !";
Hello PHP !

The <= tag is called short open tag in PHP. To use the short tags, one must have to enable it from settings in the PHP.ini file.
First of all ensure that short tags are not disabled, To check it, go into php.ini file On line 77 .(location in linux systems :/etc/php5/apache2/php.ini)
Find the below line in the file and add (On) instead of (Off):
short_open_tag=On

However, from PHP version 5.4.0, the short tags are available for use regardless of the settings in the PHP.ini file.
The below two examples produces the same output with and without short open tags.
Example 1 : Normal Way.
<?php    $username = "GeeksforGeeks";    echo "$username";?>
GeeksforGeeks

Example 2 : The Short Hand Way.
<?php    $username = "GeeksforGeeks";?>  <?= $username ?>
GeeksforGeeks

As you can observe, both of the above codes gives us the same output. So, using short tags we told to php interpreter that:
<? ?>

can be treated same as
<?php ?>

The above example can be further modified as follows :
<?=$username = "GeeksforGeeks";?>
GeeksforGeeks

PHP-basics
Picked
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python – Convert day number to date in particular year

16 Nov, 2020
Given day number, convert to date it refers to.
Input : day_num = “339”, year = “2020” Output : 12-04-2020 Explanation : 339th Day of 2020 is 4th December.
Input : day_num = “4”, year = “2020” Output : 01-04-2020 Explanation : 4th Day of 2020 is 4th January. 
Method #1 : Using datetime.strptime()
In this, we get the year string and day number string, and pass to strptime(), converts to the corresponding required date.
Python3
# Python3 code to demonstrate working of# Convert day number to date in particular year# Using datetime.strptime()from datetime import datetime  # initializing day numberday_num = "339"  # print day numberprint("The day number : " + str(day_num))  # adjusting day numday_num.rjust(3 + len(day_num), '0')  # Initialize yearyear = "2020"  # converting to dateres = datetime.strptime(year + "-" + day_num, "%Y-%j").strftime("%m-%d-%Y")  # printing resultprint("Resolved date : " + str(res))
The day number : 339
Resolved date : 12-04-2020

Method #2 : Using timedelta()
In this, we initialize the date by 1st of January and then add number of days using timedelta(), resultant gives the date required.
Python3
# Python3 code to demonstrate working of# Convert day number to date in particular year# Using datetime.strptime()from datetime import datetime, date, timedelta  # initializing day numberday_num = "339"  # print day numberprint("The day number : " + str(day_num))  # adjusting day numday_num.rjust(3 + len(day_num), '0')  # Initialize yearyear = "2020"  # Initializing start datestrt_date = date(int(year), 1, 1)  # converting to dateres_date = strt_date + timedelta(days=int(day_num) - 1)res = res_date.strftime("%m-%d-%Y")  # printing resultprint("Resolved date : " + str(res))
The day number : 339
Resolved date : 12-04-2020

Python datetime-program
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Ways to Copy Dictionary

22 Jan, 2019
Dictionary is a collection which is unordered, changeable and indexed. In Python, dictionaries are written with curly brackets, and they have keys and values. It is widely used in day to day programming, web development, and machine learning. When we simply assign dict1 = dict2 it refers to the same dictionary. Let’s discuss a few ways to copy the dictionary from another dictionary.Method#1: Using copy()copy() method returns a shallow copy of the dictionary.It doesn’t take any parameter and return a new dictionary which is not referring to the initial dictionary.
# Python3 code to demonstrate# how to copy dictionary# using copy() function    # initialising dictionarytest1 = {"name" : "akshat", "name1" : "manjeet", "name2" : "vashu"}    # method to copy dictionary using copy() functiontest2 = test1.copy()    # updating test2test2["name1"] ="nikhil"  # print initial dictionaryprint("initial dictionary = ", test1)  # printing updated dictionaryprint("updated dictionary = ", test2)
Output
initial dictionary =  {'name1': 'manjeet', 'name2': 'vashu', 'name': 'akshat'}
updated dictionary =  {'name1': 'nikhil', 'name': 'akshat', 'name2': 'vashu'}

Method #2: Using dict()The dict() is a constructor which creates dictionary in Python.
# Python3 code to demonstrate# how to copy dictionary# using dict()    # initialising dictionarytest1 = {"name" : "akshat", "name1" : "manjeet", "name2" : "vashu"}    # method to copy dictionary using dicttest2 = dict(test1)    # updating test2test2["name1"] ="nikhil"  # print initial dictionaryprint("initial dictionary = ", test1)  # printing updated dictionaryprint("updated dictionary = ", test2)
Output
initial dictionary =  {'name2': 'vashu', 'name': 'akshat', 'name1': 'manjeet'}
updated dictionary =  {'name2': 'vashu', 'name': 'akshat', 'name1': 'nikhil'}

Method#3 : Using Dictionary comprehension
# Python3 code to demonstrate# how to copy dictionary# using dictionary comprehension    # initialising dictionarytest1 = {"name" : "akshat", "name1" : "manjeet", "name2" : "vashu"}    # method to copy dictionary using dictionary comprehensiontest2 = {k:v for k, v in test1.items()}    # updating test2test2["name1"] ="ayush"  # print initial dictionaryprint("initial dictionary = ", test1)  # printing updated dictionaryprint("updated dictionary = ", test2)
Output
initial dictionary =  {'name': 'akshat', 'name2': 'vashu', 'name1': 'manjeet'}
updated dictionary =  {'name': 'akshat', 'name2': 'vashu', 'name1': 'ayush'}

python-dict
Python
python-dict
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2017 (Set 1) | Question 47

22 Sep, 2017
The values of parameters for the Stop-and – Wait ARQ protocol are as given below.
Bit rate of the transmission channel = 1Mbps
Propagation delay from sender to receiver = 0.75 ms 
Time to process a frame = 0.25ms 
Number of bytes in the information frame = 1980   
Number of bytes in the acknowledge frame = 20 
Number of overhead bytes in the information frame = 20 


Assume that there are no transmission errors. Then the transmission efficiency ( expressed in percentage) of the Stop-and – Wait ARQ protocol for the above parameters is _________( correct to 2 decimal place) .
Note: This questions appeared as Numerical Answer Type.
(A) A number between 86.5 and 87.5(B) A number between 82.4 and 82.5(C) A number between 92.4 and 95.5(D) A number between 96.4 and 97.5Answer: (A)Explanation: Given,
Number of bytes in the information frame = 1980Number of bytes in the acknowledge frame = 20Number of overhead bytes in the information frame = 20
Therefore, useful Data = Total Data – Overhead = 1980 – 20 = 1960
Tt(Data) = (1960*8) / 10^6 = 15.68 millisecond
Tt(ACK) = 20*8 / 10^6 = 0.16 millisecond
Two way round trip time = 2 * Tp = 2*0.75 = 1.5 millisecond
T(precess) = 0.25(for info) + 0.25(for ack) = 0.5 millisecond
Efficiency = Useful Time / (Tt(info) + + Tt(ACK) + 2* Tp + Tprocess )= 15.68 / (15.84 + 0.16 + 2*0.75+ 0.5 )= 0.8711111= 87%
Option (A) is correct.Quiz of this Question
GATE-CS-2017 (Set 1)
GATE-GATE-CS-2017 (Set 1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-1) | Question 65
GATE | GATE CS 2010 | Question 54
GATE | GATE-CS-2015 (Set 1) | Question 19
GATE | GATE CS 2018 | Question 43
GATE | Gate IT 2008 | Question 59
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | GATE-CS-2006 | Question 45
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE CS 2013 | Question 25
GATE | GATE-CS-2003 | Question 77
Python – Convert List to delimiter separated String

29 Aug, 2020
Given List of elements, convert it to delimiter separated String.
Input : test_list = [7, “Gfg”, “best”, 9], delim = “*”Output : 7*Gfg*best*9*Explanation : All elements are concatenated with “*” as joiner.
Input : test_list = [7, “Gfg”, “best”, 9], delim = “#”Output : 7#Gfg#best#9#Explanation : All elements are concatenated with “#” as joiner.
Method #1 : Using loop + str()
This is one of the ways in which this task can be performed. In this, we run a loop to add delimiter at end of each element, after converting each element to  string.
Python3
# Python3 code to demonstrate working of # Convert List to delimiter separated String# Using loop + str()  # initializing listtest_list = [7, "Gfg", 8, "is", "best", 9]   # printing original listprint("The original list is : " + str(test_list))  # initializing delim delim = "*"  res = ''   # using loop to add string followed by delim for ele in test_list:    res = res + str(ele) + delim  # printing result print("The resultant string : " + str(res))
The original list is : [7, 'Gfg', 8, 'is', 'best', 9]
The resultant string : 7*Gfg*8*is*best*9*

Method #2 : Using join() + str()
This is yet another way in which this task can be performed. In this we perform the task of joining each element by delim using join() and conversion to string is done using str().
Python3
# Python3 code to demonstrate working of # Convert List to delimiter separated String# Using join() + str()  # initializing listtest_list = [7, "Gfg", 8, "is", "best", 9]   # printing original listprint("The original list is : " + str(test_list))  # initializing delim delim = "*"  # using map to convert each element to string temp = list(map(str, test_list))  # join() used to join with delimiterres = delim.join(temp)  # printing result print("The resultant string : " + str(res))
The original list is : [7, 'Gfg', 8, 'is', 'best', 9]
The resultant string : 7*Gfg*8*is*best*9

Python list-programs
Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Rotate axis tick labels in Seaborn and Matplotlib
Enumerate() in Python
Deque in Python
Stack in Python
Python Dictionary
Defaultdict in Python
Python | Get dictionary keys as a list
Iterate over characters of a string in Python
Python | Convert set into a list
Python | Find most frequent element in a list
How to make HTML files open in Chrome using Python?

24 Jan, 2021
Prerequisites: Webbrowser
HTML files contain Hypertext Markup Language (HTML), which is used to design and format the structure of a webpage. It is stored in a text format and contains tags that define the layout and content of the webpage. HTML files are widely used online and displayed in web browsers.
To preview HTML files, we make the use of browsers, like Google Chrome, Mozilla Firefox, Apple Safari etc. The task of creating and previewing HTML files can be automated with the help of python scripts.
Here are a few ways how we can open HTML files on chrome:
The webbrowser module in python provides a high-level interface to allow displaying Web-based documents to users, and the os module provides a portable way of using operating system dependent functionalities (like reading or writing files, manipulating file paths etc.). So let’s see how a combination of these both can help us to open an HTML page in Chrome browser:
Function used: open_new_tab() function is used to open html file in a new tab of your default browser.
Syntax:
open_new_tab(filename)
Approach:
Import module
Open and Create file 
Add html code 
Write code to file
Close file
Open file in browser window
Example:
Python3
# creating nd viewing the html files in python  import webbrowserimport os  # to open/create a new html file in the write modef = open('GFG.html', 'w')  # the html code which will go in the file GFG.htmlhtml_template = """<html><head></head><body><p>Geeks For Geeks</p>  </body></html>"""# writing the code into the filef.write(html_template)  # close the filef.close()  # 1st method how to open html files in chrome usingfilename = 'file:///'+os.getcwd()+'/' + 'GFG.html'webbrowser.open_new_tab(filename)
Output:
If the HTML file is in the same directory as that of the python script, then there is no need of defining the file path with the os module. We can simply run the html file in new browser using the given steps:
File in Use: GFG.html
Approach
Create a html file that you want to open
In Python, Import module
Call html file using open_new_tab()
Example:
Python3
Import webbrowser  webbrowser.open_new_tab('GFG.html')
Output:
Picked
python-os-module
python-utility
Technical Scripter 2020
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to iterate through Excel rows in Python?
Rotate axis tick labels in Seaborn and Matplotlib
Deque in Python
Queue in Python
Defaultdict in Python
Check if element exists in list in Python
Python Classes and Objects
Bar Plot in Matplotlib
reduce() in Python
Python | Get unique values from a list
Angular CLI - ng lint Command

This chapter explains the syntax, argument and options of ng lint command along with an
example.
The syntax for ng lint command is as follows −
ng lint <project> [options]
ng l <project> [options]

ng lint run the linting tool on angular app code. It checks the code quality of angular project specified. It uses TSLint as default linting tool and uses the default configuration available in tslint.json file. 
The argument for ng lint command is as follows −
Options are optional parameters.
The linting configuration to use.
Aliases: -c
Default: false
Succeeds even if there was linting errors.
Default: false
Output format (prose, json, stylish, verbose, pmd, msbuild, checkstyle, vso, fileslist).
Default: prose
Shows a help message for this command in the console.
Default: false
Show output text.
Default: false
Controls the type check for linting.
Default: false
First move to an angular project updated using ng build command.which is available at
https://www.tutorialspoint.com/angular_cli/angular_cli_ng_build.htm.
Update goals.component.html and goals.component.ts as following −
goals.component.ts
import { Component, OnInit } from '@angular/core';
@Component({
   selector: 'app-goals',
   templateUrl: './goals.component.html',
   styleUrls: ['./goals.component.css']
})
export class GoalsComponent implements OnInit {
   title = 'Goal Component'
   constructor() { }
   ngOnInit(): void {
   }
}
goals.component.html
<p>{{title}}</p>

Now run the linting command.
An example for ng lint command is given below −
\>Node\>TutorialsPoint> ng lint
Linting "TutorialsPoint"...
ERROR: D:/Node/TutorialsPoint/src/app/goals/goals.component.ts:9:27 - Missing semicolon
ERROR: D:/Node/TutorialsPoint/src/app/goals/goals.component.ts:13:2 - file should end with a newline
Lint errors found in the listed files.

Here ng lint command has checked the code quality of application and prints linting status.
Now correct the errors in goals.component.ts.
goals.component.ts
import { Component, OnInit } from '@angular/core';
@Component({
   selector: 'app-goals',
   templateUrl: './goals.component.html',
   styleUrls: ['./goals.component.css']
})
export class GoalsComponent implements OnInit {
   title = 'Goal Component';
   constructor() { }
   ngOnInit(): void {
   }
}
Now run the linting command.
An example is stated below −
\>Node\>TutorialsPoint> ng lint
Linting "TutorialsPoint"...
All files pass linting.


    16 Lectures 
     1.5 hours 

 Anadi Sharma

    28 Lectures 
     2.5 hours 

 Anadi Sharma

    11 Lectures 
     7.5 hours 

 SHIVPRASAD KOIRALA

    16 Lectures 
     2.5 hours 

 Frahaan Hussain

    69 Lectures 
     5 hours 

 Senol Atac

    53 Lectures 
     3.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
How to apply style to parent if it has child with CSS? - GeeksforGeeks

28 Feb, 2022
We know how to apply styles to the child elements if a parent class has one. But if we want to apply a style to the parent class and that with CSS. Here’s the way we can do that. A child combinator describes a parent-child between two elements. A child combinator is made of the “greater-than (>)” character and separates two elements.Examples:  
E > F, an F element child of an E element.
The following selector represents a “p” element that is child of “body”:body > p.
So the style In the parent class can be by just writing the name once like this  
.parent li {
    background:blue;
    color:black;
}
If we want to apply the style in child class then use this  
.parent > li > ul > li {
    background:orange
}
Program:  
html
<!DOCTYPE html><html><head>    <style>        .parent li {            background:blue;            color:black;        }        .parent > li > ul > li {            background:orange        }        .parent > li > ul > li > ul >li {            background:pink;        }    </style></head> <body>    <ul class="parent">        <li>I am first</li>        <li>I am second</li>        <li>I am third</li>        <li>I am forth</li>        <li>I am fifth            <ul class="child">                <li>child1</li>                <li>child2                    <ul>                        <li>child2.1</li>                        <li>child2.2</li>                        <li>child2.3</li>                    </ul>                </li>                <li>child3</li>                <li>child4</li>                <li>child5</li>            </ul>        </li>        <li>I am sixth</li>        <li>I am seventh</li>        <li>I am eight</li>    </ul></body></html>
Output:  
CSS3 does not have parents selectors. If CSS4 released then there is a proposed CSS4 selector, $, which will be like selecting the li element. 
However, as of now, this code can’t be used in any of the browsers.  
ul $li ul.sub { ... }
In the meantime, we’ll have to use JavaScript if we need to select a parent element.  
$('ul li:has(ul.child)').addClass('has_child');
 
CSS is the foundation of webpages, is used for webpage development by styling websites and web apps.You can learn CSS from the ground up by following this CSS Tutorial and CSS Examples.
 
rkbhola5
CSS-Misc
Picked
CSS
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Design a web page using HTML and CSS
Create a Responsive Navbar using ReactJS
Form validation using jQuery
How to Dynamically Add/Remove Table Rows using jQuery ?
How to Create Time-Table schedule using HTML ?
Installation of Node.js on Linux
Express.js express.Router() Function
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to create bins for a continuous vector in R?

To create the bins for a continuous vector, we can use cut function and store the bins in a data frame along with the original vector. The values in the cut function must be passed based on the range of the vector values, otherwise, there will be NA’s in the bin values. For example, if we have a vector that contains 0.55 and we do not use 0 in the cut function then the first bin will be NA. Check out the below examples to understand how to properly do it.
 Live Demo
x1<−rnorm(20,5,2)
x1
[1] 3.066708 6.729915 7.706962 7.564306 3.924779 5.400262 2.529380 4.377311
[9] 7.270613 6.135201 5.068060 6.447229 8.603205 4.065874 4.132155 3.060366
[17] 0.953596 2.861802 7.250666 6.928397
df1<−data.frame(x1,bin=cut(x1,c(0,1,2,3,4,5,6,7,8,9),include.lowest=TRUE))
df1
     x1     bin
1 3.066708 (3,4]
2 6.729915 (6,7]
3 7.706962 (7,8]
4 7.564306 (7,8]
5 3.924779 (3,4]
6 5.400262 (5,6]
7 2.529380 (2,3]
8 4.377311 (4,5]
9 7.270613 (7,8]
10 6.135201 (6,7]
11 5.068060 (5,6]
12 6.447229 (6,7]
13 8.603205 (8,9]
14 4.065874 (4,5]
15 4.132155 (4,5]
16 3.060366 (3,4]
17 0.953596 [0,1]
18 2.861802 (2,3]
19 7.250666 (7,8]
20 6.928397 (6,7]
 Live Demo
x2<−runif(20,2,5)
x2
[1] 2.656399 2.436808 3.704048 3.572767 2.321280 2.982751 4.911949 2.483126
[9] 2.177203 2.797627 4.621546 3.645550 2.888457 2.919597 4.354709 4.251886
[17] 4.862071 3.367629 2.610280 3.063467
df2<−data.frame(x1,bin=cut(x2,c(2,3,4,5),include.lowest=TRUE))
df2
     x1     bin
1 3.066708 [2,3]
2 6.729915 [2,3]
3 7.706962 (3,4]
4 7.564306 (3,4]
5 3.924779 [2,3]
6 5.400262 [2,3]
7 2.529380 (4,5]
8 4.377311 [2,3]
9 7.270613 [2,3]
10 6.135201 [2,3]
11 5.068060 (4,5]
12 6.447229 (3,4]
13 8.603205 [2,3]
14 4.065874 [2,3]
15 4.132155 (4,5]
16 3.060366 (4,5]
17 0.953596 (4,5]
18 2.861802 (3,4]
19 7.250666 [2,3]
20 6.928397 (3,4]
SOAP - Messages

A SOAP message is an ordinary XML document containing the following elements −
Envelope − Defines the start and the end of the message. It is a mandatory element.
Envelope − Defines the start and the end of the message. It is a mandatory element.
Header − Contains any optional attributes of the message used in processing the message, either at an intermediary point or at the ultimate end-point. It is an optional element.
Header − Contains any optional attributes of the message used in processing the message, either at an intermediary point or at the ultimate end-point. It is an optional element.
Body − Contains the XML data comprising the message being sent. It is a mandatory element.
Body − Contains the XML data comprising the message being sent. It is a mandatory element.
Fault − An optional Fault element that provides information about errors that occur while processing the message.
Fault − An optional Fault element that provides information about errors that occur while processing the message.
All these elements are declared in the default namespace for the SOAP envelope −
https://www.w3.org/2001/12/soap-envelope
The default namespace for SOAP encoding and data types is −
https://www.w3.org/2001/12/soap-encoding
Note − All these specifications are subject to change. Thus, keep updating yourself with the latest specifications available on the W3 website.
The following block depicts the general structure of a SOAP message −
<?xml version = "1.0"?> 
<SOAP-ENV:Envelope 
xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-envelope" 
SOAP-ENV:encodingStyle = "http://www.w3.org/2001/12/soap-encoding">  
   <SOAP-ENV:Header> 
      ... 
      ... 
   </SOAP-ENV:Header>  
   <SOAP-ENV:Body> 
      ... 
      ... 
      <SOAP-ENV:Fault> 
         ... 
         ... 
      </SOAP-ENV:Fault>  
   </SOAP-ENV:Body>  
</SOAP_ENV:Envelope> 

 Print
 Add Notes
 Bookmark this page
C++ | Operator Overloading | Question 10 - GeeksforGeeks

23 Nov, 2021
Which of the following operator functions cannot be global, i.e., must be a member function.(A) new(B) delete(C) Conversion Operator(D) All of the aboveAnswer: (C)Explanation: new and delete can be global, see following example.

#include
#include
#include

using namespace std;

class Myclass {
    int x;
public:
    friend void* operator new(size_t size);
    friend void operator delete(void*);
    Myclass(int i) {
        x = i;
        cout << "Constructor called \n";
    }
    ~Myclass() { cout << "Destructor called \n"; }
};


void* operator new(size_t size)
{
    void *storage = malloc(size);
    cout << "new called \n";
    return storage;
}

void operator delete(void *p )
{
    cout<<"delete called \n";
    free(p);
}

int main()
{
    Myclass *m = new Myclass(5);
    delete m;
    return 0;
}

Quiz of this Question
clintra
C++-Operator Overloading
cpp-overloading
Operator Overloading
C Language
C++ Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
rand() and srand() in C/C++
fork() in C
Command line arguments in C/C++
Substring in C++
Function Pointer in C
C++ | Inheritance | Question 7
C++ | Function Overloading and Default Arguments | Question 2
C++ | Inheritance | Question 6
C++ | Misc C++ | Question 8
C++ | Inheritance | Question 5
How to create a circle using JavaFX?

A circle is a line forming a closed loop, every point on which is a fixed distance from a center point. A circle is defined by its center and radius − distance from the center to any point on the circle.
In JavaFX a circle is represented by the javafx.scene.shape.Circle class. This class contains three properties they are −
centerX − This property represents the x coordinate of the center of a circle, you can set the value to this property using the setCenterX() method.
centerX − This property represents the x coordinate of the center of a circle, you can set the value to this property using the setCenterX() method.
centerY − This property represents y coordinate of the center of a circle, you can set the value to this property using the setCenterY() method.
centerY − This property represents y coordinate of the center of a circle, you can set the value to this property using the setCenterY() method.
radius − The radius of the circle in pixels, you can set the value to this property using the setRadius() method.
radius − The radius of the circle in pixels, you can set the value to this property using the setRadius() method.
To create a circle you need to −
Instantiate the class Circle.
Instantiate the class Circle.
Set the required properties using the setter methods or, bypassing them as arguments to the constructor.
Set the required properties using the setter methods or, bypassing them as arguments to the constructor.
Add the created node (shape) to the Group object.
Add the created node (shape) to the Group object.
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.scene.shape.Circle;
public class DrawingCircle extends Application {
   public void start(Stage stage) {
      //Drawing a Circle
      Circle circle = new Circle();
      //Setting the properties of the circle
      circle.setCenterX(300.0f);
      circle.setCenterY(135.0f);
      circle.setRadius(100.0f);
      //Setting other properties
      circle.setFill(Color.DARKCYAN);
      circle.setStrokeWidth(8.0);
      circle.setStroke(Color.DARKSLATEGREY);
      //Setting the Scene
      Group root = new Group(circle);
      Scene scene = new Scene(root, 595, 300, Color.BEIGE);
      stage.setTitle("Drawing a Circle");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]){
      launch(args);
   }
}
Reverse Linked List in Python

Suppose we have a linked list, we have to reverse it. So if the list is like 1 → 3 → 5 → 7, then the new reversed list will be 7 → 5 → 3 → 1
To solve this, we will follow this approach −
Define one procedure to perform list reversal in a recursive way as to solve(head, back)
if the head is not present, then return head
temp := head.next
head.next := back
back = head
if temp is empty, then return head
head = temp
return solve(head, back)
Let us see the following implementation to get a better understanding −
 Live Demo
class ListNode:
   def __init__(self, data, next = None):
      self.val = data
      self.next = next
def make_list(elements):
   head = "ListNode(elements[0])
   for element in elements[1:]:
      ptr = head
      while ptr.next:
         ptr = ptr.next
      ptr.next = ListNode(element)
return head
def print_list(head):
   ptr = head
   print('[', end = "")
   while ptr:
      print(ptr.val, end = ", ")
      ptr = ptr.next
   print(']')
class Solution(object):
   def reverseList(self, head):
      """
      :type head: ListNode
      :rtype: ListNode
      """
      return self.solve(head,None)
   def solve(self, head, back):
      if not head:
         return head
      temp= head.next
      #print(head.val)
      head.next = back
      back = head
      if not temp:
         return head
      head = temp
      return self.solve(head,back)
list1 = make_list([1,3,5,7])
ob1 = Solution()
list2 = ob1.reverseList(list1)
print_list(list2)
list1 = [1,3,5,7]
[7, 5, 3, 1, ]
How to store usernames and passwords safely in MySQL database?

To store username and passwords safely in MySQL database, we can use MD5().
Let us see an example. First, we will create a table. The CREATE command is used to create a table.
mysql> create table UserNameAndPasswordDemo
- > (
- > U_Id int(10) unsigned NOT NULL AUTO_INCREMENT,
- > UserId varchar(255) DEFAULT NULL,
- > UserPassword varchar(255) DEFAULT NULL,
- > primary key(U_Id),
- > UNIQUE KEY `UserId` (`UserId`)
- > );
Query OK, 0 rows affected (0.61 sec)
Inserting records and safely storing passwords with the help of MD5().
mysql> INSERT INTO UserNameAndPasswordDemo(UserId, UserPassword) VALUES ('John@gg.com', MD5('john123'));
Query OK, 1 row affected (0.17 sec)

mysql> INSERT INTO UserNameAndPasswordDemo(UserId, UserPassword) VALUES (MD5('Carol@gg.com'), MD5('123Carol'));
Query OK, 1 row affected (0.14 sec)
Now, we will implement the SELECT statement to display the records, including password in MD5. Here, we are only displaying records for UserId 'John@gg.com'.
mysql> SELECT *from UserNameAndPasswordDemo where UserId='John@gg.com';
The following is the output.
+------+-------------+----------------------------------+
| U_Id | UserId      | UserPassword                     |
+------+-------------+----------------------------------+
| 1    | John@gg.com | 6e0b7076126a29d5dfcbd54835387b7b |
+------+-------------+----------------------------------+
1 row in set (0.00 sec)
To display all records.
mysql> SELECT *from UserNameAndPasswordDemo;
The following is the output wherein we have saved username and password using MD5 −
+------+----------------------------------+----------------------------------+
| U_Id | UserId                           | UserPassword                     |
+------+----------------------------------+----------------------------------+
| 1    | John@gg.com                      | 6e0b7076126a29d5dfcbd54835387b7b |
| 2    | 5f565a3d794f85e5db4f3bb7b5811a25 | f1d2fb85f7d6ce7428b9b3fd569be42b |
+------+----------------------------------+----------------------------------+
2 rows in set (0.00 sec)