code-rag-bench/online-tutorials huggingface dataset:
SVG path attribute

31 Mar, 2022
The path attribute defines a text path or the motion path along with the characters of a text are displayed or a referenced element is animated respectively. The elements that are using this attribute includes: <animateMotion> and <textPath>.
Syntax:
path = path-data

Attribute Values: The path attribute accepts the values mentioned above and described below
path-data: It has two different value i.e. it can either define a text path or the motion path along with the glyphs are to be rendered or animated respectively.
Note: Its default value is considered as normal.
Below examples illustrate the use of path attribute.
Example 1:
HTML
<!DOCTYPE html><html>  <body>    <h1 style="color: green;             margin-left: 10px;">        GeeksforGeeks    </h1>      <svg viewBox="0 10 500 100"         xmlns="http://www.w3.org/2000/svg">                  <path fill="green"             d = "M10, 90 Q90, 90 90, 45 Q90,                10 50, 10 Q10, 10 10, 40 Q10,                70 45, 70 Q70, 70 75, 50" />          <text>            <textPath                 path = "M10, 90 Q90, 90 90,                        45 Q90, 10 50, 10 Q10,                        10 10, 40 Q10, 70 45,                        70 Q70, 70 75, 50">                It is a Compute Science Portal            </textPath>        </text>    </svg></body>  </html>
Output:
Example 2:
HTML
<!DOCTYPE html><html>  <body>    <h1 style="color: green;             margin-left: 80px;">        GeeksforGeeks    </h1>      <svg viewBox="0 15 700 200"         xmlns="http://www.w3.org/2000/svg">          <path fill="none" stroke="green"             d = "M 100, 100 m -75, 0 a 75,                75 0 1, 0 150, 0 a 75, 75                 0 1, 0 -150, 0" />          <circle r="5" fill="green">            <animateMotion dur="5s"                 repeatCount="indefinite"                 path="M 100, 100 m -75, 0 a                 75, 75 0 1, 0 150, 0 a 75,                 75 0 1, 0 -150,0" />        </circle>    </svg></body>  </html>
Output:
HTML-SVG
SVG-Attribute
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Solidity - Mapping

Mapping is a reference type as arrays and structs. Following is the syntax to declare a mapping type.
mapping(_KeyType => _ValueType)

Where
_KeyType − can be any built-in types plus bytes and string. No reference type or complex objects are allowed.
_KeyType − can be any built-in types plus bytes and string. No reference type or complex objects are allowed.
_ValueType − can be any type.
_ValueType − can be any type.
Mapping can only have type of storage and are generally used for state variables.
Mapping can only have type of storage and are generally used for state variables.
Mapping can be marked public. Solidity automatically create getter for it.
Mapping can be marked public. Solidity automatically create getter for it.
Try the following code to understand how the mapping type works in Solidity.
pragma solidity ^0.5.0;

contract LedgerBalance {
   mapping(address => uint) public balances;

   function updateBalance(uint newBalance) public {
      balances[msg.sender] = newBalance;
   }
}
contract Updater {
   function updateBalance() public returns (uint) {
      LedgerBalance ledgerBalance = new LedgerBalance();
      ledgerBalance.updateBalance(10);
      return ledgerBalance.balances(address(this));
   }
}
Run the above program using steps provided in Solidity First Application chapter.
First Click updateBalance Button to set the value as 10 then look into the logs which will show the decoded output as − 
{
   "0": "uint256: 10"
}


    38 Lectures 
     4.5 hours 

 Abhilash Nelson

    62 Lectures 
     8.5 hours 

 Frahaan Hussain

    31 Lectures 
     3.5 hours 

 Swapnil Kole
 Print
 Add Notes
 Bookmark this page
How to add HTML elements dynamically using JavaScript ?

22 Nov, 2021
In this article, we learn how to add HTML elements dynamically using JavaScript. A basic understanding of HTML, CSS, and javascript is required. Here we are going to use a button and by clicking this button, we can add an HTML element dynamically in this example.
Approach: Create an HTML file with any name (Ex- index.html) then write the outer HTML template and take one button so that when someone clicks on the button, an HTML is dynamically added one by one in a list format. We have attached an onclick event listener to the button, when someone clicks that button immediately the event will fire and execute the callback function attached to that event listener inside the callback function we need to mention a certain task that we want to happen after an onclick event is a fire. 
Below is the implementation of the above approach:
index.html
<!DOCTYPE html><html>  <head>    <style>        h1 {            color: green;            display: flex;            justify-content: center;        }          #mybutton {            display: block;            margin: 0 auto;        }          #innerdiv {            display: flex;            flex-direction: column;            justify-content: center;            align-items: center;        }    </style></head>  <body>    <h1>        GeeksforGeeks    </h1>    <div id="innerdiv"></div>    <button id="mybutton">        click me    </button>    <script>        document.getElementById("mybutton").            addEventListener("click", function () {         document.getElementById("innerdiv").            innerHTML += "<h3>Hello geeks</h3>";        });    </script></body>  </html>
Output:
HTML-Questions
JavaScript-Questions
Picked
HTML
JavaScript
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
std::cbrt() in C++

24 Jan, 2022
The std::cbrt() is an inbuilt function in C++ STL which is used to calculate the cube root of number. It accepts a number as argument and returns the cube root of that number.Syntax:  
// Returns cube root num (num can be
// of type int, double, long double or
// long long type.
// The return type is same as parameter
// passed.
cbrt(num)
Parameter: The parameter can be of int, double, long double or long long type.Return Value: It returns the cube root of the number num. The datatype of returned cube root is same as that of the parameter passed except when an integer is passed as parameter. If the parameter passed is integral then the cbrt() function will return a value of type double. Examples:  
Input : 8
Output : 2 

Input : 9
Output : 2.08008
Below program illustrate the cbrt() function:  
CPP
// CPP program to demonstrate the cbrt()// STL function#include <bits/stdc++.h>using namespace std; int main(){    // cbrt() function with integral    // argument    int num1 = 9;    cout << cbrt(num1) << endl;     // cbrt() function with floating-point    // argument    double num2 = 7.11;    cout << cbrt(num2) << endl;     long long num3 = 7;    cout << cbrt(num3);     return 0;}
Output:  
2.08008
1.9229
1.91293
 
tranlehuy2k1
sumitgumber28
CPP-Functions
cpp-math
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Set in C++ Standard Template Library (STL)
Bitwise Operators in C/C++
Priority Queue in C++ Standard Template Library (STL)
vector erase() and clear() in C++
unordered_map in C++ STL
Substring in C++
Object Oriented Programming in C++
The C++ Standard Template Library (STL)
Inheritance in C++
C++ Classes and Objects
multimap equal_range() in C++ STL

13 Nov, 2020
The multimap::equal_range() is a built-in function in C++ STL which returns an iterator of pairs. The pair refers to the bounds of a range that includes all the elements in the container which have a key equivalent to k. If there are no matches with key K, the range returned is of length 0 with both iterators pointing to the first element that has a key considered to go after k according to the container’s internal comparison object (key_comp). 
Syntax:  
iterator multimap_name.equal_range(key)


Parameters: This function accepts a single mandatory parameter key which specifies the element whose range in the container is to be returned. 
Return Value: The function returns an iterator of pairs. The pair refers to the bounds of a range that includes all the elements in the container which have a key equivalent to k. If there are no matches with key K, the range returned is of length 0 with both iterators pointing to the first element that has a key considered to go after k according to the container’s internal comparison object (key_comp).
Program below illustrate the above method:  
C++
// C++ program to illustrate the// multimap::equal_range() function#include <bits/stdc++.h>using namespace std; int main(){     // initialize container    multimap<int, int> mp;    // insert elements in random order    mp.insert({ 2, 30 });    mp.insert({ 1, 40 });    mp.insert({ 3, 60 });    mp.insert({ 1, 20 });    mp.insert({ 5, 50 });     // Stores the range of key 1    auto it = mp.equal_range(1);     cout << "The multimap elements of key 1 is : \n";    cout << "KEY\tELEMENT\n";     // Prints all the elements of key 1    for (auto itr = it.first; itr != it.second; ++itr) {        cout << itr->first             << '\t' << itr->second << '\n';    }    return 0;}
The multimap elements of key 1 is : 
KEY    ELEMENT
1    40
1    20





 
arorakashish0911
CPP-Functions
cpp-multimap
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Bitwise Operators in C/C++
vector erase() and clear() in C++
Inheritance in C++
Substring in C++
C++ Classes and Objects
The C++ Standard Template Library (STL)
Sorting a vector in C++
Object Oriented Programming in C++
Priority Queue in C++ Standard Template Library (STL)
2D Vector In C++ With User Defined Size
Python modf() Method

Python number  method modf() returns the fractional and integer parts of x in a two-item tuple. Both parts have the same sign as x. The integer part is returned as a float.
Following is the syntax for modf() method −
import math

math.modf( x )
Note − This function is not accessible directly, so we need to import math module and then we need to call this function using math static object.
x − This is a numeric expression.
x − This is a numeric expression.
This method returns the fractional and integer parts of x in a two-item tuple. Both parts have the same sign as x. The integer part is returned as a float.
The following example shows the usage of modf() method.
#!/usr/bin/python
import math   # This will import math module

print "math.modf(100.12) : ", math.modf(100.12)
print "math.modf(100.72) : ", math.modf(100.72)
print "math.modf(119L) : ", math.modf(119L)
print "math.modf(math.pi) : ", math.modf(math.pi)
When we run above program, it produces following result −
math.modf(100.12) :  (0.12000000000000455, 100.0)
math.modf(100.72) :  (0.71999999999999886, 100.0)
math.modf(119L) :    (0.0, 119.0)
math.modf(math.pi) :  (0.14159265358979312, 3.0)


    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
C Program to calculate the Round Trip Time (RTT)

Given an Url address of any website; the task is to calculate the round trip time of a website.
Round Trip Time(RTT) is the total time or the length of a time which is taken to send a signal plus the time taken to receive the acknowledgement of that signal to be received. This time also consist of the propagation times between two points of a signal.
An end user can determine his/her round trip time from an IP address by pinging that address.
The Round Trip time’ result depends upon the following reasons −
The Transmission medium.
The presence of Interface in the circuit.
Number of nodes from the source to the destination.
Amount of traffic.
Physical Distance from the source to the destination.
Nature of the transmission medium(wireless, fiber optic, etc.).
Number of requests.
Presence of interface in the circuit.
Generally the duration of Round Trip Time will be in milliseconds and we displaying output in Seconds.
Input: www.tutorialspoint.com
Output: Time taken:0.3676435947418213
Input: www.indiatoday.in
Output: Time taken:0.4621298224721691
Approach we will be using to solve the given problem −
Take the input string of the URL whose RTT(Round Trip Time) we want to calculate.
Record the time before requesting the URL and store it into a variable.
Send the request.
Record the time after receiving acknowledgement.
Compare both the times we will get the RTT.
Start
   Step 1 -> import time
   Step 2 -> import requests
   Step 3 -> define a function def roundtriptime(url):
      Set t1 = time.time()
      Set req = requests.get(url)
      Set t2 = time.time()
      Set t = str(t2-t1)
      Print Time taken
   Step 4 -> Initialize url = "http://www.tutorialspoint.com"
   Step 5 -> Call function roundtriptime(url)
Stop
import time
import requests
# Function to calculate the roundtriptime
def roundtriptime(url):
   # time when the signal is sent
      t1 = time.time()
      req = requests.get(url)
   # time when the acknowledgement
   # is received
      t2 = time.time()
   # total time taken
      t = str(t2-t1)
      print("Time taken:" + t)
   # url address
      url = "http://www.tutorialspoint.com"
      roundtriptime(url)
Time taken:0.3676435947418213
PHP timestamp to HTML5 input type=datetime element

For HTML5 input time, in PHP:
echo date("Y-m-d\TH:i:s");
The output would be:
2018-28-03T19:12:49
HTML with Timestamp would be:
<input type="datetime" value="<?php echo date("Y-m-d\TH:i:s",$timestamp); ?>"/>
\def - Tex Command

\def - Used for defining your own commands.
{ \def\myCommandName{ <replacement text> } }
\def command is used to define your own commands (control sequences, macros, definitions); must appear (within math delimiters) before it is used;

\def\myHearts{\color{purple}{\heartsuit}\kern-2.5pt\color{green}{\heartsuit}}
\myHearts\myHearts


♡♡♡♡


\def\myHearts#1#2{\color{#1}{\heartsuit}\kern-2.5pt\color{#2}{\heartsuit}}
\myHearts{red}{blue}


♡♡



\def\myHearts{\color{purple}{\heartsuit}\kern-2.5pt\color{green}{\heartsuit}}
\myHearts\myHearts


♡♡♡♡


\def\myHearts{\color{purple}{\heartsuit}\kern-2.5pt\color{green}{\heartsuit}}
\myHearts\myHearts

\def\myHearts#1#2{\color{#1}{\heartsuit}\kern-2.5pt\color{#2}{\heartsuit}}
\myHearts{red}{blue}


♡♡


\def\myHearts#1#2{\color{#1}{\heartsuit}\kern-2.5pt\color{#2}{\heartsuit}}
\myHearts{red}{blue}


    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
Logging in SAP using command line

sapshcut.exe command can be used to log in to SAP from command line as shown in below example:
Add the directory that contains the sapshcut.exe command to your system or user path. The sapshcut.exe command is installed as part of the SAP client into the following directory: C:\Program Files\SAP\FrontEnd\SAPguiTo add additional directories to the system or user path on Windows systems, select Control Panel > System > Advanced > Environment Variables.The .bat file must be named sapshcut.bat  must be located in your default path preceding the sapshcut.exe file.The following parameters are passed to the sapshcut.bat file when called from a predefined Launch definition −
%1
keyword "-command"

%2
transaction_name, for example: SM13

%3
keyword "-system"

%4
SAP_system_identifier, for example: TV1

%5

keyword "-client"
%6
client_number, for example: 100
The following example shows a sample sapshcut.cmd file. In this example, you use a different user ID and password when sapshcut is run through the Application Launch for the system TV1. All other SAP systems use the default logon parameters.
@echo off set sapshcut="C:\Program Files\SAP\FrontEnd\SAPgui\sapshcut.exe"
if "%4" == "TV1" (
   %sapshcut% %* -user=myid -password=mypwd
) else (
   %sapshcut% %*
)
Find closest smaller value for every element in array in C++

Here we will see how to find the closest value for every element in an array. If an element x has the next element that is larger than it, and also present in the array, then that will be the greater value of that element. If the element is not present, then return -1. Suppose the array elements are [10, 5, 11, 6, 20, 12], then the greater elements are [11, 6, 12, 10, -1, 20]. As 20 has not greater value in the array, then print -1.
To solve this, we will use the settings in C++ STL. The set is implemented using the binary tree approach. In binary tree always the in-order successor is the next larger element. So we can get the element in O(log n) time.
 Live Demo
#include<iostream>
#include<set>
using namespace std;
void nearestGreatest(int arr[], int n) {
   set<int> tempSet;
   for (int i = 0; i < n; i++)
      tempSet.insert(arr[i]);
   for (int i = 0; i < n; i++) {
      auto next_greater = tempSet.upper_bound(arr[i]);
      if (next_greater == tempSet.end())
         cout << -1 << " ";
      else
         cout << *next_greater << " ";
   }
}
int main() {
   int arr[] = {10, 5, 11, 6, 20, 12};
   int n = sizeof(arr) / sizeof(arr[0]);
   nearestGreatest(arr, n);
}
11 6 12 10 -1 20
Python List extend() Method - GeeksforGeeks

05 Aug, 2021
The Python’s List extend() method iterates over an iterable like string, list, tuple, etc., and adds each element of the iterable to the end of List. The length of the list increases by the number of elements present in the iterable.
Syntax: list.extend(iterable)
Parameters:
iterable: Any iterable (list, set, tuple, etc.)
Returns:
The extend() method modifies the original list. It doesn’t return any value.
Python
# my_listmy_list = ['geeks', 'for']  # Another listanother_list = [6, 0, 4, 1]  # Using extend() methodmy_list.extend(another_list)  print my_list
Output:
['geeks', 'for', 6, 0, 4, 1]
Python
# My Listmy_list = ['geeks', 'for', 'geeks']  # My Tuplemy_tuple = ('DSA', 'Java')  # My Setmy_set = {'Flutter', 'Android'}  # Append tuple to the listmy_list.extend(my_tuple)  print(my_list)  # Append set to the listmy_list.extend(my_set)  print(my_list)
Output:
['geeks', 'for', 'geeks', 'DSA', 'Java']
['geeks', 'for', 'geeks', 'DSA', 'Java', 'Android', 'Flutter']
A string is iterable, so if you extend a list with a string, you’ll append each character as you iterate over the string.
Python
# My listmy_list = ['geeks', 'for', 6, 0, 4, 1]  # My stringmy_list.extend('geeks')  print my_list
Output:
['geeks', 'for', 6, 0, 4, 1, 'g', 'e', 'e', 'k', 's']
nikhilaggarwal3
python-list
python-list-functions
Python
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Box Plot in Python using Matplotlib
Python | Get dictionary keys as a list
Bar Plot in Matplotlib
Multithreading in Python | Set 2 (Synchronization)
Python Dictionary keys() method
loops in python
Python - Call function from another file
Ways to filter Pandas DataFrame by column values
Python | Convert set into a list
Python program to find number of days between two given dates
Difference between PUT and POST HTTP requests - GeeksforGeeks

31 Aug, 2021
PUT and POST requests have lots of similarities certainly when making an HTTP request and both can be meddled with so that one performs functions of the other. This article revolves around the major differences between PUT and POST Requests. 
PUT is a request method supported by HTTP used by the World Wide Web. The PUT method requests that the enclosed entity be stored under the supplied URI. If the URI refers to an already existing resource, it is modified and if the URI does not point to an existing resource, then the server can create the resource with that URI. Example – Let’s try making a request to httpbin’s APIs for example purposes. 
Python3
import requests # Making a PUT requestr = requests.put('https://httpbin.org/put', data={'key':'value'}) #check status code for response received# success code - 200print(r) # print content of requestprint(r.content)
save this file as request.py and through terminal run,  
python request.py
Output  
 POST HTTP Request
POST is a request method supported by HTTP used by the World Wide Web. By design, the POST request method requests that a web server accepts the data enclosed in the body of the request message, most likely for storing it. It is often used when uploading a file or when submitting a completed web form. Example – Let’s try making a request to httpbin’s APIs for example purposes.  
Python3
import requests # Making a POST requestr = requests.post('https://httpbin.org/post', data={'key':'value'}) #check status code for response received# success code - 200print(r) # print content of requestprint(r.json())
save this file as request.py and through terminal run,  
python request.py
Output – 
 Difference between PUT and POST methods
PUT request is made to a particular resource. If the Request-URI refers to an already existing resource, an update operation will happen, otherwise create operation should happen if Request-URI is a valid resource URI (assuming client is allowed to determine resource identifier). Example –  
PUT /article/{article-id}
 
POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line. It essentially means that POST request-URI should be of a collection URI. Example –  
POST /articles
 
 
ManasChhabra2
ruhelaa48
Python-requests
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
Python String | replace()
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Convert integer to string in Python
Python | Print Alphabets till N - GeeksforGeeks

26 Nov, 2019
Sometimes, while working with Python, we can have a problem in which we need to print specific number of alphabets in order. This can have application in school level programming. Let’s discuss certain ways in which this problem can be solved.
Method #1 : Using loop + chr()This is brute force way to perform this task. In this, we iterate the elements till which we need to print and concatenate the strings accordingly after conversion to character using chr().
# Python3 code to demonstrate working of# Print Alphabets till N# Using loop  # initialize N N = 20  # printing N print("Number of elements required : " + str(N))  # Print Alphabets till N# Using loopres = ""for idx in range(97, 97 + N):       res = res + chr(idx)       # printing resultprint("Alphabets till N are : " + str(res))
Number of elements required : 20
Alphabets till N are : abcdefghijklmnopqrst

 
Method #2 : Using string.ascii_lowercase + slicingCombination of above functionalities can also be used to perform this task. In this, we use inbuilt function to get extract the lowercase string and extract the N characters using slicing.
# Python3 code to demonstrate working of# Print Alphabets till N# Using string.ascii_lowercase + slicingimport string  # initialize N N = 20  # printing N print("Number of elements required : " + str(N))  # Print Alphabets till N# Using string.ascii_lowercase + slicingres = string.ascii_lowercase[:N]      # printing resultprint("Alphabets till N are : " + str(res))
Number of elements required : 20
Alphabets till N are : abcdefghijklmnopqrst

Python string-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 ?
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
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?
AngularJS | ng-click Directive - GeeksforGeeks

28 Mar, 2019
The ng-click Directive in AngluarJS is used to apply custom behavior when an element is clicked. It can be used to show/hide some element or it can popup alert when button is clicked.
Syntax:
<element ng-click="expression"> Contents... </element>
Example 1: This example uses ng-click Directive to display an alert message after clicking the element.
<!DOCTYPE html><html>      <head>    <title>ng-click Directive</title>      <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">    </script></head>   <body ng-app="geek" style="text-align:center">          <h1 style="color:green">GeeksforGeeks</h1>    <h2>ng-click Directive</h2>          <div ng-controller="app">        <button>            <a href="" ng-click="alert()">                Click Here            </a>        </button>    </div>          <script>        var app = angular.module("geek", []);        app.controller('app', ['$scope', function ($app) {            $app.alert = function () {                alert("This is an example of ng-click");            }        }]);    </script></body>  </html>
Output:Before clicking the button:After clicking the button:
Example 2: This example uses ng-click Directive to display some content after clicking the element.
<!DOCTYPE html><html>      <head>    <title>ng-click Directive</title>      <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">    </script></head>   <body ng-app="" style="text-align:center">          <h1 style="color:green">GeeksforGeeks</h1>    <h2>ng-click Directive</h2>          <form name="form">        <div ng-hide="isShow">            Enter Name:  <input type="text" required ng-model="Name" />                          <br><br>                          <input type="button" ng-disabled="form.$invalid"                    ng-click="isShow = true" value="Sign in" />        </div>                  <div ng-show="isShow">            Sign in successful.<br>            <input type="button" ng-click="isShow = false;Name=''"                    value="Logout" />        </div>    </form></body>  </html>
Output:Before clicking the button:After clicking the button:
AngularJS-Directives
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Angular File Upload
Angular | keyup event
Angular PrimeNG Dropdown Component
Auth Guards in Angular 9/10/11
Angular PrimeNG Calendar Component
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Binary Search (bisect) in Python - GeeksforGeeks

04 Feb, 2022
Binary Search is a technique used to search element in a sorted list. In this article, we will looking at library functions to do Binary Search.Finding first occurrence of an element.  
bisect.bisect_left(a, x, lo=0, hi=len(a)) : Returns leftmost insertion point of x in a sorted list. Last two parameters are optional, they are used to search in sublist.
 
Python3
# Python code to demonstrate working# of binary search in libraryfrom bisect import bisect_left def BinarySearch(a, x):    i = bisect_left(a, x)    if i != len(a) and a[i] == x:        return i    else:        return -1 a  = [1, 2, 4, 4, 8]x = int(4)res = BinarySearch(a, x)if res == -1:    print(x, "is absent")else:    print("First occurrence of", x, "is present at", res)
First occurrence of 4 is present at 2
 
Finding greatest value smaller than x.  
Python3
# Python code to demonstrate working# of binary search in libraryfrom bisect import bisect_left def BinarySearch(a, x):    i = bisect_left(a, x)    if i:        return (i-1)    else:        return -1 # Driver codea  = [1, 2, 4, 4, 8]x = int(7)res = BinarySearch(a, x)if res == -1:    print("No value smaller than ", x)else:    print("Largest value smaller than ", x, " is at index ", res)
Largest value smaller than  7  is at index  3
 
Finding rightmost occurrence 
bisect.bisect_right(a, x, lo=0, hi=len(a)) Returns rightmost insertion point of x in a sorted list a. Last two parameters are optional, they are used to search in sublist.
 
Python3
# Python code to demonstrate working# of binary search in libraryfrom bisect import bisect_right def BinarySearch(a, x):    i = bisect_right(a, x)    if i != 0 and a[i-1] == x:        return (i-1)    else:        return -1 a  = [1, 2, 4, 4]x = int(4)res = BinarySearch(a, x)if res == -1:    print(x, "is absent")else:    print("Last occurrence of", x, "is present at", res)
Last occurrence of 4 is present at 3
 
Please refer Binary Search for writing your own Binary Search code.Reference : https://docs.python.org/3/library/bisect.html 
hm32005
Binary Search
python searching-exercises
python-list
python-list-functions
Divide and Conquer
Python
Python Programs
Searching
python-list
Searching
Divide and Conquer
Binary Search
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Program for Tower of Hanoi
Divide and Conquer Algorithm | Introduction
Median of two sorted arrays of different sizes
Divide and Conquer | Set 5 (Strassen's Matrix Multiplication)
Write a program to calculate pow(x,n)
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
How to rotate an image in imageview by an angle on Android using Kotlin?

This example demonstrates how to rotate an image in imageview by an angle on Android using Kotlin.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:padding="2dp"
   tools:context=".MainActivity">
   <ImageView
      android:id="@+id/imageView"
      android:layout_width="match_parent"
      android:layout_height="600dp"
      android:src="@drawable/image" />
   <Button
      android:layout_above="@+id/imageView"
      android:id="@+id/btnRotate"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_centerInParent="true"
      android:text="Rotate View"
      android:textStyle="bold" />
</RelativeLayout>
Step 3 − Add the following code to src/MainActivity.kt
import android.os.Bundle
import android.widget.Button
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() {
   lateinit var imageView: ImageView
   lateinit var btnRotate: Button
   override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
      title = "KotlinApp"
      imageView = findViewById(R.id.imageView)
      btnRotate = findViewById(R.id.btnRotate)
      btnRotate.setOnClickListener { imageView.rotation = 90f }
   }
}
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.q11">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click the Run icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen
Tryit Editor v3.7

CSS Rounded Corners
Tryit: Creating rounded corners
Best data type for storing currency values in a MySQL database?

For representation of money, we need to use Decimal (TotalDigitsinteger, DigitsAfterDecimalinteger) method.
Let’s say, we need to display the value 345.66. For that, count how many digits are available. In value 345.66, there are 5 digits in total and 2 digits after decimal point, which is 66.
We can represent the same with the help of Decimal() method from MySQL. Here is the exact representation.
DECIMAL(5,2)
Let us first create a table and consider the same above representation for our example −
mysql> create table MoneyRepresentation
   -> (
   -> Money Decimal(5,2)
   -> );
Query OK, 0 rows affected (0.65 sec)
Let us insert the same value i.e. 345.66
mysql> insert into MoneyRepresentation values(345.66);
Query OK, 1 row affected (0.13 sec)
Display all records with the help of SELECT statement. The query is as follows −
mysql> select *from MoneyRepresentation;
The following is the output.
+--------+
| Money  |
+--------+
| 345.66 |
+--------+
1 row in set (0.00 sec)

Look at the above output, we got 5 digits total and added 2 digits after decimal point because we have set the function as
Decimal(5,2)
How to add a new column to a data frame using mutate in R?

The mutate function of dplyr package in R can help us to add a new column to a data frame and the benefit of using mutate is that we can decide the position of the new column during the addition. For example, if we have a data frame called df that contains three columns say x, y, a then we can add a new column say z after y using mutate function. To understand how it can be done, check out the below examples.
Consider the below data frame −
Live Demo
> x1<-rpois(20,2)
> x3<-rpois(20,5)
> df1<-data.frame(x1,x3)
> df1
   x1 x3
1  2  3
2  1  7
3  1  6
4  5  6
5  2  7
6  5  2
7  1  7
8  2  5
9  1  4
10 2  7
11 2  3
12 1  6
13 3  5
14 3  4
15 2  7
16 3  7
17 6  7
18 2  9
19 1  5
20 1  5
Loading dplyr package and adding a new column x2 after x1 in df1 −
> library(dplyr)
> df1%>%mutate(x2=rpois(20,1),.after=x1)
   x1 x2 x3
1  2  0  3
2  1  0  7
3  1  1  6
4  5  0  6
5  2  1  7
6  5  0  2
7  1  1  7
8  2  1  5
9  1  0  4
10 2  1  7
11 2  0  3
12 1  1  6
13 3  1  5
14 3  1  4
15 2  1  7
16 3  4  7
17 6  1  7
18 2  2  9
19 1  1  5
20 1  4  5
Live Demo
> y1<-rnorm(20)
> y2<-rnorm(20)
> y4<-rnorm(20)
> df2<-data.frame(y1,y2,y4)
> df2
       y1           y2         y4
1   1.21750225  -1.33082010  0.7365231
2   0.24052365  -1.19657893 -0.7325931
3   0.82363925  -0.03890292 -0.3103461
4  -0.28315390  -0.20730053 -1.0066420
5  -0.56196875  -0.41592524  0.4996899
6   0.90983596   0.66105140 -0.9552844
7   1.14413650   1.20610045  0.9542341
8   0.03566065   1.31518070  0.2722798
9   1.72309925   0.55267260  0.3036829
10  1.27783338  -0.61818175 -0.2573076
11  0.22074289   1.23057901  0.5180043
12  1.60663571  -1.00737269  1.1614623
13 -0.75813279  -0.36594209  0.3923075
14 -0.31492265   1.30409915 -0.2759040
15 -1.03101619   0.15687986  0.8609099
16 -0.37968676  -0.04247421 -0.7490176
17 -1.90078740  -0.61468534  1.0015994
18 -0.76753148   0.21451207 -0.1875631
19 -0.36281597  -0.94474847 -1.1014309
20 -1.90049600  -0.20750306  2.1602226
adding a new column y3 after y2 in df2 −
> df2%>%mutate(y3=rnorm(20,10,0.5),.after=y2)
      y1           y2          y3         y4
1   1.21750225  -1.33082010  8.801898   0.7365231
2   0.24052365  -1.19657893  9.592606  -0.7325931
3   0.82363925  -0.03890292  10.088155 -0.3103461
4  -0.28315390  -0.20730053  9.297835  -1.0066420
5  -0.56196875  -0.41592524  9.463427   0.4996899
6   0.90983596   0.66105140  9.494079  -0.9552844
7   1.14413650   1.20610045  9.689292   0.9542341
8   0.03566065   1.31518070  10.664904  0.2722798
9   1.72309925   0.55267260  10.778179  0.3036829
10  1.27783338  -0.61818175  9.872532  -0.2573076
11  0.22074289   1.23057901  9.301869   0.5180043
12  1.60663571  -1.00737269  10.176794  1.1614623
13 -0.75813279  -0.36594209  9.367227   0.3923075
14 -0.31492265   1.30409915  11.086966 -0.2759040
15 -1.03101619   0.15687986  9.082294   0.8609099
16 -0.37968676  -0.04247421  9.547622  -0.7490176
17 -1.90078740  -0.61468534  9.694575   1.0015994
18 -0.76753148   0.21451207  10.583576 -0.1875631
19 -0.36281597  -0.94474847  10.075352 -1.1014309
20 -1.90049600  -0.20750306  10.106721 2.1602226
How to echo XML file in PHP

HTTP URLs can be used to behave like local files, with the help of PHP wrappers. The contents from a URL can be fetched through the file_get_contents() and it can be echoed. or read using the readfile function.
Below is a sample code to do the same −
$file = file_get_contents('http://example.com/');
echo $file;
An alternative is demonstrated below −
readfile('http://example.com/');
header('Content-type: text/xml'); //The correct MIME type has to be set before displaying the output.
The asXML method also can be used. Below is a sample code −
echo $xml->asXML();
or
$xml->asXML('filename.xml'); //providing a name for the xml file.
Where are static variables stored in C/C++?

Static variables are variables that remain in memory while the program is running i.e. their lifetime is the entire program run. This is different than automatic variables as they remain in memory only when their function is running and are destroyed when the function is over.
The static variables are stored in the data segment of the memory. The data segment is a part of the virtual address space of a program.
All the static variables that do not have an explicit initialization or are initialized to zero are stored in the uninitialized data segment( also known as the BSS segment). Compared to this, the static variables that are initialized are stored in the initialized data segment.
An example of this is given as follows −
static int x = 5;
static int y;

The static variable x is stored in the initialized data segment and the static variable y is stored in the BSS segment.
A program that demonstrates static variables in C is given as follows −
 Live Demo
#include<stdio.h>
int func(){
   static int i = 4 ;
   i++;
   return i;
}

int main(){
   printf("%d\n", func());
   printf("%d\n", func());
   printf("%d\n", func());
   printf("%d\n", func());
   printf("%d\n", func());
   printf("%d\n", func());

   return 0;
}
The output of the above program is as follows −
5
6
7
8
9
10
Now let us understand the above program.
In the function func(), i is a static variable that is initialized to 4. So it is stored in the initialized data segment. Then i is incremented and its value is returned. The code snippet that shows this is as follows −
int func(){
   static int i = 4 ;
   i++;
   return i;
}
In the function main(), the function func() is called 6 times and it returns the value of i which is printed. Since i is a static variable, it remains in the memory while the program is running and it provides consistent values. The code snippet that shows this is as follows −
printf("%d\n", func());
printf("%d\n", func());
printf("%d\n", func());
printf("%d\n", func());
printf("%d\n", func());
printf("%d\n", func());
MySQL | CONNECTION_ID( ) Function - GeeksforGeeks

25 Nov, 2019
The MySQL CONNECTION_ID() function is used for return the connection ID for a current connection in MySQL. The connection ID used to establish a connection to a database is unique for every connection among the connected clients. The CONNECTION_ID() function does not require any parameters or arguments.
The value returned by the CONNECTION_ID() function is the same type of value as displayed in the ID column of the INFORMATION_SCHEMA.PROCESSLIST table.
Syntax:
CONNECTION_ID()
Parameters Used:The CONNECTION_ID() function does not require any parameters or arguments.
Return Value:The MySQL CONNECTION_ID() function returns an integer value which represents the unique current connection ID.
Supported Versions of MySQL:
MySQL 5.7
MySQL 5.6
MySQL 5.5
MySQL 5.1
MySQL 5.0
MySQL 4.1
MySQL 4.0
MySQL 3.23
Example: Implementing CONNECTION_ID() function.
SELECT CONNECTION_ID(); 
Output:
1196078 
mysql
SQLmysql
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Update Multiple Columns in Single Update Statement in SQL?
How to Alter Multiple Columns at Once in SQL Server?
What is Temporary Table in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL using Python
SQL | Subquery
SQL Query to Convert VARCHAR to INT
SQL | Date functions
SQL - SELECT from Multiple Tables with MS SQL Server
SQL Query to Insert Multiple Rows
What is the difference between Math.ceil() and Math.round() methods in JavaScript?

Math.ceil() and Math.round() methods differ in a way that the former round off a number to its nearest integer in upward direction of rounding(towards the greater value) whereas the latter round off a number to its nearest integer in downward direction of rounding(towards lower value). Let's examine the two methods individually.
Math.ceil() method round off number passed as parameter to its nearest integer so as to get greater value.
In the below example when a number 5.34 passed as a parameter, Math.ceil() round off it in to 6, which is a greater value than actual number.
Live Demo
<html>
<body>
<script>
   document.write(Math.ceil(5.34));
</script>
</body>
</html>
6
Math.round() method round off number passed as parameter to its nearest integer so as to get lower value.
In the below example when a number 5.34 passed as a parameter, Math.round() round off it in to 5, which is a lower value than actual number.
Live Demo
<html>
<body>
<script>
   document.write(Math.round(5.34));
</script>
</body>
</html>
5
How to turn an Image into a Link in HTML ? - GeeksforGeeks

16 Dec, 2021
In this article, we will see how to turn an HTML image into a webpage link in HTML. The HTML <a> type attribute is used to create a hyperlink to web pages, files, locations on the same page. We can make elements like images into links by nesting them within an <a> element. It defines a hyperlink that is used to link from one page to another. If the <a> tag has no href attribute, then it will be only a placeholder for a hyperlink.
Syntax:
<a href=""></a>
Note: The href attribute is used to specify the destination address of the link.
Example: This example describes adding the link to the image to redirect to a specific page.
HTML
<!DOCTYPE html><html> <body style="text-align: center;">    <h3>        Click on GeeksforGeeks logo to        Redirect into geeksforgeeks.org    </h3>    <a href="https://geeksforgeeks.org">        <img src="https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png"             alt="Click to visit geeksforgeeks.org">    </a></body> </html>
Output:
Making the image as a link in HTML
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
shubhamyadav4
bhaskargeeksforgeeks
CSS-Misc
HTML-Misc
CSS
HTML
Technical Scripter
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a web page using HTML and CSS
Form validation using jQuery
How to set space between the flexbox ?
Search Bar using HTML, CSS and JavaScript
How to Create Time-Table schedule using HTML ?
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
Hide or show elements in HTML using display property
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
Find an array element such that all elements are divisible by it using c++

Consider we have an array A with few elements. We have to find an element from A, such that all elements can be divided by it. Suppose the A is like [15, 21, 69, 33, 3, 72, 81], then the element will be 3, as all numbers can be divisible by 3.
To solve this problem, we will take the smallest number in A, then check whether all numbers can be divided by the smallest number or not, if yes, then return the number, otherwise, return false.
 Live Demo
#include<iostream>
#include<algorithm>
using namespace std;
int getNumber(int a[], int n) {
   int minNumber = *min_element(a, a+n);
   for (int i = 1; i < n; i++)
      if (a[i] % minNumber)
      return -1;
   return minNumber;
}
int main() {
   int a[] = { 15, 21, 69, 33, 3, 72, 81 };
   int n = sizeof(a) / sizeof(int);
   cout << "The number is: "<< getNumber(a, n);
}
The number is: 3
Java Program to set title position in Java

To set title position, use the setTitlePosition() method in Java. Let’s say we have to position the title above the border's top line. For that, use the constant ABOVE_TOP for the border −
setTitlePosition(TitledBorder.ABOVE_TOP);
The following is an example to set title position −
package my;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
public class SwingDemo {
   public static void main(String args[]) {
      JFrame frame = new JFrame("Demo");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      LineBorder lineBorder = new LineBorder(Color.orange);
      TitledBorder titledBorder = BorderFactory.createTitledBorder(lineBorder, "Demo Title");
      titledBorder.setTitlePosition(TitledBorder.ABOVE_TOP);
      JLabel label = new JLabel();
      label.setBorder(titledBorder);
      Container contentPane = frame.getContentPane();
      contentPane.add(label, BorderLayout.CENTER);
      frame.setSize(550, 300);
      frame.setVisible(true);
   }
}
How to filter rows by excluding a particular value in columns of the R data frame?

To filter rows by excluding a particular value in columns of the data frame, we can use filter_all function of dplyr package along with all_vars argument that will select all the rows except the one that includes the passed value with negation. For example, if we have a data frame called df and we want to filter rows by excluding value 2 then we can use the command
df%>%filter_all(all_vars(.!=2))
Consider the below data frame −
 Live Demo
x1<-rpois(20,5)
x2<-rpois(20,5)
df1<-data.frame(x1,x2)
df1
   x1 x2
1  6  5
2  3  5
3  1  4
4  8  7
5  4  5
6  2  4
7  5  1
8  2  7
9  3  5
10 5  9
11 4 10
12 6  4
13 9  1
14 3  4
15 5  5
16 6  3
17 4  7
18 4  2
19 3  7
20 8  4
Loading dplyr package and filtering rows of df1 by excluding 4 in all the columns −
library(dplyr)
df1%>%filter_all(all_vars(.!=4))
   x1 x2
1  6  5
2  3  5
3  8  7
4  5  1
5  2  7
6  3  5
7  5  9
8  9  1
9  5  5
10 6  3
11 3  7
 Live Demo
y1<-rpois(20,2)
y2<-rpois(20,2)
df2<-data.frame(y1,y2)
df2
   y1  y2
1  1   2
2  0   2
3  0   3
4  2   3
5  1   1
6  1   3
7  6   2
8  2   3
9  2   2
10 3   2
11 3   0
12 0   5
13 0   0
14 5   5
15 1   1
16 3   3
17 3   1
18 1   1
19 2   2
20 3   0
Filtering rows of df2 by excluding 2 in all the columns −
df2%>%filter_all(all_vars(.!=2))
   y1 y2
1  0  3
2  1  1
3  1  3
4  3  0
5  0  5
6  0  0
7  5  5
8  1  1
9  3  3
10 3  1
11 1  1
12 3  0