Skip to content

Instantly share code, notes, and snippets.

View shelajev's full-sized avatar

Oleg Šelajev shelajev

View GitHub Profile
View ci.go
package main
import (
"context"
"fmt"
"os"
"dagger.io/dagger"
)
View payara.java
// Here's the network where both containers will join
static final Network NET = Network.newNetwork();
// The database container will join the network under the 'mysql' alias
@Container
static MySQLContainer dbContainer =
new MySQLContainer<>(DockerImageName.parse("mysql:8.0"))
.withNetwork(NET)
.withNetworkAliases("mysql");
View FibonacciController.java
package com.example;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import java.util.HashMap;
import java.util.Map;
@Controller("/")
public class FibonacciController {
View FibonacciController.java
package com.example;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
@Controller("/")
public class FibonacciController {
private static final StringBuilder LOG = new StringBuilder();
View correlate-pseudo.java
public static double correlate(double[] a, double[] b) {
if (a.length != b.length) {
return Double.NaN;
}
double <w,x,y,z> = <0,0,0,0>;
int i = 0;
for ( ; i + 3 < a.length; i += 4) {
<w,x,y,z> += a[<i,i+1,i+2,i+3>] * b[<i,i+1,i+2,i+3>];
}
double correlation = w + x + y + z;
View correlate.java
public static double correlate(double[] a, double[] b) {
if (a.length != b.length) {
return Double.NaN;
}
double partial[] = new double[4];
int i = 0;
for ( ; i + 3 < a.length; i += 4) {
partial[0] += a[i+0] * b[i+0];
partial[1] += a[i+1] * b[i+1];
partial[2] += a[i+2] * b[i+2];
View SignalCorrelation.java
class SignalCorrelation {
/** Approximate {@code sin(i / 1000)}. */
public static double sin(int i) {
double x = i / 1000.0;
double term3 = (x*x*x) / (3 * 2 * 1);
double term5 = (x*x*x*x*x) / (5 * 4 * 3 * 2 * 1);
return x - term3 + term5;
}
View pseudocode.java
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
View Example.java
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")
View iterm-profile.json
{
"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
},