Skip to content

Instantly share code, notes, and snippets.

Avatar
💚
<3

Tim Caswell creationix

💚
<3
View GitHub Profile
View main.zig
const std = @import("std");
fn AutoMap(comptime BLOCK_POWER: comptime_int) type {
return struct {
const BLOCK_SIZE = 2 << (BLOCK_POWER - 1);
const HASH_SIZE = 2 << (HASH_POWER - 1);
const BRANCH_POWER = std.math.log2(@sizeOf(Leaf) / @sizeOf(*Node));
const BRANCH_FACTOR = 2 << (BRANCH_POWER - 1);
const Hash = u256;
const Block = [BLOCK_SIZE]u8;
View async-wasm.zig
extern fn slowAddJS(a: u32, b: u32, frame: *@Frame(slowAdd)) void;
var addResult: u32 = 0;
export fn onSlowAdd(frame: *@Frame(slowAdd), result: u32) void {
addResult = result;
resume frame;
}
View interface.h
#include <stdint.h>
#include <unistd.h>
typedef struct {
uint8_t* ptr;
size_t len;
} slice_t;
typedef struct {
slice_t* ptr;
View lib.zig
extern fn wsSendText(client: *Client, message: CSlice(u8)) void;
extern fn wsSendBInary(client: *Client, message: CSlice(u8)) void;
extern fn wsClose(client: *Client) void;
fn CSlice(comptime T: type) type {
return extern struct {
ptr: [*]const T,
len: usize,
pub fn fromSlice(slice: []const T) CSlice(T) {
View kitchen-table.scad
// 84 x 44
// 26.5 - 31 height
// https://www.ana-white.com/woodworking-projects/modern-farm-table
// 2x6 legs
// 2x2 supports
// 2x4 side aprons
View kitchen-remodel.scad
color("#aaaaaa") {
// Fridge
translate([0,-1.5,0]) cube([32,36,70]);
// Dishwasher
translate([0,36,0]) cube([24,24,34.5]);
// Sink
translate([27+1.5,36+21+25.9,36.05-10]) cube([33,16,10]);
// Stove
translate([24+3+36+24,36+21+24+3-1,0]) union() {
cube([30,25,36]);
View rainbowloop.js
// 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++) {
View rainbowstick.js
// 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++) {
View studio-wall.scad
//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]);
View add-empty-folders.lua
-- 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)