Skip to content

Instantly share code, notes, and snippets.

View magical's full-sized avatar
🙀
🐛

Andrew Ekstedt magical

🙀
🐛
View GitHub Profile
@magical
magical / xy-capture.txt
Last active August 29, 2015 14:11
Pokémon X capture routine analysis
; Pokemon X capture routine
; DllBattle.cro .text+0x2ee40
; tl;dr everything is pretty much the same
; but with more floating point.
; there are four shake checks again instead of three
; and the fourth root is now a 16/3 root.
; looks like we're going to use a truly staggering number of registers
2ee40: e92d4fff push {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
>>> f = open("X/exefs/code.bin", 'rb')
>>> data = []
>>> for i in range(1, 65):
... _ = f.seek(0x4467d8 + i*22)
... data.append(f.read(22))
...
>>> text = [line.strip() for line in open("xy/rips/text/en/141")]
>>> for d in data: text[d[12]], struct.unpack("<H", d[18:20])[0]
...
('Hatching Power Lv. 1', 125)
@magical
magical / gist:b89789fe20d36885b646
Created April 14, 2015 06:23
Form differences
Pichu: pokeathlon
Unown: pokeathlon
Castform: pokeathlon, type, moves (level-up)
Deoxys: effort, pokeathlon, stats, moves (level-up, tutor)
Burmy: pokeathlon
Wormadam: effort, pokeathlon, stats, type, moves (level-up, machine, tutor)
Cherrim: pokeathlon
Shellos:
Gastrodon:
Rotom: exp, pokeathlon, stats, type, moves (form-change)
import re
import time
quotefix_re = re.compile(
r'''
^(
(?:
(?:
(?:[^\n\\"]|(?:\\{2})*\\"|\\[^\n"])*
(?:\\{2})*
# NOT A TUPLE
1 # NOT A TUPLE
1, 2 # a 2-tuple
1, 2, 3 # a 3-tuple
, # SYNTAX ERROR
1, # a 1-tuple
1, 2, # a 2-tuple
1, 2, 3, # a 3-tuple
@magical
magical / add.c
Created May 11, 2015 19:45
gcc and -Wconversion
// gcc 4.9.2
// gcc -Wconversion -c add.c
unsigned char x;
void foo(unsigned char y) {
x += y; // warning: conversion to ‘unsigned char’ from ‘int’ may alter its value
}

Keybase proof

I hereby claim:

  • I am magical on github.
  • I am magical (https://keybase.io/magical) on keybase.
  • I have a public key whose fingerprint is 63F7 C160 A01D F8D0 00CF 58E2 C0C0 B6A4 6234 3062

To claim this, I am signing this object:

// https://blog.quickmediasolutions.com/2015/09/13/non-blocking-channels-in-go.html
// ...without using reflect
package util
import (
"container/list"
)
// Channel that does not block when items are sent. To use the struct, simply
@magical
magical / gist:ae51f97677632e694c4c
Last active October 5, 2015 05:23 — forked from anonymous/-
hypothetical design for a daily todo list app
hypothetical design for a daily todo list app
sits in the tray
click the tray icon to toggle the main window
has space for 10 (7? 12?) todo items
an item is a status icon and a short bit of text
status can be · or ✔ or ✘
click on an item to edit its text
click on a blank item to add a new item
click on the status to cycle through
@magical
magical / dumpcc2.py
Last active October 12, 2015 02:13
in-progress CC2 level dumper
import binascii
import struct
import sys
import traceback
u16 = struct.Struct('<H')
u32 = struct.Struct('<L')
def read16(f):
b = f.read(2)