Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
/* * {
transition: all .5s;
} */
body { margin: 0; }
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style media="screen">
#container {
display: flex;
flex-direction: row;
}
local promise = require("promise")
local create, resume, status, await =
coroutine.create, coroutine.resume,
coroutine.status, coroutine.yield
local function async(fn)
return function(...)
local args = {..., n = select("#", ...)}
local co = create(fn)
@qoh
qoh / cats.js
Last active October 28, 2015 13:54
/// bind :: Monad m => m a -> (a -> m b) -> m b
let bind = a => f => a.bind(a)(f);
/// cont :: Monad m => m a -> m b -> m b
let cont = a => f => a.cont(a)(f);
/// id :: a -> a
let id = x => x;
/// compose :: (b -> c) -> (a -> b) -> a -> c
@qoh
qoh / bytes.cs
Last active October 27, 2015 13:44
if ($bytes_nextid $= "")
$bytes_nextid = 0;
if ($bytes_holes $= "")
$bytes_holes = 0;
function build_byte_table() {
$byte_chr_lookup = "";
for (%dec = 0; %dec < 256; %dec++) {
local function callsoon(func)
func()
end
local promise_mt = {}
local promise = {}
setmetatable(promise, promise_mt)
function promise_mt.__call(_, resolver)
local status, value
@qoh
qoh / sfx.lua
Created September 21, 2015 23:21
local footstep = sfx {
dynamic = {
files = {"step1s.wav", "step2s.wav"},
filter = su.distmax(32),
is3d = false,
isdynamic = true,
pitch = su.random(0.9, 1.1),
volume = su.lerp(su.unlerp(su.dist, 0, 32), 0, 1)
},
simple = {
@qoh
qoh / timers.lua
Last active September 20, 2015 21:47
-- usage:
-- timer(1000, function() print("hey") end)
if timerCount == nil then timerCount = 0 end
if timerTable == nil then timerTable = {} end
function finishTimer(i)
i = tonumber(i)
timerTable[i]()
timerTable[i] = nil
local function containerRayCast(a, b, mask, ...)
a = a[1] .. " " .. a[2] .. " " .. a[3]
b = b[1] .. " " .. b[2] .. " " .. b[3]
local result = con.containerRayCast(a, b, mask, ...)
if result == "0" then
return nil
end
class BytesReader(object):
def __init__(self, b):
self.bytes = b
self.cursor = 0
def read(self, n=None):
c = self.cursor
if n == None:
self.cursor = len(self.bytes)