code-rag-bench/online-tutorials huggingface dataset:
How to Avoid Overlapping Labels in ggplot2 in R? - GeeksforGeeks

18 Oct, 2021
In this article, we are going to see how to avoid overlapping labels in ggplot2 in R Programming Language.
To avoid overlapping labels in ggplot2, we use guide_axis() within scale_x_discrete().
Syntax: plot+scale_x_discrete(guide = guide_axis(<type>))
In the place of we can use the following properties:
n.dodge: It makes overlapping labels shift a step-down.
check.overlap: This removes the overlapping labels and displays only those which do not overlap
R
# Create sample dataset.seed(5642)                            sample_data <- data.frame(name = c("Geeksforgeeks1",                                   "Geeksforgeeks2",                                   "Geeksforgeeks3",                                   "Geeksforgeeks4",                                   "Geeeksforgeeks5") ,                          value = c(31,12,15,28,45))# Load ggplot2 packagelibrary("ggplot2") # Create bar plotplot<-ggplot(sample_data, aes(name,value, fill=name)) +geom_bar(stat = "identity")plot
 
 
Output:
 
 
To avoid overlapping by shifting labels downward we use n.dodge parameter of guide_axis() function:
 
R
# Create sample dataset.seed(5642)                            sample_data <- data.frame(name = c("Geeksforgeeks1",                                   "Geeksforgeeks2",                                   "Geeksforgeeks3",                                   "Geeksforgeeks4",                                   "Geeeksforgeeks5") ,                          value = c(31,12,15,28,45))# Load ggplot2 packagelibrary("ggplot2") # Create bar plot without overlapping labelsplot<-ggplot(sample_data, aes(name,value, fill=name)) +geom_bar(stat = "identity") +scale_x_discrete(guide = guide_axis(n.dodge=2))plot
 
 
Output:
 
 
To remove overlapping labels we use check.overlap parameter of guide_axis() function:
 
R
# Create sample dataset.seed(5642)                            sample_data <- data.frame(name = c("Geeksforgeeks1",                                   "Geeksforgeeks2",                                   "Geeksforgeeks3",                                   "Geeksforgeeks4",                                   "Geeeksforgeeks5") ,                          value = c(31,12,15,28,45))# Load ggplot2 packagelibrary("ggplot2") # Create bar plot without overlapping labelsplot<-ggplot(sample_data, aes(name,value, fill=name)) +geom_bar(stat = "identity") +scale_x_discrete(guide = guide_axis(check.overlap = TRUE))plot
 
 
Output:
 
 
abhishek0719kadiyan
Picked
R-ggplot
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
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?
How to import an Excel File into R ?
Time Series Analysis in R
How to filter R dataframe by multiple conditions?
Replace Specific Characters in String in R
R - if statement
How to style background image to no repeat with JavaScript DOM?

To style the background image to no repeat with JavaScript, use the backgroundRepeat property. It allows you to set whether the background image repeats or not on a page.
You can try to run the following code to learn how to style background image to no repeat with JavaScript −
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <button onclick="display()">Click to Set background image</button>
      <script>
         function display() {
            document.body.style.backgroundImage = "url('https://www.tutorialspoint.com/html5/images/html5-mini-logo.jpg')";
            document.body.style.backgroundRepeat = "no-repeat";
         }
      </script>
   </body>
</html>
MySQL Select where value exists more than once

For this, you can use GROUP BY HAVING along with the COUNT(*) function. Let us first create a table −
mysql> create table DemoTable
   -> (
   -> Value int
   -> );
Query OK, 0 rows affected (0.47 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(20);
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable values(10);
Query OK, 1 row affected (0.08 sec)
mysql> insert into DemoTable values(30);
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable values(10);
Query OK, 1 row affected (0.16 sec)
mysql> insert into DemoTable values(30);
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable values(40);
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable values(50);
Query OK, 1 row affected (0.27 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------+
| Value |
+-------+
|    20 |
|    10 |
|    30 |
|    10 |
|    30 |
|    40 |
|    50 |
+-------+
7 rows in set (0.00 sec)
Following is the query to select where value exists more than once −
mysql> select *from DemoTable
   -> group by Value
   -> having count(*) > 1;
This will produce the following output −
+-------+
| Value |
+-------+
|    10 |
|    30 |
+-------+
2 rows in set (0.38 sec)
How to Find Factorial of Number Using Recursion in Python?

Factorial of a number is product of all numbers from 1 to that number.
A function is called a recursive function if it calls itself.
In following program factorial() function accepts one argument and keeps calling itself by reducing value by one till it reaches 1.
def factorial(x):
    if x==1:
        return 1
    else:
        return x*factorial(x-1)

f=factorial(5)
print ("factorial of 5 is ",f)
The result is
factorial of 5 is  120
Bootstrap checkbox class

When building a form, use the checkbox class if you want the user to select any number of options from a list. Use .checkbox-inline class to a series of checkboxes for controls appear on the same line.
You can try to run the following code to implement the Bootstrap checkbox class −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Try v1.2 Bootstrap Online</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <label for = "name">Favourite Live Streaming</label>
      <div class = "checkbox">
         <label>
            <input type = "checkbox" value = "">Amazon Prime
         </label>
      </div>
      <div class = "checkbox">
         <label>
            <input type = "checkbox" value = "">Hotstar
         </label>
      </div>
   </body>
</html>
time.LoadLocation() Function in Golang With Examples - GeeksforGeeks

21 Apr, 2020
In Go language, time packages supplies functionality for determining as well as viewing time. The LoadLocation() function in Go language is used to find a location with the name stated. So, if the stated name is “UTC” then it returns UTC and if the stated name is “Local” then it returns Local. Else, the name to be used is assumed to be a location which is equivalent to a file in the database of IANA Time Zone. Where this database is present only on Unix systems. Moreover, this function is defined under the time package. Here, you need to import the “time” package in order to use these functions.
Syntax:
func LoadLocation(name string) (*Location, error)

Here, “name” is the name of the location to be used, and *Location is the pointer to the Location. Where “Location” forms the set of time offsets in use. And “error” is a panic error.
Return Value: It returns the location with the stated name.
Example 1:
// Golang program to illustrate the usage of// LoadLocation() function  // Including main packagepackage main  // Importing fmt and timeimport (    "fmt"    "time")  // Calling mainfunc main() {      // Calling LoadLocation    // method with its parameter    locat, error := time.LoadLocation("Asia/Kolkata")      // If error not equal to nil then    // return panic error    if error != nil {        panic(error)    }      // Prints location    fmt.Println(locat)}
Output:
Asia/Kolkata

Here, IANA time zone of India is returned as there is no error.
Example 2:
// Golang program to illustrate the usage of// LoadLocation() function  // Including main packagepackage main  // Importing fmt and timeimport (    "fmt"    "time")  // Calling mainfunc main() {      // Calling LoadLocation     // method with its parameter    locat, error := time.LoadLocation("Asia/Kolkata")      // If error not     // equal to nil then    // return panic error    if error != nil {        panic(error)    }      // Calling Date() method     // with its parameter    tm := time.Date(2020, 4, 7, 16,                 7, 0, 0, time.UTC)      // Prints the time and date    // of the stated location    fmt.Println(tm.In(locat))}
Output:
2020-04-07 21:37:00 +0530 IST

Here, at first LoadLocation() method is called then the Date() method is called with its parameters i.e, date and time then the date and time of the stated location are returned.
GoLang-time
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
strings.Replace() Function in Golang With Examples
fmt.Sprintf() Function in Golang With Examples
How to Split a String in Golang?
Golang Maps
Slices in Golang
Inheritance in GoLang
Different Ways to Find the Type of Variable in Golang
Interfaces in Golang
PyQt5 - Adding action to Radio Button - GeeksforGeeks

22 Apr, 2020
In this article we will see how we can set action to a radio button. Setting action to a radio button means adding an action to it which get called and perform some task when radio button get checked or unchecked.
In order to add action to radio button we will use toggled.connect method.
Syntax : radio_button.toggled.connect(method_name)
Argument : It takes method name as argument.
Action performed : It will call the method associated with it when radio button will be toggled.
Below is the implementation.
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 600, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()      # method for widgets    def UiComponents(self):          # creating a radio button        self.radio_button = QRadioButton(self)          # setting geometry of radio button        self.radio_button.setGeometry(200, 150, 120, 40)          # setting text to radio button        self.radio_button.setText("GEEK ?")          # creating label to display if it is checked or not        self.label = QLabel("", self)          # setting geometry of label        self.label.setGeometry(200, 200, 150, 40)          # adding action to radio button        self.radio_button.toggled.connect(self.action)      # method called by radio button    def action(self):          # changing the content of label        self.label.setText("Action performed")    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
HTML autocapitalize Attribute - GeeksforGeeks

14 Nov, 2021
The HTML autocapitalize attribute is used to define whether the text present inside the HTML element should be automatically capitalized or not. It is a global attribute that means it is applied to all HTML elements.
Features:
It specifies how the text will be automatically capitalized.
It indicates that the first letter of the word or sentence would be in Capital.
It does not support <input> tag with type URL, Email, and Password.
It is a Global Attribute.
Syntax:
<tag_name autocapitalize="off | none | on 
          | sentences | words | characters" />
 
Attribute Values:
off/none: It defines that the text will not be capitalized.
on/sentences: It defines that the first letter of each sentence would be capital.
words: It defines that the first letter of each word would be capital.
characters: It specifies that the whole text will be capitalized.
Example: Below HTML code use the auto-capitalize attribute with the <input> Tag.  
HTML
<!DOCTYPE html><html>  <head>    <title>        HTML | autocapitalize Attribute      <input>    </title></head>  <body style="text-align:center">      <h1 style="color: green;">        GeeksforGeeks    </h1>      <h2>        HTML | autocapitalize Attribute         with <input> Tag    </h2>       Name:    <input type="text" autocapitalize="words" autofocus>    <br><br>      <!-- Assign id to the Button. -->    <button id="GFG">        Submit    </button>    <br></body>  </html>
Output:
Important Note: This code is working on virtual keyboards such as on mobile devices and voice inputs. It is not working on physical keyboards.
Supported Browsers:
Google Chrome 43.0
Apple Safari 5.0
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Attributes
Picked
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
HTML Cheat Sheet - A Basic Guide to HTML
Design a web page using HTML and CSS
Form validation using jQuery
Angular File Upload
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
OSI, TCP/IP and Hybrid models - GeeksforGeeks

03 Nov, 2021
OSI model: Developed by International Organization for Standardization or ISO, Open Systems Interconnection model or OSI model is a critical building block in networking. It helps in troubleshooting and understanding networks because of the layered approach that it follows; the various layers being:  
(i) Physical layer
(i) Data Link layer
(ii) Network layer
(iii) Transport layer
(iv) Session layer
(v) Presentation layer
(vi) Application layer 
These layers are given bottom to up as following below. 
 
Advantages: 
Provides standards and interoperability.
Split development(a person working in layer 3 need not be concerned with layer 7).
Quicker development (as each layer is independent of the other, development in an OSI model is faster as compared to the old proprietary models). 
TCP/IP model: OSI model was used for connectionless protocols like CLNS and CLMNP; but with the advent of TCP (connection oriented protocol) a new model; i.e., TCP/IP model came into play. In this model, the Application, Presentation and Session layers of OSI model were combined to form the Application layer in the TCP/IP model and the Datalink and Physical layers in the OSI model were combined to form the Network access layer in the TCP/IP model and the Internet layer in the TCP/IP model was the equivalent of Network layer in OSI model. 
 
Advantages:
TCP/IP supports various Network Routing Protocols.
It is scalable and based on client-server architecture.
It is an open protocol suite i.e., it’s not proprietary, so anyone can use it.
TCP/IP works independently of the OS.
Hybrid model: In the real world, we use a mix of both the OSI model and the TCP/IP model, called the Hybrid model. In the Hybrid model, the Application layer is a combination of layer 7, layer 6 and layer 5 of OSI model (similar to TCP/IP model). The remaining layers (layer 1, 2, 3 and 4) are the same as the OSI model. 
 
 
kmbh
Computer Networks
GATE CS
Computer Networks
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Advanced Encryption Standard (AES)
Intrusion Detection System (IDS)
Introduction and IPv4 Datagram Header
Secure Socket Layer (SSL)
Cryptography and its Types
ACID Properties in DBMS
Types of Operating Systems
Normal Forms in DBMS
Page Replacement Algorithms in Operating Systems
Cache Memory in Computer Organization
GATE | GATE-CS-2017 (Set 1) | Question 32 - GeeksforGeeks

28 Jun, 2021
The n-bit fixed-point representation of an unsigned real number X uses f bits for the fraction part. Let i = n – f. The range of decimal values for X in this representation is
(A) 2-f(B) 2-f to ( 2i – 2 -f)(C) 0 to 2-i(D) 0 to 2i – 2 -f)Answer: (D)Explanation: Since given number is in unsigned bit representation, its decimal value starts with 0.We have i bit in integral part so maximum value will be 2iThus integral value will be from 0 to 2i – 1We know fraction part of binary representation are calculated as (1/0)*2-fThus with f bit maximum number possible = sum of GP series with a = 1/2 and r = 1/2
Thus fmax = {1/2(1 – (1/2)f}/(1 – 1/2)
                = 1 – 2-f
Thus maximum fractional value possible = 2i – 1 + (1 – 2-f )
                                       = 2i - 2-f


This solution is contributed by Abhishek Kumar.Quiz of this Question
GATE-CS-2017 (Set 1)
GATE-GATE-CS-2017 (Set 1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE MOCK 2017 | Question 24
GATE | GATE-CS-2006 | Question 47
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
How to change SVG color ? - GeeksforGeeks

19 May, 2020
What is SVG Element?SVG stands for Scalable Vector Graphics is a vector image format for two-dimensional graphics that can be used to create the animations and the SVG element is a container that defines a new coordinate system. The SVG document is defined by the XML format.
Significance of SVG documents: In today’s world, it is SVG that had made browser animations easier and handy. It is used in making 2D animations and graphics. An SVG document can be used to create 2D games in an HTML document. It has different methods to draw lines, shapes such as circle, rectangle, and paths, etc. It is resolution independent and also supports event handling in the document.
Syntax:
<svg></svg>
Example 1: In this example, we will use SVG element to draw a rectangle and color it.
<!DOCTYPE html><html>  <head>    <meta charset="utf-8">    <meta http-equiv="X-UA-Compatible"        content="IE=edge">      <meta name="viewport" content=        "width=device-width, initial-scale=1">      <title>        How to change SVG color?    </title></head>  <body style="text-align: center;">      <h1 style="color: green;">        GeeksforGeeks    </h1>      <div>        <svg>            <rect height="300" width="500"                style="fill:#060">        </svg>    </div></body>  </html>
Output:
Example 2: In this example, we will use SVG element to draw a rectangle and color it.
<!DOCTYPE html><html>  <head>    <meta charset="utf-8">    <meta http-equiv="X-UA-Compatible"         content="IE=edge">      <meta name="viewport" content=        "width=device-width, initial-scale=1">      <title>        How to change SVG color?    </title></head>  <body style="text-align: center;">      <h1 style="color: green;">        GeeksforGeeks    </h1>      <div>        <svg height="1000" width="500">            <circle cx="250" cy="120" r="80"                stroke="#000" stroke-width="5"                 style="fill:#060">        </svg>    </div></body>  </html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Misc
Picked
HTML
Web Technologies
Web technologies Questions
HTML
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 ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
SELECT Operation in Relational Algebra - GeeksforGeeks

27 May, 2020
Prerequisite – Relational AlgebraSelect operation chooses the subset of tuples from the relation that satisfies the given condition mentioned in the syntax of selection. The selection operation is also known as horizontal partitioning since it partitions the table or relation horizontally.
Notation:
σ c(R)
where ‘c’ is selection condition which is a boolean expression(condition), we can have a single condition like Roll= 3 or combination of condition like X>2 AND Y<1,symbol ‘σ (sigma)’ is used to denote select(choose) operator,
R is a relational algebra expression, whose result is a relation. The boolean expression specified in condition ‘c’ can be written in the following form:
<attribute name> <comparison operator> <constant value> or <attribute name>
where, <attribute name> is obviously name of an attribute of relation,
<comparison operator> is any of the operator {<, >, =, <=, >=, !=} and,<constant value> is constant value taken from the domain of the relation. 
Example-1:
σ Place = 'Mumbai' or Salary >= 1000000 (Citizen)
σ Department = 'Analytics'(σLocation = 'NewYork'(Manager))
The query above(immediate) is called nested expression, here, as usual, we evaluate the inner expression first (which results in relation say Manager1), then we calculate the outer expression on Manager1(the relation we obtained from evaluating the inner expression), which results in relation again, which is an instance of a relation we input.
Example-2:
Given a relation Student(Roll, Name, Class, Fees, Team) with the following tuples:
Select all the student of Team A :
σ Team = 'A' (Student)
Select all the students of department ECE whose fees is greater then equal to 10000 and belongs to Team other than A.
σ Fees >= 10000(σClass != 'A' (Student))
Important points about Select operation :Select operator is Unary, means it it applied to single relation only. Selection operation is commutative that is,
σ c1(σ c2(R)) = σ c2(σ c1(R))
The degree (number of attributes) of resulting relation from a Selection operation is same as the degree of the Relation given. The cardinality (number of tuples) of resulting relation from a Selection operation is,
0 <= σ c (R) <= |R|
DBMS-Relational Algebra
DBMS
GATE CS
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL Interview Questions
CTE in SQL
SQL Trigger | Student Database
Introduction of B-Tree
Difference between Clustered and Non-clustered index
Layers of OSI Model
TCP/IP Model
Types of Operating Systems
Page Replacement Algorithms in Operating Systems
Differences between TCP and UDP
Write a Python program to trim the minimum and maximum threshold value in a dataframe

Assume, you have a dataframe and the result for trim of minimum and the maximum threshold value,
minimum threshold:
   Column1 Column2
0    30    30
1    34    30
2    56    30
3    78    50
4    30    90
maximum threshold:
   Column1 Column2
0    12    23
1    34    30
2    50    25
3    50    50
4    28    50
clipped dataframe is:
   Column1 Column2
0    30    30
1    34    30
2    50    30
3    50    50
4    30    50
To solve this, we will follow the steps given below −
Define a dataframe
Define a dataframe
Apply df.clip function inside (lower=30) to calculate minimum threshold value,
Apply df.clip function inside (lower=30) to calculate minimum threshold value,
df.clip(lower=30)
Apply df.clip function inside (upper=50) to calculate maximum threshold value
Apply df.clip function inside (upper=50) to calculate maximum threshold value
df.clip(upper=50)
Apply clipped dataframe with min and max threshold limit as,
Apply clipped dataframe with min and max threshold limit as,
df.clip(lower=30,upper=50)
Let’s check the following code to get a better understanding −
import pandas as pd
data = {"Column1":[12,34,56,78,28],
         "Column2":[23,30,25,50,90]}
df = pd.DataFrame(data)
print("DataFrame is:\n",df)
print("minimum threshold:\n",df.clip(lower=30))
print("maximum threshold:\n",df.clip(upper=50))
print("clipped dataframe is:\n",df.clip(lower=30,upper=50))
DataFrame is:
   Column1 Column2
0    12    23
1    34    30
2    56    25
3    78    50
4    28    90
minimum threshold:
   Column1 Column2
0    30    30
1    34    30
2    56    30
3    78    50
4    30    90
maximum threshold:
   Column1 Column2
0    12    23
1    34    30
2    50    25
3    50    50
4    28    50
clipped dataframe is:
   Column1 Column2
0    30    30
1    34    30
2    50    30
3    50    50
4    30    50
How can we fetch alternate odd numbered records from MySQL table?

To understand this concept, we are using the data from table ‘Information’ as follows −
mysql> Select * from Information;
+----+---------+
| id | Name    |
+----+---------+
| 1  | Gaurav  |
| 2  | Ram     |
| 3  | Rahul   |
| 4  | Aarav   |
| 5  | Aryan   |
| 6  | Krishan |
+----+---------+
6 rows in set (0.00 sec)
Now, the query below will fetch the alternate odd-numbered records from the above table ‘Information’ −
mysql> Select id,Name from information group by id having mod(id,2) = 1;
+----+--------+
| id | Name   |
+----+--------+
| 1  | Gaurav |
| 3  | Rahul  |
| 5  | Aryan  |
+----+--------+
3 rows in set (0.09 sec)
Jackson - JsonGenerator Class

JsonGenerator is the base class to define class that defines public API for writing JSON content. Instances are created using factory methods of a JsonFactory instance.
Following is the declaration for com.fasterxml.jackson.core.JsonGenerator class:
public abstract class JsonGenerator
   extends Object
      implements Closeable, Flushable, Versioned
protected PrettyPrinter _cfgPrettyPrinter  - Object that handles pretty-printing (usually additional white space to make results more human-readable) during output.
protected PrettyPrinter _cfgPrettyPrinter  - Object that handles pretty-printing (usually additional white space to make results more human-readable) during output.
This class inherits methods from the following classes:
java.lang.Object
java.lang.Object
 Print
 Add Notes
 Bookmark this page
What are JSTL formatting tags in JSP?

The JSTL formatting tags are used to format and display text, the date, the time, and numbers for internationalized Websites. Following is the syntax to include Formatting library in your JSP −
<%@ taglib prefix = "fmt" uri = "http://java.sun.com/jsp/jstl/fmt" %>
Following table lists out the Formatting JSTL Tags −
How to catch exceptions in JavaScript?

To catch exceptions in JavaScript, use try...catch...finally. JavaScript implements the try...catch...finally construct as well as the throw operator to handle exceptions.
You can catch programmer-generated and runtime exceptions, but you cannot catch JavaScript syntax errors.
You can try to run the following code to learn how to catch exceptions in JavaScript −
 Live Demo
<html>
   <head>
      <script>
         <!--
            function myFunc() {
               var a = 100;
               try {
                  alert("Value of variable a is : " + a );
               }
               catch ( e ) {
                  alert("Error: " + e.description );
               }
               finally {
                  alert("Finally block will always execute!" );
               }
            }
         //-->
      </script>
   </head>

   <body>
      <p>Click the following to see the result:</p>

      <form>
         <input type = "button" value = "Click Me" onclick = "myFunc();" />
      </form>
   </body>
</html>
Split keys and values into separate objects - JavaScript

Suppose, we have an object like this −
const dataset = {
   "diamonds":77,
   "gold-bars":28,
   "exciting-stuff":52,
   "oil":51,
   "sports-cars":7,
   "bitcoins":40
};
We are required to write a JavaScript function that takes one such object and returns an array of objects that have keys and their values splitted.
Therefore, for the above object, the output should be −
const output = [
   {"asset":"diamonds", "quantity":77},
   {"asset":"gold-bars", "quantity":28},
   {"asset":"exciting-stuff", "quantity":52},
   {"asset":"oil", "quantity":51},
   {"asset":"bitcoins", "quantity":40}
];
Following is the code −
const dataset = {
   "diamonds":77,
   "gold-bars":28,
   "exciting-stuff":52,
   "oil":51,
   "sports-cars":7,
   "bitcoins":40
};
const splitKeyValue = obj => {
   const keys = Object.keys(obj);
   const res = [];
   for(let i = 0; i < keys.length; i++){
      res.push({
         'asset': keys[i],
         'quantity': obj[keys[i]]
      });
   };
   return res;
};
console.log(splitKeyValue(dataset));
This will produce the following output on console −
[
   { asset: 'diamonds', quantity: 77 },
   { asset: 'gold-bars', quantity: 28 },
   { asset: 'exciting-stuff', quantity: 52 },
   { asset: 'oil', quantity: 51 },
   { asset: 'sports-cars', quantity: 7 },
   { asset: 'bitcoins', quantity: 40 }
]
CSS | invert() Function - GeeksforGeeks

03 Jun, 2020
The invert() function is an inbuilt function that is used to apply a filter to the image to set the invert of the color of the sample image.
Syntax:
invert( amount )
Parameters: This function accepts single parameter amount which holds the amount of conversion. The value of invert is set in terms of value and percentage. The value 0% represents original image and 100% represents the inverted image.
The invert() function internally uses the following formula, to computer the inverse of the image:
amount * (255 - value) + (1 - amount) * value
The value of inversion is controlled by the variable amount, the variable value lies between 0 – 1(floating) range (this is done by converting the passed percentage of color inversion to a value between 0-1). The value is the the color value of the pixel. (255-value) gives the color after subtracting the color value with the max pixel value, assumes that the value of the pixel is in the range 0 – 255 (though input image sample space could be stretched/scaled to meet the specified criteria).
Below is a table containing a list of inversion percentages and the result they produce.
Below example illustrates CSS invert() function in CSS:Example:
<!DOCTYPE html> <html>   <head>     <title>CSS invert() Function</title>           <style>        h1 {            color:green;        }        body {            text-align:center;        }        .invert_effect {            filter: invert(100%);        }    </style></head>   <body>     <h1>GeeksforGeeks</h1>           <h2>CSS invert() function</h2>          <img class="invert_effect" src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png"        alt="GeeksforGeeks logo"> </body>   </html>
Output:
Supported Browsers: The browsers supported by invert() function are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
deosurya2019
CSS-Functions
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Create a Responsive Navbar using ReactJS
Design a web page using HTML and CSS
How to Upload Image into Database and Display it using PHP ?
CSS | :not(:last-child):after Selector
How to set fixed width for <td> in a table ?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
How to convert Python Dictionary to a list?

Python's dictionary class has three methods for this purpose. The methods items(), keys() and values() return view objects comprising of tuple of key-value pairs, keys only and values only respectively. The in-built list method converts these view objects in list objects.
>>> d1 = {'name': 'Ravi', 'age': 23, 'marks': 56}
>>> d1.items()
dict_items([('name', 'Ravi'), ('age', 23), ('marks', 56)])
>>> l1 = list(d1.items())
>>> l1
[('name', 'Ravi'), ('age', 23), ('marks', 56)]
>>> d1.keys()
dict_keys(['name', 'age', 'marks'])
>>> l2 = list(d1.keys())
>>> l2
['name', 'age', 'marks']
>>> l3 = list(d1.values())
>>> l3
['Ravi', 23, 56]
Lodash - merge method

_.merge(object, [sources])

This method is like _.assign except that it recursively merges own and inherited enumerable string keyed properties of source objects into the destination object. Source properties that resolve to undefined are skipped if a destination value exists. Array and plain object properties are merged recursively. Other objects and value types are overridden by assignment. Source objects are applied from left to right. Subsequent sources overwrite property assignments of previous sources.
object (Object) − The destination object.
object (Object) − The destination object.
[sources] (...Object) − The source objects.
[sources] (...Object) − The source objects.
(Object) − Returns object.
(Object) − Returns object.
var _ = require('lodash');
var object = {
   'a': [{ 'b': 2 }, { 'd': 4 }]
};
 
var other = {
   'a': [{ 'c': 3 }, { 'e': 5 }]
};

console.log(_.merge(object, other));
Save the above program in tester.js. Run the following command to execute this program.
\>node tester.js

{ a: [ { b: 2, c: 3 }, { d: 4, e: 5 } ] }

 Print
 Add Notes
 Bookmark this page
TypeScript - While Loop

The while loop executes the instructions each time the condition specified evaluates to true. In other words, the loop evaluates the condition before the block of code is executed.
while(condition) { 
   // statements if the condition is true 
}

var num:number = 5; 
var factorial:number = 1; 

while(num >=1) { 
   factorial = factorial * num; 
   num--; 
} 
console.log("The factorial  is "+factorial);  

The above code snippet uses a while loop to calculate the factorial of the value in the variable num.
On compiling, it will generate the following JavaScript code −
//Generated by typescript 1.8.10
var num = 5;
var factorial = 1;
while (num >= 1) {
   factorial = factorial * num;
   num--;
}
console.log("The factorial  is " + factorial);

It produces the following output −
The factorial is 120


    45 Lectures 
     4 hours 

 Antonio Papa

    41 Lectures 
     7 hours 

 Haider Malik

    60 Lectures 
     2.5 hours 

 Skillbakerystudios

    77 Lectures 
     8 hours 

 Sean Bradley

    77 Lectures 
     3.5 hours 

 TELCOMA Global

    19 Lectures 
     3 hours 

 Christopher Frewin
 Print
 Add Notes
 Bookmark this page
Last occurrence of some element in a list in Python

In this article, we are going to see different ways to find the last occurrence of an element in a list.
Let's see how to find the last occurrence of an element by reversing the given list. Follow the below steps to write the code.
Initialize the list.
Reverse the list using reverse method.
Find the index of the element using index method.
The actual index of the element is len(list) - index - 1.
Print the final index.
Let's see the code.
 Live Demo
# initializing the list
words = ['eat', 'sleep', 'drink', 'sleep', 'drink', 'sleep', 'go', 'come']
element = 'sleep'

# reversing the list
words.reverse()

# finding the index of element
index = words.index(element)

# printing the final index
print(len(words) - index - 1)
If you run the above code, then you will get the following result.
5

Another way is to find all the indexes and getting the max from it.
Let's see the code.
 Live Demo
# initializing the list
words = ['eat', 'sleep', 'drink', 'sleep', 'drink', 'sleep', 'go', 'come']
element = 'sleep'

# finding the last occurrence
final_index = max(index for index, item in enumerate(words) if item == element)

# printing the index
print(final_index)
If you run the above code, then you will get the following result.
5

If you have any queries in the article, mention them in the comment section.
Creating a Doubly Linked List using Javascript

Lets start by defining a simple class with a constructor that initializes the head and tail to null. We'll also define another structure on the prototype of the DoublyLinkedList class that'll represent each node in the linked list. 
class LinkedList {
   constructor() {
      this.head = null;
      this.tail = null;
      this.length = 0;
   }
}
LinkedList.prototype.Node = class {
   constructor(data) {
      this.data = data;
      this.next = null;
      this.prev = null;
   }
};
Let's also create a display function that'll help us see how our list looks like. This function works as follows.
It starts from the head.
It iterates over the list using currElem = currElem.next till currElem doesn't become null, ie, we've not reached the end.
It prints data for each of the iterations.
Here is an illustration for the same −
Now let's have a look at how we'll implement this − 
display() {
   let currNode = this.head;
   while (currNode != null) {
      console.log(currNode.data + " -> ");
      currNode = currNode.next;
   }
}
MS SQL Server - Create Database

Database is a collection of objects such as table, view, stored procedure, function, trigger, etc.
In MS SQL Server, two types of databases are available.
System databases
User Databases
System databases are created automatically when we install MS SQL Server. Following is a list of system databases −
Master
Model
MSDB
Tempdb
Resource (Introduced in 2005 version)
Distribution (It’s for Replication feature only)
User databases are created by users (Administrators, developers, and testers who have access to create databases).
Following methods are used to create user database.
Following is the basic syntax for creating database in MS SQL Server.
Create database <yourdatabasename>

OR
Restore Database <Your database name> from disk = '<Backup file location + file name>

To create database called ‘Testdb’, run the following query.
Create database Testdb

OR
Restore database Testdb from disk = 'D:\Backup\Testdb_full_backup.bak'

Note − D:\backup is location of backup file and Testdb_full_backup.bak is the backup file name
Connect to SQL Server instance and right-click on the databases folder. Click on new database and the following screen will appear.
Enter the database name field with your database name (example: to create database with the name ‘Testdb’) and click OK. Testdb database will be created as shown in the following snapshot.

    32 Lectures 
     2.5 hours 

 Pavan Lalwani

    18 Lectures 
     1.5 hours 

 Dr. Saatya Prasad

    102 Lectures 
     10 hours 

 Pavan Lalwani

    52 Lectures 
     4 hours 

 Pavan Lalwani

    239 Lectures 
     33 hours 

 Gowthami Swarna

    53 Lectures 
     5 hours 

 Akshay Magre
 Print
 Add Notes
 Bookmark this page
Python – Remove space between tuple elements

05 Oct, 2021
Sometimes, while working with Tuples, we can have a problem in which we need to print tuples, with no space between the comma and next element, which by convention, is present. This problem can have use in day-day and school programming. Let’s discuss certain ways in which this task can be performed. 
Input : test_tuple = (7, 6, 8) Output : (7, 6, 8)Input : test_tuple = (6, 8) Output : (6, 8)  
Method #1 : Using str() + replace() The combination of above functions can be used to solve this problem. In this, we perform the task of removing the additional space, by replacing with empty space. 
Python3
# Python3 code to demonstrate working of# Remove space between tuple elements# Using replace() + str() # initializing tuplestest_tuple = (4, 5, 7, 6, 8) # printing original tupleprint("The original tuple : " + str(test_tuple)) # Remove space between tuple elements# Using replace() + str()res = str(test_tuple).replace(' ', '') # printing resultprint("The tuple after space removal : " + str(res))
The original tuple : (4, 5, 7, 6, 8)
The tuple after space removal : (4, 5, 7, 6, 8)
 
 Method #2 : Using join() + map() Another method to solve this problem. In this, we perform the task of removal of space by external joining of each element using join() and extending the logic of string conversion to each element using map(). 
Python3
# Python3 code to demonstrate working of# Remove space between tuple elements# Using join() + map() # initializing tuplestest_tuple = (4, 5, 7, 6, 8) # printing original tupleprint("The original tuple : " + str(test_tuple)) # Remove space between tuple elements# Using join() + map()res = "(" + ", ".join(map(str, test_tuple)) + ")" # printing resultprint("The tuple after space removal : " + str(res))
The original tuple : (4, 5, 7, 6, 8)
The tuple after space removal : (4, 5, 7, 6, 8)
 
kashishsoda
Python tuple-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas Series.eq()

15 Oct, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas series.eq() is used to compare every element of Caller series with passed series. It returns True for every element which is Equal to the element in passed series.
Note: The results are returned on the basis of comparison caller series = other series.
Syntax: Series.eq(other, level=None, fill_value=None)
Parameters:other: other series to be compared withlevel: int or name of level in case of multi levelfill_value: Value to be replaced instead of NaN
Return type: Boolean series
Example #1: Handling Null Values
In this example, two series are created using pd.Series(). The series contains some Null values and some equal values at same indices too. The series are compared using .eq() method and 5 is passed to fill_value parameter to replace NaN values by 5.
# importing pandas module  import pandas as pd       # importing numpy module import numpy as np      # creating series 1 series1 = pd.Series([70, 5, 0, 225, 1, 16, np.nan, 10, np.nan])      # creating series 2 series2 = pd.Series([70, np.nan, 2, 23, 1, 95, 53, 10, 5])    # NaN replacementreplace_nan = 5   # calling and returning to result variableresult = series1.eq(series2, fill_value = replace_nan)   # display result  
Output:As shown in output, True was returned wherever value in caller series was Equal to value in passed series. Also it can be seen Null values were replaced by 5 and the comparison was made using that value.
Example #2: Calling on Series with str objectsIn this example, two series are created using pd.Series(). The series contains some string values too. In case of strings, the comparison is made with their ASCII values.
# importing pandas module  import pandas as pd      # importing numpy module import numpy as np     # creating series 1 series1 = pd.Series(['Aaa', 10, 'cat', 43, 9, 'Dog', np.nan, 'x', np.nan])     # creating series 2 series2 = pd.Series(['vaa', np.nan, 'Cat', 23, 5, 'Dog', 54, 'x', np.nan])   # NaN replacementreplace_nan = 10  # calling and returning to result variableresult = series1.eq(series2, fill_value = replace_nan)  # display result 
Output:As it can be seen in output, in case of strings, the comparison was made using their ASCII values. True was returned wherever the string in Caller series was equal to string in passed series.
Python pandas-series
Python pandas-series-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Introduction to Tkinter

22 May, 2020
Graphical User Interface(GUI) is a form of user interface which allows users to interact with computers through visual indicators using items such as icons, menus, windows, etc. It has advantages over the Command Line Interface(CLI) where users interact with computers by writing commands using keyboard only and whose usage is more difficult than GUI.
Tkinter is the inbuilt python module that is used to create GUI applications. It is one of the most commonly used modules for creating GUI applications in Python as it is simple and easy to work with. You don’t need to worry about the installation of the Tkinter module separately as it comes with Python already. It gives an object-oriented interface to the Tk GUI toolkit.Some other Python Libraries available for creating our own GUI applications are
Kivy
Python Qt
wxPython
Among all Tkinter is most widely used
Widgets in Tkinter are the elements of GUI application which provides various controls (such as Labels, Buttons, ComboBoxes, CheckBoxes, MenuBars, RadioButtons and many more) to users to interact with the application.
Fundamental structure of tkinter programBasic Tkinter Widgets:
Example
from tkinter import * from tkinter.ttk import *    # writing code needs to# create the main window of # the application creating # main window object named rootroot = Tk()  # giving title to the main windowroot.title("First_Program")  # Label is what output will be # show on the windowlabel = Label(root, text ="Hello World !").pack()  # calling mainloop method which is used# when your application is ready to run# and it tells the code to keep displaying root.mainloop()
Output
Python-tkinter
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Program for Find remainder of array multiplication divided by n

07 Jun, 2022
Given multiple numbers and a number n, the task is to print the remainder after multiplying all the numbers divided by n.Examples: 
Input : arr[] = {100, 10, 5, 25, 35, 14}, n = 11Output : 9Explaination: 100 x 10 x 5 x 25 x 35 x 14 = 61250000 % 11 = 9
Naive approach: First multiple all the numbers then take % by n to find the remainder, But in this approach, if the number is a maximum of 2^64 then it gives the wrong answer.
An approach that avoids overflow: First take a remainder or individual number like arr[i] % n. Then multiply the remainder with the current result. After multiplication, again take the remainder to avoid overflow. This works because of the distributive properties of modular arithmetic. ( a * b) % c = ( ( a % c ) * ( b % c ) ) % c 
Python3
# to use reduce function import reduce from functoolsfrom functools import reduce  def find_remainder(arr, n):    sum_1 = reduce(lambda x, y: x*y, arr)    remainder = sum_1 % n    print(remainder)  arr = [100, 10, 5, 25, 35, 14]n = 11find_remainder(arr, n)
9

Please refer complete article on Find remainder of array multiplication divided by n for more details! 
Akanksha_Rai
pavanimadhira86
namritbe18
harendrakumar123
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PHP | time() Function

05 May, 2018
The time() function is a built-in function in PHP which returns the current time measured in the number of seconds since the Unix Epoch. The number of seconds can be converted to the current date using date() function in PHP.
Syntax:
int time()
Parameter: This function does not accepts any parameters as shown above.
Return Value: This function returns the current time measured in the number of seconds since the Unix Epoch.
Note: All output of programs corresponds to the date when the article was written.
Below programs illustrate the time() function:
Program 1: The program below prints the current time in term of seconds.
<?php// PHP program to demonstrate the use of current // time in seconds since Unix Epoch   // variable to store the current time in seconds $currentTimeinSeconds = time();   // prints the current time in secondsecho $currentTimeinSeconds; ?>
Output:
1525376494

Program 2: The program below prints the current time in date format.
<?php// PHP program to demonstrate the use of current // date since Unix Epoch   // variable to store the current time in seconds $currentTimeinSeconds = time();   // converts the time in seconds to current date $currentDate = date('Y-m-d', $currentTimeinSeconds);  // prints the current dateecho ($currentDate); ?>
Output:
2018-05-03 

PHP-date-time
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.