code-rag-bench/online-tutorials huggingface dataset:
Impala - Create a Database

In Impala, a database is a construct which holds related tables, views, and functions within their namespaces. It is represented as a directory tree in HDFS; it contains tables partitions, and data files. This chapter explains how to create a database in Impala.
The CREATE DATABASE Statement is used to create a new database in Impala.
Following is the syntax of the CREATE DATABASE Statement.
CREATE DATABASE IF NOT EXISTS database_name;

Here, IF NOT EXISTS is an optional clause. If we use this clause, a database with the given name is created, only if there is no existing database with the same name.
Following is an example of the create database statement. In this example, we have created a database with the name my_database.
[quickstart.cloudera:21000] > CREATE DATABASE IF NOT EXISTS my_database;
On executing the above query in cloudera impala-shell, you will get the following output.
Query: create DATABASE my_database 

Fetched 0 row(s) in 0.21s

The SHOW DATABASES query gives the list of the databases in Impala, therefore you can verify whether the database is created, using the SHOW DATABASES statement. Here you can observe the newly created database my_db in the list.
[quickstart.cloudera:21000] > show databases; 

Query: show databases
+-----------------------------------------------+
| name                                          | 
+-----------------------------------------------+ 
| _impala_builtins                              |
| default                                       | 
|  my_db                                        | 
+-----------------------------------------------+
Fetched 3 row(s) in 0.20s 
[quickstart.cloudera:21000] >

In order to create a database in HDFS file system, you need to specify the location where the database is to be created.
CREATE DATABASE IF NOT EXISTS database_name LOCATION hdfs_path;

Open Impala Query editor and type the CREATE DATABASE statement in it. Thereafter, click the execute button as shown in the following screenshot.
After executing the query, gently move the curser to the top of the dropdown menu and you will find a refresh symbol. If you click on the refresh symbol, the list of databases will be refreshed and the recent changes are applied to it.
Click the drop-down box under the heading DATABASE on the left-hand side of the editor. There you can see a list of databases in the system. Here you can observe the newly created database my_db as shown below.
If you observe carefully, you can see only one database, i.e., my_db in the list along with the default database.
 Print
 Add Notes
 Bookmark this page
Cypress - Prompt Pop-up Window

Cypress can handle prompt pop-up windows, where users can input values. A prompt has a text field, where the input is taken. To handle a prompt pop-up, cy.window() method is used.
It obtains the value of the object of the prompt (remote window). In a confirmation/alert pop-up, we have to fire a browser event. But for prompt pop-up, we have to use cy.stub() method.
Let us look at the below example, on clicking the Click for JS Prompt button, a prompt pop up gets displayed, as shown below −
The following prompt with the user input field gets displayed. Tutorialspoint is entered in the prompt pop-up, as shown below.
You entered − Tutorialspoint gets displayed under Result.
This can be seen in the screen displayed below −
Given below is an implementation of the commands for displaying prompt pop-up windows in Cypress −
describe('Tutorialspoint Test', function () {
   // test case
   it("Scenario 1", function () {
      //URL launch
      cy.visit("https://the-internet.herokuapp.com/javascript_alerts")
      //handling prompt alert
      cy.window().then(function(p){
         //stubbing prompt window
         cy.stub(p, "prompt").returns("Tutorialspoint");
         // click on Click for JS Prompt button
         cy.get(':nth-child(3) > button').click()
         // verify application message on clicking on OK
         cy.get('#result').contains('You entered: Tutorialspoint')
      });
   });
});   
Execution Results
The output is as follows −
The output logs show the successful verification of the text.
You entered − Tutorialspoint, is produced on clicking OK button on prompt pop up. Also,
the stub applied on the prompt window is visible on the output log.

    73 Lectures 
     12 hours 

 Rahul Shetty
 Print
 Add Notes
 Bookmark this page
JavaFX - 2D Shapes Rounded Rectangle

In JavaFX, you can draw a rectangle either with sharp edges or with arched edges as shown in the following diagram.
The one with arched edges is known as a rounded rectangle and it has two additional properties namely −
arcHeight − The vertical diameter of the arc, at the corners of a rounded rectangle.
arcHeight − The vertical diameter of the arc, at the corners of a rounded rectangle.
arcWidth − The horizontal diameter of the arc at the corners of a rounded rectangle.
arcWidth − The horizontal diameter of the arc at the corners of a rounded rectangle.
By default, JavaFX creates a rectangle with sharp edges unless you set the height and width of the arc to +ve values (0<) using their respective setter methods setArcHeight() and setArcWidth().
Following is a program which generates a rounded rectangle using JavaFX. Save this code in a file with the name RoundedRectangle.java.
import javafx.application.Application; 
import javafx.scene.Group; 
import javafx.scene.Scene; 
import javafx.stage.Stage; 
import javafx.scene.shape.Rectangle; 
         
public class RoundedRectangle extends Application { 
   @Override 
   public void start(Stage stage) {         
      //Drawing a Rectangle 
      Rectangle rectangle = new Rectangle();  
      
      //Setting the properties of the rectangle 
      rectangle.setX(150.0f); 
      rectangle.setY(75.0f); 
      rectangle.setWidth(300.0f); 
      rectangle.setHeight(150.0f); 
       
      //Setting the height and width of the arc 
      rectangle.setArcWidth(30.0); 
      rectangle.setArcHeight(20.0);  
         
      //Creating a Group object  
      Group root = new Group(rectangle); 
         
      //Creating a scene object 
      Scene scene = new Scene(root, 600, 300);  
      
      //Setting title to the Stage 
      stage.setTitle("Drawing a Rectangle");
      
      //Adding scene to the stage 
      stage.setScene(scene); 
      
      //Displaying the contents of the stage 
      stage.show(); 
   } 
   public static void main(String args[]){ 
      launch(args); 
   } 
}
Compile and execute the saved java file from the command prompt using the following commands.
javac RoundedRectangle.java 
java RoundedRectangle

On executing, the above program generates a JavaFX window displaying a rounded rectangle as shown below.

    33 Lectures 
     7.5 hours 

 Syed Raza

    64 Lectures 
     12.5 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    20 Lectures 
     4 hours 

 Emenwa Global, Ejike IfeanyiChukwu
 Print
 Add Notes
 Bookmark this page
Print Single and Multiple variable in C#

To display single variable value in C#, you just need to use Console.WriteLine()
Let us see an example. Here, we have displayed the value of a single variable “a” in a line −
using System;
using System.Linq;

class Program {
   static void Main() {
      int a = 10;
      Console.WriteLine("Value: "+a);
   }
}
To display multiple variables value in C#, you need to use the comma operator in Console.WriteLine().
Let us see an example. Here, we have displayed the value of multiple variables “a” and “b” in a line −
using System;
using System.Linq;

class Program {
   static void Main() {
      int a = 10;
      int b = 15;
      Console.WriteLine("Values: {0} {1} ",a,b);
   }
}
Above, the {0} is replaced by the value of variable a, whereas {1} is replaced by the value of variable b.
How to use std::sort to sort an array in C++

In programming language, sorting is a basic function which is applied to data to arrange these data is ascending or descending data. In C++ program, there is a function std::sort() for sorting the array.
sort(start address, end address)
Here,
Start address => The first address of the element.
Last address => The address of the next contiguous location of the last element of the array.
 Live Demo
#include <iostream>
#include <algorithm>
using namespace std;
void display(int a[]) {
   for(int i = 0; i < 5; ++i)
   cout << a[i] << " ";
}
int main() {
   int a[5]= {4, 2, 7, 9, 6};
   cout << "\n The array before sorting is : ";
   display(a);
   sort(a, a+5);
   cout << "\n\n The array after sorting is : ";
   display(a);
   return 0;
}
The array before sorting is : 4 2 7 9 6

The array after sorting is : 2 4 6 7 9
Print Binary Tree in 2-Dimensions in C++

In this problem, we are given a binary tree and we have to print it two dimensional plane.
Binary Tree is a special tree whose every node has at max two child nodes. So, every node is either a leaf node or has one or two child nodes.
Example,
Let’s take an example to understand the topic better −
Output -
      7
   4
5
      1
   3
      8
Now as we have seen in the example, the nodes of the tree are printed in a 2-D output screen horizontally.
Here, we have flipped the tree by 90o.
Let’s see what the new horizontal tree is made up of,
The tree data structure is stored in a horizontal way which includesThe root at the 1st position in horizontal view n lines below the starting line. i.e. root will be at the start of the nth line.The new levels of the tree are in lines n+i and n-i. And at i tab spaces away from the start of the line.And the rightmost leaf node of the tree is printed in the first line. Whereas the leftmost node of the tree is printed at the last line.
The tree data structure is stored in a horizontal way which includes
The root at the 1st position in horizontal view n lines below the starting line. i.e. root will be at the start of the nth line.
The root at the 1st position in horizontal view n lines below the starting line. i.e. root will be at the start of the nth line.
The new levels of the tree are in lines n+i and n-i. And at i tab spaces away from the start of the line.
The new levels of the tree are in lines n+i and n-i. And at i tab spaces away from the start of the line.
And the rightmost leaf node of the tree is printed in the first line. Whereas the leftmost node of the tree is printed at the last line.
And the rightmost leaf node of the tree is printed in the first line. Whereas the leftmost node of the tree is printed at the last line.
Let’s create a program based on this logic −
 Live Demo
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define COUNT 10
class Node{
   public:
      int data;
      Node* left, *right;
      Node(int data){
         this->data = data;
         this->left = NULL;
         this->right = NULL;
      }
};
void printTree(Node *root, int space){
   if (root == NULL)
      return;
   space += COUNT;
   printTree(root->right, space);
   for (int i = COUNT; i < space; i++)
      cout<<"\t";
   cout<<root->data<<"\n";
   printTree(root->left, space);
}
int main(){
   Node *root = new Node(43);
   root->left = new Node(25);
   root->right = new Node(67);
   root->left->left = new Node(14);
   root->left->right = new Node(51);
   root->right->left = new Node(26);
   root->right->right = new Node(97);
   root->left->left->left = new Node(81);
   root->left->left->right = new Node(49);
   root->left->right->left = new Node(07);
   root->left->right->right = new Node(31);
   root->right->left->left = new Node(29);
   root->right->left->right = new Node(13);
   root->right->right->left = new Node(59);
   root->right->right->right = new Node(16);
   printTree(root, 0);
   return 0;
}
         16
      97
         59
   67
         13
      26
         29
43
         31
      51
         7
   25
         49
   14
         81
Split string into equal parts JavaScript

We are required to write a JavaScript function that takes in a string and a number n as two
arguments (the number should be such that it exactly divides the length of string). And we have
to return an array of n strings of equal length.
For example −
If the string is "helloo" and the number is 3
Our output should be:
["ho", "eo", "ll"]
Here, each substring exactly contains (length of array/n) characters. And each substring is
formed by taking corresponding first and last letters of the string alternatively
Let's write the code for this function −
const str = 'helloo';
const splitEqual = (str, n) => {
   if(str.length % n !== 0){
      return false;
   }
   const len = str.length / n;
   const strArray = str.split("");
   const arr = [];
   let i = 0, char;
   while(strArray.length){
      if(i % 2 === 0){
         char = strArray.shift();
      }else{
         char = strArray.pop();
      };
      if(i % len === 0){
         arr[i / len] = char;
      }else{
         arr[Math.floor(i / len)] += char;
      };
      i++;
   };
   return arr;
};
console.log(splitEqual(str, 3));
The output in the console will be −
[ 'ho', 'eo', 'll' ]
Date after() method in Java - GeeksforGeeks

07 Nov, 2019
The java.util.Date.after() method is used to check whether the current instance of the date is after the specified date.
Syntax:
dateObject.after(Date specifiedDate)

Parameter: It takes only one parameter specifiedDate of data type Date. This is the date which is to be checked in comparison to the instance of the date calling the function.
Return Value: The return type of this function is boolean. It returns true if current instance of the date is strictly larger than the specifiedDate. Otherwise it returns false.
Exceptions: If the specifiedDate is null, this method will throw NullPointerException when called upon.
Below programs illustrate after() method in Date class:
Program 1:
// Java code to demonstrate// after() function of Date class  import java.util.Date;import java.util.Calendar;public class GfG {    // main method    public static void main(String[] args)    {          // creating a Calendar object        Calendar c = Calendar.getInstance();          // set Month        // MONTH starts with 0 i.e. ( 0 - Jan)        c.set(Calendar.MONTH, 11);          // set Date        c.set(Calendar.DATE, 05);          // set Year        c.set(Calendar.YEAR, 1996);          // creating a date object with specified time.        Date dateOne = c.getTime();          // creating a date of object        // storing the current date        Date currentDate = new Date();          System.out.print("Is currentDate after date one : ");          // if currentDate is after dateOne        System.out.println(currentDate.after(dateOne));    }}
Is currentDate after date one : true

Program 2: To demonstrate java.lang.NullPointerException
// Java code to demonstrate// after() function of Date class  import java.util.Date;  public class GfG {    // main method    public static void main(String[] args)    {          // creating a date of object        // storing the current date        Date currentDate = new Date();          // specifiedDate is assigned to null.        Date specifiedDate = null;          System.out.println("Passing null as parameter : ");        try {            // throws NullPointerException            System.out.println(currentDate.after(specifiedDate));        }        catch (Exception e) {            System.out.println("Exception: " + e);        }    }}
Passing null as parameter : 
Exception: java.lang.NullPointerException

ManasChhabra2
Java - util package
Java-Date-Time
Java-Functions
Java-util-Date
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
HashMap in Java with Examples
Interfaces in Java
Object Oriented Programming (OOPs) Concept in Java
ArrayList in Java
How to iterate any Map in Java
Initialize an ArrayList in Java
Singleton Class in Java
Overriding in Java
Collections in Java
Multithreading in Java
JavaScript String - lastIndexOf() Method

This method returns the index within the calling String object of the last occurrence of the specified value, starting the search at fromIndex or -1 if the value is not found.
Its syntax is as follows −
string.lastIndexOf(searchValue[, fromIndex])

searchValue − A string representing the value to search for.
searchValue − A string representing the value to search for.
fromIndex − The location within the calling string to start the search from. It can be any integer between 0 and the length of the string. The default value is 0.
fromIndex − The location within the calling string to start the search from. It can be any integer between 0 and the length of the string. The default value is 0.
Returns the index of the last found occurrence, otherwise -1 if not found.
Try the following example.
<html>
   <head>
      <title>JavaScript String lastIndexOf() Method</title>
   </head>
   
   <body>   
      <script type = "text/javascript">
         var str1 = new String( "This is string one and again string" );
         var index = str1.lastIndexOf( "string" );
         document.write("lastIndexOf found String :" + index ); 
         
         document.write("<br />");         
         var index = str1.lastIndexOf( "one" );
         document.write("lastIndexOf found String :" + index ); 
      </script>      
   </body>
</html>
lastIndexOf found String :29
lastIndexOf found String :15  


    25 Lectures 
     2.5 hours 

 Anadi Sharma

    74 Lectures 
     10 hours 

 Lets Kode It

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    70 Lectures 
     4.5 hours 

 Frahaan Hussain

    46 Lectures 
     6 hours 

 Eduonix Learning Solutions

    88 Lectures 
     14 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
Creating curved edges with NetworkX in Python3 (Matplotlib)

To create curved edges with NetworkX in Python3, we can use connectionstyle="arc3, rad=0.4".
Set the figure size and adjust the padding between and around the subplots.
Initialize a graph with edges, name, and graph attributes.
Add nodes to the created graph.
Add edges from one node to another.
Draw the graph G with Matplotlib, with connectionstyle="arc3, rad=0.4".
To display the figure, use show() method.
import matplotlib.pylab as plt
import networkx as nx

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

G = nx.DiGraph()

pos = nx.spring_layout(G)
G.add_nodes_from([1, 2, 3, 4])
G.add_edges_from([(1, 2), (2, 4), (2, 3), (4, 1)])

nx.draw(G, with_labels=True, connectionstyle="arc3,rad=0.4")

plt.show()
Get the Component Type of an Array Object in Java

In order to get the component type of an Array Object in Java, we use the getComponentType() method. The getComponentType() method returns the Class denoting the component type of an array. If the class is not an array class this method returns null.
Declaration − The java.lang.Class.getComponentType() method is declared as follows -
public Class<?> getComponentType()
Let us see a program to the get the component type of an Array Object in Java -
 Live Demo
public class Example {
   public static void main(String[] args) {
      int[] array = new int[] {1,2,3};
      // obtain the Class of the component type
      Class arrayClass = array.getClass();
      // obtaining the component type
      Class component = arrayClass.getComponentType();
      if (component != null) {
         System.out.println("Component type is " + component.getName());
      } else {
         System.out.println("Component type is null");
      }
   }
}
Component type is int
Difference between new and malloc( )

In this post, we will understand the difference between ‘new’ and ‘malloc’.
It is present in C++, Java, and C#.
It is present in C++, Java, and C#.
It is an operator that can be used to call the constructor of the object.
It is an operator that can be used to call the constructor of the object.
It can be overloaded.
It can be overloaded.
If it fails, an exception is thrown.
If it fails, an exception is thrown.
It doesn’t need the ‘sizeof’ operator.
It doesn’t need the ‘sizeof’ operator.
It doesn’t reallocate memory.
It doesn’t reallocate memory.
It can initialize an object when allocating memory for it.
It can initialize an object when allocating memory for it.
The memory allocated by ‘new’ operator can be de-allocated using ‘delete’ operator.
The memory allocated by ‘new’ operator can be de-allocated using ‘delete’ operator.
It reduces the execution time of the application.
It reduces the execution time of the application.
#include<iostream>
using namespace std;
int main(){
   int *val = new int(10);
   cout << *val;
   getchar();
   return 0;
}
This is present in C language.
This is present in C language.
It is a function that can’t be overloaded.
It is a function that can’t be overloaded.
When ‘malloc’ fails, it returns NULL.
When ‘malloc’ fails, it returns NULL.
It requires the ‘sizeof’ operator to know how much memory has to be allotted.
It requires the ‘sizeof’ operator to know how much memory has to be allotted.
It can’t call a constructor.
It can’t call a constructor.
Memory can’t be initialized using this function.
Memory can’t be initialized using this function.
The memory allocated using malloc can be deallocated using free function.
The memory allocated using malloc can be deallocated using free function.
Memory allocated by malloc method can be reallocated using realloc method.
Memory allocated by malloc method can be reallocated using realloc method.
It requires more time to execute applications.
It requires more time to execute applications.
Following is the example of malloc in C language −
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main () {
   char *str;
   /* Initial memory allocation */
   str = (char *) malloc(5);
   strcpy(str, "amit");
   printf("String = %s, Address = %u\n", str, str);
}
C++ iomanip Library - setw Function

The C++ function  std::setw behaves as if member width were called with n as argument on the stream on which it is inserted/extracted as a manipulator (it can be inserted/extracted on input streams or output streams).
It is used to sets the field width to be used on output operations.
Following is the declaration for std::setw function.
setw (int n);
n − Number of characters to be used as field width.
It returns unspecified. This function should only be used as a stream manipulator.
Basic guarantee − if an exception is thrown, the stream is in a valid state.
The stream object on which it is inserted/extracted is modified. Concurrent access to the same stream object may introduce data races.
In below example explains about setw function.
#include <iostream>
#include <iomanip>

int main () {
   std::cout << std::setw(10);
   std::cout << 77 << std::endl;
   return 0;
}
Let us compile and run the above program, this will produce the following result −
77

 Print
 Add Notes
 Bookmark this page
Install PostgreSQL on Linux - GeeksforGeeks

24 Sep, 2021
This is a step-by-step guide to install PostgreSQL on a Linux machine. By default, PostgreSQL is available in all Ubuntu versions as PostgreSql “Snapshot”. However other versions of the same can be downloaded through the PostgreSQL apt repository. 
We will be installing PostgreSQL version 11.3 on Ubuntu in this article. 
There are three crucial steps for the installation of PostgreSQL as follows: 
Check for the current version of PostgreSQL on your Ubuntu  Install PostgreSQL  Verify the installation  
Check for the current version of PostgreSQL on your Ubuntu  
Install PostgreSQL  
Verify the installation  
You can check for the current version of PostgreSQL on your Ubuntu device by using the below command in the terminal: 
postgres -V 
After checking if you need an update of PostgreSQL, follow the below steps to install the latest PostgreSQL version: 
Step 1: Add the GPG key for connecting with the official PostgreSQL repository using the below command: 
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
Step 2: Add the official PostgreSQL repository in your source list and also add it’s certificate using the below command: 
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
Step 3: Run the below command to install PostgreSQL: 
sudo apt update
sudo apt install postgresql postgresql-contrib 
There are couple of ways to verify the installation of PostgreSQL like connecting to the database server using some client applications like pgAdmin or psql. The quickest way though is to use the psql shell. For that follow the below steps: 
Step 1: Open the terminal and run the below command to log into PostgreSQL server: 
sudo su postgres
Step 2: Now use the below command to enter the PostgreSQL shell: 
psql
Step 3: Now run the below command to check for the PostgreSQL version: 
SELECT version();
anikaseth98
postgreSQL-basics
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
PostgreSQL - GROUP BY clause
PostgreSQL - DROP INDEX
PostgreSQL - ROW_NUMBER Function
PostgreSQL - LEFT JOIN
PostgreSQL - Copy Table
PostgreSQL - Cursor
PostgreSQL - Record type variable
PostgreSQL - SELECT
PostgreSQL - Select Into
PostgreSQL - TEXT Data Type
OpenCV - Median Blur

The Median blur operation is similar to the other averaging methods. Here, the central element of the image is replaced by the median of all the pixels in the kernel area. This operation processes the edges while removing the noise.
You can perform this operation on an image using the medianBlur() method of the imgproc class. Following is the syntax of this method −
medianBlur(src, dst, ksize)

This method accepts the following parameters −
src − A Mat object representing the source (input image) for this operation.
src − A Mat object representing the source (input image) for this operation.
dst − A Mat object representing the destination (output image) for this operation.
dst − A Mat object representing the destination (output image) for this operation.
ksize − A Size object representing the size of the kernel.
ksize − A Size object representing the size of the kernel.
The following program demonstrates how to perform the median blur operation on an image.
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

public class MedianBlurTest {
   public static void main(String args[]) {
      // Loading the OpenCV core library
      System.loadLibrary( Core.NATIVE_LIBRARY_NAME );

      // Reading the Image from the file and storing it in to a Matrix object
      String file ="C:/EXAMPLES/OpenCV/sample.jpg";
      Mat src = Imgcodecs.imread(file);

      // Creating an empty matrix to store the result
      Mat dst = new Mat();

      // Applying MedianBlur on the Image
      Imgproc.medianBlur(src, dst, 15);

      // Writing the image
      Imgcodecs.imwrite("E:/OpenCV/chap9/median.jpg", dst);

      System.out.println("Image Processed");
   }
}
Assume that following is the input image sample.jpg specified in the above program.
On executing the program, you will get the following output −
Image Processed

If you open the specified path, you can observe the output image as follows −

    70 Lectures 
     9 hours 

 Abhilash Nelson

    41 Lectures 
     4 hours 

 Abhilash Nelson

    20 Lectures 
     2 hours 

 Spotle Learn

    12 Lectures 
     46 mins

 Srikanth Guskra

    19 Lectures 
     2 hours 

 Haithem Gasmi

    67 Lectures 
     6.5 hours 

 Gianluca Mottola
 Print
 Add Notes
 Bookmark this page
Move columns to the right with Bootstrap

To move columns to the right, use the .col-*-offset-* class in Bootstrap.
You can try to run the following code to implement it
Live Demo
<!DOCTYPE html>
<html lang = "en">
   <head>
      <title>Bootstrap Example</title>
      <meta charset = "utf-8">
      <meta name = "viewport" content = "width=device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "container-fluid">
         <div class = "row">
            <div class = "col-sm-5 col-md-6" style = "background-color:blue;color: white;">This is div1.</div>
            <div class = "col-sm-5 col-md-6 col-md-offset-0" style = "background-color:orange;color: white;">This is div2.</div>
         </div>
      </div>
   </body>
</html>
How do I manually throw/raise an exception in Python?

We use the most specific exception constructor that fits our specific issue rather than raise generic exceptions. To catch our specific exception, we'll have to catch all other more specific exceptions that subclass it.
We should raise specific exceptions and handle the same specific exceptions.
To raise the specific exceptions we use the raise statement as follows.
import sys
try:
f = float('Tutorialspoint')
print f
raise ValueError
except Exception as err:
print sys.exc_info()
We get the following output
(<type 'exceptions.ValueError'>, ValueError('could not convert string to float: Tutorialspoint',), <traceback object at 0x0000000002E33748>)
We can raise an error even with arguments like the following example
try:
raise ValueError('foo', 23)
except ValueError, e:
print e.args
We get the following output
('foo', 23)
Get all subdirectories of a given directory in PHP

To get the subdirectories present in a directory, the below lines of code can be used −
 Live Demo
<?php
   $all_sub_dirs = array_filter(glob('*.*'), 'is_dir');
   print_r($all_sub_dirs);
?>
This will produce the following output. The glob function is used to get all the subdirectories of a specific directory−
Array (
   [0] => demo.csv
   [1] => mark.php
   [2] => contact.txt
   [3] => source.txt
)
To get only the directories, the below lines of code can be used−
<?php
   $all_dirs = glob($somePath . '/*' , GLOB_ONLYDIR);
   print_r($all_dirs);
?>
This will produce the following output. The glob function is used by specifying that only directories need to be extracted−
Array (
   [0] => example
   [1] => exam
   [2] => log
)
Dart Programming - while Loop

The while loop executes the instructions each time the condition specified evaluates to true. In other words, the loop evaluates the condition before the block of code is executed.
The following illustration shows the flowchart of the while loop −
Following is the syntax for the while loop. 
while (expression) {
   Statement(s) to be executed if expression is true  
}

void main() { 
   var num = 5; 
   var factorial = 1; 
   
   while(num >=1) { 
      factorial = factorial * num; 
      num--; 
   } 
   print("The factorial  is ${factorial}"); 
}  
The above code uses a while loop to calculate the factorial of the value in the variable num.
The following output is displayed on successful execution of the code.
The factorial is 120 


    44 Lectures 
     4.5 hours 

 Sriyank Siddhartha

    34 Lectures 
     4 hours 

 Sriyank Siddhartha

    69 Lectures 
     4 hours 

 Frahaan Hussain

    117 Lectures 
     10 hours 

 Frahaan Hussain

    22 Lectures 
     1.5 hours 

 Pranjal Srivastava

    34 Lectures 
     3 hours 

 Pranjal Srivastava
 Print
 Add Notes
 Bookmark this page
How to create table rows & columns in HTML?

To create table rows and columns in HTML, use the <table> tag. A table consist of rows and columns, which can be set using one or more <tr>, <th>, and <td> elements. A table row is defined by the <tr> tag. For table rows and columns, <tr> tag and <td> tag is used respectively. The <td> tag
Just keep in mind, a lot of table attributes such as align, bgcolor, border, cellpadding, cellspacing aren’t supported by HTML5. Do not use them. Use the style attribute to add CSS properties for adding a border to the table. We’re also using the <style> tag to style the table borders.
You can try to run the following code to create table rows and columns in HTML.
<!DOCTYPE html>
<html>
   <head>
      <style>
         table, th, td {
            border: 1px solid black;
         }
      </style>
   </head>

   <body>
      <h2>Understanding Tables</h2>
      <table>
         <tr>
            <th>Header: This is row1 column1</th>
            <th>Header: This is row1 column2</th>
         </tr>
         <tr>
            <td>This is row2 column1</td>
            <td>This is row2 column2</td>
         </tr>
      </table>
   </body>
</html>
SkipWhile method in C#

SkipWhile skips an element when a condition is matched.
For example, use the following if you want to skip all even elements −
ele => ele %2 == 0
The following is an example wherein all the even elements are skipped and only the odd elements are displayed −
 Live Demo
using System.IO;
using System;
using System.Linq;
public class Demo {
   public static void Main() {
      int[] arr = { 20, 35, 55 };
      Console.WriteLine("Initial array...");
      foreach (int value in arr) {
         Console.WriteLine(value);
      }
      // skipping even elements
      var res = arr.SkipWhile(ele => ele % 2 == 0);
      Console.WriteLine("New array after skipping even elements...");
      foreach (int val in res) {
         Console.WriteLine(val);
      }
   }
}
Initial array...
20
35
55
New array after skipping even elements...
35
55
Java Connection getMetaData() method with example

Generally, Data about data is known as metadata. The DatabaseMetaData interface provides methods to get information about the database you have connected with like, database name, database driver version, maximum column length etc...
The getMetaData() method of the Connection interface retrieves and returns the DatabaseMetaData object. This contains information about the database you have connected to. You can get information about the database such as name of the database, version, driver name, user name and, url etc... by invoking the methods of the DatabaseMetaData interface using the obtained object.
This method returns the DatabaseMetaData object which holds information about the underlying database.
To get the DatabaseMetaData object for the underlying database.
Register the driver using the registerDriver() method of the DriverManager class as −
//Registering the Driver
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
Get the connection using the getConnection() method of the DriverManager class as −
//Getting the connection
String url = "jdbc:mysql://localhost/mydatabase";
Connection con = DriverManager.getConnection(url, "root", "password");
Get the metadata object using the getMetaData() method as −
DatabaseMetaData dbMetadata = con.getMetaData();
Following JDBC program establishes a connection with the database and retrieves information about the underlying database such as name of the database, driver name, URL etc...
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Connection_getMetaData {
   public static void main(String args[]) throws SQLException {
      //Registering the Driver
      DriverManager.registerDriver(new com.mysql.jdbc.Driver());
      //Getting the connection
      String url = "jdbc:mysql://localhost/mydatabase";
      Connection con = DriverManager.getConnection(url, "root", "password");
      System.out.println("Connection established......");
      //Creating the DatabaseMetaData object
      DatabaseMetaData dbMetadata = con.getMetaData();
      //invoke the supportsBatchUpdates() method.
      boolean bool = dbMetadata.supportsBatchUpdates();
      if(bool) {
         System.out.println("Underlying database supports batch updates");
      } else {
         System.out.println("Underlying database doesn’t support batch updates");
      }
      //Retrieving the driver name
      System.out.println("Driver name: "+dbMetadata.getDriverName());
      //Retrieving the driver version
      System.out.println("Database version: "+dbMetadata.getDriverVersion());
      //Retrieving the user name
      System.out.println("User name: "+dbMetadata.getUserName());
      //Retrieving the URL
      System.out.println("URL for this database: "+dbMetadata.getURL());
   }
}
Connection established......
Underlying database supports batch updates
Driver name: MySQL-AB JDBC Driver
Database version: mysql-connector-java-5.1.12 ( Revision: ${bzr.revision-id} )
User name: root@localhost
URL for this database: jdbc:mysql://localhost/mydatabase
GATE | GATE-CS-2005 | Question 85 - GeeksforGeeks

12 Jul, 2021
Consider the following expression grammar. The seman­tic rules for expression calculation are stated next to each grammar production.
 E → number 	 E.val = number. val
    | E '+' E 	 E(1).val = E(2).val + E(3).val
    | E '×' E	 E(1).val = E(2).val × E(3).val
The above grammar and the semantic rules are fed to a yacc tool (which is an LALR (1) parser generator) for parsing and evaluating arithmetic expressions. Which one of the following is true about the action of yacc for the given grammar?(A) It detects recursion and eliminates recursion(B) It detects reduce-reduce conflict, and resolves(C) It detects shift-reduce conflict, and resolves the conflict in favor of a shift over a reduce action(D) It detects shift-reduce conflict, and resolves the conflict in favor of a reduce over a shift actionAnswer: (C)Explanation:  
Backgroundyacc conflict resolution is done using following rules:shift is preferred over reduce while shift/reduce conflict.first reduce is preferred over others while reduce/reduce conflict.
 
You can answer to this question straightforward by constructing LALR(1) parse table, though its a time taking process. To answer it faster, one can see intuitively that this grammar will have a shift-reduce conflict for sure. In that case, given this is a single choice question, (C) option will be the right answer.
Fool-proof explanation would be to generate LALR(1) parse table, which is a lengthy process. Once we have the parse table with us, we can clearly see thati. reduce/reduce conflict will not arise in the above given grammarii. shift/reduce conflict will be resolved by giving preference to shift, hence making the expression calculator right associative.
According to the above conclusions, only correct option seems to be (C).
Reference:
http://dinosaur.compilertools.net/yacc/
This solution is contributed by Vineet Purswani.Quiz of this Question
clintra
GATE-CS-2005
GATE-GATE-CS-2005
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
How do I create a date picker in tkinter?

Tkcalendar is a Python package which provides DateEntry and Calendar widgets for tkinter applications. In this article, we will create a date picker with the help of DateEntry Widget.
A DateEntry widget contains three fields that refer to the general format of Date as MM/DD/YY. By creating an object of DateEntry widget, we can choose a specific Date in the application.
#Import tkinter library
from tkinter import *
from tkcalendar import Calendar, DateEntry
#Create an instance of tkinter frame
win= Tk()
#Set the Geometry
win.geometry("750x250")
win.title("Date Picker")
#Create a Label
Label(win, text= "Choose a Date", background= 'gray61', foreground="white").pack(padx=20,pady=20)
#Create a Calendar using DateEntry
cal = DateEntry(win, width= 16, background= "magenta3", foreground= "white",bd=2)
cal.pack(pady=20)
win.mainloop()
Execute the above code snippet to display a date picker in the window.
Now pick any date from the DateEntry Widget to set and reflect the output.
Find path to the given file using Python - GeeksforGeeks

13 Jan, 2021
We can get the location (path) of the running script file .py with __file__. __file__ is useful for reading other files and it gives the current location of the running file. It differs in versions. In Python 3.8 and earlier, __file__ returns the path specified when executing the python (or python3) command. We can get a relative path if a relative path is specified. If we specify an absolute path, an absolute path is returned. But in Python 3.9 and later, __file__ always returns an absolute path, the “os” module provides various utilities. 
os.getcwd(): We can get the absolute path of the current working directory. So depending upon the version used, either a relative path or absolute path is retrieved.
Example 1:
Python3
import osprint('Get current working directory :      ', os.getcwd())print('Get current file name :    ', __file__)
Output:
Example 2: We can get the file name and the directory name of the running file in the below way.
Python3
import os  print('File name :    ', os.path.basename(__file__))print('Directory Name:     ', os.path.dirname(__file__))
Output:
Way to find File name and directory name
Example 3: To get the absolute path of the running file.
Python3
import os  print('Absolute path of file:     ',       os.path.abspath(__file__))print('Absolute directoryname: ',       os.path.dirname(os.path.abspath(__file__)))
Output:
Absolute way to find file and directory name
Example 4: If we specify an absolute path in os.path.abspath(), it will be returned as it is, so if __file__ is an absolute path, no error will occur even if we set os.path.abspath(__file__)
Python3
import ospythonfile = 'pathfinding.py'  # if the file is present in current directory,# then no need to specify the whole locationprint("Path of the file..", os.path.abspath(pythonfile))  for root, dirs, files in os.walk(r'E:\geeksforgeeks\path_of_given_file'):    for name in files:                  # As we need to get the provided python file,         # comparing here like this        if name == pythonfile:              print(os.path.abspath(os.path.join(root, name)))
Output:
Picked
python-os-module
Technical Scripter 2020
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
Defaultdict in Python
Python | Get unique values from a list
Python | Pandas dataframe.groupby()
GATE | GATE-CS-2014-(Set-1) | Question 65 - GeeksforGeeks

30 Sep, 2021
Consider a 6-stage instruction pipeline, where all stages are perfectly balanced. Assume that there is no cycle-time overhead of pipelining. When an application is executing on this 6-stage pipeline, the speedup achieved with respect to non-pipelined execution if 25% of the instructions incur 2 pipeline stall cycles is(A) 4(B) 8(C) 6(D) 7Answer: (A)Explanation:
It was a numerical digit type question so answer must be 4.

As for 6 stages, non-pipelining takes 6 cycles.

There were 2 stall cycles for pipelining for 25% of the instructions

So pipe line time = (1+(25/100)*2) = 1.5

Speed up = Non pipeline time/Pipeline time = 6/1.5 = 4
YouTubeGeeksforGeeks GATE Computer Science16.2K subscribersPipelining: Previous Year Question part-III | COA | GeeksforGeeks GATE | Harshit NigamWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:005:45 / 49:32•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=BVk8ZlNukmg" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
GATE-CS-2014-(Set-1)
GATE-GATE-CS-2014-(Set-1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-IT-2004 | Question 66
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2006 | Question 49
GATE | GATE-CS-2004 | Question 3
GATE | GATE CS 2010 | Question 24
GATE | GATE CS 2011 | Question 65
GATE | GATE CS 2019 | Question 27
GATE | GATE CS 2021 | Set 1 | Question 47
GATE | GATE CS 2011 | Question 7
Computer Graphics | The RGB color model - GeeksforGeeks

19 Mar, 2019
The RGB color model is one of the most widely used color representation method in computer graphics. It use a color coordinate system with three primary colors:
R(red), G(green), B(blue) 
Each primary color can take an intensity value ranging from 0(lowest) to 1(highest). Mixing these three primary colors at different intensity levels produces a variety of colors. The collection of all the colors obtained by such a linear combination of red, green and blue forms the cube shaped RGB color space.
The corner of RGB color cube that is at the origin of the coordinate system corresponds to black, whereas the corner of the cube that is diagonally opposite to the origin represents white. The diagonal line connecting black and white corresponds to all the gray colors between black and white, which is also known as gray axis.
In the RGB color model, an arbitrary color within the cubic color space can be specified by its color coordinates: (r, g.b).
Example:
(0, 0, 0) for black, (1, 1, 1) for white, 
(1, 1, 0) for yellow, (0.7, 0.7, 0.7) for gray 
Color specification using the RGB model is an additive process. We begin with black and add on the appropriate primary components to yield a desired color. The concept RGB color model is used in Display monitor. On the other hand, there is a complementary color model known as CMY color model. The CMY color model use a subtraction process and this concept is used in the printer.
In CMY model, we begin with white and take away the appropriate primary components to yield a desired color.
Example:If we subtract red from white, what remains consists of green and blue which is cyan. The coordinate system of CMY model use the three primaries’ complementary colors:
C(cray), M(magenta) and Y(yellow) 
The corner of the CMY color cube that is at (0, 0, 0) corresponds to white, whereas the corner of the cube that is at (1, 1, 1) represents black. The following formulas summarize the conversion between the two color models:
computer-graphics
GBlog
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Roadmap to Become a Web Developer in 2022
DSA Sheet by Love Babbar
GET and POST requests using Python
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Working with csv files in Python
Types of Software Testing
Working with PDF files in Python
10 Best IDE For Web Developers in 2022
Top 10 System Design Interview Questions and Answers