View tree-on-list.js
/*
0 - [foo] [[0][]] time - Add empty folder /foo
1 - [foo,hello] [[1][1]] time meta - Add file /foo/hello
2 - [foo,goodbye] [[2][1,2]] time meta - Add file /foo/goodbye
3 - [foo,man] [[3][1,2,3][]] time - Add empty folder /foo/man
4 - [bar,baz] [[3,4][4]] time meta - Add file /bar/baz
5 - [bar,bit] [[3,5][4,5]] time meta - Add file /bar/bit
6 - [foo,hello] [[5,6][2,3]] time - Delete /foo/hello
View idb-dat-storage.js
/* eslint-env browser */
var Buffer = require('buffer').Buffer
var name = 'dat'
function withStore (type, block, callback) {
var req = indexedDB.open(name + '-db', 1)
req.onerror = () => callback(req.error)
req.onupgradeneeded = () => req.result.createObjectStore(name)
req.onsuccess = () => {
View beaker-update.sh
git fetch
git reset --hard origin/master
git clean -xdf
rm package-lock.json app/package-lock.json
npm install
npm run rebuild
npm start
View rainbow.js
import React, { Component } from 'react'
import { View } from 'react-native'
export default class FlexDimensionsBasics extends Component {
constructor (props) {
super(props)
this.state = {time: Date.now()}
// Toggle the state every second
setInterval(() => {
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