Skip to content

Instantly share code, notes, and snippets.

View magical's full-sized avatar
🙀
🐛

Andrew Ekstedt magical

🙀
🐛
View GitHub Profile
@magical
magical / bw2-baseexp.py
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"
@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)
-- 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
@magical
magical / yahoo.py
Last active December 12, 2015 07:28
screen.yahoo.com video grabber
# Get a video url from screen.yahoo.com
# python3 yahoo.py 'http://screen.yahoo.com/raven-refused-sing-010647927.html' | xargs vlc
import sys
import contextlib
import json
import random
import re
import urllib.parse
import urllib.request
"""Analyze statistics of movepool typing"""
from __future__ import division
import pokedex.db
import pokedex.db.tables as t
from sqlalchemy import sql
import argparse
from itertools import groupby
@magical
magical / bch2obj.go
Last active December 13, 2015 23:42 — forked from smealum/bch2obj.py
package main
import (
"bytes"
"encoding/binary"
"flag"
"fmt"
"io"
"io/ioutil"
"math"
puts "String.concat"
1.upto(10) do |i|
i *= 10000
start = Time.now()
s = ""
0.upto(i) {
s << 'a'
}
puts "#{i}: #{Time.now()-start}s"
end
@magical
magical / ambiguous-names.txt
Created September 16, 2013 18:35
Ambiguous names in veekun/pokedex
Altering Cave en location 490
Altering Cave en location 529
Antídoto es ability 90
Antídoto es item 18
Apricorn Box en item 446
Apricorn Box en item_category 40
Attack en conquest_stat 2
@magical
magical / gist:6878341
Created October 8, 2013 02:14
Pokemon level-up movepool sizes. The numbers on the left show the size of a pokemon's level-up moveset in the versions on the right. The last number is the product of those numbers. This is the cost (in both time and space) of performing an optimal multi-dimensional sequence alignment.
Bulbasaur
9 RBY
11 GSCRSECoXDFRLG
14 DPPtHGSSBWB2W2
1386
Ivysaur
10 RBY
13 GSCRSECoXDFRLG
16 DPPtHGSSBWB2W2
@magical
magical / sudoku.c
Last active December 30, 2015 21:09
sudoku solver
#include <stdint.h>
#include <stdio.h> /* fprintf, getchar, printf, putchar, stderr */
#include <stdlib.h> /* exit, free, malloc */
#include <string.h> /* memmove */
#define N 9
#define mask ((1<<N) - 1)
typedef uint16_t Cell;
Cell puz[N*N];