Skip to content

Instantly share code, notes, and snippets.

View lifthrasiir's full-sized avatar

Kang Seonghoon lifthrasiir

View GitHub Profile
@lifthrasiir
lifthrasiir / formats.md
Last active April 11, 2024 14:47
Comparison of schemaless byte-oriented binary serialization format

What the heck?

  • Schemaless: The format does not have a knowledge about the underlying data at all.
  • Byte-oriented: The format is built upon a byte stream, probably for the ease of implementation and performance.
  • Binary: The format is not targeted for human consumption and specified in terms of "bytes" (which is 8 bits long for our purpose).
  • Serialization: The format is primarily to be used for storage and transmission, not for the in-memory representation.

Contenders

  • S-Expressions (1997), a "canonical" encoding (which is also used for transport)
@lifthrasiir
lifthrasiir / numeric-tzid.md
Last active March 13, 2024 02:53
Proposal for stable short identifier (or two) of time zones

This proposal was originally written in 2018 as a concrete proposal for numeric time zone identifiers. I'm still not sure if this has a merit or not, but for the historical perspective, I reproduce the (incomplete) proposal in verbatim here. --Kang Seonghoon


[...]

The needs for the short and stable identifier are most importantly observed by the case of the Unicode CLDR project. CLDR required a stable identifier for the locales, which requires a stable identifier for the time zones. [...]

Short Identifiers

/* The world's smallest Brainfuck interpreter in C, by Kang Seonghoon
* http://j.mearie.org/post/1181041789/brainfuck-interpreter-in-2-lines-of-c */
s[99],*r=s,*d,c;main(a,b){char*v=1[d=b];for(;c=*v++%93;)for(b=c&2,b=c%7?a&&(c&17
?c&1?(*r+=b-1):(r+=b-1):syscall(4-!b,b,r,1),0):v;b&&c|a**r;v=d)main(!c,&a);d=v;}
@lifthrasiir
lifthrasiir / brotli-bootstrap.mjs
Last active March 1, 2024 08:49
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 / alphabet.md
Last active February 16, 2024 19:03
The "Options" Alphabet
@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 / crypto.md
Last active November 14, 2023 07:10
High-level understanding of cryptography

고수준에서 암호학 이해하기

이 글은 메아리 저널에 쓸 목적으로 한동안 작업하던 글입니다. 메아리 특유의 디자인(...)이 싫다면 여기로 링크하셔도 됩니다. 어느 쪽이든간에 의견은 이 아래의 코멘트 란 또는 메아리에 기재되어 있는 메일 주소를 써 주시면 감사하겠습니다. --lifthrasiir

암호학을 사용하는 많은 시스템은 세부적으로 무슨 알고리즘을 쓰는지보다는 그 알고리즘들이 어떻게 연결되어 있는지, 즉 구조가 실제 안전성에 더 큰 영향을 미친다. 따라서 구조와 그 구조를 이루는 빌딩 블럭을 아는 것이 중요한데, 여기에서는 이러한 암호학적 빌딩 블럭과 함께 블럭들이 어떻게 쓰여서 더 큰 구조를 만드는지를 알아 본다.

Key Exchange

키 교환. 두 사람만이 알 수 있는 새로운 키를 만든다. 이 과정이 끝나도 상대방이 내가 아는 사람인진 알 수 없지만 적어도 상대방과 내가 같은 키를 가지고 있다는 건 확신할 수 있다.

@lifthrasiir
lifthrasiir / README.md
Last active September 19, 2023 12:33
〈정다면체는 사실 48종류 있음〉 번역 용어집

일반적인 용어가 없거나 부적절하여 새로 만들어낸 용어는 *로 표시함.
일부는 영어로도 정립된 용어가 없는데 이 경우 영어에도 *가 붙어 있음.

기본 용어

@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 / bf.rs
Created February 13, 2013 12:16
Brainf*ck in Rust (sort of, does not work)
struct tape { mem: ~[u8], ptr: uint }
pure fn tape() -> tape { tape { mem: vec::from_elem(10000u, 0u8), ptr: 0 } }
macro_rules! bf_rec(
() => ();
(+) => (tape.mem[tape.ptr] += 1u8);
(-) => (tape.mem[tape.ptr] -= 1u8);
(>) => (tape.ptr += 1u);
(<) => (tape.ptr -= 1u);