code-rag-bench/online-tutorials huggingface dataset:
TIME() function in MYSQL

27 Nov, 2020
TIME() function in MySQL is used to extracts the time part from a given time/datetime expression. If the expression is not a time or a datetime value, the TIME function will return ’00:00:00′. If expression is NULL, the TIME function will return NULL.
Syntax :
TIME(expression)

Parameter :This method accepts one parameter.
expression : The time or datetime value from which we want to extract the time.
Returns :It returns the time part from a given time/datetime expression.
Example-1 :Extracting the time using TIME Function from a datetime expression where the datetime is specified in the format of YYYY-MM-DD HH-MM-SS.
SELECT TIME("2019-01-10 08:14:21")as Time ;

Output :
Example-2 :Extracting the time using TIME Function from a datetime expression where the datetime is specified in the format of HH-MM-SS.
SELECT TIME("18:24:23")as Time ;

Output :
Example-3 :Extracting the time using TIME Function from a expression which is not a datetime.
SELECT TIME(NULL) AS TIME;

Output :
Example-4 :The TIME function can be used to set value of columns. To demonstrate create a table named DeliveryDetails.
CREATE TABLE DeliveryDetails (
DeliveryId INT AUTO_INCREMENT,
ProductId INT NOT NULL,
ProductName VARCHAR(20) NOT NULL,
Delivered_At TIME NOT NULL,
PRIMARY KEY(DeliveryId)
);
Here, we will use TIME function when a delivery will be completed. The value in Delivered_At column will be the value given by TIME Function.
INSERT INTO  
DeliveryDetails(ProductId, ProductName, Delivered_At)
VALUES
(12345, 'Let Us Java', TIME (NOW()));

Now, checking the DeliveryDetails table :
SELECT * FROM DeliveryDetails;

Output :
DBMS-SQL
mysql
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL using Python
Introduction to NoSQL
Window functions in SQL
How to Update Multiple Columns in Single Update Statement in SQL?
SQL Interview Questions | Set 1
Advantages and Disadvantages of SQL
SQL | Subquery
SQL | Sub queries in From Clause
What is Temporary Table in SQL?
SQL vs NoSQL: Which one is better to use?
Read a record from a File in C++ using seekg() and tellg()

26 Apr, 2021
Given that a binary file “student.data” is already loaded in the memory of the computer with the record of 100 students, the task is to read the Kth record and perform some operations.seekg() is a function in the iostream library (part of the standard library) that allows you to seek to an arbitrary position in a file. It is used in file handling to sets the position of the next character to be extracted from the input stream from a given file. For example :  
Input: "Hello World" 
Output: World
The tellg() function is used with input streams and returns the current “get” position of the pointer in the stream. It has no parameters and returns a value of the member type pos_type, which is an integer data type representing the current position of the get stream pointer.Approach:Given that there are 100 records in the binary file “student.dat” and K = 7 
Step 1: The statement fs.seekg(7*sizeof(student)) places the reading pointer to 168(->7*22) index of the file (based on ‘0’ based indexing)  
Step 2:The statement fs.read((char*)this;sizeof(student)); reads the record and now the read pointer is at the starting of 8th record. Therefore the statement fs.tellg()/sizeof(s) results to value 8 and the output of “fs.tellg()/sizeof(s)+1” is 8 + 1 = 9  
Step 3: The statement fs.seekg(0, ios::end) places the pointer to the end of the file and hence fs.seekg(0, ios::end)/sizeof(s) gives 100  
Below is the implementation of the above approach: 
CPP
// C++ program to Read a record from a File// using seekg() and tellg() #include <bits/stdio.h>using namespace std; class student {    int id;    char Name[20]; public:    void display(int K);}; void student::display(int K){    fstream fs;    fs.open("student.dat", ios::in | ios::binary);     // using seekg(pos) method    // to place pointer at 7th record    fs.seekg(K * sizeof(student));     // reading Kth record    fs.read((char*)this, sizeof(student));     // using tellg() to display current position    cout << "Current Position: "         << "student no: "         << fs.tellg() / sizeof(student) + 1;     // using seekg()place pointer at end of file    fs.seekg(0, ios::end);     cout << " of "         << fs.tellg() / sizeof(student)         << endl;    fs.close();} // Driver codeint main(){     // Record number of the student to be read    int K = 7;     student s;    s.display(K);     return 0;}
Output:  
Current Position: student no: 9 of 100
 
 
ManasChhabra2
cpp-file-handling
C++ Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Shallow Copy and Deep Copy in C++
C++ Program to check if a given String is Palindrome or not
How to find the minimum and maximum element of a Vector using STL in C++?
C++ Program for QuickSort
delete keyword in C++
C Program to Swap two Numbers
Passing a function as a parameter in C++
cin in C++
Enumerated Types or Enums in C++
Const keyword in C++
How to Install Google Chrome in Arch-based Linux Distributions?

05 Oct, 2021
Google Chrome is a world-wide very popular browser. Google Chrome is not an open-source project, hence chrome is not preinstalled on Linux systems. The installation of Google Chrome on Linux distributions like Ubuntu is very easy. For Arch Linux and Arch-based distributions, Google Chrome is available on Arch User Repository(AUR).
We will install google-chrome on arch Linux by two methods.
For installation of packages from the AUR, We can use the AUR helper to install Google Chrome. To install chrome on Arch Linux, first, we need to install the AUR helper on the system.
There are many AUR helpers by using which we can install the AUR packages, but for this tutorial, we are going to use yay AUR helper. To install the yay AUR helper, first, we need to install the git and base-devel group package on the system. So to install the git on the system, use the following command:
sudo pacman -S --needed base-devel git
To install yay on the Arch, use the following commands:
git clone https://aur.archlinux.org/yay-git.git
cd yay-git
makepkg -sri
Now we have installed the yay AUR helper on the system. yay provide similar flags like Pacman to manage the packages. So to install the packages using the yay use -S option with yay command. 
To install the google-chrome on Arch with yay, use the following command:
yay -S google-chrome
Yay shows all package related to the Google Chrome and ask to choose which package have to install. So we have chosen default (1) package.
Packages installed with yay are not upgraded with pacman command, we have to upgrade the chrome with the yay AUR helper. To update the package use -Suy option with yay command.
yay -Suy
This command will update all packages.
We can install the google-chrome without using the AUR helper by cloning the repo from the AUR.
 To install the packages from AUR we must have installed the git and base-devel group package on the system. To install these packages, use the following command:
sudo pacman -S --needed base-devel git
To install the chrome, clone the google-chrome AUR repo. Use the following command to install Google Chrome:
git clone https://aur.archlinux.org/google-chrome.git
cd google-chrome
makepkg -sri
We have to manually upgrade the google-chrome when its new version is available on the AUR repo. So to upgrade the package using the following command in the chrome repo cloned directory.
git pull
makepkg -si
how-to-install
How To
Installation Guide
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to set default values when destructuring an object in JavaScript ?

23 Dec, 2020
Destructuring in JavaScript: Destructuring was introduced in ECMA Script 6 version. It is a concept that is used to unpack or free values from arrays and objects into variables. The values corresponding to array elements or object properties get stored in the variables.
Example:
Javascript
var a, b;[a, b] = [10, 20];  console.log(a);  console.log(b);
Output:
10
20
In Arrays: In Arrays, values of corresponding elements get stored in the variables.
Example 1: In order to give default values in arrays when applying the destructuring concept in arrays, we need to initialize values with some value. In this way the default values will be assigned to the variables. Below is the implementation via an example of this concept.
Javascript
let a, b, c ;[a, b,c = 30] = [10, 20];  console.log(a);  console.log(b);  console.log(c);
Output:
10
20
30
Example 2: If any value is present for the respective variable then it will take that value or else then it will take the default variable. Below code snippet explains the behaviours in a more lucid and elaborative way. 
Javascript
let a, b, c;[a, b,c = 30] = [10, 20, 50];  console.log(a);  console.log(b);  console.log(c);
Output: If we are not having ’50’ in that array then ‘c’ would have a ’30’ value.
10
20
50
In Objects: The values of corresponding properties get stored in the variables.
Example 1: The application and implementation of destructuring in objects are also the same as in arrays. Below are the two code snippets on how to use default values in objects.
Javascript
const student = {    name: "Krishna"}const { name, age = 18 } = student;   console.log(name);  console.log(age);
Output:
Krishna
18
Example 2:
Javascript
const student = {    name: "Krishna",    age : 21}const { name, age = 18 } = student;   console.log(name);  console.log(age);
Output:
Krishna
21 
JavaScript-Misc
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SVG - Stroke

SVG supports multiple stroke properties.
Following are the main stroke properties used.
<html>
   <title>SVG Stroke</title>
   <body>
   
      <h1>Sample SVG Stroke</h1>
      
      <svg width="800" height="800">
         <g>
            <text x="30" y="30" >Using stroke: </text>
            <path stroke="red" d="M 50 50 L 300 50" />
            <path stroke="green" d="M 50 70 L 300 70" />
            <path stroke="blue" d="M 50 90 L 300 90" />
         </g> 
      </svg>
   
   </body>
</html>
Open textSVG.htm in Chrome web browser. You can use Chrome/Firefox/Opera to view SVG image directly without any plugin. Internet Explorer 9 and higher also supports SVG image rendering.
<html>
   <title>SVG Stroke</title>
   <body>
      
      <h1>Sample SVG Stroke</h1>
      
      <svg width="800" height="800">
         <text x="30" y="10" >Using stroke-width: </text>
         <path stroke-width="2" stroke="black" d="M 50 50 L 300 50" />
         <path stroke-width="4" stroke="black" d="M 50 70 L 300 70" />
         <path stroke-width="6" stroke="black" d="M 50 90 L 300 90" />
      </svg>
      
   </body>
</html>
Open textSVG.htm in Chrome web browser. You can use Chrome/Firefox/Opera to view SVG image directly without any plugin. Internet Explorer 9  and higher also supports SVG image rendering.
<html>
   <title>SVG Stroke</title>
   <body>
      
      <h1>Sample SVG Stroke</h1>
      
      <svg width="800" height="800">
         <g>
            <text x="30" y="30" >Using stroke-linecap: </text>
         
            <path stroke-linecap="butt" stroke-width="6" 
            stroke="black" d="M 50 50 L 300 50" />
         
            <path stroke-linecap="round" stroke-width="6" 
            stroke="black" d="M 50 70 L 300 70" />
         
            <path stroke-linecap="square" stroke-width="6"
            stroke="black" d="M 50 90 L 300 90" />
         </g>
      </svg>
   
   </body>
</html>
Open textSVG.htm in Chrome web browser. You can use Chrome/Firefox/Opera to view SVG image directly without any plugin. Internet Explorer 9 and higher also supports SVG image rendering.
<html>
   <title>SVG Stroke</title>
   <body>
   
      <h1>Sample SVG Stroke</h1>
      
      <svg width="800" height="800">
         <g>
            <text x="30" y="30" >Using stroke-dasharray: </text>
            
            <path stroke-dasharray="5,5" stroke-width="6" 
            stroke="black" d="M 50 50 L 300 50" />
            
            <path stroke-dasharray="10,10" stroke-width="6" 
            stroke="black" d="M 50 70 L 300 70" />
            
            <path stroke-dasharray="20,10,5,5,5,10" stroke-width="6" 
            stroke="black" d="M 50 90 L 300 90" />
         </g>
      </svg>
   
   </body>
</html>
Open textSVG.htm in Chrome web browser. You can use Chrome/Firefox/Opera to view SVG image directly without any plugin. Internet Explorer 9  and higher also supports SVG image rendering.

    45 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
Enable and disable interrupts in Arduino

If you wish to disable interrupts (when executing some critical piece of code, especially one which should be completed within a given time period), you can do that with the help of the noInterrupts() function.
Once your critical code has executed and you wish to re-enable the interrupts, you can do that using interrupts() function. Note that interrupts are enabled by default in Arduino, and therefore, calling interrupts() without an initial call to noInterrupts() is unnecessary.
The general structure of a code containing noInterrupts() and interrupts() is given below −
void setup() {
   // put your setup code here, to run once:
}

void loop() {
   // put your main code here, to run repeatedly:

   noInterrupts();
   //Add critical code that needs to be completed in a specific time below

   interrupts();
   //Add non-critical code, that can tolerate interruptions, below

}
How to measure time taken by a function in C? - GeeksforGeeks

29 May, 2017
To calculate time taken by a process, we can use clock() function which is available time.h. We can call the clock function at the beginning and end of the code for which we measure time, subtract the values, and then divide by CLOCKS_PER_SEC (the number of clock ticks per second) to get processor time, like following.
     #include <time.h>
     
     clock_t start, end;
     double cpu_time_used;
     
     start = clock();
     ... /* Do the work. */
     end = clock();
     cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;

Following is a sample C program where we measure time taken by fun(). The function fun() waits for enter key press to terminate.
/* Program to demonstrate time taken by function fun() */#include <stdio.h>#include <time.h>  // A function that terminates when enter key is pressedvoid fun(){    printf("fun() starts \n");    printf("Press enter to stop fun \n");    while(1)    {        if (getchar())            break;    }    printf("fun() ends \n");}  // The main program calls fun() and measures time taken by fun()int main(){    // Calculate the time taken by fun()    clock_t t;    t = clock();    fun();    t = clock() - t;    double time_taken = ((double)t)/CLOCKS_PER_SEC; // in seconds      printf("fun() took %f seconds to execute \n", time_taken);    return 0;}
Output: The following output is obtained after waiting for around 4 seconds and then hitting enter key.
fun() starts
Press enter to stop fun

fun() ends
fun() took 4.017000 seconds to execute

How to find time taken by a command/program on Linux Shell?
References:http://www.gnu.org/software/libc/manual/html_node/CPU-Time.htmlhttp://www.cplusplus.com/reference/ctime/clock/?kw=clock
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
cpp-puzzle
C Language
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Multidimensional Arrays in C / C++
Left Shift and Right Shift Operators in C/C++
Different methods to reverse a string in C/C++
Command line arguments in C/C++
fork() in C
Vector in C++ STL
Inheritance in C++
Initialize a vector in C++ (6 different ways)
Socket Programming in C/C++
Map in C++ Standard Template Library (STL)
What is the use of the "export" clause in a module-info file in Java 9?

A Module is a combination of both code and data that has a name, declares dependencies on other modules, exports packages that contain the public types that can be accessible outside this module and specifies the services it uses or the service implementations it provides. All of these have specified in a module-info.java file, which is included in the root directory of a module.
There are two types of "export" clause can be used in "module-info.java" file.
1) export <package>: By default, the type public of a module is no longer visible outside the module. To make the public types of a given package visible from other modules, we must export this package. We must keep in mind that we are at the package level and not at the unit level of a type. But, sub-packages are not exported.
We need to allow other modules to use the classes and interfaces of the package tp.com.tutorialspoint.model, we can write as below:
module com.tutorialspoint.model {
   exports tp.com.tutorialspoint.model;
}
It's very important to understand that a package can only be present in only one module. Otherwise, we will get an error as below:
Error:(1, 1) java: package exists in another module:
2) export <package> to <module>: We can strengthen the security of our modules by reducing the visibility of certain packages to a finite list of modules: only the modules listed will be able to access these classes.
module com.tutorialspoint.model {
   exports tp.com.tutorialspoint.model
      to com.tutorialspoint.gui;
}
ReactJS - Keys

React keys are useful when working with dynamically created components or when your lists are altered by the users. Setting the key value will keep your components uniquely identified after the change.
Let's dynamically create Content elements with unique index (i). The map function will create three elements from our data array. Since the key value needs to be unique for every element, we will assign i as a key for each created element.
import React from 'react';

class App extends React.Component {
   constructor() {
      super();
		
      this.state = {
         data:[
            {
               component: 'First...',
               id: 1
            },
            {
               component: 'Second...',
               id: 2
            },
            {
               component: 'Third...',
               id: 3
            }
         ]
      }
   }
   render() {
      return (
         <div>
            <div>
               {this.state.data.map((dynamicComponent, i) => <Content 
                  key = {i} componentData = {dynamicComponent}/>)}
            </div>
         </div>
      );
   }
}
class Content extends React.Component {
   render() {
      return (
         <div>
            <div>{this.props.componentData.component}</div>
            <div>{this.props.componentData.id}</div>
         </div>
      );
   }
}
export default App;
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App.jsx';

ReactDOM.render(<App/>, document.getElementById('app'));
We will get the following result for the Key values of each element.
If we add or remove some elements in the future or change the order of the dynamically created elements, React will use the key values to keep track of each element.

    20 Lectures 
     1.5 hours 

 Anadi Sharma

    60 Lectures 
     4.5 hours 

 Skillbakerystudios

    165 Lectures 
     13 hours 

 Paul Carlo Tordecilla

    63 Lectures 
     9.5 hours 

 TELCOMA Global

    17 Lectures 
     2 hours 

 Mohd Raqif Warsi
 Print
 Add Notes
 Bookmark this page
What is MySQL event and how it is related to trigger?

A MySQL event is a task that rums based on a predefined schedule therefore sometimes it is referred to as a scheduled event. In other words, we can say that the MySQL event schedule is a process that runs in the background and constantly looks for the events to execute. It is referred to as a temporal trigger because they triggered by time and not like triggers that execute based on the table update. We can use events to run either once or at a recurring interval. They can be used to create backups, delete stale records, aggregate data for reports, and so on. Its syntax would be as follows −
CREATE EVENT event_name
   ON SCHEDULE schedule
DO
   Event_body
Here,
event_name is the name of the event that we must have to specify after CREATE EVENT statement. It must be unique in a database.
The schedule is the time that we need to specify so that the event can occur at that particular time or schedule. The event can be a one-time event or recurring event.
Event_body is the set of SQL statements that we need to specify after the DO keyword. It can be wrapped in BEGIN...END block if there are multiple statements.
Type Selectors in CSS

A selector is an HTML tag at which a style will be applied. This could be any tag like <h1> or <table> etc.
With the type selector, set for HTML tags like h1, h2, h3, p, etc:
h2 {
   color: #FF0000;
}
Set for p:
p {
   color: #800000;
}
How to Use Volatile Variables in Arduino?

Just like in C and C++, you need to qualify a variable with the volatile keyword if it can be modified within an interrupt routine.
When you qualify a variable as volatile, this is what happens behind the scenes −
The compiler gets instructed that the variable should be loaded into the RAM and not the storage register (where program variables are generally stored/manipulated)
The compiler gets instructed that the variable should be loaded into the RAM and not the storage register (where program variables are generally stored/manipulated)
This ensures that any changes to the variable outside of the loop() (for example in the interrupt service routine), get immediately reflected in the loop()
This ensures that any changes to the variable outside of the loop() (for example in the interrupt service routine), get immediately reflected in the loop()
If you have a variable larger than a byte in size (int or long), then an 8-bit microcontroller, like in Arduino Uno, will read the variable in steps of 8 bytes each. This can cause a problem (the next 8 bytes of the variable may have changed while the microcontroller was reading the first 8 bytes). This can cause some random errors. To avoid that, you can use one of the following approaches −
Use the ATOMIC_BLOCK macro (this converts the read operation to an atomic operation, wherein the contents cannot be altered while being read). You will need to include <util/atomic.h> for this, and the syntax is given here.
Use the ATOMIC_BLOCK macro (this converts the read operation to an atomic operation, wherein the contents cannot be altered while being read). You will need to include <util/atomic.h> for this, and the syntax is given here.
Disable interrupts using noInterrupts() while the variable is being read.
Disable interrupts using noInterrupts() while the variable is being read.
An example with volatile variables is given below −
#include <util/atomic.h>
volatile int flag = 0;
int flagValue = 0;
void setup() {
   Serial.begin(9600);
   pinMode(LED_BUILTIN, OUTPUT);
   attachInterrupt(digitalPinToInterrupt(2), interruptFunction, CHANGE);
}
void loop() {
   ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
      // code with interrupts blocked (consecutive atomic operations will
not get interrupted)
      flagValue = flag;
   }
   if (flagValue == 1) {6305298009
      flag = 0;
      flagValue = 0;
      Serial.println("Interrupt encountered!");
   }
}
void interruptFunction() {
   flag = 1;
}
Note that only flag has been defined as volatile, because it is the only variable whose value changes within the interrupt. The same code as above, using noInterrupts() would look like −
volatile int flag = 0;
int flagValue = 0;
void setup() {
   Serial.begin(9600);
   pinMode(LED_BUILTIN, OUTPUT);
   attachInterrupt(digitalPinToInterrupt(2), interruptFunction, CHANGE);
}
void loop() {
   noInterrupts();
   flagValue = flag;
   interrupts();
   if (flagValue == 1) {
      flag = 0;
      flagValue = 0;
      Serial.println("Interrupt encountered!");
   }
}
void interruptFunction() {
   flag = 1;
}
Insert a character at nth position in string in JavaScript

We are required to write a JavaScript function that takes in a string as the first argument and a number as the second argument and a single character as the third argument, let’s call this argument char.
The number is guaranteed to be smaller than the length of the array. The function should insert the character char after every n characters in the string and return the newly formed string.
For example −
If the arguments are −
const str = 'NewDelhi';
const n = 3;
const char = ' ';
Then the output string should be −
const output = 'Ne wDe lhi';
Following is the code −
const str = 'NewDelhi';
const n = 3;
const char = ' ';
const insertAtEvery = (str = '', num = 1, char = ' ') => {
   str = str.split('').reverse().join('');
   const regex = new RegExp('.{1,' + num + '}', 'g');
   str = str.match(regex).join(char);
   str = str.split('').reverse().join('');
   return str;
};
console.log(insertAtEvery(str, n, char));
Following is the output on console −
Ne wDe lhi
How to instantiate a class in C#?

Use the new operator to instantiate a class in C#.
Let’s say our class is Line. Instantiation will create a new object as shown below −
Line line = new Line();
Using the object, you can now call the method −
line.setLength(6.0);
Let us see the example −
 Live Demo
using System;

namespace LineApplication {
   class Line {
      private double length; // Length of a line

      public Line() {
         Console.WriteLine("Object is being created");
      }
      public void setLength( double len ) {
         length = len;
      }
      public double getLength() {
         return length;
      }

      static void Main(string[] args) {
         Line line = new Line();

         // set line length
         line.setLength(6.0);
         Console.WriteLine("Length of line : {0}", line.getLength());
      }
   }
}
Object is being created
Length of line : 6
Lodash _.snakeCase() Method - GeeksforGeeks

09 Sep, 2020
The _.snakeCase() method is used to convert string to snake case. Snake case refers to combines words into a lower case string with underscores(_) between words.
Syntax:
_.snakeCase( [string=''] )

Parameters: This method accepts a single parameter as mentioned above and described below:
string: This parameter holds the string to convert.
Return Value: This method returns the snake cased string.
Below example illustrate the Lodash _.snakeCase() Method in JavaScript:
Example 1:
Javascript
// Requiring the lodash library  const _ = require("lodash");        // Use of _.snakeCase() method console.log(_.snakeCase('Geeks For Geeks')); console.log(_.snakeCase('GeeksForGeeks'));console.log(_.snakeCase('@#$%GeeksForGeeks@#$%'));
Output:
'geeks_for_geeks'
'geeks_for_geeks'
'geeks_for_geeks'

Example 2:  
Javascript
// Requiring the lodash library  const _ = require("lodash");        // Use of _.snakeCase() method console.log(_.snakeCase(null)); console.log(_.snakeCase('123456789'));console.log(_.snakeCase("gfg.Id"));
Output:
''
'123456789'
'gfg_id'

JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
How to Open URL in New Tab using JavaScript ?
How to read a local text file using JavaScript?
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
stack swap() in C++ STL

21 Jun, 2022
Stacks are a type of container adaptors with LIFO(Last In First Out) type of work, where a new element is added at one end and (top) an element is removed from that end only.
This function is used to swap the contents of one stack with another stack of same type but the size may vary. Syntax :
stackname1.swap(stackname2)
Parameters: The name of the stack with which the contents have to be swapped. Result: All the elements of the 2 stack are swapped. Examples:
contents of the stack from top to bottom are
Input  : mystack1 = {4, 3, 2, 1}
         mystack2 = {9, 7 ,5, 3}
         mystack1.swap(mystack2);
Output : mystack1 =  9, 7, 5, 3
         mystack2 =  4, 3, 2, 1

Input  : mystack1 = {7, 5, 3, 1}
         mystack2 = {8, 6, 4, 2}
         mystack1.swap(mystack2);
Output : mystack1 =  8, 6, 4, 2
         mystack2 =  7, 5, 3, 1
Note: In stack container, the elements are printed in reverse order because the top is printed first then moving on to other elements. 
CPP
// CPP program to illustrate// Implementation of swap() function#include <stack>#include <iostream>using namespace std; int main(){        // stack container declaration    stack<int> mystack1;    stack<int> mystack2;         // pushing elements into first stack    mystack1.push(1);    mystack1.push(2);    mystack1.push(3);    mystack1.push(4);         // pushing elements into 2nd stack    mystack2.push(3);    mystack2.push(5);    mystack2.push(7);    mystack2.push(9);         // using swap() function to swap elements of stacks    mystack1.swap(mystack2);         // printing the first stack    cout<<"mystack1 = ";    while (!mystack1.empty()) {        cout<<mystack1.top()<<" ";        mystack1.pop();    }         // printing the second stack    cout<<endl<<"mystack2 = ";    while (!mystack2.empty()) {        cout<<mystack2.top()<<" ";        mystack2.pop();    }    return 0;}
Output:
mystack1 = 9 7 5 3
mystack2 = 4 3 2 1
Time Complexity: O(1)
Auxiliary Space: O(n)
terror19_7
utkarshgupta110092
cpp-stack
cpp-stack-functions
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
VBScript Filter Function

A Filter Function, which returns a zero-based array that contains a subset of a string array based on a specific filter criteria.
Filter(inputstrings,value[,include[,compare]]) 

inputstrings, a Required parameter. This parameter corresponds to the array of strings to be searched.
inputstrings, a Required parameter. This parameter corresponds to the array of strings to be searched.
value, a Required Parameter. This parameter corresponds to the string to search for against the inputstrings parameter.
value, a Required Parameter. This parameter corresponds to the string to search for against the inputstrings parameter.
include, an Optional Parameter. This is a Boolean value, which indicates whether or not to return the substrings that include or exclude.
include, an Optional Parameter. This is a Boolean value, which indicates whether or not to return the substrings that include or exclude.
compare, an Optional Parameter. This Parameter describes what string comparison method to be used.

0 = vbBinaryCompare - Performs a binary comparison
1 = vbTextCompare - Performs a textual comparison


compare, an Optional Parameter. This Parameter describes what string comparison method to be used.
0 = vbBinaryCompare - Performs a binary comparison
0 = vbBinaryCompare - Performs a binary comparison
1 = vbTextCompare - Performs a textual comparison
1 = vbTextCompare - Performs a textual comparison
<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         a = array("Red","Blue","Yellow")
         b = Filter(a,"B")
         c = Filter(a,"e")
         d = Filter(a,"Y")

         For each x in b
           Document.write("The Filter result 1: " & x & "<br />")
         Next

         For each y in c
           Document.write("The Filter result 2: " & y & "<br />")
         Next

         For each z in d
           Document.write("The Filter result 3: " & z & "<br />")
         Next

      </script>
   </body>
</html>
When the above code is saved as .HTML and executed in Internet Explorer, it produces the following result −
The Filter result 1: Blue
The Filter result 2: Red
The Filter result 2: Blue
The Filter result 2: Yellow
The Filter result 3: Yellow


    63 Lectures 
     4 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page
resizable() method in Tkinter | Python - GeeksforGeeks

15 Apr, 2019
resizable() method is used to allow Tkinter root window to change it’s size according to the users need as well we can prohibit resizing of the Tkinter window.So, basically, if user wants to create a fixed size window, this method can be used.
How to use:
-> import tkinter
-> root = Tk()
-> root.resizable(height = None, width = None)

Arguments to be passed:
-> In resizable() method user can pass either positive integer or True, to make the window resizable.-> To make window non-resizable user can pass 0 or False.
Code #1: Allowing root window to change it’s size
# importing only  those functions# which are neededfrom tkinter import * from tkinter.ttk import * from time import strftime  # creating tkinter windowroot = Tk()root.title('Resizable')root.geometry('250x100')  Label(root, text = 'It\'s resizable').pack(side = TOP, pady = 10)  # Allowing root window to change# it's size according to user's needroot.resizable(True, True)  mainloop()
Output:Initial size – You may observe that the part inside blue circle is enabled i.e window is resizable and can be expanded. After resizing still the part inside the blue is enabled so you can still change the size of the window.
Code #2: Restricting root window to change it’s size (fixed size window).
# importing only  those functions# which are neededfrom tkinter import * from tkinter.ttk import * from time import strftime  # creating tkinter windowroot = Tk()root.title('Resizable')root.geometry('250x100')  Label(root, text = 'It\'s non-resizable').pack(side = TOP, pady = 10)  # Restricting root window to change# it's size according to user's needroot.resizable(0, 0)  mainloop()
Output:You may observe that the part inside the blue circle is disabled i.e size of the window cannot be altered.
Python-gui
Python-tkinter
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
Reading and Writing to text files in Python
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
How To Convert Python Dictionary To JSON?
Convert integer to string in Python
Check if element exists in list in Python
How to Create a Transparent button using HTML and CSS ? - GeeksforGeeks

29 Apr, 2020
The transparent button can be easily created by using HTML and CSS. In this article, we will use background-color: transparent; property to design the transparent background button.
HTML Code: In this section, we will create a basic structure of button using the button Tag.
<!DOCTYPE html><html lang="en">  <head>    <meta charset="utf-8">    <title>        Create a Transparent button        using HTML and CSS    </title></head>  <body>    <h1>GeeksforGeeks</h1>      <h3>        Create a Transparent button        using HTML and CSS    </h3>      <button class="btn">Click me!</button></body>  </html>
CSS Code: In this section, we will design the button using CSS property. We will use the background-color: transparent; property to set the button with transparent look.
<style>    body {        margin: 0;        padding: 0;        text-align: center;    }      h1 {        color: green;    }      /* Styling the button */    .btn {        cursor: pointer;        border: 1px solid #3498db;        background-color: transparent;        height: 50px;        width: 200px;        color: #3498db;        font-size: 1.5em;        box-shadow: 0 6px 6px rgba(0, 0, 0, 0.6);    }</style>
Complete Code: In this section, we will combine the above two sections to create a transparent background button.
<!DOCTYPE html><html lang="en">  <head>    <meta charset="utf-8">    <title></title>      <style>        body {            margin: 0;            padding: 0;            text-align: center;        }          h1 {            color: green;        }          /* Styling the button */        .btn {            cursor: pointer;            border: 1px solid #3498db;            background-color: transparent;            height: 50px;            width: 200px;            color: #3498db;            font-size: 1.5em;            box-shadow: 0 6px 6px rgba(0, 0, 0, 0.6);        }    </style></head>  <body>    <h1>GeeksforGeeks</h1>      <h3>        Create a Transparent button        using HTML and CSS    </h3>      <button class="btn">Click me!</button></body>  </html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
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.
How to update Node.js and NPM to next version ?
Types of CSS (Cascading Style Sheet)
How to position a div at the bottom of its container using CSS?
How to set space between the flexbox ?
How to Upload Image into Database and Display it using PHP ?
How to set the default value for an HTML <select> element ?
How to update Node.js and NPM to next version ?
Hide or show elements in HTML using display property
How to set input type date in dd-mm-yyyy format using HTML ?
HTML Cheat Sheet - A Basic Guide to HTML
How to declare a tuple in C#?

To declare a tuple the following is the format wherein we have a tuple with int and string items −
Tuple<int, string> tuple = new Tuple<int, string>(20, "Tom");
Now, check for first item in the tuple, which is an integer −
if (tuple.Item1 == 99) {
   Console.WriteLine(tuple.Item1);
}
Now check for second item in the tuple, which is a string −
if (tuple.Item2 == "Tim") {
   Console.WriteLine(tuple.Item2);
}
The following is an example to create a tuple with string and int items −
using System;
using System.Threading;

namespace Demo {
   class Program {

      static void Main(string[] args) {

         Tuple<int, string> tuple = new Tuple<int, string>(50, "Tom");

         if (tuple.Item1 == 99) {
            Console.WriteLine(tuple.Item1);
         }

         if (tuple.Item2 == "Tim") {
            Console.WriteLine(tuple.Item2);
         }
      }
   }
}
Fetch maximum individual marks for a student with marks1 and marks2 records in MySQL?

For this, use MAX() along with GROUP BY clause. Let us first create a table −
mysql> create table DemoTable
   -> (
   -> StudentEmailId varchar(20),
   -> Marks1 int,
   -> Marks2 int
-> );
Query OK, 0 rows affected (0.90 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('John@gmail.com',45,32);
Query OK, 1 row affected (0.30 sec)
mysql> insert into DemoTable values('John@gmail.com',32,45);
Query OK, 1 row affected (0.34 sec)
mysql> insert into DemoTable values('Carol@gmail.com',32,45);
Query OK, 1 row affected (1.64 sec)
mysql> insert into DemoTable values('David@gmail.com',45,32);
Query OK, 1 row affected (0.18 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable ;
This will produce the following output −
+-----------------+--------+--------+
| StudentEmailId  | Marks1 | Marks2 |
+-----------------+--------+--------+
| John@gmail.com |      45 |     32 |
| John@gmail.com |      32 |     45 |
| Carol@gmail.com |     32 |     45 |
| David@gmail.com |     45 |     32 |
+-----------------+--------+--------+
4 rows in set (0.00 sec)
Here is the query to fetch maximum individual marks for a student with marks1 and marks2 records −
mysql> select StudentEmailId,max(Marks1),max(Marks2) from DemoTable
   -> group by StudentEmailId;
This will produce the following output −
+-----------------+-------------+-------------+
| StudentEmailId  | max(Marks1) | max(Marks2) |
+-----------------+-------------+-------------+
| John@gmail.com  |          45 |          45 |
| Carol@gmail.com |          32 |          45 |
| David@gmail.com |          45 |          32 |
+-----------------+-------------+-------------+
3 rows in set (0.00 sec)
Set the size of background image using CSS ?

15 Feb, 2019
The background-size property is used to set the background image size using CSS. Use height and width property to set the size of the background image.
Syntax:
background-size: width height;
Note:
If the first value is omitted then the image takes its original width.
If the second value is omitted then the image takes its original height.
Example 1: This example sets the background-size into width and height.
<!DOCTYPE html> <html>     <head>         <title>             Set the size of background image        </title>                   <style>            #myDiv {                height: 200px;                width: 400px;                background: url("https://media.geeksforgeeks.org/wp-content/uploads/gfgbg.png");                background-size: 400px 200px;                              }        </style>    </head>          <body>         <div id= "myDiv"></div>    </body> </html>                    
Output:
Example 2: This example sets the background-size into percentage.
<!DOCTYPE html> <html>     <head>         <title>             Set the size of background image        </title>                   <style>            #myDiv {                height: 200px;                width: 400px;                background: url("https://media.geeksforgeeks.org/wp-content/uploads/gfgbg.png");                                  /* Set the background-size in percentage */                background-size: 70%;                background-repeat: no-repeat;             }        </style>    </head>          <body>         <div id= "myDiv"></div>    </body> </html>                     
Output:
CSS-Misc
Picked
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python MariaDB – Select Query using PyMySQL

14 Oct, 2020
MariaDB is an open source Database Management System and its predecessor to MySQL. The pymysql client can be used to interact with MariaDB similar to that of MySQL using Python.
In this article we will look into the process of querying data from a table of the database using pymysql.  To query data use the following syntax:
Syntax :
In order to select particular attribute columns from a table, we write the attribute names.
 SELECT attr1, attr2 FROM table_name

In order to select all the attribute columns from a table, we use the asterisk ‘*’ symbol.
SELECT * FROM table_name



Example 1 :
Python3
import pymysql  # Create a connection object# IP address of the MySQL database serverHost = "localhost"    # User name of the database serverUser = "user"        # Password for the database userPassword = ""             database = "GFG"  conn  = pymysql.connect(host=Host, user=User, password=Password, database)  # Create a cursor objectcur  = conn.cursor()    query = f"SELECT * FROM PRODUCT"  cur.execute(query)  rows = cur.fetchall()conn.close()  for row in rows :    print(row)
Output :
output of code
SQL output
The above program illustrates the connection with the MariaDB database ‘GFG‘ in which host-name is localhost, the username is ‘user’ and password is ‘your password’.
Example 2 :
Python3
import pymysql  # Create a connection object  conn  = pymysql.connect('localhost', 'user', 'password', 'database')  # Create a cursor objectcur  = conn.cursor()    query = f"SELECT price,PRODUCT_TYPE FROM PRODUCT"  cur.execute(query)  rows = cur.fetchall()conn.close()  for row in rows :    print(row)
Output :
Python-MariaDB
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Double.IsInfinity() Method in C#

10 Oct, 2021
In C#, Double.IsInfinity() is a Double struct method. This method is used to check whether a specified value evaluates to either positive infinity or negative infinity or not. While performing some mathematical operations, it is possible to obtain a result that is either positive infinity or negative infinity. For Example: If any positive value is divided by zero, it results in positive infinity. 
Syntax: public static bool IsInfinity (double d);Parameter: d: It is a double-precision floating-point number of type System.Double  
Return Type: This function return a Boolean value True, if specified value evaluates to either positive infinity or negative infinity, otherwise return False.Example:  
Input  : d = 10 / 0.0 
Output : True

Input  : d = 7.997e307 + 9.985e307
Output : True
Note: 
If the result of any floating point operation exceeds Double.MaxValue (i.e 1.79769313486232E+308) is considered as Positive Infinity and if the result is less than Double.MinValue (i.e -1.79769313486232E+308) is considered as Negative Infinity.
Floating-point operation return Infinity (Positive Infinity) or -Infinity (Negative Infinity) to indicate an overflow condition.
Code: To demonstrate the Double.IsInfinity(Double) Method 
CSHARP
// C# program to illustrate the// Double.IsInfinity() Methodusing System; class GFG {     // Main method    static public void Main()    {         // Dividing a Positive number by zero        // results in positive infinity.         double zero = 0.0;        double value = 10.0;        double result = value / zero;         // Printing result        Console.WriteLine(result);         // Check result using IsInfinity() Method        Console.WriteLine(Double.IsInfinity(result));         // Result of any operation that        // exceeds Double.MaxValue        // (i.e 1.79769313486232E+308)        // is Positive infinity        result = Double.MaxValue + 9.985e307;         // Printing result        Console.WriteLine(result);         // Check result using IsInfinity() Method        Console.WriteLine(Double.IsInfinity(result));         // Result of any operation that        // is less than Double.MinValue        // (i.e -1.79769313486232E+308)        // is Negative infinity        result = Double.MinValue - 9.985e307;         // Printing result        Console.WriteLine(result);         // Check result using IsInfinity() Method        Console.WriteLine(Double.IsInfinity(result));    }}
Infinity
True
Infinity
True
-Infinity
True
 
ruhelaa48
CSharp-Double-Struct
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Tailwind CSS Border Style

23 Mar, 2022
This class accepts more than one value in tailwind CSS in which all the properties are covered in class form. It is the alternative to the CSS border-style property. This class is used for controlling the style of an element’s borders.
Border Style Classes:
border-solid
border-dashed
border-dotted
border-double
border-none
Syntax:
<element class="border-{style}">...</element>
Example:
HTML
<!DOCTYPE html><html>  <head>    <link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"        rel="stylesheet"></head>  <body class="text-center">    <h1 class="text-green-600 text-5xl font-bold">        GeeksforGeeks    </h1>      <b>Tailwind CSS Border Style Class</b>          <div class="mx-4 grid grid-cols-5 gap-2 bg-green-200 p-2">              <!-- First sub div is not for roundig-->        <div class="border-4 border-green-900 border-solid                    bg-green-400 w-full h-12">            border-solid        </div>          <div class="border-4 border-green-900 border-dashed                    bg-green-400 w-full h-12">            border-dashed        </div>          <div class="border-4 border-green-900 border-dotted                    bg-green-400 w-full h-12">            border-dotted        </div>          <div class="border-4 border-green-900 border-double                    bg-green-400 w-full h-12">            border-double        </div>                  <div class="border-4 border-green-900 border-none                    bg-green-400 w-full h-12">            border-none        </div>    </div></body>  </html>
Output:
Tailwind CSS
Tailwind-Borders
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.