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
Last active March 31, 2024 08:40
When you have to initialise multiple resources

Sometimes you have to initialise more than one resource and properly clean everything up.

This is the cleanest option I was able to figure out for Kotlin.

Example of usage:

        private val buffers: Array<AudioBuffer>
        private val device: AudioDevice
        private val context: AudioContext
@hakanai
hakanai / Readme.md
Last active March 19, 2024 00:16
Word combination finder

Started with https://gist.github.com/gubatron/65a153478149118908c6

  • Made it work (original was probably Python 2?)
  • Significantly tidied the code
  • Performance: Removed redundant sorting
  • Performance: Made input permutations unique so identical combinations weren't tried more than once

Still very slow for inputs 9+ letters long. Roughly exponential - takes around 1s for an 8 letter word, 10-11x longer for each additional letter.

@hakanai
hakanai / BetterErrorDialog.kt
Last active March 16, 2024 23:43
Attempt at replacing the Compose error handling to get a better looking dialog
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.window.DialogWindow
@Composable
internal fun BetterErrorDialog(state: ErrorDialogState) {
if (state.isVisible) {
@hakanai
hakanai / Main.kt
Last active January 4, 2024 03:25
Demonstration of recomposition not occurring if the initial window list was empty
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.*
import androidx.compose.ui.window.*
import kotlinx.coroutines.*
data class SystemProfile(
var name: String
)
@hakanai
hakanai / BrokenSurfaceShader.shader
Last active July 7, 2023 11:51
Reproduction of an annoying "feature" of surface shaders
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
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
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

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

.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
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 エスカード