Skip to content

Instantly share code, notes, and snippets.

@vorandrew
vorandrew / blackscholes.js
Created September 4, 2012 16:44 — forked from joaojeronimo/blackscholes.js
Black-Scholes in Javascript: A rewrite of http://www.espenhaug.com/black_scholes.html
/*
PutCallFlag: Either "put" or "call"
S: Stock Price
X: Strike Price
T: Time to expiration (in years)
r: Risk-free rate
v: Volatility
This is the same one found in http://www.espenhaug.com/black_scholes.html
but written with proper indentation and a === instead of == because it's
@gavinandresen
gavinandresen / sigop_sighash_count.md
Last active January 28, 2021 09:13
sigop/sighash counting

The consensus protocol limits on blocks are:

1 million or fewer bytes canonically-serialized size. 20,000 or fewer "sigops"

Unfortunately, Satoshi implemented those as quick fixes with zero code review and little testing (Bitcoin was not a Big Deal back then, it was the right decision at the time), and the way sigop counting is done is... well, just wrong.

Here's how Satoshi did it, as pseudo-code (see GetLegacySigOpCount in main.cpp for actual code):

For all the transactions in a block:

@tgoldenberg
tgoldenberg / segment-analytics.m
Last active May 9, 2018 23:35
Segment Analytics for React Native
# AppDelegate.m
#import <Analytics/SEGAnalytics.h>
[SEGAnalytics setupWithConfiguration:[SEGAnalyticsConfiguration configurationWithWriteKey:@"YOUR_ANALYTICS_KEY_HERE"]];
# AnalyticsHelper.h
#import "RCTViewManager.h"
#import "RCTBridgeModule.h"
@tgoldenberg
tgoldenberg / bondsVersusStocks.md
Last active June 2, 2017 22:47
Bonds vs. Stocks
Stocks Vs. Bonds 1926-2003 1802-2003
Stocks - Annual Rate of Return 12.7% 8.3%
Bonds - Annual Rate of Return 5.4% 4.9%
Stocks - Multiplier 2285x 8,800,000x
Bonds - Multiplier 61x 2285x
@tgoldenberg
tgoldenberg / shares.md
Created June 3, 2017 01:42
Current portfolio of ETFs
ticker quantity unit price
VTI (US Stock Market) 50 shares $120
VEA (Foreign Developed Markets) 5 shares $30
VWO (Foreign Emerging Markets) 5 shares $30
TRE (Treasury bonds) 20 shares $100