Skip to content

Instantly share code, notes, and snippets.

Avatar

Tim Caswell creationix

View GitHub Profile
View shoe-shelf.scad
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
View lock2.js
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);
}));
}
View lock.js
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 = () => {
View dome-swing.scad
// 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;
View main.js
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';
View hextile.scad
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],
@creationix
creationix / block-profile.svg
Last active Mar 24, 2020
Block Raised Garden
View block-profile.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View gamepad.txt
____________________________ __
/ [__ZL__] [__ZR__] \ |
/ [__ TL __] [__ TR __] \ | Front Triggers
__/________________________________\__ __|
/ _ \ |
/ /\ __ (N) \ |
/ || __ |MO| __ _ _ \ | Main Pad
| <===DP===> |SE| |ST| (W) -|- (E) | |
\ || ___ ___ _ / |
/\ \/ / \ / \ (S) /\ __|
@creationix
creationix / add.wat
Created Jan 15, 2020
Zig to wasm supports tiny modules.
View add.wat
(module
(type (;0;) (func (param i32 i32) (result i32)))
(func $add (type 0) (param i32 i32) (result i32)
local.get 1
local.get 0
i32.add)
(table (;0;) 1 1 funcref)
(memory (;0;) 2)
(global (;0;) (mut i32) (i32.const 66560))
(export "memory" (memory 0))
@creationix
creationix / asusevent.zig
Last active Jan 13, 2020
Reading Asus bluetooth gamepad events in zig.
View asusevent.zig
const std = @import("std");
const File = std.fs.File;
const InputEvent = packed struct {
sec: u64,
usec: u64,
type: u16,
code: u16,
value: i32,
};
You can’t perform that action at this time.