Skip to content

Instantly share code, notes, and snippets.

View sixthgear's full-sized avatar

Joshua Cender sixthgear

View GitHub Profile
"""
Simple python dice module.
By sixthgear <sixthgear@sixthgear.ca>
"""
import random
import fractions
import itertools
class Dice(object):
--------------------------------------------------------------
DoomRL (v.0.9.9.6G) roguelike post-mortem character dump
--------------------------------------------------------------
sixthgear, level 5 Human Private Marine,
was splayed by a hell knight on level 7 of the Phobos base.
He survived 46728 turns and scored 16092 points.
He played for 51 minutes and 15 seconds.
He didn't like it too rough.
//The sum of the squares of the first ten natural numbers is,
//12 + 22 + ... + 102 = 385
//The square of the sum of the first ten natural numbers is,
//(1 + 2 + ... + 10)2 = 552 = 3025
/*Hence the difference between the sum of the squares of the first ten
natural numbers and the square of the sum is 3025 − 385 = 2640.*/
/*Find the difference between the sum of the squares of the first one
size_t
func(short a[])
{
return sizeof(a);
}
int
main()
{
short arr[10];
@sixthgear
sixthgear / 1984_words.txt
Created December 23, 2011 18:54
1984 words
# 0.06s user 0.00s system 75% cpu 0.081 total
astronomical: 1
but: 627
commanded: 1
blazed: 1
buy: 9
finally: 19
whenever: 14
regulation: 2
@sixthgear
sixthgear / vect.h
Created December 21, 2011 22:14
Generic Vector Type in C
#ifndef VECT_H
#define VECT_H
/*
* vect.h -- type-safe generic dynamic array
* made by sixthgear. BSD Licenced.
*/
#include <stdio.h>
#include <stdlib.h>
@sixthgear
sixthgear / hash.c
Created December 21, 2011 04:05
Generic Hash Table
#include "hash.h"
table *
ht_init(int num, size_t type_size, int key_len, void *hf, void *pf)
{
size_t total_size;
total_size = sizeof(table); /* table */
total_size += sizeof(char) * num * key_len; /* keys */
total_size += (type_size * num); /* values */
table *ht = malloc(total_size);
#!/usr/bin/env python
"""
Usage: ./fxuy.py [f] [u]
Example: ./fxuy.py 7 12
Requires: banner or printerbanner
"""
import os
import sys
import subprocess
import itertools
import fractions
def roll(faces, dice, keep):
results = {}
denom = faces ** dice
for roll in itertools.product(*[range(1,faces+1) for d in range(dice)]):
r = sum(sorted(roll, reverse=True)[:keep])
if not results.has_key(r): results[r] = fractions.Fraction(1, denom)
var events = [];
var intervals = [];
var max_id = 0;
function setInterval(callback, period) {
intervals.push(new Interval(callback, period));
return ++max_id;
}
function clearInterval(id) {