code-rag-bench/online-tutorials huggingface dataset:
PHP | dechex( ) Function - GeeksforGeeks

09 Mar, 2018
The dechex() is a built-in function in PHP and is used to convert a given decimal number to an equivalent hexadecimal number. The word ‘dechex’ in the name of function stands for decimal to hexadecimal. The dechex() function works only with unsigned numbers. If the argument passed to it is negative then it will treat it as an unsigned number.The largest number that can be converted is 4294967295 in decimal resulting to “ffffffff”.
Syntax:
string dechex($value)
Parameters: This function accepts a single parameter $value. It is the decimal number you want to convert in hexadecimal representation.
Return Value: It returns the hexadecimal string representation of number passed to it as argument.
Examples:
Input : dechex(10)
Output : a

Input : dechex(47)
Output : 2f

Input : dechex(4294967295)
Output : ffffffff

Below programs illustrate dechex() function in PHP:
Passing 10 as a parameter:<?php  echo dechex(10);  ?>    Output:a
<?php  echo dechex(10);  ?>    
Output:
a
Passing 47 as a parameter:<?php  echo dechex(47);  ?>      Output:2f
<?php  echo dechex(47);  ?>      
Output:
2f
When the largest possible decimal number is passed as a parameter:<?php  echo dechex(4294967295);  ?>      Output:ffffffff
<?php  echo dechex(4294967295);  ?>      
Output:
ffffffff
Reference:http://php.net/manual/en/function.dechex.php
PHP-function
PHP-math
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to Upload Image into Database and Display it using PHP ?
How to check whether an array is empty using PHP?
PHP | Converting string to Date and DateTime
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?
Handling with only visible elements in Cypress

After a test case is run on Cypress, we need to debug and understand the logs in
case of a failure. Cypress has the feature to provide information to the user on what
incident took place before and after the failure had happened.
The above screenshots show a full log of the test cases executed with pass/ fail
results. If we investigate more into the step by clicking on it, the element on which
an action has been performed gets highlighted with a red circle. For example the
type command in the screenshot.
On further investigation we found out that we have a failure in the assertion validation. On that step, Cypress provides a before and after feature that describes the event that has happened just before and after the failure step in the form of screenshots highlighting the element where failure took place. Thus debugging a failure step is very easy.
For dealing with only visible elements, Cypress takes the help of jQuery selector. The property used for this purpose is visible.
Code Implementation dealing with only visible element.
// test suite
describe('Tutorialspoint Test', function () {
   // test case
   it('Test Case1', function (){
      // test step to launch a URL
      cy.visit("https://www.tutorialspoint.com/videotutorials/index.php");
      // enter test in the edit box
      cy.get("#search-strings").type("Java");
      // wait for some time
      cy.wait(3000);
      // using jQuery selector to identify only visible elements
      // assertion to validate the number of search results
      cy.get('.clsHeadQuestion:visible'). should('have.length',19);
   });
});
MySQL DROP TABLE Statement

The DROP TABLE statement is used to drop an existing table in a database.
Note: Be careful before dropping a table. Deleting a 
table will result in loss of complete information stored in the table!
The following SQL statement drops the existing table "Shippers":
The TRUNCATE TABLE statement is used to delete the data inside a table, but 
not the table itself.
Write the correct SQL statement to delete a table called Persons.
 Persons;

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.
DFA of a string in which 3rd symbol from RHS is ‘a’ - GeeksforGeeks

06 Sep, 2019
Prerequisite – Finite Automata Introduction, DFA of a string in which 2nd symbol from RHS is ‘a’Problem – Draw deterministic finite automata (DFA) of the language containing the set of all strings over {a, b} in which 3rd symbol from RHS is ‘a’.
The strings in which 3rd last symbol is “a” are:
aaa, aab, aaab, aaaa, aabbaaa, bbbaba etc

The DFA which accept the language of such strings is similar the DFA which accept the regular expression:
L = (a+b)*.a.(a+b).(a+b) 
For example:
Input: babaa
Output: NOT ACCEPTED

Input: aaabb
Output: ACCEPTED 
Constructing the DFA of the given problem directly is very complicated. So, here we are going to design the non-deterministic finite automata (NFA) and then convert it to the deterministic finite automata (DFA).
The NFA of the language containing all the strings in which 3rd symbol from the RHS is “a” is:
Here, A is the initial state and D is the final state.
Now, we are going to construct the state transition table of the above NFA.
After that we will draw the state transition table of DFA using subset configuration on the state transition table of NFA. We will mention all the possible transition for a and b.
Now it’s become very easy to draw the DFA with the help of its transition table. In this DFA, we have eight different states A, AB, AC, AD, ABC, ABD, ACD and ABCD, where AD, ABD, ACD and ABCD are the final states and A is the initial state of the DFA.
This is our required DFA of the language containing the set of all strings over {a, b} in which 3rd symbol from RHS is ‘a’.
KrishnakumarHatele
GATE CS
Theory of Computation & Automata
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Page Replacement Algorithms in Operating Systems
Normal Forms in DBMS
LRU Cache Implementation
Differences between TCP and UDP
Data encryption standard (DES) | Set 1
Difference between DFA and NFA
Introduction of Finite Automata
Regular Expressions, Regular Grammar and Regular Languages
Conversion from NFA to DFA
Pumping Lemma in Theory of Computation
How to create a string from a Java ArrayList?

To convert the contents of an ArrayList to a String, create a StringBuffer object append the contents of the ArrayList to it, finally convert the StringBuffer object to String using the toString() method.
import java.util.ArrayList;

public class String_ArrayList {
   public static void main(String args[]) {
      ArrayList<String> al = new ArrayList<String>();
      al.add("Hello");
      al.add("are");
      al.add("you");
      StringBuffer sb = new StringBuffer();
      
      for (String s : al) {
         sb.append(s);
         sb.append(" ");
      }
      String str = sb.toString();
      System.out.println(str);
   }
}
Hello are you
How to extract paragraph from a website and save it as a text file? - GeeksforGeeks

29 Dec, 2020
Perquisites:  
Beautiful soup
Urllib
Scraping is an essential technique which helps us to retrieve useful data from a URL or a html file that can be used in another manner. The given article shows how to extract paragraph from a URL and save it as a text file.
bs4: Beautiful Soup(bs4) is a Python library used for getting data from HTML and XML files. It can be installed as follows:
pip install bs4
urllib: urllib is a package that collects several modules for working with URLs. It can also be installed the same way, it is most of the in-built in the environment itself.
pip install urllib
Approach:
Create a text file.
Now for the program, import required module and pass URL and **.txt file path. This will make a copy of html code of that URL in your local machine.
Make requests instance and pass into URL
Open file in read mode and pass required parameter(s). 
Pass the requests into a Beautifulsoup() function.
Create another file(or you can also write/append in existing file).
Then we can iterate, and find all the ‘p’ tags, and print each of the paragraph in our text file.
The implementation is given below:
Example:
Python3
import urllib.requestfrom bs4 import BeautifulSoup  # here we have to pass url and path# (where you want to save ur text file)urllib.request.urlretrieve("https://www.geeksforgeeks.org/grep-command-in-unixlinux/?ref=leftbar-rightbar",                           "/home/gpt/PycharmProjects/pythonProject1/test/text_file.txt")  file = open("text_file.txt", "r")contents = file.read()soup = BeautifulSoup(contents, 'html.parser')  f = open("test1.txt", "w")  # traverse paragraphs from soupfor data in soup.find_all("p"):    sum = data.get_text()    f.writelines(sum)  f.close()
Output:
Python BeautifulSoup
Python web-scraping-exercises
Web-scraping
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
Defaultdict in Python
Python Classes and Objects
Create a directory in Python
Python | Pandas dataframe.groupby()
Python | os.path.join() method
Python | Get unique values from a list
MongoDB query to find and return subdocument with criteria?

Let us create a collection with documents −
> db.demo345.insertOne({
...    "UserName" : "Robert",
...       "UserDetails" : [
...          {
...             "isMarried" : false,
...             "CountryName":"US"
...
...          },
...          {
...             "isMarried" : true,
...             "CountryName":"UK"
...
...          },
...          {
...             "isMarried" : false,
...             "CountryName":"AUS"
...
...          }
...       ]
...    }
... )
{
"acknowledged" : true,
"insertedId" : ObjectId("5e5404fdf8647eb59e5620ac")
}
Display all documents from a collection with the help of find() method −
> db.demo345.find();
This will produce the following output −
{
   "_id" : ObjectId("5e5404fdf8647eb59e5620ac"), "UserName" : "Robert", "UserDetails" : [
      { "isMarried" : false, "CountryName" : "US" },
      { "isMarried" : true, "CountryName" : "UK" },
      { "isMarried" : false, "CountryName" : "AUS" }
   ]
}
Following is the query to find and then return subdocument with criteria −
> db.demo345.aggregate([
...    {
...       $match: { UserName: "Robert" }
...    },
...    {
...       $addFields: {
...          UserDetails: {
...             $filter: {
...                input: "$UserDetails",
...                cond: {
...                   $eq: [ "$$this.isMarried", true ]
...                }
...             }
...          }
...       }
...    }
... ])
This will produce the following output −
{
   "_id" : ObjectId("5e5404fdf8647eb59e5620ac"), "UserName" : "Robert", "UserDetails" : [
      { "isMarried" : true, "CountryName" : "UK" }
   ] 
}
Highcharts - Chart with Data Labels

We have already seen the configuration used to draw this chart in Highcharts Configuration Syntax chapter. Now, we will discuss an example of a line chart with data labels.
highcharts_line_labels.htm
<html>
   <head>
      <title>Highcharts Tutorial</title>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
      <script src = "https://code.highcharts.com/highcharts.js"></script>  
   </head>
   
   <body>
      <div id = "container" style = "width: 550px; height: 400px; margin: 0 auto"></div>
      <script language = "JavaScript">
         $(document).ready(function() {   
            var title = {
               text: 'Monthly Average Temperature'   
            };
            var subtitle = {
               text: 'Source: WorldClimate.com'
            };
            var xAxis = {
               categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
                  'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
            };
            var yAxis = {
               title: {
                  text: 'Temperature (\xB0C)'
               }
            };
            var plotOptions = {
               line: {
                  dataLabels: {
                     enabled: true
                  },   
                  enableMouseTracking: false
               }
            };
            var series = [{
                  name: 'Tokyo',
                  data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3,
                     13.9, 9.6]
               }, 
               {
                  name: 'London',
                  data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 
                     6.6, 4.8]
               }
            ];
   
            var json = {};
            json.title = title;
            json.subtitle = subtitle;
            json.xAxis = xAxis;
            json.yAxis = yAxis;  
            json.series = series;
            json.plotOptions = plotOptions;
            $('#container').highcharts(json); 
         });
      </script>
   </body>
   
</html>
Verify the result.
 Print
 Add Notes
 Bookmark this page
Find if a substring exists within a string in Arduino

In order to check if a specific substring exists within a string in Arduino, the indexOf() function can be used. This returns the index of the first occurrence of the character or a string that you are searching for within another string. In case the character or string does not exist within the given string, the function returns -1.
Example implementations are given in the code below −
void setup() {
   Serial.begin(9600);
   Serial.println();
   String s1 = "Hello World";
   Serial.println(s1.indexOf('e'));
   Serial.println(s1.indexOf("Wor"));
   Serial.println(s1.indexOf('z'));
   Serial.println(s1.indexOf("Wer"));
}
void loop() {
   // put your main code here, to run repeatedly:
   
}
The Serial Monitor output is given below −
As you can see, for the first two cases, the index is returned correctly (the counting starts from 0, thus 'H' has index 0, 'e' has index 1 and so on). "Wor" starts from index 6. For the last two cases, the searched character/string are not found in s1, and therefore, -1 is returned.
In case you wish to start the search from an offset, you can provide the second argument to the function, specifying the index from which the search should start.
See the below code −
void setup() {
   Serial.begin(9600);
   Serial.println();
   String s1 = "Hello World";
   Serial.println(s1.indexOf('o'));
   Serial.println(s1.indexOf('o',5));
}
void loop() {
   // put your main code here, to run repeatedly:
   
}
The Serial Monitor output is −
As you can see, at the first step, the location of 'o' in Hello is returned (index 4). Later, when we specified that search should start from index 5, the location of 'o' in World is returned (index 7 of "Hello World").
How to Scroll Down or UP a Page in Selenium Webdriver?

We can scroll down or up a page in Selenium webdriver using JavaScript Executor. Selenium can execute JavaScript commands with the help of the executeScript method.
To scroll down vertically in a page we have to use the JavaScript command window.scrollBy. Then pass the pixel values to be traversed along the x and y axis for horizontal and vertical scroll respectively.
The positive value set for x-axis shall scroll the page to the right while the negative value for x-axis shall scroll it to the left. Similarly, the positive value set for y-axis shall scroll down the page while the negative value for y-axis shall scroll up the page.
JavascriptExecutor j = (JavascriptExecutor)driver;
j.executeScript("window.scrollBy(0,500)");
j.executeScript("window.scrollBy(0,-500)");
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.JavascriptExecutor;
public class ScrollUpDown{
   public static void main(String[] args) {
      System.setProperty("webdriver.gecko.driver",
         "C:\\Users\\ghs6kor\\Desktop\\Java\\geckodriver.exe");
      WebDriver driver = new FirefoxDriver();
      //implicit wait
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      //URL launch
      driver.get("https://www.tutorialspoint.com/index.htm");
      // scroll down by 500 pixels with Javascript Executor
      JavascriptExecutor j = (JavascriptExecutor) driver;
      j.executeScript("window.scrollBy(0,500)");
      // identify element
      WebElement m = driver.findElement(By.linkText("Latest Courses"));
      String s = m.getText();
      System.out.println("Text obtained on scrolling down: "+ s);
      // scroll down up 500 pixels with Javascript Executor
      j.executeScript("window.scrollBy(0,-500)");
      // identify element
      WebElement n = driver.findElement(By.tagName("h4"));
      String r = n.getText();
      System.out.println("Text obtained on scrolling up: "+ r);
      driver.quit();
   }
}
Python - How to write pandas dataframe to a CSV file

To write pandas dataframe to a CSV file in Python, use the to_csv() method. At first, let us create a dictionary of lists −
# dictionary of lists
d = {'Car': ['BMW', 'Lexus', 'Audi', 'Mercedes', 'Jaguar', 'Bentley'],'Date_of_purchase': ['2020-10-10', '2020-10-12', '2020-10-17', '2020-10-16', '2020-10-19', '2020-10-22']
}
Now, create pandas dataframe from the above dictionary of lists −
dataFrame = pd.DataFrame(d)

Our output CSV file will generate on the Desktop since we have set the Desktop path below −
dataFrame.to_csv("C:\\Users\\amit_\\Desktop\\sales1.csv\\SalesRecords.csv")
Following is the code −
import pandas as pd

# dictionary of lists
d = {'Car': ['BMW', 'Lexus', 'Audi', 'Mercedes', 'Jaguar', 'Bentley'],'Date_of_purchase': ['2020-10-10', '2020-10-12', '2020-10-17', '2020-10-16', '2020-10-19', '2020-10-22']
}

# creating dataframe from the above dictionary of lists
dataFrame = pd.DataFrame(d)
print("DataFrame...\n",dataFrame)

# write dataFrame to SalesRecords CSV file
dataFrame.to_csv("C:\\Users\\amit_\\Desktop\\SalesRecords.csv")

# display the contents of the output csv
print("The output csv file written successfully and generated...")
This will produce the following output −
DataFrame...
        Car   Date_of_purchase
0       BMW         2020-10-10
1     Lexus         2020-10-12
2      Audi         2020-10-17
3  Mercedes         2020-10-16
4    Jaguar         2020-10-19
5   Bentley         2020-10-22
The output csv file written successfully and generated...
The resultant “SalesRecords.csv” generated successfully with the following records i.e., pandas dataframe −
C# Program to get the first three elements from a list

Use the Take() method to get the first individual number of elements in C#.
Firstly, set a list and add elements −
List<string> myList = new List<string>();
myList.Add("One");
myList.Add("Two");
myList.Add("Three");
myList.Add("Four");
myList.Add("Five");
myList.Add("Six");
Now, use the Take() method to get the elements from the list. Add the number of the elements you want as an argument −
myList.Take(3)
Here is the code −
 Live Demo
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
   public static void Main() {
      List<string> myList = new List<string>();
      myList.Add("One");
      myList.Add("Two");
      myList.Add("Three");
      myList.Add("Four");
      myList.Add("Five");
      myList.Add("Six");
      // first three elements
      var res = myList.Take(3);
      // displaying the first three elements
      foreach (string str in res) {
         Console.WriteLine(str);
      }
   }
}
One
Two
Three
Angular Material - CheckBoxes

The md-checkbox, an Angular Directive, is used as a checkbox control.
The following table lists down the parameters and description of the different attributes of md-checkbox.
* ng-model
Assignable angular expression to data-bind to.
name
The property name of the form under which the control is published.
ng-true-value
The value to which the expression should be set when selected.
ng-false-value
The value to which the expression should be set when not selected.
ng-change
Angular expression to be executed when input changes due to user interaction with the input element.
md-no-ink
Use of attribute indicates the use of ripple ink effects.
aria-label
Adds label to checkbox for accessibility. Defaults to checkbox's text. If no default text is found, a warning will be logged.
The following example shows the use of the md-checkbox directive and also the use of angular checkboxes.
am_checkboxes.htm
<html lang = "en">
   <head>
      <link rel = "stylesheet"
         href = "https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.css">
      <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
      <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.min.js"></script>
      <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-aria.min.js"></script>
      <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-messages.min.js"></script>
      <script src = "https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js"></script>
      
      <script language = "javascript">
         angular
            .module('firstApplication', ['ngMaterial'])
            .controller('checkBoxController', checkBoxController);

         function checkBoxController ($scope) {            
         }  
      </script>      
   </head>
   
   <body ng-app = "firstApplication">  
      <md-checkbox ng-model = "isChecked" aria-label = "Married">
         Married
      </md-checkbox>
      
      <md-checkbox md-no-ink ng-model = "hasInk" aria-label = "No Ink Effects">
         Single
      </md-checkbox>
      
      <md-checkbox ng-disabled = "true" ng-model = "isDisabled" aria-label = "Disabled">
         Don't know (Disabled)
      </md-checkbox>
   </body>
</html>
Verify the result.

    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
jQuery - Progressbar.js

Progressbar.js is a jQuery plugin for showing progress bar
A Simple of progressbar example as shown below −
<!doctype html>
<html>
   <head>
      <meta charset = "utf-8">
      <meta http-equiv = "X-UA-Compatible" content = "IE = edge,chrome = 1">
      <meta name = "viewport" content = "width = device-width, 
         initial-scale = 1">
	
      <link href = "https://www.jqueryscript.net/css/jquerysctipttop.css" 
         rel = "stylesheet" type = "text/css">
      <link rel = "stylesheet" href = "jQuery-plugin-progressbar.css">
		
      <script src = "https://code.jquery.com/jquery-2.1.4.min.js"></script>
      <script src = "jQuery-plugin-progressbar.js"></script>
   </head>
	
   <body>
      <div class = "progress-bar position"></div>
      <div class = "progress-bar position" data-percent = "40" 
         data-duration = "1000" data-color = "#ccc,yellow"></div>
      <div class = "progress-bar position" data-percent = "90" 
         data-color = "#a456b1,#12b321"></div>
			
      <input type = "submit" value = "reload">
		
      <script>
         $(".progress-bar").loading();
			
         $('input').on('click', function () {
            $(".progress-bar").loading();
         });
      </script>
      
   </body>
</html>
This should produce following result −

    27 Lectures 
     1 hours 

 Mahesh Kumar

    27 Lectures 
     1.5 hours 

 Pratik Singh

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    60 Lectures 
     9 hours 

 Eduonix Learning Solutions

    17 Lectures 
     2 hours 

 Sandip Bhattacharya

    12 Lectures 
     53 mins

 Laurence Svekis
 Print
 Add Notes
 Bookmark this page
Dart Programming - Returning Function

Functions may also return value along with the control, back to the caller. Such functions are called as returning functions.
return_type function_name(){  
   //statements  
   return value;  
}

The return_type can be any valid data type.
The return_type can be any valid data type.
The return statement is optional. I not specified the function returns null;
The return statement is optional. I not specified the function returns null;
The data type of the value returned must match the return type of the function.
The data type of the value returned must match the return type of the function.
A function can return at the most one value. In other words, there can be only one return statement per function.
A function can return at the most one value. In other words, there can be only one return statement per function.
Let’s take an example to understand how returning functions work.
The example declares a function test(). The function’s return type is string.
The example declares a function test(). The function’s return type is string.
The function returns a string value to the caller. This is achieved by the return statement.
The function returns a string value to the caller. This is achieved by the return statement.
The function test() returns a string. This is displayed as output.
The function test() returns a string. This is displayed as output.
void main() { 
   print(test()); 
}  
String test() { 
   // function definition 
   return "hello world"; 
}
It will produce the following output −
hello world 


    44 Lectures 
     4.5 hours 

 Sriyank Siddhartha

    34 Lectures 
     4 hours 

 Sriyank Siddhartha

    69 Lectures 
     4 hours 

 Frahaan Hussain

    117 Lectures 
     10 hours 

 Frahaan Hussain

    22 Lectures 
     1.5 hours 

 Pranjal Srivastava

    34 Lectures 
     3 hours 

 Pranjal Srivastava
 Print
 Add Notes
 Bookmark this page
Filter an object based on an array JavaScript

Let’s say. we have an array and an object like this −
const arr = ['a', 'd', 'f'];
const obj = {
   "a": 5,
   "b": 8,
   "c": 4,
   "d": 1,
   "e": 9,
   "f": 2,
   "g": 7
};
We are required to write a function that takes in the object and the array and filter away all the
object properties that are not an element of the array. So, the output should only contain 3
properties, namely: “a”, “d” and “e”.
Let’s write the code for this function −
const arr = ['a', 'd', 'f'];
const obj = {
   "a": 5,
   "b": 8,
   "c": 4,
   "d": 1,
   "e": 9,
   "f": 2,
   "g": 7
};
const filterObject = (obj, arr) => {
   Object.keys(obj).forEach((key) => {
      if(!arr.includes(key)){
         delete obj[key];
      };
   });
};
filterObject(obj, arr);
console.log(obj);
The output in the console will be −
{ a: 5, d: 1, f: 2 }
What is the use of NCHAR in MySQL?

MySQL defines NCHAR as a way to indicate that a CHAR column should use predefined character set. Utf8 is used by MySQL as its predefined character set.
In the example below, we are creating a table named ‘Student1’. In this table, we are declaring the data types of three columns with three different declaration styles which are rather equivalent of each other. It is all due to NCHAR.
mysql> Create table Student1(Name Char(10) character set utf8, Address NATIONAL CHARACTER(10), FatherName NCHAR(10));
   Query OK, 0 rows affected (0.25 sec)
Now on checking the status of table, with the help of query below, we can see that all the declaration styles are same.
mysql> show create table Student1\G

*************************** 1. row ***************************
Table: Student1
Create Table: CREATE TABLE `student1` (
    `Name` char(10) CHARACTER SET utf8 DEFAULT NULL,
    `Address` char(10) CHARACTER SET utf8 DEFAULT NULL,
    `FatherName` char(10) CHARACTER SET utf8 DEFAULT NULL
    ) ENGINE = InnoDB DEFAULT CHARSET = latin1

1 row in set (0.00 sec)
AVRO - Deserialization By Generating Class

As described earlier, one can read an Avro schema into a program either by generating a class corresponding to the schema or by using the parsers library. This chapter describes how to read the schema by generating a class and Deserialize the data using Avro.
The serialized data is stored in the file emp.avro. You can deserialize and read it using Avro.
Follow the procedure given below to deserialize the serialized data from a file.
Create an object of DatumReader interface using SpecificDatumReader class.
DatumReader<emp>empDatumReader = new SpecificDatumReader<emp>(emp.class);

Instantiate DataFileReader for emp class. This class reads serialized data from a file. It requires the Dataumeader object, and path of the file where the serialized data is existing, as a parameters to the constructor.
DataFileReader<emp> dataFileReader = new DataFileReader(new File("/path/to/emp.avro"), empDatumReader);

Print the deserialized data, using the methods of DataFileReader.
The hasNext() method will return a boolean if there are any elements in the Reader.
The hasNext() method will return a boolean if there are any elements in the Reader.
The next() method of DataFileReader returns the data in the Reader.
The next() method of DataFileReader returns the data in the Reader.
while(dataFileReader.hasNext()){

   em=dataFileReader.next(em);
   System.out.println(em);
}
The following complete program shows how to deserialize the data in a file using Avro.
import java.io.File;
import java.io.IOException;

import org.apache.avro.file.DataFileReader;
import org.apache.avro.io.DatumReader;
import org.apache.avro.specific.SpecificDatumReader;

public class Deserialize {
   public static void main(String args[]) throws IOException{
	
      //DeSerializing the objects
      DatumReader<emp> empDatumReader = new SpecificDatumReader<emp>(emp.class);
		
      //Instantiating DataFileReader
      DataFileReader<emp> dataFileReader = new DataFileReader<emp>(new
         File("/home/Hadoop/Avro_Work/with_code_genfile/emp.avro"), empDatumReader);
      emp em=null;
		
      while(dataFileReader.hasNext()){
      
         em=dataFileReader.next(em);
         System.out.println(em);
      }
   }
}
Browse into the directory where the generated code is placed. In this case, at home/Hadoop/Avro_work/with_code_gen.
$ cd home/Hadoop/Avro_work/with_code_gen/

Now, copy and save the above program in the file named DeSerialize.java. Compile and execute it as shown below −
$ javac Deserialize.java
$ java Deserialize

{"name": "omar", "id": 1, "salary": 30000, "age": 21, "address": "Hyderabad"}
{"name": "ram", "id": 2, "salary": 40000, "age": 30, "address": "Hyderabad"}
{"name": "robbin", "id": 3, "salary": 35000, "age": 25, "address": "Hyderabad"}

 Print
 Add Notes
 Bookmark this page
Program to find Circumcenter of a Triangle in C++

In this tutorial, we will be discussing a program to find the circumcenter of a triangle.
For this we will be provided with three noncollinear points. Our task is to find the circumcenter of the triangle formed by those points.
 Live Demo
#include <iostream>
#include <cfloat>
using namespace std;
//storing X and Y values
#define pdd pair<double, double>
void lineFromPoints(pdd P, pdd Q, double &a, double &b, double &c){
   a = Q.second - P.second;
   b = P.first - Q.first;
   c = a*(P.first)+ b*(P.second);
}
void perpendicularBisectorFromLine(pdd P, pdd Q, double &a, double &b, double &c){
   pdd mid_point = make_pair((P.first + Q.first)/2, (P.second + Q.second)/2);
   c = -b*(mid_point.first) + a*(mid_point.second);
   double temp = a;
   a = -b;
   b = temp;
}
pdd lineLineIntersection(double a1, double b1, double c1, double a2, double b2, double c2){
   double determinant = a1*b2 - a2*b1;
   if (determinant == 0){
      return make_pair(FLT_MAX, FLT_MAX);
   } else {
      double x = (b2*c1 - b1*c2)/determinant;
      double y = (a1*c2 - a2*c1)/determinant;
      return make_pair(x, y);
   }
}
void findCircumCenter(pdd P, pdd Q, pdd R){
   double a, b, c;
   lineFromPoints(P, Q, a, b, c);
   double e, f, g;
   lineFromPoints(Q, R, e, f, g);
   perpendicularBisectorFromLine(P, Q, a, b, c);
   perpendicularBisectorFromLine(Q, R, e, f, g);
   pdd circumcenter = lineLineIntersection(a, b, c, e, f, g);
   if (circumcenter.first == FLT_MAX && circumcenter.second == FLT_MAX){
      cout << "The two perpendicular bisectors "
         "found come parallel" << endl;
      cout << "Thus, the given points do not form "
         "a triangle and are collinear" << endl;
   } else {
      cout << "The circumcenter of the triangle PQR is: ";
      cout << "(" << circumcenter.first << ", "
         << circumcenter.second << ")" << endl;
   }
}
int main(){
   pdd P = make_pair(6, 0);
   pdd Q = make_pair(0, 0);
   pdd R = make_pair(0, 8);
   findCircumCenter(P, Q, R);
   return 0;
}
The circumcenter of the triangle PQR is: (3, 4)
How to match two strings that are present in one line with grep in Linux?

In order to be able to grep two strings that exists on the same line in Linux command line, we must first understand what a grep command is and how to use it on Linux.
The grep command in Linux is used to filter searches in a file for a particular pattern of characters. It is one of the most used Linux utility commands to display the lines that contain the pattern that we are trying to search.
Normally, the pattern that we are trying to search in the file is referred to as the regular expression.
grep [options] pattern [files]
While there are plenty of different options available to us, some of the most used are −
-c : It lists only a count of the lines that match a pattern
-h : displays the matched lines only.
-i : Ignores, case for matching
-l : prints filenames only
-n : Display the matched lines and their line numbers.
-v : It prints out all the lines that do not match the pattern
Now, let’s consider a case where we want to find a particular pattern in all the files in a particular directory, say dir1.
grep -rni "word" *
In the above command replace the “word” placeholder with
For that we make use of the command shown below −
grep -rni "func main()" *
The above command will try to find a string “func main()” in all the files in a particular directory and also in the subdirectories as well.
main.go:120:func main() {}

In case we only want to find a particular pattern in a single directory and not the subdirectories then we need to use the command shown below −
grep -s "func main()" *
In the above command we made use of the -s flag which will help us to not get a warning for each subdirectory that is present inside the directory where we are running the command.
main.go:120:func main() {}
Now, consider that I have a .txt file and the content of the file looks something like this.
immukul@192 d2 % cat 2.txt
orange apple is great together

apple not great

is apple good

orange good apple not
Now I want to use the grep command for all the lines that contain both the words grep 'orange' 2.txt | grep 'apple'‘apple’ and ‘orange’.
grep 'orange' 2.txt | grep 'apple'
immukul@192 d2 % grep 'orange' 2.txt | grep 'apple'

orange apple is great together
orange good apple not
How to dynamically allocate a 2D array in C?

A 2D array can be dynamically allocated in C using a single pointer. This means that a memory block of size row*column*dataTypeSize is allocated using malloc and pointer arithmetic can be used to access the matrix elements.
A program that demonstrates this is given as follows.
 Live Demo
#include <stdio.h>
#include <stdlib.h> 
int main() {
   int row = 2, col = 3;
   int *arr = (int *)malloc(row * col * sizeof(int)); 
   int i, j;
   for (i = 0; i < row; i++)
      for (j = 0; j < col; j++)
         *(arr + i*col + j) = i + j;    
   printf("The matrix elements are:\n");
   for (i = 0; i < row; i++) {
      for (j = 0; j < col; j++) {
         printf("%d ", *(arr + i*col + j)); 
      }
      printf("\n");
   }
   free(arr); 
   return 0;
}
The output of the above program is as follows.
The matrix elements are:
0 1 2 
1 2 3

Now let us understand the above program.
The 2-D array arr is dynamically allocated using malloc. Then the 2-D array is initialized using a nested for loop and pointer arithmetic. The code snippet that shows this is as follows.
int row = 2, col = 3; 
int *arr = (int *)malloc(row * col * sizeof(int));
int i, j;
for (i = 0; i < row; i++)
   for (j = 0; j < col; j++)
      *(arr + i*col + j) = i + j; 
Then the values of the 2-D array are displayed. Finally the dynamically allocated memory is freed using free. The code snippet that shows this is as follows.
printf("The matrix elements are:\n");
for (i = 0; i < row; i++) {
   for (j = 0; j < col; j++) {
      printf("%d ", *(arr + i*col + j)); 
   }
   printf("\n");
}
free(arr);
Nested Classes in Java

Writing a class within another is allowed in Java. The class written within is called the nested class, and the class that holds the inner class is called the outer class. Nested classes are divided into two types −
Non-static nested classes (Inner Classes) − These are the non-static members of a class.
Non-static nested classes (Inner Classes) − These are the non-static members of a class.
Static nested classes − These are the static members of a class.
Static nested classes − These are the static members of a class.
Following are the types of Nested classes in Java −
Inner classes are a security mechanism in Java. We know a class cannot be associated with the access modifier private, but if we have the class as a member of other class, then the inner class can be made private. And this is also used to access the private members of a class.
Let us see an example −
class Outer_Demo {
   int num;
   // inner class
   private class Inner_Demo {
      public void print() {
         System.out.println("This is an inner class");
      }
   }
   // Accessing he inner class from the method within
   void display_Inner() {
      Inner_Demo inner = new Inner_Demo();
      inner.print();
   }
}
public class My_class {
   public static void main(String args[]) {
      // Instantiating the outer class
      Outer_Demo outer = new Outer_Demo();
      // Accessing the display_Inner() method.
      outer.display_Inner();
   }
}
This is an inner class.
A static inner class is a nested class which is a static member of the outer class. It can be accessed without instantiating the outer class, using other static members. Just like static members, a static nested class does not have access to the instance variables and methods of the outer class.
Let us see an example −
public class Outer {
   static class Nested_Demo {
      public void my_method() {
         System.out.println("This is my nested class");
      }
   }
   public static void main(String args[]) {
      Outer.Nested_Demo nested = new Outer.Nested_Demo();
      nested.my_method();
   }
}
This is my nested class
How can we read inputs as integers in Python?

Python 3.x has an in-built input() function to accept user input. This input() function returns a string data and it can be stored in string variable.
It must be converted to integer using built-in function int()
>>> var=int(input("enter age"))
enter age21
>>> var
21
>>> type(var)
 <class 'int'>
Here, if user input contains digits only, int() function parses integer otherwise a ValueError is encountered.
In Python 2.x, input() function evaluates the input and accordingly appropriate data type is returned.
What are lambda expressions in C#?

A lambda expression in C# describes a pattern. It has the token => in an expression context. This is read as “goes to” operator and used when a lambda expression is declared.
The following is an example showing how to use lambda expressions in C# −
 Live Demo
using System;
using System.Collections.Generic;

class Demo {
   static void Main() {
      List<int> list = new List<int>() { 21, 17, 40, 11, 9 };
      int res = list.FindIndex(x => x % 2 == 0);
      Console.WriteLine("Index: "+res);
   }
}
Index: 2
Above, we saw the usage of “goes to” operator to find the index of the even number −
list.FindIndex(x => x % 2 == 0);
The above example gives the following output.
Index: 2
Even number is at index 2 i.e. it is the 3rd element.
Python PIL Attributes | Image.height method - GeeksforGeeks

27 Sep, 2019
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The Image module provides a class with the same name which is used to represent a PIL image. The module also provides a number of factory functions, including functions to load images from files, and to create new images.
The Image class have the height attributes.
Image.height Image height, in pixels. Attribute defines the various property of an object, element or file.
Syntax: PIL.Image.height
Parameters:image– image used of different extension.
Returns: height of the image
Image Used:
     # importing Image module from PIL package from PIL import Image   # opening a  image im = Image.open(r"C:\Users\System-Pc\Desktop\flower1.jpg")   # height attributeim1 = im.heightprint(im1)
Output:
225

Another Example: take another image with .png extension.
Image Used:
     # importing Image module from PIL package from PIL import Image   # opening a  image im = Image.open(r"C:\Users\System-Pc\Desktop\python.png")   # height attributeim1 = im.heightprint(im1)
Output:
149

nidhi_biet
Python-pil
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
Python OOPs Concepts
Python | Get unique values from a list
Check if element exists in list in Python
Python Classes and Objects
Python | os.path.join() method
How To Convert Python Dictionary To JSON?
Python | Pandas dataframe.groupby()
Create a directory in Python
C++ Stack Library - pop() Function

The C++ function std::stack::pop() removes top element from the stack and reduces size of stack by one. This function calls destructor on removed element.
Following is the declaration for std::stack::pop() function form std::stack header.
void pop();

None
None
Depends upon underlying container.
Constant i.e. O(1)
The following example shows the usage of std::stack::pop() function.
#include <iostream>
#include <stack>

using namespace std;

int main(void) {
   stack<int> s;

   for (int i = 0; i < 5; ++i)
      s.emplace(i + 1);

   while (!s.empty()) {
      cout << s.top() << endl;
      s.pop();
   }

   return 0;
}
Let us compile and run the above program, this will produce the following result −
Stack contents are
5
4
3
2
1

 Print
 Add Notes
 Bookmark this page
JavaScript isNaN() Function - GeeksforGeeks

02 Dec, 2021
The isNaN() function is used to check whether a given value is an illegal number or not. It returns true if value is a NaN else returns false. It is different from the Number.isNaN() Method.
Syntax:
isNaN( value )
Parameter Values: This method accepts single parameter as mentioned above and described below:  
value: It is a required value passed in the isNaN() function.
Return Value: It returns a Boolean value i.e. returns true if the value is NaN else returns false.
Javascript
<script>    document.write(isNaN(12) + "<br>");    document.write(isNaN(0 / 0) + "<br>");    document.write(isNaN(12.3) + "<br>");    document.write(isNaN("Geeks") + "<br>");    document.write(isNaN("13/12/2020") + "<br>");    document.write(isNaN(-46) + "<br>");    document.write(isNaN(NaN) + "<br>");</script>
Output:
false
true
false
true
true
false
true
Supported Browsers:
Chrome 1 and above
Firefox 1 and above
Edge 12 and above
Opera 3 and above
Safari 1 and above
ysachin2314
javascript-functions
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 detect browser or tab closing in JavaScript ?
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
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 remove items from a list in C#?

Firstly, set a list and add elements.
List<string> myList = new List<string>();
myList.Add("Jennings");
myList.Add("James");
myList.Add("Chris");
Let’s say you need to delete the element “James” now. For that, use the Remove() method.
myList.Remove("James");
Here is the complete code.
 Live Demo
using System.Collections.Generic;
using System;
class Program {
   static void Main() {
      List<string> myList = new List<string>();
      myList.Add("Jennings");
      myList.Add("James");
      myList.Add("Chris");
      Console.WriteLine("Initial List...");

      foreach(string str in myList) {
         Console.WriteLine(str);
      }
      myList.Remove("James");
      Console.WriteLine("New List...");

      foreach(string str in myList) {
         Console.WriteLine(str);
      }
   }
}
Initial List...
Jennings
James
Chris
New List...
Jennings
Chris
Dequeue and Priority Queue in C++

As we know that the queue data structure is First in First Out data structure. The queue has some variations also. These are the Dequeue and the Priority Queue.
The Dequeue is basically double ended queue. So there are two front and two rear pairs. One pair of front and rear pointer is used to describe the queue from left side, and another one is used to describe it from the right side. We can insert or delete elements from both side in this structure. Here we will see some C++ code using dequeue STL to understand its functionality.
 Live Demo
#include <iostream>
#include <deque>
using namespace std;
void dequeElements(deque <int> que) {
   deque <int> :: iterator it;
   for (it = que.begin(); it != que.end(); ++it)
      cout << *it << " ";
   cout <<endl;
}
int main() {
   deque <int> que;
   que.push_back(10);
   que.push_front(20);
   que.push_back(30);
   que.push_front(15);
   cout << "Currently que is holding : ";
   dequeElements(que);
   cout <<"Size of dequeue : " <<que.size() << endl;
   cout << "Element at position 2 : " << que.at(2) << endl;
   cout << "Element at front position : " << que.front() << endl;
   cout << "Element at back position : " << que.back() << endl;
   cout << "Delete from front side : ";
   que.pop_front();
   dequeElements(que);
   cout << "Delete from back side : ";
   que.pop_back();
   dequeElements(que);
}
Currently que is holding : 15 20 10 30
Size of dequeue : 4
Element at position 2 : 10
Element at front position : 15
Element at back position : 30
Delete from front side : 20 10 30
Delete from back side : 20 10
Another variation of queue is the priority queue. In this structure, each element in the queue has its own priority. When we insert item into queue, we have to assign priority value with it. It will delete the highest priority element at first. To implement priority queue one of the easiest method is using the heap data structure.
Let us see one C++ code for priority queue STL. Here the priority is assigned based on the value. So higher value will be treated as highest priority element.
 Live Demo
#include <iostream>
#include <queue>
using namespace std;
void dequeElements(priority_queue <int> que) {
   priority_queue <int> q = que;
   while(!q.empty()){
      cout << q.top() << " ";
      q.pop();
   }
   cout << endl;
}
int main() {
   priority_queue <int> que;
   que.push(10);
   que.push(20);
   que.push(30);
   que.push(5);
   que.push(1);
   cout << "Currently que is holding : ";
   dequeElements(que);
   cout << "Size of queue : " <<que.size() << endl;
   cout << "Element at top position : " << que.top() << endl;
   cout << "Delete from queue : ";
   que.pop();
   dequeElements(que);
   cout << "Delete from queue : ";
   que.pop();
   dequeElements(que);
}
Currently que is holding : 30 20 10 5 1
Size of queue : 5
Element at top position : 30
Delete from queue : 20 10 5 1
Delete from queue : 10 5 1