code-rag-bench/online-tutorials huggingface dataset:
Internal working of list in Python

09 Dec, 2021
Introduction to Python lists : Python lists are internally represented as arrays. The idea used is similar to implementation of vectors in C++ or ArrayList in Java. The costly operations are inserting and deleting items near the beginning (as everything has to be moved). Insert at the end also becomes costly if preallocated space becomes full.We can create a list in python as shown below.Example:  
Python3
list1 = [1, 2, 3, 4]
We can access each element of a list in python by their assigned index. In python starting index of list sequence is 0 and ending index is (if N elements are there) N-1. 
Also as shown in above array lists also have negative index starting from -N (if N elements in the list) till -1.Viewing the elements of List in Python : Individual items of a list can be accessed through their indexes as done in below code segment.  
Python3
list1 = [1, 2, 3, 4] # for printing only one item from a listprint(list1[1]) # to print a sequence of item in a list# we use ':' value before this is starting# and value after that tells ending of sequenceprint(list1[1:4]) # accessing through negative indexprint(list1[-1])
Assigning and Accessing data: For creating a list we need to specify the elements inside square brackets ‘[]’ and then give it a name. Whenever you want to access the list elements then use this list name and index of element you want to show. Each element in list is assigned an index in positive indexing we have index from 0 to end of the list and in negative indexing we have index from -N(if elements are N) till -1. As shown in above examples the work of accessing elements is manual. We can also access or assign elements through loops. 
Python3
# assigning elements to listlist1 =[]for i in range(0, 11):     list1.append(i) # accessing elements from a listfor i in range(0, 11):     print(list1[i])
Updating list: We can update already assigned elements to the list and also can append one element at a time to your list.Even you can extend your list by adding another list to current list. The above task can be performed as follows. 
Python3
list1 =[1, 2, 3, 4] # updatinglist1[2]= 5print(list1) # appendinglist1.append(6)print(list1) # extendinglist1.extend([1, 2, 3])print(list1)
Note: append() and extend() are built in methods in python for lists.Deleting elements of list : We can delete elements in lists by making use of del function. In this you need to specify the position of element that is the index of the element and that element will be deleted from the list and index will be updated. 
In above shown image the element 3 in index 2 has been deleted and after that index has been updated. 
Python3
list1 = [1, 2, 3, 4, 5]print(list1) # deleting elementdel list1[2]print(list1)
Time Complexities of Operations  
Source : Python WikiPython list and its operations. 
sweetyty
Picked
python-list
Python
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Get video duration using Python – OpenCV

02 Dec, 2020
Prerequisites: 
Opencv module
datetime module
OpenCV is one of the most popular cross-platform libraries and it is widely used in Deep Learning, image processing, video capturing, and many more. In this article, we will learn how to get the duration of a given video using python and computer vision. 
Opencv can be downloaded by running the given command on the terminal:
pip install Opencv
To get the duration of a video, following steps has to be followed:
Import required modules.
Create a VideoCapture object  by providing video URL to VideoCapture() method.
Syntax:
VideoCapture("url")
Count the total numbers of frames and frames per second of a given video by providing  cv2.CAP_PROP_FRAME_COUNT and cv2.CAP_PROP_FPS to get() method.
Calculate the duration of the video in seconds by dividing frames and fps.
Also, calculate video time using timedelta() method.
Syntax:
timedelta(time)
Below is the implementation.
Python3
# import moduleimport cv2import datetime  # create video capture objectdata = cv2.VideoCapture('C:/Users/Asus/Documents/videoDuration.mp4')  # count the number of framesframes = data.get(cv2.CAP_PROP_FRAME_COUNT)fps = int(data.get(cv2.CAP_PROP_FPS))  # calculate dusration of the videoseconds = int(frames / fps)video_time = str(datetime.timedelta(seconds=seconds))print("duration in seconds:", seconds)print("video time:", video_time)
Output :
duration in seconds: 32
video time: 0:00:28
Python-OpenCV
Technical Scripter 2020
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Intersection of two arrays in Python ( Lambda expression and filter function )

20 Oct, 2018
Given two arrays, find their intersection.
Examples:
Input:  arr1[] = [1, 3, 4, 5, 7]
        arr2[] = [2, 3, 5, 6]
Output: Intersection : [3, 5]

We have existing solution for this problem please refer Intersection of two arrays link. We will solve this problem quickly in python using Lambda expression and filter() function.
# Function to find intersection of two arrays  def interSection(arr1,arr2):       # filter(lambda x: x in arr1, arr2)  -->     # filter element x from list arr2 where x     # also lies in arr1     result = list(filter(lambda x: x in arr1, arr2))      print ("Intersection : ",result)  # Driver programif __name__ == "__main__":    arr1 = [1, 3, 4, 5, 7]    arr2 = [2, 3, 5, 6]    interSection(arr1,arr2)
Output:
Intersection : [3, 5]

python-lambda
python-list
Arrays
Python
python-list
Arrays
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
autoreconf command in Linux with examples

03 Jun, 2021
autoreconf is a Autotool which is used to create automatically buildable source code for Unix-like systems. Autotool is a common name for autoconf, automake, etc. These all together are termed as Autotools. 
Important Points: 
 
Provides Portability of source code packages by automatic buildable capability.
Provides common build facilities like make install.
Automatic dependency generation for C/C++.
Syntax: 
 
autoreconf [OPTION]... [DIRECTORY]...
Options: 
 
-h, –help : Print the help message and exit.
-V, –version : Used to show the version number, and then exit.
-v, –verbose : Verbosely report processing.
-d, –debug : Don’t remove temporary files.
-f, –force : This option is used to consider all files obsolete.
-i, –install : Copy missing auxiliary files.
–no-recursive : Don’t rebuild sub-packages.
-s, –symlink : With -i option it is used to install symbolic links instead of copies.
-m, –make : When applicable, re-run ./configure && make.
Note: Autotools are used to make automatically buildable source code for distribution purpose. 
Important Configuration Files: 
 
configure.ac : Describes configuration for autoreconf.
Makefile.am : Describes sources of program files and compiler flags for automake.Step 1: Make a directory and a C program file.  
Step 1: Make a directory and a C program file.  
 
Hello, World Program  
Hello, World Program 
 
#include
void main()
{
   printf("Hello, World");
}
 
 
Step 2: Make a configure.ac file for autoreconf.  
 
# initialize the process
AC_INIT([hello], [0.01])
# make config headers
AC_CONFIG_HEADERS([config.h])
#Auxiliary files go here
AC_CONFIG_AUX_DIR([build-aux])
# init automake
AM_INIT_AUTOMAKE([1.11])
#configure and create "Makefile"
AC_CONFIG_FILES([Makefile])
#find and probe C compiler
AC_PROG_CC
#End
AC_OUTPUT
 
 
Step 3: Make a Makefile.am for automake.  
 
#list of programs to be installed in bin directory
bin_PROGRAMS = hello
#sources for targets
hello_SOURCES = hello.c
 
 
Step 4: Run the following commands on terminal. It will give an error because it is for distribution purpose and VCS(Version Control System) should have some standard license files.  
 
 
 
Step 5: Lets make license files.  
 
Step 6: Retry  
 
 
 
Step 6: Now, Let’s run the program. See, now Hello, World is printed on the screen  
 
nidhi_biet
adnanirshad158
linux-command
Linux-system-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Get SubList from LinkedList in Java

The subList of a LinkedList can be obtained using the java.util.LinkedList.subList(). This method takes two parameters i.e. the start index for the sub-list(inclusive) and the end index for the sub-list(exclusive) from the required LinkedList. If the start index and the end index are the same, then an empty sub-list is returned.
A program that demonstrates this is given as follows −
 Live Demo
import java.util.LinkedList;
import java.util.List;
public class Demo {
   public static void main(String[] args) {
      LinkedList<String> l = new LinkedList<String>();
      l.add("John");
      l.add("Sara");
      l.add("Susan");
      l.add("Betty");
      l.add("Nathan");
      System.out.println("The LinkedList is: " + l);
      List subl = l.subList(1, 3);
      System.out.println("The SubList is: " + subl);
   }
}
The LinkedList is: [John, Sara, Susan, Betty, Nathan]
The SubList is: [Sara, Susan]
Now let us understand the above program.
The LinkedList l is created. Then LinkedList.add() is used to add the elements to the LinkedList. Then the LinkedList is displayed. A code snippet which demonstrates this is as follows −
LinkedList<String> l = new LinkedList<String>();
l.add("John");
l.add("Sara");
l.add("Susan");
l.add("Betty");
l.add("Nathan");
System.out.println("The LinkedList is: " + l);
The LinkedList.subList() method is used to create a sub-list which contains the elements from index 1(inclusive) to 3(exclusive) of the LinkedList. Then the sub-list elements are displayed. A code snippet which demonstrates this is as follows −
List subl = l.subList(1, 3);
System.out.println("The SubList is: " + subl);
PHP | array_pop() Function - GeeksforGeeks

18 Nov, 2019
This inbuilt function of PHP is used to delete or pop out and return the last element from an array passed to it as parameter. It reduces the size of the array by one since the last element is removed from the array.
Syntax:
array_pop($array)
Parameters: The function takes only one parameter $array, that is the input array and pops out the last element from it, reducing the size by one.
Return Value: This function returns the last element of the array. If the array is empty or the input parameter is not an array, then NULL is returned.
Note: This function resets the (reset()) the array pointer of the input array after use.
Examples:
Input : $array = (1=>"ram", 2=>"krishna", 3=>"aakash");
Output : aakash

Input : $array = (24, 48, 95, 100, 120);
Output : 120

Below programs illustrate the array_pop() function in PHP:
Example 1
<?php// PHP code to illustrate the use of array_pop()  $array = array(1=>"ram", 2=>"krishna", 3=>"aakash");  print_r("Popped element is ");echo array_pop($array);  print_r("\nAfter popping the last element, ".                "the array reduces to: \n");print_r($array);?>
Output:
Popped element is aakash
After popping the last element, the array reduces to: 
Array
(
    [1] => ram
    [2] => krishna
)

Example 2
<?php$arr = array(24, 48, 95, 100, 120);  print_r("Popped element is ");echo array_pop($arr);  print_r("\nAfter popping the last element, ".                "the array reduces to: \n");print_r($arr);?>
Output:
Popped element is 120
After popping the last element, the array reduces to: 
Array
(
    [0] => 24
    [1] => 48
    [2] => 95
    [3] => 10
)


Exception: An E_WARNING exception is thrown if a non-array is passed which is a runtime error or warning. This warning will not stop the execution of script.
Reference:http://php.net/manual/en/function.array-pop.php
Akanksha_Rai
PHP-array
PHP-function
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
PHP | Converting string to Date and DateTime
Download file from URL using PHP
How to fetch data from localserver database and display on HTML table using PHP ?
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?
Protected vs Private Access Modifiers in Java - GeeksforGeeks

28 Apr, 2021
Access modifiers are those elements in code that determine the scope for that variable. As we know there are three access modifiers available namely public, protected, and private. Let us see the differences between Protected and Private access modifiers. 
Access Modifier 1: Protected
The methods or variables declared as protected are accessible within the same package or different packages. By using protected keywords, we can declare the methods/variables protected.
Syntax:
protected void method_name(){

......code goes here..........

}
Example:
Java
// Java Program to illustrate Protected Access Modifier   // Importing input output classesimport java.io.*;  // Main class public class Main {    // Input custom string   protected String name = "Geeks for Geeks";      // Main driver method   public static void main(String[] args) {          // Creating an object of Main class     Main obj1 = new Main();          // Displaying the object content as created    // above of Main class itself      System.out.println( obj1.name );     }}
Geeks for Geeks
Access Modifier 2: Private 
The methods or variables that are declared as private are accessible only within the class in which they are declared. By using private keyword we can set methods/variables private.
Syntax: 
private void method_name(){

......code goes here..........

}
Example:
Java
// Java Program to illustrate Private Access Modifier  // Importing input output classesimport java.io.*;  // Main classpublic class Main {      // Input custom string    private String name = "Geeks for Geeks";      // Main driver method    public static void main(String[] args)    {          // Creating an object of Main class        Main obj1 = new Main();          // Displaying the object content as created        // above of Main class itself        System.out.println(obj1.name);    }}
Geeks for Geeks
Now after having an understanding of the internal working of both of them let us come to conclude targeted major differences between these access modifiers. 
Java-Modifier
Picked
Difference Between
Java
Java
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
Difference Between Method Overloading and Method Overriding in Java
Difference Between Spark DataFrame and Pandas DataFrame
Difference between Internal and External fragmentation
Difference between Top down parsing and Bottom up parsing
Arrays in Java
Split() String method in Java with examples
For-each loop in Java
Reverse a string in Java
HashMap in Java with Examples
Data Structures | Heap | Question 4 - GeeksforGeeks

28 Jun, 2021
Suppose the elements 7, 2, 10 and 4 are inserted, in that order, into the valid 3- ary max heap found in the above question, Which one of the following is the sequence of items in the array representing the resultant heap?
(A) 10, 7, 9, 8, 3, 1, 5, 2, 6, 4(B) 10, 9, 8, 7, 6, 5, 4, 3, 2, 1(C) 10, 9, 4, 5, 7, 6, 8, 2, 1, 3(D) 10, 8, 6, 9, 7, 2, 3, 4, 1, 5Answer: (A)Explanation: After insertion of 7
                                          9
                                      /   |   \
                                    /     |     \
                                  7       6       8
                               / | \
                             /   |  \
                            3    1    5    

After insertion of 2
                                           9
                                      /    |   \
                                    /      |     \
                                  7        6       8
                               / | \       /
                             /   |  \     /
                            3    1    5  2

After insertion of 10
                                 10
                             /    |   \
                           /      |     \
                        7         9       8
                    / | \       / |
                  /   |  \     /  |
                3    1    5  2    6

After insertion of 4
                                 10
                             /   |   \
                           /     |     \
                         7        9       8
                      / | \      / | \
                    /   |  \    /  |   \
                  3    1    5  2   6    4

Quiz of this Question
Data Structures
Data Structures-Heap
Heap Quizzes
Data Structures
Data Structures
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
C program to implement Adjacency Matrix of a given Graph
Advantages and Disadvantages of Linked List
Difference between Singly linked list and Doubly linked list
Data Structures | Array | Question 2
Multilevel Linked List
Introduction to Data Structures | 10 most commonly used Data Structures
Data Structures | Linked List | Question 6
FIFO vs LIFO approach in Programming
Difference between data type and data structure
Count of triplets in an Array (i, j, k) such that i < j < k and a[k] < a[i] < a[j]
DecimalFormat setMaximumFractionDigits() method in Java - GeeksforGeeks

01 Apr, 2019
The setMaximumFractionDigits() method is a built-in method of the java.text.DecimalFomrat class in Java and is used to set the maximum number of digits allowed in the fractional part of a number. The fractional part of a number is the part displayed after the decimal(.) symbol.
Syntax:
public void setMaximumFractionDigits(int newVal)

Parameters: The function accepts a single parameter newVal which is the new value for the maximum number of fractional digits allowed to be set for this DecimalFormat instance.
Return Value: The function does not returns any value.
Below is the implementation of the above function:
Program 1:
// Java program to illustrate the// setMaximumFractionDigits() method  import java.text.DecimalFormat;import java.text.DecimalFormatSymbols;import java.util.Currency;import java.util.Locale;  public class Main {    public static void main(String[] args)    {          // Create the DecimalFormat Instance        DecimalFormat deciFormat = new DecimalFormat();          deciFormat.setMaximumFractionDigits(6);          System.out.println(deciFormat.format(12.3456789));    }}
12.345679

Program 2:
// Java program to illustrate the// setMaximumFractionDigits() method  import java.text.DecimalFormat;import java.text.DecimalFormatSymbols;import java.util.Currency;import java.util.Locale;  public class Main {    public static void main(String[] args)    {          // Create the DecimalFormat Instance        DecimalFormat deciFormat = new DecimalFormat();          deciFormat.setMaximumFractionDigits(1);          System.out.println(deciFormat.format(12.3456789));    }}
12.3

Reference: https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html#setMaximumFractionDigits(int)
Java-DecimalFormat
Java-Functions
Java-text package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Initialize an ArrayList in Java
HashMap in Java with Examples
Interfaces in Java
How to iterate any Map in Java
ArrayList in Java
Object Oriented Programming (OOPs) Concept in Java
Multidimensional Arrays in Java
Stack Class in Java
LinkedList in Java
Overriding in Java
Graph Shortest Paths - GeeksforGeeks

19 Nov, 2018
 * Time Comlexity of the Dijkstra’s algorithm is O(|V|^2 + E)  
 * Time Comlexity of the Warshall’s algorithm is O(|V|^3)
 * DFS cannot be used for finding shortest paths
 * BFS can be used for unweighted graphs. Time Complexity for BFS is O(|E| + |V|)

   1      1     1
s-----a-----b-----t
 \              /
   \          /
     \______/
        4
If we make following changes to  Dijkstra, then it can be used to find 
the longest simple path, assume that the graph is acyclic.

1) Initialize all distances as minus infinite instead of plus infinite.

2) Modify the relax condition in  Dijkstra's algorithm to update distance
  of an adjacent v of the currently considered vertex u only
  if "dist[u]+graph[u][v] > dist[v]". In shortest path algo, 
  the sign is opposite. 
Given a directed graph where weight of every edge is same, we can efficiently find shortest path from a given source to destination using? 
Breadth First Traversal
Dijkstra's Shortest Path Algorithm
Neither Breadth First Traversal nor Dijkstra's algorithm can be used
Depth First Search
With BFS, we first find explore vertices at one edge distance, then all vertices at 2 edge distance, and so on. 
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Must Do Coding Questions for Product Based Companies
How to Replace Values in Column Based on Condition in Pandas?
How to Fix: SyntaxError: positional argument follows keyword argument in Python
C Program to read contents of Whole File
How to Download and Install Spring Tool Suite (Spring Tools 4 for Eclipse) IDE?
How to Replace Values in a List in Python?
How to Select Data Between Two Dates and Times in SQL Server?
Spring - REST Controller
How to Read Text Files with Pandas?
How to Calculate Moving Averages in Python?
DAX Date & Time - YEAR function

Returns the year of a date as a four-digit integer in the range 1900-9999.
YEAR (<date>) 

date
A date in datetime or text format, containing the year you want to find.
An integer in the range 1900-9999.
DAX uses datetime data type to work with dates and times.
YEAR function takes the parameter date in one of the following ways −
By using the DATE function.
As a result of other DAX formulas or DAX functions.
As an accepted text representation of date.
The function uses the locale and date time settings of the client computer to understand the text value in order to perform the conversion. For example,
If the current date/time settings represent dates in the format of Month/Day/Year, then the string "1/8/2016" is understood as a datetime value equivalent to 8th January, 2016.
If the current date/time settings represent dates in the format of Month/Day/Year, then the string "1/8/2016" is understood as a datetime value equivalent to 8th January, 2016.
If the current date/time settings represent dates in the format of Day/Month/Year, the same string would be understood as a datetime value equivalent to 1st August, 2016.
If the current date/time settings represent dates in the format of Day/Month/Year, the same string would be understood as a datetime value equivalent to 1st August, 2016.
If the format of the string is incompatible with the current locale settings, YEAR function might return an error. For example, if your locale defines dates to be formatted as month/day/year, and the date is provided as day/month/year, then 25/1/2009 will not be interpreted as January 25th of 2009 but as an invalid date.
= YEAR (DATE (2016,9,15)) returns 2016. 
= YEAR (TODAY ()) returns 2016 if TODAY () returns 12/16/2016 12:00:00 AM. 

    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
Extract properties from an object in JavaScript

We have to write a JavaScript function, say extract() that extracts properties from an object to
another object and then deletes them from the original object.
For example −
If obj1 and obj2 are two objects, then
obj1 = {color:"red", age:"23", name:"cindy"}
obj2 = extract(obj1, ["color","name"])
After passing through the extract function, they should become like −
obj1 = { age:23 }
obj2 = {color:"red", name:"cindy"}
Therefore, let’s write the code for this function −
const obj = {
   name: "Rahul",
   job: "Software Engineer",
   age: 23,
   city: "Mumbai",
   hobby: "Reading books"
};
const extract = (obj, ...keys) => {
   const newObject = Object.assign({});
   Object.keys(obj).forEach((key) => {
      if(keys.includes(key)){
         newObject[key] = obj[key];
         delete obj[key];
      };
   });
   return newObject;
};
console.log(extract(obj, 'name', 'job', 'hobby'));
console.log(obj);
The output in the console will be −
{ name: 'Rahul', job: 'Software Engineer', hobby: 'Reading books' }
{ age: 23, city: 'Mumbai' }
Why is method overloading not possible by changing the return type of the method only in java?

Overloading is the mechanism of binding the method call with the method body dynamically based on the parameters passed to the method call.
If you observe the following example, it contains two methods with same name, different parameters and if you call the method by passing two integer values the first method will be executed and, if you call by passing 3 integer values then the second method will be executed.It is not possible to decide to execute which method based on the return type, therefore, overloading is not possible just by changing the return type of the method.
 Live Demo
public class Sample{
   public int add(int a, int b){
      int c = a+b;
      return c;
   }
   public void add(int a, int b, int c){
      int z = a+b+c;
      System.out.println(z);
   }
   public static void main(String args[] ){
      Sample obj = new Sample();
      System.out.println(obj.add(40, 50));
      obj.add(40, 50, 60);
   }
}
90
150
Groovy - Switch Statement

Sometimes the nested if-else statement is so common and is used so often that an easier statement was designed called the switch statement.
switch(expression) { 
   case expression #1: 
   statement #1 
   ... 
   case expression #2: 
   statement #2 
   ... 
   case expression #N: 
   statement #N 
   ... 
   default:
   statement #Default 
   ... 
} 

The general working of this statement is as follows −
The expression to be evaluated is placed in the switch statement.
The expression to be evaluated is placed in the switch statement.
There will be multiple case expressions defined to decide which set of statements should be executed based on the evaluation of the expression.
There will be multiple case expressions defined to decide which set of statements should be executed based on the evaluation of the expression.
A break statement is added to each case section of statements at the end. This is to ensure that the loop is exited as soon as the relevant set of statements gets executed.
A break statement is added to each case section of statements at the end. This is to ensure that the loop is exited as soon as the relevant set of statements gets executed.
There is also a default case statement which gets executed if none of the prior case expressions evaluate to true.
There is also a default case statement which gets executed if none of the prior case expressions evaluate to true.
The following diagram shows the flow of the switch-case statement.
Following is an example of the switch statement −
class Example { 
   static void main(String[] args) { 
      //initializing a local variable 
      int a = 2
		
      //Evaluating the expression value 
      switch(a) {            
         //There is case statement defined for 4 cases 
         // Each case statement section has a break condition to exit the loop 
			
         case 1: 
            println("The value of a is One"); 
            break; 
         case 2: 
            println("The value of a is Two"); 
            break; 
         case 3: 
            println("The value of a is Three"); 
            break; 
         case 4: 
            println("The value of a is Four"); 
            break; 
         default: 
            println("The value is unknown"); 
            break; 
      }
   }
}
In the above example, we are first initializing a variable to a value of 2. We then have a switch statement which evaluates the value of the variable a. Based on the value of the variable it will execute the relevant case set of statements. The output of the above code would be −
The value of a is Two


    52 Lectures 
     8 hours 

 Krishna Sakinala

    49 Lectures 
     2.5 hours 

 Packt Publishing
 Print
 Add Notes
 Bookmark this page
Node.js Buffer.writeUInt16LE() Method - GeeksforGeeks

13 Oct, 2021
The Buffer.writeUInt16LE() method is used to write specified bytes in Little Endian format to the buffer object. Here, value should be a valid unsigned 16-bit integer.
Syntax:
Buffer.writeUInt16LE( value, offset )
Parameters: This method accept two parameters as mentioned above and described below:
value: It is an integer value and that is to be written to the buffer.
offset It is an integer value and it represents the number of bytes to skip before starting to write and the value of offset lies within the range 0 to buffer.length – 2 and its default value is 0.
Return value: It returns an integer value the offset plus number of bytes written.
Example 1:
// Node.js program to demonstrate the//Buffer.writeUInt16LE() Methodconst buff = Buffer.allocUnsafe(4);  buff.writeUInt16LE(0xdead, 0);console.log(buff);  buff.writeUInt16LE(0xbeef, 2)console.log(buff);
Output:
<Buffer ad de 00 00>
<Buffer ad de ef be>


Example 2:
// Node.js program to demonstrate the//Buffer.writeUInt16LE() Methodconst buff = Buffer.allocUnsafe(4);  buff.writeUInt16LE(0xfeed, 0);console.log(buff);  buff.writeUInt16LE(0xabcd, 2);console.log(buff);
Output:
<Buffer ed fe 00 00>
<Buffer ed fe cd ab>
 
Note: The above program will compile and run by using the node index.js command.
Reference: https://nodejs.org/api/buffer.html#buffer_buf_writeuint16le_value_offset
Node.js-Buffer-module
Picked
Node.js
Technical Scripter
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Node.js path.resolve() Method
Node.js crypto.createCipheriv() Method
Node.js CRUD Operations Using Mongoose and MongoDB Atlas
Node.js fs.readdir() Method
Express.js res.render() Function
Express.js express.Router() Function
Convert a string to an integer in JavaScript
How to set the default value for an HTML <select> element ?
Top 10 Angular Libraries For Web Developers
How to create footer to stay at the bottom of a Web page?
MySQL Tryit Editor v1.0

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

A CSV file is a comma-separated file, that is used to store data in an organized way. It
usually stores data in tabular form. Most of the business organizations store their data
in CSV files.
In C#, StreamReader class is used to deal with the files. It opens, reads and helps in
performing other functions to different types of files. We can also perform different
operations on a CSV file while using this class.
OpenRead() method is used to open a CSV file and ReadLine() method is used to read
its contents.
OpenRead() method is used to open a CSV file and ReadLine() method is used to read
Data.csv
A,B,C
class Program{
   public static void Main(){
      string filePath =
      @"C:\Users\Koushik\Desktop\Questions\ConsoleApp\Data.csv";
      StreamReader reader = null;
      if (File.Exists(filePath)){
         reader = new StreamReader(File.OpenRead(filePath));
         List<string> listA = new List<string>();
         while (!reader.EndOfStream){
            var line = reader.ReadLine();
            var values = line.Split(',');
            foreach (var item in values){
               listA.Add(item);
            }
            foreach (var coloumn1 in listA){
               Console.WriteLine(coloumn1);
            }
         }
      } else {
         Console.WriteLine("File doesn't exist");
      }
      Console.ReadLine();
   }
}
A
B
C
DateTime.IsLeapYear() Method in C#

The DateTime.IsLeapYear() method in C# is used to check whether the specified year is a leap year. The return value is a boolean, with TRUE if the year is a leap year, else FALSE.
Following is the syntax −
public static bool IsLeapYear (int y);
Above, y is the year to be checked, 2010, 2016, 2019, etc.
Let us now see an example to implement the DateTime.IsLeapYear() method −
using System;
public class Demo {
   public static void Main() {
      int year = 2019;
      Console.WriteLine("Year = "+year);
      if (DateTime.IsLeapYear(year)){
         Console.WriteLine("Leap Year!");
      } else {
         Console.WriteLine("Not a Leap Year!");
      }
   }
}
This will produce the following output −
Year = 2019
Not a Leap Year!
Let us now see another example to implement the DateTime.IsLeapYear() method. Here, we will add an out of range year −
using System;
public class Demo {
   public static void Main() {
      int year = 101910;
      Console.WriteLine("Year = "+year);
      if (DateTime.IsLeapYear(year)){
         Console.WriteLine("Leap Year!");
      } else {
         Console.WriteLine("Not a Leap Year!");
      }
   }
}
This will produce the following output i.e. error will get generated. The Stack Trace would print the same error as shown below −
Year = 101910
Run-time exception (line 11): Year must be between 1 and 9999.
Parameter name: year
Stack Trace:
[System.ArgumentOutOfRangeException: Year must be between 1 and 9999.
Parameter name: year]
at System.DateTime.IsLeapYear(Int32 year) at Demo.Main() :line 11
Java Program to find largest element in an array - GeeksforGeeks

13 Jun, 2020
Given an array, find the largest element in it.
Input : arr[] = {10, 20, 4}
Output : 20

Input : arr[] = {20, 10, 20, 4, 100}
Output : 100

Method 1: Iterative Way
// Java Program to find maximum in arr[] class Test{     static int arr[] = {10, 324, 45, 90, 9808};            // Method to find maximum in arr[]     static int largest()     {         int i;                    // Initialize maximum element         int max = arr[0];                 // Traverse array elements from second and         // compare every element with current max           for (i = 1; i < arr.length; i++)             if (arr[i] > max)                 max = arr[i];                 return max;     }            // Driver method     public static void main(String[] args)      {         System.out.println("Largest in given array is " + largest());        } }
Output:
Largest in given array is 9808

Method 2: Java 8 StreamYou can simply use the new Java 8 Streams but you have to work with int.
import java.util.Arrays;  public class GFG {    public static void main(String[] args){        int arr[] = {10, 324, 45, 90, 9808};        int max = Arrays.stream(arr).max().getAsInt();        System.out.println("Largest in given array is " +max);    }  }
Output:
Largest in given array is 9808

Method 3 : (Sorting)
// Java program to find maximum in // arr[] of size n import java .io.*; import java.util.*;     class GFG {           // returns maximum in arr[] of size n     static int largest(int []arr,                           int n)     {         Arrays.sort(arr);         return arr[n - 1];     }         // Driver code     static public void main (String[] args)     {         int []arr = {10, 324, 45,                       90, 9808};         int n = arr.length;         System.out.println(largest(arr, n));     } } 
Please refer complete article on Program to find largest element in an array for more details!
29AjayKumar
Java Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Java Programming Examples
How to Iterate HashMap in Java?
Iterate through List in Java
Java Program to Remove Duplicate Elements From the Array
Factory method design pattern in Java
Min Heap in Java
Java program to count the occurrence of each character in a string using Hashmap
Iterate Over the Characters of a String in Java
How to Get Elements By Index from HashSet in Java?
Sorting in Java
Convert Tuple to integer in Python

When it is required to convert a tuple into an integer, the lambda function and the 'reduce' function can be used.
Anonymous function is a function which is defined without a name. The reduce function takes two parameters- a function and a sequence, where it applies the function to all the elements of the list/sequence. It is present in the 'functools' module.
In general, functions in Python are defined using 'def' keyword, but anonymous function is defined with the help of 'lambda' keyword. It takes a single expression, but can take any number of arguments. It uses the expression and returns the result of it.
Below is a demonstration of the same −
Live Demo
import functools
my_tuple_1 = (23, 45, 12, 56, 78, 0)

print("The first tuple is : ")
print(my_tuple_1)

my_result = functools.reduce(lambda sub, elem: sub * 10 + elem, my_tuple_1)

print("After converting tuple to integer, it is ")
print(my_result)
The first tuple is :
(23, 45, 12, 56, 78, 0)
After converting tuple to integer, it is
2768380
The required packages are downloaded.
A tuple is defined, and is displayed on the console.
The reduce function is used, to which the lambda, and the tuple are passed as arguments.
The lambda function multiples every element in the tuple with 10 and adds the previous element to it.
This operation's data is stored in a variable.
This variable is the output that is displayed on the console.
How can I get a file's size in C++?

To get a file’s size in C++ first open the file and seek it to the end. tell() will tell us the current position of the stream, which will be the number of bytes in the file.
 Live Demo
#include<iostream>
#include<fstream>
using namespace std;
int main() {
   ifstream in_file("a.txt", ios::binary);
   in_file.seekg(0, ios::end);
   int file_size = in_file.tellg();
   cout<<"Size of the file is"<<" "<< file_size<<" "<<"bytes";
}
Size of the file is 44 bytes
How to convert html pages to pdf using wkhtml2pdf

This article will guide you to install a tool which can convert your HTML pages or HTML output to PDF format. This feature will also be helpful to write a code for generating Pdf’s, if we need to send them to a group of customers or clients and for sending reports instead of HTML (which you can send them via emails in PDF format) that will be a value addition to your software.
Open source and cross platform.
Convert any HTML web pages to PDF files using WebKit engine.
Options to add headers and footers
Table of Content (TOC) generation option.
Provides batch mode conversions.
Support for PHP or Python via bindings to libwkhtmltox
Need to install some required fonts which are used for wkhtmltopdf
# yum install -y xorg-x11-fonts-75dpi
# yum install -y xorg-x11-fonts-Type1
To get the file, please run the following
# wget https://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2
To extract the files –
# tar -xvzf wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2 -C /opt
# cd /opt
# mv wkhtmltopdf-amd64 wkhtmltopdf
# mv wkhtmltopdf /usr/local/bin
To convert any HTML web page to PDF, run the following example command. It will convert the given web pages to install-eclipse .pdf as as output to /opt directory.
# wkhtmltopdf http://google.com/ /opt/google.pdf
Sample Output:
Loading pages (1/6)
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
After this installation, as mentioned earlier, now you really want a homepage and want to save it as a PDF, then you could use Wkhtmltopdf for that. Seriously, you could use it to generate invoices and save or send, create birthday cards and send them or save them or all other sorts of fun things.
Just use your imagination! That we can save any web pages or html page into PDF format for further use.
Add a grey background color to the Bootstrap 4 card

To add a gray background color to the Bootstrap 4 card, use the card class with the bg-dark contextual class −
<div class="card bg-dark text-white">
Set the card body inside the same <div> class −
<div class="card bg-dark text-white">
  <div class="card-body">Hello</div>
</div>
Let us see the complete example add a grey background color to Bootstrap card −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  </head>
  <body>
    <div class="container">
      <h2>Welcome</h2>
      <div class="card bg-dark text-white">
        <div class="card-body">Hello</div>
      </div>
    </div>
</body>
</html>
CSS :focus-within Selector - GeeksforGeeks

18 Sep, 2020
The :focus-within pseudo-class is a selects an element that consists of a focused element as a child. The CSS rules are applied when any child element gets focus. Example includes clicking a link, selecting an input, etc.
Syntax:
:focus {
    /* CSS Properties */
}
Example: Below is the example which illustrates the use of :focus-within pseudo-class Selector.
HTML
<!DOCTYPE html><html lang="en">  <head>    <style>        form {            border: 2px solid red;            padding: 15px;            width: 30%;        }          form:focus-within {            background: #ff8;            color: black;        }          input {            margin: 5px;        }    </style></head>  <body>    <h1 style="color: green;">        GeeksforGeeks    </h1>      <form>          <label>Geek 1</label>        <input type="text">        <br>        <label>Geek 2</label>        <input type="text">    </form></body>  </html>
Output:
Supported Browsers:
Chrome
Firefox
Edge
Opera
Safari
Internet Explorer (Not Supported).
CSS-Selectors
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to set space between the flexbox ?
Design a web page using HTML and CSS
Form validation using jQuery
How to style a checkbox using CSS?
Search Bar using HTML, CSS and JavaScript
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
How to print a page using jQuery ? - GeeksforGeeks

15 Oct, 2020
The task is to print a page using jQuery by calling a window.print method when the user clicks on a Button. The window.print() method is sent to open the Print Dialog Box to print the current document. It does not have any parameter value. 
Example:: 
HTML Code:
HTML
<!DOCTYPE html><html>  <head>    <title>        How to. print a page using jQuery.?    </title></head>  <body>    <center>        <h1>Hello GeeksForGeeks Users</h1>          <h3>            How to. print a page using jQuery.?        </h3>          <Button id="sudo" onclick=            "print_current_page()" />            Print!        </button>    </center></body>  </html>
jQuery Code:
$('#sudo).click(function(){
    window.print();
    return false;
});

Output:
Before Clicking On Button:
After Clicking On Button:
Supported Browsers:
Google Chrome
Internet Explorer
Firefox
Opera
Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Misc
jQuery-Misc
HTML
JQuery
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
HTML Cheat Sheet - A Basic Guide to HTML
Design a web page using HTML and CSS
Form validation using jQuery
Angular File Upload
JQuery | Set the value of an input text field
Form validation using jQuery
How to change selected value of a drop-down list using jQuery?
How to change the background color after clicking the button in JavaScript ?
How to fetch data from JSON file and display in HTML table using jQuery ?
NumberFormat getCurrency() method in Java with Examples - GeeksforGeeks

01 Apr, 2019
The getCurrency() method is a built-in method of the java.text.NumberFormat returns the currency which is used while formatting currency values by this currency. It can be null if there is no valid currency to be determined or if no currency has been set previously.
Syntax:
public Currency getCurrency()
Parameters: The function does not accepts a single parameter.
Return Value: The function returns the currency which is used while formatting currency values.
Errors and Exceptions: The function throws UnsupportedOperationException when the number format class doesn’t implement currency formatting
Below is the implementation of the above function:
Program 1:
// Java program to implement// the above function  import java.text.NumberFormat;import java.util.Locale;  public class Main {    public static void main(String[] args)        throws Exception    {          // Get the instance        NumberFormat nF            = NumberFormat                  .getInstance();          // Stores the values        String values            = nF.getCurrency()                  .getDisplayName();          // Prints the currency        System.out.println(values);    }}
US Dollar

Program 2:
// Java program to implement// the above function  import java.text.NumberFormat;import java.util.Locale;import java.util.Currency;  public class Main {    public static void main(String[] args)        throws Exception    {          // Get the instance        NumberFormat nF            = NumberFormat                  .getNumberInstance();          // Sets the currency to Canadian Dollar        nF.setCurrency(            Currency.getInstance(                Locale.CANADA));          // Stores the values        String values            = nF.getCurrency()                  .getDisplayName();          // Prints the currency        System.out.println(values);    }}
Canadian Dollar

Reference: https://docs.oracle.com/javase/10/docs/api/java/text/NumberFormat.html#getCurrency()
Java-Functions
Java-NumberFormat
Java-text package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Interfaces in Java
Stream In Java
How to iterate any Map in Java
ArrayList in Java
Initialize an ArrayList in Java
Stack Class in Java
Multidimensional Arrays in Java
Singleton Class in Java