code-rag-bench/online-tutorials huggingface dataset:
Groovy - next()

This method is called by the ++ operator for the class String. It increments the last character in the given String.
String next()

None
The new value of the string
Following is an example of the usage of this method −
class Example { 
   static void main(String[] args) { 
      String a = "Hello World"; 
      println(a.next());         
   } 
}
When we run the above program, we will get the following result −
Hello World


    52 Lectures 
     8 hours 

 Krishna Sakinala

    49 Lectures 
     2.5 hours 

 Packt Publishing
 Print
 Add Notes
 Bookmark this page
Python Program for Min Cost Path

In this article, we will learn about the solution to the problem statement given below.
Problem statement − We are given a cost matrix and a position (m, n), we need to find the cost of minimum cost path to reach (m, n) from (0, 0). Each cell represents a cost to traverse from one cell to another.
Now let’s observe the solution in the implementation below −
 Live Demo
# dynamic approach
R = 3
C = 3
def minCost(cost, m, n):
   # initialization
   tc = [[0 for x in range(C)] for x in range(R)]
   # base case
   tc[0][0] = cost[0][0]
   # total cost(tc) array
   for i in range(1, m + 1):
      tc[i][0] = tc[i-1][0] + cost[i][0]
   # tc array
   for j in range(1, n + 1):
      tc[0][j] = tc[0][j-1] + cost[0][j]
   # rest tc array
   for i in range(1, m + 1):
      for j in range(1, n + 1):
         tc[i][j] = min(tc[i-1][j-1], tc[i-1][j], tc[i][j-1]) + cost[i][j]
   return tc[m][n]
# main
cost = [[1, 5, 3],
        [7, 7, 4],
        [8, 5, 3]]
print("Total Cost:",minCost(cost, 2, 1))
Total Cost: 13
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 Min Cost Path
How to change button label in alert box using JavaScript?

With the standard alert box, you cannot change the button label. To change the label, use the custom alert box. Here, the “Ok” of an alert box is changed to “Thank you for informing!” for an example:
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
      </script>
      <script>
         function functionAlert(msg, myYes) {
            var confirmBox = $("#confirm");
            confirmBox.find(".message").text(msg);
            confirmBox.find(".yes").unbind().click(function() {
               confirmBox.hide();
            });
            confirmBox.find(".yes").click(myYes);
            confirmBox.show();
         }
      </script>
      <style>
         #confirm {
            display: none;
            background-color: #91FF00;
            border: 1px solid #aaa;
            position: fixed;
            width: 250px;
            left: 50%;
            margin-left: -100px;
            padding: 6px 8px 8px;
            box-sizing: border-box;
            text-align: center;
         }
         #confirm button {
            background-color: #48E5DA;
            display: inline-block;
            border-radius: 5px;
            border: 1px solid #aaa;
            padding: 5px;
            text-align: center;
            width: 100px;
            cursor: pointer;
         }
         #confirm .message {
            text-align: left;
         }
      </style>
   </head>
   <body>
      <div id="confirm">
         <div class = "message">This is a warning message.</div>
         <button class="yes">Thank you for informing!</button>
      </div>
      <input type="button" value="Click Me" onclick="functionAlert();" />
   </body>
</html>
HTML | canvas putImageData() Method - GeeksforGeeks

16 Oct, 2019
The putImageData() method is used to put the image data back to the canvas from a specified ImageData object.
Syntax:
context.putImageData(imgData, x, y, dirtyX, dirtyY, dirtyWidth, dirtyHeight);
Parameter Values:
imgData: It is used to specify the ImageData object to put back to the canvas.
x: It is the x-coordinate of the upper-left corner of the ImageData object. It is in pixels.
y: It is the y-coordinate of the upper-left corner of the ImageData object. It is in pixels.
dirtyX: It is the horizontal(x) value that denotes where to place the image on the canvas. It is in pixels and optional.
dirtyY: It is the vertical(y) value that denotes where to place the image on the canvas. It is in pixels and optional.
dirtyWidth: It is the width used to draw the image on the canvas. It is also optional.
dirtyHeight: It is the height used to draw the image on the canvas. It is also optional.
Example:
<!DOCTYPE html><html>  <body>    <center>        <h1 style="color:green;">GeeksforGeeks</h1>        <h2 style="color:green;">PutImageData() Method</h2>        <canvas id="gfgCanvas"                 width="300"                 height="300"                 style="border:1px solid ;">        </canvas>          <script>            var gfg = document.getElementById("gfgCanvas");            var context = gfg.getContext("2d");            context.fillStyle = "green";            context.fillRect(55, 50, 200, 100);              function putImage() {                // getImageData is used to copy the pixels                var imageData = context.getImageData(55, 50, 200, 100);                context.putImageData(imageData, 55, 170);            }        </script>        <br>        <button onclick="putImage()">PutImageData</button>    </center></body>  </html>
Output:Before click:
After click:
Supported Browsers: The browsers supported by HTML canvas putImageData() Method are listed below:
Chrome
Mozilla Firefox
Internet Explorer 9.0
Opera
Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Property
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
Form validation using HTML and JavaScript
Types of CSS (Cascading Style Sheet)
How to update Node.js and NPM to next version ?
Installation of Node.js on Linux
Express.js express.Router() Function
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Reversed Range-based for loop in C++ with Examples - GeeksforGeeks

08 Jul, 2020
Range-based for loops is an upgraded version of for loops. It is quite similar to for loops which is use in Python. Range-based for loop in C++ is added since C++ 11.
We can reverse the process of iterating the loop by using boost::adaptors::reverse() function which is included in boost library Header.
Header File:
#include <boost/range/adaptor/reversed.hpp> 

Syntax:
for (auto i : boost::adaptors::reverse(x))

Parameters:
range_declaration: a declaration used to iterate over the elements in a container. Often uses the auto specifier for automatic type deduction.
range_expression: An expression that represents a suitable sequence or a braced-init-list.
loop_statement: An statement, typically a compound statement, which is the body of the loop.
Below is the program to illustrate reverse range based loop in C++:
CPP14
// C++ program for reverse// range-based for loop#include <bits/stdc++.h>  // For reversing range based loop#include <boost/range/adaptor/reversed.hpp>using namespace std;  // Driver Codeint main(){    string s = "geeksforgeeks";      int y[] = { 1, 2, 3, 4, 5, 6, 7, 8 };      vector<int> v1{ 1, 2, 3, 4, 5, 6, 7, 8 };      // Reverse range-based for loop    // to reverse string    for (auto x : boost::adaptors::reverse(s))        cout << x << " ";    cout << endl;      // Reverse range-based for loop    // to reverse array    for (auto x : boost::adaptors::reverse(y))        cout << x << " ";    cout << endl;      // Reverse range-based for loop    // to reverse vector    for (auto x : boost::adaptors::reverse(v1))        cout << x << " ";    cout << endl;      return 0;}
s k e e g r o f s k e e g 
8 7 6 5 4 3 2 1 
8 7 6 5 4 3 2 1

loop
C++
C++ Programs
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Sorting a vector in C++
Friend class and function in C++
Pair in C++ Standard Template Library (STL)
Header files in C/C++ and its uses
Program to print ASCII Value of a character
C++ Program for QuickSort
How to return multiple values from a function in C or C++?
Sorting a Map by value in C++ STL
Lodash _.partial() Method - GeeksforGeeks

13 Sep, 2020
Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.
The _.partial() method is used to create a function which invokes the given func function with prepended partials to the arguments it receives.
Syntax:
_.partial( func, partials )

Parameters: This method accepts two parameters as mentioned above and described below:
func: This parameter holds the function to partially apply the arguments to.
partials: This parameter holds the arguments to be applied. It is an optional parameter.
Return Value: This method returns the new partially applied function.
Example 1:
Javascript
// Requiring the lodash library  const _ = require("lodash");    // Given Functionfunction info(information, name) {  console.log(information + ' ' + name);}  // Using the _.partial() method  var call_gfg =  _.partial(info, 'GeeksforGeeks');call_gfg('is a computer science portal for geeks');
Output:
'GeeksforGeeks is a computer science portal for geeks'
Example 2:  
Javascript
// Requiring the lodash library  const _ = require("lodash");    // Given Functionfunction info(information, name) {  console.log(information + ' ' + name);}  // Using the _.partial() method  var say_gfg = _.partial(info, _, 'geeks');say_gfg('Hello');
Output:
'Hello geeks'
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
numpy.put() in Python - GeeksforGeeks

09 Mar, 2022
The numpy.put() function replaces specific elements of an array with given values of p_array. Array indexed works on flattened array.  
Syntax: numpy.put(array, indices, p_array, mode = 'raise')
Parameters : 
array   : array_like, target array
indices : index of the values to be fetched
p_array : array_like, values to be placed in target array
mode    : [{‘raise’, ‘wrap’, ‘clip’}, optional] mentions how out-of-bound indices will behave
                  raise : [default]raise an error 
                  wrap  : wrap around
                  clip  : clip to the range
 
Python
# Python Program explaining# numpy.put() import numpy as geek a = geek.arange(5)geek.put(a, [0, 2], [-44, -55])print("After put : \n", a)
Output : 
After put : 
[-44,   1, -55,   3,   4]
 
Python
# Python Program explaining# numpy.put() import numpy as geek a = geek.arange(5)geek.put(a, 22, -5, mode='clip')print("After put : \n", a)
Output : 
array([ 0,  1,  2,  3, -5])
Code Source : https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.put.html#numpy.putNote : These codes won’t run on online IDE’s. So please, run them on your systems to explore the working.
This article is contributed by Mohit Gupta_OMG . If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
vinayedula
Python numpy-Indexing
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Queue Data Structure - GeeksQuiz

28 Nov, 2021
Suppose we start filling the queue.

Let the maxQueueSize ( Capacity of the Queue) is 4.
So the size of the array which is used to implement 
this circular queue is 5, which is n.

In the beginning when the queue is empty, FRONT and REAR 
point to 0 index in the array.

REAR represents insertion at the REAR index.
FRONT represents deletion from the FRONT index.

enqueue("a"); REAR = (REAR+1)%5; ( FRONT = 0, REAR = 1)
enqueue("b"); REAR = (REAR+1)%5; ( FRONT = 0, REAR = 2)
enqueue("c"); REAR = (REAR+1)%5; ( FRONT = 0, REAR = 3)
enqueue("d"); REAR = (REAR+1)%5; ( FRONT = 0, REAR = 4)

Now the queue size is 4 which is equal to the maxQueueSize. 
Hence overflow condition is reached.

Now, we can check for the conditions.

When Queue Full :

( REAR+1)%n = (4+1)%5 = 0

FRONT is also 0.

Hence ( REAR + 1 ) %n is equal to FRONT.

When Queue Empty :

REAR was equal to FRONT when empty ( because in the starting 
before filling the queue FRONT = REAR = 0 )

Hence Option A is correct. 
MultiDequeue(Q){
   m = k
   while (Q is not empty and m  > 0) {
      Dequeue(Q)
      m = m - 1
   }
}
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Best Time to Buy and Sell Stock
Must Do Coding Questions for Product Based Companies
How to Replace Values in Column Based on Condition in Pandas?
C Program to read contents of Whole File
Insert Image in a Jupyter Notebook
How to Replace Values in a List in Python?
How to Read Text Files with Pandas?
How to Compare Two Columns in Pandas?
Python Data Structures and Algorithms
Data Science With Python Tutorial
How to remove border from an editable element using CSS ? - GeeksforGeeks

14 Dec, 2020
Given an HTML document containing some document and the task is to remove border from an editable element using CSS. It is a default behavior of any element which have content-editable attributes set to true whenever, the element gets a focus it will get a border around them. The task can be done by using the [attribute] selector to select all elements that are contenteditable, and remove the border with the outline property.  
Example:   
HTML
<!DOCTYPE html><html>  <head>    <style>        [contenteditable] {            outline: 0px solid transparent;        }    </style></head>  <body>    <center>        <h2>GeeksForGeeks</h2>          <h2>            How to remove the border from             an editable element with CSS?        </h2>          <p contenteditable="true">            This paragraph is editable        </p>      </center></body>  </html>
Output:
Before Editing on Element:
After Editing on Element: 
  
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
CSS
HTML
Web Technologies
Web technologies Questions
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 ?
Python | Pandas Series.dt.normalize - GeeksforGeeks

20 Mar, 2019
Series.dt can be used to access the values of the series as datetimelike and return several properties. Pandas Series.dt.normalize() function convert times to midnight. The time component of the date-time is converted to midnight i.e. 00:00:00. This is useful in cases, when the time does not matter. Length is unaltered. The timezones are unaffected.
Syntax: Series.dt.normalize(*args, **kwargs)
Parameter : None
Returns : DatetimeArray, DatetimeIndex or Series
Example #1: Use Series.dt.normalize() function to convert the times in the given series object to midnight.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series(pd.date_range('2012-12-31 09:45', periods = 5, freq = 'M',                            tz = 'Europe / Berlin'))  # Creating the indexidx = ['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 5']  # set the indexsr.index = idx  # Print the seriesprint(sr)
Output :
Now we will use Series.dt.normalize() function to convert the times to midnight.
# convert to midnightresult = sr.dt.normalize()  # print the resultprint(result)
Output :
As we can see in the output, the Series.dt.normalize() function has successfully converted the times in the given series object to midnight.
Example #1: Use Series.dt.normalize() function to convert the times in the given series object to midnight.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series(pd.date_range('2019-1-1 12:30', periods = 5, freq = 'H',                             tz = 'Asia / Calcutta'))  # Creating the indexidx = ['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 5']  # set the indexsr.index = idx  # Print the seriesprint(sr)
Output :
Now we will use Series.dt.normalize() function to convert the times to midnight.
# convert to midnightresult = sr.dt.normalize()  # print the resultprint(result)
Output :
As we can see in the output, the Series.dt.normalize() function has successfully converted the times in the given series object to midnight.
Python pandas-series-datetime
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Create a Pandas DataFrame from Lists
Python program to convert a list to string
Reading and Writing to text files in Python
sum() function in Python
*args and **kwargs in Python
Java Examples - Commit a statement

How to commit a query?
Following example uses connection.commit() method to execute a query.
import java.sql.*;

public class jdbcConn {
   public static void main(String[] args) throws Exception {
      Class.forName("org.apache.derby.jdbc.ClientDriver");
      Connection con = DriverManager.getConnection (
         "jdbc:derby://localhost:1527/testDb","name","pass");
      
      Statement stmt = con.createStatement();
      String query = "insert into emp values(2,'name1','job')";
      String query1 ="insert into emp values(5,'name2','job')";
      String query2 = "select * from emp";
      
      ResultSet rs = stmt.executeQuery(query2);
      int no_of_rows = 0;
      
      while (rs.next()) {
         no_of_rows++;
      }
      System.out.println("No. of rows before commit statement = "+ no_of_rows);
      con.setAutoCommit(false);
      stmt.execute(query1);
      stmt.execute(query);
      con.commit();
      rs = stmt.executeQuery(query2);
      no_of_rows = 0;
      
      while (rs.next()) {
         no_of_rows++;
      }
      System.out.println("No. of rows after commit statement = "+ no_of_rows);
      con.close();
   }
}      
The above code sample will produce the following result. The result may vary.
No. of rows before commit statement = 1
No. of rows after commit statement = 3 

 Print
 Add Notes
 Bookmark this page
C# Online Compiler (Editor / Interpreter)

With our online C# compiler, you can edit C# code, and view the result in your browser.
using System;

namespace HelloWorld
{
  class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine("Hello World!");    
    }
  }
}
Click on the "Try it Yourself" button to see how it works.
The window to the left is editable - edit the code and click on the "Run" button to view the result in the right window.
The icons are explained in the table below:
If you don't know C#, we suggest that you read our C# Tutorial from scratch.
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
C# Program to get the last write time of a file

To get the last write time of a file in C#, use the LastWriteTime() method.
For this, use the FileInfo as well as DateTime classes.
Create an object of each −
FileInfo file = new FileInfo("amit.txt");
DateTime dt = file.CreationTime;
dt = file.LastWriteTime;
Let us see the complete code −
 Live Demo
using System.IO;
using System;
public class Program {
   public static void Main() {
      using (StreamWriter sw = new StreamWriter("amit.txt")) {
         sw.WriteLine("Welcome!");
      }
      FileInfo file = new FileInfo("amit.txt");
      // file creation time
      DateTime dt = file.CreationTime;
      Console.WriteLine(dt);
      // last access time
      dt = file.LastAccessTime;
      Console.WriteLine(dt);
      // last write time
      dt = file.LastWriteTime;
      Console.WriteLine(dt);
   }
}
9/5/2018 5:17:27 AM
9/5/2018 5:17:27 AM
9/5/2018 5:17:27 AM
C Program to read and write character string and sentence

Suppose you want to take a character, then a string and a sentence (string with spaces) using C. So we shall provide three inputs and print the same as output. The maximum size of the string is 500 here.
So, if the input is like
character = 'T'
string = "ProgrammingLanguage"
sentence = "I love programming through C",
then the output will be
Your character: T
Your string: ProgrammingLanguage
Your sentence: I love programming through C
To solve this, we will follow these steps −
For character we need to use scanf("%c", &character);
For character we need to use scanf("%c", &character);
For string we need to use scanf("%s", string);
For string we need to use scanf("%s", string);
This step is optional, but required in some cases. Sometimes you may face one problem. Your program sometimes does not wait for next input, so we need to clear the buffer using fflush(stdin)
This step is optional, but required in some cases. Sometimes you may face one problem. Your program sometimes does not wait for next input, so we need to clear the buffer using fflush(stdin)
And for string with spaces we need to use fgets() function. Here the first parameter is string, second is the size and last one is stdin to take input from console.
And for string with spaces we need to use fgets() function. Here the first parameter is string, second is the size and last one is stdin to take input from console.
The last one indicates we need one new line character to denote end of string. Otherwise it will take spaces as well.
The last one indicates we need one new line character to denote end of string. Otherwise it will take spaces as well.
Let us see the following implementation to get better understanding −
#include <stdio.h>
int main(){
    char character;
    char string[500];
    char sentence[500];
    scanf("%c", &character);
    scanf("%s", string);
    fflush(stdin);
    fgets(sentence, 500, stdin);
    printf("Your character: %c\n", character);
    printf("Your string: %s\n", string);
    printf("Your sentence: %s\n", sentence);
}

T
ProgrammingLanguage
I love programming through C
Your character: T
Your string: ProgrammingLanguage
Your sentence: I love programming through C
How can we update columns values on multiple rows with a single MySQL UPDATE statement?

Column values on multiple rows can be updated in a single UPDATE statement if the condition specified in WHERE clause matches multiple rows. In this case, the SET clause will be applied to all the matched rows.
Suppose we have a table ‘tender’ as follows −
mysql> Select * from tender;

+-----------+---------+------+
| tender_id | company | rate |
+-----------+---------+------+
| 200       | ABC     | 1000 |
| 300       | ABD     | 5000 |
| 301       | ABE     | 6000 |
| 302       | ABF     | 2500 |
| 303       | ABG     | 2600 |
+-----------+---------+------+

5 rows in set (0.00 sec)
Now if we want to update the ‘rate’ column where tender_id is greater than or equal to 300 then we can use the following query −
mysql> UPDATE tender SET rate = rate + 1000 WHERE tender_id >= 300;
Query OK, 4 rows affected (0.07 sec)
Rows matched: 4 Changed: 4 Warnings: 0

mysql> Select * from tender;

+-----------+---------+------+
| tender_id | company | rate |
+-----------+---------+------+
| 200       | ABC     | 1000 |
| 300       | ABD     | 6000 |
| 301       | ABE     | 7000 |
| 302       | ABF     | 3500 |
| 303       | ABG     | 3600 |
+-----------+---------+------+

5 rows in set (0.00 sec)
We can observe from the above result set that the values in multiple rows, having tender_id >= 300, has been updated.
Python Convert Html to PDF - GeeksforGeeks

30 Dec, 2017
There are many websites that do not allow to download the content in form of pdf, they either ask to buy their premium version or don’t have such download service in form of pdf.
Step1: Download library pdfkit
 $ pip install pdfkit
Step2: Download wkhtmltopdfFor Ubuntu/Debian:
 sudo apt-get install wkhtmltopdf
For Windows:(a)Download link: WKHTMLTOPDF(b)Set: PATH variable set binary folder in Environment variables.
Step3: Code in Python to Download:(i) Already Saved HTML page
import pdfkitpdfkit.from_file('test.html', 'out.pdf')
(ii) Convert by website URL
import pdfkitpdfkit.from_url('https://www.google.co.in/','shaurya.pdf')
(iii) Store text in PDF
import pdfkitpdfkit.from_string('Shaurya GFG','GfG.pdf')
Congratulations: Your pdf file would be created and saved in the same directory where python file exists.
Miscellaneous Knowledge Content:1. You can pass a list with multiple URLs or files:
pdfkit.from_url(['google.com', 'geeksforgeeks.org', 'facebook.com'], 'shaurya.pdf')pdfkit.from_file(['file1.html', 'file2.html'], 'out.pdf')
2. Save content in a variable
# Use False instead of output path to save pdf to a variablepdf = pdfkit.from_url('http://google.com', False)
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python program to convert a list to string
Python String | replace()
Reading and Writing to text files in Python
sum() function in Python
deque::push_front() in C++ STL - GeeksforGeeks

22 Jan, 2018
Deque or Double ended queues are sequence containers with the feature of expansion and contraction on both the ends. They are similar to vectors, but are more efficient in case of insertion and deletion of elements at the end, and also the beginning. Unlike vectors, contiguous storage allocation may not be guaranteed.
push_front() function is used to push elements into a deque from the front. The new value is inserted into the deque at the beginning, before the current first element and the container size is increased by 1.
Syntax :
dequename.push_front(value)
Parameters :
The value to be added in the front is 
passed as the parameter
Result :
Adds the value mentioned as the parameter 
to the front of the deque named as dequename

Examples:
Input : deque{1, 2, 3, 4, 5};
        deque.push_front(6);
Output : 6, 1, 2, 3, 4, 5

Input : deque{5, 4, 3, 2, 1};
        deque.push_front(6);
Output :6, 5, 4, 3, 2, 1

Errors and Exceptions
1. Strong exception guarantee – if an exception is thrown, there are no changes in the container.2. If the value passed as argument is not supported by the deque, it shows undefined behaviour.
// CPP program to illustrate// push_front() function#include <deque>#include <iostream>using namespace std;  int main(){    deque<int> mydeque{ 1, 2, 3, 4, 5 };    mydeque.push_front(6);      // deque becomes 6, 1, 2, 3, 4, 5      for (auto it = mydeque.begin();         it != mydeque.end(); ++it)        cout << ' ' << *it;}
Output:
6 1 2 3 4 5
Time Complexity : O(1)
ApplicationGiven an empty deque, add integers to it using push_front() function and then calculate its size.
Input  : 1, 2, 3, 4, 5, 6
Output : 6
Algorithm1. Add elements to the deque using push_front() function2. Check if the size of the deque is 0, if not, increment the counter variable initialised as 0, and pop the front element.3. Repeat this step until the size of the deque becomes 0.4. Print the final value of the variable.
// CPP program to illustrate// Application of push_front() function#include <deque>#include <iostream>using namespace std;  int main(){    int count = 0;    deque<int> mydeque;    mydeque.push_front(1);    mydeque.push_front(2);    mydeque.push_front(3);    mydeque.push_front(4);    mydeque.push_front(5);    mydeque.push_front(6);    while (!mydeque.empty()) {        count++;        mydeque.pop_front();    }    cout << count;    return 0;}
Output:
6
cpp-deque
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Map in C++ Standard Template Library (STL)
Inheritance in C++
C++ Classes and Objects
Constructors in C++
Bitwise Operators in C/C++
Socket Programming in C/C++
Operator Overloading in C++
Copy Constructor in C++
Virtual Function in C++
vector erase() and clear() in C++
Print screen using VBA in SAP

If you are using SendKeys then avoid using it. I had used it in the past project and it seems to be inconsistent and error-prone.
You can use the below snippet at the top of the module and call it wherever required.
Option Explicit
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _bScan As Byte,
 ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_SNAPSHOT = &H2C
Private Const VK_MENU = &H12
Sub PrintScreen()
    keybd_event VK_SNAPSHOT, 1, 0, 0
 End Sub
C++ Ostream Library - seekp

It is used to set position in output sequence.
Following is the declaration for std::ostream::seekp.
(1)	ostream& seekp (streampos pos);
(2)	ostream& seekp (streamoff off, ios_base::seekdir way);
pos − It is used to find absolute position within the stream.
pos − It is used to find absolute position within the stream.
off − Offset value, relative to the way parameter.
off − Offset value, relative to the way parameter.
It returns the ostream object (*this).
Basic guarantee − if an exception is thrown, the object is in a valid state.
Modifies the stream object and concurrent access to the same stream object may cause data races.
In below example explains about std::ostream::seekp.
#include <fstream>

int main () {

   std::ofstream outfile;
   outfile.open ("tutorialspoint.txt");

   outfile.write ("This is an apple",16);
   long pos = outfile.tellp();
   outfile.seekp (pos-7);
   outfile.write (" sai",4);

   outfile.close();

   return 0;
}
 Print
 Add Notes
 Bookmark this page
HTML canvas fillRect() Method

The fillRect() method of the HTML canvas is used to create a filled rectangle on the web page. The default color is black. The <canvas> element allows you to draw graphics on a web page using JavaScript. Every canvas has two elements that describes the height and width of the canvas i.e. height and width respectively.
Following is the syntax −
context.fillRect(p,q,width,height);
Above,
p: The x-coordinate of the upper-left corner of the rectangle
q: The y-coordinate of the upper-left corner of the rectangle
width: Width of the rectangle
height: Height of the rectangle
Let us now see an example to implement the fillRect() method of canvas−
 Live Demo
<!DOCTYPE html>
<html>
<body>
<canvas id="newCanvas" width="500" height="350" style="border:2px solid orange;">
</canvas>
<script>
   var c = document.getElementById("newCanvas");
   var ctx = c.getContext("2d");
   ctx.fillStyle = "blue";
   ctx.fillRect(0, 0, 500, 350);
   ctx.clearRect(250, 100, 50, 100);
</script>
</body>
</html>
Compare two strings lexicographically in C#

To compare strings in C#, use the compare() method. It compares two strings and returns the following integer values −
If str1 is less than str2, it returns -1.

If str1 is equal to str2, it returns 0.

If str1 is greater than str2, it returns 1.
Set the two strings in the String.compare() method and compare them −
string.Compare(string1, string2);
You can try to run the following code to compare two strings in C#.
Live Demo
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Demo {
   class MyApplication {
      static void Main(string[] args) {
         string string1 = null;
         string string2 = null;
         string1 = "amit";
         string2 = "Amit";
         int myOutput = 0;
         myOutput = string.Compare(string1, string2);
         Console.WriteLine(myOutput.ToString());
         Console.ReadLine();
      }
   }
}
-1
Template Specialization in C++

In C++, the templates are used to create generalized functions and classes. So we can use any type of data like int, char, float, or some user defined data also using templates.
In this section, we will see how to use the template specialization. So now we can define some generalized template for different types of data. And some special template function for special type of data. Let us see some example to get better idea.
#include<iostream>
using namespace std;
template<typename T>
void my_function(T x) {
   cout << "This is generalized template: The given value is: " << x << endl;
}
template<>
void my_function(char x) {
   cout << "This is specialized template (Only for characters): The given value is: " << x << endl;
}
main() {
   my_function(10);
   my_function(25.36);
   my_function('F');
   my_function("Hello");
}
This is generalized template: The given value is: 10
This is generalized template: The given value is: 25.36
This is specialized template (Only for characters): The given value is: F
This is generalized template: The given value is: Hello
The template specialization can also be created for classes. Let us see one example by creating generalized class, and specialized class.
#include<iostream>
using namespace std;
template<typename T>
class MyClass {
   public:
      MyClass() {
         cout << "This is constructor of generalized class " << endl;
      }
};
template<>
class MyClass <char>{
   public:
      MyClass() {
         cout << "This is constructor of specialized class (Only for characters)" << endl;
      }
};
main() {
   MyClass<int> ob_int;
   MyClass<float> ob_float;
   MyClass<char> ob_char;
   MyClass<string> ob_string;
}
This is constructor of generalized class
This is constructor of generalized class
This is constructor of specialized class (Only for characters)
This is constructor of generalized class
How to auto adjust font size using CSS ?

31 Mar, 2021
The font-size-adjust property of CSS tells the browser to adjust the font size of the text to the same size regardless of font family. When the first chosen font is not available, the font-size-adjust property allows you more control over the font size. If a font isn’t available, the window defaults to the second font defined. This could lead to a significant shift in font size. Using the font-size-adjust property to stop this. The size difference between the lowercase letter “x” and the uppercase letter “X” is the “aspect value” of all fonts. When the browser knows the “aspect value” of the first font, it will determine what font-size to use when viewing text in the second font.
Syntax:
font-size-adjust: number|none|initial|inherit;
Below are the examples that illustrates the use of font-size-adjust property.
Example:
HTML
<!DOCTYPE html><html>  <head>   <style>    div.a {font-family: Helvetica;}    div.b {font-family: 'sans-serif';}    #div1, #div2 {font-size-adjust: 0.74;}   </style></head>  <body>  <h1 style = "color:green;text-align:center;">     GeeksforGeeks   </h1>    <h2 style = "color:blue;text-align:left;">    Font Size Adjust Property  </h2>    <h2 style ="color:orange;text-align:left;">    Divs with same Font Size Adjust Property:  </h2>    <div id="div1" class="a">    We offer a range of services to help you learn,     develop, and have fun! Free tutorials, millions     of posts, live, online, and classroom classes,     regular coding contests, industry expert webinars,     internships, and career openings are all available.  </div><br>      <div id="div2" class="b">    Sandeep Jain is the founder of 'GeeksforGeeks,'    an IIT Roorkee alumni group. He enjoys finding     the most effective solutions to programming problems.   </div>    <h2 style = "color:red;text-align:left;">    Divs without same Font Size Adjust Property:  </h2>    <div class="a">    Apart from GeeksforGeeks, he has worked as a web     developer for DE Shaw and Co. and as an assistant     professor at JIIT Noida.   </div><br>    <div class="b">    GeeksforGeeks.org was founded with the aim of     providing well-written, well-considered, and     well-explained answers to specific questions.     If you're interested in mastering algorithms,     data structures, or just the programming language itself,     GeeksforGeeks has you covered!  </div></body>  </html>
Output :
Auto Adjust Font Size using CSS
Browser Support:
Only Firefox currently supports the CSS font-size-adjust property by default.
CSS-Properties
CSS-Questions
Picked
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE CS 2008 | Question 85

07 Sep, 2018
Consider the following ER diagram.
The minimum number of tables needed to represent M, N, P, R1, R2 is(A) 2(B) 3(C) 4(D) 5Answer: (B)Explanation: Answer is B, i.e, 3 minimum tables.
M, P are strong entities hence they must be represented by separate tables.
Many-to-one and one-to-many relationship sets that are total on the many-side can be represented by adding an extra attribute to the “many” side, containing the primary key of the “one” side. ( This way no extra table will be needed for Relationship sets )
M table is modified to include primary key of P side(i.e. P1). N is weak entity, and is modified to include primary key of P (i.e, P1).
Therefore there would be minimum of 3 tables with schema given below :
M ( M1, M2, M3, P1)
P ( P1, P2 )
N ( P1, N1, N2 )
Quiz of this Question
shethnisarg1998
GATE-CS-2008
GATE-GATE CS 2008
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ML | Chi-square Test for feature selection

24 Dec, 2018
Feature selection is also known as attribute selection is a process of extracting the most relevant features from the dataset and then applying machine learning algorithms for the better performance of the model. A large number of irrelevant features increases the training time exponentially and increase the risk of overfitting.
Chi-square Test for Feature Extraction:Chi-square test is used for categorical features in a dataset. We calculate Chi-square between each feature and the target and select the desired number of features with best Chi-square scores. It determines if the association between two categorical variables of the sample would reflect their real association in the population.Chi- square score is given by :where –
Observed frequency = No. of observations of classExpected frequency = No. of expected observations of class if there was no relationship between the feature and the target.
Python Implementation of Chi-Square feature selection:
# Load librariesfrom sklearn.datasets import load_irisfrom sklearn.feature_selection import SelectKBestfrom sklearn.feature_selection import chi2  # Load iris datairis_dataset = load_iris()  # Create features and targetX = iris_dataset.datay = iris_dataset.target  # Convert to categorical data by converting data to integersX = X.astype(int)  # Two features with highest chi-squared statistics are selectedchi2_features = SelectKBest(chi2, k = 2)X_kbest_features = chi2_features.fit_transform(X, y)  # Reduced featuresprint('Original feature number:', X.shape[1])print('Reduced feature number:', X_kbest.shape[1])
Output:
Original feature number: 4
Reduced feature number : 2
Machine Learning
Python
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Unique values in Matrix

25 Feb, 2019
Sometimes we need to find the unique values in a list, that is comparatively easy and has been discussed earlier. But we can also get a matrix as input i.e a list of lists, finding unique in them are discussed in this article. Let’s see certain ways in which this can be achieved.
Method #1 : Using set() + list comprehensionThe set function can be used to convert the individual list to a non-repeating element list and the list comprehension is used to iterate to each of the lists.
# Python3 code to demonstrate# checking unique values in matrix# set() + list comprehension  # initializing matrix test_matrix = [[1, 3, 1], [4, 5, 3], [1, 2, 4]]  # printing the original matrixprint ("The original matrix is : " + str(test_matrix))  # using set() + list comprehension# for checking unique values in matrixres = list(set(i for j in test_matrix for i in j))  # printing resultprint ("Unique values in matrix are : " + str(res))
The original matrix is : [[1, 3, 1], [4, 5, 3], [1, 2, 4]]
Unique values in matrix are : [1, 2, 3, 4, 5]

 Method #2 : Using chain() + set()The chain function performs the similar task that a list comprehension performs but in a faster way as it uses iterators for its internal processing and hence faster.
# Python3 code to demonstrate# checking unique values in matrix# chain() + set()from itertools import chain  # initializing matrix test_matrix = [[1, 3, 1], [4, 5, 3], [1, 2, 4]]  # printing the original matrixprint ("The original matrix is : " + str(test_matrix))  # using chain() + set()# for checking unique values in matrixres = list(set(chain(*test_matrix)))  # printing resultprint ("Unique values in matrix are : " + str(res))
The original matrix is : [[1, 3, 1], [4, 5, 3], [1, 2, 4]]
Unique values in matrix are : [1, 2, 3, 4, 5]

Python list-programs
python-list
Python
Python Programs
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python OOPs Concepts
Python Classes and Objects
Introduction To PYTHON
Python | os.path.join() method
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Python program to check whether a number is Prime or not
How to Add Labels Directly in ggplot2 in R

31 Aug, 2021
Labels are textual entities that have information about the data point they are attached to which helps in determining the context of those data points. In this article, we will discuss how to directly add labels to ggplot2 in R programming language.
To put labels directly in the ggplot2 plot we add data related to the label in the data frame. Then we use functions geom_text() or geom_label() to create label beside every data point. Both the functions work the same with the only difference being in appearance. The geom_label() is a bit more customizable than geom_text().
This method is used to add Text labels to data points in ggplot2 plots. It positions in the same manner as geom_point() does. 
Syntax: ggp + geom_text( label,  nudge_x , nudge_y,   check_overlap )
Parameters:
label: Text labels we want to show at data points
nudge_x: shifts the text along X-axis
nudge_y: shifts the text along Y-axis
check_overlap:  avoids text overlap
Example: Scatter plot with labels on it using ggplot2 and geom_text.
R
# import library ggplot2library(ggplot2)  # Create datasetx1 < - c(1, 1, 1, 2, 3, 4, 4, 4, 5, 5, 6, 2, 3)y1 < - c(7, 23, 31, 14, 11, 3, 13, 27, 21, 10, 21, 14, 30)label1 < - c('Apple', 'Guava', 'Papaya', 'Orange', 'PineApple',             'Dragon Fruit', 'Kiwi', 'blackberry', 'blueberry',             'grapes', 'strawberry', 'raspberry', 'Grapefruit')  sample_data < - data.frame(x1, y1, label1)  # add text with geom_textggplot(sample_data, aes(x=x1, y=y1)) +geom_point() +geom_text(    label=label1,    nudge_x=0.45, nudge_y=0.1,    check_overlap=T)
Output:
This method is used to add Text labels to data points in ggplot2 plots. It pretty much works the same as the geom_text the only difference being it wraps the label inside a rectangle.
Syntax: ggp + geom_label( label,  nudge_x , nudge_y,   check_overlap,  label.padding,  label.size,  color,  fill )
Parameters:
label: Text labels we want to show at data points
nudge_x: shifts the text along X-axis
nudge_y: shifts the text along Y-axis
check_overlap:  avoids text overlap
label.padding: padding inside rectangular overlap
label.size: size of rectangular overlap
color: color of text in label
fill: background color of rectangular overlap
Example: Scatter plot with labels on it using ggplot2 and geom_label().
R
# import library ggplot2library(ggplot2)  # Create datasetx1 < - c(1, 1, 1, 2, 3, 4, 4, 4, 5, 5, 6, 2, 3)y1 < - c(7, 23, 31, 14, 11, 3, 13, 27, 21, 10, 21, 14, 30)label1 < - c('Apple', 'Guava', 'Papaya', 'Orange', 'PineApple',             'Dragon Fruit', 'Kiwi', 'blackberry', 'blueberry',             'grapes', 'strawberry', 'raspberry', 'Grapefruit')  sample_data < - data.frame(x1, y1, label1)  # add text with geom_textggplot(sample_data, aes(x=x1, y=y1)) +geom_point() +geom_label(    label=label1,    nudge_x=0.45, nudge_y=0.1,    check_overlap=T,    label.padding=unit(0.55, "lines"),    label.size=0.4,    color="white",    fill="#038225")
Output:
Picked
R-ggplot
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JavaScript - Find the smallest n digit number or greater

We are required to write a JavaScript function that takes in a number as the first argument, say n, and an array of numbers as the second argument. The function should return the smallest n digit number which is a multiple of all the elements specified in the array. If there exist no such n digit element then we should return the smallest such element.
For example: If the array is −
const arr = [12, 4, 5, 10, 9]
For both n = 2 and n = 3, the output should be 180
Following is the code −
const arr = [12, 4, 5, 10, 9]
const num1 = 2;
const num2 = 3;
const allDivides = (arr, num) => arr.every(el => num % el === 0);
const smallestMultiple = (arr, num) => {
   let smallestN = Math.pow(10, (num - 1));
   while(!allDivides(arr, smallestN)){
      smallestN++;
   };
   return smallestN;
};
console.log(smallestMultiple(arr, num1));
console.log(smallestMultiple(arr, num2));
Following is the output in the console −
180
180