code-rag-bench/online-tutorials huggingface dataset:
SQL Left Join

09 Nov, 2021
The LEFT JOIN keyword in SQL returns the all matching records(or rows) and the records(or rows) that are present in the left table but not in the right table. That means that, if a certain row is present in the left table but not in the right, the result will include this row but with a NULL value in each column from the right. If a record from the right table is not in the left, it will not be included in the result.
LEFT JOIN
The syntax for a LEFT JOIN is :
SELECT column_name(s) 
FROM tableA 
LEFT JOIN tableB ON tableA.column_name = tableB.column_name;
SQL LEFT JOIN EXAMPLE :
In this example we will consider two tables Employee containing details of the employees working in the particular department the and department table containing the details of the department
employee table
Chapters
descriptions off, selected
captions settings, opens captions settings dialog
captions off, selected
English
This is a modal window.
Beginning of dialog window. Escape will cancel and close the window.
End of dialog window.
department table 
To perform left- join on  these two tables we will use the following SQL query :
select emp_no ,emp_name , age, salary ,dept_name, location 
from employee 
left join department on employee.dept_no=department.dept_no;
The output that we will get is as follows :-
As left join gives the matching rows and the rows that are present in the left table but not in the right table. Here in this example, we see that the employees that does not work in a particular department, i.e, having dept no values as [NULL], contains [NULL] values of dept name and location after the left join.
kashishsoda
DBMS-SQL
DBMS
SQL
DBMS
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
CTE in SQL
Introduction of DBMS (Database Management System) | Set 1
Difference between Clustered and Non-clustered index
SQL Trigger | Student Database
Introduction of B-Tree
How to find Nth highest salary from a table
CTE in SQL
SQL | ALTER (RENAME)
SQL Trigger | Student Database
How to Update Multiple Columns in Single Update Statement in SQL?
Python | Decimal shift() method

05 Sep, 2019
Decimal#shift() : shift() is a Decimal class method which returns the shifted copy of x, y times
Syntax: Decimal.shift()
Parameter: Decimal values
Return: the shifted copy of x, y times
Code #1 : Example for shift() method
# Python Program explaining # shift() method  # loading decimal libraryfrom decimal import *    # Initializing a decimal valuea = Decimal(1)  b = Decimal(2)  # printing Decimal valuesprint ("Decimal value a : ", a)print ("Decimal value b : ", b)    # Using Decimal.shift() methodprint ("\n\nDecimal a with shift() method : ", a.shift(b))  print ("Decimal b with shift() method : ", b.shift(b))
Output :
Decimal value a :  1
Decimal value b :  2


Decimal a with shift() method :  100
Decimal b with shift() method :  200


Code #2 : Example for shift() method
# Python Program explaining # shift() method  # loading decimal libraryfrom decimal import *    # Initializing a decimal valuea = Decimal(300)  b = Decimal(15)    # printing Decimal valuesprint ("Decimal value a : ", a)print ("Decimal value b : ", b)    # Using Decimal.shift() methodprint ("\n\nDecimal a with shift() method : ", a.shift(b))  print ("Decimal b with shift() method : ", b.shift(b))
Output :
Decimal value a :  300
Decimal value b :  15


Decimal a with shift() method :  300000000000000000
Decimal b with shift() method :  15000000000000000


Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
Python VLC MediaPlayer – Setting Position

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

A nested class is a class declared in another enclosing class. It is a member of its enclosing class and the members of an enclosing class have no access to members of a nested class.
Let us see an example code snippet of nested classes in C#.
class One {
   public int num1;
   public class Two {
      public int num2;
   }
}
class Demo {
   static void Main() {
      One a = new One();
      a.num1++;
      One.Two ab = new One.Two();
      ab.num2++;
   }
}
The example shows that class Two is a nested class. The class Two is enclosed inside the class One declaration.
The class Two here is enclosed inside the declaration of class One. Class Two is thus a nested class. Because it has a public accessibility modifier, it can be accessed in places other than class One's scope.
How to get the default Documents from the IIS site using PowerShell?

To get the default documents stored on the IIS default website page, you can use the below command.
Get-WebConfigurationProperty -Filter //defaultDocument/files/add
   -PSPath 'IIS:\Sites\Default Web Site' -Name value `
   | select value
Value
-----
Default.htm
Default.asp
index.htm
index.html
iisstart.htm
To check if the Default document contains a specific file,
(Get-WebConfigurationProperty -Filter //defaultDocument/files/add -PSPath 'IIS:\Sites\Default Web Site' -Name value).value -contains 'iisstart.htm'
The above command checks if the IIS default website contains any iisstart.htm on the default document page.
You can also use another website instead of using 'Default Web site'. To get the default documents file at the IIS level,
(Get-WebConfigurationProperty -Filter //defaultDocument/files/add -PSPath 'IIS:\' -Name value).value 
(Get-WebConfigurationProperty -Filter //defaultDocument/files/add -PSPath 'IIS:\' -Name value).value
How to set src to the img tag in HTML from another domain?

To use an image on a webpage, use the <img> tag. The tag allows you to add image source, alt, width, height, etc. The src is to add the image URL. The alt is the alternate text attribute, which is text that is visible when the image fails to load. With HTML, add the image source as another domain URL. For that, add the src attribute as a link to another domain.
The following are the attributes:
Just keep in mind the <img> tag has no end tag.
You can try to run the following code to set src to the img tag in HTML from another domain
Live Demo
<!DOCTYPE html>
<html>
   <head></head>
   <body>
      <h2>Qries</h2>
      <img src="https://www.qries.com/images/banner_logo.png" alt="Qries" width="200" height="90">
   </body>
</html>
Python program to create a list centered on zero - GeeksforGeeks

06 Apr, 2020
Given two integer variables, limit and diff, write a Python program to create a list that is centered on zero, using limit, which specifies limit of the list and diff that specifies the common difference between integers.
Examples:
Input : limit = 1, diff = 0.5
Output : [-1, -0.5, 0.0, 0.5, 1]

Input : limit = 25, diff = 5
Output : [-25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25]

 
Approach #1 : Naive Approach
This is a naive approach to the above problem. First, create an empty list ‘lst’, and then we use a while loop to append the next integer with a difference equal to ‘diff’.
# Python3 program to Convert a # list to dictionary  def create(limit, diff):              lst = [-limit]    while lst[-1] < limit:        lst.append(lst[-1] + diff)    lst[-1] = limit    return lst          # Driver codelimit = 1diff = 0.5print(create(limit, diff))
[-1, -0.5, 0.0, 0.5, 1]

 Approach #2 : Using Python Numpy
Using Numpy module makes the solution a lot easier. In this method, we use np.arange which return evenly spaced values within a given interval ‘diff’.
# Python3 program to Convert a # list to dictionaryimport numpy as np  def create(limit, diff):    lst = np.arange(diff, limit, diff)    if (lst[-1] != limit):        lst = np.r_[lst, limit]              return np.r_[-lst[::-1], 0, lst].tolist()          # Driver codelimit = 1diff = 0.5print(create(limit, diff))
[-1.0, -0.5, 0.0, 0.5, 1.0]

 Approach #3 : list comprehension
# Python3 Python program to create a list centered on zero  def create(limit, diff):    length = int(((limit/diff)*2)+1)        list = [-limit+i*diff for i in range(length)]    return list                  # Driver codelimit = 1diff = 0.5print(create(limit, diff))
[-1.0, -0.5, 0.0, 0.5, 1.0]

Shivaprakash
Python list-programs
Python
Python Programs
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 program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
PostgreSQL - FIRST_VALUE Function - GeeksforGeeks

10 Feb, 2021
In PostgreSQL, the FIRST_VALUE() function is used to return the first value in a sorted partition of a result set.
Syntax:
FIRST_VALUE ( expression )  
OVER ( 
    [PARTITION BY partition_expression, ... ]
    ORDER BY sort_expression [ASC | DESC], ...
)

Let’s analyze the above syntax:
The expression is responsible for evaluating the values against the value of the first row of a sorted partition of a query result set. It can be an expression, column, or subquery that mush evaluate a single integer value.
 The PARTITION BY clause is used to divides rows in a result set.
The ORDER BY clause is used to sort the rows the query result set in each partition.
The rows_range_clause is used to limits the rows inside the partition by setting up the start and end of the query set partitions.
Example 1:
First, create two tables named Mammals and Animal_groups for the demonstration:
CREATE TABLE Animal_groups (
    animal_id serial PRIMARY KEY,
    animal_name VARCHAR (255) NOT NULL
);

CREATE TABLE Mammals (
    mammal_id serial PRIMARY KEY,
    mammal_name VARCHAR (255) NOT NULL,
    lifespan DECIMAL (11, 2),
    animal_id INT NOT NULL,
    FOREIGN KEY (animal_id) REFERENCES Animal_groups (animal_id)
);

Now insert some data to the table:
INSERT INTO Animal_groups (animal_name)
VALUES
    ('Terrestrial'),
    ('Aquatic'),
    ('Winged');

INSERT INTO Mammals(mammal_name, animal_id, lifespan)
VALUES
    ('Cow', 1, 10),
    ('Dog', 1, 7),
    ('Ox', 1, 13),
    ('Wolf', 1, 11),
    ('Blue Whale', 2, 80),
    ('Dolphin', 2, 5),
    ('Sea Horse', 2, 3),
    ('Octopus', 2, 8),
    ('Bat', 3, 4),
    ('Flying Squirrels', 3, 1),
    ('Petaurus', 3, 2);

The following statement uses the FIRST_VALUE() function to return all mammals and also the mammal which has the lowest lifespan:
SELECT 
    mammal_id,
    mammal_name,
    mammal_id,
    lifespan,
    FIRST_VALUE(mammal_name) 
    OVER(
        ORDER BY lifespan
    ) lowest_lifespan
FROM 
    Mammals;

Output:
Example 2:
The below statement uses the FIRST_VALUE() function to return all mammals grouped by the animal group. And for each animal group, it returns the mammal with the lowest lifespan:
SELECT 
    mammal_id,
    mammal_name,
    mammal_id,
    lifespan,
    FIRST_VALUE(mammal_name) 
    OVER(
    PARTITION BY animal_id
        ORDER BY lifespan
        RANGE BETWEEN 
            UNBOUNDED PRECEDING AND 
            UNBOUNDED FOLLOWING
    ) lowest_lifespan
FROM 
    Mammals;

Output:
PostgreSQL-function
PostgreSQL-Window-function
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL - CREATE PROCEDURE
PostgreSQL - GROUP BY clause
PostgreSQL - DROP INDEX
PostgreSQL - Copy Table
PostgreSQL - REPLACE Function
PostgreSQL - TIME Data Type
PostgreSQL - CREATE SCHEMA
PostgreSQL - Cursor
PostgreSQL - SELECT
PostgreSQL - ROW_NUMBER Function
Apex - Constants

As in any other programming language, Constants are the variables which do not change their value once declared or assigned a value.
In Apex, Constants are used when we want to define variables which should have constant value throughout the program execution. Apex constants are declared with the keyword 'final'.
Consider a CustomerOperationClass class and a constant variable regularCustomerDiscount
inside it −
public class CustomerOperationClass {
   static final Double regularCustomerDiscount = 0.1;
   static Double finalPrice = 0;
   
   public static Double provideDiscount (Integer price) {
      //calculate the discount
      finalPrice = price - price * regularCustomerDiscount;
      return finalPrice;
   }
}
To see the Output of the above class, you have to execute the following code in the Developer Console Anonymous Window −
Double finalPrice = CustomerOperationClass.provideDiscount(100);
System.debug('finalPrice '+finalPrice);

    14 Lectures 
     2 hours 

 Vijay Thapa

    7 Lectures 
     2 hours 

 Uplatz

    29 Lectures 
     6 hours 

 Ramnarayan Ramakrishnan

    49 Lectures 
     3 hours 

 Ali Saleh Ali

    10 Lectures 
     4 hours 

 Soham Ghosh

    48 Lectures 
     4.5 hours 

 GUHARAJANM
 Print
 Add Notes
 Bookmark this page
ByteArrayOutputStream writeTo() method in Java with Examples - GeeksforGeeks

28 May, 2020
The writeTo() method of ByteArrayOutputStream class in Java is used to write the contents of this ByteArrayOutputStream to the specified OutputStream that is passed as the argument. In this method OutputStream is passed as a parameter and the ByteArrayOutputStream is copied to this OutputStream.
Syntax:
public void writeTo(OutputStream outputStr)
             throws IOException

Parameters: This method accepts one parameter outputStr which represents the OutputStream to which the content of ByteArrayOutputStream is to be copied.
Return value: The method does not return any value.
Exceptions: This method throws IOException if an I/O error occurs.
Below programs illustrate writeTo() method in ByteArrayOutputStream class in IO package:
Program 1:
// Java program to illustrate// ByteArrayOutputStream writeTo() method  import java.io.*;  public class GFG {    public static void main(String[] args)        throws Exception    {          // Create byteArrayOutputStream        ByteArrayOutputStream byteArrayOutStr            = new ByteArrayOutputStream();          // Create byte array        byte[] buf = { 71, 69, 69, 75, 83 };          // Create outputStream        OutputStream outputStr            = new ByteArrayOutputStream();          // Write byte array        // to byteArrayOutputStream        byteArrayOutStr.write(buf);          // Copy byteArrayOutputStream        // to OutputStream        byteArrayOutStr.writeTo(outputStr);          // Print the OutputStream        System.out.println(            outputStr.toString());    }}
GEEKS

Program 2:
// Java program to illustrate// ByteArrayOutputStream writeTo() method  import java.io.*;  public class GFG {    public static void main(String[] args)        throws IOException    {          // Create byteArrayOutputStream        ByteArrayOutputStream byteArrayOutStr            = new ByteArrayOutputStream();          // Create byte array        byte[] buf = { 71, 69, 69, 75, 83,                       70, 79, 82, 71, 69,                       69, 75, 83 };          // Create outputStream        OutputStream outputStr            = new ByteArrayOutputStream();          // Write byte array        // to byteArrayOutputStream        byteArrayOutStr.write(buf);          // Copy byteArrayOutputStream        // to OutputStream        byteArrayOutStr.writeTo(outputStr);          // Print the OutputStream        System.out.println(            outputStr.toString());    }}
GEEKSFORGEEKS

References:https://docs.oracle.com/javase/10/docs/api/java/io/ByteArrayOutputStream.html#writeTo(java.io.OutputStream)
Java-Functions
Java-IO package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Constructors in Java
Stream In Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Java Programming Examples
Internal Working of HashMap in Java
Checked vs Unchecked Exceptions in Java
Strings in Java
StringBuilder Class in Java with Examples
Tryit Editor v3.7

HTML Input attributes
Tryit: The height and width attributes
LocalTime now(clock) method in Java with Examples - GeeksforGeeks

12 May, 2020
The now(Clock clock) method of the LocalTime class in Java is used to get the current time from the specified clock.
Syntax:
public static LocalTime now(
    Clock clock)
Parameters: This method accepts clock as parameter which represents the clock to use.
Return value: This method returns the current time.
Below programs illustrate the now(Clock clock) method of LocalTime in Java:
Program 1:
// Java program to demonstrate// LocalTime.now(Clock clock) method  import java.time.*;import java.time.temporal.*;  public class GFG {    public static void main(String[] args)    {          // apply now(Clock clock) method        // of LocalTime class        LocalTime time = LocalTime.now(            Clock.systemUTC());          // print time        System.out.println("Time: "                           + time);    }}
Time: 21:04:28.811

Program 2:
// Java program to demonstrate// LocalTime.now(Clock clock) method  import java.time.*;import java.time.temporal.*;  public class GFG {    public static void main(String[] args)    {          // apply now(Clock clock) method        // of LocalTime class        LocalTime time = LocalTime.now(            Clock.systemUTC());          // print time        System.out.println("Time: "                           + time);    }}
Time: 21:05:21.192

Above two examples are taken to show the variance in result for same program according to time progression.
References: https://docs.oracle.com/javase/10/docs/api/java/time/LocalTime.html#now(java.time.Clock)
Java-Functions
Java-LocalTime
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Stream In Java
Different ways of Reading a text file in Java
Internal Working of HashMap in Java
Iterators in Java
Java Programming Examples
Comparator Interface in Java with Examples
Strings in Java
How can I check whether a field exists or not in MongoDB?

To check whether a field exists or not in MongoDB, you can use the $exists operator.
To understand the above concept, let us create a collection with the document. The query to create a collection with a document is as follows −
> db.checkFieldExistsOrNotDemo.insertOne({"StudentName":"Larry"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c92ba4136de59bd9de063a1")
}
> db.checkFieldExistsOrNotDemo.insertOne({"StudentName":"John","StudentAge":21});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c92ba4e36de59bd9de063a2")
}
> db.checkFieldExistsOrNotDemo.insertOne({"StudentName":"Chris","StudentAge":24,"StudentCountryName":"US"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c92ba6536de59bd9de063a3")
}

> db.checkFieldExistsOrNotDemo.insertOne({"StudentName":"Robert","StudentAge":21,"StudentCountryName":"UK","StudentHobby":["Teaching","Photography"]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c92ba9d36de59bd9de063a4")
}
Display all documents from a collection with the help of find() method. The query is as follows −
> db.checkFieldExistsOrNotDemo.find().pretty();
The following is the output −
{ "_id" : ObjectId("5c92ba4136de59bd9de063a1"), "StudentName" : "Larry" }
{
   "_id" : ObjectId("5c92ba4e36de59bd9de063a2"),
   "StudentName" : "John",
   "StudentAge" : 21
}
{
   "_id" : ObjectId("5c92ba6536de59bd9de063a3"),
   "StudentName" : "Chris",
   "StudentAge" : 24,
   "StudentCountryName" : "US"
}
{
   "_id" : ObjectId("5c92ba9d36de59bd9de063a4"),
   "StudentName" : "Robert",
   "StudentAge" : 21,
   "StudentCountryName" : "UK",
   "StudentHobby" : [
      "Teaching",
      "Photography"
   ]
}
Here is the query to check whether a field exists or not in MongoDB.
Case 1 − When a field exists.
The query is as follows −
> db.checkFieldExistsOrNotDemo.find({ 'StudentHobby' : { '$exists' : true }}).pretty();
The following is the output −
{
   "_id" : ObjectId("5c92ba9d36de59bd9de063a4"),
   "StudentName" : "Robert",
   "StudentAge" : 21,
   "StudentCountryName" : "UK",
   "StudentHobby" : [
      "Teaching",
      "Photography"
   ]
}
Case 2 − When a field does not exist.
The query is as follows:
> db.checkFieldExistsOrNotDemo.find({ 'StudentTechnicalSubject' : { '$exists' : true }}).pretty();
You will not get anything when a field does not exist.
Lolcode - Statements and Flow Control

LOLCODE allows you to control the flow of program through various statements. This chapter explains different types of statements available in LOLCODE.
An expression without any assignment, i.e. simply calling a mathematical operation or any function, is a legal statement in LOLCODE. Once the expression is evaluated, its final value is placed in the temporary variable IT. The value of IT remains in the local scope, and exists until the next time it is replaced with an expression.
Assignment statements are used to assign the output of any expression to a given variable. They are generally of the form −
<any_variable> <assignment operator> <any expression>
Please note that, you can use a variable in the expression, even before it is being assigned.
The if−then statement is a very simple operation working on the IT variable. It is similar to if−else statements in other programming languages like C and Java.
There are four keywords to apply the if–then statements.
O RLY?
YA RLY
NO WAI
OIC
The general form is −
<any_expression>
O RLY?
   YA RLY
      <code to execute if above condition is true>
   NO WAI
      <code to execute in this block>
OIC
All of the above statements can be written in the same line separated by commas like −
 BOTH SAEM NAMES AN "Name", O RLY?
   YA RLY, VISIBLE "My name is ABCD"
   NO WAI, VISIBLE "Your name is ABCD"
 OIC
 
While using the if-then statements, an optional MEBBE <any expression> may be used between the YA RLY and NO WAI blocks.
If the <any expression> following MEBBE is True (WIN), then that block is executed. Otherwise, if that expression is false, the block is skipped until the next MEBBE, NO WAI, or OIC statements.
<any expression>
O RLY?
   YA RLY
      <code to be executed if true>
   MEBBE <expression>
      <code to be executed mebbe is true>
   MEBBE <expression>
      <code to be executed mebbe is true>
   NO WAI
      <code to be executed if above are false>
OIC 
BOTH SAEM NAMES AN "NAME"
O RLY?
   YA RLY, VISIBLE "YOUR NAME IS ABCD"
   MEBBE BOTH SAEM ANIMAL AN "OUR NAME IS ABCD"
   VISIBLE "NO ABCD"
OIC
In LOLCODE, the keyword ‘WTF?’ is similar to switch in many other languages. The keyword WTF? takes IT as the expression value for comparison. To use WTF, a comparison block is opened by OMG which should be a literal, and not an expression.
Please remember that each literal must be unique, similar to the case in other languages.
The OMG block must be terminated by a GTFO statement. If an OMG block is not terminated by a GTFO, then the next OMG block is executed till GTFO is reached.
If none of the literals evaluate as true, then default case is signified by OMGWTF.
WTF?
   OMG <any value to compare>
      <code block to execute if expression is satisfied>
   OMG <any value to compare>
      <code block to execute if expression is satisfied>
   OMGWTF
      <code block to execute as a default case>
OIC
NAME, WTF?
   OMG "A"
      VISIBLE "ABCD"
      GTFO
   OMG "E"
      VISIBLE "EFGH"
      GTFO
   OMGWTF
      VISIBLE "ZYXW"
OIC
The output results of the above code will be −
"E":
EFGH

 Print
 Add Notes
 Bookmark this page
How to add stroke and color to text in JavaFX?

Since the javafx.scene.text.Text class in JavaFX inherits the Shape class it inherits all its members. You can modify the stroke and color of the text node by setting values to the stroke, stroke width and fill properties inherited by the Text class.
Stroke Width − The stroke width property specifies/defines the width of the boundary line of a shape. You can set value to the width of the boundary using the setWidth() method of the Shape class.
Stroke Width − The stroke width property specifies/defines the width of the boundary line of a shape. You can set value to the width of the boundary using the setWidth() method of the Shape class.
Fill − The fill property specifies/defines the color with which the interior area of the shape is to be filled. You can fill a particular shape with desired color using the fill() method of the Shape class.
Fill − The fill property specifies/defines the color with which the interior area of the shape is to be filled. You can fill a particular shape with desired color using the fill() method of the Shape class.
Stroke − The stroke property specifies/defines the color of the boundary of a shape. You can set the color of the boundary using the setStroke() method of the javafx.scene.shape.Shape class.
Stroke − The stroke property specifies/defines the color of the boundary of a shape. You can set the color of the boundary using the setStroke() method of the javafx.scene.shape.Shape class.
import java.io.FileNotFoundException;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
public class SettingStroke_Color extends Application {
   public void start(Stage stage) throws FileNotFoundException {
      //Creating a text object
      String str = "Welcome to Tutorialspoint";
      Text text = new Text(30.0, 80.0, str);
      //Setting the font
      Font font = Font.font("Brush Script MT", FontWeight.BOLD, FontPosture.REGULAR, 65);
      text.setFont(font);
      //Setting the color of the text
      text.setFill(Color.BROWN);
      //Setting the width
      text.setStrokeWidth(2);
      //Setting the stroke color
      text.setStroke(Color.BLUE);
      //Setting the stage
      Group root = new Group(text);
      Scene scene = new Scene(root, 595, 150, Color.BEIGE);
      stage.setTitle("Stroke And Color");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]){
      launch(args);
   }
}
sort() in Python

24 May, 2022
Like C++ sort(), Java sort() and other languages, python also provides built in function to sort. The sort function can be used to sort the list in both ascending and descending order. To sort the list in ascending order. Its time complexity is O(NlogN).
Syntax
# This will sort the given list in ascending order. # It returns a sorted list according to the passed parameter. List_name.sort()
This function can be used to sort list of integers, floating point number, string and others. 
Python3
# List of Integersnumbers = [1, 3, 4, 2] # Sorting list of Integersnumbers.sort() print(numbers) # List of Floating point numbersdecimalnumber = [2.01, 2.00, 3.67, 3.28, 1.68] # Sorting list of Floating point numbersdecimalnumber.sort() print(decimalnumber) # List of stringswords = ["Geeks", "For", "Geeks"] # Sorting list of stringswords.sort() print(words)
Output:
[1, 2, 3, 4]
[1.68, 2.0, 2.01, 3.28, 3.67]
['For', 'Geeks', 'Geeks']
To sort the list in descending order. 
Syntax
list_name.sort(reverse=True)
This will sort the given list in descending order.
Python3
# List of Integersnumbers = [1, 3, 4, 2] # Sorting list of Integersnumbers.sort(reverse=True) print(numbers) # List of Floating point numbersdecimalnumber = [2.01, 2.00, 3.67, 3.28, 1.68] # Sorting list of Floating point numbersdecimalnumber.sort(reverse=True) print(decimalnumber) # List of stringswords = ["Geeks", "For", "Geeks"] # Sorting list of stringswords.sort(reverse=True) print(words)
Output:
[4, 3, 2, 1]
[3.67, 3.28, 2.01, 2.0, 1.68]
['Geeks', 'Geeks', 'For']
Syntax : 
list_name.sort() – it sorts in ascending order list_name.sort(reverse=True) – it sorts in descending order list_name.sort(key=..., reverse=...) – it sorts according to user’s choice
Parameters: By default, sort() doesn’t require any extra parameters. However, it has two optional parameters:
reverse – If true, the list is sorted in descending order key – function that serves as a key for the sort comparison
Python
# Python program to demonstrate sorting by user's# choice # function to return the second element of the# two elements passed as the parameterdef sortSecond(val):    return val[1] # list1 to demonstrate the use of sorting# using second keylist1 = [(1,2),(3,3),(1,1)] # sorts the array in ascending according to# second elementlist1.sort(key=sortSecond)print(list1) # sorts the array in descending according to# second elementlist1.sort(key=sortSecond,reverse=True)print(list1)
Output:
[(1, 1), (1, 2), (3, 3)]
[(3, 3), (1, 2), (1, 1)]
Please refer Python Sort articles for more Python Sorting articles. Thanks to striver for inputs on this topic.
ManasChhabra2
ramanaceg
surinderdawra388
susobhanakhuli
python-list
python-list-functions
Python
Sorting
python-list
Sorting
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Express.js req.originalUrl Property

16 Jun, 2022
The req.originalUrl property is much like req.url however, it retains the original request URL thereby allowing you to rewrite req.url freely for internal routing purposes. Syntax:
req.originalUrl
Parameter: No parameters. Return Value: String Installation of express module:
You can visit the link to Install express module. You can install this package by using this command.
You can visit the link to Install express module. You can install this package by using this command.
npm install express
After installing the express module, you can check your express version in command prompt using the command.
After installing the express module, you can check your express version in command prompt using the command.
npm version express
After that, you can just create a folder and add a file for example, index.js. To run this file you need to run the following command.
After that, you can just create a folder and add a file for example, index.js. To run this file you need to run the following command.
node index.js
Example 1: Filename: index.js 
javascript
var express = require('express');var app = express();var PORT = 3000; app.get('/', function (req, res) {  console.log(req.originalUrl);  res.send();}); app.listen(PORT, function(err){    if (err) console.log(err);    console.log("Server listening on PORT", PORT);});
Steps to run the program:
The project structure will look like this: Make sure you have installed express module using the following command:
The project structure will look like this: 
Make sure you have installed express module using the following command:
npm install express
Run index.js file using below command:
Run index.js file using below command:
node index.js
Output:
Output:
Server listening on PORT 3000
Now open your browser and go to http://localhost:3000?title=GeeksforGeeks, now you can see the following output on your console:
Now open your browser and go to http://localhost:3000?title=GeeksforGeeks, now you can see the following output on your console:
Server listening on PORT 3000
/?title=GeeksforGeeks
Example 2: Filename: index.js 
javascript
var express = require('express');var app = express();var PORT = 3000; app.get('/user', function (req, res) {  console.log(req.originalUrl);  res.send();}); app.listen(PORT, function(err){    if (err) console.log(err);    console.log("Server listening on PORT", PORT);});
Run index.js file using below command:
node index.js
Output: Now open your browser and make GET request to http://localhost:3000/user?name=geek, now you can see the following output on your console:
Server listening on PORT 3000
/user?name=geek
Reference: Official Documentation
sumitgumber28
Express.js
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Reverse words in a given String in Java

11 Dec, 2018
Let’s see an approach to reverse words of a given String in Java without using any of the String library function
Examples:
Input : "Welcome to geeksforgeeks"
Output : "geeksforgeeks to Welcome"

Input : "I love Java Programming"
Output :"Programming Java love I"

Prerequisite: Regular Expression in Java
// Java Program to reverse a String// without using inbuilt String functionimport java.util.regex.Pattern;public class Exp {      // Method to reverse words of a String    static String reverseWords(String str)    {          // Specifying the pattern to be searched        Pattern pattern = Pattern.compile("\\s");          // splitting String str with a pattern        // (i.e )splitting the string whenever their        //  is whitespace and store in temp array.        String[] temp = pattern.split(str);        String result = "";          // Iterate over the temp array and store        // the string in reverse order.        for (int i = 0; i < temp.length; i++) {            if (i == temp.length - 1)                result = temp[i] + result;            else                result = " " + temp[i] + result;        }        return result;    }      // Driver methods to test above method    public static void main(String[] args)    {        String s1 = "Welcome to geeksforgeeks";        System.out.println(reverseWords(s1));          String s2 = "I love Java Programming";        System.out.println(reverseWords(s2));    }}
Output:
geeksforgeeks to Welcome
Programming Java love I

You can find the c++ solution for Reverse words in a String here
This article is contributed by Sumit Ghosh. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Java-String-Programs
Java-Strings
Java
Strings
Java-Strings
Strings
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Create a simple assistant using Wolfram Alpha API.

18 Oct, 2019
The Wolfram|Alpha Webservice API provides a web-based API allowing the computational and presentation capabilities of Wolfram|Alpha to be integrated into web, mobile, desktop, and enterprise applications. Wolfram Alpha is an API which can compute expert-level answers using Wolfram’s algorithms, knowledgebase and AI technology. It is made possible by the Wolfram Language. This article tells how to create a simple assistant application in Python which can answer simple questions like the ones listed below.
Input : What is the capital of India? 
Output : New Delhi

Input : What is sin(30)?
Output : 0.5

Prerequisite: Basic understanding of python syntax and functions.
Getting API Id
Create a account at Wolfram alpha. The account can be created at the official website.After signing up, sign in using your Wolfram ID.Now you will see the homepage of the website. Head to the section in the top right corner where you see your email. In the drop down menu, select the My Apps (API) option.Click the Get an AppID button to get the id.In the next dialog box, give the app a suitable name and description.Note down the APPID that appears in the next dialog box. This app id will be specific to the application.
Create a account at Wolfram alpha. The account can be created at the official website.
After signing up, sign in using your Wolfram ID.
Now you will see the homepage of the website. Head to the section in the top right corner where you see your email. In the drop down menu, select the My Apps (API) option.
Click the Get an AppID button to get the id.
In the next dialog box, give the app a suitable name and description.
Note down the APPID that appears in the next dialog box. This app id will be specific to the application.
Implementation
Make sure that wolframalpha python package is installed beforehand. It can be done by running the following command in the terminal or cmd –
pip install wolframalpha

Below is the implementation
# Python program to # demonstrate creation of an# assistant using wolf ram API  import wolframalpha  # Taking input from userquestion = input('Question: ')  # App id obtained by the above stepsapp_id = ‘Your app_id’  # Instance of wolf ram alpha # client classclient = wolframalpha.Client(app_id)  # Stores the response from # wolf ram alphares = client.query(question)  # Includes only text from the responseanswer = next(res.results).text  print(answer)
Output:
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Introduction To PYTHON
Sequential circuits - GeeksforGeeks

19 Nov, 2018
 A)  
B) 
C)
D)
Q0     Q1

0      0

1      1

0      1

1      0

0      0

.      .

.      .

.      .

Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Must Do Coding Questions for Companies like Amazon, Microsoft, Adobe, ...
Must Do Coding Questions for Product Based Companies
Git - Difference Between Git Fetch and Git Pull
ReactJS useNavigate() Hook
SDE SHEET - A Complete Guide for SDE Preparation
How to Install and Use NVM on Windows?
DSA Sheet by Love Babbar
Java Threads
Top 20 Puzzles Commonly Asked During SDE Interviews
Spring Boot - Exception Handling
PHP | Determining Client IP Address

30 Jul, 2021
What is an IP Address? The IP address stands for Internet Protocol Address. An IP address is used to provide an identity to a networked device.IP addresses allow the location of different digital devices that are connected to the Internet to be pinpointed and differentiated from other devices.
In this post we have discussed two different ways of determining the client IP address from a PHP script as explained below: 
Using getenv() function: To get the IP Address,we use getenv(“REMOTE_ADDR”) command.The getenv() function in PHP is used for retrieval of values of an environment variable in PHP.It is used to return the value of a specific environment variable.Syntax :  
PHP
<?php $ipaddress = getenv("REMOTE_ADDR") ; Echo "Your IP Address is " . $ipaddress;?>
Output : 
Your IP is 127.1.1.0
Determining IP Address using $_SERVER Variable Method : There is another way to get the IP Address by using the $_SERVER[‘REMOTE_ADDR’] or $_SERVER[‘REMOTE_HOST’] variables. The variable in the $_SERVER array is created by the web server such as apache and those can be used in PHP.Basically $_SERVER[‘REMOTE_ADDR’]gives the IP address from which the request was sent to the web server. Syntax : 
PHP
<?php $ipaddress = $_SERVER['REMOTE_ADDR'] Echo "Your IP Address is " . $ipaddress;?>
Output : 
Your IP is 127.1.1.0
 
rajeev0719singh
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to convert array to string in PHP ?
PHP | Converting string to Date and DateTime
How to get parameters from a URL string in PHP?
Split a comma delimited string into an array in PHP
Download file from URL using PHP
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
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 Int data type to Float in Golang?

10 May, 2020
In Golang, the data types are bound to variables rather than the values, which means that, if you declare a variable as int, then you can store only integer type value in it, you cant assign character or string in it unless you convert the data type to required data type.
To convert an integer data type to float you can wrap the integer with float64() or float32.
Example:
// Golang program to convert Int data type to Floatpackage main  import (    "fmt"    "reflect")  func main() {      // var declared x as int    var x int64 = 5      // y is a float64 type variable    var y float64 = float64(x)      // printing the values of x and y    fmt.Printf("x = %d \n", x)    fmt.Printf("y = %f \n", y)      // to print a float upto a    // specific number of decimal point    fmt.Printf("\ny upto 3 decimal = %.3f", y)      // getting the converted type    fmt.Println("\n", reflect.TypeOf(y))  }
Output
x = 5 
y = 5.000000 

y upto 3 decimal = 5.000
 float64

Explanation: Firstly we declare a variable x of type int64 with a value of 5. Then we wrap x with float64(), which converts the integer 5 to float value of 5.00. The %.3f formats the float value upto 3 decimal points.
Golang-Program
Picked
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Arrays in Go
Golang Maps
How to Split a String in Golang?
Interfaces in Golang
Slices in Golang
Different Ways to Find the Type of Variable in Golang
How to Parse JSON in Golang?
How to convert a string in lower case in Golang?
How to Trim a String in Golang?
How to compare times in Golang?
Python | Pandas Series.transform()

05 Feb, 2019
Pandas series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index.
Pandas Series.transform() function Call func (the passed function) on self producing a Series with transformed values and that has the same axis length as self.
Syntax: Series.transform(func, axis=0, *args, **kwargs)
Parameter :func : If a function, must either work when passed a Series or when passed to Series.applyaxis : Parameter needed for compatibility with DataFrame.*args : Positional arguments to pass to func.**kwargs : Keyword arguments to pass to func.
Returns : Returns series that must have the same length as self.
Example #1: Use Series.transform() function to transform the elements of the given Series object. Append ‘_City’ at the end of each city name.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series(['New York', 'Chicago', 'Toronto', 'Lisbon', 'Rio', 'Moscow'])  # Create the Datetime Indexdidx = pd.DatetimeIndex(start ='2014-08-01 10:00', freq ='W',                      periods = 6, tz = 'Europe/Berlin')   # set the indexsr.index = didx  # Print the seriesprint(sr)
Output :
Now we will use Series.transform() function to append ‘_City’ at the end of each city name.
# append '_City'sr.transform(lambda x : x + '_City')
Output :
As we can see in the output, the Series.transform() function has successfully appended the desired keyword at the end of which city name. Example #2: Use Dataframe.transform() function to transform the data of the given Dataframe. Increase the ticket cost of each even by 1000.
# importing pandas as pdimport pandas as pd  # Creating the Dataframedf = pd.DataFrame({'Date':['10/2/2011', '11/2/2011', '12/2/2011', '13/2/2011'],                    'Event':['Music', 'Poetry', 'Theatre', 'Comedy'],                    'Cost':[10000, 5000, 15000, 2000]})  # Print the dataframeprint(df)
Output :
Now we will use Dataframe.transform() function to increase the ticket cost by 1000
# transform the 'Cost' columndf['Cost'] = df['Cost'].transform(lambda x : x + 1000)  # Print the dataframe after modificationprint(df)
Output :
As we can see in the output, the Dataframe.transform() function has successfully increased the ticket cost of each event by 1000.
Python pandas-series
Python pandas-series-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Flask – ImmutableMultiDict

23 Sep, 2021
MultiDict is a sub-class of Dictionary that can contain multiple values for the same key, unlike normal Dictionaries.  It is used because some form elements have multiple values for the same key and it saves the multiple values of a key in form of a list.
Example:
Python3
from werkzeug.datastructures import MultiDict  orders = MultiDict([(1, 'GFG'), (1, 'Geeks')])print(orders[1])  print(orders.getlist(1))
Output:
GFG
['GFG', 'Geeks']
In this article, we will see how to get MultiDict data from the form in Flask.
Let us write a simple HTML page with a form tag and submit it to a flask route. The request.form object which is used to get the contents from the form during POST request is of type ImmutableMultiDict.  
Index.HTML
HTML
<!DOCTYPE html><html>   <head>      <title>Input Page</title>   </head>   <body>      <form method='POST' action="save">         <input type="text" name="username" id="uname"/>         <input type="submit" value="Submit"/>      </form>   </body></html>
Let us write another HML file that will shoe the type of the data given by the POST request.
HTML
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Home</title></head><body>{{userInput}}</body></html>
We will create a simple flask app that will render the above-created form at the URL http://127.0.0.1:5000/input and will show the data submitted using the POST request at the URL http://127.0.0.1:5000/save
Python3
from flask import Flask, render_template, request, redirect, url_for  app = Flask(__name__)  @app.route('/input', methods=['GET'])def input():    return render_template('index.html')  @app.route('/save', methods=['POST'])def save():        userInput = request.form    return render_template('home.html', userInput=userInput)  if __name__ == '__main__':    app.run()
Output:
Blogathon-2021
Picked
Python Flask
Blogathon
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.