code-rag-bench/online-tutorials huggingface dataset:
How to create a MenuBar in JavaFX?

A menu bar is a user interface element that holds all the menus, it is usually placed on the top. In JavaFX the javafx.scene.control.MenuBar class represents a menu bar. You can create a menu bar by instantiating this class.
A menu is a list of options or commands presented to the user. In JavaFX a menu is represented by the javafx.scene.control.Menu class.
The MenuBar class contains an observable list which holds all the menus, you can get this list by invoking the getMenus() method.
You can create the required number of menus and add them to the observable list using the addAll() method as −
menuBar.getMenus().addAll(file, fileList, skin);
You can also pass them as parameters to the constructor while instantiating the MenuBar class as −
MenuBar menuBar = new menuBar(menu1, menu2, menu3);
import javafx.application.Application;
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.paint.Color;
import javafx.stage.Stage;
public class MenuBarExample extends Application {
   public void start(Stage stage) {
      //Creating file menu
      Menu file = new Menu("File");
      //Creating file menu items
      MenuItem item1 = new MenuItem("Add Files");
      MenuItem item2 = new MenuItem("Start Converting");
      MenuItem item3 = new MenuItem("Stop Converting");
      MenuItem item4 = new MenuItem("Remove File");
      MenuItem item5 = new MenuItem("Exit");
      //Adding all the menu items to the file menu
      file.getItems().addAll(item1, item2, item3, item4, item5);
      //Creating FileList menu
      Menu fileList = new Menu("File List");
      //Creating fileList menu items
      MenuItem item6 = new MenuItem("Select All");
      MenuItem item7 = new MenuItem("Invert Selection");
      MenuItem item8 = new MenuItem("Remove");
      //Adding all the items to File List menu
      fileList.getItems().addAll(item6, item7, item8);
      //Creating Skin menu
      Menu skin = new Menu("_Skin");
      //Creating skin menu items
      MenuItem item9 = new MenuItem("Blue");
      MenuItem item10 = new MenuItem("Red");
      //Adding all elements to Skin menu
      skin.getItems().addAll(item9, item10);
      //Creating a menu bar
      MenuBar menuBar = new MenuBar();
      menuBar.setTranslateX(200);
      menuBar.setTranslateY(20);
      //Adding all the menus to the menu bar
      menuBar.getMenus().addAll(file, fileList, skin);
      //Setting the stage
      Group root = new Group(menuBar);
      Scene scene = new Scene(root, 595, 200, Color.BEIGE);
      stage.setTitle("Menu Bar Example");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]){
      launch(args);
   }
}
CICS - READNEXT / READPREV

When we issue a STARTBR command, it does not make the records available. It just tells from where to start reading the file. To get the first record and sequence after that, we need to use the READNEXT command.
The FILE, INTO, and LENGTH parameters are defined in the same way as they are in the READ command. We only need the FILE parameter because CICS allows us to browse several files at once and this tells which one we want to read next.
The FILE, INTO, and LENGTH parameters are defined in the same way as they are in the READ command. We only need the FILE parameter because CICS allows us to browse several files at once and this tells which one we want to read next.
RIDFLD points to a data area into which the CICS will "feed back" the key of the record it just read.
RIDFLD points to a data area into which the CICS will "feed back" the key of the record it just read.
The READPREV command is almost like READNEXT, except that it lets us proceed backward through a data set instead of forward.
The READPREV command is almost like READNEXT, except that it lets us proceed backward through a data set instead of forward.
Following is the syntax of READNEXT / READPREV command −
EXEC CICS READNEXT/READPREV
   FILE ('name')
   INTO (data-value)
   LENGTH (data-value)
   RIDFLD (data-value)
END-EXEC

 Print
 Add Notes
 Bookmark this page
Largest Independent Set Problem

The Independent Set is the subset of all binary tree nodes when there is no edge between any two nodes in that subset. 
Now from a set of elements, we will find the longest independent set. i.e. If the elements are used to form a binary tree, then all largest subset, where no elements in that subset are connected to each other.
Input:
A binary tree.

Output:
Size of the Largest Independent Set is: 5
longSetSize(root)
In this algorithm Binary tree will be formed, each node of that tree will hold data and setSize.
Input − Root node of the binary tree.
Output − Size of the longest set.
Begin
   if root = φ, then
      return 0
   if setSize(root) ≠ 0, then
      setSize(root)
   if root has no child, then
      setSize(root) := 1
      return setSize(root)
   setSizeEx := longSetSize(left(root)) + longSetSize(right(root)) //excluding root
   setSizeIn := 1

   if left child exists, then
      setSizeIn := setSizeIn + longSetSize(left(left(root))) + longSetSize(left(right(root)))

   if right child exists, then
      setSizeIn := setSizeIn + longSetSize(right(left(root))) + longSetSize(right(right(root)))

   if setSizeIn > setSizeEx, then
      setSize(root) := setSizeIn
   else
      setSize(root) := setSizeEx

   return setSize(root)
End
#include <iostream>
using namespace std;

struct node {
   int data;
   int setSize;
   node *left, *right;
};

int longSetSize(node *root) {
   if (root == NULL)
      return 0;

   if (root->setSize != 0)
      return root->setSize;

   if (root->left == NULL && root->right == NULL)    //when there is no child
      return (root->setSize = 1);

   // set size exclusive root is set size of left and set size of right

   int setSizeEx = longSetSize(root->left) + longSetSize(root->right);
   int setSizeIn = 1;             //inclusive root node

   if (root->left)               //if left sub tree is present
      setSizeIn += longSetSize(root->left->left) + longSetSize(root->left->right);

   if (root->right)                //if right sub tree is present
      setSizeIn += longSetSize(root->right->left) +longSetSize(root->right->right);
   root->setSize = (setSizeIn>setSizeEx)?setSizeIn:setSizeEx;

   return root->setSize;
}

struct node* getNode(int data) {          //create a new node with given data
   node* newNode = new node;
   newNode->data = data;
   newNode->left = newNode->right = NULL;
   newNode->setSize = 0;

   return newNode;
}

int main() {
   node *root = getNode(20);
   root->left = getNode(8);
   root->left->left = getNode(4);
   root->left->right = getNode(12);
   root->left->right->left = getNode(10);
   root->left->right->right = getNode(14);
   root->right = getNode(22);

   root->right->right = getNode(25);
   cout << "Size of the Largest Independent Set is: " << longSetSize(root);
}
Size of the Largest Independent Set is − 5
What are the differences between recursion and iteration in Java?

The Recursion and Iteration both repeatedly execute the set of instructions. Recursion is when a statement in a function calls itself repeatedly. The iteration is when a loop repeatedly executes until the controlling condition becomes false. The primary difference between recursion and iteration is that recursion is a process, always applied to a function and iteration is applied to the set of instructions which we want to get repeatedly executed.
Recursion uses selection structure.
Infinite recursion occurs if the recursion step does not reduce the problem in a manner that converges on some condition (base case) and Infinite recursion can crash the system.
Recursion terminates when a base case is recognized.
Recursion is usually slower than iteration due to the overhead of maintaining the stack.
Recursion uses more memory than iteration.
Recursion makes the code smaller.
Live Demo
public class RecursionExample {
   public static void main(String args[]) {
      RecursionExample re = new RecursionExample();
      int result = re.factorial(4);
      System.out.println("Result:" + result);
   }
   public int factorial(int n) {
      if (n==0) {
         return 1;
      }
      else {
         return n*factorial(n-1);
      }
   }
}
Result:24
Iteration uses repetition structure.
An infinite loop occurs with iteration if the loop condition test never becomes false and Infinite looping uses CPU cycles repeatedly.
An iteration terminates when the loop condition fails.
An iteration does not use the stack so it's faster than recursion.
Iteration consumes less memory.
Iteration makes the code longer.
Live Demo
public class IterationExample {
   public static void main(String args[]) {
      for(int i = 1; i <= 5; i++) {
         System.out.println(i + " ");
      }
   }
}
1
2
3
4
5
Python program for removing nth character from a string

In this article, we will learn about the solution to the problem statement given below −
Problem statement − We are given a string, we have to remove the ith indexed character from the given string and display it.
In any string in Python, indexing always starts from 0. Suppose we have a string “tutorialspoint” then its indexing will be done as shown below −
T u t o r i a l s p  o  i  n  t
0 1 2 3 4 5 6 7 8 9 10 11 12 13
Now let’s see the Python script for solving the statement −
 Live Demo
def remove(string, i):
   # slicing till ith character
   a = string[ : i]
   # slicing from i+1th index
   b = string[i + 1: ]
   return a + b
# Driver Code
if __name__ == '__main__':
   string = "Tutorialspoint"
   # Remove nth index element
   i = 8
   print(remove(string, i))
Tutorialpoint
Algorithms − From the given input string, i-th indexed element has to be popped. So, Split the string into two parts, before indexed character, and after indexed character thereby leaving the ith character Return the merged string.
Here we have three variables declared in global scope as shown below −
In this article, we learned about the removal of ith character from a given input string in Python 3.x or earlier
Order MySQL records randomly and display name in Ascending order

You can use subquery to order randomly and display name in asending order. The rand() is used for random, whereas ORDER BY is used to display name records in ascending order. The syntax is as follows −
select *from
(
   select *from yourTableName order by rand() limit anyIntegerValue;
) anyVariableName
order by yourColumnName;
To understand the above concept, let us create a table. We have an ID as sell as Name, which we want in Ascending order. The query to create a table is as follows −
mysql> create table OrderByRandName
   −> (
   −> Id int,
   −> Name varchar(100)
   −> );
Query OK, 0 rows affected (0.96 sec)
Display all records from the table using insert command. The query is as follows −
mysql> insert into OrderByRandName values(100,'John');
Query OK, 1 row affected (0.18 sec)

mysql> insert into OrderByRandName values(101,'Bob');
Query OK, 1 row affected (0.11 sec)

mysql> insert into OrderByRandName values(102,'Johnson');
Query OK, 1 row affected (0.19 sec)

mysql> insert into OrderByRandName values(103,'David');
Query OK, 1 row affected (0.22 sec)

mysql> insert into OrderByRandName values(104,'Smith');
Query OK, 1 row affected (0.17 sec)

mysql> insert into OrderByRandName values(105,'Taylor');
Query OK, 1 row affected (0.20 sec)

mysql> insert into OrderByRandName values(106,'Sam');
Query OK, 1 row affected (0.12 sec)

mysql> insert into OrderByRandName values(107,'Robert');
Query OK, 1 row affected (0.22 sec)

mysql> insert into OrderByRandName values(108,'Michael');
Query OK, 1 row affected (0.16 sec)

mysql> insert into OrderByRandName values(109,'Mark');
Query OK, 1 row affected (0.17 sec)
Display all records using select statement. The query is as follows −
mysql> select *from OrderByRandName;
The following is the output −
+------+---------+
| Id   | Name    |
+------+---------+
|  100 | John    |
|  101 | Bob     |
|  102 | Johnson |
|  103 | David   |
|  104 | Smith   |
|  105 | Taylor  |
|  106 | Sam     |
|  107 | Robert  |
|  108 | Michael |
|  109 | Mark    |
+------+---------+
10 rows in set (0.00 sec)
Here is the query that order by rand() and display name in ascending order −
mysql> select *from
   −> (
   −> select *from OrderByRandName order by rand() limit 10
   −> )tbl1
   −> order by Name;
The following is the output −
+------+---------+
| Id   | Name    |
+------+---------+
|  101 | Bob     |
|  103 | David   |
|  100 | John    |
|  102 | Johnson |
|  109 | Mark    |
|  108 | Michael |
|  107 | Robert  |
|  106 | Sam     |
|  104 | Smith   |
|  105 | Taylor  |
+------+---------+
10 rows in set (0.39 sec)
Difference between DBMS and DSMS - GeeksforGeeks

13 Oct, 2020
1. DBMS :In DBMS the nature of data is non-volatile and random data access is performed using DBMS. It operates on one time queries and gives the exact output for that query. DBMS uses unlimited secondary storage to store the data and also here in DBMS the data update rate is very low. DBMS is used when there is little or no time requirement.
Application of DBMS :
University records
Supply Chain Management
HR Management
Telecommunication records
Railway Reservation System
The below query is an example of DBMS query which is a one time query and gives the exact answer.
SELECT Name, Role, City
FROM Employees
WHERE City = 'Bhubaneswar'
ORDER BY Name

The above query is a very simple query which shows Name, Role, City of the company employees whose city belongs to Bhubaneswar and the output/result will be ordered by name of the employees.
2. DSMS :In DSMS the nature of data is volatile data stream and sequential data access is performed using DSMS. It operates on continuous queries and gives the exact/approximate output for that query. DBMS uses limited main memory to store the data and also here in DSMS the data update rate is very high. DSMS is used when there is real time requirement.
Application of DSMS :
Sensor Network
Network Traffic Analysis
Financial Tickers
Online Auctions
Transaction Log Analysis
The below query is an example of DSMS query which is a continuous query and gives the exact/approximate answer.
SELECT Stream
Rowtime
MIN(Temp) Over W1 as Wmin_temp,
MAX(Temp) Over W1 as Wmax_temp,
AVG(Temp) Over W1 as Wavg_temp,
FROM Wheatherstream
Window W1 as (RANGE INTERVAL '2' SECOND PRECEDING);

The above query aggregates a sensor stream from a weather monitoring system. Then it aggregates the collected minimum, maximum and average temperature values. Window clause creates a window of 2 seconds duration (refers to delay, which can be changed) showing a stream of incrementally updated results with zero result latency.
Difference between DBMS and DSMS :
DBMS
Difference Between
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Types of Functional dependencies in DBMS
Introduction of Relational Algebra in DBMS
What is Temporary Table in SQL?
Two Phase Locking Protocol
KDD Process in Data Mining
Difference between BFS and DFS
Class method vs Static method in Python
Differences between TCP and UDP
Difference between var, let and const keywords in JavaScript
Difference Between == and .equals() Method in Java
SQL - Alias Syntax

You can rename a table or a column temporarily by giving another name known as Alias. The use of table aliases is to rename a table in a specific SQL statement. The renaming is a temporary change and the actual table name does not change in the database. The column aliases are used to rename a table's columns for the purpose of a particular SQL query.
The basic syntax of a table alias is as follows.
SELECT column1, column2....
FROM table_name AS alias_name
WHERE [condition];

The basic syntax of a column alias is as follows.
SELECT column_name AS alias_name
FROM table_name
WHERE [condition];

Consider the following two tables.
Table 1 − CUSTOMERS Table is as follows.
+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
Table 2 − ORDERS Table is as follows.
+-----+---------------------+-------------+--------+
|OID  | DATE                | CUSTOMER_ID | AMOUNT |
+-----+---------------------+-------------+--------+
| 102 | 2009-10-08 00:00:00 |           3 |   3000 |
| 100 | 2009-10-08 00:00:00 |           3 |   1500 |
| 101 | 2009-11-20 00:00:00 |           2 |   1560 |
| 103 | 2008-05-20 00:00:00 |           4 |   2060 |
+-----+---------------------+-------------+--------+
Now, the following code block shows the usage of a table alias.
SQL> SELECT C.ID, C.NAME, C.AGE, O.AMOUNT 
   FROM CUSTOMERS AS C, ORDERS AS O
   WHERE  C.ID = O.CUSTOMER_ID;
This would produce the following result.
+----+----------+-----+--------+
| ID | NAME     | AGE | AMOUNT |
+----+----------+-----+--------+
|  3 | kaushik  |  23 |   3000 |
|  3 | kaushik  |  23 |   1500 |
|  2 | Khilan   |  25 |   1560 |
|  4 | Chaitali |  25 |   2060 |
+----+----------+-----+--------+

Following is the usage of a column alias.
SQL> SELECT  ID AS CUSTOMER_ID, NAME AS CUSTOMER_NAME
   FROM CUSTOMERS
   WHERE SALARY IS NOT NULL;
This would produce the following result.
+-------------+---------------+
| CUSTOMER_ID | CUSTOMER_NAME |
+-------------+---------------+
|           1 | Ramesh        |
|           2 | Khilan        |
|           3 | kaushik       |
|           4 | Chaitali      |
|           5 | Hardik        |
|           6 | Komal         |
|           7 | Muffy         |
+-------------+---------------+


    42 Lectures 
     5 hours 

 Anadi Sharma

    14 Lectures 
     2 hours 

 Anadi Sharma

    44 Lectures 
     4.5 hours 

 Anadi Sharma

    94 Lectures 
     7 hours 

 Abhishek And Pukhraj

    80 Lectures 
     6.5 hours 

 Oracle Master Training | 150,000+ Students Worldwide

    31 Lectures 
     6 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
MySQL Tryit Editor v1.0

SELECT * FROM Customers;
​
        
Edit the SQL Statement, and click "Run SQL" to see the result.
This SQL-Statement is not supported in the WebSQL Database.
The example still works, because it uses a modified version of SQL.
Your browser does not support WebSQL.
Your are now using a light-version of the Try-SQL Editor, with a read-only Database.
If you switch to a browser with WebSQL support, you can try any SQL statement, and play with the Database as much as you like. The Database can also be restored at any time.
Our Try-SQL Editor uses WebSQL to demonstrate SQL.
A Database-object is created in your browser, for testing purposes.
You can try any SQL statement, and play with the Database as much as you like. The Database can be restored at any time, simply by clicking the "Restore Database" button.
WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object.
WebSQL is supported in Chrome, Safari, and Opera.
If you use another browser you will still be able to use our Try SQL Editor, but a different version, using a server-based ASP application, with a read-only Access Database, where users are not allowed to make any changes to the data.
Swap two Strings without using temp variable in C#

To swap two strings without using a temp variable, you can try the following code and logic.
Append the second string with the first.
str1 = str1 + str2;
Set the str1 in str2.
str2 = str1.Substring(0, str1.Length - str2.Length);
Now, the final step is to set str2 in str1 −
str1 = str1.Substring(str2.Length);
using System;

class Demo {

   public static void Main(String[] args) {
      String str1 = "Brad";
      String str2 = "Pitt";

      Console.WriteLine("Strings before swap");
      Console.WriteLine(str1);
      Console.WriteLine(str2);

      str1 = str1 + str2;

      str2 = str1.Substring(0, str1.Length - str2.Length);
      str1 = str1.Substring(str2.Length);

      Console.WriteLine("Strings after swap");
      Console.WriteLine(str1);
      Console.WriteLine(str2);
   }
}
Express.js – app.delete() Method

The app.delete() method routes all the HTTP DELETE requests to the specified path with the specified callback functions.
app.delete(path, callback, [callback])
path − This is the path for which the middleware function is invoked. A path can be a string, path pattern, a regular expression, or an array of all these.
callback − These are the middleware functions or a series of middleware functions that act like a middleware except that these callbacks can invoke next (route).
Create a file "appDelete.js" and copy the following code snippet. After creating the file, use the command "node appDelete.js" to run this code.
// app.delete() Method Demo Example

// Importing the express module
const express = require('express');

// Initializing the express and port number
var app = express();
// Initializing the router from express
var router = express.Router();
var PORT = 3000;

// Creating a DELETE request
app.delete('/api', (req, res) => {
   console.log("DELETE Request Called for /api endpoint")
   res.send("DELETE Request Called")
})

// App listening on the below port
app.listen(PORT, function(err){
   if (err) console.log(err);
   console.log("Server listening on PORT", PORT);
});
Hit the following Endpoint with a DELETE request
 http://localhost:3000/api 
C:\home\node>> node appDelete.js
Server listening on PORT 3000
DELETE Request Called for /api endpoint
Let’s take a look at one more example.
// app.delete() Method Demo Example

// Importing the express module
const express = require('express');

// Initializing the express and port number
var app = express();
// Initializing the router from express
var router = express.Router();
var PORT = 3000;

// Creating a DELETE request
app.delete('/api', (req, res) => {
   console.log("Method called is -- ", req.method)
   res.end()
})

// App listening on the below port
app.listen(PORT, function(err){
   if (err) console.log(err);
   console.log("Server listening on PORT", PORT);
});
Hit the following Endpoint with a DELETE request
http://localhost:3000/api
C:\home\node>> node appDelete.js
Server listening on PORT 3000
Method called is -- DELETE
Redis - Hash Hset Command

Redis HSET command is used to set field in the hash stored at the key to value. If the key does not exist, a new key holding a hash is created. If the field already exists in the hash, it is overwritten.
Integer reply
1 if the field is a new field in the hash and value was set.
0 if the field already exists in the hash and the value was updated.
Following is the basic syntax of Redis HSET command.
redis 127.0.0.1:6379> HSET KEY_NAME FIELD VALUE

redis 127.0.0.1:6379> HSET myhash field1 "foo" 
OK 
redis 127.0.0.1:6379> HGET myhash field1 
"foo" 


    22 Lectures 
     40 mins

 Skillbakerystudios
 Print
 Add Notes
 Bookmark this page
SQL statement to add a table as Virtual table in SAP HANA Smart Data Access

You can use following SQL statement for this −
CREATE VIRTUAL TABLE <table_name> <remote_location_clause>
CREATE VIRTUAL TABLE ABC.test_VT AT “ORCL_11G_WIN”.”NULL”.”OUTLN”.”Dept”;
In this SQL statement, ABC.test_VT is Virtual table name
“ORCL_11G_WIN”.”NULL”.”OUTLN”.”Dept”;- Remote location for creating Virtual table
SQL - Using GROUP BY to COUNT the Number of Rows For Each Unique Entry in a Column - GeeksforGeeks

18 Oct, 2021
In this article, we will see how to use GROUP BY to count the number of rows for each unique entry in a given table. Using COUNT, without GROUP BY clause will return a total count of a number of rows present in the table.
Adding GROUP BY, we can COUNT total occurrences for each unique value present in the column.
Now, for the demonstration follow the below steps:
Step 1: Create a database
we can use the following command to create a database called geeks.
Query:
CREATE DATABASE geeks;
Step 2: Use database
Use the below SQL statement to switch the database context to geeks:
USE geeks;
Step 3: Table definition
We have the following demo_table in our geek’s database. 
Query:
CREATE TABLE demo_table(
NAME VARCHAR(20),
AGE int,
CITY VARCHAR(10));
Step 4: Insert data into a table
Query:
INSERT INTO demo_table VALUES ('Romy',23,'Delhi'),
('Pushkar',23,'Delhi'),
('Nikhil',24,'Punjab'),
('Rinkle',23,'Punjab'),
('Samiksha',23,'Banglore'),
('Ashtha',24,'Banglore'),
('Satish',30,'Patna'),
('Girish',30,'Patna');
Step 5: View the content
Execute the below query to see the content of the table
SELECT * FROM demo_table;
Output:
Step 6: use of COUNT without ORDER BY statement
COUNT(*) counts all rows
COUNT(column_name) counts non-NULLs only in the specified column name.
Syntax(count all rows):
SELECT COUNT(*)
FROM table_name;
Query:
SELECT COUNT(*) FROM demo_table;
Output:
The result is 8, as we have 8 entries in our demo_table.
Step 7: use GROUP BY
For counting the unique values in the AGE column.
Query:
SELECT AGE, COUNT(*) as COUNT from demo_table GROUP BY AGE;
Output:
For counting the unique values in the CITY column.
SELECT CITY,COUNT(*) as COUNT from demo_table GROUP BY CITY;
Output:
Picked
SQL-Server
TrueGeek-2021
SQL
TrueGeek
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Update Multiple Columns in Single Update Statement in SQL?
How to Alter Multiple Columns at Once in SQL Server?
What is Temporary Table in SQL?
SQL using Python
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
How to redirect to another page in ReactJS ?
How to remove duplicate elements from JavaScript Array ?
Types of Internet Protocols
SQL Statement to Remove Part of a String
Basics of API Testing Using Postman
Counting the occurrences of JavaScript array elements and put in a new 2d array

We are required to write a JavaScript function that takes in an array of literal values. The function should then count the frequency of each element of the input array and prepare a new array on that basis.
For example − If the input array is −
const arr = [5, 5, 5, 2, 2, 2, 2, 2, 9, 4];
Then the output should be −
const output = [
   [5, 3],
   [2, 5],
   [9, 1],
   [4, 1]
];
The code for this will be −
const arr = [5, 5, 5, 2, 2, 2, 2, 2, 9, 4];
const frequencyArray = (arr = []) => {
   const res = [];
   arr.forEach(el => {
      if (!this[el]) {
         this[el] = [el, 0];
         res.push(this[el])
      };
      this[el][1] ++
   }, {});
   return res;
};
console.log(frequencyArray(arr));
And the output in the console will be −
[ [ 5, 3 ], [ 2, 5 ], [ 9, 1 ], [ 4, 1 ] ]
Python 3 - os.listdir() Method

The method listdir() returns a list containing the names of the entries in the directory given by path. The list is in arbitrary order. It does not include the special entries '.' and '..' even if they are present in the directory.
path may be either of type str or of type bytes. If path is of type bytes, the filenames returned will also be of type bytes; in all other circumstances, they will be of type str.
Following is the syntax for listdir() method −
os.listdir(path)

path − This is the directory, which needs to be explored.
This method returns a list containing the names of the entries in the directory given by path.
The following example shows the usage of listdir() method.
#!/usr/bin/python3
import os, sys

# Open a file
path = "d:\\tmp\\"
dirs = os.listdir( path )

# This would print all the files and directories
for file in dirs:
   print (file)
When we run the above program, it produces the following result −
Applicationdocs.docx
test.java
book.zip
foo.txt
Java Multiple Inheritance.htm
Java Multiple Inheritance_files
java.ppt
ParallelPortViewer


    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
JavaScript RegExp return values between various square brackets? How to get value brackets?

Use regular expression with indexes 0,1....N to get the value without brackets. Following is the
code −
var regularExpression= /(?<=\[).*?(?=\])/g;
var getTheValueWithIndex= "[John Smith][David
Miller]".match(regularExpression);
console.log("The first value without bracket="+getTheValueWithIndex[0]);
console.log("The second value without
bracket="+getTheValueWithIndex[1]);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo132.js.
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo132.js
The first value without bracket=John Smith
The second value without bracket=David Miller
PyQt5 – Hide push button on click - GeeksforGeeks

23 Sep, 2021
In this article we will see how to hide the push button. When we design a GUI (Graphical User Interface) we create push button in it which do some task when they are pressed. But some time their is a need to hide the button if task is completed, in order to hide the button we will use hide method.
Syntax : button.hide()Argument : It takes no argument.Action performed : It hides the push button
Code :  
Python3
# importing librariesfrom PyQt5.QtWidgets import *from PyQt5.QtGui import *from PyQt5.QtCore import *import sys  class Window(QMainWindow):    def __init__(self):        super().__init__()         # setting title        self.setWindowTitle("Python ")         # setting geometry        self.setGeometry(100, 100, 600, 400)         # creating a button        self.button = QPushButton("CLICK", self)         # setting up the geometry        self.button.setGeometry(200, 150, 200, 40)         # connecting method when button get clicked        self.button.clicked.connect(self.clickme)         # showing all the widgets        self.show()     # action method    def clickme(self):         # hiding the button        self.button.hide()        # printing pressed        print("pressed") # create pyqt5 appApp = QApplication(sys.argv) # create the instance of our Windowwindow = Window() # start the appsys.exit(App.exec())
Output : 
When click button is pressed, output will generate and button will get hidden. 
pressed 
 
sweetyty
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Create a Pandas DataFrame from Lists
How to drop one or multiple columns in Pandas Dataframe
*args and **kwargs in Python
Graph Plotting in Python | Set 1
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Convert integer to string in Python
Python | Pandas dataframe.groupby()
How to delete azure blob (file) from the Storage account using PowerShell?

To delete the Azure blob from the azure storage account using PowerShell, we can use the RemoveAzStorageBlob command. Before running this command, we need to make sure that the Azure cloud account is connected (Connect-AzAccount) and the proper subscription is set in which the storage account resides (Set-AzContext).
Once the above two commands are executed, we can use the Remove-AzStorageBlob command but we need to use the storage context to work with the Azure Storage account.
The below commands will set the context for the Azure storage account with the storage account key.
$rg = "az204"
$storageaccount = "az204storage05june"
$key = (Get-AzStorageAccountKey -ResourceGroupName $rg - Name $storageaccount)[0].Value
$context = New-AzStorageContext -StorageAccountName $storageaccount - StorageAccountKey $key
The below will remove azure storage blob test1.py from the storage container ‘container1’.
Remove-AzStorageBlob -Container 'container1' -Context $context -Blob 'Test1.py' - Verbose
-Blob parameter accepts only one file or blob at a time. If you want to delete the entire content of the container then you need to use a loop.
foreach($file in (Get-AzStorageBlob -Container 'container1' -
Context $context).Name){
   Remove-AzStorageBlob -Container 'container1' -Context $context -Blob $file - Verbose
}
How to launch Chrome Browser via Selenium?

We can launch Chrome browser via Selenium. Java JDK, Eclipse and Selenium webdriver should be installed in the system before Chrome browser is launch.
Follow the steps one by one to launch Chrome −
Navigate to the link: https://chromedriver.chromium.org/downloads.
Navigate to the link: https://chromedriver.chromium.org/downloads.
Select the Chrome driver link which matches with the Chrome browser in our system.
Select the Chrome driver link which matches with the Chrome browser in our system.
Next, we have to choose and click on the Chrome driver link which is compatible with the operating system we are using.
Next, we have to choose and click on the Chrome driver link which is compatible with the operating system we are using.
A zip file gets downloaded. Extract and save the chromedriver.exe file in a location.
A zip file gets downloaded. Extract and save the chromedriver.exe file in a location.
We can configure the chromedriver.exe file in the following ways −
By setting the System Properties in the Environment Variables. Go to the Start and type System and click on it. Select the Advanced System Settings. Then click on the Environment Variables from the Advanced. From the System Variables, select Path and click on Edit. Then click on New. Add the chromedriver.exe path and proceed.
By setting the System Properties in the Environment Variables. Go to the Start and type System and click on it. Select the Advanced System Settings. Then click on the Environment Variables from the Advanced. From the System Variables, select Path and click on Edit. Then click on New. Add the chromedriver.exe path and proceed.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class ChromeLaunch{
   public static void main(String[] args) {
      WebDriver driver = new ChromeDriver();
      String url = " https://www.tutorialspoint.com/questions/index.php";
      driver.get(url);
   }
}
By setting the System Properties in the script. By adding the browser type and chromedriver.exe path as parameters to the System.setProperty method in the code.
By setting the System Properties in the script. By adding the browser type and chromedriver.exe path as parameters to the System.setProperty method in the code.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class LaunchChromeBrw{
   public static void main(String[] args) {
      WebDriver driver = new ChromeDriver();
      // browser type and chromedrover.exe path as parameters
      System.setProperty("webdriver.chrome.driver",
      "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      String url = " https://www.tutorialspoint.com/questions/index.php";
      driver.get(url);
   }
}
How to add items to a list in C#?

Firstly, declare a list −
var teams = new List<string>();
To add items to a C# list, use the Add() method −
teams.Add("US");
teams.Add("Canada");
teams.Add("India");
teams.Add("Australia");
You can try to run the following code to add items to a list in C# −
using System;
using System.Collections.Generic;

public class Demo {
   public static void Main(string[] args) {

      var teams = new List<string>();
      teams.Add("US");
      teams.Add("Canada");
      teams.Add("India");
      teams.Add("Australia");
   
      Console.WriteLine("Elements...");
      foreach (var countries in teams) {
         Console.WriteLine(countries);
      }
   }
}
Dart Programming - ceil Method

This property returns the ceiling value, that is the smallest integer greater than or equal to a number.
Number.ceil()

void main() { 
   var a = 2.4; 
   print("The ceiling value of 2.4 = ${a.ceil()}"); 
}  
It will produce the following output −.
The ceiling value of 2.4 = 3 


    44 Lectures 
     4.5 hours 

 Sriyank Siddhartha

    34 Lectures 
     4 hours 

 Sriyank Siddhartha

    69 Lectures 
     4 hours 

 Frahaan Hussain

    117 Lectures 
     10 hours 

 Frahaan Hussain

    22 Lectures 
     1.5 hours 

 Pranjal Srivastava

    34 Lectures 
     3 hours 

 Pranjal Srivastava
 Print
 Add Notes
 Bookmark this page
HTML <center> Tag - GeeksforGeeks

17 Mar, 2022
The <center> tag in HTML is used to set the alignment of text into the center. This tag is not supported in HTML5. CSS’s property is used to set the alignment of the element instead of the center tag in HTML5.
Syntax:
<center> Contents... </center>
Attributes: This tag dos not accept any attribute.
Example 1: In this example, we simply used the Hi Geeks content in the HTML center tag.
HTML
<!DOCTYPE html><html>  <body>    <h2>Welcome to GeeksforGeeks</h2>    <!--center tag is used here-->    <center>Hi Geeks</center>  </body>  </html>
Output:
HTML <center> tag
Example 2: This example illustrates the HTML center tag. 
HTML
<!DOCTYPE html><html>  <body>    <!--center tag starts here -->    <center>      <h1>GeeksforGeeks</h1>      <h2><center> tag</h2>      <p>GeeksforGeeks: A computer science portal for geeks</p>      <!--center tag ends here -->    </center>  </body></html>
Output:
HTML <center> tag
Example 3: Use CSS property in HTML5 to set the text alignment into the center. 
HTML
<!DOCTYPE html><html>  <body>    <h1>GeeksforGeeks</h1>    <!--center using CSS style  -->    <h2 style="text-align: center">      CSS center property    </h2>  </body></html>
Output:
HTML <center> tag
Supported Browsers:
Google Chrome
Microsoft Edge 12 and above
Internet Explorer
Firefox
Opera
Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
arorakashish0911
shubhamyadav4
bhaskargeeksforgeeks
HTML-Tags
HTML
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to set the default value for an HTML <select> element ?
How to update Node.js and NPM to next version ?
How to set input type date in dd-mm-yyyy format using HTML ?
How to Insert Form Data into Database using PHP ?
Hide or show elements in HTML using display property
REST API (Introduction)
Types of CSS (Cascading Style Sheet)
Form validation using HTML and JavaScript
C++ Program to Find Strongly Connected Components in Graphs

Weakly or Strongly Connected for a given a directed graph can be found out using DFS. This is a C++ program of this problem.
Begin
Function fillorder() = fill stack with all the vertices.
   a) Mark the current node as visited and print it
   b) Recur for all the vertices adjacent to this vertex
   c) All vertices reachable from v are processed by now, push v to Stack
End
Begin
Function DFS() :
   a) Mark the current node as visited and print it
   b) Recur for all the vertices adjacent to this vertex
End
#include <iostream>
#include <list>
#include <stack>
using namespace std;
class G {
   int m;
   list<int> *adj;
   //declaration of functions
   void fillOrder(int n, bool visited[], stack<int> &Stack);
   void DFS(int n, bool visited[]);
   public:
   G(int N); //constructor
   void addEd(int v, int w);
   int print();
   G getTranspose();
};
G::G(int m) {
   this->m = m;
   adj = new list<int> [m];
}
void G::DFS(int n, bool visited[]) {
   visited[n] = true; // Mark the current node as visited and print it
   cout << n << " ";
   list<int>::iterator i;
   //Recur for all the vertices adjacent to this vertex
   for (i = adj[n].begin(); i != adj[n].end(); ++i)
      if (!visited[*i])
         DFS(*i, visited);
}
G G::getTranspose() {
   G g(m);
   for (int n = 0; n< m; n++) {
      list<int>::iterator i;
      for (i = adj[n].begin(); i != adj[n].end(); ++i) {
         g.adj[*i].push_back(n);
      }
   }
   return g;
}
void G::addEd(int v, int w) {
   adj[v].push_back(w); //add w to v's list
}
void G::fillOrder(int v, bool visited[], stack<int> &Stack) {
   visited[v] = true; //Mark the current node as visited and print it
   list<int>::iterator i;
   //Recur for all the vertices adjacent to this vertex
   for (i = adj[v].begin(); i != adj[v].end(); ++i)
      if (!visited[*i])
         fillOrder(*i, visited, Stack);
   Stack.push(v);
}
int G::print() { //print the solution
   stack<int> Stack;
   bool *visited = new bool[m];
   for (int i = 0; i < m; i++)
      visited[i] = false;
   for (int i = 0; i < m; i++)
      if (visited[i] == false)
         fillOrder(i, visited, Stack);
   G graph= getTranspose(); //Create a reversed graph
   for (int i = 0; i < m; i++)//Mark all the vertices as not visited
      visited[i] = false;
   int count = 0;
   //now process all vertices in order defined by Stack
   while (Stack.empty() == false) {
      int v = Stack.top();
      Stack.pop(); //pop vertex from stack
      if (visited[v] == false) {
         graph.DFS(v, visited);
         cout << endl;
      }
      count++;
   }
   return count;
}
int main() {
   G g(5);
   g.addEd(2, 1);
   g.addEd(3, 2);
   g.addEd(1, 0);
   g.addEd(0, 3);
   g.addEd(3, 1);
   cout << "Following are strongly connected components
   in given graph \n";
   if (g.print() > 1) {
      cout << "Graph is weakly connected.";
   } else {
      cout << "Graph is strongly connected.";
   }
   return 0;
}
Following are strongly connected components in given
graph
4
0 1 2 3
Graph is weakly connected.
Which CSS property is used to run Animation in Reverse Direction?

Use the animation-direction property to run animation in reverse direction. The property is used with the reverse animation value to achieve this.
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            width: 150px;
            height: 200px;
            background-color: yellow;
            animation-name: myanim;
            animation-duration: 2s;
            animation-direction: reverse;
         }
         @keyframes myanim {
            from {
               background-color: green;
            }
            to {
               background-color: blue;
            }
         }
      </style>
   </head>
   <body>
      <div></div>
   </body>
</html>
How to create a responsive login form with CSS?

Following is the code to create a responsive login form with CSS −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
body {
   font-family: Arial, Helvetica, sans-serif;
   background-color: rgb(189, 189, 255);
}
form {
   border: 3px solid #f1f1f1;
   background-color: rgb(228, 228, 228);
   margin: 20px;
}
h1 {
   text-align: center;
}
input[type="text"],
input[type="password"] {
   width: 100%;
   padding: 12px 20px;
   margin: 8px 0;
   display: inline-block;
   border: 1px solid #ccc;
   box-sizing: border-box;
   font-size: 30px;
}
label {
   font-size: 30px;
}
button {
   font-weight: bold;
   font-family: monospace, sans-serif, serif;
   font-size: 25px;
   background-color: #4caf50;
   color: white;
   padding: 14px 20px;
   margin: 8px 0;
   border: none;
   cursor: pointer;
   width: 100%;
}
button:hover {
   opacity: 0.8;
}
.cancelbtn {
   width: auto;
   padding: 10px 18px;
   background-color: #f44336;
}
.profilePic {
   text-align: center;
   margin: 24px 0 12px 0;
}
img.avatar {
   width: 200px;
   height: 200px;
   border-radius: 50%;
}
.formFields {
   padding: 16px;
}
span.pass {
   float: right;
   padding-top: 16px;
}
/* Change styles for span and cancel button on extra small screens */
@media screen and (max-width: 300px) {
   span.pass {
      display: block;
      float: none;
   }
   .cancelbtn {
      width: 100%;
   }
}
</style>
</head>
<body>
<h1>Responsive Login Form Example</h1>
<form>
<div class="profilePic">
<img
src="https://cdn.pixabay.com/photo/2016/08/08/09/17/avatar-
1577909_960_720.png"
alt="Avatar"
class="avatar"/>
</div>
<div class="formFields">
<label for="uname"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="uname" required />
<label for="pass"><b>Password</b></label>
<input
type="password"
placeholder="Enter Password"
name="pass"
required/>
<button type="submit">Login</button>
<label>
<input type="checkbox" checked="checked" name="remember" /> Remember me
</label>
</div>
<div class="formFields" style="background-color:#f1f1f1">
<button type="button" class="cancelbtn">Cancel</button>
<span class="pass">Forgot <a href="#">password?</a></span>
</div>
</form>
</body>
</html>
This will produce the following output −
Decimal count of a Number in JavaScript

We are required to write a JavaScript function that takes in a number which may be an integer
or a floating-point number.
If it's a floating-point number, we have to return the count of numbers after the decimal point.
Otherwise we should return 0.
The code for this will be −
const num1 = 1.123456789;
const num2 = 123456789;
const decimalCount = num => {
   // Convert to String
   const numStr = String(num);
   // String Contains Decimal
   if (numStr.includes('.')) {
      return numStr.split('.')[1].length;
   };
   // String Does Not Contain Decimal
   return 0;
}
console.log(decimalCount(num1)) // 9
console.log(decimalCount(num2)) // 0
The output in the console will be −
9
0
GATE | GATE CS 2013 | Question 11 - GeeksforGeeks

28 Jun, 2021
Match the problem domains in GROUP I with the solution technologies in GROUP II
GROUP I                                         GROUP II
(P) Service oriented computing                 (1) Interoperability
(Q) Heterogeneous communicating systems        (2) BPMN
(R) Information representation                 (3) Publish-find-bind
(S) Process description                        (4) XML 
(A) P-1, Q-2, R-3, S-4(B) P-3, Q-4, R-2, S-1(C) P-3, Q-1, R-4, S-2(D) P-4, Q-3, R-2, S-1Answer: (C)Explanation: The answer can be easily guessed with XML. XML is used for information representation.Quiz of this Question
GATE-CS-2013
GATE-GATE CS 2013
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-CS-2014-(Set-1) | Question 30
GATE | GATE-CS-2015 (Set 1) | Question 65
GATE | GATE CS 2010 | Question 45
GATE | GATE-CS-2015 (Set 3) | Question 65
C++ Program to count Vowels in a string using Pointer
GATE | GATE-CS-2004 | Question 3
GATE | GATE-CS-2015 (Set 1) | Question 42
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE CS 2011 | Question 65
GATE | GATE CS 2012 | Question 65
How to create user defined exceptions in C#?

Like any other programming language, in C#, you can easily create user-defined exception. User-defined exception classes are derived from the Exception class.
In the below example, the exception created is not a built-in exception.
TempIsZeroException
You can try to run the following code to learn how to create user defined exception in C#.
 Live Demo
using System;
namespace Demo {
   class TestTemperature {
      static void Main(string[] args) {
         Temperature temp = new Temperature();
         try {
            temp.showTemp();
         } catch(TempIsZeroException e) {
            Console.WriteLine("TempIsZeroException: {0}", e.Message);
         }
         Console.ReadKey();
      }
   }
}
public class TempIsZeroException: Exception {
   public TempIsZeroException(string message): base(message) {
   }
}
public class Temperature {
   int temperature = 0;
   public void showTemp() {
      if(temperature == 0) {
         throw (new TempIsZeroException("Zero Temperature found"));
      } else {
         Console.WriteLine("Temperature: {0}", temperature);
      }
   }
}
TempIsZeroException: Zero Temperature found