Skip to content

Instantly share code, notes, and snippets.

Avatar

David Konsumer konsumer

View GitHub Profile
@konsumer
konsumer / setup.sh
Created Jun 3, 2022
make a debian-based os image and chroot for arm (run in arm64 qemu)
View setup.sh
#!/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
View raylib_arkos.md

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 http://old-releases.ubuntu.com/ubuntu eoan main universe
deb http://old-releases.ubuntu.com/ubuntu eoan-updates main universe
@konsumer
konsumer / btoa.js
Last active Jan 29, 2022
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')
}
View example.py
import serial
port = serial.Serial('/dev/ttyTHS1', baudrate=115200, timeout=1)
# Turn on the GPS
port.write(b'AT+CGNSPWR=1')
# Ask for the navigation info parsed from NMEA sentences
port.write(b'AT+CGNSINF')
@konsumer
konsumer / generate-raylib.js
Created Oct 26, 2021
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
konsumer / mdn_canvas.js
Created Sep 14, 2021
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 'https://deno.land/x/deno_dom/deno-dom-wasm.ts'
function getDocs (doc, parent) {
const info = {}
if (doc?.querySelectorAll) {
View protonge_setup.sh
#!/bin/bash
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
fi
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
CARD=NVIDIA
else
@konsumer
konsumer / install-apple-fonts.sh
Created Jun 15, 2021
This will install Apple SF & NY fonts on Linux. Tested on Pop!OS (similar to Ubuntu) 20.10.
View install-apple-fonts.sh
#!/bin/bash
# Install Apple fonts on Linux
# requires p7zip-full installed
getFont() {
NAME=$1
APPLENAME=$2
DIR=$3
DIR=${DIR:="/tmp"}
@konsumer
konsumer / emu.sh
Last active May 21, 2021
Choose the correct retroarch core, based on file-extension, and just run it.
View emu.sh
#!/usr/bin/bash
# Run correct core for a ROM, based on extension
# Setup with sudo apt-get install -y retroarch "libretro-*""
ROM="${1}"
if [ -z "${ROM}" ];then
echo "Usage: ${0} <ROM_FILE>"
@konsumer
konsumer / MazeMap.lua
Created Mar 17, 2021
example using shironecko/LuaMaze in love2d
View MazeMap.lua
local maze = require "lib.maze"
local Camera = require "lib.hump.camera"
math.randomseed(os.time())
--[[
generators:
sidewinder
recursive_backtracker
aldous_broder