code-rag-bench/online-tutorials huggingface dataset:
filepath.Abs() Function in Golang With Examples - GeeksforGeeks

10 May, 2020
In Go language, path package used for paths separated by forwarding slashes, such as the paths in URLs. The filepath.Abs() function in Go language used to return an absolute representation of the specified path. If the path is not absolute it will be joined with the current working directory to turn it into an absolute path. Moreover, this function is defined under the path package. Here, you need to import the “path/filepath” package in order to use these functions.
Syntax:
func Abs(path string) (string, error)

Here, ‘path’ is the specified path.
Return Value: It return an absolute representation of the specified path.
Example 1:
// Golang program to illustrate the usage of// filepath.Abs() function  // Including the main packagepackage main  // Importing fmt and path/filepathimport (    "fmt"    "path/filepath")  // Calling mainfunc main() {      // Calling the Abs() function to get    // absolute representation of the specified path    fmt.Println(filepath.Abs("/home/gfg"))    fmt.Println(filepath.Abs(".gfg"))    fmt.Println(filepath.Abs("/gfg"))    fmt.Println(filepath.Abs(":gfg"))}
Output:
/home/gfg <nil>
/.gfg <nil>
/gfg <nil>
/:gfg <nil>

Example 2:
// Golang program to illustrate the usage of// filepath.Abs() function  // Including the main packagepackage main  // Importing fmt and path/filepathimport (    "fmt"    "path/filepath")  // Calling mainfunc main() {      // Calling the Abs() function to get    // absolute representation of the specified path    fmt.Println(filepath.Abs("/"))    fmt.Println(filepath.Abs("."))    fmt.Println(filepath.Abs(":"))    fmt.Println(filepath.Abs("/."))    fmt.Println(filepath.Abs("//"))    fmt.Println(filepath.Abs(":/"))}
Output:
/ <nil>
/ <nil>
/: <nil>
/ <nil>
/ <nil>
/: <nil>

Golang-filepath
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Parse JSON in Golang?
Defer Keyword in Golang
Time Durations in Golang
Anonymous function in Go Language
How to iterate over an Array using for loop in Golang?
time.Parse() Function in Golang With Examples
Loops in Go Language
Strings in Golang
Class and Object in Golang
Structures in Golang
How to get value from the first checkbox which is not hidden in jQuery?

To get value from the first checkbox, which is not hidden, use the :visible selector. Following is the code −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initialscale=1.0">
<title>>Document</title>
<link rel="stylesheet"
href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<style>
   .notShown {
      display: none;
}
</style>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<div class='form'>
<input class="demo notShown" type="checkbox" value="first"
checked="checked" />
<br />
<input class="demo" type="checkbox" value="second"
checked="checked"/>
<br />
<input class="demo" type="checkbox" value="third" />
<br />
<input class="demo " type="checkbox" value="fourth"
checked="checked" />
</div>
<script>
   var v=$('input:checkbox:checked:visible:first').val();
   console.log(v);
</script>
</body>
</html>
To run the above program, save the file name “anyName.html(index.html)” and right click on the file. Select the option “Open with Live Server” in VS Code editor.
This will produce the following output displaying the visible value “second” in console −
How to set the color to alternate rows of JTable in Java?

A JTable is a subclass of JComponent class and it can be used to create a table with information displayed in multiple rows and columns. When a value is selected from a JTable, a TableModelEvent is generated, which is handled by implementing a TableModelListener interface.
We can set the color to alternate rows of JTable by overriding the prepareRenderer() method of JTable class.
public Component prepareRenderer(TableCellRenderer renderer, int row, int column)
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
public class AlternateRowColorTableTest extends JFrame {
   public AlternateRowColorTableTest() {
      setTitle("AlternateRowColorTable Test");
      JTable table = new JTable(new Object[][] {{"115", "Ramesh"}, {"120", "Adithya"}, {"125", "Jai"}, {"130", "Chaitanya"}, {"135", "Raja"}}, new String[] {"Employee Id", "Employee Name"}) {
         public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
            Component comp = super.prepareRenderer(renderer, row, column);
            Color alternateColor = new Color(200, 201, 210);
            Color whiteColor = Color.WHITE;
            if(!comp.getBackground().equals(getSelectionBackground())) {
               Color c = (row % 2 == 0 ? alternateColor : whiteColor);
               comp.setBackground(bg);
               c = null;
            }
            return returnComp;
         }
      };
      add(new JScrollPane(table));
      setSize(400, 300);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setLocationRelativeTo(null);
      setVisible(true);
   }
   public static void main(String[] args) {
      new AlternateRowColorTableTest();
   }
}
How to get installed windows update using PowerShell?

To get the installed windows updates using PowerShell, we can use the Get-Hotfix command. This command gets the hotfixes and updates that are installed on the local and the remote computer.
This command is the part of Microsoft.Management.PowerShell utility.
Get-HotFix
PS C:\> Get-HotFix
Source Description HotFixID InstalledBy InstalledOn
------ ----------- -------- ----------- -----------
LABMACHINE... Update KB3191565 LABMACHINE2K12\Ad... 1/15/2021 12:00:00 AM
LABMACHINE... Update KB2999226 LABMACHINE2K12\Ad... 1/13/2021 12:00:00 AM
In the above output, you can see the SourceMachine Name, HotfixID, InstalledBy, and the Installed Date.
You can also sort it by the InstalledOn parameter. For example,
Get-HotFix | Sort-Object InstalledOn -Descending
This command supports the ComputerName parameter which is a string array so we can pass the multiple remote computers to get the installed hotfixes.
PS C:\> help Get-HotFix -Parameter ComputerName
-ComputerName <System.String[]>
Specifies a remote computer. Type the NetBIOS name, an Internet Protocol (IP) address, or a fully qualified domain name (FQDN) of a remote computer.
For example,
Get-HotFix -ComputerName LabMachine2k12,AD,LabMachine2k16
How to match non-digits using Java Regular Expression (RegEx)

You can match non-digit character using the meta character "\\D".
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
   public static void main(String args[]) {
      //Reading String from user
      System.out.println("Enter a String");
      Scanner sc = new Scanner(System.in);
      String input = sc.nextLine();
      String regex = "\\D";
      //Compiling the regular expression
      Pattern pattern = Pattern.compile(regex);
      //Retrieving the matcher object
      Matcher matcher = pattern.matcher(input);
      int count = 0;
      while(matcher.find()) {
         count++;
      }
      System.out.println("Number non-digit characters: "+count);
   }
}
Enter a String
sample text 2425 36
Number non-digit characters: 13
import java.util.Scanner;
public class RegexExample {
   public static void main( String args[] ) {
      //regular expression to accept 5 letter word
      String regex = "\\D{10}";
      System.out.println("Enter input value: ");
      Scanner sc = new Scanner(System.in);
      String input = sc.nextLine();
      boolean result = input.matches(regex);
      if(result) {
         System.out.println("input matched");
      }
      else {
         System.out.println("wrong input");
      }
   }
}
Enter input value:
sample abc
input matched
Enter input value:
sample1234
wrong input
GATE | GATE-CS-2015 (Set 1) | Question 65 - GeeksforGeeks

19 Feb, 2021
Suppose the following disk request sequence (track numbers) for a disk with 100 tracks is given: 45, 20, 90, 10, 50, 60, 80, 25, 70. Assume that the initial position of the R/W head is on track 50. The additional distance that will be traversed by the R/W head when the Shortest Seek Time First (SSTF) algorithm is used compared to the SCAN (Elevator) algorithm (assuming that SCAN algorithm moves towards 100 when it starts execution) is _________ tracks(A) 8(B) 9(C) 10(D) 11Answer: (C)Explanation: In Shortest seek first (SSTF), closest request to the current position of the head, and then services that request next.
In SCAN (or Elevator) algorithm, requests are serviced only in the current direction of arm movement until the arm reaches the edge of the disk. When this happens, the direction of the arm reverses, and the requests that were remaining in the opposite direction are serviced, and so on.
Given a disk with 100 tracks 

And Sequence 45, 20, 90, 10, 50, 60, 80, 25, 70.

Initial position of the R/W head is on track 50.

In SSTF, requests are served as following

Next Served     Distance Traveled
  50                   0
  45                   5
  60                  15   
  70                  10   
  80                  10   
  90                  10
  25                  65   
  20                   5   
  10                  10
-----------------------------------     
Total Dist         =  130


If Simple SCAN is used, requests are served as following

Next Served     Distance Traveled
  50                   0
  60                  10   
  70                  10   
  80                  10   
  90                  10
  45                  65 [disk arm goes to 99, then to 45]
  25                  20   
  20                   5   
  10                  10
-----------------------------------     
Total Dist         =  140


Less Distance traveled in SSTF = 130 - 140 =  10 
Therefore, it is not additional but it is less distance traversed by SSTF than SCAN.
Quiz of this Question
GATE-CS-2015 (Set 1)
GATE-GATE-CS-2015 (Set 1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-IT-2004 | Question 71
GATE | GATE CS 2011 | Question 7
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2014-(Set-3) | Question 38
GATE | GATE CS 2018 | Question 37
GATE | GATE-CS-2016 (Set 1) | Question 65
GATE | GATE-IT-2004 | Question 83
GATE | GATE-CS-2016 (Set 1) | Question 63
GATE | GATE-CS-2014-(Set-2) | Question 65
ML | Implementation of KNN classifier using Sklearn - GeeksforGeeks

28 Nov, 2019
Prerequisite: K-Nearest Neighbours Algorithm
K-Nearest Neighbors is one of the most basic yet essential classification algorithms in Machine Learning. It belongs to the supervised learning domain and finds intense application in pattern recognition, data mining and intrusion detection. It is widely disposable in real-life scenarios since it is non-parametric, meaning, it does not make any underlying assumptions about the distribution of data (as opposed to other algorithms such as GMM, which assume a Gaussian distribution of the given data).
This article will demonstrate how to implement the K-Nearest neighbors classifier algorithm using Sklearn library of Python.
Step 1: Importing the required Libraries
import numpy as npimport pandas as pdfrom sklearn.model_selection import train_test_splitfrom sklearn.neighbors import KNeighborsClassifierimport matplotlib.pyplot as plt import seaborn as sns
 Step 2: Reading the Dataset
cd C:\Users\Dev\Desktop\Kaggle\Breast_Cancer# Changing the read file location to the location of the file  df = pd.read_csv('data.csv')  y = df['diagnosis']X = df.drop('diagnosis', axis = 1)X = X.drop('Unnamed: 32', axis = 1)X = X.drop('id', axis = 1)# Separating the dependent and independent variable  X_train, X_test, y_train, y_test = train_test_split(             X, y, test_size = 0.3, random_state = 0)# Splitting the data into training and testing data
 Step 3: Training the model
K = []training = []test = []scores = {}  for k in range(2, 21):    clf = KNeighborsClassifier(n_neighbors = k)    clf.fit(X_train, y_train)      training_score = clf.score(X_train, y_train)    test_score = clf.score(X_test, y_test)    K.append(k)      training.append(training_score)    test.append(test_score)    scores[k] = [training_score, test_score]
 Step 4: Evaluating the model
for keys, values in scores.items():    print(keys, ':', values)
 We now try to find the optimum value for ‘k’ ie the number of nearest neighbors.
Step 5: Plotting the training and test scores graph
ax = sns.stripplot(K, training);ax.set(xlabel ='values of k', ylabel ='Training Score')    plt.show()# function to show plot
ax = sns.stripplot(K, test);ax.set(xlabel ='values of k', ylabel ='Test Score')plt.show()
plt.scatter(K, training, color ='k')plt.scatter(K, test, color ='g')plt.show()# For overlapping scatter plots
From the above scatter plot, we can come to the conclusion that the optimum value of k will be around 5.
shubham_singh
Machine Learning
Python
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Support Vector Machine Algorithm
k-nearest neighbor algorithm in Python
Singular Value Decomposition (SVD)
Difference between Informed and Uninformed Search in AI
Normalization vs Standardization
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
How to detect swipe vertically on a ScrollView using Swift?

To detect swipe in scrollView we will need to make use of some tricks as scroll view does not natively give the directions of scroll made on it. We’ll see this with help of an example.
Create an empty project, add scroll view to the view as per your requirement.
Give them constraint as required in the application.
From the object library, drag and drop a swipe gesture recognizer right above the Scroll View.
Select the gesture recognizer, go to its attribute inspector and from there, select the swipe option and set the value as “up”.
When you do this, now your gesture recognizer can recognize up swipes only. Now you need to create a method for this swipe gesture.
@IBAction func swipeMade(_ sender: UISwipeGestureRecognizer) {
   if sender.direction == .up {
      print("up swipe made")
      // perform actions here.
   }
}
When you write this code, the recognizer sends events to this method, and if the swipe direction is up, it will come inside the if block. You can perform your desired operation here.
When we run this code on a device and make a swipe, below is the result that’s produced on the console.
How to perform the arithmetic operations on arrays in C language?

An array is a group of related data items that are stored with single name.
For example, int student[30]; //student is an array name that holds 30 collection of data items with a single variable name
Searching − It is used to find whether particular element is present or not
Searching − It is used to find whether particular element is present or not
Sorting − It helps in arranging the elements in an array either in ascending or descending order.
Sorting − It helps in arranging the elements in an array either in ascending or descending order.
Traversing − It processes every element in an array sequentially.
Traversing − It processes every element in an array sequentially.
Inserting − It helps in inserting the elements in an array.
Inserting − It helps in inserting the elements in an array.
Deleting − It helps in deleting an element in an array.
Deleting − It helps in deleting an element in an array.
The logic to perform all arithmetic operations in an array is as follows −
for(i = 0; i < size; i ++){
   add [i]= A[i] + B[i];
   sub [i]= A[i] - B[i];
   mul [i]= A[i] * B[i];
   div [i] = A[i] / B[i];
   mod [i] = A[i] % B[i];
}
Following is the C program for arithmetic operations on arrays −
 Live Demo
#include<stdio.h>
int main(){
   int size, i, A[50], B[50];
   int add[10], sub[10], mul[10], mod[10];
   float div[10];
   printf("enter array size:\n");
   scanf("%d", &size);
   printf("enter elements of 1st array:\n");
   for(i = 0; i < size; i++){
      scanf("%d", &A[i]);
   }
   printf("enter the elements of 2nd array:\n");
   for(i = 0; i < size; i ++){
      scanf("%d", &B[i]);
   }
   for(i = 0; i < size; i ++){
      add [i]= A[i] + B[i];
      sub [i]= A[i] - B[i];
      mul [i]= A[i] * B[i];
      div [i] = A[i] / B[i];
      mod [i] = A[i] % B[i];
   }
   printf("\n add\t sub\t Mul\t Div\t Mod\n");
   printf("------------------------------------\n");
   for(i = 0; i <size; i++){
      printf("\n%d\t ", add[i]);
      printf("%d \t ", sub[i]);
      printf("%d \t ", mul[i]);
      printf("%.2f\t ", div[i]);
      printf("%d \t ", mod[i]);
   }
   return 0;
}
When the above program is executed, it produces the following result −
Run 1:
enter array size:
2
enter elements of 1st array:
23
45
enter the elements of 2nd array:
67
89
add    sub     Mul    Div    Mod
------------------------------------
90    -44     1541  0.00    23
134    -44    4005  0.00    45
Run 2:
enter array size:
4
enter elements of 1st array:
89
23
12
56
enter the elements of 2nd array:
2
4
7
8
add  sub Mul  Div   Mod
------------------------------------
91  87  178   44.00  1
27  19  92    5.00   3
19  5   84    1.00    5
64  48  448   7.00    0
How to check the column values have string or digits in MySQL?

If you want only the string values, then use the below syntax −
select *from yourTableName where yourColumnName NOT regexp '^[0-9]+$';
If you want only the digit, then use the below syntax −
select *from yourTableName where yourColumnName regexp '^[0-9]+$';
Let us first create a table −
mysql> create table DemoTable(
   Id varchar(100)
);
Query OK, 0 rows affected (0.49 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('1000');
Query OK, 1 row affected (0.16 sec)
mysql> insert into DemoTable values('John');
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable values('Carol_Smith');
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable values('2000');
Query OK, 1 row affected (0.10 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------------+
| Id          |
+-------------+
| 1000        |
| John        |
| Carol_Smith |
| 2000        |
+-------------+
4 rows in set (0.00 sec)
CASE 1 − Following is the query to get only the string value −
mysql> select *from DemoTable where Id NOT regexp '^[0-9]+$';
This will produce the following output displaying only the string column values −
+-------------+
| Id          |
+-------------+
| John        |
| Carol_Smith |
+-------------+
2 rows in set (0.00 sec)
CASE 2 − Following is the query to get only the digits −
mysql> select *from DemoTable where Id regexp '^[0-9]+$';
This will produce the following output displaying only the digit column values −
+------+
| Id   |
+------+
| 1000 |
| 2000 |
+------+
2 rows in set (0.00 sec)
C++ program to print Happy Birthday

This is a C++ program to print Happy Birthday.
Begin
   Take a str1 which takes the next character of our desired ouput like for H it will be G.
   Assign the string to a pointer p.
   Make a while loop till *p != NULL.
      Go next character of the string print it and after that go the nextposition of string.
   Print the result.
End
#include<iostream>
using namespace std;
main(){
   char str[]="G`ooxAhqsgc`x",*p;
   p=str;
   while(*p!='\0')
      ++*p++;
   cout<<str;
}
HappyBirthday
ScheduledExecutorService Interface

A java.util.concurrent.ScheduledExecutorService interface is a subinterface of ExecutorService interface, and supports future and/or periodic execution of tasks.
<V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit)
Creates and executes a ScheduledFuture that becomes enabled after the given delay.
ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)
Creates and executes a one-shot action that becomes enabled after the given delay.
ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)
Creates and executes a periodic action that becomes enabled first after the given initial delay, and subsequently with the given period; that is executions will commence after initialDelay then initialDelay+period, then initialDelay + 2 * period, and so on.
ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
Creates and executes a periodic action that becomes enabled first after the given initial delay, and subsequently with the given delay between the termination of one execution and the commencement of the next.
The following TestThread program shows usage of ScheduledExecutorService interface in thread based environment.
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

public class TestThread {

   public static void main(final String[] arguments) throws InterruptedException {
      final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);

      final ScheduledFuture<?> beepHandler = 
         scheduler.scheduleAtFixedRate(new BeepTask(), 2, 2, TimeUnit.SECONDS);

      scheduler.schedule(new Runnable() {

         @Override
         public void run() {
            beepHandler.cancel(true);
            scheduler.shutdown();			
         }
      }, 10, TimeUnit.SECONDS);
   }

   static class BeepTask implements Runnable {
      
      public void run() {
         System.out.println("beep");      
      }
   }
}
This will produce the following result.
beep
beep
beep
beep


    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
ReactJS - Props Validation

Properties validation is a useful way to force the correct usage of the components. This will help during development to avoid future bugs and problems, once the app becomes larger. It also makes the code more readable, since we can see how each component should be used.
In this example, we are creating App component with all the props that we need. App.propTypes is used for props validation. If some of the props aren't using the correct type that we assigned, we will get a console warning. After we specify validation patterns, we will set App.defaultProps.
import React from 'react';

class App extends React.Component {
   render() {
      return (
         <div>
            <h3>Array: {this.props.propArray}</h3>
            <h3>Bool: {this.props.propBool ? "True..." : "False..."}</h3>
            <h3>Func: {this.props.propFunc(3)}</h3>
            <h3>Number: {this.props.propNumber}</h3>
            <h3>String: {this.props.propString}</h3>
            <h3>Object: {this.props.propObject.objectName1}</h3>
            <h3>Object: {this.props.propObject.objectName2}</h3>
            <h3>Object: {this.props.propObject.objectName3}</h3>
         </div>
      );
   }
}

App.propTypes = {
   propArray: React.PropTypes.array.isRequired,
   propBool: React.PropTypes.bool.isRequired,
   propFunc: React.PropTypes.func,
   propNumber: React.PropTypes.number,
   propString: React.PropTypes.string,
   propObject: React.PropTypes.object
}

App.defaultProps = {
   propArray: [1,2,3,4,5],
   propBool: true,
   propFunc: function(e){return e},
   propNumber: 1,
   propString: "String value...",
   
   propObject: {
      objectName1:"objectValue1",
      objectName2: "objectValue2",
      objectName3: "objectValue3"
   }
}
export default App;
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App.jsx';

ReactDOM.render(<App/>, document.getElementById('app'));

    20 Lectures 
     1.5 hours 

 Anadi Sharma

    60 Lectures 
     4.5 hours 

 Skillbakerystudios

    165 Lectures 
     13 hours 

 Paul Carlo Tordecilla

    63 Lectures 
     9.5 hours 

 TELCOMA Global

    17 Lectures 
     2 hours 

 Mohd Raqif Warsi
 Print
 Add Notes
 Bookmark this page
Random Numbers in C#

To generate random numbers in C#, use the Next(minValue, MaxValue) method. The parameters are used to set the minimum and maximum values.
Next(100,200);
We have set the above method under Random() object.
Random rd = new Random();
int rand_num = rd.Next(100,200);
The following is an example −
 Live Demo
using System;
class Program {
   static void Main() {
      Random rd = new Random();

      int rand_num = rd.Next(100,200);

      Console.WriteLine(rand_num);
   }
}
182
What is the range of MySQL DECIMAL(x,0)?

The range of DECIMAL data type is more than the INTEGER data type and BIGINT. As we know the BIGINT can store 18446744073709551615 while in DECIMAL you can store DECIMAL(65,0) where x represents the 65 nines(9). The DECIMAL stores the number in bytes and the storage requirement formula is: DECIMAL(x,0) i.e.
StorageRequirementInBytes = (x/9) + remaining;
WHERE remaining = round_up( (x%9) / 2 )
The DECIMAL(65,0) storage is as follows −
99999999999999999999999999999999999999999999999999999999999999999
To understand what we discussed above, let us create a table. The query to create a table is as follows −
mysql> create table DecimalDemo
-> (
-> UserId DECIMAL(65,0)
-> );
Query OK, 0 rows affected (0.62 sec)
Now you can insert some records in the table using insert command. The query is as follows −
mysql> insert into DecimalDemo
values(99999999999999999999999999999999999999999999999999999999999999999);
Query OK, 1 row affected (0.16 sec)
mysql> insert into DecimalDemo
values(99999999999999999999999999999999999999999999999999999999999999999.0);
Query OK, 1 row affected (0.28 sec)
Display all records from the table using a select statement. The query is as follows −
mysql> select *from DecimalDemo;
+-------------------------------------------------------------------+
| UserId |
+-------------------------------------------------------------------+
| 99999999999999999999999999999999999999999999999999999999999999999 |
| 99999999999999999999999999999999999999999999999999999999999999999 |
+-------------------------------------------------------------------+
2 rows in set (0.00 sec)
If you try to give 66 at the time of creation of the table, you will get the following error −
mysql> create table DecimalDemo1
-> (
-> UserId DECIMAL(66,0)
-> );
ERROR 1426 (42000): Too-big precision 66 specified for 'UserId'. Maximum is 65.
p5.js | textFont() Function

16 Apr, 2020
The textFont() function in p5.js is used to specify the font that will be used to draw text using the text() function. In the WEBGL mode, only the fonts loaded by the loadFont() method are supported.
Syntax:
textFont( font, size )
Parameters: This function accepts two parameters as mentioned above and described below:
font: It is a string that specifies the name of the web safe font or a font object loaded by the loadFont() function.
size: It is a number that specifies the size of the font to use. It is an optional parameter.
Return Value: It is an object that contains the current font.
Below examples illustrate the textFont() function in p5.js:
Example 1: This example shows the use of web safe fonts that are generally available on all systems.
function setup() {  createCanvas(600, 300);  textSize(30);    textFont('Helvetica');  text('This is the Helvetica font', 20, 80);  textFont('Georgia');  text('This is the Georgia font', 20, 120);  textFont('Times New Roman');  text('This is the Times New Roman font', 20, 160);  textFont('Courier New');  text('This is the Courier New font', 20, 200);}
Output:
Example 2: This example shows the use of a font loaded using the loadFont() function.
let newFont;  function preload() {  newFont = loadFont('fonts/Montserrat.otf');}  function setup() {  createCanvas(400, 200);  textSize(20);  fill("red");  text('Click once to print using "    + "a new loaded font', 20, 20);  fill("black");    text('Using the default font', 20, 60);  text('This is text written using"        + " the new font', 20, 80);}  function mouseClicked() {  textFont(newFont);  textSize(20);  text('Using the Montserrat font', 20, 140);  text('This is text written using the"       + " new loaded font', 20, 160);}
Output:
Online editor: https://editor.p5js.org/
Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
Reference: https://p5js.org/reference/#/p5/textFont
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to use Radio Component in ReactJS?

05 May, 2021
Radio buttons allow the user to select one option from a set. Material UI for React has this component available for us and it is very easy to integrate. We can use Radio Component in ReactJS using the following approach:
Creating React Application And Installing Module:
Step 1: Create a React application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:
cd foldername
Step 3: After creating the ReactJS application, Install the material-ui modules using the following command:
npm install @material-ui/core
Project Structure: It will look like the following.
Project Structure
App.js: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
Javascript
import React from 'react';import Radio from '@material-ui/core/Radio';import FormControl from '@material-ui/core/FormControl';import FormLabel from '@material-ui/core/FormLabel';import FormControlLabel from '@material-ui/core/FormControlLabel';import RadioGroup from '@material-ui/core/RadioGroup';  const App = () => {   return (    <div style={{      margin: 'auto',      display: 'block',      width: 'fit-content'    }}>      <h3>How to use Radio Component in ReactJS?</h3>      <FormControl component="fieldset">      <FormLabel component="legend">Select Your Gender</FormLabel>      <RadioGroup aria-label="gender" name="gender1">        <FormControlLabel value="male" control={<Radio />} label="Male" />        <FormControlLabel value="female" control={<Radio />} label="Female" />        <FormControlLabel value="other" control={<Radio />} label="Other" />      </RadioGroup>    </FormControl>    </div>  );} export default App;
  
Step to Run Application: Run the application using the following command from the root directory of the project:
 
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output:
 
 
simmytarika5
JavaScript
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
How to append HTML code to a div using JavaScript ?
Difference Between PUT and PATCH Request
How to fetch data from an API in ReactJS ?
How to redirect to another page in ReactJS ?
Axios in React: A Guide for Beginners
ReactJS Functional Components
find_element_by_class_name() driver method – Selenium Python

15 Apr, 2020
Selenium’s Python Module is built to perform automated testing with Python. Selenium Python bindings provides a simple API to write functional/acceptance tests using Selenium WebDriver. After you have installed selenium and checked out – Navigating links using get method, you might want to play more with Selenium Python. After one has opened a page using selenium such as geeksforgeeks, one might want to click some buttons automatically or fill a form automatically or any such automated task.
This article revolves around how to grab or locate elements in a webpage using locating strategies of Selenium Web Driver. More specifically, find_element_by_class_name() is discussed in this article.
driver.find_element_by_class_name("class_of_element")

Example –For instance, consider this page source:
<html> <body>  <p class="content">Site content goes here.</p></body><html>
Now after you have created a driver, you can grab an element using –
content = driver.find_element_by_class_name('content')

Let’s try to practically implement this method and get a element instance for “https://www.geeksforgeeks.org/”. Let’s try to grab search form input using its class name “gsc-input”.Create a file called run.py to demonstrate find_element_by_class_name method –
# Python program to demonstrate# selenium  # import webdriverfrom selenium import webdriver  # create webdriver objectdriver = webdriver.Firefox()  # enter keyword to searchkeyword = "geeksforgeeks"  # get geeksforgeeks.orgdriver.get("https://www.geeksforgeeks.org/")  # get element element = driver.find_element_by_class_name("gsc-input")  # print complete elementprint(element)
Now run using –
Python run.py
First, it will open firefox window with geeksforgeeks, and then select the element and print it on terminal as show below.Browser Output –Terminal Output –
NaveenArora
Python-selenium
selenium
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to display images in Angular2 ?

27 Jun, 2020
We can serve an image in angular2 by first placing the image in the assets directory of your project where you can create a specific directory for the images or just keep it in the assets directory as it is.Once you have put all the required images in the assets directory open the specific component typescript (.ts) file where you want to serve the image. Now you can add the URL of the image in a variable within the constructor so that it is initialized upon component creation.
ExampleDemo.Component.ts
import { Component, OnInit } from '@angular/core';  @Component({  selector: 'app-demo',  templateUrl: './demo.component.html',  styleUrls: ['./demo.component.css']})  export class DemoComponent implements OnInit {  ImagePath: string;    constructor() {    //image location    this.ImagePath = '/assets/images/sample.jpg'  }    ngOnInit() {  }  }
Now modify the component’s template file to fetch the image.Demo.Component.html
<!--...header and body content-->  <mat-card class="example-card" >  <mat-card-header class="example-header"                    style="padding-left: 40%;">   <h2><span></span>GeeksforGeeks</h2  >  </mat-card-header>  <mat-card-content>    <img [src] ="ImagePath"           style="width: 600px;height: 400px;">  </mat-card-content></mat-card>  <!--... body and footer content-->
Output: 
You can also fetch a web image directly from the website or database(For Ex. Firebase) by providing the full valid URL of the image.
NOTE:In angular2, images and other media are by default fetched from the assets directory within your project folder(all other directories of the project are not public to the components by default) this can be changed by modifying angular-cli.json.Within this JSON file add your media directory by adding it in the assets object property.
//add a new directory or image to start fetching from that location  "assets": [ "assets", "img", "favicon.ico", ".htaccess"]
AngularJS-Misc
Picked
HTML
JavaScript
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
Design a Tribute Page using HTML & CSS
Build a Survey Form using HTML and CSS
Design a web page using HTML and CSS
Angular File Upload
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
How to append HTML code to a div using JavaScript ?
Python | Deleting all occurrences of character

25 Jun, 2022
These days string manipulation is very popular in Python, and due to its immutable character, sometimes, it becomes more important to know its working and hacks. This particular article solves the problem of deleting all occurrences of a character from a string. Let’s discuss ways in which this can be achieved. 
Method #1: Using translate() Usually this function is used to convert a particular character to some other character. By translating the resultant removal character to “None”, this function can perform this task. This function works only for Python2 
Python
# Python code to demonstrate working of# Deleting all occurrences of character# Using translate() # initializing stringtest_str = "GeeksforGeeks & quot # initializing removal characterrem_char = "e & quot # printing original stringprint(& quot       The original string is : & quot       + str(test_str)) # Using translate()# Deleting all occurrences of characterres = test_str.translate(None, rem_char) # printing resultprint(& quot       The string after character deletion : & quot       + str(res))
The original string is : GeeksforGeeks
The string after character deletion : GksforGks
Method #2: Using replace() This function works functionally quite similarly to the above function, but it is recommended due to several reasons. It can be used in newer versions of Python and is more efficient than the above function. We replace the empty string instead of None as above for using this function to perform this task. 
Python3
# Python3 code to demonstrate working of# Deleting all occurrences of character# Using replace() # initializing stringtest_str = "GeeksforGeeks" # initializing removal characterrem_char = "e" # printing original stringprint("The original string is : " + str(test_str)) # Using replace()# Deleting all occurrences of characterres = test_str.replace(rem_char, "") # printing resultprint("The string after character deletion : " + str(res))
The original string is : GeeksforGeeks
The string after character deletion : GksforGks
Method #3: Without using any built-in methods
Python3
# Python3 code to demonstrate working of# Deleting all occurrences of character  # initializing stringtest_str = "GeeksforGeeks" # initializing removal characterrem_char = "e" # printing original stringprint("The original string is : " + str(test_str)) new_str = ""# Deleting all occurrences of characterfor i in test_str:    if(i != rem_char):        new_str += ires = new_str# printing resultprint("The string after character deletion : " + str(res))
The original string is : GeeksforGeeks
The string after character deletion : GksforGks
kogantibhavya
Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Python | Convert string dictionary to dictionary
while Loop in java

A while loop statement in Java programming language repeatedly executes a target statement as long as a given condition is true.
The syntax of a while loop is −
while(Boolean_expression) {
   // Statements
}

Here, statement(s) may be a single statement or a block of statements. The condition may be any expression, and true is any non zero value. 
When executing, if the boolean_expression result is true, then the actions inside the loop will be executed. This will continue as long as the expression result is true.
When the condition becomes false, program control passes to the line immediately following the loop.
Here, key point of the while loop is that the loop might not ever run. When the expression is tested and the result is false, the loop body will be skipped and the first statement after the while loop will be executed.
public class Test {

   public static void main(String args[]) {
      int x = 10;

      while( x < 20 ) {
         System.out.print("value of x : " + x );
         x++;
         System.out.print("\n");
      }
   }
}
This will produce the following result −
value of x : 10
value of x : 11
value of x : 12
value of x : 13
value of x : 14
value of x : 15
value of x : 16
value of x : 17
value of x : 18
value of x : 19


    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
Installation and Getting Started

You can easily install Jupyter notebook application using pip package manager.
pip3 install jupyter

To start the application, use the following command in the command prompt window.
c:\python36>jupyter notebook

The server application starts running at default port number 8888 and browser window opens to show notebook dashboard.
Observe that the dashboard shows a dropdown near the right border of browser with an arrow beside the New button. It contains the currently available notebook kernels. Now, choose Python 3, then a new notebook opens in a new tab. An input cell as similar to that of in IPython console is displayed.
You can execute any Python expression in it. The result will be displayed in the Out cell.

    22 Lectures 
     49 mins

 Bigdata Engineer
 Print
 Add Notes
 Bookmark this page
Chomsky Normal Form

Theory of Computation
In Automata, every grammar in Chomsky Normal Form is context-free. So, every context free grammar can be converted into Chomsky Normal Form. The name Chomsky Normal Form came from Noam Chomsky, who is an American linguist, philosopher and scientist. He had modelled knowledge of the language using formal grammars. He claimed that with the help of formal grammar, we can produce an infinite number of sentences with a limited set of grammatical rules. There are some conditions of grammar to belong in Chomsky Normal Form.
A context free grammar G = (V,Σ,P,S) is said to be in Chomsky Normal Form if all of its production rules are in the form.
A → BC, 
A → a, 
S → ε
Here, A, B and C are non-terminal symbols, where A,B,C ∈ N, a is the terminal symbol, where a ∈ Σ, S is the start symbol, where S → ε and ε is the empty string.
We can also say that any language (L) without any production is generated by the grammar G in which the productions are in the above form.
The context free grammar, under Chomsky Normal Form is formed with no unit productions, if any and the right hand side of any production has a single terminal or two or more symbols.
Suppose there is a grammar G with the productions P given by,
S -> aAbB 

A -> aA|a 

B -> bB|b
There, we have given productions in proper form -
A -> a 

B -> b
There is no productions in the set P.
Ba -> a 

Bb -> b 

// For S -> aAbB, we have
S -> BaABbB, 

// For A -> aA 
A -> BaA, 

// For B -> bB 
B -> BbB
In the above, we have only the following in non proper form-
S -> BaABbB
Let's taken two variables C1 and C2.
S -> BaABbB

S -> BaC1C2

C1 -> AC2

C2 -> BbB
So, the grammar G2, in Chomsky Normal Form with the productions written as - 
S -> BaC1C2

C1 -> AC2

C2 -> BbB

A -> BaA

B -> BbB

Ba -> a,

Bb -> b,

A -> a,

B -> b
Materialize - Chips

Materialize provides a special component called Chip, which can be used to represent a small set of information. For example, a contact, tags, etc.
chip
Set the div container as a chip.
The following example demonstrates the use of chip class to showcase creating various types of tags.
<!DOCTYPE html>
<html>
   <head>
      <title>The Materialize Chips Example</title>
         <meta name="viewport" content="width=device-width, initial-scale=1">
         <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
         <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/css/materialize.min.css">
         <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
         <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/js/materialize.min.js"></script>
   </head>
   <body class="container">
      <div class="chip">
         <img alt="HTML5" src="html5-mini-logo.jpg">HTML 5
      </div>
      <div class="chip">
         HTML 5<i class="material-icons">close</i>
      </div>
   </body>
</html>
Verify the output.
 Print
 Add Notes
 Bookmark this page
Scala Queue sum() method with example - GeeksforGeeks

29 Oct, 2019
The sum() method is utilized to return the sum of all the elements of the queue.
Method Definition: def sum: A
Return Type: It returns the sum of all the elements of the queue.
Example #1:
// Scala program of sum() // method   // Import Queue  import scala.collection.mutable._  // Creating object object GfG {       // Main method     def main(args:Array[String])     {               // Creating a queue         val q1 = Queue(1, 2, 3, 4, 5)                   // Print the queue        println(q1)                  // Applying sum method         val result = q1.sum                  // Display output        print("Sum of all elements of the queue: " + result)              } } 
Queue(1, 2, 3, 4, 5)
Sum of all elements of the queue: 15

Example #2:
// Scala program of sum() // method   // Import Queue  import scala.collection.mutable._  // Creating object object GfG {       // Main method     def main(args:Array[String])     {               // Creating a queue         val q1 = Queue(5, 2, 13, 7, 1)                   // Print the queue        println(q1)                  // Applying sum method         val result = q1.sum                  // Display output        print("Sum of all elements of the queue: " + result)              } } 
Queue(5, 2, 13, 7, 1)
Sum of all elements of the queue: 28

Scala
scala-collection
Scala-Method
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Scala Tutorial – Learn Scala with Step By Step Guide
Type Casting in Scala
Scala Lists
Class and Object in Scala
Scala String substring() method with example
Break statement in Scala
Lambda Expression in Scala
Scala String replace() method with example
Operators in Scala
Do I need to import the Java.lang package anytime during running a program?

No, java.lang package is a default package in Java therefore, there is no need to import it explicitly.
i.e. without importing you can access the classes of this package.
If you observe the following example here we haven’t imported the lang package explicitly but, still we are able to calculate the square root of a number using the sqrt() method of the java.lang.Math class.
 Live Demo
public class LangTest {
   public static void main(String args[]){
      int num = 100;
      double result = Math.sqrt(num);
      System.out.println("Square root of the number: "+result);
   }
}
Square root of the number: 10.0