This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
import typing as T | |
if T.TYPE_CHECKING: | |
float32: T.TypeAlias = float | |
else: | |
try: | |
from numpy import float32 | |
except ImportError: | |
float32 = float |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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: |
NewerOlder