code-rag-bench/online-tutorials huggingface dataset:
\newcommand - Tex Command

\newcommand - Used to create your own commands (control sequences, macros, definitions).
{ \newcommand\myCommandName
  [ <optional # of arguments, from 1 to 9> ]
  { <replacement text> } }
\newcommand command is used for defining your own commands (control sequences, macros, definitions); \newcommand  must appear (within math delimiters) before it is used; if desired, you can use the  TeX.Macros  property of the configuration to define macros in the head. The bracketed # of arguments is omitted when there are no arguments.

\newcommand\myHearts 
 {\color{purple}{\heartsuit}\kern-2.5pt\color{green}{\heartsuit}}

\myHearts\myHearts


♡♡♡♡


\newcommand\myHearts[2] 
 {\color{#1}{\heartsuit}\kern-2.5pt\color{#2}{\heartsuit}}
  
\myHearts{red}{blue}


♡♡



\newcommand\myHearts 
 {\color{purple}{\heartsuit}\kern-2.5pt\color{green}{\heartsuit}}

\myHearts\myHearts


♡♡♡♡


\newcommand\myHearts 
 {\color{purple}{\heartsuit}\kern-2.5pt\color{green}{\heartsuit}}

\myHearts\myHearts

\newcommand\myHearts[2] 
 {\color{#1}{\heartsuit}\kern-2.5pt\color{#2}{\heartsuit}}
  
\myHearts{red}{blue}


♡♡


\newcommand\myHearts[2] 
 {\color{#1}{\heartsuit}\kern-2.5pt\color{#2}{\heartsuit}}
  
\myHearts{red}{blue}


    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
Convert MySQL Unix-Timestamp format to date format?

To achieve this, the following is the syntax
select date_format(from_unixtime(yourColumnName),'%b %d, %Y %l:%i %p PDT') from yourTableName;
To understand the above syntax, let us create a table. The query to create a table is as follows
mysql> create table unixTimeStampFormatDemo
   -> (
   -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> MyTimeStampValue bigint
   -> );
Query OK, 0 rows affected (0.59 sec)
Insert some records in the table using insert command. The query is as follows −
mysql> insert into unixTimeStampFormatDemo(MyTimeStampValue) values(1334428200);
Query OK, 1 row affected (0.20 sec)
mysql> insert into unixTimeStampFormatDemo(MyTimeStampValue) values(1513881000);
Query OK, 1 row affected (0.15 sec)
mysql> insert into unixTimeStampFormatDemo(MyTimeStampValue) values(1542738600);
Query OK, 1 row affected (0.14 sec)
mysql> insert into unixTimeStampFormatDemo(MyTimeStampValue) values(1551637800);
Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from unixTimeStampFormatDemo;
The following is the output
+----+------------------+
| Id | MyTimeStampValue |
+----+------------------+
|  1 | 1334428200       |
|  2 | 1513881000       |
|  3 | 1542738600       |
|  4 | 1551637800       |
+----+------------------+
4 rows in set (0.00 sec)
Here is the query to convert MySQL Unix-Timestamp Format to datetime
mysql> select date_format(from_unixtime(MyTimeStampValue),'%b %d, %Y %l:%i %p PDT') from unixTimeStampFormatDemo;
The following is the output
+-----------------------------------------------------------------------+
| date_format(from_unixtime(MyTimeStampValue),'%b %d, %Y %l:%i %p PDT') |
+-----------------------------------------------------------------------+
| Apr 15, 2012 12:00 AM PDT                                             |
| Dec 22, 2017 12:00 AM PDT                                             |
| Nov 21, 2018 12:00 AM PDT                                             |
| Mar 04, 2019 12:00 AM PDT                                             |
+-----------------------------------------------------------------------+
4 rows in set (0.00 sec)
How do I know if a MySQL table is using myISAM or InnoDB Engine?

To know a MySQL table is using MyISAM or InnoDB engine, you can use the command show status table. The syntax is as follows −
SHOW TABLE STATUS from yourDatabaseName LIKE ‘yourTableName’.
The above syntax tells about the specific table engine. Now you can apply the above syntax to know whether the MySQL table engine is using MyISAM or InnoDB.
Here, I have database ‘business’ and table ‘student’. The query is as follows −
mysql> show table status from business like 'student';
The following displays the engine our table ‘student’ is using −
+---------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
| Name   | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time          | Update_time | Check_time | Collation       | Checksum       | Create_options | Comment |
+---------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
| student | InnoDB | 10      | Dynamic    | 2    | 8192           | 16384       | 0               | 32768        | 0         | NULL           | 2018-10-01 12:26:57 | NULL       | NULL       | utf8mb4_unicode_ci | NULL       |       |          |
+---------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
1 row in set (0.09 sec)
To know the engine type of all the tables, you can use the following syntax −
SHOW TABLE STATUS FROM yourDatabaseName;
Apply the above syntax in the following query −
mysql> show table status from business;
The following is the output that displays all the engines −
Do-while loop in Arduino

The do-while loop’s syntax in Arduino is similar to the syntax in C. It is given below −
do{
   //Code
} while (condition);
Note the semicolon at the end.
void setup() {
   // put your setup code here, to run once:
   Serial.begin(9600);
   Serial.println();

   int i = 5;
   do{
      Serial.println(i);
      i--;
   } while(i > 0);

}

void loop() {
   // put your main code here, to run repeatedly:
}
The Serial Monitor output is shown below −
How to get the value of PI in JavaScript?

To get the value of PI in JavaScript, use the Math.PI property. It returns the ratio of the circumference of a circle to its diameter, which is approximately 3.14159.
You can try to run the following code to get the value of PI in JavaScript −
<html>
   <head>
      <title>JavaScript Math PI Property</title>
   </head>
   <body>
      <script>
         var property_value = Math.PI
         document.write("Property Value: " + property_value);
      </script>
   </body>
</html>
DB2 - Indexes

This chapter covers introduction to indexes, their types, creation and dropping.
Index is a set of pointers, which can refer to rows in a table, blocks in MDC or ITC tables, XML data in an XML storage object that are logically ordered by the values of one or more keys. It is created on DB2 table columns to speed up the data access for the queries, and to cluster and partition the data efficiently. It can also improve the performance of operation on the view.  A table with a unique index can have rows with unique keys. Depending on the table requirements, you can take different types of indexes.
Unique and Non-Unique indexes
Clustered and non-clustered indexes
For creating unique indexes, you use following syntax:
Syntax:
db2 create unique index <index_name> on 
<table_name>(<unique_column>) include (<column_names..>) 
Example: To create index for “shopper.sales1” table.
db2 create unique index sales1_indx on 
shopper.sales1(id) include (itemname) 
For dropping the index, you use the following syntax:
Syntax:
db2 drop unique index <index_name> on 
<table_name>(<unique_column>) include (<column_names..>) 
Example:
db2 drop index sales_index 

    10 Lectures 
     1.5 hours 

 Nishant Malik

    41 Lectures 
     8.5 hours 

 Parth Panjabi

    53 Lectures 
     11.5 hours 

 Parth Panjabi

    33 Lectures 
     7 hours 

 Parth Panjabi

    44 Lectures 
     3 hours 

 Arnab Chakraborty

    178 Lectures 
     14.5 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
Explain OpenCV Simple Threshold using Java Example

Thresholding is a simple technique for the segmentation of an image. it is often used to create binary images. In simple thresholding, the pixels greater than a given threshold value will be replaced with a standard value.
The threshold() method performs the simple threshold operation on the given image. Following are the parameters of this method −
Two Mat objects representing the source and destination images.
Two Mat objects representing the source and destination images.
Two integer variables representing the threshold or the standard value.
Two integer variables representing the threshold or the standard value.
An integer variable representing the type of the simple threshold.
An integer variable representing the type of the simple threshold.
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javafx.application.Application;
import javafx.embed.swing.SwingFXUtils;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.ImageView;
import javafx.scene.image.WritableImage;
import javafx.stage.Stage;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
public class SimpleThreshold extends Application {
   public void start(Stage stage) throws IOException {
      //Loading the OpenCV core library
      System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
      String file ="D:\\Images\\win2.jpg";
      Mat src = Imgcodecs.imread(file, Imgcodecs.IMREAD_GRAYSCALE);
      //Creating an empty matrices to store the destination image.
      Mat dst = new Mat(src.rows(), src.cols(), src.type());
      //Applying simple threshold
      Imgproc.threshold(src, dst, 50, 255, Imgproc.THRESH_BINARY);
      //Converting matrix to JavaFX writable image
      Image img = HighGui.toBufferedImage(dst);
      WritableImage writableImage= SwingFXUtils.toFXImage((BufferedImage) img, null);
      //Setting the image view
      ImageView imageView = new ImageView(writableImage);
      imageView.setX(10);
      imageView.setY(10);
      imageView.setFitWidth(575);
      imageView.setPreserveRatio(true);
      //Setting the Scene object
      Group root = new Group(imageView);
      Scene scene = new Scene(root, 595, 400);
      stage.setTitle("Simple Threshold");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]) {
      launch(args);
   }
}
On executing, the above program generates the following windows −
Java Program for array rotation

Following is the Java program for array rotation −
 Live Demo
public class Demo{
   void rotate_left(int my_arr[], int d, int len){
      d = d % len;
      int i, j, k, temp;
      int divisor = greatest_Common_divisor(d, len);
      for (i = 0; i < divisor; i++){
         temp = my_arr[i];
         j = i;
         while (true){
            k = j + d;
            if (k >= len)
            k = k - len;
            if (k == i)
            break;
            my_arr[j] = my_arr[k];
            j = k;
         }
         my_arr[j] = temp;
      }
   }
   void display_arr(int my_arr[], int size){
      int i;
      for (i = 0; i < size; i++)
      System.out.print(my_arr[i] + " ");
   }
   int greatest_Common_divisor(int a, int b){
      if (b == 0)
      return a;
      else
      return greatest_Common_divisor(b, a % b);
   }
   public static void main(String[] args){
      Demo my_inst = new Demo();
      int my_arr[] = { 5, 7, 89, 91, 34, 21, 11, 0 };
      System.out.println("Rotating the array to the left ");
      my_inst.rotate_left(my_arr, 2, 8);
      System.out.println("Displaying the array from a specific index ");
      my_inst.display_arr(my_arr, 8);
   }
}
Rotating the array to the left
Displaying the array from a specific index
89 91 34 21 11 0 5 7
A class named Demo contains a static function named ‘rotate_left’. Here, the array is passed as one of the parameters to the function, ‘d’ is the amount by which the array should be rotated and ‘len’ is the size of the array. The ‘greatest_common_divisor’ function is called by passing the value of ‘d’ and ‘len’. A ‘for’ loop is iterated over the result of function call to ‘greatest_common_divisor’.
A function named 'display_arr' is defined that is used to display the array elements. Another function 'greatest_Common_divisor' is defined to find the greatest common divisor among two numbers, it is a recursive function. In the main function, an instance of the class is created. An array is also defined, and the function is called on this object. The relevant data is displayed using the 'display_arr' function.
Calculate mean of multiple columns of R DataFrame - GeeksforGeeks

09 May, 2021
Mean is a numerical representation of the central tendency of the sample in consideration. In this article, we are going to calculate the mean of multiple columns of a dataframe in R Programming Language.
Formula:
Mean= sum of observations/total number of observations.
colMeans() this will return the column-wise mean of the given dataframe.
Syntax:
colMeans(dataframe_name)
where dataframe_name is the input dataframe.
For this simply pass the dataframe in use to the colMeans() function. The result will be the mean of all the individual columns.
Example:
R
# create a vector 1a=c(1,2,3,4,5)  # create a vector 2b=c(3,5,6,7,3)  # create a vector 3d=c(34,56,78,32,45)  # pass these vectors to # dataframedata=data.frame(a,b,d)  print(data)  # mean columns of the # dataframeprint(colMeans(data))
Output:
Example 2:
R
# create a vector 1a=c(1,2,3,4,5)  # pass the vector to data framedata=data.frame(a)  print(data)  # mean column of the dataframeprint(colMeans(data))
Output:
Syntax:
sapply(dataframe,mean)
where dataframe is the input dataframe and mean is the method to calculate mean.
For this dataframe name needs to be passed along with the action to perform in our case mean.
Example:
R
# numeric vector aa=c(1,2,3,4,5)  # numeric vector bb=c(3,4,5,6,7)  # numeric vector dd=c(34.6,78.8,89,9.43,67.9)  # pass the vectors to data framedata=data.frame(a,b,d)  # use sapply function to calculate meanprint(sapply(data,mean))
Output:
     a      b      d 
 3.000  5.000 55.946 
Example 2
R
# numeric vector aa=c(1,2,3,4,5)  # pass the vector to data framedata=data.frame(a)  # use sapply function to calculate meanprint(sapply(data,mean))
Output:
a
3
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.
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?
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?
Convert Matrix to Dataframe in R
Detecting and Checking Rootkits with Chkrootkit and rkhunter Tool in Kali Linux - GeeksforGeeks

24 Jun, 2021
In this article, we are going to see how to Detect and Check Rootkits with Chkrootkit and rkhunter in Kali Linux.
chkrootkit: It is a free and open-source antivirus tool available on GitHub. This tool checks locally in the binary system of your machine and scans your Linux server for a trojan. chkrootkit is a shell script which checks system binaries for rootkit modification.  This tool is used for scanning botnets, rootkits, malware, etc. This tool is completely tested on  Linux 2.0.x, 2.2.x, 2.4.x, 2.6.x, and 3.x.x, FreeBSD 2.2.x, 3.x, 4.x, 5.x and 7.x, OpenBSD 2.x, 3.x and 4.x., NetBSD 1.6.x, Solaris 2.5.1, 2.6, 8.0 and 9.0, HP-UX 11, Tru64, BSDI and Mac OS X. This tool comes under General Public License (GPL). 
Installation:
Step 1: Open your kali Linux operating system and use the following command to install the tool.
git clone https://github.com/Magentron/chkrootkit.git
cd chkrootkit
ls
Step 2: Now use the following command to run the tool.
./chkrootkit
The tool has started checking whether the files are infected or not. in a similar way, you can also download and scan your local machine for trojans. This tool only works on Linux or Linux distributions.
rkhunter: It (Rootkit Hunter) is a free and open-source Unix-based tool that scans for rootkits. This tool can be used for backdoors and possible local exploits. This tool rkhunter is a shell script which carries out various checks on the local system to try and detect known rootkits and malware. 
Installation:
Step 1: Download and install the tool using the following command.
wget http://downloads.sourceforge.net/project/rkhunter/rkhunter/1.4.6/rkhunter-1.4.6.tar.gz
Step 2: Use the following command to unzip the tool.
tar -xvf rkhunter-1.4.6.tar.gz
Step 3: Use the following command to run the tool.
rkhunter --check
The tool has started checking whether the files are infected or not. Similarly, you can also download and scan your local machine for trojans. This tool only works in Linux or Linux distributions.
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scp command in Linux with Examples
mv command in Linux with examples
chown command in Linux with Examples
Docker - COPY Instruction
nohup 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
Thread functions in C/C++
Array Basics in Shell Scripting | Set 1
Perl qr Function

This function quotes its STRING as a regular expression. STRING is interpolated the same way as PATTERN in m/PATTERN/
Following is the simple syntax for this function −
qr EXPR

This function returns a Perl value which may be used instead of the corresponding /STRING/ expression.
Following is the example code showing its basic usage −
$rex = qr/my.STRING/is;
s/$rex/foo/;

is is equivalent to

s/my.STRING/foo/is;
When above code is executed, it produces the following result −
$re = qr/$pattern/;
$string =~ /foo${re}bar/;	# can be interpolated in other patterns
$string =~ $re;			# or used standalone
$string =~ /$re/;		# or this way


    46 Lectures 
     4.5 hours 

 Devi Killada

    11 Lectures 
     1.5 hours 

 Harshit Srivastava

    30 Lectures 
     6 hours 

 TELCOMA Global

    24 Lectures 
     2 hours 

 Mohammad Nauman

    68 Lectures 
     7 hours 

 Stone River ELearning

    58 Lectures 
     6.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
C++ Program to Implement Min Heap

A Binary Heap is a complete binary tree which is either Min Heap or Max Heap. In a Max Binary Heap, the key at root must be maximum among all keys present in Binary Heap. This property must be recursively true for all nodes in Binary Tree. Min Binary Heap is similar to Min Heap.
For min_heap():
Begin
   Declare function min_heap(int *a, int m, int n)
      Declare j, t of the integer datatype.
      Initialize t = a[m].
      j = 2 * m;
      while (j <= n) do
         if (j < n && a[j+1] < a[j]) then
            j = j + 1
         if (t < a[j]) then
            break
         else if (t >= a[j]) then
            a[j / 2] = a[j]
            j = 2 * j
      a[j/2] = t
   return
End.
For build_minheap:
Begin
   Declare function build_minheap(int *a,int n).
      Declare k of the integer datatype.
      for(k = n/2; k >= 1; k--)
         Call function min_heap(a,k,n)
End.
#include <iostream>
#include <conio.h>
using namespace std;
void min_heap(int *a, int m, int n){
   int j, t;
   t= a[m];
   j = 2 * m;
   while (j <= n) {
      if (j < n && a[j+1] < a[j])
         j = j + 1;
      if (t < a[j])
         break;
      else if (t >= a[j]) {
         a[j/2] = a[j];
         j = 2 * j;
      }
   }
   a[j/2] = t;
   return;
}
void build_minheap(int *a, int n) {
   int k;
   for(k = n/2; k >= 1; k--) {
      min_heap(a,k,n);
   }
}
int main() {
   int n, i;
   cout<<"enter no of elements of array\n";
   cin>>n;
   int a[30];
   for (i = 1; i <= n; i++) {
      cout<<"enter element"<<" "<<(i)<<endl;
      cin>>a[i];
   }
   build_minheap(a, n);
   cout<<"Min Heap\n";
   for (i = 1; i <= n; i++) {
      cout<<a[i]<<endl;
   }
   getch();
}
enter no of elements of array
5
enter element 1
7
enter element 2
6
enter element 3
2
enter element 4
1
enter element 5
4
Min Heap
1
4
2
6
7
Python program to count upper and lower case characters in a given string.

For a given string input, we'd like to count the number of characters in lower case and those in the upper case using python. For example, for the given string,
"Hello World"
The counts should be −
Upper case: 2
Lower case: 8
We can implement this using a simple for loop with 2 conditions to check for upper and lower case characters. For example,
 Live Demo
def countUpperAndLowerCase(sentence):
upper = 0
lower = 0
for i in sentence:
if i >='A' and i <= 'Z':
upper += 1
elif i >= 'a' and i <= 'z':
lower += 1
print("Upper case: " + str(upper))
print("Lower case: " + str(lower))

countUpperAndLowerCase("Hello World")
This will give the output −
Upper case: 2
Lower case: 8
How to delete file from the firebase using file url in node.js ? - GeeksforGeeks

17 Dec, 2020
To delete a file from the firebase storage we need a reference to store the file in storage. As we only have the file URL we need to create a reference object of the file in firebase storage and then delete that file.
Deleting a file using the file URL can be done in two steps –
Get the reference to the storage using refFromUrl method from firebase.storage.Deleting the file using the reference of the file in storage obtained from Step 1.
Get the reference to the storage using refFromUrl method from firebase.storage.
Deleting the file using the reference of the file in storage obtained from Step 1.
The method refFromUrl returns a reference to that file and can take two types of file URL as an input – 
gs:// URL, for example, gs://bucket/files/image.pngDownload URL taken from object metadata.
gs:// URL, for example, gs://bucket/files/image.png
Download URL taken from object metadata.
Example 1: Deleting a file from the given file URL using the refFromURL method.
Javascript
var fileUrl = 'https://firebasestorage.googleapis.com/b/bucket/o/images%20geeksforgeeks.jpg';  // Create a reference to the file to deletevar fileRef = storage.refFromURL(fileUrl);  console.log("File in database before delete exists : "         + fileRef.exists())  // Delete the file using the delete() method fileRef.delete().then(function () {      // File deleted successfully    console.log("File Deleted")}).catch(function (error) {    // Some Error occurred});  console.log("File in database after delete exists : "        + fileRef.exists())
Output:
File in database before delete exists : true
File Deleted
File in database after delete exists : false
Example 2: Deleting a file using bucket gs:// URL 
Javascript
// gs Bucket URLvar fileUrl = 'gs://bucket/geeksforgeeks/image.png';  // Create a reference to the file to deletevar fileRef = storage.refFromURL(fileUrl);  console.log("File in database before delete exists : "        + fileRef.exists())  // Delete the file using the delete() method fileRef.delete().then(function () {      // File deleted successfully    console.log("File Deleted")}).catch(function (error) {    // Some Error occurred});  console.log("File in database after delete exists : "        + fileRef.exists())
 Output :
File in database before delete exists : true
File Deleted
File in database after delete exists : false
Node.js-Misc
Picked
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Express.js express.Router() Function
JWT Authentication with Node.js
Express.js req.params Property
Difference between npm i and npm ci in Node.js
Mongoose Populate() Method
Roadmap to Become a Web Developer in 2022
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Convert a string to an integer in JavaScript
How to set the location of the Tabs in a JTabbedPane Container to the left in Java?

To set the location of the tabs in a JTabbedPane container, use the LEFT constant. Here, we will set the position to the left −
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.LEFT);
The following is an example to set the location of the Tabs in a JTabbedPane Container to the left −
package my;
import javax.swing.*;
import java.awt.*;
public class SwingDemo {
   public static void main(String args[]) {
      JFrame frame = new JFrame("Devices");
      JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.LEFT);
      JTextArea text = new JTextArea(100,100);
      JPanel panel1, panel2, panel3, panel4, panel5, panel6, panel7, panel8;
      panel1 = new JPanel();
      panel2 = new JPanel();
      panel2.add(text);
      panel3 = new JPanel();
      panel4 = new JPanel();
      panel5 = new JPanel();
      panel6 = new JPanel();
      panel7 = new JPanel();
      panel8 = new JPanel();
      tabbedPane.setBackground(Color.yellow);
      tabbedPane.setForeground(Color.black);
      tabbedPane.addTab("Laptop", panel1);
      tabbedPane.addTab("Desktop ", panel2);
      tabbedPane.addTab("Notebook", panel3);
      tabbedPane.addTab("Echo ", panel4);
      tabbedPane.addTab("Tablet", panel5);
      tabbedPane.addTab("Alexa ", panel6);
      tabbedPane.addTab("Notebook", panel7);
      tabbedPane.addTab("iPad", panel8);
      tabbedPane.setForegroundAt(2, Color.RED);
      tabbedPane.setBackgroundAt(4, Color.magenta);
      frame.add(tabbedPane);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setSize(550,270);
      frame.setVisible(true);
   }
}
How can we update values in a MySQL table?

With the help of UPDATE statement and WHERE clause, we can update the values in single or multiple rows of the table. MySQL updates the values on the basis of condition specified in WHERE clause. For example, suppose in the ‘employee’ table we want to change the ‘name’ and ‘doj’ of the employee whose id is 1 then it can be done with the following query −
mysql> UPDATE employee SET name = 'Gaurav', doj = '2010-02-01' WHERE id = 1;
Query OK, 1 row affected (0.06 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from employee WHERE id = 1;
+------+--------+------------+
| id   | name   | doj        |
+------+--------+------------+
| 1    | Gaurav | 2010-02-01 |
+------+--------+------------+
1 row in set (0.00 sec)
How to create a boxplot using ggplot2 for single variable without X-axis labels in R?

The important part of a boxplot is Y−axis because it helps to understand the variability in the data and hence, we can remove X−axis labels if we know the data description. To create a boxplot using ggplot2 for single variable without X−axis labels, we can use theme function and set the X−axis labels to blank as shown in the below example.
 Live Demo
Consider the below data frame −
y<−rnorm(20,25,4.2)
df<−data.frame(y)
df
y
1 30.52520
2 23.95832
3 25.47747
4 28.13632
5 33.78174
6 18.61764
7 20.46791
8 29.65309
9 22.46586
10 19.87244
11 22.32916
12 26.26577
13 30.54542
14 27.85693
15 23.60995
16 19.79125
17 27.01937
18 22.43575
19 29.34608
20 24.97311
Loading ggplot2 package and creating a boxplot of x −
library(ggplot2)
ggplot(df,aes(x=factor(0),y))+geom_boxplot()
Creating the boxplot without X-axis labels −
ggplot(df,aes(x=factor(0),y))+geom_boxplot()+theme(axis.title.x=element_blank(),axis.text.x=element_blank(),axis.ticks.x=element_blank())
CSS Loader in ReactJS

In this article, we will learn how to provide dynamic class names to our React application.
Npm run eject
This command will allow us to customize the configurations and the options that were predefined when we run the command of create-react-app. It is a one-sided operation that can’t be undone later on.
We need to configure the webpack loaders so as to enable css-loader which will then provide dynamic naming to our classes.
Set the configurations as −
{
   test: /\.css$/,
   loader: 'style-loader'
}, {
   test: /\.css$/,
   loader: 'css-loader',
   query: {
      modules: true,
      localIdentName: '[name]_[local]__[hash:base64:5]'
   }
}
import styles from './App.css'
In this example, we will build a React application that has dynamic naming to the classes of the JSX elements.
App.jsx
import React from 'react';
import styles from './App.css'
const App = () => {
   return (
      <div classname={styles.App}>
      <h2>TutorialsPoint</h2>
      </div>
   );
};
export default App;
In the above example, a dynamic class name is provided to the <div> tag.
Python – Separate first word from String

30 Jun, 2020
Sometimes, while working with Python strings, we can have a problem in which we need to separate the first word from the entire string. This can have possible applications in many domains such as day-day and web-development. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using loopThis is the brute force way in which this task can be performed. In this, we iterate the string and extract the word till the 1st word and then append other string as other elements of list.
# Python3 code to demonstrate working of # Separate first word from String# Using loop  # initializing stringtest_str = "gfg is best"  # printing original stringprint("The original string is : " + test_str)  # Separate first word from String# Using loopres = []temp = ''flag = 1for ele in test_str:    if ele == ' ' and flag:        res.append(temp)        temp = ''        flag = 0    else :        temp += eleres.append(temp)                      # printing result print("Initial word separated list : " + str(res)) 
The original string is : gfg is best
Initial word separated list : ['gfg', 'is best']

 
Method #2 : Using split()This is recommended and a one-liner that can be used to perform this task. In this, we just split the string by space and then construct the list of separated words.
# Python3 code to demonstrate working of # Separate first word from String# Using split()  # initializing stringtest_str = "gfg is best"  # printing original stringprint("The original string is : " + test_str)  # Separate first word from String# Using split()res = test_str.split(' ', 1)                      # printing result print("Initial word separated list : " + str(res)) 
The original string is : gfg is best
Initial word separated list : ['gfg', 'is best']

nidhi_biet
Python string-programs
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PHP - Environment Setup

In order to develop and run PHP Web pages three vital components need to be installed on your computer system.
Web Server − PHP will work with virtually all Web Server software, including Microsoft's Internet Information Server (IIS) but then most often used is freely available Apache Server. Download Apache for free here − https://httpd.apache.org/download.cgi
Web Server − PHP will work with virtually all Web Server software, including Microsoft's Internet Information Server (IIS) but then most often used is freely available Apache Server. Download Apache for free here − https://httpd.apache.org/download.cgi
Database − PHP will work with virtually all database software, including Oracle and Sybase but most commonly used is freely available MySQL database. Download MySQL for free here − https://www.mysql.com/downloads/
Database − PHP will work with virtually all database software, including Oracle and Sybase but most commonly used is freely available MySQL database. Download MySQL for free here − https://www.mysql.com/downloads/
PHP Parser − In order to process PHP script instructions a parser must be installed to generate HTML output that can be sent to the Web Browser. This tutorial will guide you how to install PHP parser on your computer.
PHP Parser − In order to process PHP script instructions a parser must be installed to generate HTML output that can be sent to the Web Browser. This tutorial will guide you how to install PHP parser on your computer.
Before you proceed it is important to make sure that you have proper environment setup on your machine to develop your web programs using PHP.
Type the following address into your browser's address box.
http://127.0.0.1/info.php

If this displays a page showing your PHP installation related information then it means you have PHP and Webserver installed properly. Otherwise you have to follow given procedure to install PHP on your computer.
This section will guide you to install and configure PHP over the following four platforms −
PHP Installation on Linux or Unix with Apache
PHP Installation on Linux or Unix with Apache
PHP Installation on Mac OS X with Apache
PHP Installation on Mac OS X with Apache
PHP Installation on Windows NT/2000/XP with  IIS
PHP Installation on Windows NT/2000/XP with  IIS
PHP Installation on Windows NT/2000/XP with  Apache
PHP Installation on Windows NT/2000/XP with  Apache
If you are using Apache as a Web Server then this section will guide you to edit Apache Configuration Files.
Just Check it here − PHP  Configuration in Apache Server
The PHP configuration file, php.ini, is the final and most immediate way to affect PHP's functionality.
Just Check it here − PHP.INI File Configuration
To configure IIS on your Windows machine you can refer your IIS Reference Manual shipped along with IIS.
Using Tkinter in Jupyter Notebook

Tkinter is a Python library used for creating and developing GUI-based applications. It is completely open-source which works on Windows, Mac, Linux, and Ubuntu. In Windows operating system, we can install the Tkinter library using the command pip install tkinter. It will install all the other modules that come with Tkinter library. Tkinter can be installed on Jupyter notebook as well, by using the command pip install tkinter. We can run all the standard commands of Tkinter in Jupyter notebook.
Once we have installed Tkinter in Jupyter notebook, then we can verify the installation by typing the following command −
from tkinter import *
Now, after verifying the installation, you are ready to write your Tkinter application code in Jupyter notebook. For example, type the following code in Jupyter notebook and run the code by pressing "Shift + Enter".
#Import tkinter library
from tkinter import *
#Create an instance of Tkinter frame or window
win= Tk()
#Set the geometry of tkinter frame
win.geometry("750x250")
def callback():
   Label(win, text="Hello World!", font=('Century 20 bold')).pack(pady=4)
#Create a Label and a Button widget
btn=Button(win, text="Press Enter", command= callback)
btn.pack(ipadx=10)
win.bind('<Return>',lambda event:callback())
win.mainloop()
Running the above code will display a window that contains a button widget.
In the given output, when we press the Enter key, it will show the Label widgets with some text.
turtle.window_width() function in Python

26 Jul, 2020
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
This function is used to return the width of the turtle window. It doesn’t require any argument.
Syntax :
turtle.window_width()

Below is the implementation of the above method with an example :
Python3
# import packageimport turtle  # get turtle window widthprint(turtle.window_width())  # make screen object# then set size and colorsc = turtle.Screen()sc.setup(300,300)sc.bgcolor("green")  # get turtle window widthprint(turtle.window_width())  # loops for pass timefor i in range(5000):  for j in range(5000):    pass  # set size and color againsc.setup(500,400)sc.bgcolor("red")  # get turtle window widthprint(turtle.window_width())
Output :
768
300
500
Python-turtle
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Python | datetime.timedelta() function
Creating and Using a MySQL Database

Once MySQL has been installed, and the user is aware of how SQL statements need to be entered, a database can be accessed. Let us understand the steps needed to retrieve data from tables in a database −
Connect to the server
Connect to the server
Create a database
Create a database
Create a table
Create a table
Load the data into the table
Load the data into the table
Retrieve data from the table
Retrieve data from the table
Before creating a database, it is important to know the databases that are already present in the environment. It can be found using the below query −
mysql> SHOW DATABASES;
+--------------+
| Database     |
+--------------+
| mysql        |
| test         |
| tmp          |
+--------------+
The above query will display the names of all databases that are present in the environment. The ‘mysql’ database tells about the user access privileges. The ‘test’ database is available like a sample workspace for users to experiment on things.
A database can be created using the below statement −
CREATE DATABASE databaseName;
If we wish to access and use a specific database, we can use the following query −
mysql> USE databaseName
Database changed
The ‘USE’ statement doesn’t require a semi-colon. This is similar to the ‘QUIT’ statement. Even if semi-colon is used, it does no harm.
We can create and use a database of our own, but before that, MySQL administrator’s permission is required.
How to execute a command and get the output of command within C++ using POSIX?

You can use the popen and pclose functions to pipe to and from processes. The popen() function opens a process by creating a pipe, forking, and invoking the shell. We can use a buffer to read the contents of stdout and keep appending it to a result string and return this string when the processes exit.
#include <iostream>
#include <stdexcept>
#include <stdio.h>
#include <string>

using namespace std;

string exec(string command) {
   char buffer[128];
   string result = "";

   // Open pipe to file
   FILE* pipe = popen(command.c_str(), "r");
   if (!pipe) {
      return "popen failed!";
   }

   // read till end of process:
   while (!feof(pipe)) {

      // use buffer to read and add to result
      if (fgets(buffer, 128, pipe) != NULL)
         result += buffer;
   }

   pclose(pipe);
   return result;
}

int main() {
   string ls = exec("ls");
   cout << ls;
}
This will give the output −
a.out
hello.cpp
hello.py
hello.o
hydeout
my_file.txt
watch.py
How to append a list to a Pandas DataFrame using iloc in Python?

The iloc method is an integer-location based indexing for selection by position. We are using iloc to append a list to a DataFrame.
Let us first create a DataFrame. The data is in the form of lists of team rankings for our example −
# data in the form of list of team rankings
Team = [['India', 1, 100],['Australia', 2, 85],['England', 3, 75],['New Zealand', 4 , 65],['South Africa', 5, 50],['Bangladesh', 6, 40]]

# Creating a DataFrame and adding columns
dataFrame = pd.DataFrame(Team, columns=['Country', 'Rank', 'Points'])
Following is the row to be appended −
myList = ["Sri Lanka", 7, 30]

Append the above row using iloc(). 5 means index 6 i.e. position 6 row will get replaced with the above new row −
dataFrame.iloc[5] = myList
Following is the code −
import pandas as pd

# data in the form of list of team rankings
Team = [['India', 1, 100],['Australia', 2, 85],['England', 3, 75],['New Zealand', 4 , 65],['South Africa', 5, 50],['Bangladesh', 6, 40]]

# Creating a DataFrame and adding columns
dataFrame = pd.DataFrame(Team, columns=['Country', 'Rank', 'Points'])

print"DataFrame...\n",dataFrame

# row to be appended
myList = ["Sri Lanka", 7, 30]

# append the above row using iloc()
# 5 means index 6 i.e. position 6 row will get replaced with the above new row
dataFrame.iloc[5] = myList

# display the update dataframe
print"\nUpdated DataFrame after appending a row using iloc...\n",dataFrame
This will produce the following output −
DataFrame...
       Country   Rank   Points
0        India      1      100
1    Australia      2       85
2      England      3       75
3  New Zealand      4       65
4 South Africa      5       50
5   Bangladesh      6       40

Updated DataFrame after appending a row using iloc...
       Country   Rank   Points
0        India      1      100
1    Australia      2       85
2      England      3       75
3  New Zealand      4       65
4 South Africa      5       50
5    Sri Lanka      7       30
Difference between Join and union in SQL

Union is a set operator that can be used to combine the result set of two different SELECT statement. In the union number of columns and data type should be the same. 
It has two types −
Union
Union All 
On the other hand ,In a Relational database, tables are associated with each other and we used foreign key to maintain relationships between tables. We used join clause to retrieve data from associated tables. The join condition indicates how column in each table are matched against each other. 
There are two types of joins clause in SQL 
Inner join 
Outer join


1
Basic 
It can be used to retrieve matched records between both tables or more tables 
It can be used to combine the result set of two different SELECT statement.
2
        Data type 
Result set can have different types of data types 
Data type should be same as the  result set of each select statement
3
Duplicate 
It doesn't remove duplicate data.
It removes duplicate rows between the various select statements.
SELECT columnlist
FROM tableA
UNION
SELECT columnlist
FROM tableB
SELECT columnlist
FROM TableA
INNER JOIN
TableB ON join condition
Java Regex - Pattern Class

The java.util.regex.Pattern class represents a compiled representation of a regular expression.
Following is the declaration for java.util.regex.Pattern class −
public final class Pattern
   extends Object
      implements Serializable

Following are the fields for java.util.regex.Duration class −
static int CANON_EQ − Enables canonical equivalence.
static int CANON_EQ − Enables canonical equivalence.
static int CASE_INSENSITIVE − Enables case-insensitive matching.
static int CASE_INSENSITIVE − Enables case-insensitive matching.
static int COMMENTS − Permits whitespace and comments in pattern.
static int COMMENTS − Permits whitespace and comments in pattern.
static int DOTALL − Enables dotall mode.
static int DOTALL − Enables dotall mode.
static int LITERAL − Enables literal parsing of the pattern.
static int LITERAL − Enables literal parsing of the pattern.
static int MULTILINE − Enables multiline mode.
static int MULTILINE − Enables multiline mode.
static int UNICODE_CASE − Enables Unicode-aware case folding.
static int UNICODE_CASE − Enables Unicode-aware case folding.
static int UNICODE_CHARACTER_CLASS − Enables the Unicode version of Predefined character classes and POSIX character classes.
static int UNICODE_CHARACTER_CLASS − Enables the Unicode version of Predefined character classes and POSIX character classes.
static int UNIX_LINES − Enables Unix lines mode.
static int UNIX_LINES − Enables Unix lines mode.
Compiles the given regular expression into a pattern.
Compiles the given regular expression into a pattern with the given flags.
Returns this pattern's match flags.
Creates a matcher that will match the given input against this pattern.
Compiles the given regular expression and attempts to match the given input against it.
Returns the regular expression from which this pattern was compiled.
Returns a literal pattern String for the specified String.
Splits the given input sequence around matches of this pattern.
Splits the given input sequence around matches of this pattern.
Returns the string representation of this pattern.
This class inherits methods from the following classes −
Java.lang.Object
 Print
 Add Notes
 Bookmark this page
What is the !! (not not) operator in JavaScript? - GeeksforGeeks

23 Apr, 2019
The !!(not not) is the repetition of the unary logical operator not(!) twice. The double negation(!!) operator calculates the truth value of a value. This operator returns a boolean value, which depends on the truthiness of the given expression.In general, logical not(!) determines the “truth” of what a value is not:
The truth is that false is not true (that’s why !false results in true)
The truth is that true is not false (that’s why !true results in false)
!! determines the “truth” of what a value is not not:
The truth is that true is not not true (that’s why !!true results in true)
The truth is that false is not not false (that’s why !!false results in false)
Example-1: This example checks the truthyness of the boolean value true.
<script>    // Write Javascript code here    var n1;    /* checking truthyness of    the boolean value true. */    n1 = !!true;    document.write(n1);</script>
Output:
true

Example-2: This example checks the falsyness of the boolean value false.
<script>    // Write Javascript code here    var n1;    // checking falsyness of the boolean value false.     n1 = !!false;    document.write(n1);</script>
Output:
false

Example-3: This example checks the truthyness or falsyness of a given string.
<script>    // Write Javascript code here    var n1;    // checking the truthyness or falsyness of a given string.    n1 = !!"Javascript programming";    document.write(n1);</script>
Output:
true

Example-4: This example checks the truthyness or falsyness of a given object.
<script>    // Write Javascript code here    var n1;    // checking the truthyness     // or falsyness of a given object.    n1 = !!{        articles: 70    };    document.write(n1);</script>
Output:
true

JavaScript-Misc
Picked
JavaScript
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
How to Open URL in New Tab using JavaScript ?
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Java - String toString() Method

This method returns itself a string.
Here is the syntax of this method −
public String toString()

Here is the detail of parameters −
NA
NA
This method returns the string itself.
import java.io.*;
public class Test {

   public static void main(String args[]) {
      String Str = new String("Welcome to Tutorialspoint.com");

      System.out.print("Return Value :");
      System.out.println(Str.toString());
   }
}
This will produce the following result −
Return Value :Welcome to Tutorialspoint.com


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page