code-rag-bench/online-tutorials huggingface dataset:
LocalTime now() method in Java with Examples - GeeksforGeeks

12 May, 2020
The now() method of the LocalTime class in Java is used to get the current time from the system clock in the default time-zone.
Syntax:
public static LocalTime now()
Parameters: This method does not accept any parameter.
Return value: This method returns the current time using the system clock and default time-zone.
Below programs illustrate the now() method of LocalTime in Java:
Program 1:
// Java program to demonstrate// LocalTime.now() method  import java.time.*;import java.time.temporal.*;  public class GFG {    public static void main(String[] args)    {          // apply now() method        // of LocalTime class        LocalTime time = LocalTime.now();          // print time        System.out.println("Time: "                           + time);    }}
Time: 20:43:41.453

Program 2:
// Java program to demonstrate// LocalTime.now() method  import java.time.*;import java.time.temporal.*;  public class GFG {    public static void main(String[] args)    {          // apply now() method        // of LocalTime class        LocalTime time = LocalTime.now();          // print time        System.out.println("Time: "                           + time);    }}
Time: 20:44:06.567

Above two examples show how the output changes for same program as the time progresses.References: https://docs.oracle.com/javase/10/docs/api/java/time/LocalTime.html#now()
Java-Functions
Java-LocalTime
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HashMap in Java with Examples
Stream In Java
Interfaces 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
Set in Java
How to concatenate two integer arrays without using loop in C ? - GeeksforGeeks

02 Jun, 2017
Given two arrays such that first array has enough extra space to accommodate elements of second array. How to concatenate second array to first in C without using any loop in program?
Example:
Input: arr1[5] = {1, 2, 3}
       arr2[]  = {4, 5}
Output: arr1[] = {1, 2, 3, 4, 5}

We strongly recommend you to minimize your browser and try this yourself first.
 
Hint: We may use library functions in C.
The idea is to use memcpy() or memmove() in C.
// arr1[] is of size m+n and arr2[] is of size n. This function// appends contents of arr2[] at the end of arr1[]void concatenate(int arr1[], int arr2[], int m, int n){   memcpy(arr1 + m, arr2, sizeof(arr2)); }
See this for complete running code.
Thanks to Utkarsh Trivedi for suggesting above solution.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
C-Arrays
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
Exception Handling in C++
Multithreading in C
'this' pointer in C++
Arrow operator -> in C/C++ with Examples
Ways to copy a vector in C++
Smart Pointers in C++ and How to Use Them
Understanding "extern" keyword in C
Multiple Inheritance in C++
How to split a string in C/C++, Python and Java?
Collect.js contains() Method - GeeksforGeeks

29 Jul, 2020
The contains() method is used to determines whether the collection contains a given item or not. If it contains the item then it returns true otherwise false. The JavaScript array is first transformed into a collection and then the function is applied to the collection.
Syntax:  
collect(array).contains(item)
Parameters: This method accepts single parameter i.e. converted into the collection and then contains() function take an item to be searched.
Return Value: Returns a boolean value.
Below examples illustrate the contains() method in Collect.js:
Example 1: Here collect = require(‘collect.js’) is used to import the collect.js library into the file.
Javascript
const collect = require('collect.js');        let arr = [1, 2, 3];        // Convert array into collection  const collection = collect(arr);    // item to searchedlet item = 3;  let newObject = collection.contains(item);      console.log("Result : ", newObject);
Output:
Result :  true
Example 2:
Javascript
const collect = require('collect.js');        let arr = [1, 2, 3]        // Convert array into collection  const collection = collect(arr);    // concate the arraylet concatarr = collection.concat(['a', 'b', 'c']);  // concate the objectconcatarr = concatarr.concat({ first : "GeeksforGeeks",         second : "Collect.js"});  // item to searchedlet item = "GeeksforGeek";  let newObject = collection.contains(item);      console.log("Result : ", newObject);
Output:
Result : false
Reference: https://collect.js.org/api/contains.html
Collect.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to calculate the number of days between two dates in 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 ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Replace Inf with NA in Dataframe in R - GeeksforGeeks

27 Sep, 2021
In this article, we will discuss how to replace Inf (Infinity) with NA in Dataframe in R Programming Language.
Create a dataframe with for demonstration:
R
# create a dataframe with 3 columns and 5 rowsdata=data.frame(column1 = c(Inf, 2, 3, 4, 5),                 column2 = c(1, Inf, 1, Inf, 1),                column3 = c(1,2,3,Inf,Inf)) # display dataframeprint(data)
Output:
So we can replace Inf with NA by using lapply() function, we have to create our own function to replace Inf with NA and then pass that function to lapply() through do.call method.
Function Syntax:
function(value) 
replace(value, is.infinite(value), 
NA)
Where value is the input value and replace() is used to replace the value to NA if it is infinite.
R
# create a dataframe with 3 columns and 5 rowsdata=data.frame(column1 = c(Inf, 2, 3, 4, 5),                column2= c(1, Inf, 1, Inf, 1),                column3=c(1,2,3,Inf,Inf)) # actual dataframeprint(data) # replace inf with NAfinal=do.call(data.frame, lapply              (data, function(value) replace               (value, is.infinite(value),NA))) # displayprint(final)
Output:
R
# create a dataframe with 5 columns and 5 rowsdata=data.frame(column1 = c(Inf, 2, 3, 4, 5),                column2= c(1, Inf, 1, Inf, 1),                column3=c(1,2,3,Inf,Inf),                column4=c(Inf,Inf,Inf,3,4),                column5=c(1,2,3,4,Inf)) # actual dataframeprint(data) # replace inf with NAfinal=do.call(data.frame,lapply              (data, function(value) replace               (value, is.infinite(value),NA))) # displayprint(final)
Output:
anikakapoor
Picked
R DataFrame-Programs
R-DataFrame
R Language
R Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
Replace Specific Characters in String in R
How to filter R dataframe by multiple conditions?
Convert Matrix to Dataframe in R
Arduino - Advanced I/O Function

In this chapter, we will learn some advanced Input and Output Functions.
Configures the reference voltage used for analog input (i.e. the value used as the top of the input range). The options are −
DEFAULT − The default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards)
DEFAULT − The default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards)
INTERNAL − An built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328 and 2.56 volts on the ATmega8 (not available on the Arduino Mega)
INTERNAL − An built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328 and 2.56 volts on the ATmega8 (not available on the Arduino Mega)
INTERNAL1V1 − A built-in 1.1V reference (Arduino Mega only)
INTERNAL1V1 − A built-in 1.1V reference (Arduino Mega only)
INTERNAL2V56 − A built-in 2.56V reference (Arduino Mega only)
INTERNAL2V56 − A built-in 2.56V reference (Arduino Mega only)
EXTERNAL − The voltage applied to the AREF pin (0 to 5V only) is used as the reference
EXTERNAL − The voltage applied to the AREF pin (0 to 5V only) is used as the reference
analogReference (type);

type − can use any type of the follow (DEFAULT, INTERNAL, INTERNAL1V1, INTERNAL2V56, EXTERNAL)
Do not use anything less than 0V or more than 5V for external reference voltage on the AREF pin. If you are using an external reference on the AREF pin, you must set the analog reference to EXTERNAL before calling the analogRead() function. Otherwise, you will short the active reference voltage (internally generated) and the AREF pin, possibly damaging the microcontroller on your Arduino board.
Alternatively, you can connect the external reference voltage to the AREF pin through a 5K resistor, allowing you to switch between external and internal reference voltages.
Note that the resistor will alter the voltage that is used as the reference because there is an internal 32K resistor on the AREF pin. The two act as a voltage divider. For example, 2.5V applied through the resistor will yield 2.5 * 32 / (32 + 5) = ~2.2V at the AREF pin.
Example
int analogPin = 3;// potentiometer wiper (middle terminal) connected to analog pin 3 
int val = 0; // variable to store the read value

void setup() {
   Serial.begin(9600); // setup serial
   analogReference(EXTERNAL); // the voltage applied to the AREF pin (0 to 5V only) 
      // is used as the reference.
}

void loop() {
   val = analogRead(analogPin); // read the input pin
   Serial.println(val); // debug value
}

    65 Lectures 
     6.5 hours 

 Amit Rana

    43 Lectures 
     3 hours 

 Amit Rana

    20 Lectures 
     2 hours 

 Ashraf Said

    19 Lectures 
     1.5 hours 

 Ashraf Said

    11 Lectures 
     47 mins

 Ashraf Said

    9 Lectures 
     41 mins

 Ashraf Said
 Print
 Add Notes
 Bookmark this page
Check if a HashMap is empty in Java

Use the isEmpty() method to check of a HashMap is empty or not. Let us first create the HashMap −
HashMap hm = new HashMap();
Now, add some elements −
hm.put("Bag", new Integer(1100));
hm.put("Wallet", new Integer(700));
hm.put("Belt", new Integer(600));
Since, we added elements above, therefore, the HashMap isn’t empty. Let us check −
set.isEmpty()
The following is an example to check if a HashMap is empty or not −
 Live Demo
import java.util.*;
public class Demo {
   public static void main(String args[]) {
      // Create a hash map
      HashMap hm = new HashMap();
      // Put elements to the map
      hm.put("Bag", new Integer(1100));
      hm.put("Wallet", new Integer(700));
      hm.put("Belt", new Integer(600));
      // Get a set of the entries
      Set set = hm.entrySet();
      // Get an iterator
      Iterator i = set.iterator();
      // Display elements
      while(i.hasNext()) {
         Map.Entry me = (Map.Entry)i.next();
         System.out.print(me.getKey() + ": ");
         System.out.println(me.getValue());
      }
      System.out.println();
      System.out.println("Is the HashMap with empty elements? "+set.isEmpty());
   }
}
Belt: 600
Wallet: 700
Bag: 1100
Is the HashMap with empty elements? False
Zip Code validation using Java Regular Expressions

The zip code can be validated using the java.util.regex.Pattern.matches() method. This method matches the regular expression for the zip code and the given input zip code and returns true if they match and false otherwise.
A program that demonstrates this is given as follows:
 Live Demo
public class Demo {
   public static void main(String args[]) {
      String zipCode = "83592-1537";
      String regex = "\\d{5}(-\\d{4})?";
      System.out.println("The zip code is: " + zipCode);
      System.out.println("Is the above zip code valid? " + zipCode.matches(regex));
   }
}
The zip code is: 83592-1537
Is the above zip code valid? true
Now let us understand the above program.
The zip code is printed. The Pattern.matches() method matches the regular expression for the zip code and the given input zip code and the result is printed. A code snippet which demonstrates this is as follows:
String zipCode = "83592-1537";
String regex = "\\d{5}(-\\d{4})?";

System.out.println("The zip code is: " + zipCode);
System.out.println("Is the above zip code valid? " + zipCode.matches(regex));
How to deal with error “Error in shapiro.test(...) : sample size must be between 3 and 5000” in R?

The shapiro.test has a restriction in R that it can be applied only up to a sample of size 5000 and the least sample size must be 3. Therefore, we have an alternative hypothesis test called Anderson Darling normality test. To perform this test, we need load nortest package and use the ad.test function as shown in the below examples.
Consider the below data frame −
 Live Demo
x<-rnorm(1000000)
df1<-data.frame(x)
head(df1,20)
     x
1    1.27305105
2    1.79910461
3   -1.05456918
4    0.27247323
5   -1.22709375
6    1.87211271
7   -0.98918543
8   -0.98504275
9    0.55901414
10   1.17920161
11  -0.16612397
12  -0.89614357
13  -0.70229748
14   1.16583130
15  -0.17427556
16   0.05428080
17   1.26193927
18   0.63517470
19  -0.02052002
20  -1.23316924
Performing shapiro.test on x −
shapiro.test(df1$x)
Error in shapiro.test(df1$x) : sample size must be between 3 and 5000
Loading nortest package and performing Anderson Darling test on x −
library(nortest)
ad.test(df1$x)
   Anderson-Darling normality test
data: df1$x
A = 0.21458, p-value = 0.8496
 Live Demo
y<-sample(0:9,500000,replace=TRUE)
df2<-data.frame(y)
head(df2,20)
   y
1  8
2  9
3  7
4  0 
5  3
6  4
7  9
8  3
9  1
10 5
11 9
12 4
13 5
14 9
15 5
16 7
17 1
18 0
19 4
20 4
Performing Anderson Darling test on y −
ad.test(df2$y)
   Anderson-Darling normality test
data: df2$y
A = 8634.6, p-value < 2.2e-16
How to create Static Variables in JavaScript ? - GeeksforGeeks

22 Jun, 2021
In this article, we will learn to create static variables in JavaScript.
Static keyword in JavaScript: The static keyword is used to define a static method or property of a class. To call the static method we do not need to create an instance or object of the class.
Static variable in JavaScript: We used the static keyword to make a variable static just like the constant variable is defined using the const keyword. It is set at the run time and such type of variable works as a global variable. We can use the static variable anywhere. The value of the static variable can be reassigned, unlike the constant variable.
Why we create a static variable in JavaScript: We create a static variable in JavaScript to prevent replication, fixed-configuration, and it is also useful for caches. 
Example 1: In the below example, we will create a static variable and display it on the JavaScript console.
Javascript
<script> class Example {   static staticVariable = 'GeeksforGeeks';      //static variable defined   static staticMethod() {     return 'static method has been called.';      }  }  // static variable called  console.log(Example.staticVariable);  // static method called  console.log(Example.staticMethod());   </static>
Output: 
Static method
Example 2: Static variable is called using this keyword.
Javascript
<script>  class Example {    static staticVariable = 'GeeksforGeeks';   //static variable defined   static staticMethod() {     return 'staticVariable : '+this.staticVariable;      }  }  // static method called  console.log(Example.staticMethod());</script>
Output:
surindertarika1234
javascript-functions
JavaScript-Questions
Picked
JavaScript
Web Technologies
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 PUT and PATCH Request
How to get character array from string in JavaScript?
How to remove duplicate elements from JavaScript Array ?
How to get selected value in dropdown list using JavaScript ?
Roadmap to Become a Web Developer 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?
difftime() function in C++ - GeeksforGeeks

01 Oct, 2018
The difftime() function is defined in ctime header file. The difftime() function is used to calculate the difference between two times in second.
Syntax:
double difftime(time_t end, time_t start);
Parameters: This method accepts two parameters:
start: time_t object for start time.
end: time_t object for end time.
Returns: This function returns the difference between two times in seconds.
Example:-
// C++ program to demonstrate// example of difftime() function.  #include <bits/stdc++.h>using namespace std;  int main(){    time_t start, ending;    long addition;      time(&start);    for (int i = 0; i < 20000; i++) {        for (int j = 0; j < 20000; j++);    }    for (int i = 0; i < 20000; i++) {        for (int j = 0; j < 20000; j++);    }    for (int i = 0; i < 20000; i++) {        for (int j = 0; j < 20000; j++);    }    time(&ending);    cout << "Total time required = "         << difftime(ending, start)         << " seconds " << endl;    return 0;}
Total time required = 2 seconds

CPP-Functions
CPP-Library
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Map in C++ Standard Template Library (STL)
Inheritance in C++
C++ Classes and Objects
Constructors in C++
Bitwise Operators in C/C++
Socket Programming in C/C++
Operator Overloading in C++
Multidimensional Arrays in C / C++
Copy Constructor in C++
Virtual Function in C++
How to determine the order of bars in a matplotlib bar chart?

To determine the order of bars in a bar chart in matplotlib, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Make a dataframe, df, of two-dimensional, size-mutable, potentially heterogeneous tabular data.
Add a subplot to the current figure.
Make a bar plot with dataframe, df.
Add a subplot to the current figure.
Create another dataframe, df_sorted, by column marks.
Make a bar plot with df_sorted.
To display the figure, use show() method.
import pandas as pd
from matplotlib import pyplot as plt

plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True

df = pd.DataFrame(
   dict(
      names=['John', 'James', 'David', 'Gary', 'Watson'],
      marks=[23, 34, 30, 19, 20]
   )
)

plt.subplot(121)
plt.bar('names', 'marks', data=df, color='green')

plt.subplot(122)
df_sorted = df.sort_values('marks')
plt.bar('names', 'marks', data=df_sorted, color='blue')

plt.show()
It will produce the following output
Matplotlib - Pie Chart

A Pie Chart can only display one series of data. Pie charts show the size of items (called wedge) in one data series, proportional to the sum of the items. The data points in a pie chart are shown as a percentage of the whole pie.
Matplotlib API has a pie() function that generates a pie diagram representing data in an array. The fractional area of each wedge is given by x/sum(x). If sum(x)< 1, then the values of x give the fractional area directly and the array will not be normalized. Theresulting pie will have an empty wedge of size 1 - sum(x).
The pie chart looks best if the figure and axes are square, or the Axes aspect is equal.
Following table lists down the parameters foe a pie chart −
Following code uses the pie() function to display the pie chart of the list of students enrolled for various computer language courses. The proportionate percentage is displayed inside the respective wedge with the help of autopct parameter which is set to %1.2f%.
from matplotlib import pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_axes([0,0,1,1])
ax.axis('equal')
langs = ['C', 'C++', 'Java', 'Python', 'PHP']
students = [23,17,35,29,12]
ax.pie(students, labels = langs,autopct='%1.2f%%')
plt.show()

    63 Lectures 
     6 hours 

 Abhilash Nelson

    11 Lectures 
     4 hours 

 DATAhill Solutions Srinivas Reddy

    9 Lectures 
     2.5 hours 

 DATAhill Solutions Srinivas Reddy

    32 Lectures 
     4 hours 

 Aipython

    10 Lectures 
     2.5 hours 

 Akbar Khan

    63 Lectures 
     6 hours 

 Anmol
 Print
 Add Notes
 Bookmark this page
Filter away object in array with null values JavaScript

Let’s say, we have an array of objects about some employees of a company. But the array
contains some bad data i.e., key pointing to empty strings or false values. Our job is to write a
function that takes in the array and away the objects that have null or undefined or empty string
value for the name key and return the new object.
The array of objects are like this −
let data = [{
   "name": "Ramesh Dhiman",
   "age": 67,
   "experience": 45,
   "description": ""
}, {
      "name": "",
      "age": 31,
      "experience": 9,
      "description": ""
}, {
      "name": "Kunal Dhiman",
      "age": 27,
      "experience": 7,
      "description": ""
}, {
      "name": "Raman Kumar",
      "age": 34,
      "experience": 10,
      "description": ""
}, {
      "name": "",
      "age": 41,
      "experience": 19,
      "description": ""
   }
]
Let’s write the code for this function −
let data = [{
   "name": "Ramesh Dhiman",
   "age": 67,
   "experience": 45,
   "description": ""
}, {
      "name": "",
      "age": 31,
      "experience": 9,
      "description": ""
}, {
      "name": "Kunal Dhiman",
      "age": 27,
      "experience": 7,
      "description": ""
}, {
      "name": "Raman Kumar",
      "age": 34,
      "experience": 10,
      "description": ""
}, {
      "name": "",
      "age": 41,
      "experience": 19,
      "description": ""
   }
]
const filterUnwanted = (arr) => {
   const required = arr.filter(el => {
      return el.name;
   });
   return required;
};
console.log(filterUnwanted(data));
The output in the console will be −
[
   { name: 'Ramesh Dhiman', age: 67, experience: 45, description: '' },
   { name: 'Kunal Dhiman', age: 27, experience: 7, description: '' },
   { name: 'Raman Kumar', age: 34, experience: 10, description: '' }
]
How to directly modify a specific item in a TKinter listbox?

Tkinter is a Python-based GUI application development library which is generally used to build useful functional desktop applications. The Listbox widget is another tkinter widget, which is used as a container to display a list of items in the form of a Listbox.
To define a list of items in a Listbox widget, you'll need to create a constructor of Listbox(root, width, height, **options). You can insert as many items as you want to display in the listbox.
Suppose you want to modify a specific item in a tkinter Listbox, then you can first create a button to select the item from the list you want to modify, and then call the delete() method to delete any existing values from it. Once the values are deleted, you can insert() a new item in the listbox.Let's take an example to understand how it works.
# Import the required libraries
from tkinter import *
from tkinter import ttk

# Create an instance of tkinter frame or window
win = Tk()

# Set the size of the window
win.geometry("700x350")

# Create a Listbox widget
lb = Listbox(win, width=100, height=10, background="purple3", foreground="white", font=('Times 13'), selectbackground="white")

lb.pack()

# Select the list item and delete the item first
# Once the list item is deleted,
# we can insert a new item in the listbox
def edit_current():
   for item in lb.curselection():
      lb.delete(item)
      lb.insert("end", "foo")

# Add items in the Listbox
lb.insert("end", "item1", "item2", "item3", "item4", "item5")

# Add a Button To Edit and Delete the Listbox Item
ttk.Button(win, text="Edit", command=edit_current).pack()

win.mainloop()
In this example, we have created a list of items using the Listbox widget. We have created a button named "Edit" which basically modifies the existing values of selected list items. Using this, you can replace/modify the values of any item in the list in the Listbox widget.
Once executed, it will produce the following output window −
Now, select an item from the list and click the "Edit" button. Suppose you select "item5" and click "Edit", then that particular entry will be replaced by "foo".
Aptitude | GATE CS 1998 | Question 47 - GeeksforGeeks

15 Mar, 2018
What value would the following function return for the input x=95 ?
function fun (x:integer):integer;
Begin
  If x >100 then fun = x-10
  Else fun = fun(fun( x+11))
End;

(A) 89(B) 90(C) 91(D) 92Answer: (C)Explanation: for solution refer ISRO CS 2017So option C is correctQuiz of this Question
Aptitude
Aptitude-GATE CS 1998
GATE CS 1998
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE CS 2019 | Question 27
GATE | GATE-IT-2004 | Question 66
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2006 | Question 49
GATE | GATE-CS-2004 | Question 3
GATE | GATE-CS-2000 | Question 43
GATE | GATE-CS-2017 (Set 2) | Question 42
GATE | GATE CS 2010 | Question 24
GATE | Gate IT 2007 | Question 30
Java Program to Concatenate Two Arrays

One way of doing it is, create an array of length equals to the sum of lengths of the two arrays and, add elements of both arrays to it one by one.
Live Demo
public class HelloWorld {
   public static void main(String[] args) {
      int[]a = {1,2,3,4};
      int[]b = {4,16,1,2,3,22};
      int[]c = new int[a.length+b.length];
      int count = 0;

      for(int i = 0; i<a.length; i++) {
         c[i] = a[i];
         count++;
      }

      for(int j = 0;j<b.length;j++) {
         c[count++] = b[j];
      }

      for(int i = 0;i<c.length;i++) System.out.print(c[i]+" ");
   }
}
1 2 3 4 4 16 1 2 3 22
\sf - Tex Command

\sf - Used to turn on sans serif mode for uppercase and lowercase letters and digits, and for uppercase Greek.
{ \sf}
\sf command turns on sans serif mode for uppercase and lowercase letters and digits, and for uppercase Greek.

\sf ABCDEFGHIJKLMNOPQRSTUVWXYZ

ABCDEFGHIJKLMNOPQRSTUVWXYZ


\sf 0123456789

0123456789


\sf abcdefghijklmnopqrstuvwxyz

abcdefghijklmnopqrstuvwxyz


ABCDE 01234 abcde

ABCDE01234abcde


{\sf AB\Delta\Gamma\Lambda}\ AB\Delta\Gamma\Lambda

ABΔΓΛ ABΔΓΛ


\sf AB \rm AB

ABAB


\sf{AB}CD

ABCD



\sf ABCDEFGHIJKLMNOPQRSTUVWXYZ

ABCDEFGHIJKLMNOPQRSTUVWXYZ


\sf ABCDEFGHIJKLMNOPQRSTUVWXYZ
\sf 0123456789

0123456789


\sf 0123456789
\sf abcdefghijklmnopqrstuvwxyz

abcdefghijklmnopqrstuvwxyz


\sf abcdefghijklmnopqrstuvwxyz
ABCDE 01234 abcde

ABCDE01234abcde


ABCDE 01234 abcde
{\sf AB\Delta\Gamma\Lambda}\ AB\Delta\Gamma\Lambda

ABΔΓΛ ABΔΓΛ


{\sf AB\Delta\Gamma\Lambda}\ AB\Delta\Gamma\Lambda
\sf AB \rm AB

ABAB


\sf AB \rm AB
\sf{AB}CD

ABCD


\sf{AB}CD

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
Tryit Editor v3.7

Tryit: Create input field with an icon inside
How to unzip all zipped files in a Linux directory?

Unzip is the Linux command utility that we will use to unzip all zipped files present in a Linux directory.
By default, the unzip utility is not present on most of the Linux distributions and we can install the same with the help of the commands mentioned below.
sudo apt install unzip
sudo yum install unzip
unzip file.zip
In the above syntax we just need to replace the file.zip with the file that we want to unzip.
Consider a case where I have a directory named direct1 that looks something like this −
immukul@192 direct1 % ls -ltr
total 5216
-rwxrwxrwx 1 immukul staff 446966 Sep 23 1998 wget-1.5.3.tar.gz
drwxr-xr-x 2 immukul staff 64 Jul 13 11:36 dr1
drwxr-xr-x 3 immukul staff 96 Jul 13 11:36 dr2
-rw-r--r-- 1 immukul staff 2201512 Jul 14 09:19 zipContent.zip
-rw-r--r-- 1 immukul staff 122 Jul 14 16:10 somefile.txt
drwxrwxrwx 5 immukul staff 160 Jul 16 10:01 d1
-rwxrwxrwx 1 immukul staff 300 Jul 16 10:06 sample.sh
-rw-r--r-- 1 immukul staff 83 Jul 16 10:58 sample.txt
drwxr-xr-x 3 immukul staff 96 Jul 16 11:05 dir1
drwxr-xr-x 3 immukul staff 96 Jul 16 11:46 dir2
-rw-r--r-- 1 immukul staff 661 Jul 16 11:47 newZip.zip
As one can notice, there are few .zip files present in the above directory and we can unzip all these .zip files with the help of the command shown below.
unzip “*.zip”
Now once we run the following command, all the .zip files will be unzipped and their contents will be printed in the terminal.
immukul@192 direct1 % ls -ltr
total 13504
-rwxrwxrwx 1 immukul staff 446966 Sep 23 1998 wget-1.5.3.tar.gz
-rwxrwxrwx 1 immukul staff 7 Jul 7 10:37 2.txt
-rwxrwxrwx 1 immukul staff 4234901 Jul 7 17:41 file.txt
-rwxrwxrwx 1 immukul staff 8 Jul 8 19:05 3.txt
-rwxrwxrwx 1 immukul staff 946 Jul 12 18:45 sample.sh
drwxr-xr-x 2 immukul staff 64 Jul 13 11:36 dr1
drwxr-xr-x 3 immukul staff 96 Jul 13 11:36 dr2
-rw-r--r-- 1 immukul staff 2201512 Jul 14 09:19 zipContent.zip
-rw-r--r-- 1 immukul staff 122 Jul 14 16:10 somefile.txt
-rw-r--r-- 1 immukul staff 83 Jul 16 10:58 sample.txt
drwxr-xr-x 3 immukul staff 96 Jul 16 11:05 dir1
drwxr-xr-x 3 immukul staff 96 Jul 16 11:46 dir2
-rw-r--r-- 1 immukul staff 661 Jul 16 11:47 newZip.zip
drwxrwxrwx 5 immukul staff 160 Jul 16 11:48 d1
drwxr-xr-x 4 immukul staff 128 Jul 16 11:48 d2
How to create new alias with PowerShell?

Anyone can create a new alias which is a shortcut to another command. To create your own alias you need to use Set-Alias cmdlet. Here, we will create a new alias Edit, which will open a
Notepad.exe. First, we will check if Edit alias exists or not.
$Alias:Edit
As this is going to be a new Alias there will be no output for it. Now, we will create new alias by the below command. You can provide any program path and create an alias for it.
Set-Alias Edit Notepad.exe
Just check if this Edit alias created successfully or not.
PS E:\scripts\Powershell> $Alias:Edit
Notepad.exe
This new alias is not permanent. Once you close the PowerShell console, all newly created aliases will be discarded. But the built-in alias will still remain.
If you want to create an alias permanently you have few options.
Manually each time − You need to set the alias each time when PowerShell console starts but this is not a feasible option.
Manually each time − You need to set the alias each time when PowerShell console starts but this is not a feasible option.
Import and Export − You can export the newly created alias and import it when the PowerShell starts.
Import and Export − You can export the newly created alias and import it when the PowerShell starts.
Save Alias in Profile − You can add your alias to your profile path. So when the profile starts, the alias will be created automatically when PowerShell starts.
Save Alias in Profile − You can add your alias to your profile path. So when the profile starts, the alias will be created automatically when PowerShell starts.
C# program to find Intersection of two lists

To find intersection of two lists in C#, use the Intersect() method.
The following is our list 1.
List<int> list1 = new List<int>();
list1.Add(2);
list1.Add(3);
list1.Add(5);
list1.Add(7);
The following is our list 2.
List<int> list2 = new List<int>();
list2.Add(5);
list2.Add(4);
list2.Add(6);
list2.Add(8);
The following is the code to find the intersection of two lists in C#.
 Live Demo
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Demo {
   public class Program {
      public static void Main(String[] args) {
         List<int> list1 = new List<int>();
         list1.Add(2);
         list1.Add(3);
         list1.Add(5);
         list1.Add(7);
         Console.WriteLine(list1.Count);
         List<int> list2 = new List<int>();
         list2.Add(5);
         list2.Add(4);
         list2.Add(6);
         list2.Add(8);
         Console.WriteLine(list2.Count);
         List<int> common = list1.Intersect(list2).ToList();
         Console.WriteLine(common.Count);
      }
   }
}
4
4
1
How to change the datatype of a column in an existing table using JDBC API?

You can change the datatype of a column in a table using the ALTER TABLE command.
ALTER TABLE Sales MODIFY COLUMN column_name column_new_datatuype
Assume we have a table named Sales in the database with 7 columns namely ProductName, CustomerName, DispatchDate, DeliveryTime, Price, Location and, ID with description as:
+--------------+--------------+------+-----+---------+-------+
| Field        | Type         | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+-------+
| ProductName  | varchar(255) | YES  |     | NULL    |       |
| CustomerName | varchar(255) | YES  |     | NULL    |       |
| DispatchDate | date         | YES  |     | NULL    |       |
| DeliveryTime | time         | YES  |     | NULL    |       |
| Price        | int(11)      | YES  |     | NULL    |       |
| Location     | varchar(255) | YES  |     | NULL    |       |
| ID           | int(11) | NO |      | NULL|         |       |
+--------------+--------------+------+-----+---------+-------+
Following JDBC program establishes connection with MySQL database, and changes the data-type of the column location from varchar to text.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class ChangingDatatype {
   public static void main(String args[]) throws SQLException {
      //Registering the Driver
      DriverManager.registerDriver(new com.mysql.jdbc.Driver());
      //Getting the connection
      String mysqlUrl = "jdbc:mysql://localhost/mydatabase";
      Connection con = DriverManager.getConnection(mysqlUrl, "root", "password");
      System.out.println("Connection established......");
      //Creating the Statement
      Statement stmt = con.createStatement();
      //Query to alter the table
      String query = "ALTER TABLE Sales MODIFY COLUMN Location Text";
      //Executing the query
      stmt.executeUpdate(query);
      System.out.println("Column datatype changed......");
   }
}
Connection established......
Column datatype changed......
Since we have altered the type of location column, if you get the description of the Sales table using the describe command you can observe that the data-type of the column named location is changed from varchar to text.
mysql> describe sales;
+--------------+--------------+------+-----+---------+-------+
| Field        | Type         | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+-------+
| ProductName  | varchar(255) | YES  |     | NULL    |       |
| CustomerName | varchar(255) | YES  |     | NULL    |       |
| DispatchDate | date         | YES  |     | NULL    |       |
| DeliveryTime | time         | YES  |     | NULL    |       |
| Price        | int(11)      | YES  |     | NULL    |       |
| Location     | text         | YES  |     | NULL    |       |
| ID           | int(11)      | NO   |     | NULL    |       |
+--------------+--------------+------+-----+---------+-------+
7 rows in set (0.00 sec)
Truly Customizing Power BI with React, Angular, or any web framework | by Thiago Candido | Towards Data Science

With the growth of the amount of data available in organizations, presenting it in a clear and direct way is increasingly important. In this context, Power BI — Microsoft’s business analysis tool — has gained prominence.
Even counting on integrated components and navigation mechanisms, enough to meet most of the regular enterprise needs, the platform still stands out for its customization possibilities.
Besides being able to customize the platform’s built-in components, it is possible, with some front-end engineering skills, to develop new ones from scratch.
The development process of a new component takes place through the programming of Custom Visuals, using the PowerBI Visual Tools package, or pbiviz, which can be installed with Node Package Manager — NPM.
The development of a Custom Visual requires only knowledge of conventional web technologies such as Typescript, HTML and CSS and can be enhanced by the use of frameworks such as React, Angular or D3.js.
The design of a Custom Visual is generated, with all that is necessary, by a CLI tool, provided by the NPM package that was indicated above.
Basically, the web developer will need to write little code — just two methods: the constructor and the update of a class that implements IVisual. In addition, the file capabilities.json, also generated by the CLI tool, allows the user to define properties, such as colors and fonts, which can be customized later during use by the end-user in Power BI.
export class Visual implements IVisual { constructor(options: VisualConstructorOptions) {   // code here  } public update(options: VisualUpdateOptions) {    // ... and here }}
The tooling provided by pbiviz allows the web developer to have instant feedback on his work, with updates that occur with hot reload. All supported by Power BI Service.
Besides being able to benefit from the work done on your reports and dashboards, it is also possible to share the creation in App Source — application store for Microsoft companies. While this article was written, over 260 free custom visuals were available.
I hope you enjoyed reading this post.
If you did, consider following me on Twitter.
Thank you for your time.
Take care and keep coding!
How to take input in Octave GNU? - GeeksforGeeks

01 Aug, 2020
Octave is open-source, free available for many of the platforms. It is a high-level language. It comes up with a text interface along with an experimental graphical interface. It is also used for various Machine Learning algorithms for solving various numeric problems. You can say that it is similar to MATLAB but slower than MATLAB.
There are multiple library functions to take input from the user in Octave.
The input() function prints the prompt and waits for the user to enter a value, it takes an expression, evaluates it, and then returns it. The return arguments depend on the expression entered.
Syntax : input(prompt, “s”)Parameters :
prompt : the text prompted on the terminal
“s” : indicates not to evaluate the entered expression
Returns : depends on the input value
Example 1 :
var = input("Enter an expression : ");% entered expression is 2 + 3  fprintf("Input is %d\n", var);
Output :
Enter an expression : 2 + 3
Input is 5

Example 2 : Using the “s” attribute :
var = input("Enter an expression : ", "s");% entered expression is 2 + 3  fprintf("Input is %s\n", var);
Output :
Enter an expression : 2 + 3
Input is 2 + 3

The yes_or_no() function accepts only two input values, either yes or no.
Syntax : yes_or_no(“prompt”)Parameters :
prompt : the text prompted on the terminal
Returns : 1 if “yes”, 0 if “no”
If any other value except yes or no is entered, the prompt will reappear asking for the input.
Example :
var = yes_or_no("Enter a value : ");% entered value is yesdisp(var)  var = yes_or_no("Enter a value : ");% entered value is nodisp(var)
Output:
Enter a value : (yes or no) yes
1
Enter a value : (yes or no) no
0

The kbhit() function waits for any keypress, after the key is pressed, it returns that key.
Syntax : kbhit(argument)Parameters :
argument : if called with an argument, it does not wait for a keypress
Returns : depends on the input value
Example :
kbhit()% entered value is a  kbhit(1)
ans = a
ans =

The menu() function is used to display a menu with a heading title and options, and wait for the user input. If the GUI is running, the menu is displayed graphically Otherwise, the title and menu options are printed on the console.
Syntax : menu(title, opt1, ...)Parameters :
title : title of the menu window
opt1, opt2 ... : list of options in the menu window
Returns : depends on the option selected
Example :
% generating the menuchoice = menu("title", "opt1","opt2","opt3");  % displaying the choicefprintf("The choice is : ");disp(choice);
Output :
The choice is :  1

Octave-GNU
Programming Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Programming Languages to Learn in 2022
Difference between Shallow and Deep copy of a class
Advantages and Disadvantages of OOP
Java Swing | JComboBox with examples
Top 10 Fastest Programming Languages
Prolog | An Introduction
JLabel | Java Swing
Control Structures in Programming Languages
Program to calculate Electricity Bill
return 0 vs return 1 in C++
Z-Buffer or Depth-Buffer method in C++

The z-buffer also known as depth-buffer is a method that is used for hidden surface detection.
For any picture that has objects and surfaces that are transparent. In this case, objects that are behind other objects are hidden. For proper visual of the image, we need to remove these hidden surfaces is required. The identification is called hidden surface problem.
In z-buffer, we will compare surfaces in the z-axis as depths.
Step 1: initialize the depth of all pixel max.
   d(i,j) = infinity
Step 2: Initialize color for all pixels.
   c(i,j) = background-color
Step 3: for each pixel in polygon projection do,
   Step 3.1: find z i.e. depth of projection’s (i,j) pixel.
   Step 3.2: if z < d(i,j) do
      Step 3.2.1 : d(i,j) = z and c(i,j) = color of polygon.
Using this method pixel by pixel, we will find the depth of each pixel of the plane. The smallest surface determines the color of the buffer. Generally, all z values are close to the range[0,1].
z=0, back clipping plane and z= 1, front clipping plane.
No initial sorting of polygons(planes) is required to apply the z-buffer method.
No initial sorting of polygons(planes) is required to apply the z-buffer method.
Z-buffer provides fast results even if the number of planes is large.
Z-buffer provides fast results even if the number of planes is large.
Object comparison is not required in the z-buffer method.
Object comparison is not required in the z-buffer method.
Non-polygonal hidden objects can also be detected using this method.
Non-polygonal hidden objects can also be detected using this method.
No extra data-structure for storing and resolving is required.
No extra data-structure for storing and resolving is required.
Hardware implementation is possible to speed up the process and is actively used in solve graphic workstations.
Hardware implementation is possible to speed up the process and is actively used in solve graphic workstations.
The method is applicable only when the objects under consideration are opaque i.e. transparent objects might give an error.
The method is applicable only when the objects under consideration are opaque i.e. transparent objects might give an error.
Drawing of the hidden surface might be a time-consuming process.
Drawing of the hidden surface might be a time-consuming process.
fopen() function in PHP

The fopen() function opens a file or URL. If the function fails, it returns FALSE and an error on failure. Add an '@' in front of the function name to hide the error output.
fopen(file_path, mode, include_path, context)
file_path − The path of the file.
file_path − The path of the file.
mode − The type of access you require to the file“r” - Read Only"r+" - Read/Write"w" - Write only"w+" - Read/Write"a" - Write only. Opens and writes to the end of the file or creates a new file if it doesn't exist)"a+" - Read/Write. Preserves file content by writing to the end of the file)"x" - Write only. Creates a new file. Returns FALSE and an error if file already exists)"x+" - Read/Write. Creates a new file. Returns FALSE and an error if file already exists)
mode − The type of access you require to the file
“r” - Read Only
"r+" - Read/Write
"w" - Write only
"w+" - Read/Write
"a" - Write only. Opens and writes to the end of the file or creates a new file if it doesn't exist)
"a+" - Read/Write. Preserves file content by writing to the end of the file)
"x" - Write only. Creates a new file. Returns FALSE and an error if file already exists)
"x+" - Read/Write. Creates a new file. Returns FALSE and an error if file already exists)
incude_path − Set it to '1' if you want to search for the file in the include_path (in php.ini) as well.
incude_path − Set it to '1' if you want to search for the file in the include_path (in php.ini) as well.
context − the context of the file pointer.
context − the context of the file pointer.
The fopen() function returns returns FALSE and an error on failure. Add an '@' in front of the function name to hide the error output.
Let’s say we have a file “new.txt” with the following content.
The content of the file!
Now, let us see the example −
<?php
   // read/ write mode
   $file_pointer = fopen("new.txt", 'r+')
   or die("File does not exist");
   $res = fgets($file_pointer);
   echo $res;
   fclose($ile_pointer);
?>
The content of the file!
Let us see an example with “one.txt” file.
<?php
   // read/write mode
   $file_pointer = fopen("one.txt", "w+");
   // writing to file
   fwrite($file_pointer, 'demo content');
   echo fread($file_pointer, filesize("new.txt"));
   fclose($file_pointer);
?>
demo content
Project specific array field in a MongoDB collection?

Let us first create a collection with documents −
> db.projectionAnElementDemo.insertOne(
...    {
...       "CustomerId":100,
...       "CustomerDetails": [
...          {
...             "CustomerName": "Chris",
...             "CustomerCountryName": "US"
...          },
...          {
...             "CustomerName": "Robert",
...             "CustomerCountryName": "UK"
...          }
...       ]
...    }
... );
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cd31c56b64f4b851c3a13ea")
}
Following is the query to display all documents from a collection with the help of find() method −
> db.projectionAnElementDemo.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5cd31c56b64f4b851c3a13ea"),
   "CustomerId" : 100,
   "CustomerDetails" : [
      {
         "CustomerName" : "Chris",
         "CustomerCountryName" : "US"
      },
      {
         "CustomerName" : "Robert",
         "CustomerCountryName" : "UK"
      }
   ]
}
Following is the query to project element in array field −
> db.projectionAnElementDemo.find({},{CustomerId:1, "CustomerDetails.CustomerName":1}).pretty();
This will produce the following output −
{
   "_id" : ObjectId("5cd31c56b64f4b851c3a13ea"),
   "CustomerId" : 100,
   "CustomerDetails" : [
      {
         "CustomerName" : "Chris"
      },
      {
         "CustomerName" : "Robert"
      }
   ]
}