HTML DOM Location Host Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

136 Views

The Location host property returns/sets the hostname and host port (if specified). Port might not get displayed if not explicitly specified.SyntaxFollowing is the syntax −Returning value of the host propertylocation.hostValue of the host property setlocation.host = hostname:hostExampleLet us see an example for Location host property − Live Demo Location host    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } Location-host Current URL: ... Read More

Get Memory Usage Under Linux in C++

Samual Sam
Updated on 30-Jul-2019 22:30:26

3K+ Views

Here we will see how to get the memory usage statistics under Linux environment using C++.We can get all of the details from “/proc/self/stat” folder. Here we are taking the virtual memory status, and the resident set size.Example#include #include #include #include #include using namespace std; void mem_usage(double& vm_usage, double& resident_set) {    vm_usage = 0.0;    resident_set = 0.0;    ifstream stat_stream("/proc/self/stat", ios_base::in); //get info from proc    directory    //create some variables to get info    string pid, comm, state, ppid, pgrp, session, tty_nr;    string tpgid, flags, minflt, cminflt, majflt, cmajflt;    string ... Read More

Close Cursors at Commit in JDBC

Vikyath Ram
Updated on 30-Jul-2019 22:30:26

500 Views

CLOSE_CURSORS_AT_COMMIT is the constant value of the ResultSet interface representing the holdability value. If the ResultSet holdability is set to this value whenever you commit/save a transaction using the commit() method of the Connection interface, the ResultSet objects created in the current transaction (that are already opened) will be closed.Let us create a table with name MyPlayers in MySQL database using CREATE statement as shown below −CREATE TABLE MyPlayers(    ID INT,    First_Name VARCHAR(255),    Last_Name VARCHAR(255),    Date_Of_Birth date,    Place_Of_Birth VARCHAR(255),    Country VARCHAR(255),    PRIMARY KEY (ID) );Now, we will insert 7 records in MyPlayers table ... Read More

Querying with MongoDB Subelement

Anvi Jain
Updated on 30-Jul-2019 22:30:26

165 Views

You can use positional operator $ for this. Let us first create a collection with documents −> db.subElementQueryingDemo.insertOne( ...    { ...       "ClientName":"Chris", ...       "Status": [ { "isMarried": true }, { "isMarried": false } ] ...    } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5ccf28c9dceb9a92e6aa1953") }Following is the query to display all documents from a collection with the help of find() method −> db.subElementQueryingDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5ccf28c9dceb9a92e6aa1953"),    "ClientName" : "Chris",    "Status" : [       {         ... Read More

Display Dates After Now Plus 10 Days from a MySQL Table

Chandu yadav
Updated on 30-Jul-2019 22:30:26

773 Views

You can use DATE_ADD() function with where clause for this. Let us first create a table −mysql> create table DemoTable    (    ShippingDate date    ); Query OK, 0 rows affected (0.54 sec)Note : The current date and time is as follows, we found using NOW() −mysql> select now(); +-----------------------+ | now() | +-----------------------+ | 2019-06-04 20 :43 :57 | +-----------------------+ 1 row in set (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-06-16'); Query OK, 1 ... Read More

Overload Method Based on Different Return Type in Java

Venkata Sai
Updated on 30-Jul-2019 22:30:26

9K+ Views

When a class has two or more methods by the same name but different parameters, at the time of calling based on the parameters passed respective method is called (or respective method body will be bonded with the calling line dynamically). This mechanism is known as method overloading.Exampleclass Test{ public int division(int a, int b){ int result = a/b; return result; } public double division (float a, float b){ double result = a/b; ... Read More

HTML DOM Location Hostname Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

379 Views

The Location hostname property returns/sets the hostname for the URL path.SyntaxFollowing is the syntax −Returning value of the hostname propertylocation.hostnameValue of the hostname property setlocation.hostname = hostnameExampleLet us see an example for Location hostname property − Live Demo Location hostname    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } Location-hostname Current URL:    var divDisplay = document.getElementById("divDisplay");    var urlSelect = document.getElementById("urlSelect");    function getHostname(){       divDisplay.textContent = 'Hostname: '+location.hostname;    } OutputThis will produce the following output −Before clicking ‘Get Hostname’ button −After clicking ‘Get Hostname’ button −

Getopt Function in C to Parse Command Line Arguments

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

9K+ Views

The getopt() is one of the built-in C function that are used for taking the command line options. The syntax of this function is like below −getopt(int argc, char *const argv[], const char *optstring)The opstring is a list of characters. Each of them representing a single character option.This function returns many values. These are like below −If the option takes a value, then that value will be pointed by optarg.It will return -1, when no more options to procesReturns ‘?’ to show that this is an unrecognized option, it stores it to optopt.Sometimes some options need some value, If the ... Read More

Intersection of Sets Between Documents in a Single Collection in MongoDB

Smita Kapse
Updated on 30-Jul-2019 22:30:26

190 Views

You can use $setIntersection for this. Let us first create a collection with documents −> db.setInterSectionDemo.insertOne( ...    {"_id":101, "Value1":[55, 67, 89]} ... ); { "acknowledged" : true, "insertedId" : 101 } > db.setInterSectionDemo.insertOne( ...    {"_id":102, "Value2":[90, 45, 55]} ... ); { "acknowledged" : true, "insertedId" : 102 } > db.setInterSectionDemo.insertOne( ...    {"_id":103, "Value3":[92, 67, 45]} ... ); { "acknowledged" : true, "insertedId" : 103 }Following is the query to display all documents from a collection with the help of find() method −> db.setInterSectionDemo.find().pretty();This will produce the following output −{ "_id" : 101, "Value1" : [ 55, 67, ... Read More

Use of substr Method in JavaScript

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

219 Views

substr()substr() method extracts parts of a string, beginning at the character at the specified index, and returns the specified number of characters. It does not change the original string. Syntaxsubstr() method accepts two parameters one is start and other is length str.substr(start , length)Arguments   a) Start: start defines the starting index from where the sub string is to be extracted from the base string.   b) length: length defines the number of characters to be extracted starting from the start in the given string. If the                          second argument to the function is ... Read More

Advertisements