code-rag-bench/online-tutorials huggingface dataset:
PyQt5 QListWidget – Getting Spacing Between the Items - GeeksforGeeks

06 Aug, 2020
In this article we will see how we can get the space between the item of the QListWidget. QListWidget is a convenience class that provides a list view with a classic item-based interface for adding and removing items. QListWidget uses an internal model to manage each QListWidgetItem in the list. Spacing property holds the space around the items in the layout. This property is the size of the empty space that is padded around an item in the layout. Setting this property when the view is visible will cause the items to be laid out again. By default, this property contains a value of 0 although it can be changed with the help of setSpacing method.
In order to do this we will use spacing method with the list widget object.
Syntax : list_widget.spacing()
Argument : It takes no argument
Return : It returns integer
Below is the implementation
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 500, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()          # method for components    def UiComponents(self):          # creating a QListWidget        list_widget = QListWidget(self)          # setting geometry to it        list_widget.setGeometry(50, 70, 150, 60)          # list widget items        item1 = QListWidgetItem("A")        item2 = QListWidgetItem("B")        item3 = QListWidgetItem("C")          # adding items to the list widget        list_widget.addItem(item1)        list_widget.addItem(item2)        list_widget.addItem(item3)          # setting spacing property        list_widget.setSpacing(5)          # creating a label        label = QLabel("GeesforGeeks", self)          # setting geometry to the label        label.setGeometry(230, 80, 280, 80)          # making label multi line        label.setWordWrap(True)          # getting spacing between the items        value = list_widget.spacing()                  # setting text to the label        label.setText("Spacing : " + str(value))    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python PyQt-QListWidget
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
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
Different ways to create Pandas Dataframe
Python String | replace()
Python program to convert a list to string
Reading and Writing to text files in Python
sum() function in Python
How to process Arrays in Java?

To process array elements, we often use either for loop or for each loop because all of the elements in an array are of the same type and the size of the array is known. Suppose we have an array of 5 elements we can print all the elements of this array as:
Live Demo
public class ProcessingArrays {
   public static void main(String args[]) {
      int myArray[] = {22, 23, 25, 27, 30};

      for(int i = 0; i<myArray.length; i++) {
         System.out.println(myArray[i]);
      }
   }
}
22
23
25
27
30
Bootstrap - Responsive utilities

Bootstrap provides some handful helper classes, for faster mobile-friendly development. These can be used for showing and hiding content by device via media query, combined with large, small, and medium devices.
Use these sparingly and avoid creating entirely different versions of the same site. Responsive utilities are currently only available for block and table toggling.
The following table lists the print classes. Use these for toggling the content for print.
The following example demonstrates the use of above listed helper classes. Resize your browser or load the example on different devices to test the responsive utility classes.
<div class = "container" style = "padding: 40px;">
   <div class = "row visible-on">
      
      <div class = "col-xs-6 col-sm-3" style = "background-color: #dedef8;
         box-shadow: inset 1px -1px 1px #444, inset -1px 1px 1px #444;">
         
         <span class = "hidden-xs">Extra small</span>
         <span class = "visible-xs">✔ Visible on x-small</span>
      </div>
      
      <div class = "col-xs-6 col-sm-3" style = "background-color: #dedef8;
         box-shadow: inset 1px -1px 1px #444, inset -1px 1px 1px #444;">
         
         <span class = "hidden-sm">Small</span>
         <span class = "visible-sm">✔ Visible on small</span>
      </div>
      
      <div class = "clearfix visible-xs"></div>
      
      <div class = "col-xs-6 col-sm-3" style = "background-color: #dedef8;
         box-shadow: inset 1px -1px 1px #444, inset -1px 1px 1px #444;">
         
         <span class = "hidden-md">Medium</span>
         <span class = "visible-md">✔ Visible on medium</span>
      </div>
      
      <div class = "col-xs-6 col-sm-3" style = "background-color: #dedef8;
         box-shadow: inset 1px -1px 1px #444, inset -1px 1px 1px #444;">
         
         <span class = "hidden-lg">Large</span>
         <span class = "visible-lg">✔ Visible on large</span>
      </div>
      
   </div>  
</div>
Checkmarks indicates that the element is visible in your current viewport.

    26 Lectures 
     2 hours 

 Anadi Sharma

    54 Lectures 
     4.5 hours 

 Frahaan Hussain

    161 Lectures 
     14.5 hours 

 Eduonix Learning Solutions

    20 Lectures 
     4 hours 

 Azaz Patel

    15 Lectures 
     1.5 hours 

 Muhammad Ismail

    62 Lectures 
     8 hours 

 Yossef Ayman Zedan
 Print
 Add Notes
 Bookmark this page
JavaScript How to get all 'name' values in a JSON array?

Let’s say the following is our JSON array −
var details = [
   {
      "customerDetails": [
            {
               "customerName": "John Smith",
               "customerCountryName": "US"
            }
      ]
   },
   {
      "customerDetails": [
         {
            "customerName": "David Miller",
            "customerCountryName": "AUS"
         }
      ]
   },
   {
      "customerDetails": [
         {
            "customerName": "Bob Taylor",
            "customerCountryName": "UK"
         }
      ]
   }
]
To get only the CustomerName values, use the concept of map() −
var details = [
   {
      "customerDetails": [
         {
            "customerName": "John Smith",
            "customerCountryName": "US"
         }
      ]
   },
   {
      "customerDetails": [
         {
            "customerName": "David Miller",
            "customerCountryName": "AUS"
         }
      ]
   },
   {
      "customerDetails": [
         {
            "customerName": "Bob Taylor",
            "customerCountryName": "UK"
         }
      ]
   }
]
var allCustomerName = details.map(obj=>
obj.customerDetails[0].customerName);
console.log(allCustomerName);
To run the above program, you need to use the following command −
node fileName.js.
Here my file name is demo206.js.
PS C:\Users\Amit\javascript-code> node demo206.js
[ 'John Smith', 'David Miller', 'Bob Taylor' ]
Scala String replaceAll() method with example

03 Oct, 2019
The replaceAll() method is used to replace each of the stated sub-string of the string which matches the regular expression with the string we supply in the argument list.
Method Definition: String replaceAll(String regex, String replacement)Return Type: It returns the stated string after replacing the stated sub-string with the string we provide.
Example #1:
// Scala program of replaceAll()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Applying replaceAll method        val result = "csoNidhimso".replaceAll(".so", "##")                  // Displays output        println(result)          }} 
##Nidhi##

Example #2:
// Scala program of replaceAll()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Applying replaceAll method        val result = "csoNidhimsoSingh ".replaceAll(".so", "##")                  // Displays output        println(result)          }} 
##Nidhi##Singh

Scala
Scala-Method
Scala-Strings
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to overlap two Barplots in Seaborn?

25 Jan, 2022
Seaborn is an amazing visualization library for statistical graphics plotting in Python. It provides beautiful default styles and colour palettes to make statistical plots more attractive. It is built on the top of matplotlib library and also closely integrated to the data structures from pandas.
Bar Plot is used to represent categories of data using rectangular bars. We can overlap two barplots in seaborn by creating subplots.
Steps required to overlap two barplots in seaborn:
Importing seaborn and matplotlib library,  seaborn for plotting graph and matplotlib for using subplot().Creating dataframe.Creating two subplots on the same axes.Displaying the plot.
Importing seaborn and matplotlib library,  seaborn for plotting graph and matplotlib for using subplot().
Creating dataframe.
Creating two subplots on the same axes.
Displaying the plot.
Below are some examples based on the above approach:
Example 1:
Python3
# importing all required librariesimport pandas as pdimport seaborn as snsimport matplotlib.pyplot as plt # creating dataframedf = pd.DataFrame({    'X': [1, 2, 3],    'Y': [3, 4, 5],    'Z': [2, 1, 2]}) # creating subplotsax = plt.subplots() # plotting columnsax = sns.barplot(x=df["X"], y=df["Y"], color='b')ax = sns.barplot(x=df["X"], y=df["Z"], color='r') # renaming the axesax.set(xlabel="x-axis", ylabel="y-axis") # visualizing illustrationplt.show()
Output:
Example 2:
Python3
#importing all required librariesimport pandas as pdimport seaborn as snsimport matplotlib.pyplot as plt #creating dataframedf=pd.DataFrame({    'X':[i for i in range(10,110,10)],    'Y':[i for i in range(100,0,-10)],    'Z':[i for i in range(10,110,10)]}) #creating subplotsax=plt.subplots() #plotting columnsax=sns.barplot(x=df["X"],y=df["Y"],color = 'lime')ax=sns.barplot(x=df["X"],y=df["Z"],color = 'green') #renaming the axesax.set(xlabel="x-axis", ylabel="y-axis") # visualizing illustrationplt.show()
 
 
Output:
 
 
clintra
Picked
Python-Seaborn
Technical Scripter 2020
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HTML | DOM createElement() Method

24 Jul, 2019
In HTML document, the document.createElement() is a method used to create the HTML element. The element specified using elementName is created or an unknown HTML element is created if the specified elementName is not recognized.
Syntax
var element = document.createElement("elementName");

In the above syntax, elementName is passed as a parameter. elementName specifies the type of the created element. The nodeName of the created element is initialized to the elementName value. The document.createElement() returns the newly created element.
Example 1: This example illustrates how to create a <p> element.
Input :
<!DOCTYPE html><html>  <head>    <script>        function createparagraph() {            var x = document.createElement("p");            var t =                 document.createTextNode("Paragraph is created.");            x.appendChild(t);            document.body.appendChild(x);        }    </script></head>  <body>    <button onclick="createparagraph()">CreateParagraph</button></body>  </html>                    
Output:Initially:
After pressing Create Paragraph button:
Explanation:
Start with creating a <p> element using document.createElement().
Create a text node using document.createTextNode().
Now, append the text to <p> using appendChild().
Append the <p> to <body> using appendChild().
Example 2: This example illustrates how to create a <p> element and append it to a <div> element.Input :
<!DOCTYPE html><html>  <head>    <script>        function createparagraph() {            var x = document.createElement("p");            var t =                 document.createTextNode("Paragraph is created.");            x.appendChild(t);            document.getElementById("divid").appendChild(x);        }    </script></head>  <body>    <div id="divid"> A div element</div>    <button onclick="createparagraph()">CreateParagraph</button></body>  </html>
Output:
Initially:
After pressing the CreateParagraph button:Supported Browser: The browsers supported by DOM createElement() Methodare listed below:
Google Chrome
Internet Explorer
Firefox
Opera
SAfari
HTML-DOM
HTML-Methods
Picked
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Roadmap to Learn JavaScript For Beginners
REST API (Introduction)
Node.js fs.readFileSync() Method
Python | random.sample() function

29 Aug, 2018
sample() is an inbuilt function of random module in Python that returns a particular length list of items chosen from the sequence i.e. list, tuple, string or set. Used for random sampling without replacement.
Syntax : random.sample(sequence, k)
Parameters:sequence: Can be a list, tuple, string, or set.k: An Integer value, it specify the length of a sample.
Returns: k length new list of elements chosen from the sequence.
Code #1: Simple implementation of sample() function.
# Python3 program to demonstrate# the use of sample() function .  # import random from random import sample  # Prints list of random items of given lengthlist1 = [1, 2, 3, 4, 5]   print(sample(list1,3))
Output:
[2, 3, 5]
 Code #2: Basic use of sample() function.
# Python3 program to demonstrate# the use of sample() function .  # import random import random    # Prints list of random items of# length 3 from the given list.list1 = [1, 2, 3, 4, 5, 6] print("With list:", random.sample(list1, 3))  # Prints list of random items of# length 4 from the given string. string = "GeeksforGeeks"print("With string:", random.sample(string, 4))  # Prints list of random items of# length 4 from the given tuple.tuple1 = ("ankit", "geeks", "computer", "science",                   "portal", "scientist", "btech")print("With tuple:", random.sample(tuple1, 4))    # Prints list of random items of# length 3 from the given set.set1 = {"a", "b", "c", "d", "e"}print("With set:", random.sample(set1, 3))
Output:
With list: [3, 1, 2]
With string: ['e', 'f', 'G', 'G']
With tuple: ['ankit', 'portal', 'geeks', 'computer']
With set: ['b', 'd', 'c']
Note: Output will be different everytime as it returns a random item. Code #3: Raise Exception
If the sample size i.e. k is larger than the sequence size, ValueError is raised.
# Python3 program to demonstrate the# error of sample() function.import random  list1 = [1, 2, 3, 4]    # exception raisedprint(random.sample(list1, 5)) 
Output:
Traceback (most recent call last):
  File "C:/Users/user/AppData/Local/Programs/Python/Python36/all_prgm/geeks_article/sample_method_article.py", line 8, in 
    print(random.sample(list1, 5))
  File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\random.py", line 317, in sample
    raise ValueError("Sample larger than population or is negative")
ValueError: Sample larger than population or is negative

Python-Built-in-functions
python-modules
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Python map() function
Adding new column to existing DataFrame in Pandas
Python Dictionary
How to get column names in Pandas dataframe
Different ways to create Pandas Dataframe
Taking input in Python
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
ER diagram of Bank Management System

20 Sep, 2021
ER diagram is known as Entity-Relationship diagram. It is used to analyze to structure of the Database. It shows relationships between entities and their attributes. An ER model provides a means of communication. 
ER diagram of Bank has the following description :  
Bank have Customer.
Banks are identified by a name, code, address of main office.
Banks have branches.
Branches are identified by a branch_no., branch_name, address.
Customers are identified by name, cust-id, phone number, address.
Customer can have one or more accounts.
Accounts are identified by account_no., acc_type, balance.
Customer can avail loans.
Loans are identified by loan_id, loan_type and amount.
Account and loans are related to bank’s branch.
ER Diagram of Bank Management System : 
 
This bank ER diagram illustrates key information about bank, including entities such as branches, customers, accounts, and loans. It allows us to understand the relationships between entities. 
Entities and their Attributes are :  
Bank Entity : Attributes of Bank Entity are Bank Name, Code and Address. Code is Primary Key for Bank Entity.
Customer Entity : Attributes of Customer Entity are Customer_id, Name, Phone Number and Address. Customer_id is Primary Key for Customer Entity.
Branch Entity : Attributes of Branch Entity are Branch_id, Name and Address. Branch_id is Primary Key for Branch Entity.
Account Entity : Attributes of Account Entity are Account_number, Account_Type and Balance. Account_number is Primary Key for Account Entity.
Loan Entity : Attributes of Loan Entity are Loan_id, Loan_Type and Amount. Loan_id is Primary Key for Loan Entity.
Relationships are :  
Bank has Branches => 1 : N One Bank can have many Branches but one Branch can not belong to many Banks, so the relationship between Bank and Branch is one to many relationship.  
Branch maintain Accounts => 1 : N One Branch can have many Accounts but one Account can not belong to many Branches, so the relationship between Branch and Account is one to many relationship.  
Branch offer Loans => 1 : N One Branch can have many Loans but one Loan can not belong to many Branches, so the relationship between Branch and Loan is one to many relationship.  
Account held by Customers => M : N One Customer can have more than one Accounts and also One Account can be held by one or more Customers, so the relationship between Account and Customers is many to many relationship.  
Loan availed by Customer => M : N (Assume loan can be jointly held by many Customers). One Customer can have more than one Loans and also One Loan can be availed by one or more Customers, so the relationship between Loan and Customers is many to many relationship. 
pradiptamukherjee
DBMS-ER model
DBMS
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Easy-Login Module

04 Jul, 2021
Easy-Login module is that library of Python which helps you to login in your social accounts like Facebook, Instagram, Twitter, Linkedin, Reddit etc through Python without opening the sites manually . 
Installation
This module does not come built-in with Python. You need to install it externally. To install this module type the below command in the terminal.
pip install easy-login
It will automatically login your account in a separate window using chrome  webdriver and will take you over the home page of that website
Web Drivers Selenium requires a web driver to interface with the chosen browser. Web drivers is a package to interact with a web browser. It interacts with the web browser or a remote web server through a wire protocol which is common to all. You can check out and install the web drivers of your browser choice. 
Chrome:    https://sites.google.com/a/chromium.org/chromedriver/downloads
Firefox: https://github.com/mozilla/geckodriver/releases
Safari:    https://webkit.org/blog/6900/webdriver-support-in-safari-10/
Username and password must be of same account which you have to login and must be in string format. Address must be in string format with forward slash(/) like  C:/Users/user1/chromedriver_win32/chromedriver .
Here is the demonstration for this module :  
python3
# importing the modulefrom easy_login import login # initializing the username and passwordusername = ""password = "" # initializing the address of chrome web driveraddress = "" # creating an object of loginobj = login(username, password, addresses) # calling the account in which we want to loginobj.Facebook()obj.Instagram()obj.Twitter()obj.Linkedin()obj.Reddit()
anikaseth98
python-modules
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
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Create a directory in Python
Output of C programs | Set 51

24 May, 2019
1. What will be the output of the below program?
#include <stdio.h>int main(){    printf("%d", printf("%d", printf("%d", printf("%s", "Welcome to geeksforgeeks"))));    return (0);}
Options:1. Welcome to geeksforgeeks25312. Welcome to geeksforgeeks24213. Welcome to geeksforgeeks21244. Welcome to geeksforgeeks3125
The answer is option(2).
Explanation : As we all know that the printf function returns the numbers of character that is going to print and scanf function returns the number of input given.
2. What will be the output of the following program?
#include <stdio.h>int main(){    int x = 30, y = 25, z = 20, w = 10;    printf("%d ", x * y / z - w);    printf("%d", x * y / (z - w));    return (0);}
Options:1. 27 852. 82 273. 27 754. No output
 The output is option(3).
Explanation : In the above program, precedence takes the advantage. Therefore In the statement compiler first calculate x*y then / and after that subtraction.Refer : https://www.geeksforgeeks.org/c-operator-precedence-associativity/
3. Guess the output?
#include <stdio.h>int main(){    int a = 15, b;    b = (a++) + (a++);    a = (b++) + (b++);    printf("a=%d b=%d", a, b);    return (0);}
Options:1. a=63 b=332. a=33 b=633. a=66 b=334. a=33 b=33
The answer is option(1).
Explanation:Here,
a = 15 and b = (a++)+(a++) i.e. b = 15+16 = 31 and a =3 2.
Now a = (b++) + (b++) = 31 + 32 = 63 and b = 33.
Therefore the result is a = 63 and b = 33.
Refer: https://www.geeksforgeeks.org/operators-in-c-set-1-arithmetic-operators/
4. What will be the output?
#include <stdio.h>int main(){    main();    return (0);}
Options:1. compile time error2. abnormal termination3. run time error4. No output
The answer is option(1).
Explanation:Here stack overflow occurs that’s result in run-time error.Refer: https://www.geeksforgeeks.org/print-geeksforgeeks-empty-main-c/
5. What will be the output of following program?
#include <stdio.h>int main(){    int c = 4;    c = c++ + ~++c;    printf("%d", c);    return (0);}
Options:1. 32. -33. 314. compile time error
 The answer is option(2).
Explanation:Because here c++ is post increment and so it takes value as 4 then it will increment. ++c is pre-increment so it increment first and value 6 is assigned to c, .~ means -6-1=-7 then c=(4-7)=-3.
This article is contributed by Bishal Kumar Dubey. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
ManasChhabra2
C-Output
Program Output
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Find number of times every day occurs in a Year

12 Jul, 2021
Given a year .Your task is to find the number of every day in a year ie.number of Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday in that given year.Examples:  
Input: 2019
Output: Monday-52
        Tuesday-53
        Wednesday-52
        Thursday-52
        Friday-52
        Saturday-52
        Sunday-52

Input: 2024
Output: Monday-53
        Tuesday-53
        Wednesday-52
        Thursday-52
        Friday-52
        Saturday-52
        Sunday-52
Observations: We have to make some key observations. The first one will be that there are at least 52 weeks in a year, so every day will occur at least 52 times in a year. As 52*7 is 364 so the day occurring on the 1st January of any year will occur 53 times and if the year is a leap year then the day on the 2nd January will also occur 53 times.Approach: Create a list with size 7 and having an initial value of 52 as the minimum number of occurrences will be 52. Find the index of the first day. Calculate the number of days whose occurrence will be 53.Below is the implementation. 
Python3
# python program Find number of# times every day occurs in a Year   import datetimeimport calendar  def day_occur_time(year):         # stores days in a week    days = [ "Monday", "Tuesday", "Wednesday",            "Thursday",  "Friday", "Saturday",           "Sunday" ]         # Initialize all counts as 52    L = [52 for i in range(7)]         # Find the index of the first day    # of the year    pos = -1    day = datetime.datetime(year, month = 1, day = 1).strftime("%A")    for i in range(7):        if day == days[i]:            pos = i                 # mark the occurrence to be 53 of 1st day    # and 2nd day if the year is leap year    if calendar.isleap(year):        L[pos] += 1        L[(pos+1)%7] += 1             else:        L[pos] += 1                  # Print the days    for i in range(7):        print(days[i], L[i])        # Driver Codeyear = 2019day_occur_time(year)
Output: 
Monday 52
Tuesday 52
Wednesday 52
Thursday 52
Friday 53
Saturday 53
Sunday 52
 
sweetyty
Python datetime-program
Python-datetime
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Convert datetime string to YYYY-MM-DD-HH:MM:SS format in Python

23 Aug, 2021
In this article, we are going to convert the DateTime string into the %Y-%m-%d-%H:%M:%S format. For this  task strptime() and strftime() function is used.
strptime() is used to convert the DateTime string to DateTime in the format of year-month-day hours minutes and seconds
Syntax:
datetime.strptime(my_date, “%d-%b-%Y-%H:%M:%S”)
strftime() is used to convert DateTime into required timestamp format
Syntax:
datetime.strftime(“%Y-%m-%d-%H:%M:%S”)
Here,
&Y means year
%m  means month
%d means day
%H means hours
%M means minutes
%S means seconds.
First the take DateTime timestamp as a String. Then, convert it into DateTime using strptime(). Now, convert into the necessary format of DateTime using strftime
Example 1: Python program to convert DateTime string into %Y-%m-%d-%H:%M:%S format
Python3
# import datetime modulefrom datetime import datetime  # consider date in string formatmy_date = "30-May-2020-15:59:02"  # convert datetime string into date,month,day and# hours:minutes:and seconds format using strptimed = datetime.strptime(my_date, "%d-%b-%Y-%H:%M:%S")  # convert datetime format into %Y-%m-%d-%H:%M:%S# format using strftimeprint(d.strftime("%Y-%m-%d-%H:%M:%S"))
Output
'2020-05-30-15:59:02'
Example 2: Python program to convert DateTime string into %Y-%m-%d-%H:%M:%S format
Python3
# import datetime modulefrom datetime import datetime  # consider date in string formatmy_date = "30-May-2020-15:59:02"  # convert datetime string into date,month,day # and hours:minutes:and seconds format using# strptimed = datetime.strptime(my_date, "%d-%b-%Y-%H:%M:%S")  # convert datetime format into %Y-%m-%d-%H:%M:%S# format using strftimeprint(d.strftime("%Y-%m-%d-%H:%M:%S"))  # consider date in string formatmy_date = "04-Jan-2021-02:45:12"  # convert datetime string into date,month,day # and hours:minutes:and seconds format using # strptimed = datetime.strptime(my_date, "%d-%b-%Y-%H:%M:%S")  # convert datetime format into %Y-%m-%d-%H:%M:%S # format using strftimeprint(d.strftime("%Y-%m-%d-%H:%M:%S"))  # consider date in string formatmy_date = "23-May-2020-15:59:02"  # convert datetime string into date,month,day and # hours:minutes:and seconds format using strptimed = datetime.strptime(my_date, "%d-%b-%Y-%H:%M:%S")  # convert datetime format into %Y-%m-%d-%H:%M:%S # format using strftimeprint(d.strftime("%Y-%m-%d-%H:%M:%S"))
2020-05-30-15:59:02
2021-01-04-02:45:12
2020-05-23-15:59:02

Picked
Python-datetime
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
p5.js | resizeCanvas() Function

17 Jan, 2020
The resizeCanvas() function is used to resize the canvas to the height and width given as parameters. The canvas is immediately redrawn after the resize takes place unless the optional ‘noRedraw’ parameter is set to true.
Syntax:
resizeCanvas(w, h, [noRedraw])
Parameters: This function accepts three parameters as mentioned above and described below:
w: It is a number representing the width of the new canvas.
h: It is a number representing the height of the new canvas.
noRedraw: It is a boolean value which specifies if the canvas is immediately redrawn when resized.
Below example illustrates the resizeCanvas() function in p5.js:
Example 1: In this example, we fixed the increase size.
function setup() {  createCanvas(200, 200);  textSize(16);    rect(0, 0, height, width);  background('green');  text("This is the canvas area", 20, 80);  text("Canvas height: " + height, 25, 100);  text("Canvas width: " + width, 25, 120);}  function mouseClicked() {  resizeCanvas(300, 300, true);    rect(0, 0, height, width);  background('green');  text("This is the canvas area", 50, 130);  text("Canvas height: " + height, 50, 150);  text("Canvas width: " + width, 50, 170);}
Output:Example 2: In this example, size depends on the click position.
function setup() {  createCanvas(200, 200);  textSize(16);    rect(0, 0, height, width);  background('green');  text("Press anywhere to resize", 10, 20);  text("Canvas height: " + height, 10, 40);  text("Canvas width: " + width, 10, 60);}  function mouseClicked(event) {  // resize canvas to the  resizeCanvas(event.x, event.y);    rect(0, 0, height, width);  background('green');  text("Press anywhere to resize", 10, 20);  text("Canvas height: " + height, 10, 40);  text("Canvas width: " + width, 10, 60);}
Output:
Online editor: https://editor.p5js.org/Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
Reference: https://p5js.org/reference/#/p5/resizeCanvas
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
numpy.vstack() in python

06 Jan, 2019
numpy.vstack() function is used to stack the sequence of input arrays vertically to make a single array.
Syntax : numpy.vstack(tup)
Parameters :tup : [sequence of ndarrays] Tuple containing arrays to be stacked. The arrays must have the same shape along all but the first axis.
Return : [stacked ndarray] The stacked array of the input arrays.
Code #1 :
# Python program explaining# vstack() function  import numpy as geek  # input arrayin_arr1 = geek.array([ 1, 2, 3] )print ("1st Input array : \n", in_arr1)   in_arr2 = geek.array([ 4, 5, 6] )print ("2nd Input array : \n", in_arr2)   # Stacking the two arrays verticallyout_arr = geek.vstack((in_arr1, in_arr2))print ("Output vertically stacked array:\n ", out_arr)
1st Input array : 
 [1 2 3]
2nd Input array : 
 [4 5 6]
Output vertically stacked array:
  [[1 2 3]
 [4 5 6]]

 Code #2 :
# Python program explaining# vstack() function  import numpy as geek  # input arrayin_arr1 = geek.array([[ 1, 2, 3], [ -1, -2, -3]] )print ("1st Input array : \n", in_arr1)   in_arr2 = geek.array([[ 4, 5, 6], [ -4, -5, -6]] )print ("2nd Input array : \n", in_arr2)   # Stacking the two arrays verticallyout_arr = geek.vstack((in_arr1, in_arr2))print ("Output stacked array :\n ", out_arr)
1st Input array : 
 [[ 1  2  3]
 [-1 -2 -3]]
2nd Input array : 
 [[ 4  5  6]
 [-4 -5 -6]]
Output stacked array :
  [[ 1  2  3]
 [-1 -2 -3]
 [ 4  5  6]
 [-4 -5 -6]]

Python numpy-arrayManipulation
Python-numpy
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
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Convert integer to string in Python
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
HTML | <link> rel Attribute

06 Jun, 2022
The HTML rel attribute is used to specify the relationship between the current and the linked document. It is used only when href attribute present.Syntax:  
<link rel="value">
Attribute Values  
alternate: It specifies the alternative link of the document(i.e. print page, translated or mirror).
author: It define author of the link
dns-prefetch: It Specifies that the browser should preemptively perform DNS resolution for the target resource’s origin
help: It specifies a link to a help document. Example: <link rel=”help” href=”/help/”>
icon: It specifies import icon in a given document
license: It specifies a link to copyright information for the document
next: It provide the link of next document in series
pingback: It specifies the address of the pingback serve
preconnect: It specifies the target should be preemptively to the origin resource
prefetch: It specifies that the target document should be cached.
preload: It specifies that the browser must preemptively fetch and cache
prerender: It specifies that the browser should load
prev: It specifies the previous document in a selection
search: It specifies the search tool for the document.
stylesheet: It Imports a style sheet
Example of HTML link rel Attribute  
html
<!DOCTYPE html><html> <head>    <link rel="stylesheet"        type="text/css"        href="index_screen.css">     <link rel="stylesheet"        type="text/css"        href="index_print.css"></head> <body>    <center>        <h1>GeeksforGeeks</h1>          <p><a href="https://ide.geeksforgeeks.org/tryit.php"        target="_blank">    Click here    </a>    </center></body> </html>                   
Output:  
Supported Browsers: The browsers supported by HTML rel Attribute are listed below  
Google Chrome 1
Edge 12
Firefox 1.0
Apple Safari 
Opera 
Internet Explorer
 
simmytarika5
kumargaurav97520
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
Design a Tribute Page using HTML & CSS
Build a Survey Form using HTML and CSS
Angular File Upload
Form validation using jQuery
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Private Constructors and Singleton Classes in Java

21 Jun, 2018
Let’s first analyze the following question:
Can we have private constructors ?
As you can easily guess, like any method we can provide access specifier to the constructor. If it’s made private, then it can only be accessed inside the class.
Do we need such ‘private constructors ‘ ?
There are various scenarios where we can use private constructors. The major ones are
Internal Constructor chainingSingleton class design pattern
Internal Constructor chaining
Singleton class design pattern
What is a Singleton class?
As the name implies, a class is said to be singleton if it limits the number of objects of that class to one.
We can’t have more than a single object for such classes.
Singleton classes are employed extensively in concepts like Networking and Database Connectivity.
Design Pattern of Singleton classes:
The constructor of singleton class would be private so there must be another way to get the instance of that class. This problem is resolved using a class member instance and a factory method to return the class member.
Below is an example in java illustrating the same:
// Java program to demonstrate implementation of Singleton // pattern using private constructors.import java.io.*;  class MySingleton{    static MySingleton instance = null;    public int x = 10;        // private constructor can't be accessed outside the class    private MySingleton() {  }       // Factory method to provide the users with instances    static public MySingleton getInstance()    {        if (instance == null)                     instance = new MySingleton();           return instance;    } }  // Driver Classclass Main{   public static void main(String args[])       {       MySingleton a = MySingleton.getInstance();       MySingleton b = MySingleton.getInstance();       a.x = a.x + 10;       System.out.println("Value of a.x = " + a.x);       System.out.println("Value of b.x = " + b.x);   }    }
Output:
Value of a.x = 20
Value of b.x = 20
We changed value of a.x, value of b.x also got updated because both ‘a’ and ‘b’ refer to same object, i.e., they are objects of a singleton class.
This article is contributed by Ashutosh Kumar Singh. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ios manipulators internal() function in C++ - GeeksforGeeks

02 Sep, 2019
The internal() method of stream manipulators in C++ is used to set the adjustfield format flag for the specified str stream. This flag sets the adjustfield to internal. It means that the number in the output will be padded to the field width by inserting fill characters at a specified internal point.
Syntax:
ios_base& internal (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 internal format flag set.
Example 1:
// C++ code to demonstrate// the working of internal() function  #include <iostream>  using namespace std;  int main(){      // Initializing the integer    double x = -1.23;      cout.precision(5);      // Using internal()    cout << "internal flag: ";      cout.width(12);    cout << internal << x << endl;      return 0;}
internal flag: -       1.23

Example 2:
// C++ code to demonstrate// the working of internal() function  #include <iostream>  using namespace std;  int main(){      // Initializing the integer    double x = -1.23;      cout.precision(5);      // Using internal()    cout << "internal flag: ";      cout.width(12);    cout << internal << x << endl;      return 0;}
internal flag: -       1.23

Reference: http://www.cplusplus.com/reference/ios/internal/
cpp-ios
cpp-manipulators
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Operator Overloading in C++
Sorting a vector in C++
Friend class and function in C++
Polymorphism in C++
List in C++ Standard Template Library (STL)
Pair in C++ Standard Template Library (STL)
Convert string to char array in C++
new and delete operators in C++ for dynamic memory
Destructors in C++
Queue in C++ Standard Template Library (STL)
AIML - <topic> Tag

<topic> Tag is used in AIML to store a context so that later conversation can be done based on that context. Usually, <topic> tag is used in Yes/No type conversation. It helps AIML to search categories written within the context of the topic. 
Define a topic using <set> tag
<template> 
   <set name = "topic"> topic-name </set>
</template>

Define the category using <topic> tag
<topic name = "topic-name">
   <category>
      ...
   </category>     
</topic>
For example, consider the following conversation.
Human: let discuss movies
Robot: Yes movies
Human: Comedy movies are nice to watch
Robot: Watching good movie refreshes our minds.
Human: I like watching comedy
Robot: I too like watching comedy.

Here bot responds taking "movie" as the topic.
Create topic.aiml inside C > ab > bots > test > aiml and topic.aiml.csv inside C > ab > bots > test > aimlif directories.
<?xml version = "1.0" encoding = "UTF-8"?>
<aiml version = "1.0.1" encoding = "UTF-8"?>
   <category>
      <pattern>LET DISCUSS MOVIES</pattern>
      <template>Yes <set name = "topic">movies</set></template>  
   </category>
   
   <topic name = "movies">
      <category>
         <pattern> * </pattern>
         <template>Watching good movie refreshes our minds.</template>
      </category>
      
      <category>
         <pattern> I LIKE WATCHING COMEDY! </pattern>
         <template>I like comedy movies too.</template>
      </category>
      
   </topic>
</aiml>
0,LET DISCUSS MOVIES,*,*,Yes <set name = "topic">movies</set>,topic.aiml
0,*,*,movies,Watching good movie refreshes our minds.,topic.aiml
0,I LIKE WATCHING COMEDY!,*,movies,I like comedy movies too.,topic.aiml
Open the command prompt. Go to C > ab > and type the following command −
java -cp lib/Ab.jar Main bot = test action = chat trace = false

You will see the following output −
Human: let discuss movies
Robot: Yes movies
Human: Comedy movies are nice to watch
Robot: Watching good movie refreshes our minds.
Human: I like watching comedy
Robot: I too like watching comedy.

 Print
 Add Notes
 Bookmark this page
C library function - ceil()

The C library function double ceil(double x) returns the smallest integer value greater than or equal to x.
Following is the declaration for ceil() function.
double ceil(double x)
x − This is the floating point value.
x − This is the floating point value.
This function returns the smallest integral value not less than x.
The following example shows the usage of ceil() function.
#include <stdio.h>
#include <math.h>

int main () {
   float val1, val2, val3, val4;

   val1 = 1.6;
   val2 = 1.2;
   val3 = 2.8;
   val4 = 2.3;

   printf ("value1 = %.1lf\n", ceil(val1));
   printf ("value2 = %.1lf\n", ceil(val2));
   printf ("value3 = %.1lf\n", ceil(val3));
   printf ("value4 = %.1lf\n", ceil(val4));
   
   return(0);
}
Let us compile and run the above program that will produce the following result −
value1 = 2.0
value2 = 2.0
value3 = 3.0
value4 = 3.0


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
Fetch records from comma separated values using MySQL IN()?

Use FIND_IN_SET() instead of MySQL IN(). Let us first create a −
mysql> create table DemoTable1423
   -> (
   -> CountryName varchar(100)
   -> );
Query OK, 0 rows affected (0.51 sec)
Insert some records in the table using insert −
mysql> insert into DemoTable1423 values('AUS,UK');
Query OK, 1 row affected (0.08 sec)
mysql> insert into DemoTable1423 values('US');
Query OK, 1 row affected (0.21 sec)
mysql> insert into DemoTable1423 values('AUS,UK,US');
Query OK, 1 row affected (0.13 sec)
Display all records from the table using select −
mysql> select * from DemoTable1423;
This will produce the following output −
+-------------+
| CountryName |
+-------------+
| AUS,UK      |
| US          |
| AUS,UK,US   |
+-------------+
3 rows in set (0.00 sec)
Here is the query to fetch records using FIND_IN_SET()−
mysql> select * from DemoTable1423 where find_in_set('US',CountryName);
This will produce the following output −
+-------------+
| CountryName |
+-------------+
| US          |
| AUS,UK,US   |
+-------------+
2 rows in set (0.00 sec)
How to set Proxy in Firefox using Selenium WebDriver?

We can set a proxy in Firefox using Selenium webdriver. A proxy server enables users to access an URL of an application for testing purposes even with the presence of several layers of network.
The setting up of proxy in Firefox can be done with the help of the FirefoxOptions class. The port information and the proxy server host are added to this class. The setting up of the proxy server can also be done by configuring the Firefox Profile in the FirefoxProfile class.
Code Implementation with the FirefoxOptions
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
public class ConfigureProxy {
   public static void main(String[] args) {
      //object of Proxy
      Proxy p = new Proxy();
      //adding host and port
      p.setHttpProxy("<HOST:PORT>");
      p.setSslProxy("<HOST:PORT>");
      p.setSslProxy("<HOST:PORT>");
      p.setFtpProxy("<HOST:PORT>");
      //object of FirefoxOptions
      FirefoxOptions o = new FirefoxOptions();
      o.setCapability("proxy", p);
      //passing Firefox option to webdriver object
      WebDriver driver = new FirefoxDriver(o);
      //url launch
      driver.get("https://www.tutorialspoint.com/index.htm");
      //browser close
      driver.close();
   }
}
Code Implementation with the FirefoxOptions
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
public class ConfigureProxyProfile {
   public static void main(String[] args) {
      //object of Proxy
      Proxy p = new Proxy();
      //adding host and port
      p.setHttpProxy("<HOST:PORT>");
      p.setSslProxy("<HOST:PORT>");
      p.setSslProxy("<HOST:PORT>");
      p.setFtpProxy("<HOST:PORT>");
      //object of FirefoxProfile
      FirefoxProfile pl = new FirefoxProfile();
      pl.setProxyPreferences(p);
      //passing Firefox profile to webdriver object
      WebDriver driver = new FirefoxDriver(pl);
      //url launch
      driver.get("https://www.tutorialspoint.com/index.htm");
      //browser close
      driver.close();
   }
}