code-rag-bench/online-tutorials huggingface dataset:
HTML | DOM Input FileUpload value Property - GeeksforGeeks

11 Oct, 2019
The Input FileUpload value Property is used to returns the path or the name of the file selected with the element.This property is used to return the name of the selected file with a fake path in IE, Google Chrome, and Opera, and return the name of the selected file in Firefox and Safari. This property is read-only, because of security reasons.
Syntax:
fileuploadObject.value
Example: Return the “path”.
<!DOCTYPE html><html>  <head>    <title>        HTML DOM Input FileUpload value    </title>    <style>        h1 {            color: green;        }    </style></head>  <body>    <center>        <h1>          Geeks for Geeks      </h1>          <input type="file"                id="myFile"                required>          <p id="demo"></p>          <button onclick="myFunction()">            Click        </button>          <script>            function myFunction() {                var x =                    document.getElementById(                        "myFile").value;                  document.getElementById(                    "demo").innerHTML = x;            }        </script>    </center></body>  </html>
Output:Before Clicking the Button:
After Clicking the Button:
Supported Browsers:
Google Chrome
Mozilla Firefox
Edge 10.0
Opera
Apple Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
shubham_singh
HTML-DOM
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
How to Show all the previously connected WiFi Networks using CMD in Windows? - GeeksforGeeks

12 Jun, 2020
Wi-Fi(Wireless Fidelity) Launched in September 1997 is affiliated with WLAN (Wireless Local Area Network).It is a wireless communication technology that uses radio waves to provide a high-speed network and Internet connection.Sometimes there is a need to know the previously connected WiFi networks to get details on some network. There is a wide range of Softwares available for the same. But, this can be done easily with the use of the command prompt of the windows.
To show the History of previously connected WiFi networks using command-prompt of windows, follow the steps given below:
Step 1: Open Command prompt by typing ‘cmd’ in the search bar and press enter.
Step 2: Now type the following command and press Enter:
netsh wlan show profile
All the previously connected WiFi networks are now visible.
GBlog
How To
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Front End Developer Skills That You Need in 2022
DSA Sheet by Love Babbar
6 Best IDE's For Python in 2022
A Freshers Guide To Programming
ML | Underfitting and Overfitting
How to Install PIP on Windows ?
How to Find the Wi-Fi Password Using CMD in Windows?
How to install Jupyter Notebook on Windows?
How to Align Text in HTML?
How to Install OpenCV for Python on Windows?
How to set the margin of ImageView programmatically in Android using Kotlin ?

This example demonstrates how to set the margin of ImageView programmatically 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"
   tools:context=".MainActivity">
   <ImageView
      android:id="@+id/imageView"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="@drawable/image" />
</RelativeLayout>
Step 3 − Add the following code to src/MainActivity.kt
import android.os.Bundle
import android.widget.ImageView
import android.widget.RelativeLayout
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() {
   lateinit var imageView: ImageView
   override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
      title = "KotlinApp"
      imageView = findViewById(R.id.imageView)
      val layoutParams = imageView.layoutParams as RelativeLayout.LayoutParams
      layoutParams.setMargins(100, 100, 100, 100)
      imageView.layoutParams = layoutParams
   }
}
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 copy files to a new directory using Python?

The shutil module provides functions for copying files, as well as entire folders. For copying multiple files at once, you'll have to have a list of all files you want to copy and loop over them to copy them.
Calling shutil.copy(source, destination) will copy the file at the path source to the folder at the path destination. (Both source and destination are strings.) If destination is a filename, it will be used as the new name of the copied file. This function returns a string of the path of the copied file. For example,
import shutil, os
files = ['file1.txt', 'file2.txt', 'file3.txt']
os.mkdir('my_new_folder')
for f in files:
    shutil.copy(f, 'my_new_folder')
How to identify elements based on text visible on page in Selenium?

To identify elements based on text visible on page, text() method is used in xpath.
Syntax −
driver.findElement(By.xpath("//tagname[text()=’value’]"))
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class TextMatch {
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      String url = "https://www.tutorialspoint.com/index.htm";
      driver.get(url);
      driver.manage().window().maximize();
      driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
      //xpath with text() method
      driver.findElement(By.xpath("//*[text()=’GATE Exams’]")).click();
      driver.close();
   }
}
How to convert a Date value to string in JDBC?

The toString() method of the java.sql.Date class returns the escape format: yyyy-mm-dd of the date represented by the current date object. Using this method you can convert a Date object to a String.
Date date = rs.getDate("Dispatch_Date");
date.toString());
Assume we have a table named dispatch_data 3 records as shown below:
+--------------+------------------+---------------+----------------+
| Product_Name | Name_Of_Customer | Dispatch_Date | Location       |
+--------------+------------------+---------------+----------------+
| KeyBoard     | Amith            | 1981-12-05    | Hyderabad      |
| Ear phones   | Sumith           | 1981-04-22    | Vishakhapatnam |
| Mouse        | Sudha            | 1988-11-05    | Vijayawada     |
+--------------+------------------+---------------+----------------+
Following JDBC program establishes connection with the database retrieves the contents of the dispatch_data table, converts the date objects into String values using the toString() method and displays the contents of the table along with the Date values (which are converted into String format):
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class DateToString {
   public static void main(String args[])throws Exception {
      //Registering the Driver
      DriverManager.registerDriver(new com.mysql.jdbc.Driver());
      //Getting the connection
      String mysqlUrl = "jdbc:mysql://localhost/mydatabase";
      Connection con = DriverManager.getConnection(mysqlUrl, "root", "password");
      System.out.println("Connection established......");
      //Creating a Statement object
      Statement stmt = con.createStatement();
      //Creating Statement object
      stmt = con.createStatement();
      ResultSet rs = stmt.executeQuery("select * from dispatch_data");
      //Retrieving values
      while(rs.next()) {
         System.out.println("Product Name: "+rs.getString("Product_Name"));
         System.out.println("Name Of The Customer: "+rs.getString("Name_Of_Customer"));
         //Retrieving the date
         Date date = rs.getDate("Dispatch_Date");
         //Converting Date object to String
         System.out.println("Date: "+date.toString());
         System.out.println();
      }
   }
}
Connection established......
Product Name: KeyBoard
Name Of The Customer: Amith
Date: 1981-12-05

Product Name: Ear phones
Name Of The Customer: Sumith
Date: 1981-04-22

Product Name: Mouse
Name Of The Customer: Sudha
Date: 1988-11-05
Maven - External Dependencies

As you know, Maven does the dependency management using the concept of Repositories. But what happens if dependency is not available in any of remote repositories and central repository? Maven provides answer for such scenario using concept of External Dependency.
For example, let us do the following changes to the project created in ‘Creating Java Project’ chapter.
Add lib folder to the src folder.
Add lib folder to the src folder.
Copy any jar into the lib folder. We've used ldapjdk.jar, which is a helper library for LDAP operations.
Copy any jar into the lib folder. We've used ldapjdk.jar, which is a helper library for LDAP operations.
Now our project structure should look like the following −
Here you are having your own library, specific to the project, which is an usual case and it contains jars, which may not be available in any repository for maven to download from. If your code is using this library with Maven, then Maven build will fail as it cannot download or refer to this library during compilation phase.
To handle the situation, let's add this external dependency to maven pom.xml using the following way.
<project xmlns = "http://maven.apache.org/POM/4.0.0" 
   xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
   http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.companyname.bank</groupId>
   <artifactId>consumerBanking</artifactId>
   <packaging>jar</packaging>
   <version>1.0-SNAPSHOT</version>
   <name>consumerBanking</name>
   <url>http://maven.apache.org</url>

   <dependencies>
      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>3.8.1</version>
         <scope>test</scope>
      </dependency>

      <dependency>
         <groupId>ldapjdk</groupId>
         <artifactId>ldapjdk</artifactId>
         <scope>system</scope>
         <version>1.0</version>
         <systemPath>${basedir}\src\lib\ldapjdk.jar</systemPath>
      </dependency>
   </dependencies>

</project>
Look at the second dependency element under dependencies in the above example, which clears the following key concepts about External Dependency.
External dependencies (library jar location) can be configured in pom.xml in same way as other dependencies.
External dependencies (library jar location) can be configured in pom.xml in same way as other dependencies.
Specify groupId same as the name of the library.
Specify groupId same as the name of the library.
Specify artifactId same as the name of the library.
Specify artifactId same as the name of the library.
Specify scope as system.
Specify scope as system.
Specify system path relative to the project location.
Specify system path relative to the project location.
Hope now you are clear about external dependencies and you will be able to specify external dependencies in your Maven project.

    34 Lectures 
     4 hours 

 Karthikeya T

    14 Lectures 
     1.5 hours 

 Quaatso Learning
 Print
 Add Notes
 Bookmark this page
SQL INNER JOIN Keyword

The INNER JOIN keyword selects records that have matching values in 
both tables.
In this tutorial we will use the well-known Northwind sample database.
Below is a selection from the "Orders" table:
And a selection from the "Customers" table:
The following SQL statement selects all orders with customer information:
Note: The INNER JOIN keyword selects all rows from both 
tables as long as there is a match between the columns. If there are records in the 
"Orders" table that do not have matches in "Customers", these orders will not 
be shown!
The following SQL statement selects all orders with customer and shipper 
information:
Choose the correct JOIN clause to select all records from the two tables where there is a match in both tables.
SELECT *
FROM Orders

ON Orders.CustomerID=Customers.CustomerID;

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.
Implement Text search in MongoDB

For text search, you need to use textalongwithsearch. Let us create a collection with documents −
> db.demo156.createIndex({"StudentName":"text"});
{
   "createdCollectionAutomatically" : true,
   "numIndexesBefore" : 1,
   "numIndexesAfter" : 2,
   "ok" : 1
}
> db.demo156.insertOne({"StudentName":"Chris Brown"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e3547e8fdf09dd6d08539e6")
}
> db.demo156.insertOne({"StudentName":"John Doe"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e3547f2fdf09dd6d08539e7")
}
> db.demo156.insertOne({"StudentName":"John Smith"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e3547f7fdf09dd6d08539e8")
}
Display all documents from a collection with the help of find() method −
> db.demo156.find();
This will produce the following output −
{ "_id" : ObjectId("5e3547e8fdf09dd6d08539e6"), "StudentName" : "Chris Brown" }
{ "_id" : ObjectId("5e3547f2fdf09dd6d08539e7"), "StudentName" : "John Doe" }
{ "_id" : ObjectId("5e3547f7fdf09dd6d08539e8"), "StudentName" : "John Smith" }
Following is the query to implement text search in MongoDB −
> db.demo156.find({ $text: { $search: "John" } } )
This will produce the following output −
{ "_id" : ObjectId("5e3547f7fdf09dd6d08539e8"), "StudentName" : "John Smith" }
{ "_id" : ObjectId("5e3547f2fdf09dd6d08539e7"), "StudentName" : "John Doe" }
LocalDateTime parse() method in Java

The LocalDateTime instance can be obtained from a string value using the parse() method in the LocalDateTime class in Java. This method requires a single parameter i.e. the string which is to be parsed. This string cannot be null. Also, it returns the LocalDateTime instance obtained from the string value that was passed as a parameter.
A program that demonstrates this is given as follows −
 Live Demo
import java.time.*;
public class Demo {
   public static void main(String[] args) {
      LocalDateTime ldt = LocalDateTime.parse("2019-02-18T23:15:30");
      System.out.println("The LocalDateTime is: " + ldt);
   }
}
The LocalDateTime is: 2019-02-18T23:15:30
Now let us understand the above program.
The LocalDateTime instance is obtained from the string value using the parse() method. Then this instance is displayed. A code snippet that demonstrates this is as follows −
LocalDateTime ldt = LocalDateTime.parse("2019-02-18T23:15:30");
System.out.println("The LocalDateTime is: " + ldt);
Find square root of number upto given precision using binary search in C++

Suppose we have a positive number n, and precision p. We have to find square root of the number n up to p decimal places using binary search technique. So if the number is n = 50, and p = 3, then output is 7.071.
So solve this, we have to follow some steps −
Initialize start := 0 and end := n
Compare the square of mid integer, if this is equal to the number then integral part has found out, otherwise look for left or right as required.
Once we have completed the task for integral part, then do for the fractional part.
Initialize increment variable as 0.1, then compute fractional part up to p places. For each iteration increment changes to 1/10 th of its previous value.
Finally return the answer.
 Live Demo
#include<iostream>
using namespace std;
float sqrtBinarySearch(int num, int p) {
   int left = 0, right = num;
   int mid;
   float res;
   while (left <= right) {
      mid = (left + right) / 2;
      if (mid * mid == num) {
         res = mid;
         break;
      }
      if (mid * mid < num) {
         left = mid + 1;
         res = mid;
      } else {
         right = mid - 1;
      }
   }
   float incr = 0.1;
   for (int i = 0; i < p; i++) {
      while (res * res <= num) {
         res += incr;
      }
      res -= incr;
      incr /= 10;
   }
   return res;
}
int main() {
   int n = 50, p = 3;
   cout << "Square root of " << n << " up to precision " << p << " is: " << sqrtBinarySearch(50, 3) << endl;
}
Square root of 50 up to precision 3 is: 7.071
tracepath - Unix, Linux Command

tracepath [-nc] <destination>[/<port>]




It traces path to destination discovering MTU along this path.
It uses UDP port port or some random port.
It is similar to traceroute, only does not not require superuser
privileges. Option -c causes tracepath to use the return address instead
of the reply type (connection refused) to determine when to stop.


tracepath6 is good replacement for traceroute6
and classic example of application of Linux error queues.
The situation with tracepath is worse, because commercial
IP routers do not return enough information in icmp error messages.
Probably, it will change, when they will be updated.
For now it uses Van Jacobson’s trick, sweeping a range
of UDP ports to maintain trace history.





root@mops:~ # tracepath6 3ffe:2400:0:109::2
 1?: [LOCALHOST]                              pmtu 1500
 1:  dust.inr.ac.ru                   0.411ms
 2:  dust.inr.ac.ru        asymm  1   0.390ms pmtu 1480
 2:  3ffe:2400:0:109::2               463.514ms reached
     Resume: pmtu 1480 hops 2 back 2


The first column shows TTL of the probe, followed by colon.
Usually value of TTL is obtained from reply from network,
but sometimes reply does not contain necessary information and
we have to guess it. In this case the number is followed by ?.


The second column shows the network hop, which replied to the probe.
It is either address of router or word [LOCALHOST], if
the probe was not sent to the network.


The rest of line shows miscellaneous information about path to
the correspinding hetwork hop. As rule it contains value of RTT.
Additionally, it can show Path MTU, when it changes.
If the path is asymmetric
or the probe finishes before it reach prescribed hop, difference
between number of hops in forward and backward direction is shown
folloing keyword async. This information is not reliable.
F.e. the third line shows asymmetry of 1, it is because the first probe
with TTL of 2 was rejected at the first hop due to Path MTU Discovery.


Te last line summarizes information about all the path to the destination,
it shows detected Path MTU, amount of hops to the destination and our
guess about amount of hops from the destination to us, which can be
different when the path is asymmetric.


tracepath was written by
Alexey Kuznetsov
<kuznet@ms2.inr.ac.ru>.


No security issues.


This lapidary deserves to be elaborated.
tracepath is not a privileged program, unlike
traceroute, ping and other beasts of this kind.
tracepath may be executed by everyone who has some access
to network, enough to send UDP datagrams to investigated destination
using given port.


tracepath is part of iputils package
and the latest versions are  available in source form from anonymous ftp
ftp://ftp.inr.ac.ru/ip-routing/iputils-current.tar.gz.











Advertisements


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
How to pause in Node.js for a specific time ? - GeeksforGeeks

07 Oct, 2021
Sometimes we need to execute some function after some amount of time like you asked for something from the user and the details are required for the next function from the server end. That time we will require a pause in our server. So to pause for a specific time we use the setTimeout() function. It has a callback function attached to it which gets executed after a given amount of time. The setTimeout() can be used to execute the code after a given amount of milliseconds.
There is one thing you can do for multiple functions that you can break the functions into different blocks of code and use the setTimeout() between them.
Syntax:
setTimeout(function, milliseconds);
Below example illustrate the approach of pausing the NOdeJS by using setTimeout() function:
Example: This function uses setTimeout() under the hood and shows geek! After Hello after 2 seconds. Here the file name is wait.js.
wait.js
function sleep(ms) {  return new Promise((resolve) => setTimeout(resolve, ms));}  console.log("Hello");sleep(2000).then(() => {  console.log("Geek!");});
Output:
NodeJS-Questions
Picked
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to install the previous version of node.js and npm ?
Difference between promise and async await in Node.js
How to use an ES6 import in Node.js?
Express.js res.sendFile() Function
Express.js res.redirect() Function
Top 10 Front End Developer Skills That You Need in 2022
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
How to use jQuery.getScript() method to load external js files?

The jQuery.getScript( url, [callback] ) method loads and executes a JavaScript file using an HTTP GET request.
Here is the description of all the parameters used by this method −
url − A string containing the URL to which the request is sent
callback − This optional parameter represents a function to be executed whenever the data is loaded successfully.
Assuming we have following JavaScript content in result.js file −
function CheckJS(){
   alert("This is JavaScript");
}
The following is the code snippet showing the usage of this method −
<head>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
       
      <script>
         $(document).ready(function() {
           
            $("#driver").click(function(event){
               $.getScript('result.js', function(jd) {
                  // Call custom function defined in script
                  CheckJS();
               });
            });
               
         });
      </script>
   </head>
   
   <body>
   
      <p>Click on the button to load result.js file −</p>
       
      <div id = "stage" style = "background-color:cc0;">
         STAGE
      </div>
       
      <input type = "button" id = "driver" value = "Load Data" />
       
   </body>
Delete Database in MS SQL Server - GeeksforGeeks

02 Sep, 2020
Prerequisite – Introduction of MS SQL Server and Create Database in MS SQL Server
System databases can’t be deleted, only user databases could be deleted. Data and log files will automatically be deleted from disk with database deletion.
To delete a database, the below methods could be used –
SQL Server Management Studio.Transact-SQL.
SQL Server Management Studio.
Transact-SQL.
These are explained as following below.
1. Using SQL Server Management Studio :To delete a database, connect to an instance of the SQL Server, and then expand that instance.
Expand Databases, select the database which need to be deleted.
Right-click the database which need to be deleted, and then click Delete.
Check delete backup and restore history or close existing connections if required and then click OK.
2. Using Transact-SQL :To execute DROP DATABASE statement a user must have CONTROL permission on the database.
To delete a database :USE master ;  
GO  
DROP DATABASE Databasename;  
GO  
USE master ;  
GO  
DROP DATABASE Databasename;  
GO  
To delete multiple databases :USE master ;  
GO  
DROP DATABASE database1, database2, ...;  
GO
USE master ;  
GO  
DROP DATABASE database1, database2, ...;  
GO
Example :Let us assume we have created a database “Geekstest” which is no longer required, to delete database :
USE master ;
GO
DROP DATABASE Geekstest;
GO 
DBMS-SQL
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
SQL | Views
Difference between DELETE, DROP and TRUNCATE
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | GROUP BY
Difference between DDL and DML in DBMS
SQL Interview Questions
What is Temporary Table in SQL?
MySQL | Group_CONCAT() Function
Difference between Where and Having Clause in SQL
SQL - ORDER BY
How to use POSIX semaphores in C language

The semaphore is a concept of process or thread synchronization. Here we will see how to use the semaphores in real programs.
In Linux system, we can get the POSIX semaphore library. To use it, we have to include semaphores.h library. We have to compile the code using the following options.
gcc program_name.c –lpthread -lrt
We can use sem_wait() to lock or wait. And sem_post() to release the lock. The semaphore initializes sem_init() or sem_open() for the Inter-Process Communication (IPC).
#include <stdio.h>
#include <pthread.h>
#include <semaphore.h>
#include <unistd.h>
sem_t mutex;
void* thread(void* arg) { //function which act like thread
   sem_wait(&mutex); //wait state
   printf("\nEntered into the Critical Section..\n");
   sleep(3); //critical section
   printf("\nCompleted...\n"); //comming out from Critical section
   sem_post(&mutex);
}
main() {
   sem_init(&mutex, 0, 1);
   pthread_t th1,th2;
   pthread_create(&th1,NULL,thread,NULL);
   sleep(2);
   pthread_create(&th2,NULL,thread,NULL);
   //Join threads with the main thread
   pthread_join(th1,NULL);
   pthread_join(th2,NULL);
   sem_destroy(&mutex);
}
soumyadeep@soumyadeep-VirtualBox:~/Cpp_progs$ gcc 1270.posix_semaphore.c -lpthread -lrt
1270.posix_semaphore.c:19:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
main() {
^~~~
soumyadeep@soumyadeep-VirtualBox:~/Cpp_progs$ ./a.out

Entered into the Critical Section..

Completed...

Entered into the Critical Section..

Completed...
soumyadeep@soumyadeep-VirtualBox:~/Cpp_progs$
Class Keyword in JavaScript

JavaScript classes, introduced in ES6, are syntactical sugar over JavaScript prototype-based inheritance. Classes are in fact "special functions". You can define classes in JavaScript using the class keyword using the following syntax −
class Person {
   // Constructor for this class
   constructor(name) {
      this.name = name;
   }
   // an instance method on this class
   displayName() {
      console.log(this.name)
   }
}
This is essentially equivalent to the following declaration −
let Person = function(name) {
   this.name = name;
}
Person.prototype.displayName = function() {
   console.log(this.name)
}
This class can also be written as a class expressions. The above format is a class declaration. The following format is a class expression −
// Unnamed expression
let Person = class {
   // Constructor for this class
   constructor(name) {
      this.name = name;
   }
   // an instance method on this class
   displayName() {
      console.log(this.name)
   }
}
No matter how you define the classes as mentioned above, you can create objects of these classes using the following −
let John = new Person("John");
John.displayName();
John
You can read in depth about JS classes and the class keyword at https://www.tutorialspoint.com/es6/es6_classes.htm.
What is BLOB data type in MySQL?

A BLOB is binary large object that can hold a variable amount of data. Followings are some points about BLOB data type −
BLOB is the family of column type intended as high-capacity binary storage.
The actual BLOB column type is of four types-TINYBLOB, BLOB, MEDIUMBLOB and LONGBLOB.
The four BLOB types are very similar to each other; the only difference is the maximum amount of data each can store.
Example − Following example shows how to declare a column as BLOB.
mysql> Create table stock(ID INT, Name VARCHAR(40), PHOTO BLOB, Quantity INT);
Query OK, 0 rows affected (0.15 sec)

mysql> Describe stock;
+----------+-------------+------+-----+---------+-------+
| Field    | Type        | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| ID       | int(11)     | YES  |     | NULL    |       |
| Name     | varchar(40) | YES  |     | NULL    |       |
| PHOTO    | blob        | YES  |     | NULL    |       |
| Quantity | int(11)     | YES  |     | NULL    |       |
+----------+-------------+------+-----+---------+-------+
4 rows in set (0.03 sec)
MS SQL Server - Login Database

A login is a simple credential for accessing SQL Server. For example, you provide your username and password when logging on to Windows or even your e-mail account. This username and password builds up the credentials. Therefore, credentials are simply a username and a password.
SQL Server allows four types of logins −
A login based on Windows credentials.
A login specific to SQL Server.
A login mapped to a certificate.
A login mapped to asymmetric key.
In this tutorial, we are interested in logins based on Windows Credentials and logins specific to SQL Server.
Logins based on Windows credentials allow you to log in to SQL Server using a Windows username and password. If you need to create your own credentials (username and password,) you can create a login specific to SQL Server.
To create, alter, or remove a SQL Server login, you can take one of two approaches −
Using SQL Server Management Studio.
Using T-SQL statements.
Following methods are used to create Login −
Step 1 − After connecting to SQL Server Instance, expand logins folder as shown in the following snapshot.
Step 2 − Right-click on Logins, then click Newlogin and the following screen will open.
Step 3 − Fill the Login name, Password and Confirm password columns as shown in the above screen and then click OK.
Login will be created as shown in the following image.
Create login yourloginname with password='yourpassword'

To create login name with TestLogin and password ‘P@ssword’ run below the following query.
Create login TestLogin with password='P@ssword'


    32 Lectures 
     2.5 hours 

 Pavan Lalwani

    18 Lectures 
     1.5 hours 

 Dr. Saatya Prasad

    102 Lectures 
     10 hours 

 Pavan Lalwani

    52 Lectures 
     4 hours 

 Pavan Lalwani

    239 Lectures 
     33 hours 

 Gowthami Swarna

    53 Lectures 
     5 hours 

 Akshay Magre
 Print
 Add Notes
 Bookmark this page
How to get the Windows certificate details using PowerShell?

We know that the Windows Certificates are resided in the Certificate store but finding the certificate with its name or getting particular certificate details might be cumbersome sometimes.
You can access the certificate store using MMC or using CertMgr.msc command. There are certificates stored for CurrentUser, ServiceAccount, and Local Computer. To access the certificate store using PowerShell, you need to access the PSDrive, and Certificates are stored in the drive called Cert as you can see below.
PS C:\> Get-PSDrive cert | ft -AutoSize
Name Used (GB) Free (GB) Provider Root CurrentLocation
---- --------- --------- -------- ---- ---------------
Cert Certificate \
Let say we want to retrieve the details of the certificate stored in the Root directory in the local machine account then we can use the below command.
Get-ChildItem Cert:\LocalMachine\Root\
PSParentPath: Microsoft.PowerShell.Security\Certificate::LocalMachine\Root
Thumbprint                               Subject
----------                               -------
CDD4EEAE6000AC7F40C3802C171E30148030C072 CN=Microsoft Root Certificate Authority
BE36A4562FB2EE05DBB3D32323ADF445084ED656 CN=Thawte Timestamping CA, OU=Thawte Ce
A43489159A520F0D93D032CCAF37E7FE20A8B419 CN=Microsoft Root Authority, OU=Microso
92B46C76E13054E104F230517E6E504D43AB10B5 CN=Symantec Enterprise Mobile Root for
8F43288AD272F3103B6FB1428485EA3014C0BCFE CN=Microsoft Root Certificate Authority
7F88CD7223F3C813818C994614A89C99FA3B5247 CN=Microsoft Authenticode(tm) Root Auth
Or you can also use the below command,
Get-Item Cert:\LocalMachine\Root\* | ft -AutoSize
The below command will get all the Microsoft certificates.
Get-ChildItem Cert:\LocalMachine\Root\ | where{$_.Subject -like "*Microsoft*"}
To find the specific certificate, you should know the certificate friendly name. For example, to find the “DigiCert” certificate from the Root store,
Get-ChildItem Cert:\LocalMachine\Root\ | where{$_.FriendlyName -eq 'DigiCert'}
Thumbprint                                Subject
----------                                -------
A8985D3A65E5E5C4B2D7D66D40C6DD2FB19C5436  CN=DigiCert Global Root CA, OU=www.digicert.com,
0563B8630D62D75ABBC8AB1E4BDFB5A899B24D43  CN=DigiCert Assured ID Root CA, OU=www.digicert.com
To search directly from the LocalComputer, CurrentUser, or Root store, use -Recurse parameter.
Get-ChildItem Cert:\LocalMachine\ -Recurse | where{$_.FriendlyName -eq 'DigiCert'}
Once you get the thumbprint or friendly Name, you can use the fl * pipeline to get the full details of the certificate.
Get-ChildItem Cert:\LocalMachine\root | where{$_.FriendlyName -eq 'DigiCert'} | fl *
For the remote servers, we can use Invoke-Command, the below example will get the certificates from the remote servers.
Invoke-Command -ComputerName Test1Comp, Test2Comp -Scriptblock{
   Get-ChildItem Cert:\LocalMachine\root | where{$_.FriendlyName -eq 'DigiCert'}
}
Python time.daylight() Function

19 Dec, 2021
Time.daylight() function which returns a non zero integer value when Daylight Saving Time (DST) is defined, else it returns 0. Daylight Saving Time, in short, is called DST which is a best practice of setting a clock time one hour forward from standard time during months of summer and back again in fall. This will be done to make better use of sunlight.
Syntax:
time.daylight
Parameters:
This function doesn’t require any parameters.
Example 1:
Here, the daylight function returns 0 indicates that Daylight Saving Time (DST) is not defined.
Python3
# import necessary packagesimport time  # use daylight functionprint(time.daylight)
Output:
0
Instead of time.daylight function, we can also check whether the Daylight Saving Time (DST) is defined or not using localtime method.
It returns the present Date, Time along with whether a Daylight Saving Time (DST) is set or not. If set, in the returned result it will be displayed as tm_isdst=1 else 0. 
Example 2:
At last in the first line of output tm_isdst=0 specifies that DST is not set. So in confirmation time.daylight also returns 0 that DST is not defined.
Python3
# import necessary packagesimport time  # use localtime methodprint(time.localtime())  # use daylight functionprint(time.daylight)
Output:
time.struct_time(tm_year=2021, tm_mon=12, tm_mday=6, tm_hour=9, tm_min=0, tm_sec=43, tm_wday=0, tm_yday=340, tm_isdst=0)
0
Example 3:
Here, we are going to check whether the DST is defined or not.
Python3
# import necessary packagesimport time  # if DST definedif(time.daylight):    print('DST defined')else:    print('DST not defined')
Output:
DST not defined
Picked
Python time-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list
Creating Phishing page of a website

13 Aug, 2020
Prerequisite – Phishing
Phishing is a type of social engineering attack of tricking an individual to enter the sensitive information like usernames, passwords and credit card details. It can be done by any individual with a mere basic requirement of Kali Linux (or any other Linux Distribution).
Steps to create a phishing page :
Open Kali Linux terminal and paste the following code :git clone https://github.com/DarkSecDevelopers/HiddenEye.git
git clone https://github.com/DarkSecDevelopers/HiddenEye.git
Now perform the steps mentioned below :
Now you can select the website which you want to clone.
You can also add a keylogger or a Cloudflare Protection Page to make your cloned website look more legitimate.
Now you have to enter the redirect URL, i.e. the URL which you want the user to be redirected to after performing a successful phishing attack. You also have to select a server of your choice and can make a legitimate-looking phishing URL or you can go with the random URL.
You now have to deliver the phishing URL to your user and when he clicks on it and he will get redirected to your cloned website.
Once the user enters the details, he will get redirected to our chosen URL and we will be able to phish all the user’s credentials.
Preventive Measures :
Never open suspicious email attachments.
Never click on suspicious email links.
Never provide confidential information via email, over phone or text messages.
Never post your personal data, like your email address or phone number, publicly on social media.
Always check for the authenticity of the URL which the sender wants you to get redirected to.
To create a Facebook Phishing Page using PHP, refer.
Information-Security
Computer Networks
Computer Networks
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
p5.js | loadStrings() Function

13 Mar, 2020
The loadStrings() function is used to read the contents of a file and create an array of strings with each of the lines of the file. The file to be read must be located at the sketch directory if the file name is used, otherwise, a URL to the file can be specified.
This function is recommended to be called in the preload() function to ensure that the function is executed before the other functions.
Syntax:
loadStrings( filename, callback, errorCallback )
Parameters: This function accept three parameter as mentioned above and described below:
filename: This is a string which denotes the name of the file or the url to load the file from.
callback: This is a function which is called after the function is successfully executed. The first argument for this function is the strings array.
errorCallback: This is a function which is called if there is any error in executing the function. The first argument for this function is the error response.
Below examples illustrate the loadStrings() function in p5.js:
Example 1:
let result;   function preload() {    result = loadStrings("test_file.txt");}   function setup() {    createCanvas(600, 300);    textSize(22);}   function draw() {    clear();    text("The contents of the file "        + "are shown below:", 20, 20);       // Check if the strings array    // is non-empty before displaying    // the contents    if (result.length > 0) {        for (let i = 0; i < result.length; i++) {            text(result[i], 20, 60 + i * 20);        }    }    else {        text("File is empty", 20, 60);    }}
Output:
Example 2:
let result;   function setup() {    createCanvas(600, 300);    textSize(22);       text("The file would be loaded"            + " below...", 20, 20);       result = loadStrings(            "test_file.txt", fileLoaded);}   function fileLoaded() {    text("The contents of the file "        + "are shown below:", 20, 60);       // Check if the strings array    // is non-empty before     // displaying the contents    if (result.length > 0) {        for (let i = 0; i < result.length; i++) {            text(result[i], 20, 100 + i * 20);        }    }    else {        text("File is empty", 20, 60);    }}
Output:
Online editor: https://editor.p5js.org/
Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
Reference: https://p5js.org/reference/#/p5/loadStrings
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Hide or show elements in HTML using display property
Difference Between PUT and PATCH Request
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
HTML | <li> value Attribute

30 Apr, 2019
The <li> value attribute in HTML is used to specify the initial value of the list item. It is only applicable on the ordered list.
Syntax:
<li value="number">list items </li>
Attribute Value: This attribute contains single value number which is used to specify the value of the list items.
Example 1: This example uses <li> value attribute to create list of items.
<!DOCTYPE html><html>    <head>        <title>            HTML list item value Attribute        </title>    </head>          <body>        <center>            <h1 style = "color: green;">                GeeksforGeeks            </h1>                          <h2>                HTML list item value Attribute            </h2>                          <p>Sorting Algorithms</p>        </center>                  <ol style="margin-left:42%">            <li value="50">Merge sort</li>            <li>Quick sort</li>            <li>Insertion sort</li>        </ol>              </body></html>                    
Output:
Example 2: This example uses <li> value attribute to create list of items.
<!DOCTYPE html><html>    <head>        <title>            HTML li value Attribute        </title>    </head>          <body>        <h1 style = "color: green;">            GeeksforGeeks        </h1>                  <h2>            HTML li value Attribute        </h2>                  <p>Sorting Algorithms</p>                  <ol type = "A">            <li value="6">Merge sort</li>            <li>Quick sort</li>            <li>Insertion sort</li>        </ol>    </body></html>                    
Output:
Supported Browsers: The browser supported by <li> value attribute are listed below:
Apple Safari
Google Chrome
Firefox
Opera
Internet Explorer
HTML-Attributes
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to Upload Image into Database and Display it using PHP ?
How to check whether an array is empty using PHP?
PHP | Converting string to Date and DateTime
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
C++ Program to Implement Set_Difference in STL

The difference of two sets is formed only by the elements that are present in the first set, not in the second set. The elements copied by the function come always from the first set in the same order. The elements in both the sets shall already be ordered.
Common set operations are −
Set Union
Set Intersection
Symmetric Set Difference or Exclusive-OR
Set Difference or Subtraction
Begin
   Declare set vector v and iterator st.
   Initialize st = set_difference (set1, set1 + n, set2, set2 +n, v.begin()))
   Print the number of elements different between two sets.
End.
#include<iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main () {
   int set1[] = {5,6,7,8,9,10};
   int set2[] = {1,2,3,4,6,7};
   vector<int> v(10);
   vector<int>::iterator it;
   sort (set1, set1 + 6);
   sort (set2, set2 + 6);
   it = set_difference(set1, set1 + 6, set2, set2 + 6, v.begin());
   v.resize(it - v.begin());
   cout << "The difference between the sets has " << (v.size()) << " elements: "<<endl;
   for (it = v.begin(); it != v.end(); ++it)
      cout<< *it<<" ";
      cout <<endl;
   return 0;
}
The difference between the sets has 4 elements
5,8,9,10
Find the first non-repeating character from a stream of characters in Python

Suppose we have a stream of characters, or we can consider a string and we have to find the first non-repeating character in the string. So, if the string is like “people”, the first letter whose occurrence is one is ‘o’. So, the index will be returned, that is 2 here. If there is no such character, then return -1.
To solve this, we will follow these steps −
create one frequency map
create one frequency map
for each character c in string, doif c is not in frequency, then insert it into frequency, and put value 1otherwise increase the count in frequency
for each character c in string, do
if c is not in frequency, then insert it into frequency, and put value 1
if c is not in frequency, then insert it into frequency, and put value 1
otherwise increase the count in frequency
otherwise increase the count in frequency
Scan the frequency map, if the value of specific key is 1, then return that key, otherwise return -1
Scan the frequency map, if the value of specific key is 1, then return that key, otherwise return -1
Let us see the following implementation to get better understanding −
 Live Demo
class Solution(object):
   def firstUniqChar(self, s):
      """
      :type s: str
      :rtype: int
      """
      frequency = {}
      for i in s:
         if i not in frequency:
            frequency[i] = 1
         else:
            frequency[i] +=1
      for i in range(len(s)):
         if frequency[s[i]] == 1:
            return i
      return -1
ob1 = Solution()
print(ob1.firstUniqChar("people"))
print(ob1.firstUniqChar("abaabba"))
"people"
"abaabba"
Output
2
-1