code-rag-bench/online-tutorials huggingface dataset:
MySQL | COMPRESS( ) Function - GeeksforGeeks

08 Nov, 2019
The MySQL COMPRESS() function is used for the compression of a string. The value returned by the COMPRESS() function is a binary string.
The COMPRESS() function stores non-empty strings as a four-byte length of the uncompressed string, which is then followed by the compressed string. If the string ends with space, a “.” character is added to the string. Also, it should be noted that empty strings are stored as empty strings. The COMPRESS() function accepts one parameter which is the string to be compressed.
Syntax:
COMPRESS(string_to_compress)
Parameters Used:
string_to_compress – It is used to specify the plain text string that is to be compressed.
Return Value:The COMPRESS function in MySQL returns a compressed string.
Supported Versions of MySQL:
MySQL 5.7
MySQL 5.6
MySQL 5.5
MySQL 5.1
MySQL 5.0
MySQL 4.1
Example-1: Implementing COMPRESS function on a string.
SELECT 
COMPRESS('geeskforgeeks'); 
Example-2: Implementing COMPRESS function on a string which has a combination of characters and integers.
SELECT 
COMPRESS('geeskforgeeks123'); 
Output:
\0\0\0x?KOM-?N?/JOM?.642\06?? 
Example-3: Implementing COMPRESS function on a string and returning the length of the string after compression.
SELECT 
COMPRESS('geeksforgeeks'), LENGTH(COMPRESS('geeksforgeeks')); 
Output:
\0\0\0x?KOM?.N?/J?\0%?f    22 
Example-4: Implementing COMPRESS function on a NULL string and returning the length of the string after compression.
SELECT 
COMPRESS(NULL), LENGTH(COMPRESS(NULL)); 
Output:
NULL NULL 
mysql
SQLmysql
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL Interview Questions
CTE in SQL
How to Update Multiple Columns in Single Update Statement in SQL?
Difference between SQL and NoSQL
Difference between DDL and DML in DBMS
Difference between DELETE, DROP and TRUNCATE
MySQL | Group_CONCAT() Function
Difference between DELETE and TRUNCATE
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?
jQuery | multiple elements Selector - GeeksforGeeks

08 Sep, 2021
There are two ways to select multiple elements using selectors:
element selector
* selector
Syntax:
For element selector:$("element1, element2, element3, ...")
$("element1, element2, element3, ...")
For * selector:$("*")
$("*")
Parameter:
element: This parameter is required to specify the elements to be selected.
Example-1: Using element selector.
<!DOCTYPE html><html>  <head>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">  </script>       <script>        $(document).ready(function() {            $("h2, div, span").css(              "background-color", "green");        });    </script></head>  <body>    <center>        <h1>Welcome to GeeksforGeeks      </h1>        <h2>Geeks1</h2>          <div>Geeks2</div>          <p>Geeks3</p>        <p><span>Geeks4</span></p>    </center>  </body>  </html>
Output:
Example-2: Using * selector.
<!DOCTYPE html><html>  <head>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">  </script>    <script>        $(document).ready(function() {            $("*").css(            "background-color", "green");        });    </script></head>  <body>    <center>        <h1>Welcome to GeeksforGeeks</h1>        <h2>Geeks1</h2>          <div>Geeks2</div>          <p>Geeks3</p>        <p><span>Geeks4</span></p>    </center>  </body>  </html>
Output:
Supported Browsers:
Google Chrome 90.0+
Internet Explorer 9.0
Firefox 3.6
Safari 4.0
Opera 10.5
ysachin2314
jQuery-Selectors
Picked
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JQuery | Set the value of an input text field
Form validation using jQuery
How to change selected value of a drop-down list using jQuery?
How to change the background color after clicking the button in JavaScript ?
How to fetch data from JSON file and display in HTML table using jQuery ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
PHP | basename( ) Function - GeeksforGeeks

26 Apr, 2018
The basename() function in PHP is an inbuilt function which is used to return the base name of a file if the path of the file is provided as a parameter to the basename() function.
Syntax:
string basename ( $path , $suffix )
Parameters: The basename() function in PHP accepts two parameters which are path and suffix.
$path: This parameter is of string type and is mandatory. It specifies the path of the file.$suffix: It is an optional parameter which hides the extension of a file if it ends with a suffix.
$path: This parameter is of string type and is mandatory. It specifies the path of the file.
$suffix: It is an optional parameter which hides the extension of a file if it ends with a suffix.
Return Value: This function returns the basename of the file whose path has been given as a parameter by the user.
Errors And Exception:
The basename() function doesn’t recognise path components such as ‘..’ .The basename() function operates on the input string provided by the user and is unaware of the actual filesystem.Both slashes, forward slash (/) and backslash (\) are used as directory separator character on a windows platform whereas it is just a forward slash (/) in other environments.
The basename() function doesn’t recognise path components such as ‘..’ .
The basename() function operates on the input string provided by the user and is unaware of the actual filesystem.
Both slashes, forward slash (/) and backslash (\) are used as directory separator character on a windows platform whereas it is just a forward slash (/) in other environments.
Examples:
Input : $path = "user01/home/documents/geeksforgeeks.php",
Output : geeksforgeeks.php

Input :  $path = "user01/home/documents/geeksforgeeks.php",
         $suffix = ".php"
Output : geeksforgeeks

Below programs illustrate the basename() function:
Program 1:
<?php  $path = "user01/home/documents/geeksforgeeks.php";  // basename() function to show// filename along with extensionecho basename($path);  ?>
Output:
geeksforgeeks.php
Program 2:
<?php  $path = "user01/home/documents/geeksforgeeks.php";  // basename() function to show the// filename while hiding the extensionecho basename($path, ".php");  ?>
Output:
geeksforgeeks
Reference:http://php.net/manual/en/function.basename.php
PHP-file-handling
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to execute PHP code using command line ?
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
PHP in_array() Function
How to pop an alert message box using PHP ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
PyQt5 – How to hide label | label.setHidden method - GeeksforGeeks

26 Mar, 2020
In this article, we will see how we can hide the Label in the PyQt5 application. A label is a graphical control element which displays text on a form. It is usually a static control; having no interactivity. A label is generally used to identify a nearby text box or other widget.
In order to hide the label we use setHidden() method, this method allows user to set if the widget should be visible or hidden, it belongs to the QWidget class.
Syntax : label.setHidden(True)
Argument : It takes bool as an argument.
Code :
# importing the required libraries  from PyQt5.QtWidgets import *from PyQt5 import QtCorefrom PyQt5.QtGui import * import sys  class Window(QMainWindow):    def __init__(self):        super().__init__()            # set the title        self.setWindowTitle("Label")          # setting  the geometry of window        self.setGeometry(0, 0, 400, 300)          # creating a label widget        self.label_1 = QLabel("Normal Label", self)          # moving position        self.label_1.move(100, 100)          # setting up border        self.label_1.setStyleSheet("border: 1px solid black;")          # creating a label widget        self.label_2 = QLabel("Hidden Label", self)          # moving position        self.label_2.move(100, 150)          # setting up border        self.label_2.setStyleSheet("border: 1px solid black;")          # hiding the label        self.label_2.setHidden(True)            # show all the widgets        self.show()    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :As we can see the label 2 is hidden in the output window.
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Graph Plotting in Python | Set 1
Defaultdict in Python
How to create a full screen search box with CSS and JavaScript?

Following is the code to create a full screen search box with CSS and JavaScript −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/fontawesome.min.css">
<style>
body {
   font-family: Arial;
}
* {
   box-sizing: border-box;
}
.showBtn {
   background: #008b0c;
   border: none;
   color:white;
   padding: 10px 15px;
   font-size: 20px;
   cursor: pointer;
   opacity: 0.8;
}
.showBtn:hover {
   opacity: 1;
}
.overlaySearch {
   height: 100%;
   width: 100%;
   display: none;
   position: fixed;
   z-index: 1;
   top: 0;
   left: 0;
   background-color: rgba(132, 150, 155, 0.747);
}
.searchBar {
   position: relative;
   top: 46%;
   width: 80%;
   text-align: center;
   margin-top: 30px;
   margin: auto;
}
.overlaySearch .hideBtn {
   position: absolute;
   top: 20px;
   right: 45px;
   font-size: 60px;
   cursor: pointer;
   color: rgb(255, 0, 0);
   opacity: 0.8;
}
.overlaySearch .hideBtn:hover {
   opacity: 1;
}
.overlaySearch input[type=text] {
   padding: 15px;
   font-size: 17px;
   border: none;
   float: left;
   width: 80%;
   background: white;
}
.overlaySearch input[type=text]:hover {
   background: #f1f1f1;
}
.overlaySearch button {
   float: left;
   width: 20%;
   padding: 15px;
   background: rgb(54, 21, 241);
   font-size: 17px;
   border: none;
   color:white;
   cursor: pointer;
   opacity: 0.8;
}
.overlaySearch button:hover {
   opacity: 1;
}
</style>
</head>
<body>
<div class="overlaySearch" >
<span class="hideBtn">×</span>
<div class="searchBar">
<form >
<input type="text" placeholder="Search Here.." ">
<button type="submit"><i class="fa fa-search"></i></button>
</form>
</div>
</div>
<h1>Fullscreen Search Example</h2>
<button class="showBtn">Open Search Box</button>
<h2>Click on the above button to open search box in full screen</h2>
<script>
document.querySelector('.hideBtn').addEventListener('click',hideSearch);
document.querySelector('.showBtn').addEventListener('click',showSearch);
function showSearch() {
   document.querySelector('.overlaySearch').style.display = "block";
}
function hideSearch() {
   document.querySelector('.overlaySearch').style.display = "none";
}
</script>
</body>
</html>
The above code will produce the following output −
On clicking the open search box button −
Python 3 - os.chflags() Method

The method chflags() sets the flags of path to the numeric flags. The flags may take a combination (bitwise OR) of the various values described below.
Note − This method is available Python version 2.6 onwards. Most of the flags can be changed by super-user only.
Following is the syntax for chflags() method −
os.chflags(path, flags)

path − This is complete path of the directory to be changed to a new location.
flags − The flags specified are formed by OR'ing the following values −
os.UF_NODUMP − Do not dump the file.
os.UF_NODUMP − Do not dump the file.
os.UF_IMMUTABLE − The file may not be changed.
os.UF_IMMUTABLE − The file may not be changed.
os.UF_APPEND − The file may only be appended to.
os.UF_APPEND − The file may only be appended to.
os.UF_NOUNLINK − The file may not be renamed or deleted.
os.UF_NOUNLINK − The file may not be renamed or deleted.
os.UF_OPAQUE − The directory is opaque when viewed through a union stack.
os.UF_OPAQUE − The directory is opaque when viewed through a union stack.
os.SF_ARCHIVED − The file may be archived.
os.SF_ARCHIVED − The file may be archived.
os.SF_IMMUTABLE − The file may not be changed.
os.SF_IMMUTABLE − The file may not be changed.
os.SF_APPEND − The file may only be appended to.
os.SF_APPEND − The file may only be appended to.
os.SF_NOUNLINK − The file may not be renamed or deleted.
os.SF_NOUNLINK − The file may not be renamed or deleted.
os.SF_SNAPSHOT − The file is a snapshot file.
os.SF_SNAPSHOT − The file is a snapshot file.
This method does not return any value.
The following example shows the usage of chflags() method.
#!/usr/bin/python3
import os

path = "/tmp/foo.txt"

# Set a flag so that file may not be renamed or deleted.
flags = os.SF_NOUNLINK
retval = os.chflags( path, flags)
print ("Return Value: %s" % retval)
When we run the above program, it produces the following result −
Return Value : None


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Implement multiple COUNT() in a single MySQL query

For this, use CASE statement. Let us first create a table −
mysql> create table DemoTable
   -> (
   -> LastName varchar(100)
   -> );
Query OK, 0 rows affected (0.60 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Smith');
Query OK, 1 row affected (0.17 sec)

mysql> insert into DemoTable values('Brown');
Query OK, 1 row affected (0.17 sec)

mysql> insert into DemoTable values('Brown');
Query OK, 1 row affected (0.13 sec)

mysql> insert into DemoTable values('Smith');
Query OK, 1 row affected (0.15 sec)

mysql> insert into DemoTable values('Taylor');
Query OK, 1 row affected (0.15 sec)

mysql> insert into DemoTable values('Taylor');
Query OK, 1 row affected (0.11 sec)

mysql> insert into DemoTable values('Miller');
Query OK, 1 row affected (0.11 sec)

mysql> insert into DemoTable values('Miller');
Query OK, 1 row affected (0.12 sec)

mysql> insert into DemoTable values('Miller');
Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+----------+
| LastName |
+----------+
| Smith    |
| Brown    |
| Brown    |
| Smith    |
| Taylor   |
| Taylor   |
| Miller   |
| Miller   |
| Miller   |
+----------+
9 rows in set (0.00 sec)
Following is the query to implement multiple COUNT() methods in one query −
mysql> select COUNT(CASE WHEN LastName='Smith' THEN 1 END) AS TotalFrequency,
-> COUNT(CASE WHEN LastName='Brown' THEN 1 END) AS TotalFrequency,
-> COUNT(CASE WHEN LastName='Taylor' THEN 1 END) AS TotalFrequency,
-> COUNT(CASE WHEN LastName='Miller' THEN 1 END) AS TotalFrequency
-> from DemoTable;
This will produce the following output −
+----------------+----------------+----------------+----------------+
| TotalFrequency | TotalFrequency | TotalFrequency | TotalFrequency |
+----------------+----------------+----------------+----------------+
| 2              | 2              | 2              | 3              |
+----------------+----------------+----------------+----------------+
1 row in set (0.00 sec)
LinkedHashMap and LinkedHashSet in Java

Hash table and linked list implementation of the Map interface, with predictable iteration order. Let us see an example −
 Live Demo
import java.util.*;
public class Demo {
   public static void main(String args[]){
      LinkedHashMap<Integer, String> my_set;
      my_set = new LinkedHashMap<Integer, String>();
      my_set.put(67, "Joe");
      my_set.put(90, "Dev");
      my_set.put(null, "Nate");
      my_set.put(68, "Sara");
      my_set.put(69, "Amal");
      my_set.put(null, "Jake");
      my_set.put(69, "Ral");
      my_set.entrySet().stream().forEach((m) ->{
         System.out.println(m.getKey() + " " + m.getValue());
      });
   }
}
67 Joe
90 Dev
null Jake
68 Sara
69 Ral
A class named Demo contains the main function, where an instance of the LinkedHashMap is created. Elements are added into this hash map using the ‘put’ function, in the ‘’’integer, string’’’ format. A ‘forEach’ loop is used to iterate over the hash map and elements are displayed on the console.
Hash table and linked list implementation of the Set interface, with predictable iteration order. Let
us see an example −
 Live Demo
import java.util.*;
public class Demo {
   public static void main(String args[]){
      LinkedHashSet<String> my_set;
      my_set = new LinkedHashSet<String>();
      my_set.add("Joe");
      my_set.add("Dev");
      my_set.add("Nate");
      my_set.add("Sara");
      my_set.add("Amal");
      my_set.add("Jake");
      my_set.add("Ral");
      Iterator<String> my_itr = my_set.iterator();
      while (my_itr.hasNext()){
         System.out.println(my_itr.next());
      }
   }
}
Joe
Dev
Nate
Sara
Amal
Jake
Ral
A class named Demo contains the main function, where an instance of the LinkedHashSet is created.
Elements are added into this LinkedHashSet using the ‘add’ function. An iterator is defined that can be used to iterate over the hash set elements. These elements are displayed on the console.
MongoDB - Limit Records

In this chapter, we will learn how to limit records using MongoDB.
To limit the records in MongoDB, you need to use limit() method. The method accepts one number type argument, which is the number of documents that you want to be displayed.
The basic syntax of limit() method is as follows −
>db.COLLECTION_NAME.find().limit(NUMBER)

Consider the collection myycol has the following data.
{_id : ObjectId("507f191e810c19729de860e1"), title: "MongoDB Overview"},
{_id : ObjectId("507f191e810c19729de860e2"), title: "NoSQL Overview"},
{_id : ObjectId("507f191e810c19729de860e3"), title: "Tutorials Point Overview"}
Following example will display only two documents while querying the document.
>db.mycol.find({},{"title":1,_id:0}).limit(2)
{"title":"MongoDB Overview"}
{"title":"NoSQL Overview"}
>
If you don't specify the number argument in limit() method then it will display all documents from the collection.
Apart from limit() method, there is one more method skip() which also accepts number type argument and is used to skip the number of documents.
The basic syntax of skip() method is as follows −
>db.COLLECTION_NAME.find().limit(NUMBER).skip(NUMBER)

Following example will display only the second document.
>db.mycol.find({},{"title":1,_id:0}).limit(1).skip(1)
{"title":"NoSQL Overview"}
>
Please note, the default value in skip() method is 0.

    44 Lectures 
     3 hours 

 Arnab Chakraborty

    54 Lectures 
     5.5 hours 

 Eduonix Learning Solutions

    44 Lectures 
     4.5 hours 

 Kaushik Roy Chowdhury

    40 Lectures 
     2.5 hours 

 University Code

    26 Lectures 
     8 hours 

 Bassir Jafarzadeh

    70 Lectures 
     2.5 hours 

 Skillbakerystudios
 Print
 Add Notes
 Bookmark this page
How to compile a Python 3 app to an .exe using Tkinter?

Python is well-known for its rich library of extensions and packages. We can import and install the necessary packages from the library. However, if we require to run a Tkinter application with an executable file in Windows Operating System, then we can use the Pyinstaller package in Python. It converts a Python-based application to a native executable file (or.exe).
Follow the steps to compile a Tkinter-based application into an executable file,
Install Pyinstaller using 'pip install pyinstaller'.
Install Pyinstaller using 'pip install pyinstaller'.
Open the Command or Shell in the same directory where the application file is located and run the file using the command, pyinstaller --onefile app.py. It will create necessary folders such as binaries and other source files.
Open the Command or Shell in the same directory where the application file is located and run the file using the command, pyinstaller --onefile app.py. It will create necessary folders such as binaries and other source files.
Go to > dist folder where the executable file of the application is located.
Go to > dist folder where the executable file of the application is located.
Run the .exe file.
Run the .exe file.
app.py
#Import the required libraries
from tkinter import *

#Create an instance of Tkinter Frame
win = Tk()

#Set the geometry
win.geometry("750x350")

def display_text():
   Label(win, text= "Hey There! Welcome to TutorialsPoint", font= ('Helvetica 22 bold'), foreground="navy").pack()

#Create a Button
Button(win, text= "Click Me", font= ('Helvetica 13 bold'), foreground= "OrangeRed3", background= "White", command= display_text).pack(pady=50)
win.mainloop()
The .exe file will be created in the dist folder, as shown below.
Running the executable file of the application will display a window with a button on it.
Upon clicking the "Click Me" button, it will show a text label in the same window.
Difference Between HTML and CSS

In this post, we will understand the difference between HTML and CSS
It refers to Hyper Text Markup Language.
It refers to Hyper Text Markup Language.
It helps create web pages and applications.
It helps create web pages and applications.
It helps define structure of web page.
It helps define structure of web page.
It is a markup language.
It is a markup language.
It helps create static pages as well.
It helps create static pages as well.
It helps display data.
It helps display data.
HyperText helps define link between multiple web pages.
HyperText helps define link between multiple web pages.
Markup Language helps define text document using tags, which gives a structure to the web page.
Markup Language helps define text document using tags, which gives a structure to the web page.
It has less backup and support options.
It has less backup and support options.
HTML can’t be used inside a CSS sheet.
HTML can’t be used inside a CSS sheet.
It helps annotate the text so that a system can understand it and use it.
It helps annotate the text so that a system can understand it and use it.
There are specific number of tags in HTML.
There are specific number of tags in HTML.
These tags are predefined.
These tags are predefined.
Data is enclosed within tags.
Data is enclosed within tags.
Closing tags are not a necessity.
Closing tags are not a necessity.
An example of HTML −
<!DOCTYPE html>
<html>
<head>
   <title>My title</title>
</head>
<body>
   <h1>title</h1>
   <p>A sample</p>
</body>
</html>
It helps style the web pages.
It helps style the web pages.
It uses different styling features to achieve the same.
It uses different styling features to achieve the same.
It uses ‘selectors’ and ‘declaration blocks’.
It uses ‘selectors’ and ‘declaration blocks’.
It can be an external file or an internal file, depending on the requirement in hand.
It can be an external file or an internal file, depending on the requirement in hand.
CSS can be used inside a HTML document.
CSS can be used inside a HTML document.
It can be used to display data.
It can be used to display data.
It has a higher backup and support in comparison to HTML.
It has a higher backup and support in comparison to HTML.
An example of CSS −
<style>
p {
   color: pink;
   text-align: left;
}
</style>
How to treat NULL as 0 and add columns in MySQL?

Use the concept of IFNULL() method to treat NULL as 0. Let us first create a table −
mysql> create table DemoTable
(
   Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   Value1 int,
   Value2 int
);
Query OK, 0 rows affected (0.64 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(Value1,Value2) values(10,20);
Query OK, 1 row affected (0.20 sec)
mysql> insert into DemoTable(Value1,Value2) values(null,null);
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable(Value1,Value2) values(40,null);
Query OK, 1 row affected (0.18 sec)
Following is the query to display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+----+--------+--------+
| Id | Value1 | Value2 |
+----+--------+--------+
| 1  | 10     | 20     |
| 2  | NULL   | NULL   |
| 3  | 40     | NULL   |
+----+--------+--------+
3 rows in set (0.00 sec)
Following is the query to treat NULL as 0 and add columns −
mysql> select ifnull(Value1,0)+ifnull(Value2,0) AS NULL_AS_ZERO from DemoTable;
This will produce the following output displaying the sum since all the NULL values were considered 0 for addition −
+--------------+
| NULL_AS_ZERO |
+--------------+
| 30           |
| 0            |
| 40           |
+--------------+
3 rows in set (0.00 sec)
Bootstrap Form TextArea

The textarea is used when you need multiple lines of input. You can try to run the following code to work with textarea in Bootstrap Forms
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Forms</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>
      <form role = "form">
         <div class = "form-group">
            <label for = "name">Player</label>
            <input type = "text" class = "form-control" placeholder = "Player Name">
         </div>
         <div class = "form-group">
            <label for = "name">Rank</label>
            <input type = "text" class = "form-control" placeholder = "Player Rank">
         </div>
         <div class = "form-group">
            <label for = "name">Player Details</label>
            <textarea class = "form-control" rows = "3" placeholder = "Player Details"></textarea>
         </div>
      </form>
   </body>
</html>
C# Program to find all substrings in a string

Use the substring() method in C# to find all substrings in a string.
Let’s say our string is −
Xyz
Loop through the length of the string and use the Substring function from the beginning to the end of the string −
for (int start = 0; start <= str.Length - i; start++) {
   string substr = str.Substring(start, i);
   Console.WriteLine(substr);
}
The following is the C# program to find all substrings in a string.
Live Demo
using System;
class Demo {
   static void Main() {
      string str = "xyz";
      for (int i = 1; i < str.Length; i++) {
         for (int start = 0; start <= str.Length - i; start++) {
            string substr = str.Substring(start, i);
            Console.WriteLine(substr);
         }
      }
   }
}
x
y
z
xy
yz
Difference between Set and MultiSet in C++

In C++, both Set and MultiSet are the type of data structures which are used to store the data for easy accessing and insertion. On the basis of characteristics of both these data structures we can distinguish between Set and MultiSet.
Following are the important differences between Set and MultiSet −
Set
#include
#include
using namespace std;
main() {
   int data[15] = {11, 55, 22, 66, 33, 22, 11, 44, 77, 88, 66, 99, 66, 23, 41};
   set my_set;
   for(int i = 0; i<15; i++) { my_set.insert(data[i]);
   }
   set::iterator it;
   for(it = my_set.begin(); it != my_set.end(); it++) {
      cout << "Item: " << *it << endl;
   }
}
Item: 11
Item: 22
Item: 23
Item: 33
Item: 41
Item: 44
Item: 55
Item: 66
Item: 77
Item: 88
Item: 99
MultiSet
#include
#include
using namespace std;
main() {
   int data[15] = {11, 55, 22, 66, 33, 22, 11, 44, 77, 88, 66, 99, 66, 23, 41};
   multiset my_set;
   for(int i = 0; i<15; i++) { my_set.insert(data[i]);
   }
   multiset::iterator it;
   for(it = my_set.begin(); it != my_set.end(); it++) {
      cout << "Item: " << *it << endl;
   }
}
Item: 11
Item: 11
Item: 22
Item: 22
Item: 23
Item: 33
Item: 41
Item: 44
Item: 55
Item: 66
Item: 66
Item: 66
Item: 77
Item: 88
Item: 99
Create a Weather app using Flask | Python - GeeksforGeeks

17 Sep, 2019
Prerequisite : Flask installation
Flask is a lightweight framework written in Python. It is lightweight because it does not require particular tools or libraries and allow rapid web development. today we will create a weather app using flask as a web framework. this weather web app will provide current weather updates of cities searched.
Basic setup :
Create a file and name it as weather.py
Linux command to create a file
touch weather.py 
Now, create a folder templates with a file name index.html
Linux command to create a folder and a file
 mkdir templates && cd templates && touch index.html 
The project folder will look like :
Editing files :Use your own API key from Weather API and place it in API variable. Now edit weather.py file.
from flask import Flask, render_template, request  # import json to load JSON data to a python dictionaryimport json  # urllib.request to make a request to apiimport urllib.request    app = Flask(__name__)  @app.route('/', methods =['POST', 'GET'])def weather():    if request.method == 'POST':        city = request.form['city']    else:        # for default name mathura        city = 'mathura'      # your API key will come here    api = api_key_here      # source contain json data from api    source = urllib.request.urlopen('http://api.openweathermap.org/data/2.5/weather?q =' + city + '&appid =' + api).read()      # converting JSON data to a dictionary    list_of_data = json.loads(source)      # data for variable list_of_data    data = {        "country_code": str(list_of_data['sys']['country']),        "coordinate": str(list_of_data['coord']['lon']) + ' '                     + str(list_of_data['coord']['lat']),        "temp": str(list_of_data['main']['temp']) + 'k',        "pressure": str(list_of_data['main']['pressure']),        "humidity": str(list_of_data['main']['humidity']),    }    print(data)    return render_template('index.html', data = data)      if __name__ == '__main__':    app.run(debug = True)
Navigate to templates/index.html and edit it: link to the index file.
Now you can run the server to see the weather app –
 python weather.py 
Web technologies
Python
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
C++ String Library - erase

It erases part of the string, reducing its length.
Following is the declaration for std::string::erase.
string& insert (size_t pos, const string& str);
 string& erase (size_t pos = 0, size_t len = npos);
string& erase (size_t pos = 0, size_t len = npos);
pos − It is an insertion point.
pos − It is an insertion point.
str − It is a string object.
str − It is a string object.
len − It contains information about number of characters to erase.
len − It contains information about number of characters to erase.
It returns *this.
if an exception is thrown, there are no changes in the string.
In below example for std::string::erase.
#include <iostream>
#include <string>

int main () {
   std::string str ("sairamkrishna Mammahe is a one of the tech person.");
   std::cout << str << '\n';

   str.erase (10,8);
   std::cout << str << '\n';

   str.erase (str.begin()+9);
   std::cout << str << '\n';

   str.erase (str.begin()+5, str.end()-9);
   std::cout << str << '\n';

   return 0;
}
The sample output should be like this −
sairamkrishna Mammahe is a one of the tech person.
sairamkrisahe is a one of the tech person.
sairamkriahe is a one of the tech person.
sairah person.

 Print
 Add Notes
 Bookmark this page
How do I get the dialer to open with phone number displayed in Android?

This example demonstrates how do I get the dialer to open with the open number displayed in android.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:padding="8dp"
   tools:context=".MainActivity">
<Button
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_centerInParent="true"
   android:layout_marginTop="40dp"
   android:onClick="ShowDialer"
   android:text="Show Number Dialer" />
<TextView
   android:layout_width="match_parent"
      android:layout_height="wrap_content"
   android:autoLink="phone"
   android:linksClickable="true" />
</RelativeLayout>
Step 3 − Add the following code to src/MainActivity.java
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
   }
   public void ShowDialer(View view) {
      Intent intent = new Intent(Intent.ACTION_DIAL);
      intent.setData(Uri.parse("tel:0123456789"));
      startActivity(intent);
   }
}

Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="app.com.sample">
   <uses-permission android:name="android.permission.CALL_PHONE" />
      <application
         android:allowBackup="true"
         android:icon="@mipmap/ic_launcher"
         android:label="@string/app_name"
         android:roundIcon="@mipmap/ic_launcher_round"
         android:supportsRtl="true"
         android:theme="@style/AppTheme">
         <activity android:name=".MainActivity">
            <intent-filter>
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
         </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from the android studio, open one of your project's activity files and click the Run icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
Conditional removal of labels in Matplotlib pie chart

To remove labels from a Matplotlib pie chart based on a condition, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Create a Pandas dataframe of wwo-dimensional, size-mutable, potentially heterogeneous tabular data.
Plot a pie chart, using pie() method with conditional removal of labels, such that if %age value is greater than 25, then only keep labels, otherwise remove them.
To display the figure, use show() method.
import pandas as pd
from matplotlib import pyplot as plt

# Set the figure size
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True

# Create a Pandas dataframe
df = pd.DataFrame(
   {
      'activities': ['sleep', 'exercise', 'work', 'study'],
      'hours': [8, 1, 9, 4]
   }
)

# Pie chart with conditional removal of labels
df.set_index('activities').plot.pie(y='hours', legend=False, autopct=lambda p: format(p, '.2f') if p > 25 else None)

plt.show()
It will produce the following output
Notice that the pie chart shows the labels only when the percentage of value is greater than 25 (as per the condition). Since the values of "exercise" and "study" are less then 25, the pie chart doesn't reflect those labels.
What is Has-a relationship in Java?

These relationships are mainly based on the usage. This determines whether a certain class HAS-A certain thing. This relationship helps to reduce duplication of code as well as bugs.
public class Vehicle{}
public class Speed{}
public class Van extends Vehicle {
   private Speed sp;
}
This shows that class Van HAS-A Speed. By having a separate class for Speed, we do not have to put the entire code that belongs to speed inside the Van class, which makes it possible to reuse the Speed class in multiple applications.
In Object-Oriented feature, the users do not need to bother about which object is doing the real work. To achieve this, the Van class hides the implementation details from the users of the Van class. So, basically what happens is the users would ask the Van class to do a certain action and the Van class will either do the work by itself or ask another class to perform the action.
8086 program to convert a 16 bit Decimal number to Octal - GeeksforGeeks

26 Jun, 2019
Problem: We are given a 16 bit decimal number we have to print the number in octal format.
Examples:
Input: d1 = 16
Output:20

Input: d1 = 123
Output: 173 
Explanation:
Load the value stored into registerDivide the value by 8 to convert it to octalPush the remainder into the stackIncrease the countRepeat the steps until the value of the register is greater than 0Until the count is greater than zeroPOP the stackAdd 48 to the top element to convert it into ASCIIPrint the character using interruptDecrements the count
Load the value stored into register
Divide the value by 8 to convert it to octal
Push the remainder into the stack
Increase the count
Repeat the steps until the value of the register is greater than 0
Until the count is greater than zero
POP the stack
Add 48 to the top element to convert it into ASCII
Print the character using interrupt
Decrements the count
Program:
;8086 program to convert a 16 bit decimal number to octal    .MODEL SMALL    .STACK 100H    .DATA        d1 dw 16    .CODE        MAIN PROC FAR            MOV AX,    @DATA        MOV DS,    AX  ;load the value stored;in variable d1    mov ax,    d1  ;convert the value to octal;print the value    CALL PRINT  ;interrupt to exit    MOV AH,    4CH INT 21H      MAIN ENDP        PRINT PROC  ;initialize count    mov cx,    0 mov dx, 0 label1:;if    ax is zero        cmp ax,        0 je print1  ;initialize bx to 8 mov bx, 8  ;divide it by 8;to convert it to octal    div bx  ;push it in the stack    push dx  ;increment the count    inc cx  ;set dx to 0    xor dx,    dx        jmp label1            print1:  ;check if count;is greater than zero    cmp cx,    0 je exit  ;pop the top of stack    pop dx  ;add 48 so that it;represents the ASCII;value of digits    add dx,    48  ;interrupt to print a;character    mov ah,    02h int 21h  ;decrease the count    dec cx        jmp print1            exit : ret                       PRINT ENDP                           END MAIN
Output:
20
Note: The program cannot be run on an online editor, please use MASM to run the program and use dos box to run MASM, you might use any 8086 emulator to run the program.
Computer Organization and Architecture
microprocessor
system-programming
Computer Organization & Architecture
microprocessor
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Computer Organization and Architecture | Pipelining | Set 2 (Dependencies and Data Hazard)
Difference between SRAM and DRAM
8259 PIC Microprocessor
Direct Access Media (DMA) Controller in Computer Architecture
Introduction of Control Unit and its Design
Architecture of 8085 microprocessor
Difference between Hardwired and Micro-programmed Control Unit | Set 2
Pin diagram of 8086 microprocessor
Storage Structure in Operating Systems
Computer Architecture | Flynn's taxonomy
Generating Word Cloud in Python - GeeksforGeeks

05 Jul, 2021
Word Cloud is a data visualization technique used for representing text data in which the size of each word indicates its frequency or importance. Significant textual data points can be highlighted using a word cloud. Word clouds are widely used for analyzing data from social network websites.
For generating word cloud in Python, modules needed are – matplotlib, pandas and wordcloud. To install these packages, run the following commands :
pip install matplotlib
pip install pandas
pip install wordcloud
The dataset used for generating word cloud is collected from UCI Machine Learning Repository. It consists of YouTube comments on videos of popular artists. Dataset Link : https://archive.ics.uci.edu/ml/machine-learning-databases/00380/
Below is the implementation : 
Python3
# Python program to generate WordCloud # importing all necessary modulesfrom wordcloud import WordCloud, STOPWORDSimport matplotlib.pyplot as pltimport pandas as pd # Reads 'Youtube04-Eminem.csv' filedf = pd.read_csv(r"Youtube04-Eminem.csv", encoding ="latin-1") comment_words = ''stopwords = set(STOPWORDS) # iterate through the csv filefor val in df.CONTENT:         # typecaste each val to string    val = str(val)     # split the value    tokens = val.split()         # Converts each token into lowercase    for i in range(len(tokens)):        tokens[i] = tokens[i].lower()         comment_words += " ".join(tokens)+" " wordcloud = WordCloud(width = 800, height = 800,                background_color ='white',                stopwords = stopwords,                min_font_size = 10).generate(comment_words) # plot the WordCloud image                      plt.figure(figsize = (8, 8), facecolor = None)plt.imshow(wordcloud)plt.axis("off")plt.tight_layout(pad = 0) plt.show()
Output :  
The above word cloud has been generated using Youtube04-Eminem.csv file in the dataset. One interesting task might be generating word clouds using other csv files available in the dataset.
Advantages of Word Clouds : 
Analyzing customer and employee feedback.Identifying new SEO keywords to target.
Analyzing customer and employee feedback.
Identifying new SEO keywords to target.
Drawbacks of Word Clouds : 
Word Clouds are not perfect for every situation.Data should be optimized for context.
Word Clouds are not perfect for every situation.
Data should be optimized for context.
Reference : https://en.wikipedia.org/wiki/Tag_cloud
sagar-sehgal
ruhelaa48
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python String | replace()
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
How to print without newline in Python?
Python | Convert string dictionary to dictionary
Ruby | Math sin() function - GeeksforGeeks

04 Dec, 2020
The sin() is an inbuilt function in Ruby returns the sine of a given angle expressed in radians which is in range [-inf, +inf]. The returned value is in range [-1, +1]. 
Syntax: Math.sin(value) 
Parameters: The function accepts one mandatory parameter value whose corresponding sine is returned. 
Return Value: It returns the sine.
Example 1: 
Ruby
#Ruby program for sin() function #Assigning valuesval1 = 176 val2 = Math::PI / 2 val3 = -3123 val4 = -89 #Prints the sin() value                                                    puts Math.sin(val1)                                                        puts Math.sin(val2)                                                            puts Math.sin(val3)                                                                puts Math.sin(val4)
Output: 
 0.07075223608034517
1.0
-0.25408576770942626
-0.8600694058124533
Example 2: 
Ruby
#Ruby program for sin() function #Assigning valuesval1 = 1 val2 = 0 val3 = 989 val4 = -8932 #Prints the sin() value                                     puts Math.sin(val1)                                         puts Math.sin(val2)                                             puts Math.sin(val3)                                                 puts Math.sin(val4)
Output: 
0.8414709848078965
0.0
0.5660330877786267
0.43684277891924755
Reference: https://devdocs.io/ruby~2.5/math#method-c-sin 
arorakashish0911
Ruby Collections
Ruby Math-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Ruby | Array count() operation
Ruby | Array slice() function
Include v/s Extend in Ruby
Global Variable in Ruby
Ruby | Hash delete() function
Ruby | Types of Variables
Ruby | Enumerator each_with_index function
Ruby | Case Statement
Ruby | Array select() function
Ruby | Data Types
HTTP headers | X-Frame-Options - GeeksforGeeks

20 Oct, 2021
HTTP headers are used to pass additional information with HTTP response or HTTP requests. The X-Frame-Options is used to prevent the site from clickjacking attacks. It defines whether or not a browser should be allowed to render a page in a <frame>, <iframe>, <embed> or <object>. The frame-ancestors directive present in Content-Security-Policy(CSP) obsoletes X-Frame-Options. 
Syntax:  
X-Frame-Options: directive
Directives:  
deny: This directive stops the site from being rendered in <frame> i.e. site can’t be embedded into other sites.
sameorigin: This directive allows the page to be rendered in the frame iff frame has the same origin as the page.
allow-from uri: This directive has now became obsolete and shouldn’t be used. It is not supported by modern browser. In this the page can be rendered in the <frame> that is originated from specified uri.
Examples:  
On Apache: To send the X-Frame-Options to all the pages of same originis, set this to your site’s configuration.
Header always set X-Frame-Options "sameorigin"
Open httpd.conf file and add the following code to deny the permission
header always set x-frame-options "DENY"
On Nginx: Open the server configuration file and add the following code to allow only from same origin
add_header x-frame-options "SAMEORIGIN" always;
Supported Browsers: The browsers supported by X-Frame-Options are listed below:  
Chrome
Internet Explorer
Safari
Firefox
Edge
Note: Only Internet Explorer and Microsoft Edge supports the allow-from directive. 
Akanksha_Rai
simmytarika5
surinderdawra388
HTTP-headers
Picked
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to create footer to stay at the bottom of a Web page?
Node.js fs.readFileSync() Method
How to set the default value for an HTML <select> element ?
File uploading in React.js
How to apply style to parent if it has child with CSS?