Skip to content

Instantly share code, notes, and snippets.

View gocha's full-sized avatar

gocha gocha

View GitHub Profile
@gocha
gocha / kirbysuperstar-boss-order.lua
Last active August 8, 2019 15:17
Kirby Super Star: Boss Order Simulator
--- Kirby Super Star: Boss Order Simulator
-- https://github.com/gocha/gocha-tas/blob/master/Tools/Lua/kirbysuperstar/random.lua
local SuperDeluxeRNG = require "kirbysuperstar/random"
function get_bosses(random)
-- Reimplementation of $d1e34f
local kNumOfBoss = 18
local bosses = {} -- $7a2f-$7a53
for i = 0, kNumOfBoss do
@gocha
gocha / kirbysuperstar-rng-sample.lua
Last active August 8, 2019 15:17
Kirby Super Star: RNG Module Example
-- https://github.com/gocha/gocha-tas/blob/master/Tools/Lua/kirbysuperstar/random.lua
local SuperDeluxeRNG = require "kirbysuperstar/random"
local random = SuperDeluxeRNG.new(0x1234)
for i = 1, 10 do
print(random:random(6))
-- raw random seed can be accessed via random.seed
end
@gocha
gocha / kirbysuperstar-rng.c
Created August 7, 2019 15:20
Kirby Super Star: RNG Simulator POC (Hoshi no Kirby Super Deluxe)
// Kirby Super Star: RNG Simulator POC
#include <stdio.h>
#include <stdint.h>
static uint16_t seed = 0x7777;
uint8_t random(uint8_t limit) {
for (int i = 0; i < 11; i++) {
uint16_t bit = ~(seed ^ (seed >> 1) ^ (seed >> 15)) & 1;
@gocha
gocha / aos_song_randomizer.lua
Created June 15, 2019 09:10
Castlevania: Aria of Sorrow - Song Randomizer
-- Castlevania: Aria of Sorrow - Song Randomizer
-- Runs on VBA-RR v23 (DO NOT USE v24)
local serial = string.char(unpack(memory.readbyterange(0x80000ac, 4)))
local m4aSongNumStart
if (serial == "A2CJ") then
m4aSongNumStart = 0x80d7950
elseif (serial == "A2CE") then
m4aSongNumStart = 0x80d9378
@gocha
gocha / xml2json.js
Last active September 19, 2018 08:55
Parses an XML document or element into a JavaScript Object (JSON)
/**
* Parses an XML document or element into a JavaScript Object.
*
* To turn the object into JSON, use JSON.stringify().
*
* This function is heavily inspired by:
* - [Converting Between XML and JSON]{@link http://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html}
* - [xmltodict]{@link https://github.com/martinblech/xmltodict} Python library.
* Thank you very much for both of two.
*
@gocha
gocha / sqltree.py
Last active June 23, 2023 20:58
Print parsed SQL statement as a tree (sqlparse with Python 3)
"""Print parsed SQL statement as a tree.
Uses Python 3 and sqlparse package.
"""
from typing import Iterator, Tuple
import argparse
import locale
import sys
import os
@gocha
gocha / loadswf.js.patch
Created August 16, 2018 02:40
Oracle Database 11: Patch for the SQL monitor report to allow modern browsers to load the Flash viewer
--- emviewers/scripts/loadswf.js.orig Thu Aug 16 11:26:42 2018
+++ emviewers/scripts/loadswf.js Thu Aug 16 11:40:06 2018
@@ -2,6 +2,13 @@
// This array should be modified everytime a new viewer is supported or when a
// new version of a viewer is introduced.
//
+// requires:
+// swfobject 2.3 (swfobject.js and expressInstall.swf) <https://github.com/swfobject/swfobject>
+// patch for chrome 55 <https://github.com/swfobject/swfobject/pull/59>
+// and also do not forget to import swfobject.js instead of legacy flashver.js (modify your saved report html by hand)
@gocha
gocha / ps_getopt_sample.sh
Last active July 17, 2018 02:24
Sample for ps_getopt.sh: Powershell-flavored command line argument parser
#!/bin/bash
#
# Powershell-flavored command line argument parser example.
#
# Requires: ps_getopt.sh <https://gist.github.com/gocha/9b12fa0b7b5d18ae56e0452cec749e87>
# License: Unlicensed
. ps_getopt.sh
ALL_PARAMS=("Path" "Nullable" "Optional" "Force")
@gocha
gocha / ps_getopt.sh
Last active July 17, 2018 02:57
Powershell-flavored command line argument parser
#!/bin/bash
#
# Powershell-flavored command line argument parser.
#
# See ps_getopt_sample.sh for usage.
# <https://gist.github.com/gocha/8c74f9724bfb9c1e3a98b28bd5cceddc>
#
# License: Unlicensed
declare -A params
@gocha
gocha / runwin32-iconv.sh
Last active January 30, 2018 07:25
Advanced runwin32 launcher for Cygwin+rsh w/ iconv charset conversion
#!/bin/bash
#
# Note:
# - Environment variables must be set before running. This script doesn't import any user profiles.
# Add Windows system directory paths to the PATH,
# to allow to use cmd.exe and any other standard commands.
export PATH="$(cygpath -S):$(cygpath -W):$PATH"
# Add some common system variables.