code-rag-bench/online-tutorials huggingface dataset:
SQL Query to Compare Two Strings

14 Sep, 2021
SQL stands for Structured Query Language. It is used to communicate with the database. There are some standard SQL commands like ‘select’, ‘delete’, ‘alter’ etc. To compare two strings in SQL Server, there is no direct way. In this article, we will learn how to compare two strings in an MS SQL server and we will provide some examples.
A string function is a function that takes a string value as an input regardless of the data type of the returned value. In SQL Server, there are many built-in string functions that can be used by developers.
We can compare strings by using the IF-ELSE statement.
Syntax:
 IF Boolean_expression    
    { sql_statement | statement_block }    
[ ELSE    
    { sql_statement | statement_block } ]  
We can declare variables easily by using the keyword DECLARE before the variable name. By default, the local variable starts with @.
Syntax:
 DECLARE @variable_name datatype;
We can assign value to the variables using the SET keyword.
Syntax: 
SET @variable_name;
Example 1:
Query:
DECLARE @Name1 VARCHAR(30), @Name2 VARCHAR(20);
Set @Name1='geeks';
Set @Name2='geeks';
If @Name1=@Name2 Select 'match' else Select 'not match';
Output:
The above example shows the string comparison and returns the result as a ‘match’ because both strings are the same.
Example 2:
Query:
DECLARE @Name1 VARCHAR(30), @Name2 VARCHAR(20);
Set @Name1='geeks';
Set @Name2='geeksforgeeks';
If @Name1=@Name2 Select 'match' else Select 'not match';
Output:
The above example shows the string comparison and returns the result as a ‘not match’ because both strings are not the same.
Blogathon-2021
Picked
SQL-Query
Blogathon
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
R - Next Statement

The next statement in R programming language is useful when we want to skip the current iteration of a loop without terminating it. On encountering next, the R parser skips further evaluation and starts next iteration of the loop.
The basic syntax for creating a next statement in R is −
next

v <- LETTERS[1:6]
for ( i in v) {
   
   if (i == "D") {
      next
   }
   print(i)
}
When the above code is compiled and executed, it produces the following result −
Python | Numpy matrix.copy()

12 Apr, 2019
With the help of Numpy matrix.copy() method, we can make a copy of all the data elements that is present in matrix. If we change any data element in the copy, it will not affect the original matrix.
Syntax : matrix.copy()
Return : Return copy of matrix
Example #1 :In this example we can see that with the help of matrix.copy() method we are making the copy of an elements in different matrix.
# import the important module in pythonimport numpy as np         # make matrix with numpygfg = np.matrix('[1, 2, 3]')         # applying matrix.copy() methodgeeks = gfg.copy()   print(geeks)
[[1 2 3]]

Example #2 :
# import the important module in pythonimport numpy as np         # make a matrix with numpygfg = np.matrix('[1, 2, 3; 4, 5, 6]')         # applying matrix.copy() methodgeeks = gfg.copy()   print(geeks)
[[1 2 3]
 [4 5 6]]

Python numpy-Matrix Function
Python-numpy
Python
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
Python program to convert time from 12 hour to 24 hour format

02 May, 2018
Given a time in 12-hour AM/PM format, convert it to military (24-hour) time.
Note : Midnight is 12:00:00 AM on a 12-hour clock and 00:00:00 on a 24-hour clock. Noon is 12:00:00 PM on 12-hour clock and 12:00:00 on 24-hour clock.
Examples :
Input : 11:21:30 PM
Output : 23:21:30

Input : 12:12:20 AM
Output : 00:12:20

Approach : Whether the time format is 12 hours or not, can be found out by using list slicing. Check if last two elements are PM, then simply add 12 to them. If AM, then don’t add. Remove AM/PM from the updated time.
 Below is the implementation :
# Python program to convert time# from 12 hour to 24 hour format  # Function to convert the date formatdef convert24(str1):          # Checking if last two elements of time    # is AM and first two elements are 12    if str1[-2:] == "AM" and str1[:2] == "12":        return "00" + str1[2:-2]              # remove the AM        elif str1[-2:] == "AM":        return str1[:-2]          # Checking if last two elements of time    # is PM and first two elements are 12       elif str1[-2:] == "PM" and str1[:2] == "12":        return str1[:-2]              else:                  # add 12 to hours and remove PM        return str(int(str1[:2]) + 12) + str1[2:8]  # Driver Code        print(convert24("08:05:45 PM"))
Output :
20:05:45
date-time-program
Python
Python Programs
School Programming
Technical Scripter
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()
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
jQuery - Widget Tab

The Widget Tab function can be used with widgets in JqueryUI.tab is used to swap between content that is broken into logical sections.
Here is the simple syntax to use tab −
$( "#tabs" ).tabs();

Following is a simple example showing the usage of Tab −
<!doctype html>
<html lang = "en">
   <head>
      <meta charset = "utf-8">
      <title>jQuery UI Tabs - Default functionality</title>
		
      <link rel = "stylesheet" 
         href = "//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
			
      <script type = "text/javascript" 
         src = "https://www.tutorialspoint.com/jquery/jquery-3.6.0.js"></script>
		
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js">
      </script>
  
      <script>
         $(function() {
            $( "#tabs" ).tabs();
         });
      </script>
   </head>
	
   <body>
      <div id = "tabs">
        <ul>
            <li><a href = "#tabs-1">Android</a></li>
            <li><a href = "#tabs-2">CSS</a></li>
            <li><a href = "#tabs-3">AngularJS</a></li>
         </ul>
			
         <div id = "tabs-1">
            <p>Android is an open source and Linux-based operating system 
               for mobile devices such as smartphones and tablet computers. 
               Android was developed by the Open Handset Alliance, led by Google, 
               and other companies.</p>
         </div>
			
         <div id = "tabs-2">
            <p>CSS is the acronym for "Cascading Style Sheet". This
               tutorial covers both the versions CSS1,CSS2 and CSS3, and gives a
               complete understanding of CSS,starting from its basics to advanced 
               concepts.</p>
         </div>
			
         <div id = "tabs-3">
            <p>AngularJS is a very powerful JavaScript library. It is used
               in Single Page Application (SPA) projects. It extends HTML DOM 
               with additional attributes and makes it more responsive to user 
               actions. AngularJS is open source,completely free, and used by
               thousands of developers around the world. It is licensed under 
               the Apache license version 2.0.</p>
         </div>
      </div>
   </body>
</html>
This will produce following result −
Android
CSS
AngularJS
Android is an open source and Linux-based operating system for mobile devices such as smartphones and tablet computers. Android was developed by the Open Handset Alliance, led by Google, and other companies.
CSS is the acronym for "Cascading Style Sheet". This tutorial covers both the versions CSS1,CSS2 and CSS3, and gives a complete understanding of CSS, starting from its basics to advanced concepts.
AngularJS is a very powerful JavaScript library. It is used in Single Page Application (SPA) projects. It extends HTML DOM with additional attributes and makes it more responsive to user actions. AngularJS is open source, completely free, and used by thousands of developers around the world. It is licensed under the Apache license version 2.0.
How to get HTML code of a WebElement in Selenium?

We can get the html code of a webelement with the help of Selenium webdriver. We can obtain the innerHTML attribute to get the HTML content of the web element.
The innerHTML is an attribute of a webelement which is equal to the content that is present between the starting and ending tag. The getAttribute method is used for this and innerHTML is passed as an argument to the method.
String s = element.getAttribute('innerHTML');
Let us see the below html code of an element. The innerHTML of the element shall be < You are browsing the best resource for <b>Online Education</b>.
Code Implementation
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.By;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebElement;
public class HtmlCodeElement{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      driver.get("https://www.tutorialspoint.com/index.htm");
      // identify element
      WebElement l=driver.findElement(By.cssSelector("h4"));
      // obtain the innerHTML with getAttribute method
      String s = l.getAttribute("innerHTML");
      System.out.println("HTML code of element: " +s);
      driver.close();
   }
}
CHARINDEX() function SQL Server

22 Dec, 2020
CHARINDEX() :This function in SQL Server helps to return the position of a substring within a given string. The searching performed in this function is NOT case-sensitive.
Syntax :
CHARINDEX(substring, string, [starting_position]
Parameters :This function accepts 3 parameters.
substring –The substring that we are searching for. It has a limit of 8, 000 characters.string –The string in which searching takes place.starting_position –The position from where searching will take place. It’s an optional parameter.
substring –The substring that we are searching for. It has a limit of 8, 000 characters.
string –The string in which searching takes place.
starting_position –The position from where searching will take place. It’s an optional parameter.
Returns :
The function will return the position of a substring within a given string.
If the substring is not found in the string, then the function will return 0.
Applicable to the following versions :
SQL Server 2017
SQL Server 2016
SQL Server 2014
SQL Server 2012
SQL Server 2008 R2
SQL Server 2008
SQL Server 2005
Example-1 :Searching a character using the CHARINDEX() function.
SELECT CHARINDEX('k', 'GeeksforGeeks') 
As Found ;
Output :
Example-2 :Searching a substring using the CHARINDEX() function.
SELECT CHARINDEX('fully', 'Life is a journey so live it fully') 
As Found ;
Output :
Example-3 :If the substring doesn’t match with the given string.
SELECT CHARINDEX
('python', 'Geeks for geeks is a well known computer science website') 
As Found ;
Output :
Example-4 :Use of “starting_position” parameter in CHARINDEX() function.
SELECT CHARINDEX
('for', 'Love for all, Hate for none', 10) 
As Found ;
Output :
Example-5 :Showing that CHARINDEX() function is case-insensitive.
SELECT  
CHARINDEX('Bear', 'Bob likes Bear, beer likes bob') 
As Found1,
CHARINDEX('bear', 'Bob likes Bear, beer likes bob') 
As Found2 ;
Output :
Example-6 :Making the function case-sensitive using the COLLATE clause.
SELECT CHARINDEX
('A', 'There is always a need to Develop' COLLATE Latin1_General_CS_AS) 
As Found;
Output :The function is now following a case-sensitive search, and since it doesn’t contain “A”, so the function will return 0.
DBMS-SQL
SQL-Server
Technical Scripter 2020
SQL
Technical Scripter
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Sub queries in From Clause
Window functions in SQL
What is Temporary Table in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL using Python
SQL Query to Convert VARCHAR to INT
RANK() Function in SQL Server
How to Import JSON Data into SQL Server?
SQL Query to Compare Two Dates
How to create static classes in PHP ?

22 Jul, 2021
A class is a user-defined data type that holds its own data members and member functions that can be accessed and used by creating one or more instances of that class. Every time a class is instantiated, the values that it holds are different and unique to the particular instance or object and not to that class. Static Classes brings forth a property wherein a class itself holds values that remain the same and aren’t unique. Another property of Static Classes is that we can do the aforementioned without having to create an instance of the class.
How to create a static class? It’s fairly simple. The variables and methods that are declared and defined within a class are to be declared as static with the use of static keyword, so that they can be used without instantiating the class first. An important point to note here is that, since this means a class variable can be accessed without a specific instance, it also means that there will only be one version of this variable. Another consequence is that a static method cannot access non-static variables and methods since these require an instance of the class.
To access the static class and it’s method use the following syntax:  
 ClassName::MethodName();
Example 1: The following code returns the current date without instantiating the class Date. In this case, the format of the date and not the actual date remains the same.
PHP
<?php class Date {     public static $date_format1 = 'F jS, Y';    public static $date_format2 = 'Y/m/d H:i:s';    public static function format_date($unix_timestamp) {        echo date(self::$date_format1, $unix_timestamp), "\n";        echo date(self::$date_format2, $unix_timestamp);    }} echo Date::format_date(time());?>
Output:
April 30th, 2020
2020/04/30 10:48:36
Example 2: The following code checks whether the string is valid or not. It is valid if it’s length is equal to 13. 
PHP
<?php class geeks {     public static $x = 13;     public static function isValid($s) {        if(strlen($s) == self::$x )            return true;        else            return false;    }} $s1 = "geeksforgeeks";if(geeks::isValid($s1))    echo "String is valid! \n";else    echo "String is NOT valid! \n"; $s2 = "geekforgeek"; if(geeks::isValid($s2))    echo "String is valid!\n ";else    echo "String is NOT valid! \n";?>
Output: 
String is valid!
String is NOT valid!
 
sumitgumber28
PHP-Misc
Picked
PHP
PHP Programs
Web Technologies
Web technologies Questions
Write From Home
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to convert array to string in PHP ?
PHP | Converting string to Date and DateTime
Comparing two dates in PHP
How to get parameters from a URL string in PHP?
Split a comma delimited string into an array in PHP
How to convert array to string in PHP ?
How to call PHP function on the click of a Button ?
Comparing two dates in PHP
How to get parameters from a URL string in PHP?
Split a comma delimited string into an array in PHP
How to read form data using JSP via POST Method?

Below is the main.jsp JSP program to handle the input given by web browser using the GET or the POST methods.
Infact there is no change in the above JSP because the only way of passing parameters is changed and no binary data is being passed to the JSP program. File handling related concepts will be explained in a separate chapter where we need to read the binary data stream.
<html>
   <head>
      <title>Using GET and POST Method to Read Form Data</title>
   </head>
   <body>
      <center>
         <h1>Using POST Method to Read Form Data</h1>
         <ul>
            <li><p><b>First Name:</b>
               <%= request.getParameter("first_name")%>
               </p></li>
            <li><p><b>Last Name:</b>
               <%= request.getParameter("last_name")%>
               </p></li>
         </ul>
      <center>
   </body>
</html>
Following is the content of the Hello.htm file −
<html>
   <body>
      <form action = "main.jsp" method = "POST">
         First Name: <input type = "text" name = "first_name">
         <br />
         Last Name: <input type = "text" name = "last_name" />
         <input type = "submit" value = "Submit" />
      </form>
   </body>
</html>
Let us now keep main.jsp and hello.htm in <Tomcat-installationdirectory>/webapps/ROOT directory. When you access http://localhost:8080/Hello.htm, you will receive the following output.
Try to enter the First and the Last Name and then click the submit button to see the result on your local machine where tomcat is running.
Based on the input provided, you will receive similar results as in the above examples.
Program to find sum of first n natural numbers in C++

In this tutorial, we will be discussing a program to find sum of first n natural numbers.
For this we will be provided with an integer n. Our task is to add up, find the sum of the first n natural numbers and print it out.
 Live Demo
#include<iostream>
using namespace std;
//returning sum of first n natural numbers
int findSum(int n) {
   int sum = 0;
   for (int x=1; x<=n; x++)
      sum = sum + x;
   return sum;
}
int main() {
   int n = 5;
   cout << findSum(n);
   return 0;
}
15
How to convert RGB image to HSV using Java OpenCV library?

The cvtColor() method of the Imgproc class changes/converts the color of the image from one to another. This method accepts three parameters −
src − A Matrix object representing source.
src − A Matrix object representing source.
dst − A Matrix object representing the destination.
dst − A Matrix object representing the destination.
code − An integer value representing the color of the destination image.
code − An integer value representing the color of the destination image.
To convert an RGB image to HSV you need to pass Imgproc.COLOR_RGB2HSV as the third parameter to this method.
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
public class RGB2HSV {
   public static void main(String args[]) throws Exception {
      //Loading the OpenCV core library
      System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
      //Reading the image
      Mat src = Imgcodecs.imread("D:\\images\\ladakh.jpg");
      //Creating the empty destination matrix
      Mat dst = new Mat();
      //Converting the image to gray scale
      Imgproc.cvtColor(src, dst, Imgproc.COLOR_RGB2HSV);
      //Instantiating the Imagecodecs class
      Imgcodecs imageCodecs = new Imgcodecs();
      //Writing the image
      imageCodecs.imwrite("D:\\images\\colorTOhsv.jpg", dst);
      System.out.println("Image Saved");
   }
}
Bigram formation from given a Python list

A bigram is formed by creating a pair of words from every two consecutive words from a given sentence. In python, this technique is heavily used in text analytics. Below we see two approaches on how to achieve this.
Using these two methods we first split the sentence into multiple words and then use the enumerate function to create a pair of words from consecutive words.
 Live Demo
list = ['Stop. look left right. go']
print ("The given list is : \n" + str(list))
# Using enumerate() and split() for Bigram formation
output = [(k, m.split()[n + 1]) for m in list for n, k in enumerate(m.split()) if n < len(m.split()) - 1]
print ("Bigram formation from given list is: \n" + str(output))
Running the above code gives us the following result −
The given list is :
['Stop. look left right. go']
Bigram formation from given list is:
[('Stop.', 'look'), ('look', 'left'), ('left', 'right.'), ('right.', 'go')]
We can also create the biagram using zip and split function. The zip() function puts tithers the words in sequence which are created from the sentence using the split().
 Live Demo
list = ['Stop. look left right. go']
print ("The given list is : \n" + str(list))
# Using zip() and split() for Bigram formation
output = [m for n in list for m in zip(n.split(" ")[:-1], n.split(" ")[1:])]
print ("Bigram formation from given list is: \n" + str(output))
Running the above code gives us the following result −
The given list is :
['Stop. look left right. go']
Bigram formation from given list is:
[('Stop.', 'look'), ('look', 'left'), ('left', 'right.'), ('right.', 'go')]
Python Program to Find the Total Sum of a Nested List Using Recursion

When it is required to find the total sum of a nest list using the recursion technique, a user defined method is used, that takes the list as a parameter.
The recursion computes output of small bits of the bigger problem, and combines these bits to give the solution to the bigger problem.
A list can be used to store heterogeneous values (i.e data of any data type like integer, floating point, strings, and so on).
Below is a demonstration for the same −
 Live Demo
def recursion_sum(my_list):
   my_total = 0
   for elem in my_list:
      if (type(elem) == type([])):
         my_total = my_total + recursion_sum(elem)
      else:
         my_total = my_total + elem
   return my_total
my_list = [[2,3], [7,9], [11,45], [78,98]]
print("The list elements are :")
print(my_list)
print( "The sum is :")
print(recursion_sum(my_list))
The list elements are :
[[2, 3], [7, 9], [11, 45], [78, 98]]
The sum is :
253
A method named ‘recursion_sum’ is defined, with list as a paramteter.
Initially, a variable is assigned to 0.
The elements in the list are iterated over, and if their type matches, the elements in the list are added, and the method is called again.
Otherwise, the elements are just added to a variable.
This variable is displayed as output on the console.
Outside the function, the below operations take place −
The nested list is defined, and is displayed on the console.
The method is called by passing this list as a parameter.
The output is displayed on the console.
Thread Safe Concurrent Collection in C#

The .NET Framework 4 brought the System.Collections.Concurrent namespace. This has several collection classes that are thread-safe and scalable. These collections are called concurrent collections because they can be accessed by multiple threads at a time.
The following are the concurrent collection in C# −
Let us see how to work with ConcurrentStack<T> that is a thread-safe last in-first out (LIFO) collection.
Create a ConcurrentStack.
ConcurrentStack<int> s = new ConcurrentStack<int>();
Add elements
s.Push(1);
s.Push(2);
s.Push(3);
s.Push(4);
s.Push(5);
s.Push(6);
Let us see an example
 Live Demo
using System;
using System.Collections.Concurrent;

class Demo{
   static void Main (){
      ConcurrentStack s = new ConcurrentStack();

      s.Push(50);
      s.Push(100);
      s.Push(150);
      s.Push(200);
      s.Push(250);
      s.Push(300);

      if (s.IsEmpty){
         Console.WriteLine("The stack is empty!");
      }

      else {
         Console.WriteLine("The stack isn't empty");
      }
   }
}
How can we create and use a MySQL trigger?

For creating a new trigger, we need to use the CREATE TRIGGER statement. Its syntax is as follows −
CREATE TRIGGER trigger_name trigger_time trigger_event
ON table_name
FOR EACH ROW
BEGIN
...
END;
Here,
Trigger_name is the name of the trigger which must be put after the CREATE TRIGGER statement. The naming convention for trigger_name can be like [trigger time]_[table name]_[trigger event]. For example, before_student_update or after_student_insert can be the name of the trigger.
Trigger_time is the time of trigger activation and it can be BEFORE or AFTER. We must have to specify the activation time while defining a trigger. We must use BEFORE if we want to process action prior to the change made on the table and AFTER if we want to process action post to the change made on the table.
Trigger_event can be INSERT, UPDATE, or DELETE. This event causes the trigger to be invoked. A trigger only can be invoked by one event. To define a trigger that is invoked by multiple events, we have to define multiple triggers, one for each event.
Table_name is the name of the table. Actually, a trigger is always associated with a specific table. Without a table, a trigger would not exist hence we have to specify the table name after the ‘ON’ keyword.
BEGIN...END is the block in which we will define the logic for the trigger.
Suppose we want to apply trigger on the table Student_age which is created as follows −
mysql> Create table Student_age(age INT, Name Varchar(35));
Query OK, 0 rows affected (0.80 sec)
Now, the following trigger will automatically insert the age = 0 if someone tries to insert age < 0.
mysql> DELIMITER //
mysql> Create Trigger before_inser_studentage BEFORE INSERT ON student_age FOR EACH ROW
BEGIN
IF NEW.age < 0 THEN SET NEW.age = 0;
END IF;
END //
Query OK, 0 rows affected (0.30 sec)
Now, for invoking this trigger, we can use the following statements −
mysql> INSERT INTO Student_age(age, Name) values(30, 'Rahul');
Query OK, 1 row affected (0.14 sec)

mysql> INSERT INTO Student_age(age, Name) values(-10, 'Harshit');
Query OK, 1 row affected (0.11 sec)

mysql> Select * from Student_age;
+------+---------+
| age  | Name    |
+------+---------+
| 30   | Rahul   |
| 0    | Harshit |
+------+---------+
2 rows in set (0.00 sec)
The above result set shows that on inserting the negative value in the table will lead to insert 0 by a trigger.
The above was the example of a trigger with trigger_event as INSERT and trigger_time are BEFORE.
Coroutines in C/C++

In this tutorial, we will be discussing a program to understand coroutines in C/C++.
Coroutines are control instructions which switch the execution control between two routines which returning any of them.
 Live Demo
#include<stdio.h>
int range(int a, int b){
   static long long int i;
   static int state = 0;
   switch (state){
   case 0:
      state = 1;
      for (i = a; i < b; i++){
         return i;
      //returning control
      case 1:; //resuming control
      }
   }
   state = 0;
   return 0;
}
int main(){
   int i;
   for (; i=range(1, 5);)
      printf("control at main :%d\n", i);
   return 0;
}
control at main :1
control at main :2
control at main :3
control at main :4
What are conditional attributes in C#?

Attributes are used for adding metadata, such as compiler instruction and other information such as comments, description, methods, and classes to a program.
This predefined attribute marks a conditional method whose execution depends on a specified preprocessing identifier.
It causes conditional compilation of method calls, depending on the specified value such as Debug or Trace. For example, it displays the values of the variables while debugging a code.
The following is the syntax of conditional attributes −
[Conditional(
   conditionalSymbol
)]
Let us see how to work with Conditional attributes −
 Live Demo
#define DEBUG
using System;
using System.Diagnostics;

public class Myclass {
   [Conditional("DEBUG")]

   public static void Message(string msg) {
      Console.WriteLine(msg);
   }
}

class Test {
   static void function1() {
      Myclass.Message("In Function 1");
      function2();
   }

   static void function2() {
      Myclass.Message("In Function 2");
   }

   public static void Main() {
      Myclass.Message("In Main function");
      function1();
      Console.ReadKey();
   }
}
In Main function
In Function 1
In Function 2
Remove borders from an element in Bootstrap

Use the border-0 class in Bootstrap 4 to remove all borders from an element in Bootstrap 4 −
<div class="mystyle border no-border">
  no border
</div>
Above, we have the div class to no-border class and this allow us to remove the borders from the element.
Let us see an example to implement the border-0 class in Bootstrap −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
   <style>
   .mystyle {
     width: 120px;
     height: 100px;
     margin: 10px;
     background: maroon;
   }
   </style>
  </head>
<body>
  <div class="container">
    <h4>Rectangle</h4>
    <div class="mystyle border no-border">no border</div>
  </div>
</body>
</html>
Increasing the space for X-axis labels in Matplotlib

To increase the space for X-axis labels in Matplotlib, we can use the spacing variable in subplots_adjust() method's argument.
Set the figure size and adjust the padding between and around the subplots.
Set the figure size and adjust the padding between and around the subplots.
Create a new figure or activate an existing figure using figure() method.
Create a new figure or activate an existing figure using figure() method.
Create x and y data points using numpy.
Create x and y data points using numpy.
Plot x and y using plot() method.
Plot x and y using plot() method.
Put xlabel using xlabel() method with LaTex expression.
Put xlabel using xlabel() method with LaTex expression.
Use subplots_adjust() method to increase or decrease the space for X-axis labels
Use subplots_adjust() method to increase or decrease the space for X-axis labels
To display the figure, use show() method.
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
fig = plt.figure()
x = np.linspace(-2, 2, 10)
y = np.exp(x)
plt.plot(x, y)
plt.xlabel("$\\bf{y=e^{x}}$")
spacing = 0.100
fig.subplots_adjust(bottom=spacing)
plt.show()
HTML | <link> sizes Attribute - GeeksforGeeks

19 Oct, 2020
The HTML link sizes Attribute is used to specify the sizes of the icon for visual media and it only works when rel=”icon”. It is a read-only Property.
Syntax:
<link sizes="HeightxWidth | any">
Attribute Values
HeightxWidth It is used to specify the one or more sizes of a linked icon. The value of the height and the width are separated by an “x” or “X”.For Example:<link rel=”icon” href=”geeks.png” sizes=”16×16′′ type=”image/png”> (1 size)<link rel=”icon” href=”sudo.png” sizes=”16×16 32×32′′ type=”image/png”> (2 sizes)
For Example:
<link rel=”icon” href=”geeks.png” sizes=”16×16′′ type=”image/png”> (1 size)<link rel=”icon” href=”sudo.png” sizes=”16×16 32×32′′ type=”image/png”> (2 sizes)
<link rel=”icon” href=”geeks.png” sizes=”16×16′′ type=”image/png”> (1 size)
<link rel=”icon” href=”sudo.png” sizes=”16×16 32×32′′ type=”image/png”> (2 sizes)
any: Specifies that the icon is scalable (like an SVG image).Examples: <link rel=”icon” href=”icon.svg” sizes=”any” type=”image/svg+xml”> (any size).
Example:
<!DOCTYPE html><html>  <head>    <link id="linkid"          rel="stylesheet"           type="text/css"          href="styles.css"           sizes="16*16"></head>  <body style="text-align:center;">    <h1>GeeksForGeeks</h1>    <h2>HTML <Link> sizes Attribute</h2></body>  </html>
Output:
Supported Browsers: No browser supported by HTML <link> sizes Attribute.
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
arorakashish0911
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
Design a web page using HTML and CSS
Angular File Upload
Form validation using jQuery
DOM (Document Object Model)
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
HTTP headers | X-XSS-Protection - GeeksforGeeks

10 Jan, 2022
HTTP headers are used to pass additional information with HTTP response or HTTP requests. The X-XSS-Protection in HTTP header is a feature that stops a page from loading when it detects XSS attacks. This feature is becoming unnecessary with increasing content-security-policy of sites.
XSS attacks: The XSS stands for Cross-site Scripting. In this attack, the procedure is to bypass the Same-origin policy into vulnerable web applications. When the HTML code generated dynamically and the user input is not sanitized only then the attacker can use this attack. In this attack, an attacker can insert his own HTML code into the webpage which will be not detected by the browsers. For his own HTML code attacker can easily gain access to the database and the cookies. To stop this kind of attacks X-XSS Protection was used in previous days.
Syntax: 
X-XSS-Protection: directive
Type of XSS Attack: Cross site scripting attacks are broadly classified into two categories.  
Server XSS: In this type of attack hacker attaches untrusted data with the HTML response. In this case, vulnerability is present at the server end and the browser just runs the script present in the response.
Client XSS: In this type of XSS attack unsafe javascript is used to update the DOM data. If we add javascript code in DOM with a javascript call, such a javascript call is called an unsafe javascript call.
Directives: In this headers filed there are four directives:  
0: It disables the X-XSS-Protection.
1: It is the by default directive and enables the X-XSS-Protection.
1; mode=block: It enables the X-XSS-Protection. If the browser detects an attack, it will not render the page.
1; report=<reporting-URI>: It enables the X-XSS-Protection. If the Cross-site Scripting attack detected then the page will be sanitizes and reported by report-uri directive.
Example 1: Block pages from loading when they detect reflected Cross-site Scripting attacks:  
HTML
// It enable the protectionX-XSS-Protection: 1; mode=block   // It disable the protectionX-XSS-Protection: 0
Example 2: This will work on an apache server. 
HTML
<IfModule mod_headers.c>   Header set X-XSS-Protection "1; mode=block" </IfModule>
Example 3: This will work on Nginx server. 
html
add_header "X-XSS-Protection" "1; mode=block";
Supported Browsers: The browsers supported by HTTP headers X-XSS-Protection are listed below: 
Google Chrome
Internet Explorer
Safari
Opera
 
rkbhola5
HTTP-headers
Picked
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
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
How to apply style to parent if it has child with CSS?
Difference Between PUT and PATCH Request
How to execute PHP code using command line ?
REST API (Introduction)
How to redirect to another page in ReactJS ?
Time complexity of insertion sort when there are O(n) inversions? - GeeksforGeeks

20 Dec, 2016
What is an inversion?Given an array arr[], a pair arr[i] and arr[j] forms an inversion if arr[i] < arr[j] and i > j. For example, the array {1, 3, 2, 5} has one inversion (3, 2) and array {5, 4, 3} has inversions (5, 4), (5, 3) and (4, 3). We have discussed a merge sort based algorithm to count inversions
What is the time complexity of Insertion Sort when there are O(n) inversions?Consider the following function of insertion sort.
/* Function to sort an array using insertion sort*/void insertionSort(int arr[], int n){   int i, key, j;   for (i = 1; i < n; i++)   {       key = arr[i];       j = i-1;          /* Move elements of arr[0..i-1], that are          greater than key, to one position ahead          of their current position */       while (j >= 0 && arr[j] > key)       {           arr[j+1] = arr[j];           j = j-1;       }       arr[j+1] = key;   }}
If we take a closer look at the insertion sort code, we can notice that every iteration of while loop reduces one inversion. The while loop executes only if i > j and arr[i] < arr[j]. Therefore total number of while loop iterations (For all values of i) is same as number of inversions. Therefore overall time complexity of the insertion sort is O(n + f(n)) where f(n) is inversion count. If the inversion count is O(n), then the time complexity of insertion sort is O(n).
In worst case, there can be n*(n-1)/2 inversions. The worst case occurs when the array is sorted in reverse order. So the worst case time complexity of insertion sort is O(n2).
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
Insertion Sort
inversion
Sorting
Sorting
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
std::sort() in C++ STL
Time Complexities of all Sorting Algorithms
Radix Sort
Merge two sorted arrays
Chocolate Distribution Problem
Count Inversions in an array | Set 1 (Using Merge Sort)
Sort an array of 0s, 1s and 2s
k largest(or smallest) elements in an array
Python Program for Bubble Sort
sort() in Python
GATE | GATE-CS-2016 (Set 2) | Question 22 - GeeksforGeeks

12 Aug, 2021
The value printed by the following program is
void f(int* p, int m){    m = m + 5;    *p = *p + m;    return;}void main(){    int i=5, j=10;    f(&i, j);    printf("%d", i+j);}
(A) 10(B) 20(C) 30(D) 40Answer: (C)Explanation:
#include"stdio.h"

void f(int* p, int m)
{
    m = m + 5;
    *p = *p + m;
    return;
}
int main()
{
    int i=5, j=10;
    f(&i, j);
    printf("%d", i+j);
}

For i, address is passed. For j, value is passed. So in function f, p will contain address of i and m will contain value 10. Ist statement of f() will change m to 15. Then 15 will be added to value at address p. It will make i = 5+15 = 20. j will remain 10. print statement will print 20+10 = 30. So answer is (C).
YouTubeGeeksforGeeks GATE Computer Science16.4K subscribersGATE PYQs 2016 with Shubham Agrawal | GeeksforGeeks GATE CSEWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:0046:25 / 1:07:54•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=Key2RKhzRGY" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
GATE-CS-2016 (Set 2)
GATE-GATE-CS-2016 (Set 2)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE MOCK 2017 | Question 24
GATE | GATE-CS-2006 | Question 47
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
SQL Query to Find the Highest Salary of Each Department - GeeksforGeeks

07 Apr, 2021
Structured Query Language or SQL is a standard Database language that is used to create, maintain and retrieve the data from relational databases like MySQL, Oracle, etc. In this article, we will be using the Microsoft SQL Server.
Here we are going to see how to get the highest salary of each department. Here, we will first create a database named “geeks” then we will create a table “department” in that database. After, that we will execute our query on that table.
Creating Database:
CREATE geeks;
To use this database:
USE geeks;
This is our table in the geeks database:
CREATE TABLE department(
    ID int,
    SALARY int,
    NAME Varchar(20),
    DEPT_ID Varchar(255));
To see the description of the table:
EXEC sp_columns department;
Add value into the table:
INSERT INTO department VALUES (1, 34000, 'ANURAG', 'UI DEVELOPERS');
INSERT INTO department VALUES (2, 33000, 'harsh', 'BACKEND DEVELOPERS');
INSERT INTO department VALUES (3, 36000, 'SUMIT', 'BACKEND DEVELOPERS');
INSERT INTO department VALUES (4, 36000, 'RUHI', 'UI DEVELOPERS');
INSERT INTO department VALUES (5, 37000, 'KAE', 'UI DEVELOPERS');
This is our data inside the table:
SELECT * FROM department;
Get the highest salary of each department on the table. Here our table contains a DEPT_ID and it has two different categories UI DEVELOPERS and BACKEND DEVELOPERS, and we will find out the highest salary of the column.
SELECT colunm_name, MAX(column_name) FROM table_name GROUP BY column_name;
Example:
SELECT DEPT_ID, MAX(SALARY) FROM department GROUP BY DEPT_ID;
Output:
RajuKumar19
SQL-Query
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL Interview Questions
CTE in SQL
How to Update Multiple Columns in Single Update Statement in SQL?
Difference between SQL and NoSQL
Difference between DDL and DML in DBMS
SQL | Views
Difference between DELETE, DROP and TRUNCATE
MySQL | Group_CONCAT() Function
Difference between DELETE and TRUNCATE
SQL - ORDER BY
numpy.defchararray.encode() in Python - GeeksforGeeks

28 Nov, 2018
numpy.core.defchararray.encode(arr, encoding): This nuympy function encodes the string(object) based on the specified codec.
Parameters:arr : array-like or string.encoding : [str] Name of encoding being followed.error : Specifying how to handle error.
Returns : Encoded string
Code:
# Python Program illustrating # numpy.char.encode() method import numpy as np   arr1 = ['eAAAa', 'ttttds', 'AAtAAt']arr2 = ['11sf', 'sdsf2', '1111f2']  # Printing the arrayprint ("\narr1 : ", arr1)print ("\narr2 : ", arr2)  print ("\nEncoded arr1 : \n", np.char.encode(arr1, encoding ='cp037'))print ("\nEncoded arr2 : \n", np.char.encode(arr2, encoding ='utf8'))print ("\nEncoded arr2 : \n", np.char.encode(arr2, encoding ='utf8',                                                  errors = 'strict'))
Output:
arr1 :  ['eAAAa', 'ttttds', 'AAtAAt']
arr2 :  ['11sf', 'sdsf2', '1111f2']

Encoded arr1 : 
 [b'\x85\xc1\xc1\xc1\x81' b'\xa3\xa3\xa3\xa3\x84\xa2'
 b'\xc1\xc1\xa3\xc1\xc1\xa3']

Encoded arr2 : 
 [b'11sf' b'sdsf2' b'1111f2']

Encoded arr2 : 
 [b'11sf' b'sdsf2' b'1111f2']

Python numpy-String Operation
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 ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
Change plot size in Matplotlib - Python - GeeksforGeeks

26 Nov, 2020
Prerequisite: Matplotlib
Plots are an effective way of visually representing data and summarizing it in a beautiful manner. However, if not plotted efficiently it seems appears complicated. In python’s matplotlib provides several libraries for the purpose of data representation.  
While making a plot it is important for us to optimize its size. Here are various ways to change the default plot size as per our required dimensions or resize a given plot. 
Method 1: Using set_figheight() and set_figwidth() 
For changing height and width of a plot set_figheight and set_figwidth are used
Python3
# importing the matplotlib libraryimport matplotlib.pyplot as plt  # values on x-axisx = [1, 2, 3, 4, 5]# values on y-axisy = [1, 2, 3, 4, 5]  # naming the x and y axisplt.xlabel('x - axis')plt.ylabel('y - axis')  # plotting a line plot with it's default sizeprint("Plot in it's default size: ")plt.plot(x, y)plt.show()  # plotting a line plot after changing it's width and heightf = plt.figure()f.set_figwidth(4)f.set_figheight(1)  print("Plot after re-sizing: ")plt.plot(x, y)plt.show()
Output:
Method 2: Using figsize
figsize() takes two parameters- width and height (in inches). By default the values for width and height are 6.4 and 4.8 respectively. 
Syntax:
plt.figure(figsize=(x,y)) 
Where, x and y are width and height respectively in inches.
Python3
import matplotlib.pyplot as plt  # values on x and y axisx = [1, 2, 3, 4, 5]y = [6, 7, 8, 9, 10]  # plot in it's default sizedisplay(plt.plot(x, y))  # changing the size of figure to 2X2plt.figure(figsize=(2, 2))display(plt.plot(x, y))
Output:
output screenshot
Method 3: Changing the default rcParams
We can permanently change the default size of a figure as per our needs by setting the figure.figsize. 
Python3
# importing the matplotlib libraryimport matplotlib.pyplot as plt  # values on x-axisx = [1, 2, 3, 4, 5]# values on y-axisy = [1, 2, 3, 4, 5]  # naming the x axisplt.xlabel('x - axis')# naming the y axisplt.ylabel('y - axis')  # plotting a line plot with it's default sizeplt.plot(x, y)plt.show()  # changing the rc parameters and plotting a line plotplt.rcParams['figure.figsize'] = [2, 2]  plt.plot(x, y)plt.show()  plt.scatter(x, y)plt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Python Dictionary
Taking input in Python
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe