code-rag-bench/online-tutorials huggingface dataset:
Can we call run() method directly instead of start() in Java

Yes, we can do that. Let us see an example −
 Live Demo
class my_thread extends Thread{
   public void run(){
      try{
         System.out.println ("The thread " + Thread.currentThread().getId() + " is currently running");
      }
      catch (Exception e){
         System.out.println ("The exception has been caught");
      }
   }
}
public class Main{
   public static void main(String[] args){
      int n = 6;
      for (int i=1; i<n; i++){
         my_thread my_object = new my_thread();
         my_object.run();
      }
   }
}
The thread 1 is currently running
The thread 1 is currently running
The thread 1 is currently running
The thread 1 is currently running
The thread 1 is currently running
A class named ‘my_thread’ inherits the main Thread, wherein a ‘run’ function is defined, that gives
the id of the current thread that is being run. A try and catch block is defined that catches an
exception (if any) and displays the relevant error. In the main function, a ‘for’ loop is run and new
object of the ‘my_thread’ class is created. The ‘run’ function is called on this object.
Find the closest value of an array in JavaScript

We are required to write a JavaScript function that takes in an array of numbers as the first
argument and a number as the second argument. The function should then return the number from the array which closest to the number given to the function as second argument.
The code for this will be −
const arr = [3, 56, 56, 23, 7, 76, -2, 345, 45, 76, 3];
const num = 37
const findClosest = (arr, num) => {
   const creds = arr.reduce((acc, val, ind) => {
      let { diff, index } = acc;
      const difference = Math.abs(val - num);
      if(difference < diff){
         diff = difference;
         index = ind;
      };
      return { diff, index };
   }, {
      diff: Infinity,
      index: -1
   });
   return arr[creds.index];
};
console.log(findClosest(arr, num));
The output in the console −
45
How to add a legend to a Matplotlib pie chart?

To add a legend to a Matplotlib pie chart, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Make a list of labels, colors, and sizes.
Use pie() method to get patches and texts with colors and sizes.
Place a legend on the plot with patches and labels.
Set equal scaling (i.e., make circles circular) by changing the axis limits.
To display the figure, use show() method.
import matplotlib.pyplot as plt

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

labels = ['Walk', 'Talk', 'Sleep', 'Work']
sizes = [23, 45, 12, 20]
colors = ['red', 'blue', 'green', 'yellow']

patches, texts = plt.pie(sizes, colors=colors, shadow=True, startangle=90)
plt.legend(patches, labels, loc="best")
plt.axis('equal')

plt.show()
Python | Output Type | Question 1 - GeeksforGeeks

28 Jun, 2021
What is the output of the following program :
def myfunc(a):    a = a + 2        a = a * 2    return a  print myfunc(2)
(A) 8(B) 16(C) Indentation Error(D) Runtime ErrorAnswer: (C)Explanation: Python creates blocks of code based on the indentation of the code. Thus, new indent defines a new scope.Quiz of this QuestionPlease comment below if you find anything wrong in the above post
amartyaghoshgfg
Output Type
Python-Output Type
Python-Quizzes
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python-Quizzes | Python List Quiz | Question 4
Python-Quizzes | Python Dictionary Quiz | Question 25
Python-Quizzes | Python List Quiz | Question 5
Python-Quizzes | Python Dictionary Quiz | Question 23
Python-Quizzes | Miscellaneous | Question 9
Python-Quizzes | Miscellaneous | Question 7
Python-Quizzes | Miscellaneous | Question 10
Output of Python Program - Dictionary (set 25)
Python | Miscellaneous | Question 5
Python-Quizzes | Python Tuples Quiz | Question 10
How to set Page Load Timeout using C# using Selenium WebDriver?

We can set page load timeout using Selenium webdriver in C# using the PageLoad method. It is used to set time to wait for loading of the page. An exception will be thrown if the page is not loaded within the timeout specified.
driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(10);
Here, 10 is the amount of time in seconds.
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using System;
using OpenQA.Selenium;
namespace NUnitTestProject2{
   public class Tests{
      String url = "https://www.tutorialspoint.com/index.htm";
      IWebDriver driver;
      [SetUp]
      public void Setup(){
         //creating object of FirefoxDriver
         driver = new FirefoxDriver("");
      }
      [Test]
      public void Test2(){
         //set page load time for 15 secs
         driver.Manage().Timeouts().PageLoad = TimeSpan.
         FromSeconds(15);
         //URL launch
         driver.Navigate().GoToUrl(url);
         Console.WriteLine("Page loaded successfully");
      }
      [TearDown]
      public void close_Browser(){
         driver.Quit();
      }
   }
}
Group objects inside the nested array JavaScript

Let’s say e have a parentArray that contains many sub arrays each of the same size, each sub
array is an array of objects containing two properties: key and value. Within a subarray it is
confirmed that two objects cannot have the same key but all subarrays have the same pair of n
keys where n is the size of the sub array.
Our job is to prepare an object with key as key of objects and value being an array that contains
all the values for that particular key.
Here is our sample parent array −
const parentArray = [[
   {
      key: 123,
      value: 'India'
   }, {
      key: 124,
      value: 'USA'
   }, {
      key: 125,
      value: 'Japan'
   }, {
      key: 126,
      value: 'Denmark'
   }, {
         key: 127,
      value: 'Austria'
   },
], [
   {
      key: 124,
      value: 'Kenya'
   }, {
      key: 126,
      value: 'UK'
   }, {
      key: 123,
      value: 'Germany'
   }, {
      key: 127,
      value: 'Spain'
   }, {
      key: 125,
      value: 'Portugal'
   },
]];
We will iterate over the parent array and then all of the sub arrays one by one and if we find a
matching key, we push it into the value array otherwise we create a new value array.
The full code for this will be −
const parentArray = [[
   {
      key: 123,
      value: 'India'
   }, {
      key: 124,
      value: 'USA'
   }, {
      key: 125,
      value: 'Japan'
   }, {
      key: 126,
      value: 'Denmark'
   }, {
      key: 127,
      value: 'Austria'
   },
], [
   {
      key: 124,
      value: 'Kenya'
   }, {
      key: 126,
      value: 'UK'
   }, {
      key: 123,
      value: 'Germany'
   }, {
      key: 127,
      value: 'Spain'
   }, {
      key: 125,
      value: 'Portugal'
   },
]];
const map = {};
parentArray.forEach(arr => {
   arr.forEach(obj => {
      const { key, value } = obj;
      if(map[key]){
         map[key].push(value);
      }else{
         map[key] = [value]
      }
   })
});
console.log(map);
The output in the console will be −
{
   '123': [ 'India', 'Germany' ],
   '124': [ 'USA', 'Kenya' ],
   '125': [ 'Japan', 'Portugal' ],
   '126': [ 'Denmark', 'UK' ],
   '127': [ 'Austria', 'Spain' ]
}
history command in Linux with Examples - GeeksforGeeks

21 May, 2019
history command is used to view the previously executed command. This feature was not available in the Bourne shell. Bash and Korn support this feature in which every command executed is treated as the event and is associated with an event number using which they can be recalled and changed if required. These commands are saved in a history file. In Bash shell history command shows the whole list of the command.
Syntax:
$ history 
Here, the number(termed as event number) preceded before each command depends on the system. You may get different numbers while executing on your own system.
To show the limited number of commands that executed previously as follows:$ history 5 Note: The command can be executed using event number also.Example:$ !1997 
$ history 5 
Note: The command can be executed using event number also.
Example:
$ !1997 
To print command before executing so that a wrong command does not get executed use :p after event number of command.Example:!1997:p
Example:
!1997:p
This command can also be used along with grep.Example:history | grep chpasswd 
Example:
history | grep chpasswd 
The most recent command can be viewed using !!Example:!!
Example:
!!
Suppose if the command has to be executed without being stored variable HISTFILE has to be unset.Example:
Example:
The command can also be executed using a part of the command.Example:!command_starting_string
Example:
!command_starting_string
History can also be removed using history -d event_numberExample:history -d 1996 
Example:
history -d 1996 
The whole history can be removed using history -c option.Example:history -c
Example:
history -c
linux-command
Linux-system-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
TCP Server-Client implementation in C
ZIP command in Linux with examples
tar command in Linux with examples
UDP Server-Client implementation in C
SORT command in Linux/Unix with examples
Named Pipe or FIFO with example C program
Mutex lock for Linux Thread Synchronization
'crontab' in Linux with Examples
Cat command in Linux with examples
echo command in Linux with Examples
How to show a checkbox in reactnative?

Checkboxes is a common component that we often use on the UI. We do have some cool
ways of showing checkboxes in reactnative.
The core react-native package does not have checkbox support and you need to install a
package to work with it.
Following package has to be installed to display checkbox −
npm install --save-dev react-native-paper
The basic checkbox component is as follows −
<Checkbox status={checkboxstatus} onPress={onCheckboxCheckedfunc} />
Let us now see some important properties on checkbox −
Here is a simple checkbox display −
The useState is used to set the checked , unchecked status for the checkbox as shown
below −
const [checked, setChecked] = React.useState(false);
The state is maintained inside checked variable and setChecked method is used to
update it.
The checked status will be updated when user checks/unchecks the checkbox as shown
below −
onPress={() => {
   setChecked(!checked);
}}
The complete code is as follows −
import * as React from 'react';
import { StyleSheet, Text, SafeAreaView } from 'react-native';
import { Checkbox } from 'react-native-paper';
const MyComponent = () => {
   const [checked, setChecked] = React.useState(false);
   return (
      <SafeAreaView style={styles.container}>
         <Checkbox
            status={checked ? 'checked' : 'unchecked'}
            onPress={() => {
               setChecked(!checked);
            }}
            color={'green'}
            uncheckColor={'red'}
         />
      <Text>Checkbox</Text>
      </SafeAreaView>
   );
};
const styles = StyleSheet.create({
   container: {
      flex: 1,
      justifyContent: 'center',
      alignItems: 'center'
   },
});
export default MyComponent;
Create index in a MongoDB collection?

To create index, use createIndex() in MongoDB. Let us create a collection with documents −
> db.demo702.createIndex({"details.id":1});
{
   "createdCollectionAutomatically" : true,
   "numIndexesBefore" : 1,
   "numIndexesAfter" : 2,
   "ok" : 1
}
> db.demo702.insertOne({
...    "details" : [
...       {
...          id:101,
...          studentInfo:{
...             "StudentName" : "Chris",
...             "StudentAge" : 23,
...          }
...       },
...    {
...
...       id: 102,
...       studentInfo:{
...          "StudentName" : "Robert",
...          "StudentAge" : 20,
...       }
...    }
... ]
... }
... );
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5ea6ea3b551299a9f98c93b3")
}
Display all documents from a collection with the help of find() method −
> db.demo702.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5ea6ea3b551299a9f98c93b3"),
   "details" : [
      {
         "id" : 101,
         "studentInfo" : {
            "StudentName" : "Chris",
            "StudentAge" : 23
         }
      },
      {
         "id" : 102,
         "studentInfo" : {
            "StudentName" : "Robert",
            "StudentAge" : 20
         }
      }
   ]
}
Chr() and Asc() Function in MS Access - GeeksforGeeks

21 Aug, 2020
1. CHR() Function :The Chr() function returns the character for the given ASCII number code. The Chr function takes an integer as a parameter and returns the respective character. It works opposite to ASC() function.
Syntax –
Chr(ASCII number code)
Parameter – Required; An integer.Return – A character.
Example –
SELECT Chr(75) 
AS NumberCodeToCharacter;
Output –
2. ASC() Function :The ASC() function returns the ASCII value of the character. If more than one character is passed in the function then it will return the ASCII value of the first character otherwise ASCII value of the specified character.
Syntax –
ASC(Character)
Parameter – Required; A character or a string.Return – ASCII value; An Integer value.
Example –
SELECT STUDENT, Asc(STUDENTNAME) 
AS NumCodeOfFirstChar
FROM STUDENT;
Output –
DBMS-SQL
DBMS
SQL
DBMS
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Introduction of ER Model
Introduction of B-Tree
SQL Trigger | Student Database
Introduction of DBMS (Database Management System) | Set 1
Difference between Clustered and Non-clustered index
SQL | DDL, DQL, DML, DCL and TCL Commands
How to find Nth highest salary from a table
SQL | ALTER (RENAME)
SQL Trigger | Student Database
SQL | Views
Wave effect with CSS?

Wave effect is used to give the object a sine wave distortion to make it look wavy.
The following parameters can be used in this filter:
You can try to run the following code to set wave effect:
Live Demo
<html>
   <head>
   </head>
   <body>

      <img src = "/css/images/logo.png"
         alt = "CSS Logo"
         style = "FILTER: Chroma(Color = #000000)
         Wave(Add=0, Freq=1, LightStrength=10, Phase=220, Strength=10)">

      <p>Text Example:</p>
      <div style = "width: 357;
         height: 50;
         font-size: 30pt;
         font-family: Arial Black;
         color: red;
         Filter: Wave(Add=0, Freq=1, LightStrength=10, Phase=20, Strength=20)">CSS Tutorials</div>
   </body>
</html>
Git - Clone Operation

We have a bare repository on the Git server and Tom also pushed his first version. Now, Jerry can view his changes. The Clone operation creates an instance of the remote repository.
Jerry creates a new directory in his home directory and performs the clone operation.
[jerry@CentOS ~]$ mkdir jerry_repo

[jerry@CentOS ~]$ cd jerry_repo/

[jerry@CentOS jerry_repo]$ git clone gituser@git.server.com:project.git

The above command will produce the following result.
Initialized empty Git repository in /home/jerry/jerry_repo/project/.git/
remote: Counting objects: 3, done.
Receiving objects: 100% (3/3), 241 bytes, done.
remote: Total 3 (delta 0), reused 0 (delta 0)

Jerry changes the directory to new local repository and lists its directory contents.
[jerry@CentOS jerry_repo]$ cd project/

[jerry@CentOS jerry_repo]$ ls
README


    251 Lectures 
     35.5 hours 

 Gowthami Swarna

    23 Lectures 
     2 hours 

 Asif Hussain

    15 Lectures 
     1.5 hours 

 Abhilash Nelson

    125 Lectures 
     9 hours 

 John Shea

    13 Lectures 
     2.5 hours 

 Raghu Pandey

    13 Lectures 
     3 hours 

 Sebastian Sulinski
 Print
 Add Notes
 Bookmark this page
How to set the maximum value of progress bar using HTML ? - GeeksforGeeks

22 Dec, 2020
In this article, we are creating the progress bar of a task by using a <progress> tag. The <progress> tag is used to represent the progress of a task. It is also defined how much work is done and how much is left to download a thing. It is not used to represent the disk space or relevant query.
The maximum value of progress bar can be set by using max property value.
Syntax:
<progress attributes...> </progress>
Property Values:
level: It returns the list of progress bar.
max: It is used to set or return the progress bar value of max attribute.
value: It represent the amount of work are already completed.
position: It returns the current position of progress bar.
Example:
HTML
<!DOCTYPE html><html>  <head>    <title>        How to set the maximum value        of progress bar using HTML?    </title></head>  <body style="text-align: center;">    <h1 style="color:green;">        GeeksforGeeks    </h1>      <h3>        How to set the maximum value        of progress bar using HTML?    </h3>      Downloading progress for a song:    <!-- Set maximum value of progress bar -->    <progress value="57" max="200">    </progress></body>  </html>
Output:
Supported Browsers: 
Google Chrome 8.0
Internet Explorer 10.0
Firefox 16.0
Opera 11.0
Safari 6.0
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Misc
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to create footer to stay at the bottom of a Web page?
Types of CSS (Cascading Style Sheet)
Design a web page using HTML and CSS
Create a Responsive Navbar using ReactJS
How to position a div at the bottom of its container using CSS?
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
Hide or show elements in HTML using display property
Difference between Concurrent hash map and Synchronized hashmap in Java

Concurrent Hashmap is a class that was introduced in jdk1.5.  Concurrent hash map applies locks only at bucket level called fragment while adding or updating the map. So, a concurrent hash map allows concurrent read and write operation to the map. 
Synchronized hashmap(Collection.syncronizedHashMap()) is a method of Collection framework. This method applies a lock on the entire collection. So, if one thread is accessing the map then no other thread can access the same map. 
public class SynchronizedMapExample {
   public static void main(String[] args) {
      Map<Integer,String> laptopmap = new HashMap<Integer,String>();
      laptopmap.put(1,"IBM");
      laptopmap.put(2,"Dell");
      laptopmap.put(3,"HCL");
      // create a synchronized map
      Map<Integer,String> syncmap = Collections.synchronizedMap(laptopmap);
      System.out.println("Synchronized map is : "+syncmap);
   }
}
public class ConcurrentHashMapExample {
   public static void main(String[] args) {
      //ConcurrentHashMap
      Map<Integer,String> laptopmap = new ConcurrentHashMap<Integer,String>();
      laptopmap.put(1,"IBM");
      laptopmap.put(2,"Dell");
      laptopmap.put(3,"HCL");
      System.out.println("ConcurrentHashMap is: "+laptopmap);
   }
}
MySQL how to declare a datetime variable?

To declare a datetime variable, you need to use a user-defined variable using the SET command. The syntax is as follows −
SET @anyVariableName=’yourdatetimeValue’;
To understand the above syntax, let us create a table. The query to create a table is as follows −
mysql> create table datetimeVariables
   -> (
   -> Id int NOT NULL AUTO_INCREMENT,
   -> Name varchar(10),
   -> ArrivalDatetime datetime,
   -> PRIMARY KEY(Id)
   -> );
Query OK, 0 rows affected (0.78 sec)
Insert some records in the table using insert command. The query to insert record is as follows −
mysql> insert into datetimeVariables(Name,ArrivalDatetime) values('John','2011-01-31 13:45:20');
Query OK, 1 row affected (0.53 sec)
mysql> insert into datetimeVariables(Name,ArrivalDatetime) values('Sam','2012-04-25 15:30:25');
Query OK, 1 row affected (0.18 sec)
mysql> insert into datetimeVariables(Name,ArrivalDatetime) values('Larry','2013-10-04 16:40:30');
Query OK, 1 row affected (0.10 sec)
mysql> insert into datetimeVariables(Name,ArrivalDatetime) values('Bob','2014-05-15 10:30:25');
Query OK, 1 row affected (0.33 sec)
mysql> insert into datetimeVariables(Name,ArrivalDatetime) values('Mike','2017-08-13 11:30:25');
Query OK, 1 row affected (0.08 sec)
mysql> insert into datetimeVariables(Name,ArrivalDatetime) values('David','2018-04-25 09:30:25');
Query OK, 1 row affected (0.20 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from datetimeVariables;
The following is the output −
+----+-------+---------------------+
| Id | Name  | ArrivalDatetime     |
+----+-------+---------------------+
|  1 | John  | 2011-01-31 13:45:20 |
|  2 | Sam   | 2012-04-25 15:30:25 |
|  3 | Larry | 2013-10-04 16:40:30 |
|  4 | Bob   | 2014-05-15 10:30:25 |
|  5 | Mike  | 2017-08-13 11:30:25 |
|  6 | David | 2018-04-25 09:30:25 |
+----+-------+---------------------+
6 rows in set (0.00 sec)
The following is the query to declare the datetime variable using SET command. The query is as follows −
mysql> set @greaterThan2011Datetime='2012-04-25 15:30:25';
Query OK, 0 rows affected (0.00 sec)
The following is the use of a variable in a select query. The query is as follows −
mysql> select *from datetimeVariables
   -> where ArrivalDatetime> = @greaterThan2011Datetime;
The following is the output −
+----+-------+---------------------+
| Id | Name  | ArrivalDatetime     |
+----+-------+---------------------+
|  2 | Sam   | 2012-04-25 15:30:25 |
|  3 | Larry | 2013-10-04 16:40:30 |
|  4 | Bob   | 2014-05-15 10:30:25 |
|  5 | Mike  | 2017-08-13 11:30:25 |
|  6 | David | 2018-04-25 09:30:25 |
+----+-------+---------------------+
5 rows in set (0.00 sec)
Disable a pagination link with Bootstrap

Use the .disabled class in Bootstrap with the .pagination to disable a pagination link.
You can try to run the following code to disable pagination link
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">
         <h2>Java Tutorial</h2>
         <p>The following are the lessons of Java Tutorial:</p>
         <ul class = "pagination">
            <li class = "disabled"><a href = "#">1</a></li>
            <li><a href = "#">2</a></li>
            <li><a href = "#">3</a></li>
            <li><a href = "#">4</a></li>
            <li><a href = "#">5</a></li>
            <li><a href = "#">6</a></li>
            <li><a href = "#">7</a></li>
            <li class = "disabled"><a href = "#">8</a></li>
         </ul>
      </div>
   </body>
</html>
What is the Instantaneous description of PDA?

The Instantaneous description is called as an informal notation, and explains how a Push down automata (PDA) computes the given input string and makes a decision that the given string is accepted or rejected.
The PDA involves both state and content of the stack.
The PDA involves both state and content of the stack.
Stack is often one of the important parts of PDA at any time.
Stack is often one of the important parts of PDA at any time.
So, we make a convenient notation for describing the successive configurations of PDA for string processing.
So, we make a convenient notation for describing the successive configurations of PDA for string processing.
The factors of PDA notation by triple (q, w, γ) wereq is the current state.w is the remaining input alphabet.γ is the current contents of the PDA stack.
The factors of PDA notation by triple (q, w, γ) were
q is the current state.
w is the remaining input alphabet.
γ is the current contents of the PDA stack.
Generally, the leftmost symbol indicates the top of the stack γ and the bottom at the right end. This type of triple notation is called an instantaneous description or ID of the pushdown automata.
A move from one instantaneous description to another is denoted by the symbol ‘⊢’
Therefore,
(q0, aw, z0) ⊢ (q1, w, yz0)
is possible if and only if
δ(q0, a, z0) ε (q1, yz0).

Consider an example as given below −
Show the IDs or moves for input string w = “aabb” of PDA where,
M = ({q0, q1, q2}, {a, b}, {a, b, Z0}, δ, q0, Z0, {q2}),
Where δ is defined as follows −
δ(q0, a, Z0) = {(q0, aZ0)} Rule (1)
δ(q0, a, a)  = {(q0, aa)}  Rule (2)
δ(q0, b, a)  = {(q1, λ)}   Rule (3)
δ(q1, b, a)  = {(q1, λ)}   Rule (4)
δ(q1, λ, Z0) = {(q2, λ)}   Rule (5)
δ(q0, λ, Z0) = {(q2, λ)}   Rule (6)
And we need to find out whether string w is accepted by PDA or not.
The Instantaneous Description for the string w = “aabb”. It is explained below −
(q0, aabb, Z0)
|- (q0, abb, aZ0) based on Rule (1)
|- (q0, bb, aaZ0) based on Rule (2)
|- (q1, b, aZ0    based on Rule (3)
|- (q1, λ, Z0)    based on Rule (3)
|- (q2, λ, λ)     based on Rule (5)
Therefore, PDA reaches a configuration of (q2, λ, λ) i.e. PDA stack is empty and it has reached a final state. So the string ‘w’ is accepted.
Dart - Anonymous Functions - GeeksforGeeks

15 Jul, 2020
An anonymous function in Dart is like a named function but they do not have names associated with it. An anonymous function can have zero or more parameters with optional type annotations. An anonymous function consists of self-contained blocks of code and that can be passed around in our code as a function parameter.
In Dart most of the functions are named functions we can also create nameless function knows as an anonymous function, lambda, or closure.
In Dart we can assign an anonymous function to constants or variables, later we can access or retrieve the value of closure based on our requirements:
Syntax:
(parameter_list)
{  
     statement(s)
}
Example: 
Dart
// Dartprogram to illustrate // Anonymous functions in Dartvoid main(){  var list = ["Shubham","Nick","Adil","Puthal"];  print("GeeksforGeeks - Anonymous function in Dart");  list.forEach((item) {    print('${list.indexOf(item)} : $item');  });}
 
Output:
This example defines an anonymous function with an untyped parameter, item. The function, invoked for each item in the list, prints a string that includes the value at the specified index. 
Dart-Function
Dart
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Flutter - DropDownButton Widget
Flutter - Custom Bottom Navigation Bar
Flutter - Checkbox Widget
Flutter - Row and Column Widgets
How to Append or Concatenate Strings in Dart?
Dart Tutorial
Flutter - Flexible Widget
ListView Class in Flutter
Flutter - BoxShadow Widget
Flutter - Stack Widget
DTD - Components

This chapter will discuss about XML Components from DTD perspective. A DTD will basically contain declarations of the following XML components −
Element
Element
Attributes
Attributes
Entities
Entities
XML elements can be defined as building blocks of an XML document. Elements can behave as a container to hold text, elements, attributes, media objects or mix of all.
Each XML document contains one or more elements, the boundaries of which are either delimited by start-tags and end-tags, or empty elements.
Below is a simple example of XML elements
<name>
   Tutorials Point
</name>
As you can see we have defined a <name> tag. There's a text between start and end tag of <name>. Elements, when used in an XML-DTD, need to be declared which will be discussed in detail in the chapter DTD Elements.
Attributes are part of the XML elements. An element can have any number of unique attributes. Attributes give more information about the XML element or more precisely it defines a property of the element. An XML attribute is always a name-value pair.
Below is a simple example of XML attributes −
<img src = "flower.jpg"/>
Here img is the element name whereas src is an attribute name and flower.jpg is a value given for the attribute src.

If attributes are used in an XML DTD then these need to be declared which will be discussed in detail in the chapter DTD Attributes
Entities are placeholders in XML. These can be declared in the document prolog or in a DTD. Entities can be primarily categorized as −
Built-in entities
Built-in entities
Character entities
Character entities
General entities
General entities
Parameter entities
Parameter entities
There are five built-in entities that play in well-formed XML, they are −
ampersand: &amp;
ampersand: &amp;
Single quote: &apos;
Single quote: &apos;
Greater than: &gt;
Greater than: &gt;
Less than: &lt;
Less than: &lt;
Double quote: "
Double quote: "
We will study more about entity declarations in XML DTD in detail in the chapter DTD Entities
 Print
 Add Notes
 Bookmark this page
C library function - ferror()

The C library function int ferror(FILE *stream) tests the error indicator for the given stream.
Following is the declaration for ferror() function.
int ferror(FILE *stream)
stream − This is the pointer to a FILE object that identifies the stream.
stream − This is the pointer to a FILE object that identifies the stream.
If the error indicator associated with the stream was set, the function returns a non-zero value else, it returns a zero value.
The following example shows the usage of ferror() function.
#include <stdio.h>

int main () {
   FILE *fp;
   char c;

   fp = fopen("file.txt", "w");

   c = fgetc(fp);
   if( ferror(fp) ) {
      printf("Error in reading from file : file.txt\n");
   }
   clearerr(fp);
   
   if( ferror(fp) ) {
      printf("Error in reading from file : file.txt\n");
   }
   fclose(fp);

   return(0);
}
Assuming we have a text file file.txt, which is an empty file. Let us compile and run the above program that will produce the following result because we try to read a file which we opened in write only mode.
Error reading from file "file.txt"


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
Difference between IP address and Port Number - GeeksforGeeks

24 Mar, 2022
1. IP address : An Internet Protocol address (IP address) is the logical address of our network hardware by which other devices identify it in a network. IP address stands for Internet Protocol address which is an unique number or a numerical representation that uniquely identifies a specific interface on the network. Each device that is connected to internet an IP address is assigned to it for its unique identification. 
Addresses in IPv4 are 32-bits long example,  
12.244.233.165 
And Addresses in IPv6 are 128-bits example,  
2001:0db8:0000:0000:0000:ff00:0042:7879 
2. Port Number : Port number is the part of the addressing information used to identify the senders and receivers of messages in computer networking. Different port numbers are used to determine what protocol incoming traffic should be directed to. Port number identifies a specific process to which an Internet or other network message is to be forwarded when it arrives at a server. Ports are identified for each protocol and It is considered as a communication endpoint. 
Ports are represented by 16-bit numbers. There are 2^16 port numbers i.e 65336.
They are divided into three categories
1. Well-Known Port Numbers
0 to 1023 are well-known port numbers are as they are used by well-known protocol services.
These are allocated to server services by the Internet Assigned Numbers Authority (IANA).
2. Registered Port Numbers
1024 to 49151 are registerd port numbers i.e it can be registered to specific protocols by software corporations
3. Dynamic Port Numbers
49152 to 65536 are dynamic port numbers and they can be used by anyone
Difference between IP address and Port Number :  
 
mansoorhameed07
Computer Networks
Difference Between
GATE CS
Computer Networks
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
RSA Algorithm in Cryptography
Data encryption standard (DES) | Set 1
Socket Programming in Python
Types of Network Topology
Types of Transmission Media
Difference between BFS and DFS
Class method vs Static method in Python
Difference between var, let and const keywords in JavaScript
Difference between Process and Thread
Difference Between == and .equals() Method in Java
What is .git folder and why is it hidden?

Git is currently the most popular version control system. A version control system records the changes made to our project codebase in a special kind of file system-based database. In Git, this database is known as a repository and its structure is inspired by the Linux file system. The repository maintains a history of the changes to our codebase.
The .git folder contains all information that is necessary for the project and all information relating commits, remote repository address, etc. It also contains a log that stores the commit history. This log can help you to roll back to the desired version of the code.
The following example creates an empty git repository.
$ git init
The hidden .git folder can be viewed using the following command in the git bash terminal −
$ ls −a
The output of the command is shown below −
./ ../ .git/
The contents of the .git folder can be viewed using the tree command in a Windows Operating System.
To switch from the git bash terminal to Windows terminal, type the cmd command.
$ cmd

The user is presented with the Windows terminal now. Navigate to the .git folder and use the tree command to inspect the contents of this folder.
>> cd .git //Navigate to the .git hidden folder
>> tree . // View contents of the current directory.
The output of the above commands can be seen in the following screenshot −
Following are a few important sub−directories and files in the .git folder −
hooks − This folder contains script files. Git hooks are the scripts that are executed before or after events like commit, push etc.
hooks − This folder contains script files. Git hooks are the scripts that are executed before or after events like commit, push etc.
objects − This folder represents an object database of Git.
objects − This folder represents an object database of Git.
config − This is the local configuration file.
config − This is the local configuration file.
refs − This folder stores information about tags and branches.
refs − This folder stores information about tags and branches.
HEAD − This file stores reference to the current branch. It points to the master branch by default.
HEAD − This file stores reference to the current branch. It points to the master branch by default.
index − This is a binary file and stores staging information
index − This is a binary file and stores staging information
The .git folder will contain details of every single change made to the code base. All snapshots of the modifications will be recorded in this folder like a database, which makes it possible to undo the changes and rollback to the desired version of the code.
The .git folder is hidden to prevent accidental deletion or modification of the folder. The version history of the code base will be lost if this folder is deleted. This means, we will not be able to rollback changes made to the code in future.
Plot Candlestick Chart using mplfinance module in Python - GeeksforGeeks

16 Dec, 2021
Candlestick chart are also known as a Japanese chart. These are widely used for technical analysis in trading as they visualize the price size within a period. They have four points Open, High, Low, Close (OHLC). Candlestick charts can be created in python using a matplotlib module called mplfinance. 
pip install mplfinance
This function is used to plot Candlestick charts.
Syntax: mplfinance.candlestick_ohlc(ax, quotes, width=0.2, colorup=’k’, colordown=’r’, alpha=1.0)Parameters: 
ax: An Axes instance to plot to.
quotes: sequence of (time, open, high, low, close, ...) sequences.
width: Fraction of a day for the rectangle width.
colorup: The color of the rectangle where close >= open.
colordown: The color of the rectangle where close < open.
alpha: (float) The rectangle alpha level.
Returns: returns (lines, patches) where lines are a list of lines added and patches is a list of the rectangle patches added.
To plot the chart, we will take data from NSE for the period 01-07-2020 to 15-07-2020, the data is available for download in a csv file, or can be downloaded from here. For this example, it is saved as ‘data.csv’.We will use the pandas library to extract the data for plotting from data.csv.
Below is the implementation:
Python3
# import required packagesimport matplotlib.pyplot as pltfrom mplfinance import candlestick_ohlcimport pandas as pdimport matplotlib.dates as mpdates plt.style.use('dark_background') # extracting Data for plottingdf = pd.read_csv('data.csv')df = df[['Date', 'Open', 'High',         'Low', 'Close']] # convert into datetime objectdf['Date'] = pd.to_datetime(df['Date']) # apply map functiondf['Date'] = df['Date'].map(mpdates.date2num) # creating Subplotsfig, ax = plt.subplots() # plotting the datacandlestick_ohlc(ax, df.values, width = 0.6,                 colorup = 'green', colordown = 'red',                 alpha = 0.8) # allow gridax.grid(True) # Setting labelsax.set_xlabel('Date')ax.set_ylabel('Price') # setting titleplt.title('Prices For the Period 01-07-2020 to 15-07-2020') # Formatting Datedate_format = mpdates.DateFormatter('%d-%m-%Y')ax.xaxis.set_major_formatter(date_format)fig.autofmt_xdate() fig.tight_layout() # show the plotplt.show()
Output :
Candlestick Chart
 
 
 
as5853535
Data Visualization
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Create a Pandas DataFrame from Lists
Box Plot in Python using Matplotlib
Python | Get dictionary keys as a list
Enumerate() in Python
Python Dictionary
Bar Plot in Matplotlib
Multithreading in Python | Set 2 (Synchronization)
Python Dictionary keys() method
loops in python
Python - Call function from another file
How can we concatenate two strings using jQuery?

To concatenate two strings use the + concatenation operator. You can try to run the following code to learn how to concatenate two strings using jQuery −
Live Demo
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script>
    $(function(){
      $("a").click(function(){
        var id= $(".id").html();
        $('.myclass').html("<br><div class='new' id='" + id + "'>Hello</div>");            
      });
    });
    </script>
</head>
<body>
   <div class="new">
     <a href="#">Click me</a>
     <div class="myclass"></div>
     <div class="id">Tutorialspoint</div>
   </div>
</body>
</html>
Traverse through a HashMap in Java

To traverse through a HashMap, use Iterator. The HashMap class uses a hashtable to implement the Map interface. This allows the execution time of basic operations, such as get( ) and put( ), to remain constant even for large sets.
Following is the code to traverse through a HashMap −
import java.util.*;
public class Main {
   public static void main(String args[]) {
      HashMap hashMap = new HashMap();
      hashMap.put("John", new Integer(10000));
      hashMap.put("Tim", new Integer(25000));
      hashMap.put("Adam", new Integer(15000));
      hashMap.put("Katie", new Integer(30000));
      hashMap.put("Jacob", new Integer(45000));
      hashMap.put("Steve", new Integer(23000));
      hashMap.put("Nathan", new Integer(25000));
      hashMap.put("Amy", new Integer(27000));
      Set set = hashMap.entrySet();
      Iterator iterator = set.iterator();
      while(iterator.hasNext()) {
         Map.Entry map = (Map.Entry)iterator.next();
         System.out.print(map.getKey() + ": ");
         System.out.println(map.getValue());
      }
      System.out.println();
      System.out.println("Size of IdentintyHashMap: "+hashMap.size());
      int bonus = ((Integer)hashMap.get("Amy")).intValue();
      hashMap.put("Amy", new Integer(bonus + 5000));
      System.out.println("Amy's salary after bonus = " + hashMap.get("Amy"));
      int deductions = ((Integer)hashMap.get("Steve")).intValue();
      hashMap.put("Steve", new Integer(deductions - 3000));
      System.out.println("Steve's salary after deductions = " + hashMap.get("Steve"));
   }
}
Adam: 15000
Nathan: 25000
Katie: 30000
Steve: 23000
John: 10000
Tim: 25000
Amy: 27000
Jacob: 45000
Size of IdentintyHashMap: 8
Amy's salary after bonus = 32000
Steve's salary after deductions = 20000
You can also traverse through a HashMap using the for-each loop. The keySet() and values() methods are needed here to display the keys and values respectively. Let us now see another example wherein we will be traversing through a HashMap using for-each −
import java.util.HashMap;
public class Main {
   public static void main(String[] args) {
      HashMap<String, String> students = new HashMap<String, String>();
      students.put("John", "Maths");
      students.put("Tim", "Political Science");
      students.put("Steve", "English");
      students.put("Nathan", "Science");
      for (String s : students.keySet()) {
         System.out.println("key= " + s + ", value= " + students.get(s));
      }
   }
}
key= Nathan, value= Science
key= Steve, value= English
key= John, value= Maths
key= Tim, value= Political Science
Operators Precedence in C

Operator precedence determines the grouping of terms in an expression and decides how an expression is evaluated. Certain operators have higher precedence than others; for example, the multiplication operator has a higher precedence than the addition operator.
For example, x = 7 + 3 * 2; here, x is assigned 13, not 20 because operator * has a higher precedence than +, so it first gets multiplied with 3*2 and then adds into 7.
Here, operators with the highest precedence appear at the top of the table, those with the lowest appear at the bottom. Within an expression, higher precedence operators will be evaluated first.
Try the following example to understand operator precedence in C −
#include <stdio.h>

main() {

   int a = 20;
   int b = 10;
   int c = 15;
   int d = 5;
   int e;
 
   e = (a + b) * c / d;      // ( 30 * 15 ) / 5
   printf("Value of (a + b) * c / d is : %d\n",  e );

   e = ((a + b) * c) / d;    // (30 * 15 ) / 5
   printf("Value of ((a + b) * c) / d is  : %d\n" ,  e );

   e = (a + b) * (c / d);   // (30) * (15/5)
   printf("Value of (a + b) * (c / d) is  : %d\n",  e );

   e = a + (b * c) / d;     //  20 + (150/5)
   printf("Value of a + (b * c) / d is  : %d\n" ,  e );
  
   return 0;
}
When you compile and execute the above program, it produces the following result −
Value of (a + b) * c / d is : 90
Value of ((a + b) * c) / d is  : 90
Value of (a + b) * (c / d) is  : 90
Value of a + (b * c) / d is  : 50

 Print
 Add Notes
 Bookmark this page
C# Program to split a string on spaces

Firstly, set a string −
string str = "Science and Mathematics";
Now use the Split() method to split wherever the spaces occur −
str.Split(' ')
The following is the complete code −
 Live Demo
using System;
using System.Linq;
using System.IO;
class Program {
   static void Main() {
      string str = "Science and Mathematics";
      Console.WriteLine("String...\n"+str);
      string[] myStr = str.Split(' ');
      Console.WriteLine("\nSplitted String...");
      foreach (string ch in myStr) {
         Console.WriteLine(ch);
      }
   }
}
String...
Science and Mathematics

Splitted String...
Science
and
Mathematics
How to print a byte array in Java?

You can simply iterate the byte array and print the byte using System.out.println() method.
public class Tester {
   public static void main(String[] args) {
      byte[] a = { 1,2,3};
      for(int i=0; i< a.length ; i++) {
         System.out.print(a[i] +" ");
      }
   }
}
1 2 3
CSS | hsla() Function - GeeksforGeeks

04 Dec, 2018
The hsla() function is an inbuilt function in CSS which is used to define the colors using the Hue Saturation Lightness Alpha (HSLA) model.
Syntax:
hsla( hue, saturation, lightness, alpha )
Parameters: This function accepts four parameters as mentioned above and described below:
hue: This parameter is used to define the degree on the color wheel. Its value lies between 0 to 360 where 0 or 360 represents red, 120 represents green and 240 represents blue.
saturation: This parameter is used to define the saturation where 0% represents shade of gray and 100% represents full color.
lightness: This parameter is used to define the lightness where 0% represents black, 50% represents normal, and 100% represents white.
alpha: This parameter is used to defines the opacity and the value lies between 0.0 (fully transparent) and 1.0 (fully opaque).
Below program illustrates the hsla() function in CSS:
Program:
<!DOCTYPE html><html>    <head>        <title>hsla function</title>        <style>             .gfg1 {                background-color:hsla(120, 100%, 40%, 0.3);                text-align:center;            }            .gfg2 {                background-color:hsla(120, 100%, 75%, 0.3);                text-align:center            }            .gfg3 {                background-color:hsla(120, 100%, 20%, 0.3);                text-align:center            }            .gfg {                font-size:40px;                font-weight:bold;                color:green;                text-align:center;            }            h1 {                text-align:center;            }        </style>    </head>    <body>        <div class = "gfg">GeeksforGeeks</div>        <h1>The hsla() Function</h1>        <p class = "gfg1">Green</p>        <p class = "gfg2">Light green</p>        <p class = "gfg3">Dark green</p>    </body></html>
Output:
Supported Browsers: The browser supported by hsla() function are listed below:
Chrome 1.0 and above
Internet Explorer 9.0 and above
Firefox 3.0 and above
Safari 3.1 and above
Opera 10.0 and above
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Functions
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to create footer to stay at the bottom of a Web page?
How to update Node.js and NPM to next version ?
Types of CSS (Cascading Style Sheet)
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to set the default value for an HTML <select> element ?
How to update Node.js and NPM to next version ?
How to set input type date in dd-mm-yyyy format using HTML ?