Skip to content

Instantly share code, notes, and snippets.

View milesrout's full-sized avatar

Miles Rout milesrout

View GitHub Profile
@milesrout
milesrout / DMA.txt
Last active August 29, 2015 14:00 — forked from Zardoz89/DMA.txt
There are two types of interaction between devices and memory:
- Passive read
- Copy from RAM to device
- Copy from device to RAM
Passive reads work by "watching" the data/address bus when the CPU (or
other device) is writing to the RAM. Could keep sync a device internal
memory/buffer respect the changes that happens in these memory
block. This is simply implemented, reading the desired RAM block with
VComputer.RAM(). If a device does passive read to keep sync his
DCPU-16 Specification
Copyright 1985 Mojang
Version 1.7
=== SUMMARY ====================================================================
* 16 bit words
* 0x10000 words of ram
#define GL_GLEXT_PROTOTYPES
#include <GLFW/glfw3.h>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <fstream>
#include <iostream>
using namespace std;
template <typename T, typename = typename std::enable_if<std::is_floating_point<T>::value, void>::type>
constexpr T pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798;
int main()
{
float radiusf;
DCPU-16 Specification
Copyright 1985
Version 1.7
=== SUMMARY ====================================================================
* 16 bit words
* 0x10000 words of ram
* 8 registers (A, B, C, X, Y, Z, I, J)
* program counter (PC)
# Determine whether, in any state, the expected chosen prize is greater than the maximum prize
from itertools import combinations
from math import log, exp
cases = {1,10,100,1000}
maxprize = 200
s = set.union(*[set(combinations(cases, i)) for i in range(1, len(cases)+1)])
ss = sorted(s)
@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