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/sh | |
# https://gist.github.com/onacit/036c93befff929a1f43b7603aa0b65bb | |
if [ $# -lt 3 ]; then | |
echo "Usage: $0 <tag> <tasks...>, e.g. $0 6.0.1-jdk11 -Pprofile=local clean build" | |
echo "See https://hub.docker.com/_/gradle for available tags" | |
exit 1 | |
fi | |
tag="$1" | |
shift | |
name=$(basename "$PWD") |
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/sh | |
# https://gist.github.com/onacit/9f79215aaf6bd8d59e78ed6a38b93889 | |
# https://stackoverflow.com/questions/3545292/how-to-get-maven-project-version-to-the-bash-command-line | |
if [ $# -lt 2 ]; then | |
echo "Usage: $0 <tag> <phases...>, e.g. $0 3-jdk-11-openj9 clean install" | |
echo "See https://hub.docker.com/_/maven for available tags" | |
exit 1 | |
fi | |
groupId=$(mvn help:evaluate -Dexpression=project.groupId | grep -v '\[') | |
artifactId=$(mvn help:evaluate -Dexpression=project.artifactId | grep -v '\[') |
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 p_0dd925d3768fcd4f79494ae32905dc1b; | |
import java.util.Comparator; | |
import java.util.List; | |
import static java.util.Objects.requireNonNull; | |
/** | |
* A class implements <a href="https://en.wikipedia.org/wiki/Selection_sort">Selection sort</a>. | |
* |
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.security.*; | |
import java.util.*; | |
import java.util.concurrent.atomic.*; | |
public class MontyHallProblem { | |
//private static final long COUNT = 1048576L; | |
private static final long COUNT = 30000L; | |
static { assert COUNT > 0L; } | |
private static final int DOORS = 3; | |
static { assert DOORS > 0; } | |
public static void main(final String... args) throws Exception { |
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.time.temporal.*; | |
public class ChronoUnitMatrix { | |
public static void main(final String... args) { | |
System.out.printf("%-10s%-6s%-6s%s\n", "name", "time", "date", | |
"duration (estimated) (seconds)"); | |
System.out.printf("%-10s%-6s%-6s%s\n", "---------", "-----", "-----", | |
"---------------------------------------------------------------"); | |
for (final ChronoUnit value : ChronoUnit.values()) { |
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.math.BigInteger; | |
public class Fibonacci { | |
public static void main(final String... args) { | |
final int n = Integer.parseInt(args[0]); | |
if (n < 0) { | |
throw new IllegalArgumentException("n(" + n + ") is negative"); | |
} | |
if (n == 0) { |
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
#include <assert.h> | |
#include <stdio.h> | |
/* | |
* 5.1.2.2.1 Program startup | |
* N1548 | |
*/ | |
int main(int argc, char *argv[]) { | |
// The value of argc shall be nonnegative. | |
assert(argc >= 0); |
NewerOlder