code-rag-bench/online-tutorials huggingface dataset:
C/C++ program to shutdown a system - GeeksforGeeks

07 Nov, 2019
How to shutdown your computer in Linux and/or Windows?
The idea is to use system() in C. This function is used to invoke operating system commands from C program.
Linux OS:
// C program to shutdown in Linux#include <stdio.h>#include <stdlib.h>  int main(){   // Running Linux OS command using system   system("shutdown -P now");       return 0;}
 Windows OS:
Shutdown/ Log off/ Restart a Windows OS
We will make use of system() from < stdlib.h > to perform a system operation with the help of a C program.To perform any of the afore-mentioned system operation we will code as:
#include <stdio.h>#include <stdlib.h>  int main(){  system("c:\\windows\\system32\\shutdown /i");  return 0;}
The argument to the system function is the path to OS and /i is one of the entity from the vast options available to us.To view the options, we run cmd and type:
C:\Users\User>shutdown

The shutdown command presents us with a list of options available for us.These are :To perform different operations, we just replace the last “/path” in system() argument.The common operations are:
Shutdown
system("c:\\windows\\system32\\shutdown /s");
Restart
system("c:\\windows\\system32\\shutdown /r");
Logoff
system("c:\\windows\\system32\\shutdown /l");
This article is contributed by Sahil Chhabra and Amartya Ranjan Saikia. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
CPP-Library
cpp-puzzle
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Sorting a vector 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)
Inline Functions in C++
Array of Strings in C++ (5 Different Ways to Create)
Convert string to char array in C++
jQuery | removeAttr() with Examples - GeeksforGeeks

03 Aug, 2021
The removeAttr() method is an inbuilt method in jQuery which is used to remove one or more attributes from the selected elements.
Syntax:
$(selector).removeAttr(attribute)
Parameters: This function accepts single parameter attribute which is mandatory. It is used to specify one or more attributes to remove. Several attributes can be separated using space operator.
Return Value: This method returns the selected element with the removed attribute.
Below example illustrates the removeAttr() method in jQuery:
Example:
<!DOCTYPE html><html>   <head>       <title>The removeAttr Method</title>       <script src=       "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">       </script>                <!-- jQuery code to show the working of this method -->       <script>            $(document).ready(function() {            $("button").click(function() {                 $("p").removeAttr("style");             });         });      </script>      <style>         div {             width: 300px;             min-height: 150px;             border: 2px solid green;             padding: 20px;             text-align:center;         }      </style>   </head>   <body>      <div>         <!-- click on the any of the paragraph         and see the change -->         <p style="font-size:35px;font-weight:bold;                       color:green;">Welcome to</p>         <p style="font-size:35px;font-weight:bold;                  color:green;">GeeksforGeeks!.</p>         <button>Click Here!</button>      </div>   </body></html>
Output:
jQuery is an open source JavaScript library that simplifies the interactions between an HTML/CSS document, It is widely famous with it’s philosophy of “Write less, do more”.You can learn jQuery from the ground up by following this jQuery Tutorial and jQuery Examples.
jQuery-HTML/CSS
JavaScript
JQuery
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
JQuery | Set the value of an input text field
Form validation using jQuery
How to change the background color after clicking the button in JavaScript ?
How to fetch data from JSON file and display in HTML table using jQuery ?
How to Dynamically Add/Remove Table Rows using jQuery ?
PyQtGraph - Extensive Examples - GeeksforGeeks

24 Sep, 2020
In this article we will see how we can access the PyQtGraph extensive examples. PyQtGraph is a graphics and user interface library for Python that provides functionality commonly required in designing and science applications. Its primary goals are to provide fast, interactive graphics for displaying data (plots, video, etc.) and second is to provide tools to aid in rapid application development (for example, property trees such as used in Qt Designer).
PyQtGraph includes an extensive set of examples which can be accessed by the import pyqtgraph.examples module
In order to do this we use run method with the pyqtgraph.examples
Syntax : examples.run()
Argument : It takes no argument
Return : It returns None
Below is the implementation
# importing the pyqtgraph.examples moduleimport pyqtgraph.examples  # run this examplespyqtgraph.examples.run()
Output :
when we run this code this window appears which has lots of options, on the left hand side we have the basic functions and on main screen it shows the code and explanation of the widget/function and on the lower left corner we have the option to try the example
Now lets traverse the fields on the left side and see how the example will work
We can try as many examples anytime for better understanding of the PyQtGraph module
Python-gui
Python-PyQtGraph
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Defaultdict in Python
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
Python - Maximum column values in mixed length 2D List - GeeksforGeeks

29 Dec, 2019
The usual list of list, unlike conventional C type Matrix, can allow the nested list of lists with variable lengths, and when we require the maximizations of its columns, the uneven length of rows may lead to some elements in that elements to be absent and if not handled correctly, may throw exception. Let’s discuss certain ways in which this problem can be performed in error free manner.
Method #1 : Using max() + filter() + map() + list comprehensionThe combination of above three function combined with list comprehension can help us perform this particular task, the max function helps to perform the maximization, filter allows us to check for the present elements and all rows are combined using the map function. Works only with python 2.
# Python code to demonstrate # Maximum column values mixed length 2D List# using max() + filter() + map() + list comprehension  # initializing list of liststest_list = [[1, 5, 3], [4], [9, 8]]  # printing original list print ("The original list is : " + str(test_list))  # using max() + filter() + map() + list comprehension# Maximum column values mixed length 2D Listres = [max(filter(None, j)) for j in map(None, *test_list)]  # printing resultprint ("The maximization of columns is : " + str(res))
The original list is : [[1, 5, 3], [4], [9, 8]]
The maximization of columns is : [9, 8, 3]

 
Method #2 : Using list comprehension + max() + zip_longest()If one desires not to play with the None values, one can opt for this method to resolve this particular problem. The zip_longest function helps to fill the not present column with 0 so that it does not has to handle the void of elements not present.
# Python3 code to demonstrate # Maximum column values mixed length 2D List# using list comprehension + max() + zip_longest()import itertools  # initializing list of liststest_list = [[1, 5, 3], [4], [9, 8]]  # printing original list print ("The original list is : " + str(test_list))  # using list comprehension + max() + zip_longest()# Maximum column values mixed length 2D Listres = [max(i) for i in itertools.zip_longest(*test_list, fillvalue = 0)]  # printing resultprint ("The maximization of columns is : " + str(res))
The original list is : [[1, 5, 3], [4], [9, 8]]
The maximization of columns is : [9, 8, 3]

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Python | Pandas Index.insert() - GeeksforGeeks

17 Dec, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas Index.insert() function make new Index inserting new item at location. This function also follows Python list.append() semantics for negative values. If the negative value are passed then it start from the other end.
Syntax: Index.insert(loc, item)
Parameters :loc : intitem : object
Returns : new_index : Index
Example #1: Use Index.insert() function to insert a new value in the Index.
# importing pandas as pdimport pandas as pd  # Creating the Indexidx = pd.Index(['Labrador', 'Beagle', 'Labrador',                     'Lhasa', 'Husky', 'Beagle'])  # Print the Indexidx
Output :Now insert ‘Great_Dane’ at the 1st index.
# Inserting a value at the first position in the index.idx.insert(1, 'Great_Dane')
Output :
As we can see in the output, the Index.insert() function has inserted the passed value at the desired location. Example #2: Use Index.insert() function to insert a value into the Index at the second position from the last in the Index.
# importing pandas as pdimport pandas as pd  # Creating the Indexidx = pd.Index(['Labrador', 'Beagle', 'Labrador',                     'Lhasa', 'Husky', 'Beagle'])  # Print the Indexidx
Output :
Now insert ‘Great_Dane’ at the 1st index from the last.
# Inserting a value at the first position in the index.idx.insert(-1, 'Great_Dane')
Output :As we can see in the output, the passed value has been inserted into the Index at the desired location.
Python pandas-indexing
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
ClipRect Widget in Flutter - GeeksforGeeks

02 Sep, 2020
The ClipRect widget is used to clips its child using a rectangle. It associates with the Clippers family. The main use of clippers is to clip out any portion of the widget as required. It behaves similar to that of ClipRRect and is used to Clip a Rectangle portion of the child widget but without the rounded corners
Syntax:
ClipRect(
{Key key, 
CustomClipper<Rect> clipper, 
Clip clipBehavior: Clip.hardEdge, 
Widget child}) 

children: The widgets below this widget in the tree.
hashCode: The hash code for this object.
key: Controls how one widget replaces another widget in the tree.
runtimeType: A representation of the runtime type of the object.
clipBehaviour: Controls how to clip
clipper: If non-null, determines which clip to use.
Example:
Here we will clip the below image in our app:
Dart
import 'package:flutter/material.dart';  void main() {  runApp(MyApp());}  class MyApp extends StatelessWidget {  // This widget is  //the root of your application.  @override  Widget build(BuildContext context) {    return MaterialApp(      title: 'ClipOval',      theme: ThemeData(        primarySwatch: Colors.blue,      ),      home: MyHomePAGE(),      debugShowCheckedModeBanner: false,    );  }}  class MyHomePAGE extends StatefulWidget {  @override  _MyHomePAGEState createState() => _MyHomePAGEState();}  class _MyHomePAGEState extends State<MyHomePAGE> {  @override  Widget build(BuildContext context) {    return Scaffold(      appBar: AppBar(        title: Text('GeeksforGeeks'),        backgroundColor: Colors.green,      ),      body: Center(          child: ClipRect(            child: Align(              alignment: Alignment.topCenter,              heightFactor: 0.5,              child: Image.network('https://picsum.photos/250?image=9'),            ),          )      ),      backgroundColor: Colors.lightBlue[50],    );  }}  class MyClip extends CustomClipper<Rect> {  Rect getClip(Size size) {    return Rect.fromLTWH(0, 0, 100, 100);  }    bool shouldReclip(oldClipper) {    return false;  }}
Output:
First initialize the main app as a stateless widget.Second design the main widget as you desire.Build the Appbar with the scaffold widget.Now use the ClipRect widget inside the body of the scaffold widget and place it in the middle using the center widget.
First initialize the main app as a stateless widget.
Second design the main widget as you desire.
Build the Appbar with the scaffold widget.
Now use the ClipRect widget inside the body of the scaffold widget and place it in the middle using the center widget.
android
Flutter
Flutter-widgets
Dart
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Flutter - Custom Bottom Navigation Bar
ListView Class in Flutter
Flutter - Flexible Widget
Container class in Flutter
Flutter - Stack Widget
Operators in Dart
Flutter - Dialogs
Android Studio Setup for Flutter Development
Flutter - Positioned Widget
Format Dates in Flutter
Katana Framework – Hacking Framework in Kali Linux

24 Jun, 2021
The Katana Framework is a free and open-source tool available on GitHub. This is a framework similar to Metasploitable 1 and Metasploitable 2, which makes it easy to use. The katana framework is written in python. This means you must have python installed in your Kali Linux operating system.  This framework is developed to make penetration testing easy and simple to perform experiments. Using this tool, you can perform experiments of penetration testing. This tool unifies all the tools that are used for penetration testing. The Katana Framework has its own command to enter as an input. This tool provides a command-line interface. Using this tool, you can find Admin Panels, perform Sniffing, establish Backdoors on remote servers. 
The Katana Framework is written in python.
The Katana Framework is similar to Metasploitable 1 and Metasploitable 2, which makes it easy to use.
The Katana Framework is developed for performing penetration testing, easy and simple to perform experiments.
The Katana Framework has its own command to enter as an input.
The Katana Framework tool provides a command-line interface. Using this tool, you can find Admin Panels, perform Sniffing, establish Backdoors on remote servers.
Nmap
aircrack-ng
arpspoof 
mysql 
ssh 
dhcpd
hostapd
ettercap
xterm 
default-jre
Step 1: Open your kali linux and install the tool using the following command.
git clone https://github.com/PowerScript/KatanaFramework.git
Step 2: The tool has been downloaded and now use the following command to move in the directory of the framework.
cd KatanaFramework
Step 3: Now you have to install the dependencies of the tool using the following command.
sudo sh dependencies
Step 4: Now use the following command to install the tool.
sudo python install
Step 5: The tool is running successfully.
Example 1: Use the katana framework to initialize the console of katana.
ktf.console
Example 2: Use the katana framework to show modules.
showm
These are the modules present in the katana framework.
Example 3: Use the katana framework to show option modules and find the admin panel.
use web/ap.finder
set target www.geeksforgeeks.com
run
The tool has started and will give you admin panel information about the target domain. You can also use this module for your own target domain.
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
jQuery | slideUp() with Examples

13 Feb, 2019
The slideUp() is an inbuilt method in jQuery which is used to hide the selected elements.Syntax:
$(selector).slideUp(speed);

Parameter: It accepts an optional parameter “speed” which specifies the speed of the duration of the effect.
Return Value: It does not return anything simply it hides the selected element.
<html>  <head>    <script     src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>    <script>        <!-- jQuery code to show the working of this method -->        $(document).ready(function() {            $(".btn1").click(function() {                $("p").slideUp();            });        });    </script>    <style>        div {            width: 300px;            height: 100px;            padding: 20px;            border: 2px solid green;        }    </style></head>  <body>    <div>        <p>This paragraph will get hide.</p>        <!-- click on this button -->        <button class="btn1">Slide up</button>    </div></body>  </html>
Output :In the below video, working of this method has been shown.
Code #2:In the below code, speeding parameter is passed to this method.
<!DOCTYPE html><html>  <head>    <script     src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>    <script>        <!-- jQuery code to show the working of this method -->        $(document).ready(function() {            $(".btn1").click(function() {                $("p").slideUp(3000);            });        });    </script>    <style>        div {            width: 300px;            height: 100px;            padding: 20px;            border: 2px solid green;        }    </style></head>  <body>    <div>        <p>This paragraph will get hide.</p>        <!-- click on this button -->        <button class="btn1">Slide up</button>    </div></body>  </html>
Output :In the below video, the working of this method has been shown.
jQuery-Effects
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Scala Char toInt() method with example

29 Oct, 2019
The toInt() method is utilized to convert a stated character into an integer or its ASCII value of type Int.
Method Definition: def toInt: Int
Return Type: It returns Integer or ASCII value of the corresponding character of type Int.
Example: 1#
// Scala program of toInt()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Applying toInt method        val result = 'A'.toInt                  // Displays output        println(result)          }} 
65

Example: 2#
// Scala program of toInt()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Applying toInt method        val result = '9'.toInt                  // Displays output        println(result)          }} 
57

Scala
Scala-Method
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Send Text messages to any mobile number using Fast2SMS API in Python

02 Sep, 2020
This article is going to be about how can we send text messages using Python. We will be using Fast2SMS API to send messages. You don’t need to install any Python package for this purpose.
First, you need a Fast2SMS account. You can sign up for Fast2SMS from here. Now, go to Dev API option and copy the API Authorization Key. This API key is generated by Fast2SMS, however, you can regenerate the API key if you want to. Now, all you have to do is to make a POST request to Fast2SMS API with your API key, message, recipient, etc. and it will send your SMS.
So, to make requests to the API, we need to use the requests module, and to read the data returned by the API, we need json module. So, first Let’s import them.
Python3
# import required moduleimport requestsimport json
Now, We will create two dictionaries, one for the SMS data and another for the headers.
Python
# mention urlurl = "https://www.fast2sms.com/dev/bulk"    # create a dictionarymy_data = {     # Your default Sender ID    'sender_id': 'FSTSMS',          # Put your message here!    'message': 'This is a test message',         'language': 'english',    'route': 'p',        # You can send sms to multiple numbers    # separated by comma.    'numbers': '9999999999, 7777777777, 6666666666'    }  # create a dictionaryheaders = {    'authorization': 'YOUR API KEY HERE',    'Content-Type': "application/x-www-form-urlencoded",    'Cache-Control': "no-cache"}
Now, we are ready to post our data to the API.
Python3
# make a post requestresponse = requests.request("POST",                            url,                            data = my_data,                            headers = headers)#load json data from sourcereturned_msg = json.loads(response.text)  # print the send messageprint(returned_msg['message'])
Output:
['Message sent successfully to NonDND numbers']
If the message is sent successfully, It will print a success message. Your mobile number will be displayed to the recipient with your message.
In case of an error, it will print the Error message.
For example, if your API key is changed or you have entered the wrong API key, the following error message will be printed.
Invalid Authentication, Check Authorization Key
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
numpy.arccos() in Python

29 Nov, 2018
numpy.arccos(x[, out]) = ufunc ‘arccos’) : This mathematical function helps user to calculate inverse cos for all x(being the array elements).
Parameters :
array    : [array_like]elements are in radians.
out      : [array_like]array of same shape as x.

Note :
2pi Radians = 360 degreesThe convention is to return the angle z whose real part lies in [0, pi].
Return :
An array with inverse cosine of x 
for all x i.e. array elements. 

The values are in the closed interval [-pi/2, pi/2].

 Code #1 : Working
# Python program explaining# arccos() function  import numpy as np  in_array = [0, 1, 0.3, -1]print ("Input array : \n", in_array)  arccos_Values = np.arccos(in_array)print ("\nInverse Cosine values : \n", arccos_Values)
Output :
Input array : 
 [0, 1, 0.3, -1]

Inverse Cosine values : 
 [ 1.57079633  0.          1.26610367  3.14159265]
 Code #2 : Graphical representation
# Python program showing# Graphical representation  # of arccos() function  import numpy as npimport matplotlib.pyplot as plt  in_array = np.linspace(-np.pi, np.pi, 12)out_array1 = np.cos(in_array)out_array2 = np.arccos(in_array)  print("in_array : ", in_array)print("\nout_array with cos : ", out_array1)print("\nout_arraywith arccos : ", out_array1)  # red for numpy.arccos()plt.plot(in_array, out_array1,            color = 'blue', marker = "*")              plt.plot(in_array, out_array2,            color = 'red', marker = "o")              plt.title("blue : numpy.cos() \nred : numpy.arccos()")plt.xlabel("X")plt.ylabel("Y")plt.show()
Output :

in_array :  [-3.14159265 -2.57039399 -1.99919533 -1.42799666 -0.856798   -0.28559933
  0.28559933  0.856798    1.42799666  1.99919533  2.57039399  3.14159265]

out_array with cos :  [-1.         -0.84125353 -0.41541501  0.14231484  0.65486073  0.95949297
  0.95949297  0.65486073  0.14231484 -0.41541501 -0.84125353 -1.        ]

out_arraywith arccos :  [-1.         -0.84125353 -0.41541501  0.14231484  0.65486073  0.95949297
  0.95949297  0.65486073  0.14231484 -0.41541501 -0.84125353 -1.        ]
RuntimeWarning: invalid value encountered in arccos
  out_array1 = np.sin(in_array)
References :https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.arcsin.html#numpy.arccos.
Python numpy-Mathematical Function
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Stack add(Object) method in Java with Example

24 Dec, 2018
The add(Object) method of Stack Class appends the specified element to the end of this Stack.
Syntax:
boolean add(Object element)
Parameters: This function accepts a single parameter element as shown in the above syntax. The element specified by this parameter is appended to end of the Stack.
Return Value: This method returns True after successful execution, else False.
Below program illustrates the working of java.util.Stack.add(Object element) method:
Example 1:
// Java code to illustrate boolean add(Object element)import java.util.*;  public class StackDemo {    public static void main(String args[])    {          // Creating an empty Stack        Stack<String> stack            = new Stack<String>();          // Use add() method        // to add elements in the Stack        stack.add("Geeks");        stack.add("for");        stack.add("Geeks");        stack.add("10");        stack.add("20");          // Output the present Stack        System.out.println("The Stack is: "                           + stack);          // Adding new elements to the end        stack.add("Last");        stack.add("Element");          // Printing the new Stack        System.out.println("The new Stack is: "                           + stack);    }}
The Stack is: [Geeks, for, Geeks, 10, 20]
The new Stack is: [Geeks, for, Geeks, 10, 20, Last, Element]

Example 2:
// Java code to illustrate// boolean add(Object element)  import java.util.*;  public class StackDemo {    public static void main(String args[])    {          // Creating an empty Stack        Stack<Integer> stack            = new Stack<Integer>();          // Use add() method        // to add elements in the Stack        stack.add(10);        stack.add(20);        stack.add(30);        stack.add(40);        stack.add(50);          // Output the present Stack        System.out.println("The Stack is: "                           + stack);          // Adding new elements to the end        stack.add(100);        stack.add(200);          // Printing the new Stack        System.out.println("The new Stack is: "                           + stack);    }}
The Stack is: [10, 20, 30, 40, 50]
The new Stack is: [10, 20, 30, 40, 50, 100, 200]

Java - util package
Java-Collections
Java-Functions
Java-Stack
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Why is Java ‘write once and run anywhere’?

26 May, 2019
JVM(Java Virtual Machine) acts as a run-time engine to run Java applications. JVM is the one that actually calls the main method present in Java code. JVM is a part of the JRE(Java Runtime Environment).
Java applications are called WORA (Write Once Run Anywhere). This means a programmer can develop Java code on one system and can expect it to run on any other Java-enabled system without any adjustment. This is all possible because of JVM.
How Java is WORA:
In traditional programming languages like C, C++ when programs were compiled, they used to be converted into the code understood by the particular underlying hardware, so If we try to run the same code at another machine with different hardware, which understands different code will cause an error, so you have to re-compile the code to be understood by the new hardware.
In Java, the program is not converted to code directly understood by Hardware, rather it is converted to bytecode(.class file), which is interpreted by JVM, so once compiled it generates bytecode file, which can be run anywhere (any machine) which has JVM( Java Virtual Machine) and hence it gets the nature of Write Once and Run Anywhere.
Example: Practical Implementation of WORA using a simple JAVA program to check whether a number is even or odd.
import java.util.Scanner;  class GFG {    public static void main(String args[])    {        int num;        System.out.println("Enter a number:");        Scanner input = new Scanner(System.in);        num = input.nextInt();        if (num % 2 == 0)            System.out.println(num + " is even");        else            System.out.println(num + " is odd");    }}
For Compiling (done on Windows 10):javac GFG.java

javac GFG.java

After compilation there will be a class file in the corresponding folder named as:GFG.class

GFG.class

When copied the bytecode (.class) generated on compilation to a macOS 10.14.3 and running it we get the following output.Java program Compiled on WIndows and ran in macOS
Java program Compiled on WIndows and ran in macOS
Conclusion:To sum it up, Java, when compiled, creates a bytecode (.class file), which can be run in any machine which supports JVM. So once compiled it doesn’t require re-compilation at every machine it runs, JVM converts the bytecode to be understood by the underlying hardware.
java-basics
Picked
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
BabylonJS - Back-Face Culling

Back-face culling determines whether a polygon of a graphical object is visible. Back-face culling determines whether or not a StandardMaterial is visible from its back side (from behind).
<!doctype html>
<html>
   <head>
      <meta charset = "utf-8">
      <title>BabylonJs - Basic Element-Creating Scene</title>
      <script src = "babylon.js"></script>
      <style>
         canvas {width: 100%; height: 100%;}
      </style>
   </head>

   <body>
      <canvas id = "renderCanvas"></canvas>
      <script type = "text/javascript">
         var canvas = document.getElementById("renderCanvas");
         var engine = new BABYLON.Engine(canvas, true);
         
         var createScene  = function() {
            var scene = new BABYLON.Scene(engine);
            
            var camera = new BABYLON.ArcRotateCamera("Camera", 1, 0.8, 10, new BABYLON.Vector3(0, 0, 0), scene);
            camera.attachControl(canvas, true);
            
            var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene);
            light.intensity = 0.7;	
            
            var materialforsphere = new BABYLON.StandardMaterial("texture1", scene);
            
            var sphere = BABYLON.Mesh.CreateSphere("Sphere1",20, 3.0, scene);
            sphere.material  = materialforsphere;
            materialforsphere.diffuseTexture = new BABYLON.Texture("images/rainbow.png", scene);
            
            materialforsphere.diffuseTexture.hasAlpha = true
            materialforsphere.backFaceCulling = false;
            return scene;
         };
         var scene = createScene();
         engine.runRenderLoop(function() {
            scene.render();
         });
      </script>
   </body>
</html>
The above line of code generates the following output −
In this demo, we have used an image called rainbow.png. The images are stored in images/ folder locally. You can download any image of your choice and use in the demo link.
Python program to find the largest number in a list

In this article, we will learn about the solution to the problem statement given below.
Problem statement − We are given a list, we need to calculate the largest element of the list.
Here we will take the help of built-in functions to reach the solution of the problem statement
# list
list1 = [23,1,32,67,2,34,12]
# sorting
list1.sort()
# printing the last element
print("Largest element is:", list1[-1])
Largest in given array is 67
 Live Demo
# list
list1 = [23,1,32,67,2,34,12]
# printing the maximum element
print("Largest element is:", max(list1))
Largest in given array is 67
We can also take input from the user by the code given below
# empty list
list1 = []
# asking number of elements to put in list
num = int(input("Enter number of elements in list: "))
# appending elements in the list
for i in range(1, num + 1):
   ele = int(input("Enter elements: "))
   list1.append(ele)
# print maximum element
print("Largest element is:", max(list1))
In this article, we have learned how to get the largest element from the list.
C Program for Basic Euclidean algorithms - GeeksforGeeks

05 Nov, 2021
GCD of two numbers is the largest number that divides both of them. A simple way to find GCD is to factorize both numbers and multiply common factors. 
C
// C program to demonstrate Basic Euclidean Algorithm#include <stdio.h> // Function to return gcd of a and bint gcd(int a, int b){    if (a == 0)        return b;    return gcd(b % a, a);} // Driver program to test above functionint main(){    int a = 10, b = 15;    printf("GCD(%d, %d) = %d\n", a, b, gcd(a, b));    a = 35, b = 10;    printf("GCD(%d, %d) = %d\n", a, b, gcd(a, b));    a = 31, b = 2;    printf("GCD(%d, %d) = %d\n", a, b, gcd(a, b));    return 0;}
GCD(10, 15) = 5
GCD(35, 10) = 5
GCD(31, 2) = 1
 
Time Complexity: O(Log min(a, b)) 
Auxiliary Space: O(1)Please refer complete article on Basic and Extended Euclidean algorithms for more details! 
subham348
GCD-LCM
C Programs
Mathematical
Mathematical
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
C Program to read contents of Whole File
How to Append a Character to a String in C
time() function in C
Flex (Fast Lexical Analyzer Generator )
C Program to Swap two Numbers
Program for Fibonacci numbers
C++ Data Types
Write a program to print all permutations of a given string
Set in C++ Standard Template Library (STL)
Coin Change | DP-7
Anubis - Subdomain enumeration and information gathering tool in Kali Linux - GeeksforGeeks

21 Jul, 2021
Anubis is a tool for information gathering. This tool is very useful in the initial phases of penetration testing. The main technique used to find subdomain using many modules is to target bruteforce with an improved wordlist Anubis is a free and open-source tool available on GitHub. This tool is free means you can download and use this tool free of cost. Anubis is used for reconnaissance of subdomains. Anubis is used for Anubis of the target. This tool is used to find subdomains from a website/web-applications. Usually, what happens that it becomes very difficult for a security researcher to find subdomains from an HTTPS website or web application. This tool helps to get subdomains of all HTTPS as well as HTTP websites. Anubis tool is written in python language you must have python language installed into your Kali Linux in order to use this tool. This tool comes with an awesome user interface. The user interface of the tool is very similar to Metasploitable 1 and metasploitable 2 which makes it very easy to run and use.
Step 1: Use the following command to install the tool in your operating system and use the second command to move into the directory of the tool.
git clone https://github.com/jonluca/Anubis.git
cd Anubis
Step 2: The tool has been downloaded and installed in your system. Now you have to install the requirements of the tool using the following command.
pip3 install -r requirements.txt
The requirements have been installed. Now we will see an example to use the tool.
Example 1: Use the Anubis tool to find subdomains of a domain.
anubis -t reddit.com
Example 2: Find the subdomain of domain geeksforgeeks.com and IP address.
anubis -t geeksforgeeks.org -ip
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
scp command in Linux with Examples
nohup Command in Linux with Examples
mv command in Linux with examples
Thread functions in C/C++
Docker - COPY Instruction
chown command in Linux with Examples
nslookup command in Linux with Examples
SED command in Linux | Set 2
Named Pipe or FIFO with example C program
uniq Command in LINUX with examples
C Program to print contents of file - GeeksforGeeks

20 May, 2017
fopen() is used to open and fclose() is used to close a file in C
#include <stdio.h>#include <stdlib.h> // For exit()  int main(){    FILE *fptr;      char filename[100], c;      printf("Enter the filename to open \n");    scanf("%s", filename);      // Open file    fptr = fopen(filename, "r");    if (fptr == NULL)    {        printf("Cannot open file \n");        exit(0);    }      // Read contents from file    c = fgetc(fptr);    while (c != EOF)    {        printf ("%c", c);        c = fgetc(fptr);    }      fclose(fptr);    return 0;}
Output:
Enter the filename to open
a.txt
/*Contents of a.txt*/
cpp-file-handling
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
rand() and srand() in C/C++
Left Shift and Right Shift Operators in C/C++
Command line arguments in C/C++
Function Pointer in C
Different methods to reverse a string in C/C++
Substring in C++
TCP Server-Client implementation in C
Enumeration (or enum) in C
Structures in C
std::string class in C++
Auto Import Python Libraries. Using Pyforest to import important... | by Himanshu Sharma | Towards Data Science

Do you also get stuck in importing libraries while coding in python? It happens with most of us that while coding we forget to import libraries that we will use and we got stuck in importing different libraries which is frustrating, also I must say being a lazy programmer I want a way to solve this importing problem once and for all.
PyForest is an open-source python library that is really helpful for a lazy programmer like me because it imports all the major libraries that are required for python programming including machine learning and deep learning.
In this article, we will explore PyForest and see how we can use it.
Let’s get started...
We will start by installing PyForest using pip. The command given below will do that.
!pip install pyforest
In this step, we will import only PyForest which is the only required library.
from pyforest import *
Now the magic begins, let’s see how many python libraries we have imported in just a single line of code.
lazy_imports()
You see how easily we imported all the major python libraries including libraries for deep learning, machine learning, image processing, etc. These libraries are really helpful if you are a lazy programmer like me.
In this article, we saw how PyForest is useful for importing important libraries. Go ahead try importing the library in a single line and let me know your comments in the response section.
This article is in collaboration with Piyush Ingale.
Thanks for reading! If you want to get in touch with me, feel free to reach me at hmix13@gmail.com or my LinkedIn Profile. You can view my Github profile for different data science projects and packages tutorials. Also, feel free to explore my profile and read different articles I have written related to Data Science.
What is strcpy() Function in C language?

The C library function char *strcpy(char *dest, const char *src) copies the string pointed to, by src to dest.
An array of characters is called a string.
Following is the declaration for an array
char stringname [size];
For example − char string[50]; string of length 50 characters
Using single character constant −
char string[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}
Using string constants −
char string[10] = "Hello":;
Accessing − There is a control string "%s" used for accessing the string till it encounters ‘\0’
This function is used for copying source string into destination string.
This function is used for copying source string into destination string.
The length of the destination string is greater than or equal to the source string.
The length of the destination string is greater than or equal to the source string.
The syntax is as follows −
strcpy (Destination string, Source String);
The following example shows the usage of strcpy() function.
char a[50]; char a[50];
strcpy ("Hello",a); strcpy ( a,"hello");
output: error output: a= "Hello"
The following program shows the usage of strcpy() function.
 Live Demo
#include <string.h>
main ( ){
   char a[50], b[50];
   printf ("enter a source string");
   scanf("%s", a);
   strcpy ( b,a);
   printf ("copied string = %s",b);
   getch ( );
}
When the above program is executed, it produces the following result −
Enter a source string : Hello
Copied string = Hello
Let’s see another example on strcpy.
Given below is a C program demonstrating strcpy library function −
 Live Demo
#include<stdio.h>
#include<string.h>
void main(){
   //Declaring source and destination strings//
   char source[25],destination[50];
   //Reading Input from user//
   printf("Enter the string to be copied : ");
   gets(source);
   printf("Enter the existing destination string : ");
   gets(destination);
   //Using strcpy library function//
   strcpy(destination,source);
   //Printing destination string//
   printf("Destination string is : ");
   puts(destination);
}
When the above program is executed, it produces the following result −
Enter the string to be copied : C programming
Enter the existing destination string : bhanu
Destination string is : C programming
D3.js | d3.selectAll() Function

18 Jul, 2019
The d3.selectAll() function in D3.js is used to select all the element that matches the specified selector string.
Syntax:
d3.selectAll("element")
Parameters: This function accepts single parameter HTML tag as a parameter.
Return Value: This function returns the selected elements.
Below programs illustrate the d3.selectAll() function in D3.js:
Example 1:
<!DOCTYPE html><html>  <head>    <title>        D3.js | d3.selectAll() Function    </title>          <script src = "https://d3js.org/d3.v4.min.js"></script></head>  <body>    <div>Geeks</div>              <div>GeeksforGeeks</div>              <script>                  // Calling the selectAll() function        d3.selectAll("div").text();    </script></body>  </html>                    
Output:
Geeks
GeeksforGeeks

Example 2:
<!DOCTYPE html><html>  <head>    <title>        D3.js | d3.selectAll() Function    </title>          <script src = "https://d3js.org/d3.v4.min.js"></script></head>  <body>    <p>GeeksforGeeks</p>              <p>A computer science portal for geeks</p>          <p>d3.selectAll() function</p>              <script>                  // Calling the selectAll() function        d3.selectAll("p").text();    </script></body>  </html>                    
Output:
GeeksforGeeks
A computer science portal for geeks
d3.selectAll() function

Reference: https://devdocs.io/d3~5/d3-selection#selectAll
D3.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Roadmap to Learn JavaScript For Beginners
Difference Between PUT and PATCH Request
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Remove array elements in Ruby

20 Jul, 2021
In this article, we will learn how to remove elements from an array in Ruby.
Method #1: Using Index
Ruby
# Ruby program to remove elements # in array   # creating string using []str = ["GFG", "G4G", "Sudo", "Geeks"]   str.delete_at(0)print str
Output:
["G4G", "Sudo", "Geeks"
Method #2: Using delete() method –
Ruby
# Ruby program to remove elements # in array   # creating string using []str = ["GFG", "G4G", "Sudo", "Geeks"]   str.delete("Sudo")print str
Output:
 ["GFG", "G4G", "Geeks"
Method #3: Using pop() method –
Ruby
# Ruby program to remove elements # in array   # creating string using []str = ["GFG", "G4G", "Sudo", "Geeks"]   str.popprint str
Output:
 ["GFG", "G4G", "Sudo"] 
 
surinderdawra388
Ruby Array
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Make a Custom Array of Hashes in Ruby?
Ruby | Enumerator each_with_index function
Ruby | unless Statement and unless Modifier
Ruby | Array class find_index() operation
Ruby For Beginners
Ruby | String concat Method
Ruby on Rails Introduction
Ruby | Array shift() function
Ruby | Types of Variables
Different Forms of Assignment Statements in Python

10 May, 2020
We use Python assignment statements to assign objects to names. The target of an assignment statement is written on the left side of the equal sign (=), and the object on the right can be an arbitrary expression that computes an object.
There are some important properties of assignment in Python :-
Assignment creates object references instead of copying the objects.
Python creates a variable name the first time when they are assigned a value.
Names must be assigned before being referenced.
There are some operations that perform assignments implicitly.
Assignment statement forms :-
1. Basic form:
This form is the most common form.
student = 'Geeks'print(student)
OUTPUT
Geeks
2. Tuple assignment:
# equivalent to: (x, y) = (50, 100)x, y = 50, 100    print('x = ', x)print('y = ', y)
OUTPUT
x = 50 
y = 100

When we code a tuple on the left side of the =, Python pairs objects on the right side with targets on the left by position and assigns them from left to right. Therefore, the values of x and y are 50 and 100 respectively.
3. List assignment:
This works in the same way as the tuple assignment.
[x, y] = [2, 4]  print('x = ', x)print('y = ', y)
OUTPUT
x = 2
y = 4

4. Sequence assignment:
In recent version of Python, tuple and list assignment have been generalized into instances of what we now call sequence assignment – any sequence of names can be assigned to any sequence of values, and Python assigns the items one at a time by position.
a, b, c = 'HEY'  print('a = ', a)print('b = ', b)print('c = ', c)
OUTPUT
a = H
b = E
c = Y

5. Extended Sequence unpacking:
It allows us to be more flexible in how we select portions of a sequence to assign.
p, *q = 'Hello'  print('p = ', p)print('q = ', q)
Here, p is matched with the first character in the string on the right and q with the rest. The starred name (*q) is assigned a list, which collects all items in the sequence not assigned to other names.
OUTPUT
p = H
q = ['e', 'l', 'l', 'o']

This is especially handy for a common coding pattern such as splitting a sequence and accessing its front and rest part.
ranks = ['A', 'B', 'C', 'D']first, *rest = ranks  print("Winner: ", first)print("Runner ups: ", ', '.join(rest))
OUTPUT
Winner: A
Runner ups: B, C, D

6. Multiple- target assignment:
x = y = 75  print(x, y)
In this form, Python assigns a reference to the same object (the object which is rightmost) to all the target on the left.
OUTPUT
75 75

7. Augmented assignment :
The augmented assignment is a shorthand assignment that combines an expression and an assignment.
x = 2  # equivalent to: x = x + 1x += 1    print(x)
OUTPUT
3

There are several other augmented assignment forms:
-=, **=, &=, etc.
python-basics
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Iterate over a list in Python
Python Classes and Objects
Convert integer to string in Python
Python | os.path.join() method