Skip to content

Instantly share code, notes, and snippets.

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 => ({
@lamchau
lamchau / smartsheet.user.js
Last active September 4, 2021 07:17
Due to how smartsheet handles seat licensing when publishing 'read only' reports they add CSS/JS to prevent selection of text or right-clicking on the page. This seems too restrictive so using this script in conjunction with Tampermonkey should enable this behavior again.
// ==UserScript==
// @name Smartsheet - Enable text selection and context menu clicks
// @version 1.1
// @author lamchau
// @description Enables text selection and context menu clicks from published Smartsheets
// @updateUrl https://go/smartsheet-hack
// @match https://app.smartsheet.com/b/publish?*
// @icon https://www.google.com/s2/favicons?domain=smartsheet.com
// @run-at document-end
// ==/UserScript==
from typing import Union, Callable
import types
# 3p libraries
from dateutil.relativedelta import relativedelta # type: ignore
from visidata import Sheet, Column, SettableColumn, asyncthread, vd # type: ignore
import pandas as pd # type: ignore
def get_frequency(column: Column,
/**
* 1. [If not owner] Create a copy of the Google Documents link
* 2. Publish to web
* 3. [Chrome] Inspect page
* 4. Open Developer Console
* 5. Paste script below
* 6. From clipboard, paste to $EDITOR
* 7. Optional: Open multiple URLs Chrome extension
* - https://chrome.google.com/webstore/detail/open-multiple-urls/oifijhaokejakekmnjmphonojcfkpbbh
*/