Skip to content

Instantly share code, notes, and snippets.


David Konsumer konsumer

View GitHub Profile
konsumer / example.js
Last active March 17, 2023 23:58
This will give you a nice clean list of wasm imports/exports which is useful for making minimal wasm-loaders.
View example.js
import getWasmInterface from './get_wasm_interface.js'
// usage
const bytes = await fetch('mine.wasm').then(r => r.arrayBuffer())
const m = await WebAssembly.compile(bytes)
// imports is minimal stub (empty functions) and exports is a list of things it exports
const { imports } = await getWasmInterface(m)
// now I can inject my own functions
konsumer / Makefile
Created January 27, 2023 23:45
Self-help for a Makefile in a python project
View Makefile
.PHONY: help clean
help: ## Show this help
@python tools/ "$(MAKEFILE_LIST)"
clean: ## Remove all built files
@rm -f FILES
konsumer /
Last active October 10, 2022 04:54
Install Kali on GPI2
konsumer /
Created June 3, 2022 01:01
make a debian-based os image and chroot for arm (run in arm64 qemu)
#!/bin/bash -e
apt install -y build-essential debootstrap unzip git
# create image
qemu-img create -f qcow2 -o preallocation=metadata rknullos.qcow2 2G
modprobe nbd max_part=8
qemu-nbd --connect=/dev/nbd0 rknullos.qcow2
# paritition

Building raylib app in docker (on another computer) for ArkOS RG351V

I am using a mac M1 (arm64), so I didn't need binfmt-support/qemu-user-static installed.

docker run --platform="linux/arm64/v8" -it --rm -v $(pwd):/workdir -w /workdir ubuntu:eoan bash

cat << EOF > /etc/apt/sources.list
deb eoan main universe
deb eoan-updates main universe
konsumer / btoa.js
Last active January 29, 2022 03:01
Node implementation for btoa/atob to do base64 like in the browser/cloudflare-worker.
View btoa.js
if (typeof atob === 'undefined') {
var atob = a => new Buffer(a).toString('base64')
if (typeof btoa === 'undefined') {
var btoa = a => Buffer.from(a, 'base64').toString('utf8')
import serial
port = serial.Serial('/dev/ttyTHS1', baudrate=115200, timeout=1)
# Turn on the GPS
# Ask for the navigation info parsed from NMEA sentences
konsumer / generate-raylib.js
Created October 26, 2021 10:57
Start of little quickjs program that will generate a native quickjs wrapper for raylib
View generate-raylib.js
import { loadFile } from 'std'
const regexes = {
func: /^RLAPI ([\*A-Za-z0-9 ]+) ([\*A-Za-z0-9]+)\((.+)\);\W+(.+)/gm
// TODO: I need a lot more in/out types
// map of input-type to function that the function-body to convert it
const inputTypes = {
konsumer / mdn_canvas.js
Created September 14, 2021 09:47
Generate JSOn from MDN docs
View mdn_canvas.js
// I use this to generate a stub from MDN docs about canvas
// run with deno run --allow-net tools/getdocs.js
/* global fetch */
import { DOMParser } from ''
function getDocs (doc, parent) {
const info = {}
if (doc?.querySelectorAll) {
if (! whiptail --title "Proton GE Setup" --yesno "This tool assumes you are running ubuntu/pop/etc 20.10. Are you?" 8 78); then
echo "Run it again, when you get a cool OS. 😂"
exit 1
if (whiptail --title "Proton GE Setup" --yesno "What kind of video card do you have, gamer?" 8 78 --no-button "AMD" --yes-button "NVidia"); then