code-rag-bench/online-tutorials huggingface dataset:
Matplotlib.figure.Figure.ginput() in Python

30 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The figure module provides the top-level Artist, the Figure, which contains all the plot elements. This module is used to control the default spacing of the subplots and top level container for all plot elements.
The ginput() method figure module of matplotlib library is used to block call to interact with a figure.
Syntax: ginput(self, n=1, timeout=30, show_clicks=True, mouse_add=1, mouse_pop=3, mouse_stop=2)
Parameters: This method accept the following parameters that are described below:
n : This parameter is the number of mouse clicks to accumulate.
timeout : This parameter is the number of seconds to wait before timing out.
show_clicks : This parameter is used to show a red cross at the location of each click.
mouse_add : This parameter is the Mouse button used to add points.
mouse_pop : This parameter is the Mouse button used to remove the most recently added point.
mouse_stop : This parameter is the Mouse button used to stop input.
Returns: This method return the list of the clicked (x, y) coordinates.
Below examples illustrate the matplotlib.figure.Figure.ginput() function in matplotlib.figure:
Example 1:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport numpy as np    t = np.arange(10)  fig = plt.figure()ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])  ax.plot(t, np.sin(t))    fig.suptitle('matplotlib.figure.Figure.ginput() \function Example', fontweight ="bold")  print("After 3 clicks :")x = fig.ginput(3)print(x)  plt.show()
Output:
After 3 clicks :
[(5.370117187499999, 0.12683733876216197), 
(5.370117187499999, 0.12683733876216197),
(5.370117187499999, 0.12683733876216197)]

Example 2:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport numpy as np    np.random.seed(10**7)    x1 = np.random.rand(103, 53) fig = plt.figure(dpi = 100)axes = fig.add_subplot(111)    fig.suptitle('matplotlib.figure.Figure.ginput() \function Example', fontweight ="bold")  print("After 2 clicks :")axes.imshow(x1)x = fig.ginput(2) print(x)  plt.show()
Output:
After 2 clicks :
[(29.90151515151514, 65.65854978354977),
(29.90151515151514, 65.65854978354977)]

Matplotlib figure-class
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stored Procedure for prime numbers in MYSQL

22 Sep, 2020
In this article, you will see how you can write the logic of stored procedure to generate prime numbers for any given input.
Title :Given a number N print all the prime number (<=N) separated by comma (, ) using Stored Procedure in MYSQL.
Example-1 :
Input : N = 10
Output : 2, 3, 5, 7

Example-2 :
Input : N = 20
Output : 2, 3, 5, 7, 11, 13, 17, 19

Program :A program to demonstrate that how you can generate the prime numbers for any given input.
delimiter $$
create procedure getPrime(IN n int, OUT result varchar(200))
Begin
declare j, i, flag int;  /* Declare variables */
set j:=2; 
set result:=' '; 
while(j<n) do /* Loop from 2 to n */
set i:=2;
set flag:=0;

while(i<=j) do /* Loop from 2 to j */
if(j%i=0)then
set flag:=flag+1;
end if;
set i:=i+1; /* Increment i */
end while;

if (flag=1) then
set result:=concat(result, j, ', '); 
/* Concat the prime number with ', ' */
end if ;
set j:=j+1; /* Increment j */
end while;

End
$$

How to call the procedure :To call the procedure used the following query given below.
call getPrime(20, @result);
select substr(@result, 1, length(@result)-1); /* To remove last character */

Output :
2, 3, 5, 7, 11, 13, 17, 19

mysql
Prime Number
DBMS
Prime Number
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Streamlit – Introduction and Setup

23 Oct, 2020
Streamlit is an open source app framework in python language. It helps us create beautiful web-apps for data science and machine learning in a little time. It is compatible with major python libraries such as scikit-learn, keras, pytorch, latex, numpy, pandas, matplotlib, etc.. Syntax for installing this library is shown below. 
 
Install StreamLit –In the command-prompt type
pip install streamlit

Creating a Simple application (Hello World) –
The 'hello, world!' script in Streamlit:
streamlit hello

# to run your python script
streamlit run myFirstStreamlitApp.py
You can stop running your app any time using Ctrl + C. 
Advantages: 1. It embraces python-scripting. 2. Less code is needed to create amazing web-apps. 3. No callbacks are needed since widgets are treated as variables. 4. Data caching simplifies and speeds up computation pipelines. 
Disadvantages: 1. Streamlit’s Data caching cannot keep track of changes to the data happening outside the function body. 
Some of its basic functions are described here. 
1. Adding a Title  
# myFirstStreamlitApp.py  #import the libraryimport streamlit as stl  # add title to your appstl.title("Geeks for Geeks")
Output:  
2. Adding some text  
# myFirstStreamlitApp.py  #import the libraryimport streamlit as stl  # add title to your appstl.title("Geeks for Geeks")  #adding text to your appstl.write("A Computer Science portal for Geeks")
Output:  
 
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list
Score of Parentheses in C++

Suppose we have a balanced parentheses string S, we have to compute the score of the string based on the following rule −
The () has score 1
AB has score A + B, where A and B are two balanced parentheses strings.
(A) has score 2 * A, where A is a balanced parentheses string.
So if the input is like “(()(()))”, then the output will be 6.
To solve this, we will follow these steps −
ans := 0, define a stack st
for i in range 0 to size of string Sif S[i] is opening parentheses, then insert -1 into stackotherwiseif top of stack is -1, then delete from stack and insert 1 into stackotherwisex := 0while top of stack is not -1increase x by st, delete from stx := x * 2delete from st, and insert x
if S[i] is opening parentheses, then insert -1 into stack
otherwiseif top of stack is -1, then delete from stack and insert 1 into stackotherwisex := 0while top of stack is not -1increase x by st, delete from stx := x * 2delete from st, and insert x
if top of stack is -1, then delete from stack and insert 1 into stack
otherwisex := 0while top of stack is not -1increase x by st, delete from stx := x * 2delete from st, and insert x
x := 0
while top of stack is not -1increase x by st, delete from st
increase x by st, delete from st
x := x * 2
delete from st, and insert x
while stack is not emptyincrease ans by top of st, and delete top element
increase ans by top of st, and delete top element
return ans.
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
   int scoreOfParentheses(string S) {
      int ans = 0;
      stack <int> st;
      for(int i = 0; i < S.size(); i+=1){
         if(S[i] == '('){
            st.push(-1);
         }else{
            if(st.top() == -1){
               st.pop();
               st.push(1);
            }else{
               int x = 0;
               while(st.top() != -1){
                  x += st.top();
                  st.pop();
               }
               x *= 2;
               st.pop();
               st.push(x);
            }
         }
      }
      while(!st.empty()){
         ans += st.top();
         st.pop();
      }
      return ans;
   }
};
main(){
   Solution ob;
   cout << (ob.scoreOfParentheses("(()(()))"));
}
"(()(()))"
6
Tryit Editor v3.7

Tryit: HTML image link
\omega - Tex Command

\omega - Used to create lowercase omega symbol.
{ \omega}
\omega command draws lowercase omega symbol.

\omega

ω



\omega

ω


\omega

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
Engineering - HEX2BIN Function

The HEX2BIN function converts a hexadecimal number to binary.
HEX2BIN (number, [places])

The hexadecimal number you want to convert.
Number cannot contain more than 10 characters (40 bits). The most significant bit of number is the sign bit (40th bit from the right). The remaining 39 bits are magnitude bits.
Negative numbers are represented using two's-complement notation.
The number of characters to use.
If places is omitted, HEX2BIN uses the minimum number of characters necessary.
Places is useful for padding the return value with leading 0s (zeros).
The Hexadecimal (Base 16) Numeral System uses the digits 0-9 and the characters A-F
The Hexadecimal (Base 16) Numeral System uses the digits 0-9 and the characters A-F
The following table shows the first 32 hexadecimal values, along with the equivalent decimal values −
The following table shows the first 32 hexadecimal values, along with the equivalent decimal values −
As hexadecimals use the numbers 0-9 and the characters A-F, they should be enclosed in quotation marks when they are supplied to an Excel function. For example, the hexadecimal 11A should be input as "11A"
As hexadecimals use the numbers 0-9 and the characters A-F, they should be enclosed in quotation marks when they are supplied to an Excel function. For example, the hexadecimal 11A should be input as "11A"
The Binary (Base 2) Numeral System uses the digits 0 & 1.
The Binary (Base 2) Numeral System uses the digits 0 & 1.
The following table shows the first 8 binary values, along with the equivalent decimal values −
The following table shows the first 8 binary values, along with the equivalent decimal values −
If number is negative, HEX2BIN ignores places and returns a 10-character binary number.
If number is negative, HEX2BIN ignores places and returns a 10-character binary number.
If number is negative, it cannot be less than FFFFFFFE00
If number is negative, it cannot be less than FFFFFFFE00
If number is positive, it cannot be greater than 1FF.
If number is positive, it cannot be greater than 1FF.
If number is not a valid hexadecimal number, HEX2BIN returns the #NUM! error value.
If number is not a valid hexadecimal number, HEX2BIN returns the #NUM! error value.
If HEX2BIN requires more than places characters, it returns the #NUM! error value.
If HEX2BIN requires more than places characters, it returns the #NUM! error value.
If places is not an integer, it is truncated.
If places is not an integer, it is truncated.
If places is nonnumeric, HEX2BIN returns the #VALUE! error value.
If places is nonnumeric, HEX2BIN returns the #VALUE! error value.
If places is negative, HEX2BIN returns the #NUM! error value.
If places is negative, HEX2BIN returns the #NUM! error value.
Excel 2007, 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
HTML - Main Tag

The HTML <main> tag specifies main or important content in the document. It can be used only once per page and can't be used as a descendent of <article>, <aside>, <footer>, <header>, <nav> element.
<!DOCTYPE html>
<html>

   <body>
      <main>
         <h1>Learning</h1>
         <p>Learn to gain experience and try to share your knowledge with others.</p>
         
         <article>
            <h3>Web Development Tutorials</h3>
            <p>Consist of CSS, HTML, and PHP tutorials for 2nd Semester exams.</p>
         </article>
         
         <article>
            <h3>Academic Tutorials</h3>
            <p>Consist of Computer Fundamental, Computer Network tutorials for
               1st Semester exams.</p>
         </article>
      </main>
   </body>

</html>
This will produce the following result −
Learn to gain experience and try to share your knowledge with others.
Consist of CSS, HTML, and PHP tutorials for 2nd Semester exams.
Consist of Computer Fundamental, Computer Network tutorials for 1st Semester exams.
This tag supports all the global attributes described in − HTML Attribute Reference
This tag supports all the event attributes described in − HTML Events Reference

    19 Lectures 
     2 hours 

 Anadi Sharma

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    18 Lectures 
     1.5 hours 

 Frahaan Hussain

    57 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)

    54 Lectures 
     6 hours 

 DigiFisk (Programming Is Fun)

    45 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
Where to use #region directive in C#?

It lets you specify a block of code that you can expand or collapse when using the outlining feature of the Visual Studio Code Editor. It should be terminated with #endregion.
Let us see how to define a region using #region.
#region NewClass definition
public class NewClass {
   static void Main() { }
}
#endregion
The following is an example showing the usage of #region directive.
 Live Demo
using System;
#region
class MyClass {
}

#endregion
class Demo {
   #region VARIABLE
   int a;
   #endregion
   static void Main() {
      #region BODY
      Console.WriteLine("Example showing the usage of region directive!");
      #endregion
   }
}
Example showing the usage of region directive!
Java Examples - Display text in a rectangle

How to display string in a rectangle?
Following example demonstrates how to display each character in a rectangle by drawing a rectangle around each character using drawRect() method.
import java.awt.*;
import javax.swing.*;

public class Main extends JPanel {
   public void paint(Graphics g) {
      g.setFont(new Font("",0,100));
      FontMetrics fm = getFontMetrics(new Font("",0,100));
      String s = "message";
      int x = 5;
      int y = 5;
      
      for (int i = 0; i < s.length(); i++) {
         char c = s.charAt(i);
         int h = fm.getHeight();
         int w = fm.charWidth(c);
         
         g.drawRect(x, y, w, h);
         g.drawString(String.valueOf(c), x, y + h);
         x = x + w;
      }
   }
   public static void main(String[] args) {
      JFrame frame = new JFrame();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setContentPane(new Main());
      frame.setSize(500, 700);
      frame.setVisible(true);
   }
}
The above code sample will produce the following result.
Each character is displayed in a rectangle. 

The following is an another sample example to display string in a rectangle.
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JComponent;
import javax.swing.JFrame;

class MyCanvas extends JComponent {
   String s = "message";
   int x = 45;
   int y = 45;
   public void paint(Graphics g) {
      g.drawRect (10, 10, 200, 200);
      g.setColor(Color.red);
      g.drawString(s, x, y);
   }
}
public class Panel {
   public static void main(String[] a) {
      JFrame window = new JFrame();
      window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      window.setBounds(30, 30, 300, 300);
      window.getContentPane().add(new MyCanvas());
      window.setVisible(true);
   }
}
The above code sample will produce the following result.
Each character is displayed in a rectangle. 

 Print
 Add Notes
 Bookmark this page
groupmod - Unix, Linux Command

groupmod modify a group definition on the system
groupmod [options] GROUP
groupmodThe groupmod command modifies the definition of the specified GROUP by modifying the appropriate entry in the group database.
The value of GID must be a non-negative decimal integer. This value must be unique, unless the -o option is used.
Users who use the group as primary group will be updated to keep the group as their primary group.

Any files that have the old group ID and must continue to belong to GROUP, must have their group ID changed manually.
No checks will be performed with regard to the GID_MIN, GID_MAX, SYS_GID_MIN, or SYS_GID_MAX from /etc/login.defs.
Example-1:
To change the group "newgroup" to "oldgroup".
# groupmod -n oldgroup newgroup
output:
# groupmod -n oldgroup newgroup
# grep oldgroup /etc/groupoldgroup:x:9090:
Example-2:
To change groupid of group:
# groupmod -g 777 oldgroup
output:
# grep oldgroup /etc/groupoldgroup:x:777:
Example-3:
To use same gid for multiple groups, use -o option
#groupmod -g 777 newgroup
output: ( both oldgroup and newgroup have same GID's)
# grep oldgroup /etc/groupoldgroup:x:777:
# grep newgroup /etc/groupoldgroup:x:777:

    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Count numbers having 0 as a digit in C++

We are provided a number N. The goal is to find the numbers that have 0 as digit and are in the range [1,N].
We will do this by traversing numbers from 10 to N ( no need to check from 1 to 9 ) and for each number we will check each digit using a while loop. If any digit is found as zero increment count and move to next number otherwise reduce the number by 10 to check digits until number is >0.
Let’s understand with examples.
Input 
N=11
Output 
Numbers from 1 to N with 0 as digit: 1
Explanation 
Starting from i=10 to i<=11
Only 10 has 0 as a digit. No need to check the range [1,9].
Input 
N=100
Output 
Numbers from 1 to N with 0 as digit: 10
Explanation 
10, 20, 30, 40, 50, 60, 70, 80, 90, 100. Ten numbers have 0 as digits.
We take an integer N.
We take an integer N.
Function haveZero(int n) takes n as parameter and returns count of numbers with 0 as digit
Function haveZero(int n) takes n as parameter and returns count of numbers with 0 as digit
Take the initial variable count as 0 for such numbers.
Take the initial variable count as 0 for such numbers.
Traverse range of numbers using for loop. i=10 to i=n
Traverse range of numbers using for loop. i=10 to i=n
Now for each number num=i, using while loop check if num%10==0, if false divide num by 10 and move to next digit until num>0
Now for each number num=i, using while loop check if num%10==0, if false divide num by 10 and move to next digit until num>0
If true stop further checking, increment count and break while loop.
If true stop further checking, increment count and break while loop.
At the end of all loops count will have a total numbers with 0 as digit between 1 to N.
At the end of all loops count will have a total numbers with 0 as digit between 1 to N.
Return the count as result.
Return the count as result.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
int haveZero(int n){
   int count = 0;
   for (int i = 1; i <= n; i++) {
      int num = i;
      while(num>1){
         int digit=num%10;
         if (digit == 0){
            count++;
            break;
         }
         else
            { num=num/10; }
      }
   }
   return count;
}
int main(){
   int N = 200;
   cout <<"Numbers from 1 to N with 0 as digit: "<<haveZero(N);
   return 0;
}
If we run the above code it will generate the following output −
Numbers from 1 to N with 0 as digit: 29
How to set background image in HTML ? - GeeksforGeeks

07 Apr, 2021
Background image which we see on some websites not only makes it look good but also enhances the user experience. The background image has the potential to tell the users about the theme of the website which makes the user stick to the website. Example: If you add a background image related to traveling to your website, it clearly tells the theme about the website and the user will explore it further. It’s like when you give a background image, it invites your users to explore some other site pages too. 
After reading this article you would be able to set a background image in a webpage by using only HTML and CSS.
There are two methods for setting a background image in an HTML file: 
By using background attribute in the tag in HTML.By using Inline or Internal Style Sheet.
By using background attribute in the tag in HTML.
By using Inline or Internal Style Sheet.
Method 1: By using background attribute in the tag in HTML
Syntax:
<body background = "image_name.extension">
Property value: It holds the file of an image that you want to use as the background image.
Note: HTML 5 does not support the background attribute in the <body> tag, so we have to use CSS to add the background image to the webpage.
Example:
<!DOCTYPE html><html>  <head>    <title>        HTML body Background Attribute    </title></head>  <!-- body tag starts here --><body background="https://media.geeksforgeeks.org/wp-content/uploads/rk.png">          <center>        <h1>GeeksforGeeks</h1>        <h2>HTML <body> background Attribute</h2>                  <a href="#">            It is a Computer Science portal For Geeks        </a>    </center></body><!-- body tag ends here -->  </html>
Output:
Method 2: By using Inline or Internal Style Sheet, here we have to use the style attribute of HTML and background-image property of CSS.
Syntax:
<div style = "background-image: url('Image_name.extension');">
HTML
<!DOCTYPE html><html>  <head>    <title> By using Inline CSS</title></head>  <body style="background-image: url('image.png');">    <h2>Welcome To GFG</h2></body>  </html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Basics
HTML-Questions
Picked
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to set the default value for an HTML <select> element ?
How to update Node.js and NPM to next version ?
How to set input type date in dd-mm-yyyy format using HTML ?
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
tmpfile() function in C - GeeksforGeeks

04 Sep, 2017
In C Programming Language, the tmpfile() function is used to produce/create a temporary file.
tmpfile() function is defined in the “stdio.h” header file.
The created temporary file will automatically be deleted after the termination of program.
It opens file in binary update mode i.e., wb+ mode.
The syntax of tmpfile() function is:FILE *tmpfile(void) 
FILE *tmpfile(void) 
The tmpfile() function always returns a pointer after the creation of file to the temporary file. If by chance temporary file can not be created, then the tmpfile() function returns NULL pointer.
// C program to demonstrate working of tmpfile()#include <stdio.h>int main(){    char str[] = "Hello GeeksforGeeks";    int i = 0;      FILE* tmp = tmpfile();    if (tmp == NULL)    {        puts("Unable to create temp file");        return 0;    }      puts("Temporary file is created\n");    while (str[i] != '\0')    {        fputc(str[i], tmp);        i++;    }      // rewind() function sets the file pointer    // at the beginning of the stream.    rewind(tmp);      while (!feof(tmp))        putchar(fgetc(tmp));}
Output:
Temporary file is created
Hello GeeksforGeeks

This article is contributed by Bishal Kumar Dubey. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
C-File Handling
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Substring in C++
Multidimensional Arrays in C / C++
Left Shift and Right Shift Operators in C/C++
Function Pointer in C
rand() and srand() in C/C++
std::string class in C++
fork() in C
Command line arguments in C/C++
Enumeration (or enum) in C
Different methods to reverse a string in C/C++
How to close current tab in a browser window using JavaScript? - GeeksforGeeks

18 Oct, 2019
We are going to be looking at the method to close the current tab in a browser window using JavaScript. Earlier it used to happen that with a simple JavaScript function, the current tab used to get closed. The following syntax was used for this purpose.
Syntax:
window.close()
But accounting for a security feature, which was introduced a few years ago, ordinary JavaScript lost its privilege to close the current tab, just by using this syntax.
Note: A current window/tab will only get closed if and only if it was created & opened by that script.Means the window.close syntax is only allowed for the window/tab that is created & opened using window.open method.
Example: This example shows how to open GeekForGeeks window and then close it.
<!DOCTYPE html>  <html><head>    <style>        body{            text-align:center;        }    </style></head>  <body>      <h2 style="color:green">GeeksforGeeks</h2>    <h4 style="color:purple">Close Tab/Window using JavaScript</h4>      <button onclick="openWin()">Click to open GeeksforGeeks website</button>      <button onclick="closeWin()">Click here to close the window</button>      <script>        var myGeeksforGeeksWindow;          function openWin() {            myGeeksforGeeksWindow = window                     .open("https://www.geeksforgeeks.org", "_blank", "width=786, height=786");        }          function closeWin() {            myGeeksforGeeksWindow.close();        }    </script>  </body>  </html>
Output:When we load the code:
New Window/Tab gets opened up:
The Window/Tab gets closed:
The entire process:
nidhi_biet
JavaScript-Misc
Picked
JavaScript
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Difference Between PUT and PATCH Request
Node.js | fs.writeFileSync() Method
How to Use the JavaScript Fetch API to Get Data?
JavaScript | Promises
How to get character array from string in JavaScript?
Set the value of an input field in JavaScript
Java Program for factorial of a number - GeeksforGeeks

20 Mar, 2018
Factorial of a non-negative integer, is multiplication of all integers smaller than or equal to n. For example factorial of 6 is 6*5*4*3*2*1 which is 720.
Recursive :
// Java program to find factorial of given numberclass Test{    // method to find factorial of given number    static int factorial(int n)    {        if (n == 0)          return 1;                  return n*factorial(n-1);    }          // Driver method    public static void main(String[] args)     {        int num = 5;        System.out.println("Factorial of "+ num + " is " + factorial(5));    }}
Iterative Solution:
// Java program to find factorial of given numberclass Test{    // Method to find factorial of given number    static int factorial(int n)    {        int res = 1, i;        for (i=2; i<=n; i++)            res *= i;        return res;    }          // Driver method    public static void main(String[] args)     {        int num = 5;        System.out.println("Factorial of "+ num + " is " + factorial(5));    }}
One line Solution (Using Ternary operator):
// Java program to find factorial// of given numberclass Factorial {    int factorial(int n)  {      // single line to find factorial    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);    }      // Driver Code  public static void main(String args[])       {    Factorial obj = new Factorial();    int num = 5;    System.out.println("Factorial of " + num +                       " is " + obj.factorial(num));   }}// This code is contributed by Anshika Goyal.
The above solutions cause overflow for small numbers. Please refer factorial of large number for a solution that works for large numbers.
Please refer complete article on Program for factorial of a number for more details!
factorial
Java Programs
factorial
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Iterate HashMap in Java?
Iterate through List in Java
Program to print ASCII Value of a character
Factory method design pattern in Java
Java program to count the occurrence of each character in a string using Hashmap
Java Program to Remove Duplicate Elements From the Array
Traverse Through a HashMap in Java
Min Heap in Java
Iterate Over the Characters of a String in Java
Remove first and last character of a string in Java
Get the first letter of each word in a string using regex in Java - GeeksforGeeks

11 Dec, 2018
Given a string, extract the first letter of each word in it. “Words” are defined as contiguous strings of alphabetic characters i.e. any upper or lower case characters a-z or A-Z.
Examples:
Input : Geeks for geeks
Output :Gfg
        
Input : United Kingdom
Output : UK

Below is the Regular expression to extract the first letter of each word. It uses ‘/b'(one of boundary matchers). Please refer How to write Regular Expressions? to learn it.
\b[a-zA-Z]

// Java program to demonstrate extracting first// letter of each word using Regeximport java.util.regex.Matcher;import java.util.regex.Pattern;  public class Test{    static void printFirst(String s)    {        Pattern p = Pattern.compile("\\b[a-zA-Z]");        Matcher m = p.matcher(s);          while (m.find())            System.out.print(m.group());          System.out.println();    }      public static void main(String[] args)    {        String s1 = "Geeks for Geeks";        String s2 = "A Computer Science Portal for Geeks";        printFirst(s1);        printFirst(s2);    }}
Output:
GfG
ACSPfG

This article is contributed by Gaurav Miglani. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
java-regular-expression
Java-String-Programs
Java
Strings
Strings
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Stream In Java
Interfaces in Java
How to iterate any Map in Java
Write a program to reverse an array or string
Write a program to print all permutations of a given string
C++ Data Types
Longest Common Subsequence | DP-4
Check for Balanced Brackets in an expression (well-formedness) using Stack
PyQt5 QCalendarWidget - Getting Date Text Format - GeeksforGeeks

04 Jul, 2021
In this article, we will see how we can get the date text format to the specific date in the QCalendarWidget. Setting the date text format makes the specified date looks more special such as increasing the size and other features. Below is how a date with date text format looks like. 
 
In order to do this we will use dateTextFormat method with the QCalendarWidget object.Syntax : calendar.dateTextFormat()Argument : It takes no argumentReturn : It return dictionary where keys are QDate object and values are QTextCharFormat object  
Below is the implementation  
Python3
# importing librariesfrom PyQt5.QtWidgets import *from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import *from PyQt5.QtCore import *import sys  class Window(QMainWindow):     def __init__(self):        super().__init__()         # setting title        self.setWindowTitle("Python ")         # setting geometry        self.setGeometry(100, 100, 650, 400)         # calling method        self.UiComponents()         # showing all the widgets        self.show()     # method for components    def UiComponents(self):         # creating a QCalendarWidget object        self.calendar = QCalendarWidget(self)         # setting geometry to the calendar        self.calendar.setGeometry(50, 10, 400, 250)         # setting cursor        self.calendar.setCursor(Qt.PointingHandCursor)         # format        format = QTextCharFormat()        format.setFont(QFont('Times', 15))         # date        date = QDate(2020, 6, 10)         # setting date text format        self.calendar.setDateTextFormat(date, format)         # creating a label        label = QLabel(self)         # setting geometry        label.setGeometry(50, 280, 420, 120)         # making it multi line        label.setWordWrap(True)         # checking date text format        value = self.calendar.dateTextFormat()         # setting text to the label        label.setText("Date Text format: " + str(value))  # create pyqt5 appApp = QApplication(sys.argv) # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :  
 
clintra
Python PyQt-QCalendarWidget
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Enumerate() in Python
Python Dictionary
Defaultdict in Python
sum() function in Python
Python String | replace()
Read a file line by line in Python
How to Install PIP on Windows ?
Deque in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
ReactJS className Attribute - GeeksforGeeks

25 May, 2021
React.js library is all about splitting the app into several components. Each Component has its own lifecycle. React provides us some in-built methods that we can override at particular stages in the life-cycle of the component.
In class-based components, the className attribute is used to set or return the value of an element’s class attribute. Using this property, the user can change the class of an element to the desired class.
Creating React Application And Installing Module:
Step 1: Create a React application using the following command.npx create-react-app foldername
Step 1: Create a React application using the following command.
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command.cd foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command.
cd foldername
Project Structure: It will look like the following.
Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
App.js
import React from 'react';   // Defining our App Componentconst App = () => {     // Function to get element by its className  function getClassNameAttribute() {    var element = document.getElementsByClassName('gfg');       // Printing the element    console.log(element)  }     // Returning our JSX code  return <>    <div>      <h1>GeeksforGeeks</h1>      <div        className='gfg'>          ReactJS className Attribute      </div>      <button onClick={getClassNameAttribute}>          click      </button>    </div>  </>;}   // Exporting your Default App Componentexport default App
Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output:
Reference:https://reactjs.org/docs/dom-elements.html#classname
ReactJS Attributes
ReactJS DOM Elements
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ReactJS useNavigate() Hook
How to set background images in ReactJS ?
Axios in React: A Guide for Beginners
How to create a table in ReactJS ?
How to navigate on path by button click in react router ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
Generate all possible permutations of words in a Sentence - GeeksforGeeks

08 Jun, 2021
Given a string S, the task is to print permutations of all words in a sentence.
Examples:
Input: S = “sky is blue”Output:  sky is bluesky blue isis sky blueis blue skyblue sky isblue is sky
Input: S =” Do what you love”Output:Do what you loveDo what love youDo you what loveDo you love whatDo love what youDo love you whatwhat Do you lovewhat Do love youwhat you Do lovewhat you love Dowhat love Do youwhat love you Doyou Do what loveyou Do love whatyou what Do loveyou what love Doyou love Do whatyou love what Dolove Do what youlove Do you whatlove what Do youlove what you Dolove you Do whatlove you what Do
Approach: The given problem can be solved using recursion. Follow the steps below to solve the problem:
Traverse the sentence and split the words present in the sentence by spaces using split() and store them in a list.Permute the list using built-in python functions itertools.permutations().Traverse the permutations and convert each permutation to a list.Print these lists.
Traverse the sentence and split the words present in the sentence by spaces using split() and store them in a list.
Permute the list using built-in python functions itertools.permutations().
Traverse the permutations and convert each permutation to a list.
Print these lists.
Below is the implementation of the above approach:
Python3
# Python implementation of# the above approach from itertools import permutations  # Function to generate permutations# of all words in a sentencedef calculatePermutations(sentence):     # Stores all words in the sentence    lis = list(sentence.split())     # Stores all possible permutations    # of words in this list    permute = permutations(lis)     # Iterate over all permutations    for i in permute:               # Convert the current        # permutation into a list        permutelist = list(i)                 # Print the words in the        # list separated by spaces        for j in permutelist:            print(j, end = " ")                     # Print a new line        print()  # Driver Codeif __name__ == '__main__':     sentence = "sky is blue"    calculatePermutations(sentence)
sky is blue 
sky blue is 
is sky blue 
is blue sky 
blue sky is 
blue is sky
 
Time Complexity: O(N!), where N denotes the number of words in a sentence.Auxiliary Space: O(N!)
ruhelaa48
permutation
Python list-programs
python-list-functions
Combinatorial
Python Programs
Strings
Strings
permutation
Combinatorial
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Print all possible strings of length k that can be formed from a set of n characters
Count of subsets with sum equal to X
Python program to get all subsets of given size of a set
Heap's Algorithm for generating permutations
Distinct permutations of the string | Set 2
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
Exports & Imports in JavaScript

Note − To run this example you will need to run a localhost server.
Following is the code for exports and imports in JavaScript −
INDEX.html
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result {
      font-size: 18px;
      font-weight: 500;
   }
</style>
</head>
<body>
<h1>Exports and imports in JavaScript</h1>
<button class="Btn">IMPORT</button>
<div class="result"></div>
<h3>Click on the above button to import module</h3>
<script src="script.js" type="module"></script>
<script src="sample.js" type="module"></script>
</body>
</html>
script.js
import test from './sample.js';
document.querySelector('.Btn').addEventListener('click',()=>{
test();
})
sample.js
let resultEle = document.querySelector(".result");
export default function testImport(){
resultEle.innerHTML = 'Module testImport has been imported';
}
On clicking the ‘IMPORT’ button −
How to resize an image in Android using Picasso?

This example demonstrates how to do I 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 − Open build.gradle (Module: app) and add the following dependency −
implementation 'com.squareup.picasso:picasso:2.5.2'
Step 3 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
   android:padding="8dp"
   tools:context=".MainActivity">
   <ImageView
      android:id="@+id/imageView"
      android:layout_width="match_parent"
      android:layout_height="match_parent" />
</LinearLayout>
Step 3 − Add the following code to src/MainActivity.java
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
import com.squareup.picasso.Picasso;
public class MainActivity extends AppCompatActivity {
   ImageView imageView;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      imageView = findViewById(R.id.imageView);
      String url = "https://images.pexels.com/photos/414612/pexels-photo-414612.jpeg";
      Picasso.with(this).load(url).resize(200, 500).into(imageView);
   }
}
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.INTERNET"/>
   <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 −
Metasploit - Brute-Force Attacks

In a brute-force attack, the hacker uses all possible combinations of letters, numbers, special characters, and small and capital letters in an automated way to gain access over a host or a service. This type of attack has a high probability of success, but it requires an enormous amount of time to process all the combinations.
A brute-force attack is slow and the hacker might require a system with high processing power to perform all those permutations and combinations faster. In this chapter, we will discuss how to perform a brute-force attack using Metasploit.
After scanning the Metasploitable machine with NMAP, we know what services are running on it. The services are FTP, SSH, mysql, http, and Telnet.
To perform a brute-force attack on these services, we will use auxiliaries of each service. Auxiliaries are small scripts used in Metasploit which don’t create a shell in the victim machine; they just provide access to the machine if the brute-force attack is successful. Let’s see how to use auxiliaries.
Here, we have created a dictionary list at the root of Kali distribution machine.
Open Metasploit. The first service that we will try to attack is FTP and the auxiliary that helps us for this purpose is auxiliary/scanner/ftp/ftp_login.
Type the following command to use this auxiliary −
msf > use auxiliary/scanner/ftp/ftp_login

Set the path of the file that contains our dictionary.
Set the victim IP and run.
It will produce the following output −
As you can see, it is completed, but no session has been created. It means we were unsuccessful in retrieving any useful username and password.
To attack the SSH service, we can use the auxiliary: auxiliary/scanner/ssh/ssh_login
As you can see in the following screenshot, we have set the RHOSTS to 192.168.1.101 (that is the victim IP) and the username list and password (that is userpass.txt). Then we apply the run command.
As can be seen in the above screenshot, three sessions were created. It means three combinations were successful. We have underlined the usernames.
To interact with one of the three sessions, we use the command msf > sessions –i 3 which means we will connect with session number 3.
The apply a brute-force attack on a Telnet service, we will take a provided set of credentials and a range of IP addresses and attempt to login to any Telnet servers. For this, we will use the auxiliary: auxiliary/scanner/telnet/telnet_login.
The process of using the auxiliary is same as in the case of attacking an FTP service or an SSH service. We have to use the auxiliary, set RHOST, then set the list of passwords and run it.
Take a look at the following screenshot. Highlighted in blue arrow are the incorrect attempts that the auxiliary did. The red arrows show the successful logins that created sessions.
Some other auxiliaries that you can apply in brute-force attack are −
SMB service − auxiliary/scanner/smb/smb_login
SMB service − auxiliary/scanner/smb/smb_login
SNMP service − auxiliary/scanner/snmp/snmp_login
SNMP service − auxiliary/scanner/snmp/snmp_login
 Print
 Add Notes
 Bookmark this page
How to pass a jQuery event as a parameter in a method?

To pass a jQuery event as a parameter in a method, use the bind() method.
You can try to run the following code to learn how to apss a jQuery event as a parameter:
Live Demo
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
   $("#btn1").bind("click", { key1: "value1", key2: "value2" }, myFunction);
   function myFunction (event)
   {
     $("#myid").text(event.data.key1);
   }
});
</script>
</head>
<body>

<input id= "btn1" type="button" value="click me" />
<div id = "myid" style="border:2px solid blue; width:400px; height:300px">

</body>
</html>
Execute VBScript Online

HTML File with VBScript
MySQL query to select rows except first row in descending order?

Let us first create a table −
mysql> create table DemoTable
   -> (
   -> Amount int
   -> );
Query OK, 0 rows affected (0.50 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(10);
Query OK, 1 row affected (0.17 sec)

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

mysql> insert into DemoTable values(30);
Query OK, 1 row affected (0.10 sec)

mysql> insert into DemoTable values(40);
Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
+--------+
| Amount |
+--------+
|     10 |
|     20 |
|     30 |
|     40 |
+--------+
4 rows in set (0.00 sec)
Following is the query to select rows except first row in descending order −
mysql> select *from DemoTable WHERE Amount NOT IN (SELECT MAX(Amount) from DemoTable) ORDER BY Amount DESC;
+--------+
| Amount |
+--------+
|     30 |
|     20 |
|     10 |
+--------+
3 rows in set (0.05 sec)