Skip to content

Instantly share code, notes, and snippets.

View statico's full-sized avatar

Ian Langworth ☠ statico

View GitHub Profile
@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}`,
@statico
statico / ian.1m.sh
Created February 28, 2022 17:36
ian's xbar icon
#!/usr/bin/env bash
export PATH="$HOME/bin:$PATH"
iface="$(route get 1.1.1.1 2>/dev/null | grep interface | perl -ple 's/\s*interface:\s*//')"
if [ $? != 0 ]; then
iface="n/a"
fi
case "$iface" in
@statico
statico / api-helpers.ts
Created February 13, 2022 04:12
Next.js API route helpers
import { encode } from "html-entities"
import { getReasonPhrase, StatusCodes } from "http-status-codes"
import stringify from "json-stringify-safe"
import { NextApiResponse } from "next"
// Semantic sugar for returning various status codes, optionally with messages.
export const statusHelper = (res: NextApiResponse) => ({
codes: StatusCodes,
status(code: number, message?: string): void {
const phrase = getReasonPhrase(code)
@statico
statico / useModals.tsx
Created February 10, 2022 04:09
useModals.tsx
import React, {
createContext,
ReactNode,
useCallback,
useContext,
useRef,
useState,
} from "react"
import {
Button,
@statico
statico / cloudWatchAlarmsToSlack.js
Created January 19, 2022 21:20
Lambdas for Slack Notifications
const fetch = require('./fetch')
const RED = '#cd3131'
const YELLOW = '#e5e512'
const GREEN = '#05bc79'
const BLUE = '#2472c8'
exports.handler = async function(event, context) {
// Debugging
// console.log('event', JSON.stringify(event, null, 2))
@statico
statico / Dockerfile
Last active November 3, 2022 15:54
Push-to-deploy architecture using AWS Fargate and GitHub Actions
# ------------------------------
# * Dependencies
FROM node:16.13.0-alpine3.14 AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
@statico
statico / useModals.tsx
Created December 19, 2021 18:26
Chakra UI await-able alert, confirm, and prompt modal dialogs
/*
* Usage:
* const { alert, confirm, prompt } = useModals()
* alert("Hey!") // awaitable too
* if (await confirm("Are you sure?")) ...
* const result = await prompt("Enter a URL", "http://")
*/
import React, {
createContext,