Skip to content

Instantly share code, notes, and snippets.

@forax
forax / Constantifier.java
Created January 12, 2018 17:33
How to simulate @stable semantics with method handles ?
import static java.lang.invoke.MethodHandles.constant;
import static java.lang.invoke.MethodHandles.dropArguments;
import static java.lang.invoke.MethodHandles.exactInvoker;
import static java.lang.invoke.MethodHandles.foldArguments;
import static java.lang.invoke.MethodHandles.lookup;
import static java.lang.invoke.MethodType.methodType;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
@sortie
sortie / which_os.c
Created October 15, 2017 23:04
Detect the operating system using UDP stack corner cases
#include <sys/socket.h>
#include <err.h>
#include <errno.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
int main(void)
{
@apangin
apangin / JDK 9 intrinsics
Last active May 11, 2023 18:32
JDK 9 intrinsics
_hashCode java/lang/Object.hashCode()I
_getClass java/lang/Object.getClass()Ljava/lang/Class;
_clone java/lang/Object.clone()Ljava/lang/Object;
_notify java/lang/Object.notify()V
_notifyAll java/lang/Object.notifyAll()V
_dabs java/lang/Math.abs(D)D
_dsin java/lang/Math.sin(D)D
_dcos java/lang/Math.cos(D)D
_dtan java/lang/Math.tan(D)D
_datan2 java/lang/Math.atan2(DD)D
@elizarov
elizarov / StackComputation.kt
Last active September 2, 2020 14:19
Using coroutines to avoid StackOverflowException on recursive calls
import kotlin.coroutines.experimental.*
import kotlin.coroutines.experimental.intrinsics.COROUTINE_SUSPENDED
import kotlin.coroutines.experimental.intrinsics.suspendCoroutineOrReturn
@RestrictsSuspension
abstract class StackComputation {
abstract suspend fun <T> push(block: suspend StackComputation.() -> T): T
}
fun <T> compute(block: suspend StackComputation.() -> T): T =
@viktorklang
viktorklang / gist:1b3032e46afc9abd400a
Last active October 13, 2017 16:43 — forked from debasishg/gist:8172796
A collection of links for streaming algorithms and data structures
  1. General Background and Overview