Skip to content

Instantly share code, notes, and snippets.

View trptcolin's full-sized avatar

Colin Jones trptcolin

View GitHub Profile
// Package secret provides encrypt/decrypt functionality with a string-oriented API.
//
// The design choice to use strings is purely for ease of API use, almost certainly not a good idea.
// To be clear, this thing is not intended for production use, just for poking around the Go ecosystem.
// In particular, there are performance implications with all the stringification, and I wouldn't trust the error handling.
// There may be additional / worse issues too!
//
// Uses `golang.org/x/crypto/nacl/secretbox` for the actual cryptography, and `encoding/base64` to round-trip into strings.
package secret
@trptcolin
trptcolin / dispqlen.d
Last active August 21, 2019 01:53
OSX DTrace scripts that didn't work as shipped (run queue related)
#!/usr/sbin/dtrace -s
/*
* dispqlen.d - dispatcher queue length by CPU.
* Written using DTrace (Solaris 10 3/05).
*
* 14-Feb-2006, ver 0.90
*
* USAGE: dispqlen.d # hit Ctrl-C to end sample
*
* NOTES: The dispatcher queue length is an indication of CPU saturation.
@trptcolin
trptcolin / runq.d
Last active August 21, 2019 01:52
A DTrace script to print the average, min, and max run queue count by CPU
#!/usr/sbin/dtrace -s
/*
* runq.d - run queue sizes by CPU.
*
* This prints the average, min, and max run queue count by CPU each second. A
* consistently large run queue count is a sign of CPU saturation.
*
* USAGE: runq.d
*
* FIELDS:

TL;DR: what was the bug? (spoilers!): https://gist.github.com/trptcolin/6039cd454acfe6e820d13cbdce5e4064

Recap

Details / How

[colin:/tmp] $ node --version
v11.14.0
[colin:/tmp] $ node /tmp/sample.js
internal/process/stdio.js:164
stream = new tty.WriteStream(fd);
^
TypeError: tty.WriteStream is not a constructor
at createWritableStdioStream (internal/process/stdio.js:164:16)
at process.getStdout [as stdout] (internal/process/stdio.js:33:14)
defmodule MyApp.Router do
use MyApp, :router
use Plug.ErrorHandler
use Sentry.Plug
alias MyApp.ScrubError
defp handle_errors(conn, %{kind: _kind, reason: _reason, stack: _stack} = error) do
updated_error = ScrubError.call(error)
super(conn, updated_error)
@trptcolin
trptcolin / readme.txt
Created September 22, 2018 20:49
Zombie Invasion (PuzzleScript Script)
Play this game by pasting the script in http://www.puzzlescript.net/editor.html
@trptcolin
trptcolin / readme.txt
Created September 22, 2018 20:49
Zombie Invasion (PuzzleScript Script)
Play this game by pasting the script in http://www.puzzlescript.net/editor.html
@trptcolin
trptcolin / readme.txt
Created September 22, 2018 20:46
Zombie Invasion (PuzzleScript Script)
Play this game by pasting the script in http://www.puzzlescript.net/editor.html