Skip to content

Instantly share code, notes, and snippets.

View creationix's full-sized avatar
💚
<3

Tim Caswell creationix

💚
<3
View GitHub Profile
../bench/corgis/website/datasets/json/tate/tate.json (2.60 MiB)
Action Duration Used Kept Output
cjson_resty.decode 38.9ms 3.87 MiB 3.63 MiB table: 0x419b8440
Tibs.decode 42.1ms 2.95 MiB 2.91 MiB table: 0x4209dad8
cjson_resty.encode 13.2ms 1.88 MiB 1.88 MiB string: 1.88 MiB
Tibs.encode 48.3ms 8.24 MiB 1.97 MiB string: 1.84 MiB
encoded sizes mismatch: 1968571 1933719
cjson_resty = "data":{"url":"http:\/\/www.tate.org.uk\/
do
-- Polyfill for luajit without __pairs and __ipairs extensions
local triggered = false
pairs(setmetatable({}, { __pairs = function()
triggered = true
return function() end
end }))
if not triggered then
print "Polyfilling pairs"
function _G.pairs(t)
@creationix
creationix / Dockerfile
Last active November 14, 2022 22:16
Build luvit from source using alpine docker
FROM alpine AS build-luv
RUN apk add build-base cmake git
RUN git clone --recursive https://github.com/luvit/luvi.git
RUN make -C luvi/deps/luv
FROM alpine AS build-luvi
RUN apk add build-base cmake git
RUN git clone --recursive https://github.com/luvit/luvi.git
RUN apk add perl linux-headers
RUN make -C luvi regular-asm
--- xxHash
--- https://github.com/Cyan4973/xxHash/blob/dev/doc/xxhash_spec.md#xxh32-algorithm-description
local bit = require 'bit'
local rshift = bit.rshift
local rol = bit.rol
local bxor = bit.bxor
local tobit = bit.tobit
local ffi = require 'ffi'
local bit = require 'bit'
local bxor = bit.bxor
local rol = bit.rol
local lshift = bit.lshift
local band = bit.band
local bor = bit.bor
local function gimli(state)
for round = 24, 1, -1 do
for column = 0, 3, 1 do
count=9;
h=100;
r=27;
s=4;
g=1.1;
w=(r+s)*(count+1)+s*2;
echo(w);
d=(r+s)*(2+2*sin(60))+s*2;
// ESC := "^"
ESC := "\x1b"
WIDTH := 33
HEIGHT := 32
FPS := 120
SIZE := WIDTH * HEIGHT
pixels := ByteArray(SIZE)
dirty_x1 := 0
dirty_y1 := 0
var Neopixel = require('neopixel');
var data = new Uint8Array(4*12);
function hue(p, h, l) {
h = h % 0x600;
var r, g, b;
if (h < 0x100) { r = 0xff; g = h; b = 0; }
else if (h < 0x200) { r = 0x1ff - h; g = 0xff; b = 0; }
/* types
Button - represents a GPIO pin hooked to a button
Neopixel - represents a GPIO pin hooked to neopixels
Strip - represents a memory buffer for 1d array of colors
Grid - represents a memory buffer for a 2d array of colors
Position1d - represents a bounded 2D coordinate
Position2d - represents a bounded 2D coordinate
Interval - represents a clock 33345rtfv ith a given frequency
Schedule - represents a schedule to alarm at given times
Color - represents a 24 bit RGB color
var WIDTH = 10
var HEIGHT = 10
// 0 is null, pointers start at 1
const SIZE = WIDTH * HEIGHT
var set = new Uint16Array(SIZE)
// return end of chain
function walk(a) {
while (set[a - 1]) {
a = set[a - 1]