code-rag-bench/online-tutorials huggingface dataset:
std::bitset::to_ullong and std::bitset::to_ulong in C++ STL

13 Aug, 2019
Bitset: A bitset is an array of bool but each Boolean value is not stored separately instead bitset optimizes the space such that each bool takes 1 bit space only, so space taken by bitset bs is less than that of bool bs[N] and vector bs(N). However, a limitation of bitset is, N must be known at compile time, i.e., a constant (this limitation is not there with vector and dynamic array)
std::bitset::to_ullong
This function Converts the contents of the bitset to an unsigned long long integer. The first bit of the bitset corresponds to the least significant digit of the number and the last bit corresponds to the most significant digit.
Syntax:
bit.to_ullong()

Here bit is a number in bits (i.e., 101 for 5)
Parameters:
We are not passing any parameters
Return:
Return the converted integer.
Exceptions:
overflow_error will occur if the value can not be represented in unsigned long long.
Examples:
Input : 1010
Output : 10

Input : 10000001
Output :129

# CODE 1 :
#include <bitset> #include <iostream> #include <limits> using namespace std;   int main() {     bitset<numeric_limits<unsigned long long>::digits> b(10);       cout << b << endl << b.to_ullong();      return 0; }  //Code is improved by Rajnis09
OUTPUT:
0000000000000000000000000000000000000000000000000000000000001010  
10

# CODE 2 :
#include <bitset>#include <iostream>#include <limits>using namespace std;  int main(){    bitset<numeric_limits<unsigned long long>::digits> b(20);      cout << b << endl << b.to_ullong();      return 0;}
OUTPUT:
0000000000000000000000000000000000000000000000000000000000010100 
20

std::bitset::to_ulong
This function Converts the contents of the bitset to an unsigned long integer. The first bit of the bitset corresponds to the least significant digit of the number and the last bit corresponds to the most significant digit.
Syntax:
bit.to_ulong()

Here bit is a number in bits (i.e., 101 for 5)
Parameters:
We are not passing any parameters
Return:
Return the converted integer.
Exceptions associated:
overflow_error will occur if the value can not be represented in unsigned long.
Examples:
Input : 1010

Output : 10

Input : 10000001
Output :129

# CODE 1 :
#include <bitset>#include <iostream>#include <limits>using namespace std;  int main(){    bitset<numeric_limits<unsigned long>::digits> b(10);      cout << b << endl << b.to_ulong();      return 0;}
OUTPUT:
0000000000000000000000000000000000000000000000000000000000001010  
10

# CODE 2 :
#include <bitset>#include <iostream>#include <limits>using namespace std;  int main(){    bitset<numeric_limits<unsigned long>::digits> b(20);      cout << b << endl << b.to_ulong();      return 0;}
OUTPUT:
0000000000000000000000000000000000000000000000000000000000010100 
20

Rajnis09
CPP-bitset
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to iterate through and access the JSON array elements using Rest Assured?

We can iterate through and access the JSON array elements using Rest Assured. First, we shall obtain a Response body which is in JSON format from a request. Then convert it to string.
To obtain JSON array size, we have to use the size method on the JSON array. Then introduce a loop that shall iterate up to the array size. We shall send a GET request via Postman on a mock API, and observe the Response.
Using Rest Assured, let us get the value of the Location field having the values State and zip. They are a part of the JSON array - Location.
Code Implementation
import static io.restassured.RestAssured.given;
import org.testng.annotations.Test;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
public class NewTest {
   @Test
   public void jsonIterateArr() {

      //base URI with Rest Assured class
      RestAssured.baseURI = "https://run.mocky.io/v3";

      //obtain Response from GET request
      Response res = given()
         .when()
         .get("/8ec8f4f7-8e68-4f4b-ad18-4f0940d40bb7");

      //convert JSON to string
      JsonPath j = new JsonPath(res.asString());

      //get values of JSON array after getting array size
      int s = j.getInt("Location.size()");
      for(int i = 0; i < s; i++) {
         String state = j.getString("Location["+i+"].State");
         String zip = j.getString("Location["+i+"].zip");
         System.out.println(state);
         System.out.println(zip);
      }
   }
}
How to Print HashSet Elements in Java?

15 Dec, 2020
In HashSet, duplicates are not allowed. If we are trying to insert duplicates then we won’t get any compile-time or runtime error and the add() method simply returns false.
We can use 2 ways to print HashSet elements:
Using the iterator() method to traverse the set elements and printing it.Directly printing it using a reference variable.
Using the iterator() method to traverse the set elements and printing it.
Directly printing it using a reference variable.
Method 1: By using Cursor which is Iterator.
If we want to get objects one by one from the collection then we should go for the cursor.
We can apply the Iterator concept for any Collection Object and hence it is a Universal Cursor.
By using Iterator we can perform both read and remove operations.
We can create an Iterator object by using the iterator method of Collection Interface.
public Iterator iterator();   //  Iterator method of Collection Interface.
Creating an iterator object
Iterator itr = c.iterator();  // where c is any Collection Object like ArrayList,HashSet etc.
Example:
Java
// Java program to print the elements// of HashSet using iterator cursor  import java.util.*;  class GFG {    public static void main(String[] args)    {          HashSet<Integer> hs = new HashSet<Integer>();        hs.add(5);        hs.add(2);        hs.add(3);        hs.add(6);        hs.add(null);          // print HashSet elements one by one.        // Inserton order in not preserved and it is based        // on hash code of objects.          // creates Iterator oblect.        Iterator itr = hs.iterator();          // check element is present or not. if not loop will        // break.        while (itr.hasNext()) {            System.out.println(itr.next());        }    }}
null
2
3
5
6
Method 2: We can directly print HashSet elements by using the HashSet object reference variable. It will print the complete HashSet object.
Note: If we do not know the hash code, so you can’t decide the order of insertion.
Example:
Java
// Java program to directly print the// elements of HashSet  import java.util.*;  class GFG {    public static void main(String[] args)    {          // create HashSet object        HashSet<String> hs = new HashSet<String>();          // add element in HashSet object        hs.add("B");        hs.add("C");        hs.add("D");        hs.add("A");        hs.add("Z");        hs.add("null");        hs.add("10");          // print HashSet        // we dont't know hash code,        // so we don't know order        // of insertion        System.out.println(hs);    }}
[A, B, C, D, null, Z, 10]
java-hashset
Picked
Technical Scripter 2020
Java
Java Programs
Technical Scripter
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Introduction to Java
Constructors in Java
Exceptions in Java
Generics in Java
Java Programming Examples
Convert Double to Integer in Java
Implementing a Linked List in Java using Class
Factory method design pattern in Java
Java Program to Remove Duplicate Elements From the Array
dc command in Linux with examples

10 Feb, 2022
dc command in Linux is used to evaluate arithmetic expressions. It evaluates expressions in the form of a postfix expression. Entering a number pushes it into the stack and entering an operator evaluates an expression and pushes the result back into the stack. It can evaluate +, -, /, *, %, ^. Different commands can be used to manipulate stack. 
Syntax:  
dc [OPTION] [file ...]
Below table illustrate the different commands and their explanation: 
 
Example 1: 
Example 2: 
 
Note: In second example, the output changes because we changed the output-radix. 
Options: 
 
expression : This command is used to evaluate a particular expression. 
file : This command is used to evaluate the contents of the file. 
help : This command displays help information. 
version: This command is used to display version information. 
sooda367
varshagumber28
sumitgumber28
linux-command
Linux-Shell-Commands
Picked
Technical Scripter 2018
Linux-Unix
Technical Scripter
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
mv command in Linux with examples
chmod command in Linux with examples
nohup Command in Linux with Examples
Introduction to Linux Operating System
Array Basics in Shell Scripting | Set 1
Basic Operators in Shell Scripting
Reverse sum of two arrays in JavaScript

We are required to write a JavaScript function that takes in two arrays of numbers of the same length. The function should return an array with any arbitrary nth element of the array being the sum of nth term from start of first array and nth term from last of second array.
For example −
If the two arrays are −
const arr1 = [34, 5, 3, 3, 1, 6];
const arr2 = [5, 67, 8, 2, 6, 4];
Then the output should be −
const output = [38, 11, 5, 11, 68, 11];
Following is the code −
const arr1 = [34, 5, 3, 3, 1, 6];
const arr2 = [5, 67, 8, 2, 6, 4];
const reverseSum = (arr1, arr2) => {
   const res = [];
   for(let i = 0; i < arr1.length; i++){
      res[i] = (arr1[i]) + (arr2[arr2.length - i - 1] || 0);
   };
   return res;
};
console.log(reverseSum(arr1, arr2));
Following is the output in the console −
[ 38, 11, 5, 11, 68, 11 ]
Perl unpack Function

This function unpacks the binary string STRING using the format specified in TEMPLATE. Basically reverses the operation of pack, returning the list of packed values according to the supplied format.
You can also prefix any format field with a %<number> to indicate that you want a 16-bit checksum of the value of STRING, instead of the value.
Following is the simple syntax for this function −
unpack TEMPLATE, STRING

This function returns the list of unpacked values.
Here is the table which gives values to be used in TEMPLATE.
a
ASCII character string padded with null characters
A
ASCII character string padded with spaces
b
String of bits, lowest first
B
String of bits, highest first
c
A signed character (range usually -128 to 127)
C
An unsigned character (usually 8 bits)
d
A double-precision floating-point number
f
A single-precision floating-point number
h
Hexadecimal string, lowest digit first
H
Hexadecimal string, highest digit first
i
A signed integer
I
An unsigned integer
l
A signed long integer
L
An unsigned long integer
n
A short integer in network order
N
A long integer in network order
p
A pointer to a string
s
A signed short integer
S
An unsigned short integer
u
Convert to uuencode format
v
A short integer in VAX (little-endian) order
V
A long integer in VAX order
x
A null byte
X
Indicates "go back one byte"
@
Fill with nulls (ASCII 0)
Following is the example code showing its basic usage −
#!/usr/bin/perl -w

$bits = pack("c", 65);
# prints A, which is ASCII 65.
print "bits are $bits\n";
$bits = pack( "x" );
# $bits is now a null chracter.
print "bits are $bits\n";
$bits = pack( "sai", 255, "T", 30 );
# creates a seven charcter string on most computers'
print "bits are $bits\n";

@array = unpack( "sai", "$bits" );

#Array now contains three elements: 255, A and 47.
print "Array $array[0]\n";
print "Array $array[1]\n";
print "Array $array[2]\n";
When above code is executed, it produces the following result −
bits are A
bits are 
bits are 􀳦T-
Array 255
Array T
Array 30


    46 Lectures 
     4.5 hours 

 Devi Killada

    11 Lectures 
     1.5 hours 

 Harshit Srivastava

    30 Lectures 
     6 hours 

 TELCOMA Global

    24 Lectures 
     2 hours 

 Mohammad Nauman

    68 Lectures 
     7 hours 

 Stone River ELearning

    58 Lectures 
     6.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
Read and write WAV files using Python (wave)

The wave module in Python's standard library is an easy interface to the audio WAV format. The functions in this module can write audio data in raw format to a file like object and read the attributes of a WAV file.
The file is opened in 'write' or read mode just as with built-in open() function, but with open() function in wave module
This function opens a file to read/write audio data. The function needs two parameters - first the file name and second the mode. The mode can be 'wb' for writing audio data or 'rb' for reading.
obj = wave.open('sound.wav','wb')
A mode of 'rb' returns a Wave_read object, while a mode of 'wb' returns a Wave_write object.
Wave_write object has following methods
Following code creates a WAV file with random short integer bytes of 99999 seconds duration.
import wave, struct, math, random
sampleRate = 44100.0 # hertz
duration = 1.0 # seconds
frequency = 440.0 # hertz
obj = wave.open('sound.wav','w')
obj.setnchannels(1) # mono
obj.setsampwidth(2)
obj.setframerate(sampleRate)
for i in range(99999):
   value = random.randint(-32767, 32767)
   data = struct.pack('<h', value)
   obj.writeframesraw( data )
obj.close()
Following code reads some of the parameters of WAV file.
import wave
obj = wave.open('sound.wav','r')
print( "Number of channels",obj.getnchannels())
print ( "Sample width",obj.getsampwidth())
print ( "Frame rate.",obj.getframerate())
print ("Number of frames",obj.getnframes())
print ( "parameters:",obj.getparams())
obj.close()
Number of channels 1
Sample width 2
Frame rate. 44100
Number of frames 99999
parameters: _wave_params(nchannels=1, sampwidth=2, framerate=44100, nframes=99999, comptype='NONE', compname='not compressed')
Add line break inside a string conditionally in JavaScript

We are required to write a function breakString() that takes in two arguments first the string to be broken and second is a number that represents the threshold count of characters after reaching which we have to repeatedly add line breaks in place of spaces.
So, let’s do it. We will iterate over the with a for loop, we will keep a count that how many
characters have elapsed with inserting a ‘\n’ if the count exceeds the limit and we encounter a
space we replace it with line break in the new string and reset the count to 0 otherwise we keep
inserting the original string characters in the new string and keep increasing the count.
The full code for the same will be −
const text = 'Hey can I call you by your name?';
const breakString = (str, limit) => {
   let brokenString = '';
   for(let i = 0, count = 0; i < str.length; i++){
      if(count >= limit && str[i] === ' '){
         count = 0;
         brokenString += '\n';
      }else{
         count++;
         brokenString += str[i];
      }
   }
   return brokenString;
}
console.log(breakString(text, 4));
Following is the console output −
Hey can
I call
you by
your
name?
C program to count number of vowels and consonants in a String - GeeksforGeeks

25 Nov, 2019
Given a string and write a C program to count the number of vowels and consonants in this string.
Examples:
Input: str = "geeks for geeks"
Output:
Vowels: 5
Consonants: 8

Input: str = "abcdefghijklmnopqrstuvwxyz"
Output:
Vowels: 5
Consonants: 21

Approach:
Take the string as input
Take each character from this string to check
If this character is a vowel, increment the count of vowels
Else increment the count of consonants.
Print the total count of vowels and consonants in the end.
Below is the implementation of the above approach:
// C program to count the number of// vowels and consonants in a string  #include <stdio.h>  // Function to count number// of vowels and consonantvoid count_vowels_and_consonant(char* str){    // Declare the variable vowels and consonant    int vowels = 0, consonants = 0;      int i;    char ch;      // Take each character from this string to check    for (i = 0; str[i] != '\0'; i++) {          ch = str[i];          // If this character is a vowel,        // increment the count of vowels        if (ch == 'a' || ch == 'e'            || ch == 'i' || ch == 'o'            || ch == 'u' || ch == 'A'            || ch == 'E' || ch == 'I'            || ch == 'O' || ch == 'U')            vowels++;          // If this character is a space        // skip it        else if (ch == ' ')            continue;          else            // Else increment the count of consonants            consonants++;    }      // Print the total count of vowels and consonants    printf("\nVowels: %d", vowels);    printf("\nConsonants: %d", consonants);}  // Driver function.int main(){    char* str = "geeks for geeks";    printf("String: %s", str);      count_vowels_and_consonant(str);      return 0;}
String: geeks for geeks
Vowels: 5
Consonants: 8

C-String
C Language
School Programming
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
Multithreading in C
Exception Handling in C++
'this' pointer in C++
Arrow operator -> in C/C++ with Examples
Python Dictionary
Inheritance in C++
Reverse a string in Java
Interfaces in Java
C++ Classes and Objects
Python | sympy.smoothness() method - GeeksforGeeks

05 Sep, 2019
With the help of sympy.smoothness() method, we can find smoothness and power-smoothness of a given number. The smoothness of a number is its largest prime factor and the power-smoothness is its largest divisor raised to its multiplicity.
Syntax:smoothness(n)
Parameter:n – It denotes the number for which the smoothness and power-smoothness is calculated.
Returns:Returns a tuple of smoothness and power-smoothness of the given number.
Example #1:
# import smoothness() method from sympyfrom sympy.ntheory.factor_ import smoothness   n = 64   # Use smoothness() method smoothness_n, power_smoothness_n = smoothness(n)        print("The smoothness and power-smoothness of {} is {} and {} respectively".      format(n, smoothness_n, power_smoothness_n))
Output:
The smoothness and power-smoothness of 64 is 2 and 64 respectively

Example #2:
from sympy.ntheory.factor_ import smoothness   n = 2**4 * 13   # Use smoothness() method smoothness_n, power_smoothness_n = smoothness(n)        print("The smoothness and power-smoothness of {} is {} and {} respectively".      format(n, smoothness_n, power_smoothness_n))
Output:
The smoothness and power-smoothness of 208 is 13 and 16 respectively

Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
Selecting rows in pandas DataFrame based on conditions
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Defaultdict in Python
Python | os.path.join() method
Create a directory in Python
Bar Plot in Matplotlib
Adding middleware in Express in Node.js

Each request in app goes through multiple middleware’s in express. If one of the middleware returns the response it ends there. If any middleware wants to pass the request to next middleware, it uses next() function call at the end of its function call.
Http Request -> Middleware (req, resp, next)-> Middleware(req, res, next)-> Http Response ( res.send() ).
const http = require('http');
const express = require('express');
const app = express();
app.use((req, res,next)=>{
   console.log('first middleware');
});
const server = http.createServer(app);
server.listen(3000);
Middleware’s are added using use function as shown above. Use() function receives three arguments basically request, response and next() function.
The use() function are added before the server create function. Now for adding second middleware −
Running app −
Open browser and navigate to localhost:3000
On terminal console, we will see log messages −
In the first middleware, we used next() function call to pass the http request to next middleware in call stack. Middleware’s generally works as they are defined the file.
Sending response from middleware −
Express provides a send() function to return any type of response e.g. html, text etc. we can still use the old write function as well. Here we don’t requires to set header, express will automatically does that.
app.use((req, res,next)=>{
   console.log('second middleware');
   res.send('<h1> Hello Tutorials Point </h1>');
});
Nodemon will auto restart app on code change −
By default the content type is text/html in express.js . We can override the default header value by using response.setHeader() function.
If we remove next() function call in first middleware −
const http = require('http');
const express = require('express');
const app = express();
app.use((req, res,next)=>{
   console.log('first middleware');
   //next();
   res.send('<h1> first midleware: Hello Tutorials Point </h1>');
});
app.use((req, res,next)=>{
   console.log('second middleware');
   res.send('<h1> second middleware: Hello Tutorials Point </h1>');
});
const server = http.createServer(app);
server.listen(3000);
Note we commented next() function call in first middleware
So our http request will not reach second middleware and we see response from first middleware only.
What is the use of Thread.sleep() method in Java?

The sleep() method is a static method of Thread class and it makes the thread sleep/stop working for a specific amount of time. The sleep() method throws an InterruptedException if a thread is interrupted by other threads, that means Thread.sleep() method must be enclosed within the try and catch blocks or it must be specified with throws clause. Whenever we call the Thread.sleep() method, it can interact with the thread scheduler to put the current thread to a waiting state for a specific period of time. Once the waiting time is over, the thread changes from waiting state to runnable state.
public static void sleep(long milliseconds)
public static void sleep(long milliseconds, int nanoseconds)
The sleep(long milliseconds) method makes a thread to sleep for some specific milliseconds only.
The sleep(long milliseconds, int nanoseconds) method makes a thread to sleep for some specific milliseconds plus nanoseconds.
class UserThread extends Thread {
   public void run() {
      for(int i=1; i <= 5; i++) {
         System.out.println("User Thread");
         try {
            Thread.sleep(1000); // sleep/stop a thread for 1 second
         } catch(InterruptedException e) {
            System.out.println("An Excetion occured: " + e);
         }
      }
   }
}
public class SleepMethodTest {
   public static void main(String args[]) {
      UserThread ut = new UserThread();
      ut.start(); // to start a thread
   }
}
User Thread
User Thread
User Thread
User Thread
User Thread
HTML <hr> Tag - GeeksforGeeks

17 Mar, 2022
The <hr> tag in HTML stands for horizontal rule and is used to insert a horizontal rule or a thematic break in an HTML page to divide or separate document sections. The <hr> tag is an empty tag, and it does not require an end tag.Tag Attributes: The table given below describe the <hr> tag attributes: 
Syntax :  
<hr> ...
Below programs illustrate the <hr> tag in HTML:Example 1:  
HTML
<!DOCTYPE html>  <html>      <body>          <p>There is a horizontal rule below this paragraph.</p>          <!--HTML hr tag is used here-->        <hr>          <p>This is a horizontal rule above this paragraph.</p>      </body>         </html>                    
Output:  
Example 2(hr tag with attributes):  
HTML
<!DOCTYPE html>  <html>      <body>                  <p>Normal horizontal line.</p>                  <!--HTML hr tag is used here-->        <hr>                     <p>Horizontal line with height of 30 pixels</p>          <hr size="30">                     <p>Horizontal line with height of 30 pixels                                       and noshade.</p>          <hr size="30" noshade>             </body>  </html>                    
Output:  
Supported Browsers:  
Google Chrome
Internet Explorer
Firefox
Opera
Safari
 
HTML is the foundation of webpages, is used for webpage development by structuring websites and web apps.You can learn HTML from the ground up by following this HTML Tutorial and HTML Examples.
CSS is the foundation of webpages, is used for webpage development by styling websites and web apps.You can learn CSS from the ground up by following this CSS Tutorial and CSS Examples.
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
shubhamyadav4
HTML-Tags
HTML
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to set the default value for an HTML <select> element ?
How to update Node.js and NPM to next version ?
How to set input type date in dd-mm-yyyy format using HTML ?
Hide or show elements in HTML using display property
Types of CSS (Cascading Style Sheet)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
REST API (Introduction)
How to trim a string using $.trim() in jQuery?

To trim a string in jQuery, use the trim() method. It removes the spaces from starting and end of the string.
The sample string I am using has spaces −
var myStr = "  Hello World    ";
Use the trim() method, 
jQuery.trim(myStr);
The following is an example to trim a string in jQuery −
Live Demo
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("#button1").click(function(){
    var myStr = "  Hello World    ";
    myStr = jQuery.trim(myStr);
    alert(myStr);
  });
});
</script>
</head>
<body>

<button id="button1">Trim</button>

</body>
</html>
What are the special symbols in C language?

In C programming language, generally, the special symbols have some special meaning and they cannot be used for other purposes.
Some of the special symbols that are used in C programming are as follows −
[] () {}, ; * = #
Let’s understand their definitions, which are as follows −
Brackets[] − Opening and closing of brackets are used for array element reference, which indicate single and multidimensional subscripts.
Brackets[] − Opening and closing of brackets are used for array element reference, which indicate single and multidimensional subscripts.
Parentheses() − These special symbols are used for function calls and function parameters.
Parentheses() − These special symbols are used for function calls and function parameters.
Braces{} − Opening and closing of curly braces indicates the start and end of a block of code which contains more than one executable statement.
Braces{} − Opening and closing of curly braces indicates the start and end of a block of code which contains more than one executable statement.
Comma (, ) − It is used to separate more than one statements like separating parameters in function calls.
Comma (, ) − It is used to separate more than one statements like separating parameters in function calls.
Colon(:) − It is an operator which essentially invokes something called as an initialization list.
Colon(:) − It is an operator which essentially invokes something called as an initialization list.
Semicolon(;) − It is called as a statement terminator that indicates the end of one logical entity. That is the reason each individual statement must be ended with a semicolon.
Semicolon(;) − It is called as a statement terminator that indicates the end of one logical entity. That is the reason each individual statement must be ended with a semicolon.
Asterisk (*) − It is used to create a pointer variable.
Asterisk (*) − It is used to create a pointer variable.
Assignment operator(=) − It is used for assigning values.
Assignment operator(=) − It is used for assigning values.
Pre-processor (#) − The pre-processor called as a macro processor is used by the compiler to transform your program before the actual compilation starts.
Pre-processor (#) − The pre-processor called as a macro processor is used by the compiler to transform your program before the actual compilation starts.
The table given below What iss the respective meaning of the special symbols used in the C programming language.
Node.js join() function - GeeksforGeeks

14 Oct, 2021
join() is an array function from Node.js that is used to return a string from the array.
Syntax:
array_name.join(parameter)
Parameter: This function takes a single parameter as per which the join operation has to be performed.
Return type: The function returns the string.
The program below demonstrates the working of the function:Program 1:
function joinDemo(){  var str= arr.join("*");  console.log(str);}var arr=[17, 55, 87, 49, 78];joinDemo();
Output:
17*55*87*49*78
Program 2:
function joinDemo(){  var str= arr.join("");  var str1= arr.join("$");  console.log(str);  console.log(str1);  }var arr=['C','Java','Python'];joinDemo();
Output:
CJavaPython
C$Java$Python
NodeJS-function
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between dependencies, devDependencies and peerDependencies
Node.js Export Module
Mongoose Populate() Method
How to connect Node.js with React.js ?
Mongoose find() Function
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
Blackphish - Phishing tool in Kali Linux - GeeksforGeeks

17 Jun, 2021
Blackphish is a powerful open-source tool Phishing Tool. Blackphish is becoming very popular nowadays that is used to do phishing attacks on Target. Blackphish is easier than Social Engineering Toolkit.  Blackphish contains some templates generated by another tool called Blackphish. Blackphish offers phishing templates web pages for 5 popular sites such as Facebook, Instagram, Google, Snapchat. This tool is very helpful performing phishing attacks.
BlackPhish
Step 1: To install the tool first move to desktop and then install the tool using the following commands.
cd Desktop
git clone https://github.com/iinc0gnit0/BlackPhish
Step 2:  Now move to the directory of the tool using the following command. Then install the tool using the following command.
cd Blackphish
./install.sh
Step 3: The tool has been installed in your system. Now to run the tool use the following command.
sudo python3 blackphish.py
Step 4: Now you can see various options here. Suppose you want to create a phishing page for Instagram so type 1 after that type 3 for localhost you can choose an option according to your requirement.
Step 5: Now open the IP address for the localhost.
Step 6: Open the ip address in the browser.
Step 7: Here you will get the details of the victim.
You can see the phishing page is generated using the tool. Once the user entered his/her id password it will be reflected on the terminal. This is how this simple tool works. You can get credentials using this tool.
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
TCP Server-Client implementation in C
ZIP command in Linux with examples
SORT command in Linux/Unix with examples
tar command in Linux with examples
UDP Server-Client implementation in C
curl command in Linux with Examples
'crontab' in Linux with Examples
Conditional Statements | Shell Script
diff command in Linux with examples
echo command in Linux with Examples
How to Check Which Apache Modules are Enabled or Loaded in Linux ? - GeeksforGeeks

29 Jun, 2021
Apache is designed on the modularity principle, which allows web server operators to install new modules to extend their basic tasks while also improving Apache’s performance.
The Apache HyperText Switch Protocol (HTTP) server has a front end called apcahe2ctl. Its purpose is to assist an administrator with controlling the Apache HTTP daemon’s operation. Use the following command to acquire additional information about apache2 modules –
$ apache2ctl -h
Use the following command to find out which Apache Modules are enabled/loaded in Linux:
$ apache2ctl -M
Enabled/Loaded is another simple approach to acquiring a list of Apache Modules, as seen below —
$ apachectl -t -D DUMP_MODULES
Use the following command to display the list in alphabetical order :-
apachetl -M | sort
Picked
How To
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install FFmpeg on Windows?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Set Git Username and Password in GitBash?
How to create a nested RecyclerView in Android
How to Create and Setup Spring Boot Project in Eclipse IDE?
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
include - Django Template Tags - GeeksforGeeks

05 Feb, 2020
A Django template is a text document or a Python string marked-up using the Django template language. Django being a powerful Batteries included framework provides convenience to rendering data in a template. Django templates not only allow passing data from view to template, but also provides some limited features of programming such as variables, for loops, comments, extends, include etc.This article revolves about how to use include tag in Templates. include tag loads a template and renders it with the current context. This is a way of “including” other templates within a template. The template name can either be a variable or a hard-coded (quoted) string, in either single or double quotes.
{% include "template_name.html" %}

{% include "foo/bar.html" %}
Normally the template name is relative to the template loader’s root directory. A string argument may also be a relative path starting with ./ or ../ as described in the extends tag.
Illustration of How to use include tag in Django templates using an Example. Consider a project named geeksforgeeks having an app named geeks.
Refer to the following articles to check how to create a project and an app in Django.
How to Create a Basic Project using MVT in Django?
How to Create an App in Django ?
Now create a view through which we will access the template,In geeks/views.py,
# import Http Response from djangofrom django.shortcuts import render  # create a functiondef geeks_view(request):      # return response    return render(request, "geeks.html.html")
Create a url path to map to this view. In geeks/urls.py,
from django.urls import path  # importing views from views.pyfrom .views import geeks_view  urlpatterns = [    path('', geeks_view),]
Now we will create three templates to demonstrate include tag. Create a base template in geeks.html,
<html>    <!-- Include header -->    {% include "component1.html" %}      <h4>Body Here</h4>          <!-- Include Footer -->    {% include "component2.html" %}</html>
Create two components in templates/component1.html
<!-- component1.html --><h2> Header Here </h2>>
and templates/component2.html
<!-- component2.html --><h4>Footer here</h4>
Now visit http://127.0.0.1:8000/,
one can pass additional context to the template using keyword arguments:
{% include "name_snippet.html" with person="Jane" greeting="Hello" %}
Django-templates
Python Django
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Enumerate() in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
sum() function in Python
Create a Pandas DataFrame from Lists
How to drop one or multiple columns in Pandas Dataframe
*args and **kwargs in Python
Graph Plotting in Python | Set 1
case - Unix, Linux Command

case - To conditionally perform a command, case will selectively execute the command-list corresponding to the first pattern that matches word. 
case word in [ [(] pattern [| pattern]...) command-list ;;]... esac
The '|' is used to separate multiple patterns, and the ')' operator terminates a pattern list. A list of patterns and an associated command-list is known as a clause. Each clause must be terminated with ';;'. The word undergoes tilde expansion, parameter expansion, command substitution, arithmetic expansion, and quote removal before matching is attempted. Each pattern undergoes tilde expansion, parameter expansion, command substitution, and arithmetic expansion. There can be an arbitrary number of case clauses, each terminated by a ';;'. The first pattern that matches determines the command-list that is executed.
Create a Utility Class to use case.
#casesample
echo -n "Enter the name of an animal: "
read ANIMAL
echo -n "The $ANIMAL has "
case $ANIMAL in
  horse | dog | cat) echo -n "four";;
  man | kangaroo ) echo -n "two";;
  *) echo -n "an unknown number of";;
esac
echo " legs."

Run the utility
$ chmod a+x casesample
$ ./casesample
Enter the name of an animal: dog
The dog has four legs.


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
new and delete operator in C++

The new operator requests for the memory allocation in heap. If the sufficient memory is available, it initializes the memory to the pointer variable and returns its address.
Here is the syntax of new operator in C++ language,
pointer_variable = new datatype;
Here is the syntax to initialize the memory,
pointer_variable = new datatype(value);
Here is the syntax to allocate a block of memory,
pointer_variable = new datatype[size];
Here is an example of new operator in C++ language,
#include <iostream>
using namespace std;
int main () {
   int *ptr1 = NULL;
   ptr1 = new int;
   float *ptr2 = new float(223.324);
   int *ptr3 = new int[28];
   *ptr1 = 28;
   cout << "Value of pointer variable 1 : " << *ptr1 << endl;
   cout << "Value of pointer variable 2 : " << *ptr2 << endl;
   if (!ptr3)
   cout << "Allocation of memory failed\n";
   else {
      for (int i = 10; i < 15; i++)
      ptr3[i] = i+1;
      cout << "Value of store in block of memory: ";
      for (int i = 10; i < 15; i++)
      cout << ptr3[i] << " ";
   }
   return 0;
}
Value of pointer variable 1 : 28
Value of pointer variable 2 : 223.324
Value of store in block of memory: 11 12 13 14 15
The delete operator is used to deallocate the memory. User has privilege to deallocate the created pointer variable by this delete operator.
Here is the syntax of delete operator in C++ language,
delete pointer_variable;
Here is the syntax to delete the block of allocated memory,
delete[ ] pointer_variable;
Here is an example of delete operator in C++ language,
 Live Demo
#include <iostream>
using namespace std;
int main () {
   int *ptr1 = NULL;
   ptr1 = new int;
   float *ptr2 = new float(299.121);
   int *ptr3 = new int[28];
   *ptr1 = 28;
   cout << "Value of pointer variable 1 : " << *ptr1 << endl;
   cout << "Value of pointer variable 2 : " << *ptr2 << endl;
   if (!ptr3)
   cout << "Allocation of memory failed\n";
   else {
      for (int i = 10; i < 15; i++)
      ptr3[i] = i+1;
      cout << "Value of store in block of memory: ";
      for (int i = 10; i < 15; i++)
      cout << ptr3[i] << " ";
   }
   delete ptr1;
   delete ptr2;
   delete[] ptr3;
   return 0;
}
Value of pointer variable 1 : 28
Value of pointer variable 2 : 299.121
Value of store in block of memory: 11 12 13 14 15
Nagios - Commands

A command definition defines a command. Commands include service checks, service notifications, service event handlers, host checks, host notifications, and host event handlers. Command definitions for Nagios are defined in commands.cfg file.
The following is the format for defining of a Command −
define command {
   command_name command_name
   command_line command_line
}

Command name − This directive is used to identify the command. The definitions of contact, host, and service is referenced by command name.
Command line − This directive is used to define what is executed by Nagios when the command is used for service or host checks, notifications, or event handlers.
define command{
   command_name check_ssh
   command_line /usr/lib/nagios/plugins/check_ssh ‘$HOSTADDRESS$’
}
This command will execute the plugin − /usr/libl/nagios/plugins/check_ssh with 1 parameter : '$HOSTADDRESS$'
A very short host definition that would use this check command could be similar to the one shown here −
define host{
   host_name host_tutorial
   address 10.0.0.1
   check_command check_ssh
}

The command definitions tell how to perform host/service checks. The also define how to generate notifications if any issue is identified and to handle any event. There are several commands to perform the checks, such as commands to check if SSH is working properly or not, command to check that database is up and running, command to check if a host is alive or not and many more.
There are commands which tell users what issues are present in the infrastructure. You can create your own custom commands or use any third-party command in Nagios, and they are treated similar to Nagios plugins project, there is no distinction between them.
You can also pass arguments in the command, this give more flexibility in performing the checks. This is how you need to define a command with parameter −
define command {
   command_name check-host-alive-limits
   command_line $USER5$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5
}

The host definition for the above command −
define host {
   host_name system2
   address 10.0.15.1
   check_command check-host-alive-limits!1000.0,70%!5000.0,100%
}

You can run external commands in Nagios by adding them to commands file which is processed by Nagios daemon periodically.
With External commands you can achieve lot many checks while Nagios is running. You can temporarily disable few checks, or force some checks to run immediately, disable notifications temporarily etc. The following is the syntax of external commands in Nagios that must be written in command file −
[time] command_id;command_arguments

You can also check out the list of all external commands that can be used in Nagios here −
https://assets.nagios.com/downloads/nagioscore/docs/externalcmds/
 Print
 Add Notes
 Bookmark this page
Tk - Scrollbar Widget

Scrollbar widget is a scrolling widget that can work without a text or canvas widgets. The syntax for scrollbar widget is shown below.
scrollbar scrollbarName options

The options available for the  scrollbar widget are listed below in table.
-background color
Used to set background color for widget.
-borderwidth width
Used to draw with border in 3D effects.
-orien orientation
Sets the orientation for widget. It can be either horizontal or vertical.
-relief condition
Sets the 3D relief for this widget. The condition may be raised, sunken, flat, ridge, solid, or groove.
-command command
Command links view to scrollbar widget.
A simple example for scrollbar widget is shown below −
#!/usr/bin/wish

grid [tk::listbox .l -yscrollcommand ".s1 set" -xscrollcommand ".s2 set" -height 5 -width
   20] -column 0 -row 0 -sticky nwes
grid [ttk::scrollbar .s1 -command ".l yview" -orient vertical -background yellow
   -borderwidth 5 -relief ridge] -column 1 -row 0 -sticky ns
grid [ttk::scrollbar .s2 -command ".l xview" -orient horizontal -background yellow
   -borderwidth 5 -relief ridge] -column 0 -row 1 -sticky ew

for {set index 0} {$index<100} {incr index} {
   .l insert end "A long line of text for testing scrollbar."
}
When we run the above program, we will get the following output −
 Print
 Add Notes
 Bookmark this page
How to find an element using the “Link Text/Partial Link Text” in Selenium?

We can find an element using the link text or the partial link text in Selenium webdriver. Both these locators can only be applied to elements with the anchor tag.
The link text locator matches the text inside the anchor tag. The partial link text locator matches the text inside the anchor tag partially. NoSuchElementException shall be thrown for both these locators if there is no matching element.
WebElement n =driver.findElement(By.partialLinkText("Coding"));
WebElement l =driver.findElement(By.linkText("Coding Ground"));
Let us find the below highlighted element CODING GROUND on the page −
Code Implementation with linkText
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.concurrent.TimeUnit;
public class LnkTxt{
   public static void main(String[] args) {
      System.setProperty("webdriver.gecko.driver",
         "C:\\Users\\ghs6kor\\Desktop\\Java\\geckodriver.exe");
      WebDriver driver = new FirefoxDriver();
      //implicit wait
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      //URL launch
      driver.get("https://www.tutorialspoint.com/online_dev_tools.htm");
      // identify element with link text
      WebElement n =driver.findElement(By.linkText("CODING GROUND"));
      n.click();
      System.out.println("Current page title : " + driver.getTitle());
      driver.quit();
   }
}
Code Implementation with partialLinkText
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.concurrent.TimeUnit;
public class PartialLnkTxt{
   public static void main(String[] args) {
      System.setProperty("webdriver.gecko.driver",
         "C:\\Users\\ghs6kor\\Desktop\\Java\\geckodriver.exe");
      WebDriver driver = new FirefoxDriver();
      //implicit wait
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      //URL launch
      driver.get("https://www.tutorialspoint.com/online_dev_tools.htm");
      // identify element with partial link text
      WebElement m = driver.findElement(By.partialLinkText("CODING"));
      m.click();
      System.out.println("Current page title : " + driver.getTitle());
      driver.quit();
   }
}
Sum of squares of the first n even numbers in C Program

The sum of squares of the first n even numbers means that, we first find the square and add all them to give the sum.
There are two methods to find the sum of squares of the first n even number
We can use loops to iterate from 1 to n increase number by 1 each time find the square and add it to the sum variable −
#include <iostream>
using namespace std;
int main() {
   int sum = 0, n =12;
   for (int i = 1; i <= n; i++)
      sum += (2 * i) * (2 * i);
   cout <<"Sum of first "<<n<<" natural numbers is "<<sum;
   return 0;
}
Sum of first 12 natural numbers is 2600
The complexity of this program increase by order 0(n). So, for big values of n, code takes time.
To deal with this problem a mathematical formula is derived which is Sum of even natural number is 2n(n+1)(2n+1)/3
#include <iostream>
using namespace std;
int main() {
   int n = 12;
   int sum = (2*n*(n+1)*(2*n+1))/3;
   cout <<"Sum of first "<<n<<" natural numbers is "<<sum;
   return 0;
}
Sum of first 12 natural numbers is 2600