Skip to content

Instantly share code, notes, and snippets.

View hakanai's full-sized avatar
⚔️
Battling i16n demons

Hakanai hakanai

⚔️
Battling i16n demons
View GitHub Profile
@hakanai
hakanai / Readme.md
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
hakanai / macos_bookmark_file.ksy
Last active December 13, 2022 08:16
File format you get when creating an alias in Finder
meta:
id: macos_bookmark_file
endian: le
#file-extension: macos-bookmark-file
seq:
- id: header
type: header
- id: toc_offset
type: u4
@hakanai
hakanai / MyTheme.kt
Created October 24, 2021 01:09
Minimal(?) example of custom theme in Jetpack Compose
import androidx.compose.desktop.Window
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.graphics.Color
fun isSystemInDarkTheme(): Boolean {
// TODO: On Android, presumably this is `AppCompatDelegate.getDefaultNightMode()`.
// What is it on Desktop?
return false
}
@hakanai
hakanai / pmx21.md
Last active February 18, 2023 17:28 — forked from felixjones/pmx21.md
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.

Todo

@hakanai
hakanai / gist:853b607366a5f366d199a0f9b7ae76c0
Created September 10, 2021 18:24
Reversing a string in Kotlin 1.5
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 (iterator.next() == BreakIterator.DONE) {
@hakanai
hakanai / Readme.md
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
hakanai / Readme.md
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
hakanai / script.py
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):
@hakanai
hakanai / ELRaymarchBase.cginc
Created May 28, 2020 08:49
Implementing raycast abstraction by defining a raymarch abstraction
#ifndef EL_RAYMARCH_BASE_CGINC
#define EL_RAYMARCH_BASE_CGINC
#include "ELRaycastBase.cginc"
float2 ELMap(float3 objectPos);
float3 ELRaymarchNormal(in float3 objectPos)
{
static const float2 e = fixed2(0.000001, -0.000001);
@hakanai
hakanai / MagicDieV3.cginc
Created May 28, 2020 07:21
Shader code reuse prototype
#include "../Common/ELRaycastBase.cginc"
#include "../Common/ELRaycastFunctions.cginc"
////////////////////////////////////////////////////////////////////////////////
// Input / Output Data Structures
struct FragmentInput
{