code-rag-bench/online-tutorials huggingface dataset:
How to Run a Command with Time Limit (Timeout) In Linux

Sometimes a Unix command may run for a very long time without giving the final output or it make a processing giving partial output from time to time. In such scenario we will like to put a time frame within which either the command mast complete for the process should abort. This is achieved by using below options.
The Timeout tool forces a command tour abort if it cannot complete within a given time frame. Below is the syntax and example.
timeout DURATION COMMAND [ARG]...

Where Duration is the number seconds you want the command to run
Before aborting if the execution is not complete. In duration flag we have,
s - seconds
m - minutes
h - hours
d - days
In the below example we use the ping command to ping our website and the process remains on only for 5 seconds after which the command stops running automatically.
$ timeout 5s ping tutorialspoint.com
Running the above code gives us the following result −
PING tutorialspoint.com (94.130.82.52) 56(84) bytes of data.
64 bytes from tutorialspoint.com (94.130.82.52): icmp_seq=1 ttl=128 time=126 ms
64 bytes from tutorialspoint.com (94.130.82.52): icmp_seq=2 ttl=128 time=126 ms
64 bytes from tutorialspoint.com (94.130.82.52): icmp_seq=3 ttl=128 time=126 ms
64 bytes from tutorialspoint.com (94.130.82.52): icmp_seq=4 ttl=128 time=126 ms
64 bytes from tutorialspoint.com (94.130.82.52): icmp_seq=5 ttl=128 time=127 ms
The timelimit program needs to be installed, to get this feature for killing the command after a certain time. It will pass the warning signal and then after timeout, it will send the kill signal. You can also pass argumnets like - arguments like, killtime, warntime etc. So this command gives us a finer control to warn and kill the commands.
First we install the program using below command.
sudo apt-get install timelimit
Next we see the below example to use timelimit. Here –t specifies the maximum execution time of the process in seconds before sending warnsig and T is the maximum execution time of the process before sending killsig after warnsig has been sent.
timelimit -t6 -T12 ping tutorialspoint.com
Running the above code gives us the following result −
PING tutorialspoint.com (94.130.82.52) 56(84) bytes of data.
64 bytes from tutorialspoint.com (94.130.82.52): icmp_seq=1 ttl=128 time=127 ms
64 bytes from tutorialspoint.com (94.130.82.52): icmp_seq=2 ttl=128 time=126 ms
64 bytes from tutorialspoint.com (94.130.82.52): icmp_seq=3 ttl=128 time=126 ms
64 bytes from tutorialspoint.com (94.130.82.52): icmp_seq=4 ttl=128 time=127 ms
64 bytes from tutorialspoint.com (94.130.82.52): icmp_seq=5 ttl=128 time=128 ms
64 bytes from tutorialspoint.com (94.130.82.52): icmp_seq=6 ttl=128 time=126 ms
timelimit: sending warning signal 15
C# | CharEnumerator.MoveNext() Method - GeeksforGeeks

30 Apr, 2019
CharEnumerator.MoveNext() Method is used to increments the internal index of the current CharEnumerator object to the next character of the enumerated string.
Syntax:
public bool MoveNext();
Return Value: This method returns the boolean value true value if the index is successfully incremented and within the enumerated string otherwise, false.
Below are the programs to illustrate the use of CharEnumerator.MoveNext() Method:
Example 1:
// C# program to illustrate the// use of CharEnumerator.MoveNext()// Methodusing System;  class GFG {      // Driver code    public static void Main()    {        // Initialize a string object        string str = "A Computer Science Portal for Geeks!";          // Instantiate a CharEnumerator object        CharEnumerator chEnum = str.GetEnumerator();          // Printing the string        while (chEnum.MoveNext())         {            Console.Write(chEnum.Current);        }    }}
A Computer Science Portal for Geeks!

Example 2:
// C# program to illustrate the// use of CharEnumerator.MoveNext()// Methodusing System;  class GFG {      // Driver code    public static void Main()    {        // Initialize a string object        string str = "Best Data Structure and Algorithms Tutorials!";          // Instantiate a CharEnumerator object        CharEnumerator chEnum = str.GetEnumerator();          // Printing the string        while (chEnum.MoveNext())         {            if (chEnum.Current == ' ')             {                Console.WriteLine();                continue;            }            Console.Write(chEnum.Current);        }    }}
Best
Data
Structure
and
Algorithms
Tutorials!

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.charenumerator.movenext?view=netframework-4.7.2
CSharp-CharEnumerator-Class
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 50 C# Interview Questions & Answers
Extension Method in C#
HashSet in C# with Examples
C# | Inheritance
Partial Classes in C#
Convert String to Character Array in C#
Linked List Implementation in C#
C# | How to insert an element in an Array?
C# | List Class
Difference between Hashtable and Dictionary in C#
How to order by certain part of a string in MySQL?

You can use ORDER BY SUBSTRING() to order by certain part of a string in MySQL. Let us first create a table:
mysql> create table DemoTable (UserId varchar(200));
Query OK, 0 rows affected (0.68 sec)
Following is the query to insert records in the table using insert command:
mysql> insert into DemoTable values('USER_1234');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values('USER_John');
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable values('USER_Sam');
Query OK, 1 row affected (0.22 sec)
mysql> insert into DemoTable values('USER_Carol');
Query OK, 1 row affected (0.16 sec)
mysql> insert into DemoTable values('USER_Bob');
Query OK, 1 row affected (0.14 sec)
Following is the query to display records from the table using select command:
mysql> select *from DemoTable;
This will produce the following output:
+------------+
| UserId     | 
+------------+
| USER_1234  |
| USER_John  |
| USER_Sam   |
| USER_Carol |
| USER_Bob   |
+------------+
5 rows in set (0.00 sec)
Case 1: When you want to ORDER BY part of a string in ascending order.
Following is the query. Here, we will order certain part of the string after 4th character:
mysql> select *from DemoTable order by substring(UserId,4) asc;
This will produce the following output
+------------+
| UserId     |
+------------+
| USER_1234  |
| USER_Bob   |
| USER_Carol |
| USER_John  |
| USER_Sam   |
+------------+
5 rows in set (0.00 sec)
Case 2: When you want to ORDER BY part of a string in descending order. Following is the query:
mysql> select *from DemoTable order by substring(UserId,4) desc;
This will produce the following output. Here, we will order certain part of the string after 4th character:
+------------+
| UserId     |
+------------+
| USER_Sam   |
| USER_John  |
| USER_Carol |
| USER_Bob   |
| USER_1234  |
+------------+
5 rows in set (0.00 sec)
Complementation process in DFA - GeeksforGeeks

26 Jul, 2021
Prerequisite – Design a Finite automata Suppose we have a DFA that is defined by ( Q, , , q0, F ) and it accepts the language L1. Then, the DFA which accepts the language L2 where L2 = ̅L1‘, will be defined as below:  
( Q, , , q0, Q-F )
The complement of a DFA can be obtained by making the non-final states as final states and vice-versa. The language accepted by the complemented DFA L2 is the complement of the language L1. 
Example-1: L1: set of all strings over {a, b} of even length  
L1 = {, ab, aa, abaa, aaba, ....} 
L2: set of all strings over {a, b} of odd length  
L2 = { a, b, aab, aaa, bba, bbb, ...} 
Here, we can see that L2 = ̅L1 
Lets first draw the DFA for L1 that accepts the strings of even length. 
 
Now, for designing the DFA for L2, we just need to complement the above DFA. We will change the non-final states as final state and the final states as non-final states. 
 
This is our required complemented DFA. 
Example-2: L1: set of all strings over {a, b} starting with ‘a’.  
L1 ={ a, ab, aa, aba, aaa, aab, ..} 
L2: set of all strings over {a, b} not starting with ‘a’.  
L2 ={ , b, ba, bb, bab, baa, bba, ...} 
Here, we can see that L2 = ̅L1 
Lets first draw the DFA for L1 that accepts the set of all strings over {a, b} starting with ‘a’ 
 
Now, for designing the DFA for L2, we just need to complement the above DFA. We will change the non-final states as final state and the final states as non-final states. 
 
This is our required complemented DFA that accepts the strings that are not starting with ‘a’. Note: Regular languages are closed under complement (i.e Complement of regular language will also be regular). 
VaibhavRai3
simmytarika5
GATE CS
Theory of Computation & Automata
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Regular Expressions, Regular Grammar and Regular Languages
Difference between Clustered and Non-clustered index
Phases of a Compiler
Preemptive and Non-Preemptive Scheduling
Introduction of Process Synchronization
Regular Expressions, Regular Grammar and Regular Languages
Difference between DFA and NFA
Pumping Lemma in Theory of Computation
Introduction of Finite Automata
Turing Machine in TOC
Rotate In Animation Effect with CSS

To create a rotate in animation effect with CSS, you can try to run the following code −
Live Demo
<html>
   <head>
      <style>
         .animated {
            background-image: url(/css/images/logo.png);
            background-repeat: no-repeat;
            background-position: left top;
            padding-top:95px;
            margin-bottom:60px;
            -webkit-animation-duration: 10s;
            animation-duration: 10s;
            -webkit-animation-fill-mode: both;
            animation-fill-mode: both;
         }

         @-webkit-keyframes rotateIn {
            0% {
               -webkit-transform-origin: center center;
               -webkit-transform: rotate(-200deg);
               opacity: 0;
            }
            100% {
               -webkit-transform-origin: center center;
               -webkit-transform: rotate(0);
               opacity: 1;
            }
         }

         @keyframes rotateIn {
            0% {
               transform-origin: center center;
               transform: rotate(-200deg);
               opacity: 0;
            }
            100% {
               transform-origin: center center;
               transform: rotate(0);
               opacity: 1;
            }
         }

         .rotateIn {
            -webkit-animation-name: rotateIn;
            animation-name: rotateIn;
         }
      </style>

   </head>
   <body>

      <div id = "animated-example" class = "animated rotateIn"></div>
      <button onclick = "myFunction()">Reload page</button>

         <script>
            function myFunction() {
            location.reload();
         }
      </script>
   </body>
</html>
C library function - free()

The C library function void free(void *ptr) deallocates the memory previously allocated by a call to calloc, malloc, or realloc.
Following is the declaration for free() function.
void free(void *ptr)
ptr − This is the pointer to a memory block previously allocated with malloc, calloc or realloc to be deallocated. If a null pointer is passed as argument, no action occurs.
ptr − This is the pointer to a memory block previously allocated with malloc, calloc or realloc to be deallocated. If a null pointer is passed as argument, no action occurs.
This function does not return any value.
The following example shows the usage of free() function.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main () {
   char *str;

   /* Initial memory allocation */
   str = (char *) malloc(15);
   strcpy(str, "tutorialspoint");
   printf("String = %s,  Address = %u\n", str, str);

   /* Reallocating memory */
   str = (char *) realloc(str, 25);
   strcat(str, ".com");
   printf("String = %s,  Address = %u\n", str, str);

   /* Deallocate allocated memory */
   free(str);
   
   return(0);
}
Let us compile and run the above program that will produce the following result −
String = tutorialspoint, Address = 355090448
String = tutorialspoint.com, Address = 355090448


    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
Advantages of getter and setter Over Public Fields in Java with Examples - GeeksforGeeks

03 Mar, 2021
Providing getter and setter methods to access any class field in Java can at first look pointless and meaningless, simply because you can make the field public, and it is available in Java programs from anywhere. In reality, many programmers do this in the early days, but once you start thinking in terms of enterprise application or production code, you can begin to see how much maintenance trouble it can make.
Since software spends more time on maintenance than development according to the SDLC process, it is worth having ease of maintenance as one of the development goals. One of the Java coding best practices involves simply using the getter and setter approaches in Java.
Below are some advantages of getter and setter over public fields
1.  The getter and setter method gives you centralized control of how a certain field is initialized and provided to the client, which makes it much easier to verify and debug. To see which thread is accessing and what values are going out, you can easily place breakpoints or a print statement.
2. You make the class accessible with many open source libraries and modules such as display tags by making fields private by including getter and setter and following the java bean naming convention. It uses a combination of reflection and the Java bean naming convention to load and access fields dynamically.
3. You give Subclass an opportunity to override this method with getter and setter and return what makes more sense in the context of the subclass.
4. Hiding the property’s internal representation by using an alternative representation to expose a property.
5. Allowing inheritors to change the semantics of how the property behaves and is exposed by overriding the getter/setter methods.
Java
class Person {    // private = restricted access    private String name;      // Getter    public String getName() { return name; }      // Setter    public void setName(String newName)    {        this.name = newName;    }}  class Main {    public static void main(String[] args)    {        Person person = new Person();        // Set the value of the name variable to "kapil"        person.setName("kapil");        System.out.println(person.getName());    }}
kapil

Java-Field
Picked
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Functional Interfaces in Java
Stream In Java
Constructors in Java
Different ways of Reading a text file in Java
Exceptions in Java
Generics in Java
Comparator Interface in Java with Examples
Strings in Java
How to remove an element from ArrayList in Java?
Difference between Abstract Class and Interface in Java
How to delete the Azure Resource Group using PowerShell?

To delete the azure resource group using PowerShell, we need to use the Remove-AZResourceGroup command. But before using this command, make sure that no usable resources exist in the resource group that you want to delete.
To check if the resources are available in the resource group, use the below command. Here we are using the TestRG resource group name.
Get-AzResource -ResourceGroupName TestRG
Once you are confirmed that you need to delete the Resource Group then use the below command to delete the resource group.
Remove-AzResourceGroup TestRG -Force -Verbose
When you use the -Force parameter, you won’t be prompted for deletion confirmation.
Search in Rotated Sorted Array II in C++

Consider we have an array sorted in ascending order. That is rotated at some pivot unknown to us beforehand. For example, if the array is like [0,0,1,2,2,5,6], this might become [2,5,6,0,0,1,2]. We have a target value to search. If that is found in the array, then return true, otherwise return false. So if the array is like [2,5,6,0,0,1,2], and target is 0, then the output will be 0
Let us see the steps −
low := 0 and high := size of array
low := 0 and high := size of array
while low < highmid := low + (high - low)/2if nums[mid] = target, then return trueif nums[low] = nums[mid] and nums[high - 1] = nums[mid], thenincrease low by 1 and decrease high by 1, and continue for the next iterationif nums[low] <= nums[mid], thenif target >= nums[low] and target < nums[mid], then high := mid, otherwise low := mid + 1Otherwiseif target <= nums[high - 1] and target > nums[mid], then low := mid + 1, otherwise high := midreturn false
while low < high
mid := low + (high - low)/2
mid := low + (high - low)/2
if nums[mid] = target, then return true
if nums[mid] = target, then return true
if nums[low] = nums[mid] and nums[high - 1] = nums[mid], thenincrease low by 1 and decrease high by 1, and continue for the next iteration
if nums[low] = nums[mid] and nums[high - 1] = nums[mid], then
increase low by 1 and decrease high by 1, and continue for the next iteration
increase low by 1 and decrease high by 1, and continue for the next iteration
if nums[low] <= nums[mid], thenif target >= nums[low] and target < nums[mid], then high := mid, otherwise low := mid + 1
if nums[low] <= nums[mid], then
if target >= nums[low] and target < nums[mid], then high := mid, otherwise low := mid + 1
if target >= nums[low] and target < nums[mid], then high := mid, otherwise low := mid + 1
Otherwiseif target <= nums[high - 1] and target > nums[mid], then low := mid + 1, otherwise high := mid
Otherwise
if target <= nums[high - 1] and target > nums[mid], then low := mid + 1, otherwise high := mid
if target <= nums[high - 1] and target > nums[mid], then low := mid + 1, otherwise high := mid
return false
return false
Let us see the following implementation to get better understanding −
class Solution(object):
   def search(self, nums, target):
      """
      :type nums: List[int]
      :type target: int
      :rtype: int
      """
      low = 0
      high = len(nums)
      while low<high:
         mid = low + (high-low)//2
         print(mid)
      if nums[mid] == target:
         return True
      if nums[low] == nums[mid] and nums[high-1] == nums[mid]:
         low +=1
         high -=1
         continue
      if nums[low]<=nums[mid]:
         if target >=nums[low] and target <nums[mid]:
            high = mid
         else:
            low = mid+1
      else:
         if target<=nums[high-1] and target>nums[mid]:
            low = mid+1
      else:
         high = mid
   return False
[2,5,6,0,0,1,2]
0
true
Machine Learning with Python - Histograms

Histograms group the data in bins and is the fastest way to get idea about the distribution of each attribute in dataset. The following are some of the characteristics of histograms −
It provides us a count of the number of observations in each bin created for visualization.
It provides us a count of the number of observations in each bin created for visualization.
From the shape of the bin, we can easily observe the distribution i.e. weather it is Gaussian, skewed or exponential.
From the shape of the bin, we can easily observe the distribution i.e. weather it is Gaussian, skewed or exponential.
Histograms also help us to see possible outliers.
Histograms also help us to see possible outliers.
The code shown below is an example of Python script creating the histogram of the attributes of Pima Indian Diabetes dataset. Here, we will be using hist() function on Pandas DataFrame to generate histograms and matplotlib for ploting them.
from matplotlib import pyplot
from pandas import read_csv
path = r"C:\pima-indians-diabetes.csv"
names = ['preg', 'plas', 'pres', 'skin', 'test', 'mass', 'pedi', 'age', 'class']
data = read_csv(path, names=names)
data.hist()
pyplot.show()
The above output shows that it created the histogram for each attribute in the dataset. From this, we can observe that perhaps age, pedi and test attribute may have exponential distribution while mass and plas have Gaussian distribution.

    168 Lectures 
     13.5 hours 

 Er. Himanshu Vasishta

    64 Lectures 
     10.5 hours 

 Eduonix Learning Solutions

    91 Lectures 
     10 hours 

 Abhilash Nelson

    54 Lectures 
     6 hours 

 Abhishek And Pukhraj

    49 Lectures 
     5 hours 

 Abhishek And Pukhraj

    35 Lectures 
     4 hours 

 Abhishek And Pukhraj
 Print
 Add Notes
 Bookmark this page
Python Comments

Comments can be used to explain Python code.
Comments can be used to make the code more readable.
Comments can be used to prevent execution when testing code.
Comments starts with a #, and Python will 
ignore them:
Comments can be placed at the end of a line, and Python will ignore the rest 
of the line:
A comment does not have to be text that explains the code, it can also be used to 
prevent Python from executing code:
Python does not really have a syntax for multi line comments.
To add a multiline comment you could insert a # for each line:
Or, not quite as intended, you can use a multiline string.
Since Python will ignore string literals that are not assigned to a variable, you can add a multiline string (triple quotes) in your code, and place your comment inside it:
As long as the string is not assigned to a variable, Python will read the code, but then ignore it, and you have made a multiline comment.
Comments in Python are written with a special character, which one?
This is a comment

Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
C++ Program to Check whether Graph is a Bipartite using BFS

A bipartite graph is a graph in which if the graph coloring is possible using two colors i.e; vertices in a set are colored with the same color. This is a C++ program to Check whether a graph bipartite or not using BFS.
Begin
   Function Bipartite():
   1) Assign a color to the source vertex
   2) Color all the neighbors with another color except first one color.
   3) Color all neighbor’s neighbor with First color.
   4) Like this way, assign color to all vertices such that it satisfies all the constraints of k way coloring problem where k = 2.
   5) While assigning colors, if we find a neighbor which is colored with same color as current vertex, then the graph cannot be colored with 2 vertices i.e.; graph is not Bipartite
End
#include <iostream>
#include <queue>
#define V 5
using namespace std;
bool Bipartite(int G[][V], int s) {
   int colorA[V];
   for (int i = 0; i < V; ++i)
   colorA[i] = -1;
   colorA[s] = 1; //Assign a color to the source vertex
   queue <int> q; //Create a queue of vertex numbers and enqueue source vertex for BFS traversal
   q.push(s);
   while (!q.empty()) {
      int w = q.front(); //dequeue a vertex
      q.pop();
      for (int v = 0; v < V; ++v) //Find all non-colored adjacent vertices {
         if (G[w][v] && colorA[v] == -1) //An edge from w to v exists and destination v is not colored {
            colorA[v] = 1 - colorA[w]; //Assign alternate color to this adjacent v of w
            q.push(v);
         } else if (G[w][v] && colorA[v] == colorA[w]) //An edge from w to v exists and destination
            //v is colored with same color as u
            return false;
      }
   }
   return true; //if all adjacent vertices can be colored with alternate color
}
int main() {
   int G[][V] = {{ 0, 1, 0, 0},
                { 1, 0, 0, 0},
                { 0, 0, 0, 1},
                { 1, 0, 1, 0}};
   if (Bipartite(G, 0))
      cout << "The Graph is Bipartite"<<endl;
   else
      cout << "The Graph is Not Bipartite"<<endl;
   return 0;
}
The Graph is Bipartite
Generate a list of Primes less than n in Python

Suppose we have a number n, we have to generate a list of all prime numbers smaller than or
equal to n in ascending order. We have to keep in mind that 1 is not a prime number.
So, if the input is like 12, then the output will be [2, 3, 5, 7, 11].
To solve this, we will follow these steps −
sieve := a list of size n+1 and fill with True
primes := a new list, initially blank
for i in range 2 to n, doif sieve[i] is True, theninsert i at the end of primesfor j in range i to n, update in each step by i, dosieve[j] := False
if sieve[i] is True, theninsert i at the end of primesfor j in range i to n, update in each step by i, dosieve[j] := False
insert i at the end of primes
for j in range i to n, update in each step by i, dosieve[j] := False
sieve[j] := False
return primes
Let us see the following implementation to get better understanding −
 Live Demo
class Solution:
   def solve(self, n):
      sieve = [True] * (n + 1)
      primes = []
      for i in range(2, n + 1):
         if sieve[i]:
            primes.append(i)
            for j in range(i, n + 1, i):
               sieve[j] = False
      return primes
ob = Solution()
print(ob.solve(12))
12
[2, 3, 5, 7, 11]
GATE | GATE-CS-2015 (Set 1) | Question 65 - GeeksforGeeks

19 Nov, 2018
For computers based on three-address instruction formats, each address field can be used to specify which of the following:
S1: A memory operand
S2: A processor register
S3: An implied accumulator register
(A) Either S1 or S2(B) Either S2 or S3(C) Only S2 and S3(D) All of S1, S2 and S3Answer: (A)Explanation: In Three address instruction format, each operand specifies either a memory address or a register. See
http://homepage.cs.uiowa.edu/~ghosh/1-19-06.pdfQuiz of this Question
GATE-CS-2015 (Set 1)
GATE-GATE-CS-2015 (Set 1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE-CS-2006 | Question 47
GATE | GATE MOCK 2017 | Question 24
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
String Interpolation in Angular 8 - GeeksforGeeks

31 Aug, 2020
String Interpolation in Angular 8 is a one-way data-binding technique that is used to transfer the data from a TypeScript code to an HTML template (view). It uses the template expression in double curly braces to display the data from the component to the view. String interpolation adds the value of a property from the component to the HTML template view.
Syntax:
{{ component_property }}

Approach: 
Define a property in the app.component.ts file containing some string value.
In the app.component.html file, bind the value of that property by calling the property name in double curly braces {{ property_name }}.
Example 1: 
app.component.htmlHTMLHTML<h1>  {{ title }}</h1>
app.component.html
HTML
<h1>  {{ title }}</h1>
app.component.tsJavascriptJavascriptimport { Component } from '@angular/core';    @Component({      selector: 'app-root',      templateUrl: './app.component.html',      styleUrls: ['./app.component.css']    })    export class AppComponent {     title = "GeeksforGeeks";}
app.component.ts
Javascript
import { Component } from '@angular/core';    @Component({      selector: 'app-root',      templateUrl: './app.component.html',      styleUrls: ['./app.component.css']    })    export class AppComponent {     title = "GeeksforGeeks";}
Output:
Example 2:
app.component.htmlHTMLHTML<h1 [style.color] = "'green'"     [style.text-align] = "'center'" >    {{ title }} : {{ about }}</h1>
app.component.html
HTML
<h1 [style.color] = "'green'"     [style.text-align] = "'center'" >    {{ title }} : {{ about }}</h1>
app.component.tsJavascriptJavascriptimport { Component } from '@angular/core';    @Component({      selector: 'app-root',      templateUrl: './app.component.html',      styleUrls: ['./app.component.css']    })    export class AppComponent {     title = "GeeksforGeeks";  about = "Computer Science Portal for Geeks";}
app.component.ts
Javascript
import { Component } from '@angular/core';    @Component({      selector: 'app-root',      templateUrl: './app.component.html',      styleUrls: ['./app.component.css']    })    export class AppComponent {     title = "GeeksforGeeks";  about = "Computer Science Portal for Geeks";}
Output:
AngularJS-Misc
Picked
AngularJS
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Angular PrimeNG Dropdown Component
Auth Guards in Angular 9/10/11
Angular PrimeNG Calendar Component
Angular PrimeNG Messages Component
How to bundle an Angular app for production?
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
How to calculate the number of days between two dates in javascript?
File uploading in React.js
Python PostgreSQL - Introduction

PostgreSQL is a powerful, open source object-relational database system. It has more than 15 years of active development phase and a proven architecture that has earned it a strong reputation for reliability, data integrity, and correctness.
To communicate with PostgreSQL using Python you need to install psycopg, an adapter provided for python programming, the current version of this is psycog2.
psycopg2 was written with the aim of being very small and fast, and stable as a rock. It is available under PIP (package manager of python)
First of all, make sure python and PIP is installed in your system properly and, PIP is up-to-date.
To upgrade PIP, open command prompt and execute the following command −
C:\Users\Tutorialspoint>python -m pip install --upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/8d/07/f7d7ced2f97ca3098c16565efbe6b15fafcba53e8d9bdb431e09140514b0/pip-19.2.2-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 19.0.3
Uninstalling pip-19.0.3:
Successfully uninstalled pip-19.0.3
Successfully installed pip-19.2.2

Then, open command prompt in admin mode and execute the pip install psycopg2-binary command as shown below −
C:\WINDOWS\system32>pip install psycopg2-binary
Collecting psycopg2-binary
Using cached https://files.pythonhosted.org/packages/80/79/d0d13ce4c2f1addf4786f4a2ded802c2df66ddf3c1b1a982ed8d4cb9fc6d/psycopg2_binary-2.8.3-cp37-cp37m-win32.whl
Installing collected packages: psycopg2-binary
Successfully installed psycopg2-binary-2.8.3

To verify the installation, create a sample python script with the following line in it.
import mysql.connector

If the installation is successful, when you execute it, you should not get any errors −
D:\Python_PostgreSQL>import psycopg2
D:\Python_PostgreSQL>


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Kubernetes - Network Policy

Network Policy defines how the pods in the same namespace will communicate with each other and the network endpoint. It requires extensions/v1beta1/networkpolicies to be enabled in the runtime configuration in the API server. Its resources use labels to select the pods and define rules to allow traffic to a specific pod in addition to which is defined in the namespace.
First, we need to configure Namespace Isolation Policy. Basically, this kind of networking policies are required on the load balancers.
kind: Namespace
apiVersion: v1
metadata:
   annotations:
      net.beta.kubernetes.io/network-policy: |
      {
         "ingress": 
         {
            "isolation": "DefaultDeny"
         }
      }

$ kubectl annotate ns <namespace> "net.beta.kubernetes.io/network-policy = 
{\"ingress\": {\"isolation\": \"DefaultDeny\"}}"

Once the namespace is created, we need to create the Network Policy.
kind: NetworkPolicy
apiVersion: extensions/v1beta1
metadata:
   name: allow-frontend
   namespace: myns
spec:
   podSelector:
      matchLabels:
         role: backend
   ingress:
   - from:
      - podSelector:
         matchLabels:
            role: frontend
   ports:
      - protocol: TCP
         port: 6379


    41 Lectures 
     5 hours 

 AR Shankar

    15 Lectures 
     2 hours 

 Harshit Srivastava, Pranjal Srivastava

    18 Lectures 
     1.5 hours 

 Nigel Poulton

    25 Lectures 
     1.5 hours 

 Pranjal Srivastava

    18 Lectures 
     1 hours 

 Pranjal Srivastava

    26 Lectures 
     1.5 hours 

 Pranjal Srivastava
 Print
 Add Notes
 Bookmark this page
C Program for KMP Algorithm for Pattern Searching

In this problem, we are given two strings a text and a pattern. Our task is to create a program for KMP algorithm for pattern search, it will find all the occurrences of pattern in text string.
Here, we have to find all the occurrences of patterns in the text.
Let’s take an example to understand the problem,
text = “xyztrwqxyzfg” pattern = “xyz”
Found at index 0
Found at index 7
Here, we will discuss the solution to the problem using KMP (Knuth Morris Pratt) pattern searching algorithm, it will use a preprocessing string of the pattern which will be used for matching in the text. And help’s in processing or finding pattern matches in the case where matching characters are followed by the character of the string that does not match the pattern.
We will preprocess the pattern wand to create an array that contains the proper prefix and suffix from the pattern that will help in finding the mismatch patterns.
// C Program for KMP Algorithm for Pattern Searching
 Live Demo
#include<iostream>
#include<string.h>
using namespace std;
void prefixSuffixArray(char* pat, int M, int* pps) {
   int length = 0;
   pps[0] = 0;
   int i = 1;
   while (i < M) {
      if (pat[i] == pat[length]) {
         length++;
         pps[i] = length;
         i++;
      } else {
         if (length != 0)
         length = pps[length - 1];
         else {
            pps[i] = 0;
            i++;
         }
      }
   }
}
void KMPAlgorithm(char* text, char* pattern) {
   int M = strlen(pattern);
   int N = strlen(text);
   int pps[M];
   prefixSuffixArray(pattern, M, pps);
   int i = 0;
   int j = 0;
   while (i < N) {
      if (pattern[j] == text[i]) {
         j++;
         i++;
      }
      if (j == M) {
         printf("Found pattern at index %d\n", i - j);
         j = pps[j - 1];
      }
      else if (i < N && pattern[j] != text[i]) {
         if (j != 0)
         j = pps[j - 1];
         else
         i = i + 1;
      }
   }
}
int main() {
   char text[] = "xyztrwqxyzfg";
   char pattern[] = "xyz";
   printf("The pattern is found in the text at the following index : \n");
   KMPAlgorithm(text, pattern);
   return 0;
}
The pattern is found in the text at the following index −
Found pattern at index 0
Found pattern at index 7
How to handle a link click event using jQuery?

To handle a click event using jQuery, use the click() method. You can try to run the following code to handle a link click event using jQuery −
Live Demo
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
 $(document).ready(function(){
    $("a").click(function(){
        alert("You've clicked the link.");
    });
 });
</script>
</head>
<body>

<p>Click below link.</p>
<a href="#">Click</a>

</body>
</html>
How to scroll to element with Selenium WebDriver using C#?

We can scroll to an element with Selenium webdriver in C#. This is done with the help of JavaScript Executor. Selenium can run JavaScript commands with the help of ExecuteScript method.
The method scrollIntoView in JavaScript is used to perform the scrolling action and the value true is passed as a parameter to the method. This is then passed to the ExecuteScript method.
var e = driver.FindElement(By.XPath("//*[text()='Careers']"));
((IJavaScriptExecutor)driver)
.ExecuteScript("arguments[0].scrollIntoView(true);", e);
For implementation we shall be using the NUnit framework.
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using System;
namespace NUnitTestProject1{
   public class Tests{
      String u = "https://www.tutorialspoint.com/index.htm";
      IWebDriver d;
      [SetUp]
      public void Setup(){
         //creating object of FirefoxDriver
         d = new FirefoxDriver();
      }
      [Test]
      public void Test1(){
         //launching URL
         d.Navigate().GoToUrl(u);
         //identify element
         var e = d.FindElement(By.XPath("//*[text()='Careers']"));
         // JavaScript Executor to scroll to element
         ((IJavaScriptExecutor)d)
         .ExecuteScript("arguments[0].scrollIntoView(true);", e);
         Console.WriteLine(e.Text);
      }
      [TearDown]
      public void close_Browser(){
         d.Quit();
      }
   }
}
Click on Run All Tests button −
Click on Open additional output for this result link −
We should get the Test Outcome and Standard Output.
How to check if String is Palindrome using C#?

Let’s say we need to find that the following string is Palindrome or not −
str = "Level";
For that, convert the string into character array to chec each character −
char[] ch = str.ToCharArray();
Now find the reverse −
Array.Reverse(ch);
Use the Equals method to find whether the reverse is equal to original array or not −
bool res = str.Equals(rev, StringComparison.OrdinalIgnoreCase);
The following is the complete code −
 Live Demo
using System;
namespace Demo {
   class Program {
      static void Main(string[] args) {

         string str, rev;
         str = "Level";
         char[] ch = str.ToCharArray();
         Array.Reverse(ch);
         rev = new string(ch);
         bool res = str.Equals(rev, StringComparison.OrdinalIgnoreCase);
     
         if (res == true) {
            Console.WriteLine("String " + str + " is a Palindrome!");
         } else {
            Console.WriteLine("String " + str + " is not a Palindrome!");
         }
         Console.Read();
      }
   }
}
String Level is a Palindrome!
How to read a .txt file with RandomAccessFile in Java?

In general, while reading or writing data to a file, you can only read or, write data from the start of the file. you cannot read/write from random position.
The java.io.RandomAccessFile class in Java enables you to read/write data to a random access file.
This acts similar to a large array of bytes with an index or, cursor known as file pointer you can get the position of this pointer using the getFilePointer() method and set it using the seek() method.
This class provides various methods to read and write data to a file. The readLine() method of this class reads the next line from the file and returns it in the form as String.
To read data from a file using the readLine() method of this class −
Instantiate the File class by passing the path of the required file in String format.
Instantiate the File class by passing the path of the required file in String format.
Instantiate the StringBuffer class.
Instantiate the StringBuffer class.
Instantiate the RandomAccessFile class by passing the above created File object and a String representing mode of access (r:read, rw:read/write etc..)
Instantiate the RandomAccessFile class by passing the above created File object and a String representing mode of access (r:read, rw:read/write etc..)
iterate through the file while its position is less than its length (length() method).
iterate through the file while its position is less than its length (length() method).
Append each line to the StringBuffer object created above.
Append each line to the StringBuffer object created above.
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
public class RandomAccessFileExample {
   public static void main(String args[]) throws IOException {
      String filePath = "D://input.txt";
      //Instantiating the File class
      File file = new File(filePath);
      //Instantiating the StringBuffer
      StringBuffer buffer = new StringBuffer();
      //instantiating the RandomAccessFile
      RandomAccessFile raFile = new RandomAccessFile(file, "rw");
      //Reading each line using the readLine() method
      while(raFile.getFilePointer() < raFile.length()) {
         buffer.append(raFile.readLine()+System.lineSeparator());
      }
      String contents = buffer.toString();
      System.out.println("Contents of the file: \n"+contents);
   }
}
Contents of the file:
Tutorials Point originated from the idea that there exists a class of readers who respond better 
to online content and prefer to learn new skills.
Our content and resources are freely available and we prefer to keep it that way to encourage 
our readers acquire as many skills as they would like to.
We don’t force our readers to sign up with us or submit their details either.
Enjoy the free content
Python program to print all the numbers divisible by 3 and 5 for a given number

This is a python program to print all the numbers which are divisible by 3 and 5 from a given interger N. There are numerous ways we can write this program except that we need to check if the number is fully divisble by both 3 and 5.
Below is my code to write a python program to print all the numbers divisible by 3 and 5 −
lower = int(input("Enter lower range limit:"))
upper = int(input("Enter upper range limit:"))
for i in range(lower, upper+1):
   if((i%3==0) & (i%5==0)):
      print(i)
Enter lower range limit:0
Enter upper range limit:99
0
15
30
45
60
75
90
Above we try to print all the numbers between 0 and 99 which are divisble by 3 and 5. Same program can be used to print all the number between 0 and 1000 which are divisible by 3 and 5, we just need to alter our range and our output will be something like,
Enter lower range limit:0
Enter upper range limit:1000
0
15
30
45
60
75
90
105
120
135
150
165
180
195
....
....
915
930
945
960
975
990
In case we want to write a program which will print all the numbers in a range divisible by a given number not the fixed number like above, i just need to update by
program like,
#Incase we want to print all number between a range divided by any given number
n = int(input("Enter the number to be divided by:"))
for i in range(lower, upper+1):
   if(i%n==0):
      print(i)
Below the steps to write above code −
Take the lower and upper limit .i.e. the range from the user.
Take the lower and upper limit .i.e. the range from the user.
Take the number to be divided by from the user. In case of our main problem, because we know that numbers(3 and 5), i write the 3 and 5 in the if statement only.
Take the number to be divided by from the user. In case of our main problem, because we know that numbers(3 and 5), i write the 3 and 5 in the if statement only.
Using a loop with &(and) operator statement(so that it print only those numbers which are divisble by both 3 & 5), prints all the factors which is divisible by the number.
Using a loop with &(and) operator statement(so that it print only those numbers which are divisble by both 3 & 5), prints all the factors which is divisible by the number.
Exit.
Exit.
How to disable landscape mode in Android?

Android supports two orientations as portrait and landscape. we can disable orientation in android application. This example demonstrate
about how to disable landscape mode 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"
   tools:context = ".MainActivity"
   android:background = "#dde4dd">
   <EditText
      android:id = "@+id/editText"
      android:layout_width = "match_parent"
      android:layout_height = "wrap_content" />
</LinearLayout>
In the above code, it contains linear layout and editext. it going to support both landscape and portrait as shown below -
The above output indicates about landscape mode
The above output indicates about portrait mode.
To disable landscape mode need to add screenOrientation tag in manifest.xml as shown below -
<?xml version = "1.0" encoding = "utf-8"?>
<manifest xmlns:android = "http://schemas.android.com/apk/res/android" package = "com.example.andy.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"
         android:screenOrientation = "portrait">
         <intent-filter>
            <action android:name = "android.intent.action.MAIN" />
            <category android:name = "android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
In the above code we have given screenOrientation as portrait means MainActivity going to support only portrait mode only . If you want to develop an application in portrait mode, add screenOrientation inside application tag.
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
In the above result it is showing only portrait mode. now turn your device it not going to change the view according to orientation.
How to create a tar file using Python?

Use the tarfile module to create a zip archive of a directory. Walk the directory tree using os.walk and add all the files in it recursively.
import os
import tarfile
def tardir(path, tar_name):
    with tarfile.open(tar_name, "w:gz") as tar_handle:
        for root, dirs, files in os.walk(path):
            for file in files:
                tar_handle.add(os.path.join(root, file))
tardir('./my_folder', 'sample.tar.gz')
tar.close()
The above code will compress the contents of my_folder in a file 'sample.tar.gz'. and store it in the current directory.
Tryit Editor v3.7

Tryit: Using the clip property