code-rag-bench/online-tutorials huggingface dataset:
Python - noise() function in Wand - GeeksforGeeks

08 May, 2020
Image noise is random variation of brightness or color information in images, and is usually an aspect of electronic noise. We can add noise to the image using noise() function. noise function can be useful when applied before a blur operation to defuse an image.
Following are the noise we can add using noise() function:
gaussian
impulse
laplacian
multiplicative_gaussian
poisson
random
uniform
Syntax :
wand.image.noise(noise_type, attenuate, channel)

Parameters :
Source Image:
Example 1:
# Import Image from wand.image modulefrom wand.image import Image  # Read image using Image() functionwith Image(filename ="koala.jpeg") as img:      # Generate noise image using spread() function    img.noise("poisson", attenuate = 0.9)    img.save(filename ="noisekoala.jpeg")
Output:
Example 2:
# Import Image from wand.image modulefrom wand.image import Image  # Read image using Image() functionwith Image(filename ="koala.jpeg") as img:      # Generate noise image using spread() function    img.noise("laplacian", attenuate = 1.0)    img.save(filename ="noisekoala2.jpeg")
Output:
Python-wand
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python String | replace()
Create a Pandas DataFrame from Lists
Python program to convert a list to string
Selecting rows in pandas DataFrame based on conditions
How to change the font size of a text using JavaScript?

This method causes a string to be displayed in the specified size as if it were in a <font size= "size"> tag.
You can try to run the following code to change the font size of a text using JavaScript −
Live Demo
<html>
   <head>
      <title>JavaScript String fontsize() Method</title>
   </head>

   <body>
      <script>
         var str = new String("Demo Text");
         document.write(str.fontsize(10));
         alert(str.fontsize( 10 ));
      </script>
   </body>
</html>
Convert PDF File Text to Audio Speech using Python

15 Jul, 2021
Let us see how to read a PDF that is converting a textual PDF file into audio.
Packages Used:
pyttsx3: It is a Python library for Text to Speech. It has many functions which will help the machine to communicate with us. It will help the machine to speak to us
PyPDF2: It will help to the text from the PDF. A Pure-Python library built as a PDF toolkit. It is capable of extracting document information, splitting documents page by page, merging documents page by page etc.
Both these modules need to be installed
pip install pyttsx3
pip install PyPDF2

Making Audio Book From Any PDF Using Python | GeeksforGeeks - YouTubeGeeksforGeeks529K subscribersMaking Audio Book From Any PDF Using Python | GeeksforGeeksWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:000:00 / 17:12•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=bLGyDfc1x2A" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>
You also need to know about the open() function which will help us to open the PDF in read mode. Knowledge about the OOPS Concept is also recommended.
Here is the link of the PDF which is read in the example: https://drive.google.com/file/d/1zhf7-_v6CVUtgd_XMK562mg6ciewi1QR/view?usp=sharing
Approach:
Import the PyPDF2 and pyttx3 modules.
Open the PDF file.
Use PdfFileReader() to read the PDF. We just have to give the path of the PDF as the argument.
Use the getPage() method to select the page to be read.
Extract the text from the page using extractText().
Instantiate a pyttx3 object.
Use the say() and runwait() methods to speak out the text.
Now here the code for it
Python3
# importing the modulesimport PyPDF2import pyttsx3  # path of the PDF filepath = open('file.pdf', 'rb')  # creating a PdfFileReader objectpdfReader = PyPDF2.PdfFileReader(path)  # the page with which you want to start# this will read the page of 25th page.from_page = pdfReader.getPage(24)  # extracting the text from the PDFtext = from_page.extractText()  # reading the textspeak = pyttsx3.init()speak.say(text)speak.runAndWait()
Output:
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
PHP program to add item at the beginning of associative array

11 Feb, 2019
In PHP associative array is the type of array where the index need not to be strictly sequential like indexed array. Normally add a new element in an existing associative array it will get appended at the end of that array.
Example:
<?php  // Existing array$arr = array('one' => 1, 'two' => 2);      // New element$arr['zero'] = 0;      // Final arrayprint_r($arr);  ?>
Array
(
    [one] => 1
    [two] => 2
    [zero] => 0
)

So, a new element can not be added directly at the beginning of an associative array but the existing array can be appended at the end of a new array where the first element is the new element.It means add the new element in the beginning first the new element need to be put in an empty array as first element and then the array need to be merged with the existing array. In PHP, there are two ways to merge arrays they are array_merge() function and by using array union(+) operator.
In case of array_merge() function if two arrays have a same key then the value corresponding to the key in later array in considered in the resulting array. But in case of indexed array the elements simply get appended and re-indexing is done for all the element in the resulting array.
Syntax:
array array_merge( $arr1, $arr2 )
In case of array union(+) operator if two arrays have same key then the value corresponding to the key in first array in considered in the resulting array, this also applies in the indexed array, if two array have an element of common index then only the element from first array will be considered in the resulting array.
Syntax:
$arr3 = $arr1 + $arr2
Program: PHP program to add a new item at the beginning of an associative array.
<?php      // Adding a new element at the beginning of an array  // Existing array$arr = array('one' => 1, 'two' => 2, 'three' => 3);          // New element to be added at 'zero' => 0  // Create an array using the new element$temp = array('zero' => 0);      // Append the $temp in the beginning of $arr      // Using array union(+) operator$arr2 = $temp + $arr;      echo "Result of array union(+) : ";print_r($arr2);      // Using array_merge() function$arr3 = array_merge($temp, $arr);      echo "\n" . "Result of array_merge() : ";print_r($arr3);  ?>
Result of array union(+) : Array
(
    [zero] => 0
    [one] => 1
    [two] => 2
    [three] => 3
)

Result of array_merge() : Array
(
    [zero] => 0
    [one] => 1
    [two] => 2
    [three] => 3
)

Picked
PHP
PHP Programs
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to convert array to string in PHP ?
PHP | Converting string to Date and DateTime
Split a comma delimited string into an array in PHP
How to get parameters from a URL string in PHP?
Download file from URL using PHP
How to convert array to string in PHP ?
How to call PHP function on the click of a Button ?
Split a comma delimited string into an array in PHP
How to get parameters from a URL string in PHP?
How to fetch data from localserver database and display on HTML table using PHP ?
How to import config.php file in a PHP script ?

02 Mar, 2020
The include statement in PHP copies the code of text from the file mentioned, into the file that uses the include statement. It directs the preprocessor to insert the content specified into the following program. The name of the file to be included is written in double-quotes. It is a good practice to write the basic database details and user details in a file named “config.php”. You can also include the connection building statements in the config.php file to automatically build the connection to the database for every page that includes the config.php file. Including files allows you to form a template of code that is required by multiple pages of a website.
Syntax:
<?php
   include('config.php');
?>
Example 1: This shows the creation and including of config.php file.
Code 1: Create a PHP file and save it with the name ‘config.php’.<?php   $host = 'localhost';   $database = 'GeeksForGeeks';   $username = 'admin';   $password = '';?>
<?php   $host = 'localhost';   $database = 'GeeksForGeeks';   $username = 'admin';   $password = '';?>
Code 2: Create a PHP file and save it with the name ‘try.php’ in the same folder as ‘config.php’ file. Copy the below code to include the ‘config.php’ file and get a print the name of the database and username.<?php   include('config.php');   echo "Host: ".$host." Database: ".$database;?>
<?php   include('config.php');   echo "Host: ".$host." Database: ".$database;?>
Output:
Example 2: If you want to save the contents of the config.php file into a variable, then the following code does that work.
Code 1: Simply return the contents of the ‘config.php’ file.<?php   return [   'host' => 'localhost2',   'database' => 'GeeksForGeeks2',   'username' => 'admin',   'password' => ''   ];?>
<?php   return [   'host' => 'localhost2',   'database' => 'GeeksForGeeks2',   'username' => 'admin',   'password' => ''   ];?>
Code 2: Accept the returning array in a variable.<?php   $details = include('config.php');   echo 'Host: ' . $details['host'] .         ' Database: ' . $details['database'];?>
<?php   $details = include('config.php');   echo 'Host: ' . $details['host'] .         ' Database: ' . $details['database'];?>
Output:
PHP-Misc
Picked
PHP
PHP Programs
Web Technologies
Web technologies Questions
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to convert array to string in PHP ?
PHP | Converting string to Date and DateTime
Comparing two dates in PHP
How to get parameters from a URL string in PHP?
Split a comma delimited string into an array in PHP
How to convert array to string in PHP ?
How to call PHP function on the click of a Button ?
Comparing two dates in PHP
Split a comma delimited string into an array in PHP
How to get parameters from a URL string in PHP?
Node.js Date.addDays() API

12 Mar, 2021
The date-and-time.Date.addDays() is a minimalist collection of functions for manipulating JS date and time module which is used to add the extra Days to the existing date and time.
Required Module: Install the module by npm or used it locally.
By using npm.
npm install date-and-time --save
By using CDN link.
<script src="/path/to/date-and-time.min.js"></script>
Syntax:
addDays(dateObj, days)
Parameters: This method takes the following arguments as parameters:
dateobject: It is the string object of the date.
days: It is the number of days.
Return Value: This method returns updated date and time.
Example 1:
index.js
// Node.js program to demonstrate the  // Date.addDays() method  // Importing moduleconst date = require('date-and-time')  // Creating object of current date and time // by using Date() const now = new Date();  // Adding Days to the existing date and time// by using date.addDays() methodconst value = date.addDays(now, 24);  // Display the resultconsole.log("updated date and time : " + value)
Run the index.js file using the following command:
node index.js
Output:
updated date and time :
Wed Mar 31 2021 20:07:07 GMT+0530 (India Standard Time)
Example 2:
index.js
// Node.js program to demonstrate the  // Date.addDays() method  // Importing moduleconst date = require('date-and-time')  // Creating object of current date and time // by using Date() const now = new Date();  now.setDate(20)  // Adding Days to the existing date and time// by using date.addDays() methodconst value = date.addDays(now, 24);  // Display the resultconsole.log("updated date and time : " + value)
Run the index.js file using the following command:
node index.js
Output:
updated date and time : 
Tue Apr 13 2021 20:09:57 GMT+0530 (India Standard Time)
Reference: https://github.com/knowledgecode/date-and-time#adddaysdateobj-days
NodeJS date-time
NodeJS-API
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How To Rename Columns In Pandas | Towards Data Science

Renaming dataframe columns is a common practise especially when we are interested in sharing some insights with other people and teams. This means that we may wish to make column names more meaningful so that it would be easier for readers to relate them to specific contexts.
In this short article, we will look at a few of options we have when it comes down to renaming columns of pandas DataFrames. Specifically, we are going to see how to rename columns:
using the rename() method
by updating the DataFrame.columns attribute
and using set_axis() method
First, let’s create an example DataFrame that will reference throughout this guide in order to showcase the desired pandas functionality.
import pandas as pddf = pd.DataFrame({    'colA':[1, 2, 3],     'colB': ['a', 'b', 'c'],})print(df)#    colA colB# 0     1    a# 1     2    b# 2     3    c
pandas.DataFrame.rename() can be used to alter columns’ or index name.
Alter axes labels.
Function / dict values must be unique (1-to-1). Labels not contained in a dict / Series will be left as-is.
In order to rename columns using rename() method, we need to provide a mapping (i.e. a dictionary) where keys are the old column name(s) and values are the new one(s). Additionally, we must specify axis=1 in order to denote that we wish to rename columns and not the index:
df = df.rename({'colA': 'A', 'colB': 'B'}, axis=1)print(df)#    A  B# 0  1  a# 1  2  b# 2  3  c
pandas DataFrames come with pandas.DataFrames.columns attribute which is an Index containing the column labels of the DataFrame.
We can rename DataFrame columns by re-assigning this particular attribute as shown below:
df.columns = ['column_A', 'column_B']print(df)#    column_A column_B# 0         1        a# 1         2        b# 2         3        c
pandas.DataFrame.set_axis() method can be used to assign a desired index to either the column or index axis. In order to rename the column names, make sure to provide axis=1 as shown below:
df = df.set_axis(['AA', 'BB'], axis=1, inplace=False)print(df)#    AA BB# 0   1  a# 1   2  b# 2   3  c
Note that in all of the examples discussed earlier, you can even use axis='columns' instead of axis=1 in order to denote that the operation should be effective on the column level. For example,
df = df.rename({'colA': 'A', 'colB': 'B'}, axis='columns')df = df.set_axis(['AA', 'BB'], axis='columns')
In today’s short guide we discussed how to rename columns of pandas DataFrames in a few different ways.
You may also be interested in understanding how to change the data types of specific columns of pandas DataFrames.
towardsdatascience.com
Additionally, the article below discusses how to perform proper row selection based on specific conditions.
C# | Check if Caps Lock is on or off through Console - GeeksforGeeks

28 Jan, 2019
Given the normal Console in C#, the task is to check if the CAPS LOCK is on or off through Console.
Approach: This can be done using the CAPS LOCK property in the Console class of the System package in C#.
Program 1: When the CAPS LOCK is on
// C# program to illustrate the// Console.CapsLock 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)    {          // Check if CAPS LOCK is on or off        Console.WriteLine("Is CAPS LOCK on: {0}",                               Console.CapsLock);    }}}
Output:
Program 2: When the CAPS LOCK is off
// C# program to illustrate the// Console.CapsLock 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)    {          // Check if CAPS LOCK is on or off        Console.WriteLine("Is CAPS LOCK on: {0}",                               Console.CapsLock);    }}}
Output:
CSharp-Console-Class
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# Dictionary with examples
C# | Delegates
C# | Method Overriding
C# | Abstract Classes
Extension Method in C#
Difference between Ref and Out keywords in C#
C# | Replace() Method
C# | Class and Object
C# | Constructors
C# | String.IndexOf( ) Method | Set - 1
Tryit Editor v3.7

Tryit: HTML button as link
How to select multiple options in a dropdown list with JavaScript?

To select multiple options in a drop-down list, use the multiple properties. It allows you to select more than one option while pressing CTRL key.
You can try to run the following code to learn how to select more than one options at once in a dropdownlist.
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <form id="myForm">
         <select id="mySelect">
            <option>One</option>
            <option>Two</option>
            <option>Three</option>
         </select>
         <input type="button" onclick="multipleFunc()" value="Select multiple options">
      </form>
      <p>Press CTRL and click above button to select multiple options at once.</p>
      <script>
         function multipleFunc() {
            document.getElementById("mySelect").multiple = true;
         }
      </script>
   </body>
</html>
Usage of Bootstrap navbar-btn class

Add buttons using class .navbar-btn to <button> elements not residing in a <form> to vertically center them in the navbar. .navbar-btn can be used on <a> and <input> elements.
You can try to run the following code to implement the navbar-btn class
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <nav class = "navbar navbar-default" role = "navigation" style="background: #85C1E9;">
         <div class = "navbar-header">
            <a class = "navbar-brand" href = "#">Search below:</a>
         </div>
         <div>
            <form class = "navbar-form navbar-left" role = "search">
               <div class = "form-group">
                  <input type = "text" class = "form-control" placeholder = "Search">
               </div>
               <button type = "submit" class = "btn btn-default">Submit Button</button>
            </form>
            <button type = "button" class = "btn btn-default navbar-btn">Navbar Button</button>
         </div>
      </nav>
   </body>
</html>
How to add hours and minutes to a date with JavaScript?

To add hours and minutes to a date, use the setHours() and setMinutes() method in JavaScript.
You can try to run the following code to add hours and minutes −
<html>
   <head>
      <title>JavaScript Dates</title>
   </head>
   <body>
      <script>
         var dt = new Date();
         document.write("Current Date: "+dt);
         dt.setHours(dt.getHours() + 2);
         dt.setMinutes(dt.getMinutes() + 20);
         document.write("<br>Updated Date: "+dt);
      </script>
   </body>
</html>
Java Program to add Combo Box to JTable

Use the JComboBox to add a combo box to a table -
JComboBox<String> comboBox = new JComboBox<>();
Now, add the combo box items -
comboBox.addItem("Asia");
comboBox.addItem("Europe");
comboBox.addItem("North America");
comboBox.addItem("South America");
Now, use the TableColumn and set the column wherein you want to set the above ComboBox items -
TableColumn testColumn = table.getColumnModel().getColumn(0);
Set the editor with the combo box -
testColumn.setCellEditor(new DefaultCellEditor(comboBox));
The following is an example to add JComboBox to JTable:
package my;
import java.awt.Color;
import java.awt.Font;
import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumn;
public class SwingDemo {
   public static void main(String[] argv) throws Exception {
      JTable table = new JTable(5, 5);
      Font font = new Font("Verdana", Font.PLAIN, 12);
      table.setFont(font);
      table.setRowHeight(30);
      table.setBackground(Color.orange);
      table.setForeground(Color.white);
      TableColumn testColumn = table.getColumnModel().getColumn(0);
      JComboBox<String> comboBox = new JComboBox<>();
      comboBox.addItem("Asia");
      comboBox.addItem("Europe");
      comboBox.addItem("North America");
      comboBox.addItem("South America");
      comboBox.addItem("Africa");
      comboBox.addItem("Antartica");
      comboBox.addItem("Australia");
      testColumn.setCellEditor(new DefaultCellEditor(comboBox));
      JFrame frame = new JFrame();
      frame.setSize(600, 400);
      frame.add(new JScrollPane(table));
      frame.setVisible(true);
   }
}
The output is as follows displaying JComboBox in JTable -
Find all the names beginning with the letter 'a' or ‘b’ or ‘c’ using MySQL query?

You need to use LIKE with OR operator to find all the names that starts with a or b or c. The syntax is as follows:
SELECT *FROM yourTableName WHERE yourColumnName like 'A%' or yourColumnName like 'B%' or yourColumnName like 'C%';
The above query finds all names that starts only with the letter ‘a’ or ‘b’ or ‘c’. To understand the above syntax, let us create a table. The query to create a table is as follows:
mysql> create table AllNamesStartWithAorBorC
   -> (
   -> Id int NOT NULL AUTO_INCREMENT,
   -> EmployeeName varchar(20),
   -> PRIMARY KEY(Id)
   -> );
Query OK, 0 rows affected (0.70 sec)
Insert some records in the table using insert command. The query is as follows:
mysql> insert into AllNamesStartWithAorBorC(EmployeeName) values('Adam');
Query OK, 1 row affected (0.19 sec)
mysql> insert into AllNamesStartWithAorBorC(EmployeeName) values('Bob');
Query OK, 1 row affected (0.16 sec)
mysql> insert into AllNamesStartWithAorBorC(EmployeeName) values('baden');
Query OK, 1 row affected (0.48 sec)
mysql> insert into AllNamesStartWithAorBorC(EmployeeName) values('Carol');
Query OK, 1 row affected (0.41 sec)
mysql> insert into AllNamesStartWithAorBorC(EmployeeName) values('Mike');
Query OK, 1 row affected (0.13 sec)
mysql> insert into AllNamesStartWithAorBorC(EmployeeName) values('Larry');
Query OK, 1 row affected (0.16 sec)
mysql> insert into AllNamesStartWithAorBorC(EmployeeName) values('Chris');
Query OK, 1 row affected (0.18 sec)
Display all records from the table using select statement. The query is as follows:
mysql> select *from AllNamesStartWithAorBorC;
The following is the output:
+----+--------------+
| Id | EmployeeName |
+----+--------------+
|  1 | Adam         |
|  2 | Bob          |
|  3 | baden        |
|  4 | Carol        |
|  5 | Mike         |
|  6 | Larry        |
|  7 | Chris        |
+----+--------------+
7 rows in set (0.00 sec)
Here is the query to find names that begins with a or b or c. The query is as follows:
mysql> select *from AllNamesStartWithAorBorC where EmployeeName like 'A%' or EmployeeName like 'B%' or
   -> EmployeeName like 'C%';
The following is the output:
+----+--------------+
| Id | EmployeeName |
+----+--------------+
|  1 | Adam         |
|  2 | Bob          |
|  3 | baden        |
|  4 | Carol        |
|  7 | Chris        |
+----+--------------+
5 rows in set (0.00 sec)
Deletion of head and tail element logic in a linked list using C language.

Linked lists use dynamic memory allocation i.e. they grow and shrink accordingly. It is collection of nodes.
Node has two parts, which are data and link. These are explained below.
There are three types of operations on linked lists which are as follows −
Insertion
Deletion
Traversing
Identify the node.
Adjust the links in such a way that deallocation of the nodes does not make the list as unconnected components.
Return/display element to delete.
Deallocate the memory.
Follow the steps given below to delete a head element in C programming language.
1. void del_head()
2. {
3. int x;
   Node *temp;
4. if(Head==NULL)
5. {
6. printf("List is empty");
7. return;
8. }
9. x=Head->ele;
10. temp=Head;
11. if(Head==Tail)
12. Head=Tail=NULL:
13. Else
14. Head=Head->next;
15. printf("Deleted element %d",x);
16. free(temp);
17. }
Here,
Step 4 − Checks for list empty or not.
Step 9 − Reads an element to delete.
Step 10 − Head referred by temp pointer.
Step 11 − Checks for last deletion.
Step 14 − Move head pointer to next element in the list.
Step 15 − Displays element to delete.
Step 16 − Deallocate the memory.
Follow the steps given below to delete a tail element in C programming language.
1. void del_tail()
2. {
3. int x;
4. Node *temp;
5. if(Head==NULL)
6. {
7. printf("List is empty");
8. return;
9. }
10. temp=Head;
11. while(temp->next !=Tail)
12. temp=temp->next;
13. x=Tail->ele;
14. Tail=temp;
15. Temp=temp->next
16. Tail->next=NULL;
17. printf("Deleted element %d",x);
18. free(temp);
19. }
Here,
Step 4 − Checks for list empty.
Step 10, 11, 12 − Move the temp pointer to last but one node of the list.
Step 13 − Reads tail element to delete.
Step 14 − Moves tail pointer to last but one node.
Step 15 − Moves the temp pointer to last node of the list.
Step 16 − Removes the reference from tail node to temp node.
Step 17 − Displays elements to delete.
Step 18 − Deallocate the memory.
Can we change the order of public static void main() to static public void main() in Java?

Yes, we can change the order of public static void main() to static public void main() in Java, the compiler doesn't throw any compile-time or runtime error. In Java, we can declare access modifiers in any order, the method name comes last, the return type comes second to last and then after it's our choice. But it's recommended to put access modifier (public, private and protected) at the forefront as per Java coding standards.
public static void main(String args[]) {
   // some statements
}
Live Demo
class ParentTest {
   int age = 10;
   public int getAge() {
      age += 25;
      return age;
   }
}
public class Test {
   // Here we can declare static public void main(String args[])
   static public void main(String args[]) {
      ParentTest pt = new ParentTest();
      System.out.println("Age is: "+ pt.getAge());
   }
}
In the above example, we have declared static public main() instead of public static void main(), the code runs successfully without any errors.
Age is: 35
Boxplot with variable length data in Matplotlib

To make a boxplot with variable length data in Matplotlib, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Make a list of data points.
Make a box and whisker plot using boxplot() method.
To display the figure, use show() method.
from matplotlib import pyplot as plt

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

data = [[2, 4, 1, 3], [0, 4, 3, 2], [0, 0, 1, 0]]

plt.boxplot(data)

plt.show()
Python & MySQL - Create Database Example

Python uses c.execute(q) function to create or delete a MySQL database where c is cursor and q is the query to be executed.
# execute SQL query using execute() method.
cursor.execute(sql)

$sql
Required - SQL query to create a MySQL database.
Try the following example to create a database −
Copy and paste the following example as mysql_example.ty −
#!/usr/bin/python

import MySQLdb

# Open database connection
db = MySQLdb.connect("localhost","root","root@123")

# prepare a cursor object using cursor() method
cursor = db.cursor()

# execute SQL query using execute() method.
cursor.execute("CREATE DATABASE TUTORIALS")

print('Database created');

# disconnect from server
db.close()
Execute the mysql_example.py script using python and verify the output.
Database created


    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
Selecting a drop-down list by using the Selenium.select_by_visible_text() method in Python - GeeksforGeeks

11 Oct, 2020
Selenium is an effective device for controlling an internet browser thru the program. It is purposeful for all browsers, works on all fundamental OS and its scripts are written in numerous languages i.e Python, Java, C#, etc, we can be running with Python.
Different methods of Select class:
Selection an option from the dropdown menu by INDEX.
Selection an option from the dropdown by VISIBLE TEXT.
Selection an option from the dropdown menu by VALUE.
we are discussing on visible text method in the drop-down list.
The strategy chooses the alternative by its obvious choice label esteem. It acknowledges the noticeable content estimation of the choice tag and brings nothing back.
Requirement: You need to install chromedriver and set path. Click here to download.for more information follows this link.
Working with Drop-down list: Initially, you have to import the Select class and afterward you have to make the case of Select class. After making the case of Select class, you can perform select strategies on that occasion to choose the choices from the dropdown list.
from selenium.webdriver.support.ui import Select
 for selection by using
drop=Select(driver.find_element_by_id(‘ ‘)
drop.select_by_visible_text(” “)
Example: We will be doing the following:
Import selenium module
Import select class module
Using web page for drop down list (URL).
Navigate to the id of option bar.
Python3
# importing the modulesfrom selenium import webdriverfrom selenium.webdriver.support.ui import Selectimport time  # using chrome driverdriver=webdriver.Chrome()  # web page urldriver.get("https://fs2.formsite.com/meherpavan/form2/index.html?1537702596407")  # find id of optionx = driver.find_element_by_id('RESULT_RadioButton-9')drop=Select(x)  # select by visible textdrop.select_by_visible_text("Afternoon")time.sleep(4)driver.close()
Output:
Python-selenium
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Defaultdict in Python
Python | Get unique values from a list
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
C program to print digital clock with current time

In this section we will see how to make a digital clock using C. To work with time we can use the time.h header file. This header file has some function signatures that are used to handle date and time related issues.
The four important components of time.h is like below
size_t This size_t is basically the unsigned integral type. This is the result of sizeof().
size_t This size_t is basically the unsigned integral type. This is the result of sizeof().
clock_t This is used to store the processor time
clock_t This is used to store the processor time
time_t This is used to store calendar time
time_t This is used to store calendar time
struct tm This is a structure. It helps to hold the entire date and time.
struct tm This is a structure. It helps to hold the entire date and time.
#include <stdio.h>
#include <time.h>
int main() {
   time_t s, val = 1;
   struct tm* curr_time;
   s = time(NULL); //This will store the time in seconds
   curr_time = localtime(&s); //get the current time using localtime()
   function
      //Display in HH:mm:ss format
      printf("%02d:%02d:%02d", curr_time->tm_hour, curr_time->tm_min,
   curr_time->tm_sec);
}
23:35:44
File isHidden() method in Java with Examples - GeeksforGeeks

28 Jan, 2019
The isHidden() function is a part of File class in Java . This function determines whether the is a file or Directory denoted by the abstract filename is Hidden or not.The function returns true if the abstract file path is Hidden else return false.
Function signature:
public boolean isHidden()
Syntax:
file.isHidden()
Parameters: This method does not accept any parameter.
Return Type The function returns boolean data type representing whether a file is hidden or not
Exception: This method throws Security Exception if the write access to the file is denied
Below programs illustrates the use of isHidden() function:
Example 1: The file “F:\\program.txt” is not hidden
// Java program to demonstrate// isHidden() method of File Class  import java.io.*;  public class solution {    public static void main(String args[])    {          // Get the file        File f = new File("F:\\program.txt");          // Check if the specified file        // is Hidden or not        if (f.isHidden())            System.out.println("File Hidden");        else            System.out.println("File Not Hidden");    }}
Output:
File Hidden
Example 2: The file “F:\\program1.txt” is hidden
// Java program to demonstrate// isHidden() method of File Class  import java.io.*;  public class solution {    public static void main(String args[])    {          // Get the file        File f = new File("F:\\program1.txt");          // Check if the specified file        // is Hidden or not        if (f.isHidden())            System.out.println("File Hidden");        else            System.out.println("File Not Hidden");    }}
Output:
File Not Hidden
Note: The programs might not run in an online IDE. Please use an offline IDE and set the path of the file.
Java-File Class
Java-Functions
Java-IO package
Java Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Apply Different Styles to a Cell in a Spreadsheet using Java?
How to Iterate HashMap in Java?
Java Program to Sort Names in an Alphabetical Order
Iterate Over the Characters of a String in Java
Create Password Protected Zip File in Java
How to Get Elements By Index from HashSet in Java?
Java Program to Write into a File
Pizza Shop Billing System using Java Swing
How to Replace a Element in Java ArrayList?
How to Write Data into Excel Sheet using Java?
Basic Line Chart with curved lines

Following is an example of a basic line chart with smooth curved lines. We've already seen the configuration used to draw this chart in Google Charts Configuration Syntax chapter. So, let's see the complete example.
We've added backgroundColor configuration to change default background color.
// Set chart options
var options = {
   curveType: 'function'
};
googlecharts_line_curve.htm
<html>
   <head>
      <title>Google Charts Tutorial</title>
      <script type = "text/javascript" src = "https://www.gstatic.com/charts/loader.js"></script>
      <script type = "text/javascript">
         google.charts.load('current', {packages: ['corechart','line']});  
      </script>
   </head>
   
   <body>
      <div id = "container" style = "width: 550px; height: 400px; margin: 0 auto">
      </div>
      <script language = "JavaScript">
         function drawChart() {
            // Define the chart to be drawn.
            var data = new google.visualization.DataTable();
            data.addColumn('string', 'Month');
            data.addColumn('number', 'Tokyo');
            data.addColumn('number', 'New York');
            data.addColumn('number', 'Berlin');
            data.addColumn('number', 'London');
            data.addRows([
               ['Jan',  7.0, -0.2, -0.9, 3.9],
               ['Feb',  6.9, 0.8, 0.6, 4.2],
               ['Mar',  9.5,  5.7, 3.5, 5.7],
               ['Apr',  14.5, 11.3, 8.4, 8.5],
               ['May',  18.2, 17.0, 13.5, 11.9],
               ['Jun',  21.5, 22.0, 17.0, 15.2],
               
               ['Jul',  25.2, 24.8, 18.6, 17.0],
               ['Aug',  26.5, 24.1, 17.9, 16.6],
               ['Sep',  23.3, 20.1, 14.3, 14.2],
               ['Oct',  18.3, 14.1, 9.0, 10.3],
               ['Nov',  13.9,  8.6, 3.9, 6.6],
               ['Dec',  9.6,  2.5,  1.0, 4.8]
            ]);
            
            // Set chart options
            var options = {'title' : 'Average Temperatures of Cities',
               hAxis: {
                  title: 'Month'
               },
               vAxis: {
                  title: 'Temperature'
               },   
               'width':550,
               'height':400,
               curveType: 'function'
            };

            // Instantiate and draw the chart.
            var chart = new google.visualization.LineChart(document.getElementById('container'));
            chart.draw(data, options);
         }
         google.charts.setOnLoadCallback(drawChart);
      </script>
   </body>
</html>
Verify the result.
 Print
 Add Notes
 Bookmark this page
How GIN Indices Can Make Your Postgres Queries 15x Faster | by GreekDataGuy | Towards Data Science

Adding an index has improved query time from minutes to milliseconds more than I can count during my career. As data scientists, we spend A LOT of time querying and analyzing data so we should know how to do it efficiently.
Postgres has 6 index types. Today we’re covering GIN indices.
We’re going to seed a database with increasingly large amounts of data and compare query time with and without a GIN index. You’ll benefit more if you follow along in your SQL editor (I’m using DBeaver).
A data structure that makes retrieving data from a database more efficient at the cost of slower insert speeds and more disk space.
GIN stands for Generalized Inverted Index. In general, an inverted index maps words to its position in a table.
Below is an abstraction I drew of an inverted index.
If we wanted to find sentences in the table with the word lazy without an index, we’d need to iterate over every sentence in the table looking for matches.
But by adding an index, we know in advance which sentences contain the word lazy and can load those directly. This makes things a lot faster!
This type of index is good for querying composite datatypes, meaning they store more than 1 value. Examples are hStores, Arrays, Ranges and JSONs.
Let’s find out.
Start by creating a table and populating it with data.
# create tableCREATE TABLE articles (  body text,  body_indexed text);# add an indexCREATE INDEX articles_search_idx ON articles USING gin (body_indexed gin_trgm_ops);# populate table with dataINSERT INTO articlesSELECT  md5(random()::text),  md5(random()::text)from (  SELECT * FROM generate_series(1,100000) AS id) AS x;
Awesome we now have a table called articles with 100k records, and 2 columns of random strings.
If you’re curious about the index. We didn’t index strings directly but used Postgres’s gin_trgm_ops to create trigrams (think ngrams in sklearn) from each string, and indexed that.
The table looks like this in my SQL editor.
I’m going to track query time after each 100k new records I add.
I’ll be running these queries.
SELECT count(*) FROM articles where body ilike '%abc%';SELECT count(*) FROM articles where body_indexed ilike'%abc%';
The same or a similar query run multiple times can vary in run time. This is due varying system load on your machine and changing query plans. For our purposes ignore fluctuations and look at general trends of time differences.
Wow! That’s a big difference on only 2 million records. Imagine we were querying on a database of billions.
Most of the time we just need to add a B-tree index. But sometimes another index like GIN is more appropriate. Just knowing that other index types are out there can be useful when you eventually come across a problem B-trees don’t solve.
Have you come across any cool use cases of indices or applied them in interesting ways?
How to convert row index number or row index name of an R data frame to a vector?

We might want to extract row index irrespective of its type (whether numeric or string) to do some calculations if it is incorrectly set as a row index. It happens during the data collection process or incorrect processing of data. Also, since row indexes are helpful to access row we must have proper names to them instead of values that might makes confusion. For example, if a data frame has row indexes as 43, 94, etc. then it might be confusing. Therefore, we should convert row indexes to a vector or a column if required.
Consider the below data frame (Here, we are using simple sequence of numbers) −
> set.seed(1)
> x1<-rnorm(20,0.01)
> x2<-rpois(20,2)
> x3<-runif(20,2,5)
> df<-data.frame(x1,x2,x3)
> df
    x1 x2           x3
1  -0.616453811 3 4.738628
2   0.193643324 2 2.880810
3  -0.825628612 3 3.377197
4   1.605280802 2 2.997184
5   0.339507772 2 3.952611
6  -0.810468384 3 2.774050
7   0.497429052 0 3.435636
8   0.748324705 2 4.298932
9   0.585781352 3 2.252741
10 -0.295388387 3 4.625964
11  1.521781168 2 3.017219
12  0.399843236 4 4.518321
13 -0.611240581 2 3.040050
14 -2.204699887 1 3.001325
15  1.134930918 0 3.429054
16 -0.034933609 0 4.676595
17 -0.006190263 1 4.593018
18  0.953836211 2 3.169969
19  0.831221195 2 4.331962
20  0.603901321 2 4.881854
Converting row index number to a vector −
> Numeric_Vector_of_row_names<-as.numeric(rownames(df))
> Numeric_Vector_of_row_names
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
> is.vector(Numeric_Vector_of_row_names)
[1] TRUE
Now suppose that the row index was not a number as shown below −
> rownames(df)<-LETTERS[1:20]
> df
    x1 x2        x3
A -0.616453811 3 4.738628
B  0.193643324 2 2.880810
C -0.825628612 3 3.377197
D  1.605280802 2 2.997184
E  0.339507772 2 3.952611
F -0.810468384 3 2.774050
G  0.497429052 0 3.435636
H  0.748324705 2 4.298932
I  0.585781352 3 2.252741
J -0.295388387 3 4.625964
K  1.521781168 2 3.017219
L  0.399843236 4 4.518321
M -0.611240581 2 3.040050
N -2.204699887 1 3.001325
O  1.134930918 0 3.429054
P -0.034933609 0 4.676595
Q -0.006190263 1 4.593018
R  0.953836211 2 3.169969
S  0.831221195 2 4.331962
T  0.603901321 2 4.881854
These row indexes can be converted to a vector as shown below −
> Row_names_String<-rownames(df)
> Row_names_String
[1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S"
[20] "T"
> is.vector(Row_names_String)
[1] TRUE
Hide or show HTML elements using visibility property in JavaScript - GeeksforGeeks

02 Mar, 2021
The visibility property is used to hide or show the content of HTML elements. The visibility property specifies that the element is currently visible on the page. The ‘hidden’ value can be used to hide the element. This hides the element but does not remove the space taken by the element, unlike the display property.
Syntax:
element.style.visibility = 'hidden';
element.style.visibility = 'visible';
Example: 
html
<!DOCTYPE html><html> <head>     <style>        .container {            height: 80px;            width: 250px;            border: 2px solid black;            background-color: green;            color: white;        }    </style></head> <body>    <div class="container">        <h1>GeeksforGeeks</h1>    </div>      <p>        Click the buttons to show or hide the green box    </p>      <button onclick="showElement()">            Show Element    </button>     <button onclick="hideElement()">            Hide Element    </button>     <script type="text/javascript">        function showElement() {            element = document.querySelector('.container');            element.style.visibility = 'visible';        }         function hideElement() {            element = document.querySelector('.container');            element.style.visibility = 'hidden';        }    </script></body> </html>
Output:  
 
 
ghoshsuman0129
JavaScript-Properties
Picked
JavaScript
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
How to Open URL in New Tab using JavaScript ?
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
How to sum elements of a column in MySQL?

Use aggregate function sum() to sum the elements of a column in MySQL. The syntax is as follows −
select sum(yourColumnName1) as anyVariableName1,sum(yourColumnName2) as anyVariableName2,sum(yourColumnName3) as anyVariableName3,............N from yourTableName;
To understand the above syntax, let us create a table. The following is the query to create a table −
mysql> create table SumDemoOnColumns
   −> (
   −> First int,  
   −> Second int,
   −> Third int
   −> );
Query OK, 0 rows affected (0.56 sec)
Insert some data in the table using insert command. The query is as follows −
mysql> insert into SumDemoOnColumns values(10,20,30);
Query OK, 1 row affected (0.18 sec)

mysql> insert into SumDemoOnColumns values(40,50,60);
Query OK, 1 row affected (0.32 sec)

mysql> insert into SumDemoOnColumns values(70,80,90);
Query OK, 1 row affected (0.10 sec)

mysql> insert into SumDemoOnColumns values(100,110,120);
Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from SumDemoOnColumns;
The following is the output −
+-------+--------+-------+
| First | Second | Third |
+-------+--------+-------+
|    10 |     20 |    30 |
|    40 |     50 |    60 |
|    70 |     80 |    90 |
|   100 |    110 |   120 |
+-------+--------+-------+
4 rows in set (0.00 sec)
The following is the query to get sum of columns −
mysql> select sum(First) as First,sum(Second) as Second,sum(Third) as Third from SumDemoOnColumns;
The following is the output −
+-------+--------+-------+
| First | Second | Third |
+-------+--------+-------+
|   220 |    260 |   300 |
+-------+--------+-------+
1 row in set (0.00 sec)