Skip to content

Instantly share code, notes, and snippets.

View jdpage's full-sized avatar
💭
random walk

Jonathan David Page jdpage

💭
random walk
View GitHub Profile
@jdpage
jdpage / FooTest.java
Created March 27, 2012 08:32
Evil Java File
import java.lang.reflect.Method;
import java.lang.reflect.Field;
public class FooTest {
static class Foo {
private int hehe = 0;
private void doSomething() {
System.out.println("Foo!");
}
@jdpage
jdpage / FooTest.java
Created March 27, 2012 08:32
Evil Java File
import java.lang.reflect.Method;
import java.lang.reflect.Field;
public class FooTest {
static class Foo {
private int hehe = 0;
private void doSomething() {
System.out.println("Foo!");
}
@jdpage
jdpage / approx.py
Created March 15, 2012 20:22
Rational Approximation Finder
from __future__ import division
from math import pi
def grader(target):
return lambda (p1, q1), (p2, q2): cmp(abs(target - p1 / q1), abs(target - p2 / q2))
def gcd(a, b):
# euclid's algorithm
while a != b:
if b < a:
@jdpage
jdpage / magfieldcurl.py
Created February 17, 2012 00:44
Magnetic field sim
from __future__ import division
from visual import *
from math import *
PROTON_CHARGE = 100
MU_ZERO = 1.256e-6
VEL = vector(.01, 0, 0) # m/s
SCALE = 20
observation_points = [vector(x * .01 - .1, .01 * cos(pi/4 * t), .01 * sin(pi/4 * t)) for x in range(20) for t in range(8)]
@jdpage
jdpage / interp-tarpit.py
Created January 29, 2012 23:49
Brainf*** interpreter
#!/usr/bin/env python
import sys
from collections import deque
SINGLE, SHIFT_LEFT_SEQ, SHIFT_RIGHT_SEQ, INC_SEQ, DEC_SEQ = range(5)
SHIFT_RIGHT = ord('>') # increment the data pointer
SHIFT_LEFT = ord('<') # decrement the data pointer
INC = ord('+') # increment the current byte
@jdpage
jdpage / linalg.py
Created September 1, 2011 21:05
Python module for vector and matrix handling
# linalg.py - vector and matrix handling
#
# Copyright 2011 Jonathan D. Page. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#