Skip to content

Instantly share code, notes, and snippets.

@klepto
klepto / Executor.java
Created September 14, 2016 16:03
Continuations implementation in Java using Thread Parking
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.locks.LockSupport;
/**
public void draw() {
GLES20.glEnable(GLES20.GL_STENCIL_TEST);
//Disable writing to the color and depth buffers: this is just for creating the stencil
GLES20.glColorMask(false, false, false, false);
GLES20.glDepthMask(false);
/*
GLES20.GL_NEVER: For every pixel, fail the stencil test (so we automatically overwrite the pixel's stencil buffer value)
1: write a '1' to the stencil buffer for every drawn pixel because glStencilOp has 'GLES20.GL_REPLACE'
@flanger001
flanger001 / zalgo.js
Created September 23, 2015 14:05
I stole a Zalgo text generator
/* <![CDATA[ */
//============================================================
// ZALGO text script by tchouky
//============================================================
// data set of leet unicode chars
//---------------------------------------------------
//those go UP
var zalgo_up = [
old syntax:
pgm0:(pgm |[] |[] |[] []
(inj []
(str "Hello World")
[SYNC_FRONT now 1 forever root nil]
)
(set [this.vw.act 0])
1) |[]
new syntax 1:
@jnorthrup
jnorthrup / Narsive.java
Created June 14, 2015 02:25
conceptual narsese grammar
package hacks;
import bbcursive.Cursive;
import bbcursive.std;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.*;
import java.util.concurrent.*;
public class CoroutineMain {
public static void main(String[] args) {
final Coroutine bob = new Coroutine() {
@Override
public void corun() throws InterruptedException {
count("Bob", this);
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.VirtualMachine;
import sun.tools.attach.HotSpotVirtualMachine;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
@bloodyowl
bloodyowl / gist:41b1de3388c626796eca
Last active April 20, 2020 03:27
es6 event-emitter
var DEFAULT_MAX_LISTENERS = 12
function error(message, ...args){
console.error.apply(console, [message].concat(args))
console.trace()
}
class EventEmitter {
constructor(){
this._maxListeners = DEFAULT_MAX_LISTENERS
@forax
forax / gist:e733e6af6114eff55149
Created June 1, 2014 16:13
Lispy interpreter written in Java
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toCollection;
import static java.util.stream.Collectors.toList;
import static java.util.stream.IntStream.range;
import static java.util.stream.Stream.concat;
import static java.util.stream.Stream.of;
import java.io.Console;
/*
The MIT License (MIT)
Copyright (c) 2014 François de Campredon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is