Skip to content

Instantly share code, notes, and snippets.

View statico's full-sized avatar

Ian Langworth ☠ statico

View GitHub Profile
@statico
statico / handle-oversight.sh
Last active December 19, 2023 22:59
Automatically control a Logitech Litra when the macOS camera is turned on/off
#!/usr/bin/env bash
if [[ "$@" == *"camera -event on"* ]]; then
$HOME/bin/litra light
fi
if [[ "$@" == *"camera -event off"* ]]; then
$HOME/bin/litra dark
fi
@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