Skip to content

Instantly share code, notes, and snippets.

View creationix's full-sized avatar
πŸ’š
<3

Tim Caswell creationix

πŸ’š
<3
View GitHub Profile
@creationix
creationix / block-profile.svg
Last active March 24, 2020 15:06
Block Raised Garden
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@creationix
creationix / gamepad.txt
Created January 24, 2020 15:32
Gamepad Areas
____________________________ __
/ [__ZL__] [__ZR__] \ |
/ [__ TL __] [__ TR __] \ | Front Triggers
__/________________________________\__ __|
/ _ \ |
/ /\ __ (N) \ |
/ || __ |MO| __ _ _ \ | Main Pad
| <===DP===> |SE| |ST| (W) -|- (E) | |
\ || ___ ___ _ / |
/\ \/ / \ / \ (S) /\ __|
@creationix
creationix / add.wat
Created January 15, 2020 05:54
Zig to wasm supports tiny modules.
(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 January 13, 2020 17:03
Reading Asus bluetooth gamepad events in zig.
const std = @import("std");
const File = std.fs.File;
const InputEvent = packed struct {
sec: u64,
usec: u64,
type: u16,
code: u16,
value: i32,
};

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 November 1, 2019 13:03
Simple conversions between utf8 Uint8Arrays and strings with surrogate pairs.
β—’β–‘β– β–‘β– β–‘β– β–‘β– β–‘β– β–‘β—£
πŸ”† Emojis πŸ“Ά
β—₯β–‘β– β–‘β– β–‘β– β–‘β– β–‘β– β–‘β—€
β—–β– β–‘β– β–‘β– β–‘β– β–‘β– β–‘β– β–‘β– β–‘β– β–‘β– β–‘β– β–‘β– β–‘β– β——
πŸ˜ƒ πŸ˜„ 🀠 😎 πŸ‘Ώ πŸ’©
🀑 πŸ‘Ή πŸ‘Ί πŸ‘» πŸ‘½ πŸ‘Ύ πŸ€–
πŸŒ‰ 🌐 😺 😾 🦊 πŸ˜€
β—–β– β–‘β– β–‘β– β–‘β– β–‘β– β–‘β– β–‘β– β–‘β– β–‘β– β–‘β– β–‘β– β–‘β– β——
╓──────────────╖
@creationix
creationix / keybase.md
Created September 19, 2019 12:32
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 February 24, 2025 13:48
Simple RPC design

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]
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
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;