code-rag-bench/online-tutorials huggingface dataset:
How to set IE compatibility mode ?

19 Oct, 2021
The percentage of market share in the global desktop browser of Internet Explorer(IE) is less than 3%. If we are developing a site that includes global users or a sizable number of visitors from an older IE version then we have to make our website compatible with IE, even though that is outdated. The solution to this problem is  X-UA-Compatible mode.
This article will tell you how to set IE(Internet Explorer) using HTML meta tags.
X-UA-Compatible is a document mode meta tag that allows us to choose which version of Internet Explorer the page should be rendered. Information about the http-equiv and content tags can be found at.
Example: This example uses a meta element that includes an X-UA-Compatible header and value of IE=9 in content attribute which limits the webpage features so that the webpage is supported by Windows Internet Explorer 9.
HTML
<!DOCTYPE html><html><head>  <title>Your Webpage Title</title>  <!-- Use Internet Explorer 9 Standards mode -->  <meta http-equiv="X-UA-Compatible" content="IE=9"></head><body>  <h>Your Heading</h>  <p>Your content goes here.</p></body></html>
The content of the http-equiv tags are below:
IE=5: This mode renders the webpage as if it were displayed in Quirks mode by Internet Explorer 7.
IE=7: This mode renders content as if it were displayed by Internet Explorer 7
IE=8: This mode provides supports for many established standards in the industry.
IE=9: This mode provides the highest support for many established industry standards.          IE 9 does not support CSS3 animations.
IE=10: This mode provides the highest support for many established industry standards, like HTML5, CSS3.
IE=11: This mode provides the highest support for established and emerging industry standards, like HTML5, CSS3.
IE=edge: This mode instructs Internet Explorer to display content in the highest mode available.
IE=EmulateIE7: Works same as IE=7 mode if a valid <!DOCTYPE> declaration is present otherwise in Quirks Mode.
IE=EmulateIE8: Works same as IE=8 mode if a valid <!DOCTYPE> declaration is present otherwise in Quirks Mode.
IE=EmulateIE9: Works same as IE=9 mode if a valid <!DOCTYPE> declaration is present otherwise in Quirks Mode.
IE=EmulateIE10: Works same as IE=10 mode if a valid <!DOCTYPE> declaration is present otherwise in Quirks Mode.
IE=EmulateIE11: Works same as IE=11 mode if a valid <!DOCTYPE> declaration is present otherwise in Quirks Mode.
Quirks Mode: This mode is a technique used by some browsers in maintaining backward compatibility for pages developed for older browsers, like in our case Internet Explorer.
HTML-Attributes
HTML-Questions
Picked
TrueGeek-2021
HTML
TrueGeek
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HTML | novalidate Attribute

03 Dec, 2021
The HTML novalidate Attribute is used to specify that the form-data should not be validated when submitting the form. It is a Boolean attribute. It can be used with the <form> element. Applicable: 
<form>
Syntax:  
<form novalidate>
Example: This Example illustrates the use of novalidate attribute in form Element.  
html
<!DOCTYPE html><html> <head>    <title>        HTML | novalidate Attribute    </title></head> <body style="text-align:center;">    <h1>        GeeksForGeeks    </h1>     <h2>        HTML | novalidate Attribute    </h2>     <form action="#"          method="get"          target="_self" novalidate>        Name:        <input type="text">        <input type="submit"               id="Geeks"               name="myGeeks"               value="Submit @ geeksforgeeks"               formTarget="_blank">    </form> </body> </html>
Output:  
Supported Browsers: The browser supported by novalidate attribute are listed below:  
Google Chrome 10.0
Internet Explorer 10.0
Firefox 4.0
Opera 10.6
 
hritikbhatnagar2182
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Draw an Olympic Symbol in Java Applet

22 Apr, 2022
Given task is to draw an Olympic symbol in Java Applet.
Expected Output:
  
Approach: Use drawOval() method to draw a circle with x and y coordinates and length and breadth.
Below is the implementation of the above approach: 
Applet Program: 
Java
// Java program to Draw an Olympic// Symbol using Java Appletimport java.applet.*;import java.awt.*;/*<applet code="Olympics" width=600 height=600></applet>*/ public class Olympics extends Applet {    public void paint(Graphics g)    {        g.setColor(Color.BLUE);        g.drawOval(30, 30, 30, 30);        g.setColor(Color.YELLOW);        g.drawOval(50, 45, 30, 30);        g.setColor(Color.BLACK);        g.drawOval(70, 30, 30, 30);        g.setColor(Color.GREEN);        g.drawOval(90, 45, 30, 30);        g.setColor(Color.RED);        g.drawOval(110, 30, 30, 30);    }}
Output:
 
Note: To run the applet in command line use the following commands
> javac Olympics.java
> appletviewer Olympics.java
You can also refer to: https://www.geeksforgeeks.org/different-ways-to-run-applet-in-java to run applet program.
sahilsulakhe3
java-applet
Technical Scripter 2018
Java
Technical Scripter
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Iperf Command to Test Speed, Performance and Bandwidth of Network in Linux

10 Jul, 2020
There is a great degree of flex in how the packets are delivered and overall bit rate and packet payload size can be controlled. iperf is a tool that is used to perform network performance measurement and tuning. iperf is an open-source software which is written in C language. Jperf is a GUI version for doing the same job. The core concept work behind Jperf is the iPerf.
It works either in server or client mode. Normally the client will send the data and the server will receive it. So we have client and server, and iPerf is going to find out the Bandwidth, performance, and speed of the network between both. It generates a packet that can be either TCP or UDP and send those packets to the server and calculate the timing of sending from client-side, timing when the packet reaches to server-side, size of the packet, etc. and on the behalf of that data, iPerf calculates the Speed, Performance, and Bandwidth of Network.
For RedHat based Linux
yum install iperf

For Other Linux based Operating Systems, download the tool from iperf.fr/iperf-download.php and execute the following command.
tar -xvf iperf-2.0.5.tar.gz
cd iperf-2.0.5
./configure
make install

As iperf works with both client and server, we must start a server before starting the client. Just run the below command on the server machine and it will initiate the server.
iperf -s
Here, -s signifies the server mode.
Initiate the client by using the following command.
iperf -c 192.165.2.137 -u 100
Here,
c signifies the client mode.
192.165.2.137 signifies the IP address of the server to which client is to be connected.
u signifies generating the UDP packets.
100 signifies the length of UDP data payload.
After the successful execution of the command, it prints the bandwidth and other network-related details.
linux-command
Linux-system-commands
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to call a JavaScript function on a click event?

JavaScript's interaction with HTML is handled through events that occur when the user or the browser manipulates a page.
When the page loads, it is called an event. When the user clicks a button, that clicks to is an event. Other examples include events like pressing any key, closing a window, resizing a window, etc.
The onclick() event occurs when a user clicks the left button of his mouse. Place your validation, warning etc., against this event type.
You can try to run the following code to call a JavaScript function on a click event −
Live Demo
<html>
   <head>
      <script>
         <!--
            function sayHello() {
               alert("Demo Alert")
            }
         //-->
      </script>
   </head>
   <body>
      <p>Click the following button and see result</p>
      <form>
         <input type="button" onclick="sayHello()" value="Click" />
      </form>
   </body>
</html
Apex - Triggers

Apex triggers are like stored procedures which execute when a particular event occurs. A trigger executes before and after an event occurs on record.
trigger triggerName on ObjectName (trigger_events) { Trigger_code_block }

Following are the events on which we can fir the trigger −
insert
update
delete
merge
upsert
undelete
Suppose we received a business requirement that we need to create an Invoice Record when Customer's 'Customer Status' field changes to Active from Inactive. For this, we will create a trigger on APEX_Customer__c object by following these steps −
Step 1 − Go to sObject
Step 2 − Click on Customer
Step 3 − Click on 'New' button in the Trigger related list and add the trigger code as give below.
// Trigger Code
trigger Customer_After_Insert on APEX_Customer__c (after update) {
   List InvoiceList = new List();
   
   for (APEX_Customer__c objCustomer: Trigger.new) {
      
      if (objCustomer.APEX_Customer_Status__c == 'Active') {
         APEX_Invoice__c objInvoice = new APEX_Invoice__c();
         objInvoice.APEX_Status__c = 'Pending';
         InvoiceList.add(objInvoice);
      }
   }
   
   // DML to insert the Invoice List in SFDC
   insert InvoiceList;
}
Trigger.new − This is the context variable which stores the records currently in the trigger context, either being inserted or updated. In this case, this variable has Customer object's records which have been updated.
There are other context variables which are available in the context – trigger.old, trigger.newMap, trigger.OldMap.
The above trigger will execute when there is an update operation on the Customer records. Suppose, the invoice record needs to be inserted only when the Customer Status changes from Inactive to Active and not every time; for this, we can use another context variable trigger.oldMap which will store the key as record id and the value as old record values.
// Modified Trigger Code
trigger Customer_After_Insert on APEX_Customer__c (after update) {
   List<apex_invoice__c> InvoiceList = new List<apex_invoice__c>();
   
   for (APEX_Customer__c objCustomer: Trigger.new) {
      
      // condition to check the old value and new value
      if (objCustomer.APEX_Customer_Status__c == 'Active' &&
      
      trigger.oldMap.get(objCustomer.id).APEX_Customer_Status__c == 'Inactive') {
         APEX_Invoice__c objInvoice = new APEX_Invoice__c();
         objInvoice.APEX_Status__c = 'Pending';
         InvoiceList.add(objInvoice);
      }
   }
   
   // DML to insert the Invoice List in SFDC
   insert InvoiceList;
}
We have used the Trigger.oldMap variable which as explained earlier, is a context variable which stores the Id and old value of records which are being updated.

    14 Lectures 
     2 hours 

 Vijay Thapa

    7 Lectures 
     2 hours 

 Uplatz

    29 Lectures 
     6 hours 

 Ramnarayan Ramakrishnan

    49 Lectures 
     3 hours 

 Ali Saleh Ali

    10 Lectures 
     4 hours 

 Soham Ghosh

    48 Lectures 
     4.5 hours 

 GUHARAJANM
 Print
 Add Notes
 Bookmark this page
How to delete all files in a directory with Python?

You can delete a single file or a single empty folder with functions in the os module.
For example, if you want to delete a file my_file.txt,
>>> import os
>>> os.remove('my_file.txt')
The argument to os.remove must be absolute or relative path.
To delete multiple files, just loop over your list of files and use the above function. If you want to delete a folder containing all files you want to remove, you can remove the folder and recreate it as follows:
>>> import shutil
>>> shutil.rmtree('my_folder')
>>> import os
>>> os.makedirs('my_folder')
You can also recursively delete the files using os.walk().
import os, re, os.path
mypath = "my_folder"
for root, dirs, files in os.walk(mypath):
    for file in files:
        os.remove(os.path.join(root, file))
The directory tree will be intact if above method is used.
hgjg
Python Pillow - M L with Numpy

In this chapter, we use numpy to store and manipulate image data using python imaging library – “pillow”.
Before proceeding with this chapter open command prompt in administrator mode and execute the following command in it to install numpy −
pip install numpy

Note − This works only if you have PIP installed and updated.
Creating an RGB image using PIL and save it as a jpg file. In the following example we will −
Create a 150 by 250-pixel array.
Create a 150 by 250-pixel array.
Fill left half of the array with orange.
Fill left half of the array with orange.
Fill right half of the array with blue.
Fill right half of the array with blue.
from PIL import Image
import numpy as np

arr = np.zeros([150, 250, 3], dtype=np.uint8)

arr[:,:100] = [255, 128, 0]

arr[:,100:] = [0, 0, 255]

img = Image.fromarray(arr)

img.show()

img.save("RGB_image.jpg")
Creating greyscale images is slightly different from creating an RGB image. We can use the 2-dimensional array to create a greyscale image.
from PIL import Image
import numpy as np

arr = np.zeros([150,300], dtype=np.uint8)

#Set grey value to black or white depending on x position
   for x in range(300):
      for y in range(150):
         if (x % 16) // 8 == (y % 16)//8:
            arr[y, x] = 0
         else:
            arr[y, x] = 255
img = Image.fromarray(arr)

img.show()

img.save('greyscale.jpg')
You can convert PIL image to numpy array and vice versa. A small program to demonstrate the same is stated below.
#Import required libraries
from PIL import Image
from numpy import array

#Open Image & create image object
img = Image.open('beach1.jpg')

#Show actual image
img.show()

#Convert an image to numpy array
img2arr = array(img)

#Print the array
print(img2arr)

#Convert numpy array back to image
arr2im = Image.fromarray(img2arr)

#Display image
arr2im.show()

#Save the image generated from an array
arr2im.save("array2Image.jpg")
If you save the above program as Example.py and execute −
It displays the original image.
It displays the original image.
Displays the array retrieved from it.
Displays the array retrieved from it.
Converts the array back into image and displays it.
Converts the array back into image and displays it.
Since we have used show() method the images are displayed using the default PNG display utility, as follows.
Since we have used show() method the images are displayed using the default PNG display utility, as follows.
[[[ 0 101 120]
[ 3 108 127]
[ 1 107 123]
...
...
[[ 38 59 60]
[ 37 58 59]
[ 36 57 58]
...
[ 74 65 60]
[ 59 48 42]
[ 66 53 47]]
[[ 40 61 62]
[ 38 59 60]
[ 37 58 59]
...
[ 75 66 61]
[ 72 61 55]
[ 61 48 42]]
[[ 40 61 62]
[ 34 55 56]
[ 38 59 60]
...
[ 82 73 68]
[ 72 61 55]
[ 63 52 46]]]

Original Image
Image constructed from the array

    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
RESTful Web Services - Addressing

Addressing refers to locating a resource or multiple resources lying on the server. It is analogous to locate a postal address of a person.
Each resource in REST architecture is identified by its URI (Uniform Resource Identifier). A URI is of the following format −
<protocol>://<service-name>/<ResourceType>/<ResourceID>

Purpose of an URI is to locate a resource(s) on the server hosting the web service. Another important attribute of a request is VERB which identifies the operation to be performed on the resource. For example, in RESTful Web Services - First Application chapter, the URI is http://localhost:8080/UserManagement/rest/UserService/users and the VERB is GET.
The following are important points to be considered while designing a URI −
Use Plural Noun − Use plural noun to define resources. For example, we've used users to identify users as a resource.
Use Plural Noun − Use plural noun to define resources. For example, we've used users to identify users as a resource.
Avoid using spaces − Use underscore (_) or hyphen (-) when using a long resource name. For example, use authorized_users instead of authorized%20users.
Avoid using spaces − Use underscore (_) or hyphen (-) when using a long resource name. For example, use authorized_users instead of authorized%20users.
Use lowercase letters − Although URI is case-insensitive, it is a good practice to keep the url in lower case letters only.
Use lowercase letters − Although URI is case-insensitive, it is a good practice to keep the url in lower case letters only.
Maintain Backward Compatibility − As Web Service is a public service, a URI once made public should always be available. In case, URI gets updated, redirect the older URI to a new URI using the HTTP Status code, 300.
Maintain Backward Compatibility − As Web Service is a public service, a URI once made public should always be available. In case, URI gets updated, redirect the older URI to a new URI using the HTTP Status code, 300.
Use HTTP Verb − Always use HTTP Verb like GET, PUT and DELETE to do the operations on the resource. It is not good to use operations name in the URI.
Use HTTP Verb − Always use HTTP Verb like GET, PUT and DELETE to do the operations on the resource. It is not good to use operations name in the URI.
Following is an example of a poor URI to fetch a user.
http://localhost:8080/UserManagement/rest/UserService/getUser/1 

Following is an example of a good URI to fetch a user.
http://localhost:8080/UserManagement/rest/UserService/users/1


    71 Lectures 
     10 hours 

 Chaand Sheikh

    27 Lectures 
     2 hours 

 Vinod Kumar Kayartaya

    517 Lectures 
     57 hours 

 Chaand Sheikh

    35 Lectures 
     3.5 hours 

 Antonio Papa
 Print
 Add Notes
 Bookmark this page
MongoDB query to test if a value is in array?

To check for a specific value, use $in. Let us first create a collection with documents −
> db.testInArray.insertOne({"ListOfNumbers":[10,56,78,90,32]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e04d42df5e889d7a519950d")
}
> db.testInArray.insertOne({"ListOfNumbers":[56,78,91,100]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e04d588f5e889d7a519950e")
}
Following is the query to display all documents from a collection with the help of find() method −
> db.testInArray.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5e04d42df5e889d7a519950d"),
   "ListOfNumbers" : [
      10,
      56,
      78,
      90,
      32
   ]
}
{
   "_id" : ObjectId("5e04d588f5e889d7a519950e"),
   "ListOfNumbers" : [
      56,
      78,
      91,
      100
   ]
}
Here is the query to test if a value is in array −
> db.testInArray.find({ ListOfNumbers:{ "$in" : [90]} });
This will produce the following output −
{ "_id" : ObjectId("5e04d42df5e889d7a519950d"), "ListOfNumbers" : [ 10, 56, 78, 90, 32 ] }
BabylonJS - Plane

In this section, we will learn how to create a Plane.
Following is the syntax for the creation of a plane −
var plane = BABYLON.Mesh.CreatePlane("plane", 10.0, scene, false, BABYLON.Mesh.DEFAULTSIDE);

Consider the following parameters for the creation of a plane −
Name − This is the name of the plane.
Name − This is the name of the plane.
Size − This is the size of the plane.
Size − This is the size of the plane.
Scene − This is the scene to attach the mesh.
Scene − This is the scene to attach the mesh.
Boolean − The value is updatable; by default, it is false.
Boolean − The value is updatable; by default, it is false.
Defaultside − This is the optional side orientation.
Defaultside − This is the optional side orientation.
The last 2 parameters are optional.
<!doctype html>
<html>
   <head>
      <meta charset = "utf-8">
      <title>MDN Games: Babylon.js demo - shapes</title>
      <script src = "babylon.js"></script>
      <style>
         html,body,canvas { margin: 0; padding: 0; width: 100%; height: 100%; font-size: 0; }
      </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);
            scene.clearColor = new BABYLON.Color3(0, 1, 0);
            
            var camera = new BABYLON.ArcRotateCamera("Camera", 3.2, 1.2, 12, new BABYLON.Vector3(0, 0, 0), scene);
            
            var light = new BABYLON.HemisphericLight("hemi", new BABYLON.Vector3(0, 1, 0), scene);
            
            var plan = BABYLON.Mesh.CreatePlane("plane", 5.0, scene);
            scene.activeCamera.attachControl(canvas);
            return scene;
         };
         var scene = createScene();
         engine.runRenderLoop(function() {
            scene.render();
         });
      </script>
   </body>
</html>
 Print
 Add Notes
 Bookmark this page
How to count all elements within a div using jQuery ? - GeeksforGeeks

31 Dec, 2020
In this article, we will count all elements inside a div element using jQuery. To count all elements inside a div elements, we use find() method and length property.
The find() method is used to find all the descendant elements of the selected element. It will traverse all the way down to the last leaf of the selected element in the DOM tree.
Syntax:
$(selector).find()
Here selector is the selected elements of which all the descendant elements are going to be found.
The length property is used to count number of the elements of the jQuery object.
Syntax:
$(selector).length
Note: Here selector is the object whose length is to be calculated.
Example:
HTML
<!DOCTYPE html><html lang="en">  <head>        <!-- Import jQuery cdn library -->    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>      <script>        $(document).ready(function () {            $("button").click(function () {                var count = $(".GFG").find("*").length;                $("p").after("<h3>Totoal Div Elemennts: "                    + count);            });        });    </script></head>  <body style="text-align: center;">    <h1 style="color: green;">        GeeksforGeeks    </h1>      <h3>        How to count all elements        within a div using jQuery?    </h3>        <div class="GFG">        <p>            GeeksforGeeks computer             science portal        </p>          <input type="text">    </div><br>        <button>Click Here!</button></body>  </html>
Output:
Before Click Button:
After Click Button:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Misc
HTML-Misc
jQuery-Misc
CSS
HTML
JQuery
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to set space between the flexbox ?
Design a web page using HTML and CSS
Form validation using jQuery
How to style a checkbox using CSS?
Search Bar using HTML, CSS and JavaScript
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
How to set input type date in dd-mm-yyyy format using HTML ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
Control Flow Software Testing - GeeksforGeeks

05 Aug, 2019
Control flow testing is a type of software testing that uses program’s control flow as a model. Control flow testing is a structural testing strategy. This testing technique comes under white box testing. For the type of control flow testing, all the structure, design, code and implementation of the software should be known to the testing team.
This type of testing method is often used by developers to test their own code and own implementation as the design, code and the implementation is better known to the developers. This testing method is implemented with the intention to test the logic of the code so that the user requirements can be fulfilled. Its main application is to relate the small programs and segments of the larger programs.
Control Flow Testing Process:Following are the steps involved into the process of control flow testing:
Control Flow Graph Creation:From the given source code a control flow graph is created either manually or by using the software.
Coverage Target:A coverage target is defined over the control flow graph that includes nodes, edges, paths, branches etc.
Test Case Creation:Test cases are created using control flow graphs to cover the defined coverage target.
Test Case Execution:After the creation of test cases over coverage target, further test cases are executed.
Analysis:Analyze the result and find out whether the program is error free or has some defects.
Control Flow Graph:Control Flow Graph is a graphical representation of control flow or computation that is done during the execution of the program. Control flow graphs are mostly used in static analysis as well as compiler applications, as they can accurately represent the flow inside of a program unit. Control flow graph was originally developed by Frances E. Allen.
Cyclomatic Complexity:Cyclomatic Complexity is the quantitative measure of the number of linearly independent paths in it. It is a software metric used to describe the complexity of a program. It is computed using the Control Flow Graph of the program.
M = E - N + 2P 
Advantages of Control flow testing:
It detects almost half of the defects that are determined during the unit testing.
It also determines almost one-third of the defects of the whole program.
It can be performed manually or automated as the control flow graph that is used can be made by hand or by using software also.
Disadvantages of Control flow testing:
It is difficult to find missing paths if program and the model are done by same person.
Unlikely to find spurious features.
Software Testing
Software Engineering
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Differences between Verification and Validation
Software Engineering | Classical Waterfall Model
Software Testing | Basics
Software Requirement Specification (SRS) Format
Levels in Data Flow Diagrams (DFD)
Difference between Alpha and Beta Testing
Software Engineering | White box Testing
Software Engineering | Integration Testing
Software Engineering | Seven Principles of software testing
Difference between Spring and Spring Boot
Python Program for Basic Euclidean algorithms

In this article, we will learn about the solution to the problem statement given below.
Problem statement− Given two numbers we need to calculate gcd of those two numbers and display them.
GCD Greatest Common Divisor of two numbers is the largest number that can divide both of them. Here we follow the euclidean approach to compute the gcd i.e. to repeatedly divide the numbers and stop when the remainder becomes zero.
Now let’s observe the solution in the implementation below −
 Live Demo
# euclid algorithm for calculation of greatest common divisor
def gcd(a, b):
   if a == 0 :
      return b
   return gcd(b%a, a)
a = 11
b = 15
print("gcd of ", a , "&" , b, " is = ", gcd(a, b))
gcd of 11 & 15 is = 1
All the variables are declared in the local scope and their references are seen in the figure above.
In this article, we have learned about how we can make a Python Program for Basic Euclidean algorithms.
Python | place() method in Tkinter

07 Jun, 2019
The Place geometry manager is the simplest of the three general geometry managers provided in Tkinter. It allows you explicitly set the position and size of a window, either in absolute terms, or relative to another window.You can access the place manager through the place() method which is available for all standard widgets.
It is usually not a good idea to use place() for ordinary window and dialog layouts; its simply to much work to get things working as they should. Use the pack() or grid() managers for such purposes.
Syntax:
widget.place(relx = 0.5, rely = 0.5, anchor = CENTER)

Note : place() method can be used with grid() method as well as with pack() method.
Code #1:
# Importing tkinter modulefrom tkinter import * from tkinter.ttk import *  # creating Tk windowmaster = Tk()  # setting geometry of tk windowmaster.geometry("200x200")  # button widgetb1 = Button(master, text = "Click me !")b1.place(relx = 1, x =-2, y = 2, anchor = NE)  # label widgetl = Label(master, text = "I'm a Label")l.place(anchor = NW)  # button widgetb2 = Button(master, text = "GFG")b2.place(relx = 0.5, rely = 0.5, anchor = CENTER)  # infinite loop which is required to# run tkinter program infinitely# until an interrupt occursmainloop()
Output:
When we use pack() or grid() managers, then it is very easy to put two different widgets separate to each other but putting one of them inside other is a bit difficult. But this can easily be achieved by place() method.In place() method, we can use in_ option to put one widget inside other.
Code #2:
# Importing tkinter modulefrom tkinter import * from tkinter.ttk import *  # creating Tk windowmaster = Tk()  # setting geometry of tk windowmaster.geometry("200x200")  # button widgetb2 = Button(master, text = "GFG")b2.pack(fill = X, expand = True, ipady = 10)  # button widgetb1 = Button(master, text = "Click me !")  # This is where b1 is placed inside b2 with in_ optionb1.place(in_= b2, relx = 0.5, rely = 0.5, anchor = CENTER)  # label widgetl = Label(master, text = "I'm a Label")l.place(anchor = NW)  # infinite loop which is required to# run tkinter program infinitely# until an interrupt occursmainloop()
Output: In below images notice that one button is placed inside the other.
Python-gui
Python-tkinter
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
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 ?
Iterate over a list in Python
jQuery | add() method with Example

13 Feb, 2019
The jQuery add() method is used to add element to the existing group of elements. This method can add element to the whole document, or just inside context element if the context parameter is defined.Syntax:
$(selector).add(element, context_parameter)

Here selector helps to find the matching element.Parameters: It accept two parameters that are specified below:
element: It is the selected element.
context_parameter: It is the context parameter of the element defined.
jQuery code to show the working of add() method:
<html>  <head>    <script src="https://ajax.googleapis.com/ajax/libs                 /jquery/3.3.1/jquery.min.js"></script>    <script>        $(document).ready(function() {            $(".heading").add("#para1").add("#span1").            css("background-color", "lightgreen");        });    </script></head>  <body>    <p style="color:green" class="heading">Welcome to GfG!!!</p>    <p style="color:green" id="para1">Welcome to GeeksforGeeks !!!</p>    <span style="color:green" id="span1">Article 1 !!!.</span>    <div>This example adds the same css style for both        "p" and "span" elements, using its class and         id name!!! </div></body>  </html>
Output:
jQuery-Traversing
JavaScript
JQuery
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
Hide or show elements in HTML using display property
Roadmap to Learn JavaScript For Beginners
JQuery | Set the value of an input text field
Form validation using jQuery
How to change selected value of a drop-down list using jQuery?
How to add options to a select element using jQuery?
How to fetch data from JSON file and display in HTML table using jQuery ?
How to use custom theme palettes in Angular?

24 Jun, 2020
We can use custom theme palettes in angular to define our own color palette. And that theme file can be used throughout all components.
Approach:
Firstly, we have to create our own theme file and in that, we have to include mat-core() Sass mixin and import theming file from angular material. After that, we have to start building our color palette and at last, we have to include our created theme file in “angular-material-theme”. After this, we can use our custom color palette by import it into “styles.Scss” file or directly we can import in any component.
Syntax:
 
@import '~@angular/material/theming';
@include mat-core();

//Available color palettes: https://material.io/design/color/

$[variable_name]-app-primary: mat-palette([defining color]);
$[variable_name]-app-accent:  mat-palette([defining colors]);
$[variable_name]-app-warn:  mat-palette([defining colors]);

$[variable_name]-app-theme: mat-light-theme([primary color], [accent color], [warn color]);
(or)
$[variable_name]-app-theme: mat-dark-theme([primary color], [accent color], [warn color]);

@include angular-material-theme($[variable_name]-app-theme);

Example:
@import '~@angular/material/theming';@include mat-core();  /* ======== Angular material custom themes ======== */   $my-custom-primary: mat-palette($mat-deep-purple);$my-custom-accent: mat-palette($mat-pink, 100, 500, A100);$my-custom-warn: mat-palette($mat-lime); //Optional  $my-custom-theme: mat-light-theme(              $my-custom-primary,               $my-custom-accent,               $my-custom-warn);  @include angular-material-theme($my-custom-theme);
Inside mat-palette, we have to define values related to brightness. The default is 500 (which is the true shade of my brand color/accent color). The rest are other shades of that color (where lower numbers mean brighter shades and higher numbers mean darker shades). Again, a lower number means brighter and higher numbers mean darker.
Now we can create a palette by 2 ways:
light
dark
In the above example, we used a light theme, and then we are including particular theme in “angular-material-theme”.
<html><mat-card class="my-alternate-theme">   My Themes:   <button mat-raised-button color="primary">Primary</button>   <button mat-raised-button color="accent">Accent</button>   <button mat-raised-button color="warn">Warning</button></mat-card></html>
Output:Reference: https://material.angular.io/guide/theming
AngularJS-Misc
Picked
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Routing in Angular 9/10
Angular PrimeNG Dropdown Component
Angular 10 (blur) Event
How to make a Bootstrap Modal Popup in Angular 9/8 ?
How to create module with Routing in Angular 9 ?
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 ?
GATE | GATE CS 2019 | Question 26

15 Feb, 2019
The following C program is executed on a Unix / Linux system:
#include <unistd.h>  int main() {    int i;    for (i = 0; i < 10; i++)      if (i % 2 == 0) fork();    return 0;  }
The total number of child process created is __________ .
Note – This was Numerical Type question.
(A) 31(B) 63(C) 5(D) 6Answer: (A)Explanation: Condition “if” will be satisfy for i = 0, 2, 4, 6, 8 only. So, “fork()” will call for 5 times.
Total number of processes created is,
= 2number of fork() 
There is always only one parent process of these processes and remaining will be child processes.
Hence number of child process created is,
= 2number of fork() - 1
= 25 - 1
= 32 - 1
= 31
So, option (A) is correct.Quiz of this Question
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE CS 2008 | Question 46
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE CS 2008 | Question 40
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2014-(Set-1) | Question 51
GATE | GATE CS 1996 | Question 63
GATE | GATE-CS-2004 | Question 31
GATE | GATE CS 2011 | Question 49
Summarise multiple columns using dplyr in R

24 Oct, 2021
In this article, we will discuss how to summarise multiple columns using dplyr package in R Programming Language,
The summarise_all method in R is used to affect every column of the data frame. The output data frame returns all the columns of the data frame where the specified function is applied over every column. 
summarise_all(data, function)
Arguments :
data – The data frame to summarise the columns of
function – The function to apply on all the data frame columns.
R
library("dplyr")  # creating a data framedf < - data.frame(col1=sample(rep(c(1: 5), each=3)),                  col2=5: 19)  print("original dataframe")print(df)  # summarising the dataprint("summarised dataframe")summarise_all(df, mean)
Output
[1] "original dataframe"
col1 col2 
1     2    1 
2     3    2 
3     4    3 
4     2    4 
5     2    5 
6     4    6 
7     1    7 
8     1    8 
9     5    9 
10    3   10 
11    5   11 
12    1   12 
13    4   13 
14    5   14 
15    3   15    
col1 col2
 1    3    8
Explanation: The mean of all the values is calculated column-wise, that is, the sum of values of col1 is calculated and divided by the number of rows. Similarly, the summation of values is computed for col2 and col3. All the columns are returned in the final output. 
The summarise_at() affects variables that are extracted with a character vector or vars(). It applies the selected function to the data frame. The output data frame contains all the columns that are specified in the summarise_at method. In case all the columns of the data frame are mentioned, then the functionality of this method is the same as the summarise_all method. 
data %>%
 summarise_at(vars(-cols(), ...), function)
Arguments :
data – The data frame to summarise the columns of
function – The function to apply on all the data frame columns.
R
library("dplyr")  # creating a data framedf < - data.frame(col1=sample(rep(c(1: 5), each=3)),                  col2=1: 15,                  col3=letters[1:15])  print("original dataframe")print(df)  # summarising the dataprint("summarised dataframe")df % >%summarise_at(c("col1", "col2"), mean, na.rm=TRUE)
Output
[1] "original dataframe" 
col1 col2 col3 
1     3    1    a 
2     5    2    b 
3     4    3    c 
4     4    4    d 
5     5    5    e 
6     3    6    f 
7     2    7    g 
8     2    8    h 
9     1    9    i 
10    4   10    j 
11    2   11    k 
12    5   12    l 
13    1   13    m 
14    3   14    n 
15    1   15    o 
[1] "summarised dataframe" 
   col1 col2 
1    3    8
Picked
R Dplyr
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
How to Split Column Into Multiple Columns in R DataFrame?
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to filter R DataFrame by values in a column?
R - if statement
Logistic Regression in R Programming
Replace Specific Characters in String in R
How to import an Excel File into R ?
Joining of Dataframes in R Programming
sciPy stats.tmean() | Python

10 Feb, 2019
scipy.stats.tmean(array, limits=None, inclusive=(True, True)) calculates the trimmed mean of the array elements along the specified axis of the array.
It’s formula –
Parameters :array: Input array or object having the elements to calculate the trimmed mean.axis: Axis along which the trimmed mean is to be computed. By default axis = 0.limits: Lower and upper bound of the array to consider, values less than the lower limit or greater than the upper limit will be ignored. If limits is None [default], then all values are used.
Returns : Trimmed mean of the array elements based on the set parameters.
Code #1:
# Trimmed Mean    from scipy import statsimport numpy as np    # array elements ranging from 0 to 19x = np.arange(20)    print("Trimmed Mean :", stats.tmean(x))       print("\nTrimmed Mean by setting limit : ",       stats.tmean(x, (2, 10)))
Trimmed Mean : 9.5

Trimmed Mean by setting limit :  6.0

Code #2: With multi-dimensional data, axis() working
# Trimmed Mean    from scipy import statsimport numpy as np   arr1 = [[1, 3, 27],         [5, 3, 18],         [17, 16, 333],         [3, 6, 82]]      # using axis = 0print("\nTrimmed Mean is with default axis = 0 : \n",       stats.tmean(arr1, axis = 1))
Trimmed Mean is with default axis = 0 : 
 42.8333333333

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
Different ways to create Pandas Dataframe
Enumerate() 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
Convert integer to string in Python
Python OOPs Concepts
Redis - List Linsert Command

Redis LINSERT command inserts the value in the list stored at the key either before or after the reference value pivot. When the key does not exist, it is considered an empty list and no operation is performed. An error is returned when the key exists but does not hold a list value.
Integer reply, the length of the list after the insert operation, or -1 when the value pivot was not found.
Following is the basic syntax of Redis LINSERT command.
redis 127.0.0.1:6379> LINSERT KEY_NAME BEFORE EXISTING_VALUE NEW_VALUE

redis 127.0.0.1:6379> RPUSH list1 "foo" 
(integer) 1 
redis 127.0.0.1:6379> RPUSH list1 "bar" 
(integer) 2 
redis 127.0.0.1:6379> LINSERT list1 BEFORE "bar" "Yes" 
(integer) 3 
redis 127.0.0.1:6379> LRANGE mylist 0 -1 
1) "foo" 
2) "Yes" 
3) "bar"


    22 Lectures 
     40 mins

 Skillbakerystudios
 Print
 Add Notes
 Bookmark this page
Frequency Domain Filters and its Types - GeeksforGeeks

05 Dec, 2019
Frequency Domain Filters are used for smoothing and sharpening of image by removal of high or low frequency components. Sometimes it is possible of removal of very high and very low frequency. Frequency domain filters are different from spatial domain filters as it basically focuses on the frequency of the images. It is basically done for two basic operation i.e., Smoothing and Sharpening.
These are of 3 types:
1. Low pass filter:Low pass filter removes the high frequency components that means it keeps low frequency components. It is used for smoothing the image. It is used to smoothen the image by attenuating high frequency components and preserving low frequency components.Mechanism of low pass filtering in frequency domain is given by:
G(u, v) = H(u, v) . F(u, v)
where F(u, v) is the Fourier Transform of original image
and H(u, v) is the Fourier Transform of filtering mask 
2. High pass filter:High pass filter removes the low frequency components that means it keeps high frequency components. It is used for sharpening the image. It is used to sharpen the image by attenuating low frequency components and preserving high frequency components.Mechanism of high pass filtering in frequency domain is given by:
H(u, v) = 1 - H'(u, v)
where H(u, v) is the Fourier Transform of high pass filtering
and H'(u, v) is the Fourier Transform of low pass filtering 
3. Band pass filter:Band pass filter removes the very low frequency and very high frequency components that means it keeps the moderate range band of frequencies. Band pass filtering is used to enhance edges while reducing the noise at the same time.
computer-graphics
Misc
Misc
Misc
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Find all factors of a natural number | Set 1
How to write Regular Expressions?
fgets() and gets() in C language
Minimax Algorithm in Game Theory | Set 3 (Tic-Tac-Toe AI - Finding optimal move)
Association Rule
Recursive Functions
Software Engineering | Prototyping Model
Java Math min() method with Examples
Set add() method in Java with Examples
OOPs | Object Oriented Design
Find the difference of largest and the smallest number in an array without sorting it in JavaScript

We have an array of Numbers that are arranged in pure random order. Our job is to write a
function that takes in one such array of Numbers and returns the difference of greatest and
smallest numbers present in it, but without sorting the array.
Therefore, let's write the code for this function −
We will use the Array.prototype.reduce() function to pick the smallest and greatest numbers
from the array and later will return their difference. The code for this function will be −
const arr = [23, 65, 67, 23, 2, 6, 87, 23, 45, 65, 3, 234, 3];
const findDifference = arr => {
   if(!arr.length){
      return 0;
   }
   const creds = arr.reduce((acc, val) => {
      let { max, min } = acc;
      if(val > max){
         max = val;
      };
      if(val < min){
         min = val;
      };
      return { max, min };
   }, {
      max: -Infinity,
      min: Infinity
   });
   return creds.max - creds.min;
};
console.log(findDifference(arr));
The output in the console will be −
232
TypeScript - Number toString()

This method returns a string representing the specified object. The toString() method parses its first argument, and attempts to return a string representation in the specified radix (base).
number.toString( [radix] )

radix − An integer between 2 and 36 specifying the base to use for representing numeric values.
Returns a string representing the specified Number object.
var num = new Number(10); 
console.log(num.toString()); 
console.log(num.toString(2)); 
console.log(num.toString(8));

On compiling, it will generate the same code in JavaScript.
The code will produce the following output −
10 
1010 
12


    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