Skip to content

Instantly share code, notes, and snippets.

View ecounysis's full-sized avatar

Eric Christensen ecounysis

View GitHub Profile
#light
open System.Text.RegularExpressions
let minify js =
let replace (m:string) (r:string) (s:string) = Regex.Replace(s, m, r)
js
|> replace "\n\f" " "
|> replace "\n" " "
|> replace "\s{2,}" " "
|> replace "\{ " "{"
(define-syntax let2
(syntax-rules ()
[(_ ((var val) ...) (exp ...))
((lambda (var ...) (exp ...)) val ...)]))
(define-syntax let2*
(syntax-rules ()
[(_ ([x1 v1]) e ...) (let2 ([x1 v1]) e ...)]
[(_ [(x1 v1) (x2 v2)] (e ...))
(define pascal
(lambda (x)
(letrec ([last
(lambda (x)
(if (null? (cdr x)) x (last (cdr x))))]
[sum-two
(lambda (x)
(+ (car x) (cadr x)))]
[sum-doubles
(lambda (x)
(define (+ a b)
(if (= a 0)
b
(inc (+ (dec a) b))))
(define (+ a b)
(if (= a 0)
b
(+ (dec a) (inc b))))
(define (p) (p))
(define (test x y)
(if (= x 0)
0
y))
(define even?
(lambda (x)
(cond ((= x 0) #t)
(else (odd? (- x 1))))))
(define odd?
(lambda (x)
(cond ((= x 0) #f)
(else (even? (- x 1))))))
@ecounysis
ecounysis / LICENSE.txt
Created March 30, 2010 17:11
Black-Scholes Option Pricing Model
Copyright (C) 2011, Eric Christensen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@ecounysis
ecounysis / bs.scm
Created April 5, 2010 02:33
Implementation of Black Scholes option pricing model using Scheme
(define black-scholes
[letrec (
[normal (lambda (zz)
(if (= zz 0) 0.5
[let ((p 0.2316419) (b1 0.31938153) (b2 -0.356563782) (b3 1.781477937)
(b4 -1.821255978) (b5 1.330274428)
(f (/ 1 (sqrt (* 2 3.1415926))))
(abszz (abs zz)))
[let ((ff (* f (exp (/ (- (expt abszz 2)) 2))))
(s1 (/ b1 (+ 1 (* p abszz))))
#light
open System
let conc ls :string =
if List.length ls = 0 then ""
else List.reduce (fun x y -> x + y) ls
let av_chars = ["0"; "1"; "2"; "3"; "4"; "5"; "6"; "7"; "8"; "9"; "A"; "B"; "C"; "D"; "E"; "F"; "G"; "H"; "I"; "J"; "K"; "L"; "M"; "N"; "O"; "P"; "Q"; "R"; "S"; "T"; "U"; "V"; "W"; "X"; "Y"; "Z"; "a"; "b"; "c"; "d"; "e"; "f"; "g"; "h"; "i"; "j"; "k"; "l"; "m"; "n"; "o"; "p"; "q"; "r"; "s"; "t"; "u"; "v"; "w"; "x"; "y"; "z";]
let special_chars = ["!"; "#"; "$"; "%"; "&"; "*"; "+"; "-"; "_"; "?"; "@";]
import httplib, os, urllib, base64, datetime
folder = <<workfolder>>
url = "posterous.com"
user = <<userid>>
def file_contents(filename):
readfile = open(folder + "\\" + filename, 'r')
date = readfile.readline().strip('\n')
content = readfile.read()