Skip to content

Instantly share code, notes, and snippets.

View lifthrasiir's full-sized avatar

Kang Seonghoon lifthrasiir

View GitHub Profile
@lifthrasiir
lifthrasiir / nothing.html
Created September 16, 2024 07:30
Use nothing but a vanilla HTML/CSS/JS to rewrite https://usenothing.com/ in a single file (including the webfont)
<base target=_blank><style>*{box-sizing:border-box;padding:0;margin:0}:root{color:#a1a1aa;background:#09090b;font:1.2rem Crimson Text,serif}::selection{color:#fafafa;background:#3f3f46}strong,output{font-weight:normal;color:#fafafa}output{font-family:Courier New,monospace}body{width:90%;max-width:550px;margin:120px auto}p,svg{margin-bottom:12px}p:has(~hr){font-size:1.2rem}hr{width:50px;height:1px;background:#27272a;border:0;margin:50px 0}hr~*{line-height:1.7}hr~p{text-indent:24px;margin-bottom:24px}a{color:#fafafa;text-decoration:underline dotted #71717a}aside{position:fixed;bottom:20px;left:0;width:100%;pointer-events:none}#A{width:-moz-max-content;width:max-content;max-width:90%;padding:12px 16px;margin:0 auto;font:0.74rem Inter,Arial,sans-serif;line-height:1.6;color:#a1a1aa;background-color:#18181b;border:1px solid #27272a;opacity:var(--o,0);transform:translateY(calc(20px*(1 - var(--o))))}/* fonttools subset CrimsonText-Regular.ttf --unicodes="U+0020,U+0027,U+002C-002E,U+0030-0039,U+0041-005A,U+0061-007A,U
@lifthrasiir
lifthrasiir / disfilter.rs
Created June 18, 2024 01:25
Disfilter: Fabian Giesen's x86-32 transformer, reworked for x86-64 in Rust (WIP)
// TODO:
// - Better error checking
// - Better code structure
// - Detect function boundary (skip CC or multi-byte nops)
use std::array;
use std::cell::Cell;
use std::fmt;
use std::fs::File;
use std::io::{self, BufReader, Read, Seek, SeekFrom, Write};
@lifthrasiir
lifthrasiir / brotli-bootstrap.mjs
Last active May 31, 2024 23:03
Brotli bootstrapping based on WOFF2 font
// Brotli bootstrapping based on WOFF2 font
// Kang Seonghoon, 2024-03-01, public domain
// Based on my earlier work for JS1024: https://js1024.fun/demos/2022/18
// Only vaguely tested, YMMV
import { argv, stderr } from 'node:process';
import fs from 'node:fs';
import zlib from 'node:zlib';
const generateBrotliParams = function* () {
@lifthrasiir
lifthrasiir / rs_ccsds.py
Created November 14, 2023 18:21
Optimized Python version of crozone/ReedSolomonCCSDS
# derived from https://github.com/crozone/ReedSolomonCCSDS
# should be more performant alternative to https://github.com/kplabs-pl/reed-solomon-ccsds
from dataclasses import dataclass
from typing import Optional, List
ALPHA_TO = [
0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x87,0x89,0x95,0xad,0xdd,0x3d,0x7a,0xf4,
0x6f,0xde,0x3b,0x76,0xec,0x5f,0xbe,0xfb,0x71,0xe2,0x43,0x86,0x8b,0x91,0xa5,0xcd,
0x1d,0x3a,0x74,0xe8,0x57,0xae,0xdb,0x31,0x62,0xc4,0x0f,0x1e,0x3c,0x78,0xf0,0x67,
@lifthrasiir
lifthrasiir / make_wheels_from_dir.py
Last active September 11, 2023 10:17
Custom Zig PyPI packaging script
# This script builds a custom Zig distribution into a Python wheel.
#
# The "custom" distribution refers to any directory resulting from
# zig-bootstrap that doesn't make into public nightly or stable releases.
# The existing ziglang/zig-pypi doesn't work with such cases, hence
# this script. It still makes use of a large portion of make_wheels.py,
# so should be put into the same directory in order to function.
#
# This script is derived from make_wheels.py from zig-pypi (commit
# 5b30070bc), and thus distributed under the same license (MIT/Expat).
@lifthrasiir
lifthrasiir / Cargo.toml
Last active December 10, 2022 11:50
Async_zip + tokio issue with nested streams
[package]
name = "async-zip-problem"
version = "0.1.0"
edition = "2021"
[[bin]]
name = "async-zip-problem"
path = "main.rs"
[dependencies]
@lifthrasiir
lifthrasiir / epyt-commented.js
Created July 13, 2022 13:44
epyt: a simple yet challenging typing game for JS1024 2022 https://js1024.fun/demos/2022/18/readme
// _
// ___ __ _ _ _ _| |
// / _ \ / _` | | | |__ | by Kang Seonghoon (@senokay, mearie.org)
// \__ | (_| | |_| |_| | 2022-07-13, for JS1024 2022
// |___/ \__, | .__/|__/ Public Domain (CC0 1.0)
// |_|\___|
//
// This is a simple typing game where you have lots of short English words to
// quickly type before a timer runs out. Perhaps most surprisingly, the game
// seems to have an access to lots of real English words (1,903 to be exact).
@lifthrasiir
lifthrasiir / dj40.c
Last active September 13, 2022 16:42
Pre-release version of J40 JPEG XL decoder, see https://github.com/lifthrasiir/j40 for recent releases
#define J40_CONFIRM_THAT_THIS_IS_EXPERIMENTAL_AND_POTENTIALLY_UNSAFE
#define J40_IMPLEMENTATION
#include "j40.h"
#ifdef __GNUC__ // stb_image_write issues too many warnings
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wconversion"
#endif
#define STB_IMAGE_WRITE_IMPLEMENTATION
@lifthrasiir
lifthrasiir / radio.html
Created April 2, 2022 04:35
xkcd 2022-04-01: transcript and runner (up to 2:17:00)
<!doctype html>
<meta http-equiv=refresh content=2>
<canvas id=canvas width=2000 height=2000></canvas>
<script>
function draw(s) {
try {
const ctx = canvas.getContext('2d');
ctx.scale(1.5, 1.5);
ctx.translate(500, 500);
ctx.scale(1, -1);
// really inefficient MicroW8 quine
// 2022-03-01 Kang Seonghoon, public domain
import "env.memory" memory(4);
import "env.printString" fn printString(i32);
export fn upd() {
if 0!64 > 0 {
return;