code-rag-bench/online-tutorials huggingface dataset:
How to include quotes in comma separated column with MySQL?

Let us first create a −
mysql> create table DemoTable1407
   -> (
   -> Name text
   -> );
Query OK, 0 rows affected (0.51 sec)
Insert some records in the table using insert −
mysql> insert into DemoTable1407 values('John,Bob');
Query OK, 1 row affected (0.20 sec)
mysql> insert into DemoTable1407 values('Carol,David,Adam');
Query OK, 1 row affected (0.16 sec)
mysql> insert into DemoTable1407 values('Mike,Sam,Chris');
Query OK, 1 row affected (0.19 sec)
Display all records from the table using select −
mysql> select * from DemoTable1407;
This will produce the following output −
+------------------+
| Name             |
+------------------+
| John,Bob         |
| Carol,David,Adam |
| Mike,Sam,Chris   |
+------------------+
3 rows in set (0.00 sec)
Here is the query to include quotes in comma separated column with MySQL −
mysql> select concat("'", replace(Name, ",", "','"), "'") AS IncludingQuotes from DemoTable1407;
This will produce the following output −
+------------------------+
| IncludingQuotes        |
+------------------------+
| 'John','Bob'           |
| 'Carol','David','Adam' |
| 'Mike','Sam','Chris'   |
+------------------------+
3 rows in set (0.00 sec)
Scala String toUpperCase() method with example

29 Oct, 2019
The toUpperCase() method is utilized to convert all the characters of the stated string to uppercase.
Method Definition: String toUpperCase()
Return Type: It returns the resultant string after converting its all the character to uppercase.
Example: 1#
// Scala program of toUpperCase()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Applying toUpperCase method        val result = "GeeksforGeeks".toUpperCase()                  // Displays output        println(result)          }} 
GEEKSFORGEEKS

Example: 2#
// Scala program of toUpperCase()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Applying toUpperCase method        val result = "nid#!".toUpperCase()                  // Displays output        println(result)          }} 
NID#!

Scala
Scala-Method
Scala-Strings
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Class and Object in Scala
Scala Tutorial – Learn Scala with Step By Step Guide
Scala Lists
Scala String substring() method with example
Scala | Arrays
Operators in Scala
Scala Constructors
Enumeration in Scala
Lambda Expression in Scala
How to Install Scala with VSCode?
How to get the classes of all columns in a dataframe in R ?

16 May, 2021
In this article, we will discuss how to find all the classes of the dataframe in R Programming Language.
There are two methods to find the classes of columns in the dataframe.
Using str() function
Using lapply() function
Method1 : Using str() function
This function will return the class and value of the input data.
Syntax: str(dataframe_name)
Example: R program to create a dataframe and apply str() function.
R
# create vector with integer # elementsa = c(7058, 7059, 7072, 7075)  # create vector with floating# point elementsc = c(98.00, 92.56, 90.00, 95.00)  # pass these vectors as inputs to# the dataframedata = data.frame( id = a, percentage = c)print(data)  # apply str function to get columns # class of the dataframeprint(str(data))
Output:
    id percentage
1 7058      98.00
2 7059      92.56
3 7072      90.00
4 7075      95.00
'data.frame':    4 obs. of  2 variables:
 $ id        : num  7058 7059 7072 7075
 $ percentage: num  98 92.6 90 95
NULL
Method 2: Using lapply() function
lapply() function will result only the class of the dataframe column
Syntax: lapply(data_frame_name,class)
where: data_frame_name is the dataframe.
R program to create the dataframe and use lapply() function to find a class.
R
# create vector with integer # elementsa = c(7058, 7059, 7072, 7075)  # create vector with string elementsb = c("sravan", "jyothika", "harsha", "deepika")  # create vector with floating point# elementsc = c(98.00, 92.56, 90.00, 95.00)  # pass these vectors as inputs to # the dataframedata = data.frame(id = a, names = b, percentage = c)print(data)  # lapply function to get columns class # of the dataframeprint(lapply(data, class))
Output:
    id    names percentage
1 7058   sravan      98.00
2 7059 jyothika      92.56
3 7072   harsha      90.00
4 7075  deepika      95.00
$id
[1] "numeric"

$names
[1] "factor"

$percentage
[1] "numeric"
Picked
R DataFrame-Programs
R-DataFrame
R Language
R Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to sort an array elements in android?

This example demonstrate about How to sort an array elements 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/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:gravity="center"
   android:layout_height="match_parent"
   tools:context=".MainActivity"
   android:orientation="vertical">
   <TextView
      android:id="@+id/text"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"></TextView>
</LinearLayout>
In the above code, we have taken text view to sorted array.
Step 3 − Add the following code to src/MainActivity.java
package com.example.myapplication;

import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {
   TextView text;
   int temp;
   int[] arr = {12, 10, 5, 4, 2, 20, 6, 1, 0, 2};
   ArrayList<String> arrayList;

   @RequiresApi(api = Build.VERSION_CODES.P)
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      text = findViewById(R.id.text);
      for (int i = 0; i < arr.length; i++) {
         for (int j = i + 1; j < arr.length; j++) {
            if (arr[i] > arr[j]) {
               temp = arr[i];
               arr[i] = arr[j];
               arr[j] = temp;
            }
         }
      }
      StringBuffer buff = new StringBuffer();
      for (int i = 0; i < arr.length; i++) {
         buff.append(String.valueOf(arr[i] + " , "));
         Log.d("sai", String.valueOf(arr[i]));
      }
      text.setText(buff);
   }
}
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
TreeSet toString() method in Java with Example

27 Dec, 2018
The toString() method of Java TreeSet is used to return a string representation of the elements of the Collection.
The String representation comprises a set representation of the elements of the Collection in the order they are picked by the iterator closed in square brackets[].This method is used mainly to display collections other than String type(for instance: Object, Integer)in a String Representation.
Syntax:
public String toString()
Parameter The method does not take any parameters.
Return This method returns a String representation of the collection.
Below examples illustrate the toString() method:
Example 1:
// Java program to demonstrate// TreeSet toString() method  import java.util.*;  public class collection {    public static void main(String args[])    {        // Creating an Empty TreeSet        TreeSet<String> abs            = new TreeSet<String>();          // Use add() method        // to add elements to the Collection        abs.add("Welcome");        abs.add("To");        abs.add("Geeks");        abs.add("For");        abs.add("Geeks");          // Using toString() method        System.out.println(abs.toString());    }}
[For, Geeks, To, Welcome]

Example 2:
// Java program to demonstrate// TreeSet toString() method  import java.util.*;  public class collection {    public static void main(String args[])    {        // Creating an Empty TreeSet        TreeSet<Integer> abs            = new TreeSet<Integer>();          // Use add() method        // to add elements to the Collection        abs.add(10);        abs.add(20);        abs.add(30);        abs.add(40);          // Using toString() method        System.out.println(abs.toString());    }}
[10, 20, 30, 40]

Java - util package
Java-Collections
Java-Functions
java-treeset
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
File canExecute() method in Java with Examples

28 Jan, 2019
The canExecute() function is a part of File class in Java. This function determines whether the program can execute the specified file denoted by the abstract pathname. If the file path exists and the application is allowed to execute the file, this method will return true. Else it will return false.
Function signature:
public boolean canExecute()
Syntax:
file.canExecute();
Parameters: This function does not accept any parameter.
Return Value: This function returns a boolean value representing whether the specified file can be executed or not.
Exceptions: This method throws Security Exception if the read access to the file is denied
Below programs illustrates the use of canExecute() function:
Example 1: The file “F:\\program.txt” is an existing file in F: directory and the program is allowed the permission to execute the file.
// Java program to demonstrate// canExecute() method of File class  import java.io.*;  public class solution {      // Driver Code    public static void main(String args[])    {          // Get the file to be executed        File f = new File("F:\\program.txt");          // Check if this file        // can be executed or not        // using canExecute() method        if (f.canExecute()) {              // The file is can be executed            // as true is returned            System.out.println("Executable");        }        else {              // The file is cannot be executed            // as false is returned            System.out.println("Non Executable");        }    }}
Output:
Executable
Example 2: The file “F:\\program1.txt” does not exist we will try to check if the file is executable or not.
// Java program to demonstrate// canExecute() method of File class  import java.io.*;  public class solution {      // Driver Code    public static void main(String args[])    {          // Get the file to be executed        File f = new File("F:\\program1.txt");          // Check if this file        // can be executed or not        // using canExecute() method        if (f.canExecute()) {              // The file is can be executed            // as true is returned            System.out.println("Executable");        }        else {              // The file is cannot be executed            // as false is returned            System.out.println("Non Executable");        }    }}
Output:
Non Executable
Note: The programs might not run in an online IDE. Please use an offline IDE and set the path of the file.
Java-File Class
Java-Functions
Java-IO package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Introduction to Java
Constructors in Java
Exceptions in Java
Generics in Java
Functional Interfaces in Java
Java Programming Examples
Strings in Java
Differences between JDK, JRE and JVM
Abstraction in Java
strings.Fields() Function in Golang With Examples

19 Apr, 2020
strings.Fields() Function in Golang is used to splits the given string around each instance of one or more consecutive white space characters, as defined by unicode.IsSpace, returning a slice of substrings of str or an empty slice if str contains only white space.
Syntax:
func Fields(str string) []string
Returns: A slice of substrings of str or an empty slice if str contains only white space.
Example 1:
// Golang program to illustrate the// strings.Fields() Functionpackage main    import (    "fmt"    "strings")    func main() {                      // String s is split on the basis of white spaces    // and store in a string array    s := "GeeksforGeeks is a computer science portal !"    v := strings.Fields(s)    fmt.Println(v)                // Another example by passing the string as argument    // directly to the Fields() function    v = strings.Fields("I am a software developer, I love coding")    fmt.Println(v)}
Output:
[GeeksforGeeks is a computer science portal !]
[I am a software developer, I love coding]

Example 2:
// Golang program to illustrate the// strings.Fields() Functionpackage main  import (    "fmt"    "strings")  func main() {      // Fields function also splits the string    // on the basis of white spaces and tabs    s := strings.Fields(" I \t love \n to \n code \n all \t day.")    fmt.Println(s)      // Splits into 5 words which have    // newline character in between    s = strings.Fields("I\nam\nlearning\nGo\nlanguage")    fmt.Println(s)}
Output:
[I love to code all day.]
[I am learning Go language]

Golang-String
Picked
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Parse JSON in Golang?
How to iterate over an Array using for loop in Golang?
Structures in Golang
Loops in Go Language
Time Durations in Golang
Strings in Golang
Constants- Go Language
time.Parse() Function in Golang With Examples
Go Variables
Class and Object in Golang
Python – Assigning Key values to list elements from Value list Dictionary

01 Aug, 2020
Given List of elements, map them with keys of matching value from value list.
Input : test_list = [4, 6, 3, 5, 3], test_dict = {“Gfg” : [5, 3, 6], “is” : [8, 4]}Output : [‘is’, ‘Gfg’, ‘Gfg’, ‘Gfg’, ‘Gfg’]Explanation : 4 is present in “is” key, hence mapped in new list.
Input : test_list = [6, 3, 5, 3], test_dict = {“Gfg” : [5, 3, 6], “is” : [18, 14]}Output : [‘Gfg’, ‘Gfg’, ‘Gfg’, ‘Gfg’]Explanation : All elements present in “Gfg” key.
Method #1 : Using list comprehension
This is one of the ways in which this task can be performed. In this, we extract each element of dictionary value list to check list value occurrence, if matched, we assign that key’s value to that index.
Python3
# Python3 code to demonstrate working of # Assigning Key values to list elements from Value list Dictionary# Using list comprehension  # initializing listtest_list = [4, 6, 3, 10, 5, 3]  # printing original listprint("The original list : " + str(test_list))  # initializing dictionary test_dict = {"Gfg" : [5, 3, 6], "is" : [8, 4], "Best" : [10, 11]}  # nested loop inside list comprehension to check each key res = [key for ele in test_list       for key, val in test_dict.items() if ele in val]  # printing result print("The filtered list : " + str(res))
The original list : [4, 6, 3, 10, 5, 3]
The filtered list : ['is', 'Gfg', 'Gfg', 'Best', 'Gfg', 'Gfg']

Method #2 : Using dictionary comprehension + list comprehension
This is yet another way in which this task can be performed.  In this we create inverse dictionary, and map each list value with its key, post that each key is mapped with argument key list elements for matching key value.
Python3
# Python3 code to demonstrate working of # Assigning Key values to list elements from Value list Dictionary# Using dictionary comprehension + list comprehension  # initializing listtest_list = [4, 6, 3, 10, 5, 3]  # printing original listprint("The original list : " + str(test_list))  # initializing dictionary test_dict = {"Gfg" : [5, 3, 6], "is" : [8, 4], "Best" : [10, 11]}  # creating inverse dictionary of elements temp = {j : i for i, k in test_dict.items() for j in k}  # creating end result by mapping elementsres = [temp.get(key) for key in test_list]  # printing result print("The filtered list : " + str(res))
The original list : [4, 6, 3, 10, 5, 3]
The filtered list : ['is', 'Gfg', 'Gfg', 'Best', 'Gfg', 'Gfg']

Python dictionary-programs
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL – Rename Database

22 Feb, 2021
In PostgreSQL, the ALTER DATABASE RENAME TO statement is used to rename a database. The below steps need to be followed while renaming a database: 
Disconnect from the database that you want to rename by connecting to a different database.Terminate all connections, connected to the database to be renamed.Now you can use the ALTER DATABASE statement to rename the database. 
Disconnect from the database that you want to rename by connecting to a different database.
Terminate all connections, connected to the database to be renamed.
Now you can use the ALTER DATABASE statement to rename the database. 
Now let’s look into the below example to see how to rename a database in PostgreSQL. 
Example: 
Step 1: Create a database named “test_db” using the below commands:
CREATE DATABASE test_db;
Step 2: Now to rename the “test_db” database, disconnect from that database using the below command and connect to the Postgres database: 
test_db=# \connect postgres;
Step 3: Use the below query to check all active connections to the “test_db” database: 
SELECT
    *
FROM
    pg_stat_activity
WHERE
    datname = 'test_db';
Step 4: Use the below query to terminate all the connections to the test_db database: 
SELECT
    pg_terminate_backend (pid)
FROM
    pg_stat_activity
WHERE
    datname = 'test_db';
Step 5: Now use the ALTER DATABASE RENAME TO statement to rename the database as “new_test_db”(say) as follows: 
ALTER DATABASE test_db RENAME TO new_test_db; 
RajuKumar19
postgreSQL-managing-database
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Docker - ADD Instruction - GeeksforGeeks

29 Oct, 2020
If you want to extract a TAR file inside a Docker Container or copy files from a URL or local directory, you can specify ADD Instructions inside your Dockerfile. This is different from COPY instruction because COPY instruction only allows you to copy files and directories from the local machine.
In this article, we will see practical examples where you can use ADD instruction to extract a tar file inside your Docker Image.
For this example, we are simply going to create a TAR file of a folder. You can use this command to create a tar file.
tar -zcvf my-tar-folder.tar.gz ~/Desktop/my-tar-folder

After you have your Tar file ready, you can now create a Dockerfile with ADD instruction. 
FROM ubuntu:latest
RUN apt-get -y update
ADD my-tar-folder.tar.gz .

In the above Dockerfile, we have pulled the Ubuntu base Image from Docker Hub and updated the Image using an apt-get update. After that, we have included the ADD instruction to extract the TAR file located inside the same directory as that of the Dockerfile.
After creating the Dockerfile, you can now create the Docker Image using the Docker build command.
sudo docker build -t sample-image .

To confirm whether the image has been successfully built or not, use the Image list command.
sudo docker images

After you have created the Docker Image, you can now run the Docker Container associated with the Docker Image using the Docker Run command.
sudo docker run -it sample-image bash

After you have the bash of the Container running, you can use the list command to list the directories and verify the instruction.
Docker Container
linux
Advanced Computer Subject
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ML | Linear Regression
Decision Tree
Reinforcement learning
Decision Tree Introduction with example
Copying Files to and from Docker Containers
Sed Command in Linux/Unix with examples
AWK command in Unix/Linux with examples
grep command in Unix/Linux
cut command in Linux with examples
cp command in Linux with examples
uint keyword in C# - GeeksforGeeks

22 Jun, 2020
Keywords are the words in a language that are used for some internal process or represent some predefined actions. uint is a keyword that is used to declare a variable which can store an integral type of value (unsigned integer) from the range of 0 to 4,294,967,295. It keyword is an alias of System.UInt32.
uint keyword occupies 4 bytes (32 bits) space in the memory.
Syntax:
uint variable_name = value;
Example:
Input: num: 67

Output: num2: 67
        Size of a uint variable: 4

Input: num = 24680

Output: Type of num1: System.UInt32
        num1: 24680
        Size of a uint variable: 4

Example 1:
// C# program for uint keywordusing System;using System.Text;  class GFG {      static void Main(string[] args)    {        // variable declaration        uint num2 = 67;          // to print value        Console.WriteLine("num2: " + num2);          // to print size        Console.WriteLine("Size of a uint variable: " + sizeof(uint));    }}
Output:
num2: 67
Size of a uint variable: 4

Example 2:
// C# program for uint keywordusing System;using System.Text;  namespace Geeks {  class GFG {      static void Main(string[] args)    {        // variable declaration        uint num1 = 24680;          // to print type of variable        Console.WriteLine("Type of num1: " + num1.GetType());          // to print value        Console.WriteLine("num1: " + num1);          // to print size        Console.WriteLine("Size of a uint variable: " + sizeof(uint));          // to print minimum & maximum value of uint        Console.WriteLine("Min value of uint: " + uint.MinValue);        Console.WriteLine("Max value of uint: " + uint.MaxValue);          // hit ENTER to exit        Console.ReadLine();    }}}
Output:
Type of num1: System.UInt32
num1: 24680
Size of a uint variable: 4
Min value of uint: 0
Max value of uint: 4294967295

Example 3:
// C# program for uint keywordusing System;using System.Text;  class GFG {      static void Main(string[] args)    {        // variable declaration        uint num2 = 4294967297;          // to print type of variable        Console.WriteLine("Type of num2: " + num2.GetType());          // to print value        Console.WriteLine("num2: " + num2);          // to print size        Console.WriteLine("Size of a uint variable: " + sizeof(uint));    }}
Error: When we input wrong integer and also input number beyond the range
Constant value `4294967297′ cannot be converted to a `uint’
CSharp-keyword
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# Dictionary with examples
C# | Delegates
C# | Abstract Classes
Difference between Ref and Out keywords in C#
Extension Method in C#
C# | Replace() Method
C# | String.IndexOf( ) Method | Set - 1
Introduction to .NET Framework
C# | Arrays
HashSet in C# with Examples
Compound Assignment Operators in C++

The compound assignment operators are specified in the form e1 op= e2, where e1 is a modifiable l-value not of const type and e2 is one of the following −
An arithmetic type
A pointer, if op is + or –
The e1 op= e2 form behaves as e1 = e1 op e2, but e1 is evaluated only once.
The following are the compound assignment operators in C++ −
Let's have a look at an example using some of these operators −
#include<iostream>
using namespace std;

int main() {
   int a = 3, b = 2;

   a += b;
   cout << a << endl;

   a -= b;
   cout << a << endl;

   a *= b;
   cout << a << endl;

   a /= b;
   cout << a << endl;

   return 0;
}
This will give the output −
5
3
6
3
Note that Compound assignment to an enumerated type generates an error message. If the left operand is of a pointer type, the right operand must be of a pointer type or it must be a constant expression that evaluates to 0. If the left operand is of an integral type, the right operand must not be of a pointer type.
Find missing elements in List in Python

If we have a list containing numbers, we can check if the numbers are contiguous or not and also find which numbers are missing from a range of numbers considering the highest number as the final value.
We can design a for loop to check for absence of values in a range using the not in operator. Then capture all these values by adding them to a new list which becomes the result set.
 Live Demo
listA = [1,5,6, 7,11,14]

# Original list
print("Given list : ",listA)

# using range and max
res = [ele for ele in range(max(listA) + 1) if ele not in listA]

# Result
print("Missing elements from the list : \n" ,res)
Running the above code gives us the following result −
Given list : [1, 5, 6, 7, 11, 14]
Missing elements from the list :
[0, 2, 3, 4, 8, 9, 10, 12, 13]
We apply the set function to hold all the unique values for a given range and then subtracting the given list from it. So this gives the result set containing the missing values from the contiguous numbers.
 Live Demo
listA = [1,5,6, 7,11,14]

# printing original list
print("Given list : ",listA)

# using set
res = list(set(range(max(listA) + 1)) - set(listA))

# Result
print("Missing elements from the list : \n" ,res)
Running the above code gives us the following result −
Given list : [1, 5, 6, 7, 11, 14]
Missing elements from the list :
[0, 2, 3, 4, 8, 9, 10, 12, 13]
MongoDB $regex operator i or I for case insensitive search

For this, you need to use case insensitive (i). Let us create a collection with documents −
> db.demo759.insertOne({SubjectName:"MySQL"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5eb02ba95637cd592b2a4ae7")
}
> db.demo759.insertOne({SubjectName:"MongoDB"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5eb02baa5637cd592b2a4ae8")
}
> db.demo759.insertOne({SubjectName:"mongodb"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5eb02baf5637cd592b2a4ae9")
}
> db.demo759.insertOne({SubjectName:"MONGODB"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5eb02bb85637cd592b2a4aea")
}
Display all documents from a collection with the help of find() method −
> db.demo759.find();
This will produce the following output −
{ "_id" : ObjectId("5eb02ba95637cd592b2a4ae7"), "SubjectName" : "MySQL" }
{ "_id" : ObjectId("5eb02baa5637cd592b2a4ae8"), "SubjectName" : "MongoDB" }
{ "_id" : ObjectId("5eb02baf5637cd592b2a4ae9"), "SubjectName" : "mongodb" }
{ "_id" : ObjectId("5eb02bb85637cd592b2a4aea"), "SubjectName" : "MONGODB" }
Following is the query implementing MongoDB regex operator −
> db.demo759.find({"SubjectName":{$regex:/mongodb/i}});
This will produce the following output −
{ "_id" : ObjectId("5eb02baa5637cd592b2a4ae8"), "SubjectName" : "MongoDB" }
{ "_id" : ObjectId("5eb02baf5637cd592b2a4ae9"), "SubjectName" : "mongodb" }
{ "_id" : ObjectId("5eb02bb85637cd592b2a4aea"), "SubjectName" : "MONGODB" }
Count the Frequency of elements in a Numeric Vector - tabulate() Function - GeeksforGeeks

05 Jun, 2020
tabulate() function in R Language is used to count the frequency of occurrence of a element in the vector. This function checks for each element in the vector and returns the number of times it occurs in the vector. It will create a vector of the length of the maximum element present in the vector.
Syntax: tabulate(x, nbins)
Parameters:x: Numeric Vectornbins: to control length of output vector
Example 1:
# R program to count frequency # of elements in a vector  # Creating a vectorx1 <- c(3, 5, 3, 7, 9, 4, 6)x2 <- c(-1, -4, 2.4, 6, -7)  # Calling tabulate() functiontabulate(x1)tabulate(x2)
Output:
[1] 0 0 2 1 1 1 1 0 1
[1] 0 1 0 0 0 1

Here, in the above code, the tabulate() function has ignored the negative values in the second vector, because it works only on numbers which are positive integers.
Example 2:
# R program to count frequency # of elements in a vector  # Creating a vectorx1 <- c(3, 5, 3, 7, 9, 4, 6)x2 <- c(-1, -4, 2.6, 6, -7, 35)  # Calling tabulate() functiontabulate(x1, nbins = 4)tabulate(x2, nbins = 8)
Output:
[1] 0 0 2 1
[1] 0 1 0 0 0 1 0 0

Here, in the above code, the length of the output vector is limited by the nbins passed as argument.
R Vector-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Replace specific values in column in R DataFrame ?
Filter data by multiple conditions in R using Dplyr
Loops in R (for, while, repeat)
How to change Row Names of DataFrame in R ?
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to Change Axis Scales in R Plots?
Printing Output of an R Program
K-Means Clustering in R Programming
Python | Remove all digits from a list of strings

11 Feb, 2019
Given a list of strings, write a Python program to remove all digits from the list of string.
Examples:
Input : ['alice1', 'bob2', 'cara3']
Output : ['alice', 'bob', 'cara']

Input : ['4geeks', '3for', '4geeks']
Output : ['geeks', 'for', 'geeks']

 
Method #1 : Python Regex
Python regex pattern can also be used to find if each string contains a digit or not and converting them to “”.
# Python program to Remove all # digits from a list of stringimport re  def remove(list):    pattern = '[0-9]'    list = [re.sub(pattern, '', i) for i in list]    return list  # Driver code   list = ['4geeks', '3for', '4geeks']print(remove(list))
['geeks', 'for', 'geeks']

 Method #2 : Using str.maketrans() methodThe maketrans() method returns a translation table that maps each character in the intabstring into the character at the same position in the outtab string. In this particular problem we translate each each digit to “” using for loop.
# Python program to Remove all # digits from a list of stringfrom string import digits  def remove(list):    remove_digits = str.maketrans('', '', digits)    list = [i.translate(remove_digits) for i in list]    return list  # Driver code   list = ['4geeks', '3for', '4geeks']print(remove(list))
['geeks', 'for', 'geeks']

 Method #3 : Using str.isalpha() methodIn ,this approach we use two for loops and check if the character of string is an alphabet or not. If yes, join it within the list, otherwise leave it.
# Python program to Remove all # digits from a list of stringfrom string import digits  def remove(list):    list = [''.join(x for x in i if x.isalpha()) for i in list]                  return list  # Driver code   list = ['4geeks', '3for', '4geeks']print(remove(list))
['geeks', 'for', 'geeks']

Python list-programs
python-list
Python
Python Programs
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
JavaScript Instanceof Operator

11 Sep, 2020
Below is the example of the Instanceof Operator.
Example:<!DOCTYPE html> <html>   <body>     <center>         <h1 style="color:green">GeeksforGeeks</h1>           <p id="GFG"></p>           <script>             var a = ["Geeks", "for", "Geeks"];               document.getElementById("GFG").innerHTML =                 (a instanceof Array) + "<br>" +                 (a instanceof Number);         </script>     </center> </body>   </html> 
<!DOCTYPE html> <html>   <body>     <center>         <h1 style="color:green">GeeksforGeeks</h1>           <p id="GFG"></p>           <script>             var a = ["Geeks", "for", "Geeks"];               document.getElementById("GFG").innerHTML =                 (a instanceof Array) + "<br>" +                 (a instanceof Number);         </script>     </center> </body>   </html> 
Output:
The instanceof operator in JavaScript is used to check the type of an object at run time. It returns a boolean value if true then it indicates that the object is an instance of a particular class and if false then it is not.
Syntax:
var gfg = objectName instanceof objectType
Parameters:objectName: States the name of Object.
Example-1: objectTypes.
<!DOCTYPE html><html>  <body>    <center>        <h1 style="color:green">GeeksforGeeks</h1>          <p id="GFG"></p>          <script>            var fruits = ["Apple", "Mango", "Banana"];              document.getElementById("GFG").innerHTML =                (fruits instanceof Array) + "<br>" +                (fruits instanceof Object) + "<br>" +                (fruits instanceof String) + "<br>" +                (fruits instanceof Number);        </script>    </center></body>  </html>
Output:
Example-2: Demonstrating that String and Date objects are also a type of Object (derived from Object).
<!DOCTYPE html><html>  <body>    <h1 style="color:green">GeeksforGeeks</h1>      <p id="GFG"></p>      <script>        var myString = new String();        var myDate = new Date();          console.log(myString instanceof Object);        console.log(myString instanceof Date);        console.log(myString instanceof String);        console.log(myDate instanceof Date);        console.log(myDate instanceof Object);        console.log(myDate instanceof String);    </script></body>  </html>
Output
Supported Browsers:
Google Chrome
Firefox
Edge
Opera
Apple Safari
javascript-operators
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Create a TreeSet with a List in Java?

31 Aug, 2021
TreeSet is an implementation of the SortedSet interface in Java that uses a Tree for storage. TreeSet can be created from List by passing the List to the TreeSet constructor in Java or we can traverse complete List and adding each element of the List to the TreeSet. 
Example:
Input : List = [a, b, c]
Output: TreeSet = [a, b, c]

Input : List = [1, 2, 3]
Output: TreeSet = [1, 2, 3]
Approach 1:
Create a List object.Enter multiple inputs in the List.Create a TreeSet Object.Initialize object with a constructor and pass List object in it.Print the Treeset.
Create a List object.
Enter multiple inputs in the List.
Create a TreeSet Object.
Initialize object with a constructor and pass List object in it.
Print the Treeset.
Below is the implementation of the above approach:
Java
// Java Program to Create a TreeSet with a Listimport java.util.ArrayList;import java.util.List;import java.util.TreeSet; public class ExampleTreeSet {    public static void main(String a[])    {        // Create new List        List<String> fruitlist = new ArrayList<String>();        fruitlist.add("Mango");        fruitlist.add("Apple");        fruitlist.add("Grape");        fruitlist.add("Papaya");         // Printing ArrayList        System.out.println("Fruit List : " + fruitlist);         // Create a TreeSet with the list        TreeSet<String> tree_set            = new TreeSet<String>(fruitlist);         // Print TreeSet        System.out.println("TreeSet from List : "                           + tree_set);    }}
Fruit List : [Mango, Apple, Grape, Papaya]
TreeSet from List : [Apple, Grape, Mango, Papaya]
Time Complexity: O(N)
Approach 2: 
Create a List object.Enter multiple inputs in the List.Create a TreeSet Object.Start List traversal and add that element in the TreeSet.After complete traversal, Print the Treeset.
Create a List object.
Enter multiple inputs in the List.
Create a TreeSet Object.
Start List traversal and add that element in the TreeSet.
After complete traversal, Print the Treeset.
Below is the implementation of the above approach:
Java
// Java Program to Create a TreeSet with a Listimport java.util.ArrayList;import java.util.List;import java.util.TreeSet; public class ExampleTreeSet {    public static void main(String a[])    {        // Create new List        List<String> fruitlist = new ArrayList<String>();        fruitlist.add("Mango");        fruitlist.add("Apple");        fruitlist.add("Grape");        fruitlist.add("Papaya");         // Printing ArrayList        System.out.println("Fruit List : " + fruitlist);         // Create a TreeSet        TreeSet<String> tree_set = new TreeSet<String>();         // Add each element in the TreeSet        for (String i : fruitlist)            tree_set.add(i);         // Print TreeSet        System.out.println("TreeSet from List : "                           + tree_set);    }}
Fruit List : [Mango, Apple, Grape, Papaya]
TreeSet from List : [Apple, Grape, Mango, Papaya]
Time Complexity: O(N)
 
as5853535
java-list
java-treeset
Picked
Java
Java Programs
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python PyQt5 – How to change font and size of Status Bar Message

26 Mar, 2020
We can set message to a Status Bar by using showMessage() method. In this article, we will see how to change the font and the size of StatusBar message. In order to do this we will use setFont() method.
Syntax : self.statusBar().setFont(QFont(font_name, font_size))
Argument : It take two argument :1. Font name it can be ‘Arial’, ’Times’ etc.2. Size to be set in integer.
Action performed : It changes the font and size of message
Code :
from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * import sys    class Window(QMainWindow):    def __init__(self):        super().__init__()          # set the title        self.setWindowTitle("Python")          # setting  the geometry of window        self.setGeometry(60, 60, 600, 400)          # setting status bar message        self.statusBar().showMessage("Times Font")          # setting  border         self.statusBar().setStyleSheet("border :3px solid black;")          # setting font and size        self.statusBar().setFont(QFont('Times', 15))          # creating a label widget        self.label_1 = QLabel("Status bar", self)          # moving position        self.label_1.move(100, 100)          # setting up the border        self.label_1.setStyleSheet("border :1px solid blue;")          # resizing label        self.label_1.adjustSize()          # show all the widgets        self.show()    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install i3 Window Manager in Linux?

29 Jan, 2021
In this article, we will see How to install i3 windows manager in Linux. i3 window manager is a tiling window manager for advanced users and developers. It is extremely lightweight and fast. It is a text-oriented and keyboard-oriented window manager. It is an easy and quick way to switch between workspaces.
Features:
It is a simple and lightweight application
It does not take more space and highly customizable
It has more Shortcut-controlled
Before Installing just update your system 
sudo apt update
Now for installing the i3 tiling manager 
sudo apt install i3 
For Arch Linux:
sudo pacman -S i3
After installing we want to restart the system and click on the small gear wheel-like icon (like settings icon) by clicking we want to select i3 option out of many like in the below image 
Once after clicking i3 and logging in we will be prompted to either generate a config file that will be saved in our home directory /.config.i3/config or use the default method which will save the /etc/i3 directory.
So now we will look at the first option where you will get a prompt like in the below image hit ENTER in order to place the configuration file in our home directory.
After the above step now we want to define the i3 wm modifier key also known as a mod key which can be a Windows Logo key or Alt key. Now use the up arrow or down arrow to select our preference modifier key. Like in the below-given image 
Now after completing these steps it saves us a blank screen with the status bar at the lower part of the screen like in the below image 
i3 window status bar 
So these are the complete steps to install and configure the i3 Window Manager. So I hope this article helps you in enriching your skills.
Picked
How To
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Set Git Username and Password in GitBash?
How to Install and Use NVM on Windows?
How to Install Jupyter Notebook on MacOS?
How to Install Python Packages for AWS Lambda Layers?
How to Add External JAR File to an IntelliJ IDEA Project?
Sed Command in Linux/Unix with examples
AWK command in Unix/Linux with examples
grep command in Unix/Linux
cut command in Linux with examples
cp command in Linux with examples
XML - Tree Structure

An XML document is always descriptive. The tree structure is often referred to as XML Tree and plays an important role to describe any XML document easily.
The tree structure contains root (parent) elements, child elements and so on. By using tree structure, you can get to know all succeeding branches and sub-branches starting from the root. The parsing starts at the root, then moves down the first branch to an element, take the first branch from there, and so on to the leaf nodes.
Following example demonstrates simple XML tree structure −
<?xml version = "1.0"?>
<Company>
   <Employee>
      <FirstName>Tanmay</FirstName>
      <LastName>Patil</LastName>
      <ContactNo>1234567890</ContactNo>
      <Email>tanmaypatil@xyz.com</Email>
      <Address>
         <City>Bangalore</City>
         <State>Karnataka</State>
         <Zip>560212</Zip>
      </Address>
   </Employee>
</Company>
Following tree structure represents the above XML document −
In the above diagram, there is a root element named as <company>. Inside that, there is one more element <Employee>. Inside the employee element, there are five branches named <FirstName>, <LastName>, <ContactNo>, <Email>, and <Address>. Inside the <Address> element, there are three sub-branches, named <City> <State> and <Zip>.
How to Create a PHP Docker Container? - GeeksforGeeks

05 Nov, 2020
PHP is one of the widely used programming languages across several organizations mostly used for creating web architectures and back-end applications. Most of the big tech giants still rely on PHP for their back-end applications and are also increasingly adopting developer tools such as Docker. Thus, it becomes very important to learn how to access and use PHP inside Docker Containers. Docker provides regularly updated PHP Images that can be pulled straight from the Dockerhub and can be customized using Dockerfiles. The Docker PHP Image allows you to build and run PHP applications and to access such applications on your localhost, you can use the -p flag to connect and publish ports.
In this article, we will discuss how to create a PHP Docker Container with the help of the Apache server.
Create a simple PHP file that will be served once we run the container. Let’s name the file app.php. 
PHP
<?php  echo ?Welcome to GeeksForGeeks?;?>
We will pull the PHP Image and Copy the files to the following directory.
FROM php:7.0-apache    
COPY . /var/www/php


Your directory structure should look like this.
To build the Docker Image, you can use the Docker Build Command.
sudo docker build -t php-demo .


To verify that the image has been built, you can list all the Images.
sudo docker images


You can use the following command to run the Docker Container.
sudo docker run -p 80:80 php-demo


You can see that our PHP application is being served at IP address 172.17.0.4.
Docker Container
linux
Advanced Computer Subject
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
ML | Stochastic Gradient Descent (SGD)
Copying Files to and from Docker Containers
Principal Component Analysis with Python
ML | Principal Component Analysis(PCA)
ML | Types of Learning – Supervised Learning
Q-Learning in Python
Classifying data using Support Vector Machines(SVMs) in Python
Getting Started with System Design
Deep Learning | Introduction to Long Short Term Memory
Learning Model Building in Scikit-learn : A Python Machine Learning Library
Crystal Reports - Creating Variables

A Variable is used to assign different values to an object unlike constant which is fixed. When you assign a value to a variable, it maintains that value till you assign a new value to it. Before using variables, it is necessary to define them in a report.
When you declare a variable in Crystal Report you need to assign a name to it, however this name shouldn’t be the same as any other function, operator, etc. A variable can be a number type, string type, date type, Boolean type, range type or an array type. A variable can hold a value of single type, like if you declare it as a number it can’t be used to hold string values later.
Local Stringvar Customer_Lastname
Local numbervar Sales_percentage

The keyword for declaring the variable has ‘var’ at the end and it is true for all variable types. You can also assign an initial value to a variable with declaration or in separate syntax.
Local NumberVar Z; //Declare Z to be a Number variable
Z := 30;           //Assign the value of 30 to Z

To use Variables in formulas, its scope is defined. Variable scope can be of three types −
Local
Global
Shared
This defines that a variable in one formula can be used in other formula.
Local variables are declared using the local keyword followed by the type and followed by the variable name as in the above examples.
Local variables are restricted to a single formula. This means that you cannot access the value of a local variable in one formula from a different formula.
//Formula 1
Local NumberVar Z;
Z := 30;

//Formula 2
EvaluateAfter ({@Formula A})
Local NumberVar Z;
Z := z + 5;
In the above example, Formula 2 will return a value 5 as Z is declared as local number variable in formula 1 so it will take default value for variable Z in formula 2.
Global variables are used throughout the main report. Their value is available to all formulas that declare the variable, except for those in sub reports.
Global StringVar Z;

It is recommended that you use global variable only when local variables do not suffice.
Since global variables share their values throughout the main report, you cannot declare a global variable in one formula with one type and then declare a global variable with the same name in a different formula with a different type.
Shared variables are used throughout the main report and all of its sub reports. Shared variables are even more general than global variables.
To use a shared variable, declare it in a formula in the main report −
Shared NumberVar Z := 10;

To use shared variables, it must be declared and assigned a value before it can be used in the main report and subreports.

    37 Lectures 
     2 hours 

 Neha Gupta

    61 Lectures 
     4.5 hours 

 Sasha Miller

    31 Lectures 
     32 mins

 Prof Krishna N Sharma

    35 Lectures 
     2 hours 

 Prof Krishna N Sharma

    24 Lectures 
     2 hours 

 Prof Krishna N Sharma
 Print
 Add Notes
 Bookmark this page