Skip to content

Instantly share code, notes, and snippets.

View aleph-naught2tog's full-sized avatar

Max Cerrina aleph-naught2tog

View GitHub Profile
# Transient
# The intent here is that a Reissue has been started but nothing has happened
Blank
cancel -> Void
listen -> Accepting
# End
# When a Reissue is voided, nothing happens policywise
Void
Open
cancel -> Void
add change -> Editing
# End
Void
Editing
cancel -> Void
Valid
@aleph-naught2tog
aleph-naught2tog / prettySortByKeys.js
Created June 3, 2019 13:29
Sort an object by keys
const sortByKeysLegibly = maybeObject => {
// presumably we want the array to stay ordered. Possibly not, but if there is
// anything that should preserve order, it's an array
if (maybeObject instanceof Array) {
return maybeObject;
}
// don't sort strings etc
if (typeof maybeObject !== 'object') {
return maybeObject;
class SuperClass {
nonarrow() {
console.log('nonarrow', 'superclass');
}
arrow = () => {
console.log('arrow', 'superclass');
}
}
@aleph-naught2tog
aleph-naught2tog / sigils.js
Created April 30, 2019 00:36
Template tags
/*
Some languages, like Elixir, have sigils -- things that often look like a ~, a letter, and then some delimiters
with a string between them.
One handy one is: `~w` -- in Elixir, you can look it up in the Kernel as `sigil_w`.
*/
// this is a one-liner of the function in the earlier file
const basicTag = (slots, ...values) => slots.map((slot, index) => [slot, values[index]].join('')).join('');
function w(pieces, ...values) {
@aleph-naught2tog
aleph-naught2tog / keys.json
Created April 30, 2019 00:14
Standard keys arranged like a keyboard
{
"keysAsKeyboard": [
[
"~ ! @ # $ % ^ & * ( ) _ +",
"` 1 2 3 4 5 6 7 8 9 0 - ="
],
[
"Q W E R T Y U I O P { } |",
"q w e r t y u i o p [ ] \\"
],
@aleph-naught2tog
aleph-naught2tog / tsconfig.json
Created April 28, 2019 18:37
tsconfig without explanatory comments (version 3.4.4)
{
"compilerOptions": {
/* Basic Options */
"target": "es5",
"module": "commonjs",
// "lib": [],
// "allowJs": true,
// "checkJs": true,
// "jsx": "preserve",
// "declaration": true,
@aleph-naught2tog
aleph-naught2tog / foreign_key_references.sh
Created April 19, 2019 14:42
Find all the tables that reference a given table
#!/bin/bash
table_to_check_references_to='table_name'
database_name='dbname'
query=$(cat <<SQL
SELECT
table_constraints.table_schema,
table_constraints.constraint_name,
table_constraints.table_name,
@aleph-naught2tog
aleph-naught2tog / about.md
Created April 14, 2019 20:11
WebSocket header encoding (key, accept)

Generating the Sec-WebSocket-* headers

The functions included are for generating the base64-encode of a sha1 hash of the input string sent in as an argument.

About

This is the mechanism for processing something to be used as the header for either the Sec-WebSocket-Key request header or Sec-WebSocket-Accept response header in the websocket opening handshake.

To generate the Sec-WebSocket-Key, you would use generateRandomBase64String; for the matching Sec-WebSocket-Accept header value, you would use base64EncodeOfSha1Hash(keyConcatenatedWithMagicString).

@aleph-naught2tog
aleph-naught2tog / pairs_array.txt
Created March 31, 2019 04:00
Example Sec-WebSocket-Key, Sec-WebSocket-Accept pairs for testing
[
["xqBt3ImNzJbYqRINxEFlkg==", "K7DJLdLooIwIG/MOpvWFB3y3FE8="],
["AQIDBAUGBwgJCgsMDQ4PEC==", "OfS0wDaT5NoxF2gqm7Zj2YtetzM="],
["dGhlIHNhbXBsZSBub25jZQ==", "s3pPLMBiTxaQ9kYGzzhZRbK+xOo="],
["bLqBK0TPRX06acXKoTMg0w==", "PUOv+s9LKpmD8Eqd/JHHU3/0+ts="],
["cGtZLupHO2Ng7bTySyqJAg==", "7PZjZ/xia21YsFgao3D7dGKk/nk="],
["T3CQ1QBhwQU+ART28dF1lg==", "nVnvAbc8RUGnQU+7M+SrTTBmXlA="],
["A4soB7HbG+RDb/0K4pOfQQ==", "6hlHUdFX8bFPzGrYhEd5DrkgeZY="],
["IUe1bWHff0Oe6/6Kwz0S7g==", "YNvyb2r1JRBDCxcvgvbpZwMinqA="],
["ZcifuDaMvDry71n+ffJZIQ==", "yk/8ZCjP66vVy8oQz50cxQofOWc="],