This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Generate a `:something-intensifies:` Slack emoji, given a reasonable image | |
# input. I recommend grabbing an emoji from https://emojipedia.org/ | |
set -euo pipefail | |
# Number of frames of shaking | |
count=10 | |
# Max pixels to move while shaking |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
from base64 import b64decode | |
from hashlib import sha1 | |
cert = sys.stdin.read() | |
lines = cert.splitlines() | |
assert lines[0] == '-----BEGIN CERTIFICATE-----' | |
assert lines[-1] == '-----END CERTIFICATE-----' | |
data_lines = lines[1:-1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT table_schema, | |
TABLE_NAME, | |
pg_size_pretty(SIZE) AS SIZE, | |
pg_size_pretty(total_size) AS total_size | |
FROM | |
(SELECT table_schema, | |
TABLE_NAME, | |
pg_relation_size(quote_ident(table_schema) || '.' || quote_ident(TABLE_NAME)) AS SIZE, | |
pg_total_relation_size(quote_ident(table_schema) || '.' || quote_ident(TABLE_NAME)) AS total_size | |
FROM information_schema.tables |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- See https://www.postgresql.org/docs/current/sql-copy.html | |
-- and https://www.postgresql.org/docs/current/sql-insert.html | |
CREATE TEMP TABLE temp_table | |
(LIKE table INCLUDING DEFAULTS) | |
ON COMMIT DROP; | |
COPY temp_table (col1, col2, ...) FROM STDIN WITH CSV; | |
-- Assumes no header row: add `HEADER` if it has one. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXAW+z0e/p/EprRzUK5hzVRBgoMQUetUzYQVsmov+rpUDQdTGJVWMy86vCarbpO5s5rSHEnB/qXA9MDu+8nyciG2pIW6oJ2U2ZKC/ORetGEbXYfVJZnd82G9HDzIFztMTKXmqBP0kvlY4NIx1OlHx00WZfDhJ+9IQyvPppFu/NKEQRlT1gPusVf6thgPS7GYNi7JlJLwhS4KrYICYBr8Sq1V5ihw647E7Vm4RqZWKA0DF7u0aJlv/bideD5FAeJch8hJaxFQYjvqJsmr56vw+a/VUDTPk9/0QfyyTwvGP9D7+xKnBWnP5i6QFu+BsmOpAvarTUbETbmnGkyL0CNLM7 frederick@orthanc 2015-11-01 | |
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC+WsRX9UQZDTOU1ZYRXNdl/ZCGhW7rUDErmWxHBhcpIQj7bcf/VUN6r/RPwWzYF3GfJ8ql7c6fDNdBWavI10TYULQBajJkLVhBCyfzq9IixG3FImFLKVc7ZfovSTcUCWaA1uw+WZeQ9vy9bSK5s2HDbOcV+l34u1L43OGpOjYRosipDuXteeN14OKUydzHw3W/ei9Rt4rzo8oZqDHwYTTRZuylxVjKt3oh5u1A/ZNHmhh7Xc+y4NCQaEmeQIYocTZFbGBirzGrn9l0+/sc5lTX7m7/uoMwDIEJjF3gvbWURKlbA+P6+37mn0CwGUmm1fe3xe9zT812Ed3QfW5O9PaAdaf2PwLEBEmXLxLeLDPOk2hebdYOXX3ucsanWpIvioowpRxV4264JVKHleGYlTMXNu0NSTs6sMib2ybIogt81+eLKq9Iquih6TWayjhD+QNRv0B/r6Es/tyVz+aQvRwOzQLGxMkP7GpFrJ497DtHP8tgaBixWAGPHw8ICOav7s0CfCVfcCh1X5ub+Q5B7+W0tEB6JLJVttYvWiqXqQIwu6EoEIXuG65PUjblhtHunT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import lru_cache | |
from types import FunctionType | |
def cache(func): | |
return lru_cache(maxsize=None)(func) | |
class Vector(tuple): | |
# [small brain] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dill | |
x = 1 | |
def print_globals(max_value_len=79): | |
""" | |
>>> print_globals(40) # doctest: +ELLIPSIS | |
globals: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Slack's new WYSIWYG format broke copy/pasting multiline code blocks: | |
blank lines are omitted when pasting as plain text. | |
If you can get the HTML contents of the clipboard, this script can | |
output the expected text, blank lines and all. | |
The macOS clipboard is complicated, and the built-in `pbpaste` command | |
won't let you get the contents as HTML. (The `-Prefer` option seems to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some surprising comparison behaviors in Python 2. | |
You can confirm these behaviors via doctest: | |
python2 -m doctest python2-wyd | |
Careful, though: some of the results change if the filename is more than | |
13 characters long. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Example usage: | |
In [1]: !cat ayy.s | |
.text | |
.global _start | |
.type _start, @function | |
_start: | |
movq $10, %rdx | |
pushw $10 |
NewerOlder