Skip to content

Instantly share code, notes, and snippets.

@kanzure
kanzure / main.cpp
Created February 4, 2013 19:34
ayoungprogrammer-equation-ocr
/*
http://ayoungprogrammer.blogspot.ca/2013/01/part-3-making-ocr-for-equations.html
Equation OCR
*/
#include <iostream>
#include <baseapi.h>
@kanzure
kanzure / pc-trail.clj
Created February 25, 2013 22:57
pc-trail
(defn pc-trail
"Track the PC for a number of ticks."
[state ticks]
(tick state)
(set-state! state)
(loop [pcs [(PC)] ]
(if (> (count pcs) ticks) pcs
(do
(com.aurellem.gb.Gb/tick)
(recur (conj pcs (PC)))))))
@kanzure
kanzure / helpers.clj
Created February 25, 2013 23:05
vba-clojure-helpers
(defn first-change
"Watch the current memory location as it ticks,
return the first state that differs at location mem."-
[state n]
(tick state)
(set-state! state)
(let [init (aget (memory state) n)]
(loop []
(if (= (aget (memory) n) init)
(do
@kanzure
kanzure / vba-clojure.c
Created February 26, 2013 01:22
vba-clojure bug?
// let the player control the game until he decides he hates it. This is particularly useful for playing from the repl.
void stepUntilCapture() {
while (currentButtons[0] != 2048) {
/* if (currentButtons[0] != 0) {
printf("currentButtons[o] is %d\n", currentButtons[0]);
} */
step();
}
// reset the buttons so that this function can be called in the future
@kanzure
kanzure / vbawarp.py
Created February 28, 2013 08:36
vba-warping
import vba
vba.load_rom()
# load my favorite state
vba.set_state(vba.load_state("mom-speech-1-before"))
# set warp memory
vba.set_memory_at(0xdcb5, 0x1)
vba.set_memory_at(0xdcb6, 0x1)
vba.set_memory_at(0xdcb8, 0x1)
@kanzure
kanzure / vba-tilemap.py
Created March 1, 2013 00:35
vba-tilemap
import vba
vba.load_rom()
vba.set_state(vba.load_state("talking-with-npc"))
vba.step()
tiles = vba.get_memory_range(0xc4a0, 1000)
from chars import chars
output = ""
@kanzure
kanzure / call.vba.py
Created March 1, 2013 05:56
vba-call
def call(bank, address):
"""
Jumps into a function at a certain address.
"""
registers = get_registers()
push = [
registers[0],
registers[5],
registers[4],
@kanzure
kanzure / pbase.py
Created April 15, 2013 04:22
pbase crawler
# -*- coding: utf-8 -*-
import requests
import lxml.etree
from StringIO import StringIO
def parse_html(content):
"""
A possibly safer way to parse HTML content with lxml. This will presumably
not break on poorly formatted HTML.
"""
@kanzure
kanzure / ncbi.py
Created April 18, 2013 19:01
Cathal's NCBI ftp server size calculator
# --- Python code ensues
# Requires requests and beautiful soup four: install using
# "sudo pip-3.2 install bs4 requests" (preferably with "lxml" too)
import requests
import bs4
refseq_ftp = "http://ftp.ncbi.nih.gov/refseq/release/microbial/"
genomes = requests.get(refseq_ftp)
link_and_size = []
for x in genomes.text.splitlines():
@kanzure
kanzure / git-commit-cleaner.py
Last active May 17, 2022 17:25
git-filter-branch examples and notes
"""
Creates pretty-looking commit messages for git. This was created to pretty
print the old-commit-id values for filter-branched-rewritten commits in
pyphantomjs from the phantomjs repository.
"""
import os
import sys