Skip to content

Instantly share code, notes, and snippets.

Tim Caswell creationix

Block or report user

Report or block creationix

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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,
};
View jack-edit.md

AST driven development

Visually described as textual code when needed, but aimed as graphical code for mobile touch or spatial 3d environments.

Expressions

If-Else

The first expression type matches traditional if..else or a ? : b.

@creationix
creationix / sample.txt
Last active Nov 1, 2019
Simple conversions between utf8 Uint8Arrays and strings with surrogate pairs.
View sample.txt
◢□■□■□■□■□■□◣
🔆 Emojis 📶
◥□■□■□■□■□■□◤
◖■□■□■□■□■□■□■□■□■□■□■□■◗
😃 😄 🤠 😎 👿 💩
🤡 👹 👺 👻 👽 👾 🤖
🌉 🌐 😺 😾 🦊 😀
◖■□■□■□■□■□■□■□■□■□■□■□■◗
╓──────────────╖
View keybase.md

Keybase proof

I hereby claim:

  • I am creationix on github.
  • I am creationix (https://keybase.io/creationix) on keybase.
  • I have a public key ASCtY8gVs6Hlo3rd9hXsvika7KjrSnnjhGId1V8Ey1HELgo

To claim this, I am signing this object:

@creationix
creationix / rpc.md
Last active Jan 13, 2020
Simple RPC design
View rpc.md

I've designed a lot of RPC protocols in my career. One pattern that's worked well basically goes as follows:

// Client calls: print('Hello World\n')
-> [1, "print", "Hello World!\n"]
// Server sends return value (or lack of return vvalue)
<- [-1]

// Client calls: add(1, 2)
-> [2, "add", 1, 2]
View gimli-core.lua
local ffi = require 'ffi'
local bit = require 'bit'
local bxor = bit.bxor
local rol = bit.rol
local lshift = bit.lshift
local band = bit.band
local bor = bit.bor
local function gimli(state)
for round = 24,1,-1 do
View circle.js
var neopixel = require("neopixel");
var pin = D14;
var count = 16*16;
var pixels = new Uint8Array(count * 3);
function rgb(o, r, g, b) {
pixels[o] = g;
pixels[o + 1] = r;
pixels[o + 2] = b;
View jack-shelf.scad
//92
//64
//3
//9.25
//7.25
//14
// Fence posts
%cube([3, 4, 64]);
%translate([94.8,0,0])
@creationix
creationix / yggdrasil.conf
Created Dec 20, 2018
Upstart service for Yggdrasil
View yggdrasil.conf
description "Yggdrasil VPN"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
umask 022
You can’t perform that action at this time.