Skip to content

Instantly share code, notes, and snippets.

View seansawyer's full-sized avatar

Sean Sawyer seansawyer

View GitHub Profile
@seansawyer
seansawyer / maze.py
Created September 18, 2021 11:52
Generate a maze using Kruskal's algorithm
import copy
import random
from typing import NamedTuple, FrozenSet
maze_height = 24
maze_width = 48
map_height = 50
map_width = 80
@seansawyer
seansawyer / map-touchup.html
Last active April 16, 2020 14:06
Touch up a blocky map to make it nicely drawable with line/junction tiles
<html>
<body>
<script>
var map = [
['#', '#', '#' ,'#', '#', '#' ,'#', '#', '#', '#'],
['#', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', '#'],
['#', ' ', ' ', '#', '#', ' ', ' ', ' ', ' ', '#'],
['#', '#', '#', '#', '#', ' ', ' ', ' ', ' ', '#'],
['#', ' ', '#', ' ', '#', '#', '#', '#', '#', '#'],
['#', ' ', '#', ' ', '#', ' ', ' ', ' ', ' ', '#'],
@seansawyer
seansawyer / graphics_boilerplate.py
Last active March 8, 2020 15:34
Roguelike Development in Python
import tcod
import tcod.event
tcod.console_set_custom_font(
'arial10x10.png',
tcod.FONT_LAYOUT_TCOD | tcod.FONT_TYPE_GREYSCALE,
)
with tcod.console_init_root(
CONSOLE_WIDTH,
@seansawyer
seansawyer / fsm-game-skeleton.py
Last active January 16, 2020 16:19
Boilerplate for a roguelike implemented as an FSM using libtcod
from dataclasses import dataclass
from enum import Enum
from typing import Callable, Dict, Optional, Tuple
import tcod
import tcod.event
@dataclass
class Game:
@seansawyer
seansawyer / reviewers.py
Created October 15, 2018 14:02
Randomly choose some teammates for code review, etc.
"""Randomly choose a list of teammates for code review, etc."""
from argparse import ArgumentParser
from getpass import getuser
from itertools import combinations
from random import randint
parser = ArgumentParser(description=__doc__)
parser.add_argument('--email',
@seansawyer
seansawyer / README.md
Last active May 2, 2018 14:27
A Brief History of Algorithmic Composition

A Brief History of Algorithmic Composition

One of the most often cited examples of algorithmic music in the Classical Period (1750-1827) is Musikalisches Würfelspiel by Wolfgang Amadeus Mozart (1756-1791). In this composition, Mozart composed discrete musical excerpts that could be combined to form a waltz. The order of musical excerpts was determined by rolling two six-sided dice. The person assembling the waltz would refer to a table created by Mozart that showed which music should be used for the values of 2-12 on the dice.

Works

After Wagner, there was pretty much nothing new that could be done with tonal composition. So music hipsters everywhere were distraught, and looking for a way to push composition and music theory in general forward. The answer came from Arnold Schoenberg and his followers in the early 20th century in the form of serial composition. Serial composition introduced a set of rules for composition that arguably served to birth algorithmic composition as we know it today.

Ly

@seansawyer
seansawyer / script.md
Last active February 22, 2017 16:41
Retrospective: Laurie Anderson

Retrospective: The Music and Stories of Laurie Anderson

Spotify playlist

Good morning everyone, Sean here. Welcome to Retrospective.

Today we're going to wander through the work of not only a great musician, but also a great storyteller, and in my opinion one of the great American poets: Laurie Anderson.

@seansawyer
seansawyer / c-tools.md
Last active February 26, 2016 03:27
Various Helpful C Tools

Print all libs loadable at runtime

ldconfig -p
# 208 libs found in cache `/etc/ld.so.cache'
#     libz.so.1 (libc6,x86-64) => /lib64/libz.so.1
#     libz.so (libc6,x86-64) => /usr/lib64/libz.so
# ...

Print all libs loadable at compile time

@seansawyer
seansawyer / comm.txt
Last active February 8, 2016 21:48
Find numbers in two files full of 10 million random positive integers
$ time shuf -i 1-4294967296 -n 10000000 | sort | uniq - sorted1.txt
real 0m21.387s
user 0m22.700s
sys 0m0.820s
$ time shuf -i 1-4294967296 -n 10000000 | sort | uniq - sorted2.txt
real 0m21.230s
user 0m22.417s
sys 0m0.703s
@seansawyer
seansawyer / coolness.sh
Created January 15, 2016 18:50
Cool Shell Things
# Meta Man
man man
# When your last commit has some garbage author info - maybe you committed in a VM or something
git commit --amend --reset-author
# Sudo do the last thing I said
sudo !!
# Remove an item from your history - maybe you typed your password by accident