code-rag-bench/online-tutorials huggingface dataset:
How to get Custom circle button in android?

This example demonstrates how to get Custom circle button in 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/actiivity_main.xml.
<?xml version = "1.0" encoding = "utf-8"?>
<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"
   android:id = "@+id/parent"
   xmlns:tools = "http://schemas.android.com/tools"
   android:layout_width = "match_parent"
   android:layout_height = "match_parent"
   tools:context = ".MainActivity"
   android:gravity = "center"
   android:orientation = "vertical">
   <Button
      android:id = "@+id/text"
      android:textSize = "18sp"
      android:textAlignment = "center"
      android:background = "@drawable/round_button"
      android:layout_width = "150dp"
      android:textColor = "#000"
      android:layout_height = "150dp" />
</LinearLayout>
In the above code, we have taken the button with a round_button background. so create round_button.xml in drawable folder and add the following code.
<?xml version = "1.0" encoding = "utf-8"?>
<selector xmlns:android = "http://schemas.android.com/apk/res/android">
   <item android:state_pressed = "false">
      <shape android:shape = "oval">
         <solid android:color = "#ffff00"/>
      </shape>
   </item>
   <item android:state_pressed = "true">
      <shape android:shape = "oval">
         <solid android:color = "#fff000"/>
      </shape>
   </item>
</selector>
In the above code, we have taken two states as pressed on button and release button. when a user clicks on a button it will take the state of the button and provide shape for the button.
Step 3 − Add the following code to src/MainActivity.java
package com.example.andy.myapplication;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
   int view = R.layout.activity_main;
   Button button;
   @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(view);
      button = findViewById(R.id.text);
      button.setText("Button");
   }
}
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 −
In the above result, it shows the default screen, click on a button, it will change the color of a button as shown below -
Click here to download the project code
ed command in Linux with examples - GeeksforGeeks

15 May, 2019
ed command in Linux is used for launching the ed text editor which is a line-based text editor with a minimal interface which makes it less complex for working on text files i.e creating, editing, displaying and manipulating files. It is the oldest editor built in the Unix. It is succeeded by vi and emacs text editor.
Syntax:
ed [options] [file]
ed command without any option: It will launch the ed editor with an empty buffer for us to write, this is similar to the other visual or command line based editor when invoked without a filename. The simplest way to start the ed text editor is by typing “ed” into the terminal.
Example 1:
Here we have not specified the filename so this will create an empty buffer for us to write.
Example 2: To Enter into insert mode press “a” and when you are done writing stop it by “.” (dot).
Example 3: To view, the last line enter “p” into the ed command prompt.
Example 4: To print all the lines that we inserted in the buffer by using “, p”.
Example 5: To save these lines into a file write “f [filename]”.
Example 6: Type “w” in ed command prompt to write the data into the file and see how many bytes are written.
Example 7: The file now has data and we can exit to the terminal by pressing “Q” at ed command prompt.
linux-command
Linux-text-processing-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
scp command in Linux with Examples
nohup Command in Linux with Examples
mv command in Linux with examples
chown command in Linux with Examples
Docker - COPY Instruction
Thread functions in C/C++
nslookup command in Linux with Examples
SED command in Linux | Set 2
Named Pipe or FIFO with example C program
uniq Command in LINUX with examples
What are the transaction isolation levels supported by  JDBC API?

JDBC provides support 5 transaction isolation levels through Connection interface.
TRANSACTION_NONE: It is represented by integer value 0 does not support transactions.
TRANSACTION_NONE: It is represented by integer value 0 does not support transactions.
TRANSACTION_READ_COMMITTED: It is represented by integer value 2 supports transactions allowing Non-Repeatable Reads and, Phantom Reads.
TRANSACTION_READ_COMMITTED: It is represented by integer value 2 supports transactions allowing Non-Repeatable Reads and, Phantom Reads.
TRANSACTION_READ_UNCOMMITTED: It is represented by integer value 1 supports transactions allowing Dirty Reads, Non-Repeatable Reads and, Phantom Reads.
TRANSACTION_READ_UNCOMMITTED: It is represented by integer value 1 supports transactions allowing Dirty Reads, Non-Repeatable Reads and, Phantom Reads.
TRANSACTION_REPEATABLE_READ: It is represented by integer value 4 supports transactions allowing only Phantom Reads.
TRANSACTION_REPEATABLE_READ: It is represented by integer value 4 supports transactions allowing only Phantom Reads.
TRANSACTION_SERIALIZABLE: It is represented by integer value 8 supports transactions with out allowing Dirty Reads, Non-Repeatable Reads and, Phantom Reads.
TRANSACTION_SERIALIZABLE: It is represented by integer value 8 supports transactions with out allowing Dirty Reads, Non-Repeatable Reads and, Phantom Reads.
Following JDBC example displays all the transactions levels provided by the Connection interface of the JDBC API.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class TransactionIsolationLevelExample {
   public static void main(String args[]) throws SQLException {
      //Registering the Driver
      DriverManager.registerDriver(new com.mysql.jdbc.Driver());
      //Getting the connection
      String url = "jdbc:mysql://localhost/mydatabase";
      Connection con = DriverManager.getConnection(url, "root", "password");
      System.out.println("Connection established: "+ con);
      System.out.println("TRANSACTION_NONE: "+Connection.TRANSACTION_NONE);
      System.out.println("TRANSACTION_READ_COMMITTED:"+Connection.TRANSACTION_READ_COMMITTED);
      System.out.println("TRANSACTION_READ_UNCOMMITTED: "+Connection.TRANSACTION_READ_UNCOMMITTED);
      System.out.println("TRANSACTION_REPEATABLE_READ: "+Connection.TRANSACTION_REPEATABLE_READ);
      System.out.println("TRANSACTION_SERIALIZABLE: "+Connection.TRANSACTION_SERIALIZABLE);
   }
}
Connection established: com.mysql.jdbc.JDBC4Connection@6fdb1f78
TRANSACTION_NONE: 0
TRANSACTION_READ_COMMITTED:2
TRANSACTION_READ_UNCOMMITTED: 1
TRANSACTION_REPEATABLE_READ: 4
TRANSACTION_SERIALIZABLE: 8
Swap the objects | Practice | GeeksforGeeks

Classes and objects are one of the most important part of C++. 
Here we will learn to use classes and objects and we'll swap the values of two objects. We'll provide name, number, and height for two objects. 
Input Format:
The first line of input contains T denoting the number of testcases. T testcases follow. Each testcase contains two lines of input. The first line contains values for object1. The second line contains values for object2.
Output Format:
For each testcase, in a new line, print the required output (see example).
Your Task:
Since this is a function problem, you do not need take any input our output . Just complete the provided function  swapper(Person **obj1, Person **obj2)  that is a friend function of class Person. Just swap values of obj1 and obj2.
Constraints:
1 <= T <= 100
1<= |name| <= 100
1 <= number <= 99999
1 <= height <= 10
Example:
Input:
1
Morty 1234 6
Rick 5678 5
Output:
Morty 1234 6 
Rick 5678 5 
Rick 5678 5 
Morty 1234 6
Explanation:
Testcase1: First we print the original values of obj1 and obj2 in two lines. The next two lines contain swapped values of obj1 and obj2.
+2
ja90807 months ago
void swapper(Person **obj1, Person **obj2){   Person *p3 = new Person();   p3 = *obj1;   *obj1 = *obj2;   *obj2 = p3;  }
0
Shapnesh Singh Tiwari8 months ago
Shapnesh Singh Tiwari
https://youtu.be/54MGyb0zw-o
-2
Radhika Gupta9 months ago
Radhika Gupta
C++ solution```void swapper(Person **obj1, Person **obj2){    //Your code here    swap(*obj1, *obj2);}```
0
snas289 months ago
snas28
void swapper(Person **obj1, Person **obj2){    //Your code here   Person *obj3 = *obj1;   *obj1= *obj2;   *obj2= obj3;
}
0
3lit3coder10 months ago
3lit3coder
0
Shubham Kumar1 year ago
Shubham Kumar
void swapper(Person **obj1, Person **obj2){    swap(*obj1 , *obj2);   //Your code here}
0
Debojyoti Sinha1 year ago
Debojyoti Sinha
Correct Answer.Correct AnswerExecution Time:0.01
void swapper(Person **obj1, Person **obj2){    swap(*obj1, *obj2);}
0
Amar Prakash1 year ago
Amar Prakash
void swapper(Person **obj1, Person **obj2){    //Your code here    Person temp = **obj1;    **obj1 = **obj2;    **obj2 = temp;
}
0
Grove Street2 years ago
Grove Street
swap(*obj1,*obj2);
0
Purvesh Patil2 years ago
Purvesh Patil
Person *temp;    temp = *obj1;    *obj1 = *obj2;    *obj2 = temp;
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.
How to set the brightness and contrast of an image with JavaScript?

To set the brightness, use the brightness property and for contrast, use the contrast property.
You can try to run the following code to use image filters with JavaScript −
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <p>Click below to change the brightness and contrast of the image.</p>
      <button onclick="display()">Edit Image</button><br><br>
      <img id="myID" src="https://www.tutorialspoint.com/videotutorials/images/tutorial_library_home.jpg"
         alt="Tutorials Library" width="320" height="320">
      <script>
         function display() {
            document.getElementById("myID").style.filter = "brightness(50%)";
            document.getElementById("myID").style.filter = "contrast(50%)";
         }
      </script>
   </body>
</html>
Solidity - Restricted Access

Restricted Access to a Contract is a common practice. By Default, a contract state is read-only unless it is specified as public.
We can restrict who can modify the contract's state or call a contract's functions using modifiers. We will create and use multiple modifiers as explained below −
onlyBy − once used on a function then only the mentioned caller can call this function.
onlyBy − once used on a function then only the mentioned caller can call this function.
onlyAfter − once used on a function then that function can be called after certain time period.
onlyAfter − once used on a function then that function can be called after certain time period.
costs − once used on a function then caller can call this function only if certain value is provided.
costs − once used on a function then caller can call this function only if certain value is provided.
pragma solidity ^0.5.0;

contract Test {
   address public owner = msg.sender;
   uint public creationTime = now;

   modifier onlyBy(address _account) {
      require(
         msg.sender == _account,
         "Sender not authorized."
      );
      _;
   }
   function changeOwner(address _newOwner) public onlyBy(owner) {
      owner = _newOwner;
   }
   modifier onlyAfter(uint _time) {
      require(
         now >= _time,
         "Function called too early."
      );
      _;
   }
   function disown() public onlyBy(owner) onlyAfter(creationTime + 6 weeks) {
      delete owner;
   }
   modifier costs(uint _amount) {
      require(
         msg.value >= _amount,
         "Not enough Ether provided."
      );
      _;
      if (msg.value > _amount)
         msg.sender.transfer(msg.value - _amount);
   }
   function forceOwnerChange(address _newOwner) public payable costs(200 ether) {
      owner = _newOwner;
      if (uint(owner) & 0 == 1) return;        
   }
}

    38 Lectures 
     4.5 hours 

 Abhilash Nelson

    62 Lectures 
     8.5 hours 

 Frahaan Hussain

    31 Lectures 
     3.5 hours 

 Swapnil Kole
 Print
 Add Notes
 Bookmark this page
How to retrieve the Operating system of the Azure VM using PowerShell?

To retrieve the OS details of the Azure VM, we need to use the Get-AzVM command.
Get-AzVM -VMName TestMachine2k16
When you run the above command, it retrieves the VM TestMachine2k16 information and there is an OSType property which shows that if the VM’s OS is Linux or Windows, or any other type.
But when you select the OSType, you won’t get anything. See below.
PS C:\> Get-AzVM -VMName TestMachine2k16 | Select OStype

OStype
------
Because this property is a part of another property and hence can’t be accessed directly. When you expose the full properties of the VM, you will get the StorageProfile, which contains the OS information.
PS C:\> $vm = Get-AzVM -VMName TestMachine2k16
PS C:\> $vm | fl *
Use the below command,
PS C:\> $vm.StorageProfile.ImageReference

Publisher    : MicrosoftWindowsServer
Offer        : WindowsServer
Sku          : 2016-Datacenter
Version      : latest
ExactVersion : 14393.4225.2102030345
Id           :
So here we got both the Server Edition and the version.
PS C:\> $osver = $vm.StorageProfile.ImageReference.Offer + " $($vm.StorageProfile.ImageReference.Sku)"
PS C:\> $osver
WindowsServer 2016-Datacenter
Get Indices of Specified Values of an Array in R Programming - arrayInd() Function - GeeksforGeeks

08 Jun, 2020
arrayInd() function in R Language is used to get the indices of the values passed to the function as argument. This function takes values and the array in which the values are to be searched and returns the indices for each match found.
Syntax: arrayInd(values, dim(x))
Parameters:values: value or vector of values to be searcheddim(x): array to be searchedx: Array name
Example 1:
# R program to illustrate # the use of arrayInd() function  # Creating an arrayx <- array(1:9, dim = c(2, 3)) x  # Creating vector of values to be foundx1 <- c(5, 4, 6)  # Calling arrayInd() functionarrayInd(x1, dim(x))
Output:
     [, 1] [, 2] [, 3]
[1, ]    1    3    5
[2, ]    2    4    6
     [, 1] [, 2]
[1, ]    1    3
[2, ]    2    2
[3, ]    2    3

Example 2:
# R program to illustrate # the use of arrayInd() function  # Creating an arrayx <- array(1:9, dim = c(3, 3)) x  # Extracting values using which() functionx1 <- which(x > 3 & x < 8)  # Calling arrayInd() functionarrayInd(x1, dim(x))
Output:

     [, 1] [, 2] [, 3]
[1, ]    1    4    7
[2, ]    2    5    8
[3, ]    3    6    9
     [, 1] [, 2]
[1, ]    1    2
[2, ]    2    2
[3, ]    3    2
[4, ]    1    3

Here, in tonhte above code, the arrayInd() function returns the indices of all the values which were returned by the which() function.
R Array-Functions
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
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?
Replace Specific Characters in String in R
How to filter R dataframe by multiple conditions?
R - if statement
How to import an Excel File into R ?
Time Series Analysis in R
Tryit Editor v3.7

HTML Input types
Tryit: input type = month
What does the explicit keyword mean in C++?

The explicit keyword in C++ is used to mark constructors to not implicitly convert types. For example, if you have a class Foo −
class Foo {
public:
    Foo(int n); // allocates n bytes to the Foo object
    Foo(const char *p); // initialize object with char *p
};
Now if you try
Foo mystring = 'x';
The char 'x' is implicitly converted to int and then will call the Foo(int) constructor. But this is not what was intended. So to prevent such conditions and make the code less error-prone, define the constructor as explicit −
class Foo {
   public:
      explicit Foo (int n); //allocate n bytes
      Foo(const char *p); // initialize with string p
};
Python - Filter Range Length Tuples - GeeksforGeeks

14 Jan, 2020
Sometimes, while working with records, we might desire to filter records in such a way in which we need to discard records that do not contains exact number of elements required to constitute a record and lie in a range. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using list comprehension + len()In this method, we just iterate through the list and discard the tuples that do not match the matching range length required to constitute the record. The computation of length is done by len().
# Python3 code to demonstrate working of# Filter Range Length Tuples# Using list comprehension + len()  # Initializing listtest_list = [(4, ), (5, 6), (2, 3, 5), (5, 6, 8, 2), (5, 9)]  # printing original listprint("The original list is : " + str(test_list))  # Initializing desired lengths i, j = 2, 3  # Filter Range Length Tuples# Using list comprehension + len()res = [sub for sub in test_list if len(sub) >= i and len(sub) <= j]      # printing resultprint("The tuple list after filtering range records : " + str(res))
The original list is : [(4, ), (5, 6), (2, 3, 5), (5, 6, 8, 2), (5, 9)]
The tuple list after filtering range records : [(5, 6), (2, 3, 5), (5, 9)]

 
Method #2 : Using filter() + lambda + len()The combination of above functions can also be used to perform this particular task. In this, we just use filter() and use lambda function to filter range length records.
# Python3 code to demonstrate working of# Filter Range Length Tuples# Using filter() + lambda + len()  # Initializing listtest_list = [(4, ), (5, 6), (2, 3, 5), (5, 6, 8, 2), (5, 9)]  # printing original listprint("The original list is : " + str(test_list))  # Initializing desired lengths i, j = 2, 3  # Filter Range Length Tuples# Using filter() + lambda + len()res = list(filter(lambda ele: len(ele) >= i and len(ele) <= j, test_list))      # printing resultprint("The tuple list after filtering range records : " + str(res))
The original list is : [(4, ), (5, 6), (2, 3, 5), (5, 6, 8, 2), (5, 9)]
The tuple list after filtering range records : [(5, 6), (2, 3, 5), (5, 9)]

Python list-programs
Python tuple-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
How to Install PIP on Windows ?
Read a file line by line in Python
Different ways to create Pandas Dataframe
Python program to convert a list to string
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
Passing by pointer Vs Passing by Reference in C++

These are simple example of passing by pointer and passing by reference -
 Live Demo
#include <iostream>
using namespace std;
void swap(int* a, int* b) {
   int c = *a;
   *a= *b;
   *b = c;
}
int main() {
   int m = 7, n = 6;
   cout << "Before Swap\n";
   cout << "m = " << m << " n = " << n << "\n";
   swap(&m, &n);
   cout << "After Swap by pass by pointer\n";
   cout << "m = " << m << " n = " << n << "\n";
}
Before Swap
m = 7 n = 6
After Swap by pass by pointer
m = 6 n = 7
 Live Demo
#include <iostream>
using namespace std;
void swap(int& a, int& b) {
   int c = a;
   a= b;
   b = c;
}
int main() {
   int m =7, n = 6;
   cout << "Before Swap\n";
   cout << "m = " << m << " n = " << n << "\n";
   swap(m, n);
   cout << "After Swap by pass by reference\n";
   cout << "m = " << m << " n = " << n << "\n";
}
Before Swap
m = 7 n = 6
After Swap by pass by reference
m = 6 n = 7
So, if we pass parameter to a function either by pass by pointer or pass by reference it will produce the same result. Only difference is that References are used to refer an existing variable in another name whereas pointers are used to store address of variable. It is safe to use reference because it cannot be NULL.
Python - RPC JSON Server

JSON or JavaScript Object Notation is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. The RPC call made based on JSON is able to send data in a much compact and efficient manner than the normal XML based RPC call.
The python module jsonrpclib is able to create a simple JSON based server and client. 
In the below example we create a simple JSON server and create a function in it. This function breaks a bigger list into smaller lists mentioning the length of the argument as well as the argument itself. 
# server program
from jsonrpclib.SimpleJSONRPCServer import SimpleJSONRPCServer

def findlen(*args):

	res = []
	for arg in args:
		try:
			lenval = len(arg)
		except TypeError:
			lenval = None
		res.append((lenval, arg))
	return res

def main():
	server = SimpleJSONRPCServer(('localhost', 1006))
	server.register_function(findlen)
	print("Start server")
	server.serve_forever()
if __name__ == '__main__':  
    main()



# Call by client
from jsonrpclib import Server
def main():
    conn = Server('http://localhost:1006')
    print(conn.findlen(('a','x','d','z'), 11, {'Mt. Abu': 1602, 'Mt. Nanda': 3001,'Mt. Kirubu': 102, 'Mt.Nish': 5710}))
if __name__ == '__main__':
    main()
When we run the above program, we get the following output −
[[4, [u'a', u'x', u'd', u'z']], [None, 11], [4, {u'Mt. Abu': 1602, u'Mt. Kirubu': 102, u'Mt. Nanda': 3001, u'Mt.Nish': 5710}]]


    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
Neo4j Create Constraint - GeeksforGeeks

03 Sep, 2019
The neo4j constraint helps user to nor enter in wrong kind of data. When the constraint is applied and the user by mistake entering the wrong kind of data then it will show an error message. In the neo4j there are two kind of constraint one is uniqueness constraints and other one is property existence constraints.Below is the example of both the constraint with the example:Suppose there is already below database is exist.
CREATE(CPP:Language{id:001, Designer: "Bjarne Stroustrup", YOE: 1985}) 
CREATE(C:Language {id:002, Designer: "Dennis Ritchie", YOE: 1972}) 
CREATE(Python:Language {id:003, Designer: "Guido van Rossum ", YOE: 1990}) 
CREATE(Java:Language {id:004, Designer: "James Gosling", YOE: 1995}) 
CREATE(CSharp:Language {id:005, Designer: "Microsoft", YOE: 2000})
RETURN CPP, C, Python, Java, CSharp 

Output:
Query:CREATE CONSTRAINT ON(l:Language) ASSERT l.id IS UNIQUEOutput:
CREATE CONSTRAINT ON(l:Language) ASSERT l.id IS UNIQUE
Output:
View the Constraint::schemaOutput:
:schema
Output:
Test the Constraint:Here we will try to add another node into that database with a redundant id value(004).Query:CREATE(Neo4j:Language {id:004, Designer: "Neo4j", YOE: 2012})Output:
CREATE(Neo4j:Language {id:004, Designer: "Neo4j", YOE: 2012})
Output:
Query:CREATE CONSTRAINT ON (label) ASSERT exists(node)Note:Property existence constraints are only available in the Neo4j Enterprise Edition.My Personal Notes
arrow_drop_upSave
CREATE CONSTRAINT ON (label) ASSERT exists(node)
Note:Property existence constraints are only available in the Neo4j Enterprise Edition.
DBMS
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Second Normal Form (2NF)
Introduction of Relational Algebra in DBMS
What is Temporary Table in SQL?
Types of Functional dependencies in DBMS
Difference between Where and Having Clause in SQL
Relational Model in DBMS
Difference between OLAP and OLTP in DBMS
KDD Process in Data Mining
MySQL | Regular expressions (Regexp)
Difference between File System and DBMS
Hive - View and Indexes

This chapter describes how to create and manage views. Views are generated based on user requirements. You can save any result set data as a view. The usage of view in Hive is same as that of the view in SQL. It is a standard RDBMS concept. We can execute all DML operations on a view.
You can create a view at the time of executing a SELECT statement. The syntax is as follows:
CREATE VIEW [IF NOT EXISTS] view_name [(column_name [COMMENT column_comment], ...) ]
[COMMENT table_comment]
AS SELECT ...
Let us take an example for view. Assume employee table as given below, with the fields Id, Name, Salary, Designation, and Dept. Generate a query to retrieve the employee details who earn a salary of more than Rs 30000. We store the result in a view named emp_30000.
+------+--------------+-------------+-------------------+--------+
| ID   | Name         | Salary      | Designation       | Dept   |
+------+--------------+-------------+-------------------+--------+
|1201  | Gopal        | 45000       | Technical manager | TP     |
|1202  | Manisha      | 45000       | Proofreader       | PR     |
|1203  | Masthanvali  | 40000       | Technical writer  | TP     |
|1204  | Krian        | 40000       | Hr Admin          | HR     |
|1205  | Kranthi      | 30000       | Op Admin          | Admin  |
+------+--------------+-------------+-------------------+--------+

The following query retrieves the employee details using the above scenario:
hive> CREATE VIEW emp_30000 AS
SELECT * FROM employee
WHERE salary>30000;

Use the following syntax to drop a view:
DROP VIEW view_name

The following query drops a view named as emp_30000:
hive> DROP VIEW emp_30000;

An Index is nothing but a pointer on a particular column of a table. Creating an index means creating a pointer on a particular column of a table. Its syntax is as follows:
CREATE INDEX index_name
ON TABLE base_table_name (col_name, ...)
AS 'index.handler.class.name'
[WITH DEFERRED REBUILD]
[IDXPROPERTIES (property_name=property_value, ...)]
[IN TABLE index_table_name]
[PARTITIONED BY (col_name, ...)]
[
   [ ROW FORMAT ...] STORED AS ...
   | STORED BY ...
]
[LOCATION hdfs_path]
[TBLPROPERTIES (...)]

Let us take an example for index. Use the same employee table that we have used earlier with the fields Id, Name, Salary, Designation, and Dept. Create an index named index_salary on the salary column of the employee table.
The following query creates an index:
hive> CREATE INDEX inedx_salary ON TABLE employee(salary)
AS 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler';

It is a pointer to the salary column. If the column is modified, the changes are stored using an index value.
The following syntax is used to drop an index:
DROP INDEX <index_name> ON <table_name>

The following query drops an index named index_salary:
hive> DROP INDEX index_salary ON employee;


    50 Lectures 
     4 hours 

 Navdeep Kaur

    67 Lectures 
     4 hours 

 Bigdata Engineer

    109 Lectures 
     2 hours 

 Bigdata Engineer
 Print
 Add Notes
 Bookmark this page
What is Regular Expressions?

Regular expressions are an important notation for defining patterns. Each pattern connects a set of strings. Therefore regular expressions will give as names for sets of strings.
It supports an appropriate and useful notation for describing tokens. Regular Expressions define the language accepted by finite Automata (Transition Diagram).
Regular Expressions are defined over an alphabet ∑.
If R is a Regular Expression, therefore L(R) represents language denoted by the regular expression.
Language − It is a collection of strings over some fixed alphabet. The empty string can be indicated by ε.
Example − If L (Language) = set of strings of 0’s & 1’s of length two
then L = {00, 01, 10, 11}
Example − If L = {1}
then L*=L0∪L1∪L2∪..... Here * can be 0, 1, 2, 3...........
∴ L*={ε}∪{1}∪{11}∪.....
∴ L*={ε,1,11,111,.....}
The various operations on the regular language are as follows −
If L1={00,10} & L2={01,11}
Kleene suggests regular expression in the 1950s with the primary operation for a union, concatenation, and Kleene closure.
There is some notational extension specified that are directly in use −
One or more instance − Unary postfix operator + displays positive closure of a regular expression and its language. It defined that if a is the regular expression, then (a) + indicates the language (L(a) +. There are two algebraic laws r∗ = r+|e and r+ =rr∗ = r∗r relate the positive closure and Kleene closure.
One or more instance − Unary postfix operator + displays positive closure of a regular expression and its language. It defined that if a is the regular expression, then (a) + indicates the language (L(a) +. There are two algebraic laws r∗ = r+|e and r+ =rr∗ = r∗r relate the positive closure and Kleene closure.
Zero or one instance − Unary postfix operator? define zero or one appearance. It define that r? is similar to r|e or L(r?) = L(r) U {e}. This operator has the equal precedence and associativity as * and +./
Zero or one instance − Unary postfix operator? define zero or one appearance. It define that r? is similar to r|e or L(r?) = L(r) U {e}. This operator has the equal precedence and associativity as * and +./
Jupyter QtConsole - Getting Started

In this chapter, let us understand how to get started with QtConsole. This chapter will give you an overview about this software and explains its installation steps.
The Qt console is a GUI application similar to IPython terminal. However, it provides a number of enhancements which are not available in text based IPython terminal. The enhance features are inline figures, multi-line editing with syntax highlighting, graphical calltips, etc. The Qt console can use any Jupyter kernel, default being IPython kernel.
Jupyter QtConsole is a part of Project Jupyter. Anaconda distribution is already having QTconsole application in it. In order to install it individually, use pip command as shown below −
pip3 install qtconsole

You can also use the conda command for this purpose −
conda install qtconsole

You can start Jupyter console from Anaconda navigator. To start it from the command line, you should use the following command, either from the Windows command prompt or Anaconda prompt −
jupyter qtonsole

You get a terminal similar to IPython terminal with first In[] prompt. You can now execute any Python expression exactly like we do in IPython terminal or Jupyter notebook

    22 Lectures 
     49 mins

 Bigdata Engineer
 Print
 Add Notes
 Bookmark this page
ip6tables - Unix, Linux Command

Each chain is a list of rules which can match a set of packets.  Each
rule specifies what to do with a packet that matches.  This is called
a ‘target’, which may be a jump to a user-defined chain in the same
table.




ACCEPT means to let the packet through.
DROP means to drop the packet on the floor.
QUEUE means to pass the packet to userspace.  (How the packet can be received
by a userspace process differs by the particular queue handler.  2.4.x
and 2.6.x kernels up to 2.6.13 include the
 ip_queue
queue handler.  Kernels 2.6.14 and later additionally include the
 nfnetlink_queue
queue handler.  Packets with a target of QUEUE will be sent to queue number ’0’
in this case. Please also see the
 NFQUEUE
target as described later in this man page.)
RETURN means stop traversing this chain and resume at the next rule in the
previous (calling) chain.  If the end of a built-in chain is reached
or a rule in a built-in chain with target
RETURN is matched, the target specified by the chain policy determines the
fate of the packet.


The tables are as follows:

 ip6tables -t mangle -n -L

 ip6tables -L -v


The following are included in the base package, and most of these can
be preceded by a
! to invert the sense of the match.

 ip6tables -p ipv6-icmp -h

 ip6tables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST SYN

 icmp6-no-route 
 no-route 
 icmp6-adm-prohibited 
 adm-prohibited 
 icmp6-addr-unreachable 
 addr-unreach 
 icmp6-port-unreachable 
 port-unreach 




The other main difference is that
-i refers to the input interface;
-o refers to the output interface, and both are available for packets
entering the
FORWARD chain.
There are several other changes in ip6tables.

ip6tables (8)
ip6tables (8)
ip6tables (8)
ip6tables (8)
iptables (8)
iptables (8)
iptables (8)
iptables (8)
iptables (8)
iptables (8)

Marc Boucher made Rusty abandon ipnatctl by lobbying for a generic packet
selection framework in iptables, then wrote the mangle table, the owner match,
the mark stuff, and ran around doing cool stuff everywhere.


James Morris wrote the TOS target, and tos match.


Jozsef Kadlecsik wrote the REJECT target.


Harald Welte wrote the ULOG and NFQUEUE target, the new libiptc, aswell as TTL match+target and libipulog.


The Netfilter Core Team is: Marc Boucher, Martin Josefsson, Jozsef Kadlecsik,
James Morris, Harald Welte and Rusty Russell.


ip6tables man page created by Andras Kis-Szabo, based on
iptables man page written by Herve Eychenne <rv@wallfire.org>.











Advertisements


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
How to define jQuery function ?

19 Feb, 2020
Defining the function in jQuery is different from JavaScript, the syntax is totally different. A function is a set of statements that takes input, do some specific computation and produce output. Basically, a function is a set of statements that performs some specific task or does some computation and then return the result to the user.The idea is to put some commonly or repeatedly done tasks together and make a function so that instead of writing the same code again and again for different inputs, we can call that function.
Syntax:
$.fn.myFunction = function(){}
Below examples illustrate the function definition in jQuery:
Example 1:
<!DOCTYPE html> <html>   <head>     <title>        How to Define jQuery function ?    </title>           <script src="https://code.jquery.com/jquery-1.12.4.min.js">    </script>          <script>        $(document).ready(function() {            $.fn.myFunction = function() {                 document.getElementById("geeks").innerHTML                    = "JQuery function is defined!";            }                          $(".gfg").click(function(){                $.fn.myFunction();            });        });    </script></head>   <body style="text-align:center">       <h1 style="color:green;">         GeeksforGeeks     </h1>           <h3>        Defining function in jQuery    </h3>           <p id="geeks"></p>          <button type="button" class="gfg">        Click    </button></body>   </html>        
Output:
Example 2:
<!DOCTYPE html> <html>   <head>     <title>        How to Define jQuery function ?    </title>           <script src="https://code.jquery.com/jquery-1.12.4.min.js">    </script>          <script>        $(document).ready(function() {            $.fn.myFunction = function() {                 alert('JQuery function is defined!');             }            $(".gfg").click(function(){                $.fn.myFunction();            });        });    </script></head>   <body style="text-align:center;">           <h1 style="color:green;">         GeeksforGeeks     </h1>           <h3>        Defining function in jQuery    </h3>           <button type="button" class="gfg">        Click    </button></body>   </html>       
Output:
jQuery-Misc
JQuery
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Form validation using jQuery
How to Dynamically Add/Remove Table Rows using jQuery ?
jQuery | children() with Examples
Scroll to the top of the page using JavaScript/jQuery
How to get the value in an input text box using jQuery ?
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 fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
GATE | GATE-CS-2015 (Set 2) | Question 65

10 Nov, 2021
Consider a processor with byte-addressable memory. Assume that all registers, including Program Counter (PC) and Program Status Word (PSW), are of size 2 bytes. A stack in the main memory is implemented from memory location (0100)16 and it grows upward. The stack pointer (SP) points to the top element of the stack. The current value of SP is (016E)16. The CALL instruction is of two words, the first word is the op-code and the second word is the starting address of the subroutine (one word = 2 bytes). The CALL instruction is implemented as follows:
   • Store the current value of PC in the stack.
   • Store the value of PSW register in the stack.
   • Load the starting address of the subroutine in PC. 
The content of PC just before the fetch of a CALL instruction is (5FA0)16. After execution of the CALL instruction, the value of the stack pointer isA.(016A)16B.(016C)16C.(0170)16D.(0172)16(A) A(B) B(C) C(D) DAnswer: (D)Explanation:
The current value of SP is (016E)16

The value of SP after following operations is asked 
in question

 • Store the current value of PC in the stack.
This operation increments SP by 2 bytes as size
of PC is given 2 bytes in question.  
So becomes (016E)16 + 2  = (0170)16

• Store the value of PSW register in the stack.
This operation also increments SP by 2 bytes as size
of PSW is also given 2 bytes.
So becomes (0170)16 + 2  = (0172)16

• Load the starting address of the subroutine in PC. 
The Load operation doesn't change SP.

So new value of SP is  (0172)16 
Quiz of this Question
GATE-CS-2015 (Set 2)
GATE-GATE-CS-2015 (Set 2)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE CS 1996 | Question 63
GATE | Gate IT 2005 | Question 52
GATE | GATE-CS-2001 | Question 50
GATE | GATE CS 1997 | Question 50
GATE | GATE CS 2011 | Question 49
GATE | GATE CS 2013 | Question 43
Output of Python Programs | Set 24 (Sets)

29 Dec, 2017
Prerequisite: Python-Sets
1. What is the output of the code shown below?
sets = {1, 2, 3, 4, 4}print(sets)
Options:
{1, 2, 3}{1, 2, 3, 4}{1, 2, 3, 4, 4}Error
{1, 2, 3}
{1, 2, 3, 4}
{1, 2, 3, 4, 4}
Error
Output:
2. {1, 2, 3, 4}

Explanation : Duplicate values are not allowed in sets. Hence, the output of the code shown above will be a set containing the duplicate value only once. Hence output will be {1, 2, 3, 4}.
2. What is the output of the code shown below?
sets = {3, 4, 5}sets.update([1, 2, 3])print(sets)
Options:
{1, 2, 3, 4, 5}{3, 4, 5, 1, 2, 3}{1, 2, 3, 3, 4, 5}Error
{1, 2, 3, 4, 5}
{3, 4, 5, 1, 2, 3}
{1, 2, 3, 3, 4, 5}
Error
Output:
1. {1, 2, 3, 4, 5}

Explanation: The method update adds elements to a set.
3. What is the output of the code shown below?
set1 = {1, 2, 3}set2 = set1.copy()set2.add(4)print(set1)
Options:
{1, 2, 3, 4}{1, 2, 3}Invalid SyntaxError
{1, 2, 3, 4}
{1, 2, 3}
Invalid Syntax
Error
Output:
2. {1, 2, 3}

Explanation: In the above piece of code, set2 is barely a copy and not an alias of set1. Hence any change made in set2 isn’t reflected in set1.
4. What is the output of the code shown below?
set1 = {1, 2, 3}set2 = set1.add(4)print(set2)
Options:
{1, 2, 3, 4}{1, 2, 3}Invalid SyntaxNone
{1, 2, 3, 4}
{1, 2, 3}
Invalid Syntax
None
Output:
4. None

Explanation: add method doesn’t return anything. Hence there will be no output.
5. What is the output of the code shown below?
set1 = {1, 2, 3}set2 = {4, 5, 6}print(len(set1 + set2))
Options:
36UnexpectedError
3
6
Unexpected
Error
Output:
4. Error

Explanation: unsupported operand type(s) for +: ‘set’ and ‘set’.
Python-Output
python-set
Program Output
python-set
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to get column index from column name in Python Pandas?

To get column index from column name in Python Pandas, we can use the get_loc() method.
Create a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.
Print the input DataFrame, df.
Find the columns of DataFrame, using df.columns.
Print the columns from Step 3.
Initialize a variable column_name.
Get the location, i.e., of index for column_name.
Print the index of the column_name.
import pandas as pd

df = pd.DataFrame(
   {
      "x": [5, 2, 7, 0],
      "y": [4, 7, 5, 1],
      "z": [9, 3, 5, 1]
   }
)

print"Input DataFrame 1 is:\n", df
columns = df.columns
print"Columns in the given DataFrame: ", columns

column_name = "z"
column_index = columns.get_loc(column_name)
print"Index of the column ", column_name, " is: ", column_index

column_name = "x"
column_index = columns.get_loc(column_name)
print"Index of the column ", column_name, " is: ", column_index

column_name = "y"
column_index = columns.get_loc(column_name)
print"Index of the column ", column_name, " is: ", column_index
Input DataFrame 1 is:
x y z
0 5 4 9
1 2 7 3
2 7 5 5
3 0 1 1

Columns in the given DataFrame: Index(['x', 'y', 'z'],
dtype='object')

Index of the column z is: 2
Index of the column x is: 0
Index of the column y is: 1
Python – Non-Central Chi-squared Distribution in Statistics

10 Jan, 2020
scipy.stats.ncx2() is a non-central chi-squared continuous random variable. It is inherited from the of generic methods as an instance of the rv_continuous class. It completes the methods with details specific for this particular distribution.
Parameters :
q : lower and upper tail probabilityx : quantilesloc : [optional]location parameter. Default = 0scale : [optional]scale parameter. Default = 1size : [tuple of ints, optional] shape or random variates.moments : [optional] composed of letters [‘mvsk’]; ‘m’ = mean, ‘v’ = variance, ‘s’ = Fisher’s skew and ‘k’ = Fisher’s kurtosis. (default = ‘mv’).
Results : non-central chi-squared continuous random variable
Code #1 : Creating non-central chi-squared continuous random variable
# importing library  from scipy.stats import ncx2      numargs = ncx2.numargs a, b = 4.32, 3.18rv = ncx2(a, b)     print ("RV : \n", rv)  
Output :
RV : 
 scipy.stats._distn_infrastructure.rv_frozen object at 0x000002A9D6E0FE08

Code #2 : non-central chi-squared continuous variates and probability distribution
import numpy as np quantile = np.arange (0.01, 1, 0.1)   # Random Variates R = ncx2.rvs(a, b) print ("Random Variates : \n", R)   # PDF R = ncx2.pdf(a, b, quantile) print ("\nProbability Distribution : \n", R) 
Output :
Random Variates : 
 1.452454339214702

Probability Distribution : 
 [0.10195838 0.10369453 0.10528707 0.1067405  0.10805931 0.1092479
 0.11031066 0.1112519  0.11207589 0.11278684]


Code #3 : Graphical Representation.
import numpy as np import matplotlib.pyplot as plt      distribution = np.linspace(0, np.minimum(rv.dist.b, 3)) print("Distribution : \n", distribution)      plot = plt.plot(distribution, rv.pdf(distribution)) 
Output :
Distribution : 
 [0.         0.04081633 0.08163265 0.12244898 0.16326531 0.20408163
 0.24489796 0.28571429 0.32653061 0.36734694 0.40816327 0.44897959
 0.48979592 0.53061224 0.57142857 0.6122449  0.65306122 0.69387755
 0.73469388 0.7755102  0.81632653 0.85714286 0.89795918 0.93877551
 0.97959184 1.02040816 1.06122449 1.10204082 1.14285714 1.18367347
 1.2244898  1.26530612 1.30612245 1.34693878 1.3877551  1.42857143
 1.46938776 1.51020408 1.55102041 1.59183673 1.63265306 1.67346939
 1.71428571 1.75510204 1.79591837 1.83673469 1.87755102 1.91836735
 1.95918367 2.        ]
 
Code #4 : Varying Positional Arguments
import matplotlib.pyplot as plt import numpy as np      x = np.linspace(0, 5, 100)      # Varying positional arguments y1 = ncx2 .pdf(x, 1, 3) y2 = ncx2 .pdf(x, 1, 4) plt.plot(x, y1, "*", x, y2, "r--") 
Output :
Python scipy-stats-functions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
LISP - Environment Setup

If you are still willing to set up your environment for Lisp programming language, you need the following two softwares available on your computer, (a) Text Editor and (b) The Lisp Executer.
This will be used to type your program. Examples of few editors include Windows Notepad, OS Edit command, Brief, Epsilon, EMACS, and vim or vi.
Name and version of text editor can vary on different operating systems. For example, Notepad will be used on Windows, and vim or vi can be used on windows as well as Linux or UNIX.
The files you create with your editor are called source files and contain program source code. The source files for Lisp programs are typically named with the extension ".lisp".
Before starting your programming, make sure you have one text editor in place and you have enough experience to write a computer program, save it in a file, finally execute it.
The source code written in source file is the human readable source for your program. It needs to be "executed", to turn into machine language so that your CPU can actually execute the program as per instructions given.
This Lisp programming language will be used to execute your source code into final executable program. I assume you have basic knowledge about a programming language.
CLISP is the GNU Common LISP multi-architechtural compiler used for setting up LISP in Windows. The windows version emulates a unix environment using MingW under windows. The installer takes care of this and automatically adds clisp to the windows PATH variable.
You can get the latest CLISP for Windows from here - https://sourceforge.net/projects/clisp/files/latest/download
It creates a shortcut in the Start Menu by default, for the line-by-line interpreter.
During installation, clisp is automatically added to your PATH variable if you select the option (RECOMMENDED)  This means that you can simply open a new Command Prompt window and type “clisp” to bring up the compiler.
To run a *.lisp or *.lsp file, simply use −
Create a Tabular representation of Data in R Programming – table() Function

19 Jun, 2020
table() function in R Language is used to create a categorical representation of data with variable name and the frequency in the form of a table.
Syntax: table(x)
Parameters:x: Object to be converted
Example 1:
# R Program to create # a tabular representation of data  # Creating a vectorvec = c(2, 4, 3, 1, 2, 3, 2, 1, 4, 2)   # Calling table() Functiontable(vec)
Output:
vec
1 2 3 4 
2 4 2 2 

Example 2:
# R Program to create # a tabular representation of data  # Creating a data frame df = data.frame(    "Name" = c("abc", "cde", "def"),    "Gender" = c("Male", "Female", "Male") )      # Calling table() function table(df) 
Output:
     Gender
Name  Female Male
  abc      0    1
  cde      1    0
  def      0    1

R DataFrame-Function
R List-Function
R Matrix-Function
R Object-Function
R Vector-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.