code-rag-bench/online-tutorials huggingface dataset:
Linear Search in Python Program

In this article, we will learn about the Linear Search and its implementation in Python 3.x. Or earlier.
Start from the leftmost element of given arr[] and one by one compare element x with each element of arr[]
Start from the leftmost element of given arr[] and one by one compare element x with each element of arr[]
If x matches with any of the element, return the index value.
If x matches with any of the element, return the index value.
If x doesn’t match with any of elements in arr[] , return -1 or element not found.
If x doesn’t match with any of elements in arr[] , return -1 or element not found.
Now let’s see the visual representation of the given approach −
 Live Demo
def linearsearch(arr, x):
   for i in range(len(arr)):
      if arr[i] == x:
         return i
   return -1
arr = ['t','u','t','o','r','i','a','l']
x = 'a'
print("element found at index "+str(linearsearch(arr,x)))
Here we linearly scan the list with the help of for loop.
element found at index 6
The scope of the variables are shown in the figure −
In this article, we learnt about the mechanism of linear search in Python3.x. Or earlier
RxJava - Using CompositeDisposable

The CompositeDisposable class represents a container which can hold multiple disposable and offers O(1) complexity of adding and removing disposables.
Following is the declaration for io.reactivex.disposables.CompositeDisposable class −
public final class CompositeDisposable
extends Object
implements Disposable, io.reactivex.internal.disposables.DisposableContainer

Create the following Java program using any editor of your choice in, say, C:\> RxJava.
import io.reactivex.Maybe;
import io.reactivex.Single;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.observers.DisposableMaybeObserver;
import io.reactivex.observers.DisposableSingleObserver;
import io.reactivex.schedulers.Schedulers;

import java.util.concurrent.TimeUnit;

public class ObservableTester  {
   public static void main(String[] args)  throws InterruptedException {    
      CompositeDisposable compositeDisposable = new CompositeDisposable();

      //Create an Single observer 
      Disposable disposableSingle = Single.just("Hello World")
      .delay(2, TimeUnit.SECONDS, Schedulers.io())
      .subscribeWith(
      new DisposableSingleObserver<String>() {
         @Override
         public void onError(Throwable e) {
            e.printStackTrace();
         }

         @Override
         public void onSuccess(String value) {
            System.out.println(value);
         }
      }); 

      //Create an observer
      Disposable disposableMayBe = Maybe.just("Hi")
      .delay(2, TimeUnit.SECONDS, Schedulers.io())
      .subscribeWith(new DisposableMaybeObserver<String>() {
         @Override
         public void onError(Throwable e) { 
            e.printStackTrace();
         }

         @Override
         public void onSuccess(String value) {
            System.out.println(value);
         }

         @Override
         public void onComplete() {
            System.out.println("Done!");
         }
      }); 

      Thread.sleep(3000);

      compositeDisposable.add(disposableSingle);
      compositeDisposable.add(disposableMayBe);

      //start observing
      compositeDisposable.dispose();
   }
}
Compile the class using javac compiler as follows −
C:\RxJava>javac ObservableTester.java

Now run the ObservableTester as follows −
C:\RxJava>java ObservableTester

It should produce the following output −
Hello World
Hi

 Print
 Add Notes
 Bookmark this page
Java Program to Add Two numbers Without using Arithmetic Operator

21 Jan, 2022
Here, we need to write a function that returns the sum of two stated integers. And the function must not utilize any of the arithmetic operators such as +, ++, –, -, .. Etc.). It will be a very basic elementary level program to compute the sum by simply using the ‘+’ operator and thereby simply printing and displaying out the resultant. But if we refrain from constraint not to use any of arithmetic operator then there is only one way out that is with the use of XOR operator which can perform an addition operation for two given bits. And for the carry bit, we can use AND (&) operator.
It is done using the bit-wise operators. Here we are going to use mainly three operations as follows:
Bit-wise XORBit-wise ANDBit-wise left shift operator
Bit-wise XOR
Bit-wise AND
Bit-wise left shift operator
First, the numbers are converted in binary format. Considering 8 indices for an integer data type.  Now the carry is handled by a bit-wise left shift operator and the rest of the binary is displayed on the screen as an integer number depicting the sum of the above two integers. It is depicted below: 
Input  : 1, 2
Output : 3
a = 1 : 00000001
b = 2 : 00000010
----------------
c = 3 : 00000011 
Implementation:
Example
Java
// Java Program to find the Sum of Two Numbers// Without Using any Arithmetic Operator // Importing input output classesimport java.io.*; // Main classclass GFG {     // Method to sum two integer elements    static int Sum(int a, int b)    {         // Iterating until there is no carry        while (b != 0) {             // Using AND operator            int carry = a & b;             // Using XOR operator            a = a ^ b;             // Shifting the carry by one so that            // adding it to the integer 'a'            // gives the desired output            b = carry << 1;        }        return a;    }     // Method 2    // Main driver method    public static void main(String arg[])    {         // Print the sum of custom integer numbers to be        // summed up passed as an arguments        System.out.println(Sum(2, 3));    }}
  
5
 
simranarora5sos
Java
Java Programs
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design an online hotel booking system like OYO Rooms

03 Jul, 2021
We need to design an online hotel booking system where a user can search a hotel in a given city and book it. This is an OOP design question, so I have not written the full code in this solution. I have created the classes and attributes only.Solution :Main Classes :1. User 2. Room 3. Hotel 4. Booking 5. Address 6. Facilities 
Java
// Java code skeleton to design an online hotel// booking system.Enums: public enum RoomStatus {    EMPTY        NOT_EMPTY;} public enum RoomType {    SINGLE,    DOUBLE,    TRIPLE;} public enum PaymentStatus {    PAID,    UNPAID;} public enum Facility {    LIFT;    POWER_BACKUP;    HOT_WATER;    BREAKFAST_FREE;    SWIMMING_POOL;} class User {     int userId;    String name;    Date dateOfBirth;    String mobNo;    String emailId;    String sex;} // For the room in any hotelclass Room {     int roomId; // roomNo    int hotelId;    RoomType roomType;    RoomStatus roomStatus;} class Hotel {     int hotelId;    String hotelName;    Address address;     // hotel contains the list of rooms    List<Room> rooms;    float rating;    Facilities facilities;} // a new booking is created for each booking// done by any userclass Booking {    int bookingId;    int userId;    int hotelId;     // We are assuming that in a single    // booking we can book only the rooms    // of a single hotel    List<Rooms> bookedRooms;         int amount;    PaymentStatus status_of_payment;    Date bookingTime;    Duration duration;} class Address {     String city;    String pinCode;    String state;    String streetNo;    String landmark;} class Duration {     Date from;    Date to; } class Facilities {     List<Facility> facilitiesList;}
Let me explain about the classes and the relationships among themselves.
The enums defined here are self-explanatory. The classes User, Room, and Address are also self-explanatory. The class Facilities contains a list of facilities (enum) that the hotel provides. We can add more facilities in the Facility enum if required. The duration class has two attributes “from” and “to”, which is obvious.
Now, the class “Hotel” contains: 1. List of rooms (Room class) // this is the list of rooms the hotel has 2. Address class // its address 3. Facilities class // the facilities it hasThe class “Booking” contains: 1. User // information about the 2. Hotel // Information about the hotel 3. List of rooms 4. PaymentStatus etc.Other fields in this class are also self-explanatory.
This article is contributed by Pooja Kamal. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
saurabh1990aror
Design Pattern
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Bootstrap Alerts

Bootstrap provides an easy way to create predefined alert messages:
Alerts are created with the .alert class, followed by one of the 
four contextual classes .alert-success, .alert-info, .alert-warning or 
.alert-danger:
Add the alert-link class to any links inside the alert box to create "matching colored links":
To close the alert message, add a .alert-dismissible 
class to the alert container. Then add class="close" and data-dismiss="alert" 
to a link or a button element (when you click on this the alert box will 
disappear).
The aria-* attribute and &times; explanationTo 
help improve accessibility for people using screen readers, you should include 
the aria-label="close" attribute, when creating a close button.&times; (×) is an HTML entity that is the preferred icon for close 
buttons, rather than the letter "x".For a list of all HTML Entities, visit our HTML Entities Reference.
The .fade and .in classes adds a fading effect when 
closing the alert message:
Add a Bootstrap "alert" class to display the result of a successful action.
<div class="">
  Success!
</div>

Start the Exercise
For a complete reference of all alert options, methods and events, go to our
Bootstrap JS Alert Reference.
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.
How to convert date to datetime in Python?

You can use the datetime module's combine method to combine a date and a time to create a datetime object. If you have a date object and not a time object, you can initialize the time object to minimum using the datetime object(minimum time means midnight).
from datetime import date
from datetime import datetime
my_date = date.today()
my_time = datetime.min.time()
my_datetime = datetime.combine(my_date, my_time)
print(my_datetime)
2018-01-01 00:00:00
from datetime import date
from datetime import datetime
my_date = date.today()
my_datetime = datetime(my_date.year, my_date.month, my_date.day)
print(my_datetime)
2018-01-01 00:00:00
jQuery - Element ID Selector

The element ID selector selects a single element with the given id attribute.
Here is the simple syntax to use this selector −
$('#elementid')

Here is the description of all the parameters used by this selector −
elementid − This would be an element ID. If the id contains any special characters like periods or colons you have to escape those characters with backslashes.
elementid − This would be an element ID. If the id contains any special characters like periods or colons you have to escape those characters with backslashes.
Like any other jQuery selector, this selector also returns an array filled with the found element.
$('#myid') − Selects a single element with the given id myid.
$('#myid') − Selects a single element with the given id myid.
$('div#yourid') − Selects a single division with the given id yourid.
$('div#yourid') − Selects a single division with the given id yourid.
Following example would select second division and  will apply yellow color to its background −
<html>
   <head>
      <title>The Selecter Example</title>
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
   
      <script type = "text/javascript" language = "javascript">
         $(document).ready(function() {
            /* This would select second division only*/
            $("#div2").css("background-color", "yellow");
         });
      </script>
   </head>
	
   <body>
      <div class = "big" id = "div1">
         <p>This is first division of the DOM.</p>
      </div>

      <div class = "medium" id = "div2">
         <p>This is second division of the DOM.</p>
      </div>

      <div class = "small" id = "div3">
         <p>This is third division of the DOM</p>
      </div>
   </body>
</html>
This will produce following result −
This is first division of the DOM.
This is second division of the DOM.
This is third division of the DOM

    27 Lectures 
     1 hours 

 Mahesh Kumar

    27 Lectures 
     1.5 hours 

 Pratik Singh

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    60 Lectures 
     9 hours 

 Eduonix Learning Solutions

    17 Lectures 
     2 hours 

 Sandip Bhattacharya

    12 Lectures 
     53 mins

 Laurence Svekis
 Print
 Add Notes
 Bookmark this page
Which version of Firefox is compatible with selenium

Compatibility of Firefox with Selenium has always been a pain area. Before Selenium3, Firefox used to be the default browser for Selenium. But after Selenium3, by using GeckoDriver explicitly, we can initialize the script in FireFox.
FireFox was fully supported only in previous versions i.e. v47 and earlier. Selenium WebDriver version 2.53 is not compatible with Mozilla FireFox version 47.0+. After v47.0, FireFox is provided with GeckoDriver. GeckoDriver is a proxy for using W3C WebDriver-compatible clients to interact with gecko-based browsers i.e. Mozilla FireFox.
FireFox was fully supported only in previous versions i.e. v47 and earlier. Selenium WebDriver version 2.53 is not compatible with Mozilla FireFox version 47.0+. After v47.0, FireFox is provided with GeckoDriver. GeckoDriver is a proxy for using W3C WebDriver-compatible clients to interact with gecko-based browsers i.e. Mozilla FireFox.
GeckoDriver acts a link between Selenium WebDriver tests and Mozilla FireFox Browser. It is a web browser engine which is inbuilt in FireFox Browser.
GeckoDriver acts a link between Selenium WebDriver tests and Mozilla FireFox Browser. It is a web browser engine which is inbuilt in FireFox Browser.
But here comes the question, why only GeckoDriver as opposed to FireFox’s default driver.The Answer to which is GeckoDriver uses W3C WebDriver protocol to communicate with Selenium, which allows Selenium Developers to allow the same WebDriver to run in multiple browser versions.
But here comes the question, why only GeckoDriver as opposed to FireFox’s default driver.The Answer to which is GeckoDriver uses W3C WebDriver protocol to communicate with Selenium, which allows Selenium Developers to allow the same WebDriver to run in multiple browser versions.
Let’s see, for Selenium 2.53.1 and before, how Selenium used to work with FireFox.
Let’s see, for Selenium 2.53.1 and before, how Selenium used to work with FireFox.
public class FirefoxTest {
   @Test
   public void startFfBrowser() {
      WebDriver driver = new FirefoxDriver();
      driver.get("http://www.tutorialspoint.com");
   }
}
After running the code, FireFox opens google.com. But now if we run the same lines of code in Selenium3 and above, we will get a run time error.
“java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property;”
So for running the script in FireFox v47 and above, GeckoDriver comes into play.
public class FirefoxTest {
   @Test
   public void startFfBrowser () {
      System.setProperty("webdriver.gecko.driver",Path of your GeckoDriver.exe file);
      FirefoxDriver driver = new FirefoxDriver();
      driver.get("http://www.tutorialspoint.com");
   }
}
We can improve this code by directly set the geckodriver path in our System’s Environment variable and use the traditional way to instantiate web driver.
How to create bitmap display in R?

The X Window System is a windowing system for bitmap displays. In R, we can create this graphical display by simply typing x11 in the R console and the graphic interface will pop-up on the right-hand side. We can change the width and height of this display by using the arguments width and height inside x11 call. There are many other arguments of x11 that helps us to change the aesthetic property of the bitmap display. The description of those arguments is as written below:
the display on which the graphics window will appear. The default is to use the value in the user's environment variable DISPLAY. This is ignored (with a warning) if an X11 device is already open on another display.
the width and height of the plotting window, in inches. If NA, taken from the resources and if not specified there defaults to 7 inches.
the default pointsize to be used. Defaults to 12.
gamma correction fudge factor. Colours in R are sRGB; if your monitor does not conform to sRGB, you might be able to improve things by tweaking this parameter to apply additional gamma correction to the RGB channels. By default 1 (no additional gamma correction).
colour, the initial background colour. Default "transparent".
colour. The colour of the canvas, which is visible only when the background colour is transparent. Should be an opaque colour (and any alpha value will be ignored). Default "white".
for type = "Xlib" only: X11 font description strings into which weight, slant and size will be substituted. There are two, the first for fonts 1 to 4 and the second for font 5, the symbol font. See section ‘Fonts’.
The default family: a length-one character string. This is primarily intended for cairo-based devices, but for type = "Xlib", the X11Fonts() database is used to map family names to fonts (and this argument takes precedence over that one).
integer: initial position of the top left corner of the window, in pixels. Negative values are from the opposite corner, e.g.xpos = -100 says the top right corner should be 100 pixels from the right edge of the screen. If NA (the default), successive devices are cascaded in 20 pixel steps from the top left. See also ‘Resources’.
character string, up to 100 bytes. With the default, "", a suitable title is created internally. A C-style format for an integer will be substituted by the device number (see the file argument to postscript for further details). How non-ASCII titles are handled is implementation-dependent.
character string, one of "Xlib", "cairo", "nbcairo" or "dbcairo". Only the first will be available if the system was compiled without support for cairographics. The default is "cairo" where available except on macOS, otherwise "Xlib".
for cairo types, the type of anti-aliasing (if any) to be used. One of c("default", "none", "gray", "subpixel").
logical: should the defaults be reset to their defaults?
> x11()
> x11(width=4,height=2)
How to add image patterns to nodes in JavaFX?

You can apply colors to geometrical shapes in JavaFX using the setFill() and setStroke() methods. The setFill() method adds color to the interior area of the shape whereas the setStroke() method applies color to the boundary of the node.
Both methods accept an object of the javafx.scene.paint.Paint class as a parameter. It is the base class for the color and gradients that are used to fill the shapes and backgrounds with color.
The javafx.scene.paint.ImagePattern class in JavaFX is a subclass of the Paint and using this you can fill a shape with an image.
To apply image pattern to a geometrical shape −
Create an Image by instantiating the Image class.
Create an Image by instantiating the Image class.
Instantiate the ImagePattern class bypassing the image created above, to
the constructor (along with other values) as a parameter.
Instantiate the ImagePattern class bypassing the image created above, to
the constructor (along with other values) as a parameter.
Set the created image pattern to the shape using the setFill() method.
Set the created image pattern to the shape using the setFill() method.
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.scene.paint.ImagePattern;
import javafx.stage.Stage;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Ellipse;
import javafx.scene.shape.Polygon;
import javafx.scene.shape.Rectangle;
public class ImagePatterns extends Application {
   public void start(Stage stage) {
      //Drawing a circle
      Circle circle = new Circle(75.0f, 65.0f, 40.0f );
      //Drawing a Rectangle
      Rectangle rect = new Rectangle(150, 30, 100, 65);
      //Drawing an ellipse
      Ellipse ellipse = new Ellipse(330, 60, 60, 35);
      //Drawing Polygon
      Polygon poly = new Polygon(410, 60, 430, 30, 470, 30, 490, 60, 470, 100, 430, 100 );
      //Creating the pattern
      Image map = new Image("http://www.tutorialspoint.com/images/tp-logo.gif");
      ImagePattern pattern = new ImagePattern(map, 20, 20, 40, 40, false);
      //Setting the pattern
      circle.setFill(pattern);
      circle.setStrokeWidth(3);
      circle.setStroke(Color.CADETBLUE);
      rect.setFill(pattern);
      rect.setStrokeWidth(3);
      rect.setStroke(Color.CADETBLUE);
      ellipse.setFill(pattern);
      ellipse.setStrokeWidth(3);
      ellipse.setStroke(Color.CADETBLUE);
      poly.setFill(pattern);
      poly.setStrokeWidth(3);
      poly.setStroke(Color.CADETBLUE);
      //Setting the stage
      Group root = new Group(circle, ellipse, rect, poly);
      Scene scene = new Scene(root, 600, 150);
      stage.setTitle("Setting Colors");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]){
      launch(args);
   }
}
How to get the Azure VM Size using Azure CLI in PowerShell?

To get the Azure VM size using Azure CLI, we first need to make sure that the Azure account is connected to the specific subscription for the VM that we need to retrieve the VM size.
To get the specific Azure VM size, we need to first retrieve the VM details and then need to run the JMESPATH query to retrieve the VM size.
az vm show -n VMname -g ResourceGroupName --query '[hardwareProfile.vmSize]' -otsv
you can also retrieve the size of the VM without resource group name, using “az vm list” command.
az vm list --query "[?name=='AzVM'].hardwareProfile.vmSize" -otsv
How to find a constant in a string in SAP BO Webi Report

You are correct. You can use functions like Match() or Pos(). You can use MATCH([Dimension];"*def*")) and this will get you the output and wildcard will match the beginning of the string.
Pos Function is used to return the position of a specific character string.
You can also try using Pos() function as below −
=Pos("def abc ghi";"def")
returns 1
=Pos("def abc ghi";"abc")
returns 5
=Pos("def abc ghi";"xyz")
returns 0
Reverse words in a given String in Java

The order of the words in a string can be reversed and the string displayed with the words in reverse order. An example of this is given as follows.
String = I love mangoes
Reversed string = mangoes love I
A program that demonstrates this is given as follows.
 Live Demo
import java.util.regex.Pattern;
public class Example {
   public static void main(String[] args) {
      String str = "the sky is blue";
      Pattern p = Pattern.compile("\\s");
      System.out.println("The original string is: " + str);
      String[] temp = p.split(str);
      String rev = "";
      for (int i = 0; i < temp.length; i++) {
         if (i == temp.length - 1)
         rev = temp[i] + rev;
         else
         rev = " " + temp[i] + rev;
      }
      System.out.println("The reversed string is: " + rev);
   }
}
The original string is: the sky is blue
The reversed string is: blue is sky the
Now let us understand the above program.
First the original string is printed. The the string is split when there is whitespace characters and stored in array temp. The code snippet that demonstrates this is given as follows.
String str = "the sky is blue";
Pattern p = Pattern.compile("\\s");
System.out.println("The original string is: " + str);
String[] temp = p.split(str);
String rev = "";
Then a for loop is used to store the string in reverse order in string rev by iterating over the string temp. Finally rev is displayed. The code snippet that demonstrates this is given as follows −
for (int i = 0; i < temp.length; i++) {
   if (i == temp.length - 1)
   rev = temp[i] + rev;
   else
   rev = " " + temp[i] + rev;
}
System.out.println("The reversed string is: " + rev);
PHP: recreate and display an image from binary data

This can be done using data URI in the image src attribute.
data:[<MIME-type>][;charset="<encoding>"][;base64],<data>
<?php
   function data_uri($file, $mime) {  
      $contents = file_get_contents($file);
      $base64   = base64_encode($contents);
      return ('data:' . $mime . ';base64,' . $base64);
   }
?>
<img src="<?php echo data_uri('some_image.png','image/png'); ?>" alt="Image sample" />
The ‘data_uri’ function defines the ‘contents’, ‘base64’ and returns the data and its encoded value. This function is called by passing an image to it, thereby recreating it and displaying it in the form of binary data.
Note − This can be used to avoid storing the images to the disk after processing them.
Is it possible to resize an array in C#

You cannot resize an array in C#, but using Array.Resize you can replace the array with a new array of different size.
The following is our array −
char[] ch = new char[10];
ch[0] = 'a';
ch[1] = 'b';
Now, resize −
Array.Resize<char>(ref ch, 10);
The following is the complete example −
 Live Demo
using System;
class Program {
   static void Main() {
      char[] ch = new char[10];
      ch[0] = 'a';
      ch[1] = 'b';
      // Resize array
      Array.Resize<char>(ref ch, 10);
      // Set value for new elements
      ch[2] = 'c';
      ch[3] = 'd';
      ch[4] = 'e';
      ch[5] = 'f';
      ch[6] = 'g';
      ch[7] = 'h';
      ch[8] = 'i';
      ch[9] = 'j';
      Console.WriteLine("New Array: "+ new string(ch));
   }
}
New Array: abcdefghij
How to get text of specific option tag using jQuery? - GeeksforGeeks

22 Apr, 2019
In order to select the text of a selected option or any specific option, jQuery allows doing that easily by its specific selectors. The selector is used to select the specific element.
Example: This example selects the text of the specific option(GFG_2) tag.
<!DOCTYPE html>  <html>    <head>     <title>         Get text of specific option tag    </title>          <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">    </script></head>          <body style = "text-align:center;">           <h1 style = "color:green;" >          GeeksForGeeks      </h1>         <select id='GFG_list'>        <option value='GFG_1'>GFG_A</option>        <option value='GFG_2'>GFG_B</option>        <option value='GFG_3'>GFG_C</option>    </select>          <br><br>          <button id="GFG_Button" onclick = "getText()">        getText    </button>           <p id = "GFG_P" style="color:green;font-size:20px;"></p>          <script>        function getText(){            var el = document.getElementById("GFG_P");            el.innerHTML = $("#GFG_list option[value='GFG_2']").text();        }    </script> </body>    </html>  
Output:
Before clicking on the button:
After clicking on the button:
Example: This example selects the text of currently selected option tag.
<!DOCTYPE html>  <html>    <head>     <title>         Get text of specific option tag    </title>          <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">    </script></head>          <body style = "text-align:center;">           <h1 style = "color:green;" >          GeeksForGeeks      </h1>         <select id='GFG_list'>        <option value='GFG_1'>GFG_A</option>        <option value='GFG_2'>GFG_B</option>        <option value='GFG_3'>GFG_C</option>    </select>          <br><br>          <button id="GFG_Button" onclick = "getText()">        getText    </button>           <p id = "GFG_P" style = "color:green; font-size: 20px;"></p>          <script>        function getText(){            var el = document.getElementById("GFG_P");            el.innerHTML = $("#GFG_list option:selected").text();        }    </script> </body>    </html> 
Output:
Before clicking on the button:
After clicking on the button:
jQuery-Misc
JQuery
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to prevent Body from scrolling when a modal is opened using jQuery ?
jQuery | ajax() Method
How to get the value in an input text box using jQuery ?
jQuery | parent() & parents() with Examples
Difference Between JavaScript and jQuery
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Convert a string to an integer in JavaScript
getdate() and setdate() function in C with Examples - GeeksforGeeks

13 May, 2022
getdate() function is defined in dos.h header file. This function fills the date structure *dt with the system’s current date. Syntax
struct date dt;
getdate(&dt);
Parameter: This function accepts a single parameter dt which is the object of structure date. 
Return Value: This method does not return anything. It just gets the system date and sets it in the specified structure. 
Note: The <dos.h> header file used in this tutorial works only on dos-based systems and will not work on Linux-based systems.
Program 1: Implementation of getdate() function 
C
// C program to demonstrate getdate() method #include <dos.h>#include <stdio.h> int main(){    struct date dt;     // This function is used to get    // system's current date    getdate(&dt);     printf("System's current date\n");    printf("%d/%d/%d",           dt.da_day,           dt.da_mon,           dt.da_year);     return 0;}
Output:
setdate() function is defined in dos.h header file. This function sets the system date to the date in *dt. Syntax
struct date dt;
setdate(&dt)
Parameter: This function accepts a single parameter dt which is the object of structure date that has to be set as the system date. Return Value: This method do not returns anything. It just sets the system date as specified. Program 1: Implementation of setdate() function 
C
// C program to demonstrate setdate() method #include <dos.h>#include <stdio.h> int main(){    struct date dt;     // This function is used to get    // system's current date    getdate(&dt);     printf("System's current date\n");    printf("%d/%d/%d",           dt.da_day,           dt.da_mon,           dt.da_year);     printf("Enter date in the format (date month year)\n");    scanf("%d%d%d", &dt.da_day, &dt.da_mon, &dt.da_year);     // This function is used to change    // system's current date    setdate(&dt);     printf("System's new date (dd/mm/yyyy)\n")        printf("%d%d%d", dt.da_day, dt.da_mon, dt.da_year);     return 0;}
Output:  
Note: These programs are run in TurboC/C++ compiler
ajitnisar95
C-Functions
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Substring in C++
Multidimensional Arrays in C / C++
Left Shift and Right Shift Operators in C/C++
Converting Strings to Numbers in C/C++
Function Pointer in C
Core Dump (Segmentation fault) in C/C++
std::string class in C++
fork() in C
Command line arguments in C/C++
Enumeration (or enum) in C
GS Labs Interview | Set 1 - GeeksforGeeks

01 Oct, 2017
I had GS Labs Pune interview on 6th Apr 2013. They called me in the morning 9am. It was good Saturday morning. Reached on time.
            
1st Round:   1. About Project
             2. Some c/c++ program
2nd Round:
             1. C++ concepts
             2. Diff between makefile and bash script
             3. Design program
3rd round:
             Design and OS concepts
            
4th round:   Manager Round.More about resume
5th round:   HR, more about joining date and policies. 
It was almost a whole day process.
Good experience.
This article is compiled by Shantibhushan Sale. Many Many congratulations to Shantibhushan for his selection. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
GS Labs
Interview Experiences
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Amazon Interview Experience for SDE-1 (Off-Campus)
Amazon AWS Interview Experience for SDE-1
Difference between ANN, CNN and RNN
Zoho Interview | Set 3 (Off-Campus)
Amazon Interview Experience for SDE-1 (Off-Campus) 2022
Directi Interview | Set 7 (Programming Questions)
Amazon Interview Experience
Amazon Interview Experience for SDE-1
Amazon Interview Experience (Off-Campus) 2022
EPAM Interview Experience (Off-Campus)
Python - API.media_upload() in Tweepy - GeeksforGeeks

05 Jun, 2020
Twitter is a popular social network where users share messages called tweets. Twitter allows us to mine the data of any user using Twitter API or Tweepy. The data will be tweets extracted from the user. The first thing to do is get the consumer key, consumer secret, access key and access secret from twitter developer available easily for each user. These keys will help the API for authentication.
The API.media_upload() method of the API class in Tweepy module is used to update the authenticated user’s current status with a media or in simple words, tweeting.
Syntax : API.media_upload(parameters)
Parameters :
filename : The name of the file to be uploaded.
status : The text of the tweet / status update.
in_reply_to_status_id : The ID of the tweet that the new tweet is being replied to.
attachment_url : This provides a URL as a tweet attachment.
media_ids : A list of media_ids to be associated with the tweet.
possibly_sensitive : Set it to True if the tweet might contain sensitive data.
lat : The latitude of the tweet.
long : The longitude of the tweet.
place_id : The name of the place of the tweet.
display_coordinates : Set this value to True if the exact coordinates of the tweet have to be displayed.
file : A file object, it is accessed when the file name is not given.
Returns : an object of the class Status
Example 1 :Posting a tweet with the following file :
# import the moduleimport tweepy  # assign the values accordinglyconsumer_key = ""consumer_secret = ""access_token = ""access_token_secret = ""  # authorization of consumer key and consumer secretauth = tweepy.OAuthHandler(consumer_key, consumer_secret)  # set access to user's access key and access secret auth.set_access_token(access_token, access_token_secret)  # calling the api api = tweepy.API(auth)  # the text to be tweetedstatus = "This is a media upload."  # the path of the media to be uploadedfilename = "gfg.png"  # posting the tweetapi.update_with_media(filename, status)
Output :
Example 2 :Using the media_upload() method with in_reply_to_status_id parameter to reply to the previous tweet with the following media :
# the text to be tweetedstatus = "This is a tweet is a reply."   # the ID of the tweet to be replied toin_reply_to_status_id = ""  # the path of the media to be uploadedfilename = "gfg.png"  # posting the tweetapi.update_with_media(filename, status, in_reply_to_status_id = in_reply_to_status_id)
Output :
Python-Tweepy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
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
Convert integer to string in Python
How to get the maximum value from strings with integers in MySQL?

You can use CAST() with MAX() for this. Since the string is filled with string and integer, fir example, “STU201”, therefore we need to use CAST().
Let us first create a table −
mysql> create table DemoTable
(
   Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   StudentBookCode varchar(200)
);
Query OK, 0 rows affected (0.56 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(StudentBookCode) values('STU201');
Query OK, 1 row affected (0.20 sec)
mysql> insert into DemoTable(StudentBookCode) values('STU202');
Query OK, 1 row affected (0.20 sec)
mysql> insert into DemoTable(StudentBookCode) values('STU203');
Query OK, 1 row affected (0.20 sec)
mysql> insert into DemoTable(StudentBookCode) values('STU290');
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable(StudentBookCode) values('STU234');
Query OK, 1 row affected (0.15 sec)
Following is the query to display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+----+-----------------+
| Id | StudentBookCode |
+----+-----------------+
| 1  | STU201          |
| 2  | STU202          |
| 3  | STU203          |
| 4  | STU290          |
| 5  | STU234          |
+----+-----------------+
5 rows in set (0.00 sec)
Following is the query to get the maximum value −
mysql> select MAX(CAST(SUBSTRING(StudentBookCode FROM 4) AS UNSIGNED)) from DemoTable;
This will produce the following output −
+----------------------------------------------------------+
| MAX(CAST(SUBSTRING(StudentBookCode FROM 4) AS UNSIGNED)) |
+----------------------------------------------------------+
| 290                                                      |
+----------------------------------------------------------+
1 row in set (0.00 sec)
Sort index in ascending order – Python Pandas

The sort_index() is used to sort index in ascending and descending order. If you won’t mention any parameter, then index sorts in ascending order.
At first, import the required library −
import pandas as pd
Create a new DataFrame. It has unsorted indexes −
dataFrame = pd.DataFrame([100, 150, 200, 250, 250, 500],index=[4, 8, 2, 9, 15, 11],columns=['Col1'])
Sort the indexes −
dataFrame.sort_index()

Following is the code −
import pandas as pd

dataFrame = pd.DataFrame([100, 150, 200, 250, 250, 500],index=[4, 8, 2, 9, 15, 11],columns=['Col1'])

print"DataFrame...\n",dataFrame

print"\nSort index...\n",dataFrame.sort_index()
This will produce the following output −
DataFrame...
   Col1
4   100
8   150
2   200
9   250
15  250
11  500

Sort index...
   Col1
2   200
4   100
8   150
9   250
11  500
15  250
How to use wildcards like $ ('#name*'), $ ('#name%') in jQuery selectors?

For getting the id that begins or ends with a particular string in jQuery selectors, you shouldn’t use the wildcards $('#name*'), $('#name%'). Instead use the characters ^and $. The ^ is used is used to get all elements starting with a particular string. The $ is used is used to get all elements ending with a particular string.
You can try to run the following code to learn how to get id beginning and endingwith a particular string.
Live Demo
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){

  $("[id$=new1]").css("background-color", "yellow");
  $("[id^=myid]").css("background-color", "green");

});
</script>
</head>
<body>

<div id="idnew1" myattr="javasubject">Java</div>
<div id="idnew2" myattr="htmlsubject">HTML</div>

<div id="myid1" myattr="rubysubject">Ruby</div>
<div id="myid2" myattr="cppsubject">C++</div>

</body>
</html>
getpass() and getuser() in Python (Password without echo)

When you create some python programs that need password protection before it can run, we take the help of the getpass() and getuser() modules. They have a variety of functionalities that can be used to manage password protection as well as password retrieval etc. In this article, we will see how to type in the password with and without echoing it back on the screen. Below are the different ways it is handled.
The below code is saved to a file (logon.py). The getpass() function prints a prompt then reads input from the user until they press return
 Live Demo
import getpass
try:
   pwd = getpass.getpass()
except Exception as err:
   print('Error Occured : ', err)
else:
   print('Password entered :', pwd)
Running the above code gives us the following result −
$ python logon.py
Password:
Password entered: abracadbra
Next, we can enhance the code to prompt the user with a security question. This question helps the user to recall the password.
import getpass
pwd = getpass .getpass(prompt = 'What is your favorite colour?')
if pwd == 'Crimson':
   print('You are in!')
else:
   print('Try Again')
Running the above code gives us the following result −
$ python logon.py
'What is your favorite colour?
You are in!
Sometimes we need to know the login name which we are using to run the script. This is achieved by using the getuser() function.
import getpass
user = getpass.getuser()
while True:
   pwd = getpass.getpass("User Name : ",user)
   if pwd == 'Crimson':
      print("You are in!")
   else:
      print("The password you entered is wrong.")
Running the above code gives us the following result −
User Name: user1
You are in !
Difference between Definition and Declaration - GeeksforGeeks

21 Dec, 2018
Declaration of a variable is for informing to the compiler the following information: name of the variable, type of value it holds and the initial value if any it takes. i.e., declaration gives details about the properties of a variable. Whereas, Definition of a variable says where the variable gets stored. i.e., memory for the variable is allocated during the definition of the variable.
In C language definition and declaration for a variable takes place at the same time. i.e. there is no difference between declaration and definition. For example, consider the following declaration
int a;

Here, the information such as the variable name: a, and data type: int, which is sent to the compiler which will be stored in the data structure known as symbol table. Along with this, a memory of size 2 bytes(depending upon the type of compiler) will be allocated.
Suppose, if we want to only declare variables and not to define it i.e. we do not want to allocate memory, then the following declaration can be used
extern int a;

In this example, only the information about the variable is sent and no memory allocation is done. The above information tells the compiler that the variable a is declared now while memory for it will be defined later in the same file or in different file.
Declaration of a function provides the compiler the name of the function, the number and type of arguments it takes and its return type. For example, consider the following code,
int add(int, int);

Here, a function named add is declared with 2 arguments of type int and return type int. Memory will not be allocated at this stage.
Definition of the function is used for allocating memory for the function. For example consider the following function definition,
int add(int a, int b)
  {
    return (a+b);
  }

During this function definition, the memory for the function add will be allocated. A variable or a function can be declared any number of times but, it can be defined only once.
The above points are summarized in the following table,
int f(int);

The above is a function declaration. This declaration is just for informing the compiler that a function named f with return type and argument as int will be used in the function.
int f(int a)
{
  return a;
} 

The system allocates memory by seeing the above function definition.
cpp-advanced
Object-Oriented-Design
Picked
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Map in C++ Standard Template Library (STL)
Bitwise Operators in C/C++
Socket Programming in C/C++
Operator Overloading in C++
Multidimensional Arrays in C / C++
Templates in C++ with Examples
vector erase() and clear() in C++
rand() and srand() in C/C++
unordered_map in C++ STL
Object Oriented Programming in C++
How to access Java package from another package

You can understand it using an example where a Boss class is defined in payroll package.
package payroll;
public class Boss {
   public void payEmployee(Employee e) {
      e.mailCheck();
   }
}
if the Employee class is not in the payroll package? The Boss class must then use one of the following techniques for referring to a class in a different package.
The fully qualified name of the class can be used. For example −
payroll.Employee
The package can be imported using the import keyword and the wild card (*). For example −
import payroll.*;
The class itself can be imported using the import keyword. For example −
import payroll.Employee;
A class file can contain any number of import statements. The import statements must appear after the package statement and before the class declaration.
How to run Perl Program?

The following are the different ways to start Perl.
You can enter Perl and start coding right away in the interactive interpreter by starting it from the command line. You can do this from Unix, DOS, or any other system, which provides you a command-line interpreter or shell window.
$perl -e <perl code>               # Unix/Linux
or
C:>perl -e <perl code>             # Windows/DOS
Here is the list of all the available command-line options −
A Perl script is a text file, which keeps Perl code in it and it can be executed at the command line by invoking the interpreter on your application, as in the following −
$perl script.pl             # Unix/Linux
or
C:>perl script.pl           # Windows/DOS
You can run Perl from a graphical user interface (GUI) environment as well. All you need is a GUI application on your system that supports Perl. You can download Padre, The Perl IDE. You can also use Eclipse Plugin EPIC - Perl Editor and IDE for Eclipse if you are familiar with Eclipse.
Before proceeding to the next chapter, make sure your environment is properly set up and working perfectly fine. If you are not able to set up the environment properly then you can take help from your system administrator.
All the examples given in subsequent chapters have been executed with v5.16.2 version available on the CentOS flavor of Linux.
Tryit Editor v3.7

CSS Image Reflection
Tryit: Image reflection - add offset
How is JavaScript an untyped language?

JavaScript is an untyped language. This means that a JavaScript variable can hold a value of any data type. It does not work like C, C++, Java; datatypes like int, char are not needed here.
To declare variables in JavaScript, you need to use the var keyword. Whether it is a number or string, use the var keyword for declaration. You can try to run the following code to learn how to declare a variable in JavaScript
Live Demo
<html>
   <body>
      <script>
         <!--
            var age = 20;
            if( age > 18 ) {
               document.write("<b>Qualifies for driving</b>");
            }
         //-->
      </script>
   </body>
</html>