code-rag-bench/online-tutorials huggingface dataset:
How to set subtitle for action bar in android?

This example demonstrates How to set subtitle for action bar 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"?>
<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"
   xmlns:app = "http://schemas.android.com/apk/res-auto"
   xmlns:tools = "http://schemas.android.com/tools"
   android:layout_width = "match_parent"
   android:gravity = "center"
   android:layout_height = "match_parent"
   tools:context = ".MainActivity">
   <TextView
      android:id = "@+id/text"
      android:textSize = "30sp"
      android:layout_width = "match_parent"
      android:layout_height = "match_parent" />
</LinearLayout>
In the above code, we have taken text view to show status bar sub tittle.
Step 3 − Add the following code to src/MainActivity.java
package com.example.myapplication;
import android.app.ActivityManager;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
   TextView textView;
   @RequiresApi(api = Build.VERSION_CODES.N)
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      textView = findViewById(R.id.text);
      getSupportActionBar().setSubtitle("sairam");
      textView.setText(" subtittle is sairam");
   }
}
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 android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen –
Click here to download the project code
Passing Hashes to Subroutines in Perl

When you supply a hash to a Perl subroutine or operator that accepts a list, then the hash is automatically translated into a list of key/value pairs. For example −
 Live Demo
#!/usr/bin/perl
# Function definition
sub PrintHash {
   my (%hash) = @_;
   foreach my $key ( keys %hash ) {
      my $value = $hash{$key};
      print "$key : $value\n";
   }
}
%hash = ('name' => 'Tom', 'age' => 19);
# Function call with hash parameter
PrintHash(%hash);
When the above program is executed, it produces the following result −
name : Tom
age : 19
Unpacking a Tuple in Python

Python offers immutable data types known as tuples. In this article, we will learn about packing an unpacking tuple type in Python 3.x. Or earlier.
Python offers a very powerful tuple assignment tool that maps right hand side arguments into left hand side arguments. THis act of mapping together is known as unpacking of a tuple of values into a norml variable. WHereas in packing, we put values into a regular tuple by means of regular assignment.
Now let’s take a look at its implementation −
 Live Demo
# Packing tuple varibles under one varible name
tup = ("Tutorialspoint", "Python", "Unpacking a tuple")
   # Packing tuple varibles into a group of arguments
   (website, language, topic) = tup
   # print college name
print(website,"\t",language," ",topic)
Tutorialspoint     Python   Unpacking a tuple
During the unpacking of tuple, the total number of variables on the left-hand side should be equivalent to the total number of values in given tuple tup.
Python gives the syntax to pass optional arguments (*arguments) for tuple unpacking of arbitrary length. All values will be assigned to every variable in the order of their specification and all remaining values will be assigned to *arguments . Let’s consider the following code.
 Live Demo
# Packing tuple variables under one variable name
tup = ("Tutorialspoint", "Python","3.x.",":Data
Structure","Unpacking a tuple")
   # Packing tuple variables into a group of arguments
   (website,*language, topic) = tup
   # print college name
print(website,"\t",*language," ",topic)
Tutorialspoint Python 3.x. :Data Structure Unpacking a tuple
In python tuples can be unpacked using a function in function tuple is passed and in function, values are unpacked into a normal variable. The following code explains how to deal with an arbitrary number of arguments.
“*_” is used to specify the arbitrary number of arguments in the tuple.
 Live Demo
# Packing tuple varibles under one varible name
tup = ("Tutorialspoint", "Python","3.x.","Data Structure:","Unpacking a tuple")
# UnPacking tuple variables into a group of arguments and skipping unwanted arguments
(website,*_,typ,topic) = tup
# print college name
print(website,"\t",typ," ",topic)
Tutorialspoint    Data Structure:    Unpacking a tuple
In case we want to skip only one argument then we can replace “*_” by “_”
In this article, we learnt how we can pack and unpack tuples in a variety of Ways.
How to multiply a matrix columns and rows with the same matrix rows and columns in R?

To multiply a rows or columns of a matrix, we need to use %*% symbol that perform the multiplication for matrices in R. If we have a matrix M with 5 rows and 5 columns then row 1 of M can be multiplied with column 1 of M using M[1,]%*%M[,1], similarly, we can multiply other rows and columns.
 Live Demo
M<−matrix(1:100,ncol=10)
M
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 1 11 21 31 41 51 61 71 81 91
[2,] 2 12 22 32 42 52 62 72 82 92
[3,] 3 13 23 33 43 53 63 73 83 93
[4,] 4 14 24 34 44 54 64 74 84 94
[5,] 5 15 25 35 45 55 65 75 85 95
[6,] 6 16 26 36 46 56 66 76 86 96
[7,] 7 17 27 37 47 57 67 77 87 97
[8,] 8 18 28 38 48 58 68 78 88 98
[9,] 9 19 29 39 49 59 69 79 89 99
[10,] 10 20 30 40 50 60 70 80 90 100
M[1,]%*%M[,1]
[,1]
[1,] 3355
M[1,]%*%M[,2]
[,1]
[1,] 7955
M[1,]%*%M[,3]
[,1]
[1,] 12555
M[1,]%*%M[,5]
[,1]
[1,] 21755
M[1,]%*%M[,7]
[,1]
[1,] 30955
M[1,]%*%M[,8]
[,1]
[1,] 35555
M[1,]%*%M[,10]
[,1]
[1,] 44755
M[2,]%*%M[,1]
[,1]
[1,] 3410
M[5,]%*%M[,3]
[,1]
[1,] 13575
M[9,]%*%M[,5]
[,1]
[1,] 25395
M[2,]%*%M[,10]
[,1]
[1,] 45710
M[3,]%*%M[,4]
[,1]
[1,] 17865
M[3,]%*%M[,6]
[,1]
[1,] 27465
M[3,]%*%M[,8]
[,1]
[1,] 37065
M[3,]%*%M[,10]
[,1]
[1,] 46665
M[4,]%*%M[,5]
[,1]
[1,] 23120
M[4,]%*%M[,8]
[,1]
[1,] 37820
M[4,]%*%M[,9]
[,1]
[1,] 42720
M[4,]%*%M[,10]
[,1]
[1,] 47620
M[5,]%*%M[,5]
[,1]
[1,] 23575
M[5,]%*%M[,8]
[,1]
[1,] 38575
M[5,]%*%M[,10]
[,1]
[1,] 48575
M[5,]%*%M[,1]
[,1]
[1,] 3575
M[6,]%*%M[,6]
[,1]
[1,] 29130
M[6,]%*%M[,10]
[,1]
[1,] 49530
M[6,]%*%M[,3]
[,1]
[1,] 13830
M[6,]%*%M[,1]
[,1]
[1,] 3630
M[7,]%*%M[,7]
[,1]
[1,] 34885
M[7,]%*%M[,10]
[,1]
[1,] 50485
M[7,]%*%M[,9]
[,1]
[1,] 45285
M[7,]%*%M[,2]
[,1]
[1,] 8885
M[8,]%*%M[,3]
[,1]
[1,] 14340
M[8,]%*%M[,4]
[,1]
[1,] 19640
M[8,]%*%M[,8]
[,1]
[1,] 40840
M[8,]%*%M[,10]
[,1]
[1,] 51440
M[,1]%*%M[9,]
[,1]
[1,] 3795
M[,1]%*%M[5,]
[,1]
[1,] 3575
M[,2]%*%M[5,]
[,1]
[1,] 8575
M[,4]%*%M[10,]
[,1]
[1,] 20350
M[,5]%*%M[9,]
[,1]
[1,] 25395
How to create an HTML Document?

An HTML document defines the structure of HTML web page. It contains two distinct parts, the head, and the body. The head contains information about the document. The body part contains the content of the document, which gets displayed.
Just keep in mind that you should use the head part inside <head>...</head> tags. The body tag is used inside the <body>...</body> tags. Also, an HTML document begins with the <!DOCTYPE html> declaration, which is known as the DTD (Document Type Definition). This is to inform the web browser the type and version of the HTML document.
You can try to run the following code to create an HTML document. The <p> tag defines the paragraph −
<!DOCTYPE html>
<html>
<head>
<title>HTML Document</title>
</head>

<body>
<p>The content gets added here.</p>
</body>
</html>
The content gets added here.
How do I call a JavaScript function on page load?

To call a function on page load, use −
window.onload
You can try to run the following code to implement a JavaScript function on page load
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <script>
         function alertFunction() {
            alert('ok');
         }
         window.onload = alertFunction;
      </script>
   </body>
</html>
How to concatenate two or more vectors in R ? - GeeksforGeeks

05 Apr, 2021
In this article, we will see how to concatenate two or more vectors in R Programming Language. 
To concatenate two or more vectors in r we can use the combination function in R. Let’s assume we have 3 vectors vec1, vec2, vec3 the concatenation of these vectors can be done as c(vec1, vec2, vec3). Also, we can concatenate different types of vectors at the same time using the same function.
Concatenate function:
This is a function that combines its arguments.
This method combines the arguments and results in a vector.
All the arguments are converted to a common type that is the return value type.
This function is also used to convert the array into vectors.
Syntax: c(argument, argument,..)
Parameter:
Arguments : The objects to be concatenated
Approach:
Create a number of example vectors to concatenate.
Concatenate the vectors by c function, c(vec1, vec2, vec3)
Example 1: Let’s first create an example vector and then concatenate those vectors.
In this example, we have first created a vector vec1 and vec2. Then by using the concatenate function we have concatenated both the vectors to get the result.
R
vec1 <- 1:9vec1  vec2 <-9:1vec2  c(vec1,vec2)
Output: 
Example 2: Lets us now concatenate 3 vectors.
In this example, we have created 3 vectors vec1,vec2,vec3 using sample function and then concatenate the vectors into a single vector using the concatenate function
R
vec1 <- sample(0:9 , 50 , replace = TRUE)vec2 <- sample(0:4 , 25 ,replace = TRUE)vec3 <- sample(1:3 , 15 , replace = TRUE)  c(vec1,vec2,vec3)
Output: 
.
Example 3: In this example, we have created a character vector and a number vector and then combine both the vectors using the concatenate function of R library.
R
number <- (1, 2, 3, 4, 5)character <- ("A" , "B" , "C" , "D" , "E")  c(number, character)
Output: 
Picked
R Vector-Programs
R-Vectors
R Language
R Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
How to filter R dataframe by multiple conditions?
Replace Specific Characters in String in R
Convert Matrix to Dataframe in R
Program to find sum of elements in a given array in C++

In this problem, we are given an array arr[] of n integer values. Our task is to create a Program to find sum of elements in a given array in C++.
Program Description − For the given array, we will add up all elements and return the sum.
Let’s take an example to understand the problem
arr[] = {3, 1, 7, 2, 9, 10}
32
Sum = 3 + 1 + 7 + 2 + 9 + 10 = 32
To find the sum of elements of the array, we will traverse the array and
extract each element of the array and add them to sumVal which will return
the sum.
We can do by two ways,
Using recursion
Using iteration
Program to show the implement Recursive approach
 Live Demo
#include <iostream>
using namespace std;
int calcArraySum(int arr[], int n){
   if(n == 1){
      return arr[n-1];
   }
   return arr[n-1] + calcArraySum(arr, n-1);
}
int main(){
   int arr[] = {1, 4, 5, 7, 6};
   int n = sizeof(arr)/ sizeof(arr[0]);
   cout<<"The sum of elements in a given array is"<<calcArraySum(arr, n);
   return 0;
}
The sum of elements in a given array is 23
Program to show the implement Iterative approach
 Live Demo
#include <iostream>
using namespace std;
int calcArraySum(int arr[], int n){
   int sumVal = 0;
   for(int i = 0; i < n; i++){
      sumVal += arr[i];
   }
   return sumVal;
}
int main(){
   int arr[] = {1, 4, 5, 7, 6};
   int n = sizeof(arr)/ sizeof(arr[0]);
   cout<<"The sum of elements in a given array is"<<calcArraySum(arr, n);
   return 0;
}
The sum of elements in a given array is 23
Java Examples - Search a file in a directory

How to search for a file in a directory ?
Following example shows how to search for a particular file in a directory by making a Filefiter. Following example displays all the files having file names starting with 'b'.
import java.io.*;

public class Main { 
   public static void main(String[] args) {
      File dir = new File("C:");
      FilenameFilter filter = new FilenameFilter() {
         public boolean accept (File dir, String name) { 
            return name.startsWith("b");
         } 
      }; 
      String[] children = dir.list(filter);
      if (children == null) {
         System.out.println("Either dir does not exist or is not a directory"); 
      } else { 
         for (int i = 0; i< children.length; i++) {
            String filename = children[i];
            System.out.println(filename);
         } 
      } 
   } 
}
The above code sample will produce the following result.
build
build.xml

 Print
 Add Notes
 Bookmark this page
How to convert a Python csv string to array?

Easiest way is to use the str.split method to split on every occurance of ',' and map every string to the strip method to remove any leading/trailing whitespace. For example,
>>> s = "1, John Doe, Boston, USA"
>>> print map(str.strip, s.split(','))
['1', 'John Doe', 'Boston', 'USA']
If you have a multi-line string with multiple lines of csv, you can split on \n and then split and strip each line. For example,
>>> s = "1, John Doe, Boston, USA\n2, Jane Doe, Chicago, USA"
>>> print [map(str.strip, s_inner.split(',')) for s_inner in s.splitlines()]
[['1', 'John Doe', 'Boston', 'USA'], ['2', 'Jane Doe', 'Chicago', 'USA']]
The csv module in Python also has a helper function, reader for achieving the same result. For example,
>>> s = "1, John Doe, Boston, USA\n2, Jane Doe, Chicago, USA".splitlines()
>>> import csv
>>> x = csv.reader(s)
>>> list(x)
[['1', ' John Doe', ' Boston', ' USA'], ['2', ' Jane Doe', ' Chicago', ' USA']]
C++ Program to Find GCD

The Greatest Common Divisor (GCD) of two numbers is the largest number that divides both of them.
For example: Let’s say we have two numbers are 45 and 27.
45 = 5 * 3 * 3
27 = 3 * 3 * 3
So, the GCD of 45 and 27 is 9.
A program to find the GCD of two numbers is given as follows.
 Live Demo
#include <iostream>
using namespace std;
int gcd(int a, int b) {
   if (b == 0)
   return a;
   return gcd(b, a % b);
}
int main() {
   int a = 105, b = 30;
   cout<<"GCD of "<< a <<" and "<< b <<" is "<< gcd(a, b);
   return 0;
}
GCD of 105 and 30 is 15
In the above program, gcd() is a recursive function. It has two parameters i.e. a and b. If b is greater than 0, then a is returned to the main() function. Otherwise the gcd() function recursively calls itself with the values b and a%b. This is demonstrated by the following code snippet −
int gcd(int a, int b) {
   if (b == 0)
   return a;
   return gcd(b, a % b);
}
Another program to find the GCD of two numbers is as follows −
 Live Demo
#include<iostream>
using namespace std;
int gcd(int a, int b) {
   if (a == 0 || b == 0)
   return 0;
   else if (a == b)
   return a;
   else if (a > b)
   return gcd(a-b, b);
   else return gcd(a, b-a);
}
int main() {
   int a = 105, b =30;
   cout<<"GCD of "<< a <<" and "<< b <<" is "<< gcd(a, b);
   return 0;
}
GCD of 105 and 30 is 15
In the above program, gcd() is a recursive function. It has two parameters i.e. a and b. If a or b is 0, the function returns 0. If a or b are equal, the function returns a. If a is greater than b, the function recursively calls itself with the values a-b and b. If b is greater than a, the function recursively calls itself with the values a and (b - a). This is demonstrated by the following code snippet.
int gcd(int a, int b) {
   if (a == 0 || b == 0)
   return 0;
   else if (a == b)
   return a;
   else if (a > b)
   return gcd(a - b, b);
   else return gcd(a, b - a);
}
Python program to right rotate n-numbers by 1 - GeeksforGeeks

31 Dec, 2020
Given a number n. The task is to print n-integers n-times (starting from 1) and right rotate the integers by after each iteration.Examples:  
Input : 6
Output :
1 2 3 4 5 6
2 3 4 5 6 1
3 4 5 6 1 2
4 5 6 1 2 3
5 6 1 2 3 4
6 1 2 3 4 5

Input : 3
Output :
1 2 3 
2 3 1 
3 1 2



Below is the implementation. 
Python3
def print_pattern(n):    for i in range(1, n+1, 1):        for j in range(1, n+1, 1):            # check that if index i is            # equal to j            if i == j:                 print(j, end=" ")                # if index i is less than j                if i <= j:                     for k in range(j+1, n+1, 1):                        print(k, end=" ")                 for p in range(1, j, 1):                    print(p, end=" ")         # print new line        print()  # Driver's codeprint_pattern(3)
Output: 
1 2 3 
2 3 1 
3 1 2 


 
krishna_6431
pattern-printing
Python Pattern-printing
Python
Python Programs
pattern-printing
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
Selecting rows in pandas DataFrame based on conditions
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Defaultdict in Python
Python | Split string into list of characters
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python program to check whether a number is Prime or not
Program to find first positive missing integer in range in Python

Suppose we have a list of sorted list of distinct integers of size n, we have to find the first positive number in range [1 to n+1] that is not present in the array.
So, if the input is like nums = [0,5,1], then the output will be 2, as 2 is the first missing number in range 1 to 5.
To solve this, we will follow these steps −
target := 1
target := 1
for each i in arr, doif i is same as target, thentarget := target + 1
for each i in arr, do
if i is same as target, thentarget := target + 1
if i is same as target, then
target := target + 1
target := target + 1
return target
return target
Let us see the following implementation to get better understanding −
 Live Demo
class Solution:
   def solve(self, arr):
      target = 1
      for i in arr:
         if i == target:
            target += 1
         return target
ob = Solution()
nums = [0,5,1]
print(ob.solve(nums))
[0,5,1]
2
Difference between Virtual function and Pure virtual function in C++ - GeeksforGeeks

16 Jun, 2021
Virtual Function in C++A virtual function is a member function which is declared within a base class and is re-defined(Overriden) by a derived class. When you refer to a derived class object using a pointer or a reference to the base class, you can call a virtual function for that object and execute the derived class’s version of the function.
Pure Virtual Functions in C++A pure virtual function (or abstract function) in C++ is a virtual function for which we don’t have an implementation, we only declare it. A pure virtual function is declared by assigning 0 in the declaration.
Similarities between virtual function and pure virtual function
These are the concepts of Run-time polymorphism.Prototype i.e. Declaration of both the functions remains the same throughout the program.These functions can’t be global or static.
These are the concepts of Run-time polymorphism.
Prototype i.e. Declaration of both the functions remains the same throughout the program.
These functions can’t be global or static.
Difference between virtual function and pure virtual function in C++
virtual<func_type><func_name>(){    // code}
virtual<func_type><func_name>()    = 0;
sudeea
mohak327
C++-Virtual Functions
cpp-virtual
Technical Scripter 2019
Virtual Functions
C++
Difference Between
Technical Scripter
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Sorting a vector in C++
Friend class and function in C++
Pair in C++ Standard Template Library (STL)
Difference between BFS and DFS
Class method vs Static method in Python
Differences between TCP and UDP
Difference between var, let and const keywords in JavaScript
Difference between Process and Thread
PL/SQL - Comparison Operators

Comparison operators are used for comparing one expression to another. The result is always either TRUE, FALSE or NULL.
This program tests the LIKE operator. Here, we will use a small procedure() to show the functionality of the LIKE operator −
DECLARE 
PROCEDURE compare (value  varchar2,  pattern varchar2 ) is 
BEGIN 
   IF value LIKE pattern THEN 
      dbms_output.put_line ('True'); 
   ELSE 
      dbms_output.put_line ('False'); 
   END IF; 
END;  
BEGIN 
   compare('Zara Ali', 'Z%A_i'); 
   compare('Nuha Ali', 'Z%A_i'); 
END; 
/
When the above code is executed at the SQL prompt, it produces the following result −
True 
False  

PL/SQL procedure successfully completed.

The following program shows the usage of the BETWEEN operator −
DECLARE 
   x number(2) := 10; 
BEGIN 
   IF (x between 5 and 20) THEN 
      dbms_output.put_line('True'); 
   ELSE 
      dbms_output.put_line('False'); 
   END IF; 
    
   IF (x BETWEEN 5 AND 10) THEN 
      dbms_output.put_line('True'); 
   ELSE 
      dbms_output.put_line('False'); 
   END IF; 
    
   IF (x BETWEEN 11 AND 20) THEN 
      dbms_output.put_line('True'); 
   ELSE 
      dbms_output.put_line('False'); 
   END IF; 
END; 
/
When the above code is executed at the SQL prompt, it produces the following result −
True 
True 
False 
 
PL/SQL procedure successfully completed.

The following program shows the usage of IN and IS NULL operators −
ECLARE 
   letter varchar2(1) := 'm'; 
BEGIN 
   IF (letter in ('a', 'b', 'c')) THEN 
      dbms_output.put_line('True'); 
   ELSE 
      dbms_output.put_line('False'); 
   END IF; 
  
   IF (letter in ('m', 'n', 'o')) THEN 
       dbms_output.put_line('True'); 
   ELSE 
      dbms_output.put_line('False'); 
   END IF; 
    
   IF (letter is null) THEN 
    dbms_output.put_line('True'); 
   ELSE 
      dbms_output.put_line('False'); 
   END IF; 
END; 
/ 
When the above code is executed at SQL prompt, it produces the following result:
False
True
False

PL/SQL procedure successfully completed.

 Print
 Add Notes
 Bookmark this page
p5.js | storeItem() Function - GeeksforGeeks

17 Jan, 2020
The storeItem() function is used to store a given value under a key name in the local storage of the browser. The local storage persists between browsing sessions and can store values even after reloading the page.
It can be used to save non-sensitive information, such as user preferences. Sensitive data like personal information should not be stored as this storage is easily accessible.
Syntax:
storeItem(key, value)
Parameters: This function accepts two parameters as mentioned above and described below:
key: This is a string which denotes the key under which the value would be stored.
value: This is any value that can be stored under the key. It can be a String, Number, Boolean, Object, p5.Color or a p5.Vector.
Below example illustrates the storeItem() function in p5.js:
Example:
function setup() {  createCanvas(400, 300);  fill("green");  text("Click anywhere to draw a circle", 10, 20);  text("The last circle would be redrawn when page is refreshed", 10, 40);    // get the coordinates   // from localStorage  oldX = getItem('xpos');  oldY = getItem('ypos');    // check if the values are  // actually present (not null)  if (oldX != null && oldY != null)    circle(oldX, oldY, 100);    }  function mouseClicked() {  clear();  fill("green");  text("Click anywhere to draw a circle", 10, 20);  text("The last circle would be redrawn when page is refreshed", 10, 40);    posX = mouseX;  posY = mouseY;  circle(posX, posY, 100);    // set the coordinates  // to localStorage  storeItem('xpos', posX);  storeItem('ypos', posY);}
Output:
Local storage of the browserOnline editor: https://editor.p5js.org/Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/Reference: https://p5js.org/reference/#/p5/storeItemMy Personal Notes
arrow_drop_upSave
Online editor: https://editor.p5js.org/Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
Reference: https://p5js.org/reference/#/p5/storeItem
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Convert a string to an integer in JavaScript
How to calculate the number of days between two dates in javascript?
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
File uploading in React.js
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to establish a connection with the database using the properties file in JDBC?

One of the variant of the getConnection() method of the DriverManager class accepts url of the database, (String format) a properties file and establishes connection with the database.
Connection con = DriverManager.getConnection(url, properties);
To establish a connection with a database using this method −
Set the Driver class name as a system property −
System.setProperty("Jdbc.drivers", "com.mysql.jdbc.Driver");
Create a properties object as −
Properties properties = new Properties();
Add the user name and password to the above created Properties object as −
properties.put("user", "root");
properties.put("password", "password");
Finally invoke the getConnection() method of the DriverManager class by passing the URL and, properties object as parameters.
//Getting the connection
String url = "jdbc:mysql://localhost/mydatabase";
Connection con = DriverManager.getConnection(url, properties);
Following JDBC program establishes connection with the MYSQL database using a properties file.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
public class EstablishingConnectionUsingProperties {
   public static void main(String args[]) throws SQLException {
      //Registering the Driver
      System.setProperty("Jdbc.drivers", "com.mysql.jdbc.Driver");
      Properties properties = new Properties();
      properties.put("user", "root");
      properties.put("password", "password");
      //Getting the connection
      String url = "jdbc:mysql://localhost/mydatabase";
      Connection con = DriverManager.getConnection(url, properties);
      System.out.println("Connection established: "+ con);
   }
}
Connection established: com.mysql.jdbc.JDBC4Connection@2db0f6b2
SLF4J - Hello world

In this chapter, we will see a simple basic logger program using SLF4J. Follow the steps described below to write a simple logger.
Since the slf4j.Logger is the entry point of the SLF4J API, first, you need to get/create its object
The getLogger() method of the LoggerFactory class accepts a string value representing a name and returns a Logger object with the specified name.
Logger logger = LoggerFactory.getLogger("SampleLogger");

The info() method of the slf4j.Logger interface accepts a string value representing the required message and logs it at the info level.
logger.info("Hi This is my first SLF4J program");

Following is the program that demonstrates how to write a sample logger in Java using SLF4J.
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SLF4JExample {
   public static void main(String[] args) {
      //Creating the Logger object
      Logger logger = LoggerFactory.getLogger("SampleLogger");

      //Logging the information
      logger.info("Hi This is my first SLF4J program");
   }
}
On running the following program initially, you will get the following output instead of the desired message.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further
details.

Since we have not set the classpath to any binding representing a logging framework, as mentioned earlier in this tutorial, SLF4J defaulted to a no-operation implementation. So, to see the message you need to add the desired binding in the project classpath. Since we are using eclipse, set build path for respective JAR file or, add its dependency in the pom.xml file.
For example, if we need to use JUL (Java.util.logging framework), we need to set build path for the jar file slf4j-jdk14-x.x.jar. And if we want to use log4J logging framework, we need to set build path or, add dependencies for the jar files slf4j-log4j12-x.x.jar and log4j.jar.
After adding the binding representing any of the logging frameworks except slf4j-nopx.x.jar to the project (classpath), you will get the following output.
Dec 06, 2018 5:29:44 PM SLF4JExample main
INFO: Hi Welcome to Tutorialspoint

 Print
 Add Notes
 Bookmark this page
HTML | <input type="file"> - GeeksforGeeks

29 May, 2019
The HTML <input type=”file”> is used to specify the file select field and add a button to choose a file for upload to the form.
Syntax:
<input type="file"> 
Example:
<!DOCTYPE html> <html>   <head>     <title>         HTML input type file    </title>           <style>         h1 {             color: green;         }         h3 {             font-family: Impact;         }         body {             text-align: center;         }     </style> </head>   <body>     <h1>         GeeksforGeeks     </h1>           <h3>         HTML <Input Type = "File">     </h3>       <input type="file" id="myFile">           <p id="submit_text"></p></body>   </html>                    
Output:
Supported Browsers: The browsers supported by <input type=”file”> are listed below:
Google Chrome 1.0
Internet Explorer
Firefox 1.0
Safari 1.0
Opera 1.0
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Types of CSS (Cascading Style Sheet)
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
Design a web page using HTML and CSS
Form validation using HTML and JavaScript
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
Laplacian Filter using Matlab

17 Mar, 2022
Laplacian filter is a second-order derivate filter used in edge detection, in digital image processing. In 1st order derivative filters, we detect the edge along with horizontal and vertical directions separately and then combine both. But using the Laplacian filter we detect the edges in the whole image at once.
The Laplacian Operator/Filter is = [0 1 0; 
                                    1 -4 1;
                                    0 1 0]
here the central value of filter is negative.
  Or
Filter is = [0 -1 0;
            -1 4 -1; 
             0 -1 0],
here the central value of filter is positive.
Note:The sum of all values of the filter is always 0.
Steps:
Read the image in Matlab, using imread() function.
If the image is colored then convert it into RGB format.
Define the Laplacian filter.
Convolve the image with the filter.
Display the binary edge-detected image.
Syntax:
  var_name = imread(” name of image . extension “); //Read the image in variable
ar_name = rgb2gray ( old_image_var); //Convert into grayscale
 “conv2( )” //Convolution is performed 
“imtool( )” is used for displaying image.
Example:
Matlab
% MATLAB code for% Edge detection using Laplacian Filter.k=imread("logo.png"); % Convert rgb image to grayscale.k1=rgb2gray(k); % Convert into double format.k1=double(k1); % Define the Laplacian filter.Laplacian=[0 1 0; 1 -4 1; 0 1 0]; % Convolve the image using Laplacian Filterk2=conv2(k1, Laplacian, 'same'); % Display the image.imtool(k1, []);imtool(abs(k2,[]);
  
Output: 
 
 
 
Figure: Input Image
 
 
Figure: Output image after Edge detection
 
Disadvantages:
 
We should note that first derivative operators exaggerate the effects of noise. Second derivatives will exaggerate noise twice as much.
No directional information about the edge is given.
 
 
sweetyty
MATLAB image-processing
MATLAB
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Remove the Last Character From a Table in SQL?

18 Oct, 2021
Here we will see, how to remove the last characters from a table in SQL. We can do this task using the SUBSTRING() function.
SUBSTRING(): This function is used to find a part of the given string from the given position. It takes three parameters:  
String: It is a required parameter. It is the string on which function is to be applied.
Start: It gives the starting position of the string. It is also the required parameter.
Length: It is an optional parameter. By default, it takes the length of the substring to be returned.
Query:
SELECT SUBSTRING('HELLO GEEKS', 1, 5);
Output:
To delete the last character from the field, pass the length parameter to be 1 less than the total length.
For the purpose of demonstration let’s create a demo_table in a database named ‘geeks’.
Step 1: Creating the Database
Use the below SQL statement to create a database called geeks.
Query:
CREATE DATABASE geeks;
Step 2: Using the Database
Use the below SQL statement to switch the database context to geeks.
Query:
USE geeks;
Step 3: Table definition
We have the following demo_table in our geek’s database.
Query:
 CREATE TABLE demo_table
(FIRSTNAME VARCHAR(20),
LASTNAME VARCHAR(20),
AGE INT);
Step 4: Insert data
Query:
INSERT INTO demo_table VALUES
('Romy', 'Kumari', 22 ),
('Pushkar', 'Jha', 23),  
('Meenakshi', 'Jha', 20),
('Shalini', 'Jha', 22),
('Nikhil', 'Kalra', 23),
('Akanksha', 'Gupta', 23);
Step 5: View the content
Query:
SELECT * FROM demo_table;
Output:
Step 6: Use of SUBSTRING() function
We will remove the last character of entries in the LASTNAME column.
Syntax:
SELECT SUBSTRING(column_name,1,LEN(column_name)-1) 
FROM table_name;
Query:
SELECT FIRSTNAME, SUBSTRING(LASTNAME,1,LEN(LASTNAME)-1)
 AS LASTNAME, AGE FROM demo_table;
Output:
We can see in the image that the last character from the LASTNAME column is removed now.
We will remove the last character of entries in the FIRSTNAME column.
Query:
SELECT SUBSTRING(FIRSTNAME,1,LEN(FIRSTNAME)-1)
 AS FIRSTNAME, LASTNAME, AGE FROM demo_table;
Output:
Picked
SQL-Query
TrueGeek-2021
SQL
TrueGeek
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Integrating TinyMCE with Django

05 Sep, 2020
TinyMCE is a online rich text editor which is fully flexible and provides customisation. mostly used to get dynamic data such as articles in GFG and much more, their is no static database for posts
Installation –
To integrate it with Django web app or website you need to first install its pip library
pip install django-tinymce

Integrate with Django Project –
add tinyMCE as individual app in setting.py
INSTALLED_APPS = [
     ...
    'tinymce',
     ... 
]

Also add default configuration for tinyMCE editor in settings.py
TINYMCE_DEFAULT_CONFIG = {
    'cleanup_on_startup': True,
    'custom_undo_redo_levels': 20,
    'selector': 'textarea',
    'theme': 'silver',
    'plugins': '''
            textcolor save link image media preview codesample contextmenu
            table code lists fullscreen  insertdatetime  nonbreaking
            contextmenu directionality searchreplace wordcount visualblocks
            visualchars code fullscreen autolink lists  charmap print  hr
            anchor pagebreak
            ''',
    'toolbar1': '''
            fullscreen preview bold italic underline | fontselect,
            fontsizeselect  | forecolor backcolor | alignleft alignright |
            aligncenter alignjustify | indent outdent | bullist numlist table |
            | link image media | codesample |
            ''',
    'toolbar2': '''
            visualblocks visualchars |
            charmap hr pagebreak nonbreaking anchor |  code |
            ''',
    'contextmenu': 'formats | link image',
    'menubar': True,
    'statusbar': True,
}



here in configuration dictionary you can customise editor by changing values like theme and many more.
setting TinyMCE is done now to bring it into actions we need forms.py file with some required values like needed size of input field it is used by displaying content on html page
from django import formsfrom tinymce import TinyMCEfrom .models import _your_model_    class TinyMCEWidget(TinyMCE):    def use_required_attribute(self, *args):        return False    class PostForm(forms.ModelForm):    content = forms.CharField(        widget=TinyMCEWidget(            attrs={'required': False, 'cols': 30, 'rows': 10}        )    )    class Meta:        model = _your_model_        fields = '__all__'
Last step is to add htmlfield to your model you can also use different field check out them on their official website
...from tinymce.models import HTMLField     class article(models.Model):    ...    content =  HTMLField()
And its all set just make migrations for see changes in admin page by running following commands
python manage.py makemigrations

python manage.py migrate
Now check it in admin area by running server 
python manage.py runserver

Output –
here how it will look like it may have different appearance 
Editor in admin area
Python Django
Python
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | os.path.size() method

22 May, 2019
OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality. os.path module is submodule of OS module in Python used for common path name manipulation.
os.path.getsize() method in Python is used to check the size of specified path. It returns the size of specified path in bytes. The method raise OSError if the file does not exist or is somehow inaccessible.
Syntax: os.path.getsize(path)
Parameter:path: A path-like object representing a file system path. A path-like object is either a string or bytes object representing a path.
Return Type: This method returns a integer value which represents the size of specified path in bytes.
Code #1: Use of os.path.getsize() method
# Python program to explain os.path.getsize() method     # importing os module import os  # Pathpath = '/home/User/Desktop/file.txt'  # Get the size (in bytes)# of specified path size = os.path.getsize(path)    # Print the size (in bytes)# of specified path print("Size (In bytes) of '%s':" %path, size)
Size (In bytes) of '/home/User/Desktop/file.txt': 243

Code #2: Handling error while using os.path.getsize() method
# Python program to explain os.path.getsize() method     # importing os module import os  # Pathpath = '/home/User/Desktop/file2.txt'  # Get the size (in bytes)# of specified path try :    size = os.path.getsize(path)  except OSError :    print("Path '%s' does not exists or is inaccessible" %path)    sys.exit()  # Print the size (in bytes)# of specified path print("Size (In bytes) of '% s':" % path, size)
Path '/home/User/Desktop/file2.txt' does not exists or is inaccessible

Reference: https://docs.python.org/3/library/os.path.html
python-os-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Double doubleValue() method in Java with examples

09 Oct, 2018
The doubleValue() method of Double class is a built in method to return the value specified by the calling object as double after type casting.
Syntax:
DoubleObject.doubleValue()
Return Value: It return the value of DoubleObject as double.
Below programs illustrate doubleValue() method in Java:
Program 1:
// Java code to demonstrate// Double doubleValue() method  class GFG {    public static void main(String[] args)    {          // Double value        Double a = 17.47;          // wrapping the Double value        // in the wrapper class Double        Double b = new Double(a);          // doubleValue of the Double Object        double output = b.doubleValue();          // prdoubleing the output        System.out.println("Double value of "                           + b + " is : " + output);    }}
Double value of 17.47 is : 17.47

Program 2:
// Java code to demonstrate// Double doubleValue() method  class GFG {    public static void main(String[] args)    {          String value = "54.1";          // wrapping the Double value        // in the wrapper class Double        Double b = new Double(value);          // doubleValue of the Double Object        double output = b.doubleValue();          // prdoubleing the output        System.out.println("Double value of "                           + b + " is : " + output);    }}
Double value of 54.1 is : 54.1

Java-Double
Java-Functions
Java-lang package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Integer intValue() Method in Java

03 May, 2022
intValue() of Integer class that is present inside java.lang package is an inbuilt method in java that returns the value of this integer as an int which is inherited from Number Class. The package view is as follows:
--> java.lang Package
    --> Integer Class
         --> intValue() Method    
Syntax: 
public int intValue()
Return Type: A numeric value that is represented by the object after conversion to the integer type.
Note: This method is applicable from java version 1.2 and onwards. 
Now we will be covering different numbers such as positive, negative, decimal, and even strings.
For a positive integer
For a negative number
For a decimal value and string
Case 1: For a positive integer
Example:
Java
// Java Program to Illustrate// the Usage of intValue() method// of Integer class // Importing required class/esimport java.lang.*; // Main classpublic class GFG {     // Main driver method    public static void main(String[] args)    {         // Creating object of Integer class inside main()        Integer intobject = new Integer(68);         // Returns the value of this Integer as an int        int i = intobject.intValue();         // Printing the value above stored in integer        System.out.println("The integer Value of i = " + i);    }}
The integer Value of i = 68
 
Case 2:  For a negative number
Example:
Java
// Java program to illustrate the// use of intValue() method of// Integer class of java.lang package // Importing required classesimport java.lang.*; // Main classpublic class GFG {     // Main driver method    public static void main(String[] args)    {         // Creating an object of Integer class        Integer intobject = new Integer(-76);         // Returns the value of this Integer as an int        int i = intobject.intValue();         // Printing the integer value above stored on        // console        System.out.println("The integer Value of i = " + i);    }}
The integer Value of i = -76
 
Case 3: For a decimal value and string. 
Example:
Java
// Java Program to illustrate// Usage of intValue() method// of Integer class of java.lang package // Importing required classesimport java.lang.*; // Main classclass GFG {     // Main driver method    public static void main(String[] args)    {        // Creating an object of Integer class        Integer intobject = new Integer(98.22);         // Using intValue() method        int i = intobject.intValue();         // Printing the value stored in above integer        // variable        System.out.println("The integer Value of i = " + i);         // Creating another object of Integer class        Integer ab = new Integer("52");         int a = ab.intValue();         // This time printing the value stored in "ab"        System.out.println("The integer Value of ab = "                           + a);    }}
Output: 
Note: It returns an error message when a decimal value is given. For a string this works fine. 
amlanbosefitcse15
adnanirshad158
solankimayank
Java-Functions
Java-Integer
Java-lang package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Mean Function in MATLAB

29 Jun, 2021
Mean or average is the average of a sequence of numbers. In MATLAB, mean (A) returns the mean of the components of A along the first array dimension whose size doesn’t equal to 1. Suppose that A is a vector, then mean(A) returns the mean of the components. Now, if A is a Matrix form, then mean(A) returns a row vector containing the mean of every column.
Mean =   
Example:
Mean of sequence x = [1,2,3,4,5]  = Sum of numbers/Count of numbers
                                                  = 15/5
                                                  = 3
Different syntax of the mean() method is:
M = mean(A)
M = mean(A,’all’)
M = mean(A,dim)
M = mean(A,vecdim)
It returns the mean of sequence A.
If A is a vector, then it returns the mean of all elements in the vector
If A is a matrix, then it returns a vector where each element is the mean of each column in A.
Example:
Matlab
% Input vectorA = [1 2 3 4 5];disp("Vector :");disp(A); % Find mean of vectorx = mean(A);disp("Mean :");disp(x);
 
 
Output:
 
 
Example:
 
Matlab
% Input matrixA = [1 1 2; 2 3 2; 0 1 2; 1 5 7];disp("Matrix :");disp(A); % Find mean of matrixx = mean(A);disp("Mean :");disp(x);
Output :
It returns the mean of all the elements in A either it can be vector or matrix.
Example:
Matlab
% Input matrixA = [1 1 2; 2 3 2; 0 1 2; 1 5 7];disp("Matrix :");disp(A); % Find mean of whole matrixx = mean(A,'all');disp("Mean :");disp(x);
Output :
It returns the mean of matrix A along each of the given dim.
If dim = 1, then it returns a vector where the mean of each column is included.
If dim = 2, then it returns a vector where the mean of each row is included.
Example:
Matlab
% Input matrixA = [1 1 2; 2 3 2; 0 1 2; 1 5 7];disp("Matrix :");disp(A); % Find mean of each row in matrixx = mean(A,2);disp("Mean :");disp(x);
Output :
It returns the mean of A based on the specified dimensions vecdim in A.
If A is a 2-by-2-by-3 array, then mean(A,[1 2]) calculates the mean of each page of size 2-by-2 as it’s considered as a single entity. So it returns the vector of size 3 as the mean of each page.
Example:
Matlab
% Creating a 2-by-3-by-3 arrayA(:,:,1) = [12 2; -1 1];A(:,:,2) = [3 13; -2 10];A(:,:,3) = [4 7 ; 3 -3];disp("Array :");disp(A); % Calculate mean of each pageM1 = mean(A,[1 2]);disp("Mean of each page :");disp(M1);
Output:
arorakashish0911
MATLAB-Maths
Picked
MATLAB
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.