Skip to content

Instantly share code, notes, and snippets.

View dominictarr's full-sized avatar

Dominic Tarr dominictarr

View GitHub Profile
@dominictarr
dominictarr / await.js
Last active November 17, 2023 03:43
wasm zig async example
const fs = require('fs');
const source = fs.readFileSync("./await2.wasm");
const typedArray = new Uint8Array(source);
;(async function () {
var callback, frame
var buffer = Buffer.from("hello world!!!\n")
var result = await WebAssembly.instantiate(typedArray, {
env: {
print: function (ptr, len) {
<canvas width=800 height=600></canvas>
<script>
var id
var mem = new Uint8ClampedArray(1024*1024 * 4)
function resize () {
canvas.width = window.innerWidth
canvas.height = window.innerHeight
id = new ImageData(mem.slice(0, canvas.width*canvas.height*4), canvas.width, canvas.height)
<canvas width=800 height=600></canvas>
<script>
var id
var mem = new Uint8ClampedArray(1024*1024 * 4)
function resize () {
canvas.width = window.innerWidth
canvas.height = window.innerHeight
id = new ImageData(mem.slice(0, canvas.width*canvas.height*4), canvas.width, canvas.height)
(module
(func (export "foo") (param $foo i32) (result i32)
(local $x i32)
;;if blocks (if, block, loop, etc) have a (result x) then they return a value!
(if (result i32) (local.get $foo)
(if (result i32)
(i32.gt_s (local.get $foo) (i32.const 10))
(i32.const 10)
(block (result i32) (i32.const 1))
)
(module
(def ints (import "acid-ints"))
(def mem (import "acid-memory"))
(def strings (import "acid-strings"))
(def read_request (system "system" "read_request" (id start bytes)))
(def write_ready (system "system" "write_ready" (id start bytes)))
(def open_request (system "system" "open_request" (id start bytes)))
;;HACK: global in main mem, TODO global vars
(module
(def strings (import "./strings"))
(def _match (mac R (str i) (block
(def len (strings.length str))
(if (eq i (sub len 1))
&(if (eq (strings.at input (add start $i)) $(strings.at str i)) len -1)
&(if (eq (strings.at input (add start $i)) $(strings.at str i))
(R $str $(add 1 i)) -1)
)
(module
;; an operation defined inside a macro
(def op_mac (mac (a b) (block
&[i32_load (mod a 1000)]
)))
;;a function that contains that macro
(def op_fun (fun (a b) (op_mac a b) ))
(def N 10000000)
@dominictarr
dominictarr / aggregate-help.js
Created December 2, 2019 08:12
aggregate muxrpc-usage help
module.exports = function (sbot, cb) {
var help = null
sbot.help(function (err, data) {
if(!data.type) data.type = 'group'
help = data
var keys = Object.keys(sbot)
var n = keys.length + 1
keys.forEach(function (key) {
if(sbot[key] && 'function' === typeof sbot[key].help)
sbot[key].help(function (err, data) {
@dominictarr
dominictarr / readme.md
Created November 26, 2018 22:39
statement on event-stream compromise

Hey everyone - this is not just a one off thing, there are likely to be many other modules in your dependency trees that are now a burden to their authors. I didn't create this code for altruistic motivations, I created it for fun. I was learning, and learning is fun. I gave it away because it was easy to do so, and because sharing helps learning too. I think most of the small modules on npm were created for reasons like this. However, that was a long time ago. I've since moved on from this module and moved on from that thing too and in the process of moving on from that as well. I've written way better modules than this, the internet just hasn't fully caught up.

@broros

otherwise why would he hand over a popular package to a stranger?

If it's not fun anymore, you get literally nothing from maintaining a popular package.

One time, I was working as a dishwasher in a restu