This file contains hidden or 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 com.amazonaws.regions.Regions; | |
| import com.amazonaws.services.s3.AmazonS3; | |
| import com.amazonaws.services.s3.AmazonS3ClientBuilder; | |
| import com.amazonaws.services.s3.internal.Constants; | |
| import com.amazonaws.services.s3.model.*; | |
| import lombok.extern.log4j.Log4j2; | |
| import java.io.ByteArrayInputStream; | |
| import java.io.ByteArrayOutputStream; | |
| import java.io.InputStream; |
This file contains hidden or 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
| public class SubmitTask { | |
| private static final int DEFAULT_THREAD_COUNT = 4; // default number of threads | |
| private final ThreadPoolExecutor executorService; | |
| public SubmitTask() { | |
| this.executorService = (ThreadPoolExecutor) Executors.newFixedThreadPool(DEFAULT_THREAD_COUNT); | |
| } | |
| // if we only submit task to executor service then our thread pool will not closed |
This file contains hidden or 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
| package com.litmus; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| import java.util.concurrent.Executors; | |
| import java.util.concurrent.ThreadPoolExecutor; | |
| import java.util.concurrent.TimeUnit; | |
| /** | |
| * @author pramesh-bhattarai |
This file contains hidden or 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
| public class AreaOfRectangle { | |
| public static long area(int length, int breadth) { | |
| return Math.abs(length * breadth); | |
| } | |
| public static boolean isOverlapped(int K, int L, int M, int N, | |
| int X, int Y) { | |
| return K < X && X < M && L < Y && Y < N; | |
| } |
This file contains hidden or 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
| // creating jar file with all dependencies | |
| jar { | |
| manifest { | |
| attributes "Main-Class": "PATH_TO_MAIN_CLASS" | |
| } | |
| from { | |
| // filters only existing and non-empty dirs | |
| sourceSets.main.runtimeClasspath | |
| .filter { (it.isDirectory() && it.listFiles().length > 0) || it.isFile() } |
This file contains hidden or 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
| /* | |
| * Chaining of map() and reduce() function | |
| */ | |
| (function() { | |
| "use strict" | |
| const object = [{id: 1, name: "normal object1"}, {id: 2, name: "normal object2"}, {id: 3, name: "normal object3"}] | |
| const providers = []; | |
| object.map(mapToProviderObject) | |
| .reduce(pushFilteredProviders, providers); |
This file contains hidden or 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() { | |
| "use strict"; | |
| function searchByKeyPath(object, keys) { | |
| var deep = keys.split("."), obj = null; | |
| for(var i = 0; i < deep.length; i++) { | |
| (obj == null) ? obj = '' + deep[i] : obj = obj + '.' + deep[i]; | |
| if((eval(obj) === null || eval(obj) === undefined) && (i !== deep.length-1)) { | |
| var beforeNotFoundFrom = obj.substring(0, obj.lastIndexOf('.')); | |
| throw "Object not found from " + obj; |
This file contains hidden or 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
| /* parse link for pagination */ | |
| (function() { | |
| 'use strict'; | |
| function parseLink(link, api) { | |
| if(link === null) return; | |
| var split = link.match(/<?([^>]*)>(.*)/); | |
| var api = split[1].substring(split[1].indexOf(api), split[1].length); | |
| var rel = split[2].match( /"(.*?)"/ )[1]; |
This file contains hidden or 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
| package com.callback.fun; | |
| import java.util.function.Consumer; | |
| public class Callback { | |
| private static final double salary = 75_000; | |
| private static void getSalary(Consumer<Double> callback) { | |
| System.out.println("get salary invoked"); |
This file contains hidden or 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
| const users = [ | |
| 'Jack Howton', | |
| 'Natividad Claussen', | |
| 'Jasper Egner', | |
| 'Adella Troxell', | |
| 'Edda Methvin', | |
| 'Aileen Chipley', | |
| 'Kellee Viles' | |
| ]; |
NewerOlder