code-rag-bench/online-tutorials huggingface dataset:
SQL - INTERSECT Clause

The SQL INTERSECT clause/operator is used to combine two SELECT statements, but returns rows only from the first SELECT statement that are identical to a row in the second SELECT statement. This means INTERSECT returns only common rows returned by the two SELECT statements.
Just as with the UNION operator, the same rules apply when using the INTERSECT operator. MySQL does not support the INTERSECT operator.
The basic syntax of INTERSECT is as follows.
SELECT column1 [, column2 ]
FROM table1 [, table2 ]
[WHERE condition]

INTERSECT

SELECT column1 [, column2 ]
FROM table1 [, table2 ]
[WHERE condition]

Here, the given condition could be any given expression based on your requirement.
Consider the following two tables.
Table 1 − CUSTOMERS Table is as follows
+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
Table 2 − ORDERS Table is as follows.
+-----+---------------------+-------------+--------+
|OID  | DATE                | CUSTOMER_ID | AMOUNT |
+-----+---------------------+-------------+--------+
| 102 | 2009-10-08 00:00:00 |           3 |   3000 |
| 100 | 2009-10-08 00:00:00 |           3 |   1500 |
| 101 | 2009-11-20 00:00:00 |           2 |   1560 |
| 103 | 2008-05-20 00:00:00 |           4 |   2060 |
+-----+---------------------+-------------+--------+
Now, let us join these two tables in our SELECT statement as follows.
SQL> SELECT  ID, NAME, AMOUNT, DATE
   FROM CUSTOMERS
   LEFT JOIN ORDERS
   ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID
INTERSECT
   SELECT  ID, NAME, AMOUNT, DATE
   FROM CUSTOMERS
   RIGHT JOIN ORDERS
   ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
This would produce the following result.
+------+---------+--------+---------------------+
| ID   | NAME    | AMOUNT | DATE                |
+------+---------+--------+---------------------+
|    3 | kaushik |   3000 | 2009-10-08 00:00:00 |
|    3 | kaushik |   1500 | 2009-10-08 00:00:00 |
|    2 | Ramesh  |   1560 | 2009-11-20 00:00:00 |
|    4 | kaushik |   2060 | 2008-05-20 00:00:00 |
subfinder Tool in Linux

25 Jan, 2021
subfinder is a subdomain enumeration tool written in the Go programming language. Subfinder is used for discovering passive subdomains of websites by using digital sources like Censys, Chaos, Recon.dev, Shodan, Spyse, Virustotal, and many other passive online sources. Subfinder is widely used by Ethical Hackers and Bug bounty hunters in the Information gathering Phase which is also known as Reconnaissance.
As subfinder is a Go tool you need to have the Go language package installed before installing subfinder.
1. From Source(Recommended)
All you need to do is open your terminal and paste this one line of code and press enter.
GO111MODULE=on go get -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder
From Source
2. From Binary
Firstly download the release suitable for your OS from https://github.com/projectdiscovery/subfinder/releases/ and then unzip the folder and move the subfinder binary file to /usr/local/bin/ and you are good to go
# download release from https://github.com/projectdiscovery/subfinder/releases/
tar -xzvf subfinder-linux-amd64.tar.gz
mv subfinder /usr/local/bin/
subfinder -h
3. From Github
Clone https://github.com/projectdiscovery/subfinder.git repository and change directory to subfinder/v2/cmd/subfinder and then type go build . (don’t forget to put a ‘.’ at the end ) now move the subfinder binary file to /usr/local/bin and subfinder is ready to use.
git clone https://github.com/projectdiscovery/subfinder.git
cd subfinder/v2/cmd/subfinder
go build .
mv subfinder /usr/local/bin/
subfinder -h
From Github
Retrieving the Subfinder list of attributes
subfinder -h 
Here we will find out subdomains of the domain geeksforgeeks.org and setting a concurrency of 50. I got around 73 subdomains for geeksforgeeks.org in 4 seconds 71 milliseconds.
subfinder -d geeksforgeeks.org -silent -t 50
Example usage of subfinder
Pros of subfinder over sublist3r: As subfinder is a Go Tool and sublist3r is a python tool and Go Language is faster than python and also Go language’s approach to concurrency is very easy to work with. Also, subfinder also provides various options that sublist3r doesn’t.
Cyber-security
Information-Security
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
tar command in Linux with examples
curl command in Linux with Examples
'crontab' in Linux with Examples
TCP Server-Client implementation in C
Conditional Statements | Shell Script
Tail command in Linux with examples
UDP Server-Client implementation in C
Docker - COPY Instruction
scp command in Linux with Examples
diff command in Linux with examples
Python – Measure time taken by program to execute

26 May, 2020
This article aims to show how to measure the time taken by the program to execute. Calculating time helps to optimize your Python script to perform better.
Approach #1 :A simple solution to it is to use time module to get the current time. The following steps calculate the running time of a program or section of a program.
Store the starting time before the first line of the program executes.
Store the ending time after the last line of the program executes.
Print the difference between start time and end time.
Code #1 :
# Code to Measure time taken by program to execute.import time  # store starting timebegin = time.time()  # program body starts  for i in range(5):    print("GeeksForGeeks")# program body ends  time.sleep(1)# store end timeend = time.time()  # total time takenprint(f"Total runtime of the program is {end - begin}")
GeeksForGeeks
GeeksForGeeks
GeeksForGeeks
GeeksForGeeks
GeeksForGeeks
Total runtime of the program is 1.0010437965393066

 Approach #2 : Using Timeit module
# importing the required module import timeit   # code snippet to be executed only once mysetup = "from math import sqrt"  # code snippet whose execution time is to be measured mycode = ''' def example():     mylist = []     for x in range(100):         mylist.append(sqrt(x)) '''  # timeit statement print timeit.timeit(setup = mysetup,                     stmt = mycode,                     number = 10000) 
Output:
0.00119590759277
Note: Output may vary depending on the system or server load.
To read more about Timeit modulule, refer – Timeit in Python with Examples
python-utility
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Math.round() function in JavaScript

The round() function of the Math object accepts a floating point random number and returns its nearest integer value.
If the given number is x.5 or more this function returns the next number (x+1)
If the given number is x.4 or less this function returns the previous number (x-1).
If the given number itself is an integer this function returns the same.
Its Syntax is as follows
Math.round();
 Live Demo
<html>
<head>
   <title>JavaScript Example</title>
</head>
<body>
   <script type="text/javascript">
      var result = Math.round(2541.542);
      document.write("Rounded value of the given number: "+result);
   </script>
</body>
</html>
Rounded value of the given number: 2542
Solidity - do...while loop

The do...while loop is similar to the while loop except that the condition check happens at the end of the loop. This means that the loop will always be executed at least once, even if the condition is false.
The flow chart of a do-while loop would be as follows −
The syntax for do-while loop in Solidity is as follows −
do {
   Statement(s) to be executed;
} while (expression);

Note − Don't miss the semicolon used at the end of the do...while loop.
Try the following example to learn how to implement a do-while loop in Solidity.
pragma solidity ^0.5.0;

contract SolidityTest {
   uint storedData; 
   constructor() public{
      storedData = 10;   
   }
   function getResult() public view returns(string memory){
      uint a = 10; 
      uint b = 2;
      uint result = a + b;
      return integerToString(result); 
   }
   function integerToString(uint _i) internal pure 
      returns (string memory) {
      
      if (_i == 0) {
         return "0";
      }
      uint j = _i;
      uint len;
      
      while (j != 0) {
         len++;
         j /= 10;
      }
      bytes memory bstr = new bytes(len);
      uint k = len - 1;
      
      do {                   // do while loop	
         bstr[k--] = byte(uint8(48 + _i % 10));
         _i /= 10;
      }
      while (_i != 0);
      return string(bstr);
   }
}
Run the above program using steps provided in Solidity First Application chapter.
0: string: 12


    38 Lectures 
     4.5 hours 

 Abhilash Nelson

    62 Lectures 
     8.5 hours 

 Frahaan Hussain

    31 Lectures 
     3.5 hours 

 Swapnil Kole
 Print
 Add Notes
 Bookmark this page
How to get the system configuration information relevant to an open file using Python?

You can call the fpathconf(file_descriptor, name) function to get the system configuration information relevant to an open file. name specifies the configuration value to retrieve; it may be a string which is the name of a defined system value; these names are specified in a number of standards. Note that this function is only available on Unix systems. For example,
import os, sys
# Open a file
fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT )
# Now get maximum number of links to the file.
no = os.fpathconf(fd, 'PC_LINK_MAX')
print "Maximum number of links to the file. :%d" % no
# Now get maximum length of a filename
no = os.fpathconf(fd, 'PC_NAME_MAX')
print "Maximum length of a filename :%d" % no
os.close( fd)
When we run above program, it produces following result:
Maximum number of links to the file. :127
 Maximum length of a filename :255
numpy.exp() in Python

29 Nov, 2018
numpy.exp(array, out = None, where = True, casting = ‘same_kind’, order = ‘K’, dtype = None) :This mathematical function helps user to calculate exponential of all the elements in the input array.
Parameters :
array    : [array_like]Input array or object whose elements, we need to test.
out      : [ndarray, optional]Output array with same dimensions as Input array, 
            placed with result.
**kwargs : Allows you to pass keyword variable length of argument to a function. 
           It is used when we want to handle named argument in a function.
where    : [array_like, optional]True value means to calculate the universal 
           functions(ufunc) at that position, False value means to leave the  
           value in the output alone.

Return :
An array with exponential of all elements of input array. 

 Code 1 : Working
# Python program explaining# exp() functionimport numpy as np  in_array = [1, 3, 5]print ("Input array : ", in_array)  out_array = np.exp(in_array)print ("Output array : ", out_array)
Output :
Input array :  [1, 3, 5]
Output array :  [   2.71828183   20.08553692  148.4131591 ]

 Code 2 : Graphical representation
# Python program showing# Graphical representation of # exp() functionimport numpy as npimport matplotlib.pyplot as plt  in_array = [1, 1.2, 1.4, 1.6, 1.8, 2]out_array = np.exp(in_array)  y = [1, 1.2, 1.4, 1.6, 1.8, 2]plt.plot(in_array, y, color = 'blue', marker = "*")  # red for numpy.exp()plt.plot(out_array, y, color = 'red', marker = "o")plt.title("numpy.exp()")plt.xlabel("X")plt.ylabel("Y")plt.show()  
Output :
References :https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.exp.html.
Python numpy-Mathematical Function
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
How to Install PIP on Windows ?
Python String | replace()
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Iterate over a list in Python
Plotly - Heatmap

A heat map (or heatmap) is a graphical representation of data where the individual values contained in a matrix are represented as colors. The primary purpose of Heat Maps is to better visualize the volume of locations/events within a dataset and assist in directing viewers towards areas on data visualizations that matter most.
Because of their reliance on color to communicate values, Heat Maps are perhaps most commonly used to display a more generalized view of numeric values. Heat Maps are extremely versatile and efficient in drawing attention to trends, and it’s for these reasons they have become increasingly popular within the analytics community.
Heat Maps are innately self-explanatory. The darker the shade, the greater the quantity (the higher the value, the tighter the dispersion, etc.). Plotly’s graph_objects module contains Heatmap() function. It needs x, y and z attributes. Their value can be a list, numpy array or Pandas dataframe.
In the following example, we have a 2D list or array which defines the data (harvest by different farmers in tons/year) to color code. We then also need two lists of names of farmers and vegetables cultivated by them.
vegetables = [
   "cucumber", 
   "tomato", 
   "lettuce", 
   "asparagus",
   "potato", 
   "wheat", 
   "barley"
]
farmers = [
   "Farmer Joe", 
   "Upland Bros.", 
   "Smith Gardening",
   "Agrifun", 
   "Organiculture", 
   "BioGoods Ltd.", 
   "Cornylee Corp."
]
harvest = np.array(
   [
      [0.8, 2.4, 2.5, 3.9, 0.0, 4.0, 0.0],
      [2.4, 0.0, 4.0, 1.0, 2.7, 0.0, 0.0],
      [1.1, 2.4, 0.8, 4.3, 1.9, 4.4, 0.0],
      [0.6, 0.0, 0.3, 0.0, 3.1, 0.0, 0.0],
      [0.7, 1.7, 0.6, 2.6, 2.2, 6.2, 0.0],
      [1.3, 1.2, 0.0, 0.0, 0.0, 3.2, 5.1],
      [0.1, 2.0, 0.0, 1.4, 0.0, 1.9, 6.3]
   ]
)
trace = go.Heatmap(
   x = vegetables,
   y = farmers,
   z = harvest,
   type = 'heatmap',
   colorscale = 'Viridis'
)
data = [trace]
fig = go.Figure(data = data)
iplot(fig)
The output of the above mentioned code is given as follows −
Log and natural Logarithmic value of a column in Pandas – Python

28 Jul, 2020
Log and natural logarithmic value of a column in pandas can be calculated using the log(), log2(), and log10() numpy functions respectively. Before applying the functions, we need to create a dataframe.
Code:
Python3
# Import required librariesimport pandas as pdimport numpy as np   # Dictionarydata = {     'Name': ['Geek1', 'Geek2',             'Geek3', 'Geek4'],   'Salary': [18000, 20000,              15000, 35000]}   # Create a dataframedata = pd.DataFrame(data,                    columns = ['Name',                                'Salary'])  # Show the dataframedata
Output:  
After the dataframe is created, we can apply numpy.log2() function to the columns. In this case, we will be finding the logarithm values of the column salary. The computed values are stored in the new column “logarithm_base2”. 
Code:
Python3
# Calculate logarithm to base 2 # on 'Salary' columndata['logarithm_base2'] = np.log2(data['Salary'])  # Show the dataframedata    
Output : 
To find the logarithm on base 10 values we can apply numpy.log10() function to the columns. In this case, we will be finding the logarithm values of the column salary. The computed values are stored in the new column “logarithm_base10”. 
Code:
Python3
# Calculate logarithm to # base 10 on 'Salary' columndata['logarithm_base10'] = np.log10(data['Salary'])  # Show the dataframedata
Output : 
Natural logarithmic value of a column in pandas:
To find the natural logarithmic values we can apply numpy.log() function to the columns. In this case, we will be finding the natural logarithm values of the column salary. The computed values are stored in the new column “natural_log”. 
Code:
Python3
# Calculate natural logarithm on# 'Salary' columndata['natural_log'] = np.log(data['Salary'])  # Show the dataframedata    
Output :  
 
Python pandas-dataFrame
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
How do I select elements inside an iframe with Xpath?

We can select elements inside an iframe with xpath in Selenium webdriver. A frame is defined with <iframe>, <frameset> or <frame> tag in html code. A frame is used to embed an HTML document within another HTML document. Let us see the html code of a frame.
Selenium by default has access to the parent browser driver. In order to access inside a frame, the driver focus has to shift from the main browser window to the frame. There are more than one methods to shift focus to frames −
switchTo().frame(id) - The id or name of frame is passed as an argument.Syntax −
driver.switchTo().frame("id"), switching to the frame with id.
switchTo().frame(id) - The id or name of frame is passed as an argument.
Syntax −
driver.switchTo().frame("id"), switching to the frame with id.
switchTo().frame(m) - The index of frame is passed as an argument. The index begins from zero.Syntax −
driver.switchTo().frame(0), switching to the first frame in the page.
switchTo().frame(m) - The index of frame is passed as an argument. The index begins from zero.
Syntax −
driver.switchTo().frame(0), switching to the first frame in the page.
switchTo().frame(webelement n) - The webelement of frame is passed as an argument.Syntax −
driver.switchTo().frame(l), switching to the frame with l webelement.
switchTo().frame(webelement n) - The webelement of frame is passed as an argument.
Syntax −
driver.switchTo().frame(l), switching to the frame with l webelement.
Once we move the driver focus inside the frame, we can access the elements inside the frame by the xpath locator with the help of the driver.findElement(By.xpath(<xpath value>)) method.
Code Implementation.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class iFrameXpath{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.get("https://the-internet.herokuapp.com/frames");
      driver.manage().timeouts().implicitlyWait(8, TimeUnit.SECONDS);
      // identify element and click
      driver.findElement(By.partialLinkText("Nested")).click();
      // switching to frame with frame name
      driver.switchTo().frame("frame-bottom");
      WebElement m = driver.findElement(By.xpath("//body"));
      System.out.println("Element identified with xpath: " +m.getText());
      driver.close();
   }
}
time.Time.Truncate() Function in Golang with Examples

28 Apr, 2020
In Go language, time packages supplies functionality for determining as well as viewing time. The Time.Truncate() function in Go language is used to find the output of rounding the stated time “t” to the closest multiple of the given duration “d” from the zero time. Moreover, this function is defined under the time package. Here, you need to import the “time” package in order to use these functions.
Syntax:
func (t Time) Truncate(d Duration) Time

Here, “t” is the stated time, and “d” is the given duration.
Note: The Truncate() method works on the time in the form of an absolute duration from zero time. However, it doesn’t work on the layout form of the time.
Return Value: It returns the output of rounding the given time “t” to the closest multiple of the stated duration “d”. Where, if d is less than or equal to zero then it returns “t” out of any monotonic clock reading but else unaltered.
Example 1:
// Golang program to illustrate the usage of// Time.Truncate() function  // Including main packagepackage main  // Importing fmt and timeimport "fmt"import "time"  // Calling mainfunc main() {      // Defining t for Truncate method    t := time.Date(2007, 7, 6, 23, 58, 11, 60, time.UTC)      // Defining duration    d := (60 * time.Second)      // Calling Truncate() method    trunc := t.Truncate(d)      // Prints output    fmt.Printf("The result after rounding 't' is: %v\n", trunc)}
Output:
The result after rounding 't' is: 2007-07-06 23:58:00 +0000 UTC

Example 2:
// Golang program to illustrate the usage of// Time.Truncate() function  // Including main packagepackage main  // Importing fmt and timeimport "fmt"import "time"  // Calling mainfunc main() {      // Defining t for Truncate method    t := time.Date(2047, 47, 96, 123, 98, 81, 999434, time.UTC)      // Defining duration    d := (2 * time.Hour)      // Calling Truncate() method    trunc := t.Truncate(d)      // Prints output    fmt.Printf("The result after rounding 't' is: %v\n", trunc)}
Output:
The result after rounding 't' is: 2051-02-09 04:00:00 +0000 UTC

Here, the “t” stated in the above code has values that are outside the usual range but they are normalized while conversion.
GoLang-time
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Golang Maps
Arrays in Go
fmt.Sprintf() Function in Golang With Examples
How to copy one slice into another slice in Golang?
Time Durations in Golang
How to convert a string in lower case in Golang?
Interfaces in Golang
Inheritance in GoLang
Check if the String starts with specified prefix in Golang
strings.Replace() Function in Golang With Examples
How to make checkbox visible when hover or select the element?

31 Jan, 2020
The problem here is how to make a checkbox visible only when:
It is hovered overSelected
It is hovered over
Selected
Approach:The checkbox shouldn’t be visible when not selected. It only becomes visible when hovered over again.The solution to the problem is simple. We can use the opacity property of the checkbox element and manipulate that. Just change the opacity value of the checkbox to 1 when the checkbox element is hovered over or when it is selected, using CSS. The default value of opacity should be 0.
Example:
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <meta http-equiv="X-UA-Compatible" content="ie=edge">    <title>Checkbox</title>    <style>        #box{            margin:50px;            width:50px;            height:50px;            border:2px solid black;            padding:10px;        }          .cardcheckbox {        opacity: 0;                  }          .cardcheckbox:hover,        .cardcheckbox:checked {            opacity: 1;        }    </style></head><body>    <div id="box">        <div>            <input type="checkbox"                   class="cardcheckbox"                    align="right"/>        </div>    </div></body></html>
Output:
Bootstrap-Misc
CSS-Misc
Picked
Technical Scripter 2019
Bootstrap
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C/C++ Program to find Prime Numbers between given range

05 Jul, 2021
Given two numbers L and R, the task is to find the prime numbers between L and R.
Examples:
Input: L = 1, R = 10Output: 2 3 5 7Explanation:Prime number between the 1 and 10 are 2, 3, 5, and 7  
Input: L = 30, R = 40Output: 31 37  
Approach: The idea is to iterate from in the range [L, R] and check if any number in the given range is prime or not. If yes then print that number and check for the next number till we iterate all the numbers.
Below the implementation of the above approach:
C
C++
// C program to find the prime numbers// between a given interval#include <stdio.h> // Function for print prime// number in given rangevoid primeInRange(int L, int R){    int i, j, flag;     // Traverse each number in the    // interval with the help of for loop    for (i = L; i <= R; i++) {         // Skip 0 and 1 as they are        // neither prime nor composite        if (i == 1 || i == 0)            continue;         // flag variable to tell        // if i is prime or not        flag = 1;         // Iterate to check if i is prime        // or not        for (j = 2; j <= i / 2; ++j) {            if (i % j == 0) {                flag = 0;                break;            }        }         // flag = 1 means i is prime        // and flag = 0 means i is not prime        if (flag == 1)            printf("%d ", i);    }} // Driver Codeint main(){    // Given Range    int L = 1;    int R = 10;     // Function Call    primeInRange(L, R);     return 0;}
// C++ program to find the prime numbers// between a given interval#include <bits/stdc++.h>using namespace std; // Function for print prime// number in given rangevoid primeInRange(int L, int R){    int flag;     // Traverse each number in the    // interval with the help of for loop    for (int i = L; i <= R; i++) {         // Skip 0 and 1 as they are        // neither prime nor composite        if (i == 1 || i == 0)            continue;         // flag variable to tell        // if i is prime or not        flag = 1;         // Iterate to check if i is prime        // or not        for (int j = 2; j <= i / 2; ++j) {            if (i % j == 0) {                flag = 0;                break;            }        }         // flag = 1 means i is prime        // and flag = 0 means i is not prime        if (flag == 1)            cout << i << " ";    }} // Driver Codeint main(){    // Given Range    int L = 1;    int R = 10;     // Function Call    primeInRange(L, R);     return 0;}
  
2 3 5 7
 
 
Time Complexity: O((R-L)*N), where N is the number, and L and R are the given range.Auxiliary Space: O(1)
 
gabaa406
ruhelaa48
array-range-queries
Prime Number
C Programs
C++ Programs
Mathematical
Mathematical
Prime Number
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to remove the space between inline-block elements?

10 Aug, 2021
There are two methods to remove the space between inline-block elements.
Method 1: Assign the font size of the parent of the inline block element to 0px and then assign the proper font-size to the inline block element
Syntax:parent-element{       font-size:0px;}parent-element child-element{       display:inline-block;       font-size:Required font size;} 
The above concept is illustrated by the following code:
html
<!DOCTYPE html><html lang="en"> <head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <style>               /*Assign font-size of parent element to 0px*/        div {            font-size: 0px;                                      }         /*Making the element inline-block*/        /*Assign proper font-size to the inline block element*/        div span {            display: inline-block;                                    background-color: green;            font-size: 10rem;                                     }    </style>    <title>How to remove spaces between inline block elements</title></head> <body>    <div>        <span>Geeks</span>        <span>For</span>        <span>Geeks</span>    </div></body> </html>
Output: 
Method 2:Make the display of the parent element to flex. 
Syntax:
parent-element{         display:flex;}parent-element child-element{         display:inline-block;         font-size:Required font size;} 
HTML
<!DOCTYPE html><html lang="en"> <head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <style>        /*Making the parent element a flexbox*/        div {            display: flex;                                     }         /*Making the element inline-block*/        /*Assign proper font-size to the inline block element*/        div span {            display: inline-block;                                    background-color:rgb(53, 77, 5);            font-size: 10rem;                                     }    </style>    <title>How to remove spaces between inline block elements</title></head> <body>    <div>        <span>Geeks</span>        <span>For</span>        <span>Geeks</span>    </div></body> </html>
OUTPUT:
 
shahbazalam75508
akshaysingh98088
CSS-Misc
HTML-Misc
Picked
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Types of CSS (Cascading Style Sheet)
How to position a div at the bottom of its container using CSS?
How to set space between the flexbox ?
How to update Node.js and NPM to next version ?
How to insert spaces/tabs in text using HTML/CSS?
How to update Node.js and NPM to next version ?
Types of CSS (Cascading Style Sheet)
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to set input type date in dd-mm-yyyy format using HTML ?
Running Commands Inside Docker Container

31 Oct, 2020
If you are working on an application inside Docker Container, you might need commands to install packages or access file system inside the Docker Container. Executing commands inside Docker Containers should be easy enough for you since you have to do it multiple times across your development phase. Docker provides you with many ways to execute commands inside the Containers.
In this article, we are going to discuss different ways to execute any type of command inside the Docker Container.
You can directly access the bash of the Docker Container and execute commands there. It’s very easy to launch the bash of the Container and you can do so using this command.
sudo docker run -it ubuntu bash

The above command runs an Ubuntu Container and fires up its bash.
Once you have access to the bash, you can start executing any command there. In this example, we will perform an echo command execution.
echo geeksforgeeks

In order to run a command inside a Docker Container using the exec command, you have to know the Container Id of the Docker Container. You can get the Container Id using the following Command.
sudo docker container ls

or 
sudo docker ps -a

Once you have the Container ID, you can use the Docker exec command. But you have to confirm that the Container is running before you can execute the exec command. To start the Container, use this command.
sudo docker start d64b00529582

After that, execute the exec command.
sudo docker exec -it d64b00529582 echo "GeeksforGeeks"

When you are creating a large application, it is always advised that you execute your commands by specifying it inside the Dockerfile. However, you should only include those commands inside the Dockerfile which you want to execute while building the Container. For executing commands on the go, you can use any of the two methods above. To execute commands through Dockerfile, you can specify them using the Docker Run Commands.
FROM ubuntu:latest
RUN echo "geeksforgeeks"

After you have created the above Dockerfile, you can build the images using the Docker build command.
sudo docker build -t sample-image .

You can see that after step 2, “geeksforgeeks” has been printed.
Docker Container
linux
Advanced Computer Subject
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
System Design Tutorial
ML | Linear Regression
Docker - COPY Instruction
Reinforcement learning
Decision Tree Introduction with example
Getting started with Machine Learning
How to Run a Python Script using Docker?
ML | Monte Carlo Tree Search (MCTS)
ML | Underfitting and Overfitting
Copying Files to and from Docker Containers
Memory leak in C++ and How to avoid it?

16 Jun, 2021
Memory leakage occurs in C++ when programmers allocates memory by using new keyword and forgets to deallocate the memory by using delete() function or delete[] operator. One of the most memory leakage occurs in C++ by using wrong delete operator. The delete operator should be used to free a single allocated memory space, whereas the delete [] operator should be used to free an array of data values. Disadvantage with memory leakage: If a program has memory leaks, then its memory usage is satirically increasing since all systems have limited amount of memory and memory is costly. Hence it will create problems.Example of memory leakage in C++  
CPP
// Program with memory leak#include <bits/stdc++.h>using namespace std; // function with memory leakvoid func_to_show_mem_leak(){    int* ptr = new int(5);     // body     // return without deallocating ptr    return;} // driver codeint main(){     // Call the function    // to get the memory leak    func_to_show_mem_leak();     return 0;}
How to avoid Memory Leak?
Instead of managing memory manually, try to use smart pointers where applicable.
use std::string instead of char *. The std::string class handles all memory management internally, and it’s fast and well-optimized.
Never use a raw pointer unless it’s to interface with an older lib.
The best way to avoid memory leaks in C++ is to have as few new/delete calls at the program level as possible – ideally NONE. Anything that requires dynamic memory should be buried inside an RAII object that releases the memory when it goes out of scope. RAII allocate memory in constructor and release it in destructor, so that memory is guaranteed to be deallocated when the variable leave the current scope.
Allocate memory by new keyword and deallocate memory by delete keyword and write all code between them.
Example to handle memory leaks 
CPP
// CPP program to// illustrate how to avoid// memory leak#include <bits/stdc++.h>using namespace std; // function to see memory handlingvoid func_to_handle_mem_leak(){    int* ptr = new int(5);     // body     // Now delete pointer ptr using delete    delete (ptr);} // Driver codeint main(){     // Call function to handle    // the memory leak    func_to_handle_mem_leak()         return 0;}
Therefore, Always write delete pointer for matching of new pointer in C++ and always write code between these new and delete as explained in above example. In above example, no memory is wasted because when we are coming out from the function we are deallocating the memory by using delete function. 
thilak
clintra
C-Dynamic Memory Allocation
memory-management
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Set in C++ Standard Template Library (STL)
unordered_map in C++ STL
vector erase() and clear() in C++
Substring in C++
Priority Queue in C++ Standard Template Library (STL)
Sorting a vector in C++
2D Vector In C++ With User Defined Size
Virtual Function in C++
C++ Data Types
Templates in C++ with Examples
Social Mapper – Find Social Media Profiles Using Photo Only

23 Sep, 2021
OSINT techniques are too powerful that they can even search the information about the anonymous person on the internet by using his/her face without knowing the actual name of the person. Social Mapper is a Python-based open-source intelligence tool that correlates social media profiles via facial recognition. The Social Mapper tool is available on the GitHub platform, it is free and open-source to use. Social Mapper tool collects various data from many popular social media like:
Facebook
Instagram
LinkedIn
Google plus
Twitter
Vkontakte
This tool can be used in the phases of Reconnaissance and can help to perform Social Engineering attacks on the Organization or the Individual Victim.
Note: Make Sure You have Python Installed on your System, as this is a python-based tool. Click to check the Installation process – Python Installation Steps on Linux
Step 1: Use the following command to install the tool in your Kali Linux operating system.
git clone https://github.com/Greenwolf/social_mapper
Step 2: Now use the following command to move into the directory of the tool. You have to move to the directory to run the tool.
cd social_mapper
Step 3: You are in the directory of the Social Mapper. Now you have to install a dependency of the Social Mapper using the following command.
sudo pip3 install -r requirements.txt
Step 4: All the dependencies have been installed in your Kali Linux operating system. Now use the following command to run the tool and check the help section.
python3 social_mapper.py -h
Step 5: Add social platform credentials in the social_mapper.py file.
leafpad social_mapper.py
Example: Perform a fast scan
python3 social_mapper.py -f imagefolder -i /home/kali/Desktop/social_mapper/Input-Examples/imagefolder -m fast -tw
In this example, we will be performing a fast scan on images specified in the image folder.
We are performing a Twitter scan on faces saved in the image folder.
Results are saved in the SM-Results folder.
Displaying the .html format result file.
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Docker - COPY Instruction
scp command in Linux with Examples
chown command in Linux with Examples
SED command in Linux | Set 2
nohup Command in Linux with Examples
mv command in Linux with examples
chmod command in Linux with examples
Array Basics in Shell Scripting | Set 1
Introduction to Linux Operating System
Basic Operators in Shell Scripting
How to list the Azure VMs using Azure CLI in PowerShell?

To list all the Azure VMs connected to the particular subscription, we need to use the “Az vm” command. Before that, we need to make sure the Azure is connected to the desired subscription, if not use the below command to set the Azure Subscription.
az account set -s 'subscription name or id'
Once the Azure subscription is set, we can use the below command to retrieve the Azure VMs.
PS C:\> az vm list -otable
To get the particular azure VM using CLI, we need to provide the VM name and resource group name.
PS C:\> az vm show -n VmName -g ResourceGroupName -otable
“az vm show” command finds the VM from the list using parameter -n (VMName) -g (resource group Name).
Underscore.js _.merge() Method

04 Aug, 2020
The _.merge() method merges two or more objects starting with the left-most to the rightmost to create a parent mapping object.
Syntax:
_.merge(obj1, obj2,..., objn);

Parameters: This method takes n objects to merge them.
Return Value: This method returns a newly generated merged object.
Note: This will not work in normal JavaScript because it requires the underscore.js contrib library to be installed. 
underscore.js contrib library can be installed using npm install underscore-contrib –save.
Example 1: 
Javascript
// Defining underscore contrib variablevar _ = require('underscore-contrib');   var obj = _.merge({ a: "1" }, { b: "2" }, { c:"3" });;  console.log("Generated Mapping Object: ", obj);
Output:
Generated Mapping Object:  { a: '1', b: '2', c: '3' }

Example 2: if two keys are the same, the generated object will have value for the rightmost key.
Javascript
// Defining underscore contrib variablevar _ = require('underscore-contrib');   var obj = _.merge({ a: "1" }, { a: "2" },                   { b: "2" }, { c:"3" });;  console.log("Generated Mapping Object: ", obj);
Output: 
Generated Mapping Object:  { a: '2', b: '2', c: '3' }

Example 3: If more than one object is the same, the newly generated object will have only one key and value corresponding to those objects.
Javascript
// Defining underscore contrib variablevar _ = require('underscore-contrib');   var obj = _.merge({ a: "1" }, { a: "1" },                   { b: "2" }, { c:"3" });;  console.log("Generated Mapping Object: ", obj);
Output: 
Generated Mapping Object:  { a: '1', b: '2', c: '3' }

Example 4: 
Javascript
// Defining underscore contrib variablevar _ = require('underscore-contrib');   var obj = _.merge({ a: "1",  d: "4"},                   { a: "1" }, { b: "2" },                   { c:"3" });;  console.log("Generated Mapping Object: ", obj);
Output: 
Generated Mapping Object:  { a: '1', d: '4', b: '2', c: '3' }

JavaScript - Underscore.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
LinkedList getLast() Method in Java

02 Jun, 2022
Linked List is a part of the Collection framework present in java.util package. This class is an implementation of the LinkedList data structure which is a linear data structure where the elements are not stored in contiguous locations and every element is a separate object with a data part and. The Java.util.LinkedList.getLast() method is used to fetch or retrieve the last element from a LinkedList or the element present at the tail of the list.
Illustration:
Input : 4 --> 1 --> 5 --> 6 --> 1 --> 3
Output: 3
As we all know that getLast() is one of the methods been there up present inside LinkedList class. It retrieves the last element from the object inside which elements of LinkedList are present. As we know LinkedList is a class been present inside java.util package so and if we do operate the following methods the syntax will look like as shown below as follows:
import java.util.LinkedList;
LinkedList ll = new LinkedList<T>();  
ll.getLast();
In simpler words, if we want to know the last element or the tail of LinkedList then do perform the below check as listed below. It will, later on, be illustrated as an example while implementing.
Syntax: 
LinkedList.getLast();
Return Type: The last element or the element present at the tail of the list.
Example:
Java
// Java Program to Illustrate getLast() method // Importing required classesimport java.io.*;import java.util.LinkedList; // Main classpublic class GFG {     // Main driver method    public static void main(String args[])    {         // Creating an empty LinkedList class object        // Declaring object of string type        LinkedList<String> list = new LinkedList<String>();         // Adding elements in the list        // using add() method        list.add("Geeks");        list.add("for");        list.add("Geeks");        list.add("10");        list.add("20");         // Displaying all elements of LinkedList        System.out.println("LinkedList:" + list);         // Now from these elements procuring        // last element from the list        // using getLast() method        System.out.println("The last element is: "                           + list.getLast());    }}
LinkedList:[Geeks, for, Geeks, 10, 20]
The last element is: 20
 
solankimayank
sweetyty
surinderdawra388
simmytarika5
Java - util package
Java-Collections
Java-Functions
java-LinkedList
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Interfaces in Java
Stream In Java
Collections in Java
Singleton Class in Java
Multidimensional Arrays in Java
Set in Java
Stack Class in Java
Initialize an ArrayList in Java
Introduction to Java
Initializing a List in Java
Python | Split strings and digits from string list

02 Dec, 2019
Sometimes, while working with String list, we can have a problem in which we need to remove the surrounding stray characters or noise from list of digits. This can be in form of Currency prefix, signs of numbers etc. Let’s discuss a way in which this task can be performed.
Method : Using list comprehension + strip() + isdigit() + join()The combination of above functions can be used to perform this task. In this, we strip the stray characters from numbers that are identified from the strings and return the result.
# Python3 code to demonstrate working of# Extract digit from string list # using list comprehension + strip() + isdigit() + join()from itertools import groupby  # initialize list test_list = ["-4", "Rs 25", "5 kg", "+15"]  # printing original list print("The original list : " + str(test_list))  # Extract digit from string list # using list comprehension + strip() + isdigit() + join()res = [''.join(j).strip() for sub in test_list         for k, j in groupby(sub, str.isdigit)]  # printing resultprint("List after removing stray characters : " + str(res))
The original list : ['-4', 'Rs 25', '5 kg', '+15']
List after removing stray characters : ['-', '4', 'Rs', '25', '5', 'kg', '+', '15']

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Python program to check whether a number is Prime or not
HTTP headers | Clear-Site-Data

31 Oct, 2019
The HTTP header Clear-Site-Header is a response-type header. This header is used in deleting the browsing data which is in the requesting website. These browsing data includes cache, cookies, storage and executionContents. It helps the web developers to have an improved level of control over data stored by the browser locally.
Syntax:
Clear-Site-Data: "cache"|"cookies"|"storage"|"executionContexts"|"*"
Note: The data to be deleted, directibves should be given within double quotes (” “). Multiple directives can be given at a time.
Directives: This header accepts four directives mentioned above and described below:
“cache”: It represents that the server wishes to remove locally cached data.
“cookies”: It represents the server wishes to delete all the cookies for the origin of response URL.
“storage:” It represents the server wishes to remove locally stored data.
“executionContents”: It represents the server wishes to remove all the browsing contents for the origin of response URL.
” * “: It represents the server wishes to delete all types of data for the origin of response URL.
Examples:
In this example header wants to delete the cache, cookies, storage and executionContents data.Clear-Site-Data: "cache", "cookies", "storage", "executionContents"
Clear-Site-Data: "cache", "cookies", "storage", "executionContents"
In this example header wants to delete all the data.Clear-Site-Data: " * "
Clear-Site-Data: " * "
Based on the directives mentioned, the corresponding type of data will be removed. To check the Clear-Site-Data go to the Inspect Element->Network click any visible name after that click the header tab if this header is used then it will be visible to you.
Supported Browsers: The browsers compatible with HTTP Clear-Site-Data headers are given below.
Google Chrome
Firefox
Opera
HTTP-headers
Picked
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
REST API (Introduction)
How to set the default value for an HTML <select> element ?
How to create footer to stay at the bottom of a Web page?
How to set input type date in dd-mm-yyyy format using HTML ?
Difference Between PUT and PATCH Request
How to Open URL in New Tab using JavaScript ?