code-rag-bench/online-tutorials huggingface dataset:
Search for a string within text column in MySQL?

You can search for a string within text column in MySQL with the help of LIKE clause. The syntax is as follows −
select *from yourTableName where yourColumnName like '%anyStringValue%';
To use the above syntax, let us first create a table −
mysql> create table SearchTextDemo
   −> (
   −> BookName TEXT
   −> );
Query OK, 0 rows affected (0.55 sec)
Insert some strings in the table. The query is as follows −
mysql> insert into SearchTextDemo values('Let us C');
Query OK, 1 row affected (0.28 sec)

mysql> insert into SearchTextDemo values('C in Depth');
Query OK, 1 row affected (0.14 sec)

mysql> insert into SearchTextDemo values('C in Depth with Data Structure');
Query OK, 1 row affected (0.18 sec)

mysql> insert into SearchTextDemo values('Introduction to Java');
Query OK, 1 row affected (0.17 sec)

mysql> insert into SearchTextDemo values('Java in Depth');
Query OK, 1 row affected (0.13 sec)
Display all records with the help of select statement. The query is as follows −
mysql> select *from SearchTextDemo;
The following is the output −
+--------------------------------+
| BookName                       |
+--------------------------------+
| Let us C                       |
| C in Depth                     |
| C in Depth with Data Structure |
| Introduction to Java           |
| Java in Depth                  |
+--------------------------------+
5 rows in set (0.00 sec)
Here is the query to search a specific string within text column −
mysql> select *from SearchTextDemo where BookName like '%in Depth%';
The following is the output −
+--------------------------------+
| BookName                       |
+--------------------------------+
| C in Depth                     |
| C in Depth with Data Structure |
| Java in Depth                  |
+--------------------------------+
3 rows in set (0.00 sec)
Look at the above sample output, the string ‘in Depth’ has been searched from column name ‘BookName’ with data type TEXT.
How to use resource bundle in JSP?

The <fmt:bundle> tag will make the specified bundle available to all <fmt:message> tags that occur between the bounding <fmt:bundle> and </fmt:bundle> tags. With this, you need not specify the resource bundle for each of your <fmt:message> tags.
For example, the following two <fmt:bundle> blocks will produce the same output −
<fmt:bundle basename = "com.tutorialspoint.Example">
   <fmt:message key = "count.one"/>
</fmt:bundle>
<fmt:bundle basename = "com.tutorialspoint.Example" prefix = "count.">
   <fmt:message key = "title"/>
</fmt:bundle>
The <fmt:bundle> tag has the following attributes −
Resource bundles contain locale-specific objects. Resource bundles contain key/value pairs. When your program needs a locale-specific resource, you keep all the keys common to all the locale but you can have translated values specific to locale. Resource bundles help in providing specific content to locale.
A Java resource bundle file contains a series of key-to-string mappings. The method that we focus on involves creating compiled Java classes that extend the java.util.ListResourceBundle class. You must compile these class files and make them available to the classpath of your Web application.
Let us define a default resource bundle as follows −
package com.tutorialspoint;
import java.util.ListResourceBundle;
public class Example_En extends ListResourceBundle {
   public Object[][] getContents() {
      return contents;
   }
   static final Object[][] contents = {
      {"count.one", "One"},
      {"count.two", "Two"},
      {"count.three", "Three"},
   };
}
Let us compile the above class Example.class and make it available in the CLASSPATH of your Web application. Now you can use the following JSTL tags to display the three numbers as follows −
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<%@ taglib uri = "http://java.sun.com/jsp/jstl/fmt" prefix = "fmt" %>
<html>
   <head>
      <title>JSTL fmt:bundle Tag</title>
   </head>
   <body>
      <fmt:bundle basename = "com.tutorialspoint.Example" prefix = "count.">
         <fmt:message key = "one"/><br/>
         <fmt:message key = "two"/><br/>
         <fmt:message key = "three"/><br/>
      </fmt:bundle>
   </body>
</html>
The above code will generate the following result −
One
Two
Three
Try the above example without prefix as follows −
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<%@ taglib uri = "http://java.sun.com/jsp/jstl/fmt" prefix = "fmt" %>
<html>
   <head>
      <title>JSTL fmt:bundle Tag</title>
   </head>
   <body>
      <fmt:bundle basename = "com.tutorialspoint.Example">
         <fmt:message key = "count.one"/><br/>
         <fmt:message key = "count.two"/><br/>
         <fmt:message key = "count.three"/><br/>
      </fmt:bundle>
   </body>
</html>
The above code will generate the following result −
One
Two
Three
JavaScript String - toUpperCase() Method

This method returns the calling string value converted to uppercase.
Its syntax is as follows −
string.toUpperCase( )

Returns a string representing the specified object.
Try the following example.
<html>
   <head>
      <title>JavaScript String toUpperCase() Method</title>
   </head>
   
   <body>  
      <script type = "text/javascript">
         var str = "Apples are round, and Apples are Juicy.";
         document.write(str.toUpperCase( ));
      </script>      
   </body>
</html>
APPLES ARE ROUND, AND APPLES ARE JUICY.


    25 Lectures 
     2.5 hours 

 Anadi Sharma

    74 Lectures 
     10 hours 

 Lets Kode It

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    70 Lectures 
     4.5 hours 

 Frahaan Hussain

    46 Lectures 
     6 hours 

 Eduonix Learning Solutions

    88 Lectures 
     14 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
How to deal with warning “removed n rows containing missing values” while using ggplot2 in R?

The warning “removed n rows containing missing values” occurs when we incorrectly specify the range of the values for X-axis or Y-axis. We can this range in ggplot function using scale_x_continuous(limits=c(?,?)) for x axis and scale_y_continuous(limits=c(?,?)) for y axis. If the range will be larger than the actual data range then there will be no warning otherwise, we will get the warning for the number of missing values.
Consider the below data frame −
> set.seed(2)
> x<-rnorm(20,0.5)
> y<-rpois(20,2)
> df<-data.frame(x,y)
Loading ggplot2 package −
> library(ggplot2)
Creating the plot with Y-axis limits from 0 to 5−
> ggplot(df,aes(x,y))+
+ geom_point()+
+ scale_y_continuous(limits=c(0,5))
Warning message:
Removed 1 rows containing missing values (geom_point).
Here, we got a warning for 1 row with missing value. Now let’s create a plot with increasing one value for Y-axis −
> ggplot(df,aes(x,y))+
+ geom_point()+
+ scale_y_continuous(limits=c(0,6))
Here, we can see that 6 is added on the Y-axis and there are no warnings. We can also increase the limit depending on our need as shown below −
> ggplot(df,aes(x,y))+
+ geom_point()+
+ scale_y_continuous(limits=c(0,7))
Callback using Interfaces in Java


In the case of Event-driven programming, we pass a reference to a function which will get called when an event occurs. This mechanism is termed as a callback. Java does not support function pointers. So we can not implement the same direction. But using interfaces we can achieve the same very easily.
In the example below, we've made a callback when a button is clicked. See the steps −
Create an interface ClickEventHandler with a single method handleClick().
Create an interface ClickEventHandler with a single method handleClick().
Create a ClickHandler class which implements this interface ClickEventHandler.
Create a ClickHandler class which implements this interface ClickEventHandler.
Create a Button class which will call ClickHandler when it's click method is called.
Create a Button class which will call ClickHandler when it's click method is called.
Test the application.
Test the application.
Live Demo
//Step 1: Create an interface for the callback method
interface ClickEventHandler {
   public void handleClick();
}

//Step 2: Create a callback handler
//implementing the above interface
class ClickHandler implements ClickEventHandler {
   public void handleClick() {
      System.out.println("Clicked");
   }
}

//Step 3: Create event generator class
class Button {
   public void onClick(ClickEventHandler clickHandler) {
      clickHandler.handleClick();
   }
}

public class Tester {
   public static void main(String[] args) {
      Button button = new Button();
      ClickHandler clickHandler = new ClickHandler();
      //pass the clickHandler to do the default operation
      button.onClick(clickHandler);

      Button button1 = new Button();
      //pass the interface to implement own operation
      button1.onClick(new ClickEventHandler() {
         @Override
         public void handleClick() {
            System.out.println("Button Clicked");
         }
      });
   }
}
Clicked Button
Clicked
ML | Handle Missing Data with Simple Imputer

28 Sep, 2021
SimpleImputer is a scikit-learn class which is helpful in handling the missing data in the predictive model dataset. It replaces the NaN values with a specified placeholder. It is implemented by the use of the SimpleImputer() method which takes the following arguments : 
missing_values : The missing_values placeholder which has to be imputed. By default is NaN strategy : The data which will replace the NaN values from the dataset. The strategy argument can take the values – ‘mean'(default), ‘median’, ‘most_frequent’ and ‘constant’. fill_value : The constant value to be given to the NaN data using the constant strategy.  
Code: Python code illustrating the use of SimpleImputer class. 
Python3
import numpy as np # Importing the SimpleImputer classfrom sklearn.impute import SimpleImputer # Imputer object using the mean strategy and# missing_values type for imputationimputer = SimpleImputer(missing_values = np.nan,                        strategy ='mean') data = [[12, np.nan, 34], [10, 32, np.nan],        [np.nan, 11, 20]] print("Original Data : \n", data)# Fitting the data to the imputer objectimputer = imputer.fit(data) # Imputing the data    data = imputer.transform(data) print("Imputed Data : \n", data)
Output  
Original Data : 

[[12, nan, 34]
[10, 32, nan]
[nan, 11, 20]]


Imputed Data : 

[[12, 21.5, 34]
[10, 32, 27]
[11, 11, 20]]
Remember: The mean or median is taken along the column of the matrix 
shruti_sharma
simmytarika5
Machine Learning
Python
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Introduction to Recurrent Neural Network
ML | Monte Carlo Tree Search (MCTS)
Support Vector Machine Algorithm
Markov Decision Process
DBSCAN Clustering in ML | Density based clustering
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
How to measure time taken by a function in C?

Here we will see how to calculate the time taken by the process. For this problem, we will use the clock() function. The clock() is present in the time.h header file.
To get the elapsed time, we can get the time using clock() at the beginning, and at the end of the tasks, then subtract the values to get the differences. After that, we will divide the difference by CLOCK_PER_SEC (Number of clock ticks per second) to get the processor time.
#include <stdio.h>
#include <time.h>
void take_enter() {
   printf("Press enter to stop the counter \n");
   while(1) {
      if (getchar())
      break;
   }
}
main() {
   // Calculate the time taken by take_enter()
   clock_t t;
   t = clock();
   printf("Timer starts\n");
   take_enter();
   printf("Timer ends \n");
   t = clock() - t;
   double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
   printf("The program took %f seconds to execute", time_taken);
}
Timer starts
Press enter to stop the counter
Timer ends
The program took 5.218000 seconds to execute
Moment.js isBetween() Function

24 Jul, 2020
It is used to check whether a date is between a range in Moment.js using the isBetween() function that checks if a moment is between two other moments, optionally looking at unit scale (minutes, hours, days, etc).
Syntax:
moment().isBetween(moment-like, moment-like);
moment().isBetween(moment-like, moment-like, String);
moment().isBetween(moment-like, moment-like, String, String);

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

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

node index.js
Output:
true
false

Example 2:Filename: index.js
// Requiring moduleconst moment = require('moment');  function checkBetween(date1, date2, date3) {   return moment(date1).isBetween(date2, date3);}  var bool = checkBetween('2019-10-20',     '2010-10-25', '2011-10-19'); // falseconsole.log(bool);
Run index.js file using below command:
node index.js
Output:
false

Reference: https://momentjs.com/docs/#/query/is-between/
Moment.js
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Sorting rows in pandas DataFrame

06 Jan, 2019
Pandas DataFrame is two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). We often need to do certain operations on both rows and column while handling the data.
Let’s see how to sort rows in pandas DataFrame.
Code #1: Sorting rows by Science
# import modulesimport pandas as pd  # create dataframedata = {'name': ['Simon', 'Marsh', 'Gaurav', 'Alex', 'Selena'],         'Maths': [8, 5, 6, 9, 7],         'Science': [7, 9, 5, 4, 7],        'English': [7, 4, 7, 6, 8]}  df = pd.DataFrame(data)  # Sort the dataframe’s rows by Science,# in descending ordera = df.sort_values(by ='Science', ascending = 0)print("Sorting rows by Science:\n \n", a)
Sorting rows by Science:
 
    English  Maths  Science    name
1        4      5        9   Marsh
0        7      8        7   Simon
4        8      7        7  Selena
2        7      6        5  Gaurav
3        6      9        4    Alex

 Code #2: Sort rows by Maths and then by English.
# import modulesimport pandas as pd  # create dataframedata = {'name': ['Simon', 'Marsh', 'Gaurav', 'Alex', 'Selena'],         'Maths': [8, 5, 6, 9, 7],         'Science': [7, 9, 5, 4, 7],        'English': [7, 4, 7, 6, 8]}  df = pd.DataFrame(data)  # Sort the dataframe’s rows by Maths# and then by English, in ascending orderb = df.sort_values(by =['Maths', 'English'])print("Sort rows by Maths and then by English: \n\n", b)
Sort rows by Maths and then by English: 

    English  Maths  Science    name
1        4      5        9   Marsh
2        7      6        5  Gaurav
4        8      7        7  Selena
0        7      8        7   Simon
3        6      9        4    Alex

 
Code #3: If you want missing values first.
import pandas as pd  # create dataframedata = {'name': ['Simon', 'Marsh', 'Gaurav', 'Alex', 'Selena'],         'Maths': [8, 5, 6, 9, 7],         'Science': [7, 9, 5, 4, 7],        'English': [7, 4, 7, 6, 8]}df = pd.DataFrame(data)    a = df.sort_values(by ='Science', na_position ='first' )print(a)
English  Maths  Science    name
3        6      9        4    Alex
2        7      6        5  Gaurav
0        7      8        7   Simon
4        8      7        7  Selena
1        4      5        9   Marsh

As there are no missing values in this example this will produce same output as the above one, but sorted in ascending order.
pandas-dataframe-program
Picked
Python pandas-dataFrame
Python-pandas
Technical Scripter 2018
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Create a directory in Python
Stack.Clone() Method in C#

05 Feb, 2019
This method is used to create a shallow copy of the Stack. It just creates a copy of the Stack. The copy will have a reference to a clone of the internal data array but not a reference to the original internal data array.
Syntax: public virtual object Clone ();
Return Value: The method returns an Object which is just the shallow copy of the Stack.
Example 1: Let’s see an example without using a Clone() method and directly copying a Stack using assignment operator ‘=’. In the below code, we can see even if we Pop() elements from myStack2, contents of myStack is also changed. This is because ‘=’ just assigns the reference of myStack to myStack2 and does not create any new Stack. But Clone() creates a new Stack.
// C# program to Copy a Stack using // the assignment operatorusing System;using System.Collections;  class GFG {      // Main Method    public static void Main(string[] args)    {          Stack myStack = new Stack();        myStack.Push("C");        myStack.Push("C++");        myStack.Push("Java");        myStack.Push("C#");          // Creating a copy using the        // assignment operator.        Stack myStack2 = myStack;           // Removing top most element        myStack2.Pop();         PrintValues(myStack);    }      public static void PrintValues(IEnumerable myCollection)    {        // This method prints all        // the elements in the Stack.        foreach(Object obj in myCollection)            Console.WriteLine(obj);    }}
Java
C++
C

Example 2:
// C# program to illustrate the use // of Stack.Clone() Method using System;using System.Collections;  class MainClass {      // Main Method    public static void Main(string[] args)    {          Stack myStack = new Stack();        myStack.Push("1st Element");        myStack.Push("2nd Element");        myStack.Push("3rd Element");        myStack.Push("4th Element");          // Creating copy using Clone() method        Stack myStack3 = (Stack)myStack.Clone();               // Removing top most element        myStack3.Pop();         PrintValues(myStack);    }      public static void PrintValues(IEnumerable myCollection)    {        // This method prints all the        // elements in the Stack.        foreach(Object obj in myCollection)            Console.WriteLine(obj);    }}
4th Element
3rd Element
2nd Element
1st Element

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.stack.clone?view=netframework-4.7.2#System_Collections_Stack_Clone
CSharp-Collections-Namespace
CSharp-Collections-Stack
Picked
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between Abstract Class and Interface in C#
C# | Delegates
C# | Abstract Classes
Introduction to .NET Framework
String.Split() Method in C# with Examples
C# | Method Overriding
C# | How to check whether a List contains a specified element
C# | Constructors
C# Dictionary with examples
C# | .NET Framework (Basic Architecture and Component Stack)
Find and click element by title Python Selenium.

We can find and click elements by title in Selenium webdriver. An element can be identified with a title attribute with xpath or css selector. With the xpath, the expression should be //tagname[@title='value']. In css, the expression should be tagname[title='value'].
Let us take an html code for an element with a title attribute.
The xpath to identify the element should be //a[@title='Tutorialspoint'] and the css expression should be a[title='Tutorialspoint']. Once the element is identified we can use the click() method for clicking on it.
Code Implementation.
from selenium import webdriver
driver = webdriver.Chrome (executable_path="C:\\chromedriver.exe")
# implicit wait for 5 seconds
driver.implicitly_wait(5)
# maximize with maximize_window()
driver.maximize_window()
driver.get("https://www.tutorialspoint.com/about/about_careers.htm")
# identify element with title attribute and click()
l=driver.find_element_by_xpath("//a[@title='Tutorialspoint']")
l.click()
print("Current page title: " + driver.title)
driver.quit()
Custom commands for linux terminal - GeeksforGeeks

18 Aug, 2021
Linux operating system allows users to create commands and execute them over the command line. To create a command in Linux, the first step is to create a bash script for the command. The second step is to make the command executable. Syntax : 
 $ nano ~/.bashrc 
Here, bashrc means run the Bash file. Bash is located at /bin/bash . This file helps in creating environment with help of startup files. nano is text editor. Instead of nano, you can use gedit text editor which is GUI base and most of the users are comfortable with it. Then we have to search content as shown below. 
# some more ls aliases
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
In the above figure : alias :It allow to user to make custom commands. unalias :It allow to user to stop working of any command. 
Make custom command for our own purpose :  
alias [name]=' [command 1]; [command 2]; [command 3]; .....  [command n]'
In place of name provide your custom command. In place of command 1 provide first command that you want to execute. In place of command 2 provide second command that you want to execute. Example : 
alias ok='echo hELLo WorlD; firefox'
echo hELLo WorlD it will display hELLo WorlD in terminal. Enter your commands in sequence and then hit CTRL + O to save your commands in file. Then, hit ENTER for the confirmation and then, hit CTRL + X to exit from file. Now, Restart your terminal. Now, whenever you will type ok it will execute your command.  
 
Don’t use bashrc directly in spite of this we may use bash_aliases
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi
Use bash_aliases to make your own aliases :
nano ~/.bash_aliases
clegerborea
abhishek0719kadiyan
sumitgumber28
linux-command
Linux-Unix
TechTips
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
TCP Server-Client implementation in C
ZIP command in Linux with examples
tar command in Linux with examples
curl command in Linux with Examples
UDP Server-Client implementation in C
How to Find the Wi-Fi Password Using CMD in Windows?
Docker - COPY Instruction
How to Run a Python Script using Docker?
Running Python script on GPU.
Top Programming Languages for Android App Development
C program to convert days into months and number of days

User has to enter total number of days. We need to convert the total number of days into months and left-over days in coming month.
The formula to convert days into months is as follows −
          Month=days/30
The logic to find left-over days for the coming month is as follows −
          Days=days %30
Refer an algorithm given below to convert days into months and number of days.
Step 1: Start
Step 2: Declare month and days
Step 3: Read total number of days
Step 4: Compute months
   months=days/30
Step 5: Compute days
   Days= days % 30
Step 6: Print months
Step 7: Print days
Following is the C program to convert days into months and number of days −
 Live Demo
#include<stdio.h>
main (){
   int months, days ;
   printf("Enter days\n") ;
   scanf("%d", &days) ;
   months = days / 30 ;
   days = days % 30 ;
   printf("Months = %d Days = %d", months, days) ;
}
When the above program is executed, it produces the following result −
Enter days
456
Months = 15 Days = 6
Enter days
145
Months = 4 Days = 25
How to check if the USB device is connected to the system using PowerShell?

To retrieve the USB-connected devices using Powershell, we need to retrieve all the drives using the WMI object or CIM Instance and need to filter the win32_diskdrive class with the USB as shown below.
So basically, USB devices and other removable devices have the drivetype '2'. You can search with the InterfaceType or the DriveType.
WMI commands,
gwmi win32_diskdrive | where{$_.Interfacetype -eq "USB"}
Alternatively,
With the CIM commands,
Get-CimInstance -ClassName Win32_DiskDrive | where{$_.InterfaceType -eq 'USB'}
or
Get-CimInstance -ClassName Win32_LogicalDisk | where{$_.DriveType -eq '2'}
If there is no USB device connected to the system, there will be no output. To retrieve the USB disk on the remote computer use −ComputerName parameter.
Get-CimInstance -ClassName Win32_LogicalDisk -ComputerName TestMachine | where{$_.DriveType -eq '2'}
Salesforce - Standard Controllers

Visualforce consists of many built-in controllers which can be used to access and display data. It works on the MVC (model-view-controller) approach. The controllers interact with the database and pull the data from the database to view the data through a webpage created by apex page.
To display a specific record or group of records, we need the record ID. When integrated with other Visualforce pages the ID can flow to the controller page automatically. But in a standalone page we need to specify the record ID manually to see the controller working.
Let us create a Visualforce page to get the summary of a record in the Contact object. To do this, we use the component called standardController and put it in an apex block. The diagram given below shows the code to achieve this.
Here we display some select fields from the Object. They are Name, Email and phone. If we go to the Preview window, we find that the page only displays the labels but no data. That is because we have not associated the result from the controller with any specific record.
So next we identify a record form the Contact Object to be attached to the result from the controller. Open the contacts object and click on any of contact name. It will open the following window from which we capture the ID of the record. The ID is highlighted in the URL. In your environment, it will be a similar string of characters.
Finally, we add this ID of the record to the URL of the preview window of the Visualforce standard controller page we created. In the current example, the ID of the record is added as shown below.
https://c.ap2.visual.force.com/apex/FirstPage?core.apexpages.request.devconsole=1&id=0032800000Wih9kAAB

On visiting the above URL from the Organization's salesforce account, we get the details of the record as shown below.

    49 Lectures 
     3.5 hours 

 Manigandan Jagadeesan

    113 Lectures 
     13 hours 

 Eduonix Learning Solutions

    37 Lectures 
     3 hours 

 Manish Choudhari

    22 Lectures 
     4.5 hours 

 Pranjal Srivastava

    43 Lectures 
     7 hours 

 Debasis Jena

    54 Lectures 
     8 hours 

 SYED CHAND SHAH
 Print
 Add Notes
 Bookmark this page
Selects all <p> elements inside <div> elements with CSS

Use the element element selector to select all elements inside another element.
You can try to run the following code to implement element element selector,
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         div p {
            color: white;
            background-color: blue;
         }
      </style>
   </head>
   <body>
      <h1>Demo Website</h1>
      <h2>Fruits</h2>
      <p>Fruits are good for health.</p>
      <div>
         <p>This is demo text.</p>
      </div>
   </body>
</html>
PyQt5 QListWidget – Getting Count of Items

01 Aug, 2020
In this article we will see how we can get the count of items of the QListWidget. QListWidget is a convenience class that provides a list view with a classic item-based interface for adding and removing items. QListWidget uses an internal model to manage each QListWidgetItem in the list. Count property holds the number of items in the list including any hidden items.
In order to do this we will use count method with the list widget object.
Syntax : list_widget.count()
Argument : It takes no argument
Return : It returns integer
Below is the implementation
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 500, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()          # method for components    def UiComponents(self):          # creating a QListWidget        list_widget = QListWidget(self)          # setting geometry to it        list_widget.setGeometry(70, 70, 100, 30)          # list widget items        item1 = QListWidgetItem("A")        item2 = QListWidgetItem("B")        item3 = QListWidgetItem("C")          # adding items to the list widget        list_widget.addItem(item1)        list_widget.addItem(item2)        list_widget.addItem(item3)          # creating a label        label = QLabel("GeesforGeeks", self)          # setting geometry to the label        label.setGeometry(200, 100, 300, 80)          # making label multi line        label.setWordWrap(True)                  # getting count of the items of list widget        value = list_widget.count()                  # setting text to the label        label.setText("Item Count : " + str(value))      # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python PyQt-QListWidget
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
Introduction To PYTHON
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list
Moment.js isDate() Function

29 Jul, 2020
Given a value to the variable and the task is to check whether a variable is actual date or not in Moment.js using the isDate() method. To check if a variable is a native js Date object, use moment.isDate() method.
Syntax:
moment.isDate(obj);
Parameter: Object
Returns: True or False
Installation of moment module:
You can visit the link to Install moment module. You can install this package by using this command.npm install momentAfter installing the moment module, you can check your moment version in command prompt using the command.npm version momentAfter that, you can just create a folder and add a file for example, index.js. To run this file you need to run the following command.node index.js
You can visit the link to Install moment module. You can install this package by using this command.npm install moment
npm install moment
After installing the moment module, you can check your moment version in command prompt using the command.npm version moment
npm version moment
After that, you can just create a folder and add a file for example, index.js. To run this file you need to run the following command.node index.js
node index.js
Example 1: Filename: index.js
// Requiring moduleconst moment = require('moment');  var bool1 = moment.isDate(); // falseconsole.log(bool1);  var bool2 = moment.isDate(new Date()); // trueconsole.log(bool2);  var bool3 = moment.isDate(moment()); // falseconsole.log(bool3);
Steps to run the program:
The project structure will look like this:Make sure you have installed moment module using the following command:npm install momentRun index.js file using below command:node index.jsOutput:false
true
false

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

node index.js
Output:
false
true
false

Example 2: Filename: index.js
// Requiring moduleconst moment = require('moment');  function checkIsDate(obj) {   return moment.isDate(obj);}  var bool = checkIsDate(new Date());console.log(bool);
Run index.js file using below command:
node index.js
Output:
true

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

22 Jun, 2020
Keywords are the words in a language that are used for some internal process or represent some predefined actions. void is a keyword, it is a reference type of data type and used to specify the return type of a method in C#. It is an alias of System.Void.
Syntax:
public void function_name([parameters])
{
    //body of the function
}
Note: void cannot be used as a parameter if there is no parameter in a C# method.
Example:
Input: Geeks
       multi = 50*20

Output: Geeks
        multi = 1000

Output: GeeksforGeeks
        sum = 80+20
        sub = 40-10

Output: GeeksforGeeks
        sum = 100
        sub = 30

Example 1:
// C# program for void keywordusing System;class GFG {      public void SimpleText()    {        Console.WriteLine("Geeks");    }      public void sum(int a, int b)    {        Console.WriteLine("multi = " + (a * b));    }};  class Prog {      static void Main(string[] args)    {        // calling functions        GFG ex = new GFG();        ex.SimpleText();        ex.sum(50, 20);    }}
Output:
Geeks
multi = 1000

Example 2:
// C# program for void keywordusing System;using System.Text;  namespace Test {  class Sample {      public void SimpleText()    {        Console.WriteLine("GeeksforGeeks");    }      public void sum(int a, int b)    {        Console.WriteLine("sum = " + (a + b));    }      public void sub(int c, int d)    {        Console.WriteLine("sub = " + (c - d));    }};  class Prog {      static void Main(string[] args)    {        // calling functions        Sample ex = new Sample();        ex.SimpleText();        ex.sum(80, 20);        ex.sub(40, 10);          // hit ENTER to exit        Console.ReadLine();    }}}
Output:
GeeksforGeeks
sum = 100
sub = 30

CSharp-keyword
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
MoviePy – Assigning Audio Clip to Video File

18 Aug, 2020
In this article we will see how we can add external audio to the video file clip in MoviePy. MoviePy is a Python module for video editing, which can be used for basic operations on videos and GIF’s. Video is formed by the frames, combination of frames creates a video each frame is an individual image. An audio file format is a file format for storing digital audio data on a computer system. The bit layout of the audio data is called the audio coding format and can be uncompressed, or compressed to reduce the file size, often using lossy compression. We can load the audio file with the help of AudioFileClip method.
In order to do this we will use set_audio attribute with the video file clip object
Syntax : clip.set_audio(audio)
Argument : It takes AudioFileClip object as argument
Return : It returns VideoFileClip object
Below is the implementation
# Import everything needed to edit video clipsfrom moviepy.editor import *     # loading video dsa gfg intro videoclip = VideoFileClip("dsa_geek.mp4")    # getting only first 5 secondsclip = clip.subclip(0, 5)  # loading audio fileaudioclip = AudioFileClip("allwell.mp3").subclip(0, 5)  # adding audio to the video clipvideoclip = clip.set_audio(audioclip)  # showing video clipvideoclip.ipython_display()
Output :
Moviepy - Building video __temp__.mp4.
MoviePy - Writing audio in __temp__TEMP_MPY_wvf_snd.mp3
                                                                                                                       
MoviePy - Done.
Moviepy - Writing video __temp__.mp4

                                                                                                                       
Moviepy - Done !
Moviepy - video ready __temp__.mp4

Another example
# Import everything needed to edit video clipsfrom moviepy.editor import *  # loading video gfgclip = VideoFileClip("geeks.mp4")  # getting only first 5 secondsclip = clip.subclip(0, 5)  # loading audio fileaudioclip = AudioFileClip("allwell.mp3").subclip(0, 5)  # adding audio to the video clipvideoclip = clip.set_audio(audioclip)  # showing video clipvideoclip.ipython_display()
Output :
Moviepy - Building video __temp__.mp4.
MoviePy - Writing audio in __temp__TEMP_MPY_wvf_snd.mp3
                                                                                                                       
MoviePy - Done.
Moviepy - Writing video __temp__.mp4

                                                                                                                       
Moviepy - Done !
Moviepy - video ready __temp__.mp4

Python-MoviePy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Java Examples - Create Table in a PDF

How to create a table in a PDF using Java.
Following is the program to create a table in a PDF using Java.
import com.itextpdf.kernel.pdf.PdfDocument; 
import com.itextpdf.kernel.pdf.PdfWriter; 

import com.itextpdf.layout.Document; 
import com.itextpdf.layout.element.Cell; 
import com.itextpdf.layout.element.Table;  

public class AddingTableToPDF { 
   public static void main(String args[]) throws Exception { 
      String file = "C:/EXAMPLES/itextExamples/addingTableToPDF.pdf"; 

      //Creating a PdfDocument object 
      PdfDocument pdfDoc = new PdfDocument(new PdfWriter(file));     

      //Creating a Document object 
      Document doc = new Document(pdfDoc);        

      //Creating a table 
      Table table = new Table(2);     

      //Adding cells to the table 
      table.addCell(new Cell().add("Name")); 
      table.addCell(new Cell().add("Raju")); 
      table.addCell(new Cell().add("Id")); 
      table.addCell(new Cell().add("1001")); 
      table.addCell(new Cell().add("Designation")); 
      table.addCell(new Cell().add("Programmer")); 

      //Adding Table to document  
      doc.add(table);

      //Closing the document 
      doc.close();  
      System.out.println("Table created successfully..");
numpy.npv() in Python - GeeksforGeeks

29 Nov, 2018
numpy.npv(rate, value) : This financial function helps user to calculate the NPV(Net Present Value) of a cash flow series.
Parameters :
rate  : [scalar] Rate of discount 
value : [array_like, shape(M,)] value of 
        cash flows time series. The (fixed) time interval 
        between cash flow “events” must be the same as that
        for given rate is given. By convention, investments
        or “deposits” are -ve, income or “withdrawals” are +ve

Return :
present value as per given parameters.

Equation being solved :
Code 1 : Working
## Python program explaining pv() functionimport numpy as np  #            rate            values     a =  np.npv(0.281,[-100, 19, 49, 58, 200])print("Net Present Value(npv) : ", a)
Output :
Net Present Value(npv) :  46.5579792365

References :https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.npv.html.
Python numpy-Financial Functions
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python String | replace()
Create a Pandas DataFrame from Lists
Python program to convert a list to string
Reading and Writing to text files in Python
Python datetime.utcoffset() Method with Example - GeeksforGeeks

27 Dec, 2021
The utcoffset() function is used to return a timedelta object that represents the difference between the local time and UTC time.
This function is used in used in the datetime class of module datetime.
Here range of the utcoffset is “timedelta(hours=24) <= offset <= timedelta(hours=24)”.
If the offset is east of UTC, then it is considered positive and if the offset is west of UTC, then it is considered negative. Since there are 24 hours in a day, -timedelta(24) and timedelta(24) are the largest values possible.
Syntax: utcoffset()
Parameters: This function does not accept any parameter.
Return values: This function returns a timedelta object representing the difference between the local time and UTC time.
Example 1: Here output is None because now() function returns date and time in UTC format, hence the difference between the local time i.e, returned by now() function and UTC time is none.
Python3
# Python3 code for getting# the difference between the# local time and UTC time # Importing datetime and pytz modulefrom datetime import datetimeimport pytz # Calling the now() function to get# current date and timedate_time = datetime.now() # Calling the utcoffset() function# over the above initialized datetimeprint(date_time.utcoffset())
Output:
None
Example 2: Finding the offset of time
Python3
# Python3 code for getting# the difference between the# local time and UTC time # Importing datetime and pytz modulefrom datetime import datetimeimport pytz # Calling the now() function to# get current date and timenaive = datetime.now() # adding a timezonetimezone = pytz.timezone("Asia/Kolkata")aware1 = timezone.localize(naive) # Calling the utcoffset() function# over the above localized timeprint("Time ahead of UTC by:", aware1.utcoffset())
Output:
Time ahead of UTC by: 5:30:00
Example 3: Finding time offset
Python3
# Python3 code for getting# the difference between the# local time and UTC time # Importing datetime and pytz modulefrom datetime import datetimeimport pytz # Calling the now() function to# get current date and timenaive = datetime.now() # adding a timezonetimezone = pytz.timezone("Asia/Tokyo")aware1 = timezone.localize(naive) # Calling the utcoffset() function# over the above localized timeprint("Time ahead of UTC by:", aware1.utcoffset())
Output:
Time ahead of UTC by: 9:00:00
simranarora5sos
Picked
Python-datetime
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Check if element exists in list in Python
Python | os.path.join() method
Defaultdict in Python
Selecting rows in pandas DataFrame based on conditions
Python | Get unique values from a list
Create a directory in Python
Python | Pandas dataframe.groupby()
VueJS - Watch Property

In this chapter, we will learn about the Watch property. Using an example, we will see we can use the Watch property in VueJS.
<html>
   <head>
      <title>VueJs Instance</title>
      <script type = "text/javascript" src = "js/vue.js"></script>
   </head>
   <body>
      <div id = "computed_props">
         Kilometers : <input type = "text" v-model = "kilometers">
         Meters : <input type = "text" v-model = "meters">
      </div>
      <script type = "text/javascript">
         var vm = new Vue({
            el: '#computed_props',
            data: {
               kilometers : 0,
               meters:0
            },
            methods: {
            },
            computed :{
            },
            watch : {
               kilometers:function(val) {
                  this.kilometers = val;
                  this.meters = val * 1000;
               },
               meters : function (val) {
                  this.kilometers = val/ 1000;
                  this.meters = val;
               }
            }
         });
      </script>
   </body>
</html>
In the above code, we have created two textboxes, one with kilometers and another with meters. In data property, the kilometers and meters are initialized to 0. There is a watch object created with two functions kilometers and meters. In both the functions, the conversion from kilometers to meters and from meters to kilometers is done.
As we enter values inside any of the texboxes, whichever is changed, Watch takes care of updating both the textboxes. We do not have to specially assign any events and wait for it to change and do the extra work of validating. Watch takes care of updating the textboxes with the calculation done in the respective functions.
Let’s take a look at the output in the browser.
Let’s enter some values in the kilometers textbox and see it changing in the meters textbox and vice-versa.
Let’s now enter in meters textbox and see it changing in the kilometers textbox. This is the display seen in the browser.
 Print
 Add Notes
 Bookmark this page
Solidity - Types

While writing program in any language, you need to use various variables to store various information. Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory.
You may like to store information of various data types like character, wide character, integer, floating point, double floating point, boolean etc. Based on the data type of a variable, the operating system allocates memory and decides what can be stored in the reserved memory.
Solidity offers the programmer a rich assortment of built-in as well as user defined data types. Following table lists down seven basic C++ data types −
Note: You can also represent the signed and unsigned fixed-point numbers as fixedMxN/ufixedMxN where M represents the number of bits taken by type and N represents the decimal points. M should be divisible by 8 and goes from 8 to 256. N can be from 0 to 80.
address holds the 20 byte value representing the size of an Ethereum address. An address can be used to get the balance using .balance method and can be used to transfer balance to another address using .transfer method.
address x = 0x212;
address myAddress = this;
if (x.balance < 10 && myAddress.balance >= 10) x.transfer(10);

    38 Lectures 
     4.5 hours 

 Abhilash Nelson

    62 Lectures 
     8.5 hours 

 Frahaan Hussain

    31 Lectures 
     3.5 hours 

 Swapnil Kole
 Print
 Add Notes
 Bookmark this page