This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add(xPromise,yPromise) { | |
// `Promise.all([ .. ])` takes an array of promises, and returns a new promise that waits on them all to finish | |
return Promise.all( [xPromise, yPromise] ) | |
// when that promise is resolved, let's take the received `X` and `Y` values and add them together. | |
.then( function(values){ | |
// `values` is an array of the messages from the previously resolved promises | |
return values[0] + values[1]; | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spent hours trying to figure out why my Spring MVC controller was not resolving to my JSP view correctly, despite the view resolver and all other configuration being in place. The name of the view returned from the controller method was being displayed in the browser window in plain text. Turned out I had the @RestController annotation in place instead of @Controller. Gaaaaaaarh ! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$folder = 'D:\Web' # <-- Provided the fully qualified directory path | |
$filter = '*.txt' # <-- Set this according to your requirements. Matches the file patterns within the directory | |
$fsw = New-Object IO.FileSystemWatcher $folder, $filter -Property @{ | |
IncludeSubdirectories = $true # <-- Set this according to your requirements | |
} | |
$onCreated = Register-ObjectEvent $fsw Created -SourceIdentifier FileCreated -Action { | |
$path = $Event.SourceEventArgs.FullPath | |
$name = $Event.SourceEventArgs.Name | |
$changeType = $Event.SourceEventArgs.ChangeType | |
$timeStamp = $Event.TimeGenerated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//numberList is a producer of subtypes of numbers. Hence is generified with ? extends Number. Producer->Extends | |
final List<? extends Number> numberList = DoubleStream.of(-99, 1, 2, 3, 4, 5, 6) | |
.boxed().collect(Collectors.toList()); | |
//numberList.add(new Integer(1)); //Cannot add integer to this list, even though integer is a subtype of number. | |
numberList.add(null);//Cannot add anything to numberList other than null | |
final Number number = numberList.get(0);//Can only get values as Number type | |
System.out.println(number.doubleValue()); | |
//integerList is a consumer of supertypes of integers. Hence is generified with ? super Integer. Consumer->Super | |
final List<Object> doubleList = IntStream.of(99, 1, 2, 3, 4, 5, 6).boxed() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a. –XX:+UseParNewGC – Use parallel GC in the young generation | |
b. –XX:–UseParNewGC – Use serial GC in young generation | |
c. –XX:+UseParallelGC - Use parallel GC in the young generation, serial in old generation | |
d. –XX:+UseSerialGC – Use serial generational GC | |
e. –XX:+UseParallelOldGC – Use parallel GC in both young and old generation. | |
f. –XX:+UseConcMarkSweepGC – Use Concurrent Mark Sweep GC in old generation. | |
g. –XX:+AlwaysTenure – Always create objects in old generation. | |
h. –XX:+UseG1GC – Use G1 garbage collector | |
i. –XX:PretenureSizeThreshold=<n bytes> - Allocate objects greater than n bytes in size directly in old generation | |
j. –Xms=<nM/m/g/G> – This option lets you specify minimum memory that is allocated to your Java heap. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Java 8 default method implementations in interfaces do not make abstract classes obsolete. Abstract classes are still needed where private state needs to be maintained. Interfaces with default method implementations are thus useful for representing types that are mostly stateless and provide default implementations for utility methods that can be used by classes that implement these interfaces but do not want to override the default implementation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You setup a study routine for your daughter, but you give her some rejuvenation breaks, during which she's free to do what she likes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
My generosity towards you will vary based on whether I've had a good day or a bad day. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
My relatives expect me to put up with them, the same way my family does. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You are not talking to your wife because you just had a huge argument, so you ask your daughter to pass on any messages to your wife. |
NewerOlder