code-rag-bench/online-tutorials huggingface dataset:
C library function - memchr()

The C library function void *memchr(const void *str, int c, size_t n) searches for the first occurrence of the character c (an unsigned char) in the first n bytes of the string pointed to, by the argument str.
Following is the declaration for memchr() function.
void *memchr(const void *str, int c, size_t n)
str − This is the pointer to the block of memory where the search is performed.
str − This is the pointer to the block of memory where the search is performed.
c − This is the value to be passed as an int, but the function performs a byte per byte search using the unsigned char conversion of this value.
c − This is the value to be passed as an int, but the function performs a byte per byte search using the unsigned char conversion of this value.
n − This is the number of bytes to be analyzed.
n − This is the number of bytes to be analyzed.
This function returns a pointer to the matching byte or NULL if the character does not occur in the given memory area.
The following example shows the usage of memchr() function.
#include <stdio.h>
#include <string.h>

int main () {
   const char str[] = "http://www.tutorialspoint.com";
   const char ch = '.';
   char *ret;

   ret = memchr(str, ch, strlen(str));

   printf("String after |%c| is - |%s|\n", ch, ret);

   return(0);
}
Let us compile and run the above program that will produce the following result −
String after |.| is - |.tutorialspoint.com|


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
Convert object to a Map - JavaScript

Suppose we have an object like this −
const obj = {
   name: "Vikas",
   age: 45,
   occupation: "Frontend Developer",
   address: "Tilak Nagar, New Delhi",
   experience: 23,
 };
We are required to write a JavaScript function that takes in such an object with key value pairs and converts it into a Map.
Let's write the code for this −
const obj = {
   name: "Vikas",
   age: 45,
   occupation: "Frontend Developer",
   address: "Tilak Nagar, New Delhi",
   experience: 23,
   salary: "98000"
};
const objectToMap = obj => {
   const keys = Object.keys(obj);
   const map = new Map();
   for(let i = 0; i < keys.length; i++){
      //inserting new key value pair inside map
      map.set(keys[i], obj[keys[i]]);
   };
   return map;
};
console.log(objectToMap(obj));
The output in the console: −
Map(6) {
   'name' => 'Vikas',
   'age' => 45,
   'occupation' => 'Frontend Developer',
   'address' => 'Tilak Nagar, New Delhi',
   'experience' => 23,
   'salary' => '98000'
}
How to Copy File Permissions and Ownership to Another File in Linux?

Many times while taking back up of data from one location to another or configuring software, we need to maintain the same level of ownership and permission of the files. Creating those permissions and granting ownership to individual files can be error prone of done by typing commands for each of the files. So we use some arguments with the chown and chmod commands.
We use the –-reference swiych in the chown function to specify the ownership cloning from the source file to the target file.
chown --reference=source_reference_file target_file
In the below example we have a source file whose ownership gets cloned to the target file after executing the above command. The Ownership details are shown both before and after applying the command.
# Before cloning the ownership
$ ls –lt
# Applying the ownership
$sudo chown --reference=ref_file.txt all_rivers.txt
# After Applying the ownership
$ls -lt
Running the above code gives us the following result −
# Before applying ownership
-rw-r--r-- 1 root root 19 Jan 1 08:40 all_rivers.txt
-rw-rw-r-- 1 ubuntu ubuntu 2925 Jan 1 08:39 ref_file.txt
# After applying ownership
-rw-r--r-- 1 ubuntu ubuntu 19 Jan 1 08:40 all_rivers.txt
-rw-rw-r-- 1 ubuntu ubuntu 2925 Jan 1 08:39 ref_file.txt
In a similar manner the file permissions also get copied from one file to another with a similar syntax, but involving chmod.
# Before cloning the permission
$ ls –lt
# Applying the permission
$sudo chmod --reference=ref_file.txt all_rivers.txt
# After Applying the permission
$ls -lt
Running the above code gives us the following result −
# Before Cloning permission
-rw-r--r-- 1 ubuntu ubuntu 19 Jan 1 08:40 all_rivers.txt
-rw-rw-r-- 1 ubuntu ubuntu 2925 Jan 1 08:39 ref_file.txt
# After cloning permission
-rw-rw-r-- 1 ubuntu ubuntu 19 Jan 1 08:40 all_rivers.txt
-rw-rw-r-- 1 ubuntu ubuntu 2925 Jan 1 08:39 ref_file.txt
C library function - strlen()

The C library function size_t strlen(const char *str) computes the length of the string str up to, but not including the terminating null character.
Following is the declaration for strlen() function.
size_t strlen(const char *str)
str − This is the string whose length is to be found.
str − This is the string whose length is to be found.
This function returns the length of string.
The following example shows the usage of strlen() function.
#include <stdio.h>
#include <string.h>

int main () {
   char str[50];
   int len;

   strcpy(str, "This is tutorialspoint.com");

   len = strlen(str);
   printf("Length of |%s| is |%d|\n", str, len);
   
   return(0);
}
Let us compile and run the above program that will produce the following result −
Length of |This is tutorialspoint.com| is |26|


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
Pattern matching in C# with Regex

A regular expression is a pattern that could be matched against an input text. A pattern consists of one or more character literals, operators, or constructs.
Let us see an example to display the words starting with the letter ‘M’ using Regex.
 Live Demo
using System;
using System.Text.RegularExpressions;

namespace Demo {
   class Program {
      private static void showMatch(string text, string expr) {
         Console.WriteLine("The Expression: " + expr);
         MatchCollection mc = Regex.Matches(text, expr);
         foreach (Match m in mc) {
            Console.WriteLine(m);
         }
      }

      static void Main(string[] args) {
         string str = "Mandatory requirements for a Cricket Match Event!";

         Console.WriteLine("Matching words that start with 'M': ");
         showMatch(str, @"\bM\S*");
         Console.ReadKey();
      }
   }
}
Matching words that start with 'M':
The Expression: \bM\S*
Mandatory
Match
Above, I have the string.
string str = "Mandatory requirements for a Cricket Match Event!";
To get all the words that begin with ‘M’, I have used the following pattern −
@"\bM\S*
SciPy Spatial Data

Spatial data refers to data that is represented in a geometric space.
E.g. points on a coordinate system.
We deal with spatial data problems on many tasks.
E.g. finding if a point is inside a boundary or not.
SciPy provides us with the module scipy.spatial, which has 
functions for working with 
spatial data.
A Triangulation of a polygon is to divide the polygon into multiple
triangles with which we can compute an area of the polygon.
A Triangulation with points means creating surface composed triangles in which all
of the given points are on at least one vertex of any triangle in the surface.
One method to generate these triangulations through points is the Delaunay() Triangulation.
Create a triangulation from following points:



Note: The simplices property creates a generalization of the triangle notation.
A convex hull is the smallest polygon that covers all of the given points.
Use the ConvexHull() method to create a Convex Hull.
Create a convex hull for following points:



KDTrees are a datastructure optimized for nearest neighbor queries.
E.g. in a set of points using KDTrees we can efficiently ask which points are nearest to a certain given point.
The KDTree() method returns a KDTree object.
The query() method returns the distance to the nearest neighbor and 
the location of the neighbors.
Find the nearest neighbor to point (1,1):



 (2.0, 0)


There are many Distance Metrics used to find various types of distances between two points in data science, Euclidean distsance, cosine distsance etc.
The distance between two vectors may not only be the length of straight line between them,
it can also be the angle between them from origin, or number of unit steps required etc.
Many of the Machine Learning algorithm's performance depends greatly on distance metrices.
E.g. "K Nearest Neighbors", or "K Means" etc.
Let us look at some of the Distance Metrices:
Find the euclidean distance between given points.



 9.21954445729


Is the distance computed using 4 degrees of movement.
E.g. we can only move: up, down, right, or left, not diagonally.
Find the cityblock distance between given points:



 11


Is the value of cosine angle between the two points A and B.
Find the cosine distsance between given points:



 0.019419324309079777


Is the proportion of bits where two bits are difference.
It's a way to measure distance for binary sequences.
Find the hamming distance between given points:



 0.666666666667


Consider this image:

Which method is most likely to be used to find the smallest polygon that covers all of the given points?
The () method

Start the Exercise
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.
Explain quantifiers in Java regular expressions

If you want to specify the number of occurrences while constructing a regular expression you can use quantifiers. Following table lists out the quantifiers supported by Java regular expressions −
 Live Demo
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
   public static void main( String args[] ) {
      String regex = "[0-9]{3,6}";
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter 5 input strings: ");
      String input[] = new String[5];
      for (int i=0; i<5; i++) {
         input[i] = sc.nextLine();
      }
      //Creating a Pattern object
      Pattern p = Pattern.compile(regex);
      System.out.println("Matched values: ");
      for(int i=0; i<5;i++) {
         //Creating a Matcher object
         Matcher m = p.matcher(input[i]);
         if(m.matches()) {
            System.out.println(m.group()+": accepted ");
         }
      }
   }
}
Enter 5 input strings:
12
154
4587
478365
4578952
Matched values:
154: accepted
4587: accepted
478365: accepted
Objective-C Basic Syntax

You have seen a basic structure of Objective-C program, so it will be easy to understand other basic building blocks of the Objective-C programming language.
A Objective-C program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol. For example, the following Objective-C statement consists of six tokens −
NSLog(@"Hello, World! \n");
The individual tokens are −
NSLog
@
(
   "Hello, World! \n"
)
;
In Objective-C program, the semicolon is a statement terminator. That is, each individual statement must be ended with a semicolon. It indicates the end of one logical entity.
For example, following are two different statements −
NSLog(@"Hello, World! \n");
return 0;
Comments are like helping text in your Objective-C program and they are ignored by the compiler. They start with /* and terminate with the characters */ as shown below −
/* my first program in Objective-C */

You can not have comments with in comments and they do not occur within a string or character literals.
An Objective-C identifier is a name used to identify a variable, function, or any other user-defined item. An identifier starts with a letter A to Z or a to z or an underscore _ followed by zero or more letters, underscores, and digits (0 to 9).
Objective-C does not allow punctuation characters such as @, $, and % within identifiers. Objective-C is a case-sensitive programming language. Thus, Manpower and manpower are two different identifiers in Objective-C. Here are some examples of acceptable identifiers −
mohd       zara    abc   move_name  a_123
myname50   _temp   j     a23b9      retVal

The following list shows few of the reserved words in Objective-C. These reserved words may not be used as constant or variable or any other identifier names.
A line containing only whitespace, possibly with a comment, is known as a blank line, and an Objective-C compiler totally ignores it.
Whitespace is the term used in Objective-C to describe blanks, tabs, newline characters and comments. Whitespace separates one part of a statement from another and enables the compiler to identify where one element in a statement, such as int, ends and the next element begins. Therefore, in the following statement −
int age;

There must be at least one whitespace character (usually a space) between int and age for the compiler to be able to distinguish them. On the other hand, in the following statement,
fruit = apples + oranges;   // get the total fruit
No whitespace characters are necessary between fruit and =, or between = and apples, although you are free to include some if you wish for readability purpose.

    18 Lectures 
     1 hours 

 PARTHA MAJUMDAR

    6 Lectures 
     25 mins

 Ken Burke
 Print
 Add Notes
 Bookmark this page
Explain Binary search in C language

Binary search method can be applied only to sorted list. The given list is divided into two equal parts. In the list, the key is compared with middle element.
Three situations may occur in binary search which are as follows −
If the middle element matches the key, then the search will end successfully here
If the middle element matches the key, then the search will end successfully here
If the middle element is greater than the key, then the search will proceed in the left partition
If the middle element is greater than the key, then the search will proceed in the left partition
If the middle element is lower than the key, then the search will proceed in the right partition.
If the middle element is lower than the key, then the search will proceed in the right partition.
Input (i/p)
sorted list of elements, key.
Output (o/p)
Success − If key is found.
Unsuccessful − Otherwise.
Following is the C program for binary search method −
#include<stdio.h>
int main(){
   int a[50], n, i, key, flag = 0, low, mid, high;
   printf("enter the no: of elements:");
   scanf ("%d",&n);
   printf("enter the elements:");
   for(i=0; i<n; i++)
      scanf( "%d", &a[i]);
   printf("enter a key element:");
   scanf ("%d", &key);
   low = 0;
   high = n-1;
   while (low<= high ){
      mid = (low + high) /2;
      if (a[mid] == key){
         flag = 1;
      break;
   } else {
      if (a[mid] > key)
         high = mid-1;
      else
         low = mid+1;
      }
   }
   if (flag == 1)
      printf ("search is successful");
   else
   printf("search is unsuccessful");
   return 0;
}
When the above program is executed, it produces the following result −
enter the no: of elements:5
enter the elements:23
45
57
89
90
enter a key element:45
search is successful
Count upper and lower case characters without using inbuilt functions in Python program

In this article, we will learn about the solution to the problem statement given below.
Problem statement − We are given a string, we need to count the number of uppercase and lowercase characters present in the string without using the inbuilt function
This can be easily solved by using islower() and isupper() function available in python. But here there is a constraint to use the inbuilt function. So here we take the help of the ASCII value of the characters.
Using the ord() function we compute the ASCII value of each character present in the string and then compare to check for uppercase and lowercase as shown below.
 Live Demo
def upperlower(string):
   upper = 0
   lower = 0
   for i in range(len(string)):
      # For lowercase
      if (ord(string[i]) >= 97 and
         ord(string[i]) <= 122):
         lower += 1
      # For uppercase
      elif (ord(string[i]) >= 65 and
         ord(string[i]) <= 90):
         upper += 1
   print('Lower case characters = '+str(lower))
   print('Upper case characters = '+str(upper))
# Driver Code
string = 'TutorialsPoint'
upperlower(string)
Lower case characters = 12
Upper case characters = 2
All the variables are declared in the local scope and their references are seen in the figure above.
In this article, we have learned how to count uppercase and lowercase characters present in the given string
C++ Program to Generate All Possible Combinations Out of a,b,c,d,e

This is a C++ program to generate all possible combinations out of a, b, c, d, e.
Begin
   Take the number of elements and the elements as input.
   function Combi(char a[], int reqLen, int s, int currLen, bool check[], int l)
   to print the all possible combination of given array set:
   //
   Here,
   char a[] = character array
   reqLen = required length
   s = start variable
   currLen = current length
   check[] = a boolean variable
   l = length of array
   //
   Body of the Function:
      If currLen>reqLen
         Return
      Else if currLen=reqLen
         Then print the new generated sequence.
      If s = l
         Then return no further element is left.
      For every index there are two option:
      either proceed with a start as ‘true’ and recursively call Combi() with incremented value of ‘currLen’ and ‘s’.
      Or proceed with a start as ‘false’ and recursively call Combi() with only incremented value of ‘s’.
End
#include<iostream>
using namespace std;
void Combi(char a[], int reqLen, int s, int currLen, bool check[], int l)
{
   if(currLen > reqLen)
   return;
   else if (currLen == reqLen) {
      cout<<"\t";
      for (int i = 0; i < l; i++) {
         if (check[i] == true) {
            cout<<a[i]<<" ";
         }
      }
      cout<<"\n";
      return;
   }
   if (s == l) {
      return;
   }
   check[s] = true;
   Combi(a, reqLen, s + 1, currLen + 1, check, l);
   check[s] = false;
   Combi(a, reqLen, s + 1, currLen, check, l);
}
int main() {
   int i,n;
   bool check[n];
   cout<<"Enter the number of element array have: ";
   cin>>n;
   char a[n];
   cout<<"\n";
   for(i = 0; i < n; i++) {
      cout<<"Enter "<<i+1<<" element: ";
      cin>>a[i];
      check[i] = false;
   }
   for(i = 1; i <= n; i++) {
      cout<<"\nThe all possible combination of length "<<i<<" for the given array set:\n";
      Combi(a, i, 0, 0, check, n);
   }
   return 0;
}
Enter the number of element array have: 5
Enter 1 element: a
Enter 2 element: b
Enter 3 element: c
Enter 4 element: d
Enter 5 element: e
The all possible combination of length 1 for the given array set:
a
b
c
d
e
The all possible combination of length 2 for the given array set:
a b
a c
a d
a e
b c
b d
b e
c d
c e
d e
The all possible combination of length 3 for the given array set:
a b c
a b d
a b e
a c d
a c e
a d e
b c d
b c e
b d e
c d e
The all possible combination of length 4 for the given array set:
a b c d
a b c e
a b d e
a c d e
b c d e
The all possible combination of length 5 for the given array set:
a b c d e
DAX Time Intelligence - DATESMTD function

Returns a table that contains a column of the dates for the month to date, in the current context.
DATESMTD (<dates>) 

dates
A column that contains dates.
A table containing a single column of date values.
The dates parameter can be any of the following −
A reference to a date/time column.
A reference to a date/time column.
A table expression that returns a single column of date/time values.
A table expression that returns a single column of date/time values.
A Boolean expression that defines a single-column table of date/time values.
A Boolean expression that defines a single-column table of date/time values.
Constraints on Boolean expressions −
The expression cannot reference a calculated field.
The expression cannot reference a calculated field.
The expression cannot use CALCULATE function.
The expression cannot use CALCULATE function.
The expression cannot use any function that scans a table or returns a table, including aggregation functions.
The expression cannot use any function that scans a table or returns a table, including aggregation functions.
However, a Boolean expression can use any function that looks up a single value, or that calculates a scalar value.
The year_end_date parameter is a string literal of a date, in the locale where the workbook was created. The year portion of the date is ignored.
= CALCULATE ( 
   SUM (Sales [Sales Amount]), DATESMTD (Sales [Date])
) 

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
Python | Pandas Timestamp.tz_localize - GeeksforGeeks

09 Dec, 2021
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas Timestamp.tz_localize() function convert naive Timestamp to local time zone, or remove timezone from tz-aware Timestamp.
Syntax :Timestamp.tz_localize()Parameters : tz : Time zone for time which Timestamp will be converted to. None will remove timezone holding local time. ambiguous : bool, ‘NaT’, default ‘raise’ errors : ‘raise’, ‘coerce’, default ‘raise’Return : localized : Timestamp  
Example #1: Use Timestamp.tz_localize() function to convert a tz-aware Timestamp to a naive Timestamp object. 
Python3
# importing pandas as pdimport pandas as pd # Create the Timestamp objectts = pd.Timestamp(year = 2011,  month = 11, day = 21,                  hour = 10, second = 49, tz = 'US/Central') # Print the Timestamp objectprint(ts)
Output : 
Now we will use the Timestamp.tz_localize() function to convert the tz-aware Timestamp to naive Timestamp. 
Python3
# convert to naive Timestampts.tz_localize(tz = None)
Output : 
As we can see in the output, the Timestamp.tz_localize() function has converted the given Timestamp to a naive Timestamp.   Example #2: Use Timestamp.tz_localize() function to convert the given naive Timestamp to tz-aware Timestamp object. Set the timezone to ‘US/Pacific’.
Python3
# importing pandas as pdimport pandas as pd # Create the Timestamp objectts = pd.Timestamp(year = 2009, month = 5, day = 31,                             hour = 4, second = 49) # Print the Timestamp objectprint(ts)
Output : 
Now we will use the Timestamp.tz_localize() function to set the timezone of ts object to ‘US/Pacific’. 
Python3
# set to 'US / Pacific'ts.tz_localize(tz = 'US/Pacific')
Output : 
As we can see in the output, the Timestamp.tz_localize() function has set the timezone of the given object to ‘US/Pacific’. 
simmytarika5
Python Pandas-Timestamp
Python-pandas
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?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
How to access props inside quotes in React JSX? - GeeksforGeeks

28 Dec, 2020
Following approaches are there to access props inside quotes in React JSX:
Approach 1: We can put any JS expression inside curly braces as the entire attribute value.
Approach 2: We can use ES6 template literals.
Creating React Application:
Step 1: Create a React application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:
cd foldername
Project Structure: It will look like the following.
Project Structure
Approach 1: App.js
Javascript
import React, { Component } from "react";  class App extends Component {  render() {    return (      <div>        <img          alt="React Logo"            // Putting js expression inside curly braces          src={this.props.image}        />      </div>    );  }}  export default App;
Approach 2: App.js
Javascript
import React, { Component } from "react";  class App extends Component {  render() {    return (      <div>        <img          alt="React Logo"            // Using ES6 template literals          src={`${this.props.image}`}         />      </div>    );  }}  export default App;
Note: Make sure to pass the prop value in the <App> component in the index.js file and place any sample picture in the public folder, like here we have used reactLogo.png.
index.js
Javascript
import React from 'react';import ReactDOM from 'react-dom';import './index.css';import App from './App';  ReactDOM.render(  <React.StrictMode>    <App image="reactLogo.png" />  </React.StrictMode>,  document.getElementById('root'));
Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output: You will see the reactLogo.png picture on your browser screen.
Picked
JavaScript
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
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Difference Between PUT and PATCH Request
How to read a local text file using JavaScript?
How to Use the JavaScript Fetch API to Get Data?
Node.js | fs.writeFileSync() Method
JavaScript | Promises
How to get character array from string in JavaScript?
Is there any alternative for OpenCV imshow() method in Java?

The HighGui class of the org.opencv.highgui package allows you to create and manipulate windows and display them. You can display an image in a window using the imshow() method of this class. This method accepts two parameters−
A string variable representing the name of the window.
A string variable representing the name of the window.
A Mat object representing the contents of an image.
A Mat object representing the contents of an image.
It is recommended to invoke the waitKey() method after imshow().
The following example reads an image, converts it into a grayscale image, detects the edges in it and displays all the three images (original, gray-scale and, edges) in windows using HighGui.
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
public class ImshowExample {
   public static void main(String args[]) {
      //Loading the OpenCV core library
      System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
      //Reading the Image from the file
      Mat src = Imgcodecs.imread("D://images//window.jpg");
      HighGui.imshow("Original Image", src);
      //Converting color to gray scale
      Mat gray = new Mat(src.rows(), src.cols(), src.type());
      Imgproc.cvtColor(src, gray, Imgproc.COLOR_RGB2GRAY);
      HighGui.imshow("Gray Scale Image", gray);
      //Applying canny
      Mat dst = new Mat(src.rows(), src.cols(), src.type());
      Imgproc.Canny(gray, dst, 100, 100*3);
      HighGui.imshow("Edges", dst);
      HighGui.waitKey();
   }
}
On executing, the above program generates three windows as shown below −
Original image −
Grayscale image −
Image with edges highlighted −
Why we mention in MySQL WHERE 1=0?

The condition 1=0 can be used to stop the query from returning any rows. It returns empty set.
The syntax is as follows:
SELECT *FROM yourTableName WHERE 1=0;
To understand the above syntax,let us create a table. The query to create a table is as follows:
mysql> create table ConditionDemo
   -> (
   -> Id int NOT NULL AUTO_INCREMENT,
   -> Name varchar(10),
   -> PRIMARY KEY(Id)
   -> );
Query OK, 0 rows affected (0.59 sec)
Insert some records in the table using insert command. The query is as follows:
mysql> insert into ConditionDemo(Name) values('Larry');
Query OK, 1 row affected (0.10 sec)
mysql> insert into ConditionDemo(Name) values('Sam');
Query OK, 1 row affected (0.14 sec)
mysql> insert into ConditionDemo(Name) values('Mike');
Query OK, 1 row affected (0.13 sec)
mysql> insert into ConditionDemo(Name) values('Carol');
Query OK, 1 row affected (0.12 sec)
mysql> insert into ConditionDemo(Name) values('John');
Query OK, 1 row affected (0.17 sec)
mysql> insert into ConditionDemo(Name) values('Bob');
Query OK, 1 row affected (0.10 sec)
Display all records from the table using select statement. The query is as follows:
mysql> select *from ConditionDemo;
The following is the output:
+----+-------+
| Id | Name  |
+----+-------+
|  1 | Larry |
|  2 | Sam   |
|  3 | Mike  |
|  4 | Carol |
|  5 | John  |
|  6 | Bob   |
+----+-------+
6 rows in set (0.00 sec)
Here is the query to prevent the query from returning any row
mysql> select *from ConditionDemo where 1=0;
Empty set (0.00 sec)
How to convert a Pandas Series to Python list?

28 Jul, 2020
In this article, we will discuss how to convert a Pandas series to a Python List and it’s type. This can be done using the tolist() method.Example 1:
Python3
import pandas as pd    evenNumbers = [2, 4, 6, 8, 10]  evenNumbersDs = pd.Series(evenNumbers)print("Pandas Series and type")print(evenNumbersDs)print(type(evenNumbersDs))  print("\nConvert Pandas Series to Python list")print(evenNumbersDs.tolist())print(type(evenNumbersDs.tolist()))
Output:
In the above example,  we are passing Panda series data as evenNumbers . As index is not given, by default 0 is takenExample 2:
Python3
import pandas as pdimport numpy as np    data = np.array(['ant','bat','cat','dog'])series = pd.Series(data,index=[100,101,102,103])print(series)print(type(series))  print("\nConvert Pandas Series to Python list")print(series.tolist())print(type(series.tolist()))
Output:
In the above example, we are passing Panda series data as np.array([‘ant’,’bat’,’cat’,’dog’]).Index as [100,101,102,103]
Example 3:
Python3
# Series from dictionaryimport pandas as pdimport numpy as np    marks = {'Maths' : 100., 'Physics' : 90.,         'Chemistry' : 85.}series = pd.Series(marks)  print(series)print(type(series))  print("\nConvert Pandas Series to Python list")print(series.tolist())print(type(series.tolist()))
Output:
Example 4:
Python3
# Get First 3 student marks and# convert as listimport pandas as pdseries = pd.Series([100, 90, 80, 90, 85],                   index=['Student1', 'Student2',                          'Student3', 'Student4',                          'Student5'])  # retrieve the first three elementprint(series[:3])print(series[:3].tolist())print(type(series[:3].tolist()))
Output:
pandas-series-program
Python Pandas-exercise
Python pandas-series
Python-pandas
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
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Iterate over a list in Python
Introduction To PYTHON
Python Program to Find Most common elements set

02 Feb, 2021
Given a List of sets, the task is to write a Python program tocompare elements with argument set, and return one with maximum matching elements.
Examples:
Input : test_list = [{4, 3, 5, 2}, {8, 4, 7, 2}, {1, 2, 3, 4}, {9, 5, 3, 7}], arg_set = {9, 6, 5, 3}
Output : {9, 3, 5, 7}
Explanation : Resultant set has maximum matching elements.
Input : test_list = [{4, 3, 5, 2}, {8, 4, 7, 2}, {1, 2, 3, 4}, {9, 5, 3, 7}], arg_set = {4, 6, 5, 3}
Output : {2, 3, 4, 5}
Explanation : Resultant set has maximum matching elements.
Method 1: Using loop + set.intersection()
In this, we perform task of getting all the common elements with argument set using intersection(), and get its length using len(), and maximum length and set is compared and updated during iteration.
Python3
# Python3 code to demonstrate working of# Most common elements set# Using loop + intersection()  # initializing listtest_list = [{4, 3, 5, 2}, {8, 4, 7, 2},             {1, 2, 3, 4}, {9, 5, 3, 7}]  # printing original listprint("The original list is : " + str(test_list))  # initializing arg_setarg_set = {9, 6, 5, 3}  res = set()max_len = 0  for sub in test_list:          # updating max value on occurrence    if len(sub.intersection(arg_set)) > max_len:        max_len = len(sub.intersection(arg_set))        res = sub  # printing resultprint("Max Set intersection : " + str(res))
Output:
The original list is : [{2, 3, 4, 5}, {8, 2, 4, 7}, {1, 2, 3, 4}, {9, 3, 5, 7}]
Max Set intersection : {9, 3, 5, 7}
Method 2 : Using max() + list comprehension + intersection()
In this, initial step is to check for the lengths of all intersected set results and get maximum using max(). Next, task of getting set which matches required length is extracted.
Python3
# Python3 code to demonstrate working of# Most common elements set# Using loop + intersection()  # initializing listtest_list = [{4, 3, 5, 2}, {8, 4, 7, 2},             {1, 2, 3, 4}, {9, 5, 3, 7}]  # printing original listprint("The original list is : " + str(test_list))  # initializing arg_setarg_set = {9, 6, 5, 3}  # getting maximum length max_len = max(len(sub.intersection(arg_set)) for sub in test_list)  # getting element matching lengthres = [sub for sub in test_list if len(sub.intersection(arg_set)) == max_len][0]  # printing resultprint("Set intersection : " + str(res))
Output:
The original list is : [{2, 3, 4, 5}, {8, 2, 4, 7}, {1, 2, 3, 4}, {9, 3, 5, 7}]
Max Set intersection : {9, 3, 5, 7}
Python set-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Program to count number of nice subarrays in Python

Suppose we have an array called nums and another value k. We have to find the number of nice sub-arrays. A subarray is said to be nice subarray if there are k odd numbers on it.
So, if the input is like nums = [1,1,2,1,1], k = 3, then the output will be 2 because there are two subarrays [1,1,2,1] and [1,2,1,1].
To solve this, we will follow these steps −
odd_i := a new list
odd_i := a new list
for i in range 0 to size of nums - 1, doif nums[i] mod 2 is same as 1, theninsert i at the end of odd_i
for i in range 0 to size of nums - 1, do
if nums[i] mod 2 is same as 1, theninsert i at the end of odd_i
if nums[i] mod 2 is same as 1, then
insert i at the end of odd_i
insert i at the end of odd_i
start := 0, end := k - 1
start := 0, end := k - 1
i := 0
i := 0
count := 0
count := 0
while end < size of odd_i, doif end is same as size of odd_i - 1, thenj := size of nums - 1otherwise,j := odd_i[end + 1] - 1count := count +(odd_i[start] - i + 1) *(j - odd_i[end] + 1)i := odd_i[start] + 1start := start + 1end := end + 1
while end < size of odd_i, do
if end is same as size of odd_i - 1, thenj := size of nums - 1
if end is same as size of odd_i - 1, then
j := size of nums - 1
j := size of nums - 1
otherwise,j := odd_i[end + 1] - 1
otherwise,
j := odd_i[end + 1] - 1
j := odd_i[end + 1] - 1
count := count +(odd_i[start] - i + 1) *(j - odd_i[end] + 1)
count := count +(odd_i[start] - i + 1) *(j - odd_i[end] + 1)
i := odd_i[start] + 1
i := odd_i[start] + 1
start := start + 1
start := start + 1
end := end + 1
end := end + 1
return count
return count
Let us see the following implementation to get better understanding −
def solve(nums, k):
   odd_i = []
   for i in range(len(nums)):
      if nums[i] % 2 == 1:
         odd_i.append(i)
   start = 0
   end = k - 1
   i = 0
   count = 0
   while end < len(odd_i):
      if end == len(odd_i) - 1:
         j = len(nums) - 1
      else:
         j = odd_i[end + 1] - 1
      count = count + (odd_i[start] - i + 1) * (j - odd_i[end] + 1)
      i = odd_i[start] + 1
      start = start + 1
      end = end + 1
   return count

nums = [1,1,2,1,1]
k = 3
print(solve(nums, k))
[1,2,3,4,5,6,7,8]

2
Python | os.path.realpath() method

18 Jun, 2019
OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality. os.path module is sub module of OS module in Python used for common path name manipulation.
os.path.realpath() method in Python is used to get the canonical path of the specified filename by eliminating any symbolic links encountered in the path.
Syntax: os.path.realpath(path)
Parameter:path: A path-like object representing the file system path.A path-like object is either a string or bytes object representing a path.
Return Type: This method returns a string value which represents the canonical path.
Create a soft link or symbolic linkIn Unix or Linux, soft link or symbolic link can be created using ln command. Below is the syntax to create a symbolic link at the shell prompt:
$ ln -s {source-filename} {symbolic-filename}

Example:
Example:
In above output, “/home/ihritik/Desktop/file(shortcut).txt” is a symbolic link.
Code : Use of os.path.realpath() method to get canonical path and resolve symbolic links
# Python program to explain os.path.realpath() method     # importing os module import os  # Pathpath = "/home / ihritik / Desktop / file(shortcut).txt"    # Get the canonical path# of the specified path# by eliminating any symbolic links# encountered in the pathreal_path = os.path.realpath(path)  # Print the canonical pathprint(real_path)    # Pathpath = "/../../GeeksForGeeks / sample.py"    # Get the canonical path# of the specified path# eliminating any symbolic links# encountered in the pathreal_path = os.path.realpath(path)  # Print the canonical pathprint(real_path)    # Pathpath = "file.txt"    # Get the canonical path# of the specified path# eliminating any symbolic links# encountered in the pathreal_path = os.path.realpath(path)  # Print the canonical pathprint(real_path)  os.chdir("/home / ihritik / Downloads/")    # Pathpath = "file.txt"  # Get the canonical path# of the specified path# eliminating any symbolic links# encountered in the pathreal_path = os.path.realpath(path)  # Print the canonical pathprint(real_path)
/home/ihritik/Documents/file(original).txt
/GeeksForGeeks/sample.py
/home/ihritik/file.txt
/home/ihritik/Downloads/file.txt

Reference: https://docs.python.org/3/library/os.path.html
Python OS-path-module
python-os-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2015 (Set 3) | Question 65

28 Jun, 2021
If ROAD is written as URDG, then SWAN should be written as:(A) VXDQ(B) VZDQ(C) VZDP(D) UXDQAnswer: (B)Explanation: In ROAD to URDG transformation, every character is replaced by next third character in alphabetic sequence. (R by U, O by R, A by D and D by G)Applying same, SWAN becomes VZDQQuiz of this Question
GATE-CS-2015 (Set 3)
GATE-GATE-CS-2015 (Set 3)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Program to delete a line given the line number from a file

20 Feb, 2018
Given a file and a line number n, the task is to delete nth line from the given text file.Suppose the initial content of myfile.txt is :
GeeksforGeeks
GeeksforGeeks IDE
GeeksforGeeks Practice
GeeksforGeeks Contribute

After Deletion of Line 2 the content would be :
GeeksforGeeks
GeeksforGeeks IDE
GeeksforGeeks Contribute

Approach :1) Open the source file in input mode and read it character by character.2) Open another file in output mode and place contents in the file character by character.3) Rename the other file to the source file.
// C++ Program to delete the given// line number from a file#include <bits/stdc++.h>using namespace std;  // Delete n-th line from given filevoid delete_line(const char *file_name, int n){    // open file in read mode or in mode    ifstream is(file_name);      // open file in write mode or out mode    ofstream ofs;    ofs.open("temp.txt", ofstream::out);      // loop getting single characters    char c;    int line_no = 1;    while (is.get(c))    {        // if a newline character        if (c == '\n')        line_no++;          // file content not to be deleted        if (line_no != n)            ofs << c;    }      // closing output file    ofs.close();      // closing input file    is.close();      // remove the original file    remove(file_name);      // rename the file    rename("temp.txt", file_name);}  // Driver codeint main(){    int n = 3;    delete_line("a.txt", n);    return 0;}
 Note: Run this code offline IDE keep text file name 
as "a.txt" in same folder 
cpp-file-handling
C++
C++ Programs
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Sorting a vector in C++
Polymorphism in C++
Pair in C++ Standard Template Library (STL)
std::string class in C++
Friend class and function in C++
Header files in C/C++ and its uses
Sorting a Map by value in C++ STL
Program to print ASCII Value of a character
How to return multiple values from a function in C or C++?
C++ program for hashing with chaining
How to Get First and Last Element of Slice in Golang?

17 May, 2020
Go language slice is more powerful, flexible, convenient than an array, and is a lightweight data structure. Slice is a variable-length sequence which stores elements of a similar type, you are not allowed to store different type of elements in the same slice. It is just like an array having an index value and length, but the size of the slice is resized they are not in fixed-size just like an array. Internally, slice and an array are connected with each other, a slice is a reference to an underlying array. It is allowed to store duplicate elements in the slice. The first index position in a slice is always 0 and the last one will be (length of slice – 1).
Accessing First Element: It’s easy to access the first element with the zeroth index of Slice.
Accessing Last Element: The Last element is the element at the index position that is the length of the Slice minus 1.
Examples:
Input : 
sliceOfInt[]=[2, 3, 4, 5, 6]

Output :
First element : 2
Last element : 6

Input : 
sliceOfFloat[]=[4.5, 3.4, 6.6, 5.2, 2.1]

Output :
First element : 4.5
Last element : 2.1

Example 1:
// Golang program to access the first// and last element of the slice  package main  import "fmt"  func main() {      // Declaring & Defining    // the Slice    sliceOfInt := []int{2, 3, 4, 5, 6}      // Printing the Slice    fmt.Printf("Slice: %v\n", sliceOfInt)      // Accessing zeroth index    // i.e. first element    first := sliceOfInt[0]      // Printing first element    fmt.Printf("First element: %d\n", first)      // Accessing length(slice)-1    // index i.e. last    // element    last := sliceOfInt[len(sliceOfInt)-1]      // Printing last element    fmt.Printf("Last element: %v\n", last)  }
Output:
Slice: [2 3 4 5 6]
First element: 2
Last element: 6

Example 2:
// Golang program to access the first// and last element of the slicepackage main  import "fmt"  func main() {      sliceOfFloat := []float32{2.5, 3.2, 4.1, 5.7, 6.9}    fmt.Printf("Slice: %v\n", sliceOfFloat)      first := sliceOfFloat[0]    fmt.Printf("First element: %v\n", first)      last := sliceOfFloat[len(sliceOfFloat)-1]    fmt.Printf("Last element: %v\n", last)  }
Output:
Slice: [2.5 3.2 4.1 5.7 6.9]
First element: 2.5
Last element: 6.9

Golang-Slices
Picked
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove grid and background from plot using ggplot2 in R

03 Mar, 2021
Prerequisite: ggplo2 in R programming
A plot by default is produced with a grid background and grayish colored background. This article discusses how they can be removed. The examples given below use line plot, but the same can be employed for any other Visualization.
Approach
Create data frame
Plot normally
Now add functions to make changes
Display plot
To understand the difference better let us first create a plot with grid and background.
Program:
R
df <- data.frame(a=c(2,4,8), b=c(5, 10, 15))  plot = ggplot(df, aes(x = a, y = b)) + geom_point() + geom_line()  #outputplot
Output:
Basic Line Plot
Now, We are going to perform some operation/ modification on this plot. 
Assigning the grid’s major and minor with the element_blanck() function, will remove the grid but not remove the background color and borderlines.
Program:
R
df <- data.frame(a=c(2,4,8),b=c(5, 10, 15))  plot + theme(panel.grid.major = element_blank(),                panel.grid.minor = element_blank())
Output:
Remove Grid But not remove Background
Using theme_bw() function with the plot removes the grayish background but doesn’t affect the Grid.
Program:
R
df <- data.frame(a=c(2,4,8),b=c(5, 10, 15))  # theme_bw() functionplot + theme_bw()
Output:
Only Grid and Axis
Assigning panel.background with element_blank() function will remove both grid and the background.
Program:
R
df <- data.frame(a=c(2,4,8),b=c(5, 10, 15))  plot + theme(panel.background = element_blank())
Output:
Remove Grid and Background
Picked
R-ggplot
Technical Scripter 2020
R Language
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
IDE | GeeksforGeeks | A computer science portal for geeks

Please enter your email address or userHandle.
12345678910111213141516171819202122232425262728293031323334353637https://c.mi.com/thread-3967156-1-1.html https://forums.ubisoft.com/showthread.php/2371427-44-Free-Cookie-Run-Cookies-Generator-2022iwd?p=15523073#post15523073https://coin-master-spins-generator-2022.tumblr.comhttps://gta-5-money-generator-2022.tumblr.comhttps://fortnite-free-account-generator.tumblr.comhttps://clash-royale-gems-generator-2022.tumblr.comhttps://bingo-blitz-credit-2022.tumblr.comhttps://xbox-gift-card-code-generator.tumblr.comhttps://apex-legends-coins-generator.tumblr.comhttps://cookie-run-cookies-generator.tumblr.comhttps://instagram-free-followers.tumblr.comhttps://nba-2k22-free-vc-generator.tumblr.comhttps://roblox-gift-card-generator.tumblr.comhttps://pokemon-go-coins-generator.tumblr.comhttps://forums.ubisoft.com/showthread.php/2371435-ewfeoijf09iew-foirewjofvper4fgt4?p=15523081#post15523081http://zacriley.ning.com/photo/albums/oiuu0wd0iewfdeijfuie0wfr34https://paiza.io/projects/FE0cKWK9wOVfWy4DUXjBcA?language=phphttps://jsfiddle.net/cvb6jurq/https://notes.io/ABA8https://onecompiler.com/java/3xq2arqqqhttps://paste2.org/nzpDxFFXhttps://pasteio.com/xcSX5MxXPrYuhttps://ideone.com/2tyQfahttps://authors.curseforge.com/paste/55bcf509https://dev.bukkit.org/paste/1e5c7bcfhttps://paste.feed-the-beast.com/view/466d3332http://cpp.sh/65aguhttps://brainly.co.id/tugas/47544401https://pasteall.org/n1Wnhttps://ide.geeksforgeeks.org/rzkmEa6jhahttps://pastebin.com/https://paste.centos.org/view/8d1dfcbahttps://paste.in/aE81KRhttps://ctxt.io/2/AABgxmZ4Ewhttps://wow.curseforge.com/paste/a9a7e63fhttp://paste.jp/0adb2856/https://paste.ofcode.org/w2eWHucTsYsx5KJPRK2FcmההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
https://ide.geeksforgeeks.org/VYvlOsqxzV
prog.c:1:6: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before â:â token