code-rag-bench/online-tutorials huggingface dataset:
Calculate the number of characters in each word in a Pandas series - GeeksforGeeks

28 Jul, 2020
To calculate the numbers of characters we use Series.str.len(). This function returns the count of the characters in each word in a series.
Syntax: Series.str.len()
Return type: Series of integer values. NULL values might be present too depending upon caller series.
Another way to find the number of characters by using len() function (that wrapped inside the map function) so that the given series substitutes the value of length by taking series of data as input using pandas.series().
Let’s see some examples:
Example 1: We take input of words and count each character of words with the help of Series.map() that substitute the values and gives output using a function named as calc.
# Import pandas libraryimport pandas as pd  # Input series of wordswords = pd.Series(['Java', 'Kotlin',                   'Python', 'Scala',                    'Ruby'])print("Given Series:")print(words)  # Substituting values using maprst = words.map(lambda calc: len(calc))print("No. of characters in each word in the given series:")print(rst)
Output:
Example 2: We input a series of words and substitute values using Series.map() and use Series.apply() for single values.
# Import pandas libraryimport pandas as pd  # Input series of wordswords = pd.Series(['Number', 'Of', 'Characters',                   'In', 'Each', 'Word'])[len(count)                   for count in words]  # Substituting values using a mapwords.map(len)  # For single valueswords.apply(len)
Output:
Example 3: To print in a specific format of word with its length.
# Import pandas libraryimport pandas as pd  # Input series of wordswords = pd.Series(['alphabet', 'consonants',                    'vowels', 'letters'])  # Display length of words# along with wordsfor i in range(len(words)):    print(words[i], words.str.len()[i])     
Output:
Python pandas-dataFrame
Python-pandas
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()
MySQL query to split a column after specific characters?

To split a column after specific characters, use the SUBSTRING_INDEX() method −
select substring_index(yourColumnName,'-',-1) AS anyAliasName from yourTableName;
Let us first create a table −
mysql> create table DemoTable
-> (
-> StreetName text
-> );
Query OK, 0 rows affected (0.60 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Paris Hill St.-CA-83745646') ;
Query OK, 1 row affected (0.32 sec)

mysql> insert into DemoTable values('502 South Armstrong Street-9948443');
Query OK, 1 row affected (0.20 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------------------------------------+
| StreetName                         |
+------------------------------------+
| Paris Hill St.-CA-83745646         |
| 502 South Armstrong Street-9948443 |
+------------------------------------+
2 rows in set (0.00 sec)
Following is the query to split a column after specific characters −
mysql> select substring_index(StreetName,'-',-1) AS Split from DemoTable;
This will produce the following output −
+----------+
| Split    |
+----------+
| 83745646 |
| 9948443  |
+----------+
2 rows in set (0.00 sec)
CSS Styling of File Upload Button with ::file-selector-button Selector

We can style the file upload button using the CSS pseudo element ::file-selector-button. However, the full support of this pseudo element is limited to Firefox and Firefox Android.
::-webkit-file-upload-button is used to support Safari, Chrome and Opera.
The syntax of CSS file-selector property is as follows −
Selector::file-selector-button {
   attribute: /*value*/
}
Selector::-webkit-file-upload-button {
   attribute: /*value*/
}
The following examples illustrate CSS file-selector-button selector.
 Live Demo
<!DOCTYPE html>
<html>
<head>
   <style>
   input[type=file]::file-selector-button:hover {
      cursor: grab;
      background-color: blueviolet;
      color: white;
      font-size: 1.2em;
      box-shadow: inset 5px 10px 10px cornflowerblue;
   }
</style>
</head>
   <body>
      <form>
         <label for="fup">Click to</label>
         <input type="file" id="fup" />
         <input type="text" placeholder="Random Text here" />
         <button type="submit">Done</button>
      </form>
   </body>
</html>
This gives the following output in Firefox web browser.
 Live Demo
<!DOCTYPE html>
<html>
<head>
   <style>
      input[type=file]::file-selector-button:hover {
         cursor: pointer;
         background-color: crimson;
         font-size: 1.2em;
         border-radius: 25%;
         box-shadow: inset 5px 10px 10px cornsilk;
      }
      input[type=file]::-webkit-file-upload-button:hover {
         cursor: pointer;
         background-color: crimson;
         font-size: 1.2em;
         border-radius: 25%;
         box-shadow: inset 5px 10px 10px cornsilk;
      }
   </style>
</head>
   <body>
      <form>
         <label for="fup">Click to</label>
         <input type="file" id="fup" />
         <input type="text" placeholder="using webkit prefix" />
         <button type="submit">Done</button>
      </form>
   </body>
</html>
This gives the following output in Google Chrome.
C library function - fsetpos()

The C library function int fsetpos(FILE *stream, const fpos_t *pos) sets the file position of the given stream to the given position. The argument pos is a position given by the function fgetpos.
Following is the declaration for fsetpos() function.
int fsetpos(FILE *stream, const fpos_t *pos)
stream − This is the pointer to a FILE object that identifies the stream.
stream − This is the pointer to a FILE object that identifies the stream.
pos − This is the pointer to a fpos_t object containing a position previously obtained with fgetpos.
pos − This is the pointer to a fpos_t object containing a position previously obtained with fgetpos.
This function returns zero value if successful, or else it returns a non-zero value and sets the global variable errno to a positive value, which can be interpreted with perror.
The following example shows the usage of fsetpos() function.
#include <stdio.h>

int main () {
   FILE *fp;
   fpos_t position;

   fp = fopen("file.txt","w+");
   fgetpos(fp, &position);
   fputs("Hello, World!", fp);
  
   fsetpos(fp, &position);
   fputs("This is going to override previous content", fp);
   fclose(fp);
   
   return(0);
}
Let us compile and run the above program to create a file file.txt which will have the following content. First of all we get the initial position of the file using fgetpos() function, and then we write Hello, World! in the file but later we used fsetpos() function to reset the write pointer at the beginning of the file and then over-write the file with the following content −
This is going to override previous content

Now let's see the content of the above file using the following program −
#include <stdio.h>

int main () {
   FILE *fp;
   int c;

   fp = fopen("file.txt","r");
   while(1) {
      c = fgetc(fp);
      if( feof(fp) ) {
         break;
      }
      printf("%c", c);
   }
   fclose(fp);
   return(0);
}
Let us compile and run the above program to produce the following result −
This is going to override previous content


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
How to make an ImageView with rounded corners on Android App using Kotlin?

This example demonstrates how to make an ImageView with rounded corners on Android App using
Kotlin.
Step 1 − Create a new project in Android Studio, go to File ? New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:padding="4dp"
   tools:context=".MainActivity">
   <ImageView
      android:id="@+id/imageView"
      android:layout_width="match_parent"
      android:layout_height="match_parent" />
</RelativeLayout>
Step 3 − Add the following code to src/MainActivity.kt
import android.graphics.*
import android.graphics.drawable.BitmapDrawable
import android.os.Bundle
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() {
   override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
      title = "KotlinApp"
      val imageView = findViewById(R.id.imageView)
      val bitmap = (resources.getDrawable(R.drawable.image) as BitmapDrawable).bitmap
      val imageRounded = Bitmap.createBitmap(bitmap.width, bitmap.height, bitmap.config)
      val canvas = Canvas(imageRounded)
      val paint = Paint()
      paint.isAntiAlias = true
      paint.shader = BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP)
      canvas.drawRoundRect(RectF(10F, 10F, bitmap.width.toFloat(), bitmap.height.toFloat()),
      200F, 200F, paint) // Round Image Corner 100 100 100 100
      imageView.setImageBitmap(imageRounded)
   }
}
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.myapplication">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with
your computer. To run the app from android studio, open one of your project's activity files and click the Run icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen
TensorFlow - Distributed Computing

This chapter will focus on how to get started with distributed TensorFlow. The aim is to help developers understand the basic distributed TF concepts that are reoccurring, such as TF servers. We will use the Jupyter Notebook for evaluating distributed TensorFlow. The implementation of distributed computing with TensorFlow is mentioned below −
Step 1 − Import the necessary modules mandatory for distributed computing −
import tensorflow as tf

Step 2 − Create a TensorFlow cluster with one node. Let this node be responsible for a job that that has name "worker" and that will operate one take at localhost:2222.
cluster_spec = tf.train.ClusterSpec({'worker' : ['localhost:2222']})
server = tf.train.Server(cluster_spec)
server.target

The above scripts generate the following output −
'grpc://localhost:2222'
The server is currently running.

Step 3 − The server configuration with respective session can be calculated by executing the following command −
server.server_def

The above command generates the following output −
cluster {
   job {
      name: "worker"
      tasks {
         value: "localhost:2222"
      }
   }
}
job_name: "worker"
protocol: "grpc"
Step 4 − Launch a TensorFlow session with the execution engine being the server. Use TensorFlow to create a local server and use lsof to find out the location of the server.
sess = tf.Session(target = server.target)
server = tf.train.Server.create_local_server()

Step 5 − View devices available in this session and close the respective session.
devices = sess.list_devices()
for d in devices:
   print(d.name)
sess.close()
The above command generates the following output −
/job:worker/replica:0/task:0/device:CPU:0


    61 Lectures 
     9 hours 

 Abhishek And Pukhraj

    57 Lectures 
     7 hours 

 Abhishek And Pukhraj

    52 Lectures 
     7 hours 

 Abhishek And Pukhraj

    52 Lectures 
     6 hours 

 Abhishek And Pukhraj

    29 Lectures 
     3.5 hours 

 Mohammad Nauman

    82 Lectures 
     4 hours 

 Anis Koubaa
 Print
 Add Notes
 Bookmark this page
Given a column name how can I find which tables in a MySQL database contain that column?

Use the COLUMN_NAME to find which table in a database contains a specific column. Let us first create a table −
mysql> create table DemoTable
   -> (
   -> CustomerId int,
   -> CustomerName varchar(20),
   -> CustomerCountryName varchar(100)
   -> );
Query OK, 0 rows affected (1.05 sec)
Following is the query to find in which tables a specific column “'CustomerCountryName'” is present −
mysql> select *from information_schema.columns WHERE COLUMN_NAME =
'CustomerCountryName';
This will produce the following output −
+---------------+--------------+--------------+---------------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+-----------------+--------------+------------+-------+---------------------------------+----------------+-----------------------+-------+
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME  | COLUMN_NAME          |ORDINAL_POSITION  | COLUMN_DEFAULT | IS_NULLABLE | DATA_TYPE |CHARACTER_MAXIMUM_LENGTH | CHARACTER_OCTET_LENGTH |NUMERIC_PRECISION | UMERIC_SCALE | DATETIME_PRECISION |CHARACTER_SET_NAME | COLLATION_NAME | COLUMN_TYPE | COLUMN_KEY | EXTRA | PRIVILEGES | COLUMN_COMMENT | GENERATION_EXPRESSION | SRS_ID |
+---------------+--------------+--------------+---------------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+-----------------+--------------+------------+-------+---------------------------------+----------------+-----------------------+-------+
| def | sample | demotable189 | CustomerCountryName | 4 | NULL |YES | varchar | 100 | 300 | NULL | NULL | NULL | utf8 | utf8_general_ci | varchar(100) | | |select,insert,update,references | | | NULL |
| def | web | DemoTable | CustomerCountryName | 4 | NULL |YES | varchar | 20 | 60 | NULL | NULL |NULL | utf8 | utf8_unicode_ci | varchar(20) | | |select,insert,update,references | | | NULL |
| def | web | DemoTable | CustomerCountryName | 3 | NULL |YES | varchar | 100 | 300 | NULL | NULL |NULL | utf8 | utf8_unicode_ci | varchar(100) | | |select,insert,update,references | | | NULL |
+---------------+--------------+--------------+---------------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+-----------------+--------------+------------+-------+---------------------------------+----------------+-----------------------+-------+
3 rows in set (0.68 sec)
Above, you can see the column “CustomerCountryName” is present in 3 tables.
What are enumerated data types in C++?

An enumerated type declares an optional type name and a set of zero or more identifiers that can be used as values of the type. Each enumerator is a constant whose type is the enumeration. For example, if you are creating an application that has a fixed number of types for some variable. For example, let's say gender, it can be of three types male, female and others. You can define and use an enum like −
#include<iostream>
using namespace std;
enum Gender {MALE, FEMALE, OTHERS};
int main() {
   Gender gen = Gender.FEMALE;
   return 0;
}
By default, the value of the first name is 0, the second name has the value 1, and the third has the value 2, and so on. But these values don't matter because enums are basically used to have a symbolic meaning. Whenever you compare an enum in your program, you'd be just using its symbolic meaning and not its actual value.
Convert an object to another type using map() method with Lambda in Java?

In Java 8, we have the ability to convert an object to another type using a map() method of Stream object with a lambda expression. The map() method is an intermediate operation in a stream object, so we need a terminal method to complete the stream.
<R>Stream <R> map(Function<? super T,? extends R> mapper)
import java.util.*;
import java.util.stream.*;

public class EmployeeInformationTest {
   public static void main(String args[]) {
      List<Employee> employees = Arrays.asList(
         new Employee("Jai"),
         new Employee("Adithya"),
         new Employee("Raja"));
      List<String> names = employees.stream()
         .map(s -> s.getEmployeeName())              // Lambda Expression
         .collect(Collectors.toList());
      System.out.println(names);
   }
}

// Employee class
class Employee {
   private String empName;
   private String empDesignation;
   public Employee(String empName) {
      this.empName = empName;
   }
   public String getEmployeeName() {
      return empName;
   }
   public void setEmployeeName(String empName) {
      this.empName = empName;
   }
   public String getEmployeeDesignation() {
      return empDesignation;
   }
   public void setEmployeeDesignation(String empDesignation) {
      this.empDesignation = empDesignation;
   }
}
[Jai, Adithya, Raja]
C# program to find the index of an element in a List

Set a list and add elements −
List<int> val = new List<int>();

// integer elements
val.Add(35);
val.Add(55);
val.Add(68);
Let’s say now we need to find the index of element 68. For that, use the IndexOf() method −
int index = val.IndexOf(68);
Here is the complete code −
 Live Demo
using System;
using System.Collections.Generic;
public class Demo {
   public static void Main() {
      List<int> val = new List<int>();
      // integer elements
      val.Add(35);
      val.Add(55);
      val.Add(68);
      // finding the index of element 68
      int index = val.IndexOf(68);
      Console.WriteLine(index);
   }
}
2
numpy.sign() in Python - GeeksforGeeks

03 Oct, 2019
numpy.sign(array [, out]) function is used to indicate the sign of a number element-wise.For integer inputs, if array value is greater than 0 it returns 1, if array value is less than 0 it returns -1, and if array value 0 it returns 0.
Syntax: numpy.sign()
Parameters :array : [array_like] Input values.out : [ndarray, optional] Output array placed with result.
Return : [ndarray] Returns the sign of array. If an array is scalar then the sign of array will be scalar.
Code 1 :
# Python Program illustrating# numpy.sign() method  # importing numpyimport numpy as geek    # input arrays    array1 = [1, 0, -13]array2 =  [-1, 0, 15]  # print the input arrays  print ("input array1 : ", array1)print ("input array2 : ", array2)  # determine the sign of integer numbers in an array  print ("\nCheck sign of array1 : ", geek.sign(array1))print ("\nCheck sign of array2 : ", geek.sign(array2)) 
Output :
array1 :  [1, 0, -13]
array2 :  [-1, 0, 15]

Check sign of array1 :  [ 1  0 -1]

Check sign of array2 :  [-1  0  1]


Code 2 :
# Python Program illustrating# numpy.sign() method  # importing numpy  import numpy as geek   # determine the sign of complex numberprint ("\n Check sign of complex input1 : ", geek.sign(7-3j))print ("\n Check sign of complex input2 : ", geek.sign(-7 + 3j)) 
Output :
 Check sign of complex input1 :  (1+0j)

 Check sign of complex input2 :  (-1+0j)
 
sanjoy_62
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
How to Install PIP on Windows ?
Read a file line by line in Python
Enumerate() in Python
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python program to convert a list to string
Create a Pandas DataFrame from Lists
Python String | replace()
Reading and Writing to text files in Python
Python – Consecutive Repetition of Characters

22 Apr, 2020
Sometimes, while working with character lists we can have a problem in which we need to perform consecutive repetition of characters. This can have application in many domains. Lets discuss certain ways in which this task can be performed.
Method #1 : Using list comprehensionThis is one of the way in which this task can be performed. In this, we perform a brute force way to perform but in a one-liner for by multiplying each character by magnitude.
# Python3 code to demonstrate working of # Consecutive Repetition of  Characters# Using list comprehension  # initializing listtest_list = ['g', 'f', 'g', 'i', 's', 'b', 'e', 's', 't']  # printing original listprint("The original list is : " + str(test_list))  # initializing K K = 3  # Consecutive Repetition of  Characters# Using list comprehensionres = [sub for ele in test_list for sub in [ele] * K]  # printing result print("The list after Consecutive Repetition is : " + str(res)) 
The original list is : [‘g’, ‘f’, ‘g’, ‘i’, ‘s’, ‘b’, ‘e’, ‘s’, ‘t’]The list after Consecutive Repetition is : [‘g’, ‘g’, ‘g’, ‘f’, ‘f’, ‘f’, ‘g’, ‘g’, ‘g’, ‘i’, ‘i’, ‘i’, ‘s’, ‘s’, ‘s’, ‘b’, ‘b’, ‘b’, ‘e’, ‘e’, ‘e’, ‘s’, ‘s’, ‘s’, ‘t’, ‘t’, ‘t’]
 
Method #2 : Using chain() + repeat()The combination of above functions can be used to solve this problem. In this, we perform the task of repeating using repeat() and the result construction using chain().
# Python3 code to demonstrate working of # Consecutive Repetition of  Characters# Using chain() + repeat()from itertools import chain, repeat  # initializing listtest_list = ['g', 'f', 'g', 'i', 's', 'b', 'e', 's', 't']  # printing original listprint("The original list is : " + str(test_list))  # initializing K K = 3  # Consecutive Repetition of  Characters# Using chain() + repeat()res = list(chain.from_iterable(repeat(chr, K) for chr in test_list))  # printing result print("The list after Consecutive Repetition is : " + str(res)) 
The original list is : [‘g’, ‘f’, ‘g’, ‘i’, ‘s’, ‘b’, ‘e’, ‘s’, ‘t’]The list after Consecutive Repetition is : [‘g’, ‘g’, ‘g’, ‘f’, ‘f’, ‘f’, ‘g’, ‘g’, ‘g’, ‘i’, ‘i’, ‘i’, ‘s’, ‘s’, ‘s’, ‘b’, ‘b’, ‘b’, ‘e’, ‘e’, ‘e’, ‘s’, ‘s’, ‘s’, ‘t’, ‘t’, ‘t’]
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python | os.path.join() method
Python OOPs Concepts
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 | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
Ruby | String index Method

09 Dec, 2019
index is a String class method in Ruby which is used to returns the index of the first occurrence of the given substring or pattern (regexp) in the given string. It specifies the position in the string to begin the search if the second parameter is present. It will return nil if not found.
Syntax: str.index()
Parameters: Here, str is the given string.
Returns: Index of the first occurrence of the given substring or pattern (regexp) in str.
Example 1:
# Ruby program to demonstrate # the index method        # Taking a string and # using the methodputs "Sample".index('m')           puts "Program".index('gr')            puts "Checking".index('a')             
Output:
2
3


Example 2:
# Ruby program to demonstrate # the index method        # Taking a string and # using the methodputs "Mangal".index(?g)           puts "Language".index(/[aeiou]/, -3)            
Output:
3
5

Ruby String-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Make a Custom Array of Hashes in Ruby?
Global Variable in Ruby
Ruby | Array select() function
Ruby | Case Statement
Ruby | Enumerator each_with_index function
Ruby | Hash delete() function
Ruby | unless Statement and unless Modifier
Ruby | Data Types
Ruby | String capitalize() Method
Ruby | String gsub! Method
How to make text bold in HTML?

To make text bold in HTML, use the <b>...</b> tag or <strong>...</strong> tag. Both the tags have the same functioning, but <strong> tag adds semantic strong importance to the text. The <b> tag is a physical markup element, but do not add semantic importance.
Just keep in mind that you can get the same result in HTML with CSS font-weight property.
You can try to run the following code to make text bold in HTML using <strong>...</strong> tag
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>HTML text bold</title>
   </head>

   <body>
      <h2>Our Products</h2>
      <p>Developed 10 <strong>Android</strong> apps till now.</p>
   </body>
</html>
You can try to run the following code to make text bold in HTML using font-weight property
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>HTML text bold</title>
   </head>

   <body>
      <h1>Tutorialspoint</h1>
      <p style="font-weight: bold;">Simply Easy Learning</p>
   </body>
</html>
<mat-list> in Angular Material

22 Feb, 2021
Introduction:Angular Material is a UI component library that is developed by the Angular team to build design components for desktop and mobile web applications. In order to install it, we need to have angular installed in our project, once you have it you can enter the below command and can download it. <mat-list> tag is used to display the list of items or records.
Installation syntax:
ng add @angular/material
Approach:
First, install the angular material using the above-mentioned command.
After completing the installation, Import ‘MatListModule’ from ‘@angular/material/list’ in the app.module.ts file.
After importing the ‘MatListModule’ we need to use <mat-list> tag.
Inside the <mat-list> tag we need to use <mat-list-item> tag for every item or labels.
We need to include role property for both <mat-list> tag and <mat-list-item>.
For <mat-list> we need to assign the role property with “list” string and for <mat-list-item> we need to assign the role property with “listitem” string value.
Once done with the above steps then serve or start the project.
Code Implementation:app.module.ts:
Javascript
import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { MatListModule } from '@angular/material';     import { AppComponent } from './example.component';     @NgModule({   declarations: [AppComponent],   exports: [AppComponent],   imports: [     CommonModule,     FormsModule,     MatListModule    ], }) export class AppModule {}
app.component.html:
HTML
<mat-list role="list">  <mat-list-item role="listitem">HTML</mat-list-item>  <mat-list-item role="listitem">CSS</mat-list-item>  <mat-list-item role="listitem">Javascript</mat-list-item></mat-list>
Output: 
 
 
Angular-material
Picked
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Routing in Angular 9/10
Angular PrimeNG Dropdown Component
Angular 10 (blur) Event
How to make a Bootstrap Modal Popup in Angular 9/8 ?
How to create module with Routing in Angular 9 ?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Python Desktop Notifier using Plyer module

06 Jun, 2021
This article demonstrates how to create a simple Desktop Notifier application using Python. A desktop notifier is a simple application which produces a notification message in form of a pop-up message on desktop. We will be using plyer module for the same.
time: This module works with the time object and is installed by defaultPlyer: Plyer module is used to access the features of the hardware. This module does not comes built-in with Python. We need to install it externally. To install this module type the below command in the terminal.
time: This module works with the time object and is installed by default
Plyer: Plyer module is used to access the features of the hardware. This module does not comes built-in with Python. We need to install it externally. To install this module type the below command in the terminal.
pip install plyer 
Approach:
Step 1) Import the notification class from the plyer module
from plyer import notification
Step 2) After that you just need to call the notify method of this class.
Syntax: notify(title=”, message=”, app_name=”, app_icon=”, timeout=10, ticker=”, toast=False)
Parameters:
title (str) – Title of the notification
message (str) – Message of the notification
app_name (str) – Name of the app launching this notification
app_icon (str) – Icon to be displayed along with the message
timeout (int) – time to display the message for, defaults to 10
ticker (str) – text to display on status bar as the notification arrives
toast (bool) – simple Android message instead of full notification
Step 3) Add the sleep function to show that notification again.
Below is the implementation. 
Python3
import timefrom plyer import notification  if __name__=="__main__":         notification.notify(            title = "HEADING HERE",            message=" DESCRIPTION HERE" ,                       # displaying time            timeout=2)        # waiting time        time.sleep(7)
Output:
sooda367
Python-projects
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list
TCS Placement Paper | Email Writing Question 8

21 May, 2019
Pre-requisite: Procedure to E-mail WritingThis is a TCS model placement email-writing question. It covers the important directions along with a sample solution to the question.
Directions:
Use all the phrases given.Minimum words should be 70 otherwise your email cannot be validated.Addressing and signing should be done as in the question given.Common grammatical rules, punctuation should be according to standard English.You can use your own phrases along with the phrases given.
Use all the phrases given.
Minimum words should be 70 otherwise your email cannot be validated.
Addressing and signing should be done as in the question given.
Common grammatical rules, punctuation should be according to standard English.
You can use your own phrases along with the phrases given.
Question:Using the following phrases, write an email with a minimum of 70 words to the customer Mr Roy explaining the delay to the project.
Phrases:
Payment processing system – Schedule – 10th May (Friday) – Unexpected power outage – 
3 days – Overall delay – 7 days – includes recovery of lost work – will not recur

Solution – Sample E-mail:
Dear Mr Roy,
The project “Payment Processing System” which was scheduled to be completed by 10th May (Friday) will face a delay. Due to an unexpected power outage at the site for the past 3 days and failing to get the backups online, an overall delay is imminent. Therefore a maximum of 7 days would be required to come up with an overhaul which includes recovery of lost work and resuming the task.
We would like to apologize for the delay caused and would ensure that the failure will not recur in the future again.
Thanks and regards,Chinmoy.
Note: You can write your own versions of e-mail keeping in mind the points needed to be taken care of while an e-mail. Refer Procedure to E-mail Writing.
interview-preparation
placement preparation
TCS
Placements
TCS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Space between two rows in a table using CSS?

10 May, 2022
The space between two rows in a table can be done using CSS border-spacing and border-collapse property. The border-spacing property is used to set the spaces between cells of a table and border-collapse property is used to specify whether the border of table is collapse or not. The border-spacing attribute can only be used if border-collapse attribute is set to separate. Example: 
html
<!DOCTYPE html><html>    <head>        <style>            table {                border-collapse: collapse;            }            th {                background-color:green;                Color:white;            }            th, td {                width:150px;                text-align:center;                border:1px solid black;                padding:5px                         }            .geeks {                border-right:hidden;            }            .gfg {                border-collapse:separate;                border-spacing:0 15px;            }            h1 {                color:green;            }        </style>    </head>    <body>        <center>        <h1>GeeksforGeeks</h1>        <h2>Row spacing in a table</h2>        <table>            <tr>                <th>Employee ID</th>                <th>Name</th>                <th>Gender</th>                <th>Age</th>            </tr>        </table>        <table class = "gfg">            <tr>                <td class = "geeks">10001</td>                <td>Thomas</td>                <td>M</td>                <td>32</td>            </tr>            <tr>                <td class = "geeks">10002</td>                <td>Sally</td>                <td>F</td>                <td>28</td>            </tr>            <tr>                <td class = "geeks">10003</td>                <td>Anthony</td>                <td>M</td>                <td>24</td>            </tr>        </table>        </center>    </body></html>
Output: 
CSS is the foundation of webpages, is used for webpage development by styling websites and web apps.You can learn CSS from the ground up by following this CSS Tutorial and CSS Examples.
hardikkoriintern
CSS-Misc
Picked
Technical Scripter 2018
CSS
HTML
Technical Scripter
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to write in a file using fputs() in C

17 May, 2022
fputs() is a function declared in stdio.h header file. It is used to write the contents of the file. The function takes 2 arguments. The first argument is a pointer to the string which is to be written and the second argument is the pointer of the file where the string is to be written. It returns 1 if the write operation was successful, otherwise, it returns 0. fputs() writes a single line of characters in a file.
Syntax-
fputs(const *char str, FILE *fp); where str is a char name that we write in a file and fp is the file pointer.
Example-
Input- str1 = “geeksforgeeks”, str2 = “gfg”Output- The output file will consist of two lines:geeksforgeeksgfg
Below is the C program to implement the fputs() function-
C
// C program to implement// the above approach #include <stdio.h>#include <string.h> // Function to write// string to file// using fputsvoid writeToFile(char str[]){    // Pointer to file    FILE* fp;     // Name of the file    // and mode of the file    fp = fopen("f1.txt", "w");     // Write string to file    fputs(str, fp);     // Close the file pointer    fclose(fp);} // Driver Codeint main(){    char str[20];    strcpy(str, "GeeksforGeeks");    writeToFile(str);    return 0;}
Output-
 
demian_parkhomenko
File Handling
C Programs
File Handling
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Matplotlib.axes.Axes.secondary_xaxis() in Python

06 Jul, 2022
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
The Axes.secondary_xaxis() function in axes module of matplotlib library is also used to add a second x-axis to this axes.
Syntax: Axes.secondary_xaxis(self, location, *, functions=None, **kwargs) 
Parameters: This method accept the following parameters that are described below:
location : This parameter is the position to put the secondary axis.
functions : This parameter is used to specify the transform function and its inverse.
Returns: This method returns  the following:
ax : This return the axes._secondary_axes.SecondaryAxis.
Note: This function works in Matplotlib version >= 3.1 
Below examples illustrate the matplotlib.axes.Axes.secondary_xaxis() function in matplotlib.axes: 
Example 1: 
Python3
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport numpy as np    fig, ax = plt.subplots()ax.plot([1, 2, 3]) ax.set_xlabel('X-Axis')ax.set_ylabel('Y-Axis') secax = ax.secondary_xaxis('top')secax.set_xlabel('Secondary-X-Axis')ax.set_title('matplotlib.axes.Axes.secondary_xaxis() Example',             fontsize = 14, fontweight ='bold')plt.show()
Output:
  
Example 2: 
Python3
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport numpy as npimport datetimeimport matplotlib.dates as mdatesfrom matplotlib.transforms import Transformfrom matplotlib.ticker import (    AutoLocator, AutoMinorLocator) fig, ax = plt.subplots(constrained_layout = True)x = np.arange(0, 500, 2)y = np.sin(3 * x * np.pi / 180)ax.plot(x, y)ax.set_xlabel('Degree')ax.set_ylabel('Frequency')  def val1(x):    return x * np.pi / 180  def val2(x):    return x * 180 / np.pi secax = ax.secondary_xaxis('top', functions =(val1, val2))secax.set_xlabel('Radian')ax.set_title('matplotlib.axes.Axes.secondary_xaxis() Example',             fontsize = 14, fontweight ='bold')plt.show()
Output:
 
simmytarika5
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Iterate over a list in Python
Python Classes and Objects
Convert integer to string in Python
Find subsequences with maximum Bitwise AND and Bitwise OR in Python

Suppose we have an array of n elements, we have to show the maximum sum by choosing two subsequences of the array (they may or may not be different) so that the sum of bit-wise AND operation of all elements of the first subsequence and bit-wise OR operation of all the elements of the second subsequence is maximum.
So, if the input is like A = {4, 6, 7, 2}, then the output will be 14 as we are getting maximum AND value by selecting 7 only and maximum OR value by selecting all (4 | 6 | 7 | 2) = 7. So, the result will be 7 + 7 = 14.
To solve this, we will follow these steps −
and_max := maximum of arr
and_max := maximum of arr
or_max := 0
or_max := 0
for i in range 0 to size of arr, door_max := or_max OR arr[i]
for i in range 0 to size of arr, do
or_max := or_max OR arr[i]
or_max := or_max OR arr[i]
return and_max + or_max
return and_max + or_max
Let us see the following implementation to get better understanding −
 Live Demo
def get_max_sum(arr):
   and_max = max(arr)
   or_max = 0
   for i in range(len(arr)):
      or_max|= arr[i]
   return and_max + or_max
a = [4,6,7,2]
print(get_max_sum(a))
[4,6,7,2]
Output
14
How to search by multiple key => value in PHP array ?

30 May, 2019
In a multidimensional array, if there is no unique pair of key => value (more than one pair of key => value) exists then in that case if we search the element by a single key => value pair then it can return more than one items. Therefore we can implement the search with more than one key => value pair to get unique items.
Approach: For each array inside the array, iterate over the search array and if any search key value doesn’t match with corresponding array key value we discard that array and continue the process for next array. Let’s understand this better with an example:Suppose we want to search student details from a list of the student which contains student of different section, therefore, in this case, rollNo alone might not give the correct output. So we will need to search the list with two key => value that is rollNO and section.
Example:
<?php  // PHP program to search for multiple// key=>value pairs in array  function search($array, $search_list) {      // Create the result array    $result = array();      // Iterate over each array element    foreach ($array as $key => $value) {          // Iterate over each search condition        foreach ($search_list as $k => $v) {                  // If the array element does not meet            // the search condition then continue            // to the next element            if (!isset($value[$k]) || $value[$k] != $v)            {                                  // Skip two loops                continue 2;            }        }              // Append array element's key to the        //result array        $result[] = $value;    }      // Return result     return $result;}  // Multidimensional array for students list$arr = array(    1 => array(        'rollNo' => 44,        'name' => 'Alice',        'section' => 'B'    ),    2 => array(        'rollNo' => 3,        'name' => 'Amit',        'section' => 'B'    ),    3 => array(        'rollNo' => 3,        'name' => 'Bob',        'section' => 'A'    ),    4 => array(        'rollNo' => 5,        'name' => 'Gaurav',        'section' => 'B'    ),    5 => array(        'rollNo' => 5,        'name' => 'Gaurav',        'section' => 'A'    ) );  // Define search list with multiple key=>value pair$search_items = array('rollNo'=>5, 'section'=>"A");  // Call search and pass the array and// the search list$res = search($arr, $search_items);  // Print search resultforeach ($res as $var) {    echo 'RollNo: ' . $var['rollNo'] . '<br>';    echo 'Name: ' . $var['name'] . '<br>';    echo 'Section: ' . $var['section'] . '<br>';        }  ?>
RollNo: 5Name: GauravSection: A

PHP-array
PHP
PHP Programs
Web Technologies
Web technologies Questions
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to check if array contains three consecutive dates in java?

To check to find whether a given array contains three consecutive dates:
Convert the given array into a list of type LocalDate.
Using the methods of the LocalDate class compare ith, i+1th and i+1th, i+2th elements of the list if equal the list contain 3 consecutive elements.
Live Demo
import java.time.LocalDate;
import java.time.Month;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

public class ConsicutiveDate {
   public static void main(String args[]) {
      String[] dates = {"5/12/2017", "6/12/2017", "7/12/2017"};
      List<LocalDate> localDateList = new ArrayList<>();
      for (int i = 0; i<dates.length; i++) {
         String[] data = dates[i].split("/");
         Month m = Month.of(Integer.parseInt(data[1]));
         LocalDate localDate =
            LocalDate.of(Integer.parseInt(data[2]),m,Integer.parseInt(data[0]));
         localDateList.add(localDate);
         Date date = java.sql.Date.valueOf(localDate);
      }
      System.out.println("Contents of the list are ::"+localDateList);
      Collections.sort(localDateList);
      for (int i = 0; i < localDateList.size() - 1; i++) {
         LocalDate date1 = localDateList.get(i);
         LocalDate date2 = localDateList.get(i + 1);
         if (date1.plusDays(1).equals(date2)) {
            System.out.println("Consecutive Dates are: " + date1 + " and " + date2);
         }
      }
   }
}
Contents of the list are ::[2017-12-05, 2017-12-06, 2017-12-07]
Consecutive Dates are: 2017-12-05 and 2017-12-06
Consecutive Dates are: 2017-12-06 and 2017-12-07
Find a local minima in an array in C++

Suppose we have an array A with n elements. We have to find the local minima of the array. In array A, the element A[x] is said to be local minima if it is less than or equal to both of its neighbors. For corner elements only one neighbor will be considered. And if there are more than one local minima available, then return only one. For example, if the array is like [9, 6, 3, 14, 5, 7, 4], then the local minima can be 3, 5 and 4, so this algorithm can return only one of them.
To solve this problem, we will follow the logic like binary search. If the middle element is lesser than its left and right elements, then return mid, otherwise, if it is greater than left neighbor, then there may be some local minima at left hand side, if it is greater than the right element, then there will be some local minima at right, do the same task for them to find exact local minima.
 Live Demo
#include<iostream>
using namespace std;
int localMinima(int arr[], int left, int right, int n) {
   int mid = left + (right - left)/2;
   if ((mid == 0 || arr[mid-1] > arr[mid]) && (mid == n-1 || arr[mid+1] > arr[mid]))
      return mid;
   else if (mid > 0 && arr[mid-1] < arr[mid])
      return localMinima(arr, left, (mid -1), n);
   return localMinima(arr, (mid + 1), right, n);
}
int findLocalMinima(int arr[], int n) {
   return localMinima(arr, 0, n-1, n);
}
int main() {
   int arr[] = {9, 6, 3, 14, 5, 7, 4};
   int n = sizeof(arr)/sizeof(arr[0]);
   cout << "Local minima is: " << arr[findLocalMinima(arr, n)];
}
Local minima is: 3
Tryit Editor v3.7

Tryit: Background image for paragraph
Compressing and Decompressing files using GZIP Format in C#

To compress and decompress files using GZIP Format, use the GZipStream class.
To zip a file, use the GZipStream class with the FileStream class. Set the following parameters.
File to be zipped and the name of the output zip file.
Here, outputFile is the output file and the file is read into the FileStream.
using(var compress = new GZipStream(outputFile, CompressionMode.Compress, false)) {
   byte[] b = new byte[inFile.Length];
   int read = inFile.Read(b, 0, b.Length);
   while (read > 0) {
      compress.Write(b, 0, read);
      read = inFile.Read(b, 0, b.Length);
   }
}
To decompress a file, use the same the GZipStream class. Set the following parameters: source file and the name of the output file.
From the source zip file, open a GZipStream.
using (var zip = new GZipStream(inStream, CompressionMode.Decompress, true))
To decompress, use a loop and read as long as you have data in the stream. Write it to the output stream and a file generates. The file is our decompressed file.
using(var zip = new GZipStream(inputStream, CompressionMode.Decompress, true)) {
   byte[] b = new byte[inputStream.Length];
   while (true) {
      int count = zip.Read(b, 0, b.Length);
      if (count != 0)
      outputStream.Write(b, 0, count);
      if (count != b.Length)
      break;
   }
}