code-rag-bench/online-tutorials huggingface dataset:
SQL Query to Add Email Validation Using Only One Query

19 May, 2021
In this article let us see how can we check for the validation of mails in the student database using MSSQL as the database server. For example, if the email is like abcdedfABCDEF...0123456@gmail.com this is the valid form of an email if it is other than this then that is said to Invalid. So, now we will discuss this concept in detail step-by-step:
Step 1: Creating a database college by using the following SQL query as follows.
CREATE DATABASE college;
Step 2: Using the database student using the following SQL query as follows.
USE college;
Step 3: Creating a table student with 4 columns using the following SQL query as follows.
CREATE TABLE student
(
    s_id varchar(20),
    s_name varchar(20),
    s_branch varchar(20),
    s_email varchar(100)
);
Step 4: To view the description of the table in the database using the following SQL query as follows.
EXEC sp_columns student;
Step 5: Inserting rows into student_details table using the following SQL query as follows.
INSERT INTO student VALUES
('19102001','JOHNSON','E.C.E','john432@gmail.com'),
('19102002','VIVEK','E.C.E','VIVEK2252gmail.com'),
('19102003','DINESH','E.C.E','dineshg@gmail.com'),
('19102004','HARSHA','E.C.E','hARsha302@gmail.com'),
('19102005','DAVID','E.C.E','david2000@gmail.com'),
('19102006','NAVIN','E.C.E','navin00'),
('19102007','VINAY','E.C.E','Vinay24mail.com');
Step 6: Viewing the table student_details after inserting rows by using the following SQL query as follows.
SELECT * FROM student;
Query: Now we are querying to display all the student details with valid emails. So, the email validation is done by using pattern matching which can be done by using LIKE operator in MSSQL. It checks for the fixed pattern set by the database designer in the data and displays the data that matches the fixed pattern.
Syntax:
SELECT * FROM table_name
WHERE attribute LIKE 'pattern';
SELECT * FROM student
WHERE s_email LIKE '%@gmail.com';
Only the students with valid emails are displayed in the tables.
Picked
SQL-Query
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
CTE in SQL
How to Update Multiple Columns in Single Update Statement in SQL?
SQL Trigger | Student Database
SQL Interview Questions
SQL | Views
Difference between DELETE, DROP and TRUNCATE
MySQL | Group_CONCAT() Function
Difference between DDL and DML in DBMS
SQL | GROUP BY
Window functions in SQL
JavaScript toLocaleString() function

The toLocaleString() method of JavaScript is used to convert a Date object to a string using locale settings.
The syntax is as follows −
Date.toLocaleString(locales, options)
Above, the locales parameter is the language specific format to be used −
ar-SA Arabic (Saudi Arabia)
bn-BD Bangla (Bangladesh)
bn-IN Bangla (India)
cs-CZ Czech (Czech Republic)
da-DK Danish (Denmark)
de-AT Austrian German
de-CH "Swiss" German
de-DE Standard German (as spoken in Germany)
el-GR Modern Greek
en-AU Australian English
en-CA Canadian English
en-GB British English
en-IE Irish English
en-IN Indian English
en-NZ New Zealand English
en-US US English
en-ZA English (South Africa)
es-AR Argentine Spanish
es-CL Chilean Spanish
es-CO Colombian Spanish
es-ES Castilian Spanish (as spoken in Central-Northern Spain)
es-MX Mexican Spanish
es-US American Spanish
fi-FI Finnish (Finland)
fr-BE Belgian French
Let us now implement the array. toLocaleString() method in JavaScript −
 Live Demo
<!DOCTYPE html>
<html>
<body>
<h2>Products</h2>
<p>Click to display the updated product list...</p>
<button onclick="display()">Result</button>
<p id="test"></p>
<script>
   var products = ["Electronics", "Books", "Accessories"];
   document.getElementById("test").innerHTML = products;
   function display() {
      var d = new Date();
      products.splice(3, 1, "Pet Supplies", "Footwear", "Home Appliances");
      document.getElementById("test").innerHTML = products +" on "+d.toLocaleString();
   }
</script>
</body>
</html>
Click on the “Result” button above −
 Live Demo
<!DOCTYPE html>
<html>
<body>
<h2>Displaying Date</h2>
<button onclick="display()">Result</button>
<p id="test"></p>
<script>
   document.getElementById("test").innerHTML = "Display the current date...";
   function display() {
      var d = new Date();
      document.getElementById("test").innerHTML = d.toLocaleString();
   }
</script>
</body>
</html>
Click “Result” button −
HTML acronym Tag

24 Mar, 2022
The <acronym> tag in HTML is used to define the acronym. The <acronym> tag is used to spell out another word. It is used to give useful information to browsers, translation systems, and search-engines. This tag is not supported in HTML 5 otherwise use <abbr> Tag.
Syntax: 
<acronym title=""> Short Form </acronym>
Attribute: This tag accepts an optional attribute as mentioned above and described below:
title: It is used to specify extra information about the element. When the mouse moves over the element then it shows the information.
Example: 
html
<!DOCTYPE html><html>  <body>    <h1>GeeksforGeeks</h1>      <h2>This is HTML <acronym> Tag</h2>      <acronym title="GeeksforGeeks">GFG</acronym>    <br>    <acronym title="Operating System">OS</acronym></body>  </html>
Output: 
Supported Browser: 
Google Chrome
Internet Explorer
Firefox
Opera
Safari
shubhamyadav4
hritikbhatnagar2182
HTML-Tags
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
REST API (Introduction)
Hide or show elements in HTML using display property
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 ?
How to schedule background tasks (jobs) in ASP.NET Core?

Background tasks, also called as jobs, are essentially services that aren’t meant to execute during a normal flow of the application, such as sending email confirmations or periodically cleaning up the database to purge the inactive accounts. These jobs are not meant to interact with the customers or process user input. Rather, they run in the background, handling items from a queue or executing a long-running process.
A primary advantage of performing these tasks in a background job or service, you can keep the application responsive. For example, when a user signs up, instead of sending them an email in the same request, you can schedule a background job that will send the email to the user.
ASP.NET Core supports background tasks, by providing an abstraction for running a task in the background when the application starts. In ASP.NET Core, these types of background tasks are called Hosted Services, because you host them within your application.
You can use the IHostedService interface to run tasks in the background. The hosted service simply indicates a class that contains background task logic. When the application starts, you register multiple background tasks that run in the background while the application is running. When the application stops, the services are stopped as well. Even Kestrel, the ASP.NET Core server, runs as an IHostedService.
The IHostedService interface contains two methods:
StartAsync(CancellationToken): provides the logic to start the background task.
StartAsync(CancellationToken): provides the logic to start the background task.
StopAsync(CancellationToken): called before the application stops. It provides the logic to end the background task.
StopAsync(CancellationToken): called before the application stops. It provides the logic to end the background task.
Here is an example that illustrates the configuration of a hosted service.
public class Program{
   public static void Main(string[] args){
      CreateHostBuilder(args).Build().Run();
   }

   public static IHostBuilder CreateHostBuilder(string[] args) =>
   Host.CreateDefaultBuilder(args)
      .ConfigureWebHostDefaults(webBuilder =>{
         webBuilder.UseStartup<Startup>();
      })
      .ConfigureServices(services =>{
         services.AddHostedService<VideosWatcher>();
      });
}
You can implement the IHostedService interface using the BackgroundService class as the base class. It contains an ExecuteAsync(CancellationToken) that is called to run the background service. The method returns a Task object that represents the background service lifetime.
NumPy | Vector Multiplication

05 May, 2020
Vector multiplication is of three types:
Scalar Product
Dot Product
Cross Product
Scalar Multiplication:Scalar multiplication can be represented by multiplying a scalar quantity by all the elements in the vector matrix.
Code: Python code explaining Scalar Multiplication
       # importing libraries  import numpy as npimport matplotlib.pyplot as pltimport math  v = np.array([4, 1])w = 5 * vprint("w = ", w)  # Plot worigin =[0], [0]plt.grid()plt.ticklabel_format(style ='sci', axis ='both',                      scilimits =(0, 0))plt.quiver(*origin, *w, scale = 10)plt.show()
Output :
w =  [20  5]
Dot Product multiplication:
Code: Python code to explain Dot Product Multiplication
import numpy as npimport math  v = np.array([2, 1])s = np.array([3, -2])d = np.dot(v, s)print(d)
Here, dot product can also be received using the ‘@’ operator.
d = v@s
Output :
4
Cross Product:
Code: Python code explaining Cross Product
import numpy as npimport math  v = np.array([4, 9, 12])s = np.array([21, 32, 44])r = np.cross(v, s)print(r)
Output:
[ 12  76 -61]
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Matplotlib.pyplot.xlim() in Python

27 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. There are various plots which can be used in Pyplot are Line Plot, Contour, Histogram, Scatter, 3D Plot, etc.#Sample Code
# sample codeimport matplotlib.pyplot as plt     plt.plot([1, 2, 3, 4], [16, 4, 1, 8]) plt.show() 
Output:
The xlim() function in pyplot module of matplotlib library is used to get or set the x-limits of the current axes.Syntax:
matplotlib.pyplot.xlim(*args, **kwargs)
Parameters: This method accept the following parameters that are described below:
left: This parameter is used to set the xlim to left.
right: This parameter is used to set the xlim to right.
**kwargs: This parameter is Text properties that is used to control the appearance of the labels.
Returns: This returns the following:
left, right: This returns the tuple of the new x-axis limits.
Below examples illustrate the matplotlib.pyplot.ylim() function in matplotlib.pyplot:
Example-1:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport numpy as np  h = plt.plot(np.arange(0, 10), np.arange(0, 10))plt.xlim([-5, 20])l1 = np.array((1, 1))angle = 65  th1 = plt.text(l1[0], l1[1], 'Line_angle',               fontsize = 10, rotation = angle,               rotation_mode ='anchor')  plt.title(" matplotlib.pyplot.xlim() Example")plt.show()
Output:
Example-2:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport numpy as np  np.random.seed(9680801)  mu, sigma = 50, 13x = mu + sigma * np.random.randn(10000)  # the histogram of the datan, bins, patches = plt.hist(x, 50,                            density = True,                             facecolor ='g',                             alpha = 0.75)    plt.xlabel('No of Users in K')plt.title('Histogram of IQ')plt.text(50, .035, r'$\mu = 50, \         \ \sigma = 13$')  plt.xlim(-10, 110)plt.ylim(0, 0.04)  plt.grid(True)plt.title(" matplotlib.pyplot.xlim() Example")plt.show()
Output:
Matplotlib Pyplot-class
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Convert integer to string in Python
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
How to pass argument to an Exception in Python?

07 Oct, 2021
There might arise a situation where there is a need for additional information from an exception raised by Python. Python has two types of exceptions namely, Built-In Exceptions and User-Defined Exceptions.Why use Argument in Exceptions? Using arguments for Exceptions in Python is useful for the following reasons: 
It can be used to gain additional information about the error encountered. 
As contents of an Argument can vary depending upon different types of Exceptions in Python, Variables can be supplied to the Exceptions to capture the essence of the encountered errors. Same error can occur of different causes, Arguments helps us identify the specific cause for an error using the except clause. 
It can also be used to trap multiple exceptions, by using a variable to follow the tuple of Exceptions.  
Arguments in Built-in Exceptions:
The below codes demonstrates use of Argument with Built-in Exceptions:Example 1: 
Python3
try:    b = float(100 + 50 / 0)except Exception as Argument:    print( 'This is the Argument\n', Argument)
Output:  
This is the Argument
 division by zero
Example 2: 
Python3
my_string = "GeeksForGeeks" try:    b = float(my_string / 20)except Exception as Argument:    print( 'This is the Argument\n', Argument)
Output:  
This is the Argument
 unsupported operand type(s) for /: 'str' and 'int'
Arguments in User-defined Exceptions:
The below codes demonstrates use of Argument with User-defined Exceptions:Example 1: 
Python3
# create user-defined exception # derived from super class Exceptionclass MyError(Exception):       # Constructor or Initializer    def __init__(self, value):        self.value = value       # __str__ is to print() the value    def __str__(self):        return(repr(self.value))   try:    raise(MyError("Some Error Data"))   # Value of Exception is stored in errorexcept MyError as Argument:    print('This is the Argument\n', Argument)
Output:  
This is the Argument
 'Some Error Data'
Example 2: 
Python3
# class Error is derived from super class Exceptionclass Error(Exception):     # Error is derived class for Exception, but    # Base class for exceptions in this module    pass class TransitionError(Error):     # Raised when an operation attempts a state    # transition that's not allowed.    def __init__(self, prev, nex, msg):        self.prev = prev        self.next = nex try:    raise(TransitionError(2, 3 * 2, "Not Allowed")) # Value of Exception is stored in errorexcept TransitionError as Argument:    print('Exception occurred: ', Argument)
Output: 
Exception occurred:  (2, 6, 'Not Allowed')
anikaseth98
Python-exceptions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python – Extract values of Particular Key in Nested Values

01 Aug, 2020
Given a dictionary with nested dictionaries as values, extract all the values with of particular key.
Input : test_dict = {‘Gfg’ : {“a” : 7, “b” : 9, “c” : 12}, ‘is’ : {“a” : 15, “b” : 19, “c” : 20}, ‘best’ :{“a” : 5, “b” : 10, “c” : 2}}, temp = “b”Output : [9, 10, 19]Explanation : All values of “b” key are extracted.
Input : test_dict = {‘Gfg’ : {“a” : 7, “b” : 9, “c” : 12}, ‘is’ : {“a” : 15, “b” : 19, “c” : 20}, ‘best’ :{“a” : 5, “b” : 10, “c” : 2}}, temp = “a”Output : [7, 15, 5]Explanation : All values of “a” key are extracted.
Method #1 : Using list comprehension + items()
This is one of the ways in which this task can be performed. In this, we use list comprehension to perform the task of extracting particular key and items() is used to get all the items().
Python3
# Python3 code to demonstrate working of # Extract values of Particular Key in Nested Values# Using list comprehension  # initializing dictionarytest_dict = {'Gfg' : {"a" : 7, "b" : 9, "c" : 12},             'is' : {"a" : 15, "b" : 19, "c" : 20},              'best' :{"a" : 5, "b" : 10, "c" : 2}}  # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # initializing keytemp = "c"  # using item() to extract key value pair as wholeres = [val[temp] for key, val in test_dict.items() if temp in val]  # printing result print("The extracted values : " + str(res)) 
The original dictionary is : {'Gfg': {'a': 7, 'b': 9, 'c': 12}, 'is': {'a': 15, 'b': 19, 'c': 20}, 'best': {'a': 5, 'b': 10, 'c': 2}}
The extracted values : [12, 20, 2]

Method #2 : Using list comprehension + values() + keys() 
The combination of above functions can be used to solve this problem. In this, we use values() and keys() to get values and keys separately rather than at once extracted using items().
Python3
# Python3 code to demonstrate working of # Extract values of Particular Key in Nested Values# Using list comprehension + values() + keys()   # initializing dictionarytest_dict = {'Gfg' : {"a" : 7, "b" : 9, "c" : 12},             'is' : {"a" : 15, "b" : 19, "c" : 20},              'best' :{"a" : 5, "b" : 10, "c" : 2}}  # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # initializing keytemp = "c"  # using keys() and values() to extract valuesres = [sub[temp] for sub in test_dict.values() if temp in sub.keys()]  # printing result print("The extracted values : " + str(res)) 
The original dictionary is : {'Gfg': {'a': 7, 'b': 9, 'c': 12}, 'is': {'a': 15, 'b': 19, 'c': 20}, 'best': {'a': 5, 'b': 10, 'c': 2}}
The extracted values : [12, 20, 2]

Python dictionary-programs
Python list-programs
Python
Python Programs
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()
Python program to convert a list to string
Defaultdict in Python
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
Python EasyGUI module – Introduction

09 Jun, 2021
EasyGUI is a module for very simple, very easy GUI programming in Python. EasyGUI is different from other GUI generators in that EasyGUI is NOT event-driven. Instead, all GUI interactions are invoked by simple function calls. Unlike other complicated GUI’s EasyGUI is the simplest GUI till now.
Install using this command: 
pip install easygui
Note : It is not recommended to run EasyGui on IDLE as EasyGui runs on Tkinter and has its own event loop, and IDLE is also an application written by Tkinter module and also it has its own event loop. So when both are run at the same time, conflicts can occur and unpredictable results can occur. So it is preferred to run EasyGui out side the IDLE.
Importing EasyGUI  
from easygui import *
It is the best way to use all the widgets without extra reference.
Example : In this we will create a window having a short message and a press button which when pressed closes our message box, below is the implementation 
Python3
# importing easygui modulefrom easygui import * # title of our windowtitle = "GfG-EasyGUI" # message for our windowmsg = "GeeksforGeeks, Hello World from EasyGUI" # button message by default it is "OK"button = "Let's Go" # creating a message boxmsgbox(msg, title, button )
Output : 
"Let's Go"
Another Example: In this we will allow user to choose the “geek form” and when ans is selected it will get printed, below is the implementation 
Python3
# importing easygui modulefrom easygui import * # choices which user can selectchoices = ["Geek", "Super Geek", "Super Geek 2", "Super Geek God"] # message / question to be askedmsg = "Select any one option" # opening a choice box using our msg and choicesreply = choicebox(msg, choices = choices) # printing the selected optionprint("You selected : ", end = "")print(reply)
Output :  
You selected : Super Geek God
 
saurabh1990aror
Python-EasyGUI
Python-gui
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
Python Classes and Objects
Iterate over a list in Python
Convert integer to string in Python
GATE | GATE-CS-2015 (Set 2) | Question 47 - GeeksforGeeks

27 Sep, 2021
The number of min-terms after minimizing the following Boolean expression is _________.
      [D′ + AB′ + A′C + AC′D + A′C′D]′
(A) 1(B) 2(C) 3(D) 4Answer: (A)Explanation:
Given Boolean expression is: 
              [D′ + AB′ + A′C + AC′D + A′C′D]′

Step 1 : [D′ + AB′ + A′C + C′D ( A + A')]′ 
( taking C'D as common )

Step 2 : [D′ + AB′ + A′C + C′D]′ 
( as, A + A' = 1 )

: [D' + DC' + AB' + A'C]' (Rearrange)

Step 3 : [D' + C' + AB' + A'C]' 
( Rule of Duality, A + A'B = A + B )

: [D' + C' + CA' + AB']' (Rearrange)

Step 4 : [D' + C' + A' + AB']' 
(Rule of Duality)

: [D' + C' + A' + AB']' (Rearrange)

Step 5 : [D' + C' + A' + B']' 
(Rule of Duality)

:[( D' + C' )'.( A' + B')'] 
(Demorgan's law, (A + B)'=(A'. B'))

:[(D''.C'').( A''.B'')] (Demorgan's law)

:[(D.C).(A.B)] (Idempotent law, A'' = A)

: ABCD

Hence only 1 minterm after minimization. 
YouTubeGeeksforGeeks GATE Computer Science16.1K subscribersBoolean Functions and Canonical Forms with Rishabh Setiya | GeeksforGeeks GATEWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:0017:51 / 21:51•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=irOK71KSqR0" 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
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.
GATE | GATE-IT-2004 | Question 66
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2006 | Question 49
GATE | GATE-CS-2004 | Question 3
GATE | GATE CS 2010 | Question 24
GATE | GATE CS 2011 | Question 65
GATE | GATE CS 2019 | Question 27
GATE | GATE CS 2021 | Set 1 | Question 47
GATE | GATE CS 2011 | Question 7
GATE | GATE-CS-2017 (Set 2) | Question 42
How to use Remove, RemoveAt, RemoveRange methods in C# list collections?

To implement Remove() and RemoveAt() methods in C#, try the following code −
Firstly, set a list.
List<string> myList = new List<string>() {
   "mammals",
   "reptiles",
   "amphibians",
   "vertebrate"
};
Now, use Remove() method to remove an element.
myList.Remove("reptiles");
Now, use RemoveAt() method to remove an element by setting the position.
myList.RemoveAt(2);
The following is the complete code −
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
   static void Main() {
      List<string> myList = new List<string>() {
         "mammals",
         "reptiles",
         "amphibians",
         "vertebrate"
      };

      Console.Write("Initial list...");
      foreach (string list in myList) {
         Console.WriteLine(list);
      }

      Console.Write("Using Remove() method...");
      myList.Remove("reptiles");

      foreach (string list in myList) {
         Console.WriteLine(list);
      }

      Console.Write("Using RemoveAt() method...");
      myList.RemoveAt(2);

      foreach (string list in myList) {
         Console.WriteLine(list);
      }
   }
}
Here is an example that implements RemoveRange() method.
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
   static void Main() {
      List<int> myList = new List<int>();
      myList.Add(5);
      myList.Add(10);
      myList.Add(15);
      myList.Add(20);
      myList.Add(25);
      myList.Add(30);
      myList.Add(35);

      Console.Write("Initial list...");
      foreach (int list in myList) {
         Console.WriteLine(list);
      }

      Console.Write("New list...");
      int rem = Math.Max(0, myList.Count - 3);
      myList.RemoveRange(0, rem);

      foreach (int list in myList) {
         Console.Write("\n"+list);
      }
   }
}
PostgreSQL - DROP Database

In this chapter, we will discuss how to delete the database in PostgreSQL. There are two options to delete a database −
Using DROP DATABASE, an SQL command.
Using dropdb a command-line executable.
This command drops a database. It removes the catalog entries for the database and deletes the directory containing the data. It can only be executed by the database owner. This command cannot be executed while you or anyone else is connected to the target database (connect to postgres or any other database to issue this command).
The syntax for DROP DATABASE is given below −
DROP DATABASE [ IF EXISTS ] name

The table lists the parameters with their descriptions.
IF EXISTS
Do not throw an error if the database does not exist. A notice is issued in this case.
name
The name of the database to remove.
The following is a simple example, which will delete testdb from your PostgreSQL schema −
postgres=# DROP DATABASE testdb;
postgres-# 
PostgresSQL command line executable dropdb is a command-line wrapper around the SQL command DROP DATABASE. There is no effective difference between dropping databases via this utility and via other methods for accessing the server. dropdb destroys an existing PostgreSQL database. The user, who executes this command must be a database super user or the owner of the database.
The syntax for dropdb is as shown below −
dropdb  [option...] dbname

The following table lists the parameters with their descriptions
dbname
The name of a database to be deleted.
option
command-line arguments, which dropdb accepts.
The following table lists the command-line arguments dropdb accepts −
-e
Shows the commands being sent to the server.
-i
Issues a verification prompt before doing anything destructive.
-V
Print the dropdb version and exit.
--if-exists
Do not throw an error if the database does not exist. A notice is issued in this case.
--help
Show help about dropdb command-line arguments, and exit.
-h host
Specifies the host name of the machine on which the server is running.
-p port
Specifies the TCP port or the local UNIX domain socket file extension on which the server is listening for connections.
-U username
User name to connect as.
-w
Never issue a password prompt.
-W
Force dropdb to prompt for a password before connecting to a database.
--maintenance-db=dbname
Specifies the name of the database to connect to in order to drop the target database.
The following example demonstrates deleting a database from OS command prompt −
dropdb -h localhost -p 5432 -U postgress testdb
Password for user postgress: ****
The above command drops the database testdb. Here, I have used the postgres (found under the pg_roles of template1) username to drop the database.

    23 Lectures 
     1.5 hours 

 John Elder

    49 Lectures 
     3.5 hours 

 Niyazi Erdogan

    126 Lectures 
     10.5 hours 

 Abhishek And Pukhraj

    35 Lectures 
     5 hours 

 Karthikeya T

    5 Lectures 
     51 mins

 Vinay Kumar

    5 Lectures 
     52 mins

 Vinay Kumar
 Print
 Add Notes
 Bookmark this page
Passing Information Using POST Method in Python

A generally more reliable method of passing information to a CGI program is the POST method. This packages the information in exactly the same way as GET methods, but instead of sending it as a text string after a ? in the URL it sends it as a separate message. This message comes into the CGI script in the form of the standard input.
Below is same hello_get.py script which handles GET as well as POST method.
#!/usr/bin/python
Import modules for CGI handling
import cgi, cgitb
# Create instance of FieldStorage
form = cgi.FieldStorage()
# Get data from fields
first_name = form.getvalue('first_name')
last_name = form.getvalue('last_name')
print "Content-type:text/html\r\n\r\n"
print "<html>"
print "<head>"
print "<title>Hello - Second CGI Program</title>"
print "</head>"
print "<body>"
print "<h2>Hello %s %s</h2>" % (first_name, last_name)
print "</body>"
print "</html>"
Let us take again same example as above which passes two values using HTML FORM and submit button. We use same CGI script hello_get.py to handle this input.
<form action = "/cgi-bin/hello_get.py" method = "post">
First Name: <input type = "text" name = "first_name"><br />
Last Name: <input type = "text" name = "last_name" />
<input type = "submit" value = "Submit" />
</form>
Here is the actual output of the above form. You enter First and Last Name and then click submit button to see the result.
What are Closures in JavaScript?

Closures in JavaScript allow us to access outer function scope from inner function even after the outer function has executed and returned. This means that the inner function will always have access to the outer function variable.
Following is the code for closures in JavaScript −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result {
      font-size: 20px;
      font-weight: 500;
   }
</style>
</head>
<body>
<h1>JavaScript Closures</h1>
<div style="color: green;" class="result"></div>
<button class="Btn">CLICK HERE</button>
<h3>Click on the above button to add two numbers using closure</h3>
<script>
   let sampleEle = document.querySelector(".sample");
   let resEle = document.querySelector(".result");
   function add(num) {
      return function add1(num1) {
         resEle.innerHTML += `${num}+${num1} = ${num + num1}`;
      };
   }
   document.querySelector(".Btn").addEventListener("click", () => {
      let storeadd = add(99);
      storeadd(44);
   });
</script>
</body>
</html>
On clicking the ‘CLICK HERE’ button −
How to remove a common suffix from column names in an R data frame?

To remove a common suffix from column names we can use gsub function. For example, if we have a data frame df that contains column defined as x1df, x2df, x3df, and x4df then we can remove df from all the column names by using the below command:
colnames(df)<-gsub("df","",colnames(df))
Consider the below data frame:
Live Demo
> x1Data<-rnorm(20,25,4)
> x2Data<-rnorm(20,25,1.2)
> x3Data<-runif(20,2,5)
> df1<-data.frame(x1Data,x2Data,x3Data)
> df1
x1Data x2Data x3Data
1 29.26500 26.64124 2.598983
2 21.82170 23.41442 4.134393
3 22.71918 25.21586 4.442823
4 19.88633 25.23487 3.338448
5 20.48989 23.33683 3.829757
6 29.07910 25.54084 3.519393
7 24.28573 23.67258 4.667397
8 27.99849 22.97148 4.100405
9 23.48148 25.36574 2.618030
10 26.39401 23.80191 4.235092
11 29.39867 24.36261 2.782559
12 30.11137 24.62702 4.873779
13 23.56623 25.29017 2.255684
14 24.18464 25.59862 2.247147
15 23.35541 25.38190 4.704027
16 25.02549 25.76776 4.706971
17 18.24187 23.53798 2.411423
18 24.12003 25.27751 2.137409
19 27.58055 24.80092 3.992380
20 23.70832 25.73701 2.577801
Removing the word Data from column names of data frame df1:
> colnames(df1)<-gsub("Data","",colnames(df1))
> df1
x1 x2 x3
1 29.26500 26.64124 2.598983
2 21.82170 23.41442 4.134393
3 22.71918 25.21586 4.442823
4 19.88633 25.23487 3.338448
5 20.48989 23.33683 3.829757
6 29.07910 25.54084 3.519393
7 24.28573 23.67258 4.667397
8 27.99849 22.97148 4.100405
9 23.48148 25.36574 2.618030
10 26.39401 23.80191 4.235092
11 29.39867 24.36261 2.782559
12 30.11137 24.62702 4.873779
13 23.56623 25.29017 2.255684
14 24.18464 25.59862 2.247147
15 23.35541 25.38190 4.704027
16 25.02549 25.76776 4.706971
17 18.24187 23.53798 2.411423
18 24.12003 25.27751 2.137409
19 27.58055 24.80092 3.992380
20 23.70832 25.73701 2.577801
Let’s have a look at another example:
Live Demo
> a_treatment<-rpois(20,5)
> b_treatment<-rpois(20,10)
> c_treatment<-rpois(20,2)
> d_treatment<-rpois(20,8)
> df2<-data.frame(a_treatment,b_treatment,c_treatment,d_treatment)
> df2
a_treatment b_treatment c_treatment d_treatment
1 3 18 3 4
2 1 9 1 5
3 3 13 0 5
4 2 14 0 9
5 4 9 1 10
6 6 8 0 8
7 4 7 5 9
8 2 13 1 8
9 5 4 4 7
10 6 11 1 7
11 4 9 3 12
12 7 6 4 10
13 6 20 3 6
14 4 10 1 4
15 13 11 0 12
16 6 11 1 10
17 6 8 1 16
18 4 8 1 14
19 8 11 2 8
20 3 7 0 9
Removing the word _treatment from column names of data frame df2:
> colnames(df2)<-gsub("_treatment","",colnames(df2))
> df2
a b c d
1 3 18 3 4
2 1 9 1 5
3 3 13 0 5
4 2 14 0 9
5 4 9 1 10
6 6 8 0 8
7 4 7 5 9
8 2 13 1 8
9 5 4 4 7
10 6 11 1 7
11 4 9 3 12
12 7 6 4 10
13 6 20 3 6
14 4 10 1 4
15 13 11 0 12
16 6 11 1 10
17 6 8 1 16
18 4 8 1 14
19 8 11 2 8
20 3 7 0 9
D3.js log.tickFormat() Function - GeeksforGeeks

03 Sep, 2020
The log.tickFormat() function is used to format the ticks returned by log.ticks() function. This function is similar to pow.tickFormat(), the only difference is that this function is customized for the logarithmic scale. If there are too many ticks, the formatter may return the empty string for some ticks so to avoid this set the count equal to infinity.
Syntax:
log.tickFormat([count[, specifier]]);
Parameters: This function accepts two parameters as mentioned above and described below:
count: It is the number of tick values.
specifier: A specifier is a string of format type “s”.
Return Values: This function does not return anything.
Below given are a few examples of the function given above.
Example 1:
<!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>    <script src="https://d3js.org/d3-color.v1.min.js">    </script>    <script src="https://d3js.org/d3-interpolate.v1.min.js">    </script>    <script src="https://d3js.org/d3-scale-chromatic.v1.min.js">    </script></head>  <body>    <h1 style="color:green;">        Geeks for geeks    </h1>      <p>log.tickFormat() Function</p>      <script>        var log = d3.scaleLog()            .domain([1, 14])            .range([1, 2, 3, 4]);          var ticks = log.ticks(2);        var tickFormat = log.tickFormat(2, "$, f");          document.write("<h3>" +            ticks.map(tickFormat) + "</h3>");    </script></body>  </html>
Output:
Example 2:
<!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>     <script src="https://d3js.org/d3-color.v1.min.js">    </script>     <script src="https://d3js.org/d3-interpolate.v1.min.js">    </script>     <script src="https://d3js.org/d3-scale-chromatic.v1.min.js">    </script> </head>   <body>     <h1 style="color:green;">        Geeks for geeks    </h2>      <p>log.tickFormat() Function </p>      <script>         var log = d3.scaleLog()            .domain([1, 14])            .range([1, 2, 3, 4]);            var ticks = log.ticks(Infinity);        var tickFormat = log.tickFormat(Infinity, "$");                    document.write("<h3>" +            ticks.map(tickFormat) + "</h3>");    </script> </body>   </html>
Output:
D3.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Difference Between PUT and PATCH Request
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
C++ Program to Implement Traveling Salesman Problem using Nearest Neighbour Algorithm

Here is a C++ Program to Implement Traveling Salesman Problem using Nearest Neighbour Algorithm.
Begin
   Initialize c = 0, cost = 1000;
   Initialize g[][].
   function swap() is used to swap two values x and y.
   function cal_sum() to calculate the cost which take array a[] and size of array as input.
   Initialize sum = 0.
   for i = 0 to n
      compute s+= g[a[i %3]][a[(i+ 1) %3]];
   if (cost >s)
      cost = s
   function permute() is used to perform permutation:
      if there is one element in array
         call cal_sum().
      else
   for j = i to n
      swap (a+i) with (a + j)
      cal_sum(a+1,n)
      swap (a+i) with (a + j)
End
 Live Demo
#include<iostream>
using namespace std;
int c = 0, cost = 1000;
int g[3][3 ]={{1, 2, 3}, {4, 5, 8}, {6, 7, 10}};
void swap(int *x, int *y) {
   int t;
   t = *x;
   *x = *y;
   *y = t;
}
void cal_sum(int *a, int n) {
   int i, s= 0;
   for (i = 0; i <= n; i++) {
      s+= g[a[i %3]][a[(i+ 1) %3]];
   } if (cost >s) {
      cost = s;
   }
}
void permute(int *a,int i,int n) {
   int j, k;
   if (i == n) {
      cal_sum (a,n);
   } else {
      for (j = i; j <= n; j++) {
         swap((a + i), (a + j));
         cal_sum(a+1,n);
         swap((a + i), (a + j));
      }
   }
}
int main() {
   int i, j;
   int a[] = {1,2,3};
   permute(a, 0,2);
   cout << "minimum cost:" << cost << endl;
}
Comparing str1 and str2 using ==, Res: 0
Comparing str1 and str3 using ==, Res: 1
Comparing str1 and str2 using compare(), Res: -1024
Comparing str1 and str3 using compare(), Res: 0
Evaluation of Expression Tree in C++

In this problem, we are given an expression tree that consist of binary operations like +, - , /, *. We need to do the evaluation of the expression tree and then return the result.
Expression Tree is a special type of binary tree in which each node either consist of an operator or operand which are distributed as−
Leaf nodes of the tree are values on which the operation is to be performed. 
Non-leaf nodes consist of the binary operator
denoting the operation to be performed. 
Input: 
Output: 1
Explanation: 
Decoding the expression tree,
Exp             = ( (5+9) / (2*7) )                   = ( 14 / 14 )
= 1
A simple solution to the problem is by performing one operation each from root, for operends we will solve the subtree. As all operations are binary the nodes of a tree either have two childrens or none.
We will use recursion to solve each node's binary operation.
Live Demo
#include <bits/stdc++.h>
using namespace std;

class node {
   
   public:
      string value;
      node *left = NULL, *right = NULL;
      node(string x)
      {
         value = x;
      }
};

int solveExpressionTree(node* root) {
   
   if (!root)
      return 0;

   if (!root->left &amp;&amp; !root->right)
      return stoi(root->value);

   int leftSubTreeSol = solveExpressionTree(root->left);
   int rightSubTreeSol = solveExpressionTree(root->right);

   if (root->value == "+")
      return leftSubTreeSol + rightSubTreeSol;

   if (root->value == "-")
      return leftSubTreeSol - rightSubTreeSol;

   if (root->value == "*")
      return leftSubTreeSol * rightSubTreeSol;
   
   if (root -> value == "/")
      return leftSubTreeSol / rightSubTreeSol;
   
   return -1;
}

int main()
{
   node *root = new node("/");
   root->left = new node("+");
   root->left->left = new node("9");
   root->left->right = new node("5");
   root->right = new node("*");
   root->right->left = new node("2");
   root->right->right = new node("7");
   cout<<"The evaluation of expression tree is "<<solveExpressionTree(root);
   return 0;
}
The evaluation of expression tree is 1
VB.Net - ContextMenuStrip Control

The ContextMenuStrip control represents a shortcut menu that pops up over controls, usually when you right click them. They appear in context of some specific controls, so are called context menus. For example, Cut, Copy or Paste options.
This control associates the context menu with other menu items by setting that menu item's ContextMenuStrip property to the ContextMenuStrip control you designed.
Context menu items can also be disabled, hidden or deleted. You can also show a context menu with the help of the Show method of the ContextMenuStrip control.
The following diagram shows adding a  ContextMenuStrip control on the form −
The following are some of the commonly used properties of the ContextMenuStrip control −
SourceControl
Gets the last control that displayed the ContextMenuStrip control.
In this example, let us add a content menu with the menu items Cut, Copy and Paste.
Take the following steps −
Drag and drop or double click on a ControlMenuStrip control to add it to the form.
Drag and drop or double click on a ControlMenuStrip control to add it to the form.
Add the menu items, Cut, Copy and Paste to it.
Add the menu items, Cut, Copy and Paste to it.
Add a RichTextBox control on the form.
Add a RichTextBox control on the form.
Set the ContextMenuStrip property of the rich text box to ContextMenuStrip1 using the properties window.
Set the ContextMenuStrip property of the rich text box to ContextMenuStrip1 using the properties window.
Double the menu items and add following codes in the Click event of these menus −
Double the menu items and add following codes in the Click event of these menus −
Private Sub CutToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles CutToolStripMenuItem.Click
   RichTextBox1.Cut()
End Sub

Private Sub CopyToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles CopyToolStripMenuItem.Click
   RichTextBox1.Copy()
End Sub

Private Sub PasteToolStripMenuItem_Click(sender As Object, e As EventArgs) _
Handles PasteToolStripMenuItem.Click
   RichTextBox1.Paste()
End Sub
When the above code is executed and run using Start button available at the Microsoft Visual Studio tool bar, it will show the following window −
Enter some text in the rich text box, select it and right-click to get the context menu appear −
Now, you can select any menu items and perform cut, copy or paste on the text box.

    63 Lectures 
     4 hours 

 Frahaan Hussain

    103 Lectures 
     12 hours 

 Arnold Higuit

    60 Lectures 
     9.5 hours 

 Arnold Higuit

    97 Lectures 
     9 hours 

 Arnold Higuit
 Print
 Add Notes
 Bookmark this page
3D passwords-Advanced Authentication Systems - GeeksforGeeks

17 Dec, 2019
The increase in the usage of computer systems has given rise to many security concerns.One of the major security concern is authentication, which is the process of validating who you are to whom you claimed to be.
Current authentication systems suffer from various weaknesses. People usually use textual passwords; however they do not follow their requirements.The issue is that users intend to use meaningful words from the dictionary, which eventually are easier to break and vulnerable to attack.
A major drawback of the textual password is its conflicting requirements-the selection of a password that is easy to remember(for the user), and at the same time, hard to guess(to prevent unauthorized access to private data).
As a solution, many biometric authentications have been proposed. These include:
1. Retinal scans
2. Fingerscanning
3. Iris recognition
4. Facial recognition
5. Finger vein ID 
However, users usually tend to resist biometrics because:
because of their effect on privacy and their intrusiveness.
moreover, biometrics cannot be revoked.
3D password is a multi factor authentication scheme, that is, it is a security approach that requires the user to provide more than 1 identity factor before accessing their data.
Some factors include:
what a user KNOWS: that is their password.what a user HAS: that is a smart card/hard token.what a user IS: that is a retinal scan/ finger print.
what a user KNOWS: that is their password.
what a user HAS: that is a smart card/hard token.
what a user IS: that is a retinal scan/ finger print.
To be authenticated into a secure system, we present a 3-D virtual environment where the user navigates and interacts with various objects. The sequence of actions and interactions towards the objects inside the environment.Then the user’s password is constructed. The password can combine most existing authentication schemes, i.e., graphical and textual passwords and various biometrics into a virtual 3D environment.
The design of the 3D virtual environment and the type of objects selected determine the 3D password key space.
Advantages:
easy to remember and is highly secure.
easy to customise.
difficult to share.
3D graphical password has no limit.
Disadvantages:
difficult to use for the blind people.
is costly.
requires complex computer technology.
cryptography
Computer Networks
cryptography
Computer Networks
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Advanced Encryption Standard (AES)
Intrusion Detection System (IDS)
Introduction and IPv4 Datagram Header
Block Cipher modes of Operation
Stop and Wait ARQ
Multiple Access Protocols in Computer Network
Cryptography and its Types
Congestion Control in Computer Networks
Active and Passive attacks in Information Security
Secure Electronic Transaction (SET) Protocol
Python – tensorflow.math.subtract()

16 Jun, 2020
TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks.
subtract() is used to compute element wise (x-y).
Syntax: tensorflow.math.subtract(x, y, name)
Parameters:
x: It’s a tensor. Allowed dtypes are bfloat16, half, float32, float64, complex64, complex128.
y: It’s a tensor of same dtype as x.
name(optional): It defines the name for the operation.
Returns: It returns a tensor.
Example 1:
Python3
# importing the libraryimport tensorflow as tf  # Initializing the input tensora = tf.constant([ -5, -7, 2, 5, 7], dtype = tf.float64)b = tf.constant([ 1, 3, 9, 4, 7], dtype = tf.float64)  # Printing the input tensorprint('a: ', a)print('b: ', b)  # Calculating resultres = tf.math.subtract(a, b)  # Printing the resultprint('Result: ', res)
Output:
a:  tf.Tensor([-5. -7.  2.  5.  7.], shape=(5, ), dtype=float64)
b:  tf.Tensor([1. 3. 9. 4. 7.], shape=(5, ), dtype=float64)
Result:  tf.Tensor([ -6. -10.  -7.   1.   0.], shape=(5, ), dtype=float64)




Example 2: Taking complex input
Python3
# importing the libraryimport tensorflow as tf  # Initializing the input tensora = tf.constant([ -5 + 3j, -7-2j, 2 + 1j, 5-7j, 7 + 3j], dtype = tf.complex128)b = tf.constant([ 1 + 5j, 3 + 1j, 9-5j, 4 + 3j, 7-6j], dtype = tf.complex128)  # Printing the input tensorprint('a: ', a)print('b: ', b)  # Calculating resultres = tf.math.subtract(a, b)  # Printing the resultprint('Result: ', res)
Output:
a:  tf.Tensor([-5.+3.j -7.-2.j  2.+1.j  5.-7.j  7.+3.j], shape=(5, ), dtype=complex128)
b:  tf.Tensor([1.+5.j 3.+1.j 9.-5.j 4.+3.j 7.-6.j], shape=(5, ), dtype=complex128)
Result:  tf.Tensor([ -6. -2.j -10. -3.j  -7. +6.j   1.-10.j   0. +9.j], shape=(5, ), dtype=complex128)

Python Tensorflow-math-functions
Python-Tensorflow
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list