Skip to content

Instantly share code, notes, and snippets.

// Old Test Files
foo.bar.baz = function() {
window.setUp = function() {
// Set up
}
window.testFoo = function() {
// A test
}
@campaul
campaul / dywypi_setup
Last active August 29, 2015 13:57
Setting up dywypi
Be in your virtualenv first
Clone dywypi somewhere outside your project
git clone https://github.com/eevee/dywypi.git
cd into dywypi
do `python setup.py develop`
dywypi is now installed for your virtualenv. You can update it by coming back to this directory and doing `git pull`
cd into your porject
@campaul
campaul / pandemic.md
Last active August 29, 2015 13:57
Rules for Pandemic IRC Game

Yelpidemic Rules

Setup

When the game starts, all players are either healthy or infected. 1/6th of players will start infected. All players start with 0 antidotes.

Actions

Actions can be performed by sending messages to the bot.

status

Do yelpidemic status to have the bot private message your status to you.

import random
# The die
class d(object):
def __init__(self, sides):
super(d, self).__init__()
self.sides = sides
def __mul__(self, rolls):
@campaul
campaul / raw_bucketer.py
Created June 8, 2014 19:44
Bucket CR2 files by date
from datetime import datetime
from os import walk
import sys
from wand.image import Image
def get_bucket(filename):
date = get_date(get_exif(filename)['DateTimeOriginal'])
return (str(date), filename)
@campaul
campaul / http-server.rs
Created July 1, 2014 00:08
First attempt at responding to HTTP
use std::io::{Acceptor, Listener};
use std::io::net::tcp::TcpListener;
use std::io::net::ip::SocketAddr;
use std::from_str::from_str;
use std::io::File;
use std::io::IoError;
use std::io::{BufferedReader, BufferedWriter};
fn read_file(path: Path) -> Result<~str, IoError> {
let mut file = match File::open(&path) {
@campaul
campaul / synth.c
Created July 25, 2014 06:22
Blind attempt at controlling the frequency of a 555 timer
int pin = 0; // The pin we will read the audio signal from
volatile int last = 0; // The time of the last sample
volatile int expected = 2272; // Roughly 440Hz
volatile int data = 0; // The direction to change the digi-pot
void setup() {
pinMode(pin, INPUT);
last = micros();
attachInterrupt(0, adjust, FALLING);
@campaul
campaul / tilt_eq_frequency.py
Created August 27, 2014 06:17
Calculate the Pivot Frequency of a Tilt Equalizer
from math import pi, sqrt
# Part labels based on the schematic from
# http://www.edn.com/design/analog/4368935/Implement-an-audio-frequency-tilt-equalizer-filter
RF = float(input('RF: '))
P1 = float(input('P1: '))
C = float(input('C: '))
R = float(input('R: '))
pivot = sqrt(P1 + 2 * RF) / (2 * pi * C * sqrt(RF - R) * sqrt(P1 * (R + RF) + 2 * R * RF))
@campaul
campaul / gist:d15833a5a5f0f5712ac3
Created November 4, 2014 17:25
Enabling interrupts without an interrupt enable instruction
push INTENABLE
icall
push DONE
ret
INTENABLE:
iret
DONE:
@campaul
campaul / octave-isa
Last active August 29, 2015 14:08
Octave ISA
========
Core ISA
========
000 : Jump MEM[RS] NZP (previous operation)
This is a relative jump.
0010 : LoadIH R0 <- I (Load 4 bit immediate into R0 lower bits)
0011 : LoadIL R0 <- I (Load 4 bit immediate into R0 upper bits)
0100: Add RD <- RD + RS