code-rag-bench/online-tutorials huggingface dataset:
Align single rows of items in the center with Bootstrap 4

Use the .align-items-center class in Bootstrap to align single rows of items in the center.
To align in the center −
<div class="d-flex flex-wrap align-items-center bg-info" style="height:200px">
Now add the flex items −
<div class="d-flex flex-wrap align-items-center bg-info" style="height:200px">
  <div class="p-2 border">Item 1</div>
  <div class="p-2 border">Item 2</div>
  <div class="p-2 border">Item 3</div>
  <div class="p-2 border">Item 4</div>
</div>
You can try to run the following code to implement the align-items-center class in Bootstrap 4 −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  </head>
<body>
  <div class="container mt-3">
    <h1>Align Flex Items on a single row at the center</h1>
    <div class="d-flex flex-wrap align-items-center bg-info" style="height:200px">
      <div class="p-2 border">Item 1</div>
      <div class="p-2 border">Item 2</div>
      <div class="p-2 border">Item 3</div>
      <div class="p-2 border">Item 4</div>
   </div>
  </div>
</body>
</html>
C++ function call by reference

The call by reference method of passing arguments to a function copies the reference of an argument into the formal parameter. Inside the function, the reference is used to access the actual argument used in the call. This means that changes made to the parameter affect the passed argument.
To pass the value by reference, argument reference is passed to the functions just like any other value. So accordingly you need to declare the function parameters as reference types as in the following function swap(), which exchanges the values of the two integer variables pointed to by its arguments.
// function definition to swap the values.
void swap(int &x, int &y) {
   int temp;
   temp = x; /* save the value at address x */
   x = y;    /* put y into x */
   y = temp; /* put x into y */
  
   return;
}
For now, let us call the function swap() by passing values by reference as in the following example −
#include <iostream>
using namespace std;

// function declaration
void swap(int &x, int &y);

int main () {
   // local variable declaration:
   int a = 100;
   int b = 200;
 
   cout << "Before swap, value of a :" << a << endl;
   cout << "Before swap, value of b :" << b << endl;

   /* calling a function to swap the values using variable reference.*/
   swap(a, b);

   cout << "After swap, value of a :" << a << endl;
   cout << "After swap, value of b :" << b << endl;
 
   return 0;
}
When the above code is put together in a file, compiled and executed, it produces the following result −
Before swap, value of a :100
Before swap, value of b :200
After swap, value of a :200
After swap, value of b :100


    154 Lectures 
     11.5 hours 

 Arnab Chakraborty

    14 Lectures 
     57 mins

 Kaushik Roy Chowdhury

    30 Lectures 
     12.5 hours 

 Frahaan Hussain

    54 Lectures 
     3.5 hours 

 Frahaan Hussain

    77 Lectures 
     5.5 hours 

 Frahaan Hussain

    12 Lectures 
     3.5 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page
How to create a data frame in R with repeated rows by a sequence of number of times or by a fixed number of times?

There are times when duplicated rows in a data frame are required, mainly they are used to extend the data size instead of collecting the raw data. This saves our time but surely it will have some biasedness, which is not recommended. Even though it is not recommended but sometimes it becomes necessary, for example, if it is impossible to collect raw data then we can do it. If we do so then we must specify it in our analysis report. In R, we can use rep function with seq_len and nrows to create a data frame with repeated rows.
Consider the below data frame df −
> x<-1:10
> y<-letters[1:10]
> df<-data.frame(x,y)
Creating a new data frame in which the rows are printed one more after original rows −
> df[rep(seq_len(nrow(df)), times = 2), ]
      x y
1     1 a
2     2 b
3     3 c
4     4 d
5     5 e
6     6 f
7     7 g
8     8 h
9     9 i
10   10 j
1.1   1 a
2.1   2 b
3.1   3 c
4.1   4 d
5.1   5 e
6.1   6 f
7.1   7 g
8.1   8 h
9. 1  9 i
10.1 10 j
Creating a new data frame in which the duplicate rows are printed one by one −
> df[rep(seq_len(nrow(df)), each = 2), ]
      x y
1     1 a
1.1   1 a
2     2 b
2.1   2 b
3     3 c
3.1   3 c
4     4 d
4.1   4 d
5     5 e
5.1   5 e
6     6 f
6.1   6 f
7     7 g
7.1   7 g
8     8 h
8.1   8 h
9     9 i
9.1   9 i
10   10 j
10.1 10 j
Repeating each row by sequence of numbers −
> df[rep(seq_len(nrow(df)), times = 1:10), ]
      x y
1     1 a
2     2 b
2.1   2 b
3 3     c
3.1   3 c
3.2   3 c
4 4     d
4.1   4 d
4.2   4 d
4.3   4 d
5 5     e
5.1   5 e
5.2   5 e
5.3   5 e
5.4   5 e
6     6 f
6.1   6 f
6.2   6 f
6.3   6 f
6.4   6 f
6.5   6 f
7     7 g
7.1   7 g
7.2   7 g
7.3   7 g
7.4   7 g
7.5   7 g
7.6   7 g
8     8 h
8.1   8 h
8.2   8 h
8.3   8 h
8.4   8 h
8.5   8 h
8.6   8 h
8.7   8 h
9     9 i
9.1   9 i
9.2   9 i
9.3   9 i
9.4   9 i
9.5   9 i
9.6   9 i
9.7   9 i
9.8   9 i
10   10 j
10.1 10 j
10.2 10 j
10.3 10 j
10.4 10 j
10.5 10 j
10.6 10 j
10.7 10 j
10.8 10 j
10.9 10 j
How to add styling or css to your app using reactnative?

Styling your app can be done as follows −
Using Stylesheet component
Using Inline styles
React native Stylesheet component comes very handy and neat when you want to apply styling to your app. To work with Stylesheet component first import it as shown below −
import { StyleSheet } from 'react-native';
You can create the style using Stylesheet component as follows −
const styles = StyleSheet.create({
   container: {
      flex: 1,
      marginTop: StatusBar.currentHeight || 0,
   },
   item: {
      margin: 10,
      padding: 20,
      marginVertical: 8,
      marginHorizontal: 16,
   }
});
The above style can be used as follows inside your code −
<View style={styles.container}></View>
Here is an example that makes use of Stylesheet for display of FlatList component −
import React from "react";
import { FlatList , Text, View, StyleSheet, StatusBar } from "react-native";
export default class App extends React.Component {
   constructor() {
      super();
      this.state = {
         data: [
            { name: "Javascript Frameworks", isTitle: true },
            { name: "Angular", isTitle: false },
            { name: "ReactJS", isTitle: false },
            { name: "VueJS", isTitle: false },
            { name: "ReactNative", isTitle: false },
            { name: "PHP Frameworks", isTitle: true },
            { name: "Laravel", isTitle: false },
            { name: "CodeIgniter", isTitle: false },
            { name: "CakePHP", isTitle: false },
            { name: "Symfony", isTitle: false }
         ],
         stickyHeaderIndices: []
      };
   }
   renderItem = ({ item }) => {
      return (
         <View style={styles.item}>
            <Text style={{ fontWeight: (item.isTitle) ? "bold" : "", color: (item.isTitle) ? "red" : "gray"}} >
               {item.name}
            </Text>
         </View>
      );
   };
   render() {
      return (
         <View style={styles.container}>
            <FlatList
               data={this.state.data}
               renderItem={this.renderItem}
               keyExtractor={item => item.name}
               stickyHeaderIndices={this.state.stickyHeaderIndices}
            />
         </View>
      );
   }
}
const styles = StyleSheet.create({
   container: {
      flex: 1,
      marginTop: StatusBar.currentHeight || 0,
   },
   item: {
      margin: 10,
      padding: 20,
      marginVertical: 8,
      marginHorizontal: 16,
   }
});
You can use the style property to add the styles inline. However, this is not the best practice because it can be hard to read the code. Here is a working example on how to use inline style inside reactnative component
export default App;
import React from 'react';
import { Button, View, Alert } from 'react-native';

const App = () => {
   return (
      <View style={{flex :1, justifyContent: 'center', margin: 15 }}>
         <Button
            title="Click Me"
            color="#9C27B0"
            onPress={() => Alert.alert('Testing Button for React Native ')}
         />
      </View>
   );
}
Write a C program demonstrating strlen library function

It returns the number of characters in a string.
int strlen (string name)
In this program, with the help of gets function reading the name at run time and trying to print the length of that name using strlen() function, this function returns an integer value and try to print that no using printf.
 Live Demo
#include<stdio.h>
#include<string.h>
void main(){
   //Declaring string and length//
   char name[25];
   int length;
   //Reading Input from user//
   printf("Enter your name : ");
   gets(name);
   length=strlen(name);
   //Printing name//
   printf("Your name is : ");
   puts(name);
   printf("Length of the string is : %d\n",length);
}
Enter your name : Tutorialspoint
Your name is : Tutorialspoint
Length of the string is : 14
We shall consider another example to print string length without using string function i.e., without using strlen().
 Live Demo
#include <stdio.h>
int main(){
   char string[50],i;
   printf("enter the string: \n");
   scanf("%s",string);
   for(i=0; string[i]!='\0'; ++i);
      printf("\length of the given string is: %d",i);
   return 0;
}
enter the string:
TutorialsPoint
length of the given string is: 14
How to search and replace text in a file using Python?

There is the re.sub() method in Python module re which helps to search a pattern and replace with a new sub string. If the pattern is not found, string is returned unchanged.
Syntax of re.sub()
re.sub(pattern, repl, string):
For example in the code below, we search for ‘India’ and replace it with ‘the World’ in the string 'TP is most popular Tutorials site of India'
result=re.sub(r'India','the World','TP is the most popular Tutorials site of India')
print result
TP is the most popular Tutorials site of the World
Difference between Big-O and Little-O Notation

e∈O(g) says, essentially −
For at least one choice of a constant l>0, ∋ a constant a such that the inequality e(x)<l⋅g(x) holds ∀x>a.
e∈o(g) says, essentially −
For every choice of a constant l>0, ∋ a constant a such that the inequality e(x)<k⋅g(x) holds ∀x>a.
e∈O(g) means that e’s asymptotic growth is no faster than g’s, whereas e∈o(g) means that e’s asymptotic growth is strictly slower than g’s. It’s like ≤ versus <.
E.g.
x2∈O(x2)
x2∉o(x2)
x2∈o(x3)
How to include an external JavaScript inside an HTML page?

The HTML <script> tag is used for declaring a script within your HTML document. Through this, you can define client-side JavaScript. But, what if you want to add external JavaScript inside an HTML Page? Well, you can easily do that too using the src attribute of the <script> tag.
The following are the attributes of the <script> tag −
For adding external JavaScript file, we will be using the src attribute −
Let’s see the HTML file first, which will include the source for the external file source.
You can try to run the following code to include external JS in HTML. The HTML file is here, with a src to the JS file myscript.js.
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <h2>Alert Button</h2>
      <p>
      <External JavaScript file is myscript.js/p>
      <button type="button" onclick="sayHello()">Click</button>
      <script src="myscript.js"></script>
   </body>
</html>
To use JavaScript from an external file source, you need to write all your JavaScript source code in a simple text file with the extension ".js" and then include that file as in the above structure i.e. <script src="myscript.js"></script>Keep the following content in myscript.js file −
function sayHello() {
   alert("Hello World")
}
Multiple inheritance by Interface in Java

An interface contains variables and methods like a class but the methods in an interface are abstract by default unlike a class. Multiple inheritance by interface occurs if a class implements multiple interfaces or also if an interface itself extends multiple interfaces.
A program that demonstrates multiple inheritance by interface in Java is given as follows:
 Live Demo
interface AnimalEat {
   void eat();
}
interface AnimalTravel {
   void travel();
}
class Animal implements AnimalEat, AnimalTravel {
   public void eat() {
      System.out.println("Animal is eating");
   }
   public void travel() {
      System.out.println("Animal is travelling");
   }
}
public class Demo {
   public static void main(String args[]) {
      Animal a = new Animal();
      a.eat();
      a.travel();
   }
}
Animal is eating
Animal is travelling
Now let us understand the above program.
The interface AnimalEat and AnimalTravel have one abstract method each i.e. eat() and travel(). The class Animal implements the interfaces AnimalEat and AnimalTravel. A code snippet which demonstrates this is as follows:
interface AnimalEat {
   void eat();
}
interface AnimalTravel {
   void travel();
}
class Animal implements AnimalEat, AnimalTravel {
   public void eat() {
      System.out.println("Animal is eating");
   }
   public void travel() {
      System.out.println("Animal is travelling");
   }
}
In the method main() in class Demo, an object a of class Animal is created. Then the methods eat() and travel() are called. A code snippet which demonstrates this is as follows:
public class Demo {
   public static void main(String args[]) {
      Animal a = new Animal();
      a.eat();
      a.travel();
   }
}
How to convert Drawable to a Bitmap in Android?

This example demonstrates how do I convert Drawable to a Bitmap 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:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical"
   android:padding="4dp"
   android:gravity="center"
   tools:context=".MainActivity">
   <ImageView
   android:id="@+id/imageView"
   android:layout_width="match_parent"
   android:layout_height="wrap_content" />
   <Button
   android:id="@+id/btnConvert"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:text="Convert Drawable to Bitmap"/>
</LinearLayout>
Step 3 − Add the following code to src/MainActivity.java
import androidx.appcompat.app.AppCompatActivity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
   ImageView imageView;
   Button btnConvert;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      imageView = findViewById(R.id.imageView);
      btnConvert = findViewById(R.id.btnConvert);
      btnConvert.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.image);
            imageView.setImageBitmap(bitmap);
            Toast.makeText(getApplicationContext(), "Image converted to Bitmap",
            Toast.LENGTH_SHORT).show();
         }
      });
   }
}
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="app.com.sample">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity" android:windowSoftInputMode="adjustPan">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from the android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen
How to inherit multiple interfaces in Java?

An interface in Java is similar to class but, it contains only abstract methods and fields which are final and static.
Just like classes you can extend one interface from another using the extends keyword. You can also extend multiple interfaces from an interface using the extends keyword, by separating the interfaces using comma (,) as −
interface MyInterface extends ArithmeticCalculations, MathCalculations{
Following is the Java program demonstrating, how to extend multiple interfaces from a single interface.
interface ArithmeticCalculations{
   public abstract int addition(int a, int b);
   public abstract int subtraction(int a, int b);
}
interface MathCalculations {
   public abstract double squareRoot(int a);
   public abstract double powerOf(int a, int b);  
}
interface MyInterface extends MathCalculations, ArithmeticCalculations {
   public void displayResults();
}
public class ExtendingInterfaceExample implements MyInterface {
   public int addition(int a, int b) {
      return a+b;
   }
   public int subtraction(int a, int b) {
      return a-b;
   }
   public double squareRoot(int a) {
      return Math.sqrt(a);
   }
   public double powerOf(int a, int b) {
      return Math.pow(a, b);
   }
   public void displayResults(){
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter the value of a: ");
      int a = sc.nextInt();
      System.out.println("Enter the value of b: ");
      int b = sc.nextInt();      
      ExtendingInterfaceExample obj = new ExtendingInterfaceExample();
      System.out.println("Result of addition: "+obj.addition(a, b));
      System.out.println("Result of subtraction: "+obj.subtraction(a, b));
      System.out.println("Square root of "+a+" is: "+obj.squareRoot(a));
      System.out.println(a+"^"+b+" value is: "+obj.powerOf(a, b));
   }
   public static void main(String args[]){
      new ExtendingInterfaceExample().displayResults();
   }
}
Enter the value of a:
4
Enter the value of b:
3
Result of addition: 7
Result of subtraction: 1
Square root of 4 is: 2.0
4^3 value is: 64.0
Powershell - Regular Expression - Match Characters

Following is the example of supported regular expression characters in Windows PowerShell
#Format value
#Matches exact characters anywhere in the original value.
"book" -match "oo"

#Format   .
#Logic    Matches any single character.
"copy" -match "c..y"

#Format   [value]
#Logic    Matches at least one of the characters in the brackets.
"big" -match "b[iou]g"

#Format   [range]
#Logic    Matches at least one of the characters within the range. The use
#         of a hyphen (-) allows you to specify an adjacent character.
"and" -match "[a-e]nd"

#Format   [^]
#Logic    Matches any characters except those in brackets.
"and" -match "[^brt]nd"

#Format   ^
#Logic    Matches the beginning characters.
"book" -match "^bo"

#Format   $
#Logic    Matches the end characters.
"book" -match "ok$"

#Format   *
#Logic    Matches any instances of the preceding character.
"baggy" -match "g*"

#Format   ?
#Logic    Matches zero or one instance of the preceding character.
"baggy" -match "g?"
Output of all the above commands is True.

    15 Lectures 
     3.5 hours 

 Fabrice Chrzanowski

    35 Lectures 
     2.5 hours 

 Vijay Saini

    145 Lectures 
     12.5 hours 

 Fettah Ben
 Print
 Add Notes
 Bookmark this page
JavaScript – Getting Coordinates of mouse

To get the coordinates of mouse using JavaScript, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .sample {
      font-size: 25px;
      font-weight: 500;
   }
</style>
</head>
<body>
<h1>Coordinates of mouse</h1>
<p class="sample"></p>
<h3>Hover the mouse over the screen to get its x and y axis position</h3>
<script>
   let sampleEle = document.querySelector(".sample");
   document.body.addEventListener("mousemove", (event) => {
      sampleEle.innerHTML = "X axis: " + event.x + " Y axis: " + event.y;
   });
</script>
</body>
</html>
The above code will produce the following output:
Fortran - Location Functions

The following table describes the location functions:
Example
The following example demonstrates the concept:
program arrayLocation
implicit none

   real, dimension(1:6) :: a = (/ 21.0, 12.0,33.0, 24.0, 15.0, 16.0 /)
   Print *, maxloc(a)
   Print *, minloc(a)
   
end program arrayLocation   
When the above code is compiled and executed, it produces the following result:
3
2

 Print
 Add Notes
 Bookmark this page
Properties get(key) method in Java with Examples - GeeksforGeeks

30 Sep, 2019
The get(key) method of Properties class is used to get the value mapped to this key, passed as the parameter, in this Properties object. This method will fetch the corresponding value to this key, if present, and return it. If there is no such mapping, then it returns null.
Syntax:
public Object get(Object key)
Parameters: This method accepts a parameter key whose mapping is to be checked in this Properties object.
Returns: This method returns the value fetched corresponding to this key, if present. If there is no such mapping, then it returns null.
Below programs illustrate the get(key) method:
Program 1:
// Java program to demonstrate// get(key) method.  import java.util.*;  public class GFG {      // Main method    public static void main(String[] args)    {          // Create a properties and add some values        Properties properties = new Properties();        properties.put("Pen", 10);        properties.put("Book", 500);        properties.put("Clothes", 400);        properties.put("Mobile", 5000);          // Print Properties details        System.out.println("Properties: "                           + properties.toString());          // Getting the value of Pen        System.out.println("Value of Pen: "                           + properties.get("Pen"));          // Getting the value of Phone        System.out.println("Value of Phone: "                           + properties.get("Phone"));    }}
Properties: {Book=500, Mobile=5000, Pen=10, Clothes=400}
Value of Pen: 10
Value of Phone: null

Program 2:
// Java program to demonstrate// get(key) method.  import java.util.*;  public class GFG {      // Main method    public static void main(String[] args)    {          // Create a properties and add some values        Properties properties = new Properties();          properties.put(1, "100RS");        properties.put(2, "500RS");        properties.put(3, "1000RS");          // Print Properties details        System.out.println("Current Properties: "                           + properties.toString());          // Getting the value of 1        System.out.println("Value of 1: "                           + properties.get(1));          // Getting the value of 5        System.out.println("Value of 5: "                           + properties.get(5));    }}
Current Properties: {3=1000RS, 2=500RS, 1=100RS}
Value of 1: 100RS
Value of 5: null

References: https://docs.oracle.com/javase/9/docs/api/java/util/Properties.html#get-java.lang.Object-
Akanksha_Rai
Java - util package
Java-Functions
Java-Properties
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Object Oriented Programming (OOPs) Concept in Java
Interfaces in Java
How to iterate any Map in Java
ArrayList in Java
Initialize an ArrayList in Java
Stack Class in Java
Singleton Class in Java
Multithreading in Java
Multidimensional Arrays in Java
Regular Expression "\W" Metacharacter in Java

The subexpression/metacharacter “\W” matches the non-word characters.
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegexExample {
   public static void main(String args[]) {
      String regex = "\\W!";
      String input = "Hello how are you welcome to Tutorialspoint !";
      Pattern p = Pattern.compile(regex);
      Matcher m = p.matcher(input);
      int count = 0;
      while(m.find()) {
         count++;
      }
      System.out.println("Number of matches: "+count);
   }
}
Number of matches: 1
Following example reads 5 string values and prints those that contain non-word characters −
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
   public static void main( String args[] ) {
      String regex = "\\W.*$";
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter 5 input strings: ");
      String input[] = new String[5];
      for (int i=0; i<5; i++) {
         input[i] = sc.nextLine();
      }
      //Creating a Pattern object
      Pattern p = Pattern.compile(regex);
      System.out.println("Strings that contain non-word characters: ");
      for(int i=0; i<5;i++) {
         //Creating a Matcher object
         Matcher m = p.matcher(input[i]);
         if(m.matches()) {
            System.out.println(m.group());
         }
      }
   }
}
Enter 5 input strings:
$hello
sample
test1
test2
#$&*
Strings that contain non-word characters:
$hello
#$&*
Difference between PGP and S/MIME - GeeksforGeeks

22 Jun, 2020
1. Pretty Good Privacy (PGP) :PGP is an open source software package that is designed for the purpose of email security. Phil Zimmerman developed it. It provides the basic or fundamental needs of cryptography. In this multiple steps such are taken to secure the email, these are,
1. Confidentiality
2. Authentication
3. Compression
4. Resemble
5. Segmentation
6. E-mail compatibility 
2. Secure/Multipurpose Internet Mail Extension (S/MIME) :S/MIME is a security-enhanced version of Multipurpose Internet Mail Extension (MIME). In this, public key cryptography is used for digital sign, encrypt or decrypt the email. User acquires a public-private key pair with a trusted authority and then makes appropriate use of those keys with email applications.
Difference between PGP and S/MIME :
Computer Networks
Difference Between
Computer Networks
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
TCP Server-Client implementation in C
Differences between TCP and UDP
Types of Network Topology
Socket Programming in Python
Types of Transmission Media
Difference between BFS and DFS
Class method vs Static method in Python
Difference between var, let and const keywords in JavaScript
Differences between TCP and UDP
Difference between Process and Thread
Tryit Editor v3.6 - Show Node.js Command Prompt

var path = require('path');
var filename = path.basename('/Users/Refsnes/demo_path.js');
MySQL query to get current datetime and only current date

The query SELECT NOW() gives the current date as well as current time. If you want only current date, use only CURDATE(). Following is the syntax for datetime −
SELECT NOW();
The syntax for only date.
SELECT CURDATE();
Let us now implement the above syntax −
Case 1 : If you want both current date and time −
mysql> SELECT NOW();
+-----------------------+
| NOW()                 |
+-----------------------+
| 2019-06-02 15 :30 :39 |
+-----------------------+
1 row in set (0.00 sec)
Case 2 : If you want the current date only −
mysql> SELECT CURDATE();
+------------+
| CURDATE()  |
+------------+
| 2019-06-02 |
+------------+
1 row in set (0.00 sec)
How to create Switch in ReactJS? - GeeksforGeeks

22 Jan, 2021
Switches toggle the state of a single setting on or off. The switch is useful when we want users to toggle between any value, like iPhone Silent Button, etc. Material UI for React has this component available for us and it is very easy to integrate. We can use the Switch Component in ReactJS using the following approach.
Creating React Application And Installing Module:
Step 1: Create a React application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:
cd foldername
Step 3: After creating the ReactJS application, Install the material-ui modules using the following command:
npm install @material-ui/core
Project Structure: It will look like the following.
Project Structure
App.js: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
Javascript
import React from 'react';import FormControlLabel from '@material-ui/core/FormControlLabel';import Switch from '@material-ui/core/Switch';  const App = () => {    // Our States  const [state, setState] = React.useState({status: true});    // Change State Function  const handleChange = (event) => {    setState({ ...state, [event.target.name]: event.target.checked });  };    return (    <div style={{      margin: 'auto',      display: 'block',      width: 'fit-content'    }}>      <h3>How to use Switch Component in ReactJS?</h3>      <FormControlLabel        control={          <Switch            checked={state.status}            onChange={handleChange}            color="primary"            name="status"          />        }        label="Switch Silent Mode"      />    </div>  );}  export default App;
Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output:
JavaScript
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to filter object array based on attributes?
How to fetch data from an API in ReactJS ?
How to redirect to another page in ReactJS ?
How to pass data from child component to its parent in ReactJS ?
How to pass data from one component to other component in ReactJS ?
ReactJS Functional Components
Matplotlib.pyplot.twiny() in Python - GeeksforGeeks

11 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface.
Sample Code
# sample codeimport matplotlib.pyplot as plt     plt.plot([1, 2, 3, 4], [16, 4, 1, 8]) plt.show() 
Output:
The twinx() function in pyplot module of matplotlib library is used to make and return a second axes that shares the y-axis.
Syntax:
matplotlib.pyplot.twiny(ax=None)
Parameters: This method does not accepts any parameters.
Returns: This returns the second axes that shares the x-axis
Below examples illustrate the matplotlib.pyplot.twiny() function in matplotlib.pyplot:
Example #1:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport numpy as np        def GFG1(temp):    return (5. / 9.) * (temp - 32)    def GFG2(ax1):    y1, y2 = ax1.get_ylim()    ax_twin .set_ylim(GFG1(y1), GFG1(y2))    ax_twin .figure.canvas.draw()    fig, ax1 = plt.subplots()ax_twin = ax1.twiny()    ax1.callbacks.connect("ylim_changed", GFG2)ax1.plot(np.linspace(10, 120, 100))ax1.set_xlim(0, 40)    ax1.set_xlabel('Fahrenheit')ax_twin .set_xlabel('Celsius')  fig.suptitle('matplotlib.pyplot.twiny() function\ Example\n\n', fontweight ="bold")plt.show()
Output:
Example #2:
# Implementation of matplotlib functionimport numpy as npimport matplotlib.pyplot as plt   # Create some mock datat = np.arange(0.01, 20.0, 0.001)data1 = np.exp(t)data2 = np.sin(0.3 * np.pi * t)   fig, ax1 = plt.subplots()   color = 'tab:blue'ax1.set_ylabel('time (s)')ax1.set_xlabel('exp', color = color)ax1.plot(data1, t, color = color)ax1.tick_params(axis ='x', labelcolor = color)   ax2 = ax1.twiny()   color = 'tab:green'ax2.set_xlabel('sin', color = color)ax2.plot(data2, t, color = color)ax2.tick_params(axis ='x', labelcolor = color)  fig.suptitle('matplotlib.pyplot.twiny() function\ Example\n\n', fontweight ="bold")plt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Reading and Writing to text files in Python
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
Check if element exists in list in Python
Highlight the nan values in Pandas Dataframe - GeeksforGeeks

26 Jul, 2020
In this article, we will discuss how to highlight the NaN (Not a number) values in Pandas Dataframe. NaN values used to represent NULL values and sometimes it is the result of the mathematical overflow.Lets first make a dataframe: 
Python3
# Import Required Librariesimport pandas as pdimport numpy as np  # Create a dictionary for the dataframedict = {'Name': ['Sumit Tyagi', 'Sukritin', 'Akriti Goel',                 'Sanskriti', 'Abhishek Jain'],        'Age': [22, 20, np.nan, np.nan, 22],        'Marks': [90, 84, 33, 87, 82]}  # Converting Dictionary to Pandas Dataframedf = pd.DataFrame(dict)  # Print Dataframedf
Output:  
Now, come to the highlighting part. Our objective is to highlight those cells which have Nan values. 
Method 1: Highlighting Cell with nan values
We can do this by using the highlight_null() method of DataFrame.style property.This is a property that returns a Styler object, which has useful methods for formatting and displaying DataFrames. highlight_null() method requires one string parameter (the name of the colour with which you want to highlight the cell). 
Example: 
Python3
# Highlighting cell with nan valuesdf.style.highlight_null('red')
Output:  
 
Method 2: Highlighting text with nan values instead of background
We can do this by using applymap() method of the style property. applymap() method requires a function that takes a scalar and returns a scalar.Example:
Python3
# Highlighting text instead of the # cell's backgrounddf.style.applymap(lambda cell: 'color:red' if pd.isnull(cell) else '')
Output:  
 
Method 3: Highlighting the text of the complete row with nan values
We can do this using the apply() method Example:
Python3
# Highlighting text of the complete rowdf.style.apply(lambda row: np.repeat('color: red' if row.isnull().any() else '',                                     row.shape[0]), axis=1)
Output:  
 
Method 4: Highlighting the complete row with nan values
Python3
# Highlighting the complete rowdf.style.apply(lambda row: np.repeat('background: red' if row.isnull().any() else '', row.shape[0]), axis=1)
Output:  
 
 
Python3
# Highlighting column with nan valuesdf.style.apply(lambda row: np.repeat('background: red' if row.isnull().any() else '',                                                                row.shape[0]), axis=0)
Output:  
 
pandas-dataframe-program
Python pandas-dataFrame
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Java Examples - Add Text to PDF

How to add text to a PDF using Java.
Following is an example program to add text to a PDF document using Java.
import java.io.File; 
import java.io.IOException;  

import org.apache.pdfbox.pdmodel.PDDocument; 
import org.apache.pdfbox.pdmodel.PDPage; 
import org.apache.pdfbox.pdmodel.PDPageContentStream; 
import org.apache.pdfbox.pdmodel.font.PDType1Font;  

public class AddingTextToAPdf {  
   public static void main(String args[]) throws IOException {     
      
      //Loading an existing document 
      PDDocument doc = PDDocument.load(new File("C:/pdfBox/AddText_IP.pdf")); 

      //Creating a PDF Document 
      PDPage page = doc.getPage(0);       
      PDPageContentStream contentStream = new PDPageContentStream(doc, page); 
      
      //Begin the Content stream 
      contentStream.beginText(); 

      //Setting the font to the Content stream  
      contentStream.setFont( PDType1Font.TIMES_ROMAN, 16 ); 

      //Setting the position for the line 
      contentStream.newLineAtOffset(25, 725 ); 
      String text = "This is an example of adding text to a page in the pdf document. 
         we can add as many lines as we want like this using the draw string method 
         of the ContentStream class"; 

      //Adding text in the form of string 
      contentStream.showText(text); 

      //Ending the content stream 
      contentStream.endText(); 
      System.out.println("Content added");       

      //Closing the content stream 
      contentStream.close();      

      //Saving the document  
      doc.save(new File("C:/pdfBox/AddText_OP.pdf")); 

      //Closing the document  
      doc.close();  
   }  
} 
 Print
 Add Notes
 Bookmark this page
Amazon Interview Experience | Set 243 (2.5 Years Experience) - GeeksforGeeks

25 Jun, 2020
Input: arr[] = [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1]
Output: 6
       | 
   |   || |
_|_||_||||||
Trap "1 unit" between first 1 and 2, "4 units" between
first 2 and 3 and "1 unit" between second last 1 and last 2
 
 
 
 
 
 
If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
 
Amazon
Interview Experiences
Amazon
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Amazon Interview Experience for SDE-1 (Off-Campus)
Amazon AWS Interview Experience for SDE-1
Amazon Interview Experience
Amazon Interview Experience for SDE-1
Infosys Interview Experience for DSE 2022
Amazon Interview Experience (Off-Campus) 2022
Amazon Interview Experience for SDE-1 (On-Campus)
JPMorgan Chase & Co. Code for Good Internship Interview Experience 2021
Infosys Interview Experience for Digital Specialist Engineer Through InfyTQ
Google Interview Experience SDE-1 (Off-Campus) 2022
How to get all 2D diagonals of a 3D NumPy array? - GeeksforGeeks

02 Sep, 2020
Let’s see the program for getting all 2D diagonals of a 3D NumPy array. So, for this we are using numpy.diagonal() function of NumPy library. This function return specified diagonals from an n-dimensional array. 
Syntax: numpy.diagonal(a, axis1, axis2)Parameters: 
a: represents array from which diagonals has to be taken 
axis1: represents first axis to be taken for 2-d subarray 
axis2: represents second axis to be taken for 2-d subarray 
Return: array of diagonal elements.
Now, let’s see an example:
Example 1:
Python3
# Import the numpy packageimport numpy as np  # Create 3D-numpy array# of 4 rows and 4 columnsarr = np.arange(3 * 4 * 4).reshape(3, 4, 4)  print("Original 3d array:\n",       arr)  # Create 2D diagonal arraydiag_arr = np.diagonal(arr,                        axis1 = 1,                       axis2 = 2)  print("2d diagonal array:\n",       diag_arr)
Output:
Original 3d array:
 [[[ 0  1  2  3]
  [ 4  5  6  7]
  [ 8  9 10 11]
  [12 13 14 15]]

 [[16 17 18 19]
  [20 21 22 23]
  [24 25 26 27]
  [28 29 30 31]]

 [[32 33 34 35]
  [36 37 38 39]
  [40 41 42 43]
  [44 45 46 47]]]
2d diagonal array:
 [[ 0  5 10 15]
 [16 21 26 31]
 [32 37 42 47]]


Example 2:
Python3
# Import the numpy packageimport numpy as np  # Create 3D numpy array# of 3 rows and 4 columnsarr = np.arange(3 * 3 * 4).reshape(3, 3, 4)  print("Original 3d array:\n",       arr)  # Create 2D diagonal arraydiag_arr = np.diagonal(arr,                        axis1 = 1,                       axis2 = 2)  print("2d diagonal array:\n",      diag_arr)
Output:
Original 3d array:
 [[[ 0  1  2  3]
  [ 4  5  6  7]
  [ 8  9 10 11]]

 [[12 13 14 15]
  [16 17 18 19]
  [20 21 22 23]]

 [[24 25 26 27]
  [28 29 30 31]
  [32 33 34 35]]]
2d diagonal array:
 [[ 0  5 10]
 [12 17 22]
 [24 29 34]]


Example 3:
Python3
# Import the numpy packageimport numpy as np  # Create 3D numpy array# of 5 rows and 6 columnsarr = np.arange(3 * 5 * 6).reshape(3, 5, 6)print("Original 3d array:\n",      arr)  # Create 2D diagonal arraydiag_arr = np.diagonal(arr,                        axis1 = 1,                       axis2 = 2)  print("2d diagonal array:\n",      diag_arr)
Output:
Original 3d array:
 [[[ 0  1  2  3  4  5]
  [ 6  7  8  9 10 11]
  [12 13 14 15 16 17]
  [18 19 20 21 22 23]
  [24 25 26 27 28 29]]

 [[30 31 32 33 34 35]
  [36 37 38 39 40 41]
  [42 43 44 45 46 47]
  [48 49 50 51 52 53]
  [54 55 56 57 58 59]]

 [[60 61 62 63 64 65]
  [66 67 68 69 70 71]
  [72 73 74 75 76 77]
  [78 79 80 81 82 83]
  [84 85 86 87 88 89]]]
2d diagonal array:
 [[ 0  7 14 21 28]
 [30 37 44 51 58]
 [60 67 74 81 88]]


Python numpy-arrayManipulation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
Defaultdict in Python
Python | Get unique values from a list
Python | Pandas dataframe.groupby()
How do I handle the window close event in Tkinter?

Tkinter provides a custom handler to close the window. It acts as a callback function that the user can run in order to close the window.
To close the window using the handler, we can use the destroy() method. It closes the window abruptly after calling it in any function or any widget. Let us invoke the close event handler by defining a method.
#Importing the required library
from tkinter import *

#Create an instance of tkinter frame or window
win= Tk()

#Set the geometry
win.geometry("600x400")

#Create a button and pass arguments in command as a function name
my_button= Button(win, text= "X", font=('Helvetica bold', 20),
borderwidth=2, command= win.destroy)
my_button.pack(pady=20)

win.mainloop()
#Importing the required library
from tkinter import *

#Create an instance of tkinter frame or window
win= Tk()

#Set the geometry
win.geometry("600x300")

#Define a function

def close():
   win.destroy()

#Create a button and pass arguments in command as a function name
my_button= Button(win, text= "X", font=('Helvetica bold', 20),
borderwidth=2, command= close)
my_button.pack(pady=20)

win.mainloop()
Running the above code will create a button “X” and by clicking over that, we can close the main window.
How to Create Custom Errors using New Function in Golang? - GeeksforGeeks

15 Apr, 2020
Custom errors are those that can be defined by the user. For example, if one writes a function that is used to divide two numbers, which is to be used in multiple places, the user could create a custom error that can be set whenever division by zero is encountered, for it could prove to be fatal in the long run.
The easiest way to create custom errors in Golang is to use the New() function which is present in the errors module of Golang. Before actually moving on to creating our own error, let’s have a look at how it is implemented in the errors package.
package errors  // New returns an errorString// that contains the input // text as its value.func New(text string) error {    return &errorString{text}}  // errorString is a trivial// implementation of error.type errorString struct {    s string}  func (e *errorString) Error() string {    return e.s}
So, basically what the New() function does is create an error with a custom message that can be written by the programmer. For example, let’s say we want an error to be displayed whenever a negative value is given as input for the program that outputs the area of a square, given its side.
package main  // the errors package // contains the New functionimport (    "errors"     "fmt")  func main() {    side := -2.0    if side < 0.0 {                  // control enters here if error condition is met        fmt.Println(errors.New("Negative value entered!"))         return    }    fmt.Printf("Area= %f", side*side)  }
Output:
Negative value entered!

This was so because we had entered the length of side as -2, which cannot be possible, and hence the error was thrown. Now let’s try out a similar program but this time let’s put the error generation in a separate function.
package main  import (    "errors"    "fmt")  func findAreaSquare(side float64) (error, float64) {    if side < 0.0 {          // function that returns the error        // as well as the computed area        return errors.New("Negative value entered!"), 0    }    return nil, side * side}func main() {    side := -2.0    err, area := findAreaSquare(side)    if err != nil {        fmt.Printf("%s", err)        return    }    fmt.Printf("Area= %f", area)  }
Output:
Negative value entered!

Picked
Go Language
Write From Home
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Parse JSON in Golang?
Defer Keyword in Golang
Loops in Go Language
time.Parse() Function in Golang With Examples
Anonymous function in Go Language
Convert integer to string in Python
Convert string to integer in Python
How to set input type date in dd-mm-yyyy format using HTML ?
Python infinity
Matplotlib.pyplot.title() in Python
Java - toLowerCase() Method

The method returns the lowercase form of the specified char value.
char toLowerCase(char ch)

Here is the detail of parameters −
ch − Primitive character type.
ch − Primitive character type.
This method returns the lowercase form of the specified char value.
public class Test {

   public static void main(String args[]) {
      System.out.println(Character.toLowerCase('c'));
      System.out.println(Character.toLowerCase('C'));
   }
}
This will produce the following result −
c
c


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
How do I find out the default server character set in MySQL?

You can use system variables character_set_server to know the default server character set in MySQL. Following is the syntax −
SHOW VARIABLES LIKE 'character_set_server';
Additionally, to u can use collation_server system variable to know the default collation in MySQL. Following is the syntax −
SHOW VARIABLES LIKE 'collation_server';
Let us execute the above syntaxes to know the default character set and collation.
Following is the query −
mysql> SHOW VARIABLES LIKE 'character_set_server';
This will produce the following output −
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| character_set_server | utf8  |
+----------------------+-------+
1 row in set (0.25 sec)
Following is the query to know collation −
mysql> SHOW VARIABLES LIKE 'collation_server';
This will produce the following output −
+------------------+-----------------+
| Variable_name    | Value           |
+------------------+-----------------+
| collation_server | utf8_unicode_ci |
+------------------+-----------------+
1 row in set (0.01 sec)