code-rag-bench/online-tutorials huggingface dataset:
Node.js crypto.randomBytes() Method - GeeksforGeeks

11 Oct, 2021
The crypto.randomBytes() method is used to generate a cryptographically well-built artificial random data and the number of bytes to be generated in the written code.Syntax:  
crypto.randomBytes( size, callback )
Parameters: This method accept two parameters as mentioned above and described below:  
size: It is of type number which indicates the number of bytes to be generated.
callback: It is a function which is made of two parameters namely, err and buf. However, if a callback function is available in the stated code then the bytes are generated asynchronously else these bytes are generated synchronously.
Return Type: It returns a Buffer if the callback function is given.Below example illustrate the use of crypto.randomBytes() method in Node.js:Example 1:  
// Node.js program to demonstrate the // crypto.randomBytes() method  // Including crypto moduleconst crypto = require('crypto');  // Calling randomBytes method with callbackcrypto.randomBytes(127, (err, buf) => {  if (err) {    // Prints error    console.log(err);    return;  }    // Prints random bytes of generated data  console.log("The random data is: "             + buf.toString('hex'));});
Output: Here, callback function is provided so random bytes are generated synchronously.  
The random data is: 074e48c8e3c0bc19f9e22dd7570037392e5d0bf80cf9dd51bb7808872a511b3c1cd91053fca873a4cb7b2549ec1010a9a1a4c2a6aceead9d115eb9d60a1630e056f3accb10574cd563371296d4e4e898941231d06d8dd5de35690c4ba94ca12729aa316365145f8a00c410a859c40a46bbb4d5d51995241eec8f6b7a90415e
Example 2:  
// Node.js program to demonstrate the // crypto.randomBytes() method  // Including crypto moduleconst crypto = require('crypto');  // Calling randomBytes method without callbackconst buf = crypto.randomBytes(60);   // Prints random bytes of generated dataconsole.log("The random bytes of data generated is: "                + buf.toString('utf8'));
Output: Here, callback function is not provided so bytes are generated synchronously  
The random bytes of data generated is: _??i???Z?Z?o?i?W??bEC
?F????#?-??T??jDqmm?v??7?Q?c_G?%?
Reference: https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback 
intensefire22
Node.js-crypto-module
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Node.js fs.writeFile() Method
Node.js fs.readFile() 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?
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
Write a bash script to print a particular line from a file in C

In this program, we are given a file name text.txt. Our task is to print a particular line from the file.
For this there are multiple methods in bash script, they are awk, sed, head.
$> awk ‘{if(NR==LINE_NUMBER) print $0}’ filename
$> sed -n LINE_NUMBERp filename
$head -n LineNumber filename | tail - n + LINE_NUMBER
Code to print a specific line in bash programming from file text.txt.
$> awk ‘{if(NR==5) print $0}’ text.txt
$>sed -n 5p text.txt
$head -n 5 filename | tail - n + 5
MariaDB - Update Query

The UPDATE command modifies existing fields by changing values. It uses the SET clause to specify columns for modification, and to specify the new values assigned. These values can be either an expression or the default value of the field. Setting a default value requires using the DEFAULT keyword. The command can also employ a WHERE clause to specify conditions for an update and/or an ORDER BY clause to update in a certain order.
Review the following general syntax −
UPDATE table_name SET field=new_value, field2=new_value2,...
[WHERE ...]

Execute an UPDATE command from either the command prompt or using a PHP script.
At the command prompt, simply use a standard commandroot −
root@host# mysql -u root -p password;
Enter password:*******
mysql> use PRODUCTS;
Database changed
mysql> UPDATE products_tbl
   SET nomenclature = 'Fiber Blaster 300Z' WHERE ID_number = 112;
mysql> SELECT * from products_tbl WHERE ID_number='112';
+-------------+---------------------+----------------------+
| ID_number   | Nomenclature        | product_manufacturer |
+-------------+---------------------+----------------------+
| 112         | Fiber Blaster 300Z  | XYZ Corp             |
+-------------+---------------------+----------------------+      

Employ the mysql_query() function in UPDATE command statements −
<?php
   $dbhost = ‘localhost:3036’;
   $dbuser = ‘root’;
   $dbpass = ‘rootpassword’;
   $conn = mysql_connect($dbhost, $dbuser, $dbpass);

   if(! $conn ) {
      die(‘Could not connect: ‘ . mysql_error());
   }

   $sql = ‘UPDATE products_tbl
      SET product_name = ”Fiber Blaster 300z”
      WHERE product_id = 112’;

   mysql_select_db(‘PRODUCTS’);
   $retval = mysql_query( $sql, $conn );

   if(! $retval ) {
      die(‘Could not update data: ‘ . mysql_error());
   }

   echo “Updated data successfully\n”;
   mysql_close($conn);
?>
On successful data update, you will see the following output −
mysql> Updated data successfully

 Print
 Add Notes
 Bookmark this page
Python Pandas - Get the quarter of the year from Period object

To get the quarter of the year component of the Period, use the period.quarter property. At first, import the required libraries −
import pandas as pd
The pandas.Period represents a period of time. Creating two Period objects
period1 = pd.Period("2020-02-27 08:32:48")
period2 = pd.Period(freq="M", year = 2021, month = 8, day = 16, hour = 2, minute = 35)
Display the Period objects
print("Period1...\n", period1)
print("Period2...\n", period2)
Get the quarter of the year from two Period objects
res1 = period1.quarter
res2 = period2.quarter
Result is based on the following quarters of an year
Quarter 1 = 1st January to 31st March
Quarter 2 = 1st April to 30th June
Quarter 3 = 1st July to 30th September
Quarter 4 = 1st October to 31st December
Following is the code
import pandas as pd

# The pandas.Period represents a period of time
# creating two Period objects
period1 = pd.Period("2020-02-27 08:32:48")
period2 = pd.Period(freq="M", year = 2021, month = 8, day = 16, hour = 2, minute = 35)

# display the Period objects
print("Period1...\n", period1)
print("Period2...\n", period2)

# get the quarter of the year from two Period objects
res1 = period1.quarter
res2 = period2.quarter

# Return the quarter from the two Period objects
# Result is based on the following quarters of an year:
# Quarter 1 = 1st January to 31st March
# Quarter 2 = 1st April to 30th June
# Quarter 3 = 1st July to 30th September
# Quarter 4 = 1st October to 31st December
print("\nQuarter from the 1st Period object ...\n", res1)
print("\nQuarter from the 2nd Period object...\n", res2)
This will produce the following code
Period1...
2020-02-27 08:32:48
Period2...
2021-08

Quarter from the 1st Period object ...
1

Quarter from the 2nd Period object...
3
Java & MySQL - Select Database Example

This chapter provides an example on how to select a Database using JDBC application. Before executing the following example, make sure you have the following in place −
To execute the following example you need to replace the username and password with your actual user name and password.
To execute the following example you need to replace the username and password with your actual user name and password.
Your MySQL database you are using, is up and running.
Your MySQL database you are using, is up and running.
The following steps are required to create a new Database using JDBC application −
Import the packages − Requires that you include the packages containing the JDBC classes needed for the database programming. Most often, using import java.sql.* will suffice.
Import the packages − Requires that you include the packages containing the JDBC classes needed for the database programming. Most often, using import java.sql.* will suffice.
Open a connection − Requires using the DriverManager.getConnection() method to create a Connection object, which represents a physical connection with a selected database.
Open a connection − Requires using the DriverManager.getConnection() method to create a Connection object, which represents a physical connection with a selected database.
Selection of database is made while you prepare database URL. Following example would make connection with STUDENTS database.
Selection of database is made while you prepare database URL. Following example would make connection with STUDENTS database.
Clean up the environment − try with resources automatically closes the resources.
Clean up the environment − try with resources automatically closes the resources.
Copy and paste the following example in JDBCExample.java, compile and run as follows −
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCExample {
   static final String DB_URL = "jdbc:mysql://localhost/TUTORIALSPOINT";
   static final String USER = "guest";
   static final String PASS = "guest123";

   public static void main(String[] args) {
      System.out.println("Connecting to a selected database...");
      // Open a connection
      try(Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);) {		      
         System.out.println("Connected database successfully...");  
      } catch (SQLException e) {
         e.printStackTrace();
      } 
   }
}
Now let us compile the above example as follows −
C:\>javac JDBCExample.java
C:\>

When you run JDBCExample, it produces the following result −
C:\>java JDBCExample
Connecting to a selected database...
Connected database successfully...
C:\>


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
GATE | GATE CS 2019 | Question 46 - GeeksforGeeks

18 Feb, 2019
There are n unsorted arrays: A1, A2, ....,An. Assume that n is odd. Each of A1, A2, ...., An contains n distinct elements. There are no common elements between any two arrays. The worst-case time complexity of computing the median of the medians of A1, A2, ....,An is ________ .
(A) Ο(n log n)(B) Ο(n2)(C) Ο(n)(D) Ω(n2log n)Answer: (B)Explanation: Since given arrays are not sorted, so the time complexity to find median is O(n) in an unsorted array. You need to apply this apgorithm n time to find all medians and again once to find median of all these medians, so total time complexity is,
= O(n)*O(n) + O(n)
= O(n2) + O(n)
≈ O(n2) 
So, option (B) is correct.Quiz of this Question
manav23lohani
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE-CS-2006 | Question 47
GATE | GATE MOCK 2017 | Question 24
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
Meteor - EJSON

EJSON is an extension of JSON syntax that supports Date and Binary types.
To install EJSON package, we need to add it from the command prompt window.
C:\Users\username\Desktop\meteorApp>meteor add ejson

We can deserialize the date using the parse method.
if (Meteor.isClient) {
   var myEjsonDate = '{"$date": 1455029631493}';
   var myDate = EJSON.parse(myEjsonDate);
   console.log(myDate);
}
The console will log the correct date value.
The same can be applied to binary types.
if (Meteor.isClient) {
   var myEjsonBinary = '{"$binary": "c3VyZS4="}';
   var myBinary = EJSON.parse(myEjsonBinary);
   console.log(myBinary);
}
You can see that the console is logging new deserialized value.
We can serialize an object using the stringify method. This is the reversed process from the example above.
if (Meteor.isClient) {

   var myObject = {
      myDate : new Date(),
      myBinary : new Uint8Array([115, 117, 114, 101, 46])
   }

   var myEjosnData = EJSON.stringify(myObject);
   console.log(myEjosnData);
}
We can see our new values in the console.
EJSON.parse(string)
Used for parsing a string into EJSON value.
EJSON.stringify(value)
Used for serializing a value to the string.
EJSON.fromJSONValue(value)
Used for deserializing an EJSON value from JSON.
EJSON.toJSONValue(value)
Used for serializing an EJSON value into JSON.
EJSON.equals(value1, value2)
Used for comparing if two values are equal.
EJSON.clone(value)
Used for returning a deep copy of the value.
EJSON.newBinary
Used for assigning a binary data that EJSON can serialize.
EJSON.isBinary(x)
Used for checking if the value is a binary data.
EJSON.addType(name, factory)
Used for creating a custom EJSON type.
customType.typeName()
Used for returning a name of the custom type.
customType.toJSONValue()
Used for serializing custom types.
customType.clone()
Used for returning a deep copy of the custom type.
customType.equals(otherValue)
Used for comparison between the custom type value and other value.

    73 Lectures 
     4 hours 

 Skillbakerystudios
 Print
 Add Notes
 Bookmark this page
Perl | Appending to a File - GeeksforGeeks

05 Mar, 2019
When a file is opened in write mode using “>”, the content of the existing file is deleted and content added using the print statement is written to the file. In this mode, the writing point will be set to the end of the file. So old content of file remains intact and anything that is written to file using print statement is added to the end of the file. However, read operation cannot be performed unless the file is opened in +>> mode indicating append and read.
Example:
# Opening a file in read mode# to display existing content open(FH, "Hello.txt") or      die "Sorry!! couldn't open";  # Reading and printing the existing# content of the fileprint"\nExisiting Content of the File:\n";while(<FH>){    print $_;}  # Opening file in append mode# using >>open(FH, ">>", "Hello.txt") or die "File couldn't be opened";  # Getting the text to be appended # from the userprint "\n\nEnter text to append\n";$a = <>;  # Appending the content to fileprint FH $a;  # Printing the success messageprint "\nAppending to File is Successful!!!\n";  # Reading the file after appendingprint "\nAfter appending, Updated File is\n";  # Opening file in read mode to # display updated contentopen(FH, "Hello.txt") or      die "Sorry!! couldn't open";while(<FH>){    print $_;}close FH or "couldn't close";
Original File: 
Appending to File: Updated File: 
Here is how the program works:-Step 1: Opening a file in read mode to see the existing content of the file.Step 2: Printing the existing content of the file.Step 3: Opening the File in Append mode to add content to the file.Step 4: Getting text from the user to be appended to a fileStep 5: Appending text to fileStep 6: Reading the file again to see the updated content.Step 7: Closing a file
Perl-files
Picked
Perl
Perl
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Perl | Arrays (push, pop, shift, unshift)
Perl | Arrays
Perl Tutorial - Learn Perl With Examples
Perl | length() Function
Perl | sleep() Function
Hello World Program in Perl
Introduction to Perl
Perl | Boolean Values
Perl | Basic Syntax of a Perl Program
Perl | join() Function
How to copy certain files from one folder to another using Python?

The shutil module provides functions for copying files, as well as entire folders. For copying multiple files at once, you'll have to have a list of all files you want to copy and loop over them to copy them.
Calling shutil.copy(source, destination) will copy the file at the path source to the folder at the path destination. (Both source and destination are strings.) If destination is a filename, it will be used as the new name of the copied file. This function returns a string of the path of the copied file.  
import shutil, os
files = ['file1.txt', 'file2.txt', 'file3.txt']
for f in files:
    shutil.copy(f, 'dest_folder')
View stored procedure/function definition in MySQL?

To view stored procedure/function definition in MySQL, you can use show command. The syntax is as follows −
SHOW CREATE PROCEDURE yourProcedureName;
To understand the above syntax, you can create a procedure and check that definition. Let us create a stored procedure −
mysql> delimiter //
mysql> create procedure AllRecords()
   -> begin
   -> select *from student;
   -> end //
Query OK, 0 rows affected (0.24 sec)
You can call the stored procedure with the help of call command. The query is as follows −
mysql> delimiter ;
mysql> call AllRecords();
The following is the output −
+------+-------+
| id   | Name  |
+------+-------+
| 1    | John  |
| 2    | Bob   |
| 3    | Smith |
| 6    | John  |
+------+-------+
4 rows in set (0.14 sec)

Query OK, 0 rows affected (0.18 sec)
Now you can check the definition with the help of above syntax which we discussed in the beginning. The query is as follows −
mysql> show create procedure AllRecords;
Here is the output −
+------------+--------------------------------------------+-----------------------------------------------------------------------+----------------------+----------------------+--------------------+
| Procedure  | sql_mode                                   | Create Procedure                                                      | character_set_client | collation_connection | Database Collation |
+------------+--------------------------------------------+-----------------------------------------------------------------------+----------------------+----------------------+--------------------+
| AllRecords | STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION | CREATE DEFINER=`root`@`%` PROCEDURE `AllRecords`() begin select *from student;end | utf8     | utf8_general_ci      | utf8mb4_unicode_ci |
+------------+--------------------------------------------+-----------------------------------------------------------------------+----------------------+----------------------+--------------------+
1 row in set (0.00 sec)
To check the function definition in MySQL, you can use function in place of procedure. The syntax is as follows: −
SHOW CREATE FUNCTION yourFunctionName;
Check if a triangle of positive area is possible with the given angles in Python

Suppose we have three angles. We have to check whether it is possible to create a triangle of positive area with these angles or not.
So, if the input is like a = 40 b = 120 c = 20, then the output will be True as the sum of 40 + 120 + 20 = 180.
To solve this, we will follow these steps −
if a, b and c are not 0 and (a + b + c) is same as 180, thenif (a + b) >= c or (b + c) >= a or (a + c) >= b, thenreturn Trueotherwise,return False
if (a + b) >= c or (b + c) >= a or (a + c) >= b, thenreturn True
return True
otherwise,return False
return False
otherwise,return False
return False
Let us see the following implementation to get better understanding −
 Live Demo
def solve(a, b, c):
   if a != 0 and b != 0 and c != 0 and (a + b + c) == 180:
      if (a + b)>= c or (b + c)>= a or (a + c)>= b:
         return True
      else:
         return False
   else:
      return False
a = 40
b = 120
c = 20
print(solve(a, b, c))
40, 120, 20
True
Extract Tweets using GetOldTweets3 - GeeksforGeeks

29 Aug, 2020
For most text mining or classification projects, extracting tweets is one of the most important and initial steps. The well-known method is extracting tweets with tweepy and creating a developer account in twitter. Due to certain security reasons, Twitter takes nearly 15 days to verify the process of making a developer account. Thus using this python library makes the process easy. Another advantage of using this library is that the tweets are pretty recent tweets. One can get tweets from previous months or even weeks.
Let’s understand the working better with a code – 
Installing the library GetOldTweets3 – The following command can be installed in a Jupyter Notebook or any command prompt.
pip install GetOldTweets3


Specify the needed hashtag – After installing the library it will be imported with another variable. With the inbuilt method TweetCriteria() the needed specifications in our dataset of tweets can be mentioned. The method setQuerySearch() allows getting any tweets with respect to our hashtag
import GetOldTweets3 as got

    gettweet = got.manager.TweetCriteria().setQuerySearch(hashtag) \ 
    #'\' is similar to ', in a sentence' i.e 
    used to separate


More specifications can be added. There are many
.setSince("2020-01-01") \
.setUntil("2020-05-01") \
.setMaxTweets(100)\
.setLocation("Pune")\
.setUsername("Raj")\...etc.


Let’s see the complete code
Python3
import GetOldTweets3 as got  def extract_tweets(hashtag):          gettweet= got.manager.TweetCriteria().setQuerySearch(hashtag) \        .setSince("2020-01-01") \        .setUntil("2020-05-01") \        .setMaxTweets(100)          # Creation of list that contains all tweets    tweets = got.manager.TweetManager.getTweets(gettweet)          # Creating list of chosen tweet data    text_tweets = [[tweet.text] for tweet in tweets]    print(text_tweets)  # calling the functionextract_tweets('COVID19')
Output:
GfG-GetOldTweets3
Some tweets are in different languages. One can use the translator() function of Python to convert those tweets in a distinct language.
python-modules
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
Selecting rows in pandas DataFrame based on conditions
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
How to perform different commands over ssh with Python?

The simplest way to use SSH using python is to use paramiko. You can install it using −
$ pip install paramiko
To use paramiko, ensure that you have correctly set up SSH keys(https://confluence.atlassian.com/bitbucketserver/creating-ssh-keys-776639788.html) on the host machine and when running the python script, these keys are accessible. Once that is done use the following code to connect to a remote server using ssh −
from paramiko import SSHClient
ssh = SSHClient()
ssh.load_system_host_keys()
ssh.connect('user@server:path')
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command('ls')
print(ssh_stdout) #print the output of ls command
You can use the exec_command function to run any command supported by the server you're connected to over ssh. Running the above code will give you the directory listing on the remote server.
C# Method Overloading

With method overloading, multiple methods can have the same name with different
parameters:
int MyMethod(int x)
float MyMethod(float x)
double MyMethod(double x, double y)
Consider the following example, which have two methods that add numbers of different type:
static int PlusMethodInt(int x, int y)
{
  return x + y;
}

static double PlusMethodDouble(double x, double y)
{
  return x + y;
}

static void Main(string[] args)
{
  int myNum1 = PlusMethodInt(8, 5);
  double myNum2 = PlusMethodDouble(4.3, 6.26);
  Console.WriteLine("Int: " + myNum1);
  Console.WriteLine("Double: " + myNum2);
}

Try it Yourself »

Instead of defining two methods that should do the same thing, it is better to overload one. 
In the example below, we overload the PlusMethod 
method to work for both int 
and double:
static int PlusMethod(int x, int y)
{
  return x + y;
}

static double PlusMethod(double x, double y)
{
  return x + y;
}

static void Main(string[] args)
{
  int myNum1 = PlusMethod(8, 5);
  double myNum2 = PlusMethod(4.3, 6.26);
  Console.WriteLine("Int: " + myNum1);
  Console.WriteLine("Double: " + myNum2);
} 
 
 
 


Try it Yourself »

Note: Multiple methods can have the same name 
  as long as the number and/or type of parameters are different.
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.
WPF - Keyboard

There are many types of keyboard inputs such as KeyDown, KeyUp, TextInput, etc. In the following example, some of the keyboard inputs are handled. The following example defines a handler for the Click event and a handler for the KeyDown event.
Let’s create a new WPF project with the name WPFKeyboardInput.
Let’s create a new WPF project with the name WPFKeyboardInput.
Drag a textbox and a button to a stack panel and set the following properties and events as shown in the following XAML file.
Drag a textbox and a button to a stack panel and set the following properties and events as shown in the following XAML file.
<Window x:Class = "WPFKeyboardInput.MainWindow" 
   xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
   xmlns:x = "http://schemas.microsoft.com/winfx/2006/xaml" 
   xmlns:d = "http://schemas.microsoft.com/expression/blend/2008" 
   xmlns:mc = "http://schemas.openxmlformats.org/markup-compatibility/2006" 
   xmlns:local = "clr-namespace:WPFKeyboardInput" 
   mc:Ignorable = "d" Title = "MainWindow" Height = "350" Width = "604"> 
	
   <Grid> 
      <StackPanel Orientation = "Horizontal" KeyDown = "OnTextInputKeyDown"> 
         <TextBox Width = "400" Height = "30" Margin = "10"/> 
         <Button Click = "OnTextInputButtonClick"
            Content = "Open" Margin = "10" Width = "50" Height = "30"/> 
      </StackPanel> 
   </Grid> 
	
</Window> 
Here is the C# code in which different keyboard and click events are handled.
using System.Windows; 
using System.Windows.Input; 

namespace WPFKeyboardInput { 
   /// <summary> 
      /// Interaction logic for MainWindow.xaml 
   /// </summary> 
	
   public partial class MainWindow : Window { 
	
      public MainWindow() { 
         InitializeComponent(); 
      } 
		
      private void OnTextInputKeyDown(object sender, KeyEventArgs e) {
		
         if (e.Key == Key.O && Keyboard.Modifiers == ModifierKeys.Control) { 
            handle(); 
            e.Handled = true; 
         } 
			
      } 
		
      private void OnTextInputButtonClick(object sender, RoutedEventArgs e) { 
         handle(); 
         e.Handled = true; 
      } 
		
      public void handle() { 
         MessageBox.Show("Do you want to open a file?"); 
      }
		
   } 
}
When the above code is compiled and executed, it will produce the following window −
If you click the Open button or press CTRL+O keys inside textbox, it will display the same message.

    31 Lectures 
     2.5 hours 

 Anadi Sharma

    30 Lectures 
     2.5 hours 

 Taurius Litvinavicius
 Print
 Add Notes
 Bookmark this page
Using DELETE Expression

In the previous chapter, we have understood what an Update expression does. The next expression that we are going to learn is Delete.
The delete operation can be achieved by running delete() method on target table object as given in the following statement −
stmt = students.delete()
In case of students table, the above line of code constructs a SQL expression as following −
'DELETE FROM students'
However, this will delete all rows in students table. Usually DELETE query is associated with a logical expression specified by WHERE clause. The following statement shows where parameter −
stmt = students.delete().where(students.c.id > 2)
The resultant SQL expression will have a bound parameter which will be substituted at runtime when the statement is executed.
'DELETE FROM students WHERE students.id > :id_1'
Following code example will delete those rows from students table having lastname as ‘Khanna’ −
from sqlalchemy.sql.expression import update
from sqlalchemy import create_engine, MetaData, Table, Column, Integer, String
engine = create_engine('sqlite:///college.db', echo = True)

meta = MetaData()

students = Table(
   'students', meta, 
   Column('id', Integer, primary_key = True), 
   Column('name', String), 
   Column('lastname', String), 
)

conn = engine.connect()
stmt = students.delete().where(students.c.lastname == 'Khanna')
conn.execute(stmt)
s = students.select()
conn.execute(s).fetchall()
To verify the result, refresh the data view of students table in SQLiteStudio.

    21 Lectures 
     1.5 hours 

 Jack Chan
 Print
 Add Notes
 Bookmark this page
PHP microtime() Function

The microtime() function returns the current Unix timestamp with microseconds. By default, this function returns a string value which contains microseconds and seconds separated by space (msec sec).
microtime($get_as_float)

get_as_float(Optional)
This is a boolean value which is used to specify whether the result should be a floating point value or not. If you pass the boolean value true as a parameter, this function returns result as floating point value.
PHP microtime() function returns the current Unix timestamp. By default this returns a string value in the form msec sec. If you pass the boolean value true as a parameter to this method, it returns the current time in seconds since the Unix epoch accurate to the nearest microsecond. 
This function was first introduced in PHP Version 4 and, works with all the later versions.
Following example demonstrates the usage of the microtime() function −
<?php
   $time = microtime();
   print($time);
?>
This will produce following result −
0.60664200 1589305212

Lets try to set the get_as_float value to true −
<?php
   $time = gettimeofday(true);    
   print_r($time); 
?>
This will produce following result −
1589298812.5101

<?php
   $time_start = microtime(true);
   usleep(100);
   
   $time_end = microtime(true);
   $time = $time_end - $time_start;
   
   echo "Did nothing in $time seconds\n";
?>
This produces the following result −
Did nothing in 0.0018141269683838 seconds


    45 Lectures 
     9 hours 

 Malhar Lathkar

    34 Lectures 
     4 hours 

 Syed Raza

    84 Lectures 
     5.5 hours 

 Frahaan Hussain

    17 Lectures 
     1 hours 

 Nivedita Jain

    100 Lectures 
     34 hours 

 Azaz Patel

    43 Lectures 
     5.5 hours 

 Vijay Kumar Parvatha Reddy
 Print
 Add Notes
 Bookmark this page
C++ Increment and Decrement Operators

The increment operator ++ adds 1 to its operand, and the decrement operator -- subtracts 1 from its operand. Thus −
x = x+1;
 
is the same as
 
x++;

And similarly −
x = x-1;
 
is the same as
 
x--;

Both the increment and decrement operators can either precede (prefix) or follow (postfix) the operand. For example −
x = x+1;
 
can be written as
 
++x; // prefix form

or as −
x++; // postfix form

When an increment or decrement is used as part of an expression, there is an important difference in prefix and postfix forms. If you are using prefix form then increment or decrement will be done before rest of the expression, and if you are using postfix form, then increment or decrement will be done after the complete expression is evaluated.
Following is the example to understand this difference −
#include <iostream>
using namespace std;
 
main() {
   int a = 21;
   int c ;
 
   // Value of a will not be increased before assignment.
   c = a++;   
   cout << "Line 1 - Value of a++ is :" << c << endl ;
 
   // After expression value of a is increased
   cout << "Line 2 - Value of a is :" << a << endl ;
 
   // Value of a will be increased before assignment.
   c = ++a;  
   cout << "Line 3 - Value of ++a is  :" << c << endl ;
   return 0;
}
When the above code is compiled and executed, it produces the following result −
Line 1 - Value of a++ is :21
Line 2 - Value of a is :22
Line 3 - Value of ++a is  :23


    154 Lectures 
     11.5 hours 

 Arnab Chakraborty

    14 Lectures 
     57 mins

 Kaushik Roy Chowdhury

    30 Lectures 
     12.5 hours 

 Frahaan Hussain

    54 Lectures 
     3.5 hours 

 Frahaan Hussain

    77 Lectures 
     5.5 hours 

 Frahaan Hussain

    12 Lectures 
     3.5 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page
Some interesting facts about static member functions in C++ - GeeksforGeeks

30 Oct, 2020
1) static member functions do not have this pointer. For example following program fails in compilation with error “`this’ is unavailable for static member functions “
CPP
#include<iostream>class Test {        static Test * fun() {     return this; // compiler error   }};  int main(){   getchar();   return 0;}
2) A static member function cannot be virtual (See this G-Fact)3) Member function declarations with the same name and the name parameter-type-list cannot be overloaded if any of them is a static member function declaration. For example, following program fails in compilation with error “‘void Test::fun()’ and `static void Test::fun()’ cannot be overloaded “
CPP
#include<iostream>class Test {   static void fun() {}   void fun() {} // compiler error};  int main(){   getchar();   return 0;}
4) A static member function can not be declared const, volatile, or const volatile. For example, following program fails in compilation with error “static member function `static void Test::fun()’ cannot have `const’ method qualifier ” 
CPP
#include<iostream>class Test {        static void fun() const { // compiler error     return;   }};  int main(){   getchar();   return 0;}
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.References: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf
bhuvanchandra825
C++-Static Keyword
Static Keyword
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Socket Programming in C/C++
Operator Overloading in C++
Multidimensional Arrays in C / C++
vector erase() and clear() in C++
rand() and srand() in C/C++
Templates in C++ with Examples
unordered_map in C++ STL
C++ Data Types
Left Shift and Right Shift Operators in C/C++
Sorting a vector in C++
How to disable MySQL foreign key checks and what are the benefits of
disabling it?

We can disable foreign key checks with the help of the following statement −
mysql> Set foreign_key_checks = 0;
Query OK, 0 rows affected (0.00 sec)
And we can enable it with the help of the following statement −
mysql> Set foreign_key_checks = 1;
Query OK, 0 rows affected (0.00 sec)
Some benefits of disabling foreign key checks are as follows −
After disabling foreign key checks we can load data into parent and child table in any order. Otherwise, we must have to load the data first in the parent table and then in the child table.
Without disabling foreign key checks we cannot drop a table that is referenced by a foreign key constraint.
Dart Programming - Map

The Map object is a simple key/value pair. Keys and values in a map may be of any type. A Map is a dynamic collection. In other words, Maps can grow and shrink at runtime.
Maps can be declared in two ways −
Using Map Literals
Using a Map constructor
To declare a map using map literals, you need to enclose the key-value pairs within a pair of curly brackets "{  }".
Here is its syntax −
var identifier = { key1:value1, key2:value2 [,.....,key_n:value_n] }

To declare a Map using a Map constructor, we have two steps. First, declare the map and second, initialize the map.
The syntax to declare a map is as follows −
var identifier = new Map()

Now, use the following syntax to initialize the map −
map_name[key] = value

void main() { 
   var details = {'Usrname':'tom','Password':'pass@123'}; 
   print(details); 
}
It will produce the following output −
{Usrname: tom, Password: pass@123}

void main() { 
   var details = {'Usrname':'tom','Password':'pass@123'}; 
   details['Uid'] = 'U1oo1'; 
   print(details); 
} 
It will produce the following output −
{Usrname: tom, Password: pass@123, Uid: U1oo1}

void main() { 
   var details = new Map(); 
   details['Usrname'] = 'admin'; 
   details['Password'] = 'admin@123'; 
   print(details); 
} 
It will produce the following output −
{Usrname: admin, Password: admin@123}

Note − A map value can be any object including NULL.
The Map class in the dart:core package defines the following properties −
Returns an iterable object representing keys
Returns an iterable object representing values
Returns the size of the Map
Returns true if the Map is an empty Map
Returns true if the Map is an empty Map
Following are the commonly used functions for manipulating Maps in Dart.
Adds all key-value pairs of other to this map.
Removes all pairs from the map.
Removes key and its associated value, if present, from the map.
Applies f to each key-value pair of the map.

    44 Lectures 
     4.5 hours 

 Sriyank Siddhartha

    34 Lectures 
     4 hours 

 Sriyank Siddhartha

    69 Lectures 
     4 hours 

 Frahaan Hussain

    117 Lectures 
     10 hours 

 Frahaan Hussain

    22 Lectures 
     1.5 hours 

 Pranjal Srivastava

    34 Lectures 
     3 hours 

 Pranjal Srivastava
 Print
 Add Notes
 Bookmark this page
C# Bitwise and Bit Shift Operators

Bitwise operator works on bits and performs bit by bit operation.
The Bitwise operators supported by C# are listed in the following table. Assume variable A holds 60 and variable B holds 13 −
The following is an example showing how to implement the Bitwise operators in C#.
Live Demo
using System;
namespace MyApplication {
   class Program {
      static void Main(string[] args) {
         int a = 60; /* 60 = 0011 1100 */
         int b = 13; /* 13 = 0000 1101 */
         int c = 0;
         // Bitwise AND Operator
         c = a &amp; b; /* 12 = 0000 1100 */
         Console.WriteLine("Line 1 - Value of c is {0}", c );
         // Bitwise OR Operator
         c = a | b; /* 61 = 0011 1101 */
         Console.WriteLine("Line 2 - Value of c is {0}", c);
         // Bitwise XOR Operator
         c = a ^ b; /* 49 = 0011 0001 */
         Console.WriteLine("Line 3 - Value of c is {0}", c);
         // Bitwise Complement Operator
         c = ~a; /*-61 = 1100 0011 */
         Console.WriteLine("Line 4 - Value of c is {0}", c);
         // Bitwise Left Shift Operator
         c = a << 2; /* 240 = 1111 0000 */
         Console.WriteLine("Line 5 - Value of c is {0}", c);
         // Bitwise Right Shift Operator
         c = a >> 2; /* 15 = 0000 1111 */
         Console.WriteLine("Line 6 - Value of c is {0}", c);
         Console.ReadLine();
      }
   }
}
Line 1 - Value of c is 12
Line 2 - Value of c is 61
Line 3 - Value of c is 49
Line 4 - Value of c is -61
Line 5 - Value of c is 240
Line 6 - Value of c is 15
How to serialize a null field using Gson library in Java?

By default, the Gson object does not serialize the fields with null values to JSON. If a field in a Java object is null, Gson excludes it. We can force Gson to serialize null values via the GsonBuilder class. We need to call the serializeNulls() method on the GsonBuilder instance before creating the Gson object. Once serializeNulls() has been called the Gson instance created by the GsonBuilder can include null fields in the serialized JSON.
public GsonBuilder serializeNulls()
import com.google.gson.*;
import com.google.gson.annotations.*;
public class NullFieldTest {
   public static void main(String args[]) {
      GsonBuilder builder = new GsonBuilder();
      builder.serializeNulls();
      Gson gson = builder.setPrettyPrinting().create();
      Employee emp = new Employee(null, 25, 40000.00);
      String jsonEmp = gson.toJson(emp);
      System.out.println(jsonEmp);
   }
}
// Employee class
class Employee {
   @Since(1.0)
   public String name;
   @Since(1.0)
   public int age;
   @Since(2.0)
   public double salary;
   public Employee(String name, int age, double salary) {
      this.name = name;
      this.age = age;
      this.salary = salary;
   }
}
{
   "name": null,
   "age": 25,
   "salary": 40000.0
}
C library function - mblen()

The C library function int mblen(const char *str, size_t n) returns the length of a multi-byte character pointed to, by the argument str.
Following is the declaration for mblen() function.
int mblen(const char *str, size_t n)
str − This is the pointer to the first byte of a multibyte character.
str − This is the pointer to the first byte of a multibyte character.
n − This is the maximum number of bytes to be checked for character length.
n − This is the maximum number of bytes to be checked for character length.
 The mblen() function returns the number of bytes passed from the multi-byte sequence starting at str, if a non-null wide character was recognized. It returns 0, if a null wide character  was  recognized. It returns -1, if an invalid multi-byte sequence was encountered or if it could not parse a complete multi-byte character.
The following example shows the usage of mblen() function.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main () {
   int len;
   char *pmbnull  = NULL;
   char *pmb = (char *)malloc( MB_CUR_MAX );
   wchar_t *pwc = L"Hi";
   wchar_t *pwcs = (wchar_t *)malloc( sizeof( wchar_t ));

   printf("Converting to multibyte string\n");
   len = wcstombs( pmb, pwc, MB_CUR_MAX);
   printf("Characters converted %d\n", len);
   printf("Hex value of first multibyte character: %#.4x\n", pmb);
   
   len = mblen( pmb, MB_CUR_MAX );
   printf( "Length in bytes of multibyte character %x: %u\n", pmb, len );
   
   pmb = NULL;
   
   len = mblen( pmb, MB_CUR_MAX );
   printf( "Length in bytes of multibyte character %x: %u\n", pmb, len );
   
   return(0);
}
Let us compile and run the above program that will produce the following result −
Converting to multibyte string
Characters converted 1
Hex value of first multibyte character: 0x168c6010
Length in bytes of multibyte character 168c6010: 1
Length in bytes of multibyte character 0: 0


    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 to create an inline frame using HTML5 ? - GeeksforGeeks

30 Jun, 2020
In this article, we will create an inline iframe by using a <iframe> tag in a document.It represents a fixed rectangular area within the document in which the browser can display a separate document along with scroll bars and borders. Inline frames are used to embed another document within the current HTML page.Syntax :
<iframe src="URL"></iframe>
Example:
<!DOCTYPE html><html>  <head>    <title>        How to create an inline         frame using HTML5?    </title></head>  <body>    <h2>Hlo GeeksForGeeks</h2>      <h2>        How to create an inline         frame using HTML5?    </h2>      <p>Content goes here</p>      <iframe src="https://ide.geeksforgeeks.org/tryit.php"         height="300" width="400">    </iframe>  </body>  </html> 
Output:
Example 2:
<!DOCTYPE html><html>  <head>    <title>        How to create an inline         frame using HTML5?    </title></head>  <body>    <h2>Hlo GeeksForGeeks</h2>      <h2>        How to create an inline         frame using HTML5?    </h2>      <iframe height="300" width="350"        src="https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190717121605/Screenshot-from-2019-07-17-12-12-55.png"        name="iframe_a"></iframe>  </body>  </html>
Output:
Supported Browser are listed below:
Google Chrome
Internet Explorer
Firefox
Opera
Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Misc
HTML5
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
How to apply style to parent if it has child with CSS?
Types of CSS (Cascading Style Sheet)
How to position a div at the bottom of its container using CSS?
How to set space between the flexbox ?
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
REST API (Introduction)
HTML Cheat Sheet - A Basic Guide to HTML
C++ Assignment Operators

Try the following example to understand all the assignment operators available in C++.
Copy and paste the following C++ program in test.cpp file and compile and run this program.
#include <iostream>
using namespace std;

main() {
   int a = 21;
   int c ;

   c =  a;
   cout << "Line 1 - =  Operator, Value of c = : " <<c<< endl ;

   c +=  a;
   cout << "Line 2 - += Operator, Value of c = : " <<c<< endl ;

   c -=  a;
   cout << "Line 3 - -= Operator, Value of c = : " <<c<< endl ;

   c *=  a;
   cout << "Line 4 - *= Operator, Value of c = : " <<c<< endl ;

   c /=  a;
   cout << "Line 5 - /= Operator, Value of c = : " <<c<< endl ;

   c  = 200;
   c %=  a;
   cout << "Line 6 - %= Operator, Value of c = : " <<c<< endl ;

   c <<=  2;
   cout << "Line 7 - <<= Operator, Value of c = : " <<c<< endl ;

   c >>=  2;
   cout << "Line 8 - >>= Operator, Value of c = : " <<c<< endl ;

   c &=  2;
   cout << "Line 9 - &= Operator, Value of c = : " <<c<< endl ;

   c ^=  2;
   cout << "Line 10 - ^= Operator, Value of c = : " <<c<< endl ;

   c |=  2;
   cout << "Line 11 - |= Operator, Value of c = : " <<c<< endl ;

   return 0;
}
When the above code is compiled and executed, it produces the following result −
Line 1 - =  Operator, Value of c = : 21
Line 2 - += Operator, Value of c = : 42
Line 3 - -= Operator, Value of c = : 21
Line 4 - *= Operator, Value of c = : 441
Line 5 - /= Operator, Value of c = : 21
Line 6 - %= Operator, Value of c = : 11
Line 7 - <<= Operator, Value of c = : 44
Line 8 - >>= Operator, Value of c = : 11
Line 9 - &= Operator, Value of c = : 2
Line 10 - ^= Operator, Value of c = : 0
Line 11 - |= Operator, Value of c = : 2


    154 Lectures 
     11.5 hours 

 Arnab Chakraborty

    14 Lectures 
     57 mins

 Kaushik Roy Chowdhury

    30 Lectures 
     12.5 hours 

 Frahaan Hussain

    54 Lectures 
     3.5 hours 

 Frahaan Hussain

    77 Lectures 
     5.5 hours 

 Frahaan Hussain

    12 Lectures 
     3.5 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page
Can static variables be called using className.variableName in Java?

Class variables also known as static variables are declared with the static keyword There would only be one copy of each class variable per class, regardless of how many objects are created from it. You can access a class variable without instantiation using the class name as className.variableName.
 Live Demo
public class Test{
   static int num = 92;
   
   public static void main(String args[]) throws Exception {
      System.out.println(Test.num);
   }
}
92
Format double type in Java

Let’s say we have the following three values −
double val1 = 15.546;
double val2 = 25.87;
double val3 = Math.PI;
Let us now format these double-type numbers. Firstly, we are formatting Euler’s number with Math.exp(). After that, we have also evaluated log. The %.3f you can see here is what we used for formatting the numbers.
System.out.printf("exp(%.3f) = %.3f%n", val1, Math.exp(val1));
System.out.printf("log = %.3f%n", val1, Math.log(val1));
The following is an example where we have also shown other ways to format double in Java.
 Live Demo
public class Demo {
   public static void main(String args[]) {
      double val1 = 15.546;
      double val2 = 25.87;
      double val3 = Math.PI;
      System.out.format("%f%n", val1);
      System.out.printf("exp(%.3f) = %.3f%n", val1, Math.exp(val1));
      System.out.printf("log = %.3f%n", val1, Math.log(val1));
      System.out.format("%3f%n", val2);
      System.out.format("%+3f%n", val2);
      System.out.format("%f%n", val3);
      System.out.format("%.3f%n", val3);
      System.out.printf("pow(%.3f, %.3f) = %.3f%n", val1, val2, Math.pow(val1, val2));
   }
}
15.546000
exp(15.546) = 5643415.357
log = 15.546
25.870000
+25.870000
3.141593
3.142
pow(15.546, 25.870) = 6716991850252629000000000000000.000