Skip to content

Instantly share code, notes, and snippets.

@creachadair
creachadair / test.c
Created December 12, 2018 17:03
Closing Unix domain sockets does not clean up the socket path
/*
gcc -std=c99 -o test test.c
./test foobar
*/
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
@creachadair
creachadair / docker-volumes.md
Last active March 8, 2019 15:26
Notes on volumes and mountpoints in Docker

Notes on Volumes and Mountpoints

The following are some lessons I've learned from stumbling around with volumes and mountpoints in Docker. At the outset let me be clear that there is no new information here -- everything described below can be found in the user documentation in one form or another. However, I spent a bunch of time screwing things up for lack of context, so I am recording some of my lessons here so I can find them again.

The Old and the New

There are broadly two ways external filesystems can be attached to a container:

  1. As a pass-through to an existing filesystem on the host. This is what Docker calls a "bind mount", and it basically
@creachadair
creachadair / enumerations.go
Last active May 28, 2019 14:47
A mechanism for representing enumerations in Go
// See also: https://play.golang.org/p/2Bbde-p2MBx
package enum
import "fmt"
// A common way to represent enumerations in Go is to define a type
// whose structure is int, char, string, bool, etc. That has the
// virtue of being simple, but has some deficiencies, viz.
//
@creachadair
creachadair / poke.md
Last active June 29, 2019 02:26
Informal survey of Seattle poke

An Informal Survey of Seattle Poke

TODO: Price data.

Tried so far:

  • 45th Stop N Shop & Poke Bar, 2323 N 45th St, Seattle, WA 98103.

    Notes: Quick friendly service, very good fish, and a tasty combination of ingredients. And they have unagi. The main downside is that you don't get to pick what goes in your bowl (though there are addons like avocado), but their defaults are all things I like anyway. Note that at busy times, there can be a line out the door. Be aware also that the poke service is closed during the 3–5pm window, though the rest of the store is open and has a nice selection of sake, mochi, pocky, ice cream, and other interesting stuff.

@creachadair
creachadair / gnupg-tags.md
Created May 26, 2019 23:42
Signing git tags with gnupg

To cryptographically sign a tag, you need to have gpg installed and either have a secret key matching your configured user/e-mail, or define user.signingkey in the git config for your repository.

Assuming you have done this, write

git tag -s -m "description" tagname

This may still fail if gpg is unable to figure out how to prompt you for your passphrase. In that case, verify that gpg-agent is running, and that GPG_TTY is set correctly.

@creachadair
creachadair / bayes-spam.pdf
Last active June 29, 2019 02:21
Bayesian Classification of Unsolicited E-Mail (PDF)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@creachadair
creachadair / dependency-hacking.md
Last active July 5, 2019 14:35
Accurate reverse package dependencies for Go

Accurate reverse package dependencies for Go

Idea: Read each repository on GitHub (et al.) with Go code. Maybe limit this to repositories with a go.mod file, maybe not. You can't get this from the godoc.org API because imports are only updated when you visit the importer, and if nobody does that the imports don't change (you can verify this by checking cases you know of manually and reloading to watch the counter go up).

Use go list ./... to list all the import paths of all the packages, and find the import paths of all packages depended upon by each one.

Build a matrix of: depends-on(x ipath) : [ipath]

Include version numbers maybe, if they're available (e.g., from a go.mod file).

@creachadair
creachadair / python-packages.md
Created July 5, 2019 18:27
Mining Python package dependencies
(defun format-buffer-hujson ()
"Format the current buffer contents as HuJSON (JWCC)."
(interactive)
(let* ((outbuf (generate-new-buffer "hujsonfmt" t))
(ecode (call-shell-region
(point-min) (point-max) "hujsonfmt" nil outbuf)))
(if (= ecode 0)
(progn
(replace-buffer-contents outbuf)
(kill-buffer outbuf)))))
@creachadair
creachadair / bailout.md
Created August 13, 2019 21:58
Bank bailouts

Bank Bailouts Since the Great Depression

An incomplete list.

Amounts in US dollars at the year of issue. See https://www.usinflationcalculator.com for current values.

  • 1974: Franklin National Bank. $1.75B loan.
  • 1984: Continental Illinois National Bank & Trust Co. ~$4.6B FDIC rescue package.
  • 1989: Savings & Loans. ~$142B Financial Institutions Reform Recovery and Enforcement Act.
  • 2008: Housing and Economic Recovery Act of 2008.