Skip to content

Instantly share code, notes, and snippets.

View statico's full-sized avatar

Ian Langworth ☠ statico

View GitHub Profile
@statico
statico / policy.json
Created April 25, 2023 22:06
Metabase Athena Policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"athena:StartQueryExecution",
"athena:ListDataCatalogs",
"glue:GetTableVersions",
@statico
statico / index.mjs
Created April 17, 2023 19:33
sanity blog backup to lambda (not working because of --raw)
/*global fetch*/
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
const client = new S3Client({});
export const handler = async (event) => {
const projectId = process.env.SANITY_PROJECT_ID
const dataset = process.env.SANITY_DATASET
const token = process.env.SANITY_TOKEN
@statico
statico / 01-minimal-seed.ts
Created January 30, 2023 18:52
Jest + Node.js + Postgres testing pipeline
import { Knex } from "knex"
export async function seed(knex: Knex): Promise<void> {
// Delete order is specific because of foreign key references
await knex.delete().from("...")
await knex("users").insert(TestUsers)
...
await knex.raw("refresh materialized view ...")
@statico
statico / smallify.sh
Last active January 11, 2023 23:22
Use gifsicle to resize GIFs for Slack emoji
#!/usr/bin/env bash
set -eo pipefail
srcdir="$1"
if [ -z "$srcdir" ]; then
echo "usage: $0 <dir>"
exit 1
fi
@statico
statico / light-off
Last active August 18, 2022 16:04
Control Logitech Litra with Raycast
#!/usr/bin/env bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Logitech Litra Glow Light Off
# @raycast.mode silent
$HOME/bin/litra dark
@statico
statico / 00_README.md
Last active June 15, 2022 20:23
angular bug: An unhandled exception occurred: Object prototype may only be an Object or null: undefined

we have a project that’s using Node v12 and Angular 7. when i try to build the project with ng build i get An unhandled exception occurred: Object prototype may only be an Object or null: undefined

lots of people on the internet have this problem. there are a few dozen stackoverflow answers, and there are issues on both webpack and typescript the blame each other. it seems to have something to do with circular dependencies, but i’ve run madge --circular --extensions ts ./ which claims to find circular deps but it says none are found. in fact, if i delete all of the page source code other than the entry point, the error still occurs. so this seems to be a bug with the angular build system. i’ve hooked up a debugger and tried to step through the stack but i haven’t found anything useful.

a lot of people say “ok, run ng update.” well, that doesn’t seem to do anything useful. i’ve tried updating to just node v14 and v16, i’ve tried running node-check-updates to update dependencies. warping ahead to Angu

@statico
statico / README.md
Created April 13, 2022 19:10
Autocrop shortcut for macOS Finder
for f in "$@"; do
    cp "$f" /tmp/image
    /opt/homebrew/bin/convert /tmp/image -trim +repage "$f"
done

CleanShot 2022-04-13 at 12 10 44

@statico
statico / 00_README.md
Created April 5, 2022 18:50
Controlling the Logitech Litra on MacOS
@statico
statico / 00_README.md
Last active April 2, 2022 02:48
Automatically build a publish a Docker container image to GitHub Container Registry on every push for free, like how Docker Hub used to work
const { graphql } = require("@octokit/graphql")
const REPO_OWNER = "xxxxxx"
const REPO_NAME = "xxxxxx"
const PROJECT_NUMBER = 2
const COLUMN_TO_SORT = /To Do/
const api = graphql.defaults({
headers: {
authorization: `token ${process.env.GITHUB_TOKEN}`,