This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local tableview = require 'tableview' | |
local pegasus = require 'pegasus' | |
local print = function(...) | |
print(...) | |
io.stdout:flush() | |
end | |
local function serve(tab) | |
local server = pegasus:new { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local fun = require 'fun' () | |
local function avg(...) | |
local sum, count = 0, 0 | |
for i=1,select('#', ...) do | |
count = count + 1 | |
sum = sum + select(i, ...) | |
end | |
return sum / count | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let template = document.createElement("template") | |
template.innerHTML = ` | |
<svg> | |
<defs> | |
<filter id="zoom"> | |
<feTurbulence type="turbulence" baseFrequency="0.05" numOctaves="2" /> | |
<feGaussianBlur in="distorted" stdDeviation="2" result="turbulence" /> | |
<feDisplacementMap in2="turbulence" in="SourceGraphic" scale="10" xChannelSelector="R" yChannelSelector="G" result="distorted"/> | |
<feGaussianBlur in="distorted" stdDeviation="2" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function time(times, fn) | |
local before = os.clock() | |
for i=1,times do | |
fn() | |
end | |
local after = os.clock() | |
return after - before | |
end | |
local function bench(name, times, fn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local t = setmetatable({}, {__name="foobar"}) | |
print(type(t)) --> foobar | |
print(rawtype(t)) --> table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- Resolves a missing key in a table to one of its mixins (in order) | |
local function resolve(tab, key) | |
local mt = getmetatable(tab) | |
for i=mt.mixins,0,-1 do | |
if mt[i][key] then | |
return mt[i][key] | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setup(root) { | |
root.parts = {} | |
root.querySelectorAll("[part-id]").forEach( element => { | |
root.parts[element.getAttribute("part-id")] = element | |
}) | |
root.clone = function() { return setup(this.cloneNode(true)) } | |
return root | |
} | |
function template(strings, ...args) { |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
form { display: flex; flex-flow: column } | |
</style> | |
<form> | |
<input type="range" min="0" max="100" value="100" id="value"> | |
<input type="range" min="0" max="100" value="100" id="modulus"> | |
<input type="range" min="0" max="100" value="100" id="modulo" disabled> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local lpeg = require 'lpeg' | |
local function loader(name, version) | |
local version = table.concat(version, "_") | |
return function(module) | |
return require(module:gsub("[^.]*", function(original) | |
return original .. "." .. version | |
end)) | |
end | |
end |