code-rag-bench/online-tutorials huggingface dataset:
How to get html with javascript rendered sourcecode by using Selenium?

We can get HTML with JavaScript rendered source code by using Selenium webdriver. Selenium can execute JavaScript commands with the help of the executeScript method.
JavaScript command to be executed is passed as a parameter to the method. To obtain the HTML, with JavaScript, we shall pass return document.getElementsByTagName('html')[0].innerHTML as a parameter to the executeScript method.
JavascriptExecutor j = (JavascriptExecutor) driver;
String s = (String) j.executeScript
(return document.getElementsByTagName('html')[0].innerHTML");
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
public class HTmlSrcJS{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver",
      "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.get("https://www.tutorialspoint.com/index.htm ");
      //Javascript Executor
      JavascriptExecutor j = (JavascriptExecutor) driver;
      String s = (String) j.executeScript
      (return document.getElementsByTagName('html')[0].innerHTML");
      System.out.println(s);
      driver.quit();
   }
}
To obtain the HTML, with JavaScript, we can also pass return document.body.innerHTML as a parameter to the executeScript method.
JavascriptExecutor j = (JavascriptExecutor) driver;
String s = (String) j.executeScript
(return document.body.innerHTML");
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
public class HTmlSrcBodyJS{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver",
      "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.get("https://www.tutorialspoint.com/index.htm ");
      //Javascript Executor
      JavascriptExecutor j = (JavascriptExecutor) driver;
      String s = (String) j.executeScript
      (return document.body.innerHTML");
      System.out.println(s);
      driver.quit();
   }
}
VBScript - Strings

Strings are a sequence of characters, which can consist of alphabets or numbers or special characters or all of them. A variable is said to be a string if it is enclosed within double quotes " ".
variablename = "string"

str1 = "string"   ' Only Alphabets
str2 = "132.45"   ' Only Numbers
str3 = "!@#$;*"   ' Only Special Characters
Str4 = "Asc23@#"  ' Has all the above
There are predefined VBScript String functions, which help the developers to work with the strings very effectively. Below are String methods that are supported in VBScript. Please click on each one of the methods to know in detail.

    63 Lectures 
     4 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page
How to Convert Decimal to Binary, Octal, and Hexadecimal using Python?

Python provides straightforward functions to convert Decimal to Binary, Octal, and Hexadecimal. These functions are −
Binary: bin()
Octal: oct()
Hexadecimal: hex()
You can use these functions as follows to get the corresponding representation −
decimal = 27

print(bin(decimal),"in binary.")
print(oct(decimal),"in octal.")
print(hex(decimal),"in hexadecimal.")
This will give the output −
0b11011 in binary.
0o33 in octal.
0x1b in hexadecimal.
Wand line() function in Python - GeeksforGeeks

09 Feb, 2022
line() is another drawing function present in wand.drawing module. As the name implies line() function is used to draw a line in the image. line() function only need two arguments that are start and end point of the line that we want to draw. 
Syntax :  
wand.drawing.line(start, end)
Parameters : 
Example #1: 
Python3
# Import required objects from wand modulesfrom wand.image import Imagefrom wand.drawing import Drawingfrom wand.color import Color # generate object for wand.drawingwith Drawing() as draw:    # set stroke color    draw.stroke_color = Color('green')    # set width for stroke    draw.stroke_width = 1    draw.line(( 50, 50),  # Stating point             ( 150, 150))  # Ending point    with Image(width = 200,               height = 200,               background = Color('white')) as img:        # draw shape on image using draw() function        draw.draw(img)        img.save(filename ='line.png')
Output : 
Example #2: Draw a line on a pre-existing image.Source Image: 
Python3
# Import required objects from wand modulesfrom wand.image import Imagefrom wand.drawing import Drawingfrom wand.color import Color # generate object for wand.drawingwith Drawing() as draw:    # set stroke color    draw.stroke_color = Color('white')     # set width for stroke    draw.stroke_width = 1    with Image(filename = "gog.png") as img:        draw.line((( img.height)/2, 0),  # Stating point                   ( 0, (img.width)/2))  # Ending point         # draw shape on image using draw() function        draw.draw(img)        img.save(filename ='line2.png')
Output : 
akshaysingh98088
adnanirshad158
Python-wand
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 Convert Python Dictionary To JSON?
Check if element exists in list in Python
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
Java Program for Iterative Quick Sort - GeeksforGeeks

04 Dec, 2018
// Java implementation of iterative quick sortclass IterativeQuickSort {    void swap(int arr[], int i, int j)    {        int t = arr[i];        arr[i] = arr[j];        arr[j] = t;    }      /* This function is same in both iterative and       recursive*/    int partition(int arr[], int l, int h)    {        int x = arr[h];        int i = (l - 1);          for (int j = l; j <= h - 1; j++) {            if (arr[j] <= x) {                i++;                // swap arr[i] and arr[j]                swap(arr, i, j);            }        }        // swap arr[i+1] and arr[h]        swap(arr, i + 1, h);        return (i + 1);    }      // Sorts arr[l..h] using iterative QuickSort    void QuickSort(int arr[], int l, int h)    {        // create auxiliary stack        int stack[] = new int[h - l + 1];          // initialize top of stack        int top = -1;          // push initial values in the stack        stack[++top] = l;        stack[++top] = h;          // keep popping elements until stack is not empty        while (top >= 0) {            // pop h and l            h = stack[top--];            l = stack[top--];              // set pivot element at it's proper position            int p = partition(arr, l, h);              // If there are elements on left side of pivot,            // then push left side to stack            if (p - 1 > l) {                stack[++top] = l;                stack[++top] = p - 1;            }              // If there are elements on right side of pivot,            // then push right side to stack            if (p + 1 < h) {                stack[++top] = p + 1;                stack[++top] = h;            }        }    }      // A utility function to print contents of arr    void printArr(int arr[], int n)    {        int i;        for (i = 0; i < n; ++i)            System.out.print(arr[i] + " ");    }      // Driver code to test above    public static void main(String args[])    {        IterativeQuickSort ob = new IterativeQuickSort();        int arr[] = { 4, 3, 5, 2, 1, 3, 2, 3 };        ob.QuickSort(arr, 0, arr.length - 1);        ob.printArr(arr, arr.length);    }}/*This code is contributed by Rajat Mishra */
1 2 2 3 3 3 4 5

The above mentioned optimizations for recursive quick sort can also be applied to iterative version.
1) Partition process is same in both recursive and iterative. The same techniques to choose optimal pivot can also be applied to iterative version.
2) To reduce the stack size, first push the indexes of smaller half.
3) Use insertion sort when the size reduces below a experimentally calculated threshold.
Please refer complete article on Iterative Quick Sort for more details!
Java Programs
Sorting
Sorting
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Iterate Over the Characters of a String in Java
How to Get Elements By Index from HashSet in Java?
Java Program to Write into a File
Java Program to Find Sum of Array Elements
How to Replace a Element in Java ArrayList?
Methods to concatenate string in C/C++ with Examples - GeeksforGeeks

20 Feb, 2019
There are various ways to concatenate strings. We will discuss each one by one.
Method 1: Using strcat() function.
The strcat() function is defined in “string.h” header file.
Syntax:
char * strcat(char * init, const char * add)

The init and add string should be of character array(char*). This function concatenates the added string to the end of the init string.
Example:
#include <bits/stdc++.h>using namespace std;  int main(){    char init[] = "this is init";    char add[] = " added now";      // concatenating the string.    strcat(init, add);      cout << init << endl;      return 0;}
this is init added now

Method 2: Using append() function.
Syntax:
string& string::append (const string& str)

str: the string to be appended.

Here str is the object of std::string class which is an instantiation of the basic_string class template that uses char (i.e., bytes) as its character type. The append function appends the add(variable) string at the end of the init string.
Example:
#include <bits/stdc++.h>using namespace std;  int main(){    string init("this is init");    string add(" added now");      // Appending the string.    init.append(add);      cout << init << endl;    return 0;}
this is init added now

Method 3: Using ‘+’ Operator
Syntax:
string new_string = string init + string add;

This is the most easiest method for concatenation of two string.The + operator simply adds the two string and returns a concatenated string.
Example:
#include <bits/stdc++.h>using namespace std;  int main(){    string init("this is init");    string add(" added now");      // Appending the string.    init = init + add;      cout << init << endl;    return 0;}
this is init added now

cpp-string
C Language
C++
Strings
Strings
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Substring in C++
Left Shift and Right Shift Operators in C/C++
Function Pointer in C
Core Dump (Segmentation fault) in C/C++
rand() and srand() in C/C++
Vector in C++ STL
Initialize a vector in C++ (6 different ways)
Inheritance in C++
Map in C++ Standard Template Library (STL)
C++ Classes and Objects
jQuery | error() Method - GeeksforGeeks

27 Feb, 2019
The error() method in jQuery is used when an element encounters an error that is the element is not loaded correctly. The error() method attaches a function to run when an error event occurs or it triggers the error event.
Syntax:
Addition of function in error event:$(selector).error(function)
$(selector).error(function)
Triggering of error event for some selected elements:$(selector).error()
$(selector).error()
Parameter:
function: This parameter is optional and it specifies the function to be run when the error event occurs.
Example-1:
<!DOCTYPE html><html>  <head>    <title>error() method</title>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">  </script>      <script>        $(document).ready(function() {            $("img").error(function() {                $("img").replaceWith(                  "<h3>Error occurs</h3>");            });        });    </script></head>  <body>    <center>          <h1>Welcome to GeeksforGeeks!.</h1>        <div style="background-color:yellow;">        <img src="https://media.geeksforgeeks.org/wp-content/uploads/20190220214542/a13.png">      </div>        <div style="background-color:green">          <h3> The image will be replaced with specified       text if the image above encounters an error.</h3>          </div>    </center>  </body>  </html>
Output:
Example-2:
<!DOCTYPE html><html>  <head>    <title>error() method</title>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">  </script>    <script>        $(document).ready(function() {            $("img").error(function() {              $("img").replaceWith(               "<h3>Error </h3>");            });        });    </script></head>  <body>    <center>        <div style="background-color:green">            <h1>Welcome to GeeksforGeeks!.          </h1>        </div>        <img src="https://media.geeksforgeeks.org/wp-content/uploads/20190220220257/a22.png"              width="284"              height="113">        <h3>Image is replaced with a specified         text, if error occur in loading.</h3>      </center>  </body>  </html>
Output:
Note: This method was removed in jQuery version 3.0.
jQuery-Methods
Picked
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JQuery | Set the value of an input text field
Form validation using jQuery
How to change selected value of a drop-down list using jQuery?
How to change the background color after clicking the button in JavaScript ?
How to fetch data from JSON file and display in HTML table using jQuery ?
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 ?
How to insert spaces/tabs in text using HTML/CSS?
IntStream forEach() method in Java - GeeksforGeeks

06 Dec, 2018
IntStream forEach(IntConsumer action) performs an action for each element of the stream. IntStream forEach(IntConsumer action) is a terminal operation i.e, it may traverse the stream to produce a result or a side-effect.
Syntax :
void forEach(IntConsumer action)

Parameter : IntConsumer represents an operation that accepts a single int-valued argument and returns no result. This is the primitive type specialization of Consumer for int.
Note : The behavior of this operation is explicitly nondeterministic. Also, for any given element, the action may be performed at whatever time and in whatever thread the library chooses.
Example 1 :
// Java code for IntStream forEach// (IntConsumer action) in Java 8import java.util.*;import java.util.stream.IntStream;  class GFG {      // Driver code    public static void main(String[] args)    {        // Creating an IntStream        IntStream stream = IntStream.of(7, 8, 9, 10);          // Using IntStream.forEach        stream.forEach(System.out::println);    }}
7
8
9
10

Example 2 :
// Java code for IntStream forEach// (IntConsumer action) in Java 8import java.util.*;import java.util.stream.IntStream;  class GFG {      // Driver code    public static void main(String[] args)    {        // Creating an IntStream        IntStream stream = IntStream.range(4, 9);          // Using IntStream.forEach() on sequential stream        stream.forEach(System.out::println);    }}
4
5
6
7
8

Note : For parallel stream, IntStream forEach(IntConsumer action) does not guarantee to respect the encounter order of the stream, as doing so would sacrifice the benefit of parallelism. Below is the example.
Example 3 :
// Java code for IntStream forEach// (IntConsumer action) in Java 8import java.util.*;import java.util.stream.IntStream;  class GFG {      // Driver code    public static void main(String[] args)    {        // Creating an IntStream        IntStream stream = IntStream.range(4, 9);          // Using IntStream.forEach() on parallel stream        stream.parallel().forEach(System.out::println);    }}
6
8
7
5
4

Java - util package
Java-Functions
java-intstream
java-stream
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Generics in Java
Introduction to Java
Comparator Interface in Java with Examples
Internal Working of HashMap in Java
Strings in Java
Timing diagram of MOV Instruction in Microprocessor - GeeksforGeeks

21 Aug, 2019
Problem – Draw the timing diagram of the given instruction in 8085,
MOV B, C 
Given instruction copies the contents of the source register into the destination register and the contents of the source register are not altered.
Example:
MOV B, C
Opcode: MOV 
Operand: B and C 
Bis the destination register and C is the source register whose contents need to be transferred to the destination register.
Algorithm –The instruction MOV B, C is of 1 byte; therefore the complete instruction will be stored in a single memory address. For example:
2000: MOV B, C 
Only opcode fetching is required for this instruction and thus we need 4 T states for the timing diagram. For the opcode fetch the IO/M (low active) = 0, S1 = 1 and S0 = 1.
The timing diagram of MOV instruction is shown below:
In Opcode fetch ( t1-t4 T states ):
00 – lower bit of address where opcode is stored, i.e., 0020 – higher bit of address where opcode is stored, i.e., 20.ALE – provides signal for multiplexed address and data bus. Only in t1 it used as address bus to fetch lower bit of address otherwise it will be used as data bus.RD (low active) – signal is 1 in t1 & t4 as no data is read by microprocessor. Signal is 0 in t2 & t3 because here the data is read by microprocessor.WR (low active) – signal is 1 throughout, no data is written by microprocessor.IO/M (low active) – signal is 1 in throughout because the operation is performing on memory.S0 and S1 – both are 1 in case of opcode fetching.
00 – lower bit of address where opcode is stored, i.e., 00
20 – higher bit of address where opcode is stored, i.e., 20.
ALE – provides signal for multiplexed address and data bus. Only in t1 it used as address bus to fetch lower bit of address otherwise it will be used as data bus.
RD (low active) – signal is 1 in t1 & t4 as no data is read by microprocessor. Signal is 0 in t2 & t3 because here the data is read by microprocessor.
WR (low active) – signal is 1 throughout, no data is written by microprocessor.
IO/M (low active) – signal is 1 in throughout because the operation is performing on memory.
S0 and S1 – both are 1 in case of opcode fetching.
microprocessor
system-programming
Computer Organization & Architecture
microprocessor
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Logical and Physical Address in Operating System
Computer Organization and Architecture | Pipelining | Set 1 (Execution, Stages and Throughput)
Memory Hierarchy Design and its Characteristics
Computer Organization | RISC and CISC
Direct Access Media (DMA) Controller in Computer Architecture
Computer Organization | Instruction Formats (Zero, One, Two and Three Address Instruction)
Interrupts
I/O Interface (Interrupt and DMA Mode)
Computer Organization and Architecture | Pipelining | Set 2 (Dependencies and Data Hazard)
Addressing modes in 8085 microprocessor
GATE | GATE-CS-2003 | Question 90

28 Jun, 2021
RTT = Transmission Time

Transmission Time = Length of packet / Bandwidth
RTT = 2 (d/v) = 2(2000/2×108) 

Therefore to find minimum size of the packet, 
RTT = Length of packet / Bandwidth
Length of packet = RTT x Bandwith
                         = 2(2000/2×108) x 107 = 200bits = 25bytes

Therefore, minimum size of the packet = 25bytes 
Source: http://www.btechonline.org/2012/12/gate-computer-networks-ethernet.htmlQuiz of this Question
GATE-CS-2003
GATE-GATE-CS-2003
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to extract the column headers in a table in Selenium with python?

We can extract the column headers in a table in Selenium. The headers of
a table are represented by <th> tag in html and always in the first row of the table. The rows are identified with <tr> tag in html. A <th> tag’s parent is always a <tr> tag.
The logic is to get all the headers. We shall use the locator xpath and then use find_elements_by_xpath method. The list of headers will be returned. Next we need to compute the size of the list with the help of len method.
driver.find_elements_by_xpath("//table/tbody/tr[1]/th")
The html code snippet of a table header is as described below −
Code Implementation for getting table headers.
from selenium import webdriver
#browser exposes an executable file
#Through Selenium test we will invoke the executable file which will then
#invoke actual browser
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
# to maximize the browser window
driver.maximize_window()
#get method to launch the URL
driver.get("https://www.tutorialspoint.com/plsql/plsql_basic_syntax.htm")
#to refresh the browser
driver.refresh()
# identifying the header from row1 having <th> tag
heads = driver.find_elements_by_xpath("//table/tbody/tr[1]/th")
# len method is used to get the size of that list
print(len(heads))
for h in heads:
   print(h.text)
#to close the browser
driver.close()
How to center the JavaScript alert message box?

To center the JavaScript alert box, you need to use the custom alert box. Under that, style it accordingly and position it to the center. Use the “top” and “left” CSS properties to achieve this. Set them as 50%, but as you can see the button below, so the property to 40% for correct alignment.
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
      <script>
         function functionAlert(msg, myYes) {
            var confirmBox = $("#confirm");
            confirmBox.find(".message").text(msg);
            confirmBox.find(".yes").unbind().click(function() {
               confirmBox.hide();
            });
            confirmBox.find(".yes").click(myYes);
            confirmBox.show();
         }
      </script>
      <style>
         #confirm {
            display: none;
            background-color: #F3F5F6;
            color: #000000;
            border: 1px solid #aaa;
            position: fixed;
            width: 300px;
            height: 100px;
            left: 50%;
            margin-left: -100px;
            padding: 10px 20px 10px;
            box-sizing: border-box;
            text-align: center;
         }
         #confirm button {
            background-color: #FFFFFF;
            display: inline-block;
            border-radius: 12px;
            border: 4px solid #aaa;
            padding: 5px;
            text-align: center;
            width: 60px;
            cursor: pointer;
         }
         #confirm .message {
            text-align: left;
         }
      </style>
   </head>
   <body>
      <div id="confirm">
         <div class="message">This is a warning message.</div>
            <button class="yes">OK</button>
         </div>
      <input type="button" value="Click Me" onclick="functionAlert();" />
   </body>
</html>
C# | Check if two HashSet<T> objects are equal - GeeksforGeeks

01 Feb, 2019
Equals(Object) Method which is inherited from the Object class is used to check if a specified HashSet<T> object is equal to another HashSet<T> object or not.
Syntax:
public virtual bool Equals (object obj);
Here, obj is the object which is to be compared with the current object.
Return Value: This method return true if the specified object is equal to the current object otherwise it returns false.
Below programs illustrate the use of above-discussed method:
Example 1:
// C# program to if a HashSet object// is equal to another HashSet objectusing System;using System.Collections.Generic;  class Geeks {      // Main Method    public static void Main(String[] args)    {          // Creating a HashSet of strings        HashSet<string> mySet = new HashSet<string>();          // Inserting elements in HashSet        mySet.Add("DS");        mySet.Add("C++");        mySet.Add("Java");        mySet.Add("JavaScript");          // Checking whether mySet is        // equal to itself or not        Console.WriteLine(mySet.Equals(mySet));    }}
True

Example 2:
// C# program to if a HashSet object// is equal to another HashSet objectusing System;using System.Collections.Generic;  class Geeks {      // Main Method    public static void Main(String[] args)    {          // Creating a HashSet of strings        HashSet<string> mySet1 = new HashSet<string>();          // Inserting elements in HashSet        mySet1.Add("HTML");        mySet1.Add("CSS");        mySet1.Add("PHP");        mySet1.Add("DBMS");          // Creating a HashSet of integers        HashSet<int> mySet2 = new HashSet<int>();          // Inserting elements in HashSet        for (int i = 0; i < 5; i++) {            mySet2.Add(i * 2);        }          // Checking whether mySet1 is        // equal to mySet2 or not        Console.WriteLine(mySet1.Equals(mySet2));          // Creating a HashSet of integers        HashSet<int> mySet3 = new HashSet<int>();          // Assigning mySet2 to mySet3        mySet3 = mySet2;          // Checking whether mySet3 is        // equal to mySet2 or not        Console.WriteLine(mySet3.Equals(mySet2));    }}
False
True

CSharp-Generic-HashSet
CSharp-Generic-Namespace
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Program to calculate Electricity Bill
C# | Class and Object
Linked List Implementation in C#
Introduction to .NET Framework
C# | How to insert an element in an Array?
How to find the length of an Array in C#
C# | Replace() Method
Lambda Expressions in C#
Main Method in C#
C# | Data Types
How to retrieve CSV file headers using PowerShell?

To retrieve the CSV file headers using PowerShell, we need to use the hidden property PSObject once we use to import the CSV file. We have a CSV file stored at the C:\temp\VMTags.csv and we need to retrieve its headers. The CSV file is as below.
Importing the CSV file,
PS C:\> $csv = Import-Csv C:\Temp\VMTags.csv
PS C:\> $csv

For    Patching_Day Application Owner
---    ------------ ----------- -----
Ansible    Sunday    SecretTag Chirag
Accessing hidden property,
PS C:\> $csv.psobject
We need to use Properties to get our values. We will get all the headers here.
PS C:\> $csv.psobject.Properties | Select Name
Name
----
For
Patching_Day
Application
Owner
To get all the header values,
PS C:\> $csv.psobject.Properties | Select Value
Value
-----
Ansible
Sunday
SecretTag
Chirag
Tryit Editor v3.7

HTML Form elements
Tryit: HTML select more that one
Entity Framework - Index

An index is an on-disk data structure that is based on tables and views. Indexes make the retrieval of data faster and efficient, in most cases. However, overloading a table or view with indexes could unpleasantly affect the performance of other operations such as inserts or updates.
Indexing is the new feature in entity framework where you can improve the performance of your Code First application by reducing the time required to query data from the database.
Indexing is the new feature in entity framework where you can improve the performance of your Code First application by reducing the time required to query data from the database.
You can add indexes to your database using the Index attribute, and override the default Unique and Clustered settings to get the index best suited to your scenario.
You can add indexes to your database using the Index attribute, and override the default Unique and Clustered settings to get the index best suited to your scenario.
Let’s take a look at the following code in which Index attribute is added in Course class for CourseID.
public partial class Course {

   public Course() {
      this.Enrollments = new HashSet<Enrollment>();
   }

   [Index]
   public int CourseID { get; set; }
   public string Title { get; set; }
	
   public int Credits { get; set; }
   public byte[] VersionNo { get; set; }
	
   public virtual ICollection<Enrollment> Enrollments { get; set; }

}
The key created above is non-unique, non-clustered.  There are overloads available to override these defaults −
To make an index a Clustered index, you need to specify IsClustered = true
To make an index a Clustered index, you need to specify IsClustered = true
Similarly, you can also make an index a unique index by specifying IsUnique = true
Similarly, you can also make an index a unique index by specifying IsUnique = true
Let’s take a look at the following C# code where an index is clustered and unique.
public partial class Course {

   public Course() {
      this.Enrollments = new HashSet<Enrollment>();
   }

   [Index(IsClustered = true, IsUnique = true)]
   public int CourseID { get; set; }
   public string Title { get; set; }
	
   public int Credits { get; set; }
   public byte[] VersionNo { get; set; }
	
   public virtual ICollection<Enrollment> Enrollments { get; set; }
}
Index attribute can be used to create a unique index in the database. However, this does not mean that EF will be able to reason about the uniqueness of the column when dealing with relationships, etc. This feature is usually referred to as support for “unique constraints”.

    19 Lectures 
     5 hours 

 Trevoir Williams

    33 Lectures 
     3.5 hours 

 Nilay Mehta

    21 Lectures 
     2.5 hours 

 TELCOMA Global

    89 Lectures 
     7.5 hours 

 Mustafa Radaideh
 Print
 Add Notes
 Bookmark this page
Program to check a number is ugly number or not in Python

Suppose we have a number n, we have to check whether its prime factors only include 2, 3 or 5 or not.
So, if the input is like n = 18, then the output will be True, as 18's prime factors are 2 and 3.
To solve this, we will follow these steps −
if n < 0, thenreturn False
return False
factor := a list with elements [2,3,5]
for each i in factor, dowhile n mod i is same as 0, don := n / i
while n mod i is same as 0, don := n / i
n := n / i
return true when n is same as 1, otherwise false
Let us see the following implementation to get better understanding −
 Live Demo
class Solution:
   def solve(self, n):
      if n < 0:
         return False
      factor = [2,3,5]
      for i in factor:
         while n%i ==0:
            n/=i
      return n==1
ob = Solution()
print(ob.solve(18))
18
True
How to click a button on webpage using selenium ?

26 Nov, 2020
Selenium can automatically click on buttons that appear on a webpage. This article revolves around how to click any button using Selenium in a webpage. In order to do this there are two major steps we have to take :
Find the button.Click on the button.
Find the button.
Click on the button.
We can find the button on the web page by using methods like find_element_by_class_name(), find_element_by_name(), find_element_by_id() etc, following which we can click on it by using the click() method.
Syntax :  
# finding the button using ID
button = driver.find_element_by_id(ID)

# clicking on the button
button.click()
Code : 
Python3
import time# importing webdriver from seleniumfrom selenium import webdriver # Here Chrome  will be useddriver = webdriver.Chrome() # URL of websiteurl = "https://www.geeksforgeeks.org/" # Opening the websitedriver.get(url) # getting the button by class namebutton = driver.find_element_by_class_name("slide-out-btn") # clicking on the buttonbutton.click()
This will click on the button and a popup will be shown. Output – 
 
SamarthiLahiri
selenium
Python
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Default Array Values in Java

24 Jan, 2022
If we don’t assign values to array elements and try to access them, the compiler does not produce an error as in the case of simple variables. Instead, it assigns values that aren’t garbage. 
Below are the default assigned values. 
Example:
Java
// Java program to demonstrate default// values of array elements class ArrayDemo {    public static void main(String[] args)    {        System.out.println("String array default values:");        String str[] = new String[5];        for (String s : str)            System.out.print(s + " ");         System.out.println(            "\n\nInteger array default values:");        int num[] = new int[5];        for (int val : num)            System.out.print(val + " ");         System.out.println(            "\n\nDouble array default values:");        double dnum[] = new double[5];        for (double val : dnum)            System.out.print(val + " ");         System.out.println(            "\n\nBoolean array default values:");        boolean bnum[] = new boolean[5];        for (boolean val : bnum)            System.out.print(val + " ");         System.out.println(            "\n\nReference Array default values:");        ArrayDemo ademo[] = new ArrayDemo[5];        for (ArrayDemo val : ademo)            System.out.print(val + " ");    }}
String array default values:
null null null null null 

Integer array default values:
0 0 0 0 0 

Double array default values:
0.0 0.0 0.0 0.0 0.0 

Boolean array default values:
false false false false false 

Reference Array default values:
null null null null null 
This article is contributed by Twinkle Tyagi. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
nishkarshgandhi
Java-Array-Programs
Java-Arrays
Java
School Programming
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
ArrayList in Java
Python Dictionary
Arrays in C/C++
Introduction To PYTHON
Interfaces in Java
Inheritance in C++
Initialize an Empty Dictionary in Python

13 Nov, 2020
Dictionary in Python is an unordered collection of data values, used to store data values like a map, which unlike other Data Types that hold only a single value as an element, Dictionary holds key:value pair. Key-value is provided in the dictionary to make it more optimized. 
Now, Let’s see the different ways to create an Empty Dictionary.
Method 1: Use of { } symbol.
We can create an empty dictionary object by giving no elements in curly brackets in the assignment statement
Code:
Python3
# Python3 code to demonstrate use of# {} symbol to initialize dictionaryemptyDict = {} # print dictionaryprint(emptyDict) # print length of dictionaryprint("Length:", len(emptyDict)) # print typeprint(type(emptyDict))
{}
Length: 0
<class 'dict'>





Method 2: Use of dict() built-in function.
Empty dictionary is also created by dict() built-in function without any arguments.
Code:
Python3
# Python3 code to demonstrate use of # dict() built-in function to# initialize dictionaryemptyDict = dict() # print dictionaryprint(emptyDict) # print length of dictionaryprint("Length:",len(emptyDict)) # print typeprint(type(emptyDict))
{}
Length: 0
<class 'dict'>





espinozahg
python-dict
Python
python-dict
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list
GATE | GATE-CS-2002 | Question 46

28 Jun, 2021
Which combination of the following features will suffice to characterize an OS as a multi-programmed OS?
(a) More than one program may be loaded into main memory 
   at the same time for execution. 
(b) If a program waits for certain events such as I/O, 
   another program is immediately scheduled for execution. 
(c) If the execution of program terminates, another program 
   is immediately scheduled for execution. 
(A) a(B) a and b(C) a and c(D) a, b and cAnswer: (B)Explanation:
(a) More than one program may be loaded into main memory 
   at the same time for execution. 
True: Only done in a multiprogrammed OS, not in single
       programmed OS

(b) If a program waits for certain events such as I/O, 
   another program is immediately scheduled for execution.
True: Only done in a multiprogrammed OS, not in single
       programmed OS
 
(c) If the execution of program terminates, another program 
   is immediately scheduled for execution. 
False: Done in both Multiprogrammed and single
       programmed OSs
Quiz of this Question
GATE-CS-2002
GATE-GATE-CS-2002
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE CS 2008 | Question 46
GATE | GATE CS 2011 | Question 49
GATE | GATE CS 1996 | Question 38
GATE | GATE-CS-2004 | Question 31
GATE | GATE IT 2006 | Question 20
GATE | GATE-CS-2016 (Set 1) | Question 45
Variable Shadowing in JavaScript

08 Mar, 2021
Block Scoping: To understand shadowing in JavaScript, we need to be clear with the scope first. In computer programming languages, Scope is a certain section/region of the program where a defined variable can have its existence and can be recognized, beyond that it can’t be accessed. In JavaScript, a Block is a compound statement that is defined by curly braces {} and used to combine multiple statements into one statement where JavaScript expects only one statement. And all the variables and functions that can be accessed inside a block are said to be inside that block scope, hence called Block scoped.
For example, let and const variables are stored in separate memory space, so it is called block-scoped but var variables can be accessed outside the block as it is stored in the Global object memory space, hence it is called Global scoped.
Shadowing: Now, when a variable is declared in a certain scope having the same name defined on its outer scope and when we call the variable from the inner scope, the value assigned to the variable in the inner scope is the value that will be stored in the variable in the memory space. This is known as Shadowing or Variable Shadowing. In JavaScript, the introduction of let and const in ECMAScript 6 along with block scoping allows variable shadowing.
Example:
Javascript
function func() {    let a = 'Geeks';          if (true) {        let a = 'GeeksforGeeks';  // New value assigned        console.log(a);     }          console.log(a); func();
Output:
GeeksforGeeks
Geeks
Illegal Shadowing: Now, while shadowing a variable, it should not cross the boundary of the scope, i.e. we can shadow var variable by let variable but cannot do the opposite. So, if we try to shadow let variable by var variable, it is known as Illegal Shadowing and it will give the error as “variable is already defined.” 
Example:
Javascript
function func() {    var a = 'Geeks';    let b = 'Geeks;          if (true) {        let a = 'GeeksforGeeks'; // Legal Shadowing        var b = 'Geeks'; // Illegal Shadowing        console.log(a); // It will print 'GeeksforGeeks'        console.log(b); // It will print error    }}func();
Output:
Identifier 'b' has already been declared
Note: Arrow functions also follow the same scope and variable shadowing rule.
javascript-basics
JavaScript-Questions
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
Roadmap to Learn JavaScript For Beginners
JavaScript | Promises
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Matplotlib.axes.Axes.set_fc() in Python

19 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
The Axes.set_fc() function in axes module of matplotlib library is used to set the facecolor of the Axes.
Syntax: Axes.set_fc(self, color)
Parameters: This method accept only one parameters.color: This parameter accepts the color for the facecolor of the axes.
Returns:This method does not returns any value.
Below examples illustrate the matplotlib.axes.Axes.set_fc() function in matplotlib.axes:
Example 1:
# Implementation of matplotlib function import matplotlib.pyplot as pltimport numpy as np     fig, ax = plt.subplots()  ax.set_fc('# B6ABF0')ax.set_xlabel('x-axis')ax.set_ylabel('y-axis')ax.plot([1, 2, 3], color ="black")  ax.set_title('matplotlib.axes.Axes.set_fc()\ Example\n', fontsize = 12, fontweight ='bold')plt.show()
Output:
Example 2:
# Implementation of matplotlib functionimport numpy as npimport matplotlib.pyplot as plt     t = np.linspace(0.0, 2.0, 201)s = np.sin(2 * np.pi * t)  fig, ax = plt.subplots()ax.set_fc('# 339E17')ax.set_xlabel('x-axis')ax.set_ylabel('y-axis')ax.plot(t, s, )ax.set_title('matplotlib.axes.Axes.set_fc()\ Example\n', fontsize = 12, fontweight ='bold')plt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Create a directory in Python
Batch Script - TASKLIST

This batch command lists tasks, including task name and process id (PID).
Tasklist

@echo off 
Tasklist
The above command will list all the tasks on the current system.
 Print
 Add Notes
 Bookmark this page
How to flip an image (add a mirror effect) with CSS?

Following is the code to flip and image using CSS −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
img:hover {
   transform: scaleX(-1);
   width: 400;
   height: 400;
}
</style>
</head>
<body>
<h1>Flipping an Image Example</h1>
<img src="https://i.picsum.photos/id/551/400/400.jpg">
<h1>Hover over the above image to see it mirrored</h1>
</body>
</html>
The above code will produce the following output −
On hovering the image the image will be mirrored as follows −
How to create an unordered list with image bullets in HTML?

To create unordered list in HTML, use the <ul> tag. The unordered list starts with the <ul> tag. The list item starts with the <li> tag and will be marked as disc, square, circle, etc. The default is bullets, which is small black circles. If you want to create an unordered list with image bullets, use the CSS property list-style-image.
We will be using the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <ul> tag, with the CSS property list-style-image to add image bullets to an unordered list. The URL property sets the image source for the list item. 
Just keep in mind, the usage of style attribute overrides any style set globally. It will override any style set in the HTML <style> tag or external style sheet
You can try to run the following code to set image bullet in an unordered list −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>HTML Unorderd List</title>
   </head>
   <body>
      <h2>Tutorials</h2>
      <p>The list of tutorials:</p>
      <ul style="list-style-image: url('/theme/css/icons/image-editor.png');">
         <li>Java</li>
         <li>C++</li>
         <li>Ruby</li>
      </ul>
   </body>
</html>
Count how many rows have the same value in MySQL?

To count how many rows have the same value using the function COUNT(*) and GROUP BY. The syntax is as follows −
SELECT yourColumName1, count(*) as anyVariableName from yourTableName GROUP BY yourColumName1;
To understand the above syntax, let us first create a table. The query to create a table is as follows −
mysql> create table RowWithSameValue
   −> (
   −> StudentId int,
   −> StudentName varchar(100),
   −> StudentMarks int
   −> );
Query OK, 0 rows affected (0.55 sec)
Insert some records with same value. Here, we have added same marks for more than one student for our example. The query to insert records is as follows −
mysql> insert into RowWithSameValue values(100,'Carol',89);
Query OK, 1 row affected (0.21 sec)

mysql> insert into RowWithSameValue values(101,'Sam',89);
Query OK, 1 row affected (0.15 sec)

mysql> insert into RowWithSameValue values(102,'John',99);
Query OK, 1 row affected (0.12 sec)

mysql> insert into RowWithSameValue values(103,'Johnson',89);
Query OK, 1 row affected (0.15 sec)
Now you can display all records which we inserted above. The query to display all records is as follows −
mysql> select *from RowWithSameValue;
The following is the output −
+-----------+-------------+--------------+
| StudentId | StudentName | StudentMarks |
+-----------+-------------+--------------+
|       100 | Carol       |           89 |
|       101 | Sam         |           89 |
|       102 | John        |           99 |
|       103 | Johnson     |           89 |
+-----------+-------------+--------------+
4 rows in set (0.00 sec)
Implement the syntax we discussed in the beginning to count rows that have the same value −
mysql> SELECT StudentMarks, count(*) as SameValue from RowWithSameValue GROUP BY StudentMarks;
The following is the output that displays count of multiple values −
+--------------+-----------+
| StudentMarks | SameValue |
+--------------+-----------+
|           89 |         3 |
|           99 |         1 |
+--------------+-----------+
2 rows in set (0.00 sec)