code-rag-bench/online-tutorials huggingface dataset:
Why Protected access modifier used in Java?

The data members and methods of a class can be accessed from the same package or sub-classes in a different package if they are specified with the protected access modifier. The keyword protected is used to specify this modifier.
A program that demonstrates the protected access modifier in Java is given as follows:
 Live Demo
class A {
   protected int a = 9;
   public void printA() {
      System.out.println("Value of a = " + a);
   }
}
public class Demo {
   public static void main(String args[]) {
      A obj = new A();
      obj.a = 18;
      obj.printA();
   }
}
Value of a = 18
Now let us understand the above program.
The class A has a protected data member a that can be accessed from the same package or sub-classes in a different package. The public method printA() displays the value of a. A code snippet which demonstrates this is as follows:
class A {
   protected int a = 9;
   public void printA() {
      System.out.println("Value of a = " + a);
   }
}
In the main() method in class Demo, an object obj of class A is created. The value of obj.a is modified which is possible as it is protected and the modification is done in the same package. Then printA() method is called. A code snippet which demonstrates this is as follows:
public class Demo {
   public static void main(String args[]) {
      A obj = new A();
      obj.a = 18;
      obj.printA();
   }
}
How to map a step definition to a feature file in Cucumber?

We can map a step definition file to a feature file in Cucumber. This can be done using the below steps −
Step1− Create a feature file with .feature extension(say Login.feature) with the following −
Feature − Login Module
Scenario − Welcome Page Login verification
Given User is on Welcome Page
Then Welcome page should be displayed
Step2− Create a step definition java file(say stepDefination.java) having the mapping of the step definition file to the feature file.
package stepDefinations;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
public class stepDefination {
   @Given("^User is on Welcome Page$")
   public void user_on_welcome_page() {
      System.out.println("User on welcome page");
   }
   @Then("^Welcome page should be displayed$")
   public void verify_user_on_welcome_page() {
      System.out.println("User should be on welcome page");
   }
}
How to Use Column Alias in SELECT Statement? - GeeksforGeeks

08 Oct, 2021
Alias is used to give a temporary name(only for the duration of the query) to the column or table in order to make the column name or table name more readable. It does not change the name of the column permanently. 
Alias can be performed using the ‘AS’ keyword or without any keyword. But it is recommended to use the ‘AS’ keyword to avoid confusion between the initial column name and column alias.
If alias name contain space or any special character, enclose alias name in single(‘ ‘) or double(” “) quotes.
In SQL strings are also enclosed in single(‘ ‘) quotes. To avoid confusion,  it is recommended to use double quotes for alias name.
Syntax for Table Alias:
SELECT * FROM table_name AS alias_name;
Syntax for Column Alias:
SELECT column_name AS alias_name FROM table_name;
For the purpose of the demonstration, we will be creating demo_table in a database called “geeks“.
Step 1: Creating the Database
Use the below SQL statement to create a database called geeks.
Query:
CREATE DATABASE geeks;
Step 2: Using the Database
Use the below SQL statement to switch the database context to geeks.
Query:
USE geeks;
Step 3: Table definition
We have the following demo_table in our geeks database.
Query:
CREATE TABLE demo_table
(FIRSTNAME VARCHAR(20),
ENDNAME VARCHAR(20),
AGE INT,GENDER VARCHAR(20));
Step 4: Insert data into the table
INSERT INTO demo_table VALUES
('Romy', 'Kumari', 22, 'female'),
('Meenakshi', 'Jha', 20, 'female'),
('Shalini', 'Jha', 22, 'female'),
('Akanksha', 'Gupta', 23, 'female'),
('Rinkle', 'Arora', 23, 'female');
Step 5: See the content of the table
Use the below command to see the content of the demo_table:
Query:
SELECT * FROM demo_table;
Step 6: Perform column alias on ENDNAME column.
We will use LASTNAME as alias name for ENDNAME column 
Query:
SELECT FIRSTNAME, ENDNAME AS LASTNAME, AGE, GENDER FROM demo_table;
Output:
Use (LAST NAME) and (FIRST NAME) as alias name 
If we have a special character or spaces in the alias name, we enclose the alias name within double brackets:
Query:
SELECT FIRSTNAME AS "FIRST NAME", ENDNAME AS "LAST NAME", AGE, GENDER FROM demo_table;
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?
SQL | DROP, TRUNCATE
Composite Key in SQL
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL using Python
Types of Internet Protocols
How to redirect to another page in ReactJS ?
How to remove duplicate elements from JavaScript Array ?
Types of Network Firewall
Introduction to CUDA Programming
Extract domain of Email from table in SQL Server - GeeksforGeeks

07 Dec, 2020
Introduction :As a DBA, you might come across a request where you need to extract the domain of the email address, the email address that is stored in the database table. In case you want to count the most used domain names from email addresses in any given table, you can count the number of extracted domains from Email in SQL Server as shown below.
SQL Queries could be used to extract the domain from the Email address.Let us created table named “email_demo” –
create table (ID int, Email varchar (200));
Inserting values in the table email_demo –
insert into email_demo values(
(1, 'Sam@gfg.com'), (2, 'Khushi@gfg.com'),
(3, 'Komal@gfg.org'), (4, 'Priya@xyz.com'),
(5, 'Sam@xyz.com'), (6, 'Krish@xyz.com'),
(7, 'Neha@gfg.com'), (8, 'Pam@gfg.com'),
(9, 'Mohan@abc.com'), (10, 'Ankit@mno.com'),
(11, 'Kumari@gfg.com'), (12, 'Hina@abc.com'),
(13, 'Jaya@mno.com'), (14, 'Piyush@abc.com'),
(15, 'Khushi@xyz.com'), (16, 'Mona@gfg.org'),
(17, 'Roza@abc.com'));
Displaying the table contents –
select * from email_demo;
1. Extract Domain From Email in SQL Server :In below example we will use SUBSTRING function to select the string after the @ symbol in each of the value.
SQL Extract Domain From Email –
SELECT ID,
SUBSTRING ([Email], CHARINDEX( '@', [Email]) + 1,
LEN([Email])) AS [Domain]
FROM [email_demo];
OUTPUT :
Approached used :
Here we assigned the Source as our Column Name ‘Email’ in the SUBSTRING function.
Next, we used the CHARINDEX function to find the @ symbol, and then added 1, so that the starting point will be after the @ symbol.
Then, we used the LEN function to specify the end value.
2. Count the number of extracted Domain From Email in SQL Server :Approach 1 : SQL Query to Count Number of Records for Extract Domain name From Email –
SELECT RIGHT ([Email],
LEN([Email]) - CHARINDEX( '@', [Email])) AS [Domain],
COUNT(*) AS [Total Number of Domain]
FROM [email_demo]
WHERE LEN([Email ]) > 0
GROUP BY RIGHT([Email],
LEN([Email]) - CHARINDEX( '@', [Email]));
OUTPUT :
Approach 2 : SQL Query to Count Number of Records for Extract Domain name From Email –
SELECT SUBSTRING ([Email],
CHARINDEX( '@', [Email] ) + 1, LEN([Email])) AS [Domain],
COUNT(*) AS [Total Number of Domain]
FROM [email_demo]
WHERE LEN([Email]) > 1
GROUP BY SUBSTRING ([Email], CHARINDEX( '@', [Email] ) + 1,
LEN([Email]));
OUTPUT :
SQL-Server
DBMS
SQL
DBMS
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Second Normal Form (2NF)
Introduction of Relational Algebra in DBMS
Types of Functional dependencies in DBMS
What is Temporary Table in SQL?
Relational Model in DBMS
SQL | DDL, DQL, DML, DCL and TCL Commands
How to find Nth highest salary from a table
SQL | ALTER (RENAME)
How to Update Multiple Columns in Single Update Statement in SQL?
What is Temporary Table in SQL?
Foundation - Slider Two Handles

To use two handles you need to use .slider-handle span and input field. It works for both horizontal and vertical sliders. The JavaScript will allocate ids for input fields, until you change it. If you do not change, then the handles and inputs match in the way they are in the DOM tree.
The following example demonstrates how to use two handles slider in Foundation.
<html>
   <head>
      <title>Slider Two Handles</title>
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/foundation-sites@6.5.1/dist/css/foundation.min.css" integrity="sha256-1mcRjtAxlSjp6XJBgrBeeCORfBp/ppyX4tsvpQVCcpA= sha384-b5S5X654rX3Wo6z5/hnQ4GBmKuIJKMPwrJXn52ypjztlnDK2w9+9hSMBz/asy9Gw sha512-M1VveR2JGzpgWHb0elGqPTltHK3xbvu3Brgjfg4cg5ZNtyyApxw/45yHYsZ/rCVbfoO5MSZxB241wWq642jLtA==" crossorigin="anonymous">

      <!-- Compressed JavaScript -->
      <script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/vendor/jquery.min.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/foundation-sites@6.5.1/dist/js/foundation.min.js" integrity="sha256-WUKHnLrIrx8dew//IpSEmPN/NT3DGAEmIePQYIEJLLs= sha384-53StQWuVbn6figscdDC3xV00aYCPEz3srBdV/QGSXw3f19og3Tq2wTRe0vJqRTEO sha512-X9O+2f1ty1rzBJOC8AXBnuNUdyJg0m8xMKmbt9I3Vu/UOWmSg5zG+dtnje4wAZrKtkopz/PEDClHZ1LXx5IeOw==" crossorigin="anonymous"></script>

   </head>

   <body>
      <div class = "slider" data-slider data-initial-start = "30" data-initial-end = "60">
         <span class = "slider-handle" data-slider-handle role = "slider" tabindex = "1"></span>
         <span class = "slider-fill" data-slider-fill></span>
         <span class = "slider-handle" data-slider-handle role = "slider" tabindex = "1"></span>
         <input type = "hidden">
         <input type = "hidden">
      </div>


      <script>
         $(document).ready(function() {
            $(document).foundation();
         })
      </script>
   </body>
</html>
Let us carry out the following steps to see how the above given code works −
Save the above given html code slider_two_handles.html file.
Save the above given html code slider_two_handles.html file.
Open this HTML file in a browser, an output is displayed as shown below.
Open this HTML file in a browser, an output is displayed as shown below.

    117 Lectures 
     5.5 hours 

 Shakthi Swaroop

    61 Lectures 
     1.5 hours 

 Hans Weemaes

    17 Lectures 
     4 hours 

 Stephen Kahuria

    8 Lectures 
     50 mins

 Zenva

    28 Lectures 
     2 hours 

 Sandra L

    16 Lectures 
     2.5 hours 

 GreyCampus Inc.
 Print
 Add Notes
 Bookmark this page
How to count digits of given number? JavaScript

The requirements here are simple, we are required to write a JavaScript function that takes in a
number and returns the number of digits in it.
For example −
The number of digits in 4567 is 4
The number of digits in 423467 is 6
The number of digits in 457 is 3
Let's write the code for this function −
const num = 2353454;
const digits = (num, count = 0) => {
   if(num){
      return digits(Math.floor(num / 10), ++count);
   };
   return count;
};
console.log(digits(num));
console.log(digits(123456));
console.log(digits(53453));
console.log(digits(5334534534));
The output in the console will be −
7
6
5
10
AtomicInteger getAndAccumulate() method in Java with Examples - GeeksforGeeks

03 Jun, 2019
The Java.AtomicInteger.getAndAccumulate() method is an inbuilt method, which updates the current value of the object by applying the specified operation on the current value and value passed as a parameter. It takes an integer as its parameter and an object of IntBinaryOperator interface and applies the operation specified in the object to the values. It returns the previous value.
Syntax:
public final int getAndAccumulate(int y, 
                   IntBinaryOperator function)

Parameters: This method accepts two parameters:
y: an integer on which the function is to be applied.
function: function applied to the current value of the object and the value y.
Return Value: The function returns the previous value of the current object.
Example to demonstrate the function.
// Java program to demonstrate// working of getAndAccumulate() method  import java.util.concurrent.atomic.AtomicInteger;import java.util.function.IntBinaryOperator;  public class Demo {    public static void main(String[] args)    {        new UserThread("Thread A");        new UserThread("Thread B");    }}  class Shared {    static AtomicInteger ai        = new AtomicInteger(1);}  class UserThread implements Runnable {    String name;      UserThread(String name)    {        this.name = name;        new Thread(this).start();    }      IntBinaryOperator ibo = (x, y) -> (x * y);      int value = 5;    @Override    public void run()    {        for (int i = 0; i < 3; i++) {              int ans                = Shared.ai                      .getAndAccumulate(value, ibo);              System.out.println(name + " "                               + ans);        }    }}
Thread A 1
Thread A 5
Thread A 25
Thread B 125
Thread B 625
Thread B 3125

Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicInteger.html
Java-AtomicInteger
Java-Functions
Java-util-concurrent-atomic package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
How to iterate any Map in Java
Interfaces in Java
Initialize an ArrayList in Java
ArrayList in Java
Stack Class in Java
Multidimensional Arrays in Java
Singleton Class in Java
LinkedList in Java
Program to find number of solutions in Quadratic Equation in C++

In this problem, we are given a quadratic equation of type ax2 + bx + c, where a,b and c are constants. Our task is to create a program to find number of solutions in Quadratic Equation in C++.
Problem Description − Here, we need to find the numbers of solutions for a quadratic equation that can have at max 2 solutions.
Let’s take a few examples to understand the problem,
Input − 3x2 + 7x + 4
Output − 2
Explanation − the two solutions of the equation are 1 and 4/3.
Input − x2 - 4x + 4
Output − 1
Explanation − The solution to the equation is 2.
Input − 2x2 + 2x + 2
Output − 0
Explanation: There is no solution to the equation.
To find the number of solutions, we need the nature of solutions of the quadratic equation which is found using the value of discriminant (D).
The roots of the equation are given by the formula,
= −b ± √b.
D = ( (b^2) - (4*a*c) )
So, the discriminant’s value gives the number of roots of the quadratic equation.
If D = 0, the number of solutions is 1.
If D = 0, the number of solutions is 1.
If D > 0, the number of solutions is 2.
If D > 0, the number of solutions is 2.
If D < 0, the number of solutions is 0. As the value of the root of a negative number is imaginary.
If D < 0, the number of solutions is 0. As the value of the root of a negative number is imaginary.
Step 1 − find the value of D, D = ((b^2) - 4*a*c).
Step 1 − find the value of D, D = ((b^2) - 4*a*c).
Step 2 − if(D > 0), print 2 solutions
Step 2 − if(D > 0), print 2 solutions
Step 3 − if(D = 0), print 1 solution
Step 3 − if(D = 0), print 1 solution
Step 4 − if(D < 0), print 0 solution
Step 4 − if(D < 0), print 0 solution
#include <iostream>
using namespace std;
int checkSolution(int a, int b, int c) {
   if (((b * b) - (4 * a * c)) > 0)
      return 2;
   else if (((b * b) - (4 * a * c)) == 0)
      return 1;
   else
      return 0;
}
int main() {
   int a = 2, b = 2, c = 3;
   cout<<"The quadratic equation is "<<a<<"x^2 + "<<b<<"x +
   "<<c<<" has ";
   cout<<checkSolution(a, b, c)<<" solutions ";
   return 0;
}
The quadratic equation is 2x^2 + 2x + 3 has 0 solutions
Next.js - Pages

In Next.js, we can create pages and navigate between them using file system routing feature. We'll use Link component to have a client side navigation between pages.
In Next.js, a page is a React Component and are exported from pages directory. Each page is associated with a route based on its file name. For example
pages/index.js is linked with '/' route.
pages/index.js is linked with '/' route.
pages/posts/first.js is linked with '/posts/first' route and so on.
pages/posts/first.js is linked with '/posts/first' route and so on.
Let's update the nextjs project created in Environment Setup chapter.
Create post directory and first.js within it with following contents.
export default function FirstPost() {
   return <h1>My First Post</h1>
}
Add Link Support to go back to Home page. Update first.js as follows −
import Link from 'next/link'

export default function FirstPost() {
   return (
      <>
         <h1>My First Post</h1>
         <h2>
            <Link href="/">
               <a>Home</a>
            </Link>
         </h2>
      </>	  
   )
}
Add Link Support to home page to navigate to first page. Update index.js as follows −
import Link from 'next/link'

function HomePage() {
   return (
      <>
         <div>Welcome to Next.js!</div>
         <Link href="/posts/first"><a>First Post</a></Link>
      </>	    
   )
}

export default HomePage
Run the following command to start the server −.
npm run dev
> nextjs@1.0.0 dev \Node\nextjs
> next

ready - started server on http://localhost:3000
event - compiled successfully
event - build page: /
wait  - compiling...
event - compiled successfully
event - build page: /next/dist/pages/_error
wait  - compiling...
event - compiled successfully

Open localhost:3000 in a browser and you will see the following output.
Click on First Link and you will see the following output.
 Print
 Add Notes
 Bookmark this page
How to use Push-Location and Pop-Location command in PowerShell?

Push-Location command in PowerShell is used to push (add) the current location to the location stack (Last In First Out (LIFO) - queue) while the Pop-Location is to retrieve the last location from the stack.
When the PowerShell console opens there are no locations set to the stack.
PS C:\> Get-Location -Stack
PS C:\>
When you type the Push-Location command it performs two operations at a time. First, it saves the current location to the top of the stack, and second, it browse the path specified. If there is no path specified then it only moves the current location to the stack. For example,
PS C:\> Push-Location
PS C:\> Get-Location -Stack
Path
----
C:\
We will specify the path now,
PS C:\> Push-Location C:\Temp\
PS C:\Temp> Get-Location -Stack
Path
----
C:\
C:\
In the above example, the current location was C:\ so the command pushed it to the stack and it moved to that specified directory. Let say we are pushing one more location to the stack.
PS C:\Temp> Push-Location C:\Temp\iisadministration\
PS C:\Temp\iisadministration> Get-Location -Stack
Path
----
C:\Temp
C:\
C:\
In the above example, C:\Temp was the current location so it is top of the stack. To jump to the last location we need to use the Pop-Location command. For example,
PS C:\Temp\iisadministration> Pop-Location
PS C:\Temp>
When you run the Pop-Location command, the last item (recent item) from the queue is deleted. Let’s check the stack.
PS C:\Temp> Get-Location -Stack
Path
----
C:\
C:\
You can also create a new stack to push the location and then you can retrieve the location using the Pop-Location command from the specific stack. For example,
PS C:\Windows\System32> Push-Location WindowsPowerShell -StackName Stack2
PS C:\Windows\System32\WindowsPowerShell> Get-Location -StackName Stack2
Path
----
C:\Windows\System32
In the above example, we have created a new stack called ‘Stack2’ and pushed a current location there, you can see the location was inserted in the new stack using the Get-Location command for the specific stack.
To retrieve the data from that stack,
PS C:\Windows\System32\WindowsPowerShell> Pop-Location -StackName stack2
PS C:\Windows\System32>
C function argument and return values

Here we will see what are the different types of C functions based on the return values and arguments.
So a function either can take some arguments, or nothing is taken. Similarly, a function can return something, otherwise does not return anything. So we can categorize them into four types.
Function with No argument and No return type.
Function with No argument and Return something.
A function that takes argument but returns nothing.
Functions that take an argument and also return something.
#include <stdio.h>
void my_function() {
   printf("This is a function that takes no argument, and returns nothing.");
}
main() {
   my_function();
}
This is a function that takes no argument, and returns nothing.
Here this function is not taking any input argument, and also the return type is void. So this returns nothing.
#include <stdio.h>
int my_function() {
   printf("This function takes no argument, But returns 50\n");
   return 50;
}
main() {
   int x;
   x = my_function();
   printf("Returned Value: %d", x);
}
This function takes no argument, But returns 50
Returned Value: 50
Here this function is not taking any input argument, but its return type is int. So this returns a value.
#include <stdio.h>
void my_function(int x) {
   printf("This function is taking %d as argument, but returns nothing", x);
   return 50;
}
main() {
   int x;
   x = 10;
   my_function(x);
}
This function is taking 10 as argument, but returns nothing
Here this function is taking an input argument, but its return type is void. So this returns nothing.
#include <stdio.h>
int my_function(int x) {
   printf("This will take an argument, and will return its squared value\n");
   return x * x;
}
main() {
   int x, res;
   x = 12;
   res = my_function(12);
   printf("Returned Value: %d", res);
}
This function is taking 10 as argument, but returns nothing
Here this function is taking any input argument, and also returns value.
How to display square root sign in base R plot?

To display square root sign in base R plot, we can follow the below steps −
First of all, create a plot having square root values to display default visualisation.
First of all, create a plot having square root values to display default visualisation.
Then, create the plot with expression function to display square root sign in the plot.
Then, create the plot with expression function to display square root sign in the plot.
Using plot function to create a plot in base R with square root values as shown below −
x<-1:10
y<-sqrt(x)
plot(x,y)
Display square root sign in the plot
Create the plot with plot and expression function to display square root sign in the plot as shown below −
x<-1:10
y<-sqrt(x)
plot(x,y,ylab=expression(sqrt(x)))
Node.js process.kill() Method - GeeksforGeeks

17 Jan, 2022
The process.kill( pid[,signal] ) is an inbuilt method of node.js which sends a signal to the process, pid (which is the process id) and signal is in the string format that is the signal to send.
Syntax :
process.kill(pid[, signal])
Parameters: This method accepts two parameters as mentioned above and described below:
pid: This parameter holds the process ID.
signal: This parameter holds the string format.signal names : These are in string format .SIGTERMSIGINTSIGHUP
signal names : These are in string format .
SIGTERMSIGINTSIGHUP
SIGTERM
SIGINT
SIGHUP
Note : If no signal specified, then by default ‘SIGTERM’ will be the signal.
‘SIGTERM’ and ‘SIGINT‘ signals have default handlers on non-Windows platforms that reset the terminal mode before exiting with code 128 + signal number. If one of these signals has a listener installed, its default behavior on node.js will be removed.
‘SIGHUP’ is generated when the console window is closed.
Return value : The process.kill() method will throw an error if the target pid is not found or doesn’t exist. This method returns boolean value 0 if pid exists and can be used as a test for the existence of the target process. For window users, this method will also throw an error if pid is used to kill a group of process. 
Below examples illustrate the use of process.kill() property in Node.js:
Example 1:
index.js
// Node.js program to demonstrate the // process.kill(pid[, signal]) method     // Printing process signal acknowledgedconst displayInfo = () => {  console.log('Receiving SIGINT signal in nodeJS.');}  // Initiating a processprocess.on('SIGINT', displayInfo);  setTimeout(() => {  console.log('Exiting.');  process.exit(0);}, 100);  // kill the process with pid and signal = 'SIGINT'     process.kill(process.pid, 'SIGINT');
Command to run :
node index.js
Output :
Example 2 :
index.js
// Node.js program to demonstrate the // process.kill(pid[, signal]) method // Printing process signal acknowledgedconst displayInfo = () => {  console.log('Acknowledged SIGHUP signal in nodeJS.');}  // Initiating a processprocess.on('SIGHUP', displayInfo);  setTimeout(() => {  console.log('Exiting.');  process.exit(0);}, 100);  // kill the process with pid and signal = 'SIGHUP'     process.kill(process.pid, 'SIGHUP');
Command to run :
node index.js
Output :
Reference : https://nodejs.org/api/process.html#process_process_kill_pid_signal
adnanirshad158
Node.js-Methods
NodeJS-Process
Picked
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to build a basic CRUD app with Node.js and ReactJS ?
How to connect Node.js with React.js ?
Mongoose Populate() Method
Express.js req.params Property
How to Convert CSV to JSON file having Comma Separated values in Node.js ?
Top 10 Front End Developer Skills That You Need in 2022
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?
Difference between var, let and const keywords in JavaScript
How can we start MySQL event scheduler?

Actually, MySQL event scheduler is a process that runs in the background and constantly looks for the events to execute. But before we create or schedule an event we just have to start the scheduler. It can start with the help of the following statement −
mysql> SET GLOBAL event_scheduler = ON;
Query OK, 0 rows affected (0.07 sec)
Now with the help of the following statement, we can check its status in MySQL process list −
mysql> SHOW PROCESSLIST\G
*************************** 1. row ***************************
     Id: 3
   User: root
   Host: localhost:49500
     db: query
Command: Query
   Time: 0
  State: starting
   Info: SHOW PROCESSLIST
*************************** 2. row ***************************
     Id: 4
   User: event_scheduler
   Host: localhost
     db: NULL
Command: Daemon
   Time: 11
  State: Waiting on empty queue
   Info: NULL
2 rows in set (0.06 sec)
It can be turn off with the help of the following statement −
mysql> SET GLOBAL event_scheduler = OFF;
Query OK, 0 rows affected (0.07 sec)
Solidity - Environment Setup

This chapter explains how we can setup Solidity compiler on CentOS machine. If you do not have a Linux machine then you can use our Online Compiler for small contracts and for quickly learning Solidity.
This is the fastest way to install Solidity compiler on your CentoS Machine. We have following steps to install Solidity Compiler −
First make sure you have node.js available on your CentOS machine. If it is not available then install it using the following commands −
# First install epel-release
$sudo yum install epel-release

# Now install nodejs
$sudo yum install nodejs

# Next install npm (Nodejs Package Manager )
$sudo yum install npm

# Finally verify installation
$npm --version

If everything has been installed then you will see an output something like this −
3.10.10

Once you have Node.js package manager installed then you can proceed to install Solidity compiler as below −
$sudonpm install -g solc

The above command will install solcjs program and will make it available globally through out the system. Now you can test your Solidity compiler by issuing following command −
$solcjs-version

If everything goes fine, then this will print something as follows −
0.5.2+commit.1df8f40c.Emscripten.clang

Now you are ready to use solcjs which has fewer features than the standard Solidity compiler but it will give you a good starting point.
You can pull a Docker image and start using it to start with Solidity programming. Following are the simple steps. Following is the command to pull a Solidity Docker Image.
$docker pull ethereum/solc:stable

Once a docker image is downloaded we can verify it using the following command.
$docker run ethereum/solc:stable-version

This will print something as follows −
$ docker run ethereum/solc:stable -version

solc, the solidity compiler commandlineinterfaceVersion: 0.5.2+commit.1df8f40c.Linux.g++

If you are willing to install full fledged compiler on your Linux machine, then please check official website Installing the Solidity Compiler.

    38 Lectures 
     4.5 hours 

 Abhilash Nelson

    62 Lectures 
     8.5 hours 

 Frahaan Hussain

    31 Lectures 
     3.5 hours 

 Swapnil Kole
 Print
 Add Notes
 Bookmark this page
JavaScript Proxy() Object

The JavaScript proxy() object wraps an object or function and is used for custom actions for fundamental operations like accessing property , invoking function etc.
Following is the code for proxy() object in JavaScript −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .sample {
      font-size: 18px;
      font-weight: 500;
      color: red;
   }
</style>
</head>
<body>
<h1>JavaScript Proxy() Object</h1>
<div class="sample"></div>
<button class="Btn">CLICK HERE</button>
<h3>
Click on the above button to access object values using proxy object
</h3>
<script>
   let sampleEle = document.querySelector('.sample');
   const test = {
      Name: 'Rohan Sharma',
      birthYear: 1990,
   };
   const handler = {
      get: function(target, objectKey) {
         if (objectKey === 'FirstName') {
            return target.Name.split(' ')[0];
         }
         if (objectKey === 'CurrentAge') {
            let date = new Date();
            return date.getFullYear() - target.birthYear;
         } else {
            return Reflect.get(target,objectKey);
         }
      }
   };
   const proxy1 = new Proxy(test, handler);
   document.querySelector('.Btn').addEventListener('click',()=>{
      sampleEle.innerHTML += 'proxy1.Firstname = ' + proxy1.FirstName + '<br>';
      sampleEle.innerHTML += 'proxy1.CurrentAge = ' + proxy1.CurrentAge + '<br>';
   })
</script>
</body>
</html>
On clicking the ‘CLICK HERE’ button −
C | String | Question 5 - GeeksforGeeks

05 Feb, 2013
What does the following fragment of C-program print?
char c[] = "GATE2011"; char *p =c; printf("%s", p + p[3] - p[1]) ;
(A) GATE2011(B) E2011(C) 2011(D) 011Answer: (C)Explanation: See comments for explanation.

char c[] = "GATE2011"; 
 
 // p now has the base address string "GATE2011" 
char *p = c;  
 
// p[3] is 'E' and p[1] is 'A'. 
// p[3] - p[1] = ASCII value of 'E' - ASCII value of 'A' = 4 
// So the expression  p + p[3] - p[1] becomes p + 4 which is 
// base address of string "2011" 
printf("%s", p + p[3] - p[1]);  // prints 2011
C-String
C-String-Question
C Language
C Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Multidimensional Arrays in C / C++
rand() and srand() in C/C++
fork() in C
Core Dump (Segmentation fault) in C/C++
Left Shift and Right Shift Operators in C/C++
Compiling a C program:- Behind the Scenes
Operator Precedence and Associativity in C
C | Pointer Basics | Question 15
C | Structure & Union | Question 4
C | File Handling | Question 1
numpy.absolute() in Python - GeeksforGeeks

29 Nov, 2018
numpy.absolute(arr, out = None, ufunc ‘absolute’) : This mathematical function helps user to calculate absolute value of each element. For complex input, a + ib, the absolute value is .
Parameters :
arr  : [array_like] Input array or object whose elements, we need to test.

Return :
An array with absolute value of each array.  

 Code #1 : Working
# Python program explaining# absolute () function  import numpy as np  arr1 = [1, -3, 15, -466]print ("Absolute Value of arr1 : \n",                    np.absolute(arr1))  arr2 = [23 , -56]print ("\nAbsolute Value of arr2 : \n",                        np.absolute(arr2))
Output :
Absolute Value of arr1 : 
 [  1   3  15 466]

Absolute Value of arr2 : 
 [23 56]

 Code #2 : Working with complex numbers
# Python program explaining# absolute () function  import numpy as np  a = 4 + 3jprint("Absolute(4 + 3j) : ",             np.absolute(a))  b = 16 + 13jprint("\nAbsolute value(16 + 13j) : ",                        np.absolute(b))
Output :
Absolute(4 + 3j) :  5.0

Absolute value(16 + 13j) :  20.6155281281
 Code #3: Graphical Representation of numpy.absolute()
# Python program explaining# absolute () function  import numpy as npimport matplotlib.pyplot as plt  a = np.linspace(start = -5, stop = 5,                num = 6, endpoint = True)                  print("Graphical Representation : \n",                        np.absolute(a))  plt.title("blue : with absolute\nred : without absolute")plt.plot(a, np.absolute(a))  plt.plot(a, a, color = 'red')plt.show()
Output :
Graphical Representation : 
 [ 5.  3.  1.  1.  3.  5.]

References :https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.absolute.html.
Python numpy-Mathematical Function
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
Python | Arrange the files in directories according to extensions - GeeksforGeeks

09 Sep, 2019
In this article, we will learn how to arrange the files in different directories according to their extensions. When you have a lot of files with different extension than you can simply use the script for your help.
Below is the Python implementation –
import os  # Using system functions  import shutil # Moving file to different folders.  # Changing the folder location.os.chdir(os.getcwd())cwd = os.getcwd()  # For listing files from the folder.  l = [f for f in os.listdir(cwd) if os.path.isfile(f)] l2 = []  # Get the extension of file from list l.  for  value in l:    s = value.split('.')[1]     l2.append(s)print(l, l2)  # We remove duplicate values from # list l2 and checks if directory # exists otherwise we create new one  for extension in set(l2):    dirname = extension     if os.path.exists(cwd+'\'+extension):        pass    else:        os.makedirs(dirname)  # We use zip function and list l and# l2 passed as arguments.# If extension in file is same and# file not exists then we move the file.  for files, extension in zip(l, l2):    if extension in files:        if os.path.exists(cwd+'\'+extension+'\'+files):            pass        else:            shutil.move(cwd+'\'+files, cwd+'\'+extension)        print(extension, files)    else :        print('error')
Files Not Arranged:
Files Arranged:
['arrange.py', 'mydata.pdf', 'python.exe', 'resume.doc'] ['py', 'pdf', 'exe', 'doc']
py arrange.py
pdf mydata.pdf
exe python.exe
doc resume.doc

python-utility
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
How to Use Terminal in Sublime Text Editor ? - GeeksforGeeks

06 Jun, 2021
Well in Visual Studio Code we get a direct Option for opening Terminal, Unlike Sublime Text editor. Sublime is Simple and free to use, Light on memory, and can easily work with multiple projects. In this article, we will see how to use the terminal in a sublime text editor.
Step 1: Open Sublime Text,
Step 2: Open Command Palette using command Ctrl+shift+p
Type the below until the option appears and select it.
Package Control: Install Package
Note: You’ll need to install package control if you are using it for the first time.
Type ‘Terminus’ and select it. Wait for it to Complete installation and Restart sublime text.
Step 3: Now go to Preferences >Package Settings > Terminus > Command Palette
Now paste this code in the Default sublime Commands Section
[
   {
        "caption": "Terminal (panel)",
        "command": "terminus_open",
        "args"   : {
           "cmd": "bash",
           "cwd": "${file_path:${folder}}",
           "title": "Command Prompt",
           "panel_name": "Terminus"
        }
   },
]  
And save it.
Note: The above code is for Linux users for Windows users you have to enter “cmd.exe” in place of “bash”
Step 4: Now go to Preferences >Package Settings > Terminus > Key Bindings
Now paste this code in the Default sublime Keymap Section and save it:
[
   {
       "keys": ["alt+1"],
       "command": "terminus_open",
       "args" : {
           "cmd": "bash",
           "cwd": "${file_path:${folder}}",
           "panel_name": "Terminus"
       }
   }
] 
Note: The above code is for Linux users for Windows users you have to enter “cmd.exe” in place of “bash”, also here we kept the shortcut key as “alt+1” you can use your own key.
Step 5: So whenever you want to use terminal press alt+1 and to close terminal type exit in the terminal and hit enter.
How To
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install FFmpeg on Windows?
How to Set Git Username and Password in GitBash?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Create and Setup Spring Boot Project in Eclipse IDE?
How to Install Jupyter Notebook on MacOS?
Sed Command in Linux/Unix with examples
AWK command in Unix/Linux with examples
grep command in Unix/Linux
cut command in Linux with examples
TCP Server-Client implementation in C
How to declare a constructor in Java?

While declaring the constructors you should keep the following points in mind.
A constructor does not have a return type.
The name of the constructor is same as the name of the class.
 A class can have more than one constructor.
public class Sample {
   int num;
   public Sample() {
      num = 30;
   }
   public Sample(int value) {
      num = value;
   }
}
Responsive grid with Bootstrap

To create a responsive grid in Bootstrap, use the .col-*-* class in Bootstrap.
In the below example, we have 4 divs −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "container-fluid">
         <div class = "row">
            <div class = "col-sm-3 col-md-6 col-lg-4" style = "color:white;background-color:orange;">
               This is div1.
            </div>
            <div class = "col-sm-9 col-md-6 col-lg-8" style = "color:white;background-color:blue;">
               This is div2.
            </div>
            <div class = "col-sm-3 col-md-6 col-lg-4" style = "color:white;background-color:green;">
               This is div3.
            </div>
            <div class = "col-sm-9 col-md-6 col-lg-8" style = "color:white;background-color:gray;">
               This is div4.
            </div>
         </div>
      </div>
   </body>
</html>
Remove Leading whitespaces from a String in R Language - trimws() Function - GeeksforGeeks

23 Dec, 2021
In this article, we are going to see how to remove whitespaces from a String in R Programming Language.
trimws() function in R Language is used to trim the leading white spaces. It shrinks an object by removing outermost rows and columns with the same values.
Syntax: trimws(x)
Parameters: 
x: Object or character string
R
# R program to illustrate# Removing of leading whitespaces # Create example character stringmy_text <- "     . This is a trim     function     example " # Apply trimws function in Rprint(trimws(my_text))
Output: 
".  This is a trim       function      example"
Here in the above code, we have created a character string and have white spaces in it, So we have used the trimws() function to remove the white spaces.
R
# R program to illustrate# Removing of leading whitespaces # Create example character stringmy_text <- "     Geeks_For_Geeks     " # Apply trimws function in Rprint(trimws(my_text))
Output:
"Geeks_For_Geeks     "
kumar_satyam
Programming Language
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
R - Data Types
7 Highest Paying Programming Languages For Freelancers in 2022
Introduction of Object Oriented Programming
R - Matrices
R - Charts and Graphs
Change column name of a given DataFrame in R
How to Replace specific values in column in R DataFrame ?
Adding elements in a vector in R programming - append() method
How to change Row Names of DataFrame in R ?
Filter data by multiple conditions in R using Dplyr
Getting first letter of each word in a String using regex in Java

A word is contiguous series of alphabetic characters. Using regex, we need to search the boundary character to be between A to Z or a to z. Consider the following cases −
Input: Hello World
Output: H W

Input: Welcome to world of Regex
Output: W t w o R
We'll use the regex as "\\b[a-zA-Z]" where \\b signifies the boundary matchers. See the example −
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Tester {
   public static void main(String[] args) {

      String input1 = "Hello World";
      String input2 = "Welcome to world of Regex";
      Pattern p = Pattern.compile("\\b[a-zA-Z]");

      Matcher m = p.matcher(input1);
      System.out.println("Input: " + input1);
      System.out.print("Output: ");
      while (m.find()){
         System.out.print(m.group() + " ");
      }
      System.out.println("\n");

      m = p.matcher(input2);
      System.out.println("Input: " + input2);
      System.out.print("Output: ");
      while (m.find()){
         System.out.print(m.group() + " ");
      }
      System.out.println();
   }
}
Input: Hello World
Output: H W

Input: Welcome to world of Regex
Output: W t w o R
Java Program to wrap text in a JTextPane and show Scrollbar

Let’s say we have lots of content in our JTextPane component −
textPane.setText("This is demo text1. This is demo text2. This is demo text3."
   + "This is demo text4.This is demo text5. This is demo text6. "
   + "This is demo text7. This is demo text8. This is demo text9. "
   + "This is demo text10. This is demo text11. This is demo text12."
   + "This is demo text13. This is demo text13. This is demo text14."
   + "This is demo text15. This is demo text13. This is demo text16."
   + " This is demo text17. This is demo text13. This is demo text18."
   + " This is demo text19.This is demo text13.This is demo text20.");
To wrap it and display the scrollbar, set scrollpane and use the VERTICAL_SCROLLBAR_AS_NEEDED constant −
JScrollPane scrollPane = new JScrollPane(textPane);
scrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
package my;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.text.BadLocationException;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
public class SwingDemo {
   public static void main(String args[]) throws BadLocationException {
      JFrame frame = new JFrame("Demo");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      Container container = frame.getContentPane();
      JTextPane textPane = new JTextPane();
      textPane.setBackground(Color.BLUE);
      Font font = new Font("Serif", Font.ITALIC, 22);
      textPane.setFont(font);
      SimpleAttributeSet attributeSet = new SimpleAttributeSet();
      StyleConstants.setItalic(attributeSet, true);
      StyleConstants.setForeground(attributeSet, Color.blue);
      StyleConstants.setBackground(attributeSet, Color.white);
      textPane.setCharacterAttributes(attributeSet, true);
      textPane.setText("This is demo text1. This is demo text2. This is demo text3."
         + "This is demo text4.This is demo text5. This is demo text6. "
         + "This is demo text7. This is demo text8. This is demo text9. "
         + "This is demo text10. This is demo text11. This is demo text12."
         + "This is demo text13. This is demo text13. This is demo text14."
         + "This is demo text15. This is demo text13. This is demo text16."
         + " This is demo text17. This is demo text13. This is demo text18."
         + " This is demo text19.This is demo text13.This is demo text20.");
      JScrollPane scrollPane = new JScrollPane(textPane);
      scrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
      container.add(scrollPane, BorderLayout.CENTER);
      frame.setSize(500, 300);
      frame.setVisible(true);
   }
}
String compareTo(String anotherString)

This method compares two strings lexicographically.
Here is the syntax of this method −
int compareTo(String anotherString)

Here is the detail of parameters −
anotherString − the String to be compared.
anotherString − the String to be compared.
The value 0 if the argument is a string lexicographically equal to this string; a value less than 0 if the argument is a string lexicographically greater than this string; and a value greater than 0 if the argument is a string lexicographically less than this string.
The value 0 if the argument is a string lexicographically equal to this string; a value less than 0 if the argument is a string lexicographically greater than this string; and a value greater than 0 if the argument is a string lexicographically less than this string.
public class Test {

   public static void main(String args[]) {
      String str1 = "Strings are immutable";
      String str2 = "Strings are immutable";
      String str3 = "Integers are not immutable";
      
      int result = str1.compareTo( str2 );
      System.out.println(result);
      
      result = str2.compareTo( str3 );
      System.out.println(result);
      
      result = str3.compareTo( str1 );
      System.out.println(result);
   }
}
This will produce the following result −
0
10
-10


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page