code-rag-bench/online-tutorials huggingface dataset:
How to create a WebView in iOS/iPhone?

To create a web view in iOS we'll use Webkit framework of iOS. Previously UIWebView was used to create web views but that has been deprecated now.
We'll use WebKit View in this project.
Create a new project and from object library drag and drop webKit View to the ViewController.
Create a new project and from object library drag and drop webKit View to the ViewController.
Give constraints as per your requirement.
Give constraints as per your requirement.
Make an outlet connection to the webKit in ViewController.
Make an outlet connection to the webKit in ViewController.
We'll open facebook in this example using the code below.
We'll open facebook in this example using the code below.
let url = URL(string: "https://www.facebook.com")
override func viewDidLoad() {
   super.viewDidLoad()
   let request = URLRequest.init(url: self.url!)
   self.wbView.load(request)
}
Now finally we need to add a key App Transport Security Settings in info.plist.
Open your info.plist file as source code and paste the following code −
<key>NSAppTransportSecurity</key>
<dict>
<!--Include to allow all connections (DANGER)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Note − In devices running iOS 10.0 or later we also need to add Photo library usage description and Camera usage description in the info.plist
NSPhotoLibraryUsageDescription
NSCameraUsageDescription
This is how the app looks when running on a simulator.
C# | Convert Queue To array - GeeksforGeeks

01 Feb, 2019
Queue represents a first-in, first out collection of object. It is used when you need a first-in, first-out access of items. When you add an item in the list, it is called enqueue, and when you remove an item, it is called deque. Queue.ToArray Method is used to copy the Queue elements to a new array.
Properties:
Enqueue adds an element to the end of the Queue.
Dequeue removes the oldest element from the start of the Queue.
Peek returns the oldest element that is at the start of the Queue but does not remove it from the Queue.
The capacity of a Queue is the number of elements the Queue can hold.
As elements are added to a Queue, the capacity is automatically increased as required by reallocating the internal array.
Queue accepts null as a valid value for reference types and allows duplicate elements.
Syntax :
public virtual object[] ToArray();

Below given are some examples to understand the implementation in a better way:
Example 1:
// C# code to Convert Queue to arrayusing System;using System.Collections.Generic;  class GFG {      // Driver code    public static void Main()    {          // Creating a Queue of strings        Queue<string> myQueue = new Queue<string>();          // Inserting the elements into the Queue        myQueue.Enqueue("Geeks");        myQueue.Enqueue("Geeks Classes");        myQueue.Enqueue("Noida");        myQueue.Enqueue("Data Structures");        myQueue.Enqueue("GeeksforGeeks");          // Converting the Queue into array        String[] arr = myQueue.ToArray();          // Displaying the elements in array        foreach(string str in arr)        {            Console.WriteLine(str);        }    }}
Geeks
Geeks Classes
Noida
Data Structures
GeeksforGeeks

Example 2:
// C# code to Convert Queue to arrayusing System;using System.Collections.Generic;  class GFG {      // Driver code    public static void Main()    {          // Creating a Queue of Integers        Queue<int> myQueue = new Queue<int>();          // Inserting the elements into the Queue        myQueue.Enqueue(2);        myQueue.Enqueue(3);        myQueue.Enqueue(4);        myQueue.Enqueue(5);        myQueue.Enqueue(6);          // Converting the Queue into array        int[] arr = myQueue.ToArray();          // Displaying the elements in array        foreach(int i in arr)        {            Console.WriteLine(i);        }    }}
2
3
4
5
6

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.queue-1.toarray?view=netframework-4.7.2
CSharp-Collections-Namespace
CSharp-Generic-Namespace
CSharp-Generic-Queue
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
C# Dictionary with examples
C# | Method Overriding
C# | Class and Object
C# | Constructors
Extension Method in C#
Introduction to .NET Framework
C# | Delegates
Difference between Ref and Out keywords in C#
C# | Data Types
HashSet in C# with Examples
JavaScript | Add new attribute to JSON object - GeeksforGeeks

25 Jun, 2021
The task is to add a JSON attribute to the JSON object. To do so, Here are a few of the most used techniques discussed.Example 1: This example adds a prop_11 attribute to the myObj object via var key.  
html
<!DOCTYPE HTML><html> <head>    <title>        JavaScript      | Add new attribute to JSON object.    </title></head> <body style="text-align:center;"      id="body">    <h1 style="color:green;">             GeeksForGeeks         </h1>    <p id="GFG_UP"       style="font-size: 16px;              font-weight: bold;">     </p>     <button onclick="gfg_Run()">        Click here    </button>    <p id="GFG_DOWN"       style="color:green;              font-size: 20px;              font-weight: bold;">    </p>     <script>        var el_up =            document.getElementById("GFG_UP");        var el_down =            document.getElementById("GFG_DOWN");        var myObj = {            'prop_1': {                'prop_12': 'value_12'            }        };        el_up.innerHTML = JSON.stringify(myObj);         function gfg_Run() {            var key = "prop_11";            myObj.prop_1[key] = "value_11";            el_down.innerHTML = JSON.stringify(myObj);        }    </script></body> </html>
Output:  
Before clicking on the button:  
 
After clicking on the button:  
 
Example 2: This example adds a prop_11 attribute to the myObj with value value_11.  
html
<!DOCTYPE HTML><html> <head>    <title>        JavaScript      | Add new attribute to JSON object.    </title></head> <body style="text-align:center;"      id="body">    <h1 style="color:green;">             GeeksForGeeks         </h1>    <p id="GFG_UP"       style="font-size: 16px;              font-weight: bold;">     </p>     <button onclick="gfg_Run()">        Click here    </button>    <p id="GFG_DOWN"       style="color:green;              font-size: 20px;              font-weight: bold;">    </p>     <script>        var el_up =            document.getElementById("GFG_UP");        var el_down =            document.getElementById("GFG_DOWN");        var myObj = {            'prop_1': {                'prop_12': 'value_12'            }        };        el_up.innerHTML = JSON.stringify(myObj);         function gfg_Run() {            myObj.prop_1["prop_11"] = "value_11";            el_down.innerHTML = JSON.stringify(myObj);        }    </script></body> </html>
Output:  
Before clicking on the button:  
 
After clicking on the button:  
 
 
surinderdawra388
JSON
JavaScript
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 ?
Difference Between PUT and PATCH Request
JavaScript | console.log() with Examples
How to read a local text file using JavaScript?
Node.js | fs.writeFileSync() Method
How to Use the JavaScript Fetch API to Get Data?
Node.js hash.digest() Method

25 May, 2021
The hash.digest( ) method is an inbuilt function of the crypto module’s Hash class. This is used to create the digest of the data which is passed when creating the hash. For example, when we create a hash we first create an instance of Hash using crypto.createHash() and then we update the hash content using the update( ) function but till now we did not get the resulting hash value, So to get the hash value we use the digest function which is offered by the Hash class.
This function takes a string as an input which defines the type of the returning value for example hex or base64. If you leave this field you will get Buffer as a result.
Syntax:
hash.digest([encoding])
Parameter: This function takes the following one parameter:
encoding: This method takes an optional parameter that defines the type of returning output. You can use ‘hex’ or ‘base64’ as a parameter.
Module Installation: Install the required module using the following command:
npm install crypto
Return Value: This function returns a String when the parameter is passed and returns a Buffer object when no parameter is passed. Suppose we passed parameter base64 then the return value will be a string of base64 encoding.
Example 1: Generating hash values of the string GeeksForGeeks in the form of a hex and base64.
// Importing the crypto library
const crypto = require("crypto")

// Defining the algorithm
let algorithm = "sha256"

// Defining the key
let key = "GeeksForGeeks"

// Creating the digest in hex encoding
let digest1 = crypto.createHash(algorithm).update(key).digest("hex")

// Creating the digest in base64 encoding
let digest2 = crypto.createHash(algorithm).update(key).digest("base64")

// Printing the digests
console.log("In hex Encoding : \n " + digest1 + "\n")
console.log("In base64 encoding: \n " + digest2)
Run the index.js file using the following command:
node index.js
Output:
In hex Encoding :
 0112e476505aab51b05aeb2246c02a11df03e1187e886f7c55d4e9935c290ade

In base64 encoding:
 ARLkdlBaq1GwWusiRsAqEd8D4Rh+iG98VdTpk1wpCt4= 
Example 2: Creating a digest by not passing the encoding key.
// Importing the crypto library
const crypto = require("crypto")

// Defining the algorithm
let algorithm = "sha256"

// Defining the key
let key = "GeeksForGeeks"

// Creating the digest in hex encoding
let digest = crypto.createHash(algorithm).update(key).digest()

// Printing the digests
console.log(digest)
Run the index.js file using the following command:
node index.js
Output:
<Buffer 01 12 e4 76 50 5a ab 51 b0 5a eb 22 46
c0 2a 11 df 03 e1 18 7e 88 6f 7c 55 d4 e9 93 5c 29 0a de>
Reference: https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding
bunnyram19
Node.js-crypto-module
Picked
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between Hashtable and Dictionary in C#

26 Feb, 2019
In C#, Dictionary is a generic collection which is generally used to store key/value pairs. Dictionary is defined under System.Collection.Generics namespace. It is dynamic in nature means the size of the dictionary is growing according to the need.
Example:
// C# program to illustrate Dictionaryusing System;using System.Collections.Generic;  class GFG {      // Main Method    static public void Main()    {          // Creating a dictionary        // using Dictionary<TKey, TValue> class        Dictionary<string, string> My_dict =                     new Dictionary<string, string>();          // Adding key/value pairs in the Dictionary        // Using Add() method        My_dict.Add("a.01", "C");        My_dict.Add("a.02", "C++");        My_dict.Add("a.03", "C#");          foreach(KeyValuePair<string, string> element in My_dict)        {            Console.WriteLine("Key:- {0} and Value:- {1}",                               element.Key, element.Value);        }    }}
Output:
Key:- a.01 and Value:- C
Key:- a.02 and Value:- C++
Key:- a.03 and Value:- C#

A Hashtable is a collection of key/value pairs that are arranged based on the hash code of the key. Or in other words, a Hashtable is used to create a collection which uses a hash table for storage. It is the non-generic type of collection which is defined in System.Collections namespace. In Hashtable, key objects must be immutable as long as they are used as keys in the Hashtable.
Example:
// C# program to illustrate a hashtableusing System;using System.Collections;  class GFG {      // Main method    static public void Main()    {          // Create a hashtable        // Using Hashtable class        Hashtable my_hashtable = new Hashtable();          // Adding key/value pair in the hashtable        // Using Add() method        my_hashtable.Add("A1", "Welcome");        my_hashtable.Add("A2", "to");        my_hashtable.Add("A3", "GeeksforGeeks");          foreach(DictionaryEntry element in my_hashtable)        {            Console.WriteLine("Key:- {0} and Value:- {1} ",                               element.Key, element.Value);        }    }}
Output:
Key:- A3 and Value:- GeeksforGeeks 
Key:- A2 and Value:- to 
Key:- A1 and Value:- Welcome 

CSharp Dictionary Class
CSharp-Collections-Hashtable
C#
Difference Between
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
What is CSS ruleset ?

20 Aug, 2021
A CSS ruleset is various affirmations to various pieces or elements of the document. The objective is to apply a bunch of properties for certain distinct qualities to a solitary, or a particular arrangement of components in the connected HTML page. 
Visualization of CSS Ruleset :
CSS ruleset
The “.” in the beginning indicates that the rule created will be a class, also “container” indicates the name of the selector. Similarly “first-child” indicates the pseudo-class, and elements inside curly brackets are elements of a declaration block, which contains some CSS properties and their corresponding values. The CSS ruleset will be applied when the selector name is called on the main HTML page. 
CSS Ruleset is the main building block of the CSS stylesheet.
Example 1: The following code demonstrates the application of CSS ruleset on various HTML elements. The class name is used to give property and its corresponding values. The :first-child selector is used to selecting those elements which are the first-child elements as implemented below for the HTML “p” element. 
HTML
<!DOCTYPE html><html>  <head>    <title>Rulesets in CSS</title>    <style>        h1 {            color: green;        }        /* Selector */        p:first-child{                          /* Declaration-block */            background-color: green;            color: white;            font-size: 15px;            border-radius: 50px                    ;            text-transform: uppercase                            ;            font-weight: bold;        }          body {            text-align: center;        }    </style></head>  <body>    <div>        <p>Welcome To Largest Computer Science portal</p>          <h1>GeeksforGeeks</h1>        <h2>CSS Rulesets</h2>          <p>GeeksforGeeks </p>      </div></body></html>
Output : 
Example 2: The following code also applied some of the different CSS ruleset for various HTML elements.
HTML
<!DOCTYPE html><html>  <head>    <title>Rulesets in CSS</title>    <style>      h1 {        color: green;      }              /* Selector */      span {                  /* Declaration-block */        background-color: green;        color: white;        padding: 5px;        font-size: 15px;        border-radius: 50px;        text-transform: uppercase;      }        h2 {        font-size: small;      }        .divClass {        font-family: "Franklin Gothic Medium",                      "Arial Narrow", Arial, sans-serif;      }        body {        text-align: center;      }    </style>  </head>    <body>    <div class="divClass">      <span> This website is for geeks </span>      <h1>GeeksforGeeks</h1>      <h2>        A CSS ruleset is applying various <br />        affirmations to various pieces of the document.      </h2>    </div>  </body></html>
Output:       
CSS ruleset
CSS-Basics
CSS-Properties
CSS-Questions
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python VLC MediaPlayer – Getting position

11 Apr, 2022
In this article we will see how we can get position of the MediaPlayer object in the python vlc module. VLC media player is a free and open-source portable cross-platform media player software and streaming media server developed by the VideoLAN project. MediaPlayer object is the basic object in vlc module for playing the video. We can create a MediaPlayer object with the help of MediaPlayer method. Setting media position as percentage between 0.0 and 1.0. This has no effect if playback is not enabled. This might not work depending on the underlying input format and protocol, it can be set with the help of set_position method.
In order to do this we will use get_position method with the MediaPlayer object 
Syntax : media_player.get_position() 
Argument : It takes no as argument 
Return : It returns float value
Below is the implementation 
Python3
# importing vlc moduleimport vlc # importing time moduleimport time  # creating vlc media player objectmedia_player = vlc.MediaPlayer() # media objectmedia = vlc.Media("death_note.mkv") # setting media to the media playermedia_player.set_media(media)  # start playing videomedia_player.play() # wait so the video can be played for 5 seconds# irrespective for length of videotime.sleep(5)  # setting positionmedia_player.set_position(0.5) # getting positionvalue = media_player.get_position() # printing valueprint("Current media Position: ")print(value)
Output : 
Current media Position: 
0.5
Another example Below is the implementation 
Python3
# importing vlc moduleimport vlc # importing time moduleimport time # creating vlc media player objectmedia_player = vlc.MediaPlayer() # media objectmedia = vlc.Media("1mp4.mkv") # setting media to the media playermedia_player.set_media(media)   # start playing videomedia_player.play() # wait so the video can be played for 5 seconds# irrespective for length of videotime.sleep(5) # setting positionmedia_player.set_position(0.3) # getting positionvalue = media_player.get_position() # printing valueprint("Current media Position: ")print(value)
Output : 
Current media Position: 
0.3
simranarora5sos
Python vlc-library
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
map lower_bound() function in C++ STL

29 Oct, 2020
The map::lower_bound(k) is a built-in function in C++ STL which returns an iterator pointing to the key in the container which is equivalent to k passed in the parameter.Syntax: 
map_name.lower_bound(key)

Parameters: This function accepts a single mandatory parameter key which specifies the element whose lower_bound is to be returned.Return Value: The function returns an iterator pointing to the key in the map container which is equivalent to k passed in the parameter. In case k is not present in the map container, the function returns an iterator pointing to the immediate next element which is just greater than k. If the key passed in the parameter exceeds the maximum key in the container, then the returned iterator points to the number of elements in the map as key and element= any element. 
If the passed parameter exceeds the maximum key in the container, then returned iterator will point to the map::end() like in std::set.
CPP
// C++ function for illustration// map::lower_bound() function#include <bits/stdc++.h>using namespace std; int main(){     // initialize container    map<int, int> mp;     // insert elements in random order    mp.insert({ 2, 30 });    mp.insert({ 1, 10 });    mp.insert({ 5, 50 });    mp.insert({ 4, 40 });    for (auto it = mp.begin(); it != mp.end(); it++)    {        cout << (*it).first << " " <<                              (*it).second << endl;    }     // when 2 is present    auto it = mp.lower_bound(2);    cout << "The lower bound of key 2 is ";    cout << (*it).first << " " << (*it).second << endl;     // when 3 is not present    // points to next greater after 3    it = mp.lower_bound(3);    cout << "The lower bound of key 3 is ";    cout << (*it).first << " " << (*it).second;     // when 6 exceeds    it = mp.lower_bound(6);    cout << "\nThe lower bound of key 6 is ";    cout << (*it).first << " " << (*it).second;    return 0;}
Output : 
1 10
2 30
4 40
5 50
The lower bound of key 2 is 2 30
The lower bound of key 3 is 4 40
The lower bound of key 6 is 4 0

ChetanAggarwal
naithanipkpiyush
CPP-Functions
cpp-map
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Bitwise Operators in C/C++
vector erase() and clear() in C++
Inheritance in C++
Substring in C++
C++ Classes and Objects
The C++ Standard Template Library (STL)
Sorting a vector in C++
Object Oriented Programming in C++
Priority Queue in C++ Standard Template Library (STL)
2D Vector In C++ With User Defined Size
How to create user from Django shell

14 Sep, 2021
Let’s look at how to create a user for Django using Django’s interactive shell? Make sure you have the virtual environment activated, and you are within the folder that has the manage.py file. 
Note: Refer to the article How to Create a Basic Project using MVT in Django? to understand how to create a project in Django.
Let’s launch Django’s interactive shell using the below command
python manage.py shell
You will get a similar output as mentioned below
Now enter the following code in the shell to create a user for Django.
Python3
from django.contrib.auth.models import User  user = User.objects.create_user('sonu','sonu@xyz.com','sn@pswrd')user.save()
Let’s check our new user using superuser credentials. You can follow How to create superuser in Django? to create a superuser. Let’s start the server and log in using the admin URL (make sure path(‘admin/’, admin.site.urls), is mentioned in the URL patterns). 
http://127.0.0.1:8000/admin/
Sharing the screenshot below
You can check the newly added user details under the Users section. 
Django-basics
Python Django
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Change the Time Interval of setinterval() Method at RunTime using JavaScript ?

21 Jun, 2021
In this article, we are going to learn how to change the setInterval() time after running one element. The setInterval() method reads the timing once and invokes the function at regular intervals. There are two methods to solve this problem which are discussed below:Method 1: Using clearInterval() method: The setInterval() method returns a numeric ID. This ID can be passed to clearInterval() method to clear/stop the setInterval timer. In this technique, we keep firing clearInterval() after each setInterval() to stop the previous setInterval() and initialize setInterval() with a new counter.Example:  
html
<!DOCTYPE html><html>     <head>    <title>        How to Change the Time Interval of        setinterval() Method after Running        one Element using JavaScript ?    </title></head> <body>    <div id="message"></div>         <script>         // Output message        var msg = document.getElementById("message");         var t = 200; // Timer                 // Stores the setInterval ID used by        // clearInterval to stop the timer        var interval;         f1();         // Function that changes the timer        function changeTimer(){            t = t * 1.2;        }         // Function that run at irregular intervals        function f1() {                         // Clears the previous setInterval timer            clearInterval(interval);            msg.innerHTML += "<p>Function Fired</p>";            changeTimer();            interval = setInterval(f1, t);        }    </script></body> </html>
Output:  
Method 2: Using setTimeout() method: This technique is easier and simpler than the previous one. The setTimout() method fires a function after a certain period. The timer is the time after which we want to run our function. In this technique, after performing the desired task, we change the value of the timer and call setTimeout() again. Now, since the value of timer changes, each function call is invoked at different intervals.Example:  
html
<!DOCTYPE html><html>     <head>    <title>        How to Change the Time Interval of        setinterval() Method after Running        one Element using JavaScript ?    </title></head> <body>    <div id="message"></div>    <script>         // To display output        var msg = document.getElementById("message");         // Timer        var t = 200;         f1();                 // Function that changes the timer        function changeTimer(){            t = t * 1.2;        }                 // Function to run at irregular intervals        function f1() {            msg.innerHTML += "<p>Function Fired</p>";            changeTimer();            setTimeout(f1, t);        }    </script></body> </html>
Output:  
 
rajeev0719singh
JavaScript-Misc
Picked
JavaScript
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Multiplots in Python using Matplotlib

12 May, 2022
Matplotlib is a Python library that can be used for plotting graphs and figures. Plotting multiplots or multiple plots are often required either for comparing the two curves or show some gradual changes in the multiple plots, and this can be done using Subplots. Subplots are one of the most important and fundamental concepts to be understood while trying to plot multiple figures/graphs/plots in the same, and this tutorial shows you how it is done. The subplot() function can be found in the pyplot module of matplotlib, which provides a MATLAB-like framework for plotting in Python. The function’s prototype is as shown below:
matplotlib.pyplot.subplot(nrows, ncols, index)
There are also certain keyword arguments that can be given.
First, let’s try to plot a sequence of plots (3 here) by stacking one over the other. As we are stacking them, it’s the number of rows (nrows) that change, meaning ncols stay the same as 1. Each subplot is identified by the index parameter. 
Python3
import matplotlib.pyplot as pltimport numpy as np  x = np.arange(0, 10, 0.01) # notice that nrows = number# of imagesplt.subplot(3, 1, 1)plt.plot(x, np.sin(x)) # ncols stays as 1plt.subplot(3, 1, 2)plt.plot(x, np.cos(x)) # each image has a unique# indexplt.subplot(3, 1, 3)plt.plot(x, x) plt.show()
Output: 
Next, we’ll try to plot some graphs as a grid, that is, multiplots with multiple columns. Here, we will create a multiplot with 4 plots, we will make it a 2×2 grid, which means nrows=2 and ncols=2, with each image being identified by the index again, in a row-major order. 
Python3
import matplotlib.pyplot as pltimport numpy as np  x = np.arange(0, 10, 0.01)plt.subplot(2, 2, 1)plt.plot(x, np.sin(x)) plt.subplot(2, 2, 2)plt.plot(x, np.cos(x)) plt.subplot(2, 2, 3)plt.plot(x, x) plt.subplot(2, 2, 4)plt.plot(x, 5-x) plt.show()
Output:  If we were to create a multiplot where one plot overlaps over the other one, kind of like what we see when we minimize a youtube video but it still runs in a small window at the bottom corner, then the add_suplplot() function helps in this. 
Python3
import matplotlib.pyplot as pltimport numpy as np  fig = plt.figure()x = np.arange(0, 10, 0.01)plt.plot(x, x-5) plt.title("Not so Tiny")fig.add_subplot(2, 2, 4)plt.plot(x, 5-x) plt.title("Tiny Plot")plt.show()
Output:  Oh, and also, for all the subplot functions that we’ve implemented, if nrows, ncols, and index are less than 10, instead of giving the arguments in the (nrows, ncols, index) format, they can be passed as a three-digit  in the format (nrows*100+ncols*10+index), and the output would remain the same. Why don’t we try it out with the Grid Plots? 
Python3
import matplotlib.pyplot as pltimport numpy as np  x = np.arange(0, 10, 0.01)plt.subplot(221)plt.plot(x, np.sin(x)) plt.subplot(222)plt.plot(x, np.cos(x)) plt.subplot(223)plt.plot(x, x) plt.subplot(224)plt.plot(x, 5-x)plt.show()
Output:  
The output still remains the same even if we use the three-digit format of passing the arguments.
sagartomar9927
Python-matplotlib
Python
Write From Home
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL – LIMIT with OFFSET clause

28 Aug, 2020
The PostgreSQL LIMIT clause is used to get a subset of rows generated by a query. It is an optional clause of the SELECT statement. The LIMIT clause can be used with the OFFSET clause to skip a specific number of rows before returning the query for the LIMIT clause.
Syntax:SELECT * FROM table LIMIT n OFFSET m;
Let’s analyze the syntax above.
The LIMIT clause returns a subset of “n” rows from the query result.
The OFFSET clause placed after the LIMIT clause skips “m” number of rows before returning the result query.
If “m” is Zero, then it acts as a normal LIMIT clause.
For the sake of this article we will be using the sample DVD rental database, which is explained here and can be downloaded by clicking on this link.
Now, let’s look into a few examples.Example 1:Here we will query for 5 films starting from the sixth one ordered by “film_id” from the film table of our sample database.
SELECT
    film_id,
    title,
    release_year
FROM
    film
ORDER BY
    film_id
LIMIT 5 OFFSET 6;
Output:
Example 2:Here we will query for 5 films starting from the sixth one ordered by “film_id” from the film table of our sample database in descending order of the film “title”.
SELECT
    film_id,
    title,
    release_year
FROM
    film
ORDER BY
    title DESC
LIMIT 5 OFFSET 6;
Output:
postgreSQL-clauses
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL - INSERT
PostgreSQL - SELECT
PostgreSQL- LOWER function
PostgreSQL - EXISTS Operator
PostgreSQL - BIGINT Integer Data Type
PostgreSQL - ROW_NUMBER Function
PostgreSQL - Select Into
PostgreSQL - LAST_VALUE Function
PostgreSQL - DROP INDEX
PostgreSQL - CREATE PROCEDURE
Transpose a vector into single column in R

05 Apr, 2021
In this article, we will discuss how to convert a vector from single row to a column in R Programming Language.
Steps –
Create a vector
c(value1,value2,.....,valuen)
Convert the vector into the matrix. In R, Matrix is a two-dimensional data structure that comprises rows and columns. We can create a matrix in R, by using matrix() function.
matrix(data)
View the resultant data
Implementation using this approach is given below.
Example:
R
# vector 1 is created with nested vectordata1=c("sravan","bobby","pinkey","rohith",        "gnanesh",'divya',"satwik")  print(data1)  # pass data1 vector into a matrixprint(matrix(data1))
Output:
     [,1]      
[1,] “sravan”  
[2,] “bobby”  
[3,] “pinkey”  
[4,] “rohith”  
[5,] “gnanesh”
[6,] “divya”  
[7,] “satwik” 
A vector can also be nested into another but since it is a part of the same vector it will appear in the same 
Example:
R
# vector 1 is created with nested vectordata1=c("sravan","bobby","pinkey","rohith",        "gnanesh",'divya',"satwik",        c(1,2,3,4,5))  print(data1)  # pass data1 vector into a matrixprint(matrix(data1))
Output:
      [,1]      
[1,] “sravan”  
[2,] “bobby”  
[3,] “pinkey”  
[4,] “rohith”  
[5,] “gnanesh”
[6,] “divya”  
[7,] “satwik”  
[8,] “1”      
[9,] “2”      
[10,] “3”      
[11,] “4”      
[12,] “5”
Picked
R Vector-Programs
R-Vectors
R Language
R Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Split Column Into Multiple Columns in R DataFrame?
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to filter R DataFrame by values in a column?
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
Replace Specific Characters in String in R
Merge DataFrames by Column Names in R
How to Sort a DataFrame in R ?
Trackip – Advance IP tracker tool in Kali Linux

17 Jun, 2021
Trackip is a free and open source available on GitHub. This tool can retrieve IP or Domain Geolocation, This tool can retrieve your own Geolocation, this tool selects random proxy in a new line and the IP geolocation maps that IP using Google Map. Track IP tool is used to find information about IP address in your kali Linux operating system. This tool is used to retrieve IP Geolocation information. This tool is powered by ip-api which is an API used to retrieve information about IP Geolocation. This tool is a bash script. This tool is written in bash language you must have bash language installed in your system in order to use the tool. In order to use the tool, you must have 
System Requirement:
Python3
termcolor modules
colorama modules
Step 1: Before installing the tool you have to install the dependencies of the tool using the following command.
apt install git curl -y
Step 2: Now install the tool from GitHub using the following command.
git clone git://github.com/htr-tech/track-ip.git
Step 3: The tool has been downloaded to your kali Linux operating system. Now move to the directory using the following command.
cd track-ip
Step 3: Now you are in track-ip directory. Use the following command to run the tool.
bash trackip
Step 4: The tool is downloaded and running successfully. Now the tool is giving 3 options it’s upon you for what you choose. If you want to know the geo-ip location details of your own ip address type 01 or 02.
01
Now let’s check another IP. Here we are using google IP( 8.8.8.8).
You can see that the track-ip tool is giving accurate geo-ip location. This is how you can also perform experiments using the track-ip tool.
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
MariaDB - Create Tables

In this chapter, we will learn how to create tables. Before creating a table, first determine its name, field names, and field definitions.
Following is the general syntax for table creation −
CREATE TABLE table_name (column_name column_type);

Review the command applied to creating a table in the PRODUCTS database −
databaseproducts_ tbl(
   product_id INT NOT NULL AUTO_INCREMENT,
   product_name VARCHAR(100) NOT NULL,
   product_manufacturer VARCHAR(40) NOT NULL,
   submission_date DATE,
   PRIMARY KEY ( product_id )
);

The above example uses “NOT NULL” as a field attribute to avoid errors caused by a null value. The attribute “AUTO_INCREMENT” instructs MariaDB to add the next available value to the ID field. The keyword primary key defines a column as the primary key. Multiple columns separated by commas can define a primary key.
The two main methods for creating tables are using the command prompt and a PHP script.
Utilize the CREATE TABLE command to perform the task as shown below −
root@host# mysql -u root -p
Enter password:*******
mysql> use PRODUCTS;
Database changed
mysql> CREATE TABLE products_tbl(
   -> product_id INT NOT NULL AUTO_INCREMENT,
   -> product_name VARCHAR(100) NOT NULL,
   -> product_manufacturer VARCHAR(40) NOT NULL,
   -> submission_date DATE,
   -> PRIMARY KEY ( product_id )
   -> );
mysql> SHOW TABLES;
+------------------------+
| PRODUCTS               |
+------------------------+
| products_tbl           |
+------------------------+

Ensure all commands are terminated with a semicolon.
PHP provides mysql_query() for table creation. Its second argument contains the necessary SQL command −
<html>
   <head>
      <title>Create a MariaDB Table</title>
   </head>

   <body>
      <?php
         $dbhost = 'localhost:3036';
         $dbuser = 'root';
         $dbpass = 'rootpassword';
         $conn = mysql_connect($dbhost, $dbuser, $dbpass);
      
         if(! $conn ){
            die('Could not connect: ' . mysql_error());
         }
         echo 'Connected successfully<br />';
         
         $sql = "CREATE TABLE products_tbl( ".
            "product_id INT NOT NULL AUTO_INCREMENT, ".
            "product_name VARCHAR(100) NOT NULL, ".
            "product_manufacturer VARCHAR(40) NOT NULL, ".
            "submission_date DATE, ".
            "PRIMARY KEY ( product_id )); ";
      
         mysql_select_db( 'PRODUCTS' );
         $retval = mysql_query( $sql, $conn );
      
         if(! $retval ) {
            die('Could not create table: ' . mysql_error());
         }
         echo "Table created successfully\n";
         
         mysql_close($conn);
      ?>
   </body>
</html>
On successful table creation, you will see the following output −
mysql> Table created successfully
Python – turtle.bye()

17 Aug, 2020
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
This function is used to shut the turtle graphics window. It doesn’t require any argument.
Syntax : turtle.bye()Parameters : NoneReturns : Nothing
Below is the implementation of above method with some examples :
Example 1:
# import packageimport turtle   # set turtle speed to # slowest for better# understandings  turtle.speed(1)# motion  turtle.forward(200)# use bye() method to # shut the windowturtle.bye()
Output :
Example 2 :
# import packageimport turtle     # set drawing turtle speedturtle.speed(10)  # loop for patternfor i in range(12):  turtle.circle(50)  turtle.right(30)  # As simply use of bye() here will shut the # turtle graphics window too fast so use # loops to pass the timefor i in range(2000):  for j in range(500):    pass  # shut the turtle graphics windowturtle.bye()
Output :
Python-turtle
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas Series.pow()

30 Sep, 2019
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas Series.pow() is a series mathematical operation method. This is used to put each element of passed series as exponential power of caller series and returned the results. For this, index of both the series has to be same otherwise error is returned.
Syntax: Series.pow(other, =None, fill_value=None, axis=0)
Parameters:other: Other series or list type to be put as exponential power to the caller serieslevel: Value to be replaced by NaN in series/list before operationfill_value: Integer value of level in case of multi index
Return : Value of caller series with other series as its exponential power
Example #1:In this example, two Series are created using Pandas .Series() method. None of the series is having null values. The second series is directly passed as other parameter to return the values after operation.
# importing pandas moduleimport pandas as pd  # creating first seriesfirst =[1, 2, 5, 6, 3, 4]  # creating second seriessecond =[5, 3, 2, 1, 3, 2]  # making seriesfirst = pd.Series(first)  # making seriessecond = pd.Series(second)  # calling .pow()result = first.pow(second)  # displayresult
Output:As shown in the output, the returned values are equal to first series with second series as its exponential power.
0     1
1     8
2    25
3     6
4    27
5    16
dtype: int64

 Example #2: Handling Null values
In this example, NaN values are also put in the series using numpy.nan method. After that 2 is passed to fill_value parameter to replace null values with 2.
# importing pandas moduleimport pandas as pd  # importing numpy moduleimport numpy as np  # creating first seriesfirst =[1, 2, 5, 6, 3, np.nan, 4, np.nan]  # creating second seriessecond =[5, np.nan, 3, 2, np.nan, 1, 3, 2]  # making seriesfirst = pd.Series(first)  # making seriesasecond = pd.Series(second)  # value for null replacementnull_replacement = 2  # calling .pow()result = first.pow(second, fill_value = null_replacement)  # displayresult
Output:As shown in the output, all NaN values were replaced by 2 before the operation and result was returned without any Null value in it.
0      1.0
1      4.0
2    125.0
3     36.0
4      9.0
5      2.0
6     64.0
7      4.0
dtype: float64
Akanksha_Rai
Python pandas-series
Python pandas-series-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
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
Python | os.path.join() method
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list
GATE | GATE-IT-2004 | Question 37

10 Sep, 2018
What is the number of vertices in an undirected connected graph with 27 edges, 6 vertices of degree 2, 3 vertices of degree 4 and remaining of degree 3?(A) 10(B) 11(C) 18(D) 19Answer: (D)Explanation: The idea is to use Handshaking Lemma :- In any graph, the sum of all the vertex-degree is equal to twice the number of edges.
Let x = Total Number of Vertices.

By Handshaking Lemma

6*2 + 3*4 + (x-9)*3 = 27*2

24 + (x-9)*3 = 54

x-9 = 10

x = 19 
Quiz of this Question
NikhilVerma2
GATE IT 2004
GATE-GATE IT 2004
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE-CS-2014-(Set-3) | Question 20
GATE | GATE CS 2008 | Question 40
GATE | GATE CS 2008 | Question 46
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE CS 2011 | Question 49
GATE | GATE CS 1996 | Question 38
GATE | GATE-CS-2004 | Question 31
ios manipulators showpos() function in C++

28 Aug, 2019
The showpos() method of stream manipulators in C++ is used to set the showpos format flag for the specified str stream. This flag always displays the non negative values along with their + sign.
Syntax:
ios_base& showpos (ios_base& str)

Parameters: This method accepts str as a parameter which is the stream for which the format flag is affected.
Return Value: This method returns the stream str with showpos format flag set.
Example 1:
// C++ code to demonstrate// the working of showpos() function  #include <iostream>  using namespace std;  int main(){      // Initializing the integers    int a = 10;    int b = 0;      // Using showpos()    cout << "showpos flag: "         << showpos         << a << endl         << b << endl;      return 0;}
showpos flag: +10
+0

Example 2:
// C++ code to demonstrate// the working of showpos() function  #include <iostream>  using namespace std;  int main(){      // Initializing the integers    int a = -10;      // Using showpos()    cout << "showpos flag: "         << showpos         << a << endl;      return 0;}
showpos flag: -10

Reference: http://www.cplusplus.com/reference/ios/showpos/
cpp-ios
cpp-manipulators
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Set in C++ Standard Template Library (STL)
Bitwise Operators in C/C++
Priority Queue in C++ Standard Template Library (STL)
vector erase() and clear() in C++
unordered_map in C++ STL
Substring in C++
Object Oriented Programming in C++
The C++ Standard Template Library (STL)
Inheritance in C++
C++ Classes and Objects
Explain higher order functions in JavaScript.

JavaScript treats functions as objects and allow us to pass functions as parameter to another function and even return functions from other functions. In JavaScript the functions are first class functions meaning we can store them in variable, objects and array. The higher order functions can take function, return them or do both.
Following is the code for higher order functions on JavaScript.
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result,.sample {
      font-size: 18px;
      font-weight: 500;
      color: rebeccapurple;
   }
   .result {
      color: red;
   }
</style>
</head>
<body>
<h1>Higher order functions in JavaScript</h1>
<div class="sample">[22,33,44,55]</div>
<br />
<div class="result"></div>
<br />
<button class="Btn">CLICK HERE</button>
<h3>Click on the above button to double each element of the above array</h3>
<script>
   let resEle = document.querySelector(".result");
   let BtnEle = document.querySelector(".Btn");
   function doubleNum(ele) {
      return ele * 2;
   }
   let arr = [22, 33, 44, 55];
   function doubleArray(arr, fn) {
      let doubleArr = [];
      arr.forEach((element) => {
         doubleArr.push(doubleNum(element));
      });
      return doubleArr;
   }
   BtnEle.addEventListener("click", () => {
      resEle.innerHTML = "New array = " + doubleArray(arr, doubleNum);
   });
</script>
</body>
</html>
The above code will produce the following output −
On clicking the ‘CLICK HERE’ button −
Python | Convert list to Python array

27 Sep, 2019
Sometimes while working in Python we can have a problem in which we need to restrict the data elements to be just of one type. List, can be heterogeneous, can have data of multiple data types and it is sometimes undesirable. There a need to convert this to data structure which restricts the type of data. The Python language comes with array data structure which can be used for this purpose. Let’s discuss a way to convert list to array.
Method : Using array() + data type indicatorThis task can be easily performed using array(). This is an inbuilt function in Python to convert to array. The data type indicator “i” is used in case of integers, which restricts data type.
# Python3 code to demonstrate working of# Convert list to Python array# Using array() + data type indicatorfrom array import array  # initializing listtest_list = [6, 4, 8, 9, 10]  # printing listprint("The original list : " + str(test_list))  # Convert list to Python array# Using array() + data type indicatorres = array("i", test_list)  # Printing resultprint("List after conversion to array : " + str(res))
 
The original list : [6, 4, 8, 9, 10]
List after conversion to array : array('i', [6, 4, 8, 9, 10])

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
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
Run shell command from GUI using Python

20 Oct, 2021
In this article, we are going to discuss how we can create a GUI window that will take Operating System commands as input and after executing them, displays the output in a pop-up window.
PyAutoGui: It is a module in python which is used to automate the GUI and controls the mouse and keyboard.  It is an external module, it can be installed in the system using the below command:
Linux:
pip3 install pyautogui
Windows:
pip install pyautogui
OS: The OS module in Python provides functions for interacting with the operating system.This module comes under Python’s standard utility modules. It provides a portable way of using operating system dependent functionality.
Import modules.
Use the prompt() of pyautogui module to take input command
Use the system() of os module to execute the command.
Finally, call the popen() of os module to generate a pop-up window and then using alert() of pyautogui module to display output.
Below program depicts how to create a window which takes operating system commands as input.
Python3
# import required modulesimport osimport pyautogui # prompts message on screen and takes the# input command in val variableval = pyautogui.prompt("Enter Shell Command") # executes the value of val variableos.system(val)
Output:
However, when commands are entered they are performed in the background. Below is a better version of the above previous python program in which on the execution of the given command, the output is displayed in a popup window.
Python3
# import required modulesimport osimport pyautogui # prompts message on screen and gets the command# value in val variablevalue = pyautogui.prompt("Enter Shell Command") # executes the command and returns# the output in stream variablestream = os.popen(value) # reads the output from stream variableout = stream.read()pyautogui.alert(out)
Output:
surinderdawra388
Python-PyAutoGUI
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.