code-rag-bench/online-tutorials huggingface dataset:
comment – Django template tags

23 Sep, 2021
A Django template is a text document or a Python string marked-up using the Django template language. Django being a powerful Batteries included framework provides convenience to rendering data in a template. Django templates not only allow passing data from view to the template but also provide some limited features of programming such as variables, for loops, comments, etc. This article revolves about how to use comment tag in Template. Template ignores everything between {% comment %} and {% endcomment %}. An optional note may be inserted in the first tag. For example, this is useful when commenting out code for documenting why the code was disabled. 
Syntax 
{% comment 'comment_name' %}
{% endcomment %}
Example 
{% comment "Optional note" %}
    Commented out text with {{ create_date|date:"c" }}
{% endcomment %}
Illustration of How to use comment tag in Django templates using an Example. Consider a project named geeksforgeeks having an app named geeks. 
Refer to the following articles to check how to create a project and an app in Django. 
How to Create a Basic Project using MVT in Django?
How to Create an App in Django ?
Now create a view through which we will pass the context dictionary, In geeks/views.py, 
Python3
# import Http Response from djangofrom django.shortcuts import render # create a functiondef geeks_view(request):    # create a dictionary    context = {        "data" : "<h1>GeeksForGeeks is the Best</h1>",    }    # return response    return render(request, "geeks.html", context)
Create a url path to map to this view. In geeks/urls.py,
Python3
from django.urls import path # importing views from views..pyfrom .views import geeks_view urlpatterns = [    path('', geeks_view),]
Create a template in templates/geeks.html, 
HTML
Data uncommented :{{ data }}Data commented :{% comment "Optional note" %}    {{ data }}{% endcomment %}
Let’s check is comments are displayed in the template. 
 
surindertarika1234
Django-templates
Python Django
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Iterate over a list in Python
How to find time taken by a command/program on Linux Shell?

26 Sep, 2017
We have already discussed a way to find time taken by a function through C libraries. If we are on Linux, then it becomes very easy to find time taken by a program/command.
We can use time command for this purpose. The time taken is shown in three forms.real: Total end to end time taken by program/commanduser: Time taken in user mode.sys: Time taken in kernel mode
A Command Example (Time taken by ls-l):
$ time ls -l

The above command runs "ls -l" and shows 
contents of current directory followed by
the time taken by command "ls -l".  

 
A program example (Time taken by fib(30)):let us consider below program.
#include<stdio.h>int fib(int n){   if (n <= 1)      return n;   return fib(n-1) + fib(n-2);}  int main (){  printf("Fibonacci Number is %d", fib(30));  return 0;}
Let we save above program as fib.c.

// Compiling above program on shell
~$ gcc fib.c

// Running the generated executable with time
~$ time ./a.out
Fibonacci Number is 832040
real    0m0.017s
user    0m0.017s
sys    0m0.000s

Note: 0.017 seconds (shown with real) is total 
time taken by program.

This article is contributed Dheeraj Gupta. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
Linux-Unix
TechTips
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ZIP command in Linux with examples
tar command in Linux with examples
curl command in Linux with Examples
TCP Server-Client implementation in C
Conditional Statements | Shell Script
How to Find the Wi-Fi Password Using CMD in Windows?
Docker - COPY Instruction
Setting up the environment in Java
How to Run a Python Script using Docker?
Running Python script on GPU.
How jQuery selects elements using CSS?

jQuery uses CSS selector to select elements using CSS. Let us see an example to return a style property on the first matched element. The css( name ) method returns a style property on the first matched element.
Here is the description of all parameter used by this method −
name − The name of the property to access.
You can try to run the following code to learn how jQuery selects elements with CSS:
Live Demo
<html>

   <head>
      <title>jQuery Example</title>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
       
      <script>
         $(document).ready(function() {
           
            $("div").click(function () {
               var color = $(this).css("background-color");
               $("#result").html("That div is <span style = 'color:" +
                  color + ";'>" + color + "</span>.");
            });
               
         });
      </script>
       
      <style>
         div { width:60px; height:60px; margin:5px; float:left; }
      </style>
   </head>
   
   <body>
   
      <p>Click on any square:</p>
      <span id = "result"> </span>
       
      <div style = "background-color:blue;"></div>
      <div style = "background-color:gray;"></div>
      <div style = "background-color:#123456;"></div>
      <div style = "background-color:#f11;"></div>
       
   </body>
   
</html>
numpy.frombuffer() function – Python

18 Aug, 2020
numpy.frombuffer() function interpret a buffer as a 1-dimensional array.
Syntax : numpy.frombuffer(buffer,  dtype = float,  count = -1,  offset = 0)
Parameters :
buffer : [buffer_like] An object that exposes the buffer interface.
dtype : [data-type, optional] Data-type of the returned array, default data-type is float.
count : [int, optional] Number of items to read.
offset : [int, optional] Start reading the buffer from this offset, default is 0.
Return : This function interpret a buffer as a 1-dimensional array.
Code #1 :
Python3
# Python program explaining# numpy.frombuffer() function              # importing numpy as geek import numpy as geek   gfg = geek.frombuffer(b'\x01\x02\x03', dtype = geek.uint8)  print (gfg)
Output :
[1 2 3]
Code #2 :
Python3
# Python program explaining# numpy.frombuffer() function              # importing numpy as geek import numpy as geek   gfg = geek.frombuffer(b'\x01\x02\x03\x04\x05\x06\x07', dtype = geek.uint8, count = 5)  print (gfg)
Output :
[1 2 3 4 5]
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python | os.path.join() method
Introduction To PYTHON
Python OOPs Concepts
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Create a directory in Python
Access specifier of methods in interfaces

07 Dec, 2018
In Java, all methods in an interface are public even if we do not specify public with method names. Also, data fields are public static final even if we do not mention it with fields names. Therefore, data fields must be initialized.
Consider the following example, x is by default public static final and foo() is public even if there are no specifiers.
interface Test {  int x = 10;  // x is public static final and must be initialized here  void foo();  // foo() is public}
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
access modifiers
java-basics
java-interfaces
Java
School Programming
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Arrays in Java
Arrays.sort() in Java with examples
Split() String method in Java with examples
Reverse a string in Java
Object Oriented Programming (OOPs) Concept in Java
Python Dictionary
Reverse a string in Java
Arrays in C/C++
Introduction To PYTHON
Interfaces in Java
How to change the font size of the Title in a Matplotlib figure ?

03 Nov, 2021
In this article, we are going to discuss how to change the font size of the title in a figure using matplotlib module.
As we use matplotlib.pyplot.title() method to assign a title a plot, so in order to change the font size, we are going to use the fontsize argument of the pyplot.title() method in the matplotlib module.  
Below is are some programs which depict how to change the font size of the title in a matplotlib figure:
Example 1:
Python3
# importing moduleimport matplotlib.pyplot as plt # assigning x and y coordinatesx = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]y = [] for i in range(len(x)):    y.append(max(0, x[i])) # depicting the visualizationplt.plot(x, y, color='green')plt.xlabel('x')plt.ylabel('y') # displaying the titleplt.title("ReLU Function",          fontsize = 40)
Output:
Example 2:
Python3
# importing modulesfrom matplotlib import pyplot as plt # assigning x and y coordinatesfoodPreference = ['Vegetarian', 'Non Vegetarian',                                'Vegan', 'Eggitarian'] consumers = [30, 100, 10, 60] # depicting the visualizationfig = plt.figure()ax = fig.add_axes([0, 0, 1, 1])ax.axis('equal')ax.pie(consumers, labels = foodPreference,       autopct='%1.2f%%') # displaying the titleplt.title("Society Food Preference",          fontsize = 10)
Output:
Example 3:
Python3
# importing modulesfrom matplotlib import pyplotimport numpy # assigning time values of the signal# initial time period, final time period# and phase anglesignalTime = numpy.arange(0, 100, 0.5) # getting the amplitude of the signalsignalAmplitude = numpy.sin(signalTime) # depicting the visualizationpyplot.plot(signalTime, signalAmplitude,            color = 'green') pyplot.xlabel('Time')pyplot.ylabel('Amplitude') # displaying the titlepyplot.title("Signal",             fontsize = 30)
Output:
kashishsoda
Picked
Python-matplotlib
Technical Scripter 2020
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to iterate through Excel rows in Python?
Rotate axis tick labels in Seaborn and Matplotlib
Deque in Python
Queue in Python
Defaultdict in Python
Check if element exists in list in Python
Python Classes and Objects
Bar Plot in Matplotlib
reduce() in Python
Python | Get unique values from a list
What is the difference between SCSS and SASS ?

01 Jun, 2022
SASS (Syntactically Awesome Style Sheets) is a pre-processor scripting language that will be compiled or interpreted into CSS. SassScript is itself a scripting language whereas SCSS is the main syntax for the SASS which builds on top of the existing CSS syntax. It makes use of semicolons and brackets like CSS (Cascaded Style Sheets).SASS and SCSS can import each other. Sass actually makes CSS more powerful with math and variable support. Let’s list down the main difference between SASS and SCSS.  
SASS is used when we need an original syntax, code syntax is not required for SCSS.
SASS follows strict indentation, SCSS has no strict indentation.
SASS has a loose syntax with white space and no semicolons, the SCSS resembles more to CSS style and use of semicolons and braces are mandatory.
SASS file extension is .sass and SCSS file extension is .scss.
SASS has more developer community and support than SCSS.
SASS supports SassDoc to add documentation whereas SCSS allows inline documentation.
SASS can’t be used as CSS and vice-versa whereas a valid CSS code is also a valid SCSS code.
SASS is hard to add to existing CSS projects whereas SCSS can be added easily to an existing CSS project just by adding new code.
SCSS Example:  
SCSS
/* .scss file */$bgcolor: blue;$textcolor: red;$fontsize: 25px; /* Use the variables */body {  background-color: $bgcolor;  color: $textcolor;  font-size: $fontsize;}
Output CSS:  
body {
  background-color: blue;
  color: red;
  font-size: 25px;
}
/* now this can apply resulting html file */
SASS Example: 
SASS
/* SASS */ $primary-color: green$primary-bg: red body  color: $primary-color  background: $primary-bg
Output CSS:
/* CSS */
body {
  color: green;
  background: red;
}
CSS is the foundation of webpages, is used for webpage development by styling websites and web apps.You can learn CSS from the ground up by following this CSS Tutorial and CSS Examples.
raragarwal102
daveholuborhee
olumideokedusi
siddharthredhu01
Picked
SASS
CSS
Technical Scripter
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a Tribute Page using HTML & CSS
How to set space between the flexbox ?
How to select all child elements recursively using CSS?
Build a Survey Form using HTML and CSS
CSS | :not(:last-child):after Selector
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
How can we use MySQL INSTR() function with WHERE clause?

When we use INSTR() function with MySQL WHERE clause, we need to provide column name of the table as the first argument and the substring as second argument along with a comparison operator. Following is an example using ‘Student’ table to demonstrate it −
Suppose we have the following values in ‘Student’ table −
mysql> Select * from Student;
+------+---------+---------+-----------+
| Id   | Name    | Address | Subject   |
+------+---------+---------+-----------+
| 1    | Gaurav  | Delhi   | Computers |
| 2    | Aarav   | Mumbai  | History   |
| 15   | Harshit | Delhi   | Commerce  |
| 20   | Gaurav  | Jaipur  | Computers |
| 21   | Yashraj | NULL    | Math      |
+------+---------+---------+-----------+

5 rows in set (0.02 sec)
Now, following query show how we can use INSTR() function with WHERE caluse −
mysql> select name, INSTR(Name,'av')As Result from student where INSTR(Name,'av') > 0;

+--------+--------+
| name   | Result |
+--------+--------+
| Gaurav |      5 |
| Aarav  |      4 |
| Gaurav |      5 |
+--------+--------+

3 rows in set (0.00 sec)

mysql> select name, INSTR(Name,'av')As Result from student where INSTR(Name,'av') = 0 ;

+---------+--------+
| name    | Result |
+---------+--------+
| Harshit |      0 |
| Yashraj |      0 |
+---------+--------+

2 rows in set (0.01 sec)
How to serialize the order of properties using the Jackson library in Java?

The @JsonPropertyOrder is an annotation to be used at the class-level. It takes as property a list of fields that defines the order in which fields can appear in the string resulting from the object JSON serialization. The properties included in the annotation declaration can be serialized first(in defined order), followed by any properties not included in the definition.
public @interface JsonPropertyOrder
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import java.util.*;
import java.io.*;
public class JsonPropertyOrderTest {
   public static void main(String args[]) throws JsonGenerationException, JsonMappingException,        IOException {
      Employee emp = new Employee();
      emp.setFirstName("Adithya");
      emp.setEmpId(25);
      emp.setLastName("Jai");
      emp.getTechnologies().add("Java");
      emp.getTechnologies().add("Scala");
      emp.getTechnologies().add("Python");
      ObjectMapper mapper = new ObjectMapper();
      mapper.writerWithDefaultPrettyPrinter().writeValue(System.out, emp);
   }
}
// Employee class
@JsonPropertyOrder({
   "firstName",
   "lastName",
   "technologies",
   "empId"
})
class Employee {
   private int empId;
   private String firstName;
   private String lastName;
   private List<String> technologies = new ArrayList<>();
   public int getEmpId() {
      return empId;
   }
   public void setEmpId(int empId) {
      this.empId = empId;
   }
   public String getFirstName() {
      return firstName;
   }
   public void setFirstName(String firstName) {
      this.firstName = firstName;
   }
   public String getLastName() {
      return lastName;
   }
   public void setLastName(String lastName) {
      this.lastName = lastName;
   }
   public List<String> getTechnologies() {
      return technologies;
   }
   public void setTechnologies(List<String> technologies) {
      this.technologies = technologies;
   }
}
{
   "firstName" : "Adithya",
   "lastName" : "Jai",
   "technologies" : [ "Java", "Scala", "Python" ],
   "empId" : 125
}
When to use the readNBytes() method of InputStream in Java 9?

Since Java 9, the readNBytes() method can be added to the InputStream class. This method reads the requested number of bytes from an input stream into the given byte array. This method blocks until len bytes of input data have read, end of a stream is detected, or an exception is thrown. The readNBytes() method doesn't close an input stream. This method can be useful to avoid memory problems with large files.
public int readNBytes(byte[] b, int off, int len) throws IOException
In the below example, we have created a "Technology.txt" file in the source folder with simple data: { "JAVA", "PYTHON", "JAVASCRIPT", "SELENIUM", "SCALA"}.
import java.io.*;
import java.util.stream.*;
import java.nio.*;
import java.nio.file.*;

public class InputStreamReadNByteMethodTest {
   InputStream inputStream = nputStreamReadNByteMethodTest.class.getResourceAsStream("Technology.txt");

   public void testReadNBytes() throws Exception {
      final byte[] data = new byte[10];
      inputStream.readNBytes(data, 0, 7);
      System.out.println(new String(data));
   }
   public static void main(String args[]) throws Exception {
      InputStreamReadNByteMethodTest t = new InputStreamReadNByteMethodTest();
      t.testReadNBytes();  
   }
}
"JAVA",
How to identify nth element using xpath in Selenium with python?

There are multiple ways of building a customized xpath. In case we need to identify nth element we can achieve this by the ways listed below.
position() method in xpath.Suppose we have two edit boxes in a page with similar xpath and we want to identify the first element, then we need to add the position()=1.
position() method in xpath.
Suppose we have two edit boxes in a page with similar xpath and we want to identify the first element, then we need to add the position()=1.
Syntax −
driver.find_element_by_xpath("//input[@type='text'][position()=1]")
square bracket addition with braces to indicate index.Suppose we need to reach the third row of the table and the customized xpath for that row should be indicated with the help of [3] expression.
square bracket addition with braces to indicate index.
Suppose we need to reach the third row of the table and the customized xpath for that row should be indicated with the help of [3] expression.
Syntax −
driver.find_element_by_xpath("//table/tbody/tr[2]/td[2]")
Code Implementation with position()
from selenium import webdriver
#browser exposes an executable file
#Through Selenium test we will invoke the executable file which will then #invoke actual browser
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
# to maximize the browser window
driver.maximize_window()
#get method to launch the URL
driver.get("https://www.tutorialspoint.com/index.htm")
#to refresh the browser
driver.refresh()
# identifying the edit box with the help of position()
driver.find_element_by_xpath("//input[@type='text'][position()=1]").
send_keys("Selenium")
#to close the browser
driver.close()
Code Implementation with index
from selenium import webdriver
#browser exposes an executable file
#Through Selenium test we will invoke the executable file which will then #invoke actual browser
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
# to maximize the browser window
driver.maximize_window()
#get method to launch the URL
driver.get("https://www.tutorialspoint.com/plsql/plsql_basic_syntax.htm")
#to refresh the browser
driver.refresh()
# printing the first data in the row 2 of table with index
print(driver.find_element_by_xpath("//table/tbody/tr[2]/td[1]").text)
#to close the browser
driver.close()
Python - Maximum of each Column - GeeksforGeeks

30 Jan, 2020
Sometimes, we are encountered with such problem in which we need to find the maximum of each column in a matrix i.e maximum of each index in list of lists. This kind of problem is quite common and useful in competitive programming. Let’s discuss certain ways in which this problem can be solved.
Method #1 : Using max() + list comprehension + zip()The combination of above methods are required to solve this particular problem. The max function is used to get the required maximum value and zip function provides the combination of like indices and then list is created using list comprehension.
# Python3 code to demonstrate# Maximum of each Column# using max() + list comprehension + zip()  # initializing listtest_list = [[3, 7, 6], [1, 3, 5], [9, 3, 2]]  # printing original listprint("The original list : " + str(test_list))  # using max() + list comprehension + zip()# Maximum of each Columnres = [max(idx) for idx in zip(*test_list)]  # print resultprint("The Maximum of each index list is : " + str(res))
The original list : [[3, 7, 6], [1, 3, 5], [9, 3, 2]]
The Maximum of each index list is : [9, 7, 6]

 
Method #2 : Using map() + max() + zip()This works in almost similar way as the above method, but the difference is just that we use map function to build the max element list rather than using list comprehension.
# Python3 code to demonstrate# Maximum index value# using max() + map() + zip()  # initializing listtest_list = [[3, 7, 6], [1, 3, 5], [9, 3, 2]]  # printing original listprint("The original list : " + str(test_list))  # using max() + map() + zip()# Maximum index valueres = list(map(max, zip(*test_list)))  # print resultprint("The Maximum of each index list is : " + str(res))
The original list : [[3, 7, 6], [1, 3, 5], [9, 3, 2]]
The Maximum of each index list is : [9, 7, 6]

Python list-programs
Python
Python Programs
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
Enumerate() in Python
Defaultdict in Python
Python program to convert a list to string
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
What are Enumerated Constants in C++?

An enumerated type declares an optional type name and a set of zero or more identifiers that can be used as values of the type. Each enumerator is a constant whose type is the enumeration. These are also called as enumerated constants.
For example, if you are creating an application that has a fixed number of types for some variable. For example, let's say gender, it can be of three types male, female and others. You can define and use an enum like −
#include<iostream>
using namespace std;
enum Gender {MALE, FEMALE, OTHERS};
int main() {
   Gender gen = Gender.FEMALE;
   return 0;
}
By default, the value of the first name is 0, the second name has the value 1, and the third has the value 2, and so on. But these values don't matter because enums are basically used to have a symbolic meaning. Whenever you compare an enum in your program, you'd be just using its symbolic meaning and not its actual value.
Last element of vector in C++ (Accessing and updating) - GeeksforGeeks

10 Sep, 2020
In C++ vectors, we can access last element using size of vector using following ways.
1) Using size()
#include <bits/stdc++.h>using namespace std;  int main(){    vector<int> v{10, 20, 30, 40, 50};          // Accessing last element    int n = v.size();    cout << v[n - 1] << endl;      // modifying last element    v[n - 1] = 100;      cout << v[n - 1] << endl;    return 0;}
Output :
50
100
2) Using back() We can access and modify last value using back().
#include <bits/stdc++.h>using namespace std;  int main(){    vector<int> v{10, 20, 30, 40, 50};          // Accessing last element    cout << v.back() << endl;      // modifying last element    v.back() = 100;      cout << v.back() << endl;    return 0;}
Output :
50
100
19bcs1298
cpp-vector
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
C++ Classes and Objects
Constructors in C++
Socket Programming in C/C++
Operator Overloading in C++
Copy Constructor in C++
Virtual Function in C++
vector erase() and clear() in C++
rand() and srand() in C/C++
Templates in C++ with Examples
unordered_map in C++ STL
How can we perform ROLLBACK transactions inside a MySQL stored procedure?

As we know that ROLLBACK will revert any changes made to the database after the transaction has been started. To perform the ROLLBACK in MySQL stored procedure we must have to declare EXIT handler. We can use a handler for either sqlexception or SQL warnings. It can be understood with the help of an example in which stored procedure having ROLLBACK created for the table having the following details −
mysql> SHOW CREATE table gg\G
*************************** 1. row ***************************
       Table: gg
Create Table: CREATE TABLE `gg` (
   `Id` int(11) NOT NULL AUTO_INCREMENT,
   `Name` varchar(30) NOT NULL,
   PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
We can see that the column ‘name’ cannot have NULL values and table have the following data −
mysql> Select * from employee.tbl;
+----+---------+
| Id | Name    |
+----+---------+
|  1 | Mohan   |
|  2 | Gaurav  |
|  3 | Sohan   |
|  4 | Saurabh |
|  5 | Yash    |
|  6 | Rahul   |
+----+---------+
6 rows in set (0.00 sec)
mysql> Delimiter //
mysql> Create Procedure st_transaction_Rollback()
    -> BEGIN
    -> DECLARE exit handler for sqlexception
    -> BEGIN
    -> ROLLBACK;
    -> END;
    -> DECLARE exit handler for sqlwarning
    -> BEGIN
    -> ROLLBACK;
    -> END;
    -> START TRANSACTION;
    -> INSERT INTO employee.tbl(name) values();
    -> UPDATE employee.tbl set name = 'YashPal' where id = 5;
    -> COMMIT;
    -> END //
Query OK, 0 rows affected (0.02 sec)

mysql> Delimiter ;
mysql> CALL st_transaction_Rollback ()
Query OK, 0 rows affected (0.00 sec)

mysql> Select * from employee.tbl;
+----+---------+
| Id | Name    |
+----+---------+
|  1 | Mohan   |
|  2 | Gaurav  |
|  3 | Sohan   |
|  4 | Saurabh |
|  5 | Yash    |
|  6 | Rahul   |
+----+---------+
6 rows in set (0.00 sec)
We can see from the above result set that the changes made by UPDATE statement have been ROLLBACKED because the first query of INSERT has thrown an error (trying to insert NULL values).
C++ Tutorial

C++ is a popular programming language.
C++ is used to create computer programs, and is one of the most used language in game development.
Our "Try it Yourself" editor makes it easy to learn C++. You can edit C++ code and view the result in your browser.
Click on the "Run example" button to see how it works.
We recommend reading this tutorial, in the sequence listed in the left menu.
C++ is an object oriented language and some concepts may be new. Take breaks when needed, and go
over the examples as many times as needed.
Insert the missing part of the code below to output "Hello World".
int main() {
   << "Hello World!";
  return 0;
}

Start the Exercise
Learn by examples! This tutorial supplements all explanations with clarifying examples.
See All C++ Examples
Learn by taking a quiz! The quiz will give you a signal of how much you know, or do not know, about C++.
Start C++ Quiz
Get certified by completing the C++ course
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.
Haskell - Monads

Monads are nothing but a type of Applicative Functor with some extra features. It is a Type class which governs three basic rules known as monadic rules.
All the three rules are strictly applicable over a Monad declaration which is as follows −
class Monad m where  
   return :: a -> m a 
   (>>=) :: m a -> (a -> m b) -> m b 
   (>>) :: m a -> m b -> m b 
   x >> y = x >>= \_ -> y 
   fail :: String -> m a  
   fail msg = error msg 
The three basic laws that are applicable over a Monad declaration are −
Left Identity Law − The return function does not change the value and it should not change anything in the Monad. It can be expressed as "return >=> mf = mf".
Left Identity Law − The return function does not change the value and it should not change anything in the Monad. It can be expressed as "return >=> mf = mf".
Right Identity Law − The return function does not change the value and it should not change anything in the Monad. It can be expressed as "mf >=> return = mf".
Right Identity Law − The return function does not change the value and it should not change anything in the Monad. It can be expressed as "mf >=> return = mf".
Associativity − According to this law, both Functors and Monad instance should work in the same manner. It can be mathematically expressed as "( f >==>g) >=> h =f >= >(g >=h)".
Associativity − According to this law, both Functors and Monad instance should work in the same manner. It can be mathematically expressed as "( f >==>g) >=> h =f >= >(g >=h)".
The first two laws iterate the same point, i.e., a return should have identity behavior on both sides of the bind operator.
We have already used lots of Monads in our previous examples without realizing that they are Monad. Consider the following example where we are using a List Monad to generate a specific list.
main = do
   print([1..10] >>= (\x -> if odd x then [x*2] else []))
This code will produce the following output −
[2,6,10,14,18]

 Print
 Add Notes
 Bookmark this page
HTML5 - URL

It accepts only URL value. This type is used for input fields that should contain a URL address. If you try to submit a simple text, it forces to enter only URL address either in http://www.example.com format or in http://example.com format.
<!DOCTYPE HTML>

<html>
   <body>

      <form action = "/cgi-bin/html5.cgi" method = "get">
         Enter URL : <input type = "url" name = "newinput" />
         <input type = "submit" value = "submit" />
      </form>

   </body>
</html>

    19 Lectures 
     2 hours 

 Anadi Sharma

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    18 Lectures 
     1.5 hours 

 Frahaan Hussain

    57 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)

    54 Lectures 
     6 hours 

 DigiFisk (Programming Is Fun)

    45 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
Print pair with maximum AND value in an array in C Program.

According to the problem we are given an array of n positive integers, we have to find a pair with maximum AND value from the array.
Input: arr[] = { 4, 8, 12, 16 }
Output: pair = 8 12
The maximum and value= 8

Input:arr[] = { 4, 8, 16, 2 }
Output: pair = No possible AND
The maximum and value = 0
For finding Maximum AND value is similar to find out Maximum AND value in an array. Program must find out the pair of elements resulting in obtained AND value. For finding the elements, simply traverse the whole array and find the AND value of each element with the obtained maximum AND value (result) and if arr[i] & result == result, that means arr[i] is the element which will generate maximum AND value. Also, in the case if maximum AND value (result) is zero then we should print “Not possible” in that case.
int checkBit(int pattern, int arr[], int n)
START
STEP 1: DECLARE AND INITIALIZE count AS 0
STEP 2: LOOP FOR i = 0 AND i < n AND i++
   IF (pattern & arr[i]) == pattern THEN,
      INCREMENT count BY 1
STEP 3: RETURN count
STOP
int maxAND(int arr[], int n)
START
STEP 1: DECLARE AND INITIALIZE res = 0 AND count
STEP 2: LOOP FOR bit = 31 AND bit >= 0 AND bit--
   count = GOTO FUNCTION checkBit(res | (1 << bit), arr,n)
   IF count >= 2 THEN,
      res |= (1 << bit);
   END IF
   IF res == 0
      PRINT "no possible AND”
   ELSE
      PRINT "Pair with maximum AND= "
   count = 0;
   LOOP FOR int i = 0 AND i < n && count < 2 AND i++
      IF (arr[i] & res) == res THEN,
         INCREMENT count BY 1
         PRINT arr[i]
      END IF
   END FOR
END FOR
RETURN res
STOP
#include <stdio.h>
int checkBit(int pattern, int arr[], int n){
   int count = 0;
   for (int i = 0; i < n; i++)
      if ((pattern & arr[i]) == pattern)
         count++;
   return count;
}
// Function for finding maximum AND value pair
int maxAND(int arr[], int n){
   int res = 0, count;
   for (int bit = 31; bit >= 0; bit--) {
      count = checkBit(res | (1 << bit), arr, n);  
      if (count >= 2)
         res |= (1 << bit);
   }
   if (res == 0) //if there is no pair available
      printf("no possible and\n");
   else { //Printing the pair available
      printf("Pair with maximum AND= ");
      count = 0;
      for (int i = 0; i < n && count < 2; i++) {
         // incremnent count value after
         // printing element
         if ((arr[i] & res) == res) {
            count++;
            printf("%d ", arr[i]);
         }
      }
   }
   return res;
}
int main(int argc, char const *argv[]){
   int arr[] = {5, 6, 2, 8, 9, 12};
   int n = sizeof(arr)/sizeof(arr[0]);
   int ma = maxAND(arr, n);
   printf("\nThe maximum AND value= %d ", ma);
   return 0;
}
If we run the above program then it will generate the following output −
pair = 8 9
The maximum and value= 8
Create a transparent border with CSS - GeeksforGeeks

30 Jan, 2020
In CSS, we can create a transparent border by using the border property in a nested div tag.
The steps to create this are:Step 1: Create a nested div tag.Step 2: Specify the outer div tag’s border-style to be solid and the border-width property can be of any desired size.Step 3: The size of the inner div tag is made smaller than the outer div tag.
Alternatively, we can specify all the individual properties by using the border shorthand property as shown in the example below.
Example 1: Create a transparent border in CSS using the above approach.
<!DOCTYPE html><html>  <head>    <style type="text/css">        h1 {            color: green;        }                  .outer {            width: 300px;            height: 300px;            margin: 10%;            border: 10px solid rgba(0, 0, 0, .4);            border-radius: 5px;        }                  .inner {            width: 270px;            height: 270px;            margin: auto;            margin-top: 3%;            text-align: center;            background: rgba(0, 0, 0, .4);            border-radius: 5px;            padding: 5px;        }    </style></head>  <body>    <div class="outer">        <div class="inner">            <h1>GeeksforGeeks</h1>        </div>    </div></body>  </html>
Output:
Another alternative approach would be to use a single div tag and to use the border-style and background-clip property to create the transparent border.
The steps to reproduce this are:Step 1: Create a div tag.Step 2: Specify the border-style property to be double to set two borders around the box.Step 3: Set the background-clip property to padding-box which clips the background color to the padding of the element.
Example 2: Create a transparent border in CSS using the alternative approach discussed above.
<!DOCTYPE html><html>  <head>    <style type="text/css">        h1 {            color: green;        }                  .trans_border {            width: 270px;            height: 270px;            margin: auto;            margin-top: 3%;            text-align: center;            border: 20px double rgba(0, 0, 0, .4);            background: rgba(0, 0, 0, .4);            background-clip: padding-box;            border-radius: 5px;            padding: 5px;        }    </style></head>  <body>    <div class="trans_border">        <h1>GeeksforGeeks</h1>    </div></body>  </html>
Output:
CSS-Misc
Picked
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to create footer to stay at the bottom of a Web page?
How to update Node.js and NPM to next version ?
Types of CSS (Cascading Style Sheet)
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
How to detect iOS device UDID, Name, Version, Model by programmatically?

Device UDID stands for Unique device identifier. Every iOS Device has UDID which is a sequence of 40 letters and numbers that is guaranteed to be specific to your device.
Device name is generally a name which will find in the device Setting→ General→ About.
iOS Version is the version on which your current iPhone runs, latest iOS version in 12.2
iOS Model describes whether the iOS device which user is using is an iPhone/iPad.
Now will see how to detect UDID, Name, Version and Model programatically.
Open Xcode → New Project and add the below code in ViewController’s viewDidLoad method.
override func viewDidLoad() {
   super.viewDidLoad()
   // Do any additional setup after loading the view, typically from a nib.
   let udid = UIDevice.current.identifierForVendor?.uuidString
   let name = UIDevice.current.name
   let version = UIDevice.current.systemVersion
   let modelName = UIDevice.current.model
   print(udid ?? "")    // D774EAE3F447445F9D5FE2B3B699ADB1
   print(name)          // iPhone XR
   print(version)       // 12.1
   print(modelName)     // iPhone
}
Difference Between One-Dimensional (1D) and Two-Dimensional (2D) Array

In this post, we will understand the difference between one dimensional array and two dimensional array.
It helps store a single list of elements that are similar data type.
It helps store a single list of elements that are similar data type.
The total bytes is calculates as the product of the datatype of variable array and the size of the array.
The total bytes is calculates as the product of the datatype of variable array and the size of the array.
type variable_name[ size ];
type variable_name [ ];
variable_name = new type[size];
int [ ] a = new int [10];
It helps store 'list of lists' or 'array of arrays' or 'array of one dimensional arrays', i.e nested arrays.
It helps store 'list of lists' or 'array of arrays' or 'array of one dimensional arrays', i.e nested arrays.
The total bytes is equivalent to product of datatype of variable array and size of first index and size of the second index.
The total bytes is equivalent to product of datatype of variable array and size of first index and size of the second index.
type variable_name[size1][size2];
type variable_name = new int[size1][size2];
type variable_name = new int[size1][size2];
Reason of runtime error in C/C++ - GeeksforGeeks

08 Feb, 2021

In this article, we will discuss the reason for the run-time error and its solution.
Runtime Error: A runtime error in a program is an error that occurs while the program is running after being successfully compiled. Below are some methods to identify the reason behind Runtime error:
Method 1: When the index of the array is assigned with a negative index it leads to invalid memory access during runtime error. Below is the C++ Program to illustrate the invalid memory access during run-time:
C++
 

 
 










// C++ program to illustrate invalid 
// memory access during run-time 
#include <iostream> 
using namespace std; 
  
// Global declaration 
int arr[5]; 
  
// Driver Code 
int main() 
{ 
    int answer = arr[-10]; 
    cout << answer; 
  
    return 0; 
} 






1736487104

Method 2: Sometimes Array or vector runs out of bound of their limits resulting in a runtime error. Below is the C++ program illustrating array runs out of bound:
C++
 

 
 










// C++ program to illustrate 
// array runs out of bound 
#include <iostream> 
using namespace std; 
  
// Driver Code 
int main() 
{ 
    long n; 
    n = 100000000000; 
  
    // 'n' is out of bound for 
    // the array limit 
    long a[n]; 
  
    cout << a[1] << " "; 
    return 0; 
} 






Output:

Explanation:
This is an error for index out of bound.
It can be resolved by using the size of the array/vector as within the limit.
Method 3: Some silly mistakes encountered while coding in hurry, sometimes leads to runtime error. Below is the C++ program illustrating runtime error by un-assigned variables:
C++
 

 
 










// C++ program to illustrate runtime 
// error by un-assigned variables 
#include <iostream> 
using namespace std; 
  
// Driver Code 
int main() 
{ 
    long long N; 
  
    // N is assigned garbage value 
    long arr[N]; 
  
    cin >> N; 
  
    for (int i = 0; i < N; i++) { 
        cin >> arr[i]; 
    } 
  
    for (int i = 0; i < N; i++) { 
        cout << arr[i] << " "; 
    } 
  
    return 0; 
} 






Output:

Explanation:
 The above program shows “Bad memory access (SIGBUS)” because:
Here, variable N is assigned a garbage value resulting in a runtime error.
Sometimes, since it depends on the compiler how it assigned the garbage value.
This can be resolved by declaring arr[N] after scanning the value for variable n and checking if it is the upper or lower limit of the array/vector index.

CPP-Basics


C++


C++ Programs

Writing code in comment? 
                                    Please use ide.geeksforgeeks.org, 
                                    generate link and share the link here.
                                
Operator Overloading in C++
Polymorphism in C++
Friend class and function in C++
Sorting a vector in C++
Iterators in C++ STL
Header files in C/C++ and its uses
C++ Program for QuickSort
How to return multiple values from a function in C or C++?
Program to print ASCII Value of a character
CSV file management using C++
Check if a String is whitespace, empty ("") or null in Java

Let’s say the following is our string.
String myStr = "";
Now, we will check whether the above string is whitespace, empty ("") or null.
if(myStr != null && !myStr.isEmpty() && !myStr.trim().isEmpty()) {
   System.out.println("String is not null or not empty or not whitespace");
} else {
   System.out.println("String is null or empty or whitespace");
}
The following is an example that checks for an empty string.
 Live Demo
public class Demo {
   public static void main(String[] args) {
      String myStr = "";
      if(myStr != null && !myStr.isEmpty() && !myStr.trim().isEmpty()) {
         System.out.println("String is not null or not empty or not whitespace");
      } else {
         System.out.println("String is null or empty or whitespace");
      }
   }
}
String is null or empty or whitespace
Let us see another example that checks for whitespace input.
 Live Demo
public class Demo {
   public static void main(String[] args) {
      String myStr = " ";
      if(myStr != null && !myStr.isEmpty() && !myStr.trim().isEmpty()) {
         System.out.println("String is not null or not empty or not whitespace");
      } else {
         System.out.println("String is null or empty or whitespace");
      }
   }
}
String is null or empty or whitespace
Compare array of objects - JavaScript

We have two arrays of objects like these −
const blocks = [
   { id: 1 },
   { id: 2 },
   { id: 3 },
   { id: 4 },
]
const containers = [
   { block: { id: 1 } },
   { block: { id: 2 } },
   { block: { id: 3 } },
]
We are required to write a function that checks each object of blocks array with the block key of each object of containers array and see if there exists any id in blocks array that is not present in the containers array. If so, we return false, otherwise we return true.
Let’s write the code −
const blocks = [
   { id: 1 },
   { id: 2 },
   { id: 3 },
   { id: 4 },
]
const containers = [
   { block: { id: 1 } },
   { block: { id: 2 } },
   { block: { id: 3 } },
]
const checkProperty = (first, second) => {
   const findInContainers = id => {
      for(let i = 0; i < second.length; i++){
         if(second[i].block.id === id){
            return true;
         };
      };
      return false;
   };
   for(let i = 0; i < first.length; i++){
      if(!findInContainers(first[i].id)){
         return false;
      };
   };
   return true;
};
console.log(checkProperty(blocks, containers));
Following is the output in the console −
false
C++ Program to Implement Bucket Sort

In the Bucket Sorting technique, the data items are distributed of a set of buckets. Each bucket can hold similar type of data. After distributing, each bucket is sorted using another sorting algorithm. After that all elements are gathered into the main list to get the sorted form.
Time Complexity: O(n + k) for best case and average case and O(n2 ) for worst case.
Time Complexity: O(n + k) for best case and average case and O(n2 ) for worst case.
Space Complexity: O(nk) for worst case
Space Complexity: O(nk) for worst case
Input − A list of unsorted data: 0.25 0.36 0.58 0.41 0.29 0.22 0.45 0.79 0.01 0.69
Output − Array after Sorting: 0.01 0.22 0.25 0.29 0.36 0.41 0.45 0.58 0.69 0.79
Input: An array of data, and the total number in the array
Output: The sorted Array
Begin
   for i := 0 to size-1 do
      insert array[i] into the bucket index (size * array[i])
   done
   for i := 0 to size-1 do
      sort bucket[i]
   done
   for i := 0 to size -1 do
      gather items of bucket[i] and put in array
   done
End
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
void display(float *array, int size) {
   for(int i = 0; i<size; i++)
      cout << array[i] << " ";
   cout << endl;
}
void bucketSort(float *array, int size) {
   vector<float> bucket[size];
   for(int i = 0; i<size; i++)  {          //put elements into different buckets
      bucket[int(size*array[i])].push_back(array[i]);
   }
   for(int i = 0; i<size; i++) {
      sort(bucket[i].begin(), bucket[i].end());       //sort individual vectors
   }
   int index = 0;
   for(int i = 0; i<size; i++) {
      while(!bucket[i].empty()) {
         array[index++] = *(bucket[i].begin());
         bucket[i].erase(bucket[i].begin());
      }
   }
}
int main() {
   int n;
   cout << "Enter the number of elements: ";
   cin >> n;
   float arr[n];     //create an array with given number of elements
   cout << "Enter elements:" << endl;
   for(int i = 0; i<n; i++) {
      cin >> arr[i];
   }
   cout << "Array before Sorting: ";
   display(arr, n);
   bucketSort(arr, n);
   cout << "Array after Sorting: ";
   display(arr, n);
}
Enter the number of elements: 10
Enter elements:
0.25 0.36 0.58 0.41 0.29 0.22 0.45 0.79 0.01 0.69
Array before Sorting: 0.25 0.36 0.58 0.41 0.29 0.22 0.45 0.79 0.01
0.69
Array after Sorting: 0.01 0.22 0.25 0.29 0.36 0.41 0.45 0.58 0.69
0.79