Filter Records of Current Day, Month and Year in MySQL

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

721 Views

Let’s say you have a table with UserLoginTime column wherein we have stored some values for sample. This is the login time of users and we want to filter all these records on the basis of current day, month and year i.e. the current date. We will beLet us now create the table we discussed abovemysql> create table userLoginInformation    - > (    - > UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    - > UserName varchar(20),    - > UserLoginTime datetime    - > ); Query OK, 0 rows affected (0.79 sec)Insert some records in the table using ... Read More

Implement Hit Counter in JSP

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

491 Views

A hit counter tells you about the number of visits on a particular page of your web site. Usually, you attach a hit counter with your index.jsp page assuming people first land on your home page.To implement a hit counter you can make use of the Application Implicit object and associated methods getAttribute() and setAttribute().This object is a representation of the JSP page through its entire lifecycle. This object is created when the JSP page is initialized and will be removed when the JSP page is removed by the jspDestroy() method.Following is the syntax to set a variable at the ... Read More

MonthDay with Method in Java

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

93 Views

An immutable copy of a MonthDay with the month of the year altered as required is done using the method with() in the MonthDay class in Java. This method requires a single parameter i.e. the month that is to be set in the MonthDay and it returns the MonthDay with the month of the year altered as required.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { MonthDay md1 = MonthDay.parse("--02-22"); System.out.println("The MonthDay ... Read More

LongStream max() Method in Java

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

351 Views

The max() method of the LongStream class in Java returns an OptionalLong describing the maximum element of this stream, or an empty optional if this stream is empty.The syntax is as followsOptionalLong max()Here, OptionalLong is a container object which may or may not contain a long value.To use the LongStream class in Java, import the following packageimport java.util.stream.LongStream;The following is an example to implement LongStream max() method in Java. The isPresent() method of the OptionalLong class returns true if the value is presentExample Live Demoimport java.util.*; import java.util.stream.LongStream; public class Demo {    public static void main(String[] args) {     ... Read More

LongStream Parallel Method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

149 Views

The parallel() method of the LongStream class in Java returns an equivalent stream that is parallel.The syntax is as follows:LongStream parallel()To use the LongStream class in Java, import the following packageExample Live Demoimport java.util.stream.LongStream;The following is an example to implement LongStream parallel() method in Java:import java.util.stream.LongStream; public class Demo {    public static void main(String[] args) {       LongStream longStream = LongStream.range(10L, 20L);       System.out.println("Parallel LongStream = ");       longStream.parallel().forEach(System.out::println);    } }outputParallel LongStream = 16 15 10 17 11 13 12 19 18 14

Update Nested Value in Embedded Document Using Set in MongoDB

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

1K+ Views

The syntax is as follows for this −db.yourCollectionName.update({ }, { $set: { "yourOuterFieldName.yourInnerFieldName": "yourValue" } });To understand the syntax, let us create a collection with the document. The query to create a collection with a document is as follows −> db.updateNestedValueDemo.insertOne({"CustomerName":"Chris",    ... "CustomerDetails":{"CustomerAge":25, "CustomerCompanyName":"Google", "CustomerCityName":"US"}}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8fccc4d3c9d04998abf015") }Display all documents from a collection with the help of find() method. The query is as follows −> db.updateNestedValueDemo.find().pretty();The following is the output −{    "_id" : ObjectId("5c8fccc4d3c9d04998abf015"),    "CustomerName" : "Chris",    "CustomerDetails" : {       "CustomerAge" : 25,       ... Read More

Make Custom Objects Serializable in Java

Nitya Raut
Updated on 30-Jul-2019 22:30:25

277 Views

This example demonstrate about how can I make my custom objects SerializableStep 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.     In the above code, we have taken button view to show Serializable object values.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    serializableObject sample;    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)    @Override   ... Read More

Make HTTP POST Request on iOS App Using Swift

Rama Giri
Updated on 30-Jul-2019 22:30:25

1K+ Views

To make an http request in iOS we’ll make use of DataTask and sessions. We’ll create configuration, sessions, url, request, and dataTask objects. Let’s see the steps that we’ll go through.First of all we need to create a session object, which default configuration.let configuration = URLSessionConfiguration.default let session = URLSession(configuration: configuration)Then we need to create an URL Request of The type we need, it can be get, post, delete or put. In this example we are seeing ”POST” type.let url = URL(string: URLString) //let url = NSURL(string: urlString as String) var request : URLRequest = URLRequest(url: url!) request.httpMethod = "POST" ... Read More

Apply DFS for Topological Sorting of Directed Acyclic Graph in C++

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

1K+ Views

Topological sorting of DAG (Directed Acyclic Graph) is a linear ordering of vertices such that for every directed edge uv, where vertex u comes before v in the ordering. If the graph is not a DAG, Topological Sorting for a graph is not possible.Functions and pseudocodesBegin    function topologicalSort():    a) Mark the current node as visited.    b) Recur for all the vertices adjacent to this vertex.    c) Push current vertex to stack which stores result. End Begin    function topoSort() which uses recursive topological sort() function:    a) Mark all the vertices which are not visited.   ... Read More

Remove Duplicate Values Inside a List in MongoDB

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

1K+ Views

You can use aggregate framework along with $setUnion operator. Let us first create a collection with documents −> db.removeDuplicatesDemo.insertOne({"InstructorName":"Chris", "InstructorAge":34, "InstructorSubject":    ["Java", "C", "Java", "C++", "MongoDB", "MySQL", "MongoDB"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb9d96c895c4fd159f80807") }Following is the query to display all documents from the collection with the help of find() method −> db.removeDuplicatesDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5cb9d96c895c4fd159f80807"),    "InstructorName" : "Chris",    "InstructorAge" : 34,    "InstructorSubject" : [       "Java",       "C",       "Java",       "C++",       "MongoDB",   ... Read More

Advertisements