View fake-hypercore.js
// Fake hypercore feed for testing and learning
var values = []
var feed = {
append (value, cb) {
console.log('APPEND', {value, cb})
values.push(value)
nextTick(cb)
},
get (index, options, cb) {
console.log('GET', {index, options, cb})
View coroutine-fengari.js
// Import some stuff from fengari
global.WEB = false
const {
lua: {
lua_pushnil,
lua_tointeger,
lua_touserdata,
lua_atnativeerror,
lua_yield,
lua_resume,
View coroutine-fengari.js
// Import some stuff from fengari
global.WEB = false
const {
lua: {
lua_tointeger,
lua_touserdata,
lua_atnativeerror,
lua_yield,
lua_resume,
lua_pushjsfunction,
View watercooler.js
SPI2.setup({baud:3200000,mosi:B15});
var count = 150;
var pixels = new Uint8Array(count * 3);
function update() {
SPI2.send4bit(pixels, 0b0001, 0b0011);
}
function dampen(p) {
var i = (p % count) * 3;
pixels[i]>>>=1;
View secure-redirect.lua
require('weblit-app')
-- Listen on port 80 without encryption
.bind {host = "0.0.0.0", port = 80 }
-- Listen on port 443 with encryption
.bind {host = "0.0.0.0", port = 443, tls = {
cert = module:load("cert.pem"),
key = module:load("key.pem")
View imperial.lua
-- Use Euclids algorithm to find gcd
-- m and n need to be positive integers, m must be larger.
local function gcd(m, n)
while n > 0 do
m, n = n, m % n
end
return m
end
View hexycoop.scad
module timber(l=8*12) {
linear_extrude(l)
polygon([
[.5,0],[3,0],
[3.5,1.75],
[3,3.5],[.5,3.5],
[0,1.75]]);
}
module timberr(x,y,z,r,o) {
View hexycoop.scad
module timber(l=8*12) {
linear_extrude(l)
polygon([
[.5,0],[3,0],
[3.5,1.75],
[3,3.5],[.5,3.5],
[0,1.75]]);
}
module timberr(x,y,z,r,o) {
rotate([0,0,r-90])
View promise-run.js
function run(iterator) {
return new Promise((resolve, reject) => {
var error, value, done;
next();
function next() {
while (!done) {
View storage.md

Level DB Style

This is highly influenced by https://github.com/google/leveldb#features

  • Keys and values are arbitrary byte arrays.
  • Data is stored sorted by key.
  • Callers can provide a custom comparison function to override the sort order.
  • The basic operations are Put(key,value), Get(key), Delete(key).
  • Multiple changes can be made in one atomic batch.
  • Users can create a transient snapshot to get a consistent view of data.