code-rag-bench/online-tutorials huggingface dataset:
Integer doubleValue() Method in Java - GeeksforGeeks

07 Jul, 2018
The doubleValue() method of Integer class of java.lang package is used to convert the value of the given Integer to a Double type after a widening primitive conversion and returns it.
Syntax:
public double doubleValue()
Parameters: The method does not take any parameter.
Return Value: This method returns a numeric value represented by this object after conversion to double type.
Below programs illustrate java.lang.Integer.doubleValue() method.Program 1:
// Code to illustrate doubleValue() methodimport java.lang.Integer;  class Gfg {      // Driver code    public static void main(String args[])    {        Integer a = new Integer(14);          // Convert Integer number to double value        double b = a.doubleValue();          System.out.println(b);    }}
14.0

Program 2:
// Code to illustrate doubleValue() methodimport java.lang.Integer;  class Gfg {      // Driver code    public static void main(String args[])    {        Integer a = new Integer(120);          // Convert Integer number to double value        double b = a.doubleValue();          System.out.println(b);    }}
120.0

Java-Functions
Java-Integer
Java-lang package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
Stream In Java
HashMap in Java with Examples
Interfaces in Java
How to iterate any Map in Java
Initialize an ArrayList in Java
ArrayList in Java
Stack Class in Java
Singleton Class in Java
Multidimensional Arrays in Java
Tryit Editor v3.7

CSS Style Images
Tryit: Image hover - Fade in text
Tryit Editor v3.7

Tryit: JavaScript - change style
How to align checkbutton in ttk to the left side?

To align the checkbuttons to left, you can use the anchor parameter and set it to "w" (west). Let's take an example and see how to do it.
Import the tkinter library and create an instance of tkinter frame.
Import the tkinter library and create an instance of tkinter frame.
Set the size of the frame using geometry method.
Set the size of the frame using geometry method.
Create a LabelFrame to collect the checkbuttons in a group.
Create a LabelFrame to collect the checkbuttons in a group.
Next, create a checkbutton inside the LabelFrame and set its anchor to the West. anchor='w'.
Next, create a checkbutton inside the LabelFrame and set its anchor to the West. anchor='w'.
Similarly, create three more checkbuttons with their anchor set at West. It will align all the checkbuttons to the left.
Similarly, create three more checkbuttons with their anchor set at West. It will align all the checkbuttons to the left.
Finally, run the mainloop of the application window.
Finally, run the mainloop of the application window.
from tkinter import *

root = Tk()
root.geometry("700x350")

# Create a LabelFrame
frame = LabelFrame(root, text="Select the Subjects", padx=20, pady=20)
frame.pack(pady=20, padx=10)

# Create four checkbuttons inside the frame
C1 = Checkbutton(frame, text="Mathematics", width=200, anchor="w").pack()

C2 = Checkbutton(frame, text = "Physics", width=200, anchor="w").pack()

C3 = Checkbutton(frame, text = "Chemistry", width=200, anchor="w").pack()

C4 = Checkbutton(frame, text = "Biology", width=200, anchor="w").pack()

root.mainloop()
On execution, it will produce the following output −
How to draw a log-normalized imshow plot with a colorbar representing the raw data in Matplotlib?

To draw a log-normalized imshow() plot with a colorbar representing the raw data in matplotlib, we can
take the following steps −
Create a 2D array using numpy.
Display the data as an image, i.e., on a 2D regular raster, using imshow() method
Create a colorbar for a ScalarMappable instance, *mappable*, using imshow() method.
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt, cm
from matplotlib import colors
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
data = np.random.rand(4, 4)
im = plt.imshow(data, cmap=cm.rainbow, norm=colors.LogNorm())
plt.colorbar(im)
plt.show()
Python program to get all subsets of given size of a set

In this article, we will learn about the solution to the problem statement given below.
Problem statement − We are given two integers, we need to display the common divisors of two numbers
Here we are computing the minimum of the two numbers we take as input. A loop to calculate the divisors by computed by dividing each value from 1 to the minimum computed.
Each time the condition is evaluated to be true counter is incremented by one.
Now let’s observe the concept in the implementation below−
# built-in module
import itertools
def findsubsets(str_, n):
   return list(itertools.combinations(s, n))
# Driver Code
str_ = {'t','u','t','o','r'}
n = 2
print(findsubsets(str_, n))
[('u', 'r'), ('u', 'o'), ('u', 't'), ('r', 'o'), ('r', 't'), ('o',
't')]
# using combinations function in itertools
from itertools import combinations
def findsubsets(str_, n):
   return list(map(set, itertools.combinations(s, n)))
str_ = {'t','u','t','o','r'}
n = 3
print(findsubsets(str_, n))
[{'u', 'o', 'r'}, {'u', 'r', 't'}, {'u', 'o', 't'}, {'o', 'r', 't'}]
# using combinations function in itertools and appending in a new list
def findsubsets(str_, n):
   return [set(i) for i in itertools.combinations(s, n)]
str_ = {'t','u','t','o','r'}
n = 3
print(findsubsets(str_, n))
[{'u', 'o', 'r'}, {'u', 'r', 't'}, {'u', 'o', 't'}, {'o', 'r', 't'}]
All the variables are declared in the local scope and their references are seen in the figure above.
In this article, we have learned about python object comparison by using equality & the referencing operator(is).
Combine two arrays in C#

Firstly, declare and initialize two arrays −
int[] arr1 = { 37, 45, 65 };
int[] arr2 = { 70, 89, 118 };
Now create a new list −
var myList = new List<int>();
myList.AddRange(arr1);
myList.AddRange(arr2);
Use the AddRange() method the arrays into the newly created list.
myList.AddRange(arr1);
myList.AddRange(arr2);
Now convert the list into array as shown below −
 Live Demo
using System;
using System.Collections.Generic;
class Demo {
   static void Main() {
      int[] arr1 = { 37, 45, 65 };
      int[] arr2 = { 70, 89, 118 };
      // displaying array1
      Console.WriteLine("Array 1...");
      foreach(int ele in arr1) {
         Console.WriteLine(ele);
      }
      // displaying array2
      Console.WriteLine("Array 2...");
      foreach(int ele in arr2) {
         Console.WriteLine(ele);
      }
      var myList = new List<int>();
      myList.AddRange(arr1);
      myList.AddRange(arr2);
      int[] arr3 = myList.ToArray();
      Console.WriteLine("Combined array elements..");
      foreach (int res in arr3) {
         Console.WriteLine(res);
      }
   }
}
Array 1...
37
45
65
Array 2...
70
89
118
Combined array elements..
37
45
65
70
89
118
memcpy() function in C/C++

The function memcpy() is used to copy a memory block from one location to another. One is source and another is destination pointed by the pointer. This is declared in “string.h” header file in C language. It does not check overflow.
Here is the syntax of memcpy() in C language,
void *memcpy(void *dest_str, const void *src_str, size_t number)
Here,
dest_str − Pointer to the destination array.
src_str − Pointer to the source array.
number − The number of bytes to be copied from source to destination.
Here is an example of memcpy() in C language,
 Live Demo
#include <stdio.h>
#include <string.h>
int main () {
   char a[] = "Firststring";
   const char b[] = "Secondstring";
   memcpy(a, b, 5);
   printf("New arrays : %s\t%s", a, b);
   return 0;
}
New arrays : SeconstringSecondstring
In the above program, two char type arrays are initialized and memcpy() function is copying the source string ‘b’ to the destination string ‘a’.
char a[] = "Firststring";
const char b[] = "Secondstring";
memcpy(a, b, 5);
Reading Path Parameters in Node.js - GeeksforGeeks

22 Jan, 2021
The path parameter is a variable that allows the user to add a parameter in his resource point (API endpoint) whose value can be changed. Path parameters offer a unique opportunity for the user to control the representations of resources.
Just create a folder and add a file for example index.js, To run this file you need to run the following command.
node index.js
Filename: index.js
const express = require("express")const path = require('path')const app = express()   var PORT = process.env.port || 3000  // View Engine Setupapp.set("views", path.join(__dirname))app.set("view engine", "ejs")  app.get("/user/:id/:start/:end", function(req, res){      var user_id = req.params['id']    var start = req.params['start']    var end = req.params['end']          var user_id = req.params['id'] // Or req.params.id    var start = req.params['start'] // Or req.params.start    var end = req.params['end'] // Or req.params.end})   app.listen(PORT, function(error){    if (error) throw error    console.log("Server created Successfully on PORT", PORT)})
Steps to run the program:
The project structure will look like this:Make sure you have installed ‘view engine’ like I have used ‘ejs’ and install express module using the following commands:npm install express
npm install ejsRun index.js file using below command:node index.jsOpen browser and type this URL “http://localhost:3000/user/1234/1/10” as shown below:Go back to console and you can see the path parameter value as shown below:
The project structure will look like this:
Make sure you have installed ‘view engine’ like I have used ‘ejs’ and install express module using the following commands:npm install express
npm install ejs
npm install express
npm install ejs
Run index.js file using below command:node index.js
node index.js
Open browser and type this URL “http://localhost:3000/user/1234/1/10” as shown below:
Go back to console and you can see the path parameter value as shown below:
So this is how you can use the path parameter in Node.js which offers a unique opportunity for the user to control the representations of resources.
mridulmanochagfg
NodeJS-Questions
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
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 use an ES6 import in Node.js?
Top 10 Front End Developer Skills That You Need in 2022
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
SVN - Tags

Version Control System supports the tag operation by using that concept that one can give meaningful name to a specific version of the code. Tag allows to give descriptive and memorable names to specific version of code. For example BASIC_ARRAY_OPERATIONS is more memorable than revision 4.
Let us see tag operation with an example. Tom decides to create a tag so that he can access the code more easily.
[tom@CentOS project_repo]$ svn copy --revision=4 trunk/ tags/basic_array_operations

Above command will produce the following result.
A    tags/basic_array_operations/array.c
Updated to revision 4.
A         tags/basic_array_operations

Upon successful completion, the new directory will be created inside the tags directory.
[tom@CentOS project_repo]$ ls -l tags/
total 4
drwxrwxr-x. 3 tom tom 4096 Aug 24 18:18 basic_array_operations

Tom wants to double-check it before commit. Status operation is showing that the tag operation is successful, so he can safely commit his changes.
[tom@CentOS project_repo]$ svn status
A  +    tags/basic_array_operations

[tom@CentOS project_repo]$ svn commit -m "Created tag for basic array operations"
Adding         tags/basic_array_operations

Committed revision 5.

 Print
 Add Notes
 Bookmark this page
Java Operators

Operators are used to perform operations on variables and values.
In the example below, we use the
+ operator to add together two values:
int x = 100 + 50;


Try it Yourself »

Although the + operator is often used to add together two values, like in the example above, it can also be used to add together a variable and a value, or a variable and another variable:
int sum1 = 100 + 50;        // 150 (100 + 50)
int sum2 = sum1 + 250;      // 400 (150 + 250)
int sum3 = sum2 + sum2;     // 800 (400 + 400)


Try it Yourself »

Java divides the operators into the following groups:
Arithmetic operators
Assignment operators
Comparison operators
Logical operators
Bitwise operators
Arithmetic operators are used to perform common mathematical operations.
Assignment operators are used to assign values to variables.
In the example below, we use the assignment operator (=) 
to assign the value 10 to a variable called x:
int x = 10;


Try it Yourself »

The addition assignment operator (+=) adds a value to a variable:
int x = 10;
x += 5;


Try it Yourself »

A list of all assignment operators:
Comparison operators are used to compare two values:
Logical operators are used to determine the logic between variables or 
values:
Multiply 10 with 5, and print the result.
System.out.println(10  5);

Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
How to change the size of the Console using PowerShell?

You can change the size of the PowerShell Console with GUI and CLI both.
With GUI −
With CLI −
To change the Width of the console,
$host.UI.RawUI.WindowSize.Width = 150
To change the Height of the console,
$host.UI.RawUI.WindowSize.Height = 60
Accessing Key-value in a Python Dictionary

While analyzing data using Python data structures we will eventually come across the need for accessing key and value in a dictionary. There are various ways to do it in this article we will see some of the ways.
Using a for loop we can access both the key and value at each of the index position in dictionary as soon in the below program.
 Live Demo
dictA = {1:'Mon',2:'Tue',3:'Wed',4:'Thu',5:'Fri'}
#Given dictionary
print("Given Dictionary: ",dictA)
# Print all keys and values
print("Keys and Values: ")
for i in dictA :
   print(i, dictA[i])
Running the above code gives us the following result −
Given Dictionary: {1: 'Mon', 2: 'Tue', 3: 'Wed', 4: 'Thu', 5: 'Fri'}
Keys and Values:
1 Mon
2 Tue
3 Wed
4 Thu
5 Fri
In this approach we consider the key similar to an index in a list. So in the print statement we represent the keys and the values as a pair along with the for loop.
 Live Demo
dictA = {1:'Mon',2:'Tue',3:'Wed',4:'Thu',5:'Fri'}
#Given dictionary
print("Given Dictionary: ",dictA)
# Print all keys and values
print("Keys and Values: ")
print([(k, dictA[k]) for k in dictA])
Running the above code gives us the following result −
Given Dictionary: {1: 'Mon', 2: 'Tue', 3: 'Wed', 4: 'Thu', 5: 'Fri'}
Keys and Values:
[(1, 'Mon'), (2, 'Tue'), (3, 'Wed'), (4, 'Thu'), (5, 'Fri')]
The dictionary class has a method named items. We can access the items method and iterate over it getting each pair of key and value.
 Live Demo
dictA = {1:'Mon',2:'Tue',3:'Wed',4:'Thu',5:'Fri'}
#Given dictionary
print("Given Dictionary: ",dictA)
# Print all keys and values
print("Keys and Values: ")
for key, value in dictA.items():
   print (key, value)
Running the above code gives us the following result −
Given Dictionary: {1: 'Mon', 2: 'Tue', 3: 'Wed', 4: 'Thu', 5: 'Fri'}
Keys and Values:
1 Mon
2 Tue
3 Wed
4 Thu
5 Fri
SciPy - Input & Output

The Scipy.io (Input and Output) package provides a wide range of functions to work around with different format of files. Some of these formats are −
Matlab
IDL
Matrix Market
Wave
Arff
Netcdf, etc.
Let us discuss in detail about the most commonly used file formats −
Following are the functions used to load and save a .mat file.
loadmat
Loads a MATLAB file
savemat
Saves a MATLAB file
whosmat
Lists variables inside a MATLAB file
Let us consider the following example.
import scipy.io as sio
import numpy as np

#Save a mat file
vect = np.arange(10)
sio.savemat('array.mat', {'vect':vect})

#Now Load the File
mat_file_content = sio.loadmat(‘array.mat’)
Print mat_file_content
The above program will generate the following output.
{
   'vect': array([[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]), '__version__': '1.0', 
   '__header__': 'MATLAB 5.0 MAT-file Platform: posix, Created on: Sat Sep 30 
   09:49:32 2017', '__globals__': []
}

We can see the array along with the Meta information. If we want to inspect the contents of a MATLAB file without reading the data into memory, use the whosmat command as shown below.
import scipy.io as sio
mat_file_content = sio.whosmat(‘array.mat’)
print mat_file_content
The above program will generate the following output.
[('vect', (1, 10), 'int64')]

 Print
 Add Notes
 Bookmark this page
How to check if an input string contains a specified substring in JSP?

The fn:contains() function determines whether an input string contains a specified substring.
The fn:contains() function has the following syntax −
boolean contains(java.lang.String, java.lang.String)
Following example explains the functionality of fn:contains() function −
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<%@ taglib uri = "http://java.sun.com/jsp/jstl/functions" prefix = "fn" %>
<html>
   <head>
      <title>Using JSTL Functions</title>
   </head>
   <body>
      <c:set var = "theString" value = "I am a test String"/>
      <c:if test = "${fn:contains(theString, 'test')}">
         <p>Found test string<p>
      </c:if>
      <c:if test = "${fn:contains(theString, 'TEST')}">
         <p>Found TEST string<p>
      </c:if>
   </body>
</html>
You will receive the following result −
Found test string
Whatsapp using Python?

In this section we are going to create a Whatsapp chatbots, but unlike few other chatbots for twitter or facebook, whatsapp chatbots don’t run on the platform directly because of whatsapp’s policies.
But there is a way to get is done, using selenium, a very smart package in python with which developer’s can automate the browser’s activity. With this we can make use of whatsapp-web through the browser.
We need three basic things to get things done: Selenium.
We can install selenium very easily using pip, just run below command on your terminal −
$pip install selenium
Chrome/firefox or any other webdriver.As I using chrome webdriver, below is a link to download chrome webdriver as per your os.
Chrome/firefox or any other webdriver.
As I using chrome webdriver, below is a link to download chrome webdriver as per your os.
https://chromedriver.storage.googleapis.com/index.html?path=2.46/
https://chromedriver.storage.googleapis.com/index.html?path=2.46/
Whatsapp account.Need to have Whatsapp account if not create one.
Whatsapp account.
Need to have Whatsapp account if not create one.
Below is a simple program to send whatsapp message using python to specific contacts.
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import time
import sys
# Replace below path with the absolute path of the \
#chromedriver in your computer
driver = webdriver.Chrome(r'c:\users\rajesh\Desktop\chromedriver')

driver.get("https://web.whatsapp.com/")
# time.sleep()
wait = WebDriverWait(driver, 600)
# Replace 'My Bsnl' with the name of your friend or group name
target = '"My Bsnl"'

# Replace the below string with your own message
string = sys.argv[1]

x_arg = '//span[contains(@title,' + target + ')]'
group_title = wait.until(EC.presence_of_element_located((
By.XPATH, x_arg)))
print (group_title)
print ("Wait for few seconds")
group_title.click()
message = driver.find_elements_by_xpath('//*[@id="main"]/footer/div[1]/div[2]/div/div[2]')[0]

message.send_keys(string)
sendbutton = driver.find_elements_by_xpath('//*[@id="main"]/footer/div[1]/div[3]/button')[0]
sendbutton.click()
driver.close()
Let’s run the above scripts on command prompt, passing message as argument to the whatsapp contact−
>python whatsppPython.py "Hello"

DevTools listening on ws://127.0.0.1:12954/devtools/browser/a5bb04bd-66a3-4002-999f-6a0824f591da
<selenium.webdriver.remote.webelement.WebElement (session="83e7034b9a6f6b49e9e422e655f270d3", element="0.30994636046479007-1")>
after wait
....
.....
chrome browser will open, with a screen something like −
On your mobile device, Choose whatsapp web from the top bar in whatsapp. Scan the QR code that appears on the screen.
There we can see the message is send to a specific contact (“My Bsnl”) in our case.
How to identify foreign key in MySQL DB?

Let us first create a table −
mysql> create table DemoTable1 (Id int NOT NULL PRIMARY KEY,EmployeeName varchar(100));
Query OK, 0 rows affected (0.50 sec)
Following is the query to create a second table with foreign key constraints −
mysql> create table DemoTable2
   (
      Id int NOT NULL,
      StreetName varchar(100),
      CityName varchar(100),
      CountryName varchar(100),
      PinCode int,
      EmployeeId int,
      PRIMARY KEY(Id),
      FOREIGN KEY (Id) REFERENCES DemoTable1(Id)
   );
Query OK, 0 rows affected (0.46 sec)
Following is the query to identify the foreign key in MySQL DB −
mysql> show create table DemoTable2\G
This will produce the following output −
*************************** 1. row ***************************
Table: DemoTable2
Create Table: CREATE TABLE `demotable2` (
   `Id` int(11) NOT NULL,
   `StreetName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
   `CityName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
   `CountryName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
   `PinCode` int(11) DEFAULT NULL,
   `EmployeeId` int(11) DEFAULT NULL,
   PRIMARY KEY (`Id`),
   CONSTRAINT `demotable2_ibfk_1` FOREIGN KEY (`Id`) REFERENCES `demotable1`
(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
1 row in set (0.00 sec)
DateDiff() and DatePart() Function in MS Access - GeeksforGeeks

01 Oct, 2020
In this article, we are going to cover DateDiff() and DatePart function with examples. DateDiff() is used to calculate the difference between two dates. DatePart is used when you want a specific part want to display from date specified format. Let’s discuss one by one.
1. DateDiff() Function :In MS Access, the DateDiff() function returns the difference between two dates. In this function, it will take the first parameter datepart, and the second parameter will be date1 and the third parameter will be date2. And it will return the difference between two dates.
Syntax :
DateDiff(datepart, date1, date2, firstdayofweek, firstweekofyear)

Parameter Values :
Example-1 :
SELECT DateDiff("yyyy", #15/02/2000#, #06/05/2020#);

Output :
20

Example-2 :
SELECT DateDiff("m", #15/02/2000#, #06/05/2020#);

Output :
244

2. DatePart() Function :In MS Access, the DatePart() function returns the specified part of a date. In this function the first parameter will be the specified datepart symbol and the second parameter will be the date. And it will return the date part of the date.
Syntax :
DatePart(datepart, date, firstdayofweek, firstweekofyear);

Parameter Values :In this parameter values the same as Datadiff() function for datepart, firstdayofweek, and firstweekofyear. For data value, It is required it specifies the date.
Example-1 :
SELECT DatePart("yyyy", #02/09/2020#);

Output :
2020

Example-2 :
SELECT DatePart("m", #02/09/2020#);

Output :
2

DBMS-SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
CTE in SQL
SQL | Views
Difference between DELETE, DROP and TRUNCATE
How to Update Multiple Columns in Single Update Statement in SQL?
Difference between DDL and DML in DBMS
SQL Interview Questions
What is Temporary Table in SQL?
MySQL | Group_CONCAT() Function
SQL - ORDER BY
Difference between Where and Having Clause in SQL
C library function - isalnum()

The C library function int isalnum(int c) checks if the passed character is alphanumeric.
Following is the declaration for isalnum() function.
int isalnum(int c);
c − This is the character to be checked.
c − This is the character to be checked.
This function returns non-zero value if c is a digit or a letter, else it returns 0.
The following example shows the usage of isalnum() function.
#include <stdio.h>
#include <ctype.h>

int main () {
   int var1 = 'd';
   int var2 = '2';
   int var3 = '\t';
   int var4 = ' ';
    
   if( isalnum(var1) ) {
      printf("var1 = |%c| is alphanumeric\n", var1 );
   } else {
      printf("var1 = |%c| is not alphanumeric\n", var1 );
   }
   
   if( isalnum(var2) ) {
      printf("var2 = |%c| is alphanumeric\n", var2 );
   } else {
      printf("var2 = |%c| is not alphanumeric\n", var2 );
   }
   
   if( isalnum(var3) ) {
      printf("var3 = |%c| is alphanumeric\n", var3 );
   } else {
      printf("var3 = |%c| is not alphanumeric\n", var3 );
   }
   
   if( isalnum(var4) ) {
      printf("var4 = |%c| is alphanumeric\n", var4 );
   } else {
      printf("var4 = |%c| is not alphanumeric\n", var4 );
   }
   return(0);
}
Let us compile and run the above program, to produce the following result −
var1 = |d| is alphanumeric
var2 = |2| is alphanumeric
var3 = |        | is not alphanumeric
var4 = | | is not alphanumeric


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
How can I check the status of MySQL Server?

With the help of ‘mysqladmin’ along with ‘status’ option program we would be able to check the status of MySQL server. It can be used as follows on command line −
C:\mysql\bin>mysqladmin -u root status
Uptime: 3865 Threads: 1 Questions: 50 Slow queries: 0 Opens: 113
Flush tables: 1 Open tables: 102 Queries per second avg: 0.012
Get the length of distinct values in an array with MongoDB

To get distinct values, use MongoDB DISTINCT. For length, use LENGTH(). Let us create a collection with documents −
> db.demo36.insertOne({"Names":["Chris","Bob"]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e17643bcfb11e5c34d898d4")
}
> db.demo36.insertOne({"Names":["Mike","Sam","Carol"]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e176449cfb11e5c34d898d5")
}
> db.demo36.insertOne({"Names":["Chris","Bob","David"]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e17645bcfb11e5c34d898d6")
}
Display all documents from a collection with the help of find() method −
> db.demo36.find();
This will produce the following output −
{ "_id" : ObjectId("5e17643bcfb11e5c34d898d4"), "Names" : [ "Chris", "Bob" ] }
{ "_id" : ObjectId("5e176449cfb11e5c34d898d5"), "Names" : [ "Mike", "Sam", "Carol" ] }
{ "_id" : ObjectId("5e17645bcfb11e5c34d898d6"), "Names" : [ "Chris", "Bob", "David" ] }
Following is the query to get the length −
> db.demo36.distinct('Names').length;
This will produce the following output −
6
Python | Split given list and insert in excel file

28 Feb, 2019
Given a list containing Names and Addresses consecutively, the task is to split these two elements at a time and insert it into excel.
We can use a very popular library for data analysis, Pandas. Using pandas we can easily manipulate the columns and simply insert the filtered elements into excel file using df.to_excel() function.
Below is the implementation :
# Python code to split the list two element # at a time and insert it into excel.  # Importing pandas as pdimport pandas as pd  # List initializationlist1 = ['Assam', 'India',         'Lahore', 'Pakistan',          'New York', 'USA',         'Bejing', 'China']  df = pd.DataFrame()  # Creating two columnsdf['State'] = list1[0::2]df['Country'] = list1[1::2]  # Converting to exceldf.to_excel('result.xlsx', index = False)
Output :
Python list-programs
Python-excel
Python-pandas
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
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Convert integer to string in Python
How to drop one or multiple columns in Pandas Dataframe
OAuth 2.0 - Obtaining an Access Token

An access token is a string that identifies a user, an application, or a page. The token includes information such as when the token will expire and which app created that token.
First, it is necessary to acquire OAuth 2.0 client credentials from API console.
First, it is necessary to acquire OAuth 2.0 client credentials from API console.
Then, the access token is requested from the authorization server by the client.
Then, the access token is requested from the authorization server by the client.
It gets an access token from the response and sends the token to the API that you wish to access.
It gets an access token from the response and sends the token to the API that you wish to access.
You must send the user to the authorization endpoint at the beginning. Following is an example of a dummy request
https://publicapi.example.com/oauth2/authorize?client_id=your_client_id&redirect_uri=your_url 
   &response_type=code

Following are the parameters and their descriptions.
client_id − It should be set to the client id of your application.
client_id − It should be set to the client id of your application.
redirect_uri − It should be set to the URL. After the request is authorized, the user will be redirected back.
redirect_uri − It should be set to the URL. After the request is authorized, the user will be redirected back.
response_type − It can either be a code or a token. The code must be used for server side applications, whereas the token must be used for client side applications. In server side applications, you can make sure that the secrets are saved safely.
response_type − It can either be a code or a token. The code must be used for server side applications, whereas the token must be used for client side applications. In server side applications, you can make sure that the secrets are saved safely.
Following table lists the concepts of Client Credentials.
The authorization code allows accessing the authorization request and grants access to the client application to fetch the owner resources.
The resource owner password credentials include only one request and one response, and is useful where the resource owner has a good relationship with the client.
Assertion is a package of information that makes the sharing of identity and security information across various security domains possible.
The refresh tokens are used to acquire a new access tokens, which carries the information necessary to get a new access token.
Access token is a type of token that is assigned by the authorization server.
If the token access request, which is issued by the authorization server is invalid or unauthorized, then the authorization server returns an error response.
SequenceMatcher in Python for Longest Common Substring.

Given two strings, our task is to print the longest common sub-string. We will solve problem in python using SequenceMatcher.find_longest_match () method.
Class difflib.SequenceMatcher is a flexible class for comparing pairs of sequences of any type, so long as the sequence elements are hashable.
find_longest_match(a, x, b, y)
Find longest matching block in a[a:x] and b[b:y].
Input:  str1 = "pythonprogramming", 
        str2 = "pro"
Output: pro

Step 1: Enter two string.
Step 2: initialize SequenceMatcher object with the input string.
Step 3: find the match of longest sub-string output.
Step 4: print longest substring.

# Python program to find Longest Common Sub-string 
from difflib import SequenceMatcher 
def matchsubstring(m,n): 
   seqMatch = SequenceMatcher(None,m,n) 
   match = seqMatch.find_longest_match(0, len(m), 0, len(n)) 
   if (match.size!=0): 
      print ("Common Substring ::>",m[match.a: match.a + match.size])  
   else: 
      print ('No longest common sub-string found') 
# Driver program 
if __name__ == "__main__": 
   X = input("Enter first String ")
   Y = input("Enter second String ")
   matchsubstring(X,Y) 
Enter first String pythonprogramming
Enter second String pro
Common Substring ::> pro
std::move in C++

20 Jul, 2017
std :: moveMoves the elements in the range [first,last] into the range beginning at result.The value of the elements in the [first,last] is transferred to the elements pointed by result. After the call, the elements in the range [first,last] are left in an unspecified but valid state.Template :
OutputIterator move (InputIterator first, InputIterator last, OutputIterator result);

Parameters :

first, last
Input iterators to the initial and final positions in a sequence
to be moved. The range used is [first,last], which contains all
the elements between first and last, including the element pointed
by first but not the element pointed by last.

result
Output iterator to the initial position in the destination sequence.
This shall not point to any element in the range [first,last].

Return type :
An iterator to the end of the destination range where elements have been moved.

Examples:
Input :
vec1 contains : 1 2 3 4 5
vec2 contains : 7 7 7 7 7
Output :
arr2 contains : 7 1 2 3 4
/*First 4 elements of vector vec1 moved to vec2 starting second position*/

// CPP program to illustrate// std::move and std::move_backward// STL library functions#include<bits/stdc++.h>  // Driver codeint main(){    std :: vector <int> vec1 {1, 2, 3, 4, 5};    std :: vector <int> vec2 {7, 7, 7, 7, 7};      // Print elements    std :: cout << "Vector1 contains :";    for(int i = 0; i < vec1.size(); i++)        std :: cout << " " << vec1[i];    std :: cout << "\n";          // Print elements    std :: cout << "Vector2 contains :";    for(unsigned int i = 0; i < vec2.size(); i++)        std :: cout << " " << vec2[i];    std :: cout << "\n\n";          // std :: move function    // move first 4 element from vec1 to starting position of vec2    std :: move (vec1.begin(), vec1.begin() + 4, vec2.begin() + 1);          // Print elements    std :: cout << "Vector2 contains after std::move function:";    for(unsigned int i = 0; i < vec2.size(); i++)        std :: cout << " " << vec2[i];    std :: cout << "\n";          return 0;}
Output:
Vector1 contains : 1 2 3 4 5
Vector2 contains : 7 7 7 7 7

Vector2 contains after std::move function: 7 1 2 3 4

This article is contributed by Sachin Bisht. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
cpp-algorithm-library
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java Program to Swap the Elements of Vector

21 Dec, 2021
The swap() method of java.util.Collections class is used to swap the elements at the specified positions in the specified list. If the specified positions are equal, invoking this method leaves the list unchanged.
Syntax:
public static void swap(List list, int i, int j)
Parameters: This method takes the following argument as a Parameter
list – The list in which to swap elements.
i – the index of one element to be swapped.
j – the index of the other element to be swapped.
Exception This method throws IndexOutOfBoundsException, if either i or j is out of range (i = list.size() || j = list.size()).
Example 1:
Java
// Java program to Swap Elements of Java Vector  import java.util.Collections;import java.util.Vector;  public class GFG {    public static void main(String[] args)    {          // create vector        Vector<String> vector = new Vector<String>();          // insert elements in vector        vector.add("A");        vector.add("B");        vector.add("C");        vector.add("D");        vector.add("E");          // print original vector        System.out.println("Before Swapping = "+vector);          // call Collection.swap() method        Collections.swap(vector, 0, 4);          // print vector after swap two elements        System.out.println("After Swapping = "+vector);    }}
[A, B, C, D, E]
After swapping
[E, B, C, D, A]
Example 2: For IndexOutOfBoundsException
Java
// Java program to demonstrate // swap() method for IndexOutOfBoundsException     import java.util.*;     public class GFG1 {     public static void main(String[] argv) throws Exception     {         try {                 // creating object of List<String>             List<String> vector = new ArrayList<String>();                 // populate the vector             vector.add("rohan");             vector.add("manish");             vector.add("simran");             vector.add("ananya");             vector.add("ishika");                 // printing the vector before swap             System.out.println("Before swap: " + vector);                 // swap the elements             System.out.println("\nTrying to swap elements"                               + " more than upper bound index ");             Collections.swap(vector, 0, 5);                 // printing the vector after swap             System.out.println("After swap: " + vector);         }             catch (IndexOutOfBoundsException e) {             System.out.println("Exception thrown : " + e);         }     } }
Before swap: [rohan, manish, simran, ananya, ishika]

Trying to swap elements more than upper bound index 
Exception thrown : java.lang.IndexOutOfBoundsException: Index 5 out of bounds for length 5

kapoorsagar226
Java-Vector
Picked
Technical Scripter 2020
Java
Technical Scripter
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Scrape Videos using Python ? - GeeksforGeeks

30 Nov, 2021
Prerequisite:
requests
BeautifulSoup
In this article, we will discuss web scraping of videos using python. For web scraping, we will use requests and BeautifulSoup Module in Python. The requests library is an integral part of Python for making HTTP requests to a specified URL. Whether it be REST APIs or Web Scraping, requests are must be learned for proceeding further with these technologies. When one makes a request to a URI, it returns a response. Python requests provide inbuilt functionalities for managing both the request and response.
pip install requests
Beautiful Soup is a Python library designed for quick turnaround projects like screen-scraping.
pip install bs4
Let’s Understand Step by step implementation:
Import Required Module
Python3
# Import Required Moduleimport requestsfrom bs4 import BeautifulSoup
  
Parse HTML Content
 
Python3
# Web URLWeb_url = "Enter WEB URL" # Get URL Contentr = requests.get(Web_url) # Parse HTML Codesoup = BeautifulSoup(r.content, 'html5lib')
  
Count How many videos are there on the web page. In HTML For displaying video, we use video tag.
 
Python3
# List of all video tagvideo_tags = soup.findAll('video')print("Total ",len(video_tags),"videos found")
  
Iterate through all video tags and fetch video URL
 
Python3
for video_tag in video_tags:    video_url = video_tag.find("a")['href']    print(video_url)
 
 
Below is the Implementation:
 
Python3
# Import Required Moduleimport requestsfrom bs4 import BeautifulSoup # Web URLWeb_url = "https://www.geeksforgeeks.org/make-notepad-using-tkinter/" # Get URL Contentr = requests.get(Web_url) # Parse HTML Codesoup = BeautifulSoup(r.content, 'html.parser') # List of all video tagvideo_tags = soup.findAll('video')print("Total ", len(video_tags), "videos found") if len(video_tags) != 0:    for video_tag in video_tags:        video_url = video_tag.find("a")['href']        print(video_url)else:    print("no videos found")
Output:
Total  1 videos found
https://media.geeksforgeeks.org/wp-content/uploads/15.webm
surinderdawra388
Picked
Python BeautifulSoup
Python bs4-Exercises
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?
Selecting rows in pandas DataFrame based on conditions
Check if element exists in list in Python
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
How to use the tree command in PowerShell?

Tree command graphically shows the folder structure of the given drive or a path. It is similar to Get−ChildItem or dir recursive command except this shows the graphical structure. For example, the below command will retrieve the folder structure of C:\VMs including
tree c:\VMs
There are also two other switches supported for this command. They will appear in the help section of this command.
c:\>tree /?
Graphically displays the folder structure of a drive or path.

TREE [drive:][path] [/F] [/A]
/F Display the names of the files in each folder.
/A Use ASCII instead of extended characters.
This command is a cmd utility and hence we are using the ‘?’ symbol for the help command.
Command with /F switch which displays the name of the files in each folder.
tree c:\VMs /F
To display the one screen at a time, use the ‘more’ keyword in the pipeline. For example,
You can use /A switch uses text characters instead of graphical characters to show the line that links to subdirectories.
For example,
tree c:\VMs /a
MongoDB query to search for Month and Day only?

To search for month and day only, use the aggregate framework.
Let us first create a collection with documents −
> db.monthAndDayDemo.insertOne({"LoginDate":new ISODate("2019-04-27")});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cefbcaeef71edecf6a1f6b2")
}
> db.monthAndDayDemo.insertOne({"LoginDate":new ISODate("2018-04-30")});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cefbcb7ef71edecf6a1f6b3")
}
> db.monthAndDayDemo.insertOne({"LoginDate":new ISODate("2018-04-27")});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cefbcbcef71edecf6a1f6b4")
}
> db.monthAndDayDemo.insertOne({"LoginDate":new ISODate("2016-04-27")});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cefbdaaef71edecf6a1f6b5")
}
Display all documents from a collection with the help of find() method −
> db.monthAndDayDemo.find();
{ "_id" : ObjectId("5cefbcaeef71edecf6a1f6b2"), "LoginDate" : ISODate("2019-04-27T00:00:00Z") }
{ "_id" : ObjectId("5cefbcb7ef71edecf6a1f6b3"), "LoginDate" : ISODate("2018-04-30T00:00:00Z") }
{ "_id" : ObjectId("5cefbcbcef71edecf6a1f6b4"), "LoginDate" : ISODate("2018-04-27T00:00:00Z") }
{ "_id" : ObjectId("5cefbdaaef71edecf6a1f6b5"), "LoginDate" : ISODate("2016-04-27T00:00:00Z") }
Following is the query to search for month and day only −
{ "_id" : ObjectId("5cefbcaeef71edecf6a1f6b2"), "LoginDate" : ISODate("2019-04-27T00:00:00Z") }
> db.monthAndDayDemo.aggregate( { "$project": { "m":{"$month":"$LoginDate"}, 
"d": { "$dayOfMonth":"$LoginDate" } }}, { "$match":{ "m": 4, "d": 27 } } );
{ "_id" : ObjectId("5cefbcaeef71edecf6a1f6b2"), "m" : 4, "d" : 27 }
{ "_id" : ObjectId("5cefbcbcef71edecf6a1f6b4"), "m" : 4, "d" : 27 }
{ "_id" : ObjectId("5cefbdaaef71edecf6a1f6b5"), "m" : 4, "d" : 27 }
Maximum bitwise AND value of a pair in an array in C++

Given an array of n positive elements. we need to find the maximum bitwise AND value generated by any pair of element from the array.
If input array is {10, 12, 15, 18} then maximum value of bitwise AND is 12.
The result of bitwise AND operations on single bit is maximum when both bits are 1. Considering this property −
Start from the MSB and check whether we have minimum of two elements of array having set value
If yes, then that MSB will be part of our solution and be added to result otherwise we will discard that bit
Similarly, iterating from MSB to LSB (32 to 1) for bit position we can easily check which bit will be part of our solution and will keep adding all such bits to our solution
Let us now see an example −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
int checkBits(int *arr, int n, int pattern) {
   int cnt = 0;
   for (int i = 0; i < n; ++i) {
      if ((pattern & arr[i]) == pattern) {
         ++cnt;
      }
   }
   return cnt;
}
int getMaxBitwiseAnd(int *arr, int n) {
   int result = 0;
   int count;
   for (int i = 31; i >= 0; --i) {
      count = checkBits(arr, n, result | (1 << i));
      if (count >= 2) {
         result |= (1 << i);
      }
   }
   return result;
}
int main() {
   int arr[] = {10, 12, 15, 18};
   int n = sizeof(arr) / sizeof(arr[0]);
   cout << "Maximum bitwise AND = " << getMaxBitwiseAnd(arr, n) << endl;
   return 0;
}
Maximum bitwise AND = 12
How to convert table to dataframe in R? - GeeksforGeeks

08 Oct, 2021
In this article, we will discuss how to convert a given table to a dataframe in the R programming language.
as.data.frame.matrix() will be taking the table as its parameter and will return the dataframe back to the user.
Syntax: as.data.frame.matrix(x)
Parameter:
x: name of the table which is to be converted into dataframe
Returns: It will return the dataframe which is converted from the given data.
table() function is used for the cross-classifying factors to build a contingency table of the counts at each combination of factor levels of the provided data in R language.
Syntax: table(...,exclude = if (useNA == “no”) c(NA, NaN),useNA = c(“no”, “ifany”, “always”),dnn = list.names(...), deparse.level = 1)
Returns:
This function will be returning the frequency table of the provided data back to the user.
Thus, we will first create a contingency table using table() function from a dataframe and then convert this table to a dataframe.
Given below are some implementations for this.
Example 1:
R
data_gfg=data.frame(x=c(1,3,5,3,4),                    y=c(1,5,1,4,5)) table_gfg=table(data_gfg$x,data_gfg$y)print("table in use: ")table_gfg new_data_gfg=as.data.frame.matrix(table_gfg)print("converted to dataframe: ")new_data_gfg
Output:
Example 2:
R
data_gfg=data.frame(x=c("a","b","c","d","e"),                    y=c("1","2","3","4","5")) table_gfg=table(data_gfg$x,data_gfg$y)print("table in use: ")table_gfg new_data_gfg=as.data.frame.matrix(table_gfg)print("dataframe after conversion :")new_data_gfg
Output:
saurabh1990aror
Picked
R DataFrame-Programs
R-DataFrame
R Language
R Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
How to filter R dataframe by multiple conditions?
Replace Specific Characters in String in R
Convert Matrix to Dataframe in R