code-rag-bench/online-tutorials huggingface dataset:
HTML DOM createTextNode() Method

The HTML DOM createTextNode() method is used to create a Text Node with the specified text.
Let us look at an example for the createTextNode() method −
<!DOCTYPE html>
<html>
<body>
<h2>createTextNode() example</h2>
<p>Click the below button to create a p element with some text.</p>
<button onclick="createText()">CREATE</button>
<script>
   function createText() {
      var x = document.createElement("P");
      var p = document.createTextNode("This is a sample paragraph created with
      createTextNode()");
      x.appendChild(p);
      document.body.appendChild(x);
   }
</script>
</body>
</html>
This will produce the following output −
On clicking the CREATE button −
In the above example −
We have created a button CREATE that will execute the createText() function on being clicked by the user −
<button onclick="createText()">CREATE</button>
The createText() method creates the <p> element by using the createElement() method of the document object and assigns it to the variable x. We then create a text node using createTextNode() with some text and assigns it to the variable p.
We then append the text node to the <p> element using the appendChild() method. Finally the <p> element along with the text node are appended to document using the document.body appendChild() method:
function createText() {
   var x = document.createElement("P");
   var p = document.createTextNode("This is a sample paragraph created with createTextNode()");
   x.appendChild(p);
   document.body.appendChild(x);
}
How to remove empty rows from an R data frame?

During the survey or any other medium of data collection, getting all the information from all units is not possible. Sometimes we get partial information and sometimes nothing. Therefore, it is possible that some rows in our data are completely blank and some might have partial data. The blank rows can be removed and the other empty values can be filled with methods that helps to deal with missing information.
Consider the below data frame, it has some missing rows and some missing values −
> x1<-c(rep(c(1,2,3),times=5),"","","",2,1)
> x2<-rep(c(2,4,"",4,""),each=4)
> x3<-rep(c(5,4,2,""),times=c(2,5,3,10))
> df<-data.frame(x1,x2,x3)
> df
x1 x2 x3
1 1 2 5
2 2 2 5
3 3 2 4
4 1 2 4
5 2 4 4
6 3 4 4
7 1 4 4
8 2 4 2
9 3 2
10 1 2
11 2
12 3
13 1 4
14 2 4
15 3 4
16 4
17
18
19 2
20 1
Here, we can see that the rows 17 and 18 are complete blank that means we do not have any data in them. Hence, we can remove them from the data frame as shown below −
> df[!apply(df == "", 1, all),]
x1 x2 x3
1 1 2 5
2 2 2 5
3 3 2 4
4 1 2 4
5 2 4 4
6 3 4 4
7 1 4 4
8 2 4 2
9 3 2
10 1 2
11 2
12 3
13 1 4
14 2 4
15 3 4
16 4
19 2
20 1
How to get hidden files and folders using PowerShell?

To get hidden files and folders using PowerShell, we need to use the Get-ChildItem command with the - Hidden or -Force parameter.
The difference between the two mentioned parameters is Hidden parameter only retrieves the hidden files and folders while the Force parameter retrieves all the files and folders including Hidden, read-only and normal files and folder.
For example, We have one folder named Data inside folder C:\temp and we need to retrieve it.
PS C:\> Get-ChildItem C:\Temp\ -Hidden
Directory: C:\Temp
Mode        LastWriteTime      Length Name
----        -------------     ------ ----
d--h-       9/28/2020 7:57 AM        Data
You can check the mode of the above folder in the output where ‘d’ indicates the directory and the ‘h’ attribute indicates the Hidden.
If we use the Force parameter, PowerShell will retrieve all attributed files and folders.
PS C:\> Get-ChildItem C:\Temp\ -Force
Directory: C:\Temp
Mode     LastWriteTime      Length     Name
----     -------------      ------     ----
d--h-    9/28/2020          7:57  AM   Data
d----    8/11/2020          10:58 AM   Help Files
d----    7/29/2020          6:01  PM   iisadministration
You can also use cmd command Dir to retrieve hidden files and folder with switch -h.
PS C:\> dir -h
Directory: C:\
Mode         LastWriteTime      Length      Name
----         -------------      ------      ----
d--hs        6/4/2020           2:28 PM     $Recycle.Bin
d--hs        9/27/2020         10:07 PM     Config.Msi
d--hs        6/3/2020           1:00 AM     IntelOptaneData
d--h-        6/5/2020          12:18 PM     OneDriveTemp
d--h-        9/25/2020          8:02 AM     ProgramData
d--hs        6/2/2020          12:32 PM     Recovery
-a-hs        9/28/2020          7:54 AM     6768705536 hiberfil.sys
-a-hs        9/16/2020          7:47 AM     12348030976 pagefile.sys
-a-hs        9/18/2020          7:06 PM     285212672 swapfile.sys
The above example retrieves all files and folder which has a hidden attribute.
To check the same settings on the remote computer, use the Invoke-Command method. For example,
Invoke-Command -ComputerName Test1-Win2k16 -ScriptBlock{Get-ChildItem c:\ - Hidden}
Mode    LastWriteTime   Length      Name            PSComputerName
----    -------------   ------      ----            --------------
d--hs-  7/29/2020      10:21 PM     $Recycle.Bin    Test1-Win2k16
d--hsl  7/21/2020       4:36 PM     Documents and   Settings Test1-Win2k16
d--h--  9/20/2020       3:24 AM     ProgramData     Test1-Win2k16
d--hs-  7/21/2020       4:36 PM     Recovery       Test1 -Win2k16
d--hs-  7/27/2020       6:31 AM     System Volume  Information Test1-Win2k16
-arhs-  7/16/2016       6:18 AM     384322 bootmgr Test1-Win2k16
-a-hs-  7/16/2016       6:18 AM     1 BOOTNXT      Test1-Win2k16
-a-hs-  9/28/2020      10:44 PM     1006632960     pagefile.sys Test1-Win2k16
You can see the hidden files and folders on the remote computer.
Cordova - Splash Screen

This plugin is used to display a splash screen on application launch.
Splash screen plugin can be installed in command prompt window by running the following code.
C:\Users\username\Desktop\CordovaProject>cordova plugin add cordova-plugin-splashscreen

Adding splash screen is different from adding the other Cordova plugins. We need to open config.xml and add the following code snippets inside the widget element.
First snippet is SplashScreen. It has value property which is the name of the images in platform/android/res/drawable- folders. Cordova offers default screen.png images that we are using in this example, but you will probably want to add your own images. Important thing is to add images for portrait and landscape view and also to cover different screen sizes.
<preference name = "SplashScreen" value = "screen" />
Second snippet we need to add is SplashScreenDelay. We are setting value to 3000 to hide the splash screen after three seconds.
<preference name = "SplashScreenDelay" value = "3000" />
The last preference is optional. If value is set to true, the image will not be stretched to fit screen. If it is set to false, it will be stretched.
<preference name = "SplashMaintainAspectRatio" value = "true" />
Now when we run the app, we will see the splash screen.

    45 Lectures 
     2 hours 

 Skillbakerystudios

    16 Lectures 
     1 hours 

 Nilay Mehta
 Print
 Add Notes
 Bookmark this page
Tkinter scrollbar for frame

Let’s suppose you want to organize a set of widgets inside an application window, then you can use Frames. Tkinter Frames are generally used to organize and group many widgets. For a particular application, we can also add a scrollbar in the frames. In order to add a scrollbar, we generally use to the Scrollbar(...options) function.
#Import the required library
from tkinter import *
#Create an instance of tkinter frame or window
win = Tk()
#Define the geometry
win.geometry("750x400")
#Create a Frame
frame= Frame(win)
def close():
   win.destroy()
#Create a Label widget in the frame
text= Label(frame, text= "Register", font= ('Helvetica bold', 14))
text.pack(pady=20)
#ADDING A SCROLLBAR
myscrollbar=Scrollbar(frame,orient="vertical")
myscrollbar.pack(side="right",fill="y")
#Add Entry Widgets
Label(frame, text= "Username").pack()
username= Entry(frame, width= 20)
username.pack()
Label(frame, text= "password").pack()
password= Entry(frame, show="*", width= 15)
password.pack()
Label(frame, text= "Email Id").pack()
email= Entry(frame, width= 15)
email.pack()
#Create widget in the frame
button= Button(frame, text= "Close",font= ('Helvetica bold',14),
command= close)
button.pack(pady=20)
frame.pack()
win.mainloop()
Running the above code will display a window with a frame containing Entry widgets. All the widgets in the frame are aligned vertically with a scrollbar.
How can I manually set proxy settings in Python Selenium?

We can manually set proxy settings using Selenium webdriver in Python. It is done using the DesiredCapabilities class. We would create an object of this class and apply the add_to_capabilities method to it. Then pass the proxy capabilities as a parameter to this method.
Code Implementation
from selenium import webdriver
from selenium.webdriver.common.proxy import ProxoxyType

#add proxy’s ip and port
p = '<proxy ip, port>'
pxy = Proxy()

#set proxy type
pxy.p_type = ProxyType.MANUAL

#http proxy
pxy.http_pxy = p

#ssl proxy
pxy.ssl_pxy = p

#object of DesiredCapabilities
c = webdriver.DesiredCapabilities.CHROME

#set proxy browser capabilties
pxy.add_to_capabilities(c)

#set chromedriver.exe path
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe", desired_capabilities = c)

#launch URL
driver.get("https://www.tutorialspoint.com/index.htm")

#quit browser
driver.quit()
How to set global event_scheduler=ON even if MySQL is restarted?

There is a single way by which you can set a global event_scheduler=ON even if MySQL is restarted. You need to set global system variable ON and need to use this system variable even if MySQL restart.
For this, I am using system variable @@event_scheduler using select statement. The query is as follows:
mysql> select @@event_scheduler;
The following is the output:
+-------------------+
| @@event_scheduler |
+-------------------+
| ON                |
+-------------------+
1 row in set (0.00 sec)
Now, restart MySQL. The query is as follows:
mysql> restart;
Query OK, 0 rows affected (0.00 sec)
After restarting the server the connection is lost for some time. If you use any query you will get the following error message:
mysql> select @@event_scheduler;
ERROR 2013 (HY000): Lost connection to MySQL server during query
After some time if you will use the system variable @@event_scheduler again using select statement, then the output you will get the same i.e. ON. The query is as follows:
mysql> select @@event_scheduler;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 8
Current database: *** NONE ***
+-------------------+
| @@event_scheduler |
+-------------------+
| ON                |
+-------------------+
1 row in set (0.04 sec)
Or you can set the event_scheduler ON in my.cnf file or my.ini file. The statement is as follows:
[mysqld]
event_scheduler = ON;
Now your event_scheduler is ON. Whether your server restarts or not, it will always be ON.
list-unstyled class in Bootstrap

For unstyled list in Bootstrap, use the list-unstyled class.
You can try to run the following code to implement the list-unstyled class −
 Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap lists</title>
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://stackpath.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://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
   </head>
   <body>
      <h1>Lists</h1>
      <h2>Definition List</h2>
      <h4>Unstyled List</h4>
      <ul class = "list-unstyled">
         <li>Item 1</li>
         <li>Item 2</li>
         <li>Item 3</li>
         <li>Item 4</li>
      </ul>
      <h2>Vegetables (UnOrdered List)</h2>
      <ul>
         <li>Tomato</li>
         <li>Brinjal</li>
         <li>Broccoli</li>
      </ul>
   </body>
</html>
Tcl - Ternary Operator

Try the following example to understand ternary operator available in Tcl language −
#!/usr/bin/tclsh

set a 10;
set b [expr $a == 1 ? 20: 30]
puts "Value of b is $b\n"
set b [expr $a == 10 ? 20: 30]
puts "Value of b is $b\n" 
When you compile and execute the above program it produces the following result −
Value of b is 30

Value of b is 20

 Print
 Add Notes
 Bookmark this page
Statistical - COVARIANCE.P Function

The COVARIANCE.P function returns population covariance, the average of the products of deviations for each data point pair in two data sets. Use covariance to determine the relationship between two data sets.
COVARIANCE.P (array1, array2)

Covariance is given by −
$$Cov\left ( X,Y \right )=\frac{\sum \left ( x-\bar{x} \right )\left ( y-\bar{y} \right )}{n}$$
Where n is the sample size and $\bar{x}$ and $\bar{y}$ are the sample means AVERAGE (array1) and AVERAGE (array2).

Covariance is given by −
$$Cov\left ( X,Y \right )=\frac{\sum \left ( x-\bar{x} \right )\left ( y-\bar{y} \right )}{n}$$
Where n is the sample size and $\bar{x}$ and $\bar{y}$ are the sample means AVERAGE (array1) and AVERAGE (array2).
The arguments must either be numbers or be names, arrays, or references that contain numbers.
The arguments must either be numbers or be names, arrays, or references that contain numbers.
If an array or reference argument contains text, logical values, or empty cells, those values are ignored. However, cells with the value zero are included.
If an array or reference argument contains text, logical values, or empty cells, those values are ignored. However, cells with the value zero are included.
If array1 and array2 have different numbers of data points, COVARIANCE.P returns the #N/A error value.
If array1 and array2 have different numbers of data points, COVARIANCE.P returns the #N/A error value.
If either array1 or array2 is empty, COVARIANCE.P returns the #DIV/0! error value.
If either array1 or array2 is empty, COVARIANCE.P returns the #DIV/0! error value.
Excel 2010, Excel 2013, Excel 2016

    296 Lectures 
     146 hours 

 Arun Motoori

    56 Lectures 
     5.5 hours 

 Pavan Lalwani

    120 Lectures 
     6.5 hours 

 Inf Sid

    134 Lectures 
     8.5 hours 

 Yoda Learning

    46 Lectures 
     7.5 hours 

 William Fiset

    25 Lectures 
     1.5 hours 

 Sasha Miller
 Print
 Add Notes
 Bookmark this page
SQL Query to Print the Name and Salary of the Person Having Least Salary in the Department - GeeksforGeeks

29 Dec, 2021
In SQL, we need to find out the department wise information from the given table containing information about employees. One such data is the minimum salary of the employees of each department. We shall use the GROUP BY clause to achieve this. This is illustrated below. For this article, we will be using the Microsoft SQL Server as our database.
Step 1: Create a Database. For this use the below command to create a database named GeeksForGeeks.
Query:
CREATE DATABASE GeeksForGeeks
Output:
Step 2: Use the GeeksForGeeks database. For this use the below command.
Query:
USE GeeksForGeeks
Output:
Step 3: Create a table COMPANY inside the database GeeksForGeeks. This table has 4 columns namely EMPLOYEE_ID, EMPLOYEE_NAME, DEPARTMENT_NAME and SALARY containing the id, name, department and the salary of various employees.
Query:
CREATE TABLE COMPANY(
EMPLOYEE_ID INT PRIMARY KEY,
EMPLOYEE_NAME VARCHAR(10),
DEPARTMENT_NAME VARCHAR(10),
SALARY INT);
Output:
Step 4: Describe the structure of the table COMPANY.
Query:
EXEC SP_COLUMNS COMPANY;
Output:
Step 5: Insert 5 rows into the COMPANY table.
Query:
INSERT INTO COMPANY VALUES(1,'RAM','HR',10000);
INSERT INTO COMPANY VALUES(2,'AMRIT','MRKT',20000);
INSERT INTO COMPANY VALUES(3,'RAVI','HR',30000);
INSERT INTO COMPANY VALUES(4,'NITIN','MRKT',40000);
INSERT INTO COMPANY VALUES(5,'VARUN','IT',50000);
Output:
Step 6: Display all the rows of the COMPANY table.
Query:
SELECT * FROM COMPANY;
Output:
Step 7: Display the minimum salary obtained by the employees in each department along with their employee name and department. We will use the IN clause here to compare the salaries obtained from the outer query to minimum salaries obtained from the inner query. The inner query uses the GROUP BY clause to return only 1 salary from each department i.e. the least one. MIN aggregate function is used to find the least salary in a department.
Syntax:
SELECT INFORMATION FROM TABLE_NAME WHERE
COLUMN_1 IN (SELECT AGGREGATE_FUNCTION
(COLUMN_1) FROM TABLE_NAME GROUP BY COLUMN_2);
Query:
SELECT EMPLOYEE_NAME,DEPARTMENT_NAME,
SALARY FROM COMPANY WHERE
SALARY IN (SELECT MIN(SALARY) FROM
COMPANY GROUP BY DEPARTMENT_NAME);
Output:
Picked
SQL-Query
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
SQL | DROP, TRUNCATE
How to Select Data Between Two Dates and Times in SQL Server?
SQL vs NoSQL: Which one is better to use?
Advanced SQL Interview Questions
SQL | OFFSET-FETCH Clause
Insert multiple values into multiple tables using a single statement in SQL Server
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Comments
SQL | CREATE
Adding multiple constraints in a single table
Laravel - Authorization

In the previous chapter, we have studied about authentication process in Laravel. This chapter explains you the authorization process in Laravel.
Before proceeding further into learning about the authorization process in Laravel, let us understand the difference between authentication and authorization.
In authentication, the system or the web application identifies its users through the credentials they provide. If it finds that the credentials are valid, they are authenticated, or else they are not.
In authorization, the system or the web application checks if the authenticated users can access the resources that they are trying to access or make a request for. In other words, it checks their rights and permissions over the requested resources. If it finds that they can access the resources, it means that they are authorized.
Thus, authentication involves checking the validity of the user credentials, and authorization involves checking the rights and permissions over the resources that an authenticated user has.
Laravel provides a simple mechanism for authorization that contains two primary ways, namely Gates and Policies.
Gates are used to determine if a user is authorized to perform a specified action. They are typically defined in App/Providers/AuthServiceProvider.php using Gate facade. Gates are also functions which are declared for performing authorization mechanism.
Policies are declared within an array and are used within classes and methods which use authorization mechanism.
The following lines of code explain you how to use Gates and Policies for authorizing a user in a Laravel web application. Note that in this example, the boot function is used for authorizing the users.
<?php

namespace App\Providers;

use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;

class AuthServiceProvider extends ServiceProvider{
   /**
      * The policy mappings for the application.
      *
      * @var array
   */
   
   protected $policies = [
      'App\Model' => 'App\Policies\ModelPolicy',
   ];
   
   /**
      * Register any application authentication / authorization services.
      *
      * @param \Illuminate\Contracts\Auth\Access\Gate $gate
      * @return void
   */
   
   public function boot(GateContract $gate) {
      $this->registerPolicies($gate);
      //
   }
}

    13 Lectures 
     3 hours 

 Sebastian Sulinski

    35 Lectures 
     3.5 hours 

 Antonio Papa

    7 Lectures 
     1.5 hours 

 Sebastian Sulinski

    42 Lectures 
     1 hours 

 Skillbakerystudios

    165 Lectures 
     13 hours 

 Paul Carlo Tordecilla

    116 Lectures 
     13 hours 

 Hafizullah Masoudi
 Print
 Add Notes
 Bookmark this page
How to match a whitespace in python using Regular Expression?

The following code matches whitespaces in the given string.
import re
result = re.search(r'[\s]', 'The Indian Express')
print result
<_sre.SRE_Match object at 0x0000000005106648>
The following code finds all whitespaces in the given string and prints them
import re
result = re.findall(r'[\s]', 'The Indian Express')
print result
[' ', ' ']
C++ Program to Perform Edge Coloring of a Graph

In this program, we will perform Edge Coloring of a Graph in which we have to
color the edges of the graph that no two adjacent edges have the same color.
Steps in Example.
Begin
   Take the input of the number of vertices, n, and then number of edges, e, in the graph.
   The graph is stored as adjacency list.
   BFS is implemented using queue and colors are assigned to each edge.
End
#include<bits/stdc++.h>
using namespace std;
int n, e, i, j;
vector<vector<pair<int, int> > > g;
vector<int> color;
bool v[111001];
void col(int n) {
   queue<int> q;
   int c = 0;
   set<int> vertex_colored;
   if(v[n])
      return;
      v[n] = 1;
   for(i = 0;i<g[n].size();i++) {
      if(color[g[n][i].second]!=-1) {
         vertex_colored.insert(color[g[n][i].second]);
      }
   }
   for(i = 0;i<g[n].size();i++) {
      if(!v[g[n][i].first]) {
         q.push(g[n][i].first);
      }
      if(color[g[n][i].second]==-1) {
         while(vertex_colored.find(c)!=vertex_colored.end())
            c++;
            color[g[n][i].second] = c;
            vertex_colored.insert(c);
            c++;
      }
   }
   while(!q.empty()) {
      int temp = q.front();
      q.pop();
      col(temp);
   }
   return;
}
int main() {
   int u,w;
   set<int> empty;
   cout<<"Enter number of vertices and edges respectively:";
   cin>>n>>e;
   cout<<"\n";
   g.resize(n); //number of vertices
   color.resize(e,-1); //number of edges
   memset(v,0,sizeof(v));
   for(i = 0;i<e;i++) {
      cout<<"\nEnter edge vertices of edge "<<i+1<<" :"<<"\n";
      cin>>u>>w;
      u--; w--;
      g[u].push_back(make_pair(w,i));
      g[w].push_back(make_pair(u,i));
   }
   col(0);
   for(i = 0;i<e;i++) {
      cout<<"Edge "<<i+1<<" is coloured with colour "<<color[i]+1
      << "\n";
   }
}
Enter number of vertices and edges respectively:4 5
Enter edge vertices of edge 1 :1 2
Enter edge vertices of edge 2 :2 3
Enter edge vertices of edge 3 :1 1
Enter edge vertices of edge 4 :3 4
Enter edge vertices of edge 5 :1 4
Edge 1 is coloured with colour 1
Edge 2 is coloured with colour 2
Edge 3 is coloured with colour 2
Edge 4 is coloured with colour 1
Edge 5 is coloured with colour 3
How to retrieve the Azure VM deallocated date using PowerShell?

To get the Azure VM deallocated date using PowerShell we can use the below command.
PS C:\> Get-AzVM -VMName Win2k16VM1 -ResourceGroupName TestVMRG -Status
Here it will retrieve the PowerState of the VM.
To retrieve the date when the VM was deallocated, we need to filter out the result.
PS C:\> $vm = Get-AzVM -VMName Win2k16VM1 -ResourceGroupName TestVMRG -
Status

PS C:\> $vm.Statuses[0].Time
Saturday, June 19, 2021 12:49:16 PM
How to use week input type in HTML?

The week input type is used in HTML using the <input type="week">. Using this, allow users to select a week and year.
A date picker popup is visible whenever you will give a user input to the week input type.
Note − The input type week is not supported in Firefox and Internet Explorer. It works on Google Chrome.
You can try to run the following code to learn how to use week input type in HTML. It will show both week and year.
<!DOCTYPE html>
<html>
   <head>
      <title>HTML input week</title>
   </head>

   <body>
      <form action = "" method = "get">
         Details:<br><br>
         Student Name<br><input type = "name" name = "sname"><br>
         Training week<br><input type = "week" name = "week"><br>
         <input type = "submit" value = "Submit">
      </form>
   </body>
   
</html>
fgetcsv() function in PHP

The fgetcsv() function parses a line from an open file to check for CSV fields. It returns an array containing the fields read.
fgetcsv(file_pointer, length, delimiter, enclosure, escape)
file_pointer − A valid file pointer to a file successfully opened by fopen(), popen(), or fsockopen().
file_pointer − A valid file pointer to a file successfully opened by fopen(), popen(), or fsockopen().
length − Maximum length of a line.
length − Maximum length of a line.
delimiter − Character that specifies the field separator. Default is comma ( , )
delimiter − Character that specifies the field separator. Default is comma ( , )
enclosure − Set the field enclosure character. Defaults as a double quotation mark.
enclosure − Set the field enclosure character. Defaults as a double quotation mark.
escape − Set the escape character. Defaults as a backslash (\).
escape − Set the escape character. Defaults as a backslash (\).
The fgetcsv() function returns an array containing the fields read.
Let’s say we have the following “products.csv” CSV file.
laptop, keyboard, mouse
The following is an example that displays the content of CSV, that includes the products.
<?php
   $file_pointer = fopen("products.csv","r");
   print_r(fgetcsv($file_pointer));
   fclose($file_pointer);
?>
Array
(
   [0] => Laptop
   [1] => Keyboard
   [2] => Mouse
)
Let us see another example.
We have the following “tutorials.csv” CSV file.
Java, C#, HTML5, CSS3, Bootstrap, Android
The following is an example that displays the content of CSV “tutorials.csv”.
<?php
   $file_pointer = fopen("tutorials.csv","r");
   while(! feof($file_pointer)) {
      print_r(fgetcsv($file_pointer));
   }
   fclose($file_pointer);
?>
The following is the output: Java, C#, HTML5, CSS3, Bootstrap, Android
Array
(
   [0] => Java
   [1] => C#
   [2] => HTML5
   [3] => CSS3
   [4] => Bootstrap
   [5] => Android
)
Delete Tuple Elements in Python

Removing individual tuple elements is not possible. There is, of course, nothing wrong with putting together another tuple with the undesired elements discarded.
To explicitly remove an entire tuple, just use the del statement.
 Live Demo
#!/usr/bin/python
tup = ('physics', 'chemistry', 1997, 2000);
print tup;
del tup;
print "After deleting tup : ";
print tup;
This produces the following result. Note an exception raised, this is because after del tup tuple does not exist any more −
('physics', 'chemistry', 1997, 2000)
After deleting tup :
Traceback (most recent call last):
File "test.py", line 9, in <module>
print tup;
NameError: name 'tup' is not defined
How to use express router

In earlier examples, we wrote all routing code in a single file App.js. But in real world scenarios, we have to split the code into multiple files.
We can create separate files and import them but express gives a router mechanism which is easy to use.
Create a separate file called route.js (name can be anything)
Create router using express −
const express = require('express');
const router = express.Router();
exporting router −
module.exports = router;
Adding routing functions −
router.get('/add-username', (req, res,next)=>{
   res.send('<form action="/post-username" method="POST"> <input type="text" name="username"> <button    type="submit"> Send </button> </form>');
});
 router.post('/post-username', (req, res, next)=>{
   console.log('data: ', req.body.username);
   res.redirect('/');
});
Similar to functions we used in App.js for creating paths , we used router .
Import the router in App.js file −
const route = require('./routes');
add a middleware for using router in App.js file.
app.use(route);
with these changes the complete App.js file is −
const http = require('http');
const express = require('express');
const bodyParser = require('body-parser');
const route = require('./routes');
const app = express();
app.use(bodyParser.urlencoded({extended: false}));
app.use(route); app.use('/', (req, res,next)=>{
   res.send('<h1> first midleware: Hello Tutorials Point </h1>');
});
const server = http.createServer(app);
server.listen(3000);
route.js
const express = require('express');
const router = express.Router();
router.get('/add-username', (req, res,next)=>{
   res.send('<form action="/post-username" method="POST"> <input type="text" name="username"> <button    type="submit"> Send </button> </form>');
});
router.post('/post-username', (req, res, next)=>{
   console.log('data: ', req.body.username);
   res.redirect('/');
});
module.exports = router;
The router middleware should be placed before any url handling if present in App.js. Because code execution works from top to bottom in App.js file.
If any additional routers required , we can create separate files similar to routes.js and import it in App.js with another middleware in order for using that router.
Creating a Browse Button with Tkinter

In order to create buttons in a Tkinter application, we can use the Button widget. Buttons can be used to process the execution of an event in the runtime of an application. We can create a button by defining the Button(parent, text, **options) constructor.
Let us suppose we want to create a Browse Button which when clicked, will ask the user to select a file from the system explorer. To create a dialog box for selecting a file, we can use filedialog package in tkinter library. We can import the filedialog in the notebook using the following command,
from tkinter import filedialog
Once the package is imported in the program, we can use it to create a dialog box for opening and selecting all the Python files and it will return the number of characters present in that particular file.
# Import the required Libraries
from tkinter import *
from tkinter import ttk, filedialog
from tkinter.filedialog import askopenfile

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

# Set the geometry of tkinter frame
win.geometry("700x350")

def open_file():
   file = filedialog.askopenfile(mode='r', filetypes=[('Python Files', '*.py')])
   if file:
      content = file.read()
      file.close()
      print("%d characters in this file" % len(content))

# Add a Label widget
label = Label(win, text="Click the Button to browse the Files", font=('Georgia 13'))
label.pack(pady=10)

# Create a Button
ttk.Button(win, text="Browse", command=open_file).pack(pady=20)

win.mainloop()
Now, run the above code to browse and select the files from the system explorer.
How to use min and max attributes in HTML?

The min and max attributes in HTML are used to set the minimum and maximum value of an element. The min and max attribute can be used on the following elements:
You can try to run the following code to learn how to use the min and max attribute in HTML.
<!DOCTYPE html>
<html>
   <head>
      <title>HTML min and max attribute</title>
   </head>
   <body>
      <form action = "" method = "get">
         Mention any number between 1 to 20
         <input type = "number" name="num" min = "1" max = "20"><br>
         <input type = "submit" value = "Submit">
      </form>
   </body>
</html>
Usage of Bootstrap navbar-fixed-bottom class

To fix navbar to the bottom, use the navbar-fixed-bottom class.
You can try to run the following code to implement navbar-fixed-bottom class −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <nav class = "navbar navbar-default navbar-fixed-bottom" role = "navigation" style="background: orange;">
         <div class = "navbar-header">
            <a class = "navbar-brand" href = "#">Java Topics</a>
         </div>
         <div>
            <ul class = "nav navbar-nav">
               <li class = "active"><a href = "#">Basics</a></li>
               <li><a href = "#">Interface</a></li>
               <li><a href = "#">Polymorphism</a></li>
               <li><a href = "#">Encapsulation</a></li>
            </ul>
         </div>
      </nav>
   </body>
</html>
IDE | GeeksforGeeks | A computer science portal for geeks

Please enter your email address or userHandle.
12345678910111213141516171819202122232425262728293031323334// A C/C++ Program to generate OTP (One Time Password)#include<bits/stdc++.h>using namespace std;// A Function to generate a unique OTP everytimestring generateOTP(int len){    // All possible characters of my OTP    string str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";    int n = str.length();        // String to hold my OTP    string OTP;        for (int i=1; i<=len; i++)        OTP.push_back(str[rand() % n]);        return(OTP);}// Driver Program to test above functionsint main(){    // For different values each time we run the code    srand(time(NULL));         // Delare the length of OTP    int len = 6;    printf("Your OTP is - %s", generateOTP(len).c_str());        return(0);}ההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
https://ide.geeksforgeeks.org/Ks84Ck
Your OTP is - 8qOtzy
Is there any way to embed a PDF file into an HTML5 page?

To embed a PDF file in an HTML5 page, use the <iframe> element.
<!DOCTYPE html>
<html>
   <head>
      <title>HTML iframe Tag</title>
   </head>
   <body>
      <h1>HTML5 Tutorial</h1>
      <iframe src = " https://www.tutorialspoint.com/html5/html5_tutorial.pdf" style="width:500px; height:300px;"></iframe>
   </body>
</html>
Print longest palindrome word in a sentence in C Program

Given a sentence and the challenge is to find the longest palindrome from the given sentence
Palindrome is a word or sequence whose meaning remains same even after reversing the string
Example − Nitin, after reversing the string its meaning remains the same.
Challenge is to find the longest palindrome from the given sentence.
Like sentence is: malayalam liemadameil iji
It contains three palindrome words but the longest is − liemadameil
START
STEP 1 -> Declare start variables I, j, k, l, max to 0, index to -1, check to 0, count to 0
Step 2 -> Loop For i to 0 and i<strlen(str) and i++
   Set max =0, k =i and j=i+1
   Loop While str[j]!=' ' and str[j]!='\0'
      Increment j by 1
   End While
   Set l=j-1
   IF str[k]!=' ' and str[k]!='\0'
      Loop While k<=1
      If str[k]==str[l]
         Increment max by 1
         If count<=max
            Set index=i and count = max
         End If
      End IF
      Else
         Set max = 0, count = -1
         Break
      End Else
      Increment k and I by 1
   End Loop While
End If
Set i=j
Step 3 -> End Loop For
Step 4 -> Loop For i = index and i!=-1 && str[i]!=' ' && str[i]!='\0' and i++
   Print str[i]
Step 5 -> End Loop For
STOP
#include <stdio.h>
#include <string.h>
int main(int argc, char const *argv[]) {
   char str[] = {"malayalam liemadameil iji"};
   int i, k, l, j, max =0, index = -1, check = 0, count = 0;
   for(i=0; i<strlen(str); i++) {
      max = 0;
      k = i;
      j = i+1;
      while(str[j]!=' ' && str[j]!='\0'){
         j++;
      }
      l = j-1;
      if(str[k]!=' ' && str[k]!='\0') {
         while(k<=l) {
            if (str[k]==str[l]) {
               max++;
               if(count<=max) {
                  index = i;
                  count = max;
               }
            } else {
               max = 0;
               count = -1;
               break;
            }
            k++;
            l--;
         }
      }
      i = j;
   }
   for (i = index; i!=-1 && str[i]!=' ' && str[i]!='\0'; i++) {
      printf("%c", str[i]);
   }
   return 0;
}
If we run above program then it will generate following output.
liemadameil
How to set justification on Tkinter Text box?

The Text widget supports multiline user input from the user. We can configure the Text widget properties such as its font properties, text color, background, etc., by using the configure() method.
To set the justification of our text inside the Text widget, we can use tag_add() and tag_configure() properties. We will specify the value of "justify" as CENTER.
# Import the required libraries
from tkinter import *

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

# Set the size of the tkinter window
win.geometry("700x350")

# Create a text widget
text=Text(win, width=40, height=10)

# justify the text alignment to the center
text.tag_configure("center", justify='center')
text.insert(INSERT, "Welcome to Tutorialspoint...")

# Add the tag from start to end text
text.tag_add("center", 1.0, "end")
text.pack()

win.mainloop()
If you run the above code, you will observe that the cursor of the text window will have justification set to its center.
How to format currencies in JSP?

The <fmt:formatNumber> tag is used to format numbers, percentages, and currencies.
The <fmt:formatNumber> tag has the following attributes −
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix = "fmt" uri = "http://java.sun.com/jsp/jstl/fmt" %>
<html>
   <head>
      <title>JSTL fmt:formatNumber Tag</title>
   </head>
   <body>
      <h3>Number Format:</h3>
      <c:set var = "balance" value = "120000.2309" />
      <p>Currency in USA :
         <fmt:setLocale value = "en_US"/>
         <fmt:formatNumber value = "${balance}" type = "currency"/>
      </p>
   </body>
</html>
The above code will generate the following result −
Number Format:
Currency in USA : $120,000.23
Python List VS Array VS Tuple

09 Feb, 2021
List: A list is of an ordered collection data type that is mutable which means it can be easily modified and we can change its data values and a list can be indexed, sliced, and changed and each element can be accessed using its index value in the list. The following are the main characteristics of a List:
The list is an ordered collection of data types.
The list is mutable.
List are dynamic and can contain objects of different data types.
List elements can be accessed by index number.
Example: 
Python
# Python program to demonstrate List list = ["mango", "strawberry", "orange",        "apple", "banana"]print(list) # we can specify the range of the# index by specifying where to start# and where to endprint(list[2:4]) # we can also change the item in the# list by using its index numberlist[1] = "grapes"print(list[1])
Output :
['mango', 'strawberry', 'orange', 'apple', 'banana']
['orange', 'apple']
grapes
Array:  An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together. This makes it easier to calculate the position of each element by simply adding an offset to a base value, i.e., the memory location of the first element of the array (generally denoted by the name of the array). The following are the main characteristics of an Array:
An array is an ordered collection of the similar data types.
An array is mutable.
An array can be accessed by using its index number.
Examples: 
Python
# Python program to demonstrate # Creation of Array    # importing "array" for array creationsimport array as arr   # creating an array with integer typea = arr.array('i', [1, 2, 3])   # printing original arrayprint ("The new created array is : ", end =" ")for i in range (0, 3):    print (a[i], end =" ")print()   # creating an array with float typeb = arr.array('d', [2.5, 3.2, 3.3])   # printing original arrayprint ("The new created array is : ", end =" ")for i in range (0, 3):    print (b[i], end =" ")
Output:
 
The new created array is :  1 2 3 
The new created array is :  2.5 3.2 3.3
Tuple:  A tuple is an ordered and an immutable data type which means we cannot change its values and tuples are written in round brackets. We can access tuple by referring to the index number inside the square brackets.  The following are the main characteristics of a Tuple:
Tuples are immutable and can store any type of data type.
it is defined using ().
it cannot be changed or replaced as it is an immutable data type.
Examples: 
Python
tuple = ("orange","apple","banana")print(tuple) # we can access the items in# the tuple by its index numberprint(tuple[2]) #we can specify the range of the# index by specifying where to start# and where to endprint(tuple[0:2])
Output :
('orange', 'apple', 'banana')
banana
('orange', 'apple')
List
Array
Tuple
jinojossy93
Python-array
python-list
python-tuple
Difference Between
Python
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Prolog - Hello World

In the previous section, we have seen how to install GNU Prolog. Now, we will see how to write a simple Hello World program in our Prolog environment.
After running the GNU prolog, we can write hello world program directly from the console. To do so, we have to write the command as follows −
write('Hello World').

Note − After each line, you have to use one period (.) symbol to show that the line has ended.
The corresponding output will be as shown below −
Now let us see how to run the Prolog script file (extension is *.pl) into the Prolog console.
Before running *.pl file, we must store the file into the directory where the GNU prolog console is pointing, otherwise just change the directory by the following steps −
Step 1 − From the prolog console, go to File > Change Dir, then click on that menu.
Step 2 − Select the proper folder and press OK.
Now we can see in the prolog console, it shows that we have successfully changed the directory.
Step 3 − Now create one file (extension is *.pl) and write the code as follows −
main :- write('This is sample Prolog program'),
write(' This program is written into hello_world.pl file').

Now let’s run the code. To run it, we have to write the file name as follows −
[hello_world]

The output is as follows −
Tag Object – Python Beautifulsoup

05 Sep, 2020
Tag object is provided by Beautiful Soup which is a web scraping framework for Python. Web scraping is the process of extracting data from the website using automated tools to make the process faster. Tag object corresponds to an XML or HTML tag in the original document. Further, this object is usually used to extract a tag from the whole HTML document. Further, Beautiful Soup is not an HTTP client which means to scrap online websites you first have to download them using requests module and then serve it to Beautiful Soup for scraping. Additionally, this object returns the first found tag if your document have multiple tags with the same name.
Prerequisite: Beautiful Soup Installation
Syntax:
Object.tag_name
Parameters: This function doesn’t accept any parameter.
Below given examples explain the concept of Tag object in Beautiful Soup.Example 1: In this example we are going to extract h1 tag element only.
# Import Beautiful Soupfrom bs4 import BeautifulSoup  # Initialize the object with an HTML pagesoup = BeautifulSoup('''    <html>        <h1>a web page</h1>    </html>    ''', "lxml")  # Get the tagtag = soup.h1  # Print the outputprint(tag)
Output:
<h1>a web page</h1>
Example 2: In this example we are going to see the type of strong tag element only.
# Import Beautiful Soupfrom bs4 import BeautifulSoup  # Initialize the object with an HTML pagesoup = BeautifulSoup('''    <html>        <strong>a web page</strong>    </html>    ''', "lxml")  # Get the tagtag = soup.strong  # Print the outputprint(type(tag))
Output:
<class 'bs4.element.Tag'>
Example 3: In this example we are going to see the output from a HTML with multiple tags.
# Import Beautiful Soupfrom bs4 import BeautifulSoup  # Initialize the object with a HTML pagesoup = BeautifulSoup('''    <html>        <strong>the first strong tag</strong>        <h1> Heading </h1>        <strong>the second strong tag</strong>    </html>    ''', "lxml")  # Get the tagtag = soup.strong  # Print the outputprint(tag)
Output:
<strong>the first strong tag</strong>
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
Python Number randrange() Method

Python number method randrange() returns a randomly selected element from range(start, stop, step).
Following is the syntax for randrange() method −
randrange ([start,] stop [,step])

Note − This function is not accessible directly, so we need to import random module and then we need to call this function using random static object.
start − Start point of the range. This would be included in the range.
start − Start point of the range. This would be included in the range.
stop − Stop point of the range. This would be excluded from the range.
stop − Stop point of the range. This would be excluded from the range.
step − Steps to be added in a number to decide a random number.
step − Steps to be added in a number to decide a random number.
This method returns a random item from the given range
The following example shows the usage of randrange() method.
#!/usr/bin/python
import random

# Select an even number in 100 <= number < 1000
print "randrange(100, 1000, 2) : ", random.randrange(100, 1000, 2)

# Select another number in 100 <= number < 1000
print "randrange(100, 1000, 3) : ", random.randrange(100, 1000, 3)
When we run above program, it produces following result −
randrange(100, 1000, 2) :  976
randrange(100, 1000, 3) :  520
Keyboard module in Python

24 Jan, 2019
Python provides a library named keyboard which is used to get full control of the keyboard. It’s a small Python library which can hook global events, register hotkeys, simulate key presses and much more.
It helps to enter keys, record the keyboard activities and block the keys until a specified key is entered and simulate the keys.
It captures all keys, even onscreen keyboard events are also captured.
Keyboard module supports complex hotkeys.
Using this module we can listen and send keyboard events.
It works on both windows and linux operating system.
Install using this command:
pip install keyboard
Example #1:
# Using Keyboard module in Pythonimport keyboard  # It writes the content to outputkeyboard.write("GEEKS FOR GEEKS\n")  # It writes the keys r, k and endofline keyboard.press_and_release('shift + r, shift + k, \n')keyboard.press_and_release('R, K')  # it blocks until ctrl is pressedkeyboard.wait('Ctrl')
Output:
GEEKS FOR GEEKS 
RK
rk

 Example #2: Keyboard module to enter hotkeys.
# Keyboard module in Pythonimport keyboard  # press a to print rkkeyboard.add_hotkey('a', lambda: keyboard.write('Geek'))keyboard.add_hotkey('ctrl + shift + a', print, args =('you entered', 'hotkey'))  keyboard.wait('esc')
Output:
ark
you entered hotkey

 Example #3: Keyboard module also used to record all the keyboard activities and replay them using play method.
# Keyboard module in Pythonimport keyboard  # It records all the keys until escape is pressedrk = keyboard.record(until ='Esc')  # It replay back the all keyskeyboard.play(rk, speed_factor = 1)
Output:
www.geeksforgeeks.org 

 Reference : https://pypi.org/project/keyboard/
Python-Library
Technical Scripter 2018
Python
Technical Scripter
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