Skip to content

Instantly share code, notes, and snippets.


Steve Hanov smhanov

View GitHub Profile
View index.html
<!DOCTYPE html>
<h1>Hello world!</h1>
<script src="test.js"></script>

The first file

This is the first file in the gist.

smhanov / TrueType.ts
Last active Jul 28, 2022
Here is my implementation of a TrueType font reader in Typescript. You can read a font directly from an ArrayBuffer, and then call drawText() to draw it. See my article
View TrueType.ts
// By Steve Hanov
// Released to the public domain on April 18, 2020
//import { log } from "./log"
// Usage:
declare let arrayBuffer:ArrayBuffer;
smhanov /
Last active Jul 26, 2022
Pipeline multiprocessing for python with generators

Pipeline multiprocessing in Python with generators

Similar to mpipe, this short module lets you string together tasks so that they are executed in parallel.

The difference is that it lets you use generators, functions which yield results instead of returning them. Each yielded item gets passed to the next stage.

You can specify that one or more copies of the workers operate on the input queue.

Things that can be in a stage

#!/usr/bin/env python3
import time
import sys
# Python by Steve Hanov
# Suffix array construction from:
# From Ge Nong, Sen Zhang and Wai Hong Chan, Two Efficient Algorithms for Linear Suffix Array Construction, 2008
# longestMatches from:
# Released to the public domain.
class SuffixArray:
View Heap.js
// By Steve Hanov (2014)
// Released to public domain
// Minimum element is always on top.
// You can pass in an optional lessThan(a, b) function to the constructor.
// You may use .length to retrieve the length. Try not to set it though.
function Heap()
if (arguments.length) {
smhanov /
Last active Jul 19, 2022
Use a DAWG as a map
# By Steve Hanov, 2011. Released to the public domain.
# Please see for the accompanying article.
# Based on Daciuk, Jan, et al. "Incremental construction of minimal acyclic finite-state automata."
# Computational linguistics 26.1 (2000): 3-16.
# Updated 2014 to use DAWG as a mapping; see
# Kowaltowski, T.; CL. Lucchesi (1993), "Applications of finite automata representing large vocabularies",
# Software-Practice and Experience 1993