Skip to content

Instantly share code, notes, and snippets.

View ecounysis's full-sized avatar

Eric Christensen ecounysis

View GitHub Profile
(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)))
@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
//&>/dev/null;x="${0%.*}";[ ! "$x" -ot "$0" ]||(rm -f "$x";cc -o "$x" "$0")&&"$x" $*;exit
#include <stdio.h>
int main() {
char c;
while ((c = getchar()) != EOF)
putchar(c);
return 0;
}
@ecounysis
ecounysis / binsearch.c
Created June 22, 2011 15:01
Attempting to solve K&R exercise 3-1
#include <stdio.h>
#include <stdlib.h>
int binsearch1(int, int[], int);
int binsearch2(int, int[], int);
int main(int argc, char *argv[])
{
int size = atoi(argv[2]);
@ecounysis
ecounysis / bml.js
Created June 22, 2011 15:11
Bookmarklet to view embed from github
javascript:(function() {document.write('<script src="https://gist.github.com/1040276.js"> </script>') })()
// why not just do this?
@ecounysis
ecounysis / hackernews.pl
Created July 11, 2011 02:00
console tool for reading Hacker News
#!/usr/bin/env perl
use JSON;
use strict;
no warnings;
use HTML::Entities;
my $command = @ARGV[0];
my $home = $ENV{'HOME'};
if (not (-e "$home/.hn")) {
#!/usr/bin/env python
def twodigits(st):
g = st[2:]
if (len(g) == 1):
g = '0' + g
return g.upper()
def n2h(n):
r = hex(n)
@ecounysis
ecounysis / black-scholes.vb
Created July 20, 2011 16:44
Black Scholes VBA module
Option Explicit
Private Function n(strike As Double, s As Double, sd As Double, r As Double, days As Double) As Double
Dim ls, lx, sd2, t As Double
ls = Log(s)
lx = Log(strike)
t = days / 365
sd2 = pow(sd, 2)
n = ls - lx + r * t + sd2 * t / 2
End Function
@ecounysis
ecounysis / gist.py
Created July 20, 2011 17:15
A Gist for Displaying Gists
import cgi
print "Content-Type: text/html"
print
form = cgi.FieldStorage()
if 'g' not in form:
out = ""
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
source $VIMRUNTIME/eric_custom.vim
behave mswin
set ff="unix"
set encoding=utf-8
set nobinary