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 java.util.concurrent.atomic.AtomicInteger; | |
import java.util.function.BiConsumer; | |
import java.util.function.Predicate; | |
public class RetryRunnable implements Runnable { | |
private final long sleep; | |
private final Runnable r; | |
private final int times; | |
private final Predicate<Throwable> p; | |
private BiConsumer<Integer, Throwable> log; |
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 java.util.ArrayList; | |
import java.util.List; | |
import java.util.concurrent.atomic.AtomicInteger; | |
import java.util.function.Function; | |
public class StringToCharSequences implements Function<String, CharSequence[]> { | |
final private char delimiter; | |
public StringToCharSequences(char delimiter) { | |
this.delimiter = delimiter; |
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 java.util.function.Function; | |
public class BytesConvertUtils { | |
public static final Function<Integer, byte[]> intToBytes = l -> { | |
int count = Integer.BYTES; | |
return new byte[] { (byte) ((l >> 8 * --count) & 0xFF), | |
(byte) ((l >> 8 * --count) & 0xFF), | |
(byte) ((l >> 8 * --count) & 0xFF), | |
(byte) ((l >> 8 * --count) & 0xFF) }; | |
}; |
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 static java.lang.Thread.currentThread; | |
import java.util.Iterator; | |
import java.util.NoSuchElementException; | |
import java.util.Optional; | |
import java.util.Spliterator; | |
import java.util.Spliterators; | |
import java.util.concurrent.BlockingQueue; | |
import java.util.concurrent.CompletableFuture; | |
import java.util.concurrent.LinkedBlockingQueue; |
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 java.util.function.Predicate; | |
import javax.script.Invocable; | |
import javax.script.ScriptEngine; | |
import javax.script.ScriptEngineManager; | |
import javax.script.ScriptException; | |
public class ScriptValidator implements Predicate<Object> { | |
private final ScriptEngine engine; | |
private final String functionName; |
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 java.util.Arrays; | |
import java.util.Iterator; | |
import java.util.List; | |
import java.util.function.Consumer; | |
import java.util.function.Function; | |
import java.util.function.Predicate; | |
import java.util.function.Supplier; | |
import java.util.stream.IntStream; | |
public class StreamSample { |
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
#/bin/bash | |
# if sudo not required | |
# find . -name *.sh 2>>/dev/null| xargs chmod +x | |
find . -name *.sh 2>>/dev/null| xargs sudo chmod +x | |
# to verify | |
# find . -name *.sh -ls 2>>/dev/null | |
# OR | |
# find . -name *.sh 2>>/dev/null| xargs ls -l |
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
#!/bin/bash | |
set -e | |
set -x | |
MAP_FILE='./map' | |
DELIMITER="," | |
add (){ | |
KEY=$1 | |
VALUE=$2 | |
echo Key=$KEY Value=$VALUE |
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
#!/usr/bin/env bash | |
set -e | |
#set -x | |
arrayContains(){ | |
ARRAY=($1); | |
ITEM=$2; | |
if echo "${ARRAY[*]}" | grep -E -q " $ITEM |^$ITEM | $ITEM\$" ; | |
then | |
echo true; | |
else |
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
FROM alpine | |
LABEL maintainer="[email protected]" | |
ARG JAVA_VERSION=8 | |
ENV LANG C.UTF-8 | |
ENV JAVA_HOME /usr/lib/jvm/default-jvm | |
ENV PATH $PATH:/usr/lib/jvm/default-jvm/jre/bin:/usr/lib/jvm/default-jvm/bin | |
RUN apk update --no-cache && apk add --no-cache bash openjdk$JAVA_VERSION | |
ADD https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-cli/2.0.0.BUILD-SNAPSHOT/spring-boot-cli-2.0.0.BUILD-20171013.160946-30-bin.tar.gz /opt/spring/ | |
WORKDIR /opt/spring/ | |
RUN tar xvf spring-boot-cli-2.0.0.BUILD-20171013.160946-30-bin.tar.gz |