Skip to content

Instantly share code, notes, and snippets.

View statico's full-sized avatar

Ian Langworth ☠ statico

View GitHub Profile
{
"name": "xxxxx",
"version": "1.0.0",
"license": "UNLICENSED",
"private": true,
"scripts": {
"format": "prettier --write .",
"prepare": "husky install",
"lint": "pnpm -r lint --fix",
"types:check": "pnpm -r types:check",
@statico
statico / tricks.md
Created July 26, 2012 23:05
Mac OS X Tricks

Switch between workspaces instantly with Ctrl-1, Ctrl-2, Ctrl-3, etc.

defaults write com.apple.dock workspaces-swoosh-animation-off -bool YES && killall Dock

Disable the "Application X has crashed" dialog

defaults write com.apple.CrashReporter DialogType none

Allow Screen Sharing (Cmd-K in Finder) to connect to vnc://localhost/

@statico
statico / gpu.cpp
Last active January 25, 2024 01:06
Trick to tell AMD and Nvidia drivers to use the most powerful GPU instead of a lower-performance (such as integrated) GPU
#ifdef _WIN32
// Use discrete GPU by default.
extern "C" {
// http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
// http://developer.amd.com/community/blog/2015/10/02/amd-enduro-system-for-developers/
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
#endif
@statico
statico / FCC-ULS-Postgres.md
Last active January 19, 2024 06:05
Put the FCC amateur radio license data into a PostgreSQL database

Here's how I put the FCC Universal Licensing System (ULS) data into a local database so I could find a vanity call sign.

  1. On the FCC ULS Databases page:
  2. Grabbed "Amateur Radio Service" -> "Licenses" -> l_amat.zip (133 MB when I wrote this)
  3. Reviewed the "Introduction to the ULS public access database files", which told me that HD.dat is the file I want
  4. Reviewed "Database Field Definitions", searched for HD, and turned that table into the schema below
  5. Converted the data to UTF8 with iconv -f latin1 -t utf-8 <HD.dat >HD.dat.utf8
  6. Ran psql -f schema.sql to create the table and import the data

Notes

@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 / 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,
@statico
statico / index.js
Last active October 18, 2023 20:48
Simple AWS ECS status update notifications to Slack webhook
/*
Want to know when ECS events happen in Slack? Try this.
(1) Create a new Slack app with an incoming webhook, save the webhook URL
(2) Create an SNS topic called something like ECSEvents
(3) Create a CloudWatch Rule that publishes all ECS events to the topic
(4) Create a Node.js Lambda that is triggered by the SNS topic
(5) Add a WEBHOOK_URL environment variable to the Lambda with the webhook URL
(6) Paste this code into index.js
(7) Paste the contents of https://unpkg.com/node-fetch/lib/index.js into fetch.js
(8) Deploy and enjoy
@statico
statico / 00_statico.link_README.md
Last active September 24, 2023 12:15
Ian's Personal Short Link Bookmark Service
@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 --&gt;|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.