code-rag-bench/online-tutorials huggingface dataset:
Python | startswith() and endswith() functions - GeeksforGeeks

13 Feb, 2020
Python library provides a number of built in methods, one such being startswith() and endswith() function which used in string related operations.
startswith()
Syntax
str.startswith(search_string, start, end)
Parameters :
search_string : The string to be searched.start : start index of the str from where the search_string is to be searched.end : end index of the str, which is to be considered for searching.
Use :
startswith() function is used to check whether a given Sentence starts with some particular string.
Start and end parameter are optional.
We may use them when we want only some particular substring of the original string to be considered for searching.
 Returns :The return value is binary. The functions returns True if the original Sentence starts with the search_string else False.
 
endswith()
Syntax :
str.endswith( search_string, start, end)
Parameters :
search_string : The string to be searched.start : Start index of the str from where the search_string is to be searched.end : End index of the str, which is to be considered for searching.
Use :
endswith() function is used to check whether a given Sentence ends with some particular string.
Start and end parameter are optional.
We may use them when we want only some particular substring of the original string to be considered for searching.
 Returns :The return value is binary. The functions returns True if the original Sentence ends with the search_string else False. Below is the code explaining startswith() and endswidth() :
# Python code to implement startswith()# and endswith() function.  str = "GeeksforGeeks"  # startswith()print(str.startswith("Geeks"))print(str.startswith("Geeks", 4, 10))print(str.startswith("Geeks", 8, 14))  print("\n")  # endswithprint(str.endswith("Geeks"))print(str.endswith("Geeks", 2, 8))print(str.endswith("for", 5, 8))
Output :
True
False
True


True
False
True
z00003
Python-Built-in-functions
Python-Functions
python-string
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Enumerate() in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Create a Pandas DataFrame from Lists
Reading and Writing to text files in Python
*args and **kwargs in Python
sum() function in Python
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Get a List of points obtained by Interpolation in R Programming - spline() and splinefun() Function - GeeksforGeeks

03 Jul, 2020
In R programming, spline() and splinefun() function is used to create a list of points obtained by interpolation. It performs cubic spline interpolation of given data points.
Syntax:spline(x, y, method)andsplinefun(x, y, method)
Parameters:x, y: represents vectors giving the points for interpolationmethod: represents the type of spline interpolation to be used
To know about more optional parameters of both the functions, use below command in console:
help("spline")

Example 1:
# Coordinatesn <- 100x <- 1:ny <- rnorm(n)  # Output to be present as PNG filepng(file = "splineGFG.png")  # Spline() functionplot(x, y, main = "spline() function")lines(spline(x, y))  # Saving the filedev.off()
Output:
Example 2:
# Coordinatesn <- 100x <- 1:ny <- sin((x-0.5)*pi)  # Output to be present as PNG filepng(file = "splinefunGFG.png")  f <- splinefun(x, y)curve(f(x))  # Saving the filedev.off()
Output:
R Math-Function
R Statistics-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Change Color of Bars in Barchart using ggplot2 in R
Data Visualization in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
Logistic Regression in R Programming
How to Split Column Into Multiple Columns in R DataFrame?
Control Statements in R Programming
How to import an Excel File into R ?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
How to assign values to variables in Python

Variable assignment is a very basic requirement in any computer programming language. In python there are multiple ways we can declare a variable and assign value to it. Below we see each of them.
In this method, we directly declare the variable and assign a value using the = sign. If the variable is declare multiple times, then the last declaration’s value will be used by the program.
x = 5
x = 9
print(a)
Running the above code gives us the following result:
9
We can initialize value of a variable using some conditions. The evaluation of the result of the condition will become the value of the variable.
 Live Demo
x = 12
y = 13 if x > 8 else 0
# printing value of a
print("Value of z is: " + str(y))
Running the above code gives us the following result:
Value of z is: 13
Convert image to binary using Python - GeeksforGeeks

17 Dec, 2020

In this article, we are going to convert the image into its binary form. A binary image is a monochromatic image that consists of pixels that can have one of exactly two colors, usually black and white. Binary images are also called bi-level or two-level. This means that each pixel is stored as a single bit—i.e., 0 or 1.
The most important library needed for image processing in Python is OpenCV. Make sure you have installed the library into your Python. For steps for installing OpenCV refers to this article: Set up Opencv with anaconda environment
Approach:

Read the image from the location.
As a colored image has RGB layers in it and is more complex, convert it to its Grayscale form first.
Set up a Threshold mark, pixels above the given mark will turn white, and below the mark will turn black.

Read the image from the location.
As a colored image has RGB layers in it and is more complex, convert it to its Grayscale form first.
Set up a Threshold mark, pixels above the given mark will turn white, and below the mark will turn black.
Below is the implementation:
Python3
 

 
 










import cv2 
  
# read the image file 
img = cv2.imread('ff.jpg', 2) 
  
ret, bw_img = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY) 
  
# converting to its binary form 
bw = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY) 
  
cv2.imshow("Binary", bw_img) 
cv2.waitKey(0) 
cv2.destroyAllWindows() 






Output:
Original Image
Binary Form

Picked


Python-OpenCV


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 drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Defaultdict in Python
Python | os.path.join() method
Python | Get unique values from a list
Selecting rows in pandas DataFrame based on conditions
Create a directory in Python
Python | Pandas dataframe.groupby()
Chomsky Classification of Grammars

According to Noam Chomosky, there are four types of grammars − Type 0, Type 1, Type 2, and Type 3. The following table shows how they differ from each other −
Take a look at the following illustration. It shows the scope of each type of grammar −
Type-3 grammars generate regular languages. Type-3 grammars must have a single non-terminal on the left-hand side and a right-hand side consisting of a single terminal or single terminal followed by a single non-terminal.
The productions must be in the form X → a or X → aY
where X, Y ∈ N (Non terminal)
and a ∈ T (Terminal)
The rule S → ε is allowed if S does not appear on the right side of any rule.
X → ε 
X → a | aY
Y → b 

Type-2 grammars generate context-free languages.
The productions must be in the form A → γ
where  A ∈ N (Non terminal)
and γ ∈ (T ∪ N)* (String of terminals and non-terminals).
These languages generated by these grammars are be recognized by a non-deterministic pushdown automaton.
S → X a 
X → a 
X → aX 
X → abc 
X → ε

Type-1 grammars generate context-sensitive languages. The productions must be in the form
α A β → α γ β
where A ∈ N (Non-terminal)
and α, β, γ ∈ (T ∪ N)* (Strings of terminals and non-terminals)
The strings α and β may be empty, but γ must be non-empty.
The rule S → ε is allowed if S does not appear on the right side of any rule. The languages generated by these grammars are recognized by a linear bounded automaton.
AB → AbBc 
A → bcA 
B → b 

Type-0 grammars generate recursively enumerable languages. The productions have no restrictions. They are any phase structure grammar including all formal grammars.
They generate the languages that are recognized by a Turing machine.
The productions can be in the form of α → β where α is a string of terminals and nonterminals with at least one non-terminal and α cannot be null. β is a string of terminals and non-terminals.
S → ACaB 
Bc → acB 
CB → DB 
aD → Db 


    98 Lectures 
     10 hours 

 Arnab Chakraborty

    15 Lectures 
     2 hours 

 Anchal Kamra

    16 Lectures 
     1.5 hours 

 Packt Publishing
 Print
 Add Notes
 Bookmark this page
Python | Frequency of substring in given string - GeeksforGeeks

25 Jun, 2019
Finding a substring in a string has been dealt in many ways. But sometimes, we are just interested to know how many times a particular substring occurs in a string. Let’s discuss certain ways in which this task is performed.
Method #1 : Using count()This is a quite straightforward method in which this task is performed. It simply counts the occurrence of substrings in a string that we pass as an argument.
# Python3 code to demonstrate working of# Frequency of substring in string # Using count()  # initializing string test_str = "GeeksforGeeks is for Geeks"  # initializing substringtest_sub = "Geeks"   # printing original string print("The original string is : " + test_str)  # printing substringprint("The original substring : " + test_sub)  # using count()# Frequency of substring in stringres = test_str.count(test_sub)  # printing result print("The frequency of substring in string is " + str(res))
The original string is : GeeksforGeeks is for Geeks
The original substring : Geeks
The frequency of substring in string is 3

 
Method #2 : Using len() + split()The combination of above functions can be used to perform this task. This is performed in 2 steps, in 1st step, we split the string to list by the substring and then count the elements, which is 1 more than the required value.
# Python3 code to demonstrate working of# Frequency of substring in string # Using split() + len()  # initializing string test_str = "GeeksforGeeks is for Geeks"  # initializing substringtest_sub = "Geeks"   # printing original string print("The original string is : " + test_str)  # printing substringprint("The original substring : " + test_sub)  # using split() + len()# Frequency of substring in stringres = len(test_str.split(test_sub))-1  # printing result print("The frequency of substring in string is " + str(res))
The original string is : GeeksforGeeks is for Geeks
The original substring : Geeks
The frequency of substring in string is 3

Python string-programs
Python
Python Programs
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
Defaultdict in Python
Python | Split string into list of characters
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python program to check whether a number is Prime or not
Node.js zlib.inflateRawSync() Method - GeeksforGeeks

11 Oct, 2021
The zlib.inflateRawSync() method is an inbuilt application programming interface of the Zlib module which is used to decompress a chunk of data with InflateRaw.
Syntax:
zlib.inflateRawSync( buffer, options )
Parameters: This method accepts two parameters as mentioned above and described below:
buffer: This parameter holds the buffer of type Buffer, TypedArray, DataView, ArrayBuffer, string.
options: This parameter holds the zlib options value.
Return Value: It returns the chunk of data with InflateRaw.
Below examples illustrate the use of zlib.inflateRawSync() method in Node.js:
Example 1:
// Node.js program to demonstrate the     // inflateRawSync() method    // Including zlib modulevar zlib = require('zlib');  // Declaring input and assigning// it a value stringvar input = "GeeksforGeeks";  // Calling deflateRawSync methodvar deflatedRS = zlib.deflateRawSync(input);  // Calling inflateRawSync methodvar inflatedRS = zlib.inflateRawSync(    new Buffer.from(deflatedRS)).toString();  console.log(inflatedRS);
Output:
GeeksforGeeks

Example 2:
// Node.js program to demonstrate the     // inflateRawSync() method    // Including zlib modulevar zlib = require('zlib');  // Declaring input and assigning// it a value stringvar input = "GeeksforGeeks";  // Calling deflateRawSync methodvar deflatedRS = zlib.deflateRawSync(        input).toString('hex')  // Calling inflateRawSync methodvar inflatedRS = zlib.inflateRawSync(new Buffer.from(        deflatedRS, 'hex')).toString('hex');  console.log(inflatedRS);
Output:
4765656b73666f724765656b73

Reference: https://nodejs.org/api/zlib.html#zlib_zlib_inflaterawsync_buffer_options
Node.js-Zlib-module
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Node.js fs.readFile() Method
Node.js fs.writeFile() Method
How to install the previous version of node.js and npm ?
Difference between promise and async await in Node.js
How to read and write Excel file in Node.js ?
Roadmap to Become a Web Developer in 2022
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
Convert a string to an integer in JavaScript
Tutorial: How do I add images with HTML? – W3Schools.com

How to library



W3Schools.com


How to library


Tutorial: Learn HTML


Tutorial: Learn CSS


Tutorial: Learn JavaScript


Tutorial: Learn W3.CSS


How do I set up Google Analytics?


How do I make a website?


How do I create a link tree website?


How do I create a portfolio?


How do I create an online resume?


How do I get an overview of the different HTML tags? 

6 months ago
Updated
Images can improve the design and the appearance of a web page.
 
You can add images to your website with HTML.
 
<img src="pic_trulli.jpg" alt="Italian Trulli">
 
For a complete list of all available HTML tags, visit our HTML Tag Reference.
Partition Equal Subset Sum in C++

Suppose we have a non-empty array containing only positive numbers, we have to find if the array can be partitioned into two subsets such that the sum of elements in both subsets is the same. So if the input is like [1,5,11,5], the output will be true. As this array can be partitioned as [1, 5, 5] and [11]
To solve this, we will follow these steps −
n := size of the array
sum := 0
for i := 0 to n – 1sum := sum + nums[i]
sum := sum + nums[i]
if sum is odd, return false
sum := sum / 2
create one array called dp of size sum + 1
dp[0] := true
for i in range 0 to n – 1x := nums[i]for j := sum down to j – xdp[j] := dp[j] or dp[j - x], which is not 0
x := nums[i]
for j := sum down to j – xdp[j] := dp[j] or dp[j - x], which is not 0
dp[j] := dp[j] or dp[j - x], which is not 0
return dp[sum]
Let us see the following implementation to get a better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
   bool canPartition(vector<int>& nums) {
      int n = nums.size();
      int sum = 0;
      for(int i =0;i<n;i++)sum+=nums[i];
      if(sum&1)return false;
      sum/=2;
      vector <bool> dp(sum+1);
      dp[0] = true;
      for(int i =0;i<n;i++){
         int x = nums[i];
         for(int j =sum;j-x>=0;j--){
            dp[j]=dp[j] || dp[j-x];
         }
      }
      return dp[sum];
   }
};
main(){
   Solution ob;
   vector<int> v = {1,5,11,5};
   cout << ob.canPartition(v);
}
[1,5,11,5]
1
Elm - Operators

An operator defines some function that will be performed on the data. The values on which the operators work are called operands. Consider the following expression
7 + 5 = 12
Here, the values 7, 5, and 12 are operands, while + and = are operators.
The major operators in Elm can be classified as −
Arithmetic
Relational
Logical
Assume the values in variables a and b are 7 and 2 respectively.
Show Examples
Relational Operators test or define the kind of relationship between two entities. These operators are used to compare two or more values. Relational operators return a Boolean value, i.e. true or false.
Assume the value of a is 10 and b is 20.
Show Examples
Comparison operators like >= or < work with comparable types. These are defined as numbers, characters, strings, and lists, tuples. The comparable types on both sides of the operator must be the same.
Open the elm REPL and try the examples shown below −
C:\Users\admin>elm repl
---- elm-repl 0.18.0 -----------------------------------------------------------
:help for help, :exit to exit, more at <https://github.com/elm-lang/elm-repl>
--------------------------------------------------------------------------------
> 7>2
True : Bool
> 7.0>2
True : Bool
> 7.0<2.0
False : Bool
> 'a' > 'b'
False : Bool
> 'a' < 'b'
True : Bool
> "a" < "b"
True : Bool
> (1,2) > (2,3)
False : Bool
> ['1','3'] < ['2','1']
True : Bool
>
Logical Operators are used to combine two or more conditions. Logical operators too return a Boolean value.
Show Examples

    27 Lectures 
     2.5 hours 

 Ahmed Elfakharany
 Print
 Add Notes
 Bookmark this page
Creating Media Dependent Style Sheets using CSS

Media dependent stylesheets are basic stylesheets only but apply to html document only when mediatype matches device type on which document is visible.
We can create media dependent stylesheets by following methods −
Using @media At-rules
Using @import At-rules
Using HTML <link> element with media attribute
Let’s see an example for creating media dependent stylesheets −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="screen.css">
<link rel="stylesheet" type="text/css" media="print" href="print.css">
</head>
<body>
<div></div>
</body>
</html>
div {
height: 50px;
width: 100px;
border-radius: 20%;
border: 2px solid blueviolet;
box-shadow: 22px 12px 3px 3px lightblue;
position: absolute;
left: 30%;
top: 20px;
}
div {
   height: 50px;
   width: 100px;
   border-radius: 20%;
   border: 2px solid #dc3545;
   box-shadow: 22px 12px 3px 3px #dc3545;
   position: absolute;
   left: 30%;
   top: 20px;
}
This will produce the following output −
When document is visible in a screen mediatype −
When document is visible in a print mediatype −
Let’s see another example for creating media dependent stylesheets −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
p {
   background-origin: content-box;
   background-repeat: no-repeat;
   background-size: cover;
   box-shadow: 0 0 3px black;
   padding: 20px;
   background-origin: border-box;
}
@media screen and (max-width: 900px) {
   p{
      background: url("https://www.tutorialspoint.com/android/images/android.jpg");
      color: #c303c3;
   }
}
@media screen and (max-width: 500px) {
   p {
      color: black;
      background: url("https://www.tutorialspoint.com/react_native/images/react-native.jpg");
   }
}
</style>
</head>
<body>
<p>This is demo text. This is demo text. This is demo text. This is demo text. 
This is demo text. This is demo text. This is demo text. This is demo text. 
This is demo text. This is demo text. This is demo text. This is demo text. 
This is demo text. This is demo text. This is demo text. This is demo text. 
This is demo text. This is demo text. This is demo text. This is demo text. </p>
</body>
</html>
This will produce the following output −
When screen size is above 500px −
When screen size is below 500px −
How to get a particular anchor in a document in JavaScript?

Javascript anchor tags follow an array-like structure. When we try to display a particular anchor tag we have to use document.anchors.innerHTML method. This method works the same as array methods which are used to display a particular element.
element = document.anchors[i].innerHTML;
In the following example, the first anchor tag, out of 2 anchor tags, is displayed as shown in the output. 
Live Demo
<html>
<body>
<a name="Tutor">Tutorix</a><br>
<a name="Totorial">Tutorialspoint</a><br>
<p id="anchors"></p>
<script>
   document.getElementById("anchors").innerHTML =
   "The first anchor element is: " + document.anchors[0].innerHTML;
</script>
</body>
</html>
Tutorix
In the following example, there are 3 anchor elements in which the third element is displayed using document.innerHTML as shown in the output.
Live Demo
<html>
<body>
   <a name="Tutor">Tutorix</a><br>
   <a name="Totorial">Tutorialspoint</a><br>
   <a name="Totorials">Tutorialspoint private ltd</a><br>
<p id="anchors"></p>
<script>
   document.getElementById("anchors").innerHTML =
   "The third element is:" + document.anchors[2].length;
</script>
</body>
</html>
Tutorix
Tutorialspoint
Tutorialspoint private ltd
The third element is:Tutorialspoint private ltd
How to calculate weighted mean in R?

Weighted mean is the average which is determined by finding the sum of the products of weights and the values then dividing this sum by the sum of total weights. If the weights are in proportion then the total sum of the weights should be 1. In base R, we have a function weighted.mean to find the weighted mean in which we just need to pass the vector of values and the vector of weights.
 Live Demo
x1<-c(1,2,3,4)
x1
[1] 1 2 3 4
Live Demo
Weight_x1<-c(0.25,0.25,0.25,0.25)
Weight_x1
[1] 0.25 0.25 0.25 0.25
Weighted_Mean_x1<-weighted.mean(x1,Weight_x1)
Weighted_Mean_x1
[1] 2.5
 Live Demo
x2<-rpois(10,5)
x2
[1] 3 3 4 6 6 10 5 3 3 6
 Live Demo
Weight_x2<-rep(0.1,10)
Weight_x2
[1] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1
Weighted_Mean_x2<-weighted.mean(x2,Weight_x2)
Weighted_Mean_x2
[1] 4.9
 Live Demo
x3<-c(8,6,7)
x3
[1] 8 6 7
Live Demo
Weight_x3<-c(0.5,0.3,0.2)
Weight_x3
[1] 0.5 0.3 0.2
Weighted_Mean_x3<-weighted.mean(x3,Weight_x3)
Weighted_Mean_x3
[1] 7.2
 Live Demo
x4<-rnorm(5,1.5)
x4
[1] 3.0320687 0.9741989 0.2783473 0.8061909 0.5833953
Live Demo
Weight_x4<-rep(0.2,5)
Weight_x4
[1] 0.2 0.2 0.2 0.2 0.2
Weighted_Mean_x4<-weighted.mean(x4,Weight_x4)
Weighted_Mean_x4
[1] 1.13484
 Live Demo
x5<-c(1,2,5,7)
x5
[1] 1 2 5 7
Weight_x5<-c(2,14,8,32)
Weight_x5
[1] 2 14 8 32
Weighted_Mean_x5<-weighted.mean(x5,Weight_x5)
Weighted_Mean_x5
[1] 5.25
 Live Demo
x6<-runif(10,2,4)
x6
[1] 2.126860 3.194281 3.051176 3.083388 3.393485 2.139493 2.634237 2.647985
[9] 3.318430 2.765557
Weight_x6<-rep(0.1,10)
Weight_x6
[1] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1
Weighted_Mean_x6<-weighted.mean(x6,Weight_x6)
Weighted_Mean_x6
[1] 2.835489
 Live Demo
x7<-c(1,2,3,4)
x7
[1] 1 2 3 4
Weight_x7<-c(73,378,459,90)
Weight_x7
[1] 73 378 459 90
Weighted_Mean_x7
<-weighted.mean(x7,Weight_x7)
Weighted_Mean_x7
[1] 2.566
How to dismount the ISO file using PowerShell?

To dismount the ISO file on the Windows Server using PowerShell, we need to use the Dismount−DiskImage command. When you use this command, you need to use the same path used for mounting the disk image.
In this example, we have a disk mounted on E: on the local server, that we can check using the windows explorer or cmdlets.
We have the source ISO image stored at F: drive, so we can dismount the image using the below command.
ISO Disk will be mounted from the E:
To dismount the disk on the remote server, we can use the CIMSession command.
$sess = New−CimSession −ComputerName Labmachine2k12
Dismount−DiskImage −ImagePath F:\Windows_Server_2016_Datacenter.ISO −
CimSession $sess
In the above example, the ISO file will be dismounted from the LabMachine2k12 server, and that ImagePath should exist on the remote machine.
Difference between two strings JavaScript

We are given two strings, say s and t. String t is generated by random shuffling string s and then add one more letter at a random position.
We are required to write a JavaScript function that takes both these strings and returns the letter that was added to t.
For example −
If the input stings are −
const s = "abcd", t = "abcde";
Then the output should be −
const output = "e";
because 'e' is the letter that was added.
const s = "abcd", t = "abcde";
const findTheDifference = (s, t) => {
   let a = 0, b = 0; let charCode, i = 0;
   while(s[i]){
      a ^= s.charCodeAt(i).toString(2);
      b ^= t.charCodeAt(i).toString(2);
      i++;
   };
   b^=t.charCodeAt(i).toString(2);
   charCode = parseInt(a^b,2);
   return String.fromCharCode(charCode);
};
console.log(findTheDifference(s, t));
And the output in the console will be −
e
What is Overloading in Java?

When a class has two or more methods by the same name but different parameters, at the time of calling based on the parameters passed respective method is called (or respective method body will be bonded with the calling line dynamically). This mechanism is known as method overloading.
 Live Demo
public class Sample{
   public static void add(int a, int b){
      System.out.println(a+b);
   }
   public static void add(int a, int b, int c){
      System.out.println(a+b+c);
   }
   public static void main(String args[]){
      Sample obj = new Sample();
      obj.add(20, 40);
      obj.add(40, 50, 60);
   }
}
60
150
How to exclude specific file names using Get-ChildItem in PowerShell?

To exclude specific file(s) from being displayed in the output of Get- ChildItem, you need to specify the file name(s).
Get-ChildItem D:\Temp\ -Recurse -Exclude style.css, LGPO.exe
Directory: D:\Temp\LGPO
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       01-06-2017     02:25         638115 LGPO.pdf
    Directory: D:\Temp
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       07-05-2018     23:00            301 cars.xml
-a----       29-12-2017     15:16           4526 healthcheck.htm
-a----       29-12-2017     15:16           4526 healthcheck1.htm
-ar---       13-01-2020     18:19              0 Readonlyfile.txt
-a----       08-12-2017     10:24          48362 servicereport.htm
-a----       08-12-2017     10:24          48362 servicereport1.htm
-a----       12-12-2017     23:04           1034 tes.htmoutput.htm
-a----       08-12-2017     11:29           7974 Test.xlsx
-a----       25-10-2017     08:13            104 testcsv.csv
You can also use the wildcard characters to exclude files.
Get-ChildItem D:\Temp\ -Recurse -Exclude LG*

The above command will exclude all the files and folders starting with LG.
Convert.FromBase64String(String) Method in C#

The Convert.FromBase64String(String) method in C# converts the specified string, which encodes binary data as base-64 digits, to an equivalent 8-bit unsigned integer array.
Following is the syntax −
public static byte[] FromBase64String (string str);
Above, the parameter str is the string to convert.
Let us now see an example to implement the Convert.FromBase64String(String) method −
using System;
public class Demo {
   public static void Main(){
      byte[] val1 = {5,10,15,20,25,30};
      string str = Convert.ToBase64String(val1);
      Console.WriteLine("Base 64 string: '{0}'", str);
      byte[] val2 = Convert.FromBase64String(str);
      Console.WriteLine("Converted byte value: {0}", BitConverter.ToString(val2));
   }
}
This will produce the following output −
Base 64 string: 'BQoPFBke'
Converted byte value: 05-0A-0F-14-19-1E
How to use if/else condition in select in MySQL?

Let us first create a table −
mysql> create table DemoTable1966
   (
   UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   UserName varchar(20),
   PhotoLiked int
   );
Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1966(UserName,PhotoLiked) values('Chris',57);
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1966(UserName,PhotoLiked) values('David',100);
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1966(UserName,PhotoLiked) values('Mike',68);
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1966(UserName,PhotoLiked) values('Sam',78);
Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1966;
This will produce the following output −
+--------+----------+------------+
| UserId | UserName | PhotoLiked |
+--------+----------+------------+
|      1 | Chris    |         57 |
|      2 | David    |        100 |
|      3 | Mike     |         68 |
|      4 | Sam      |         78 |
+--------+----------+------------+
4 rows in set (0.00 sec)
Here is the query to use if/else condition in SELECT with MySQL −
mysql> select if(PhotoLiked > 75,UserName,'Likes are less') as Result from DemoTable1966;
This will produce the following output −
+------------------------------------------------+
| Result                                         |
+------------------------------------------------+
| Likes are less                                 |
| David                                          |
| Likes are less                                 |
| Sam                                            |
+------------------------------------------------+
4 rows in set (0.00 sec)
Variables in Java Do Not Follow Polymorphism and Overriding

23 Sep, 2021
Variables in Java do not follow polymorphism. Overriding is only applicable to methods but not to variables. In Java, if the child and parent class both have a variable with the same name, Child class’s variable hides the parent class’s variable, even if their types are different. This concept is known as Variable Hiding. In the case of method overriding, overriding methods completely replace the inherited methods but in variable hiding, the child class hides the inherited variables instead of replacing them which basically means that the object of Child class contains both variables but Child’s variable hides Parent’s variable. 
Hence when we try to access the variable within Child class, it will be accessed from the child class. If we are trying to access the variable outside of the Parent and Child class, then the instance variable is chosen from the reference type.
Example
Java
// Java Program Illustrating Instance variables// Can not be Overridden  // Class 1// Parent class// Helper classclass Parent {    // Declaring instance variable by name `a`    int a = 10;    public void print()    {        System.out.println("inside B superclass");    }}  // Class 2// Child class// Helper classclass Child extends Parent {      // Hiding Parent class's variable `a` by defining a    // variable in child class with same name.    int a = 20;      // Method defined inside child class    public void print()    {        // Print statement        System.out.println("inside C subclass");    }}  // Main classpublic class GFG {      // Main driver method    public static void main(String[] args)    {        // Creating a Parent class object        // Reference Parent        Parent obj = new Child();          // Calling print() method over object created        obj.print();          // Printing superclass variable value 10        System.out.println(obj.a);          // Creating a Child class object        // Reference Child        Child obj2 = new Child();          // Printing childclass variable value 20        System.out.println(obj2.a);    }}
inside C subclass
10
20

Conclusion: 
Variables in Java do not follow polymorphism and overriding. If we are trying to access the variable outside of Parent and Child class, then the instance variable is chosen from the reference type.
Blogathon-2021
java-inheritance
java-overriding
Blogathon
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Import JSON Data into SQL Server?
SQL Query to Convert Datetime to Date
Python program to convert XML to Dictionary
Scrape LinkedIn Using Selenium And Beautiful Soup in Python
How to toggle password visibility in forms using Bootstrap-icons ?
Arrays in Java
Split() String method in Java with examples
Arrays.sort() in Java with examples
Reverse a string in Java
Object Oriented Programming (OOPs) Concept in Java
How to Install and Run Apache Kafka on Windows?

28 Jun, 2022
Apache Kafka is an open-source application used for real-time streams for data in huge amount. Apache Kafka is a publish-subscribe messaging system. A messaging system lets you send messages between processes, applications, and servers. Broadly Speaking, Apache Kafka is software where topics can be defined and further processed.
Apache Kafka can be downloaded from its official site kafka.apache.org
For the installation process, follow the steps given below:
Step 1: Go to the Downloads folder and select the downloaded Binary file.
Step 2: Extract the file and move the extracted folder to the directory where you wish to keep the files.
Step 3: Copy the path of the Kafka folder. Now go to config inside kafka folder and open zookeeper.properties file. Copy the path against the field dataDir and add /zookeeper-data to the path.For example if the path is c:/kafka
Step 4: Now in the same folder config open server.properties and scroll down to log.dirs and paste the path. To the path add /kafka-logs
Step 5: This completes the configuration of zookeeper and kafka server. Now open command prompt and change the directory to the kafka folder. First start zookeeper using the command given below:
.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties

Step 6: Now open another command prompt and change the directory to the kafka folder. Run kafka server using the command:
.\bin\windows\kafka-server-start.bat .\config\server.properties

Now kafka is running and ready to stream data.
Apache
how-to-install
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to create a horizontal bar graph using ggplot2 in R?

Making comparisons is bit easier through horizontal bar graphs as compared to the vertical bar graphs in cases where the labels for the categories have large names. Because a large name for the labels of a vertical bar graph is likely to mix with the other labels and therefore, the reading of these labels become difficult for the viewer. To solve this problem, we can draw a bar graph and flip it with coord_flip() in ggplot2.
Consider the below data frame −
Size <-c("Small","Medium","Large")
Frequency <-c(42,49,47)
df <-data.frame(Size,Frequency)
df
Size Frequency
1 Small 42
2 Medium 49
3 Large 47
> library(ggplot2)
Creating vertical bar graph −
ggplot(df,aes(Size,Frequency))+geom_bar(stat="identity")
Creating horizontal bar graph −
ggplot(df,aes(Size,Frequency))+geom_bar(stat="identity")+coord_flip()
How to define the naming conventions for JSON field names in Java?

The FieldNamingPolicy can be used to define a few standard naming conventions for JSON field names and it can be used in conjunction with GsonBuilder to configure a Gson instance to properly translate Java field names into the desired JSON field names. We can use the setFieldNamingPolicy() method of GsonBuilder to configure a specific naming policy strategy to an object's field during serialization and deserialization.
Gson supports various field naming requirements with following field naming policies
FieldNamingPolicy.IDENTITY: It uses the exact same naming as the Java model when it serializes an object.
FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES: It modifies a Java field name from its camel-cased form to a lower case field name where each word is separated by an underscore(_).
FieldNamingPolicy.LOWER_CASE_WITH_DASHES: It modifies the Java field name from its camel-cased form to a lower case field name where each word is separated by a dash(-).
FieldNamingPolicy.UPPER_CAMEL_CASE: It will ensure that the first "letter" of the Java field name is capitalized when serialized to its JSON form.
FieldNamingPolicy.UPPER_CAMEL_CASE_WITH_SPACES: It will ensure that the first "letter" of the Java field name is capitalized when serialized to its JSON form and the words will be separated by a space.
import com.google.gson.*;
import java.sql.Date;
import java.time.LocalDate;
public class FieldNamingPolicyTest {
   public static void main(String[] args) {
      Gson gson = new GsonBuilder().setPrettyPrinting().setDateFormat("yyyy-MM- dd") .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES).create();
      Person p = new Person("Raja", "Ramesh", 30, Date.valueOf(LocalDate.of(1988, 1, 1)));
      String jsonStr = gson.toJson(p);
      System.out.println(jsonStr);
   }
}
// Person class
class Person {
   private String fistName;
   private String lastName;
   private int _age;
   private Date dateOfBirth;
   public Person(String fistName, String lastName, int _age, Date dateOfBirth) {
      super();
      this.fistName = fistName;
      this.lastName = lastName;
      this._age = _age;
      this.dateOfBirth = dateOfBirth;
   }
}
{
 "fist-name": "Raja",
   "last-name": "Ramesh",
   "_age": 30,
   "date-of-birth": "1988-01-01"
}
How to set Line Border color and width with Java?

To set Line Border color and width, use the LineBorder. At first, set a panel wherein we need to set the line border −
JPanel panel = new JPanel();
Now, create a border and set on the panel created above −
Border border = new LineBorder(Color.ORANGE, 4, true);
panel.setBorder(border);
The following is an example to set LineBorder color and width −
package my;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
public class SwingDemo {
   public static void main(String[] args) {
      JFrame frame = new JFrame();
      JPanel panel = new JPanel();
      Border border = new LineBorder(Color.ORANGE, 4, true);
      panel.setBorder(border);
      String[][] rec = {
         { "1", "Steve", "AUS" },
         { "2", "Virat", "IND" },
         { "3", "Kane", "NZ" },
         { "4", "David", "AUS" },
         { "5", "Ben", "ENG" },
         { "6", "Eion", "ENG" },
      };
      String[] header = { "Rank", "Player", "Country" };
      JTable table = new JTable(rec, header);
      table.setShowHorizontalLines(true);
      table.setGridColor(Color.orange);
      table.setCellSelectionEnabled(true);
      panel.add(new JScrollPane(table));
      frame.add(panel);
      frame.setSize(550, 400);
      frame.setVisible(true);
   }
}
Redeclaration of global variable in C

Here we will see what is re-declaration of global variables in C. Does C supports this or not. Let us see the following code to get the idea about it.
#include <stdio.h>
int main(){
   int a;
   int a = 50;
   printf("a is : %d\n", a);
}
[Error] redeclaration of 'a' with no linkage
So we can see that we cannot re-declare local variables. Now let us see what will be the output for global variables.
#include <stdio.h>
int a;
int a = 50;
int main(){
   printf("a is : %d\n", a);
}
a is : 50
So global variables are not creating any error in this case. Now let us see if the first declaration is holding one value, then it can be re-declared or not?
#include <stdio.h>
int a = 10;
int a = 50;
int main(){
   printf("a is : %d\n", a);
}
[Error] redefinition of 'a'
So we can see that we can only re-declare global variables, when they are not initialized.
How to set the type of cursor to display for the mouse pointer with JavaScript?

To set the type of cursor, use the cursor property in JavaScript. It allows you to change the cursor on button click.
You can try to run the following code to set the type of cursor to display for the mouse pointer with JavaScript −
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <h1 id="myID">Heading 1</h1>
      <p>Check the heading before and after mouse hover.</p>
      <button type="button" onclick="display()">Click to change the cursor</button>
      <script>
         function display() {
            document.getElementById("myID").style.cursor = "pointer";
         }
      </script>
   </body>
</html>
Fibonacci series program in Java using recursion.

Following is the required program.
Live Demo
public class Tester {
   static int n1 = 0, n2 = 1, n3 = 0;
   static void fibbonacci(int count) {
      if (count > 0) {
         n3 = n1 + n2;
         n1 = n2;
         n2 = n3;
         System.out.print(" " + n3);
         fibbonacci(count - 1);
      }
   }
   public static void main(String args[]) {
      int count = 5;
      System.out.print(n1 + " " + n2);
      fibbonacci(count - 2);
   }
}
0 1 1 2 3
Python - Convert Strings to Uppercase in Dictionary value lists - GeeksforGeeks

01 Aug, 2020
Given dictionary with values list, convert all the strings to upper case.
Input : {“Gfg” : [“ab”, “cd”], “Best” : [“gh”], “is” : [“kl”]}Output : {‘Gfg’: [‘AB’, ‘CD’], ‘Best’: [‘GH’], ‘is’: [‘KL’]}Explanation : All value lists strings are converted to upper case.
Input : {“Gfg” : [“ab”, “cd”, “Ef”]}Output : {‘Gfg’: [‘AB’, ‘CD’, “EF”]}Explanation : All value lists strings are converted to upper case, already upper case have no effect.
Method #1 : Using dictionary comprehension + upper() + list comprehension
The combination of above functions can be used to solve this problem. In this, we perform upper case using upper(), list comprehension is used to iterate through all strings, dictionary comprehension is used to remake dictionary with upper case values.
Python3
# Python3 code to demonstrate working of # Convert Strings to Uppercase in Dictionary value lists# Using dictionary comprehension + upper() + list comprehension  # initializing dictionarytest_dict = {"Gfg" : ["ab", "cd", "ef"],             "Best" : ["gh", "ij"], "is" : ["kl"]}  # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # using upper to convert to upper case res = {key: [ele.upper() for ele in test_dict[key] ] for key in test_dict }  # printing result print("The dictionary after conversion " + str(res)) 
The original dictionary is : {‘Gfg’: [‘ab’, ‘cd’, ‘ef’], ‘Best’: [‘gh’, ‘ij’], ‘is’: [‘kl’]}The dictionary after conversion {‘Gfg’: [‘AB’, ‘CD’, ‘EF’], ‘Best’: [‘GH’, ‘IJ’], ‘is’: [‘KL’]}
Method #2 : Using map() + upper() + dictionary comprehension
The combination of above functions can be used to solve this problem. In this, we perform the task of extending logic of upper case using map() instead of list comprehension.
Python3
# Python3 code to demonstrate working of # Convert Strings to Uppercase in Dictionary value lists# Using map() + upper() + dictionary comprehension  # initializing dictionarytest_dict = {"Gfg" : ["ab", "cd", "ef"],             "Best" : ["gh", "ij"], "is" : ["kl"]}  # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # using map() to extend logic to all inner list res = {key: list(map(str.upper, test_dict[key])) for key in test_dict}  # printing result print("The dictionary after conversion " + str(res)) 
The original dictionary is : {‘Gfg’: [‘ab’, ‘cd’, ‘ef’], ‘Best’: [‘gh’, ‘ij’], ‘is’: [‘kl’]}The dictionary after conversion {‘Gfg’: [‘AB’, ‘CD’, ‘EF’], ‘Best’: [‘GH’, ‘IJ’], ‘is’: [‘KL’]}
Python dictionary-programs
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
MoviePy – Setting FPS of the Clip - GeeksforGeeks

30 Aug, 2020
In this article we will see how we can set fps of 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. Frame rate is the frequency at which consecutive images called frames appear on a display. The term applies equally to film and video cameras, computer graphics, and motion capture systems. Frame rate may also be called the frame frequency, and be expressed in hertz.
In order to do this we will use set_fps method with the VideoFileClip object
Syntax : clip.set_fps(n)
Argument : It takes integer value as argument
Return : It returns VideoFileClip object
Below is the implementation
# Import everything needed to edit video clips from moviepy.editor import *    # loading video dsa gfg intro video clip = VideoFileClip("dsa_geek.mp4")      # getting only first 5 secondsclip = clip.subclip(0, 5)  # new clip with new fpsnew_clip = clip.set_fps(5)  # displaying new clipnew_clip.ipython_display(width = 360)
Output :
Moviepy - Building video __temp__.mp4.
Moviepy - Writing video __temp__.mp4

                                                                                                                       
Moviepy - Done !
Moviepy - video ready __temp__.mp4

# 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)  # new clip with new fpsnew_clip = clip.set_fps(100)  # displaying new clipnew_clip.ipython_display(width = 360)
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.
Comments
Old Comments
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
Iterate over a list in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
Create a Pandas DataFrame from Lists
Reading and Writing to text files in Python
Selecting rows in pandas DataFrame based on conditions
How to Install Java Applet Viewer on Linux? - GeeksforGeeks

17 Dec, 2021
Applet viewer is a command-line program to run a java applet. It helps you to test an applet before you run it in the browser. The applet’s code gets transferred to the system & then the Java Virtual Machine (JVM) of the browser & executes that code.
In this article, we will look into the process of installing a Java Applet Viewer on Linux.
Follow the below steps to install Java Applet Viewer on Linux:
Step 1: For installing Java Applet Viewer, you need to first download Java JDK 8. Because Java gives applet only up to JDK version 9 only.
Step 2: Open Terminal and execute the below command:
 sudo apt install openjdk-8-jdk openjdk-8-jre 
This command will install Java JDK 8. Or if you already installed it, it will give the following output.
Step 3: Write a sample applet code. You can write the following code also. Save it by the name Demo.java in a folder which name is also Java.
Java
import java.awt.*;import java.applet.*;  public class Demo extents Applet{  public void init()  {        setForeground(Color.white);        setBackground(Color.blue);  }  public void paint(Graphics g)  {    g.drawString("Welcome To Java Applet",40,50);  }}
Step 4: Write the following commands one by one to execute the applet program.
cd Java/
ls
Demo.class Demo.java
javac Demo.java
appletviewer Demo.java
Step 5: As a result, the program will be executed & give output.
Hence Java Applet Viewer is successfully installed.
how-to-install
Picked
How To
Installation Guide
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install FFmpeg on Windows?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Set Git Username and Password in GitBash?
How to create a nested RecyclerView in Android
How to Create and Setup Spring Boot Project in Eclipse IDE?
Installation of Node.js on Linux
How to Install FFmpeg on Windows?
How to Install Pygame on Windows ?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Install Jupyter Notebook on MacOS?