let A and B be polygons
let a and b be vectors representing the movement of said polygons within a game tick
let c be the movement of A relative to B a-b
calculate the transformation matrix Ta that transforms c into the vector (1, 0)
#!/bin/bash | |
# This script installs OpenResty on an ubuntu-like system. | |
if [ "$(id -u)" -ne 0 ] | |
then | |
echo 'must run as root 😖' | |
exit | |
fi | |
umask a+rx |
This small benchmark test compares the performance of using `ipairs{...}` vs. | |
`select('#',<n>)` to iterate over the arguments inside a variadic function. |
<!doctype html> | |
<!-- Set type to one of "full", "all" or "selective" --> | |
<fun-matrix type="selective"> | |
</fun-matrix> | |
<script type="module"> | |
import {html} from "https://darkwiiplayer.github.io/js/skooma.js" | |
import element from "https://darkwiiplayer.github.io/js/element.js" |
local based = require 'based.32.crockford' | |
local basexx = require 'basexx' | |
local function bench(name, fn, vector) | |
local before = os.clock() | |
for _, input in ipairs(vector) do | |
fn(input) | |
end | |
local after = os.clock() | |
print(string.format("%-10s %1.6f seconds", name..":", after-before)) |
local times = 100000 | |
local start = os.clock() | |
for i=1,times do | |
local closure = function() | |
print("test") | |
end | |
end | |
print(os.clock() - start) |
values = Symbol("values") | |
hijack = (object, callbacks) => { | |
const val = object[values] ||= Object.create(null) | |
Object.entries(callbacks).forEach(([key, callback]) => { | |
Object.defineProperty(object, key, { | |
get() { return val[key] }, | |
set(value) { | |
callback(value) | |
val[key] = value | |
return true |
height = 20 | |
width = 100 | |
split = 6/10 | |
tag = (number, color='#ea316e') -> | |
buf = require'strbuffer'! | |
generator = require'moonxml'.xml -> | |
svg { | |
xmlns: 'http://www.w3.org/2000/svg' | |
:width |
local function locals(n) | |
n = n + 1 | |
local result = {} | |
for i=1,math.huge do | |
name, value = debug.getlocal(n, i) | |
if not name then break end | |
result[name] = {value} | |
end | |
return result | |
end |
<script type="module"> | |
import {Better} from "/better.js" | |
class ConstantInterval extends Better { | |
#timer | |
static attributes = { | |
interval: { get: Number }, | |
onTick: { | |
get: Function, | |
set: e => `(${e.toString()})()` |