Friday, 24 November 2017
Moodle 2.1 Customizations: Adding Javascript to "page" resource
Moodle 2.1 Customizations: Adding Javascript to "page" resource: Well this has been bugging me for a while - every time I tried to insert Javascript into the moodle html editor it never worked. You could e...
Thursday, 9 November 2017
Remote Procedure Call Frameworks
- https://dzone.com/articles/is-java-remote-procedure-call-dead-in-the-rest-age
- https://en.wikipedia.org/wiki/Apache_Thrift
- https://stackoverflow.com/questions/2728495/what-is-the-difference-between-java-rmi-and-rpc
Interview question: What is the difference between JMS and RPC?
Monday, 9 October 2017
Reading Notes: Debuggers vs. Logging
"We find stepping through a program less productive than thinking harder and adding output statements and self-checking code at critical places."
Professional Java for Web Applications, by Nicholas S. Williams
Professional Java for Web Applications, by Nicholas S. Williams
Wednesday, 17 May 2017
Completable Futures
Problem:
Process concurrently all the files in a directory tree.
The files store integers, separated by line endings.
Bibliography:
http://www.baeldung.com/java-completablefuture
My solution:
Process concurrently all the files in a directory tree.
The files store integers, separated by line endings.
Bibliography:
http://www.baeldung.com/java-completablefuture
My solution:
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
package parallelStreamsOfIntegers; | |
import java.io.BufferedReader; | |
import java.io.File; | |
import java.io.FileNotFoundException; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import java.nio.file.Files; | |
import java.nio.file.Path; | |
import java.nio.file.Paths; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.concurrent.CompletableFuture; | |
import java.util.stream.Collectors; | |
import java.util.stream.Stream; | |
public class TestWithCompletableFuture { | |
public static void main(String[] args) { | |
List<CompletableFuture<Integer>> futures = new ArrayList<>(); | |
try(Stream<Path> paths = Files.walk(Paths.get("D:\\JavaInterviewExercises\\parallelStreamsOfIntegers\\data"))) { | |
paths.forEach(filePath -> { | |
if (Files.isRegularFile(filePath)) { | |
System.out.println(filePath); | |
futures.add(CompletableFuture.supplyAsync(() -> { | |
int sum = 0; | |
File file = new File(filePath.toString()); | |
try (BufferedReader reader = new BufferedReader(new FileReader(file))){ | |
String text = null; | |
while ((text = reader.readLine()) != null) { | |
sum += (Integer.parseInt(text)); | |
System.out.println(text); | |
} | |
} | |
catch (FileNotFoundException e) { | |
System.out.println("I can't find this file!!!"); | |
} | |
catch (IOException e){ | |
e.printStackTrace(); | |
} | |
return sum; | |
})); | |
} | |
}); | |
} catch (IOException e1) { | |
// TODO Auto-generated catch block | |
e1.printStackTrace(); | |
} | |
Integer combined = futures.stream() | |
.map(CompletableFuture::join) | |
.mapToInt(i -> i) | |
.sum(); | |
System.out.println(combined); | |
} | |
} |
Tuesday, 2 May 2017
Does IT Industry Need Better Namings?
Does IT Industry Need Better Namings?: The IT industry borrows terms from other domains, which is a fairly good approach. But we distort their meanings or use terms in inconsistent ways, within IT and also in comparison to other disciplines. This article shares some of these leaky terminologies with examples, explains why this matters and suggests how to deal with inconsistencies and improve the situation.
Subscribe to:
Posts (Atom)