code-rag-bench/online-tutorials huggingface dataset:
Why error “$ is not defined” occurred in jQuery ?

07 Nov, 2020
One of the most common errors faced by jQuery developers is the ‘$ is not defined’ error. At first, it may seem like a small error, but considering the fact that more than 70 percent of the website uses jQuery in some form or other, this may turn out to create a huge mess.
Reason behind this error: This error basically arises, when the developer is using a variable, before declaring it in the script. 
Example:  
Javascript
// ReferenceError: num is not definednum; declarationvar num; // No more errorsdata;
Output:  
In the above example, we see that ‘num’ has been called before it was declared. This is why ReferenceError: num is not defined was thrown in the first line. In the third line, ‘num’ is called again. However, no error will be thrown this time, as the variable has already been defined in the second line of the script.
This is a very common error. The best way to avoid this is to hoist all the variables and functions before calling them. Have a look at another example. 
Example:  
Javascript
//reference errorprocess(); process = function(){var a = 2;console.log(a);} // no errorprocess();
Output:  
Most common reasons for this error: 
Embedding jQuery plugin before the jQuery script file ‘$’ is used to declare any variable in jQuery. A plug-in is basically a code chunk written beforehand. These chunks use predefined jQuery functions and methods. Therefore, it is necessary to embed the jQuery script file before the plugin file. Otherwise, the application won’t understand the jQuery coding.
Correct Order: 
Javascript
<script src="/lib/jquery.min.js"></script><script src="/lib/jquery.plugin.js"></script>
CDN hosted jQuery problem: It is possible that the CDN hosted jQuery version, used for the website, might have been blocked on the customer’s connection. This type of issue is generally observed on IP addresses originating from countries like China, Indonesia, Korea, etc. To avoid this issue, it is better to provide a locally-hosted fallback version of jQuery.
Example: 
Javascript
//an external CDN link<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> //fall back to local jQuery<script>window.jQuery || document.write('<script src="http://www.mywebsite.com/jquery.min.js"><\/script>'))</script>
 
Akanksha_Rai
Vijay Sirra
jQuery-Basics
Picked
JQuery
Technical Scripter
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to get the value in an input text box using jQuery ?
jQuery | ajax() Method
How to prevent Body from scrolling when a modal is opened using jQuery ?
jQuery | removeAttr() with Examples
jQuery | parent() & parents() with Examples
Installation of Node.js on Linux
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 ?
Functions that accept variable length key value pair as arguments

13 Aug, 2021
To pass a variable-length key-value pair as an argument to a function, Python provides a feature called **kwargs.kwarg stands for Keyword arguments. It proves to be an efficient solution when one wants to deal with named arguments in their function.
Syntax:
def functionName(**anything):
    statement(s)
Note: adding ‘**‘ to any term makes it a kwarg parameter. It accepts keywords as arguments. 
Example #1: 
Python3
# using kwargs# in functions  def printKwargs(**kwargs):    print(kwargs)  # driver codeif __name__ == "__main__":    printKwargs(Argument_1='gfg', Argument_2='GFG')
Output:
{'Argument_1': 'gfg', 'Argument_2': 'GFG'}
Example #2:
Python3
# using kwargs# in functions  def printValues(**kwargs):    for key, value in kwargs.items():        print("The value of {} is {}".format(key, value))  # driver codeif __name__ == '__main__':    printValues(abbreviation="GFG", full_name="geeksforgeeks")
Output:
The value of abbreviation is GFG
The value of full_name is geeksforgeeks
Example #3:
Python3
# using kwargs# in functions# to concatenate  def concatenate(**arguments):    # initialising empty string    final_str = ""         # Iterating over the Python kwargs    # dictionary    for elements in arguments.values():        final_str += elements    return final_str  # driver codeif __name__ == '__main__':    print(concatenate(a="g", b="F", c="g"))
Output:
gFg
Example #4:
Python3
# using kwargs# to multiply  def multiply(**kwargs):       # initialising answer    answer = 1         # Iterating over the Python kwargs    # dictionary    for elements in kwargs.values():        answer *= elements    return answer  # driver codeif __name__ == '__main__':    print(multiply(a=1, b=2, c=3, d=4, e=5))
Output:
120
sweetyty
Python function-programs
Python-Functions
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 | os.path.join() method
Python OOPs Concepts
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
How can we grant privileges to a MySQL user?

We need to grant privileges to the new user which we have created because the new user would not have privileges. We can use GRANT statement to grant privileges to the user account. Its syntax would be as follows −
GRANT privilege,[privilege],.. ON privilege_level
TO user [IDENTIFIED BY password]
[REQUIRE tsl_option]
[WITH [GRANT_OPTION | resource_option]];
Explanation of the above syntax is as follows −
First, specify one or more privileges after the GRANT keyword. If we grant the user multiple privileges, each privilege is separated by a comma.
Next, specify the privilege_level that determines the level at which the privileges apply. MySQL supports global ( *.*), database ( database.*), table ( database.table) and column levels. If we use column privilege level, we must specify one or a list of the comma-separated column after each privilege.
Then, place the user that we want to grant privileges. If the user already exists, the GRANTstatement modifies its privilege. Otherwise, the GRANT statement creates a new user. The optional clause IDENTIFIED BY allows us to set a new password for the user.
After that, we specify whether the user has to connect to the database server over a secure connection such as SSL, X059, etc.
Finally, the optional WITH GRANT OPTION clause allows us to grant other users or remove from other users the privileges that we possess. In addition, we can use the WITH clause to allocate MySQL database server’s resource e.g., to set how many connections or statements that the user can use per hour. This is very helpful in the shared environments such as MySQL shared hosting.
In the example below we are creating a user and granting privileges to it −
mysql> use mysql
Database changed
mysql> create user abcd@localhost identified by 'password123';
Query OK, 0 rows affected (0.04 sec)
The query below will give us the privileges for the new user account abcd@localhost.
mysql> SHOW GRANTS FOR abcd@localhost;
+------------------------------------------+
| Grants for abcd@localhost                |
+------------------------------------------+
| GRANT USAGE ON *.* TO 'abcd'@'localhost' |
+------------------------------------------+
1 row in set (0.01 sec)
Now, to grant all the privileges to the abcd@localhost user account, we can use the following statement −
mysql> GRANT ALL ON *.* TO 'abcd'@'localhost' WITH GRANT OPTION;
Query OK, 0 rows affected (0.05 sec)
Here, the ON *.* clause means all databases and all objects in the databases. The WITH GRANT OPTION allows abcd@localhost to grant privileges to other users.
Now if we will use the SHOW GRANTS statement again, we will see that the privileges of abcd@localhost have been updated.
mysql> SHOW GRANTS FOR abcd@localhost;
+---------------------------------------------------------------------+
| Grants for abcd@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'abcd'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
1 row in set (0.00 sec)
Python Program for Tower of Hanoi

16 Jun, 2022
Tower of Hanoi is a mathematical puzzle where we have three rods and n disks. The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules: 1) Only one disk can be moved at a time. 2) Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack i.e. a disk can only be moved if it is the uppermost disk on a stack. 3) No disk may be placed on top of a smaller disk.Note: Transferring the top n-1 disks from source rod to Auxiliary rod can again be thought of as a fresh problem and can be solved in the same manner. 
 
Python3
# Recursive Python function to solve the tower of hanoi def TowerOfHanoi(n , source, destination, auxiliary):    if n==1:        print ("Move disk 1 from source",source,"to destination",destination)        return    TowerOfHanoi(n-1, source, auxiliary, destination)    print ("Move disk",n,"from source",source,"to destination",destination)    TowerOfHanoi(n-1, auxiliary, destination, source)         # Driver coden = 4TowerOfHanoi(n,'A','B','C')# A, C, B are the name of rods # Contributed By Dilip Jain
Move disk 1 from source A to destination C
Move disk 2 from source A to destination B
Move disk 1 from source C to destination B
Move disk 3 from source A to destination C
Move disk 1 from source B to destination A
Move disk 2 from source B to destination C
Move disk 1 from source A to destination C
Move disk 4 from source A to destination B
Move disk 1 from source C to destination B
Move disk 2 from source C to destination A
Move disk 1 from source B to destination A
Move disk 3 from source C to destination B
Move disk 1 from source A to destination C
Move disk 2 from source A to destination B
Move disk 1 from source C to destination B
Time Complexity: O(2n)
Auxiliary Space: O(n)
Please refer complete article on Program for Tower of Hanoi for more details! 
dilipjain0504
nidhi_biet
amartyaghoshgfg
chandramauliguptach
Python DSA-exercises
Python-Data-Structures
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | os.get_terminal_size() method

26 May, 2019
OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.
os.get_terminal_size() method in Python is used to query the size of a terminal. This method returns the size of a terminal as a pair columns and lines. Here, columns represents width of the terminal window in characters and lines represents height of the terminal window in characters.
Syntax: os.get_terminal_size(fd = STDOUT_FILENO)
Parameter:fd (optional): A file descriptor. It specifies which file descriptor should be queried. The default value of fd parameter is STDOUT_FILENO or standard output.
Return Type: This method returns a object of class ‘os.terminal_size’ which holds columns and lines attributes.
Code: Use of os.get_terminal_size() method
# Python program to explain os.get_terminal_size() method     # importing os module import os  # Get the size# of the terminalsize = os.get_terminal_size()    # Print the size# of the terminalprint(size)
os.terminal_size(columns=80, lines=24)

python-os-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
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
Convert integer to string in Python
Find the number of occurrences of a sequence in a NumPy array

05 Sep, 2020
The sequence is consisting of some elements in the form of a list and we have to find the number of occurrences of that sequence in a given NumPy array. This can be done easily by checking the sequence for every iteration of ndarray. But this leads to higher time so we use the concept of NumPy methods.
Example :
Arr = [[2,8,9,4],
       [9,4,9,4],
       [4,5,9,7],
       [2,9,4,3]]
and the seq = [9,4] then output is 4.

Here, 
first row [2,8,9,4] 
contains one [9,4] sequence so output = 1.

second row [9,4,9,4] 
contains two [9,4] sequence so output = 1+2 = 3.

third row [4,5,9,7] 
contains no [9,4] sequence so output = 3+0 = 3.

fourth row [2,9,4,3] 
contains one [9,4] sequence so output = 3+1 = 4.
Below is the implementation with an example :
Python3
# importing packageimport numpy  # create numpy arrayarr = numpy.array([[2, 8, 9, 4],                    [9, 4, 9, 4],                   [4, 5, 9, 7],                   [2, 9, 4, 3]])  # Counting sequenceoutput = repr(arr).count("9, 4")  # view outputprint(output)
Output :
4

Python numpy-arrayManipulation
Python numpy-program
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | sympy.lambdify() method

25 Jun, 2019
With the help of sympy.lambdify() method, we can convert a SymPy expression to an expression that can be numerically evaluated. lambdify acts like a lambda function, except it, converts the SymPy names to the names of the given numerical library, usually NumPy or math.
Syntax: lambdify(variable, expression, library)
Parameters:variable – It is the variable in the mathematical expression.expression – It is the mathematical expression which is converted into its respective name in the given library.library – It is the Python library to which expression is to be converted into.
Returns: Returns a lambda function which can evaluate a mathematical expression.
Example #1:In this example we can see that by using sympy.lambdify() method, we can get a lambda function from a mathematical expression.
# import sympyfrom sympy import *   x = symbols('x')expr = sin(x)     # Use sympy.lambdify() methodf = lambdify(x, expr, "math")     print("Using lambda function in SymPy to evaluate sin(90) : {}".format(f(90))) 
Output:
Using lambda function in SymPy to evaluate sin(90) : 0.893996663601
Example #2:We can pass a dictionary of sympy_name:numerical_function pair to use lambdify with numerical libraries that it does not know about.
# import sympyfrom sympy import *   def squared(n) :     return n**2  x = symbols('x')expr = x**2     # Use sympy.lambdify() methodf = lambdify(x, expr, {"**" : squared})     print("Using lambda function in SymPy to evaluate squared function : {}".format(f(10))) 
Output:
Using lambda function in SymPy to evaluate squared function : 100

SymPy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
DAX Text - SEARCH function

Returns the number of the character at which a specific character or text string is first found, reading left to right.
Search is case insensitive and accent sensitive.
SEARCH (<find_text>, <within_text>, [<start_num>], <NotFoundValue>) 

find_text
The text that you want to find.
You can use the wildcard characters question mark (?) and asterisk (*) in find_text.
A question mark matches any single character and an asterisk matches any sequence of characters.
If you want to find an actual question mark or asterisk, type a tilde (~) before the character.
within_text
The text in which you want to search for find_text, or a column containing text.
start_num
Optional.
The character position in within_text at which you want to start searching.
If omitted, default is 1.
NotFoundValue
The value that should be returned when find_text is not found in within_text.
This can be any specific integer or BLANK ().
An integer, or Blank if specified as NotFoundValue.
DAX SEARCH function is case insensitive. Searching for "N" will find the first occurrence of 'N' or 'n'.
DAX SEARCH function is case insensitive. Searching for "N" will find the first occurrence of 'N' or 'n'.
DAX SEARCH function is accent sensitive. Searching for "á" will find the first occurrence of 'á' but not any of the occurrences of 'a', 'à', or the capitalized versions 'A', 'Á'.
DAX SEARCH function is accent sensitive. Searching for "á" will find the first occurrence of 'á' but not any of the occurrences of 'a', 'à', or the capitalized versions 'A', 'Á'.
You can use the SEARCH function to determine the location of a text string within another text string, and then use the MID function to return the text, or use the REPLACE function to change the text.
You can use the SEARCH function to determine the location of a text string within another text string, and then use the MID function to return the text, or use the REPLACE function to change the text.
If find_text cannot be found in within_text, DAX SEARCH function returns NotFoundValue, if given. If omitted, returns #ERROR.
If find_text cannot be found in within_text, DAX SEARCH function returns NotFoundValue, if given. If omitted, returns #ERROR.
Nulls in within_text will be interpreted as empty strings.
Nulls in within_text will be interpreted as empty strings.
= SEARCH ("Yes", "Yesterday",, BLANK()) returns 1. 
= SEARCH("yes","Yesterday") returns 1. 
= SEARCH ("no", "Yesterday",, BLANK()) returns (blank). 
= SEARCH("no","Yesterday") returns #ERROR. 
= MID("Yesterday",SEARCH("day","Yesterday"),2) returns da. 
= REPLACE("Yesterday",SEARCH("day","Yesterday"),3,"fff") returns Yesterfff.
Encrypt the String according to the given algorithm in Python

02 Jul, 2021
Given a string s, the task is to encrypt the string in the following way. Let the string be “apple”.
Step 1: Reverse the input: “elppa”
Step 2: Replace all vowels using the following chart:
a => 0
e => 1
i => 2
o => 2
u => 3
Resultant string - "1lpp0"
Step 3: Add “aca” to the end of the word:
Resultant String: "1lpp0aca"
Examples:
Input: banana
Output: 0n0n0baca"

Input: karaca
Output: 0c0r0kaca"

Input: burak
Output: k0r3baca
Approach:
Create a dictionary which stores values so that it can be easily accessed.Reverse the string by indexing method.Loop through the word to replace vowels.
Create a dictionary which stores values so that it can be easily accessed.
Reverse the string by indexing method.
Loop through the word to replace vowels.
Below is the implementation.
Python3
# Create an input fieldencrypt = "banana" # Create a dictionary to store keys# and valuesdict = {"a": "0", "e": "1",        "i": "2", "o": "2",        "u": "3"} # Reverse the stringnum = encrypt[::-1] # Replace vowels using loopsfor i in dict:    num = num.replace(i, dict[i]) # f- strings which improves readabilityprint(f"{num}aca")
Output:
0n0n0baca
Let’s understand the above code:
For indexing, through a string, we have a provision of three arguments. The indexing is done with integers (not float values) and intended with close brackets.
The first argument is for the starting point, the second argument is for jump though the sub-string and third argument is the endpoint.
So in the above reverse-string method, we keep the first argument empty , so the indexing would begin from the first sub-string , the second argument is left empty so there would be not jumping through sub-strings and endpoint would be -1 which would result in the compiler to manipulate and reverse the given input.
saurabh1990aror
python-string
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Iterate over a list in Python
Rotate axis tick labels in Seaborn and Matplotlib
Enumerate() in Python
Deque in Python
Stack in Python
Python Dictionary
sum() function in Python
Print lists in Python (5 Different Ways)
Different ways to create Pandas Dataframe
Queue in Python
How to create div dynamically using jQuery?

To create a div dynamically, use the html() method. You can try to run the following code to learn how to create a div dynamically on button click −
Live Demo
<!DOCTYPE html>
<html>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
      $("button").click(function(){
        $("body").html("<div>This is a new div.</div>");
      });
    });
</script>
</head>
<body>

  <button>Create a new div</button>

<p>This is demo text.</p>
</body>
</html>
Electron - System Tray

System tray is a menu outside of your application window. On MacOS and Ubuntu, it is located on the top right corner of your screen. On Windows it is on the bottom right corner. We can create menus for our application in system trays using Electron.
Create a new main.js file and add the following code to it. Have a png file ready to use for the system tray icon.
const {app, BrowserWindow} = require('electron')
const url = require('url')
const path = require('path')

let win

function createWindow() {
   win = new BrowserWindow({width: 800, height: 600})
   win.loadURL(url.format ({
      pathname: path.join(__dirname, 'index.html'),
      protocol: 'file:',
      slashes: true
   }))
}

app.on('ready', createWindow)
After having set up a basic browser window, we will create a new index.html file with the following content −
<!DOCTYPE html>
<html>
   <head>
      <meta charset = "UTF-8">
      <title>Menus</title>
   </head>
   <body>
      <script type = "text/javascript">
         const {remote} = require('electron')
         const {Tray, Menu} = remote
         const path = require('path')

         let trayIcon = new Tray(path.join('','/home/ayushgp/Desktop/images.png'))

         const trayMenuTemplate = [
            {
               label: 'Empty Application',
               enabled: false
            },
            
            {
               label: 'Settings',
               click: function () {
                  console.log("Clicked on settings")
               }
            },
            
            {
               label: 'Help',
               click: function () {
                  console.log("Clicked on Help")
               }
            }
         ]
         
         let trayMenu = Menu.buildFromTemplate(trayMenuTemplate)
         trayIcon.setContextMenu(trayMenu)
      </script>
   </body>
</html>
We created the tray using the Tray submodule. We then created a menu using a template and further attached the menu to our tray object.
Run the application using the following command −
$ electron ./main.js

When you run the above command, check your system tray for the icon you used. I used a smiley face for my application. The above command will generate the following output −

    251 Lectures 
     35.5 hours 

 Gowthami Swarna

    9 Lectures 
     41 mins

 Ashraf Said

    8 Lectures 
     32 mins

 Ashraf Said

    25 Lectures 
     1 hours 

 Ashraf Said

    17 Lectures 
     1 hours 

 Ashraf Said

    8 Lectures 
     25 mins

 Ashraf Said
 Print
 Add Notes
 Bookmark this page
Substring in C++

A substring is a part of a string. A function to obtain a substring in C++ is substr(). This function contains two parameters: pos and len. The pos parameter specifies the start position of the substring and len denotes the number of characters in a substring.
A program that obtains the substring in C++ is given as follows −
 Live Demo
#include <iostream>
#include <string.h>

using namespace std;
int main() {
   string str1 = "Apples are red";
   string str2 = str1.substr(11, 3);
   string str3 = str1.substr(0, 6);

   cout << "Substring starting at position 11 and length 3 is: " << str2 <<endl;
   cout << "Substring starting at position 0 and length 6 is: " << str3;
   return 0;
}
The output of the above program is as follows −
Substring starting at position 11 and length 3 is: red
Substring starting at position 0 and length 6 is: Apples
In the above program, str1 is declared as “Apples are red”. Then str2 stores the substring of str1 that starts at position 11 and is of length 3. Also, str3 stores the substring of str1 that starts at position 0 and is of length 6. This is given below −
string str1 = "Apples are red";
string str2 = str1.substr(11, 3);
string str3 = str1.substr(0, 6);
The contents of str2 and str3 are displayed. The code snippet for this is given as follows −
cout << "Substring starting at position 11 and length 3 is: " << str2 <<endl;
cout << "Substring starting at position 0 and length 6 is: " << str3;
3-6-9 in Python

Suppose we have a number n, we have to construct a list with each number from 1 to n, except when it is multiple of 3 or has a 3, 6, or 9 in the number, it should be the string "no-fill".
So, if the input is like 20, then the output will be ['1', '2', 'clap', '4', '5', 'clap', '7', '8', 'clap', '10', '11', 'clap', 'clap', '14', 'clap', 'clap', '17', 'clap', 'clap', '20']
To solve this, we will follow these steps −
string := "no-fill"
string := "no-fill"
ls:= make a list of numbers as string from 1 to n
ls:= make a list of numbers as string from 1 to n
for i in range 0 to size of ls - 1, doif ls[i] is divisible by 3, thenls[i]:= stringotherwise when '3' is present in ls[i], thenls[i]:= stringotherwise when '6' is present in ls[i], thenls[i]:= stringotherwise when '9' is present in ls[i], thenls[i]:= string
for i in range 0 to size of ls - 1, do
if ls[i] is divisible by 3, thenls[i]:= string
if ls[i] is divisible by 3, then
ls[i]:= string
ls[i]:= string
otherwise when '3' is present in ls[i], thenls[i]:= string
otherwise when '3' is present in ls[i], then
ls[i]:= string
ls[i]:= string
otherwise when '6' is present in ls[i], thenls[i]:= string
otherwise when '6' is present in ls[i], then
ls[i]:= string
ls[i]:= string
otherwise when '9' is present in ls[i], thenls[i]:= string
otherwise when '9' is present in ls[i], then
ls[i]:= string
ls[i]:= string
return ls
return ls
Let us see the following implementation to get better understanding −
 Live Demo
class Solution:
   def solve(self, n):
      string = "no-fill"
      ls=[str(i) for i in range(1,n+1)]
      for i in range(len(ls)):
         if int(ls[i])%3==0:
            ls[i]=string
         elif '3' in ls[i]:
            ls[i]=string
         elif '6' in ls[i]:
            ls[i]=string
         elif '9' in ls[i]:
            ls[i]=string
      return ls
ob = Solution()
print(ob.solve(20))
20
['1', '2', 'clap', '4', '5', 'clap', '7', '8', 'clap', '10', '11', 'clap', 'clap', '14', 'clap', 'clap', '17', 'clap', 'clap', '20']
Get Last Part of URL in PHP?

To get the last part of URL, use preg_match() in PHP. Let’s say the following is our input URL 
$websiteAddress='https://www.tutorialspoint.com/java/java_questions_answers/9989809898';
We need to get the following output, with only the last part, which is a number 
9989809898'
Following is the PHP code to get the last part of URL 
 Live Demo
<!DOCTYPE html>
<html>
<body>
<?php
$websiteAddress='https://www.tutorialspoint.com/java/java_questions_answers/9989809898';
if(preg_match("/\/(\d+)$/",$websiteAddress,$recordMatch)){
   $lastResult=$recordMatch[1];
}
echo "The result is as follows:",$lastResult;
?>
</body>
</html>
This will produce the following output
The result is as follows:82345999
Amplitude Modulation using MATLAB - GeeksforGeeks

29 May, 2021
Amplitude modulation (AM) is a modulation technique utilized in electronic communication, most ordinarily for transmitting data by means of a carrier wave. In amplitude modulation, the amplitude that is the signal quality of the carrier wave differs with respect to that of the message signal being transmitted. 
Amplitude modulation in MATLAB can be achieved by using the ammod() function.  
Syntax : y = ammod(x, Fc, Fs, ini_phase, carramp) Parameters :  
x : amplitude signal
Fc : carrier signal frequency
Fs : sampling frequency
ini_phase : initial phase in the modulated signal y in radians
carramp : carrier amplitude of the modulated signal
Returns : amplitude modulated (AM) signal  
Example: Amplitude modulation of a sine wave with only 3 parameters. 
MATLAB
% carrier FrequencyFc = 200; % sampling frequencyFs= 4000; % time Durationt = (0 : 1 / Fs : 1); % sine Wave with time duration of 't'x = sin(2*pi*t);  % Amplitude Modulationy = ammod(x, Fc, Fs); plot(y);title('Amplitude Modulation');xlabel('Time(sec)');ylabel('Amplitude');
Output :  
 
2019kuec2035
MATLAB
Programming Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Programming Languages to Learn in 2022
Shallow Copy and Deep Copy in C++
Decorators with parameters in Python
Difference between Shallow and Deep copy of a class
Kotlin Array
C# | Data Types
Advantages and Disadvantages of OOP
Java Swing | JComboBox with examples
Top 10 Fastest Programming Languages
Use of FLAG in programming
Google Guice - Binding Annotations

As we can bind a type with its implementation. In case we want to map a type with multiple implmentations, we can create custom annotation as well. See the below example to understand the concept.
@BindingAnnotation @Target({ FIELD, PARAMETER, METHOD }) @Retention(RUNTIME)
@interface WinWord {}
@BindingAnnotation - Marks annotation as binding annotation.

@BindingAnnotation - Marks annotation as binding annotation.
@Target - Marks applicability of annotation.

@Target - Marks applicability of annotation.
@Retention - Marks availablility of annotation as runtime.

@Retention - Marks availablility of annotation as runtime.
bind(SpellChecker.class).annotatedWith(WinWord.class).to(WinWordSpellCheckerImpl.class);
@Inject
public TextEditor(@WinWord SpellChecker spellChecker) {
   this.spellChecker = spellChecker;
}
Create a java class named GuiceTester.
GuiceTester.java
import java.lang.annotation.Target;

import com.google.inject.AbstractModule;
import com.google.inject.BindingAnnotation;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;

import java.lang.annotation.Retention;

import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;

@BindingAnnotation @Target({ FIELD, PARAMETER, METHOD }) @Retention(RUNTIME)
@interface WinWord {}

public class GuiceTester {
   public static void main(String[] args) {
      Injector injector = Guice.createInjector(new TextEditorModule());
      TextEditor editor = injector.getInstance(TextEditor.class);
      editor.makeSpellCheck();     
   } 
}

class TextEditor {
   private SpellChecker spellChecker;   

   @Inject
   public TextEditor(@WinWord SpellChecker spellChecker) {
      this.spellChecker = spellChecker;
   }

   public void makeSpellCheck(){
      spellChecker.checkSpelling(); 
   } 
}

//Binding Module
class TextEditorModule extends AbstractModule {

   @Override
   protected void configure() {
      bind(SpellChecker.class).annotatedWith(WinWord.class)
         .to(WinWordSpellCheckerImpl.class);    
   } 
}

//spell checker interface
interface SpellChecker {
   public void checkSpelling();
}

//spell checker implementation
class SpellCheckerImpl implements SpellChecker {

   @Override
   public void checkSpelling() {
      System.out.println("Inside checkSpelling." );
   } 
}

//subclass of SpellCheckerImpl
class WinWordSpellCheckerImpl extends SpellCheckerImpl{
   @Override
   public void checkSpelling() {
      System.out.println("Inside WinWordSpellCheckerImpl.checkSpelling." );
   } 
}
Compile and run the file, you will see the following output.
Inside WinWordSpellCheckerImpl.checkSpelling.


    27 Lectures 
     1.5 hours 

 Lemuel Ogbunude
 Print
 Add Notes
 Bookmark this page
How to remove certain number elements from an array in JavaScript

We are required to write a function that takes in an array of numbers and a number, and it
should remove all the occurrences of that number from the array inplace.
Let’s write the code for this function.
We will make use of recursion to remove elements here. The recursive function that removes all
occurrences of an element from an array can be written like.
const numbers = [1,2,0,3,0,4,0,5];
const removeElement = (arr, element) => {
   if(arr.indexOf(element) !== -1){
      arr.splice(arr.indexOf(element), 1);
      return removeElement(arr, element);
   };
   return;
};
removeElement(numbers, 0);
console.log(numbers);
The output in the console will be −
[ 1, 2, 3, 4, 5 ]
HTML DOM Input Text readOnly property

The HTML DOM Input Text readOnly property is used for setting or returning if the input text field is read-only or not. The readOnly property makes the element non-editable but it can still be focused by tab or click. If there is a default value inside a read-only element then it is sent to a server on submit.
Following is the syntax for −
Setting the readOnly property −
textObject.readOnly = true|false
Here, truly represents the text field is read-only while false represents otherwise. The readOnly property is set to false by default.
Let us look at an example for the Input Text readOnly property −
<!DOCTYPE html>
<html>
<body>
<h1>Input Text readOnly property</h1>
USERNAME: <input type="text" id="USR" >
<p>Change the readOnly property of the above field by clicking the below button</p>
<button onclick="changeRead()">CHANGE</button>
<script>
   function changeRead() {
      document.getElementById("USR").readOnly = true;
   }
</script>
</body>
</html>
This will produce the following output −
On clicking the CHANGE button you can’t change the text now and it will be submitted to the server on submit −
Create linked list from a given array in C++ Program

In this tutorial, we are going to learn how to create a linked list from the given array.
Let's see the steps to solve the problem.
Initialize the array with dummy data.
Initialize the array with dummy data.
Write the struct node.
Write the struct node.
Iterate over the array.Create a new node with the data.Insert the new node into the linked list.
Iterate over the array.
Create a new node with the data.
Create a new node with the data.
Insert the new node into the linked list.
Insert the new node into the linked list.
Print the linked list.
Print the linked list.
Let's see the code.
#include <bits/stdc++.h>
using namespace std;
struct Node {
   int data;
   Node* next;
};
struct Node* newNode(int data) {
   Node* node = new Node;
   node->data = data;
   node->next = NULL;
   return node;
}
void insertNewNode(Node** root, int data) {
   Node* node = newNode(data);
   Node* ptr;
   if (*root == NULL) {
      *root = node;
   }
   else {
      ptr = *root;
      while (ptr->next != NULL) {
         ptr = ptr->next;
      }
      ptr->next = node;
   }
}
void printLinkedList(Node* root) {
   while (root != NULL) {
      cout << root->data << " -> ";
      root = root->next;
   }
   cout << "NULL" << endl;
}
Node* createLinkedList(int arr[], int n) {
   Node *root = NULL;
   for (int i = 0; i < n; i++) {
      insertNewNode(&root, arr[i]);
   }
   return root;
}
int main() {
   int arr[] = { 1, 2, 3, 4, 5 }, n = 5;
   Node* root = createLinkedList(arr, n);
   printLinkedList(root);
   return 0;
}
If you run the above code, then you will get the following result.
1 -> 2 -> 3 -> 4 -> 5 -> NULL
If you have any queries in the tutorial, mention them in the comment section.
How do I delete blank rows in MySQL?

Use the delete command to delete blank rows in MySQL.
The syntax is as follows
delete from yourTableName where yourColumnName=' ' OR yourColumnName IS NULL;
The above syntax will delete blank rows as well as NULL row.
To understand the concept, let us create a table.The query to create a table is as follows
mysql> create table deleteRowDemo
   -> (
   -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> StudentName varchar(20)
   -> );
Query OK, 0 rows affected (0.57 sec)
Insert some records in the table using insert command.
The query is as follows
mysql> insert into deleteRowDemo(StudentName) values('John');
Query OK, 1 row affected (0.13 sec)
mysql> insert into deleteRowDemo(StudentName) values('');
Query OK, 1 row affected (0.18 sec)
mysql> insert into deleteRowDemo(StudentName) values('');
Query OK, 1 row affected (0.14 sec)
mysql> insert into deleteRowDemo(StudentName) values(NULL);
Query OK, 1 row affected (0.13 sec)
mysql> insert into deleteRowDemo(StudentName) values('Carol');
Query OK, 1 row affected (0.13 sec)
mysql> insert into deleteRowDemo(StudentName) values('Bob');
Query OK, 1 row affected (0.14 sec)
mysql> insert into deleteRowDemo(StudentName) values('');
Query OK, 1 row affected (0.18 sec)
mysql> insert into deleteRowDemo(StudentName) values('David');
Query OK, 1 row affected (0.35 sec)
Display all records from the table using select statement.
The query is as follows
mysql> select *from deleteRowDemo;
The following is the output
+----+-------------+
| Id | StudentName |
+----+-------------+
| 1  | John        |
| 2  |             |
| 3  |             |
| 4  | NULL        |
| 5  | Carol       |
| 6  | Bob         |
| 7  |             |
| 8  | David       |
+----+-------------+
8 rows in set (0.00 sec)
Here is the query to delete blank rows as well as NULL
mysql> delete from deleteRowDemo where StudentName='' OR StudentName IS NULL;
Query OK, 4 rows affected (0.18 sec)
Now let us check the table records once again.
The query is as follows
mysql> select *from deleteRowDemo;
The following is the output
+----+-------------+
| Id | StudentName |
+----+-------------+
| 1  | John        |
| 5  | Carol       |
| 6  | Bob         |
| 8  | David       |
+----+-------------+
4 rows in set (0.00 sec)
Python | os.fsencode() method - GeeksforGeeks

20 Jun, 2019
OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.
os.fsencode() method in Python is used to encode the specified filename to the filesystem encoding with ‘surrogateescape‘ error handler, or ‘strict‘ on Windows;
Syntax: os.fsencode(filename)
Parameter:filename: A path-like object representing a file system path. A path-like object is either a str or bytes object representing a path.
Return Type: This method returns a bytestring which represents the encoded filename.
Code: use of os.fsencode() method
# Python program to explain os.fsencode() method     # importing os module import os  # Filenamefilename = "/home/user/File.txt"  # Encode the filename# to the filesystem encoding   # with 'surrogateescape' error handler,# or 'strict' (On Windows)encode = os.fsencode(filename)  # Print the encoded filenameprint(encode)  # The encode filename can be # decoded using os.fsdecode() methodprint(os.fsdecode(encode))
Encoded filename: b'/home/user/F\xc3\x8e\xe2\x95\x9a\xc3\x88.txt'
/home/user/FÎ?È.txt

Reference: https://docs.python.org/3/library/os.html#os.fsencode
python-os-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
How to Install PIP on Windows ?
Read a file line by line in Python
Different ways to create Pandas Dataframe
Reading and Writing to text files in Python
Python OOPs Concepts
Create a Pandas DataFrame from Lists
*args and **kwargs in Python
How to drop one or multiple columns in Pandas Dataframe
Python String | replace()
Find the Difference in C++

Suppose we have two strings s and t which consist of only lowercase letters. Now, string t is generated by random shuffling string s and then add one more letter at a random index. We have to find the letter that was added in t.
So, if the input is like "mnopq","pqmnot", then the output will be "t", this is the extra letter.
To solve this, we will follow these steps −
sSum := 0, tSum := 0
sSum := 0, tSum := 0
for initialize i := 0, when i < call length() of s, update (increase i by 1), do −sSum := sSum + s[i]
for initialize i := 0, when i < call length() of s, update (increase i by 1), do −
sSum := sSum + s[i]
sSum := sSum + s[i]
for initialize j := 0, when j < call length() of t, update (increase j by 1), do −tSum := tSum + t[j]
for initialize j := 0, when j < call length() of t, update (increase j by 1), do −
tSum := tSum + t[j]
tSum := tSum + t[j]
return (tSum - sSum) as character
return (tSum - sSum) as character
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
   char findTheDifference(string s, string t) {
      int sSum = 0;
      int tSum = 0;
      for (int i = 0; i < s.length(); i++) {
         sSum += s[i];
      }
      for (int j = 0; j < t.length(); j++) {
         tSum += t[j];
      }
      return char(tSum - sSum);
   }
};
main(){
   Solution ob;
   cout << (ob.findTheDifference("mnopq","pqmnot"));
}
"mnopq","pqmnot"
Output
t
How to append objects in a list in Python?

To add a single element to a list in Python at the end, you can simply use the append() method. It accepts one object and adds that object to the end of the list on which it is called. 
my_list = [2, 3, 1, -4, -1, -4]
my_list.append(8)
print(my_list)
This will give the output −
[2, 3, 1, -4, -1, -4, 8]
If you want to insert an element at a given position, use the insert(pos, obj) method. It accepts one object and adds that object at the position pos of the list on which it is called. 
my_list = [2, 3, 1, -4, -1, -4]
my_list.insert(1, 0)
print(my_list)
This will give the output −
[2, 0, 3, 1, -4, -1, -4]
You can also concatenate 2 lists using the extend method. It accepts one list and adds all objects of that list to the end of the list on which it is called. 
my_list = [2, 3, 1, -4, -1, -4]
another_list = ["a", "b"]
my_list.extend(another_list)
print(my_list)
This will give the output −
[2, 3, 1, -4, -1, -4, "a", "b"]
MySQL query error with a table named “order”?

The order is a reserved word. To still use a reserved word, you need to use backticks around the column name. Let us first create a table −
mysql> create table `order`
   -> (
   -> StudentId int
   -> );
Query OK, 0 rows affected (1.78 sec)
Insert some records in the table using insert command −
mysql> insert into `order` values(101);
Query OK, 1 row affected (0.26 sec)
mysql> insert into `order` values(210);
Query OK, 1 row affected (0.18 sec)
mysql> insert into `order` values(190);
Query OK, 1 row affected (0.28 sec)
mysql> insert into `order` values(180);
Query OK, 1 row affected (0.46 sec)
mysql> insert into `order` values(205);
Query OK, 1 row affected (0.28 sec)
Display all records from the table using select statement −
mysql> select *from `order`;
This will produce the following output −
+-----------+
| StudentId |
+-----------+
|       101 |
|       210 |
|       190 |
|       180 |
|       205 |
+-----------+
5 rows in set (0.00 sec)
Here is the query to use ‘order’ as table name using backticks −
mysql> select *from `order` order by StudentId desc limit 1;
This will produce the following output −
+-----------+
| StudentId |
+-----------+
|       210 |
+-----------+
1 row in set (0.03 sec)
Assertions in C#

Assert statements are an effective way to catch program logic errors at runtime. It has two arguments −
A boolean expression for a true condition, and
What to display in case of false.
Assertions are useful in large and complex programs to quickly flush out errors that generally arise when the code is modified. Avoid using any function call inside the assert method.
You need to be sure that whatever code you add inside an Assert should not change the output if it is removed. This is when you implement Debug. Assert in your program.
To implement it, you can use a temporary variable −
int temp= DecCounter(d);
Debug.Assert(temp !=0);
Above, the call to the counter will decrement the value. We have used the temp variable because Release Version eliminates the call when Assert is used. This can create a bug in the code, therefore better way is to use temp.
Collections.UserDict in Python - GeeksforGeeks

01 Oct, 2021
An unordered collection of data values that are used to store data values like a map is known as Dictionary in Python. Unlike other Data Types that hold only a single value as an element, Dictionary holds key:value pair. Key-value is provided in the dictionary to make it more optimized.
Note: For more information, refer to Python Dictionary
Python supports a dictionary like a container called UserDict present in the collections module. This class acts as a wrapper class around the dictionary objects. This class is useful when one wants to create a dictionary of their own with some modified functionality or with some new functionality. It can be considered as a way of adding new behaviors to the dictionary. This class takes a dictionary instance as an argument and simulates a dictionary that is kept in a regular dictionary. The dictionary is accessible by the data attribute of this class.
Syntax: 
collections.UserDict([initialdata])
Example 1:
Python3
# Python program to demonstrate# userdict  from collections import UserDict  d = {'a':1,    'b': 2,    'c': 3} # Creating an UserDictuserD = UserDict(d)print(userD.data)  # Creating an empty UserDictuserD = UserDict()print(userD.data)
Output:
{'a': 1, 'b': 2, 'c': 3}
{}
Example 2: Let’s create a class inheriting from UserDict to implement a customized dictionary.
Python3
# Python program to demonstrate# userdict   from collections import UserDict   # Creating a Dictionary where# deletion is not allowedclass MyDict(UserDict):         # Function to stop deletion    # from dictionary    def __del__(self):        raise RuntimeError("Deletion not allowed")             # Function to stop pop from    # dictionary    def pop(self, s = None):        raise RuntimeError("Deletion not allowed")             # Function to stop popitem    # from Dictionary    def popitem(self, s = None):        raise RuntimeError("Deletion not allowed")     # Driver's coded = MyDict({'a':1,    'b': 2,    'c': 3}) print("Original Dictionary")print(d) d.pop(1)
Output:
Original Dictionary
{'a': 1, 'c': 3, 'b': 2}
Traceback (most recent call last):
  File "/home/3ce2f334f5d25a3e24d10d567c705ce6.py", line 35, in 
    d.pop(1)
  File "/home/3ce2f334f5d25a3e24d10d567c705ce6.py", line 20, in pop
    raise RuntimeError("Deletion not allowed")
RuntimeError: Deletion not allowed
Exception ignored in: 
Traceback (most recent call last):
  File "/home/3ce2f334f5d25a3e24d10d567c705ce6.py", line 15, in __del__
RuntimeError: Deletion not allowed
 
sooda367
gabaa406
Python collections-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
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()
How to write into a file from command line using Python?

In order to write to a file from command line using Python, the script you want to use for it needs to accept a CLI argument.
For example, you want to write a program that appends "Hello" to any file it opens:
import sys
with open(sys.argv[1], 'a') as f:
    f.write("Hello")
If you save this file as cat.py and run it using:
$ python cat.py my_file.txt
Then open my_file.txt, you'll see at the end, Hello is written. The above command will take the my_file.txt and pass it to cat.py as a CLI argument in variable argv[1](second command line argument) which we can use to get the file and read/write to it.