code-rag-bench/online-tutorials huggingface dataset:
Scope Resolution operator in PHP

21 Jul, 2021
The scope resolution operator also known as Paamayim Nekudotayim or more commonly known as the double colon is a token that allows access to static, constant, and overridden properties or methods of a class.
It is used to refer to blocks or codes in context to classes, objects, etc. An identifier is used with the scope resolution operator. The most common example of the application of the scope resolution operator in PHP is to access the properties and methods of the class. 
The following examples show the usage of the scope resolution operator in various scenarios.
Example 1: This type of definition is used while defining constants within a class.
PHP
<?php  class democlass {    const PI = 3.14;}  echo democlass::PI;  ?>
Output: 
3.14
Example 2: Three special keywords self, parent, and static are used to access properties or methods from inside the class definition. 
PHP
<?php  // Declaring parent classclass demo{      public static $bar=10;      public static function func(){          echo static::$bar."\n";    }}  // Declaring child classclass Child extends demo{      public static $bar=20;  }  // Calling for demo's version of func()demo::func();  // Calling for child's version of func()Child::func();  ?>
Output: 
10 
20
Example 3: When an extending class overrides its parent’s function, the compiler calls the child class’s version of the method but it is up to the child class to call its parent’s version of the method.
PHP
<?php  class demo{      public function myfunc() {        echo "myfunc() of parent class\n ";    }}  class child extends demo {      public function myfunc(){           // Calling parent's version         // of myfunc() method        parent::myfunc();          echo "myfunc() of child class";    }}  $class = new child;$class -> myfunc()  ?>
Output: 
myfunc() of parent class 
myfunc() of child class
 
sagar0719kumar
PHP-Operators
PHP
PHP Programs
Write From Home
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to fetch data from localserver database and display on HTML table using PHP ?
Difference between HTTP GET and POST Methods
Different ways for passing data to view in Laravel
PHP | file_exists( ) Function
PHP | Ternary Operator
How to call PHP function on the click of a Button ?
How to fetch data from localserver database and display on HTML table using PHP ?
PHP | Ternary Operator
How to create admin login page using PHP?
How to send an email using PHPMailer ?
Batch Script - MOVE

This batch command moves files or directories between directories.
move [source] [destination]

The files will be copied from source to destination location.
The following example shows the different variants of the move command.
@echo off
Rem Moves the file list.txt to the directory c:\tp
move C:\lists.txt c:\tp
Rem Renames directory Dir1 to Dir2, assuming Dir1 is a directory and Dir2 does not exist. 
move Dir1 Dir2
Rem Moves the file lists.txt to the current directory.
move C:\lists.txt
All actions are performed as per the remarks in the batch file.
Create a responsive navigation menu with CSS Media Queries

Media Queries is used when you need to set a style to different devices such as tablet, mobile, desktop, etc.
You can try to run the following code to create a responsive navigation menu with Media Queries:
Live Demo
<!DOCTYPE html>
<html lang = "en">
   <head>
      <meta charset = "utf-8">
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <style>
         .demo {
            overflow: hidden;
            background-color: blue;
         }
         .demo a {
            float: left;
            display: block;
            color: white;
            text-align: center;
            padding: 10px;
            text-decoration: none;
         }
         @media screen and (max-width: 600px) {
            .demo a {
               float: none;
               width: 100%;
            }
         }
      </style>
   </head>
   <body>
      <p>Navigation Menu:</p>
      <div class = "demo">
         <a href = "#">Home</a>
         <a href = "#">About</a>
         <a href = "#">Tutorials</a>
         <a href = "#">QA</a>
         <a href = "#">Videos</a>
         <a href = "#">Contact</a>
      </div>
   </body>
</html>
Define Node position in Sankey Diagram in plotly

15 Feb, 2022
Plotly is a Python library which is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library.
Sankey Diagram is used to visualize the flow by defining the source node and target node. Value parameters is used to set the flow volume. There are basically arrangement for defining a node position. There are –
perpendicular
freeform
fixed
The node position can be set by setting the node.x and node.y value. let’s see the below example for better understanding.
Example 1:
Python3
import plotly.graph_objects as go    plot = go.Figure(go.Sankey(    node = {        "label": ["A", "B", "C"],        "x": [0.5, 0.2, 0.1],        "y": [0.4, 0.3, 0.7],        'pad':5},    link = {        "source": [1, 0, 1],        "target": [2, 3, 4],        "value": [4, 2, 1]}))  plot.show()
Output:
Example 2:
Python3
import plotly.graph_objects as go    plot = go.Figure(go.Sankey(    node = {        "label": ["Geeks", "For", "Geeks", "GFG"],        "x": [0.5, 0.2, 0.1, 0.9],        "y": [0.6, 0.8, 0.7],        "color": "green",        'pad':5},    link = {        "source": [3, 2, 1],        "target": [5, 3, 7],        "value": [6, 1, 2]}))  plot.show()
Output:
clintra
Data Visualization
Python-Plotly
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Convert integer to string in Python
How to handle SSL certificate error using Selenium WebDriver?

We can handle SSL certificate error using Selenium webdriver while we try to launch a web page based on HTTP. SSL certificate errors are encountered in multiple browsers like Chrome, Safari, and Firefox and so on.
SSL certificate error comes up if the site we are making an attempt to access has an outdated, invalid or an untrusted certificate. SSL or Secure Sockets Layer is a protocol followed to create a connection between the client (browser) and the server.
To handle the SSL certificate error we have to use the DesiredCapabilities class and then accept the SSL error by setting the ACCEPT_SSL_CERTS to true and applying this capability to the browser
DesiredCapabilities c=DesiredCapabilities.internetExplorer();
c.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
public class SSLError{
   public static void main(String[] args) {
      //DesiredCapabilities object
      DesiredCapabilities c=DesiredCapabilities.internetExplorer();
      //set SSL certificate to true
      c.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
      System.setProperty("webdriver.ie.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\IEDriverServer.exe");
      //configure capability to browser
      WebDriver driver = new InternetExplorerDriver(c);
      //implicit wait
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      //URL launch
      driver.get("application url to be entered");
   }
}
Python Dictionary | Check if binary representations of two numbers are anagram

27 Jul, 2020
Given two numbers you are required to check whether they are anagrams of each other or not in binary representation.
Examples:
Input : a = 8, b = 4 
Output : Yes
Binary representations of both
numbers have same 0s and 1s.

Input : a = 4, b = 5
Output : No

We have existing solution for this problem please refer Check if binary representations of two numbers are anagram link. We can solve this problem quickly in python using Counter(iterable) method and Dictionary Comparison. Approach is simple,
Convert both number into it’s binary using bin() function.Since binary representation of both numbers could differ in length so we will append zeros in start of shorter string to make both string of equal length. ie.; append zeros = abs(len(bin1)-len(bin2)).Convert both output string containing 0 and 1 returned by bin function into dictionary using Counter() function, having 0 and 1 keys and their count as value. Compare both dictionaries, if value of 0’s and 1’s in both dictionaries are equal then binary representations of two numbers are anagram otherwise not.
Convert both number into it’s binary using bin() function.
Since binary representation of both numbers could differ in length so we will append zeros in start of shorter string to make both string of equal length. ie.; append zeros = abs(len(bin1)-len(bin2)).
Convert both output string containing 0 and 1 returned by bin function into dictionary using Counter() function, having 0 and 1 keys and their count as value. Compare both dictionaries, if value of 0’s and 1’s in both dictionaries are equal then binary representations of two numbers are anagram otherwise not.
# function to Check if binary representations# of two numbers are anagramfrom collections import Counter  def checkAnagram(num1,num2):      # convert numbers into in binary    # and remove first two characters of     # output string because bin function     # '0b' as prefix in output string    bin1 = bin(num1)[2:]    bin2 = bin(num2)[2:]      # append zeros in shorter string    zeros = abs(len(bin1)-len(bin2))    if (len(bin1)>len(bin2)):         bin2 = zeros * '0' + bin2    else:         bin1 = zeros * '0' + bin1      # convert binary representations     # into dictionary    dict1 = Counter(bin1)    dict2 = Counter(bin2)      # compare both dictionaries    if dict1 == dict2:         print('Yes')    else:         print('No')  # Driver programif __name__ == "__main__":    num1 = 8    num2 = 4    checkAnagram(num1,num2)     
Output:
Yes

Akanksha_Rai
base-conversion
Python dictionary-programs
python-dict
Python
python-dict
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Groovy - size()

Obtains the number of elements in this List.
int size()

None
The size of the list.
Following is an example of the usage of this method −
class Example {
   static void main(String[] args) {
      def lst = [11, 12, 13, 14];
      println(lst.size);
   } 
}
When we run the above program, we will get the following result −
4


    52 Lectures 
     8 hours 

 Krishna Sakinala

    49 Lectures 
     2.5 hours 

 Packt Publishing
 Print
 Add Notes
 Bookmark this page
Swing Examples - Add Border to JLabel

Following example showcase how to add border to a JLabel in a Java Swing application.
We are using the following APIs.
BorderFactory.createLineBorder() − To create a line border.
BorderFactory.createLineBorder() − To create a line border.
JLabel.setBorder(border) − To set the desired border to the JLabel.
JLabel.setBorder(border) − To set the desired border to the JLabel.
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.LayoutManager;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.Border;

public class SwingTester {
   public static void main(String[] args) {
      createWindow();
   }

   private static void createWindow() {    
      JFrame frame = new JFrame("Swing Tester");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      createUI(frame);
      frame.setSize(560, 200);      
      frame.setLocationRelativeTo(null);  
      frame.setVisible(true);
   }

   private static void createUI(JFrame frame){
      //Create a border
      Border blackline = BorderFactory.createLineBorder(Color.black);
      JPanel panel = new JPanel();
      LayoutManager layout = new FlowLayout();  
      panel.setLayout(layout);       
      JPanel panel1 = new JPanel();
      String spaces = "                   ";
      JLabel label = new JLabel(spaces + "Border to JLabel" + spaces);
      label.setBorder(blackline);
      panel1.add(label);  
      panel1.add( new JLabel(spaces + "JLabel with no border" + spaces));  
      panel.add(panel1);
      frame.getContentPane().add(panel, BorderLayout.CENTER);    
   }
}
 Print
 Add Notes
 Bookmark this page
How to view the complete output of tibble in R?

Tibbles are created when we analyze data using dplyr package and if the data size is large then only 10 values are printed in R. If we want to display the complete output of tibble then View function needs to be used. For example, if we want to perform calculation of counts then we should add View() at the end of the code with pipe operator.
 Live Demo
Consider the below data frame −
Group<−rep(c("A","B","C","D","E"),times=10)
Rating<−sample(1:10,50,replace=TRUE)
df<−data.frame(Group,Rating)
head(df,20)
Group Rating
1 A 4
2 B 2
3 C 8
4 D 3
5 E 3
6 A 1
7 B 8
8 C 8
9 D 1
10 E 2
11 A 2
12 B 8
13 C 10
14 D 4
15 E 6
16 A 3
17 B 7
18 C 1
19 D 5
20 E 10
tail(df,20)
Group Rating
31 A 2
32 B 5
33 C 4
34 D 1
35 E 4
36 A 8
37 B 2
38 C 6
39 D 2
40 E 5
41 A 1
42 B 4
43 C 9
44 D 5
45 E 2
46 A 7
47 B 10
48 C 9
49 D 1
50 E 6
Loading dplyr package −
library(dplyr)

Finding the counts for Group and Rating and viewing the whole output using View() −
df%>%group_by(Group,Rating)%>%mutate(count=n())%>%View()
explode() function in PHP

The explode() function is used to split a string by string.
explode(delimiter, str, limit)
delimiter − The boundary string
delimiter − The boundary string
str − String to split
str − String to split
limit − Specifies the number of array elements to return.
limit − Specifies the number of array elements to return.
The following are possible values −Greater than 0 - Returns an array with a maximum of limit element(s)Less than 0 - Returns an array except for the last -limit elements()0 - Returns an array with one element
The following are possible values −
Greater than 0 - Returns an array with a maximum of limit element(s)
Greater than 0 - Returns an array with a maximum of limit element(s)
Less than 0 - Returns an array except for the last -limit elements()
Less than 0 - Returns an array except for the last -limit elements()
0 - Returns an array with one element
0 - Returns an array with one element
The explode() function returns an array of strings.
The following is an example −
 Live Demo
<?php
$s = "This is demo text!";
print_r (explode(" ",$s));
?>
The following is the output −
Array
(
   [0] => This
   [1] => is
   [2] => demo
   [3] => text!
)
Let us see another example −
 Live Demo
<?php
$str = 'car,bus,motorbike,cycle';
print_r(explode(',',$str,0));
print "<br>";
?>
The following is the output −
Array
(
   [0] => car,bus,motorbike,cycle
)
Let us see another example −
 Live Demo
<?php
$str = 'car,bus,motorbike,cycle';
print_r(explode(',',$str,2));
?>
The following is the output −
Array
(
   [0] => car
   [1] => bus,motorbike,cycle
)
Let us see another example −
 Live Demo
<?php
$str = 'car,bus,motorbike,cycle';
print_r(explode(',',$str,-1));
?>
The following is the output −
Array
(
   [0] => car
   [1] => bus
   [2] => motorbike
)
H2O - Flow

In the last lesson, you learned to create H2O based ML models using command line interface. H2O Flow fulfils the same purpose, but with a web-based interface.
In the following lessons, I will show you how to start H2O Flow and to run a sample application.
The H2O installation that you downloaded earlier contains the h2o.jar file. To start H2O Flow, first run this jar from the command prompt −
$ java -jar h2o.jar

When the jar runs successfully, you will get the following message on the console −
Open H2O Flow in your web browser: http://192.168.1.10:54321

Now, open the browser of your choice and type the above URL. You would see the H2O web-based desktop as shown here −
This is basically a notebook similar to Colab or Jupyter. I will show you how to load and run a sample application in this notebook while explaining the various features in Flow. Click on the view example Flows link on the above screen to see the list of provided examples.
I will describe the Airlines delay Flow example from the sample.

    14 Lectures 
     1 hours 

 Mahesh Kumar

    31 Lectures 
     1.5 hours 

 Shweta

    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    77 Lectures 
     5.5 hours 

 Ayushi Nangru

    12 Lectures 
     1.5 hours 

 Richa Maheshwari
 Print
 Add Notes
 Bookmark this page
Height of a complete binary tree (or Heap) with N nodes - GeeksforGeeks

06 Jan, 2022
Consider a Binary Heap of size N. We need to find the height of it.Examples :  
Input : N = 6
Output : 2
        ()
      /    \
     ()     ()
    /  \    /
  ()    () ()

Input : N = 9
Output :
        ()
      /    \
     ()     ()
    /  \    /  \
  ()    () ()   ()
 / \
()  ()
 
Let the size of heap be N and height be h If we take a few examples, we can notice that the value of h in a complete binary tree is floor(log2N). Examples :  
 N    h
---------
 1    0
 2    1
 3    1
 4    2
 5    2
 .....
 .....
 
C++
Java
Python 3
C#
PHP
Javascript
// CPP program to find height of complete// binary tree from total nodes.#include <bits/stdc++.h>using namespace std; int height(int N){    return floor(log2(N));} // driver nodeint main(){    int N = 2;    cout << height(N);    return 0;}
// Java program to find height// of complete binary tree// from total nodes.import java.lang.*; class GFG {         // Function to calculate height    static int height(int N)    {        return (int)Math.ceil(Math.log(N +                    1) / Math.log(2)) - 1;    }     // Driver Code    public static void main(String[] args)    {        int N = 6;        System.out.println(height(N));    }} // This code is contributed by// Smitha Dinesh Semwal
# Python 3 program to find# height of complete binary# tree from total nodes.import mathdef height(N):    return math.ceil(math.log2(N + 1)) - 1 # driver nodeN = 6print(height(N)) # This code is contributed by# Smitha Dinesh Semwal
// C# program to find height// of complete binary tree// from total nodes.using System; class GFG {    static int height(int N)    {        return (int)Math.Ceiling(Math.Log(N                   + 1) / Math.Log(2)) - 1;    }     // Driver node    public static void Main()    {        int N = 6;        Console.Write(height(N));    }} // This code is contributed by// Smitha Dinesh Semwal
<?php// PHP program to find height// of complete binary tree// from total nodes. function height($N){    return ceil(log($N + 1, 2)) - 1;} // Driver Code$N = 6;echo height($N); // This code is contributed by aj_36?>
<script>     // Javascript program to find height    // of complete binary tree    // from total nodes.         function height(N)    {        return Math.ceil(Math.log(N + 1) / Math.log(2)) - 1;    }           let N = 6;      document.write(height(N));         </script>
2
 
Smitha Dinesh Semwal
jit_t
suresh07
demishassabis
Heap
Tree
Tree
Heap
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Sliding Window Maximum (Maximum of all subarrays of size k)
Building Heap from Array
Time Complexity of building a heap
Max Heap in Java
Insertion and Deletion in Heaps
Binary Tree | Set 1 (Introduction)
AVL Tree | Set 1 (Insertion)
Binary Tree | Set 3 (Types of Binary Tree)
Binary Tree | Set 2 (Properties)
Ruby | Enumerable partition() function - GeeksforGeeks

05 Dec, 2019
The partition() of enumerable is an inbuilt method in Ruby returns two arrays, one containing the elements of the enumerable which return true, while the other contains the elements which returns false. It returns an enumerator if no block is passed.
Syntax enu.partition { |obj| block }
Parameters: The function takes a block according to which partition is to be done.
Return Value: It returns two arrays.
Example #1:
# Ruby program for partition method in Enumerable    # Initialize an enumerableenu1 = [10, 19, 18]     # Printsenu1.partition { |num| num>12} 
Output:
[[19, 18], [10]]

Example #2:
# Ruby program for partition method in Enumerable    # Initialize an enumerableenu1 = (1..100)  # Printsenu1.partition     
Output:
Enumerator: 1..100:partition

Ruby Enumerable-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Include v/s Extend in Ruby
Ruby | Enumerator each_with_index function
Global Variable in Ruby
Ruby | Array select() function
Ruby | Hash delete() function
Ruby | String gsub! Method
Ruby | String capitalize() Method
How to Make a Custom Array of Hashes in Ruby?
Ruby | Case Statement
Ruby | Decision Making (if, if-else, if-else-if, ternary) | Set - 1
How to push a Lua table as an argument?

We may want to push the Lua table as an argument to a code written in C++ which uses Lua as an embedded language and for that case we need to make use of the different API functions that the Lua library provides us with.
The Lua code will look something like the code shown below −
a = {
   numb = 10,
   create = function(a)
      print(a);
   end,
increment = function(self)
   --self.numb = 11;
   print(self.numb);
end,
decrement = function(self,i)
   self.numb = self.numb-i;
   print(self.numb);
end
};
b = a;
And the C++ code that will invoke the Lua functions will look like this −
luaL_openlibs(L);
luaL_dofile (L,"main.lua");
lua_getglobal(L, "a");
lua_getfield(L, -1, "increment");
lua_pushvalue(L,-2); // get the table a as the argument
lua_pcall(L ,1,0,0);
printf(" \nI am done with Lua in C++.\n");
lua_close(L);
In the above code, the call to lua_pushvalue(L,-2) is the one that does the magic, as it enables us to pass the table a as the argument.
11
I am done with Lua in C++
Interface Arduino with Gas Sensor

In this article, we will see how to interface Arduino with the MQ-2 gas sensor. MQ2 gas sensor is used for detecting smoke and some flammable gases like LPG, Methane, etc. It changes its resistance depending on the type of the gas. This principle can be used to raise an alarm based on the concentration of the gas.
An image of the MQ2 gas sensor is given above. As you can see, it has 4 pins. Out of these the Aout pin gives the Analog voltage in proportion to the gas concentration. Higher the gas concentration, higher the voltage on the Aout pin. Depending on your application, you can perform some trial and errors, and determine the threshold of Aout voltage above which you want to raise an alarm.
Alternatively, you can adjust the potentiometer on the other side of the sensor to set the threshold, and then use the Dout pin to get digital value (whether concentration of gas is above or below threshold).
The circuit diagram is shown below −
As you can see, Vcc of MQ2 is connected to 5V, GND to GND and Aout to A0.
The code is pretty straightforward, as you can see below −
int sensorPin = A0;
int sensorThreshold = 300;

void setup() {
   // put your setup code here, to run once:
   Serial.begin(9600);
   pinMode(sensorPin, INPUT);
}

void loop() {
   // put your main code here, to run repeatedly:
   if (analogRead(sensorPin) > sensorThreshold) {
      Serial.println("Gas concentration too high!");
   } else {
      Serial.println("Gas concentration in control");
   }
}
As discussed earlier as well, you can determine the threshold using trial and error. Also, don’t touch the sensor after it has been active for some time, because it tends to heat up. Also, you can add other actions, like ringing a buzzer, once the sensor readings cross the threshold.
Tryit Editor v3.7

Tryit: HTML image - error in source
8086 program for selection sort - GeeksforGeeks

22 May, 2018
Problem – Write an assembly language program in 8086 microprocessor to sort a given array of n numbers using Selection Sort.
Assumptions – The number of elements in the array is stored at offset 500. The array starts from offset 501.
Example –
Algorithm –
We first find the smallest number in the array.Swap the smallest number from the first element of the array.Keep repeating the process till all elements are traversed.
We first find the smallest number in the array.
Swap the smallest number from the first element of the array.
Keep repeating the process till all elements are traversed.
Program –
Explanation – Registers AH, AL, BX, CX, DL, SI, DI are used for general purpose:
AL - Stored the smallest number
AH - Stores the counter for the inner loop
BX - Stores the offset of the smallest 
     number of each iteration of the outer loop
CX - Stores the counter for the outer loop
DL - Helps in swapping the elements
SI - Pointer
DI - Pointer 
MOV SI, 500: stores 0500 in SI.MOV CL, [SI]: stores the content at offset SI in CL.XOR CH, CH: stores the result of logical operation XOR b/w CH and CH in CH.INC SI: increase the value of SI by 1.DEC CX: decrease the value of CX by 1.MOV AH, CL: stores the contents of CL in AH.CMP AL, [SI]: compares the content of AL with content at offset SI. If AL < [SI] – Sets Carry Flag(i.e. Carry Flag = 1).JC 41F: jumps to offset 041F, if carry flag is set(1).JNZ 417: jumps to offset 0417, if zero flag is reset(0).XCHG DL, [BX]: swaps the content of DL with content at offset BX.LOOP 40C: decrease the value of CX by 1 and check whether Zero Flag is set(1) or not. If Zero Flag is reset(0), then it jumps to offset 040C.HLT: terminates the program.
MOV SI, 500: stores 0500 in SI.
MOV CL, [SI]: stores the content at offset SI in CL.
XOR CH, CH: stores the result of logical operation XOR b/w CH and CH in CH.
INC SI: increase the value of SI by 1.
DEC CX: decrease the value of CX by 1.
MOV AH, CL: stores the contents of CL in AH.
CMP AL, [SI]: compares the content of AL with content at offset SI. If AL < [SI] – Sets Carry Flag(i.e. Carry Flag = 1).
JC 41F: jumps to offset 041F, if carry flag is set(1).
JNZ 417: jumps to offset 0417, if zero flag is reset(0).
XCHG DL, [BX]: swaps the content of DL with content at offset BX.
LOOP 40C: decrease the value of CX by 1 and check whether Zero Flag is set(1) or not. If Zero Flag is reset(0), then it jumps to offset 040C.
HLT: terminates the program.
microprocessor
system-programming
Computer Organization & Architecture
Sorting
Sorting
microprocessor
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Architecture of 8085 microprocessor
Computer Organization and Architecture | Pipelining | Set 2 (Dependencies and Data Hazard)
Direct Access Media (DMA) Controller in Computer Architecture
Pin diagram of 8086 microprocessor
Computer Organization | Different Instruction Cycles
Add a percentage (%) sign at the end to each value while using MySQL SELECT statement

To add percentage sign at the end, use CONCAT() function. Let us first create a table −
mysql> create table DemoTable
(
   StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   StudentName varchar(100),
   StudentScore int
);
Query OK, 0 rows affected (0.68 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(StudentName,StudentScore) values('John',65);
Query OK, 1 row affected (0.09 sec)
mysql> insert into DemoTable(StudentName,StudentScore) values('Chris',98);
Query OK, 1 row affected (0.30 sec)
mysql> insert into DemoTable(StudentName,StudentScore) values('Robert',91);
Query OK, 1 row affected (0.09 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+-------------+--------------+
| StudentId | StudentName | StudentScore |
+-----------+-------------+--------------+
|         1 | John        | 65           |
|         2 | Chris       | 98           |
|         3 | Robert      | 91           |
+-----------+-------------+--------------+
3 rows in set (0.00 sec)
Following is the query to add a percentage (%) sign to each value at the end while using MySQL SELECT statement −
mysql> select StudentId,StudentName,concat(StudentScore,'%') AS StudentScore from DemoTable;
This will produce the following output −
+-----------+-------------+--------------+
| StudentId | StudentName | StudentScore |
+-----------+-------------+--------------+
|         1 | John        | 65%          |
|         2 | Chris       | 98%          |
|         3 | Robert      | 91%          |
+-----------+-------------+--------------+
3 rows in set (0.00 sec)
Modular Multiplication - GeeksforGeeks

19 Dec, 2021
Below are some interesting properties of Modular Multiplication 
 
(a x b) mod m = ((a mod m) x (b mod m)) mod m 
(a x b x c) mod m = ((a mod m) x (b mod m) x (c mod m)) mod m 
The same property holds for more than three numbers.
 
The above formula is the extended version of the following formula: 
Example 1: Find the remainder of 15 x 17 x 19 when divided by 7. Solution: On dividing 15 by 7 we get 1 as remainder. On dividing 17 by 7 we get 3 as remainder. On dividing 19 by 7 we get 5 as remainder. Remainder of the expression (15 x 17 x 19)/7 will be equal to (1 x 3 x 5)/7. Combined remainder will be equal to remainder of 15/7 i.e. 1. 
Example 2: Find the remainder of 1421 x 1423 x 1425 when divided by 12. Solution: On dividing 1421 by 12 we get 5 as remainder. On dividing 1423 by 12 we get 7 as remainder. On dividing 1425 by 12 we get 9 as remainder. Rem [(1421 x 1423 x 1425)/12] = Rem [(5 x 7 x 9)/12] Rem [(35 x 9)/12] = Rem [(11 x 9)/12] Rem [99/12] = 3. 
How is it useful? If we need to find remainder of multiplication of two large numbers, we can avoid doing the multiplication of large numbers, especially helpful in programming where multiplication of large numbers can cause overflow. 
Proof: If we prove for two numbers, then we can easily generalize it. Let us see proof for two numbers.  
Let a % m = r1
and b % m = r2

Then a and b can be written as (using quotient
theorem).  Here q1 is quotient when we divide 
a by m and r1 is remainder. Similar meanings 
are there for q2 and r2
a = m x q1 + r1
b = m x q2 + r2

LHS = (a x b) % m

    = ((m x q1 + r1 ) x (m x q2 + r2) ) % m

    = (m x m x q1 x q2 + 
        m x q1 x r2 + 
        m x q2 x r1 + r1 x r2 ) % m

    = (m x (m x q1 x q2 + q1 x r2 + 
        q2 x r1) + 
        r1 x r2 ) % m

We can eliminate the multiples of m when
we take the mod m.
LHS = (r1 x r2) % m

RHS = (a % m x b % m) % m
    = (r1 x r2) % m

Hence, LHS = RHS
 
mortyohhgezz
Modular Arithmetic
Engineering Mathematics
GATE CS
Mathematical
Mathematical
Modular Arithmetic
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Newton's Divided Difference Interpolation Formula
Arrow Symbols in LaTeX
Set Notations in LaTeX
Activation Functions
Mathematics | Graph Isomorphisms and Connectivity
Layers of OSI Model
ACID Properties in DBMS
Normal Forms in DBMS
Types of Operating Systems
Stack Data Structure in Javascript

A stack is an Abstract Data Type (ADT), commonly used in most programming languages. It is named stack as it behaves like a real-world stack, for example – a deck of cards or a pile of plates, etc.
A stack allows operations at one end only. This feature makes it LIFO data structure. LIFO stands for Last-in-first-out. Here, the element which is placed (inserted or added) last, is accessed first. In stack terminology, insertion operation is called PUSH operation and removal operation is called POP operation.
The following diagram shows the operations on the stack −
Following is the complete Javascript class to represent a Stack −
class Stack {
   constructor(maxSize) { // Set default max size if not provided
      if (isNaN(maxSize)) {
         maxSize = 10;
      }
      this.maxSize = maxSize; // Init an array that'll contain the stack values.
      this.container = [];
   }
   display() {
      console.log(this.container);
   }
   isEmpty() {
      return this.container.length === 0;
   }
   isFull() {
      return this.container.length >= this.maxSize;
   }
   push(element) { // Check if stack is full
      if (this.isFull()) {
         console.log("Stack Overflow!") return;
      }
      this.container.push(element)
   }
   pop() { // Check if empty
      if (this.isEmpty()) {
         console.log("Stack Underflow!") return;
      }
      this.container.pop()
   }
   peek() {
      if (isEmpty()) {
         console.log("Stack Underflow!");
         return;
      }
      return this.container[this.container.length - 1];
   }
   clear() {
      this.container = [];
   }
}
Conversion of whole String to uppercase or lowercase using STL in C++ - GeeksforGeeks

06 Jul, 2017
Given a string, convert the whole string to uppercase or lowercase using STL in C++.
Examples:
For uppercase conversion
Input : s = "String"
Output : s = "STRING"

For lowercase conversion
Input : s = "String"
Output : s = "string"

Functions used :transform : Performs a transformation on given array/string.toupper(int c) : Returns upper case version of character c. If c is already in uppercase, return c itself.tolower(int c) : Returns lower case version of character c. If c is already in lowercase, return c itself.
// C++ program to convert whole string to// uppercase or lowercase using STL.#include<bits/stdc++.h>using namespace std;  int main(){    // su is the string which is converted to uppercase    string su = "Jatin Goyal";      // using transform() function and ::toupper in STL    transform(su.begin(), su.end(), su.begin(), ::toupper);    cout << su << endl;      // sl is the string which is converted to lowercase    string sl = "Jatin Goyal";      // using transform() function and ::tolower in STL    transform(sl.begin(), sl.end(), sl.begin(), ::tolower);    cout << sl << endl;      return 0;}
Output:
JATIN GOYAL
jatin goyal

This article is contributed by Jatin Goyal. 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-strings-library
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Inheritance in C++
Map in C++ Standard Template Library (STL)
C++ Classes and Objects
Bitwise Operators in C/C++
Operator Overloading in C++
Constructors in C++
Socket Programming in C/C++
Virtual Function in C++
Templates in C++ with Examples
Copy Constructor in C++
How to redirect if JavaScript is not enabled in a browser?

To redirect if JavaScript is not enabled in the web browser, add a script to the <noscript> tag. Let us say you need to redirect to index.php if JavaScript is not enabled. 
Here’s how you can do this:
<!DOCTYPE html>
<html>
   <head>
      <title>HTML noscript Tag</title>
   </head>
   
   <body>
      <script>
         <!--
            document.write("Hello JavaScript!")
         -->
      </script>
     
      <noscript>
         <style>html{display:none;}</style>
         <meta http-equiv="refresh" content="0.0;url=nojs/index.php”>
   </body>
</html>
Above, we first use CSS style, since we do not want the actual page to be visible if JavaScript is disabled in the web browser.
Flatten a list of DataFrames - GeeksforGeeks

02 Dec, 2020
In this article, we are going to see how to flatten a list of DataFrames. Flattening is defined as Converting or Changing data format to a narrow format. The advantage of the flattened list is Increases the computing speed and Good understanding of data.
Example:
Let consider, the data frame that contains values like payments in four months. Actually, the data is stored in a list format.
Note: 0,1,2 are the indices of the records   
Flattening means assigning lists separately for each author.
We are going to perform flatten operations on the list using data frames.
Method 1:
Step 1: Create a simple data frame.
Python3
#importing pandas moduleimport pandas as pd  #creating dataframe with 2 columnsdf = pd.DataFrame(data=[[[ 300, 400, 500, 600], 'sravan_payment'],                         [[ 300, 322, 333, 233], 'bobby_payment']],                   index=[ 0, 1], columns=[ 'A', 'B'])  display(df)
Output:
Step 2: iterate each row with a specific column.
Python3
flatdata = pd.DataFrame([( index, value) for ( index, values)                         in df[ 'A' ].iteritems() for value in values],                             columns = [ 'index', 'A']).set_index( 'index' )  df = df.drop( 'A', axis = 1 ).join( flatdata )display(df)
Output:
Methods 2: Using the flatten methods.
We are going to apply the flatten function for the above code.
Python3
#importing pandas module for dataframe.import pandas as pd  df = pd.DataFrame(data=[[[ 300, 400, 500, 600], 'sravan_payment'],                         [[ 300, 322, 333, 233], 'bobby_payment']],                   index = [ 0, 1], columns = [ 'A', 'B'])display(df)
Output:
Python3
df.values.flatten()
Output:
Python pandas-dataFrame
Python Pandas-exercise
Python-pandas
Technical Scripter 2020
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
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()
Program to find longest path between two nodes of a tree in Python

Suppose we have a binary tree; we have to find the longest path between any two nodes in the
tree.
So, if the input is like
 then the output will be 5 
To solve this, we will follow these steps:
ans := 0
ans := 0
Define a function getMaxPath() . This will take node
Define a function getMaxPath() . This will take node
if node is null, thenreturn 0
if node is null, then
return 0
return 0
leftCnt := getMaxPath(left of node)
leftCnt := getMaxPath(left of node)
rightCnt := getMaxPath(right of node)
rightCnt := getMaxPath(right of node)
temp := 1 + maximum of leftCnt and rightCnt
temp := 1 + maximum of leftCnt and rightCnt
ans := maximum of ans and l+r+1
ans := maximum of ans and l+r+1
From the main method do the following −
From the main method do the following −
getMaxPath(root)
getMaxPath(root)
return ans
return ans
Let us see the following implementation to get better understanding −
 Live Demo
class TreeNode:
   def __init__(self, val, left=None, right=None):
      self.val = val
      self.left = left
      self.right = right

class Solution:
   def solve(self, root):
      self.ans = 0
      def getMaxPath(root):
         if root is None:
            return 0
         l = getMaxPath(root.left)
         r = getMaxPath(root.right)
         temp = max(l, r) + 1
         self.ans = max(self.ans, l + r + 1)
         return temp
      getMaxPath(root)
      return self.ans
ob = Solution()
root = TreeNode(2)
root.left = TreeNode(10)
root.right = TreeNode(4)
root.right.left = TreeNode(8)
root.right.right = TreeNode(2)
root.right.left.left = TreeNode(6)
print(ob.solve(root))
root = TreeNode(2)
root.left = TreeNode(10)
root.right = TreeNode(4)
root.right.left = TreeNode(8)
root.right.right = TreeNode(2)
root.right.left.left = TreeNode(6)
5
How to write a MySQL stored function that updates the values in a table?

As we know that function is best used when we want to return a result. Hence, when we will create stored functions for manipulating tables like to Insert or Update values then it would be more or less like stored procedures. In the following example, we are creating a stored function named ‘tbl_update’ which will update the values in a table named ‘student_marks’.
mysql> Select * from student_marks//
+---------+------+---------+---------+---------+
| Name    | Math | English | Science | History |
+---------+------+---------+---------+---------+
| Raman   |   95 |      89 |      85 |      81 |
| Rahul   |   90 |      87 |      86 |      81 |
| Mohit   |   90 |      85 |      86 |      81 |
| Saurabh | NULL |    NULL |    NULL |    NULL |
+---------+------+---------+---------+---------+
4 rows in set (0.00 sec)

mysql> Create Function tbl_Update(S_name Varchar(50),M1 INT,M2 INT,M3 INT,M4 INT)
    -> RETURNS INT
    -> DETERMINISTIC
    -> BEGIN
    -> UPDATE student_marks SET Math = M1,English = M2, Science = M3, History =M4 WHERE Name = S_name;
    -> RETURN 1;
    -> END //
Query OK, 0 rows affected (0.03 sec)

mysql> Select tbl_update('Saurabh',85,69,75,82);
+------------------------------------+
| tbl_update('Saurabh',85,69,75,82)  |
+------------------------------------+
|                                  1 |
+------------------------------------+
1 row in set (0.07 sec)

mysql> Select * from Student_marks;
+---------+------+---------+---------+---------+
| Name    | Math | English | Science | History |
+---------+------+---------+---------+---------+
| Raman   |   95 |      89 |      85 |      81 |
| Rahul   |   90 |      87 |      86 |      81 |
| Mohit   |   90 |      85 |      86 |      81 |
| Saurabh |   85 |      69 |      75 |      82 |
+---------+------+---------+---------+---------+
4 rows in set (0.00 sec)
Groovy - Dates & Times compareTo()

Compares two Dates for ordering.
public int compareTo(Date anotherDate)

anotherDate – the Date to be compared.
Return Value − The value 0 if the argument Date is equal to this Date; a value less than 0 if this Date is before the Date argument; and a value greater than 0 if this Date is after the Date argument.
Following is an example of the usage of this method −
class Example { 
   static void main(String[] args) { 
      Date olddate = new Date("05/11/2015"); 
      Date newdate = new Date("05/11/2015"); 
      Date latestdate = new Date(); 
		
      System.out.println(olddate.compareTo(newdate)); 
      System.out.println(latestdate.compareTo(newdate)); 
   } 
}
When we run the above program, we will get the following result −
0 
1 


    52 Lectures 
     8 hours 

 Krishna Sakinala

    49 Lectures 
     2.5 hours 

 Packt Publishing
 Print
 Add Notes
 Bookmark this page
File.Exists() Method in C# with Examples

11 Oct, 2021
File.Exists(String) is an inbuilt File class method that is used to determine whether the specified file exists or not. This method returns true if the caller has the required permissions and path contains the name of an existing file; otherwise, false. Also, if the path is null, then this method returns false. 
Syntax:  
public static bool Exists (string path);
Here, path is the specified path that is to be checked.  
Program 1: Before running the below code, a file file.txt is created with some contents shown below: 
 
CSharp
// C# program to illustrate the usage// of File.Exists(String) method // Using System and System.IO namespacesusing System;using System.IO; class GFG {    static void Main()    {        // Checking the existence of the specified        if (File.Exists("file.txt")) {            Console.WriteLine("Specified file exists.");        }        else {            Console.WriteLine("Specified file does not "+                      "exist in the current directory.");        }    }}
Output:  
Specified file exists.
Program 2: Before running the below code, no file is created. 
CSharp
// C# program to illustrate the usage// of File.Exists(String) method // Using System and System.IO namespacesusing System;using System.IO; class GFG {    static void Main()    {        // Checking the existence of the specified        if (File.Exists("file.txt")) {            Console.WriteLine("Specified file exists.");        }        else {            Console.WriteLine("Specified file does not"+                    " exist in the current directory.");        }    }}
Output:  
Specified file does not exist in the current directory.
 
khushboogoyal499
CSharp-File-Handling
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python MongoDB – find_one Query

04 Jul, 2022
This article focus on the find_one() method of the PyMongo library. find_one() is used to find the data from MongoDB. 
Prerequisites: MongoDB Python Basics 
Let’s begin with the find_one() method:
Importing PyMongo Module: Import the PyMongo module using the command:
from pymongo import MongoClient
If MongoDB is already not installed on your machine, one can refer to the guide og how to Install MongoDB with Python.Creating a Connection: Now we had already imported the module, it’s time to establish a connection to the MongoDB server, presumably which is running on localhost (host name) at port 27017 (port number).
If MongoDB is already not installed on your machine, one can refer to the guide og how to Install MongoDB with Python.
Creating a Connection: Now we had already imported the module, it’s time to establish a connection to the MongoDB server, presumably which is running on localhost (host name) at port 27017 (port number).
client = MongoClient(‘localhost’, 27017)
Accessing the Database: Since the connection to the MongoDB server is established. We can now create or use the existing database.
mydatabase = client.name_of_the_database
Accessing the Collection: We now select the collection from the database using the following syntax:
collection_name = mydatabase.name_of_collection
Finding in the collection: Now we will find in the collection using find_one() function. This function return only one document if the data is found in the collection else it returns None. It is ideal for those situations where we need to search for only one document. Syntax:
find_one(filter=None, *args, **kwargs)
Example 1: Sample Database:  
Python3
# Python program to demonstrate# find_one() method # Importing Libraryfrom pymongo import MongoClient  # Connecting to MongoDB server# client = MongoClient('host_name','port_number')client = MongoClient('localhost', 27017)  # Connecting to the database named# GFGmydatabase = client.GFG  # Accessing the collection named# gfg_collectionmycollection = mydatabase.Student  # Searching through the database# using find_one method.result = mycollection.find_one({'Branch': 'CSE'})print(result)
Output:
{'_id': 1, 'name': 'Vishwash', 'Roll No': '1001', 'Branch': 'CSE'}
Example 2: 
Python3
# Python program to demonstrate# find_one() method # Importing Libraryfrom pymongo import MongoClient  # Connecting to MongoDB server# client = MongoClient('host_name','port_number')client = MongoClient('localhost', 27017)  # Connecting to the database named# GFGmydatabase = client.GFG  # Accessing the collection named# gfg_collectionmycollection = mydatabase.Student  # Searching through the database# using find_one method.result = mycollection.find_one({'Branch': 'CSE'},                               {'_id': 0, 'name': 1, 'Roll No': 1})print(result)
Output:
{'name': 'Vishwash', 'Roll No': '1001'}
khushb99
Python-mongoDB
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.