Skip to content

Instantly share code, notes, and snippets.

View creationix's full-sized avatar
💚
<3

Tim Caswell creationix

💚
<3
View GitHub Profile
// espruino + 16 GRB Neopixels on a loop
var neopixel = require('neopixel');
var pixels = new Uint8Array(16*3);
var j = 0;
setInterval(function () {
j = (j + 17) % 768;
var o = 0;
for (var i = 0; i < 16; i++) {
// espruino + 8 GRBW Neopixels on a stick
var neopixel = require('neopixel');
var pixels = new Uint8Array(8*4+1);
var j = 0;
setInterval(function () {
j = (j + 17) % 768;
var o = 0;
for (var i = 0; i < 8; i++) {
//for(i=[16:16:156]) {
//#translate([i-.75,0,1.5]) cube([1.5,5.5,93]);
//}
//#translate([0,5.5,0])cube([156,6.5,8*12]);
// top and bottom boards
translate([0,0,94.5]) cube([12*8,5.5,1.5]);
translate([12*8,0,94.5]) cube([156-12*8,5.5,1.5]);
translate([0,0,0]) cube([58,5.5,1.5]);
-- Using luvit.io and https://github.com/creationix/lua-git
local makeChroot = require('coro-fs').chroot
local mount = require('git').mount
coroutine.wrap(function ()
local db = mount(makeChroot(".git"))
local head = db.getHead()
local commit = db.loadAs("commit", head)
w = 3;
h = 4;
thick=19/32; // Thickness of plywood.
lift = 4+1/32;
//lift = height-(h+1)*thick-h*vspace;
width = 12*w; // outer width of shelves
hspace = (width-(thick*(w+1)))/w;
vspace = 12;
height = lift + thick*(h+1)+vspace*h; // outer height of shelves.
deep = 19.5; // depth of shelves
const locks = {};
async function protect(fn, name, ...args) {
while (locks[name]) await locks[name]
return (locks[name] = new Promise(async (resolve) => {
const ret = await fn(name, ...args);
delete locks[name];
resolve(ret);
}));
}
const locks = {};
/**
* @param {string} name the thing we want to have access to
*/
async function getLock(name) {
while (locks[name]) await locks[name]
let release;
locks[name] = new Promise(resolve => {
release = () => {
// For golden ratio rectangles
phi = (1 + sqrt(5)) / 2;
echo("phi",phi);
// dihedral angle of icosahedron
dih = acos(sqrt(5) / -3);
echo("dih",dih);
model="low_poly_person_by_Rochus.stl";
modelHeight=14.274;
import 'magic-script-polyfills';
import lumin from 'lumin';
import uv from 'uv';
import ssl from 'ssl';
import egl from 'egl';
import gl from 'gl';
import png from 'png';
import jpeg from 'jpeg';
a = cos(60);
b = sin(60);
z = 0.25; // inset to connections, larger is looser. 0.2
w = 7;
hex_tile = [
[(-1+z)*a,(2*w-1-z)*b],
[w+(-1-z)*a,(2*w-1-z)*b],
[w+(-2)*a,(2*w-2)*b],
[w-z-1+(-2)*a,(2*w-2)*b],
[w-1+(w-2-z)*a,(w-2-z)*b],