code-rag-bench/online-tutorials huggingface dataset:
Python | Inverse Fast Fourier Transformation

20 Jul, 2021
Inverse Fast Fourier transform (IDFT) is an algorithm to undoes the process of DFT. It is also known as backward Fourier transform. It converts a space or time signal to a signal of the frequency domain. The DFT signal is generated by the distribution of value sequences to different frequency components. Working directly to convert on Fourier transform is computationally too expensive. So, Fast Fourier transform is used as it rapidly computes by factorizing the DFT matrix as the product of sparse factors. As a result, it reduces the DFT computation complexity from O(N2) to O(N log N). And this is a huge difference when working on a large dataset. Also, FFT algorithms are very accurate as compared to the DFT definition directly, in the presence of round-off error.
This transformation is a translation from the configuration space to frequency space and this is very important in terms of exploring both transformations of certain problems for more efficient computation and in exploring the power spectrum of a signal. This translation can be from xn to Xk. It is converting spatial or temporal data into the frequency domain data.
sympy.discrete.transforms.ifft() :It can perform Inverse Discrete Fourier Transform (DFT) in the complex domain.Automatically the sequence is padded with zero to the right because the radix-2 FFT requires the sample point number as a power of 2. For short sequences use this method with default arguments only as with the size of the sequence, the complexity of expressions increases.
 Parameters : 

-> seq : [iterable] sequence on which Inverse DFT is to be applied.
-> dps : [Integer] number of decimal digits for precision.

Returns : 
Fast Fourier Transform

Example 1:
# import sympy from sympy import ifft  # sequence seq = [15, 21, 13, 44]  # ffttransform = ifft(seq)print ("Inverse FFT : ", transform)
Output:
Inverse FFT :  [93/4, 1/2 + 23*I/4, -37/4, 1/2 - 23*I/4]
Example 2:
# import sympy from sympy import ifft  # sequence seq = [15, 21, 13, 44]  decimal_point = 4  # ffttransform = ifft(seq, decimal_point )print ("Inverse FFT : ", transform)
Output:
Inverse FFT :  [23.25, 0.5 + 5.75*I, -9.250, 0.5 - 5.75*I]

Maths
Mathematical
Python
Mathematical
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Node.js console.count() Method

26 Jun, 2020
The console.count() method is an inbuilt application programming interface of the console module which is used to count label passed to it as a parameter, by maintaining an internal counter for that specific label.
Syntax:
console.count(label)
Parameters: This method has one parameter as mentioned above and described below:
label: It is an optional parameter specifies the label to be counted. Default value is “default”.
Return Value: This method outputs the count of this function called with the specified label to the stdout.
Below examples illustrate the use of console.count() method in Node.js:
Example 1:
// Node.js program to demonstrate the   // console.count() Method  // Accessing console moduleconst console = require('console');  // Calling console.count() console.count("a");console.count("b");console.count("a");console.count("a");console.count("a");console.count("b");console.count("b");console.count("b");
Output:
a: 1
b: 1
a: 2
a: 3
a: 4
b: 2
b: 3
b: 4

Example 2:
// Node.js program to demonstrate the   // console.count() Method  // Accessing console moduleconst console = require('console');  // Calling console.count() method// with no parameter to count// default labelconsole.count();console.count("a");console.count("b");console.count("a");console.count("a");console.count();console.count();console.count();console.count("b");
Output:
default: 1
a: 1
b: 1
a: 2
a: 3
default: 2
default: 3
default: 4
b: 2

Note: The above program will compile and run by using the node filename.js command.
Reference: https://nodejs.org/api/console.html#console_console_count_label
Node.js-Methods
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
Node.js fs.readFileSync() Method
Node.js fs.writeFile() Method
How to update NPM ?
Difference between promise and async await in Node.js
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
How to reload activity in Android?

In some situations, we need to recall activity again from onCreate(). This example demonstrates how to reload activity in Android.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version = "1.0" encoding = "utf-8"?>
<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"
   android:id = "@+id/parent"
   xmlns:tools = "http://schemas.android.com/tools"
   android:layout_width = "match_parent"
   android:layout_height = "match_parent"
   tools:context = ".MainActivity"
   android:gravity = "center"
   android:orientation = "vertical">
   <TextView
      android:id = "@+id/text"
      android:textSize = "28sp"
      android:textAlignment = "center"
      android:layout_width = "match_parent"
      android:layout_height = "wrap_content" />
</LinearLayout>
In the above code, We have taken text view, when a user clicks on text view, it will call Main Activity again.
Step 3 − Add the following code to src/MainActivity.java
package com.example.andy.myapplication;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
   int view = R.layout.activity_main;
   TextView textview;
   @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(view);
      textview = findViewById(R.id.text);
      textview.setText("Click here to recall activity");
      textview.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            Intent i = new Intent(MainActivity.this, MainActivity.class);
            finish();
            overridePendingTransition(0, 0);
            startActivity(i);
            overridePendingTransition(0, 0);
         }
      });
   }
}
In the above code, we have used Intent to recreate an activity as shown below -
Intent i = new Intent(MainActivity.this, MainActivity.class);
finish();
overridePendingTransition(0, 0);
startActivity(i);
overridePendingTransition(0, 0);
In the above code, we have used overridePendingTransition(), it is used to remove activity create animation while re-creating activity.
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
In the above result, it has shown default screen when you click on text view, it will re-create Main Activity from onCreate() as shown below -
Click here to download the project code
Accessing variables in a constructor function using a prototype method with JavaScript?

For this, use a “prototype”. JavaScript objects inherit properties and methods from a prototype.
For accessing variables, we have also used the “this” in JavaScript.
function Customer(fullName){
   this.fullName=fullName;
}
Customer.prototype.setFullName = function(newFullName){
   this.fullName=newFullName;
}
var customer=new Customer("John Smith");
console.log("Using Simple Method = "+ customer.fullName);
customer.setFullName("David Miller");
console.log("Using Prototype Method = "+customer.fullName);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo79.js.
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo79.js
Using Simple Method = John Smith
Using Prototype Method = David Miller
Ways to read input from console in Java

Let us see some ways to read input from console in Java −
import java.util.Scanner;
public class Demo{
   public static void main(String args[]){
      Scanner my_scan = new Scanner(System.in);
      String my_str = my_scan.nextLine();
      System.out.println("The string is "+my_str);
      int my_val = my_scan.nextInt();
      System.out.println("The integer is "+my_val);
      float my_float = my_scan.nextFloat();
      System.out.println("The float value is "+my_float);
   }
}
The string is Joe
The integer is 56
The float value is 78.99
A class named Demo contains the main function. An instance of the Scanner class is created and the ‘nextLine’ function is used to read every line of a string input. An integer value is defined and it is read from the standard input console using ‘nextInt’. Similarly, ‘nextFloat’ function is used to read float type input from the standard input console. They are displayed on the console.
 Live Demo
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Demo{
   public static void main(String[] args) throws IOException{
      BufferedReader my_reader = new BufferedReader(new InputStreamReader(System.in));
      String my_name = my_reader.readLine();
      System.out.println("The name is ");
      System.out.println(my_name);
   }
}
The name is
Joe
A class named Demo contains the main function. Here, an instance of the buffered reader is created. A string type of data is defined and every line of the string is read using the ‘readLine’ function. The input is given from the standard input, and relevant message is displayed on the console.
C++ Program to Implement Sparse Matrix

A sparse matrix is a matrix in which majority of the elements are 0. An example for this is given as follows.
The matrix given below contains 5 zeroes. Since the number of zeroes is more than half the elements of the matrix, it is a sparse matrix.
5 0 0
3 0 1
0 0 9
A program to implement a sparse matrix is as follows.
 Live Demo
#include<iostream>
using namespace std;
int main () {
   int a[10][10] = { {0, 0, 9} , {5, 0, 8} , {7, 0, 0} };
   int i, j, count = 0;
   int row = 3, col = 3;
   for (i = 0; i < row; ++i) {
      for (j = 0; j < col; ++j){
         if (a[i][j] == 0)
         count++;
      }
   }
   cout<<"The matrix is:"<<endl;
   for (i = 0; i < row; ++i) {
      for (j = 0; j < col; ++j) {
         cout<<a[i][j]<<" ";
      }
      cout<<endl;
   }
   cout<<"The number of zeros in the matrix are "<< count <<endl;
   if (count > ((row * col)/ 2))
   cout<<"This is a sparse matrix"<<endl;
   else
   cout<<"This is not a sparse matrix"<<endl;
   return 0;
}
The matrix is:
0 0 9
5 0 8
7 0 0
The number of zeros in the matrix are 5
This is a sparse matrix
In the above program, a nested for loop is used to count the number of zeros in the matrix. This is demonstrated using the following code snippet.
for (i = 0; i < row; ++i) {
   for (j = 0; j < col; ++j) {
      if (a[i][j] == 0)
      count++;
   }
}
After finding the number of zeros, the matrix is displayed using a nested for loop. This is shown below.
cout<<"The matrix is:"<<endl;
for (i = 0; i < row; ++i) {
   for (j = 0; j < col; ++j) {
      cout<<a[i][j]<<" ";
   }
   cout<<endl;
}
Finally, the number of zeroes are displayed. If the count of zeros is more than half the elements in the matrix, then it is displayed that the matrix is a sparse matrix otherwise the matrix is not a sparse matrix.
cout<<"The number of zeros in the matrix are "<< count <<endl;
if (count > ((row * col)/ 2))
cout<<"This is a sparse matrix"<<endl;
else
cout<<"This is not a sparse matrix"<<endl;
Make HTML5 input type=“number” accepting dashes

To allow HTML5 input type = ”number” to accept dashes, use a regular expression.
Add the regular expression in the pattern attribute as shown below.
[ 0 - 9 ] + ([ - \, ] [0 - 9] + ) ? "
Add it to the code now:
input type = "text" pattern = "[0-9]+([-\,][0-9]+)?" name = "my-num" title = "dashes or comma"/>
The above will allow you to add dashes in number. However, above you need to use input type text for the solution to work.
Redis - Benchmarks

Redis benchmark is the utility to check the performance of Redis by running n commands simultaneously.
Following is the basic syntax of Redis benchmark.
redis-benchmark [option] [option value] 

Following example checks Redis by calling 100000 commands.
redis-benchmark -n 100000  

PING_INLINE: 141043.72 requests per second 
PING_BULK: 142857.14 requests per second 
SET: 141442.72 requests per second 
GET: 145348.83 requests per second 
INCR: 137362.64 requests per second 
LPUSH: 145348.83 requests per second 
LPOP: 146198.83 requests per second 
SADD: 146198.83 requests per second 
SPOP: 149253.73 requests per second 
LPUSH (needed to benchmark LRANGE): 148588.42 requests per second 
LRANGE_100 (first 100 elements): 58411.21 requests per second 
LRANGE_300 (first 300 elements): 21195.42 requests per second 
LRANGE_500 (first 450 elements): 14539.11 requests per second 
LRANGE_600 (first 600 elements): 10504.20 requests per second 
MSET (10 keys): 93283.58 requests per second 

Following is a list of available options in Redis benchmark.
Following example shows the multiple usage options in Redis benchmark utility.
redis-benchmark -h 127.0.0.1 -p 6379 -t set,lpush -n 100000 -q  

SET: 146198.83 requests per second 
LPUSH: 145560.41 requests per second 


    22 Lectures 
     40 mins

 Skillbakerystudios
 Print
 Add Notes
 Bookmark this page
Angular 6 - Environment Setup

In this chapter, we will discuss the Environment Setup required for Angular 6. To install Angular 6, we require the following −
Nodejs
Npm
Angular CLI
IDE for writing your code
Nodejs has to be greater than 8.11 and npm has to be greater than 5.6.
To check if nodejs is installed on your system, type node -v in the terminal. This will help you see the version of nodejs currently installed on your system.
C:\>node -v
v8.11.3

If it does not print anything, install nodejs on your system. To install nodejs, go the homepage https://nodejs.org/en/download/ of nodejs and install the package based on your OS.
The homepage of nodejs will look like the following −
Based on your OS, install the required package. Once nodejs is installed, npm will also get installed along with it. To check if npm is installed or not, type npm -v in the terminal. It should display the version of the npm.
C:\>npm -v
5.6.0

Angular 6 installations are very simple with the help of angular CLI. Visit the homepage https://cli.angular.io/ of angular to get the reference of the command.
Type npm install -g @angular/cli, to install angular cli on your system.
You will get the above installation in your terminal, once Angular CLI is installed. You can use any IDE of your choice, i.e., WebStorm, Atom, Visual Studio Code, etc.
The details of the project setup is explained in the next chapter.

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    28 Lectures 
     2.5 hours 

 Anadi Sharma

    11 Lectures 
     7.5 hours 

 SHIVPRASAD KOIRALA

    16 Lectures 
     2.5 hours 

 Frahaan Hussain

    69 Lectures 
     5 hours 

 Senol Atac

    53 Lectures 
     3.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
Play infinitely looping video on-load in HTML5

The <video> tag specifies video. Currently, there are 3 supported video formats for the <video> element that are MP4, WebM, and Ogg. Autoplay is used to start the video when the video and page loads.
The loop attribute is a boolean attribute. When present, it specifies that the video will start over again, every time it is finished.
The loop attribute should do it.
<video width="600" height="500" autoplay loop>
   <source src="movie.mp4" type="video/mp4" />
   <source src="movie.ogg" type="video/ogg" />
   Your browser does not support the video element.
</video>
If you have a problem with the loop attribute, listen to the videoEnd event. After that call the play() method when it fires.
JavaScript Number NaN Property - GeeksforGeeks

24 Dec, 2021
In JavaScript, NaN stands for Not a Number. It represents a value which is not a valid number. It can be used to check whether a number entered is a valid number or not a number. To assign a variable to NaN value, we can use one of the two following ways.
var a = NaN
var a = Number.NaN
Example: In this example, we will use JavaScript Number NaN Property.
var monthNumber = 14;  if (monthNumber < 1 || monthNumber > 12) {      // Assigning monthNumber NaN as     // month number is not valid    monthNumber = Number.NaN;      console.log("Month number should be"                + " between 1 and 12");}else {    console.log(monthNumber);}
Output:
We will see some examples of operations that return NaN.
Example 1: Whenever we try to parse a string or “undefined” to an int, it returns NaN.
console.log(parseInt("higeeks"));
Output:
Example 2: Whenever we try to find square root of a negative number using Math.sqrt function, it returns NaN.
console.log(Math.sqrt(-1));
Output:
Example 3: Whenever we try to make on operation on NaN, it returns NaN.
console.log(5 + NaN);
Output:
Example 4: Any indeterminate form also returns NaN.
console.log(0 * Infinity)
Output:
Example 5: Any operation other than addition on a string also results in NaN.
console.log("hi"/5)
Output:
Supported Browser:
Chrome 1 and above
Edge 12 and above
Firefox 1 and above
Internet Explorer 4 and above
Opera 3 and above
safari 1 and above
ysachin2314
JavaScript-Properties
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
How to check whether a thread is alive or not in C# - GeeksforGeeks

11 Jan, 2019
A Thread class is responsible for creating and managing a thread in multi-thread programming. It provides a property known as IsAlive to check if the thread is alive or not. Or in other words, the value of this property indicates the current execution of the thread.
Syntax:
public bool IsAlive { get; }
Return Value: This property returns true if the thread is started and not terminated normally or aborted. Otherwise, return false. The return type of this property is System.Boolean.
Below programs illustrate the use of IsAlive property:
Example 1:
// C# program to illustrate the // use of IsAlive propertyusing System;using System.Threading;  public class GFG {      // Main Method    static public void Main()    {        Thread thr;          // Get the reference of main Thread        // Using CurrentThread property        thr = Thread.CurrentThread;          // Display the current state of         // the main thread Using IsAlive        // property        Console.WriteLine("Is main thread is alive"+                            " ? : {0}", thr.IsAlive);    }}
Output:
Is main thread is alive ? : True

Example 2:
// C# program to illustrate the // use of IsAlive propertyusing System;using System.Threading;  public class GFG {      // Main method    public static void Main()    {        // Creating and initializing threads        Thread Thr1 = new Thread(new ThreadStart(job));        Thread Thr2 = new Thread(new ThreadStart(job));          // Display the current state of         // the threads Using IsAlive         // property        Console.WriteLine("Is thread 1 is alive : {0}",                                         Thr1.IsAlive);          Console.WriteLine("Is thread 2 is alive : {0}",                                         Thr2.IsAlive);        Thr1.Start();        Thr2.Start();          // Display the current state of         // the threads Using IsAlive        // property        Console.WriteLine("Is thread 1 is alive : {0}",                                         Thr1.IsAlive);          Console.WriteLine("Is thread 2 is alive : {0}",                                         Thr2.IsAlive);    }      // Static method    public static void job()    {        Thread.Sleep(2000);    }}
Output:
Is thread 1 is alive : False
Is thread 2 is alive : False
Is thread 1 is alive : True
Is thread 2 is alive : True

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.threading.thread.isalive?view=netframework-4.7.2
CSharp Multithreading
CSharp Thread Class
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# Dictionary with examples
C# | Delegates
C# | Method Overriding
C# | Abstract Classes
Extension Method in C#
Difference between Ref and Out keywords in C#
C# | Replace() Method
C# | Class and Object
C# | Constructors
C# | String.IndexOf( ) Method | Set - 1
What is nodeValue property in JavaScript HTML DOM?

The nodeValue property is used to get the node value. You need to specify the node.
You can try to run the following code to learn how to get nodeValue property.
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <p>Get the node value</p>
      <button>Demo Button Text</button>
      <script>
         var val = document.getElementsByTagName("BUTTON")[0];
         var res = val.childNodes[0].nodeValue;
         document.write("<br>Node Value: "+res);
      </script>
   </body>
</html>
How to import an Excel File into R ? - GeeksforGeeks

21 Apr, 2021
In this article, we will discuss how to import an excel file in the R Programming Language. There two different types of approaches to import the excel file into the R programming language and those are discussed properly below.
File in use:
In this approach to import the Excel file in the R, the user needs to call the read_excel() function from readxl library of the R language with the name of the file as the parameter. With the use of this function, the user will be able to import the Excel file in R.
Syntax: read_excel(filename, sheet, dtype = “float32”)
Parameters:
filename:-File name to read from.
sheet:-Name of the sheet in Excel file.
dtype:-Numpy data type.
Returns:
The variable is treated to be a data frame.
Example:
R
library(readxl)  gfg_data=read_excel('Data_gfg.xlsx')  gfg_data
Output:
This approach is the easy approach to import the excel file in R compared with the previous one as this is the only approach to import an excel file in R where the user need not type any code in the console to import the excel file. Further, here user just needs to work on the environment window of the studio.
Environment window of the Rstudio:
Steps to import excel file using Dataset option from the environment window of Rstudio:
Step 1: Select the Import Dataset option in the environment window. Here the user needs to select the option to import the dataset from the environment window in Rstudio.
Step 2: Select the option of “From excel” under the import Dataset option. In this step, the user needs to select the option to “from excel” as the file is in the form of excel under the import dataset option to import the excel file.
Step 3: Select the browse option and select the excel file to be imported. Now, under this with the click to the browse option user will be given the choice to select the needed excel file to be imported in R.And then the user need to select the needed excel file to be imported in R.
Step 4: Select the import option and the excel file is successfully imported. Now, in this final step user need to select the import button and this will lead to successful importation of the selected excel file by the user in R.
Picked
R-Excel
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
Replace Specific Characters in String in R
How to filter R dataframe by multiple conditions?
R - if statement
Time Series Analysis in R
How to change the order of bars in bar chart in R ?
How to provide multiple statements on a single line in Python?

More than one statements in a block of uniform indent form a compound statement. Normally each statement is written on separate physical line in editor. However, statements in a block can be written in one line if they are separated by semicolon. Following is code of three statements written in separate lines
a=10
b=20
c=a*b
print (c)
These statements can very well be written in one line by putting semicolon in between.
a=10; b=20; c=1*b; print (c)
A new block of increased indent generally starts after : symbol as in case of if, else, while, for, try statements. However, using above syntax, statements in block can be written in one line by putting semicolon. Following is a straight forward example of a block of statements in a for loop
for i in range(5):
   print ("Hello")
   print ("i=",i)
This block can also be written in single line as follows −
for i in range(5): print ("Hello"); print ("i=",i)
However, this practice is not allowed if there is a nested block of statements.
Tryit Editor v3.7

Tryit: Grey HEX color values
Google Guice - Field Injection

Injection is a process of injecting dependeny into an object. Field injection is used to set value object as dependency to the field of an object. See the example below.
Create a java class named GuiceTester.
GuiceTester.java
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.ImplementedBy;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.name.Named;
import com.google.inject.name.Names;

public class GuiceTester {
   public static void main(String[] args) {
      Injector injector = Guice.createInjector(new TextEditorModule());
      TextEditor editor = injector.getInstance(TextEditor.class);
      editor.makeSpellCheck();
   } 
}

class TextEditor {
   private SpellChecker spellChecker;

   @Inject
   public TextEditor( SpellChecker spellChecker) {
      this.spellChecker = spellChecker;
   }

   public void makeSpellCheck(){
      spellChecker.checkSpelling();
   } 
}

//Binding Module
class TextEditorModule extends AbstractModule {

   @Override
   protected void configure() { 
      bind(String.class)
         .annotatedWith(Names.named("JDBC"))
         .toInstance("jdbc:mysql://localhost:5326/emp");
   } 
}

@ImplementedBy(SpellCheckerImpl.class)
interface SpellChecker {
   public void checkSpelling();
}

//spell checker implementation
class SpellCheckerImpl implements SpellChecker {

   @Inject @Named("JDBC")
   private String dbUrl;

   public SpellCheckerImpl(){}

   @Override
   public void checkSpelling() { 
      System.out.println("Inside checkSpelling." );
      System.out.println(dbUrl); 
   }
}
Compile and run the file, you will see the following output.
Inside checkSpelling.
jdbc:mysql://localhost:5326/emp


    27 Lectures 
     1.5 hours 

 Lemuel Ogbunude
 Print
 Add Notes
 Bookmark this page
Python - tensorflow.math.reduce_sum() - GeeksforGeeks

17 May, 2021
TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks.
reduce_sum() is used to find sum of elements across dimensions of a tensor.
Syntax: tensorflow.math.reduce_sum( input_tensor, axis, keepdims, name)
Parameters:
input_tensor: It is numeric tensor to reduce.
axis(optional): It represent the dimensions to  reduce. It’s value should be in range [-rank(input_tensor), rank(input_tensor)). If no value is given for this all dimensions are reduced.
keepdims(optional): It’s default value is False. If it’s set to True it will retain the reduced dimension with length 1.
name(optional): It defines the name for the operation.
Returns: It returns a tensor.
Example 1:
Python3
# importing the libraryimport tensorflow as tf # Initializing the input tensora = tf.constant([1, 2, 3, 4], dtype = tf.float64) # Printing the input tensorprint('Input: ', a) # Calculating resultres = tf.math.reduce_sum(a) # Printing the resultprint('Result: ', res)
Output:
Input:  tf.Tensor([1. 2. 3. 4.], shape=(4, ), dtype=float64)
Result:  tf.Tensor(10., shape=(), dtype=float64)
Example 2:
Python3
# importing the libraryimport tensorflow as tf # Initializing the input tensora = tf.constant([[1, 2], [3, 4]], dtype = tf.float64) # Printing the input tensorprint('Input: ', a) # Calculating resultres = tf.math.reduce_sum(a, axis = 1, keepdims = True) # Printing the resultprint('Result: ', res)
Output:
Input:  tf.Tensor(
[[1. 2.]
 [3. 4.]], shape=(2, 2), dtype=float64)
Result:  tf.Tensor(
[[3.]
 [7.]], shape=(2, 1), dtype=float64)
surinderdawra388
Python Tensorflow-math-functions
Python-Tensorflow
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
Selecting rows in pandas DataFrame based on conditions
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
C program for pipe in Linux - GeeksforGeeks

26 Apr, 2018
Working and implementation of Pipe in Linux.
Prerequisite : Pipe in Linux
Approach : Pipe is highly used in Linux. Basically, pipe has 2 parts, one part is for writing and another is used for reading. So, an array of size 2 is taken. a[1] is used for writing and a[0] for reading.After reading from pipe, program will show output on console.
// C program to implement pipe in Linux#include <errno.h>#include <fcntl.h>#include <stdio.h>#include <stdlib.h>#include <sys/wait.h>#include <unistd.h>  int main(){    // array of 2 size a[0] is for reading     // and a[1] is for writing over a pipe     int a[2];       // opening of pipe using pipe(a)       char buff[10];    if (pipe(a) == -1)     {        perror("pipe"); // error in pipe        exit(1); // exit from the program    }      // writing a string "code" in pipe    write(a[1], "code", 5);     printf("\n");      // reading pipe now buff is equal to "code"    read(a[0], buff, 5);      // it will print "code"    printf("%s", buff); }
Output :
More examples on pipe()
C Programs
Linux-Unix
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
C Program to read contents of Whole File
Producer Consumer Problem in C
C / C++ Program for Dijkstra's shortest path algorithm | Greedy Algo-7
Regular expressions in C
Handling multiple clients on server with multithreading using Socket Programming in C/C++
Sed Command in Linux/Unix with examples
AWK command in Unix/Linux with examples
grep command in Unix/Linux
TCP Server-Client implementation in C
cut command in Linux with examples
Adding two Sets in Javascript

The operation of adding 2 sets is known as a union. You need to add every object from one set to another while checking for duplicates. We can just use the 2 methods we already implemented to implement this method.
We'll implement this function as a static function as we don’t want to mutate existing sets, but create and return a new one. We first need to check if the object passed to it is really an instance of the MySet class. 
static union(s1, s2) {
   if (!s1 instanceof MySet || !s2 instanceof MySet) {
      console.log("The given objects are not of type MySet");
      return null;
   }
   let newSet = new MySet();
   s1.forEach(elem => newSet.add(elem));
   s2.forEach(elem => newSet.add(elem));
   newSet;
}
You can test this using − 
const testSet1 = new MySet();
testSet1.add(1);
testSet1.add(2);

const testSet2 = new MySet();
testSet2.add(2);
testSet2.add(5);

let testSet3 = MySet.union(testSet1, testSet2);
testSet3.display();
This will give the output −
{ '1': '1', '2': '2', '5': '5' }
Note that the union function is not there in the ES6 API as well. You can make this function be available in the Set class as follows &minusl 
Set.union = function(s1, s2) {
   if (!s1 instanceof Set || !s2 instanceof Set) {
      console.log("The given objects are not of type Set");
      return null;
   }
   let newSet = new Set();
   s1.forEach(elem => newSet.add(elem));
   s2.forEach(elem => newSet.add(elem));
   return newSet;
}
You can test this using −
let setA = new Set([1, 2, 3, 4]);
let setB = new Set([2, 3]);
console.log(Set.union(setA, setB));
This will give the output −
Set { 1, 2, 3, 4 }
Python Pandas - Create a DateOffset and increment date

To create a DateOffset, use the DateOffset() method in Pandas. Set the Increment value as an argument.
At first, import the required libraries −
from pandas.tseries.offsets import DateOffset
import pandas as pd
Set the timestamp object in Pandas −
timestamp = pd.Timestamp('2021-09-11 02:30:55')

DateOffset for date increment. We are incrementing the months here using the "months" parameter −
print("DateOffset...\n",timestamp + DateOffset(months=2))
Following is the code −
from pandas.tseries.offsets import DateOffset
import pandas as pd

# Set the timestamp object in Pandas
timestamp = pd.Timestamp('2021-09-11 02:30:55')

# Display the Timestamp
print("Timestamp...\n",timestamp)

# DateOffset for date increment
# We are incrementing the months here using the "months" parameter
print("DateOffset...\n",timestamp + DateOffset(months=2))
This will produce the following code −
Timestamp...
2021-09-11 02:30:55
DateOffset...
2021-11-11 02:30:55
How can we implement the paintComponent() method of a JPanel in Java?


A JPanel is a lightweight container and it is an invisible component in Java. A JPanel's default layout is FlowLayout. After the JPanel has been created, other components can be added to the JPanel object by calling its add() method inherited from the Container class.
This method is needed to draw something on JPanel other than drawing the background color. This method already exists in a JPanel class so that we need to use the super declaration to add something to this method and takes Graphics objects as parameters. The super.paintComponent() which represents the normal the paintComponent() method of the JPanel which can only handle the background of the panel must be called in the first line.
protected void paintComponent(Graphics g)
import java.awt.*;
import javax.swing.*;
public class SmileyApp extends JPanel {
   @Override
   public void paintComponent(Graphics g) {
      super.paintComponent(g);
      g.setColor(Color.YELLOW);
      g.fillOval(10, 10, 200, 200);
      // draw Eyes
      g.setColor(Color.BLACK);
      g.fillOval(55, 65, 30, 30);
      g.fillOval(135, 65, 30, 30);
      // draw Mouth
      g.fillOval(50, 110, 120, 60);
      // adding smile
      g.setColor(Color.YELLOW);
      g.fillRect(50, 110, 120, 30);
      g.fillOval(50, 120, 120, 40);
   }
   public static void main(String[] args) {
      SmileyApp smiley = new SmileyApp();
      JFrame app = new JFrame("Smiley App");
      app.add(smiley, BorderLayout.CENTER);
      app.setSize(300, 300);
      app.setLocationRelativeTo(null);
      app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      app.setVisible(true);
   }
}
PHP strtotime() Function

The strtotime() function accepts a date/time string, with textual date/time values and parses it as an Unix timestamp.
strtotime($time)

time(Mandatory)
This value represents the date/time string.
now(Optional)
This represents a timestamp which is used as a base for the calculation of relative dates..
PHP strtotime() function returns a timestamp value for the given date string. Incase of failure, this function returns the boolean value false.
This function was first introduced in PHP Version 4.0 and, works with all the later versions.
Following example demonstrates the usage of the strtotime() function −
<?php
   $str = strtotime("12 September 2009");
   print("Timestamp: ".$str); 
?>
This will produce following result −
Timestamp: 1252713600

If you pass "now" as a parameter this function returns the current time stamp
<?php
   $str = strtotime("now");
   print("Timestamp: ".$str); 
?>
This will produce following result −
Timestamp: 1589369948

Now letus invoke this method by passing various date values −
<?php
   print("Time stamp of 25 December 2019: ".strtotime("25 December 2019")."\n");
   print("Time stamp of +26 day: ".strtotime("+26 day")."\n");
   print("Time stamp of +3 week: ".strtotime("+3 week")."\n");
   print("Time stamp of +3 month 9 days 9 hours: ".strtotime("+3 month 9 days 9 hours")."\n");
   print("Time stamp of last Sunday: ".strtotime("last Sunday")."\n");
   print("Time stamp of next Friday: ".strtotime("next Friday")."\n");
?>
This will produce the following output −
Time stamp of 25 December 2019: 1577232000
Time stamp of +26 day: 1591617718
Time stamp of +3 week: 1591185718
Time stamp of +3 month 9 days 9 hours: 1598130118
Time stamp of last Sunday: 1589068800
Time stamp of next Friday: 1589500800

<?php
   $timestamp = strtotime( "February 15, 2015" );   
   print date( 'Y-m-d', $timestamp );
?>
This will produce the following output −
2015-02-15


    45 Lectures 
     9 hours 

 Malhar Lathkar

    34 Lectures 
     4 hours 

 Syed Raza

    84 Lectures 
     5.5 hours 

 Frahaan Hussain

    17 Lectures 
     1 hours 

 Nivedita Jain

    100 Lectures 
     34 hours 

 Azaz Patel

    43 Lectures 
     5.5 hours 

 Vijay Kumar Parvatha Reddy
 Print
 Add Notes
 Bookmark this page
HTML - <style> tag

The HTML <style> tag is used for declaring style sheets within the head of your HTML document.
NONE
<head>

   <style type="text/css">
      h1 { color:#F1F1F1 }
   </style>

</head>
For more detail on <style> tag please check HTML Styles chapter.
Specifies the direction of the text
Document wide identifier
Sets the language code.
Sets the language code.

    19 Lectures 
     2 hours 

 Anadi Sharma

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    18 Lectures 
     1.5 hours 

 Frahaan Hussain

    57 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)

    54 Lectures 
     6 hours 

 DigiFisk (Programming Is Fun)

    45 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
Angular10 TitleCasePipe - GeeksforGeeks

30 Apr, 2021
In this article, we are going to see what is TitleCasePipe in Angular 10 and how to use it.
TitleCasePipe is used to Transforms all the text to titlecase.
Syntax:
{{ value | TitleCasePipe }}
NgModule: Module used by TitleCasePipe is:
CommonModule
Approach: 
Create the angular app to be used
There is no need for any import for the TitleCasePipe to be used
In app.component.ts define the variables that takes the TitleCasePipe value.
In app.component.html use the above syntax with ‘|’ symbol to make TitleCasePipe element.
Serve the angular app using ng serve to see the output
Input value:
value: it takes a string value.
Example 1:
app.component.ts
import { Component, OnInit } from '@angular/core';  @Component({    selector: 'app-root',    templateUrl: './app.component.html'})export class AppComponent {    // Key Value object    value : string = 'geeksforgeeks';  }
app.component.html
<b>  <div>    titlecase value is : {{value | titlecase}}  </div></b>
Output:
Example 2:
app.component.ts
import { Component, OnInit } from '@angular/core';  @Component({    selector: 'app-root',    templateUrl: './app.component.html'})export class AppComponent {    // Key Value object    value : string = 'geeksforgeeks';  }
app.component.html
<b>  <div>    CamelCase value is : {{value}}  </div>  <div>    TitleCase value is : {{value |titlecase}}  </div></b>
Output:
Reference: https://angular.io/api/common/TitleCasePipe
Angular10
AngularJS-Basics
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Angular Libraries For Web Developers
How to use <mat-chip-list> and <mat-chip> in Angular Material ?
How to make a Bootstrap Modal Popup in Angular 9/8 ?
Angular 10 (blur) Event
Angular PrimeNG Dropdown Component
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to Get Current Date and Time in SQL?

08 Oct, 2021
In this article, we will show to get the current date and time in SQL. In SQL whenever we need to insert and fetching the Current date and time. So For finding to Current Date and Time in SQL have some Predefined function. We will Implement a few methods here. With the Help of the below function.  
GETDATE() function is mostly used to find the current Date. It will return the DATETIME data type. This means it will Return the Current date with the current Time.
Query:
Select GetDate() AS 'CurrentDATETime';
Output:
CURRENT_TIMESTAMP:
It is also used to find current TIMESTAMP means current Date and Time. The CURRENT_TIMESTAMP function can be used the same that the GETDATE() function is used CURRENT_TIMESTAMP returns the same result as GETDATE(). 
Query:
Select CURRENT_TIMESTAMP AS "CURRENTTIMESTAMP"; 
Output:
SYSDATETIME(): 
SYSDATETIME() function is also used to get the current TIME of the System on which the instance of SQL Server is running. SYSDATETIME() function provides more fractional seconds precision compared to the GETDATE() function. We can fetch the TIME part from the DATE and TIME value returned from the SYSDATETIME() function as below:
Query:
SELECT SYSDATETIME() 'Current TIME using SYSDATETIME()'
Output:
 We can extract the time part from GETDATE() or CURRENT_TIMESTAMP().
Query:
SELECT CONVERT(VARCHAR(8), GETDATE(),108)'hh:mi:ss'
Output:
 
Picked
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE CS 2018 | Question 32

14 Nov, 2018
Consider a long-lived TCP session with an end-to-end bandwidth of 1 Gbps (= 109 bits-per-second). The session starts with a sequence number of 1234. The minimum time (in seconds, rounded to the closest integer) before this sequence number can be used again is _______ .
Note – This was Numerical Type question.
(A) 34(B) 4.30(C) 43(D) None of theseAnswer: (A)Explanation: As sequence number field of TCP is 32 bits, so there are total 232 unique sequence number are possible (from 0 to 232-1), which is limit of TCP data.
But if you want to send data more than 232 bytes in TCP, then you need to repeat this procedure after sending 232 bytes of data or unique sequence numbers. This concept is known as wrap around which allow sending unlimited data using TCP.
Therefore, question is asking for wrap around time which is equal to pass all unique sequences first, i.e., 232, TCP assigns 1 sequence number to each byte of data.
Twrap−around = (Total data) / (Bandwidth)
= (232 bytes) / (109 bits per second) 
= (232 * 8 bits) / (109 bits per second) 
= 34.35 seconds = 34 (in seconds) 
GATE’ answer is same as either ceiling value or floor value (i.e., 34 and 35 both are correct).
So, option (A) is correct.Quiz of this Question
GATE CS 2018
GATE-GATE CS 2018
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
dmidecode command in Linux with Examples

15 May, 2019
dmidecode also referred as Desktop Management Interface table decoder, record data from DMI table and produce it in human readable format. dmidecode command is used when the user want to retrieve system’s hardware related information such as Processor, RAM(DIMMs), BIOS detail, Memory, Serial numbers etc. of Linux system in a readable format. dmidecode command not only displays the system’s current hardware configuration but also the maximum supported CPU and memory.
Syntax:
dmidecode [OPTIONS]
However, in some Linux/Unix system, it may require root permission in order to run dmidecode command, like the present Linux system which is being used to run the following command require root privilege.
Example 1: Running a simple dmidecode command to get hardware information.
Example 2: To get information about Processor.
Example 3: To get BIOS information.
Options:
-d, –dev-mem FILE: This option is used to read memory from device FILE, where FILE is the file name being used. By default it is /dev/mem.
-h, –help: Display help and exit.
-q, –quiet: This option is used to print less verbose output.
-s, –string KEYWORD: Only display the value of the given DMI string. Suppose if we want to know the value of processor-frequency, we can use the following command along with the keyword(processor-frequency).
-t, –type TYPE: This option is helpful when we only want to display the entries of a given type. With the help of DMI type id, we can get particular information about a hardware component. Type ids are equivalent to the keyword thus we can either use the type id’s # or we can use the entire keyword to get the information related to that keyword. Type keywords are not case sensitive.Example 1: To get information about Baseboard we can execute any of the following commands.sudo dmidecode -t baseboardorsudo dmidecode -t 2orsudo dmidecode --type baseboardExample 2: To get information about Chassis.
Example 1: To get information about Baseboard we can execute any of the following commands.
sudo dmidecode -t baseboard
or
sudo dmidecode -t 2
or
sudo dmidecode --type baseboard
Example 2: To get information about Chassis.
-u, –dump: Mostly used in debugging processes. This option is used when don’t want to decode the entries rather we want them to be dumped in hexadecimal form.
–dump-bin FILE: This option comes handy when we don’t want dmidecode to decode the entries but to dump the DMI information to a binary file. The file is the name of the file that is to be used.
–from-dump FILE: This option Read the DMI data from a given binary file.
-V, –version: Display the version and exit.
linux-command
Linux-misc-commands
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.