Skip to content

Instantly share code, notes, and snippets.

@darkf
darkf / game.py
Created May 18, 2012 20:32
Terrible text-based RPG
import random
def say(msg):
print ":", msg
def rnd(min, max):
return random.randint(min, max)
class Player:
def __init__(self):
@darkf
darkf / derp.txt
Created May 17, 2012 02:45
Another terrible game object DSL
# Objects are values with at least the methods {init, update, draw}.
# state describes properties shared by all game states.
# game states can transition into others, or call methods by others.
# there is a global event system that can emit (dispatch) events (by string), and catch (observe) them.
state {
player : player
objects : [Object]
}
@darkf
darkf / ddrdd.txt
Created May 7, 2012 02:59
Data-driven rougelike description DSL
merchant Tom
inventory: 3x Pistol Rounds @ $5, 1x SMG Rounds @ $10
on talk {
say "Hello! Welcome to Tom's Ammunition Supply!"
}
end
enemy Boar
inventory: 1x Boar Meat
@darkf
darkf / main.fs
Created April 30, 2012 01:09
Very simple type generator (annotates ASTs with approximate types)
module Prog
type Node = Call of string * Node * Node
| Str of string
| Int of int
| Binop of string * Node * Node
type Type = FunType of Type * Type
| StrType
| IntType
@darkf
darkf / vm.txt
Created April 27, 2012 23:39
VM Architecture
PC:
- 1024x768 VGA device; stored in memory from 0x00000000 to 0x00300000 (3,145,728 i.e. 1024x768 @ 32 bpp)
- BIOS using interrupt 0; has text rendering capabilities, among other things
RAM:
- Dynamically sized - default is 32mb
- Smallest addressable unit is the byte (8 bits)
- Address from VRAM's end to the next 16mb is stack space
- Memory from stack's end to the next 4096 bytes is reserved for the ROM (e.g. bootloader)
- Rest of address space is contiguous
@darkf
darkf / build_index.py
Created April 24, 2012 02:33
Very basic text indexer/searcher in Python
import sys, os, glob, re, pickle
if len(sys.argv) != 2:
print "USAGE: %s DIR" % sys.argv[0]
sys.exit(1)
INDEX = {}
FILES = []
for path,_,dirs in os.walk(sys.argv[1]):
@darkf
darkf / short.py
Created April 11, 2012 04:36
nanoshorten
# nanoshorten - a very tiny URL shortener Web application written in Bottle and sqlite
# copyright (c) 2012 darkf
# licensed under the WTFPL (WTF Public License)
# see http://sam.zoy.org/wtfpl/ for details
from bottle import get, request, run
import sqlite3, random, string
con = sqlite3.connect('short.db')
c = con.cursor()
@darkf
darkf / main.fs
Created March 17, 2012 06:40
calculus assignment bs
(* Take a tree of expressions in and output the expression tree of the differentiation of it. (or something like that.)
Copyright (c) 2012 darkf
MIT license
*)
(* Assignment: http://pastebin.com/tiRVsxNx
Graphs: http://f.imgtmp.com/FOVY7.jpg
*)
type Node =
@darkf
darkf / p.py
Created March 8, 2012 22:14
Codegolf!
# copyright 2012 darkf
import sys;_,s,h=sys.argv;[open(x,'w').writelines([y for y in open(h)if x.strip()in y])for x in open(s)]
@darkf
darkf / web-dsl-spec.txt
Created February 29, 2012 01:02
Web DSL for Possum, WIP
html
body {
p "hi there"
h1 ":)"
}