code-rag-bench/online-tutorials huggingface dataset:
Sum of the multiples of two numbers below N in C++

In this problem, we have given three integers M1, M2, and N. Our task is to create a program to find the sum of multiples of two numbers below N.
Here, we will add all the elements below N which are multiples of either M1 or M2
Let’s take an example to understand the problem,
Input 
N = 13, M1 = 4, M2 = 6
Output  
20
Explanation − Number that are multiples of 4 and 6 that are less than 13 are 4, 6, 8, 12.
A simple solution to the problem is to be looping from 1 to N and adding all values that can be divided by M1 or M2.
Step 1 − sum = 0 , i = 0. Loop from i = 1 to N.
Step 1.1 − if (i%M1 == 0) or (i%M2 == 0), sum + = i
Step 2 − Return sum.
Program to illustrate the working of our solution,
 Live Demo
#include <iostream<
using namespace std;
int calcMulSum(int N, int M1, int M2){
   int sum = 0;
   for (int i = 0; i < N; i++)
      if (i%M1 == 0 || i%M2 == 0)
   sum += i;
   return sum;
}
int main(){
   int N = 24, M1 = 4, M2 = 7;
   cout<<"The sum of multiples of "<<M1<<" and "<<M2<<" below "<<N<<" is "<<calcMulSum(N, M1, M2);
   return 0;
}
The sum of multiples of 4 and 7 below 24 is 102
This is not the best solution to our problem as it takes O(n) time complexity.
A better solution will be using mathematical formulas for the sum of series.
Here, we will use the formula for the sum of the series. The final sum will be the (multiples of M1 + multiples of M2 - multiples of M1*M2)
Sum of multiple of x upto n terms is given by,
Sum(X) = (n * (1+n) * X)/2
Let’s formulate the sum,
sum = ( ( ((n/M1)*(1+(n/M1))*M1)/2) + ((n/M2)*(1+(n/M2))*M2)/2 ) - ((n/M1*M2)*(1+(n/M1*M2))*M1*M2)/2 ) )
Program to illustrate the solution,
 Live Demo
#include <iostream>
using namespace std;
int calcMulSum(int N, int M1, int M2){
   N--;
   return (((N/M1) * (1 + (N/M1)) * M1 / 2) + ((N/M2) * (1 + (N/M2)) * M2 / 2) - ((N/(M1*M2)) * (1 + (N/(M1*M2))) * (M1*M2) / 2));
}
int main(){
   int N = 24, M1 = 4, M2 = 7;
   cout<<"The sum of multiples of "<<M1<<" and "<<M2<<" below "<<N<<" is "<<calcMulSum(N, M1, M2);
   return 0;
}
The sum of multiples of 4 and 7 below 24 is 102
Get Month Name from Month number in MySQL?

You can use MONTHNAME() function from MySQL to display Month name from number. The syntax is as follows.
SELECT MONTHNAME(STR_TO_DATE(yourColumnName,’%m’)) as anyVariableName from yourTableName;
To understand the above concept, let us first create a table. The query to create a table is as follows.
mysql> create table MonthDemo
-> (
-> MonthNum int
-> );
Query OK, 0 rows affected (0.87 sec)
Insert some records in the table using insert command. The query is as follows −
mysql> insert into MonthDemo values(1);
Query OK, 1 row affected (0.14 sec)

mysql> insert into MonthDemo values(2);
Query OK, 1 row affected (0.15 sec)

mysql> insert into MonthDemo values(3);
Query OK, 1 row affected (0.12 sec)

mysql> insert into MonthDemo values(4);
Query OK, 1 row affected (0.12 sec)

mysql> insert into MonthDemo values(5);
Query OK, 1 row affected (0.13 sec)

mysql> insert into MonthDemo values(6);
Query OK, 1 row affected (0.18 sec)

mysql> insert into MonthDemo values(7);
Query OK, 1 row affected (0.13 sec)

mysql> insert into MonthDemo values(8);
Query OK, 1 row affected (0.13 sec)

mysql> insert into MonthDemo values(9);
Query OK, 1 row affected (0.15 sec)

mysql> insert into MonthDemo values(10);
Query OK, 1 row affected (0.13 sec)

mysql> insert into MonthDemo values(11);
Query OK, 1 row affected (0.14 sec)

mysql> insert into MonthDemo values(12);
Query OK, 1 row affected (0.15 sec)
Display all records from the table using select command. The query is as follows.
mysql> select *from MonthDemo;
The following is the output.
+------------+
| MonthNum   |
+------------+
| 1          |
| 2          |
| 3          |
| 4          |
| 5          |
| 6          |
| 7          |
| 8          |
| 9          |
| 10         |
| 11         |
| 12         |
+------------+
12 rows in set (0.00 sec)
Here is the query to display month name.
mysql> select monthname(str_to_date(MonthNum,'%m')) as MonthName from MonthDemo;
The following is the output.
+-----------+
| MonthName |
+-----------+
| January   |
| February  |
| March     |
| April     |
| May       |
| June      |
| July      |
| August    |
| September |
| October   |
| November  |
| December  |
+-----------+
12 rows in set (0.00 sec)
How to create scrollable TextView on Android using Kotlin?

This example demonstrates how to create scrollable TextView on Android using Kotlin.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:id="@+id/activity_main"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:padding="5dp"
   tools:context=".MainActivity">
   <TextView
      android:id="@+id/textView"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:scrollbars="vertical"
      android:textColor="@android:color/background_dark"
      android:textSize="48sp"
      android:textStyle="italic" />
</RelativeLayout>

Step 3 − Add the following code to src/MainActivity.kt
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.text.method.ScrollingMovementMethod
import android.widget.TextView
class MainActivity : AppCompatActivity() {
   override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
      title = "KotlinApp"
      val textView: TextView = findViewById(R.id.textView)
      val text: String = "Your time is limited, so don’t waste it living someone else’s life. Don’t be trapped by dogma – which is living with the results of other people’s thinking. " + "If life were predictable it would cease to be life, and be without flavor. The big lesson in life, baby, is never be scared of anyone or anything."
      textView.text = text
      textView.movementMethod = ScrollingMovementMethod()
   }
}
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.q11">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click the Run icon  from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen.
Click here to download the project code.
Compare Strings in Arduino

Arduino has an inbuilt compareTo() function that helps compare which string comes before another. Very crudely, you can think of it as this: if you are given two strings, which one will come first in a dictionary.
String1.compareTo(String2)
Where String1 and String2 are the two strings to be compared. This function returns an integer. Here’s the interpretation of the value of the integer −
Negative − String1 comes before String2
Negative − String1 comes before String2
0 − String1 and String2 are equal
0 − String1 and String2 are equal
Positive − String2 comes before String1
Positive − String2 comes before String1
Please note that this function is case sensitive. So ‘A’ comes before ‘a’ and ‘B’ comes before ‘a’. But ‘a’ comes before ‘b’. Also, numbers come before letters. Basically, if a character’s ASCII value is higher than another, then the higher character comes later in the dictionary. And compareTo() function compares the strings character by character.
void setup() {
   // put your setup code here, to run once:
   Serial.begin(9600);
   Serial.println();

   String s1 = "Book";
   String s2 = "books";
   String s3 = "library";

   if(s1.compareTo(s2) < 0){
      Serial.println("s1 before s2");
   }

   if(s2.compareTo(s3) < 0){
      Serial.println("s2 before s3");
   }

   if(s3.compareTo(s1) < 0){
      Serial.println("s3 before s1");
   }
}

void loop() {
   // put your main code here, to run repeatedly:
}
The Serial Monitor output is shown below −
As you can see, the function works exactly as described.
mat-slide-toggle in Angular material - GeeksforGeeks

27 Jan, 2021
Angular Material is a UI component library that is developed by the Angular team to build design components for desktop and mobile web applications. In order to install it, we need to have angular installed in our project, once you have it you can enter the below command and can download it. 
mat-slide-toggle is a kind of switch or button that is used to toggle between states like one and off or true or false.
Installation syntax:
ng add @angular/material
Approach:
First, install the angular material using the above-mentioned command.
After completing the installation, Import ‘MatSlideToggleModule’ from ‘@angular/material/slide-toggle’ in the app.module.ts file.
Then use the mat-slide-toggle tag to display a toggle button.
And in order to write the significance of that button then we need to mention it between the opening and closing tags.
If we want to change the theme then we can change it by using the color property. In angular we have 3 themes, they are primary, accent, and warn.
Once done with the above steps then serve or start the project.
Code Implementation:
app.module.ts:
Javascript
import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms';       import { AppComponent } from './app.component'; import { MatSlideToggleModule } from '@angular/material/slide-toggle';      @NgModule({ imports: [ BrowserModule,     FormsModule,   MatSlideToggleModule], declarations: [ AppComponent ], bootstrap: [ AppComponent ] })   export class AppModule { }
app.component.html:
HTML
<mat-slide-toggle color="primary">  Slide me to get the primary theme!</mat-slide-toggle> <br /><br /><mat-slide-toggle color="accent">  Slide me to get the accent theme!</mat-slide-toggle><br /><br /><mat-slide-toggle color="warn">  Slide me to get the warn theme!</mat-slide-toggle>
Output:
AngularJS-Misc
Picked
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Angular PrimeNG Dropdown Component
Angular PrimeNG Calendar Component
Angular PrimeNG Messages Component
Angular 10 (blur) Event
How to make a Bootstrap Modal Popup in Angular 9/8 ?
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?
Excel Delete Cells

Cells can be deleted by selecting them, and pressing the delete button.
Note: The delete function will not delete the formatting of the cell, just the value inside of it.
Let's have a look at three examples.
Pressing the delete button:
Pressing the delete button:
With formatting:
Pressing the delete button:
Note that it only deletes the value in the cells, and not the formatting (the color).
Note: You will learn more about formatting, and how to style cells in a later chapter.
Complete the name of the command for removing columns:
 Columns

Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
How to find all uppercase strings in a MySQL table?

To find all upper case strings in a MySQL table, you need to use BINARY UPPER() function. The syntax is as follows:
SELECT *FROM yourTableName WHERE yourColumnName=BINARY UPPER(yourColumnName);
To understand the above syntax, let us create a table. The query to create a table is as follows:
mysql> create table FindUpperCaseDemo
   -> (
   -> Id int,
   -> FirstName varchar(20),
   -> Age int
   -> );
Query OK, 0 rows affected (1.04 sec)
Insert some records in the table using insert command. The query is as follows:
mysql> insert into FindUpperCaseDemo values(1,'John',23);
Query OK, 1 row affected (0.17 sec)
mysql> insert into FindUpperCaseDemo values(2,'CAROL',21);
Query OK, 1 row affected (0.29 sec)
mysql> insert into FindUpperCaseDemo values(3,'JoHN',23);
Query OK, 1 row affected (0.11 sec)
mysql> insert into FindUpperCaseDemo values(4,'JOHN',26);
Query OK, 1 row affected (0.22 sec)
mysql> insert into FindUpperCaseDemo values(5,'sAM',26);
Query OK, 1 row affected (0.18 sec)
mysql> insert into FindUpperCaseDemo values(6,'SAM',28);
Query OK, 1 row affected (0.18 sec)
mysql> insert into FindUpperCaseDemo values(7,'MIKE',29);
Query OK, 1 row affected (0.17 sec)
mysql> insert into FindUpperCaseDemo values(8,'BOB',20);
Query OK, 1 row affected (0.45 sec)
mysql> insert into FindUpperCaseDemo values(9,'LARRY',22);
Query OK, 1 row affected (0.39 sec)
mysql> insert into FindUpperCaseDemo values(10,'LARRy',22);
Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement. The query is as follows:
mysql> select *from FindUpperCaseDemo;
The following is the output:
+------+-----------+------+
| Id   | FirstName | Age  |
+------+-----------+------+
|    1 | John      |   23 |
|    2 | CAROL     |   21 |
|    3 | JoHN      |   23 |
|    4 | JOHN      |   26 |
|    5 | sAM       |   26 |
|    6 | SAM       |   28 |
|    7 | MIKE      |   29 |
|    8 | BOB       |   20 |
|    9 | LARRY     |   22 |
|   10 | LARRy     |   22 |
+------+-----------+------+
10 rows in set (0.00 sec)
Here is the query to find all uppercase strings in a MySQL table:
mysql> select *from FindUpperCaseDemo where FirstName=BINARY UPPER(FirstName);
The following is the output:
+------+-----------+------+
| Id   | FirstName | Age  |
+------+-----------+------+
|    2 | CAROL     |   21 |
|    4 | JOHN      |   26 |
|    6 | SAM       |   28 |
|    7 | MIKE      |   29 |
|    8 | BOB       |   20 |
|    9 | LARRY     |   22 |
+------+-----------+------+
6 rows in set (0.09 sec)
Using the new keyword in C#

Use the new keyword to create an instance of the array. The new operator is used to create an object or instantiate an object. Here in the example an object is created for the class using the new.
The following is an example.
Calculate c = new Calculate();
You can also use the new keyword to create an instance of the array.
double[] points = new double[10];
The new keyword is also used to create object of a collection.
SortedList sl = new SortedList(); // SortedList
List<string> myList = new List<string>() // List
Let us see an example.
 Live Demo
using System;
class Program {
   static void Main() {

      int[] arrSource = new int[4];
      arrSource[0] = 5;
      arrSource[1] = 9;
      arrSource[2] = 1;
      arrSource[3] = 3;

      int[] arrTarget = new int[4];

      // CopyTo() method
      arrSource.CopyTo(arrTarget,0 );

      Console.WriteLine("Destination Array ...");
      foreach (int value in arrTarget) {
         Console.WriteLine(value);
      }
   }
}
Destination Array ...
5
9
1
3
Calculate Hyperbolic sine of a value in R Programming - sinh() Function - GeeksforGeeks

01 Jun, 2020
sinh() function in R Language is used to calculate the hyperbolic sine value of the numeric value passed to it as argument.
Syntax: sinh(x)
Parameter:x: Numeric value
Example 1:
# R code to calculate hyperbolic sine of a value  # Assigning values to variablesx1 <- -90x2 <- -30  # Using sinh() Functionsinh(x1)sinh(x2)
Output:
[1] -6.102016e+38
[1] -5.343237e+12
Example 2:
# R code to calculate hyperbolic sine of a value  # Assigning values to variablesx1 <- pix2 <- pi / 3  # Using sinh() Functionsinh(x1)sinh(x2)
Output:
[1] 11.54874
[1] 1.249367
R Math-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
How to filter R dataframe by multiple conditions?
R - if statement
Replace Specific Characters in String in R
How to import an Excel File into R ?
Filter multiple values on a string column in R using Dplyr
C program to sort an array of ten elements in an ascending order

An array is a group of related data items that are stored with single name.
For example, int student[30];
Here, student is an array name which holds 30 collection of data items, with a single variable name.
The operations of an array are explained below −
Searching − It is used to find whether a particular element is present or not.
Searching − It is used to find whether a particular element is present or not.
Sorting − Helps in arranging the elements in an array either in ascending or descending order.
Sorting − Helps in arranging the elements in an array either in ascending or descending order.
Traversing − Processing every element in an array, sequentially.
Traversing − Processing every element in an array, sequentially.
Inserting − Helps in inserting the elements in an array.
Inserting − Helps in inserting the elements in an array.
Deleting − Helps in deleting an element in an array.
Deleting − Helps in deleting an element in an array.
In this program, we are using the swapping technique to sort the elements in an ascending order.
The logic that we applied to sort an array in ascending order is as follows −
for(i=0;i<10-1;i++){
   for(j=i+1;j<10;j++){
      if(element[i]>element[j]){
         temp=element[i]; //swapping element[i] with element[j]
         element[i]=element[j];
         element[j]=temp;
      }
   }
}
Given below is the C program to sort an array of ten elements in an ascending order −
 Live Demo
#include<stdio.h>
int main(){
   int element[10],i,j,temp;
   printf("enter 10 integer numbers:");
   for(i=0;i<10;i++){
      scanf("%d",&element[i]);
   }
   for(i=0;i<10-1;i++){
      for(j=i+1;j<10;j++){
         if(element[i]>element[j]){
            temp=element[i]; //swapping element[i] with element[j]
            element[i]=element[j];
            element[j]=temp;
         }
      }
   }
   printf("Elements are now in ascending order:");
   for(i=0;i<10;i++)
      printf("%d\n",element[i]);
   return 0;
}
The output is given below −
enter 10 integer numbers:
12
23
34
1
22
34
56
45
33
78
Elements are now in ascending order:1
12
22
23
33
34
34
45
56
78
C library function - isspace()

The C library function int isspace(char c) checks whether the passed character is white-space.
Standard white-space characters are −
' '   (0x20)	space (SPC)
'\t'	(0x09)	horizontal tab (TAB)
'\n'	(0x0a)	newline (LF)
'\v'	(0x0b)	vertical tab (VT)
'\f'	(0x0c)	feed (FF)
'\r'	(0x0d)	carriage return (CR)
Following is the declaration for isspace() function.
int isspace(char c);
c − This is the character to be checked.
c − This is the character to be checked.
This function returns a non-zero value(true) if c is a white-space character else, zero (false).
The following example shows the usage of isspace() function.
#include <stdio.h>
#include <ctype.h>

int main () {
   int var1 = 't';
   int var2 = '1';
   int var3 = ' ';

   if( isspace(var1) ) {
      printf("var1 = |%c| is a white-space character\n", var1 );
   } else {
      printf("var1 = |%c| is not a white-space character\n", var1 );
   }
   
   if( isspace(var2) ) {
      printf("var2 = |%c| is a white-space character\n", var2 );
   } else {
      printf("var2 = |%c| is not a white-space character\n", var2 );
   }
   
   if( isspace(var3) ) {
      printf("var3 = |%c| is a white-space character\n", var3 );
   } else {
      printf("var3 = |%c| is not a white-space character\n", var3 );
   }
   
   return(0);
}
Let us compile and run the above program that will produce the following result −
var1 = |t| is not a white-space character
var2 = |1| is not a white-space character
var3 = | | is a white-space character


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
Data Structures | Stack | Question 1 - GeeksforGeeks

08 Jan, 2013
Following is C like pseudo code of a function that takes a number as an argument, and uses a stack S to do processing.
void fun(int n){    Stack S;  // Say it creates an empty stack S    while (n > 0)    {      // This line pushes the value of n%2 to stack S      push(&S, n%2);        n = n/2;    }      // Run while Stack S is not empty    while (!isEmpty(&S))      printf("%d ", pop(&S)); // pop an element from S and print it}
What does the above function do in general?(A) Prints binary representation of n in reverse order(B) Prints binary representation of n(C) Prints the value of Logn(D) Prints the value of Logn in reverse orderAnswer: (B) Explanation: See method 2 of https://www.geeksforgeeks.org/binary-representation-of-a-given-number/ for explanation.
Data Structures
Data Structures-Stack
Data Structures
Data Structures
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Advantages and Disadvantages of Linked List
Introduction to Data Structures | 10 most commonly used Data Structures
FIFO vs LIFO approach in Programming
Bit manipulation | Swap Endianness of a number
Data Structures | Queue | Question 11
Advantages of vector over array in C++
Program to create Custom Vector Class in C++
Multilevel Linked List
Difference between data type and data structure
Encryption and Decryption of String according to given technique
Erlang - Case Statements

Erlang offers the case statement, which can be used to execute expressions based on the output of the case statement.
The general form of this statement is −
case expression of
   value1 -> statement#1;
   value2 -> statement#2;
   valueN -> statement#N
end.

The general working of this statement is as follows −
The expression to be evaluated is placed in the case statement. This generally will evaluate to a value, which is used in the subsequent statements.
The expression to be evaluated is placed in the case statement. This generally will evaluate to a value, which is used in the subsequent statements.
Each value is evaluated against that which is passed by the case expression. Depending on which value holds true, that subsequent statement will be executed.
Each value is evaluated against that which is passed by the case expression. Depending on which value holds true, that subsequent statement will be executed.
The following diagram shows the flow of the case statement.
The following program is an example of the case statement in Erlang −
-module(helloworld). 
-export([start/0]). 

start() -> 
   A = 5,
   case A of 
      5 -> io:fwrite("The value of A is 5"); 
      6 -> io:fwrite("The value of A is 6") 
   end.
The output of the above code will be −
The value of A is 5.

 Print
 Add Notes
 Bookmark this page
Python - Data Structure

Computers store and process data with an extra ordinary speed and accuracy. So it is highly essential that the data is stored efficiently and can be accessed fast. 
Also the processing of data should happen in the smallest possible time but without losing the accuracy. 
Data structures deal with how the data is organized and held in the memory when a program processes it. 
It is important to note that the data that is stored in the disk as part of persistent storages (like relational tables) are not referred as data structure here. 
An Algorithm is step by step set of instruction to process the data for a specific purpose. So an algorithm utilizes various data structures in a logical way to solve a specific computing problem.
In this tutorial we will cover these two fundamental concepts of computer science using the Python programming language.
This tutorial is designed for Computer Science graduates as well as Software Professionals who are willing to learn data structures and algorithm programming in simple and easy steps using Python as a programming language.
Before proceeding with this tutorial, you should have a basic knowledge of writing code in Python programming language, using any python IDE  and execution of Python programs.
If you are completely new to python then please refer our  Python tutorial  to get a sound understanding of the language.
For most of the examples given in this tutorial you will find Try it option, so just make use of it and enjoy your learning.
Try following example using Try it option available at the top right corner of the below sample code box 
#!/usr/bin/python

print "Hello, Python!"



    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
How to create a flip card with CSS?

To create a flip card with CSS, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
   body {
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      margin:20px;
   }
   .flipCard {
      background-color: transparent;
      width: 300px;
      height: 300px;
      perspective: 1000px;
   }
   .innerCard {
      position: relative;
      width: 100%;
      height: 100%;
      text-align: center;
      transition: transform 0.6s;
      transform-style: preserve-3d;
      box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
   }
   .flipCard:hover .innerCard {
      transform: rotateY(180deg);
   }
   .frontCard, .cardBack {
      position: absolute;
      width: 100%;
      height: 100%;
      -webkit-backface-visibility: hidden;
      backface-visibility: hidden;
   }
   .frontCard {
      background-color: rgb(124, 225, 243);
      color: black;
   }
   .cardBack {
      background-color: #3329b9;
      color: white;
      transform: rotateY(180deg);
      font-size: 18px;
      font-weight: bold;
   }
</style>
</head>
<body>
<h1>Card Flip with Text Example</h1>
<div class="flipCard">
<div class="innerCard">
<div class="frontCard">
<img src="https://cdn.pixabay.com/photo/2016/04/01/11/25/avatar-1300331_960_720.png" alt="Avatar" style="width:300px;height:300px;">
</div>
<div class="cardBack">
<h1>James Anderson</h1>
<p>Architect</p>
<p>Experience: 16 years</p>
</div>
</div>
</div>
<h2>Hover over the above image to see the text</h2>
</body>
</html>
The above code will produce the following output −
On hovering over the image −
Mouse over Actions with Cypress

The mouseover actions are very common in web pages where a list of elements becomes visible once we hover on it. Cypress does not support mouse over actions like other automation tools like Selenium as it considers it to be flaky.
Cypress shall manipulate DOM elements to perform mouse over actions. Cypress takes the help of show() method in JQuery. The show() method displays the elements which are hidden [ having the CSS property display:none] and selected.
Also, the show() method only works with the immediate parent in the DOM of the
hidden element.
Now to invoke any JQuery function, Cypress takes the help of the invoke() command which is used to invoke a function. The invoke() method cannot be chained directly with cy.
.invoke(name of function)
.invoke(options, name of function)
.invoke(name of function, arguments..)
.invoke(name of function, arguments..)
.invoke(options, name of function, arguments...)
The name of the function refers to the function that has to be invoked. Also, we
can have additional arguments to the function call and there is no restriction on
the count of the number of arguments.
There can be of two types of options as listed below which can modify the default
behavior of .invoke() −
log − The default value of log is true.
log − The default value of log is true.
timeout − The default value of timeout parameter is defaultCommandTimeout (4000 milliseconds). This the duration to wait for .invoke() to conclude.
timeout − The default value of timeout parameter is defaultCommandTimeout (4000 milliseconds). This the duration to wait for .invoke() to conclude.
cy.get('#txt').invoke('show')
Coding Implementation with JQuery show() method.
describe('Tutorialspoint Test', function () {
   // test case
   it('Test Case5', function (){
      // launch the application
      cy.visit("https://www.amazon.com/");
      // to display hidden element with invoke() with show
      cy.get('#nav-flyout-ya-signin').invoke('show');
      //click on the hidden element
      cy.contains('Sign').click();
      //assert to verify the url
      cy.url().should('include','signin');
   });
});
Cypress has another workaround to click on the hidden elements that appear only
on mouse over action on the page. This is done by passing an option as an argument
to the click() command in Cypress.
click({ force: true }) − The click() command with the option force set to true [force:true ] modifies the default behavior of the hidden element and we can click on it.
cy.get('.butn').click({ force: true })
Coding implementation with force option for hidden element.
describe('Tutorialspoint Test', function () {
   // test case
   it('Test Case5', function (){
      // launch the application
      cy.visit("https://www.amazon.com/");
      //click on the hidden element with option force set to true
      cy.contains('Sign').click({force:true});
      //assert to verify the url
      cy.url().should('include','signin');
   });
});
Semantic similarity classifier and clustering sentences based on semantic similarity. | by Manish Chablani | Towards Data Science

Recently we have been doing some experiments to cluster semantically similar messages, by leveraging pre-trained models so we can get something off the ground using no labelled data. Task here is given a list of sentences we cluster them such that semantically similar sentences are in same cluster and number of clusters is not predetermined.
Task of semantic similarity classifier is: Given two sentences/messages/paragraphs classify of they are semantically equivalent.
InferSent is a sentence embeddings method that provides semantic representations for English sentences. It is trained on natural language inference data and generalizes well to many different tasks.
github.com
Here is the code:
# Load infersent model model_version = 2MODEL_PATH = "infersent_sentence_encoder/infersent%s.pkl" % model_versionparams_model = {'bsize': 64, 'word_emb_dim': 300, 'enc_lstm_dim': 2048,                'pool_type': 'max', 'dpout_model': 0.0, 'version': model_version}model = InferSent(params_model)model.load_state_dict(torch.load(MODEL_PATH))# If infersent1 -> use GloVe embeddings. If infersent2 -> use InferSent embeddings.W2V_PATH = 'infersent_sentence_encoder/GloVe/glove.840B.300d.txt' if model_version == 1 else 'infersent_sentence_encoder/fastText/crawl-300d-2M.vec'model.set_w2v_path(W2V_PATH)#load datads = pd.read_msgpack('./ds.mp')sentences = ds['text']# generate infersent sentence embeddingsmodel.build_vocab(sentences, tokenize=True)embs = model.encode(sentences, tokenize=True)
Idea here is to index representation (embedding) of each sentence/message/paragraph and pick k (=10) NN (nearest neighbor) candidates for each sentence based on distance threshold. We found that nmslib is very fast and efficient.
import nmslibNTHREADS = 8def create_index(a):    index = nmslib.init(space='angulardist')    index.addDataPointBatch(a)    index.createIndex()    return indexdef get_knns(index, vecs, k=3):    return zip(*index.knnQueryBatch(vecs, k=k,num_threads=NTHREADS))nn_wvs = create_index(embs)to_frame = lambda x: pd.DataFrame(np.array(x)[:,1:])idxs, dists = map(to_frame, get_knns(nn_wvs, embs, k=10))catted = pd.concat([idxs.stack().to_frame('idx'), dists.stack().to_frame('dist')], axis=1).reset_index().drop('level_1',1).rename(columns={'level_0': 'v1', 'idx': 'v2'})
Think of step 2 as candidate generation (focusing on recall) and step 3 as focusing on precision. Of all the candidates that are considered potential duplicates here we assign probability to each pair.
Based on candidates that are considered duplicates in step 3 we merge clusters using agglomerative clustering implementation in scikit. In agglomerative clustering all observations start as thier own clusters and clusters are merge using the merge criteria specified until convergence, at which point no more merges are happening.
scikit-learn.org
This works fairly well in practice and the clusters formed have good semantic equivalence.
How to change Entry.get() into an integer in Tkinter?

The Entry widget in Tkinter is generally used to accept one-line input in the text field. We can get the output from the Entry widget using .get() method. However, the .get() method returns the output in string format. For example, if the user types an integer number in the Entry widget, it gets converted to a string. To change the type of the Entry input into an integer, we can cast the string to an integer.
In this example, we have shown how to calculate the sum while taking an integer input from the user.
# Import the required libraries
from tkinter import *

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

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

def cal_sum():
   t1=int(a.get())
   t2=int(b.get())
   sum=t1+t2
   label.config(text=sum)

# Create an Entry widget
Label(win, text="Enter First Number", font=('Calibri 10')).pack()
a=Entry(win, width=35)
a.pack()
Label(win, text="Enter Second Number", font=('Calibri 10')).pack()
b=Entry(win, width=35)
b.pack()

label=Label(win, text="Total Sum : ", font=('Calibri 15'))
label.pack(pady=20)

Button(win, text="Calculate Sum", command=cal_sum).pack()

win.mainloop()
Collect.js | diff() Function - GeeksforGeeks

11 Jun, 2020
The diff() function compares the main collection against the given collection and returns the values which are in original collection but not in the given collection. In JavaScript, the array is first converted to a collection and then the function is applied to the collection.
Syntax: 
data.diff(collection)

Parameters: This function accept a single parameter as mentioned above and described below:
collection: Hold the collection that will be compared with the main collection.
Return Value:  Returns a new collection with difference between collection items. 
Below examples illustrate the diff() function in collect.jsExample 1: Here in this example, we take a collection and then using the diff() function and return the value not in the new collection.
Javascript
// It is used to import collect.js library const collect = require('collect.js');  const collection = collect([1, 2, 3, 4, 5 ,6]);console.log(collection.diff([1, 2, 5]));
 Output:
Collection { items: [ 3, 4, 6 ] }

Example 2: There is one thing to notice that this function holds a collection, compare with the main collection but only return only those items that are extra in the main collection.
Javascript
// It is used to import collect.js libraryconst collect = require('collect.js');  const col1 = [1, 2, 3, 4];const col2 = [3, 4, 5, 6];  const x = collect(col1);const y = collect(col2);  const difference = x.diff(y); console.log(difference.all());
Output:
[ 1 , 2]

Reference: https://collect.js.org/api/count.html
Collect.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
Remove elements from a JavaScript Array
How to get character array from string in JavaScript?
How to filter object array based on attributes?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
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?
How to convert Java Array to Iterable?

To make an array iterable either you need to convert it to a stream or as a list using the asList() or stream() methods respectively. Then you can get an iterator for these objects using the iterator() method.
Live Demo
import java.util.Arrays;
import java.util.Iterator;

public class ArrayToIterable {
   public static void main(String args[]){
      Integer[] myArray = {897, 56, 78, 90, 12, 123, 75};
      Iterator<Integer> iterator = Arrays.stream(myArray).iterator();
      while(iterator.hasNext()) {
         System.out.println(iterator.next());
      }
   }
}
897
56
78
90
12
123
75
As mentioned above, you can also convert an array to list and get an iterator from that list using the iterator() method.
Integer[] myArray = {897, 56, 78, 90, 12, 123, 75};
Iterator<Integer> iterator = Arrays.asList(myArray).iterator();

//Iterator<Integer> iterator = Arrays.stream(myArray).iterator();
while(iterator.hasNext()) {
   System.out.println(iterator.next());
}
How to hide ticks label in Python but keep the ticks in place?

To hide ticks label and keep the ticks in place, we can take the following steps −
Initialize x1 and x10 variables to get the x and y points, using numpy.
Initialize x1 and x10 variables to get the x and y points, using numpy.
Plot points x and y using the plot() method.
Plot points x and y using the plot() method.
Using xticks method, get or set the current tick locations and labels of the X-axis. Pass no arguments to return the current values without modifying them. So, pass the range(x1, x10) to get ticks but pass an empty list to hide the labels.
Using xticks method, get or set the current tick locations and labels of the X-axis. Pass no arguments to return the current values without modifying them. So, pass the range(x1, x10) to get ticks but pass an empty list to hide the labels.
To display the figure, use the show() method.
To display the figure, use the show() method.
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
x1 = 1
x10 = 10
x = np.linspace(1, 10, 100)
y = np.log(x)
plt.plot(x, y)
plt.xticks(ticks=range(x1, x10), labels=[])
plt.show()
Python 3 - Tkinter pack() Method

This geometry manager organizes widgets in blocks before placing them in the parent widget.
widget.pack( pack_options )

Here is the list of possible options  −
expand − When set to true, widget expands to fill any space not otherwise used in widget's parent.
expand − When set to true, widget expands to fill any space not otherwise used in widget's parent.
fill − Determines whether widget fills any extra space allocated to it by the packer, or keeps its own minimal dimensions: NONE (default), X (fill only horizontally), Y (fill only vertically), or BOTH (fill both horizontally and vertically).
fill − Determines whether widget fills any extra space allocated to it by the packer, or keeps its own minimal dimensions: NONE (default), X (fill only horizontally), Y (fill only vertically), or BOTH (fill both horizontally and vertically).
side − Determines which side of the parent widget packs against: TOP (default), BOTTOM, LEFT, or RIGHT.
side − Determines which side of the parent widget packs against: TOP (default), BOTTOM, LEFT, or RIGHT.
Try the following example by moving cursor on different buttons −
# !/usr/bin/python3
from tkinter import *

root = Tk()
frame = Frame(root)
frame.pack()

bottomframe = Frame(root)
bottomframe.pack( side = BOTTOM )

redbutton = Button(frame, text = "Red", fg = "red")
redbutton.pack( side = LEFT)

greenbutton = Button(frame, text = "Brown", fg = "brown")
greenbutton.pack( side = LEFT )

bluebutton = Button(frame, text = "Blue", fg = "blue")
bluebutton.pack( side = LEFT )

blackbutton = Button(bottomframe, text = "Black", fg = "black")
blackbutton.pack( side = BOTTOM)

root.mainloop()
When the above code is executed, it produces the following result −

    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
C# program to find IP Address of the client

Firstly find the hostname using the Dns.GetHostName() method in C# −
String hostName = string.Empty;
hostName = Dns.GetHostName();
Console.WriteLine("Hostname: "+hostName);
Now, use the IPHostEntry.AddressList Property to get IP Address −
IPHostEntry myIP = Dns.GetHostEntry(hostName);
IPAddress[] address = myIP.AddressList;
Try the following code to display IP address −
using System;
using System.Net;
class Program {
   static void Main() {
      String hostName = string.Empty;
      hostName = Dns.GetHostName();
      IPHostEntry myIP = Dns.GetHostEntry(hostName);
      IPAddress[] address = myIP.AddressList;
      for (int i = 0; i < address.Length; i++) {
         Console.WriteLine("IP Address {1} : ",address[i].ToString());
      }
      Console.ReadLine();
   }
}
PyQt - QList Widget

QListWidget class is an item-based interface to add or remove items from a list. Each item in the list is a QListWidgetItem object. ListWidget can be set to be multiselectable.
Following are the frequently used methods of QListWidget class −
addItem()
Adds QListWidgetItem object or string in the list
addItems()
Adds each item in the list
insertItem()
Inserts item at the specified index
clear()
Removes contents of the list
setCurrentItem()
Sets currently selected item programmatically
sortItems()
Rearranges items in ascending order
Following are the signals emitted by QListWidget −
currentItemChanged()
Whenever current item changes
itemClicked()
Whenever an item in the list is clicked
The following example shows the click event being captured to pop up a message box.
from PyQt4.QtGui import *
from PyQt4.QtCore import *

import sys

class myListWidget(QListWidget):

   def Clicked(self,item):
      QMessageBox.information(self, "ListWidget", "You clicked: "+item.text())
		
def main():
   app = QApplication(sys.argv)
   listWidget = myListWidget()
	
   #Resize width and height
   listWidget.resize(300,120)
	
   listWidget.addItem("Item 1"); 
   listWidget.addItem("Item 2");
   listWidget.addItem("Item 3");
   listWidget.addItem("Item 4");
	
   listWidget.setWindowTitle('PyQT QListwidget Demo')
   listWidget.itemClicked.connect(listWidget.Clicked)
   
   listWidget.show()
   sys.exit(app.exec_())
	
if __name__ == '__main__':
   main()

    146 Lectures 
     22.5 hours 

 ALAA EID
 Print
 Add Notes
 Bookmark this page
What are getters and setters methods in PHP?

In this article, we learn the best way to create getter and setter strategies in PHP. Getter and setter strategies are utilized when we need to restrict the direct access to the variables by end-users. Getters and setters are methods used to define or retrieve the values of variables, normally private ones.
Just as the name suggests, a getter method is a technique that gets or recovers the value of an object. Also, a setter method is a technique that sets the value of an object.
Let's understand the use of getter and setter methods through an example.
<?php
   class Person{
      private $name;
      public function setName($name){
         $this->name = $name;
      }
      public function getName(){
         return $this->name;
      }
   }
   $person = new Person();
   echo $person->name;
?>
PHP Error Cannot access private property Person::$name
In our Person class above, we have a private property called $name. Because it is private property, we are unable to access them directly like the above and that will produce a fatal error.
To run the code above and get our desired output Let's test this example.
<?php
   class Person{
      private $name;
      public function setName($name){
         $this->name = $name;
      }
      public function getName(){
         return 'welocme'. $this->name;
      }
   }
   $person = new Person();
   $person->setName('Alex');
   $name = $person->getName();
   echo $name;
?>
welcomeAlex
Here to give access to our private properties, we have made a "getter" function called getData, again because the visibility of the properties is set to private, you will likewise unable to change or modify their values. So, you should utilize one of the "setter" functions that we made: setName. After that, we have Instantiated our Person object.
We "set" the namepropertyto"Alex"utilizingoursettertechniquesetData.ThenWeretrievedthevalueofthename property by using our getter function getData.
Java Examples - View classpath?

How to view current classpath?
Following example demonstrates how to view current classpath using echo command.
C:> echo %CLASSPATH%

The above code sample will produce the following result.
.;C:\Program Files\Java\jre1.6.0_03\lib\ext\QTJava.zip

 Print
 Add Notes
 Bookmark this page
How do malloc() and free() work in C/C++?

The function malloc() is used to allocate the requested size of bytes and it returns a pointer to the first byte of allocated memory. It returns null pointer, if it fails.
Here is the syntax of malloc() in C language,
pointer_name = (cast-type*) malloc(size);
Here,
pointer_name  − Any name given to the pointer.
pointer_name  − Any name given to the pointer.
cast-type  − The datatype in which you want to cast the allocated memory by malloc().
cast-type  − The datatype in which you want to cast the allocated memory by malloc().
size  − Size of allocated memory in bytes.
size  − Size of allocated memory in bytes.
Here is an example of malloc() in C language,
 Live Demo
#include <stdio.h>
#include <stdlib.h>

int main() {
   int n = 4, i, *p, s = 0;
   p = (int*) malloc(n * sizeof(int));
   
   if(p == NULL) {
      printf("\nError! memory not allocated.");
      exit(0);
   }
   printf("\nEnter elements of array : ");

   for(i = 0; i < n; ++i) {
      scanf("%d", p + i);
      s += *(p + i);
   }
   printf("\nSum : %d", s);
   return 0;
}
Here is the output
Enter elements of array : 32 23 21 8
Sum : 84
The function free() is used to deallocate the allocated memory by malloc(). It does not change the value of the pointer which means it still points to the same memory location.
Here is the syntax of free() in C language,
void free(void *pointer_name);
Here,
pointer_name − Any name given to the pointer.
pointer_name − Any name given to the pointer.
Here is an example of free() in C language,
 Live Demo
#include <stdio.h>
#include <stdlib.h>

int main() {
   int n = 4, i, *p, s = 0;
   p = (int*) malloc(n * sizeof(int));

   if(p == NULL) {
      printf("\nError! memory not allocated.");
      exit(0);
   }
   printf("\nEnter elements of array : ");

   for(i = 0; i < n; ++i) {
      scanf("%d", p + i);
      s += *(p + i);
   }
   printf("\nSum : %d", s);
   free(p);
   return 0;
}
Here is the output
Enter elements of array : 32 23 21 28
Sum : 104