code-rag-bench/online-tutorials huggingface dataset:
How to add color breezing effect using pygame? - GeeksforGeeks

19 Apr, 2022
Pygame is a python library that can be used specifically to design and build games. Pygame supports only 2d games that are built using different sprites. Pygame is not particularly best for designing games as it is very complex to use and doesn’t have a proper GUI like unity but it definitely builds logic for further complex projects.
Before initializing pygame library we need to install it. To install it type the below command in the terminal.
pip install pygame
Pygame contains color coding in the format of a tuple that contains three values, these values indicate the intensities of the three core colors i.e. red, blue, green. The values of the individual colors can be changed in order to make another unique color. As the values of the tuple are mutable at the run time too, it gives us the flexibility to add some color effects to make our game/application more unique and beautiful.
one of the color effects is a breezing effect, a breezing effect is an effect in which the color changes from one shade to another smoothly without sudden or abrupt change. These effects can be seen in the RGB keyboard and mouse.
Example:
Python3
import pygameimport randomimport sys  # initializing the constructorpygame.init() # setting up variable screenscreen = pygame.display.set_mode((720,720)) # three arguments of the color tuplec1 = random.randint(0,255)c2 = random.randint(0,255)c3 = random.randint(0,255) # setting up variable clockclock = pygame.time.Clock() while True:    for ev in pygame.event.get():        if ev.type == pygame.QUIT:            pygame.quit()                 # increases the shade of    # the current color    if 0 < c1 < 255:        c1 += 1             # if value of c1 exceeds    # 255 it resets it to 0    elif c1 >= 255:        c1 -= 255             # if value of c1 precedes 0    # it is incremented by 3    elif c1 <= 0:        c1 += 3             # sets game fps to 60    clock.tick(60)         # sets bg color to tuple    # (c1,c2,c3)    screen.fill((c1,c2,c3))         # updates the frames of    # the game    pygame.display.update()
Output: 
 
anshitaagarwal
gabaa406
sagartomar9927
Python-PyGame
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
How to select at the same time from two Tkinter Listbox?

Let us consider a situation for a particular system to keep selecting multiple files from a directory and, once copied in the clipboard, paste them into another directory. The idea of making multiple selections in ListBoxes can be implemented by using the exportselection property. The property prevents the selected options from losing while choosing an item from another ListBox. Thus, we can select multiple options from the ListBoxes. To configure a Listbox to behave like keep selection steady, we can make exportselection = False.
#Import Tkinter library
from tkinter import *
#Create an instance of Tkinter frame or window
win= Tk()
#Set the geometry of tkinter frame
win.geometry("750x350")
#Create ListBoxes
listboxA=Listbox(win, exportselection=False) #Create listboxA
listboxA.pack(padx=10,pady=10,fill=BOTH,expand=True)
listboxB=Listbox(win,exportselection=False) #Create ListboxB
listboxB.pack(padx=10,pady=10,fill=BOTH,expand=True)
listboxA.insert(1, "1.Python")
listboxA.insert(2, "2.Java")
listboxA.insert(3, "3.C++")
listboxA.insert(4, "4.Rust")
listboxA.insert(5, "5.GoLang")
listboxB.insert(1, "a.C#")
listboxB.insert(2, "b.JavaScript")
listboxB.insert(3, "c.R")
listboxB.insert(4, "d.Php")
listboxB.insert(5, "e.CoffeeScript")
listboxB.insert(6, "f.Curl")
win.mainloop()
Running the above code will display a window that contains two listboxes. While making a selection, we can select multiple items from both listboxes.
Java Examples - Find proxy settings

How to find proxy settings of a System ?
Following example shows how to find proxy settings & create a proxy connection on a system using put method of systemSetting & getResponse method of HttpURLConnection class.
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Properties;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.URI;

public class Main{
   public static void main(String s[]) throws Exception {
      try {
         Properties systemSettings = System.getProperties();
         systemSettings.put("proxySet", "true");
         systemSettings.put("http.proxyHost", "proxy.mycompany1.local");
         systemSettings.put("http.proxyPort", "80");
         
         URL u = new URL("http://www.google.com");
         HttpURLConnection con = (HttpURLConnection)u.openConnection();
         System.out.println(con.getResponseCode() + " : " + con.getResponseMessage());
         System.out.println(con.getResponseCode() == HttpURLConnection.HTTP_OK);
      } catch (Exception e) {
         e.printStackTrace();
         System.out.println(false);
      }
      System.setProperty("java.net.useSystemProxies", "true");
      Proxy proxy = (Proxy) ProxySelector.getDefault().select(new URI(
         "http://www.yahoo.com/")).iterator().
      next();;
      System.out.println("proxy hostname : " + proxy.type());
      InetSocketAddress addr = (InetSocketAddress)proxy.address();
      
      if (addr == null) {
         System.out.println("No Proxy");
      } else {
         System.out.println("proxy hostname : " + addr.getHostName());
         System.out.println("proxy port : " + addr.getPort());
      }
   }
}
The above code sample will produce the following result.
200 : OK
true
proxy hostname : HTTP
proxy hostname : proxy.mycompany1.local
proxy port : 80

The following is an example to find proxy settings of a System ?
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.URI;
import java.util.Iterator;
import java.util.List;

public class NewClass {
   public static void main(String[] args) {
      try {
         System.setProperty("java.net.useSystemProxies", "true");
         List<Proxy> l = ProxySelector.getDefault().select(
            new URI("http://www.google.com/"));
         
         for (Iterator<Proxy> iter = l.iterator(); iter.hasNext();) {
            Proxy proxy = iter.next();
            System.out.println("proxy hostname : " + proxy.type());
            InetSocketAddress addr = (InetSocketAddress) proxy.address();
            
            if (addr == null) {
               System.out.println("No Proxy");
            } else {
               System.out.println("proxy hostname : " + addr.getHostName());
               System.out.println("proxy port : " + addr.getPort());
            } 
         }
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
}
The above code sample will produce the following result.
proxy hostname : DIRECT
No Proxy

 Print
 Add Notes
 Bookmark this page
Java program to print the Armstrong numbers between two numbers

An Armstrong number is a number which equals to the sum of the cubes of its individual digits. For example, 153 is an Armstrong number as −
153 = (1)3 + (5)3 + (3)3
153 1 + 125 + 27
154 153
1. Take integer variable Arms.
2. Assign a value to the variable.
3. Split all digits of Arms.
4. Find cube-value of each digit.
5. Add all cube-values together.
6. Save the output to Sum variable.
7. If Sum equals to Arms print Armstrong Number.
8. If Sum does not equal to Arms print Not Armstrong Number.
import java.util.Scanner;
public class ArmstrongBetweenTwoNumbers {
   public static void main(String args[]){
      int num1, num2;
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter the first number ::");
      num1 = sc.nextInt();
      System.out.println("Enter the second number ::");
      num2 = sc.nextInt();

      for (int i = num1; i<num2; i++){
         int check, rem, sum = 0;
         check = i;
         while(check != 0) {
            rem = check % 10;
            sum = sum + (rem * rem * rem);
            check = check / 10;
         }
         if(sum == i){
            System.out.println(""+i+" is an Armstrong number.");
         }
      }
   }
}
Enter the first number::
1
Enter the second number::
500
1 is an Armstrong number.
153 is an Armstrong number.
370 is an Armstrong number.
371 is an Armstrong number.
407 is an Armstrong number.
How to perform Bitwise And operation on two images using Java OpenCV?

You can compute bitwise conjunction between two images using the bitwise_and() method of the org.opencv.core.Core class.
This method accepts three Mat objects representing the source, destination and result matrices, calculates the bitwise conjunction of each every element in the source matrices and stores the result in the destination matrix.
In the following Java example we are converting an image into binary and gray scale and calculating the bitwise conjunction of the results.
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
public class BitwiseAndExample {
   public static void main(String args[]) throws Exception {
      //Loading the OpenCV core library
      System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
      //Reading the Image
      String file ="D://images//elephant.jpg";
      Mat src = Imgcodecs.imread(file, Imgcodecs.IMREAD_GRAYSCALE );
      HighGui.imshow("Grayscale Image", src);
      //Creating an empty matrix to store the results
      Mat dst = new Mat(src.rows(), src.cols(), src.type());
      Mat threshold = new Mat(src.rows(), src.cols(), src.type());
      Mat gray = new Mat(src.rows(), src.cols(), src.type());
      //Converting the gray scale image to binary image
      Imgproc.threshold(src, threshold, 100, 255, Imgproc.THRESH_BINARY_INV);
      HighGui.imshow("Binary Image", threshold);
      //Applying bitwise and operation
      Core.bitwise_and(src, threshold, dst);
      HighGui.imshow("Bitwise And operation", dst);
      HighGui.waitKey();
   }
}
On executing, the above program generates the following windows −
Gray Scale Image −
Binary Image −
Bitwise And −
Functional Programming - Pure Function

A function is considered as Pure Function if it fulfils the following two conditions −
It always returns the same result for the given inputs and its results purely depends upon the inputs passed.
It always returns the same result for the given inputs and its results purely depends upon the inputs passed.
It has no side effects means it is not modifying any state of the caller entity.
It has no side effects means it is not modifying any state of the caller entity.
public class FunctionTester {    
   public static void main(String[] args) {
      int result = sum(2,3);
      System.out.println(result);
  
      result = sum(2,3);
      System.out.println(result);
   }
   static int sum(int a, int b){
      return a + b;
   }
}
5
5

Here sum() is a pure function as it always return 5 when passed 2 and 3 as parameters at different times and has no side effects.
public class FunctionTester {
   private static double valueUsed = 0.0; 
   public static void main(String[] args) {
      double result = randomSum(2.0,3.0);
      System.out.println(result);
      result = randomSum(2.0,3.0);
      System.out.println(result);
   }
   
   static double randomSum(double a, double b){
      valueUsed = Math.random();       
      return valueUsed + a + b;
   }
}
5.919716721877799
5.4830887819586795

Here randomSum() is an impure function as it return different results when passed 2 and 3 as parameters at different times and modifies state of instance variable as well.

    32 Lectures 
     3.5 hours 

 Pavan Lalwani

    11 Lectures 
     1 hours 

 Prof. Paul Cline, Ed.D

    72 Lectures 
     10.5 hours 

 Arun Ammasai

    51 Lectures 
     2 hours 

 Skillbakerystudios

    43 Lectures 
     4 hours 

 Mohammad Nauman

    8 Lectures 
     1 hours 

 Santharam Sivalenka
 Print
 Add Notes
 Bookmark this page
Ruby | Hash each_key() function - GeeksforGeeks

07 Jan, 2020
Hash#each_key() is a Hash class method which finds the nested value which calls block once for each_key key in hash by passing the key pair as parameters.
Syntax: Hash.each_key()
Parameter: Hash values
Return: calls block once for each_key key in hash with key as parameter otherwise Enumerator if no argument is passed.
Example #1 :
# Ruby code for Hash.each_key() method  # declaring Hash valuea = {a:100, b:200}  # declaring Hash valueb = {a:100, c:300, b:200}  # declaring Hash valuec = {a:100}    # each Valueputs "Hash a each_key form : #{a.each_key()}\n\n"  puts "Hash b each_key form : #{b.each_key {|key| puts "#{key}"}}\n\n"  puts "Hash c each_key form : #{c.each_key {|value| puts "#{value}"}}\n\n"
Output :
Hash a each_key form : #

a
c
b
Hash b each_key form : {:a=>100, :c=>300, :b=>200}

a
Hash c each_key form : {:a=>100}


Example #2 :
# Ruby code for Hash.each_key() method  # declaring Hash valuea = { "a" => 100, "b" => 200 }  # declaring Hash valueb = {"a" => 100}  # declaring Hash valuec = {"a" => 100, "c" => 300, "b" => 200}    # each Valueputs "Hash a each_key form : #{a.each_key()}\n\n"  puts "Hash b each_key form : #{b.each_key {|key| puts "#{key}"}}\n\n"  puts "Hash c each_key form : #{c.each_key {|value| puts "#{value}"}}\n\n"
Output :
Hash a each_key form : #

a
Hash b each_key form : {"a"=>100}

a
c
b
Hash c each_key form : {"a"=>100, "c"=>300, "b"=>200}


Ruby Hash-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Ruby | Array count() operation
Include v/s Extend in Ruby
Global Variable in Ruby
Ruby | Hash delete() function
Ruby | Types of Variables
Ruby | Enumerator each_with_index function
Ruby | Case Statement
Ruby | Array select() function
Ruby | Numeric round() function
Ruby | Data Types
ISRO | ISRO CS 2013 | Question 39 - GeeksforGeeks

08 May, 2018
If the frame to be transmitted is 1101011011 and the CRC polynomial to be used for generating checksum is x4+ x + 1, then what is the transmitted frame?(A) 11010110111011(B) 11010110111101(C) 11010110111110(D) 11010110111001Answer: (C)Explanation:
Step-1: 
Append (number of bits in divisor - 1) number
of zeroes at the end of data unit
Data unit = 1101011011, Divisor = 10011,
So, append 4 zeroes at the end.
          = 11010110110000

Step 2
Divide using xor subtraction:      
      _________________
10111) 11010110110000  ( 101000001
       10111
       ------
        10011
        10011
        -------
              10110
              10011
             --------
                10100
                10011
               --------
                  1110


Step 3
Perform Xor-sum of the remainder with the appended
zeroes in data unit.
= 11010110110000 xor (1100)
= 11010110111110 
So, option (C) is correct.Quiz of this Question
ISRO
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ISRO | ISRO CS 2016 | Question 29
ISRO | ISRO CS 2017 - May | Question 17
ISRO | ISRO CS 2017 | Question 54
ISRO | ISRO CS 2007 | Question 55
ISRO | ISRO CS 2017 - May | Question 40
ISRO | ISRO CS 2007 | Question 80
ISRO | ISRO CS 2017 - May | Question 13
ISRO | ISRO CS 2013 | Question 54
ISRO | ISRO CS 2013 | Question 51
ISRO | ISRO CS 2016 | Question 49
Python: filecmp.cmp() method - GeeksforGeeks

10 Jan, 2020
Filecmp module in Python provides functions to compare files and directories. This module comes under Python’s standard utility modules. This module also consider the properties of files and directories for comparison in addition to data in them.
filecmp.cmp() method in Python is used to compare two files. This method by default performs shallow comparison (as by default shallow = True) that means only the os.stat() signatures (like size, date modified etc.) of both files are compared and if they have identical signatures then files are considered to be equal irrespective of contents of the files. If shallow is set to False then the comparison is done by comparing the contents of both files.
Syntax: filecmp.cmp(file1, file2, shallow = True)
Parameter:file1: The path of first file to be compared. It can be a string, bytes, os.PathLike object or an integer representing the path of the file.file2: The path of second file to be compared. It can be a string, bytes, os.PathLike object or an integer representing the path of the file.shallow (optional): A bool value ‘True’ or ‘False’. The default value of this parameter is True. If its value is True then only the metadata of files are compared. If False then the contents of the files are compared.
Return Type: This method returns a bool value True if specified files are equal or False if they are not.
# Python program to demonstrate# filecmp.cmp() method       import filecmp    # Path of first filefile1 = "/home/geeks/Desktop/gfg/data.txt"  # Path of second filefile2 = "/home/geeks/Desktop/gfg/gfg.txt"   # Compare the os.stat()# signature i.e the metadata# of both files comp = filecmp.cmp(file1, file2)  # Print the result of comparisonprint(comp)  # Compare the# contents of both filescomp = filecmp.cmp(file1, file2, shallow = False)  # Print the result of comparisonprint(comp)
False
True

python-file-handling
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
PLSQL | SIGN Function - GeeksforGeeks

25 Oct, 2019
The PLSQL SIGN function is used for returning a value which indicates the sign of a number. The SIGN function accepts one parameter which is the number whose sign needs to be known. The SIGN function returns a value of the numeric data type. This function takes as an argument any numeric data type as well as any non-numeric data type that can be implicitly converted to a numeric data type.
The possible values returned by the SIGN function are:
The SIGN function returns -1 if the number is smaller than 0.
The SIGN function returns 0 if the number is equal to 0.
The SIGN function returns 1 if the number is greater than 0.
Syntax:
SIGN (number)
Parameters Used:
number – It is used to specify the number whose sign needs to be tested.
Return Value:The SIGN function in PLSQL returns a numeric value.
Supported Versions of Oracle/PLSQL:
Oracle 12cOracle 11gOracle 10gOracle 9iOracle 8i
Oracle 12c
Oracle 11g
Oracle 10g
Oracle 9i
Oracle 8i
Example-1: Using positive numeric value as an argument in the SIGN function.
DECLARE 
   Test_Number1 number := 5;
   
BEGIN 
   dbms_output.put_line(SIGN(Test_Number1)); 
   
END; 
Output:
1 
Example-2: Using negative numeric value as an argument in the SIGN function.
DECLARE 
   Test_Number1 number := -5;
   
BEGIN 
   dbms_output.put_line(SIGN(Test_Number1)); 
   
END;

Output:
-1 
Example-3: Using zero as an argument in the SIGN function.
DECLARE 
   Test_Number1 number := 0;
   
BEGIN 
   dbms_output.put_line(SIGN(Test_Number1)); 
   
END; 
Output:
0 
Example-4: Using a positive number with decimal value as an argument in the SIGN function.
DECLARE 
   Test_Number1 number := 0.0032;
   
BEGIN 
   dbms_output.put_line(SIGN(Test_Number1)); 
   
END; 
Output:
1 
Example-5: Using a negative number with decimal value as an argument in the SIGN function.
DECLARE 
   Test_Number1 number := - 0.0032;
   
BEGIN 
   dbms_output.put_line(SIGN(Test_Number1)); 
   
END; 
Example-6: Using SIGN function with select query.
SELECT SIGN(-5) "Sign" FROM DUAL; 
Output:
Sign
-1 
Advantages:The SIGN function accepts any numeric datatype as well as any non-numeric datatype as an argument that can be implicitly converted to a numeric datatype.
SQL-PL/SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Subquery
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL Query to Convert VARCHAR to INT
SQL using Python
How to Write a SQL Query For a Specific Date Range and Date Time?
How to Select Data Between Two Dates and Times in SQL Server?
SQL Query to Compare Two Dates
How to use PowerShell Help commands?

To get help for the particular command, you can use Get-Help (alias: help)  cmdlet with the command that you need help.
For example,
help Get-Service
Once you run this command, you will get the description of NAME, SYNOPSIS, SYNTAX, DESCRIPTION, RELATED LINKS, and REMARKS.
Multiple parameters that support help as shown below
-Full − Detailed help with parameter explanation and examples.
-Full − Detailed help with parameter explanation and examples.
help Get-Service -Full
-Detailed − Detailed help of parameters and doesn’t include the examples.
-Detailed − Detailed help of parameters and doesn’t include the examples.
help Get-Service -Detailed
-Examples − Only help related to examples will be displayed on the PowerShell screen.
-Examples − Only help related to examples will be displayed on the PowerShell screen.
help Get-Service -Examples

-Online − Help contents for the cmdlet will be searched online on the Microsoft website.
-Online − Help contents for the cmdlet will be searched online on the Microsoft website.
help Get-Service -Online
When you install or update PowerShell version or install a new operating system that comes with the PowerShell installed then you need to make sure to update the help content from Microsoft website and that can be done using Update-Help command and that is recommended once in a month because some help contents get outdated and MS continuously updates their help content.
Some help for cmdlets is not visible if the outdated help resides in your system at that time you need to update the help content.
When -ShowWindow parameter is specified, help will be displayed in the separate window for that specific command. For example,
help Get-Service -ShowWindow
Here, in the Settings button, there are options to filter out specific items.
If you need any specific section(s) related help the select that setting(s).
If you need help with the parameters in command line then use -Parameter and command name. For example,
help Get-Service -Parameter ComputerName
PS C:\Users\Chirag.Nagarekar> help Get-Service -Parameter ComputerName -ComputerName <System.String[]>
Gets the services running on the specified computers. The default is the local computer.
Type the NetBIOS name, an IP address, or a fully qualified domain name (FQDN)
of a remote computer. To specify the local computer, type the
computer name, a dot (.), or localhost.

This parameter does not rely on Windows PowerShell remoting. You can use the
ComputerName parameter of Get-Service even if your computer is not configured to run remote commands.

Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
If you need to display all the parameters then use * instead of the parameter name.
help Get-Service -Parameter *
Similarly, if you need help related to only example sections in command line then use -Examples in command.
help Get-Service -Examples
Solidity - View Functions

View functions ensure that they will not modify the state. A function can be declared as view. The following statements if present in the function are considered modifying the state and compiler will throw warning in such cases.
Modifying state variables.
Modifying state variables.
Emitting events.
Emitting events.
Creating other contracts.
Creating other contracts.
Using selfdestruct.
Using selfdestruct.
Sending Ether via calls.
Sending Ether via calls.
Calling any function which is not marked view or pure.
Calling any function which is not marked view or pure.
Using low-level calls.
Using low-level calls.
Using inline assembly containing certain opcodes.
Using inline assembly containing certain opcodes.
Getter method are by default view functions.
See the example below using a view function.
pragma solidity ^0.5.0;

contract Test {
   function getResult() public view returns(uint product, uint sum){
      uint a = 1; // local variable
      uint b = 2;
      product = a * b;
      sum = a + b; 
   }
}
Run the above program using steps provided in Solidity First Application chapter.
0: uint256: product 2
1: uint256: sum 3


    38 Lectures 
     4.5 hours 

 Abhilash Nelson

    62 Lectures 
     8.5 hours 

 Frahaan Hussain

    31 Lectures 
     3.5 hours 

 Swapnil Kole
 Print
 Add Notes
 Bookmark this page
jQuery | resize() with Examples

13 Feb, 2019
The resize() method is an inbuilt method in jQuery which is used when the browser window change its size.
Syntax:
$(selector).resize(function)
Parameter: This method accepts single parameter function which is optional. It is used to specify the function to run when the resize event is called.
Return Value: This method returns the selected element with increases its size.
Below example illustrates the resize() method in jQuery:
Example:
<!DOCTYPE html><html>    <head>        <title>The resize method</title>        <script src=        "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">        </script>                  <!-- jQuery code to show the working of this method -->        <script>            x = 0;            $(document).ready(function() {                $(window).resize(function() {                    $("p").text(x += 1);                });            });        </script>        <style>            div {                width: 150px;                height: 100px;                padding: 20px;                border: 2px solid green;                font-size: 20px;            }        </style>    </head>           <body>        <div>            <!-- press "ctrl" and "+" key together            and see the effect -->            Welcome to GfG!            <br>            <p>0</p>            times.        </div>    </body></html>
Output:Before click anything.After clicking 2 times “ctrl” and “+” key together in keyboard.
jQuery-Events
JavaScript
JQuery
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
How to append HTML code to a div using JavaScript ?
JQuery | Set the value of an input text field
Form validation using jQuery
How to change selected value of a drop-down list using jQuery?
How to add options to a select element using jQuery?
How to fetch data from JSON file and display in HTML table using jQuery ?
How to get parameters from a URL string in PHP?

28 Feb, 2022
The parameters from a URL string can be be retrieved in PHP using parse_url() and parse_str() functions.
Note: Page URL and the parameters are separated by the ? character.
parse_url() Function: The parse_url() function is used to return the components of a URL by parsing it. It parse an URL and return an associative array which contains its various components.
Syntax: 
parse_url( $url, $component = -1 )
parse_str() Function: The parse_str() function is used to parse a query string into variables. The string passed to this function for parsing is in the format of a query string passed via a URL.
Syntax:  
parse_str( $string, $array )
Approach: Parse the URL string using parse_url() function which will return an associative array that contains its (passed URL) various components. The query of the array returned by parse_url() function which contains a query string of URL.
Below examples uses parse_url() and parse_str() function to get the parameters from URL string. 
Example 1:  
PHP
<?php  // Initialize URL to the variable$url = 'https://www.geeksforgeeks.org?name=Tonny';      // Use parse_url() function to parse the URL // and return an associative array which// contains its various components$url_components = parse_url($url);  // Use parse_str() function to parse the// string passed via URLparse_str($url_components['query'], $params);      // Display resultecho ' Hi '.$params['name'];  ?>
Hi Tonny
 
Example 2: 
PHP
<?php  // Initialize URL to the variable$url = 'https://www.geeksforgeeks.org/register?name=Amit&email=amit1998@gmail.com';      // Use parse_url() function to parse the URL // and return an associative array which// contains its various components$url_components = parse_url($url);  // Use parse_str() function to parse the// string passed via URLparse_str($url_components['query'], $params);      // Display resultecho ' Hi '.$params['name'].' your emailID is '.$params['email'];  ?>
Hi Amit your emailID is amit1998@gmail.com
 
PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples.
gabaa406
Picked
PHP
PHP Programs
Web Technologies
Web technologies Questions
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to Upload Image into Database and Display it using PHP ?
How to check whether an array is empty using PHP?
PHP | Converting string to Date and DateTime
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to Upload Image into Database and Display it using PHP ?
How to check whether an array is empty using PHP?
How to call PHP function on the click of a Button ?
Using “not equal” in MySQL?

If you want to work with not equal operator, then use the <> operator. The syntax is as follows −
SELECT *FROM yourTableName WHERE yourColumnName <> anyValue;
To understand the above syntax, let us first create a table. The query to create a table is as follows −
mysql> create table NotEqualDemo
-> (
-> ProductId int
-> );
Query OK, 0 rows affected (0.53 sec)
Insert some records in the table using insert command. The query is as follows −
mysql> insert into NotEqualDemo values(101);
Query OK, 1 row affected (0.13 sec)

mysql> insert into NotEqualDemo values(102);
Query OK, 1 row affected (0.23 sec)

mysql> insert into NotEqualDemo values(103);
Query OK, 1 row affected (0.11 sec)

mysql> insert into NotEqualDemo values(104);
Query OK, 1 row affected (0.13 sec)

mysql> insert into NotEqualDemo values(105);
Query OK, 1 row affected (0.12 sec)
Let us now display all records from the table using select command. The query is as follows −
mysql> select *from NotEqualDemo;
The following is the output −
+-----------+
| ProductId |
+-----------+
| 101       |
| 102       |
| 103       |
| 104       |
| 105       |
+-----------+
5 rows in set (0.00 sec)
Here we are using <> operator to filter the data which is not equal to 104. In this, all the data will be displayed except 104. The query is as follows −
mysql> select *from NotEqualDemo where ProductId <> 104 or ProductId is null;
The following is the output −
+-----------+
| ProductId |
+-----------+
| 101       |
| 102       |
| 103       |
| 105       |
+-----------+
4 rows in set (0.00 sec)
PLSQL | LOG Function

25 Oct, 2019
The PLSQL LOG function is used for returning the logarithm of n base m. The LOG function accepts two parameters which are used to calculate the logarithmic value. The LOG function returns a value of the numeric data type.
This function takes as an argument any numeric data type as well as any non-numeric data type that can be implicitly converted to a numeric data type. If in any case, the argument is BINARY_FLOAT or BINARY_DOUBLE, then the LOG function returns BINARY_DOUBLE, otherwise it returns number.
Syntax:
LOG( m, n )
Parameters Used:
m – It is used to specify the base number. It should be any positive numeric value except 0 and 1.
n – It is used to specify the number whose logarithmic value needs to be calculated with a specific base. It should be a positive numeric value.
Return Value:The LOG function in PLSQL returns a numeric value.
Supported Versions of Oracle/PLSQL:
Oracle 12cOracle 11gOracle 10gOracle 9iOracle 8i
Oracle 12c
Oracle 11g
Oracle 10g
Oracle 9i
Oracle 8i
Example-1: Using positive numeric values as arguments in the LOG function.
DECLARE 
   Test_Number1 number := 9;
   Test_Number2 number := 3;
   
BEGIN 
   dbms_output.put_line(LOG(Test_Number1, 
                            Test_Number2)); 
   
END; 
Output:
0.5 
Example-2: Using positive numeric values as arguments in the LOG function.
DECLARE 
   Test_Number1 number := 3;
   Test_Number2 number := 9;
   
BEGIN 
   dbms_output.put_line(LOG(Test_Number1, 
                            Test_Number2)); 
   
END; 
Output:
2 
Example-3: Using same positive numeric values in both the arguments in the LOG function.
DECLARE 
   Test_Number1 number := 3;
   Test_Number2 number := 3;
   
BEGIN 
   dbms_output.put_line(LOG(Test_Number1, 
                            Test_Number2)); 
   
END; 
Output:
1 
Example-4: Using zero in the base value argument in the LOG function.
DECLARE 
   Test_Number1 number := 0;
   Test_Number2 number := 3;
   
BEGIN 
   dbms_output.put_line(LOG(Test_Number1, 
                            Test_Number2)); 
   
END; 
Output:
numeric or value error 
The above example throws error because the LOG function doesn’t except 0 and 1 as base values in the argument.
Example-5: Using LOG function with select query.
SELECT LOG(2, 8) "Log base 2 of 8" FROM DUAL; 
Output:
3 
Advantages:The LOG function accepts any numeric datatype as well as any non-numeric datatype as an argument that can be implicitly converted to a numeric datatype.
SQL-PL/SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ushort keyword in C#

22 Jun, 2020
Keywords are the words in a language that are used for some internal process or represent some predefined actions. ushort is a keyword that is used to declare a variable which can store an unsigned integer value from the range 0 to 65,535. It is an alias of System.UInt16.
Syntax:
ushort variable_name = value;
ushort keyword occupies 2 bytes (16 bits) space in the memory.
Example:
Input: num: 5

Output: num: 5
        Size of a ushort variable: 2

Input: num = 8765

Output: num: 8765
        Type of num: System.UInt16
        Size of a ushort variable: 2
Example 1:
// C# program for ushort keywordusing System;using System.Text;  class GFG {      static void Main(string[] args)    {        // variable declaration        ushort num = 5;          // to print value        Console.WriteLine("num: " + num);          // to print size        Console.WriteLine("Size of a ushort variable: " + sizeof(ushort));    }}
Output:
num: 5
Size of a ushort variable: 2

Example 2:
// C# program for ushort keywordusing System;using System.Text;  namespace Test {  class GFG {      static void Main(string[] args)    {        // variable declaration        ushort num = 8765;          // to print value        Console.WriteLine("num: " + num);          // to print type of variable        Console.WriteLine("Type of num: " + num.GetType());          // to print size        Console.WriteLine("Size of a ushort variable: " + sizeof(ushort));          // to print minimum & maximum value of ushort        Console.WriteLine("Min value of ushort: " + ushort.MinValue);        Console.WriteLine("Max value of ushort: " + ushort.MaxValue);    }}}
Output:
num: 8765
Type of num: System.UInt16
Size of a ushort variable: 2
Min value of ushort: 0
Max value of ushort: 65535

CSharp-keyword
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to change the width of an iframe to 100% using JavaScript ?

30 Jul, 2020
Given an HTML document containing an <iframe> element and the task is to change the width of the <iframe> element to 100% with the help of JavaScript. There are two methods to change the width of the iframe which are discussed below:
Method 1: This method uses id attribute of iframe with width property to change the width of <iframe> element. JavaScript’s code is written within the <script> tag.
HTML
<!DOCTYPE html><html>      <head>     <title>         How to change the width of an         iframe to 100% with JavaScript?     </title> </head>      <body>     <center>        <h1 style="color:green;">             GeeksforGeeks          </h1>         <h3>             How to change the width of a <br>            to 100% with JavaScript?         </h3>         <iframe id="iframe" height="100%" width="40%"            src="https://www.youtube.com/embed/HzeK7g8cD0Y"            frameborder="0" allowfullscreen>         </iframe>          <br><br>         <button onclick="changewidth()">             Click to change         </button>                   <script>               // JavaScript code to change the             // width to 100% of <iframe>             function changewidth() {                 var x = document.getElementById('iframe');                 x.style.width = "100%";             }         </script>     </center></body>  </html>
Output:
Before clicking the button:
After clicking the button:
Method 2: This method uses the id attribute of the iframe with window.innerWidth property to change the width of <iframe> element. JavaScript code is written within the <script> tag.
HTML
<!DOCTYPE html><html>      <head>     <title>         How to change the width of an         iframe to 100% with JavaScript?     </title> </head>      <body>     <center>        <h1 style="color:green;">             GeeksforGeeks          </h1>         <h3>             How to change the width of a <br>            to 100% with JavaScript?         </h3>         <iframe id="iframe" height="100%" width="40%"            src="https://www.youtube.com/embed/HzeK7g8cD0Y"            frameborder="0" allowfullscreen>         </iframe>          <br><br>         <button onclick="changewidth()">             Click to change         </button>                   <script>             // JavaScript code to change the             // width to 100% of <iframe>             function changewidth() {                 var x = document.getElementById('iframe');                 x.style.width = window.innerWidth;             }         </script>     </center></body>  </html>
Output:
Before clicking the button:
After clicking the button:
CSS-Misc
HTML-Misc
JavaScript-Misc
CSS
HTML
JavaScript
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
p5.js | keyPressed() Function

14 Jan, 2022
The keyPressed() function is invoked whenever a key is pressed. The most recently typed ASCII key is stored into the ‘key’ variable, however it does not distinguish between uppercase and lowercase characters. The non-ASCII character codes can be accessed in the ‘keyCode’ variable with their respective names.Holding down a key may cause multiple keyPressed() calls. This is due to how the Operating System handles keypressed and depends on how the computer is configured. A browser may have its own default behavior attached to various keys. This can be prevented by adding “return false” to the end of the method.Syntax:  
keyPressed()
Parameters: This method does not accept any parameters.Below examples illustrate the keyPressed() function in p5.js:Example 1:  
javascript
function setup() {  createCanvas(600, 200);  textSize(20);  text("Press any key to display it "          + "on the screen", 10, 20);} function keyPressed() {  clear();  textSize(20);  text("Press any key to display it "          + "on the screen", 10, 20);  textSize(100);  text(key, 100, 150);}
Output:  
Example 2:  
javascript
let opac = 128; function setup() {  createCanvas(700, 200);  background(0, 128, 0, opac);  textSize(22);  text("Press the left and right arrow"        + " keys to change the opacity"        + " of the color.", 10, 20);} function keyPressed() {  clear();   textSize(50);  text("Pressing: " + key, 100, 150);   // Reduce opacity if the left arrow is pressed  if (key == "ArrowLeft" && opac > 0)    opac -= 20;  // Increase opacity if the left arrow is pressed  else if (key == "ArrowRight" && opac < 255)    opac += 20;   // Set the new background color  background(0, 128, 0, opac);   textSize(22);  text("Press the left and right arrow"        + " keys to change the opacity"        + " of the color.", 10, 20);}
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/keyPressed 
adnanirshad158
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Hide or show elements in HTML using display property
Difference Between PUT and PATCH Request
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 ?
How to convert unix timestamp string to readable date in Python?

You can use the fromtimestamp function from the datetime module to get a date from a UNIX timestamp. This function takes the timestamp as input and returns the datetime object corresponding to the timestamp.  
import datetime
timestamp = datetime.datetime.fromtimestamp(1500000000)
print(timestamp.strftime('%Y-%m-%d %H:%M:%S'))
This will give the output −
2017-07-14 08:10:00
Minimum Increment to Make Array Unique in C++

Suppose we have an array of integers A, here a move consists of choosing any A[i], and incrementing it by 1. We have to find the least number of moves to make every value in A unique. So if the input is like [3,2,1,2,1,7], then the output will be 6, as after 6 moves, the array could be [3,4,1,2,5,7], it can be shown with 5 or less moves that it is impossible for the array to have all distinct values.
To solve this, we will follow these steps −
ret:= 0
ret:= 0
sort array A
sort array A
create one set called visited to keep track which value is considered before
create one set called visited to keep track which value is considered before
for i in range 1 to size of array A – 1if A[i] < A[i – 1], then ret := ret + (1 + A[i – 1 ]) – A[i], and A[i] := A[i – 1] + 1
for i in range 1 to size of array A – 1
if A[i] < A[i – 1], then ret := ret + (1 + A[i – 1 ]) – A[i], and A[i] := A[i – 1] + 1
if A[i] < A[i – 1], then ret := ret + (1 + A[i – 1 ]) – A[i], and A[i] := A[i – 1] + 1
return ret.
return ret.
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
   public:
   int minIncrementForUnique(vector<int>& A) {
      int ret = 0;
      sort(A.begin(), A.end());
      set <int> visited;
      for(int i = 1; i < A.size(); i++){
         if(A[i] <= A[i - 1]){
            ret+= (A[i - 1] + 1) - A[i];
            A[i] = A[i - 1] + 1;
         }
      }
      return ret;
   }
};
main(){
   vector<int> v1 = {3,2,1,2,1,7};
   Solution ob;
   cout << (ob.minIncrementForUnique(v1));
}
[3,2,1,2,1,7]
6
C# Program to Check Whether the Entered Number is an Armstrong Number or Not

For an Armstrong number, let us say a number has 3 digits, then the sum of cube of its digits is equal to the number itself.
For example, 153 is equal to −
13 + 33 + 53
To check for it using C#, check the value and find its remainder. Here “val” is the number you want to check for Armstrong −
for (int i = val; i > 0; i = i / 10) {
   rem = i % 10;
   sum = sum + rem*rem*rem;
}
Now compare the addition with the actual value. If it matches, that would mean the sum of cubes are the same and it is an Armstrong number −
if (sum == val) {
   Console.Write("Armstrong Number");
}else {
   Console.Write("Not an Armstrong Number");
}
Let us see a complete example to check whether a number is Armstrong or not.
Live Demo
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Demo {
   class ApplicationNew {
      static void Main(string[] args) {
         int val = 153, sum = 0;
         int rem;
         // check for armstrong
         for (int i = val; i > 0; i = i / 10) {
            rem = i % 10;
            sum = sum + rem*rem*rem;
         }
         if (sum == val) {
            Console.Write("Armstrong Number");
         } else {
            Console.Write("Not an Armstrong Number");
         }
         Console.ReadLine();
      }
   }
}
Armstrong Number
CSS3 - Shadow

CSS3 supported to add shadow to text or elements.Shadow property has divided as follows −
Text shadow
Box Shadow
CSS3 supported to add shadow effects to text. Following is the example to add shadow effects to text −
<html>
   <head>
      <style>
         h1 {
            text-shadow: 2px 2px;
         }
         h2 {
            text-shadow: 2px 2px red;
         }
         h3 {
            text-shadow: 2px 2px 5px red;
         }
         h4 {
            color: white;
            text-shadow: 2px 2px 4px #000000;
         }
         h5 {
            text-shadow: 0 0 3px #FF0000;
         }
         h6 {
            text-shadow: 0 0 3px #FF0000, 0 0 5px #0000FF;
         }
         p {
            color: white;
            text-shadow: 1px 1px 2px black, 0 0 25px blue, 0 0 5px darkblue;
         }
      </style>
   </head>

   <body>
      <h1>Tutorialspoint.com</h1>
      <h2>Tutorialspoint.com</h2>
      <h3>Tutorialspoint.com</h3>
      <h4>Tutorialspoint.com</h4>
      <h5>Tutorialspoint.com</h5>
      <h6>Tutorialspoint.com</h6>
      <p>Tutorialspoint.com</p>
   </body>
</html>
It will produce the following result −
Tutorialspoint.com
Used to add shadow effects to elements, Following is the example to add shadow effects to element.
<html>
   <head>
      <style>
         div {
            width: 300px;
            height: 100px;
            padding: 15px;
            background-color: red;
            box-shadow: 10px 10px;
         }
      </style>
   </head>

   <body>
      <div>This is a div element with a box-shadow</div>
   </body>
</html>
It will produce the following result −

    33 Lectures 
     2.5 hours 

 Anadi Sharma

    26 Lectures 
     2.5 hours 

 Frahaan Hussain

    44 Lectures 
     4.5 hours 

 DigiFisk (Programming Is Fun)

    21 Lectures 
     2.5 hours 

 DigiFisk (Programming Is Fun)

    51 Lectures 
     7.5 hours 

 DigiFisk (Programming Is Fun)

    52 Lectures 
     4 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page