// THANK YOU! brazenly stolen from https://www.math.ucla.edu/~tom/distributions/normal.html // within the spreadsheet, of course, you can just use =NORMSDIST(X) function normalcdf(X){ //HASTINGS. MAX ERROR = .000001 var T=1/(1+.2316419*Math.abs(X)); var D=.3989423*Math.exp(-X*X/2); var Prob=D*T*(.3193815+T*(-.3565638+T*(1.781478+T*(-1.821256+T*1.330274)))); if (X>0) { Prob=1-Prob } return Prob } /** * Provides d1 for Black-Scholes. * * @param {30} DTE T-t in days to expiration […]

# Handy commit hook

I try really hard to set myself up for success in the sense that I believe in setting up my environment to discourage mistakes (poka-yoke). I’ve been known to leave Office files open while I’m working in git, and occasionally things can get confused. To wit, I present a pre-commit hook that will prevent a […]

# Detecting character encodings

This is a quick and dirty script inspired by this post, but it can definitely be a useful tool: #!/usr/bin/env python from chardet import detect from sys import argv for fn in argv[1:]: with open(fn, “rb”) as f: print(fn, detect(f.read())[‘encoding’])

# No fault go-arounds

In aviation, if you think there’s going to be a problem with a landing or a take-off, you stop, pull away, and try again. There are two somewhat conflicting quotes that I love: If you can walk away from a landing, it’s a good landing. If you use the airplane the next day, it’s an […]

# minHash implementation in PowerShell

Could not have done it without the Better Programming article. function minHash($a, $b, $shingleLength=3, [switch]$caseInsensitive=$False) { # adapted from https://betterprogramming.pub/identify-similarities-between-sentences-in-python-e9f71d454d1d function jaccardDistance($a, $b) { $toTest = [System.Collections.Generic.HashSet[string]] @($b) $intersect = [System.Collections.Generic.HashSet[string]] @($a) $intersect.IntersectWith($toTest) $union = [System.Collections.Generic.HashSet[string]] @($a) $union.UnionWith($toTest) if($union.Count -eq 0) { return $null } return $intersect.Count / $union.Count } function shingles($s, $len=3, [switch]$caseInsensitive=$False) { […]

# Installing 32-bit versions of Microsoft Office

Suppose, not entirely hypothetically, that a vendor tells you that you need 32-bit Office. With 2016 and 2019, this is not so easy. Microsoft has official docs that explain how to do it, but of course, they are outdated and no longer work. Here’s the trick: install any 32-bit Office component, and then the Office […]

# Preparing to teach CS theory

I am gearing up to teach some computer science theory. I feel well-prepared to teach the basics of discrete math: set theory, graphs, cardinalities, basic recurrences, proofs, and so on– but when considered as a whole, the subject is incredibly broad. I’m hoping to structure lectures as 75 minute periods twice a week, but the […]

# An incomplete list of my excellent teachers

It’s just about that time to get back to school, so I wanted to thank some people in my life, from preschool through to teachers in my career: Mrs. Hsu Miss Wheeler Mrs. Owens Mrs. Hood Mike Gajewski Wade Jackson Ken Drury Mr. Anderson Mr. Evans Mrs. Chilson Mr. Chilson Nancy Black Joan Twillman Leigh […]

# Brother Printers on Raspbian

It turns out that Brother doesn’t seem to be very serious about publishing driver packages that work for ARM machines. The easiest way I’ve found to deal with this so far– and still have quick, good-quality color printing– is to use the MFC-9840CDW PPD. Verified working on HL-3170CDW, MFC-8480DN, and I’ll test it on HL-2170DW […]

# Oddly missing core functions

MSSQL is terrible for lacking some seemingly straightforward functionality- like the ability to drop a table only if it exists and has no rows. Salt to taste: — TODO: accept an array of tables, check all of them for existence and zero rows, then perform drop CREATE PROCEDURE DropTableIfEmpty(@t as nvarchar(max)) AS BEGIN SELECT @t […]