code-rag-bench/online-tutorials huggingface dataset:
Laravel - Action URL

Laravel 5.7 introduces a new feature called “callable action URL”. This feature is similar to the one in Laravel 5.6 which accepts string in action method. The main purpose of the new syntax introduced Laravel 5.7 is to directly enable you access the controller.
The syntax used in Laravel 5.6 version is as shown −
<?php
$url = action('UserController@profile', ['id' => 1]);

The similar action called in Laravel 5.7 is mentioned below −
<?php
$url = action([PostsController::class, 'index']);

One advantage with the new callable array syntax format is the feature of ability to navigate to the controller directly if a developer uses a text editor or IDE that supports code navigation.

    13 Lectures 
     3 hours 

 Sebastian Sulinski

    35 Lectures 
     3.5 hours 

 Antonio Papa

    7 Lectures 
     1.5 hours 

 Sebastian Sulinski

    42 Lectures 
     1 hours 

 Skillbakerystudios

    165 Lectures 
     13 hours 

 Paul Carlo Tordecilla

    116 Lectures 
     13 hours 

 Hafizullah Masoudi
 Print
 Add Notes
 Bookmark this page
Neo4j - Max Function

It takes a set of rows and a <property-name> of a node or relationship as an input and finds the maximum value from the given <property-name> column of the given rows.
Following is the syntax of the MAX() function.
MAX(<property-name>) 

Following is a sample Cypher query, which demonstrates the usage of the function MAX() in Neo4j. Here we are trying to calculate the maximum salaries of the employees.
MATCH (n:employee) RETURN MAX(n.sal)
To execute the above query, carry out the following steps −
Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot.
Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot.
On executing, you will get the following result.
 Print
 Add Notes
 Bookmark this page
How to extract the p-value and F-statistic from aov output in R?

The analysis of variance technique helps us to identify whether there exists a significant mean difference in more than two variables or not. To detect this difference, we either use F-statistic value or p-value. If the F-statistic value is greater than the critical value of F or if p-value is less than the level of significance then we say that at least one of the means is significantly different from the rest. To extract the p-value and F-statistic value, we can make use of summary function of the ANOVA model.
 Live Demo
set.seed(123)
Group<-rep(c("G1","G2","G3","G4"),times=5)
Response<-runif(20,2,5)
df<-data.frame(Group,Response)
df
Group Response
1 G1 2.862733
2 G2 4.364915
3 G3 3.226931
4 G4 4.649052
5 G1 4.821402
6 G2 2.136669
7 G3 3.584316
8 G4 4.677257
9 G1 3.654305
10 G2 3.369844
11 G3 4.870500
12 G4 3.360002
13 G1 4.032712
14 G2 3.717900
15 G3 2.308774
16 G4 4.699475
17 G1 2.738263
18 G2 2.126179
19 G3 2.983762
20 G4 4.863511
ANOVA<-aov(Response~Group,df)
summary(ANOVA)
Df Sum Sq Mean Sq F value Pr(F)
Group 3 4.813 1.6043 2.141 0.135
Residuals 16 11.990 0.7494
summary(ANOVA)[[1]][1,4:5]
F value Pr(F)
Group 2.1408 0.1351
If we want to extract only p-value then it can be done as shown below −
summary(ANOVA)[[1]][1,5]
[1] 0.1351315
If we want to extract only F-value then it can be done as shown below −
summary(ANOVA)[[1]][1,4]
[1] 2.140825
Let’s have a look at one more example −
 Live Demo
Factor<-rep(c("F1","F2","F3","F4","F5"),each=4)
Dependent<-rnorm(20,2)
ANOVA_data<-data.frame(Factor,Dependent)
ANOVA_data
Factor Dependent
1 F1 2.2236414
2 F1 4.0072015
3 F1 3.0119791
4 F1 1.6975408
5 F2 0.9747552
6 F2 1.7326152
7 F2 1.8008943
8 F2 2.1311226
9 F3 2.1457999
10 F3 2.3620647
11 F3 2.6739812
12 F3 4.0720358
13 F4 1.4589714
14 F4 0.9295078
15 F4 1.6275433
16 F4 1.5148586
17 F5 2.2747842
18 F5 1.5204874
19 F5 2.7981053
20 F5 0.9955488
ANOVA_Model<-aov(Dependent~Factor,ANOVA_data)
summary(ANOVA_Model)
Df Sum Sq Mean Sq F value Pr(F)
Factor 4 6.647 1.6617 3.04 0.0508 .
Residuals 15 8.200 0.5467
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
summary(ANOVA_Model)[[1]][1,4:5]
F value Pr(F)
Factor 3.0395 0.05078 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
summary(ANOVA_Model)[[1]][1,5]
[1] 0.05077798
summary(ANOVA_Model)[[1]][1,4]
[1] 3.039549
How can Tensorflow be used to evaluate a CNN model using Python?

A convolutional neural network can be evaluated using the ‘evaluate’ method. This method takes the test data as its parameters. Before this, the data is plotted on the console using ‘matplotlib’ library and ‘imshow’ methods.
Read More:
What is TensorFlow and how Keras work with TensorFlow to create Neural Networks?
Convolutional neural networks have been used to produce great results for a specific kind of problems, such as image recognition.  
We are using the Google Colaboratory to run the below code. Google Colab or Colaboratory helps run Python code over the browser and requires zero configuration and free access to GPUs (Graphical Processing Units). Colaboratory has been built on top of Jupyter Notebook.
print("Plotting accuracy versus epoch")
plt.plot(history.history['accuracy'], label='accuracy')
plt.plot(history.history['val_accuracy'], label = 'val_accuracy')
plt.xlabel('Epoch')
plt.ylabel('Accuracy')
plt.ylim([0.5, 1])
plt.legend(loc='lower right')
print("The model is being evaluated")
test_loss, test_acc = model.evaluate(test_images,test_labels, verbose=2)
print("The accuracy of the model is:")
print(test_acc)
Code credit: https://www.tensorflow.org/tutorials/images/cnn
Plotting accuracy versus epoch
The model is being evaluated
313/313 - 3s - loss: 0.8884 - accuracy: 0.7053
The accuracy of the model is:
0.705299973487854
The accuracy versus epoch data is visualized.
This is done using matplotlib library.
The model is evaluated, and the loss and accuracy are determined.
Adding Lottie animation in React JS

Lottie is an open source animation file format that’s tiny, high quality,
interactive, and can be manipulated at runtime. Let us learn how to
implement Lottie animation in React.js. Lottie animations are mainly
used for loader screen or as a start screen. It is written and
implemented in JSON format in our React projects.
Go to the official Lottie animation website and download Lottie JSON.
Link to animation the I am going to use −
 https://lottiefiles.com/74546-character-02#/
Name the JSON file "myloader.json" and keep it at the same level as App.js.
Now install the react-lottie package −
npm i --save react-lottie
Lottie library will be used to add lottie-animation’s JSON file to your
React site.
Add the following lines of code in App.js −
import Lottie from "react-lottie";

// importing lottie animation JSON
// note that you can use any variable in place of "animation"
import animation from './myloader.json'
function App() {
   const defaultOptions = {
      loop: true,
      autoplay: true,
      // here is where we will declare lottie animation
      // "animation" is what we imported before animationData: animation,
      rendererSettings: {
         preserveAspectRatio: "xMidYMid slice",
      },
   };

   return (
      <div>
         <Lottie options={defaultOptions} height={300} width={300} />
      </div>
   );
}

export default App;
Here in defaultOptions, we simply added some animation properties and linked to our Lottie animation JSON. Then we rendered a lottieView with our default options and link to animation.
It will produce the following output −
Your browser does not support HTML5 video.
Find other two sides of a right angle triangle in C++

In this problem, we are given an integer a denoting one side of a right angle
triangle. We need to check whether it is possible to have a right angle triangle with side a. If it is possible, then find the other two sides of a right angle triangle.
Let’s take an example to understand the problem,
a = 5
Sides : 5, 12, 13
The sides of right angle are found as 52 + 122 = 132
A simple solution to the problem is using pythagoras theorem. We know that the sides of a right angled triangle follow pythagoras theorem, which is
a2 + b2 = c2
Where a and b are sides of the triangle and c is the hypotenuse of the triangle.
Using this, we will calculate values of b and c using a.
If a is even,
c = (a2 + 4) + 1
b = (a2 + 4) - 1
If a is odd,
c = (a2 + 1)/ 2
c = (a2 - 1)/ 2
Program to illustrate the working of our solution,
 Live Demo
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define PI 3.1415926535
void printOtherSides(int n) {
   int b,c;
   if (n & 1) {
      if (n == 1)
         cout << -1 << endl;
      else{
         b = (n*n-1)/2;
         c = (n*n+1)/2;
      }
   } else {
      if (n == 2)
         cout << -1 << endl;
      else{
         b = n*n/4-1;
         c = n*n/4+1;
      }
   }
   cout<<"Sides : a = "<<n<<", b = "<<b<<", c = "<<c<<endl;
}
int main() {
   int a = 5;
   printOtherSides(a);
   return 0;
}
Sides : a = 5, b = 12, c = 13
8085 program to convert gray to binary

Now let us see a program of Intel 8085 Microprocessor. This program will convert gray code to binary code.
Write an assembly language program for 8085 to convert gray code to binary code. The data is stored at address 8200H & store the result at memory location 8201H.
Here we are loading the number from memory and in each step we are performing right shift, and XOR the intermediate result with the previous one. Thus we are getting the result. In the following demonstration you can get the logic.
C       1110 1011    (A) (EBH)
07H     0111 0101    (RAR)
XOR     1110 1011    (D)
        1001 1110    (A = A XOR D) (9EH)
06H     0100 1111    (RAR)
XOR     1110 1011    (D)
        1010 0100    (A = A XOR D) (A4H)
05H     0101 0010    (RAR)
XOR     1110 1011    (D)
        1011 1001    (A = A XOR D) (B9H)
04H     0101 1100    (RAR)XOR     1110 1011   (D)        1011 0111    (A = A XOR D) (B7H)
03H     0101 1011    (RAR)
XOR     1110 1011    (D)
        1011 0000    (A = A XOR D) (B0H)
02H     0101 1000    (RAR)
XOR     1110 1011    (D)
        1011 0011    (A = A XOR D) (B3H)
01H     0101 1001    (RAR)
XOR     1110 1011    (D)
        1011 0010    (A = A XOR D) (B2H) 
XOR     1110 1011   (D)
C | Advanced Pointer | Question 7 - GeeksforGeeks

28 Jun, 2021
Assume that the size of int is 4.
#include <stdio.h>void f(char**);int main(){    char *argv[] = { "ab", "cd", "ef", "gh", "ij", "kl" };    f(argv);    return 0;}void f(char **p){    char *t;    t = (p += sizeof(int))[-1];    printf("%s\n", t);}
(A) ab(B) cd(C) ef(D) ghAnswer: (D)Explanation: The expression (p += sizeof(int))[-1] can be written as (p += 4)[-1] which can be written as (p = p+4)[-] which returns address p+3 which is address of fourth element in argv[].Quiz of this Question
Advanced Pointer
C-Advanced Pointer
C Language
C Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Multidimensional Arrays in C / C++
rand() and srand() in C/C++
Substring in C++
Core Dump (Segmentation fault) in C/C++
Left Shift and Right Shift Operators in C/C++
Compiling a C program:- Behind the Scenes
Operator Precedence and Associativity in C
C | Loops & Control Structure | Question 8
Output of C programs | Set 64 (Pointers)
C | File Handling | Question 1
Installing CUDA on Google Cloud Platform in 10 minutes | by Shruti | Towards Data Science

Recently, I spent *quite* some time setting up my CUDA instance on Google Cloud Platform (GCP). After a lot of errors and articles, I figured that it could have been done pretty quick, had I stumbled upon the correct setup process in the first go!
So I decided to write this post to get your CUDA enabled instance running in minutes. By the end of this post, you will have CUDA 10.0, cuDNN 7.6.5 and Ubuntu 16.04 installed on GCP.
Step 0: Create a free account on Google Cloud Platform (GCP)
Create a free account on Google Cloud Platform. Enter your credit card details and verify. You will get 300$ credit.
To use GPU, you will need to upgrade to a paid account and increase your GPU quota. If you don’t already have a verified, upgraded account, this step can take some time (usually 1–2 days).
Step 1: Set up a VM instance on GCP
Choose a project. I selected ‘My First Project’
Create a VM instance in your project. Click on ‘Create’.
Select the number of CPU cores you need, and the GPU you want. I chose ‘n1-standard-8' CPU and one ‘P100 GPU’.
Select the OS as Ubuntu 16.04 and the boot disk size. 200 GB is the recommended size.
Tick firewall rules, then click on ‘Management, security, disks, networking, sole tenancy’.
Disable boot disk delete option under ‘Disks’
Click on create at the end, and your instance is ready!
Click on SSH to open a terminal. Your instance should be running.
Don’t close the terminal. You will install CUDA and cuDNN in this terminal, NOT in your local desktop terminal.
ALERT!! Your instance is up and running now. You are being CHARGED. IF your usage exceeds 300$ credit, you will have to pay the balance amount. DON’T forget to stop the instance when not in use.
Step 2: Install CUDA
I installed CUDA 10.0 for Ubuntu1604. You can install other CUDA versions as well and edit the following code accordingly.
You might get libcudnn.so is not symbolic link error at this point. Check at the bottom of this post for the solution
Step 3: Install CuDNN
You need to create a developer account on Nvidia before proceeding, for free.
To verify CUDA 10.0 installation, run the following command. It should print the CUDA version installed.
nvcc -V 
Full code for easy reference.
Step 4: Install Tensorflow and other packages
You can install Tensorflow and basic python packages like ipython and pip.
ALERT!! Don’t forget to STOP the instance!
On sudo ldconfig, you might get the following error:
/usr/local/cuda/lib64/libcudnn.so.7 is not a symbolic link
This is because libcudnn.so.5 and libcudnn.so are not symlinks. You can read the details here.
To solve the error, perform the following steps:
This concludes our quick post on setting up a CUDA enabled VM instance on Google Cloud Platform.
I hope you enjoyed this more technical post!
How to generate all permutations of a list in Python?

You can use the itertools package's permutations method to find all permutations of a list in Python. You can use it as follows −
import itertools
perms = list(itertools.permutations([1, 2, 3]))
print(perms)
This will give the output −
[(1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1)]
Accessing HTML source code using Python Selenium.

We can access HTML source code with Selenium webdriver. We can take the help of the page_source method and print the value obtained from it in the console.
src = driver.page_source
We can also access the HTML source code with the help of Javascript commands in Selenium. We shall take the help of execute_script method and pass the command return document.body.innerHTML as a parameter to the method.
h = driver.execute_script("return document.body.innerHTML;")
Code Implementation.
from selenium import webdriver
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
driver.implicitly_wait(0.5)
driver.get("https://www.tutorialspoint.com/index.htm")
# access HTML source code with page_source method
s = driver.page_source
print(s)
Code Implementation with Javascript Executor.
from selenium import webdriver
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
driver.implicitly_wait(0.5)
driver.get("https://www.tutorialspoint.com/index.htm")
# access HTML source code with Javascript command
h = driver.execute_script("return document.body.innerHTML")
print(h)
How to Install Pandas-Profiling on Windows? - GeeksforGeeks

09 Sep, 2021
In this article, we will look into ways of installing the Pandas Profiling package in Python.
Python
PIP or Conda (Depending upon preference)
Pip users can just open up the command prompt and use the below command to install the Pandas profiling package in python:
pip install pandas-profiling
The following message will be shown once the installation is completed:
Conda users can open up the Anaconda Power Shell Prompt and use the below command to install the pandas profiling package in python:
conda install -c anaconda pandas-profiling 
The following message will be shown once the installation is completed:
You can use the below code to verify your installation. Make sure to add a sample .csv file having some data to check the installation and replace the Geeks.csv file in the below code.
Python3
#import the packagesimport pandas as pdimport pandas_profiling  # read the filedf = pd.read_csv('Geeks.csv')  # run the profile reportprofile = df.profile_report(title='Pandas Profiling Report')
Output:
Blogathon-2021
how-to-install
Picked
Python pandas-basics
Blogathon
How To
Installation Guide
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install Tkinter in Windows?
How to Import JSON Data into SQL Server?
How to configure ESLint for React Projects ?
How to pass data into table from a form using React Components
SQL Query to Create Table With a Primary Key
How to Install PIP on Windows ?
How to Find the Wi-Fi Password Using CMD in Windows?
How to Align Text in HTML?
Java Tutorial
How to Install FFmpeg on Windows?
How to get the day of the month in JavaScript?

To get the day of the month, use the getDate() method. JavaScript date getDate() method returns the day of the month for the specified date according to local time. The value returned by getDate() is an integer between 1 and 31.
You can try to run the following code to learn how to get a day of the month in JavaScript −
Live Demo
<html>
   <head>
      <title>JavaScript getDate Method</title>
   </head>
   <body>
      <script>
         var dt = new Date("December 31, 2017 11:20:10");
         document.write("Today is " + dt.getDate() );
      </script>
   </body>
</html>
Today is 31
Count number of trailing zeros in (1^1)*(2^2)*(3^3)*(4^4)*.. in C++

Given an integer num as input. The goal is to find the number of trailing zeroes in the product 11 X 22 X 33 X...X numnum.
For Example
num=5
Count of number of trailing zeros in (1^1)*(2^2)*(3^3)*(4^4)*.. are: 5
The number of 2s and 5s in the product will be:
11 * 22* 33* 44* 55=11 * 22* 33* (22)4* 55. So total 10 2s and 5 5s, minimum is 5 so trailing zeroes will be 5.
num=10
Count of number of trailing zeros in (1^1)*(2^2)*(3^3)*(4^4)*.. are: 5
The number of 2s and 5s in the product will be:
11 *22*33*44*55*66 *77*88*99*1010 = 11 *22*33*44*55*66 *77*88*99*(2*5)10. So total 20 2s and 15 5s, minimum is 15 so trailing zeroes will be 15.
Approach used in the below program is as follows −
In this approach we will count the number of 2s and 5s in prime factorization of each number in the product. As each number is raised to its own power, the minimum of count of 2s or 5s in factorization will give the count of trailing zeroes. As each 2*5 adds one 0 in the product.
Take an integer num as input.
Take an integer num as input.
Function count_trailing(int num) takes num and returns count of number of
trailing zeros in (1^1)*(2^2)*(3^3)*(4^4)*.....
Function count_trailing(int num) takes num and returns count of number of
trailing zeros in (1^1)*(2^2)*(3^3)*(4^4)*.....
Take the initial count as 0.
Take the initial count as 0.
Take variables temp_2 = 0, temp_5 = 0 for counts of 2s and 5s.
Take variables temp_2 = 0, temp_5 = 0 for counts of 2s and 5s.
Traverse using for loops from i=1 to i<=num.
Traverse using for loops from i=1 to i<=num.
Take temp as i.
Take temp as i.
While temp is divisible by 2 then reduce it to half and add i to count temp_2 as the number of 2s.
While temp is divisible by 2 then reduce it to half and add i to count temp_2 as the number of 2s.
While temp is divisible by 5 then divide it by 5 and add i to count temp_5 as the number of 5s.
While temp is divisible by 5 then divide it by 5 and add i to count temp_5 as the number of 5s.
Take count as a minimum of two counts using count = min(temp_2, temp_5).
Take count as a minimum of two counts using count = min(temp_2, temp_5).
Return count as result.
Return count as result.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
int count_trailing(int num){
   int count = 0;
   int temp_2 = 0;
   int temp_5 = 0;
   for (int i = 1; i <= num; i++){
      int temp = i;
      while(temp % 2 == 0 && temp > 0){
         temp = temp / 2;
         temp_2 = temp_2 + i;
      }
      while (temp % 5 == 0 && temp > 0){
         temp = temp / 5;
         temp_5 = temp_5+ i;
      }
   }
   count = min(temp_2, temp_5);
   return count;
}
int main(){
   int num = 5;
   cout<<"Count of number of trailing zeros in (1^1)*(2^2)*(3^3)*(4^4)*.. are: "<<count_trailing(num);
   return 0;
}
If we run the above code it will generate the following output −
Count of number of trailing zeros in (1^1)*(2^2)*(3^3)*(4^4)*.. are: 5
Program to find Lexicographically Smallest String With One Swap in Python

Suppose we have a string s, we have to find the lexicographically smallest string that can be made if we can make at most one swap between two characters in the given string s.
So, if the input is like "zyzx", then the output will be "xyzz"
To solve this, we will follow these steps −
temp := an array of size s and fill with 0
m:= size of s - 1
for i in range size of s -1 to -1, decrease by 1, doif s[i] < s[m], thenm := itemp[i] := mfor i in range 0 to size of s, doa := temp[i]if s[a] is not same as s[i], thenreturn substring of s [from index 0 to i] concatenate s[a] concatenate
substring of s [from index i+1 to a] concatenate s[i] concatenate
substring of s [from index a+1 to end]
if s[i] < s[m], thenm := i
m := i
temp[i] := m
for i in range 0 to size of s, doa := temp[i]if s[a] is not same as s[i], thenreturn substring of s [from index 0 to i] concatenate s[a] concatenate
substring of s [from index i+1 to a] concatenate s[i] concatenate
substring of s [from index a+1 to end]
a := temp[i]
if s[a] is not same as s[i], thenreturn substring of s [from index 0 to i] concatenate s[a] concatenate
substring of s [from index i+1 to a] concatenate s[i] concatenate
substring of s [from index a+1 to end]
return substring of s [from index 0 to i] concatenate s[a] concatenate
substring of s [from index i+1 to a] concatenate s[i] concatenate
substring of s [from index a+1 to end]
return s
 Live Demo
class Solution:
   def solve(self, s):
      temp = [0]*len(s)
      m=len(s)-1
      for i in range(len(s)-1, -1, -1):
         if s[i]<s[m]: m=i
            temp[i] = m
      for i in range(len(s)):
         a = temp[i]
         if s[a] != s[i]:
            return s[:i]+s[a]+s[i+1:a]+s[i]+s[a+1:]
      return s
ob = Solution()
print(ob.solve("zyzx"))
zyzx
xyzz
Ruby | String chop Method - GeeksforGeeks

17 Jun, 2021
chop is a String class method in Ruby which is used to return a new String with the last character removed. Both characters are removed if the string ends with \r\n, b. Applying chop to an empty string returns an empty string. 
Syntax:str.chopParameters: Here, str is the given string.Returns: A new string having no record separator.  
Example 1:  
Ruby
# Ruby program to demonstrate# the chop method      # Taking a string and# using the methodputs "Ruby".chopputs "Ruby\r\n".chop
Output:  
Rub
Ruby
Example 2: 
Ruby
# Ruby program to demonstrate# the chop method      # Taking a string and# using the methodputs "String\r\n\r\r\n".chop # Removing two charactersputs "Method".chop.chop
Output:  
String

Meth
 
sweetyty
Ruby String-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Ruby | Enumerator each_with_index function
Ruby | Types of Iterators
Ruby | Decision Making (if, if-else, if-else-if, ternary) | Set - 1
Ruby | Class Method and Variables
Ruby | pop() function
Ruby | String chomp! Method
Ruby | Array shift() function
Ruby | String concat Method
Ruby | Operators
Ruby on Rails Introduction
Getter and Setter in Dart Programming

Reading and writing access to objects is very important in any programming language. Getter and Setter are the exact methods that we use when we want to access the reading and writing privileges to an object's properties.
A getter usually looks something like this -
returnType get fieldName {
   // return the value
}
The returnType is the type of data we are returning. The get keyword is what tells us and the compiler that is a getter, and then lastly we have the fieldName whose value we are trying to get.
A setter usually looks something like this −
set fieldName {
   // set the value
}
The set is the keyword that tells us and the compiler that this is a setter method. After the set keyword, we have the fieldName whose value we are trying to set in the following code block.
Now, let's create a class named Employee in which we will have different fields to apply our getter and setter methods to.
Consider the example shown below −
 Live Demo
class Employee {
   var empName = "mukul";
   var empAge = 24;
   var empSalary = 500;
   String get employeeName {
      return empName;
   }
   void set employeeName(String name) {
      this.empName = name;
   }
   void set employeeAge(int age) {
      if(age<= 18) {
         print("Employee Age should be greater than 18 Years.");
      } else {
         this.empAge = age;
      }
   }
   int get employeeAge {
      return empAge;
   }
   void set employeeSalary(int salary) {
      if(salary<= 0) {
         print("Salary cannot be less than 0");
      } else {
         this.empSalary = salary;
      }
   }
   int get employeeSalary {
      return empSalary;
   }
}
void main() {
   Employee emp = new Employee();
   emp.employeeName = 'Rahul';
   emp.employeeAge = 25;
   emp.employeeSalary = 2000;
   print("Employee's Name is : ${emp.employeeName}");
   print("Employee's Age is : ${emp.employeeAge}");
   print("Employee's Salary is : ${emp.employeeSalary}");
}
In the above example, we have an Employee class and when we are creating an object of the Employee class inside the main function, we are then making use of different getter and setter methods to access and write to the object's fields.
Employee's Name is : Rahul
Employee's Age is : 25
Employee's Salary is : 2000
Bitwise NOT in Arduino

Unlike logical NOT, which inverts the truth value of an expression, the bitwise NOT applies to each bit of a number and inverts its value (0 to 1 and 1 to 0). The operator is ~.
The syntax thus is ~a, where a is the number on which this operator has to apply.
Please note, that all the leading 0s in the number’s representation are also converted to 1. For example, if your board uses 16 bits to represent an integer, then here’s what ~10 will look like
As you can see, each bit of 10 got inverted. This number corresponds to, using 2’s complement, -11. You can use this site for quickly converting decimal number to their 2’s complements and vice versa https://www.exploringbinary.com/twos-complement-converter/.
You can read more about 2’s complement here &minnus; https://www.tutorialspoint.com/two-scomplement
Let’s verify this on the Serial Monitor. The code is given below −
void setup() {
   // put your setup code here, to run once:
   Serial.begin(9600);
   Serial.println();

   int a = 10;
   Serial.println(~a);
}

void loop() {
   // put your main code here, to run repeatedly:
}
The Serial Monitor output is −
As you can see, the output was exactly as expected.
GATE | GATE CS 2008 | Question 69 - GeeksforGeeks

24 Sep, 2021
Consider the following relational schemes for a library database:Book (Title, Author, Catalog_no, Publisher, Year, Price)Collection (Title, Author, Catalog_no)
with in the following functional dependencies:
I. Title Author --> Catalog_no
II. Catalog_no --> Title, Author, Publisher, Year
III. Publisher Title Year --> Price 
Assume {Author, Title} is the key for both schemes. Which of the following statements is true?(A) Both Book and Collection are in BCNF(B) Both Book and Collection are in 3NF only(C) Book is in 2NF and Collection is in 3NF(D) Both Book and Collection are in 2NF onlyAnswer: (C)Explanation:
Book (Title, Author, Catalog_no, Publisher, Year, Price)
Collection (Title, Author, Catalog_no) 
with in the following functional dependencies:
I. Title, Author --> Catalog_no
II. Catalog_no --> Title, Author, Publisher, Year
III. Publisher, Title, Year --> Price  

Assume {Author, Title} is the key for both schemes 
The table “Collection” is in BCNF as there is only one functional dependency “Title Author –> Catalog_no” and {Author, Title} is key for collection.
Book is not in BCNF because Catalog_no is not a key and there is a functional dependency “Catalog_no –> Title Author Publisher Year”.
Book is not in 3NF because non-prime attributes (Publisher Year) are transitively dependent on key [Title, Author].
Book is in 2NF because every non-prime attribute of the table is either dependent on the whole of a candidate key [Title, Author], or on another non prime attribute.In table book, candidate keys are {Title, Author} and {Catalog_no}. In table Book, non-prime attributes (attributes that do not occur in any candidate key) are Publisher, Year and Place
Please refer Database Normalization | Normal Forms for details of normal forms.Quiz of this Question
jainarpitkekri
GATE-CS-2008
GATE-GATE CS 2008
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-CS-2014-(Set-3) | Question 38
GATE | GATE-IT-2004 | Question 83
GATE | GATE CS 2018 | Question 37
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2016 (Set 1) | Question 65
GATE | GATE-CS-2016 (Set 1) | Question 63
GATE | GATE-IT-2004 | Question 12
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2007 | Question 64
GATE | GATE-CS-2014-(Set-3) | Question 65
How to show values in boxplot in R?

The main values in a boxplot are minimum, first quartile, median, third quartile, and the maximum, and this group of values is also called five-number summary. Therefore, if we want to show values in boxplot then we can use text function and provide the five-number summary and labels with fivenum function as shown in the below examples.
x<-sample(0:9,500,replace=TRUE)
boxplot(x,horizontal=TRUE) text(x=fivenum(x),labels=fivenum(x),y=1.25)
y<-rpois(5000,10)
boxplot(y,horizontal=TRUE)
text(x=fivenum(y),labels=fivenum(y),y=1.25)
Is Python Object Oriented or Procedural?

Yes, Python support both Object  Oriented and Procedural  Programming language as it is a high level programming language designed for general purpose programming. Python are multi-paradigm, you can write programs or libraries that are largely procedural, object-oriented, or functional in all of these languages. It depends on what you mean by functional. Python does have some features of a functional language. 
OOP's concepts like, Classes,Encapsulation,Polymorphism, Inheritance etc.. in Python makes it as a object oriented programming language. 
In Similar way we can created procedural program through python using loops ,for ,while etc ..and control structure.
class Rectangle:
   def __init__(self, length, breadth, unit_cost=0):
      self.length = length
      self.breadth = breadth
      self.unit_cost = unit_cost
   def get_perimeter(self):
       return 2 * (self.length + self.breadth)
   def get_area(self):
       return self.length * self.breadth
   def calculate_cost(self):
      area = self.get_area()
      return area * self.unit_cost
# breadth = 120 cm, length = 160 cm, 1 cm^2 = Rs 2000
r = Rectangle(160, 120, 2000)
print("Area of Rectangle: %s cm^2" % (r.get_area()))
print("Cost of rectangular field: Rs. %s " %(r.calculate_cost()))
Area of Rectangle: 19200 cm^2
Cost of rectangular field: Rs. 38400000
How to insert own values into auto_increment column in MySQL?

You can achieve this with the help of INSERT statement i.e, you can simply insert it like a normal insert. The syntax is as follows −
INSERT INTO yourTableName (yourIdColumnName,yourColumnName) values(value1,'value2');
Let us first create a table:
mysql> create table InsertValueInAutoIncrement
   -> (
   -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> UserName varchar(20)
   -> );
Query OK, 0 rows affected (0.59 sec)
Now you can insert some records in the table using insert command. Here, we are also inserting our own values for the auto_increment field UserId. The query is as follows −
mysql> insert into InsertValueInAutoIncrement(UserName) values('John');
Query OK, 1 row affected (0.19 sec)
mysql> insert into InsertValueInAutoIncrement(UserName) values('Carol');
Query OK, 1 row affected (0.17 sec)
mysql> insert into InsertValueInAutoIncrement(UserName) values('Sam');
Query OK, 1 row affected (0.11 sec)
mysql> insert into InsertValueInAutoIncrement(UserName) values('Bob');
Query OK, 1 row affected (0.18 sec)
mysql> insert into InsertValueInAutoIncrement(UserId,UserName) values(100,'Maxwell');
Query OK, 1 row affected (0.18 sec)
mysql> insert into InsertValueInAutoIncrement(UserName) values('James');
Query OK, 1 row affected (0.20 sec)
mysql> insert into InsertValueInAutoIncrement(UserId,UserName) values(1000,'Larry');
Query OK, 1 row affected (0.12 sec)
Display all records from the table using a select statement. The query is as follows −
mysql> select *from InsertValueInAutoIncrement;
The following is the table −
+--------+----------+
| UserId | UserName |
+--------+----------+
|      1 | John     |
|      2 | Carol    |
|      3 | Sam      |
|      4 | Bob      |
|    100 | Maxwell  |
|    101 | James    |
|   1000 | Larry    |
+--------+----------+
7 rows in set (0.00 sec)
Node.js Buffer.equals() Method - GeeksforGeeks

12 Oct, 2021
The Buffer.equals() method is used to compare two buffer objects and returns True of both buffer objects are the same otherwise returns False.
Syntax:
buffer.equals( buf )
Parameters: This method accepts single parameter otherBuffer which holds the another buffer to compare with buffer object.
Return Value: This method returns True if both buffer objects are equal otherwise returns false.
Below examples illustrate the Buffer.equals() method in Node.js:
Example 1:
// Node.js program to demonstrate the   // Buffer.equals() Method  // Create two bufferesvar buf1 = Buffer.from('Hi');var buf2 = Buffer.from('Hi');   // Prints true(boolean value)console.log(buf1.equals(buf2));
Output:
true
Example 2:
// Node.js program to demonstrate the   // Buffer.equals() Method  // Create two bufferesvar buf1 = Buffer.from('Hi');var buf2 = Buffer.from('Hello');  // Prints false(boolean value)console.log(buf1.equals(buf2));
Output:
false
Reference: https://nodejs.org/api/buffer.html#buffer_buf_equals_otherbuffer
Node.js-Buffer-module
Picked
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Express.js express.Router() Function
How to update Node.js and NPM to next version ?
Node.js fs.readFileSync() Method
How to update NPM ?
Difference between promise and async await in Node.js
Roadmap to Become a Web Developer in 2022
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
Distinct Subsequences in C++

Suppose we have strings S and T. We have to count number of distinct sequences of S which is equal to T.
We know that a subsequence of a string is a new string which is formed from the original string by removing some (can be none) of the characters without disturbing the relative positions of the remaining characters. (Like, "ACE" is a subsequence of "ABCDE" while "AEC" is not).
If the input strings are “baalllloonnn” and “balloon”, then there will be 36 different ways to select.
To solve this, we will follow these steps −
n := size of s, m := size of t. Update s and t by concatenating blank spaces before them
n := size of s, m := size of t. Update s and t by concatenating blank spaces before them
Make one matrix of size (n + 1) x (m + 1)
Make one matrix of size (n + 1) x (m + 1)
set dp[0, 0] := 1, then set 1 for 0th column of all row, put 1
set dp[0, 0] := 1, then set 1 for 0th column of all row, put 1
for i in range 1 to nfor j in range 1 to mif s[i] = t[j], thendp[i, j] := dp[i – 1, j – 1]dp[i, j] := dp[i, j] + dp[i – 1, j]
for i in range 1 to n
for j in range 1 to mif s[i] = t[j], thendp[i, j] := dp[i – 1, j – 1]dp[i, j] := dp[i, j] + dp[i – 1, j]
for j in range 1 to m
if s[i] = t[j], thendp[i, j] := dp[i – 1, j – 1]
if s[i] = t[j], then
dp[i, j] := dp[i – 1, j – 1]
dp[i, j] := dp[i – 1, j – 1]
dp[i, j] := dp[i, j] + dp[i – 1, j]
dp[i, j] := dp[i, j] + dp[i – 1, j]
return dp[n, m]
return dp[n, m]
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
class Solution {
   public:
   int numDistinct(string s, string t) {
      int n = s.size();
      int m = t.size();
      s = " " + s;
      t = " " + t;
      vector < vector <lli>> dp(n + 1, vector <lli> (m + 1));
      dp[0][0] = 1;
      for(int i = 1; i<= n; i++)dp[i][0] = 1;
      for(int i = 1; i <= n; i++){
         for(int j = 1; j <= m; j++){
            if(s[i] == t[j]) dp[i][j] = dp[i - 1][j - 1];
            dp[i][j]+= dp[i - 1][j];
         }
      }
      return dp[n][m];
   }
};
main(){
   Solution ob;
   cout << (ob.numDistinct("baalllloonnn", "balloon"));
}
"baalllloonnn"
"balloon"
36
Group by JavaScript Array Object

Suppose we have an array of arrays that contains the marks of some students in some subjects like this −
const arr = [ ["English", 52], ["Hindi", 154], ["Hindi", 241], ["Spanish", 10], ["French", 65], ["German", 98], ["Russian", 10] ];
We are required to write a JavaScript function that takes in one such array and returns an object of objects.
The return object should contain an object for each unique subject, and that object should contain information like the number of appearances of that language, sum of total marks and the average.
The code for this will be −
const arr = [
   ["English", 52],
   ["Hindi", 154],
   ["Hindi", 241],
   ["Spanish", 10],
   ["French", 65],
   ["German", 98],
   ["Russian", 10]
];
const groupSubjects = arr => {
   const grouped = arr.reduce((acc, val) => {
      const [key, total] = val;
      if(!acc.hasOwnProperty(key)){
         acc[key] = {
            'count': 0,
            'total': 0
         };
      };
      const accuKey = acc[key];
      accuKey['count']++;
      accuKey['total'] += total;
      accuKey['average'] = total / accuKey['count'];
      return acc;
   }, {});
   return grouped;
};
console.log(groupSubjects(arr));
And the output in the console will be −
{
English: { count: 1, total: 52, average: 52 },
Hindi: { count: 2, total: 395, average: 120.5 },
Spanish: { count: 1, total: 10, average: 10 },
French: { count: 1, total: 65, average: 65 },
German: { count: 1, total: 98, average: 98 },
Russian: { count: 1, total: 10, average: 10 }
}
Count two different columns in a single query in MySQL?

You can use CASE statement to count two different columns in a single query. To understand the concept, let us first create a table. The query to create a table is as follows.
mysql> create table CountDifferentDemo
   - > (
   - > ProductId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   - > ProductName varchar(20),
   - > ProductColor varchar(20),
   - > ProductDescription varchar(20)
   - > );
Query OK, 0 rows affected (1.06 sec)
Insert some records in the table using insert command.
The query is as follows
mysql> insert into CountDifferentDemo(ProductName,ProductColor,ProductDescription) values('Product-1','Red','Used');
Query OK, 1 row affected (0.46 sec)
mysql> insert into CountDifferentDemo(ProductName,ProductColor,ProductDescription) values('Product-1','Blue','Used');
Query OK, 1 row affected (0.17 sec)
mysql> insert into CountDifferentDemo(ProductName,ProductColor,ProductDescription) values('Product-2','Green','New');
Query OK, 1 row affected (0.12 sec)
mysql> insert into CountDifferentDemo(ProductName,ProductColor,ProductDescription) values('Product-2','Blue','New');
Query OK, 1 row affected (0.14 sec)
mysql> insert into CountDifferentDemo(ProductName,ProductColor,ProductDescription) values('Product-3','Green','New');
Query OK, 1 row affected (0.21 sec)
mysql> insert into CountDifferentDemo(ProductName,ProductColor,ProductDescription) values('Product-4','Blue','Used');
Query OK, 1 row affected (0.20 sec)
Display all records from the table using select statement.
The query is as follows
mysql> select *from CountDifferentDemo;
The following is the output
+-----------+-------------+--------------+--------------------+
| ProductId | ProductName | ProductColor | ProductDescription |
+-----------+-------------+--------------+--------------------+
|         1 | Product-1   | Red          | Used               |
|         2 | Product-1   | Blue         | Used               |
|         3 | Product-2   | Green        | New                |
|         4 | Product-2   | Blue         | New                |
|         5 | Product-3   | Green        | New                |
|         6 | Product-4   | Blue         | Used               |
+-----------+-------------+--------------+--------------------+
6 rows in set (0.01 sec)
Here is the query to count two different columns in a single query i.e. we are counting the occurrence of a particular color “Red” and description “New”
mysql> select ProductName,
   - > SUM(CASE WHEN ProductColor = 'Red' THEN 1 ELSE 0 END) AS Color,
   - > SUM(CASE WHEN ProductDescription = 'New' THEN 1 ELSE 0 END) AS Desciption
   - > from CountDifferentDemo
   - > group by ProductName;
The following is the output
+-------------+-------+------------+
| ProductName | Color | Desciption |
+-------------+-------+------------+
| Product-1   |     1 |          0 |
| Product-2   |     0 |          2 |
| Product-3   |     0 |          1 |
| Product-4   |     0 |          0 |
+-------------+-------+------------+
4 rows in set (0.12 sec)
How to set the background color of a column in a matplotlib table?

To set the background color of a column in a matplotlib table, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Set the figure size and adjust the padding between and around the subplots.
Make a tuple for columns attribute.
Make a tuple for columns attribute.
Make a list of lists, i.e., list of records.
Make a list of lists, i.e., list of records.
Make a list of lists, i.e., color of each cell.
Make a list of lists, i.e., color of each cell.
Create a figure and a set of subplots.
Create a figure and a set of subplots.
Add a table to an axes, ax.
Add a table to an axes, ax.
Turn off the axes.
Turn off the axes.
To display the figure, use show() method.
To display the figure, use show() method.
import matplotlib.pyplot as plt

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

columns = ('name', 'age', 'marks', 'salary')

cell_text = [["John", "23", "98", "234"], ["James", "24", "90", "239"]]

colors = [["red", "yellow", "blue", "green"], ["blue", "green", "yellow", "red"]]

fig, ax = plt.subplots()

the_table = ax.table(cellText=cell_text, cellColours=colors, colLabels=columns, loc='center')

ax.axis('off')

plt.show()
PostgreSQL – LEFT JOIN

28 Aug, 2020
The PostgreSQL LEFT JOIN returns all the rows of the table on the left side of the join and matching rows for the table on the right side of the join. The rows for which there is no matching row on the right side, the result-set will contain null. LEFT JOIN is also known as LEFT OUTER JOIN.
Syntax:
SELECT table1.column1, table1.column2, table2.column1, ....
FROM table1 
LEFT JOIN table2
ON table1.matching_column = table2.matching_column;


table1: First table.
table2: Second table
matching_column: Column common to both the tables.
Let’s analyze the above syntax:
Firstly, using the SELECT statement we specify the tables from where we want the data to be selected.
Second, we specify the main table.
Third, we specify the table that the main table joins to.
The below Venn Diagram illustrates the working of PostgreSQL LEFT JOIN clause:
For the sake of this article we will be using the sample DVD rental database, which is explained here and can be downloaded by clicking on this link in our examples.
Now, let’s look into a few examples.
Example 1:Here we will use the LEFT JOIN clause to join the “film” table to the “inventory” table.
SELECT
    film.film_id,
    film.title,
    inventory_id
FROM
    film
LEFT JOIN inventory ON inventory.film_id = film.film_id;
Output:
Example 2:Here we will use the LEFT JOIN clause to join the “film” table to the “inventory” table and use the WHERE clause to filter out films that are not in the inventory supply.
SELECT
    film.film_id,
    film.title,
    inventory_id
FROM
    film
LEFT JOIN inventory ON inventory.film_id = film.film_id
WHERE
    inventory.film_id IS NULL;
Output:
postgreSQL-joins
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Moment.js isBefore() Function

24 Jul, 2020
It is used to check whether a date is before a particular date in Node.js using the isBefore() function that checks if a moment is before another moment. The first argument will be parsed as a moment, if not already so.
Syntax:
moment().isBefore(Moment|String|Number|Date|Array);
moment().isBefore(Moment|String|Number|Date|Array, String);

Parameter: It can holds either Moment|String|Number|Date|Array.
Returns: True or False
Installation of moment module:
You can visit the link to Install moment module. You can install this package by using this command.npm install momentAfter installing the moment module, you can check your moment version in command prompt using the command.npm version momentAfter that, you can just create a folder and add a file for example, index.js. To run this file you need to run the following command.node index.js
You can visit the link to Install moment module. You can install this package by using this command.npm install moment
npm install moment
After installing the moment module, you can check your moment version in command prompt using the command.npm version moment
npm version moment
After that, you can just create a folder and add a file for example, index.js. To run this file you need to run the following command.node index.js
node index.js
Example 1: Filename: index.js
// Requiring moduleconst moment = require('moment');  var bool1 = moment('2010-10-20')    .isBefore('2010-10-21'); // trueconsole.log(bool1);  var bool2 = moment('2010-10-20')    .isBefore('2010-12-31', 'year'); // falseconsole.log(bool2);
Steps to run the program:
The project structure will look like this:Make sure you have installed moment module using the following command:npm install momentRun index.js file using below command:node index.jsOutput:true
false

The project structure will look like this:
Make sure you have installed moment module using the following command:npm install moment
npm install moment
Run index.js file using below command:node index.jsOutput:true
false

node index.js
Output:
true
false

Example 2: Filename: index.js
// Requiring moduleconst moment = require('moment');  function checkIsBefore(date1, date2) {    return moment(date1).isBefore(date2); }  var bool = checkIsBefore('2010-10-20', '2010-10-21');console.log(bool);
Run index.js file using below command:
node index.js
Output:
true

Reference: https://momentjs.com/docs/#/query/is-before/
Moment.js
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Node.js fs.writeFile() Method
How to install the previous version of node.js and npm ?
Difference between promise and async await in Node.js
Mongoose | findByIdAndUpdate() Function
JWT Authentication with Node.js
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React