code-rag-bench/online-tutorials huggingface dataset:
Get all MySQL records from the previous day (yesterday)?

To get the records from the previous day, the following is the syntax
select *from yourTableName where date(yourColumnName)= DATE(NOW() - INTERVAL 1 DAY);
To understand the above syntax, let us create a table. The query to create a table is as follows
mysql> create table yesterDayRecordsDemo
   -> (
   -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> ArrivalDateTime datetime
   -> );
Query OK, 0 rows affected (0.44 sec)
Insert some records in the table using insert command.
The query is as follows
mysql> insert into yesterDayRecordsDemo(ArrivalDateTime) values('2014-11-09 13:45:21');
Query OK, 1 row affected (0.11 sec)
mysql> insert into yesterDayRecordsDemo(ArrivalDateTime) values('2017-10-19 11:41:31');
Query OK, 1 row affected (0.15 sec)
mysql> insert into yesterDayRecordsDemo(ArrivalDateTime) values('2019-02-25 10:40:45');
Query OK, 1 row affected (0.14 sec)
mysql> insert into yesterDayRecordsDemo(ArrivalDateTime) values('2019-02-26 12:06:07');
Query OK, 1 row affected (0.15 sec)
mysql> insert into yesterDayRecordsDemo(ArrivalDateTime) values('2019-02-25 12:06:47');
Query OK, 1 row affected (0.19 sec)
mysql> insert into yesterDayRecordsDemo(ArrivalDateTime) values('2019-02-27 11:45:49');
Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement
mysql> select *from yesterDayRecordsDemo;
The following is the output
+----+---------------------+
| Id | ArrivalDateTime     |
+----+---------------------+
| 1  | 2014-11-09 13:45:21 |
| 2  | 2017-10-19 11:41:31 |
| 3  | 2019-02-25 10:40:45 |
| 4  | 2019-02-26 12:06:07 |
| 5  | 2019-02-25 12:06:47 |
| 6  | 2019-02-27 11:45:49 |
+----+---------------------+
6 rows in set (0.00 sec)
Here is the query to get MySQL records from yesterday
mysql> select *from yesterDayRecordsDemo where date(ArrivalDateTime)= DATE(NOW() - INTERVAL 1 DAY);
The following is the output
+----+---------------------+
| Id | ArrivalDateTime     |
+----+---------------------+
| 4  | 2019-02-26 12:06:07 |
+----+---------------------+
1 row in set (0.08 sec)
Basic calculator program using Python

In this program we will see how to accomplish the basic calculator functionalities of a calculator using a python program. Here we create individual functions to carry out the calculations and return the result. Also user input is accepted along with the choice of operator.
# This function performs additiion
def add(a, b):
   return a + b
# This function performs subtraction
def subtract(a, b):
   return a - b
# This function performs multiplication
def multiply(a, b):
   return a * b
# This function performs division
def divide(a, b):
return a / b
print("Select an operation.")
print("+")
print("-")
print("*")
print("/")
# User input
choice = input("Enter operator to use:")
A = int(input("Enter first number: "))
B = int(input("Enter second number: "))
if choice == '+':
   print(A,"+",B,"=", add(A,B))
elif choice == '-':
   print(A,"-",B,"=", subtract(A,B))
elif choice == '*':
   print(A,"*",B,"=", multiply(A,B))
elif choice == '/':
   print(A,"/",B,"=", divide(A,B))
else:
print("Invalid input")
Running the above code gives us the following result −
Select an operation.
+
-
*
/
Enter operator to use: -
Enter first number: 34
Enter second number: 20
34 - 20 = 14
How to set the day of a date in JavaScript?

Following is the code to set the day of a date in JavaScript −
 Live Demo
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result,.sample {
      font-size: 20px;
      font-weight: 500;
   }
</style>
</head>
<body>
<h1>Setting day of the date in JavaScript</h1>
<div class="sample"></div>
<div style="color: green;" class="result"></div>
<button class="Btn">CLICK HERE</button>
<h3>
Click on the above button to change the day of the above date object
</h3>
<script>
   let sampleEle = document.querySelector('.sample');
   let resEle = document.querySelector(".result");
   let dateObj = new Date();
   sampleEle.innerHTML = dateObj;
   document.querySelector(".Btn").addEventListener("click", () => {
      dateObj.setDate(28)
      resEle.innerHTML = 'Changing day of the date = <br> '+dateObj;
   });
</script>
</body>
</html>
The above code will produce the following output −
On clicking the ‘CLICK HERE’ button −
SQL DELETE Statement

The DELETE statement is used to delete existing records in a table.
Note: Be careful when deleting records in a table! Notice the 
WHERE clause in the 
DELETE statement.
The WHERE clause specifies which record(s) should be deleted. If 
you omit the WHERE clause, all records in the table will be deleted!
Below is a selection from the "Customers" table in the Northwind sample 
database:
The following SQL statement deletes the customer "Alfreds Futterkiste" from 
the "Customers" table:
The "Customers" table will now look like this:
It is possible to delete all rows in a table without deleting the table. This 
means that the table structure, attributes, and indexes will be intact:
The following SQL statement deletes all rows in the "Customers" table, 
without deleting the table:
Delete all the records from the Customers table where the Country value is 'Norway'.
 Customers
 Country = 'Norway';

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

Sizeof operator is one of the most used operators in C language used to compute the size of any data structure or data type that we pass through it. The sizeof operator returns unsigned integer type, and this operator can be applied to primitive and compound data types. We can use sizeof operator directly to data types and know the memory it is taking up −
#include <bits/stdc++.h>
using namespace std;

int main() {
   cout << sizeof(int) << "\n";
   cout << sizeof(char) << "\n";
   cout << sizeof(float) << "\n";
   cout << sizeof(long) << "\n";
   return 0;
}
4
1
4
8
8
By using this functionality, we can know the space any variable of this data type takes up. The output also depends on the compiler as a 16_bit compiler will give a different value for int than a 32_bit compiler.
We can also apply this operation to an expression −
#include <bits/stdc++.h>
using namespace std;

int main() {
   cout << sizeof(int) << "\n";
   cout << sizeof(char) << "\n";
   cout << sizeof(float) << "\n";
   cout << sizeof(double) << "\n";
   cout << sizeof(long) << "\n";
   return 0;
}
4
4
As you can see, the previous value of x was four, and even after the prefix operation, it happens to remain the same. This is all because of the sizeof the operator because this operator is used during the compile-time, so it doesn’t change the value of the expression we applied.
There are various uses of the sizeof operator. Still, it is mainly used to determine a compound data type size like an array, structure, union, etc.
#include <bits/stdc++.h>

using namespace std;

int main() {
   int arr[] = {1, 2, 3, 4, 5}; // the given array

   int size = sizeof(arr) / sizeof(int); // calculating the size of array

   cout << size << "\n"; // outputting the size of given array
}
5
Here firstly, we calculate the size of the whole array or calculate the memory it is taking up. Then we divide that number with the sizeof of the data type; in this program, it is int.
The second most important use case for this operator is allocating a dynamic memory, so we use the sizeof operator when allotting the space.
#include <bits/stdc++.h>

using namespace std;

int main() {
   int* ptr = (int*)malloc(10 * sizeof(int)); // here we allot a memory of 40 bytes
   // the sizeof(int) is 4 and we are allocating 10 blocks
   // i.e. 40 bytes
}
In this article, we are discussing the uses of the sizeof operator and how this works. We also coded different types of its use cases to see the output and discuss it. We implemented the use cases of this operator in C++. We can write the same program in other languages such as C, Java, Python, etc. We hope you find this article helpful.
How to Calculate Quartiles in R? - GeeksforGeeks

19 Dec, 2021
In this article, we will discuss how to calculate quartiles in the R programming language. 
Quartiles are just special percentiles that occur after a certain percent of data has been covered.
First quartile: Refers to 25th percentile of the data. This depicts that 25% percent of data is under the produced value.
Second quartile: Refers to 50th percentile of the data. This depicts that 50% percent of data is under the produced value. This is also the median of the data.
Third quartile: Refers to the 75th percentile of the data. This predicts that 75% percent of the data is under the produced value.
To obtain the required quartiles, the quantile() function is used.
Syntax: quantile( data, probs)
Parameter:
data: data whose percentiles are to be calculated
probs: percentile value
R
x = c(2,13,5,36,12,50)  res<-quantile(x, probs = c(0,0.25,0.5,0.75,1))res
Output:
   0%   25%   50%   75%  100%  
2.00  6.75 12.50 30.25 50.00 
R
df<-data.frame(x = c(2,13,5,36,12,50),y = c('a','b','c','c','c','b'))  res<-quantile(df$x, probs = c(0,0.25,0.5,0.75,1))res
Output:
  0%   25%   50%   75%  100%  
2.00  6.75 12.50 30.25 50.00 
Picked
R-Statistics
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
How to filter R dataframe by multiple conditions?
How to import an Excel File into R ?
Replace Specific Characters in String in R
R - if statement
Time Series Analysis in R
Java program to delete duplicate characters from a given String

The interface Set does not allow duplicate elements, therefore, create a set object and try to add each element to it using the add() method in case of repetition of elements this method returns false −
If you try to add all the elements of the array to a Set, it accepts only unique elements so, to find duplicate characters in a given string
Convert it into a character array.
Try to insert elements of the above-created array into a hash set using add method.
If the addition is successful this method returns true.
Since Set doesn't allow duplicate elements this method returns 0 when you try to insert duplicate elements
Print those elements
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class DuplicateCharacters {
   public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter the required string value ::");
      String reqString = sc.next();
      char[] myArray = reqString.toCharArray();
      System.out.println("indices of the duplicate characters in the given string :: ");
      Set set = new HashSet();

      for(int i=0; i<myArray.length; i++){
         if(!set.add(myArray[i])){
            System.out.println("Index :: "+i+" character :: "+myArray[i]);
         }
      }
   }
}
Enter the required string value ::
malayalam
indices of the duplicate characters in the given string ::
Index :: 3 character :: a
Index :: 5 character :: a
Index :: 6 character :: l
Index :: 7 character :: a
Index :: 8 character :: m
Program to Add Two Complex Numbers in C

Given are the two complex numbers in the form of a1+ ib1 and a2 + ib2, the task is to add these two complex numbers.
Complex numbers are those numbers which can be expressed in the form of “a+ib” where “a” and “b” are the real numbers and i is the imaginary number which is the solution of the expression x 2 = −1 as no real number satisfies the equation that’s why it is called as imaginary number.
Input 
a1 = 3, b1 = 8
a2 = 5, b2 = 2
Output 
Complex number 1: 3 + i8
Complex number 2: 5 + i2
Sum of the complex numbers: 8 + i10
Explanation 
(3+i8) + (5+i2) = (3+5) + i(8+2) = 8 + i10
Input 
a1 = 5, b1 = 3
a2 = 2, b2 = 2
Output 
Complex number 1: 5 + i3
Complex number 2: 2 + i2
Sum of the complex numbers: 7 + i5
Explanation 
(5+i3) + (2+i2) = (5+2) + i(3+2) = 7 + i5
Declare a struct for storing the real and imaginary numbers.
Declare a struct for storing the real and imaginary numbers.
Take the input and add the real numbers and imaginary numbers of all the complex numbers.
Take the input and add the real numbers and imaginary numbers of all the complex numbers.
Start
Decalre a struct complexnum with following elements
   1. real
   2. img
In function complexnum sumcomplex(complexnum a, complexnum b)
   Step 1→ Declare a signature struct complexnum c
   Step 2→ Set c.real as a.real + b.real
   Step 3→ Set c.img as a.img + b.img
   Step 4→ Return c
In function int main()
   Step 1→ Declare and initialize complexnum a = {1, 2} and b = {4, 5}
   Step 2→ Declare and set complexnum c as sumcomplex(a, b)
   Step 3→ Print the first complex number
   Step 4→ Print the second complex number
   Step 5→ Print the sum of both in c.real, c.img
Stop
#include <stdio.h>
//structure for storing the real and imaginery
//values of complex number
struct complexnum{
   int real, img;
};
complexnum sumcomplex(complexnum a, complexnum b){
   struct complexnum c;
   //Adding up two complex numbers
   c.real = a.real + b.real;
   c.img = a.img + b.img;
   return c;
}
int main(){
   struct complexnum a = {1, 2};
   struct complexnum b = {4, 5};
   struct complexnum c = sumcomplex(a, b);
   printf("Complex number 1: %d + i%d\n", a.real, a.img);
   printf("Complex number 2: %d + i%d\n", b.real, b.img);
   printf("Sum of the complex numbers: %d + i%d\n", c.real, c.img);
   return 0;
}
If run the above code it will generate the following output −
Complex number 1: 1 + i2
Complex number 2: 4 + i5
Sum of the complex numbers: 5 + i7
CSS mask-image Property - GeeksforGeeks

10 Aug, 2021
The mask-image property in CSS is used to set the mask of an image or a text. It is used to form a mask layer for a particular element in CSS.
Syntax:
mask-image: none | <mask-source>
none: No mask layer is set and transparent black layer is set. 
Syntax:
mask-image: none
Example:
In this example, no mask is created.
html
<!DOCTYPE html><html lang="en">    <head>        <meta charset="UTF-8" />        <meta name="viewport"              content="width=device-width,                       initial-scale=1.0" />        <title>Document</title>    </head>    <style>        .container{          background-color: green;          background-repeat: no-repeat;          width: 400px;          height: 400px;          display: flex;          align-items: center;          justify-content: center;        }        .mask{          background:black;          width: 200px;          height: 200px;          -webkit-mask-image: none;        }        .mask h1{          height: 400px;          width: 400px;        }        wrap text h1    </style>    <body>        <div class="container">            <div class="mask"></div>        </div>    </body></html>
Output: 
<mask-source>: Used to give the source of the image url.
Syntax:
mask-image: url();
Example :
The icon is a mask over background color which is black. It can be changed as required.
html
<!DOCTYPE html><html lang="en">    <head>        <meta charset="UTF-8" />        <meta name="viewport"              content="width=device-width,                       initial-scale=1.0" />        <title>Document</title>    </head>    <style>        .container{          background-color: green;          background-repeat: no-repeat;          width: 400px;          height: 400px;          display: flex;          align-items: center;          justify-content: center;        }        .mask{          background:black;          width: 200px;          height: 200px;          -webkit-mask-image: url("https://image.flaticon.com/icons/svg/942/942195.svg");        }        .mask h1{          height: 400px;          width: 400px;        }        wrap text h1    </style>    <body>        <div class="container">            <div class="mask"></div>        </div>    </body></html>
Output:
Browsers supported:
Chrome
Edge
Firefox
Opera
Safari
surindertarika1234
CSS-Properties
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a web page using HTML and CSS
Form validation using jQuery
How to set space between the flexbox ?
Search Bar using HTML, CSS and JavaScript
How to Create Time-Table schedule using HTML ?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
What does 'Space Complexity' mean? - GeeksforGeeks

24 Sep, 2021
Space Complexity: The term Space Complexity is misused for Auxiliary Space at many places. Following are the correct definitions of Auxiliary Space and Space Complexity. 
Auxiliary Space is the extra space or temporary space used by an algorithm. 
Space Complexity of an algorithm is the total space taken by the algorithm with respect to the input size. Space complexity includes both Auxiliary space and space used by input. 
For example, if we want to compare standard sorting algorithms on the basis of space, then Auxiliary Space would be a better criterion than Space Complexity. Merge Sort uses O(n) auxiliary space, Insertion sort, and Heap Sort use O(1) auxiliary space. The space complexity of all these sorting algorithms is O(n) though. 
Space complexity is a parallel concept to time complexity. If we need to create an array of size n, this will require O(n) space. If we create a two-dimensional array of size n*n, this will require O(n2) space.
In recursive calls stack space also counts. 
Example : 
int add (int n){
    if (n <= 0){
        return 0;
    }
    return n + add (n-1);
}

Here each call add a level to the stack :

1.  add(4)
2.    -> add(3)
3.      -> add(2)
4.        -> add(1)
5.          -> add(0)

Each of these calls is added to call stack and takes up actual memory.
So it takes O(n) space.
However, just because you have n calls total doesn’t mean it takes O(n) space.
Look at the below function :
int addSequence (int n){
    int sum = 0;
    for (int i = 0; i < n; i++){
        sum += pairSum(i, i+1);
    }
    return sum;
}

int pairSum(int x, int y){
    return x + y;
}

There will be roughly O(n) calls to pairSum. However, those 
calls do not exist simultaneously on the call stack,
so you only need O(1) space.
Note: It’s necessary to mention that space complexity depends on a variety of things such as the programming language, the compiler, or even the machine running the algorithm.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
tripathipriyanshu1998
hritikrommie
filipprayden
Analysis
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Understanding Time Complexity with Simple Examples
Time Complexity and Space Complexity
Practice Questions on Time Complexity Analysis
Complexity of different operations in Binary tree, Binary Search Tree and AVL tree
Time Complexity of building a heap
Analysis of different sorting techniques
NP-Completeness | Set 1 (Introduction)
Analysis of Algorithms | Big-O analysis
Difference between Big Oh, Big Omega and Big Theta
Python program to check if the given number is a Disarium Number

When it is required to check if a given nmber is a disarium number, the sum of digits powered to their respective position is computed. Before this, the number of digits present in the number is determined.
A Disarium Number is the one where the sum of its digits to the power of their respective position is equal to the original number itself.
Below is a demonstration for the same −
 Live Demo
def length_calculation(num_val):
   length = 0
   while(num_val != 0):
      length = length + 1
      num_val = num_val//10
   return length
my_num = 192
remaining = sum_val = 0
len_val = length_calculation(my_num)
print("A copy of the original number is being made...")
num_val = my_num
while(my_num > 0):
   remaining = my_num%10
   sum_val = sum_val + int(remaining**len_val)
   my_num = my_num//10
   len_val = len_val - 1
if(sum_val == num_val):
   print(str(num_val) + " is a disarium number !")
else:
   print(str(num_val) + " isn't a disarium number")
A copy of the original number is being made...
192 isn't a disarium number
A method named ‘length_calculation’ is defined, that calculates the number of digits in the number.
It computes the floor division of the number and returns the length of the number.
The number is defined, and is displayed on the console.
It uses the modulus operation to get the remainder, and adds it to a sum variable.
The power of the position is multiplied with the number itself.
This is compared with the number.
If it is equal, it means it is a Harshad number, otherwise it is not.
How do we access command line arguments in Python?

Command line is the place where executable commands are given to operating system. A Python script can be executed by writing its name in front of python executable in the command line.
C:\users\acer>python test.py
If you want some data elements to be passed to Python script for its processing, these elements are written as space delimited values in continuation to name of script. This list of space delimited values are called command line arguments.
C:\users\acer>python test.py Hello TutorialsPoint
Items separated by space are stored in a special List object called argv[]. It is defined in sys module of Python distribution.
In above example, the List object would contain:
sys.argv[]=[‘test.py’, ‘Hello’, ‘TutorialsPoint’]
In the program access these arguments by
import sys
print ("first command line argument: ",sys.argv[1])
 print ("second command line argument: ",sys.argv[2])
Data Structures | Balanced Binary Search Trees | Question 5 - GeeksforGeeks

28 Jun, 2021
Consider the following AVL tree.
         60
      /     \  
    20      100
           /   \
         80    120     

Which of the following is updated AVL tree after insertion of 70
A
        70
      /    \  
    60      100
   /       /    \
 20       80    120 

B
        100
      /    \  
    60      120
   /  \     /  
 20   70   80   


C
        80
      /    \  
    60      100
   /  \       \
 20   70      120

D
        80
      /    \  
    60      100
   /       /   \
 20      70    120  
(A) A(B) B(C) C(D) DAnswer: (C)Explanation: Refer following for steps used in AVL insertion.
AVL Tree | Set 1 (Insertion)
After insertion of 70, tree becomes following
         60
      /     \  
    20      100
           /   \
         80    120     
        /
       70

We start from 50 and travel up. We keep travelling up till we find an unbalanced node. In above case, we reach the node 60 and see 60 got unbalanced after insertion and this is Right Left Case. So we need to apply two rotations
         60                               60                            80
      /     \       Right Rotate(100)  /      \     Left Rotate(60)   /    \
    20      100    -----------------> 20        80 ---------------> 60      100 
           /   \                              /   \                /  \        \
         80    120                          70     100            20   70       120  
        /                                            \    
      70                                             120 

Quiz of this Question
Balanced Binary Search Trees
Data Structures
Data Structures-Balanced Binary Search Trees
Data Structures
Data Structures
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
C program to implement Adjacency Matrix of a given Graph
Advantages and Disadvantages of Linked List
Difference between Singly linked list and Doubly linked list
Introduction to Data Structures | 10 most commonly used Data Structures
FIFO vs LIFO approach in Programming
Multilevel Linked List
Advantages of vector over array in C++
Bit manipulation | Swap Endianness of a number
Difference between data type and data structure
Program to create Custom Vector Class in C++
How to move the horizontal slider right-to-left in Java?

At first, let us create a horizontal slider −
JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 55);
Now, we will set it to move right-to-left using setInverted() −
slider.setInverted(true);
The following is an example to move the horizontal slider right-to-left −
package my;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.WindowConstants;
public class SwingDemo {
   public static void main(String[] args) {
      JFrame frame = new JFrame("Frame with Slider");
      JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 55);
      slider.setInverted(true);
      slider.setMinorTickSpacing(10);
      slider.setMajorTickSpacing(25);
      slider.setPaintTicks(true);
      slider.setPaintLabels(true);
      slider.setBackground(Color.orange);
      slider.setForeground(Color.white);
      Font font = new Font("Serif", Font.BOLD, 20);
      slider.setFont(font);
      JPanel panel = new JPanel();
      panel.add(slider);
      frame.add(panel);
      frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
      frame.setSize(600, 300);
      frame.setVisible(true);
   }
}
What is the usage and purpose of DCLGEN and host variables used in COBOL-DB2 program 

A COBOL-DB2 program can query/update/insert/delete data from multiple DB2 tables. However, in order to achieve this, we must fulfill two main conditions.
Notify the structure of the DB2 table to the COBOL-DB2 program. This includes all the columns and data types of these columns.The respective host variables for each column. The host variables are used in the program logic to move the data from DB2 to program and vice versa. There is one host variable for every table column based on its data type. For example, for a table column with data type CHAR(2), there should be a host variable with equivalent COBOL data type as PIC X(2).
Notify the structure of the DB2 table to the COBOL-DB2 program. This includes all the columns and data types of these columns.
Notify the structure of the DB2 table to the COBOL-DB2 program. This includes all the columns and data types of these columns.
The respective host variables for each column. The host variables are used in the program logic to move the data from DB2 to program and vice versa. There is one host variable for every table column based on its data type. For example, for a table column with data type CHAR(2), there should be a host variable with equivalent COBOL data type as PIC X(2).
The respective host variables for each column. The host variables are used in the program logic to move the data from DB2 to program and vice versa. There is one host variable for every table column based on its data type. For example, for a table column with data type CHAR(2), there should be a host variable with equivalent COBOL data type as PIC X(2).
The DCLGEN utility helps us to generate the table structures and host variables automatically. Using this utility, we just need to give the DB2 table name and it will return
the table structure and the host variables in a PDS member. We can simply use this PDS member in our COBOL-DB2 program in the working storage section using the INCLUDE
statement as below−
EXEC SQL
   INCLUDE ORDERD
END-EXEC
The ORDERD is a PDS member which is generated using a DCLGEN utility. This will have the structure of the ORDERS table and host variables for all the columns. For example,the columns ORDER_ID and ORDER_DATE with data type as CHAR(30) and TIMESTAMP will have a host variable as ORDER-ID PIC X(30) and ORDER-DATE PIC X(26) respectively.If we want to use this host variable to move the data from DB2 to program, then we can have−
EXEC SQL
EXEC SQL
   SELECT ORDER_DATE
      INTO :ORDER-DATE,
      FROM ORDERS
      WHERE ORDER_ID = :ORDER-ID
END-EXEC
END-EXEC
How to change state continuously after a certain amount of time in React? - GeeksforGeeks

01 Sep, 2020
To change a state continuously after a certain amount of time is required in a few cases for the toggling. First, make a function that is responsible for changing the state of the component. Then call the function from the constructor method for the first time.  Use the set interval method inside the function to change the state after a fixed amount of time. setInterval method takes two parameter callback and time. The callback function is called again and again after that given amount of time.  Use the setState method to change the state of the component.
timing(){
  setInterval(() => {
    this.setState({
      stateName : new-state-value
    })
  }, time)
}

Example 1: This example illustrates how to change the state continuously after a certain amount of time.
index.js: 
Javascript
import React from 'react'import ReactDOM from 'react-dom'import App from './App'  ReactDOM.render(<App />, document.querySelector('#root'))
App.js:
Javascript
import React, { Component } from 'react'  class App extends Component {  constructor(props){    super(props)    this.state = {Number : 0}    this.makeTimer()  }    makeTimer(){    setInterval(() => {      let rand = Math.floor(Math.random() * 10) + 1        this.setState({number: rand})    }, 1000)  }  render(){    return (      <div>        <h1>          Random Number :           {this.state.number}        </h1>      </div>    )  }}  export default App
Output: 
react-js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
How to calculate the number of days between two dates in javascript?
How to append HTML code to a div using JavaScript ?
File uploading in React.js
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Convert a string to an integer in JavaScript
How to copy rows from one table to another in MySQL?

For this, use INSERT INTO SELECT statement. Let us first create a table −
mysql> create table DemoTable1879
   (
   Id int,
   Name varchar(20)
   );
Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1879 values(101,'Chris Brown');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1879 values(102,'David Miller');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1879 values(103,'Adam Smith');
Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1879;
This will produce the following output −
+------+--------------+
| Id   | Name         |
+------+--------------+
|  101 | Chris Brown  |
|  102 | David Miller |
|  103 | Adam Smith   |
+------+--------------+
3 rows in set (0.00 sec)
Here is the query to create second table −
mysql> create table DemoTable1880
   (
   ClientId int,
   ClientName varchar(20)
   );
Query OK, 0 rows affected (0.00 sec)
Here is the query to copy rows from one table to another −
mysql> insert into DemoTable1880(ClientId,ClientName) select Id,Name from DemoTable1879 where Id IN(101,103);
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0
Display all records from the table using select statement −
mysql> select * from DemoTable1880;
This will produce the following output −
+----------+-------------+
| ClientId | ClientName  |
+----------+-------------+
|      101 | Chris Brown |
|      103 | Adam Smith  |
+----------+-------------+
2 rows in set (0.00 sec)
How to retrieve XY data from a Matplotlib figure?

To retrieve XY data from a matplotlib figure, we can use get_xdata() and get_ydata() methods.
Create x and y data points using numpy.
Create x and y data points using numpy.
Limit X and Y axes range, using xlim() and ylim() methods.
Limit X and Y axes range, using xlim() and ylim() methods.
Plot xs and ys data points using plot() method with marker=diamond, color=red, and markersize=10, store the returned tuple in a line.
Plot xs and ys data points using plot() method with marker=diamond, color=red, and markersize=10, store the returned tuple in a line.
Use get_xdata() and get_ydata() methods on the line to get xy data.
Use get_xdata() and get_ydata() methods on the line to get xy data.
To display the figure, use show() method.
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
xs = np.random.rand(10)
ys = np.random.rand(10)
plt.xlim(0, 1)
plt.ylim(0, 1)
line, = plt.plot(xs, ys, marker='d', c='red', markersize=10)
xdata = line.get_xdata()
ydata = line.get_ydata()
print("X-data of plot is: {}\nY-data for plot is: {}".format(xdata, ydata))
plt.show()
When we execute the code, it will display a plot and print its XY data on the console.
X-data of plot is: [0.80956382 0.99844606 0.57811592 0.01201992 0.85059459
0.03628843 0.99122502 0.7581602 0.93371784 0.60358098]
Y-data for plot is: [0.65190208 0.27895754 0.46742327 0.79049074 0.36485545
0.80771822 0.9753513 0.91897778 0.17651205 0.7898951 ]
JSON.simple - Encode JSONObject

Using JSON.simple, we can encode a JSON Object using following ways −
Encode a JSON Object - to String − Simple encoding.
Encode a JSON Object - to String − Simple encoding.
Encode a JSON Object - Streaming − Output can be used for streaming.
Encode a JSON Object - Streaming − Output can be used for streaming.
Encode a JSON Object - Using Map − Encoding by preserving the order.
Encode a JSON Object - Using Map − Encoding by preserving the order.
Encode a JSON Object - Using Map and Streaming − Encoding by preserving the order and to stream.
Encode a JSON Object - Using Map and Streaming − Encoding by preserving the order and to stream.
Following example illustrates the above concepts.
import java.io.IOException;
import java.io.StringWriter;
import java.util.LinkedHashMap;
import java.util.Map;

import org.json.simple.JSONObject;
import org.json.simple.JSONValue;

class JsonDemo {
   public static void main(String[] args) throws IOException {
      JSONObject obj = new JSONObject();
      String jsonText;

      obj.put("name", "foo");
      obj.put("num", new Integer(100));
      obj.put("balance", new Double(1000.21));
      obj.put("is_vip", new Boolean(true));
      jsonText = obj.toString();

      System.out.println("Encode a JSON Object - to String");
      System.out.print(jsonText);

      StringWriter out = new StringWriter();
      obj.writeJSONString(out);       
      jsonText = out.toString();

      System.out.println("\nEncode a JSON Object - Streaming");       
      System.out.print(jsonText);

      Map obj1 = new LinkedHashMap();
      obj1.put("name", "foo");
      obj1.put("num", new Integer(100));
      obj1.put("balance", new Double(1000.21));
      obj1.put("is_vip", new Boolean(true));

      jsonText = JSONValue.toJSONString(obj1); 
      System.out.println("\nEncode a JSON Object - Preserving Order");
      System.out.print(jsonText);

      out = new StringWriter();
      JSONValue.writeJSONString(obj1, out); 
      jsonText = out.toString();
      System.out.println("\nEncode a JSON Object - Preserving Order and Stream");
      System.out.print(jsonText);
   }
}
Encode a JSON Object - to String
{"balance":1000.21,"is_vip":true,"num":100,"name":"foo"}
Encode a JSON Object - Streaming
{"balance":1000.21,"is_vip":true,"num":100,"name":"foo"}
Encode a JSON Object - Preserving Order
{"name":"foo","num":100,"balance":1000.21,"is_vip":true}
Encode a JSON Object - Preserving Order and Stream
{"name":"foo","num":100,"balance":1000.21,"is_vip":true}


    20 Lectures 
     1 hours 

 Laurence Svekis

    16 Lectures 
     1 hours 

 Laurence Svekis

    10 Lectures 
     1 hours 

 Laurence Svekis

    23 Lectures 
     2.5 hours 

 Laurence Svekis

    9 Lectures 
     48 mins

 Nilay Mehta

    18 Lectures 
     2.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
How to convert hex string to byte Array in Java?

We can convert a hex string to byte array in Java by first converting the hexadecimal number to integer value using the parseInt() method of the Integer class in java. This will return an integer value which will be the decimal conversion of hexadecimal value. We will then use the toByteArray() method of BigInteger class that will return a byte array.
 Live Demo
import java.math.BigInteger;
public class Demo {
   public static void main(String args[]) {
      String str = "1D08A";
      int it = Integer.parseInt(str, 16);
      System.out.println("Hexadecimal String " + str);
      BigInteger bigInt = BigInteger.valueOf(it);
      byte[] bytearray = (bigInt.toByteArray());
      System.out.print("Byte Array : ");
      for(int i = 0; i < bytearray.length; i++)
      System.out.print(bytearray[i]+ "\t");
   }
}
Hexadecimal String 1D08A
Byte Array : 1 -48 -118
Python Comparison Operators Example

These operators compare the values on either sides of them and decide the relation among them. They are also called Relational operators.
Assume variable a holds 10 and variable b holds 20, then −
Assume variable a holds 10 and variable b holds 20, then −
#!/usr/bin/python

a = 21
b = 10
c = 0

if ( a == b ):
   print "Line 1 - a is equal to b"
else:
   print "Line 1 - a is not equal to b"

if ( a != b ):
   print "Line 2 - a is not equal to b"
else:
   print "Line 2 - a is equal to b"

if ( a <> b ):
   print "Line 3 - a is not equal to b"
else:
   print "Line 3 - a is equal to b"

if ( a < b ):
   print "Line 4 - a is less than b" 
else:
   print "Line 4 - a is not less than b"

if ( a > b ):
   print "Line 5 - a is greater than b"
else:
   print "Line 5 - a is not greater than b"

a = 5;
b = 20;
if ( a <= b ):
   print "Line 6 - a is either less than or equal to  b"
else:
   print "Line 6 - a is neither less than nor equal to  b"

if ( b >= a ):
   print "Line 7 - b is either greater than  or equal to b"
else:
   print "Line 7 - b is neither greater than  nor equal to b"
When you execute the above program it produces the following result −
Line 1 - a is not equal to b
Line 2 - a is not equal to b
Line 3 - a is not equal to b
Line 4 - a is not less than b
Line 5 - a is greater than b
Line 6 - a is either less than or equal to b
Line 7 - b is either greater than or equal to b


    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
Header files “stdio.h” and “stdlib.h” in C

The header file stdio.h stands for Standard Input Output. It has the information related to input/output functions.
Here is the table that displays some of the functions in stdio.h in C language,
Here is an example of stdio.h in C language,
 Live Demo
#include<stdio.h>

int main () {
   char val;

   printf("Enter the character: \n");
   val = getc(stdin);
   printf("Character entered: ");
   putc(val, stdout);

   return(0);
}
Here is the output
Enter the character: s
Character entered: s
The header file stdlib.h stands for Standard Library. It has the information of memory allocation/freeing functions.
Here is the table that displays some of the functions in stdlib.h in C language,
Here is an example of stdlib.h in C language,
 Live Demo
#include <stdio.h>
#include<stdlib.h>

int main() {
   char str1[20] = "53875";
   char str2[20] = "367587938";
   char str3[20] = "53875.8843";

   long int a = atol(str1);
   printf("String to long int : %d\n", a);

   long long int b = atoll(str2);
   printf("String to long long int : %d\n", b);

   double c = atof(str3);
   printf("String to long int : %f\n", c);
   printf("The first random value : %d\n", rand());
   printf("The second random value : %d", rand());

   return 0;
}
Here is the output
String to long int : 53875
String to long long int : 367587938
String to long int : 53875.884300
The first random value : 1804289383
The second random value : 846930886
Matplotlib.pyplot.setp() function in Python

05 Jun, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. There are various plots which can be used in Pyplot are Line Plot, Contour, Histogram, Scatter, 3D Plot, etc.
The setp() function in pyplot module of matplotlib library is used to set the property on an artist object.  
Syntax: matplotlib.pyplot.setp(obj, \*args, \*\*kwargs) 
Parameters: This method accept the following parameters that are described below: 
obj: This parameter is the artist object.
**kwargs: There are different keyword arguments which are accepted.
Returns: This method does not returns any value. 
Below examples illustrate the matplotlib.pyplot.setp() function in matplotlib.pyplot:  
Example 1: 
Python3
#Implementation of matplotlib functionimport numpy as npimport matplotlib.pyplot as plt      def tellme(s):    plt.title(s, fontsize=16)    plt.draw()plt.clf()plt.setp(plt.gca(), autoscale_on=False)   tellme('matplotlib.pyplot.setp() function Example')plt.show()
Output: 
Example 2: 
Python3
# Implementation of matplotlib functionimport matplotlibimport numpy as npimport matplotlib.cm as cmimport matplotlib.pyplot as plt    delta = 0.25x = np.arange(-3.0, 5.0, delta)y = np.arange(-1.3, 2.5, delta)X, Y = np.meshgrid(x, y)Z = (np.exp(-X**2 - Y**2) - np.exp(-(X - 1)**2 - (Y - 1)**2))    im = plt.imshow(Z, interpolation='bilinear',                 origin='lower',                cmap="bone",                extent=(-3, 3, -2, 2))  levels = np.arange(-1.2, 1.6, 0.2)CS = plt.contour(Z, levels,                 origin='lower',                  cmap='Greens',                 linewidths=2,                 extent=(-3, 3, -2, 2))  zc = CS.collections[6]plt.setp(zc, linewidth=2)  plt.clabel(CS, levels,           inline=1,           fmt='%1.1f',           fontsize=14)   plt.title('matplotlib.pyplot.setp() Example')  plt.show()
Output: 
 
Matplotlib Pyplot-class
Python-matplotlib
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
Python OOPs Concepts
Perl | Regular Expressions

30 May, 2019
Regular Expression (Regex or Regexp or RE) in Perl is a special text string for describing a search pattern within a given text. Regex in Perl is linked to the host language and is not the same as in PHP, Python, etc. Sometimes it is termed as “Perl 5 Compatible Regular Expressions“. To use the Regex, Binding operators like ‘=~‘(Regex Operator) and ‘!~‘ (Negated Regex Operator) are used. Before moving to Binding operators let’s have a look at building patterns.
Building Patterns: In Perl, patterns can be constructed using the m// operator. In this operator, the required pattern is simply placed between the two slashes and the binding operators are used to search for the pattern in the specified string.
Using m// and Binding Operators: Mostly the binding operators are used with the m// operator so that required pattern could be matched out. Regex operator is used to match a string with a regular expression. The left-hand side of the statement will contain a string which will be matched with the right-hand side containing the specified pattern. Negated regex operator is used to check if the string is not equal to the regular expression specified on the right-hand side.
Program 1: To illustrate the use of ‘m//’ and ‘=~’ as follows:# Perl program to demonstrate# the m// and =~ operators  # Actual String$a = "GEEKSFORGEEKS";  # Prints match found if # its found in $aif ($a =~ m[GEEKS]) {    print "Match Found\n";}  # Prints match not found # if its not found in $aelse {    print "Match Not Found\n";}Output:Match Found

# Perl program to demonstrate# the m// and =~ operators  # Actual String$a = "GEEKSFORGEEKS";  # Prints match found if # its found in $aif ($a =~ m[GEEKS]) {    print "Match Found\n";}  # Prints match not found # if its not found in $aelse {    print "Match Not Found\n";}
Match Found

Program 2: To illustrate the use of ‘m//’ and ‘!~’ as follows:# Perl program to demonstrate# the m// and !~ operators  # Actual String$a = "GEEKSFORGEEKS";  # Prints match found if # its not found in $aif ($a !~ m[GEEKS]) {    print "Match Found\n";}  # Prints match not found # if it is found in $aelse{    print "Match Not Found\n";}Output:Match Not Found

# Perl program to demonstrate# the m// and !~ operators  # Actual String$a = "GEEKSFORGEEKS";  # Prints match found if # its not found in $aif ($a !~ m[GEEKS]) {    print "Match Found\n";}  # Prints match not found # if it is found in $aelse{    print "Match Not Found\n";}
Match Not Found

Uses of Regular Expression:
It can be used to count the number of occurrence of a specified pattern in a string.
It can be used to search for a string which matches the specified pattern.
It can also replace the searched pattern with some other specified string.
Perl-regex
Perl
Perl
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Perl | split() Function
Perl | push() Function
Perl | chomp() Function
Perl | substr() function
Perl | grep() Function
Perl | exists() Function
Perl Tutorial - Learn Perl With Examples
Perl | length() Function
Perl | Subroutines or Functions
Use of print() and say() in Perl
Printing Heart Pattern in C

In this program we will see how to print heart shaped pattern in C. The heart shape pattern will be look like this
Now if we analyze this pattern, we can find different section in this pattern. The base of the heart is an inverted triangle; the upper portion has two different peaks. Between these two peaks there is a gap. To make this pattern we have to manage these parts into our code to print the pattern like this.
 Live Demo
#include<stdio.h>
int main() {
   int a, b, line = 12;
   for (a = line/2; a <= line; a = a+2) { //for the upper part of the heart
      for (b = 1; b < line-a; b = b+2) //create space before the first peak
         printf(" ");
      for (b = 1; b <= a; b++) //print the first peak
         printf("*");
      for (b = 1; b <= line-a; b++) //create space before the first peak
         printf(" ");
      for (b = 1; b <= a-1; b++) //print the second peak
         printf("*");
      printf("\n");
   }
   for (a = line; a >= 0; a--) { //the base of the heart is inverted triangle
      for (b = a; b < line; b++) //generate space before triangle
         printf(" ");
      for (b = 1; b <= ((a * 2) - 1); b++) //print the triangle
         printf("*");
      printf("\n");
   }
}