Skip to content

Instantly share code, notes, and snippets.

@lamchau
lamchau / pmset.json
Created February 16, 2025 21:12
lnav for pmset -g log
{
"pmset": {
"_______": "/Users/$USER/.config/lnav/formats/installed",
"$schema": "https://lnav.org/schemas/format-v1.schema.json",
"title": "macOS pmset",
"description": "format for macOS power management setting logs",
"timestamp-format": [
"%Y-%m-%d %H:%M:%S %z"
],
"regex": {
@lamchau
lamchau / set-wezterm-color-scheme.sh
Last active January 17, 2025 03:50
utility to set wezterm color schemes using a fuzzy selector
#!/usr/bin/env bash
# HACK: edit config[1] location until `wezterm config` or `wezterm debug` is
# exposed for programmatic access.
# [1]: https://github.com/wez/wezterm/issues/4238
config_file="$XDG_CONFIG_HOME/wezterm/wezterm.lua"
script_dir="$(dirname "$(realpath "$0")")"
color_scheme_cache="$script_dir/color_schemes.txt"
one_day_in_seconds=$((24 * 60 * 60))
@lamchau
lamchau / slang.md
Last active August 23, 2024 21:52
*according to chat gpt
Gen Z Slang Millennial Equivalent Gen X Equivalent Baby Boomer Equivalent
skibidi cool dance move breakdancing jitterbug
cringe awkward awkward embarrassing
slay nailed it rocked it did a great job
bruh dude man pal
it's giving it looks like it seems it resembles
___ vibes ___ feels ___ feeling ___ atmosphere
yooo (fr) hey hey hello
fam

Log File Navigator (Optional)

lnav is a log file navigator that is capable of reading and analyzing log files in real time. It is a terminal application and is the a robust tool for navigating and analyzing log files.

It's similar to multitail but more powerful more discoverable UX.

Some notable features:

  • Creates a unified view across multiple formats and types (e.g. JSON, syslog + ftl and temporal).
@lamchau
lamchau / README.md
Last active February 29, 2024 12:18
lnav.org logging definition for https://github.com/tbd54566975/ftl

Usage

For usage with lnav allowing for consolidated/colored logs with FTL

Installation

curl \
  --silent \
  --output $XDG_CONFIG_HOME/lnav/formats/installed/ftl_json.json \
@lamchau
lamchau / list-aws-creds.py
Created February 29, 2024 10:29
Convert AWS credentials into an easier format ot script with.
#!/usr/bin/env python3
from __future__ import annotations
import argparse
import configparser as ConfigParser
import json
import re
from enum import Enum
from pathlib import Path

extracted via dotfiles commit

fish: wrap/split funced to avoid temp files

By design, funced uses a temporary file to make changes to functions. While this is useful so users don't overwrite key functionality in share/fish/functions ensuring the edited function can be parsed by fish. However, this adds friction (e.g. save, exit, load, run) during

@lamchau
lamchau / dev-watch-select.sh
Created December 13, 2023 23:13
`jest` runner for multiple disparate ts[x] files
#!/usr/bin/env bash
script_name="${0##*/}"
# By default `fzf` uses `find`, try using one of the options listed here
# https://github.com/junegunn/fzf#tips to ignore .gitignore files
check_fzf_default_command() {
if [ -x "$(command -v gfind)" ]; then
export FZF_DEFAULT_COMMAND='gfind . -path "*__tests__*" -iname "*.ts" -o -path "*__tests__*" -iname "*.tsx"'
else
@lamchau
lamchau / render-fonts.sh
Last active October 15, 2023 06:10
render all available `toilet` fonts
#!/usr/bin/env bash
# macOS/homebrew:
# - hardcoded via `man` -> /opt/homebrew/Cellar/toilet/0.3/share/figlet
# - dynamic: `ls $(realpath $(which toilet)"/../../share/figlet")`
# Linux: /usr/share/figlet
# render fonts using their own name
find "$1" -type f |
sort -V |
@lamchau
lamchau / google-meet-chat.js
Last active April 4, 2024 23:27
capture messages from google meet chat log (as a JSON blob)
(() => {
const CURRENT_USER_NAME = document.querySelector('.dwSJ2e');
const $messages = Array.from(document.querySelectorAll('.Ss4fHf'));
const messages = $messages
.map($element => {
const time = $element.querySelector('.MuzmKe').innerText;
const author = $element.querySelector('.poVWob').innerText;
const lines = Array.from($element.querySelectorAll('.ptNLrf')).map(x => x.innerText);
// duplicate fields rapid successive messages for easier formatting
return lines.map(message => ({