Skip to content

Instantly share code, notes, and snippets.

View statico's full-sized avatar

Ian Langworth ☠ statico

View GitHub Profile
@statico
statico / 01_setup.md
Last active September 19, 2023 20:40
Ian's Office Setup

Ian's Office Setup 2023

flowchart TD
    Mac((MacBook Pro)) -->|USB-C/Thunderbolt| Dock(Thunderbolt Dock)
    PC((Windows PC)) -->|DP| Monitor
    Dock -->|HDMI/DP| Monitor
    Backup(Backup drive) -->|USB| Dock
    Net(Network Switch) -->|Cat7| Dock
 Net -->|Cat7| PC
@statico
statico / PressableWithAnimation.jsx
Created September 18, 2023 02:07
Simple Pressable with Opacity component for React Native
/**
* Why?
*
* Pressable is the newer and superior component in React Native for buttons.
* It has a built in affordance for near-misses and, most importantly, it
* doesn't respond or show an animation while the user is dragging.
*
* However, Pressable doesn't have any feedback, like TouchableOpacity. This
* simple component adds the animation you want *when* the user is actually
* committed a press. This is how, for example, the official Facebook app works.
@statico
statico / db.ts
Created September 12, 2023 23:10
Configure Sentry performance tracing because the default integration doesn't work
// Configure Sentry performance tracing because the default Postgres integration doesn't work with Knex:
// https://github.com/getsentry/sentry-javascript/blob/main/packages/tracing-internal/src/node/integrations/postgres.ts
const sentrySpans = new Map<string, Span>()
db.on("query", (query: any) => {
const span = Sentry.getActiveSpan()?.startChild({
op: "db.query",
description: query.sql,
})
if (span) sentrySpans.set(query.__knexQueryUid, span)
})
@statico
statico / index.mjs
Created May 28, 2023 03:11
AWS Kinesis Firehose + S3 bucket to ClickHouse import Lambda
/*global fetch*/
import { S3Client, GetObjectCommand } from '@aws-sdk/client-s3'
const s3 = new S3Client({ region: 'us-east-2' })
export const handler = async (event, context) => {
// console.log('Received event:', JSON.stringify(event, null, 2))
const bucket = event.Records[0].s3.bucket.name
@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