code-rag-bench/online-tutorials huggingface dataset:
Merge and remove duplicates in JavaScript Array

Suppose, we have two arrays of literals like these −
const arr1 = [2, 4, 5, 3, 7, 8, 9];
const arr2 = [1, 4, 5, 2, 3, 7, 6];
We are required to write a JavaScript function that takes in two such arrays and returns a new
array with all the duplicates removed (should appear only once).
The code for this will be −
const arr1 = [2, 4, 5, 3, 7, 8, 9];
const arr2 = [1, 4, 5, 2, 3, 7, 6];
const mergeArrays = (first, second) => {
   const { length: l1 } = first;
   const { length: l2 } = second;
   const res = [];
   let temp = 0;
   for(let i = 0; i < l1+l2; i++){
      if(i >= l1){
         temp = i - l1;
         if(!res.includes(first[temp])){
            res.push(first[temp]);
         };
      }else{
         temp = i;
         if(!res.includes(second[temp])){
            res.push(second[temp]);
         };
      };
   };
   return res;
};
console.log(mergeArrays(arr1, arr2));
The output in the console −
[
   1, 4, 5, 2, 3,
   7, 6, 8, 9
]
Tryit Editor v3.7

Tryit: Border color with RGB values
Program to find sum of beauty of all substrings in Python

Suppose we have a string s. We have to find the sum of beauty of all of its substrings. The beauty of a string is actually the difference in frequencies between the most frequent and least frequent characters. So if the string is "abaacc", then its frequency is 3 - 1 = 2.
So, if the input is like s = "xxyzy", then the output will be 5 because the substrings with non-zero beauty are ["xxy","xxyz","xxyzy","xyzy","yzy"], each has beauty value 1.
To solve this, we will follow these steps −
res:= 0
res:= 0
for i in range 0 to size of s - 1, dofor j in range i+2 to size of s - 1, doc:= a map containing characters frequency of substring of s from index i to jv:= list of all frequency values of cres := res +(maximum of v - minimum of v)
for i in range 0 to size of s - 1, do
for j in range i+2 to size of s - 1, doc:= a map containing characters frequency of substring of s from index i to jv:= list of all frequency values of cres := res +(maximum of v - minimum of v)
for j in range i+2 to size of s - 1, do
c:= a map containing characters frequency of substring of s from index i to j
c:= a map containing characters frequency of substring of s from index i to j
v:= list of all frequency values of c
v:= list of all frequency values of c
res := res +(maximum of v - minimum of v)
res := res +(maximum of v - minimum of v)
return res
return res
Let us see the following implementation to get better understanding −
from collections import Counter

def solve(s):
   res=0
   for i in range(len(s)):
      for j in range(i+2,len(s)):
         c=Counter(s[i:j+1])
         v=c.values()
         res+=(max(v)-min(v))
   return res

s = "xxyzy"
print(solve(s))
"xxyzy"

5
How to underline a Hyperlink on Hover using jQuery?

To underline a hyperlink on hover using jQuery, use the jQuery css() property. The color text-decoration  property is used.
You can try to run the following code to learn how to underline a hyperlink on hover:
Live Demo
<html>

   <head>
      <title>jQuery Hyperlink Decoration</title>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
       
      <script>
         $(document).ready(function() {

            $('a').hover(
               
               function () {
                  $(this).css({"text-decoration":"underline"});
               });
               
         });
      </script>
      <style>
      a {
           text-decoration: none;
         }
     </style>
   </head>
   
   <body>
      <a href="#">Demo text</a>
       
   </body>
   
</html>
C Program for subtraction of matrices

Given two matrices MAT1[row][column] and MAT2[row][column] we have to find the difference between two matrices and print the result obtained after subtraction of two matrices. Subtraction of two matrices are MAT1[n][m] – MAT2[n][m].
For subtraction the number of rows and columns of both matrices should be same.
Input:
MAT1[N][N] = { {1, 2, 3},
   {4, 5, 6},
   {7, 8, 9}}
MAT2[N][N] = { {9, 8, 7},
   {6, 5, 4},
   {3, 2, 1}}
Output:
-8 -6 -4
-2 0 2
4 6 8
Approach used below is as follows −
We will iterate both matrix for every row and column and subtract the values of mat2[][] from mat1[][] and store the result in a result[][] where row and column remain same for all the matrices.
In fucntion void subtract(int MAT1[][N], int MAT2[][N], int RESULT[][N])
   Step 1-> Declare 2 integers i, j
   Step 2-> Loop For i = 0 and i < N and i++
      Loop For j = 0 and j < N and j++
      Set RESULT[i][j] as MAT1[i][j] - MAT2[i][j]
In function int main()
   Step 1-> Declare a matrix MAT1[N][N] and MAT2[N][N]
   Step 2-> Call function subtract(MAT1, MAT2, RESULT);
   Step 3-> Print the result
 Live Demo
#include <stdio.h>
#define N 3
// This function subtracts MAT2[][] from MAT1[][], and stores
// the result in RESULT[][]
void subtract(int MAT1[][N], int MAT2[][N], int RESULT[][N]) {
   int i, j;
   for (i = 0; i < N; i++)
   for (j = 0; j < N; j++)
   RESULT[i][j] = MAT1[i][j] - MAT2[i][j];
}
int main() {
   int MAT1[N][N] = { {1, 2, 3},
      {4, 5, 6},
      {7, 8, 9}
      };
   int MAT2[N][N] = { {9, 8, 7},
      {6, 5, 4},
      {3, 2, 1}
   };
   int RESULT[N][N]; // To store result
   int i, j;
   subtract(MAT1, MAT2, RESULT);
   printf("Resultant matrix is \n");
   for (i = 0; i < N; i++) {
      for (j = 0; j < N; j++)
      printf("%d ", RESULT[i][j]);
      printf("\n");
   }
   return 0;
}
If run the above code it will generate the following output −
Resultant matrix is
-8 -6 -4
-2  0  2
 4  6  8
AWS DynamoDB - Update Data in a Table - GeeksforGeeks

31 Mar, 2021
Amazon DynamoDB is a NoSQL managed database that supports semi-structured data i.e. key-value and document data. A DynamoDB table stores data in the form of an item. While creating a table in DynamoDB, a partition key needs to be defined which acts as the primary key for the table and no schema. Each item consists of attributes. By default, every item will have a partition key as one of the attributes. Every item can have a different number of attributes. An example of an item is given below:
Example:
{
  "Color": true,
  "Director": "Christopher Nolan",
  "MovieID": 1,
  "Name": "Inception",
  "Rating": 8.7,
  "Year": 2010
}
We will be doing the following operations in this article:
Create a table in DynamoDB, say, Movies.Add items or data into the table.Update attribute of an item in the table.
Create a table in DynamoDB, say, Movies.
Add items or data into the table.
Update attribute of an item in the table.
The above approach has been implemented below:
Create a table named Movies with partition key as MoviesID. Add items to the table. A table has been already created for your reference. See the image below:
 There are two ways to update the attributes of an item. They are :
AWS CLI – In this, update-item is used to update the value of an attribute using Amazon Command Line Interface (CLI).
Amazon Management Console – To update the value of an attribute in items, navigate to the Items tab of a table and click on the MovieID to update the item. An edit item page will open to either add, update or delete a key-value pair. In the original table, the director column of MovieID=050 is empty. We are going to add ‘Christopher Nolan’ under the director attribute. See the below images:
Edit MovieID 050
Updated Table 
We observe that the director column of MovieID=050 has been updated with the value ‘Christopher Nolan’. Similarly, we can select any partition key and edit the value of the attribute of an item.
Cloud-Computing
DynamoDB
DynamoDB-Basics
Picked
Amazon Web Services
DynamoDB
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install Python3 on AWS EC2?
How to Connect to Amazon Linux Instance from Windows Client Operating System using PUTTY?
Amazon S3 - Cross Region Replication
Amazon EC2 - Creating an Elastic Cloud Compute Instance
AWS DynamoDB - PartiQL Insert Statement
How to Mock AWS DynamoDB Services for Unit Testing?
DynamoDB - Local Installation
DynamoDB - Data Types
AWS DynamoDB - Introduction to DynamoDB Accelerator (DAX)
AWS DynamoDB - Create a Global Secondary Index
HTML maxlength Attribute - GeeksforGeeks

08 Dec, 2021
It specifies the maximum number of characters that have been allowed in the Element. It can be used on the following Elements: 
<input><textarea>
<input>
<textarea>
Attribute Values: It contains a single value number that allows the maximum number of characters in the <input> element. Its default value is 524288.
Examples:  
Example for <input> element:
HTML
<!DOCTYPE html><html> <body>    <center>        <h1 style="color:green;font-style:italic;">          GeeksForGeeks        </h1>        <h2 style="color:green;font-style:italic;">          maxlength attribute        </h2>        <form action="">            Username:            <input type="text" name="usrname" maxlength="12">            <br>            <br>            Password:            <input type="text" name="password" maxlength="10">            <br>            <br>            <input type="submit" value="Submit">        </form>    </center></body> </html>
Output: 
Example for <textarea> element:
HTML
<!DOCTYPE html><html> <body>    <center>        <h1 style="color:green;font-style:italic;">          GeeksforGeeks        </h1>        <h2 style="color:green;font-style:italic;">          maxlength attribute        </h2>        <textarea rows="4" cols="50" maxlength="6">          write here something that you want....        </textarea>  </center></body> </html>
Output: 
Supported Browsers: The browsers supported by maxlength attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Opera
Safari
 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
akshaysingh98088
hritikbhatnagar2182
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to set the default value for an HTML <select> element ?
How to update Node.js and NPM to next version ?
Hide or show elements in HTML using display property
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 ?
How to insert spaces/tabs in text using HTML/CSS?
Angular CLI - ng generate Command

This chapter explains the syntax, argument and options of ng generate command along with an example.
The syntax for ng generate command is as follows −
ng generate <schematic> [options]
ng g <schematic> [options]

ng generate command generates and/or modifies files based on a schematic.
The argument for ng help command is as follows −
appShell
appShell
application
application
class
class
component
component
directive
directive
enum
enum
guard
guard
interceptor
interceptor
interface
interface
library
library
module
module
pipe
pipe
service
service
serviceWorker
serviceWorker
webWorker
webWorker
Options are optional parameters.
When true,runs through and reports activity without writing out results.
Default:false.
Aliases: -d.
When true,forces overwriting of existing files.
Default:false.
Aliases: -f.
Shows a helpmessage for this command in the console.
Default: false.
First move to an angular project created using ng new command and then run the
command. This chapter is available athttps://www.tutorialspoint.com/angular_cli/angular_cli_ng_new.htm.
An example for ng generate command is given below −
\>Node\>TutorialsPoint> ng generate component goals
CREATE src/app/goals/goals.component.html (20 bytes)
CREATE src/app/goals/goals.component.spec.ts (621 bytes)
CREATE src/app/goals/goals.component.ts (271 bytes)
CREATE src/app/goals/goals.component.css (0 bytes)
UPDATE src/app/app.module.ts (471 bytes)

Here, ng generate command has created a new component in our project TutorialsPoint and added this new component entry in app.module.ts.

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    28 Lectures 
     2.5 hours 

 Anadi Sharma

    11 Lectures 
     7.5 hours 

 SHIVPRASAD KOIRALA

    16 Lectures 
     2.5 hours 

 Frahaan Hussain

    69 Lectures 
     5 hours 

 Senol Atac

    53 Lectures 
     3.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
Grouped Barplots in Python with Seaborn - GeeksforGeeks

02 Dec, 2020
Prerequisites: Seaborn
In this article, we will discuss ways to make grouped barplots using Seaborn in Python. Before that, there are some concepts one must be familiar with:
Barcharts: Barcharts are great when you have two variables one is numerical and therefore the other may be a categorical variable. A barplot can reveal the relationship between them.
Grouped Barplot: A Grouped barplot is beneficial when you have a multiple categorical variable. Python’s Seaborn plotting library makes it easy to form grouped barplots.
Groupby: Pandas dataframe.groupby() function is used to split the data into groups based on some criteria. Pandas objects can be split on any of their axes. The abstract definition of grouping is to provide a mapping of labels to group names.
Import Libraries.
Load or create data.
Perform groupby with an aggregate function.
Plot the barplot with grouped attributes.
Following are implementation to explain the same: 
Example 1:
Python3
# importing packagesimport seaborn as sb  # load datasetdf = sb.load_dataset('tips')  # perform groupbydf = df.groupby(['size', 'sex']).agg(mean_total_bill=("total_bill", 'mean'))df = df.reset_index()  # plot barplotsb.barplot(x="size",           y="mean_total_bill",           hue="sex",           data=df)
Output:
Example 2:
Python3
# importing packagesimport seaborn as sb  # load datasetdf = sb.load_dataset('tips')  # perform groupbydf = df.groupby(['size', 'day']).agg(mean_total_bill=("total_bill", 'mean'))df = df.reset_index()  # plot barplotsb.barplot(x="size",           y="mean_total_bill",           hue="day",           data=df)
Output:
Example 3:
Python3
# importing packagesimport seaborn as sb  # load datasetdf = sb.load_dataset('anagrams')  # perform groupbydf = df.groupby(['num1', 'attnr']).agg(mean_num3=("num3", 'mean'))df = df.reset_index()  # plot barplotsb.barplot(x="num1",           y="mean_num3",           hue="attnr",           data=df)
Output:
Python-Seaborn
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
Defaultdict in Python
Python | Get unique values from a list
Python | Pandas dataframe.groupby()
What is ternary operator (? X : Y)  in C++?

The conditional operator (? :) is a ternary operator (it takes three operands). The conditional operator works as follows −
The first operand is implicitly converted to bool. It is evaluated and all side effects are completed before continuing.
If the first operand evaluates to true (1), the second operand is evaluated.
If the first operand evaluates to false (0), the third operand is evaluated.
The result of the conditional operator is the result of whichever operand is evaluated — the second or the third. Only one of the last two operands is evaluated in a conditional expression. The evaluation of the conditional operator is very complex. The steps above were just a quick intro to it. Conditional expressions have right-to-left associativity. The first operand must be of integral or pointer type. 
The following rules apply to the second and third operands −If both operands are of the same type, the result is of that type.If both operands are of arithmetic or enumeration types, the usual arithmetic 
If both operands are of the same type, the result is of that type.
If both operands are of arithmetic or enumeration types, the usual arithmetic 
conversions (covered in Standard Conversions) are performed to convert them to a common type.
If both operands are of pointer types or if one is a pointer type and the other is a constant expression that evaluates to 0, pointer conversions are performed to convert them to a common type.
If both operands are of reference types, reference conversions are performed to convert them to a common type.
If both operands are of type void, the common type is type void.
If both operands are of the same user-defined type, the common type is that type.
If the operands have different types and at least one of the operands has user-defined type then the language rules are used to determine the common type. (See warning below.)
#include <iostream>  
using namespace std;  
int main() {  
   int i = 1, j = 2;  
   cout << ( i > j ? i : j ) << " is greater." << endl;  
}
This will give the output −
2 is greater.
Comparing dates in Python - GeeksforGeeks

24 May, 2018
Comparing dates is quite easy in Python. Dates can be easily compared using comparison operators (like <, >, <=, >=, != etc.). Let’s see how to compare dates with the help of datetime module using Python.
Code #1 : Basic
# Simple Python program to compare dates  # importing datetime moduleimport datetime  # date in yyyy/mm/dd formatd1 = datetime.datetime(2018, 5, 3)d2 = datetime.datetime(2018, 6, 1)  # Comparing the dates will return# either True or Falseprint("d1 is greater than d2 : ", d1 > d2)print("d1 is less than d2 : ", d1 < d2)print("d1 is not equal to d2 : ", d1 != d2)
Output :
d1 is greater than d2 :  False
d1 is less than d2 :  True
d1 is not equal to d2 :  True
 Code #2 : Sorting dates
One of the best ways to sort a group of dates is to store them into a list and apply sort() method. This will sort all the dates which are available in the list. One can store the date class objects into the list using append() method.
# Python program to sort the dates  # importing datetime modulefrom datetime import *  # create empty listgroup = []  # add today's dategroup.append(date.today())  # create some more datesd = date(2015, 6, 29)group.append(d)  d = date(2011, 4, 7)group.append(d)  # add 25 days to the date# and add to the listgroup.append(d + timedelta(days = 25))  # sort the listgroup.sort()  # print the datesfor d in group:    print(d)     
Output :
2011-04-07
2011-05-02
2015-06-29
2018-05-24
 Code #3 : Comparing Dates
Compare two date class objects, just like comparing two numbers.
# importing datetime modulefrom datetime import *  # Enter birth dates and store# into date class objectsd1, m1, y1 = [int(x) for x in input("Enter first"        " person's date(DD/MM/YYYY) : ").split('/')]  b1 = date(y1, m1, d1)  # Input for second dated2, m2, y2 = [int(x) for x in input("Enter second"        " person's date(DD/MM/YYYY) : ").split('/')]  b2 = date(y2, m2, d2)  # Check the datesif b1 == b2:    print("Both persons are of equal age")      elif b1 > b2:    print("The second person is older")      else:    print("The first person is older")
Output :
Enter first person's date(DD/MM/YYYY) : 12/05/2017
Enter second person's date(DD/MM/YYYY) : 10/11/2015
The second person is older
date-time-program
python-modules
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Convert integer to string in Python
sum() function in Python
isupper(), islower(), lower(), upper() in Python and their applications
Statistics - Continuous Uniform Distribution

The continuous uniform distribution is the probability distribution of random number selection from the continuous interval between a and b. Its density function is defined by the following. Here is a graph of the continuous uniform distribution with a = 1, b = 3.
Problem Statement:
Suppose you are leading a test and present an inquiry on the crowd of 20 contenders. The time permitted to answer the inquiry is 30 seconds. What number of persons is prone to react inside of 5 seconds? (Regularly, the contenders are required to click a catch of the right decision and the champ is picked on the premise of first snap).
Solution:
Step 1: The interval of the probability distribution in seconds is [0, 30].
⇒ The probability density is = 1/30-0=1/30. 

Step 2: The requirement is how many will respond in 5 seconds. That is, the sub interval of the successful event is [0, 5]. Now the probability P (x < 5) is the proportion of the widths of these two interval.
⇒ 5/30=1/6. 

Subsequent to there are 20 contenders, the quantity of contenders prone to react in 5 seconds is (1/6) (20) =3.

    40 Lectures 
     3.5 hours 

 Madhu Bhatia

    40 Lectures 
     2 hours 

 Megha Aggarwal

    66 Lectures 
     1.5 hours 

 Mike West

    22 Lectures 
     1 hours 

 Mike West

    60 Lectures 
     12 hours 

 Michael Miller

    65 Lectures 
     5 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
How to make “spoiler” text in github wiki pages? - GeeksforGeeks

29 May, 2020
GitHub Wiki pages support GitHub Flavored Markdown. Read more about GitHub flavored markdown here: 
Mastering Markdown
GitHub Flavored Markdown Spec
However, there is no direct method to add a spoiler text in GitHub Flavored Markdown. But, there’s a workaround!
Approach: Markdown Supports HTML Blocks in it. So, we can use HTML’s <details> and <summary> tag to create a spoiler text. The heading of the Spoiler Alert can be specified within the <summary> tag. The rest of the spoiler must be within the <details> tag. Only clicking on the “Spoiler Ahead” heading will reveal the spoiler. The text within the summary tag is the Spoiler Heading. Code, Images, Links, etc can be used following the GitHub flavored markdown, within the details tag.
Example:
html
<!DOCTYPE html><head><head>    <title>         “spoiler” text in github wiki pages    </title></head><body>    <details>        <summary>GeeksforGeeks</summary>         A Computer Science Portal for Geeks    </details>        </body></html>
Output: The <details> tag along with the <summary> tag creates the following output in markdown.
Note: The Above Outputs has been directly generated from GitHub Wiki Pages markdown preview.
Picked
Web Technologies
Web technologies Questions
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
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
How to execute PHP code using command line ?
How to Insert Form Data into Database using PHP ?
Types of CSS (Cascading Style Sheet)
How to apply style to parent if it has child with CSS?
How to perform group-wise linear regression for a data frame in R?

The group−wise linear regression means creating regression model for group levels. For example, if we have a dependent variable y and the independent variable x also a grouping variable G that divides the combination of x and y into multiple groups then we can create a linear regression model for each of the group. In R, we can convert data frame to data.table object, this will help us to create the regression models easily.
 Live Demo
Consider the below data frame −
G1<−sample(LETTERS[1:4],20,replace=TRUE)
x1<−rnorm(20,2,0.96)
y1<−rnorm(20,5,1)
df1<−data.frame(G1,x1,y1)
df1
   G1    x1    y1
1 C 1.2692290 3.994126
2 C 1.6317682 4.474443
3 D 1.3686734 5.444823
4 D 2.4969567 5.818360
5 C 2.3882221 3.766412
6 A 2.7568873 5.506297
7 A 2.1352764 4.548771
8 B 2.5232049 5.378314
9 A 2.8695959 4.735447
10 C −0.2317400 5.280478
11 A 1.1473469 5.064822
12 A 2.9099241 4.090654
13 A 2.4095434 6.538454
14 C 2.5310162 7.137598
15 A 2.4097431 4.778472
16 C 0.4945313 5.511772
17 C 1.3427334 5.030479
18 A 1.5200120 6.758618
19 A 2.4414779 5.854175
20 B −0.6968409 4.594522
Loading data.table package and converting data frame df1 to a data.table object −
library(data.table)
df1<−data.table(df1)
Creating linear regression model groups defined in column G1 −
df1[,as.list(coef(lm(y1 ~ x1))), by=G1]
   G1 (Intercept) x1
1: C 4.959098 0.05109642
2: D 4.991700 0.33106700
3: A 6.536957 -0.53189331
4: B 4.764140 0.24341026
Let’s have a look at another example −
Class<−sample(c("I","II","III"),20,replace=TRUE)
Ratings<−sample(1:10,20,replace=TRUE)
Salary<−sample(20000:50000,20)
df2<−data.frame(Class,Ratings,Salary)
df2
Class Ratings Salary
1 I 4 28423
2 III 1 34728
3 II 1 26975
4 I 9 26777
5 II 6 29501
6 I 8 33061
7 II 4 43584
8 I 4 42525
9 II 9 30526
10 I 1 32872
11 I 7 21198
12 I 3 20971
13 III 9 49071
14 I 1 40314
15 III 1 36269
16 I 6 45482
17 II 1 48595
18 I 8 44054
19 I 1 25294
20 III 10 34944
df2<−data.table(df2)
Creating regression models of Salary and Ratings for the three Classes −
df2[,as.list(coef(lm(Salary~Ratings))),by=Class]
Class (Intercept) Ratings
1: I 31894.13 194.9152
2: III 35270.10 663.4089
3: II 40405.42 -1087.9103
Apply a Function over a Ragged Array in R Programming - tapply() Function - GeeksforGeeks

19 Jun, 2020
tapply() function in R Language is used to apply a function over a subset of vectors given by a combination of factors
Syntax: tapply(vector, factor, fun)
Parameters:vector: Created Vectorfactor: Created Factorfun: Function to be applied
Example 1:
# R Program to apply a function# over a data object  # Creating Factorfac <- c(1, 1, 1, 1, 2, 2, 2, 3, 3)  # Created Vectorvec <- c(1, 2, 3, 4, 5, 6, 7, 8, 9)   # Calling tapply() Functiontapply(vec, fac, sum)
Output:
 1  2  3 
10 18 17 

This is how above code works: Example 2:
# R Program to apply a function# over a data object  # Creating Factorfac <- c(1, 1, 1, 1, 2, 2, 2, 3, 3)  # Created Vectorvec <- c(1, 2, 3, 4, 5, 6, 7, 8, 9)   # Calling tapply() Functiontapply(vec, fac, prod)
Output:
 1   2   3 
24 210  72 

R Array-Functions
R Factor-Function
R Vector-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
R - if statement
How to filter R dataframe by multiple conditions?
Plot mean and standard deviation using ggplot2 in R
How to import an Excel File into R ?
Fabric.js Textbox editable Property - GeeksforGeeks

20 Jan, 2021
In this article, we are going to see how to set the edit mode of a Textbox canvas using Fabric.js. The Textbox in Fabric.js is movable and can be stretched according to requirements. Further, the Textbox can be customized when it comes to initial stroke color, height, width, fill color, or stroke width.
To make it possible we are going to use a JavaScript library called Fabric.js. After importing the library using CDN, we will create a canvas block in the body tag which will contain the Textbox. After this, we will initialize instances of Canvas and Textbox provided by Fabric.js, set the edit mode by using the editable property, and render the Textbox on the Canvas as given in the example below.
Syntax:
fabric.Textbox('text', {
    editable: boolean
});
Parameters: This property accepts a single parameter as mentioned above and described below:
editable: It specifies the edit mode of the Textbox. A value of true makes the Textbox editable and a value of false disables editing.
Example: This example uses Fabric.js to set the edit mode of the Textbox.
HTML
<html><head>    <script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/4.3.0/fabric.min.js">    </script></head><body>    <h1 style="color: green;">        GeeksforGeeks    </h1>    <h3>        Fabric.js | Textbox editable Property    </h3>    <canvas id="canvas" width="600" height="300"            style="border:1px solid #000000">    </canvas>    <script>        // Initiate a Canvas instance         var canvas = new fabric.Canvas("canvas");          // Create new Textbox instances         var textEditable = new fabric.Textbox(            'Editable Textbox', {            width: 500,            editable: true        });          var textNonEditable = new fabric.Textbox(            'Non Editable Textbox', {            width: 500,            editable: false        });          // Render the Textbox in canvas         canvas.add(textEditable);        canvas.add(textNonEditable);          canvas.centerObject(textNonEditable);        canvas.centerObjectH(textEditable);    </script></body></html>
Output:
Fabric.js
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?
C program to convert roman numbers to decimal numbers

Given below is an algorithm to convert roman numbers to decimal numbers in C language −
Step 1 − Start
Step 2 − Read the roman numeral at runtime
Step 3 − length: = strlen(roman)
Step 4 − for i = 0 to length-1 do
      Step 4.1 − switch(roman[i])
          Step 4.1.1 − case ‘m’:
          Step 4.1.2 − case ‘M’:
               Step 4.1.2.1 − d[i]: =1000
          Step 4.1.3 − case ‘d’:
               Step 4.1.4 − case ‘D’:
          Step 4.1.4.1 − d[i]: =500
          Step 4.1.5 − case ‘c’:
               Step 4.1.6 − case ‘C’:
                   Step 4.1.6.1 − d[i]: =100
          Step 4.1.7 − case ‘l’:
          Step 4.1.8 − case ‘L’:
                   Step 4.1.8.1 − d[i]: =50
          Step 4.1.9 − case ‘x’:
          Step 4.1.10 − case ‘X’:
                   Step 4.1.10.1 − d[i]: =10
           Step 4.1.11 − case ‘v’:
          Step 4.1.12 − case ‘V’:
                Step 4.1.12.1 − d[i]: =5
          Step 4.1.13 − case ‘i’:
          Step 4.1.14 − case ‘I’:
                Step 4.1.14.1 − d[i]: =1
          Step 5 − for i =0 to length-1 do
                Step 5.1 − if (i==length-1) or (d[i]>=d[i+1]) then
                      Step 5.1.1 − deci += d[i]
          Step 5.2 − else
              Step 5.2.1 − deci -= d[i]
Step 6 − Print the decimal equivalent of roman numeral
Step 7 − Stop
Following is the C program to convert roman numbers to decimal numbers −
#include <stdio.h>
#include <conio.h>
main(){
   char roman[30];
   int deci=0;
   int length,i,d[30];
   printf("The Roman equivalent to decimal\n");
   printf("Decimal:.........Roman\n");
   printf("%5d............%3c\n",1,'I');
   printf("%5d............%3c\n",5,'V');
   printf("%5d............%3c\n",10,'X');
   printf("%5d............%3c\n",50,'L');
   printf("%5d............%3c\n",100,'C');
   printf("%5d............%3c\n",500,'D');
   printf("%5d............%3c\n",1000,'M');
   printf("Enter a Roman numeral:");
   scanf("%s",roman);
   length=strlen(roman);
   for(i=0;i<length;i++){
      switch(roman[i]){
         case 'm':
         case 'M': d[i]=1000; break;
         case 'd':
         case 'D': d[i]= 500; break;
         case 'c':
         case 'C': d[i]= 100; break;
         case 'l':
         case 'L': d[i]= 50; break;
         case 'x':
         case 'X': d[i]= 10; break;;
         case 'v':
         case 'V': d[i]= 5; break;
         case 'i':
         case 'I': d[i]= 1;
      }
   }
   for(i=0;i<length;i++){
      if(i==length-1 || d[i]>=d[i+1])
         deci += d[i];
      else
         deci -= d[i];
   }
   printf("The Decimal equivalent of Roman numeral %s is %d", roman, deci);
}
When the above program is executed, it produces the following result −
The Roman equivalent to decimal
Decimal:.........Roman
1............ I
5............ V
10............ X
50............ L
100............ C
500............ D
1000............ M
Enter a Roman numeral: M
The Decimal equivalent of Roman Numeral M is 1000
How to get the Position of mouse pointer in jQuery ? - GeeksforGeeks

31 Mar, 2021
In this article, we will see how to get the position of the mouse pointer using jQuery. To get the position of mouse pointer, event.pageX, and event.pageY property is used. The event.pageX property is used to find the position of the mouse pointer relative to the left edge of the document. The event.pageY property is used to find the position of the mouse pointer relative to the top edge of the document.
Syntax:
event.pageX
event.pageY
Here, we use on() method to attach one or more event handlers for the selected elements and the text() method to set or return the text content of the element
Example:
HTML
<!DOCTYPE html><html>  <head>    <title>        How to get the Position of        mouse pointer in jQuery?    </title>      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>      <script>        $(document).ready(function () {            $(document).on("mousemove", function (event) {                $("#GFG").text("Mouse Position ("                 + event.pageX + ", " + event.pageY + ")");            });        });    </script>      <style>        body {            text-align: center;        }          h1 {            color: green;        }    </style></head>  <body>    <h1>GeeksforGeeks</h1>      <h3>        How to get the Position of        mouse pointer in jQuery?    </h3>      <div id="GFG"></div></body>  </html>
Output:
HTML-Tags
jQuery-Questions
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to prevent Body from scrolling when a modal is opened using jQuery ?
jQuery | ajax() Method
How to get the value in an input text box using jQuery ?
Difference Between JavaScript and jQuery
QR Code Generator using HTML, CSS and jQuery
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?
How to strike through and underline text in JavaFX?

In JavaFX, the text node is represented by the Javafx.scene.text.Text class. To insert/display text in JavaFx window you need to −
Instantiate the Text class.
Instantiate the Text class.
Set the basic properties like position and text string, using the setter methods or, bypassing them as arguments to the constructor.
Set the basic properties like position and text string, using the setter methods or, bypassing them as arguments to the constructor.
Add the created node to the Group object.
Add the created node to the Group object.
The strikethrough property of the javafx.scene.text.Text class determines whether each line of the text should have a straight line passing through the middle of it. You can set the value to this property using the setStrikeThrough() method. It accepts a boolean value. You can strike though the text (node) by passing true as an argument to this method.
The underline property of the javafx.scene.text.Text class determines whether each line of the text should have a straight line below it. You can set the value to this property using the setUnderline() method. It accepts a boolean value. You can have a line below the text (node) by passing true as an argument to this method.
import java.io.FileNotFoundException;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
public class Underline_StrikeThrough extends Application {
   public void start(Stage stage) throws FileNotFoundException {
      //Creating a text object
      String str = "Welcome to Tutorialspoint";
      Text text = new Text(30.0, 80.0, str);
      //Setting the font
      Font font = Font.font("Brush Script MT", FontWeight.BOLD, FontPosture.REGULAR, 65);
      text.setFont(font);
      //Setting the color of the text
      text.setFill(Color.DARKCYAN);
      //Setting the width and color of the stroke
      text.setStrokeWidth(2);
      text.setStroke(Color.DARKSLATEGRAY);
      //Underlining the text
      text.setUnderline(true);
      //Striking through the text
      text.setStrikethrough(true);
      //Setting the stage
      Group root = new Group(text);
      Scene scene = new Scene(root, 595, 150, Color.BEIGE);
      stage.setTitle("Underline And Strike-through");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]){
      launch(args);
   }
}
Delete all records from a table in MySQL?

To delete all the records from a table in MySQL, use the TRUNCATE command. Let us fir see the syntax −
TRUNCATE TABLE yourTableName.
The above syntax will delete all the records from a table. Let us create a table to understand the above syntax −
mysql> create table TruncateTableDemo
−> (
   −> BookId int
   −> ,
   −> BookName varchar(200)
−> );
Query OK, 0 rows affected (0.54 sec)
Inserting records in the table with the help of insert command. The query to insert records in the table are as follows −
mysql> insert into TruncateTableDemo values(1001,'C in Dept');
Query OK, 1 row affected (0.18 sec)

mysql> insert into TruncateTableDemo values(1002,'The C++ Programming');
Query OK, 1 row affected (0.22 sec)

mysql> insert into TruncateTableDemo values(1003,'Let us C');
Query OK, 1 row affected (0.16 sec)
Now you can display all the records from the table with the help of a select statement. The query is as follows −
mysql> select *from TruncateTableDemo;
The following is the output −
+--------+---------------------+
| BookId |           BookName  |
+--------+---------------------+
| 1001   |           C in Dept |
| 1002   | The C++ Programming |
| 1003   |            Let us C |
+--------+---------------------+
3 rows in set (0.00 sec)
Implement the above syntax to delete all the records from the table. The query is as follows −
mysql> truncate table TruncateTableDemo;
Query OK, 0 rows affected (0.93 sec)
Now you can check all records have been deleted from the table or not.
The following is the query −
mysql> select *from TruncateTableDemo;
Empty set (0.00 sec)
C++ Memory Library - static_pointer_cast

It allocates memory for an object of type T using alloc and constructs it passing args to its constructor. The function returns an object of type shared_ptr that owns and stores a pointer to the constructed object.
Following is the declaration for std::static_pointer_cast.
template <class T, class U>
   shared_ptr<T> static_pointer_cast (const shared_ptr<U>& sp) noexcept;
template <class T, class U>
   shared_ptr<T> static_pointer_cast (const shared_ptr<U>& sp) noexcept;
sp − Its a shared pointer.
It returns a copy of sp of the proper type with its stored pointer casted statically from U* to T*.
noexcep − It doesn't throw any exceptions.
In below example explains about std::static_pointer_cast.
#include <iostream>
#include <memory>

struct BaseClass {};

struct DerivedClass : BaseClass {
   void f() const {
      std::cout << "Sample word!\n";
   }
};
 
int main() {
   std::shared_ptr<BaseClass> ptr_to_base(std::make_shared<DerivedClass>());

   std::static_pointer_cast<DerivedClass>(ptr_to_base)->f();

   static_cast<DerivedClass*>(ptr_to_base.get())->f();

}
Let us compile and run the above program, this will produce the following result −
Sample word!
Sample word!

 Print
 Add Notes
 Bookmark this page
Firebase - Github Authentication

In this chapter, we will show you how to authenticate users using the GitHub API.
Open Firebase dashboard and click Auth from the side menu and then SIGN-IN-METHOD in tab bar. You need enable GitHub authentication and copy the Callback URL. You will need this in step 2. You can leave this tab open since you will need to add Client ID and Client Secret once you finish step 2.
Follow this link to create the GitHub app. You need to copy the Callback URL from Firebase into the Authorization callback URL field. Once your app is created, you need to copy the Client Key and the Client Secret from the GitHub app to Firebase.
We will add two buttons in the body tag.
<button onclick = "githubSignin()">Github Signin</button>
<button onclick = "githubSignout()">Github Signout</button>
We will create functions for signin and signout inside the index.js file.
var provider = new firebase.auth.GithubAuthProvider();

function githubSignin() {
   firebase.auth().signInWithPopup(provider)
   
   .then(function(result) {
      var token = result.credential.accessToken;
      var user = result.user;
		
      console.log(token)
      console.log(user)
   }).catch(function(error) {
      var errorCode = error.code;
      var errorMessage = error.message;
		
      console.log(error.code)
      console.log(error.message)
   });
}

function githubSignout(){
   firebase.auth().signOut()
   
   .then(function() {
      console.log('Signout successful!')
   }, function(error) {
      console.log('Signout failed')
   });
}
Now we can click on buttons to trigger authentication. Console will show that the authentication is successful.

    60 Lectures 
     5 hours 

 University Code

    28 Lectures 
     2.5 hours 

 Appeteria

    85 Lectures 
     14.5 hours 

 Appeteria

    46 Lectures 
     2.5 hours 

 Gautham Vijayan

    13 Lectures 
     1.5 hours 

 Nishant Kumar

    85 Lectures 
     16.5 hours 

 Rahul Agarwal
 Print
 Add Notes
 Bookmark this page
Hexadecimal Arithmetic

Following are the characteristics of a hexadecimal number system.
Uses 10 digits and 6 letters, 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F.
Uses 10 digits and 6 letters, 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F.
Letters represents numbers starting from 10. A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.
Letters represents numbers starting from 10. A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.
Also called base 16 number system.
Also called base 16 number system.
Each position in a hexadecimal number represents a 0 power of the base (16). Example − 160
Each position in a hexadecimal number represents a 0 power of the base (16). Example − 160
Last position in a hexadecimal number represents an x power of the base (16). Example − 16x where x represents the last position - 1.
Last position in a hexadecimal number represents an x power of the base (16). Example − 16x where x represents the last position - 1.
Hexadecimal Number − 19FDE16
Calculating Decimal Equivalent −
Note − 19FDE16 is normally written as 19FDE.
Following hexadecimal addition table will help you greatly to handle Hexadecimal addition.
To use this table, simply follow the directions used in this example − Add A16 and 516. Locate A in the X column then locate the 5 in the Y column. The point in 'sum' area where these two columns intersect is the sum of two numbers.
A16 + 516 = F16.

The subtraction of hexadecimal numbers follow the same rules as the subtraction of numbers in any other number system. The only variation is in borrowed number. In the decimal system, you borrow a group of 1010. In the binary system, you borrow a group of 210. In the hexadecimal system you borrow a group of 1610.

    107 Lectures 
     13.5 hours 

 Arnab Chakraborty

    106 Lectures 
     8 hours 

 Arnab Chakraborty

    99 Lectures 
     6 hours 

 Arnab Chakraborty

    46 Lectures 
     2.5 hours 

 Shweta

    70 Lectures 
     9 hours 

 Abhilash Nelson

    52 Lectures 
     7 hours 

 Abhishek And Pukhraj
 Print
 Add Notes
 Bookmark this page
Docker - Hub

Docker Hub is a registry service on the cloud that allows you to download Docker images that are built by other communities. You can also upload your own Docker built images to Docker hub. In this chapter, we will see how to download and the use the Jenkins Docker image from Docker hub.

The official site for Docker hub is − https://www.docker.com/community-edition#/add_ons
Step 1 − First you need to do a simple sign-up on Docker hub.
Step 2 − Once you have signed up, you will be logged into Docker Hub.
Step 3 − Next, let’s browse and find the Jenkins image.
Step 4 − If you scroll down on the same page, you can see the Docker pull command. This will be used to download the Jenkins image onto the local Ubuntu server.
Step 5 − Now, go to the Ubuntu server and run the following command −
sudo docker pull jenkins 

To run Jenkins, you need to run the following command −
sudo docker run -p 8080:8080 -p 50000:50000 jenkins 

Note the following points about the above sudo command −
We are using the sudo command to ensure it runs with root access.
We are using the sudo command to ensure it runs with root access.
Here, jenkins is the name of the image we want to download from Docker hub and install on our Ubuntu machine.
Here, jenkins is the name of the image we want to download from Docker hub and install on our Ubuntu machine.
-p is used to map the port number of the internal Docker image to our main Ubuntu server so that we can access the container accordingly.
-p is used to map the port number of the internal Docker image to our main Ubuntu server so that we can access the container accordingly.
You will then have Jenkins successfully running as a container on the Ubuntu machine.

    70 Lectures 
     12 hours 

 Anshul Chauhan

    41 Lectures 
     5 hours 

 AR Shankar

    31 Lectures 
     3 hours 

 Abhilash Nelson

    15 Lectures 
     2 hours 

 Harshit Srivastava, Pranjal Srivastava

    33 Lectures 
     4 hours 

 Mumshad Mannambeth

    13 Lectures 
     53 mins

 Musab Zayadneh
 Print
 Add Notes
 Bookmark this page