Skip to content

Instantly share code, notes, and snippets.

View ecounysis's full-sized avatar

Eric Christensen ecounysis

View GitHub Profile
@ecounysis
ecounysis / VbaUnit.bas
Created May 9, 2011 02:14
Unit Tests for VBA
Sub Test(Assertion As Boolean, Description As String)
ActiveCell.Value = Description
If Assertion Then
With Selection.Interior
.ColorIndex = 10
.Pattern = xlSolid
End With
Else
(define mycons
(lambda (x y)
(lambda (m) (m x y))))
(define (mycar x)
(x (lambda (p q) p)))
(define (mycdr x)
(x (lambda (p q) q)))
var callback = function(msg) {
alert(msg);
}
var funcList = [];
var vals = ['do', 're', 'mi'];
for(var m in vals) {
funcList[m] = function() {
callback(m);
@ecounysis
ecounysis / ll.c
Created February 11, 2011 06:32
My first attempt at building a linked list in C that actually compiles and works
#include <stdlib.h>
#include <stdio.h>
#include "ll.h"
LL *createlist(int item)
{
LL *it = malloc(sizeof(LL));
it->val = item;
printf("creating new LL@%p whose value is %d\n", it, item);
return it;
@ecounysis
ecounysis / jalert.js
Created December 18, 2010 06:57
jQuery UI plugin for themed alerts and dialogs
/*
* jalert jQuery JavaScript Plugin v0.0.1
*
* Copyright 2010, Eric Christensen
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of the copyright holder not be used in
@ecounysis
ecounysis / closure_recursion_1.js
Created November 25, 2010 19:24
Closures and Recursion in JavaScript
var SlideChanger = function(seconds_each) {
var index = -1;
// on the first cycle, index will be set to zero below
var maxindex = ($(".change_link").length) - 1;
// how many total slides are there (count the slide buttons)
var timer = function() {
// this is the function returned by SlideChanger
var logic = function() {
// this is an inner function which uses the
// enclosed values (index and maxindex) to cycle through the slides
@ecounysis
ecounysis / circuits.py
Created October 21, 2010 05:52
modeling different types of circuits for fun
class Circuit:
"""Base class for modeling circuits"""
_type="Circuit"
def __init__(self,a,b):
self.set(a,b)
def __repr__(self):
return str(self)
def cond(self, e, r1, r2):
if e:
return r1
#include <stdio.h>
#include <stdlib.h>
double stack[100];
char buffer[100];
int isDot(char);
int handle(char);
int ptr=0;
int bufptr=0;
#include <stdio.h>
#define BUFFER_SIZE 2
enum FLAGS {NONE, SLASH, COMMENT1, COMMENTM, QUOTE1, QUOTE2, COMMENTM_STAR};
char buffer[BUFFER_SIZE];
int buff_pointer = 0;
void flush(char buff[]);
int state = NONE;
char t;
@ecounysis
ecounysis / black.scm
Created August 22, 2010 21:48
Black-Scholes Option Pricing Model in Scheme
(define new-pi 3.1415926)
(define days-in-year 365)
(define (sqrt-t days-to-expiration)
(sqrt (/ days-to-expiration days-in-year)))
(define (normal-dist zz)
(if (= zz 0) 0.5
[let ((p 0.2316419) (b1 0.31938153) (b2 -0.356563782)