code-rag-bench/online-tutorials huggingface dataset:
Explain the Difference Between Definition and Declaration

In this post, we will understand the difference between definition and declaration.
Definition, with respect to a function indicates that the body of the function has been developed.
Definition, with respect to a function indicates that the body of the function has been developed.
With respect to variable, it means a value has been associated/defined with that variable.
With respect to variable, it means a value has been associated/defined with that variable.
A function can be defined only once.
A function can be defined only once.
Once a function or variable has been defined, it is ready to be used.
Once a function or variable has been defined, it is ready to be used.
A variable can be re-defined multiple times, as and when required. This depends on the language and the scopes.
A variable can be re-defined multiple times, as and when required. This depends on the language and the scopes.
Memory is allocated when function or a variable is defined.
Memory is allocated when function or a variable is defined.
Below is an example of variable definition
sum = 0
A variable named ‘sum’ is assigned to 0.
Below is an example of function definition
def add_val(param_1, param_2)
c = param_1 + param_2
return c
The ‘add_val’ is a method, and ‘param_1’ and ‘param_2’ are parameters passed to it. There is a definition of this method too.
Function declaration basically means that a name has been given and the parameters have been mentioned.
Function declaration basically means that a name has been given and the parameters have been mentioned.
No value is associated with a variable when it is just declared.
No value is associated with a variable when it is just declared.
Its body hasn’t been developed yet.
Its body hasn’t been developed yet.
Once a function or variable has been declared, it is not yet ready to be used.
Once a function or variable has been declared, it is not yet ready to be used.
A function or variable can be declared any number of times.
A function or variable can be declared any number of times.
Memory isn’t allocated when a function or variable is declared.
Memory isn’t allocated when a function or variable is declared.
Below is an example of variable declaration −
sum_val
A variable named ‘sum_val’ is declared.
Below is an example of function declaration −
add_val(p_1, p_2)
The ‘add_val’ is a method, and ‘p_1’ and ‘p_2’ are parameters passed to it. There is no definition of the method.
Levering cheap GPU compute: Connecting to Vast.ai using windows | by Jason Price | Towards Data Science

Venturing into the world of crypto-currency and Data-science, it was by no coincidence that I would have built my own supercomputer (by 2002 standards). The cool thing about this is that anyone can have access to cheap GPU compute, that is 3 -10 times cheaper than AWS instances. All this is made possible due to the Vast.ai platform that enables peer to peer sharing of GPU compute power.
In next these series of articles, I’ll be showing how to get started with some various tasks on the Vast.ai platform:
Connecting to Vast.ai using windows: Select and ssh into your rig of choice
Starting a Jupyter notebook
Running benchmarks
Get started: Folding@Home
Getting started: Using hashcat
Getting started: Using fast.ai
In your browser, select your image and rig of choice at https://vast.ai/console/create/
In your browser, select your image and rig of choice at https://vast.ai/console/create/
To get started, select your docker image of choice as shown below. There are several options to chose from, but for this tutorial, I have selected the fastai image from docker hub and selected Run interactive shell server, SSH
We then select the rig of choice (116) and click to rent as shown below.
2. Navigate to your instance that has just been created https://vast.ai/console/instances/. Please note your instance could take from 30 sec to 15 min to load depending on the host connection speed if the image is already on the host rig and the size of the image. Pro tip: ask the host lo pre-load the image for you so you can get started in less than a minute every time.
3. Go to instances and click connect which will show the ip address and port (it is also shown at the top of the instance).
ssh -p 515836  root@ssh5.vast.ai -L 8080:localhost:8080
You will need the port 515836 and the ip address root@ssh5.vast.ai later (note the port and ip address may be different).
4. Download and install PuTTYgen for windows
5. Using PuTTYgen choose RSA , and then press the generate button to generate the public and private key.
6. Add a passphrase for extra security, save the public and private key and copy the public key to your clipboard.
7. Go to https://vast.ai/console/account/ and input the public key generated in step 6.
8. Open PuTTY and input the IP address and port number from step 3.
9. Go to Connection →SSH → Auth and select your private key
10. Navigate back to Session and save your configuration so you can load it easily later on.
11. Click open, accept any popups and log in with the password you used when generating your public key.
12. Go wild !!!!!!!!
If you still having issues, feel free to reach out in the comments below or even better, join the Vast.ai Discord community. More info on Vastai’s peer to peer system can be found in the FAQ.
Note I am not a developer on Vast.ai, but I do have rig (116), that is hosted on the platform, so feel free to show some love 😺.
How to replace space between two words with underscore in an R data frame column?

To replace space between two words with underscore in an R data frame column, we can use gsub function. For example, if we have a data frame called df that contains character column x having two words having a single space between them then we can replace that space using the command dfx<−gsub("","",dfx)
Consider the below data frame −
 Live Demo
x1<-sample(c("id 1","id 2","id 3","id 4"),20,replace=TRUE)
x2<-rpois(20,5)
df1<-data.frame(x1,x2)
df1
    x1   x2
1 id 4   6
2 id 4   5
3 id 1   6
4 id 3   8
5 id 4  12
6 id 4   8
7 id 3   2
8 id 3   5
9 id 4   8
10 id 1  1
11 id 3  4
12 id 3  5
13 id 2  3
14 id 1  2
15 id 3  5
16 id 1  8
17 id 4  8
18 id 3  5
19 id 2  2
20 id 3  4
Replacing space between id and the number in column x1 with underscore −
df1$x1<-gsub(" ", "_", df1$x1)
df1
    x1   x2
1 id_4   6
2 id_4   5
3 id_1   6
4 id_3   8
5 id_4  12
6 id_4   8
7 id_3   2
8 id_3   5
9 id_4   8
10 id_1  1
11 id_3  4
12 id_3  5
13 id_2  3
14 id_1  2
15 id_3  5
16 id_1  8
17 id_4  8
18 id_3  5
19 id_2  2
20 id_3  4
 Live Demo
y1<-sample(c("class 1","class 2","class 3"),20,replace=TRUE)
y2<-rnorm(20)
df2<-data.frame(y1,y2)
df2
     y1         y2
1  class 1   0.62986928
2  class 2   1.65731515
3  class 3  -1.13406383
4  class 1  -0.35842133
5  class 1   0.58141698
6  class 3  -0.18424254
7  class 3  -1.05955455
8  class 2  -0.80841041
9  class 3   1.05838028
10 class 2  -1.06141883
11 class 3  -0.54195571
12 class 3  -0.18038280
13 class 2   0.75236011
14 class 2  -0.55374067
15 class 1   0.38737080
16 class 3   0.35892853
17 class 2  -0.44576804
18 class 1   0.62543133
19 class 2  -0.05862987
20 class 1  -0.01508226
Replacing space between id and the number in column y1 with underscore −
df2$y1<-gsub(" ", "_",df2$y1)
df2
      y1        y2
1  class_1   0.62986928
2  class_2   1.65731515
3  class_3  -1.13406383
4  class_1  -0.35842133
5  class_1   0.58141698
6  class_3  -0.18424254
7  class_3  -1.05955455
8  class_2  -0.80841041
9  class_3   1.05838028
10 class_2  -1.06141883
11 class_3  -0.54195571
12 class_3  -0.18038280
13 class_2   0.75236011
14 class_2  -0.55374067
15 class_1   0.38737080
16 class_3   0.35892853
17 class_2  -0.44576804
18 class_1   0.62543133
19 class_2  -0.05862987
20 class_1  -0.01508226
Python Program for Recursive Insertion Sort - GeeksforGeeks

31 Aug, 2021
Insertion sort is a simple sorting algorithm that works the way we sort playing cards in our hands. Below is an iterative algorithm for insertion sortAlgorithm 
// Sort an arr[] of size n
insertionSort(arr, n) 
    Loop from i = 1 to n-1.
       a) Pick element arr[i] and insert
          it into sorted sequence arr[0..i-1] 
Python
Python
# Recursive Python program for insertion sort # Recursive function to sort an array using insertion sortdef insertionSortRecursive(arr, n):    # base case    if n <= 1:        return     # Sort first n-1 elements    insertionSortRecursive(arr, n - 1)     # Insert last element at its correct position in sorted array.    last = arr[n - 1]    j = n - 2     # Move elements of arr[0..i-1], that are    # greater than key, to one position ahead    # of their current position    while (j >= 0 and arr[j] > last):        arr[j + 1] = arr[j]        j = j - 1    arr[j + 1] = last  # Driver program to test insertion sortif __name__ == '__main__':    A = [-7, 11, 6, 0, -3, 5, 10, 2]    n = len(A)    insertionSortRecursive(A, n)    print(A) # Contributed by Harsh Valecha,# Edited by Abraar Masud Nafiz.
Please refer complete article on Recursive Insertion Sort for more details!
3gcp5bon7ageb76qt65bn0b5f8p0uyj7ciyogztl
Insertion Sort
python sorting-exercises
Python Programs
Sorting
Sorting
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Appending to list in Python dictionary
Python program to interchange first and last elements in a list
How to inverse a matrix using NumPy
Take Matrix input from user in Python
Differences and Applications of List, Tuple, Set and Dictionary in Python
Perl ord Function

This function returns the ASCII numeric value of the character specified by EXPR, or $_ if omitted. For example, ord('A') returns a value of 65.
Following is the simple syntax for this function −
ord EXPR

ord

This function returns Integer.
Following is the example code showing its basic usage −
#!/usr/bin/perl -w

print("ord() ", ord('G'), "\n");
When above code is executed, it produces the following result −
ord() 71


    46 Lectures 
     4.5 hours 

 Devi Killada

    11 Lectures 
     1.5 hours 

 Harshit Srivastava

    30 Lectures 
     6 hours 

 TELCOMA Global

    24 Lectures 
     2 hours 

 Mohammad Nauman

    68 Lectures 
     7 hours 

 Stone River ELearning

    58 Lectures 
     6.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
XQuery - Custom Functions

XQuery provides the capability to write custom functions. Listed below are the guidelines to create a custom function.
Use the keyword declare function to define a function.
Use the keyword declare function to define a function.
Use the data types defined in the current XML Schema
Use the data types defined in the current XML Schema
Enclose the body of function inside curly braces.
Enclose the body of function inside curly braces.
Prefix the name of the function with an XML namespace.
Prefix the name of the function with an XML namespace.
The following syntax is used while creating a custom function.
declare function prefix:function_name($parameter as datatype?...)
as returnDatatype?
{
   function body...
};
The following example shows how to create a user-defined function in XQuery.
declare function local:discount($price as xs:decimal?,$percentDiscount as xs:decimal?)
as xs:decimal? {
   let $discount := $price - ($price * $percentDiscount div 100) 
   return $discount
};

let $originalPrice := 100

let $discountAvailed := 10

return ( local:discount($originalPrice, $discountAvailed)) 
90

To verify the result, replace the contents of books.xqy (given in the Environment Setup chapter) with the above XQuery expression and execute the XQueryTester java program.
 Print
 Add Notes
 Bookmark this page
C++ Program for cube sum of first n natural numbers - GeeksforGeeks

17 Mar, 2022
Print the sum of series 13 + 23 + 33 + 43 + .......+ n3 till n-th term.Examples:  
Input : n = 5
Output : 225
13 + 23 + 33 + 43 + 53 = 225

Input : n = 7
Output : 784
13 + 23 + 33 + 43 + 53 + 
63 + 73 = 784
CPP
CPP
// Simple C++ program to find sum of series// with cubes of first n natural numbers#include <iostream>using namespace std; /* Returns the sum of series */int sumOfSeries(int n){   int sum = 0;   for (int x=1; x<=n; x++)      sum += x*x*x;   return sum;} // Driver Functionint main(){    int n = 5;    cout << sumOfSeries(n);    return 0;}
Output : 
225
Time Complexity : O(n) An efficient solution is to use direct mathematical formula which is (n ( n + 1 ) / 2) ^ 2  
For n = 5 sum by formula is
       (5*(5 + 1 ) / 2)) ^ 2
          = (5*6/2) ^ 2
          = (15) ^ 2
          = 225

For n = 7, sum by formula is
       (7*(7 + 1 ) / 2)) ^ 2
          = (7*8/2) ^ 2
          = (28) ^ 2
          = 784
Output:  
225
Time Complexity : O(1) How does this formula work? We can prove the formula using mathematical induction. We can easily see that the formula holds true for n = 1 and n = 2. Let this be true for n = k-1.  
Let the formula be true for n = k-1.
Sum of first (k-1) natural numbers = 
            [((k - 1) * k)/2]2

Sum of first k natural numbers = 
          = Sum of (k-1) numbers + k3
          = [((k - 1) * k)/2]2 + k3
          = [k2(k2 - 2k + 1) + 4k3]/4
          = [k4 + 2k3 + k2]/4
          = k2(k2 + 2k + 1)/4
          = [k*(k+1)/2]2
The above program causes overflow, even if result is not beyond integer limit. Like previous post, we can avoid overflow upto some extent by doing division first. 
CPP
CPP
// Efficient CPP program to find sum of cubes// of first n natural numbers that avoids// overflow if result is going to be within// limits.#include<iostream>using namespace std;  // Returns sum of first n natural// numbersint sumOfSeries(int n){    int x;    if (n % 2 == 0)        x = (n/2) * (n+1);    else        x = ((n + 1) / 2) * n;    return x * x;}  // Driver codeint main(){  int n = 5;  cout << sumOfSeries(n);  return 0;}
Output: 
225
Please refer complete article on Program for cube sum of first n natural numbers for more details! 
surinderdawra388
maths-cube
C++ Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
cin in C++
Shallow Copy and Deep Copy in C++
Check if given number is perfect square
C++ Program to check if a given String is Palindrome or not
Passing a function as a parameter in C++
Program to implement Singly Linked List in C++ using class
C Program to Swap two Numbers
CSV file management using C++
cout in C++
Pi(π) in C++ with Examples
Bootstrap Progress Bars

A progress bar can be used to show a user how far along he/she is in a 
process.
Bootstrap provides several types of progress bars.
A default progress bar in Bootstrap looks like this:
To create a default progress bar, add a .progress class to a <div> element:
Note: Progress bars are not supported in Internet Explorer 9 and 
earlier (because they use CSS3 transitions and animations to achieve some of 
their effects).Note: To help improve accessibility for 
people using screen readers, you should include the aria-* attributes.
A progress bar with a label looks like this:
Remove the .sr-only class from the progress bar to show a visible percentage:
Contextual classes are used to provide "meaning through colors".
The contextual classes that can be used with progress bars are:
.progress-bar-success
.progress-bar-info
.progress-bar-warning
.progress-bar-danger
The following example shows how to create progress bars with the different 
contextual classes:
Progress bars can also be striped:
Add class .progress-bar-striped to add stripes to the progress bars:
Add class .active to animate the progress bar:
Progress bars can also be stacked:
Create a stacked progress bar by placing multiple bars into the same <div class="progress">:
Add the correct classes to make this HTML code behave as a progress bar.
<div class="">
  <div class=""
    role="progressbar"
    style="width:70%">
  </div>
</div>

Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
How to append to array in MongoDB?

To append to array in MongoDB, use $concatArrays. Let us create a collection with documents −
> db.demo435.insertOne({"FirstName":["Chris"],"LastName":["Brown"]} );
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e7719b1bbc41e36cc3cae97")
}
> db.demo435.insertOne({"FirstName":["David"],"LastName":["Miller"]} );
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e7719bdbbc41e36cc3cae98")
}
> db.demo435.insertOne({"FirstName":["John"],"LastName":["Doe"]} );
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e7719c6bbc41e36cc3cae99")
}
Display all documents from a collection with the help of find() method −
> db.demo435.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5e7719b1bbc41e36cc3cae97"),
   "FirstName" : [
      "Chris"
      ],
      "LastName" : [
         "Brown"
      ]
   }
   {
      "_id" : ObjectId("5e7719bdbbc41e36cc3cae98"),
      "FirstName" : [
         "David"
      ],
      "LastName" : [
         "Miller"
      ]
   }
   {
      "_id" : ObjectId("5e7719c6bbc41e36cc3cae99"),
      "FirstName" : [
         "John"
      ],
      "LastName" : [
         "Doe"
   ]
}
Following is the query to append to array in MongoDB −
> db.demo435.aggregate([ { $project: { FullName: { $concatArrays: [ "$FirstName", "$LastName" ] } } } ])
This will produce the following output −
{ "_id" : ObjectId("5e7719b1bbc41e36cc3cae97"), "FullName" : [ "Chris", "Brown" ] }
{ "_id" : ObjectId("5e7719bdbbc41e36cc3cae98"), "FullName" : [ "David", "Miller" ] }
{ "_id" : ObjectId("5e7719c6bbc41e36cc3cae99"), "FullName" : [ "John", "Doe" ] }
What is React Native?

React Native is an open source JavaScript Mobile framework from Facebook specially designed to build native mobile apps for iOS and Android. React Native is based on ReactJS JavaScript library that helps to build the user interface for mobile platforms.
React Native can be directly used inside an existing IOS or android app or you can build a native app right from scratch. At present React Native is used with some popular apps like Facebook mobile app, Instagram, Pinterest, Skype, etc.
Some important features of React Native that makes it a very popular mobile development app today are −
Cross Platform Support − To develop mobile apps you don’t need a team expert in IOS and Android programming instead JavaScript developers who are enthusiastic to build apps can use React Native to build native apps without having to learn Kotlin or Java for Android and Swift or Objective-C for IOS apps. You can write one common code and React Native will take care of displaying it in IOS and Android.
React Native Components − React Native offers native components like View, Text, and Image that are changed to the IOS or Android native UI.
Here is a simple example using react native that displays the text Hello World:
import React from 'react';
import { Text, View} from 'react-native';

const App = () => {
   return (
      <View style={{flex :1, justifyContent: 'center', margin: 15}}>
      <Text style={{color:'red', fontSize:30}}>Hello World</Text>
      </View>
   );
}

export default App;
JSX − As ReactJS is for the web world, React Native is meant for the mobile app world. React Native makes use of JSX i.e., an XML for writing code that replaces HTML and CSS. The advantage of JSX is as follows −
It is faster because it performs optimization while compiling code to JavaScript.
It is faster because it performs optimization while compiling code to JavaScript.
It is also type-safe and most of the errors can be caught during compilation.
It is also type-safe and most of the errors can be caught during compilation.
It makes it easier and faster to write templates, if you are familiar with HTML.
It makes it easier and faster to write templates, if you are familiar with HTML.
React Native App Build and Testing − It is very easy to build your app in react native and also to test the changes without any compilation headache. The changes are available soon for display the moment you save your code.
About React Native Release − The first version of React Native was released by Facebook in the year 2015 and from there onwards they are updating and maintaining it. It has gained a lot of popularity post the release as it is one of the top most frameworks used for mobile apps development. As per React Native official website, in 2018 React Native has been the 2nd highest number of contributors for any repository in GitHub. Today, React Native is supported by contributions from individuals and companies around the world including Callstack, Expo, Infinite Red, Microsoft and Software Mansion. The Facebook community has been very active and updates the projects regularly with new updates across platforms.
MongoDB query to get only distinct values

To get distinct values, use distinct() in MongoDB. It finds the distinct values for a specified field across a single collection or view and returns the results in an array.
Let us create a collection with documents −
> db.demo287.insertOne({"details":{"AllVowels":["a","u","u","o","e","a","o","i"]}});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e4c014cf49383b52759cbbd")
}
Display all documents from a collection with the help of find() method −
> db.demo287.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5e4c014cf49383b52759cbbd"),
   "details" : {
      "AllVowels" : [ "a", "u", "u", "o", "e", "a", "o", "i" ]
   }
}
Following is the query to get distinct values −
> db.demo287.distinct("details.AllVowels");
This will produce the following output −
[ "a", "e", "i", "o", "u" ]
HTML | onerror Event Attribute - GeeksforGeeks

30 Jul, 2021
This attribute works when an error occurs while loading an external file. The external file may contain document file or image file.Supported Tags
<input type=”image”>
, <object>
, <link>
, <script>
Syntax:  
<element onerror = "script">
Attribute Value: This attribute contains single value script which works when onerror event attribute call. This attribute is supported by <img>, <input type=”image”>, <object>, <link>, and <script> tags.Example:  
html
<!DOCTYPE html><html>    <head>        <title>onerror event attribute</title>        <style>            body {                text-align:center;            }            h1 {                color:green;            }        </style>    </head>    <body>        <img src="image.gif" onerror="myFunction()">        <h1>GeeksforGeeks</h1>        <h2>onerror event attribute</h2>        <script>        function myFunction() {            alert("The image could not be loaded.");        }        </script>    </body></html>                   
Output:  
Supported Browsers: The browser supported by onerror attribute are listed below:  
Chrome
Internet Explorer
Firefox
Safari
Opera
 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
hritikbhatnagar2182
HTML-Attributes
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to create footer to stay at the bottom of a Web page?
How to update Node.js and NPM to next version ?
CSS to put icon inside an input element in a form
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to set the default value for an HTML <select> element ?
How to update Node.js and NPM to next version ?
How to set input type date in dd-mm-yyyy format using HTML ?
How to select records that begin with a specific value in MySQL?

To select records that begin with a specific value, you need to use LIKE operator. Let us first create a table −
mysql> create table DemoTable690(
   UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   UserValue varchar(100)
);
Query OK, 0 rows affected (0.56 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable690(UserValue) values('567890');
Query OK, 1 row affected (0.21 sec)
mysql> insert into DemoTable690(UserValue) values('789032');
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable690(UserValue) values('567342');
Query OK, 1 row affected (0.20 sec)
mysql> insert into DemoTable690(UserValue) values('890678');
Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable690;
This will produce the following output −
+--------+-----------+
| UserId | UserValue |
+--------+-----------+
|      1 | 567890    |
|      2 | 789032    |
|      3 | 567342    |
|      4 | 890678    |
+--------+-----------+
4 rows in set (0.00 sec)
Following is the query to select records that begin with a specific value −
mysql> select *from DemoTable690 where UserValue LIKE '567%';
This will produce the following output −
+--------+-----------+
| UserId | UserValue |
+--------+-----------+
|      1 | 567890    |
|      3 | 567342    |
+--------+-----------+
2 rows in set (0.00 sec)
Materialize - Buttons

Materialize provides different CSS classes to apply various predefined visual and behavioral enhancements to the buttons. Following table mentions the available classes and their effects.
btn
Sets button or anchor as a Materialize button, required. Sets raised display effect to a button.
btn-floating
Creates a circular button.
btn-flat
Sets flat display effect to a button, default.
btn-large
Creates large buttons.
disabled
Creates a disabled button.
type="submit"
Represents an anchor or button as a primary button.
waves-effect
Sets ripple click effect, can be used in combination with any other classes.
The following example demonstrates the use of mdl-button classes to show different types of buttons.
<!DOCTYPE html>
<html>
   <head>
      <title>The Materialize Buttons 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="card-panel">
         <h5>Raised Buttons</h5>
         <button class="btn waves-effect waves-teal">Add</button></td>
         <button class="btn waves-effect waves-teal"><i class="material-icons left">add</i>Add</button></td>
         <button class="btn waves-effect waves-teal"><i class="material-icons right">add</i>Add</button></td>
         <button class="btn waves-effect waves-teal disabled">Add</button></td>
      </div>
      <div class="card-panel">
         <h5>Flat Buttons</h5>
         <button class="btn-flat waves-effect waves-teal">Add</button></td>
         <button class="btn-flat waves-effect waves-teal disabled" ><i class="material-icons left">add</i>Add</button></td>
      </div>
      <div class="card-panel">
         <h5>Floating Buttons</h5>
         <a class="btn-floating waves-effect waves-light red"><i class="material-icons">add</i></a>
         <a class="btn-floating waves-effect waves-light red disabled" ><i class="material-icons">add</i></a>
      </div>
      <div class="card-panel">
         <h5>Primary Buttons</h5>
         <button class="btn waves-effect waves-light red" type="submit">Send<i class="material-icons right">send</i></button>
         <button class="btn waves-effect waves-light red disabled" type="submit" >Cancel<i class="material-icons right">cancel</i></button>
      </div>
      <div class="card-panel">
         <h5>Large Buttons</h5>
         <a class="btn-floating btn-large waves-effect waves-light red"><i class="material-icons">add</i></a>
         <a class="btn-floating btn-large waves-effect waves-light red disabled"><i class="material-icons">add</i></a>
      </div>
   </body>
</html>
Verify the output.
 Print
 Add Notes
 Bookmark this page
How to add 30 minutes to datetime in MySQL?

To add minutes to a datetime you can use DATE_ADD() function from MySQL. In PHP, you can use strtotime().
To add 30 minutes in MySQL, the DATE_ADD() function is as follows −
select date_add(yourColumnName,interval 30 minute) from yourTableName;
To use the above syntax, let us create a table. The following is the query to create a table.
mysql> create table Add30MinutesDemo
   −> (
   −> YourTime datetime
   −> );
Query OK, 0 rows affected (0.67 sec)
Insert records in the table with the help of following query −
mysql> insert into Add30MinutesDemo values(now());
Query OK, 1 row affected (0.21 sec)
Display records from table with the help of select statement. The query is as follows −
mysql> select *from Add30MinutesDemo;
The following is the output −
+---------------------+
| YourTime            |
+---------------------+
| 2018-12-07 18:03:51 |
+---------------------+
1 row in set (0.00 sec)
Here is the MySQL query to add 30 minutes to a column. The query is as follows −
mysql> select date_add(YourTime,interval 30 minute) from Add30MinutesDemo;
The following is the output −
+---------------------------------------+
| date_add(YourTime,interval 30 minute) |
+---------------------------------------+
| 2018-12-07 18:33:51                   |
+---------------------------------------+
1 row in set (0.00 sec)
How to find the average of non-zero values in a Python dictionary?

You can do this by iterating over the dictionary and filtering out zero values first. Then take the sum of the filtered values. Finally, divide by the number of these filtered values. 
my_dict = {"foo": 100, "bar": 0, "baz": 200}
filtered_vals = [v for _, v in my_dict.items() if v != 0]
average = sum(filtered_vals) / len(filtered_vals)
print(average)
This will give the output −
150.0
You can also use reduce but for a simple task such as this, it is an overkill. And it is also much less readable than using a list comprehension.
SimpleDateFormat(“HH:mm:ss Z”) in Java

The Z means "zero hour offset", also known as "Zulu time" (UTC) in the ISO 8601 time representation. However, ACP 121 standard defines the list of military time zones and derives the "Zulu time" from theGreenwich Mean Time (GMT).
Let us see the usage of SimpleDateFormat(“HH:mm:ss Z”) −
Format f = new SimpleDateFormat("HH.mm.ss Z");
String strResult = f.format(new Date());
System.out.println("Time = "+strResult);
The following is the complete example that displays time with offset (HH:mm:ss Z) −
 Live Demo
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Calendar;
public class Demo {
   public static void main(String[] args) throws Exception {
      // displaying current date and time
      Calendar cal = Calendar.getInstance();
      SimpleDateFormat simpleformat = new SimpleDateFormat("dd/MMMM/yyyy hh:mm:s");
      System.out.println("Today's date = "+simpleformat.format(cal.getTime()));
      // current time
      Format f = new SimpleDateFormat("HH.mm.ss Z");
      String strResult = f.format(new Date());
      System.out.println("Time = "+strResult);
      // displaying hour
      f = new SimpleDateFormat("H");
      String strHour = f.format(new Date());
      System.out.println("Current Hour = "+strHour);
      // displaying minutes
      f = new SimpleDateFormat("mm");
      String strMinute = f.format(new Date());
      System.out.println("Current Minutes = "+strMinute);
      // displaying seconds
      f = new SimpleDateFormat("ss");
      String strSeconds = f.format(new Date());
      System.out.println("Current Seconds = "+strSeconds);
   }
}
Today's date = 26/November/2018 08:52:33
Time = 08.52.33 +0000
Current Hour = 8
Current Minutes = 52
Current Seconds = 33
ReactJS – Axios Interceptors

In this article, we are going to learn how to intercept every request or response that is being sent by Axios Interceptors in a React application.
Axios interceptors are the default configurations that are added automatically to every request or response that a user receives. It is useful to check response status code for every response that is being received.
In this example, we will build a React application that automatically checks and logs the status code that is sent by the server while sending a POST request from our React application.
We have to set all the configuration in the most global file, i.e. index.js, to intercept every request/response.
import React from 'react';
import App from './App';
import ReactDOM from 'react-dom';
import axios from 'axios';

// For GET requests
axios.interceptors.request.use(
   (req) => {
      // Add configurations here
      return req;
   },
   (err) => {
      return Promise.reject(err);
   }
);

// For POST requests
axios.interceptors.response.use(
   (res) => {
      // Add configurations here
      if (res.status === 201) {
         console.log('Posted Successfully');
      }
      return res;
   },
   (err) => {
      return Promise.reject(err);
   }
);

ReactDOM.render(
   <React.StrictMode>
      <App />
   </React.StrictMode>,
   document.getElementById('root')
);
import React, { useEffect, useState } from 'react';
import './App.css';
const App = () => {
   const [data, setData] = useState(null);
   const [val, setVal] = useState('');
   const [fetchData, setFetch] = useState(false);

   useEffect(() => {

      if (fetchData) {
         const payload = {
            method: 'POST',
            body: JSON.stringify({ title: val }),
         };
         axios.post('https://jsonplaceholder.typicode.com/posts', payload)
.then((res) => setData(res.data.id));
      }
   }, [fetchData]);
   return (
      <>
      {data && <h1>Your data is saved with Id: {data}</h1>}
      <input
         placeholder="Title of Post"
         value={val}
         onChange={(e) => setVal(e.target.value)}
      />
      <button onClick={() => setFetch(true)}>Save Data</button>
   );
};
export default App;
In the above example, when the request is sent with the data, the response is intercepted and if the status code is 201, then it will log the message 'Posted Successfully'.
This will produce the following result.
Python Program to Find the Sum of Digits in a Number without Recursion

When it is required to find the sum of digits in a number without using the method of recursion, the ‘%’ operator, the ‘+’ operator and the ‘//’ operator can be used.
Below is a demonstration for the same −
 Live Demo
def sum_of_digits(my_num):
   sum_val = 0
   while (my_num != 0):
      sum_val = sum_val + (my_num % 10)
      my_num = my_num//10
   return sum_val
my_num = 12345671
print("The number is : ")
print(my_num)
print("The method to calculate sum of digits is being called...")
print("The sum of " +str(my_num) + " is : ")
print(sum_of_digits(my_num))
The number is :
12345671
The method to calculate sum of digits is being called...
The sum of 12345671 is :
29
A method named ‘sum_of_digits’ is defined, that takes a number as parameter.
A sum is initially assigned to 0.
The number is divided by 10 and the remainder obtained is added to the sum.
The number is again floor divided by 10 and assigned to the number itself.
The sum value is returned as output from the function.
A number is defined, and is displayed on the console.
The method is called by passing this number as a parameter.
The output id displayed on the console.
How to create a line break with JavaScript?

To create a line break in JavaScript, use “<br>”. With this, we can add more than one line break also.
Let’s see it in the below example:
<html>
   <body>
      <script>
         <!--
            document.write("Hello World!");
            document.write("<br>");
            document.write("Demo<br><br>Text!");
          //-->
      </script>
   </body>
</html>
How can I insert a string in an Entry widget that is in the "readonly" state using Tkinter?

Tkinter Entry widget is used to insert single-line text input. We can use the Entry widget to create forms where single-line input is the prime requirement.
Sometimes, we need to insert a predefined text inside the Entry Widget. In such cases, we can use insert(INSERT,<Your Text>) method. These are generally called as Placeholders for the Entry widget.
Let us suppose that we want to change the state of our text as read-only. Here, we can use state= ‘readonly’ property while configuring the Entry widget.
#Import the required Libraries
from tkinter import *
from tkinter import ttk
#Create an instance of tkinter frame
win = Tk()
#Set the geometry of tkinter frame
win.geometry("750x270")
#Create an Entry Widget
entry= ttk.Entry(win, width= 40)
entry.insert(0, 'www.tutorialspoint.com')
#Set the state of Entry widget ReadOnly
entry.configure(state= "readonly")
entry.pack(ipadx= 20,ipady=10)
win.mainloop()
Running the above code will display a window that will have an Entry widget containing a single text which cannot be modified.
How to convert a NumPy ndarray to a PyTorch Tensor and vice versa?

A PyTorch tensor is like numpy.ndarray. The difference between these two is that a tensor utilizes the GPUs to accelerate numeric computation. We convert a numpy.ndarray to a PyTorch tensor using the function torch.from_numpy(). And a tensor is converted to numpy.ndarray using the .numpy() method.
Import the required libraries. Here, the required libraries are torch and numpy.
Import the required libraries. Here, the required libraries are torch and numpy.
Create a numpy.ndarray or a PyTorch tensor.
Create a numpy.ndarray or a PyTorch tensor.
Convert the numpy.ndarray to a PyTorch tensor using torch.from_numpy() function or convert the PyTorch tensor to numpy.ndarray using the .numpy() method.
Convert the numpy.ndarray to a PyTorch tensor using torch.from_numpy() function or convert the PyTorch tensor to numpy.ndarray using the .numpy() method.
Finally, print the converted tensor or numpy.ndarray.
Finally, print the converted tensor or numpy.ndarray.
The following Python program converts a numpy.ndarray to a PyTorch tensor.
# import the libraries
import torch
import numpy as np

# Create a numpy.ndarray "a"
a = np.array([[1,2,3],[2,1,3],[2,3,5],[5,6,4]])
print("a:\n", a)

print("Type of a :\n", type(a))
# Convert the numpy.ndarray to tensor
t = torch.from_numpy(a)
print("t:\n", t)
print("Type after conversion:\n", type(t))
When you run the above code, it will produce the following output
a:
[[1 2 3]
[2 1 3]
[2 3 5]
[5 6 4]]
Type of a :
<class 'numpy.ndarray'>
t:
tensor([[1, 2, 3],
         [2, 1, 3],
         [2, 3, 5],
         [5, 6, 4]], dtype=torch.int32)
Type after conversion:
<class 'torch.Tensor'>
The following Python program converts a PyTorch tensor to a numpy.ndarray.
# import the libraries
import torch
import numpy

# Create a tensor "t"
t = torch.Tensor([[1,2,3],[2,1,3],[2,3,5],[5,6,4]])
print("t:\n", t)
print("Type of t :\n", type(t))

# Convert the tensor to numpy.ndarray
a = t.numpy()
print("a:\n", a)
print("Type after conversion:\n", type(a))
When you run the above code, it will produce the following output
t:
tensor([[1., 2., 3.],
         [2., 1., 3.],
         [2., 3., 5.],
         [5., 6., 4.]])
Type of t :
<class 'torch.Tensor'>
a:
[[1. 2. 3.]
[2. 1. 3.]
[2. 3. 5.]
[5. 6. 4.]]
Type after conversion:
<class 'numpy.ndarray'>
Designing a Working Table Fan using HTML and CSS - GeeksforGeeks

21 Sep, 2021
In this article, we will design a Working Table-fan using HTML and CSS.
List of HTML tags used:
Polyline: The <polyline> element is used to create the HTML <svg> element which is a container for SVG graphics any shape that consists of only straight lines
div: The <div> tag defines a division or a section in an HTML document.
svg: The HTML <svg> element is a container for SVG graphics
circle: The HTML <circle> element is used to create circle
style: The HTML <style> element is used to provide internal CSS.
Example:
HTML
<!DOCTYPE html><html>  <head>    <style>        .blade_container {            width: 180px;            height: 180px;            margin: auto;            margin-top: 50px;            animation: blade 1s linear infinite;        }          @keyframes blade {            0% {                transform: rotate(360deg);            }        }          .rode {            width: 15px;            height: 150px;            background-color: black;            margin: auto;            margin-top: 0px;        }          .main_container {            background-color: #308D46;            border-radius: 50%;            height: 180px;            width: 180px;            margin: auto;        }    </style></head>  <body>    <center>        <h3 style="color:green">Its Geek Time</h3>                <div class="main_container">            <div class="blade_container">                <svg width="100%" height="100%">                    <polyline style="stroke-linejoin:miter;                     stroke:white; stroke-width:12;                     fill:white;" points=                    "90 90, 0 90, 90 90,                    90 0,90 90,180 90,                    90 90,90 180,90 90,                    27 27,90 90,                    153 27,90 90,                    27 153,                    90 90,                    153 153" />                </svg>            </div>        </div>                  <img src="https://media.geeksforgeeks.org/wp-content/uploads/20210921173505/bg.png"            style="z-index:-1;">    </center></body>  </html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
Blogathon-2021
CSS-Properties
CSS-Questions
HTML-Questions
HTML-Tags
Blogathon
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Re-rendering Components in ReactJS
Python NOT EQUAL operator
How to build a basic CRUD app with Node.js and ReactJS ?
Banking Transaction System using Java
How to Connect Python with SQL Database?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
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)
Java program to find whether the given string is empty or null

The isEmpty() method of the String class returns true if the length of the current string is 0.
import java.util.Scanner;
public class StringEmptyOrNull {
   public static void main(String[] args) {
      System.out.println("Enter a string value ::");
      Scanner sc = new Scanner(System.in);
      String str = sc.nextLine();

      if(str.isEmpty()&& str==null ){
         System.out.println("Given string is empty or null");
      }else{
         System.out.println("Given string is not empty or null");
      }
   }
}

Enter a string value ::
Hi welcome to tutorialspoint
Given string is not empty or null
Enter a string value ::
Given string is empty or null
How do I load an image by URL on iOS device using Swift?

To load an image in iOS using swift we’ll make use of simple data Task session. The image needs to be loaded in background because it may be of any size and we don’t want it to stop our main view’s operations.
Let’s see this with help of an example. Create an empty project and add an empty Image view.
Create its outlet and then we’ll write the code to get image from an URL. This is how our application looks at the moment.
Now, let’s add code to get image from an URL.
func getData(from url: URL, completion: @escaping (Data?, URLResponse?, Error?) -> ()) {
   URLSession.shared.dataTask(with: url, completionHandler: completion).resume()
}
func downloadImage(from url: URL) {
   getData(from: url) {
      data, response, error in
      guard let data = data, error == nil else {
         return
      }
      DispatchQueue.main.async() {
         self.image = UIImage(data: data)
     }
   }
}
When we run this code, it will download image from the URL, we can create an image object and initialize our imgView with the new object.
But let’s create an extension of this method and use.
extension UIImageView {
   func getData(from url: URL, completion: @escaping (Data?, URLResponse?, Error?) -> ()) {
      URLSession.shared.dataTask(with: url, completionHandler: completion).resume()
   }
   func downloadImage(from url: URL) {
      getData(from: url) {
         data, response, error in
         guard let data = data, error == nil else {
            return
         }
         DispatchQueue.main.async() {
            self.image = UIImage(data: data)
         }
      }
   }
}
Now, In our viewDidLoad (or any other place you like) add the following code.
override func viewDidLoad() {
   super.viewDidLoad()
   let url = URL(string: "https://static.independent.co.uk/s3fs-public/thumbnails/image/2017/09/12/11/naturo-monkey-selfie.jpg?w968h681")
   self.imgView.downloadImage(from: url!)
}
When we run this code on our device, we get the following result.
How to create full width container in bootstrap5? - GeeksforGeeks

10 Sep, 2020
Bootstrap containers are content holders that are used to align, add margins and padding to your content.  Bootstrap has three different container classes, namely: 
.container
.container-fluid
.container-{breakpoint}
Width of a container varies in accordance with its class. We can create a full width container in Bootstrap5 using “.container-fluid” class. It sets the container width equal to 100% in all screen sizes. This means the container spans the entire width of the viewport.
Syntax:
<div class= ".container-fluid">
  ...
</div>  

Example:
<!DOCTYPE html><html>    <head>        <link rel="stylesheet"              href="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css"              integrity="sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I"              crossorigin="anonymous" />          <style>            .gfg {                background-color: green;                color: white;                text-align: center;            }        </style>    </head>      <body>        <div class="container-fluid gfg">            <h2>GeeksforGeeks</h2>        </div>    </body></html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
Bootstrap-Misc
Bootstrap
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to pass data into a bootstrap modal?
How to Show Images on Click using HTML ?
How to set Bootstrap Timepicker using datetimepicker library ?
How to change the background color of the active nav-item?
How to Use Bootstrap with React?
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 ?