code-rag-bench/online-tutorials huggingface dataset:
bits Package in Golang - GeeksforGeeks

08 Jun, 2020
Go language provides inbuilt support for bit counting and manipulation functions for the predeclared unsigned integer types with the help of the bits package.
Example 1:
// Golang program to illustrate bits.Sub() Functionpackage main  import (    "fmt"    "math/bits")  // Main functionfunc main() {      // Finding diff and borrowOu    // of the specified numbers    // Using Sub() function    nvalue_1, borrowOut := bits.Sub(4, 3, 0)    fmt.Println("Diff:", nvalue_1)    fmt.Println("BorrowOut :", borrowOut)}
Output:
Diff: 1
BorrowOut : 0
Example 2:
// Golang program to illustrate bits.TrailingZeros64() Functionpackage main  import (    "fmt"    "math/bits")  // Main functionfunc main() {      // Using TrailingZeros64() function    a := bits.TrailingZeros64(15)    fmt.Printf("Total number of trailing"+            " zero bits in %d: %d", 15, a)}
Output:
Total number of trailing zero bits in 15: 0
Golang-bits
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
6 Best Books to Learn Go Programming Language
How to Parse JSON in Golang?
Time Durations in Golang
Strings in Golang
Structures in Golang
How to iterate over an Array using for loop in Golang?
Rune in Golang
Loops in Go Language
Defer Keyword in Golang
Class and Object in Golang
How to Browse From the Linux Terminal Using W3M? - GeeksforGeeks

17 Sep, 2019
W3M is an open-source text-based terminal web browser for Linux used to browse through the terminal. It is simple to use and do not require any additional interacting interface application though it interacts through the terminal. It renders the web pages in a form as their original layout.
How to Install W3M?
As W3M is not included by default on most Linux distributions, we have to install the main w3m package and the w3m-img package for inline image support using the following command:
sudo apt-get install w3m w3m-img
While installing, it asks your permission, type Y to proceed
Browsing: To access a webpage, we just have to specify the web address. If you want to bring up Google, then you just to run following command:
w3m google.com
Instructions to Use:
Use arrow keys to move the cursor around or click at the desired location.
Where you want to type anything, select the text box with your cursor and press enter before typing the text.
Load a hyperlink by selecting it and pressing enter.
Searching
Result
Note: Tab key can be used to position the cursor over different links or tabs.
Linux-Unix
TechTips
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ZIP command in Linux with examples
TCP Server-Client implementation in C
tar command in Linux with examples
curl command in Linux with Examples
Conditional Statements | Shell Script
How to Find the Wi-Fi Password Using CMD in Windows?
Docker - COPY Instruction
Top Programming Languages for Android App Development
How to Run a Python Script using Docker?
Setting up the environment in Java
NumberFormat setMaximumFractionDigits() method in Java with Examples - GeeksforGeeks

01 Apr, 2019
The setMaximumFractionDigits() method is a built-in method of the java.text.NumberFormat which sets the maximum number of digits allowed in the fraction portion of a number.If the new value for maximumFractionDigits is less than the current value of minimumFractionDigits, then minimumFractionDigits will also be set to the new value.
Syntax:
public void setMaximumFractionDigits(int val)
Parameters: The function accepts a mandatory parameter val which specifies the maximum value to be set.
Return Value: The function returns nothing, hence has a return type void.
Below is the implementation of the above function:
Program 1:
// Java program to implement// the above function  import java.text.NumberFormat;import java.util.Locale;import java.util.Currency;  public class Main {    public static void main(String[] args)        throws Exception    {          NumberFormat nF            = NumberFormat.getNumberInstance();          System.out.println("Maximum set initially as: "                           + nF.getMaximumFractionDigits());          // Set grouping        nF.setMaximumFractionDigits(100);          // Print the final        System.out.println("Maximum set finally as: "                           + nF.getMaximumFractionDigits());    }}
Maximum set initially as: 3
Maximum set finally as: 100

Program 2:
// Java program to implement// the above function  import java.text.NumberFormat;import java.util.Locale;import java.util.Currency;  public class Main {    public static void main(String[] args)        throws Exception    {          NumberFormat nF            = NumberFormat.getNumberInstance();          System.out.println("Maximum set initially as: "                           + nF.getMaximumFractionDigits());          // Set grouping        nF.setMaximumFractionDigits(6785);          // Print the final        System.out.println("Maximum set finally as: "                           + nF.getMaximumFractionDigits());    }}
Maximum set initially as: 3
Maximum set finally as: 6785

Reference: https://docs.oracle.com/javase/10/docs/api/java/text/NumberFormat.html#setMaximumFractionDigits(int)
Java-Functions
Java-NumberFormat
Java-text package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Stream In Java
Interfaces in Java
How to iterate any Map in Java
ArrayList in Java
Initialize an ArrayList in Java
Stack Class in Java
Multidimensional Arrays in Java
Singleton Class in Java
Python - Double Split String to Matrix - GeeksforGeeks

01 Oct, 2020
Given a String, perform the double split, 1st for rows, and next for individual elements so that the given string can be converted to a matrix.
Examples:
Input : test_str = ‘Gfg,best*for,all*geeks,and,CS’, row_splt = “*”, ele_splt = “,” Output : [[‘Gfg’, ‘best’], [‘for’, ‘all’], [‘geeks’, ‘and’, ‘CS’]] Explanation : String split by rows, and elements by respective delims.
Input : test_str = ‘Gfg!best*for!all*geeks!and!CS’, row_splt = “*”, ele_splt = “!” Output : [[‘Gfg’, ‘best’], [‘for’, ‘all’], [‘geeks’, ‘and’, ‘CS’]] Explanation : String split by rows, and elements by respective delims. 
Method #1 : Using split() + loop
In this, 1st split() is used to construct rows of Matrix, and then nested split() to get separation between individual elements.
Python3
# Python3 code to demonstrate working of # Double Split String to Matrix# Using split() + loop  # initializing stringtest_str = 'Gfg,best#for,all#geeks,and,CS'  # printing original stringprint("The original string is : " + str(test_str))  # initializing row split char row_splt = "#"  # initializing element split char ele_splt = ","  # split for rowstemp = test_str.split(row_splt)res = []  for ele in temp:          # split for elements    res.append(ele.split(ele_splt))          # printing result print("String after Matrix conversion : " + str(res)) 
Output:
The original string is : Gfg,best#for,all#geeks,and,CSString after Matrix conversion : [[‘Gfg’, ‘best’], [‘for’, ‘all’], [‘geeks’, ‘and’, ‘CS’]]
Method #2 : Using list comprehension + split()
This is yet another way in which this task can be performed. In this, we use a similar process, but one-liner to solve the problem.
Python3
# Python3 code to demonstrate working of # Double Split String to Matrix# Using list comprehension + split()  # initializing stringtest_str = 'Gfg,best#for,all#geeks,and,CS'  # printing original stringprint("The original string is : " + str(test_str))  # initializing row split char row_splt = "#"  # initializing element split char ele_splt = ","  # split for rowstemp = test_str.split(row_splt)  # using list comprehension as shorthandres = [ele.split(ele_splt) for ele in temp]          # printing result print("String after Matrix conversion : " + str(res))
Output:
The original string is : Gfg,best#for,all#geeks,and,CSString after Matrix conversion : [[‘Gfg’, ‘best’], [‘for’, ‘all’], [‘geeks’, ‘and’, ‘CS’]]
Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
GATE | GATE-CS-2014-(Set-1) | Question 65 - GeeksforGeeks

28 Jun, 2021
Which of the regular expressions given below represent the following DFA?
I) 0*1(1+00*1)*
II) 0*1*1+11*0*1
III) (0+1)*1 
(A) I and II only(B) I and III only(C) II and III only(D) I, II, and IIIAnswer: (B)Explanation:
I) 0*1(1+00*1)*
II) 0*1*1+11*0*1
III) (0+1)*1 

(I) and  (III) represent DFA.

(II) doesn't represent as the DFA accepts strings like 11011,
    but the regular expression doesn't accept. 
Quiz of this Question
GATE-CS-2014-(Set-1)
GATE-GATE-CS-2014-(Set-1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE MOCK 2017 | Question 24
GATE | GATE-CS-2006 | Question 47
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
File length() method in Java with Examples

28 Jan, 2019
The length() function is a part of File class in Java . This function returns the length of the file denoted by the this abstract pathname was length.The function returns long value which represents the number of bits else returns 0L if the file does not exists or if an exception occurs.
Function signature:
public long length()
Syntax:
long var = file.length();
Parameters: This method does not accept any parameter.
Return Type The function returns long data type represents the length of the file in bits.
Exception: This method throws Security Exception if the write access to the file is denied
Below programs illustrates the use of length() function:
Example 1: The file “F:\\program.txt” is a existing file in F: Directory.
// Java program to demonstrate// length() method of File Class  import java.io.*;  public class solution {    public static void main(String args[])    {          // Get the file        File f = new File("F:\\program.txt");          // Get the length of the file        System.out.println("length: "                           + f.length());    }}
Output:
length: 100000
Example 2: The file “F:\\program1.txt” is empty
// Java program to demonstrate// length() method of File Class  import java.io.*;  public class solution {    public static void main(String args[])    {          // Get the file        File f = new File("F:\\program.txt");          // Get the length of the file        System.out.println("length: "                           + f.length());    }}
Output:
length: 0
Note: The programs might not run in an online IDE. Please use an offline IDE and set the path of the file.
Java-File Class
java-file-handling
Java-Functions
Java-IO package
Java Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Puzzle | Guess the total number of coins

28 Aug, 2018
There are 10 robbers named as’A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’, ‘G’, ‘H’, ‘I’, ‘J’ they stole some coins from a bank and they decided to divide these coins equally among themselves. So they divide the coins into 10 parts but the last robber ‘J’ got 1 coin less than other robbers. So the remaining 9 robbers murder ‘J’. They again decided to divide the coins into 9 parts. But this time again the last robber ‘I’ got 1 less coin than other robbers. So again the remaining 8 robbers murder ‘I’ and try to divide all coins in between remaining 8 robbers. But again this time ‘H’ got one less coin than the other. Now, this process goes on until 1 robber left i.e. is ‘A’. After that ‘A’ take all the coins and run away. Now you have to guess the total number of coins.
Answer: 2519
Explanation:In a first attempt if there was 1 more coin then the coins could be easily divided among 10 robbers. And in the second attempt also the coins could be equally divided in among 9 robbers and so on. So let just add one coin to the total number of the coin. So the total coins become N+1.now this (N+1) should be divisible by 10. It should be divisible by 9, 8, 7, 6, 5, 4, 3, 2, 1.So our answer should be LCM of (10, 9, 8, 7, 6, 5, 4, 3, 2, 1).Total Number of coins = LCM of (10, 9, 8, 7, 6, 5, 4, 3, 2, 1) which is 2520.Now we have to subtract 1 coin which we have added before, so the total number of coins is 2519.
Puzzles
Puzzles
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Compare Two Queries in SQL

08 Jun, 2021
Queries in SQL :A query will either be an invitation for data results from your info or for action on the info, or each. a question will provide you with a solution to a straightforward question, perform calculations, mix data from totally different tables, add, change, or delete data from info.
Creating a Database :We use CREATE DATABASE command to create a new SQL database.
Syntax –
CREATE DATABASE db_name;
Creating a Table into a created Database :We use the CREATE TABLE command to create a new SQL database.
Syntax  –
CREATE TABLE table_name (   col1 datatype,   col2 datatype,    col3 datatype, );
Inserting the values into created Table :We use INSERT INTO command to create a new SQL database.
Syntax –
INSERT INTO table_nameVALUES (value1, value2, value3);
Example Code to create a database and a table into it –
PHP
CREATE DATABASE myDatabase;  CREATE TABLE myTable(Pid int,FName varchar(255),LName varchar(255),Adrs varchar(255),District varchar(255));  INSERT INTO myTable (Pid, FName, LName, Adrs, District)VALUES ('1','Krishna','Kripa','Jansa','Varanasi');
myDatabase: myTable
Pid
FName
LName
Adrs
District
1
Krishna
Kripa
Jansa
Varanasi
Comparison of Queries :For example, we’ve 2 similar tables in completely different databases and we wish to understand what’s different. Here are the scripts that make sample databases, tables, and information.
PHP
CREATE DATABASE myDatabase1;GOUSE myDatabase1;GO  CREATE TABLE myTable(Aid int,Atype varchar(10),Acost varchar(10));  GO  INSERT INTO myTable (Aid, Atype, Acost)  VALUES ('001', '1', '40'),  ('002', '2', '80'),  ('003', '3', '120')GO  CREATE DATABASE myDatabase2;GOUSE myDatabase2;GO  CREATE TABLE myTable(Aid int,Atype varchar(10),Acost varchar(10));  GO  INSERT INTO myTable (Aid, Atype, Acost)  VALUES ('001', '1', '40'),  ('002', '2', '80'),  ('003', '3', '120'),  ('004', '4', '160')  GO
Output –For myDatabse1 –
Aid
Atype
Acost
001
1
40
002
2
80
003
3
120
For myDatabase2 –
Aid
Atype
Acost
001
1
40
002
2
80
003
3
120
004
4
160
Compare SQL Queries in Tables by using the EXCEPT keyword :EXCEPT shows the distinction between 2 tables. it’s wont to compare the variations between 2 tables.
Now run this query where we use the EXCEPT keyword over DB2 from DB1 –
PHP
SELECT * FROM myDatabase2.myTableEXCEPTSELECT * FROM myDatabase1.myTable
Aid
Atype
Acost
004
4
160
DBMS-SQL
Picked
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Sub queries in From Clause
Window functions in SQL
What is Temporary Table in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL using Python
SQL Query to Convert VARCHAR to INT
RANK() Function in SQL Server
How to Import JSON Data into SQL Server?
SQL Query to Compare Two Dates
Vulmap – Web Vulnerability Scanning And Verification Tools

14 Sep, 2021
Vulnerability Scanning is the process of testing the target domain for various vulnerabilities in Web containers, Web servers, Web middleware, and CMS, and other Web programs, and has vulnerability exploitation functions. Testing each CVE against the target domain manually is not possible as manual testing takes a lot of time. So automated testing is the approach through which we can test the different CVEs against the target domain more quickly. Vulmap is an automated script developed in the Python Language which tests for various CVEs against the target domain. Vulmap is open-source and free to use the tool. Vulmap supports the testing of multiple target domains parallelly. Vulmap supports saving the results in the text and JSON format for further uses. 
Note: Make Sure You have Python Installed on your System, as this is a python-based tool. Click to check the Installation process Python Installation Steps on Linux
Step 1: Use the following command to install the tool in your Kali Linux operating system.
git clone https://github.com/zhzyker/vulmap.git
Step 2: Now use the following command to move into the directory of the tool. You have to move in the directory in order to run the tool.
cd vulmap 
Step 3: You are in the directory of the Vulmap. Now you have to install a dependency of the Vulmap using the following command.
sudo pip3 install -r requirements.txt
Step 4: All the dependencies have been installed in your Kali Linux operating system. Now use the following command to run the tool and check the help section.
python3 vulmap.py -h
Example 1: Test all vulnerabilities poc mode.
In this example, We are testing some common vulnerabilities against the target domain geeksforgeeks.org.
python3 vulmap.py -u http://geeksforgeeks.org
Example 2: Display the list of supported vulnerabilities
In this example, We are displaying the list of available vulnerabilities.
python3 vulmap.py --list
Example 3: Check target domain for struts2 vuln
In this example, We are testing struts2 vulnerability against the geeksforgeeks.org domain.
python3 vulmap.py -u http://geeksforgeeks.org -a struts2
Example 4: Batch scan URLs in list.txt
In this example, We are testing a list of multiple targets at the same time.
python3 vulmap.py -f targets.txt
Example 5: Export scan results to result.txt
In this example, We are saving the results in text file format.
python3 vulmap.py -u http://facebook.com --output-text result.txt
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to reverse an Array using STL in C++?

23 Jun, 2022
Given an array arr[], reverse this array using STL in C++. Example:
Input: arr[] = {1, 45, 54, 71, 76, 12}
Output: {12, 76, 71, 54, 45, 1}

Input: arr[] = {1, 7, 5, 4, 6, 12}
Output: {12, 6, 4, 5, 7, 1}
Approach: Reversing can be done with the help of reverse() function provided in STL. Syntax:
reverse(start_index, index_next_to_last_index);

For example to reverse an array arr[] of size 'n' we need to write as follows:
reverse(arr, arr+n); 
if we observe it is reverse(arr+0, arr+n);
which means, the reverse function reverse the elements in an array from index-0 to index-(n-1)

Ex: Given an array arr of size 7 
reverse(arr, arr+5); 
The above reverse function reverses the elements in an array from index-0 to index-4
CPP
// C++ program to reverse Array// using reverse() in STL #include <algorithm>#include <iostream>using namespace std; int main(){    // Get the array    int arr[] = { 1, 45, 54, 71, 76, 12 };     // Compute the sizes    int n = sizeof(arr) / sizeof(arr[0]);     // Print the array    cout << "Array: ";    for (int i = 0; i < n; i++)        cout << arr[i] << " ";     // Reverse the array    reverse(arr, arr + n);     // Print the reversed array    cout << "\nReversed Array: ";    for (int i = 0; i < n; i++)        cout << arr[i] << " ";    return 0;}
Array: 1 45 54 71 76 12 
Reversed Array: 12 76 71 54 45 1
gufideg
saitej7
cpp-array
STL
C++
C++ Programs
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Writing to an excel file using openpyxl module

03 May, 2018
Prerequisite : Reading an excel file using openpyxl
Openpyxl is a Python library for reading and writing Excel (with extension xlsx/xlsm/xltx/xltm) files. The openpyxl module allows Python program to read and modify Excel files.
For example, user might have to go through thousands of rows and pick out few handful information to make small changes based on some criteria. Using Openpyxl module, these tasks can be done very efficiently and easily.
Let’s see how to create and write to an excel-sheet using Python.
Code #1 : Program to print a active sheet title name
# import openpyxl moduleimport openpyxl  # Call a Workbook() function of openpyxl # to create a new blank Workbook objectwb = openpyxl.Workbook()  # Get workbook active sheet  # from the active attribute. sheet = wb.active  # Once have the Worksheet object,# one can get its name from the# title attribute.sheet_title = sheet.title  print("active sheet title: " + sheet_title)
Output :
active sheet title: Sheet
 Code #2 : Program to change the Title name
# import openpyxl moduleimport openpyxl  # Call a Workbook() function of openpyxl # to create a new blank Workbook objectwb = openpyxl.Workbook()  # Get workbook active sheet  # from the active attributesheet = wb.active  # One can change the name of the titlesheet.title = "sheet1"  print("sheet name is renamed as: " + sheet.title)
Output :
sheet name is renamed as: sheet1
 Code #3 :Program to write to an Excel sheet
# import openpyxl moduleimport openpyxl  # Call a Workbook() function of openpyxl # to create a new blank Workbook objectwb = openpyxl.Workbook()  # Get workbook active sheet  # from the active attributesheet = wb.active  # Cell objects also have row, column# and coordinate attributes that provide# location information for the cell.  # Note: The first row or column integer# is 1, not 0. Cell object is created by# using sheet object's cell() method.c1 = sheet.cell(row = 1, column = 1)  # writing values to cellsc1.value = "ANKIT"  c2 = sheet.cell(row= 1 , column = 2)c2.value = "RAI"  # Once have a Worksheet object, one can# access a cell object by its name also.# A2 means column = 1 & row = 2.c3 = sheet['A2']c3.value = "RAHUL"  # B2 means column = 2 & row = 2.c4 = sheet['B2']c4.value = "RAI"  # Anytime you modify the Workbook object# or its sheets and cells, the spreadsheet# file will not be saved until you call# the save() workbook method.wb.save("C:\\Users\\user\\Desktop\\demo.xlsx")
Output : 
code #4 :Program to add Sheets in the Workbook
# import openpyxl moduleimport openpyxl  # Call a Workbook() function of openpyxl # to create a new blank Workbook objectwb = openpyxl.Workbook()  sheet = wb.active  # Sheets can be added to workbook with the# workbook object's create_sheet() method. wb.create_sheet(index = 1 , title = "demo sheet2")  wb.save("C:\\Users\\user\\Desktop\\demo.xlsx")
Output :
python-modules
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java - String Buffer reverse() Method

This method reverses the value of the StringBuffer object that invoked the method.
Let n be the length of the old character sequence, the one contained in the string buffer just prior to the execution of the reverse method. Then, the character at index k in the new character sequence is equal to the character at index n-k-1 in the old character sequence.
Here is the syntax for this method −
public StringBuffer reverse()

Here is the detail of parameters −
NA
NA
This method returns StringBuffer object with the reversed sequence.
public class Test {

   public static void main(String args[]) {
      StringBuffer buffer = new StringBuffer("Game Plan");
      buffer.reverse();
      System.out.println(buffer);
   }  
}
This will produce the following result −
nalP emaG


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
How do I get the resource id of an image if I know its name in Android using Kotlin?

This example demonstrates how to get the resource id of an image if I know its name in Android using Kotlin.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:padding="4dp"
   tools:context=".MainActivity">
   <ImageView
      android:id="@+id/imageView"
      android:layout_width="match_parent"
      android:layout_height="400dp"
      android:src="@drawable/ic_baseline_account_balance_24" />
   <TextView
      android:id="@+id/textView"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/imageView"
      android:layout_centerInParent="true"
      android:layout_marginTop="10dp"
      android:textColor="@android:color/holo_blue_dark"
      android:textSize="24sp"
      android:textStyle="bold" />
</RelativeLayout>
Step 3 − Add the following code to src/MainActivity.kt
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
class MainActivity : AppCompatActivity() {
   override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
      title = "KotlinApp"
      val drawableName: String = "ic_baseline_account_balance_24" val resID = resources.getIdentifier(
         drawableName, "drawable",
         packageName
      )
      val tvResourceId: TextView = findViewById(R.id.textView)
      tvResourceId.text = "Resource ID:$resID"
   }
}
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.example.q11">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click the Run icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen.
How to hide a widget after some time in Python Tkinter?

Tkinter is a standard Python library for developing GUI-based applications. We can create games, tools, and other applications using the Tkinter library. To develop GUI-based applications, Tkinter provides widgets.
Sometimes, there might be a requirement to hide a widget for some time. This can be achieved by using the pack_forget() method. When we pack the widget in the window using the various methods, we have to use the same method for hiding the widget.
# Import the required libraries
from tkinter import *
from PIL import Image, ImageTk

# Create an instance of tkinter frame or window
win=Tk()

# Set the size of the tkinter window
win.geometry("700x350")

# Create a canvas widget
canvas=Canvas(win, width=400, height=300)
canvas.pack()

# Add an image in the canvas widget
img=ImageTk.PhotoImage(file="baseball.png")
canvas.create_image(100, 150,image=img)

# Hide the image from the canvas after sometime
canvas.after(3000, canvas.pack_forget)

win.mainloop()
Running the given code will display an image in the Canvas widget that will disappear after sometime.
Creating child process using fork() in Python

Our task is to create a child process and display process id of both parent and child process using fork() function in Python.
When we use fork(), it creates a copy of itself, it is a very important aspect of LINUX, UNIX. fork() is mainly applicable for multithreading environment that means the execution of the thread is duplicated created a child thread from a parent thread. When there is an error, the method will return a negative value and for the child process, it returns 0, Otherwise, it returns positive value that means we are in the parent process.
The fork() module can be used from the os module or from Pseudo terminal module called pty. So we should import os or pty for it.
The fork() is used to create a process, it has no argument and its return the process ID. The main reason for using fork() to create a new process which becomes the child process of the caller. When a new child process is created, both processes will execute the next instruction.
The return value of fork() we can understand which process we are when return 0 that means we are in the child process and if return positive value that means we are in the parent process and return negative value means that some error occurred.
import os
   def parentchild():
      n = os.fork()
   if n > 0:
      print("Parent process : ", os.getpid())
   else:
      print("Child proces : ", os.getpid())
# Driver code
parentchild()
Parent process : 8023
Child process : 8024
$
The Pseudo-terminal utility module pty is defined to handle pseudo-terminal concepts. Using this we can start another process, and also can read or write from controlling terminal using programs.
This module is highly platform oriented. We should use UNIX systems to perform these operations.
import pty, os
   def process_parent_child():
      (process_id, fd) = pty.fork()
   print("The Process ID for the Current process is: " + str(os.getpid()))
   print("The Process ID for the Child process is: " + str(process_id))
process_parent_child()
The Process ID for the Current process is: 12508
The Process ID for the Child process is: 12509
Node.js process.traceDeprecation Property - GeeksforGeeks

10 Jun, 2021

The process.traceDeprecation property is an inbuilt application programming interface of the process module which is used to indicate whether the –trace-deprecation flag is set on the current Node.js process.
Syntax:
process.traceDeprecation
Return Value: This property indicates whether the –trace-deprecation flag is set on the current Node.js process.
Below examples illustrate the use of the process.traceDeprecation property in Node.js:
 
Example 1:
index.js
 

 
 










// Node.js program to demonstrate the 
// process.traceDeprecation Property 
  
// Include process module 
const process = require('process'); 
  
// Printing process.traceDeprecation property value 
console.log(process.traceDeprecation); 






Run the index.js file using the following command:
node --trace-deprecation index.js
Output:
true
Again run the same file, but using the different command as shown below:
node index.js
Output:
undefined
Example 2:
Filename: index.js
Javascript
 

 
 










// Node.js program to demonstrate the 
// process.traceDeprecation Property 
  
// Include process module 
const process = require('process'); 
  
// Instance Properties  
process.traceDeprecation = false; 
  
// Printing process.traceDeprecation 
// property value 
console.log(process.traceDeprecation); 
  
// Instance Properties  
process.traceDeprecation = true; 
  
// Printing process.traceDeprecation 
// property value 
console.log(process.traceDeprecation); 






Run the index.js file using the following command:
node --trace-deprecation index.js
Output:
true
true
Again run the same file, but using the different command as shown below:
node index.js
Output:
false
true

Node.js-process-module


Picked


Node.js


Web Technologies

Writing code in comment? 
                                    Please use ide.geeksforgeeks.org, 
                                    generate link and share the link here.
                                
Express.js express.Router() Function
Mongoose Populate() Method
JWT Authentication with Node.js
Node.js Event Loop
How to build a basic CRUD app with Node.js and ReactJS ?
Express.js express.Router() Function
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Creating a JavaScript array with new keyword.

Following is the code for creating a JavaScript array with new keyword −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result {
      font-size: 20px;
      font-weight: 500;
   }
</style>
</head>
<body>
<h1>Creating array with new keyword</h1>
<div style="color: green;" class="result"></div>
<button class="Btn">CLICK HERE</button>
<h3>
Click on the above button to create a new array and display it
</h3>
<script>
   let resEle = document.querySelector(".result");
   document.querySelector(".Btn").addEventListener("click", () => {
   let arr = new Array(1, 2, 3, 4, "A", "B", "C", "D");
      resEle.innerHTML = "arr = " + arr;
   });
</script>
</body>
</html>
The above code will produce the following output −
On clicking the ‘CLICK HERE’ button−
Absolute difference between the first X and last X Digits of N?

Here we will see how to get the differences between first and last X digits of a number N. The number and X are given. To solve this problem, we have to find the length of the number, then cut the last x digits using modulus operator. After that cut all digits from the number except first x digits. Then get the difference, and return the result. Let the number is N = 568424. The X is 2 so first two digits are 56, and last two digits are 24. The difference is (56 - 24) = 32.
begin
   p := 10^X
   last := N mod p
   len := length of the number N
   while len is not same as X, do
      N := N / 10
      len := len -1
   done
   first := len
   return |first - last|
end
 Live Demo
#include <iostream>
#include <cmath>
using namespace std;
int lengthCount(int n){
   return floor(log10(n) + 1);
}
int diffFirstLastDigits(int n, int x) {
   int first, last, p, len;
   p = pow(10, x);
   last = n % p;
   len = lengthCount(n);
   while(len != x){
      n /= 10;
      len--;
   }
   first = n;
   return abs(first - last);
}
main() {
   int n, x;
   cout << "Enter number and number of digits from first and last: ";
   cin >> n >> x;
   cout << "Difference: " << diffFirstLastDigits(n,x);
}
Enter number and number of digits from first and last: 568424 2 
Difference: 32
Go For Loops

The for loop loops through a block of code a specified number of times.
The for loop is the only loop 
available in Go.
Loops are handy if you want to run the same code over and over again, each time with a different value.
Each execution of a loop is called an iteration.
The for loop can take up to three statements:
statement1 Initializes the loop counter value.
statement2 Evaluated for each loop iteration. If it evaluates to TRUE, the loop continues. If it evaluates to FALSE, the loop ends.
statement3 Increases the loop counter value.
Note: These statements don't need to be present as loops arguments. However, they need to be present in the code in some form.
This example will print the numbers from 0 to 4:  
Result:
i:=0; - Initialize the loop counter (i), and set the start value to 0
i < 5; - Continue the loop as long as i is less than 5
i++ - Increase the loop counter value by 1 for each iteration
This example counts to 100 by tens: 
Result:
i:=0; - Initialize the loop counter (i), and set the start value to 0
i <= 100; - Continue the loop as long as i is less than or equal to 100
i+=10 - Increase the loop counter value by 10 for each iteration
The continue statement is used to skip one 
or more iterations in the loop. It then continues with the next iteration in the loop.
This example skips the value of 3:
Result:
The break statement is used to break/terminate the loop execution.
This example breaks out of the loop when i is equal to 3:
Result:
Note: continue and break are usually used with conditions.
It is possible to place a loop inside another loop.
Here, the "inner loop" will be executed one time for each iteration of the "outer loop":
Result:
The range keyword is used to more easily iterate 
over an array, slice or map. It returns both the index and the value.
The range keyword is used like this:
This example uses range to iterate over an 
  array and print both the indexes and the values at each (idx 
  stores the index, val stores the value):
Result:
Tip: To only show the value or the index, you can omit the other output using an underscore (_).
Here, we want to omit the indexes (idx 
  stores the index, val stores the value):
Result:
Here, we want to omit the values (idx 
  stores the index, val stores the value):
Result:
Print i as long as i is less than 6.
package main   
import ("fmt") 
func main() {
   i:=0; i < 6;  {
    fmt.Println(i)
  }
}

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.
Apex - if statement

An if statement consists of a Boolean expression followed by one or more statements.
if boolean_expression {
   /* statement(s) will execute if the boolean expression is true */
}

If the Boolean expression evaluates to true, then the block of code inside the if statement will be executed. If the Boolean expression evaluates to false, then the first set of code after the end of the if statement(after the closing curly brace) will be executed.
Suppose, our Chemical company has customers of two categories – Premium and Normal. Based on the customer type, we should provide them discount and other benefits like after sales service and support. Following is an implementation of this.
//Execute this code in Developer Console and see the Output
String customerName = 'Glenmarkone'; //premium customer
Decimal discountRate = 0;
Boolean premiumSupport = false;

if (customerName == 'Glenmarkone') {
   discountRate = 0.1; //when condition is met this block will be executed
   premiumSupport = true;
   System.debug('Special Discount given as Customer is Premium');
}
As 'Glenmarkone' is a premium customer so the if block will be executed based on the condition.

    14 Lectures 
     2 hours 

 Vijay Thapa

    7 Lectures 
     2 hours 

 Uplatz

    29 Lectures 
     6 hours 

 Ramnarayan Ramakrishnan

    49 Lectures 
     3 hours 

 Ali Saleh Ali

    10 Lectures 
     4 hours 

 Soham Ghosh

    48 Lectures 
     4.5 hours 

 GUHARAJANM
 Print
 Add Notes
 Bookmark this page
jQuery Remove Elements

With jQuery, it is easy to remove existing HTML elements.
To remove elements and content, there are mainly two jQuery methods:
remove() - Removes the selected element (and its child elements)
empty() - Removes the child elements from the selected element
The jQuery remove() method removes the selected element(s) and its child 
elements.
The jQuery empty() method removes the child elements of the selected element(s).
The jQuery remove() method also accepts one parameter, which allows you to 
filter the elements to be removed.
The parameter can be any of the jQuery selector syntaxes.
The following example removes all <p> elements with class="test":   
This example removes all <p> elements with class="test" and 
class="demo":  
Use a jQuery method to remove a <div> element.
$("div").();

Start the Exercise
For a complete overview of all jQuery HTML methods, please go to our
jQuery HTML/CSS Reference.
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 create a Venn diagram in R?

A Venn diagram helps to identify the common and uncommon elements between two or more than two sets of elements. This is also used in probability theory to visually represent the relationship between two or more events. To create a Venn diagram in R, we can make use of venn function of gplots package.
Consider the below vectors
x<-c(rep(c(1,2,3),times=c(4,5,8)),12,15,20)
y<-c(1:10,25)
Installing and loading gplots package −
install.packages("gplots")
library(gplots)
Creating the Venn diagram for x and y −
venn(list(x,y))
If we have three variables then we will just add the third variable in venn function as shown below −
z<-c(5:15,21)
venn(list(x,y,z))
SAP UI5 - Views

Views are defined using SAP libraries as follows −
XML with HTML, mixed, or Standalone: Library- sap.ui.core.mvc.XMLView
JavaScript: Library- sap.ui.core.mvc.JSView
JSON: Library - sap.ui.core.mvc.JSONView
HTML: Library - sap.ui.core.mvc.HTMLView
Sap.ui.jsview(“sap.hcm.address”, {
   getControllerName: function() {
      return “sap.hcm.address”;
   },
   createContent: function(oController) {
      var oButton = new sap.ui.commons.Button({ text: “Hello” });
      oButton.attachPress(function() {
         oController.Hello();
      })
      Return oButton;
   }
});
<template data-controller-name = ”sap.hcm.address’>
   <h1>title</h1>
   <div> Embedded html </div>
   <div class = ”test” data-sap-ui-type = ”sap.ui.commons.Button”
      Id = ”Button1” data-text =  ”Hello” Data-press = ”sayHello”>
   </div>
</template>
Similarly, you can create JSON view derived from sap.ui.core.mvc.JsonView.
{
   “type”:”sap.ui.core.mvc.JsonView”,
   “controllerName”:”sap.hcm.address”,
   ............................
   ........................
   .........................
}

The following table lists key features associated with MVC concept and comparison of different view types w.r.t the features.

    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
TypeScript - Array push()

push() method appends the given element(s) in the last of the array and returns the length of the new array.
array.push(element1, ..., elementN);

element1, ..., elementN − The elements to add to the end of the array.
Returns the length of the new array.
var numbers = new Array(1, 4, 9); 
var length = numbers.push(10); 
console.log("new numbers is : " + numbers );  
length = numbers.push(20); 
console.log("new numbers is : " + numbers );

On compiling, it will generate the same code in JavaScript.
Its output is as follows −
new numbers is : 1,4,9,10 
new numbers is : 1,4,9,10,20


    45 Lectures 
     4 hours 

 Antonio Papa

    41 Lectures 
     7 hours 

 Haider Malik

    60 Lectures 
     2.5 hours 

 Skillbakerystudios

    77 Lectures 
     8 hours 

 Sean Bradley

    77 Lectures 
     3.5 hours 

 TELCOMA Global

    19 Lectures 
     3 hours 

 Christopher Frewin
 Print
 Add Notes
 Bookmark this page
Check if a string can be obtained by rotating another string 2 places in Python

Suppose we have two strings s and t. We have to check whether we can get s by rotating t two place at any direction left or right.
So, if the input is like s = "kolkata" t = "takolka", then the output will be True as we can rotate "takolka" to the left side two times to get "kolkata".
To solve this, we will follow these steps −
if size of s is not same as size of t, thenreturn False
return False
right_rot := blank string
left_rot := blank string
l := size of t
left_rot := left_rot concatenate t[from index l - 2 to end] concatenate t[from index 0 to l - 3]
right_rot := right_rot concatenate t[from index 2 to end] concatenate t[from index 0 to 1]
return true when (s is same as right_rot or s is same as left_rot) otherwise false
Let us see the following implementation to get better understanding −
 Live Demo
def solve(s, t):
   if (len(s) != len(t)):
      return False
   right_rot = ""
   left_rot = ""
   l = len(t)
   left_rot = (left_rot + t[l - 2:] + t[0: l - 2])
   right_rot = right_rot + t[2:] + t[0:2]
   return (s == right_rot or s == left_rot)
s = "kolkata"
t = "takolka"
print(solve(s, t))
"kolkata", "takolka"
True
Program to find all possible strings typed using phone keypad in python

Suppose we have a string containing digits from 2-9. We have to find all possible letter combinations that the number could generate. One mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does map some characters but no letters.
For an example, if the given string is “49”, then the possible strings will be ['gw', 'gx', 'gy', 'gz', 'hw', 'hx', 'hy', 'hz', 'iw', 'ix', 'iy', 'iz']
To solve this, we will follow these steps:
Define an array called solve to solve the problem recursively
solve method takes digits, characters, result, current_string and current_level, the function will be like
if current_level = length of digits, then add current string after the result, and return
for all characters i in characters[digits[current_level]]perform solve(digits, characters, result, current_string + i, current_level + 1)
perform solve(digits, characters, result, current_string + i, current_level + 1)
The actual function will be like
if digits length is 0, then return empty list
define one map to hold numbers and corresponding characters as a string
result := an empty list
call solve(digits, characters, result, “”, 0)
Let us see the following implementation to get better understanding:
Live Demo
class Solution(object):
   def letterCombinations(self, digits):
      if len(digits) == 0:
         return []

      characters = {2:"abc",3:"def",4:"ghi",5:"jkl",6:"mno",7:"pqrs",8:"tuv",9:"wxyz"}
      result = []
      self.solve(digits,characters,result)
      return result
   def solve(self, digits, characters, result, current_string="",current_level = 0):
      if current_level == len(digits):
         result.append(current_string)
      return
   for i in characters[int(digits[current_level])]:
self.solve(digits,characters,result,current_string+i,current_level+1)

ob1 = Solution()
print(ob1.letterCombinations("49"))
"49"
['gw', 'gx', 'gy', 'gz', 'hw', 'hx', 'hy', 'hz', 'iw', 'ix', 'iy', 'iz']
How to get the current date to display in a Tkinter window?

To work with the date and time module, Python provides the 'datetime' package. Using 'datetime' package, we can display the date, manipulate the datetime object, and use it to write the additional functionality in an application.
To display the current date in a Tkinter window, we've to first import the datetime module in our environment. Once imported, you can create an instance of its object and display them using the label widget.
Here is an example of how you can show the current date in a Tkinter window.
# Import the required libraries
from tkinter import *
import datetime as dt

# Create an instance of tkinter frame or window
win=Tk()

# Set the size of the tkinter window
win.geometry("700x350")

# Create an instance of datetime module
date=dt.datetime.now()

# Format the date
format_date=f"{date:%a, %b %d %Y}"

# Display the date in a a label widget
label=Label(win, text=format_date, font=("Calibri", 25))
label.pack()

win.mainloop()
Running the above code will display the current date in the window.