code-rag-bench/online-tutorials huggingface dataset:
Python 3 - String title() Method

The title() method returns a copy of the string in which first characters of all the words are capitalized.
Following is the syntax for title() method −
str.title();

NA
This method returns a copy of the string in which first characters of all the words are capitalized.
The following example shows the usage of title() method.
#!/usr/bin/python3

str = "this is string example....wow!!!"
print (str.title())
When we run above program, it produces the following result −
This Is String Example....Wow!!!


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
How to set time zone in a JSP?

The <fmt:setTimeZone> tag is used to copy a time zone object into the specified scoped variable.
The <fmt:setTimeZone> tag has the following attributes −
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<%@ taglib uri = "http://java.sun.com/jsp/jstl/fmt" prefix = "fmt" %>
<html>
   <head>
      <title>JSTL fmt:setTimeZone Tag</title>
   </head>
   <body>
      <c:set var = "now" value = "<%=new java.util.Date()%>" />
      <p>Date in Current Zone: <fmt:formatDate value = "${now}" type = "both" timeStyle = "long" dateStyle = "long" /></p>
      <p>Change Time Zone to GMT-8</p>
      <fmt:setTimeZone value = "GMT-8" />
      <p>Date in Changed Zone: <fmt:formatDate value = "${now}" type = "both" timeStyle = "long" dateStyle = "long" /></p>
   </body>
</html>
The above code will generate the following result −
Date in Current Zone: 23 September 2010 15:21:37 GST
Change Time Zone to GMT-8
Date in Changed Zone: 23 September 2010 03:21:37 GMT-08:00
How to validate a date pattern in JavaScript?

To validate a date pattern in JavaScript, try to run the following code. Here, we will check for correct as well as incorrect dates to validate
Live Demo
<!DOCTYPE html>
<html>
   <body>
   
      <script>
         function validDate(date) {
            var split = date.split('/');
            var date = new Date(split[2] + '/' + split[0] + '/' + split[1]);
            return (date &amp;&amp; (date.getMonth() + 1) == split[0] &amp;&amp; date.getDate() == Number(split[1]) &amp;&amp; date.getFullYear() == Number(split[2]));
         }
         document.write("Valid date: 11/11/2017 = "+validDate('11/11/2017'));
         document.write("<br>Valid date: 18/18/2017 = "+validDate('18/18/2017'));
         document.write("<br>Valid date: 05/09/2017 = "+validDate('05/09/2017'));
      </script>
      
   </body>
</html>
Valid date: 11/11/2017 = true
Valid date: 18/18/2017 = false
Valid date: 05/09/2017 = true
Design Patterns - Proxy Pattern

In proxy pattern, a class represents functionality of another class. This type of design pattern comes under structural pattern.
In proxy pattern, we create object having original object to interface its functionality to outer world.
We are going to create an Image interface and concrete classes implementing the Image interface. ProxyImage is a a proxy class to reduce memory footprint of RealImage object loading.
ProxyPatternDemo, our demo class, will use ProxyImage to get an Image object to load and display as it needs.
Create an interface.
Image.java
public interface Image {
   void display();
}
Create concrete classes implementing the same interface.
RealImage.java
public class RealImage implements Image {

   private String fileName;

   public RealImage(String fileName){
      this.fileName = fileName;
      loadFromDisk(fileName);
   }

   @Override
   public void display() {
      System.out.println("Displaying " + fileName);
   }

   private void loadFromDisk(String fileName){
      System.out.println("Loading " + fileName);
   }
}
ProxyImage.java
public class ProxyImage implements Image{

   private RealImage realImage;
   private String fileName;

   public ProxyImage(String fileName){
      this.fileName = fileName;
   }

   @Override
   public void display() {
      if(realImage == null){
         realImage = new RealImage(fileName);
      }
      realImage.display();
   }
}
Use the ProxyImage to get object of RealImage class when required.
ProxyPatternDemo.java
public class ProxyPatternDemo {
	
   public static void main(String[] args) {
      Image image = new ProxyImage("test_10mb.jpg");

      //image will be loaded from disk
      image.display(); 
      System.out.println("");
      
      //image will not be loaded from disk
      image.display(); 	
   }
}
Verify the output.
Loading test_10mb.jpg
Displaying test_10mb.jpg

Displaying test_10mb.jpg


    102 Lectures 
     10 hours 

 Arnab Chakraborty

    30 Lectures 
     3 hours 

 Arnab Chakraborty

    31 Lectures 
     4 hours 

 Arnab Chakraborty

    43 Lectures 
     1.5 hours 

 Manoj Kumar

    7 Lectures 
     1 hours 

 Zach Miller

    54 Lectures 
     4 hours 

 Sasha Miller
 Print
 Add Notes
 Bookmark this page
Python 3 - List append() Method

The append() method appends a passed obj into the existing list.
Following is the syntax for append() method −
list.append(obj)

obj − This is the object to be appended in the list.
This method does not return any value but updates existing list.
The following example shows the usage of append() method.
#!/usr/bin/python3

list1 = ['C++', 'Java', 'Python']
list1.append('C#')
print ("updated list : ", list1)
When we run above program, it produces the following result −
updated list :  ['C++', 'Java', 'Python', 'C#']


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Changing the Position of List Markers in CSS

The CSS list-style-position property is used to set marker position of list items. The default value for this property is outside which sets the marker outside the list item.
The syntax of CSS list-style-position property is as follows −
Selector {
   list-style-position: /*value*/
}
The following examples illustrate CSS list-style-property −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
li {
   width: 50%;
   margin: 5px;
   font-size: 120%;
   box-shadow: 0 0 3px 1px black;
   background: url("https://www.tutorialspoint.com/dbms/images/dbms.jpg") no-repeat 32px 8px;
   list-style-position: inside;
   padding: 0 0 10px 20px;
}
ol ol li {
   list-style: lower-roman;
   list-style-position: outside;
}
</style>
</head>
<body>
<ol>
<li>Black</li>
<li>
Blue
<ol>
<li>Green</li>
<li>Red</li>
</ol>
</li>
<li>Yellow</li>
<li>Red</li>
</ol>
</body>
</html>
This gives the following output −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
ul {
   width: 200px;
   box-shadow: inset 0 0 6px green;
   list-style-position: outside;
}
ul + ul {
   list-style-type: circle;
   list-style-position: inside;
}
</style>
</head>
<body>
<ul>
<li>demo</li>
<li>demo</li>
<li>demo</li>
</ul>
<ul>
<li>demo</li>
<li>demo</li>
<li>demo</li>
</ul>
</body>
</html>
This gives the following output −
How to change the Y-axis values in a bar plot using ggplot2 in R?

Bar plot is frequently used to analyze the number of times a level of factor variable occurs in a data set and the Y-axis values are crucial to the bar plot. Sometimes these values are not in the form we want, therefore, we want to replace them with the new ones. This can be done with the help of breaks argument of scale_y_continuous function in ggplot2.
Consider the below data frame −
> set.seed(1)
> x<-rpois(50,5)
> df<-data.frame(x)
Loading ggplot2 package −
> library(ggplot2)
Creating the plot without specifying the Y-axis values −
> ggplot(df,aes(x))+
+ geom_bar()
Plotting with new Y-axis values −
> ggplot(df,aes(x))+
+ geom_bar()+
+ scale_y_continuous(breaks=c(0,2,4,6,8,10))
How to populate an array one value at a time by taking input from user in Java?

To read data from user create a scanner class. Read the size of the array to be created from the user using nextInt() method. Create an array with the specified size. In the loop read the values from the user and store in the array created above.
import java.util.Arrays;
import java.util.Scanner;

public class PopulatingAnArray {
   public static void main(String args[]) {
      System.out.println("Enter the required size of the array :: ");
      Scanner s = new Scanner(System.in);
      int size = s.nextInt();
      int myArray[] = new int [size];
      System.out.println("Enter the elements of the array one by one ");
      for(int i=0; i<size; i++) {
         myArray[i] = s.nextInt();
      }
      System.out.println("Contents of the array are: "+Arrays.toString(myArray));
   }
}
Enter the required size of the array ::
5
Enter the elements of the array one by one
78
96
45
23
45
Contents of the array are: [78, 96, 45, 23, 45]
How to catch a divide by zero error in C++?

The following is an example to catch a divide by zero error.
 Live Demo
#include <iostream>
using namespace std;
int display(int x, int y) {
   if( y == 0 ) {
      throw "Division by zero condition!";
   }
   return (x/y);
}
int main () {
   int a = 50;
   int b = 0;
   int c = 0;
   try {
      c = display(a, b);
      cout << c << endl;
   } catch (const char* msg) {
      cerr << msg << endl;
   }
   return 0;
}
Division by zero condition!
In the above program, a function display() is defined with arguments x and y. It is returning x divide by y and throwing an error.
int display(int x, int y) {
   if( y == 0 ) {
      throw "Division by zero condition!";
   }
   return (x/y);
}
In the main() function, using try catch block, the error is caught by catch block and print the message.
try {
   c = display(a, b);
   cout << c << endl;
} catch (const char* msg) {
   cerr << msg << endl;
}
Binary representation of a given number in C++

A binary number is a number that consists of only two digits 0 and 1. For example, 01010111.
There are various ways to represent a given number in binary form.
This method is used to represent a number in its binary form using recursion.
Step 1 : if number > 1. Follow step 2 and 3.
Step 2 : push the number to a stand.
Step 3 : call function recursively with number/2
Step 4 : pop number from stack and print remainder by dividing it by 2.
 Live Demo
#include<iostream>
using namespace std;
void tobinary(unsigned number){
   if (number > 1)
      tobinary(number/2);
   cout << number % 2;
}
int main(){
   int n = 6;
   cout<<"The number is "<<n<<" and its binary representation is ";
   tobinary(n);
   n = 12;
   cout<<"\nThe number is "<<n<<" and its binary representation is ";
   tobinary(n);
}
The number is 6 and its binary representation is 110
The number is 12 and its binary representation is 1100
Int16.Parse(String) Method in C# with Examples - GeeksforGeeks

12 Jun, 2019
Int16.Parse(String) Method is used to convert the string representation of a number to its 16-bit signed integer equivalent.
Syntax:
public static short Parse (string str);
Here, str is a string that contains a number to convert. The format of str will be [optional white space][optional sign]digits[optional white space].
Return Value: It is a 16-bit signed integer equivalent to the number contained in str.
Exceptions:
ArgumentNullException: If str is null.
FormatException: If str is not in the correct format.
OverflowException: If str represents a number less than MinValue or greater than MaxValue.
Below programs illustrate the use of above-discussed method:
Example 1:
// C# program to demonstrate// Int16.Parse(String) Methodusing System;  class GFG {      // Main Method    public static void Main()    {          // passing different values        // to the method to check        checkParse("14321");        checkParse("15,784");        checkParse("-4589");        checkParse(" 456");    }      // Defining checkParse method    public static void checkParse(string input)    {          try {              // declaring Int16 variable            short val;              // getting parsed value            val = Int16.Parse(input);            Console.WriteLine("'{0}' parsed as {1}", input, val);        }          catch (FormatException)         {            Console.WriteLine("Can't Parsed '{0}'", input);        }    }}
'14321' parsed as 14321
Can't Parsed '15,784'
'-4589' parsed as -4589
' 456' parsed as 456

Example 2: For ArgumentNullException
// C# program to demonstrate// Int16.Parse(String) Method// for ArgumentNullExceptionusing System;  class GFG {      // Main Method    public static void Main()    {          try {              // passing null value as a input            checkParse(null);        }          catch (ArgumentNullException e) {              Console.Write("Exception Thrown: ");            Console.Write("{0}", e.GetType(), e.Message);        }          catch (FormatException e) {              Console.Write("Exception Thrown: ");            Console.Write("{0}", e.GetType(), e.Message);        }    }      // Defining checkparse method    public static void checkParse(string input)    {          // declaring Int16 variable        short val;          // getting parsed value        val = Int16.Parse(input);        Console.WriteLine("'{0}' parsed as {1}", input, val);    }}
Exception Thrown: System.ArgumentNullException

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.int16.parse?view=netframework-4.7.2#System_Int16_Parse_System_String_
CSharp-Int16-Struct
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 50 C# Interview Questions & Answers
Extension Method in C#
HashSet in C# with Examples
Partial Classes in C#
C# | Inheritance
Convert String to Character Array in C#
Linked List Implementation in C#
C# | How to insert an element in an Array?
C# | List Class
Difference between Hashtable and Dictionary in C#
How to move a file from one folder to another using Python?

The shutil module provides functions for moving files, as well as entire folders. For moving multiple files at once, you'll have to have a list of all files you want to copy and loop over them to copy them.
Calling shutil.move(source, destination) will move the file at the path source to the folder at the path destination. (Both source and destination are strings.) If destination is a filename, it will be used as the new name of the moved file. This function returns a string of the path of the moved file. 
import shutil, os
files = ['file1.txt', 'file2.txt', 'file3.txt']
for f in files:
    shutil.move(f, 'dest_folder')
Element repetition in list in Python

There are scenarios when we need to repeat the values in a list. This duplication of values can be achived in python in the following ways.
It is a straight forward approach in which pick each element, take through a inner for loop to create its duplicate and then pass both of them to an outer for loop.
 Live Demo
# Given list
listA = ['Mon', 'Tue', 9, 3, 3]

print("Given list : ",listA)

# Adding another element for each element
Newlist = [i for i in listA for n in (0, 1)]

# Result
print("New list after duplication: ",Newlist)
Running the above code gives us the following result −
Given list : ['Mon', 'Tue', 9, 3, 3]
New list after duplication: ['Mon', 'Mon', 'Tue', 'Tue', 9, 9, 3, 3, 3, 3]
The itertools module deals with data manipulation in iterables. Here we apply the chain.from_iterables which
 Live Demo
import itertools

# Given list
listA = ['Mon', 'Tue', 9, 3, 3]

print("Given list : ",listA)

# Adding another element for each element
Newlist = list(itertools.chain.from_iterable([n, n] for n in listA))

# Result
print("New list after duplication: ",Newlist)
Running the above code gives us the following result −
Given list : ['Mon', 'Tue', 9, 3, 3]
New list after duplication: ['Mon', 'Mon', 'Tue', 'Tue', 9, 9, 3, 3, 3, 3]
The reduce function applies a particular function passed to it as an argument to all of the list elements passed onto it as second argument. We use this with add function which adds the duplicate element of each element present in the list.
 Live Demo
from functools import reduce
from operator import add

# Given list
listA = ['Mon', 'Tue', 9, 3, 3]

print("Given list : ",listA)

# Adding another element for each element
Newlist = list(reduce(add, [(i, i) for i in listA]))

# Result
print("New list after duplication: ",Newlist)
Running the above code gives us the following result −
Given list : ['Mon', 'Tue', 9, 3, 3]
New list after duplication: ['Mon', 'Mon', 'Tue', 'Tue', 9, 9, 3, 3, 3, 3]
Find k longest words in given list in Python

We have a scenario where we have to pick the top n longest word from a list containing many words of varying length. In this article we will see various approaches to achieve that.
We first sort the elements of the list in the reverse order so that the longest words are available at the beginning of the list. Then find the length of each word and add the result of the count to a variable. Finally take a slice of the required number of longest words we need.
 Live Demo
from itertools import count

def longwords(l, x):
   c = count()
   return sorted(l, key=lambda i: (len(i), next(c)),
                  reverse=True)[:x]

listA = ['Earth','Moonshine','Aurora','Snowflakes','Sunshine']
n = 2
print(longwords(listA, n))
Running the above code gives us the following result −
['Snowflakes', 'Moonshine']
In this approach we use enumerate to list out each element of the list and then apply sorted and zip function to get the count. The negative length values indicate the reverse order of sorting and finally we slice the required number of counts.
 Live Demo
def longwords(l, x):
   idx, words = zip(*sorted(enumerate(l),
   key = lambda i: (-len(i[1]), -i[0]))[:x])
   return list(words)

listA = ['Earth','Moonshine','Aurora','Snowflakes','Sunshine']
n = 2
print(longwords(listA, n))
Running the above code gives us the following result −
['Snowflakes', 'Moonshine']
Sum of XOR of all possible subsets in C++

In this problem, we are given an array aar[] of n numbers. Our task is to create a program to find the Sum of XOR of all possible subsets.
Here, we will find all subsets of the array. Then for each subset, we will find the XOR of elements of the subset and add them to the sum variable.
Input: arr[] = {5, 1, 4}
Output: 20
Explanation: XOR of all subsets:
{5} = 5
{1} = 1
{4} = 4
{5, 1} = 4
{5, 4} = 1
{1, 4} = 5
{5, 1, 4} = 0
Sum of XOR = 5 + 1 + 4 + 4 + 1 + 5 = 20
A simple solution to the problem, is using loop and find all possible subsets of the array and then for each subset find XOR of all the elements and update the sum. Return sum at the end.
This is not an effective approach, for the large value, the time complexity will grow exponentially.
An efficient approach is using the properties of XOR. Here, we will find the OR of all elements of the array and check the bits. If the ith is set, then update sum with (2^(n-1+i)).
Program to illustrate the working of our solution,
 Live Demo
#include <iostream>
#include <math.h>
using namespace std;
int subSetXORSum(int arr[], int n) {
   int bitOR = 0;
   for (int i=0; i < n; ++i)
   bitOR |= arr[i];
   return (bitOR * pow(2, n-1));
}
int main() {
   int arr[] = {1, 5, 4};
   int size = sizeof(arr) / sizeof(arr[0]);
   cout<<"Sum of XOR of all possible subsets is "<<subSetXORSum(arr, size);
}
Sum of XOR of all possible subsets is 20
C# | How to change BackGround Color of Text in Console - GeeksforGeeks

28 Jan, 2019
Given the normal Console in C#, the default color of the text background is “Black”. The task is to change this color to some other color.
Approach: This can be done using the BackgroundColor property in the Console class of the System package in C#.
Program 1: Changing the Console Background Color to Blue.
// C# program to illustrate the // BackgroundColor Propertyusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;  namespace GFG {class Program {    static void Main(string[] args)    {          // Display current Background color        Console.WriteLine("Default Background Color: {0}",                          Console.BackgroundColor);          // Set the Background color to blue        Console.BackgroundColor            = ConsoleColor.Blue;          // Display current Background color        Console.WriteLine("Changed Background Color: {0}",                          Console.BackgroundColor);    }}}
Output:
Program 2: The list of available colors in which the BackgroundColor can be changed are
// C# program to get the// list of available colorsusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;  namespace GFG {class Program {    static void Main(string[] args)    {          // Get the list of available colors        // that can be changed        ConsoleColor[] consoleColors            = (ConsoleColor[])ConsoleColor                  .GetValues(typeof(ConsoleColor));          // Display the list        // of available console colors        Console.WriteLine("List of available "                          + "Console Colors:");        foreach(var color in consoleColors)            Console.WriteLine(color);    }}}
Output:
CSharp-Console-Class
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between Ref and Out keywords in C#
C# | Delegates
Top 50 C# Interview Questions & Answers
Introduction to .NET Framework
C# | Constructors
Extension Method in C#
C# | Class and Object
C# | Abstract Classes
C# | String.IndexOf( ) Method | Set - 1
Common Language Runtime (CLR) in C#
PHP – Make an upper case string using mb_strtoupper()

In PHP, mb_strtoupper() is an inbuilt function that is used to change a given string to upper case.
string mb_strtoupper(str $string, str $encoding)
mb_strtoupper() accepts two parameters: $string and $encoding.
$string− The string being uppercased.
$string− The string being uppercased.
$encoding− This parameter is the character encoding. If it is absent or null, then the internal character encoding value will be used.
$encoding− This parameter is the character encoding. If it is absent or null, then the internal character encoding value will be used.
string with all alphabetic characters converted to uppercase.
 Live Demo
<?php
   $string = "Hello World!, Welcome to online tutorials";
   $string = mb_strtoupper($string);
   echo $string;
?>
It will convert the given string to upper case.
HELLO WORLD!, WELCOME TO ONLINE TUTORIALS
Filter Color with OpenCV - GeeksforGeeks

16 Feb, 2021
Colour segmentation or color filtering is widely used in OpenCV for identifying specific objects/regions having a specific color. The most widely used color space is RGB color space, it is called an additive color space as the three color shades add up to give color to the image. To identify a region of a specific color, put the threshold and create a mask to separate the different colors. HSV color space is much more useful for this purpose as the colors in HSV space are much more localized thus can be easily separated. Color Filtering has many applications and uses cases such as in Cryptography, infrared analysis, food preservation of perishable foods, etc. In such cases, the concepts of Image processing can be used to find out or extract out regions of a particular color. For color segmentation, all we need is the threshold values or the knowledge of the lower bound and upper bound range of colors in one of the color spaces. It works best in the Hue-Saturation-Value color space. After specifying the range of color to be segmented, it is needed to create a mask accordingly and by using it, a particular region of interest can be separated out. 
Below is the code:  
Python3
import cv2import numpy as np cap = cv2.VideoCapture(0) while(1):    _, frame = cap.read()    # It converts the BGR color space of image to HSV color space    hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)         # Threshold of blue in HSV space    lower_blue = np.array([60, 35, 140])    upper_blue = np.array([180, 255, 255])     # preparing the mask to overlay    mask = cv2.inRange(hsv, lower_blue, upper_blue)         # The black region in the mask has the value of 0,    # so when multiplied with original image removes all non-blue regions    result = cv2.bitwise_and(frame, frame, mask = mask)     cv2.imshow('frame', frame)    cv2.imshow('mask', mask)    cv2.imshow('result', result)         cv2.waitKey(0) cv2.destroyAllWindows()cap.release()
Original Image-  
Masked Image-  
Blue Color segmented regions-  
 
trevorspreadbury
Image-Processing
OpenCV
Advanced Computer Subject
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Naive Bayes Classifiers
Linear Regression (Python Implementation)
Removing stop words with NLTK in Python
ML | Linear Regression
Apriori Algorithm
Python program to convert a list to string
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python program to check whether a number is Prime or not
Python | Convert a list to dictionary
How to hold key down with Selenium?

We can hold a key down with Selenium webdriver. We mostly utilize the CONTROL/SHIFT/ALT keys to hold down and then click on other keys. So, only mentioning the modifier keys like keys.CONTROL/ keys.SHIFT or Keys.ALT is not
sufficient.
To hold down a key simultaneously while another key is being pressed, we use the keyDown() and keyUp() methods. Both these methods accept the modifier key as a parameter.
The action of these two methods on a key yields a special functionality of a key. All these methods are a part of Actions class in Selenium. We have to add the import org.openqa.selenium.interactions.Actions package to our code for using the methods under Actions class.
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;

public class MetdKeyDown{
   public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      String url = "https://www.tutorialspoint.com/index.htm";
      driver.get(url);
      driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS);
      // identify element
      WebElement l = driver.findElement(By.id("gsc-i-id1"));
      // Actions class
      Actions a = new Actions(driver);
      // moveToElement() and then click()
      a.moveToElement(l).click();
      //enter text with keyDown() SHIFT key ,keyUp() then build() ,perform()
      a.keyDown(Keys.SHIFT);
      a.sendKeys("hello").keyUp(Keys.SHIFT).build().perform();
      driver.quit()
   }
}
System.lineSeparator() method in Java With Examples - GeeksforGeeks

19 Jun, 2018
The lineSeparator() is a built-in method in Java which returns the system-dependent line separator string. It always returns the same value – the initial value of the system property line.separator.
Syntax:
public static String lineSeparator()
Parameters: This method does not take any parameters.
Return Values: In any UNIX systems, it will return “\n” or a positive integer; and on Windows systems it returns “\r\n” or a positive integer.
Exception : It throws NullPointerException , if the string is null
Below programs illustrate the System.lineSeparator() method:
Program 1: To illustrate the working of static String lineSeparator() method.
// Java program to demonstrate working// of static String lineSeparator() methodimport java.io.IOException;import java.lang.*;import java.nio.channels.Channel;public class LineSeparatorExample {      public static void main(String[] args)    {        String s = System.lineSeparator();          for (char c : s.toCharArray()) {            System.out.println((int)c);        }    }}
10

Note: Here it returns 10. So here 10 is the line separator.
Program 2: To illustrate the working of static String lineSeparator() method for an integral value.
// Java program to demonstrate working// of static String lineSeparator() methodimport java.io.IOException;import java.lang.*;import java.nio.channels.Channel;class SystemDemo {    public static void main(String args[])        throws NullPointerException,               IOException    {        Integer x = 636;        System.out.println(System.lineSeparator());    }}
\r\n

Note: Here it returns “\r\n” since its a Microsoft Windows systems.
Reference: https://docs.oracle.com/javase/7/docs/api/java/lang/System.html#lineSeparator()
Java-Functions
Java-I/O
Java-lang package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
Stream In Java
HashMap in Java with Examples
Interfaces in Java
How to iterate any Map in Java
Initialize an ArrayList in Java
ArrayList in Java
Stack Class in Java
Singleton Class in Java
Multidimensional Arrays in Java
How to Query PostgreSQL using Python (with SSH) in 3 Steps | by Erik Yan | Towards Data Science

*- This story describes how to use this script to quickly setup connection with a remote PostgreSQL database with or without SSH .pem authentication. -*
Often data is housed within databases like PostgreSQL on remote servers, which can make it difficult for data analysts to access the data quickly. Sometimes, there are intermediate teams that assist analysts with retrieving the data from the database. In this story we’ll talk about how you can directly query the data using Python, without the need for intermediates.
If you know how to use Python (mainly for analytics and visualizations) but don’t have experience with databases or how to interact with them, then this post is for you!
There are a variety of tools at our disposal that will enable you to interact/retrieve data yourself from a database and spend more time extracting insights.
STEP 1: Install all required packages.
STEP 2: Import or paste query.py contents into your Notebook.
STEP 3: Start querying!
This story assumes the following:
You have Python already installed on your local environment
You are using a live-code environment like Jupyter Notebooks
Have been given the necessary credentials to SSH into the remote server (.pem certificate) and query the PostgreSQL database (username and password).
First we’ll need to install several packages from terminal.
pip3 install paramikopip3 install sshtunnelpip3 install SQLAlchemypip3 install pandas
Next, you’ll need to either save the query.py file from the repo to your working directory (where your Jupyter Notebook file is) or simply copy the contents of the file into your Notebook directly.
If you are placing the query.py file in your working directory, then include the following import line in your Notebook:
from query.py import *
Alternatively, simply copy and paste the code below into a code cell in your Notebook:
Now were ready to start querying! The defined class only provides a handful of basic functions. Let’s walk through how to use the class and what we can do with it.
First, we’ll need to specify our PostgreSQL connection arguments, and SSH arguments (if SSH tunneling is required to access the remote server).
We define pgres as our connection to simplify each time we want to query the database or explore the organizational structure of the database. You will also be prompted for your PostgreSQL username and password, which are stored as temporary variables (best-practice is to save these variables as environment variables instead).
Next, we can explore the schemas of our given database named ‘database_name’ to find our schema of interest using the .schemas() function.
If we want to explore the schema named ‘schema_name’, we can return the names of the tables within the schema using the .tables() function.
Finally, we can use .query() to run standard SQL queries (for PostgreSQL). In this example we’re querying the column names and data types from the table named ‘ey_test_table’
Try replacing the contents of sql_statement with your own query, and have fun!
GATE | GATE-CS-2004 | Question 15 - GeeksforGeeks

28 Jun, 2021
Choose the best matching between Group 1 and Group 2.
   Group-1               Group-2   
 P. Data link          1. Ensures reliable transport of data
                           over a physical point-to-point link
 Q. Network layer      2. Encoder/decodes data for physical
                          transmission
 R. Transport layer    3. Allows end-to-end communication
                          between two processes
                       4. Routes data from one network
                          node to the next
(A) P-1, Q-4, R-3(B) P-2, Q-4, R-1(C) P-2, Q-3, R-1(D) P-1, Q-3, R-2Answer: (A)Explanation: Data link layer is the second layer of the OSI Model. This layer is responsible for data transfer between nodes on the network and providing a point to point local delivery framework. So, P matches with 1.
Network layer is the third layer of the OSI Model. This layer is responsible for forwarding of data packets and routing through intermediate routers. So, Q matches with 4.
Transport layer is the fourth layer of the OSI Model. This layer is responsible for delivering data from process to process. So, R matches with 3.
 
Thus, A is the correct option.
 
Please comment below if you find anything wrong in the above post.Quiz of this Question
GATE-CS-2004
GATE-GATE-CS-2004
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE-CS-2006 | Question 47
GATE | GATE MOCK 2017 | Question 24
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
HTML - <blockquote> Tag

The HTML <blockquote> tag is used for indicating long quotations (i.e. quotations that span multiple lines). It should contain only block-level elements within it, and not just plain text.
<!DOCTYPE html>
<html>

   <head>
      <title>HTML blockquote Tag</title>
   </head>

   <body>
      <blockquote>Browsers generally render blockquote text as indented text. If your
         quoted text needs to display within a non-quoted paragraph, you should use the
         HTML q tag. Most browsers surround q text with quotation marks.</blockquote>
      <q>Browsers generally render blockquote text as indented text. If your quoted text
         needs to display within a non-quoted paragraph, you should use the HTML q tag.
         Most browsers surround q text with quotation marks.</q>
   </body>

</html>
This will produce the following result −
This tag supports all the global attributes described in HTML Attribute Reference
The HTML <blockquote> tag also supports the following additional attributes −
This tag supports all the event attributes described in HTML Events Reference

    19 Lectures 
     2 hours 

 Anadi Sharma

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    18 Lectures 
     1.5 hours 

 Frahaan Hussain

    57 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)

    54 Lectures 
     6 hours 

 DigiFisk (Programming Is Fun)

    45 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
Python | Test for False list - GeeksforGeeks

04 Jan, 2019
Sometimes, we need to check if a list is completely True of False, these occurrences come more often in testing purposes after the development phase. Hence, having a knowledge of all this is necessary and useful. Lets discuss certain ways in which this can be performed.
Method #1 : Naive MethodIn the naive method, we just run a loop from beg to end of list and check manually for each value. This is the most basic way to perform this particular task.
# Python3 code to demonstrate # to check for False list # using naive method  # initializing list  test_list = [False, False, False, False]  # printing original listprint ("The original list is : " + str(test_list))  flag = 0  # using naive method # to check for False list for i in test_list :    if i == True :        flag = 1        break  # printing resultprint ("Is List completely false ? : " +  str(bool(not flag)))
The original list is : [False, False, False, False]
Is List completely false ? : True

 Method #2 : Using all()This function tests each value to be False and if yes, returns boolean True, else returns false. The list iteration is done using list comprehension.
# Python3 code to demonstrate # to check for False list # using all()  # initializing list  test_list = [False, False, False, False]  # printing original listprint ("The original list is : " + str(test_list))  flag = 0  # using all()# to check for False list res = all(not i for i in test_list)  # printing resultprint ("Is List completely false ? : " +  str(res))
The original list is : [False, False, False, False]
Is List completely false ? : True

 Method #3 : Using any()This function tests for any one of the True value, if found returns True, else returns False value. Negation of this function is used as the result.
# Python3 code to demonstrate # to check for False list # using any()  # initializing list  test_list = [False, False, False, False]  # printing original listprint ("The original list is : " + str(test_list))  # using any()# to check for False list res = not any(test_list)  # printing resultprint ("Is List completely false ? : " +  str(res))
The original list is : [False, False, False, False]
Is List completely false ? : True

Python list-programs
Python
Python Programs
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?
How to drop one or multiple columns in Pandas Dataframe
Check if element exists in list in Python
Python | os.path.join() method
Defaultdict in Python
Python | Split string into list of characters
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python program to check whether a number is Prime or not
MySQL query to return a substring after delimiter?

Use SUBSTRING() to return values after delimiter. Let us first create a table −
mysql> create table DemoTable
-> (
-> Title text
-> );
Query OK, 0 rows affected (0.56 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('John is good in MySQL,Sam is good in MongoDB,Mike is good in Java');
Query OK, 1 row affected (0.19 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------------------------------------------------------------------+
| Title                                                             |
+-------------------------------------------------------------------+
| John is good in MySQL,Sam is good in MongoDB,Mike is good in Java |
+-------------------------------------------------------------------+
1 row in set (0.00 sec)
Here is the query to return substring after delimiter.
mysql> select substring(Title, instr(Title, ',') + 1) as AfterDelimiter from DemoTable;
This will produce the following output −
+---------------------------------------------+
| AfterDelimiter                              |
+---------------------------------------------+
| Sam is good in MongoDB,Mike is good in Java |
+---------------------------------------------+
1 row in set (0.03 sec)
PHP mysqli_begin_transaction() Function

The mysqli_begin_transaction() is used to start a new transaction.
mysqli_begin_transaction($con, [$flags, $name]);

con(Mandatory)
This is an object representing a connection to MySQL Server.
flags(Optional)
A constant which can be on of the following :
MYSQLI_TRANS_START_READ_ONLY
MYSQLI_TRANS_START_READ_ONLY
MYSQLI_TRANS_START_READ_WRITE
MYSQLI_TRANS_START_READ_WRITE
MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT
MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT
name(Optional)
This is string value representing the name of the save point of the transaction.
The PHP mysqli_begin_transaction() function returns a boolean value which is, true if the operation is successful and, false if not.
This function was first introduced in PHP Version 5 and works in all the later versions.
Following example demonstrates the usage of the mysqli_begin_transaction() function (in procedural style) −
<?php
   //Creating a connection
   $con = mysqli_connect("localhost", "root", "password", "mydb");

   //Beginning the transaction
   mysqli_begin_transaction($con, MYSQLI_TRANS_START_READ_ONLY);
   print("Transaction Started......\n");

   //Creating a table
   mysqli_query($con, "CREATE TABLE Test(Name VARCHAR(255), AGE INT)");
   print("Table Created......\n");

   //Inserting values
   mysqli_query($con, "INSERT INTO Test values('Raju', 25),('Rahman', 30),('Sarmista', 27)");
   print("Records Inserted......\n");

   //Committing the transaction
   mysqli_commit($con);
   print("Transaction Saved......\n");

   //Closing the connection
   mysqli_close($con);
?>
This will produce following result −
Transaction Started......
Table Created......
Records Inserted......
Transaction Saved......

The syntax of this method in object oriented style is $con->begin_transaction(). Following is an example of this function in object oriented mode $minus;
//Creating a connection
$con = new mysqli("localhost", "root", "password", "mydb");

//Beginning the transaction
$con->begin_transaction($con, MYSQLI_TRANS_START_READ_ONLY);
print("Transaction Started......\n");

//Creating a table
$con->query("CREATE TABLE Test(Name VARCHAR(255), AGE INT)");
print("Table Created......\n");

//Inserting values
$con->query("insert into Test values('Raju', 25),('Rahman', 30),('Sarmista', 27)");
print("Records Inserted......\n");

//Committing the transaction
$con->commit();
print("Transaction Saved......\n");

//Closing the connection
$con->close();
?>
This will produce following result −
Transaction Started......
Table Created......
Records Inserted......
Transaction Saved......


    45 Lectures 
     9 hours 

 Malhar Lathkar

    34 Lectures 
     4 hours 

 Syed Raza

    84 Lectures 
     5.5 hours 

 Frahaan Hussain

    17 Lectures 
     1 hours 

 Nivedita Jain

    100 Lectures 
     34 hours 

 Azaz Patel

    43 Lectures 
     5.5 hours 

 Vijay Kumar Parvatha Reddy
 Print
 Add Notes
 Bookmark this page
Date toString() method in Java with Examples - GeeksforGeeks

02 Jan, 2019
The toString() method of Java Date class converts this date object into a String in form “dow mon dd hh:mm:ss zzz yyy”. This method overrides toString in class object.Syntax:
public String toString()

Parameters: The function does not accept any parameter.
Return Value: It method returns a string representation of this date.
Exception: The function does not throws any exception.
Program below demonstrates the above mentioned function:
// Java code to demonstrate// toString() function of Date class  import java.util.Date;import java.util.Calendar;public class GfG {    // main method    public static void main(String[] args)    {          // creating a Calendar object        Calendar c1 = Calendar.getInstance();          // set Month        // MONTH starts with 0 i.e. ( 0 - Jan)        c1.set(Calendar.MONTH, 11);          // set Date        c1.set(Calendar.DATE, 05);          // set Year        c1.set(Calendar.YEAR, 1996);          // creating a date object with specified time.        Date dateOne = c1.getTime();          System.out.println(dateOne.toString());    }}
Thu Dec 05 08:21:00 UTC 1996

// Java code to demonstrate// toString() function of Date class  import java.util.Date;import java.util.Calendar;public class GfG {    // main method    public static void main(String[] args)    {          // creating a Calendar object        Calendar c1 = Calendar.getInstance();          // set Month        // MONTH starts with 0 i.e. ( 0 - Jan)        c1.set(Calendar.MONTH, 11);          // set Date        c1.set(Calendar.DATE, 15);          // set Year        c1.set(Calendar.YEAR, 1999);          // creating a date object with specified time.        Date dateOne = c1.getTime();          System.out.println(dateOne.toString());    }}
Wed Dec 15 08:21:02 UTC 1999

Java - util package
Java-Functions
Java-util-Date
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Different ways of Reading a text file in Java
Constructors in Java
Exceptions in Java
Generics in Java
Functional Interfaces in Java
Comparator Interface in Java with Examples
HashMap get() Method in Java
Introduction to Java
Difference between Abstract Class and Interface in Java
Unsafe Code in C# - GeeksforGeeks

11 Mar, 2019
Unsafe code in C# is the part of the program that runs outside the control of the Common Language Runtime (CLR) of the .NET frameworks. The CLR is responsible for all of the background tasks that the programmer doesn’t have to worry about like memory allocation and release, managing stack etc. Using the keyword “unsafe” means telling the compiler that the management of this code will be done by the programmer. Making a code content unsafe introduces stability and security risks as there are no bound checks in cases of arrays, memory related errors can occur which might remain unchecked etc.
A programmer can make the following sub-programs as unsafe:
Code blocksMethodsTypesClassStruct
Code blocks
Methods
Types
Class
Struct
Need to use the unsafe code?
When the program needs to implement pointers.
If native methods are used.
Syntax:
unsafe Context_declaration
Example: Here, we are declaring a block of code inside main as unsafe so that we can use pointers.
// C# program to demonstrate the unsafe codeusing System;  namespace GFG {  class Program {      // Main Method    static void Main(string[] args)    {        // Declaring a code block as         // unsafe to make use of pointers        unsafe        {            int x = 10;            int* ptr;            ptr = &x;              // displaying value of x using pointer            Console.WriteLine("Inside the unsafe code block");            Console.WriteLine("The value of x is " + *ptr);        } // end unsafe block          Console.WriteLine("\nOutside the unsafe code block");    } // end main}}
Note: This code will not compile directly, it gives the following error.
Therefore, if you are using Visual Studio, then you need to follow the given steps:
1) Go to the project properties
2) Select the build option and check the “Allow unsafe code” option.
Output:
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 50 C# Interview Questions & Answers
Extension Method in C#
HashSet in C# with Examples
C# | Inheritance
Partial Classes in C#
Convert String to Character Array in C#
Linked List Implementation in C#
C# | How to insert an element in an Array?
C# | List Class
Difference between Hashtable and Dictionary in C#