code-rag-bench/online-tutorials huggingface dataset:
Java 8 | ObjDoubleConsumer Interface with Example - GeeksforGeeks

26 Oct, 2018
The ObjDoubleConsumer Interface is a part of the java.util.function package which has been introduced since Java 8, to implement functional programming in Java. It represents a function which takes in two arguments and produces a result. However these kind of functions don’t return any value.
Hence this functional interface takes in one generic namely:-
T: denotes the type of the input argument to the operation
The lambda expression assigned to an object of ObjDoubleConsumer type is used to define its accept() which eventually applies the given operation on its argument. It takes in a double-valued and a T-valued argument and is expected to operate without any side effects. It is more like using an object of type BiConsumer<T, Double> except the fact that one is a reference and one is a primitive data type in this case. Hence we will be obtaining one reference and one value when this function is called.
The ObjDoubleConsumer interface consists of the following two functions:
This method accepts two values and performs the operation on the given arguments.
Syntax:
void accept(T t, double value)
Parameters: This method takes in two parameters:
t– the first input argument
value– the second input argument
Return Value: This method does not return any value.
Below is the code to illustrate accept() method:
Program:
// Java code to demonstrate// accept() method of ObjDoubleConsumer Interface  import java.util.Arrays;import java.util.List;import java.util.function.ObjDoubleConsumer;import java.util.stream.Stream;  public class GFG {    public static void main(String args[])    {          // Get the list from which        // the Interface is to be instantiated.        List<Integer>            arr = Arrays.asList(3, 2, 5, 7, 4);          // Instantiate the ObjDoubleConsumer interface        ObjDoubleConsumer<List<Integer> >            func = (list, num) ->        {            list.stream()                .forEach(                    a -> System.out.println(a * num));        };        func.accept(arr, 2.0);    }}
6.0
4.0
10.0
14.0
8.0

Java - util package
Java 8
java-basics
Java-Functional Programming
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Interfaces in Java
How to iterate any Map in Java
ArrayList in Java
Initialize an ArrayList in Java
Stack Class in Java
Singleton Class in Java
Multidimensional Arrays in Java
Set in Java
How to detect touch screen device using CSS ? - GeeksforGeeks

18 May, 2021
In a website, it becomes important to detect the pointing device used by the user. For example, if the user uses a finger as the pointing device (which has less accuracy on the screen due to more screen-finger contact area) then we should increase the size of various elements like buttons, links, input fields, etc. so that the user feels comfortable using the website.
A touchscreen device can easily be detected using CSS media queries or by using JavaScript. 
HTML alone cannot detect touchscreen devices. Along with HTML, we will need CSS media queries. In CSS media queries we have a feature called pointer used to detect the pointing accuracy of the pointing device used by the user. It has the following 3 values.
pointer: none: It gets triggered when the input mechanism of the device has no pointing device.
pointer: coarse: It gets triggered when the input mechanism of the pointing device has less accuracy. For example, touchscreens.
pointer: fine: It gets triggered when the input mechanism of the pointing device has high accuracy. For example, mouse, trackpad, stylus, etc.
HTML Code: The following code detects if the user is using a touchscreen device or not.
HTML
<!-- HTML code to detect a touch    screen device  --><!DOCTYPE html><html lang="en">  <head>    <style>          /* By default, setting the         image display to none */        #image-GFG {            display: none;        }          /* In case of touch-screen device,        setting image display to block.        Using @media to detect pointer         accuracy */        @media (pointer:coarse) {            #image-GFG {                display: block;            }        }    </style></head>  <body>    <h2>        This image will only be visible on         a touch screen device    </h2>          <img src="https://media.geeksforgeeks.org/wp-content/uploads/20210513020603/GFG.png"         id="image-GFG"></body>  </html>
Output:
Output on the touch screen:              
Output from a smartphone 
Output on the non-touch screen:
Output from a non touch-screen desktop
Note: To test output on a smartphone, copy the above code into a .html file and transfer it to the smartphone and open it using any browser like Chrome or Safari.
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Properties
CSS-Questions
HTML-Questions
Picked
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Design a web page using HTML and CSS
Form validation using jQuery
How to set space between the flexbox ?
Search Bar using HTML, CSS and JavaScript
How to style a checkbox using CSS?
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
Hide or show elements in HTML using display property
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
java.time.LocalTime.now() Method Example

The java.time.LocalTime.now(ZoneId zone) method obtains the current time from the system clock in the specified time-zone.
Following is the declaration for java.time.LocalTime.now(ZoneId zone) method.
public static LocalTime now(ZoneId zone)

zone −  the zone ID to use, not null.
the current time using the system clock, not null.
The following example shows the usage of java.time.LocalTime.now(ZoneId zone) method.
package com.tutorialspoint;

import java.time.LocalTime;
import java.time.ZoneId;

public class LocalTimeDemo {
   public static void main(String[] args) {
 
      LocalTime time = LocalTime.now(ZoneId.systemDefault());
      System.out.println(time);  
   }
}
Let us compile and run the above program, this will produce the following result −
12:35:15.354

 Print
 Add Notes
 Bookmark this page
Swap two numbers in PL/SQL without using temp - GeeksforGeeks

05 Jul, 2018
In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations.
Given two numbers num1 and num2 and the task is to swap the value of given numbers.
Examples:
Input : num1  = 1000, num2 = 2000
Output : num1  = 2000, num2 = 1000

Input : num1  = 40, num2 = 20
Output : num1  = 20, num2 = 40

Method 1 (Using Arithmetic Operators)The idea is to get sum in one of the two given numbers. The numbers can then be swapped using the sum and subtraction from sum.
DECLARE     -- declare variable num1, num2      -- of datatype number     num1 NUMBER;     num2 NUMBER; BEGIN     num1 := 1000;       num2 := 2000;       -- print result before swapping     dbms_output.Put_line('Before');       dbms_output.Put_line('num1 = '                          || num1                          ||' num2 = '                          || num2);       -- swapping of numbers num1 and num2     num1 := num1 + num2;       num2 := num1 - num2;       num1 := num1 - num2;       -- print result after swapping     dbms_output.Put_line('After');       dbms_output.Put_line('num1 = '                          || num1                          ||' num2 = '                          || num2); END; -- Program End 
Output:
Before
num1 = 1000 num2 = 2000
After
num1 = 2000 num2 = 1000

Method 2 Multiplication and division can also be used for swapping.
DECLARE     -- declare variable num1, num2      -- of datatype number     num1 NUMBER;     num2 NUMBER; BEGIN     num1 := 1000;       num2 := 2000;       -- print result before swapping     dbms_output.Put_line('Before');       dbms_output.Put_line('num1 = '                          || num1                          ||' num2 = '                          || num2);       -- swapping of numbers num1 and num2     num1 := num1 * num2; -- num1 now becomes 15 (1111)       num2 := num1 / num2; -- num2 becomes 10 (1010)       num1 := num1 / num2; -- num1 becomes 5 (0101)     -- print result after swapping     dbms_output.Put_line('After');       dbms_output.Put_line('num1 = '                          || num1                          ||' num2 = '                          || num2); END;   -- Program End 
Output:
Before
num1 = 1000 num2 = 2000
After
num1 = 2000 num2 = 1000

SQL-PL/SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between SQL and NoSQL
SQL | Views
Difference between DDL and DML in DBMS
SQL Correlated Subqueries
Difference between DELETE, DROP and TRUNCATE
SQL | GROUP BY
What is Cursor in SQL ?
SQL Interview Questions
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | TRANSACTIONS
How to specify an image as a client-side image-map in HTML?

Use the usemap attribute to specify an image as a client-side image-map in HTML. You can try to run the following code to implement usemap attribute −
<!DOCTYPE html>
<html>
   <head>
      <title>HTML map Tag</title>
   </head>
   <body>
      <img src = "/images/html.gif" alt = "HTML Map" border = "0" usemap = "#html"/>
      <!-- Create Mappings -->
      <map name = "html">
         <area shape = "circle" coords = "154,150,59" href = "about/about_team.htm"
         alt = "Team" target = "_self" />
      </map>
   </body>
</html>
How to delete data in a MySQL database with Java?

Delete data from a MySQL database with the help of DELETE command. The syntax is as follows.
delete from yourTableName where condition;
I will delete data from a MySQL database with the help of JAVA programming language. First, create a table and insert some records. The following is the query to create a table.
mysql> create table DeleteTableDemo
   -> (
   -> id int,
   -> Name varchar(200)
   -> );
Query OK, 0 rows affected (0.94 sec)
Insert records in the above table. The query to insert records is as follows.
mysql> insert into DeleteTableDemo values(101,'Smith');
Query OK, 1 row affected (0.21 sec)

mysql> insert into DeleteTableDemo values(102,'Johnson');
Query OK, 1 row affected (0.27 sec)
Now we can check how many records are in my table. The query is as follows.
mysql> select *from DeleteTableDemo;
The following is the output.
+------+---------+
| id   | Name    |
+------+---------+
|  101 | Smith   |
|  102 | Johnson |
+------+---------+
2 rows in set (0.00 sec)
We have two records in the table. Now, let us deleted data from a MySQL database table with the help of delete command. Here is the JAVA code that deletes the data with id=101. Before that, we will establish a Java Connection to our MySQL database.
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;
import com.mysql.jdbc.Statement;
public class JavaDeleteDemo {
   public static void main(String[] args) {
       Connection conn = null;
      Statement stmt = null;
       try {
          try {
             Class.forName("com.mysql.jdbc.Driver");
          } catch (Exception e) {
             System.out.println(e);
          }
          conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/business", "Manish", "123456");
          System.out.println("Connection is created successfully:");
          stmt = (Statement) conn.createStatement();
          String query1 = "delete from  DeleteTableDemo " +
          "where id=101";
          stmt.executeUpdate(query1);
          System.out.println("Record is deleted from the table successfully..................");
       } catch (SQLException excep) {
          excep.printStackTrace();
       } catch (Exception excep) {
          excep.printStackTrace();
       } finally {
          try {
             if (stmt != null)
             conn.close();
          } catch (SQLException se) {}
          try {
             if (conn != null)
             conn.close();
          } catch (SQLException se) {
             se.printStackTrace();
          }
       }
       System.out.println("Please check it in the MySQL Table. Record is now deleted.......");
    }
}
The following is the output.
mysql> select *from DeleteTableDemo;
The following is the output.
+------+---------+
| id   | Name |
+------+---------+
| 102  |Johnson |
+------+---------+
1 row in set (0.00 sec) We have deleted the data with id 101.
Batch Script - ATTRIB

Displays or sets the attributes of the files in the current directory
attrib

The following example shows the different variants of the attrib command.
@echo off
Rem Displays the attribites of the file in the current directory
Attrib

Rem Displays the attributes of the file lists.txt
attrib C:\tp\lists.txt

Rem Adds the "Read-only" attribute to the file.
attrib +r C:\tp\lists.txt
Attrib C:\tp\lists.txt

Rem Removes the "Archived" attribute from the file
attrib -a C:\tp\lists.txt
Attrib C:\tp\lists.txt
For example,
A           C:\tp\assoclst.txt
A           C:\tp\List.cmd
A           C:\tp\lists.txt
A           C:\tp\listsA.txt
A           C:\tp\lists.txt
A    R      C:\tp\lists.txt
     R      C:\tp\lists.txt

 Print
 Add Notes
 Bookmark this page
How to avoid the warning “Cannot compute exact p-value with ties” while perform correlation test for Spearman’s correlation in R?

When the variables are not continuous but could be ranked then we do not use pearson correlation coefficient to find the linear relationship, in this case spearman correlation coefficient comes into the scene. Since the spearman correlation coefficient considers the rank of values, the correlation test ignores the same ranks to find the p-values as a result we get the warning “Cannot compute exact p-value with ties”. This can be avoided by using exact = FALSE inside the cor.test function.
Consider the below vectors and perform spearman correlation test to check the relationship between them −
 Live Demo
x1<-rpois(20,2)
y1<-rpois(20,5)
cor.test(x1,y1,method="spearman")
   Spearman's rank correlation rho
data: x1 and y1
S = 1401.7, p-value = 0.8214
alternative hypothesis: true rho is not equal to 0
sample estimates:
   rho
-0.05390585
Warning message:
In cor.test.default(x1, y1, method = "spearman") :
Cannot compute exact p-value with ties
Here, we have the warning for ties, this can be avoided by using exact=FALSE as shown below −
cor.test(x1,y1,method="spearman",exact=FALSE)
   Spearman's rank correlation rho
data: x1 and y1
S = 1401.7, p-value = 0.8214
alternative hypothesis: true rho is not equal to 0
sample estimates:
   rho
-0.05390585
Let’s have a look at some more examples −
 Live Demo
x2<-sample(1:100,500,replace=TRUE)
y2<-sample(1:50,500,replace=TRUE)
cor.test(x2,y2,method="spearman")
   Spearman's rank correlation rho
data: x2 and y2
S = 20110148, p-value = 0.4387
alternative hypothesis: true rho is not equal to 0
sample estimates:
   rho
0.03470902
Warning message:
In cor.test.default(x2, y2, method = "spearman") :
Cannot compute exact p-value with ties
cor.test(x2,y2,method="spearman",exact=FALSE)
   Spearman's rank correlation rho
data: x2 and y2
S = 20110148, p-value = 0.4387
alternative hypothesis: true rho is not equal to 0
sample estimates:
   rho
0.03470902
 Live Demo
x3<-sample(101:110,5000,replace=TRUE)
y3<-sample(501:510,5000,replace=TRUE)
cor.test(x3,y3,method="spearman")
   Spearman's rank correlation rho
data: x3 and y3
S = 2.0642e+10, p-value = 0.5155
alternative hypothesis: true rho is not equal to 0
sample estimates:
   rho
0.009199129
Warning message:
In cor.test.default(x3, y3, method = "spearman") :
Cannot compute exact p-value with ties
cor.test(x3,y3,method="spearman",exact=FALSE)
   Spearman's rank correlation rho
data: x3 and y3
S = 2.0642e+10, p-value = 0.5155
alternative hypothesis: true rho is not equal to 0
sample estimates:
   rho
0.009199129
Python os.chown() Method

Python method chown() changes the owner and group id of path to the numeric uid and gid. To leave one of the ids unchanged, set it to -1.To set ownership, you would need super user privilege..
Following is the syntax for chown() method −
os.chown(path, uid, gid);

path − This is the path for which owner id and group id need to be setup.
path − This is the path for which owner id and group id need to be setup.
uid − This is Owner ID to be set for the file.
uid − This is Owner ID to be set for the file.
gid − This is Group ID to be set for the file.
gid − This is Group ID to be set for the file.
This method does not return any value.
The following example shows the usage of chown() method.
#!/usr/bin/python

import os, sys

# Assuming /tmp/foo.txt exists.
# To set owner ID 100 following has to be done.
os.chown("/tmp/foo.txt", 100, -1)

print "Changed ownership successfully!!"
When we run above program, it produces following result −
Changed ownership successfully!!


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Difference Between Inline and Macro in C++

In this post, we will understand the difference between inline and macro in C++.
It is a function in C++.
It is a function in C++.
It is parsed by the compiler.
It is parsed by the compiler.
It can be defined inside or outside the class.
It can be defined inside or outside the class.
It evaluates the argument only once.
It evaluates the argument only once.
The compiler may not convert all functions to ‘inline’ function and expand them all.
The compiler may not convert all functions to ‘inline’ function and expand them all.
The short functions that are defined inside the class are automatically made as inline functions.
The short functions that are defined inside the class are automatically made as inline functions.
An inline function inside a class can access the data members of the class.
An inline function inside a class can access the data members of the class.
Inline function can be terminated using curly brackets.
Inline function can be terminated using curly brackets.
It is easy to debug.
It is easy to debug.
This is because error checking is done during compilation.
This is because error checking is done during compilation.
It binds all statements in the body of the function.
It binds all statements in the body of the function.
inline return_type funct_name ( parameters ) {
   . . .
}
It is expanded by the preprocessor.
It is expanded by the preprocessor.
It is defined at the beginning of the program.
It is defined at the beginning of the program.
It evaluates the argument every time it is used inside the code.
It evaluates the argument every time it is used inside the code.
They always need to be/are expanded.
They always need to be/are expanded.
They need to be defined specifically.
They need to be defined specifically.
They will never become members of class.
They will never become members of class.
They can’t access data members of the class.
They can’t access data members of the class.
Definition of macro ends with the new line.
Definition of macro ends with the new line.
It is difficult to debug macros since error checking doesn’t happen during compile time.
It is difficult to debug macros since error checking doesn’t happen during compile time.
It encounters binding problem if it contains more than one statement since it doesn’t have a termination symbol.
It encounters binding problem if it contains more than one statement since it doesn’t have a termination symbol.
#define macro_name char_sequence
How can we set a border to JCheckBox in Java?


A JCheckBox is a component that can extend JToggleButton and an object of JCheckBox represents an option that can be checked or unchecked. If there are two or more options then any combination of these options can be selected at the same time. We can set a border to the JCheckBox component by using the setBorder() method and make sure that setBorderPainted() method set to true.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class BorderedJCheckBoxTest extends JFrame {
   private JCheckBox jcb;
   public BorderedJCheckBoxTest() throws Exception {
      setTitle("JCheckBox Test");
      setLayout(new FlowLayout());
      jcb = new JCheckBox("BorderedJCheckBox Test");
      jcb.setBorderPainted(true);
      jcb.setBorder(BorderFactory.createLineBorder(Color.red)); // set the border
      add(jcb);
      setSize(375, 250);
      setLocationRelativeTo(null);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setVisible(true);
   }
   public static void main(String args[]) throws Exception {
      new BorderedJCheckBoxTest();
   }
}
Accessing inner element of JSON array in MongoDB?

To access inner element of JSON array in MongoDB, use dot notation. Let us create a collection with documents −
> db.demo687.insert({CountryName:'US',
... info:
... {
... id:101,
... details:
... [
... {
...    Name:'Chris',
...    SubjectName:'MongoDB',
...    otherDetails:{
...       "Marks":58,
...       Age:23
...    }
... }
... ]
... }
... }
... )
WriteResult({ "nInserted" : 1 })
> db.demo687.insert({CountryName:'UK',
... info:
... {
... id:102,
... details:
... [
... {
...    Name:'David',
...    SubjectName:'MySQL',
...    otherDetails:{
...       "Marks":78,
...       Age:21
...    }
... }
... ]
... }
... }
... )
WriteResult({ "nInserted" : 1 })
Display all documents from a collection with the help of find() method −
> db.demo687.find();
This will produce the following output −
{ "_id" : ObjectId("5ea55658a7e81adc6a0b3962"), "CountryName" : "US", "info" : { "id" : 101, "details" : [ { "Name" : "Chris", "SubjectName" : "MongoDB", "otherDetails" : { "Marks" : 58, "Age" : 23 } } ] } }
{ "_id" : ObjectId("5ea55673a7e81adc6a0b3963"), "CountryName" : "UK", "info" : { "id" : 102, "details" : [ { "Name" : "David", "SubjectName" : "MySQL", "otherDetails" : { "Marks" : 78, "Age" : 21 } } ] } }
Following is the query to access inner element of JSON array −
> db.demo687.find({"info.details.otherDetails.Marks":58});
This will produce the following output −
{ "_id" : ObjectId("5ea55658a7e81adc6a0b3962"), "CountryName" : "US", "info" : { "id" : 101, "details" : [ { "Name" : "Chris", "SubjectName" : "MongoDB", "otherDetails" : { "Marks" : 58, "Age" : 23 } } ] } }
Extracting rows using Pandas .iloc[] in Python

Pandas is a famous python library that Is extensively used for data processing and analysis in python. In this article we will see how to use the .iloc method which is used for reading selective data from python by filtering both rows and columns from the dataframe.
iloc method processes data by using integer based indexes which may or may not be part of the original data set. The first row is assigned index 0 and second and index 1 and so on. Similarly, the first column is index 0 and second is index 1 and so on.
Below is the data set which we are going to use.
Id       SepalLengthCm ...    PetalLengthCm    PetalWidthCm
Iris-setosa-1          5.1 ...                   1.4       0.2
Iris-setosa-2          4.9 ...                   1.4       0.2
Iris-setosa-3          4.7 ...                   1.3       0.2
We can select both a single row and multiple rows by specifying the integer for the index. In the below example we are selecting individual rows at row 0 and row 1.
import pandas as pd

# Create data frame from csv file
data = pd.read_csv("D:\\Iris_readings.csv")

row0 = data.iloc[0]
row1 = data.iloc[1]
print(row0)
print(row1)
Running the above code gives us the following result −
Id       Iris-setosa-1
SepalLengthCm    5.1
SepalWidthCm     3.5
PetalLengthCm    1.4
PetalWidthCm     0.2
Name: 0, dtype: object

Id       Iris-setosa-2
SepalLengthCm    4.9
SepalWidthCm       3
PetalLengthCm    1.4
PetalWidthCm     0.2
Name: 1, dtype: object
In the below example we select many rows together at one shot by mentioning the slice of the rows we need.
import pandas as pd

# making data frame from csv file
data = pd.read_csv("D:\\Iris_readings.csv")

rows = data.iloc[4:8]
print(rows)
Running the above code gives us the following result −
   Id       SepalLengthCm       SepalWidthCm       PetalLengthCm       PetalWidthCm
4          Iris-setosa-5         5.0          3.6             1.4       0.2
5          Iris-versicolor-51    7.0          3.2             4.7       1.4
6          Iris-versicolor-52    6.4          3.2             4.5       1.5
7          Iris-versicolor-53    6.9          3.1             4.9       1.5
In the below example we can select both rows and columns as necessary.
import pandas as pd

# making data frame from csv file
data = pd.read_csv("D:\\Iris_readings.csv")

rows_columns = data.iloc[4:8,0:2]
print(rows_columns)
Running the above code gives us the following result −
      Id           SepalLengthCm
4    Iris-setosa-5         5.0
5    Iris-versicolor-51    7.0
6    Iris-versicolor-52    6.4
7    Iris-versicolor-53    6.9
C# Linq SelectMany Method

Use SelectMany method to collapse elements into a single collection like an error.
An example would be to convert string to character array. The following is our string array.
string[] str = { "Mobile", "Laptop", "Tablet" };
Now, convert to character array.
str.SelectMany(item => item.ToCharArray());
 Live Demo
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
   public static void Main() {
      string[] str = { "Mobile", "Laptop", "Tablet" };
      var res = str.SelectMany(item => item.ToCharArray());
      Console.WriteLine("String converted to character array: ");
      foreach (char letter in res) {
         Console.Write(letter);
      }
   }
}
String converted to character array:
MobileLaptopTablet
Performance of paging - GeeksforGeeks

23 Oct, 2020
In this article, we are going to cover the performance of paging and will also cover the expression for evaluating paging performance. Let’s discuss one by one.
Pre-requisite –Paging in Operating System
Performance of Paging :Evaluating of paging performance is one of the important tasks. Consider the main memory access time is M and the page table is stored in the main memory then the evaluating expression for effective memory access time is as follows.
Effective Memory Access Time (E.M.A.T) = 2M

Features of Performance of Paging :
Translation lookaside buffer(TLB) is added to improve the performance of paging.
The TLB is a hardware device implemented using associative registers.
TLB access time will be very less compared to the main memory access time.
TLB contains frequently referred page numbers and corresponding frame numbers.
Now, let’s see the diagram given below of the performance of paging for a better understanding.
Evaluating Expression for the performance of paging :
Consider the TLB access time is ‘c’. And the TLB hit ratio is ‘x’ then the Evaluating Expression for the performance of paging is as follows.
Effective Memory Access Time (E.M.A.T) with TLB
= x(c+m) + (1-x) (c + 2 m)

Operating Systems-Memory Management
GATE CS
Operating Systems
Operating Systems
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Differences between IPv4 and IPv6
Preemptive and Non-Preemptive Scheduling
Difference between Clustered and Non-clustered index
Phases of a Compiler
Three address code in Compiler
Banker's Algorithm in Operating System
Program for FCFS CPU Scheduling | Set 1
Paging in Operating System
Introduction of Deadlock in Operating System
Program for Round Robin scheduling | Set 1
Python | Numpy matrix.argmax() - GeeksforGeeks

10 Apr, 2019
With the help of Numpy matrix.argmax() method, we are able to find the index value of the maximum element in the given matrix having one or more dimension.
Syntax : matrix.argmax()
Return : Return index number of maximum element in matrix
Example #1 :In this example we can see that with the help of matrix.argmax() method we are able to find the index of maximum element in a given matrix.
# import the important module in pythonimport numpy as np           # make a matrix with numpygfg = np.matrix('[1, 2, 3, 4]')           # applying matrix.argmax() methodgeeks = gfg.argmax()     print(geeks)
3

Example #2 :
# import the important module in pythonimport numpy as np           # make a matrix with numpygfg = np.matrix('[1, 2, 3; 4, 5, 6; 7, 8, 9]')           # applying matrix.argmax() methodgeeks = gfg.argmax()     print(geeks)
8

Python numpy-Matrix Function
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
Reading and Writing to text files in Python
*args and **kwargs in Python
Convert integer to string in Python
Create a Pandas DataFrame from Lists
Check if element exists in list in Python
Type Casting or Type Conversion in Golang - GeeksforGeeks

13 Jul, 2021
Type conversion happens when we assign the value of one data type to another. Statically typed languages like C/C++, Java, provide the support for Implicit Type Conversion but Golang is different, as it doesn’t support the Automatic Type Conversion or Implicit Type Conversion even if the data types are compatible. The reason for this is the Strong Type System of the Golang which doesn’t allow to do this. For type conversion, you must perform explicit conversion. As per Golang Specification, there is no typecasting word or terminology in Golang. If you will try to search Type Casting in Golang Specifications or Documentation, you will find nothing like this. There is only Type Conversion. In Other programming languages, typecasting is also termed as the type conversion.What is the need for Type Conversion? Well, if you need to take advantage of certain characteristics of data type hierarchies, then we have to change entities from one data type into another. The general syntax for converting a value val to a type T is T(val). Example: 
var geek1 int = 845

// explicit type conversion
var geek2 float64 = float64(geek1)

var geek3 int64 = int64(geek1)

var geek4 uint = uint(geek1)
 
C
// Go program to find the// average of numberspackage main import "fmt" func main() {     // taking the required    // data into variables    var totalsum int = 846    var number int = 19    var avg float32     // explicit type conversion    avg = float32(totalsum) / float32(number)     // Displaying the result    fmt.Printf("Average = %f\n", avg)}
Output: 
Average = 44.526318
Note: As Golang has a strong type system, it doesn’t allow to mix(like addition, subtraction, multiplication, division, etc.) the numeric types in the expressions and also you are not allowed to perform an assignment between the two mixed types.Example: 
var geek1 int64 = 875

// it will give compile time error as we
// are performing an assignment between
// mixed types i.e. int64 as int type
var geek2 int = geek1

var geek3 int = 100

// it gives compile time error
// as this is invalid operation
// because types are mix i.e.
// int64 and int
var addition = geek1 + geek3
 
surindertarika1234
Go-Basics
Golang
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
6 Best Books to Learn Go Programming Language
Arrays in Go
How to Split a String in Golang?
Golang Maps
Slices in Golang
Different Ways to Find the Type of Variable in Golang
Inheritance in GoLang
Interfaces in Golang
How to Trim a String in Golang?
How to compare times in Golang?
Teradata - Compression

Compression is used to reduce the storage used by the tables. In Teradata, compression can compress up to 255 distinct values including NULL. Since the storage is reduced, Teradata can store more records in a block. This results in improved query response time since any I/O operation can process more rows per block. Compression can be added at table creation using CREATE TABLE or after table creation using ALTER TABLE command.
Only 255 values can be compressed per column.
Primary Index column cannot be compressed.
Volatile tables cannot be compressed.
The following table compresses the field DepatmentNo for values 1, 2 and 3. When compression is applied on a column, the values for this column is not stored with the row. Instead the values are stored in the Table header in each AMP and only presence bits are added to the row to indicate the value.
CREATE SET TABLE employee ( 
   EmployeeNo integer, 
   FirstName CHAR(30), 
   LastName CHAR(30), 
   BirthDate DATE FORMAT 'YYYY-MM-DD-', 
   JoinedDate DATE FORMAT 'YYYY-MM-DD-', 
   employee_gender CHAR(1), 
   DepartmentNo CHAR(02) COMPRESS(1,2,3) 
) 
UNIQUE PRIMARY INDEX(EmployeeNo);
Multi-Value compression can be used when you have a column in a large table with finite values.
Node.js forEach() function

13 Oct, 2021
forEach() is an array function from Node.js that is used to iterate over items in a given array.
Syntax:
array_name.forEach(function)
Parameter: This function takes a function (which is to be executed) as a parameter.
Return type: The function returns array element after iteration.
The program below demonstrates the working of the function:
Program 1:
const arr = ['cat', 'dog', 'fish'];arr.forEach(element => {  console.log(element);});
Output:
cat
dog
fish
Program 2:
const arr = [1, 2, 3, 8, 7];arr.forEach(element => {  console.log(element);});
Output:
1
2
3
8
7
NodeJS-function
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between promise and async await in Node.js
Mongoose | findByIdAndUpdate() Function
JWT Authentication with Node.js
Installation of Node.js on Windows
Difference between dependencies, devDependencies and peerDependencies
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
Python Program to get all unique keys from a List of Dictionaries

22 Mar, 2021
Given a list arr[] consisting of N dictionaries, the task is to find the sum of unique keys from the given list of the dictionary.
Examples:
Input: arr = [{‘my’: 1, ‘name’: 2}, {‘is’: 1, ‘my’: 3}, {‘ria’: 2}]Output: [‘ria’, ‘my’, ‘is’, ‘name’]Explanation: The set of unique keys are {“ria”, “my”, “Is”, “name”}.
Input: arr = [{‘X’: 100, ‘Y’: 2}, {‘Z’: 1, ‘Z’: 30}, {‘X’: 21}]Output: [‘Z’, ‘X’, ‘Y’]Explanation: The set of unique keys are {“X”, “Y”, “Z”}.
Approach using Chain iterable tools: The problem can be solved using set() and keys() methods and chain iterable tools to solve the above problem.
Follow the steps below to solve the problem:
Traverse all keys of every dictionary using chain iterable tools
Store the set of keys in a list, say res.
Print the list res as the required answer.
Below is the implementation of the above approach:
Python3
# Python3 program for the above approachfrom itertools import chain    # Function to print all unique keys# present in a list of dictionariesdef UniqueKeys(arr):      # Stores the list of unique keys    res = list(set(chain.from_iterable(sub.keys() for sub in arr)))      # Print the list    print(str(res))  # Driver Codearr = [{'my': 1, 'name': 2},        {'is': 1, 'my': 3},       {'ria': 2}]UniqueKeys(arr)
['is', 'ria', 'my', 'name']

Time Complexity: O(N * maxm), where maxm denotes the size of the longest dictionary.Auxiliary Space: O(N * maxm)
Approach using List Comprehension and Dictionary Comprehension: The problem can be solved alternately using set() and keys() method and list comprehension and dictionary comprehension to solve the problem.
Follow the steps below to solve the problem:
Traverse all the keys of every dictionary using List Comprehension and Dictionary Comprehension and then store the set of keys in a list, say res.
Print the list res as the required answer.
Below is the implementation of the above approach:
Python3
# Python3 program for the above approach  from itertools import chain  # Function to print all unique keys# from a list of dictionariesdef UniqueKeys(arr):      # Stores the list of unique keys    res = list(set(val for dic in arr for val in dic.keys()))      # Print the list    print(str(res))  # Driver Code  # Inputarr = [{'my': 1, 'name': 2},        {'is': 1, 'my': 3},       {'ria': 2}]  UniqueKeys(arr)
['ria', 'my', 'name', 'is']

Time Complexity: O(N * maxm), where maxm denotes the size of the longest dictionary.Auxiliary Space: O(N * maxm)
Python dictionary-programs
Python list-programs
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Shut Down a Computer using Command Prompt?

01 Oct, 2020
Sometimes, situations might arise due to either a windows bug or some malicious program that start menu tray won’t open even on the press, leaving us with only forcing the desktop or laptop to shut down by either long pressing the power button or cutting off the power supply of the device.
To overcome such a situation, there are various efficient least time-consuming methods of shutdown, here in this article we will show you one of such ways to shutdown a computer in multiple ways. Go through the following command and save that as a .bat file. This .bat on getting executed (by a simple double click or other methods) should initiate the shutdown process.
Open Command Prompt (cmd) and type:
shutdown /s

or,
shutdown -s

The above command will schedule a shutdown, the Windows machine should be scheduled to shutdown within a minute of executing this command.  It should look something like this:
After execution of this command, you would see something similar like this:
Canceling the Shutdown:
To cancel a scheduled shutdown via this method simply type:
shutdown /a

or,
shutdown -a

Remote Shutdown:
The remote shutdown of a computer (GUI aided) in network can be done with the help of the following command:
shutdown /i

or,
shutdown -i

Shutdown commands with additional parameters:
You can save the above code as a .bat file, and execute it instead of always clicking start > power > shutdown. Save with -t 00 parameter, so that the shutdown is instantaneous. Basically type & save:
shutdown -s -t 00
To have a windows machine shutdown after a custom set time, type:
shutdown -s -t 900

 ( -t is superseded by time in seconds, for example, if we want an immediate shutdown, we can write: shutdown -s -t 00. Also, as stated above, you can just as easily cancel a scheduled shutdown or restart like this by typing, shutdown -a )
To have the windows machine restart instead of shutdown, type:
shutdown -r

(you can have -t and other parameters in this command. Type shutdown /? for more information on other available parameters)
Additional Note:
For instant and most efficient shutdown process, open any text editor software, namely notepad (comes in-built with windows) and write:
shutdown -s -t 00

and then save the file with .bat extension. Now simply execute this .bat file to initiate an instantaneous shutdown.
How To
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Set Git Username and Password in GitBash?
How to Install Jupyter Notebook on MacOS?
How to Install and Use NVM on Windows?
How to Install Python Packages for AWS Lambda Layers?
How to Install Git in VS Code?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Create and Setup Spring Boot Project in Eclipse IDE?
How to Set Upstream Branch on Git?
How to Install Flutter on Visual Studio Code?
How to Permanently Disable Swap in Linux?
HTML | <base> href Attribute

30 Mar, 2022
The HTML | <base> href Attribute is used to specify the base URL for all the relative URL of a page.
Syntax:
<base href="URL">
Attribute Values: It contains the value i.e URL which specifies the absolute URL that defines the base URL of the page. for eg.”www.geeksforgeeks.org”
Example: This Example illustrates the use of href attribute in element.
<!DOCTYPE html><html>  <head>    <!-- Declaring the BASE URL -->    <base href="https://media.geeksforgeeks.org/wp-content/uploads/"           target="_blank"></head><h1>GeeksForGeeks</h1><h2>  HTML | <base>href Attribute  </h2>  <body>    <img src="1-95.jpg"         width="400"         height="250"></body>  </html>
Output:
Supported Browsers: The browser supported by HTML | <base> href Attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Opera
Safari
shubham_singh
chhabradhanvi
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
Design a Tribute Page using HTML & CSS
Build a Survey Form using HTML and CSS
Angular File Upload
Design a web page using HTML and CSS
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
jQuery Effect - Scale Effect

The Scale effect can be used with show/hide/toggle. This shrinks or grows an element by a percentage factor.
Here is the simple syntax to use this effect −
selector.hide|show|toggle( "scale", {arguments}, speed );

Here is the description of all the arguments −
direction − The direction of the effect. Can be "both", "vertical" or "horizontal". Default is both.
direction − The direction of the effect. Can be "both", "vertical" or "horizontal". Default is both.
from − The state at beginning, usually not needed. This would be an object and would be given in the form of { height: .., width: .. }.
from − The state at beginning, usually not needed. This would be an object and would be given in the form of { height: .., width: .. }.
origin − The vanishing point. This is an array and by default set to ['middle','center'].
origin − The vanishing point. This is an array and by default set to ['middle','center'].
percent − The percentage to scale to, number. Default is 0/100.
percent − The percentage to scale to, number. Default is 0/100.
scale − Which areas of the element will be resized: 'both', 'box', 'content' Box resizes the border and padding of the element Content resizes any content inside of the element. Default is both.
scale − Which areas of the element will be resized: 'both', 'box', 'content' Box resizes the border and padding of the element Content resizes any content inside of the element. Default is both.
Following is a simple example a simple showing the usage of this effect −
<html>
   <head>
      <title>The jQuery Example</title>
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
		
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js">
      </script>
		
      <script type = "text/javascript" language = "javascript">
   
         $(document).ready(function() {

            $("#hide").click(function(){
               $(".target").hide( "scale", {percent: 200, direction: 'horizontal'}, 2000 );
            });

            $("#show").click(function(){
               $(".target").show( "scale", {percent: 200, direction: 'vertical' }, 2000 );
            });
				
         });
			
      </script>
		
      <style>
         p {background-color:#bca; width:200px; border:1px solid green;}
         div{ width:100px; height:100px; background:red;}
      </style>
   </head>
	
   <body>
      <p>Click on any of the buttons</p>
		
      <button id = "hide"> Hide </button>
      <button id = "show"> Show</button> 
  
      <div class = "target">
      </div>
   </body>
</html>
This will produce following result −
Click on any of the buttons

    27 Lectures 
     1 hours 

 Mahesh Kumar

    27 Lectures 
     1.5 hours 

 Pratik Singh

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    60 Lectures 
     9 hours 

 Eduonix Learning Solutions

    17 Lectures 
     2 hours 

 Sandip Bhattacharya

    12 Lectures 
     53 mins

 Laurence Svekis
 Print
 Add Notes
 Bookmark this page
Find and display duplicate records in MySQL?

First, a table is created with the help of the CREATE command. This is given as follows −
mysql> CREATE table DuplicateFound
-> (
-> ID int,
-> Name varchar(100),
-> Location varchar(200)
-> );
Query OK, 0 rows affected (0.45 sec)
After creating the table, the records are inserted with the help of the INSERT command as
follows −
mysql> INSERT into DuplicateFound values(1,'John','US');
Query OK, 1 row affected (0.10 sec)

mysql> INSERT into DuplicateFound values(2,'Bob','UK');
Query OK, 1 row affected (0.18 sec)

mysql> INSERT into DuplicateFound values(3,'David','US');
Query OK, 1 row affected (0.14 sec)

mysql> INSERT into DuplicateFound values(4,'Smith','US');
Query OK, 1 row affected (0.16 sec)

mysql> INSERT into DuplicateFound values(5,'Carol','UK');
Query OK, 1 row affected (0.16 sec)
The records are displayed with the help of the SELECT statement. This is given below −
mysql> SELECT * from DuplicateFound;

The following is the output obtained −
+------+-------+----------+
| ID   | Name  | Location |
+------+-------+----------+
| 1    | John  | US       |
| 2    | Bob   | UK       |
| 3    | David | US       |
| 4    | Smith | US       |
| 5    | Carol | UK       |
+------+-------+----------+
5 rows in set (0.00 sec)
The query to find and display the duplicate records together is given as follows −
mysql> SELECT * from DuplicateFound
-> where location in (select location from DuplicateFound group by location having count(location) >1 )
-> order by location;
The following is the output obtained
+------+-------+----------+
| ID   | Name  | Location |
+------+-------+----------+
| 2    | Bob   | UK       |
| 5    | Carol | UK       |
| 1    | John  | US       |
| 3    | David | US       |
| 4    | Smith | US       |
+------+-------+----------+
5 rows in set (0.06 sec)
We can display those records which belong to a single location. This is given as follows −
mysql> select Name,location from DuplicateFound
-> group by location
-> having count(location) > 1;
The following is the output
+------+----------+
| Name | Location |
+------+----------+
| John | US       |
| Bob   | UK      |
+------+----------+
2 rows in set (0.04 sec)