Skip to content

Instantly share code, notes, and snippets.

@willnode
willnode / redox_gen_go_types.sh
Created September 2, 2025 02:13
Generate Go Types for Redox OS, see https://github.com/willnode/go
# A script to generate Redox syscalls in Go source files, put this script to "src" folder
# You must have Redox build system in $HOME/redox with "prefix" generated
# You must have "$ARCH-unknown-redox-gcc" in your PATH, add it from Redox build system
# mkerrors: You need to patch "$CC" to "gcc" at the bottom of the script, also "$(uname)" to "Redox"
# mkerrors: You need to comment out "#include <netinet/ip6.h>" and "#include <sys/signal.h>" since Redox doesn't have it
export ARCH=x86_64 GOARCH=amd64 # intentionally not setting GOOS since "go" run on vanilla Go
export redox_sysroot="$HOME/redox/prefix/$ARCH-unknown-redox/sysroot/$ARCH-unknown-redox"
export CGO_FLAGS="--sysroot=${redox_sysroot}" \
CC=$ARCH-unknown-redox-gcc TARGET=$ARCH-unknown-redox GNU_TARGET=$ARCH-unknown-redox \
@willnode
willnode / redox-offline-setup.md
Last active August 28, 2025 23:46
Fully offline Redox build system

There are three things you need to know in Redox build system to achieve full offline build system.

Fetch source files as much as possible

The first thing that you need to do is fetch as many package sources that you might want to download before going offline. I recommend following these steps:

  1. Set CONFIG_NAME=ci. It will match to all packages proven to build correctly
  2. Run make fetch. It will download all of them without building it

After fetch is done you can revert CONFIG_NAME to a kind of image you wish to build.

@willnode
willnode / loadenv.sh
Created April 9, 2025 11:44
Load .env file as environment variables and execute a command
#!/bin/sh
ENV_FILES="" # list of env files (empty by default)
VERBOSE=0
show_help() {
cat <<EOF
Usage: $(basename "$0") [--env-file=FILE ...] [--verbose] [--help] [VAR=val ...] COMMAND [ARGS...]
Options:
@willnode
willnode / readcsvinzip.go
Created December 29, 2024 09:32
Streaming CSV inside a ZIP File with Go Channel
package main
import (
"archive/zip"
"bytes"
"context"
"errors"
"fmt"
"io"
"path/filepath"
@willnode
willnode / deceptive.html
Created August 7, 2024 17:33
DOM Cloud
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>You're entering DOM Cloud User Generated Content</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@567&display=swap" rel="stylesheet">
<style>
<?php
namespace App\Libraries;
use App\Entities\User;
use App\Entities\Purchase;
use Config\Services;
use WpOrg\Requests\Requests;
/**
@willnode
willnode / install-medusa-no-tty.sh
Last active March 11, 2024 04:53
install medusa.js without interactive prompts
#!/usr/bin/expect -f
# Check if the correct number of arguments is provided
if { $argc != 2 } {
puts "Usage: $argv0 <npx_command_arguments> <admin_email>"
exit 1
}
# Set timeout for expect
set timeout -1
@willnode
willnode / install.md
Last active May 26, 2025 06:02
Build Redox for Aarch64 OS Guide

[WIP] Building Aarch64 Redox OS from Mac M1

Here's how you build Redox from Mac in May 2025. It's so much easier to do it now than in ancient days.

The only problem you may encounter is packaging the build, since it requires FUSE and it's requires patching Mac kernel, which I don't want. I (trying) develop a way to avoid it by using Podman only for that.

I run with UTM on QEMU virtualization. It works for me.

This notes is WIP, see https://gist.github.com/willnode/a31a1265d955dbb914001aba8a576ad2 for Redox OS native bootstrapping

@willnode
willnode / restart.sh
Created January 4, 2024 10:44
DOM Cloud's restart script
#!/bin/bash
while [ `passenger-config list-instances --json | jq length` -ne 1 ]; do
echo "Waiting until NGINX done reloading..."
sleep 1
done
sudo -n -- passenger-config reopen-logs &> /dev/null || true
passenger-config restart-app ~ --ignore-app-not-running
@willnode
willnode / index.html
Created November 16, 2023 22:07
DOM Cloud's default index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Welcome!</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
text-align: center;
font-family: "Segoe UI", Roboto, sans-serif;