code-rag-bench/online-tutorials huggingface dataset:
How to Draw a Trapezium using HTML and CSS ?

21 Jun, 2021
A Trapezium is a Quadrilateral which has two parallel and two non-parallel sides. In this article we will create a Trapezium shape using simple HTML and CSS.
HTML Code: In this section, we will create a simple element using the HTML div tag.
HTML
<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <meta name="viewport" content=    "width=device-width, initial-scale=1.0">  <title>Trapezium</title></head> <body>  <div class="trapezium"></div>  </body></html>
CSS Code: In this section, we will first design the div element using some basic CSS properties and then use the border-bottom, border-left and border-right properties to create the trapezium shape.
css
<style>  /* creating the trapezium shape*/  .trapezium {     height: 0;     width: 150px;     border-bottom: 150px solid green;     border-left: 100px solid transparent;     border-right: 100px solid transparent;  }</style>
Final Code: It is the combination of the above two code sections.
HTML
<!DOCTYPE html><html lang="en"> <head>  <meta charset="UTF-8">  <meta name="viewport" content=    "width=device-width, initial-scale=1.0">  <title>Trapezium</title>   <style>        /* Creating the trapezium shape*/    .trapezium {      height: 0;      width: 150px;      border-bottom: 150px solid green;      border-left: 100px solid transparent;      border-right: 100px solid transparent;    }  </style></head> <body>  <div class="trapezium"></div></body> </html>
Output:
CoderSaty
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java Program to Get the File Extension

22 Oct, 2021
The extension of a file is the last part of its name after the period (.). For example, the Java source file extension is “java”, and you will notice that the file name always ends with “.java”. Getting the file extension in Java is done using the File class of Java, i.e., probeContentType() method. The File class is Java’s representation of a file or directory pathname. The File class contains several processes for working with the pathname, deleting and renaming files, creating new directories, listing the directory contents, and determining several common attributes of files and directories.
The probeContentType() is a method that comes predefined in the Java File class. The parameter to this method is passed the path of the file.
Parameters: A path of the file.
Return value: It returns a string(extension).
Syntax: In Java, we can get the filename by – 
File file = new File("/home/mayur/GFG.java");
String fileName = file.getName();

fileType = Files.probeContentType(f.toPath());
Below is the implementation of the problem statement: 
Java
// Java Program to Get the File Extension  import java.io.*;import java.nio.file.Files;  public class GFG {    public static void main(String[] args)    {        // File location        File f = new File("/home/mayur/GFG.java");          // If file exists        if (f.exists()) {            String fileType = "Undetermined";            String fileName = f.getName();            String extension = "";            int i = fileName.lastIndexOf('.');              if (i > 0) {                extension = fileName.substring(i + 1);            }            try {                fileType                    = Files.probeContentType(f.toPath());            }            catch (IOException ioException) {                System.out.println(                    "Cannot determine file type of "                    + f.getName()                    + " due to following exception: "                    + ioException);            }              // Print Extension            System.out.println(                "Extension used for file is -> " + extension                + " and is probably " + fileType);        }        else {            System.out.println("File does not exist!");        }    }}
Output: 
In the above example,
file.getName() – Returns the file’s name and store it in a String variable.
fileName.lastIndexOf(‘.’) – Returns the last occurrence of character. Since all file extension starts with ‘.’, we use the character ‘.’.
fileName.substring() – Returns the string after character ‘.’.
nishkarshgandhi
Java-File Class
Picked
Technical Scripter 2020
Java
Java Programs
Technical Scripter
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL – Timestamp Data Type

24 Jan, 2022
In PostgreSQL 2 temporal data types namely timestamp and timestamptz where one is without timezone and the later is with timezone respectively, are supported to store Time and Date to a column. Both timestamp and timestamptz uses 8 bytes for storing timestamp values. 
 
Syntax: TIMESTAMP; or TIMESTAMPTZ;
Now let’s look into some example for better understanding. Example 1: First we create a table that has both timestamp and timestamptz columns using the below command:  
CREATE TABLE timestamp_demo (ts TIMESTAMP, tstz TIMESTAMPTZ);
Then we will set the time zone of database server to Asia/Calcutta as below:  
SET timezone = 'Asia/Calcutta';
Now that our time zone is set, we will insert a new row into the timestamp_demo table using the below command:  
INSERT INTO timestamp_demo (ts, tstz)
VALUES
    (
        '2020-06-22 19:10:25-07',
        '2020-06-22 19:10:25-07'
    );
Now we will query data from the timestamp and timestamptz columns using the below command:  
SELECT
    ts, tstz
FROM
    timestamp_demo;
Output:  
Example 2: In this example we will convert Asia/Calcutta timezone into America/New_York timezone using the timezone(zone, timestamp) function. First we create a table that has both timestamp and timestamptz columns using the below command:  
CREATE TABLE timezone_conversion_demo ( tstz TIMESTAMPTZ);
Then we will set the time zone of database server to Asia/Calcutta as below:  
SET timezone = 'Asia/Calcutta';
Now that our time zone is set, we will insert a new row into the timezone_conversion_demo table using the below command:  
INSERT INTO timezone_conversion_demo ( tstz)
VALUES
    (
        
        '2020-06-22 19:10:25-07'
    );
Now we will query data from the timestamp and timestamptz columns using the below command:  
SELECT timezone('America/New_York', '2020-06-22 19:10:25');
Output:  
 
sooda367
saurabh1990aror
postgreSQL-dataTypes
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Prototype - toArray() Method

This method splits the string character-by-character and returns an array with the result.
string.toArray() ;

Returns an array of characters.
<html>
   <head>
      <title>Prototype examples</title>
      <script type = "text/javascript" src = "/javascript/prototype.js"> </script>
      
      <script>
         function showResult() {
            var str = "a";
            alert("a.toArray() : " + str.toArray()[0] );
            
            var str = "hello world!";
            var arr = str.toArray();
            arr.each(function(alpha) {
               alert(alpha);
            });
         }
      </script>
   </head>

   <body>
      <p>Click the button to see the result.</p>
      <br />
      <br />
      <input type = "button" value = "Result" onclick = "showResult();"/>
   </body>
</html>
Click the button to see the result.

    127 Lectures 
     11.5 hours 

 Aleksandar Cucukovic
 Print
 Add Notes
 Bookmark this page
How to use trim () in Android textview?

This example demonstrate about How to use trim () in Android textview.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical"
   android:gravity="center"
   tools:context=".MainActivity">
   <EditText
      android:id="@+id/name"
      android:layout_width="match_parent"
      android:hint="Enter name"
      android:layout_height="wrap_content" />
   <Button
      android:id="@+id/click"
      android:text="Click"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />
   <TextView
      android:id="@+id/textview"
      android:layout_width="wrap_content"
      android:textSize="25sp"
      android:layout_height="wrap_content" />
</LinearLayout>
In the above code, we have taken name as Edit text, when user click on button it will take data and trim the data without spaces.
Step 3 − Add the following code to src/MainActivity.java
package com.example.myapplication;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
   EditText name;
   Button button;
   TextView text;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      name = findViewById(R.id.name);
      button = findViewById(R.id.click);
      text = findViewById(R.id.textview);
      button.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            if (!name.getText().toString().isEmpty()) {
               if (name.getText().toString().length() >= 0) {
                  String trim = name.getText().toString().trim();
                  text.setText(String.valueOf(trim));
               }
            } else {
               name.setError("Plz enter name");
            }
         }
      });
   }
}
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
In the above result, enter the string as “ krishna ” and it returned krishna without spaces.
Click here to download the project code
How to refresh a webpage using Python Selenium Webdriver?

We can refresh a webpage using Selenium webdriver in Python. This can be done with the help of the refresh method. First of all, we have to launch the application with the get method.
Once a web page is loaded completely, we can then refresh the page with the help of the refresh method. This way the existing page gets refreshed. The refresh method is to be applied on the webdriver object.
driver.get("https://www.tutorialspoint.com/tutor_connect/index.php")
driver.refresh()
from selenium import webdriver
#set chromodriver.exe path
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
driver.implicitly_wait(0.5)
#launch URL
driver.get("https://www.google.com/")
#identify text box
m = driver.find_element_by_class_name("gLFyf")
#send input
m.send_keys("Java")
#refresh page
driver.refresh()
eval - Unix, Linux Command

eval - Eval is a built in linux or unix command.
eval [arg ..]
eval is a built in linux or unix command. The eval command is used to execute the arguments as a shell command on unix or linux system. Eval command comes in handy when you have a unix or linux command stored in a variable and you want to execute that command stored in the string. The eval command first evaluates the argument and then runs the command stored in the argument.
Example-1:
To execute that command stored in the string:
$ COMMAND="ls -lrt"
$ eval $COMMAND
 output: 
total 16
-rw-rw-r-- 1 user group 11  Oct  4 01:06 sample.sh-rw-rw-r-- 1 user group 0   Oct  4 01:06 test.bat
-rw-rw-r-- 1 user group 0   Oct  4 01:06 xyz_ip
Example-2:
To print the value of variable which is again variable with value assigned to it
$ a=10
$ b=a
$ c='$'$b ( note: The dollar sign must be escaped with '$')
$ echo $c
output:
$a
$ eval c='$'$b
$ echo $c
output:
10

    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
C Program for product of array

Given an array arr[n] of n number of elements, the task is to find the product of all the elements of that array.
Like we have an array arr[7] of 7 elements so its product will be like
Input: arr[] = { 10, 20, 3, 4, 8 }
Output: 19200
Explanation: 10 x 20 x 3 x 4 x 8 = 19200
Input: arr[] = { 1, 2, 3, 4, 3, 2, 1 }
Output: 144
The approach used below is as follows −
Take array input.
Find its size.
Iterate the array and Multiply each element of that array
Show result
Start
In function int prod_mat(int arr[], int n)
   Step 1-> Declare and initialize result = 1
   Step 2-> Loop for i = 0 and i < n and i++
      result = result * arr[i];
   Step 3-> Return result
int main()
   Step 1-> Declare an array arr[]
   step 2-> Declare a variable for size of array
   Step 3-> Print the result
 Live Demo
#include <stdio.h>
int prod_arr(int arr[], int n) {
   int result = 1;
   //Wil multiply each element and store it in result
   for (int i = 0; i < n; i++)
   result = result * arr[i];
   return result;
}
int main() {
   int arr[] = { 10, 20, 3, 4, 8 };
   int n = sizeof(arr) / sizeof(arr[0]);
   printf("%d", prod_arr(arr, n));
   return 0;
}
If run the above code it will generate the following output −
19200
Maximum number of threads that can be created within a process in C - GeeksforGeeks

26 Sep, 2017
Thread of execution is the smallest sequence of programmed instructions that can be managed independently by scheduler. Thread is a component of process and so multiple threads can be associated in a process. Linux doesn’t have a separate threads per process limit, but has a limit on the total number of processes on the system (as threads just processes with a shared address space on Linux).
Our task is to find out maximum number of thread that can be created within a single process (maximum number of thread that pthread_create can create). Maximum number of threads can be seen is ubuntu by using command:
cat /proc/sys/kernel/threads-max
This thread limit for linux can be modified at runtime by writing desired limit to /proc/sys/kernel/threads-max.
Compile the following program on ubuntu operating system, to check maximum number of threads that can be created within a process in C.
cc filename.c -pthread where filename.c 
is the name with which file is saved.
// C program to find maximum number of thread within// a process#include<stdio.h>#include<pthread.h>  // This function demonstrates the work of thread// which is of no use here, So left blankvoid *thread ( void *vargp){     }  int main(){    int err = 0, count = 0;    pthread_t tid;          // on success, pthread_create returns 0 and     // on Error, it returns error number    // So, while loop is iterated until return value is 0    while (err == 0)    {        err = pthread_create (&tid, NULL, thread, NULL);        count++;    }    printf("Maximum number of thread within a Process"                                   " is : %d\n", count);}
Output:
Maximum number of thread within a Process is : 32754

This article is contributed by Aditya Kumar. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Processes & Threads
C Language
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
TCP Server-Client implementation in C
Exception Handling in C++
Multithreading in C
'this' pointer in C++
UDP Server-Client implementation in C
Sed Command in Linux/Unix with examples
AWK command in Unix/Linux with examples
grep command in Unix/Linux
cut command in Linux with examples
TCP Server-Client implementation in C
How to uninstall the PowerShell Module?

To uninstall the PowerShell module, we can directly use the Uninstall-Module command but the module should not be in use, otherwise, it will throw an error.
When we use the Uninstall-Module command, it can uninstall the module from the current user profile or from the all users profile.
Uninstall-Module 7Zip4PowerShell -Force -Verbose
Another method,
Get-InstalledModule 7Zip4Powershell | Uninstall-Module -Force -Verbose
If you have multiple versions of the same module installed in the PowerShell, and if you want to uninstall all of them then use the -AllVersions Parameter.
Uninstall-Module 7Zip4PowerShell -AllVersions -Force -Verbose
If you want to uninstall the specific version, we can use -RequiredVersion.
Uninstall-Module 7Zip4PowerShell -RequiredVersion 1.5.0 -Force -Verbose
To uninstall on the remote computer, use the Invoke-Command method.
Invoke-Command -ComputerName RemoteComputer1 -ScriptBlock {
   Uninstall-Module 7Zip4PowerShell -RequiredVersion 1.5.0 -Force -Verbose
}
How do I view the auto_increment value for a table in MySQL?

In order to view the auto_increment value for a table, you can use SHOW TABLE command.
The syntax is as follows
SHOW TABLE STATUS LIKE 'yourTableName'\G
The syntax is as follows
SELECT `AUTO_INCREMENT`
   FROM `information_schema`.`TABLES`
   WHERE `TABLE_SCHEMA` = ‘yourDatabaseName’
   AND `TABLE_NAME` =’yourTableName';
To understand the above syntaxes, let us create a table. The query to create a table is as follows
mysql> create table viewAutoIncrementDemo
   -> (
   -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> UserName varchar(20)
   -> );
Query OK, 0 rows affected (0.59 sec)
Now you can insert some records in the table using insert command. The query is as follows −
mysql> insert into viewAutoIncrementDemo(UserName) values('John');
Query OK, 1 row affected (0.18 sec)
mysql> insert into viewAutoIncrementDemo(UserName) values('Carol');
Query OK, 1 row affected (0.14 sec)
mysql> insert into viewAutoIncrementDemo(UserName) values('Bob');
Query OK, 1 row affected (0.08 sec)
mysql> insert into viewAutoIncrementDemo(UserName) values('Sam');
Query OK, 1 row affected (0.12 sec)
mysql> insert into viewAutoIncrementDemo(UserName) values('Mike');
Query OK, 1 row affected (0.14 sec)
mysql> insert into viewAutoIncrementDemo(UserName) values('David');
Query OK, 1 row affected (0.16 sec)
mysql> insert into viewAutoIncrementDemo(UserName) values('Larry');
Query OK, 1 row affected (0.11 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from viewAutoIncrementDemo;
The following is the output
+--------+----------+
| UserId | UserName |
+--------+----------+
|     1 | John      |
|     2 | Carol     |
|     3 | Bob       |
|     4 | Sam       |
|     5 | Mike      |
|     6 | David     |
|     7 | Larry     |
+--------+----------+
7 rows in set (0.00 sec)
Here is the query to view the auto_increment value for a table
mysql> SHOW TABLE STATUS LIKE 'viewAutoIncrementDemo'\G
The following is the output
*************************** 1. row ***************************
           Name: viewautoincrementdemo
         Engine: InnoDB
        Version: 10
     Row_format: Dynamic
           Rows: 7
 Avg_row_length: 2340
    Data_length: 16384
Max_data_length: 0
   Index_length: 0
      Data_free: 0
 Auto_increment: 8
    Create_time: 2019-03-02 04:05:20
    Update_time: 2019-03-02 04:06:11
     Check_time: NULL
      Collation: utf8_general_ci
       Checksum: NULL
 Create_options:
        Comment:
1 row in set (0.08 sec)
The following is the second query
mysql> SELECT `AUTO_INCREMENT`
   -> FROM `information_schema`.`TABLES`
   -> WHERE `TABLE_SCHEMA` = 'sample'
   -> AND `TABLE_NAME` = 'viewAutoIncrementDemo';
The following is the output
+----------------+
| AUTO_INCREMENT |
+----------------+
| 8              |
+----------------+
1 row in set (0.00 sec)
Compare only day and month with date field in MySQL?

You can compare only day and month with date field in MySQL with the help of DATE_FORMAT().
The syntax is as follows
select *from yourTableName
WHERE DATE_FORMAT(yourColumnName, '%m-%d') = DATE_FORMAT('yourValue', '%m-%d') and yourCondition;
To understand the above syntax, let us create a table. The query to create a table is as follows
mysql> create table compareDayAndMonthDemo
   -> (
   -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> compareDayAndTime date
   -> );
Query OK, 0 rows affected (0.49 sec)
Insert some records in the table using insert command.
The query is as follows
mysql> insert into compareDayAndMonthDemo(compareDayAndTime) values('2014-01-31');
Query OK, 1 row affected (0.20 sec)
mysql> insert into compareDayAndMonthDemo(compareDayAndTime) values('2014-10-11');
Query OK, 1 row affected (0.16 sec)
mysql> insert into compareDayAndMonthDemo(compareDayAndTime) values('2016-09-12');
Query OK, 1 row affected (0.08 sec)
mysql> insert into compareDayAndMonthDemo(compareDayAndTime) values('2017-04-25');
Query OK, 1 row affected (0.08 sec)
mysql> insert into compareDayAndMonthDemo(compareDayAndTime) values('2018-12-25');
Query OK, 1 row affected (0.08 sec)
mysql> insert into compareDayAndMonthDemo(compareDayAndTime) values('2019-02-27');
Query OK, 1 row affected (0.07 sec)
Display all records from the table using select statement.
The query is as follows
mysql> select *from compareDayAndMonthDemo;
The following is the output
+----+-------------------+
| Id | compareDayAndTime |
+----+-------------------+
| 1  | 2014-01-31        |
| 2  | 2014-10-11        |
| 3  | 2016-09-12        |
| 4  | 2017-04-25        |
| 5  | 2018-12-25        |
| 6  | 2019-02-27        |
+----+-------------------+
6 rows in set (0.00 sec)
Here is the query to compare only day and month
mysql> select *from compareDayAndMonthDemo
-> WHERE DATE_FORMAT(compareDayAndTime, '%m-%d') = DATE_FORMAT('2019-01-31', '%m-%d') and Id=1;
The following is the output
+----+-------------------+
| Id | compareDayAndTime |
+----+-------------------+
| 1  | 2014-01-31        |
+----+-------------------+
1 row in set (0.00 sec)
If you want only day and month, then use the below query
mysql> select DATE_FORMAT(compareDayAndTime, '%m-%d') AS DayAndMonthOnly from compareDayAndMonthDemo
-> WHERE DATE_FORMAT(compareDayAndTime, '%m-%d') = DATE_FORMAT('2019-01-31', '%m-%d') and Id=1;
The following is the output
+-----------------+
| DayAndMonthOnly |
+-----------------+
| 01-31           |
+-----------------+
1 row in set (0.00 sec)
Write a program in Python to split the date column into day, month, year in multiple columns of a given dataframe

Assume, you have a dataframe and the result for a date, month, year column is,
      date  day  month  year
0 17/05/2002 17   05    2002
1 16/02/1990 16   02    1990
2 25/09/1980 25   09    1980
3 11/05/2000 11   05    2000
4 17/09/1986 17   09    1986
To solve this, we will follow the steps given below −
Create a list of dates and assign into dataframe.
Create a list of dates and assign into dataframe.
Apply str.split function inside ‘/’ delimiter to df[‘date’] column. Assign the result to df[[“day”, “month”, “year”]].
Apply str.split function inside ‘/’ delimiter to df[‘date’] column. Assign the result to df[[“day”, “month”, “year”]].
Let’s check the following code to get a better understanding −
import pandas as pd
df = pd.DataFrame({
      'date': ['17/05/2002','16/02/1990','25/09/1980','11/05/2000','17/09/1986']
   })
print("Original DataFrame:")
print(df)
df[["day", "month", "year"]] = df["date"].str.split("/", expand = True)
print("\nNew DataFrame:")
print(df)
Original DataFrame:
     date
0 17/05/2002
1 16/02/1990
2 25/09/1980
3 11/05/2000
4 17/09/1986
New DataFrame:
      date  day  month year
0 17/05/2002 17    05 2002
1 16/02/1990 16    02 1990
2 25/09/1980 25    09 1980
3 11/05/2000 11    05 2000
4 17/09/1986 17    09 1986
How to create a responsive zig zag (alternating) layout with CSS?

To create responsive zig zag layout with CSS, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
   * {
      box-sizing:border-box;
   }
   body {
      margin: 0;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
   }
   div h1{
      font-size: 40px;
      color: blueviolet;
      text-align: center;
   }
   div p{
      font-size: 18px;
   }
   .container {
      padding: 64px;
   }
   .row:after {
      content: "";
      display: table;
      clear: both
   }
   .width66 {
      float: left;
      width: 66.66666%;
      padding: 20px;
      height: 471px;
   }
   .width33 {
      float: left;
      width: 33.33333%;
      padding: 20px;
      height: 471px;
   }
   .large-font {
      font-size: 48px;
   }
   .xlarge-font {
      font-size: 64px
   }
   .button {
      border: none;
      color: white;
      padding: 14px 28px;
      font-size: 16px;
      cursor: pointer;
      background-color: #4CAF50;
   }
   img {
      display: block;
      height: 250px;
      width: 250px;
      max-width: 100%;
   }
   @media screen and (max-width: 1000px) {
      .width66, .width33 {
         width: 100%;
         text-align: center;
      }
      img {
         margin: auto;
      }
   }
</style>
</head>
<body>
<h1 style="text-align:center">Responsive Zig Zag Layout Example</h2>
<div class="width66">
<h1>A Gypsy</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia tempore expedita sequi consequuntur rerum quasi voluptate deleniti iure quae magni qui, laudantium illo dolorum temporibus, dolor labore, quos eos. Dolores?</p>
</div>
<div class="width33">
<img src="https://i.picsum.photos/id/551/800/800.jpg">
</div>
<div class="width33">
<img src="https://i.picsum.photos/id/211/800/800.jpg" alt="App">
</div>
<div class="width66">
<h1>A cruise ship</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia tempore expedita sequi consequuntur rerum quasi voluptate deleniti iure quae magni qui, laudantium illo dolorum temporibus, dolor labore, quos eos. Dolores?</p>
</div>
<div class="width66">
<h1>Natures View</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia tempore expedita sequi consequuntur rerum quasi voluptate deleniti iure quae magni qui, laudantium illo dolorum temporibus, dolor labore, quos eos. Dolores?</p>
</div>
<div class="width33">
<img src="https://i.picsum.photos/id/251/800/800.jpg" >
</div>
</div>
</div>
</body>
</html>
The above code will produce the following output −
On resizing ourscreen −
How to draw shapes using SVG in HTML5?

SVG stands for Scalable Vector Graphics and is a language for describing 2D-graphics and graphical applications in XML and the XML is then rendered by an SVG viewer. Most of the web browsers can display SVG just like they can display PNG, GIF, and JPG.
You can draw shapes like circle, rectangle, line, etc using SVG in HTML5 easily. Let’s see an example to draw a rectangle using SVG.
You can try to run the following code to draw a rectangle in HTML5. The <rect> element will be used
<!DOCTYPE html>
<html>
   <head>
      <style>
         #svgelem {
            position: relative;
            left: 10%;
            -webkit-transform: translateX(-20%);
            -ms-transform: translateX(-20%);
            transform: translateX(-20%);
         }
      </style>
      <title>SVG</title>
   </head>
   <body>
      <h2>HTML5 SVG Rectangle</h2>
      <svg id="svgelem" width="300" height="200" xmlns="http://www.w3.org/2000/svg">
         <rect width="200" height="100" fill="green"/>
      </svg>
   </body>
</html>
Find geometric sum of the series using recursion

09 Aug, 2021
Given an integer N, we need to find the geometric sum of the following series using recursion.  
1 + 1/3 + 1/9 + 1/27 + ... + 1/(3^n)  
Examples:  
Input N = 5 
Output: 1.49794

Input: N = 7
Output: 1.49977
 
Approach:In the above-mentioned problem, we are asked to use recursion. We will calculate the last term and call recursion on the remaining n-1 terms each time. The final sum returned is the result.Below is the implementation of the above approach:  
C++
Java
Python3
C#
Javascript
// CPP implementation to Find the// geometric sum of the series using recursion #include <bits/stdc++.h>using namespace std; // function to find the sum of given seriesdouble sum(int n){    // base case    if (n == 0)        return 1;     // calculate the sum each time    double ans = 1 / (double)pow(3, n) + sum(n - 1);     // return final answer    return ans;} // Driver codeint main(){     // integer initialisation    int n = 5;     cout << sum(n) << endl;     return 0;}
// JAVA implementation to Find the// geometric sum of the series using recursion import java.util.*; class GFG {     static double sum(int n)    {        // base case        if (n == 0)            return 1;         // calculate the sum each time        double ans = 1 / (double)Math.pow(3, n) + sum(n - 1);         // return final answer        return ans;    }     // Driver code    public static void main(String[] args)    {        // integer initialisation        int n = 5;         // print result        System.out.println(sum(n));    }}
# CPP implementation to Find the# geometric sum of the series using recursion  def sum(n):         # base case    if n == 0:        return 1         # calculate the sum each time    # and return final answer    return 1 / pow(3, n) + sum(n-1) n = 5; print(sum(n));
// C# implementation to Find the// geometric sum of the series using recursion using System; class GFG {     static double sum(int n)    {        // base case        if (n == 0)            return 1;         // calculate the sum each time        double ans = 1 / (double)Math.Pow(3, n) + sum(n - 1);         // return final answer        return ans;    }     // Driver code    static public void Main()    {        int n = 5;         Console.WriteLine(sum(n));    }}
<script> // Javascript implementation to Find the// geometric sum of the series using recursion // function to find the sum of given seriesfunction sum(n){    // base case    if (n == 0)        return 1;     // calculate the sum each time    var ans = 1 / Math.pow(3, n) + sum(n - 1);     // return final answer    return ans;} // Driver code// integer initialisationvar n = 5;document.write( sum(n).toFixed(5)); </script>
1.49794
 
Time Complexity: O(N)Auxiliary Space: O(N)
itsok
pankajsharmagfg
Algorithms
Recursion
Recursion
Algorithms
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
exec command in Linux with examples

15 May, 2019
exec command in Linux is used to execute a command from the bash itself. This command does not create a new process it just replaces the bash with the command to be executed. If the exec command is successful, it does not return to the calling process.
Syntax:
exec [-cl] [-a name] [command [arguments]] [redirection ...]

Options:
c: It is used to execute the command with empty environment.
a name: Used to pass a name as the zeroth argument of the command.
l: Used to pass dash as the zeroth argument of the command.
Note: exec command does not create a new process. When we run the exec command from the terminal, the ongoing terminal process is replaced by the command that is provided as the argument for the exec command.
The exec command can be used in two modes:
Exec with a command as an argument: In the first mode, the exec tries to execute it as a command passing the remaining arguments, if any, to that command and managing the redirections, if any.Example 1:Example 2:The exec command searches the path mentioned in the $PATH variable to find a command to be executed. If the command is not found the exec command as well as the shell exits in an error.
Example 1:
Example 2:
The exec command searches the path mentioned in the $PATH variable to find a command to be executed. If the command is not found the exec command as well as the shell exits in an error.
Exec without a command: If no command is supplied, the redirections can be used to modify the current shell environment. This is useful as it allows us to change the file descriptors of the shell as per our desire. The process continues even after the exec command unlike the previous case but now the standard input, output, and error are modified according to the redirections.Example:Here the exec command changes the standard out of the shell to the tmp file and so all the commands executed after the exec command write their results in that file. This is one of the most common ways of using exec without any commands.
Example:
Here the exec command changes the standard out of the shell to the tmp file and so all the commands executed after the exec command write their results in that file. This is one of the most common ways of using exec without any commands.
linux-command
Linux-Shell-Commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python PostgreSQL – Update Table

07 Dec, 2021
In this article, we will see how to Update data in PostgreSQL using python and Psycopg2. The update command is used to modify the existing record in the table. By default whole records of the specific attribute are modified, but to modify some particular row, we need to use the where clause along with the update clause.
Syntax for Update Clause
UPDATE table_name SET column1=value1,column2=value2,...
Here we are going to see how to update the columns of the table. The table after modification looks like the table shown below. As we can see for every tuple state value is changed to Kashmir. 
Python3
# importing psycopg2 moduleimport psycopg2 # establishing the connectionconn = psycopg2.connect(   database="postgres",    user='postgres',    password='password',    host='localhost',    port= '5432') # creating a cursor objectcursor = conn.cursor() # query to update table with where clausesql='''update Geeks set state='Kashmir'; ''' # execute the querycursor.execute(sql)print('table updated..') print('table after updation...')sql2='''select * from Geeks;'''cursor.execute(sql2); # print table after modificationprint(cursor.fetchall()) # Commit your changes in the databaseconn.commit() # Closing the connectionconn.close()# code
Output
table updated..
table after updation...
[(1,'Babita','kashmir'),(2,'Anushka','Kashmir'),(3,'Anamika','Kashmir'),
(4,'Sanaya','Kashmir'),(5,'Radha','Kashmir')]
Here we will use the where clause along with the update table.
Syntax: UPDATE Geeks set state=’Delhi’ where id=2;
We can see state of the row having id 2 is changed from Hyderabad to Delhi.
Python3
# importing psycopg2 moduleimport psycopg2 # establishing the connectionconn = psycopg2.connect(   database="postgres",    user='postgres',    password='password',    host='localhost',    port= '5432') # create a cursor objectcursor = conn.cursor() # query to update tablesql='''update Geeks set state='Delhi' where id='2'; ''' # execute the querycursor.execute(sql)print("Table updated..") print('Table after updation...') # query to display Geeks tablesql2='select * from Geeks;' # execute querycursor.execute(sql2); # fetching all detailsprint(cursor.fetchall()); # Commit your changes in the databaseconn.commit() # Closing the connectionconn.close()
Output:
Table updated..
Table after updation...
[(1, 'Babita', 'Bihar'), (3, 'Anamika', 'Banglore'), 
(4, 'Sanaya', 'Pune'), (5, 'Radha', 'Chandigarh'),
 (2, 'Anushka', 'Delhi')]
as5853535
avtarkumar719
Picked
Python PostgreSQL
Python Pyscopg2
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Generate Database Dump of MySQL Database in Linux?

30 Jun, 2021
We will learn how to Backup and Restore your MySQL Database with Mysqldump query in LINUX.  We had always a need that if the production database is corrupted somehow, we should be able to recover it, for recovering we should always keep a backup of the database at particular instances. So, data rollback can be done.
First, we will create a Database in our system. We will need LAMPP and APACHE Software for this purpose.
Step 1: Create a database using the below command:
CREATE DATABASE geeksforgeeks;
Step 2: Use the database using the below command:
USE geeksforgeeks;
Step 3: Create a table in this database as shown below:
CREATE TABLE employeeData(ID INT(10),
            Name VARCHAR(255),
            Designation VARCHAR(255),
            Address VARCHAR(255),
            Branch VARCHAR(255)
            );
Step 4: Describe this table to see if it is correctly created or not:
DESC employeeData;
Employee Data Table is successfully created
Step 5: Insert some data in this table.
INSERT INTO `employeedata`(`ID`, `Name`, `Designation`, `Address`, `Branch`) VALUES (1,"Devesh Pratap Singh","Software Engineer","Uttar Pradesh, India", "Noida");
INSERT INTO `employeedata`(`ID`, `Name`, `Designation`, `Address`, `Branch`) VALUES (2,"Megha Arele","Web Developer","Uttar Pradesh, India", "Noida");
INSERT INTO `employeedata`(`ID`, `Name`, `Designation`, `Address`, `Branch`) VALUES (3,"Aditya Srivastava","Research Analyst","Uttar Pradesh, India", "Noida");
INSERT INTO `employeedata`(`ID`, `Name`, `Designation`, `Address`, `Branch`) VALUES (4,"Tanishka Sharma","Jr. Architect","Uttar Pradesh, India", "Noida");
INSERT INTO `employeedata`(`ID`, `Name`, `Designation`, `Address`, `Branch`) VALUES (3,"Divyanshi Upadhyay","Jr. Architect","Uttar Pradesh, India", "Noida");
Step 6: Dump the data for backup for restoring purposes with the below command:
mysqldump -u root -p geeksforgeeks > ~/Desktop/backup_db.sql
After running this command you will get the dumped database on your desktop.
Output File
mysql
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PLSQL | CONCAT Function

18 Sep, 2019
The string in PL/SQL is actually a sequence of characters with an optional size specification.The characters could be numeric, letters, blank, special characters or a combination of all.The CONCAT function allows you to concatenate two strings together. To CONCAT more than two values, we can nest multiple CONCAT function calls.
Syntax:
CONCAT( string1, string2 )
Parameters Used:
string1: It is used to specify the first string to concatenate.string2: It is used to specify the second string to concatenate.
string1: It is used to specify the first string to concatenate.
string2: It is used to specify the second string to concatenate.
Supported Versions of Oracle/PLSQL:
Oracle 12cOracle 11gOracle 10gOracle 9iOracle 8i
Oracle 12c
Oracle 11g
Oracle 10g
Oracle 9i
Oracle 8i
Example-1:
DECLARE 
   Test_String string(10) := 'Hello ';
   Test_String2 string(10) := 'world!';
   
BEGIN 
   dbms_output.put_line(CONCAT(Test_String, Test_String2)); 
   
END; 
Output:
Hello world! 
Example-2:
DECLARE 
   Test_String string(10) := 'Geeks';
   Test_String2 string(10) := 'For';
   Test_String3 string(10) := 'Geeks';
   
BEGIN 
   dbms_output.put_line(CONCAT(CONCAT(Test_String, Test_String2), Test_String3)); 
   
END; 
Output:
GeeksForGeeks 
SQL-PL/SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
INET_ATON() function in MySQL

14 Dec, 2020
INET_ATON() :
This function in MySQL takes the dotted-quad representation of an IPv4 address as a string and returns the numeric value of the given IP address in form of an integer. If the input address is not a valid IPv4 address this function returns NULL. The return address is calculated by the following formula :
If the given input IPv4 address is a.b.c.d then the return value a×2563+ b×2562+ c×2561 + d
Syntax :
INET_ATON(expr)
Parameter : 
This method accepts only one parameter.
expr – Input IPv4 address represented by a string.
Returns : 
It returns the numeric value of a given IPv4 address.
Example-1 :
Checking the equivalent integer representation for the following address “1.6.5.0” with the help of INET_ATON Function. As it is a valid IPv4 address we will get results in an integer.
SELECT INET_ATON('1.6.5.0')  AS AddressInInteger ;
Output :
Example-2 :
Checking the equivalent integer representation for the following address “::1.6” with the help of INET_ATON Function. As it is not a valid IPv4 address we will get NULL.
 SELECT INET_ATON('::1.6')  AS AddressInInteger ;
Output :
Example -3 :
Checking the equivalent integer representation for the following address “115.16.55.255” with the help of INET_ATON Function. As it is a valid IPv4 address we will get results in an integer.
 SELECT INET_ATON('15.16.55.255')  AS AddressInInteger ;
Output :
Example-4 :
Checking the equivalent integer representation for the following IPv6 address “fdfe::5a55:caff:fefa:9089” with the help of INET_ATON Function. 
SELECT INET_ATON('fdfe::5a55:caff:fefa:9089')  AS AddressInInteger ;
Output :
DBMS-SQL
mysql
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Visualize Graphs in Python

17 May, 2022
Prerequisites: Graph Data Structure And Algorithms
A Graph is a non-linear data structure consisting of nodes and edges. The nodes are sometimes also referred to as vertices and the edges are lines or arcs that connect any two nodes in the graph.
In this tutorial we are going to visualize undirected Graphs in Python with the help of networkx library.
Installation:
To install this module type the below command in the terminal.
pip install networkx
Below is the implementation.
# First networkx library is imported # along with matplotlibimport networkx as nximport matplotlib.pyplot as plt     # Defining a Classclass GraphVisualization:       def __init__(self):                  # visual is a list which stores all         # the set of edges that constitutes a        # graph        self.visual = []              # addEdge function inputs the vertices of an    # edge and appends it to the visual list    def addEdge(self, a, b):        temp = [a, b]        self.visual.append(temp)              # In visualize function G is an object of    # class Graph given by networkx G.add_edges_from(visual)    # creates a graph with a given list    # nx.draw_networkx(G) - plots the graph    # plt.show() - displays the graph    def visualize(self):        G = nx.Graph()        G.add_edges_from(self.visual)        nx.draw_networkx(G)        plt.show()  # Driver codeG = GraphVisualization()G.addEdge(0, 2)G.addEdge(1, 2)G.addEdge(1, 3)G.addEdge(5, 3)G.addEdge(3, 4)G.addEdge(1, 0)G.visualize()
Output:
graph-basics
Python-matplotlib
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Simplification and Approximation - GeeksforGeeks

13 May, 2016
10152 = (1000+15)2
= 10002 + 152 +2 x 1000 x 15
=1000000 + 225 + 30000
=1030225
10152 = (1000+15)2
= 10002 + 152 +2 x 1000 x 15
=1000000 + 225 + 30000
=1030225
103 x 103 + 97 x 97
= (100+3)2 + (100-3)2
= 2 (1002 + 32 )  
[ (X +Y)2 + ( X – Y)2 = 2 ( X2 + Y2 ) ]
= 2 (10000 + 9 )
= 2 x 10009
= 20018
9848 x 125 = 9848 x (250 / 2)
           = 4924 x (500 / 2)
           = 2462 x (1000 / 2)
           = 1231 x (1000)
           = 1231000
Let X=500 & Y=12
Now, (X + Y)2 + (X – Y)2 = 2 ( X2 + Y2 )
		        = 2 ( 5002 + 122 )
 			= 2 ( 250000 + 144 )
 			= 2 * 250144
 			= 500288

Let (x / √216) = (√96 / x)

Then x2 = √(216 x 96)
       = √(36 x 2 x 3 x 16 x 2 x 3)
       = √(62 x 42 x 22 x 32)
       = 6 x 4 x 2 x 3
       = 144
Or x = 12

Given series is a G. P. with a = 7, r = 7 and n = 6

∴ Sn = a(rn-1) / (r-1)

∴ Sn = 7(76-1) / 6

  Sn = = 137256
  1 1    <- CARRY

  5 X 8
+ 3 Y 4
+ 2 Z 1
--------
 11 0 3
--------

In 267 unit digit is 7 and cyclicity of 7 is 4.
So, (267)153 can be written as (267)Rem(153)/4 = (267)1 
Unit digit of (267)1 = 7.
similarly for 66666 unit digit is 6 and cyclicity for 6 is 1.
Unit digit for (66666)72 = 6.

Therefore , Unit digit of the resultant is 7 * 6 = 2
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Must Do Coding Questions for Companies like Amazon, Microsoft, Adobe, ...
Must Do Coding Questions for Product Based Companies
Types of Distributed System
SDE SHEET - A Complete Guide for SDE Preparation
DSA Sheet by Love Babbar
Java Threads
Top 20 Puzzles Commonly Asked During SDE Interviews
Optimization of Basic Blocks
Tejas Networks Interview Experience  for R&D Engineer
TCS NQT Coding Sheet
GATE | GATE CS 2019 | Question 19

14 Feb, 2019
Let G be an undirected complete graph on n vertices, where n > 2. Then, the number of different Hamiltonian cycles in G is equal to
(A) n!(B) n – 1!(C) 1(D) (n-1)! / 2Answer: (D)Explanation: A simple circuit in a graph G that passes through every vertex exactly once is called a Hamiltonian circuit.
In an undirected complete graph on n vertices, there are n permutations are possible to visit every node. But from these permutations, there are:
n different places (i.e., nodes) you can start;2 (clockwise or anticlockwise) different directions you can travel.
n different places (i.e., nodes) you can start;
2 (clockwise or anticlockwise) different directions you can travel.
So any one of these n! cycles is in a set of 2n cycles which all contain the same set of edges. So there are,
= (n)! / (2n)
= (n−1)! / 2 distinct Hamilton cycles. 
Option (D) is correct.Quiz of this Question
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE-CS-2014-(Set-3) | Question 20
GATE | GATE CS 2008 | Question 46
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE CS 2008 | Question 40
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2014-(Set-1) | Question 51
GATE | GATE CS 1996 | Question 63
GATE | GATE-CS-2004 | Question 31
How to Remove Firebase Authentication in Android Studio?

29 Dec, 2021
Android Studio is the official IDE (Integrated Development Environment) for Android app development and it is based on JetBrains’ IntelliJ IDEA software. Android Studio provides many excellent features that enhance productivity when building Android apps, such as:
A blended environment where one can develop for all Android devices
Apply Changes to push code and resource changes to the running app without restarting the app
A flexible Gradle-based build system
A fast and feature-rich emulator
GitHub and Code template integration to assist you to develop common app features and importing sample code
Extensive testing tools and frameworks
C++ and NDK support
Built-in support for Google Cloud Platform, making it easy to integrate Google Cloud Messaging and App Engine, and many more.
Here, we are going to Remove Firebase Authentication in Android Studio. We are going to remove the firebase project connected to our app. This feature can be implemented when want to change the firebase project connected to our app. We can simply remove the connect project and then we can add another project with our app.
Step 1: Go to the top and Click on Project
Step 2: Here Go to the google-services.json file
Step 3: Here, Right Click on it and then Select Show in Explorer and then close Android Studio of our current app. Then delete this file from your folder
Step 4: Now, Move to build.gradle (project) and remove this line
classpath 'com.google.gms:google-services:4.2.0'
Remove this line also from the build.gradle (app)
implementation 'com.google.firebase:firebase-database:19.0.0'
implementation 'com.google.firebase:firebase-storage:19.1.1'
implementation 'com.google.firebase:firebase-auth:19.0.0'
Remove this line also from the build.gradle (app)
apply plugin: 'com.google.gms.google-services'
Now we have successfully removed the firebase project from our app. Now we can either add another Firebase project or leave.
Android-Studio
Android
Android
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.