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 / BrokenSurfaceShader.shader
Last active July 7, 2023 11:51
Reproduction of an annoying "feature" of surface shaders
View BrokenSurfaceShader.shader
Shader "Custom/BrokenSurfaceShader"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
@hakanai
hakanai / BusinessTypes.txt
Last active July 1, 2023 01:59
BusinessTypes.txt
View BusinessTypes.txt
ABALONE FISHING
ACCOMMODATION
ACCOMMODATION FOR THE AGED OPERATION
ACCOUNTING SERVICES
ADHESIVE MANUFACTURING
ADULT SEX SHOP OPERATION
ADULT, COMMUNITY AND OTHER EDUCATION N.E.C.
ADVERTISING SERVICES
AGRICULTURAL AND CONSTRUCTION MACHINERY WHOLESALING
AGRICULTURAL MACHINERY AND EQUIPMENT MANUFACTURING
@hakanai
hakanai / Main.kt
Created May 13, 2023 03:42
Fragment shaders in Jetpack Compose
View Main.kt
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Size
@hakanai
hakanai / Readme.md
Last active March 1, 2023 05:15
Performance issue removing 1,000,000 items from a mutable list in Compose
View Readme.md

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
hakanai / Readme.md
Created January 11, 2023 07:47
.DS_Store pBB0 blob format
View Readme.md

.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?

Header

@hakanai
hakanai / Readme.md
Created December 25, 2022 07:21
That block of Unicode with all the abbreviated Japanese words
View Readme.md
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
View macos_bookmark_file.ksy
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
View MyTheme.kt
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
View pmx21.md

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
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 (iterator.next() == BreakIterator.DONE) {