code-rag-bench/online-tutorials huggingface dataset:
Python PIL | Image.show() method

04 Mar, 2022
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The Image module provides a class with the same name which is used to represent a PIL image. The module also provides a number of factory functions, including functions to load images from files, and to create new images.Image.show() Displays this image. This method is mainly intended for debugging purposes. On Unix platforms, this method saves the image to a temporary PPM file, and calls the xv utility. On Windows, it saves the image to a temporary BMP file, and uses the standard BMP display utility to show it (usually Paint). 
Syntax: Image.show(title=None, command=None) Parameters: title – Optional title to use for the image window, where possible.command – command used to show the image Return Type = The assigned path image will open.  
Image Used:  
 
Python3
# importing Image class from PIL packagefrom PIL import Image # creating a objectim = Image.open(r"C:\Users\System-Pc\Desktop\home.png") im.show()
Output:  
Another example: opening image with show()using .jpg extension . Image Used:  
 
Python3
# importing Image class from PIL packagefrom PIL import Image # creating a objectim = Image.open(r"C:\Users\System-Pc\Desktop\tree.jpg") im.show()
Output:  
 
surinderdawra388
spi3lot
Python-pil
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python – Kolmogorov-Smirnov Distribution in Statistics

10 Jan, 2020
scipy.stats.kstwobign() is Kolmogorov-Smirnov two-sided test for large N test that is defined with a standard format and some shape parameters to complete its specification. It is a statistical test that measures the maximum absolute distance of the theoretical CDF from the empirical CDF.
Parameters :
q : lower and upper tail probabilityx : quantilesloc : [optional]location parameter. Default = 0scale : [optional]scale parameter. Default = 1size : [tuple of ints, optional] shape or random variates.
Results : kstwobign continuous random variable
Code #1 : Creating kstwobign continuous random variable
# importing library  from scipy.stats import kstwobign      numargs = kstwobign.numargs a, b = 4.32, 3.18rv = kstwobign(a, b)     print ("RV : \n", rv)    
Output :
RV : 
 scipy.stats._distn_infrastructure.rv_frozen object at 0x000002A9D54959C8

Code #2 : kstwobign continuous variates and probability distribution
import numpy as np quantile = np.arange (0.01, 1, 0.1)   # Random Variates R = kstwobign.rvs(a, b, scale = 2, size = 10) print ("Random Variates : \n", R) 
Output :
Random Variates : 
 [3.88510141 3.48394857 3.66124797 3.88484201 3.86533511 3.21176073
 4.10238585 3.42397866 3.85111721 4.36433596]

Code #3 : Graphical Representation.
import numpy as np import matplotlib.pyplot as plt      distribution = np.linspace(0, np.minimum(rv.dist.b, 3)) print("Distribution : \n", distribution)      plot = plt.plot(distribution, rv.pdf(distribution)) 
Output :
Distribution : 
 [0.         0.06122449 0.12244898 0.18367347 0.24489796 0.30612245
 0.36734694 0.42857143 0.48979592 0.55102041 0.6122449  0.67346939
 0.73469388 0.79591837 0.85714286 0.91836735 0.97959184 1.04081633
 1.10204082 1.16326531 1.2244898  1.28571429 1.34693878 1.40816327
 1.46938776 1.53061224 1.59183673 1.65306122 1.71428571 1.7755102
 1.83673469 1.89795918 1.95918367 2.02040816 2.08163265 2.14285714
 2.20408163 2.26530612 2.32653061 2.3877551  2.44897959 2.51020408
 2.57142857 2.63265306 2.69387755 2.75510204 2.81632653 2.87755102
 2.93877551 3.        ]
 
Code #4 : Varying Positional Arguments
import matplotlib.pyplot as plt import numpy as np      x = np.linspace(0, 5, 100)      # Varying positional arguments y1 = kstwobign .pdf(x, 1, 3) y2 = kstwobign .pdf(x, 1, 4) plt.plot(x, y1, "*", x, y2, "r--") 
Output :
Python scipy-stats-functions
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
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Convert integer to string in Python
Python | os.path.join() method
fprintf() in C

28 Oct, 2020
fprintf is used to print content in file instead of stdout console.
int fprintf(FILE *fptr, const char *str, ...);

Example: 
C
// C Program for the above approach  #include<stdio.h>int main(){    int i, n=2;    char str[50];       //open file sample.txt in write mode    FILE *fptr = fopen("sample.txt", "w");    if (fptr == NULL)    {        printf("Could not open file");        return 0;    }       for (i = 0; i < n; i++)    {        puts("Enter a name");        scanf("%[^\n]%*c", str);        fprintf(fptr,"%d.%s\n", i, str);    }    fclose(fptr);       return 0;}
Input: GeeksforGeeks
       GeeksQuiz
Output:  sample.txt file now having output as 
0. GeeksforGeeks
1. GeeksQuiz

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
subhankarh701
cpp-input-output
CPP-Library
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Centered triangular number in PL/SQL - GeeksforGeeks

31 Oct, 2018
Prerequisite – PL/SQL introductionIn PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations.
Given n and task is to find nth centered triangular number. A centered triangular number is a centered number that represents a triangle with a dot in the center and all other dots surrounding the center in successive triangular layers.Examples:
Input: n = 6 
Output: 64

Input: n = 10
Output: 166

The first few centered triangular number series are:1, 4, 10, 19, 31, 46, 64, 85, 109, 136, 166, 199, 235, 274, 316, 361, 409, 460...........................
Approachnth Term of centered triangular number is given by:


Below is the required implementation:
--PL/SQL Program to find the nth Centered triangular number -- declaration section DECLARE   x NUMBER;   n NUMBER;       --utility function   FUNCTION Centered_triangular_num(n IN NUMBER)     RETURN NUMBER   IS     z NUMBER;   BEGIN         --formula applying     z := (3 * n * n + 3 * n + 2) / 2;     RETURN z;   END;       --driver code   BEGIN     n := 3;     x := centered_triangular_num(n);     dbms_output.Put_line(x);     n := 12;     x := centered_trigunal_num(n);     dbms_output.Put_line(x);   END;   --End of program
Output:
19
235
References:https://en.wikipedia.org/wiki/Centered_triangular_number
SQL-PL/SQL
triangular-number
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
CTE in SQL
How to Update Multiple Columns in Single Update Statement in SQL?
SQL Interview Questions
Difference between DELETE, DROP and TRUNCATE
Difference between SQL and NoSQL
MySQL | Group_CONCAT() Function
What is Temporary Table in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL using Python
MySQL | Regular expressions (Regexp)
C++ Algorithm Library - for_each() Function

The C++ function std::algorithm::for_each() applies provided function on each element of the range.
Following is the declaration for std::algorithm::for_each() function form std::algorithm header.
template <class InputIterator, class Function>
Function for_each (InputIterator first, InputIterator last, Function fn);

first − Input iterator to the initial position.
first − Input iterator to the initial position.
last − Final iterator to the final position.
last − Final iterator to the final position.
fn − Unary function that accepts an element in the range as argument.
fn − Unary function that accepts an element in the range as argument.
Returns function fn.
Linear.
Throws exception if either function fn or an operation on an iterator throws exception.
Please note that invalid parameters cause undefined behavior.
The following example shows the usage of std::algorithm::for_each() function.
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int print_even(int n) {
   if (n % 2 == 0)
      cout << n << ' ';
}

int main(void) {
   vector<int> v = {1, 2, 3, 4, 5};

   cout << "Vector contains following even numebr" << endl;

   for_each(v.begin(), v.end(), print_even);

   cout << endl;

   return 0;
}
Let us compile and run the above program, this will produce the following result −
Vector contains following even numebr
2 4 

 Print
 Add Notes
 Bookmark this page
Java program to find if the given number is positive or negative

Read a number from the user using the Scanner class's method. check whether the given number is greater, lesser or, equal to 0. If it is greater given number is positive if the lesser given number is negative. the else given number is neither positive or negative.
import java.util.Scanner;

public class PositiveOrNegative {
   public static void main(String args[]){
      int num;
      System.out.println("Enter a number ::");
      Scanner sc = new Scanner(System.in);
      num = sc.nextInt();

      if (num > 0){
         System.out.println("Given number is a positive integer");
      } else if(num < 0){
         System.out.println("Given number is a negative integer");
      } else {
         System.out.println("Given number is neither positive nor negative integer");
      }
   }
}
Enter a number ::
55
Given number is a positive integer
Enter a number ::
-88
Given number is a negative integer
Scala - Files I/O

Scala is open to make use of any Java objects and java.io.File is one of the objects which can be used in Scala programming to read and write files.
The following is an example program to writing to a file.
import java.io._

object Demo {
   def main(args: Array[String]) {
      val writer = new PrintWriter(new File("test.txt" ))

      writer.write("Hello Scala")
      writer.close()
   }
}
Save the above program in Demo.scala. The following commands are used to compile and execute this program.
\>scalac Demo.scala
\>scala Demo

It will create a file named Demo.txt in the current directory, where the program is placed. The following is the content of that file.
Hello Scala

Sometime you need to read user input from the screen and then proceed for some further processing. Following example program shows you how to read input from the command line.
object Demo {
   def main(args: Array[String]) {
      print("Please enter your input : " )
      val line = Console.readLine
      
      println("Thanks, you just typed: " + line)
   }
}
Save the above program in Demo.scala. The following commands are used to compile and execute this program.
\>scalac Demo.scala
\>scala Demo

Please enter your input : Scala is great
Thanks, you just typed: Scala is great

Reading from files is really simple. You can use Scala's Source class and its companion object to read files. Following is the example which shows you how to read from "Demo.txt" file which we created earlier.
import scala.io.Source

object Demo {
   def main(args: Array[String]) {
      println("Following is the content read:" )

      Source.fromFile("Demo.txt" ).foreach { 
         print 
      }
   }
}
Save the above program in Demo.scala. The following commands are used to compile and execute this program.
\>scalac Demo.scala
\>scala Demo

Following is the content read:
Hello Scala


    82 Lectures 
     7 hours 

 Arnab Chakraborty

    23 Lectures 
     1.5 hours 

 Mukund Kumar Mishra

    52 Lectures 
     1.5 hours 

 Bigdata Engineer

    76 Lectures 
     5.5 hours 

 Bigdata Engineer

    69 Lectures 
     7.5 hours 

 Bigdata Engineer

    46 Lectures 
     4.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
How to find the number of levels in R for a factor column?

To find the number of levels in R for a factor column, we can use length function along with unique function. For example, if we have a data frame called df that contains a factor column X then we can find the number of levels in the factor column using the command −
length(unique(df$X))
Consider the below data frame −
 Live Demo
x1<-sample(c("A","B","C"),20,replace=TRUE)
y1<-sample(0:9,20,replace=TRUE)
df1<-data.frame(x1,y1)
df1
   x1 y1
1  C  8
2  B  9
3  B  2
4  A  7
5  A  8
6  C  4
7  B  0
8  C  3
9  B  3
10 A  5
11 A  8
12 B  0
13 A  6
14 C  2
15 A  4
16 B  7
17 A  9
18 B  1
19 B  3
20 A  5
Finding the number of levels in column x1 −
length(unique(df1$x1))
[1] 3
 Live Demo
x2<-sample(c("id1","id2","id3","id4"),20,replace=TRUE)
y2<-rnorm(20,1,0.05)
df2<-data.frame(x2,y2)
df2
    x2    y2
1  id2  1.0582275
2  id4  0.8763659
3  id4  1.0091340
4  id1  1.0087233
5  id1  1.0022543
6  id3  0.9682852
7  id3  0.9458475
8  id2  1.0329383
9  id3  0.9890525
10 id1  0.9814830
11 id4  0.9732973
12 id1  1.0644264
13 id3  0.9328492
14 id1  0.9064330
15 id2  0.9781466
16 id2  0.9633579
17 id1  0.9985626
18 id4  1.0428324
19 id4  1.0047497
20 id4  0.9717654
Finding the number of levels in column x2 −
length(unique(df2$x2))
[1] 4
What is the best way to break from nested loops in JavaScript?

The best way to break from nested loops is to use labels. A label can be used with break and continue to control the flow more precisely. A label is simply an identifier followed by a colon (:) that is applied to a statement or a block of code.
You can try to run the following code to implement Label with a break statement to break from nested loops −
Live Demo
<html>
   <body>
      <script>
         document.write("Entering the loop! <br /> ");
         outerloop:  // This is the label name

         for (var i = 0; i < 5; i++) {
            document.write("Outerloop: " + i + "<br />");
            innerloop:
            for(var j = 0; j < 5; j++) {
               if(j > 3 ) break ; // Quit the innermost loop
               if(i == 2) break innerloop; // Do the same thing
               if(i == 4) break outerloop; // Quit the outer loop
               document.write("Innerloop: " + j + " <br />");
            }
         }
         document.write("Exiting the loop!<br /> ");
      </script>
   </body>
</html>
Mongoose | findById() Function - GeeksforGeeks

20 May, 2020
The findById() function is used to find a single document by its _id field. The _id field is cast based on the Schema before sending the command.
Installation of mongoose module:
You can visit the link Install mongoose module. You can install this package by using this command.npm install mongooseAfter installing mongoose module, you can check your mongoose version in command prompt using the command.npm version mongooseAfter that, you can just create a folder and add a file for example index.js, To run this file you need to run the following command.node index.js
You can visit the link Install mongoose module. You can install this package by using this command.npm install mongoose
npm install mongoose
After installing mongoose module, you can check your mongoose version in command prompt using the command.npm version mongoose
npm version mongoose
After that, you can just create a folder and add a file for example index.js, To run this file you need to run the following command.node index.js
node index.js
Filename: index.js
const mongoose = require('mongoose');  // Database connectionmongoose.connect('mongodb://127.0.0.1:27017/geeksforgeeks', {    useNewUrlParser: true,    useCreateIndex: true,    useUnifiedTopology: true});  // User modelconst User = mongoose.model('User', {    name: { type: String },    age: { type: Number }});  // Finding a document whose id=5ebadc45a99bde77b2efb20evar id = '5ebadc45a99bde77b2efb20e';User.findById(id, function (err, docs) {    if (err){        console.log(err);    }    else{        console.log("Result : ", docs);    }});
Steps to run the program:
The project structure will look like this:Make sure you have install mongoose module using following command:npm install mongooseBelow is the sample data in the database before the function is executed, You can use any GUI tool or terminal to see the database, like we have used Robo3T GUI tool as shown below:Run index.js file using below command:node index.js
The project structure will look like this:
Make sure you have install mongoose module using following command:npm install mongoose
npm install mongoose
Below is the sample data in the database before the function is executed, You can use any GUI tool or terminal to see the database, like we have used Robo3T GUI tool as shown below:
Run index.js file using below command:node index.js
node index.js
So this is how you can use the mongoose findById() function to find a single document by its _id field.
Mongoose
MongoDB
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Spring Boot JpaRepository with Example
MongoDB - Check the existence of the fields in the specified collection
Aggregation in MongoDB
MongoDB - db.collection.Find() Method
Mongoose Populate() Method
Installation of Node.js on Linux
Node.js fs.readFileSync() Method
How to update Node.js and NPM to next version ?
Node.js fs.readFile() Method
Node.js fs.writeFile() Method
Java Program to convert ASCII code to String

To convert ASCII to string, use the toString() method. Using this method will return the associated character.
Let’s say we have the following int value, which works as ASCII for us.
int asciiVal = 89;
Now, use the toString() method.
String str = new Character((char) asciiVal).toString();
 Live Demo
public class Demo {
   public static void main(String []args) {
      int asciiVal = 87;
      String str = new Character((char) asciiVal).toString();
      System.out.println(str);
   }
}
W
Tk - Selection Widgets

Selection widgets are used to select different options in a Tk application. The list of available selection widgets are as shown below.
Widget that has a set of on/off buttons and labels, one of which may be selected.
Widget that has a set of on/off buttons and labels, many of which may be selected.
Widget that acts as holder for menu items.
Widget that displays a list of cells, one or more of which may be selected.
A simple Tk example is shown below using selection widgets −
#!/usr/bin/wish

grid [frame .gender ]
grid [label .label1  -text "Male" -textvariable myLabel1 ] 
grid [radiobutton .gender.maleBtn -text "Male"   -variable gender -value "Male"
   -command "set  myLabel1 Male"] -row 1 -column 2
grid [radiobutton .gender.femaleBtn -text "Female" -variable gender -value "Female"
   -command "set  myLabel1 Female"] -row 1 -column 3
.gender.maleBtn select
grid [label .myLabel2  -text "Range 1 not selected" -textvariable myLabelValue2 ] 
grid [checkbutton .chk1 -text "Range 1" -variable occupied1 -command {if {$occupied1 } {
   set myLabelValue2 {Range 1 selected}
} else {
   set myLabelValue2 {Range 1 not selected}
} }]
proc setLabel {text} {
   .label configure -text $text 
}
When we run the above program, we will get the following output −
 Print
 Add Notes
 Bookmark this page
Merging subarrays in JavaScript

Suppose, we have an array of arrays that contains information about the name and email of some people like this −
const arr = [
   ["John", "johnsmith@mail.com", "john00@mail.com"],
   ["John", "johnnybravo@mail.com"],
   ["John", "johnsmith@mail.com", "john_newyork@mail.com"],
   ["Mary", "mary@mail.com"]
];
Each element of the array is a subarray of strings, where the first element is a name, and the rest of the elements are emails belonging to that name.
Now, we would like to merge these subarrays. Two subarrays definitely belong to the same person if there is some email that is common to both subarrays.
Note that even if two subarrays have the same name, they may belong to different people as people could have the same name.
A person can have any number of accounts initially, but all of their accounts definitely have the same name.
After merging the subarrays, we need to return them in the following format − the first element of each subarray is the name, and the rest of the elements are emails in sorted order. The subarrays themselves can be returned in any order.
Therefore, for the above array, the output should look like −
const output = [
   ["John", 'john00@mail.com', 'john_newyork@mail.com',
   'johnsmith@mail.com'],
   ["John", "johnnybravo@mail.com"],
   ["Mary", "mary@mail.com"]
];
The code for this will be −
const arr = [
   ["John", "johnsmith@mail.com", "john00@mail.com"],
   ["John", "johnnybravo@mail.com"],
   ["John", "johnsmith@mail.com", "john_newyork@mail.com"],
   ["Mary", "mary@mail.com"]
];
const recusiveMatch = (included, i, tmp, arr, res) => {
   for(let j = 1; j < arr[i].length; j += 1) {
      let currentEmail = arr[i][j];
      if(included.has(currentEmail)) continue;
      res.push(currentEmail);
      included.add(currentEmail);
      let currentAccountIndexes = tmp.get(currentEmail);
      for(let c = 0; c < currentAccountIndexes.length; c += 1) {
         let currentIndex = currentAccountIndexes[c];
         if(i !== currentIndex) {
            recusiveMatch(included, currentIndex, tmp, arr, res);
         }
      }
   }
};
const merge = (arr) => {
   const tmp = new Map(),
   included = new Set(),
   res = [];
   arr.forEach((account, i) => {
      for(let u = 1; u < account.length; u += 1) {
         let currentEMail = account[u];
         tmp.set(currentEMail, tmp.get(currentEMail) || []);
         tmp.get(currentEMail).push(i);
      }
   });
   arr.forEach((account, i) => {
      if(!included.has(arr[1])) {
         let u = [];
         recusiveMatch(included, i, tmp, arr, u);
         if(u.length) {
            res.push(u);
            u.sort();
            u.unshift(account[0]);
         }
      }
   });
   return res;
};
console.log(merge(arr));
And the output in the console will be −
[
   [
      'John',
      'john00@mail.com',
      'john_newyork@mail.com',
      'johnsmith@mail.com'
   ],
   [ 'John', 'johnnybravo@mail.com' ],
   [ 'Mary', 'mary@mail.com' ]
]
Dart Programming - continue Statement

The continue statement skips the subsequent statements in the current iteration and takes the control back to the beginning of the loop. Unlike the break statement, the continue statement doesn’t exit the loop. It terminates the current iteration and starts the subsequent iteration.
The following example shows how you can use the continue statement in Dart −
void main() { 
   var num = 0; 
   var count = 0; 
   
   for(num = 0;num<=20;num++) { 
      if (num % 2==0) { 
         continue; 
      } 
      count++; 
   } 
   print(" The count of odd values between 0 and 20 is: ${count}"); 
}  
The above example displays the number of even values between 0 and 20. The loop exits the current iteration if the number is even. This is achieved using the continue statement.
The following output is displayed on successful execution of the above code.
The count of odd values between 0 and 20 is: 10 


    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
JavaScript String concat() Method - GeeksforGeeks

05 Oct, 2021
Below is the example of the concat() Method Method.
Example:<script> // JavaScript to illustrate concat() function function func() {       // Original string     var str = 'Geeks';       // Joining the strings together     var value = str.concat(' for',' Geeks');     document.write(value);     } func(); </script> 
<script> // JavaScript to illustrate concat() function function func() {       // Original string     var str = 'Geeks';       // Joining the strings together     var value = str.concat(' for',' Geeks');     document.write(value);     } func(); </script> 
Output:Geeks for Geeks

Geeks for Geeks

str.concat() function is used to join two or more strings together in JavaScript.
Syntax:
str.concat(string2, string3, string4,......, stringN)
Arguments:The arguments to this function are the strings that need to be joined together. The number of arguments to this function is equal to the number of strings to be joined together.
Return value:This function returns a new string that is the combination of all the different strings passed to it as the argument.
Example for the above function is provided below:
Example 1:
print('It'.concat(' is',' a',' great',' day.'));

Output:
It is a great day.

In this example the function concat() joins together “It” with ” is”, ” a”, ” great”, “day.” to create a final string containing all the strings.
Code for the above function is provided below:
Program 1:
<script>// JavaScript to illustrate concat() functionfunction func() {      // Original string    var str = 'It';      // Joining the strings together    var value = str.concat(' is',' a',' great',' day.');    document.write(value);    }func();</script> 
Output:
It is a great day.

Supported Browsers:
Chrome 1 and above
Edge 12 and above
Firefox 1 and above
Internet Explorer 4 and above
Opera 4 and above
Safari 1 and above
ysachin2314
javascript-string
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to Open URL in New Tab using JavaScript ?
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
How to install the ext-curl extension with PHP 7 ? - GeeksforGeeks

06 Oct, 2021
The ext-curl CURL stands for client user, In Linux cURL is a PHP extension, that allows us to receive and send information via the URL syntax. And ext-curl is the extension in the latest PHP-7 which is loaded with some of the advanced features of the basic curls.
The following are the steps to add ext-curl extension in Ubuntu –
1. Update the Extension
sudo apt-get update
2. Install PHP-curl
sudo apt-get install php-curl
             OR
sudo apt-get install php7.0-curl
During this command the system while ask for your confirmation and if you have to install you have to press ‘y’ key
3. Restart the extension to avoid any problem in the future by the extension
sudo service apache2 restart
After, all the above steps your ext-curl PHP-7 is successfully installing and is ready to use.
gabaa406
how-to-install
PHP-Misc
Picked
How To
Installation Guide
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install FFmpeg on Windows?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Set Git Username and Password in GitBash?
How to create a nested RecyclerView in Android
How to Install Jupyter Notebook on MacOS?
Installation of Node.js on Linux
How to Install FFmpeg on Windows?
How to Install Pygame on Windows ?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Install Jupyter Notebook on MacOS?
GATE | GATE-CS-2001 | Question 41 - GeeksforGeeks

28 Jun, 2021
What is the minimum number of stacks of size n required to implement a queue of size n?(A) One(B) Two(C) Three(D) FourAnswer: (B)Explanation: A queue can be implemented using two stacks. Let queue to be implemented be q and stacks used to implement q be stack1 and stack2. q can be implemented in two ways: 
Method 1 (By making enQueue operation costly)This method makes sure that newly entered element is always at the top of stack 1, so that deQueue operation just pops from stack1. To put the element at top of stack1, stack2 is used.
enQueue(q, x)
  1) While stack1 is not empty, push everything from satck1 to stack2.
  2) Push x to stack1 (assuming size of stacks is unlimited).
  3) Push everything back to stack1.

dnQueue(q)
  1) If stack1 is empty then error
  2) Pop an item from stack1 and return it

Method 2 (By making deQueue operation costly)In this method, in en-queue operation, the new element is entered at the top of stack1. In de-queue operation, if stack2 is empty then all the elements are moved to stack2 and finally top of stack2 is returned.
enQueue(q,  x)
  1) Push x to stack1 (assuming size of stacks is unlimited).

deQueue(q)
  1) If both stacks are empty then error.
  2) If stack2 is empty
       While stack1 is not empty, push everything from satck1 to stack2.
  3) Pop the element from stack2 and return it.

Source: https://www.geeksforgeeks.org/queue-using-stacks/Quiz of this Question
GATE-CS-2001
GATE-GATE-CS-2001
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-CS-2006 | Question 47
GATE | GATE MOCK 2017 | Question 24
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
How to include inline JavaScript inside an HTML page?

JavaScript is used in HTML using the <script>...</script> or using External JavaScript file. Well, there’s another way through which you can include inline JavaScript inside an HTML page.
Generally, the HTML event attributes calls functions specified elsewhere in script tags. But, you can also add the JavaScript code directly to the onClick event tags.
Note: Adding inline JavaScript isn’t considered a good practice according to coding standards and shouldn’t be followed.
<p>
   <a href="#" onClick="alert('Hello World');">
      Click
   </a>
</p>
How to put the origin in the center of the figure with Matplotlib ? - GeeksforGeeks

08 Oct, 2021
In this article, we are going to discuss how to put the origin in the center of the figure using the matplotlib module. To put the origin at the center of the figure we use the spines module from the matplotlib module. Basically, spines are the lines connecting the axis tick marks and noting the boundaries of the data area. Under this module, we use set_position() method which sets the position of the spine which helps to set the origin in the center.
However, we can put the origin in the center of the figure without using set_position() method. The below graph is made without using set_position() method.
Example 1:
Python3
# import required modulesimport numpy as npimport matplotlib.pyplot as plt # assign coordinatesx = np.linspace(-np.pi, np.pi, 100)y = 2*np.sin(x) # depict illustrationplt.xlim(-np.pi, np.pi)plt.plot(x, y)plt.grid(True)plt.show()
Output:
The below graph is made with using set_position() method which helped to bring origin to the center.
Example 2:
Python3
# import required modulesimport numpy as npimport matplotlib.pyplot as plt # assign coordinatesx = np.linspace(-np.pi, np.pi, 100)y = 2*np.sin(x) # use set_positionax = plt.gca()ax.spines['top'].set_color('none')ax.spines['left'].set_position('zero')ax.spines['right'].set_color('none')ax.spines['bottom'].set_position('zero') # depict illustrationplt.xlim(-np.pi, np.pi)plt.plot(x, y)plt.grid(True)plt.show()
Output:
saurabh1990aror
Picked
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
Selecting rows in pandas DataFrame based on conditions
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Defaultdict in Python
Python OOPs Concepts
Python | os.path.join() method
Python | Pandas dataframe.groupby()
Python | Construct Cartesian Product Tuple list - GeeksforGeeks

03 Nov, 2019
Sometimes, while working with data, we need to create data as all possible pairs of containers. This type of application comes from web development domain. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using list comprehensionThis is one-liner way to perform this particular task. In this, we just shorten the task of loop in one line to generate all possible pairs of tuple with list elements.
# Python3 code to demonstrate working of# Construct Cartesian Product Tuple list# using list comprehension  # initialize list and tuple test_list = [1, 4, 6, 7]test_tup = (1, 3)  # printing original list and tuple print("The original list : " + str(test_list))print("The original tuple : " + str(test_tup))  # Construct Cartesian Product Tuple list# using list comprehensionres = [(a, b) for a in test_tup for b in test_list]  # printing resultprint("The Cartesian Product is : " + str(res))
The original list : [1, 4, 6, 7]The original tuple : (1, 3)The Cartesian Product is : [(1, 1), (1, 4), (1, 6), (1, 7), (3, 1), (3, 4), (3, 6), (3, 7)]
 
Method #2 : Using itertools.product()This task can also be performed using the single function which internally performs the task of returning the required Cartesian Product.
# Python3 code to demonstrate working of# Construct Cartesian Product Tuple list# using itertools.product()from itertools import product  # initialize list and tuple test_list = [1, 4, 6, 7]test_tup = (1, 3)  # printing original list and tuple print("The original list : " + str(test_list))print("The original tuple : " + str(test_tup))  # Construct Cartesian Product Tuple list# using itertools.product()res = list(product(test_tup, test_list))  # printing resultprint("The Cartesian Product is : " + str(res))
The original list : [1, 4, 6, 7]The original tuple : (1, 3)The Cartesian Product is : [(1, 1), (1, 4), (1, 6), (1, 7), (3, 1), (3, 4), (3, 6), (3, 7)]
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to convert an array of objects to an array of their primitive types in java?

Apache Commons provides a library named org.apache.commons.lang3 and, following is the maven dependency to add the library to your project.
<dependencies>
   <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <version>3.0</version>
   </dependency>
</dependencies>
This package provides a class named ArrayUtils. Using the toPrimitive() method of this class you can convert An object array to an array of primitive types:
import java.util.Arrays;
import org.apache.commons.lang3.ArrayUtils;

public class ArraysToPrimitives {
   public static void main(String args[]) {
      Integer[] myArray = {234, 76, 890, 27, 10, 63};
      int[] primitiveArray = ArrayUtils.toPrimitive(myArray);
      System.out.println(Arrays.toString(primitiveArray));
   }
}
[234, 76, 890, 27, 10, 63]
Docker - USER Instruction - GeeksforGeeks

28 Oct, 2020
By default, a Docker Container runs as a Root user. This poses a great security threat if you deploy your applications on a large scale inside Docker Containers. You can change or switch to a different user inside a Docker Container using the USER Instruction. For this, you first need to create a user and a group inside the Container.
In this article, we are going to use the USER instruction to switch the user inside the Container from Root to the one which we will create. To do so follow the below steps:
You can specify the instructions to create a new user and group and to switch the user both in the Dockerfile. For this example, we will simply create an Ubuntu Image and use the bash with a different user other than the Root user.
FROM ubuntu:latest
RUN apt-get -y update
RUN groupadd -r user && useradd -r -g user user
USER user


In the above dockerfile, we have pulled the base Image Ubuntu and updated it. We have created a new group called user and a new user inside the group with the same name. Using the USER option, we have then switched the user.
After creating the Dockerfile, we can now create the Docker Image using the Build command.
sudo docker build -t user-demo .


Use the Docker Run command to run the Container.
sudo docker run -it user-demo bash

You can now check that the default user and the group have now changed to the one we created in the Dockerfile using the id command.
id

To conclude, in this article we discussed how to use the USER instruction inside the Dockerfile to switch the Docker Container’s default user from Root to another user that we can create using the useradd and grouadd commands.
Docker Container
linux
Advanced Computer Subject
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Decision Tree
ML | Linear Regression
Python | Decision tree implementation
System Design Tutorial
Copying Files to and from Docker Containers
Decision Tree Introduction with example
Reinforcement learning
ML | Underfitting and Overfitting
KDD Process in Data Mining
ML | Label Encoding of datasets in Python
Maximum Bipartite Matching

The bipartite matching is a set of edges in a graph is chosen in such a way, that no two edges in that set will share an endpoint. The maximum matching is matching the maximum number of edges.
When the maximum match is found, we cannot add another edge. If one edge is added to the maximum matched graph, it is no longer a matching. For a bipartite graph, there can be more than one maximum matching is possible.
Input:
The adjacency matrix.
0 1 1 0 0 0
1 0 0 1 0 0
0 0 1 0 0 0
0 0 1 1 0 0
0 0 0 0 0 0
0 0 0 0 0 1

Output:
Maximum number of applicants matching for job: 5
bipartiteMatch(u, visited, assign)
Input: Starting node, visited list to keep track, assign the list to assign node with another node.
Output − Returns true when a matching for vertex u is possible.
Begin
   for all vertex v, which are adjacent with u, do
      if v is not visited, then
         mark v as visited
         if v is not assigned, or bipartiteMatch(assign[v], visited, assign) is true, then
            assign[v] := u
            return true
   done
   return false
End
maxMatch(graph)
Input − The given graph.
Output − The maximum number of the match.
Begin
   initially no vertex is assigned
   count := 0
   for all applicant u in M, do
      make all node as unvisited
      if bipartiteMatch(u, visited, assign), then
         increase count by 1
   done
End
#include <iostream>
#define M 6
#define N 6
using namespace std;

bool bipartiteGraph[M][N] = {    //A graph with M applicant and N jobs
   {0, 1, 1, 0, 0, 0},
   {1, 0, 0, 1, 0, 0},
   {0, 0, 1, 0, 0, 0},
   {0, 0, 1, 1, 0, 0},
   {0, 0, 0, 0, 0, 0},
   {0, 0, 0, 0, 0, 1}
};

bool bipartiteMatch(int u, bool visited[], int assign[]) {
   for (int v = 0; v < N; v++) {    //for all jobs 0 to N-1
      if (bipartiteGraph[u][v] && !visited[v]) {    //when job v is not visited and u is interested
         visited[v] = true;    //mark as job v is visited
         //when v is not assigned or previously assigned
         if (assign[v] < 0 || bipartiteMatch(assign[v], visited, assign)) {
            assign[v] = u;    //assign job v to applicant u
            return true;
         }
      }
   }
   return false;
}

int maxMatch() {
   int assign[N];    //an array to track which job is assigned to which applicant
   for(int i = 0; i<N; i++)
      assign[i] = -1;    //initially set all jobs are available
   int jobCount = 0;

   for (int u = 0; u < M; u++) {    //for all applicants
      bool visited[N];
      for(int i = 0; i<N; i++)
         visited[i] = false;    //initially no jobs are visited
      if (bipartiteMatch(u, visited, assign))    //when u get a job
         jobCount++;
   }
   return jobCount;
}

int main() {
   cout << "Maximum number of applicants matching for job: " << maxMatch();
}
Maximum number of applicants matching for job: 5
Python - Implementation of Polynomial Regression

Polynomial Regression is a form of linear regression in which the relationship between the independent variable x and dependent variable y is modeled as an nth degree polynomial. Polynomial regression fits a nonlinear relationship between the value of x and the corresponding conditional mean of y, denoted E(y |x)
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
datas = pd.read_csv('data.csv')
datas
# divide the dataset into two components
X = datas.iloc[:, 1:2].values
y = datas.iloc[:, 2].values
# Fitting Linear Regression to the dataset
from sklearn.linear_model import LinearRegression
lin = LinearRegression()
lin.fit(X, y)
# Fitting Polynomial Regression to the dataset
from sklearn.preprocessing import PolynomialFeatures
poly = PolynomialFeatures(degree = 4)
X_poly = poly.fit_transform(X)
poly.fit(X_poly, y)
lin2 = LinearRegression()
lin2.fit(X_poly, y)
# Visualising the Linear Regression results
plt.scatter(X, y, color = 'blue')
plt.plot(X, lin.predict(X), color = 'red')
plt.title('Linear Regression')
plt.xlabel('Temperature')
plt.ylabel('Pressure')
plt.show()
# Visualising the Polynomial Regression results
plt.scatter(X, y, color = 'blue')
plt.plot(X, lin2.predict(poly.fit_transform(X)), color = 'red')
plt.title('Polynomial Regression')
plt.xlabel('Temperature')
plt.ylabel('Pressure')
plt.show()
# Predicting a new result with Linear Regression
lin.predict(110.0)
# Predicting a new result with Polynomial Regression
lin2.predict(poly.fit_transform(110.0))
How to read an input value from a JTextField and add to a JList in Java?

A JList is a subclass of JComponent class that allows the user to choose either a single selection or multiple selections. A JList class itself does not support scrollbar. In order to add scrollbar, we have to use JScrollPane class together with the JList class. The JScrollPane then manages a scrollbar automatically. A DefaultListModel class provides a simple implementation of a list model, which can be used to manage items displayed by a JList control. We can add items or elements to a JList by using addElement() method of DefaultListModel class. We can also add items or elements to a JList by reading an input value from a text field.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class JTextfieldToJListTest extends JFrame {
   private DefaultListModel model;
   private JList list;
   private JTextField jtf;
   public JTextfieldToJListTest() {
      setTitle("JTextfieldToJList Test");
      model = new DefaultListModel();
      jtf = new JTextField("Type something and Hit Enter");
      jtf.addMouseListener(new MouseAdapter() {
         public void mouseClicked(MouseEvent me) {
            jtf.setText("");
         }
      });
      list = new JList(model);
      list.setBackground(Color.lightGray);
      jtf.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent event) {
            model.addElement(jtf.getText());
            JOptionPane.showMessageDialog(null, jtf.getText());
            jtf.setText("Type something and Hit Enter");
         }
      });
      add(jtf,BorderLayout.NORTH);
      add(new JScrollPane(list),BorderLayout.CENTER);
      setSize(375, 250);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setLocationRelativeTo(null);
      setVisible(true);
   }
   public static void main(String[] args) {
      new JTextfieldToJListTest();
   }
}
How to implement JavaFX event handling using lambda in Java? 


JavaFX Button class provides the setOnAction() method that can be used to set an action for the button click event. An EventHandler is a functional interface and holds only one method is the handle() method.
@FunctionalInterface
public interface EventHandler<T extends Event> extends EventListener
In the below example, we can able to implement event handling of JavaFX by using a lambda expression.
import javafx.application.*;
import javafx.beans.property.*;
import javafx.event.*;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.*;

public class LambdaWithJavaFxTest extends Application {
   public static void main(String[] args) {
      Application.launch(args);
   }
   @Override
   public void start(Stage stage) throws Exception {
      BorderPane root = new BorderPane();
      ToggleButton button = new ToggleButton("Click");

      final StringProperty btnText = button.textProperty();
      button.setOnAction((event) -> {    // lambda expression
         ToggleButton source = (ToggleButton) event.getSource();
         if(source.isSelected()) {
            btnText.set("Clicked!");
         } else {
            btnText.set("Click!");
         }
      });
      root.setCenter(button);  
      Scene scene = new Scene(root);
      stage.setScene(scene);
      stage.setWidth(300);
      stage.setHeight(250);
      stage.show();
   }
}
logout - Unix, Linux Command

logout - session-logout.
session-logout[options]  
session-logout[options] 
logout command allows you to programmatically logout from your session. 
causes the session manager to take the requested action immediately.
Example-1:
To logout from current user session:
$ logout
output:
no output on screen, current user session will be logged out.

    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Python program to find start and end indices of all Words in a String - GeeksforGeeks

11 Oct, 2020
Given a String, return all the start indices and end indices of each word.
Examples:
Input : test_str = ‘ Geekforgeeks is Best’ Output : [(1, 12), (16, 17), (19, 22)] Explanation : “Best” Starts at 19th index, and ends at 22nd index.
Input : test_str = ‘ Geekforgeeks is Best’ Output : [(1, 12), (17, 18), (20, 23)] Explanation : “Best” Starts at 20th index, and ends at 23rd index. 
Method : Using list comprehension + regex + finditer()
In this, we extract all the words using finditer() and regex, to get initial and end index, we use start() and end() and encapsulate using list comprehension in form of tuple list.
Python3
# Python3 code to demonstrate working of# Word Ranges in String# Using list comprehension + regex + finditer()import re  # initializing stringtest_str = ' Geekforgeeks   is Best    for  geeks'  # printing original stringprint("The original string is : " + str(test_str))  # regex to get words, loop to get each start and end indexres = [(ele.start(), ele.end() - 1) for ele in re.finditer(r'\S+', test_str)]  # printing resultprint("Word Ranges are : " + str(res))
The original string is :  Geekforgeeks   is Best    for  geeks
Word Ranges are : [(1, 12), (16, 17), (19, 22), (27, 29), (32, 36)]

Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Python program to convert a list to string
Defaultdict in Python
Python | Split string into list of characters
Python | Get dictionary keys as a list
Python | Convert a list to dictionary