Skip to content

Instantly share code, notes, and snippets.

View magical's full-sized avatar

Andrew Ekstedt magical

View GitHub Profile
#!/usr/bin/env python3.1
movenames = [None,
'Pound', 'Karate Chop', 'DoubleSlap', 'Comet Punch', 'Mega Punch', 'Pay Day', 'Fire Punch', 'Ice Punch', 'ThunderPunch', 'Scratch',
'ViceGrip', 'Guillotine', 'Razor Wind', 'Swords Dance', 'Cut', 'Gust', 'Wing Attack', 'Whirlwind', 'Fly', 'Bind',
'Slam', 'Vine Whip', 'Stomp', 'Double Kick', 'Mega Kick', 'Jump Kick', 'Rolling Kick', 'Sand-Attack', 'Headbutt', 'Horn Attack',
'Fury Attack', 'Horn Drill', 'Tackle', 'Body Slam', 'Wrap', 'Take Down', 'Thrash', 'Double-Edge', 'Tail Whip', 'Poison Sting',
'Twineedle', 'Pin Missile', 'Leer', 'Bite', 'Growl', 'Roar', 'Sing', 'Supersonic', 'SonicBoom', 'Disable',
'Acid', 'Ember', 'Flamethrower', 'Mist', 'Water Gun', 'Hydro Pump', 'Surf', 'Ice Beam', 'Blizzard', 'Psybeam',
'BubbleBeam', 'Aurora Beam', 'Hyper Beam', 'Peck', 'Drill Peck', 'Submission', 'Low Kick', 'Counter', 'Seismic Toss', 'Strength',
#!/usr/bin/env python3
from struct import pack, unpack
import sys
def main(args):
if not args:
print("Usage: python3 file.nds | pnmtopng > icon.png")
print("Extract the game icon from a ROM dump.")
return 1
magical / 4lw
Created November 28, 2010 03:25
#!/usr/bin/env python
# written by magical
# based on
# licensed under WTFPL
# works with python2 and python3
WORDS = [ "A", "AID", "ANA", "ARC", "AT", "AWN", "BAR", "BET", "BOG", "BUG", "CAB", "COD", "COY", "DAD",
"DES", "DOE", "DUE", "EGO", "ETC", "FAT", "FIR", "FUM", "GAP", "GIL", "GUY", "HAP", "HER", "HIT", "HOW", "ICY", "ION",
"IVY", "JET", "JOY", "KIM", "LAM", "LEN", "LIT", "LOW", "MAN", "MEL", "MOD", "MUG", "NAY", "NIP", "NOV", "OAR", "OIL",
# pokemon: a pokemon (name or identifier)
# form: the pokemon's form (identifier)
# version: a space-separated list of version identifiers
# level: the pokemon's level
# type: one of...
# - overworld: a one-shot wild pokemon (default)
# - roaming: a pokemon that moves from route to route
# - starter: given by the professor at the beginning of the game
#!/usr/bin/env python3
from sys import argv, stdout
from urllib.request import urlopen as _urlopen, Request
from urllib.parse import urlunsplit
import json
import re
USER_AGENT = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.815.0 Safari/535.1"
#!/usr/bin/env python3
"""Download an HTML page, translating <img> tags to data: URIs"""
import sys
import lxml.html as etree
from urllib.request import urlopen
from base64 import b64encode
magical / math.asm
Created May 31, 2012 01:55
multiplication and division in x86 asm
global Mul
global Div
; input: [esp+4] m
; [esp+8] n
; return: eax low word of product
; edx high word of product
push esi
push edi
magical / gcd.1.txt
Created June 7, 2012 07:37
gcd and lcm tools
:doctype: manpage
:man source: gcd
:man version: 0.1
gcd, lcm - compute greatest common divisor and least common multiple
magical /
Created October 13, 2012 23:15
Pokémon B/W base experience
#!/usr/bin/env python3
import sys
import narc
from namedstruct import namedstruct
from itertools import islice
BaseStats = namedstruct('BaseStats',
"stat_hp:B stat_atk:B stat_def:B"
-- even and odd as mutually recursive infinite lists
import Prelude hiding (even, odd)
module Main where
even = 0:(map (1+) odd)
odd = map (1+) even
main = putStr $ show $ even