code-rag-bench/online-tutorials huggingface dataset:
Add elements to a linked list using Javascript

We need to create a function insert(data, position) that inserts data at given position in the linked list. We'll perform the following steps −
Create a new Node
Check if the list is empty. If it then adds the node to head and return.
If not, then we'll iterate to the position we want to insert it to using currElem. We iterate a linked list by making currElem equal to currElem.next.
Then we'll make node point to the next node in the list. This is to keep track of the rest of the list.
Finally, we break the link from currElem to rest of the list and make it point to our created node. Now the node is in the list at the given position.
Here is an illustration of the same −
Now let's have a look at how we'll implement this − 
insert(data, position = this.length) {
   let node = new this.Node(data);
   if (this.head === null) {
      this.head = node;
      this.length++;
      return this.head;
   }
   let iter = 1;
   let currNode = this.head;
   while (currNode.next != null && iter < position) {
      currNode = currNode.next; iter++;
   }
   node.next = currNode.next;
   currNode.next = node;
   this.length++;
   return node;
}
Note that we've given position as the last element. This is because if you don’t provide a position, it'll be inserted at the end by default.
You can test this using −
let list = new LinkedList();
list.insert(10);
list.insert(20);
list.insert(30);
list.insert(15, 2);
list.display();
This will give the output −
10 ->
30 ->
15 ->
20 ->
As we can see all the elements are in the order we intended. We tried inserting 15 at the position after 2.
SQLSERVER Tryit Editor v1.0

SELECT ISNUMERIC('Hello world!');
​
        
Edit the SQL Statement, and click "Run SQL" to see the result.
This SQL-Statement is not supported in the WebSQL Database.
The example still works, because it uses a modified version of SQL.
Your browser does not support WebSQL.
Your are now using a light-version of the Try-SQL Editor, with a read-only Database.
If you switch to a browser with WebSQL support, you can try any SQL statement, and play with the Database as much as you like. The Database can also be restored at any time.
Our Try-SQL Editor uses WebSQL to demonstrate SQL.
A Database-object is created in your browser, for testing purposes.
You can try any SQL statement, and play with the Database as much as you like. The Database can be restored at any time, simply by clicking the "Restore Database" button.
WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object.
WebSQL is supported in Chrome, Safari, and Opera.
If you use another browser you will still be able to use our Try SQL Editor, but a different version, using a server-based ASP application, with a read-only Access Database, where users are not allowed to make any changes to the data.
Create a button look like a link with Bootstrap

Use the .btn-link class in Bootstrap to create a button look like a link.
You can try to run the following code to implement a .btn-link class
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link rel = "stylesheet"
         href = "https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
   </head>
   <body>
      <p>The following are FMCG companies:</p>
      <div class = "btn-group-justified btn-group-sm btn-group-vertical">
         <button type = "button" class = "btn btn-primary">ITC Limited</button>
         <button type = "button" class = "btn btn-primary">Colgate-Palmolive</button>
         <button type = "button" class = "btn btn-primary">Nestle</button>
         <button type = "button" class = "btn btn-link">Britannia Industries Limited</button>
      </div>
   </body>
</html>
Array element with minimum sum of absolute differences in C++?

This program is to find minimum absolute difference of the array given we have an array which have distinct element.To learn this concept better let’s rebrush the things that required,
Array is a container of elements of same data type. The length of an array needs to be predefined.
absolute difference is the absolute value of the difference between two numbers i.e. the difference will always be positive, negative values will be converted to positive.
The sum of minimum absolute difference of each element has to be found the minimum absolute solute difference formula is
Minimum Absolute Difference (a) = min(abs(a – arr[j])) ;
where 1 <= j <= n and j != i, abs is the absolute value.
Input: arr = {1, 3, 9, 3, 6}
Output: 8
The optimal solution is to choose x = 3, which produces the sum
|1 – 3| + |3 – 3| + |9 – 3| + |3 – 3| = 2 + 0 + 6 + 0 = 8
The given input array is sorted.
The given input array is sorted.
minimum absolute difference for the first element of the array, is calculated using the second array element.
minimum absolute difference for the first element of the array, is calculated using the second array element.
minimum absolute difference for the last array element, is also calculated using the second last array element.
minimum absolute difference for the last array element, is also calculated using the second last array element.
, minimum absolute difference for the other array elements which hare present at index i are calculated by :
, minimum absolute difference for the other array elements which hare present at index i are calculated by :
minAbsDiff = min( abs(arr[i] – arr[i-1]), abs(ar[i] – arr[i+1]) ).
minAbsDiff = min( abs(arr[i] – arr[i-1]), abs(ar[i] – arr[i+1]) ).
 Live Demo
#include<iostream>
#include <algorithm>
using namespace std;
int abs_sum(int a[], int len);
int main() {
   int a[]={1, 3, 9, 3, 6};
   int n, i;
   n=5;
   sort(a, a+n);
   int sum = 0;
   sum += abs(a[0]- a[1]);
   sum += abs(a[n-1]-a[n-2]);
   for (int i = 1; i < n-1; i++) {
      sum += min(abs(a[i]-a[i-1]), abs(a[i]-a[i+1]));
   }
   cout<<"The element with minimum sum of absolute differences is : "<<sum;
   return 0;
}
The element with minimum sum of absolute differences is : 8
C# Program to Show the Use of GetEnvironmentVariable() Method of Environment Class - GeeksforGeeks

16 Nov, 2021
In C#, Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that it retrieves command-line arguments information, exit codes information, environment variable settings information, contents of the call stack information, and time since the last system boot in milliseconds information. By just using some predefined methods we can get the information of the Operating System using the Environment class and GetEnvironmentVariable() method is one of them. This method is used to get the value of an environment variable from the current process.
Syntax:
Environment.GetEnvironmentVariable(“directory_name”)
where directory_name is the directory
Return: This method will return the string that will represent the environment variable or it will return null if the environment variable is not found.
Exceptions: This method will throw the following exceptions:
ArgumentNullException is thrown when the variable is null.
SecurityException is thrown when the caller does not have the required permission to perform this operation.
Example:
C#
// C# program to illustrate the GetEnvironmentVariable()// method of Environment Classusing System;using System.IO;  class GFG{    static public void Main(){          // Get the windows directory    // environment details    Environment.CurrentDirectory = Environment.GetEnvironmentVariable("windir");    DirectoryInfo info = new DirectoryInfo(".");          // Display the information    Console.WriteLine("Information:\n" + info.FullName);}}
Output:
Information:
D:\Windows
Picked
C#
C# Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 50 C# Interview Questions & Answers
Extension Method in C#
HashSet in C# with Examples
Partial Classes in C#
C# | Inheritance
Convert String to Character Array in C#
Getting a Month Name Using Month Number in C#
Socket Programming in C#
Program to Print a New Line in C#
Program to find absolute value of a given number
Can we write any statements between try, catch and finally blocks in Java?

No, we cannot write any statements in between try, catch and finally blocks and these blocks form one unit.  The functionality of try keyword is to identify an exception object and catch that exception object and transfer the control along with the identified exception object to the catch block by suspending the execution of the try block. The functionality of the catch block is to receive the exception class object that has been sent by the try and catch that exception class object and assigns that exception class object to the reference of the corresponding exception class defined in the catch block. The finally blocks are the blocks which are going to get executed compulsorily irrespective of the exception.
We can write statements like try with catch block, try with multiple catch blocks, try with finally block and try with catch and finally blocks and cannot write any code or statements between these combinations. If we try to put any statements between these blocks, it will throw a compile-time error.
try
{
   // Statements to be monitored for exceptions
}
// We can't keep any statements here
catch(Exception ex){
   // Catching the exceptions here
}
// We can't keep any statements here
finally{
   // finally block is optional and can only exist if try or try-catch block is there.
   // This block is always executed whether exception is occurred in the try block or not
   // and occurred exception is caught in the catch block or not.
   // finally block is not executed only for System.exit() and if any Error occurred.
}
Live Demo
public class ExceptionHandlingTest {
   public static void main(String[] args) {
      System.out.println("We can keep any number of statements here");
      try {
         int i = 10/0; // This statement throws ArithmeticException
         System.out.println("This statement will not be executed");
      }
      //We can't keep statements here
      catch(ArithmeticException ex){
         System.out.println("This block is executed immediately after an exception is thrown");
      }
      //We can't keep statements here
      finally {
         System.out.println("This block is always executed");
      }
         System.out.println("We can keep any number of statements here");
   }
}
We can keep any number of statements here
This block is executed immediately after an exception is thrown
This block is always executed
We can keep any number of statements here
What is the difference between jQuery.load() and jQuery.get() methods in jQuery?

The load( url, data, callback ) method loads data from the server and places the returned HTML into the matched element.
Here is the description of all the parameters used by this method −
url − A string containing the URL to which the request is sent.
data − This optional parameter represents a map of data that is sent with the request.
callback − This optional parameter represents a function that is executed if the request succeeds
Assuming we have following HTML content in result.html file:
<h1>THIS IS RESULT...</h1>
The following is the code snippet showing the usage of this method.
   <head>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
       
      <script>
         $(document).ready(function() {
            $("#driver").click(function(event){
               $('#stage').load('result.html');
            });
         });
      </script>
   </head>
   
   <body>
   
      <p>Click on the button to load result.html file:</p>
       
      <div id = "stage" style = "background-color:cc0;">
         STAGE
      </div>
       
      <input type = "button" id = "driver" value = "Load Data" />
       
   </body>
The jQuery.get( url, [data], [callback], [type] ) method loads data from the server using a GET HTTP request.
Here is the description of all the parameters used by this method −
url − A string containing the URL to which the request is sent
data − This optional parameter represents key/value pairs that will be sent to the server.
callback − This optional parameter represents a function to be executed whenever the data is loaded successfully.
type − This optional parameter represents type of data to be returned to callback function: "xml", "html", "script", "json", "jsonp", or "text".
Let’s say we have the following PHP content in result.php file,
<html>
   <?php
    if( $_REQUEST["name"] ) {

      $name = $_REQUEST['name'];
      echo "Welcome ". $name;
    }
   ?>
</html>
The following is the code snippet showing the usage of this method −
   <head>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
       
      <script>
         $(document).ready(function() {
           
            $("#driver").click(function(event){
               $.get(
                  "result.php",
                  { name: "Zara" },
                  function(data) {
                     $('#stage').html(data);
                  }
               );
            });
               
         });
      </script>    
   </head>
   
   <body>
   
      <p>Click on the button to load result.html file</p>
       
      <span id = "stage" style = "background-color:#cc0;">
         STAGE
      </span>
       
      <div><input type = "button" id = "driver"
         value = "Load Data" /></div>
   
   </body>
Anchor Pseudo-classes in CSS

Using CSS pseudo-class selectors, namely, :active, :hover, :link and :visited we can style different states of a link/anchor. For proper functionality, the order of these selectors should be −
:link
:visited
:hover
:active
The syntax of CSS psudo-class property is as follows −
a:(pseudo-selector) {
   /*declarations*/
}
Let’s see an example to use CSS Anchor Pseudo Classes −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
div {
   display: flex;
   float: left;
}
a {
   margin: 20px;
   padding: 10px;
   border: 2px solid black;
   text-shadow: -1px 0px black, 0px -1px black, 0px 1px black, 1px 0px black;
   font-size: 1.1em;
}
a:link {
   text-decoration: none;
}
a:visited {
   color: blueviolet;
}
a:hover {
   color: orange;
   font-size: 150%;
   font-weight: bold;
   box-shadow: 0 0 5px 1px grey;
}
a:active {
   color: red;
   box-shadow: inset 0 0 15px red;
}
</style>
</head>
<body>
<div>
<h2>Your favourite sports?</h2>
<a href="#">Football</a>
<a href="">Cricket</a>
</div>
</body>
</html>
Initial output −
On hovering the first link, we get the following output
During click of the first link, the following output is returned −
Let’s see another example of CSS Anchor Pseudo Class −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<title>CSS Anchor Pseudo Classes</title>
</head>
<style>
div {
   color: #000;
   padding:20px;
   background-image: linear-gradient(135deg, grey 0%, white 100%);
   text-align: center;
}
.anchor {
   color: #FF8A00;
}
.anchor:last-child {
   color: #03A9F4;
}
.anchor:visited {
   color: #FEDC11;
}
.anchor:hover {
   color: #C303C3;
}
.anchor:active {
   color: #4CAF50;
}
</style>
<body>
<div>
<h1>Search Engines</h1>
<a class="anchor" href="https://www.google.com" target="_blank">Go To Google</a>
<a class="anchor" href="https://www.bing.com" target="_blank">Go To Bing</a>
</div>
</body>
</html>
Program to find out the k-th smallest difference between all element pairs in an array in C++

Suppose we are given a list containing several integer numbers. We have to find out the difference between each pair of values in the array and find out the k-th smallest difference number. The index starts at 0 and the value k is given to us as input.
So, if the input is like numbers = {2, 6, 4, 8}, k = 2, then the output will be 2.
The differences between the pairs are −
(2, 6) = 4
(2, 4) = 2
(2, 8) = 6
(6, 4) = 2
(6, 8) = 2
(4, 8) = 4
If we sort the values, it becomes 2, 2, 2, 4, 4, 6. The 2-nd smallest value is 2. (Index starts from
0).
To solve this, we will follow these steps −
increase k by 1
sort the array input
le := 0
ri := last element of input - first item of input
while le < ri, do −mid := (le + ri) / 2tmp := 0lp := 0for initialize i := 1, when i < size of input, update (increase i by 1), do −while input[i] - input[lp] > mid, do −lp := lp + 1tmp := tmp + i - lpif tmp >= k, then −ri := midOtherwisele := mid + 1
mid := (le + ri) / 2
tmp := 0
lp := 0
for initialize i := 1, when i < size of input, update (increase i by 1), do −while input[i] - input[lp] > mid, do −lp := lp + 1tmp := tmp + i - lp
while input[i] - input[lp] > mid, do −lp := lp + 1
lp := lp + 1
tmp := tmp + i - lp
if tmp >= k, then −ri := mid
ri := mid
Otherwisele := mid + 1
le := mid + 1
return le
Let us see the following implementation to get better understanding −
#include<bits/stdc++.h>

using namespace std;

int solve(vector<int>& input, int k) {
k++;
sort(input.begin(), input.end());
int le = 0;
int ri = input.back() - input[0];
while (le < ri) {
int mid = (le + ri) / 2;
long long tmp = 0;
int lp = 0;
for (int i = 1; i < input.size(); i++) {
while (input[i] - input[lp] > mid) lp++;
tmp += i - lp;
}
if (tmp >= k)
ri = mid;
else
le = mid + 1;
}
return le;
}
int main() {
vector<int> numbers = {2, 6, 4, 8};
cout<< solve(numbers, 2) <<endl;
return 0;
}
vector<int> numbers = {2, 6, 4, 8};
cout<< solve(numbers, 2) <<endl;
2
MySQL - ABS() Function

MySQL provides a set of functions to perform various numerical functions. The ABS() function of MySQL accepts an integer value as a parameter and returns the absolute value for the given integer.
Following is the syntax of this function −
ABS(x)

Where x is a real number.
Following is an example of the MySQL ABS() function −
mysql> SELECT ABS(225);
+----------+
| ABS(225) |
+----------+
|      225 |
+----------+
1 row in set (0.01 sec)
Following is another example of this function −
mysql> SELECT ABS(PI());
+-----------+
| ABS(PI()) |
+-----------+
| 3.141593  |
+-----------+
1 row in set (0.09 sec)
If you pass a negative integer to this function the resultant value will be the same integer without the negative sign.
mysql> SELECT ABS(-55787);
+-------------+
| ABS(-55787) |
+-------------+
|       55787 |
+-------------+
1 row in set (0.41 sec)
If the value passed is NULL or, in case of an error, this function returns NULL.
mysql> SELECT ABS(NULL);
+-----------+
| ABS(NULL) |
+-----------+
|      NULL |
+-----------+
1 row in set (0.00 sec)
You can also pass value to this function in the form of a string −
mysql> SELECT ABS('-225');
+-------------+
| ABS('-225') |
+-------------+
|         225 |
+-------------+
1 row in set (0.00 sec)
If the value passed is not null and not an integer value, this function returns 0 −
mysql> SELECT ABS('test');
+-------------+
| ABS('test') |
+-------------+
|           0 |
+-------------+
1 row in set, 1 warning (0.00 sec)
Assume we have created a table with name Test as shown below −
mysql> CREATE TABLE Test (radius INT);
Query OK, 0 rows affected (3.13 sec)

Let us insert r values into it −
mysql> INSERT INTO Test VALUES(20),(30),(40);
Query OK, 3 rows affected (3.51 sec)
Records: 3 Duplicates: 0 Warnings: 0

Following query calculates the area of circles for all the records and displays −
mysql> SELECT radius, abs(PI()*radius*radius) as Area FROM Test;
+--------+-------------+
| radius | Area        |
+--------+-------------+
| 20     | 1256.637061 |
| 30     | 2827.433388 |
| 40     | 5026.548246 |
+--------+-------------+
3 rows in set (0.00 sec)
Import module in Python

12 May, 2021
Import in python is similar to #include header_file in C/C++. Python modules can get access to code from another module by importing the file/function using import. The import statement is the most common way of invoking the import machinery, but it is not the only way.
import module_name When the import is used, it searches for the module initially in the local scope by calling __import__() function. The value returned by the function is then reflected in the output of the initial code. 
PYTHON
import mathprint(math.pi)
Output:
3.141592653589793
import module_name.member_name In the above code module, math is imported, and its variables can be accessed by considering it to be a class and pi as its object. The value of pi is returned by __import__(). pi as a whole can be imported into our initial code, rather than importing the whole module. 
PYTHON
from math import pi # Note that in the above example,# we used math.pi. Here we have used# pi directly.print(pi)
Output:
3.141592653589793
 from module_name import * In the above code module, math is not imported, rather just pi has been imported as a variable. All the functions and constants can be imported using *. 
PYTHON
from math import *print(pi)print(factorial(6))
Output:
3.141592653589793
720
As said above import uses __import__() to search for the module, and if not found, it would raise ImportError 
PYTHON
import mathematicsprint(mathematics.pi)
Output:
Traceback (most recent call last):
  File "C:/Users/GFG/Tuples/xxx.py", line 1, in 
    import mathematics
ImportError: No module named 'mathematics'
This article is contributed by Piyush Doorwar. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks. 
simranarora5sos
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
Python OOPs Concepts
turtle.end_fill() function in Python

29 Jun, 2021
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
This method is used to Fill the shape drawn after the call begin_fill(). It doesn’t take any argument.
Syntax :
turtle.end_fill()
Below is the implementation of the above method with an example :
Example:
Python3
# importing packageimport turtle # set turtle position# and colorturtle.up()turtle.goto(0,-30)turtle.down()turtle.color("yellow") # start fill blockturtle.begin_fill() # all instruction within this# block are filled with turtle# color as set aboveturtle.circle(60) # end fill blockturtle.end_fill() # hide the turtleturtle.hideturtle()
 
 
Output :
 
 
varshagumber28
Python-turtle
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 | os.path.join() method
Introduction To PYTHON
Python OOPs Concepts
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 | Get unique values from a list
Create a directory in Python
Why Abstract Class is used in Java?

A class is an abstract class if it contains at least one abstract method. It can contain other non-abstract methods as well. A class can be declared as abstract by using the abstract keyword. Also, an abstract class cannot be instantiated.
A program that demonstrates an abstract class in Java is given as follows:
 Live Demo
abstract class Animal {
   abstract void sound();
}
class Cat extends Animal {
   void sound() {
      System.out.println("Cat Meows");
   }
}
class Dog extends Animal {
   void sound() {
      System.out.println("Dog Barks");
   }
}
class Cow extends Animal {
   void sound() {
      System.out.println("Cow Moos");
   }
}
public class Demo {
   public static void main(String[] args) {
      Animal a;
      a = new Cat();
      a.sound();
      a = new Dog();
      a.sound();
      a = new Cow();
      a.sound();
   }
}
Cat Meows
Dog Barks
Cow Moos
Python | Get all substrings of given string

01 Jul, 2019
There are many problems in which we require to get all substrings of a string. This particular utility is very popular in competitive programming and having shorthands to solve this problem can always be handy. Let’s discuss certain ways in which this problem can be solved.
Method #1 : Using list comprehension + string slicingThe combination of list comprehension and string slicing can be used to perform this particular task. This is just brute force method to perform this task.
# Python3 code to demonstrate working of# Get all substrings of string# Using list comprehension + string slicing  # initializing string test_str = "Geeks"  # printing original string print("The original string is : " + str(test_str))  # Get all substrings of string# Using list comprehension + string slicingres = [test_str[i: j] for i in range(len(test_str))          for j in range(i + 1, len(test_str) + 1)]  # printing result print("All substrings of string are : " + str(res))
The original string is : GeeksAll substrings of string are : [‘G’, ‘Ge’, ‘Gee’, ‘Geek’, ‘Geeks’, ‘e’, ‘ee’, ‘eek’, ‘eeks’, ‘e’, ‘ek’, ‘eks’, ‘k’, ‘ks’, ‘s’]
 
Method #2 : Using itertools.combinations()This particular task can also be performed using the inbuilt function of combinations, which helps to get all the possible combinations i.e the substrings from a string.
# Python3 code to demonstrate working of# Get all substrings of string# Using itertools.combinations()from itertools import combinations  # initializing string test_str = "Geeks"  # printing original string print("The original string is : " + str(test_str))  # Get all substrings of string# Using itertools.combinations()res = [test_str[x:y] for x, y in combinations(            range(len(test_str) + 1), r = 2)]  # printing result print("All substrings of string are : " + str(res))
The original string is : GeeksAll substrings of string are : [‘G’, ‘Ge’, ‘Gee’, ‘Geek’, ‘Geeks’, ‘e’, ‘ee’, ‘eek’, ‘eeks’, ‘e’, ‘ek’, ‘eks’, ‘k’, ‘ks’, ‘s’]
Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to iterate through Excel rows in Python?
Enumerate() in Python
Python Dictionary
Deque in Python
Defaultdict in Python
Defaultdict in Python
Python program to add two numbers
Python | Get dictionary keys as a list
Python Program for Fibonacci numbers
Python Program for factorial of a number
Live Search Using Flask And jQuery

09 Apr, 2021
In this article, we will do a live search in Flask using Jquery. Live search means that whenever a user type any letter in the input box then all the words containing that letter will be shown.
This module does not come in-built with Python. To install it type the below command in the terminal.
pip install flask
After installing the flask create a new directory for the project. Inside that create a new file and name that app.py. 
Python3
from flask import Flask,render_template    app = Flask(__name__)  @app.route("/")def home():    return render_template("index.html")    if __name__ == "__main__":    app.run(debug=True)
Inside the project create new directory templates and inside that create a new file index.html. This file contains the HTML code for user input where user will input the desired text and the output will be shown. The Jquery will search for the all the strings containing the matching character(s) typed by the user.
Index.HTML
HTML
<!DOCTYPE html><html><head>    <title>GFG</title></head><body>  <input type="text" class="live-search-box" placeholder="search here" />  <ul class="live-search-list" type="None"><li>C++</li><li>c</li><li>Python</li><li>Java</li><li>Javascript</li><li>Golang</li><li>R</li><li>Ruby</li><li>Scala</li><li>C#</li><li>PHP</li><li>Fortran</li><li>Dart</li></ul>  <script src="https://code.jquery.com/jquery-3.5.1.js" integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc=" crossorigin="anonymous"></script>  <script type="text/javascript">    jQuery(document).ready(function($){  $('.live-search-list li').each(function(){$(this).attr('data-search-term', $(this).text().toLowerCase());});  $('.live-search-box').on('keyup', function(){  var searchTerm = $(this).val().toLowerCase();      $('.live-search-list li').each(function(){          if ($(this).filter('[data-search-term *= ' + searchTerm + ']').length > 0 || searchTerm.length < 1) {            $(this).show();        } else {            $(this).hide();        }      });  });  });</script>  </body></html>
To run this app open cmd or terminal in the same directory and type the below command.
python app.py
Output:
Python Flask
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 | Get unique values from a list
Python | datetime.timedelta() function
C++ Exception Library - domain_error

It is a domain error exception.the domain of a mathematical function is the subset of values that it is defined for. For example, the square root function is only defined for non-negative numbers. Thus, a negative number for such a function would qualify as a domain error.
Following is the declaration for std::domain_error.
class domain_error;
class domain_error;
none
none
No-throw guarantee − no members throw exceptions.
constructor − what_arg has the same content as the value returned by member what.
constructor − what_arg has the same content as the value returned by member what.
what − It is used to get string identifying exception.
what − It is used to get string identifying exception.
 Print
 Add Notes
 Bookmark this page
How To Make Scree Plot in R with ggplot2 - GeeksforGeeks

23 Sep, 2021
In this article, we are going to see how can we plot a Scree plot in R Programming Language with ggplot2. 
Here we will load the dataset, (Remember to drop the non-numerical column). Since the iris flower dataset contains a species column that is of character type so we need to drop it because PCA works with only numerical data.
R
# drop the species column as its character typenum_iris = subset(iris,                  select = -c(Species))head(num_iris)
Output: 
We use R language’s inbuilt prcomp() function, this function takes the dataset as an argument and computes the PCA. Principal Component Analysis (PCA) is a statistical procedure that uses an orthogonal transformation that converts a set of correlated variables to a set of uncorrelated variables. Doing scale=TRUE standardizes the data. 
Syntax: prcomp(numeric_data, scale = TRUE)
Code: 
R
# drop the species column as its character typenum_iris = subset(iris, select = -c(Species) ) # compute pcapca <- prcomp(num_iris, scale = TRUE)pca
Output: 
We use the formula below to compute the total variance experienced by each PC. 
Syntax: pca$sdev^2 / sum(pca$sdev^2)
Code: 
R
# drop the species column as its character typenum_iris = subset(iris, select = -c(Species) ) # compute pcapca <- prcomp(num_iris, scale = TRUE) # compute total variancevariance = pca$sdev^2 / sum(pca$sdev^2)variance
Output: 
[1] 0.729624454 0.228507618 0.036689219 0.005178709
R
library(ggplot2) # drop the species column as its character typenum_iris = subset(iris, select = -c(Species) ) # compute pcapca <- prcomp(num_iris, scale = TRUE) # compute total variancevariance = pca $sdev^2 / sum(pca $sdev^2) # Scree plotqplot(c(1:4), variance) +  geom_line() +  geom_point(size=4)+  xlab("Principal Component") +  ylab("Variance Explained") +  ggtitle("Scree Plot") +  ylim(0, 1)
Output: 
R
library(ggplot2) # drop the species column as its character typenum_iris = subset(iris, select = -c(Species) ) # compute pcapca <- prcomp(num_iris, scale = TRUE) # compute total variancevariance = pca $sdev^2 / sum(pca $sdev^2) # Scree plotqplot(c(1:4), variance) +  geom_col()+  xlab("Principal Component") +  ylab("Variance Explained") +  ggtitle("Scree Plot") +  ylim(0, 1)
Output: 
 
anikakapoor
Picked
R-ggplot
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Control Statements in R Programming
Change Color of Bars in Barchart using ggplot2 in R
Data Visualization in R
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
Logistic Regression in R Programming
How to change Colors in ggplot2 Line Plot in R ?
How to filter R DataFrame by values in a column?
Linear Discriminant Analysis in R Programming
R - Operators
How to show the date and time the document was last modified with JavaScript?

To show the last modified date with JavaScript, use the lastModified property.
You can try to run the following code to display the date and time the document last modified with JavaScript −
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <script>
         var date = document.lastModified;
         document.write("Last Modified: "+date);
      </script>
   </body>
</html>
How to group header content of a table using HTML5 ? - GeeksforGeeks

05 Jun, 2020
In this article, we define to group the header content in a table by using the <th> tag in HTML to set the header cell of a table. Two types of cells in an HTML table.
Header Cell: It is used to hold the header information.
Standard Cell: It is used to hold the body of data.
The working of both tags (<th> and <td>) are same but the text properties are different. In <th> tag, text is bold and centered, and in <td> tag, text is regular and left align by default.
Syntax:
<th> Contents... </th>
Example:
<!DOCTYPE html><html>  <head>    <title>        Group the header content         in a table using HTML    </title>      <style>        body {            text-align: center;        }          h1 {            color: green;        }          th {            color: blue;        }          table,        tbody,        td {            border: 1px solid black;            border-collapse: collapse;        }    </style></head>  <body>    <center>        <h1>GeeksforGeeks</h1>          <h2>            HTML5: How to group the             header content in a table?        </h2>                  <table>            <thead>                <tr>                    <th>Name</th>                    <th>User Id</th>                </tr>            </thead>            <tbody>                <tr>                    <td>Shashank</td>                    <td>@shashankla</td>                </tr>                <tr>                    <td>GeeksforGeeks</td>                    <td>@geeks</td>                </tr>            </tbody>        </table>    </center></body>  </html>                              
Output:
Supported Browsers are listed below:
Google Chrome
Internet Explorer
Firefox
Opera
Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Misc
HTML-Basics
HTML-Misc
HTML5
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to create footer to stay at the bottom of a Web page?
How to update Node.js and NPM to next version ?
Types of CSS (Cascading Style Sheet)
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
How does modulus work with complex numbers in Python?

Floor and modulus operators (// and % respectively) are not allowed to be used on complex number in Python 3.x. However, these operations are defined for complex numbers in Python 2.7.x
>>> x=9+2j
>>> y=2+1j
>>> x%y
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
x%y
TypeError: can't mod complex numbers.
>>> x=9+2j
>>> y=2+1j
>>> x%y
(1-2j)
Modulus of complex number operands returns their floor division multiplied by denominator
>>> x-(x//y)*y
(1-2j)
Explain JavaScript Regular Expression modifiers with examples

The JavaScript regular expression modifiers are optional part of a regular expression and allow us to perform case insensitive and global searchers. The modifiers can also be combined together.
Following are the modifiers −
Following is the code for strict comparison in JavaScript switch statement −
 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 Regular expression modifiers</h1>
<div class="sample"></div>
<div style="color: green;" class="result"></div>
<button class="Btn">CLICK HERE</button>
<h3>
Click on the above button to see the modifiers operate on the above string
</h3>
<script>
   let sampleEle=document.querySelector('.sample');
   let resEle = document.querySelector('.result');
   let str = '\nHello world. This is a beautiful world';
   sampleEle.innerHTML =str;
   document.querySelector(".Btn").addEventListener("click", () => {
      resEle.innerHTML += '/^Hello/m = ' + str.match(/^Hello/m) + '<br>';
      resEle.innerHTML += '/world/g = ' + str.match(/world/g) + '<br>';
      resEle.innerHTML += '/WORLD/i = ' + str.match(/WORLD/i) + '<br>';
   });
</script>
</body>
</html>
The above code will produce the following output −
On clicking the ‘CLICK HERE’ button −
How to change font size in ttk.Button?

Tkinter Ttk is a native library in Tkinter which is used to style the widgets in a Tkinter application. It provides a native GUI interface to all the widgets defined in the application.In order to style the widgets with ttk, we have to import it in the notebook using the command ‘from tkinter import ttk’.
For a particular application, we can change the font properties such as background color, foreground color, font size, font-family, and font style by defining an instance of ttk style object. After initializing the ttk object, we can configure(options) each widget defined in an application.
In this example, we will create a button that can be customized after defining the style object.
#Import the required Libraries
from tkinter import *
from tkinter import ttk

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

#Set the geometry of tkinter frame
win.geometry("750x270")

#Create an instance of Style Object
style = ttk.Style()

#Create ttk buttons
small_button = ttk.Button(win, text="small button", style="small.TButton")
small_button.pack(pady=20)
big_button = ttk.Button(win, text="big button", style="big.TButton")
big_button.pack()

#Configure the properties of the Buttons
style.configure('big.TButton', font=(None, 20), foreground="blue4")
style.configure('small.TButton', font=(None, 7))

win.mainloop()
Running the above code will display a window that will contain two buttons of different sizes and properties.
In the given output, there are two ttk buttons which are having different properties such as font size and color. We can modify the font size by updating the values in the configuration.
How to Create a Black and White Image Using CSS

By specifying grayscale value to the filter property of CSS we can create a black and white image. filter property can be used to apply special effects like blur, drop-shadow to images.
The syntax of CSS filter property is as follows −
Selector {
   filter: grayscale(100%);
   -webkit-filter: grayscale(100%);
}
The following examples illustrate CSS filter property.
 Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         img {
            margin: 2%;
            border-radius: 25%;
         }
         img:nth-of-type(even) {
            filter: grayscale(100%);
            -webkit-filter: grayscale(100%);
         }
      </style>
   </head>
   <body>
      <img src="https://images.unsplash.com/photo-1611825715408-826f2b19c43f?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=200&ixlib=rb-1.2.1&q=80&w=200" alt="img from unsplash">
      <img src="https://images.unsplash.com/photo-1611825715408-826f2b19c43f?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=200&ixlib=rb-1.2.1&q=80&w=200" alt="img from unsplash">
   </body>
</html>
This gives the following output
 Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         img {
            margin: 2%;
         }
         img:nth-of-type(odd) {
            filter: grayscale(100%);
            -webkit-filter: grayscale(100%);
         }
      </style>
   </head>
   <body>
      <img src="https://images.unsplash.com/photo-1611781750917-8777ab68668a?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=256&ixlib=rb-1.2.1&q=80&w=256">
      <img src="https://images.unsplash.com/photo-1611781750917-8777ab68668a?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=256&ixlib=rb-1.2.1&q=80&w=256">
   </body>
</html>
This gives the following output
How to compare two JavaScript Date Objects?

To compare two date objects with JavaScript, create two dates object and get the recent date to compare it with the custom date.
You can try to run the following code to compare two dates −
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <script>
         var date1, date2;
         date1 = new Date();
         document.write(date1);
         date2 = new Date( "Dec 10, 2015 20:15:10" );
         document.write("<br>"+date2);
         if (date1 > date2) {
            document.write("<br>Date1 is the recent date.");
         } else {
            document.write("<br>Date 2 is the recent date.");
         }
      </script>
   </body>
</html>
Mon May 28 2018 09:48:49 GMT+0530 (India Standard Time)
Thu Dec 10 2015 20:15:10 GMT+0530 (India Standard Time)
Date1 is the recent date
Perl IF...ELSE statement

A Perl if statement can be followed by an optional else statement, which executes when the boolean expression is false.
The syntax of an if...else statement in Perl programming language is −
if(boolean_expression) {
   # statement(s) will execute if the given condition is true
} else {
   # statement(s) will execute if the given condition is false
}

If the boolean expression evaluates to true, then the if block of code will be executed otherwise else block of code will be executed.
The number 0, the strings '0' and "" , the empty list () , and undef are all false in a boolean context and all other values are true. Negation of a true value by ! or not returns a special false value.
#!/usr/local/bin/perl
 
$a = 100;
# check the boolean condition using if statement
if( $a < 20 ) {
   # if condition is true then print the following
   printf "a is less than 20\n";
} else { 
   # if condition is false then print the following
   printf "a is greater than 20\n";
}
print "value of a is : $a\n";

$a = "";
# check the boolean condition using if statement
if( $a ) {
   # if condition is true then print the following
   printf "a has a true value\n";
} else {
   # if condition is false then print the following
   printf "a has a false value\n";
}
print "value of a is : $a\n";
When the above code is executed, it produces the following result −
a is greater than 20
value of a is : 100
a has a false value
value of a is : 


    46 Lectures 
     4.5 hours 

 Devi Killada

    11 Lectures 
     1.5 hours 

 Harshit Srivastava

    30 Lectures 
     6 hours 

 TELCOMA Global

    24 Lectures 
     2 hours 

 Mohammad Nauman

    68 Lectures 
     7 hours 

 Stone River ELearning

    58 Lectures 
     6.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
DAX Information - ISBLANK function

Checks whether a value is blank, and returns TRUE or FALSE.
ISBLANK (<value>) 

value
The value or expression you want to test.
TRUE or FLASE.
= if (ISBLANK([Athlete]), "Name Missing", [Athlete]) 
This DAX formula returns a column of values – with Athlete name, if present and with the text string Name Missing, otherwise.

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
How to implement custom deserializer using @JsonDeserialize annotation in Java?


The @JsonDeserialize annotation is used to declare custom deserializer while deserializing JSON to Java object. We can implement a  custom deserializer by extending the StdDeserializer class with a generic type Employee and need to override the deserialize() method of StdDeserializer class.
@Target(value={ANNOTATION_TYPE,METHOD,FIELD,TYPE,PARAMETER})
@Retention(value=RUNTIME)
public @interface JsonDeserialize
In the below program, we can implement a custom deserializer using @JsonDeserialize annotation
import java.io.*;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.annotation.*;
import com.fasterxml.jackson.databind.deser.std.*;
public class JsonDeSerializeAnnotationTest {
   public static void main (String[] args) throws JsonProcessingException, IOException {
      Employee emp = new Employee(115, "Adithya");
      ObjectMapper mapper = new ObjectMapper();
      String jsonString = mapper.writeValueAsString(emp);
      emp = mapper.readValue(jsonString, Employee.class);
      System.out.println(emp);
   }
}
// CustomDeserializer class
class CustomDeserializer extends StdDeserializer<Employee> {
   public CustomDeserializer(Class<Employee> t) {
      super(t);
   }
   public CustomDeserializer() {
      this(Employee.class);
   }
   @Override
   public Employee deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException {
      int id = 0;
      String name = null;
      JsonToken currentToken = null;
      while((currentToken = jp.nextValue()) != null) {
         switch(currentToken) {
            case VALUE_NUMBER_INT:
            if(jp.getCurrentName().equals("id")) {
               id = jp.getIntValue();
            }
            break;
            case VALUE_STRING:
            switch(jp.getCurrentName()) {
               case "name":
               name = jp.getText();
               break;
               default:
               break;
            }
            break;
            default:
            break;
         }
      }
      return new Employee(id, name);
   }
}
// Employee class
@JsonDeserialize(using=CustomDeserializer.class)
class Employee {
   private int id;
   private String name;
   public Employee(int id, String name) {
      this.id = id;
      this.name = name;
   }
   public int getId() {
      return id;
   }
   public String getName() {
      return name;
   }
   @Override
   public String toString() {
      StringBuilder sb = new StringBuilder("ID: ").append(this.id).append("\nName: ").append(this.name);
      return sb.toString();
   }
}
ID: 115
Name: Adithya