Skip to content

Instantly share code, notes, and snippets.

@TellowKrinkle
TellowKrinkle / HigurashiSwitchReader.swift
Created November 25, 2019 05:52
Extractor for Higurashi Switch ROM
import Foundation
guard CommandLine.arguments.count > 2 else {
print("Usage: \(CommandLine.arguments[0]) data.rom outputFolder")
exit(EXIT_FAILURE)
}
let outputPath = CommandLine.arguments[2]
func fileInfo(path: String) -> (exists: Bool, isDirectory: Bool) {
var isDir: ObjCBool = false
@TellowKrinkle
TellowKrinkle / modifyCommit.fish
Created July 21, 2019 17:09
A function to modify git commits
function modifyCommit -d "Creates a new commit by modifying an old one"
argparse --name=modifyCommit "p/parent=+" "c/content=" "C-preserve-committer" "S/gpg-sign=" -- $argv; or return
if test (count $argv) != 1
echo "Usage: modifyCommit [-p parent] [--preserve-committer] [--content content] commitHash"
echo "Got " $argv
return 1
end
set commit $argv[1]
@TellowKrinkle
TellowKrinkle / EncodingGuesser.swift
Last active May 9, 2019 06:51
Guesses an unknown UInt16 → Character file encoding of a file based on some strings known to exist in it (Remember to compile with optimizations!)
import Foundation
extension String {
func leftpad(to size: Int, with char: Character) -> String {
if count >= size { return self }
return String(repeating: char, count: size - count) + self
}
}
guard CommandLine.arguments.count > 2 else {
@TellowKrinkle
TellowKrinkle / AoC_2018D17Picture.txt
Created December 17, 2018 06:16
Advent of Code 2018 Day 17 Picture
.........................................................................................................................................................|.......#.#..........................................................................
.......................................................................................................................................................||||||||||#.#..........................................................................
.......................................................................................................................................................|#~~~~~~~~#.#..........................................................................
.......................................................................................................................................................|#~~~~~~~~#.#.......#..................................................................
....................................................................
@TellowKrinkle
TellowKrinkle / EMIPGenerator.py
Last active August 25, 2018 20:05
Generate EMIP files which can be imported by UABE
import sys
import os
import re
from PIL import Image
from PIL import ImageOps
from unitypack.asset import Asset
if len(sys.argv) < 4:
print("Usage: " + sys.argv[0] + " assetfile.assets inputFolder outputFile.emip\nInput folder should contain files whose names start with the object ID they want to replace.")
exit()
@TellowKrinkle
TellowKrinkle / UnityTextModifier.py
Created August 22, 2018 15:36
Creates update files to edit the text of unity asset files to use with UABE
import sys
import os
import json
import unitypack
from unitypack.asset import Asset
if len(sys.argv) < 4:
print("Usage: " + sys.argv[0] + " assetfile.assets edits.json outputfolder\nEdits.json should be an array of objects with the fields 'CurrentEnglish', 'CurrentJapanese', 'NewEnglish', and 'NewJapanese'. An optional 'Discriminator' field can be added if multiple texts have the same English and Japanese values.");
exit()
@TellowKrinkle
TellowKrinkle / UnityPosFinder.py
Created August 22, 2018 00:47
Correlates offsets with object IDs in unity asset files
import sys
import unitypack
from unitypack.asset import Asset
if len(sys.argv) < 3:
print("Usage: " + sys.argv[0] + " assetfile.assets (offset | offsetfile.txt)\nOffset file formatting: per line \"offset [printout name]\"")
exit()
try:
targetOffsets = [[int(sys.argv[2], 0), sys.argv[2]]]
@TellowKrinkle
TellowKrinkle / Filter.swift
Last active March 20, 2018 21:45
LazyCompactMap
// Note: This is just a copy of the swift stdlib Filter.swift with everything renamed
//===--- Filter.swift -----------------------------------------*- swift -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
@TellowKrinkle
TellowKrinkle / 0001-Fixed-an-issue-where-the-library-would-infinitely-tr.patch
Created September 8, 2017 20:10
SwiftDiscord Swift 4 DiscordGatewayPayloadData Changes
From a301a28f43fc9faa20bd3d3e8452bf20dfe988d6 Mon Sep 17 00:00:00 2001
From: Evan Tang <etang110@gmail.com>
Date: Thu, 7 Sep 2017 12:02:26 -0500
Subject: [PATCH 1/4] Fixed an issue where the library would infinitely try to
reconnect NSNumber bools are convertible to Integers and NSNumber integers
that are 0 or 1 are convertible to booleans This caused the reconnect code to
improperly assume that a netsplit occurred because it received an int
payload, not a bool
---
@TellowKrinkle
TellowKrinkle / tatsuCompiler.py
Created July 14, 2017 09:35
A program that strips comments and newlines from tatsu tags so they can be used
#! /usr/bin/python
import sys
if len(sys.argv) < 2:
print("Usage: " + sys.argv[0] + " file.tatsu")
exit(1)
tatsuFileName = sys.argv[1]
try:
tatsuFile = open(tatsuFileName, "r")