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
//"abc" "bc" -> [ 0 ] | |
//"abc" "c" -> [ 0, 1 ] | |
//"abac" -> "aac" -> [ 1 ] | |
//"aabc" -> "abc" -> [ 0 ] *or* [ 1 ] | |
public static List getDeletedChar(String a, String b) { | |
List results = new ArrayList(); | |
int charIndex; | |
int cursorPos = 0; | |
for (int i = 0; i < b.length(); i++) { |
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
FROM codenvy/jdk7 | |
EXPOSE 8080 | |
ENV CODENVY_APP_PORT_8080_HTTP 8080 | |
ADD $app$ /home/user/$app$ | |
WORKDIR /home/user/ | |
RUN unzip $app$ >/dev/null | |
CMD java -jar application.jar 2>&1 run |
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
@RestController | |
class HelloController{ | |
@RequestMapping | |
public String hello(@RequestParam(required=false) String name){ | |
if(StringUtils.isEmpty(name)) | |
return "Hello World !\n"; | |
else | |
return "Hello "+name+" !\n"; | |
} | |
} |
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
'use strict'; | |
var fs = require('fs'); | |
var Lazy=require("lazy"); | |
var fileName = '{fileName}'; | |
var file = fs.createReadStream(fileName,{encoding:'utf-8'}); | |
var NanoTimer = require('nanotimer'); | |
var timer = new NanoTimer(); | |
function loadFile(callback){ | |
new Lazy(file).lines.forEach( |
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 java.util.Optional; | |
import java.util.function.Consumer; | |
public class OptionalConsumerMain { | |
public static void main(String[] args) { | |
Optional<String> o = Optional.ofNullable(null); | |
OptionalConsumer.of(o) | |
.ifPresent(s -> System.out.println("isPresent " + s)) | |
.ifNotPresent(() -> System.out.println("! isPresent")); |
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 java.util.concurrent.LinkedBlockingQueue; | |
import java.util.concurrent.atomic.AtomicBoolean; | |
import java.util.function.Consumer; | |
import java.util.function.Supplier; | |
public class BlockedForEachLinkedBlockingQueue<T> extends LinkedBlockingQueue<T> { | |
private static final long serialVersionUID = 9053130343708158526L; | |
private static final AtomicBoolean stopBlockedForEach = new AtomicBoolean(false); |
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 java.util.concurrent.BlockingQueue; | |
import java.util.concurrent.Executor; | |
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.LinkedBlockingQueue; | |
import java.util.concurrent.atomic.AtomicBoolean; | |
import java.util.function.Consumer; | |
import java.util.function.Predicate; | |
public class QueuedConsumer<T> implements Consumer<T> { |
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 java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.Future; | |
import java.util.function.Function; | |
public class FutureFunction<T, R> implements Function<T, Future<R>> { | |
private final Function<T, R> function; | |
private FutureFunction(Function<T, R> function) { |
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 java.util.Iterator; | |
import java.util.NoSuchElementException; | |
import java.util.Optional; | |
import java.util.Spliterator; | |
import java.util.Spliterators; | |
import java.util.concurrent.atomic.AtomicInteger; | |
import java.util.function.Supplier; | |
import java.util.stream.Stream; | |
import java.util.stream.StreamSupport; |
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 java.util.Iterator; | |
public class LineSplitter implements Iterable<String> { | |
private final String line; | |
private final char delimiter; | |
public LineSplitter(String line, char delimiter) { | |
this.line = line; | |
this.delimiter = delimiter; | |
} |
OlderNewer