code-rag-bench/online-tutorials huggingface dataset:
How to convert String to Long in Kotlin?

In this article, we will see how to convert a String to Long in Kotlin using a
library function. There are multiple ways to do it. Let's take a couple of
examples to demonstrate how it's done.
toLong() is a function that provides the most convenient way to convert a string to a long. In the following example, we will see how we can use toLong() to convert our String.
fun convertToLong(s: String) {

   try {
      val value = s.toLong()
      println("The Long value is: $value")
   }

   catch (ex: NumberFormatException) {
      println("Please enter a number: ")
   }
}
fun main() {
   val str = "1234567890"
   convertToLong(str)
}
Once the above piece of code is executed, it will convert our String
"1234567890" to a Long value.
The Long value is: 1234567890
Like toLong(), we can use another function called toLongOrNull() to convert a String value to Long. In the following example, we will see how to convert a String to Long using toLongOrNull().
fun convertToLong(s: String) {

   try {
      val value = s.toLongOrNull()
      println("The Long value is: $value")
   }
   catch (ex: NumberFormatException) {
      println("Please enter a number: ")
   }
}

fun main() {
   val str = "1234567890"
   convertToLong(str)
}
Once the above piece of code is executed, it will convert our String
"1234567890" to a Long value.
The Long value is: 1234567890
Kotlin is based on the JVM. Hence, we can use the Java Lang package to convert a String to a Long variable. In the following example, we have used the valueOf() function to convert a String to a Long variable.
fun main() {
   val str = "12345678"
   println("The given string is: " +str)
   val value = java.lang.Long.valueOf(str)
   println("After converting to Long: " +value)
}
One executed, the above piece of code will convert our String "1234567890"
to a Long value.
The given string is: 12345678
After converting to Long: 12345678
Excel Addition Operator

Addition uses the + symbol in Excel, and is also known as plus.
There are two ways to do addition in Excel. Either by using the + symbol in a formula or by using the SUM function.
How to add cells:

Select a cell and type (=)
Select a cell
Type (+)
Select another cell
Hit enter

Select a cell and type (=)
Select a cell
Type (+)
Select another cell
Hit enter
You can add more cells to the formula by typing (+) between the cells.
Let's have a look at some examples. 
Type A1(=)
Type 5+5
Hit enter
Congratulations! You have successfully added 5+5=10.
First let's add some numbers to work with. Type the following values:
How to do it, step by step:

Type B1(=)
Select A1
Type (+)
Select A2
Hit enter

Type B1(=)
Select A1
Type (+)
Select A2
Hit enter
Great! 30 is the result by adding A1 and A2.
First let's  add some numbers to work with. Type the following values:
Step by step to add several cells:

Type B1(=)
Select A1
Type (+)
Select A2
Type (+)
Select A3
Type (+)
Select A4
Type (+)
Select A5
Hit enter

Type B1(=)
Select A1
Type (+)
Select A2
Type (+)
Select A3
Type (+)
Select A4
Type (+)
Select A5
Hit enter
Good job! You have successfully added five cells!
Let's keep the numbers from the last exercise. If you did last exercise, remove the value in B1. 
Step by step to add with SUM:

Type B1(=SUM)
Double click the SUM command
Mark the range A1:A5
Hit enter

Type B1(=SUM)
Double click the SUM command
Mark the range A1:A5
Hit enter
Note: SUM saves you time! Keep practicing this function.
You can also lock a cell and add it to other cells.
How to do it, step by step:

Select a cell and type (=)
Select the cell you want to lock, add two dollar signs ($) before the column and row
Type (+)
Fill a range

Select a cell and type (=)
Select the cell you want to lock, add two dollar signs ($) before the column and row
Type (+)
Fill a range
Let's have a look at an example where we add B(5) to the range A1:A10 using absolute reference and the fill function.
Type the values:
Step by step:

Type C1(=)
Select B1
Type dollar sign before column and row $B$1
Type (+)
Select A1
Hit enter
Fill the range C1:C10

Type C1(=)
Select B1
Type dollar sign before column and row $B$1
Type (+)
Select A1
Hit enter
Fill the range C1:C10
Great! You have successfully used absolute reference to add B1(5) with the range A1:A10.
Type the symbol that Excel uses for addition:


Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
How to remove a class name from an element with JavaScript?

To remove a class name from an element with JavaScript, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
   .newStyle {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
      width: 100%;
      padding: 25px;
      background-color: rgb(147, 80, 255);
      color: white;
      font-size: 25px;
      box-sizing: border-box;
      text-align: center;
   }
</style>
</head>
<body>
<h1>Remove className with JavaScript Example</h1>
<button class="btn">Remove Class</button>
<h2>Click the above button to remove className from below div</h2>
<div class="newStyle" id="sampleDiv">
This is a DIV element.
</div>
<script>
   document.querySelector(".btn").addEventListener("click", addClassName);
   function addClassName() {
      var element = document.getElementById("sampleDiv");
      element.classList.remove("newStyle");
   }
</script>
</body>
</html>
The above code will produce the following output −
On clicking the the “Remove Class” button −
Find the compatibility difference between two arrays in C++

Consider there are two friends and now they want to test their bonding. So they will check, how much compatible they are. Given the numbers n, numbered from 1..n. And they are asked to rank the numbers. They have to find the compatibility difference between them. The compatibility difference is basically the number of mismatches in the relative ranking of the same movie given by them. So if A = [3, 1, 2, 4, 5], and B = [3, 2, 4, 1, 5], then the output will be 2. The compatibility difference is 2, as first ranks movie 1 before 2 and 4, but other ranks it after.
To solve this, we will traverse both arrays, when the current elements are same, then do nothing. Then find the next position of A and B, let the position be j, one by one move B[j] to B[i]
 Live Demo
#include<iostream>
using namespace std;

int getArrayDiff(int A[], int B[], int n) {
   int result = 0;

   for (int i = 0; i < n; i++) {
      if (A[i] != B[i]) {

         int j = i + 1;
         while (A[i] != B[j])      
         j++;

         while (j != i) {
            swap(B[j], B[j - 1]);
            j--;
            result++;
         }
      }
   }
   return result;
}

int main() {
   int A[] = { 3, 1, 2, 4, 5 };
   int B[] = { 3, 2, 4, 1, 5 };
   int n = sizeof(A)/sizeof(A[0]);

   cout << "Compatibility difference: " << getArrayDiff(A, B, n);
}

Compatibility difference: 2
GATE | GATE-CS-2016 (Set 1) | Question 43 - GeeksforGeeks

19 Nov, 2018
Consider a carry lookahead adder for adding two n-bit integers, built using gates of fan-in at most two. The time to perform addition using this adder is(A) Θ(1)(B) Θ(Log (n))(C) Θ(√ n)(D) Θ(n)Answer: (B)Explanation: Look ahead carry generator gives output in constant time if fan-in = number of inputs.
For Example:
It will take O(1) to calculate 
c4 = g3 + p3g2 + p3p2g1 + p3p2p1g0 + p3p2p1p0c0c4 
   = g3 + p3g2 + p3p2g1 + p3p2p1g0 + p3p2p1p0c0, 
              if OR gate with 5 inputs is present.

And, if fan-in != number of inputs then we will have delay in each level, as given below.
If we have 8 inputs, and OR gate with 2 inputs, to build an OR gate with 8 inputs, we will need 4 gates in level-1, 2 in level-2 and 1 in level-3. Hence 3 gate delays, for each level.
Similarly an n-input gate constructed with 2-input gates, total delay will be O(log n).
// This Explanation has been provided by Saksham Raj Seth.Quiz of this Question
GATE-CS-2016 (Set 1)
GATE-GATE-CS-2016 (Set 1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-IT-2004 | Question 71
GATE | GATE CS 2011 | Question 7
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2016 (Set 2) | Question 61
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE CS 2010 | Question 24
GATE | GATE-CS-2016 (Set 1) | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 38
GATE | GATE CS 2018 | Question 37
GATE | GATE-IT-2004 | Question 83
TestNG - Asserts

In the previous chapters we executed some tests using TestNG. We didn't declare a test success or fail. A test is considered successful if it completed without throwing any exception or if it threw an exception that was expected.
A test method will typically be made of calls that can throw an exception, or of various assertions (using the Java "assert" keyword). TestNG asserts the tester decides whether the test was successful or not, along with the exceptions. Assertions in TestNG are a way to verify that the expected result and the actual result matched or not.
Following is the generic syntax of TestNG Assertions:
  Assert.Method( actual, expected)
actual:  The actual value that the tester gets.
actual:  The actual value that the tester gets.
expected:  The value that you expect.
expected:  The value that you expect.
Let us see an example of assertion here. Create a java class to be tested, say, MessageUtil.java in /work/testng/src.
/*
* This class prints the given message on console.
*/

public class MessageUtil {

   private String message;

   //Constructor
   //@param message to be printed
   public MessageUtil(String message) {
      this.message = message;
   }

   // prints the message
   public String printMessage() {
      System.out.println(message);
      return message;
   }
}
Create a java class, say, TestAssertion.java in /work/testng/src. Here we assert the actual and expected result.
  import org.testng.Assert;
  import org.testng.annotations.Test;

  public class TestAssertion {
     String message = "Manisha";
     MessageUtil messageUtil = new MessageUtil(message);

     @Test
     public void testPrintMessage() {
        Assert.assertEquals("Tutorialspoint", messageUtil.printMessage());
     }
  }
The preceding test class contains two test methods which will run in separate threads.
Create testng.xml in /work/testng/src to execute test case(s).
  <?xml version = "1.0" encoding = "UTF-8"?>
  <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
  <suite name = "Suite1">
     <test name = "test1">
        <classes>
           <class name = "TestAssertion"/>
        </classes>
     </test>
  </suite>
Compile the java files using javac.
/work/testng/src$ javac TestAssertion.java MessageUtil.java
Now, run testng.xml.
/work/testng/src$ java org.testng.TestNG testng.xml
Verify the output.
  Manisha

  ===============================================
  Suite1
  Total tests run: 1, Passes: 0, Failures: 1, Skips: 0
  ===============================================
You can check the /work/testng/src/test-output/index.html for detailed report. You will see a report as below:

    38 Lectures 
     4.5 hours 

 Lets Kode It

    15 Lectures 
     1.5 hours 

 Quaatso Learning

    28 Lectures 
     3 hours 

 Dezlearn Education
 Print
 Add Notes
 Bookmark this page
DAX Aggregation - COUNTX function

Counts the number of rows that contain a number or an expression that evaluates to a number, when evaluating an expression over a table.
COUNTX (<table>, <expression>)

table
The table containing the rows to be counted.
expression
An expression that returns the numbers you want to count.
Returns a whole number.
The COUNTX function counts only numeric values or dates. Parameters that are logical values or text that cannot be translated into numbers are not counted.
If the function finds no rows to count, it returns a blank. When there are rows, but none meets the specified criteria, then the function returns 0.
= COUNTX (RELATEDTABLE (East_Sales), IF ([Product] = East_Sales[Product],1,0)) 

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
SAP HANA Admin - Solman Integration

You can also support your SAP HANA system by using SAP Solution Manager. To make two systems communicate with each other, you need to register your SAP HANA system to SAP solution manager’s System Landscape Directory (SLD). This directory contains the information about the landscape and software component versions. A SAP system can be configured to register under SLD. SLD manages the information about all installable and installed elements of your system landscape.
To register your SAP HANA system under SLD, you should meet the following prerequisites −
Your SAP HANA system should be installed with SAP HANA Database Lifecycle Manager (HDBLCM).
Your SAP HANA system should be installed with SAP HANA Database Lifecycle Manager (HDBLCM).
You should be logged in with Administrator account of SID credentials.
You should be logged in with Administrator account of SID credentials.
SAP HANA system is running.
SAP HANA system is running.
To perform the integration of SAP HANA system under SLD, open SAP HANA Database Lifecycle Manager GUI. You can open SAP HANA Database Lifecycle Manager via HANA cockpit or via HANA Studio → Platform Lifecycle Manager.
Navigate to Configure System Landscape Registry Configuration under SAP HANA Platform Lifecycle Management.
Enter the following information under System Landscape Directory −
SLD Host Name − Name of the host where the SLD system is installed.
SLD Host Name − Name of the host where the SLD system is installed.
SLD Port − Enter the standard HTTP access port of the SLD.
SLD Port − Enter the standard HTTP access port of the SLD.
SLD User Name − Enter the user of the SLD system. It must be a user that already exists on the host where the SLD system is running.
SLD User Name − Enter the user of the SLD system. It must be a user that already exists on the host where the SLD system is running.
SLD Password − Enter the password for the SLD system.
SLD Password − Enter the password for the SLD system.
Use HTTPS − Here you can mention whether to use HTTPS or not.
Use HTTPS − Here you can mention whether to use HTTPS or not.
Click the Run button to finish the configuration under System Landscape Directory.
You can also perform the above steps from the command line, by executing the following command −
./hdblcm --action=configure_sld 

Enter the above specified parameters using command line. Select ’y’ to finalize the configuration under SLD.

    25 Lectures 
     6 hours 

 Sanjo Thomas

    26 Lectures 
     2 hours 

 Neha Gupta

    30 Lectures 
     2.5 hours 

 Sumit Agarwal

    30 Lectures 
     4 hours 

 Sumit Agarwal

    14 Lectures 
     1.5 hours 

 Neha Malik

    13 Lectures 
     1.5 hours 

 Neha Malik
 Print
 Add Notes
 Bookmark this page
Java Math getExponent() method with Example - GeeksforGeeks

09 Apr, 2018
The java.lang.Math.getExponent() returns the unbiased exponent used in the representation of a double or float.Note:
If the argument is NaN or infinite of double or float type, then the result is (Double.MAX_EXPONENT + 1) or (Float.MAX_EXPONENT + 1).
If the argument is zero or subnormal of double or float type, then the result is (Double.MIN_EXPONENT -1) or (Float.MIN_EXPONENT -1).
Syntax :
public static int getExponent(DataType a)
Parameter :
a : an argument of double or float type
Return :
This method returns the unbiased exponent of the argument.
// Java program to demonstrate working// of java.lang.Math.getExponent() methodimport java.lang.Math;  class Gfg {      // driver code    public static void main(String args[])    {        double a = 345.65;        double b = 1.0 / 0;        double c = 0;          // Input double value        // Output unbiased exponent of it        System.out.println(Math.getExponent(a));          // Input Infinity        // Output (Double.MAX_EXPONENT + 1)        System.out.println(Math.getExponent(b));          // Input Zero        // Output (Double.MIN_EXPONENT - 1)        System.out.println(Math.getExponent(c));          float d = 237.2f;        float e = 1.0f / 0;        float f = 0f;          // Input float value        // Output unbiased exponent of it        System.out.println(Math.getExponent(d));          // Input Infinity        // Output (Float.MAX_EXPONENT + 1)        System.out.println(Math.getExponent(e));          // Input Zero        // Output (Float.MIN_EXPONENT - 1)        System.out.println(Math.getExponent(f));    }}
Output:
8
1024
-1023
7
128
-127

Java-lang package
java-math
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Different ways of Reading a text file in Java
Exceptions in Java
Functional Interfaces in Java
Generics in Java
Comparator Interface in Java with Examples
Introduction to Java
HashMap get() Method in Java
Strings in Java
ContainsKey in C#

ContainsKey is a Dictionary method in C# and check whether a key exists in the Dictionary or not.
Declare a Dictionary and add elements −
var dict = new Dictionary<string, int>() {
   {"TV", 1},
   {"Home Theatre", 2},
   {"Amazon Alexa", 3},
   {"Google Home", 5},
   {"Laptop", 5},
   {"Bluetooth Speaker", 6}
};
Now, let’s say you need to check for the existence of a particular element in the Dictionary. For that, use the ContainsKey() method −
if (dict.ContainsKey("Laptop") == true) {
   Console.WriteLine(dict["Laptop"]);
}
The following is the code −
 Live Demo
using System;
using System.Collections.Generic;
public class Demo {
   public static void Main() {
      var dict = new Dictionary<string, int>() {
         {"TV", 1},
         {"Home Theatre", 2},
         {"Amazon Alexa", 3},
         {"Google Home", 5},
         {"Laptop", 5},
         {"Bluetooth Speaker", 6}
      };
      if (dict.ContainsKey("Laptop") == true) {
         Console.WriteLine(dict["Laptop"]);
      }
      if (dict.ContainsKey("Amazon Alexa") == true) {
         Console.WriteLine(dict["Amazon Alexa"]);
      }
   }
}
5
3
PHP | call_user_func() Function

25 Jun, 2018
The call_user_func() is an inbuilt function in PHP which is used to call the callback given by the first parameter and passes the remaining parameters as argument. It is used to call the user-defined functions.
Syntax:
mixed call_user_func ( $function_name[, mixed $value1[, mixed $... ]])
Here, mixed indicates that a parameter may accept multiple types.Parameter: The call_user_func() function accepts two types of parameters as mentioned above and described below:
$function_name: It is the name of function call in the list of defined function. It is a string type parameter.
$value: It is mixed value. One or more parameters to be passed to the function.
Return Value: This function returns the value returned by the callback function.
Below programs illustrate the call_user_func() function in PHP:
Program 1: Call the function
<?phpfunction GFG($value){    echo "This is $value site.\n";}  call_user_func('GFG', "GeeksforGeeks");call_user_func('GFG', "Content");  ?>
This is GeeksforGeeks site.
This is Content site.

Program 2: call_user_func() using namespace name
<?php  namespace Geeks;  class GFG {    static public function demo() {        print "GeeksForGeeks\n";    }}  call_user_func(__NAMESPACE__ .'\GFG::demo');   // Another way of declarationcall_user_func(array(__NAMESPACE__ .'\GFG', 'demo'));   ?>
GeeksForGeeks
GeeksForGeeks

Program 3: Using a class method with call_user_func()
<?php  class GFG {    static function show()    {        echo "Geeks\n";    }}  $classname = "GFG";call_user_func($classname .'::show');  // Another way to use object$obj = new GFG();call_user_func(array($obj, 'show'));  ?>
Geeks
Geeks

Program 4: Using lambda function with call_user_func()
<?phpcall_user_func(function($arg) { print "$arg\n"; }, 'GeeksforGeeks');?>
GeeksforGeeks

References: http://php.net/manual/en/function.call-user-func.php
PHP-function
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Set title of window in PyQt5 – setWindowTitle

24 Nov, 2021
PyQt5 is a comprehensive set of Python bindings for Qt v5. It is implemented as more than 35 extension modules and enables Python to be used as an alternative application development language to C++ on all supported platforms including iOS and Android.In this article, we will see how to set title of the window in PyQt5. In order to do so setWindowTitle() method is used, this method belongs to the QWidget class. 
Syntax : self.setWindowTitle(title)Argument : It takes title i.e string as argument.
Below is the Python implementation –  
Python3
# importing the required librariesfrom PyQt5.QtGui import *from PyQt5.QtWidgets import *import sys class Window(QMainWindow):    def __init__(self):        super().__init__()                 # string value        title = "Title of window"         # set the title        self.setWindowTitle(title)         # setting  the geometry of window        self.setGeometry(0, 0, 500, 300)         # show all the widgets        self.show() # create pyqt5 appApp = QApplication(sys.argv) # create the instance of our Windowwindow = Window() # start the appsys.exit(App.exec())
Output :  
 
gabaa406
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C program to check whether a given number is even or odd

10 Jun, 2022
Given an integer N, the task is to check if the given number N is even or odd. If it is found to be even, then print “Even”. Otherwise, print “Odd”.
Examples:
Input: N = 2Output: Even
Input: N = 5Output: Odd
Method 1: The simplest approach is to check if the remainder obtained after dividing the given number N by 2 is 0 or 1. If the remainder is 0, then print “Even”. Otherwise, print “Odd”.
Below is the implementation of the above approach:
C
// C program for the above approach#include <stdio.h>  // Function to check if a// number is even or oddvoid checkEvenOdd(int N){    // Find remainder    int r = N % 2;      // Condition for even    if (r == 0) {        printf("Even");    }      // Otherwise    else {        printf("Odd");    }}  // Driver Codeint main(){    // Given number N    int N = 101;      // Function Call    checkEvenOdd(N);      return 0;}
Odd

Time Complexity: O(1)Auxiliary Space: O(1)
Method 2: Another approach is to use Bitwise Operators. The idea is to check whether the last bit of the given number N is 1 or not. To check whether the last bit is 1 find the value of (N & 1). If the result is 1, then print “Odd”. Otherwise, print “Even”.
Below is the illustration for N = 5:
N = 5.Binary representation of 5 is 00000101Binary representation of 1 is 00000001——————————————————————-The value of Bitwise AND is 00000001
Since the result is 1. Therefore, the number N = 5 is odd.
Below is the implementation of the above approach:
C
// C program for the above approach  #include <stdio.h>  // Function to check if a// number is even or oddvoid checkEvenOdd(int N){    // If N & 1 is true    if (N & 1) {        printf("Odd");    }      // Otherwise    else {        printf("Even");    }}  // Driver Codeint main(){    // Given number N    int N = 101;      // Function Call    checkEvenOdd(N);      return 0;}
Odd

Time Complexity: O(1)Auxiliary Space: O(1)
Method 3: The idea is to initialize an integer variable var as 1 and change it from 1 to 0 and vice-versa alternately, N times. If var is equal to 1 after N operations, print “Even”. Otherwise, print “Odd”.
Below is the implementation of the above approach:
C
// C program for the above approach#include <stdio.h>  // Function to check a number is// even or oddvoid checkEvenOdd(int N){    // Initialise a variable var    int var = 1;      // Iterate till N    for (int i = 1; i <= N; i++) {          // Subtract var from 1        var = 1 - var;    }      // Condition for even    if (var == 1) {        printf("Even");    }      // Otherwise    else {        printf("Odd");    }}  // Driver Codeint main(){    // Given number N    int N = 101;      // Function Call    checkEvenOdd(N);      return 0;}
Odd

Time Complexity: O(1)Auxiliary Space: O(1)
C Basic Programs
Natural Numbers
Number Divisibility
Bit Magic
C Programs
Mathematical
Mathematical
Bit Magic
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Tweepy – Getting the number of followers of a user

18 Jun, 2020
In this article we will see how we can get the number of followers of a user. The followers_count attribute provides us with an integer donating the number of followers the user account has.
Identifying the number of followers in the GUI :
In the above mentioned profile the number of followers are : 17.8K (17, 800+)
In order to get the number of followers we have to do the following :
Identify the user ID or the screen name of the profile.Get the User object of the profile using the get_user() method with the user ID or the screen name.From this object, fetch the followers_count attribute present in it.
Identify the user ID or the screen name of the profile.
Get the User object of the profile using the get_user() method with the user ID or the screen name.
From this object, fetch the followers_count attribute present in it.
Example 1: Consider the following profile :We will use the user ID to fetch the user. The user ID of the above mentioned profile is 57741058.
# import the moduleimport tweepy  # assign the values accordinglyconsumer_key = ""consumer_secret = ""access_token = ""access_token_secret = ""  # authorization of consumer key and consumer secretauth = tweepy.OAuthHandler(consumer_key, consumer_secret)  # set access to user's access key and access secret auth.set_access_token(access_token, access_token_secret)  # calling the api api = tweepy.API(auth)  # the ID of the userid = 57741058  # fetching the useruser = api.get_user(id)  # fetching the followers_countfollowers_count = user.followers_count  print("The number of followers of the user are : " + str(followers_count))
Output :
The number of followers of the user are : 17814

Example 2: Consider the following profile :We will use the screen name to fetch the user. The screen name of the above mentioned profile is PracticeGfG.
# the screen name of the userscreen_name = "PracticeGfG"  # fetching the useruser = api.get_user(screen_name)  # fetching the followers_countfollowers_count = user.followers_count  print("The number of followers of the user are : " + str(followers_count))
Output :
The number of followers of the user are : 2204

Python-Tweepy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JSON Schema

22 Jun, 2020
JSON Schema is a content specification language used for validating the structure of a JSON data.It helps you specify the objects and what values are valid inside the object’s properties. JSON schema is useful in offering clear, human-readable, and machine-readable documentation.
Structure of a JSON Schema: Since JSON format contains an object, array, and name-value pair elements. Name-value pairs are used for providing schema processing elements as well as validating the JSON content. Schema processing elements include(not limited to).
$schema” To specify the version of JSON schema.
title and description: To provide information about the schema.
required: It’s an array of elements that indicates which elements should be present.
additionalProperties: To indicate whether existence of specified elements are allowed or not.
JSON content definition:
When a JSON object is defined, JSON schema uses name-value pair “type”:”object”
When arrays are defined, JSON schema uses the name-value pair “type”:”array”
Example:
{
  "$id": "https://example.com/person.schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Voters information",
  "type": "object",
  "properties": {
    "firstName": {
      "type": "string",
      "description": "The person's first name."
    },
    "lastName": {
      "type": "string",
      "description": "The person's last name."
    },
    "age": {
      "description": "Age in years which must be equal to or 
                      greater than eighteen in order to vote.",
      "type": "integer",
      "minimum": 18
    }
  }
}


Output:
{
  "firstName": "Indra",
  "lastName": "Sen",
  "age": 20
}

The above JSON schema contains the following:
$id keyword
$schema keyword
title annotation keyword
properties validation keyword
Three keys: firstName, lastName and age each with their own description keyword.
type instance data model (see above)
minimum validation keyword on the age key.
JSON
Picked
JavaScript
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python – Cross Pairing in Tuple List

02 Sep, 2020
Given 2 tuples, perform cross pairing of corresponding tuples, convert to single tuple if 1st element of both tuple matches.
Input : test_list1 = [(1, 7), (6, 7), (8, 100), (4, 21)], test_list2 = [(1, 3), (2, 1), (9, 7), (2, 17)]Output : [(7, 3)]Explanation : 1 occurs as tuple element at pos. 1 in both tuple, its 2nd elements are paired and returned.
Input : test_list1 = [(10, 7), (6, 7), (8, 100), (4, 21)], test_list2 = [(1, 3), (2, 1), (9, 7), (2, 17)]Output : []Explanation : NO pairing possible.
Method #1 : Using list comprehension
In this, we check for 1st element using conditional statements and, and construct new tuple in list comprehension.
Python3
# Python3 code to demonstrate working of # Cross Pairing in Tuple List# Using list comprehension  # initializing liststest_list1 = [(1, 7), (6, 7), (9, 100), (4, 21)]test_list2 = [(1, 3), (2, 1), (9, 7), (2, 17)]  # printing original listsprint("The original list 1 : " + str(test_list1))print("The original list 2 : " + str(test_list2))  # corresponding loop in list comprehensionres = [(sub1[1], sub2[1]) for sub2 in test_list2 for sub1 in test_list1 if sub1[0] == sub2[0]]  # printing result print("The mapped tuples : " + str(res))
The original list 1 : [(1, 7), (6, 7), (9, 100), (4, 21)]
The original list 2 : [(1, 3), (2, 1), (9, 7), (2, 17)]
The mapped tuples : [(7, 3), (100, 7)]

Method #2 : Using zip() + list comprehension
In this, the task of pairing is done using zip() and conditional check is done inside list comprehension.
Python3
# Python3 code to demonstrate working of # Cross Pairing in Tuple List# Using zip() + list comprehension  # initializing liststest_list1 = [(1, 7), (6, 7), (9, 100), (4, 21)]test_list2 = [(1, 3), (2, 1), (9, 7), (2, 17)]  # printing original listsprint("The original list 1 : " + str(test_list1))print("The original list 2 : " + str(test_list2))  # zip() is used for pairing res = [(a[1], b[1]) for a, b in zip(test_list1, test_list2) if a[0] == b[0]]  # printing result print("The mapped tuples : " + str(res))
The original list 1 : [(1, 7), (6, 7), (9, 100), (4, 21)]
The original list 2 : [(1, 3), (2, 1), (9, 7), (2, 17)]
The mapped tuples : [(7, 3), (100, 7)]

Python list-programs
Python tuple-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Lodash _.includes() Method

09 Sep, 2020
The _.includes() method is used to find the value is in the collection or not. If the collection is a string, it will be tested for a value sub-string, otherwise SameValueZero() method is used for equality comparisons. If the index is given and is negative, the value is tested from the end indexes of the collection as the offset.
Syntax:
_.includes( collection, value, index )

Parameters: This method accepts three parameters as mentioned above and described below:
collection: This parameter holds the collection to inspect. Collection can be an array or object or string.
value: This parameter holds the value to search for.
index: This parameter holds the index to search from.
Return Value: This method returns true if the value is found in the collection, else false.
Example 1:
Javascript
// Requiring the lodash library  const _ = require("lodash");    // Collection of stringvar name = [ 'gfg', 'geeks', 'computer', 'science', 'portal' ];  // Check value is found or not by _.includes() methodconsole.log(_.includes(name, 'computer'));  // Check value is found or not by _.includes() methodconsole.log(_.includes(name, 'geeeks'));   // Check value is found or not by _.includes() methodconsole.log(_.includes(name, 'gfg', 2));
Output:
true
false
false

Example 2:  
Javascript
// Requiring the lodash library  const _ = require("lodash");    // Collection of integer valuevar name = [ 10, 15, 20, 25, 30 ];   // Check value is found or not by _.includes() methodconsole.log(_.includes(name, 25));  // Check value is found or not by _.includes() methodconsole.log(_.includes(name, 35));  // Check value is found or not by _.includes() methodconsole.log(_.includes(name, 25, 3));
Output:
true
false
true

JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Lodash _.exists() Method

30 Sep, 2020
The Lodash _.exists() method checks whether the given value is Exist or not and returns the corresponding boolean value. Both null and undefined are considered non-existy values. All other values are “Existy”.
Syntax:
_.exists( value );

Parameters: This method accepts single parameter as mentioned above and described below:
value: Given value to be checked for Existy value.
Return Value: This method returns a Boolean value true if the given value is Existy, else false.
Note: This will not work in normal JavaScript because it requires the lidash.js contrib library to be installed. Lodash.js contrib library can be installed using npm install lodash-contrib.
Example 1:
Javascript
// Defining underscore lodash variable var _ = require('lodash-contrib');   var bool = _.exists("Geeks");    console.log("Check the Existenc of Given Value : ", bool);
Output:
Check the Existenc of Given Value : true

Example 2:
Javascript
// Defining underscore lodash variable var _ = require('lodash-contrib');   var bool = _.exists(undefined);     console.log("Check the Existenc of Given Value : ", bool);
Output:
Check the Existenc of Given Value : false

Example 3:
Javascript
// Defining underscore lodash variable var _ = require('lodash-contrib');   var bool = _.exists(null);    console.log("Check the Existenc of Given Value : ", bool);
Output:
Check the Existenc of Given Value : false

Example 4:
Javascript
// Defining underscore lodash variable var _ = require('lodash-contrib');   var bool = _.exists([1, 12, 2, 3]);    console.log("Check the Existenc of Given Value : ", bool);
Output:
Check the Existenc of Given Value : true

JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Explain about add and assignment(+=) operator in detail in javascript?

The add and assignment(+=) operator reduces the code little bit.It may not much influential  in small codes whereas coming to long codes it's use can't be ignored.
 Live Demo
<html>
<body>
<script>
   var tot = 0;
   var a = [1,45,78,9,78,40];
   for(var i = 0; i<a.length;i++){
      tot += a[i]
   }
   document.write(tot);
</script>
</body>
</html>
251
Upload file with php to another php server

The fopen, fread and fwrite functions can be used to open a file stream, read a data stream and write that data to a file respectively.
The file resource doesn't necessarily need to point to a location on the local machine itself.
Below is an example that transfers a file from the local server to ftp server −
$file = "file_name.jpg";
$destination = fopen("ftp://username:password@example.com/" . $file, "wb");
$source = file_get_contents($file);
fwrite($destination, $source, strlen($source));
fclose($destination);
The image needs to be transferred to an FTP server. Hence the server is opened in write mode, and the image is written to that location and the stream is closed.
The curl extension uses Client URL Library (libcurl) to transfer files from one location to the other. The logic of implementing a curl solution follows the below logic −
Initialize a session first.
The desired transfer options can be set.
The transfer can be performed.
The session can be closed.
The curl session can be initialized using the 'curl_init' function. It returns a resource that could be used with other curl functions.
The destination to upload the file and other factors associated with the transfer session can be set using the 'curl_setopt'.
This takes the curl resource, that is a predefined constant which represents the setting and the optional value.
Below is an example demonstrating the same −
$session_begin = curl_init();
curl_setopt($session_begin, CURLOPT_POST, true);
curl_setopt($session_begin, CURLOPT_POSTFIELDS, array('file' => 'path/to/file.txt'));
curl_setopt($session_begin, CURLOPT_URL, 'http://server2/upload.php');
curl_exec($session_begin);
curl_close($session_begin);
The second server can be handled as a regular file upload.
Interface 8255 with 8085 microprocessor for addition - GeeksforGeeks

07 Apr, 2022
Problem – Interface 8255 with 8085 microprocessor and write an assembly program that determines the addition of contents of port A and port B and stores the result in port C. 
Example –  
Algorithm – 
Construct the control word registerInput the data from port A and port BAdd the contents of port A and port BDisplay the result in port C
Construct the control word register
Input the data from port A and port B
Add the contents of port A and port B
Display the result in port C
Program –  
Explanation –  
MVI A, 92H means that the value of the control register is 92. 
D7=1 as it is in I/O mode.
D6=0 & D5=0 as Poet A is in m0 mode.
D4=1 as Port A is taking input.
D3=0 & D0=0 as Port C is not taking part.
D2=0 as mode of Port B is m0.
D1=1as Port B is taking the input.
OUT 83H putting the value of A in 83H which is the port number of the port control register.
IN 80H taking input from 80H which is the port number of port A.
MOV B, A copies the content of A register to B register.
IN 81H takes input from 81H which is the port number of port B.
ADD B add the contents of A register and B register.
OUT 82H displays the result in 81H which is the port number of port C.
RET return
 
nidhi_biet
roozbehsayadi
avtarkumar719
xineyir106
microprocessor
system-programming
Computer Organization & Architecture
microprocessor
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Logical and Physical Address in Operating System
Computer Organization and Architecture | Pipelining | Set 1 (Execution, Stages and Throughput)
Memory Hierarchy Design and its Characteristics
Computer Organization | RISC and CISC
Direct Access Media (DMA) Controller in Computer Architecture
Computer Organization | Instruction Formats (Zero, One, Two and Three Address Instruction)
Interrupts
I/O Interface (Interrupt and DMA Mode)
Computer Organization and Architecture | Pipelining | Set 2 (Dependencies and Data Hazard)
Addressing modes in 8085 microprocessor
Kali Linux - Aircrack-ng - GeeksforGeeks

28 Jul, 2020
Aircrack-ng is a tool that comes pre-installed in Kali Linux and is used for wifi network security and hacking. Aircrack is an all in one packet sniffer, WEP and WPA/WPA2 cracker, analyzing tool and a hash capturing tool. It is a tool used for wifi hacking. It helps in capturing the package and reading the hashes out of them and even cracking those hashes by various attacks like dictionary attacks. It supports almost all the latest wireless interfaces. It mainly focuses on 4 areas:
Monitoring: Captures cap, packet, or hash files.
Attacking: Performs deauthentication or creates fake access points
Testing: Checking the wifi cards or driver capabilities
Cracking: Various security standards like WEP or WPA PSK.
1. To list all network interfaces.
airmon-ng

This command will return all the network interfaces available or connected to the system.
2. Stopping the desired network interface.
airmon-ng stop wlan0mon

To stop a network interface enter the above command and replace “wlan0” with the desired network interface.
3. Starting a network interface at a specific channel.
airmon-ng start wlan0 10

To start a network interface at a specific channel enter the above command and replace “wlan0” with the desired network interface and 10 with the desired channel name.
4. Collecting authentication handshake
airodump-ng -c 10 --bssid 00:15:5D:9C:44:00 -w psk wlan0

To collect the authentication handshake enter the above command in terminal and replace “wlan0” with the desired network interface and 10 with the desired channel name and bssid with the bssid of the wifi.
5. Cracking the captured handshake file by means of a wordlist
aircrack-ng -w wordlist psk*.cap

To run a brute force attack and to crack the password enter the above command in the terminal and replace “wordlist” with the desired wordlist to be used and “wpa.cap” with the desired handshake filename.
6. To get the help section of the tool
aircrack-ng --help

The above command will display the help section of the aircrack-ng command.
7. To display the # of CPUs and SIMD support
aircrack-ng -u

The above command will display the details of the hash of CPUs and SIMD support.
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
TCP Server-Client implementation in C
ZIP command in Linux with examples
tar command in Linux with examples
SORT command in Linux/Unix with examples
curl command in Linux with Examples
UDP Server-Client implementation in C
'crontab' in Linux with Examples
Conditional Statements | Shell Script
diff command in Linux with examples
tee command in Linux with examples
Concatenate strings from several rows using Pandas groupby - GeeksforGeeks

20 Aug, 2020
Pandas Dataframe.groupby() method is used to split the data into groups based on some criteria. The abstract definition of grouping is to provide a mapping of labels to the group name.
To concatenate string from several rows using Dataframe.groupby(), perform the following steps:
Group the data using Dataframe.groupby() method whose attributes you need to concatenate.Concatenate the string by using the join function and transform the value of that column using lambda statement.
Group the data using Dataframe.groupby() method whose attributes you need to concatenate.
Concatenate the string by using the join function and transform the value of that column using lambda statement.
We will use the CSV file having 2 columns, the content of the file is shown in the below image:
Example 1: We will concatenate the data in the branch column having the same name.
Python3
# import pandas libraryimport pandas as pd  # read csv filedf = pd.read_csv("Book2.csv")  # concatenate the stringdf['branch'] = df.groupby(['Name'])['branch'].transform(lambda x : ' '.join(x))  # drop duplicate datadf = df.drop_duplicates()     # show the dataframeprint(df)
Output:
Example 2: We can perform Pandas groupby on multiple columns as well.
We will use the CSV file having 3 columns, the content of the file is shown in the below image:
Apply groupby on Name and year column
Python3
# import pandas libraryimport pandas as pd  # read a csv filedf = pd.read_csv("Book1.csv")  # concatenate the stringdf['branch'] = df.groupby(['Name', 'year'])['branch'].transform(                                              lambda x: ' '.join(x))  # drop duplicate datadf = df.drop_duplicates()            # show the dataframedf
Output:
Python Pandas-exercise
Python pandas-groupby
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Create a Pandas DataFrame from Lists
Python program to convert a list to string
Reading and Writing to text files in Python
*args and **kwargs in Python
Explain about concurrent transactions in DBMS

A transaction is a unit of database processing which contains a set of operations. For example, deposit of money, balance enquiry, reservation of tickets etc.
Every transaction starts with delimiters begin transaction and terminates with end transaction delimiters. The set of operations within these two delimiters constitute one transaction.
main()
{
   begin transaction
} end transaction
There are three possible ways in which a transaction can be executed. These are as follows −
Serial execution.
Parallel execution.
Concurrent execution.
Concurrent transaction or execution includes multiple transactions which are executed concurrently or simultaneously in the system.
The advantages of the concurrent transactions are as follows −
Increases throughput which is nothing but number of transactions completed per unit time.
Increases throughput which is nothing but number of transactions completed per unit time.
It reduces the waiting time.
It reduces the waiting time.
T1= 90sec
T2= 500sec
T3= 5sec.
If we execute serially by T1->T2->T3 then transaction T3 waits for 590 sec, so we go for non-serial or concurrent transactions to reduce waiting time.
i.e. T3 -> T1 -> T2.
The disadvantage is that the execution of concurrent transactions may result in inconsistency.
The concurrent execution given below is in a consistent state.
The transaction given below is not consistent.
Concurrent schedules do not keep the database in the consistent state. The concurrent execution of the transactions has to be carried out in a controlled environment.
If a system consists of ‘n’ number of transactions, we will have more than ‘n!’ number of concurrent schedules, out of which only a few of them are keeping the database in consistent state.
Java program to reverse bits of a positive integer number

The bits of an integer number can be reversed to obtain another number. An example of this is given as follows −
Number = 11
Binary representation = 1011
Reversed binary representation = 1101
Reversed number = 13
A program that demonstrates this is given as follows −
 Live Demo
public class Example {
   public static void main(String[] args) {
      int num = 14;
      int n = num;
      int rev = 0;
      while (num > 0) {
         rev <<= 1;
         if ((int)(num & 1) == 1)
         rev ^= 1;
         num >>= 1;
      }
      System.out.println("The original number is: " + n);
      System.out.println("The number with reversed bits is: " + rev);
   }
}
The original number is: 14
The number with reversed bits is: 7
Now let us understand the above program.
The number is defined. Then a while loop is used to reverse the bits of the number. The code snippet that demonstrates this is given as follows −
int num = 14;
int n = num;
int rev = 0;
while (num > 0) {
   rev <<= 1;
   if ((int)(num & 1) == 1)
   rev ^= 1;
   num >>= 1;
}
Finally, the number, as well as the reversed number, are displayed. The code snippet that demonstrates this is given as follows −
System.out.println("The original number is: " + n);
System.out.println("The number with reversed bits is: " + rev);