code-rag-bench/online-tutorials huggingface dataset:
jQuery | contains() Method

14 May, 2020
This contains() method in jQuery is used to check whether a DOM element is a descendant of another DOM element or not.
Syntax:
jQuery.contains( container, contained )

Parameters: This method accepts two parameters as mentioned above and described below:
container: This parameter holds the DOM element that may contain the other element.
contained: This parameter holds the DOM element that may be contained by (a descendant of) the other element.
Return Value: It returns the boolean value.
Below examples illustrate the use of jQuery.contains() method:
Example 1:
<!DOCTYPE html><html>  <head>    <meta charset="utf-8">    <title>JQuery | contains() method</title>      <script src=        "https://code.jquery.com/jquery-3.4.1.js">    </script></head>  <body style="text-align:center;">      <h1 style="color: green">        GeeksForGeeks    </h1>      <h3>JQuery | contains() method</h3>      <b id="gfg"></b>      <script>        $("#gfg").append(            "Is 'document.documentElement' in 'document.body'? <br>"            + $.contains(document.documentElement, document.body));      </script></body>  </html>
Output:
Example 2:
<!DOCTYPE html><html>  <head>    <meta charset="utf-8">    <title>JQuery | contains() method</title>      <script src=        "https://code.jquery.com/jquery-3.4.1.js">    </script>  </head>  <body style="text-align:center;">      <h1 style="color: green">        GeeksForGeeks    </h1>      <h3>JQuery | contains() method</h3>      <b id="gfg"></b>      <script>        $("#gfg").append(            "Is 'document.body' in 'document.documentElement'? <br>"            + $.contains(document.body, document.documentElement));    </script></body>  </html>
Output:
jQuery-Methods
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Reverse a String in Golang?

04 May, 2020
Given a string and the task is to reverse the string. Here are a few examples.
Approach 1: Reverse the string by swapping the letters, like first with last and second with second last and so on.
Example:
// Golang program to reverse a stringpackage main  // importing fmtimport "fmt"  // function, which takes a string as// argument and return the reverse of string.func reverse(s string) string {    rns := []rune(s) // convert to rune    for i, j := 0, len(rns)-1; i < j; i, j = i+1, j-1 {          // swap the letters of the string,        // like first with last and so on.        rns[i], rns[j] = rns[j], rns[i]    }      // return the reversed string.    return string(rns)}  func main() {      // Reversing the string.    str := "Geeks"      // returns the reversed string.    strRev := reverse(str)    fmt.Println(str)    fmt.Println(strRev)}
Output:
Geeks
skeeG

Approach 2: This example declares an empty string and then start appending the characters from the end, one by one.
Example:
// Golang program to reverse a stringpackage main  // importing fmtimport "fmt"  // function, which takes a string as// argument and return the reverse of string.func reverse(str string) (result string) {    for _, v := range str {        result = string(v) + result    }    return}  func main() {      // Reversing the string.    str := "Geeks"      // returns the reversed string.    strRev := reverse(str)    fmt.Println(str)    fmt.Println(strRev)}
Output:
Geeks
skeeG

Golang-Program
Golang-String
Picked
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Timer cancel() method in Java with Examples

29 May, 2019
The cancel() method of Timer class is used to terminate this timer and remove any currently scheduled tasks.
Syntax:
public void cancel()

Parameters: The function does not accepts any parameter.
Return Value: The method has no return value.
Exception: The function does not throws any exception.
Program below demonstrates the above mentioned function:
Program 1:
// program to demonstrate the// function java.util.Timer.cancel()  import java.util.*;public class GFG {    public static void main(String[] args)    {          // creating timertask, timer        Timer timer = new Timer();        TimerTask tt = new TimerTask() {              public void run()            {                for (int i = 1; i <= 15; i++) {                    System.out.println("working on the task");                    if (i >= 7) {                        System.out.println("stop the task");                        // loop stops after 7 iterations                        timer.cancel();                        break;                    }                }            };        };        timer.schedule(tt, 1000, 1000);    }}
working on the task
working on the task
working on the task
working on the task
working on the task
working on the task
working on the task
stop the task

Program 2:
// program to demonstrate the// function java.util.Timer.cancel()  import java.util.*;public class GFG {    public static void main(String[] args)    {          // creating timertask, timer        Timer timer = new Timer();        TimerTask tt = new TimerTask() {              public void run()            {                for (int i = 1; i <= 15; i++) {                    System.out.println("working on the task");                    if (i >= 7) {                        System.out.println("stop the task");                        // loop stops after 7 iterations                        timer.cancel();                    }                }            };        };        timer.schedule(tt, 1000, 1000);    }}
working on the task
working on the task
working on the task
working on the task
working on the task
working on the task
working on the task
stop the task
working on the task
stop the task
working on the task
stop the task
working on the task
stop the task
working on the task
stop the task
working on the task
stop the task
working on the task
stop the task
working on the task
stop the task
working on the task
stop the task

Java - util package
Java-Functions
Java-Timer
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Introduction to Java
Constructors in Java
Exceptions in Java
Generics in Java
Functional Interfaces in Java
Strings in Java
Java Programming Examples
HashSet in Java
Abstraction in Java
How to find common elements between two Arrays using STL in C++?

26 Apr, 2019
Given two arrays, find common elements between these two arrays using STL in C++.
Example:
Input: 
arr1[] = {1, 45, 54, 71, 76, 12}, 
arr2[] = {1, 7, 5, 4, 6, 12}
Output: {1, 12}

Input: 
arr1[] = {1, 7, 5, 4, 6, 12}, 
arr2[] = {10, 12, 11}
Output: {1, 4, 12}

Approach: Common elements can be found with the help of set_intersection() function provided in STL.
Syntax:
set_intersection (InputIterator1 first1, InputIterator1 last1,
           InputIterator2 first2, InputIterator2 last2,
           OutputIterator result);

// C++ program to find common elements// between two Arrays using STL  #include <bits/stdc++.h>using namespace std;  int main(){      // Get the array    int arr1[] = { 1, 45, 54, 71, 76, 12 };    int arr2[] = { 1, 7, 5, 4, 6, 12 };      // Compute the sizes    int n1 = sizeof(arr1) / sizeof(arr1[0]);    int n2 = sizeof(arr2) / sizeof(arr2[0]);      // Sort the arrays    sort(arr1, arr1 + n1);    sort(arr2, arr2 + n2);      // Print the array    cout << "First Array: ";    for (int i = 0; i < n1; i++)        cout << arr1[i] << " ";    cout << endl;      cout << "Second Array: ";    for (int i = 0; i < n2; i++)        cout << arr2[i] << " ";    cout << endl;      // Initialise a vector    // to store the common values    // and an iterator    // to traverse this vector    vector<int> v(n1 + n2);    vector<int>::iterator it, st;      it = set_intersection(arr1, arr1 + n1,                          arr2, arr2 + n2,                          v.begin());      cout << "\nCommon elements:\n";    for (st = v.begin(); st != it; ++st)        cout << *st << ", ";    cout << '\n';      return 0;}
First Array: 1 12 45 54 71 76 
Second Array: 1 4 5 6 7 12 

Common elements:
1, 12,

shubham_singh
cpp-array
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
lsblk Command in Linux with Examples

27 Sep, 2021
Lsblk is used to display details about block devices and these block devices(Except ram disk) are basically those files that represent devices connected to the pc. It queries /sys virtual file system and udev db to obtain information that it displays. And it basically displays output in a tree-like structure. This command comes pre-installed with the util-Linux package. 
Many Linux distributions do not have lsblk command pre-installed. To install it use the following commands as per your Linux distribution. 
In case of Debian/Ubuntu  
$sudo apt-get install util-linux
In case of CentOS/RedHat  
$sudo yum install util-linux-ng
In case of Fedora OS  
$sudo yum install util-linux-ng
1. To display block devices. 
$lsblk 
It displays the list of block devices on your system. 
2. To display empty block devices as well.  
#lsblk -a 
This will display all block devices along with empty ones. 
3. To print size information in bytes. 
$lsblk -b
It displays all the block devices along with their sizes in bytes. 
4. To print zone model for devices.  
$lsblk -z 
5. To skip slave entries.  
$lsblk -d 
This will skip all the slave entries. 
6.To use ASCII characters for tree formatting.  
$lsblk -i 
This will display the tree formatting with ASCII character values. 
7. To print information about device owner, group, and mode of block devices.  
$lsblk -m 
This will display all details of device owner, group and mode of block devices. 
8. To print selected columns of block-devices. 
$lsblk -o SIZE, NAME, MOUNTPOINT 
This will print only the specified columns. 
9. To hide column headings.  
$lsblk -dn
This will hide column headings. 
10. To display help section of the command.  
$lsblk --help 
This will display the help section of the command. 
simmytarika5
linux-command
Linux-system-commands
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Microsoft Azure – Check Resource Owner in Azure using KQL

29 Dec, 2021
In this article, we will see how we can find the creation date of resources by using the Kusto Query Language. Azure KQL Queries helps in finding the resource creation date, time, created user email,...etc.
Note: You cannot retrieve log data if it is more than 90 days using KQL. In this case store log data to a storage account to fetch the logs for beyond 90 days.
Prerequisites:
Log Analytics Workspace
Diagnostic Logs should be enabled for subscription and log analytics.
1. Find who created a specific resource in a specific resource group with Activity Status Succeeded.
AzureActivity
| where ResourceGroup == "Add_Resource_Group_Name" and Resource == "Add_Resource_Type"
| where ActivityStatus == "Succeeded" 
| project ResourceGroup, Resource, CreatedBy = Caller, CreationTime = TimeGenerated
This query returns the name of the resource group, resource name, caller (one who created), and creation time.
Sample Output:
 2. To find who created a specific resource in a specific resource group with Activity Status Succeeded by specific user email id use the below KQL query:
AzureActivity
| where ResourceGroup == "Add_Resource_Group_Name" and Resource == "Add_Resource_Type"
| where ActivityStatus == "Succeeded" 
| project ResourceGroup, Resource, CreatedBy = Caller, CreationTime = TimeGenerated
| where CreatedBy == "UserName@domain.com" 
This query returns the name of the resource group, resource name, the caller (specific user), and creation time.
Sample Output:
3. To find all the resources created with the service principal use the below query:
AzureActivity
| where ResourceGroup != "" and Resource != ""
| where ActivityStatus == "Succeeded" 
| where Caller !has "@" 
| project ResourceGroup, Resource, CreatedBy = Caller, CreationTime = TimeGenerated
This query returns the name of resource group, resource name, caller (puts service principal name) and creation time.
Sample Output:
Cloud-Computing
Microsoft Azure
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Program for Coin Change

22 Jun, 2022
Given a value N, if we want to make change for N cents, and we have infinite supply of each of S = { S1, S2, .. , Sm} valued coins, how many ways can we make the change? The order of coins doesn\’t matter. For example, for N = 4 and S = {1,2,3}, there are four solutions: {1,1,1,1},{1,1,2},{2,2},{1,3}. So output should be 4. For N = 10 and S = {2, 5, 3, 6}, there are five solutions: {2,2,2,2,2}, {2,2,3,3}, {2,2,6}, {2,3,5} and {5,5}. So the output should be 5. 
Python3
# Dynamic Programming Python implementation of Coin# Change problemdef count(S, m, n):    # We need n+1 rows as the table is constructed    # in bottom up manner using the base case 0 value    # case (n = 0)    table = [[0 for x in range(m)] for x in range(n+1)]     # Fill the entries for 0 value case (n = 0)    for i in range(m):        table[0][i] = 1     # Fill rest of the table entries in bottom up manner    for i in range(1, n+1):        for j in range(m):             # Count of solutions including S[j]            x = table[i - S[j]][j] if i-S[j] >= 0 else 0             # Count of solutions excluding S[j]            y = table[i][j-1] if j >= 1 else 0             # total count            table[i][j] = x + y     return table[n][m-1] # Driver program to test above functionarr = [1, 2, 3]m = len(arr)n = 4print(count(arr, m, n)) # This code is contributed by Bhavya Jain
Python3
# Dynamic Programming Python implementation of Coin# Change problemdef count(S, m, n):     # table[i] will be storing the number of solutions for    # value i. We need n+1 rows as the table is constructed    # in bottom up manner using the base case (n = 0)    # Initialize all table values as 0    table = [0 for k in range(n+1)]     # Base case (If given value is 0)    table[0] = 1     # Pick all coins one by one and update the table[] values    # after the index greater than or equal to the value of the    # picked coin    for i in range(0,m):        for j in range(S[i],n+1):            table[j] += table[j-S[i]]     return table[n] # Driver program to test above functionarr = [1, 2, 3]m = len(arr)n = 4x = count(arr, m, n)print (x) # This code is contributed by Afzal Ansari
For both the solutions the time and space complexity is same:
Time Complexity: O(n*m)
Space Complexity: O(n)
Though first solution might be a little slow as it has multiple loops.
Please refer complete article on Dynamic Programming | Set 7 (Coin Change) for more details!
amartyaghoshgfg
harshmaster07705
dp-coin-change
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Grouping words with their anagrams in JavaScript

Two words or phrases which can be made by arranging the letters of each other in a different
order are called anagrams of each other, like rat and tar.
We are required to write a JavaScript function that takes in an array of strings that might contain some anagram strings. The function should group all the anagrams into separate subarrays and return the new array thus formed.
For example −
If the input array is −
const arr = ['rat', 'jar', 'tar', 'raj','ram', 'arm', 'mar', 'art'];
Then the output array should be −
const output = [
   ['rat', 'tar', 'art'],
   ['jar', 'raj'],
   ['ram', 'arm', 'mar']
];
Following is the code −
const arr = ['rat', 'jar', 'tar', 'raj','ram', 'arm', 'mar', 'art'];
const groupSimilarWords = (arr = []) => {
   if (arr.length === 0){
      return arr;
   };
   const map = new Map();
   for(let str of arr){
      let sorted = [...str];
      sorted.sort();
      sorted = sorted.join('');
      if(map.has(sorted)){
         map.get(sorted).push(str);
      }else{
         map.set(sorted, [str])
      };
   };
   return [...map.values()];
};
console.log(groupSimilarWords(arr));
Following is the console output −
[ [ 'rat', 'tar', 'art' ], [ 'jar', 'raj' ], [ 'ram', 'arm', 'mar' ] ]
How to add a colorbar for a hist2d plot in Matplotlib?

To add a colorbar for hist2d plot, we can pass a scalar mappable object to colorbar() method's argument.
Create x and y data points using numpy.
Create x and y data points using numpy.
Create a figure and a set of subplots using subplots() method.
Create a figure and a set of subplots using subplots() method.
Make a 2D histogram plot using hist2d() method.
Make a 2D histogram plot using hist2d() method.
Create a colorbar for a hist2d scalar mappable instance.
Create a colorbar for a hist2d scalar mappable instance.
To display the figure, use show() method.
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt, colors
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
x = np.random.randn(100)
y = np.random.randn(100) + 5
fig, ax = plt.subplots()
hh = ax.hist2d(x, y, bins=40, norm=colors.LogNorm())
fig.colorbar(hh[3], ax=ax)
plt.show()
Lua - If statement

An if statement consists of a Boolean expression followed by one or more statements.
The syntax of an if statement in Lua programming language is −
if(boolean_expression)
then
   --[ statement(s) will execute if the boolean expression is true --]
end

If the Boolean expression evaluates to true, then the block of code inside the if statement will be executed. If  Boolean expression evaluates to false, then the first set of code after the end of the if statement(after the closing curly brace) will be executed.
Lua programming language assumes any combination of Boolean true and non-nil values as true, and if it is either Boolean false or nil, then it is assumed as false value. It is to be noted that in Lua, zero will be considered as true.
--[ local variable definition --]
a = 10;

--[ check the boolean condition using if statement --]

if( a < 20 )
then
   --[ if condition is true then print the following --]
   print("a is less than 20" );
end

print("value of a is :", a);
When you build and run the above code, it produces the following result.
a is less than 20
value of a is : 10


    12 Lectures 
     2 hours 

 Manish Gupta

    80 Lectures 
     3 hours 

 Sanjeev Mittal

    54 Lectures 
     3.5 hours 

 Mehmet GOKTEPE
 Print
 Add Notes
 Bookmark this page
Parsing PDFs in Python with Tika - GeeksforGeeks

17 Aug, 2020
Apache Tika is a library that is used for document type detection and content extraction from various file formats. Using this, one can develop a universal type detector and content extractor to extract both structured text and metadata from different types of documents such as spreadsheets, text documents, images, PDF’s, and even multimedia input formats to a certain extent. Tika-Python is Python binding to the Apache TikaTM REST services allowing tika to be called natively in python language.
Installation:
To install Tika type the below command in the terminal. 
pip install tika

Note: Tika is written in Java, so you need a java(7 or 7+) runtime installed
For extracting contents from the PDF files we will use from_file() method of parser object. So let’s see the description first.
Syntax: parser.from_file(filename, additional)
Parameters:
filename: This is location of file, it is opened in rb mode i.e. read binary mode
additional: param service: service requested from the tika server, Default value is ‘all’, which results in recursive text content+metadata.‘meta’ returns only metadata. ‘text’ returns only content.param xmlContent: You can have XML content, default value- False
‘meta’ returns only metadata. ‘text’ returns only content.
param xmlContent: You can have XML content, default value- False
Return type: dictionary.
Now, Let’s see the python program for Extracting pdf’s data:
Example 1: Extracting contents of the pdf file.
Python3
# import parser object from tikefrom tika import parser    # opening pdf fileparsed_pdf = parser.from_file("sample.pdf")  # saving content of pdf# you can also bring text only, by parsed_pdf['text'] # parsed_pdf['content'] returns string data = parsed_pdf['content']   # Printing of content print(data)  # <class 'str'>print(type(data))
Output:
Example 2: Extracting Meta-Data of pdf file.
Python3
# import parser object from tikefrom tika import parser    parsed_pdf = parser.from_file("sample.pdf")  # ['metadata'] attribute returns # key-value pairs of meta-data print(parsed_pdf['metadata'])   # <class 'dict'>print(type(parsed_pdf['metadata']))
Output:
Example 3: Extract keys.
Python3
from tika import parser  parsed_pdf=parser.from_file("sample.pdf")  # Returns keys applicable for given pdf.print(parsed_pdf.keys())
Output:
Example 4: Know the tika server status.
Python3
from tika import parser  # You can also know the # status returned from tika # server, 200 for success parsed_pdf= parser.from_file("sample.pdf")  print(parsed_pdf['status'],type(parsed_pdf['status'] ))
Output:
200 <class 'int'>

python-modules
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Defaultdict in Python
Python | Get unique values from a list
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
Can we declare constructor as final in java?

A constructor is used to initialize an object when it is created. It is syntactically similar to a method. The difference is that the constructors have the same name as their class and, have no return type.
There is no need to invoke constructors explicitly these are automatically invoked at the time of instantiation.
 Live Demo
public class Example {
   public Example(){
      System.out.println("This is the constructor of the class example");
   }
   public static void main(String args[]) {
      Example obj = new Example();
   }
}
This is the constructor of the class example
Whenever you make a method final, you cannot override it. i.e. you cannot provide implementation to the superclass’s final method from the subclass.
i.e. The purpose of making a method final is to prevent modification of a method from outside (child class).
In the following Java program, we are trying to override a final method.
 Live Demo
class SuperClass{
   final public void display() {
      System.out.println("This is a method of the superclass");
   }
}
public class SubClass extends SuperClass{
   final public void display() {
      System.out.println("This is a method of the superclass");
   }
}
On compiling, the above program generates the following error.
SubClass.java:10: error: display() in SubClass cannot override display() in SuperClass
final public void display() {
                  ^
overridden method is final
1 error
In inheritance whenever you extend a class. The child class inherits all the members of the superclass except the constructors.
In other words, constructors cannot be inherited in Java, therefore, you cannot override constructors.
So, writing final before constructors make no sense. Therefore, java does not allow final keyword before a constructor.
If you try, make a constructor final a compile-time error will be generated saying “modifier final not allowed here”.
In the following Java program, the Student class has a constructor which is final.
 Live Demo
public class Student {
   public final String name;
   public final int age;
   public final Student(){
      this.name = "Raju";
      this.age = 20;
   }
   public void display(){
      System.out.println("Name of the Student: "+this.name );
      System.out.println("Age of the Student: "+this.age );
   }
   public static void main(String args[]) {
      new Student().display();
   }
}
On compiling, the above program generates the following error.
Student.java:6: error: modifier final not allowed here
public final Student(){
            ^
1 error
GATE | GATE CS 1996 | Question 20 - GeeksforGeeks

31 Oct, 2017
A critical section is a program segment
(A) which should run in a certain specified amount of time(B) which avoids deadlocks(C) where shared resources are accessed(D) which must be enclosed by a pair of semaphore operations, P and VAnswer: (C)Explanation:Quiz of this QuestionPlease comment below if you find anything wrong in the above post
GATE CS 1996
GATE-GATE CS 1996
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE CS 2019 | Question 27
GATE | GATE-IT-2004 | Question 66
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2006 | Question 49
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2004 | Question 3
GATE | GATE-CS-2000 | Question 43
GATE | GATE-CS-2017 (Set 2) | Question 42
GATE | GATE CS 2010 | Question 24
GATE | Gate IT 2007 | Question 30
Arrange given numbers to form the biggest number?

Here we will see how to generate the biggest number by rearranging the given numbers. Suppose there are {45, 74, 23} is given, the program will find the largest number, that is 744523. So each digit will not be arranged. but the whole number will be placed to make largest number.
To solve this problem, we will use the string sorting. But the comparison logic is different. The comparing function will take two numbers a and b, then concatenate them to form ab and ba. Among them which one is bigger, that is considered.
begin
   ab := concatenate b with a
   ba := concatenate a with b
   compare ba with ab, then return 1 if ba is bigger, otherwise return 0
end
getLargest(arr):
begin
   sort the arr with the comparison logic using compareString()
   for each string s in arr, do
      print s
   done
end
 Live Demo
#include<iostream>
#include <string>
#include &t;vector>
#include <algorithm>
using namespace std;
int stringCompare(string a, string b) {
   string ab = a.append(b);
   string ba = b.append(a);
   return ab.compare(ba) > 0 ? 1: 0;
}
void getLargest(vector<string> arr) {
   sort(arr.begin(), arr.end(), stringCompare); //sort the array
   for (int i =0; i < arr.size() ; i++ )
      cout << arr[i];
}
int main() {
   vector<string> arr;
   arr.push_back("45");
   arr.push_back("74");
   arr.push_back("23");
   getLargest(arr);
}
744523
React Native - View

View is the most common element in React Native. You can consider it as an equivalent of the div element used in web development.
Let us now see a few common use cases.
When you need to wrap your elements inside the container, you can use View as a container element.
When you need to wrap your elements inside the container, you can use View as a container element.
When you want to nest more elements inside the parent element, both parent and child can be View. It can have as many children as you want.
When you want to nest more elements inside the parent element, both parent and child can be View. It can have as many children as you want.
When you want to style different elements, you can place them inside View since it supports style property, flexbox etc.
When you want to style different elements, you can place them inside View since it supports style property, flexbox etc.
View also supports synthetic touch events, which can be useful for different purposes.
View also supports synthetic touch events, which can be useful for different purposes.
We already used View in our previous chapters and we will use it in almost all subsequent chapters as well. The View can be assumed as a default element in React Native. In example given below, we will nest two Views and a text.
import React, { Component } from 'react'
import { View, Text } from 'react-native'

const App = () => {
   return (
      <View>
         <View>
            <Text>This is my text</Text>
         </View>
      </View>
   )
}
export default App

    20 Lectures 
     1.5 hours 

 Anadi Sharma

    61 Lectures 
     6.5 hours 

 A To Z Mentor

    40 Lectures 
     4.5 hours 

 Eduonix Learning Solutions

    56 Lectures 
     12.5 hours 

 Eduonix Learning Solutions

    62 Lectures 
     4.5 hours 

 Senol Atac

    67 Lectures 
     4.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
Git Push Branch to GitHub

Let's try to create a new local branch, and push that to GitHub.
Start by creating a branch, like we did earlier:
git checkout -b update-readme
Switched to a new branch 'update-readme'
And we make some changes to the README.md file. Just add a new line.
So now we check the status of the current branch.
git status
On branch update-readme
Changes not staged for commit:
  (use "git add ..." to update what will be committed)
  (use "git restore ..." to discard changes in working directory)
        modified:   README.md

no changes added to commit (use "git add" and/or "git commit -a")
We see that README.md is modified but not added to the Staging Environment:
git add README.md
Check the status of the branch:
git status
On branch update-readme
Changes to be committed:
  (use "git restore --staged ..." to unstage)
        modified:   README.md
We are happy with our changes. So we will commit them to the branch:
git commit -m "Updated readme for GitHub Branches"
[update-readme 836e5bf] Updated readme for GitHub Branches
 1 file changed, 1 insertion(+)
Now push the branch from our local Git repository, 
to GitHub, where everyone can see the changes:
git push origin update-readme
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 16 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 366 bytes | 366.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
remote:
remote: Create a pull request for 'update-readme' on GitHub by visiting:
remote:      https://github.com/w3schools-test/hello-world/pull/new/update-readme
remote:
To https://github.com/w3schools-test/hello-world.git
 * [new branch]      update-readme -> update-readme
Go to GitHub, and confirm that the repository has a new 
branch:
In GitHub, we can now see the changes and merge them into the master 
branch if we approve it.
If you click the "Compare & pull request", you can go through the changes made and new files added:
Note: This comparison shows both the changes from update-readme and html-skeleton because we created the new branch FROM html-skeleton.
If the changes look good, you can go forward, creating a 
pull request:
A pull request is how you propose changes. You can ask some to review your 
changes or pull your contribution and merge it into their branch.
Since this is your own repository, you can  merge 
your pull request yourself:
The pull request will record the changes, which means you can go through them 
later to figure out the changes made.
The result should be something like this:
To keep the repo from getting overly complicated, you can delete the now unused branch by clicking "Delete branch".
An after you confirm that the changes from the previous branch were included, delete that as well:
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.
Keras - Backend Configuration

This chapter explains Keras backend implementations TensorFlow and Theano in detail. Let us go through each implementation one by one.
TensorFlow is an open source machine learning library used for numerical computational tasks developed by Google. Keras is a high level API built on top of TensorFlow or Theano. We know already how to install TensorFlow using pip.
If it is not installed, you can install using the below command −
pip install TensorFlow

Once we execute keras, we could see the configuration file is located at your home directory inside and go to .keras/keras.json.
{ 
   "image_data_format": "channels_last", 
   "epsilon": 1e-07, "floatx": "float32", "backend": "tensorflow" 
}

Here,
image_data_format represent the data format.
image_data_format represent the data format.
epsilon represents numeric constant. It is used to avoid DivideByZero error.
epsilon represents numeric constant. It is used to avoid DivideByZero error.
floatx represent the default data type float32. You can also change it to float16 or float64 using set_floatx() method.
floatx represent the default data type float32. You can also change it to float16 or float64 using set_floatx() method.
image_data_format represent the data format.
image_data_format represent the data format.
Suppose, if the file is not created then move to the location and create using the below steps −
> cd home 
> mkdir .keras 
> vi keras.json

Remember, you should specify .keras as its folder name and add the above configuration inside keras.json file. We can perform some pre-defined operations to know backend functions.
Theano is an open source deep learning library that allows you to evaluate multi-dimensional arrays effectively. We can easily install using the below command −
pip install theano

By default, keras uses TensorFlow backend. If you want to change backend configuration from TensorFlow to Theano, just change the backend = theano in keras.json file. It is described below −
{ 
   "image_data_format": "channels_last", 
   "epsilon": 1e-07, 
   "floatx": "float32", 
   "backend": "theano" 
}

Now save your file, restart your terminal and start keras, your backend will be changed.
>>> import keras as k 
using theano backend.


    87 Lectures 
     11 hours 

 Abhilash Nelson

    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

    68 Lectures 
     2 hours 

 Mike West
 Print
 Add Notes
 Bookmark this page
How to get the IP Address of local computer using C/C++?

In this section we will see how to see the Host name and IP address of the local system in an easier way. We will write a C program to find the host name and IP.
Some of the following functions are used. These functions have different task. Let us see the functions and their tasks.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
void check_host_name(int hostname) { //This function returns host name for local computer
   if (hostname == -1) {
      perror("gethostname");
      exit(1);
   }
}
void check_host_entry(struct hostent * hostentry) { //find host info from host name
   if (hostentry == NULL){
      perror("gethostbyname");
      exit(1);
   }
}
void IP_formatter(char *IPbuffer) { //convert IP string to dotted decimal format
   if (NULL == IPbuffer) {
      perror("inet_ntoa");
      exit(1);
   }
}
main() {
   char host[256];
   char *IP;
   struct hostent *host_entry;
   int hostname;
   hostname = gethostname(host, sizeof(host)); //find the host name
   check_host_name(hostname);
   host_entry = gethostbyname(host); //find host information
   check_host_entry(host_entry);
   IP = inet_ntoa(*((struct in_addr*) host_entry->h_addr_list[0])); //Convert into IP string
   printf("Current Host Name: %s\n", host);
   printf("Host IP: %s\n", IP);
}
Current Host Name: soumyadeep-VirtualBox
Host IP: 127.0.1.1
MYSQL - SHOW SCHEMAS statement

The SHOW SCHEMAS is a synonym for the SHOW DATABASES statement so, you can also use this statement to list out databases.
Assume we have created the deleted databases again, using the CREATE DATABASE statement as −
mysql> CREATE DATABASE testDB1;
Query OK, 1 row affected (0.34 sec)

mysql> CREATE DATABASE testDB2;
Query OK, 1 row affected (0.19 sec)

mysql> CREATE DATABASE testDB3;
Query OK, 1 row affected (0.21 sec)
Following SHOW SCHEMAS statement lists out the databases −
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mydatabase         |
| performance_schema |
| testdb1            |
| testdb2            |
| testdb3            |
| testdb4            |
| world              |
+--------------------+
8 rows in set (0.00 sec)
Using the LIKE clause, you can specify a pattern to retrieve specific databases. Following query retrieves the database name starting with the word "test".
mysql> SHOW DATABASES LIKE 'test%';
+------------------+
| Database (test%) |
+------------------+
| testdb1          |
| testdb2          |
| testdb3          |
| testdb4          |
+------------------+
4 rows in set (0.00 sec)
You can use the WHERE clause of the SHOW DATABASES statements to retrieve names of the databases which match the specified condition.
mysql> SHOW DATABASES WHERE `Database` LIKE '%test%';
+------------------+
| Database         |
+------------------+
| testdb1          |
| testdb2          |
| testdb3          |
| testdb4          |
+------------------+
4 rows in set (0.00 sec)

    31 Lectures 
     6 hours 

 Eduonix Learning Solutions

    84 Lectures 
     5.5 hours 

 Frahaan Hussain

    6 Lectures 
     3.5 hours 

 DATAhill Solutions Srinivas Reddy

    60 Lectures 
     10 hours 

 Vijay Kumar Parvatha Reddy

    10 Lectures 
     1 hours 

 Harshit Srivastava

    25 Lectures 
     4 hours 

 Trevoir Williams
 Print
 Add Notes
 Bookmark this page
How to Visualize a Decision Tree from a Random Forest in Python using Scikit-Learn | by Will Koehrsen | Towards Data Science

Here’s the complete code: just copy and paste into a Jupyter Notebook or Python script, replace with your data and run:
The final result is a complete decision tree as an image.
Create a model train and extract: we could use a single decision tree, but since I often employ the random forest for modeling it’s used in this example. (The trees will be slightly different from one another!).
Create a model train and extract: we could use a single decision tree, but since I often employ the random forest for modeling it’s used in this example. (The trees will be slightly different from one another!).
from sklearn.ensemble import RandomForestClassifiermodel = RandomForestClassifier(n_estimators=10)# Trainmodel.fit(iris.data, iris.target)# Extract single treeestimator = model.estimators_[5]
2. Export Tree as .dot File: This makes use of the export_graphviz function in Scikit-Learn. There are many parameters here that control the look and information displayed. Take a look at the documentation for specifics.
from sklearn.tree import export_graphviz# Export as dot fileexport_graphviz(estimator_limited,                 out_file='tree.dot',                 feature_names = iris.feature_names,                class_names = iris.target_names,                rounded = True, proportion = False,                 precision = 2, filled = True)
3. Convert dot to png using a system command: running system commands in Python can be handy for carrying out simple tasks. This requires installation of graphviz which includes the dot utility. For the complete options for conversion, take a look at the documentation.
# Convert to pngfrom subprocess import callcall(['dot', '-Tpng', 'tree.dot', '-o', 'tree.png', '-Gdpi=600'])
4. Visualize: the best visualizations appear in the Jupyter Notebook. (Equivalently you can use matplotlib to show images).
# Display in jupyter notebookfrom IPython.display import ImageImage(filename = 'tree.png')
With a random forest, every tree will be built differently. I use these images to display the reasoning behind a decision tree (and subsequently a random forest) rather than for specific details.
It’s helpful to limit maximum depth in your trees when you have a lot of features. Otherwise, you end up with massive trees, which look impressive, but cannot be interpreted at all! Here’s a full example with 50 features.
Machine learning still suffers from a black box problem, and one image is not going to solve the issue! Nonetheless, looking at an individual decision tree shows us this model (and a random forest) is not an unexplainable method, but a sequence of logical questions and answers — much as we would form when making predictions. Feel free to use and adapt this code for your data.
As always, I welcome feedback, constructive criticism, and hearing about your data science projects. I can be reached on Twitter @koehrsen_will
Tk - Grid Widget

The grid widget used to layout widgets in specific rows and columns. The syntax for grid widget is shown below −
grid gridName options

The options available for the grid widget are listed below in the following table −
-column number
Sets the column position for widget.
-row number
Sets the row position for widget.
-columnspan number
Number of columns to be used for this widget. Defaults to 1.
-rowspan number
Number of rows to be used for this widget. Defaults to 1.
-sticky side
Sets the edge of the cell to which the widget should stick to. Valid values can be n for top, s for bottom, e for right, w for left, or a combination of these letters.
A simple example for grid widget is shown below − 
#!/usr/bin/wish

frame .myFrame1 -background red  -relief ridge -borderwidth 8 -padx 10 -pady 10
   -height 100 -width 100
frame .myFrame2 -background blue  -relief ridge -borderwidth 8 -padx 10 -pady 10
   -height 100 -width 50
grid .myFrame1 -columnspan 10 -rowspan 10 -sticky w
grid .myFrame2 -column 10 -row 2
When we run the above program, we will get the following output −
 Print
 Add Notes
 Bookmark this page
Python – Convert Strings to Character Matrix

12 Mar, 2020
Sometimes, while dealing with String lists, we can have a problem in which we need to convert the Strings in list to separate character list. Overall converting into Matrix. This can have multiple applications in data science domain in which we deal with lots of data. Lets discuss certain ways in which this task can be performed.
Method #1 : Using List comprehensionThis is one way in which this task can be performed. In this, we convert the string to list of characters using list() and convert the result to desired matrix.
# Python3 code to demonstrate # Convert Strings to Character Matrix# using List comprehension  # Initializing listtest_list = ['gfg', 'is', 'best']  # printing original listprint("The original list is : " + str(test_list))  # Convert Strings to Character Matrix# using List comprehensionres = [list(sub) for sub in test_list]              # printing result print ("List String after conversion to Matrix : " + str(res))
The original list is : [‘gfg’, ‘is’, ‘best’]List String after conversion to Matrix : [[‘g’, ‘f’, ‘g’], [‘i’, ‘s’], [‘b’, ‘e’, ‘s’, ‘t’]]
 
Method #2 : Using loop + list()This is brute force way to perform this task. In this, we run loop and and convert each string to character list using list().
# Python3 code to demonstrate # Convert Strings to Character Matrix# using loop + list()  # Initializing listtest_list = ['gfg', 'is', 'best']  # printing original listprint("The original list is : " + str(test_list))  # Convert Strings to Character Matrix# using loop + list()res = []for sub in test_list:    res.append(list(sub))  # printing result print ("List String after conversion to Matrix : " + str(res))
The original list is : [‘gfg’, ‘is’, ‘best’]List String after conversion to Matrix : [[‘g’, ‘f’, ‘g’], [‘i’, ‘s’], [‘b’, ‘e’, ‘s’, ‘t’]]
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HTML <caption> Tag

17 Mar, 2022
The caption tag is used to specify the caption of a table. This tag will be inserted just after the <table> tag. Only one caption can be specified for one table. It is by default aligned to the center. 
Syntax:
<caption align = "value" ></caption>
Attributes: This tag accepts a single attribute as mentioned above and described below.
align: This attribute is used to specify the alignment of text content.
Below examples illustrate the <caption> tag in HTML:
Example 1: Adding a caption to the table i.e. by default aligned to the center. 
html
<!DOCTYPE html> <html> <body>     <h1>GeeksForGeeks</h1>     <h2>HTML <Caption> Tag</h2>           <table>         <!-- Adding caption to the table -->        <caption>Students</caption>         <tr>             <th>Firstname</th>             <th>Lastname</th>             <th>Age</th>         </tr>         <tr>             <td>Priya</td>             <td>Sharma</td>             <td>24</td>         </tr>         <tr>             <td>Arun</td>             <td>Singh</td>             <td>32</td>         </tr>         <tr>             <td>Sam</td>             <td>Watson</td>             <td>41</td>         </tr>     </table> </body> </html>
Output: 
Example 2: Adding a caption to the table and adding align attribute to it to align the caption to the left.
html
<!DOCTYPE html><html>  <body>    <h1>GeeksforGeeks</h1>    <h2>HTML <Caption> Tag</h2>      <table>      <!-- Adding a caption to the table             and aligning it to the left-->      <caption style="text-align: left">        Students      </caption>      <tr>        <th>Firstname</th>        <th>Lastname</th>        <th>Age</th>      </tr>      <tr>        <td>Priya</td>        <td>Sharma</td>        <td>24</td>      </tr>      <tr>        <td>Arun</td>        <td>Singh</td>        <td>32</td>      </tr>      <tr>        <td>Sam</td>        <td>Watson</td>        <td>41</td>      </tr>    </table>  </body></html>
Output: 
 
Supported Browsers: 
Google Chrome
Internet Explorer
Firefox
Opera
Safari
arorakashish0911
shubhamyadav4
HTML-Tags
Picked
HTML
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
REST API (Introduction)
Hide or show elements in HTML using display property
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
HTTP headers | Content-Type