code-rag-bench/online-tutorials huggingface dataset:
Checking internet connectivity in Java


Internet connectivity can be checked using java.net.URL and java.net.URLConnection class. Following are the required steps.
Create a URL object and pass it the URL say Google
Create a URL object and pass it the URL say Google
Call URL.openConnection() method to get a URLConnection object.
Call URL.openConnection() method to get a URLConnection object.
Call URLConnection.connect() method to check the internet connectivity. connect() method opens a communications link to the resource referenced by the passed URL if a connection has not already been established.
Call URLConnection.connect() method to check the internet connectivity. connect() method opens a communications link to the resource referenced by the passed URL if a connection has not already been established.
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class Tester {
   public static void main(String[] args) {
      try {
         URL url = new URL("http://www.google.com");
         URLConnection connection = url.openConnection();
         connection.connect();
         System.out.println("Internet is connected");
      } catch (MalformedURLException e) {
         System.out.println("Internet is not connected");
      } catch (IOException e) {
         System.out.println("Internet is not connected");
      }
   }
}
Internet is connected
Creating column table in SAP HANA database

To create a Column store table, you need to enter “Column” keyword in Create table command.
Create column Table Test_ColumnTB1 (
   Cust_ID INTEGER,
   Cust_NAME VARCHAR(10),
   PRIMARY KEY (Cust_ID)
);
Running Selenium Webdriver with a proxy in Python.

We can run a proxy with Selenium webdriver in Python. A proxy is an essential component to do localization testing. We can take an e-commerce application and check if the language and currency visible is as per the user location.
With the help of proxy within tests, we can verify if the website user interface matches with the location. We have to SET a proxy with below steps −
Import webdriver from Selenium package.
Import webdriver from Selenium package.
Define proxy server address.
Define proxy server address.
Create an object of ChromeOptions class
Create an object of ChromeOptions class
Communication of proxy with ChromeOptions.
Communication of proxy with ChromeOptions.
Summing options to Chrome() object.
Summing options to Chrome() object.
Code Implementation.
from selenium import webdriver
#proxy server definition
py = "128.21.0.0:8080"
#configure ChromeOptions class
chrome_options = WebDriverWait.ChromeOptions()
#proxy parameter to options
chrome_options.add_argument('--proxy-server=%s' % py)
#options to Chrome()
driver = webdriver.Chrome(chrome_options= chrome_options)
driver.implicitly_wait(0.6)
driver.get("https://www.tutorialspoint.com/index.htm")
Then, to check if a search field has the present user address we shall add the below code snippet −
def checkL(self):
self.driver.get(self.url)
st = self.driver.find_element_by_xpath('#loc')
#check location with assertion
self.assertEqual('India', st.text)
If we have to verify more than locations, we can create a method and pass the proxy address as an argument.
How to stop a page loading from Selenium in chrome?

We can stop a page loading with Selenium webdriver in Chrome browser by using the JavaScript Executor. Selenium can execute JavaScript commands with the help of the executeScript command.
To stop a page loading, the command window.stop() is passed as a parameter to the executeScript method. Also, for the Chrome browser we have to configure the pageLoadStrategy to none value and wait for the web element to be available.
Finally, we have to invoke window.stop.
driver.execute_script("window.stop();")
Code Implementation with JavaScript Executor
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import
DesiredCapabilities
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
#configure pageLoadStrategy to none
c = DesiredCapabilities.CHROME
c["pageLoadStrategy"] = "none"
#set chromodriver.exe path
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe",
desired_capabilities=c)
#explicit wait
w = WebDriverWait(driver, 15)
#launch URL
driver.get("https://www.google.com/")
#expected condition
w.until(EC.presence_of_element_located((By.CLASS_NAME, 'gLFyf')))
#JavaScript Executor to stop page load
driver.execute_script("window.stop();")
We can also stop the page load with the help of the set_page_load_timeout method and passing the time in seconds as a parameter to this method. For example, if the time is 0.1 seconds, a TimeoutException shall be raised if the page load consumes greater than 0.1 second.
driver.set_page_load_timeout(0.1)
from selenium import webdriver
#set chromodriver.exe path
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
#set page load timeout
driver.set_page_load_timeout(0.1)
#launch URL
driver.get("https://accounts.google.com/")
#close browser
driver.close()
How to index and slice a tuple in Python?

To index or slice a tuple you need to use the [] operator on the tuple. When indexing a tuple, if you provide a positive integer, it fetches that index from the tuple counting from the left. In case of a negative index, it fetches that index from the tuple counting from the right. 
my_tuple = ('a', 'b', 'c', 'd')
print(my_tuple[1])
print(my_tuple[-1])
This will give the output −
b
d
If you want to get a part of the tuple, use the slicing operator. [start:stop:step]. 
my_tuple = ('a', 'b', 'c', 'd')
print(my_tuple[1:]) #Print elements from index 1 to end
print(my_tuple[:2]) #Print elements from start to index 2
print(my_tuple[1:3]) #Print elements from index 1 to index 3
print(my_tuple[::2]) #Print elements from start to end using step sizes of 2
This will give the output −
('b', 'c', 'd')
('a', 'b')
('b', 'c')
('a', 'c')
Python - Nth smallest Greater than K - GeeksforGeeks

27 Feb, 2020
This article offers various approaches to solve the problem of finding Nth smallest number in python list greater than a specific element K in python list. This basically provides all the approaches from naive to one-liners so that they can be used in programming whenever required.
Method 1 : Naive Method + sort()Using loop we keep on adding elements that are greater than K and then sort the list and find the Nth element greater than K.
# Python 3 code to demonstrate # Nth smallest Greater than K# using naive method + sort()  # Initializing list test_list = [1, 4, 7, 5, 10]  # Initializing kk = 6  # Initializing N N = 2  # Printing original list print ("The original list is : " + str(test_list))  # Using naive method + sort()# Nth smallest Greater than Kres = []for i in test_list :    if i > k :        res.append(i)res.sort()  # Printing result print ("The Nth minimum value greater than 6 is : " + str(res[N - 1]))
The original list is : [1, 4, 7, 5, 10]
The Kth minimum value greater than 6 is : 10

 
Method 2 : lambda + filter() + sort()Similar approach to method above, just to filter the numbers in list greater than k, filter() instead of loop is used in this approach. Works in a similar way as above after that.
# Python 3 code to demonstrate # Nth smallest Greater than K# using min() + sort() + lambda  # Initializing list test_list = [1, 4, 7, 5, 10]  # Initializing kk = 6  # Initializing N N = 2  # Printing original list print ("The original list is : " + str(test_list))  # Nth smallest Greater than K# using min() + sort() + lambdares = list(filter(lambda i: i > k, test_list))res.sort()  # Printing result print ("The Nth minimum value greater than 6 is : " + str(res[N - 1]))
The original list is : [1, 4, 7, 5, 10]
The Kth minimum value greater than 6 is : 10

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?
Check if element exists in list in Python
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Javascript | Window scrollTo() Method - GeeksforGeeks

26 Jul, 2019
The Window scrollTo() method is used to scroll to a particular set of coordinates in the document.
Syntax:
window.scrollTo(x-coord, y-coord)

Parameters: The scrollTo() method accepts two parameters as described below:
x-coord: It is the pixel along the horizontal axis of the document that is displayed in the upper left. It is the required field.
y-coord: It is the pixel along the vertical axis of the document that is displayed in the upper left. It is the required field.
Example:
<!DOCTYPE html><html>  <head>    <title>Window scrollTo() Method</title>    <style>        body {            width: 5000px;            height: 5000px;            margin-left: 260px;        }    </style></head>  <body>    <h1 style="color:green;">            GeeksforGeeks        </h1>    <h2>            Window scrollTo() Method        </h2>      <p>        A computer science portal for geeks.    </p>      <button onclick="geek()">Click to scroll!</button>      <script>        function geek() {            //Scrolling the document to position "250"             //horizontally and "110" vertically            window.scrollTo(250, 110);        }    </script></body>  </html>
Output:Before clicking the button:After clicking the button:Supported Browsers: The browser supported by Window scrollTo() Method are listed below:
Google Chrome
Internet Explorer
Firefox 1.0
Opera
Safari
javascript-functions
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
How to create footer to stay at the bottom of a Web page?
Differences between Functional Components and Class Components in React
Node.js fs.readFileSync() Method
How to apply style to parent if it has child with CSS?
How to Open URL in New Tab using JavaScript ?
How to execute PHP code using command line ?
strings.Replace() Function in Golang With Examples - GeeksforGeeks

04 Mar, 2022
strings.Replace() Function in Golang is used to returns a copy of the given string with the first n non-overlapping instances of old replaced by new one.
Syntax:
func Replace(s, old, new string, n int) string
Here, s is the original or given string, old is the string that you want to replace. new is the string which replaces the old, and n is the number of times the old replaced.
Note: If old is empty, it matches at the beginning of the string and after each UTF-8 sequence, yielding up to k+1 replacements for a k-rune string. If n < 0, there is no limit on the number of replacements.
Example 1:
// Golang program to illustrate the usage of// strings.Replace() function  package main  import (    "fmt"    "strings")  func main() {    // using the function    fmt.Println(strings.Replace("gfg gfg gfg", "g", "G", 3))    fmt.Println(strings.Replace("gfg gfg gfg", "fg", "FG", -1))}
Output:
GfG Gfg gfg
gFG gFG gFG

In the first case, the first 3 matched substrings of “g” in “gfg gfg gfg” get replaced by “G”. In the second case, every matched case of “fg” gets replaced by “FG”.
Example 2: Let’s consider an example where we do not pass any value for old.
// Golang program to illustrate the usage of// strings.Replace() function  package main  import (    "fmt"    "strings")  func main() {      // using the function    fmt.Println(strings.Replace("i am geeks", "", "G", 5))    fmt.Println(strings.Replace("i love the geekiness", "", "F", -1))}
Output:
GiG GaGmG geeks
FiF FlFoFvFeF FtFhFeF FgFeFeFkFiFnFeFsFsF

It can be seen that every alternate position gets replaced by new, n times.
daradadachanji
Golang-String
Picked
Go Language
Write From Home
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
6 Best Books to Learn Go Programming Language
Slices in Golang
Golang Maps
Interfaces in Golang
How to Trim a String in Golang?
Convert integer to string in Python
Convert string to integer in Python
How to set input type date in dd-mm-yyyy format using HTML ?
Python infinity
Matplotlib.pyplot.title() in Python
Bootstrap | Media queries - GeeksforGeeks

28 Mar, 2019
We use a handful of media queries for delivering different styles sheet to different devices, to create sensible breakpoints for our layouts and interfaces. These breakpoints are mostly based on minimum viewport widths and allow us to scale up elements as the viewport changes.
Bootstrap primarily uses the following media query ranges—or breakpoints—in our source Sass files for our layout, grid system, and components.
// Extra small devices (portrait phones, less than 576px)
// No media query since this is the default in Bootstrap

// Small devices (landscape phones, 576px and up)
@media (min-width: 576px) { ... }

// Medium devices (tablets, 768px and up)
@media (min-width: 768px) { ... }

// Large devices (desktops, 992px and up)
@media (min-width: 992px) { ... }

// Extra large devices (large desktops, 1200px and up)
@media (min-width: 1200px) { ... }

Media queries for changing background colorCopy below code and save it with .htm extension and Resize the browser window to see the effectExamples:
<!DOCTYPE html><html><head><style>body {  background-color:#008000;  color: black;}  /* On screens that are 992px wide or less,   the background color is green */@media screen and (max-width: 992px) {  body {    background-color: #008000;    color: black;  }}  /* On screens that are 600px wide or less,  the background color is yellow */@media screen and (max-width: 600px) {  body {    background-color: Yellow;    color: Pink;  }}</style></head><body><h1>GEEKS FOR GEEKS</h1><h1>Resize the browser window to see the effect!</h1><p>By default, the background color of    the document is "green".</p><p> If it is 600px or less,      it will change to "Yellow".</p>  </body></html>
After Resizing the window we get:Similarly, Media queries can be used in different places
Media Queries For ColumnsMedia Queries For MenusChange Font Size With Media QueriesOrientation: Portrait / Landscape etc..
Media Queries For Columns
Media Queries For Menus
Change Font Size With Media Queries
Orientation: Portrait / Landscape etc..
Picked
Bootstrap
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Show Images on Click using HTML ?
How to set Bootstrap Timepicker using datetimepicker library ?
How to Use Bootstrap with React?
How to keep gap between columns using Bootstrap?
Tailwind CSS vs Bootstrap
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?
How to Fix: ValueError: Trailing data? - GeeksforGeeks

19 Dec, 2021
In this article, we will discuss how we may fix ValueError: Trailing data in Python.
This problem commonly occurs when you attempt to import a JSON file into a pandas DataFrame, although the data is written in lines separated by endlines like ‘\n‘. 
Like in this sample json file:
JSON Used:
Let’s examine what happens if we try to import this json file into pandas.
Python3
# This code fix ValueError: Trailing dataimport pandas as pd  df = pd.read_json('sample_json.json')print(df.head())
Output:
ValueError: Trailing data
Because the “ABOUT” item in our JSON file contains ‘\n’ to indicate endlines, we get an error.
For this, we will use lines = True Read the file as a json object per line.
Python3
# This code fix ValueError: Trailing dataimport pandas as pd  df = pd.read_json('sample_json.json', lines = True)print(df.head())
Output:
   ID NAME
0   1  abc
1   2  def
2   3  ghi
3   4  jkl
Notice that we’re able to properly import the JSON file into a pandas DataFrame without any issues. This was fixed by changing the lines attribute of pandas read json method into True. The line attribute reads the file as a json object per line.
Picked
Python How-to-fix
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
AngularJS | ng-hide Directive - GeeksforGeeks

30 Mar, 2021
The ng-hide Directive in AngluarJS is used to show or hide the specified HTML element. If the expression given in the ng-hide attribute is true than the HTML elements hide. In AngularJS there is a predefined class named ng-hide which is used to set the display to none. Syntax:  
 <element ng-hide="expression"> Contents... </element> 
Example 1: This example uses ng-hide Directive to display the entered number is multiple of 5 or not.  
html
<!DOCTYPE html><html>     <head>    <title>ng-hide Directive</title>     <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">    </script></head> <body ng-app="app" style="text-align:center">    <div ng-controller="geek" ng-init="val=0">                 <h1 style="color:green">GeeksforGeeks</h1>                 <h2>ng-hide Directive</h2>                 Enter a number: <input type="text" ng-model="val"                ng-keyup="check(val)">          <div ng-hide="hide">            <h3>                The number is multiple of 5            </h3>        </div>                 <div ng-show="hide">            <h3>                The number is not a multiple of 5            </h3>        </div>    </div>         <script>        var app = angular.module("app", []);        app.controller('geek', ['$scope', function ($scope) {            $scope.check = function (val) {            $scope.hide = val % 5 == 0 ? false : true;            };        }]);    </script></body> </html>
Output:  
Example 2: This example uses ng-hide Directive to hide content.  
html
<!DOCTYPE html><html>    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/    1.6.9/angular.min.js"></script>    <head>        <title>ng-hide Directive</title>    </head>    <body>        <div ng-app="app" ng-controller="geek"  style="text-align:center">            <h1 style="color:green">GeeksforGeeks</h1>            <h2>ng-hide Directive</h2>            <input id="chbhide" type="checkbox" ng-model="hide" />            <label for="chbhide">                Hide Paragraph            </label>            <p ng-hide="hide" style="background: green; color: white;            font-size: 14px; width:35%; padding: 10px;">                Hide this paragraph using ng-hide            </p>         </div>        <script>            var myapp = angular.module("app", []);            myapp.controller("geek", function ($scope) {            $scope.hide = false;            });        </script>    </body></html>
Output: Before click:  
After click:  
 
simranarora5sos
AngularJS-Directives
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Angular PrimeNG Dropdown Component
Angular PrimeNG Calendar Component
Angular 10 (blur) Event
Angular PrimeNG Messages Component
How to make a Bootstrap Modal Popup in Angular 9/8 ?
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?
PostgreSQL - SPLIT_PART Function - GeeksforGeeks

16 Jul, 2021
The PostgreSQL SPLIT_PART() function is used to split a string from a specific delimiter and these queries return the nth substring.
Syntax: SPLIT_PART(string, delimiter, position)
Let’s analyze the above syntax:
The string argument is the string to be split.
The delimiter is a string used as the delimiter for splitting.
The position argument sets the part of the string that is to be returned, starting from 1. The argument must have a positive integer as its value.
Example 1:
The below query uses the SPLIT_PART() function to return the year and month of the payment date from the payment table of the sample database, ie, dvdrental:
SELECT
    split_part(payment_date::TEXT, '-', 1) y,
    split_part(payment_date::TEXT, '-', 2) m,
    amount
FROM
    payment;
Output:
Example 2:
Through the below query the string ‘A, B, C’ is split on the comma delimiter (, ) and results in 3 substrings: ‘A’, ‘B’, and ‘C’. Because the position is 2, the function returns the 2nd substring which is ‘B’:
SELECT SPLIT_PART('A, B, C', ', ', 2);
Output:
kapoorsagar226
PostgreSQL-function
PostgreSQL-String-function
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL - CREATE PROCEDURE
PostgreSQL - GROUP BY clause
PostgreSQL - DROP INDEX
PostgreSQL - TIME Data Type
PostgreSQL - REPLACE Function
PostgreSQL - CREATE SCHEMA
PostgreSQL - ROW_NUMBER Function
PostgreSQL - SELECT
PostgreSQL - Cursor
PostgreSQL - LEFT JOIN
Python | Retain records of specific length - GeeksforGeeks

21 Nov, 2019
Sometimes, while working with records, we might desire to filter records in such a way in which we need to discard records that do not contains exact number of elements required to constitute a record. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using list comprehension + len()In this method, we just iterate through the list and discard the tuples that do not match the matching length required to constitute the record. The computation of length is done by len().
# Python3 code to demonstrate working of# Retain records of specific length# Using list comprehension + len()  # Initializing listtest_list = [(4, 5, 6), (5, 6), (2, 3, 5), (5, 6, 8), (5, 9)]  # printing original listprint("The original list is : " + str(test_list))  # Initializing desired length N = 3  # Retain records of specific length# Using list comprehension + len()res =  [sub for sub in test_list if len(sub) == 3]      # printing resultprint("The tuple list after removing uneven records: " + str(res))
The original list is : [(4, 5, 6), (5, 6), (2, 3, 5), (5, 6, 8), (5, 9)]
The tuple list after removing uneven records: [(4, 5, 6), (2, 3, 5), (5, 6, 8)]

 
Method #2 : Using filter() + lambda + len()The combination of above functions can also be used to perform this particular task. In this, we just use filter() and use lambda function to separate uneven length records.
# Python3 code to demonstrate working of# Retain records of specific length# Using filter() + lambda + len()  # Initializing listtest_list = [(4, 5, 6), (5, 6), (2, 3, 5), (5, 6, 8), (5, 9)]  # printing original listprint("The original list is : " + str(test_list))  # Initializing desired length N = 3  # Retain records of specific length# Using filter() + lambda + len()res = list(filter(lambda ele: len(ele) == N, test_list))      # printing resultprint("The tuple list after removing uneven records: " + str(res))
The original list is : [(4, 5, 6), (5, 6), (2, 3, 5), (5, 6, 8), (5, 9)]
The tuple list after removing uneven records: [(4, 5, 6), (2, 3, 5), (5, 6, 8)]

shubham_singh
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 ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Python - Kth word replace in String - GeeksforGeeks

29 Dec, 2019
Sometimes, while working with String list, we can have a problem in which we need to replace the most Kth word of string. This problem has many application in web development domain. Let’s discuss a way in which this problem can be solved.
Method : Using split() + join()This is way in which we can perform this task. In this, we break elements into parts and then return the Kth value and perform the addition of new element using join().
# Python3 code to demonstrate working of# Kth word replace in String# using split() + join()  # initializing string test_str = "GFG is good"  # printing original string print("The original string is : " + test_str)  # initializing replace string rep_str = "best"  # initializing K K = 1   # Kth word replace in String# using split() + join()temp = test_str.split(' ')res = " ".join(temp[: K]  + [rep_str] + temp[K + 1 :])  # printing resultprint("The String after performing replace : " + res)
The original string is : GFG is good
The String after performing replace : GFG best good

Python string-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?
Check if element exists in list in Python
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Char.IsLetter() Method in C#

The Char.IsLetter() method in C# is used to indicate whether the specified Unicode character is categorized as a Unicode letter.
Following is the syntax −
public static bool IsLetter (char ch);
Above, the parameter ch is the Unicode character to evaluate.
Let us now see an example to implement the Char.IsLetter() method −
using System;
public class Demo {
   public static void Main(){
      bool res;
      char val = 'K';
      Console.WriteLine("Value = "+val);
      res = Char.IsLetter(val);
      Console.WriteLine("Is the value a letter? = "+res);
   }
}
This will produce the following output −
Value = K
Is the value a letter? = True
Let us now see another example −
using System;
public class Demo {
   public static void Main(){
      bool res;
      char val = '2';
      Console.WriteLine("Value = "+val);
      res = Char.IsLetter(val);
      Console.WriteLine("Is the value a letter? = "+res);
   }
}
This will produce the following output −
Value = 2
Is the value a letter? = False
CSS | overflow-x Property - GeeksforGeeks

06 Apr, 2021
The overflow-x property in CSS specifies whether to add a scroll bar, clip the content or display overflow content of a block-level element, when it overflows at the left and right edges. In other words, this property helps us to display the content which is overflowing from the page horizontally.The default value of overflow-x property is visible. This CSS property is not animatable.Syntax:  
overflow-x: visible|hidden|scroll|auto|initial|inherit;
Property Values:  
visible: This property does not clip the content. The content may be rendered outside the left and right edges.
hidden: It is used to clip the content and no scrolling mechanism is provided.
scroll: It is used to clip the content and providing a scrolling mechanism.
auto: It provides a scrolling mechanism for overflowing boxes.
initial: This property is used to set overflow-x property to its default value.
inherit: This property is inherited from its parent.
Example  
html
<!DOCTYPE html><html><head>    <style>    div.example1 {        background-color: green;        width: 80px;        overflow-x: scroll;    }         div.example2 {        background-color: green;        width: 80px;        overflow-x: hidden;    }         div.example3 {        background-color:green;        width: 80px;        overflow-x: auto;    }         div.example4 {        background-color: green;        width: 80px;        overflow-x: visible;    }    </style></head><body>    <h1>GeeksforGeeks</h1>          <p>        The overflow-x property specifies whether to        clip the content, add a scroll bar, or display        overflow content of a block-level element,        when it overflows at the left and right edges.    </p>          <h2>overflow-x: scroll:</h2>    <div class="example1">        GeeksforGeeks computer science portal    </div>         <h2>overflow-x: hidden:</h2>    <div class="example2">        GeeksforGeeks computer science portal    </div>         <h2>overflow-x: auto:</h2>    <div class="example3">        GeeksforGeeks computer science portal    </div>         <h2>overflow-x: visible (default):</h2>    <div class="example4">        GeeksforGeeks computer science portal    </div></body></html>                   
Output:  
Supported Browsers: The browsers supported by  overflow-x property are listed below:  
Google Chrome 4.0
Internet Explorer 9.0
Firefox 3.5
Safari 3.0
Opera 9.5
 
arorakashish0911
CSS-Properties
Picked
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to create footer to stay at the bottom of a Web page?
How to update Node.js and NPM to next version ?
Types of CSS (Cascading Style Sheet)
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
C# Program to skip a specified number of elements of an array

The following is our array −
int[] points = { 210, 250, 300, 350, 420};
Use skip() method to skip elements. Add the number as an argument that displays the number of elements to be returned.
IEnumerable<int> skipEle = points.AsQueryable().OrderByDescending(s => s).Skip(3);
 Live Demo
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
   public static void Main() {
      int[] points = { 210, 250, 300, 350, 420};
      Console.WriteLine("Initial array...");
   
      foreach (int res in points)
      Console.WriteLine(res);
      IEnumerable<int> skipEle = points.AsQueryable().OrderByDescending(s => s).Skip(3);
      Console.WriteLine("Skipped 3 elements...");

      foreach (int res in skipEle)
      Console.WriteLine(res);
   }
}
Initial array...
210
250
300
350
420
Skipped 3 elements...
250
210
Conditional update depending on field matched in MongoDB

For conditional update, use update() and set new value using $set. Let us create a collection with documents −
> db.demo150.insertOne({"StudentId":101,"StudentName":"Chris","StudentMarks":35});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e350dcdfdf09dd6d08539d3")
}
> db.demo150.insertOne({"StudentId":102,"StudentName":"Chris","StudentMarks":55});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e350dcefdf09dd6d08539d4")
}
> db.demo150.insertOne({"StudentId":103,"StudentName":"David","StudentMarks":34});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e350dcffdf09dd6d08539d5")
}
> db.demo150.insertOne({"StudentId":104,"StudentName":"Chris","StudentMarks":38});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e350dd0fdf09dd6d08539d6")
}
Display all documents from a collection with the help of find() method −
> db.demo150.find();
This will produce the following output −
{ "_id" : ObjectId("5e350dcdfdf09dd6d08539d3"), "StudentId" : 101, "StudentName" : "Chris", "StudentMarks" : 35 }
{ "_id" : ObjectId("5e350dcefdf09dd6d08539d4"), "StudentId" : 102, "StudentName" : "Chris", "StudentMarks" : 55 }
{ "_id" : ObjectId("5e350dcffdf09dd6d08539d5"), "StudentId" : 103, "StudentName" : "David", "StudentMarks" : 34 }
{ "_id" : ObjectId("5e350dd0fdf09dd6d08539d6"), "StudentId" : 104, "StudentName" : "Chris", "StudentMarks" : 38 }
Following is the query for conditional update depending on field matched −
> db.demo150.update({"StudentId":103},{$set:{"StudentMarks":97}});
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
Display all documents from a collection with the help of find() method −
> db.demo150.find();
This will produce the following output −
{ "_id" : ObjectId("5e350dcdfdf09dd6d08539d3"), "StudentId" : 101, "StudentName" : "Chris", "StudentMarks" : 35 }
{ "_id" : ObjectId("5e350dcefdf09dd6d08539d4"), "StudentId" : 102, "StudentName" : "Chris", "StudentMarks" : 55 }
{ "_id" : ObjectId("5e350dcffdf09dd6d08539d5"), "StudentId" : 103, "StudentName" : "David", "StudentMarks" : 97 }
{ "_id" : ObjectId("5e350dd0fdf09dd6d08539d6"), "StudentId" : 104, "StudentName" : "Chris", "StudentMarks" : 38 }
Java program to print the reverse of the given number

Following is the algorithm to reverse a given number.
1. Get the number to reverse.
2. Hold the number in temporary variable.
3. Start the while loop with condition temp >0.
4. Store the first digit in the temporary variable d by performing modulus
operation on temp with 10.
5. Multiply the revnum (initialized with 0) with 10 and concatenate the digit
obtained in the previous step.
6. Reduce one digit in the temp by dividing with 10.
import java.util.Scanner;
public class ReverseOfANumber {
   public static void main(String args[]) {
      int d, number,temp, revnum = 0;
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter a number ::");
      number = sc.nextInt();
      temp = number;
      while (temp >0) {
         d = temp %10;
         revnum = (revnum*10)+d;
         temp = temp/10;
      }
      System.out.println("Reverse of the given number is:"+revnum);
   }
}
Enter a number ::
5112115
Reverse of the given number is:5112115
\hbox - Tex Command

\hbox - Used to treat contents as text, but you can switch to math mode inside.
{ \hbox }
\hbox command is used to treat contents as text, but you can switch to math mode inside.

\hbox{\alpha a }\alpha a

\alpha a αa


\hbox{This is a sentence.}

This is a sentence.


\hbox{for all $x > 0$}

for all x>0



\hbox{\alpha a }\alpha a

\alpha a αa


\hbox{\alpha a }\alpha a
\hbox{This is a sentence.}

This is a sentence.


\hbox{This is a sentence.}
\hbox{for all $x > 0$}

for all x>0


\hbox{for all $x > 0$}

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
How to start ChromeDriver in headless mode?

We can start chromedriver in headless mode. Headless execution is getting popular now−a−days since the resource consumption is less and execution is done at a faster speed.
Post version 59, Chrome supports headless execution. ChromeOptions class is utilized to modify the default characteristics of the browser. The addArguments method of the ChromeOptions class is used for headless execution and headless is passed as a parameter to that method.
ChromeOptions opt = new ChromeOptions();
opt.addArguments("headless");
WebDriver drv = new ChromeDriver(opt);
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import java.util.concurrent.TimeUnit;
public class HeadlessChrome{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver",
         "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      //ChromeOptions object
      ChromeOptions opt = new ChromeOptions();
      //headless argument
      opt.addArguments("headless");
      // configure options parameter to ChromeDriver
      WebDriver driver = new ChromeDriver(opt);
      driver.manage().timeouts().implicitlyWait(8, TimeUnit.SECONDS);
      driver.get("https://www.tutorialspoint.com/about/about_careers.htm");
      // get page title
      System.out.println("Page title in headless mode: " + driver.getTitle());
      driver.quit();
   }
}
What are subnets and subnet masks in computer networks?

Subnet Mask is used in networking to create multiple sub networks in a network. It divides the IP address into multiple parts which can be assigned to every computer. Subnet Mask is made by setting the network bits to all "1"s and setting host bits to all "0"s. Within a given network, two host addresses are reserved for a special purpose, and cannot be assigned to hosts.
The binary "0" in the subnet mask tell us about the host address. It tells us about the IP of the host which has done subnetting.
Suppose we have a subnet address as 192.168.1.0. In this, all host addresses are zero. It will be represented in binary as
11000000 10101000 00000001 00000000
In this way, we set the host bits to zero in the Subnet mask.
Every website needs a unique IP address, in order to uniquely identify the website, we are dividing the IP network into two or more networks called subnet, which is preferred to control network traffic.
It is a smaller network inside a large network. This technique makes the network routing an efficient one.
The main features of subnet are as follows −
Reduce network congestion.
Control network growth
Ease administration
Boost network security
Generally, we divide the network into smaller networks or subnets which is called subnetting.
Let’s take a class A of network. In class A, we have 224hosts. To manage such a large number of hosts is a very difficult job. So, if we divide this large network into the smaller network then maintaining each network would become easy.
Given below is the diagram of subnet −
How to Install Metasploit 6 on Android using Termux (No Root)? - GeeksforGeeks

08 Mar, 2022
In this article,  we are going to learn how we can set up Metasploit 6 on our android phones using termux without rooting the phone. Metasploit is a framework written in RUBY for penetration testing purposes in ethical hacking as well as in unethical hacking.
Termux Emulator: In Linux, we have a terminal to run the commands similarly for Android devices we have termux used as a terminal emulator. It allows us to install a minimal package using the package manager.
Following are the steps to install Metasploit 6 On Android Phone Using Termux:
Step 1: If you have not installed termux then install it from the play store. 
Step 2: Run the following command :
$ apt update
$ apt upgrade -y
Step 3: Install the required packages using this command:
$ pkg install wget curl openssh git -y
Step 4: Now we need to install nucurses utility programming library 
$ apt install ncurses-utils
Step 5: We have full filled all the necessary requirements for Metasploit 6. Now run only single command to install Metasploit 6:
$ source <(curl -fsSL https://kutt.it/msf)
Or You can use manual process using these commands:
$ pkg install wget
$ wget https://raw.githubusercontent.com/gushmazuko/metasploit_in_termux/master/metasploit.sh
$ chmod +x metasploit.sh
$ ./metasploit.sh
Note: You need 1GB-2GB space in the device for installing this framework.
Downloading starts as shown below:
Metasploit 6 is successfully installed on your device you can check it using the below command:
$ metasploit
how-to-install
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install FFmpeg on Windows?
How to Set Git Username and Password in GitBash?
How to Install Jupyter Notebook on MacOS?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Create and Setup Spring Boot Project in Eclipse IDE?
Installation of Node.js on Linux
How to Install FFmpeg on Windows?
How to Install Pygame on Windows ?
How to Install Jupyter Notebook on MacOS?
How to Add External JAR File to an IntelliJ IDEA Project?
How to create Color Picker in ReactJS ? - GeeksforGeeks

29 Oct, 2021
In this article, we are going to learn how we can create Color Picker in ReactJs. A color picker is a graphical user interface widget, usually found within graphics software or online, used to select colors and sometimes to create color schemes.
React is a free and open-source front-end JavaScript library for building user interfaces or UI components. It is maintained by Facebook and a community of individual developers and companies.
Approach: To create our color picker we are going to use the react-color-palette package because it is powerful, lightweight, and fully customizable. After that, we will add our color picker on our homepage using the installed package.
 
Create ReactJS Application: 
Step 1: You can create a new ReactJs project using the below command:
npx create-react-app gfg
Step 2: Now we will install the react-color-palette package using the below command:
npm install react-color-palette
Project Structure: It will look like this.
Adding Color Picker: In this example, we are going to add the color picker on the homepage of our app using the package that we installed. For this, add the below content in the App.js file.
App.js
import { ColorPicker, useColor } from "react-color-palette";import "react-color-palette/lib/css/styles.css";  export default function ColorPickerGfg(){  const [color, setColor] = useColor("hex", "#121212");    return (    <div>        <h1>Color Picker - GeeksforGeeks</h1>        <ColorPicker width={456} height={228}                    color={color}                    onChange={setColor} hideHSV dark />;    </div>  )};
Explanation: In the above example first, we are importing the ColorPicker and the CSS file for our color picker using the react-color-palette package. After that, we are using our useColor() hook to set the initial color. Then we will add our color picker using the ColorPicker component of the installed package.
Steps to run the application: Run the below command in the terminal to run the app.
npm start
React-Questions
JavaScript
ReactJS
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
Difference Between PUT and PATCH Request
Remove elements from a JavaScript Array
How to get character array from string in JavaScript?
How to filter object array based on attributes?
How to fetch data from an API in ReactJS ?
How to redirect to another page in ReactJS ?
How to pass data from child component to its parent in ReactJS ?
How to pass data from one component to other component in ReactJS ?
ReactJS Functional Components
How to add an image as label using JavaFX?

You can display a text element/image on the User Interface using the Label component. It is a not editable text control, mostly used to specify the purpose of other nodes in the application.
In JavaFX you can create a label by instantiating the javafx.scene.control.Label class. To create a label, you need to instantiate this class
You can use a graphic object as a label using the setGraphic() method of the Label class (inherited from javafx.scene.control.Labeled class). This method accepts an object of the Node class representing a graphic (icon).
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;

public class ImageAsLabel extends Application {
   public void start(Stage stage) {
      // Creating a Label
      Label label = new Label("Sample label");
     
      // Creating a graphic (image)
      Image img = new Image("UIControls/logo.png");
      ImageView view = new ImageView(img);
      view.setFitHeight(80);
      view.setPreserveRatio(true);
      label.setGraphic(view);
     
      // Setting font to the label
      Font font = Font.font("Brush Script MT", FontWeight.BOLD, FontPosture.REGULAR, 25);
      label.setFont(font);
     
      // Filling color to the label
      label.setTextFill(Color.BROWN);
     
      // Setting the position
      label.setTranslateX(150);
      label.setTranslateY(25);
      Group root = new Group();
      root.getChildren().add(label);
     
      // Setting the stage
      Scene scene = new Scene(root, 595, 200, Color.BEIGE);
      stage.setTitle("Label Example");
      stage.setScene(scene);
      stage.show();
   }
   
   public static void main(String args[]){
      launch(args);
   }
}
On execution, it will produce the following output:
str() vs repr() in Python?

Both str() and repr() methods in python are used for string representation of a string. Though they both seem to serve the same puppose, there is a little difference between them.
Have you ever noticed what happens when you call a python built-in function str(x) where x is any object you want? The return value of str(x) depends on two methods: __str__ being the default choice and __repr__ as a fallback.
Let’s first see what python docs says about them −
>>> help(str)
Help on class str in module builtins:

class str(object)
| str(object='') -> str
| str(bytes_or_buffer[, encoding[, errors]]) -> str
|
| Create a new string object from the given object.

>>> help(repr)
Help on built-in function repr in module builtins:

repr(obj, /)
Return the canonical string representation of the object.

For many object types, including most builtins, eval(repr(obj)) == obj.
Now let’s try to understand these two methods using few examples
>>> str(123)
'123'
>>> repr(123)
'123'
>>> #Above we see- with integer data, there is no difference
>>> #Now let's try string data on these two methods
>>> str('Python')
'Python'
>>> repr('Python')
"'Python'"
The returns of repr() and str() are same for integer value, but there’s a difference between the return values for string – one is formal and the other is informal.
Now if you go by the official python documentation – the __str__ is used to find the “informal”(readable) string representation of an object whereas __repr__ is used to find the “official” string representation of an object.
The difference between the formal and informal representations is that the default implementation of __repr__ for a str value can be called as an argument to eval, and the return value would be a valid string object. This function (repr()) takes a string and evaluates it’s content as python code.
So when we pass "'Python'" to it, its work. However, ‘Python’ leads to an error cause it’s interpreted as the variable Python which is of course undefined. Below is the code to understand it −
>>> x = "Python"
>>> repr(x)
"'Python'"
>>> x1 = eval (repr(x))
>>> x == x1
True
So if we try to call the return value of __str__ as an argument to eval, it failed.
>>> y = "Python"
>>> str(y)
'Python'
>>> y1 = eval(str(y))
Traceback (most recent call last):
File "<pyshell#51>", line 1, in <module>
y1 = eval(str(y))
File "<string>", line 1, in <module>
NameError: name 'Python' is not defined
Another example to demonstrate the difference between the two is −
>>> import datetime
>>> now = datetime.datetime.now()
>>> str(now)
'2019-03-29 01:29:23.211924'
>>> repr(now)
'datetime.datetime(2019, 3, 29, 1, 29, 23, 211924)'
In above output, the str(now) computes a string containing the value of now whereas repr(now) again returns the python code needed to rebuild our now object.
Above points need to be considered when writing __str__ and __repr__ for your classes.
How to use multiple modules with Python import Statement?

To import multiple modules with a single import statement, just separate the module names by commas. For example,
>>> import math, sys, os
If you want to change the name under which the modules are imported, just add as after each module name followed by module alias. For example,
>>> import math as Mathematics, sys as system
If you have a list of modules you want to import as strings, then you can use the inbuilt __import__(module_name). For example,
>>> modnames = ["os", "sys", "math"]
>>> for lib in modnames:
 ...     globals()[lib] = __import__(lib)