code-rag-bench/online-tutorials huggingface dataset:
C# | Get the number of elements contained in Collection<T> - GeeksforGeeks

01 Feb, 2019
Collection<T>.Count property is used to get the number of elements actually contained in the Collection<T>.
Syntax:
public int Count { get; }

Return Value: The number of elements actually contained in the Collection<T>.
Below given are some examples to understand the implementation in a better way:
Example 1:
// C# code to get the number of// elements contained in the Collectionusing System;using System.Collections.Generic;using System.Collections.ObjectModel;  class GFG {      // Driver code    public static void Main()    {        // Creating a collection of strings        Collection<string> myColl = new Collection<string>();          // Adding elements in Collection myColl        myColl.Add("A");        myColl.Add("B");        myColl.Add("C");        myColl.Add("D");        myColl.Add("E");          // To print the count of elements in Collection        Console.WriteLine("Count : " + myColl.Count);          // Displaying the elements in myColl        foreach(string str in myColl)        {            Console.WriteLine(str);        }    }}
Output:
Count : 5
A
B
C
D
E

Example 2:
// C# code to get the number of// elements contained in the Collectionusing System;using System.Collections.Generic;using System.Collections.ObjectModel;  class GFG {      // Driver code    public static void Main()    {        // Creating a collection of ints        Collection<int> myColl = new Collection<int>();          // Adding elements in Collection myColl        myColl.Add(2);        myColl.Add(3);        myColl.Add(4);        myColl.Add(5);          // To print the count of elements in Collection        Console.WriteLine("Count : " + myColl.Count);          // Displaying the elements in myColl        foreach(int i in myColl)        {            Console.WriteLine(i);        }    }}
Output:
Count : 4
2
3
4
5

Note: Retrieving the value of this property is an O(1) operation.
Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.objectmodel.collection-1.count?view=netframework-4.7.2
CSharp-Collection-Class
CSharp-Collections.ObjectModel-Namespace
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Destructors in C#
Extension Method in C#
HashSet in C# with Examples
Top 50 C# Interview Questions & Answers
C# | How to insert an element in an Array?
Partial Classes in C#
C# | Inheritance
C# | List Class
Difference between Hashtable and Dictionary in C#
C# | Generics - Introduction
Search Insert Position in C++

Suppose we have a sorted array arr and a target value, we have to find the index when the target is found. If that is not present, then return the index where it would be if it were inserted in order.
So, if the input is like [1,3,4,6,6], and target = 5, then the output will be 3, as we can insert 5 at index 3, so the array will be [1,3,4,5,6,6]
To solve this, we will follow these steps−
n := size of A
n := size of A
if n < 1, then −return 0
if n < 1, then −
return 0
return 0
low := 0, high := n - 1
low := 0, high := n - 1
while low <= high, do −mid := low + (high - low) /2if A[mid] is same as target, then −return midotherwise when A[mid] > target, then −high := mid - 1, pos := midotherwiselow := mid + 1, pos := mid + 1
while low <= high, do −
mid := low + (high - low) /2
mid := low + (high - low) /2
if A[mid] is same as target, then −return mid
if A[mid] is same as target, then −
return mid
return mid
otherwise when A[mid] > target, then −high := mid - 1, pos := mid
otherwise when A[mid] > target, then −
high := mid - 1, pos := mid
high := mid - 1, pos := mid
otherwiselow := mid + 1, pos := mid + 1
otherwise
low := mid + 1, pos := mid + 1
low := mid + 1, pos := mid + 1
return pos
return pos
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
   int searchInsert(vector<int>& A, int target) {
      int n = A.size();
      if(n < 1) {
         return 0;
      }
      int low = 0;
      int high = n-1;
      int mid;
      int pos;
      while(low <= high) {
         mid = low + (high-low)/2;
         if(A[mid] == target) {
            return mid;
         }
         else if(A[mid] > target) {
            high = mid - 1;
            pos = mid;
         }
         else {
            low = mid + 1;
            pos = mid + 1;
         }
      }
      return pos;
   }
};
main(){
   Solution ob;
   vector<int&g; v = {1,3,4,6,6};
   cout << (ob.searchInsert(v,5));
}
{1,3,4,6,6},5
3
C++ Program to Sum the digits of a given number

Here is an example to calculate the sum of digits in C++ language,
 Live Demo
#include<iostream>
using namespace std;
int main() {
   int x, s = 0;
   cout << "Enter the number : ";
   cin >> x;
   while (x != 0) {
      s = s + x % 10;
      x = x / 10;
   }
   cout << "\nThe sum of the digits : "<< s;
}
Enter the number : 236214828
The sum of the digits : 36
In the above program, two variables x and s are declared and s is initialized with zero. The number is entered by the user and when number is not equal to zero, it will sum up the digits of number.
while (x != 0) {
   s = s + x % 10;
   x = x / 10;
}
Excel Move Cells

There are two ways to move cells: Drag and drop or by copy and paste.
Let's start by typing or copying some values that we can work with:
Next, start by marking the area A1:B4:
You can drag and drop the range by pressing and holding the left mouse button on the border. The mouse cursor will change to the move symbol when you hover over the border.
Drag and drop it when you see the symbol.
Move the range to B2:C5 as shown in the picture:
Great! Now you have created more space, so that we have room for more data.
Note: It is important to give context to the data, making the spreadsheet easy to understand. This can be done by adding text which explains the data.
Let's go ahead and give the data more context. Type or copy the following values:
Yes, that is right, we are looking at Pokemons! Giving context to the data is always helpful.
Next, lets see how we can move data by using cut and paste.
Ranges can be moved by cutting and pasting values from one place to another.
Tip: You can cut using the hotkey CTRL+X and paste by CTRL+V. This saves you time.
Mark the range A1:C5
Right click the marked area, and click on the "Cut" command, which has scissors as its icon:
Cutting makes the range white-grey with dotted borders. This indicates that the range is cutted and ready for pasting.

Right click the paste destination B6 and left click the paste icon.
You have successfully cutted and pasted the range from A1:C5 to B6:D10.
Copy and paste works in the same way as cut and paste. The difference is that it does not remove the original cells.
Let's copy the cells back from B6:D10 to A1:C5.
Tip: You can copy using the hotkey CTRL+C and paste by CTRL+V. This saves you time. Try it!
Mark the range B6:D10.
Right click the marked area, and click on the "Copy" command which has two papers as its icon.
Copying gives the range a dotted green border. This indicates that the range is copied and ready for pasting.
Right click the paste destination A1 and left click the paste icon:
The difference between cutting and copying, is that cutting removes the originals, while copying leaves the originals.
Next, let's delete the original data and keep the data in the A1:C5 range.
Select the original cells and remove them by pressing the "Delete" button on the keyboard:
Type the cell in the bottom right corner of the range B2:C5:
C

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.
How to Convert Bytes to Int in Python? - GeeksforGeeks

23 Dec, 2020
A bytes object can be converted to an integer value easily using Python. Python provides us various in-built methds like from_bytes() as well as classes to carry out this interconversion.
A byte value can be interchanged to an int value by using the int.from_bytes() method. This method requires at least Python 3.2 and has the following syntax : 
Syntax: int.from_bytes(bytes, byteorder, *, signed=False)
Parameters:
bytes – A byte object 
byteorder – Determines the order of representation of the integer value. byteorder can have values as either “little” where most significant bit is stored at the end and least at the beginning, or big, where MSB is stored at start and LSB at the end. Big byte order calculates the value of an integer in base 256. 
signed – Default value – False . Indicates whether to represent 2’s complement of a number. 
Returns – an int equivalent to the given byte
The following snippets indicate the conversion of byte to int object. 
Example 1:
Python3
# declaring byte valuebyte_val = b'\x00\x01'  # converting to int# byteorder is big where MSB is at startint_val = int.from_bytes(byte_val, "big")  # printing int equivalentprint(int_val)
Output:
1
Example 2:
Python3
byte_val = b'\x00\x10'  int_val = int.from_bytes(byte_val, "little")  # printing int objectprint(int_val)
Output:
4096
Example 3:
Python3
byte_val = b'\xfc\x00'  # 2's complement is enabled in big # endian byte order formatint_val = int.from_bytes(byte_val, "big", signed="True")  # printing int objectprint(int_val)
Output:
-1024
python-basics
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Enumerate() in Python
Python OOPs Concepts
Read a file line by line in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Stack in Python
Reading and Writing to text files in Python
Python Classes and Objects
sum() function in Python
File.GetLastAccessTime() Method in C# with Examples - GeeksforGeeks

10 Mar, 2021
File.GetLastAccessTime(String) is an inbuilt File class method which is used to return the date and time the specified file or directory was last accessed.Syntax:  
public static DateTime GetLastAccessTime (string path);
Parameter: This function accepts a parameter which is illustrated below:  
path: This is the specified file path.
Exceptions: 
UnauthorizedAccessException: The caller does not have the required permission.
ArgumentException: The path is a zero-length string, contains only white space, or one or more invalid characters as defined by InvalidPathChars.
ArgumentNullException: The path is null.
PathTooLongException: The given path, file name, or both exceed the system-defined maximum length.
NotSupportedException: The path is in an invalid format.
Return Value: Returns the date and time the specified file or directory was last accessed.Below are the programs to illustrate the File.GetLastAccessTime(String) method.Program 1: Before running the below code, a file file.txt is created with some contents shown below: 
 
C#
// C# program to illustrate the usage// of File.GetLastAccessTime(String) method  // Using System and System.IO namespacesusing System;using System.IO;  class GFG {    public static void Main()    {        // Specifying a file        string myfile = @"file.txt";          // Calling GetLastAccessTime() function        DateTime dt = File.GetLastAccessTime(myfile);          // Getting the last access time        Console.WriteLine("The last access time for this file was {0}.", dt);    }}
Executing:  
The last access time for this file was 5/4/2020 12:00:00 AM.
Program 2: Before running the below code, a file was created shown below: 
 
C#
// C# program to illustrate the usage// of File.GetLastAccessTime(String) method  // Using System and System.IO namespacesusing System;using System.IO;  class GFG {    public static void Main()    {        // Specifying a file        string myfile = @"file.txt";          // Setting the date        File.SetLastAccessTime(myfile, new DateTime(2020, 5, 4));          // Calling GetLastAccessTime() function        DateTime dt = File.GetLastAccessTime(myfile);          // Getting the last access time        Console.WriteLine("The last access time for this file was {0}.", dt);    }}
Executing:  
The last access time for this file was 5/4/2020 12:00:00 AM.
arorakashish0911
CSharp-File-Handling
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Extension Method in C#
HashSet in C# with Examples
C# | Inheritance
Partial Classes in C#
C# | Generics - Introduction
Top 50 C# Interview Questions & Answers
C# | How to insert an element in an Array?
Switch Statement in C#
Linked List Implementation in C#
Convert String to Character Array in C#
File.GetLastWriteTime() Method in C# with Examples - GeeksforGeeks

10 Mar, 2021
File.GetLastWriteTime(String) is an inbuilt File class method which is used to return the date and time the specified file or directory was last written to.Syntax:  
public static DateTime GetLastWriteTime (string path);
Parameter: This function accepts a parameter which is illustrated below:  
path: This is the specified file path.
Exceptions: 
UnauthorizedAccessException: The caller does not have the required permission.
ArgumentException: The path is a zero-length string, contains only white space, or one or more invalid characters as defined by InvalidPathChars.
ArgumentNullException: The path is null.
PathTooLongException: The given path, file name, or both exceed the system-defined maximum length.
NotSupportedException: The path is in an invalid format.
Return Value: Returns the date and time the specified file or directory was last written to.Below are the programs to illustrate the File.GetLastWriteTime(String) method.Program 1: Before running the below code, a file file.txt is created with some contents shown below: 
 
C#
// C# program to illustrate the usage// of File.GetLastWriteTime(String) method  // Using System and System.IO namespacesusing System;using System.IO;  class GFG {    public static void Main()    {        // Specifying a file        string myfile = @"file.txt";          // Calling GetLastWriteTime() function        DateTime dt = File.GetLastWriteTime(myfile);          // Getting the last write time        Console.WriteLine("The last write time for this file was {0}.", dt);    }}
Executing:  
The last write time for this file was 4/19/2020 4:43:24 AM.
Program 2: Before running the below code, a file was created shown below: 
 
C#
// C# program to illustrate the usage// of File.GetLastWriteTime(String) method  // Using System and System.IO namespacesusing System;using System.IO;  class GFG {    public static void Main()    {        // Specifying a file        string myfile = @"file.txt";          // Setting the date        File.SetLastWriteTime(myfile, new DateTime(2020, 4, 3));          // Calling GetLastWriteTime() function        DateTime dt = File.GetLastWriteTime(myfile);          // Getting the last write time        Console.WriteLine("The last write time for this file was {0}.", dt);    }}
Executing:  
The last write time for this file was 4/3/2020 12:00:00 AM.
arorakashish0911
CSharp-File-Handling
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Extension Method in C#
HashSet in C# with Examples
C# | Inheritance
Partial Classes in C#
C# | Generics - Introduction
Top 50 C# Interview Questions & Answers
Switch Statement in C#
Convert String to Character Array in C#
C# | How to insert an element in an Array?
Linked List Implementation in C#
Right and Left linear Regular Grammars - GeeksforGeeks

16 Feb, 2021
Regular grammar is a type of grammar that describes a regular language. A regular grammar is a mathematical object, G, which consists of four components, G = (N, E, P, S), where 
N: non-empty, finite set of non-terminal symbols,
E: a finite set of terminal symbols, or alphabet, symbols,
P: a set of grammar rules, each of one having one of the formsA ⇢ aBA⇢ aA ⇢∈, Here ∈=empty string, A, B ∈ N, a ∈ ∑
A ⇢ aB
A⇢ a
A ⇢∈, Here ∈=empty string, A, B ∈ N, a ∈ ∑
S ∈ N is the start symbol.
This grammar can be of two forms:
Right Linear Regular GrammarLeft Linear Regular Grammar
Right Linear Regular Grammar
Left Linear Regular Grammar
In this type of regular grammar, all the non-terminals on the right-hand side exist at the rightmost place, i.e; right ends.
Examples :
A ⇢ a, A ⇢ aB, A ⇢ ∈
where,
A and B are non-terminals,
a is terminal, and
∈ is empty string
S ⇢ 00B | 11S
B ⇢ 0B | 1B | 0 | 1
where,
S and B are non-terminals, and
0 and 1 are terminals
In this type of regular grammar, all the non-terminals on the right-hand side exist at the leftmost place, i.e; left ends.
A ⇢ a, A ⇢ Ba, A ⇢ ∈
where,
A and B are non-terminals,
a is terminal, and
∈ is empty string
S ⇢ B00 | S11
B ⇢ B0 | B1 | 0 | 1
where
S and B are non-terminals, and
0 and 1 are terminals
In this type of conversion, we have to shift all the left-handed non-terminals to right as shown in example given below:
               Left linear                       Right linear 
                      
                 A -> Ba                           A -> abaB     
                 B -> ab                           B -> epsilon   
                                        OR
                                            A -> abB
                                            B -> a
                                                                                                
So, this can be done to give multiple answers. Example explained above have multiple answers other than the given once.
In this type of conversion, we have to shift all the right-handed non-terminals to left as shown in example given below:
               Right linear                      Left linear
                     
                 A -> aB                             A -> Baba  
                 B -> ab                             B -> epsilon  
                                                 OR
                                                     A -> Bab
                                                     B -> a
 So, this can be done to give multiple answers. Example explained above have multiple answers other than the given once.
Compiler Design
GATE CS
Theory of Computation & Automata
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Directed Acyclic graph in Compiler Design (with examples)
S - attributed and L - attributed SDTs in Syntax directed translation
Issues in the design of a code generator
Error Handling in Compiler Design
Error detection and Recovery in Compiler
Layers of OSI Model
ACID Properties in DBMS
TCP/IP Model
Types of Operating Systems
Normal Forms in DBMS
TCS Placement Paper | Email Writing Question 1 - GeeksforGeeks

21 May, 2019
Pre-requisite: Procedure to E-mail WritingThis is a TCS model placement email-writing question. It covers the important directions along with a sample solution to the question.
Directions:
Use all the phrases given.Minimum words should be 50 otherwise your email cannot be validated.Addressing and signing should be done as in the question given.Common grammatical rules, punctuation should be according to standard English.You can use your own phrases along with the phrases given.
Use all the phrases given.
Minimum words should be 50 otherwise your email cannot be validated.
Addressing and signing should be done as in the question given.
Common grammatical rules, punctuation should be according to standard English.
You can use your own phrases along with the phrases given.
Question:As a member of your residential society, write an email to the inspector of the local Police station, Mr.Agarwal, informing him about miscreants who ride their bikes rashly every evening outside your society. Sign the email as Shyam.
Phrases:
residential area - ride - rashly - children - play - elderly - walk - grocery shop - 
across the road - dangerous - accidents - nuisance - action - immediately.
Solution – Sample E-mail:
Dear Mr Agarwal,
I am a resident of Lajpat Nagar and on behalf of the society, would like to bring to your kind attention regarding the rash driving during the evening hours in the residential area of the society. The evening is the time when all the children come out to play and the elderly commences there evening walk. Being a residential area, there is a grocery shop across the street and now and then people walk across the road to buy groceries. For many days, the rash driving of miscreants is causing dangerous problems for the people, leading to accidents.
This is causing a constant nuisance to the people and action must be taken to curb this problem immediately.
Yours sincerely,Shyam.
Note: You can write your own versions of e-mail keeping in mind the points needed to be taken care of while an e-mail. Refer Procedure to E-mail Writing.
interview-preparation
placement preparation
TCS
Placements
TCS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Top 20 Puzzles Commonly Asked During SDE Interviews
Codenation Recruitment Process
Must Do Questions for Companies like TCS, CTS, HCL, IBM ...
Minimum changes required to make all Array elements Prime
Progressions (AP, GP, HP)
Work and Wages
Permutation and Combination
How to Prepare for HR Interviews
Interview Preparation
Puzzle | 50 red marbles and 50 blue marbles
p5.js | dist() Function - GeeksforGeeks

17 Jan, 2020
The dist() function calculates the Euclidean distance in 2D or 3D. Means the p5.js | dist() Function is used to measure the distance between two points in 2D or 3D. Below is the formula for distance in 2D and 3D.
2D formula:
3D formula:
Syntax:
dist(x1, y1, x2, y2)

dist(x1, y1, z1, x2, y2, z2)

Parameters:
x1: These parameters holds the x-coordinate of the first point.
y1: These parameters hold the y-coordinate of the first point.
z1: These parameters hold the z-coordinate of the first point.
x2: These parameters hold the x-coordinate of the second point.
y2: These parameters hold the y-coordinate of the second point.
z2: These parameters hold the z-coordinate of the second point.
Return value: Distance between two points.Example: This example calculates and prints the distance between a fixed point and the cursor.
function setup() {    // Create a canvas    createCanvas(400, 400);}  function draw() {    // set background color    background(50);    // coordinates of the fixed point    var x1 = 200;    var y1 = 200;    // coordinates of the cursor    var x2 = mouseX;    var y2 = mouseY;    // set line color and weight    stroke(255);    strokeWeight(2);    // draw a line connecting 2 points    line(x1, y1, x2, y2);    fill("red");    // draw a circle centered at each point    ellipse(x1, y1, 10);    ellipse(x2, y2, 10);    // calculate the distance between 2 points    d = dist(x1, y1, x2, y2);    noStroke();    fill("lightgreen");    // set text size and alignment    textSize(20);    textAlign(CENTER);    // display the distance calculated    text("distance = "+ str(d), 200, 350);}
Output:
Online editor: https://editor.p5js.org/Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
Reference: https://p5js.org/reference/#/p5/dist
ManasChhabra2
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
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
How to calculate the number of days between two dates in javascript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Create Pandas Series using NumPy functions - GeeksforGeeks

18 Dec, 2018
Pandas Series is a one-dimensional labeled array capable of holding data of any type (integer, string, float, python objects, etc.).
Let’s see how can we create a Pandas Series using different numpy functions.
Code #1: Using numpy.linspace()
# import pandas and numpyimport pandas as pdimport numpy as np  # series with numpy linspace() ser1 = pd.Series(np.linspace(3, 33, 3))print(ser1)  # series with numpy linspace()ser2 = pd.Series(np.linspace(1, 100, 10))print("\n", ser2)  
Output: 
Code #2: Using np.random.normal() and random.rand() method.
# import pandas and numpyimport pandas as pdimport numpy as np  # series with numpy random.normalser3 = pd.Series(np.random.normal())print(ser3)  # series with numpy random.normalser4 = pd.Series(np.random.normal(0.0, 1.0, 5))print("\n", ser4)  # series with numpy random.randser5 = pd.Series(np.random.rand(10))print("\n", ser5)
Output: 
Code #3: Using numpy.repeat()
# import pandas and numpyimport pandas as pdimport numpy as np    # series with numpy random.repeatser = pd.Series(np.repeat(0.08, 7))print("\n", ser)
Output:
pandas-series-program
Python pandas-series
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
How to Install PIP on Windows ?
Read a file line by line in Python
Enumerate() in Python
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python program to convert a list to string
Create a Pandas DataFrame from Lists
Reading and Writing to text files in Python
*args and **kwargs in Python
Tryit Editor v3.7

HTML Style guide
Tryit: HTML with no head element
C++ Stack Library - stack() Function

The C++ copy constructor std::stack::stack() constructs a stack with copy of each elements present in another stack.
Following is the declaration for std::stack::stack() constructor form std::stack header.
template <class Alloc>
stack (const stack& x, const Alloc& alloc);

x − Another stack object of same type.
x − Another stack object of same type.
alloc − Allocator object.
alloc − Allocator object.
Constructor never returns value.
This member function never throws exception.
Linear i.e. O(n)
The following example shows the usage of std::stack::stack() constructor.
#include <iostream>
#include <stack>

using namespace std;

int main(void) {   
   stack<int> s1;

   for (int i = 0; i < 5; ++i)
      s1.push(i + 1);

   stack<int> s2(s1);

   cout << "Contents of stack s2" << endl;
   while (!s2.empty()) {
      cout << s2.top() << endl;
      s2.pop();
   }

   return 0;
}
Let us compile and run the above program, this will produce the following result −
Contents of stack s2
5
4
3
2
1

 Print
 Add Notes
 Bookmark this page
Java ResultSet getRow() method with example

When we execute certain SQL queries (SELECT query in general) they return tabular data.
The java.sql.ResultSet interface represents such tabular data returned by the SQL statements.
i.e. the ResultSet object holds the tabular data returned by the methods that execute the statements which quires the database (executeQuery() method of the Statement interface in general).
The ResultSet object has a cursor/pointer which points to the current row. Initially this cursor is positioned before first row.
The getRow() method of the ResultSet interface retrieves the current row number/position of the ResultSet pointer.
This method returns an integer value representing the current row number to which the ResultSet pointer points to.
Let us create a table with name MyPlayers in MySQL database using CREATE statement as shown below −
CREATE TABLE MyPlayers(
   ID INT,
   First_Name VARCHAR(255),
   Last_Name VARCHAR(255),
   Date_Of_Birth date,
   Place_Of_Birth VARCHAR(255),
   Country VARCHAR(255),
   PRIMARY KEY (ID)
);
Now, we will insert 7 records in MyPlayers table using INSERT statements −
insert into MyPlayers values(1, 'Shikhar', 'Dhawan', DATE('1981-12-05'), 'Delhi', 'India');
insert into MyPlayers values(2, 'Jonathan', 'Trott', DATE('1981-04-22'), 'CapeTown', 'SouthAfrica');
insert into MyPlayers values(3, 'Kumara', 'Sangakkara', DATE('1977-10-27'), 'Matale', 'Srilanka');
insert into MyPlayers values(4, 'Virat', 'Kohli', DATE('1988-11-05'), 'Delhi', 'India');
insert into MyPlayers values(5, 'Rohit', 'Sharma', DATE('1987-04-30'), 'Nagpur', 'India');
insert into MyPlayers values(6, 'Ravindra', 'Jadeja', DATE('1988-12-06'), 'Nagpur', 'India');
insert into MyPlayers values(7, 'James', 'Anderson', DATE('1982-06-30'), 'Burnley', 'England');
Following JDBC program establishes connection with the database, retrieves the contents of the table MyPlayers into a ResultSet object, retrieves the current position of the cursor using the getRow() method.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class ResultSet_getRow {
   public static void main(String args[]) throws SQLException {
      //Registering the Driver
      DriverManager.registerDriver(new com.mysql.jdbc.Driver());
      //Getting the connection
      String mysqlUrl = "jdbc:mysql://localhost/mydatabase";
      Connection con = DriverManager.getConnection(mysqlUrl, "root", "password");
      System.out.println("Connection established......");
      //Creating the Statement
      Statement stmt = con.createStatement();
      //Query to retrieve records
      String query = "Select * from MyPlayers";
      //Executing the query
      ResultSet rs = stmt.executeQuery(query);
      //Moving the pointer to 5th position
      rs.absolute(5);
      //Moving the cursor from default position to 1st row.
      int current_row_number = rs.getRow();
      //Retrieving the current row number.
      System.out.println("Current row number: "+current_row_number);
   }
}
Connection established......
Current row number: 5
How to install the PowerShell Active Directory module?

To install the active directory module using PowerShell, you need Remote Server Administrator Tools (RSAT) on the server. It should be available in the Roles and Features section of the windows server operating system as shown below and you can enable it from the GUI as well.
If you can’t find the RSAT then you can download it from the below location, appropriate to your OS version.
https://www.microsoft.com/en-us/download/details.aspx?id=45520
Once you have the RSAT tool available in your system, you can use the PowerShell command to enable this feature. To get the Active Directory tools features available in the system, use the below command.
Get-WindowsFeature RSAT-AD*
We need RSAT-AD-Tools on the windows system and we will include all sub-features. You can also other AD tools as per your requirement.
Get-WindowsFeature RSAT-AD-Tools | Install-WindowsFeature -IncludeAllSubFeature
You can confirm if the AD tool is installed properly or not by running the dsa.msc command from Run or PowerShell Console. It will open AD MMC.
To install this feature on the remote computer, you can use -ComputerName parameter as shown in the below example,
Install-WindowsFeature RSAT-AD-Tools -ComputerName Test1-Win2k16 - IncludeAllSubFeature
Majority Element in Java

Let’s suppose we have given an array of integers. The task is to find the index of a particular element in the given array. For example,
Input-1 −
N = 8
A[ ] = { 1,2,4,3,3,1,1,5}
Output −
1
Explanation − In the given array of integers, the most appearing number is ‘1’. Thus the output is ‘1’.
Input-2 −
N = 6
A[ ] = {1,5,4,4,1,1}
Output −
1
Explanation − In the given array of integers, the most appearing number is ‘1’. Thus we can return the output ‘1’.
The given array contains multiple integers in which we have to find the most frequent element present in the array. To solve this problem in linear time O(n) and Linear Space O(n) we can use the approach of a hashmap.
In this approach, we will create an unordered map(STL Library) consist of key-value pair in which the key will be an element and the Value will be the occurrence of the element. While traversing through the map we will find the maximum occurrence of the number and return the number as Output.
Take Input an array of size N
Take Input an array of size N
An Integer function maxOccurrence(int A[], int size) takes an array and its size as an input and returns the numbers with maximum frequency.
An Integer function maxOccurrence(int A[], int size) takes an array and its size as an input and returns the numbers with maximum frequency.
Creating a hashmap of all the elements of the array by taking the key as an element and value as its frequency.
Creating a hashmap of all the elements of the array by taking the key as an element and value as its frequency.
Iterating over the map and checking if any of the elements having the most frequency then return the result as the number. Otherwise, if there is not any number present in the array then return ‘-1’.
Iterating over the map and checking if any of the elements having the most frequency then return the result as the number. Otherwise, if there is not any number present in the array then return ‘-1’.
import java.util.Scanner;
import java.util.Map;
import java.util.HashMap;
class Majority_Element{
   public static int checkMajorityElement(int arr[], int N){
      Map<Integer, Integer> mp = new HashMap<Integer, Integer>();
      for (int i = 0; i < N; i++){
         if (mp.containsKey(arr[i]))
            mp.put(arr[i], mp.get(arr[i]) + 1);
         else
            mp.put(arr[i], 1);
      }
      for (Map.Entry<Integer, Integer> entry : mp.entrySet()){
         if (entry.getValue() > (N / 2))
            return entry.getKey();
      }
      return -1;
   }
   public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter size of array:");
      int N = 6;
      int arr[] = {2,1,1,2,2,2};
      System.out.println("Enter elements of array:");
      for (int i = 0; i < N; i++)
         arr[i] = sc.nextInt();
      int ans = checkMajorityElement(arr, N);
      if (ans != -1)
         System.out.println("Majority Element is: " + ans);
      else
         System.out.println("No majority element in array");
   }
}
Running the above code will generate the output as,
Enter size of array: 6
Enter elements of array: 2 1 1 2 2 2
Majority Element is: 2
sha1() function in PHP

The sha1() function in PHP is used to calculate the sha1 hash of a string. Let us first see what is SHA-1 −
The US Secure Hash Algorithm 1 − "SHA-1 produces a 160-bit output called a message digest. The message digest can then, for example, be input to a signature algorithm which generates or verifies the signature for the message. Signing the message digest rather than the message often improves the efficiency of the process because the message digest is usually much smaller in size than the message. The same hash algorithm must be used by the verifier of a digital signature as was used by the creator of the digital signature."
-- Ref − RFC 3174
sha1(str, raw)
str  − Specify the string. Required.
str  − Specify the string. Required.
raw  − A boolean value that specifies hex or binary output format. Optional.
raw  − A boolean value that specifies hex or binary output format. Optional.
TRUE  − Raw 20 character binary format
TRUE  − Raw 20 character binary format
FALSE  − 40 character hex number
FALSE  − 40 character hex number
The sha1() function returns the calculated SHA-1 hash on success, or FALSE on failure.
The following is an example −
 Live Demo
<?php
$s = "Welcome";
echo sha1($s);
?>
ca4f9dcf204e2037bfe5884867bead98bd9cbaf8
The following is an example −
 Live Demo
<?php
$s = "Welcome!";
echo sha1($s);
if (sha1($s) == "ca4f9dcf204e2037bfe5884867bead98bd9cbaf8") {
   echo "<br>Hello Welcome!";
   exit;
}
?>
e52e5e6cd50ef4de30d8a4fafbbfab41180cc200
\diagup - Tex Command

\diagup - Used to draw diagonal up symbol.
{ \diagup }
\diagup command draws diagonal up symbol.

\diagup

╱



\diagup

╱


\diagup

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
smbget - Unix, Linux Command

This tool is part of the
samba(7)
suite.


smbget is a simple utility with wget-like semantics, that can download files from SMB servers. You can specify the files you would like to download on the command-line.


The files should be in the smb-URL standard, e.g. use smb://host/share/file for the UNC path
\\\\HOST\\SHARE\\file.


-a, --guest
Work as user guest


-r, --resume
Automatically resume aborted files


-R, --recursive
Recursively download files


-u, --username=STRING
Username to use


-p, --password=STRING
Password to use


-w, --workgroup=STRING
Workgroup to use (optional)


-n, --nonprompt
Don't ask anything (non-interactive)


-d, --debuglevel=INT
Debuglevel to use


-D, --dots
Show dots as progress indication


-P, --keep-permissions
Set same permissions on local file as are set on remote file.


-o, --outputfile
Write the file that is being downloaded to the specified file. Can not be used together with -R.


-O, --stdout
Write the file that is being downloaded to standard output.


-f, --rcfile
Use specified rcfile. This will be loaded in the order it was specified - e.g. if you specify any options before this one, they might get overriden by the contents of the rcfile.


-q, --quiet
Be quiet


-v, --verbose
Be verbose


-b, --blocksize
Number of bytes to download in a block. Defaults to 64000.


-?, --help
Show help message


--usage
Display brief usage message


SMB URL's should be specified in the following format:





smb://[[[domain;]user[:password@]]server[/share[/path[/file]]]]





smb:// means all the workgroups





smb://name/ means, if name is a workgroup, all the servers in this workgroup, or if name is a server, all the shares on this server.





# Recursively download 'src' directory
smbget -R smb://rhonwyn/jelmer/src
# Download FreeBSD ISO and enable resuming
smbget -r smb://rhonwyn/isos/FreeBSD5.1.iso
# Recursively download all ISOs
smbget -Rr smb://rhonwyn/isos
# Backup my data on rhonwyn
smbget -Rr smb://rhonwyn/


Permission denied is returned in some cases where the cause of the error is unknown (such as an illegally formatted smb:// url or trying to get a directory without -R turned on).


This man page is correct for version 3.0 of the Samba suite.


The original Samba software and related utilities were created by Andrew Tridgell. Samba is now developed by the Samba Team as an Open Source project similar to the way the Linux kernel is developed.


The smbget manpage was written by Jelmer Vernooij.











Advertisements


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Remove duplicates from a sorted array using STL in C++ - GeeksforGeeks

30 May, 2019
Given a sorted array, the task is to remove the duplicate elements from the array using STL in C++
Examples:
Input: arr[] = {2, 2, 2, 2, 2}
Output: arr[] = {2}

Input: arr[] = {1, 2, 2, 3, 4, 4, 4, 5, 5}
Output: arr[] = {1, 2, 3, 4, 5}

Approach:The duplicates of the array can be removed using the unique() function provided in STL.
Below is the implementation of the above approach.
#include <bits/stdc++.h>using namespace std;  // Function to remove duplicate elementsvoid removeDuplicates(int arr[], int n){      // Initialise a vector    // to store the array values    // and an iterator    // to traverse this vector    vector<int> v(arr, arr + n);    vector<int>::iterator it;      // using unique() method to remove duplicates    it = unique(v.begin(), v.end());      // resize the new vector    v.resize(distance(v.begin(), it));      // Print the array with duplicates removed    cout << "\nAfter removing duplicates:\n";    for (it = v.begin(); it != v.end(); ++it)        cout << *it << ", ";    cout << '\n';}  // Driver codeint main(){    int arr[] = { 1, 2, 2, 3, 4, 4, 4, 5, 5 };      int n = sizeof(arr) / sizeof(arr[0]);      // Print array    cout << "\nBefore removing duplicates:\n";    for (int i = 0; i < n; i++)        cout << arr[i] << " ";      // call removeDuplicates()    removeDuplicates(arr, n);      return 0;}
Before removing duplicates:
1 2 2 3 4 4 4 5 5 
After removing duplicates:
1, 2, 3, 4, 5,

cpp-array
STL
C++ Programs
STL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
C++ Program for QuickSort
CSV file management using C++
delete keyword in C++
cin in C++
Generics in C++
Shallow Copy and Deep Copy in C++
C Program to Swap two Numbers
Const keyword in C++
C++ Program to check if a given String is Palindrome or not
Program to implement Singly Linked List in C++ using class
Compare define() vs const in PHP

As we know both define() and const are used to declare a constant in PHP script.
<?php
   const VAR = 'FOO'
   define('VAR', 'FOO');
?>
Let's discuss the difference between these two.
The basic difference between these two is that const defines constants at compile time, whereas define() defines them at run time.
We can't use the const keyword to declare constant in conditional blocks, while with define() we can achieve that.
<?php
   if(){
   const VAR = 'FOO'; // invalid
   }
   if(){
   define('VAR', 'FOO'); //valid
   }
?>
<?php
   if(){
   const VAR = 'FOO'; // invalid
   }
   if(){
   define('VAR', 'FOO'); //valid
   }
?>
const accepts a static scalar(number, string or other constants like true, false, null, __FILE__), whereas define() takes any expression.
consts are always case sensitive, whereas define() allows you to define case insensitive constants by passing true as the third argument.
consts are always case sensitive, whereas define() allows you to define case insensitive constants by passing true as the third argument.
const can also be utilized within a class or interface to declare a class constant or interface constant, while define() can't be utilized for this reason
<?php
   class abc{
      const VAR = 2; // valid
      echo VAR; // valid
   }
// but
   class xyz{
      define('XUV', 2); // invalid
      echo XUV;// invalid
   }
?>
<?php
   class abc{
      const VAR = 2; // valid
      echo VAR; // valid
   }
// but
   class xyz{
      define('XUV', 2); // invalid
      echo XUV;// invalid
   }
?>
The above example shows that we can declare constant inside the class with the const keyword but define() can't be used for declaring constant inside a class.
XSLT <sort>

<xsl:sort> tag specifies a sort criteria on the nodes.
Following is the syntax declaration of <xsl:sort> element.
<xsl:sort 
   select = string-expression  
   lang = { nmtoken } 
   data-type = { "text" | "number" | QName } 
   order = { "ascending" | "descending" } 
   case-order = { "upper-first" | "lower-first" } > 
</xsl:sort> 

select
Sorting key of the node.
lang
Language alphabet used to determine sort order.
data-type
Data type of the text.
order
Sorting order. Default is "ascending".
case-order
Sorting order of string by capitalization. Default is "upper-first".
This example creates a table of <student> element with its attribute rollno and its child <firstname>, <lastname>, <nickname>, and <marks> by iterating over each student sort them by first name.
students.xml
<?xml version = "1.0"?> 
<?xml-stylesheet type = "text/xsl" href = "students.xsl"?> 
<class> 
   <student rollno = "393"> 
      <firstname>Dinkar</firstname> 
      <lastname>Kad</lastname> 
      <nickname>Dinkar</nickname> 
      <marks>85</marks> 
   </student> 
   <student rollno = "493"> 
      <firstname>Vaneet</firstname> 
      <lastname>Gupta</lastname> 
      <nickname>Vinni</nickname> 
      <marks>95</marks> 
   </student> 
   <student rollno = "593"> 
      <firstname>Jasvir</firstname> 
      <lastname>Singh</lastname> 
      <nickname>Jazz</nickname> 
      <marks>90</marks>
   </student>
</class>
students.xsl
<?xml version = "1.0" encoding = "UTF-8"?> 
<xsl:stylesheet version = "1.0" 
   xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">    
   <xsl:template match = "/"> 
      <html> 
         <body> 
            <h2>Students</h2> 
            <table border = "1"> 
               <tr bgcolor = "#9acd32"> 
                  <th>Roll No</th> 
                  <th>First Name</th> 
                  <th>Last Name</th> 
                  <th>Nick Name</th> 
                  <th>Marks</th> 
               </tr> 
					
               <xsl:for-each select = "class/student"> 
					
                  <xsl:sort select = "firstname"/> 
                  <tr> 
                     <td><xsl:value-of select = "@rollno"/></td> 
                     <td><xsl:value-of select = "firstname"/></td> 
                     <td><xsl:value-of select = "lastname"/></td> 
                     <td><xsl:value-of select = "nickname"/></td> 
                     <td><xsl:value-of select = "marks"/></td> 
                  </tr> 
               </xsl:for-each> 
            </table>
         </body>
      </html>
   </xsl:template>
</xsl:stylesheet>
 Print
 Add Notes
 Bookmark this page
Get the datatypes of columns of a Pandas DataFrame - GeeksforGeeks

10 Aug, 2021
Let us see how to get the datatypes of columns in a Pandas DataFrame. TO get the datatypes, we will be using the dtype() and the type() function.Example 1 :  
python
# importing the moduleimport pandas as pd  # creating a DataFrame   dictionary = {'Names':['Simon', 'Josh', 'Amen', 'Habby',                       'Jonathan', 'Nick', 'Jake'],              'Countries':['AUSTRIA', 'BELGIUM', 'BRAZIL',                           'JAPAN', 'FRANCE', 'INDIA', 'GERMANY'],              'Boolean':[True, False, False, True,                         True, False, True],              'HouseNo':[231, 453, 723, 924, 784, 561, 403],              'Location':[12.34, 45.67, 03.45, 17.23,                          83.12, 90.45, 84.34]}table = pd.DataFrame(dictionary, columns = ['Names', 'Countries',                                            'Boolean', 'HouseNo', 'Location'])  print("Data Types of The Columns in Data Frame")display(table.dtypes)  print("Data types on accessing a single column of the Data Frame ")print("Type of Names Column : ", type(table.iloc[:, 0]))print("Type of HouseNo Column : ", type(table.iloc[:, 3]), "\n")  print("Data types of individual elements of a particular columns Data Frame ")print("Type of Names Column Element : ", type(table.iloc[:, 0][1]))print("Type of Boolean Column Element : ", type(table.iloc[:, 2][2]))print("Type of HouseNo Column Element : ", type(table.iloc[:, 3][4]))print("Type of Location Column Element : ", type(table.iloc[:, 4][0]))
Output
From the Output we can observe that on accessing or getting a single column separated from DataFrame its type gets converted to a Pandas Series type irrespective of the data type present in that series. On accessing the individual elements of the pandas Series we get the data is stored always in the form of numpy.datatype() either numpy.int64 or numpy.float64 or numpy.bool_ thus we observed that the Pandas data frame automatically typecast the data into the NumPy class format.
Example 2 :  
Python3
# importing the moduleimport pandas as pd  # creating a DataFrame   data = {'Name' : ['Jai', 'Princi', 'Gaurav', 'Anuj'],        'Age' : [27, 24, 22, 32],        'Address' : ['Delhi', 'Kanpur', 'Allahabad', 'Kannauj'],        'Qualification' : ['Msc', 'MA', 'MCA', 'Phd']}table = pd.DataFrame(data)  print("Data Types of The Columns in Data Frame")display(table.dtypes)
sweetyty
Python pandas-dataFrame
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 ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Selecting rows in pandas DataFrame based on conditions
Create a directory in Python
Python | Pandas dataframe.groupby()