Skip to content

Instantly share code, notes, and snippets.

View kageru's full-sized avatar

kageru

View GitHub Profile
@kageru
kageru / kotlin-python-slice.kt
Created July 2, 2019 20:16
Mainly a proof of concept. There are better ways to do this, but it was a quick experiment to create something like Python’s slicing in Kotlin.
import kotlin.math.min
object start {
infix fun to(other: Int) = RangeTuple(0, other)
infix fun to(other: end) = RangeTuple(0, Int.MAX_VALUE)
}
object end
infix fun Int.to(other: end) = RangeTuple(this, Int.MAX_VALUE)
@kageru
kageru / inc_to_pory.sh
Last active January 13, 2022 18:12
A simple script that will rename .inc files to .pory and wrap their contents in `raw` blocks. Something for gen 3 rom hacking.
#!/bin/sh
# Save this somewhere and call it in a loop of your choice, e.g.
# find -name 'scripts.inc' -exec ./inc_to_pory.sh {} \;
# to wrap all `scripts.inc` files in raw blocks and rename them to pory or
# find -name '*.inc' -exec ./inc_to_pory.sh {} \;
# to do the same with *all* .inc scripts in the current folder or subfolders.
f="$(echo $1 | rev | cut -c 5- | rev)"
echo 'raw `' >> "$f.pory"