code-rag-bench/online-tutorials huggingface dataset:
C library function - strncat()

The C library function char *strncat(char *dest, const char *src, size_t n) appends the string pointed to by src to the end of the string pointed to by dest up to n characters long.
Following is the declaration for strncat() function.
char *strncat(char *dest, const char *src, size_t n)
dest − This is pointer to the destination array, which should contain a C string, and should be large enough to contain the concatenated resulting string which includes the additional null-character.
dest − This is pointer to the destination array, which should contain a C string, and should be large enough to contain the concatenated resulting string which includes the additional null-character.
src − This is the string to be appended.
src − This is the string to be appended.
n − This is the maximum number of characters to be appended.
n − This is the maximum number of characters to be appended.
This function returns a pointer to the resulting string dest.
The following example shows the usage of strncat() function.
#include <stdio.h>
#include <string.h>

int main () {
   char src[50], dest[50];

   strcpy(src,  "This is source");
   strcpy(dest, "This is destination");

   strncat(dest, src, 15);

   printf("Final destination string : |%s|", dest);
   
   return(0);
}
Let us compile and run the above program that will produce the following result −
Final destination string : |This is destinationThis is source|


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
C Program for Anagram Substring Search

In this problem, we are given two string one text of size n and other a pattern of size m. Our task is to create a program for Anagram substring search.
Here, we have to find all the occurrence of pattern and all its permutations (anagrams) in the text.
Let’s take an example to understand the problem,
text = “xyztrwqyzxfg” pattern = “xyz”
Found at index 0
Found at index 7
To solve this problem, we will have to use an algorithm similar to the Rabin Karp algorithm which is used to check for anagram occurrence by adding the ASCII values of all characters under modulo of a number. and then using a window of characteristics sets and matching the sum.
The solution will require two arrays that will be to store the frequencies of characters in the window of the text as well as the matching pattern. Then we will slide the window by one and match the character frequencies for each widow and print of the matching pattern.
//Program for Anagram Substring Search
 Live Demo
#include <cstring>
#include <iostream>
#define MAX 256
using namespace std;
bool matchPattern(char arr1[], char arr2[]){
   for (int i = 0; i < MAX; i++)
   if (arr1[i] != arr2[i])
      return false;
   return true;
}
void anagramSearch(char* pattern, char* text){
   int M = strlen(pattern);
   int N = strlen(text);
   char patternArray[MAX] = { 0 }, textArray[MAX] = { 0 };
   for (int i = 0; i < M; i++) {
      (patternArray[pattern[i]])++;
      (textArray[text[i]])++;
   }
   for (int i = M; i < N; i++) {
      if (matchPattern(patternArray, textArray))
         printf("\nPattern found at index value : %d", (i-M));
      (textArray[text[i]])++;
      textArray[text[i - M]]--;
   }
   if (matchPattern(patternArray, textArray))
   printf("\nPattern found at index value: %d", (N-M));
}
int main() {
   char text[] = "xyztrwqyzxfg";
   char pattern[] = "xyz";
   printf("Searching Anagram pattern in the string ");
   anagramSearch(pattern, text);
   return 0;
}
Searching Anagram pattern in the string
Pattern found at index value: 0
Pattern found at index value: 7
Check for perfect square without using Math libraries - JavaScript

We are required to write a JavaScript function that takes in a number and returns a boolean based on the fact whether or not the number is a perfect square.
Examples of perfect square numbers −
4, 16, 81, 441, 256, 729, 9801
Let’s write the code for this function −
const num = 81;
const isPerfectSquare = num => {
   let ind = 1;
      while(ind * ind <= num){
         if(ind * ind !== num){
            ind++;
            continue;
         };
      return true;
   };
   return false;
};
console.log(isPerfectSquare(81));
console.log(isPerfectSquare(9801));
console.log(isPerfectSquare(99));
console.log(isPerfectSquare(441));
console.log(isPerfectSquare(7648));
Following is the output in the console −
true
true
false
true
false
How to print all the keys of a dictionary in Python?

Dictionary object possesses keys() method which does this job for us.
>>> D1 = {1:'a', 2:'b',3:'c'}
>>> D1.keys()
dict_keys([1, 2, 3])
>>> list(D1.keys())
   [1, 2, 3]
iterable list object can be traversed using for loop
>>> L1 = list(D1.keys())
>>> for i in L1:
   print (i)
1
2
3
MySQL Tryit Editor v1.0

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

The @SerializedName annotation can be used to serialize a field with a different name instead of an actual field name. We can provide the expected serialized name as an annotation attribute, Gson can make sure to read or write a field with the provided name.
@Retention(value=RUNTIME)
@Target(value={FIELD,METHOD})
public @interface SerializedName
import com.google.gson.*;
import com.google.gson.annotations.*;
public class SerializedNameTest {
   public static void main(String args[]) {
      Gson gson = new GsonBuilder().setPrettyPrinting().create();
      Person person = new Person(115, "Raja Ramesh", "Hyderabad");
      String jsonStr = gson.toJson(person);
      System.out.println(jsonStr);
   }
}
// Person class
class Person {
   @SerializedName("id")
   private int personId;
   @SerializedName("name")
   private String personName;
   private String personAddress;
   public Person(int personId, String personName, String personAddress) {
      this.personId = personId;
      this.personName = personName;
      this.personAddress = personAddress;
   }
   public int getPersonId() {
      return personId;
   }
   public String getPersonName() {
      return personName;
   }
   public String getPersonAddress() {
      return personAddress;
   }
}
{
 "id": 115,
 "name": "Raja Ramesh",
 "personAddress": "Hyderabad"
}
C Program for simple interest - GeeksforGeeks

07 Feb, 2018
Simple interest formula is given by:Simple Interest = (P x T x R)/100Where,P is the principle amountT is the time andR is the rate
Examples:
EXAMPLE1:
Input : P = 10000
        R = 5
        T = 5
Output :2500
We need to find simple interest on 
Rs. 10,000 at the rate of 5% for 5 
units of time.

EXAMPLE2:
Input : P = 3000
        R = 7
        T = 1
Output :210

// CPP program to find simple interest for// given principal amount, time and rate of// interest.#include<iostream>using namespace std;int main(){    // We can change values here for    // different inputs    float P = 1, R = 1, T = 1;      /* Calculate simple interest */    float SI = (P * T * R) / 100;      /* Print the resultant value of SI */    cout << "Simple Interest = " << SI;      return 0;}
Please refer complete article on Program to find simple interest for more details!
C Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C Program to read contents of Whole File
Producer Consumer Problem in C
C program to find the length of a string
Exit codes in C/C++ with Examples
Regular expressions in C
C / C++ Program for Dijkstra's shortest path algorithm | Greedy Algo-7
Conditional wait and signal in multi-threading
Handling multiple clients on server with multithreading using Socket Programming in C/C++
C Hello World Program
Difference between break and continue statement in C
What are circular references in C#?

Circular reference occurs when two or more interdependent resources cause lock condition. This makes the resource unusable.
To handle the problem of circular references in C#, you should use garbage collection. It detects and collects circular references. The garbage collector begins with local and static and it marks each object that can be reached through their children.
Through this, you can handle the issues with circular references.
Let’s say the following classes is in circular reference. Here both of them depends on each other −
public class A {
   B Two;
}

public class B {
   A one;
}
To solve the issue, create an interface −
public interface myInterface {
}

public class A {
   myInterface Two;
}

public class B: myInterface {
   A one;
}
Python os.listdir() Method

Python method listdir() returns a list containing the names of the entries in the directory given by path. The list is in arbitrary order. It does not include the special entries '.' and '..' even if they are present in the directory.
Following is the syntax for listdir() method −
os.listdir(path)

path − This is the directory, which needs to be explored.
path − This is the directory, which needs to be explored.
This method returns a list containing the names of the entries in the directory given by path.
The following example shows the usage of listdir() method.
#!/usr/bin/python

import os, sys

# Open a file
path = "/var/www/html/"
dirs = os.listdir( path )

# This would print all the files and directories
for file in dirs:
   print(file)
When we run above program, it produces following result −
test.htm
stamp
faq.htm
_vti_txt
robots.txt
itemlisting
resumelisting
writing_effective_resume.htm
advertisebusiness.htm
papers
resume


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
HTML <meta> charset Attribute

The charset attribute of the <meta> element is used to specify the character encoding for the HTML document. You can use the charset attribute on <meta> as well as <script> element.
Different charsets include ASCII, ANSI, ISO-8859-1, UTF-8, etc. ISO-8859-1 supports 256 different character codes. ASCII defined 128 different alphanumeric characters. The charset attribute in HTML is used with the <meta> to specify the character encoding.
Let us now see an example to implement the charset attribute of the <meta> element:
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
   <h1>Demo Heading</h1>
   <p>This is demo text.</p>
   <p>We are learning about the charset attribute of the meta element in HTML.</p>
</body>
</html>
In the above example, we have set the charset using the <meta> element:
<meta charset="UTF-8">
How to update many documents with one query in MongoDB?

To update many documents with a single query, use bulkWrite() in MongoDB. Let us create a collection with documents −
> db.demo760.insertOne({id:1,details:{Value1:100,Value2:50}});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5eb0309f5637cd592b2a4aee")
}
> db.demo760.insertOne({id:2,details:{Value1:60,Value2:70}});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5eb030a15637cd592b2a4aef")
}
> db.demo760.insertOne({id:3,details:{Value1:80,Value2:90}});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5eb030a15637cd592b2a4af0")
}
Display all documents from a collection with the help of find() method −
> db.demo760.find();
This will produce the following output −
{ "_id" : ObjectId("5eb0309f5637cd592b2a4aee"), "id" : 1, "details" : { "Value1" : 100, "Value2" : 50 } }
{ "_id" : ObjectId("5eb030a15637cd592b2a4aef"), "id" : 2, "details" : { "Value1" : 60, "Value2" : 70 } }
{ "_id" : ObjectId("5eb030a15637cd592b2a4af0"), "id" : 3, "details" : { "Value1" : 80, "Value2" : 90 } }
Following is the query to update many documents with one query in MongoDB −
> db.demo760.bulkWrite([
...    {
...       updateOne: {
...          filter: {id: 1},
...          update: {$set: {'details.Value1': 900, 'details.Value2': 500}},
...       }
...    },
...    {
...    updateOne: {
...       filter: {id: 2},
...       update: {$set: {'details.Value1': 1000, 'details.Value2': 2000}},
...    },
... }
... ])
{
   "acknowledged" : true,
   "deletedCount" : 0,
   "insertedCount" : 0,
   "matchedCount" : 2,
   "upsertedCount" : 0,
   "insertedIds" : {
   },
   "upsertedIds" : {
   }
}
Display all documents from a collection with the help of find() method −
> db.demo760.find();
This will produce the following output −
{ "_id" : ObjectId("5eb0309f5637cd592b2a4aee"), "id" : 1, "details" : { "Value1" : 900, "Value2" : 500 } }
{ "_id" : ObjectId("5eb030a15637cd592b2a4aef"), "id" : 2, "details" : { "Value1" : 1000, "Value2" : 2000 } }
{ "_id" : ObjectId("5eb030a15637cd592b2a4af0"), "id" : 3, "details" : { "Value1" : 80, "Value2" : 90 } }
How to select domain name from email address in MySQL?

To select domain name from email address, you can use in-built SUBSTRING_INDEX() function from MySQL.
To understand the concept, let us create a table. The following is the query to create a table.
mysql> create table selectDomainNameOnly
   −> (
   −> UserEmailAddress varchar(200)
   −> );
Query OK, 0 rows affected (0.52 sec)
Insert records in the table using insert command. The record will have email-ids from which we need to fetch the domain name. The query is as follows −
mysql> insert into selectDomainNameOnly values('John123@yahoo.com');
Query OK, 1 row affected (0.10 sec)
mysql> insert into selectDomainNameOnly values('234Bob@gmail.com');
Query OK, 1 row affected (0.24 sec)
mysql> insert into selectDomainNameOnly values('Carol23595@hotmail.com');
Query OK, 1 row affected (0.16 sec)
Display all records from table using select statement. The query is as follows −
mysql> select *from selectDomainNameOnly;
The following is the output −
+------------------------+
| UserEmailAddress       |
+------------------------+
| John123@yahoo.com      |
| 234Bob@gmail.com       |
| Carol23595@hotmail.com |
+------------------------+
3 rows in set (0.00 sec)
The following is the query to select only domain name. The query is as follows −
mysql> select (SUBSTRING_INDEX(SUBSTR(UserEmailAddress, INSTR(UserEmailAddress, '@') + 1),'.',1)) as DomainName from selectDomainNameOnly;
The following is the output −
+------------+
| DomainName |
+------------+
| yahoo      |
| gmail      |
| hotmail    |
+------------+
3 rows in set (0.06 sec)
log4j - Logging Levels

The org.apache.log4j.Level levels. You can also define your custom levels by sub-classing the Level class.
A log request of level p in a logger with level q is enabled if p >= q. This rule is at the heart of log4j. It assumes that levels are ordered. For the standard levels, we have ALL < DEBUG < INFO < WARN < ERROR < FATAL < OFF.

The Following example shows how we can filter all our DEBUG and INFO messages. This program uses of logger method setLevel(Level.X) to set a desired logging level:
This example would print all the messages except Debug and Info:
import org.apache.log4j.*;

public class LogClass {
   private static org.apache.log4j.Logger log = Logger.getLogger(LogClass.class);
   
   public static void main(String[] args) {
      log.setLevel(Level.WARN);

      log.trace("Trace Message!");
      log.debug("Debug Message!");
      log.info("Info Message!");
      log.warn("Warn Message!");
      log.error("Error Message!");
      log.fatal("Fatal Message!");
   }
}
When you compile and run the LogClass program, it would generate the following result −
Warn Message!
Error Message!
Fatal Message!

log4j provides you configuration file based level setting which sets you free from changing the source code when you want to change the debugging level.
Following is an example configuration file which would perform the same task as we did using the log.setLevel(Level.WARN) method in the above example.
# Define the root logger with appender file
log = /usr/home/log4j
log4j.rootLogger = WARN, FILE

# Define the file appender
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=${log}/log.out

# Define the layout for file appender
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.conversionPattern=%m%n

Let us now use our following program −
import org.apache.log4j.*;

public class LogClass {

   private static org.apache.log4j.Logger log = Logger.getLogger(LogClass.class);
   
   public static void main(String[] args) {
   
      log.trace("Trace Message!");
      log.debug("Debug Message!");
      log.info("Info Message!");
      log.warn("Warn Message!");
      log.error("Error Message!");
      log.fatal("Fatal Message!");
   }
}
Now compile and run the above program and you would get following result in /usr/home/log4j/log.out file −
Warn Message!
Error Message!
Fatal Message!

 Print
 Add Notes
 Bookmark this page
Hide Matplotlib descriptions in Jupyter notebook

To hide matplotlib descriptions of an instance while calling plot() method, we can take the following steps −
Open Ipython instance.
Open Ipython instance.
import numpy as np
import numpy as np
from matplotlib, import pyplot as plt
from matplotlib, import pyplot as plt
Create points for x, i.e., np.linspace(1, 10, 1000)
Create points for x, i.e., np.linspace(1, 10, 1000)
Now, plot the line using plot() method.
Now, plot the line using plot() method.
To hide the instance, use plt.plot(x); i.e., (with semi-colon)
To hide the instance, use plt.plot(x); i.e., (with semi-colon)
Or, use _ = plt.plot(x)
Or, use _ = plt.plot(x)
In [1]: import numpy as np

In [2]: from matplotlib import pyplot as plt

In [3]: x = np.linspace(1, 10, 1000)

In [4]: plt.plot(x)
Out[4]: [<matplotlib.lines.Line2D at 0x7faa3852fac8>]

In [5]: plt.plot(x);

In [6]: _ = plt.plot(x)

In [7]:
Out[4]: [<matplotlib.lines.Line2D at 0x7faa3852fac8>]
How to make Wind Rose and Polar Bar Charts in Plotly – Python?

01 Oct, 2020
A Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library.
The wind rose chart are graphical charts that show the speed and direction of winds at a location over a period of time. This chart is represented in circular format and the circle indicates the amount of time that the wind blows from a particular direction. The wind rose chart is also known as the polar bar chart.
In plotly, a wind rose chart can be made by using the go.Barpolar() method of graph_object class or by px.bar_polar() method of express class.
Syntax: plotly.graph_objects.Barpolar(arg=None,dr=None, dtheta=None,r=None,theta=None)
Syntax: plotly.express.bar_polar(data_frame=None, r=None, theta=None, color=None,)
Example 1:
Python3
import plotly.express as px  # using the wind datasetdf = px.data.wind()  fig = px.bar_polar(df, r="strength", theta="direction",                   color="frequency",)fig.show()
Output:
Example 2:
Python3
import plotly.express as px    df = px.data.tips()  fig = px.bar_polar(df, r="total_bill", theta="time",                   color="sex",)  fig.show()
Output:
Example 3:
Python3
import plotly.graph_objects as go  fig = go.Figure()  fig.add_trace(go.Barpolar(    r=[10, 20, 30, 40],    name='Wind 1',))  fig.add_trace(go.Barpolar(    r=[40, 20, 50, 10],    name='Wind 2',))  fig.show()
Output:
Python-Plotly
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Orthogonal and Orthonormal Vectors in Linear Algebra

01 Apr, 2022
Orthogonal Vectors: Two vectors are orthogonal to each other when their dot product is 0. How do we define the dot product? Dot product(scalar product) of two n-dimensional vectors A and B, is given by this expression.Thus the vectors A and B are orthogonal to each other if and only ifNote: In a compact form the above expression can be written as (A^T)B. Example: Consider the vectors v1 and v2 in 3D space.Taking the dot product of the vectors.Hence the vectors are orthogonal to each other. Code: Python program to illustrate orthogonal vectors. 
Python3
# A python program to illustrate orthogonal vector  # Import numpy moduleimport numpy  # Taking two vectorsv1 = [[1, -2, 4]]v2 = [[2, 5, 2]]  # Transpose of v1transposeOfV1 = numpy.transpose(v1)  # Matrix multiplication of both vectorsresult = numpy.dot(v2, transposeOfV1)print("Result  = ", result)  # This code is contributed by Amiya Rout
Output:
Result = [[0]]
Unit Vector: Let’s consider a vector A. The unit vector of the vector A may be defined asLet’s understand this by taking an example. Consider a vector A in 2D space.The magnitude of A is given bySo the unit vector of A can be calculated asProperties of unit vector:
Unit vectors are used to define directions in a coordinate system.
Any vectors can be written as a product of a unit vector and a scalar magnitude.
Orthonormal vectors: These are the vectors with unit magnitude. Now, take the same 2 vectors which are orthogonal to each other and you know that when I take a dot product between these 2 vectors it is going to 0. So If we also impose the condition that we want each of these vectors to have unit magnitude then what we could possibly do is by taking this vector and then divide this vector by the magnitude of this vector as we see in the unit vector. Now we can write v1 and v2 asSo what we do is we have taken the vectors from the previous example and converted them into unit vectors by dividing them by their magnitudes. So, these vectors will still be orthogonal to each other and now individually they also have unit magnitude. Such vectors are known as orthonormal vectors. Note: All orthonormal vectors are orthogonal by the definition itself.
saurabh1990aror
Engineering Mathematics
Mathematical
Python
Mathematical
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Count of Matching i, j index elements

17 Dec, 2019
Sometimes, while programming, we can have a problem in which we need to check for ith and jth character of each string. We may require to extract count of all strings with similar ith and jth characters. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using loopThis is brute force method by which this task can be performed. In this, iterate each element of list and check for each string’s ith and jth character and increase the counter in case we find a match.
# Python3 code to demonstrate working of# Count of Matching i, j index elements# Using loop  # initialize list test_list = ['geeks', 'beke', 'treat', 'neke']  # printing original list print("The original list : " + str(test_list))  # initialize i i = 1  # initialize j j = 3   # Count of Matching i, j index elements# Using loopcount = 0for ele in test_list:    if ele[i] == ele[j]:        count = count + 1  # printing resultprint("Total Strings with similar ith and jth elements : " + str(count))
The original list : ['geeks', 'beke', 'treat', 'neke']
Total Strings with similar ith and jth elements : 2

 
Method #2 : Using sum() + generator expressionThis is one liner alternative to perform this task. In this, we perform the task of iteration using generator expression and summation using sum().
# Python3 code to demonstrate working of# Count of Matching i, j index elements# Using sum() + generator expression  # initialize list test_list = ['geeks', 'beke', 'treat', 'neke']  # printing original list print("The original list : " + str(test_list))  # initialize i i = 1  # initialize j j = 3   # Count of Matching i, j index elements# Using sum() + generator expressionres = sum(1 for ele in test_list if ele[i] == ele[j])  # printing resultprint("Total Strings with similar ith and jth elements : " + str(res))
The original list : ['geeks', 'beke', 'treat', 'neke']
Total Strings with similar ith and jth elements : 2

Python list-programs
Python
Python Programs
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
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Python | Convert string dictionary to dictionary
What is Sublist3r and How to Use it?

15 Jul, 2020
Sublister is a tool designed in python and uses OSINT in order to enumerate subdomains of websites. It helps pen-testers in collecting and gathering subdomains for a domain which is their target. In order to fetch the accurate results, sublilster uses many search engines like Google, Yahoo, etc. and even tools like Netcraft, Virustotal, etc.
1. To install sublister you can clone the Github repository and use it. To do so you can follow the command 
git clone https://github.com/aboul3la/Sublist3r.git

2. Once the process is done move to the seblister directory 
cd sublist3r

 
3. Now we need to check for dependencies, sublist3r depends on requests, dnspython, and argparse python modules. These dependencies can be installed using requirements.txt file:  
pip install -r requirements.txt

 
You can even manually install all the required modules.
Requests module: 
sudo pip install requests

dnspython module 
sudo pip install dnspython

argparse module 
sudo pip install argparse

 
4. To run the tool, Enter the following command in the terminal.
./sublist3r.py

While running tool if you get any errors like for example dns.resolver module not found or dns.message module not found then it is because you might be running tool on python version 2.7 and installed dnspython module in python 3 version, so it will be better if you use python pip instead of pip3 to solve these errors. 
5. Now our tool is working in the current directory and every time we will try to run it then we need to go into the directory and run it, so now we will make a symbolic link so that we can access it from any directory we are in.  
sudo ln -sfv /opt/Sublist3r/sublist3r.py /usr/bin/sublist3r

 
Usage:  
Example:To list the subdomains of a domain enter the following command in Linux and replace “kali.org” with the website you want to list the subdomains of.
sublist3r -v -d kali.org -t 5 -e bing -o -/Desktop/subresult.txt

Where -d stands for domain listing and -v will verbose the output and tell from where it is getting the results. The fetch results will be saved in subresult.txt file in the desktop directory and the number of threads will be 5 using bing as a search engine.  
As you can see, the above command lists all the domains and subdomains related to kali.org and hence make it easy for us to look for the subdomains of a website.
GBlog
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GEEK-O-LYMPICS 2022 - May The Geeks Force Be With You!
Geek Streak - 24 Days POTD Challenge
How to Learn Data Science in 10 weeks?
What is Hashing | A Complete Tutorial
What is Data Structure: Types, Classifications and Applications
Sed Command in Linux/Unix with examples
AWK command in Unix/Linux with examples
grep command in Unix/Linux
cut command in Linux with examples
cp command in Linux with examples
Storage Classes and Type Qualifiers in C- GeeksQuiz

09 Sep, 2021
Which of the following is not a storage class specifier in C? 
auto 
register 
static 
extern 
volatile 
volatile is not a storage class specifier. volatile and const are type qualifiers.
fun() called first time: num = 16 // for loop initialization done;


In test condition, compiler checks for non zero value

fun() called again : num = 15

printf("%d \n", fun());:num=14 ->printed

Increment/decrement condition check

fun(); called again : num = 13

----------------

fun() called second time: num: 13 

In test condition,compiler checks for non zero value

fun() called again : num = 12

printf("%d \n", fun());:num=11 ->printed

fun(); called again : num = 10

--------

fun() called second time : num = 10 

In test condition,compiler checks for non zero value

fun() called again : num = 9

printf("%d \n", fun());:num=8 ->printed

fun(); called again   : num = 7

--------------------------------

fun() called second time: num = 7

In test condition,compiler checks for non zero value

fun() called again : num = 6

printf("%d \n", fun());:num=5 ->printed

fun(); called again   : num = 4

-----------

fun() called second time: num: 4 

In test condition,compiler checks for non zero value

fun() called again : num = 3

printf("%d \n", fun());:num=2 ->printed

fun(); called again   : num = 1

----------

fun() called second time: num: 1 

In test condition,compiler checks for non zero value

fun() called again : num = 0 => STOP 
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Must Do Coding Questions for Companies like Amazon, Microsoft, Adobe, ...
Must Do Coding Questions for Product Based Companies
Split given String into substrings of size K by filling elements
SDE SHEET - A Complete Guide for SDE Preparation
DSA Sheet by Love Babbar
Java Threads
Top 20 Puzzles Commonly Asked During SDE Interviews
Software Testing Metrics, its Types and Example
Software Testing - Boundary Value Analysis
TCS NQT Coding Sheet
How to Zoom in/Zoom out using React-PDF in ReactJS ?

01 Jun, 2021
We can easily do zoom in / zoom out using React-PDF in ReactJS by passing a prop named scale inside <page /> component. Scale prop takes value only in a decimal form that means even if you want to pass an integer value you should put decimal after it. A value greater than 1 will zoom in on the page and a value less than 1 will zoom out the page.
Syntax:
<page scale = {value} />
Example 1: When you want to pass an integer value to scale.
<Page width={900} scale={30.0} className="page" pageNumber={1} />
Example 2: When you want to pass decimal value to scale.
<Page width={300} scale={0.5} className="page" pageNumber={1} />
Creating React Application And Installing Module:
Step 1: Create a React application using the following command:npx create-react-app pdfapp
Step 1: Create a React application using the following command:
npx create-react-app pdfapp
Step 2: After creating your project folder i.e. pdfapp, move to it using the following command:cd pdfapp
Step 2: After creating your project folder i.e. pdfapp, move to it using the following command:
cd pdfapp
Step 3: After creating the ReactJS application, Install the required module using the following command:npm install react-pdf
Step 3: After creating the ReactJS application, Install the required module using the following command:
npm install react-pdf
Step 4: Add a sample PDF file in your src folder, like here we have added sample.pdf as shown in Project Structure.
Step 4: Add a sample PDF file in your src folder, like here we have added sample.pdf as shown in Project Structure.
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';import { Document,Page } from 'react-pdf/dist/esm/entry.webpack';  // Importing your sample PDFimport pdfFile from './sample.pdf'  // Defining our App Componentconst App = () => {    // Returning our JSX code  return <>    <div>      <Document file={pdfFile}>        <Page scale={2.0} pageNumber={1} />      </Document>    </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:
Sample.pdf as Output
Reference: https://www.npmjs.com/package/react-pdf
Picked
React-Modules
React-Questions
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Axios in React: A Guide for Beginners
ReactJS useNavigate() Hook
How to install bootstrap in React.js ?
How to create a multi-page website using React.js ?
How to do crud operations in ReactJS ?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
Differences between Functional Components and Class Components in React
Node.js crypto.createHmac() Method

27 May, 2022
The crypto.createHmac() method is used to create an Hmac object that uses the stated ‘algorithm’ and ‘key’. Syntax:
crypto.createHmac( algorithm, key, options )
Parameters: This method accept three parameters as mentioned above and described below:
algorithm: It is dependent on the accessible algorithms which are favored by the version of OpenSSL on the platform. It returns string. The examples are sha256, sha512, etc.
key: It is the HMAC key which is used to create the cryptographic HMAC hash. It returns string, Buffer, TypedArray, DataView, or KeyObject. And if it is a KeyObject, then its type must be secret.
options: It is optional parameter and used to control stream behavior. It returns an object.
Return Type: It returns Hmac object. Below examples illustrate the use of crypto.createHmac() method in Node.js: Example 1: 
javascript
// Node.js program to demonstrate the    // crypto.createHmac() method // Includes crypto moduleconst crypto = require('crypto'); // Defining keyconst secret = 'GfG'; // Calling createHmac methodconst hash = crypto.createHmac('sha256', secret)                                       // updating data                   .update('GeeksforGeeks')                    // Encoding to be used                   .digest('hex'); // Displays outputconsole.log(hash);
Output:
a08116905e92633e4f30eefd1276206b259305c8783642fc5b7f51c089187939
Example 2: 
javascript
// Node.js program to demonstrate the    // crypto.createHmac() method   // Defining myfileconst myfile = process.argv[1];   // Includes crypto and  fs moduleconst crypto = require('crypto');const fs = require('fs');   // Creating Hmacconst creathmac = crypto.createHmac('sha1', 'CS-Portal!');   // Creating read streamconst readfile = fs.createReadStream(myfile);   readfile.on('readable', () => {     // Calling read method to read data  const data = readfile.read();  if (data)           // Updating    creathmac.update(data);  else   {    // Encoding and displaying filename    console.log("The hmac object returns:",    `${creathmac.digest('hex')} ${myfile}`);  }});console.log("Program done!");console.log();
Output:
Program done!
The hmac object returns: 4605d44703c2620fc2574c9a9216bd3267457324 /run_dir/interp.js
Reference: https://nodejs.org/api/crypto.html#crypto_crypto_createhmac_algorithm_key_options
vinayedula
Node.js-crypto-module
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to add a colored border to a button with CSS?

To add colored border, use the CSS border property.
You can try to run the following code to add a colored border.
<!DOCTYPE html>
<html>
   <head>
      <style>
         .button {
            background-color: yellow;
            color: black;
            text-align: center;
            font-size: 15px;
            padding: 20px;
            border-radius: 15px;
            border: 3px dashed blue;
         }
      </style>
   </head>
   <body>
      <h2>Result</h2>
      <p>Click below for result:</p>
      <button class = "button">Result</button>
   </body>
</html>
Polymorphism in Java

Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.
Any Java object that can pass more than one IS-A test is considered to be polymorphic. In Java, all Java objects are polymorphic since any object will pass the IS-A test for their own type and for the class Object.
It is important to know that the only possible way to access an object is through a reference variable. A reference variable can be of only one type. Once declared, the type of a reference variable cannot be changed.
The reference variable can be reassigned to other objects provided that it is not declared final. The type of the reference variable would determine the methods that it can invoke on the object.
A reference variable can refer to any object of its declared type or any subtype of its declared type. A reference variable can be declared as a class or interface type.
Let us look at an example.
public                  interface                             Vegetarian{}
public                     class                                  Animal{}
public class Deer extends Animal implements Vegetarian{}
Now, the Deer class is considered to be polymorphic since this has multiple inheritances. Following are true for the above examples −
A Deer IS-A Animal
A Deer IS-A Vegetarian
A Deer IS-A Deer
A Deer IS-A Object
When we apply the reference variable facts to a Deer object reference, the following declarations are legal −
Deer            d               =         new                      Deer();
Animal          a               =                                       d;
Vegetarian      v               =                                       d;
Object          o               =                                       d;
All the reference variables d, a, v, o refer to the same Deer object in the heap.
Java Examples - Collection Size

How to get size of a collection ?
Following example shows how to get the size of a collection by the use of collection.add() to add new data and collection.size() to get the size of the collection of Collections class.
import java.util.*;

public class CollectionTest {
   public static void main(String [] args) {   
      System.out.println( "Collection Example!\n" ); 
      int size;
      HashSet <String>collection = new HashSet <String>();
      String str1 = "Yellow", str2 = "White", str3 = "Green", str4 = "Blue";  
      Iterator iterator;
      collection.add(str1);    
      collection.add(str2);   
      collection.add(str3);   
      collection.add(str4);
      System.out.print("Collection data: ");  
      iterator = collection.iterator();     
      
      while (iterator.hasNext()){
         System.out.print(iterator.next() + " ");  
      }
      System.out.println();
      size = collection.size();
      
      if (collection.isEmpty()){
         System.out.println("Collection is empty");
      } else {
         System.out.println( "Collection size: " + size);
      }
      System.out.println();
   }
}
The above code sample will produce the following result.
Collection Example!

Collection data: Blue White Green Yellow
Collection size: 4

 Print
 Add Notes
 Bookmark this page
What is $(document).ready() equivalent in JavaScript?

In jQuery, if you want an event to work on your page, you should call it inside the $(document).ready() function. Everything inside it will load as soon as the DOM is loaded and before the page contents are loaded.
$(document).ready(function() {
   alert(“Document loaded successful!");
});
In JavaScript, to achieve the same result like $(document).ready, try the following code −
<html>
   <body>
      <script>
         var loader = setInterval(function () {
            if(document.readyState !== "complete") return;
            clearInterval(loader);
            alert(“Document loaded successful!");
            // document.write("Document loaded successful!");
         }, 300);
      </script>
   </body>
</html>
Java Regular Expressions

A regular expression is a sequence of characters that forms a search pattern.
When you search for data in a text, you can use this search pattern to describe what you
are searching for.
A regular expression can be a single character, or a more complicated pattern.
Regular expressions can be used to perform all types of text search and text replace
operations.
Java does not have a built-in Regular Expression class, but we can import the java.util.regex 
package to work with regular expressions. The package includes the following 
classes:
Pattern Class - Defines a pattern (to be used in a search)
Matcher Class - Used to search for the 
pattern
PatternSyntaxException Class - Indicates syntax error in a regular 
expression pattern
Find out if there are any occurrences of the word "w3schools" in a sentence:
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
  public static void main(String[] args) {
    Pattern pattern = Pattern.compile("w3schools", Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher("Visit W3Schools!");
    boolean matchFound = matcher.find();
    if(matchFound) {
      System.out.println("Match found");
    } else {
      System.out.println("Match not found");
    }
  }
}
// Outputs Match found


Try it Yourself »

In this example, The word "w3schools" is being searched for in a sentence.
First, the pattern is created using the Pattern.compile() method. The first parameter
indicates which pattern is being searched for and the second parameter has a flag to
indicates that the search should be case-insensitive. The second parameter is optional.
The matcher() method is used to search for the pattern in a string. It returns a Matcher
object which contains information about the search that was performed.
The find() method returns true if the pattern was found in the string and false if it was not
found.
Flags in the compile() method change how the search is performed. Here are a few of
them:
Pattern.CASE_INSENSITIVE - The case of letters will be ignored when performing
a search.
Pattern.LITERAL - Special characters in the pattern will not have any special
meaning and will be treated as ordinary characters when performing a search.
Pattern.UNICODE_CASE - Use it together with the CASE_INSENSITIVE flag to
also ignore the case of letters outside of the English alphabet
The first parameter of the Pattern.compile() method is the pattern. It describes what
is being searched for.
Brackets are used to find a range of characters:
Metacharacters are characters with a special meaning:
Quantifiers define quantities:
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
What is the conditional operator ?: in Java?

The conditional operator is also known as the ternary operator. This operator consists of three operands and is used to evaluate Boolean expressions. The goal of the operator is to decide; which value should be assigned to the variable. The operator is written as:
variable x = (expression)? value if true: value if false
public class Test {
   public static void main(String args[]) {
      int a, b;
      a = 10;
      b = (a == 1) ? 20: 30;
      System.out.println("Value of b is: " + b);
      b = (a == 10) ? 20: 30;
      System.out.println(“Value of b is: " + b);
   }
}
Value of b is: 30
Value of b is: 20
HTML5 Canvas and select / drag-and-drop features in a JS library?

If you want to use HTML5 canvas to draw shapes, texts and curves and also want to attach traditional DOM events like onClick or drag and drop functions, a crossbar framework Raphael is used for doing drag and drop or touch events.
This technology uses SVG and XML for older versions of IE.  Drag and drag using HTML is shown below.  
<!DOCTYPE html>
<html lang = "en">
   <head>
      <meta charset = "utf-8">
         <title>Raphaël · Drag-n-drop</title>
         <link rel = "stylesheet" href = "demo.css" type = "text/css" media = "screen">
         <meta name = "apple-mobile-web-app-capable" content = "yes">
         <link rel = "apple-touch-icon-precomposed" href = "/Raphael.png">
         <link rel = "stylesheet" href = "demo-print.css" type = "text/css" media = "print">
         <script src = "raphael.js"></script>
         <script>
            window.onload = function () {
               var R = Raphael(0, 0, "100%", "100%"),
               r = R.circle(100, 100, 50).attr({fill: "hsb(0, 1, 1)", stroke: "none", opacity: .5}),
               g = R.circle(210, 100, 50).attr({fill: "hsb(.3, 1, 1)", stroke: "none", opacity: .5}),
               b = R.circle(320, 100, 50).attr({fill: "hsb(.6, 1, 1)", stroke: "none", opacity: .5}),
               p = R.circle(430, 100, 50).attr({fill: "hsb(.8, 1, 1)", stroke: "none", opacity: .5});
            var start = function () {
               this.ox = this.attr("cx");
               this.oy = this.attr("cy");
               this.animate({r: 70, opacity: .25}, 500, ">");
            },
            move = function (dx, dy) {
               this.attr({cx: this.ox + dx, cy: this.oy + dy});
            },
            up = function () {
               this.animate({r: 50, opacity: .5}, 500, ">");
            };
            R.set(r, g, b, p).drag(move, start, up);
         };
      </script>
   </head>
   <body>
      <div id = "holder"></div>
      <p id = "copy">Demo of <a href = "http://raphaeljs.com/">Raphaël</a>— JavaScript Vector Library</p>
   </body>
</html>
array::size() in C++ STL - GeeksforGeeks

15 Jan, 2018
Array classes are generally more efficient, light-weight and reliable than C-style arrays. The introduction of array class from C++11 has offered a better alternative for C-style arrays.
size() function is used to return the size of the list container or the number of elements in the list container.
Syntax :
arrayname.size()
Parameters :
No parameters are passed.
Returns :
Number of elements in the container.
Examples:
Input  : myarray{1, 2, 3, 4, 5};
         myarray.size();
Output : 5

Input  : myarray{};
         myarray.size();
Output : 0
Errors and Exceptions
1. It has a no exception throw guarantee.2. Shows error when a parameter is passed.
// CPP program to illustrate// Implementation of size() function#include <iostream>#include <array>using namespace std;  int main(){    array<int,5> myarray{ 1, 2, 3, 4, 5 };    cout << myarray.size();    return 0;}
Output:
5
cpp-array
STL
C++
Misc
Misc
Misc
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Inheritance in C++
Map in C++ Standard Template Library (STL)
C++ Classes and Objects
Bitwise Operators in C/C++
Operator Overloading in C++
Top 10 algorithms in Interview Questions
vector::push_back() and vector::pop_back() in C++ STL
Overview of Data Structures | Set 1 (Linear Data Structures)
How to write Regular Expressions?
fgets() and gets() in C language