Skip to content

Instantly share code, notes, and snippets.

View michaelcmartin's full-sized avatar

Michael C. Martin michaelcmartin

View GitHub Profile
@michaelcmartin
michaelcmartin / derez.py
Created November 28, 2018 00:57
Classic Mac resource fork decoder
#!/usr/bin/python
import sys
import struct
resfile = file(sys.argv[1]).read()
(dataoffset, mapoffset, datalen, maplen) = struct.unpack(">4I", resfile[:16])
print "Data: %d bytes at %d" % (datalen, dataoffset)
print "Map: %d bytes at %d" % (maplen, mapoffset)
@michaelcmartin
michaelcmartin / mlx.py
Created May 10, 2015 22:53
A simple Python utility to generate MLX listings
#!/usr/bin/python
# mlx.py - convert a .PRG program into an MLX listing.
# By default it uses the MLX 1 format (7 decimals per line), but
# the -2 option will use the MLX 2 format (9 hexadecimals per line).
import sys
def mlx1_encode(code, start_address):
while len(code) % 6 != 0:
@michaelcmartin
michaelcmartin / model.clj
Created May 21, 2012 00:21
Computational core of the 'king' game.
(ns king.model)
(defn year-prices
"Returns an update structure with new prices for land and farming."
[]
{:landvalue (+ 95 (rand-int 11))
:plantcost (+ 10 (rand-int 6))})
(defn initial-stats
"Produces an initial state, which is the Year 1 initial position."