Skip to content

Instantly share code, notes, and snippets.

View shelajev's full-sized avatar

Oleg Šelajev shelajev

View GitHub Profile
{
"Badge Text" : "",
"Custom Directory" : "No",
"Working Directory" : "\/Users\/shelajev",
"Prompt Before Closing 2" : 0,
"Selected Text Color" : {
"Green Component" : 0.94760049999999996,
"Red Component" : 0.94760049999999996,
"Blue Component" : 0.94760049999999996
},
public class Main {
public static void main(String[] args) {
GraalVM download = new GraalVM("ce", "21.1", "java11", "linux", "amd64");
var text = """
Get your favorite OpenJDK build with the GraalVM JIT compiler,
capable of native image technology,
polyglot support for JavaScript, Ruby, R, Python, Webassembly, etc
It's cool modern and all around wonderful!
Click here to download: %s!
""";
import org.graalvm.polyglot.*;
import org.graalvm.polyglot.Context.Builder;
import org.graalvm.polyglot.proxy.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
try (Context context = Context.newBuilder()
.allowAllAccess(true)
.build()) {
public class Main {
public static void main(String[] args) {
GraalVM download = new GraalVM("ce", "21.1", "java11", "linux", "amd64");
var text = """
Get your favorite OpenJDK build with the GraalVM JIT compiler,
capable of native image technology,
polyglot support for JavaScript, Ruby, R, Python, Webassembly, etc
import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream;
public class Main {
private static String filename = "fib1000";
static Stream<Long> fibonacciStream() {
return Stream.iterate(new long[]{1, 0}, (f) -> new long[]{f[0] + f[1], f[0]}).map(f -> f[0]);
}
public static void main(String[] args) throws Exception {
List<Long> fib1000 = fibonacciStream().limit(1000).collect(Collectors.toList());
package primes;
import io.micronaut.configuration.picocli.PicocliRunner;
import io.micronaut.context.ApplicationContext;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;
import javax.inject.*;
import java.util.*;
@Command(name = "primes", description = "...",
cob_procedure_params[0] = &f_8;
cob_procedure_params[1] = &f_9;
cob_procedure_params[2] = COB_SET_DATA (f_12, b_12);
cob_procedure_params[3] = COB_SET_DATA (f_13, b_13);
cob_procedure_params[4] = &f_10;
cob_procedure_params[5] = COB_SET_DATA (f_14, b_14);
cob_procedure_params[6] = &f_11;
cob_glob_ptr->cob_call_params = 7;
cob_glob_ptr->cob_stmt_exception = 0;
if (unlikely((cob_glob_ptr->cob_exception_code & 0x0b00) == 0x0b00)) cob_glob_ptr->cob_exception_code = 0;
IDENTIFICATION DIVISION.
PROGRAM-ID. KECCAK-Wrapper.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-KECCAK-RATE BINARY-LONG UNSIGNED.
01 WS-KECCAK-CAPACITY BINARY-LONG UNSIGNED.
struct __attribute__((packed)) KECCAK__Wrapper__struct_LNK_KECCAK {
unsigned int LNK_KECCAK_RATE;
unsigned int LNK_KECCAK_CAPACITY;
void *LNK_KECCAK_INPUT;
unsigned long LNK_KECCAK_INPUT_BYTE_LEN;
void *LNK_KECCAK_DELIMITED_SUFFIX;
void *LNK_KECCAK_OUTPUT;
unsigned long LNK_KECCAK_OUTPUT_BYTE_LEN;
};
POLYGLOT_DECLARE_STRUCT(KECCAK__Wrapper__struct_LNK_KECCAK)
COBCOPTS = -free -Q "-Wl,-rpath -Wl,$(MANAGED_LIBRARIES_PATH)/lib -Wl,-rpath -Wl,$(GRAALVM_LIBRARIES_PATH)"
# create dynamic library that can by loaded by Sulong
KECCAK.so: KECCAK.cob
cobc $(COBCOPTS) -m -fstatic-call -fno-gen-c-decl-static-call -G KECCAK-Wrapper-struct -lpolyglot-mock KECCAK.cob
TESTSHA3-256: TESTSHA3-256.cob KECCAK.so
cobc $(COBCOPTS) -x TESTSHA3-256.cob -lpolyglot-mock