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
//const pattern = 'XXXXXXXXXXXXIIXXXX' | |
const digitsRe = new RegExp('/^\d+$/') | |
function test(str) { | |
if (str.length == 0) return false | |
// part 1: check that first at most 12 characters are only numbers | |
let end = Math.min(12, str.length) | |
if !digitsRe.test(str.substring(0, end)) return false | |
// part 3: check that at most 4 characters after 12 digits and 2 any chars are only numbers | |
end = Math.min(12 + 2 + 4, str.length) |
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.Collection; | |
import java.util.Objects; | |
import java.util.TreeSet; | |
public class Main { | |
public static void main(String[] args) { | |
assertEquals("0,5,7,8,9", getPossiblePins("8")); | |
assertEquals("11,12,14,21,22,24,41,42,44", getPossiblePins("11")); | |
assertEquals("13,15,16,19,43,45,46,49,53,55,56,59,73,75,76,79", getPossiblePins("46")); | |
} |
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
#!/usr/bin/env bash | |
set -e | |
# Returns latest jdk 10 version, e.g. jdk-10.0.2+13 | |
JDK=$(curl --silent "https://api.github.com/repos/AdoptOpenJDK/openjdk10-releases/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') | |
# 10.0.2+13 | |
VERSION=$(basename "${JDK}" | awk -F"-" '{ print $2 }') | |
# 10.0.2 |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>CFBundleDevelopmentRegion</key> | |
<string>English</string> | |
<key>CFBundleExecutable</key> | |
<string>libjli.dylib</string> | |
<key>CFBundleIdentifier</key> | |
<string>net.adoptopenjdk.jdk10</string> |
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
public class Scratch implements EntryPoint { | |
@Override | |
public void onModuleLoad() { | |
testStream(1, 2, 3); | |
} | |
private String createString(Integer n) { | |
return "" + 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
public static CompletableFuture<String> getUrlBytes(String url) { | |
CompletableFuture<String> future = new CompletableFuture<>(); | |
final XMLHttpRequest req = new XMLHttpRequest(); | |
req.open("GET", url, true); | |
req.setOnreadystatechange((e) -> { | |
if (req.status == 200) { | |
future.complete(req.response); | |
} else { | |
future.completeExceptionally(new Exception(req.statusText)); |
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
ArrayList<Throwable> throwables = new ArrayList<>(); | |
onClose.forEach((runnable) -> { | |
try { | |
runnable.run(); | |
} catch (Throwable e) { | |
throwables.add(e); | |
} | |
}); | |
if (!throwables.isEmpty()) { | |
Throwable e = throwables.get(0); |
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
#!/usr/bin/env bash | |
FILESTORE_DIR="$1" | |
if [ -z "$FILESTORE_DIR" ]; then | |
FILESTORE_DIR="`pwd`/filestore" | |
fi | |
function install_artifact() { | |
IFS=':' read -a array <<< "$1" | |
GROUP_ID="${array[0]}" |
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
@Module(complete = false, library = true) | |
public class ProtocolModule { | |
@Provides | |
@Singleton | |
Executor provideExecutor(TaskExecutorImpl executor) { | |
return executor; | |
} | |
@Provides |
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
public static String toPath(String... names) { | |
StringBuilder sb = new StringBuilder(getCharCount(names) + names.length - 1); | |
for (String s : names) { | |
sb.append(s).append(File.separator); | |
} | |
if (sb.length() > 0) { | |
sb.deleteCharAt(sb.length() - 1); | |
} | |
return sb.toString(); | |
} |
NewerOlder