code-rag-bench/online-tutorials huggingface dataset:
Static Single Assignment (with relevant examples) - GeeksforGeeks

06 Oct, 2021
Static Single Assignment was presented in 1988 by Barry K. Rosen, Mark N, Wegman, and F. Kenneth Zadeck. 
In compiler design, Static Single Assignment ( shortened SSA) is a means of structuring the IR (intermediate representation) such that every variable is allotted a value only once and every variable is defined before it’s use. The prime use of SSA is it simplifies and improves the results of compiler optimisation algorithms, simultaneously by simplifying the variable properties. Some Algorithms improved by application of SSA – 
Constant Propagation – Translation of calculations from runtime to compile time. E.g. – the instruction v = 2*7+13 is treated like v = 27Value Range Propagation – Finding the possible range of values a calculation could result in.Dead Code Elimination –Removing the code which is not accessible and will have no effect on results whatsoever.Strength Reduction –Replacing computationally expensive calculations by inexpensive ones.Register Allocation –Optimising the use of registers for calculations.
Constant Propagation – Translation of calculations from runtime to compile time. E.g. – the instruction v = 2*7+13 is treated like v = 27
Value Range Propagation – Finding the possible range of values a calculation could result in.
Dead Code Elimination –Removing the code which is not accessible and will have no effect on results whatsoever.
Strength Reduction –Replacing computationally expensive calculations by inexpensive ones.
Register Allocation –Optimising the use of registers for calculations.
Any code can be converted to SSA form by simply replacing the target variable of each code segment with a new variable and substituting each use of a variable with the new edition of the variable reaching that point. Versions are created by splitting the original variables existing in IR and are represented by original name with a subscript such that every variable gets its own version.
Example #1:
Convert the following code segment to SSA form:
x = y - z
s = x + s
x = s + p
s = z * q
s = x * s
Solution:
x = y - z
s2 = x + s
x2 = s2 + p
s3 = z * q
s4 = x2 * s3
Here x,y,z,s,p,q are original variables and x2, s2, s3, s4 are versions of x and s. 
Example #2:
Convert the following code segment to SSA form:
a = s - b
q = a * e
a = q + d
q = b - c
q = a * q
Solution:
a = s - b
q = a * e
a2 = q + d
q2 = b - c
q3 = a2 * q2
Here a,b,c,d,e,q,s are original variables and a2, q2, q3 are versions of a and q. 
Picked
Compiler Design
GATE CS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Directed Acyclic graph in Compiler Design (with examples)
S - attributed and L - attributed SDTs in Syntax directed translation
Issues in the design of a code generator
Error Handling in Compiler Design
Difference between Top down parsing and Bottom up parsing
Layers of OSI Model
ACID Properties in DBMS
TCP/IP Model
Types of Operating Systems
Normal Forms in DBMS
Class getClassLoader() method in Java with Examples - GeeksforGeeks

27 Jan, 2022
The getClassLoader() method of java.lang.Class class is used to get the classLoader of this entity. This entity can be a class, an array, an interface, etc. The method returns the classLoader of this entity.Syntax:  
public ClassLoader getClassLoader()
Parameter: This method does not accept any parameter.Return Value: This method returns the ClassLoader of the entity.Below programs demonstrate the getClassLoader() method.Example 1: 
Java
// Java program to demonstrate getClassLoader() method public class Test {    public static void main(String[] args)        throws ClassNotFoundException    {         // returns the Class object for this class        Class myClass = Class.forName("Test");         System.out.println("Class represented by myClass: "                           + myClass.toString());         // Get the classLoader of myClass        // using getClassLoader() method        System.out.println("ClassLoader of myClass: "                           + myClass.getClassLoader());    }}
Class represented by myClass: class Test
ClassLoader of myClass: sun.misc.Launcher$AppClassLoader@42a57993
 
Example 2: 
Java
// Java program to demonstrate getClassLoader() method public class Test {     class Arr {    }     public static void main(String[] args)        throws ClassNotFoundException    {        // returns the Class object for Arr        Class arrClass = Arr.class;         // Get the classLoader of arrClass        // using getClassLoader() method        System.out.println("ClassLoader of arrClass: "                           + arrClass.getClassLoader());    }}
ClassLoader of arrClass: sun.misc.Launcher$AppClassLoader@42a57993
 
Reference: https://docs.oracle.com/javase/9/docs/api/java/lang/Class.html#getClassLoader– 
adnanirshad158
Java-Functions
Java-lang package
Java.lang.Class
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Generics in Java
Introduction to Java
Internal Working of HashMap in Java
Comparator Interface in Java with Examples
Strings in Java
Convert numbers into binary representation and add them without carry - GeeksforGeeks

29 Apr, 2021
Given two numbers N and M. The task to convert both the numbers in the binary form then add respective bits of both the binary converted numbers but with a given condition that there is not any carry system in this addition.  
Input: N = 37, M = 12
Output: 41

Input: N = 456, M = 854
Output: 670
 
Approach:  
If we don’t consider carry then the binary addition of two bits will be:  
    1 + 0 = 1
    0 + 1 = 1
    0 + 0 = 0
    1 + 1 = 0 (No carry)
If you observe clearly you will notice that this is just bitwise XOR of two numbers.  
Below is the implementation of the above approach  
C++
Java
Python3
C#
Javascript
// C++ program to add two binary// number without carry#include<bits/stdc++.h>using namespace std; // Function returns sum of both// the binary number without// carryint NoCarrySum(int N, int M){    // XOR of N and M    return N ^ M;}     // Driver codeint main(){    int N = 37;    int M = 12;         cout << NoCarrySum(N, M);    return 0;}
// Java program to add two binary// number without carryimport java.util.*; class GFG{ // Function returns sum of both// the binary number without// carrystatic int NoCarrySum(int N, int M){    // XOR of N and M    return N ^ M;}     // Driver codepublic static void main(String[] args){    int N = 37;    int M = 12;    System.out.print(NoCarrySum(N, M));}} // This code is contributed by amal kumar choubey
# Python3 program to add two binary# number without carry # Function returns sum of both# the binary number without# carrydef NoCarrySum(N, M):     # XOR of N and M    return N ^ M # Driver codeN = 37M = 12print(NoCarrySum(N, M)) # This code is contributed by sayesha
// C# program to add two binary// number without carryusing System; class GFG{ // Function returns sum of both// the binary number without// carrystatic int NoCarrySum(int N, int M){         // XOR of N and M    return N ^ M;}     // Driver codestatic public void Main(String[] args){    int N = 37;    int M = 12;    Console.Write(NoCarrySum(N, M));}} // This code is contributed by Rajput-Ji
<script> // Javascript program to add two binary// number without carry // Function returns sum of both// the binary number without// carryfunction NoCarrySum(N, M){    // XOR of N and M    return N ^ M;}     // Driver code    let N = 37;    let M = 12;         document.write(NoCarrySum(N, M)); </script>
41
 
Amal Kumar Choubey
Rajput-Ji
subhammahato348
Bitwise-XOR
Articles
Bit Magic
Bit Magic
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Time Complexity and Space Complexity
Docker - COPY Instruction
Time complexities of different data structures
Difference between Class and Object
SQL | Date functions
Bitwise Operators in C/C++
Left Shift and Right Shift Operators in C/C++
Travelling Salesman Problem | Set 1 (Naive and Dynamic Programming)
Count set bits in an integer
How to swap two numbers without using a temporary variable?
Add a Pandas series to another Pandas series - GeeksforGeeks

30 Jul, 2020
Let us see how to add a Pandas series to another series in Python. This can be done using 2 ways :
append()
concat()
Method 1 : Using the append() function. It appends one series object at the end of another series object and returns an appended series.
# importing the moduleimport pandas as pd   # create 2 series objectsseries_1 = pd.Series([2, 4, 6, 8])series_2 = pd.Series([10, 12, 14, 16])   # adding series_2 to series_1 using the append() functionseries_1 = series_1.append(series_2, ignore_index = True)  # displaying series_1print(series_1)
Output :
Method 2 : Using the concat() function. It takes a list of series objects that are to be concatenated as an argument and returns a concatenated series.
# importing the moduleimport pandas as pd   # create 2 series objectsseries_1 = pd.Series([2, 4, 6, 8])series_2 = pd.Series([10, 12, 14, 16])   # adding series_2 to series_1 using the concat() functionseries_1 = pd.concat([series_1, series_2])  # displaying series_1print(series_1)
Output :
data mining
data-science
Picked
Python pandas-series-methods
Python
Write From Home
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Enumerate() in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
sum() function in Python
Convert integer to string in Python
Convert string to integer in Python
Python infinity
How to set input type date in dd-mm-yyyy format using HTML ?
Matplotlib.pyplot.title() in Python
How to prepend a string in PHP ?

31 May, 2020
We have given two strings and the task is to prepend a string str1 with another string str2 in PHP. There is no specific function to prepend a string in PHP. In order to do this task, we have the following operators in PHP:
Method 1: Using Concatenation Operator(“.”): The Concatenation operator is used to prepend a string str1 with another string str2 by concatenation of str1 and str2.
Syntax:
$x . $y

Example :
PHP
<?php// PHP program to prepend a string     // Function to prepend a string function prepend_string ($str1, $str2){          // Using concatenation operator (.)    $res = $str1 . $str2;          // Returning the result     return $res;    }  // Given string$str1 = "Geeksforgeeks"; $str2 = "Example";   // Function Call$str = prepend_string ($str1, $str2);   // Printing the resultecho $str; ?>
GeeksforgeeksExample
Method 2: Using Concatenation assignment operator (“.=”): The Concatenation assignment operator is used to prepend a string str1 with another string str2 by appending the str2 to the str1.
Syntax:
$x .= $y

Example :
PHP
<?php// PHP program to prepend a string   // Function to prepend a string function prepend_string ($str1, $str2) {          // Using Concatenation assignment    // operator (.=)    $str1 .= $str2;          // Returning the result     return $str1;}  // Given string$str1 = "Geeksforgeeks"; $str2 = "Example";   // Function call$str = prepend_string ($str1, $str2);   // Printing the resultecho $str; ?>
GeeksforgeeksExample
PHP-string
PHP
PHP Programs
Web Technologies
Web technologies Questions
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to execute PHP code using command line ?
PHP in_array() Function
How to delete an array element based on key in PHP?
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to execute PHP code using command line ?
How to delete an array element based on key in PHP?
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to pop an alert message box using PHP ?
How to get key attribute of parent div when button is clicked in ReactJS ?

07 Apr, 2021
In ReactJs we can pass properties in the child component from the parent component. So, we are going to do the same and pass the key of a parent as a property in the child component.
Creating React Application And Installing Module:
Step 1: Create a React application using the following command:npx create-react-app foldername
Step 1: Create a React application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:cd foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:
cd foldername
Step 3: Create Parent.js and Child.js components.
Project Structure: It will look like the following.
Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
App.js
import React, { Component }  from 'react';  import Parent from './Parent';  class App extends Component {    state = {    key: "GFG",  }    render() {    return (      <div>        <h2>GeeksforGeeks</h2>        <Parent key={this.state.key} keyValue={this.state.key}/>      </div>    );  }}  export default App;
Parent.js
import React, { Component }  from 'react';  import Child from './Child';  class Parent extends Component {    render() {    return (        // Passing key in child        <div>            <h3>(Parent.js) Key = {this.props.keyValue}</h3>            <Child keyValue={this.props.keyValue}/>        </div>    );  }}  export default Parent;
Child.js
import React, { Component }  from 'react';  class Child extends Component {    state = {    key: "",  }    handleClick = () => {    this.setState({key: this.props.keyValue});  }    render() {    return (      <div>        <h3>(Child.js) Key = {this.state.key}</h3>        <button onClick={this.handleClick}>            Get Parent Key        </button>      </div>    );  }    }  export default Child;
Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output.
Picked
React-Questions
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Axios in React: A Guide for Beginners
ReactJS useNavigate() Hook
How to install bootstrap in React.js ?
How to create a multi-page website using React.js ?
How to do crud operations in ReactJS ?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
Differences between Functional Components and Class Components in React
restrict keyword in C

26 Jul, 2021
In the C programming language (after 99 standard), a new keyword is introduced known as restrict.  
restrict keyword is mainly used in pointer declarations as a type qualifier for pointers.
It doesn’t add any new functionality. It is only a way for programmer to inform about an optimization that compiler can make.
When we use restrict with a pointer ptr, it tells the compiler that ptr is the only way to access the object pointed by it, in other words, there’s no other pointer pointing to the same object i.e. restrict keyword specifies that a particular pointer argument does not alias any other and the compiler doesn’t need to add any additional checks.
If a programmer uses restrict keyword and violate the above condition, the result is undefined behavior.
restrict is not supported by C++. It is a C only keyword.
 
C
// C program to use restrict keyword.#include <stdio.h> // Note that the purpose of restrict is to// show only syntax. It doesn't change anything// in output (or logic). It is just a way for// programmer to tell compiler about an// optimizationvoid use(int* a, int* b, int* restrict c){    *a += *c;     // Since c is restrict, compiler will    // not reload value at address c in    // its assembly code. Therefore generated    // assembly code is optimized    *b += *c; } int main(void){    int a = 50, b = 60, c = 70;    use(&a, &b, &c);    printf("%d %d %d", a, b, c);    return 0;}
Output:  
120 130 70
This article is contributed by Bishal Kumar Dubey. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
gauravpathak129
C-Data Types
C-Pointers
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Substring in C++
Multidimensional Arrays in C / C++
Function Pointer in C
Left Shift and Right Shift Operators in C/C++
Different Methods to Reverse a String in C++
std::string class in C++
Unordered Sets in C++ Standard Template Library
rand() and srand() in C/C++
Enumeration (or enum) in C
Memory Layout of C Programs
minsize() method in Tkinter | Python

29 Nov, 2021
In Tkinter, minsize() method is used to set the minimum size of the Tkinter window. Using this method user can set window’s initialized size to its minimum size, and still be able to maximize and scale the window larger.
Syntax:
master.minsize(height, width)
Here, height and width are in pixels.
Code #1: Root window without minimum size that means you can shrink window as much you want.
# importing only  those functions# which are neededfrom tkinter import * from tkinter.ttk import *from time import strftime  # creating tkinter windowroot = Tk()  # Adding widgets to the root windowLabel(root, text = 'GeeksforGeeks',       font =('Verdana', 15)).pack(side = TOP, pady = 10)  Button(root, text = 'Click Me !').pack(side = TOP)  mainloop()
Output:Initial root window without alteration in size
Root window after shrunken down, see the window is completely shrunken because it has no minimum geometry.
Code #2: Root window with minimum size.
# importing only  those functions# which are neededfrom tkinter import * from tkinter.ttk import * from time import strftime  # creating tkinter windowroot = Tk()  # setting the minimum size of the root windowroot.minsize(150, 100)  # Adding widgets to the root windowLabel(root, text = 'GeeksforGeeks',       font =('Verdana', 15)).pack(side = TOP, pady = 10)Button(root, text = 'Click Me !').pack(side = TOP)  mainloop()
Output:Initial window
Expanded window (we can expand window as much as we want because we haven’t set the maximum size of the window).
Window shrunken to it’s minimum size (one cannot shrunk it any further).
nidhi_biet
Python-gui
Python-tkinter
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
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Create a Pandas DataFrame from Lists
Python | os.path.join() method
Python – all() function

15 Aug, 2021
The all() function is an inbuilt function in Python which returns true if all the elements of a given iterable( List, Dictionary, Tuple, set, etc) are True else it returns False. It also returns True if the iterable object is empty.
Syntax: all( iterable ) 
Parameters: Iterable: It is an iterable object such as a dictionary,tuple,list,set,etc.                                  
Example #1: Working of all() with Lists:
Code:
Python3
# All elements of list are truel = [4, 5, 1]print(all(l)) # All elements of list are falsel = [0, 0, False]print(all(l)) # Some elements of list are# true while others are falsel = [1, 0, 6, 7, False]print(all(l)) # Empty Listl = []print(all(l))
Output:
True
False
False
True
Example #2: Working of all() with Tuples.
Python3
# All elements of tuple are truet = (2, 4, 6)print(all(t)) # All elements of tuple are falset = (0, False, False)print(all(t)) # Some elements of tuple# are true while others are falset = (5, 0, 3, 1, False)print(all(t)) # Empty tuplet = ()print(all(t))
Output:
True
False
False
True
Example #3: Working of all() with Sets.
Python3
# All elements of set are trues = {1, 1, 3}print(all(s)) # All elements of set are falses = {0, 0, False}print(all(s)) # Some elements of set# are true while others are falses = {1, 2, 0, 8, False}print(all(s)) # Empty sets = {}print(all(s))
Output:
True
False
False
True
Example #4: Working of all() with Dictionaries.
Note: In the case of a dictionary if all the keys of the dictionary are true or the dictionary is empty the all() returns true else it returns false.
Python3
# All elements of dictionary are trued = {1: "Hello", 2: "Hi"}print(all(d)) # All elements of dictionary are falsed = {0: "Hello", False: "Hi"}print(all(d)) # Some elements of dictionary# are true while others are falsed = {0: "Salut", 1: "Hello", 2: "Hi"}print(all(d)) # Empty dictionaryd = {}print(all(d))
Output:
True
False
False
True
Example #5: Working of all() with Strings.
Python3
# Non-Empty Strings = "Hi There!"print(all(s)) # Non-Empty Strings = "000"print(all(s)) # Empty strings = ""print(all(s))
Output:
True
True
True
dannyjc16
Python-Built-in-functions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Enum with Customized Value in Java

17 Jul, 2018
Prerequisite : enum in Java
By default enums have their own string values, we can also assign some custom values to enums. Consider below example for that.
Examples:
enum  Fruits
{
    APPLE(“RED”), BANANA(“YELLOW”), GRAPES(“GREEN”);
}

In above example we can see that the Fruits enum have three members i.e APPLE, BANANA and GRAPES with have their own different custom values RED, YELLOW and GREEN respectively.
Now to use this enum in code, there are some points we have to follow:-
We have to create parameterized constructor for this enum class. Why? Because as we know that enum class’s object can’t be create explicitly so for initializing we use parameterized constructor. And the constructor cannot be the public or protected it must have private or default modifiers. Why? if we create public or protected, it will allow initializing more than one objects. This is totally against enum concept.We have to create one getter method to get the value of enums.
We have to create parameterized constructor for this enum class. Why? Because as we know that enum class’s object can’t be create explicitly so for initializing we use parameterized constructor. And the constructor cannot be the public or protected it must have private or default modifiers. Why? if we create public or protected, it will allow initializing more than one objects. This is totally against enum concept.
We have to create one getter method to get the value of enums.
// Java program to demonstrate how values can// be assigned to enums.enum TrafficSignal{    // This will call enum constructor with one    // String argument    RED("STOP"), GREEN("GO"), ORANGE("SLOW DOWN");      // declaring private variable for getting values    private String action;      // getter method    public String getAction()    {        return this.action;    }      // enum constructor - cannot be public or protected    private TrafficSignal(String action)    {        this.action = action;    }}  // Driver codepublic class EnumConstructorExample{    public static void main(String args[])    {        // let's print name of each enum and there action        // - Enum values() examples        TrafficSignal[] signals = TrafficSignal.values();          for (TrafficSignal signal : signals)        {            // use getter method to get the value            System.out.println("name : " + signal.name() +                        " action: " + signal.getAction() );        }    }}
Output:
name : RED action: STOP
name : GREEN action: GO 
name : ORANGE action: SLOW DOWN 

This article is contributed by Vihang Shah. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
rss009
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Starting a New Thread in Python

To spawn another thread, you need to call following method available in thread module −
thread.start_new_thread ( function, args[, kwargs] )
This method call enables a fast and efficient way to create new threads in both Linux and Windows.
The method call returns immediately and the child thread starts and calls function with the passed list of args. When function returns, the thread terminates.
Here, args is a tuple of arguments; use an empty tuple to call function without passing any arguments. kwargs is an optional dictionary of keyword arguments.
#!/usr/bin/python
import thread
import time
# Define a function for the thread
def print_time( threadName, delay):
   count = 0
   while count < 5:
      time.sleep(delay)
      count += 1
      print "%s: %s" % ( threadName, time.ctime(time.time()) )
# Create two threads as follows
try:
   thread.start_new_thread( print_time, ("Thread-1", 2, ) )
   thread.start_new_thread( print_time, ("Thread-2", 4, ) )
except:
   print "Error: unable to start thread"
while 1:
   pass
When the above code is executed, it produces the following result −
Thread-1: Thu Jan 22 15:42:17 2009
Thread-1: Thu Jan 22 15:42:19 2009
Thread-2: Thu Jan 22 15:42:19 2009
Thread-1: Thu Jan 22 15:42:21 2009
Thread-2: Thu Jan 22 15:42:23 2009
Thread-1: Thu Jan 22 15:42:23 2009
Thread-1: Thu Jan 22 15:42:25 2009
Thread-2: Thu Jan 22 15:42:27 2009
Thread-2: Thu Jan 22 15:42:31 2009
Thread-2: Thu Jan 22 15:42:35 2009
Although it is very effective for low-level threading, but the thread module is very limited compared to the newer threading module.
How to rotate an Image in ImageView by an angle on Android?

This example demonstrates how do I rotate an image in ImageView by an angle on android.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical"
   android:padding="2dp"
   tools:context=".MainActivity">
   <ImageView
      android:id="@+id/imageView"
      android:layout_width="match_parent"
      android:layout_height="600dp"
      android:layout_gravity="center"
      android:layout_margin="20sp"
      android:src="@drawable/image"/>
   <Button
      android:id="@+id/btnRotate"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerInParent="true"
      android:layout_marginTop="20sp"
      android:text="Rotate View"
      android:textStyle="bold"
      android:layout_marginBottom="10dp"
      android:layout_alignParentBottom="true"/>
</RelativeLayout>
Step 3 − Add the following code to src/MainActivity.java
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
   ImageView imageView;
   Button btnRotate;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      imageView = findViewById(R.id.imageView);
      btnRotate = findViewById(R.id.btnRotate);
      btnRotate.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            imageView.setRotation(90);
         }
      });
   }
}
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="app.com.sample">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen –
Click here to download the project code.
REPLICATE() Function in SQL Server

30 Dec, 2020
REPLICATE() function :This function in SQL Server is used to repeat the specified string for a given number of times.
Features :
This function is used to return the stated string for a given number of times.
This function accepts only strings and integers as parameter.
This function returns an error if the second parameter is not provided.
The repeated strings returned here has no space in between the former and the latter string.
Syntax :
REPLICATE(string, integer)
Parameter :This method accepts two parameter as given below :
string : Specified string to repeat.
integer : Specified number of times for which the string is to be repeated.
Returns :It returns the stated string for a specified number of times.
Example-1 :Getting the stated string for a specified number of times.
SELECT REPLICATE('Geeks for Geeks ', 2);
Output :
Geeks for Geeks Geeks for Geeks
Example-2 :Using REPLICATE() function with a variable and getting the repeated strings for the specified number of times.
DECLARE @string VARCHAR(4);  
SET @string = '123 ';  
SELECT REPLICATE(@string, 4);

Output :
123 123 123 123
Example-3 :Using REPLICATE() function with two variables and getting the repeated strings for the specified number of times.
DECLARE @string VARCHAR(6);  
DECLARE @int INT;  
SET @string = 'Geeks ';  
SET @int = 5;
SELECT REPLICATE(@string, @int);

Output :
Geeks Geeks Geeks Geeks Geeks
Example-4 :Getting the stated string for a specified number of times which is a float value.
SELECT REPLICATE('gfg ', 5.9);
Output :
gfg gfg gfg gfg gfg
Application :This function is used to repeat the specified string for a stated number of times.
DBMS-SQL
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
Window functions in SQL
What is Temporary Table in SQL?
SQL using Python
SQL | Sub queries in From Clause
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
RANK() Function in SQL Server
SQL Query to Convert VARCHAR to INT
SQL Query to Compare Two Dates
SQL Query to Insert Multiple Rows
PDFBox - Reading Text

In the previous chapter, we have seen how to add text to an existing PDF document. In this chapter, we will discuss how to read text from an existing PDF document.
Extracting text is one of the main features of the PDF box library. You can extract text using the getText() method of the PDFTextStripper class. This class extracts all the text from the given PDF document.
Following are the steps to extract text from an existing PDF document.
Load an existing PDF document using the static method load() of the PDDocument class. This method accepts a file object as a parameter, since this is a static method you can invoke it using class name as shown below.
File file = new File("path of the document") 
PDDocument document = PDDocument.load(file);

The PDFTextStripper class provides methods to retrieve text from a PDF document therefore, instantiate this class as shown below.
PDFTextStripper pdfStripper = new PDFTextStripper();

You can read/retrieve the contents of a page from the PDF document using the getText() method of the PDFTextStripper class. To this method you need to pass the document object as a parameter. This method retrieves the text in a given document and returns it in the form of a String object.
String text = pdfStripper.getText(document);

Finally, close the document using the close() method of the PDDocument class as shown below.
document.close();

Suppose, we have a PDF document with some text in it as shown below.
This example demonstrates how to read text from the above mentioned PDF document. Here, we will create a Java program and load a PDF document named new.pdf, which is saved in the path C:/PdfBox_Examples/. Save this code in a file with name ReadingText.java.
import java.io.File;
import java.io.IOException;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
public class ReadingText {

   public static void main(String args[]) throws IOException {

      //Loading an existing document
      File file = new File("C:/PdfBox_Examples/new.pdf");
      PDDocument document = PDDocument.load(file);

      //Instantiate PDFTextStripper class
      PDFTextStripper pdfStripper = new PDFTextStripper();

      //Retrieving text from PDF document
      String text = pdfStripper.getText(document);
      System.out.println(text);

      //Closing the document
      document.close();

   }
}
Compile and execute the saved Java file from the command prompt using the following commands.
javac ReadingText.java 
java ReadingText

Upon execution, the above program retrieves the text from the given PDF document and displays it as shown below.
This is an example of adding text to a page in the pdf document. we can add as many lines
as we want like this using the ShowText() method of the ContentStream class.

 Print
 Add Notes
 Bookmark this page
How to flatten a given array up to the specified depth in JavaScript ? - GeeksforGeeks

08 Apr, 2021
In this article, we will learn how to flatten a given array up to the specified depth in JavaScript.
The flat() method in JavaScript is used to flatten an array up to the required depth. It creates a new array and recursively concatenates the sub-arrays of the original array up to the given depth. The only parameter this method accepts is the optional depth parameter (by default: 1). This method can be also used for removing empty elements from the array.
Syntax:
array.flat(depth);
Example:
HTML
<html>  <body>    <h1 style="color: green;">      GeeksforGeeks    </h1>    <b>      How to flatten a given array up to       the specified depth in JavaScript?    </b>    <script>        // Define the array      let arr = [1, [2, [3, [4, 5], 6], 7, 8], 9, 10];        console.log("Original Array:", arr);        let flatArrOne = arr.flat();        console.log(        "Array flattened to depth of 1:",        flatArrOne      );        let flatArrTwo = arr.flat(2);        console.log(        "Array flattened to depth of 2:",        flatArrTwo      );        let flatArrThree = arr.flat(Infinity);        console.log(        "Array flattened completely:",        flatArrThree      );    </script>  </body></html>
Output:
Original Array: [1, [2, [3, [4, 5], 6], 7, 8], 9, 10]
Array flattened to depth of 1: [1, 2, [3, [4, 5], 6], 7, 8, 9, 10]
Array flattened to depth of 2: [1, 2, 3, [4, 5], 6, 7, 8, 9, 10]
Array flattened completely: [1, [2, [3, [4, 5], 6], 7, 8], 9, 10]
javascript-array
javascript-math
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Convert a string to an integer in JavaScript
How to calculate the number of days between two dates in javascript?
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
File uploading in React.js
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
SQL Tryit Editor v1.6

SELECT * FROM Customers
WHERE City LIKE '%es%';
​
Edit the SQL Statement, and click "Run SQL" to see the result.
This SQL-Statement is not supported in the WebSQL Database.
The example still works, because it uses a modified version of SQL.
Your browser does not support WebSQL.
Your are now using a light-version of the Try-SQL Editor, with a read-only Database.
If you switch to a browser with WebSQL support, you can try any SQL statement, and play with the Database as much as you like. The Database can also be restored at any time.
Our Try-SQL Editor uses WebSQL to demonstrate SQL.
A Database-object is created in your browser, for testing purposes.
You can try any SQL statement, and play with the Database as much as you like. The Database can be restored at any time, simply by clicking the "Restore Database" button.
WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object.
WebSQL is supported in Chrome, Safari, Opera, and Edge(79).
If you use another browser you will still be able to use our Try SQL Editor, but a different version, using a server-based ASP application, with a read-only Access Database, where users are not allowed to make any changes to the data.
Foundation - Centered Columns

Including the class small-centered to column, you can make the column at the center. The large-centered class is used to center the column in large devices. To uncenter the columns in large devices or screen then include large-uncenter class.
The following example demonstrates the use of Centered Columns in Foundation −
<!DOCTYPE html>
<html>
   <head>
      <title>Foundation Template</title>

      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/foundation-sites@6.5.1/dist/css/foundation.min.css" integrity="sha256-1mcRjtAxlSjp6XJBgrBeeCORfBp/ppyX4tsvpQVCcpA= sha384-b5S5X654rX3Wo6z5/hnQ4GBmKuIJKMPwrJXn52ypjztlnDK2w9+9hSMBz/asy9Gw sha512-M1VveR2JGzpgWHb0elGqPTltHK3xbvu3Brgjfg4cg5ZNtyyApxw/45yHYsZ/rCVbfoO5MSZxB241wWq642jLtA==" crossorigin="anonymous">

      <!-- Compressed JavaScript -->
      <script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/vendor/jquery.min.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/foundation-sites@6.5.1/dist/js/foundation.min.js" integrity="sha256-WUKHnLrIrx8dew//IpSEmPN/NT3DGAEmIePQYIEJLLs= sha384-53StQWuVbn6figscdDC3xV00aYCPEz3srBdV/QGSXw3f19og3Tq2wTRe0vJqRTEO sha512-X9O+2f1ty1rzBJOC8AXBnuNUdyJg0m8xMKmbt9I3Vu/UOWmSg5zG+dtnje4wAZrKtkopz/PEDClHZ1LXx5IeOw==" crossorigin="anonymous"></script>
      
   </head>

   <body>
      <h2>Centered Columns</h2>

      <div class = "row">
         <div class = "small-2 small-centered columns" style = "background-color:#8BD6EE;">
            Small centered
         </div>
      </div>

      <div class = "row">
         <div class = "small-4 small-centered columns" style = "background-color:#C0B0F0;">
            Small centered
         </div>
      </div>

      <div class = "row">
         <div class = "small-6 small-centered large-uncentered columns" style = "background-color:#808000;">
            Large uncentered
         </div>
      </div>

      <div class = "row">
         <div class = "small-8 small-centered columns" style = "background-color:#FF6347;">
            Small centered
        </div>
      </div>

      <div class = "row">
         <div class = "small-10 large-centered columns" style = "background-color:#7B68EE;">
            Large centered
         </div>
      </div>

   </body>
</html>
Let us carry out the following steps to see how the above given code works −
Save the above given html code centered_columns.htm file.
Save the above given html code centered_columns.htm file.
Open this HTML file in a browser, an output is displayed as shown below.
Open this HTML file in a browser, an output is displayed as shown below.

    117 Lectures 
     5.5 hours 

 Shakthi Swaroop

    61 Lectures 
     1.5 hours 

 Hans Weemaes

    17 Lectures 
     4 hours 

 Stephen Kahuria

    8 Lectures 
     50 mins

 Zenva

    28 Lectures 
     2 hours 

 Sandra L

    16 Lectures 
     2.5 hours 

 GreyCampus Inc.
 Print
 Add Notes
 Bookmark this page
Playit

This example demonstrates different vertical-aligns.
  
span#mySpan {  background-color:yellow;  vertical-align:baseline;}
Powershell - Read CSV File

Get-Content cmdlet is used to read content of a csv file.
In this example, we're reading content of test.csv.
Get-Content D:\temp\test\test.csv 

You can see following output in PowerShell console.
Mahesh,Suresh,Ramesh


    15 Lectures 
     3.5 hours 

 Fabrice Chrzanowski

    35 Lectures 
     2.5 hours 

 Vijay Saini

    145 Lectures 
     12.5 hours 

 Fettah Ben
 Print
 Add Notes
 Bookmark this page
Find all distinct palindromic sub-strings of a given String in Python

Suppose we have a string with lowercase ASCII characters, we have to find all distinct continuous palindromic substrings of it.
So, if the input is like "bddaaa", then the output will be [a, aa, aaa, b, d, dd]
To solve this, we will follow these steps −
m := a new map
n := size of s
matrix := make two rows of n number of 0s
s := "@" concatenate s concatenate "#"
for j in range 0 to 1, dotemp := 0matrix[j, 0] := 0i := 1while i <= n, dowhile s[i - temp - 1] is same as s[i + j + temp], dotemp := temp + 1matrix[j, i] := tempk := 1while (matrix[j, i - k] is not same as temp - k) and k < temp, domatrix[j,i+k] := minimum of matrix[j, i-k]k := k + 1temp := maximum of temp - k, 0i := i + k
temp := 0
matrix[j, 0] := 0
i := 1
while i <= n, dowhile s[i - temp - 1] is same as s[i + j + temp], dotemp := temp + 1matrix[j, i] := tempk := 1while (matrix[j, i - k] is not same as temp - k) and k < temp, domatrix[j,i+k] := minimum of matrix[j, i-k]k := k + 1temp := maximum of temp - k, 0i := i + k
while s[i - temp - 1] is same as s[i + j + temp], dotemp := temp + 1
temp := temp + 1
matrix[j, i] := temp
k := 1
while (matrix[j, i - k] is not same as temp - k) and k < temp, domatrix[j,i+k] := minimum of matrix[j, i-k]k := k + 1
matrix[j,i+k] := minimum of matrix[j, i-k]
k := k + 1
temp := maximum of temp - k, 0
i := i + k
s := s from index 1 to end
m[s[0]] := 1
for i in range 1 to n, dofor j in range 0 to 1, dofor temp in range, dom[substring of s from (i - temp - 1) to (i - temp - 1 + 2 * temp + j)] = 1m[s[i]] := 1
for j in range 0 to 1, dofor temp in range, dom[substring of s from (i - temp - 1) to (i - temp - 1 + 2 * temp + j)] = 1
for temp in range, dom[substring of s from (i - temp - 1) to (i - temp - 1 + 2 * temp + j)] = 1
m[substring of s from (i - temp - 1) to (i - temp - 1 + 2 * temp + j)] = 1
m[s[i]] := 1
for each i in m, dodisplay i
display i
Let us see the following implementation to get better understanding −
 Live Demo
def find_substr(s):
   m = dict()
   n = len(s)
   matrix = [[0 for x in range(n+1)] for x in range(2)]
   s = "@" + s + "#"
   for j in range(2):
      temp = 0
      matrix[j][0] = 0
      i = 1
      while i <= n:
         while s[i - temp - 1] == s[i + j + temp]:
            temp += 1
         matrix[j][i] = temp
         k = 1
         while (matrix[j][i - k] != temp - k) and (k < temp):
            matrix[j][i+k] = min(matrix[j][i-k], temp - k)
            k += 1
         temp = max(temp - k, 0)
         i += k
   s = s[1:len(s)-1]
   m[s[0]] = 1
   for i in range(1,n):
      for j in range(2):
         for temp in range(matrix[j][i],0,-1):
            m[s[i - temp - 1 : i - temp - 1 + 2 * temp + j]] = 1
      m[s[i]] = 1
   for i in m:
      print (i)
find_substr("bddaaa")
bddaaa
a
aa
b
aaa
d
dd
How to add custom view in alert dialog?

This example demonstrate about How to add custom view in alert dialog
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version = "1.0" encoding = "utf-8"?>
<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"
   android:layout_width = "match_parent"
   android:gravity = "center"
   android:layout_height = "match_parent">
   <TextView
      android:id = "@+id/click"
      android:layout_width = "wrap_content"
      android:textSize = "30sp"
      android:layout_height = "wrap_content"
      android:text = "Click"/>
</LinearLayout>
In the above code, we have taken text view.
Step 3 − Add the following code to src/MainActivity.java
package com.example.myapplication;
import android.annotation.TargetApi;
import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
   TextView text;
   @TargetApi(Build.VERSION_CODES.LOLLIPOP)
   @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      text = findViewById(R.id.click);
      text.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            showAlertDialog();
         }
      });
   }
   private void showAlertDialog() {
      AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this);
      final View customLayout = getLayoutInflater().inflate(R.layout.custom, null);
      alertDialog.setView(customLayout);
      alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
            // send data from the AlertDialog to the Activity
            EditText editText = customLayout.findViewById(R.id.editText);
            Toast.makeText(MainActivity.this,editText.getText().toString(),Toast.LENGTH_LONG).show();
         }
      });
      AlertDialog alert = alertDialog.create();
      alert.setCanceledOnTouchOutside(false);
      alert.show();
   }
}
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen –
Now click on textview to open Alert Dialog.
Now click on ok button to show toast as shown below –
How to create a vertical line with CSS?

To create a vertical line with CSS, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
   .vLine {
      border-left: 6px solid rgb(128, 0, 128);
      height: 500px;
      margin-left: 5%;
   }
</style>
</head>
<body>
<h1>Vertical Line Example<h1>
<div class="vLine"></div>
</body>
</html>
The above code will produce the following output −
How to Line Breaks to JavaScript Alert?

To add line breaks to JavaScript alert, use “\r\n”. In the following example, we will see how to display text in JavaScript alert.
 Live Demo
<html>
   <body>
      <script>
         function DisplayAlert() {
            var newLine = "\r\n"
            var msg = "Showing how to add line break."
            msg += newLine;
            msg += "Line Break can be easily added in JavaScript.";
            msg += newLine;
            msg += "Simply Easy Learning";
            msg+= newLine;
            msg += "TutorialsPoint.com";
            alert(msg);
         }
      </script>
      <input type = "button" value = "Click" onclick = "DisplayAlert()" />
   </body>
</html>