code-rag-bench/online-tutorials huggingface dataset:
How to list temporary table columns in MySQL?

To list temporary table columns in MySQL, let us first create a temporary table.
Here’s an example. We have created a temporary table with some columns that includes the details of a student −
mysql> CREATE TEMPORARY TABLE DemoTable745 (
   StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   StudentName varchar(100),
   StudentAge int,
   StudentAddress varchar(100),
   StudentCountryName varchar(20)
);
Query OK, 0 rows affected (0.00 sec)
Following is the query to list temporary table columns in MySQL−
mysql> show columns from DemoTable745;
This will produce the following output -
+--------------------+--------------+------+-----+---------+----------------+
| Field              | Type         | Null | Key | Default | Extra          |
+--------------------+--------------+------+-----+---------+----------------+
| StudentId          | int(11)      | NO   | PRI | NULL    | auto_increment |
| StudentName        | varchar(100) | YES  |     | NULL    | NULL           |
| StudentAge         | int(11)      | YES  |     | NULL    | NULL           |
| StudentAddress     | varchar(100) | YES  |     | NULL    | NULL           |
| StudentCountryName | varchar(20)  | YES  |     | NULL    | NULL           |
+--------------------+--------------+------+-----+---------+----------------+
5 rows in set (0.05 sec)
Print all odd numbers and their sum from 1 to n in PL/SQL - GeeksforGeeks

02 Jul, 2018
Prerequisite – PL/SQL introductionIn PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations.
Given a number N, the task is to display all the odd numbers from 1 to N and their sum.
Examples:
Input: 3
Output: 1, 3

Input: 5
Output: 1, 3, 5

Approach is to initialize a num with 1 and sum with 0 and keep incrementing num by 2 and sum by num until num <= N.
-- display all odd number from 1 to nDECLARE    -- declare variable num    num NUMBER(3) := 1;    sum1 NUMBER(4) := 0;BEGIN    WHILE num <= 5 LOOP        -- display odd number        dbms_output.Put_line(num);          -- the sum of all odd numbers         sum1 := sum1 + num;          --next odd number        num := num + 2;      -- end  loop    END LOOP;dbms_output.Put_line('Sum of all odd numbers is '|| sum1);END;  
Output:
1
3
5
Sum of all odd numbers is 9

SQL-PL/SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL Interview Questions
CTE in SQL
How to Update Multiple Columns in Single Update Statement in SQL?
Difference between DDL and DML in DBMS
SQL | Views
Difference between DELETE, DROP and TRUNCATE
MySQL | Group_CONCAT() Function
Difference between DELETE and TRUNCATE
SQL - ORDER BY
SQL | Subquery
Draw Plot with two Y-Axes in R - GeeksforGeeks

29 Jun, 2021
In this article, we are going to discuss how to create y-axes of both sides of a plot in R programming language.
Sometimes for quick data analysis, it is required to create a single graph having two data variables with different scales. To do that in R language we use the following steps.
First, we create a sample data, such that the sample data consists of three numeric vectors: x, y1, and y2. The x data will determine X-axis information whereas y1 and y2 will be used for two Y-Axis simultaneously.
Now, we will create a scatter plot with two different colors and y-axis values on the left and right sides of the plot. To do so, firstly we will create white space around the plot. This leave space for second y-axis. This can be done using par() method. Now, create the first plot (i.e. the red cross dots) around the first Y-Axis that takes into account data y1.
Syntax:
plot(x, y1, pch , col )
 Next, set new to TRUE in par() method. This needs to be called again after the first plot has been created. This tells the plot that a new plot will be drawn over the first one.
Syntax:
par(new = TRUE)
 Next, plot the second plot now with taking y2 data in account.
Syntax:
plot(x, y2, pch = 15, col = 3, axes = FALSE, xlab = “”, ylab = “”) 
Next set axis or any additional attribute if required.
Example:
R
# Create sample dataset.seed(2585)                             x <- rnorm(45)y1 <- x + rnorm(45)y2 <- x + rnorm(45, 7)  # Draw first plot using axis y1par(mar = c(7, 3, 5, 4) + 0.3)              plot(x, y1, pch = 13, col = 2)    # set parameter new=True for a new axispar(new = TRUE)           # Draw second plot using axis y2plot(x, y2, pch = 15, col = 3, axes = FALSE, xlab = "", ylab = "")  axis(side = 4, at = pretty(range(y2)))      mtext("y2", side = 4, line = 3)
Output:
Output
Example 2:
R
# Create sample data                            x <- c(1,2,3,4,5,6,7,8,9,10)y1 <-c(2,5,2,8,6,8,3,4,2,4)y2 <-c(2,5,3,7,5,9,7,9,4,1)  # Draw first plot using axis y1par(mar = c(7, 3, 5, 4) + 0.3)              plot(x, y1, type="l", col = 2)    # set parameter new=True for a new axispar(new = TRUE)           # Draw second plot using axis y2plot(x, y2, type="l", col = 3, axes = FALSE, xlab = "", ylab = "")  axis(side = 4, at = pretty(range(y2)))      mtext("y2", side = 4, line = 3)
Output:
Picked
R-Charts
R-Graphs
R-plots
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to import an Excel File into R ?
How to filter R DataFrame by values in a column?
Time Series Analysis in R
R - if statement
Logistic Regression in R Programming
isblank() in C/C++ - GeeksforGeeks

26 Apr, 2018
The isblank()function returns non-zero if ch is a character for which isspace() returns true and is used to separate words. Thus for English, the blank characters are space and horizontal tab.
Header File : 
ctype.h

Declaration : 
int isblank(int ch)

difference between isblank() and isspace()The isspace() simply return true if the character is a space. In other words blank character is a space character used to separate words within a line of text and isblank() is used to identify it.
isblank() considers blank characters the tab character (‘\t’) and the space character (‘ ‘).isspace() considers space characters : (‘ ‘) – Space, (‘\t’) – Horizontal tab, (‘\n’) – Newline, (‘\v’) – Vertical tab, (‘\f’) – Feed, (‘\r’) – Carriage return
Examples:
Input:  Geeks for Geeks
Output: Geeks
        for 
        Geeks

Explanation: Since there are 2 spaces for Geeks for Geeks marked by an underscore( _ ) :Geeks_for_Geekswe replace the space with a newline character.
isblank() C++ Program:This code prints out the string character by character, replacing any blank character by a newline.
// CPP program to demonstrate working// of isblank()#include <ctype.h>#include <iostream>using namespace std;  int main(){    string str = "Geeks for Geeks";    int i = 0;      // to store count of blanks    int count = 0;    while (str[i]) {          // to get ith character        // from string        char ch = str[i++];          // mark a new line when space        // or horizontal tab is found        if (isblank(ch)) {            cout << endl;            count++;        }        else            cout << ch;    }         cout << "\nTotal blanks are : "            << count << endl;    return 0;}
Output:
Geeks
for
Geeks
Total blanks are : 2

C-String
C Language
C++
Technical Scripter
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
Exception Handling in C++
Multithreading in C
'this' pointer in C++
Arrow operator -> in C/C++ with Examples
Vector in C++ STL
Initialize a vector in C++ (6 different ways)
Inheritance in C++
Map in C++ Standard Template Library (STL)
C++ Classes and Objects
Differences Between Scala and Golang - GeeksforGeeks

21 Apr, 2022
Scala is a general-purpose, high-level, multi-paradigm programming language. It is a pure object-oriented programming language that also provides support to the functional programming approach. Scala programs can convert to bytecodes and can run on the JVM (Java Virtual Machine). Scala stands for Scalable language. It also provides Javascript runtimes. 
Example:
Scala
// Scala program to print Hello GFG! // Creating objectobject Geeks { // Main methoddef main(args: Array[String]){         // prints Hello, GFG!    println("Hello, GFG!")}}
Output:
Hello GFG!
Golang is a procedural and statically typed programming language having syntax similar to C programming language. Sometimes it is termed as Go Programming Language. It was developed in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson at Google but launched in 2009 as an open-source programming language and mainly used in Google’s production systems.
Example:
Go
// Golang programpackage main   import "fmt"   // Main functionfunc main() {       fmt.Println("Hello Geeks")}
Output:
Hello Geeks
Golang
Scala
mayank007rawa
Difference Between
Go Language
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Difference Between Method Overloading and Method Overriding in Java
Difference between Prim's and Kruskal's algorithm for MST
Difference between Internal and External fragmentation
Difference between Compile-time and Run-time Polymorphism in Java
Different ways to concatenate two strings in Golang
time.Sleep() Function in Golang With Examples
strings.Contains Function in Golang with Examples
Time Formatting in Golang
strings.Replace() Function in Golang With Examples
Python | Convert a nested list into a flat list - GeeksforGeeks

10 Sep, 2018
The task is to convert a nested list into a single list in python i.e no matter how many levels of nesting is there in python list, all the nested has to be removed in order to convert it to a single containing all the values of all the lists inside the outermost brackets but without any brackets inside.
Examples:
Input : l = [1, 2, [3, 4, [5, 6] ], 7, 8, [9, [10] ] ]Output : l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Input : l = [[[‘item1’, ‘item2’]], [[‘item3’, ‘item4’]]]Output : l = [‘item1’, ‘item2’, ‘itm3, ‘item4”]
We use recursion because the levels of nesting cannot be predetermined.
# Python code to flat a nested list with# multiple levels of nesting allowed.  # input listl = [1, 2, [3, 4, [5, 6]], 7, 8, [9, [10]]]  # output listoutput = []  # function used for removing nested # lists in python. def reemovNestings(l):    for i in l:        if type(i) == list:            reemovNestings(i)        else:            output.append(i)  # Driver codeprint ('The original list: ', l)reemovNestings(l)print ('The list after removing nesting: ', output)
The original list:  [1, 2, [3, 4, [5, 6]], 7, 8, [9, [10]]]
The list after removing nesting:  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

python-list
Python
Recursion
python-list
Recursion
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Write a program to print all permutations of a given string
Given an array A[] and a number x, check for pair in A[] with sum as x (aka Two Sum)
Recursion
Program for Tower of Hanoi
Backtracking | Introduction
C | Functions | Question 9 - GeeksforGeeks

28 Jun, 2021
What is the meaning of using static before function declaration?
For example following function sum is made static
static int sum(int x, int y, int z)
{
    return (x + y + z);
}
(A) Static means nothing, sum() is same without static keyword.(B) Function need not to be declared before its use(C) Access to static functions is restricted to the file where they are declared(D) Static functions are made inlineAnswer: (C)Explanation: In C, functions are global by default. Unlike global functions, access to static functions is restricted to the file where they are declared. We can have file level encapsulation using static variables/functions in C because when we make a global variable static, access to the variable becomes limited to the file in which it is declared.Quiz of this Question
C-Functions
Functions
C Language
C Quiz
Functions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Function Pointer in C
fork() in C
std::string class in C++
Enumeration (or enum) in C
Command line arguments in C/C++
Compiling a C program:- Behind the Scenes
Operator Precedence and Associativity in C
C | File Handling | Question 1
C | Arrays | Question 7
C | Misc | Question 7
Kali Linux - Cisco-Torch Tool - GeeksforGeeks

01 Feb, 2021
Cisco-Torch is one of the best penetration testing and scanning tool. It is a mass scanning and exploitation tool. Which was written while working on the edition of “Hacking Exposed Cisco Networks”.
Installation: It comes pre-installed in Kali-Linux but if not then just type the given command in the terminal box.
sudo apt-get install cisco-torch
To get the summary of parameters and attributes of the command use the following command:
cisco-torch -h
1. Using cisco-torch to run all fingerprint and scan types against the desired host:
cisco-torch -A 192.168.43.184
2. We can also use cisco-torch to scan an entire network or subnet:
cisco-torch -A 10.1.1.0/24
3. Using cisco-torch to run a dictionary attack against the host:
cisco-torch -t -b 10.1.1.54
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scp command in Linux with Examples
mv command in Linux with examples
Docker - COPY Instruction
SED command in Linux | Set 2
chown command in Linux with Examples
nohup Command in Linux with Examples
Named Pipe or FIFO with example C program
Thread functions in C/C++
uniq Command in LINUX with examples
Start/Stop/Restart Services Using Systemctl in Linux
Map Values() Method in Java With Examples - GeeksforGeeks

10 Sep, 2020
Map Values() method returns the Collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. 
Syntax:
map.values()
Parameter: This method does not take any parameter.
Return value: It returns a collection view of all the values present in the map.
Example 1:
Java
// Java program to illustrate the// use of Map.Values() Methodimport java.util.*;  public class GfG {        // Main Method    public static void main(String[] args)    {        // Initializing a Map of type HashMap         Map<Integer, String> map            = new HashMap<Integer, String>();          map.put(12345, "student 1");        map.put(22345, "student 2");        map.put(323456, "student 3");        map.put(32496, "student 4");        map.put(32446, "student 5");        map.put(32456, "student 6");          System.out.println(map.values());    }}
 
Output:
[student 4, student 3, student 6, student 1, student 2, student 5]
As you can see, the output of the above example is returning a collection view of values. So any change in the map will be reflected in the collection view automatically. So always take the generic of collection same as the generic of the values of the map otherwise it will give an error.
Example 2:
Java
// Java program to illustrate the// use of Map.Values() Methodimport java.util.*;  public class GfG {        // Main Method    public static void main(String[] args)    {        // Initializing a Map of type HashMap         Map<Integer, String> map            = new HashMap<Integer, String>();          map.put(12345, "student 1");        map.put(22345, "student 2");        map.put(323456, "student 3");        map.put(32496, "student 4");        map.put(32446, "student 5");        map.put(32456, "student 6");        Collection<String> collectionValues = map.values();                            System.out.println("<------OutPut before modification------>\n");        for(String s: collectionValues){            System.out.println(s);        }                 map.put(3245596, "student 7");        System.out.println("\n<------OutPut after modification------>\n");        for(String s: collectionValues){            System.out.println(s);        }    }}
Output:
<------OutPut before modification------>

student 4
student 3
student 6
student 1
student 2
student 5

<------OutPut after modification------>

student 4
student 3
student 6
student 1
student 2
student 7
student 5
Java-Collections
Java-Functions
java-map
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Interfaces in Java
ArrayList in Java
Stack Class in Java
Singleton Class in Java
Multidimensional Arrays in Java
Multithreading in Java
Collections in Java
Initializing a List in Java
Overriding in Java
Java Program to convert LocalDateTime to LocalDate and LocalTime

At first set a LocalDateTime:
LocalDate date = LocalDate.now();
LocalTime time = LocalTime.now();
LocalDateTime dateTime = LocalDateTime.of(date, time);
Now, convert the LocalDateTime to LocalDate and LocalTime:
LocalDate localDate = LocalDateTime.now().toLocalDate();
LocalTime localTime = LocalDateTime.now().toLocalTime();
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
public class Demo {
   public static void main(String[] args) {
      LocalDate date = LocalDate.now();
      LocalTime time = LocalTime.now();
      LocalDateTime dateTime = LocalDateTime.of(date, time);
      System.out.println("DateTime = "+dateTime);
      LocalDate localDate = LocalDateTime.now().toLocalDate();
      LocalTime localTime = LocalDateTime.now().toLocalTime();
      System.out.println("Date = "+localDate);
      System.out.println("Time = "+localTime);
   }
}
DateTime = 2019-04-18T13:57:22.591327100
Date = 2019-04-18
Time = 13:57:22.591327100
Convert an ArrayList to HashSet in Java

To convert ArrayList to HashSet, firstly create an ArrayList −
List<String> l = new ArrayList<String>();
Add elements to the ArrayList −
l.add("Accent");
l.add("Speech");
l.add("Diction");
l.add("Tone");
l.add("Pronunciation");
Now convert the ArrayList to HashSet −
Set<String> s = new HashSet<String>(l);
The following is an example to convert an ArrayList to HashSet in Java.
 Live Demo
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.HashSet;
public class Main {
   public static void main(String[] args) {
      List<String> l = new ArrayList<String>();
      l.add("Accent");
      l.add("Speech");
      l.add("Diction");
      l.add("Tone");
      l.add("Pronunciation");
      Set<String> s = new HashSet<String>(l);
      System.out.println("HashSet elements...");
      for (Object ob : s)
      System.out.println(ob);
   }
}
HashSet elements...
Tone
Pronunciation
Accent
Speech
Diction
Batch Script - Align Right

This used to align text to the right, which is normally used to improve readability of number columns.
@echo off 
set x = 1000 
set y = 1 
set y = %y% 
echo %x% 

set y = %y:~-4% 
echo %y%
A few key things to note about the above program is −
Spaces are added to the variable of y, in this case we are adding 9 spaces to the variable of y.
Spaces are added to the variable of y, in this case we are adding 9 spaces to the variable of y.
We are using the ~-4 option to say that we just want to show the last 4 characters of the string y.
We are using the ~-4 option to say that we just want to show the last 4 characters of the string y.
The above command produces the following output. The key thing to note is that the value of 2 is aligned to match the units columns when displaying numbers.
1000
1

 Print
 Add Notes
 Bookmark this page
How to write a comment in a JSP page?

JSP comment marks to text or statements that the JSP container should ignore. A JSP comment is useful when you want to hide or "comment out", a part of your JSP page.
Following is the syntax of the JSP comments −
<%-- This is JSP comment --%>
Following example shows the JSP Comments −
<html>
   <head>
      <title>A Comment Test</title>
   </head>
   <body>
      <h2>A Test of Comments</h2>
      <%-- This comment will not be visible in the page source --%>
   </body>
</html>
The above code will generate the following result −
A Test of Comments
There are a small number of special constructs you can use in various cases to insert comments or characters that would otherwise be treated specially. Here's a summary −
PHP for loops

The for loop - Loops through a block of code a specified number of times.
The for loop is used when you know in advance how many times the script should run.
Parameters:
init counter: Initialize the loop counter value
test counter: Evaluated for each loop iteration. If it evaluates to TRUE, the loop continues. If it evaluates to FALSE, the loop ends.
increment counter: Increases the loop counter value
The example below displays the numbers from 0 to 10:
$x = 0; - Initialize the loop counter ($x), and set the start value to 0
$x <= 10; - Continue the loop as long as $x is less than or equal to 10
$x++ - Increase the loop counter value by 1 for each iteration
This example counts to 100 by tens:
$x = 0; - Initialize the loop counter ($x), and set the start value to 0
$x <= 100; - Continue the loop as long as $x is less than or equal to 100
$x+=10 - Increase the loop counter value by 10 for each iteration
Create a loop that runs from 0 to 9.
 ($i = 0; $i < 10; ) {
  echo $i;
}

We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Boolean parseBoolean() method in Java with examples - GeeksforGeeks

01 Oct, 2018
The parseBoolean() method of Boolean Class is a built in static method of the class java.lang.Boolean which is used to convert a given string to its boolean value.
Syntax:
Boolean.parseBoolean(String value)
Parameters: It takes one parameter value of type string which contains the value which is to be converted to boolean.
Return Value: It returns a primitive boolean value. It returns the true if the given value is equals “true” ignoring cases. Else it returns false.
Below are java code to illustrate parseBoolean() method:
Example 1:
class GeeksforGeeks {      // Driver method    public static void main(String[] args)    {          // string value        String value = "TrUe";          // parseBoolean using parse Boolean() method        boolean result = Boolean.parseBoolean(value);          // printing the result        System.out.println(result);    }}
true

Example 2:
class GeeksforGeeks {      // Driver method    public static void main(String[] args)    {          // string value        String value = "true";          // parseBoolean using parse Boolean() method        boolean result = Boolean.parseBoolean(value);          // printing the result        System.out.println(result);    }}
true

Example 3:
class GeeksforGeeks {      // Driver method    public static void main(String[] args)    {          // string value        String value = "gfg";          // parseBoolean using parse Boolean() method        boolean result = Boolean.parseBoolean(value);          // printing the result        System.out.println(result);    }}
false

Java - util package
Java-Functions
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Generics in Java
Introduction to Java
Comparator Interface in Java with Examples
PriorityQueue in Java
Internal Working of HashMap in Java
p5.js | draw() Function - GeeksforGeeks

23 Aug, 2019
The draw() function is called after setup() function. The draw() function is used to executes the code inside the block until the program is stopped or noLoop() is called. If the program does not contain noLoop() function within setup() function then draw() function will still be executed once before stopping it. It should always be controlled with noLoop(), redraw() and loop() functions.
Syntax:
draw()
Below examples illustrate the draw() function in p5.js:
Example 1:
function setup() {           // Create Canvas of given size     createCanvas(400, 300); }   function draw() {           background(220);           // Use color() function     let c = color('green');       // Use fill() function to fill color     fill(c);           // Draw a rectangle     rect(50, 50, 300, 200);       } 
Output:
Example 2:
function setup() {           // Create Canvas of given size     var cvs = createCanvas(600, 250);}  function draw() {        // Set the background color    background('green');         // Use createDiv() function to    // create a div element    var myDiv = createDiv('GeeksforGeeks');        var myDiv1 = createDiv('A computer science portal for geeks');        // Use child() function    myDiv.child(myDiv1);        // Set the position of div element    myDiv.position(150, 100);          myDiv.style('text-align', 'center');        // Set the font-size of text    myDiv.style('font-size', '24px');        // Set the font color    myDiv.style('color', 'white');  }
Output:
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Convert a string to an integer in JavaScript
How to calculate the number of days between two dates in javascript?
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
File uploading in React.js
Roadmap to Become a Web Developer 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?
JavaFX example to set action to the "exit" MenuItem

A menu is a list of options or commands presented to the user, typically menus contain items that perform some action. The contents of a menu are known as menu items.
You can create a menu item by instantiating the javafx.scene.control.MenuItem class.
The Menu class inherits a property named onAction from the javafx.scene.control.ButtonBase class, which is of the type ObjectProperty<EventHandler<ActionEvent>>. This property represents the action that is invoked whenever you press the button. You can set the value to this property using the setOnAction() method.
To set action on a menu you need to −
Instantiate the Menu class.
Instantiate the Menu class.
Create a MenuItem objects and add them to the Menu.
Create a MenuItem objects and add them to the Menu.
Invoke the setOnAction() method the menu item object.
Invoke the setOnAction() method the menu item object.
To the setOnAction() method you need to pass an EventHandler<ActionEvent> object wrapping the code for the action to perform within it. For exit operation, since you need to close the application you can use System.exit(0).
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class ExitMenuItemAction extends Application {
   @Override
   public void start(Stage stage) {
      //Creating image view files
      ImageView imgView1 = new ImageView("UIControls/open.png");
      imgView1.setFitWidth(20);
      imgView1.setFitHeight(20);
      ImageView imgView2 = new ImageView("UIControls/Save.png");
      imgView2.setFitWidth(20);
      imgView2.setFitHeight(20);
      ImageView imgView3 = new ImageView("UIControls/Exit.png");
      imgView3.setFitWidth(20);
      imgView3.setFitHeight(20);
      //Creating menu
      Menu fileMenu = new Menu("File");
      //Creating menu Items
      MenuItem item1 = new MenuItem("Open File", imgView1);
      MenuItem item2 = new MenuItem("Save file", imgView2);
      MenuItem item3 = new MenuItem("Exit", imgView3);
      //Adding all the menu items to the menu
      fileMenu.getItems().addAll(item1, item2, item3);
      //Creating a menu bar and adding menu to it.
      MenuBar menuBar = new MenuBar(fileMenu);
      menuBar.setTranslateX(200);
      menuBar.setTranslateY(20);
      //Setting action to exit menu item
      item3.setOnAction((ActionEvent t) -> {
         System.exit(0);
      });
      //Setting the stage
      Group root = new Group(menuBar);
      Scene scene = new Scene(root, 595, 200, Color.BEIGE);
      stage.setTitle("Menu Example");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]){
      launch(args);
   }
}
Java String equals() Method

❮ String Methods

Compare strings to find out if they are equal:
String myStr1 = "Hello";
String myStr2 = "Hello";
String myStr3 = "Another String";
System.out.println(myStr1.equals(myStr2)); // Returns true because they are equal
System.out.println(myStr1.equals(myStr3)); // false

Try it Yourself »

The equals() method compares two strings, 
and returns true if the strings are equal, and false if not.
Tip: Use the compareTo() method to compare two strings lexicographically.
public boolean equals(Object anotherObject)

true - if the strings are equal
false - if the strings are not equal
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
\d vs \D in JavaScript?

There is a lot of difference between \d and \D in which the former results in the digits and the latter results in the non-digits such as e,^, etc. These are used along with global object "g" so that all the digits and non-digits across a text will be displayed in the output. Let's discuss it in detail.
new RegExp("\\d", "g");
new RegExp("\\D", "g")
In the following example, '\d' is used along with the global object "g" to get all the digits from the provided text. If the global object is not used, then only the first digit will be displayed in the output. 
 Live Demo
<html>
<body>
<script>
   var text = "one has to score 760+ in gmat to get into ivy colleges";
   var regpat = /\d/g;
   var result = text.match(regpat);
   document.write(result);
</script>
</body>
</html>
7,6,0
In the following example, \D\ is used along with global object 'g' to get all the non-digit characters such as t, y, ^, &, etc. Non-digit characters can include -, ^, &, etc and also can include spaces. 
Live Demo
<html>
<body>
<script>
   var text = "one has to score 760+ in gmat to get into ivy colleges";
   var regpat = /\D/g;
   var result = text.match(regpat);
   document.write(result);
</script>
</body>
</html>
o,n,e, ,h,a,s, ,t,o, ,s,c,o,r,e, ,+, ,i,n, ,g,m,a,t, ,t,o, ,g,e,t, ,i,n,t,o, ,i,v,y, ,c,o,l,l,e,g,e,s
Connect Django Project to MongoDB - GeeksforGeeks

26 Nov, 2021
Djongo is a SQL to mongodb query transpiler. Using djongo we can use MongoDB as a backend database for our Django project. We don’t even need to change the Django ORM. The best part is that we can setup Django with MongoDB by adding just one line of code. There is no need to change serializers, views, or any other modules.
Official Docs – https://pypi.org/project/djongo/ 
Working – Djongo translates a SQL query string into a MongoDB query document. Therefore, there is no need to change models, serializers, views or any Django features. Djongo supports all django contrib libraries which make it an easy to use connector. 
Requirements – 
1. Python 3.6 or higher.
2. MongoDB 3.4 or higher. (If you are using nested queries then MongoDB 3.6 or higher is required.)
Features :  
Reuse Django Models/ORM – As Django Models are compatible with Djongo, we can use reuse them.
Integrity checks Djongo allows integrity checks like missing values before they are saved to the database.For eg- Missing values are never stored if we set null=False, blank=False in EmbeddedField
Validators We can apply validation checks like URLValidator, EmailValidator, RegexValidator etc. before each fields are saved to the database. 
Usage : 
Step 1: Setup Virtual Environment 
virtualenv myenv
myenv\Scripts\activate
Step 2:  Install Django 
pip install django
Step 3: Install Djongo 
pip install djongo
Step 4: Start Django Project 
django-admin startproject geeks_project
Your project structure will look like this :
Step 5:  Make changes to settings.py file 
Now, open settings.py file. Comment out or remove previous SQL Database configuration and add the following code in settings.py file :settings.py
   DATABASES = {
      'default': {
          'ENGINE': 'djongo',
          'NAME': 'your-database-name',
      }
  }
That’s it. Now you can Use Mongodb as a backend database for your django project, without changing a single django model!
yuvraj_chandra
MongoDB
Python Django
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
Reading and Writing to text files in Python
sum() function in Python
Create a Pandas DataFrame from Lists
How to drop one or multiple columns in Pandas Dataframe
Add a new column in Pandas Data Frame Using a Dictionary - GeeksforGeeks

09 Nov, 2018
Pandas is basically the library in Python used for Data Analysis and Manipulation. To add a new Column in the data frame we have a variety of methods. But here in this post, we are discussing adding a new column by using the dictionary.
Let’s take Example!
# Python program to illustrate# Add a new column  in Pandas   # Importing the pandas Libraryimport pandas as pd  # creating a data frame with some data values.data_frame = pd.DataFrame([[i] for i in range(7)], columns =['data'])  print (data_frame)
Output:
  data 
0  0
1  1
2  2
3  3
4  4
5  5
6  6


Now Using the above-written method lets try to add a new column to it. Let’s add the New columns named as “new_data_1”.Map Function : Adding column “new_data_1” by giving the functionality of getting week name for the column named “data”. Call map and pass the dict, this will perform a lookup and return the associated value for that key.
Let’s Introduce variable week data typed as Dictionary that includes the name of days in the week.
# Python program to illustrate# Add a new column  in Pandas # Data Frame Using a Dictionary  import pandas as pd  data_frame = pd.DataFrame([[i] for i in range(7)], columns =['data'])  # Introducing weeks as dictionaryweeks = {0:'Sunday', 1:'Monday', 2:'Tuesday', 3:'Wednesday', 4:'Thursday', 5:'Friday', 6:'Saturday'}  # Mapping the dictionary keys to the data frame.data_frame['new_data_1'] = data_frame['data'].map(weeks)print (data_frame)
Output:
  data  new_data_1
0  0  Sunday
1  1  Monday
2  2  Tuesday
3  3  Wednesday
4  4  Thursday
5  5  Friday
6  6  Saturday


And, we have successfully added a column (Sunday, Monday....) at the end.
Picked
Python dictionary-programs
Python pandas-dataFrame
Technical Scripter 2018
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Enumerate() in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Create a Pandas DataFrame from Lists
Reading and Writing to text files in Python
*args and **kwargs in Python
How to drop one or multiple columns in Pandas Dataframe
sum() function in Python
How To Convert Python Dictionary To JSON?
Deadlock with mutex locks

Deadlock can be occurred in a multithreaded Pthread program using mutex locks. Let’s see how it can be occurred. An unlocked mutex is initialized by the pthread_mutex_init() function.
Using pthread_mutex_lock() and pthread_mutex_unlock() Mutex locks are acquired and released. If a thread try to acquire a locked mutex, the call to pthread_mutex_lock() blocks the thread until the owner of the mutex lock invokes pthread_mutex_unlock().
Let’s take an example, two Mutex locks are created in the following Code −
/* Create and initialize the mutex locks */
pthread mutex t mutex1;
pthread mutex t mutex2; pthread mutex init(&mutex1,NULL);
pthread mutex init(&mutex2,NULL);
Next, two threads - thread1 and thread2 - are created, and both these threads have access to both mutex locks. Thread1 and thread2 run in the functions dosomework_1 and dosomework_2, respectively, as shown below −
/* thread1 runs in this function */
void *dosomework_1(void *param) {
   pthread mutex lock(&mutex1);
   pthread mutex lock(&mutex2);
   /**
   * Do some work */
   pthread mutex unlock(& mutex2);
   pthread mutex unlock(& mutex2);
   pthread exit(0); } /*
   thread2 runs in this function
   */ void *dosomework_2(void *param) {
      pthread mutex lock(&mutex2);
      pthread mutex lock(&mutex1);
   /**
   * Do some work */
   pthread mutex unlock(&mutex1);
   pthread mutex unlock(&mutex2);
   pthread exit(0);
}
In this example, thread1 tries to acquire the mutex locks in the order
mutex1,
mutex2,
while thread two tries to acquire the mutex locks in the order
mutex2,
mutex1,
Deadlock is possible if thread1 acquires mutex1 while thread2 acquires mutex2. Even though deadlock is possible, it will not occur if thread1 can acquire and release the mutex locks for mutex1 and mutex2 before thread2 tries to acquire the locks. Of course, CPU scheduler scheduled the order in which the threads run. The above example illustrates a problem with handling deadlocks: it is difficult to identify and test for deadlocks that may occur only under certain scheduling circumstances.
Python Number floor() Method

Python number  method floor() returns floor of x - the largest integer not greater than x.
Following is the syntax for floor() method −
import math

math.floor( x )
Note − This function is not accessible directly, so we need to import math module and then we need to call this function using math static object.
x − This is a numeric expression.
x − This is a numeric expression.
This method returns largest integer not greater than x.
The following example shows the usage of floor() method.
#!/usr/bin/python
import math   # This will import math module

print "math.floor(-45.17) : ", math.floor(-45.17)
print "math.floor(100.12) : ", math.floor(100.12)
print "math.floor(100.72) : ", math.floor(100.72)
print "math.floor(119L) : ", math.floor(119L)
print "math.floor(math.pi) : ", math.floor(math.pi)
When we run above program, it produces following result −
math.floor(-45.17) :  -46.0
math.floor(100.12) :  100.0
math.floor(100.72) :  100.0
math.floor(119L) :  119.0
math.floor(math.pi) :  3.0


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Allowed Functional Dependencies (FD) in Various Normal Forms (NF) - GeeksforGeeks

18 May, 2021
Prerequisite – Functional Dependency and Attribute Closure 
We all know the following: 
2 NF does not allow partial dependency.
3NF does not allow transitive dependency.
BCNF does not allow anything other than super key as determinant.
Let’s check all possible functional dependencies to find out what is allowed and what’s not. Please note: prime attribute is an attribute that is part of any candidate key. Non prime attribute is an attribute that is not part of any candidate key. So, its advisable that you find out all possible candidate keys from the given functional dependencies and mark the prime and non prime attributes. 
1. Second Normal Form (2NF) : 
Not allowed FDs – 
prime -> non prime 
If say your functional dependency is of the form A->X where ‘A’ is a prime attribute but not a key and ‘X’ is a non prime attribute, then such an FD is not allowed in 2NF. 
Allowed FDs –  
Prime -> Prime
Non prime -> Prime/Non prime
Key -> Prime/Non prime
Prime + Non prime combination -> Prime/Non Prime 
If ‘A’ is a prime attribute (though not a key) it can determine another prime attribute 
If ‘A’ is a non prime attribute, it can determine a prime/non prime attribute. 
If ‘A’ is a key, it can determine a prime/non prime attribute. 
2. Third Normal Form (3NF) : 
Not allowed FDs – 
Prime -> Non prime  (2NF requirement)
Non prime -> Non prime  (3NF special) 
Allowed FDs –  
Prime -> Prime
Non prime -> Prime 
Key -> Prime/Non prime 
Prime + Non Prime -> Prime/Non prime 
3. Boyce-Codd Normal Form (BCNF) : 
Not allowed FDs –  
Prime -> Non prime  
Non prime -> Non prime  
Prime -> Prime 
Non prime -> Prime
Allowed –  
Key -> Prime/Non prime 
 
clintra
DBMS-Normalization
DBMS
GATE CS
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Deadlock in DBMS
Types of Functional dependencies in DBMS
KDD Process in Data Mining
Conflict Serializability in DBMS
Two Phase Locking Protocol
Layers of OSI Model
TCP/IP Model
Types of Operating Systems
Page Replacement Algorithms in Operating Systems
Differences between TCP and UDP
Node.js Stream readable.setEncoding() Method - GeeksforGeeks

12 Oct, 2021
The readable.setEncoding() method in a Readable Stream is used to set the encoding of the data read.
Syntax:
readable.setEncoding( encoding )
Parameters: This method accepts single parameter encoding which holds the encoding type.
Return Value: It returns the data in the encoded form.
Below examples illustrate the use of readable.setEncoding() method in Node.js:
Example 1:
// Node.js program to demonstrate the     // readable.setEncoding() method    // Include fs moduleconst fs = require('fs');  // Create readable streamconst readable = fs.createReadStream("input.txt");  // Calling setEncoding methodreadable.setEncoding('hex');  // Handling data eventreadable.on('data', (chunk) => {  console.log(`${chunk}`);});  // Displays that program // is endedconsole.log("Program ends!!");
Output:
Program ends!!
48656c6c6f

Example 2:
// Node.js program to demonstrate the     // readable.setEncoding() method    // Include fs moduleconst fs = require('fs');  // Create readable streamconst readable = fs.createReadStream("input.txt");  // Calling setEncoding methodreadable.setEncoding('base64');  // Handling data eventreadable.on('data', (chunk) => {  console.log(`${chunk}`);});  // Displays that program // is endedconsole.log("Program ends!!");
Output:
Program ends!!
SGVs
bG8=

Reference: https://nodejs.org/api/stream.html#stream_readable_setencoding_encoding
Node.js-Stream-module
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between promise and async await in Node.js
How to use an ES6 import in Node.js?
Express.js res.redirect() Function
How to read and write Excel file in Node.js ?
Express.js res.send() Function
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
Random sampling in numpy | random() function - GeeksforGeeks

26 Feb, 2019
numpy.random.random() is one of the function for doing random sampling in numpy. It returns an array of specified shape and fills it with random floats in the half-open interval [0.0, 1.0).
Syntax : numpy.random.random(size=None)
Parameters :size : [int or tuple of ints, optional] Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. Default is None, in which case a single value is returned.
Return : Array of random floats in the interval [0.0, 1.0). or a single such random float if size not provided.
Code #1 :
# Python program explaining# numpy.random.random() function  # importing numpyimport numpy as geek    # output arrayout_arr = geek.random.random(size = 3)print ("Output 1D Array filled with random floats : ", out_arr) 
Output 1D Array filled with random floats :  [ 0.21698734  0.01617363  0.70382199]

 
Code #2 :
# Python program explaining# numpy.random.random() function  # importing numpyimport numpy as geek    # output arrayout_arr = geek.random.random(size =(2, 4))print ("Output 2D Array filled with random floats : ", out_arr) 
Output 2D Array filled with random floats :  [[ 0.95423066  0.35595927  0.76048569  0.90163066]
 [ 0.41903408  0.85596254  0.21666156  0.05734769]]

 Code #3 :
# Python program explaining# numpy.random.random() function  # importing numpyimport numpy as geek  # output arrayout_arr = geek.random.random((2, 3, 2))print ("Output 3D Array filled with random floats : ", out_arr) 
Output 3D Array filled with random floats :  [[[ 0.07861816  0.79132387]
  [ 0.9112629   0.98162851]
  [ 0.0727613   0.03480279]]

 [[ 0.11267727  0.07631742]
  [ 0.47554553  0.83625053]
  [ 0.67781339  0.37856642]]]

Python numpy-Random sampling
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
AngularJS | angular.isNumber() Function - GeeksforGeeks

12 Apr, 2019
The angular.isNumber() function in AngularJS is used to determine the parameter inside isNumber function is a number or not. It returns true if the reference is a number otherwise returns false.
Syntax:
angular.isNumber( value )
Return Value: It returns true if the passed value is a number else false.
Example: This example uses angular.isNumber() function to determine the given input is number or not.
<!DOCTYPE html><html>    <head>        <title>angular.isNumber()</title>                  <script src=        "//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js">        </script>    </head>      <body ng-app="app" style="text-align:center">        <h1 style="color:green">GeeksforGeeks</h1>        <h2>angular.isNumber()</h2>          <div ng-controller="geek">            <b>Input1: </b>             <span><code>                    123             </code></span>                          <br>                          <b>IsNumber: </b>{{isNumber1}}<br /><br><br>            <b>Input2: </b>             <code>                "geeksforgeeks"            </code>            <br>            <b>IsNumber:</b> {{isNumber2}}        </div>                  <!-- Script to uses angular.isNumber() Function -->        <script>            var app = angular.module("app", []);            app.controller('geek', ['$scope', function ($scope) {                var obj1 = 123;                var obj2 = "geeksforgeeks";                $scope.isNumber1 = angular.isNumber(obj1);                $scope.isNumber2 = angular.isNumber(obj2);            }]);        </script>    </body></html>                    
Output:
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Angular File Upload
Angular PrimeNG Dropdown Component
Angular | keyup event
Auth Guards in Angular 9/10/11
How to Display Spinner on the Screen till the data from the API loads using Angular 8 ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills