Skip to content

Instantly share code, notes, and snippets.

@Kyuuhachi
Kyuuhachi / nani.py
Last active April 7, 2024 15:21
Ys I/II/Origin/VI extractor
import typing as T
from pathlib import Path
import zlib
import struct
try:
import numpy as np
def decode(data: bytes) -> bytes:
data = np.frombuffer(data, dtype=np.ubyte).copy()
obf = 0x7C53F961 * 0x3D09 ** (1+np.arange(len(data), dtype=np.uint32))
@Kyuuhachi
Kyuuhachi / it3tex.py
Last active April 9, 2024 19:10
Extract and inject textures to Falcom's it3 files
import typing as T
from pathlib import Path
from dataclasses import dataclass
@dataclass
class Chunk:
type: bytes
data: bytearray
def read_chunks(f: T.IO[bytes]) -> list[Chunk]:
@Kyuuhachi
Kyuuhachi / itm.py
Created August 23, 2023 15:01
Zwei II and Gurumin tools
# Deciphers ITM files into their raw form (usually a bmp, wav, or txt).
# Zwei II has an extra level of scrambling on its text files, so use --zwei for that.
# Gurumin's sound.itm is not enciphered at all, it's just a binary file.
from pathlib import Path
import struct
import numpy as np
Buf = np.ndarray[int, np.dtype[np.uint8]]
@Kyuuhachi
Kyuuhachi / 0-DEPRECATED.md
Last active April 11, 2023 16:02
[DEPRECATED] Convert a bc7-encoded .dds file to a NISA Trails from Zero-style .itp file (and also itp to dds)

This script is deprecated, please use Cradle instead.

import sys
if not sys.gettrace():
# f_trace doesn't work if settrace isn't set
sys.settrace(lambda a, b, c: None)
def j(n):
def hook(fr, event, arg):
assert event == "opcode"
fr.f_lineno += n
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE CPP #-}
module Music (withMusic) where
#ifdef NO_SOUND
import Data.IORef
withMusic :: ((IORef Double, IORef Double) -> IO ()) -> IO ()
withMusic f = do
a <- newIORef 0
@Kyuuhachi
Kyuuhachi / TypeSort.hs
Created May 2, 2018 15:55
A merge sort implementation in Haskell's type system
{-# LANGUAGE NoImplicitPrelude, UndecidableInstances, FlexibleInstances, FunctionalDependencies, UnicodeSyntax, TypeOperators, FlexibleContexts #-}
module TypeSort where
data T
data F
class (Either b l r) o | b l r → o
instance (Either T l r) l
instance (Either F l r) r
@Kyuuhachi
Kyuuhachi / Schedule.user.js
Created April 4, 2017 18:44
An userscript for cleaning up SchoolSoft's schedule's print view
// ==UserScript==
// @name Schedule
// @namespace c98
// @include https://sms7.schoolsoft.se/nti/jsp/student/right_student_schedule_print.jsp?*
// @version 1
// @grant none
// ==/UserScript==
print=alert;
@Kyuuhachi
Kyuuhachi / i3bg2.py
Created December 11, 2016 00:28
i3 per-workspace background for /u/Ghostotw
#!/usr/bin/env python3
import Xlib.threaded
import Xlib
import Xlib.display
from Xlib import Xatom
from PIL import Image
import os.path
from collections import defaultdict
try:
2c2
< xkb_keycodes "k" {
---
> xkb_keycodes "evdev+aliases(qwerty)" {
259a260,262
> virtual indicator 12 = "Shift Lock";
> virtual indicator 13 = "Group 2";
> virtual indicator 14 = "Mouse Keys";
266a270,295
> alias <LatQ> = <AD01>;