View RequestAndResponseLoggingFilter.java
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
import lombok.extern.slf4j.Slf4j; | |
import lombok.val; | |
import org.springframework.http.HttpStatus; | |
import org.springframework.http.MediaType; | |
import org.springframework.web.filter.OncePerRequestFilter; | |
import org.springframework.web.util.ContentCachingRequestWrapper; | |
import org.springframework.web.util.ContentCachingResponseWrapper; | |
import javax.servlet.FilterChain; | |
import javax.servlet.ServletException; |
View medium-status.js
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
(() => { | |
if(__APOLLO_STATE__) { | |
let result = null | |
for(const [key, value] of Object.entries(__APOLLO_STATE__)) { | |
if(key.startsWith('Post') && value.hasOwnProperty('curationStatus')) { | |
result = 'Curation status: ' + value.curationStatus; | |
console.log(result) | |
} | |
} |
View padStringResults.json
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
[ | |
{ | |
"jmhVersion" : "1.19", | |
"benchmark" : "de.jawb.jmh.benchmark.example.uniquechars.PaddingBenchmark.testPadding_StringFormat_2", | |
"mode" : "avgt", | |
"threads" : 10, | |
"forks" : 3, | |
"jvm" : "/Library/Java/JavaVirtualMachines/jdk-11.0.10.jdk/Contents/Home/bin/java", | |
"jvmArgs" : [ | |
"-Dfile.encoding=UTF-8" |
View jdk_linked_list_arraylist_runs_size_500k.csv
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
JDK | JDK8 | JDK11 | JDK8 | JDK11 | JDK8 | JDK11 | JDK8 | JDK11 | JDK8 | JDK11 | JDK8 | JDK11 | JDK8 | JDK11 | JDK8 | JDK11 | JDK8 | JDK11 | JDK8 | JDK11 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Size | 500000 | 500000 | 500000 | 500000 | 500000 | 500000 | 500000 | 500000 | 500000 | 500000 | 500000 | 500000 | 500000 | 500000 | 500000 | 500000 | 500000 | 500000 | 500000 | 500000 | |
Time/Run | 3.6ms | 3.5ms | 3.9ms | 4ms | 3.2ms | 4.5ms | 3.9ms | 5.2ms | 0.7ms | 1.5ms | 2.1ms | 2.4ms | 2.9ms | 6.1ms | 3.3ms | 3.6ms | 2449ns | 1659ns | 3166ns | 1906ns | |
Operation | Array List search and remove | Array List search and remove | Linked List search and remove | Linked List search and remove | Array List search | Array List search | Linked List search | Linked List search | Array List addAll() | Array List addAll() | Linked List addAll() | Linked List addAll() | Array List add() from scratch | Array List add() from scratch | Linked List add() from scratch | Linked List add() from scratch | Array List add() on end | Array List add() on end | Linked List add() on end | Linked List add() on end |
View emptyCatch_removed.java
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
private OptionalInt readExpirationAsInt(Milk milk) | |
{ | |
String expiration = milk.getExpiration(); | |
try { | |
return Optional.of(Integer.parseInt(expiration)); | |
} | |
catch(NumberFormatException e) { | |
return OptionalInt.empty(); | |
} |
View emptyCatch.java
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
private int readExpirationAsInt(Milk milk) | |
{ | |
String expiration = milk.getExpiration(); | |
try { | |
return Integer.parseInt(expiration); | |
} | |
catch(NumberFormatException ignored) {} | |
return 0; | |
} |
View avoidThisForDefaultValue.java
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
Optional<String> defaultStoreStatus = Optional.of("Store not found."); | |
public Optional<String> fetchStoreStatus(int storeId) { | |
Optional<String> foundStore = ... ; // fetch declared store status by id | |
if (foundStore.isPresent()) | |
return foundStore; | |
else | |
return defaultStoreStatus; | |
} |
View orOptional_Java9.java
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
1 public Optional<String> fetchStoreStatus(int storeId) { | |
2 Optional<String> foundStore = ... ; // fetch declared store status by id | |
3 return foundStore.or(() -> Optional.of("store uid not found")); | |
4 } |
View orElseGet_orElseCorrection.java
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
getValue(x).orElseGet(() -> getValue(y) | |
.orElseThrow(() -> new NotFoundException("value not present"))); | |
public Optional<Value> getValue(Source s) | |
{ | |
System.out.println("Source: " + s.getName()); | |
// returns value from s source | |
} |
View orElse_BadExample.java
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
getValue(x).orElse(getValue(y) | |
.orElseThrow(() -> new NotFoundException("value not present"))); | |
public Optional<Value> getValue(Source s) | |
{ | |
System.out.println("Source: " + s.getName()); | |
// returns value from s source | |
} |
NewerOlder