Skip to content

Instantly share code, notes, and snippets.

@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 / README.rst
Last active March 26, 2024 05:35
[Chrome/Tampermonkey] Extract *.user.js scripts from LevelDB backup

Restoring Tampermonkey scripts

Chrome stores .user.js scripts in a .ldb, which isn't in a user accessible format to recovery. On some versions of macOS the provided python script can't compile the leveldb package. As a workaround, we can use the node level package to recover our userscripts.

Prerequisite

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 |
#!/usr/bin/env python3
import argparse
import datetime
import json
import logging
import os
import re
import requests
import sys
const triggerMouseEvent = (node, eventType) => {
const clickEvent = document.createEvent('MouseEvents');
clickEvent.initEvent(eventType, true, true);
node.dispatchEvent(clickEvent);
};
const clapButton = document.querySelector('[aria-label="clap"]').parentNode;
const click = button => {
triggerMouseEvent(button, 'mousedown');
triggerMouseEvent(button, 'mouseup');
};