Skip to content

Instantly share code, notes, and snippets.

Battling i16n demons

Hakanai hakanai

Battling i16n demons
View GitHub Profile
hakanai /
Last active March 1, 2023 05:15
Performance issue removing 1,000,000 items from a mutable list in Compose

This was an idea for tree implementation I came up with to try and play well with the way Compose wants us to do things.

The basic idea:

  • Maintain a list of every row which is currently visible/expanded
  • When you expand a node, add all its children to the list
  • When you collapse a node, remove its children (caveat: and their children) from the list
  • Rendering nodes is fairly easy because the only thing that varies is the amount of indent and which icon to show

The idea seems sound - adding a million entries to the list is fast enough as to be unnoticeable.

hakanai /
Created January 11, 2023 07:47
.DS_Store pBB0 blob format

.DS_Store pBB0 blob format

This blob contains many values which look like file offsets, but the blob itself isn't big enough for any of the offsets to make sense, so they must be offsets inside some other, larger structure. Possibly the pBBk entry?


hakanai /
Created December 25, 2022 07:21
That block of Unicode with all the abbreviated Japanese words
code point ch expanded meaning
U+3300 アパート   apartment?
U+3301 アルファ   alpha (α)
U+3302 アンペア   ampere (A)
U+3303 アール    are (a)
U+3304 イニング   inning?
U+3305 インチ    inch (in.)
U+3306 ウォン    won (₩)
U+3307 エスカード 
hakanai / macos_bookmark_file.ksy
Last active December 13, 2022 08:16
File format you get when creating an alias in Finder
View macos_bookmark_file.ksy
id: macos_bookmark_file
endian: le
#file-extension: macos-bookmark-file
- id: header
type: header
- id: toc_offset
type: u4
hakanai / MyTheme.kt
Created October 24, 2021 01:09
Minimal(?) example of custom theme in Jetpack Compose
View MyTheme.kt
import androidx.compose.desktop.Window
import androidx.compose.material.*
import androidx.compose.runtime.*
fun isSystemInDarkTheme(): Boolean {
// TODO: On Android, presumably this is `AppCompatDelegate.getDefaultNightMode()`.
// What is it on Desktop?
return false
hakanai /
Last active February 18, 2023 17:28 — forked from felixjones/
PMX (Polygon Model eXtended) 2.0, 2.1 File Format Specifications

PMX (Polygon Model eXtended) 2.1

This is an English description of the .PMX file format used in Miku Miku Dance (MMD).

PMX is the successor to the .PMD format (Polygon Model Data).

This is work-in-progress! Please leave feedback in the comments.


hakanai / gist:853b607366a5f366d199a0f9b7ae76c0
Created September 10, 2021 18:24
Reversing a string in Kotlin 1.5
View gist:853b607366a5f366d199a0f9b7ae76c0
import java.text.BreakIterator
import java.text.StringCharacterIterator
fun reverse(string: String): String {
val iterator = BreakIterator.getCharacterInstance()
iterator.text = StringCharacterIterator(string)
val characters = mutableListOf<String>()
while (true) {
val startOffset = iterator.current()
if ( == BreakIterator.DONE) {
hakanai /
Last active February 17, 2022 10:53
Modelling Light

Modelling Light

I wanted to improve the realism of ray traced images.

Real light waves are not conveniently split into RGB components, but rather a spectrum. Further, light exhibits polarisation and diffraction.

A spectrum

hakanai /
Last active September 21, 2021 02:32
RFL File Format Notes

RFL File Format Notes

The RFL file format was used by Wavefront's Advanced Visualizer software to store "spectral curve data", which is essentially a way to encode the response of a material to different wavelengths of light.

The docs for the [MTL file format][1] frequently refer to this format, but never seem to include the documentation for the format.

hakanai /
Created August 30, 2020 09:02
Blender script to perform conformal mapping from unit square to unit circle
import numpy
import bpy
import bmesh
from math import sqrt, floor
from bpy import context
from scipy.special import ellipj, ellipk
Kval = ellipk(0.5) # 1.8540746773013719
def elliptical_map(x, y):