code-rag-bench/online-tutorials huggingface dataset:
Get current time and date on Android

As per Oracle documentation, SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. In this example, we have imported simple date format class from java as shown below -
import java.text.SimpleDateFormat;
import java.util.Date;
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: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">
   <TextView
      android:id="@+id/date"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:textSize="30sp"
      android:layout_marginBottom="36dp" />
</RelativeLayout>
In the above code, we have given text view, it going to print the current date on the window manager.
Step 3 − Add the following code to src/MainActivity.java
package com.example.andy.myapplication;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import java.text.SimpleDateFormat;
import java.util.Date;
public class MainActivity extends AppCompatActivity {
   @TargetApi(Build.VERSION_CODES.O)
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      TextView textView=findViewById(R.id.date);
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd G 'at' HH:mm:ss z");
      String currentDateandTime = sdf.format(new Date());
      textView.setText(currentDateandTime);
   }
}
In the above code we are calling SimpleDateFormat and from the simpledateformat, we are accessing the current date in the string. There are so many date format are available. For more reference Click here.
Step 4 − No need to change manifest.xml.
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 an android studio, open one of your project's activity files and click Run from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
In the above example, it contains a current date and time.
Click here to download the project code
Excel – Descriptive Statistics

08 Feb, 2022
Descriptive statistics is all about describing the given data. To describe about the data, we use Measures of central tendency and measures of dispersion.
Measures of central tendency [Mean, Median, and Mode] – a single number about the center of the data points.
Measures of dispersion [Range, Variance and Standard Deviation] – how the data is distributed
In this article, we explain how to use “Data Analysis” in excel for descriptive statistics in detail.
Sample data:
For eg. We have given shirt size of 20 men in the below table.
Follow the below steps to implement descriptive statistics on sample data:
Step 1: Go to “Data” >> Click “Data Analysis” (Image 1) – to popup the “Data Analysis” Dialog box. If you cannot find “Data analysis” in excel ribbon.  The end of this article finds the steps [To provide “Data Analysis”].
Image 1
Step 2: In Data Analysis, Select “Descriptive Statistics” and Press “OK” – To popup “Descriptive statistics” Dialog box for further input
Step 3: Make sure the below options are selected in “Descriptive statistics” and Press “OK”.
Input Range: “$B$1:$B$21”

Grouped By: Columns

Labels in first row: Checked

Output Range: $D$5

Summary statistics: Checked
Output:
Descriptive statistics Output in Table  “D5:E19”
To provide the “Data Analysis” button in the “Analysis Group”  
Step 1: Go to File >> Click “Options”  – to popup “Excel options”.
Step 2: Select “Add-ins” and Press “Go”.
Step 3: Select “Analysis ToolPak” and press  “OK”.
avtarkumar719
Excel-Charts
Picked
Excel
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Delete Blank Columns in Excel?
How to Get Length of Array in Excel VBA?
How to Normalize Data in Excel?
How to Find the Last Used Row and Column in Excel VBA?
How to Use Solver in Excel?
Introduction to Excel Spreadsheet
How to make a 3 Axis Graph using Excel?
Macros in Excel
How to Show Percentages in Stacked Column Chart in Excel?
How to Extract the Last Word From a Cell in Excel?
Python program to find the String in a List

12 Apr, 2022
Given a list, the task is to write a Python program to check whether a list contains a particular string or not.
Examples:
Input: l=[1, 1.0, ‘have’, ‘a’, ‘geeky’, ‘day’]; s=’geeky’
Output: geeky is present in the list
Input: l=[‘hello’,’ geek’, ‘have’, ‘a’, ‘geeky’, ‘day’]; s=’nice’
Output: nice is not present in the list
Method #1: Using in operator
The in operator comes handy for checking if a particular string/element exists in the list or not.
Example:
Python3
# assign listl = [1, 2.0, 'have', 'a', 'geeky', 'day'] # assign strings = 'geeky'  # check if string is present in the listif s in l:    print(f'{s} is present in the list')else:    print(f'{s} is not present in the list')
Output:
geeky is present in the list
Method #2: Using count() function
The count() function is used to count the occurrence of a particular string in the list. If the count of a string is more than 0, it means that particular string exists in the list, else that string doesn’t exist in the list.
Example:
Python3
# assign listl = ['1', 1.0, 32, 'a', 'geeky', 'day'] # assign strings = 'prime' # check if string is present in listif l.count(s) > 0:    print(f'{s} is present in the list')else:    print(f'{s} is not present in the list')
Output:
prime is not present in the list
Method #3: Using List Comprehension
List comprehensions are used for creating new lists from other iterables like tuples, strings, arrays, lists, etc. It is used to transform iterative statements into formulas.
Example:
Python3
# assign listl = ['hello', 'geek', 'have', 'a', 'geeky', 'day'] # assign strings = 'geek' # list comprehensioncompare = [i for i in l if s in l] # check if string is present in listif len(compare) > 0:    print(f'{s} is present in the list')else:    print(f'{s} is not present in the list')
Output:
geeky is present in the list
Method #4: Using any() function
The any() function is used to check the existence of an element in the list. it’s like- if any element in the string matches the input element, print that the element is present in the list, else, print that the element is not present in the list.
Example:
Python3
# assign listl = ['hello', 'geek', 'have', 'a', 'geeky', 'day'] # assign strings = 'prime' # check if string is present in listif any(s in i for i in l):    print(f'{s} is present in the list')else:    print(f'{s} is not present in the list')
Output:
prime is not present in the list
sweetyty
singghakshay
Python list-programs
Python string-programs
Technical Scripter 2020
Python
Python Programs
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Python | Convert string dictionary to dictionary
How to upload file with selenium (Python)?

We can upload files with Selenium using Python. This can be done with the help of the send_keys method. First, we shall identify the element which does the task of selecting the file path that has to be uploaded.
This feature is only applied to elements having the type attribute set to file. Also, the tagname of the element should be input. Let us investigate the html code of an element having the above properties.
Code Implementation.
from selenium import webdriver
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
driver.implicitly_wait(0.5)
driver.maximize_window()

driver.get("https://www.tutorialspoint.com/selenium/selenium_automat
ion_practice.htm")
#to identify element
s = driver.find_element_by_xpath("//input[@type='file']")
#file path specified with send_keys
s.send_keys("C:\\Users\\Pictures\\Logo.jpg")
How to implement a constructor reference with one or more arguments in Java?

A method reference can also be applicable to constructors in Java 8. A constructor reference can be created using the class name and a new keyword. The constructor reference can be assigned to any functional interface reference that defines a method compatible with the constructor.
<Class-Name>::new
import java.util.function.*;

@FunctionalInterface
interface MyFunctionalInterface {
   Student getStudent(String name);
}
public class ConstructorReferenceTest1 {
   public static void main(String[] args) {
      MyFunctionalInterface mf = Student::new;

      Function<Sttring, Student> f1 = Student::new;    // Constructor Reference
      Function<String, Student> f2 = (name) -> new Student(name);

      System.out.println(mf.getStudent("Adithya").getName());
      System.out.println(f1.apply("Jai").getName());
      System.out.println(f2.apply("Jai").getName());
   }
}

// Student class
class Student {
   private String name;
   public Student(String name) {
      this.name = name;
   }
   public String getName() {
      return name;
   }
   public void setName(String name) {
      this.name = name;
   }
}
Adithya
Jai
Jai
import java.util.function.*;

@FunctionalInterface
interface MyFunctionalInterface {
   Student getStudent(int id, String name);
}
public class ConstructorReferenceTest2 {
   public static void main(String[] args) {
      MyFunctionalInterface mf = Student::new;    //  Constructor Reference

      BiFunction<Integer, String, Student> f1 = Student::new;
      BiFunction<Integer, String, Student> f2 = (id, name) -> new Student(id,name);

      System.out.println(mf.getStudent(101, "Adithya").getId());
      System.out.println(f1.apply(111, "Jai").getId());
      System.out.println(f2.apply(121, "Jai").getId());
   }
}

// Student class
class Student {
   private int id;
   private String name;
   public Student(int id, String name) {
      this.id = id;
      this.name = name;
   }
   public int getId() {
      return id;
   }
   public void setId(int id) {
      this.id = id;
   }
   public String getName() {
      return name;
   }
   public void setName(String name) {
      this.name = name;
   }
}
101
111
121
How to change the mode of a file using Python?

To change the permission of a file, you can use the os.chmod(file, mode) call. Note that the mode should be specified in octal representation and therefore must begin with a 0o. For example, to make a file readonly, you can set the permission to 0o777, you can use:
>>> import os
>>> os.chmod('my_file', 0o777)
You can also use flags from the stat module. You can read more about these flags here: http://docs.python.org/2/library/stat.html
Another way to acheive it is using a subprocess call:
>>> import subprocess
>>> subprocess.call(['chmod', '0444', 'my_file'])
PHP Cookies

A cookie is often used to identify a user. A cookie is a small file that the 
server embeds on the user's computer. Each time the same computer requests a 
page with a browser, it will send the cookie too. With PHP, you can both create 
and retrieve cookie values.
A cookie is created with the setcookie() function.
Only the name parameter is required. All other parameters are 
optional.
The following example creates a cookie named "user" with the value "John 
Doe". The cookie will expire after 30 days (86400 * 30). The "/" means that the 
cookie is available in entire website (otherwise, select the directory you 
prefer).
We then retrieve the value of the cookie "user" (using the global variable 
$_COOKIE). We also use the isset() function to find out if the cookie is set:


Note: The setcookie() function must appear BEFORE the <html> tag.
Note: The value of the cookie is automatically URLencoded when 
sending the cookie, and automatically decoded when received (to prevent 
URLencoding, use setrawcookie() instead).
To modify a cookie, just set (again) the cookie using the setcookie() function:
To delete a cookie, use the setcookie() function with an expiration date in 
the past:
The following example creates a small script that checks whether cookies are 
enabled. First, try to create a test cookie with the setcookie() function, then 
count the $_COOKIE array variable:
For a complete reference of Network functions, go to our complete
PHP Network Reference.
Create a cookie named "username".
("username", "John", time() + (86400 * 30), "/");

We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
How to call Python file from within PHP?

To call a Python file from within a PHP file, you need to call it using the shell_exec function.
<?php
    $command = escapeshellcmd('/usr/custom/test.py');
    $output = shell_exec($command);
    echo $output;
?>
This will call the script. But in your script at the top, you'll need to specify the interpreter as well. So in your py file, add the following line at the top:
#!/usr/bin/env python
Alternatively you can also provide the interpreter when executing the command.
<?php
    $command = escapeshellcmd('python3 /usr/custom/test.py');
    $output = shell_exec($command);
    echo $output;
?>
Python - String concatenation in Heterogeneous list - GeeksforGeeks

04 Oct, 2021
Sometimes, while working with Python, we can come across a problem in which we require to find the concatenation of strings. This problem is easier to solve. But this can get complex in case we have mixture of data types to go along with it. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using loop + conditions We can employ a brute force method to type caste check each element, if its a string we concatenate it. This can ensure that only strings are concatenated and hence can solve the problem.
Python3
# Python3 code to demonstrate working of# String concatenation in Heterogeneous list# using loop + conditions  # initializing listtest_list = [5, 6, "gfg ", 8, (5, 7), ' is', 9, ' best']  # printing original listprint("The original list is : " + str(test_list))  # String concatenation in Heterogeneous list# using loop + conditionsres = ''for ele in test_list:    if type(ele) == str:        res += ele           # printing result print("Concatenation of strings in list : " + str(res))
The original list is : [5, 6, 'gfg ', 8, (5, 7), ' is', 9, ' best']
Concatenation of strings in list : gfg  is best
 
Method #2 : Using join() + isinstance() This problem can also be solved using the inbuilt function of join() and it also supports the instance filter using isinstance() which can be feeded with strings and hence solve the problem.
Python3
# Python3 code to demonstrate working of# String concatenation in Heterogeneous list# using join() + isinstance()  # initializing listtest_list = [5, 6, "gfg ", 8, (5, 7), ' is', 9, ' best']  # printing original listprint("The original list is : " + str(test_list))  # String concatenation in Heterogeneous list# using join() + isinstance()res = "".join(filter(lambda i: isinstance(i, str), test_list))  # printing result print("Concatenation of strings in list : " + str(res))
The original list is : [5, 6, 'gfg ', 8, (5, 7), ' is', 9, ' best']
Concatenation of strings in list : gfg  is best
 
anikaseth98
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
Python program to check whether a number is Prime or not
Python program to split a string and join with comma

Suppose we have few words that are separated by spaces. We have to split these words to form a list, then join them into a string by placing comma in-between.
So, if the input is like s = "Programming Python Language Easy Funny", then the output will be Programming, Python, Language, Easy, Funny
To solve this, we will follow these steps −
words := a list of words by applying split function on s with delimiter " " blank space.
words := a list of words by applying split function on s with delimiter " " blank space.
ret := join each items present in words and place ", " in between each pair of words
ret := join each items present in words and place ", " in between each pair of words
return ret
return ret
Let us see the following implementation to get better understanding
def solve(s):
   words = s.split(' ')
   ret = ', '.join(words)
   return ret

s = "Programming Python Language Easy Funny"
print(solve(s))
"Programming Python Language Easy Funny"
Programming, Python, Language, Easy, Funny
Why is the size of an empty class not zero in C++?

Suppose we have one empty class in C++. Now let us check whether its size is 0 or not. Actually, the standard does not permit objects (or classes) of size 0, this is because that would make it possible for two distinct objects to have the same memory location. This is the reason behind the concept that even an empty class must have a size at least 1. It is known that size of an empty class is not zero. Generally, it is 1 byte. See the below example.
Let us see the following implementation to get better understanding −
 Live Demo
#include<iostream>
using namespace std;
class MyClass {
};
int main() {
   cout << sizeof(MyClass);
}
1
It clearly shows that an object of one empty class will take at least one byte to ensure that the two different objects will have different addresses. See the below example.
 Live Demo
#include<iostream>
using namespace std;
class MyClass {
};
int main() {
   MyClass a, b;
   if (&a == &b)
      cout <<"Same "<< endl;
   else
      cout <<"Not same "<< endl;
}
Not same
For dynamic allocation also, the new keyword returns different address for the same reason.
 Live Demo
#include<iostream>
using namespace std;
class MyClass {
};
int main() {
   MyClass *a = new MyClass();
   MyClass *b = new MyClass();
   if (a == b)
      cout <<"Same "<< endl;
   else
      cout <<"Not same "<< endl;
}
Not same
2D Shapes(Objects) Intersection Operation

This operation takes two or more shapes as inputs and returns the intersection area between them as shown below.
You can perform an intersection operation on the shapes using the method named intersect(). Since this is a static method, you should call it using the class name (Shape or its subclasses) as shown below.
Shape shape = Shape.intersect(circle1, circle2); 

Following is an example of the intersection operation. In here, we are drawing two circles and performing a intersection operation on them.
Save this code in a file with the name IntersectionExample.java
import javafx.application.Application; 
import javafx.scene.Group; 
import javafx.scene.Scene; 
import javafx.scene.paint.Color; 
import javafx.stage.Stage; 
import javafx.scene.shape.Circle; 
import javafx.scene.shape.Shape; 
         
public class IntersectionExample extends Application { 
   @Override 
   public void start(Stage stage) { 
      //Drawing Circle1 
      Circle circle1 = new Circle();
      
      //Setting the position of the circle 
      circle1.setCenterX(250.0f); 
      circle1.setCenterY(135.0f); 
      
      //Setting the radius of the circle 
      circle1.setRadius(100.0f); 
      
      //Setting the color of the circle 
      circle1.setFill(Color.DARKSLATEBLUE);     
       
      //Drawing Circle2 
      Circle circle2 = new Circle();         
      
      //Setting the position of the circle 
      circle2.setCenterX(350.0f); 
      circle2.setCenterY(135.0f); 
      
      //Setting the radius of the circle  
      circle2.setRadius(100.0f); 
      
      //Setting the color of the circle 
      circle2.setFill(Color.BLUE);  
       
      //Performing intersection operation on the circle 
      Shape shape = Shape.intersect(circle1, circle2); 
      
      //Setting the fill color to the result 
      shape.setFill(Color.DARKSLATEBLUE); 
       
      //Creating a Group object  
      Group root = new Group(shape); 
         
      //Creating a scene object 
      Scene scene = new Scene(root, 600, 300);  
      
      //Setting title to the Stage 
      stage.setTitle("Intersection Example"); 
         
      //Adding scene to the stage 
      stage.setScene(scene);
      
      //Displaying the contents of the stage 
      stage.show(); 
   }      
   public static void main(String args[]){ 
      launch(args); 
   } 
}       
Compile and execute the saved java file from the command prompt using the following commands.
javac IntersectionExample.java 
java IntersectionExample

On executing, the above program generates a JavaFX window displaying the following output −

    33 Lectures 
     7.5 hours 

 Syed Raza

    64 Lectures 
     12.5 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    20 Lectures 
     4 hours 

 Emenwa Global, Ejike IfeanyiChukwu
 Print
 Add Notes
 Bookmark this page
Check privileges (grants) for a specific user in MySQL?

If you want to check privileges for a specific user, then use the below syntax −
SHOW GRANTS FOR 'yourUserName'@'yourHostName';
The above syntax will check privileges for a specific user.
To check the privileges for a specific user, then use FOR. Let’s say we have a username ‘JOHN‘ and host is ‘%’. Following is the query to get the privileges for user “JOHN” −
mysql> SHOW GRANTS FOR 'JOHN'@'%';
This will produce the following output −
+---------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
--------------+
| Grants for JOHN@%
|
+---------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
--------------+
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN,
PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE
TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION
CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE
USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO
`JOHN`@`%` WITH GRANT OPTION |
| GRANT
BACKUP_ADMIN,BINLOG_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,GR
OUP_REPLICATION_ADMIN,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_SLAVE_A
DMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SET_USE
R_ID,SYSTEM_VARIABLES_ADMIN,XA_RECOVER_ADMIN ON *.* TO `JOHN`@`%` WITH
GRANT OPTION |
+---------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
--------------+
2 rows in set (0.00 sec)
MCQ on Memory allocation and compilation process in C

Here we will see some MCQ questions on Memory Allocation and Compilation Processes.
Question 1 − What will be the output of the following code −
 Live Demo
#include <stdio.h>
#include <stdlib.h>
int main() {
   union my_union {
      int i;
      float f;
      char c;
   };
   union my_union* u;
   u = (union my_union*)malloc(sizeof(union my_union));
   u->f = 20.60f;
   printf("%f", u->f);
}
Options −
Garbage Value
20.600000
Syntax Error
20.6
Explanation
Using unions, we can use same memory location to hold multiple type of data. All member of union uses same memory location which has maximum space. Here float is used, which has 20.60f = 20.600000. So answer B is correct.
Question 2 − What is the correct sequence of the compilation Process −
Options −
Assembler, Compiler, Preprocessor, Linking
Compiler, Assembler, Preprocessor, Linking
Preprocessor, Compiler, Assembler, Linking
Assembler, Compiler, Linking, Preprocessor
Explanation −
The option C is correct, At first it preprocess the code, then compile it, after that it creates assembly level code, or object code, then the linking is
taken place.
Question 3 − Which of the following statement is true?
Options −
During Linking the Code #include replaces by stdio.h
During Preprocessing the Code #include replaces by stdio.h
During Execution the Code #include replaces by stdio.h
During Editing the Code #include replaces by stdio.h
Explanation −
The option B is correct. At first, it creates the preprocessed code, in that phase, it attaches the codes present in file mentioned in #include statements into the code then sent to the compiler.
Question 4 − Purpose of using fflush() function −
Options −
To flush all streams and specified streams
To flush only specified streams
To flush input-output buffer
This is invalid library function
Explanation −
This function is used to flush output stream only. It clears the output buffer and send the output to the console. The option A is correct.
Question 5 − Point out the error of the following code −
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
   char* ptr;
   *ptr = (int*)malloc(30);
   strcpy(ptr, "ABC");
   printf("%s", ptr);
   free(ptr);
}
Options −
Error in strcpy() statement
Error in *ptr = (int*)malloc(30);
Error in free(ptr)
No Error
Explanation −
The option B is correct. Here this makes integer from pointer, without a cast
What are the main file components in Cucumber?

The main file components in Cucumber are listed below −
Feature file − This file has an extension of .feature. It comprises single or multiple test scenarios in plain text. All the scenarios are written with the
keywords like Then, Given, When, And, But, Feature, Background and so on.
Feature file − This file has an extension of .feature. It comprises single or multiple test scenarios in plain text. All the scenarios are written with the
keywords like Then, Given, When, And, But, Feature, Background and so on.
Feature file.
Feature: Login Test
Scenario: Tutorialspoint login validation
Given: Launch the “https://www.tutorialspoint.com/index.htm”
Step Definition File - This file has an extension of .java. It provides mapping
of the test scenarios to the test script logic.
Step Definition File - This file has an extension of .java. It provides mapping
of the test scenarios to the test script logic.
Step Definition file based on the above feature file.
@Given (“^Launch the \"([^\"]*)\"$”)
public void launch_application(String url){
   System.out.println("The url is : " + url);
}
Test Runner file - This file has an extension of .java. It acts as a link between
the step definition file and feature file. It gives the option of selecting a single
or multiple feature files. It has the path of the step definition file and the feature file.
Test Runner file - This file has an extension of .java. It acts as a link between
the step definition file and feature file. It gives the option of selecting a single
or multiple feature files. It has the path of the step definition file and the feature file.
Test Runner file
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import cucumber.api.testng.AbstractTestNGCucumberTests;
@CucumberOptions(
   features = "src/test/java/features",
   glue="stepDefinations")
public class TestRunner extends AbstractTestNGCucumberTests { }
How can we update the values of a collection using LINQ in C#?

If the collection is a List, then we can make use of ForEach extension method which is available as part of LINQ.
 Live Demo
using System;
using System.Collections.Generic;
namespace DemoApplication {
   class Program {
      static void Main(string[] args) {
         List<Fruit> fruits = new List<Fruit> {
            new Fruit {
               Name = "Apple",
               Size = "Small"
            },
            new Fruit {
               Name = "Orange",
               Size = "Small"
            }
         };
         foreach(var fruit in fruits) {
            Console.WriteLine($"Fruit Details Before Update. {fruit.Name}, {fruit.Size}");
         }
         fruits.ForEach(fruit => { fruit.Size = "Large"; });
         foreach (var fruit in fruits) {
            Console.WriteLine($"Fruit Details After Update. {fruit.Name}, {fruit.Size}");
         }
         Console.ReadLine();
      }
   }
   public class Fruit {
      public string Name { get; set; }
      public string Size { get; set; }
   }
}
The output of the above code is
Fruit Details Before Update. Apple, Small
Fruit Details Before Update. Orange, Small
Fruit Details After Update. Apple, Large
Fruit Details After Update. Orange, Large
If we want to update the list items based on a condition, we can make use of Where() clause.
 Live Demo
using System;
using System.Collections.Generic;
using System.Linq;
namespace DemoApplication {
   class Program {
      static void Main(string[] args) {
         IEnumerable<Fruit> fruits = new List<Fruit> {
            new Fruit {
               Name = "Apple",
               Size = "Small"
            },
            new Fruit {
               Name = "Orange",
               Size = "Small"
            },
            new Fruit {
               Name = "Mango",
               Size = "Medium"
            }
         };
         foreach(var fruit in fruits) {
            Console.WriteLine($"Fruit Details Before Update. {fruit.Name}, {fruit.Size}");
         }
         foreach (var fruit in fruits.Where(w => w.Size == "Small")) {
            fruit.Size = "Large";
         }
         foreach (var fruit in fruits) {
            Console.WriteLine($"Fruit Details After Update. {fruit.Name}, {fruit.Size}");
         }
         Console.ReadLine();
      }
   }
   public class Fruit {
      public string Name { get; set; }
      public string Size { get; set; }
   }
}
The output of the above code is
Fruit Details Before Update. Apple, Small
Fruit Details Before Update. Orange, Small
Fruit Details Before Update. Mango, Medium
Fruit Details After Update. Apple, Large
Fruit Details After Update. Orange, Large
Fruit Details After Update. Mango, Medium
In the above we are filtering only the fruits having small size and updating the values. So, the where clause filters the record based on a condition.
.NET Core - Create a Testing Project

In this chapter, we will discuss how to create a Testing project using .NET Core. Unit testing is a development process for the software that has the smallest testable parts of an application, which are called units. They are individually and independently scrutinized for any proper operation. Unit testing is can either be automated or done manually as well.
Let us now open the New Project dialog box and select Visual C# → .NET Core template.
On this dialog box, you can see that there is no project template for unit testing. To create a unit test project, we should use the command line utility. Let us go to the Solution folder that we created; create a test folder and inside the test folder create another folder and call it StringLibraryTests.
Let us now use the dotnet commandline utility to create a new test project by executing the following command −
dotnet new -t xunittest

You can now see that a new C# project is created; let us look into the folder by executing the v command and you will see project.json and Tests.cs files as shown below.
Here is the code in project.json file.
{ 
   "version": "1.0.0-*", 
   "buildOptions": { 
      "debugType": "portable" 
   }, 
   "dependencies": { 
      "System.Runtime.Serialization.Primitives": "4.1.1", 
      "xunit": "2.1.0", 
      "dotnet-test-xunit": "1.0.0-rc2-192208-24" 
   }, 
   "testRunner": "xunit", 
   "frameworks": { 
      "netcoreapp1.0": { 
         "dependencies": { 
            "Microsoft.NETCore.App": { 
               "type": "platform", 
               "version": "1.0.1" 
            } 
         }, 
         "imports": [ 
            "dotnet5.4", 
            "portable-net451+win8" 
         ] 
      } 
   } 
} 
Following is the code in the Test.cs file.
using System; 
using Xunit; 
namespace Tests { 
   public class Tests { 
      [Fact] 
      public void Test1() { 
         Assert.True(true); 
      } 
   } 
} 
To fetch the necessary dependencies from NuGet, let us execute the following command −
dotnet restore

We can run the test when the necessary dependencies are restored.
You can see that the compilation succeeded; as you go down you can see some information about the test executed.
Currently we have 1 test executed, 0 error, 0 failed, 0 skipped and the time taken by the execution process also mentioned as information.
 Print
 Add Notes
 Bookmark this page
Convert.ToBase64String() Method in C#

The Convert.ToBase64String() method in C# is used to convert the value of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with base-64 digits.
Following is the syntax −
public static string ToBase64String (byte[] arr);
Above, arr is an array of 8-bit unsigned integers.
Let us now see an example to implement the Convert.ToBase64String() method −
Using System;
public class Demo {
   public static void Main(){
      byte[] val1 = {5,10,15,20,25,30};
      string str = Convert.ToBase64String(val1);
      Console.WriteLine("Base 64 string: '{0}'", str);
      byte[] val2 = Convert.FromBase64String(str);
      Console.WriteLine("Converted byte value: {0}", BitConverter.ToString(val2));
   }
}
This will produce the following output −
Base 64 string: 'BQoPFBke'
Converted byte value: 05-0A-0F-14-19-1E
Accessing a parent Element using JavaScript

Following is the code for accessing a parent element using JavaScript −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result {
      font-size: 18px;
      font-weight: 500;
      color: #8a2be2;
   }
   .parent1,
   .parent2,
   .parent3 {
      display: inline-block;
      margin: 10px;
   }
   .child1,
   .child2,
   .child3 {
      width: 70px;
      height: 70px;
   }
   .child1 {
      background-color: red;
   }
   .child2 {
      background-color: pink;
   }
   .child3 {
      background-color: blue;
   }
</style>
</head>
<body>
<h1>Accessing a parent Element using JavaScript</h1>
<div class="parent1">
<div class="child1">Child 1</div>
</div>
<div class="parent2">
<div class="child2">Child 2</div>
</div>
<div class="parent3">
<div class="child3">Child 3</div>
</div>
<br />
<div class="result"></div>
<h3>Click on the any of the above div to know its parent element</h3>
<script>
   let resEle = document.querySelector(".result");
   document.querySelector(".child3").addEventListener("click", (event) => {
      resEle.innerHTML =
      "The parent node is " + event.target.parentNode.className;
   });
   document.querySelector(".child1").addEventListener("click", (event) => {
      resEle.innerHTML =
      "The parent node is " + event.target.parentNode.className;
   });
   document.querySelector(".child2").addEventListener("click", (event) => {
      resEle.innerHTML =
      "The parent node is " + event.target.parentNode.className;
   });
</script>
</body>
</html>
On clicking any of the divs, the following output will be produced −
How to flip an image horizontally or vertically in Python?

25 May, 2021
Prerequisites: PIL
Given an image the task here is to generate a Python script to flip an image horizontally and vertically. Here the module used for the task is PIL and transpose() function of this module. 
Syntax:
transpose(degree)
Keywords FLIP_TOP_BOTTOM and FLIP_LEFT_RIGHT will be passed to transpose method to flip it.
FLIP_TOP_BOTTOM – returns an original image flipped Vertically
FLIP_LEFT_RIGHT- returns an original image flipped Horizontally
Import module
Open original image
Transform the image as required
Save the new transformed image.
Image in use:
Example: Flipping image vertically
Python3
# importing PIL Modulefrom PIL import Image # open the original imageoriginal_img = Image.open("original.png") # Flip the original image verticallyvertical_img = original_img.transpose(method=Image.FLIP_TOP_BOTTOM)vertical_img.save("vertical.png") # close all our files objectoriginal_img.close()vertical_img.close()
Output:
Example : Flip image horizontally
Python3
# importing PIL Modulefrom PIL import Image # open the original imageoriginal_img = Image.open("original.png")  # Flip the original image horizontallyhorz_img = original_img.transpose(method=Image.FLIP_LEFT_RIGHT)horz_img.save("horizontal.png") # close all our files objectoriginal_img.close()horz_img.close()
Output:
simmytarika5
Picked
Python-pil
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python – Convert Image to String and vice-versa

23 Dec, 2020
To store or transfer an Image to some we need to convert it into a string such that the string should portray the image which we give as input. So In Python to do this Operation, it is a straight forward task not complicated because we have a lot of functions in Python available.
Here First We Import “Base64“ Method To Encode The Given Image 
Next, We Opened Our Image File In rb Mode Which Is Read In Binary Mode.
The We Read Our Image With image2.read() Which Reads The Image And Encode it Using b64encode() It Is Method That Is Used To Encode Data Into Base64 
Finally, we Print Our Encoded String 
Image used:
Python3
import base64    with open("food.jpeg", "rb") as image2string:    converted_string = base64.b64encode(image2string.read())print(converted_string)  with open('encode.bin', "wb") as file:    file.write(converted_string)
Output:
This Is The Output Of  Image That is Converted To String Using Base64
Here We got the output but if you notice in Starting Of String we get this b’ This We Can Say As Base64 Encoded String in Pair of single quotation. So if we want to remove that we can do the Following By Replacing The Print Statement With print(my_string.decode(‘utf-8’))
Here To Convert It From String It Is Actually A Reverse Process Which Is Also Straight Forward Method
First We Import Base64. Then We Open Our binary File Where We Dumped Our String. Then Open The File rb Mode Which Is Read In Binary Mode.
Store The Data That was Read From File Into A Variable. Then Close The File 
Then Just Give Any Image File Name (ex:”myimage.png”) And Open It In wb Mode Write In  Binary 
Decode The Binary With b64.decode() Then Close The File With .close()
Note: We will use the above-created string for converting it back to the image
Python3
import base64    file = open('encode.bin', 'rb')byte = file.read()file.close()  decodeit = open('hello_level.jpeg', 'wb')decodeit.write(base64.b64decode((byte)))decodeit.close()
Output:
Picked
python-string
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Scala Int max() method with example

30 Jan, 2020
The max() method is utilized to return the maximum value of the two specified int numbers.
Method Definition: (First_Number).max(Second_Number)
Return Type: It returns true the maximum value of the two specified int numbers.
Example #1:
// Scala program of Int max()// method   // Creating objectobject GfG{        // Main method    def main(args:Array[String])    {               // Applying max method        val result = (5).max(9)                   // Displays output        println(result)           }} 
9

Example #2:
// Scala program of Int max()// method   // Creating objectobject GfG{        // Main method    def main(args:Array[String])    {               // Applying max method        val result = (5).max(5)                   // Displays output        println(result)           }} 
5

Scala
Scala-Method
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to find the height of a text in HTML canvas using JavaScript ?

25 Dec, 2020
In this article, we will find the height of the text canvas using JavaScript.
Approach: In the following example, the height attribute of the HTML canvas is used. First set the font in pt to set the height.
context.font = '26pt Calibri';
Then the current text is aligned in the center by using values ‘middle’ and color ‘yellow’.
context.textAlign = 'middle';
context.fillStyle = 'yellow';
Then, check the width of the text using the measureText() method before writing to the canvas. Finally, the text is written on the canvas using the fillText() method.
Example 1:
HTML
<!DOCTYPE HTML><html>  <head>    <style>        body {            margin: 0px;            padding: 0px;        }    </style></head>  <body>    <canvas id="myCanvas" width="550" height="200">    </canvas>    <script>        var canvas = document.getElementById('myCanvas');        var context = canvas.getContext('2d');        var x = canvas.width / 3;        var y = canvas.height / 2 - 15;        var text = 'HI ';          // Set the font to set the height        context.font = '26pt Calibri';        context.textAlign = 'middle';        context.fillStyle = 'yellow';        context.fillText(text, x, y);        context.font = '20pt Calibri';          // Check the width of the text         var metrics = context.measureText(text);        var width = metrics.width;          // Text is aligned in the left              context.textAlign = 'left';        context.fillStyle = '#010';                  context.fillText('(' + width             + 'px wide)', x, y + 40);    </script></body>  </html>
Approach: First get the 2d drawing context of the canvas by using getContext() method. Set the font and the text string. Then write the text with x and y co-ordinates using fillText() method as given below.
Example 2:
HTML
<!DOCTYPE html><html>  <body>    <canvas id="Canvas" width="300" height="150"         style="border:1px solid #010;">        Your browser isn't supporting         HTML5 canvas tag.    </canvas>      <script>        var c = document.getElementById("Canvas");        var x = c.getContext("2d");        x.font = "30px Arial";        var txt = "Computer Science"        x.fillText("width:"             + x.measureText(txt).width, 10, 50);        x.fillText(txt, 10, 100);    </script></body>  </html>
HTML-Canvas
JavaScript-Misc
Picked
Technical Scripter 2020
HTML
JavaScript
Technical Scripter
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Birthday Reminder Application in Python

In this section we will see how to create a birthday reminder application using Python.
Create an application using Python, which can check whether there is any birthday on the current day or not. If it is the birthday of some listed person, send a notification to the System with the name of that person.
We need a file, where we can store the date and month and the name of the person as a lookup file for this application. The file will look like this −
Here we will convert this application to a start-up application to start when the system starts.
Steps to create Birthday Reminder Application
Take the lookup file and read from it.
Whether the date and month is matched with the current date and month

Send notification to the system with all of the names whose birthday is today.


Send notification to the system with all of the names whose birthday is today.
Stop
importos, time
#Take the birthday lookup file from home directory
file_path = os.getenv('HOME') + '/birth_day_lookup.txt'
defcheck_birthday():
   lookup_file = open(file_path, 'r') #open the lookup file as read mode
   today = time.strftime('%d-%B') #get the todays date as dd-Month format
   bday_flag = 0
   #loop through each entry in the birthday file, and check whether the day is present or not
   for entry inlookup_file:
      if today in entry:
         line = entry.split(' ') #cut the line on spaces to get name and surname
         bday_flag = 1
         os.system('notify-send "Today is '+line[1]+' '+line[2]+'\'s Birthday"')
   ifbday_flag == 0:
      os.system('notify-send "No birthday for today is listed"')
check_birthday()
Step 1 − Convert the script file as executable file by using the chmod command
sudochmod +x file_name.py

Step 2 − Move the script file to /usr/bin directory.
sudocp file_name.py /usr/bin

Step 3 − Now search for the Startup Applications, and start it.
After opening the application go to add, and give desired name, then the program name in the command field. And add as startup application.
Difference Between Friend Function and Virtual Function in C++ - GeeksforGeeks

12 Mar, 2021
A friend class can access private and protected members of other classes in which it is declared as friend. It is sometimes useful to allow a particular class to access private members of other classes. Just likely, a friend function is a function that is declared outside the scope of a class. This function can be invoked like a normal function and include object/s as arguments. It is mostly used for overloading <<and>> for I/O. It can generally access any member of the class to which it is friend.  
Illustration: 
class GFG  
{ 
 private: 
 {  
 Public: 
 {  
 friend void check();  
 }
  
void check();  
Now coming onto the second function is a virtual function. So a virtual function is basically a member function of a class that is declared within the base class. In this, a virtual keyword is used to make member function of base class Virtual. It also supports polymorphism at both compile-time and run time. It also allows derived class to simply replace implementation that is provided or given by the base class.  
Illustration:  
class GFG  
{  
Public:  
          Virtual return_type function_name(arguments)  
         {  
         .....  
         }  
}:  
   class A  
  {  
By far we are clear with discussing friend function and virtual function, now let us see the major differences between them even to grasp a good grip over it.
Friend Function 
Virtual Function 
C++
Difference Between
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 == and .equals() Method in Java