Skip to content

Instantly share code, notes, and snippets.

View milesrout's full-sized avatar

Miles Rout milesrout

View GitHub Profile
@milesrout
milesrout / struct.py
Last active August 29, 2015 14:04
struct
def __make_init(*argnames):
def __init__(self, *args):
expected = len(argnames)
actual = len(args)
if expected != actual:
s = '' if expected == 1 else 's'
raise TypeError("__init__() takes exactly {expected} argument{s} ({actual} given)".format(**locals()))
for (arg, argname) in zip(args, argnames):
setattr(self, argname, arg)
return __init__
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
alias ls='ls --color=auto'
# Play a directory
cat pacman.log | grep ' installed' | cut -d ' ' -f 5 | uniq | wc -l
for directory in $(ls -lAFp | grep '/' | sed 's/\///' | cut -f 2 --d ':' | cut -f 2 --delim ' '); do cd $directory; echo -n "$directory "; sudo find | wc -l; cd ..; done
find . -name "*.[ch]" | xargs etags -o ~/.tags/TAGS
pavucontrol
syntax on
nnoremap ; :
nnoremap : ;
" Sane auto-completion
set wildmode=list:longest,longest
" Set working directory to the current file automatically
set autochdir
@milesrout
milesrout / 01-let-and-where.hs
Last active November 23, 2017 00:09
The ? language.
-- ? doesn't have statements, it has sentences.
-- sentences end with a full stop, as everyone knows.
-- every expression can be a sentence.
let a = 1.
-- let expressions look like this:
-- `'let' VARIABLE '=' EXPRESSION (',' VARIABLE '=' EXPRESSION)* ('and' VARIABLE '=' EXPRESSION)?`
let b = 2 and c = 3.
let d = 4, e = 5 and f = 6.
let g = 7, h = 8.
data Natural = Zero | Succ Natural
add :: Natural -> Natural -> Natural
add Zero b = b
add (Succ a) b = add a (Succ b)
mul :: Natural -> Natural -> Natural
mul Zero _ = Zero
mul _ Zero = Zero
mul (Succ a) b = add b (mul a b)
@milesrout
milesrout / gist:6a3a2d2a1a569d5c8073
Last active January 8, 2017 21:46
My vision document for Trillek
Vision for Trillek
==================
This is my vision for Trillek. This is intentionally brief: it's not a
design document.
Pillar #1: Multiplayer
----------------------
Trillek is primarily a multiplayer game. It will have a singleplayer
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <pthread.h>
#include "html.h"
@milesrout
milesrout / fpu.md
Last active August 29, 2015 14:08

In the following, $xxx represents a memory location and %xxx represents a register. dst represents a destination, src represents a source, lft represents the left-hand argument of a binary operation, rgt represents the right-hand argument of a binary operation, arg represents the only argument of a unary operation,

l          $addr, %reg
st         %reg, $addr

add        %lft, %rgt, %dst
sub        %lft, %rgt, %dst
mul        %lft, %rgt, %dst

div %lft, %rgt, %dst

@milesrout
milesrout / 1.dfpu17.txt
Last active November 1, 2017 12:14
DFPU-17
A Floating Point Unit for the DCPU-16
This is a short document describing the DFPU-17 (D17), a
floating-point coprocessor for the DCPU-16 (D16). Despite its
simplicity, the DCPU-16 provides significant
functionality. However, a significant problem is its lack of
high-throughput floating-point support. The D17 exists to solve
this problem.
DCPU-16 Hardware Info: