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 April 9, 2026 09:11
oEmbed notes

oEmbed notes

[oEmbed][OE] is the format used to embed content from a website into other sites or apps.

It is not the only standardized format for this. Including an application/ld+json summary in the page header is another.

How it works

  1. Consumer determines that the site supports oEmbed. There are several ways:
@hakanai
hakanai / ANSI-escape-sequences.md
Created March 28, 2026 11:58 — forked from ConnerWill/ANSI-escape-sequences.md
ANSI Escape Sequences cheatsheet

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@hakanai
hakanai / build.gradle.kts
Created October 11, 2025 17:49
Is there a more streamlined way to boot Material 2 out of the project?
// This is the sort of thing that should be in `settings.gradle.kts`, but there's no API for it yet.
// I could boot it out into `buildSrc`, but for now it lives here.
allprojects {
configurations.all {
resolutionStrategy {
dependencySubstitution {
substitute(module("org.jetbrains.compose.material:material"))
.because("Material 3 is shinier")
.using(module(compose.dependencies.material3))
}
@hakanai
hakanai / README.md
Last active April 5, 2025 09:10
Manually disassembled AppleScript .SCPT file

The structure given here possibly only applies to the "jscr" variant, because I see quite different examples out there for "ascr". In particular, "ascr" files don't seem to contain a bplist at all!

AppleScriptHeader: {
    0x0000:  4A 73 4F 73 61 44 41 53 31 2E 30 30 31 2E 30 30
        - magic number?
        - ASCII: "JsOsaDAS1.001.00"
}
@hakanai
hakanai / gist:93540ea87a5cd7c325f9fb86413af535
Created April 4, 2025 15:21
Quick and dirty code to pull width and height from SVG files and compute how much to scale them
$maxsize = 96
Get-ChildItem "*.svg" | ForEach-Object {
$xml = [xml](Get-Content $_.FullName)
$origWidth = [float][string]($xml | Select-Xml -XPath "/*/@width")
$origHeight = [float][string]($xml | Select-Xml -XPath "/*/@height")
$widthRatio = $maxsize / $origWidth
$heightRatio = $maxsize / $origHeight
$largerRatio = ($widthRatio,$heightRatio | Measure -Min).Minimum
@hakanai
hakanai / Disable Snipping Tool Hotkey.reg
Created April 23, 2024 12:02
Something I found useful
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"DisabledHotkeys"="S"
@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 February 11, 2025 01:46
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
)