code-rag-bench/online-tutorials huggingface dataset:
Perl | Removing leading and trailing white spaces (trim)

05 Jun, 2020
Removing unwanted spaces from a string can be used to store only the required data and to remove the unnecessary trailing spaces. This can be done using the trim function in Perl. The trim function uses a regular expression to remove white spaces. It is not a library function but defined by the user whenever required. The types of trim functions are:
Left Trim (~ s/^\s+//): Removes extra spaces from leftmost side of the string till the actual text starts. From the leftmost side the string takes 1 or more white spaces (\s+) and replaces it with nothing.
Right Trim (~ s/\s+$//): Removes extra spaces from rightmost side of the string till the actual text end is reached. From the rightmost side the string takes 1 or more white spaces (\s+) and replaces it with nothing.
Trim (~ s/^\s+|\s+$//): It removes extra space from both sides of the string.
Example: The following code demonstrates the left trim, right trim and trim in Perl:
   # Perl program for removing leading and# trailing white spaces using trim  #!/usr/bin/perl  # Original String$str1 = "     Geeks----";  print"The Original String is:\n";print"${str1}\n\n";  # Applying left trim to str1print"After Lefttrim Str1:\n";$str1=~ s/^\s+//;print"${str1}\n\n";  # again initializing the # value to string$str1 = "----Geeks     ";  # Applying right trim to str1print"After Righttrim Str1:\n";$str1=~ s/\s+$//;print"${str1}\n\n";  # again initializing the # value to strings$str1="      Geeks      ";    # Applying trim to str1print"After trim Str1:\n";$str1=~ s/^\s+|\s+$//g;print"${str1}\n";
Output:
The Original String is:
     Geeks----

After Lefttrim Str1:
Geeks----

After Righttrim Str1:
----Geeks

After trim Str1:
Geeks
Code_Mech
Perl-method
Perl-regex
Perl-String
Perl
Perl
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Perl | Arrays
Perl Tutorial - Learn Perl With Examples
Perl | Boolean Values
Perl | length() Function
Perl | Subroutines or Functions
Use of print() and say() in Perl
Hello World Program in Perl
Perl | Basic Syntax of a Perl Program
Perl | ne operator
Perl | eq operator
Return Value from R Function

12 May, 2022
In this article, we will discuss how to return value from a function in R Programming Language.
In this scenario, we will use the return statement to return some value
Syntax:
function_name <- function(parameters) {      
statements
 return(value)
}
function_name(values)
Where,
function_name is the name of the function
parameters are the values that are passed as arguments
return() is used to return a value
function_name(values) is used to pass values to the parameters
Example: R program to perform addition operation with return value
R
# define addition function# perform addition operation on two valuesaddition= function(val1,val2) {       # add       add=val1+val2     # return the result  return(add) } # pass the values to the functionaddition(10,20)
Output:
[1] 30
Here without using return function we will return a value. For this just passing the name of the variable that stores the value to returned works.
Syntax:
function_name <- function(parameters) {      
statements
value
}
function_name(values)
where,
function_name is the name of the function
parameters are the values that are passed as arguments
value is the return value
function_name(values) is used to pass values to the parameters
Example: R program to perform addition operation without using return function
R
# define addition function# perform addition operation on two valuesaddition= function(val1,val2) {     # add       add=val1+val2     # return the result with out using return  add} # pass the values to the functionaddition(10,20)
Output:
[1] 30
In this scenario, we will use the list() function in the return statement to return multiple values.
Syntax:
function_name <- function(parameters) {      
statements
return(list(value1,value2,.,value n)
}
function_name(values)
where,
function_name is the name of the function
parameters are the values that are passed as arguments
return() function takes list of values as input
function_name(values) is used to pass values to the parameters
Example: R program to perform arithmetic operations and return those values
R
# define arithmetic function# perform arithmetic operations on two valuesarithmetic = function(val1,val2) {        # add       add=val1+val2     # subtract  sub=val1-val2     # multiply  mul=val1*val2   # divide  div=val2/val1     # return the result as a list  return(list(add,sub,mul,div))} # pass the values to the functionarithmetic(10,20)
Output:
[[1]]
[1] 30

[[2]]
[1] -10

[[3]]
[1] 200

[[4]]
[1] 2
kalrap615
simmytarika5
sumitgumber28
Picked
R-Functions
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Move Image in HTML ?

24 Jun, 2021
You can easily move images in HTML using <marquee> tag. It is used to create scrolling images either from horizontally left to right or right to left, or vertically top to bottom or bottom to top. By default, image found within the <marquee> tag will scroll from right to left.
Syntax:
<marquee>
   <img src="">
</marquee>
Attributes of <marquee> tag:
direction: Sets the direction for the scrolling images. The value of this attribute can be left, right, up or down.
behavior: The behavior tells about how the text scrolls. It can be one of the following values which are alternate, scroll, slide.
Example 1: The following example uses scroll behavior.
HTML
<!DOCTYPE html><html>  <body><center>    <!-- The image has scrolling behavior to left -->    <marquee  behavior="scroll" direction="left">                  <img src="https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png"          alt="GeeksforGeeks logo">     </marquee>           <!-- The image has scrolling behavior to the upper direction. -->   <marquee  behavior="scroll" direction="up">                   <img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png"          alt="GeeksforGeeks logo">     </marquee>  </center></body></html>
 
Output:
Example 2: The following example uses the alternate behaviour.
HTML
<!DOCTYPE html><html><body>  <center>    <marquee  behavior="alternate" direction="left">                    <img src="https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png"          alt="GeeksforGeeks logo">     </marquee>           <marquee  behavior="alternate" direction="right">                   <img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png"          alt="GeeksforGeeks logo">     </marquee>  </center>  </body></html>
Output:
HTML-Questions
HTML-Tags
Picked
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
Types of CSS (Cascading Style Sheet)
How to Insert Form Data into Database using PHP ?
Design a Tribute Page using HTML & CSS
Form validation using HTML and JavaScript
Installation of Node.js on Linux
Node.js fs.readFileSync() Method
How do you run JavaScript script through the Terminal?
Node.js | fs.writeFileSync() Method
Difference between var, let and const keywords in JavaScript
What is method hiding in Java and how to use it?

When super class and sub class contains same method including parameters and if they are static.

The method in the super class will be hidden by the one that is in the sub class. This mechanism is known as method hiding.
 Live Demo
class Demo{
   public static void demoMethod() {
      System.out.println("method of super class");
   }
}
public class Sample extends Demo {
   public static void demoMethod() {
      System.out.println("method of sub class");
   }
   public static void main(String args[] ) {
      Sample.demoMethod();
   }
}
method of sub class
How to set background-image for the body element using CSS ?

23 Dec, 2020
In this article, we set the image into the background using CSS property. The background-image property is used to set one or more background images to an element. By default, it places the image on the top left corner. To specify two or more images, separate the URLs with a comma.
Syntax:
background-image: url("url");
Property value: It holds the URL of an image that you want to use as background image.
Example:
HTML
<!DOCTYPE html><html>  <head>    <title>        How to set background-image for        the body element using CSS ?    </title>      <style>        body {            background-image: url("https://media.geeksforgeeks.org/wp-content/cdn-uploads/CSS.png");            text-align: center;        }    </style></head>  <body>    <h1 style="color: white;">        GeeksforGeeks    </h1>      <h3>        Set background-image for        the body element    </h3></body>  </html>
Output:
Supported Browsers:
Google Chrome 1.0
Edge 4.0
Firefox 1.0
Opera 3.5
Safari 1.0
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a Tribute Page using HTML & CSS
How to set space between the flexbox ?
Build a Survey Form using HTML and CSS
Form validation using jQuery
Design a web page using HTML and CSS
REST API (Introduction)
Hide or show elements in HTML using display property
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
HTTP headers | Content-Type
CSS :hover Selector - GeeksforGeeks

01 Nov, 2021
The :hover selector CSS pseudo-class is used to style elements when the mouse hovers over them. It can be used on every element.
We can style the links for unvisited pages using the :link selector, for styling the links to visited pages, use the :visited selector & for styling the active link, use the :active selector. If the :link and :visited selectors are present in the CSS definition then in order to see the effect, we must add :hover selector after it.
Syntax:
element :hover{
    // CSS declarations;
}
Example 1: This example illustrates the changing of the background-color on hover over an element.
HTML
<!DOCTYPE html><html> <head>    <style>    h1:hover {        color: white;        background-color: green;    }    </style></head> <body>    <h1 align="center"> hover it</h1></body> </html>
Output:
Example 2: This example is showing a hidden block on hover over text.
HTML
<!DOCTYPE html><html> <head>    <style>    ul {        display: none;    }         div {        background: green;        width: 200px;        height: 200px;        padding: 20px;        padding-left: 50px;        font-size: 30px;        color: white;        display: none;    }         h3:hover + div {        display: block;    }    </style></head> <body>    <h3 align="center">        Hover to see hidden GeeksforGeeks.    </h3>    <div> GeeksforGeeks </div></body> </html>
Output:
Example 3: This example illustrates the changing of the font-color on hover over an element.
HTML
<!DOCTYPE html><html> <head>    <style>    h1:hover {        color: red;    }    </style></head> <body>    <h1 align="center"> hover it</h1></body> </html>
Output:
Example 4: This example illustrates the changing of the font-family of text on hover over it. 
HTML
<!DOCTYPE html><html> <head>    <style>    h1:hover {        font-family: monospace;    }    </style></head> <body>    <h1 align="center"> hover it</h1></body> </html>
Output:
Example 5: This example illustrates the changing of the text-decoration to underline on hover over an element.
HTML
<!DOCTYPE html><html> <head>    <style>    h1:hover {        text-decoration: underline;    }    </style></head> <body>    <h1 align="center"> hover it</h1></body> </html>
Output:
Supported Browsers:
Google Chrome 4.0
Microsoft Edge 7.0
Mozilla Firefox 2.0
Safari 3.1
Opera 9.6
arorakashish0911
bhaskargeeksforgeeks
CSS-Selectors
Picked
Web technologies
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to create footer to stay at the bottom of a Web page?
How to apply style to parent if it has child with CSS?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
C Program to concatenate two strings without using strcat - GeeksforGeeks

16 Oct, 2019
Given two strings str1 and str2, the task is to write a C Program to concatenate these two strings without using the strcat() function
Examples:
Input: str1 = "hello", str2 = "world"
Output: helloworld

Input: str1 = "Geeks", str2 = "World"
Output: GeeksWorld

Approach:
Get the two Strings to be concatenated
Declare a new Strings to store the concatenated String
Insert the first string in the new string
Insert the second string in the new string
Print the concatenated string
Below is the implementation of the above approach:
// C Program to concatenate// two strings without using strcat  #include <stdio.h>  int main(){      // Get the two Strings to be concatenated    char str1[100] = "Geeks", str2[100] = "World";      // Declare a new Strings    // to store the concatenated String    char str3[100];      int i = 0, j = 0;      printf("\nFirst string: %s", str1);    printf("\nSecond string: %s", str2);      // Insert the first string in the new string    while (str1[i] != '\0') {        str3[j] = str1[i];        i++;        j++;    }      // Insert the second string in the new string    i = 0;    while (str2[i] != '\0') {        str3[j] = str2[i];        i++;        j++;    }    str3[j] = '\0';      // Print the concatenated string    printf("\nConcatenated string: %s", str3);      return 0;}
First string: Geeks
Second string: World
Concatenated string: GeeksWorld

C Programs
Strings
Strings
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C Program to read contents of Whole File
Header files in C/C++ and its uses
Program to print ASCII Value of a character
How to return multiple values from a function in C or C++?
How to Append a Character to a String in C
Write a program to reverse an array or string
Reverse a string in Java
Write a program to print all permutations of a given string
C++ Data Types
Longest Common Subsequence | DP-4
How to correctly use delimiter in a MySQL stored procedure and insert values?

Let us first create a table −
mysql> create table DemoTable2028
   -> (
   -> StudentFirstName varchar(20),
   -> StudentLastName varchar(20)
   -> );
Query OK, 0 rows affected (0.87 sec)
Here is the query to create a stored procedure and insert values (using delimiter correctly) −
mysql> delimiter //
mysql> create procedure insert_name(in fname varchar(20),in lname varchar(20))
   -> begin
   -> insert into DemoTable2028 values(fname,lname);
   -> end
   -> //
Query OK, 0 rows affected (0.17 sec)
mysql> delimiter ;
Call the stored procedure using CALL command −
mysql> call insert_name('Chris','Brown');
Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable2028;
This will produce the following output −
+------------------+-----------------+
| StudentFirstName | StudentLastName |
+------------------+-----------------+
| Chris            | Brown           |
+------------------+-----------------+
1 row in set (0.00 sec)
Python Design Patterns - Adapter

Adapter pattern works as a bridge between two incompatible interfaces. This type of design pattern comes under structural pattern as this pattern combines the capability of two independent interfaces.
This pattern involves a single class, which is responsible to join functionalities of independent or incompatible interfaces. A real life example could be the case of a card reader, which acts as an adapter between memory card and a laptop. You plug in the memory card into the card reader and the card reader into the laptop so that memory card can be read via the laptop.
The adapter design pattern helps to work classes together. It converts the interface of a class into another interface based on requirement. The pattern includes a speciation a polymorphism which names one name and multiple forms. Say for a shape class which can use as per the requirements gathered.
There are two types of adapter pattern −
This design pattern relies on object implementation. Hence, it is called the Object Adapter Pattern.
This is an alternative way to implement the adapter design pattern. The pattern can be implemented using multiple inheritances.
Let us now see how to implement the adapter pattern.
class EuropeanSocketInterface:
   def voltage(self): pass

   def live(self): pass
   def neutral(self): pass
   def earth(self): pass

# Adaptee
class Socket(EuropeanSocketInterface):
   def voltage(self):
      return 230

	def live(self):
      return 1
   
   def neutral(self):
      return -1
   
   def earth(self):
      return 0

# Target interface
class USASocketInterface:
   def voltage(self): pass
   def live(self): pass
   def neutral(self): pass

# The Adapter
class Adapter(USASocketInterface):
   __socket = None
   def __init__(self, socket):
      self.__socket = socket
   
   def voltage(self):
      return 110
   
   def live(self):
      return self.__socket.live()
   
   def neutral(self):
      return self.__socket.neutral()

# Client
class ElectricKettle:
   __power = None
   
   def __init__(self, power):
	   self.__power = power
   
   def boil(self):
      if self.__power.voltage() > 110:
         print "Kettle on fire!"
      else:
         if self.__power.live() == 1 and \
            self.__power.neutral() == -1:
            print "Coffee time!"
         else:
            print "No power."

def main():
   # Plug in
   socket = Socket()
   adapter = Adapter(socket)
   kettle = ElectricKettle(adapter)
	
   # Make coffee
   kettle.boil()
	
   return 0
	
if __name__ == "__main__":
   main()
The above program generates the following output −
The code includes adapter interface with various parameters and attributes. It includes Adaptee along with Target interface that implements all the attributes and displays the output as visible.

    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
JavaScript array.includes() function

The array.includes() method of JavaScript is used to check whether an array contains a specified element.
The syntax is as follows −
array.includes(ele, start)
Above, the parameter ele is the element to search for. The start parameter is the position to begin the search with.
Let us now implement the array.includes() method in JavaScript −
 Live Demo
<!DOCTYPE html>
<html>
<body>
   <h2>Car Variant</h2>
   <button onclick="display()">Result</button>
   <p id="test"></p>
   <script>
      var carid = ["110", "230", "299", "399"];
      document.getElementById("test").innerHTML = carid;
      function display() {
         var n = carid.includes("230");
         document.getElementById("test").innerHTML = "The array has the specific value 230? = "+n;
      }
   </script>
</body>
</html>
Above, the click the “Result” button −
 Live Demo
<!DOCTYPE html>
<html>
<body>
   <h2>Car Variant</h2>
   <p>Does the array includes the specific element Crossover?</p>
   <button onclick="display()">Result</button>
   <p id="test"></p>
   <script>
      var car = ["Hatchback", "Convertible"];
      var res2 = car.entries();
      for (val of res2) {
         document.getElementById("test").innerHTML += val + "<br>";
      }
      function display() {
         var res = car.includes("Crossover");
         document.getElementById("test").innerHTML = res;
      }
   </script>
</body>
</html>
Click on the “Result” button above −
Gradle - Deployment

Gradle offers several ways to deploy build artifacts repositories. When deploying signatures for your artifacts to a Maven repository, you will also want to sign the published POM file.
By default, maven-publish plugin is provided by Gradle. It is used to publish the gradle script. Take a look into the following code.
apply plugin: 'java'
apply plugin: 'maven-publish'

publishing {
   publications {
      mavenJava(MavenPublication) {
         from components.java
      }
   }

   repositories {
      maven {
         url "$buildDir/repo"
      }
   }
}
There are several publish options, when the Java and the maven-publish plugin is applied. Take a look at the following code, it will deploy the project into a remote repository.
apply plugin: 'groovy'
apply plugin: 'maven-publish'

group 'workshop'
version = '1.0.0'

publishing {
   publications {
      mavenJava(MavenPublication) { 
         from components.java 
      }
   }
	
   repositories {
      maven {
          default credentials for a nexus repository manager
         credentials {
            username 'admin'
            password 'admin123'
         }
         // url to the releases maven repository
            url "http://localhost:8081/nexus/content/repositories/releases/"
      }
   }
}
There is a special command for converting Apache Maven pom.xml files to Gradle build files, if all used Maven plug-ins are known to this task.
In this section the following pom.xml maven configuration will be converted to a Gradle project.
<project xmlns = "http://maven.apache.org/POM/4.0.0" 
   xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0
   http://maven.apache.org/xsd/maven-4.0.0.xsd">
	
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.example.app</groupId>
   <artifactId>example-app</artifactId>
   <packaging>jar</packaging>
   
   <version>1.0.0-SNAPSHOT</version>
	
   <dependencies>
      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>

         <version>4.11</version>
         <scope>test</scope>
      </dependency>
   </dependencies>
	
</project>
You can use the following command on the command line that results in the following Gradle configuration.
C:\> gradle init --type pom

The init task depends on the wrapper task so that a Gradle wrapper is created.
The resulting build.gradle file looks similar to this −
apply plugin: 'java'
apply plugin: 'maven'

group = 'com.example.app'
version = '1.0.0-SNAPSHOT'

description = """"""

sourceCompatibility = 1.5
targetCompatibility = 1.5

repositories {
   maven { url "http://repo.maven.apache.org/maven2" }
}

dependencies {
   testCompile group: 'junit', name: 'junit', version:'4.11'
}
 Print
 Add Notes
 Bookmark this page
What is the difference between prefix and postfix operators in C++?

In the prefix version (i.e., ++i), the value of i is incremented, and the value of the expression is the new value of i. So basically it first increments then assigns a value to the expression.
 In the postfix version (i.e., i++), the value of i is incremented, however, the {value|the worth} of the expression is that the original value of i. So basically it first assigns a value to expression and then increments the variable.
Let's look at some code to get a better understanding −
#include<iostream>
using namespace std;

int main() {
   int x = 3, y, z;
   y = x++;
   z = ++x;
   cout << x << ", " << y << ", " << z;
   return 0;
}
This would give us the output −
5, 3, 5
Why is this? Let's look at it in detail −
Initialize x to 3
 Assign y the value we get by evaluating the expression x++, ie, the value of x before increment then increment x.
Increment x then assign z the value we get by evaluating the expression ++x, ie, value of x after the increment.
Print these values
Add a light grey background color to the Bootstrap 4 card

To add a light grey background color to a card in Bootstrap, use the bg-light contextual class with the card class.
To set light grey background, add it to the <div> class −
<div class="card bg-light text-dark">
  <div class="card-body">Reduce size of images</div>
</div>
You can try to run the following code to add ligh grey background color to a card in Bootstrap 4 −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  </head>

<body>
  <div class="container">
    <h2>Optimization</h2>
    <div class="card bg-light text-dark">
      <div class="card-body">Reduce size of images</div>
    </div>
    <div class="card bg-light text-dark">
      <div class="card-body">Clear Cache</div>
    </div>
    <div class="card bg-light text-dark">
      <div class="card-body">Use CDN</div>
    </div>
  </div>

</body>
</html>
How to Change or Set System Locales in Linux

We often need to customise the operating system to become useful to our own preferences like the language we want to use the time zone we are in the type of currency which would become the default currency in the OS etc. In this article we will see how to customise these options which is known as locale.
We can check the current locally by using the locale command as shown below. We get list of variables which can be reset to a different value as per our choice later
$ locale
Running the above code gives us the following result −
LANG=en_US.UTF-8
LANGUAGE=en_US
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
To get all the available locale we use the below command. It just displays the locale values.
$ locale -a
Running the above code gives us the following result −
C
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
. . .
en_IN
en_IN.utf8
en_NG
. . .
en_ZM.utf8
en_ZW.utf8
POSIX
The specific variable details can be obtained by using the variable name along with the –c and –k switch.
$ locale -c -k LC_TIME
Running the above code gives us the following result −
LC_TIME
abday="Sun;Mon;Tue;Wed;Thu;Fri;Sat"
day="Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday"
abmon="Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec"
mon="January;February;March;April;May;June;July;August;September;October;November;December"
am_pm="AM;PM"
d_t_fmt="%a %d %b %Y %r %Z"
d_fmt="%m/%d/%Y"
t_fmt="%r"
t_fmt_ampm="%I:%M:%S %p"
. . .
. . .
timezone=""
date_fmt="%a %b %e %H:%M:%S %Z %Y"
time-codeset="UTF-8"
To change the value of a locale which is already set, we can edit the .bashrc profile of the use who needs the new locale.
$ sudo nano ~/.bashrc
#And add the following lines at end
LANG="en_IN.utf8"
export LANG

$ locale
Running the above code gives us the following result −
$ locale
LANG=en_IN.utf8
LANGUAGE=en_US
LC_CTYPE="en_IN.utf8"
LC_NUMERIC="en_IN.utf8"
. . .
How to apply forEach tag in JSP?

The <c:forEach> tag is a commonly used tag because it iterates over a collection of objects. The <c:forTokens> tag is used to break a string into tokens and iterate through each of the tokens.
The <c:forEach> tag has the following attributes −
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<html>
   <head>
      <title><c:forEach> Tag Example</title>
   </head>
   <body>
      <c:forEach var = "i" begin = "1" end = "5">
         Item <c:out value = "${i}"/><p>
      </c:forEach>
   </body>
</html>
The above code will generate the following result −
Item 1
Item 2
Item 3
Item 4
Item 5
turtle.clone() function in Python

21 Jul, 2020
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
The turtle.clone() method is used to create and return a clone of the turtle with the same position, heading, and turtle properties. This method does not require any argument.
Syntax :
turtle.clone()

Below is the implementation of the above method with an example in two ways for better understanding :
Example 1: Without Cloning
Python3
# import packageimport turtle    # make first turtle objecttur1=turtle.Turtle()  # set turtle propertiestur1.width(5)tur1.color("red")  # move ittur1.circle(50)  # make another turtle objecttur2=turtle.Turtle()  # move ittur2.circle(-50)
Output :
Example 2: With Cloning
Python3
# import packageimport turtle    # make first turtle objecttur1=turtle.Turtle()  # set turtle propertiestur1.width(5)tur1.color("red")  # move ittur1.circle(50)  # make another turtle objecttur2=turtle.Turtle()  # cloning the properties of # first turtle objecttur2 = tur1.clone()  # move ittur2.circle(-50)
Output :
Here we can find that in first output second turtle (tur2) is not having any property as the first turtle (tur1). To get this we have to set these properties again. But turtle.clone() method gives the advantage to clone properties of one turtle object to another as we can see in the second output.
Python-turtle
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
Iterate over a list in Python
Python Classes and Objects
Convert integer to string in Python
Create a Pandas Series from array

07 Feb, 2019
Pandas Series is a one-dimensional labelled array capable of holding any data type (integers, strings, floating point numbers, Python objects, etc.). It has to be remembered that unlike Python lists, a Series will always contain data of the same type.
Let’s see how to create a Pandas Series from the array.
Method #1:Create a series from array without index.
In this case as no index is passed, so by default index will be range(n) where n is array length.
# importing Pandas & numpyimport pandas as pdimport numpy as np  # numpy arraydata = np.array(['a', 'b', 'c', 'd', 'e'])  # creating seriess = pd.Series(data)print(s)
0    a
1    b
2    c
3    d
4    e
dtype: object

 Method #2: Create a series from array with index.
In this case we will pass index as a parameter to the constructor.
# importing Pandas & numpyimport pandas as pdimport numpy as np  # numpy arraydata = np.array(['a', 'b', 'c', 'd', 'e'])  # creating seriess = pd.Series(data, index =[1000, 1001, 1002, 1003, 1004])print(s)
1000    a
1001    b
1002    c
1003    d
1004    e
dtype: object

pandas-series-program
Picked
Python pandas-series
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to read request parameters passed in URL using JSP?

The following URL will pass two values to HelloForm program using the GET method.
href="http://localhost:8080/main.jsp?first_name=ZARA&last_name=ALI" 
Below is the main.jsp JSP program to handle input given by web browser. We are going to use the getParameter() method which makes it very easy to access the passed information −
<html>
   <head>
      <title>Using GET Method to Read Form Data</title>
   </head>
   <body>
      <h1>Using GET Method to Read Form Data</h1>
      <ul>
         <li><p><b>First Name:</b>
            <%= request.getParameter("first_name")%>
            </p></li>
         <li><p><b>Last Name:</b>
            <%= request.getParameter("last_name")%>
            </p></li>
      </ul>
   </body>
</html>
Now type href="http://localhost:8080/main.jsp?first_name=ZARA&last_name=ALI" in your browser's Location:box. This will generate the following result −
First Name: ZARA
First Name: ZARA
Last Name: ALI
Last Name: ALI
What is the difference between MySQL DATETIME and TIMESTAMP data type?

Both the data types store data in “YYYY-MM-DD HH:MM:SS” format and include date as well as time. In spite of these similarities they are having the following differences −
Range − Datetime data type supports a date along with time in the range between 1000-01-01 00:00:00 and 9999-12-31 23:59:59. But timestamp data type supports a date along with time in the range between ‘1970-01-01 00:00:01’ to ‘2038-01-19 08:44:07’.
Size − Datetime requires 5 bytes along with 3 additional bytes for fractional seconds’ data storing. On the other hand, timestamp datatype requires 4 bytes along with 3 additional bytes for fractional seconds’ data storing. But before MySQL 5.6.4, DateTime requires 8 bytes along with 3 additional bytes for fractional seconds’ data storing.
Conversion from one timezone to other − Actually in MySQL5+, timestamp value converts from current time to UTC and vice-versa while datetime does not do any conversion.
Indexing − Indexing can be done on timestamp data but datetime data cannot be indexed.
Caching of query − queries having timestamp datatype can be cached but queries having datetime datatype cannot be cached.
Above were some major differences between DATETIME and TIMESTAMP datatype and the following example will demonstrate it −
mysql> Create table test_datetime(time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
Query OK, 0 rows affected (0.44 sec)

mysql> INSERT INTO test_datetime (time) values (CURRENT_TIMESTAMP);
Query OK, 1 row affected (0.04 sec)

mysql> Select * from test_datetime;
+---------------------+
| time                |
+---------------------+
| 2017-11-14 17:29:03 |
+---------------------+
1 row in set (0.00 sec)

mysql> Create table test_timestamp(time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
Query OK, 0 rows affected (0.64 sec)

mysql> INSERT INTO test_timestamp (time) values (CURRENT_TIMESTAMP);
Query OK, 1 row affected (0.06 sec)

mysql> Select * from test_timestamp;
+---------------------+
| time                |
+---------------------+
| 2017-11-14 17:29:50 |
+---------------------+
1 row in set (0.00 sec)
Now, in the following query we have changed the timezone to UTC-05:00 and the result is changed for table having TIMESTAMP datatype.
mysql> SET @@session.time_zone = '-5:00';
Query OK, 0 rows affected (0.00 sec)

mysql> Select * from test_timestamp;
+---------------------+
| time                |
+---------------------+
| 2017-11-14 06:59:50 |
+---------------------+
1 row in set (0.00 sec)
mysql> Select * from test_datetime;
+---------------------+
| time                |
+---------------------+
| 2017-11-14 17:29:03 |
+---------------------+
1 row in set (0.00 sec)
How to start any program using PowerShell?

If you have noticed, you can start notepad and calculator or other standard system utilities with the Windows Run or through the PowerShell console directly by typing just their names, but not the wordpad.exe, word, excel or any other application. It will throw an exception.
For example, just type notepad.exe in PowerShell console and it will open the program but type wordpad.exe there will be an error.
wordpad.exe − The term 'wordpad.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ wordpad.exe
+ ~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (wordpad.exe:String) [],
CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
This is because all the programs run through the command whose paths have stored into an environmental variable.
To check the environmental path variables, use the below command.
$env:Path -split ';'
C:\Program Files (x86)\Intel\iCLS Client\
C:\Program Files\Intel\iCLS Client\
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
C:\Program Files\Intel\Intel(R) Management Engine Components\DAL
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL
C:\Program Files\Intel\Intel(R) Management Engine Components\IPT
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT
C:\Program Files (x86)\Skype\Phone\
C:\Program Files\Intel\WiFi\bin\
C:\Program Files\Common Files\Intel\WirelessCommon\
Programs located under the above path will run directly through the PowerShell console without providing the full path of the application or utility.
Now, to open the Wordpad you need to give the full path of the Wordpad. But when you give full path in the double or single quotation it will consider it as a string and returns the same value without executing the program.
"C:\Program Files\Windows NT\Accessories\wordpad.exe"
To execute the program, you need to use the ampersand (&) sign followed by the full path of the program.
& 'C:\Program Files\Windows NT\Accessories\wordpad.exe'
Another way to execute the program is to browse to that directory and run the program.
cd 'C:\Program Files\Windows NT\Accessories\'
and run the program name.
PS C:\Program Files\Windows NT\Accessories> .\wordpad.exe
So far, we have executed the program with the full pathname. Now we want to execute wordpad.exe, directly from the PowerShell console. To do so, we need to provide the program path to the environmental variable.
$env:Path += ";C:\Program Files\Windows NT\Accessories\"
Now you just need to type wordpad.exe from the PowerShell console and the program will open.
Please Note − Change in the environment variable is temporary. Once you close the
PowerShell console, the newly added environment variable path will be removed. To add this path permanently you need to use the profile script path and it loads every time when PowerShell console starts.
C++ Programs To Create Pyramid and Pattern

There are many different pyramid patterns that can be created in C++. These are mostly created using nested for loops. Some of the pyramids that can be created are as follows.
The code to create a basic pyramid is given as follows.
 Live Demo
#include <iostream>
using namespace std;
int main() {
   int n = 6, i, j;
   for (i=1; i<=n; i++) {
      for(j=1; j<=i; j++ ) {
         cout << "* ";
      }
      cout << endl;
   }
   return 0;
}
*
* *
* * *
* * * *
* * * * *
* * * * * *
In the above program, there are 2 for loops with loop variables i and j. The outer for loop counts the number of pyramid rows and the inner for loop counts the number of stars that are displayed in each row. This is demonstrated using the following code snippet.
for (i=1; i<=n; i++) {
   for(j=1; j<=i; j++ ) {
      cout << "* ";
   }
   cout << endl;
}
The code to create a rotated pyramid is given as follows.
 Live Demo
#include <iostream>
using namespace std;
int main() {
   int n = 6, k = 2*n - 2;
   for (int i=0; i<n; i++) {
      for (int j=0; j<k; j++)
      cout <<" ";
      for (int j=0; j<=i; j++ )
      cout << "* ";
      k = k - 2;
      cout << endl;
   }
   return 0;
}
*
* *
* * *
* * * *
* * * * *
* * * * * *
In the above program, there are two nested loops with loop variables i and j respectively. The value of k is set to 2*n -2. The outer for loop counts the number of pyramid rows. The first inner loop specifies the number of spaces before the stars. The next inner loop specifies the numbers of stars in each row.
This is demonstrated using the following code snippet.
for (int i=0; i<n; i++) {
   for (int j=0; j<k; j++)
   cout <<" ";
   for (int j=0; j<=i; j++ )
   cout << "* ";
   k = k - 2;
   cout << endl;
}
How do I insert multiple values in a column with a single MySQL query?

To insert multiple values in a column, the syntax is as follows −
insert into yourTableName values(yourValue1),(yourValue2),..........N;
To understand the above syntax, let us create a table −
mysql> create table DemoTable2022
   -> (
   -> Department varchar(100)
   -> );
Query OK, 0 rows affected (0.49 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable2022 values('Computer Science'),('Information Technology'),
   ('Civil'),('Mechanical'),('Electronics'),('Electrical');
Query OK, 6 rows affected (0.46 sec)
Records: 6 Duplicates: 0 Warnings: 0
Display all records from the table using select statement −
mysql> select *from DemoTable2022;
This will produce the following output −
+---------------------------+
| Department                |
+---------------------------+
| Computer Science          |
| Information Technology    |
| Civil                     |
| Mechanical                |
| Electronics               |
| Electrical                |
+---------------------------+
6 rows in set (0.00 sec)
What are signed and unsigned keywords in C++?

All number types in C++ can either have a sign or not. For example, you can declare an int to only represent positive integers. Unless otherwise specified, all integer data types are signed data types, i.e. they have values which can be positive or negative. The unsigned keyword can be used to declare variables without signs.
#include<iostream>
using namespace std;

int main() {
   unsigned int i = -1;
   int x = i;
   cout << i << ", " << x;
   return 0;
}
This will give the output −
4294967295, -1
This output is given because it overflows the int by changing all 0 in the bit representation to 1s and max value of int is printed. This is because now the int i doesn't have a sign.  But x has a sign so it'll have the value -1 only.
C++ program to print values of different data types provided as input

Suppose we are given an integer value, a long value, a character value, a float value, and a double value as inputs. We have to print the values that are given to us as input maintaining their precision.
So, if the input is like integer value = 15, long value = 59523256297252, character value = 'y', float value = 367.124, double value = 6464292.312621, then the output will be
15
59523256297252
y
367.124
6464292.31262
To solve this, we will follow these steps −
Print the values given as input in separate lines.
Let us see the following implementation to get better understanding −
#include <iostream>
#include <cstdio>
using namespace std;

void solve(int a, long b, char c, float d, double e) {

   cout << a << endl << b << endl << c << endl << d << endl;
   printf("%.5f", e);
}
int main() {
   solve(15, 59523256297252, 'y', 367.124, 6464292.312621);
   return 0;
}
15, 59523256297252, 'y', 367.124, 6464292.312621
15
59523256297252
y
367.124
6464292.31262
Java Program to Convert Character to String

The toString() method of the Character class converts the character to string. You can use this method to convert the given character to String.
import java.util.Scanner;
public class CharToString {
   public static void main(String args[]){
      System.out.println("Enter a character ::");
      Scanner sc = new Scanner(System.in);
      char ch = sc.next().charAt(0);
      String str = Character.toString(ch);
      System.out.println(str);
   }
}
Enter a character ::
h
h
Perl | grep() Function

20 Jun, 2022
The grep() function in Perl used to extract any element from the given array which evaluates the true value for the given regular expression.
Syntax: grep(Expression, @Array) 
Parameters:
Expression : It is the regular expression which is used to run on each elements of the given array.
@Array : It is the given array on which grep() function is called.
Returns: any element from the given array which evaluates the true value for the given regular expression.
Example 1: 
Perl
#!/usr/bin/perl # Initialising an array of some elements@Array = ('Geeks', 'for', 'Geek'); # Calling the grep() function@A = grep(/^G/, @Array); # Printing the required elements of the arrayprint @A;
Output:
GeeksGeek
In the above code, Regular expression /^G/ is used to get the element starting with ‘G’ from the given array and discard the remaining elements. Example 2: 
Perl
#!/usr/bin/perl # Initialising an array of some elements@Array = ('Geeks', 1, 2, 'Geek', 3, 'For'); # Calling the grep() function@A = grep(/\d/, @Array); # Printing the required elements of the arrayprint @A;
Output :
123
In the above code, Regular expression /^d/ is used to get the integer value from the given array and discard the remaining elements.
 Example 3: 
Perl
#!/usr/bin/perl # Initialising an array of some elements@Array = ('Ram', 'Shyam', 'Rahim', 'Geeta', 'Sheeta'); # Calling the grep() function@A = grep(!/^R/, @Array); # Printing the required elements of the arrayprint @A;
Output :
ShyamGeetaSheeta
In the above code, Regular expression !/^R/ is used to get the elements not starting with ‘R’ and discard the elements which start with ‘R’.
surinderdawra388
Perl-Array-Functions
Perl-Arrays
Perl-function
Perl-regex
Perl
Perl
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Matplotlib.pyplot.ion() in Python

24 Jan, 2022
Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack. One of the greatest benefits of visualization is that it allows us visual access to huge amounts of data in easily digestible visuals. Matplotlib consists of several plots like line, bar, scatter, histogram etc.The matplotlib.pyplot.ion() is used to turn on interactive mode. To check the status of interactive mode one can run the below commands,  
plt.rcParams['interactive']
or, this command 
plt.isinteractive()
Matplotlib also interacts with different backends behind the scene. The workhorse behind rendering charts in matplotlib is its backends. Some interactive backends dynamically update and pop up to users after every change. By default, the interactive mode is turned off.Syntax:  
matplotlib.pyplot.ion()
It accepts no parameters.Example 1:  
Python3
import matplotlib.pyplot as plt  #the function to turn on interactive modeplt.ion() #creating randomly generate collections/datarandom_array = np.arange(-4, 5)collection_1 = random_array ** 2collection_2 = 10 / (random_array ** 2 + 1)figure, axes = plt.subplots() axes.plot(random_array, collection_1,          'rx', random_array,          collection_2, 'b+',          linestyle='solid') axes.fill_between(random_array,                  collection_1,                  collection_2,                  where=collection_2>collection_1,                  interpolate=True,                  color='green', alpha=0.3) lgnd = axes.legend(['collection-1',                    'collection-2'],                   loc='upper center',                   shadow=True) lgnd.get_frame().set_facecolor('#ffb19a')
Output:  
  Example 2:  
Python3
import matplotlib.pyplot as plt plt.ion()plt.plot([1.4, 2.5])plt.title(" Sample interactive plot") axes = plt.gca()axes.plot([3.1, 2.2])
Output:  
 
saurabh1990aror
Python-matplotlib
Python
Write From Home
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
Python String | replace()
How to Install PIP on Windows ?
Convert integer to string in Python
Convert string to integer in Python
How to set input type date in dd-mm-yyyy format using HTML ?
Python infinity
Similarities and Difference between Java and C++