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’])
Author: Frank
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 […]
Strong self-signed SSL certificates for development on IIS
openssl req -newkey rsa:4096 -nodes -keyout key.pem -x509 -days 3650 -out certificate.pem -sha256 openssl x509 -text -noout -in certificate.pem openssl pkcs12 -inkey key.pem -in certificate.pem -export -out certificate.pfx openssl pkcs12 -in certificate.pfx -noout -info Links: Generating a self-signed certificate using OpenSSL Generate an OpenSSL Certificate Request with SHA256 Signature Create a .pfx/.p12 certificate file using […]
Splitting LDIF files
I went to the St. Louis PowerShell meetup last night, and someone had an interesting issue. They were dealing with a 4.5 gigabyte LDIF file- it needed to be somehow processed, and the issue of processing had already been dealt with. However, it turns out that PowerShell wasn’t cranking fast enough for the application. Most […]