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
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 Sep 20, 2019
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
View jack-v2.txt
integer literals
1 -- integer
-5 -- integer
rational literals
1/4 -- rational
3.141 -- rational (syntax sugar for 3141/1000)
@creationix
creationix / hyperdrive-serviceworker.js
Last active Oct 14, 2017
WIP service worker that serves a dat as http responses.
View hyperdrive-serviceworker.js
/* eslint-env serviceworker */
/* global fetch, ReadableStream, Response */
// Tweak so internal crypto stuff can find `window.crypto`
window = self
const hyperdrive = require('hyperdrive')
const websocket = require('websocket-stream')
const ram = require('random-access-memory')
const { E, M } = require('promisey')
View nativescript-file-system-example
var fileSystemModule = require("file-system");
var fileName = "persistedFile.json";
var file = fileSystemModule.knownFolders.documents().getFile(fileName);
var data = [{"id": "1", "value": "NativeScript"}, ...];
// write data to the file, converted to a JSON string first
file.writeText(JSON.stringify(data));
// read data from the file
View blake2b.js
async function setup() {
// In node, this will use the polyfill and read the file from disk using `fs.readFile('blake2b.wasm', ...)`
// But in the browser, it will make an HTTP fetch request to `GET blake2b.wasm`!
let res = await fetch('blake2b.wasm')
let buf = await res.arrayBuffer()
let mod = await WebAssembly.instantiate(buf))
// ...
}
You can’t perform that action at this time.