Skip to content

Instantly share code, notes, and snippets.

Avatar

Ian Langworth ☠ statico

View GitHub Profile
@statico
statico / light-off
Last active Aug 18, 2022
Control Logitech Litra with Raycast
View light-off
#!/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 Jun 15, 2022
angular bug: An unhandled exception occurred: Object prototype may only be an Object or null: undefined
View 00_README.md

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 Apr 13, 2022
Autocrop shortcut for macOS Finder
View README.md
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
Last active Apr 2, 2022
Automatically build a publish a Docker container image to GitHub Container Registry on every push for free, like how Docker Hub used to work
View 00_README.md
View github-project-sorter.js
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 Feb 28, 2022
ian's xbar icon
View ian.1m.sh
#!/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 Feb 13, 2022
Next.js API route helpers
View api-helpers.ts
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)
View useModals.tsx
import React, {
createContext,
ReactNode,
useCallback,
useContext,
useRef,
useState,
} from "react"
import {
Button,
@statico
statico / cloudWatchAlarmsToSlack.js
Created Jan 19, 2022
Lambdas for Slack Notifications
View cloudWatchAlarmsToSlack.js
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))