Skip to content

Instantly share code, notes, and snippets.

View shelajev's full-sized avatar

Oleg Šelajev shelajev

View GitHub Profile
function lowUsage() {
for (i = 0; i < COMPILATION_THRESHOLD; i++) {
// Do something
}
}
function highUsage() {
for (i = 0; i < 100 * COMPILATION_THRESHOLD; i++) {
// Do something
}
@shelajev
shelajev / Example.java
Created July 19, 2021 13:08
Example of using a JFR event from Java code
import jdk.jfr.Event;
import jdk.jfr.Description;
import jdk.jfr.Label;
public class Example {
@Label("Hello World")
@Description("Helps programmer getting started")
static class HelloWorld extends Event {
@Label("Message")
{
"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.