code-rag-bench/online-tutorials huggingface dataset:
Perl – Introduction to Debugger

10 Jul, 2020
Perl is a general-purpose, high level interpreted and dynamic programming language. Since Perl is a lot similar to other widely used languages syntactically, it is easier to code and learn in Perl. But perfect programs are hard to get in the very first attempt. They have to go through various steps of debugging to fix all errors. These programs may contain some bugs which result in the failure of code execution.
A bug in software is a flaw, error, fault, or failure that causes the software to fail to perform designated tasks. In simple words, when we make an error during coding, we call it a bug. We measure the impact of a bug on the software by means of two parameters, namely – Severity and Priority.
The process of finding and removing software errors which result in failure of the software is known as debugging. The debugging phase starts just after receiving a bug report and ends when that bug is removed and the program is working correctly.
The debugging process includes detection and removal of bugs from software programs. The steps of debugging are as follows:
Replication of bug: This is the first step in debugging, in which we try to recreate the steps which led to the failure of program by giving the same set of inputs.
Understanding the bug: In this step, we try to analyze the reasons which led to the failure of the program. We may have to thoroughly understand the program execution for this. Thus, a debugger helps in this process by providing better mechanisms to understand the program. It inspects the program line-by-line, can pause the program by using breakpoints, uses watch to keep track of variables, registers, etc.
Locating the bug: After we know the incorrect behavior, we aim to find the portion of source code that produces this error. This activity is known as locating the bug. To do this, we may have to inspect the source code, watch variable changes, etc.
Fixing the bug and re-testing of program: This is the final step of debugging, where we fix the bug in the software program. We then have to re-test the program and see if the bug is removed and all corrections are in place. During this step, it is possible that some other portions of the program may get affected too. Hence an impact analysis may have to be performed to identify the affected portions and re-test them. This process is known as regression testing.
To enter into debugger, we can type the following command :
perl -d program_name
Exiting the DebuggerTo exit from the debugger we can press q or use:
Ctrl+D or Ctrl+Z
Picked
Perl
Perl
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Perl Tutorial - Learn Perl With Examples
Perl | ne operator
Perl | Basic Syntax of a Perl Program
Perl | Opening and Reading a File
Perl | Decision Making (if, if-else, Nested–if, if-elsif ladder, unless, unless-else, unless-elsif)
Perl | File Handling Introduction
Perl | Writing to a File
Perl | Multidimensional Hashes
Perl | Data Types
Perl | qw Operator
PostgreSQL – CREATE DOMAIN

06 Sep, 2021
PostgreSQL supports the creation of user-defined data types using the following statements:  
CREATE DOMAIN:It creates a user-defined data type that can have optional constraints.  
CREATE TYPE:It is often applied to create a composite type (data type that are mixes of two or more data types) using stored procedures.  
CREATE DOMAIN: In PostgreSQL, a domain is a data type that has optional constraints. It is a must to have a unique name and a well-defined schema range. 
Example: First, we create a table (say, marksheet) using the below command:  
CREATE TABLE marksheet (
    student_id SERIAL PRIMARY KEY,
    first_name VARCHAR NOT NULL,
    last_name VARCHAR NOT NULL,
    email VARCHAR NOT NULL,
    marks_obtained INT NOT NULL, 
    CHECK (
        first_name !~ '\s'
        AND last_name !~ '\s'
    )
);
The first_name and last_name fields are not null and must not contain any spaces. For the simplicity of the teachers we can make a student_detail domain using the below command:  
CREATE DOMAIN student_detail AS 
    VARCHAR NOT NULL CHECK (value !~ '\s');
Now we can use the student_detail as the data type of the first_name and last_name fields as follows:  
CREATE TABLE marksheet (
    student_id serial PRIMARY KEY,
    first_name student_detail,
    last_name student_detail,
    marks_obtained INT NOT NULL,
    email VARCHAR NOT NULL
);
Now insert some data to the table using the below command:  
INSERT INTO marksheet (first_name, last_name,marks_obtained, email)
VALUES
    (
        'Raju K',
        'Singh',
     95,
        'rajukumar@gmail.com'
    );
At this stage PostgreSQL will raise the following error:  
ERROR:  value for domain marksheet violates check constraint "marksheet_check"
 
So, the behaviour is as we expected. To modify or delete a domain, one can make use of the ALTER DOMAIN or DROP DOMAIN respectively. To get all domains in the current database use the below command:  
\dD
Output:  
 
prabhurajendran2
anikaseth98
postgreSQL
postgreSQL-dataTypes
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL - Psql commands
PostgreSQL - Change Column Type
PostgreSQL - For Loops
PostgreSQL - Function Returning A Table
PostgreSQL - LIMIT with OFFSET clause
PostgreSQL - ARRAY_AGG() Function
PostgreSQL - DROP INDEX
PostgreSQL - Create Auto-increment Column using SERIAL
PostgreSQL - Copy Table
How to use PostgreSQL Database in Django?
Advanced Pointer in C - GeeksQuiz

07 Mar, 2018
void fun(int **pptr)
{
  static int q = 10;
  *pptr = &q;
}

int main()
{
  int r = 20;
  int *p = &r;
  fun(&p);
  printf("%d", *p);
  return 0;
}


#include <string.h>
#include <stdio.h>
#include <stdlib.h>

void fun(char** str_ref)
{
    (*str_ref)++;
}

int main()
{
    char *str = (void *)malloc(100*sizeof(char));
    strcpy(str, "GeeksQuiz");
    fun(&str);
    puts(str);
    free(str);
    return 0;
}

Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Must Do Coding Questions for Companies like Amazon, Microsoft, Adobe, ...
Must Do Coding Questions for Product Based Companies
Git - Difference Between Git Fetch and Git Pull
SDE SHEET - A Complete Guide for SDE Preparation
How to Install and Use NVM on Windows?
DSA Sheet by Love Babbar
Download Image From URL in Android
Java Threads
Top 20 Puzzles Commonly Asked During SDE Interviews
Spring Boot - Architecture
Node.js querystring.escape() Method

08 Mar, 2021
The querystring.escape( ) function is used to produce a percent-encoded query string from a normal string. This method is very similar to the browser’s encodeURIComponent functions. This method performs percent-encoding on the given string it means it encodes any string into a URL query string by using the % symbol. This method iterates through the string and places the % encoding where needed. The method querystring.stringify( )  internally uses this method and generally, it is not used directly.
Syntax:
querystring.escape(str);
Parameters: This function accepts only one parameter which is described below.
str: It is the string that is going to be encoded into a query string.
Return value: It returns a string containing the query produced by the given string.
Below are the following examples to explain the concepts of the query string.escape function.
Example 1: In this example, we are encoding a simple string.
index.js
//Importing querystring moduleconst querystring = require("querystring")  // String to be encodedlet str = "I love geeksforgeeks";  // Using the escape function to the stringlet encodedURL = querystring.escape(str);  // Printing the encoded urlconsole.log(encodedURL)
Run index.js file using below command:
node index.js
Output:
encoded url : I%20love%20geeksforgeeks
Example 2: In this example, we are encoding a string using querystring.escape( ) function and encodeURIComponent function and print the output of both the functions.
index.js
//Importing querystring moduleconst querystring = require("querystring")  // String to be encodedlet str = "I love geeksforgeeks";  // Using the escape function to the stringlet encodedURL1 = querystring.escape(str);  // Using the encodedURIComponent functionlet encodedURL2 = encodeURIComponent(str);  // Printing the encoded urlsconsole.log("encoded url using escape: " + encodedURL1)console.log("encoded url using encodeURIComponent: " + encodedURL2)  // Printing if the both encodings are equalif(encodedURL1 === encodedURL2){    console.log("Both are the same results.")}
Run index.js file using below command:
node index.js
Output:
encoded url using escape: I%20love%20geeksforgeeks
encoded url using encodeURIComponent: I%20love%20geeksforgeeks
Both are the same results.
Reference:https://nodejs.org/api/querystring.html#querystring_querystring_escape_str
Node.js-Methods
Picked
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JWT Authentication with Node.js
Installation of Node.js on Windows
Difference between dependencies, devDependencies and peerDependencies
Mongoose Populate() Method
Mongoose find() Function
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to create footer to stay at the bottom of a Web page?
How to set the default value for an HTML <select> element ?
How do you run JavaScript script through the Terminal?
delete and free() in C++

28 Nov, 2021
delete and free() in have similar functionalities programming languages but they are different. In C++, the delete operator should only be used either for the pointers pointing to the memory allocated using new operator or for a NULL pointer, and free() should only be used either for the pointers pointing to the memory allocated using malloc() or for a NULL pointer.
Differences in delete and free are:
delete() 
free()
Note: The most important reason why free() should not be used for de-allocating memory allocated using new is that, it does not call the destructor of that object while delete operator does.
Example for delete operator:
CPP
// CPP program to demonstrate the correct and incorrect// usage of delete operator#include <cstdlib>#include <iostream>using namespace std;  // Driver Codeint main(){    int x;    int* ptr1 = &x;    int* ptr2 = (int*)malloc(sizeof(int));    int* ptr3 = new int;    int* ptr4 = NULL;      // delete Should NOT be used like below because x is    // allocated on stack frame    delete ptr1;      // delete Should NOT be used like below because x is    // allocated using malloc()    delete ptr2;      // Correct uses of delete    delete ptr3;    delete ptr4;      getchar();    return 0;}
Example for free() function:
C++
// CPP program to demonstrate the correct and incorrect// usage of free() function#include <cstdlib>#include <iostream>using namespace std;  // Driver Codeint main(){      int* ptr1 = NULL;    int* ptr2;    int x = 5;    ptr2 = &x;    int* ptr3 = (int*)malloc(5 * sizeof(int));      // Correct uses of free()    free(ptr1);    free(ptr3);      // Incorrect use of free()    free(ptr2);      return 0;}
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
ammarnasikwala
anshikajain26
cpp-pointer
C Language
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Substring in C++
Function Pointer in C
Multidimensional Arrays in C / C++
Left Shift and Right Shift Operators in C/C++
Different Methods to Reverse a String in C++
Vector in C++ STL
Map in C++ Standard Template Library (STL)
Initialize a vector in C++ (7 different ways)
Set in C++ Standard Template Library (STL)
vector erase() and clear() in C++
How to remove focus around buttons on click?

22 Apr, 2019
To remove focus around the button outline:none property is used.
Syntax:
button {
    // Remove focus around button
    outline:none;  
}

Outline property: Outline is an element property which draws a line around element but outside the border. It does not take space from the width of an element like border.
Example 1: This example creates focus on button.
<!DOCTYPE html><html>  <head>    <title>        Remove focus around the button    </title>          <style>        h1 {            text-align: center;            margin-top: 10%;            font-family: Arial;            color: green;        }        button {            background-color: lightgray;            font-size: xx-large;            border: none;            cursor: pointer;        }    </style></head>  <body>    <h1>        Button get Focused when clicking it    </h1>          <div>        <button type="submit"             style="margin:auto;display:block;">            click here        </button>    </div></body>  </html>                                    
Output:
Example 2: This example uses outline:none property to remove focus from button after clicking the button.
<!DOCTYPE html><html>      <head>    <title>        Remove Focus from button    </title>          <style>        h1 {            text-align: center;            margin-top: 10%;            font-family: Arial;            color: green;        }        button {            background-color: lightgray;            font-size: xx-large;            border: none;            cursor: pointer;            outline: none;        }    </style></head>  <body>    <h1>        Remove focus from button when        clicking the button    </h1>          <div>        <button type="submit"             style="margin:auto; display:block;">            click here        </button>    </div></body>  </html>                    
Output:In the above code, the outline:none property is used to remove focus from button.
Picked
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Inline-level Elements and Inline Boxes in CSS

Inline-level elements have their CSS display property set to either ‘inline, ‘inline-table’, or ‘inline-block’ and these elements do not force a line break above and below themselves. Inline-level boxes are generated by each inline-level element which is a part of the positioning scheme as well as contains child boxes.
Inline boxes are boxes which have their content follow inline formatting context. Inline boxes are split into a number of inline boxes whilst those inline boxes that are never split are called atomic inline-level boxes.
Anonymous inline boxes are those boxes over which developer has no control. If a block box contains some bare text and other inline-level boxes, then the bare text around inline-level boxes follows inline formatting context and is enclosed in anonymous inline boxes.
Let’s see an example for Inline-level Elements and Inline Boxes −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<title>CSS Inline-level Elements and Inline Boxes</title>
<style>
form {
   width:70%;
   margin: 0 auto;
   text-align: center;
}
* {
   padding: 2px;
}
input[type="button"] {
   border-radius: 10px;
}
.child{
   color: white;
   border: 4px solid black;
}
.child:nth-of-type(1){
   background-color: #FF8A00;
}
.child:nth-of-type(2){
   background-color: #F44336;
}
.child:nth-of-type(3){
   background-color: #C303C3;
}
.child:nth-of-type(4){
   background-color: #4CAF50;
}
.child:nth-of-type(5){
   background-color: #03A9F4;
}
.child:nth-of-type(6){
   background-color: #FEDC11;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>CSS Inline-level Elements and Inline Boxes</legend>
<div><span class="child">Orange</span> Color<span class="child">Red</span> Color<span class="child">Violet</span> Color</div><br>
</body>
</html>
This will produce the following output −
Matplotlib.axes.Axes.set_axis_off() in Python

19 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
The Axes.set_axis_off() function in axes module of matplotlib library is used to turn the x- and y-axis off and this affects the axis lines, ticks, ticklabels, grid and axis labels.
Syntax: Axes.set_axis_off(self)
Parameters: This method does not accept any parameters.
Returns:This method does not returns anything.
Below examples illustrate the matplotlib.axes.Axes.set_axis_off() function in matplotlib.axes:
Example 1:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport numpy as np    # Time series datageeksx = np.array([24.40, 110.25, 20.05,                   22.00, 61.90, 7.80,                   15.00])  geeksy = np.array([24.40, 110.25, 20.05,                   22.00, 61.90, 7.80,                   15.00])    fig, ax = plt.subplots()ax.xcorr(geeksx,  geeksy, maxlags = 6,          color ="green")  ax.set_axis_off()  ax.set_title('matplotlib.axes.Axes.set_axis_off()\Example')plt.show()
Output:
Example 2:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport matplotlib.tri as mtriimport numpy as np     x = np.asarray([0, 1, 2, 3, 0.5,                1.5, 2.5, 1, 2,                1.5])  y = np.asarray([0, 0, 0, 0, 1.0,                 1.0, 1.0, 2, 2,                 3.0])  triangles = [[0, 1, 4], [1, 5, 4],              [2, 6, 5], [4, 5, 7],             [5, 6, 8], [5, 8, 7],              [7, 8, 9], [1, 2, 5],              [2, 3, 6]]  triang = mtri.Triangulation(x, y, triangles)z = np.cos(1.5 * x) * np.cos(1.5 * y)     fig, axs = plt.subplots()axs.tricontourf(triang, z)axs.triplot(triang, 'go-', color ='white')  axs.set_axis_off()axs.set_title('matplotlib.axes.Axes.set_axis_off()\Example', fontsize = 10, fontweight ='bold')plt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Iterate over a list in Python
Introduction To PYTHON
Difference between length of Array and size of ArrayList in Java - GeeksforGeeks

15 Mar, 2019
Array has length property which provides the length of the Array or Array object. It is the total space allocated in memory during the initialization of the array. Array is static so when we create an array of size n then n blocks are created of array type and JVM initializes every block by default value. Let’s see this in the following figure.
On the other hand, java ArrayList does not have length property. The java ArrayList has size() method for ArrayList which provides the total number of objects available in the collection.
We use length property to find length of Array in Java and size() to find size of ArrayList.
Below is the implementation of the above idea:
// Java code to illustrate the difference between// length in java Array and size in ArrayList  import java.util.ArrayList;  public class GFG {    // main method    public static void main(String[] args)    {          /* creating an array A[] for 10 elements */        String A[] = new String[10];          /* store 2 elements */        A[0] = "Hello";        A[1] = "Geeks!";          /* print length of array A[] */        System.out.println(A.length); // 10          /* Creating an ArrayList */        ArrayList<String> al = new ArrayList<String>();          /* add 3 elements */        al.add("G");        al.add("F");        al.add("G");          /* print size of ArrayList */        System.out.println(al.size()); // 3    }}
10
3

SatyaShekharBarik
Java-Array-Programs
Java-ArrayList
Java-Arrays
Java-List-Programs
Technical Scripter 2018
Difference Between
Java
Technical Scripter
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Stack vs Heap Memory Allocation
Difference between Process and Thread
Difference Between Method Overloading and Method Overriding in Java
Difference between Clustered and Non-clustered index
For-each loop in Java
Arrays.sort() in Java with examples
Reverse a string in Java
HashMap in Java with Examples
Initialize an ArrayList in Java
closegraph() function in C - GeeksforGeeks

23 Jan, 2018
The header file graphics.h contains closegraph() function which closes the graphics mode, deallocates all memory allocated by graphics system and restores the screen to the mode it was in before you called initgraph.
Syntax :
void closegraph();

Below is the implementation of closegraph() in C.
// C Implementation for closegraph()#include <graphics.h>  // driver codeint main(){    // gm is Graphics mode which is    // a computer display mode that    // generates image using pixels.    // DETECT is a macro defined in    // "graphics.h" header file    int gd = DETECT, gm;      // initgraph initializes the    // graphics system by loading a    // graphics driver from disk    initgraph(&gd, &gm, "");      // outtext function displays    // text at current position.    outtext("Press any key to close"           " the graphics mode !!");      getch();      // closegraph function closes the    // graphics mode and deallocates    // all memory allocated by    // graphics system .    closegraph();      return 0;}
Output :


Note : On executing the program, the output window looks as shown above. On pressing any key, the closegraph() closes the graphics mode.
c-graphics
computer-graphics
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Multidimensional Arrays in C / C++
rand() and srand() in C/C++
fork() in C
Core Dump (Segmentation fault) in C/C++
Left Shift and Right Shift Operators in C/C++
Command line arguments in C/C++
Different methods to reverse a string in C/C++
Function Pointer in C
Substring in C++
Enumeration (or enum) in C
How to sort bars in a bar plot in ascending order (Matplotlib)?

To sort bars in a bar plot in ascending order, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Set the figure size and adjust the padding between and around the subplots.
Make a list of data for bar plots.
Make a list of data for bar plots.
Create a bar plot using bar() method, with sorted data.
Create a bar plot using bar() method, with sorted data.
To display the figure, use show() method.
To display the figure, use show() method.
from matplotlib import pyplot as plt

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

data = [3, 5, 9, 15, 12]

plt.bar(range(len(data)), sorted(data), color='red', alpha=0.5)

plt.show()
Program to find largest of three numbers - JavaScript

We are required to write a JavaScript function that takes in three or more numbers and returns the largest of those numbers.
For example: If the input numbers are −
4, 6, 7, 2, 3
Then the output should be −
7
Let’s write the code for this function −
// using spread operator to cater any number of elements
const findGreatest = (...nums) => {
   let max = -Infinity;
   for(let i = 0; i < nums.length; i++){
      if(nums[i] > max){
         max = nums[i];
      };
   };
   return max;
};
console.log(findGreatest(5, 6, 3, 5, 7, 5));
The output in the console −
7
What does raw_input() function do in python?

The function raw_input() presents a prompt to the user (the optional arg of raw_input([arg])), gets input from the user and returns the data input by the user in a string. For example,
name = raw_input("What is your name? ")
print "Hello, %s." % name
This differs from input() in that the latter tries to interpret the input given by the user; it is usually best to avoid input() and to stick with raw_input() and custom parsing/conversion code.
How to use Card Component in ReactJS?

08 Sep, 2021
Cards contain content and actions about a single subject. Material UI for React has this component available for us, and it is very easy to integrate. We can use the Card Component in ReactJS using the following approach.
Creating React Application And Installing Module:
Step 1: Create a React application using the following command.
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command.
cd foldername
Step 3: After creating the ReactJS application, Install the material-ui modules using the following command.
npm install @material-ui/core
Project Structure:
Example:Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
App.js
import React from "react";import Card from "@material-ui/core/Card";import CardContent from "@material-ui/core/CardContent";import Typography from "@material-ui/core/Typography";import Button from "@material-ui/core/Button";import CardActions from "@material-ui/core/CardActions";  export default function App() {  return (    <div style={{}}>      <h4>How to use CardComponent in ReactJS?</h4>      <Card        style={{          width: 400,          backgroundColor: "yellow",        }}      >        <CardContent>          <Typography            style={{ fontSize: 14 }}            color="textSecondary"            gutterBottom          >            Greetings of the day          </Typography>          <Typography variant="h5" component="h2">            How are you ?          </Typography>          <Typography            style={{              marginBottom: 12,            }}            color="textSecondary"          >            Keep Motivated          </Typography>          <Typography variant="body2" component="p">            Stay Happy          </Typography>        </CardContent>        <CardActions>          <Button size="small">Stay Safe.....</Button>        </CardActions>      </Card>    </div>  );}
Step to Run Application: Run the application using the following command from the root directory of the project.
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output.
Reference:https://material-ui.com/api/card/
rs1686740
React-Questions
ReactJS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Axios in React: A Guide for Beginners
ReactJS setState()
How to pass data from one component to other component in ReactJS ?
Re-rendering Components in ReactJS
ReactJS defaultProps
How to create a table in ReactJS ?
ReactJS useNavigate() Hook
How to set background images in ReactJS ?
ReactJS useCallback Hook
How to install bootstrap in React.js ?
HTML | <input> placeholder Attribute

09 May, 2019
The <input> placeholder attribute in HTML is used to specify the expected value to be displayed before user input in the input element.
Syntax:
<input placeholder="text"> 
Attribute Values: This attribute contains a single value text which specifies a short hint that describes the expected value of the input field.
Example: This Example illustrates the use of Placeholder attribute in <input> element.
<!DOCTYPE html><html>  <body>    <center>        <h1 style="font-size:25px;font-style:italic;">          GeeksForGeeks      </h1>        <h2 style="font-size:25px;font-style:italic;">          HTML input Placeholder Attribute      </h2>                <form action=" ">            <input type="text"                   name="fname"                   placeholder="First name">            <br>            <input type="text"                   name="lname"                    placeholder="Last name">            <br>            <input type="submit"                    value="Submit">        </form>  </center></body>  </html>
Output:
Supported Browsers: The browser supported by HTML <input> Placeholder Attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Opera
Safari
shubham_singh
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python – Rows with all List elements

12 Nov, 2020
Given a Matrix, get all the rows with all the list elements.
Input : test_list = [[7, 6, 3, 2], [5, 6], [2, 1, 8], [6, 1, 2]], sub_list = [1, 2] Output : [[2, 1, 8], [6, 1, 2]] Explanation : Extracted lists have 1 and 2.
Input : test_list = [[7, 6, 3, 2], [5, 6], [2, 1, 8], [6, 1, 2]], sub_list = [2, 6] Output : [[7, 6, 3, 2], [6, 1, 2]] Explanation : Extracted lists have 2 and 6.
Method #1: Using loop
In this, we iterate for each row from Matrix, and check for presence of each list element, if present row is returned as result. If any element is not present, row is flagged off.
Python3
# Python3 code to demonstrate working of# Rows with all List elements# Using loop  # initializing listtest_list = [[7, 6, 3, 2], [5, 6], [2, 1, 8], [6, 1, 2]]  # printing original listprint("The original list is : " + str(test_list))  # initializing listsub_list = [1, 2]  res = []for row in test_list:      flag = True      # checking for all elements in list    for ele in sub_list:        if ele not in row:            flag = False      if flag:        res.append(row)  # printing resultprint("Rows with list elements : " + str(res))
Output:
The original list is : [[7, 6, 3, 2], [5, 6], [2, 1, 8], [6, 1, 2]]Rows with list elements : [[2, 1, 8], [6, 1, 2]]
Method #2 : Using all() + list comprehension
In this, all elements for presence as tested using all(), list comprehension is used as a one-liner to perform the task of iterating through rows.
Python3
# Python3 code to demonstrate working of # Rows with all List elements# Using all() + list comprehension  # initializing listtest_list = [[7, 6, 3, 2], [5, 6], [2, 1, 8], [6, 1, 2]]  # printing original listprint("The original list is : " + str(test_list))  # initializing list  sub_list = [1, 2]  # testing elements presence using all()res = [row for row in test_list if all(ele in row for ele in sub_list)]          # printing result print("Rows with list elements : " + str(res))
Output:
The original list is : [[7, 6, 3, 2], [5, 6], [2, 1, 8], [6, 1, 2]]Rows with list elements : [[2, 1, 8], [6, 1, 2]]
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
Matplotlib.pyplot.yticks() in Python

12 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface.
The annotate() function in pyplot module of matplotlib library is used to get and set the current tick locations and labels of the y-axis.
Syntax: matplotlib.pyplot.yticks(ticks=None, labels=None, **kwargs)
Parameters: This method accept the following parameters that are described below:
ticks: This parameter is the list of xtick locations. and an optional parameter. If an empty list is passed as an argument then it will removes all xticks
labels: This parameter contains labels to place at the given ticks locations. And it is an optional parameter.
**kwargs: This parameter is Text properties that is used to control the appearance of the labels.
Returns: This returns the following:
locs :This returns the list of ytick locations.
labels :This returns the list of ylabel Text objects.
The resultant is (locs, labels)
Below examples illustrate the matplotlib.pyplot.yticks() function in matplotlib.pyplot:
Example #1:
# Implementation of matplotlib.pyplot.yticks()# function  import numpy as npimport matplotlib.pyplot as plt    # values of x and y axes valx = [30, 35, 50, 5, 10, 40, 45, 15, 20, 25] valy = [1, 4, 3, 2, 7, 6, 9, 8, 10, 5]     plt.plot(valx, valy) plt.xlabel('X-axis') plt.ylabel('Y-axis')     plt.xticks(np.arange(0, 60, 5)) plt.yticks(np.arange(0, 15, 1)) plt.show() 
Output:
Example #2:
#Implementation of matplotlib.pyplot.yticks() # function   import matplotlib.pyplot as plt   from mpl_toolkits.axes_grid1.inset_locator import inset_axes, zoomed_inset_axes      def get_demo_image():    from matplotlib.cbook import get_sample_data    import numpy as np    f = get_sample_data("axes_grid/bivariate_normal.npy",                        asfileobj=False)    z = np.load(f)    # z is a numpy array of 15x15    return z, (3, 19, 4, 13)      fig, ax = plt.subplots(figsize=[5, 4])   Z, extent = get_demo_image()   ax.set(aspect=1,       xlim=(0, 65),       ylim=(0, 50))      axins = zoomed_inset_axes(ax, zoom=2, loc='upper right')im = axins.imshow(Z, extent=extent, interpolation="nearest",                  origin="upper")   plt.xlabel('X-axis') plt.ylabel('Y-axis')   plt.yticks(visible=False)      plt.show() 
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Python getpass Module

There are two functions defined in getpass module of Python’s standard library. They are useful whenever a terminal based application needs to be executed only after validating user credentials.
This function prompts the user to enter a password. By default the keys entered by user in the terminal are not echoed. Also the default prompt that appears on terminal is ‘password’ which can be customized by providing a string as parameter.
In following example, Python prompt is invoked from Command prompt terminal on Windows. The password entered is not echoed in the terminal.
C:\python36>python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import getpass
>>> pwd=getpass.getpass("enter pssword:")
enter pssword:
>>> pwd
'admin'
However, if IDLE software is used for interactive session of Python, it doesn’t provide echo free input. Hence password entered is echoed.
This function returns login name of the user.
>>> getpass.getuser()
'acer'
Java Program to Count trailing zeroes in factorial of a number

14 Jun, 2022
Given an integer n, write a function that returns count of trailing zeroes in n!.  Examples :
Input: n = 5
Output: 1 
Factorial of 5 is 120 which has one trailing 0.

Input: n = 20
Output: 4
Factorial of 20 is 2432902008176640000 which has
4 trailing zeroes.

Input: n = 100
Output: 24
Trailing 0s in n! = Count of 5s in prime factors of n!
                  = floor(n/5) + floor(n/25) + floor(n/125) + ....
Java
// Java program to count// trailing 0s in n!import java.io.*; class GFG {    // Function to return trailing    // 0s in factorial of n    static int findTrailingZeros(int n)    {        // Initialize result        int count = 0;         // Keep dividing n by powers        // of 5 and update count        for (int i = 5; n / i >= 1; i *= 5)            count += n / i;         return count;    }     // Driver Code    public static void main(String[] args)    {        int n = 100;        System.out.println("Count of trailing 0s in "                          + n + "! is " + findTrailingZeros(n));    }} // This code is contributed by Pramod Kumar
Count of trailing 0s in 100! is 24
Time Complexity:  O(log5n)
Auxiliary Space: O(1)
Please refer complete article on Count trailing zeroes in factorial of a number for more details!
chandramauliguptach
Java Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to set background color for an elements using jQuery ?

31 Dec, 2020
In this article, we will set the background color for an element using jQuery. To add the background color, we use css() method. The css() method in JQuery is used to change style property of the selected element. The css() in JQuery can be used in different ways. The css() method can be used to check the present value of the property for the selected element.
Syntax:
$(selector).css(property)
Return value: It will return the value of the property for the selected element. 
Example:
HTML
<!DOCTYPE html><html lang="en">  <head>    <title>        How to set background color        for an elements using jQuery?    </title>      <!-- Import jQuery cdn library -->    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>      <script>        $(document).ready(function () {            $("button").click(function () {                $("p").add("span").add("input")                    .css("background", "green");            });        });    </script></head>  <body style="text-align: center;">    <h1 style="color: green;">        GeeksforGeeks    </h1>      <h3>        How to set background color        for an elements using jQuery?    </h3>      <p>GeeksforGeeks computer science portal</p>    <br>      <span>GeeksforGeeks</span>    <br><br>      <input type="text">    <br><br>      <button>Click Here!</button></body>  </html>
Output:
Before Click Button:
After Click Button:
CSS-Misc
HTML-Misc
jQuery-Misc
CSS
HTML
JQuery
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Types of CSS (Cascading Style Sheet)
How to set space between the flexbox ?
How to position a div at the bottom of its container using CSS?
How to Upload Image into Database and Display it using PHP ?
Design a Tribute Page using HTML & CSS
REST API (Introduction)
Hide or show elements in HTML using display property
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
Design a Tribute Page using HTML & CSS
How to validate the path with the PowerShell function parameter?

To validate the file or folder path inside the PowerShell function parameter, we need to use the ValidateScript command. Generally, we write the script as below to validate the path.
function Validate-Path{
   param(
      [parameter(Mandatory)]
      [String]$Path
   )
   if(Test-Path $Path) {Write-Output "Path is valid"}
   else{Write-Output "Path is invalid"}
}
PS C:\> Validate-Path -Path C:\Temp
Path is valid
We can add similar functionality inside the function parameter with the validatescript argument so the script will throw the error initially at the parameters check. See below,
function Validate-Path{
   param(
      [parameter(Mandatory)]
      [ValidateScript({
      if(Test-Path $_){$true}
         else{throw "Path $_ is not valid"}
      })]
      [String]$Path
   )
   Write-Output "Executing Script further"
}
PS C:\> Validate-Path -Path C:\Temp
Executing Script further
PS C:\> Validate-Path -Path C:\Temp223
Validate-Path : Cannot validate argument on parameter 'Path'. Path C:\Temp223 is not valid
At line:1 char:21
+ Validate-Path -Path C:\Temp223
+ ~~~~~~~~~~
   + CategoryInfo : InvalidData: (:) [Validate-Path], ParameterBindingValidationException
   + FullyQualifiedErrorId : ParameterArgumentValidationError,Validate-Path
In the above example, if the path is valid, the script will continue execution but if the path is not valid then it will throw an exception and the script is terminated.
Delete only some rows from a table based on a condition in MySQL

Let us first create a table −
mysql> create table DemoTable
   -> (
   -> Id int,
   -> Name varchar(20)
   -> );
Query OK, 0 rows affected (0.60 sec)
Insert some records in the table using insert command:
Insert some records in the table using insert command:
mysql> insert into DemoTable values(100,'Bob');
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable values(101,'Chris');
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable values(102,'David');
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable values(103,'Sam');
Query OK, 1 row affected (0.08 sec)
mysql> insert into DemoTable values(104,'Carol');
Query OK, 1 row affected (0.10 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------+-------+
| Id   | Name  |
+------+-------+
| 100  | Bob   |
| 101  | Chris |
| 102  | David |
| 103  | Sam   |
| 104  | Carol |
+------+-------+
5 rows in set (0.00 sec)
Following is the query to delete only limited rows from a table −
mysql> delete from DemoTable
   -> where Id > 102;
Query OK, 2 rows affected (0.10 sec)
Let us check the table records once again −
mysql> select *from DemoTable;
This will produce the following output −
+------+-------+
| Id   | Name  |
+------+-------+
| 100  | Bob   |
| 101  | Chris |
| 102  | David |
+------+-------+
3 rows in set (0.00 sec)
C++ Map Library - insert() Function

The C++ function std::map::insert() extends container by inserting new element in map. This function increases container size by one.
Following is the declaration for std::map::insert() function form std::map header.
pair<iterator,bool> insert (const value_type& val);

pair<iterator,bool> insert (const value_type& val);

val − value to be inserted.
Returns a pair consisting of bool to indicate whether insertion is happened or not and returns an iterator to the newly inserted element.
This member function doesn't throw exception.
Logarithmic i.e. O(log n)
The following example shows the usage of std::map::insert() function.
#include <iostream>
#include <map>

using namespace std;

int main(void) {
   map<char, int> m = {
            {'a', 1},
            {'b', 2},
            {'c', 3},
            };

   m.insert(pair<char, int>('d', 4));
   m.insert(pair<char, int>('e', 5));

   cout << "Map contains following elements" << endl;

   for (auto it = m.begin(); it != m.end(); ++it)
      cout << it->first << " = " << it->second << endl;

   return 0;
}
Let us compile and run the above program, this will produce the following result −
Map contains following elements
a = 1
b = 2
c = 3
d = 4
e = 5

 Print
 Add Notes
 Bookmark this page
How do I kill all the processes in MySQL “show processlist”?

We can kill the processes with the help of the ‘kill’ command. However, you need to kill those processes one by one, since MySQL does not have any massive kill command.
To check how many processes exist, use ‘show processlist’
mysql> show processlist;
The following is the output.
+----+-----------------+-----------------+------+---------+------+------------------------+------------------+
| Id | User            | Host            | db   | Command | Time | State                  | Info             |
+----+-----------------+-----------------+------+---------+------+------------------------+------------------+
|  4 | event_scheduler | localhost       | NULL | Daemon  | 7986 | Waiting on empty queue | NULL             |
|  8 | root            | localhost:65180 | test | Query   |    0 | starting               | show processlist |
+----+-----------------+-----------------+------+---------+------+------------------------+------------------+
2 rows in set (0.00 sec)

To kill a process which have been active for more than 10 seconds, the following is the query. Here, we are killing a process with Id “4”
mysql> select concat('kill ',4,';')
   -> from information_schema.processlist
   ->  where TIME > 10;
Here is the output.
+-----------------------+once;

| concat('kill ',4,';') |
+-----------------------+
| kill 4;               |
+-----------------------+
1 row in set (0.00 sec)

As an alterbative, you can still try the following MySQL query to kill all the processes.
mysql -e "show full processlist;" -ss | awk '{print "KILL "$1";"}'| mysql
Dart Programming - Interfaces

An interface defines the syntax that any entity must adhere to. Interfaces define a set of methods available on an object. Dart does not have a syntax for declaring interfaces. Class declarations are themselves interfaces in Dart.
Classes should use the implements keyword to be able to use an interface.  It is mandatory for the implementing class to provide a concrete implementation of all the functions of the implemented interface. In other words, a class must redefine every function in the interface it wishes to implement.
class identifier implements interface_name

In the following program, we are declaring a class Printer. The ConsolePrinter class implements the implicit interface declaration for the Printer class. The main function creates an object of the ConsolePrinter class using the new keyword. This object is used to invoke the function print_data defined in the ConsolePrinter class.
void main() { 
   ConsolePrinter cp= new ConsolePrinter(); 
   cp.print_data(); 
}  
class Printer { 
   void print_data() { 
      print("__________Printing Data__________"); 
   } 
}  
class ConsolePrinter implements Printer { 
   void print_data() {  
      print("__________Printing to Console__________"); 
   } 
} 
It should produce the following output −
__________Printing to Console__________

A class can implement multiple interfaces. The interfaces are separated by a comma. The syntax for the same is given below −
class identifier implements interface-1,interface_2,interface_4.......

The following example shows how you can implement multiple interfaces in Dart −
void main() { 
   Calculator c = new Calculator(); 
   print("The gross total : ${c.ret_tot()}"); 
   print("Discount :${c.ret_dis()}"); 
}  
class Calculate_Total { 
   int ret_tot() {} 
}  
class Calculate_Discount { 
   int ret_dis() {} 
}
class Calculator  implements Calculate_Total,Calculate_Discount { 
   int ret_tot() { 
      return 1000; 
   } 
   int ret_dis() { 
      return 50; 
   } 
}
It should produce the following output −
The gross total: 1000 
Discount:50 


    44 Lectures 
     4.5 hours 

 Sriyank Siddhartha

    34 Lectures 
     4 hours 

 Sriyank Siddhartha

    69 Lectures 
     4 hours 

 Frahaan Hussain

    117 Lectures 
     10 hours 

 Frahaan Hussain

    22 Lectures 
     1.5 hours 

 Pranjal Srivastava

    34 Lectures 
     3 hours 

 Pranjal Srivastava
 Print
 Add Notes
 Bookmark this page
\nolimits - Tex Command

\nolimits - Used to change the default placement of limits; only allowed on items of class  OP.
{ \nolimits}
\nolimits command is used to change the default placement of limits; only allowed on items of class  OP.

\sum_{k=1}^n a_k

∑k=1nak


\sum\nolimits_{k=1}^n a_k

∑k=1nak



\sum_{k=1}^n a_k

∑k=1nak


\sum_{k=1}^n a_k
\sum\nolimits_{k=1}^n a_k

∑k=1nak


\sum\nolimits_{k=1}^n a_k

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page