code-rag-bench/online-tutorials huggingface dataset:
DC.js - Legend

Legend is an attachable screen customization. It can be added to other DC charts to render horizontal legend labels. This chapter explains about legend in detail.
Legend supports the following important methods. Let us go through each one of them in detail.
This method is used to set an automatic width for legend items on or off. If true, itemWidth is ignored. It is defined below −
legend.autoItemWidth = function (width) {
   if (!arguments.length) {
      return _width;
   }
}
This method is used to set or get a gap between the legend items. It is defined as follows −
legend.gap = function (gap) {
   if (!arguments.length) {
      return _gap;
   }
}
This method is used to position the legend horizontally and is defined as follows.
_legend.horizontal = function (h) {
   if (!arguments.length) {
      return _h;
   }
};
This method is used to set or get the legend item height.
legend.itemHeight = function (itemHeight) {
   if (!arguments.length) {
      return _itemHeight;
   }
};
This method is used to set or get the legend the item width for a horizontal legend.
_legend.itemWidth = function (itemWidth) {
   if (!arguments.length) {
      return _itemWidth;
   }
};
This method is used to set or get the legend text function. The legend widget uses this function to render the legend text for each item. If no function is specified, the legend widget will display the names associated with each group. A simple example is shown below −
legend.legendText(dc.pluck('name'))
This method is used to display the maximum number of legend items.
It is used to set or get the x-coordinate for a legend widget and is defined below −
legend.x = function (x) {
   if (!arguments.length) {
      return _x;
   }
};
Similarly, you can also perform the y-coordinate.
 Print
 Add Notes
 Bookmark this page
Swift - If Statement

An if statement consists of a Boolean expression followed by one or more statements.
The syntax of an if statement in Swift 4 is as follows −
if boolean_expression {
   /* statement(s) will execute if the boolean expression is true */
}

If the Boolean expression evaluates to true, then the block of code inside the if statement will be executed. If Boolean expression evaluates to false, then the first set of code after the end of the if statement (after the closing curly brace) will be executed.
var varA:Int = 10;

/* Check the boolean condition using if statement */
if varA < 20 {
   /* If condition is true then print the following */
   print("varA is less than 20");
}

print("Value of variable varA is \(varA)");
When we run the above program using playground, we get the following result.
varA is less than 20
Value of variable varA is 10


    38 Lectures 
     1 hours 

 Ashish Sharma

    13 Lectures 
     2 hours 

 Three Millennials

    7 Lectures 
     1 hours 

 Three Millennials

    22 Lectures 
     1 hours 

 Frahaan Hussain

    12 Lectures 
     39 mins

 Devasena Rajendran

    40 Lectures 
     2.5 hours 

 Grant Klimaytys
 Print
 Add Notes
 Bookmark this page
How to send HTML email using Android App?

This example demonstrates about How to send HTML email using Android App.
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"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:layout_margin="16dp">
   <Button
      android:onClick="sendHtmlEmail"
      android:text="Send HTML Email"
      android:layout_width="match_parent"
      android:layout_height="wrap_content" />
</RelativeLayout>
Step 3 − Add the following code to src/MainActivity.java
package app.com.sample;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
   }
   public void sendHtmlEmail(View view) {
      String mailId = "yourmail@gmail.com";
      Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", mailId, null));
      emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject text here");
      emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("<p><b>Some Content</b></p>" + "http://www.google.com" + "<small><p>More content</p></small>"));
      startActivity(Intent.createChooser(emailIntent, "Send email..."));
   }
}
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="app.com.sample">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
Click here to download the project code.
Comparing two Strings lexicographically in Java 


We can compare two strings lexicographically using following ways in Java.
Using String.compareTo(String) method. It compares in a case-sensitive manner.
Using String.compareTo(String) method. It compares in a case-sensitive manner.
Using String.compareToIgnoreCase(String) method. It compares in case insensitive manner.
Using String.compareToIgnoreCase(String) method. It compares in case insensitive manner.
Using String.compareTo(Object) method. It compares in case-sensitive manner.
Using String.compareTo(Object) method. It compares in case-sensitive manner.
These methods return the ASCII difference of first odd characters of compared strings.
Live Demo
public class Tester {
   public static void main(String args[]) {
      String str = "Hello World";
      String anotherString = "hello world";
      Object objStr = str;

      System.out.println( str.compareTo(anotherString) );
      System.out.println( str.compareToIgnoreCase(anotherString) );
      System.out.println( str.compareTo(objStr.toString()));
   }
}
-32
0
0
How to pass a PHP array to a JavaScript function?

PHP array can be passed to a JavaScript function using json_encode with the below lines of code −
<script>
   var var_name= <?php echo json_encode($php_variable); ?>;
</script>
If an object needs to be parsed from JSON like string (required in AJAX request), the below lines of code can be used −
var my_data = "<JSON-String>";
var my_var = JSON.parse(my_data);
Let us see an example −
<?php
   // Create a PHP array
   $sample_array = array(
      0 => "Hello",
      1 => "there",
   )
?>
<script>
   // Access the elements of the array
   var passed_array = <?php echo json_encode($sample_array); ?>;
   // Display the elements inside the array
   for(var i = 0; i < passed_array.length; i++){
      document.write(passed_array[i]);
   }
</script>
This will produce the following output −
Hellothere
Generate Random Long type numbers in Java

In order to generate Random long type numbers in Java, we use the nextLong() method of the java.util.Random class. This returns the next random long value from the random generator sequence.
Declaration − The java.util.Random.nextLong() method is declared as follows −
public long nextLong()
Let us see a program to generate random long type numbers in Java −
 Live Demo
import java.util.Random;
public class Example {
   public static void main(String[] args) {
      Random rd = new Random(); // creating Random object
      System.out.println(rd.nextLong()); // displaying a random long value
   }
}
-4787108556148621714
Note - The output may vary on Online compilers.
C library function - iscntrl()

The C library function int iscntrl(int c) checks if the passed character is a control character.
According to standard ASCII character set, control characters are between ASCII codes 0x00 (NUL), 0x1f (US), and 0x7f (DEL). Specific compiler implementations for certain platforms may define additional control characters in the extended character set (above 0x7f).
Following is the declaration for iscntrl() function.
int iscntrl(int c);
c − This is the character to be checked.
c − This is the character to be checked.
This function returns non-zero value if c is a control character, else it returns 0.
The following example shows the usage of iscntrl() function.
#include <stdio.h>
#include <ctype.h>

int main () {
   int i = 0, j = 0;
   char str1[] = "all \a about \t programming";
   char str2[] = "tutorials \n point";
  
   /* Prints string till control character \a */
   while( !iscntrl(str1[i]) ) {
      putchar(str1[i]);
      i++;
   }
  
   /* Prints string till control character \n */
   while( !iscntrl(str2[j]) ) {
      putchar(str2[j]);
      j++;
   }
   
   return(0);
}
Let us compile and run the above program, to produce the following result −
all tutorials 


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
How to create a Menu using JavaFX?

A menu is a list of options or commands presented to the user. In JavaFX a menu is represented by the javafx.scene.control.Menu class, you can create a menu by instantiating this class.
While instantiating, you can pass the title of the menu as a parameter to its constructor. The Menu class contains an observable list that holds the contents of the menu (menu items).
The menu items are represented by the javafx.scene.control.MenuItem class, a superclass of the Menu class. You can display a text or a graphic as a menu item and add the desired cation to it.
To create a menu −
Instantiate the Menu class.
Instantiate the Menu class.
Create a required number of menu items by instantiating the MenuItem class.
Create a required number of menu items by instantiating the MenuItem class.
Add the created menu items to the observable list of the menu.
Add the created menu items to the observable list of the menu.
The javafx.scene.control.MenuBar class represents a menu bar that holds all the menus in a UI application.
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class MenuExample extends Application {
   public void start(Stage stage) {
      //Creating a menu
      Menu fileMenu = new Menu("File");
      //Creating menu Items
      MenuItem item1 = new MenuItem("Add Files");
      MenuItem item2 = new MenuItem("Start Converting");
      MenuItem item3 = new MenuItem("Stop Converting");
      MenuItem item4 = new MenuItem("Remove File");
      MenuItem item5 = new MenuItem("Exit");
      //Adding all the menu items to the menu
      fileMenu.getItems().addAll(item1, item2, item3, item4, item5);
      //Creating a menu bar and adding menu to it.
      MenuBar menuBar = new MenuBar(fileMenu);
      menuBar.setTranslateX(200);
      menuBar.setTranslateY(20);
      //Setting the stage
      Group root = new Group(menuBar);
      Scene scene = new Scene(root, 595, 200, Color.BEIGE);
      stage.setTitle("Menu Example");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]){
      launch(args);
   }
}
OpenCV - Color Maps

In OpenCV, you can apply different color maps to an image using the method applyColorMap() of the class Imgproc. Following is the syntax of this method −
applyColorMap(Mat src, Mat dst, int colormap)

It accepts three parameters −
src − An object of the class Mat representing the source (input) image.
src − An object of the class Mat representing the source (input) image.
dst − An object of the class Mat representing the destination (output) image.
dst − An object of the class Mat representing the destination (output) image.
colormap − A variable of integer type representing the type of the color map to be applied.
colormap − A variable of integer type representing the type of the color map to be applied.
The following program demonstrates how to apply color map to an image.
import org.opencv.core.Core;
import org.opencv.core.Mat;

import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

public class ColorMapTest {
   public static void main(String args[]) {
      // Loading the OpenCV core library
      System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

      // Reading the Image from the file and storing it in to a Matrix object
      String file ="E:/OpenCV/chap25/color_input.jpg";
      Mat src = Imgcodecs.imread(file);

      // Creating an empty matrix to store the result
      Mat dst = new Mat();

      // Applying color map to an image
      Imgproc.applyColorMap(src, dst, Imgproc.COLORMAP_HOT);

      // Writing the image
      Imgcodecs.imwrite("E:/OpenCV/chap25/colormap_hot.jpg", dst);
      System.out.println("Image processed");
   }
}
Assume that following is the input image color_input.jpg specified in the above program.
On executing the above program, you will get the following output −
Image Processed

If you open the specified path, you can observe the output image as follows −
In addition to COLORMAP_HOT demonstrated in the previous example, OpenCV caters various other types of color maps. All these types are represented by predefined static fields (fixed values) of Imgproc class.
You can choose the type of the colormap you need, by passing its respective predefined value to the parameter named colormap of the applyColorMap() method.
Imgproc.applyColorMap(src, dst, Imgproc.COLORMAP_HOT);

Following are the values representing various types of color maps and their respective outputs.

    70 Lectures 
     9 hours 

 Abhilash Nelson

    41 Lectures 
     4 hours 

 Abhilash Nelson

    20 Lectures 
     2 hours 

 Spotle Learn

    12 Lectures 
     46 mins

 Srikanth Guskra

    19 Lectures 
     2 hours 

 Haithem Gasmi

    67 Lectures 
     6.5 hours 

 Gianluca Mottola
 Print
 Add Notes
 Bookmark this page
How to limit input text length using CSS3?

With HTML, you can easily limit input length. However, with CSS3, it will not be possible, since CSS can’t be used to limit the number of input characters. This will cause a functional restriction.
CSS deals with presentation i.e. how your web page will look. This is done with HTML attribute malength, since it’s for behavior.
Let’s see how to do it in HTML −
You can try to run the following code to limit input text length
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>HTML maxlength attribute</title>
   </head>
   <body>
      <form action="">
         Student Name<br><input type="text" name="name" maxlength="20"><br><br>
         <input type="submit" value="Submit">
      </form>
   </body>
</html>
DAX Aggregation - COUNTROWS function

Counts the number of rows in the specified table, or in a table defined by an expression.
COUNTROWS (<table>) 

table
The name of the table that contains the rows to be counted, or an expression that returns a table.
Returns a whole number.
This function can be used to count the number of rows in a base table, but more often is used to count the number of rows that result from filtering a table, or applying a context to a table.
= COUNTROWS (CALENDAR (DATE (2016,8,1), DATE (2016,10,31))) returns 92. 
= COUNTROWS (Results) returns 34094. 
= COUNTROWS (Events) returns 995. 
You can use columns containing any type of data, but only blank cells are counted. Cells that have the value zero (0) are not counted, as zero is considered a numeric value and not a blank.
= COUNTBLANK (SalesTarget[SalesTarget])

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
Bash Scripting - Bash Echo Command - GeeksforGeeks

22 Nov, 2021
In this article, we are going to see the echo command. The Echo command is a built-in command feature for Unix / Linux which is generally used to display the text or message on the screen.
Syntax :
$ echo [option]
For Example :
$ echo Geeks For Geeks
Output :
Geeks For Geeks
Output
-n: It does not print the trailing newline.
-E: It is the default option that disables the implementation of escape sequences.
-e: It is used to enable interpretation of backslash escapes
There are some escape sequences performing different operations such as:
Example 1 :
$ echo -e "Geeks \bFor \bGeeks"
Output:
GeeksForGeeks
Output
Example 2 :
$ echo -e "Geeks\nFor\nGeeks"
Output :
Geeks
For  
Geeks
Output
Example 3 :
$ echo -e "Geeks\tFor\tGeeks"
Output :
Geeks   For     Geeks
Output
Example 4 :
$ echo -e "Geeks\\For\\Geeks"  
Output : 
Geeks\For\Geeks
Output
Example 5 :
$ echo -e "Geeks\rFor Geeks"
Output : 
For Geeks
Output
Example 6 :
$ echo -e "Geeks\v For\v Geeks"
Output :
Geeks For Geeks
Output
Example 7 :
$ echo -n "Geeks For Geeks"
Output :
Geeks For Geeks
Output
You can find all the commands related to echo by writing the following command.
$ /bin/echo --help
Output : 
Output
We create a text file named ” userInput.sh ” and write the following code inside the file. 
#!/bin/sh  

echo "Enter Your Name : "

read name     #It take input from user

echo "Hello, $name. Welcome to GeeksForGeeks"
Now run the ” userInput.sh ” with the help of the below code:
$ chmod +x ./userInput.sh
$ ./userInput.sh
Output :
Output
Bash-Script
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
ZIP command in Linux with examples
tar command in Linux with examples
curl command in Linux with Examples
UDP Server-Client implementation in C
Conditional Statements | Shell Script
Tail command in Linux with examples
Mutex lock for Linux Thread Synchronization
echo command in Linux with Examples
tee command in Linux with examples
C# Linq Last() Method

Get the last element from a sequence using the Linq Last() method.
The following is our array.
int[] val = { 10, 20, 30, 40 };
Now, get the last element.
val.AsQueryable().Last();
 Live Demo
using System;
using System.Collections.Generic;
using System.Linq;
class Demo {
   static void Main() {
      int[] val = { 10, 20, 30, 40 };
      // getting last element
      int last_num = val.AsQueryable().Last();
      Console.WriteLine("Last element: "+last_num);
   }
}
Last element: 40
JSTL - fn:indexOf() Function

The fn:indexOf() function returns the index within a string of a specified substring.
The fn:indexOf() function has the following syntax −
int indexOf(java.lang.String, java.lang.String)

Following is the example to explain the functionality of the fn:indexOf() function −
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<%@ taglib uri = "http://java.sun.com/jsp/jstl/functions" prefix = "fn" %>

<html>
   <head>
      <title>Using JSTL Functions</title>
   </head>

   <body>
      <c:set var = "string1" value = "This is first String."/>
      <c:set var = "string2" value = "This <abc>is second String.</abc>"/>
      <p>Index (1) : ${fn:indexOf(string1, "first")}</p>
      <p>Index (2) : ${fn:indexOf(string2, "second")}</p>

   </body>
</html>
You will receive the following result −
Index (1) : 8
Index (2) : 13


    108 Lectures 
     11 hours 

 Chaand Sheikh

    517 Lectures 
     57 hours 

 Chaand Sheikh

    41 Lectures 
     4.5 hours 

 Karthikeya T

    42 Lectures 
     5.5 hours 

 TELCOMA Global

    15 Lectures 
     3 hours 

 TELCOMA Global

    44 Lectures 
     15 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Javascript search for an object key in a set

The Set class in JavaScript provides a has method to search elements in a given set object. In case you want to search for a object in a set, you need to provide the reference to that object. Identical objects with different memory addresses are not considered equal. This method can be used as follows −
let mySet = new Set();
let myObj = {name: "John"}
mySet.add(1);
mySet.add(3);
mySet.add("a");
mySet.add(myObj);
console.log(mySet)
console.log(mySet.has(myObj))
// Considered as a new object
console.log(mySet.has({name: "John"}))
Set { 1, 2, 3, 'a' }
true
false
How to work with Mouse Events using OpenCV in C++?

Mouse Events is one of the most useful features of OpenCV. In OpenCV, we can track the mouse pointer's position and track the clicks (right, left and middle-click). OpenCV has a wide application in robotics and computer vision. In robotics and computer vision tracking mouse pointer and clicks are frequently used.
Here we will understand how to track the mouse pointer's location on an image and track the clicks.
The following program demonstrates how to track the location of the mouse pointer and clicks.
#include<iostream>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
using namespace std;
using namespace cv;
void locator(int event, int x, int y, int flags, void* userdata){ //function to track mouse movement and click//
   if (event == EVENT_LBUTTONDOWN){ //when left button clicked//
      cout << "Left click has been made, Position:(" << x << "," << y << ")" << endl;
   } else if (event == EVENT_RBUTTONDOWN){ //when right button clicked//
      cout << "Rightclick has been made, Position:(" << x << "," << y << ")" << endl;
   } else if (event == EVENT_MBUTTONDOWN){ //when middle button clicked//
      cout << "Middleclick has been made, Position:(" << x << "," << y << ")" << endl;
   } else if (event == EVENT_MOUSEMOVE){ //when mouse pointer moves//
      cout << "Current mouse position:(" << x << "," << y << ")" << endl;
   }
}
int main() {
   Mat image = imread("bright.jpg");//loading image in the matrix//
   namedWindow("Track");//declaring window to show image//
   setMouseCallback("Track", locator, NULL);//Mouse callback function on define window//
   imshow("Track", image);//showing image on the window//
   waitKey(0);//wait for keystroke//
   return 0;
}
GATE | GATE-CS-2004 | Question 69 - GeeksforGeeks

07 Nov, 2019
A 4-stage pipeline has the stage delays as 150, 120, 160 and 140 nanoseconds respectively. Registers that are used between the stages have a delay of 5 nanoseconds each. Assuming constant clocking rate, the total time taken to process 1000 data items on this pipeline will be(A) 120.4 microseconds(B) 160.5 microseconds(C) 165.5 microseconds(D) 590.0 microsecondsAnswer: (C)Explanation:
Delay between each stage is 5 ns.

Total delay for 1st data item = 165*4
                              = 660 
For 1000 data items, first data will take 660 ns to complete and rest 
999 data will take max of all the stages that is 160 ns + 5 ns register delay

Total Delay = 660 + 999*165 ns which is equal to 165.5 microsecond. 
Quiz of this Question
manikshekhar15
GATE-CS-2004
GATE-GATE-CS-2004
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-IT-2004 | Question 71
GATE | GATE CS 2011 | Question 7
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE CS 2010 | Question 24
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2016 (Set 1) | Question 65
GATE | GATE-IT-2004 | Question 83
GATE | GATE-CS-2007 | Question 64
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | GATE CS 2019 | Question 27
ISRO | ISRO CS 2015 | Question 13 - GeeksforGeeks

03 Apr, 2018
Six files F1, F2, F3, F4, F5 and F6 have 100, 200, 50, 80, 120, 150 records respectively. In what order should they be stored so as to optimize act. Assume each file is accessed with the same frequency(A) F3, F4, F1, F5, F6, F2(B) F2, F6, F5, F1, F4, F3(C) F1, F2, F3, F4, F5, F6(D) Ordering is immaterial as all files are accessed with the same frequency.Answer: (A)Explanation:
This question is based on the Optimal Storage on Tape problem
which uses greedy approach to find the optimal time to retrieve them.
There are n programs of length L that are to be stored on a computer
tape. Associated with each program i is a length Li. So in order to
retrieve these programs most optimally, we need to store them in the
non-decreasing order of length Li.
So, the correct order is F3, F4, F1, F5, F6, F2
Quiz of this QuestionPlease comment below if you find anything wrong in the above post
ISRO
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ISRO | ISRO CS 2011 | Question 26
ISRO | ISRO CS 2017 - May | Question 21
ISRO | ISRO CS 2013 | Question 54
ISRO | ISRO CS 2011 | Question 13
ISRO | ISRO CS 2008 | Question 1
ISRO | ISRO CS 2013 | Question 4
ISRO | ISRO CS 2016 | Question 49
ISRO | ISRO CS 2018 | Question 10
ISRO | ISRO CS 2016 | Question 41
ISRO | ISRO CS 2018 | Question 17
Java Program to shift array elements to the right

Let us first create an int array −
int[] arr = { 10, 20, 30, 40, 50, 60, 70, 80, 90 };
Now, shift array elements to the right with arraycopy() and placing the elements correctly so that it gets shifted to the right −
System.arraycopy(arr, 0, arr, 1, arr.length - 1);
 Live Demo
import java.util.Arrays;
public class Demo {
   public static void main(String[] argv) throws Exception {
      int[] arr = { 10, 20, 30, 40, 50, 60, 70, 80, 90 };
      System.out.println("Initial array...\n"+Arrays.toString(arr));
      System.arraycopy(arr, 0, arr, 1, arr.length - 1);
      System.out.println("Array after shifting to the right...");
      System.out.println(Arrays.toString(arr));
   }
}
Initial array...
[10, 20, 30, 40, 50, 60, 70, 80, 90]
Array after shifting to the right...
[10, 10, 20, 30, 40, 50, 60, 70, 80]
Hiding of all overloaded methods in base class in C++

In C++, we can use the function overloading techniques. But if some base class has one method in overloaded form (different function signature with the same name), and the derived class redefines one of the function which is present inside the base, then all of the overloaded version of that function will be hidden from the derived class.
Let us see one example to get the clear idea.
#include <iostream>
using namespace std;
class MyBaseClass {
   public:
      void my_function() {
         cout << "This is my_function. This is taking no arguments" << endl;
      }
      void my_function(int x) {
         cout << "This is my_function. This is taking one argument x" << endl;
      }
};
class MyDerivedClass : public MyBaseClass {
   public:
      void my_function() {
         cout << "This is my_function. From derived class, This is taking no arguments" << endl;
      }
};
main() {
   MyDerivedClass ob;
   ob.my_function(10);
}
[Error] no matching function for call to 'MyDerivedClass::my_function(int)'
[Note] candidate is:
[Note] void MyDerivedClass::my_function()
[Note] candidate expects 0 arguments, 1 provided
Delete Dictionary Elements in Python

You can either remove individual dictionary elements or clear the entire contents of a dictionary. You can also delete entire dictionary in a single operation.
To explicitly remove an entire dictionary, just use the del statement.
Following is a simple example −
 Live Demo
#!/usr/bin/python
dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}
del dict['Name']; # remove entry with key 'Name'
dict.clear(); # remove all entries in dict
del dict ; # delete entire dictionary
print "dict['Age']: ", dict['Age']
print "dict['School']: ", dict['School']
This produces the following result. Note that an exception is raised because after del dict dictionary does not exist any more −
dict['Age']:
Traceback (most recent call last):
File "test.py", line 8, in <module>
print "dict['Age']: ", dict['Age'];
TypeError: 'type' object is unsubscriptable
Note − del() method is discussed in subsequent section.
How to install pandas using the python package manager?

A package is a bundle of modules, to be installed into a Python environment. And typically, this would include things like third-party libraries and frameworks.
Package Managers are tools that help you manage the dependencies for your project implementation. For python-pip is the package manager provided by default with the rest of the Python standard library and things like the Python interpreter, pip’s main interface is a command-line tool.
pip is written in Python which is used to install and manage software packages. as we know that pip is available by default with python, so we no need to install it again, because it is already installed. And it has a feature to manage full lists of packages and corresponding version numbers
pip installs packages like TensorFlow and NumPy, pandas and sklearn, and many more, along with their dependencies.
To install the pandas package by using pip we have to open the command prompt in our system (assuming, our machine is a windows operating system).
pip install pandas
This command will install the pandas package as well as it will also install all the dependencies of our pandas package.
If you want to install any particular version of the pandas package, we can give the below command −
pip install pandas==1.2.2
In some situations, we need to upgrade the python package manager to get the latest version of packages then we can use the below command in our command prompt.
python -m pip install --upgrade pip
Every time, when you try to install any package, initially pip will check for the package dependencies if they are already installed on the system or not. if not, it will install them. Once all dependencies have been satisfied, it proceeds to install the requested package(s).
How can I remove a value from an enum in MySQL?

Use ALTER command to remove a value from an enum in MySQL. Let us first create a table −
mysql> create table DemoTable
   (
   `Rank` ENUM('LOW','MEDIUM','HIGH')
   );
Query OK, 0 rows affected (0.52 sec)
Let us check the description of table.
mysql> DESC DemoTable;
This will produce the following output −
+-------+-----------------------------+------+-----+---------+-------+
| Field | Type                        | Null | Key | Default | Extra |
+-------+-----------------------------+------+-----+---------+-------+
| Rank  | enum('LOW','MEDIUM','HIGH') | YES  |     | NULL    |       |
+-------+-----------------------------+------+-----+---------+-------+
1 row in set (0.00 sec)
Following is the query to remove a value from an enum in MySQL.
mysql> alter table DemoTable change `Rank` `Rank` ENUM('LOW','HIGH');
Query OK, 0 rows affected (1.19 sec)
Records: 0 Duplicates: 0 Warnings: 0
Now let us check the description of table once again −
mysql> DESC DemoTable;
This will produce the following output −
+-------+--------------------+------+-----+---------+-------+
| Field | Type               | Null | Key | Default | Extra |
+-------+--------------------+------+-----+---------+-------+
| Rank | enum('LOW','HIGH') | YES | | NULL | |
+-------+--------------------+------+-----+---------+-------+
1 row in set (0.00 sec)
Scraping Tables from PDF Files Using Python | Towards Data Science

Fetching tables from PDF files is no more a difficult task, you can do this using a single line in python.
Installing a tabula-py library.Importing library.Reading a PDF file.Reading a table on a particular page of a PDF file.Reading multiple tables on the same page of a PDF file.Converting PDF files directly to a CSV file.
Installing a tabula-py library.
Importing library.
Reading a PDF file.
Reading a table on a particular page of a PDF file.
Reading multiple tables on the same page of a PDF file.
Converting PDF files directly to a CSV file.
Tabula is one of the useful packages which not only allows you to scrape tables from PDF files but also convert a PDF file directly into a CSV file.
pip install tabula-py
import tabula
lets scrap this PDF into pandas Data Frame.
file1 = "https://nbviewer.jupyter.org/github/kuruvasatya/Scraping-Tables-from-PDF/blob/master/data1.pdf"table = tabula.read_pdf(file1,pages=1)table[0]
Take a look at the output of above code snippet executed in Google Colabs
let say we need to scrap this PDF FILE which contains multiple pages in it.
file2 = "https://nbviewer.jupyter.org/github/kuruvasatya/Reading-Table-Data-From-PDF/blob/master/data.pdf"# To read table in first page of PDF filetable1 = tabula.read_pdf(file2 ,pages=1)# To read tables in secord page of PDF filetable2 = tabula.read_pdf(file2 ,pages=2)print(table1[0])print(table2[0])
let's say we need to scrape these 2 tables which are on the same page of a PDF file.
To read multiple tables we need to add extra parametermultiple_tables = True -> Read multiple tables as independent tablesmultiple_tables = False -> Read multiple tables as single table
file3 = "https://nbviewer.jupyter.org/github/kuruvasatya/Reading-Table-Data-From-PDF/blob/master/data3.pdf"tables = tabula.read_pdf(file3 ,pages=1, multiple_tables=True)print(tables[0])print(tables[1])
tables = tabula.read_pdf(file3 ,pages=1,multiple_tables=False)tables[0]
we can directly convert a PDF file containing tabular data directly to a CSV file using convert_into() method in tabula library.
# output just the first page tables in the PDF to a CSVtabula.convert_into("pdf_file_name", "Name_of_csv_file.csv")
tabula.convert_into("pdf_file_name","Name_of_csv_file.csv",all = True)
I hope you learned a great way to scrape PDF file tables using a single line in python.
Check out my related articles
C program that does not suspend when Ctrl+Z is pressed

In Programing when a program malfunction and runs unusually in the terminal compiler the programmer has the power to explicitly stop the program from running. For explicitly stopping the program, the user must know the right keyboard shortcut that is needed to be pressed.
To terminate the execution of a block of code, there are two types of keyboard shortcuts used.
Ctrl+c − It is used to stop the execution of the program, it take a bit of time to complete the i/o operations and then suspends the execution. It sends a SIGINT signal to the process which gets terminated. In some languages, there are ways to handle this SIGINT like the signal function in C.
Ctrl+c − It is used to stop the execution of the program, it take a bit of time to complete the i/o operations and then suspends the execution. It sends a SIGINT signal to the process which gets terminated. In some languages, there are ways to handle this SIGINT like the signal function in C.
Ctrl+z − It is used to stop the execution of the program, all the tasks related to the process are shut and execution is suspended. It sends a SINTSTP signal to the process which terminates the program though the implementation is the same but this signal is more powerful as compared to others. This can also be handled.
Ctrl+z − It is used to stop the execution of the program, all the tasks related to the process are shut and execution is suspended. It sends a SINTSTP signal to the process which terminates the program though the implementation is the same but this signal is more powerful as compared to others. This can also be handled.
Here, we will write a code that will be able to surpass the ctrl+z call. And instead of getting suspended the program will print “ctrl+z cannot suspend this code”.
As discussed above, the ctrl+z call can be handled in the C programming language. When the SINTSTP signal is invoked to end the process of the program. We will redefine what this signal does so that I will not terminate the code and print a line when used.
The signal() method is used to handle this type of thing.
 Live Demo
#include <stdio.h>
#include <signal.h>
void signalhandler(int sig_num){
   signal(SIGTSTP, signalhandler);
   printf("Cannot execute Ctrl+Z\n");
}
int main(){
   int a = 1;
   signal(SIGTSTP, signalhandler);
   while(a){
   }
   return 0;
}
// an infinite loop
Example of goto in C or C++

The goto statement is a jump statement that allows the program control to jump from goto to a label. Using the goto statement is frowned upon as it makes the program convoluted and hard to understand.
The following is the syntax of goto statement.
goto label;
.
.
.
label: statements;
A program that demonstrates the goto statement in C++ is given as follows.
 Live Demo
#include <iostream>
using namespace std;
int main () {
   int i = 1;
   while(1) {
      cout<< i <<"\n";
      if(i == 10)
      goto OUT;
      i++;
   }
   OUT: cout<<"Out of the while loop";
   return 0;
}
The output of the above program is as follows.
1
2
3
4
5
6
7
8
9
10
Out of the while loop
Now, let us understand the above program.
A while loop is used in the above program. In each pass of the while loop, the value of i is displayed. Then, if statement is used to check if the value of i is 10. If so, then goto statement is used to leave the while loop. Otherwise, i is incremented by 1.
The label used with the goto statement is OUT and it leads the program control out of the while loop. Then "Out of the while loop" is displayed. The code snippet for this is given as follows.
int i = 1;
while(1) {
   cout<< i <<"\n";
   if(i == 10)
   goto OUT;
   i++;
}
OUT: cout<<"Out of the while loop";
Node.js process.title Property - GeeksforGeeks

12 Oct, 2021
The process.title property is an inbuilt application programming interface of the process module which is used to get and set the title of the process.
Syntax:
process.title
Return Value: This property returns a string value that specifies the title of the process, current value is ‘ps’.
Note: Assigning the new value to this property will modify the current value. The different platforms can impose a restriction on the maximum length of process title.
Below examples illustrate the use of process.title property in Node.js:
Example 1:
// Node.js program to demonstrate the    // process.title property  // Include process moduleconst process = require('process');  // Printing process.title property valueconsole.log("PID: " + process.pid +       " process title is " + process.title);
Output:
PID: 8852 process title is Command Prompt - node  title_1

Example 2:
// Node.js program to demonstrate the    // process.title property  // Include process moduleconst process = require('process');  // Printing process.title property valueconsole.log("Before modification: PID: " + process.pid          +" process title is " + process.title);  // Setting new process title valueprocess.title = "gekchosCustomProcess";  // Printing process.title value after modificationconsole.log("After modification: PID: " + process.pid          + " process title is " + process.title);
Output:
Before modification: PID: 14012 process title is Command Prompt - node  title_2
After modification: PID: 14012 process title is gekchosCustomProcess

Note: The above program will compile and run by using the node filename.js command.
Reference: https://nodejs.org/api/process.html#process_process_title
Node.js-process-module
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Express.js express.Router() Function
JWT Authentication with Node.js
Express.js req.params Property
Mongoose Populate() Method
Difference between npm i and npm ci in Node.js
Roadmap to Become a Web Developer in 2022
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Convert a string to an integer in JavaScript
Python – Random range in list

11 Oct, 2020
Given a List, extract random range from it. 
Input : test_list = [3, 19, 4, 8, 10, 13, 5, 7, 2, 1, 4] Output : [5, 7, 2, 1] Explanation : A random range elements are extracted of any length.
Input : test_list = [3, 19, 4, 8, 10, 13, 5, 7, 2, 1, 4] Output : [4, 8] Explanation : A random range elements are extracted of any length. 
Method : Using randrange() + slicing
randrange(): Python offers a function that can generate random numbers from a specified range and also allowing rooms for steps to be included, called randrange() in random module.
In this, we extract index of list, and for first index, and then again employ the function to get end part of range using randrange() from start index to list length. The range is extracted using slicing.
Python3
# Python3 code to demonstrate working of# Random range in list# Using randrange() + slicingimport random    # function to Random range in listdef rabdomRangeList(test_list):    # getting ranges    strt_idx = random.randrange(0, len(test_list) - 1)    end_idx = random.randrange(strt_idx, len(test_list) - 1)      # getting range elements    res = test_list[strt_idx: end_idx]      return str(res)    # Driver Code# initializing listinput_list1 = [3, 19, 4, 8, 10, 13, 5, 7, 2, 1, 4]  # printing original listprint("\nThe original list is : ", input_list1)  # printing resultprint("Required List : " + rabdomRangeList(input_list1))    # initializing listinput_list2 = [3, 19, 4, 8, 10, 13, 5, 7, 2, 1, 4]  # printing original listprint("\nThe original list is : ", input_list2)  # printing resultprint("Required List : " + rabdomRangeList(input_list2))    # initializing listinput_list3 = [3, 19, 4, 8, 10, 13, 5, 7, 2, 1, 4]  # printing original listprint("\nThe original list is : ", input_list3)  # printing resultprint("Required List : " + rabdomRangeList(input_list3))
Output:
The original list is :  [3, 19, 4, 8, 10, 13, 5, 7, 2, 1, 4]
Required List : [19]

The original list is :  [3, 19, 4, 8, 10, 13, 5, 7, 2, 1, 4]
Required List : [10, 13, 5, 7]

The original list is :  [3, 19, 4, 8, 10, 13, 5, 7, 2, 1, 4]
Required List : []
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
vector :: cbegin() and vector :: cend() in C++ STL

09 Jun, 2022
Vectors are known as dynamic arrays which can change its size automatically when an element is inserted or deleted. This storage is maintained by container.
The function returns an iterator which is used to iterate container.
The iterator points to the beginning of the vector.
Iterator cannot modify the contents of the vector.
Syntax:
vectorname.cbegin()
Parameters: There is no parameter Return value: Constant random access iterator points to the beginning of the vector. Exception: No exception
Time Complexity – constant O(1)
Below program(s) illustrate the working of the function 
CPP
// CPP program to illustrate// use of cbegin()#include <iostream>#include <string>#include <vector> using namespace std; int main(){    vector<string> vec;     // 5 string are inserted    vec.push_back("first");    vec.push_back("second");    vec.push_back("third");    vec.push_back("fourth");    vec.push_back("fifth");     // displaying the contents    cout << "Contents of the vector:" << endl;    for (auto itr = vec.cbegin();         itr != vec.end();         ++itr)        cout << *itr << endl;     return 0;}
Output:
Contents of the vector:
first
second
third
fourth
fifth
The function returns an iterator which is used to iterate container.
The iterator points to past-the-end element of the vector.
Iterator cannot modify the contents of the vector.
Syntax:
vectorname.cend()
Parameters: There is no parameter Return value: Constant random access iterator points to past-the-end element of the vector. Exception: No exception
Time Complexity – constant O(1)
Below program(s) illustrate the working of the function 
CPP
// CPP programto illustrate// functioning of cend()#include <iostream>#include <string>#include <vector> using namespace std; int main(){    vector<string> vec;     // 5 string are inserted    vec.push_back("first");    vec.push_back("second");    vec.push_back("third");    vec.push_back("fourth");    vec.push_back("fifth");     // displaying the contents    cout << "Contents of the vector:" << endl;    for (auto itr = vec.cend() - 1;         itr >= vec.begin();         --itr)        cout << *itr << endl;     return 0;}
Output:
Contents of the vector:
fifth
fourth
third
second
first
utkarshgupta110092
cpp-vector
C++
Technical Scripter
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Sorting a vector in C++
Polymorphism in C++
std::string class in C++
Friend class and function in C++
Pair in C++ Standard Template Library (STL)
Queue in C++ Standard Template Library (STL)
Unordered Sets in C++ Standard Template Library
std::find in C++
List in C++ Standard Template Library (STL)
Inline Functions in C++
numpy.multiply() in Python

16 May, 2020
numpy.multiply() function is used when we want to compute the multiplication of two array. It returns the product of arr1 and arr2, element-wise.
Syntax : numpy.multiply(arr1, arr2, /, out=None, *, where=True, casting=’same_kind’, order=’K’, dtype=None, subok=True[, signature, extobj], ufunc ‘multiply’)
Parameters :arr1: [array_like or scalar]1st Input array.arr2: [array_like or scalar]2nd Input array.dtype: The type of the returned array. By default, the dtype of arr is used.out: [ndarray, optional] A location into which the result is stored.  -> If provided, it must have a shape that the inputs broadcast to.  -> If not provided or None, a freshly-allocated array is returned.where: [array_like, optional] Values of True indicate to calculate the ufunc at that position, values of False indicate to leave the value in the output alone.**kwargs: Allows to pass keyword variable length of argument to a function. Used when we want to handle named argument in a function.
Return: [ndarray or scalar] The product of arr1 and arr2, element-wise.
Example #1 :
# Python program explaining# numpy.multiply() function  import numpy as geekin_num1 = 4in_num2 = 6  print ("1st Input  number : ", in_num1)print ("2nd Input  number : ", in_num2)    out_num = geek.multiply(in_num1, in_num2) print ("output number : ", out_num) 
1st Input number :  4
2nd Input number :  6
output number :  24

 
Example #2 :The following code is also known as the Hadamard product which is nothing but the element-wise-product of the two matrices. It is the most commonly used product for those who are interested in Machine Learning or statistics.
# Python program explaining# numpy.multiply() function  import numpy as geek  in_arr1 = geek.array([[2, -7, 5], [-6, 2, 0]])in_arr2 = geek.array([[0, -7, 8], [5, -2, 9]])   print ("1st Input array : ", in_arr1)print ("2nd Input array : ", in_arr2)       out_arr = geek.multiply(in_arr1, in_arr2) print ("Resultant output array: ", out_arr) 
1st Input array :  [[ 2 -7  5]
 [-6  2  0]]
2nd Input array :  [[ 0 -7  8]
 [ 5 -2  9]]
Resultant output array:  [[  0  49  40]
 [-30  -4   0]]

Another way to find the same is
import numpy as geekin_arr1=geek.matrix([[2, -7, 5], [-6, 2, 0]])in_arr2 = geek.matrix([[0, -7, 8], [5, -2, 9]])    print ("1st Input array : ", in_arr1)print ("2nd Input array : ", in_arr2)   out_arr=geek.array(in_arr1)*geek.array(in_arr2)print ("Resultant output array: ", out_arr)
Output :
1st Input array :  [[ 2 -7  5]
 [-6  2  0]]
2nd Input array :  [[ 0 -7  8]
 [ 5 -2  9]]
Resultant output array:  [[  0  49  40]
 [-30  -4   0]]

riasehgal1999
Python numpy-Mathematical Function
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.