code-rag-bench/online-tutorials huggingface dataset:
How to display Pandas Dataframe in Python without Index?

Use index=False to ignore index. Let us first import the required library −
import pandas as pd
Create a DataFrame −
dataFrame = pd.DataFrame([[10, 15], [20, 25], [30, 35]],index=['x', 'y', 'z'],columns=['a', 'b'])
Select rows by passing label using loc −
dataFrame.loc['x']

Display DataFrame without index −
dataFrame.to_string(index=False)
Following is the code −
import pandas as pd

# Create DataFrame
dataFrame = pd.DataFrame([[10, 15], [20, 25], [30, 35]],index=['x', 'y', 'z'],columns=['a', 'b'])

# DataFrame
print"Displaying DataFrame with index...\n",dataFrame

# select rows with loc
print"\nSelect rows by passing label..."
print(dataFrame.loc['x'])

# display DataFrame without index
print"\nDisplaying DataFrame without Index...\n",dataFrame.to_string(index=False)
This will produce the following output −
Displaying DataFrame with index...
    a   b
x  10  15
y  20  25
z  30  35

Select rows by passing label...
a  10
b  15
Name: x, dtype: int64

Displaying DataFrame without Index...
 a   b
10  15
20  25
30  35
How to remove hash from window.location with JavaScript without page refresh ? - GeeksforGeeks

26 Jul, 2021
The replaceState() method is used to modify the current history entry, replacing it with the state objects, title, and URL passed in the method parameters. This method is useful when you want to update the state object or URL of the current history entry in response to some user action. To remove the hash URL, you can use the replaceState method on the history API to remove the hash location.Example:  
HTML
<!DOCTYPE html><html> <head>    <title>        How to remove hash from window.location        with JavaScript without page refresh?    </title></head> <body style="text-align: center;">     <h1 style="color: green">        GeeksforGeeks    </h1>      <p>        How to remove the hash from        window.location</br> with        JavaScript without page refresh?    </p>       <p>        Click on the button to modify        the current history state    </p>      <button onclick="modifyState()">        Modify history state    </button>     <button onclick="remove_hash_from_url()">        Remove hash from url    </button>     <script>        function modifyState() {            let stateObj = { id: "100" };            window.history.replaceState(stateObj,                "Page 3", "/answer#page3.html");        }                 function remove_hash_from_url() {            var uri = window.location.toString();             if (uri.indexOf("#") > 0) {                var clean_uri = uri.substring(0,                                uri.indexOf("#"));                 window.history.replaceState({},                        document.title, clean_uri);            }        }    </script></body> </html>
Output:  
 
anikakapoor
CSS-Misc
HTML-Misc
Picked
CSS
HTML
JavaScript
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to create footer to stay at the bottom of a Web page?
Types of CSS (Cascading Style Sheet)
How to position a div at the bottom of its container using CSS?
Create a Responsive Navbar using ReactJS
Design a web page using HTML and CSS
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
Hide or show elements in HTML using display property
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
How to read data from PDF file and display on console in Java?

There are several libraries to read data from a pdf using Java. Let us see how to read data from a PDF document and display it on the console using a library named PDFBox.
You can extract text using the getText() method of the PDFTextStripper class. This class extracts all the text from the given PDF document to use this.
Load an existing PDF document using the static method load() of the PDDocument class.
Load an existing PDF document using the static method load() of the PDDocument class.
Instantiate the PDFTextStripper class.
Instantiate the PDFTextStripper class.
Retrieve.read the contents of the PDF page to a String using the getText() method of the PDFTextStripper class.
Retrieve.read the contents of the PDF page to a String using the getText() method of the PDFTextStripper class.
Finally, close the document using the close() method of the PDDocument class as shown below.
Finally, close the document using the close() method of the PDDocument class as shown below.
Assume we have a pdf with name sample.PDF in the directory D:// as shown below −
Following the Java program reads the contents of the above-mentioned PDF document and displays them on the console.
import java.io.File;
import java.io.IOException;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
public class PdfToConsole {
   public static void main(String args[]) throws IOException {
      //Loading an existing document
      File file = new File("D://Sample.pdf");
      PDDocument document = PDDocument.load(file);
      //Instantiate PDFTextStripper class
      PDFTextStripper pdfStripper = new PDFTextStripper();
      //Retrieving text from PDF document
      String text = pdfStripper.getText(document);
      System.out.println(text);
      //Closing the document
      document.close();
   }
}
Tutorials Point originated from the idea that there exists a class of readers who respond
better to online content and prefer to learn new skills at their own pace from the comforts 
of their drawing rooms.
The journey commenced with a single tutorial on HTML in 2006 and elated by the response it
generated, we worked our way to adding fresh tutorials to our repository which now proudly 
flaunts a wealth of tutorials and allied articles on topics ranging from
programming languages to web designing to academics and much more.
Tryit Editor v3.7

Tryit: HTML abbreviations
How to pass Checkbox Data to Python CGI script?



Checkboxes are used when more than one option is required to be selected.
Here is example HTML code for a form with two checkboxes −
<form action = "/cgi-bin/checkbox.cgi" method = "POST" target = "_blank">
<input type = "checkbox" name = "maths" value = "on" /> Maths
<input type = "checkbox" name = "physics" value = "on" /> Physics
<input type = "submit" value = "Select Subject" />
</form>
The result of this code is the following form −
Maths  Physics Select Subject
Below is checkbox.cgi script to handle input given by web browser for checkbox button.
#!/usr/bin/python
# Import modules for CGI handling
import cgi, cgitb
# Create instance of FieldStorage
form = cgi.FieldStorage()
# Get data from fields
if form.getvalue('maths'):
   math_flag = "ON"
else:
   math_flag = "OFF"
if form.getvalue('physics'):
   physics_flag = "ON"
else:
   physics_flag = "OFF"
print "Content-type:text/html\r\n\r\n"
print "<html>"
print "<head>"
print "<title>Checkbox - Third CGI Program</title>"
print "</head>"
print "<body>"
print "<h2> CheckBox Maths is : %s</h2>" % math_flag
print "<h2> CheckBox Physics is : %s</h2>" % physics_flag
print "</body>"
print "</html>"
jQuery Mobile - Multi-Page Template

Multiple pages can be included in the single jQuery mobile document which loads together by adding multiple divs with the attribute data-role = "page". The div with data-role = "page" should consist unique id to link internally between the pages.
Following example demonstrates the use of multi page in the jQuery Mobile.
<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" 
         href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
   </head>
   
   <body>
      <div data-role = "page" id = "page1">
         <div data-role = "header">
            <h2>Header</h2>
         </div>
         
         <div role = "main" class = "ui-content">
            <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
            <p> For more information <a href = "#page2">click here</a></p>
         </div>
         
         <div data-role = "footer">
            <h4>Footer</h4>
         </div>
      </div>
      
      <div data-role = "page" id = "page2">
         <div data-role = "header">
            <h1>Header Text</h1>
         </div>
         
         <div role = "main" class = "ui-content">
            <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
            Lorem Ipsum has been the  industry's standard dummy text ever since the 
            1500s.</p>
            
            <p><a href = "#page1">Back to previous page</a></p>
         </div>
         
         <div data-role = "footer">
            <h4>Footer Text</h4>
         </div>
      </div>
   </body>
</html>
Let's carry out the following steps to see how the above code works −
Save the above html code as multiple_page.html file in your server root folder.
Save the above html code as multiple_page.html file in your server root folder.
Open this HTML file as http://localhost/multiple_page.html and the following output will be displayed.
Open this HTML file as http://localhost/multiple_page.html and the following output will be displayed.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
 For more information click here
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
Back to previous page

    27 Lectures 
     1 hours 

 Mahesh Kumar

    27 Lectures 
     1.5 hours 

 Pratik Singh

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    60 Lectures 
     9 hours 

 Eduonix Learning Solutions

    17 Lectures 
     2 hours 

 Sandip Bhattacharya

    12 Lectures 
     53 mins

 Laurence Svekis
 Print
 Add Notes
 Bookmark this page
Python - Convert String to unicode characters - GeeksforGeeks

02 Sep, 2020
Given a String, convert its characters to unicode characters.
Input : test_str = ‘gfg’Output : \u0067\u0066\u0067Explanation : Result changed to unicoded string.
Input : test_str = ‘himani’Output : \u0068\u0069\u006D\u0061\u006E\u0069Explanation : Result changed to unicoded string.
Method #1 : Using re.sub() + ord() + lambda
In this, we perform the task of substitution using re.sub() and lambda function is used to perform the task of conversion of each characters using ord().
Python3
# Python3 code to demonstrate working of # Convert String to unicode characters# using re.sub() + ord() + lambdaimport re  # initializing stringtest_str = 'geeksforgeeks'  # printing original Stringprint("The original string is : " + str(test_str))  # using sub() to perform substitutions# ord() for conversion.res = (re.sub('.', lambda x: r'\u % 04X' % ord(x.group()), test_str))  # printing result print("The unicode converted String : " + str(res)) 
The original string is : geeksforgeeks
The unicode converted String : \u0067\u0065\u0065\u006B\u0073\u0066\u006F\u0072\u0067\u0065\u0065\u006B\u0073

Method #2 : Using join() + format() + ord()
In this, task of substitution in unicode formatted string is done using format() and ord() is used for conversion.
Python3
# Python3 code to demonstrate working of # Convert String to unicode characters# using join() + format() + ord()import re  # initializing stringtest_str = 'geeksforgeeks'  # printing original Stringprint("The original string is : " + str(test_str))  # using format to perform required formatting res = ''.join(r'\u{:04X}'.format(ord(chr)) for chr in test_str)  # printing result print("The unicode converted String : " + str(res)) 
The original string is : geeksforgeeks
The unicode converted String : \u0067\u0065\u0065\u006B\u0073\u0066\u006F\u0072\u0067\u0065\u0065\u006B\u0073

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 ?
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
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?
Autoincrement in MySQL begins from 1? How can we begin it from another number?

The autoincrement in MySQL gives a unique number every time. By default, it starts at 1. If you want to start from another number, then you need to change the auto-increment value with the help of ALTER command or you can give value at the time of table creation.
Let us first create a table −
mysql> create table DemoTable
(
   UniqueNumber int NOT NULL AUTO_INCREMENT,
   PRIMARY KEY(UniqueNumber)
);
Query OK, 0 rows affected (0.53 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values();
Query OK, 1 row affected (0.30 sec)
mysql> insert into DemoTable values();
Query OK, 1 row affected (0.26 sec)
mysql> insert into DemoTable values();
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable values();
Query OK, 1 row affected (0.08 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+--------------+
| UniqueNumber |
+--------------+
|            1 |
|            2 |
|            3 |
|            4 |
+--------------+
4 rows in set (0.00 sec)
Following is the query to change the auto_increment value to begin from another number −
mysql> alter table DemoTable AUTO_INCREMENT=1000;
Query OK, 0 rows affected (0.18 sec)
Records: 0 Duplicates: 0 Warnings: 0
Insert some records in the table using insert command −
mysql> insert into DemoTable values();
Query OK, 1 row affected (0.09 sec)
mysql> insert into DemoTable values();
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable values();
Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output. Now the new auto_increment value inserted and begins from 1000 −
+--------------+
| UniqueNumber |
+--------------+
|            1 |
|            2 |
|            3 |
|            4 |
|         1000 |
|         1001 |
|         1002 |
+--------------+
7 rows in set (0.00 sec)
CICS - Abend

Abend command is used to terminate the task intentionally. Using Abend command, we can set a user-defined abend code. Following is the syntax of Abend command −
EXEC CICS ABEND
   ABCODE(name)
END-EXEC.

The following example shows how to use the Abend command in a program. It will abend when the program reaches this paragraph with the user-defined abend code. In the following example, it will abend with abend code D100 −
IDENTIFICATION DIVISION.                                         
PROGRAM-ID. HELLO.                                               
PROCEDURE DIVISION.

EXEC CICS ABEND
   ABCODE(D100) 
END-EXEC.
 Print
 Add Notes
 Bookmark this page
Create a white image using NumPy in Python - GeeksforGeeks

02 Sep, 2020
Let us see how to create a white image using NumPy and cv2. A white image has all its pixels as 255.
Method 1: Using np.full() method :  
Python3
# importing the librariesimport cv2import numpy as np  # creating an array using np.full # 255 is code for white colorarray_created = np.full((500, 500, 3),                        255, dtype = np.uint8)  # displaying the imagecv2.imshow("image", array_created)
Output:
Method 2: By creating an array using np.zeroes() :  
Python3
# importing the modulesimport numpy as npimport cv2  # creating array using np.zeroes()array = np.zeros([500, 500, 3],                 dtype = np.uint8)  # setting RGB color values as 255,255,255array[:, :] = [255, 255, 255]   # displaying the imagecv2.imshow("image", array)
Output:
 
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Box Plot in Python using Matplotlib
Bar Plot in Matplotlib
Python | Get dictionary keys as a list
Python | Convert set into a list
Ways to filter Pandas DataFrame by column values
Python - Call function from another file
loops in python
Multithreading in Python | Set 2 (Synchronization)
Python Dictionary keys() method
Python Lambda Functions
java.lang.reflect.Array.newInstance() Method Example

The java.lang.reflect.Array.newInstance(Class<?> componentType, int length) method creates a new array with the specified component type and length.
Following is the declaration for java.lang.reflect.Array.newInstance(Class<?> componentType, int length) method.
public static Object newInstance(Class<?> componentType, int length)
   throws IllegalArgumentException, NegativeArraySizeException

componentType − the Class object representing the component type of the new array.
componentType − the Class object representing the component type of the new array.
length − an array of int representing the dimensions of the new array.
length − an array of int representing the dimensions of the new array.
the new array.
NullPointerException − If the specified componentType is null.
NullPointerException − If the specified componentType is null.
IllegalArgumentException − if the specified dimensions argument is a zero-dimensional array, or if the number of requested dimensions exceeds the limit on the number of array dimensions supported by the implementation (typically 255), or if componentType is Void.TYPE.
IllegalArgumentException − if the specified dimensions argument is a zero-dimensional array, or if the number of requested dimensions exceeds the limit on the number of array dimensions supported by the implementation (typically 255), or if componentType is Void.TYPE.
ArrayIndexOutOfBoundsException − If the specified index argument is negative.
ArrayIndexOutOfBoundsException − If the specified index argument is negative.
The following example shows the usage of java.lang.reflect.Array.newInstance(Class<?> componentType, int length) method.
package com.tutorialspoint;

import java.lang.reflect.Array;

public class ArrayDemo {
   public static void main(String[] args) {

      String[] stringArray = (String[]) Array.newInstance(String.class, 3);

      Array.set(stringArray, 0, "Mahesh");
      Array.set(stringArray, 1, "Ramesh");
      Array.set(stringArray, 2, "Suresh");

      System.out.println("stringArray[0] = " + Array.get(stringArray, 0));
      System.out.println("stringArray[1] = " + Array.get(stringArray, 1));
      System.out.println("stringArray[2] = " + Array.get(stringArray, 2));
   }
}
Let us compile and run the above program, this will produce the following result −
stringArray[0] = Mahesh
stringArray[1] = Ramesh
stringArray[2] = Suresh

 Print
 Add Notes
 Bookmark this page
How to Change the Mac Address in Kali Linux Using Macchanger? - GeeksforGeeks

08 Jun, 2020
When you are anonymizing your system for penetration testing there are a number of steps you follow. At some point, you also change or fake your mac address so your original device network card’s hardware MAC address is hidden. To do so you can use a tool macchanger which is already present in Kali Linux.
If you are using a penetrating testing distro like a parrot or kali it is already present in it, so right now we will give priority to only penetration testing operating systems as the majority of users is there only. But still, if you need you can clone the repo from GitHub you can use this link of macchanger
Change random mac address: First lets change network card’s hardware MAC address to a random address. First, we will find the MAC address of the eth0 network interface. To do this we execute macchanger with an option -s and an argument eth0.
macchanger -s eth0
Now the network interface you are about to change a MAC address should be turned off before changing the mac address. Use ifconfig command to turn off your network interface:
ifconfig eth0 down
Now we can change the MAC address of the hardware by using the command
macchanger -r eth0
Once you have executed the command you can finally turn your network interface up
ifconfig eth0 down
Now you can display your MAC by using:
macchanger -s eth0
Change specific MAC address: You can use MAC changer to change MAC of your choice follow the commands
~ ifconfig eth0 down
~ macchanger -m 00:d0:70:00:20:69 eth0
~ ifconfig eth0 up
~ macchanger -s eth0

Follow the same sequence as we did for random change, the only difference is that this time you have your specific MAC address with you. Use -l option to find a MAC address prefix of a specific hardware vendor:
~macchanger -l
Kali-Linux
Linux-Unix
TechTips
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
TCP Server-Client implementation in C
ZIP command in Linux with examples
SORT command in Linux/Unix with examples
tar command in Linux with examples
curl command in Linux with Examples
How to Find the Wi-Fi Password Using CMD in Windows?
Docker - COPY Instruction
How to Run a Python Script using Docker?
Top Programming Languages for Android App Development
Running Python script on GPU.
How to install third party packages using npm

Now, so far we saw how to create a node project with npm init command and also adding scripts to run application.
We used core modules of node.js like http, fs etc which are available by default with node.js but working only with these core modules does not simplify our work. To add more useful functionality and simpler code we requires to install third party libraries like express, body-parser etc.
We get the third party libraries from cloud stored npm repository. Installation is done using npm install command.
We are running our App.js file using npm start command. But whenever we do change our code, we have to stop server using ctrl + c and then restart using npm start to make available those changes.
To make things simpler, we have third party package called nodemon to auto restart whenever changes are added automatically.
Dependencies which are required in production environment are categorized as just dependencies and the other libraries which are required only in development mode are categorized as de dependencies.
To install a library as dev dependency we used –save-dev in our npm install command.On installation complete package.json file looks like −
{
   "name": "dev",
   "version": "1.0.0",
   "description": "",
   "main": "App.js",
   "scripts": {
      "test": "echo \"Error: no test specified\" &&
      exit 1",
      "start": "node App.js"
   },
   "author": "",
   "license": "ISC",
   "devDependencies": {
      "nodemon": "^2.0.3"
   }
}
package.json file shows the installed version of nodemon.
With the addition of first third party library, we also get a folder named Node Modules and file package-lock.json
Package-lock.json maintains the internal tree hierarchy of libraries which are dependent on each other.
^ in version number of nodemon is for deciding latest version ,how nodemon will be installed in any other systems on npm install.
How to use nodemon −
In our npm scripts section we have npm start command −
"scripts": {
   "test": "echo \"Error: no test specified\" && exit 1",
   "start": "node App.js"
},
Start command will need to change −
"scripts": {
   "test": "echo \"Error: no test specified\" && exit 1",
   "start": "nodemon App.js"
},
Now, we can run app using npm start and it will also auto restart on any code change save.
Algebra - GeeksforGeeks

13 Oct, 2021
x3+y3 = (x + y) × (x2 − xy + y2)

Putting given values of x3+y3 and (x + y)
9 = 3 × ((x+y)2 − 3xy)
  = 3 × (9 − 3xy) 
  = 27 − 9xy

9xy = 18
xy = 2

x4 + y4 = (x2 + y2)2 - 2x2y2
   = (x2 + y2)2 - 2*4 
                                  [Putting value of xy]
   = ((x + y)2 - 2xy)2 - 2*4 
                            [Putting values of (x+y) and xy]
   = (9 - 4)2 - 2*4 
   = 17
x3 + 1/8x3 + 3 = 23
x3 + 1/8x3 = 5
8x3 + 1/x3 = 5.8 = 40
E = (b + 1⁄b)(b2 - 1 + 1⁄b2)

Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Comments
Old Comments
Must Do Coding Questions for Product Based Companies
How to Update Multiple Columns in Single Update Statement in SQL?
Difference between var, let and const keywords in JavaScript
Array of Objects in C++ with Examples
SQLAlchemy Core - Creating Table
How to Replace Values in Column Based on Condition in Pandas?
C Program to read contents of Whole File
How to Replace Values in a List in Python?
Spring - REST Controller
How to Read Text Files with Pandas?
How to clear an ImageView in Android?

This example demonstrates how do I clear an imageview in android.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   tools:context=".MainActivity>
<Button
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_centerHorizontal="true"
   android:layout_marginTop="40dp"
   android:onClick="ClickHere"
   android:text="Click here" />
<ImageView
   android:layout_below="@id/imageView"
   android:id="@+id/imageView"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_centerInParent="true"
   android:background="@drawable/wallpaper"/>
</RelativeLayout>
Step 3 − Add the following code to src/MainActivity.java
package app.com.sample;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
   ImageView imageView;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      imageView = findViewById(R.id.imageView);
   }
   public void ClickHere(View view) {
      imageView.setBackgroundDrawable(null);
   }
}
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="app.com.sample">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from the android studio, open one of your project's activity files and click the Run icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
Comparing ascii scores of strings - JavaScript

ASCII is a 7-bit character code where every single bit represents a unique character.
Every English alphabet has a unique decimal ascii code.
We are required to write a function that takes in two strings and calculates their ascii scores (i.e., the sum of ascii decimal of each character of string) and returns the difference.
Let's write the code for this −
const str1 = 'This is the first string.';
const str2 = 'This here is the second string.';
const calculateScore = (str = '') => {
   return str.split("").reduce((acc, val) => {
      return acc + val.charCodeAt(0);
   }, 0);
};
const compareASCII = (str1, str2) => {
   const firstScore = calculateScore(str1);
   const secondScore = calculateScore(str2);
   return Math.abs(firstScore - secondScore);
};
console.log(compareASCII(str1, str2));
Following is the output in the console −
536
C++ IOS Library - imbue

Associates loc to both the stream and its associated stream buffer (if any) as the new locale object to be used with locale-sensitive operations.
This function calls its inherited homonym ios_base::imbue(loc) and, if the stream is associated with a stream buffer, it also calls rdbuf()->pubimbue(loc).
Following is the declaration for ios::imbue function.
locale imbue (const locale& loc);
loc − Locale object to be imbued as the new locale for the stream.
The locale object associated with the stream before the call.
Basic guarantee − if an exception is thrown, the stream is in a valid state.
Modifies the stream object.
Concurrent access to the same stream object may cause data races.
In below example explains about ios::imbue function.
#include <iostream>     
#include <locale>       

int main() {
   std::locale mylocale("");   
   std::cout.imbue(mylocale);  
   std::cout << 3.14159 << '\n';
   return 0;
}
Let us compile and run the above program, this will produce the following result −
3.14159

 Print
 Add Notes
 Bookmark this page
PyQt5 QDial - Slider's Value Changed Signal - GeeksforGeeks

07 Jul, 2020
In this article we will see how we can get slider’s value changed signal of the QDial. User can change the value with the help of mouse although we can change it programmatically with the help of setValue method. This signal is emitted when the slider value gets changed.
In order to do this we use valueChanged method with the QDial object
Syntax : dial.valueChanged.connect(method)
Argument : It takes method as argument
Return : It returns None
Below is the implementation
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 500, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()      # method for components    def UiComponents(self):          # creating QDial object        dial = QDial(self)          # setting geometry to the dial        dial.setGeometry(100, 100, 100, 100)          # making notch visible        dial.setNotchesVisible(True)          # value        value = 50          # setting value to the dial slider        dial.setValue(value)            # creating a label        label = QLabel("GeeksforGeeks", self)          # setting geometry to the label        label.setGeometry(220, 125, 200, 60)          # making label multiline        label.setWordWrap(True)          # getting slider value        value = dial.value()          # setting text to the label        label.setText("Value : " + str(value))          # getting value changed signal        dial.valueChanged.connect(lambda: label.setText("Value = " + str(dial.value())))      # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python PyQt-QDial
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
PHP | DOMDocument getElementById() Function - GeeksforGeeks

20 Feb, 2020
The DOMDocument::getElementById() function is an inbuilt function in PHP which is used to search for an element with a certain id.
Syntax:
DOMElement DOMDocument::getElementById( string $elementId )
Parameters:This function accepts a single parameter $elementId which holds the id to search for.
Return Value: This function returns the DOMElement or NULL if the element is not found.
Below given programs illustrate the DOMDocument::getElementById() function in PHP:
Program 1: In this program we will get the tagname of element with certain id.
<?php  // Create a new DOM Document$dom = new DOMDocument('1.0', 'iso-8859-1');  // Enable validate on parse$dom->validateOnParse = true;  // Create a div element$element = $dom->appendChild(new DOMElement('div'));  // Create a id attribute to div$attr = $element->setAttributeNode(        new DOMAttr('id', 'my_id'));  // Set that attribute as id$element->setIDAttribute('id', true);  // Get the tag name$tagname = $dom->getElementById('my_id')->tagName;  echo $tagname;?>
Output:
div // Because id 'my_id' is applied to div tag.
Program 2: In this program we will get the content of element with certain id.
<?php  // Create a new DOM Document$dom = new DOMDocument('1.0', 'iso-8859-1');  // Enable validate on parse$dom->validateOnParse = true;  // Create a div element$element = $dom->appendChild(new DOMElement('div',   'Hey, this is the text content of the div element.'));  // Create a id attribute to div$attr = $element->setAttributeNode(          new DOMAttr('id', 'my_id'));  // Set that attribute as id$element->setIDAttribute('id', true);  // Get the tag content$tagcontent = $dom->getElementById('my_id')->textContent;  echo $tagcontent;?>
Output:
Hey, this is the text content of the div element.
Reference: https://www.php.net/manual/en/domdocument.getelementbyid.php
PHP-DOM
PHP-function
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to Upload Image into Database and Display it using PHP ?
How to check whether an array is empty using PHP?
PHP | Converting string to Date and DateTime
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 ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Mongoose | update() Function - GeeksforGeeks

20 May, 2020
The update() function is used to update one document in the database without returning it.
Installation of mongoose module:
You can visit the link to Install mongoose module. You can install this package by using this command.npm install mongooseAfter installing mongoose module, you can check your mongoose version in command prompt using the command.npm version mongooseAfter that, you can just create a folder and add a file, for example index.js. To run this file you need to run the following command.node index.js
You can visit the link to Install mongoose module. You can install this package by using this command.npm install mongoose
npm install mongoose
After installing mongoose module, you can check your mongoose version in command prompt using the command.npm version mongoose
npm version mongoose
After that, you can just create a folder and add a file, for example index.js. To run this file you need to run the following command.node index.js
node index.js
Filename: index.js
const mongoose = require('mongoose');  // Database Connectionmongoose.connect('mongodb://127.0.0.1:27017/geeksforgeeks', {    useNewUrlParser: true,    useCreateIndex: true,    useUnifiedTopology: true});  // User modelconst User = mongoose.model('User', {    name: { type: String },    age: { type: Number }});  User.update({name:"Gourav"}, function (err, result) {    if (err){        console.log(err)    }else{        console.log("Result :", result)     }});
Steps to run the program:
The project structure will look like this:Make sure you have installed mongoose module using following command:npm install mongooseBelow is the sample data in the database before the function is executed, You can use any GUI tool or terminal to see the database, like we have used Robo3T GUI tool as shown below:Run index.js file using below command:node index.jsAfter the function is executed, You can see the database as shown below:
The project structure will look like this:
Make sure you have installed mongoose module using following command:npm install mongoose
npm install mongoose
Below is the sample data in the database before the function is executed, You can use any GUI tool or terminal to see the database, like we have used Robo3T GUI tool as shown below:
Run index.js file using below command:node index.js
node index.js
After the function is executed, You can see the database as shown below:
So this is how you can use the mongoose update() function which updates one document in the database without returning it.
Mongoose
MongoDB
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Spring Boot JpaRepository with Example
Aggregation in MongoDB
Mongoose Populate() Method
MongoDB - Check the existence of the fields in the specified collection
How to build a basic CRUD app with Node.js and ReactJS ?
Installation of Node.js on Linux
How to update Node.js and NPM to next version ?
Node.js fs.readFileSync() Method
Node.js fs.writeFile() Method
Node.js fs.readFile() Method
Differences between ES6 class and ES5 function constructors - GeeksforGeeks

28 Jul, 2021
In this article, we will discuss the difference between the ES6 class and ES5 function constructors. Both serve the purpose of creating new objects, still, they have some differences between them.
ES6 Class constructors: ES6 class constructors work quite the same as class constructors in other object-oriented languages. They are used to create new objects.
Javascript
<script>    class User {        constructor(name, age, gender) {            this.name = name;            this.age = age;            this.gender = gender;        }        print() {            console.log(`${this.name} has an age of             ${this.age} and gender of ${this.gender}`);        }    }      const Roy = new User('Roy', '19', 'Male');    Roy.print();</script>
Output:
"Roy has an age of 19 and gender of Male"
ES5 function constructor: ES5 function constructors are also used to create objects. The above example can be modified as following through the use of function constructors.
Javascript
<script>    function User(name, age, gender) {        this.age = age;        this.name = name;        this.gender = gender;        this.print = function () {            console.log(                `${this.name} has an age of ${this.age}                 and gender of ${this.gender}`            );        };    }      const Roy = new User('Roy', '19', 'Male');    Roy.print();</script>
Output:
"Roy has an age of 19 and gender of Male"
Difference between ES6 class and ES5 function  constructors:
ES6
JavaScript-Questions
Picked
Difference Between
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Difference Between Method Overloading and Method Overriding in Java
Difference between Prim's and Kruskal's algorithm for MST
Difference between Internal and External fragmentation
Difference between Compile-time and Run-time Polymorphism in Java
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to calculate the number of days between two dates in javascript?
How to get the value in an input text box using jQuery ? - GeeksforGeeks

03 Aug, 2021
jQuery val() method is used to get the value of an element. This function is used to set or return the value. Return value gives the value attribute of the first element. In case of the set value, it sets the value of the attribute for all elements. This element is mostly used with HTML forms.
Syntax:
$(selector).val(function(index, currentvalue))

Example 1: This example is implemented where a text is written in the field and when the show value button is clicked a popover comes up and shows the entered text.
<!DOCTYPE html><html lang="en">  <head>    <script src="https://code.jquery.com/jquery-3.4.1.min.js">    </script>      <script>        $(document).ready(function () {              // On button click, get value            // of input control Show alert            // message box            $("#getValBtnID").click(function () {                var inputString = $("#userInputID").val();                alert(inputString);            });        });    </script></head>  <body>    <h3 style="color:green">        GeeksForGeeks    </h3>      <b>JQuery val() Method</b>          <br><br>          <input type="text" id="userInputID">    <br><br>      <button type="button" id="getValBtnID">        Get Value    </button></body>  </html>
Output:
Example 2: This implementation shows the set value property when the button is clicked. It automatically calls and fills the text box with the predefined data mentioned in the code.
<!DOCTYPE html><html>  <head>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">    </script>      <script>        $(document).ready(function () {            $("#setBtnID").click(function () {                $("input:text").val("Hello World!");            });        });    </script></head>  <body>    <h2 style="color:green">        GeeksForGeeks    </h2>          <b>JQuery val() Method</b>      <p>User Text: <input type="text"        name="userInput">    </p>      <button id="setBtnID">        Set the value of the         input field    </button></body>  </html>
Output:
jQuery is an open source JavaScript library that simplifies the interactions between an HTML/CSS document, It is widely famous with it’s philosophy of “Write less, do more”.You can learn jQuery from the ground up by following this jQuery Tutorial and jQuery Examples.
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Misc
HTML-Misc
jQuery-Misc
Picked
CSS
HTML
JQuery
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to apply style to parent if it has child with CSS?
Types of CSS (Cascading Style Sheet)
How to position a div at the bottom of its container using CSS?
Design a web page using HTML and CSS
How to set space between the flexbox ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
Types of CSS (Cascading Style Sheet)
Filter array based on another array in JavaScript

Suppose we have two arrays of literals like these −
const arr1 = [4, 23, 7, 6, 3, 6, 4, 3, 56, 4];
const arr2 = [4, 56, 23];
We are required to write a JavaScript function that takes in these two arrays and filters the first to contain only those elements that are not present in the second array. And then return the filtered array.
Therefore, the output should look like −
const output = [7, 6, 3, 6, 3];
Therefore, let’s write the code for this function −
The code for this will be −
const arr1 = [4, 23, 7, 6, 3, 6, 4, 3, 56, 4];
const arr2 = [4, 56, 23];
const filterArray = (arr1, arr2) => {
   const filtered = arr1.filter(el => {
      return arr2.indexOf(el) === -1;
   });
   return filtered;
};
console.log(filterArray(arr1, arr2));
The output in the console will be −
[ 7, 6, 3, 6, 3 ]
Working with Input box/Test Box in Selenium with Python - GeeksforGeeks

01 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.
Requirement: You need to install chromedriver and set path. Click here to download, for more information follows this link.
Working with Input box/Test Box, let us how to:
find how many input boxes present in the web page.provide value into text boxes.get the status.
find how many input boxes present in the web page.
provide value into text boxes.
get the status.
Process:
Importing the modules.
https://write.geeksforgeeks.org/reviewer-copy/2197543
We will load the URL https://gitpress.io/u/1155/selenium-Example2RadioButtonAndCheckBoxes in the driver.
Now select the XPath of the desired field by doing:
Then find(navigate) the class name where input is present.
Find the length using len().
Check the status by is_displayed().
Implementation:
Python3
# importing the modulesfrom selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.common.keys import Keysimport time  # using chrome driverdriver = webdriver.Chrome()  # web page urldriver.get("https://fs2.formsite.com/meherpavan/form2/index.html?1537702596407")  # select class name where is input box are presentelement = driver.find_elements(By.CLASS_NAME, "text_field")  # find number of input box print(len(element))  # fill value in input boxdriver.find_element_by_xpath('//*[@id="RESULT_TextField-1"]').send_keys("praveen")driver.find_element_by_xpath('//*[@id="RESULT_TextField-2"]').send_keys("yadav")driver.find_element_by_xpath('//*[@id="RESULT_TextField-3"]').send_keys("87871111")  # check statusx = driver.find_element_by_xpath('//*[@id="RESULT_TextField-1"]').is_displayed()print(x)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
Python Dictionary
Enumerate() in Python
Read a file line by line in Python
Defaultdict in Python
Different ways to create Pandas Dataframe
sum() function in Python
Iterate over a list in Python
Deque in Python
How to Install PIP on Windows ?
Python String | replace()
Get the path of the file selected in the JFileChooser component with Java

To get the path of the selected file, at first get the selected file −
java.io.File f = file.getSelectedFile();
Now, get the path of the selected file which we will get using the above method −
System.err.println(f.getPath());
The following is an example to get the path of the file selected in the JFileChooser component −
package my;
import javax.swing.JFileChooser;
public class SwingDemo {
   public static void main(String[] args) {
      JFileChooser file = new JFileChooser();
      file.setMultiSelectionEnabled(true);
      file.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
      file.setFileHidingEnabled(false);
      if (file.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
         java.io.File f = file.getSelectedFile();
         System.err.println(f.getPath());
      }
   }
}
On clicking “Open” above, the path of the selected file is displayed in the Console −