code-rag-bench/online-tutorials huggingface dataset:
How to Shake Text on hover using HTML and CSS?

31 Jul, 2020
Shaking Text animation is a very cool animation which can be used in websites, this animation can be easily created using some basic HTML and CSS, the below section will guide on how to create the animation.
HTML Code: In this section we have a basic div element which contains some text inside of it.
<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <meta name="viewport"        content="width=device-width, initial-scale=1.0">  <title>Shake Text</title></head><body>  <div>    <h2>Shake!</h2>  </div>      </body></html>
CSS Code: In this section first we will design the text with some basic CSS and use @keyframes animation and then use the transitionX() function to produce the shaking effect when we hover over the text.
<style> *{    margin: 0;    padding: 0;  }  /* designing the text*/  div{    position: absolute;    top: 50%;    left: 50%;    transform: translate(-50%, -50%);    font-size: 2.5em;    color: rgb(4, 110, 4);  }  /*creating the shake animation*/      div:hover h2{    animation:  shake 0.8s  ;  }    @keyframes shake{    0%{      transform: translateX(0)    }    25%{      transform: translateX(25px);    }          50%{      transform: translateX(-25px);    }    100%{      transform: translateX(0px);    }  }     </style>
Final Code: It is the combination of the above two code sections.
<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <meta name="viewport"        content="width=device-width, initial-scale=1.0">  <title>Shake Text</title></head><style>  *{     margin: 0;     padding: 0;   }   /* designing the text*/   div{     position: absolute;     top: 50%;     left: 50%;     transform: translate(-50%, -50%);     font-size: 2.5em;     color: rgb(4, 110, 4);   }   /*creating the shake animation*/        div:hover h2{     animation:  shake 0.8s  ;   }      @keyframes shake{     0%{       transform: translateX(0)     }     25%{       transform: translateX(25px);     }            50%{       transform: translateX(-25px);     }     100%{       transform: translateX(0px);     }   }       </style>  <body>  <div>    <h2>Shake!</h2>  </div>         </body></html>
Output:
HTML-DOM
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Types of CSS (Cascading Style Sheet)
How to set space between the flexbox ?
How to position a div at the bottom of its container using CSS?
How to Upload Image into Database and Display it using PHP ?
Design a Tribute Page using HTML & CSS
REST API (Introduction)
Hide or show elements in HTML using display property
How to set the default value for an HTML <select> element ?
Design a Tribute Page using HTML & CSS
Types of CSS (Cascading Style Sheet)
Temporal Data and Temporal Consistency

28 Jun, 2022
Temporal Data is the temporary data that is valid only for a prescribed time. Temporal data becomes invalid or obsolete after a certain period of time. For example, the current temperature of a particular region is temporal data as it keeps on updating and the validity of this temporal data (current temperature) becomes obsolete. Also, the data for the current seat availability in flight booking keeps on changing every minute. Such type of temporary data is called as temporal data. Temporal Data is generally used in Real-time systems, for example, Railway Seat Reservation, Sensex, Weather forecasting, etc. Real-time Systems use temporal consistency constrains on the data objects. Temporal consistency ensures that the difference in the values which is stored in the database of the real-time systems and the real data is within some predefined limit. Absolute Validity makes sure that there must be some consistency in the real data and the data stored in the database. Relative Consistency makes sure that the set of data obtained when queried from the database of the real-time systems should lie within a certain fixed and predefined range. The relative values of the data obtained from the database should be close to each other and there must not be a huge difference in the values.  
In the above diagram:
x arrives at 0 and becomes obsolete at 8, because the validity time is 8
y arrives at 6 and becomes obsolete at 13, because the validity time is 7
Data items in the Real-time System are stored in the form of a tuple:
(value, avi, timestamp)
value: It represents the data value.
avi: It represents the validity time of the data.
timestamp: It represents the generation time of the data instance.
For example, (786.34, 8 ms, 800 ms): means that the data value is 786.34 and it is generated at 800 ms and is valid from 800ms to 804ms. Absolute Validity can be verified using the equation:
( current_time - dtimestamp ) <= davi
Relative Validity can be verified using the equation:
∀d, ∀ d' ∈ R : |dts - d'ts|
simmytarika5
Computer Subject
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas dataframe.to_clipboard()

29 Jan, 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 dataframe.to_clipboard() function copy object to the system clipboard. This function writes a text representation of the object to the system clipboard. This could be easily pasted into excel or notepad++.
Syntax: DataFrame.to_clipboard(excel=True, sep=None, **kwargs)
Parameters :excel : True, use the provided separator, writing in a csv format for allowing easy pasting into excel. False, write a string representation of the object to the clipboard.sep : Field delimiter.**kwargs : These parameters will be passed to DataFrame.to_csv.
Note : For link to the CSV file used in the code, click here
Example #1: Use to_clipboard() function to copy the object to the clipboard in a non-excel format.
# importing pandas as pdimport pandas as pd  # Creating the dataframe df = pd.read_csv('nba.csv')  # Print the dataframedf
Output :
Now we will copy this object to clipboard in a non-excel format.
# copy to clipboarddf.to_clipboard(excel = False, sep = ', ')
Output :We have simply pasted, what got copied to the clipboard after executing the previous command. The software used was “Notepad++”. Example #2: Use to_clipboard() function to copy the object to the clipboard in an excel format.
# importing pandas as pdimport pandas as pd  # Creating the dataframe df = pd.read_csv('nba.csv')  # Print the dataframedf
Output :
Now we will copy this object to clipboard in an excel format.
# copy to clipboarddf.to_clipboard(excel = True)
Output :
Python pandas-dataFrame
Python pandas-dataFrame-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
TemplateView – Class Based Generic View Django

25 May, 2021
Django provides several class based generic views to accomplish common tasks. The simplest among them is TemplateView. It Renders a given template, with the context containing parameters captured in the URL.
TemplateView should be used when you want to present some information on an HTML page. TemplateView shouldn’t be used when your page has forms and does creation or update of objects. In such cases, FormView, CreateView, or UpdateView is a better option.
TemplateView is most suitable in the following cases:
Showing ‘about us’ like pages that are static and hardly need any context. Though, it is easy to use context variables with TemplateView.
Showing pages that work with GET requests and don’t have forms in them.
Explanation :
Illustration of How to use TemplateView using an Example. Consider a project named geeksforgeeks having an app named geeks.
Refer to the following articles to check how to create a project and an app in Django.   
How to Create a Basic Project using MVT in Django ?   
How to Create an App in Django ?
Let’s write a view using base class view View and then modify it to use TemplateView. TemplateView would help us avoid several lines of code.
Enter the following code into views.py file of geeks app.
Python3
from django.views.generic.base import Viewfrom django.shortcuts import render class AboutUs(View):  def get(self, request, *args, **kwargs):        return render(request, "aboutus.html")
Create a folder named templates inside the geeks app and then create a file named aboutus.html inside templates folder.
Enter the following code into aboutus.html file.
HTML
<!DOCTYPE html><html><head><title>AboutUs</title></head><body><h2>Welcome To GFG</h2></body></html>
Enter the Following code into urls.py of geeksforgeeks project folder.
Python3
from django.contrib import adminfrom django.urls import pathfrom geeks.views import AboutUs urlpatterns = [    path('admin/', admin.site.urls),      path('',AboutUs.as_view(),name="aboutus")]
  
Run below three commands to see the output.
Python manage.py makemigrations
Python manage.py migrate
Python manage.py runserver
Same output can be achieved using TemplateView , replace code of  views.py file of geeks app by given below code.
 
Python3
from django.views.generic.base import TemplateView class AboutUs(TemplateView):    template_name = 'aboutus.html'
Let’s check what is there on http://localhost:8000/
Output – 
Code_Mech
Django-views
Python Django
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 | os.path.join() method
Introduction To PYTHON
Python OOPs Concepts
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Create a directory in Python
MongoDB - Rename Operator ($rename) - GeeksforGeeks

10 May, 2020
MongoDB provides different types of field update operators to update the values of the fields of the documents and $rename operator is one of them. This operator is used to update the names of the fields with new names. The new name of the field should be different from the existing name of the field.
$rename operator logically first performs an $unset operation on both the old name and the new name and then performs an $set operation with the new name.
If the document contains the field with the new name, then this operator will remove that field and renames the specified field to the new name.
This operator can also work with embedded/nested documents or arrays. In embedded/nested documents, this operator can rename the specified field as well as move the fields in and out of the embedded documents
You can use this operator in methods like update(), findAndModify(), etc., according to your requirements.
If the specified field for renaming is not available, then this operator will do nothing.
Syntax:
{$rename: {<field1>:<newName1>, <field2>:<newName2>, ... } }
Here, newName is the new name and it must be different from the existing name of the field. To specify field in embedded/nested documents with the help of dot notation.
In the following examples, we are working with:
Database: GeeksforGeeksCollection: EmployeeDocument: three documents that contain the details of the employees in the form of field-value pairs.
In this example, we are renaming the name of experienceYear field to experience in the employee’s document whose first name is Amu.
db.Employee.update({"name.first": "Amu"},                    {$rename: {"experienceYear":"experience"}})
In this example, we are renaming the name of the department field to unit in all the documents present in the Employee collection.
db.Employee.updateMany({}, {$rename: {"department":"unit"}})
In this example, we are renaming the name of personalDetails.contactInfo to personalDetails.phoneNumber field inan embedded/nested document of the employee whose name is Sumit.
db.Employee.update({"name.first": "Sumit"},                   {$rename: {"personalDetails.contactInfo":"personalDetails.phoneNumber"}})
MongoDB
MongoDB-operators
MongoDB
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to connect MongoDB with ReactJS ?
MongoDB - limit() Method
MongoDB - FindOne() Method
Create user and add role in MongoDB
MongoDB Cursor
MongoDB insertMany() Method - db.Collection.insertMany()
MongoDB updateOne() Method - db.Collection.updateOne()
MongoDB - Map Reduce
MongoDB - sort() Method
MongoDB updateMany() Method - db.Collection.updateMany()
AngularJS | ng-value Directive - GeeksforGeeks

05 Apr, 2019
The ng-value Directive in AngularJS is used to specify the value of an input element. It is supported by <input> and <select> elements.
Syntax:
<element ng-value="expression"> Content ... </element> 

Example 1:
<!DOCTYPE html><html>    <head>        <title>ng-value Directive</title>        <script src=        "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js">        </script>            </head>    <body ng-app="app" style="padding:20px">      <h1 style="color:green;">GeeksforGeeks</h1>      <h2 style="">ng-value Directive</h2>      <p>Choose one:</p>      <div ng-controller="geek">          <div ng-repeat="l in sort">           <input type="radio" ng-model="my.fav" ng-value="l" name="Sort"> {{l}}          </div>          <pre>Selected choice is: {{my.fav}}</pre>      </div>      <script>      var app = angular.module("app", []);      app.controller('geek', ['$scope', function ($scope) {          $scope.sort = ['Merge Sort', 'Quick Sort', 'Bubble Sort'];          $scope.my = { fav: 'Merge Sort' };      }]);        </script>    </body></html>
Output:
AngularJS-Directives
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Angular PrimeNG Dropdown Component
How to make a Bootstrap Modal Popup in Angular 9/8 ?
Angular 10 (blur) Event
How to create module with Routing in Angular 9 ?
How to setup 404 page in angular routing ?
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
PHP - Mutex Functions

Static methods contained in the Mutex class can provide direct access to Posix Mutex functionality.
Mutex {
   /* Methods */
   final public static long create([ boolean $lock ] )
   final public static boolean destroy( long $mutex )
   final public static boolean lock( long $mutex )
   final public static boolean trylock( long $mutex )
   final public static boolean unlock( long $mutex [, boolean $destroy ] )
}
Mutex class removed in pthreads v3.
Mutex::create
Function can create a Mutex.
Mutex::destroy()
Function can destroy a Mutex.
Mutex::lock()
Function can acquire Mutex.
Mutex::trylock()
Function can attempt to acquire the Mutex.
Mutex::unlock()
Function can release the Mutex.

    45 Lectures 
     9 hours 

 Malhar Lathkar

    34 Lectures 
     4 hours 

 Syed Raza

    84 Lectures 
     5.5 hours 

 Frahaan Hussain

    17 Lectures 
     1 hours 

 Nivedita Jain

    100 Lectures 
     34 hours 

 Azaz Patel

    43 Lectures 
     5.5 hours 

 Vijay Kumar Parvatha Reddy
 Print
 Add Notes
 Bookmark this page
C++ String Library - pop_back

It erases the last character of the string, effectively reducing its length by one.
Following is the declaration for std::string::pop_back.
void pop_back();
void pop_back();
void pop_back();
none
none
if an exception is thrown, there are no changes in the string.
In below example for std::string::pop_back.
#include <iostream>
#include <string>

int main () {
   std::string str ("sairamkrishna Mammahe");
   str.pop_back();
   std::cout << str << '\n';
   return 0;
}
The sample output should be like this −
sairamkrishna Mammah

 Print
 Add Notes
 Bookmark this page
How to disable logging from imported modules in Python?

You can disable logging from imported modules using the logging module. You can configure it to not log messages unless they are at least warnings using the following code:
import logging
logging.getLogger("imported_module").setLevel(logging.WARNING)
If you dont want to write the module name as a string, you can also use imported_module.__name__. If you want to go a level higher and only want to log messages when they are errors or critical, you can do replace logging.WARNING with logging.ERROR and logging.CRITICAL respectively.
SQL NULL Values - IS NULL and IS NOT NULL

A field with a NULL value is a field with no value.
If a field in a table is optional, it is possible to insert a new record or 
update a record without adding a value to this field. Then, the field will be 
saved with a NULL value.
Note: A NULL value is different from a zero value or a field that 
contains spaces. A field with a NULL value is one that has been left blank 
during record creation!
It is not possible to test for NULL values with comparison operators, such as 
=, <, or <>.
We will have to use the IS NULL and 
IS NOT NULL operators instead.
Below is a selection from the "Customers" table in the Northwind sample 
database:
The IS NULL operator is used to test for empty values (NULL values).
The following SQL lists all customers with a NULL value in the "Address" field:
Tip: Always use IS NULL to look for NULL values.
The IS NOT NULL operator is used to test for non-empty values (NOT NULL 
values).
The following SQL lists all customers with a value in the "Address" field:
Select all records from the Customers where 
the PostalCode column is empty.
SELECT * FROM Customers
WHERE   ;

Start the 
Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Lua - Arithmetic Operators

Following table shows all the arithmetic operators supported by Lua language. Assume variable A holds 10 and variable B holds 20, then −
Try the following example to understand all the arithmetic operators available in the Lua programming language −
a = 21
b = 10
c = a + b

print("Line 1 - Value of c is ", c )
c = a - b

print("Line 2 - Value of c is ", c )
c = a * b

print("Line 3 - Value of c is ", c )
c = a / b

print("Line 4 - Value of c is ", c )
c = a % b

print("Line 5 - Value of c is ", c )
c = a^2

print("Line 6 - Value of c is ", c )
c = -a

print("Line 7 - Value of c is ", c )
When you execute the above program, it produces the following result −
Line 1 - Value of c is 	31
Line 2 - Value of c is 	11
Line 3 - Value of c is 	210
Line 4 - Value of c is 	2.1
Line 5 - Value of c is 	1
Line 6 - Value of c is 	441
Line 7 - Value of c is 	-21


    12 Lectures 
     2 hours 

 Manish Gupta

    80 Lectures 
     3 hours 

 Sanjeev Mittal

    54 Lectures 
     3.5 hours 

 Mehmet GOKTEPE
 Print
 Add Notes
 Bookmark this page
Clojure - REPL

REPL (read-eval-print loop) is a tool for experimenting with Clojure code. It allows you to interact with a running program and quickly try out if things work out as they should. It does this by presenting you with a prompt where you can enter the code. It then reads your input, evaluates it, prints the result, and loops, presenting you with a prompt again.
This process enables a quick feedback cycle that isn’t possible in most other languages.
A REPL session can be started in Leiningen by typing the following command in the command line.
lein repl

This will start the following REPL window.
You then start evaluating Clojure commands in the REPL window as required.
To start a REPL session in Eclipse, click the Menu option, go to Run As → Clojure Application.
This will start a new REPL session in a separate window along with the console output.
Conceptually, REPL is similar to Secure Shell (SSH). In the same way that you can use SSH to interact with a remote server, Clojure REPL allows you to interact with a running Clojure process. This feature can be very powerful because you can even attach a REPL toa live production app and modify your program as it runs.
REPL includes some useful variables, the one widely used is the special variable *1, *2, and *3. These are used to evaluate the results of the three most recent expressions.
Following example shows how these variables can be used.
user => "Hello"
Hello
user => "World"
World
user => (str *2 *1)
HelloWorld
In the above example, first two strings are being sent to the REPL output window as “Hello” and “World” respectively. Then the *2 and *1 variables are used to recall the last 2 evaluated expressions.
 Print
 Add Notes
 Bookmark this page
How to change the color of the alert box in JavaScript?

You can try to run the following code to change the color of the alert box. To change the color of the alert box, use the following custom alert box. We’re using JavaScript library, jQuery to achieve this and will change the color of the alert box to “blue” −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
      </script>
      <script>
         function functionAlert(msg, myYes) {
            var confirmBox = $("#confirm");
            confirmBox.find(".message").text(msg);
            confirmBox.find(".yes").unbind().click(function() {
               confirmBox.hide();
            });
            confirmBox.find(".yes").click(myYes);
            confirmBox.show();
         }
      </script>
      <style>
         #confirm  {
            display: none;
            background-color: #8416f9;
            color: #FCD116;
            border: 1px solid #aaa;
            position: fixed;
            width: 250px;
            left: 50%;
            margin-left: -100px;
            padding: 6px 8px 8px;
            box-sizing: border-box;
            text-align: center;
         }
         #confirm button {
            background-color: #48E5DA;
            display: inline-block;
            border-radius: 5px;
            border: 1px solid #aaa;
            padding: 5px;
            text-align: center;
            width: 80px;
            cursor: pointer;
         }
         #confirm .message {
            text-align: left;
         }
      </style>
   </head>
   <body>
     <div id="confirm">
         <div class="message">This is a warning message.</div>
         <button class="yes">OK</button>
      </div>
      <input type="button" value="Click Me" onclick="functionAlert();" />
   </body>
</html>
Char.ConvertToUtf32(String, Int32) Method in C#

The Char.ConvertToUtf32(String, Int32) method in C# is used to convert the value of a UTF-16 encoded character or surrogate pair at a specified position in a string into a Unicode code point.
Following is the syntax −
public static int ConvertToUtf32 (string str, int index);
Above, str is the string that contains a character or surrogate pair. The index parameter is the index position of the character or surrogate pair in str.
Let us now see an example to implement the Char.ConvertToUtf32(String, Int32) method −
using System;
public class Demo {
   public static void Main(){
      int utf = 0x046;
      string str = Char.ConvertFromUtf32(utf);
      Console.WriteLine("Final Value = "+str);
      int res = Char.ConvertToUtf32(str, 0);
      Console.WriteLine("Actual Value = 0x{0:X}", res);
   }
}
This will produce the following output −
Final Value = F
Actual Value = 0x46
Let us now see another example −
using System;
public class Demo {
   public static void Main(){
      int utf = 0x057;
      string str = Char.ConvertFromUtf32(utf);
      Console.WriteLine("Final Value = "+str);
      int res = Char.ConvertToUtf32(str, 0);
      Console.WriteLine("Actual Value = 0x{0:X}", res);
   }
}
This will produce the following output −
Final Value = W
Actual Value = 0x57
Addressing modes in 8086 microprocessor

In this section we will see the addressing modes of Intel 8086 microprocessor.
There are eight addressing modes in 8086 MPU. These modes are:
Immediate Addressing Mode
Immediate Addressing Mode
Register Addressing Mode
Register Addressing Mode
Direct Addressing Mode
Direct Addressing Mode
Register Indirect Addressing Mode
Register Indirect Addressing Mode
Based Addressing Mode
Based Addressing Mode
Indexed Addressing Mode
Indexed Addressing Mode
Based-Index Addressing Mode
Based-Index Addressing Mode
Based-Index with displacement addressing mode
Based-Index with displacement addressing mode
The addressing mode in which the data operand is a part of the instruction itself is known as immediate addressing mode.
MOV CX, 4929 H, ADD AX, 2387 H, MOV AL, FFH

MOV CX, 4929 H, ADD AX, 2387 H, MOV AL, FFH
 
It means that the register is the source of an operand for an instruction.
MOV CX, AX; copies the contents of the 16-bit AX register into; the 16-bit CX register),ADD BX, AX

MOV CX, AX; copies the contents of the 16-bit AX register into
; the 16-bit CX register),
ADD BX, AX
 
The addressing mode in which the effective address of the memory location is written directly in the instruction.
MOV AX, [1592H], MOV AL, [0300H]

MOV AX, [1592H], MOV AL, [0300H]
 
This addressing mode allows data to be addressed at any memory location through an offset address held in any of the following registers: BP, BX, DI & SI.
MOV AX, [BX]; Suppose the register BX contains 4895H, then the contents
; 4895H are moved to AX
ADD CX, {BX}

MOV AX, [BX]; Suppose the register BX contains 4895H, then the contents
; 4895H are moved to AX
ADD CX, {BX}
 
In this addressing mode, the offset address of the operand is given by the sum of contents of the BX/BP registers and 8-bit/16-bit displacement.
MOV DX, [BX+04], ADD CL, [BX+08]

MOV DX, [BX+04], ADD CL, [BX+08]
 
In this addressing mode, the operands offset address is found by adding the contents of SI or DI register and 8-bit/16-bit displacements.
MOV BX, [SI+16], ADD AL, [DI+16]

MOV BX, [SI+16], ADD AL, [DI+16]
 
In this addressing mode, the offset address of the operand is computed by summing the base register to the contents of an Index register.
ADD CX, [AX+SI], MOV AX, [AX+DI]

ADD CX, [AX+SI], MOV AX, [AX+DI]
 
In this addressing mode, the operands offset is computed by adding the base register contents. An Index registers contents and 8 or 16-bit displacement.
MOV AX, [BX+DI+08], ADD CX, [BX+SI+16]

MOV AX, [BX+DI+08], ADD CX, [BX+SI+16]
wxPython | Exit() function in wxPython - GeeksforGeeks

15 Jun, 2020
In this article we are going to learn about wx.Exit() which is a inbuilt parent function present in wxPython.Exit() function exits application after calling wx.App.OnExit .
Should only be used in an emergency: normally the top-level frame should be deleted (after deleting all other frames) to terminate the application. See wx.CloseEvent and wx.App.
Syntax:wx.Exit()
Parameters:No parameters are required by Exit() function
Coding Example:
import wx    class Example(wx.Frame):      def __init__(self, *args, **kwargs):        super(Example, self).__init__(*args, **kwargs)          self.InitUI()      def InitUI(self):          self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)        self.panel = wx.Panel(self, pos =(100, 100), size =(100, 100))        self.btn = wx.Button(self.panel, id = 2, label ="Exit", pos = wx.DefaultPosition, size =(100, 20))          self.Bind(wx.EVT_BUTTON, self.onclick, self.btn)      def onclick(self, e):        # EXITS APPLICATION ON CLICKING EXIT BUTTON        wx.Exit()  def main():    app = wx.App()    ex = Example(None)    ex.Show()    app.MainLoop()    if __name__ == '__main__':    main()
Output Window:
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
Drawing borders around an image using OpenCV

In this program, we will draw borders around an image. We will use the copyMakeBorder() method in the openCV library. This function takes various parameters like image, top, bottom, left, right border values.
Step 1: Import cv2.
Step 2: Read the image.
Step 3: Dall the cv2.copymakeborder() method.
Step 4: Display the output.
import cv2

image = cv2.imread('testimage.jpg')
image = cv2.copyMakeBorder(image, 10,10,10,10, cv2.BORDER_CONSTANT)
cv2.imshow('Border', image)
How to get the Tkinter widget's current x and y coordinates?

Tkinter is widely used to create GUI based applications. It has many toolkits and
functions or modules available which can be used to define the different attributes
of a particular application. For building GUI applications it provides some widgets
including buttons, text boxes and labels. We can customize the position of the
widget and its coordinates on the tkinter frame using other functions and libraries.
Let us suppose that we have created a text label widget which is having some position in the tkinter frame. Now, to get the actual coordinates of the widget, we can use the geometry methods available in the tkinter’s library.
We will use winfo_rootx() and winfo_rooty() functions which return the actual coordinates of the widget with respect to the frame or window.
#Import the tkinter library
from tkinter import *

#Create an instance of the tkinter frame
win = Tk()

#Define the geometry of the frame
win.geometry("600x400")

#Define the text-widget
my_text= Text(win, height = 5, width = 52)

# Create label
lab = Label(win, text ="TutorialsPoint.com")

#Configure it using other properties
lab.config(font =("Helvetica", 20))

#Create a button widget
my_button = Button(text="Hello")

#Define the position of the widget
my_button.place(x=100, y=100)

#Update the coordinates with respect to the tkinter frame
win.update()

#Get the coordinates of both text widget and button widget
widget_x1, widget_y1 = my_button.winfo_rootx(),
my_button.winfo_rooty()
widget_x2, widget_y2 = my_text.winfo_rootx(),
my_button.winfo_rooty()

lab.pack()

print(widget_x1, widget_y1)
print(widget_x2, widget_y2)

#Keep the window running
win.mainloop()
Running the above code snippet will print the current position of widget as,
134 157
0 157
C++ Stdexcept Library - invalid_argument

It is an invalid argument exception and this class defines the type of objects thrown as exceptions to report an invalid argument.
Following is the declaration for std::invalid_argument.
class invalid_argument;
class invalid_argument;
none
none
constructor − Here the string passed as what_arg has the same content as the value returned by member what.
In below example for std::invalid_argument.
#include <iostream>
#include <stdexcept>
#include <bitset>
#include <string>
int main (void) {
   try {
      std::bitset<5> mybitset (std::string("01203040"));
   } catch (const std::invalid_argument& ia) {
      std::cerr << "Invalid argument: " << ia.what() << '\n';
   }
   return 0;
}
The output should be like this −
Invalid argument: bitset::_M_copy_from_ptr

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

The C library function int fputs(const char *str, FILE *stream) writes a string to the specified stream up to but not including the null character.
Following is the declaration for fputs() function.
int fputs(const char *str, FILE *stream)
str − This is an array containing the null-terminated sequence of characters to be written.
str − This is an array containing the null-terminated sequence of characters to be written.
stream − This is the pointer to a FILE object that identifies the stream where the string is to be written.
stream − This is the pointer to a FILE object that identifies the stream where the string is to be written.
This function returns a non-negative value, or else on error it returns EOF.
The following example shows the usage of fputs() function.
#include <stdio.h>

int main () {
   FILE *fp;

   fp = fopen("file.txt", "w+");

   fputs("This is c programming.", fp);
   fputs("This is a system programming language.", fp);

   fclose(fp);
   
   return(0);
}
Let us compile and run the above program, this will create a file file.txt with the following content −
This is c programming.This is a system programming language.

Now let's see the content of the above file using the following program −
#include <stdio.h>

int main () {
   FILE *fp;
   int c;

   fp = fopen("file.txt","r");
   while(1) {
      c = fgetc(fp);
      if( feof(fp) ) {
         break ;
      }
      printf("%c", c);
   }
   fclose(fp);
   return(0);
}
Let us compile and run the above program to produce the following result.
This is c programming.This is a system programming language.


    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
DAX Date & Time - DAY function

Returns the day of the month, a number from 1 to 31.
DAY (<date>) 

date
A date in datetime format or a text representation of a date.
An integer indicating the day of the month.
The argument to the DAY function is the Date of the day. DAX handles the date values in datetime format.
You can specify Date as one of the following −
An output of another date function.
An output of another date function.
An expression that returns a date.
An expression that returns a date.
A date in a datetime format.
A date in a datetime format.
A date as text representation in one of the accepted string formats for dates.
A date as text representation in one of the accepted string formats for dates.
The DAY function uses the locale and date/time settings of the client computer to understand the text value in order to perform the conversion. For example,
If the current date/time settings represent dates in the format of Month/Day/Year, then the string, "1/8/2016" is understood as a datetime value equivalent to 8th January, 2016 and the function returns 8.
If the current date/time settings represent dates in the format of Month/Day/Year, then the string, "1/8/2016" is understood as a datetime value equivalent to 8th January, 2016 and the function returns 8.
If the current date/time settings represent dates in the format of Day/Month/Year, the same string would be understood as a datetime value equivalent to 1st August, 2016, and the function returns 1.
If the current date/time settings represent dates in the format of Day/Month/Year, the same string would be understood as a datetime value equivalent to 1st August, 2016, and the function returns 1.
= DAY ("8-Jan") returns 8. 
= DAY ("3/5/2016") returns 5. 
= DAY ("March 5, 2016") returns 5. 
= DAY (TODAY ()) returns 16 if TODAY () returns 12/16/2016 12:00:00 AM. 
= DAY ([Date]) returns a calculated column with day values. 

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
What kind of variables can we access in a lambda expression in Java?

The lambda expressions consist of two parts, one is parameter and another is an expression and these two parts have separated by an arrow (->) symbol. A lambda expression can access a variable of it's enclosing scope. 
A Lambda expression has access to both instance and static variables of it's enclosing class and also it can access local variables which are effectively final or final.
( argument-list ) -> expression
interface TestInterface {
   void print();
}
public class LambdaExpressionTest {
   int a; // instance variable
   static int b; // static variable
   LambdaExpressionTest(int x) {    // constructor to initialise instance variable
      this.a = x;
   }
   void show() {
      // lambda expression to define print() method
      TestInterface testInterface = () -> {
      // accessing of instance and static variable using lambda expression
         System.out.println("Value of a is: "+ a);
         System.out.println("Value of b is: "+ b);
      };
      testInterface.print();
   }
   public static void main(String arg[]) {
      LambdaExpressionTest test = new LambdaExpressionTest(10);
      test.show();
   }
}
Value of a is: 10
Value of b is: 0
Vertically align numeric values in Java using Formatter

To vertically align numeric values in Java, use Formatter. For working with Formatter class, import the following package.
import java.util.Formatter;
Take an array −
double arr[] = { 2.5, 4.8, 5.7, 6.5, 9.4, 8.4, 9.5, 10.2, 11.5 };
While displaying this double array values, use the %f to set spaces −
for (double d : arr) {
   f.format("%12.2f %12.2f %12.2f\n", d, Math.ceil(d), Math.floor(d));
}
Above, we have also set the decimal places i.e. 12.2f is for 2 decimal places.
The following is an example −
 Live Demo
import java.util.Formatter;
public class Demo {
   public static void main(String[] argv) throws Exception {
      double arr[] = { 2.5, 4.8, 5.7, 6.5, 9.4, 8.4, 9.5, 10.2, 11.5 };
      Formatter f = new Formatter();
      f.format("%12s %12s %12s\n", "Points1", "Points2", "Points3");
      System.out.println("The point list...\n");
      for (double d : arr) {
         f.format("%12.2f %12.2f %12.2f\n", d, Math.ceil(d), Math.floor(d));
      }
      System.out.println(f);
   }
}
The point list...
Points1  Points2  Points3
2.50     3.00     2.00
4.80     5.00     4.00
5.70     6.00     5.00
6.50     7.00     6.00
9.40     10.00    9.00
8.40     9.00     8.00
9.50     10.00    9.00
10.20    11.00    10.00
11.50    12.00    11.00
Batch Script - Logging

Logging in is possible in Batch Script by using the redirection command.
test.bat > testlog.txt 2> testerrors.txt

Create a file called test.bat and enter the following command in the file.
net statistics /Server

The above command has an error because the option to the net statistics command is given in the wrong way.
If the command with the above test.bat file is run as
test.bat > testlog.txt 2> testerrors.txt

And you open the file testerrors.txt, you will see the following error.
The option /SERVER is unknown.

The syntax of this command is −
NET STATISTICS
[WORKSTATION | SERVER]

More help is available by typing NET HELPMSG 3506.
If you open the file called testlog.txt, it will show you a log of what commands were executed.
C:\tp>net statistics /Server

 Print
 Add Notes
 Bookmark this page
VBScript Date Function

The Function returns the current system Date.
date()

<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         a = date()
         document.write("The Value of a : " & a)
       
      </script>
   </body>
</html>
When you save it as .html and execute it in Internet Explorer, then the above script will produce the following result −
The Value of a : 19/07/2013 


    63 Lectures 
     4 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page
Check if a Queen can attack a given cell on chessboard in Python

Suppose we have two coordinates on a chessboard for queen and opponent. These points are Q and O respectively. We have to check whether the queen can attack the opponent or not. As we know that the queen can attack in the same row, same column and diagonally.
So, if the input is like Q = (1, 1) O = (4, 4), then the output will be True as Q can go (4, 4) diagonally.
To solve this, we will follow these steps −
if x of Q is same as x of O, thenreturn True
return True
if y of Q is same as y of O, thenreturn True
return True
if |x of Q - x of O| is same as |y of Q - y of O|, thenreturn True
return True
return False
Let us see the following implementation to get better understanding −
 Live Demo
def solve(Q, O):
   if Q[0] == O[0]:
      return True
   if Q[1] == O[1]:
      return True
   if abs(Q[0] - O[0]) == abs(Q[1] - O[1]):
      return True
   return False
Q = (1, 1)
O = (4, 4)
print(solve(Q, O))
(1, 1), (4, 4)
True
Adding Images to a Slide in a PPT using Java - GeeksforGeeks

28 Dec, 2020
In Java, using createPicture() method from XSLFSlide, images can be added to the PPT. Now the computer doesn’t understand, what’s there in the picture, so internally, this method accepts the image in a byte array format —> (a series of non-understandable random numbers, letters, symbols, etc.) something like this, AGETRDYDC5545#$^NHVGCFFSFSFGSDF#@@?.0976*).
The syntax for an empty slideshow
XMLSlideShow ppt = new XMLSlideShow();
The syntax for creating slide
XSLFSlide slide = ppt.createSlide();
The next task is to read the image file, which we wish to insert, and then convert it into a byte array using IOUtils.toByteArray() —> IOUtils class.
Add image into the presentation, using addPicture():
Byte array format of the picture which is to be added(written in the code as byte[] photo)
A static variable, which represents the file format of the image.
Syntax:
int idx = ppt.addPicture(photo, XSLFPictureData.PICTURE_TYPE_PNG);
Insert the image to a slide, using createPicture().
XSLFPictureShape pic = slide.createPicture(idx);
Implementation:
Java
// Adding Images to a slide in a PPT using javaimport java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;  import org.apache.poi.util.IOUtils;import org.apache.poi.xslf.usermodel.XMLSlideShow;import org.apache.poi.xslf.usermodel.XSLFPictureData;import org.apache.poi.xslf.usermodel.XSLFPictureShape;import org.apache.poi.xslf.usermodel.XSLFSlide;  public class InsertingImage {      public static void main(String args[])        throws IOException    {          XMLSlideShow ppt = new XMLSlideShow();          XSLFSlide slide = ppt.createSlide();          File image            = new File("C://Folder//codingisfun.png");          byte[] photo = IOUtils.toByteArray(            new FileInputStream(image));          int idx = ppt.addPicture(            photo, XSLFPictureData.PICTURE_TYPE_PNG);          XSLFPictureShape pic = slide.createPicture(idx);          // we are creating a file object        File file = new File("insertingimg.pptx");        FileOutputStream out = new FileOutputStream(file);          // saving the changes to the file we created        ppt.write(out);        System.out.println("image is inserted");        out.close();    }}
Commands for Compilation and Execution:
$javac InsertingImage.java
$java InsertingImage
Output:
Reordering of the slides is done.
Picked
Java
Java Programs
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Initialize an ArrayList in Java
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Interfaces in Java
ArrayList in Java
Convert a String to Character array in Java
Initializing a List in Java
Java Programming Examples
Convert Double to Integer in Java
Implementing a Linked List in Java using Class
Pytest - Grouping the Tests

In this chapter, we will learn how to group the tests using markers.
Pytest allows us to use markers on test functions. Markers are used to set various features/attributes to test functions. Pytest provides many inbuilt markers such as xfail, skip and parametrize. Apart from that, users can create their own marker names. Markers are applied on the tests using the syntax given below −
@pytest.mark.<markername>

To use markers, we have to import pytest module in the test file. We can define our own marker names to the tests and run the tests having those marker names.
To run the marked tests, we can use the following syntax −
pytest -m <markername> -v

-m <markername> represents the marker name of the tests to be executed.
Update our test files test_compare.py and test_square.py with the following code. We are defining 3 markers – great, square, others.
import pytest
@pytest.mark.great
def test_greater():
   num = 100
   assert num > 100

@pytest.mark.great
def test_greater_equal():
   num = 100
   assert num >= 100

@pytest.mark.others
def test_less():
   num = 100
   assert num < 200
import pytest
import math

@pytest.mark.square
def test_sqrt():
   num = 25
   assert math.sqrt(num) == 5

@pytest.mark.square
def testsquare():
   num = 7
   assert 7*7 == 40

@pytest.mark.others
   def test_equality():
   assert 10 == 11
Now to run the tests marked as others, run the following command −
pytest -m others -v

See the result below. It ran the 2 tests marked as others.
test_compare.py::test_less PASSED
test_square.py::test_equality FAILED
============================================== FAILURES
==============================================
___________________________________________ test_equality
____________________________________________
   @pytest.mark.others
   def test_equality():
>  assert 10 == 11
E  assert 10 == 11
test_square.py:16: AssertionError
========================== 1 failed, 1 passed, 4 deselected in 0.08 seconds
==========================

Similarly, we can run tests with other markers also – great, compare

    21 Lectures 
     4 hours 

 Lucian Musat

    22 Lectures 
     1.5 hours 

 Fanuel Mapuwei

    44 Lectures 
     3.5 hours 

 Rohit Dharaviya
 Print
 Add Notes
 Bookmark this page
How to check if a string is a subset of another string in R?

To check whether a string is a subset of another string we can use grepl function.
> Company <- "TutorialsPoint"
> Job <- "Tutor"
> grepl(Job, Company, fixed = TRUE)
[1] TRUE
Here we are getting TRUE because Tutor is a subset of TutorialsPoint.
> grepl(Company, Job, fixed = TRUE)
[1] FALSE
Here we are getting FALSE because TutorialsPoint is not a subset of Tutor.
Can a C++ virtual functions have default parameters?

Yes, C++ virtual functions can have default parameters.
 Live Demo
#include<iostream>
using namespace std;
class B {
   public:
      virtual void s(int a = 0) {
         cout<<" In Base \n";
      }
};

class D: public B {
   public:
      virtual void s(int a) {
         cout<<"In Derived, a="<<a;
      }
};

int main(void) {
   D d; // An object of class D
   B *b = &d;// A pointer of type B* pointing to d
   b->s();// prints"D::s() called"
   return 0;
}
In Derived, a=0
In this output, we observe that, s() of derived class is called and default value of base class s() is used.
Default arguments do not participate in signature of functions. So signatures of s() in base class and derived class are considered same, hence base class’s s() is overridden. Default value is used at compile time. When compiler checks that an argument is missing in a function call, it substitutes the default value given. Therefore, in the above program, value of x is substituted at compile time, and at run time derived class’s s() is called. Value of a is substituted at compile time, and at run time derived class’s s() is called.